Skip to content

Commit

Permalink
Fix compilation without SQL database.
Browse files Browse the repository at this point in the history
  • Loading branch information
progval authored and necropotame committed Nov 30, 2016
1 parent 46b2c58 commit 384a557
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/engine/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ class IServer : public IInterface
virtual void ShowChallenge(int ClientID) = 0;
virtual void ShowRank(int ClientID, int ScoreType) = 0;
virtual void ShowGoal(int ClientID, int ScoreType) = 0;
virtual int GetUserLevel(int ClientID) = 0;
#endif
virtual void Ban(int i, int Seconds, const char* pReason) = 0;
virtual int GetUserLevel(int ClientID) = 0;

public:
virtual class CRoundStatistics* RoundStatistics() = 0;
Expand Down
14 changes: 8 additions & 6 deletions src/engine/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ void CServer::CClient::Reset(bool ResetScore)
m_WasInfected = 0;

m_UserID = -1;
#ifdef CONF_SQL
m_UserLevel = SQL_USERLEVEL_NORMAL;
#endif
m_LogInstance = -1;

m_CustomSkin = 0;
Expand Down Expand Up @@ -978,7 +980,9 @@ int CServer::DelClientCallback(int ClientID, int Type, const char *pReason, void
pThis->m_aClients[ClientID].m_Snapshots.PurgeAll();
pThis->m_aClients[ClientID].m_WaitingTime = 0;
pThis->m_aClients[ClientID].m_UserID = -1;
#ifdef CONF_SQL
pThis->m_aClients[ClientID].m_UserLevel = SQL_USERLEVEL_NORMAL;
#endif
pThis->m_aClients[ClientID].m_LogInstance = -1;
pThis->m_aClients[ClientID].m_Quitting = false;

Expand Down Expand Up @@ -1352,8 +1356,8 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "ClientID=%d authed (admin)", ClientID);
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
#ifdef CONF_SQL
}
else
{
SendRconLine(ClientID, "You are not admin.");
Expand All @@ -1379,8 +1383,8 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "ClientID=%d authed (moderator)", ClientID);
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
#ifdef CONF_SQL
}
else
{
SendRconLine(ClientID, "You are not moderator.");
Expand Down Expand Up @@ -4059,14 +4063,12 @@ void CServer::RemoveAccusations(int ClientID)
m_aClients[ClientID].m_Accusation.m_Num = 0;
}

#ifdef CONF_SQL
int CServer::GetUserLevel(int ClientID)
{
#ifdef CONF_SQL
return m_aClients[ClientID].m_UserLevel;
#else
return SQL_USERLEVEL_NORMAL;
#endif
}
#endif

/* INFECTION MODIFICATION END *****************************************/

4 changes: 3 additions & 1 deletion src/engine/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ class CServer : public IServer
//Login
int m_LogInstance;
int m_UserID;
#ifdef CONF_SQL
int m_UserLevel;
#endif
char m_aUsername[MAX_NAME_LENGTH];
};

Expand Down Expand Up @@ -332,9 +334,9 @@ class CServer : public IServer
virtual void ShowRank(int ClientID, int ScoreType);
virtual void ShowGoal(int ClientID, int ScoreType);
virtual void RefreshChallenge();
virtual int GetUserLevel(int ClientID);
#endif
virtual void Ban(int ClientID, int Seconds, const char* pReason);
virtual int GetUserLevel(int ClientID);
private:
bool InitCaptcha();

Expand Down
6 changes: 6 additions & 0 deletions src/game/server/gamecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2511,7 +2511,9 @@ bool CGameContext::PrivateMessage(const char* pStr, int ClientID, bool TeamChat)
int CheckID = -1;
int CheckTeam = -1;
int CheckClass = -1;
#ifdef CONF_SQL
int CheckLevel = SQL_USERLEVEL_NORMAL;
#endif

if(TeamChat && m_apPlayers[ClientID])
{
Expand Down Expand Up @@ -2543,6 +2545,7 @@ bool CGameContext::PrivateMessage(const char* pStr, int ClientID, bool TeamChat)
str_copy(aChatTitle, "near", sizeof(aChatTitle));
}
}
#ifdef CONF_SQL
else if(str_comp(aNameFound, "!mod") == 0)
{
if(m_apPlayers[ClientID] && m_apPlayers[ClientID]->GetCharacter())
Expand All @@ -2552,6 +2555,7 @@ bool CGameContext::PrivateMessage(const char* pStr, int ClientID, bool TeamChat)
str_copy(aChatTitle, "moderators", sizeof(aChatTitle));
}
}
#endif
else if(str_comp(aNameFound, "!engineer") == 0 && m_apPlayers[ClientID] && m_apPlayers[ClientID]->GetCharacter())
{
CheckClass = PLAYERCLASS_ENGINEER;
Expand Down Expand Up @@ -2694,8 +2698,10 @@ bool CGameContext::PrivateMessage(const char* pStr, int ClientID, bool TeamChat)
continue;
}

#ifdef CONF_SQL
if(Server()->GetUserLevel(i) < CheckLevel)
continue;
#endif

if(CheckID >= 0 && !(i == CheckID))
continue;
Expand Down

0 comments on commit 384a557

Please sign in to comment.