Skip to content

Commit

Permalink
[MP] reconcile game module changes with the original source releases …
Browse files Browse the repository at this point in the history
…by diffing codemp/game (JACoders#1178)

* reconcile game module changes with the SDK release by diffing codemp/game

* revert saberMoveData changes to match basejka, provide a new cvar (g_fixSaberMoveData) to patch it if desired
* introduce a new configstring (26: CS_LEGACY_FIXES) to inform the client of which fixes it should also apply, e.g. saberMoveData
* client module obtains gamestate (including configstrings) earlier to prevent use before initialisation, which is now checked for in debug builds
* revert a change to saber disarm bonus calculation if g_fixSaberDisarmBonus is not enabled
* G_CanBeEnemy considers private duels once again (removed from modbase before its git history)

* add disclaimer to legacyFixes_e

* revert: client module obtains gamestate (including configstrings) earlier to prevent use before initialisation

this was causing issues loading incorrect clientinfo

(cherry picked from commit 142e0b7)
  • Loading branch information
Razish authored and taysta committed Feb 23, 2024
1 parent 0af68dc commit 8c62f90
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 25 deletions.
3 changes: 3 additions & 0 deletions codemp/cgame/cg_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1903,6 +1903,9 @@ CG_ConfigString
=================
*/
const char *CG_ConfigString( int index ) {
// FIXME: don't read configstrings before initialisation
// assert( cgs.gameState.dataCount != 0 );

if ( index < 0 || index >= MAX_CONFIGSTRINGS ) {
trap->Error( ERR_DROP, "CG_ConfigString: bad index: %i", index );
}
Expand Down
17 changes: 15 additions & 2 deletions codemp/game/g_cvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,20 @@ static void CVU_YDFA(void) {
trap->Cvar_Set("jcinfo", va("%i", jcinfo.integer));
}
*/
static void CVU_FixSaberMoveData(void) {
BG_FixSaberMoveData();

char sLegacyFixes[32];
trap->GetConfigstring(CS_LEGACY_FIXES, sLegacyFixes, sizeof(sLegacyFixes));

uint32_t legacyFixes = strtoul(sLegacyFixes, NULL, 0);
if (g_fixSaberMoveData.integer) {
legacyFixes |= (1 << LEGACYFIX_SABERMOVEDATA);
} else {
legacyFixes &= ~(1 << LEGACYFIX_SABERMOVEDATA);
}
trap->SetConfigstring(CS_LEGACY_FIXES, va("%" PRIu32, legacyFixes));
}
static void CVU_Headslide(void) {
g_slideOnPlayer.integer ?
(jcinfo.integer |= JAPRO_CINFO_HEADSLIDE) : (jcinfo.integer &= ~JAPRO_CINFO_HEADSLIDE);
Expand Down Expand Up @@ -555,12 +568,12 @@ static void CVU_TribesClass(void) {

trap->GetUserinfo(i, userinfo, sizeof(userinfo));
Q_strncpyz(model, Info_ValueForKey(userinfo, "model"), sizeof(model));

if (g_tribesMode.integer == 1) {
if (!ent->client->pers.tribesClass) {
if (ent->health > 0)
G_Kill(ent);
}
}
DetectTribesClass(ent, model);
}
else if (ent->client->pers.tribesClass) {
Expand Down
46 changes: 23 additions & 23 deletions codemp/game/g_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void SetGametypeFuncSolids (void) {
for (i = 0; i < level.num_entities; i++) {
ent = &g_entities[i];
if (ent->inuse) {
if (ent->s.eType == ET_MOVER && ent->spawnflags & 512) {
if (ent->s.eType == ET_MOVER && ent->spawnflags & 512) {
if (level.gametype == GT_CTF || level.gametype == GT_CTY) { //Make nonsolid/invis
ent->r.contents = 0;
ent->r.svFlags |= SVF_NOCLIENT;
Expand All @@ -153,9 +153,9 @@ void SetGametypeFuncSolids (void) {
ent->r.contents = CONTENTS_SOLID;
ent->r.svFlags &= ~SVF_NOCLIENT;
ent->s.eFlags &= ~EF_NODRAW;
}
}
}
else if (ent->r.contents == CONTENTS_TRIGGER && ent->spawnflags & 8192) {
else if (ent->r.contents == CONTENTS_TRIGGER && ent->spawnflags & 8192) {
if (level.gametype == GT_CTF || level.gametype == GT_CTY) { //Make nonsolid/invis
ent->flags |= FL_INACTIVE;
}
Expand Down Expand Up @@ -495,7 +495,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) {

if (level.gametype == GT_SIEGE)
{ //just get these configstrings registered now...

while (i < MAX_CUSTOM_SIEGE_SOUNDS)
{
if (!bg_customSiegeSoundNames[i])
Expand All @@ -505,7 +505,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) {
G_SoundIndex((char *)bg_customSiegeSoundNames[i]);
i++;
}

/*
for (i = 0; i < MAX_CUSTOM_SIEGE_SOUNDS; i++)
{
Expand All @@ -527,7 +527,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) {
i++;
}
*/


if ( level.gametype == GT_JEDIMASTER ) {
gentity_t *ent = NULL;
Expand Down Expand Up @@ -2138,7 +2138,7 @@ void PrintStats(int client) {
//Conditional label shit here:
//If ctf, ungroup suicides from deaths, otherwise just count them as deaths.
//If TFFA and showdrains , add drainratio
//If TFFA and teampowers, add TE/TH
//If TFFA and teampowers, add TE/TH
//If showaccuracy, show accuracy
//If CTF, show caps, returns, carrier kills

Expand All @@ -2157,12 +2157,12 @@ void PrintStats(int client) {
j++;
if (j%2)
Q_strcat(partialTmpMsg, sizeof(partialTmpMsg), S_COLOR_YELLOW);
else
else
Q_strcat(partialTmpMsg, sizeof(partialTmpMsg), S_COLOR_GREEN);

if(showAccuracy && cl->accuracy_shots)
if(showAccuracy && cl->accuracy_shots)
accuracy = 100.0f * (float)cl->accuracy_hits / (float)cl->accuracy_shots;
if (cl->ps.persistant[PERS_KILLED])
if (cl->ps.persistant[PERS_KILLED])
dmgPerDeath = cl->pers.stats.damageGiven / cl->ps.persistant[PERS_KILLED];
if (cl->pers.stats.enemyDrainDamage + cl->pers.stats.teamDrainDamage)
drainRatio = 100.0f * (float)cl->pers.stats.enemyDrainDamage / (float)(cl->pers.stats.enemyDrainDamage + cl->pers.stats.teamDrainDamage);
Expand All @@ -2180,7 +2180,7 @@ void PrintStats(int client) {
Com_sprintf (partialTmpMsg2, sizeof(partialTmpMsg2), "%-*s", strlen(lDmgNet), int_to_string(cl->pers.stats.damageGiven - cl->pers.stats.damageTaken - cl->pers.stats.teamDamageGiven, numbuf, sizeof(numbuf)));
Q_strcat(partialTmpMsg, sizeof(partialTmpMsg), partialTmpMsg2);
Com_sprintf (partialTmpMsg2, sizeof(partialTmpMsg2), "%-*s", strlen(lDmgPerDeath), int_to_string(dmgPerDeath, numbuf, sizeof(numbuf)));
Q_strcat(partialTmpMsg, sizeof(partialTmpMsg), partialTmpMsg2);
Q_strcat(partialTmpMsg, sizeof(partialTmpMsg), partialTmpMsg2);
if (level.gametype == GT_TEAM && g_friendlyFire.value) {
Com_sprintf (partialTmpMsg2, sizeof(partialTmpMsg2), "%-*s", strlen(lTK), int_to_string(cl->pers.stats.teamDamageGiven, numbuf, sizeof(numbuf)));
Q_strcat(partialTmpMsg, sizeof(partialTmpMsg), partialTmpMsg2);
Expand All @@ -2193,7 +2193,7 @@ void PrintStats(int client) {
Com_sprintf (partialTmpMsg2, sizeof(partialTmpMsg2), "%-*s", strlen(lFragCarrier), int_to_string(cl->pers.teamState.fragcarrier, numbuf, sizeof(numbuf)));
Q_strcat(partialTmpMsg, sizeof(partialTmpMsg), partialTmpMsg2);

}
}
if (showAccuracy) {
Com_sprintf (partialTmpMsg2, sizeof(partialTmpMsg2), "%-*s", strlen(lAccuracy), int_to_string(accuracy, numbuf, sizeof(numbuf)));
Q_strcat(partialTmpMsg, sizeof(partialTmpMsg), partialTmpMsg2);
Expand All @@ -2207,7 +2207,7 @@ void PrintStats(int client) {
if (showDrain) {
Com_sprintf (partialTmpMsg2, sizeof(partialTmpMsg2), "%-*s", strlen(lDrain), int_to_string(drainRatio, numbuf, sizeof(numbuf)));
Q_strcat(partialTmpMsg, sizeof(partialTmpMsg), partialTmpMsg2);
}
}
Com_sprintf (partialTmpMsg2, sizeof(partialTmpMsg2), "^7%-*s", strlen(lName), cl->pers.netname);
Q_strcat(partialTmpMsg, sizeof(partialTmpMsg), partialTmpMsg2);
Q_strcat(partialTmpMsg, sizeof(partialTmpMsg), "\n");
Expand Down Expand Up @@ -3590,7 +3590,7 @@ void G_RunFrame( int levelTime ) {
continue;
if (!level.clients[j].sess.raceMode || (level.clients[j].sess.sessionTeam == TEAM_SPECTATOR)) //Not in racemode, or in spec, show the msg?
trap->SendServerCommand( j, va("cp \"Match has been paused.\n%.0f seconds remaining\n\"", ceilf( (level.pause.time - level.time) / 1000.0f)) );
}
}
//trap->SendServerCommand( -1, va("cp \"Match has been paused.\n%.0f seconds remaining\n\"", ceilf( (level.pause.time - level.time) / 1000.0f)) );
lastMsgTime = level.time;
}
Expand All @@ -3600,13 +3600,13 @@ void G_RunFrame( int levelTime ) {
}
else if ( level.pause.state == PAUSE_UNPAUSING ) {
if ( lastMsgTime < level.time - 500 ) {

for (j=0; j<MAX_CLIENTS; j++) {//Also print to anyone spectating them..
if (!g_entities[j].inuse)
continue;
if (!level.clients[j].sess.raceMode || (level.clients[j].sess.sessionTeam == TEAM_SPECTATOR)) //Not in racemode, or in spec, show the msg?
trap->SendServerCommand( j, va("cp \"MATCH IS UNPAUSING\nin %.0f...\n\"", ceilf( (level.pause.time - level.time) / 1000.0f)) );
}
}
//trap->SendServerCommand( -1, va("cp \"MATCH IS UNPAUSING\nin %.0f...\n\"", ceilf( (level.pause.time - level.time) / 1000.0f)) );
lastMsgTime = level.time;
}
Expand All @@ -3618,7 +3618,7 @@ void G_RunFrame( int levelTime ) {
continue;
if (!level.clients[j].sess.raceMode || (level.clients[j].sess.sessionTeam == TEAM_SPECTATOR)) //Not in racemode, or in spec, show the msg?
trap->SendServerCommand( i, "cp \"Fight!\n\"" );
}
}
//trap->SendServerCommand( -1, "cp \"Fight!\n\"" );
}
}
Expand Down Expand Up @@ -3915,7 +3915,7 @@ void G_RunFrame( int levelTime ) {
ent->client->ps.jetpackFuel -= 4;
//Special case for down jet here?
}

if (ent->client->ps.jetpackFuel <= 0)
{ //turn it off
ent->client->ps.jetpackFuel = 0;
Expand Down Expand Up @@ -3950,7 +3950,7 @@ void G_RunFrame( int levelTime ) {
else if (!ent->waterlevel)
ent->client->ps.fd.forcePower -= 4;//Light

if (ent->client->ps.fd.forcePower <= 0)
if (ent->client->ps.fd.forcePower <= 0)
ent->client->ps.fd.forcePower = 0;
ent->client->jetPackDebReduce = level.time + JETPACK_DEFUEL_RATE;
}
Expand Down Expand Up @@ -4157,8 +4157,8 @@ void G_RunFrame( int levelTime ) {
ent->client->pers.stats.displacement += xyspeed/sv_fps.value;
ent->client->pers.stats.displacementSamples++;
if (xyspeed > ent->client->pers.stats.topSpeed)
ent->client->pers.stats.topSpeed = xyspeed; //uhh, round?
}
ent->client->pers.stats.topSpeed = xyspeed; //uhh, round?
}
if (ent->client->ps.duelInProgress) {
if (!ent->client->pers.stats.lowestHP || ent->client->ps.stats[STAT_HEALTH] < ent->client->pers.stats.lowestHP)
ent->client->pers.stats.lowestHP = ent->client->ps.stats[STAT_HEALTH];
Expand Down Expand Up @@ -4201,7 +4201,7 @@ void G_RunFrame( int levelTime ) {
// NOW run the missiles, with all players backward-reconciled
// to the positions they were in exactly 50ms ago, at the end
// of the last server frame

/*
if (g_unlagged.integer & UNLAGGED_PROJ_REC)
{
Expand Down Expand Up @@ -4716,7 +4716,7 @@ static void G_AddSingleBox( vec3_t mins, vec3_t maxs ) {
bmaxs[0] = bmaxs[1] = x;
bmins[2] = -zd;
bmaxs[2] = zu;

if ( developer.integer ) {
Com_Printf( "Loaded box entity %d\n", ent->s.number );
Com_Printf( "mins %f %f %f\norigin %f %f %f\nmaxs %f %f %f\nsolid: %d\nbmins %f %f %f\nbmaxs %f %f %f\n",
Expand Down

0 comments on commit 8c62f90

Please sign in to comment.