Skip to content

Commit

Permalink
Upstream update (#157)
Browse files Browse the repository at this point in the history
* remove bloat

(cherry picked from commit ca17eb4)

* [Meta] trim EOL whitespace (JACoders#1202)

(cherry picked from commit 4547d40)

* [Meta] trim EOL whitespace (JACoders#1202)

* trim EOL whitespace

* draw the rest of the owl

* fix encoding issue with JK2 cg_effects.cpp

(cherry picked from commit 4547d40)

* [Shared] misc loop overrun fixes (JACoders#1201)

* misc loop overrun fixes

* revert RT_BEAM changes

the extra iteration is intentional to seal the tri strip

* revert inadvertent whitespace changes

(cherry picked from commit 6a8a880)

* [MP] reconcile game module changes with the original source releases 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)

* [MP] Remove BASE_COMPAT define (JACoders#1211)

* move BASE_COMPAT flag behind cmake option BuildMPWithCompatMode, add g_fixWeaponAttackAnim making use of CS_LEGACY_FIXES

* remove BASE_COMPAT and BuildMPWithCompatMode, add g_fixRunWalkAnims

* actually remove BuildMPWithCompatMode

(cherry picked from commit 1e8a799)

* [rend2] Fix refraction rendering again

Broke it in SomaZ@a257512#diff-f17621117755ac0b403c963e0eb2d08e8fb088bc6b32c0d077915b71bd93311c

* [rend2] Fix rendering misc_bsps

It works as expected now. The model handle was simply incorrect.

* [rend2] No need to seperate entity types in sp/mp anymore

* [rend2] Fix volume shadow inaccuracies

More or less broken in SomaZ@a257512#diff-15a6e6b851882a24a69cb29a788cafb3771b6b579ace4aa497a00e3cb0f53354

* [rend2] Fix out-of-bounds crash with weather

Thanks @kuvirah for this fix.

* let passengers eject from vehicles

(cherry picked from commit 057e259)

* Thomas

(cherry picked from commit 5fb9249)

* crashfix

(cherry picked from commit 34071a0)

* [Versioning] Add quotes around script variable

* [jaPRO] Don't crash players that are missing vehicle files

* [jaPRO] Default chatbox emojis on and timer msec off

---------

Co-authored-by: videoP <videoprofess@gmail.com>
Co-authored-by: razor <mrrazish@gmail.com>
Co-authored-by: SomaZ <17459161+somaz@users.noreply.github.com>
  • Loading branch information
4 people committed Feb 26, 2024
1 parent e2dbc45 commit cd784cb
Show file tree
Hide file tree
Showing 88 changed files with 1,414 additions and 1,377 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ if(WIN64)
endif()

if (APPLE)
set(SharedDefines "MACOS_X")
set(SharedDefines ${SharedDefines} "MACOS_X")
endif()

if (NOT WIN32 AND NOT APPLE)
set(SharedDefines "ARCH_STRING=\"${Architecture}\"")
set(SharedDefines ${SharedDefines} "ARCH_STRING=\"${Architecture}\"")
endif()

if(CMAKE_SYSTEM_NAME MATCHES "BSD")
Expand Down
4 changes: 2 additions & 2 deletions codemp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ if(BuildMPEngine OR BuildMPDed)
"${MPDir}/qcommon/qcommon.h"
"${MPDir}/qcommon/qfiles.h"
"${MPDir}/qcommon/tags.h"

${SharedCommonFiles}
)
source_group("common" FILES ${MPBotlibCommonFiles})
Expand Down Expand Up @@ -298,7 +298,7 @@ if(BuildMPEngine OR BuildMPDed)
endif(WIN32)
source_group("common" FILES ${MPEngineAndDedCommonFiles})
set(MPEngineAndDedFiles ${MPEngineAndDedFiles} ${MPEngineAndDedCommonFiles})

set(MPEngineAndDedCommonSafeFiles
"${SharedDir}/qcommon/safe/files.cpp"
"${SharedDir}/qcommon/safe/files.h"
Expand Down
2 changes: 1 addition & 1 deletion codemp/cgame/cg_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -6045,7 +6045,7 @@ static float CG_DrawTeamOverlay( float y, qboolean right, qboolean upper ) {
} else {
xx = x + w - TINYCHAR_WIDTH*cgs.widthRatioCoef;
}
for (j = 0; j <= PW_NUM_POWERUPS; j++) {
for (j = 0; j < PW_NUM_POWERUPS; j++) {
if (ci->powerups & (1 << j)) {

item = BG_FindItemForPowerup( j );
Expand Down
2 changes: 0 additions & 2 deletions codemp/cgame/cg_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -3852,7 +3852,6 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
//
// powerup events
//
#ifdef BASE_COMPAT
case EV_POWERUP_QUAD:
DEBUGNAME("EV_POWERUP_QUAD");
if ( es->number == cg.snap->ps.clientNum ) {
Expand All @@ -3869,7 +3868,6 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
}
//trap->S_StartSound (NULL, es->number, CHAN_ITEM, cgs.media.protectSound );
break;
#endif // BASE_COMPAT

case EV_FORCE_DRAINED:
DEBUGNAME("EV_FORCE_DRAINED");
Expand Down
4 changes: 4 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 Expand Up @@ -3225,6 +3228,7 @@ Ghoul2 Insert End
CG_ParseEntitiesFromString();

BG_FixSaberMoveData();
BG_FixWeaponAttackAnim();
}

//makes sure returned string is in localized format
Expand Down
2 changes: 1 addition & 1 deletion codemp/cgame/cg_newDraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ void CG_DrawNewTeamInfo(rectDef_t *rect, float text_x, float text_y, float scale
if ( ci->infoValid && ci->team == cg.snap->ps.persistant[PERS_TEAM]) {

xx = rect->x + 1;
for (j = 0; j <= PW_NUM_POWERUPS; j++) {
for (j = 0; j < PW_NUM_POWERUPS; j++) {
if (ci->powerups & (1 << j)) {

item = BG_FindItemForPowerup( j );
Expand Down
81 changes: 45 additions & 36 deletions codemp/cgame/cg_players.c
Original file line number Diff line number Diff line change
Expand Up @@ -5261,11 +5261,9 @@ static void CG_PlayerPowerups( centity_t *cent, refEntity_t *torso ) {
return;
}

#ifdef BASE_COMPAT
// quad gives a dlight
if ( powerups & ( 1 << PW_QUAD ) )
trap->R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.2f, 0.2f, 1 );
#endif // BASE_COMPAT
// quad gives a dlight
if ( powerups & ( 1 << PW_QUAD ) )
trap->R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.2f, 0.2f, 1 );

if (cent->currentState.eType == ET_NPC)
assert(cent->npcClient);
Expand Down Expand Up @@ -8559,19 +8557,24 @@ void BG_GetVehicleSkinName(char *skinname, int len);

void CG_CacheG2AnimInfo(char *modelName)
{
void *g2 = NULL;
char *slash;
char useModel[MAX_QPATH] = {0};
char useSkin[MAX_QPATH] = {0};
int animIndex;

Q_strncpyz(useModel, modelName, sizeof( useModel ) );
Q_strncpyz(useSkin, modelName, sizeof( useSkin ) );

if (modelName[0] == '$')
{ //it's a vehicle name actually, let's precache the whole vehicle
BG_GetVehicleModelName(useModel, useModel, sizeof( useModel ) );
BG_GetVehicleSkinName(useSkin, sizeof( useSkin ) );
void *g2 = NULL;
char *slash;
char useModel[MAX_QPATH] = {0};
char useSkin[MAX_QPATH] = {0};
int animIndex;

Q_strncpyz(useModel, modelName, sizeof( useModel ) );
Q_strncpyz(useSkin, modelName, sizeof( useSkin ) );

if (modelName[0] == '$')
{ //it's a vehicle name actually, let's precache the whole vehicle
char* vehType = &modelName[1];
int iVehIndex = BG_VehicleGetIndex(vehType);

if (iVehIndex == -1) { //Pre-empt a crash and just treat it as a swoop!
Q_strncpyz(useModel, "$swoop_mp", sizeof(useModel));
Q_strncpyz(useSkin, "$swoop_mp", sizeof(useSkin));
}
if ( useSkin[0] )
{ //use a custom skin
trap->R_RegisterSkin(va("models/players/%s/model_%s.skin", useModel, useSkin));
Expand Down Expand Up @@ -8679,26 +8682,32 @@ extern void G_CreateFighterNPC( Vehicle_t **pVeh, const char *strType );
extern playerState_t *cgSendPS[MAX_GENTITIES];
void CG_G2AnimEntModelLoad(centity_t *cent)
{
const char *cModelName = CG_ConfigString( CS_MODELS+cent->currentState.modelindex );

if (!cent->npcClient)
{ //have not init'd client yet
return;
}
const char *cModelName = CG_ConfigString( CS_MODELS+cent->currentState.modelindex );

if (cModelName && cModelName[0])
{
char modelName[MAX_QPATH];
int skinID;
char *slash;

strcpy(modelName, cModelName);
if (!cent->npcClient)
{ //have not init'd client yet
return;
}

if (cent->currentState.NPC_class == CLASS_VEHICLE && modelName[0] == '$')
{ //vehicles pass their veh names over as model names, then we get the model name from the veh type
//create a vehicle object clientside for this type
char *vehType = &modelName[1];
int iVehIndex = BG_VehicleGetIndex( vehType );
if (cModelName && cModelName[0])
{
char modelName[MAX_QPATH];
int skinID;
char *slash;

strcpy( modelName, cModelName );

if ( cent->currentState.NPC_class == CLASS_VEHICLE && modelName[0] == '$' )
{ //vehicles pass their veh names over as model names, then we get the model name from the veh type
//create a vehicle object clientside for this type
char *vehType = &modelName[1];
int iVehIndex = BG_VehicleGetIndex( vehType );

if ( iVehIndex == -1 ) { //Pre-empt a crash and just treat it as a swoop!
Q_strncpyz(modelName, "$swoop_mp", sizeof( modelName ));
vehType = &modelName[1];
iVehIndex = BG_VehicleGetIndex( vehType );
}

switch( g_vehicleInfo[iVehIndex].type )
{
Expand Down
3 changes: 2 additions & 1 deletion codemp/cgame/cg_servercmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,8 +1029,9 @@ static void CG_ConfigStringModified( void ) {
CG_ShaderStateChanged();
}
else if ( num == CS_LEGACY_FIXES ) {
// LEGACYFIX_SABERMOVEDATA may have changed
// LEGACYFIX_SABERMOVEDATA etc may have changed
BG_FixSaberMoveData();
BG_FixWeaponAttackAnim();
}
else if ( num >= CS_LIGHT_STYLES && num < CS_LIGHT_STYLES + (MAX_LIGHT_STYLES * 3))
{
Expand Down
10 changes: 4 additions & 6 deletions codemp/cgame/cg_weapons.c
Original file line number Diff line number Diff line change
Expand Up @@ -2399,12 +2399,10 @@ void CG_FireWeapon( centity_t *cent, qboolean altFire ) {
}
}

#ifdef BASE_COMPAT
// play quad sound if needed
if ( cent->currentState.powerups & ( 1 << PW_QUAD ) ) {
//trap->S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.media.quadSound );
}
#endif // BASE_COMPAT
// play quad sound if needed
if ( cent->currentState.powerups & ( 1 << PW_QUAD ) ) {
//trap->S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.media.quadSound );
}


// play a sound
Expand Down
4 changes: 2 additions & 2 deletions codemp/cgame/cg_xcvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ XCVAR_DEF( cg_chatBoxLines, "5", NULL, CVAR_ARCHIVE ) //this would be call
XCVAR_DEF( cg_chatBoxHeight, "350", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_chatBoxX, "30", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_chatBoxCutOffLength, "350", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_chatBoxEmojis, "0", NULL, CVAR_ARCHIVE_ND )
XCVAR_DEF( cg_chatBoxEmojis, "1", NULL, CVAR_ARCHIVE_ND )
XCVAR_DEF( cg_chatBoxShowCutoff, "0", NULL, CVAR_ARCHIVE_ND )
XCVAR_DEF( cg_hudColors, "0", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_tintHud, "1", NULL, CVAR_ARCHIVE )
Expand Down Expand Up @@ -273,7 +273,7 @@ XCVAR_DEF( cg_drawRewards, "1", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_drawSnapshot, "0", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_drawStatus, "1", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_drawTimer, "0", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_drawTimerMsec, "1", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_drawTimerMsec, "0", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_drawTimerCountdown, "0", NULL, CVAR_ARCHIVE )
XCVAR_DEF( cg_drawUpperRight, "1", NULL, CVAR_NONE )
XCVAR_DEF( cg_drawVehLeadIndicator, "1", NULL, CVAR_ARCHIVE )
Expand Down
2 changes: 1 addition & 1 deletion codemp/client/cl_uiapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ static qboolean CL_G2API_HaveWeGhoul2Models( void *ghoul2) {
static qboolean CL_G2API_GetBoltMatrix( void *ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, const vec3_t position, const int frameNum, qhandle_t *modelList, vec3_t scale ) {
if ( !ghoul2 ) {
return qfalse;

}
return re->G2API_GetBoltMatrix( *((CGhoul2Info_v *)ghoul2), modelIndex, boltIndex, matrix, angles, position, frameNum, modelList, scale );
}
Expand Down
2 changes: 1 addition & 1 deletion codemp/game/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ set(MPGameCommonFiles
"${MPDir}/qcommon/disablewarnings.h"
"${MPDir}/qcommon/q_shared.h"
"${MPDir}/qcommon/tags.h"

${SharedCommonFiles}
)
source_group("common" FILES ${MPGameCommonFiles})
Expand Down
8 changes: 2 additions & 6 deletions codemp/game/NPC_AI_GalakMech.c
Original file line number Diff line number Diff line change
Expand Up @@ -1181,9 +1181,7 @@ void NPC_BSGM_Attack( void )
//if ( NPC->client->ps.powerups[PW_GALAK_SHIELD] > 0 )
if (0)
{
#ifdef BASE_COMPAT
NPCS.NPC->client->ps.powerups[PW_BATTLESUIT] = level.time + ARMOR_EFFECT_TIME;
#endif
NPCS.NPC->client->ps.powerups[PW_BATTLESUIT] = level.time + ARMOR_EFFECT_TIME;
G_Damage( NPCS.NPC->enemy, NPCS.NPC, NPCS.NPC, NULL, NPCS.NPC->r.currentOrigin, 100, DAMAGE_NO_KNOCKBACK, MOD_UNKNOWN );
}
else
Expand All @@ -1208,9 +1206,7 @@ void NPC_BSGM_Attack( void )
//FIXME: debounce this?
NPCS.NPCInfo->touchedByPlayer = NULL;
//FIXME: some shield effect?
#ifdef BASE_COMPAT
NPCS.NPC->client->ps.powerups[PW_BATTLESUIT] = level.time + ARMOR_EFFECT_TIME;
#endif
NPCS.NPC->client->ps.powerups[PW_BATTLESUIT] = level.time + ARMOR_EFFECT_TIME;

VectorSubtract( NPCS.NPC->enemy->r.currentOrigin, NPCS.NPC->r.currentOrigin, smackDir );
smackDir[2] += 30;
Expand Down
2 changes: 1 addition & 1 deletion codemp/game/NPC_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -2556,7 +2556,7 @@ qboolean NPC_ParseParms( const char *NPCName, gentity_t *NPC )
}
//FIXME: need to precache the weapon, too? (in above func)
weap = GetIDForString( WPTable, value );
if ( weap >= WP_NONE && weap <= WP_NUM_WEAPONS )///*WP_BLASTER_PISTOL*/WP_SABER ) //?!
if ( weap >= WP_NONE && weap < WP_NUM_WEAPONS )///*WP_BLASTER_PISTOL*/WP_SABER ) //?!
{
NPC->client->ps.weapon = weap;
NPC->client->ps.stats[STAT_WEAPONS] |= ( 1 << NPC->client->ps.weapon );
Expand Down
40 changes: 32 additions & 8 deletions codemp/game/bg_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,14 +453,40 @@ int WeaponAttackAnim[WP_NUM_WEAPONS] =
BOTH_THERMAL_THROW,//WP_THERMAL,
BOTH_ATTACK3,//BOTH_ATTACK11,//WP_TRIP_MINE,
BOTH_ATTACK3,//BOTH_ATTACK12,//WP_DET_PACK,
BOTH_ATTACK3,//WP_CONCUSSION,
BOTH_ATTACK3,//WP_CONCUSSION,
BOTH_ATTACK2,//WP_BRYAR_OLD,

//NOT VALID (e.g. should never really be used):
BOTH_STAND1,//WP_EMPLACED_GUN,
BOTH_ATTACK1//WP_TURRET,
};

void BG_FixWeaponAttackAnim(void) {
#if defined(_GAME)
const qboolean doFix = !!g_fixWeaponAttackAnim.integer;
#elif defined(_CGAME)
const char *cs = CG_ConfigString(CS_LEGACY_FIXES);
const uint32_t legacyFixes = strtoul(cs, NULL, 0);
const qboolean doFix = !!(legacyFixes & (1 << LEGACYFIX_WEAPONATTACKANIM));
#elif defined(UI_BUILD)
const qboolean doFix = qtrue; // no chance of prediction error from UI code
#endif
int *move;

for (move = WeaponAttackAnim; move - WeaponAttackAnim < ARRAY_LEN(WeaponAttackAnim); move++) {
const weapon_t wpIndex = (weapon_t)(move - WeaponAttackAnim);
if (wpIndex == WP_CONCUSSION) {
*move = doFix ? BOTH_ATTACK3 : BOTH_ATTACK2;
} else if (wpIndex == WP_BRYAR_OLD) {
*move = doFix ? BOTH_ATTACK2 : BOTH_STAND1;
} else if (wpIndex == WP_EMPLACED_GUN) {
*move = doFix ? BOTH_STAND1 : BOTH_ATTACK1;
} else if (wpIndex == WP_TURRET) {
*move = doFix ? BOTH_ATTACK1 : BOTH_ATTACK2; // better than UB?
}
}
}

qboolean BG_FileExists( const char *fileName ) {
if ( fileName && fileName[0] ) {
fileHandle_t f = NULL_FILE;
Expand Down Expand Up @@ -799,7 +825,7 @@ qboolean BG_LegalizedForcePowers(char *powerOut, size_t powerOutSize, int maxRan

//[JAPRO - Serverside - Saber - Allow server to cap block level - End]
#ifdef _GAME
if (g_maxSaberDefense.integer && (final_Powers[FP_SABER_DEFENSE] > g_maxSaberDefense.integer))//my block is middle[2], forced max is 2,
if (g_maxSaberDefense.integer && (final_Powers[FP_SABER_DEFENSE] > g_maxSaberDefense.integer))//my block is middle[2], forced max is 2,
final_Powers[FP_SABER_DEFENSE] = g_maxSaberDefense.integer;
#endif
//[JAPRO - Serverside - Saber - Allow server to cap block level - End]
Expand Down Expand Up @@ -2021,7 +2047,7 @@ gitem_t *BG_FindItemForWeapon( weapon_t weapon ) {

#ifdef _GAME
//Debug this crash
Com_Printf("BG_FindItemForWeapon crash\n");
Com_Printf("BG_FindItemForWeapon crash\n");
Svcmd_GameMem_f();
if (it->classname)
Com_Printf("Last classname %s type %i, tag %i, end: %i\n", it->classname, it->giType, it->giTag, it);
Expand Down Expand Up @@ -2412,7 +2438,7 @@ qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const play
(item->giTag == PW_NEUTRALFLAG && ent->modelindex2) ||
(item->giTag == PW_NEUTRALFLAG && ps->powerups[PW_NEUTRALFLAG]))
return qtrue;
}
}
}
else if (gametype == GT_FFA || gametype == GT_TEAM)
{
Expand Down Expand Up @@ -2694,10 +2720,8 @@ const char *eventnames[EV_NUM_ENTITY_EVENTS] = {
"EV_DEATH3",
"EV_OBITUARY",

#ifdef BASE_COMPAT
"EV_POWERUP_QUAD",
"EV_POWERUP_BATTLESUIT",
#endif // BASE_COMPAT
"EV_POWERUP_QUAD",
"EV_POWERUP_BATTLESUIT",
//"EV_POWERUP_REGEN",

"EV_FORCE_DRAINED",
Expand Down

0 comments on commit cd784cb

Please sign in to comment.