Skip to content

Commit

Permalink
Disable eject brass delay, it crashes the game
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfetplayer committed Jul 2, 2024
1 parent 68b9dbd commit 49ebd29
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
12 changes: 7 additions & 5 deletions code/cgame/cg_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,14 +497,14 @@ typedef struct localEntity_s {

} localEntity_t;

typedef struct delayedBrass_s {
/*typedef struct delayedBrass_s {
struct centity_s *centity;
int time;
void ( *ejectBrassFunc )( centity_t * );
struct delayedBrass_s *prev;
struct delayedBrass_s *next;
} delayedBrass_t;
} delayedBrass_t;*/

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

Expand Down Expand Up @@ -714,7 +714,9 @@ typedef struct weaponInfo_s {
vec3_t missileDlightColor;
int missileRenderfx;

void ( *ejectBrassFunc )( centity_t *, int delay );
//void ( *ejectBrassFunc )( centity_t *, int delay );

void ( *ejectBrassFunc )( centity_t * );

float trailRadius;
float wiTrailTime;
Expand Down Expand Up @@ -2251,8 +2253,8 @@ void CG_FlameDamage( int owner, vec3_t org, float radius );
void CG_InitLocalEntities( void );
localEntity_t *CG_AllocLocalEntity( void );
void CG_AddLocalEntities( void );
void CG_FreeDelayedBrass( delayedBrass_t * );
void CG_AllocDelayedBrass( centity_t *, int, void ( *ejectBrassFunc )( centity_t * ) );
//void CG_FreeDelayedBrass( delayedBrass_t * );
//void CG_AllocDelayedBrass( centity_t *, int, void ( *ejectBrassFunc )( centity_t * ) );

//
// cg_effects.c
Expand Down
14 changes: 8 additions & 6 deletions code/cgame/cg_localents.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ localEntity_t cg_localEntities[MAX_LOCAL_ENTITIES];
localEntity_t cg_activeLocalEntities; // double linked list
localEntity_t *cg_freeLocalEntities; // single linked list

delayedBrass_t *cg_delayedBrasses = NULL;
//delayedBrass_t *cg_delayedBrasses = NULL;

// Ridah, debugging
int localEntCount = 0;
Expand Down Expand Up @@ -134,6 +134,7 @@ localEntity_t *CG_AllocLocalEntity( void ) {
CG_FreeDelayedBrass
==================
*/
/*
void CG_FreeDelayedBrass( delayedBrass_t * delayedBrass ) {
if ( !delayedBrass ) {
CG_Error( "CG_FreeDelayedBrass: delayedBrass is NULL" );
Expand All @@ -154,12 +155,13 @@ void CG_FreeDelayedBrass( delayedBrass_t * delayedBrass ) {
free( delayedBrass );
}

*/
/*
===================
CG_AllocDelayedBrass
===================
*/
/*
void CG_AllocDelayedBrass( centity_t * cent, int time, void ( *ejectBrassFunc )( centity_t * ) ) {
delayedBrass_t *delayedBrasses = ( delayedBrass_t* )malloc( sizeof( delayedBrass_t ) );
Expand All @@ -176,7 +178,7 @@ void CG_AllocDelayedBrass( centity_t * cent, int time, void ( *ejectBrassFunc )(
cg_delayedBrasses = delayedBrasses;
}
}

*/
/*
====================================================================================
Expand Down Expand Up @@ -1718,19 +1720,19 @@ CG_AddLocalEntities
*/
void CG_AddLocalEntities( void ) {
localEntity_t *le, *next;
delayedBrass_t *dlBrass;
//delayedBrass_t *dlBrass;

cg.viewFade = 0.0;

dlBrass = cg_delayedBrasses;
/*dlBrass = cg_delayedBrasses;
for ( ; dlBrass != NULL ; dlBrass = dlBrass->next ) {
if ( cg.time < dlBrass->time ) {
continue;
}
dlBrass->ejectBrassFunc(dlBrass->centity);
CG_FreeDelayedBrass( dlBrass );
}
}*/

// walk the list backwards, so any new local entities generated
// (trails, marks, etc) will be present this frame
Expand Down
38 changes: 21 additions & 17 deletions code/cgame/cg_weapons.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ static void CG_MachineGunEjectBrass( centity_t *cent ) {
le->leMarkType = LEMT_NONE;
}

static void CG_MachineGunEjectBrassDelay( centity_t *cent, int delay ) {
/*static void CG_MachineGunEjectBrassDelay( centity_t *cent, int delay ) {
CG_AllocDelayedBrass( cent, cg.time + delay, CG_MachineGunEjectBrass );
}
}*/

/*
==============
Expand Down Expand Up @@ -456,9 +456,9 @@ static void CG_ShotgunEjectBrass( centity_t *cent ) {
le->leMarkType = LEMT_NONE;
}

static void CG_ShotgunEjectBrassDelay( centity_t *cent, int delay ) {
/*static void CG_ShotgunEjectBrassDelay( centity_t *cent, int delay ) {
CG_AllocDelayedBrass( cent, cg.time + delay, CG_ShotgunEjectBrass );
}
}*/

/*
==============
Expand Down Expand Up @@ -645,9 +645,9 @@ static void CG_PistolEjectBrass( centity_t *cent ) {
le->leMarkType = LEMT_NONE;
}

static void CG_PistolEjectBrassDelay( centity_t *cent, int delay ) {
/*static void CG_PistolEjectBrassDelay( centity_t *cent, int delay ) {
CG_AllocDelayedBrass( cent, cg.time + delay, CG_PistolEjectBrass );
}
}*/

//----(SA) added
/*
Expand Down Expand Up @@ -741,9 +741,9 @@ static void CG_PanzerFaustEjectBrass( centity_t *cent ) {
le->leMarkType = LEMT_NONE;
}

static void CG_PanzerFaustEjectBrassDelay( centity_t *cent, int delay ) {
/*static void CG_PanzerFaustEjectBrassDelay( centity_t *cent, int delay ) {
CG_AllocDelayedBrass( cent, cg.time + delay, CG_PanzerFaustEjectBrass );
}
}*/

/*
==============
Expand Down Expand Up @@ -1707,13 +1707,13 @@ static qboolean CG_RW_ParseClient( int handle, weaponInfo_t *weaponInfo, int wea
return CG_RW_ParseError( handle, "expected ejectBrassFunc" );
} else {
if ( !Q_stricmp( filename, "MachineGunEjectBrass" ) ) {
weaponInfo->ejectBrassFunc = CG_MachineGunEjectBrassDelay;
weaponInfo->ejectBrassFunc = CG_MachineGunEjectBrass;
} else if ( !Q_stricmp( filename, "PanzerFaustEjectBrass" ) ) {
weaponInfo->ejectBrassFunc = CG_PanzerFaustEjectBrassDelay;
weaponInfo->ejectBrassFunc = CG_PanzerFaustEjectBrass;
} else if ( !Q_stricmp( filename, "PistolEjectBrass" ) ) {
weaponInfo->ejectBrassFunc = CG_PistolEjectBrassDelay;
weaponInfo->ejectBrassFunc = CG_PistolEjectBrass;
} else if ( !Q_stricmp( filename, "ShotgunEjectBrass" ) ) {
weaponInfo->ejectBrassFunc = CG_ShotgunEjectBrassDelay;
weaponInfo->ejectBrassFunc = CG_ShotgunEjectBrass;
}
}
} else if ( !Q_stricmp( token.string, "modModel" ) ) {
Expand Down Expand Up @@ -3162,7 +3162,7 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
CG_AddWeaponWithPowerups( &gun, cent->currentState.powerups, ps, cent );
}

if ( isPlayer && ps != NULL ) {
if ( isPlayer ) {
refEntity_t brass;

// opposite tag in akimbo, since at this point the weapon
Expand Down Expand Up @@ -5520,19 +5520,23 @@ void CG_FireWeapon( centity_t *cent, int event ) {
}
}

if (cent->currentState.aiChar) {
return;
if ( weap->ejectBrassFunc && cg_brassTime.integer > 0 ) {
weap->ejectBrassFunc( cent );
}

//if (cent->currentState.aiChar) {
//return;
// }


// do brass ejection with special delays for some weapons
if ( weap->ejectBrassFunc && cg_brassTime.integer > 0 ) {
/*if ( weap->ejectBrassFunc && cg_brassTime.integer > 0 ) {
if (cg.predictedPlayerState.ammoclip[cent->currentState.weapon] == 0) {
weap->ejectBrassFunc( cent, ammoTable[cent->currentState.weapon].brassDelayEmpty );
} else {
weap->ejectBrassFunc( cent, ammoTable[cent->currentState.weapon].brassDelay );
}
}
}*/
}


Expand Down

0 comments on commit 49ebd29

Please sign in to comment.