Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 79 additions & 114 deletions include/game_api.h

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions include/game_cod11mp.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ Created By:
#ifndef QMM2_GAME_COD11MP_H
#define QMM2_GAME_COD11MP_H

#include "version.h"

#if defined(QMM_ARCH_32)

// these import messages do not have an exact analogue in COD11MP
enum {
G_ARGS = -100, // char* (void)
};

#endif // QMM_ARCH_32

#endif // QMM2_GAME_COD11MP_H

6 changes: 6 additions & 0 deletions include/game_codmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ Created By:
#ifndef QMM2_GAME_CODMP_H
#define QMM2_GAME_CODMP_H

#include "version.h"

#if defined(QMM_ARCH_32)

// these import messages do not have an exact analogue in CODMP
enum {
G_ARGS = -100, // char* (void)
};

#endif // QMM_ARCH_32

#endif // QMM2_GAME_CODMP_H
6 changes: 6 additions & 0 deletions include/game_coduomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ Created By:
#ifndef QMM2_GAME_CODUOMP_H
#define QMM2_GAME_CODUOMP_H

#include "version.h"

#if defined(QMM_ARCH_32)

// these import messages do not have an exact analogue in CODUOMP
enum {
G_ARGS = -100, // char* (void)
};

#endif // QMM_ARCH_32

#endif // QMM2_GAME_CODUOMP_H
6 changes: 6 additions & 0 deletions include/game_mohaa.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Created By:
#ifndef QMM2_GAME_MOHAA_H
#define QMM2_GAME_MOHAA_H

#include "version.h"

#if defined(QMM_ARCH_32)

