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_FREEVIEW=-1,
|
||||||
SPEC_FOLLOW=-2,
|
SPEC_FOLLOW=-2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
AUTHED_NO=0,
|
||||||
|
AUTHED_HELPER,
|
||||||
|
AUTHED_MOD,
|
||||||
|
AUTHED_ADMIN,
|
||||||
|
};
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RawSource = '''
|
RawSource = '''
|
||||||
|
@ -194,6 +202,10 @@ Objects = [
|
||||||
NetIntAny("m_Test"),
|
NetIntAny("m_Test"),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
NetObjectEx("AuthInfo", "auth-info@netobj.ddnet.tw", [
|
||||||
|
NetIntRange("m_AuthLevel", "AUTHED_NO", "AUTHED_ADMIN"),
|
||||||
|
]),
|
||||||
|
|
||||||
## Events
|
## Events
|
||||||
|
|
||||||
NetEvent("Common", [
|
NetEvent("Common", [
|
||||||
|
|
|
@ -153,13 +153,7 @@ public:
|
||||||
|
|
||||||
virtual void SnapSetStaticsize(int ItemType, int Size) = 0;
|
virtual void SnapSetStaticsize(int ItemType, int Size) = 0;
|
||||||
|
|
||||||
enum
|
enum {
|
||||||
{
|
|
||||||
AUTHED_NO=0,
|
|
||||||
AUTHED_HELPER,
|
|
||||||
AUTHED_MOD,
|
|
||||||
AUTHED_ADMIN,
|
|
||||||
|
|
||||||
RCON_CID_SERV=-1,
|
RCON_CID_SERV=-1,
|
||||||
RCON_CID_VOTE=-2,
|
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)
|
if(Server()->m_aClients[i].m_State == CServer::CClient::STATE_EMPTY)
|
||||||
continue;
|
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)");
|
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", "ban error (command denied)");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -2125,7 +2125,7 @@ void CServer::StatusImpl(IConsole::IResult *pResult, void *pUser, bool DnsblBlac
|
||||||
char aAddrStr[NETADDR_MAXSTRSIZE];
|
char aAddrStr[NETADDR_MAXSTRSIZE];
|
||||||
CServer *pThis = static_cast<CServer *>(pUser);
|
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++)
|
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);
|
net_addr_str(pThis->m_NetServer.ClientAddr(i), aAddrStr, sizeof(aAddrStr), true);
|
||||||
if(pThis->m_aClients[i].m_State == CClient::STATE_INGAME)
|
if(pThis->m_aClients[i].m_State == CClient::STATE_INGAME)
|
||||||
{
|
{
|
||||||
const char *pAuthStr = pThis->m_aClients[i].m_Authed == CServer::AUTHED_ADMIN ? "(Admin)" :
|
const char *pAuthStr = pThis->m_aClients[i].m_Authed == AUTHED_ADMIN ? "(Admin)" :
|
||||||
pThis->m_aClients[i].m_Authed == CServer::AUTHED_MOD ? "(Mod)" :
|
pThis->m_aClients[i].m_Authed == AUTHED_MOD ? "(Mod)" :
|
||||||
pThis->m_aClients[i].m_Authed == CServer::AUTHED_HELPER ? "(Helper)" : "";
|
pThis->m_aClients[i].m_Authed == AUTHED_HELPER ? "(Helper)" : "";
|
||||||
char aAuthStr[128];
|
char aAuthStr[128];
|
||||||
aAuthStr[0] = '\0';
|
aAuthStr[0] = '\0';
|
||||||
if(pThis->m_aClients[i].m_AuthKey >= 0)
|
if(pThis->m_aClients[i].m_AuthKey >= 0)
|
||||||
|
@ -2178,11 +2178,11 @@ static int GetAuthLevel(const char *pLevel)
|
||||||
{
|
{
|
||||||
int Level = -1;
|
int Level = -1;
|
||||||
if(!str_comp_nocase(pLevel, "admin"))
|
if(!str_comp_nocase(pLevel, "admin"))
|
||||||
Level = CServer::AUTHED_ADMIN;
|
Level = AUTHED_ADMIN;
|
||||||
else if(!str_comp_nocase_num(pLevel, "mod", 3))
|
else if(!str_comp_nocase_num(pLevel, "mod", 3))
|
||||||
Level = CServer::AUTHED_MOD;
|
Level = AUTHED_MOD;
|
||||||
else if(!str_comp_nocase(pLevel, "helper"))
|
else if(!str_comp_nocase(pLevel, "helper"))
|
||||||
Level = CServer::AUTHED_HELPER;
|
Level = AUTHED_HELPER;
|
||||||
|
|
||||||
return Level;
|
return Level;
|
||||||
}
|
}
|
||||||
|
@ -3052,7 +3052,7 @@ bool CServer::SetTimedOut(int ClientID, int OrigID)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DelClientCallback(OrigID, "Timeout Protection used", this);
|
DelClientCallback(OrigID, "Timeout Protection used", this);
|
||||||
m_aClients[ClientID].m_Authed = IServer::AUTHED_NO;
|
m_aClients[ClientID].m_Authed = AUTHED_NO;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -444,13 +444,25 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
||||||
|
|
||||||
// name
|
// name
|
||||||
TextRender()->SetCursor(&Cursor, NameOffset, y + (LineHeight - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
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)
|
if(g_Config.m_ClShowIDs)
|
||||||
{
|
{
|
||||||
char aId[64] = "";
|
char aId[64] = "";
|
||||||
if (pInfo->m_ClientID >= 10)
|
str_format(aId, sizeof(aId)," %2d: ", pInfo->m_ClientID);
|
||||||
str_format(aId, sizeof(aId),"%d: ", pInfo->m_ClientID);
|
|
||||||
else
|
|
||||||
str_format(aId, sizeof(aId)," %d: ", pInfo->m_ClientID);
|
|
||||||
str_append(aId, m_pClient->m_aClients[pInfo->m_ClientID].m_aName,sizeof(aId));
|
str_append(aId, m_pClient->m_aClients[pInfo->m_ClientID].m_aName,sizeof(aId));
|
||||||
Cursor.m_LineWidth = NameLength+8;
|
Cursor.m_LineWidth = NameLength+8;
|
||||||
TextRender()->TextEx(&Cursor, aId, -1);
|
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;
|
Cursor.m_LineWidth = NameLength;
|
||||||
TextRender()->TextEx(&Cursor, m_pClient->m_aClients[pInfo->m_ClientID].m_aName, -1);
|
TextRender()->TextEx(&Cursor, m_pClient->m_aClients[pInfo->m_ClientID].m_aName, -1);
|
||||||
}
|
}
|
||||||
|
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
// clan
|
// clan
|
||||||
tw = TextRender()->TextWidth(0, FontSize, m_pClient->m_aClients[pInfo->m_ClientID].m_aClan, -1);
|
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)
|
else if(Item.m_Type == NETOBJTYPE_FLAG)
|
||||||
m_Snap.m_paFlags[Item.m_ID%2] = (const CNetObj_Flag *)pData;
|
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_Friend;
|
||||||
bool m_Foe;
|
bool m_Foe;
|
||||||
|
|
||||||
|
int m_AuthLevel;
|
||||||
|
|
||||||
void UpdateRenderInfo();
|
void UpdateRenderInfo();
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
|
|
|
@ -1333,7 +1333,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
||||||
|
|
||||||
int Authed = Server()->GetAuthedState(ClientID);
|
int Authed = Server()->GetAuthedState(ClientID);
|
||||||
if(Authed)
|
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
|
else
|
||||||
Console()->SetAccessLevel(IConsole::ACCESS_LEVEL_USER);
|
Console()->SetAccessLevel(IConsole::ACCESS_LEVEL_USER);
|
||||||
Console()->SetPrintOutputLevel(m_ChatPrintCBIndex, 0);
|
Console()->SetPrintOutputLevel(m_ChatPrintCBIndex, 0);
|
||||||
|
@ -1479,7 +1479,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
||||||
|
|
||||||
if(!pOption)
|
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);
|
str_format(aChatmsg, sizeof(aChatmsg), "'%s' isn't an option on this server", pMsg->m_Value);
|
||||||
SendChatTarget(ClientID, aChatmsg);
|
SendChatTarget(ClientID, aChatmsg);
|
||||||
|
|
|
@ -698,7 +698,7 @@ void IGameController::Tick()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#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)
|
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;
|
pPlayerInfo->m_Score = -9999;
|
||||||
else
|
else
|
||||||
pPlayerInfo->m_Score = abs(m_Score) * -1;
|
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()
|
void CPlayer::FakeSnap()
|
||||||
|
|
|
@ -352,9 +352,9 @@ TEST_F(TeeHistorian, Auth)
|
||||||
0x01,
|
0x01,
|
||||||
0x40, // FINISH
|
0x40, // FINISH
|
||||||
};
|
};
|
||||||
m_TH.RecordAuthInitial(0, IServer::AUTHED_ADMIN, "default_admin");
|
m_TH.RecordAuthInitial(0, AUTHED_ADMIN, "default_admin");
|
||||||
m_TH.RecordAuthLogin(1, IServer::AUTHED_MOD, "foobar");
|
m_TH.RecordAuthLogin(1, AUTHED_MOD, "foobar");
|
||||||
m_TH.RecordAuthLogin(2, IServer::AUTHED_HELPER, "help");
|
m_TH.RecordAuthLogin(2, AUTHED_HELPER, "help");
|
||||||
m_TH.RecordAuthLogout(1);
|
m_TH.RecordAuthLogout(1);
|
||||||
Finish();
|
Finish();
|
||||||
Expect(EXPECTED, sizeof(EXPECTED));
|
Expect(EXPECTED, sizeof(EXPECTED));
|
||||||
|
|
Loading…
Reference in a new issue