2917: Create ALLOW_X_SKINS game info flag r=heinrich5991 a=def-

To allow server to set any x_ prefixed skin and client won't filter it
out. As requested by Pure_luck for his mod to show players as tanks,
walls, etc. Won't be enabled on DDNet-Servers, thus such skins can be
added where a server modification wants to fine-control what skins are
allowed and can enforce such skins.

Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2020-09-25 21:22:38 +00:00 committed by GitHub
commit c6ade7eeeb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 66 additions and 36 deletions

View file

@ -17,7 +17,11 @@ GameInfoFlags = [
"BUG_DDRACE_INPUT", "BUG_FNG_LASER_RANGE", "BUG_VANILLA_BOUNCE",
"PREDICT_FNG", "PREDICT_DDRACE", "PREDICT_DDRACE_TILES", "PREDICT_VANILLA",
"ENTITIES_DDNET", "ENTITIES_DDRACE", "ENTITIES_RACE", "ENTITIES_FNG",
"ENTITIES_VANILLA", "DONT_MASK_ENTITIES", "ENTITIES_BW",
"ENTITIES_VANILLA", "DONT_MASK_ENTITIES", "ENTITIES_BW"
# Full, use GameInfoFlags2 for more flags
]
GameInfoFlags2 = [
"ALLOW_X_SKINS", "GAMETYPE_CITY",
]
ExPlayerFlags = ["AFK", "PAUSED", "SPEC"]
@ -52,7 +56,7 @@ enum
enum
{
GAMEINFO_CURVERSION=4,
GAMEINFO_CURVERSION=5,
};
'''
@ -74,6 +78,7 @@ Flags = [
Flags("GAMESTATEFLAG", GameStateFlags),
Flags("CHARACTERFLAG", CharacterFlags),
Flags("GAMEINFOFLAG", GameInfoFlags),
Flags("GAMEINFOFLAG2", GameInfoFlags2),
Flags("EXPLAYERFLAG", ExPlayerFlags),
]
@ -236,6 +241,7 @@ Objects = [
NetObjectEx("GameInfoEx", "gameinfo@netobj.ddnet.tw", [
NetIntAny("m_Flags"),
NetIntAny("m_Version"),
NetIntAny("m_Flags2"),
], validate_size=False),
## Events

View file

@ -72,6 +72,7 @@ bool IsFastCap(const CServerInfo *pInfo);
bool IsDDRace(const CServerInfo *pInfo);
bool IsDDNet(const CServerInfo *pInfo);
bool IsBlockWorlds(const CServerInfo *pInfo);
bool IsCity(const CServerInfo *pInfo);
bool Is64Player(const CServerInfo *pInfo);
bool IsPlus(const CServerInfo *pInfo);

View file

@ -48,8 +48,8 @@ bool IsDDRace(const CServerInfo *pInfo)
bool IsBlockInfectionZ(const CServerInfo *pInfo)
{
return str_find_nocase(pInfo->m_aGameType, "blockZ")
|| str_find_nocase(pInfo->m_aGameType, "infectionZ");
return str_find_nocase(pInfo->m_aGameType, "blockz") ||
str_find_nocase(pInfo->m_aGameType, "infectionz");
}
bool IsBlockWorlds(const CServerInfo *pInfo)
@ -58,6 +58,11 @@ bool IsBlockWorlds(const CServerInfo *pInfo)
|| (str_comp_nocase(pInfo->m_aGameType, "bw") == 0);
}
bool IsCity(const CServerInfo *pInfo)
{
return str_find_nocase(pInfo->m_aGameType, "city");
}
bool IsDDNet(const CServerInfo *pInfo)
{
return str_find_nocase(pInfo->m_aGameType, "ddracenet")

View file

@ -996,10 +996,14 @@ void CGameClient::ProcessEvents()
static CGameInfo GetGameInfo(const CNetObj_GameInfoEx *pInfoEx, int InfoExSize, CServerInfo *pFallbackServerInfo)
{
int Version = -1;
if(InfoExSize >= 8)
if(InfoExSize >= 12)
{
Version = pInfoEx->m_Version;
}
else if(InfoExSize >= 8)
{
Version = minimum(pInfoEx->m_Version, 4);
}
else if(InfoExSize >= 4)
{
Version = 0;
@ -1009,12 +1013,18 @@ static CGameInfo GetGameInfo(const CNetObj_GameInfoEx *pInfoEx, int InfoExSize,
{
Flags = pInfoEx->m_Flags;
}
int Flags2 = 0;
if(Version >= 5)
{
Flags2 = pInfoEx->m_Flags2;
}
bool Race;
bool FastCap;
bool FNG;
bool DDRace;
bool DDNet;
bool BlockWorlds;
bool City;
bool Vanilla;
bool Plus;
if(Version < 1)
@ -1025,19 +1035,21 @@ static CGameInfo GetGameInfo(const CNetObj_GameInfoEx *pInfoEx, int InfoExSize,
DDRace = IsDDRace(pFallbackServerInfo);
DDNet = IsDDNet(pFallbackServerInfo);
BlockWorlds = IsBlockWorlds(pFallbackServerInfo);
City = IsCity(pFallbackServerInfo);
Vanilla = IsVanilla(pFallbackServerInfo);
Plus = IsPlus(pFallbackServerInfo);
}
else
{
Race = Flags&GAMEINFOFLAG_GAMETYPE_RACE;
FastCap = Flags&GAMEINFOFLAG_GAMETYPE_FASTCAP;
FNG = Flags&GAMEINFOFLAG_GAMETYPE_FNG;
DDRace = Flags&GAMEINFOFLAG_GAMETYPE_DDRACE;
DDNet = Flags&GAMEINFOFLAG_GAMETYPE_DDNET;
BlockWorlds = Flags&GAMEINFOFLAG_GAMETYPE_BLOCK_WORLDS;
Vanilla = Flags&GAMEINFOFLAG_GAMETYPE_VANILLA;
Plus = Flags&GAMEINFOFLAG_GAMETYPE_PLUS;
Race = Flags & GAMEINFOFLAG_GAMETYPE_RACE;
FastCap = Flags & GAMEINFOFLAG_GAMETYPE_FASTCAP;
FNG = Flags & GAMEINFOFLAG_GAMETYPE_FNG;
DDRace = Flags & GAMEINFOFLAG_GAMETYPE_DDRACE;
DDNet = Flags & GAMEINFOFLAG_GAMETYPE_DDNET;
BlockWorlds = Flags & GAMEINFOFLAG_GAMETYPE_BLOCK_WORLDS;
Vanilla = Flags & GAMEINFOFLAG_GAMETYPE_VANILLA;
Plus = Flags & GAMEINFOFLAG_GAMETYPE_PLUS;
City = Version >= 5 && Flags2 & GAMEINFOFLAG2_GAMETYPE_CITY;
// Ensure invariants upheld by the server info parsing business.
DDRace = DDRace || DDNet;
@ -1050,9 +1062,9 @@ static CGameInfo GetGameInfo(const CNetObj_GameInfoEx *pInfoEx, int InfoExSize,
Info.m_UnlimitedAmmo = Race;
Info.m_DDRaceRecordMessage = DDRace && !DDNet;
Info.m_RaceRecordMessage = DDNet || (Race && !DDRace);
Info.m_AllowEyeWheel = DDRace || BlockWorlds || Plus;
Info.m_AllowEyeWheel = DDRace || BlockWorlds || City || Plus;
Info.m_AllowHookColl = DDRace;
Info.m_AllowZoom = Race || BlockWorlds;
Info.m_AllowZoom = Race || BlockWorlds || City;
Info.m_BugDDRaceGhost = DDRace;
Info.m_BugDDRaceInput = DDRace;
Info.m_BugFNGLaserRange = FNG;
@ -1069,6 +1081,7 @@ static CGameInfo GetGameInfo(const CNetObj_GameInfoEx *pInfoEx, int InfoExSize,
Info.m_EntitiesBW = BlockWorlds;
Info.m_Race = Race;
Info.m_DontMaskEntities = !DDNet;
Info.m_AllowXSkins = false;
if(Version >= 0)
{
@ -1102,11 +1115,14 @@ static CGameInfo GetGameInfo(const CNetObj_GameInfoEx *pInfoEx, int InfoExSize,
Info.m_Race = Flags&GAMEINFOFLAG_RACE;
Info.m_DontMaskEntities = Flags&GAMEINFOFLAG_DONT_MASK_ENTITIES;
}
if (Version >= 4)
if(Version >= 4)
{
Info.m_EntitiesBW = Flags&GAMEINFOFLAG_ENTITIES_BW;
}
if(Version >= 5)
{
Info.m_AllowXSkins = Flags2 & GAMEINFOFLAG2_ALLOW_X_SKINS;
}
return Info;
}
@ -1199,7 +1215,7 @@ void CGameClient::OnNewSnapshot()
pClient->m_ColorFeet = pInfo->m_ColorFeet;
// prepare the info
if(pClient->m_aSkinName[0] == 'x' || pClient->m_aSkinName[1] == '_')
if(!m_GameInfo.m_AllowXSkins && (pClient->m_aSkinName[0] == 'x' || pClient->m_aSkinName[1] == '_'))
str_copy(pClient->m_aSkinName, "default", 64);
pClient->m_SkinInfo.m_ColorBody = color_cast<ColorRGBA>(ColorHSLA(pClient->m_ColorBody).UnclampLighting());

View file

@ -53,6 +53,7 @@ public:
bool m_Race;
bool m_DontMaskEntities;
bool m_AllowXSkins;
};
class CGameClient : public IGameClient

View file

@ -539,24 +539,25 @@ void IGameController::Snap(int SnappingClient)
if(!pGameInfoEx)
return;
pGameInfoEx->m_Flags = 0
| GAMEINFOFLAG_TIMESCORE
| GAMEINFOFLAG_GAMETYPE_RACE
| GAMEINFOFLAG_GAMETYPE_DDRACE
| GAMEINFOFLAG_GAMETYPE_DDNET
| GAMEINFOFLAG_UNLIMITED_AMMO
| GAMEINFOFLAG_RACE_RECORD_MESSAGE
| GAMEINFOFLAG_ALLOW_EYE_WHEEL
| GAMEINFOFLAG_ALLOW_HOOK_COLL
| GAMEINFOFLAG_ALLOW_ZOOM
| GAMEINFOFLAG_BUG_DDRACE_GHOST
| GAMEINFOFLAG_BUG_DDRACE_INPUT
| GAMEINFOFLAG_PREDICT_DDRACE
| GAMEINFOFLAG_PREDICT_DDRACE_TILES
| GAMEINFOFLAG_ENTITIES_DDNET
| GAMEINFOFLAG_ENTITIES_DDRACE
| GAMEINFOFLAG_ENTITIES_RACE
| GAMEINFOFLAG_RACE;
pGameInfoEx->m_Flags =
GAMEINFOFLAG_TIMESCORE |
GAMEINFOFLAG_GAMETYPE_RACE |
GAMEINFOFLAG_GAMETYPE_DDRACE |
GAMEINFOFLAG_GAMETYPE_DDNET |
GAMEINFOFLAG_UNLIMITED_AMMO |
GAMEINFOFLAG_RACE_RECORD_MESSAGE |
GAMEINFOFLAG_ALLOW_EYE_WHEEL |
GAMEINFOFLAG_ALLOW_HOOK_COLL |
GAMEINFOFLAG_ALLOW_ZOOM |
GAMEINFOFLAG_BUG_DDRACE_GHOST |
GAMEINFOFLAG_BUG_DDRACE_INPUT |
GAMEINFOFLAG_PREDICT_DDRACE |
GAMEINFOFLAG_PREDICT_DDRACE_TILES |
GAMEINFOFLAG_ENTITIES_DDNET |
GAMEINFOFLAG_ENTITIES_DDRACE |
GAMEINFOFLAG_ENTITIES_RACE |
GAMEINFOFLAG_RACE;
pGameInfoEx->m_Flags2 = 0;
pGameInfoEx->m_Version = GAMEINFO_CURVERSION;
if(Server()->IsSixup(SnappingClient))