Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beginnings of enhanced protocol support #168

Open
wants to merge 7 commits into
base: aqtion-alpha
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ endif


ifeq ($(USE_AQTION),TRUE)
CFLAGS += -DUSE_AQTION -DAQTION_EXTENSION
CFLAGS += -DUSE_AQTION -DAQTION_EXTENSION -DUSE_AQ_CURL

ifneq (,$(findstring WIN32,$(TNG_BUILD_FOR))$(findstring WIN64,$(TNG_BUILD_FOR)))
CFLAGS += -I../q2pro-mgw-sdk/inc -DCURL_STATICLIB
Expand Down Expand Up @@ -140,6 +140,10 @@ ifdef NO_BOTS
CFLAGS+=-DNO_BOTS
endif

ifndef NO_PROTOCOL_EXTENSIONS
CFLAGS+=-DUSE_PROTOCOL_EXTENSIONS
endif

## Use this to build on older glibc/gcc for older dedicated servers
ifdef C99COMPAT
CFLAGS+=-std=c99
Expand Down
6 changes: 3 additions & 3 deletions source/a_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ void SetIDView(edict_t * ent)
if (ent->client->chase_mode) {
if (ent->client->chase_target && ent->client->chase_target->inuse) {
ent->client->ps.stats[STAT_ID_VIEW] =
CS_PLAYERSKINS + (ent->client->chase_target - g_edicts - 1);
game.csr.playerskins + (ent->client->chase_target - g_edicts - 1);
}
return;
}
Expand All @@ -934,7 +934,7 @@ void SetIDView(edict_t * ent)
tr = gi.trace(ent->s.origin, NULL, NULL, forward, ent, MASK_SOLID);
POSTTRACE();
if (tr.fraction < 1 && tr.ent && tr.ent->client) {
ent->client->ps.stats[STAT_ID_VIEW] = CS_PLAYERSKINS + (ent - g_edicts - 1);
ent->client->ps.stats[STAT_ID_VIEW] = game.csr.playerskins + (ent - g_edicts - 1);
return;
}

Expand All @@ -958,7 +958,7 @@ void SetIDView(edict_t * ent)
}
}
if (best != NULL && bd > 0.90) {
ent->client->ps.stats[STAT_ID_VIEW] = CS_PLAYERSKINS + (best - g_edicts - 1);
ent->client->ps.stats[STAT_ID_VIEW] = game.csr.playerskins + (best - g_edicts - 1);
}
}

Expand Down
8 changes: 4 additions & 4 deletions source/a_team.c
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ void AssignSkin (edict_t * ent, const char *s, qboolean nickChanged)
}
}

gi.configstring(CS_PLAYERSKINS + playernum, skin);
gi.configstring(game.csr.playerskins + playernum, skin);
}

