summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorM. Kristall <mkpdev@gmail.com>2011-09-25 20:36:06 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:18:14 +0000
commit3826b4c224aa491c52802d826cdee9cafd5408f0 (patch)
tree0d1f8510b5de810ab4ac1a8bd3295eb24c88903a /src
parent37a60fa83a2e5a17ee1b3be56f98479a06b810eb (diff)
* (bug 4984) Show who built a destroyed structure in buildlog
* A non-builder was sometimes credited when a structure self-destructed
Diffstat (limited to 'src')
-rw-r--r--src/game/g_admin.c51
-rw-r--r--src/game/g_buildable.c17
-rw-r--r--src/game/g_local.h3
3 files changed, 42 insertions, 29 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index 55572943..eef4f1ad 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -2972,6 +2972,8 @@ qboolean G_admin_builder( gentity_t *ent )
gentity_t *traceEnt;
buildLog_t *log;
int i;
+ qboolean buildlog;
+ char logid[ 20 ] = {""};
if( !ent )
{
@@ -2979,6 +2981,8 @@ qboolean G_admin_builder( gentity_t *ent )
return qfalse;
}
+ buildlog = G_admin_permission( ent, "buildlog" );
+
AngleVectors( ent->client->ps.viewangles, forward, right, up );
if( ent->client->pers.teamSelection != TEAM_NONE &&
ent->client->sess.spectatorState == SPECTATOR_NOT )
@@ -2991,7 +2995,7 @@ qboolean G_admin_builder( gentity_t *ent )
traceEnt = &g_entities[ tr.entityNum ];
if( tr.fraction < 1.0f && ( traceEnt->s.eType == ET_BUILDABLE ) )
{
- if( !G_admin_permission( ent, "buildlog" ) &&
+ if( !buildlog &&
ent->client->pers.teamSelection != TEAM_NONE &&
ent->client->pers.teamSelection != traceEnt->buildableTeam )
{
@@ -2999,32 +3003,28 @@ qboolean G_admin_builder( gentity_t *ent )
return qfalse;
}
- for( i = 0 ; i < level.numBuildLogs; i++ )
+ if( buildlog )
{
- log = &level.buildLog[ ( level.buildId - i - 1 ) % MAX_BUILDLOG ];
- if( log->fate != BF_CONSTRUCT || traceEnt->s.modelindex != log->modelindex )
- continue;
-
- VectorSubtract( traceEnt->s.pos.trBase, log->origin, dist );
- if( VectorLengthSquared( dist ) < 2.0f )
+ for( i = 0 ; buildlog && i < level.numBuildLogs; i++ )
{
- char logid[ 20 ] = {""};
+ log = &level.buildLog[ ( level.buildId - i - 1 ) % MAX_BUILDLOG ];
+ if( log->fate != BF_CONSTRUCT || traceEnt->s.modelindex != log->modelindex )
+ continue;
- if( G_admin_permission( ent, "buildlog" ) )
+ VectorSubtract( traceEnt->s.pos.trBase, log->origin, dist );
+ if( VectorLengthSquared( dist ) < 2.0f )
Com_sprintf( logid, sizeof( logid ), ", buildlog #%d",
MAX_CLIENTS + level.buildId - i - 1 );
- ADMP( va( "^3builder: ^7%s built by %s^7%s\n",
- BG_Buildable( log->modelindex )->humanName,
- log->actor ?
- log->actor->name[ log->actor->nameOffset ] :
- "<world>",
- logid ) );
- break;
}
}
- if( i == level.numBuildLogs )
- ADMP( va( "^3builder: ^7%s not in build log, possibly a layout item\n",
- BG_Buildable( traceEnt->s.modelindex )->humanName ) );
+
+ ADMP( va( "^3builder: ^7%s%s%s^7%s\n",
+ BG_Buildable( traceEnt->s.modelindex )->humanName,
+ traceEnt->builtBy ? " built by " : "",
+ traceEnt->builtBy ?
+ traceEnt->builtBy->name[ traceEnt->builtBy->nameOffset ] :
+ "",
+ buildlog ? ( logid[ 0 ] ? logid : ", not in buildlog" ) : "" ) );
}
else
ADMP( "^3builder: ^7no structure found under crosshair\n" );
@@ -3160,13 +3160,22 @@ qboolean G_admin_buildlog( gentity_t *ent )
printed++;
time = ( log->time - level.startTime ) / 1000;
Com_sprintf( stamp, sizeof( stamp ), "%3d:%02d", time / 60, time % 60 );
- ADMBP( va( "^2%c^7%-3d %s ^7%s^7 %s%s%s\n",
+ ADMBP( va( "^2%c^7%-3d %s %s^7%s%s%s %s%s%s\n",
log->actor && log->fate != BF_REPLACE && log->fate != BF_UNPOWER ?
'*' : ' ',
i + MAX_CLIENTS,
log->actor && ( log->fate == BF_REPLACE || log->fate == BF_UNPOWER ) ?
" \\_" : stamp,
BG_Buildable( log->modelindex )->humanName,
+ log->builtBy && log->fate != BF_CONSTRUCT ?
+ " (built by " :
+ "",
+ log->builtBy && log->fate != BF_CONSTRUCT ?
+ log->builtBy->name[ log->builtBy->nameOffset ] :
+ "",
+ log->builtBy && log->fate != BF_CONSTRUCT ?
+ "^7)" :
+ "",
fates[ log->fate ],
log->actor ? " by " : "",
log->actor ?
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 6f48aadd..8bfa7048 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -884,8 +884,9 @@ void ASpawn_Think( gentity_t *self )
// If it's part of the map, kill self.
if( ent->s.eType == ET_BUILDABLE )
{
- if( ent->builtBy >= 0 ) // don't queue the bp from this
- G_Damage( ent, NULL, g_entities + ent->builtBy, NULL, NULL, 10000, 0, MOD_SUICIDE );
+ // don't queue the bp from this
+ if( ent->builtBy && ent->builtBy->slot >= 0 )
+ G_Damage( ent, NULL, g_entities + ent->builtBy->slot, NULL, NULL, 10000, 0, MOD_SUICIDE );
else
G_Damage( ent, NULL, NULL, NULL, NULL, 10000, 0, MOD_SUICIDE );
@@ -1791,8 +1792,8 @@ void HRepeater_Think( gentity_t *self )
// If the repeater is inside of another power zone then suicide
// Attribute death to whoever built the reactor if that's a human,
// which will ensure that it does not queue the BP
- if( powerEnt->builtBy >= 0 )
- G_Damage( self, NULL, g_entities + powerEnt->builtBy, NULL, NULL, self->health, 0, MOD_SUICIDE );
+ if( powerEnt->builtBy && powerEnt->builtBy->slot >= 0 )
+ G_Damage( self, NULL, g_entities + powerEnt->builtBy->slot, NULL, NULL, self->health, 0, MOD_SUICIDE );
else
G_Damage( self, NULL, NULL, NULL, NULL, self->health, 0, MOD_SUICIDE );
return;
@@ -3667,9 +3668,9 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable,
built->s.weapon = BG_Buildable( buildable )->turretProjType;
if( builder->client )
- built->builtBy = builder->client->ps.clientNum;
+ built->builtBy = builder->client->pers.namelog;
else
- built->builtBy = -1;
+ built->builtBy = NULL;
G_SetOrigin( built, localOrigin );
@@ -3706,7 +3707,7 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable,
G_SetIdleBuildableAnim( built, BG_Buildable( buildable )->idleAnim );
- if( built->builtBy >= 0 )
+ if( built->builtBy )
G_SetBuildableAnim( built, BANIM_CONSTRUCT1, qtrue );
trap_LinkEntity( built );
@@ -4225,6 +4226,7 @@ void G_BuildLogSet( buildLog_t *log, gentity_t *ent )
log->modelindex = ent->s.modelindex;
log->deconstruct = log->deconstruct;
log->deconstructTime = ent->deconstructTime;
+ log->builtBy = ent->builtBy;
VectorCopy( ent->s.pos.trBase, log->origin );
VectorCopy( ent->s.angles, log->angles );
VectorCopy( ent->s.origin2, log->origin2 );
@@ -4339,6 +4341,7 @@ void G_BuildLogRevert( int id )
builder->s.modelindex = log->modelindex;
builder->deconstruct = log->deconstruct;
builder->deconstructTime = log->deconstructTime;
+ builder->builtBy = log->builtBy;
builder->think = G_BuildLogRevertThink;
builder->nextthink = level.time + FRAMETIME;
diff --git a/src/game/g_local.h b/src/game/g_local.h
index e027b415..727c280b 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -198,7 +198,7 @@ struct gentity_s
qboolean active; // for power repeater, but could be useful elsewhere
qboolean locked; // used for turret tracking
qboolean powered; // for human buildables
- int builtBy; // clientNum of person that built this
+ struct namelog_s *builtBy; // person who built this
int dcc; // number of controlling dccs
qboolean spawned; // whether or not this buildable has finished spawning
int shrunkTime; // time when a barricade shrunk or zero
@@ -516,6 +516,7 @@ typedef struct
int time;
buildFate_t fate;
namelog_t *actor;
+ namelog_t *builtBy;
buildable_t modelindex;
qboolean deconstruct;
int deconstructTime;