diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cgame/cg_event.c | 7 | ||||
-rw-r--r-- | src/cgame/cg_players.c | 26 | ||||
-rw-r--r-- | src/game/bg_misc.c | 28 | ||||
-rw-r--r-- | src/game/bg_pmove.c | 27 | ||||
-rw-r--r-- | src/game/bg_public.h | 34 | ||||
-rw-r--r-- | src/game/g_active.c | 45 | ||||
-rw-r--r-- | src/game/g_client.c | 22 | ||||
-rw-r--r-- | src/game/g_combat.c | 2 | ||||
-rw-r--r-- | src/game/g_main.c | 9 |
9 files changed, 124 insertions, 76 deletions
diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c index 42ac22da..d5f30cb4 100644 --- a/src/cgame/cg_event.c +++ b/src/cgame/cg_event.c @@ -419,7 +419,7 @@ void CG_PainEvent( centity_t *cent, int health ) { CG_Menu ============== */ -void CG_Menu( centity_t *cent, int eventParm ) +void CG_Menu( int eventParm ) { switch( eventParm ) { @@ -448,7 +448,7 @@ void CG_Menu( centity_t *cent, int eventParm ) break; default: - Com_Printf( "cgame: debug: no such menu no %d\n", eventParm ); + Com_Printf( "cgame: debug: no such menu %d\n", eventParm ); } } @@ -981,7 +981,8 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) { case EV_MENU: DEBUGNAME("EV_MENU"); - CG_Menu( cent, es->eventParm ); + if( es->number == cg.clientNum ) + CG_Menu( es->eventParm ); break; default: diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c index 680f544a..f2b1aaff 100644 --- a/src/cgame/cg_players.c +++ b/src/cgame/cg_players.c @@ -494,9 +494,12 @@ static void CG_CopyClientInfoModel( clientInfo_t *from, clientInfo_t *to ) { CG_GetCorpseNum ====================== */ -static int CG_GetCorpseNum( clientInfo_t *ci ) { - int i; +static int CG_GetCorpseNum( int pclass ) { + int i; clientInfo_t *match; + char *modelName; + + modelName = BG_FindModelNameForClass( pclass ); for ( i = 0 ; i < cgs.maxclients ; i++ ) { match = &cgs.corpseinfo[ i ]; @@ -506,15 +509,14 @@ static int CG_GetCorpseNum( clientInfo_t *ci ) { if ( match->deferred ) { continue; } - if ( !Q_stricmp( ci->modelName, match->modelName ) - && !Q_stricmp( ci->skinName, match->skinName ) ) { + if ( !Q_stricmp( modelName, match->modelName ) + /*&& !Q_stricmp( modelName, match->skinName )*/ ) { // this clientinfo is identical, so use it's handles - return i; } } - //something has gone badly wrong + //something has gone horribly wrong return -1; } @@ -1947,17 +1949,13 @@ void CG_Corpse( centity_t *cent ) float shadowPlane; //if this is the first time the function has been run set cent->corpseNum - if( cent->corpseNum < 1 ) + cent->corpseNum = CG_GetCorpseNum( cent->currentState.clientNum ); + if ( cent->corpseNum < 0 || cent->corpseNum >= MAX_CLIENTS ) { - ci = &cgs.clientinfo[ cent->currentState.clientNum ]; - cent->corpseNum = CG_GetCorpseNum( ci ) + 1; - if ( cent->corpseNum < 1 || cent->corpseNum >= MAX_CLIENTS + 1 ) - { - CG_Error( "Bad corpseNum on corpse entity: %d", cent->corpseNum ); - } + CG_Error( "Bad corpseNum on corpse entity: %d", cent->corpseNum ); } - ci = &cgs.corpseinfo[ cent->corpseNum - 1 ]; + ci = &cgs.corpseinfo[ cent->corpseNum ]; // it is possible to see corpses from disconnected players that may // not have valid clientinfo diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index b4ca57c8..25ade6fd 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -889,6 +889,34 @@ Only in CTF games int bg_numItems = sizeof(bg_itemlist) / sizeof(bg_itemlist[0]) - 1; +classModelName_t bg_pModelList[ ] = +{ + { PCL_D_O_BASE, "klesk" }, + { PCL_D_D_BASE, "orbb" }, + { PCL_D_B_BASE, "lucy" }, + { PCL_H_BASE, "sarge" }, +}; + +int bg_numPModels = sizeof( bg_pModelList ) / sizeof( bg_pModelList[ 0 ] ); + +/* +============== +BG_FindModelNameForClass +============== +*/ +char *BG_FindModelNameForClass( int pclass ) +{ + int i; + + for( i = 0; i < bg_numPModels; i++ ) + { + if( bg_pModelList[ i ].classNum == pclass ) + return bg_pModelList[ i ].className; + } + + //wimp out + return bg_pModelList[ 0 ].className; +} /* ============== diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index 4c8fe6dc..767395f8 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -398,7 +398,7 @@ static float PM_CmdScale( usercmd_t *cmd ) { int max; float total; float scale; - float modifier = 1.0; + float modifier = 1.0f; static int time; int dTime; int aForward, aRight; @@ -406,32 +406,13 @@ static float PM_CmdScale( usercmd_t *cmd ) { dTime = pm->cmd.serverTime - time; time = pm->cmd.serverTime; - if( pm->ps->stats[ STAT_PTEAM ] == PTE_HUMANS ) + if( pm->ps->stats[ STAT_PTEAM ] == PTE_HUMANS && pm->ps->pm_type == PM_NORMAL ) { if( !( pm->ps->stats[ STAT_STATE ] & SS_SPEEDBOOST ) ) { //if not sprinting modifier *= 0.8; } - else if( cmd->upmove >= 0 ) - { - //subtract stamina - pm->ps->stats[ STAT_STAMINA ] -= (dTime/8); - } - - aForward = abs( cmd->forwardmove ); - aRight = abs( cmd->rightmove ); - - if( ( aForward <= 64 && aForward > 5 ) || ( aRight <= 64 && aRight > 5 ) ) - { - //restore stamina - pm->ps->stats[ STAT_STAMINA ] += (dTime/10); - } - else if( aForward <= 5 && aRight <= 5 ) - { - //restore stamina faster - pm->ps->stats[ STAT_STAMINA ] += (dTime/8); - } if( cmd->forwardmove < 0 ) { @@ -450,10 +431,6 @@ static float PM_CmdScale( usercmd_t *cmd ) { if( pm->ps->stats[ STAT_STAMINA ] < -1000 ) pm->ps->stats[ STAT_STAMINA ] = -1000; - //if not trying to run then not trying to sprint - if( abs( cmd->forwardmove ) <= 64 ) - pm->ps->stats[ STAT_STATE ] &= ~SS_SPEEDBOOST; - //must have +ve stamina to jump if( pm->ps->stats[ STAT_STAMINA ] < 0 ) cmd->upmove = 0; diff --git a/src/game/bg_public.h b/src/game/bg_public.h index e096b33d..feee73b8 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -603,16 +603,25 @@ typedef enum { //FIXME: switch to enums at some point //TA: player classes -#define PCL_D_B_BASE 1 -#define PCL_D_O_BASE 2 -#define PCL_D_D_BASE 3 +typedef enum { + PCL_NONE, + PCL_D_B_BASE, + PCL_D_O_BASE, + PCL_D_D_BASE, + PCL_H_BASE, + + PCL_NUM_CLASSES +} pClass_t; -#define PCL_H_BASE 11 //TA: player teams -#define PTE_NONE 0 -#define PTE_DROIDS 1 -#define PTE_HUMANS 2 +typedef enum { + PTE_NONE, + PTE_DROIDS, + PTE_HUMANS, + + PTE_NUM_TEAMS +} pTeam_t; // means of death @@ -685,6 +694,14 @@ typedef struct gitem_s { char *sounds; // string of all sounds this item will use } gitem_t; +//TA: player model precaching +typedef struct +{ + int classNum; + char *className; +} classModelName_t; + + // included in both the game dll and the client extern gitem_t bg_itemlist[]; extern int bg_numItems; @@ -695,6 +712,9 @@ gitem_t *BG_FindItemForBuildable( buildable_t buildable ); gitem_t *BG_FindItemForUpgrade( upgrade_t upgrade ); gitem_t *BG_FindItemForPowerup( powerup_t pw ); gitem_t *BG_FindItemForHoldable( holdable_t pw ); + +//TA: +char *BG_FindModelNameForClass( int pclass ); #define ITEM_INDEX(x) ((x)-bg_itemlist) qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const playerState_t *ps ); diff --git a/src/game/g_active.c b/src/game/g_active.c index c9e024c8..3e2d704c 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -374,10 +374,10 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) { // attack button cycles through spectators //TA: messes with the menus - if ( ( client->buttons & BUTTON_ATTACK ) && + /*if ( ( client->buttons & BUTTON_ATTACK ) && !( client->oldbuttons & BUTTON_ATTACK ) && ( client->sess.spectatorState == SPECTATOR_FREE ) ) - Cmd_FollowCycle_f( ent, 1 ); + Cmd_FollowCycle_f( ent, 1 );*/ } @@ -641,6 +641,7 @@ void ClientThink_real( gentity_t *ent ) { int msec; usercmd_t *ucmd; float speed; + int aForward, aRight; //TA: torch gentity_t *light; @@ -770,8 +771,13 @@ void ClientThink_real( gentity_t *ent ) { } //TA: torch stuff - if( client->torch == NULL && BG_activated( UP_TORCH, client->ps.stats ) ) + if( client->torch == NULL && + BG_activated( UP_TORCH, client->ps.stats ) && + BG_gotItem( UP_TORCH, client->ps.stats ) && + !( client->ps.pm_type == PM_DEAD ) + ) { + Com_Printf( "spawn torch\n" ); light = G_Spawn( ); light->s.eType = ET_TORCH; light->r.ownerNum = ent->s.number; @@ -779,9 +785,14 @@ void ClientThink_real( gentity_t *ent ) { client->torch = light; } - if( ( client->torch != NULL && !BG_activated( UP_TORCH, client->ps.stats ) ) || - ( client->torch != NULL && BG_activated( UP_TORCH, client->ps.stats ) && pm.ps->pm_type == PM_DEAD ) ) + if( client->torch != NULL && + ( !BG_activated( UP_TORCH, client->ps.stats ) || + client->ps.pm_type == PM_DEAD || + !BG_gotItem( UP_TORCH, client->ps.stats ) + ) + ) { + Com_Printf( "destroy torch\n" ); G_FreeEntity( client->torch ); trap_LinkEntity( client->torch ); client->torch = NULL; @@ -791,6 +802,30 @@ void ClientThink_real( gentity_t *ent ) { if( client->torch != NULL ) ShineTorch( client->torch ); + aForward = abs( ucmd->forwardmove ); + aRight = abs( ucmd->rightmove ); + + //if not trying to run then not trying to sprint + if( aForward <= 64 ) + client->ps.stats[ STAT_STATE ] &= ~SS_SPEEDBOOST; + + if( ( client->ps.stats[ STAT_STATE ] & SS_SPEEDBOOST ) && ucmd->upmove >= 0 ) + { + //subtract stamina + client->ps.stats[ STAT_STAMINA ] -= 2; + } + + if( ( aForward <= 64 && aForward > 5 ) || ( aRight <= 64 && aRight > 5 ) ) + { + //restore stamina + client->ps.stats[ STAT_STAMINA ] += 3; + } + else if( aForward <= 5 && aRight <= 5 ) + { + //restore stamina faster + client->ps.stats[ STAT_STAMINA ] += 2; + } + // set up for pmove oldEventSequence = client->ps.eventSequence; diff --git a/src/game/g_client.c b/src/game/g_client.c index 90fabc38..87d5fc8d 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -582,6 +582,7 @@ void CopyToBodyQue( gentity_t *ent ) { body->s.event = 0; body->r.contents = CONTENTS_BODY; body->clipmask = MASK_PLAYERSOLID; + body->s.clientNum = ent->client->ps.stats[ STAT_PCLASS ]; switch ( body->s.legsAnim & ~ANIM_TOGGLEBIT ) { case BOTH_DEATH1: @@ -928,23 +929,10 @@ void ClientUserinfoChanged( int clientNum ) { // set model //Q_strncpyz( model, Info_ValueForKey (userinfo, "model"), sizeof( model ) ); - switch( client->pers.pclass ) - { - case PCL_D_O_BASE: - Q_strncpyz( model, "klesk", sizeof( model ) ); - break; - case PCL_D_D_BASE: - Q_strncpyz( model, "orbb", sizeof( model ) ); - break; - case PCL_D_B_BASE: - Q_strncpyz( model, "lucy", sizeof( model ) ); - break; - case PCL_H_BASE: - Q_strncpyz( model, "sarge", sizeof( model ) ); - break; - default: - Q_strncpyz( model, "grunt", sizeof( model ) ); - } + s = BG_FindModelNameForClass( client->pers.pclass ); + + //if( client->pers.pclass > PCL_NONE && client->pers.pclass < PCL_NUM_CLASSES ) + Q_strncpyz( model, s, sizeof( model ) ); // team switch( client->sess.sessionTeam ) { diff --git a/src/game/g_combat.c b/src/game/g_combat.c index 5394314f..fbefaf26 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -454,7 +454,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int } // Add team bonuses - Team_FragBonuses(self, inflictor, attacker); + //Team_FragBonuses(self, inflictor, attacker); // if client is in a nodrop area, don't drop anything (but return CTF flags!) contents = trap_PointContents( self->r.currentOrigin, -1 ); diff --git a/src/game/g_main.c b/src/game/g_main.c index d5b6479f..cf82e34d 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -298,13 +298,14 @@ G_RegisterPlayerModels */ void G_RegisterPlayerModels( void ) { - char *precacheModels[ MAX_CLIENTS ] = { "klesk", "orbb", "lucy", "sarge", NULL }; - char *s; + char *s, *class; int i; - for( i = 0; i < 4; i++ ) + for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ ) { - s = va("n\\%s%d\\t\\%i\\model\\%s\\hmodel\\%s\\g_redteam\\%s\\g_blueteam\\%s\\c1\\%s\\hc\\%i\\w\\%i\\l\\%i\\tt\\%d\\tl\\%d", "precache", i, 0, precacheModels[ i ], precacheModels[ i ], 0, 0, "7", 100, 0, 0, 0, 0); + class = BG_FindModelNameForClass( i ); + Com_Printf( ":%s: ", class ); + s = va("n\\%s%d\\t\\%i\\model\\%s\\hmodel\\%s\\g_redteam\\%s\\g_blueteam\\%s\\c1\\%s\\hc\\%i\\w\\%i\\l\\%i\\tt\\%d\\tl\\%d", "precache", i, 0, class, class, 0, 0, "7", 100, 0, 0, 0, 0); trap_SetConfigstring( CS_PLAYERS + MAX_CLIENTS + i, s ); } |