// import ("syscall") cmds
enum {
G_PRINTF,
Expand Down Expand Up @@ -250,4 +254,6 @@ enum {
// we need to store FILE* in fileHandle_t so change the underlying type
#define fileHandle_t intptr_t

#endif // QMM_ARCH_32

#endif // QMM2_GAME_MOHAA_H
6 changes: 6 additions & 0 deletions include/game_mohbt.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Created By:
#ifndef QMM2_GAME_MOHBT_H
#define QMM2_GAME_MOHBT_H

#include "version.h"

#if defined(QMM_ARCH_32)

// import ("syscall") cmds
enum {
G_PRINTF,
Expand Down Expand Up @@ -256,4 +260,6 @@ enum {
// we need to store FILE* in fileHandle_t so change the underlying type
#define fileHandle_t intptr_t

#endif // QMM_ARCH_32

#endif // QMM2_GAME_MOHBT_H
6 changes: 6 additions & 0 deletions include/game_mohsh.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Created By:
#ifndef QMM2_GAME_MOHSH_H
#define QMM2_GAME_MOHSH_H

#include "version.h"

#if defined(QMM_ARCH_32)

// import ("syscall") cmds
enum {
G_PRINTF,
Expand Down Expand Up @@ -256,4 +260,6 @@ enum {
// we need to store FILE* in fileHandle_t so change the underlying type
#define fileHandle_t intptr_t

#endif // QMM_ARCH_32

#endif // QMM2_GAME_MOHSH_H
6 changes: 6 additions & 0 deletions include/game_sof2mp.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ Created By:
#ifndef QMM2_GAME_SOF2MP_H
#define QMM2_GAME_SOF2MP_H

#include "version.h"

#if defined(QMM_ARCH_32)

// these import messages do not have an exact analogue in SOF2MP
enum {
G_ARGS = -100, // char* (void)
};

#endif // QMM_ARCH_32

#endif // QMM2_GAME_SOF2MP_H
6 changes: 6 additions & 0 deletions include/game_sof2sp.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Created By:
#ifndef QMM2_GAME_SOF2SP_H
#define QMM2_GAME_SOF2SP_H

#include "version.h"

#if defined(QMM_ARCH_32)

// import ("syscall") cmds
enum {
G_PRINTF,
Expand Down Expand Up @@ -167,4 +171,6 @@ enum {
G_ERROR = -100, // void (const char* msg)
};

#endif // QMM_ARCH_32

#endif // QMM2_GAME_SOF2SP_H
6 changes: 6 additions & 0 deletions include/game_stef2.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Created By:
#ifndef QMM2_GAME_STEF2_H
#define QMM2_GAME_STEF2_H

#include "version.h"

#if defined(QMM_ARCH_32)

// import ("syscall") cmds
enum {
G_PRINTF,
Expand Down Expand Up @@ -407,4 +411,6 @@ enum {
G_GET_ENTITY_TOKEN, // qboolean (char *buffer, int bufferSize)
};

#endif // QMM_ARCH_32

#endif // QMM2_GAME_STEF2_H
5 changes: 5 additions & 0 deletions include/game_stvoyhm.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Created By:
#ifndef QMM2_GAME_STVOYMP_H
#define QMM2_GAME_STVOYMP_H

#include "version.h"

#if defined(QMM_ARCH_32)

// these function ids are defined either in the g_syscalls.asm file or in qcommon.h from ioef source,
// but they do not appear in the enum in stvoyhm/game/g_public.h
Expand All @@ -37,4 +40,6 @@ enum {
G_ARGS = -100, // char* (void)
};

#endif // QMM_ARCH_32

#endif // QMM2_GAME_STVOYMP_H
6 changes: 6 additions & 0 deletions include/game_stvoysp.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Created By:
#ifndef QMM2_GAME_STVOYSP_H
#define QMM2_GAME_STVOYSP_H

#include "version.h"

#if defined(QMM_ARCH_32)

// import ("syscall") cmds
enum {
G_PRINTF,
Expand Down Expand Up @@ -94,4 +98,6 @@ enum {
G_ARGS, // char* (void)
};

#endif // QMM_ARCH_32

#endif // QMM2_GAME_STVOYSP_H
15 changes: 7 additions & 8 deletions include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,21 @@ struct gameinfo {
std::string qmm_file; // filename of qmm dll
std::string mod_dir; // active mod dir
std::string cfg_path; // qmm config file path
eng_syscall pfnsyscall = nullptr; // game-specific wrapper for syscall. given to plugins and called by QMM
mod_vmMain pfnvmMain = nullptr; // game-specific wrapper for vmMain. given to plugins and called by QMM
api_supportedgame* game = nullptr; // loaded engine from supported games table from game_api.cpp
GameSupport* game = nullptr; // loaded engine from supported games table from game_api.cpp
eng_syscall syscall = nullptr; // syscall from dllEntry (if applicable) to call G_ERROR if needed
void* qmm_module_ptr = nullptr; // qmm module pointer
bool is_auto_detected = false; // was this engine auto-detected?
bool is_shutdown = false; // is game shutting down due to G_ERROR? avoids calling G_ERROR again from GAME_SHUTDOWN
APIType api = QMM_API_ERROR; // engine api that QMM was loaded with
};
extern gameinfo g_gameinfo;

#define QMM_ENG_MSG (g_gameinfo.game->funcs->qmm_eng_msgs)
#define QMM_MOD_MSG (g_gameinfo.game->funcs->qmm_mod_msgs)
#define QMM_ENG_MSG g_gameinfo.game->QMMEngMsg
#define QMM_MOD_MSG g_gameinfo.game->QMMModMsg

#define ENG_SYSCALL (g_gameinfo.pfnsyscall)
#define CONSOLE_PRINT(str) ENG_SYSCALL(msg_G_PRINT, str)
#define CONSOLE_PRINTF(str, ...) ENG_SYSCALL(msg_G_PRINT, fmt::format(str, ## __VA_ARGS__).c_str())
#define ENG_SYSCALL g_gameinfo.game->syscall
#define CONSOLE_PRINT(str) ENG_SYSCALL(msg_G_PRINT, str)
#define CONSOLE_PRINTF(str, ...) ENG_SYSCALL(msg_G_PRINT, fmt::format(str, ## __VA_ARGS__).c_str())

// this is used if we couldn't determine a game engine and we have to fail.
// G_ERROR appears to be 1 in all supported dllEntry games. they are different in some GetGameAPI games,
Expand Down
4 changes: 2 additions & 2 deletions include/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Created By:
#define STRINGIFY2(x) #x

#define QMM_VERSION_MAJOR 2
#define QMM_VERSION_MINOR 4
#define QMM_VERSION_REV 9
#define QMM_VERSION_MINOR 5
#define QMM_VERSION_REV 0

#define QMM_VERSION STRINGIFY(QMM_VERSION_MAJOR) "." STRINGIFY(QMM_VERSION_MINOR) "." STRINGIFY(QMM_VERSION_REV)

Expand Down
55 changes: 27 additions & 28 deletions src/game_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Created By:
// cache some dynamic message values that get evaluated a lot
intptr_t msg_G_PRINT, msg_GAME_INIT, msg_GAME_CONSOLE_COMMAND, msg_GAME_SHUTDOWN;

// externs for each game's functions/structs
// externs for each game's support objects
GEN_GAME_EXTS(COD11MP);
GEN_GAME_EXTS(CODMP);
GEN_GAME_EXTS(CODUOMP);
Expand All @@ -41,46 +41,45 @@ GEN_GAME_EXTS(SOF2SP);
GEN_GAME_EXTS(STEF2);
GEN_GAME_EXTS(STVOYSP);

// add your game's info data here
std::vector<api_supportedgame> api_supportedgames = {
// mod filename qvm mod filename default moddir full gamename short name/funcs #syscall#vmmain

// vmMain games
{ "qagame" MOD_DLL, "vm/qagame.qvm", "baseq3", "Quake 3 Arena", GEN_GAME_INFO(Q3A), 13, 4 },
{ "qagame" SP_DLL X64_DLL, nullptr, ".", "Return to Castle Wolfenstein (SP)", GEN_GAME_INFO(RTCWSP), 13, 5 },
{ "jk2mpgame" MOD_DLL, "vm/jk2mpgame.qvm", "base", "Jedi Knight 2: Jedi Outcast (MP)", GEN_GAME_INFO(JK2MP), 13, 3 },
{ "jampgame" MOD_DLL, nullptr, "base", "Jedi Knight: Jedi Academy (MP)", GEN_GAME_INFO(JAMP), 13, 6 },
{ "qagame" MP_DLL X64_DLL, nullptr, "etmain", "Wolfenstein: Enemy Territory", GEN_GAME_INFO(WET), 13, 5 },
{ "qagame" MP_DLL X64_DLL, "vm/qagame.mp.qvm", "main", "Return to Castle Wolfenstein (MP)", GEN_GAME_INFO(RTCWMP), 13, 5 },
std::vector<GameSupport*> api_supportedgames = {
// vmMain games
GET_GAME_OBJ(Q3A),
GET_GAME_OBJ(RTCWSP),
GET_GAME_OBJ(JK2MP),
GET_GAME_OBJ(JAMP),
GET_GAME_OBJ(WET),
GET_GAME_OBJ(RTCWMP),

// these games don't appear to have an official 64-bit version or source port
#if defined(QMM_ARCH_32)
{ "qagame" MOD_DLL, "vm/qagame.qvm", "baseef", "Star Trek Voyager: Elite Force (Holomatch)", GEN_GAME_INFO(STVOYHM), 13, 3 },
{ "sof2mp_game" MOD_DLL, "vm/sof2mp_game.qvm","base/mp", "Soldier of Fortune 2: Double Helix (MP)", GEN_GAME_INFO(SOF2MP), 13, 6 },
{ "game" MP_DLL MOD_DLL, nullptr, "Main", "Call of Duty (MP)", GEN_GAME_INFO(CODMP), 8, 4 },
{ "" UO_DLL MOD_DLL, nullptr, "uo", "Call of Duty: United Offensive (MP)", GEN_GAME_INFO(CODUOMP), 8, 4 },
GET_GAME_OBJ(STVOYHM),
GET_GAME_OBJ(SOF2MP),
GET_GAME_OBJ(CODMP),
GET_GAME_OBJ(CODUOMP),
// allow a user to choose "COD11MP" manually if they are playing an old version of CoD (no auto-detection)
{ "game" MP_DLL MOD_DLL, nullptr, "Main", "Call of Duty v1.1 (MP)", GEN_GAME_INFO(COD11MP), 8, 4 },
GET_GAME_OBJ(COD11MP),
#endif

// GetGameAPI games
{ "jk2game" MOD_DLL, nullptr, ".", "Jedi Knight 2: Jedi Outcast (SP)", GEN_GAME_INFO(JK2SP), 13, 9 },
{ "jagame" MOD_DLL, nullptr, ".", "Jedi Knight: Jedi Academy (SP)", GEN_GAME_INFO(JASP), 13, 9 },
{ "game" MOD_DLL, nullptr, "baseq2", "Quake 2", GEN_GAME_INFO(QUAKE2), 7, 3 },
{ "game" MOD_DLL, nullptr, "base", "SiN", GEN_GAME_INFO(SIN), 10, 3 },
GET_GAME_OBJ(JK2SP),
GET_GAME_OBJ(JASP),
GET_GAME_OBJ(QUAKE2),
GET_GAME_OBJ(SIN),

// OpenMOHAA adds 64-bit MoH support but the API is very different, so disable it for now
// the rest of the games don't appear to have an official 64-bit version or source port
#if defined(QMM_ARCH_32)
{ "game" MOD_DLL, nullptr, "main", "Medal of Honor: Allied Assault", GEN_GAME_INFO(MOHAA), 9, 7 },
{ "game" MOD_DLL, nullptr, "mainta", "Medal of Honor: Spearhead", GEN_GAME_INFO(MOHSH), 9, 7 },
{ "game" MOD_DLL, nullptr, "maintt", "Medal of Honor: Breakthrough", GEN_GAME_INFO(MOHBT), 9, 7 },
{ "game" MOD_DLL, nullptr, "base", "Star Trek: Elite Force II", GEN_GAME_INFO(STEF2), 17, 4 },
{ "game" MOD_DLL, nullptr, ".", "Soldier of Fortune 2: Double Helix (SP)", GEN_GAME_INFO(SOF2SP), 0, 0 },
{ "efgame" MOD_DLL, nullptr, ".", "Star Trek Voyager: Elite Force (SP)", GEN_GAME_INFO(STVOYSP), 13, 9 },
GET_GAME_OBJ(MOHAA),
GET_GAME_OBJ(MOHSH),
GET_GAME_OBJ(MOHBT),
GET_GAME_OBJ(STEF2),
GET_GAME_OBJ(SOF2SP),
GET_GAME_OBJ(STVOYSP),
#endif

// Q2R only exists for 64-bit Windows
#if defined(QMM_OS_WINDOWS) && defined(QMM_ARCH_64)
{ "game_" X64_DLL, nullptr, "baseq2", "Quake 2 Remastered", GEN_GAME_INFO(Q2R), 9, 6 },
GET_GAME_OBJ(Q2R),
#endif
};

Expand Down
Loading
Loading