mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 18:18:18 +00:00
Clean up gametype determination
This commit is contained in:
parent
bf8b482dd7
commit
8b108a2311
|
@ -910,7 +910,6 @@ int net_host_lookup(const char *hostname, NETADDR *addr, int types)
|
||||||
|
|
||||||
dbg_msg("host lookup", "host='%s' port=%d %d", host, port, types);
|
dbg_msg("host lookup", "host='%s' port=%d %d", host, port, types);
|
||||||
|
|
||||||
|
|
||||||
mem_zero(&hints, sizeof(hints));
|
mem_zero(&hints, sizeof(hints));
|
||||||
|
|
||||||
hints.ai_family = AF_UNSPEC;
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
|
|
@ -431,7 +431,7 @@ void CClient::Rcon(const char *pCmd)
|
||||||
{
|
{
|
||||||
CServerInfo Info;
|
CServerInfo Info;
|
||||||
GetServerInfo(&Info);
|
GetServerInfo(&Info);
|
||||||
if(RconAuthed() && (str_find_nocase(Info.m_aGameType, "ddracenetw") || str_find_nocase(Info.m_aGameType, "ddnet")))
|
if(RconAuthed() && IsDDNet(&Info))
|
||||||
{ // Against IP spoofing on DDNet servers
|
{ // Against IP spoofing on DDNet servers
|
||||||
CMsgPacker Msg(NETMSG_RCON_AUTH);
|
CMsgPacker Msg(NETMSG_RCON_AUTH);
|
||||||
Msg.AddString("", 32);
|
Msg.AddString("", 32);
|
||||||
|
@ -1398,7 +1398,7 @@ void CClient::ProcessConnlessPacket(CNetChunk *pPacket)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(Info.m_aGameType, "64") || strstr(Info.m_aName, "64") || strstr(Info.m_aGameType, "DDraceNet") || strstr(Info.m_aGameType, "DDNet"))
|
if (Is64Player(&Info))
|
||||||
{
|
{
|
||||||
pEntry = m_ServerBrowser.Find(pPacket->m_Address);
|
pEntry = m_ServerBrowser.Find(pPacket->m_Address);
|
||||||
if (pEntry)
|
if (pEntry)
|
||||||
|
@ -1831,8 +1831,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
|
||||||
mem_copy(aExtraInfoRemoved, pTmpBuffer3, SnapSize);
|
mem_copy(aExtraInfoRemoved, pTmpBuffer3, SnapSize);
|
||||||
CServerInfo Info;
|
CServerInfo Info;
|
||||||
GetServerInfo(&Info);
|
GetServerInfo(&Info);
|
||||||
bool IsDDNet = str_find_nocase(Info.m_aGameType, "ddracenetw") || str_find_nocase(Info.m_aGameType, "ddnet");
|
if(IsDDNet(&Info))
|
||||||
if(IsDDNet)
|
|
||||||
SnapshotRemoveExtraInfo(aExtraInfoRemoved);
|
SnapshotRemoveExtraInfo(aExtraInfoRemoved);
|
||||||
|
|
||||||
// add snapshot to demo
|
// add snapshot to demo
|
||||||
|
@ -1875,8 +1874,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
|
||||||
|
|
||||||
if(m_RecivedSnapshots[g_Config.m_ClDummy] > 50 && !m_TimeoutCodeSent[g_Config.m_ClDummy])
|
if(m_RecivedSnapshots[g_Config.m_ClDummy] > 50 && !m_TimeoutCodeSent[g_Config.m_ClDummy])
|
||||||
{
|
{
|
||||||
if(str_find_nocase(m_CurrentServerInfo.m_aGameType, "ddracenetw")
|
if(IsDDNet(&m_CurrentServerInfo))
|
||||||
|| str_find_nocase(m_CurrentServerInfo.m_aGameType, "ddnet"))
|
|
||||||
{
|
{
|
||||||
m_TimeoutCodeSent[g_Config.m_ClDummy] = true;
|
m_TimeoutCodeSent[g_Config.m_ClDummy] = true;
|
||||||
CNetMsg_Cl_Say Msg;
|
CNetMsg_Cl_Say Msg;
|
||||||
|
|
|
@ -51,6 +51,11 @@ public:
|
||||||
CClient m_aClients[MAX_CLIENTS];
|
CClient m_aClients[MAX_CLIENTS];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool IsRace(const CServerInfo *pInfo);
|
||||||
|
bool IsDDRace(const CServerInfo *pInfo);
|
||||||
|
bool IsDDNet(const CServerInfo *pInfo);
|
||||||
|
bool Is64Player(const CServerInfo *pInfo);
|
||||||
|
|
||||||
class IServerBrowser : public IInterface
|
class IServerBrowser : public IInterface
|
||||||
{
|
{
|
||||||
MACRO_INTERFACE("serverbrowser", 0)
|
MACRO_INTERFACE("serverbrowser", 0)
|
||||||
|
|
|
@ -25,7 +25,7 @@ void CCamera::OnRender()
|
||||||
{
|
{
|
||||||
CServerInfo Info;
|
CServerInfo Info;
|
||||||
Client()->GetServerInfo(&Info);
|
Client()->GetServerInfo(&Info);
|
||||||
if(!(m_pClient->m_Snap.m_SpecInfo.m_Active || (str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap")) || Client()->State() == IClient::STATE_DEMOPLAYBACK))
|
if(!(m_pClient->m_Snap.m_SpecInfo.m_Active || IsRace(&Info) || Client()->State() == IClient::STATE_DEMOPLAYBACK))
|
||||||
m_Zoom = 1.0f;
|
m_Zoom = 1.0f;
|
||||||
|
|
||||||
// update camera center
|
// update camera center
|
||||||
|
@ -88,7 +88,7 @@ void CCamera::ConZoomPlus(IConsole::IResult *pResult, void *pUserData)
|
||||||
CCamera *pSelf = (CCamera *)pUserData;
|
CCamera *pSelf = (CCamera *)pUserData;
|
||||||
CServerInfo Info;
|
CServerInfo Info;
|
||||||
pSelf->Client()->GetServerInfo(&Info);
|
pSelf->Client()->GetServerInfo(&Info);
|
||||||
if(pSelf->m_pClient->m_Snap.m_SpecInfo.m_Active || (str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap")) || pSelf->Client()->State() == IClient::STATE_DEMOPLAYBACK)
|
if(pSelf->m_pClient->m_Snap.m_SpecInfo.m_Active || IsRace(&Info) || pSelf->Client()->State() == IClient::STATE_DEMOPLAYBACK)
|
||||||
((CCamera *)pUserData)->m_Zoom *= ZoomStep;
|
((CCamera *)pUserData)->m_Zoom *= ZoomStep;
|
||||||
}
|
}
|
||||||
void CCamera::ConZoomMinus(IConsole::IResult *pResult, void *pUserData)
|
void CCamera::ConZoomMinus(IConsole::IResult *pResult, void *pUserData)
|
||||||
|
@ -96,7 +96,7 @@ void CCamera::ConZoomMinus(IConsole::IResult *pResult, void *pUserData)
|
||||||
CCamera *pSelf = (CCamera *)pUserData;
|
CCamera *pSelf = (CCamera *)pUserData;
|
||||||
CServerInfo Info;
|
CServerInfo Info;
|
||||||
pSelf->Client()->GetServerInfo(&Info);
|
pSelf->Client()->GetServerInfo(&Info);
|
||||||
if(pSelf->m_pClient->m_Snap.m_SpecInfo.m_Active || (str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap")) || pSelf->Client()->State() == IClient::STATE_DEMOPLAYBACK)
|
if(pSelf->m_pClient->m_Snap.m_SpecInfo.m_Active || IsRace(&Info) || pSelf->Client()->State() == IClient::STATE_DEMOPLAYBACK)
|
||||||
((CCamera *)pUserData)->m_Zoom *= 1/ZoomStep;
|
((CCamera *)pUserData)->m_Zoom *= 1/ZoomStep;
|
||||||
}
|
}
|
||||||
void CCamera::ConZoomReset(IConsole::IResult *pResult, void *pUserData)
|
void CCamera::ConZoomReset(IConsole::IResult *pResult, void *pUserData)
|
||||||
|
|
|
@ -128,10 +128,8 @@ static void ConKeyInputState(IConsole::IResult *pResult, void *pUserData)
|
||||||
|
|
||||||
CServerInfo Info;
|
CServerInfo Info;
|
||||||
pState->m_pControls->GameClient()->Client()->GetServerInfo(&Info);
|
pState->m_pControls->GameClient()->Client()->GetServerInfo(&Info);
|
||||||
bool IsGameTypeRace = str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap");
|
|
||||||
bool IsGameTypeDDRace = str_find_nocase(Info.m_aGameType, "ddrace") || str_find_nocase(Info.m_aGameType, "mkrace");
|
|
||||||
|
|
||||||
if ((IsGameTypeRace || IsGameTypeDDRace) && pState->m_pControls->GameClient()->m_Snap.m_SpecInfo.m_Active)
|
if ((IsRace(&Info) || IsDDRace(&Info)) && pState->m_pControls->GameClient()->m_Snap.m_SpecInfo.m_Active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_Config.m_ClDummy)
|
if (g_Config.m_ClDummy)
|
||||||
|
@ -146,10 +144,8 @@ static void ConKeyInputCounter(IConsole::IResult *pResult, void *pUserData)
|
||||||
|
|
||||||
CServerInfo Info;
|
CServerInfo Info;
|
||||||
pState->m_pControls->GameClient()->Client()->GetServerInfo(&Info);
|
pState->m_pControls->GameClient()->Client()->GetServerInfo(&Info);
|
||||||
bool IsGameTypeRace = str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap");
|
|
||||||
bool IsGameTypeDDRace = str_find_nocase(Info.m_aGameType, "ddrace") || str_find_nocase(Info.m_aGameType, "mkrace");
|
|
||||||
|
|
||||||
if ((IsGameTypeRace || IsGameTypeDDRace) && pState->m_pControls->GameClient()->m_Snap.m_SpecInfo.m_Active)
|
if ((IsRace(&Info) || IsDDRace(&Info)) && pState->m_pControls->GameClient()->m_Snap.m_SpecInfo.m_Active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int *v;
|
int *v;
|
||||||
|
@ -438,10 +434,8 @@ void CControls::OnRender()
|
||||||
|
|
||||||
CServerInfo Info;
|
CServerInfo Info;
|
||||||
GameClient()->Client()->GetServerInfo(&Info);
|
GameClient()->Client()->GetServerInfo(&Info);
|
||||||
bool IsGameTypeRace = str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap");
|
|
||||||
bool IsGameTypeDDRace = str_find_nocase(Info.m_aGameType, "ddrace") || str_find_nocase(Info.m_aGameType, "mkrace");
|
|
||||||
|
|
||||||
if( g_Config.m_ClAutoswitchWeaponsOutOfAmmo && !IsGameTypeRace && !IsGameTypeDDRace && m_pClient->m_Snap.m_pLocalCharacter )
|
if( g_Config.m_ClAutoswitchWeaponsOutOfAmmo && !IsRace(&Info) && !IsDDRace(&Info) && m_pClient->m_Snap.m_pLocalCharacter )
|
||||||
{
|
{
|
||||||
// Keep track of ammo count, we know weapon ammo only when we switch to that weapon, this is tracked on server and protocol does not track that
|
// Keep track of ammo count, we know weapon ammo only when we switch to that weapon, this is tracked on server and protocol does not track that
|
||||||
m_AmmoCount[m_pClient->m_Snap.m_pLocalCharacter->m_Weapon%NUM_WEAPONS] = m_pClient->m_Snap.m_pLocalCharacter->m_AmmoCount;
|
m_AmmoCount[m_pClient->m_Snap.m_pLocalCharacter->m_Weapon%NUM_WEAPONS] = m_pClient->m_Snap.m_pLocalCharacter->m_AmmoCount;
|
||||||
|
|
|
@ -59,14 +59,12 @@ void CHud::RenderGameTimer()
|
||||||
|
|
||||||
CServerInfo Info;
|
CServerInfo Info;
|
||||||
Client()->GetServerInfo(&Info);
|
Client()->GetServerInfo(&Info);
|
||||||
bool IsGameTypeRace = str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap");
|
|
||||||
bool IsGameTypeDDRace = str_find_nocase(Info.m_aGameType, "ddrace") || str_find_nocase(Info.m_aGameType, "mkrace");
|
|
||||||
|
|
||||||
if(Time <= 0 && g_Config.m_ClShowDecisecs)
|
if(Time <= 0 && g_Config.m_ClShowDecisecs)
|
||||||
str_format(Buf, sizeof(Buf), "00:00.0");
|
str_format(Buf, sizeof(Buf), "00:00.0");
|
||||||
else if(Time <= 0)
|
else if(Time <= 0)
|
||||||
str_format(Buf, sizeof(Buf), "00:00");
|
str_format(Buf, sizeof(Buf), "00:00");
|
||||||
else if(IsGameTypeRace && !IsGameTypeDDRace && m_ServerRecord >= 0)
|
else if(IsRace(&Info) && !IsDDRace(&Info) && m_ServerRecord >= 0)
|
||||||
str_format(Buf, sizeof(Buf), "%02d:%02d", (int)(m_ServerRecord*100)/60, ((int)(m_ServerRecord*100)%60));
|
str_format(Buf, sizeof(Buf), "%02d:%02d", (int)(m_ServerRecord*100)/60, ((int)(m_ServerRecord*100)%60));
|
||||||
else if(g_Config.m_ClShowDecisecs)
|
else if(g_Config.m_ClShowDecisecs)
|
||||||
str_format(Buf, sizeof(Buf), "%02d:%02d.%d", Time/60, Time%60, m_DDRaceTick/10);
|
str_format(Buf, sizeof(Buf), "%02d:%02d.%d", Time/60, Time%60, m_DDRaceTick/10);
|
||||||
|
@ -220,8 +218,7 @@ void CHud::RenderScoreHud()
|
||||||
{
|
{
|
||||||
CServerInfo Info;
|
CServerInfo Info;
|
||||||
Client()->GetServerInfo(&Info);
|
Client()->GetServerInfo(&Info);
|
||||||
bool IsGameTypeRace = str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap");
|
if(IsRace(&Info) && g_Config.m_ClDDRaceScoreBoard)
|
||||||
if(IsGameTypeRace && g_Config.m_ClDDRaceScoreBoard)
|
|
||||||
{
|
{
|
||||||
if (apPlayerInfo[t]->m_Score != -9999)
|
if (apPlayerInfo[t]->m_Score != -9999)
|
||||||
str_format(aScore[t], sizeof(aScore[t]), "%02d:%02d", abs(apPlayerInfo[t]->m_Score)/60, abs(apPlayerInfo[t]->m_Score)%60);
|
str_format(aScore[t], sizeof(aScore[t]), "%02d:%02d", abs(apPlayerInfo[t]->m_Score)/60, abs(apPlayerInfo[t]->m_Score)%60);
|
||||||
|
|
|
@ -75,8 +75,7 @@ void CItems::RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemID)
|
||||||
|
|
||||||
CServerInfo Info;
|
CServerInfo Info;
|
||||||
Client()->GetServerInfo(&Info);
|
Client()->GetServerInfo(&Info);
|
||||||
bool IsDDNet = str_find_nocase(Info.m_aGameType, "ddracenetw") || str_find_nocase(Info.m_aGameType, "ddnet");
|
ExtractInfo(pCurrent, &StartPos, &StartVel, IsDDNet(&Info));
|
||||||
ExtractInfo(pCurrent, &StartPos, &StartVel, IsDDNet);
|
|
||||||
|
|
||||||
vec2 Pos = CalcPos(StartPos, StartVel, Curvature, Speed, Ct);
|
vec2 Pos = CalcPos(StartPos, StartVel, Curvature, Speed, Ct);
|
||||||
vec2 PrevPos = CalcPos(StartPos, StartVel, Curvature, Speed, Ct-0.001f);
|
vec2 PrevPos = CalcPos(StartPos, StartVel, Curvature, Speed, Ct-0.001f);
|
||||||
|
|
|
@ -487,15 +487,12 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
||||||
hsl = vec3(0.00f, 1.0f, 0.75f); // Instagib
|
hsl = vec3(0.00f, 1.0f, 0.75f); // Instagib
|
||||||
else if (str_find_nocase(pItem->m_aGameType, "fng"))
|
else if (str_find_nocase(pItem->m_aGameType, "fng"))
|
||||||
hsl = vec3(0.83f, 1.0f, 0.75f); // FNG
|
hsl = vec3(0.83f, 1.0f, 0.75f); // FNG
|
||||||
else if (str_find_nocase(pItem->m_aGameType, "ddracenetw")
|
else if (IsDDNet(pItem))
|
||||||
|| str_find_nocase(pItem->m_aGameType, "ddnet"))
|
|
||||||
hsl = vec3(0.58f, 1.0f, 0.75f); // DDNet
|
hsl = vec3(0.58f, 1.0f, 0.75f); // DDNet
|
||||||
else if (str_find_nocase(pItem->m_aGameType, "ddrace")
|
else if (IsDDRace(pItem))
|
||||||
|| str_find_nocase(pItem->m_aGameType, "mkrace"))
|
|
||||||
hsl = vec3(0.75f, 1.0f, 0.75f); // DDRace
|
hsl = vec3(0.75f, 1.0f, 0.75f); // DDRace
|
||||||
else if (str_find_nocase(pItem->m_aGameType, "race")
|
else if (IsRace(pItem))
|
||||||
|| !str_comp(pItem->m_aGameType, "FastCap"))
|
hsl = vec3(0.46f, 1.0f, 0.75f); // Race
|
||||||
hsl = vec3(0.46f, 1.0f, 0.75f); // Races
|
|
||||||
|
|
||||||
vec3 rgb = HslToRgb(hsl);
|
vec3 rgb = HslToRgb(hsl);
|
||||||
TextRender()->TextColor(rgb.r, rgb.g, rgb.b, 1.0f);
|
TextRender()->TextColor(rgb.r, rgb.g, rgb.b, 1.0f);
|
||||||
|
@ -894,7 +891,7 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View)
|
||||||
|
|
||||||
if(!pSelectedServer->m_aClients[i].m_Player)
|
if(!pSelectedServer->m_aClients[i].m_Player)
|
||||||
str_copy(aTemp, "SPEC", sizeof(aTemp));
|
str_copy(aTemp, "SPEC", sizeof(aTemp));
|
||||||
else if(str_find_nocase(pSelectedServer->m_aGameType, "race") || str_find_nocase(pSelectedServer->m_aGameType, "fastcap"))
|
else if(IsRace(pSelectedServer))
|
||||||
{
|
{
|
||||||
if(pSelectedServer->m_aClients[i].m_Score == -9999 || pSelectedServer->m_aClients[i].m_Score == 0)
|
if(pSelectedServer->m_aClients[i].m_Score == -9999 || pSelectedServer->m_aClients[i].m_Score == 0)
|
||||||
aTemp[0] = 0;
|
aTemp[0] = 0;
|
||||||
|
|
|
@ -32,7 +32,7 @@ void CScoreboard::ConKeyScoreboard(IConsole::IResult *pResult, void *pUserData)
|
||||||
CServerInfo Info;
|
CServerInfo Info;
|
||||||
|
|
||||||
pSelf->Client()->GetServerInfo(&Info);
|
pSelf->Client()->GetServerInfo(&Info);
|
||||||
pSelf->m_IsGameTypeRace = str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap");
|
pSelf->m_IsGameTypeRace = IsRace(&Info);
|
||||||
pSelf->m_Active = pResult->GetInteger(0) != 0;
|
pSelf->m_Active = pResult->GetInteger(0) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1249,7 +1249,6 @@ void CGameClient::OnPredict()
|
||||||
|
|
||||||
CServerInfo Info;
|
CServerInfo Info;
|
||||||
Client()->GetServerInfo(&Info);
|
Client()->GetServerInfo(&Info);
|
||||||
bool IsRace = str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap");
|
|
||||||
const int MaxProjectiles = 128;
|
const int MaxProjectiles = 128;
|
||||||
class CLocalProjectile PredictedProjectiles[MaxProjectiles];
|
class CLocalProjectile PredictedProjectiles[MaxProjectiles];
|
||||||
int NumProjectiles = 0;
|
int NumProjectiles = 0;
|
||||||
|
@ -1383,7 +1382,7 @@ void CGameClient::OnPredict()
|
||||||
WillFire = true;
|
WillFire = true;
|
||||||
if(!WillFire)
|
if(!WillFire)
|
||||||
break;
|
break;
|
||||||
if(!IsRace && !m_Snap.m_pLocalCharacter->m_AmmoCount && Local->m_ActiveWeapon != WEAPON_HAMMER)
|
if(!IsRace(&Info) && !m_Snap.m_pLocalCharacter->m_AmmoCount && Local->m_ActiveWeapon != WEAPON_HAMMER)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
int ExpectedStartTick = Tick-1;
|
int ExpectedStartTick = Tick-1;
|
||||||
|
|
Loading…
Reference in a new issue