diff options
author | kai <kai@zittrig.eu> | 2020-04-02 16:11:15 +0100 |
---|---|---|
committer | kai <kai@zittrig.eu> | 2020-04-02 16:11:15 +0100 |
commit | 92dfebfc6424b2cb634ee15fef0029f7974b1e2b (patch) | |
tree | 43ccea2ffbbe01e64d1939cf3fc8bc828c7ed1d8 /src | |
parent | 4689f76ff17323021d7141fb88ee2b5452e36006 (diff) |
G_admin_isconsoleaschacht
Diffstat (limited to 'src')
-rw-r--r-- | src/game/g_admin.c | 40 | ||||
-rw-r--r-- | src/game/g_admin.h | 2 | ||||
-rw-r--r-- | src/game/g_local.h | 2 | ||||
-rw-r--r-- | src/game/g_main.c | 4 |
4 files changed, 46 insertions, 2 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c index 6bb44a4..4c2e963 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -1088,6 +1088,42 @@ char* G_admin_adminPrintName( gentity_t *ent ) return out; } +qboolean G_admin_isconsoleaschacht( void ){ + time_t t; + struct tm *actual_time_tm; + char day_s[ 10 ]; + int day; + + time( &t ); // what's the time + + actual_time_tm = localtime( &t ); // whats the local time + + strftime( day_s, sizeof( day_s ), "%d", actual_time_tm ); // i just need the actual day number + + sscanf( day_s, "%d", &day ); // now convert it to an integer for the below logic + + // G_Printf( "Day is (string): %s, day is (int) %i\n", day_s, day ); // debug + + if( day < 15 ){ + if( g_consoleIsASchacht.integer == day ) { + return qfalse; + } + else + { + return qtrue; + } + } + else if( day >= 15 ){ + if( g_consoleIsASchacht.integer == ceil( day / 3 ) ){ + return qfalse; + } + else + { + return qtrue; + } + } +} + static void admin_log( gentity_t *admin, char *cmd, int skiparg ) { fileHandle_t f; @@ -1588,13 +1624,13 @@ qboolean G_admin_cmd_check( gentity_t *ent, qboolean say ) if( G_admin_permission( ent, g_admin_cmds[ i ].flag ) ) { - if( G_admin_permission( ent, ADMF_SCHACHT ) && ent ) + if( ( G_admin_permission( ent, ADMF_SCHACHT ) && ent ) || ( !ent && G_admin_isconsoleaschacht() ) ) { for( j = 0; j < adminNumSchachts; j++ ) { if( !Q_stricmp( cmd, g_admin_schachts[ j ].keyword )) // Q_stricmp = 0 means the values are equal { - Com_sprintf( buffer, sizeof( buffer ), g_admin_schachts[ j ].schacht, ent->client->pers.netname ); + Com_sprintf( buffer, sizeof( buffer ), g_admin_schachts[ j ].schacht, ( ent ) ? G_admin_adminPrintName( ent ) : "console" ); AP( va( "print \"^3!%s: ^7%s^7\n\"", cmd, buffer )); admin_log( ent, "schachted command:", skip - 1 ); return qtrue; diff --git a/src/game/g_admin.h b/src/game/g_admin.h index 9532477..e2cc0ac 100644 --- a/src/game/g_admin.h +++ b/src/game/g_admin.h @@ -240,6 +240,8 @@ int G_admin_level( gentity_t *ent ); void G_admin_set_adminname( gentity_t *ent ); char* G_admin_adminPrintName( gentity_t *ent ); +qboolean G_admin_isconsoleaschacht( void ); // check if the console is schachted + qboolean G_admin_seen(gentity_t *ent, int skiparg ); void G_admin_seen_update( char *guid ); diff --git a/src/game/g_local.h b/src/game/g_local.h index baf69ee..ca176de 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -1507,6 +1507,8 @@ extern vmCvar_t g_specNoclip; extern vmCvar_t g_practise; extern vmCvar_t g_tyrantNerf; +extern vmCvar_t g_consoleIsASchacht; + void trap_Printf( 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 c6b9344..af69a6d 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -248,6 +248,8 @@ vmCvar_t g_specNoclip; vmCvar_t g_practise; vmCvar_t g_tyrantNerf; +vmCvar_t g_consoleIsASchacht; + static cvarTable_t gameCvarTable[ ] = { // don't override the cheat state set by the system @@ -474,6 +476,8 @@ static cvarTable_t gameCvarTable[ ] = { &g_specNoclip, "g_specNoclip", "0", CVAR_ARCHIVE, 0, qtrue }, { &g_practise, "g_practise", "0", CVAR_ARCHIVE, 0, qfalse }, { &g_tyrantNerf, "g_tyrantNerf", "0", CVAR_ARCHIVE, 0, qfalse }, + + { &g_consoleIsASchacht, "g_consoleIsASchacht", "0", CVAR_ARCHIVE, 0, qfalse }, }; static int gameCvarTableSize = sizeof( gameCvarTable ) / sizeof( gameCvarTable[ 0 ] ); |