Skip to content

Commit

Permalink
Merge pull request #233 from Iceman12k/reki/sync/aq2-tng
Browse files Browse the repository at this point in the history
Fixed various protocol 38/AQTION_EXTENSION issues from the new GameAPIEx upstream changes
  • Loading branch information
darkshade9 authored Oct 27, 2024
2 parents 3418abc + ab3e483 commit e092829
Show file tree
Hide file tree
Showing 31 changed files with 130 additions and 125 deletions.
2 changes: 1 addition & 1 deletion inc/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common/net/net.h"
#include "common/utils.h"

#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
#include "shared/ghud.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion inc/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void Sys_Printf(const char *fmt, ...) q_printf(1, 2);
#define COM_DEDICATED 1
#endif

#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
void G_InitializeExtensions(void);
#endif

Expand Down
2 changes: 1 addition & 1 deletion inc/common/msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void MSG_ParseDeltaPlayerstate_Enhanced(const player_state_t *from, player_st
void MSG_ParseDeltaPlayerstate_Aqtion(const player_state_t *from, player_state_t *to, int flags, int extraflags, msgPsFlags_t psflags);
#endif
void MSG_ParseDeltaPlayerstate_Packet(player_state_t *to, int flags, msgPsFlags_t psflags);
#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
int MSG_DeltaGhud(ghud_element_t *from, ghud_element_t *to, int protocolmask);
void MSG_WriteGhud(ghud_element_t *element, int flags);
#if USE_CLIENT || USE_MVD_CLIENT
Expand Down
4 changes: 2 additions & 2 deletions inc/shared/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct gclient_old_s {

// the game dll can add anything it wants after
// this point in the structure
#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
cvarsyncvalue_t cl_cvar[CVARSYNC_MAX];
#endif
};
Expand All @@ -126,7 +126,7 @@ struct gclient_new_s {

// the game dll can add anything it wants after
// this point in the structure
#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
cvarsyncvalue_t cl_cvar[CVARSYNC_MAX];
#endif
};
Expand Down
10 changes: 5 additions & 5 deletions inc/shared/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ typedef enum {
PRINT_NOTICE // print in cyan color
} print_type_t;

#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
#include "shared/ghud.h"
#endif

Expand Down Expand Up @@ -933,7 +933,7 @@ typedef struct cvar_s {
struct cvar_s *next;

// ------ new stuff ------
#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
int sync_index;
#endif
#if USE_NEW_GAME_API
Expand Down Expand Up @@ -1091,7 +1091,7 @@ typedef enum {
#define PMF_ON_LADDER BIT(8)
//KEX

#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
// pmove->pm_aq2_flags
#define PMF_AQ2_LIMP 0x01 // used to predict limping
#define PMF_AQ2_FRICTION 0x02 //rekkie -- Increase friction for bots
Expand All @@ -1112,7 +1112,7 @@ typedef struct {
short gravity;
short delta_angles[3]; // add to command angles to get view direction
// changed by spawns, rotating objects, and teleporters
#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
short pm_aq2_flags; // limping, bandaging, etc
unsigned short pm_timestamp; // timestamp, resets every 60 seconds
byte pm_aq2_leghits; // number of leg hits
Expand All @@ -1130,7 +1130,7 @@ typedef struct {
int16_t gravity;
int16_t delta_angles[3]; // add to command angles to get view direction
// changed by spawns, rotating objects, and teleporters
#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
short pm_aq2_flags; // limping, bandaging, etc
unsigned short pm_timestamp; // timestamp, resets every 60 seconds
byte pm_aq2_leghits; // number of leg hits
Expand Down
2 changes: 1 addition & 1 deletion src/action/a_esp.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ void EspMakeCapturePoint(edict_t *flag)
/* Indicator arrow
This appears regardless of indicator settings
*/
#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
if (!flag->obj_arrow){
flag->obj_arrow = G_Spawn();
flag->obj_arrow->solid = SOLID_NOT;
Expand Down
4 changes: 2 additions & 2 deletions src/action/a_team.c
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ void JoinTeam (edict_t * ent, int desired_team, int skip_menuclose)
G_UpdatePlayerStatusbar(ent, 1);
}

#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
if (desired_team == NOTEAM)
HUD_SetType(ent, 1);
else
Expand Down Expand Up @@ -1566,7 +1566,7 @@ void LeaveTeam (edict_t * ent)
ent->client->resp.team = NOTEAM;
G_UpdatePlayerStatusbar(ent, 1);

#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
HUD_SetType(ent, 1);
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/action/g_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ static void Cmd_PrintSettings_f( edict_t * ent )
itmflagsSettings( text, sizeof( text ), (int)itm_flags->value );

length = strlen( text );
#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
Q_snprintf( text + length, sizeof( text ) - length, "\n"
"timelimit %2d roundlimit %2d roundtimelimit %2d\n"
"limchasecam %2d tgren %2d antilag_interp %2d\n"
Expand Down
4 changes: 2 additions & 2 deletions src/action/g_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "g_local.h"
#include "q_ghud.h"

#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
//
// Reki
// Setup struct and macro for defining engine-callable entrypoints
Expand Down Expand Up @@ -297,7 +297,7 @@ void G_InitExtEntrypoints(void)
}


void* G_FetchGameExtension(char *name)
void* G_FetchGameExtension(const char *name)
{
Com_Printf("Game: G_FetchGameExtension for %s\n", name);
extension_func_t *ext;
Expand Down
24 changes: 12 additions & 12 deletions src/action/g_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ typedef struct

int model_null;
int model_lsight;
#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
int model_arrow;
#endif

Expand Down Expand Up @@ -1374,7 +1374,7 @@ extern cvar_t *lca_grenade; // Allows grenade pin pulling during LCA
extern cvar_t *breakableglass; // Moved from cgf_sfx_glass, enables breakable glass (0,1,2)
extern cvar_t *glassfragmentlimit; // Moved from cgf_sfx_glass, sets glass fragment limit

#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
extern int (*engine_Client_GetVersion)(edict_t *ent);
extern int (*engine_Client_GetProtocol)(edict_t *ent);

Expand Down Expand Up @@ -1437,7 +1437,7 @@ extern cvar_t *gm; // Gamemode
extern cvar_t *gmf; // Gamemodeflags
extern cvar_t *sv_idleremove; // Remove idlers

#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
extern cvar_t *use_newirvision; // enable new irvision (only highlight baddies)
extern cvar_t *use_indicators; // enable/allow indicators
extern cvar_t *use_xerp; // allow clients to use cl_xerp
Expand Down Expand Up @@ -1656,9 +1656,9 @@ void ClientBeginServerFrame (edict_t * ent);
//
// g_ext.c
//
#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
void G_InitExtEntrypoints(void);
void* G_FetchGameExtension(char *name);
void* G_FetchGameExtension(const char *name);
#endif

//
Expand Down Expand Up @@ -1890,7 +1890,7 @@ typedef struct
int limp_nopred;
int spec_flags;
qboolean antilag_optout;
#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
int cl_xerp;
int cl_indicators;
#endif
Expand Down Expand Up @@ -2002,7 +2002,7 @@ typedef struct
vec3_t jmp_teleport_v_angle;
qboolean jmp_teleport_ducked;

#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
int hud_items[128];
int hud_type;
#endif
Expand Down Expand Up @@ -2054,7 +2054,7 @@ struct gclient_s
int clientNum;

// Reki: cvar sync
#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
cvarsyncvalue_t cl_cvar[CVARSYNC_MAX];
#endif

Expand Down Expand Up @@ -2240,7 +2240,7 @@ struct gclient_s
int ctf_grapplereleaseframe; // frame of grapple release
qboolean ctf_hasflag; // set to true if this client has the flag

#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
//AQTION - Reki: Teammate indicators
edict_t *arrow;
#endif
Expand Down Expand Up @@ -2760,7 +2760,7 @@ struct edict_s
vec3_t lastPosition;
qboolean nameused[NUMNAMES][NUMNAMES];
qboolean newnameused[AQ2WTEAMSIZE];
#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
//AQTION - Reki: Entity indicators
edict_t *obj_arrow;
#endif
Expand Down Expand Up @@ -2917,7 +2917,7 @@ typedef struct team_s
char leader_name[MAX_SKINLEN];
char leader_skin[MAX_QPATH];
char leader_skin_index[MAX_QPATH];
#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
#if AQTION_HUD
int ghud_resettime;
byte ghud_icon;
Expand All @@ -2943,7 +2943,7 @@ extern int gameSettings;
#include "a_dom.h"
#include "a_esp.h"

#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
#define HAS_CVARSYNC(ent) (Client_GetProtocol(ent) == 38 && Client_GetVersion(ent) >= 3013)

// hud (through ghud extension)
Expand Down
52 changes: 26 additions & 26 deletions src/action/g_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ cvar_t *lca_grenade; // Allows grenade pin pulling during LCA
cvar_t *breakableglass; // Moved from cgf_sfx_glass, enables breakable glass (0,1,2)
cvar_t *glassfragmentlimit; // Moved from cgf_sfx_glass, sets glass fragment limit

#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
cvar_t *use_newirvision;
cvar_t *use_indicators;
cvar_t *use_xerp;
Expand Down Expand Up @@ -696,39 +696,39 @@ const game_export_ex_t gex = {

// // Functionality examples?
// // https://github.com/skullernet/q2pro/issues/294#issuecomment-1476818818
//.GetExtension = GetExtension,
.GetExtension = G_FetchGameExtension,

};

q_exported const game_export_ex_t *GetGameAPIEx(game_import_ex_t *importx)
{
gix = importx; // assign pointer, don't copy!

//gex.CheckForExtension = G_FetchGameExtension;
//gex.GetExtension = G_FetchGameExtension;
G_InitExtEntrypoints();
engine_Client_GetProtocol = gix->CheckForExtension("Client_GetProtocol");
engine_Client_GetVersion = gix->CheckForExtension("Client_GetVersion");

engine_Ghud_ClearForClient = gix->CheckForExtension("Ghud_ClearForClient");
engine_Ghud_NewElement = gix->CheckForExtension("Ghud_NewElement");
engine_Ghud_RemoveElement = gix->CheckForExtension("Ghud_RemoveElement");
engine_Ghud_SetFlags = gix->CheckForExtension("Ghud_SetFlags");
engine_Ghud_SetInt = gix->CheckForExtension("Ghud_SetInt");
engine_Ghud_SetText = gix->CheckForExtension("Ghud_SetText");
engine_Ghud_SetPosition = gix->CheckForExtension("Ghud_SetPosition");
engine_Ghud_SetAnchor = gix->CheckForExtension("Ghud_SetAnchor");
engine_Ghud_SetColor = gix->CheckForExtension("Ghud_SetColor");
engine_Ghud_SetSize = gix->CheckForExtension("Ghud_SetSize");

engine_CvarSync_Set = gix->CheckForExtension("CvarSync_Set");

SV_BSP = gix->CheckForExtension("Bsp");
CS_NAV = gix->CheckForExtension("Nav");
CS_DebugDraw = gix->CheckForExtension("DebugDraw");
SV_BotConnect = gix->CheckForExtension("SV_BotConnect");
SV_BotDisconnect = gix->CheckForExtension("SV_BotDisconnect");
SV_BotUpdateInfo = gix->CheckForExtension("SV_BotUpdateInfo");
SV_BotClearClients = gix->CheckForExtension("SV_BotClearClients");
engine_Client_GetProtocol = gix->GetExtension("Client_GetProtocol");
engine_Client_GetVersion = gix->GetExtension("Client_GetVersion");

engine_Ghud_ClearForClient = gix->GetExtension("Ghud_ClearForClient");
engine_Ghud_NewElement = gix->GetExtension("Ghud_NewElement");
engine_Ghud_RemoveElement = gix->GetExtension("Ghud_RemoveElement");
engine_Ghud_SetFlags = gix->GetExtension("Ghud_SetFlags");
engine_Ghud_SetInt = gix->GetExtension("Ghud_SetInt");
engine_Ghud_SetText = gix->GetExtension("Ghud_SetText");
engine_Ghud_SetPosition = gix->GetExtension("Ghud_SetPosition");
engine_Ghud_SetAnchor = gix->GetExtension("Ghud_SetAnchor");
engine_Ghud_SetColor = gix->GetExtension("Ghud_SetColor");
engine_Ghud_SetSize = gix->GetExtension("Ghud_SetSize");

engine_CvarSync_Set = gix->GetExtension("CvarSync_Set");

SV_BSP = gix->GetExtension("Bsp");
CS_NAV = gix->GetExtension("Nav");
CS_DebugDraw = gix->GetExtension("DebugDraw");
SV_BotConnect = gix->GetExtension("SV_BotConnect");
SV_BotDisconnect = gix->GetExtension("SV_BotDisconnect");
SV_BotUpdateInfo = gix->GetExtension("SV_BotUpdateInfo");
SV_BotClearClients = gix->GetExtension("SV_BotClearClients");

return &gex;
}
Expand Down
4 changes: 2 additions & 2 deletions src/action/g_save.c
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ void InitGame( void )


// new AQtion Extension cvars
#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
use_newirvision = gi.cvar("use_newirvision", "1", 0);
use_indicators = gi.cvar("use_indicators", "1", 0);
use_xerp = gi.cvar("use_xerp", "1", 0);
Expand Down Expand Up @@ -802,7 +802,7 @@ void InitGame( void )
gi.cvar_forceset("g_view_high", va("%d", STANDING_VIEWHEIGHT));
gi.cvar_forceset("g_view_low", va("%d", CROUCHING_VIEWHEIGHT));

#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
CvarSync_Set(clcvar_cl_antilag, "cl_antilag", "1");
CvarSync_Set(clcvar_cl_indicators, "cl_indicators", "1");
CvarSync_Set(clcvar_cl_xerp, "cl_xerp", "0");
Expand Down
2 changes: 1 addition & 1 deletion src/action/g_spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -2077,7 +2077,7 @@ void SP_worldspawn (edict_t * ent)

level.model_null = gi.modelindex("sprites/null.sp2"); // null sprite
level.model_lsight = gi.modelindex("sprites/lsight.sp2"); // laser sight dot sprite
#if AQTION_EXTENSION
#ifdef AQTION_EXTENSION
level.model_arrow = gi.modelindex("models/indicator/arrow_red.md2");
gi.modelindex("models/indicator/arrow_blue.md2");
gi.modelindex("models/indicator/arrow_green.md2");
Expand Down
Loading

0 comments on commit e092829

Please sign in to comment.