/*
Expand Down Expand Up @@ -1516,7 +1516,7 @@ void JoinTeam (edict_t * ent, int desired_team, int skip_menuclose)
AddToTransparentList (ent);
}

#if USE_AQTION
#ifdef USE_AQTION
if (in_warmup && warmup_bots->value) {
PutClientInServer (ent);
}
Expand Down Expand Up @@ -2313,7 +2313,7 @@ void RunWarmup ()
gi.centerprintf(ent, "WARMUP");
}
}
#if USE_AQTION
#ifdef USE_AQTION
if (warmup_bots->value){
gi.cvar_forceset("am", "1");
gi.cvar_forceset("am_botcount", warmup_bots->string);
Expand Down Expand Up @@ -2799,7 +2799,7 @@ int CheckTeamRules (void)
gi.sound (&g_edicts[0], CHAN_VOICE | CHAN_NO_PHS_ADD,
gi.soundindex ("world/10_0.wav"), 1.0, ATTN_NONE, 0.0);

#if USE_AQTION
#ifdef USE_AQTION
// Cleanup and remove all bots, it's go time!
if (warmup_bots->value){
gi.cvar_forceset("am", "0");
Expand Down
116 changes: 103 additions & 13 deletions source/g_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,21 +298,36 @@
#define getEnt(entnum) (edict_t *)((char *)globals.edicts + (globals.edict_size * entnum)) //AQ:TNG Slicer - This was missing
#define GAMEVERSION "action" // the "gameversion" client command will print this plus compile date

// features this game supports

// R1Q2 and Q2PRO specific
#define GMF_CLIENTNUM BIT(0) // game sets clientNum gclient_s field
#define GMF_PROPERINUSE BIT(1) // game maintains edict_s inuse field properly
#define GMF_MVDSPEC BIT(2) // game is dummy MVD client aware
#define GMF_WANT_ALL_DISCONNECTS BIT(3) // game wants ClientDisconnect() for non-spawned clients

// Q2PRO specific
#define GMF_ENHANCED_SAVEGAMES BIT(10) // game supports safe/portable savegames
#define GMF_VARIABLE_FPS BIT(11) // game supports variable server FPS
#define GMF_EXTRA_USERINFO BIT(12) // game wants extra userinfo after normal userinfo
#define GMF_IPV6_ADDRESS_AWARE BIT(13) // game supports IPv6 addresses
#define GMF_ALLOW_INDEX_OVERFLOW BIT(14) // game wants PF_FindIndex() to return 0 on overflow
#define GMF_PROTOCOL_EXTENSIONS BIT(15) // game supports protocol extensions

#define GMF_CLIENTNUM 0x00000001
#define GMF_PROPERINUSE 0x00000002
#define GMF_MVDSPEC 0x00000004
#define GMF_WANT_ALL_DISCONNECTS 0x00000008
#define GMF_VARIABLE_FPS 0x00000800
#define GMF_EXTRA_USERINFO 0x00001000

#ifndef NO_FPS
#define G_GMF_VARIABLE_FPS GMF_VARIABLE_FPS
#else
#define G_GMF_VARIABLE_FPS 0
#endif

#define G_FEATURES (GMF_CLIENTNUM | GMF_PROPERINUSE | GMF_MVDSPEC | GMF_WANT_ALL_DISCONNECTS | G_GMF_VARIABLE_FPS)
#ifdef USE_PROTOCOL_EXTENSIONS
#define G_GMF_PROTOCOL_EXTENSIONS GMF_PROTOCOL_EXTENSIONS
#else
#define G_GMF_PROTOCOL_EXTENSIONS 0
#endif

#define G_FEATURES (GMF_CLIENTNUM | GMF_PROPERINUSE | GMF_MVDSPEC | GMF_WANT_ALL_DISCONNECTS | G_GMF_VARIABLE_FPS | G_GMF_PROTOCOL_EXTENSIONS)

// protocol bytes that can be directly added to messages
#define svc_muzzleflash 1
Expand Down Expand Up @@ -728,7 +743,6 @@ typedef struct gitem_s
}
gitem_t;


//
// this structure is left intact through an entire game
// it should be initialized at dll load time, and read/written to
Expand Down Expand Up @@ -756,7 +770,10 @@ typedef struct

// items
int num_items;


//q2pro protocol extensions
cs_remap_t csr;

// stats
char matchid[MAX_QPATH];
int gamemode;
Expand Down Expand Up @@ -1163,6 +1180,7 @@ extern cvar_t *maptime;
extern cvar_t *capturelimit;
extern cvar_t *password;
extern cvar_t *g_select_empty;
extern cvar_t *g_protocol_extensions;
extern cvar_t *dedicated;
extern cvar_t *steamid;

Expand Down Expand Up @@ -1629,7 +1647,7 @@ void ProduceShotgunDamageReport(edict_t*);

//tng_stats.c
void StatBotCheck(void);
#if USE_AQTION
#ifdef USE_AQTION
void LogKill(edict_t *self, edict_t *inflictor, edict_t *attacker);
void LogWorldKill(edict_t *self);
void LogCapture(edict_t *capturer);
Expand Down Expand Up @@ -1731,7 +1749,7 @@ typedef struct
ignorelist_t ignorelist;
gitem_t *chosenItem2; // Support for item kit mode

#if USE_AQTION
#ifdef USE_AQTION
char steamid[24];
char discordid[24];
#endif
Expand Down Expand Up @@ -2070,6 +2088,63 @@ struct gclient_s
unsigned int dimension_observe;
};

#ifdef USE_PROTOCOL_EXTENSIONS


#define ENTITYNUM_BITS 13
#define ENTITYNUM_MASK (BIT(ENTITYNUM_BITS) - 1)

#define GUNINDEX_BITS 13 // upper 3 bits are skinnum
#define GUNINDEX_MASK (BIT(GUNINDEX_BITS) - 1)

typedef struct {
int morefx;
float alpha;
float scale;
float loop_volume;
float loop_attenuation;
} entity_state_extension_t;


typedef union {
struct {
entity_state_t state;
entity_state_extension_t state_extension;
};
struct {
entity_state_t s;
entity_state_extension_t x;
};
} centity_state_t;

typedef struct centity_s {
centity_state_t current;
centity_state_t prev; // will always be valid, but might just be a copy of current

vec3_t mins, maxs;
float radius; // from mid point

int serverframe; // if not current, this ent isn't in the frame

int trailcount; // for diminishing grenade trails
vec3_t lerp_origin; // for trails (variable hz)

#ifdef USE_FPS
int prev_frame;
int anim_start;

int event_frame;
#endif

int fly_stoptime;

float flashlightfrac;
} centity_t;

extern centity_t cl_entities[MAX_EDICTS];

#endif


struct edict_s
{
Expand Down Expand Up @@ -2099,7 +2174,7 @@ struct edict_s
int clipmask;
edict_t *owner;


entity_state_extension_t x;
// DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER
// EXPECTS THE FIELDS IN THAT ORDER!

Expand Down Expand Up @@ -2323,7 +2398,7 @@ typedef struct
gitem_t *weapon;
gitem_t *item;
// Extended stats
#if USE_AQTION
#ifdef USE_AQTION
char steamid[24];
char discordid[24];
#endif
Expand Down Expand Up @@ -2528,3 +2603,18 @@ extern Message *timedMessages;

void addTimedMessage(int teamNum, edict_t *ent, int seconds, char *msg);
void FireTimedMessages();

/*
=====================================================================

CONFIG STRING REMAPPING

=====================================================================
*/

