From ec1c42b04a2f1fe17101c2b2cb2b3298e7a730c4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 8 Sep 2020 18:39:47 +0200 Subject: [PATCH] - got rid of common.h All still relevant content was moved to places closer to its use. --- source/blood/src/actor.cpp | 1 - source/blood/src/blood.cpp | 1 - source/blood/src/common_game.h | 1 - source/blood/src/dude.cpp | 1 - source/blood/src/endgame.cpp | 1 - source/blood/src/misc.h | 2 +- source/blood/src/tile.cpp | 1 - source/blood/src/triggers.h | 1 - source/build/include/build.h | 2 + source/build/include/common.h | 72 ------------------------------- source/build/include/compat.h | 16 ------- source/build/include/scriptfile.h | 17 ++++++++ source/build/src/animvpx.cpp | 5 +++ source/build/src/defs.cpp | 1 - source/build/src/engine.cpp | 1 - source/build/src/mdsprite.cpp | 1 - source/build/src/polymost.cpp | 1 - source/build/src/scriptfile.cpp | 1 - source/core/gamecvars.cpp | 1 - source/core/intvec.h | 7 +-- source/core/palette.cpp | 1 - source/core/raze_sound.h | 13 ++++++ source/core/searchpaths.cpp | 1 - source/exhumed/src/cheats.cpp | 1 - source/exhumed/src/exhumed.cpp | 3 -- source/exhumed/src/gameloop.cpp | 1 - source/exhumed/src/osdcmds.cpp | 1 - source/sw/src/ai.cpp | 1 - source/sw/src/game.cpp | 1 - source/sw/src/jweapon.cpp | 1 - source/sw/src/mclip.cpp | 1 - source/sw/src/osdcmds.cpp | 1 - source/sw/src/panel.cpp | 1 - source/sw/src/player.cpp | 1 - source/sw/src/quake.cpp | 1 - source/sw/src/sector.cpp | 1 - source/sw/src/weapon.cpp | 1 - 37 files changed, 39 insertions(+), 126 deletions(-) delete mode 100644 source/build/include/common.h diff --git a/source/blood/src/actor.cpp b/source/blood/src/actor.cpp index 8d3e193a3..b7cd59b95 100644 --- a/source/blood/src/actor.cpp +++ b/source/blood/src/actor.cpp @@ -29,7 +29,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "automap.h" #include "pragmas.h" #include "mmulti.h" -#include "common.h" #include "common_game.h" #include "actor.h" diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index d141ca732..6598f3cab 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -26,7 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "build.h" #include "mmulti.h" #include "compat.h" -#include "common.h" #include "common_game.h" #include "g_input.h" #include "automap.h" diff --git a/source/blood/src/common_game.h b/source/blood/src/common_game.h index fe37b1837..e3f697399 100644 --- a/source/blood/src/common_game.h +++ b/source/blood/src/common_game.h @@ -23,7 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #pragma once #include "build.h" -#include "common.h" #include "pragmas.h" #include "misc.h" #include "printf.h" diff --git a/source/blood/src/dude.cpp b/source/blood/src/dude.cpp index 35b3559fa..44256df39 100644 --- a/source/blood/src/dude.cpp +++ b/source/blood/src/dude.cpp @@ -24,7 +24,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ns.h" // Must come before everything else! #include "compat.h" -#include "common.h" #include "blood.h" #include "dude.h" diff --git a/source/blood/src/endgame.cpp b/source/blood/src/endgame.cpp index 8a907e365..ba5b18d01 100644 --- a/source/blood/src/endgame.cpp +++ b/source/blood/src/endgame.cpp @@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "build.h" #include "v_draw.h" -#include "common.h" #include "mmulti.h" #include "common_game.h" #include "blood.h" diff --git a/source/blood/src/misc.h b/source/blood/src/misc.h index d0b80f087..984ac96a4 100644 --- a/source/blood/src/misc.h +++ b/source/blood/src/misc.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //------------------------------------------------------------------------- #pragma once -#include "common.h" +#include "m_fixed.h" #include "filesystem.h" BEGIN_BLD_NS diff --git a/source/blood/src/tile.cpp b/source/blood/src/tile.cpp index cd08a5324..ad1998dda 100644 --- a/source/blood/src/tile.cpp +++ b/source/blood/src/tile.cpp @@ -27,7 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #include "compat.h" #include "build.h" -#include "common.h" #include "common_game.h" #include "blood.h" diff --git a/source/blood/src/triggers.h b/source/blood/src/triggers.h index 827dadcb5..14e195d4a 100644 --- a/source/blood/src/triggers.h +++ b/source/blood/src/triggers.h @@ -22,7 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //------------------------------------------------------------------------- #pragma once #include "build.h" -#include "common.h" #include "common_game.h" #include "blood.h" diff --git a/source/build/include/build.h b/source/build/include/build.h index d9445c19b..3c5a0b9cf 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -31,6 +31,8 @@ static_assert('\xff' == 255, "Char must be unsigned!"); #include "buildtiles.h" #include "c_cvars.h" #include "cmdlib.h" +#include "m_fixed.h" +#include "mathutil.h" typedef int64_t coord_t; diff --git a/source/build/include/common.h b/source/build/include/common.h deleted file mode 100644 index 4528d05a3..000000000 --- a/source/build/include/common.h +++ /dev/null @@ -1,72 +0,0 @@ -// -// Definitions of common non-engine data structures/functions -// (and declarations of data appearing in both) -// for EDuke32 and Mapster32 -// - -#ifndef EDUKE32_COMMON_H_ -#define EDUKE32_COMMON_H_ - - -#include "compat.h" -#include "pragmas.h" // klabs -#include "scriptfile.h" -#include "mathutil.h" - -//// TYPES -struct strllist -{ - struct strllist *next; - char *str; -}; - -typedef struct -{ - const char *text; - int32_t tokenid; -} -tokenlist; - - -enum -{ - T_EOF = -2, - T_ERROR = -1, -}; - - -//// EXTERN DECLS - -extern const char *s_buildRev; -extern const char *s_buildTimestamp; - -//// FUNCTIONS - -void G_AddDef(const char *buffer); -void G_AddDefModule(const char *buffer); - -// returns a buffer of size BMAX_PATH -static inline char *dup_filename(const char *fn) -{ - char * const buf = (char *) Xmalloc(BMAX_PATH); - return Bstrncpyz(buf, fn, BMAX_PATH); -} - -static inline void realloc_copy(char **fn, const char *buf) -{ - uint8_t len = Bstrlen(buf) + 1; - *fn = (char *)Xrealloc(*fn, len); - Bstrncpy(*fn, buf, len); -} - -int32_t getatoken(scriptfile *sf, const tokenlist *tl, int32_t ntokens); - - -void COMMON_clearbackground(int32_t numcols, int32_t numrows); - -// timer defs for profiling function chunks the simple way -#define EDUKE32_TMRDEF int32_t t[20], ti=0; const char *tmrstr=__func__; fprintf(stderr,"%s\n",tmrstr); t[ti++]=I_msTime(); -#define EDUKE32_TMRTIC t[ti++]=I_msTime() -#define EDUKE32_TMRPRN do { int ii=0; fprintf(stderr,"%s: ",tmrstr); for (ii=1; iix* xmul, pos->z* zmul, pos->y* ymul }; -} - /* End dependence on compat.o object. */ diff --git a/source/build/include/scriptfile.h b/source/build/include/scriptfile.h index be570d59c..0562a1732 100644 --- a/source/build/include/scriptfile.h +++ b/source/build/include/scriptfile.h @@ -30,4 +30,21 @@ int32_t scriptfile_getsymbolvalue(char const *name, int32_t *val); int32_t scriptfile_addsymbolvalue(char const *name, int32_t val); void scriptfile_clearsymbols(void); +typedef struct +{ + const char *text; + int32_t tokenid; +} +tokenlist; + + +enum +{ + T_EOF = -2, + T_ERROR = -1, +}; + + +int32_t getatoken(scriptfile *sf, const tokenlist *tl, int32_t ntokens); + #endif diff --git a/source/build/src/animvpx.cpp b/source/build/src/animvpx.cpp index 293a66bc5..93cd050ce 100644 --- a/source/build/src/animvpx.cpp +++ b/source/build/src/animvpx.cpp @@ -21,6 +21,11 @@ #include #include "animvpx.h" +struct vec2u_t +{ + uint32_t x, y; +} ; + const char *animvpx_read_ivf_header_errmsg[] = { "All OK", "couldn't read 32-byte IVF header", diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index 70804aa53..ebf39d57b 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -10,7 +10,6 @@ #include "engine_priv.h" #include "scriptfile.h" -#include "common.h" #include "mdsprite.h" // md3model_t #include "buildtiles.h" #include "bitmap.h" diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index bf680a715..bb3f0cb00 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -13,7 +13,6 @@ #include "automap.h" #include "imagehelpers.h" -#include "common.h" #include "compat.h" #include "engine_priv.h" #include "palette.h" diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index 8afbe75a8..ec6f504eb 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -9,7 +9,6 @@ #include "polymost.h" #include "mdsprite.h" -#include "common.h" #include "palette.h" #include "textures.h" #include "bitmap.h" diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 507e2792c..be90b54d7 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -7,7 +7,6 @@ Ken Silverman's official web site: http://www.advsys.net/ken #include "build.h" #include "automap.h" -#include "common.h" #include "engine_priv.h" #include "mdsprite.h" #include "polymost.h" diff --git a/source/build/src/scriptfile.cpp b/source/build/src/scriptfile.cpp index 0db34e132..a8a13f014 100644 --- a/source/build/src/scriptfile.cpp +++ b/source/build/src/scriptfile.cpp @@ -8,7 +8,6 @@ #include "compat.h" #include "scriptfile.h" #include "compat.h" -#include "common.h" #include "filesystem.h" #include "printf.h" diff --git a/source/core/gamecvars.cpp b/source/core/gamecvars.cpp index 608273068..ab8a5d854 100644 --- a/source/core/gamecvars.cpp +++ b/source/core/gamecvars.cpp @@ -35,7 +35,6 @@ */ #include "c_cvars.h" -#include "common.h" #include "gameconfigfile.h" #include "gamecontrol.h" #include "m_argv.h" diff --git a/source/core/intvec.h b/source/core/intvec.h index 97fcad844..1675386f4 100644 --- a/source/core/intvec.h +++ b/source/core/intvec.h @@ -12,11 +12,6 @@ struct vec2_t int32_t x, y; }; -struct vec2u_t -{ - uint32_t x, y; -}; - struct vec2f_t { float x, y; @@ -50,4 +45,4 @@ struct vec3_16_t vec2_16_t vec2; }; }; -#endif \ No newline at end of file +#endif diff --git a/source/core/palette.cpp b/source/core/palette.cpp index c303734e8..877791747 100644 --- a/source/core/palette.cpp +++ b/source/core/palette.cpp @@ -36,7 +36,6 @@ #include "palette.h" #include "superfasthash.h" -#include "common.h" #include "memarena.h" #include "palettecontainer.h" #include "palutil.h" diff --git a/source/core/raze_sound.h b/source/core/raze_sound.h index dc7c809cf..8d43ea145 100644 --- a/source/core/raze_sound.h +++ b/source/core/raze_sound.h @@ -1,5 +1,18 @@ #pragma once #include "s_soundinternal.h" +#include "m_fixed.h" +#include "vectors.h" +#include "build.h" + +inline FVector3 GetSoundPos(const vec3_t *pos) +{ + // converts a Build coordinate to a sound system coordinate + const float xmul = 1 / 16.f; + const float ymul = -1 / 16.f; + const float zmul = -1 / 256.f; + return { pos->x* xmul, pos->z* zmul, pos->y* ymul }; +} + enum { diff --git a/source/core/searchpaths.cpp b/source/core/searchpaths.cpp index 9cc739cca..3cc3965a7 100644 --- a/source/core/searchpaths.cpp +++ b/source/core/searchpaths.cpp @@ -41,7 +41,6 @@ #include "sc_man.h" #include "resourcefile.h" #include "printf.h" -#include "common.h" #include "version.h" #include "gamecontrol.h" #include "m_argv.h" diff --git a/source/exhumed/src/cheats.cpp b/source/exhumed/src/cheats.cpp index 8f7258d36..ea9515f04 100644 --- a/source/exhumed/src/cheats.cpp +++ b/source/exhumed/src/cheats.cpp @@ -18,7 +18,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ns.h" #include "automap.h" #include "compat.h" -#include "common.h" #include "engine.h" #include "exhumed.h" #include "sequence.h" diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index ece140b93..9e68cf9c5 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -17,7 +17,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //------------------------------------------------------------------------- #include "ns.h" #include "compat.h" -#include "common.h" #include "engine.h" #include "exhumed.h" #include "sequence.h" @@ -54,8 +53,6 @@ BEGIN_PS_NS extern short bPlayerPan; extern short bLockPan; - extern const char* s_buildRev; - extern const char* s_buildTimestamp; void uploadCinemaPalettes(); diff --git a/source/exhumed/src/gameloop.cpp b/source/exhumed/src/gameloop.cpp index c838686c9..3c449ad16 100644 --- a/source/exhumed/src/gameloop.cpp +++ b/source/exhumed/src/gameloop.cpp @@ -17,7 +17,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //------------------------------------------------------------------------- #include "ns.h" #include "compat.h" -#include "common.h" #include "engine.h" #include "exhumed.h" #include "sequence.h" diff --git a/source/exhumed/src/osdcmds.cpp b/source/exhumed/src/osdcmds.cpp index 466281c37..4b6884fa6 100644 --- a/source/exhumed/src/osdcmds.cpp +++ b/source/exhumed/src/osdcmds.cpp @@ -22,7 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "ns.h" #include "compat.h" #include "build.h" -#include "common.h" #include "exhumed.h" #include "player.h" #include "view.h" diff --git a/source/sw/src/ai.cpp b/source/sw/src/ai.cpp index 201bf3024..a147d61b3 100644 --- a/source/sw/src/ai.cpp +++ b/source/sw/src/ai.cpp @@ -26,7 +26,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "ns.h" #include "build.h" -#include "common.h" #include "names2.h" #include "game.h" diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index bd494198d..5d691b340 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -60,7 +60,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "misc.h" #include "jsector.h" -#include "common.h" #include "gameconfigfile.h" #include "printf.h" #include "m_argv.h" diff --git a/source/sw/src/jweapon.cpp b/source/sw/src/jweapon.cpp index ac6747c98..e85f0d4b4 100644 --- a/source/sw/src/jweapon.cpp +++ b/source/sw/src/jweapon.cpp @@ -26,7 +26,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "ns.h" #include "build.h" -#include "common.h" #include "names2.h" #include "panel.h" diff --git a/source/sw/src/mclip.cpp b/source/sw/src/mclip.cpp index 284d2ae9d..109845fb8 100644 --- a/source/sw/src/mclip.cpp +++ b/source/sw/src/mclip.cpp @@ -26,7 +26,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "ns.h" #include "build.h" -#include "common.h" #include "mytypes.h" #include "names2.h" diff --git a/source/sw/src/osdcmds.cpp b/source/sw/src/osdcmds.cpp index 71a3d3aff..d3a655314 100644 --- a/source/sw/src/osdcmds.cpp +++ b/source/sw/src/osdcmds.cpp @@ -35,7 +35,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gamecontrol.h" #include "gstrings.h" -#include "common.h" #include "v_text.h" #include "printf.h" diff --git a/source/sw/src/panel.cpp b/source/sw/src/panel.cpp index 674b053d1..022b989a2 100644 --- a/source/sw/src/panel.cpp +++ b/source/sw/src/panel.cpp @@ -28,7 +28,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #undef MAIN #include "build.h" -#include "common.h" #include "names2.h" #include "panel.h" diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 7a2794d76..e385c062a 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -26,7 +26,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "ns.h" #include "build.h" -#include "common.h" #include "mytypes.h" #include "names2.h" diff --git a/source/sw/src/quake.cpp b/source/sw/src/quake.cpp index 15f7edc68..beff31b73 100644 --- a/source/sw/src/quake.cpp +++ b/source/sw/src/quake.cpp @@ -26,7 +26,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "ns.h" #include "build.h" -#include "common.h" #include "gamecontrol.h" diff --git a/source/sw/src/sector.cpp b/source/sw/src/sector.cpp index f42b13b8c..fa1d442df 100644 --- a/source/sw/src/sector.cpp +++ b/source/sw/src/sector.cpp @@ -25,7 +25,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms //------------------------------------------------------------------------- #include "ns.h" #include "build.h" -#include "common.h" #include "names2.h" #include "panel.h" diff --git a/source/sw/src/weapon.cpp b/source/sw/src/weapon.cpp index 1250485ab..e5ddf95df 100644 --- a/source/sw/src/weapon.cpp +++ b/source/sw/src/weapon.cpp @@ -25,7 +25,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms //------------------------------------------------------------------------- #include "ns.h" #include "build.h" -#include "common.h" #include "names2.h" #include "panel.h"