Skip to content

Commit

Permalink
Merged pull request "Sync with Q2PRO: Game fixes & improvements": #436
Browse files Browse the repository at this point in the history
  • Loading branch information
apanteleev committed Feb 19, 2025
2 parents 7ef9373 + aa2e825 commit d5c8070
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
26 changes: 16 additions & 10 deletions inc/shared/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,18 @@ typedef enum {

// extended features

#define GMF_CLIENTNUM 0x00000001
#define GMF_PROPERINUSE 0x00000002
#define GMF_MVDSPEC 0x00000004
#define GMF_WANT_ALL_DISCONNECTS 0x00000008

#define GMF_ENHANCED_SAVEGAMES 0x00000400
#define GMF_VARIABLE_FPS 0x00000800
#define GMF_EXTRA_USERINFO 0x00001000
#define GMF_IPV6_ADDRESS_AWARE 0x00002000
// R1Q2 and Q2PRO specific
#define GMF_CLIENTNUM 0x00000001 // game sets clientNum gclient_s field
#define GMF_PROPERINUSE 0x00000002 // game maintains edict_s inuse field properly
#define GMF_MVDSPEC 0x00000004 // game is dummy MVD client aware
#define GMF_WANT_ALL_DISCONNECTS 0x00000008 // game wants ClientDisconnect() for non-spawned clients

// Q2PRO specific
#define GMF_ENHANCED_SAVEGAMES 0x00000400 // game supports safe/portable savegames
#define GMF_VARIABLE_FPS 0x00000800 // game supports variable server FPS
#define GMF_EXTRA_USERINFO 0x00001000 // game wants extra userinfo after normal userinfo
#define GMF_IPV6_ADDRESS_AWARE 0x00002000 // game supports IPv6 addresses
#define GMF_ALLOW_INDEX_OVERFLOW 0x00004000 // game wants PF_FindIndex() to return 0 on overflow

//===============================================================

Expand All @@ -69,9 +72,12 @@ struct gclient_s {
player_state_t ps; // communicated by server to clients
int ping;

// set to (client POV entity number) - 1 by game,
// only valid if g_features has GMF_CLIENTNUM bit
int clientNum;

// the game dll can add anything it wants after
// this point in the structure
int clientNum;
};


Expand Down
6 changes: 5 additions & 1 deletion src/server/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ static int PF_FindIndex(const char *name, int start, int max, const char *func)
}

if (i == max) {
if (g_features->integer & GMF_ALLOW_INDEX_OVERFLOW) {
Com_DPrintf("%s(%s): overflow\n", func, name);
return 0;
}
Com_Error(ERR_DROP, "%s(%s): overflow", func, name);
}

Expand Down Expand Up @@ -113,7 +117,7 @@ static void PF_Unicast(edict_t *ent, qboolean reliable)
flags |= MSG_RELIABLE;
}

if (cmd == svc_layout || (cmd == svc_configstring && msg_write.data[1] == CS_STATUSBAR)) {
if (cmd == svc_layout || (cmd == svc_configstring && RL16(&msg_write.data[1]) == CS_STATUSBAR)) {
flags |= MSG_COMPRESS_AUTO;
}

Expand Down
2 changes: 1 addition & 1 deletion src/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define SV_FEATURES (GMF_CLIENTNUM | GMF_PROPERINUSE | GMF_MVDSPEC | \
GMF_WANT_ALL_DISCONNECTS | GMF_ENHANCED_SAVEGAMES | \
SV_GMF_VARIABLE_FPS | GMF_EXTRA_USERINFO | \
GMF_IPV6_ADDRESS_AWARE)
GMF_IPV6_ADDRESS_AWARE | GMF_ALLOW_INDEX_OVERFLOW)

// ugly hack for SV_Shutdown
#define MVD_SPAWN_DISABLED 0
Expand Down

0 comments on commit d5c8070

Please sign in to comment.