Hi,
I cannot compile git pull e5827e997a9d6ce4283c7b660079a3c5db706244 under linux. The problems seems to originate with path_explorer. First of all there is a simple typo on line 11 which causes a necessary header file not to be included:
#include <string>
should be
#include <string.h>
The greater problem is the inclusion of <mmsystem.h>, which is not under any win32 ifdef in simsys_s.h (line 38) I am not an expert but I thought this was a windows specific header? Moving the line
#include <mmsystem.h>
to line 27 (inside the #ifdef _WIN32) does not help since it seems that a lot of called functions then are unavailable.
There is also a problem with the following (gcc-output:)
path_explorer.h: In destructor ‘path_explorer_t::halthandle_sorted_heap_t::~halthandle_sorted_heap_t()’:
path_explorer.h:52: error: ‘free’ was not declared in this scope
This is probably connected to simmem.h:10-15
#ifdef _MSC_VER
# include <malloc.h>
# define guarded_free free
#else
void guarded_free(void* ptr);
#endif
Here I gave up...
--
OS debian/squeeze - gcc 4.3.3
config.template: linux, sdl, colour_depth=16, debug =3
What I did to make it compile:
Change the string to string.h
Commented out the mmsystem.h (Too lazy to move it)
Commented out all code that knightly added in simsys_s.cc, and uncommented SDL_GetTicks in dr_time() (Too lazy to place it in an ifdef, as far as I know SDL_GetTicks is good enough on linux/unix, Knightly please correct me if I'm wrong...)
Added path_explorer.cc to SOURCES in Makefile
For reference: complete patch
diff --git a/Makefile b/Makefile
index 0cf09c5..53edd4c 100644
--- a/Makefile
+++ b/Makefile
@@ -307,6 +307,7 @@ SOURCES += simware.cc
SOURCES += simwerkz.cc
SOURCES += simwin.cc
SOURCES += simworld.cc
+SOURCES += path_explorer.cc
SOURCES += sucher/platzsucher.cc
SOURCES += tpl/debug_helper.cc
SOURCES += unicode.cc
diff --git a/path_explorer.h b/path_explorer.h
index 0d55358..9cc0208 100644
--- a/path_explorer.h
+++ b/path_explorer.h
@@ -8,7 +8,7 @@
#ifndef path_explorer_h
#define path_explorer_h
-#include <string>
+#include <string.h>
#include "halthandle_t.h"
#include "convoihandle_t.h"
diff --git a/simsys_s.cc b/simsys_s.cc
index a514ad0..134e2c3 100644
--- a/simsys_s.cc
+++ b/simsys_s.cc
@@ -35,7 +35,8 @@
#include <string.h>
#include <stdlib.h>
#include <math.h>
-#include <mmsystem.h>
+//#include <mmsystem.h>
+#define LARGE_INTEGER uint64
#ifndef PATH_MAX
#define PATH_MAX (1024)
@@ -141,7 +142,7 @@ int dr_os_init(const int* parameter)
atexit(SDL_Quit); // clean up on exit
// Added by : Knightly
- if ( umgebung_t::default_einstellungen.get_system_time_option() == 0 )
+ /*if ( umgebung_t::default_einstellungen.get_system_time_option() == 0 )
{
// set precision to 1ms if multimedia timer functions are used
timeBeginPeriod(1);
@@ -156,7 +157,7 @@ int dr_os_init(const int* parameter)
umgebung_t::default_einstellungen.set_system_time_option(0); // reset to using multimedia timer
timeBeginPeriod(1); // set precision to 1ms
}
- }
+ }*/
return TRUE;
}
@@ -261,11 +262,11 @@ int dr_os_close(void)
// SDL_FreeSurface(screen);
// Added by : Knightly
- if ( umgebung_t::default_einstellungen.get_system_time_option() == 0 )
+ /*if ( umgebung_t::default_einstellungen.get_system_time_option() == 0 )
{
// reset precision if multimedia timer functions have been used
timeEndPeriod(1);
- }
+ }*/
return TRUE;
@@ -693,7 +694,7 @@ unsigned long dr_time(void)
{
// Modified by : Knightly
// declare and initialize once
- static LARGE_INTEGER t; // for storing current time in counts
+ /*static LARGE_INTEGER t; // for storing current time in counts
static LARGE_INTEGER f; // for storing performance counter frequency, which is fixed when system is running
static const bool support_performance_counter = ( QueryPerformanceFrequency(&f) != 0 );
@@ -707,10 +708,10 @@ unsigned long dr_time(void)
{
// Case : use multimedia timer functions
return timeGetTime();
- }
+ }*/
// Knightly : this function actually calls timeGetTime()
- // return SDL_GetTicks();
+ return SDL_GetTicks();
}
I don't know if it has anythhing to do with my "patch" but the path_explorer system crashes when creating a new line and starting the convoi
EDIT: as you may have guessed it is a division by zero...
Also it seems that it does not happen with busses but only with trucks (did not try trains or something else) (it is also possible it just does not happen everytime)
Hi Sanna and Nathan,
I am really sorry. It's my fault -- (1) I forgot to add path_explorer.cc to the Makefile (2) I forgot that SDL is used by versions of other platforms besides Windows, but I added some Windows-specific code, namely, performance counter.
I have already made the necessary changes and pushed them to my forked branch, and have also requested James to kindly merge my commits and pushed back to Github master repository.
Once again, very sorry about that!
As for the division by zero error, I will check it out to see what goes wrong.
Edit :
I have found out what caused the division by zero error. I will make another commit to fix it. Thanks for spotting this, Nathan.
Knightly