NPC_misc.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // NPC_misc.cpp
  3. //
  4. // leave this line at the top for all NPC_xxxx.cpp files...
  5. #include "g_headers.h"
  6. #include "b_local.h"
  7. #include "q_shared.h"
  8. /*
  9. Debug_Printf
  10. */
  11. void Debug_Printf (cvar_t *cv, int debugLevel, char *fmt, ...)
  12. {
  13. char *color;
  14. va_list argptr;
  15. char msg[1024];
  16. if (cv->value < debugLevel)
  17. return;
  18. if (debugLevel == DEBUG_LEVEL_DETAIL)
  19. color = S_COLOR_WHITE;
  20. else if (debugLevel == DEBUG_LEVEL_INFO)
  21. color = S_COLOR_GREEN;
  22. else if (debugLevel == DEBUG_LEVEL_WARNING)
  23. color = S_COLOR_YELLOW;
  24. else if (debugLevel == DEBUG_LEVEL_ERROR)
  25. color = S_COLOR_RED;
  26. else
  27. color = S_COLOR_RED;
  28. va_start (argptr,fmt);
  29. vsprintf (msg, fmt, argptr);
  30. va_end (argptr);
  31. gi.Printf("%s%5i:%s", color, level.time, msg);
  32. }
  33. /*
  34. Debug_NPCPrintf
  35. */
  36. void Debug_NPCPrintf (gentity_t *printNPC, cvar_t *cv, int debugLevel, char *fmt, ...)
  37. {
  38. int color;
  39. va_list argptr;
  40. char msg[1024];
  41. if (cv->value < debugLevel)
  42. {
  43. return;
  44. }
  45. if ( debugNPCName->string[0] && Q_stricmp( debugNPCName->string, printNPC->targetname) != 0 )
  46. {
  47. return;
  48. }
  49. if (debugLevel == DEBUG_LEVEL_DETAIL)
  50. color = COLOR_WHITE;
  51. else if (debugLevel == DEBUG_LEVEL_INFO)
  52. color = COLOR_GREEN;
  53. else if (debugLevel == DEBUG_LEVEL_WARNING)
  54. color = COLOR_YELLOW;
  55. else if (debugLevel == DEBUG_LEVEL_ERROR)
  56. color = COLOR_RED;
  57. else
  58. color = COLOR_RED;
  59. va_start (argptr,fmt);
  60. vsprintf (msg, fmt, argptr);
  61. va_end (argptr);
  62. gi.Printf ("%c%c%5i (%s) %s", Q_COLOR_ESCAPE, color, level.time, printNPC->targetname, msg);
  63. }