Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef DEBUG_H
00013 #define DEBUG_H
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifdef NO_DEBUG_MESSAGES
00030 #define DEBUG(name, level, ...) { }
00031 #else
00032
00037 #define DEBUG(name, level, ...) if ((level) == 0 || _debug_ ## name ## _level >= (level)) debug(#name, __VA_ARGS__)
00038
00039 extern int _debug_driver_level;
00040 extern int _debug_grf_level;
00041 extern int _debug_map_level;
00042 extern int _debug_misc_level;
00043 extern int _debug_net_level;
00044 extern int _debug_sprite_level;
00045 extern int _debug_oldloader_level;
00046 extern int _debug_npf_level;
00047 extern int _debug_yapf_level;
00048 extern int _debug_freetype_level;
00049 extern int _debug_script_level;
00050 extern int _debug_sl_level;
00051 extern int _debug_gamelog_level;
00052 extern int _debug_desync_level;
00053 extern int _debug_console_level;
00054 #ifdef RANDOM_DEBUG
00055 extern int _debug_random_level;
00056 #endif
00057
00058 void CDECL debug(const char *dbg, const char *format, ...) WARN_FORMAT(2, 3);
00059 #endif
00060
00061 void SetDebugString(const char *s);
00062 const char *GetDebugString();
00063
00064
00065 #define FILE_LINE __FILE__, __LINE__
00066
00071 uint64 ottd_rdtsc();
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 #define TIC() {\
00095 uint64 _xxx_ = ottd_rdtsc();\
00096 static uint64 __sum__ = 0;\
00097 static uint32 __i__ = 0;
00098
00099 #define TOC(str, count)\
00100 __sum__ += ottd_rdtsc() - _xxx_;\
00101 if (++__i__ == count) {\
00102 DEBUG(misc, 0, "[%s] " OTTD_PRINTF64 " [avg: %.1f]", str, __sum__, __sum__/(double)__i__);\
00103 __i__ = 0;\
00104 __sum__ = 0;\
00105 }\
00106 }
00107
00108 void ShowInfo(const char *str);
00109 void CDECL ShowInfoF(const char *str, ...) WARN_FORMAT(1, 2);
00110
00111 const char *GetLogPrefix();
00112
00114 extern uint32 _realtime_tick;
00115
00116 #endif