#ifdef USE_PROTOCOL_EXTENSIONS

extern const cs_remap_t cs_remap_old;
extern const cs_remap_t cs_remap_new;

#endif
3 changes: 2 additions & 1 deletion source/g_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ cvar_t *password;
cvar_t *maxclients;
cvar_t *maxentities;
cvar_t *g_select_empty;
cvar_t *g_protocol_extensions;
cvar_t *dedicated;
cvar_t *steamid;
cvar_t *filterban;
Expand Down Expand Up @@ -1115,7 +1116,7 @@ void CycleLights (void)
}
temp[0] = brightness[day_cycle_at];
temp[1] = 0;
gi.configstring (CS_LIGHTS + 0, temp);
gi.configstring (game.csr.lights + 0, temp);
day_next_cycle = level.time + day_cycle->value;
}
}
Expand Down
36 changes: 23 additions & 13 deletions source/g_save.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ field_t fields[] = {
void InitGame( void )
{
cvar_t *cv;

int features = G_FEATURES;
InitCommandList();

IRC_init();
Expand Down Expand Up @@ -530,6 +530,7 @@ void InitGame( void )
CGF_SFX_InstallGlassSupport(); // william for CGF (glass fx)

g_select_empty = gi.cvar( "g_select_empty", "0", CVAR_ARCHIVE );
g_protocol_extensions = gi.cvar("g_protocol_extensions", "0", CVAR_LATCH);

run_pitch = gi.cvar( "run_pitch", "0.002", 0 );
run_roll = gi.cvar( "run_roll", "0.005", 0 );
Expand All @@ -540,6 +541,24 @@ void InitGame( void )
// flood control
flood_threshold = gi.cvar( "flood_threshold", "4", 0 );

gi.dprintf( "Reading extra server features\n" );
cv = gi.cvar( "sv_features", NULL, 0 );
if (cv) {
game.serverfeatures = (int)cv->value;

if (game.serverfeatures & GMF_CLIENTNUM) {
gi.dprintf( "...server supports GMF_CLIENTNUM\n" );
}

if (game.serverfeatures & GMF_PROTOCOL_EXTENSIONS && (int)g_protocol_extensions->value) {
features |= GMF_PROTOCOL_EXTENSIONS;
gi.dprintf( "...server supports GMF_PROTOCOL_EXTENSIONS\n" );
game.csr = cs_remap_new;
} else {
game.csr = cs_remap_old;
}
}

jump = gi.cvar ("jump", "0", /*CVAR_SERVERINFO|*/ CVAR_LATCH); // jumping mod -- removed from serverinfo 2022

warmup = gi.cvar( "warmup", "0", CVAR_LATCH );
Expand Down Expand Up @@ -649,7 +668,8 @@ void InitGame( void )

// initialize all entities for this game
game.maxentities = maxentities->value;
clamp(game.maxentities, globals.num_edicts, MAX_EDICTS);
//clamp(game.maxentities, globals.num_edicts, MAX_EDICTS);
clamp(game.maxentities, (int)maxclients->value + 1, game.csr.max_edicts);
g_edicts = gi.TagMalloc( game.maxentities * sizeof(g_edicts[0]), TAG_GAME );
globals.edicts = g_edicts;
globals.max_edicts = game.maxentities;
Expand All @@ -659,16 +679,6 @@ void InitGame( void )
//PG BUND - must be at end of gameinit:
vInitGame();

gi.dprintf( "Reading extra server features\n" );
cv = gi.cvar( "sv_features", NULL, 0 );
if (cv) {
game.serverfeatures = (int)cv->value;

if (game.serverfeatures & GMF_CLIENTNUM) {
gi.dprintf( "...server supports GMF_CLIENTNUM\n" );
}
}

// setup framerate parameters

game.framerate = BASE_FRAMERATE;
Expand Down Expand Up @@ -712,7 +722,7 @@ void InitGame( void )
}
#endif

gi.cvar_forceset("g_features", va("%d", G_FEATURES));
gi.cvar_forceset("g_features", va("%d", features));
gi.cvar_forceset("g_view_predict", "1");
gi.cvar_forceset("g_view_high", va("%d", STANDING_VIEWHEIGHT));
gi.cvar_forceset("g_view_low", va("%d", CROUCHING_VIEWHEIGHT));
Expand Down
Loading
Loading