From 56a06e3ff067b1d691583d0e29de91999b89e29f Mon Sep 17 00:00:00 2001 From: Paradox460 Date: Sun, 9 Mar 2008 21:24:49 +0000 Subject: [PATCH] Added /builder command and flag (+) Upped max admin commands and flags to 128 (200% of original value). Wiki --- src/game/g_admin.h | 5 +++-- src/game/g_buildable.c | 7 +++++++ src/game/g_cmds.c | 36 +++++++++++++++++++++++++++++++++++- src/game/g_local.h | 3 +++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/game/g_admin.h b/src/game/g_admin.h index d81deea..b1c4489 100644 --- a/src/game/g_admin.h +++ b/src/game/g_admin.h @@ -38,8 +38,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define MAX_ADMIN_NAMELOG_NAMES 5 #define MAX_ADMIN_ADMINLOGS 128 #define MAX_ADMIN_ADMINLOG_ARGS 50 -#define MAX_ADMIN_FLAGS 64 -#define MAX_ADMIN_COMMANDS 64 +#define MAX_ADMIN_FLAGS 128 +#define MAX_ADMIN_COMMANDS 128 #define MAX_ADMIN_CMD_LEN 20 #define MAX_ADMIN_BAN_REASON 50 @@ -79,6 +79,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define ADMF_SEESFULLLISTPLAYERS '$' #define ADMF_DBUILDER '#' #define ADMF_ADMINCHAT '?' +#define ADMF_BUILDCHECK '+' #define ADMF_BANIMMUNITY '&' diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index b49ef12..24c0cb0 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -3516,6 +3516,7 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, vec3_t ori BG_FindNameForBuildable( built->s.modelindex ) ); } + // ok we're all done building, so what we log here should be the final values if( builder && builder->client ) // log ingame building only { @@ -3530,6 +3531,12 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, vec3_t ori VectorCopy( built->s.angles2, new->angles2 ); new->fate = BF_BUILT; } + + built->madeby = ( builder->client ) ? builder->client->pers.netname : ""; + if( !builder->client ) + built->bdnumb = -1; + else + built->bdnumb = new->ID ; return built; } diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 5fd920a..ec50106 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -3385,6 +3385,39 @@ void Cmd_Protect_f( gentity_t *ent ) } } +/* +================= +Cmd_Builder_f +================= +*/ +void Cmd_Builder_f( gentity_t *ent ) +{ + vec3_t forward, end; + trace_t tr; + gentity_t *traceEnt; + char bdnumbchr[21]; + + if( !G_admin_permission( ent, ADMF_BUILDCHECK ) ) + return; + + AngleVectors( ent->client->ps.viewangles, forward, NULL, NULL ); + VectorMA( ent->client->ps.origin, 100, forward, end ); + + trap_Trace( &tr, ent->client->ps.origin, NULL, NULL, end, ent->s.number, + MASK_PLAYERSOLID ); + traceEnt = &g_entities[ tr.entityNum ]; + + Com_sprintf( bdnumbchr, sizeof(bdnumbchr), "%i", traceEnt->bdnumb ); + + if( tr.fraction < 1.0f && ( traceEnt->s.eType == ET_BUILDABLE ) && + ( traceEnt->biteam == ent->client->pers.teamSelection ) ) + { + + trap_SendServerCommand( ent-g_entities, va( + "print \"Building was built by: %s^7, buildlog number: %s^7\n\"", traceEnt->madeby, (traceEnt->bdnumb != -1) ? bdnumbchr : "none" ) ); + } +} + /* ================= Cmd_Resign_f @@ -4239,7 +4272,8 @@ commands_t cmds[ ] = { { "share", CMD_TEAM, Cmd_Share_f }, { "donate", CMD_TEAM, Cmd_Donate_f }, { "protect", CMD_TEAM|CMD_LIVING, Cmd_Protect_f }, - { "resign", CMD_TEAM, Cmd_Resign_f } + { "resign", CMD_TEAM, Cmd_Resign_f }, + { "builder", CMD_TEAM, Cmd_Builder_f } }; static int numCmds = sizeof( cmds ) / sizeof( cmds[ 0 ] ); diff --git a/src/game/g_local.h b/src/game/g_local.h index b861d27..20e41d6 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -240,6 +240,9 @@ struct gentity_s int suicideTime; // when the client will suicide int lastDamageTime; + + char *madeby; + int bdnumb; }; typedef enum