Skip to content

Commit

Permalink
listadmins, optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
videoP committed Oct 19, 2018
1 parent d2a8f93 commit 429e61f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
9 changes: 7 additions & 2 deletions codemp/game/bg_pmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -13207,9 +13207,14 @@ void Pmove (pmove_t *pmove) {
int msec;

msec = finalTime - pmove->ps->commandTime;
if (pmove->ps->stats[STAT_RACEMODE] && BG_InRollFixed(pmove->ps, pmove->ps->legsAnim)) { //Using float now
if (pmove->ps->stats[STAT_RACEMODE]) { //Using float now
if ( msec > 8 ) {
msec = 8;
if (BG_InRollFixed(pmove->ps, pmove->ps->legsAnim)) {
msec = 8;
}
else if (msec > 16) {
msec = 16;
}
}
//Com_Printf("Chopping\n");
}
Expand Down
45 changes: 45 additions & 0 deletions codemp/game/g_account.c
Original file line number Diff line number Diff line change
Expand Up @@ -2679,6 +2679,51 @@ void Svcmd_AccountIPLock_f(void) {

}

void Svcmd_ListAdmins_f(void)
{
if (trap->Argc() != 1) {
trap->Print("Usage: /listAdmins\n");
return;
}

{
sqlite3 * db;
char * sql;
sqlite3_stmt * stmt;
int s;
unsigned int flags;
char adminString[16];

CALL_SQLITE(open(LOCAL_DB_PATH, &db));

sql = "SELECT username, flags FROM localAccount WHERE flags & 16 OR flags & 32 ORDER BY flags DESC"; //ehh
CALL_SQLITE(prepare_v2(db, sql, strlen(sql) + 1, &stmt, NULL));

Com_Printf(" ^5Username Admin\n");

while (1) {
s = sqlite3_step(stmt);
if (s == SQLITE_ROW) {
flags = sqlite3_column_int(stmt, 1);
if (flags & 32)
Q_strncpyz(adminString, "Full", sizeof(adminString));
else if (flags & 16)
Q_strncpyz(adminString, "Junior", sizeof(adminString));
Com_Printf(va(" %-18s %s\n", (char*)sqlite3_column_text(stmt, 0), adminString));
}
else if (s == SQLITE_DONE) {
break;
}
else {
G_ErrorPrint("ERROR: SQL Select Failed (Svcmd_ListAdmins)", s);
return;
}
}
CALL_SQLITE(finalize(stmt));
CALL_SQLITE(close(db));
}
}

void Svcmd_SetAdmin_f(void)
{
char username[16], adminLevelStr[8];
Expand Down
6 changes: 5 additions & 1 deletion codemp/game/g_svcmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,7 @@ void G_TestAddRace( void );
#endif
void Svcmd_AccountIPLock_f( void );
void Svcmd_SetAdmin_f(void);
void Svcmd_ListAdmins_f(void);

void Svcmd_ClanJoin_f( void );
void Svcmd_ClanKick_f( void );
Expand Down Expand Up @@ -1614,6 +1615,9 @@ svcmd_t svcmds[] = {
{ "gametype", Svcmd_ChangeGametype_f, qfalse },
{ "game_memory", Svcmd_GameMem_f, qfalse },
{ "iplock", Svcmd_AccountIPLock_f, qfalse },

{ "listAdmins", Svcmd_ListAdmins_f, qfalse },

{ "listip", Svcmd_ListIP_f, qfalse },

{ "pause", SV_Pause_f, qfalse },
Expand All @@ -1637,7 +1641,7 @@ svcmd_t svcmds[] = {

{ "say", Svcmd_Say_f, qtrue },

{ "setAdmin", Svcmd_SetAdmin_f, qtrue },
{ "setAdmin", Svcmd_SetAdmin_f, qfalse },

{ "startingItems", Svcmd_ToggleStartingItems_f, qfalse },
{ "startingWeapons", Svcmd_ToggleStartingWeapons_f, qfalse },
Expand Down

0 comments on commit 429e61f

Please sign in to comment.