summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/abi.h7
-rw-r--r--src/con_.c8
-rw-r--r--src/gamedata.c11
-rw-r--r--src/gamedata.h8
-rw-r--r--src/kvsys.c10
-rw-r--r--src/l4dreset.c8
6 files changed, 19 insertions, 33 deletions
diff --git a/src/abi.h b/src/abi.h
index 98d972e..f0637e5 100644
--- a/src/abi.h
+++ b/src/abi.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 Michael Smith <mikesmiffy128@gmail.com>
+ * Copyright © 2024 Michael Smith <mikesmiffy128@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -26,6 +26,9 @@
#ifdef _WIN32 // Windows RTTI stuff, obviously only used on Windows.
+// also this: number of virtual destructor entries (used all over the place)
+#define NVDTOR 1
+
// MSVC RTTI is quite a black box, but thankfully there's some useful sources:
// - https://doxygen.reactos.org/d0/dcf/cxx_8h_source.html
// - https://blog.quarkslab.com/visual-c-rtti-inspection.html
@@ -93,6 +96,8 @@ mod const struct msvc_rtti_locator name = { \
#else
+#define NVDTOR 2 // *stupid* ABI, btw
+
struct itanium_type_info_vtable {
void *dtor1, *dtor2;
};
diff --git a/src/con_.c b/src/con_.c
index a462286..6fc8857 100644
--- a/src/con_.c
+++ b/src/con_.c
@@ -1,6 +1,6 @@
/* THIS FILE SHOULD BE CALLED `con.c` BUT WINDOWS IS STUPID */
/*
- * Copyright © 2023 Michael Smith <mikesmiffy128@gmail.com>
+ * Copyright © 2024 Michael Smith <mikesmiffy128@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -256,12 +256,6 @@ static void VCALLCONV Create_var(void *thisoff, const char *name,
const char *defaultval, int flags, const char *helpstr, bool hasmin,
float min, bool hasmax, float max, void *cb) {}
-#ifdef _WIN32
-#define NVDTOR 1
-#else
-#define NVDTOR 2 // Itanium ABI has 2 because I said so
-#endif
-
// the first few members of ConCommandBase are the same between versions
void *_con_vtab_cmd[14 + NVDTOR] = {
(void *)&dtor,
diff --git a/src/gamedata.c b/src/gamedata.c
index 78eb620..247bf25 100644
--- a/src/gamedata.c
+++ b/src/gamedata.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 Michael Smith <mikesmiffy128@gmail.com>
+ * Copyright © 2024 Michael Smith <mikesmiffy128@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -14,16 +14,9 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
+#include "abi.h" // purely for NVDTOR
#include "gametype.h"
-// same as gamedata.h, not worth putting in its own thing
-// (it's also in con_.c. whatever)
-#ifdef _WIN32
-#define NVDTOR 1
-#else
-#define NVDTOR 2
-#endif
-
#include <gamedatainit.gen.h> // generated by build/mkgamedata.c
// vi: sw=4 ts=4 noet tw=80 cc=80
diff --git a/src/gamedata.h b/src/gamedata.h
index 2e58ef6..050d3b8 100644
--- a/src/gamedata.h
+++ b/src/gamedata.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 Michael Smith <mikesmiffy128@gmail.com>
+ * Copyright © 2024 Michael Smith <mikesmiffy128@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -17,14 +17,20 @@
#ifndef INC_GAMEDATA_H
#define INC_GAMEDATA_H
+// STUPID HACK to avoid pollution if abi.h not already included (only because
+// generated gamedata stuff relies on this being defined)
+#ifndef NVDTOR
#ifdef _WIN32
#define NVDTOR 1
#else
#define NVDTOR 2
#endif
+#endif
#include <gamedata.gen.h> // generated by build/mkgamedata.c
#include <entprops.gen.h> // generated by build/mkentprops.c
+#ifndef INC_ABI_H // YUCK YUCK YUCK
#undef NVDTOR
+#endif
/* Called as part of plugin init to set up various metadata about the game. */
void gamedata_init(void);
diff --git a/src/kvsys.c b/src/kvsys.c
index 1d09b0f..fc10b93 100644
--- a/src/kvsys.c
+++ b/src/kvsys.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 Michael Smith <mikesmiffy128@gmail.com>
+ * Copyright © 2024 Michael Smith <mikesmiffy128@gmail.com>
* Copyright © 2024 Willian Henrique <wsimanbrazil@yahoo.com.br>
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -15,6 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
+#include "abi.h"
#include "con_.h"
#include "engineapi.h"
#include "extmalloc.h"
@@ -75,13 +76,6 @@ static const char *VCALLCONV hook_GetStringForSymbol(void *this, int s) {
return ret;
}
-// XXX: 5th instance of this in the codebase, should REALLY tidy up soon
-#ifdef _WIN32
-#define NVDTOR 1
-#else
-#define NVDTOR 2
-#endif
-
static void detectabichange(void **kvsvt) {
// When no virtual destructor is present, the 6th function in the KVS vtable
// is AddKeyValuesToMemoryLeakList, which is a nop in release builds.
diff --git a/src/l4dreset.c b/src/l4dreset.c
index e95a1ac..c1a22dd 100644
--- a/src/l4dreset.c
+++ b/src/l4dreset.c
@@ -17,6 +17,7 @@
#include <string.h>
+#include "abi.h"
#include "con_.h"
#include "engineapi.h"
#include "ent.h"
@@ -67,13 +68,6 @@ static void *director; // "TheDirector" server global
bool last_passed;
};*/
-// XXX: duping this again here... what makes sense to tidy this up?
-#ifdef _WIN32
-#define NVDTOR 1
-#else
-#define NVDTOR 2
-#endif
-
struct CVoteIssue;
DECL_VFUNC(const char *, SetIssueDetails, 1 + NVDTOR, const char *)
DECL_VFUNC(const char *, GetDisplayString, 8 + NVDTOR)