mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Add colors for authed players. Deprecates #1299
This commit is contained in:
parent
65ce202697
commit
548e9969b2
|
@ -32,6 +32,14 @@ enum
|
|||
SPEC_FREEVIEW=-1,
|
||||
SPEC_FOLLOW=-2,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AUTHED_NO=0,
|
||||
AUTHED_HELPER,
|
||||
AUTHED_MOD,
|
||||
AUTHED_ADMIN,
|
||||
};
|
||||
'''
|
||||
|
||||
RawSource = '''
|
||||
|
@ -194,6 +202,10 @@ Objects = [
|
|||
NetIntAny("m_Test"),
|
||||
]),
|
||||
|
||||
NetObjectEx("AuthInfo", "auth-info@netobj.ddnet.tw", [
|
||||
NetIntRange("m_AuthLevel", "AUTHED_NO", "AUTHED_ADMIN"),
|
||||
]),
|
||||
|
||||
## Events
|
||||
|
||||
NetEvent("Common", [
|
||||
|
|
|
@ -153,13 +153,7 @@ public:
|
|||
|
||||
virtual void SnapSetStaticsize(int ItemType, int Size) = 0;
|
||||
|
||||
enum
|
||||
{
|
||||
AUTHED_NO=0,
|
||||
AUTHED_HELPER,
|
||||
AUTHED_MOD,
|
||||
AUTHED_ADMIN,
|
||||
|
||||
enum {
|
||||
RCON_CID_SERV=-1,
|
||||
RCON_CID_VOTE=-2,
|
||||
};
|
||||
|
|
|
@ -176,7 +176,7 @@ int CServerBan::BanExt(T *pBanPool, const typename T::CDataType *pData, int Seco
|
|||
if(Server()->m_aClients[i].m_State == CServer::CClient::STATE_EMPTY)
|
||||
continue;
|
||||
|
||||
if(Server()->m_aClients[i].m_Authed != CServer::AUTHED_NO && NetMatch(pData, Server()->m_NetServer.ClientAddr(i)))
|
||||
if(Server()->m_aClients[i].m_Authed != AUTHED_NO && NetMatch(pData, Server()->m_NetServer.ClientAddr(i)))
|
||||
{
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", "ban error (command denied)");
|
||||
return -1;
|
||||
|
@ -2125,7 +2125,7 @@ void CServer::StatusImpl(IConsole::IResult *pResult, void *pUser, bool DnsblBlac
|
|||
char aAddrStr[NETADDR_MAXSTRSIZE];
|
||||
CServer *pThis = static_cast<CServer *>(pUser);
|
||||
|
||||
bool CanSeeAddress = pThis->m_aClients[pResult->m_ClientID].m_Authed > CServer::AUTHED_MOD;
|
||||
bool CanSeeAddress = pThis->m_aClients[pResult->m_ClientID].m_Authed > AUTHED_MOD;
|
||||
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
|
@ -2137,9 +2137,9 @@ void CServer::StatusImpl(IConsole::IResult *pResult, void *pUser, bool DnsblBlac
|
|||
net_addr_str(pThis->m_NetServer.ClientAddr(i), aAddrStr, sizeof(aAddrStr), true);
|
||||
if(pThis->m_aClients[i].m_State == CClient::STATE_INGAME)
|
||||
{
|
||||
const char *pAuthStr = pThis->m_aClients[i].m_Authed == CServer::AUTHED_ADMIN ? "(Admin)" :
|
||||
pThis->m_aClients[i].m_Authed == CServer::AUTHED_MOD ? "(Mod)" :
|
||||
pThis->m_aClients[i].m_Authed == CServer::AUTHED_HELPER ? "(Helper)" : "";
|
||||
const char *pAuthStr = pThis->m_aClients[i].m_Authed == AUTHED_ADMIN ? "(Admin)" :
|
||||
pThis->m_aClients[i].m_Authed == AUTHED_MOD ? "(Mod)" :
|
||||
pThis->m_aClients[i].m_Authed == AUTHED_HELPER ? "(Helper)" : "";
|
||||
char aAuthStr[128];
|
||||
aAuthStr[0] = '\0';
|
||||
if(pThis->m_aClients[i].m_AuthKey >= 0)
|
||||
|
@ -2178,11 +2178,11 @@ static int GetAuthLevel(const char *pLevel)
|
|||
{
|
||||
int Level = -1;
|
||||
if(!str_comp_nocase(pLevel, "admin"))
|
||||
Level = CServer::AUTHED_ADMIN;
|
||||
Level = AUTHED_ADMIN;
|
||||
else if(!str_comp_nocase_num(pLevel, "mod", 3))
|
||||
Level = CServer::AUTHED_MOD;
|
||||
Level = AUTHED_MOD;
|
||||
else if(!str_comp_nocase(pLevel, "helper"))
|
||||
Level = CServer::AUTHED_HELPER;
|
||||
Level = AUTHED_HELPER;
|
||||
|
||||
return Level;
|
||||
}
|
||||
|
@ -3052,7 +3052,7 @@ bool CServer::SetTimedOut(int ClientID, int OrigID)
|
|||
return false;
|
||||
}
|
||||
DelClientCallback(OrigID, "Timeout Protection used", this);
|
||||
m_aClients[ClientID].m_Authed = IServer::AUTHED_NO;
|
||||
m_aClients[ClientID].m_Authed = AUTHED_NO;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -444,13 +444,25 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
|
||||
// name
|
||||
TextRender()->SetCursor(&Cursor, NameOffset, y + (LineHeight - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
||||
switch(m_pClient->m_aClients[pInfo->m_ClientID].m_AuthLevel) {
|
||||
case AUTHED_HELPER:
|
||||
TextRender()->TextColor(0.5f, 0.0f, 0.5f, 1.0f);
|
||||
break;
|
||||
case AUTHED_MOD:
|
||||
TextRender()->TextColor(0.2f, 0.2f, 0.8f, 1.0f);
|
||||
break;
|
||||
case AUTHED_ADMIN:
|
||||
TextRender()->TextColor(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
break;
|
||||
case AUTHED_NO:
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
if(g_Config.m_ClShowIDs)
|
||||
{
|
||||
char aId[64] = "";
|
||||
if (pInfo->m_ClientID >= 10)
|
||||
str_format(aId, sizeof(aId),"%d: ", pInfo->m_ClientID);
|
||||
else
|
||||
str_format(aId, sizeof(aId)," %d: ", pInfo->m_ClientID);
|
||||
str_format(aId, sizeof(aId)," %2d: ", pInfo->m_ClientID);
|
||||
str_append(aId, m_pClient->m_aClients[pInfo->m_ClientID].m_aName,sizeof(aId));
|
||||
Cursor.m_LineWidth = NameLength+8;
|
||||
TextRender()->TextEx(&Cursor, aId, -1);
|
||||
|
@ -460,6 +472,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
Cursor.m_LineWidth = NameLength;
|
||||
TextRender()->TextEx(&Cursor, m_pClient->m_aClients[pInfo->m_ClientID].m_aName, -1);
|
||||
}
|
||||
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
// clan
|
||||
tw = TextRender()->TextWidth(0, FontSize, m_pClient->m_aClients[pInfo->m_ClientID].m_aClan, -1);
|
||||
|
|
|
@ -1187,6 +1187,8 @@ void CGameClient::OnNewSnapshot()
|
|||
}
|
||||
else if(Item.m_Type == NETOBJTYPE_FLAG)
|
||||
m_Snap.m_paFlags[Item.m_ID%2] = (const CNetObj_Flag *)pData;
|
||||
else if(Item.m_Type == NETOBJTYPE_AUTHINFO)
|
||||
m_aClients[Item.m_ID].m_AuthLevel = ((const CNetObj_AuthInfo *)pData)->m_AuthLevel;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -252,6 +252,8 @@ public:
|
|||
bool m_Friend;
|
||||
bool m_Foe;
|
||||
|
||||
int m_AuthLevel;
|
||||
|
||||
void UpdateRenderInfo();
|
||||
void Reset();
|
||||
|
||||
|
|
|
@ -1333,7 +1333,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
|
||||
int Authed = Server()->GetAuthedState(ClientID);
|
||||
if(Authed)
|
||||
Console()->SetAccessLevel(Authed == IServer::AUTHED_ADMIN ? IConsole::ACCESS_LEVEL_ADMIN : Authed == IServer::AUTHED_MOD ? IConsole::ACCESS_LEVEL_MOD : IConsole::ACCESS_LEVEL_HELPER);
|
||||
Console()->SetAccessLevel(Authed == AUTHED_ADMIN ? IConsole::ACCESS_LEVEL_ADMIN : Authed == AUTHED_MOD ? IConsole::ACCESS_LEVEL_MOD : IConsole::ACCESS_LEVEL_HELPER);
|
||||
else
|
||||
Console()->SetAccessLevel(IConsole::ACCESS_LEVEL_USER);
|
||||
Console()->SetPrintOutputLevel(m_ChatPrintCBIndex, 0);
|
||||
|
@ -1479,7 +1479,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
|
||||
if(!pOption)
|
||||
{
|
||||
if(Authed != IServer::AUTHED_ADMIN) // allow admins to call any vote they want
|
||||
if(Authed != AUTHED_ADMIN) // allow admins to call any vote they want
|
||||
{
|
||||
str_format(aChatmsg, sizeof(aChatmsg), "'%s' isn't an option on this server", pMsg->m_Value);
|
||||
SendChatTarget(ClientID, aChatmsg);
|
||||
|
|
|
@ -698,7 +698,7 @@ void IGameController::Tick()
|
|||
break;
|
||||
}
|
||||
#endif
|
||||
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS && Server()->GetAuthedState(i) == IServer::AUTHED_NO)
|
||||
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS && Server()->GetAuthedState(i) == AUTHED_NO)
|
||||
{
|
||||
if(Server()->Tick() > GameServer()->m_apPlayers[i]->m_LastActionTick+g_Config.m_SvInactiveKickTime*Server()->TickSpeed()*60)
|
||||
{
|
||||
|
|
|
@ -328,6 +328,12 @@ void CPlayer::Snap(int SnappingClient)
|
|||
pPlayerInfo->m_Score = -9999;
|
||||
else
|
||||
pPlayerInfo->m_Score = abs(m_Score) * -1;
|
||||
|
||||
CNetObj_AuthInfo *pAuthInfo = static_cast<CNetObj_AuthInfo *>(Server()->SnapNewItem(NETOBJTYPE_AUTHINFO, id, sizeof(CNetObj_AuthInfo)));
|
||||
if(!pAuthInfo)
|
||||
return;
|
||||
|
||||
pAuthInfo->m_AuthLevel = Server()->GetAuthedState(id);
|
||||
}
|
||||
|
||||
void CPlayer::FakeSnap()
|
||||
|
|
|
@ -352,9 +352,9 @@ TEST_F(TeeHistorian, Auth)
|
|||
0x01,
|
||||
0x40, // FINISH
|
||||
};
|
||||
m_TH.RecordAuthInitial(0, IServer::AUTHED_ADMIN, "default_admin");
|
||||
m_TH.RecordAuthLogin(1, IServer::AUTHED_MOD, "foobar");
|
||||
m_TH.RecordAuthLogin(2, IServer::AUTHED_HELPER, "help");
|
||||
m_TH.RecordAuthInitial(0, AUTHED_ADMIN, "default_admin");
|
||||
m_TH.RecordAuthLogin(1, AUTHED_MOD, "foobar");
|
||||
m_TH.RecordAuthLogin(2, AUTHED_HELPER, "help");
|
||||
m_TH.RecordAuthLogout(1);
|
||||
Finish();
|
||||
Expect(EXPECTED, sizeof(EXPECTED));
|
||||
|
|
Loading…
Reference in a new issue