diff options
author | Paweł Redman <trem.redman@gmail.com> | 2013-09-09 23:24:54 +0200 |
---|---|---|
committer | Paweł Redman <trem.redman@gmail.com> | 2013-09-09 23:24:54 +0200 |
commit | 37b8af1e6eb90378f1290b5130c8b6882b06a219 (patch) | |
tree | 1f8c00819cf59b7147e657dcb90d9ccc2e0d7989 /src/game | |
parent | 27a16fb1fa69d458fb10e6437eb07b85496b46b8 (diff) |
0.1.3
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/g_admin.c | 1 | ||||
-rw-r--r-- | src/game/g_buildable.c | 33 | ||||
-rw-r--r-- | src/game/g_cmds.c | 23 | ||||
-rw-r--r-- | src/game/g_combat.c | 22 | ||||
-rw-r--r-- | src/game/g_local.h | 8 | ||||
-rw-r--r-- | src/game/g_main.c | 37 | ||||
-rw-r--r-- | src/game/g_team.c | 2 |
7 files changed, 99 insertions, 27 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c index e753f19..35d57ed 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -2528,6 +2528,7 @@ qboolean G_admin_endvote( gentity_t *ent ) admin_log( BG_TeamName( team ) ); level.voteNo[ team ] = cancel ? level.numVotingClients[ team ] : 0; level.voteYes[ team ] = cancel ? 0 : level.numVotingClients[ team ]; + level.voteAborted[ team ] = qtrue; G_CheckVote( team ); if( team == TEAM_NONE ) AP( msg ); diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index beb7e37..b13c54a 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -4548,3 +4548,36 @@ void G_BuildLogRevert( int id ) } } +/* +============ +G_RemoveUnbuiltBuildables + +Kill all player's buildables if they havent spawned yet +============ +*/ +void G_RemoveUnbuiltBuildables( gentity_t *self ) +{ + int i; + vec3_t dir; + gentity_t *ent; + + dir[0] = dir[1] = 0.0f; + dir[2] = 1.0f; + + for( i = MAX_CLIENTS, ent = g_entities + i; i < level.num_entities; i++, ent++ ) + { + if( ent->s.eType != ET_BUILDABLE ) + continue; + + if( ent == self ) + continue; + + if( ent->spawned ) + continue; + + if( ent->builtBy != self->client->ps.clientNum ) + continue; + + G_Damage( ent, self, NULL, dir, dir, ent->health, 0, MOD_DECONSTRUCT ); + } +} diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index aebb975..c9c6213 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1363,12 +1363,28 @@ void Cmd_CallVote_f( gentity_t *ent ) } else if( !Q_stricmp( vote, "map_restart" ) ) { + if( level.time / 60000 >= g_restartVoteTimelimit.integer ) + { + trap_SendServerCommand( ent-g_entities, + va( "print \"%s: It's not allowed to call a restart vote after %i minute%s.\n\"", + cmd, g_restartVoteTimelimit.integer, ( g_restartVoteTimelimit.integer == 1 ? "" : "s" ) ) ); + return; + } strcpy( level.voteString[ team ], vote ); strcpy( level.voteDisplayString[ team ], "Restart current map" ); + level.voteThreshold[ team ] = g_restartVotePercent.integer; // map_restart comes with a default delay } else if( !Q_stricmp( vote, "map" ) ) { + if( level.time / 60000 >= g_mapVoteTimelimit.integer ) + { + trap_SendServerCommand( ent-g_entities, + va( "print \"%s: It's not allowed to call a map vote after %i minute%s. Call a ^1nextmap^7 vote instead\n\"", + cmd, g_mapVoteTimelimit.integer, ( g_mapVoteTimelimit.integer == 1 ? "" : "s" ) ) ); + return; + } + if( !G_MapExists( arg ) ) { trap_SendServerCommand( ent-g_entities, @@ -1383,6 +1399,7 @@ void Cmd_CallVote_f( gentity_t *ent ) sizeof( level.voteDisplayString[ team ] ), "Change to map '%s'", arg ); level.voteDelay[ team ] = 3000; + level.voteThreshold[ team ] = g_mapVotePercent.integer; } else if( !Q_stricmp( vote, "nextmap" ) ) { @@ -1406,13 +1423,14 @@ void Cmd_CallVote_f( gentity_t *ent ) "set g_nextMap \"%s\"", arg ); Com_sprintf( level.voteDisplayString[ team ], sizeof( level.voteDisplayString[ team ] ), - "Set the next map to '%s'", arg ); + "Set the ^1next^7 map to '%s'", arg ); } else if( !Q_stricmp( vote, "draw" ) ) { strcpy( level.voteString[ team ], "evacuation" ); strcpy( level.voteDisplayString[ team ], "End match in a draw" ); level.voteDelay[ team ] = 3000; + level.voteThreshold[ team ] = g_drawVotePercent.integer; } else if( !Q_stricmp( vote, "sudden_death" ) ) { @@ -1552,6 +1570,9 @@ void Cmd_CallVote_f( gentity_t *ent ) ent->client->pers.namelog->voteCount++; ent->client->pers.vote |= 1 << team; G_Vote( ent, team, qtrue ); + + level.voteAborted[ team ] = qfalse; + trap_SendServerCommand( -1, "voteevent votenow" ); } /* diff --git a/src/game/g_combat.c b/src/game/g_combat.c index b5963ab..a9e8e68 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -281,27 +281,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int for( i = UP_NONE + 1; i < UP_NUM_UPGRADES; i++ ) BG_DeactivateUpgrade( i, self->client->ps.stats ); - // kill all player's buildables if they havent spawned yet - // this should eliminate build timer hacks for ever - dir[0] = dir[1] = 0.0f; - dir[2] = 1.0f; - - for( i = MAX_CLIENTS, ent = g_entities + i; i < level.num_entities; i++, ent++ ) - { - if( ent->s.eType != ET_BUILDABLE ) - continue; - - if( ent == self ) - continue; - - if( ent->spawned ) - continue; - - if( ent->builtBy != self->client->ps.clientNum ) - continue; - - G_Damage( ent, self, attacker, dir, dir, ent->health, 0, MOD_DECONSTRUCT ); - } + G_RemoveUnbuiltBuildables( self ); // broadcast the death event to everyone ent = G_TempEntity( self->r.currentOrigin, EV_OBITUARY ); diff --git a/src/game/g_local.h b/src/game/g_local.h index a8c78b0..f836875 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -597,6 +597,7 @@ typedef struct int voteYes[ NUM_TEAMS ]; int voteNo[ NUM_TEAMS ]; int numVotingClients[ NUM_TEAMS ];// set by CalculateRanks + qboolean voteAborted[ NUM_TEAMS ]; // true if ended by an admin // spawn variables qboolean spawning; // the G_Spawn*() functions are valid @@ -833,6 +834,7 @@ void G_BuildLogAuto( gentity_t *actor, gentity_t *buildable, buildF void G_BuildLogRevert( int id ); const char *G_CuboidName(buildable_t buildable, const vec3_t cuboidSize, qboolean verbose); void G_LayoutBuildItem( buildable_t buildable, vec3_t origin, vec3_t angles, vec3_t origin2, vec3_t angles2 ); +void G_RemoveUnbuiltBuildables( gentity_t *self ); // // g_utils.c @@ -1143,6 +1145,11 @@ extern vmCvar_t g_allowVote; extern vmCvar_t g_voteLimit; extern vmCvar_t g_suddenDeathVotePercent; extern vmCvar_t g_suddenDeathVoteDelay; +extern vmCvar_t g_mapVotePercent; +extern vmCvar_t g_mapVoteTimelimit; +extern vmCvar_t g_restartVotePercent; +extern vmCvar_t g_restartVoteTimelimit; +extern vmCvar_t g_drawVotePercent; extern vmCvar_t g_teamForceBalance; extern vmCvar_t g_smoothClients; extern vmCvar_t pmove_fixed; @@ -1217,6 +1224,7 @@ extern vmCvar_t g_cuboidSizeLimit; extern vmCvar_t g_buildableDensityLimit; extern vmCvar_t g_buildableDensityLimitRange; + void trap_Print( const char *fmt ); void trap_Error( const char *fmt ); int trap_Milliseconds( void ); diff --git a/src/game/g_main.c b/src/game/g_main.c index 4bc03b5..7775fc8 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -72,6 +72,11 @@ vmCvar_t g_allowVote; vmCvar_t g_voteLimit; vmCvar_t g_suddenDeathVotePercent; vmCvar_t g_suddenDeathVoteDelay; +vmCvar_t g_mapVotePercent; +vmCvar_t g_mapVoteTimelimit; +vmCvar_t g_restartVotePercent; +vmCvar_t g_restartVoteTimelimit; +vmCvar_t g_drawVotePercent; vmCvar_t g_teamForceBalance; vmCvar_t g_smoothClients; vmCvar_t pmove_fixed; @@ -210,6 +215,12 @@ static cvarTable_t gameCvarTable[ ] = { &g_voteLimit, "g_voteLimit", "5", CVAR_ARCHIVE, 0, qfalse }, { &g_suddenDeathVotePercent, "g_suddenDeathVotePercent", "74", CVAR_ARCHIVE, 0, qfalse }, { &g_suddenDeathVoteDelay, "g_suddenDeathVoteDelay", "180", CVAR_ARCHIVE, 0, qfalse }, + { &g_mapVotePercent, "g_mapVotePercent", "67", CVAR_ARCHIVE, 0, qfalse }, + { &g_mapVoteTimelimit, "g_mapVoteTimelimit", "5", CVAR_ARCHIVE, 0, qfalse }, + { &g_restartVotePercent, "g_restartVotePercent", "67", CVAR_ARCHIVE, 0, qfalse }, + { &g_restartVoteTimelimit, "g_restartVoteTimelimit", "10", CVAR_ARCHIVE, 0, qfalse }, + { &g_drawVotePercent, "g_drawVotePercent", "67", CVAR_ARCHIVE, 0, qfalse }, + { &g_minNameChangePeriod, "g_minNameChangePeriod", "5", 0, 0, qfalse}, { &g_maxNameChanges, "g_maxNameChanges", "5", 0, 0, qfalse}, @@ -2215,6 +2226,7 @@ G_CheckVote void G_CheckVote( team_t team ) { float votePassThreshold = (float)level.voteThreshold[ team ] / 100.0f; + float threshold; qboolean pass = qfalse; char *msg; int i; @@ -2247,18 +2259,33 @@ void G_CheckVote( team_t team ) return; } } + + threshold = (float)level.voteYes[ team ] / ( (float)level.voteNo[ team ] + level.voteYes[ team ] ); if( pass ) + { + if( !level.voteAborted[ team ] ) + trap_SendServerCommand( -1, "voteevent votepassed" ); level.voteExecuteTime[ team ] = level.time + level.voteDelay[ team ]; + } + else + { + if( !level.voteAborted[ team ] ) + trap_SendServerCommand( -1, "voteevent votefailed" ); + else + trap_SendServerCommand( -1, "voteevent votecancelled" ); + } - G_LogPrintf( "EndVote: %s %s %d %d %d\n", + G_LogPrintf( "EndVote: %s %s %d %d %d %f %f\n", team == TEAM_NONE ? "global" : BG_TeamName( team ), pass ? "pass" : "fail", - level.voteYes[ team ], level.voteNo[ team ], level.numVotingClients[ team ] ); + level.voteYes[ team ], level.voteNo[ team ], level.numVotingClients[ team ], + threshold, votePassThreshold ); - msg = va( "print \"%sote %sed (%d - %d)\n\"", - team == TEAM_NONE ? "V" : "Team v", pass ? "pass" : "fail", - level.voteYes[ team ], level.voteNo[ team ] ); + msg = va( "print \"%sote %sed^7: %d - %d (%.0f%%/%.0f%%)\n\"", + team == TEAM_NONE ? "V" : "Team v", pass ? "^2pass" : "^1fail", + level.voteYes[ team ], level.voteNo[ team ], threshold * 100, + votePassThreshold * 100 ); if( team == TEAM_NONE ) trap_SendServerCommand( -1, msg ); diff --git a/src/game/g_team.c b/src/game/g_team.c index fd15aa7..f46436d 100644 --- a/src/game/g_team.c +++ b/src/game/g_team.c @@ -209,6 +209,8 @@ void G_LeaveTeam( gentity_t *self ) // cut all relevant zap beams G_ClearPlayerZapEffects( self ); + G_RemoveUnbuiltBuildables( self ); + G_namelog_update_score( self->client ); } |