diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -670,6 +670,7 @@ SRCS += oldloader.c SRCS += openttd.c SRCS += order_cmd.c SRCS += order_gui.c +SRCS += os_timer.c SRCS += pathfind.c SRCS += player_gui.c SRCS += players.c diff --git a/debug.h b/debug.h --- a/debug.h +++ b/debug.h @@ -26,4 +26,27 @@ void CDECL debug(const char *s, ...); void SetDebugString(const char *s); const char *GetDebugString(void); +/* MSVC of course has to have a different syntax for long long *sigh* */ +#ifdef _MSC_VER +# define OTTD_PRINTF64 "I64" +#else +# define OTTD_PRINTF64 "ll" +#endif + +// Used for profiling +#define TIC() {\ + extern uint64 _rdtsc(void);\ + uint64 _xxx_ = _rdtsc();\ + static uint64 __sum__ = 0;\ + static uint32 __i__ = 0; + +#define TOC(str, count)\ + __sum__ += _rdtsc() - _xxx_;\ + if (++__i__ == count) {\ + printf("[%s]: %" OTTD_PRINTF64 "u [avg: %.1f]\n", str, __sum__, __sum__/(double)__i__);\ + __i__ = 0;\ + __sum__ = 0;\ + }\ +} + #endif /* DEBUG_H */ diff --git a/functions.h b/functions.h --- a/functions.h +++ b/functions.h @@ -116,12 +116,6 @@ static inline TileIndex RandomTile(void) uint32 InteractiveRandom(void); /* Used for random sequences that are not the same on the other end of the multiplayer link */ uint InteractiveRandomRange(uint max); - -// Used for profiling -#define TIC() { extern uint32 _rdtsc(void); uint32 _xxx_ = _rdtsc(); static float __avg__; -#define TOC(s) _xxx_ = _rdtsc() - _xxx_; __avg__=__avg__*0.99+_xxx_*0.01; printf("%s: %8d %f\n", s, _xxx_,__avg__); } - - void SetDate(uint date); /* facedraw.c */ void DrawPlayerFace(uint32 face, int color, int x, int y); diff --git a/openttd.dsp b/openttd.dsp --- a/openttd.dsp +++ b/openttd.dsp @@ -339,6 +339,12 @@ SOURCE=.\ottdres.rc # End Source File # Begin Source File +SOURCE=.\os_timer.c +# End Source File +# Begin Source File + +# Begin Source File + SOURCE=.\pathfind.c # End Source File # Begin Source File diff --git a/openttd.vcproj b/openttd.vcproj --- a/openttd.vcproj +++ b/openttd.vcproj @@ -299,6 +299,9 @@ RelativePath=".\ottdres.rc"> + +