You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

common.h 4.8KB

2 years ago
2 years ago
2 years ago
3 years ago
Changes 2/1/2017 through 3/1/2017 Forgot to commit for a while, sorry! Fix combat rifle sprites conflicting with DRLA monsters Add impact sounds to cannoballs Add quit sounds Add a title map Add confirmation text for extra hard/nightmare difficulties Add cluster intermission texts Add finale sequence Make the cannon easier to use (again) Add unfinished Game Nanhai shop "weapon" Fix the sniper rifle making things fly away and gib Make the shotgun slightly weaker (again) Make the laser shotgun slightly stronger (again) Balance the knife a bit Add loading screen Upgr::VitalScan: Make names and text flip out at stronger enemies CBI: Stretch the GUI to 320x240 from 320x200 GUI: Implement checkboxes GUI: Add width/height parameters for whole GUI GUI: Add color parameter to button GUI: Add new list button presets World: Add enemy compatibility checks Upgrades: Generalize upgrade group types Upgrades: Switch buying over to shopdef system Upgrades: Add auto-groups Upgrades: Move function defs into their own header CBI::Settings: Add missing cvars Player: Split player_t data into several structures Player: Generalize GUI switching code Player: Split p_player.c over several files Upgr::HeadsUpDisp: Add a small fade when switching weapons TurboHitler: Change upgrade setup parameters to strings Upgr::AutoReload: Add description Shop: Remove some items from the shop Info: Fix pistol's description Info: Add missing descriptions Info: Fix arachnotron/mastermind names Update package.bat Add NetFile module Add Games module Add SaveData module Add ShopDef module Rename C files for categorization Bump version number Add miscallaneous text changes
4 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /* ---------------------------------------------------------------------------|
  2. *
  3. * Distributed under the CC0 public domain license.
  4. * By Alison G. Watson. Attribution is encouraged, though not required.
  5. * See licenses/cc0.txt for more information.
  6. *
  7. * ---------------------------------------------------------------------------|
  8. *
  9. * Common functions and debugging functions.
  10. *
  11. * ---------------------------------------------------------------------------|
  12. */
  13. #ifndef common_h
  14. #define common_h
  15. #pragma GDCC FIXED_LITERAL ON
  16. #include <ACS_ZDoom.h>
  17. #include <stdarg.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20. #include "m_types.h"
  21. #include "m_memory.h"
  22. #include "m_drawing.h"
  23. #include "m_math.h"
  24. #include "m_str.h"
  25. #include "m_stab.h"
  26. #define LineHash ((u32)__LINE__ * FileHash)
  27. #define ifw(decl, ...) __with(decl;) if(__VA_ARGS__)
  28. #define ifauto(type, name, ...) ifw(type name = (__VA_ARGS__), name)
  29. #define countof(a) (sizeof(a) / sizeof(*(a)))
  30. #define swap(t, a, b) do {t _tmp = a; a = b; b = _tmp;} while(0)
  31. #define IsSmallNumber(x) ((x) > -0.001 && (x) < 0.001)
  32. #define CloseEnough(x, y) (IsSmallNumber(x - y))
  33. #ifndef NDEBUG
  34. #define Dbg_Log(level, ...) \
  35. do if(get_bit(dbglevel, level)) Log(c"" #level ": " __VA_ARGS__); while(0)
  36. #else
  37. #define Dbg_Log(...)
  38. #endif
  39. /* !!!FIXME!!! GZDoom doesn't have a way of using PRINT_NONOTIFY yet */
  40. #define ConsoleLog(...) ((void)0)
  41. #define TickerT(t, on, off) ((ACS_Timer() % 35) < (t) ? (on) : (off))
  42. #define Ticker(on, off) (TickerT(17, on, off))
  43. #define FourCCPtr(s) FourCC((s)[0], (s)[1], (s)[2], (s)[3])
  44. #define FourCC(a, b, c, d) ((d << 24) | (c << 16) | (b << 8) | (a << 0))
  45. #define SCallI ACS_ScriptCall
  46. #define SCallK ACS_ScriptCallFixed
  47. #define SCallS ACS_ScriptCallString
  48. #define GetMembI ACS_GetUserVariable
  49. #define GetMembK ACS_GetUserVariableFixed
  50. #define GetMembS ACS_GetUserVariableString
  51. #define SetMembI ACS_SetUserVariable
  52. #define SetMembK ACS_SetUserVariableFixed
  53. #define GetPropI ACS_GetActorProperty
  54. #define GetPropK ACS_GetActorPropertyFixed
  55. #define GetPropS ACS_GetActorPropertyString
  56. #define SetPropI ACS_SetActorProperty
  57. #define SetPropK ACS_SetActorPropertyFixed
  58. #define SetPropS ACS_SetActorPropertyString
  59. #define GetX ACS_GetActorX
  60. #define GetY ACS_GetActorY
  61. #define GetZ ACS_GetActorZ
  62. #define Paused ServCallI(sm_GetPaused)
  63. #define PausableTick() do ACS_Delay(1); while(Paused)
  64. #define WaitPause() while(Paused) ACS_Delay(1)
  65. #define Spf s""
  66. #define CVAR "lith_"
  67. #define DCVAR "__lith_"
  68. #define LANG "LITH_"
  69. #define OBJ "Lith_"
  70. #define sCVAR Spf CVAR
  71. #define sDCVAR Spf DCVAR
  72. #define sLANG Spf LANG
  73. #define sOBJ Spf OBJ
  74. #define ServCallI(...) SCallI(so_Serv, __VA_ARGS__)
  75. #define ServCallK(...) SCallK(so_Serv, __VA_ARGS__)
  76. #define ServCallS(...) SCallS(so_Serv, __VA_ARGS__)
  77. #define DrawCallI(...) SCallI(so_Draw, __VA_ARGS__)
  78. #define DrawCallK(...) SCallK(so_Draw, __VA_ARGS__)
  79. #define DrawCallS(...) SCallS(so_Draw, __VA_ARGS__)
  80. #define Dbg_Stat(...) \
  81. (get_bit(dbglevel, log_devh) ? Dbg_Stat_Impl(__VA_ARGS__) : (void)0)
  82. #define Dbg_Note(...) \
  83. (get_bit(dbglevel, log_devh) ? Dbg_Note_Impl(__VA_ARGS__) : (void)0)
  84. #define InvGive ACS_GiveInventory
  85. #define InvMax(arg) ACS_GetMaxInventory(0, arg)
  86. #define InvNum ACS_CheckInventory
  87. #define InvTake ACS_TakeInventory
  88. /* Types ------------------------------------------------------------------- */
  89. enum {
  90. log_none,
  91. log_dev, /* general debug info */
  92. log_devh, /* prints live stats to the HUD (position, angles, etc) */
  93. log_boss, /* debug info for the boss system */
  94. log_dmon, /* debug info for the monster tracker */
  95. log_dmonV, /* verbose debug info for the monster tracker */
  96. log_dlg, /* debug info for the dialogue/terminal compiler */
  97. log_bip, /* debug info for the BIP */
  98. log_sys, /* meta debug info */
  99. log_sysV, /* tick info */
  100. };
  101. enum {
  102. dbgf_bip,
  103. dbgf_items,
  104. dbgf_save,
  105. dbgf_score,
  106. dbgf_upgr,
  107. };
  108. /* Extern Functions -------------------------------------------------------- */
  109. void FadeFlash(i32 r, i32 g, i32 b, k32 amount, k32 seconds);
  110. script optargs(1) i32 PtrTID(i32 tid, i32 ptr);
  111. script optargs(1) i32 PtrPlayerNumber(i32 tid, i32 ptr);
  112. script optargs(1) bool PtrValid(i32 tid, i32 ptr);
  113. script optargs(2) bool PtrSet(i32 tid, i32 ptr, i32 assign, i32 tid2, i32 ptr2, i32 flags);
  114. i32 PtrInvNum(i32 tid, str item);
  115. void PtrInvGive(i32 tid, str item, i32 amount);
  116. void PtrInvTake(i32 tid, str item, i32 amount);
  117. void PtrInvSet (i32 tid, str item, i32 amount);
  118. void Dbg_Stat_Impl(cstr fmt, ...);
  119. void Dbg_Note_Impl(cstr fmt, ...);
  120. void Dbg_PrintMem(void const *data, size_t size);
  121. void Dbg_PrintMemC(void const *data, size_t size);
  122. void Log(cstr fmt, ...);
  123. /* Extern Objects ---------------------------------------------------------- */
  124. extern str dbgstat[], dbgnote[];
  125. extern i32 dbgstatnum, dbgnotenum;
  126. extern i32 lmvar dbglevel;
  127. extern i32 lmvar dbgflag;
  128. #endif