mirror of
https://github.com/UberGames/RPG-X2-rpgxEF.git
synced 2025-02-12 15:15:42 +00:00
Steps towards reenabling SQL suppport (much TODO)
- acccessing the user DB now works. if it does not exist it will be created - adding new users with the useradd command works again - userlogin command works again
This commit is contained in:
parent
d58101a275
commit
b7d34b9994
10 changed files with 284 additions and 168 deletions
|
@ -62,6 +62,7 @@ OBJ = \
|
|||
g_items.o \
|
||||
g_fx.o \
|
||||
g_combat.o \
|
||||
g_sql.o \
|
||||
g_cmds.o \
|
||||
g_client.o \
|
||||
g_breakable.o \
|
||||
|
@ -69,7 +70,6 @@ OBJ = \
|
|||
g_arenas.o \
|
||||
g_active.o \
|
||||
g_cinematic.o \
|
||||
g_sql.o \
|
||||
bg_slidemove.o \
|
||||
bg_pmove.o \
|
||||
bg_oums.o \
|
||||
|
|
|
@ -24,6 +24,7 @@ void Cinematic_ActivateCameraMode(gentity_t *ent, gentity_t *target) {
|
|||
VectorCopy(ent->r.currentOrigin, client->origOrigin);
|
||||
SetClientViewAngle(ent, target->s.angles);
|
||||
G_SetOrigin(ent, target->r.currentOrigin);
|
||||
VectorCopy(target->r.currentOrigin, ent->client->ps.origin);
|
||||
trap_LinkEntity(ent);
|
||||
}
|
||||
|
||||
|
|
289
game/g_cmds.c
289
game/g_cmds.c
|
@ -2,6 +2,7 @@
|
|||
//
|
||||
|
||||
#include "g_local.h"
|
||||
#include "g_sql.h"
|
||||
|
||||
//#include <windows.h>
|
||||
|
||||
|
@ -246,7 +247,7 @@ static void Cmd_Give_f( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 1) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_GIVE) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -440,7 +441,7 @@ static void Cmd_God_f (gentity_t *ent)
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 2) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_GOD) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -493,7 +494,7 @@ static void Cmd_Noclip_f( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 4) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_NOCLIP) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -1205,7 +1206,7 @@ static void Cmd_Cloak_f( gentity_t *ent )
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 8) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_CLOAK) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -1257,7 +1258,7 @@ static void Cmd_EvoSuit_f( gentity_t *ent )
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 16) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_EVOSUIT) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -1298,7 +1299,7 @@ static void Cmd_Flight_f( gentity_t *ent )
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 32) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FLIGHT) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -1981,7 +1982,7 @@ void Cmd_ForceVote_f( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 536870912) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEVOTE) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -2079,7 +2080,7 @@ void Cmd_ForceName_f( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 64) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCENAME) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -2171,7 +2172,7 @@ void Cmd_ShakeCamera_f( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 1073741824) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_SHAKE) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -2258,7 +2259,7 @@ void Cmd_ForceClass_f( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 268435456) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCECLASS) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -2351,7 +2352,7 @@ void Cmd_ForceKill_f( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 128) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEKILL) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -2482,7 +2483,7 @@ void Cmd_ForceKillRadius_f( gentity_t *ent)
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 128) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEKILL) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -2606,7 +2607,7 @@ void Cmd_TargetKick_f( gentity_t *ent)
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 256) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_KICK) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -2680,7 +2681,7 @@ void Cmd_Drag_f( gentity_t *ent)
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 512) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DRAG) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -2799,7 +2800,7 @@ void Cmd_UnDrag_f( gentity_t *ent)
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 512) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DRAG) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -2964,7 +2965,7 @@ void Cmd_disarm_f( gentity_t *ent)
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 1024) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_DISARM) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -3164,7 +3165,7 @@ void Cmd_ForceRank_f( gentity_t *ent)
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 2048) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCERANK) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -3434,7 +3435,7 @@ void Cmd_Revive_f( gentity_t *ent)
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 4096) || !rpg_medicsrevive.integer ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_REVIVE) || !rpg_medicsrevive.integer ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -3599,7 +3600,7 @@ void Cmd_n00b_f( gentity_t *ent)
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 8192) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_NOOB) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -3663,7 +3664,7 @@ static void Cmd_admin_message( gentity_t *ent)
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 16384) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_MESSAGE) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -3728,7 +3729,7 @@ static void Cmd_ForceModel_f( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 32768) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEMODEL) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -3802,7 +3803,7 @@ static void Cmd_PlayMusic_f( gentity_t *ent )
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 65536) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, 65536) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -3841,7 +3842,7 @@ static void Cmd_StopMusic_f( gentity_t *ent )
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 65536) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_MUSIC) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -3869,7 +3870,7 @@ static void Cmd_PlaySound_f( gentity_t *ent )
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 131072) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_SOUND) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -3972,7 +3973,7 @@ static void Cmd_UseEnt_f ( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 262144) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_USEENT) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -4058,7 +4059,7 @@ void Cmd_EntList_f ( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 2147483648) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_USEENT) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -4320,7 +4321,7 @@ void Cmd_BeamToLoc_f( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 524288) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_BEAM) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -4495,7 +4496,7 @@ void Cmd_ForcePlayer_f ( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 1048576) ) {
|
||||
if ( !IsAdmin( ent ) || G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FORCEPLAYER) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -4603,7 +4604,7 @@ void Cmd_BeamToPlayer_f( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 524288) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_BEAM) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -5075,7 +5076,7 @@ void Cmd_fxGun_f ( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 2097152) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FX) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -5313,7 +5314,7 @@ void Cmd_flushFX_f( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 2097152) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FX) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -5337,7 +5338,7 @@ void Cmd_spawnChar_f( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 4194304) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_CHARS) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -5372,7 +5373,7 @@ void Cmd_fluchChars_f( gentity_t *ent ) //GSIO01: fluch Chars ehhh? you know flu
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 4194304) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_CHARS) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -5411,9 +5412,9 @@ void Cmd_flushDropped_f( gentity_t *ent )
|
|||
|
||||
trap_Argv( 1, arg, sizeof(arg) );
|
||||
if ( !arg[0] ) {
|
||||
ans = 0;
|
||||
ans = (qboolean)0;
|
||||
} else {
|
||||
ans = atoi( arg );
|
||||
ans = (qboolean)atoi( arg );
|
||||
}
|
||||
|
||||
for ( i=0, locEnt=g_entities; i < level.num_entities; locEnt++, i++ ) {
|
||||
|
@ -5453,7 +5454,7 @@ static void Cmd_Kick2_f( gentity_t *ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 256) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_KICK) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -5557,7 +5558,7 @@ static void Cmd_ClampInfo_f( gentity_t* ent ) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 8388608) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_CLAMP) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -5914,7 +5915,7 @@ static void Cmd_lockDoor_f(gentity_t *ent) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 16777216) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_CLAMP) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -6000,7 +6001,7 @@ static void Cmd_ffColor_f(gentity_t *ent) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 33554432) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FFSTUFF) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -6084,7 +6085,7 @@ static void Cmd_unlockAll_f(gentity_t *ent) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 16777216) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_LOCK) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -6137,7 +6138,7 @@ static void Cmd_lockAll_f(gentity_t *ent) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 16777216) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_LOCK) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -6170,7 +6171,7 @@ static void Cmd_changeFreq(gentity_t *ent) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 33554432) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_FFSTUFF) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -6218,7 +6219,7 @@ static void Cmd_alert_f(gentity_t *ent) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 67108864) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_ALERT) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -6299,7 +6300,7 @@ static void Cmd_selfdestruct_f(gentity_t *ent) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, /*need to fill this*/ ) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, /*need to fill this*/-1 ) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -6433,7 +6434,7 @@ static void Cmd_admin_centerprint_f(gentity_t *ent) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 16384) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_MESSAGE) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -6685,7 +6686,7 @@ static void Cmd_flushTentities_f(gentity_t *ent) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 134217728) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_TESS) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -6750,7 +6751,7 @@ static void Cmd_spawnTentity_f(gentity_t *ent) {
|
|||
return;
|
||||
}
|
||||
#else
|
||||
if ( !IsAdmin( ent ) || !qboolean G_Sql_UserDB_CheckRight(ent->client->uid, 134217728) ) {
|
||||
if ( !IsAdmin( ent ) || !G_Sql_UserDB_CheckRight(ent->client->uid, SQLF_TESS) ) {
|
||||
trap_SendServerCommand( ent-g_entities, va("print \"ERROR: You are not logged in as a user with the appropiate rights.\n\" ") );
|
||||
return;
|
||||
}
|
||||
|
@ -7448,7 +7449,8 @@ static void UI_DEBUG(gentity_t *ent) {
|
|||
G_Printf(S_COLOR_GREEN "%s\n", arg);
|
||||
}
|
||||
|
||||
#ifdef OLDSQL // SQL
|
||||
#define SQL
|
||||
#ifdef SQL
|
||||
/*
|
||||
=================
|
||||
Cmd_SqlLogin_f
|
||||
|
@ -7457,7 +7459,7 @@ Cmd_SqlLogin_f
|
|||
static void Cmd_SqlLogin_f(gentity_t *ent) {
|
||||
char uName[MAX_TOKEN_CHARS];
|
||||
char pwd[MAX_TOKEN_CHARS];
|
||||
int res;
|
||||
qboolean res;
|
||||
int clientNum;
|
||||
gclient_t *client;
|
||||
|
||||
|
@ -7473,24 +7475,98 @@ static void Cmd_SqlLogin_f(gentity_t *ent) {
|
|||
trap_Argv(1, uName, sizeof(uName));
|
||||
trap_Argv(2, pwd, sizeof(pwd));
|
||||
|
||||
res = trap_SQL_UserLogin(sql_dbName.string, uName, pwd);
|
||||
res = G_Sql_UserDB_Login(uName, pwd, clientNum);
|
||||
|
||||
if(res > 0) {
|
||||
if(res) {
|
||||
trap_SendServerCommand(clientNum, "print \"Login Successful.\n\"");
|
||||
client->uid = res;
|
||||
res = trap_SQL_UserCheckRight(sql_dbName.string, client->uid, "admin");
|
||||
if(res) {
|
||||
client->LoggedAsAdmin = qtrue;
|
||||
ClientUserinfoChanged(clientNum);
|
||||
trap_SendServerCommand(clientNum, "print \"You have been grated full admin access.\n\"");
|
||||
}
|
||||
} else if (res == 0) {
|
||||
trap_SendServerCommand(clientNum, "print \"Login failed. An SQL error occured.\n\"");
|
||||
} else {
|
||||
trap_SendServerCommand(clientNum, "print \"Login failed. Wrong password or username?\n\"");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Cmd_SqlUserAdd_f
|
||||
=================
|
||||
*/
|
||||
static void Cmd_SqlUserAdd_f(gentity_t *ent) {
|
||||
char uName[MAX_TOKEN_CHARS];
|
||||
char password[MAX_TOKEN_CHARS];
|
||||
qboolean res;
|
||||
|
||||
if(!sql_use.integer || !ent || !ent->client) return;
|
||||
|
||||
if(!IsAdmin(ent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(trap_Argc() < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
trap_Argv(1, uName, sizeof(uName));
|
||||
trap_Argv(2, password, sizeof(password));
|
||||
|
||||
res = G_Sql_UserDB_Add(uName, password);
|
||||
|
||||
if(!res) {
|
||||
trap_SendServerCommand(ent->client->ps.clientNum, "print \"User could not be added.\n\"");
|
||||
} else {
|
||||
trap_SendServerCommand(ent->client->ps.clientNum, va("print \"User was added.\n\""));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Cmd_SqlUserMod_f
|
||||
=================
|
||||
*/
|
||||
static void Cmd_SqlUserMod_f(gentity_t *ent) {
|
||||
char uName[MAX_TOKEN_CHARS];
|
||||
char right[MAX_TOKEN_CHARS];
|
||||
long lright;
|
||||
int value;
|
||||
qboolean res;
|
||||
int clientNum;
|
||||
|
||||
if(!sql_use.integer || !ent || !ent->client) return;
|
||||
|
||||
if(!IsAdmin(ent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(trap_Argc() < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
clientNum = ent->client->ps.clientNum;
|
||||
|
||||
trap_Argv(3, uName, sizeof(uName));
|
||||
value = atoi(uName);
|
||||
trap_Argv(1, uName, sizeof(uName));
|
||||
trap_Argv(2, right, sizeof(right));
|
||||
|
||||
/* TODO finish me */
|
||||
res = qfalse;
|
||||
|
||||
switch(res) {
|
||||
case 1:
|
||||
trap_SendServerCommand(clientNum, "print \"Seems to have worked.\n\"");
|
||||
break;
|
||||
case 2:
|
||||
trap_SendServerCommand(clientNum, "print \"User does not exist.\n\"");
|
||||
break;
|
||||
case 3:
|
||||
trap_SendServerCommand(clientNum, "print \"No entry for user found. Created one.\n\"");
|
||||
break;
|
||||
case 0:
|
||||
trap_SendServerCommand(clientNum, "print \"An SQL Error occured, check server log for more information.\n\"");
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef OLDSQL
|
||||
/*
|
||||
=================
|
||||
Cmd_SqlSetup_f
|
||||
|
@ -7520,89 +7596,6 @@ static void Cmd_SqlSetup_f(gentity_t *ent) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Cmd_SqlUserAdd_f
|
||||
=================
|
||||
*/
|
||||
static void Cmd_SqlUserAdd_f(gentity_t *ent) {
|
||||
char uName[MAX_TOKEN_CHARS];
|
||||
char password[MAX_TOKEN_CHARS];
|
||||
int res;
|
||||
int clientNum;
|
||||
|
||||
if(!sql_use.integer || !ent || !ent->client) return;
|
||||
|
||||
if(!IsAdmin(ent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(trap_Argc() < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
clientNum = ent->client->ps.clientNum;
|
||||
|
||||
trap_Argv(1, uName, sizeof(uName));
|
||||
trap_Argv(2, password, sizeof(password));
|
||||
|
||||
res = trap_SQL_UserAdd(sql_dbName.string, uName, password);
|
||||
|
||||
if(res <= 0) {
|
||||
trap_SendServerCommand(clientNum, "print \"An SQL Error occured, serr server lof gor more information.\n\"");
|
||||
return;
|
||||
} else {
|
||||
trap_SendServerCommand(clientNum, va("print \"The user %s was added with ID %i.\n\"", uName, res));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Cmd_SqlUserMod_f
|
||||
=================
|
||||
*/
|
||||
static void Cmd_SqlUserMod_f(gentity_t *ent) {
|
||||
char uName[MAX_TOKEN_CHARS];
|
||||
char right[MAX_TOKEN_CHARS];
|
||||
int value;
|
||||
int res;
|
||||
int clientNum;
|
||||
|
||||
if(!sql_use.integer || !ent || !ent->client) return;
|
||||
|
||||
if(!IsAdmin(ent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(trap_Argc() < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
clientNum = ent->client->ps.clientNum;
|
||||
|
||||
trap_Argv(3, uName, sizeof(uName));
|
||||
value = atoi(uName);
|
||||
trap_Argv(1, uName, sizeof(uName));
|
||||
trap_Argv(2, right, sizeof(right));
|
||||
|
||||
res = trap_SQL_UserMod(sql_dbName.string, uName, right, value);
|
||||
|
||||
switch(res) {
|
||||
case 1:
|
||||
trap_SendServerCommand(clientNum, "print \"Seems to have worked.\n\"");
|
||||
break;
|
||||
case 2:
|
||||
trap_SendServerCommand(clientNum, "print \"User does not exist.\n\"");
|
||||
break;
|
||||
case 3:
|
||||
trap_SendServerCommand(clientNum, "print \"No entry for user found. Created one.\n\"");
|
||||
break;
|
||||
case 0:
|
||||
trap_SendServerCommand(clientNum, "print \"An SQL Error occured, check server log for more information.\n\"");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Cmd_SqlUserDel_f
|
||||
|
@ -7945,15 +7938,19 @@ void ClientCommand( int clientNum )
|
|||
Cmd_UiHolodeck_f(ent);
|
||||
else if (Q_stricmp(cmd, "ui_debug") == 0)
|
||||
UI_DEBUG(ent);
|
||||
#ifdef OLDSQL // SQL
|
||||
#ifdef SQL
|
||||
else if (Q_stricmp(cmd, "userlogin") == 0)
|
||||
Cmd_SqlLogin_f(ent);
|
||||
else if (Q_stricmp(cmd, "sql_setup") == 0)
|
||||
Cmd_SqlSetup_f(ent);
|
||||
else if (Q_stricmp(cmd, "userAdd") == 0)
|
||||
Cmd_SqlUserAdd_f(ent);
|
||||
else if (Q_stricmp(cmd, "userMod") == 0)
|
||||
Cmd_SqlUserMod_f(ent);
|
||||
#endif
|
||||
#ifdef OLDSQL // SQL
|
||||
else if (Q_stricmp(cmd, "sql_setup") == 0)
|
||||
Cmd_SqlSetup_f(ent);
|
||||
else if (Q_stricmp(cmd, "userAdd") == 0)
|
||||
Cmd_SqlUserAdd_f(ent);
|
||||
else if (Q_stricmp(cmd, "userDel") == 0)
|
||||
Cmd_SqlUserDel_f(ent);
|
||||
#endif
|
||||
|
|
|
@ -15,6 +15,11 @@
|
|||
//#define GAMEVERSION "RPG-X v",RPGX_VERSION
|
||||
//const char GAMEVERSION[] = strcat("RPG-X v",RPGX_VERSION);
|
||||
#define GAMEVERSION "rpg-x2"
|
||||
|
||||
#ifndef BASEPATH
|
||||
#define BASEPATH "rpgxEF"
|
||||
#endif
|
||||
|
||||
//#define RPGX_SERECT_PASS "HRkq1yF22o06Zng9FZXH5sle" //"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD> <20><><EFBFBD>"
|
||||
|
||||
#define BODY_QUEUE_SIZE 8
|
||||
|
@ -979,6 +984,7 @@ qboolean G_Sql_UserDB_AddRight(int uid, int right);
|
|||
qboolean G_Sql_UserDB_RemoveRight(int uid, int right);
|
||||
qboolean G_Sql_UserDB_Del(const char *uName);
|
||||
qboolean G_Sql_UserDB_Login(const char *uName, const char *pwd, int clientnum);
|
||||
int G_Sql_UserDB_GetUID(const char *uName);
|
||||
|
||||
//RPG-X: J2J - Nice neat struct to hold info for admin tricorder transport..//////
|
||||
//TiM: I may be a complete nutter here, but I'm gonna try and mod this to see if we can mosey SP transportery FX in here
|
||||
|
|
|
@ -2068,7 +2068,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) {
|
|||
if ( trap_Cvar_VariableIntegerValue( "bot_enable" ) ) {
|
||||
BotAISetup( restart );
|
||||
BotAILoadMap( restart );
|
||||
G_InitBots( restart );
|
||||
G_InitBots( (qboolean)restart );
|
||||
}
|
||||
|
||||
G_InitModRules();
|
||||
|
@ -2160,6 +2160,16 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) {
|
|||
t->nextthink = level.time + 1000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef SQL
|
||||
if(G_Sql_Init()) {
|
||||
G_Printf("SQL initialization successful.\n");
|
||||
} else {
|
||||
G_Printf(S_COLOR_RED "Error: SQL initialization failed!\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/*************************************************************************************************/
|
||||
|
||||
G_Printf(" ,. \n"); G_Printf(" ..:, :Xt. ,:. \n");
|
||||
|
@ -2216,6 +2226,10 @@ void G_ShutdownGame( int restart ) {
|
|||
if(selfdestructSafeZones != NULL) {
|
||||
destroy_list(selfdestructSafeZones);
|
||||
}
|
||||
|
||||
#ifdef SQL
|
||||
G_Sql_Shutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
131
game/g_sql.c
131
game/g_sql.c
|
@ -11,15 +11,15 @@
|
|||
#include "g_local.h"
|
||||
#include "md5.h"
|
||||
|
||||
extern vmCvar_t sql_dbName;
|
||||
extern vmCvar_t sql_use;
|
||||
extern vmCvar_t sql_server;
|
||||
extern vmCvar_t sql_user;
|
||||
extern vmCvar_t sql_password;
|
||||
extern vmCvar_t sql_port;
|
||||
//extern vmCvar_t sql_dbName;
|
||||
//extern vmCvar_t sql_use;
|
||||
//extern vmCvar_t sql_server;
|
||||
//extern vmCvar_t sql_user;
|
||||
//extern vmCvar_t sql_password;
|
||||
//extern vmCvar_t sql_port;
|
||||
|
||||
extern void QDECL G_Printf( const char *fmt, ... );
|
||||
extern void QDECL G_PrintfClient( gentity_t *ent, const char *fmt, ...);
|
||||
//extern void QDECL G_Printf( const char *fmt, ... );
|
||||
//extern void QDECL G_PrintfClient( gentity_t *ent, const char *fmt, ...);
|
||||
|
||||
sqlite3 *user_db;
|
||||
qboolean sql_ready = qfalse;
|
||||
|
@ -111,9 +111,9 @@ qboolean G_Sql_Init(void) {
|
|||
|
||||
if(!sql_use.integer) return qtrue;
|
||||
|
||||
res = sqlite3_open("db/users.db", &user_db);
|
||||
res = sqlite3_open(BASEPATH "/db/users.db", &user_db);
|
||||
if(res != SQLITE_OK) {
|
||||
G_Printf(S_COLOR_RED "SQL ERROR: %s\n", sqlite3_errmsg(user_db));
|
||||
G_Printf(S_COLOR_RED "[SQL-Error] %s\n", sqlite3_errmsg(user_db));
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
|
@ -171,6 +171,7 @@ G_Sql_Shutdown
|
|||
void G_Sql_Shutdown(void) {
|
||||
|
||||
if(!sql_use.integer) return;
|
||||
if(sql_ready == qfalse) return;
|
||||
|
||||
sql_ready = qfalse;
|
||||
sqlite3_close(user_db);
|
||||
|
@ -185,6 +186,11 @@ qboolean G_Sql_UserDB_Del(const char *uName) {
|
|||
sqlite3_stmt *stmt;
|
||||
int res, id = -1;
|
||||
|
||||
if(!sql_ready) {
|
||||
G_Printf(S_COLOR_RED "[SQL-Error] SQL is not initialized!\n");
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
res = sqlite3_prepare_v2(user_db, "SELECT id FROM rpgx_users WHERE username = :UNAME", -1, &stmt, 0);
|
||||
if(G_Sql_Check_PrepareReturn(res)) {
|
||||
return qfalse;
|
||||
|
@ -211,7 +217,7 @@ qboolean G_Sql_UserDB_Del(const char *uName) {
|
|||
sqlite3_finalize(stmt);
|
||||
|
||||
if(id == -1) {
|
||||
G_Printf(S_COLOR_RED "SQL ERROR: no user %s found\n", uName);
|
||||
G_Printf(S_COLOR_RED "[SQL-Error] No user %s found\n", uName);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
|
@ -251,11 +257,16 @@ qboolean G_Sql_UserDB_Del(const char *uName) {
|
|||
G_Sql_UserAdd
|
||||
===============
|
||||
*/
|
||||
qboolean Do_Sql_UserAdd(const char *uName, const char *password) {
|
||||
qboolean G_Sql_UserDB_Add(const char *uName, const char *password) {
|
||||
sqlite3_stmt *stmt;
|
||||
int res, id;
|
||||
char *hashedpw;
|
||||
|
||||
if(!sql_ready) {
|
||||
G_Printf(S_COLOR_RED "[SQL-Error] SQL is not initialized!\n");
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
res = sqlite3_prepare_v2(user_db, SQL_USER_GET_UID, -1, &stmt, 0);
|
||||
if(G_Sql_Check_PrepareReturn(res)) {
|
||||
return qfalse;
|
||||
|
@ -339,11 +350,16 @@ qboolean Do_Sql_UserAdd(const char *uName, const char *password) {
|
|||
G_Sql_UserDB_login
|
||||
===============
|
||||
*/
|
||||
qboolean G_Sql_UserDB_login(const char *uName, const char *pwd, int clientnum) {
|
||||
qboolean G_Sql_UserDB_Login(const char *uName, const char *pwd, int clientnum) {
|
||||
sqlite3_stmt *stmt;
|
||||
int res, id;
|
||||
char *hashedpw;
|
||||
|
||||
if(!sql_ready) {
|
||||
G_Printf(S_COLOR_RED "[SQL-Error] SQL is not initialized!\n");
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
res = sqlite3_prepare_v2(user_db, SQL_USER_LOGIN, -1, &stmt, 0);
|
||||
if(G_Sql_Check_PrepareReturn(res)) {
|
||||
return qfalse;
|
||||
|
@ -368,12 +384,37 @@ qboolean G_Sql_UserDB_login(const char *uName, const char *pwd, int clientnum) {
|
|||
if(res == SQLITE_ROW) {
|
||||
id = sqlite3_column_int(stmt, 0);
|
||||
level.clients[clientnum].uid = id;
|
||||
return qtrue;
|
||||
} else {
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
return qfalse;
|
||||
res = sqlite3_prepare_v2(user_db, SQL_USER_CHECK_ADMIN, -1, &stmt, 0);
|
||||
if(G_Sql_Check_PrepareReturn(res)) {
|
||||
level.clients[clientnum].uid = -1;
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
res = sqlite3_bind_int(stmt, 1, id);
|
||||
if(G_Sql_Check_BindReturn(res)) {
|
||||
level.clients[clientnum].uid = -1;
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
res = sqlite3_step(stmt);
|
||||
if(G_Sql_Check_StepReturn(res)) {
|
||||
level.clients[clientnum].uid = -1;
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if(res == SQLITE_ROW) {
|
||||
level.clients[clientnum].LoggedAsAdmin = qtrue;
|
||||
} else {
|
||||
level.clients[clientnum].uid = -1;
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -386,6 +427,11 @@ qboolean G_Sql_UserDB_CheckRight(int uid, int right) {
|
|||
int res;
|
||||
long rights;
|
||||
|
||||
if(!sql_ready) {
|
||||
G_Printf(S_COLOR_RED "[SQL-Error] SQL is not initialized!\n");
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
res = sqlite3_prepare_v2(user_db, SQL_USER_GET_RIGHTS, -1, &stmt, 0);
|
||||
if(G_Sql_Check_PrepareReturn(res)) {
|
||||
return qfalse;
|
||||
|
@ -404,14 +450,18 @@ qboolean G_Sql_UserDB_CheckRight(int uid, int right) {
|
|||
if(res == SQLITE_ROW) {
|
||||
rights = (long)sqlite3_column_int64(stmt, 0);
|
||||
if(right & right) {
|
||||
sqlite3_finalize(stmt);
|
||||
return qtrue;
|
||||
} else {
|
||||
sqlite3_finalize(stmt);
|
||||
return qfalse;
|
||||
}
|
||||
} else {
|
||||
sqlite3_finalize(stmt);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
|
@ -425,6 +475,11 @@ qboolean G_Sql_UserDB_AddRight(int uid, int right) {
|
|||
int res;
|
||||
long rights;
|
||||
|
||||
if(!sql_ready) {
|
||||
G_Printf(S_COLOR_RED "[SQL-Error] SQL is not initialized!\n");
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
res = sqlite3_prepare_v2(user_db, SQL_USER_GET_RIGHTS, -1, &stmt, 0);
|
||||
if(G_Sql_Check_PrepareReturn(res)) {
|
||||
return qfalse;
|
||||
|
@ -440,11 +495,10 @@ qboolean G_Sql_UserDB_AddRight(int uid, int right) {
|
|||
} else {
|
||||
return qfalse;
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
rights |= right;
|
||||
|
||||
rights |= right;
|
||||
|
||||
res = sqlite3_prepare_v2(user_db, SQL_USER_MOD_RIGHTS, -1, &stmt, 0);
|
||||
if(G_Sql_Check_PrepareReturn(res)) {
|
||||
return qfalse;
|
||||
|
@ -465,6 +519,7 @@ qboolean G_Sql_UserDB_AddRight(int uid, int right) {
|
|||
return qfalse;
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt);
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
|
@ -478,6 +533,11 @@ qboolean G_Sql_UserDB_RemoveRight(int uid, int right) {
|
|||
int res;
|
||||
long rights;
|
||||
|
||||
if(!sql_ready) {
|
||||
G_Printf(S_COLOR_RED "[SQL-Error] SQL is not initialized!\n");
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
res = sqlite3_prepare_v2(user_db, SQL_USER_MOD_RIGHTS, -1, &stmt, 0);
|
||||
if(G_Sql_Check_PrepareReturn(res)) {
|
||||
return qfalse;
|
||||
|
@ -493,6 +553,7 @@ qboolean G_Sql_UserDB_RemoveRight(int uid, int right) {
|
|||
} else {
|
||||
return qfalse;
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
rights &= right;
|
||||
|
||||
|
@ -516,7 +577,43 @@ qboolean G_Sql_UserDB_RemoveRight(int uid, int right) {
|
|||
return qfalse;
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt);
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
G_Sql_UserDB_GetUID
|
||||
===============
|
||||
*/
|
||||
int G_Sql_UserDB_GetUID(const char *uName) {
|
||||
sqlite3_stmt *stmt;
|
||||
int res;
|
||||
int uid;
|
||||
|
||||
if(!uName || !uName[0] || !sql_ready) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
res = sqlite3_prepare_v2(user_db, SQL_USER_GET_UID, -1, &stmt, 0);
|
||||
if(G_Sql_Check_PrepareReturn(res)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
res = sqlite3_bind_text(stmt, 1, uName, sizeof(uName), SQLITE_STATIC);
|
||||
if(G_Sql_Check_BindReturn(res)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
res = sqlite3_step(stmt);
|
||||
if(res == SQLITE_ROW) {
|
||||
uid = sqlite3_column_int(stmt, 0);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt);
|
||||
return uid;
|
||||
}
|
||||
|
||||
#endif //SQL
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#define SQL_USER_DELETE "DELETE FROM rpgx_users WHERE username = :UNAME"
|
||||
#define SQL_USER_DELTE_RIGHTS "DELETE FROM rpgx_userRights WHERE id = :ID"
|
||||
#define SQL_USER_ADD "INSERT INTO rpgx_users VALUES(NULL,:USERNAME,:PASSWORD)"
|
||||
#define SQL_USER_ADD_RIGHTS "INSERT INTO rpgx_userRights VALUES(NULL, 0, 0, :ID)"
|
||||
#define SQL_USER_ADD_RIGHTS "INSERT INTO rpgx_userRights VALUES(:ID, 0, 0)"
|
||||
#define SQL_USER_MOD_RIGHTS "UPDATE rpgx_userRights SET rights = :RIGHTS WHERE id = :ID"
|
||||
#define SQL_USER_GET_RIGHTS "SELECT rights FROM rpgx_userRights WHERE id = :ID"
|
||||
#define SQL_USER_CHECK_ADMIN "SELECT admin FROM rpgx_userRights WHERE id = :ID"
|
||||
|
@ -62,7 +62,7 @@ typedef enum {
|
|||
SQLF_FORCECLASS = 268435456,
|
||||
SQLF_FORCEVOTE = 536870912,
|
||||
SQLF_SHAKE = 1073741824,
|
||||
SQLF_ENTLIST = 2147483648
|
||||
//SQLF_ENTLIST = 2147483648 // that is to big ... using SQLF_USEENT for entitylist as it makes sense
|
||||
} sql_userflags;
|
||||
|
||||
#endif // _G_SQL_H_
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<AdditionalIncludeDirectories>lua\include;mysql;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>__WIN32__;WIN32;_DEBUG;_WINDOWS;DEBUG;QAGAME;XTRA;G_LUA;CG_LUA;SQL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>__WIN32__;WIN32;_DEBUG;_WINDOWS;DEBUG;QAGAME;XTRA;G_LUA;CG_LUA;SQL=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>false</StringPooling>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
|
|
|
@ -366,6 +366,7 @@ static const luaL_Reg lib_mover[] = {
|
|||
{"HaltAngles", Mover_HaltAngles},
|
||||
{"AsTrain", Mover_AsTrain},
|
||||
{"SetPosition", Mover_SetPosition},
|
||||
{"SetOrigin", Mover_SetPosition},
|
||||
{"ToPosition", Mover_ToPosition},
|
||||
{"SetAngles", Mover_SetAngles},
|
||||
{"ToAngles", Mover_ToAngles},
|
||||
|
|
BIN
stefgame.suo
BIN
stefgame.suo
Binary file not shown.
Loading…
Reference in a new issue