Rename all variables for strict camel-casing of abbreviations

This is the strict version, ID → Id, UI → Ui, except DDNet which stays
DDNet.

This would fix #7750.

Done using a naive rename script (for bash, use `shopt -s globstar`):

```fish
sed -i \
	-e 's/\([a-z]_\?\)ID/\1Id/g' \
	-e 's/\([^ ]\)\<UI\>/\1Ui/g' \
	-e 's/UI()/Ui()/g' \
	-e 's/\<CUI\>/CUi/g' \
	-e 's/\([\ta-z.(&]\|[,=|] \)ID\>/\1Id/g' \
	-e 's/\<ID\>\([^ ").]\)/Id\1/g' \
	-e 's/\<ID\([0-9]\)/Id\1/g' \
	-e 's/\<ID\>\( [<=>:+*/-]\)/Id\1/g' \
	-e 's/int ID/int Id/g' \
	-e 's/\([a-z]_\?\)GPU/\1Gpu/g' \
	-e 's/\([a-z]_\?\)IP/\1Ip/g' \
	-e 's/\([a-z]_\?\)CID/\1Cid/g' \
	-e 's/\([a-z]_\?\)MySQL/\1Mysql/g' \
	-e 's/MySql/Mysql/g' \
	-e 's/\([a-xz]_\?\)SQL/\1Sql/g' \
	-e 's/DPMode/DpMode/g' \
	-e 's/TTWGraphics/TTwGraphics/g' \
	\
	-e 's/Ipointer/IPointer/g' \
	-e 's/\.vendorId/.vendorID/g' \
	-e 's/\.windowId/.windowID/g' \
	-e 's/SDL_GetWindowFromId/SDL_GetWindowFromID/g' \
	-e 's/SDL_AudioDeviceId/SDL_AudioDeviceID/g' \
	-e 's/SDL_JoystickId/SDL_JoystickID/g' \
	-e 's/SDL_JoystickInstanceId/SDL_JoystickInstanceID/g' \
	-e 's/AVCodecId/AVCodecID/g' \
	src/**/*.cpp src/**/*.h {datasrc,scripts}/**/*.py
git checkout -- src/engine/external
```

I like this option because it presents clear rules.

Still needs fixups because of the naive replacement, I'd do this if we
want this merged.
This commit is contained in:
heinrich5991 2024-03-05 15:44:09 +01:00
parent ca9f5dfcbe
commit 17402cc43f
221 changed files with 5945 additions and 5945 deletions

View file

@ -4,12 +4,12 @@ def only(x):
return list(x)[0] return list(x)[0]
GlobalIdCounter = 0 GlobalIdCounter = 0
def GetID(): def GetId():
global GlobalIdCounter global GlobalIdCounter
GlobalIdCounter += 1 GlobalIdCounter += 1
return GlobalIdCounter return GlobalIdCounter
def GetUID(): def GetUID():
return f"x{int(GetID())}" return f"x{int(GetId())}"
def FixCasing(Str): def FixCasing(Str):
NewStr = "" NewStr = ""
@ -36,7 +36,7 @@ class BaseType:
def __init__(self, type_name): def __init__(self, type_name):
self._type_name = type_name self._type_name = type_name
self._target_name = "INVALID" self._target_name = "INVALID"
self._id = GetID() # this is used to remember what order the members have in structures etc self._id = GetId() # this is used to remember what order the members have in structures etc
def Identifier(self): def Identifier(self):
return "x"+str(self._id) return "x"+str(self._id)
@ -44,7 +44,7 @@ class BaseType:
return self._target_name return self._target_name
def TypeName(self): def TypeName(self):
return self._type_name return self._type_name
def ID(self): def Id(self):
return self._id return self._id
def EmitDeclaration(self, name): def EmitDeclaration(self, name):
@ -65,7 +65,7 @@ class Struct(BaseType):
BaseType.__init__(self, type_name) BaseType.__init__(self, type_name)
def Members(self): def Members(self):
def sorter(a): def sorter(a):
return a.var.ID() return a.var.Id()
m = [] m = []
for name, value in self.__dict__.items(): for name, value in self.__dict__.items():
if name[0] == "_": if name[0] == "_":
@ -226,7 +226,7 @@ class NetObject:
lines += [f"struct {self.struct_name} : public {self.base_struct_name}", "{"] lines += [f"struct {self.struct_name} : public {self.base_struct_name}", "{"]
else: else:
lines += [f"struct {self.struct_name}", "{"] lines += [f"struct {self.struct_name}", "{"]
lines += [f"\tstatic constexpr int ms_MsgID = {self.enum_name};"] lines += [f"\tstatic constexpr int ms_MsgId = {self.enum_name};"]
for v in self.variables: for v in self.variables:
lines += ["\t"+line for line in v.emit_declaration()] lines += ["\t"+line for line in v.emit_declaration()]
lines += ["};"] lines += ["};"]

View file

@ -208,7 +208,7 @@ Objects = [
NetObject("PlayerInfo", [ NetObject("PlayerInfo", [
NetIntRange("m_Local", 0, 1), NetIntRange("m_Local", 0, 1),
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", 0, 'MAX_CLIENTS-1'),
NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'), NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'),
NetIntAny("m_Score"), NetIntAny("m_Score"),
@ -236,7 +236,7 @@ Objects = [
]), ]),
NetObject("SpectatorInfo", [ NetObject("SpectatorInfo", [
NetIntRange("m_SpectatorID", 'SPEC_FREEVIEW', 'MAX_CLIENTS-1'), NetIntRange("m_SpectatorId", 'SPEC_FREEVIEW', 'MAX_CLIENTS-1'),
NetIntAny("m_X"), NetIntAny("m_X"),
NetIntAny("m_Y"), NetIntAny("m_Y"),
]), ]),
@ -250,7 +250,7 @@ Objects = [
NetTick("m_FreezeEnd", 0), NetTick("m_FreezeEnd", 0),
NetIntRange("m_Jumps", -1, 255, 2), NetIntRange("m_Jumps", -1, 255, 2),
NetIntAny("m_TeleCheckpoint", -1), NetIntAny("m_TeleCheckpoint", -1),
NetIntRange("m_StrongWeakID", 0, 'MAX_CLIENTS-1', 0), NetIntRange("m_StrongWeakId", 0, 'MAX_CLIENTS-1', 0),
# New data fields for jump display, freeze bar and ninja bar # New data fields for jump display, freeze bar and ninja bar
# Default values indicate that these values should not be used # Default values indicate that these values should not be used
@ -331,15 +331,15 @@ Objects = [
NetEvent("HammerHit:Common", []), NetEvent("HammerHit:Common", []),
NetEvent("Death:Common", [ NetEvent("Death:Common", [
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", 0, 'MAX_CLIENTS-1'),
]), ]),
NetEvent("SoundGlobal:Common", [ #TODO 0.7: remove me NetEvent("SoundGlobal:Common", [ #TODO 0.7: remove me
NetIntRange("m_SoundID", 0, 'NUM_SOUNDS-1'), NetIntRange("m_SoundId", 0, 'NUM_SOUNDS-1'),
]), ]),
NetEvent("SoundWorld:Common", [ NetEvent("SoundWorld:Common", [
NetIntRange("m_SoundID", 0, 'NUM_SOUNDS-1'), NetIntRange("m_SoundId", 0, 'NUM_SOUNDS-1'),
]), ]),
NetEvent("DamageInd:Common", [ NetEvent("DamageInd:Common", [
@ -386,7 +386,7 @@ Messages = [
NetMessage("Sv_Chat", [ NetMessage("Sv_Chat", [
NetIntRange("m_Team", -2, 3), NetIntRange("m_Team", -2, 3),
NetIntRange("m_ClientID", -1, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", -1, 'MAX_CLIENTS-1'),
NetStringHalfStrict("m_pMessage"), NetStringHalfStrict("m_pMessage"),
]), ]),
@ -398,7 +398,7 @@ Messages = [
]), ]),
NetMessage("Sv_SoundGlobal", [ NetMessage("Sv_SoundGlobal", [
NetIntRange("m_SoundID", 0, 'NUM_SOUNDS-1'), NetIntRange("m_SoundId", 0, 'NUM_SOUNDS-1'),
]), ]),
NetMessage("Sv_TuneParams", []), NetMessage("Sv_TuneParams", []),
@ -410,7 +410,7 @@ Messages = [
]), ]),
NetMessage("Sv_Emoticon", [ NetMessage("Sv_Emoticon", [
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", 0, 'MAX_CLIENTS-1'),
NetIntRange("m_Emoticon", 0, 'NUM_EMOTICONS-1'), NetIntRange("m_Emoticon", 0, 'NUM_EMOTICONS-1'),
]), ]),
@ -458,7 +458,7 @@ Messages = [
]), ]),
NetMessage("Cl_SetSpectatorMode", [ NetMessage("Cl_SetSpectatorMode", [
NetIntRange("m_SpectatorID", 'SPEC_FREEVIEW', 'MAX_CLIENTS-1'), NetIntRange("m_SpectatorId", 'SPEC_FREEVIEW', 'MAX_CLIENTS-1'),
]), ]),
NetMessage("Cl_StartInfo", [ NetMessage("Cl_StartInfo", [
@ -556,7 +556,7 @@ Messages = [
]), ]),
NetMessageEx("Sv_RaceFinish", "racefinish@netmsg.ddnet.org", [ NetMessageEx("Sv_RaceFinish", "racefinish@netmsg.ddnet.org", [
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", 0, 'MAX_CLIENTS-1'),
NetIntAny("m_Time"), NetIntAny("m_Time"),
NetIntAny("m_Diff"), NetIntAny("m_Diff"),
NetBool("m_RecordPersonal"), NetBool("m_RecordPersonal"),

View file

@ -4,12 +4,12 @@ def only(x):
return list(x)[0] return list(x)[0]
GlobalIdCounter = 0 GlobalIdCounter = 0
def GetID(): def GetId():
global GlobalIdCounter global GlobalIdCounter
GlobalIdCounter += 1 GlobalIdCounter += 1
return GlobalIdCounter return GlobalIdCounter
def GetUID(): def GetUID():
return f"x{int(GetID())}" return f"x{int(GetId())}"
def FixCasing(Str): def FixCasing(Str):
NewStr = "" NewStr = ""
@ -36,7 +36,7 @@ class BaseType:
def __init__(self, type_name): def __init__(self, type_name):
self._type_name = type_name self._type_name = type_name
self._target_name = "INVALID" self._target_name = "INVALID"
self._id = GetID() # this is used to remember what order the members have in structures etc self._id = GetId() # this is used to remember what order the members have in structures etc
def Identifier(self): def Identifier(self):
return "x"+str(self._id) return "x"+str(self._id)
@ -44,7 +44,7 @@ class BaseType:
return self._target_name return self._target_name
def TypeName(self): def TypeName(self):
return self._type_name return self._type_name
def ID(self): def Id(self):
return self._id return self._id
def EmitDeclaration(self, name): def EmitDeclaration(self, name):
@ -65,7 +65,7 @@ class Struct(BaseType):
BaseType.__init__(self, type_name) BaseType.__init__(self, type_name)
def Members(self): def Members(self):
def sorter(a): def sorter(a):
return a.var.ID() return a.var.Id()
m = [] m = []
for name, value in self.__dict__.items(): for name, value in self.__dict__.items():
if name[0] == "_": if name[0] == "_":
@ -229,7 +229,7 @@ class NetObject:
else: else:
lines = [f"struct {self.struct_name}", "{"] lines = [f"struct {self.struct_name}", "{"]
lines += ["\tusing is_sixup = char;"] lines += ["\tusing is_sixup = char;"]
lines += [f"\tstatic constexpr int ms_MsgID = {self.enum_name};"] lines += [f"\tstatic constexpr int ms_MsgId = {self.enum_name};"]
for v in self.variables: for v in self.variables:
lines += ["\t"+line for line in v.emit_declaration()] lines += ["\t"+line for line in v.emit_declaration()]
lines += ["};"] lines += ["};"]

View file

@ -12,7 +12,7 @@ GameStateFlags = Flags("GAMESTATEFLAG", ["WARMUP", "SUDDENDEATH", "ROUNDOVER", "
CoreEventFlags = Flags("COREEVENTFLAG", ["GROUND_JUMP", "AIR_JUMP", "HOOK_ATTACH_PLAYER", "HOOK_ATTACH_GROUND", "HOOK_HIT_NOHOOK"]) CoreEventFlags = Flags("COREEVENTFLAG", ["GROUND_JUMP", "AIR_JUMP", "HOOK_ATTACH_PLAYER", "HOOK_ATTACH_GROUND", "HOOK_HIT_NOHOOK"])
RaceFlags = Flags("RACEFLAG", ["HIDE_KILLMSG", "FINISHMSG_AS_CHAT", "KEEP_WANTED_WEAPON"]) RaceFlags = Flags("RACEFLAG", ["HIDE_KILLMSG", "FINISHMSG_AS_CHAT", "KEEP_WANTED_WEAPON"])
GameMsgIDs = Enum("GAMEMSG", ["TEAM_SWAP", "SPEC_INVALIDID", "TEAM_SHUFFLE", "TEAM_BALANCE", "CTF_DROP", "CTF_RETURN", GameMsgIds = Enum("GAMEMSG", ["TEAM_SWAP", "SPEC_INVALIDID", "TEAM_SHUFFLE", "TEAM_BALANCE", "CTF_DROP", "CTF_RETURN",
"TEAM_ALL", "TEAM_BALANCE_VICTIM", "CTF_GRAB", "TEAM_ALL", "TEAM_BALANCE_VICTIM", "CTF_GRAB",
@ -61,7 +61,7 @@ Enums = [
Emoticons, Emoticons,
Votes, Votes,
ChatModes, ChatModes,
GameMsgIDs, GameMsgIds,
] ]
Flags = [ Flags = [
@ -180,7 +180,7 @@ Objects = [
NetObject("SpectatorInfo", [ NetObject("SpectatorInfo", [
NetIntRange("m_SpecMode", 0, 'NUM_SPECMODES-1'), NetIntRange("m_SpecMode", 0, 'NUM_SPECMODES-1'),
NetIntRange("m_SpectatorID", -1, 'MAX_CLIENTS-1'), NetIntRange("m_SpectatorId", -1, 'MAX_CLIENTS-1'),
NetIntAny("m_X"), NetIntAny("m_X"),
NetIntAny("m_Y"), NetIntAny("m_Y"),
]), ]),
@ -229,15 +229,15 @@ Objects = [
NetEvent("HammerHit:Common", []), NetEvent("HammerHit:Common", []),
NetEvent("Death:Common", [ NetEvent("Death:Common", [
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", 0, 'MAX_CLIENTS-1'),
]), ]),
NetEvent("SoundWorld:Common", [ NetEvent("SoundWorld:Common", [
NetIntRange("m_SoundID", 0, 'NUM_SOUNDS-1'), NetIntRange("m_SoundId", 0, 'NUM_SOUNDS-1'),
]), ]),
NetEvent("Damage:Common", [ # Unused yet NetEvent("Damage:Common", [ # Unused yet
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", 0, 'MAX_CLIENTS-1'),
NetIntAny("m_Angle"), NetIntAny("m_Angle"),
NetIntRange("m_HealthAmount", 0, 9), NetIntRange("m_HealthAmount", 0, 9),
NetIntRange("m_ArmorAmount", 0, 9), NetIntRange("m_ArmorAmount", 0, 9),
@ -270,13 +270,13 @@ Messages = [
NetMessage("Sv_Chat", [ NetMessage("Sv_Chat", [
NetIntRange("m_Mode", 0, 'NUM_CHATS-1'), NetIntRange("m_Mode", 0, 'NUM_CHATS-1'),
NetIntRange("m_ClientID", -1, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", -1, 'MAX_CLIENTS-1'),
NetIntRange("m_TargetID", -1, 'MAX_CLIENTS-1'), NetIntRange("m_TargetId", -1, 'MAX_CLIENTS-1'),
NetStringStrict("m_pMessage"), NetStringStrict("m_pMessage"),
]), ]),
NetMessage("Sv_Team", [ NetMessage("Sv_Team", [
NetIntRange("m_ClientID", -1, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", -1, 'MAX_CLIENTS-1'),
NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'), NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'),
NetBool("m_Silent"), NetBool("m_Silent"),
NetTick("m_CooldownTick"), NetTick("m_CooldownTick"),
@ -298,7 +298,7 @@ Messages = [
]), ]),
NetMessage("Sv_Emoticon", [ NetMessage("Sv_Emoticon", [
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", 0, 'MAX_CLIENTS-1'),
NetEnum("m_Emoticon", Emoticons), NetEnum("m_Emoticon", Emoticons),
]), ]),
@ -315,7 +315,7 @@ Messages = [
]), ]),
NetMessage("Sv_VoteSet", [ NetMessage("Sv_VoteSet", [
NetIntRange("m_ClientID", -1, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", -1, 'MAX_CLIENTS-1'),
NetEnum("m_Type", Votes), NetEnum("m_Type", Votes),
NetIntRange("m_Timeout", 0, 60), NetIntRange("m_Timeout", 0, 60),
NetStringStrict("m_pDescription"), NetStringStrict("m_pDescription"),
@ -339,7 +339,7 @@ Messages = [
]), ]),
NetMessage("Sv_ClientInfo", [ NetMessage("Sv_ClientInfo", [
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", 0, 'MAX_CLIENTS-1'),
NetBool("m_Local"), NetBool("m_Local"),
NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'), NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'),
NetStringStrict("m_pName"), NetStringStrict("m_pName"),
@ -362,7 +362,7 @@ Messages = [
]), ]),
NetMessage("Sv_ClientDrop", [ NetMessage("Sv_ClientDrop", [
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", 0, 'MAX_CLIENTS-1'),
NetStringStrict("m_pReason"), NetStringStrict("m_pReason"),
NetBool("m_Silent"), NetBool("m_Silent"),
]), ]),
@ -372,13 +372,13 @@ Messages = [
## Demo messages ## Demo messages
NetMessage("De_ClientEnter", [ NetMessage("De_ClientEnter", [
NetStringStrict("m_pName"), NetStringStrict("m_pName"),
NetIntRange("m_ClientID", -1, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", -1, 'MAX_CLIENTS-1'),
NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'), NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'),
]), ]),
NetMessage("De_ClientLeave", [ NetMessage("De_ClientLeave", [
NetStringStrict("m_pName"), NetStringStrict("m_pName"),
NetIntRange("m_ClientID", -1, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", -1, 'MAX_CLIENTS-1'),
NetStringStrict("m_pReason"), NetStringStrict("m_pReason"),
]), ]),
@ -395,7 +395,7 @@ Messages = [
NetMessage("Cl_SetSpectatorMode", [ NetMessage("Cl_SetSpectatorMode", [
NetIntRange("m_SpecMode", 0, 'NUM_SPECMODES-1'), NetIntRange("m_SpecMode", 0, 'NUM_SPECMODES-1'),
NetIntRange("m_SpectatorID", -1, 'MAX_CLIENTS-1'), NetIntRange("m_SpectatorId", -1, 'MAX_CLIENTS-1'),
]), ]),
NetMessage("Cl_StartInfo", [ NetMessage("Cl_StartInfo", [
@ -428,7 +428,7 @@ Messages = [
# todo 0.8: move up # todo 0.8: move up
NetMessage("Sv_SkinChange", [ NetMessage("Sv_SkinChange", [
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", 0, 'MAX_CLIENTS-1'),
NetArray(NetStringStrict("m_apSkinPartNames"), 6), NetArray(NetStringStrict("m_apSkinPartNames"), 6),
NetArray(NetBool("m_aUseCustomColors"), 6), NetArray(NetBool("m_aUseCustomColors"), 6),
NetArray(NetIntAny("m_aSkinPartColors"), 6), NetArray(NetIntAny("m_aSkinPartColors"), 6),
@ -442,7 +442,7 @@ Messages = [
## Race ## Race
NetMessage("Sv_RaceFinish", [ NetMessage("Sv_RaceFinish", [
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'), NetIntRange("m_ClientId", 0, 'MAX_CLIENTS-1'),
NetIntRange("m_Time", -1, 'max_int'), NetIntRange("m_Time", -1, 'max_int'),
NetIntAny("m_Diff"), NetIntAny("m_Diff"),
NetBool("m_RecordPersonal"), NetBool("m_RecordPersonal"),

View file

@ -63,13 +63,13 @@ def main():
"Time FLOAT DEFAULT 0, " "Time FLOAT DEFAULT 0, "
"Server CHAR(4), " + "Server CHAR(4), " +
"".join(f"cp{i + 1} FLOAT DEFAULT 0, " for i in range(25)) + "".join(f"cp{i + 1} FLOAT DEFAULT 0, " for i in range(25)) +
"GameID VARCHAR(64), " "GameId VARCHAR(64), "
"DDNet7 BOOL DEFAULT FALSE" "DDNet7 BOOL DEFAULT FALSE"
");") ");")
c.executemany( c.executemany(
"INSERT INTO record_race (Map, Name, Time, Server, " + "INSERT INTO record_race (Map, Name, Time, Server, " +
"".join(f"cp{i + 1}, " for i in range(25)) + "".join(f"cp{i + 1}, " for i in range(25)) +
"GameID, DDNet7) " + "GameId, DDNet7) " +
f"VALUES ({','.join('?' * 31)})", f"VALUES ({','.join('?' * 31)})",
[(map, r.name, float(r.time), "TEXT", *[float(c) for c in r.checkpoints], None, False) for map, record in records.items() for r in record] [(map, r.name, float(r.time), "TEXT", *[float(c) for c in r.checkpoints], None, False) for map, record in records.items() for r in record]
) )

View file

@ -87,10 +87,10 @@ struct CAntibotData
int64_t m_Now; int64_t m_Now;
int64_t m_Freq; int64_t m_Freq;
void (*m_pfnKick)(int ClientID, const char *pMessage, void *pUser); void (*m_pfnKick)(int ClientId, const char *pMessage, void *pUser);
void (*m_pfnLog)(const char *pMessage, void *pUser); void (*m_pfnLog)(const char *pMessage, void *pUser);
void (*m_pfnReport)(int ClientID, const char *pMessage, void *pUser); void (*m_pfnReport)(int ClientId, const char *pMessage, void *pUser);
void (*m_pfnSend)(int ClientID, const void *pData, int DataSize, int Flags, void *pUser); void (*m_pfnSend)(int ClientId, const void *pData, int DataSize, int Flags, void *pUser);
void (*m_pfnTeehistorian)(const void *pData, int DataSize, void *pUser); void (*m_pfnTeehistorian)(const void *pData, int DataSize, void *pUser);
void *m_pUser; void *m_pUser;
}; };

View file

@ -17,23 +17,23 @@ ANTIBOTAPI void AntibotRoundEnd(void);
ANTIBOTAPI void AntibotUpdateData(void); ANTIBOTAPI void AntibotUpdateData(void);
ANTIBOTAPI void AntibotDestroy(void); ANTIBOTAPI void AntibotDestroy(void);
ANTIBOTAPI void AntibotConsoleCommand(const char *pCommand); ANTIBOTAPI void AntibotConsoleCommand(const char *pCommand);
ANTIBOTAPI void AntibotOnPlayerInit(int ClientID); ANTIBOTAPI void AntibotOnPlayerInit(int ClientId);
ANTIBOTAPI void AntibotOnPlayerDestroy(int ClientID); ANTIBOTAPI void AntibotOnPlayerDestroy(int ClientId);
ANTIBOTAPI void AntibotOnSpawn(int ClientID); ANTIBOTAPI void AntibotOnSpawn(int ClientId);
ANTIBOTAPI void AntibotOnHammerFireReloading(int ClientID); ANTIBOTAPI void AntibotOnHammerFireReloading(int ClientId);
ANTIBOTAPI void AntibotOnHammerFire(int ClientID); ANTIBOTAPI void AntibotOnHammerFire(int ClientId);
ANTIBOTAPI void AntibotOnHammerHit(int ClientID, int TargetID); ANTIBOTAPI void AntibotOnHammerHit(int ClientId, int TargetId);
ANTIBOTAPI void AntibotOnDirectInput(int ClientID); ANTIBOTAPI void AntibotOnDirectInput(int ClientId);
ANTIBOTAPI void AntibotOnCharacterTick(int ClientID); ANTIBOTAPI void AntibotOnCharacterTick(int ClientId);
ANTIBOTAPI void AntibotOnHookAttach(int ClientID, bool Player); ANTIBOTAPI void AntibotOnHookAttach(int ClientId, bool Player);
ANTIBOTAPI void AntibotOnEngineTick(void); ANTIBOTAPI void AntibotOnEngineTick(void);
ANTIBOTAPI void AntibotOnEngineClientJoin(int ClientID, bool Sixup); ANTIBOTAPI void AntibotOnEngineClientJoin(int ClientId, bool Sixup);
ANTIBOTAPI void AntibotOnEngineClientDrop(int ClientID, const char *pReason); ANTIBOTAPI void AntibotOnEngineClientDrop(int ClientId, const char *pReason);
// Returns true if the message shouldn't be processed by the server. // Returns true if the message shouldn't be processed by the server.
ANTIBOTAPI bool AntibotOnEngineClientMessage(int ClientID, const void *pData, int Size, int Flags); ANTIBOTAPI bool AntibotOnEngineClientMessage(int ClientId, const void *pData, int Size, int Flags);
ANTIBOTAPI bool AntibotOnEngineServerMessage(int ClientID, const void *pData, int Size, int Flags); ANTIBOTAPI bool AntibotOnEngineServerMessage(int ClientId, const void *pData, int Size, int Flags);
// Returns true if the server should simulate receiving a client message. // Returns true if the server should simulate receiving a client message.
ANTIBOTAPI bool AntibotOnEngineSimulateClientMessage(int *pClientID, void *pBuffer, int BufferSize, int *pOutSize, int *pFlags); ANTIBOTAPI bool AntibotOnEngineSimulateClientMessage(int *pClientId, void *pBuffer, int BufferSize, int *pOutSize, int *pFlags);
} }
#endif // ANTIBOT_ANTIBOT_INTERFACE_H #endif // ANTIBOT_ANTIBOT_INTERFACE_H

View file

@ -32,19 +32,19 @@ void AntibotConsoleCommand(const char *pCommand)
g_pData->m_pfnLog("unknown command", g_pData->m_pUser); g_pData->m_pfnLog("unknown command", g_pData->m_pUser);
} }
} }
void AntibotOnPlayerInit(int /*ClientID*/) {} void AntibotOnPlayerInit(int /*ClientId*/) {}
void AntibotOnPlayerDestroy(int /*ClientID*/) {} void AntibotOnPlayerDestroy(int /*ClientId*/) {}
void AntibotOnSpawn(int /*ClientID*/) {} void AntibotOnSpawn(int /*ClientId*/) {}
void AntibotOnHammerFireReloading(int /*ClientID*/) {} void AntibotOnHammerFireReloading(int /*ClientId*/) {}
void AntibotOnHammerFire(int /*ClientID*/) {} void AntibotOnHammerFire(int /*ClientId*/) {}
void AntibotOnHammerHit(int /*ClientID*/, int /*TargetID*/) {} void AntibotOnHammerHit(int /*ClientId*/, int /*TargetId*/) {}
void AntibotOnDirectInput(int /*ClientID*/) {} void AntibotOnDirectInput(int /*ClientId*/) {}
void AntibotOnCharacterTick(int /*ClientID*/) {} void AntibotOnCharacterTick(int /*ClientId*/) {}
void AntibotOnHookAttach(int /*ClientID*/, bool /*Player*/) {} void AntibotOnHookAttach(int /*ClientId*/, bool /*Player*/) {}
void AntibotOnEngineTick(void) {} void AntibotOnEngineTick(void) {}
void AntibotOnEngineClientJoin(int /*ClientID*/, bool /*Sixup*/) {} void AntibotOnEngineClientJoin(int /*ClientId*/, bool /*Sixup*/) {}
void AntibotOnEngineClientDrop(int /*ClientID*/, const char * /*pReason*/) {} void AntibotOnEngineClientDrop(int /*ClientId*/, const char * /*pReason*/) {}
bool AntibotOnEngineClientMessage(int /*ClientID*/, const void * /*pData*/, int /*Size*/, int /*Flags*/) { return false; } bool AntibotOnEngineClientMessage(int /*ClientId*/, const void * /*pData*/, int /*Size*/, int /*Flags*/) { return false; }
bool AntibotOnEngineServerMessage(int /*ClientID*/, const void * /*pData*/, int /*Size*/, int /*Flags*/) { return false; } bool AntibotOnEngineServerMessage(int /*ClientId*/, const void * /*pData*/, int /*Size*/, int /*Flags*/) { return false; }
bool AntibotOnEngineSimulateClientMessage(int * /*pClientID*/, void * /*pBuffer*/, int /*BufferSize*/, int * /*pOutSize*/, int * /*pFlags*/) { return false; } bool AntibotOnEngineSimulateClientMessage(int * /*pClientId*/, void * /*pBuffer*/, int /*BufferSize*/, int * /*pOutSize*/, int * /*pFlags*/) { return false; }
} }

View file

@ -11,15 +11,15 @@ public:
virtual void RoundEnd() = 0; virtual void RoundEnd() = 0;
// Hooks // Hooks
virtual void OnPlayerInit(int ClientID) = 0; virtual void OnPlayerInit(int ClientId) = 0;
virtual void OnPlayerDestroy(int ClientID) = 0; virtual void OnPlayerDestroy(int ClientId) = 0;
virtual void OnSpawn(int ClientID) = 0; virtual void OnSpawn(int ClientId) = 0;
virtual void OnHammerFireReloading(int ClientID) = 0; virtual void OnHammerFireReloading(int ClientId) = 0;
virtual void OnHammerFire(int ClientID) = 0; virtual void OnHammerFire(int ClientId) = 0;
virtual void OnHammerHit(int ClientID, int TargetID) = 0; virtual void OnHammerHit(int ClientId, int TargetId) = 0;
virtual void OnDirectInput(int ClientID) = 0; virtual void OnDirectInput(int ClientId) = 0;
virtual void OnCharacterTick(int ClientID) = 0; virtual void OnCharacterTick(int ClientId) = 0;
virtual void OnHookAttach(int ClientID, bool Player) = 0; virtual void OnHookAttach(int ClientId, bool Player) = 0;
// Commands // Commands
virtual void ConsoleCommand(const char *pCommand) = 0; virtual void ConsoleCommand(const char *pCommand) = 0;
@ -35,11 +35,11 @@ public:
// Hooks // Hooks
virtual void OnEngineTick() = 0; virtual void OnEngineTick() = 0;
virtual void OnEngineClientJoin(int ClientID, bool Sixup) = 0; virtual void OnEngineClientJoin(int ClientId, bool Sixup) = 0;
virtual void OnEngineClientDrop(int ClientID, const char *pReason) = 0; virtual void OnEngineClientDrop(int ClientId, const char *pReason) = 0;
virtual bool OnEngineClientMessage(int ClientID, const void *pData, int Size, int Flags) = 0; virtual bool OnEngineClientMessage(int ClientId, const void *pData, int Size, int Flags) = 0;
virtual bool OnEngineServerMessage(int ClientID, const void *pData, int Size, int Flags) = 0; virtual bool OnEngineServerMessage(int ClientId, const void *pData, int Size, int Flags) = 0;
virtual bool OnEngineSimulateClientMessage(int *pClientID, void *pBuffer, int BufferSize, int *pOutSize, int *pFlags) = 0; virtual bool OnEngineSimulateClientMessage(int *pClientId, void *pBuffer, int BufferSize, int *pOutSize, int *pFlags) = 0;
virtual ~IEngineAntibot(){}; virtual ~IEngineAntibot(){};
}; };

View file

@ -99,7 +99,7 @@ public:
{ {
public: public:
int m_Type; int m_Type;
int m_ID; int m_Id;
int m_DataSize; int m_DataSize;
}; };
@ -217,10 +217,10 @@ public:
}; };
// TODO: Refactor: should redo this a bit i think, too many virtual calls // TODO: Refactor: should redo this a bit i think, too many virtual calls
virtual int SnapNumItems(int SnapID) const = 0; virtual int SnapNumItems(int SnapId) const = 0;
virtual const void *SnapFindItem(int SnapID, int Type, int ID) const = 0; virtual const void *SnapFindItem(int SnapId, int Type, int Id) const = 0;
virtual void *SnapGetItem(int SnapID, int Index, CSnapItem *pItem) const = 0; virtual void *SnapGetItem(int SnapId, int Index, CSnapItem *pItem) const = 0;
virtual int SnapItemSize(int SnapID, int Index) const = 0; virtual int SnapItemSize(int SnapId, int Index) const = 0;
virtual void SnapSetStaticsize(int ItemType, int Size) = 0; virtual void SnapSetStaticsize(int ItemType, int Size) = 0;
@ -230,7 +230,7 @@ public:
template<class T> template<class T>
int SendPackMsgActive(T *pMsg, int Flags) int SendPackMsgActive(T *pMsg, int Flags)
{ {
CMsgPacker Packer(T::ms_MsgID, false); CMsgPacker Packer(T::ms_MsgId, false);
if(pMsg->Pack(&Packer)) if(pMsg->Pack(&Packer))
return -1; return -1;
return SendMsgActive(&Packer, Flags); return SendMsgActive(&Packer, Flags);
@ -293,7 +293,7 @@ public:
MESSAGE_BOX_TYPE_INFO, MESSAGE_BOX_TYPE_INFO,
}; };
virtual void ShowMessageBox(const char *pTitle, const char *pMessage, EMessageBoxType Type = MESSAGE_BOX_TYPE_ERROR) = 0; virtual void ShowMessageBox(const char *pTitle, const char *pMessage, EMessageBoxType Type = MESSAGE_BOX_TYPE_ERROR) = 0;
virtual void GetGPUInfoString(char (&aGPUInfo)[256]) = 0; virtual void GetGpuInfoString(char (&aGpuInfo)[256]) = 0;
}; };
class IGameClient : public IInterface class IGameClient : public IInterface
@ -314,7 +314,7 @@ public:
virtual void OnUpdate() = 0; virtual void OnUpdate() = 0;
virtual void OnStateChange(int NewState, int OldState) = 0; virtual void OnStateChange(int NewState, int OldState) = 0;
virtual void OnConnected() = 0; virtual void OnConnected() = 0;
virtual void OnMessage(int MsgID, CUnpacker *pUnpacker, int Conn, bool Dummy) = 0; virtual void OnMessage(int MsgId, CUnpacker *pUnpacker, int Conn, bool Dummy) = 0;
virtual void OnPredict() = 0; virtual void OnPredict() = 0;
virtual void OnActivateEditor() = 0; virtual void OnActivateEditor() = 0;
virtual void OnWindowResize() = 0; virtual void OnWindowResize() = 0;

View file

@ -123,7 +123,7 @@ public:
char *m_pVersionString; char *m_pVersionString;
char *m_pRendererString; char *m_pRendererString;
TTWGraphicsGPUList *m_pGPUList; TTwGraphicsGpuList *m_pGpuList;
}; };
struct SCommand_Init : public CCommandBuffer::SCommand struct SCommand_Init : public CCommandBuffer::SCommand
@ -141,7 +141,7 @@ public:
std::atomic<uint64_t> *m_pStreamMemoryUsage; std::atomic<uint64_t> *m_pStreamMemoryUsage;
std::atomic<uint64_t> *m_pStagingMemoryUsage; std::atomic<uint64_t> *m_pStagingMemoryUsage;
TTWGraphicsGPUList *m_pGPUList; TTwGraphicsGpuList *m_pGpuList;
TGLBackendReadPresentedImageData *m_pReadPresentedImageDataFunc; TGLBackendReadPresentedImageData *m_pReadPresentedImageDataFunc;

View file

@ -326,9 +326,9 @@ bool CCommandProcessorFragment_OpenGL::InitOpenGL(const SCommand_Init *pCommand)
const char *pRendererString = (const char *)glGetString(GL_RENDERER); const char *pRendererString = (const char *)glGetString(GL_RENDERER);
str_copy(pCommand->m_pVendorString, pVendorString, gs_GPUInfoStringSize); str_copy(pCommand->m_pVendorString, pVendorString, gs_GpuInfoStringSize);
str_copy(pCommand->m_pVersionString, pVersionString, gs_GPUInfoStringSize); str_copy(pCommand->m_pVersionString, pVersionString, gs_GpuInfoStringSize);
str_copy(pCommand->m_pRendererString, pRendererString, gs_GPUInfoStringSize); str_copy(pCommand->m_pRendererString, pRendererString, gs_GpuInfoStringSize);
// parse version string // parse version string
ParseVersionString(pCommand->m_RequestedBackend, pVersionString, pCommand->m_pCapabilities->m_ContextMajor, pCommand->m_pCapabilities->m_ContextMinor, pCommand->m_pCapabilities->m_ContextPatch); ParseVersionString(pCommand->m_RequestedBackend, pVersionString, pCommand->m_pCapabilities->m_ContextMajor, pCommand->m_pCapabilities->m_ContextMinor, pCommand->m_pCapabilities->m_ContextPatch);
@ -1664,7 +1664,7 @@ bool CCommandProcessorFragment_OpenGL2::Cmd_Init(const SCommand_Init *pCommand)
m_pTileProgram->AddShader(&VertexShader); m_pTileProgram->AddShader(&VertexShader);
m_pTileProgram->AddShader(&FragmentShader); m_pTileProgram->AddShader(&FragmentShader);
glBindAttribLocation(m_pTileProgram->GetProgramID(), 0, "inVertex"); glBindAttribLocation(m_pTileProgram->GetProgramId(), 0, "inVertex");
m_pTileProgram->LinkProgram(); m_pTileProgram->LinkProgram();
@ -1691,8 +1691,8 @@ bool CCommandProcessorFragment_OpenGL2::Cmd_Init(const SCommand_Init *pCommand)
m_pTileProgramTextured->AddShader(&VertexShader); m_pTileProgramTextured->AddShader(&VertexShader);
m_pTileProgramTextured->AddShader(&FragmentShader); m_pTileProgramTextured->AddShader(&FragmentShader);
glBindAttribLocation(m_pTileProgram->GetProgramID(), 0, "inVertex"); glBindAttribLocation(m_pTileProgram->GetProgramId(), 0, "inVertex");
glBindAttribLocation(m_pTileProgram->GetProgramID(), 1, "inVertexTexCoord"); glBindAttribLocation(m_pTileProgram->GetProgramId(), 1, "inVertexTexCoord");
m_pTileProgramTextured->LinkProgram(); m_pTileProgramTextured->LinkProgram();
@ -1717,7 +1717,7 @@ bool CCommandProcessorFragment_OpenGL2::Cmd_Init(const SCommand_Init *pCommand)
m_pBorderTileProgram->AddShader(&VertexShader); m_pBorderTileProgram->AddShader(&VertexShader);
m_pBorderTileProgram->AddShader(&FragmentShader); m_pBorderTileProgram->AddShader(&FragmentShader);
glBindAttribLocation(m_pBorderTileProgram->GetProgramID(), 0, "inVertex"); glBindAttribLocation(m_pBorderTileProgram->GetProgramId(), 0, "inVertex");
m_pBorderTileProgram->LinkProgram(); m_pBorderTileProgram->LinkProgram();
@ -1746,8 +1746,8 @@ bool CCommandProcessorFragment_OpenGL2::Cmd_Init(const SCommand_Init *pCommand)
m_pBorderTileProgramTextured->AddShader(&VertexShader); m_pBorderTileProgramTextured->AddShader(&VertexShader);
m_pBorderTileProgramTextured->AddShader(&FragmentShader); m_pBorderTileProgramTextured->AddShader(&FragmentShader);
glBindAttribLocation(m_pBorderTileProgramTextured->GetProgramID(), 0, "inVertex"); glBindAttribLocation(m_pBorderTileProgramTextured->GetProgramId(), 0, "inVertex");
glBindAttribLocation(m_pBorderTileProgramTextured->GetProgramID(), 1, "inVertexTexCoord"); glBindAttribLocation(m_pBorderTileProgramTextured->GetProgramId(), 1, "inVertexTexCoord");
m_pBorderTileProgramTextured->LinkProgram(); m_pBorderTileProgramTextured->LinkProgram();
@ -1864,15 +1864,15 @@ void CCommandProcessorFragment_OpenGL2::Cmd_CreateBufferObject(const CCommandBuf
} }
} }
GLuint VertBufferID = 0; GLuint VertBufferId = 0;
glGenBuffers(1, &VertBufferID); glGenBuffers(1, &VertBufferId);
glBindBuffer(GL_ARRAY_BUFFER, VertBufferID); glBindBuffer(GL_ARRAY_BUFFER, VertBufferId);
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)(pCommand->m_DataSize), pUploadData, GL_STATIC_DRAW); glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)(pCommand->m_DataSize), pUploadData, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
SBufferObject &BufferObject = m_vBufferObjectIndices[Index]; SBufferObject &BufferObject = m_vBufferObjectIndices[Index];
BufferObject.m_BufferObjectID = VertBufferID; BufferObject.m_BufferObjectId = VertBufferId;
BufferObject.m_DataSize = pCommand->m_DataSize; BufferObject.m_DataSize = pCommand->m_DataSize;
BufferObject.m_pData = malloc(pCommand->m_DataSize); BufferObject.m_pData = malloc(pCommand->m_DataSize);
if(pUploadData) if(pUploadData)
@ -1888,7 +1888,7 @@ void CCommandProcessorFragment_OpenGL2::Cmd_RecreateBufferObject(const CCommandB
int Index = pCommand->m_BufferIndex; int Index = pCommand->m_BufferIndex;
SBufferObject &BufferObject = m_vBufferObjectIndices[Index]; SBufferObject &BufferObject = m_vBufferObjectIndices[Index];
glBindBuffer(GL_ARRAY_BUFFER, BufferObject.m_BufferObjectID); glBindBuffer(GL_ARRAY_BUFFER, BufferObject.m_BufferObjectId);
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)(pCommand->m_DataSize), pUploadData, GL_STATIC_DRAW); glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)(pCommand->m_DataSize), pUploadData, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
@ -1908,7 +1908,7 @@ void CCommandProcessorFragment_OpenGL2::Cmd_UpdateBufferObject(const CCommandBuf
int Index = pCommand->m_BufferIndex; int Index = pCommand->m_BufferIndex;
SBufferObject &BufferObject = m_vBufferObjectIndices[Index]; SBufferObject &BufferObject = m_vBufferObjectIndices[Index];
glBindBuffer(GL_ARRAY_BUFFER, BufferObject.m_BufferObjectID); glBindBuffer(GL_ARRAY_BUFFER, BufferObject.m_BufferObjectId);
glBufferSubData(GL_ARRAY_BUFFER, (GLintptr)(pCommand->m_pOffset), (GLsizeiptr)(pCommand->m_DataSize), pUploadData); glBufferSubData(GL_ARRAY_BUFFER, (GLintptr)(pCommand->m_pOffset), (GLsizeiptr)(pCommand->m_DataSize), pUploadData);
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
@ -1929,7 +1929,7 @@ void CCommandProcessorFragment_OpenGL2::Cmd_CopyBufferObject(const CCommandBuffe
mem_copy(((uint8_t *)WriteBufferObject.m_pData) + (ptrdiff_t)pCommand->m_WriteOffset, ((uint8_t *)ReadBufferObject.m_pData) + (ptrdiff_t)pCommand->m_ReadOffset, pCommand->m_CopySize); mem_copy(((uint8_t *)WriteBufferObject.m_pData) + (ptrdiff_t)pCommand->m_WriteOffset, ((uint8_t *)ReadBufferObject.m_pData) + (ptrdiff_t)pCommand->m_ReadOffset, pCommand->m_CopySize);
glBindBuffer(GL_ARRAY_BUFFER, WriteBufferObject.m_BufferObjectID); glBindBuffer(GL_ARRAY_BUFFER, WriteBufferObject.m_BufferObjectId);
glBufferSubData(GL_ARRAY_BUFFER, (GLintptr)(pCommand->m_WriteOffset), (GLsizeiptr)(pCommand->m_CopySize), ((uint8_t *)WriteBufferObject.m_pData) + (ptrdiff_t)pCommand->m_WriteOffset); glBufferSubData(GL_ARRAY_BUFFER, (GLintptr)(pCommand->m_WriteOffset), (GLsizeiptr)(pCommand->m_CopySize), ((uint8_t *)WriteBufferObject.m_pData) + (ptrdiff_t)pCommand->m_WriteOffset);
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
} }
@ -1939,7 +1939,7 @@ void CCommandProcessorFragment_OpenGL2::Cmd_DeleteBufferObject(const CCommandBuf
int Index = pCommand->m_BufferIndex; int Index = pCommand->m_BufferIndex;
SBufferObject &BufferObject = m_vBufferObjectIndices[Index]; SBufferObject &BufferObject = m_vBufferObjectIndices[Index];
glDeleteBuffers(1, &BufferObject.m_BufferObjectID); glDeleteBuffers(1, &BufferObject.m_BufferObjectId);
free(BufferObject.m_pData); free(BufferObject.m_pData);
BufferObject.m_pData = NULL; BufferObject.m_pData = NULL;
@ -1992,13 +1992,13 @@ void CCommandProcessorFragment_OpenGL2::Cmd_DeleteBufferContainer(const CCommand
if(pCommand->m_DestroyAllBO) if(pCommand->m_DestroyAllBO)
{ {
int VertBufferID = BufferContainer.m_ContainerInfo.m_VertBufferBindingIndex; int VertBufferId = BufferContainer.m_ContainerInfo.m_VertBufferBindingIndex;
if(VertBufferID != -1) if(VertBufferId != -1)
{ {
glDeleteBuffers(1, &m_vBufferObjectIndices[VertBufferID].m_BufferObjectID); glDeleteBuffers(1, &m_vBufferObjectIndices[VertBufferId].m_BufferObjectId);
free(m_vBufferObjectIndices[VertBufferID].m_pData); free(m_vBufferObjectIndices[VertBufferId].m_pData);
m_vBufferObjectIndices[VertBufferID].m_pData = NULL; m_vBufferObjectIndices[VertBufferId].m_pData = NULL;
} }
} }
@ -2035,7 +2035,7 @@ void CCommandProcessorFragment_OpenGL2::Cmd_RenderBorderTile(const CCommandBuffe
SBufferObject &BufferObject = m_vBufferObjectIndices[(size_t)BufferContainer.m_ContainerInfo.m_VertBufferBindingIndex]; SBufferObject &BufferObject = m_vBufferObjectIndices[(size_t)BufferContainer.m_ContainerInfo.m_VertBufferBindingIndex];
glBindBuffer(GL_ARRAY_BUFFER, BufferObject.m_BufferObjectID); glBindBuffer(GL_ARRAY_BUFFER, BufferObject.m_BufferObjectId);
glEnableVertexAttribArray(0); glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, false, BufferContainer.m_ContainerInfo.m_Stride, BufferContainer.m_ContainerInfo.m_vAttributes[0].m_pOffset); glVertexAttribPointer(0, 2, GL_FLOAT, false, BufferContainer.m_ContainerInfo.m_Stride, BufferContainer.m_ContainerInfo.m_vAttributes[0].m_pOffset);
@ -2087,7 +2087,7 @@ void CCommandProcessorFragment_OpenGL2::Cmd_RenderTileLayer(const CCommandBuffer
SBufferObject &BufferObject = m_vBufferObjectIndices[(size_t)BufferContainer.m_ContainerInfo.m_VertBufferBindingIndex]; SBufferObject &BufferObject = m_vBufferObjectIndices[(size_t)BufferContainer.m_ContainerInfo.m_VertBufferBindingIndex];
glBindBuffer(GL_ARRAY_BUFFER, BufferObject.m_BufferObjectID); glBindBuffer(GL_ARRAY_BUFFER, BufferObject.m_BufferObjectId);
glEnableVertexAttribArray(0); glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, false, BufferContainer.m_ContainerInfo.m_Stride, BufferContainer.m_ContainerInfo.m_vAttributes[0].m_pOffset); glVertexAttribPointer(0, 2, GL_FLOAT, false, BufferContainer.m_ContainerInfo.m_Stride, BufferContainer.m_ContainerInfo.m_vAttributes[0].m_pOffset);

View file

@ -144,13 +144,13 @@ class CCommandProcessorFragment_OpenGL2 : public CCommandProcessorFragment_OpenG
struct SBufferObject struct SBufferObject
{ {
SBufferObject(TWGLuint BufferObjectID) : SBufferObject(TWGLuint BufferObjectId) :
m_BufferObjectID(BufferObjectID) m_BufferObjectId(BufferObjectId)
{ {
m_pData = NULL; m_pData = NULL;
m_DataSize = 0; m_DataSize = 0;
} }
TWGLuint m_BufferObjectID; TWGLuint m_BufferObjectId;
void *m_pData; void *m_pData;
size_t m_DataSize; size_t m_DataSize;
}; };

View file

@ -39,10 +39,10 @@ int CCommandProcessorFragment_OpenGL3_3::TexFormatToNewOpenGLFormat(int TexForma
void CCommandProcessorFragment_OpenGL3_3::UseProgram(CGLSLTWProgram *pProgram) void CCommandProcessorFragment_OpenGL3_3::UseProgram(CGLSLTWProgram *pProgram)
{ {
if(m_LastProgramID != pProgram->GetProgramID()) if(m_LastProgramId != pProgram->GetProgramId())
{ {
pProgram->UseProgram(); pProgram->UseProgram();
m_LastProgramID = pProgram->GetProgramID(); m_LastProgramId = pProgram->GetProgramId();
} }
} }
@ -114,7 +114,7 @@ bool CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
m_pPrimitiveExProgramRotationless = new CGLSLPrimitiveExProgram; m_pPrimitiveExProgramRotationless = new CGLSLPrimitiveExProgram;
m_pPrimitiveExProgramTexturedRotationless = new CGLSLPrimitiveExProgram; m_pPrimitiveExProgramTexturedRotationless = new CGLSLPrimitiveExProgram;
m_pSpriteProgramMultiple = new CGLSLSpriteMultipleProgram; m_pSpriteProgramMultiple = new CGLSLSpriteMultipleProgram;
m_LastProgramID = 0; m_LastProgramId = 0;
CGLSLCompiler ShaderCompiler(g_Config.m_GfxGLMajor, g_Config.m_GfxGLMinor, g_Config.m_GfxGLPatch, m_IsOpenGLES, m_OpenGLTextureLodBIAS / 1000.0f); CGLSLCompiler ShaderCompiler(g_Config.m_GfxGLMajor, g_Config.m_GfxGLMinor, g_Config.m_GfxGLPatch, m_IsOpenGLES, m_OpenGLTextureLodBIAS / 1000.0f);
@ -366,15 +366,15 @@ bool CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
m_LastStreamBuffer = 0; m_LastStreamBuffer = 0;
glGenBuffers(MAX_STREAM_BUFFER_COUNT, m_aPrimitiveDrawBufferID); glGenBuffers(MAX_STREAM_BUFFER_COUNT, m_aPrimitiveDrawBufferId);
glGenVertexArrays(MAX_STREAM_BUFFER_COUNT, m_aPrimitiveDrawVertexID); glGenVertexArrays(MAX_STREAM_BUFFER_COUNT, m_aPrimitiveDrawVertexId);
glGenBuffers(1, &m_PrimitiveDrawBufferIDTex3D); glGenBuffers(1, &m_PrimitiveDrawBufferIdTex3D);
glGenVertexArrays(1, &m_PrimitiveDrawVertexIDTex3D); glGenVertexArrays(1, &m_PrimitiveDrawVertexIdTex3D);
for(int i = 0; i < MAX_STREAM_BUFFER_COUNT; ++i) for(int i = 0; i < MAX_STREAM_BUFFER_COUNT; ++i)
{ {
glBindBuffer(GL_ARRAY_BUFFER, m_aPrimitiveDrawBufferID[i]); glBindBuffer(GL_ARRAY_BUFFER, m_aPrimitiveDrawBufferId[i]);
glBindVertexArray(m_aPrimitiveDrawVertexID[i]); glBindVertexArray(m_aPrimitiveDrawVertexId[i]);
glEnableVertexAttribArray(0); glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1); glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2); glEnableVertexAttribArray(2);
@ -386,8 +386,8 @@ bool CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
m_aLastIndexBufferBound[i] = 0; m_aLastIndexBufferBound[i] = 0;
} }
glBindBuffer(GL_ARRAY_BUFFER, m_PrimitiveDrawBufferIDTex3D); glBindBuffer(GL_ARRAY_BUFFER, m_PrimitiveDrawBufferIdTex3D);
glBindVertexArray(m_PrimitiveDrawVertexIDTex3D); glBindVertexArray(m_PrimitiveDrawVertexIdTex3D);
glEnableVertexAttribArray(0); glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1); glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2); glEnableVertexAttribArray(2);
@ -400,8 +400,8 @@ bool CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_MaxTexSize); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_MaxTexSize);
glBindVertexArray(0); glBindVertexArray(0);
glGenBuffers(1, &m_QuadDrawIndexBufferID); glGenBuffers(1, &m_QuadDrawIndexBufferId);
glBindBuffer(BUFFER_INIT_INDEX_TARGET, m_QuadDrawIndexBufferID); glBindBuffer(BUFFER_INIT_INDEX_TARGET, m_QuadDrawIndexBufferId);
unsigned int aIndices[CCommandBuffer::MAX_VERTICES / 4 * 6]; unsigned int aIndices[CCommandBuffer::MAX_VERTICES / 4 * 6];
int Primq = 0; int Primq = 0;
@ -469,11 +469,11 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Shutdown(const SCommand_Shutdown *
delete m_pSpriteProgramMultiple; delete m_pSpriteProgramMultiple;
glBindVertexArray(0); glBindVertexArray(0);
glDeleteBuffers(MAX_STREAM_BUFFER_COUNT, m_aPrimitiveDrawBufferID); glDeleteBuffers(MAX_STREAM_BUFFER_COUNT, m_aPrimitiveDrawBufferId);
glDeleteBuffers(1, &m_QuadDrawIndexBufferID); glDeleteBuffers(1, &m_QuadDrawIndexBufferId);
glDeleteVertexArrays(MAX_STREAM_BUFFER_COUNT, m_aPrimitiveDrawVertexID); glDeleteVertexArrays(MAX_STREAM_BUFFER_COUNT, m_aPrimitiveDrawVertexId);
glDeleteBuffers(1, &m_PrimitiveDrawBufferIDTex3D); glDeleteBuffers(1, &m_PrimitiveDrawBufferIdTex3D);
glDeleteVertexArrays(1, &m_PrimitiveDrawVertexIDTex3D); glDeleteVertexArrays(1, &m_PrimitiveDrawVertexIdTex3D);
for(int i = 0; i < (int)m_vTextures.size(); ++i) for(int i = 0; i < (int)m_vTextures.size(); ++i)
{ {
@ -727,9 +727,9 @@ void CCommandProcessorFragment_OpenGL3_3::UploadStreamBufferData(unsigned int Pr
}; };
if(AsTex3D) if(AsTex3D)
glBindBuffer(GL_ARRAY_BUFFER, m_PrimitiveDrawBufferIDTex3D); glBindBuffer(GL_ARRAY_BUFFER, m_PrimitiveDrawBufferIdTex3D);
else else
glBindBuffer(GL_ARRAY_BUFFER, m_aPrimitiveDrawBufferID[m_LastStreamBuffer]); glBindBuffer(GL_ARRAY_BUFFER, m_aPrimitiveDrawBufferId[m_LastStreamBuffer]);
glBufferData(GL_ARRAY_BUFFER, VertSize * Count, pVertices, GL_STREAM_DRAW); glBufferData(GL_ARRAY_BUFFER, VertSize * Count, pVertices, GL_STREAM_DRAW);
} }
@ -744,7 +744,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Render(const CCommandBuffer::SComm
UploadStreamBufferData(pCommand->m_PrimType, pCommand->m_pVertices, sizeof(CCommandBuffer::SVertex), pCommand->m_PrimCount); UploadStreamBufferData(pCommand->m_PrimType, pCommand->m_pVertices, sizeof(CCommandBuffer::SVertex), pCommand->m_PrimCount);
glBindVertexArray(m_aPrimitiveDrawVertexID[m_LastStreamBuffer]); glBindVertexArray(m_aPrimitiveDrawVertexId[m_LastStreamBuffer]);
switch(pCommand->m_PrimType) switch(pCommand->m_PrimType)
{ {
@ -756,10 +756,10 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Render(const CCommandBuffer::SComm
glDrawArrays(GL_TRIANGLES, 0, pCommand->m_PrimCount * 3); glDrawArrays(GL_TRIANGLES, 0, pCommand->m_PrimCount * 3);
break; break;
case CCommandBuffer::PRIMTYPE_QUADS: case CCommandBuffer::PRIMTYPE_QUADS:
if(m_aLastIndexBufferBound[m_LastStreamBuffer] != m_QuadDrawIndexBufferID) if(m_aLastIndexBufferBound[m_LastStreamBuffer] != m_QuadDrawIndexBufferId)
{ {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferId);
m_aLastIndexBufferBound[m_LastStreamBuffer] = m_QuadDrawIndexBufferID; m_aLastIndexBufferBound[m_LastStreamBuffer] = m_QuadDrawIndexBufferId;
} }
glDrawElements(GL_TRIANGLES, pCommand->m_PrimCount * 6, GL_UNSIGNED_INT, 0); glDrawElements(GL_TRIANGLES, pCommand->m_PrimCount * 6, GL_UNSIGNED_INT, 0);
break; break;
@ -780,7 +780,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderTex3D(const CCommandBuffer::
UploadStreamBufferData(pCommand->m_PrimType, pCommand->m_pVertices, sizeof(CCommandBuffer::SVertexTex3DStream), pCommand->m_PrimCount, true); UploadStreamBufferData(pCommand->m_PrimType, pCommand->m_pVertices, sizeof(CCommandBuffer::SVertexTex3DStream), pCommand->m_PrimCount, true);
glBindVertexArray(m_PrimitiveDrawVertexIDTex3D); glBindVertexArray(m_PrimitiveDrawVertexIdTex3D);
switch(pCommand->m_PrimType) switch(pCommand->m_PrimType)
{ {
@ -789,7 +789,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderTex3D(const CCommandBuffer::
glDrawArrays(GL_LINES, 0, pCommand->m_PrimCount * 2); glDrawArrays(GL_LINES, 0, pCommand->m_PrimCount * 2);
break; break;
case CCommandBuffer::PRIMTYPE_QUADS: case CCommandBuffer::PRIMTYPE_QUADS:
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferId);
glDrawElements(GL_TRIANGLES, pCommand->m_PrimCount * 6, GL_UNSIGNED_INT, 0); glDrawElements(GL_TRIANGLES, pCommand->m_PrimCount * 6, GL_UNSIGNED_INT, 0);
break; break;
default: default:
@ -800,16 +800,16 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderTex3D(const CCommandBuffer::
void CCommandProcessorFragment_OpenGL3_3::DestroyBufferContainer(int Index, bool DeleteBOs) void CCommandProcessorFragment_OpenGL3_3::DestroyBufferContainer(int Index, bool DeleteBOs)
{ {
SBufferContainer &BufferContainer = m_vBufferContainers[Index]; SBufferContainer &BufferContainer = m_vBufferContainers[Index];
if(BufferContainer.m_VertArrayID != 0) if(BufferContainer.m_VertArrayId != 0)
glDeleteVertexArrays(1, &BufferContainer.m_VertArrayID); glDeleteVertexArrays(1, &BufferContainer.m_VertArrayId);
// all buffer objects can deleted automatically, so the program doesn't need to deal with them (e.g. causing crashes because of driver bugs) // all buffer objects can deleted automatically, so the program doesn't need to deal with them (e.g. causing crashes because of driver bugs)
if(DeleteBOs) if(DeleteBOs)
{ {
int VertBufferID = BufferContainer.m_ContainerInfo.m_VertBufferBindingIndex; int VertBufferId = BufferContainer.m_ContainerInfo.m_VertBufferBindingIndex;
if(VertBufferID != -1) if(VertBufferId != -1)
{ {
glDeleteBuffers(1, &m_vBufferObjectIndices[VertBufferID]); glDeleteBuffers(1, &m_vBufferObjectIndices[VertBufferId]);
} }
} }
@ -835,10 +835,10 @@ void CCommandProcessorFragment_OpenGL3_3::AppendIndices(unsigned int NewIndicesC
Primq += 4; Primq += 4;
} }
glBindBuffer(GL_COPY_READ_BUFFER, m_QuadDrawIndexBufferID); glBindBuffer(GL_COPY_READ_BUFFER, m_QuadDrawIndexBufferId);
GLuint NewIndexBufferID; GLuint NewIndexBufferId;
glGenBuffers(1, &NewIndexBufferID); glGenBuffers(1, &NewIndexBufferId);
glBindBuffer(BUFFER_INIT_INDEX_TARGET, NewIndexBufferID); glBindBuffer(BUFFER_INIT_INDEX_TARGET, NewIndexBufferId);
GLsizeiptr size = sizeof(unsigned int); GLsizeiptr size = sizeof(unsigned int);
glBufferData(BUFFER_INIT_INDEX_TARGET, (GLsizeiptr)NewIndicesCount * size, NULL, GL_STATIC_DRAW); glBufferData(BUFFER_INIT_INDEX_TARGET, (GLsizeiptr)NewIndicesCount * size, NULL, GL_STATIC_DRAW);
glCopyBufferSubData(GL_COPY_READ_BUFFER, BUFFER_INIT_INDEX_TARGET, 0, 0, (GLsizeiptr)m_CurrentIndicesInBuffer * size); glCopyBufferSubData(GL_COPY_READ_BUFFER, BUFFER_INIT_INDEX_TARGET, 0, 0, (GLsizeiptr)m_CurrentIndicesInBuffer * size);
@ -846,8 +846,8 @@ void CCommandProcessorFragment_OpenGL3_3::AppendIndices(unsigned int NewIndicesC
glBindBuffer(BUFFER_INIT_INDEX_TARGET, 0); glBindBuffer(BUFFER_INIT_INDEX_TARGET, 0);
glBindBuffer(GL_COPY_READ_BUFFER, 0); glBindBuffer(GL_COPY_READ_BUFFER, 0);
glDeleteBuffers(1, &m_QuadDrawIndexBufferID); glDeleteBuffers(1, &m_QuadDrawIndexBufferId);
m_QuadDrawIndexBufferID = NewIndexBufferID; m_QuadDrawIndexBufferId = NewIndexBufferId;
for(unsigned int &i : m_aLastIndexBufferBound) for(unsigned int &i : m_aLastIndexBufferBound)
i = 0; i = 0;
@ -873,13 +873,13 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_CreateBufferObject(const CCommandB
} }
} }
GLuint VertBufferID = 0; GLuint VertBufferId = 0;
glGenBuffers(1, &VertBufferID); glGenBuffers(1, &VertBufferId);
glBindBuffer(BUFFER_INIT_VERTEX_TARGET, VertBufferID); glBindBuffer(BUFFER_INIT_VERTEX_TARGET, VertBufferId);
glBufferData(BUFFER_INIT_VERTEX_TARGET, (GLsizeiptr)(pCommand->m_DataSize), pUploadData, GL_STATIC_DRAW); glBufferData(BUFFER_INIT_VERTEX_TARGET, (GLsizeiptr)(pCommand->m_DataSize), pUploadData, GL_STATIC_DRAW);
m_vBufferObjectIndices[Index] = VertBufferID; m_vBufferObjectIndices[Index] = VertBufferId;
if(pCommand->m_DeletePointer) if(pCommand->m_DeletePointer)
free(pUploadData); free(pUploadData);
@ -942,8 +942,8 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_CreateBufferContainer(const CComma
} }
SBufferContainer &BufferContainer = m_vBufferContainers[Index]; SBufferContainer &BufferContainer = m_vBufferContainers[Index];
glGenVertexArrays(1, &BufferContainer.m_VertArrayID); glGenVertexArrays(1, &BufferContainer.m_VertArrayId);
glBindVertexArray(BufferContainer.m_VertArrayID); glBindVertexArray(BufferContainer.m_VertArrayId);
BufferContainer.m_LastIndexBufferBound = 0; BufferContainer.m_LastIndexBufferBound = 0;
@ -971,7 +971,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_UpdateBufferContainer(const CComma
{ {
SBufferContainer &BufferContainer = m_vBufferContainers[pCommand->m_BufferContainerIndex]; SBufferContainer &BufferContainer = m_vBufferContainers[pCommand->m_BufferContainerIndex];
glBindVertexArray(BufferContainer.m_VertArrayID); glBindVertexArray(BufferContainer.m_VertArrayId);
// disable all old attributes // disable all old attributes
for(size_t i = 0; i < BufferContainer.m_ContainerInfo.m_vAttributes.size(); ++i) for(size_t i = 0; i < BufferContainer.m_ContainerInfo.m_vAttributes.size(); ++i)
@ -1017,7 +1017,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderBorderTile(const CCommandBuf
return; return;
SBufferContainer &BufferContainer = m_vBufferContainers[Index]; SBufferContainer &BufferContainer = m_vBufferContainers[Index];
if(BufferContainer.m_VertArrayID == 0) if(BufferContainer.m_VertArrayId == 0)
return; return;
CGLSLTileProgram *pProgram = NULL; CGLSLTileProgram *pProgram = NULL;
@ -1033,11 +1033,11 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderBorderTile(const CCommandBuf
pProgram->SetUniformVec2(pProgram->m_LocOffset, 1, (float *)&pCommand->m_Offset); pProgram->SetUniformVec2(pProgram->m_LocOffset, 1, (float *)&pCommand->m_Offset);
pProgram->SetUniformVec2(pProgram->m_LocScale, 1, (float *)&pCommand->m_Scale); pProgram->SetUniformVec2(pProgram->m_LocScale, 1, (float *)&pCommand->m_Scale);
glBindVertexArray(BufferContainer.m_VertArrayID); glBindVertexArray(BufferContainer.m_VertArrayId);
if(BufferContainer.m_LastIndexBufferBound != m_QuadDrawIndexBufferID) if(BufferContainer.m_LastIndexBufferBound != m_QuadDrawIndexBufferId)
{ {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferId);
BufferContainer.m_LastIndexBufferBound = m_QuadDrawIndexBufferID; BufferContainer.m_LastIndexBufferBound = m_QuadDrawIndexBufferId;
} }
glDrawElements(GL_TRIANGLES, pCommand->m_DrawNum * 6, GL_UNSIGNED_INT, pCommand->m_pIndicesOffset); glDrawElements(GL_TRIANGLES, pCommand->m_DrawNum * 6, GL_UNSIGNED_INT, pCommand->m_pIndicesOffset);
} }
@ -1050,7 +1050,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderTileLayer(const CCommandBuff
return; return;
SBufferContainer &BufferContainer = m_vBufferContainers[Index]; SBufferContainer &BufferContainer = m_vBufferContainers[Index];
if(BufferContainer.m_VertArrayID == 0) if(BufferContainer.m_VertArrayId == 0)
return; return;
if(pCommand->m_IndicesDrawNum == 0) if(pCommand->m_IndicesDrawNum == 0)
@ -1071,11 +1071,11 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderTileLayer(const CCommandBuff
SetState(pCommand->m_State, pProgram, true); SetState(pCommand->m_State, pProgram, true);
pProgram->SetUniformVec4(pProgram->m_LocColor, 1, (float *)&pCommand->m_Color); pProgram->SetUniformVec4(pProgram->m_LocColor, 1, (float *)&pCommand->m_Color);
glBindVertexArray(BufferContainer.m_VertArrayID); glBindVertexArray(BufferContainer.m_VertArrayId);
if(BufferContainer.m_LastIndexBufferBound != m_QuadDrawIndexBufferID) if(BufferContainer.m_LastIndexBufferBound != m_QuadDrawIndexBufferId)
{ {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferId);
BufferContainer.m_LastIndexBufferBound = m_QuadDrawIndexBufferID; BufferContainer.m_LastIndexBufferBound = m_QuadDrawIndexBufferId;
} }
for(int i = 0; i < pCommand->m_IndicesDrawNum; ++i) for(int i = 0; i < pCommand->m_IndicesDrawNum; ++i)
{ {
@ -1091,7 +1091,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderQuadLayer(const CCommandBuff
return; return;
SBufferContainer &BufferContainer = m_vBufferContainers[Index]; SBufferContainer &BufferContainer = m_vBufferContainers[Index];
if(BufferContainer.m_VertArrayID == 0) if(BufferContainer.m_VertArrayId == 0)
return; return;
if(pCommand->m_QuadNum == 0) if(pCommand->m_QuadNum == 0)
@ -1110,11 +1110,11 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderQuadLayer(const CCommandBuff
UseProgram(pProgram); UseProgram(pProgram);
SetState(pCommand->m_State, pProgram); SetState(pCommand->m_State, pProgram);
glBindVertexArray(BufferContainer.m_VertArrayID); glBindVertexArray(BufferContainer.m_VertArrayId);
if(BufferContainer.m_LastIndexBufferBound != m_QuadDrawIndexBufferID) if(BufferContainer.m_LastIndexBufferBound != m_QuadDrawIndexBufferId)
{ {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferId);
BufferContainer.m_LastIndexBufferBound = m_QuadDrawIndexBufferID; BufferContainer.m_LastIndexBufferBound = m_QuadDrawIndexBufferId;
} }
int QuadsLeft = pCommand->m_QuadNum; int QuadsLeft = pCommand->m_QuadNum;
@ -1209,14 +1209,14 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderText(const CCommandBuffer::S
return; return;
SBufferContainer &BufferContainer = m_vBufferContainers[Index]; SBufferContainer &BufferContainer = m_vBufferContainers[Index];
if(BufferContainer.m_VertArrayID == 0) if(BufferContainer.m_VertArrayId == 0)
return; return;
glBindVertexArray(BufferContainer.m_VertArrayID); glBindVertexArray(BufferContainer.m_VertArrayId);
if(BufferContainer.m_LastIndexBufferBound != m_QuadDrawIndexBufferID) if(BufferContainer.m_LastIndexBufferBound != m_QuadDrawIndexBufferId)
{ {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferId);
BufferContainer.m_LastIndexBufferBound = m_QuadDrawIndexBufferID; BufferContainer.m_LastIndexBufferBound = m_QuadDrawIndexBufferId;
} }
RenderText(pCommand->m_State, pCommand->m_DrawNum, pCommand->m_TextTextureIndex, pCommand->m_TextOutlineTextureIndex, pCommand->m_TextureSize, pCommand->m_TextColor, pCommand->m_TextOutlineColor); RenderText(pCommand->m_State, pCommand->m_DrawNum, pCommand->m_TextTextureIndex, pCommand->m_TextOutlineTextureIndex, pCommand->m_TextureSize, pCommand->m_TextColor, pCommand->m_TextOutlineColor);
@ -1235,14 +1235,14 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderQuadContainer(const CCommand
return; return;
SBufferContainer &BufferContainer = m_vBufferContainers[Index]; SBufferContainer &BufferContainer = m_vBufferContainers[Index];
if(BufferContainer.m_VertArrayID == 0) if(BufferContainer.m_VertArrayId == 0)
return; return;
glBindVertexArray(BufferContainer.m_VertArrayID); glBindVertexArray(BufferContainer.m_VertArrayId);
if(BufferContainer.m_LastIndexBufferBound != m_QuadDrawIndexBufferID) if(BufferContainer.m_LastIndexBufferBound != m_QuadDrawIndexBufferId)
{ {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferId);
BufferContainer.m_LastIndexBufferBound = m_QuadDrawIndexBufferID; BufferContainer.m_LastIndexBufferBound = m_QuadDrawIndexBufferId;
} }
CGLSLTWProgram *pProgram = m_pPrimitiveProgram; CGLSLTWProgram *pProgram = m_pPrimitiveProgram;
@ -1267,14 +1267,14 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderQuadContainerEx(const CComma
return; return;
SBufferContainer &BufferContainer = m_vBufferContainers[Index]; SBufferContainer &BufferContainer = m_vBufferContainers[Index];
if(BufferContainer.m_VertArrayID == 0) if(BufferContainer.m_VertArrayId == 0)
return; return;
glBindVertexArray(BufferContainer.m_VertArrayID); glBindVertexArray(BufferContainer.m_VertArrayId);
if(BufferContainer.m_LastIndexBufferBound != m_QuadDrawIndexBufferID) if(BufferContainer.m_LastIndexBufferBound != m_QuadDrawIndexBufferId)
{ {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferId);
BufferContainer.m_LastIndexBufferBound = m_QuadDrawIndexBufferID; BufferContainer.m_LastIndexBufferBound = m_QuadDrawIndexBufferId;
} }
CGLSLPrimitiveExProgram *pProgram = m_pPrimitiveExProgramRotationless; CGLSLPrimitiveExProgram *pProgram = m_pPrimitiveExProgramRotationless;
@ -1328,14 +1328,14 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderQuadContainerAsSpriteMultipl
return; return;
SBufferContainer &BufferContainer = m_vBufferContainers[Index]; SBufferContainer &BufferContainer = m_vBufferContainers[Index];
if(BufferContainer.m_VertArrayID == 0) if(BufferContainer.m_VertArrayId == 0)
return; return;
glBindVertexArray(BufferContainer.m_VertArrayID); glBindVertexArray(BufferContainer.m_VertArrayId);
if(BufferContainer.m_LastIndexBufferBound != m_QuadDrawIndexBufferID) if(BufferContainer.m_LastIndexBufferBound != m_QuadDrawIndexBufferId)
{ {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferId);
BufferContainer.m_LastIndexBufferBound = m_QuadDrawIndexBufferID; BufferContainer.m_LastIndexBufferBound = m_QuadDrawIndexBufferId;
} }
UseProgram(m_pSpriteProgramMultiple); UseProgram(m_pSpriteProgramMultiple);

View file

@ -37,18 +37,18 @@ protected:
CGLSLPrimitiveExProgram *m_pPrimitiveExProgramTexturedRotationless; CGLSLPrimitiveExProgram *m_pPrimitiveExProgramTexturedRotationless;
CGLSLSpriteMultipleProgram *m_pSpriteProgramMultiple; CGLSLSpriteMultipleProgram *m_pSpriteProgramMultiple;
TWGLuint m_LastProgramID; TWGLuint m_LastProgramId;
TWGLuint m_aPrimitiveDrawVertexID[MAX_STREAM_BUFFER_COUNT]; TWGLuint m_aPrimitiveDrawVertexId[MAX_STREAM_BUFFER_COUNT];
TWGLuint m_PrimitiveDrawVertexIDTex3D; TWGLuint m_PrimitiveDrawVertexIdTex3D;
TWGLuint m_aPrimitiveDrawBufferID[MAX_STREAM_BUFFER_COUNT]; TWGLuint m_aPrimitiveDrawBufferId[MAX_STREAM_BUFFER_COUNT];
TWGLuint m_PrimitiveDrawBufferIDTex3D; TWGLuint m_PrimitiveDrawBufferIdTex3D;
TWGLuint m_aLastIndexBufferBound[MAX_STREAM_BUFFER_COUNT]; TWGLuint m_aLastIndexBufferBound[MAX_STREAM_BUFFER_COUNT];
int m_LastStreamBuffer; int m_LastStreamBuffer;
TWGLuint m_QuadDrawIndexBufferID; TWGLuint m_QuadDrawIndexBufferId;
unsigned int m_CurrentIndicesInBuffer; unsigned int m_CurrentIndicesInBuffer;
void DestroyBufferContainer(int Index, bool DeleteBOs = true); void DestroyBufferContainer(int Index, bool DeleteBOs = true);
@ -58,8 +58,8 @@ protected:
struct SBufferContainer struct SBufferContainer
{ {
SBufferContainer() : SBufferContainer() :
m_VertArrayID(0), m_LastIndexBufferBound(0) {} m_VertArrayId(0), m_LastIndexBufferBound(0) {}
TWGLuint m_VertArrayID; TWGLuint m_VertArrayId;
TWGLuint m_LastIndexBufferBound; TWGLuint m_LastIndexBufferBound;
SBufferContainerInfo m_ContainerInfo; SBufferContainerInfo m_ContainerInfo;
}; };

View file

@ -126,7 +126,7 @@ bool CGLSL::LoadShader(CGLSLCompiler *pCompiler, IStorage *pStorage, const char
m_Type = Type; m_Type = Type;
m_IsLoaded = true; m_IsLoaded = true;
m_ShaderID = shader; m_ShaderId = shader;
return true; return true;
} }
@ -139,7 +139,7 @@ void CGLSL::DeleteShader()
if(!IsLoaded()) if(!IsLoaded())
return; return;
m_IsLoaded = false; m_IsLoaded = false;
glDeleteShader(m_ShaderID); glDeleteShader(m_ShaderId);
} }
bool CGLSL::IsLoaded() const bool CGLSL::IsLoaded() const
@ -147,9 +147,9 @@ bool CGLSL::IsLoaded() const
return m_IsLoaded; return m_IsLoaded;
} }
TWGLuint CGLSL::GetShaderID() const TWGLuint CGLSL::GetShaderId() const
{ {
return m_ShaderID; return m_ShaderId;
} }
CGLSL::CGLSL() CGLSL::CGLSL()

View file

@ -21,13 +21,13 @@ public:
void DeleteShader(); void DeleteShader();
bool IsLoaded() const; bool IsLoaded() const;
TWGLuint GetShaderID() const; TWGLuint GetShaderId() const;
CGLSL(); CGLSL();
virtual ~CGLSL(); virtual ~CGLSL();
private: private:
TWGLuint m_ShaderID; TWGLuint m_ShaderId;
int m_Type; int m_Type;
bool m_IsLoaded; bool m_IsLoaded;
}; };

View file

@ -14,7 +14,7 @@
void CGLSLProgram::CreateProgram() void CGLSLProgram::CreateProgram()
{ {
m_ProgramID = glCreateProgram(); m_ProgramId = glCreateProgram();
} }
void CGLSLProgram::DeleteProgram() void CGLSLProgram::DeleteProgram()
@ -22,14 +22,14 @@ void CGLSLProgram::DeleteProgram()
if(!m_IsLinked) if(!m_IsLinked)
return; return;
m_IsLinked = false; m_IsLinked = false;
glDeleteProgram(m_ProgramID); glDeleteProgram(m_ProgramId);
} }
bool CGLSLProgram::AddShader(CGLSL *pShader) const bool CGLSLProgram::AddShader(CGLSL *pShader) const
{ {
if(pShader->IsLoaded()) if(pShader->IsLoaded())
{ {
glAttachShader(m_ProgramID, pShader->GetShaderID()); glAttachShader(m_ProgramId, pShader->GetShaderId());
return true; return true;
} }
return false; return false;
@ -39,27 +39,27 @@ void CGLSLProgram::DetachShader(CGLSL *pShader) const
{ {
if(pShader->IsLoaded()) if(pShader->IsLoaded())
{ {
DetachShaderByID(pShader->GetShaderID()); DetachShaderById(pShader->GetShaderId());
} }
} }
void CGLSLProgram::DetachShaderByID(TWGLuint ShaderID) const void CGLSLProgram::DetachShaderById(TWGLuint ShaderId) const
{ {
glDetachShader(m_ProgramID, ShaderID); glDetachShader(m_ProgramId, ShaderId);
} }
void CGLSLProgram::LinkProgram() void CGLSLProgram::LinkProgram()
{ {
glLinkProgram(m_ProgramID); glLinkProgram(m_ProgramId);
int LinkStatus; int LinkStatus;
glGetProgramiv(m_ProgramID, GL_LINK_STATUS, &LinkStatus); glGetProgramiv(m_ProgramId, GL_LINK_STATUS, &LinkStatus);
m_IsLinked = LinkStatus == GL_TRUE; m_IsLinked = LinkStatus == GL_TRUE;
if(!m_IsLinked) if(!m_IsLinked)
{ {
char aInfoLog[1024]; char aInfoLog[1024];
char aFinalMessage[1536]; char aFinalMessage[1536];
int iLogLength; int iLogLength;
glGetProgramInfoLog(m_ProgramID, 1024, &iLogLength, aInfoLog); glGetProgramInfoLog(m_ProgramId, 1024, &iLogLength, aInfoLog);
str_format(aFinalMessage, sizeof(aFinalMessage), "Error! Shader program wasn't linked! The linker returned:\n\n%s", aInfoLog); str_format(aFinalMessage, sizeof(aFinalMessage), "Error! Shader program wasn't linked! The linker returned:\n\n%s", aInfoLog);
dbg_msg("glslprogram", "%s", aFinalMessage); dbg_msg("glslprogram", "%s", aFinalMessage);
} }
@ -74,13 +74,13 @@ void CGLSLProgram::DetachAllShaders() const
GLsizei ReturnedCount = 0; GLsizei ReturnedCount = 0;
while(true) while(true)
{ {
glGetAttachedShaders(m_ProgramID, 100, &ReturnedCount, aShaders); glGetAttachedShaders(m_ProgramId, 100, &ReturnedCount, aShaders);
if(ReturnedCount > 0) if(ReturnedCount > 0)
{ {
for(GLsizei i = 0; i < ReturnedCount; ++i) for(GLsizei i = 0; i < ReturnedCount; ++i)
{ {
DetachShaderByID(aShaders[i]); DetachShaderById(aShaders[i]);
} }
} }
@ -121,18 +121,18 @@ void CGLSLProgram::SetUniform(int Loc, const bool Value)
int CGLSLProgram::GetUniformLoc(const char *pName) const int CGLSLProgram::GetUniformLoc(const char *pName) const
{ {
return glGetUniformLocation(m_ProgramID, pName); return glGetUniformLocation(m_ProgramId, pName);
} }
void CGLSLProgram::UseProgram() const void CGLSLProgram::UseProgram() const
{ {
if(m_IsLinked) if(m_IsLinked)
glUseProgram(m_ProgramID); glUseProgram(m_ProgramId);
} }
TWGLuint CGLSLProgram::GetProgramID() const TWGLuint CGLSLProgram::GetProgramId() const
{ {
return m_ProgramID; return m_ProgramId;
} }
CGLSLProgram::CGLSLProgram() CGLSLProgram::CGLSLProgram()

View file

@ -26,10 +26,10 @@ public:
void LinkProgram(); void LinkProgram();
void UseProgram() const; void UseProgram() const;
TWGLuint GetProgramID() const; TWGLuint GetProgramId() const;
void DetachShader(CGLSL *pShader) const; void DetachShader(CGLSL *pShader) const;
void DetachShaderByID(TWGLuint ShaderID) const; void DetachShaderById(TWGLuint ShaderId) const;
void DetachAllShaders() const; void DetachAllShaders() const;
//Support various types //Support various types
@ -47,7 +47,7 @@ public:
virtual ~CGLSLProgram(); virtual ~CGLSLProgram();
protected: protected:
TWGLuint m_ProgramID; TWGLuint m_ProgramId;
bool m_IsLinked; bool m_IsLinked;
}; };

View file

@ -113,10 +113,10 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
* STRUCT DEFINITIONS * STRUCT DEFINITIONS
************************/ ************************/
static constexpr size_t s_StagingBufferCacheID = 0; static constexpr size_t s_StagingBufferCacheId = 0;
static constexpr size_t s_StagingBufferImageCacheID = 1; static constexpr size_t s_StagingBufferImageCacheId = 1;
static constexpr size_t s_VertexBufferCacheID = 2; static constexpr size_t s_VertexBufferCacheId = 2;
static constexpr size_t s_ImageBufferCacheID = 3; static constexpr size_t s_ImageBufferCacheId = 3;
struct SDeviceMemoryBlock struct SDeviceMemoryBlock
{ {
@ -325,7 +325,7 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
} }
}; };
template<size_t ID> template<size_t Id>
struct SMemoryBlock struct SMemoryBlock
{ {
SMemoryHeap::SMemoryHeapQueueElement m_HeapData; SMemoryHeap::SMemoryHeapQueueElement m_HeapData;
@ -342,13 +342,13 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
SMemoryHeap *m_pHeap; SMemoryHeap *m_pHeap;
}; };
template<size_t ID> template<size_t Id>
struct SMemoryImageBlock : public SMemoryBlock<ID> struct SMemoryImageBlock : public SMemoryBlock<Id>
{ {
uint32_t m_ImageMemoryBits; uint32_t m_ImageMemoryBits;
}; };
template<size_t ID> template<size_t Id>
struct SMemoryBlockCache struct SMemoryBlockCache
{ {
struct SMemoryCacheType struct SMemoryCacheType
@ -364,7 +364,7 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
std::vector<SMemoryCacheHeap *> m_vpMemoryHeaps; std::vector<SMemoryCacheHeap *> m_vpMemoryHeaps;
}; };
SMemoryCacheType m_MemoryCaches; SMemoryCacheType m_MemoryCaches;
std::vector<std::vector<SMemoryBlock<ID>>> m_vvFrameDelayedCachedBufferCleanup; std::vector<std::vector<SMemoryBlock<Id>>> m_vvFrameDelayedCachedBufferCleanup;
bool m_CanShrink = false; bool m_CanShrink = false;
@ -411,7 +411,7 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
m_vvFrameDelayedCachedBufferCleanup[ImgIndex].clear(); m_vvFrameDelayedCachedBufferCleanup[ImgIndex].clear();
} }
void FreeMemBlock(SMemoryBlock<ID> &Block, size_t ImgIndex) void FreeMemBlock(SMemoryBlock<Id> &Block, size_t ImgIndex)
{ {
m_vvFrameDelayedCachedBufferCleanup[ImgIndex].push_back(Block); m_vvFrameDelayedCachedBufferCleanup[ImgIndex].push_back(Block);
} }
@ -455,12 +455,12 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
struct CTexture struct CTexture
{ {
VkImage m_Img = VK_NULL_HANDLE; VkImage m_Img = VK_NULL_HANDLE;
SMemoryImageBlock<s_ImageBufferCacheID> m_ImgMem; SMemoryImageBlock<s_ImageBufferCacheId> m_ImgMem;
VkImageView m_ImgView = VK_NULL_HANDLE; VkImageView m_ImgView = VK_NULL_HANDLE;
VkSampler m_aSamplers[2] = {VK_NULL_HANDLE, VK_NULL_HANDLE}; VkSampler m_aSamplers[2] = {VK_NULL_HANDLE, VK_NULL_HANDLE};
VkImage m_Img3D = VK_NULL_HANDLE; VkImage m_Img3D = VK_NULL_HANDLE;
SMemoryImageBlock<s_ImageBufferCacheID> m_Img3DMem; SMemoryImageBlock<s_ImageBufferCacheId> m_Img3DMem;
VkImageView m_Img3DView = VK_NULL_HANDLE; VkImageView m_Img3DView = VK_NULL_HANDLE;
VkSampler m_Sampler3D = VK_NULL_HANDLE; VkSampler m_Sampler3D = VK_NULL_HANDLE;
@ -477,7 +477,7 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
struct SBufferObject struct SBufferObject
{ {
SMemoryBlock<s_VertexBufferCacheID> m_Mem; SMemoryBlock<s_VertexBufferCacheId> m_Mem;
}; };
struct SBufferObjectFrame struct SBufferObjectFrame
@ -865,7 +865,7 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
struct SSwapChainMultiSampleImage struct SSwapChainMultiSampleImage
{ {
VkImage m_Image = VK_NULL_HANDLE; VkImage m_Image = VK_NULL_HANDLE;
SMemoryImageBlock<s_ImageBufferCacheID> m_ImgMem; SMemoryImageBlock<s_ImageBufferCacheId> m_ImgMem;
VkImageView m_ImgView = VK_NULL_HANDLE; VkImageView m_ImgView = VK_NULL_HANDLE;
}; };
@ -875,10 +875,10 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
std::unordered_map<std::string, SShaderFileCache> m_ShaderFiles; std::unordered_map<std::string, SShaderFileCache> m_ShaderFiles;
SMemoryBlockCache<s_StagingBufferCacheID> m_StagingBufferCache; SMemoryBlockCache<s_StagingBufferCacheId> m_StagingBufferCache;
SMemoryBlockCache<s_StagingBufferImageCacheID> m_StagingBufferCacheImage; SMemoryBlockCache<s_StagingBufferImageCacheId> m_StagingBufferCacheImage;
SMemoryBlockCache<s_VertexBufferCacheID> m_VertexBufferCache; SMemoryBlockCache<s_VertexBufferCacheId> m_VertexBufferCache;
std::map<uint32_t, SMemoryBlockCache<s_ImageBufferCacheID>> m_ImageBufferCaches; std::map<uint32_t, SMemoryBlockCache<s_ImageBufferCacheId>> m_ImageBufferCaches;
std::vector<VkMappedMemoryRange> m_vNonFlushedStagingBufferRange; std::vector<VkMappedMemoryRange> m_vNonFlushedStagingBufferRange;
@ -889,7 +889,7 @@ class CCommandProcessorFragment_Vulkan : public CCommandProcessorFragment_GLBase
std::atomic<uint64_t> *m_pStreamMemoryUsage; std::atomic<uint64_t> *m_pStreamMemoryUsage;
std::atomic<uint64_t> *m_pStagingMemoryUsage; std::atomic<uint64_t> *m_pStagingMemoryUsage;
TTWGraphicsGPUList *m_pGPUList; TTwGraphicsGpuList *m_pGpuList;
int m_GlobalTextureLodBIAS; int m_GlobalTextureLodBIAS;
uint32_t m_MultiSamplingCount = 1; uint32_t m_MultiSamplingCount = 1;
@ -1600,10 +1600,10 @@ protected:
return CreateBuffer(RequiredSize, MemUsage, BufferUsage, BufferProperties, Buffer, BufferMemory); return CreateBuffer(RequiredSize, MemUsage, BufferUsage, BufferProperties, Buffer, BufferMemory);
} }
template<size_t ID, template<size_t Id,
int64_t MemoryBlockSize, size_t BlockCount, int64_t MemoryBlockSize, size_t BlockCount,
bool RequiresMapping> bool RequiresMapping>
[[nodiscard]] bool GetBufferBlockImpl(SMemoryBlock<ID> &RetBlock, SMemoryBlockCache<ID> &MemoryCache, VkBufferUsageFlags BufferUsage, VkMemoryPropertyFlags BufferProperties, const void *pBufferData, VkDeviceSize RequiredSize, VkDeviceSize TargetAlignment) [[nodiscard]] bool GetBufferBlockImpl(SMemoryBlock<Id> &RetBlock, SMemoryBlockCache<Id> &MemoryCache, VkBufferUsageFlags BufferUsage, VkMemoryPropertyFlags BufferProperties, const void *pBufferData, VkDeviceSize RequiredSize, VkDeviceSize TargetAlignment)
{ {
bool Res = true; bool Res = true;
@ -1611,7 +1611,7 @@ protected:
bool FoundAllocation = false; bool FoundAllocation = false;
SMemoryHeap::SMemoryHeapQueueElement AllocatedMem; SMemoryHeap::SMemoryHeapQueueElement AllocatedMem;
SDeviceMemoryBlock TmpBufferMemory; SDeviceMemoryBlock TmpBufferMemory;
typename SMemoryBlockCache<ID>::SMemoryCacheType::SMemoryCacheHeap *pCacheHeap = nullptr; typename SMemoryBlockCache<Id>::SMemoryCacheType::SMemoryCacheHeap *pCacheHeap = nullptr;
auto &Heaps = MemoryCache.m_MemoryCaches.m_vpMemoryHeaps; auto &Heaps = MemoryCache.m_MemoryCaches.m_vpMemoryHeaps;
for(size_t i = 0; i < Heaps.size(); ++i) for(size_t i = 0; i < Heaps.size(); ++i)
{ {
@ -1626,7 +1626,7 @@ protected:
} }
if(!FoundAllocation) if(!FoundAllocation)
{ {
typename SMemoryBlockCache<ID>::SMemoryCacheType::SMemoryCacheHeap *pNewHeap = new typename SMemoryBlockCache<ID>::SMemoryCacheType::SMemoryCacheHeap(); typename SMemoryBlockCache<Id>::SMemoryCacheType::SMemoryCacheHeap *pNewHeap = new typename SMemoryBlockCache<Id>::SMemoryCacheType::SMemoryCacheHeap();
VkBuffer TmpBuffer; VkBuffer TmpBuffer;
if(!GetBufferImpl(MemoryBlockSize * BlockCount, RequiresMapping ? MEMORY_BLOCK_USAGE_STAGING : MEMORY_BLOCK_USAGE_BUFFER, TmpBuffer, TmpBufferMemory, BufferUsage, BufferProperties)) if(!GetBufferImpl(MemoryBlockSize * BlockCount, RequiresMapping ? MEMORY_BLOCK_USAGE_STAGING : MEMORY_BLOCK_USAGE_BUFFER, TmpBuffer, TmpBufferMemory, BufferUsage, BufferProperties))
@ -1712,18 +1712,18 @@ protected:
return Res; return Res;
} }
[[nodiscard]] bool GetStagingBuffer(SMemoryBlock<s_StagingBufferCacheID> &ResBlock, const void *pBufferData, VkDeviceSize RequiredSize) [[nodiscard]] bool GetStagingBuffer(SMemoryBlock<s_StagingBufferCacheId> &ResBlock, const void *pBufferData, VkDeviceSize RequiredSize)
{ {
return GetBufferBlockImpl<s_StagingBufferCacheID, 8 * 1024 * 1024, 3, true>(ResBlock, m_StagingBufferCache, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT, pBufferData, RequiredSize, maximum<VkDeviceSize>(m_NonCoherentMemAlignment, 16)); return GetBufferBlockImpl<s_StagingBufferCacheId, 8 * 1024 * 1024, 3, true>(ResBlock, m_StagingBufferCache, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT, pBufferData, RequiredSize, maximum<VkDeviceSize>(m_NonCoherentMemAlignment, 16));
} }
[[nodiscard]] bool GetStagingBufferImage(SMemoryBlock<s_StagingBufferImageCacheID> &ResBlock, const void *pBufferData, VkDeviceSize RequiredSize) [[nodiscard]] bool GetStagingBufferImage(SMemoryBlock<s_StagingBufferImageCacheId> &ResBlock, const void *pBufferData, VkDeviceSize RequiredSize)
{ {
return GetBufferBlockImpl<s_StagingBufferImageCacheID, 8 * 1024 * 1024, 3, true>(ResBlock, m_StagingBufferCacheImage, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT, pBufferData, RequiredSize, maximum<VkDeviceSize>(m_OptimalImageCopyMemAlignment, maximum<VkDeviceSize>(m_NonCoherentMemAlignment, 16))); return GetBufferBlockImpl<s_StagingBufferImageCacheId, 8 * 1024 * 1024, 3, true>(ResBlock, m_StagingBufferCacheImage, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT, pBufferData, RequiredSize, maximum<VkDeviceSize>(m_OptimalImageCopyMemAlignment, maximum<VkDeviceSize>(m_NonCoherentMemAlignment, 16)));
} }
template<size_t ID> template<size_t Id>
void PrepareStagingMemRange(SMemoryBlock<ID> &Block) void PrepareStagingMemRange(SMemoryBlock<Id> &Block)
{ {
VkMappedMemoryRange UploadRange{}; VkMappedMemoryRange UploadRange{};
UploadRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; UploadRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
@ -1742,7 +1742,7 @@ protected:
m_vNonFlushedStagingBufferRange.push_back(UploadRange); m_vNonFlushedStagingBufferRange.push_back(UploadRange);
} }
void UploadAndFreeStagingMemBlock(SMemoryBlock<s_StagingBufferCacheID> &Block) void UploadAndFreeStagingMemBlock(SMemoryBlock<s_StagingBufferCacheId> &Block)
{ {
PrepareStagingMemRange(Block); PrepareStagingMemRange(Block);
if(!Block.m_IsCached) if(!Block.m_IsCached)
@ -1755,7 +1755,7 @@ protected:
} }
} }
void UploadAndFreeStagingImageMemBlock(SMemoryBlock<s_StagingBufferImageCacheID> &Block) void UploadAndFreeStagingImageMemBlock(SMemoryBlock<s_StagingBufferImageCacheId> &Block)
{ {
PrepareStagingMemRange(Block); PrepareStagingMemRange(Block);
if(!Block.m_IsCached) if(!Block.m_IsCached)
@ -1768,12 +1768,12 @@ protected:
} }
} }
[[nodiscard]] bool GetVertexBuffer(SMemoryBlock<s_VertexBufferCacheID> &ResBlock, VkDeviceSize RequiredSize) [[nodiscard]] bool GetVertexBuffer(SMemoryBlock<s_VertexBufferCacheId> &ResBlock, VkDeviceSize RequiredSize)
{ {
return GetBufferBlockImpl<s_VertexBufferCacheID, 8 * 1024 * 1024, 3, false>(ResBlock, m_VertexBufferCache, VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, nullptr, RequiredSize, 16); return GetBufferBlockImpl<s_VertexBufferCacheId, 8 * 1024 * 1024, 3, false>(ResBlock, m_VertexBufferCache, VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, nullptr, RequiredSize, 16);
} }
void FreeVertexMemBlock(SMemoryBlock<s_VertexBufferCacheID> &Block) void FreeVertexMemBlock(SMemoryBlock<s_VertexBufferCacheId> &Block)
{ {
if(!Block.m_IsCached) if(!Block.m_IsCached)
{ {
@ -1825,15 +1825,15 @@ protected:
return true; return true;
} }
template<size_t ID, template<size_t Id,
int64_t MemoryBlockSize, size_t BlockCount> int64_t MemoryBlockSize, size_t BlockCount>
[[nodiscard]] bool GetImageMemoryBlockImpl(SMemoryImageBlock<ID> &RetBlock, SMemoryBlockCache<ID> &MemoryCache, VkMemoryPropertyFlags BufferProperties, VkDeviceSize RequiredSize, VkDeviceSize RequiredAlignment, uint32_t RequiredMemoryTypeBits) [[nodiscard]] bool GetImageMemoryBlockImpl(SMemoryImageBlock<Id> &RetBlock, SMemoryBlockCache<Id> &MemoryCache, VkMemoryPropertyFlags BufferProperties, VkDeviceSize RequiredSize, VkDeviceSize RequiredAlignment, uint32_t RequiredMemoryTypeBits)
{ {
auto &&CreateCacheBlock = [&]() -> bool { auto &&CreateCacheBlock = [&]() -> bool {
bool FoundAllocation = false; bool FoundAllocation = false;
SMemoryHeap::SMemoryHeapQueueElement AllocatedMem; SMemoryHeap::SMemoryHeapQueueElement AllocatedMem;
SDeviceMemoryBlock TmpBufferMemory; SDeviceMemoryBlock TmpBufferMemory;
typename SMemoryBlockCache<ID>::SMemoryCacheType::SMemoryCacheHeap *pCacheHeap = nullptr; typename SMemoryBlockCache<Id>::SMemoryCacheType::SMemoryCacheHeap *pCacheHeap = nullptr;
for(size_t i = 0; i < MemoryCache.m_MemoryCaches.m_vpMemoryHeaps.size(); ++i) for(size_t i = 0; i < MemoryCache.m_MemoryCaches.m_vpMemoryHeaps.size(); ++i)
{ {
auto *pHeap = MemoryCache.m_MemoryCaches.m_vpMemoryHeaps[i]; auto *pHeap = MemoryCache.m_MemoryCaches.m_vpMemoryHeaps[i];
@ -1847,7 +1847,7 @@ protected:
} }
if(!FoundAllocation) if(!FoundAllocation)
{ {
typename SMemoryBlockCache<ID>::SMemoryCacheType::SMemoryCacheHeap *pNewHeap = new typename SMemoryBlockCache<ID>::SMemoryCacheType::SMemoryCacheHeap(); typename SMemoryBlockCache<Id>::SMemoryCacheType::SMemoryCacheHeap *pNewHeap = new typename SMemoryBlockCache<Id>::SMemoryCacheType::SMemoryCacheHeap();
if(!GetImageMemoryImpl(MemoryBlockSize * BlockCount, RequiredMemoryTypeBits, TmpBufferMemory, BufferProperties)) if(!GetImageMemoryImpl(MemoryBlockSize * BlockCount, RequiredMemoryTypeBits, TmpBufferMemory, BufferProperties))
{ {
@ -1907,7 +1907,7 @@ protected:
return true; return true;
} }
[[nodiscard]] bool GetImageMemory(SMemoryImageBlock<s_ImageBufferCacheID> &RetBlock, VkDeviceSize RequiredSize, VkDeviceSize RequiredAlignment, uint32_t RequiredMemoryTypeBits) [[nodiscard]] bool GetImageMemory(SMemoryImageBlock<s_ImageBufferCacheId> &RetBlock, VkDeviceSize RequiredSize, VkDeviceSize RequiredAlignment, uint32_t RequiredMemoryTypeBits)
{ {
auto it = m_ImageBufferCaches.find(RequiredMemoryTypeBits); auto it = m_ImageBufferCaches.find(RequiredMemoryTypeBits);
if(it == m_ImageBufferCaches.end()) if(it == m_ImageBufferCaches.end())
@ -1916,10 +1916,10 @@ protected:
it->second.Init(m_SwapChainImageCount); it->second.Init(m_SwapChainImageCount);
} }
return GetImageMemoryBlockImpl<s_ImageBufferCacheID, s_1024x1024ImgSize, 2>(RetBlock, it->second, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, RequiredSize, RequiredAlignment, RequiredMemoryTypeBits); return GetImageMemoryBlockImpl<s_ImageBufferCacheId, s_1024x1024ImgSize, 2>(RetBlock, it->second, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, RequiredSize, RequiredAlignment, RequiredMemoryTypeBits);
} }
void FreeImageMemBlock(SMemoryImageBlock<s_ImageBufferCacheID> &Block) void FreeImageMemBlock(SMemoryImageBlock<s_ImageBufferCacheId> &Block)
{ {
if(!Block.m_IsCached) if(!Block.m_IsCached)
{ {
@ -2531,7 +2531,7 @@ protected:
[[nodiscard]] bool UpdateTexture(size_t TextureSlot, VkFormat Format, void *&pData, int64_t XOff, int64_t YOff, size_t Width, size_t Height) [[nodiscard]] bool UpdateTexture(size_t TextureSlot, VkFormat Format, void *&pData, int64_t XOff, int64_t YOff, size_t Width, size_t Height)
{ {
const size_t ImageSize = Width * Height * VulkanFormatToPixelSize(Format); const size_t ImageSize = Width * Height * VulkanFormatToPixelSize(Format);
SMemoryBlock<s_StagingBufferImageCacheID> StagingBuffer; SMemoryBlock<s_StagingBufferImageCacheId> StagingBuffer;
if(!GetStagingBufferImage(StagingBuffer, pData, ImageSize)) if(!GetStagingBufferImage(StagingBuffer, pData, ImageSize))
return false; return false;
@ -2793,11 +2793,11 @@ protected:
return true; return true;
} }
[[nodiscard]] bool CreateTextureImage(size_t ImageIndex, VkImage &NewImage, SMemoryImageBlock<s_ImageBufferCacheID> &NewImgMem, const void *pData, VkFormat Format, size_t Width, size_t Height, size_t Depth, size_t PixelSize, size_t MipMapLevelCount) [[nodiscard]] bool CreateTextureImage(size_t ImageIndex, VkImage &NewImage, SMemoryImageBlock<s_ImageBufferCacheId> &NewImgMem, const void *pData, VkFormat Format, size_t Width, size_t Height, size_t Depth, size_t PixelSize, size_t MipMapLevelCount)
{ {
int ImageSize = Width * Height * Depth * PixelSize; int ImageSize = Width * Height * Depth * PixelSize;
SMemoryBlock<s_StagingBufferImageCacheID> StagingBuffer; SMemoryBlock<s_StagingBufferImageCacheId> StagingBuffer;
if(!GetStagingBufferImage(StagingBuffer, pData, ImageSize)) if(!GetStagingBufferImage(StagingBuffer, pData, ImageSize))
return false; return false;
@ -2903,7 +2903,7 @@ protected:
return ImageView; return ImageView;
} }
[[nodiscard]] bool CreateImage(uint32_t Width, uint32_t Height, uint32_t Depth, size_t MipMapLevelCount, VkFormat Format, VkImageTiling Tiling, VkImage &Image, SMemoryImageBlock<s_ImageBufferCacheID> &ImageMemory, VkImageUsageFlags ImageUsage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT) [[nodiscard]] bool CreateImage(uint32_t Width, uint32_t Height, uint32_t Depth, size_t MipMapLevelCount, VkFormat Format, VkImageTiling Tiling, VkImage &Image, SMemoryImageBlock<s_ImageBufferCacheId> &ImageMemory, VkImageUsageFlags ImageUsage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT)
{ {
VkImageCreateInfo ImageInfo{}; VkImageCreateInfo ImageInfo{};
ImageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; ImageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
@ -3088,11 +3088,11 @@ protected:
size_t BufferOffset = 0; size_t BufferOffset = 0;
if(!IsOneFrameBuffer) if(!IsOneFrameBuffer)
{ {
SMemoryBlock<s_StagingBufferCacheID> StagingBuffer; SMemoryBlock<s_StagingBufferCacheId> StagingBuffer;
if(!GetStagingBuffer(StagingBuffer, pUploadData, BufferDataSize)) if(!GetStagingBuffer(StagingBuffer, pUploadData, BufferDataSize))
return false; return false;
SMemoryBlock<s_VertexBufferCacheID> Mem; SMemoryBlock<s_VertexBufferCacheId> Mem;
if(!GetVertexBuffer(Mem, BufferDataSize)) if(!GetVertexBuffer(Mem, BufferDataSize))
return false; return false;
@ -3653,25 +3653,25 @@ public:
return true; return true;
} }
STWGraphicGPU::ETWGraphicsGPUType VKGPUTypeToGraphicsGPUType(VkPhysicalDeviceType VKGPUType) STWGraphicGpu::ETWGraphicsGpuType VKGPUTypeToGraphicsGpuType(VkPhysicalDeviceType VKGPUType)
{ {
if(VKGPUType == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) if(VKGPUType == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
return STWGraphicGPU::ETWGraphicsGPUType::GRAPHICS_GPU_TYPE_DISCRETE; return STWGraphicGpu::ETWGraphicsGpuType::GRAPHICS_GPU_TYPE_DISCRETE;
else if(VKGPUType == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU) else if(VKGPUType == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU)
return STWGraphicGPU::ETWGraphicsGPUType::GRAPHICS_GPU_TYPE_INTEGRATED; return STWGraphicGpu::ETWGraphicsGpuType::GRAPHICS_GPU_TYPE_INTEGRATED;
else if(VKGPUType == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU) else if(VKGPUType == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU)
return STWGraphicGPU::ETWGraphicsGPUType::GRAPHICS_GPU_TYPE_VIRTUAL; return STWGraphicGpu::ETWGraphicsGpuType::GRAPHICS_GPU_TYPE_VIRTUAL;
else if(VKGPUType == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_CPU) else if(VKGPUType == VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_CPU)
return STWGraphicGPU::ETWGraphicsGPUType::GRAPHICS_GPU_TYPE_CPU; return STWGraphicGpu::ETWGraphicsGpuType::GRAPHICS_GPU_TYPE_CPU;
return STWGraphicGPU::ETWGraphicsGPUType::GRAPHICS_GPU_TYPE_CPU; return STWGraphicGpu::ETWGraphicsGpuType::GRAPHICS_GPU_TYPE_CPU;
} }
// from: https://github.com/SaschaWillems/vulkan.gpuinfo.org/blob/5c3986798afc39d736b825bf8a5fbf92b8d9ed49/includes/functions.php#L364 // from: https://github.com/SaschaWillems/vulkan.gpuinfo.org/blob/5c3986798afc39d736b825bf8a5fbf92b8d9ed49/includes/functions.php#L364
const char *GetDriverVerson(char (&aBuff)[256], uint32_t DriverVersion, uint32_t VendorID) const char *GetDriverVerson(char (&aBuff)[256], uint32_t DriverVersion, uint32_t VendorId)
{ {
// NVIDIA // NVIDIA
if(VendorID == 4318) if(VendorId == 4318)
{ {
str_format(aBuff, std::size(aBuff), "%d.%d.%d.%d", str_format(aBuff, std::size(aBuff), "%d.%d.%d.%d",
(DriverVersion >> 22) & 0x3ff, (DriverVersion >> 22) & 0x3ff,
@ -3681,7 +3681,7 @@ public:
} }
#ifdef CONF_FAMILY_WINDOWS #ifdef CONF_FAMILY_WINDOWS
// windows only // windows only
else if(VendorID == 0x8086) else if(VendorId == 0x8086)
{ {
str_format(aBuff, std::size(aBuff), str_format(aBuff, std::size(aBuff),
"%d.%d", "%d.%d",
@ -3702,7 +3702,7 @@ public:
return aBuff; return aBuff;
} }
[[nodiscard]] bool SelectGPU(char *pRendererName, char *pVendorName, char *pVersionName) [[nodiscard]] bool SelectGpu(char *pRendererName, char *pVendorName, char *pVersionName)
{ {
uint32_t DevicesCount = 0; uint32_t DevicesCount = 0;
auto Res = vkEnumeratePhysicalDevices(m_VKInstance, &DevicesCount, nullptr); auto Res = vkEnumeratePhysicalDevices(m_VKInstance, &DevicesCount, nullptr);
@ -3736,14 +3736,14 @@ public:
size_t Index = 0; size_t Index = 0;
std::vector<VkPhysicalDeviceProperties> vDevicePropList(vDeviceList.size()); std::vector<VkPhysicalDeviceProperties> vDevicePropList(vDeviceList.size());
m_pGPUList->m_vGPUs.reserve(vDeviceList.size()); m_pGpuList->m_vGpus.reserve(vDeviceList.size());
size_t FoundDeviceIndex = 0; size_t FoundDeviceIndex = 0;
size_t FoundGPUType = STWGraphicGPU::ETWGraphicsGPUType::GRAPHICS_GPU_TYPE_INVALID; size_t FoundGpuType = STWGraphicGpu::ETWGraphicsGpuType::GRAPHICS_GPU_TYPE_INVALID;
STWGraphicGPU::ETWGraphicsGPUType AutoGPUType = STWGraphicGPU::ETWGraphicsGPUType::GRAPHICS_GPU_TYPE_INVALID; STWGraphicGpu::ETWGraphicsGpuType AutoGpuType = STWGraphicGpu::ETWGraphicsGpuType::GRAPHICS_GPU_TYPE_INVALID;
bool IsAutoGPU = str_comp(g_Config.m_GfxGPUName, "auto") == 0; bool IsAutoGpu = str_comp(g_Config.m_GfxGpuName, "auto") == 0;
for(auto &CurDevice : vDeviceList) for(auto &CurDevice : vDeviceList)
{ {
@ -3751,30 +3751,30 @@ public:
auto &DeviceProp = vDevicePropList[Index]; auto &DeviceProp = vDevicePropList[Index];
STWGraphicGPU::ETWGraphicsGPUType GPUType = VKGPUTypeToGraphicsGPUType(DeviceProp.deviceType); STWGraphicGpu::ETWGraphicsGpuType GPUType = VKGPUTypeToGraphicsGpuType(DeviceProp.deviceType);
STWGraphicGPU::STWGraphicGPUItem NewGPU; STWGraphicGpu::STWGraphicGpuItem NewGpu;
str_copy(NewGPU.m_aName, DeviceProp.deviceName); str_copy(NewGpu.m_aName, DeviceProp.deviceName);
NewGPU.m_GPUType = GPUType; NewGpu.m_GpuType = GPUType;
m_pGPUList->m_vGPUs.push_back(NewGPU); m_pGpuList->m_vGpus.push_back(NewGpu);
Index++; Index++;
int DevAPIMajor = (int)VK_API_VERSION_MAJOR(DeviceProp.apiVersion); int DevAPIMajor = (int)VK_API_VERSION_MAJOR(DeviceProp.apiVersion);
int DevAPIMinor = (int)VK_API_VERSION_MINOR(DeviceProp.apiVersion); int DevAPIMinor = (int)VK_API_VERSION_MINOR(DeviceProp.apiVersion);
if(GPUType < AutoGPUType && (DevAPIMajor > gs_BackendVulkanMajor || (DevAPIMajor == gs_BackendVulkanMajor && DevAPIMinor >= gs_BackendVulkanMinor))) if(GPUType < AutoGpuType && (DevAPIMajor > gs_BackendVulkanMajor || (DevAPIMajor == gs_BackendVulkanMajor && DevAPIMinor >= gs_BackendVulkanMinor)))
{ {
str_copy(m_pGPUList->m_AutoGPU.m_aName, DeviceProp.deviceName); str_copy(m_pGpuList->m_AutoGpu.m_aName, DeviceProp.deviceName);
m_pGPUList->m_AutoGPU.m_GPUType = GPUType; m_pGpuList->m_AutoGpu.m_GpuType = GPUType;
AutoGPUType = GPUType; AutoGpuType = GPUType;
} }
if(((IsAutoGPU && (FoundGPUType > STWGraphicGPU::ETWGraphicsGPUType::GRAPHICS_GPU_TYPE_INTEGRATED && GPUType < FoundGPUType)) || str_comp(DeviceProp.deviceName, g_Config.m_GfxGPUName) == 0) && (DevAPIMajor > gs_BackendVulkanMajor || (DevAPIMajor == gs_BackendVulkanMajor && DevAPIMinor >= gs_BackendVulkanMinor))) if(((IsAutoGpu && (FoundGpuType > STWGraphicGpu::ETWGraphicsGpuType::GRAPHICS_GPU_TYPE_INTEGRATED && GPUType < FoundGpuType)) || str_comp(DeviceProp.deviceName, g_Config.m_GfxGpuName) == 0) && (DevAPIMajor > gs_BackendVulkanMajor || (DevAPIMajor == gs_BackendVulkanMajor && DevAPIMinor >= gs_BackendVulkanMinor)))
{ {
FoundDeviceIndex = Index; FoundDeviceIndex = Index;
FoundGPUType = GPUType; FoundGpuType = GPUType;
} }
} }
@ -3788,7 +3788,7 @@ public:
int DevAPIMinor = (int)VK_API_VERSION_MINOR(DeviceProp.apiVersion); int DevAPIMinor = (int)VK_API_VERSION_MINOR(DeviceProp.apiVersion);
int DevAPIPatch = (int)VK_API_VERSION_PATCH(DeviceProp.apiVersion); int DevAPIPatch = (int)VK_API_VERSION_PATCH(DeviceProp.apiVersion);
str_copy(pRendererName, DeviceProp.deviceName, gs_GPUInfoStringSize); str_copy(pRendererName, DeviceProp.deviceName, gs_GpuInfoStringSize);
const char *pVendorNameStr = NULL; const char *pVendorNameStr = NULL;
switch(DeviceProp.vendorID) switch(DeviceProp.vendorID)
{ {
@ -3823,8 +3823,8 @@ public:
} }
char aBuff[256]; char aBuff[256];
str_copy(pVendorName, pVendorNameStr, gs_GPUInfoStringSize); str_copy(pVendorName, pVendorNameStr, gs_GpuInfoStringSize);
str_format(pVersionName, gs_GPUInfoStringSize, "Vulkan %d.%d.%d (driver: %s)", DevAPIMajor, DevAPIMinor, DevAPIPatch, GetDriverVerson(aBuff, DeviceProp.driverVersion, DeviceProp.vendorID)); str_format(pVersionName, gs_GpuInfoStringSize, "Vulkan %d.%d.%d (driver: %s)", DevAPIMajor, DevAPIMinor, DevAPIPatch, GetDriverVerson(aBuff, DeviceProp.driverVersion, DeviceProp.vendorID));
// get important device limits // get important device limits
m_NonCoherentMemAlignment = DeviceProp.limits.nonCoherentAtomSize; m_NonCoherentMemAlignment = DeviceProp.limits.nonCoherentAtomSize;
@ -5606,7 +5606,7 @@ public:
} }
} }
if(!SelectGPU(pRendererString, pVendorString, pVersionString)) if(!SelectGpu(pRendererString, pVendorString, pVersionString))
return -1; return -1;
if(!CreateLogicalDevice(vVKLayers)) if(!CreateLogicalDevice(vVKLayers))
@ -6393,7 +6393,7 @@ public:
{ {
VkDeviceSize BufferDataSize = DataSize; VkDeviceSize BufferDataSize = DataSize;
SMemoryBlock<s_StagingBufferCacheID> StagingBuffer; SMemoryBlock<s_StagingBufferCacheId> StagingBuffer;
if(!GetStagingBuffer(StagingBuffer, pData, DataSize)) if(!GetStagingBuffer(StagingBuffer, pData, DataSize))
return false; return false;
@ -6945,7 +6945,7 @@ public:
void *pUploadData = pCommand->m_pUploadData; void *pUploadData = pCommand->m_pUploadData;
VkDeviceSize DataSize = (VkDeviceSize)pCommand->m_DataSize; VkDeviceSize DataSize = (VkDeviceSize)pCommand->m_DataSize;
SMemoryBlock<s_StagingBufferCacheID> StagingBuffer; SMemoryBlock<s_StagingBufferCacheId> StagingBuffer;
if(!GetStagingBuffer(StagingBuffer, pUploadData, DataSize)) if(!GetStagingBuffer(StagingBuffer, pUploadData, DataSize))
return false; return false;
@ -7490,7 +7490,7 @@ public:
[[nodiscard]] bool Cmd_WindowCreateNtf(const CCommandBuffer::SCommand_WindowCreateNtf *pCommand) [[nodiscard]] bool Cmd_WindowCreateNtf(const CCommandBuffer::SCommand_WindowCreateNtf *pCommand)
{ {
log_debug("vulkan", "creating new surface."); log_debug("vulkan", "creating new surface.");
m_pWindow = SDL_GetWindowFromID(pCommand->m_WindowID); m_pWindow = SDL_GetWindowFromID(pCommand->m_WindowId);
if(m_RenderingPaused) if(m_RenderingPaused)
{ {
#ifdef CONF_PLATFORM_ANDROID #ifdef CONF_PLATFORM_ANDROID
@ -7527,7 +7527,7 @@ public:
[[nodiscard]] bool Cmd_PreInit(const CCommandProcessorFragment_GLBase::SCommand_PreInit *pCommand) [[nodiscard]] bool Cmd_PreInit(const CCommandProcessorFragment_GLBase::SCommand_PreInit *pCommand)
{ {
m_pGPUList = pCommand->m_pGPUList; m_pGpuList = pCommand->m_pGpuList;
if(InitVulkanSDL(pCommand->m_pWindow, pCommand->m_Width, pCommand->m_Height, pCommand->m_pRendererString, pCommand->m_pVendorString, pCommand->m_pVersionString) != 0) if(InitVulkanSDL(pCommand->m_pWindow, pCommand->m_Width, pCommand->m_Height, pCommand->m_pRendererString, pCommand->m_pVendorString, pCommand->m_pVersionString) != 0)
{ {
m_VKInstance = VK_NULL_HANDLE; m_VKInstance = VK_NULL_HANDLE;

View file

@ -226,7 +226,7 @@ void CCommandProcessorFragment_SDL::Cmd_VSync(const CCommandBuffer::SCommand_VSy
void CCommandProcessorFragment_SDL::Cmd_WindowCreateNtf(const CCommandBuffer::SCommand_WindowCreateNtf *pCommand) void CCommandProcessorFragment_SDL::Cmd_WindowCreateNtf(const CCommandBuffer::SCommand_WindowCreateNtf *pCommand)
{ {
m_pWindow = SDL_GetWindowFromID(pCommand->m_WindowID); m_pWindow = SDL_GetWindowFromID(pCommand->m_WindowId);
// Android destroys windows when they are not visible, so we get the new one and work with that // Android destroys windows when they are not visible, so we get the new one and work with that
// The graphic context does not need to be recreated, just unbound see @see SCommand_WindowDestroyNtf // The graphic context does not need to be recreated, just unbound see @see SCommand_WindowDestroyNtf
#ifdef CONF_PLATFORM_ANDROID #ifdef CONF_PLATFORM_ANDROID
@ -900,10 +900,10 @@ static void DisplayToVideoMode(CVideoMode *pVMode, SDL_DisplayMode *pMode, int H
pVMode->m_Format = pMode->format; pVMode->m_Format = pMode->format;
} }
void CGraphicsBackend_SDL_GL::GetVideoModes(CVideoMode *pModes, int MaxModes, int *pNumModes, int HiDPIScale, int MaxWindowWidth, int MaxWindowHeight, int ScreenID) void CGraphicsBackend_SDL_GL::GetVideoModes(CVideoMode *pModes, int MaxModes, int *pNumModes, int HiDPIScale, int MaxWindowWidth, int MaxWindowHeight, int ScreenId)
{ {
SDL_DisplayMode DesktopMode; SDL_DisplayMode DesktopMode;
int maxModes = SDL_GetNumDisplayModes(ScreenID); int maxModes = SDL_GetNumDisplayModes(ScreenId);
int numModes = 0; int numModes = 0;
// Only collect fullscreen modes when requested, that makes sure in windowed mode no refresh rates are shown that aren't supported without // Only collect fullscreen modes when requested, that makes sure in windowed mode no refresh rates are shown that aren't supported without
@ -911,7 +911,7 @@ void CGraphicsBackend_SDL_GL::GetVideoModes(CVideoMode *pModes, int MaxModes, in
bool IsFullscreenDestkop = m_pWindow != NULL && (((SDL_GetWindowFlags(m_pWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) || g_Config.m_GfxFullscreen == 3); bool IsFullscreenDestkop = m_pWindow != NULL && (((SDL_GetWindowFlags(m_pWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) || g_Config.m_GfxFullscreen == 3);
bool CollectFullscreenModes = m_pWindow == NULL || ((SDL_GetWindowFlags(m_pWindow) & SDL_WINDOW_FULLSCREEN) != 0 && !IsFullscreenDestkop); bool CollectFullscreenModes = m_pWindow == NULL || ((SDL_GetWindowFlags(m_pWindow) & SDL_WINDOW_FULLSCREEN) != 0 && !IsFullscreenDestkop);
if(SDL_GetDesktopDisplayMode(ScreenID, &DesktopMode) < 0) if(SDL_GetDesktopDisplayMode(ScreenId, &DesktopMode) < 0)
{ {
dbg_msg("gfx", "unable to get display mode: %s", SDL_GetError()); dbg_msg("gfx", "unable to get display mode: %s", SDL_GetError());
} }
@ -922,7 +922,7 @@ void CGraphicsBackend_SDL_GL::GetVideoModes(CVideoMode *pModes, int MaxModes, in
for(int i = 0; i < maxModes && NumModes < ModeCount; i++) for(int i = 0; i < maxModes && NumModes < ModeCount; i++)
{ {
SDL_DisplayMode mode; SDL_DisplayMode mode;
if(SDL_GetDisplayMode(ScreenID, i, &mode) < 0) if(SDL_GetDisplayMode(ScreenId, i, &mode) < 0)
{ {
dbg_msg("gfx", "unable to get display mode: %s", SDL_GetError()); dbg_msg("gfx", "unable to get display mode: %s", SDL_GetError());
continue; continue;
@ -964,20 +964,20 @@ void CGraphicsBackend_SDL_GL::GetVideoModes(CVideoMode *pModes, int MaxModes, in
*pNumModes = numModes; *pNumModes = numModes;
} }
void CGraphicsBackend_SDL_GL::GetCurrentVideoMode(CVideoMode &CurMode, int HiDPIScale, int MaxWindowWidth, int MaxWindowHeight, int ScreenID) void CGraphicsBackend_SDL_GL::GetCurrentVideoMode(CVideoMode &CurMode, int HiDPIScale, int MaxWindowWidth, int MaxWindowHeight, int ScreenId)
{ {
SDL_DisplayMode DPMode; SDL_DisplayMode DpMode;
// if "real" fullscreen, obtain the video mode for that // if "real" fullscreen, obtain the video mode for that
if((SDL_GetWindowFlags(m_pWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN) if((SDL_GetWindowFlags(m_pWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN)
{ {
if(SDL_GetCurrentDisplayMode(ScreenID, &DPMode)) if(SDL_GetCurrentDisplayMode(ScreenId, &DpMode))
{ {
dbg_msg("gfx", "unable to get display mode: %s", SDL_GetError()); dbg_msg("gfx", "unable to get display mode: %s", SDL_GetError());
} }
} }
else else
{ {
if(SDL_GetDesktopDisplayMode(ScreenID, &DPMode) < 0) if(SDL_GetDesktopDisplayMode(ScreenId, &DpMode) < 0)
{ {
dbg_msg("gfx", "unable to get display mode: %s", SDL_GetError()); dbg_msg("gfx", "unable to get display mode: %s", SDL_GetError());
} }
@ -986,11 +986,11 @@ void CGraphicsBackend_SDL_GL::GetCurrentVideoMode(CVideoMode &CurMode, int HiDPI
int Width = 0; int Width = 0;
int Height = 0; int Height = 0;
SDL_GL_GetDrawableSize(m_pWindow, &Width, &Height); SDL_GL_GetDrawableSize(m_pWindow, &Width, &Height);
DPMode.w = Width; DpMode.w = Width;
DPMode.h = Height; DpMode.h = Height;
} }
} }
DisplayToVideoMode(&CurMode, &DPMode, HiDPIScale, DPMode.refresh_rate); DisplayToVideoMode(&CurMode, &DpMode, HiDPIScale, DpMode.refresh_rate);
} }
CGraphicsBackend_SDL_GL::CGraphicsBackend_SDL_GL(TTranslateFunc &&TranslateFunc) : CGraphicsBackend_SDL_GL::CGraphicsBackend_SDL_GL(TTranslateFunc &&TranslateFunc) :
@ -1275,7 +1275,7 @@ int CGraphicsBackend_SDL_GL::Init(const char *pName, int *pScreen, int *pWidth,
CmdPre.m_pVendorString = m_aVendorString; CmdPre.m_pVendorString = m_aVendorString;
CmdPre.m_pVersionString = m_aVersionString; CmdPre.m_pVersionString = m_aVersionString;
CmdPre.m_pRendererString = m_aRendererString; CmdPre.m_pRendererString = m_aRendererString;
CmdPre.m_pGPUList = &m_GPUList; CmdPre.m_pGpuList = &m_GpuList;
CmdBuffer.AddCommandUnsafe(CmdPre); CmdBuffer.AddCommandUnsafe(CmdPre);
RunBufferSingleThreadedUnsafe(&CmdBuffer); RunBufferSingleThreadedUnsafe(&CmdBuffer);
CmdBuffer.Reset(); CmdBuffer.Reset();
@ -1299,7 +1299,7 @@ int CGraphicsBackend_SDL_GL::Init(const char *pName, int *pScreen, int *pWidth,
CmdGL.m_pBufferMemoryUsage = &m_BufferMemoryUsage; CmdGL.m_pBufferMemoryUsage = &m_BufferMemoryUsage;
CmdGL.m_pStreamMemoryUsage = &m_StreamMemoryUsage; CmdGL.m_pStreamMemoryUsage = &m_StreamMemoryUsage;
CmdGL.m_pStagingMemoryUsage = &m_StagingMemoryUsage; CmdGL.m_pStagingMemoryUsage = &m_StagingMemoryUsage;
CmdGL.m_pGPUList = &m_GPUList; CmdGL.m_pGpuList = &m_GpuList;
CmdGL.m_pReadPresentedImageDataFunc = &m_ReadPresentedImageDataFunc; CmdGL.m_pReadPresentedImageDataFunc = &m_ReadPresentedImageDataFunc;
CmdGL.m_pStorage = pStorage; CmdGL.m_pStorage = pStorage;
CmdGL.m_pCapabilities = &m_Capabilites; CmdGL.m_pCapabilities = &m_Capabilites;
@ -1444,9 +1444,9 @@ uint64_t CGraphicsBackend_SDL_GL::StagingMemoryUsage() const
return m_StagingMemoryUsage; return m_StagingMemoryUsage;
} }
const TTWGraphicsGPUList &CGraphicsBackend_SDL_GL::GetGPUs() const const TTwGraphicsGpuList &CGraphicsBackend_SDL_GL::GetGpus() const
{ {
return m_GPUList; return m_GpuList;
} }
void CGraphicsBackend_SDL_GL::Minimize() void CGraphicsBackend_SDL_GL::Minimize()
@ -1488,14 +1488,14 @@ void CGraphicsBackend_SDL_GL::SetWindowParams(int FullscreenMode, bool IsBorderl
SDL_SetWindowFullscreen(m_pWindow, 0); SDL_SetWindowFullscreen(m_pWindow, 0);
SDL_SetWindowBordered(m_pWindow, SDL_TRUE); SDL_SetWindowBordered(m_pWindow, SDL_TRUE);
SDL_SetWindowResizable(m_pWindow, SDL_FALSE); SDL_SetWindowResizable(m_pWindow, SDL_FALSE);
SDL_DisplayMode DPMode; SDL_DisplayMode DpMode;
if(SDL_GetDesktopDisplayMode(g_Config.m_GfxScreen, &DPMode) < 0) if(SDL_GetDesktopDisplayMode(g_Config.m_GfxScreen, &DpMode) < 0)
{ {
dbg_msg("gfx", "unable to get display mode: %s", SDL_GetError()); dbg_msg("gfx", "unable to get display mode: %s", SDL_GetError());
} }
else else
{ {
ResizeWindow(DPMode.w, DPMode.h, DPMode.refresh_rate); ResizeWindow(DpMode.w, DpMode.h, DpMode.refresh_rate);
SDL_SetWindowPosition(m_pWindow, SDL_WINDOWPOS_CENTERED_DISPLAY(g_Config.m_GfxScreen), SDL_WINDOWPOS_CENTERED_DISPLAY(g_Config.m_GfxScreen)); SDL_SetWindowPosition(m_pWindow, SDL_WINDOWPOS_CENTERED_DISPLAY(g_Config.m_GfxScreen), SDL_WINDOWPOS_CENTERED_DISPLAY(g_Config.m_GfxScreen));
} }
} }
@ -1620,13 +1620,13 @@ void CGraphicsBackend_SDL_GL::NotifyWindow()
#endif #endif
} }
void CGraphicsBackend_SDL_GL::WindowDestroyNtf(uint32_t WindowID) void CGraphicsBackend_SDL_GL::WindowDestroyNtf(uint32_t WindowId)
{ {
} }
void CGraphicsBackend_SDL_GL::WindowCreateNtf(uint32_t WindowID) void CGraphicsBackend_SDL_GL::WindowCreateNtf(uint32_t WindowId)
{ {
m_pWindow = SDL_GetWindowFromID(WindowID); m_pWindow = SDL_GetWindowFromID(WindowId);
} }
TGLBackendReadPresentedImageData &CGraphicsBackend_SDL_GL::GetReadPresentedImageDataFuncUnsafe() TGLBackendReadPresentedImageData &CGraphicsBackend_SDL_GL::GetReadPresentedImageDataFuncUnsafe()

View file

@ -198,7 +198,7 @@ public:
void HandleWarning(); void HandleWarning();
}; };
static constexpr size_t gs_GPUInfoStringSize = 256; static constexpr size_t gs_GpuInfoStringSize = 256;
// graphics backend implemented with SDL and the graphics library @see EBackendType // graphics backend implemented with SDL and the graphics library @see EBackendType
class CGraphicsBackend_SDL_GL : public CGraphicsBackend_Threaded class CGraphicsBackend_SDL_GL : public CGraphicsBackend_Threaded
@ -211,7 +211,7 @@ class CGraphicsBackend_SDL_GL : public CGraphicsBackend_Threaded
std::atomic<uint64_t> m_StreamMemoryUsage{0}; std::atomic<uint64_t> m_StreamMemoryUsage{0};
std::atomic<uint64_t> m_StagingMemoryUsage{0}; std::atomic<uint64_t> m_StagingMemoryUsage{0};
TTWGraphicsGPUList m_GPUList; TTwGraphicsGpuList m_GpuList;
TGLBackendReadPresentedImageData m_ReadPresentedImageDataFunc; TGLBackendReadPresentedImageData m_ReadPresentedImageDataFunc;
@ -219,9 +219,9 @@ class CGraphicsBackend_SDL_GL : public CGraphicsBackend_Threaded
SBackendCapabilites m_Capabilites; SBackendCapabilites m_Capabilites;
char m_aVendorString[gs_GPUInfoStringSize] = {}; char m_aVendorString[gs_GpuInfoStringSize] = {};
char m_aVersionString[gs_GPUInfoStringSize] = {}; char m_aVersionString[gs_GpuInfoStringSize] = {};
char m_aRendererString[gs_GPUInfoStringSize] = {}; char m_aRendererString[gs_GpuInfoStringSize] = {};
EBackendType m_BackendType = BACKEND_TYPE_AUTO; EBackendType m_BackendType = BACKEND_TYPE_AUTO;
@ -240,13 +240,13 @@ public:
uint64_t StreamedMemoryUsage() const override; uint64_t StreamedMemoryUsage() const override;
uint64_t StagingMemoryUsage() const override; uint64_t StagingMemoryUsage() const override;
const TTWGraphicsGPUList &GetGPUs() const override; const TTwGraphicsGpuList &GetGpus() const override;
int GetNumScreens() const override { return m_NumScreens; } int GetNumScreens() const override { return m_NumScreens; }
const char *GetScreenName(int Screen) const override; const char *GetScreenName(int Screen) const override;
void GetVideoModes(CVideoMode *pModes, int MaxModes, int *pNumModes, int HiDPIScale, int MaxWindowWidth, int MaxWindowHeight, int ScreenID) override; void GetVideoModes(CVideoMode *pModes, int MaxModes, int *pNumModes, int HiDPIScale, int MaxWindowWidth, int MaxWindowHeight, int ScreenId) override;
void GetCurrentVideoMode(CVideoMode &CurMode, int HiDPIScale, int MaxWindowWidth, int MaxWindowHeight, int ScreenID) override; void GetCurrentVideoMode(CVideoMode &CurMode, int HiDPIScale, int MaxWindowWidth, int MaxWindowHeight, int ScreenId) override;
void Minimize() override; void Minimize() override;
void Maximize() override; void Maximize() override;
@ -261,8 +261,8 @@ public:
void GetViewportSize(int &w, int &h) override; void GetViewportSize(int &w, int &h) override;
void NotifyWindow() override; void NotifyWindow() override;
void WindowDestroyNtf(uint32_t WindowID) override; void WindowDestroyNtf(uint32_t WindowId) override;
void WindowCreateNtf(uint32_t WindowID) override; void WindowCreateNtf(uint32_t WindowId) override;
bool GetDriverVersion(EGraphicsDriverAgeType DriverAgeType, int &Major, int &Minor, int &Patch, const char *&pName, EBackendType BackendType) override; bool GetDriverVersion(EGraphicsDriverAgeType DriverAgeType, int &Major, int &Minor, int &Patch, const char *&pName, EBackendType BackendType) override;
bool IsConfigModernAPI() override { return IsModernAPI(m_BackendType); } bool IsConfigModernAPI() override { return IsModernAPI(m_BackendType); }

View file

@ -98,14 +98,14 @@ CClient::CClient() :
static inline bool RepackMsg(const CMsgPacker *pMsg, CPacker &Packer) static inline bool RepackMsg(const CMsgPacker *pMsg, CPacker &Packer)
{ {
Packer.Reset(); Packer.Reset();
if(pMsg->m_MsgID < OFFSET_UUID) if(pMsg->m_MsgId < OFFSET_UUID)
{ {
Packer.AddInt((pMsg->m_MsgID << 1) | (pMsg->m_System ? 1 : 0)); Packer.AddInt((pMsg->m_MsgId << 1) | (pMsg->m_System ? 1 : 0));
} }
else else
{ {
Packer.AddInt(pMsg->m_System ? 1 : 0); // NETMSG_EX, NETMSGTYPE_EX Packer.AddInt(pMsg->m_System ? 1 : 0); // NETMSG_EX, NETMSGTYPE_EX
g_UuidManager.PackUuid(pMsg->m_MsgID, &Packer); g_UuidManager.PackUuid(pMsg->m_MsgId, &Packer);
} }
Packer.AddRaw(pMsg->Data(), pMsg->Size()); Packer.AddRaw(pMsg->Data(), pMsg->Size());
@ -125,7 +125,7 @@ int CClient::SendMsg(int Conn, CMsgPacker *pMsg, int Flags)
return 0; return 0;
mem_zero(&Packet, sizeof(CNetChunk)); mem_zero(&Packet, sizeof(CNetChunk));
Packet.m_ClientID = 0; Packet.m_ClientId = 0;
Packet.m_pData = Pack.Data(); Packet.m_pData = Pack.Data();
Packet.m_DataSize = Pack.Size(); Packet.m_DataSize = Pack.Size();
@ -157,7 +157,7 @@ int CClient::SendMsgActive(CMsgPacker *pMsg, int Flags)
void CClient::SendInfo(int Conn) void CClient::SendInfo(int Conn)
{ {
CMsgPacker MsgVer(NETMSG_CLIENTVER, true); CMsgPacker MsgVer(NETMSG_CLIENTVER, true);
MsgVer.AddRaw(&m_ConnectionID, sizeof(m_ConnectionID)); MsgVer.AddRaw(&m_ConnectionId, sizeof(m_ConnectionId));
MsgVer.AddInt(GameClient()->DDNetVersion()); MsgVer.AddInt(GameClient()->DDNetVersion());
MsgVer.AddString(GameClient()->DDNetVersionStr()); MsgVer.AddString(GameClient()->DDNetVersionStr());
SendMsg(Conn, &MsgVer, MSGFLAG_VITAL); SendMsg(Conn, &MsgVer, MSGFLAG_VITAL);
@ -445,7 +445,7 @@ void CClient::Connect(const char *pAddress, const char *pPassword)
Disconnect(); Disconnect();
dbg_assert(m_State == IClient::STATE_OFFLINE, "Disconnect must ensure that client is offline"); dbg_assert(m_State == IClient::STATE_OFFLINE, "Disconnect must ensure that client is offline");
m_ConnectionID = RandomUuid(); m_ConnectionId = RandomUuid();
if(pAddress != m_aConnectAddressStr) if(pAddress != m_aConnectAddressStr)
str_copy(m_aConnectAddressStr, pAddress); str_copy(m_aConnectAddressStr, pAddress);
@ -676,37 +676,37 @@ void CClient::LoadDebugFont()
// --- // ---
void *CClient::SnapGetItem(int SnapID, int Index, CSnapItem *pItem) const void *CClient::SnapGetItem(int SnapId, int Index, CSnapItem *pItem) const
{ {
dbg_assert(SnapID >= 0 && SnapID < NUM_SNAPSHOT_TYPES, "invalid SnapID"); dbg_assert(SnapId >= 0 && SnapId < NUM_SNAPSHOT_TYPES, "invalid SnapId");
const CSnapshot *pSnapshot = m_aapSnapshots[g_Config.m_ClDummy][SnapID]->m_pAltSnap; const CSnapshot *pSnapshot = m_aapSnapshots[g_Config.m_ClDummy][SnapId]->m_pAltSnap;
const CSnapshotItem *pSnapshotItem = pSnapshot->GetItem(Index); const CSnapshotItem *pSnapshotItem = pSnapshot->GetItem(Index);
pItem->m_DataSize = pSnapshot->GetItemSize(Index); pItem->m_DataSize = pSnapshot->GetItemSize(Index);
pItem->m_Type = pSnapshot->GetItemType(Index); pItem->m_Type = pSnapshot->GetItemType(Index);
pItem->m_ID = pSnapshotItem->ID(); pItem->m_Id = pSnapshotItem->Id();
return (void *)pSnapshotItem->Data(); return (void *)pSnapshotItem->Data();
} }
int CClient::SnapItemSize(int SnapID, int Index) const int CClient::SnapItemSize(int SnapId, int Index) const
{ {
dbg_assert(SnapID >= 0 && SnapID < NUM_SNAPSHOT_TYPES, "invalid SnapID"); dbg_assert(SnapId >= 0 && SnapId < NUM_SNAPSHOT_TYPES, "invalid SnapId");
return m_aapSnapshots[g_Config.m_ClDummy][SnapID]->m_pAltSnap->GetItemSize(Index); return m_aapSnapshots[g_Config.m_ClDummy][SnapId]->m_pAltSnap->GetItemSize(Index);
} }
const void *CClient::SnapFindItem(int SnapID, int Type, int ID) const const void *CClient::SnapFindItem(int SnapId, int Type, int Id) const
{ {
if(!m_aapSnapshots[g_Config.m_ClDummy][SnapID]) if(!m_aapSnapshots[g_Config.m_ClDummy][SnapId])
return nullptr; return nullptr;
return m_aapSnapshots[g_Config.m_ClDummy][SnapID]->m_pAltSnap->FindItem(Type, ID); return m_aapSnapshots[g_Config.m_ClDummy][SnapId]->m_pAltSnap->FindItem(Type, Id);
} }
int CClient::SnapNumItems(int SnapID) const int CClient::SnapNumItems(int SnapId) const
{ {
dbg_assert(SnapID >= 0 && SnapID < NUM_SNAPSHOT_TYPES, "invalid SnapID"); dbg_assert(SnapId >= 0 && SnapId < NUM_SNAPSHOT_TYPES, "invalid SnapId");
if(!m_aapSnapshots[g_Config.m_ClDummy][SnapID]) if(!m_aapSnapshots[g_Config.m_ClDummy][SnapId])
return 0; return 0;
return m_aapSnapshots[g_Config.m_ClDummy][SnapID]->m_pAltSnap->NumItems(); return m_aapSnapshots[g_Config.m_ClDummy][SnapId]->m_pAltSnap->NumItems();
} }
void CClient::SnapSetStaticsize(int ItemType, int Size) void CClient::SnapSetStaticsize(int ItemType, int Size)
@ -1306,7 +1306,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
bool Sys; bool Sys;
CUuid Uuid; CUuid Uuid;
int Result = UnpackMessageID(&Msg, &Sys, &Uuid, &Unpacker, &Packer); int Result = UnpackMessageId(&Msg, &Sys, &Uuid, &Unpacker, &Packer);
if(Result == UNPACKMESSAGE_ERROR) if(Result == UNPACKMESSAGE_ERROR)
{ {
return; return;
@ -1513,24 +1513,24 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
} }
else if(Msg == NETMSG_PINGEX) else if(Msg == NETMSG_PINGEX)
{ {
CUuid *pID = (CUuid *)Unpacker.GetRaw(sizeof(*pID)); CUuid *pId = (CUuid *)Unpacker.GetRaw(sizeof(*pId));
if(Unpacker.Error()) if(Unpacker.Error())
{ {
return; return;
} }
CMsgPacker MsgP(NETMSG_PONGEX, true); CMsgPacker MsgP(NETMSG_PONGEX, true);
MsgP.AddRaw(pID, sizeof(*pID)); MsgP.AddRaw(pId, sizeof(*pId));
int Vital = (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 ? MSGFLAG_VITAL : 0; int Vital = (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 ? MSGFLAG_VITAL : 0;
SendMsg(Conn, &MsgP, MSGFLAG_FLUSH | Vital); SendMsg(Conn, &MsgP, MSGFLAG_FLUSH | Vital);
} }
else if(Conn == CONN_MAIN && Msg == NETMSG_PONGEX) else if(Conn == CONN_MAIN && Msg == NETMSG_PONGEX)
{ {
CUuid *pID = (CUuid *)Unpacker.GetRaw(sizeof(*pID)); CUuid *pId = (CUuid *)Unpacker.GetRaw(sizeof(*pId));
if(Unpacker.Error()) if(Unpacker.Error())
{ {
return; return;
} }
if(m_ServerCapabilities.m_PingEx && m_CurrentServerCurrentPingTime >= 0 && *pID == m_CurrentServerPingUuid) if(m_ServerCapabilities.m_PingEx && m_CurrentServerCurrentPingTime >= 0 && *pId == m_CurrentServerPingUuid)
{ {
int LatencyMs = (time_get() - m_CurrentServerCurrentPingTime) * 1000 / time_freq(); int LatencyMs = (time_get() - m_CurrentServerCurrentPingTime) * 1000 / time_freq();
m_ServerBrowser.SetCurrentServerPing(ServerAddress(), LatencyMs); m_ServerBrowser.SetCurrentServerPing(ServerAddress(), LatencyMs);
@ -1565,10 +1565,10 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
return; return;
} }
char aAddr[128]; char aAddr[128];
char aIP[64]; char aIp[64];
NETADDR ServerAddr = ServerAddress(); NETADDR ServerAddr = ServerAddress();
net_addr_str(&ServerAddr, aIP, sizeof(aIP), 0); net_addr_str(&ServerAddr, aIp, sizeof(aIp), 0);
str_format(aAddr, sizeof(aAddr), "%s:%d", aIP, RedirectPort); str_format(aAddr, sizeof(aAddr), "%s:%d", aIp, RedirectPort);
Connect(aAddr); Connect(aAddr);
} }
else if(Conn == CONN_MAIN && (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_CMD_ADD) else if(Conn == CONN_MAIN && (pPacket->m_Flags & NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_CMD_ADD)
@ -1995,7 +1995,7 @@ int CClient::UnpackAndValidateSnapshot(CSnapshot *pFrom, CSnapshot *pTo)
} }
const int ItemSize = pNetObjHandler->GetUnpackedObjSize(ItemType); const int ItemSize = pNetObjHandler->GetUnpackedObjSize(ItemType);
void *pObj = Builder.NewItem(pFromItem->Type(), pFromItem->ID(), ItemSize); void *pObj = Builder.NewItem(pFromItem->Type(), pFromItem->Id(), ItemSize);
if(!pObj) if(!pObj)
return -4; return -4;
@ -2279,7 +2279,7 @@ void CClient::PumpNetwork()
{ {
while(m_aNetClient[i].Recv(&Packet)) while(m_aNetClient[i].Recv(&Packet))
{ {
if(Packet.m_ClientID == -1) if(Packet.m_ClientId == -1)
{ {
ProcessConnlessPacket(&Packet); ProcessConnlessPacket(&Packet);
continue; continue;
@ -2329,7 +2329,7 @@ void CClient::OnDemoPlayerMessage(void *pData, int Size)
bool Sys; bool Sys;
CUuid Uuid; CUuid Uuid;
int Result = UnpackMessageID(&Msg, &Sys, &Uuid, &Unpacker, &Packer); int Result = UnpackMessageId(&Msg, &Sys, &Uuid, &Unpacker, &Packer);
if(Result == UNPACKMESSAGE_ERROR) if(Result == UNPACKMESSAGE_ERROR)
{ {
return; return;
@ -4340,8 +4340,8 @@ int main(int argc, const char **argv)
char aVersionStr[128]; char aVersionStr[128];
if(!os_version_str(aVersionStr, sizeof(aVersionStr))) if(!os_version_str(aVersionStr, sizeof(aVersionStr)))
str_copy(aVersionStr, "unknown"); str_copy(aVersionStr, "unknown");
char aGPUInfo[256]; char aGpuInfo[256];
pClient->GetGPUInfoString(aGPUInfo); pClient->GetGpuInfoString(aGpuInfo);
char aMessage[768]; char aMessage[768];
str_format(aMessage, sizeof(aMessage), str_format(aMessage, sizeof(aMessage),
"An assertion error occurred. Please write down or take a screenshot of the following information and report this error.\n" "An assertion error occurred. Please write down or take a screenshot of the following information and report this error.\n"
@ -4352,7 +4352,7 @@ int main(int argc, const char **argv)
"OS version: %s\n\n" "OS version: %s\n\n"
"%s", // GPU info "%s", // GPU info
pMsg, CONF_PLATFORM_STRING, GAME_RELEASE_VERSION, GIT_SHORTREV_HASH != nullptr ? GIT_SHORTREV_HASH : "", aVersionStr, pMsg, CONF_PLATFORM_STRING, GAME_RELEASE_VERSION, GIT_SHORTREV_HASH != nullptr ? GIT_SHORTREV_HASH : "", aVersionStr,
aGPUInfo); aGpuInfo);
pClient->ShowMessageBox("Assertion Error", aMessage); pClient->ShowMessageBox("Assertion Error", aMessage);
// Client will crash due to assertion, don't call PerformAllCleanup in this inconsistent state // Client will crash due to assertion, don't call PerformAllCleanup in this inconsistent state
}); });
@ -4768,15 +4768,15 @@ void CClient::ShowMessageBox(const char *pTitle, const char *pMessage, EMessageB
::ShowMessageBox(pTitle, pMessage, Type); ::ShowMessageBox(pTitle, pMessage, Type);
} }
void CClient::GetGPUInfoString(char (&aGPUInfo)[256]) void CClient::GetGpuInfoString(char (&aGpuInfo)[256])
{ {
if(m_pGraphics != nullptr && m_pGraphics->IsBackendInitialized()) if(m_pGraphics != nullptr && m_pGraphics->IsBackendInitialized())
{ {
str_format(aGPUInfo, std::size(aGPUInfo), "GPU: %s - %s - %s", m_pGraphics->GetVendorString(), m_pGraphics->GetRendererString(), m_pGraphics->GetVersionString()); str_format(aGpuInfo, std::size(aGpuInfo), "GPU: %s - %s - %s", m_pGraphics->GetVendorString(), m_pGraphics->GetRendererString(), m_pGraphics->GetVersionString());
} }
else else
{ {
str_copy(aGPUInfo, "Graphics backend was not yet initialized."); str_copy(aGpuInfo, "Graphics backend was not yet initialized.");
} }
} }

View file

@ -91,7 +91,7 @@ class CClient : public IClient, public CDemoPlayer::IListener
char m_aConnectAddressStr[MAX_SERVER_ADDRESSES * NETADDR_MAXSTRSIZE] = ""; char m_aConnectAddressStr[MAX_SERVER_ADDRESSES * NETADDR_MAXSTRSIZE] = "";
CUuid m_ConnectionID = UUID_ZEROED; CUuid m_ConnectionId = UUID_ZEROED;
bool m_HaveGlobalTcpAddr = false; bool m_HaveGlobalTcpAddr = false;
NETADDR m_GlobalTcpAddr = NETADDR_ZEROED; NETADDR m_GlobalTcpAddr = NETADDR_ZEROED;
@ -323,10 +323,10 @@ public:
// --- // ---
int GetPredictionTime() override; int GetPredictionTime() override;
void *SnapGetItem(int SnapID, int Index, CSnapItem *pItem) const override; void *SnapGetItem(int SnapId, int Index, CSnapItem *pItem) const override;
int SnapItemSize(int SnapID, int Index) const override; int SnapItemSize(int SnapId, int Index) const override;
const void *SnapFindItem(int SnapID, int Type, int ID) const override; const void *SnapFindItem(int SnapId, int Type, int Id) const override;
int SnapNumItems(int SnapID) const override; int SnapNumItems(int SnapId) const override;
void SnapSetStaticsize(int ItemType, int Size) override; void SnapSetStaticsize(int ItemType, int Size) override;
void Render(); void Render();
@ -506,7 +506,7 @@ public:
#endif #endif
void ShowMessageBox(const char *pTitle, const char *pMessage, EMessageBoxType Type = MESSAGE_BOX_TYPE_ERROR) override; void ShowMessageBox(const char *pTitle, const char *pMessage, EMessageBoxType Type = MESSAGE_BOX_TYPE_ERROR) override;
void GetGPUInfoString(char (&aGPUInfo)[256]) override; void GetGpuInfoString(char (&aGpuInfo)[256]) override;
void SetLoggers(std::shared_ptr<ILogger> &&pFileLogger, std::shared_ptr<ILogger> &&pStdoutLogger); void SetLoggers(std::shared_ptr<ILogger> &&pFileLogger, std::shared_ptr<ILogger> &&pStdoutLogger);
}; };

View file

@ -208,9 +208,9 @@ uint64_t CGraphics_Threaded::StagingMemoryUsage() const
return m_pBackend->StagingMemoryUsage(); return m_pBackend->StagingMemoryUsage();
} }
const TTWGraphicsGPUList &CGraphics_Threaded::GetGPUs() const const TTwGraphicsGpuList &CGraphics_Threaded::GetGpus() const
{ {
return m_pBackend->GetGPUs(); return m_pBackend->GetGpus();
} }
void CGraphics_Threaded::MapScreen(float TopLeftX, float TopLeftY, float BottomRightX, float BottomRightY) void CGraphics_Threaded::MapScreen(float TopLeftX, float TopLeftY, float BottomRightX, float BottomRightY)
@ -337,12 +337,12 @@ static bool ConvertToRGBA(uint8_t *pDest, const uint8_t *pSrc, size_t SrcWidth,
} }
} }
int CGraphics_Threaded::LoadTextureRawSub(CTextureHandle TextureID, int x, int y, size_t Width, size_t Height, CImageInfo::EImageFormat Format, const void *pData) int CGraphics_Threaded::LoadTextureRawSub(CTextureHandle TextureId, int x, int y, size_t Width, size_t Height, CImageInfo::EImageFormat Format, const void *pData)
{ {
dbg_assert(TextureID.IsValid(), "Invalid texture handle used with LoadTextureRawSub."); dbg_assert(TextureId.IsValid(), "Invalid texture handle used with LoadTextureRawSub.");
CCommandBuffer::SCommand_Texture_Update Cmd; CCommandBuffer::SCommand_Texture_Update Cmd;
Cmd.m_Slot = TextureID.Id(); Cmd.m_Slot = TextureId.Id();
Cmd.m_X = x; Cmd.m_X = x;
Cmd.m_Y = y; Cmd.m_Y = y;
Cmd.m_Width = Width; Cmd.m_Width = Width;
@ -505,12 +505,12 @@ IGraphics::CTextureHandle CGraphics_Threaded::LoadTexture(const char *pFilename,
CImageInfo Img; CImageInfo Img;
if(LoadPNG(&Img, pFilename, StorageType)) if(LoadPNG(&Img, pFilename, StorageType))
{ {
CTextureHandle ID = LoadTextureRawMove(Img.m_Width, Img.m_Height, Img.m_Format, Img.m_pData, Flags, pFilename); CTextureHandle Id = LoadTextureRawMove(Img.m_Width, Img.m_Height, Img.m_Format, Img.m_pData, Flags, pFilename);
if(ID.IsValid()) if(Id.IsValid())
{ {
if(g_Config.m_Debug) if(g_Config.m_Debug)
dbg_msg("graphics/texture", "loaded %s", pFilename); dbg_msg("graphics/texture", "loaded %s", pFilename);
return ID; return Id;
} }
} }
@ -556,10 +556,10 @@ bool CGraphics_Threaded::UnloadTextTextures(CTextureHandle &TextTexture, CTextur
return true; return true;
} }
bool CGraphics_Threaded::UpdateTextTexture(CTextureHandle TextureID, int x, int y, size_t Width, size_t Height, const void *pData) bool CGraphics_Threaded::UpdateTextTexture(CTextureHandle TextureId, int x, int y, size_t Width, size_t Height, const void *pData)
{ {
CCommandBuffer::SCommand_TextTexture_Update Cmd; CCommandBuffer::SCommand_TextTexture_Update Cmd;
Cmd.m_Slot = TextureID.Id(); Cmd.m_Slot = TextureId.Id();
Cmd.m_X = x; Cmd.m_X = x;
Cmd.m_Y = y; Cmd.m_Y = y;
Cmd.m_Width = Width; Cmd.m_Width = Width;
@ -839,11 +839,11 @@ void CGraphics_Threaded::ScreenshotDirect(bool *pSwapped)
} }
} }
void CGraphics_Threaded::TextureSet(CTextureHandle TextureID) void CGraphics_Threaded::TextureSet(CTextureHandle TextureId)
{ {
dbg_assert(m_Drawing == 0, "called Graphics()->TextureSet within begin"); dbg_assert(m_Drawing == 0, "called Graphics()->TextureSet within begin");
dbg_assert(!TextureID.IsValid() || m_vTextureIndices[TextureID.Id()] == -1, "Texture handle was not invalid, but also did not correlate to an existing texture."); dbg_assert(!TextureId.IsValid() || m_vTextureIndices[TextureId.Id()] == -1, "Texture handle was not invalid, but also did not correlate to an existing texture.");
m_State.m_Texture = TextureID.Id(); m_State.m_Texture = TextureId.Id();
} }
void CGraphics_Threaded::Clear(float r, float g, float b, bool ForceClearNow) void CGraphics_Threaded::Clear(float r, float g, float b, bool ForceClearNow)
@ -2741,12 +2741,12 @@ int CGraphics_Threaded::GetWindowScreen()
return m_pBackend->GetWindowScreen(); return m_pBackend->GetWindowScreen();
} }
void CGraphics_Threaded::WindowDestroyNtf(uint32_t WindowID) void CGraphics_Threaded::WindowDestroyNtf(uint32_t WindowId)
{ {
m_pBackend->WindowDestroyNtf(WindowID); m_pBackend->WindowDestroyNtf(WindowId);
CCommandBuffer::SCommand_WindowDestroyNtf Cmd; CCommandBuffer::SCommand_WindowDestroyNtf Cmd;
Cmd.m_WindowID = WindowID; Cmd.m_WindowId = WindowId;
AddCmd(Cmd); AddCmd(Cmd);
// wait // wait
@ -2754,12 +2754,12 @@ void CGraphics_Threaded::WindowDestroyNtf(uint32_t WindowID)
WaitForIdle(); WaitForIdle();
} }
void CGraphics_Threaded::WindowCreateNtf(uint32_t WindowID) void CGraphics_Threaded::WindowCreateNtf(uint32_t WindowId)
{ {
m_pBackend->WindowCreateNtf(WindowID); m_pBackend->WindowCreateNtf(WindowId);
CCommandBuffer::SCommand_WindowCreateNtf Cmd; CCommandBuffer::SCommand_WindowCreateNtf Cmd;
Cmd.m_WindowID = WindowID; Cmd.m_WindowId = WindowId;
AddCmd(Cmd); AddCmd(Cmd);
// wait // wait

View file

@ -604,7 +604,7 @@ public:
SCommand_WindowCreateNtf() : SCommand_WindowCreateNtf() :
SCommand(CMD_WINDOW_CREATE_NTF) {} SCommand(CMD_WINDOW_CREATE_NTF) {}
uint32_t m_WindowID; uint32_t m_WindowId;
}; };
struct SCommand_WindowDestroyNtf : public CCommandBuffer::SCommand struct SCommand_WindowDestroyNtf : public CCommandBuffer::SCommand
@ -612,7 +612,7 @@ public:
SCommand_WindowDestroyNtf() : SCommand_WindowDestroyNtf() :
SCommand(CMD_WINDOW_DESTROY_NTF) {} SCommand(CMD_WINDOW_DESTROY_NTF) {}
uint32_t m_WindowID; uint32_t m_WindowId;
}; };
// //
@ -709,7 +709,7 @@ public:
virtual uint64_t StreamedMemoryUsage() const = 0; virtual uint64_t StreamedMemoryUsage() const = 0;
virtual uint64_t StagingMemoryUsage() const = 0; virtual uint64_t StagingMemoryUsage() const = 0;
virtual const TTWGraphicsGPUList &GetGPUs() const = 0; virtual const TTwGraphicsGpuList &GetGpus() const = 0;
virtual void GetVideoModes(CVideoMode *pModes, int MaxModes, int *pNumModes, int HiDPIScale, int MaxWindowWidth, int MaxWindowHeight, int Screen) = 0; virtual void GetVideoModes(CVideoMode *pModes, int MaxModes, int *pNumModes, int HiDPIScale, int MaxWindowWidth, int MaxWindowHeight, int Screen) = 0;
virtual void GetCurrentVideoMode(CVideoMode &CurMode, int HiDPIScale, int MaxWindowWidth, int MaxWindowHeight, int Screen) = 0; virtual void GetCurrentVideoMode(CVideoMode &CurMode, int HiDPIScale, int MaxWindowWidth, int MaxWindowHeight, int Screen) = 0;
@ -731,8 +731,8 @@ public:
virtual void GetViewportSize(int &w, int &h) = 0; virtual void GetViewportSize(int &w, int &h) = 0;
virtual void NotifyWindow() = 0; virtual void NotifyWindow() = 0;
virtual void WindowDestroyNtf(uint32_t WindowID) = 0; virtual void WindowDestroyNtf(uint32_t WindowId) = 0;
virtual void WindowCreateNtf(uint32_t WindowID) = 0; virtual void WindowCreateNtf(uint32_t WindowId) = 0;
virtual void RunBuffer(CCommandBuffer *pBuffer) = 0; virtual void RunBuffer(CCommandBuffer *pBuffer) = 0;
virtual void RunBufferSingleThreadedUnsafe(CCommandBuffer *pBuffer) = 0; virtual void RunBufferSingleThreadedUnsafe(CCommandBuffer *pBuffer) = 0;
@ -953,7 +953,7 @@ public:
uint64_t StreamedMemoryUsage() const override; uint64_t StreamedMemoryUsage() const override;
uint64_t StagingMemoryUsage() const override; uint64_t StagingMemoryUsage() const override;
const TTWGraphicsGPUList &GetGPUs() const override; const TTwGraphicsGpuList &GetGpus() const override;
void MapScreen(float TopLeftX, float TopLeftY, float BottomRightX, float BottomRightY) override; void MapScreen(float TopLeftX, float TopLeftY, float BottomRightX, float BottomRightY) override;
void GetScreen(float *pTopLeftX, float *pTopLeftY, float *pBottomRightX, float *pBottomRightY) override; void GetScreen(float *pTopLeftX, float *pTopLeftY, float *pBottomRightX, float *pBottomRightY) override;
@ -967,12 +967,12 @@ public:
int UnloadTexture(IGraphics::CTextureHandle *pIndex) override; int UnloadTexture(IGraphics::CTextureHandle *pIndex) override;
IGraphics::CTextureHandle LoadTextureRaw(size_t Width, size_t Height, CImageInfo::EImageFormat Format, const void *pData, int Flags, const char *pTexName = nullptr) override; IGraphics::CTextureHandle LoadTextureRaw(size_t Width, size_t Height, CImageInfo::EImageFormat Format, const void *pData, int Flags, const char *pTexName = nullptr) override;
IGraphics::CTextureHandle LoadTextureRawMove(size_t Width, size_t Height, CImageInfo::EImageFormat Format, void *pData, int Flags, const char *pTexName = nullptr) override; IGraphics::CTextureHandle LoadTextureRawMove(size_t Width, size_t Height, CImageInfo::EImageFormat Format, void *pData, int Flags, const char *pTexName = nullptr) override;
int LoadTextureRawSub(IGraphics::CTextureHandle TextureID, int x, int y, size_t Width, size_t Height, CImageInfo::EImageFormat Format, const void *pData) override; int LoadTextureRawSub(IGraphics::CTextureHandle TextureId, int x, int y, size_t Width, size_t Height, CImageInfo::EImageFormat Format, const void *pData) override;
IGraphics::CTextureHandle NullTexture() const override; IGraphics::CTextureHandle NullTexture() const override;
bool LoadTextTextures(size_t Width, size_t Height, CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture, void *pTextData, void *pTextOutlineData) override; bool LoadTextTextures(size_t Width, size_t Height, CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture, void *pTextData, void *pTextOutlineData) override;
bool UnloadTextTextures(CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture) override; bool UnloadTextTextures(CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture) override;
bool UpdateTextTexture(CTextureHandle TextureID, int x, int y, size_t Width, size_t Height, const void *pData) override; bool UpdateTextTexture(CTextureHandle TextureId, int x, int y, size_t Width, size_t Height, const void *pData) override;
CTextureHandle LoadSpriteTextureImpl(CImageInfo &FromImageInfo, int x, int y, size_t w, size_t h); CTextureHandle LoadSpriteTextureImpl(CImageInfo &FromImageInfo, int x, int y, size_t w, size_t h);
CTextureHandle LoadSpriteTexture(CImageInfo &FromImageInfo, struct CDataSprite *pSprite) override; CTextureHandle LoadSpriteTexture(CImageInfo &FromImageInfo, struct CDataSprite *pSprite) override;
@ -991,7 +991,7 @@ public:
void CopyTextureBufferSub(uint8_t *pDestBuffer, uint8_t *pSourceBuffer, size_t FullWidth, size_t FullHeight, size_t PixelSize, size_t SubOffsetX, size_t SubOffsetY, size_t SubCopyWidth, size_t SubCopyHeight) override; void CopyTextureBufferSub(uint8_t *pDestBuffer, uint8_t *pSourceBuffer, size_t FullWidth, size_t FullHeight, size_t PixelSize, size_t SubOffsetX, size_t SubOffsetY, size_t SubCopyWidth, size_t SubCopyHeight) override;
void CopyTextureFromTextureBufferSub(uint8_t *pDestBuffer, size_t DestWidth, size_t DestHeight, uint8_t *pSourceBuffer, size_t SrcWidth, size_t SrcHeight, size_t PixelSize, size_t SrcSubOffsetX, size_t SrcSubOffsetY, size_t SrcSubCopyWidth, size_t SrcSubCopyHeight) override; void CopyTextureFromTextureBufferSub(uint8_t *pDestBuffer, size_t DestWidth, size_t DestHeight, uint8_t *pSourceBuffer, size_t SrcWidth, size_t SrcHeight, size_t PixelSize, size_t SrcSubOffsetX, size_t SrcSubOffsetY, size_t SrcSubCopyWidth, size_t SrcSubCopyHeight) override;
void TextureSet(CTextureHandle TextureID) override; void TextureSet(CTextureHandle TextureId) override;
void Clear(float r, float g, float b, bool ForceClearNow = false) override; void Clear(float r, float g, float b, bool ForceClearNow = false) override;
@ -1245,8 +1245,8 @@ public:
void AddWindowPropChangeListener(WINDOW_PROPS_CHANGED_FUNC pFunc) override; void AddWindowPropChangeListener(WINDOW_PROPS_CHANGED_FUNC pFunc) override;
int GetWindowScreen() override; int GetWindowScreen() override;
void WindowDestroyNtf(uint32_t WindowID) override; void WindowDestroyNtf(uint32_t WindowId) override;
void WindowCreateNtf(uint32_t WindowID) override; void WindowCreateNtf(uint32_t WindowId) override;
int WindowActive() override; int WindowActive() override;
int WindowOpen() override; int WindowOpen() override;

View file

@ -174,7 +174,7 @@ CInput::CJoystick::CJoystick(CInput *pInput, int Index, SDL_Joystick *pDelegate)
m_NumHats = SDL_JoystickNumHats(pDelegate); m_NumHats = SDL_JoystickNumHats(pDelegate);
str_copy(m_aName, SDL_JoystickName(pDelegate)); str_copy(m_aName, SDL_JoystickName(pDelegate));
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(pDelegate), m_aGUID, sizeof(m_aGUID)); SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(pDelegate), m_aGUID, sizeof(m_aGUID));
m_InstanceID = SDL_JoystickInstanceID(pDelegate); m_InstanceId = SDL_JoystickInstanceID(pDelegate);
} }
void CInput::CloseJoysticks() void CInput::CloseJoysticks()
@ -411,7 +411,7 @@ void CInput::HandleJoystickAxisMotionEvent(const SDL_JoyAxisEvent &Event)
if(!g_Config.m_InpControllerEnable) if(!g_Config.m_InpControllerEnable)
return; return;
CJoystick *pJoystick = GetActiveJoystick(); CJoystick *pJoystick = GetActiveJoystick();
if(!pJoystick || pJoystick->GetInstanceID() != Event.which) if(!pJoystick || pJoystick->GetInstanceId() != Event.which)
return; return;
if(Event.axis >= NUM_JOYSTICK_AXES) if(Event.axis >= NUM_JOYSTICK_AXES)
return; return;
@ -450,7 +450,7 @@ void CInput::HandleJoystickButtonEvent(const SDL_JoyButtonEvent &Event)
if(!g_Config.m_InpControllerEnable) if(!g_Config.m_InpControllerEnable)
return; return;
CJoystick *pJoystick = GetActiveJoystick(); CJoystick *pJoystick = GetActiveJoystick();
if(!pJoystick || pJoystick->GetInstanceID() != Event.which) if(!pJoystick || pJoystick->GetInstanceId() != Event.which)
return; return;
if(Event.button >= NUM_JOYSTICK_BUTTONS) if(Event.button >= NUM_JOYSTICK_BUTTONS)
return; return;
@ -475,7 +475,7 @@ void CInput::HandleJoystickHatMotionEvent(const SDL_JoyHatEvent &Event)
if(!g_Config.m_InpControllerEnable) if(!g_Config.m_InpControllerEnable)
return; return;
CJoystick *pJoystick = GetActiveJoystick(); CJoystick *pJoystick = GetActiveJoystick();
if(!pJoystick || pJoystick->GetInstanceID() != Event.which) if(!pJoystick || pJoystick->GetInstanceId() != Event.which)
return; return;
if(Event.hat >= NUM_JOYSTICK_HATS) if(Event.hat >= NUM_JOYSTICK_HATS)
return; return;
@ -513,7 +513,7 @@ void CInput::HandleJoystickAddedEvent(const SDL_JoyDeviceEvent &Event)
void CInput::HandleJoystickRemovedEvent(const SDL_JoyDeviceEvent &Event) void CInput::HandleJoystickRemovedEvent(const SDL_JoyDeviceEvent &Event)
{ {
auto RemovedJoystick = std::find_if(m_vJoysticks.begin(), m_vJoysticks.end(), [Event](const CJoystick &Joystick) -> bool { return Joystick.GetInstanceID() == Event.which; }); auto RemovedJoystick = std::find_if(m_vJoysticks.begin(), m_vJoysticks.end(), [Event](const CJoystick &Joystick) -> bool { return Joystick.GetInstanceId() == Event.which; });
if(RemovedJoystick != m_vJoysticks.end()) if(RemovedJoystick != m_vJoysticks.end())
{ {
dbg_msg("joystick", "Closed joystick %d '%s'", (*RemovedJoystick).GetIndex(), (*RemovedJoystick).GetName()); dbg_msg("joystick", "Closed joystick %d '%s'", (*RemovedJoystick).GetIndex(), (*RemovedJoystick).GetName());

View file

@ -25,7 +25,7 @@ public:
int m_Index; int m_Index;
char m_aName[64]; char m_aName[64];
char m_aGUID[34]; char m_aGUID[34];
SDL_JoystickID m_InstanceID; SDL_JoystickID m_InstanceId;
int m_NumAxes; int m_NumAxes;
int m_NumButtons; int m_NumButtons;
int m_NumBalls; int m_NumBalls;
@ -42,7 +42,7 @@ public:
int GetIndex() const override { return m_Index; } int GetIndex() const override { return m_Index; }
const char *GetName() const override { return m_aName; } const char *GetName() const override { return m_aName; }
const char *GetGUID() const { return m_aGUID; } const char *GetGUID() const { return m_aGUID; }
SDL_JoystickID GetInstanceID() const { return m_InstanceID; } SDL_JoystickID GetInstanceId() const { return m_InstanceId; }
int GetNumAxes() const override { return m_NumAxes; } int GetNumAxes() const override { return m_NumAxes; }
int GetNumButtons() const override { return m_NumButtons; } int GetNumButtons() const override { return m_NumButtons; }
int GetNumBalls() const override { return m_NumBalls; } int GetNumBalls() const override { return m_NumBalls; }

View file

@ -944,7 +944,7 @@ void CServerBrowser::Refresh(int Type, bool Force)
CNetChunk Packet; CNetChunk Packet;
/* do the broadcast version */ /* do the broadcast version */
Packet.m_ClientID = -1; Packet.m_ClientId = -1;
mem_zero(&Packet, sizeof(Packet)); mem_zero(&Packet, sizeof(Packet));
Packet.m_Address.type = m_pNetClient->NetType() | NETTYPE_LINK_BROADCAST; Packet.m_Address.type = m_pNetClient->NetType() | NETTYPE_LINK_BROADCAST;
Packet.m_Flags = NETSENDFLAG_CONNLESS | NETSENDFLAG_EXTENDED; Packet.m_Flags = NETSENDFLAG_CONNLESS | NETSENDFLAG_EXTENDED;
@ -1020,7 +1020,7 @@ void CServerBrowser::RequestImpl(const NETADDR &Addr, CServerEntry *pEntry, int
aBuffer[sizeof(SERVERBROWSE_GETINFO)] = GetBasicToken(Token); aBuffer[sizeof(SERVERBROWSE_GETINFO)] = GetBasicToken(Token);
CNetChunk Packet; CNetChunk Packet;
Packet.m_ClientID = -1; Packet.m_ClientId = -1;
Packet.m_Address = Addr; Packet.m_Address = Addr;
Packet.m_Flags = NETSENDFLAG_CONNLESS | NETSENDFLAG_EXTENDED; Packet.m_Flags = NETSENDFLAG_CONNLESS | NETSENDFLAG_EXTENDED;
Packet.m_DataSize = sizeof(aBuffer); Packet.m_DataSize = sizeof(aBuffer);

View file

@ -275,9 +275,9 @@ void CSound::UpdateVolume()
void CSound::Shutdown() void CSound::Shutdown()
{ {
for(unsigned SampleID = 0; SampleID < NUM_SAMPLES; SampleID++) for(unsigned SampleId = 0; SampleId < NUM_SAMPLES; SampleId++)
{ {
UnloadSample(SampleID); UnloadSample(SampleId);
} }
SDL_CloseAudioDevice(m_Device); SDL_CloseAudioDevice(m_Device);
@ -640,15 +640,15 @@ int CSound::LoadWVFromMem(const void *pData, unsigned DataSize, bool FromEditor
return pSample->m_Index; return pSample->m_Index;
} }
void CSound::UnloadSample(int SampleID) void CSound::UnloadSample(int SampleId)
{ {
if(SampleID == -1 || SampleID >= NUM_SAMPLES) if(SampleId == -1 || SampleId >= NUM_SAMPLES)
return; return;
Stop(SampleID); Stop(SampleId);
// Free data // Free data
CSample &Sample = m_aSamples[SampleID]; CSample &Sample = m_aSamples[SampleId];
free(Sample.m_pData); free(Sample.m_pData);
Sample.m_pData = nullptr; Sample.m_pData = nullptr;
@ -660,21 +660,21 @@ void CSound::UnloadSample(int SampleID)
} }
} }
float CSound::GetSampleTotalTime(int SampleID) float CSound::GetSampleTotalTime(int SampleId)
{ {
if(SampleID == -1 || SampleID >= NUM_SAMPLES) if(SampleId == -1 || SampleId >= NUM_SAMPLES)
return 0.0f; return 0.0f;
return m_aSamples[SampleID].TotalTime(); return m_aSamples[SampleId].TotalTime();
} }
float CSound::GetSampleCurrentTime(int SampleID) float CSound::GetSampleCurrentTime(int SampleId)
{ {
if(SampleID == -1 || SampleID >= NUM_SAMPLES) if(SampleId == -1 || SampleId >= NUM_SAMPLES)
return 0.0f; return 0.0f;
const CLockScope LockScope(m_SoundLock); const CLockScope LockScope(m_SoundLock);
CSample *pSample = &m_aSamples[SampleID]; CSample *pSample = &m_aSamples[SampleId];
for(auto &Voice : m_aVoices) for(auto &Voice : m_aVoices)
{ {
if(Voice.m_pSample == pSample) if(Voice.m_pSample == pSample)
@ -686,13 +686,13 @@ float CSound::GetSampleCurrentTime(int SampleID)
return pSample->m_PausedAt / (float)pSample->m_Rate; return pSample->m_PausedAt / (float)pSample->m_Rate;
} }
void CSound::SetSampleCurrentTime(int SampleID, float Time) void CSound::SetSampleCurrentTime(int SampleId, float Time)
{ {
if(SampleID == -1 || SampleID >= NUM_SAMPLES) if(SampleId == -1 || SampleId >= NUM_SAMPLES)
return; return;
const CLockScope LockScope(m_SoundLock); const CLockScope LockScope(m_SoundLock);
CSample *pSample = &m_aSamples[SampleID]; CSample *pSample = &m_aSamples[SampleId];
for(auto &Voice : m_aVoices) for(auto &Voice : m_aVoices)
{ {
if(Voice.m_pSample == pSample) if(Voice.m_pSample == pSample)
@ -705,10 +705,10 @@ void CSound::SetSampleCurrentTime(int SampleID, float Time)
pSample->m_PausedAt = pSample->m_NumFrames * Time; pSample->m_PausedAt = pSample->m_NumFrames * Time;
} }
void CSound::SetChannel(int ChannelID, float Vol, float Pan) void CSound::SetChannel(int ChannelId, float Vol, float Pan)
{ {
m_aChannels[ChannelID].m_Vol = (int)(Vol * 255.0f); m_aChannels[ChannelId].m_Vol = (int)(Vol * 255.0f);
m_aChannels[ChannelID].m_Pan = (int)(Pan * 255.0f); // TODO: this is only on and off right now m_aChannels[ChannelId].m_Pan = (int)(Pan * 255.0f); // TODO: this is only on and off right now
} }
void CSound::SetListenerPos(float x, float y) void CSound::SetListenerPos(float x, float y)
@ -722,14 +722,14 @@ void CSound::SetVoiceVolume(CVoiceHandle Voice, float Volume)
if(!Voice.IsValid()) if(!Voice.IsValid())
return; return;
int VoiceID = Voice.Id(); int VoiceId = Voice.Id();
const CLockScope LockScope(m_SoundLock); const CLockScope LockScope(m_SoundLock);
if(m_aVoices[VoiceID].m_Age != Voice.Age()) if(m_aVoices[VoiceId].m_Age != Voice.Age())
return; return;
Volume = clamp(Volume, 0.0f, 1.0f); Volume = clamp(Volume, 0.0f, 1.0f);
m_aVoices[VoiceID].m_Vol = (int)(Volume * 255.0f); m_aVoices[VoiceId].m_Vol = (int)(Volume * 255.0f);
} }
void CSound::SetVoiceFalloff(CVoiceHandle Voice, float Falloff) void CSound::SetVoiceFalloff(CVoiceHandle Voice, float Falloff)
@ -737,14 +737,14 @@ void CSound::SetVoiceFalloff(CVoiceHandle Voice, float Falloff)
if(!Voice.IsValid()) if(!Voice.IsValid())
return; return;
int VoiceID = Voice.Id(); int VoiceId = Voice.Id();
const CLockScope LockScope(m_SoundLock); const CLockScope LockScope(m_SoundLock);
if(m_aVoices[VoiceID].m_Age != Voice.Age()) if(m_aVoices[VoiceId].m_Age != Voice.Age())
return; return;
Falloff = clamp(Falloff, 0.0f, 1.0f); Falloff = clamp(Falloff, 0.0f, 1.0f);
m_aVoices[VoiceID].m_Falloff = Falloff; m_aVoices[VoiceId].m_Falloff = Falloff;
} }
void CSound::SetVoiceLocation(CVoiceHandle Voice, float x, float y) void CSound::SetVoiceLocation(CVoiceHandle Voice, float x, float y)
@ -752,14 +752,14 @@ void CSound::SetVoiceLocation(CVoiceHandle Voice, float x, float y)
if(!Voice.IsValid()) if(!Voice.IsValid())
return; return;
int VoiceID = Voice.Id(); int VoiceId = Voice.Id();
const CLockScope LockScope(m_SoundLock); const CLockScope LockScope(m_SoundLock);
if(m_aVoices[VoiceID].m_Age != Voice.Age()) if(m_aVoices[VoiceId].m_Age != Voice.Age())
return; return;
m_aVoices[VoiceID].m_X = x; m_aVoices[VoiceId].m_X = x;
m_aVoices[VoiceID].m_Y = y; m_aVoices[VoiceId].m_Y = y;
} }
void CSound::SetVoiceTimeOffset(CVoiceHandle Voice, float TimeOffset) void CSound::SetVoiceTimeOffset(CVoiceHandle Voice, float TimeOffset)
@ -767,31 +767,31 @@ void CSound::SetVoiceTimeOffset(CVoiceHandle Voice, float TimeOffset)
if(!Voice.IsValid()) if(!Voice.IsValid())
return; return;
int VoiceID = Voice.Id(); int VoiceId = Voice.Id();
const CLockScope LockScope(m_SoundLock); const CLockScope LockScope(m_SoundLock);
if(m_aVoices[VoiceID].m_Age != Voice.Age()) if(m_aVoices[VoiceId].m_Age != Voice.Age())
return; return;
if(!m_aVoices[VoiceID].m_pSample) if(!m_aVoices[VoiceId].m_pSample)
return; return;
int Tick = 0; int Tick = 0;
bool IsLooping = m_aVoices[VoiceID].m_Flags & ISound::FLAG_LOOP; bool IsLooping = m_aVoices[VoiceId].m_Flags & ISound::FLAG_LOOP;
uint64_t TickOffset = m_aVoices[VoiceID].m_pSample->m_Rate * TimeOffset; uint64_t TickOffset = m_aVoices[VoiceId].m_pSample->m_Rate * TimeOffset;
if(m_aVoices[VoiceID].m_pSample->m_NumFrames > 0 && IsLooping) if(m_aVoices[VoiceId].m_pSample->m_NumFrames > 0 && IsLooping)
Tick = TickOffset % m_aVoices[VoiceID].m_pSample->m_NumFrames; Tick = TickOffset % m_aVoices[VoiceId].m_pSample->m_NumFrames;
else else
Tick = clamp(TickOffset, (uint64_t)0, (uint64_t)m_aVoices[VoiceID].m_pSample->m_NumFrames); Tick = clamp(TickOffset, (uint64_t)0, (uint64_t)m_aVoices[VoiceId].m_pSample->m_NumFrames);
// at least 200msec off, else depend on buffer size // at least 200msec off, else depend on buffer size
float Threshold = maximum(0.2f * m_aVoices[VoiceID].m_pSample->m_Rate, (float)m_MaxFrames); float Threshold = maximum(0.2f * m_aVoices[VoiceId].m_pSample->m_Rate, (float)m_MaxFrames);
if(absolute(m_aVoices[VoiceID].m_Tick - Tick) > Threshold) if(absolute(m_aVoices[VoiceId].m_Tick - Tick) > Threshold)
{ {
// take care of looping (modulo!) // take care of looping (modulo!)
if(!(IsLooping && (minimum(m_aVoices[VoiceID].m_Tick, Tick) + m_aVoices[VoiceID].m_pSample->m_NumFrames - maximum(m_aVoices[VoiceID].m_Tick, Tick)) <= Threshold)) if(!(IsLooping && (minimum(m_aVoices[VoiceId].m_Tick, Tick) + m_aVoices[VoiceId].m_pSample->m_NumFrames - maximum(m_aVoices[VoiceId].m_Tick, Tick)) <= Threshold))
{ {
m_aVoices[VoiceID].m_Tick = Tick; m_aVoices[VoiceId].m_Tick = Tick;
} }
} }
} }
@ -801,14 +801,14 @@ void CSound::SetVoiceCircle(CVoiceHandle Voice, float Radius)
if(!Voice.IsValid()) if(!Voice.IsValid())
return; return;
int VoiceID = Voice.Id(); int VoiceId = Voice.Id();
const CLockScope LockScope(m_SoundLock); const CLockScope LockScope(m_SoundLock);
if(m_aVoices[VoiceID].m_Age != Voice.Age()) if(m_aVoices[VoiceId].m_Age != Voice.Age())
return; return;
m_aVoices[VoiceID].m_Shape = ISound::SHAPE_CIRCLE; m_aVoices[VoiceId].m_Shape = ISound::SHAPE_CIRCLE;
m_aVoices[VoiceID].m_Circle.m_Radius = maximum(0.0f, Radius); m_aVoices[VoiceId].m_Circle.m_Radius = maximum(0.0f, Radius);
} }
void CSound::SetVoiceRectangle(CVoiceHandle Voice, float Width, float Height) void CSound::SetVoiceRectangle(CVoiceHandle Voice, float Width, float Height)
@ -816,81 +816,81 @@ void CSound::SetVoiceRectangle(CVoiceHandle Voice, float Width, float Height)
if(!Voice.IsValid()) if(!Voice.IsValid())
return; return;
int VoiceID = Voice.Id(); int VoiceId = Voice.Id();
const CLockScope LockScope(m_SoundLock); const CLockScope LockScope(m_SoundLock);
if(m_aVoices[VoiceID].m_Age != Voice.Age()) if(m_aVoices[VoiceId].m_Age != Voice.Age())
return; return;
m_aVoices[VoiceID].m_Shape = ISound::SHAPE_RECTANGLE; m_aVoices[VoiceId].m_Shape = ISound::SHAPE_RECTANGLE;
m_aVoices[VoiceID].m_Rectangle.m_Width = maximum(0.0f, Width); m_aVoices[VoiceId].m_Rectangle.m_Width = maximum(0.0f, Width);
m_aVoices[VoiceID].m_Rectangle.m_Height = maximum(0.0f, Height); m_aVoices[VoiceId].m_Rectangle.m_Height = maximum(0.0f, Height);
} }
ISound::CVoiceHandle CSound::Play(int ChannelID, int SampleID, int Flags, float x, float y) ISound::CVoiceHandle CSound::Play(int ChannelId, int SampleId, int Flags, float x, float y)
{ {
const CLockScope LockScope(m_SoundLock); const CLockScope LockScope(m_SoundLock);
// search for voice // search for voice
int VoiceID = -1; int VoiceId = -1;
for(int i = 0; i < NUM_VOICES; i++) for(int i = 0; i < NUM_VOICES; i++)
{ {
int NextID = (m_NextVoice + i) % NUM_VOICES; int NextId = (m_NextVoice + i) % NUM_VOICES;
if(!m_aVoices[NextID].m_pSample) if(!m_aVoices[NextId].m_pSample)
{ {
VoiceID = NextID; VoiceId = NextId;
m_NextVoice = NextID + 1; m_NextVoice = NextId + 1;
break; break;
} }
} }
// voice found, use it // voice found, use it
int Age = -1; int Age = -1;
if(VoiceID != -1) if(VoiceId != -1)
{ {
m_aVoices[VoiceID].m_pSample = &m_aSamples[SampleID]; m_aVoices[VoiceId].m_pSample = &m_aSamples[SampleId];
m_aVoices[VoiceID].m_pChannel = &m_aChannels[ChannelID]; m_aVoices[VoiceId].m_pChannel = &m_aChannels[ChannelId];
if(Flags & FLAG_LOOP) if(Flags & FLAG_LOOP)
{ {
m_aVoices[VoiceID].m_Tick = m_aSamples[SampleID].m_PausedAt; m_aVoices[VoiceId].m_Tick = m_aSamples[SampleId].m_PausedAt;
} }
else if(Flags & FLAG_PREVIEW) else if(Flags & FLAG_PREVIEW)
{ {
m_aVoices[VoiceID].m_Tick = m_aSamples[SampleID].m_PausedAt; m_aVoices[VoiceId].m_Tick = m_aSamples[SampleId].m_PausedAt;
m_aSamples[SampleID].m_PausedAt = 0; m_aSamples[SampleId].m_PausedAt = 0;
} }
else else
{ {
m_aVoices[VoiceID].m_Tick = 0; m_aVoices[VoiceId].m_Tick = 0;
} }
m_aVoices[VoiceID].m_Vol = 255; m_aVoices[VoiceId].m_Vol = 255;
m_aVoices[VoiceID].m_Flags = Flags; m_aVoices[VoiceId].m_Flags = Flags;
m_aVoices[VoiceID].m_X = (int)x; m_aVoices[VoiceId].m_X = (int)x;
m_aVoices[VoiceID].m_Y = (int)y; m_aVoices[VoiceId].m_Y = (int)y;
m_aVoices[VoiceID].m_Falloff = 0.0f; m_aVoices[VoiceId].m_Falloff = 0.0f;
m_aVoices[VoiceID].m_Shape = ISound::SHAPE_CIRCLE; m_aVoices[VoiceId].m_Shape = ISound::SHAPE_CIRCLE;
m_aVoices[VoiceID].m_Circle.m_Radius = 1500; m_aVoices[VoiceId].m_Circle.m_Radius = 1500;
Age = m_aVoices[VoiceID].m_Age; Age = m_aVoices[VoiceId].m_Age;
} }
return CreateVoiceHandle(VoiceID, Age); return CreateVoiceHandle(VoiceId, Age);
} }
ISound::CVoiceHandle CSound::PlayAt(int ChannelID, int SampleID, int Flags, float x, float y) ISound::CVoiceHandle CSound::PlayAt(int ChannelId, int SampleId, int Flags, float x, float y)
{ {
return Play(ChannelID, SampleID, Flags | ISound::FLAG_POS, x, y); return Play(ChannelId, SampleId, Flags | ISound::FLAG_POS, x, y);
} }
ISound::CVoiceHandle CSound::Play(int ChannelID, int SampleID, int Flags) ISound::CVoiceHandle CSound::Play(int ChannelId, int SampleId, int Flags)
{ {
return Play(ChannelID, SampleID, Flags, 0, 0); return Play(ChannelId, SampleId, Flags, 0, 0);
} }
void CSound::Pause(int SampleID) void CSound::Pause(int SampleId)
{ {
// TODO: a nice fade out // TODO: a nice fade out
const CLockScope LockScope(m_SoundLock); const CLockScope LockScope(m_SoundLock);
CSample *pSample = &m_aSamples[SampleID]; CSample *pSample = &m_aSamples[SampleId];
for(auto &Voice : m_aVoices) for(auto &Voice : m_aVoices)
{ {
if(Voice.m_pSample == pSample) if(Voice.m_pSample == pSample)
@ -901,11 +901,11 @@ void CSound::Pause(int SampleID)
} }
} }
void CSound::Stop(int SampleID) void CSound::Stop(int SampleId)
{ {
// TODO: a nice fade out // TODO: a nice fade out
const CLockScope LockScope(m_SoundLock); const CLockScope LockScope(m_SoundLock);
CSample *pSample = &m_aSamples[SampleID]; CSample *pSample = &m_aSamples[SampleId];
for(auto &Voice : m_aVoices) for(auto &Voice : m_aVoices)
{ {
if(Voice.m_pSample == pSample) if(Voice.m_pSample == pSample)
@ -941,20 +941,20 @@ void CSound::StopVoice(CVoiceHandle Voice)
if(!Voice.IsValid()) if(!Voice.IsValid())
return; return;
int VoiceID = Voice.Id(); int VoiceId = Voice.Id();
const CLockScope LockScope(m_SoundLock); const CLockScope LockScope(m_SoundLock);
if(m_aVoices[VoiceID].m_Age != Voice.Age()) if(m_aVoices[VoiceId].m_Age != Voice.Age())
return; return;
m_aVoices[VoiceID].m_pSample = nullptr; m_aVoices[VoiceId].m_pSample = nullptr;
m_aVoices[VoiceID].m_Age++; m_aVoices[VoiceId].m_Age++;
} }
bool CSound::IsPlaying(int SampleID) bool CSound::IsPlaying(int SampleId)
{ {
const CLockScope LockScope(m_SoundLock); const CLockScope LockScope(m_SoundLock);
const CSample *pSample = &m_aSamples[SampleID]; const CSample *pSample = &m_aSamples[SampleId];
return std::any_of(std::begin(m_aVoices), std::end(m_aVoices), [pSample](const auto &Voice) { return Voice.m_pSample == pSample; }); return std::any_of(std::begin(m_aVoices), std::end(m_aVoices), [pSample](const auto &Voice) { return Voice.m_pSample == pSample; });
} }

View file

@ -105,13 +105,13 @@ public:
int LoadWV(const char *pFilename, int StorageType = IStorage::TYPE_ALL) override REQUIRES(!m_SoundLock); int LoadWV(const char *pFilename, int StorageType = IStorage::TYPE_ALL) override REQUIRES(!m_SoundLock);
int LoadOpusFromMem(const void *pData, unsigned DataSize, bool FromEditor) override REQUIRES(!m_SoundLock); int LoadOpusFromMem(const void *pData, unsigned DataSize, bool FromEditor) override REQUIRES(!m_SoundLock);
int LoadWVFromMem(const void *pData, unsigned DataSize, bool FromEditor) override REQUIRES(!m_SoundLock); int LoadWVFromMem(const void *pData, unsigned DataSize, bool FromEditor) override REQUIRES(!m_SoundLock);
void UnloadSample(int SampleID) override REQUIRES(!m_SoundLock); void UnloadSample(int SampleId) override REQUIRES(!m_SoundLock);
float GetSampleTotalTime(int SampleID) override; // in s float GetSampleTotalTime(int SampleId) override; // in s
float GetSampleCurrentTime(int SampleID) override REQUIRES(!m_SoundLock); // in s float GetSampleCurrentTime(int SampleId) override REQUIRES(!m_SoundLock); // in s
void SetSampleCurrentTime(int SampleID, float Time) override REQUIRES(!m_SoundLock); void SetSampleCurrentTime(int SampleId, float Time) override REQUIRES(!m_SoundLock);
void SetChannel(int ChannelID, float Vol, float Pan) override; void SetChannel(int ChannelId, float Vol, float Pan) override;
void SetListenerPos(float x, float y) override; void SetListenerPos(float x, float y) override;
void SetVoiceVolume(CVoiceHandle Voice, float Volume) override REQUIRES(!m_SoundLock); void SetVoiceVolume(CVoiceHandle Voice, float Volume) override REQUIRES(!m_SoundLock);
@ -122,14 +122,14 @@ public:
void SetVoiceCircle(CVoiceHandle Voice, float Radius) override REQUIRES(!m_SoundLock); void SetVoiceCircle(CVoiceHandle Voice, float Radius) override REQUIRES(!m_SoundLock);
void SetVoiceRectangle(CVoiceHandle Voice, float Width, float Height) override REQUIRES(!m_SoundLock); void SetVoiceRectangle(CVoiceHandle Voice, float Width, float Height) override REQUIRES(!m_SoundLock);
CVoiceHandle Play(int ChannelID, int SampleID, int Flags, float x, float y) REQUIRES(!m_SoundLock); CVoiceHandle Play(int ChannelId, int SampleId, int Flags, float x, float y) REQUIRES(!m_SoundLock);
CVoiceHandle PlayAt(int ChannelID, int SampleID, int Flags, float x, float y) override REQUIRES(!m_SoundLock); CVoiceHandle PlayAt(int ChannelId, int SampleId, int Flags, float x, float y) override REQUIRES(!m_SoundLock);
CVoiceHandle Play(int ChannelID, int SampleID, int Flags) override REQUIRES(!m_SoundLock); CVoiceHandle Play(int ChannelId, int SampleId, int Flags) override REQUIRES(!m_SoundLock);
void Pause(int SampleID) override REQUIRES(!m_SoundLock); void Pause(int SampleId) override REQUIRES(!m_SoundLock);
void Stop(int SampleID) override REQUIRES(!m_SoundLock); void Stop(int SampleId) override REQUIRES(!m_SoundLock);
void StopAll() override REQUIRES(!m_SoundLock); void StopAll() override REQUIRES(!m_SoundLock);
void StopVoice(CVoiceHandle Voice) override REQUIRES(!m_SoundLock); void StopVoice(CVoiceHandle Voice) override REQUIRES(!m_SoundLock);
bool IsPlaying(int SampleID) override REQUIRES(!m_SoundLock); bool IsPlaying(int SampleId) override REQUIRES(!m_SoundLock);
void Mix(short *pFinalOut, unsigned Frames) override REQUIRES(!m_SoundLock); void Mix(short *pFinalOut, unsigned Frames) override REQUIRES(!m_SoundLock);
void PauseAudioDevice() override; void PauseAudioDevice() override;

View file

@ -58,7 +58,7 @@ public:
virtual void RemoveArgument(unsigned Index) = 0; virtual void RemoveArgument(unsigned Index) = 0;
int NumArguments() const { return m_NumArgs; } int NumArguments() const { return m_NumArgs; }
int m_ClientID; int m_ClientId;
// DDRace // DDRace
@ -82,7 +82,7 @@ public:
int GetAccessLevel() const { return m_AccessLevel; } int GetAccessLevel() const { return m_AccessLevel; }
}; };
typedef void (*FTeeHistorianCommandCallback)(int ClientID, int FlagMask, const char *pCmd, IResult *pResult, void *pUser); typedef void (*FTeeHistorianCommandCallback)(int ClientId, int FlagMask, const char *pCmd, IResult *pResult, void *pUser);
typedef void (*FPrintCallback)(const char *pStr, void *pUser, ColorRGBA PrintColor); typedef void (*FPrintCallback)(const char *pStr, void *pUser, ColorRGBA PrintColor);
typedef void (*FPossibleCallback)(int Index, const char *pCmd, void *pUser); typedef void (*FPossibleCallback)(int Index, const char *pCmd, void *pUser);
typedef void (*FCommandCallback)(IResult *pResult, void *pUserData); typedef void (*FCommandCallback)(IResult *pResult, void *pUserData);
@ -106,10 +106,10 @@ public:
virtual void StoreCommands(bool Store) = 0; virtual void StoreCommands(bool Store) = 0;
virtual bool LineIsValid(const char *pStr) = 0; virtual bool LineIsValid(const char *pStr) = 0;
virtual void ExecuteLine(const char *pStr, int ClientID = -1, bool InterpretSemicolons = true) = 0; virtual void ExecuteLine(const char *pStr, int ClientId = -1, bool InterpretSemicolons = true) = 0;
virtual void ExecuteLineFlag(const char *pStr, int FlasgMask, int ClientID = -1, bool InterpretSemicolons = true) = 0; virtual void ExecuteLineFlag(const char *pStr, int FlasgMask, int ClientId = -1, bool InterpretSemicolons = true) = 0;
virtual void ExecuteLineStroked(int Stroke, const char *pStr, int ClientID = -1, bool InterpretSemicolons = true) = 0; virtual void ExecuteLineStroked(int Stroke, const char *pStr, int ClientId = -1, bool InterpretSemicolons = true) = 0;
virtual bool ExecuteFile(const char *pFilename, int ClientID = -1, bool LogFailure = false, int StorageType = IStorage::TYPE_ALL) = 0; virtual bool ExecuteFile(const char *pFilename, int ClientId = -1, bool LogFailure = false, int StorageType = IStorage::TYPE_ALL) = 0;
virtual char *Format(char *pBuf, int Size, const char *pFrom, const char *pStr) = 0; virtual char *Format(char *pBuf, int Size, const char *pFrom, const char *pStr) = 0;
virtual void Print(int Level, const char *pFrom, const char *pStr, ColorRGBA PrintColor = gs_ConsoleDefaultColor) const = 0; virtual void Print(int Level, const char *pFrom, const char *pStr, ColorRGBA PrintColor = gs_ConsoleDefaultColor) const = 0;

View file

@ -202,9 +202,9 @@ enum EBackendType
BACKEND_TYPE_COUNT, BACKEND_TYPE_COUNT,
}; };
struct STWGraphicGPU struct STWGraphicGpu
{ {
enum ETWGraphicsGPUType enum ETWGraphicsGpuType
{ {
GRAPHICS_GPU_TYPE_DISCRETE = 0, GRAPHICS_GPU_TYPE_DISCRETE = 0,
GRAPHICS_GPU_TYPE_INTEGRATED, GRAPHICS_GPU_TYPE_INTEGRATED,
@ -215,16 +215,16 @@ struct STWGraphicGPU
GRAPHICS_GPU_TYPE_INVALID, GRAPHICS_GPU_TYPE_INVALID,
}; };
struct STWGraphicGPUItem struct STWGraphicGpuItem
{ {
char m_aName[256]; char m_aName[256];
ETWGraphicsGPUType m_GPUType; ETWGraphicsGpuType m_GpuType;
}; };
std::vector<STWGraphicGPUItem> m_vGPUs; std::vector<STWGraphicGpuItem> m_vGpus;
STWGraphicGPUItem m_AutoGPU; STWGraphicGpuItem m_AutoGpu;
}; };
typedef STWGraphicGPU TTWGraphicsGPUList; typedef STWGraphicGpu TTwGraphicsGpuList;
typedef std::function<void()> WINDOW_RESIZE_FUNC; typedef std::function<void()> WINDOW_RESIZE_FUNC;
typedef std::function<void()> WINDOW_PROPS_CHANGED_FUNC; typedef std::function<void()> WINDOW_PROPS_CHANGED_FUNC;
@ -295,8 +295,8 @@ public:
*/ */
virtual void AddWindowPropChangeListener(WINDOW_PROPS_CHANGED_FUNC pFunc) = 0; virtual void AddWindowPropChangeListener(WINDOW_PROPS_CHANGED_FUNC pFunc) = 0;
virtual void WindowDestroyNtf(uint32_t WindowID) = 0; virtual void WindowDestroyNtf(uint32_t WindowId) = 0;
virtual void WindowCreateNtf(uint32_t WindowID) = 0; virtual void WindowCreateNtf(uint32_t WindowId) = 0;
// ForceClearNow forces the backend to trigger a clear, even at performance cost, else it might be delayed by one frame // ForceClearNow forces the backend to trigger a clear, even at performance cost, else it might be delayed by one frame
virtual void Clear(float r, float g, float b, bool ForceClearNow = false) = 0; virtual void Clear(float r, float g, float b, bool ForceClearNow = false) = 0;
@ -319,7 +319,7 @@ public:
virtual uint64_t StreamedMemoryUsage() const = 0; virtual uint64_t StreamedMemoryUsage() const = 0;
virtual uint64_t StagingMemoryUsage() const = 0; virtual uint64_t StagingMemoryUsage() const = 0;
virtual const TTWGraphicsGPUList &GetGPUs() const = 0; virtual const TTwGraphicsGpuList &GetGpus() const = 0;
virtual bool LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) = 0; virtual bool LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) = 0;
virtual void FreePNG(CImageInfo *pImg) = 0; virtual void FreePNG(CImageInfo *pImg) = 0;
@ -336,7 +336,7 @@ public:
virtual int UnloadTexture(CTextureHandle *pIndex) = 0; virtual int UnloadTexture(CTextureHandle *pIndex) = 0;
virtual CTextureHandle LoadTextureRaw(size_t Width, size_t Height, CImageInfo::EImageFormat Format, const void *pData, int Flags, const char *pTexName = nullptr) = 0; virtual CTextureHandle LoadTextureRaw(size_t Width, size_t Height, CImageInfo::EImageFormat Format, const void *pData, int Flags, const char *pTexName = nullptr) = 0;
virtual CTextureHandle LoadTextureRawMove(size_t Width, size_t Height, CImageInfo::EImageFormat Format, void *pData, int Flags, const char *pTexName = nullptr) = 0; virtual CTextureHandle LoadTextureRawMove(size_t Width, size_t Height, CImageInfo::EImageFormat Format, void *pData, int Flags, const char *pTexName = nullptr) = 0;
virtual int LoadTextureRawSub(CTextureHandle TextureID, int x, int y, size_t Width, size_t Height, CImageInfo::EImageFormat Format, const void *pData) = 0; virtual int LoadTextureRawSub(CTextureHandle TextureId, int x, int y, size_t Width, size_t Height, CImageInfo::EImageFormat Format, const void *pData) = 0;
virtual CTextureHandle LoadTexture(const char *pFilename, int StorageType, int Flags = 0) = 0; virtual CTextureHandle LoadTexture(const char *pFilename, int StorageType, int Flags = 0) = 0;
virtual CTextureHandle NullTexture() const = 0; virtual CTextureHandle NullTexture() const = 0;
virtual void TextureSet(CTextureHandle Texture) = 0; virtual void TextureSet(CTextureHandle Texture) = 0;
@ -345,7 +345,7 @@ public:
// pTextData & pTextOutlineData are automatically free'd // pTextData & pTextOutlineData are automatically free'd
virtual bool LoadTextTextures(size_t Width, size_t Height, CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture, void *pTextData, void *pTextOutlineData) = 0; virtual bool LoadTextTextures(size_t Width, size_t Height, CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture, void *pTextData, void *pTextOutlineData) = 0;
virtual bool UnloadTextTextures(CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture) = 0; virtual bool UnloadTextTextures(CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture) = 0;
virtual bool UpdateTextTexture(CTextureHandle TextureID, int x, int y, size_t Width, size_t Height, const void *pData) = 0; virtual bool UpdateTextTexture(CTextureHandle TextureId, int x, int y, size_t Width, size_t Height, const void *pData) = 0;
virtual CTextureHandle LoadSpriteTexture(CImageInfo &FromImageInfo, struct CDataSprite *pSprite) = 0; virtual CTextureHandle LoadSpriteTexture(CImageInfo &FromImageInfo, struct CDataSprite *pSprite) = 0;

View file

@ -24,10 +24,10 @@ public:
virtual int NumData() const = 0; virtual int NumData() const = 0;
virtual int GetItemSize(int Index) = 0; virtual int GetItemSize(int Index) = 0;
virtual void *GetItem(int Index, int *pType = nullptr, int *pID = nullptr) = 0; virtual void *GetItem(int Index, int *pType = nullptr, int *pId = nullptr) = 0;
virtual void GetType(int Type, int *pStart, int *pNum) = 0; virtual void GetType(int Type, int *pStart, int *pNum) = 0;
virtual int FindItemIndex(int Type, int ID) = 0; virtual int FindItemIndex(int Type, int Id) = 0;
virtual void *FindItem(int Type, int ID) = 0; virtual void *FindItem(int Type, int Id) = 0;
virtual int NumItems() const = 0; virtual int NumItems() const = 0;
}; };

View file

@ -9,18 +9,18 @@
class CMsgPacker : public CPacker class CMsgPacker : public CPacker
{ {
public: public:
int m_MsgID; int m_MsgId;
bool m_System; bool m_System;
bool m_NoTranslate; bool m_NoTranslate;
CMsgPacker(int Type, bool System = false, bool NoTranslate = false) : CMsgPacker(int Type, bool System = false, bool NoTranslate = false) :
m_MsgID(Type), m_System(System), m_NoTranslate(NoTranslate) m_MsgId(Type), m_System(System), m_NoTranslate(NoTranslate)
{ {
Reset(); Reset();
} }
template<typename T> template<typename T>
CMsgPacker(const T *, bool System = false, bool NoTranslate = false) : CMsgPacker(const T *, bool System = false, bool NoTranslate = false) :
CMsgPacker(T::ms_MsgID, System, NoTranslate) CMsgPacker(T::ms_MsgId, System, NoTranslate)
{ {
} }
}; };

View file

@ -19,7 +19,7 @@
struct CAntibotRoundData; struct CAntibotRoundData;
// When recording a demo on the server, the ClientID -1 is used // When recording a demo on the server, the ClientId -1 is used
enum enum
{ {
SERVER_DEMO_CLIENT = -1 SERVER_DEMO_CLIENT = -1
@ -42,7 +42,7 @@ public:
bool m_GotDDNetVersion; bool m_GotDDNetVersion;
int m_DDNetVersion; int m_DDNetVersion;
const char *m_pDDNetVersionStr; const char *m_pDDNetVersionStr;
const CUuid *m_pConnectionID; const CUuid *m_pConnectionId;
}; };
int Tick() const { return m_CurrentGameTick; } int Tick() const { return m_CurrentGameTick; }
@ -52,34 +52,34 @@ public:
virtual int MaxClients() const = 0; virtual int MaxClients() const = 0;
virtual int ClientCount() const = 0; virtual int ClientCount() const = 0;
virtual int DistinctClientCount() const = 0; virtual int DistinctClientCount() const = 0;
virtual const char *ClientName(int ClientID) const = 0; virtual const char *ClientName(int ClientId) const = 0;
virtual const char *ClientClan(int ClientID) const = 0; virtual const char *ClientClan(int ClientId) const = 0;
virtual int ClientCountry(int ClientID) const = 0; virtual int ClientCountry(int ClientId) const = 0;
virtual bool ClientSlotEmpty(int ClientID) const = 0; virtual bool ClientSlotEmpty(int ClientId) const = 0;
virtual bool ClientIngame(int ClientID) const = 0; virtual bool ClientIngame(int ClientId) const = 0;
virtual bool ClientAuthed(int ClientID) const = 0; virtual bool ClientAuthed(int ClientId) const = 0;
virtual bool GetClientInfo(int ClientID, CClientInfo *pInfo) const = 0; virtual bool GetClientInfo(int ClientId, CClientInfo *pInfo) const = 0;
virtual void SetClientDDNetVersion(int ClientID, int DDNetVersion) = 0; virtual void SetClientDDNetVersion(int ClientId, int DDNetVersion) = 0;
virtual void GetClientAddr(int ClientID, char *pAddrStr, int Size) const = 0; virtual void GetClientAddr(int ClientId, char *pAddrStr, int Size) const = 0;
/** /**
* Returns the version of the client with the given client ID. * Returns the version of the client with the given client ID.
* *
* @param ClientID the client ID, which must be between 0 and * @param ClientId the client Id, which must be between 0 and
* MAX_CLIENTS - 1, or equal to SERVER_DEMO_CLIENT for server demos. * MAX_CLIENTS - 1, or equal to SERVER_DEMO_CLIENT for server demos.
* *
* @return The version of the client with the given client ID. * @return The version of the client with the given client ID.
* For server demos this is always the latest client version. * For server demos this is always the latest client version.
* On errors, VERSION_NONE is returned. * On errors, VERSION_NONE is returned.
*/ */
virtual int GetClientVersion(int ClientID) const = 0; virtual int GetClientVersion(int ClientId) const = 0;
virtual int SendMsg(CMsgPacker *pMsg, int Flags, int ClientID) = 0; virtual int SendMsg(CMsgPacker *pMsg, int Flags, int ClientId) = 0;
template<class T, typename std::enable_if<!protocol7::is_sixup<T>::value, int>::type = 0> template<class T, typename std::enable_if<!protocol7::is_sixup<T>::value, int>::type = 0>
inline int SendPackMsg(const T *pMsg, int Flags, int ClientID) inline int SendPackMsg(const T *pMsg, int Flags, int ClientId)
{ {
int Result = 0; int Result = 0;
if(ClientID == -1) if(ClientId == -1)
{ {
for(int i = 0; i < MaxClients(); i++) for(int i = 0; i < MaxClients(); i++)
if(ClientIngame(i)) if(ClientIngame(i))
@ -87,101 +87,101 @@ public:
} }
else else
{ {
Result = SendPackMsgTranslate(pMsg, Flags, ClientID); Result = SendPackMsgTranslate(pMsg, Flags, ClientId);
} }
return Result; return Result;
} }
template<class T, typename std::enable_if<protocol7::is_sixup<T>::value, int>::type = 1> template<class T, typename std::enable_if<protocol7::is_sixup<T>::value, int>::type = 1>
inline int SendPackMsg(const T *pMsg, int Flags, int ClientID) inline int SendPackMsg(const T *pMsg, int Flags, int ClientId)
{ {
int Result = 0; int Result = 0;
if(ClientID == -1) if(ClientId == -1)
{ {
for(int i = 0; i < MaxClients(); i++) for(int i = 0; i < MaxClients(); i++)
if(ClientIngame(i) && IsSixup(i)) if(ClientIngame(i) && IsSixup(i))
Result = SendPackMsgOne(pMsg, Flags, i); Result = SendPackMsgOne(pMsg, Flags, i);
} }
else if(IsSixup(ClientID)) else if(IsSixup(ClientId))
Result = SendPackMsgOne(pMsg, Flags, ClientID); Result = SendPackMsgOne(pMsg, Flags, ClientId);
return Result; return Result;
} }
template<class T> template<class T>
int SendPackMsgTranslate(const T *pMsg, int Flags, int ClientID) int SendPackMsgTranslate(const T *pMsg, int Flags, int ClientId)
{ {
return SendPackMsgOne(pMsg, Flags, ClientID); return SendPackMsgOne(pMsg, Flags, ClientId);
} }
int SendPackMsgTranslate(const CNetMsg_Sv_Emoticon *pMsg, int Flags, int ClientID) int SendPackMsgTranslate(const CNetMsg_Sv_Emoticon *pMsg, int Flags, int ClientId)
{ {
CNetMsg_Sv_Emoticon MsgCopy; CNetMsg_Sv_Emoticon MsgCopy;
mem_copy(&MsgCopy, pMsg, sizeof(MsgCopy)); mem_copy(&MsgCopy, pMsg, sizeof(MsgCopy));
return Translate(MsgCopy.m_ClientID, ClientID) && SendPackMsgOne(&MsgCopy, Flags, ClientID); return Translate(MsgCopy.m_ClientId, ClientId) && SendPackMsgOne(&MsgCopy, Flags, ClientId);
} }
int SendPackMsgTranslate(const CNetMsg_Sv_Chat *pMsg, int Flags, int ClientID) int SendPackMsgTranslate(const CNetMsg_Sv_Chat *pMsg, int Flags, int ClientId)
{ {
CNetMsg_Sv_Chat MsgCopy; CNetMsg_Sv_Chat MsgCopy;
mem_copy(&MsgCopy, pMsg, sizeof(MsgCopy)); mem_copy(&MsgCopy, pMsg, sizeof(MsgCopy));
char aBuf[1000]; char aBuf[1000];
if(MsgCopy.m_ClientID >= 0 && !Translate(MsgCopy.m_ClientID, ClientID)) if(MsgCopy.m_ClientId >= 0 && !Translate(MsgCopy.m_ClientId, ClientId))
{ {
str_format(aBuf, sizeof(aBuf), "%s: %s", ClientName(MsgCopy.m_ClientID), MsgCopy.m_pMessage); str_format(aBuf, sizeof(aBuf), "%s: %s", ClientName(MsgCopy.m_ClientId), MsgCopy.m_pMessage);
MsgCopy.m_pMessage = aBuf; MsgCopy.m_pMessage = aBuf;
MsgCopy.m_ClientID = VANILLA_MAX_CLIENTS - 1; MsgCopy.m_ClientId = VANILLA_MAX_CLIENTS - 1;
} }
if(IsSixup(ClientID)) if(IsSixup(ClientId))
{ {
protocol7::CNetMsg_Sv_Chat Msg7; protocol7::CNetMsg_Sv_Chat Msg7;
Msg7.m_ClientID = MsgCopy.m_ClientID; Msg7.m_ClientId = MsgCopy.m_ClientId;
Msg7.m_pMessage = MsgCopy.m_pMessage; Msg7.m_pMessage = MsgCopy.m_pMessage;
Msg7.m_Mode = MsgCopy.m_Team > 0 ? protocol7::CHAT_TEAM : protocol7::CHAT_ALL; Msg7.m_Mode = MsgCopy.m_Team > 0 ? protocol7::CHAT_TEAM : protocol7::CHAT_ALL;
Msg7.m_TargetID = -1; Msg7.m_TargetId = -1;
return SendPackMsgOne(&Msg7, Flags, ClientID); return SendPackMsgOne(&Msg7, Flags, ClientId);
} }
return SendPackMsgOne(&MsgCopy, Flags, ClientID); return SendPackMsgOne(&MsgCopy, Flags, ClientId);
} }
int SendPackMsgTranslate(const CNetMsg_Sv_KillMsg *pMsg, int Flags, int ClientID) int SendPackMsgTranslate(const CNetMsg_Sv_KillMsg *pMsg, int Flags, int ClientId)
{ {
CNetMsg_Sv_KillMsg MsgCopy; CNetMsg_Sv_KillMsg MsgCopy;
mem_copy(&MsgCopy, pMsg, sizeof(MsgCopy)); mem_copy(&MsgCopy, pMsg, sizeof(MsgCopy));
if(!Translate(MsgCopy.m_Victim, ClientID)) if(!Translate(MsgCopy.m_Victim, ClientId))
return 0; return 0;
if(!Translate(MsgCopy.m_Killer, ClientID)) if(!Translate(MsgCopy.m_Killer, ClientId))
MsgCopy.m_Killer = MsgCopy.m_Victim; MsgCopy.m_Killer = MsgCopy.m_Victim;
return SendPackMsgOne(&MsgCopy, Flags, ClientID); return SendPackMsgOne(&MsgCopy, Flags, ClientId);
} }
int SendPackMsgTranslate(const CNetMsg_Sv_RaceFinish *pMsg, int Flags, int ClientID) int SendPackMsgTranslate(const CNetMsg_Sv_RaceFinish *pMsg, int Flags, int ClientId)
{ {
if(IsSixup(ClientID)) if(IsSixup(ClientId))
{ {
protocol7::CNetMsg_Sv_RaceFinish Msg7; protocol7::CNetMsg_Sv_RaceFinish Msg7;
Msg7.m_ClientID = pMsg->m_ClientID; Msg7.m_ClientId = pMsg->m_ClientId;
Msg7.m_Diff = pMsg->m_Diff; Msg7.m_Diff = pMsg->m_Diff;
Msg7.m_Time = pMsg->m_Time; Msg7.m_Time = pMsg->m_Time;
Msg7.m_RecordPersonal = pMsg->m_RecordPersonal; Msg7.m_RecordPersonal = pMsg->m_RecordPersonal;
Msg7.m_RecordServer = pMsg->m_RecordServer; Msg7.m_RecordServer = pMsg->m_RecordServer;
return SendPackMsgOne(&Msg7, Flags, ClientID); return SendPackMsgOne(&Msg7, Flags, ClientId);
} }
return SendPackMsgOne(pMsg, Flags, ClientID); return SendPackMsgOne(pMsg, Flags, ClientId);
} }
template<class T> template<class T>
int SendPackMsgOne(const T *pMsg, int Flags, int ClientID) int SendPackMsgOne(const T *pMsg, int Flags, int ClientId)
{ {
dbg_assert(ClientID != -1, "SendPackMsgOne called with -1"); dbg_assert(ClientId != -1, "SendPackMsgOne called with -1");
CMsgPacker Packer(T::ms_MsgID, false, protocol7::is_sixup<T>::value); CMsgPacker Packer(T::ms_MsgId, false, protocol7::is_sixup<T>::value);
if(pMsg->Pack(&Packer)) if(pMsg->Pack(&Packer))
return -1; return -1;
return SendMsg(&Packer, Flags, ClientID); return SendMsg(&Packer, Flags, ClientId);
} }
bool Translate(int &Target, int Client) bool Translate(int &Target, int Client)
@ -220,23 +220,23 @@ public:
virtual void GetMapInfo(char *pMapName, int MapNameSize, int *pMapSize, SHA256_DIGEST *pSha256, int *pMapCrc) = 0; virtual void GetMapInfo(char *pMapName, int MapNameSize, int *pMapSize, SHA256_DIGEST *pSha256, int *pMapCrc) = 0;
virtual bool WouldClientNameChange(int ClientID, const char *pNameRequest) = 0; virtual bool WouldClientNameChange(int ClientId, const char *pNameRequest) = 0;
virtual bool WouldClientClanChange(int ClientID, const char *pClanRequest) = 0; virtual bool WouldClientClanChange(int ClientId, const char *pClanRequest) = 0;
virtual void SetClientName(int ClientID, const char *pName) = 0; virtual void SetClientName(int ClientId, const char *pName) = 0;
virtual void SetClientClan(int ClientID, const char *pClan) = 0; virtual void SetClientClan(int ClientId, const char *pClan) = 0;
virtual void SetClientCountry(int ClientID, int Country) = 0; virtual void SetClientCountry(int ClientId, int Country) = 0;
virtual void SetClientScore(int ClientID, std::optional<int> Score) = 0; virtual void SetClientScore(int ClientId, std::optional<int> Score) = 0;
virtual void SetClientFlags(int ClientID, int Flags) = 0; virtual void SetClientFlags(int ClientId, int Flags) = 0;
virtual int SnapNewID() = 0; virtual int SnapNewId() = 0;
virtual void SnapFreeID(int ID) = 0; virtual void SnapFreeId(int Id) = 0;
virtual void *SnapNewItem(int Type, int ID, int Size) = 0; virtual void *SnapNewItem(int Type, int Id, int Size) = 0;
template<typename T> template<typename T>
T *SnapNewItem(int ID) T *SnapNewItem(int Id)
{ {
const int Type = protocol7::is_sixup<T>::value ? -T::ms_MsgID : T::ms_MsgID; const int Type = protocol7::is_sixup<T>::value ? -T::ms_MsgId : T::ms_MsgId;
return static_cast<T *>(SnapNewItem(Type, ID, sizeof(T))); return static_cast<T *>(SnapNewItem(Type, Id, sizeof(T)));
} }
virtual void SnapSetStaticsize(int ItemType, int Size) = 0; virtual void SnapSetStaticsize(int ItemType, int Size) = 0;
@ -246,48 +246,48 @@ public:
RCON_CID_SERV = -1, RCON_CID_SERV = -1,
RCON_CID_VOTE = -2, RCON_CID_VOTE = -2,
}; };
virtual void SetRconCID(int ClientID) = 0; virtual void SetRconCid(int ClientId) = 0;
virtual int GetAuthedState(int ClientID) const = 0; virtual int GetAuthedState(int ClientId) const = 0;
virtual const char *GetAuthName(int ClientID) const = 0; virtual const char *GetAuthName(int ClientId) const = 0;
virtual void Kick(int ClientID, const char *pReason) = 0; virtual void Kick(int ClientId, const char *pReason) = 0;
virtual void Ban(int ClientID, int Seconds, const char *pReason) = 0; virtual void Ban(int ClientId, int Seconds, const char *pReason) = 0;
virtual void RedirectClient(int ClientID, int Port, bool Verbose = false) = 0; virtual void RedirectClient(int ClientId, int Port, bool Verbose = false) = 0;
virtual void ChangeMap(const char *pMap) = 0; virtual void ChangeMap(const char *pMap) = 0;
virtual void DemoRecorder_HandleAutoStart() = 0; virtual void DemoRecorder_HandleAutoStart() = 0;
// DDRace // DDRace
virtual void SaveDemo(int ClientID, float Time) = 0; virtual void SaveDemo(int ClientId, float Time) = 0;
virtual void StartRecord(int ClientID) = 0; virtual void StartRecord(int ClientId) = 0;
virtual void StopRecord(int ClientID) = 0; virtual void StopRecord(int ClientId) = 0;
virtual bool IsRecording(int ClientID) = 0; virtual bool IsRecording(int ClientId) = 0;
virtual void StopDemos() = 0; virtual void StopDemos() = 0;
virtual void GetClientAddr(int ClientID, NETADDR *pAddr) const = 0; virtual void GetClientAddr(int ClientId, NETADDR *pAddr) const = 0;
virtual int *GetIdMap(int ClientID) = 0; virtual int *GetIdMap(int ClientId) = 0;
virtual bool DnsblWhite(int ClientID) = 0; virtual bool DnsblWhite(int ClientId) = 0;
virtual bool DnsblPending(int ClientID) = 0; virtual bool DnsblPending(int ClientId) = 0;
virtual bool DnsblBlack(int ClientID) = 0; virtual bool DnsblBlack(int ClientId) = 0;
virtual const char *GetAnnouncementLine(const char *pFileName) = 0; virtual const char *GetAnnouncementLine(const char *pFileName) = 0;
virtual bool ClientPrevIngame(int ClientID) = 0; virtual bool ClientPrevIngame(int ClientId) = 0;
virtual const char *GetNetErrorString(int ClientID) = 0; virtual const char *GetNetErrorString(int ClientId) = 0;
virtual void ResetNetErrorString(int ClientID) = 0; virtual void ResetNetErrorString(int ClientId) = 0;
virtual bool SetTimedOut(int ClientID, int OrigID) = 0; virtual bool SetTimedOut(int ClientId, int OrigId) = 0;
virtual void SetTimeoutProtected(int ClientID) = 0; virtual void SetTimeoutProtected(int ClientId) = 0;
virtual void SetErrorShutdown(const char *pReason) = 0; virtual void SetErrorShutdown(const char *pReason) = 0;
virtual void ExpireServerInfo() = 0; virtual void ExpireServerInfo() = 0;
virtual void FillAntibot(CAntibotRoundData *pData) = 0; virtual void FillAntibot(CAntibotRoundData *pData) = 0;
virtual void SendMsgRaw(int ClientID, const void *pData, int Size, int Flags) = 0; virtual void SendMsgRaw(int ClientId, const void *pData, int Size, int Flags) = 0;
virtual const char *GetMapName() const = 0; virtual const char *GetMapName() const = 0;
virtual bool IsSixup(int ClientID) const = 0; virtual bool IsSixup(int ClientId) const = 0;
}; };
class IGameServer : public IInterface class IGameServer : public IInterface
@ -306,10 +306,10 @@ public:
virtual void OnTick() = 0; virtual void OnTick() = 0;
virtual void OnPreSnap() = 0; virtual void OnPreSnap() = 0;
virtual void OnSnap(int ClientID) = 0; virtual void OnSnap(int ClientId) = 0;
virtual void OnPostSnap() = 0; virtual void OnPostSnap() = 0;
virtual void OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) = 0; virtual void OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId) = 0;
// Called before map reload, for any data that the game wants to // Called before map reload, for any data that the game wants to
// persist to the next map. // persist to the next map.
@ -318,24 +318,24 @@ public:
// //
// Returns whether the game should be supplied with the data when the // Returns whether the game should be supplied with the data when the
// client connects for the next map. // client connects for the next map.
virtual bool OnClientDataPersist(int ClientID, void *pData) = 0; virtual bool OnClientDataPersist(int ClientId, void *pData) = 0;
// Called when a client connects. // Called when a client connects.
// //
// If it is reconnecting to the game after a map change, the // If it is reconnecting to the game after a map change, the
// `pPersistentData` point is nonnull and contains the data the game // `pPersistentData` point is nonnull and contains the data the game
// previously stored. // previously stored.
virtual void OnClientConnected(int ClientID, void *pPersistentData) = 0; virtual void OnClientConnected(int ClientId, void *pPersistentData) = 0;
virtual void OnClientEnter(int ClientID) = 0; virtual void OnClientEnter(int ClientId) = 0;
virtual void OnClientDrop(int ClientID, const char *pReason) = 0; virtual void OnClientDrop(int ClientId, const char *pReason) = 0;
virtual void OnClientPrepareInput(int ClientID, void *pInput) = 0; virtual void OnClientPrepareInput(int ClientId, void *pInput) = 0;
virtual void OnClientDirectInput(int ClientID, void *pInput) = 0; virtual void OnClientDirectInput(int ClientId, void *pInput) = 0;
virtual void OnClientPredictedInput(int ClientID, void *pInput) = 0; virtual void OnClientPredictedInput(int ClientId, void *pInput) = 0;
virtual void OnClientPredictedEarlyInput(int ClientID, void *pInput) = 0; virtual void OnClientPredictedEarlyInput(int ClientId, void *pInput) = 0;
virtual bool IsClientReady(int ClientID) const = 0; virtual bool IsClientReady(int ClientId) const = 0;
virtual bool IsClientPlayer(int ClientID) const = 0; virtual bool IsClientPlayer(int ClientId) const = 0;
virtual int PersistentDataSize() const = 0; virtual int PersistentDataSize() const = 0;
virtual int PersistentClientDataSize() const = 0; virtual int PersistentClientDataSize() const = 0;
@ -349,13 +349,13 @@ public:
virtual void OnPreTickTeehistorian() = 0; virtual void OnPreTickTeehistorian() = 0;
virtual void OnSetAuthed(int ClientID, int Level) = 0; virtual void OnSetAuthed(int ClientId, int Level) = 0;
virtual bool PlayerExists(int ClientID) const = 0; virtual bool PlayerExists(int ClientId) const = 0;
virtual void TeehistorianRecordAntibot(const void *pData, int DataSize) = 0; virtual void TeehistorianRecordAntibot(const void *pData, int DataSize) = 0;
virtual void TeehistorianRecordPlayerJoin(int ClientID, bool Sixup) = 0; virtual void TeehistorianRecordPlayerJoin(int ClientId, bool Sixup) = 0;
virtual void TeehistorianRecordPlayerDrop(int ClientID, const char *pReason) = 0; virtual void TeehistorianRecordPlayerDrop(int ClientId, const char *pReason) = 0;
virtual void TeehistorianRecordPlayerRejoin(int ClientID) = 0; virtual void TeehistorianRecordPlayerRejoin(int ClientId) = 0;
virtual void FillAntibot(CAntibotRoundData *pData) = 0; virtual void FillAntibot(CAntibotRoundData *pData) = 0;
@ -365,7 +365,7 @@ public:
* @param aBuf Should be the json key values to add, starting with a ',' beforehand, like: ',"skin": "default", "team": 1' * @param aBuf Should be the json key values to add, starting with a ',' beforehand, like: ',"skin": "default", "team": 1'
* @param i The client id. * @param i The client id.
*/ */
virtual void OnUpdatePlayerServerInfo(char *aBuf, int BufSize, int ID) = 0; virtual void OnUpdatePlayerServerInfo(char *aBuf, int BufSize, int Id) = 0;
}; };
extern IGameServer *CreateGameServer(); extern IGameServer *CreateGameServer();

View file

@ -23,23 +23,23 @@ CAntibot::~CAntibot()
if(m_Initialized) if(m_Initialized)
AntibotDestroy(); AntibotDestroy();
} }
void CAntibot::Kick(int ClientID, const char *pMessage, void *pUser) void CAntibot::Kick(int ClientId, const char *pMessage, void *pUser)
{ {
CAntibot *pAntibot = (CAntibot *)pUser; CAntibot *pAntibot = (CAntibot *)pUser;
pAntibot->Server()->Kick(ClientID, pMessage); pAntibot->Server()->Kick(ClientId, pMessage);
} }
void CAntibot::Log(const char *pMessage, void *pUser) void CAntibot::Log(const char *pMessage, void *pUser)
{ {
CAntibot *pAntibot = (CAntibot *)pUser; CAntibot *pAntibot = (CAntibot *)pUser;
pAntibot->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "antibot", pMessage); pAntibot->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "antibot", pMessage);
} }
void CAntibot::Report(int ClientID, const char *pMessage, void *pUser) void CAntibot::Report(int ClientId, const char *pMessage, void *pUser)
{ {
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "%d: %s", ClientID, pMessage); str_format(aBuf, sizeof(aBuf), "%d: %s", ClientId, pMessage);
Log(aBuf, pUser); Log(aBuf, pUser);
} }
void CAntibot::Send(int ClientID, const void *pData, int Size, int Flags, void *pUser) void CAntibot::Send(int ClientId, const void *pData, int Size, int Flags, void *pUser)
{ {
CAntibot *pAntibot = (CAntibot *)pUser; CAntibot *pAntibot = (CAntibot *)pUser;
@ -52,7 +52,7 @@ void CAntibot::Send(int ClientID, const void *pData, int Size, int Flags, void *
{ {
RealFlags |= MSGFLAG_FLUSH; RealFlags |= MSGFLAG_FLUSH;
} }
pAntibot->Server()->SendMsgRaw(ClientID, pData, Size, RealFlags); pAntibot->Server()->SendMsgRaw(ClientId, pData, Size, RealFlags);
} }
void CAntibot::Teehistorian(const void *pData, int Size, void *pUser) void CAntibot::Teehistorian(const void *pData, int Size, void *pUser)
{ {
@ -115,50 +115,50 @@ void CAntibot::Update()
} }
} }
void CAntibot::OnPlayerInit(int ClientID) void CAntibot::OnPlayerInit(int ClientId)
{ {
Update(); Update();
AntibotOnPlayerInit(ClientID); AntibotOnPlayerInit(ClientId);
} }
void CAntibot::OnPlayerDestroy(int ClientID) void CAntibot::OnPlayerDestroy(int ClientId)
{ {
Update(); Update();
AntibotOnPlayerDestroy(ClientID); AntibotOnPlayerDestroy(ClientId);
} }
void CAntibot::OnSpawn(int ClientID) void CAntibot::OnSpawn(int ClientId)
{ {
Update(); Update();
AntibotOnSpawn(ClientID); AntibotOnSpawn(ClientId);
} }
void CAntibot::OnHammerFireReloading(int ClientID) void CAntibot::OnHammerFireReloading(int ClientId)
{ {
Update(); Update();
AntibotOnHammerFireReloading(ClientID); AntibotOnHammerFireReloading(ClientId);
} }
void CAntibot::OnHammerFire(int ClientID) void CAntibot::OnHammerFire(int ClientId)
{ {
Update(); Update();
AntibotOnHammerFire(ClientID); AntibotOnHammerFire(ClientId);
} }
void CAntibot::OnHammerHit(int ClientID, int TargetID) void CAntibot::OnHammerHit(int ClientId, int TargetId)
{ {
Update(); Update();
AntibotOnHammerHit(ClientID, TargetID); AntibotOnHammerHit(ClientId, TargetId);
} }
void CAntibot::OnDirectInput(int ClientID) void CAntibot::OnDirectInput(int ClientId)
{ {
Update(); Update();
AntibotOnDirectInput(ClientID); AntibotOnDirectInput(ClientId);
} }
void CAntibot::OnCharacterTick(int ClientID) void CAntibot::OnCharacterTick(int ClientId)
{ {
Update(); Update();
AntibotOnCharacterTick(ClientID); AntibotOnCharacterTick(ClientId);
} }
void CAntibot::OnHookAttach(int ClientID, bool Player) void CAntibot::OnHookAttach(int ClientId, bool Player)
{ {
Update(); Update();
AntibotOnHookAttach(ClientID, Player); AntibotOnHookAttach(ClientId, Player);
} }
void CAntibot::OnEngineTick() void CAntibot::OnEngineTick()
@ -166,17 +166,17 @@ void CAntibot::OnEngineTick()
Update(); Update();
AntibotOnEngineTick(); AntibotOnEngineTick();
} }
void CAntibot::OnEngineClientJoin(int ClientID, bool Sixup) void CAntibot::OnEngineClientJoin(int ClientId, bool Sixup)
{ {
Update(); Update();
AntibotOnEngineClientJoin(ClientID, Sixup); AntibotOnEngineClientJoin(ClientId, Sixup);
} }
void CAntibot::OnEngineClientDrop(int ClientID, const char *pReason) void CAntibot::OnEngineClientDrop(int ClientId, const char *pReason)
{ {
Update(); Update();
AntibotOnEngineClientDrop(ClientID, pReason); AntibotOnEngineClientDrop(ClientId, pReason);
} }
bool CAntibot::OnEngineClientMessage(int ClientID, const void *pData, int Size, int Flags) bool CAntibot::OnEngineClientMessage(int ClientId, const void *pData, int Size, int Flags)
{ {
Update(); Update();
int AntibotFlags = 0; int AntibotFlags = 0;
@ -184,9 +184,9 @@ bool CAntibot::OnEngineClientMessage(int ClientID, const void *pData, int Size,
{ {
AntibotFlags |= ANTIBOT_MSGFLAG_NONVITAL; AntibotFlags |= ANTIBOT_MSGFLAG_NONVITAL;
} }
return AntibotOnEngineClientMessage(ClientID, pData, Size, AntibotFlags); return AntibotOnEngineClientMessage(ClientId, pData, Size, AntibotFlags);
} }
bool CAntibot::OnEngineServerMessage(int ClientID, const void *pData, int Size, int Flags) bool CAntibot::OnEngineServerMessage(int ClientId, const void *pData, int Size, int Flags)
{ {
Update(); Update();
int AntibotFlags = 0; int AntibotFlags = 0;
@ -194,12 +194,12 @@ bool CAntibot::OnEngineServerMessage(int ClientID, const void *pData, int Size,
{ {
AntibotFlags |= ANTIBOT_MSGFLAG_NONVITAL; AntibotFlags |= ANTIBOT_MSGFLAG_NONVITAL;
} }
return AntibotOnEngineServerMessage(ClientID, pData, Size, AntibotFlags); return AntibotOnEngineServerMessage(ClientId, pData, Size, AntibotFlags);
} }
bool CAntibot::OnEngineSimulateClientMessage(int *pClientID, void *pBuffer, int BufferSize, int *pOutSize, int *pFlags) bool CAntibot::OnEngineSimulateClientMessage(int *pClientId, void *pBuffer, int BufferSize, int *pOutSize, int *pFlags)
{ {
int AntibotFlags = 0; int AntibotFlags = 0;
bool Result = AntibotOnEngineSimulateClientMessage(pClientID, pBuffer, BufferSize, pOutSize, &AntibotFlags); bool Result = AntibotOnEngineSimulateClientMessage(pClientId, pBuffer, BufferSize, pOutSize, &AntibotFlags);
if(Result) if(Result)
{ {
*pFlags = 0; *pFlags = 0;
@ -245,22 +245,22 @@ void CAntibot::Update()
{ {
} }
void CAntibot::OnPlayerInit(int ClientID) {} void CAntibot::OnPlayerInit(int ClientId) {}
void CAntibot::OnPlayerDestroy(int ClientID) {} void CAntibot::OnPlayerDestroy(int ClientId) {}
void CAntibot::OnSpawn(int ClientID) {} void CAntibot::OnSpawn(int ClientId) {}
void CAntibot::OnHammerFireReloading(int ClientID) {} void CAntibot::OnHammerFireReloading(int ClientId) {}
void CAntibot::OnHammerFire(int ClientID) {} void CAntibot::OnHammerFire(int ClientId) {}
void CAntibot::OnHammerHit(int ClientID, int TargetID) {} void CAntibot::OnHammerHit(int ClientId, int TargetId) {}
void CAntibot::OnDirectInput(int ClientID) {} void CAntibot::OnDirectInput(int ClientId) {}
void CAntibot::OnCharacterTick(int ClientID) {} void CAntibot::OnCharacterTick(int ClientId) {}
void CAntibot::OnHookAttach(int ClientID, bool Player) {} void CAntibot::OnHookAttach(int ClientId, bool Player) {}
void CAntibot::OnEngineTick() {} void CAntibot::OnEngineTick() {}
void CAntibot::OnEngineClientJoin(int ClientID, bool Sixup) {} void CAntibot::OnEngineClientJoin(int ClientId, bool Sixup) {}
void CAntibot::OnEngineClientDrop(int ClientID, const char *pReason) {} void CAntibot::OnEngineClientDrop(int ClientId, const char *pReason) {}
bool CAntibot::OnEngineClientMessage(int ClientID, const void *pData, int Size, int Flags) { return false; } bool CAntibot::OnEngineClientMessage(int ClientId, const void *pData, int Size, int Flags) { return false; }
bool CAntibot::OnEngineServerMessage(int ClientID, const void *pData, int Size, int Flags) { return false; } bool CAntibot::OnEngineServerMessage(int ClientId, const void *pData, int Size, int Flags) { return false; }
bool CAntibot::OnEngineSimulateClientMessage(int *pClientID, void *pBuffer, int BufferSize, int *pOutSize, int *pFlags) { return false; } bool CAntibot::OnEngineSimulateClientMessage(int *pClientId, void *pBuffer, int BufferSize, int *pOutSize, int *pFlags) { return false; }
#endif #endif
IEngineAntibot *CreateEngineAntibot() IEngineAntibot *CreateEngineAntibot()

View file

@ -19,10 +19,10 @@ class CAntibot : public IEngineAntibot
bool m_Initialized; bool m_Initialized;
void Update(); void Update();
static void Kick(int ClientID, const char *pMessage, void *pUser); static void Kick(int ClientId, const char *pMessage, void *pUser);
static void Log(const char *pMessage, void *pUser); static void Log(const char *pMessage, void *pUser);
static void Report(int ClientID, const char *pMessage, void *pUser); static void Report(int ClientId, const char *pMessage, void *pUser);
static void Send(int ClientID, const void *pData, int Size, int Flags, void *pUser); static void Send(int ClientId, const void *pData, int Size, int Flags, void *pUser);
static void Teehistorian(const void *pData, int Size, void *pUser); static void Teehistorian(const void *pData, int Size, void *pUser);
public: public:
@ -33,25 +33,25 @@ public:
void Init() override; void Init() override;
void OnEngineTick() override; void OnEngineTick() override;
void OnEngineClientJoin(int ClientID, bool Sixup) override; void OnEngineClientJoin(int ClientId, bool Sixup) override;
void OnEngineClientDrop(int ClientID, const char *pReason) override; void OnEngineClientDrop(int ClientId, const char *pReason) override;
bool OnEngineClientMessage(int ClientID, const void *pData, int Size, int Flags) override; bool OnEngineClientMessage(int ClientId, const void *pData, int Size, int Flags) override;
bool OnEngineServerMessage(int ClientID, const void *pData, int Size, int Flags) override; bool OnEngineServerMessage(int ClientId, const void *pData, int Size, int Flags) override;
bool OnEngineSimulateClientMessage(int *pClientID, void *pBuffer, int BufferSize, int *pOutSize, int *pFlags) override; bool OnEngineSimulateClientMessage(int *pClientId, void *pBuffer, int BufferSize, int *pOutSize, int *pFlags) override;
// Game // Game
void RoundStart(class IGameServer *pGameServer) override; void RoundStart(class IGameServer *pGameServer) override;
void RoundEnd() override; void RoundEnd() override;
void OnPlayerInit(int ClientID) override; void OnPlayerInit(int ClientId) override;
void OnPlayerDestroy(int ClientID) override; void OnPlayerDestroy(int ClientId) override;
void OnSpawn(int ClientID) override; void OnSpawn(int ClientId) override;
void OnHammerFireReloading(int ClientID) override; void OnHammerFireReloading(int ClientId) override;
void OnHammerFire(int ClientID) override; void OnHammerFire(int ClientId) override;
void OnHammerHit(int ClientID, int TargetID) override; void OnHammerHit(int ClientId, int TargetId) override;
void OnDirectInput(int ClientID) override; void OnDirectInput(int ClientId) override;
void OnCharacterTick(int ClientID) override; void OnCharacterTick(int ClientId) override;
void OnHookAttach(int ClientID, bool Player) override; void OnHookAttach(int ClientId, bool Player) override;
void ConsoleCommand(const char *pCommand) override; void ConsoleCommand(const char *pCommand) override;
}; };

View file

@ -23,7 +23,7 @@ void IDbConnection::FormatCreateRace(char *aBuf, unsigned int BufferSize, bool B
" cp19 FLOAT DEFAULT 0, cp20 FLOAT DEFAULT 0, cp21 FLOAT DEFAULT 0, " " cp19 FLOAT DEFAULT 0, cp20 FLOAT DEFAULT 0, cp21 FLOAT DEFAULT 0, "
" cp22 FLOAT DEFAULT 0, cp23 FLOAT DEFAULT 0, cp24 FLOAT DEFAULT 0, " " cp22 FLOAT DEFAULT 0, cp23 FLOAT DEFAULT 0, cp24 FLOAT DEFAULT 0, "
" cp25 FLOAT DEFAULT 0, " " cp25 FLOAT DEFAULT 0, "
" GameID VARCHAR(64), " " GameId VARCHAR(64), "
" DDNet7 BOOL DEFAULT FALSE, " " DDNet7 BOOL DEFAULT FALSE, "
" PRIMARY KEY (Map, Name, Time, Timestamp, Server)" " PRIMARY KEY (Map, Name, Time, Timestamp, Server)"
")", ")",
@ -40,9 +40,9 @@ void IDbConnection::FormatCreateTeamrace(char *aBuf, unsigned int BufferSize, co
" Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, " " Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "
" Time FLOAT DEFAULT 0, " " Time FLOAT DEFAULT 0, "
" ID %s NOT NULL, " // VARBINARY(16) for MySQL and BLOB for SQLite " ID %s NOT NULL, " // VARBINARY(16) for MySQL and BLOB for SQLite
" GameID VARCHAR(64), " " GameId VARCHAR(64), "
" DDNet7 BOOL DEFAULT FALSE, " " DDNet7 BOOL DEFAULT FALSE, "
" PRIMARY KEY (ID, Name)" " PRIMARY KEY (Id, Name)"
")", ")",
GetPrefix(), Backup ? "_backup" : "", GetPrefix(), Backup ? "_backup" : "",
BinaryCollate(), MAX_NAME_LENGTH_SQL, BinaryCollate(), pIdType); BinaryCollate(), MAX_NAME_LENGTH_SQL, BinaryCollate(), pIdType);
@ -73,7 +73,7 @@ void IDbConnection::FormatCreateSaves(char *aBuf, unsigned int BufferSize, bool
" Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, " " Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "
" Server CHAR(4), " " Server CHAR(4), "
" DDNet7 BOOL DEFAULT FALSE, " " DDNet7 BOOL DEFAULT FALSE, "
" SaveID VARCHAR(36) DEFAULT NULL, " " SaveId VARCHAR(36) DEFAULT NULL, "
" PRIMARY KEY (Map, Code)" " PRIMARY KEY (Map, Code)"
")", ")",
GetPrefix(), Backup ? "_backup" : "", GetPrefix(), Backup ? "_backup" : "",

View file

@ -49,7 +49,7 @@ struct CSqlExecData
{ {
CDbConnectionPool::Mode m_Mode; CDbConnectionPool::Mode m_Mode;
CMysqlConfig m_Config; CMysqlConfig m_Config;
} m_MySql; } m_Mysql;
struct struct
{ {
CDbConnectionPool::Mode m_Mode; CDbConnectionPool::Mode m_Mode;
@ -104,8 +104,8 @@ CSqlExecData::CSqlExecData(CDbConnectionPool::Mode m,
m_pThreadData(nullptr), m_pThreadData(nullptr),
m_pName("add mysql server") m_pName("add mysql server")
{ {
m_Ptr.m_MySql.m_Mode = m; m_Ptr.m_Mysql.m_Mode = m;
mem_copy(&m_Ptr.m_MySql.m_Config, pMysqlConfig, sizeof(m_Ptr.m_MySql.m_Config)); mem_copy(&m_Ptr.m_Mysql.m_Config, pMysqlConfig, sizeof(m_Ptr.m_Mysql.m_Config));
} }
CSqlExecData::CSqlExecData(IConsole *pConsole, CDbConnectionPool::Mode m) : CSqlExecData::CSqlExecData(IConsole *pConsole, CDbConnectionPool::Mode m) :
@ -352,8 +352,8 @@ void CWorker::ProcessQueries()
break; break;
case CSqlExecData::ADD_MYSQL: case CSqlExecData::ADD_MYSQL:
{ {
auto pMysql = CreateMysqlConnection(pThreadData->m_Ptr.m_MySql.m_Config); auto pMysql = CreateMysqlConnection(pThreadData->m_Ptr.m_Mysql.m_Config);
switch(pThreadData->m_Ptr.m_MySql.m_Mode) switch(pThreadData->m_Ptr.m_Mysql.m_Mode)
{ {
case CDbConnectionPool::Mode::READ: case CDbConnectionPool::Mode::READ:
m_vpReadConnections.push_back(std::move(pMysql)); m_vpReadConnections.push_back(std::move(pMysql));

File diff suppressed because it is too large Load diff

View file

@ -177,7 +177,7 @@ public:
bool m_DDNetVersionSettled; bool m_DDNetVersionSettled;
int m_DDNetVersion; int m_DDNetVersion;
char m_aDDNetVersionStr[64]; char m_aDDNetVersionStr[64];
CUuid m_ConnectionID; CUuid m_ConnectionId;
int64_t m_RedirectDropTime; int64_t m_RedirectDropTime;
// DNSBL // DNSBL
@ -197,7 +197,7 @@ public:
CSnapshotDelta m_SnapshotDelta; CSnapshotDelta m_SnapshotDelta;
CSnapshotBuilder m_SnapshotBuilder; CSnapshotBuilder m_SnapshotBuilder;
CSnapIDPool m_IDPool; CSnapIdPool m_IdPool;
CNetServer m_NetServer; CNetServer m_NetServer;
CEcon m_Econ; CEcon m_Econ;
CFifo m_Fifo; CFifo m_Fifo;
@ -220,7 +220,7 @@ public:
bool m_MapReload; bool m_MapReload;
bool m_ReloadedWhenEmpty; bool m_ReloadedWhenEmpty;
int m_RconClientID; int m_RconClientId;
int m_RconAuthLevel; int m_RconAuthLevel;
int m_PrintCBIndex; int m_PrintCBIndex;
char m_aShutdownReason[128]; char m_aShutdownReason[128];
@ -266,21 +266,21 @@ public:
CServer(); CServer();
~CServer(); ~CServer();
bool IsClientNameAvailable(int ClientID, const char *pNameRequest); bool IsClientNameAvailable(int ClientId, const char *pNameRequest);
bool SetClientNameImpl(int ClientID, const char *pNameRequest, bool Set); bool SetClientNameImpl(int ClientId, const char *pNameRequest, bool Set);
bool SetClientClanImpl(int ClientID, const char *pClanRequest, bool Set); bool SetClientClanImpl(int ClientId, const char *pClanRequest, bool Set);
bool WouldClientNameChange(int ClientID, const char *pNameRequest) override; bool WouldClientNameChange(int ClientId, const char *pNameRequest) override;
bool WouldClientClanChange(int ClientID, const char *pClanRequest) override; bool WouldClientClanChange(int ClientId, const char *pClanRequest) override;
void SetClientName(int ClientID, const char *pName) override; void SetClientName(int ClientId, const char *pName) override;
void SetClientClan(int ClientID, const char *pClan) override; void SetClientClan(int ClientId, const char *pClan) override;
void SetClientCountry(int ClientID, int Country) override; void SetClientCountry(int ClientId, int Country) override;
void SetClientScore(int ClientID, std::optional<int> Score) override; void SetClientScore(int ClientId, std::optional<int> Score) override;
void SetClientFlags(int ClientID, int Flags) override; void SetClientFlags(int ClientId, int Flags) override;
void Kick(int ClientID, const char *pReason) override; void Kick(int ClientId, const char *pReason) override;
void Ban(int ClientID, int Seconds, const char *pReason) override; void Ban(int ClientId, int Seconds, const char *pReason) override;
void RedirectClient(int ClientID, int Port, bool Verbose = false) override; void RedirectClient(int ClientId, int Port, bool Verbose = false) override;
void DemoRecorder_HandleAutoStart() override; void DemoRecorder_HandleAutoStart() override;
@ -291,49 +291,49 @@ public:
int Init(); int Init();
void SendLogLine(const CLogMessage *pMessage); void SendLogLine(const CLogMessage *pMessage);
void SetRconCID(int ClientID) override; void SetRconCid(int ClientId) override;
int GetAuthedState(int ClientID) const override; int GetAuthedState(int ClientId) const override;
const char *GetAuthName(int ClientID) const override; const char *GetAuthName(int ClientId) const override;
void GetMapInfo(char *pMapName, int MapNameSize, int *pMapSize, SHA256_DIGEST *pMapSha256, int *pMapCrc) override; void GetMapInfo(char *pMapName, int MapNameSize, int *pMapSize, SHA256_DIGEST *pMapSha256, int *pMapCrc) override;
bool GetClientInfo(int ClientID, CClientInfo *pInfo) const override; bool GetClientInfo(int ClientId, CClientInfo *pInfo) const override;
void SetClientDDNetVersion(int ClientID, int DDNetVersion) override; void SetClientDDNetVersion(int ClientId, int DDNetVersion) override;
void GetClientAddr(int ClientID, char *pAddrStr, int Size) const override; void GetClientAddr(int ClientId, char *pAddrStr, int Size) const override;
const char *ClientName(int ClientID) const override; const char *ClientName(int ClientId) const override;
const char *ClientClan(int ClientID) const override; const char *ClientClan(int ClientId) const override;
int ClientCountry(int ClientID) const override; int ClientCountry(int ClientId) const override;
bool ClientSlotEmpty(int ClientID) const override; bool ClientSlotEmpty(int ClientId) const override;
bool ClientIngame(int ClientID) const override; bool ClientIngame(int ClientId) const override;
bool ClientAuthed(int ClientID) const override; bool ClientAuthed(int ClientId) const override;
int Port() const override; int Port() const override;
int MaxClients() const override; int MaxClients() const override;
int ClientCount() const override; int ClientCount() const override;
int DistinctClientCount() const override; int DistinctClientCount() const override;
int GetClientVersion(int ClientID) const override; int GetClientVersion(int ClientId) const override;
int SendMsg(CMsgPacker *pMsg, int Flags, int ClientID) override; int SendMsg(CMsgPacker *pMsg, int Flags, int ClientId) override;
void DoSnapshot(); void DoSnapshot();
static int NewClientCallback(int ClientID, void *pUser, bool Sixup); static int NewClientCallback(int ClientId, void *pUser, bool Sixup);
static int NewClientNoAuthCallback(int ClientID, void *pUser); static int NewClientNoAuthCallback(int ClientId, void *pUser);
static int DelClientCallback(int ClientID, const char *pReason, void *pUser); static int DelClientCallback(int ClientId, const char *pReason, void *pUser);
static int ClientRejoinCallback(int ClientID, void *pUser); static int ClientRejoinCallback(int ClientId, void *pUser);
void SendRconType(int ClientID, bool UsernameReq); void SendRconType(int ClientId, bool UsernameReq);
void SendCapabilities(int ClientID); void SendCapabilities(int ClientId);
void SendMap(int ClientID); void SendMap(int ClientId);
void SendMapData(int ClientID, int Chunk); void SendMapData(int ClientId, int Chunk);
void SendConnectionReady(int ClientID); void SendConnectionReady(int ClientId);
void SendRconLine(int ClientID, const char *pLine); void SendRconLine(int ClientId, const char *pLine);
// Accepts -1 as ClientID to mean "all clients with at least auth level admin" // Accepts -1 as ClientId to mean "all clients with at least auth level admin"
void SendRconLogLine(int ClientID, const CLogMessage *pMessage); void SendRconLogLine(int ClientId, const CLogMessage *pMessage);
void SendRconCmdAdd(const IConsole::CCommandInfo *pCommandInfo, int ClientID); void SendRconCmdAdd(const IConsole::CCommandInfo *pCommandInfo, int ClientId);
void SendRconCmdRem(const IConsole::CCommandInfo *pCommandInfo, int ClientID); void SendRconCmdRem(const IConsole::CCommandInfo *pCommandInfo, int ClientId);
void UpdateClientRconCommands(); void UpdateClientRconCommands();
bool CheckReservedSlotAuth(int ClientID, const char *pPassword); bool CheckReservedSlotAuth(int ClientId, const char *pPassword);
void ProcessClientPacket(CNetChunk *pPacket); void ProcessClientPacket(CNetChunk *pPacket);
class CCache class CCache
@ -379,10 +379,10 @@ public:
const char *GetMapName() const override; const char *GetMapName() const override;
int LoadMap(const char *pMapName); int LoadMap(const char *pMapName);
void SaveDemo(int ClientID, float Time) override; void SaveDemo(int ClientId, float Time) override;
void StartRecord(int ClientID) override; void StartRecord(int ClientId) override;
void StopRecord(int ClientID) override; void StopRecord(int ClientId) override;
bool IsRecording(int ClientID) override; bool IsRecording(int ClientId) override;
void StopDemos() override; void StopDemos() override;
int Run(); int Run();
@ -411,7 +411,7 @@ public:
static void ConchainMaxclientsperipUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainMaxclientsperipUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainCommandAccessUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainCommandAccessUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
void LogoutClient(int ClientID, const char *pReason); void LogoutClient(int ClientId, const char *pReason);
void LogoutKey(int Key, const char *pReason); void LogoutKey(int Key, const char *pReason);
void ConchainRconPasswordChangeGeneric(int Level, const char *pCurrent, IConsole::IResult *pResult); void ConchainRconPasswordChangeGeneric(int Level, const char *pCurrent, IConsole::IResult *pResult);
@ -429,47 +429,47 @@ public:
void RegisterCommands(); void RegisterCommands();
int SnapNewID() override; int SnapNewId() override;
void SnapFreeID(int ID) override; void SnapFreeId(int Id) override;
void *SnapNewItem(int Type, int ID, int Size) override; void *SnapNewItem(int Type, int Id, int Size) override;
void SnapSetStaticsize(int ItemType, int Size) override; void SnapSetStaticsize(int ItemType, int Size) override;
// DDRace // DDRace
void GetClientAddr(int ClientID, NETADDR *pAddr) const override; void GetClientAddr(int ClientId, NETADDR *pAddr) const override;
int m_aPrevStates[MAX_CLIENTS]; int m_aPrevStates[MAX_CLIENTS];
const char *GetAnnouncementLine(const char *pFileName) override; const char *GetAnnouncementLine(const char *pFileName) override;
int *GetIdMap(int ClientID) override; int *GetIdMap(int ClientId) override;
void InitDnsbl(int ClientID); void InitDnsbl(int ClientId);
bool DnsblWhite(int ClientID) override bool DnsblWhite(int ClientId) override
{ {
return m_aClients[ClientID].m_DnsblState == CClient::DNSBL_STATE_NONE || return m_aClients[ClientId].m_DnsblState == CClient::DNSBL_STATE_NONE ||
m_aClients[ClientID].m_DnsblState == CClient::DNSBL_STATE_WHITELISTED; m_aClients[ClientId].m_DnsblState == CClient::DNSBL_STATE_WHITELISTED;
} }
bool DnsblPending(int ClientID) override bool DnsblPending(int ClientId) override
{ {
return m_aClients[ClientID].m_DnsblState == CClient::DNSBL_STATE_PENDING; return m_aClients[ClientId].m_DnsblState == CClient::DNSBL_STATE_PENDING;
} }
bool DnsblBlack(int ClientID) override bool DnsblBlack(int ClientId) override
{ {
return m_aClients[ClientID].m_DnsblState == CClient::DNSBL_STATE_BLACKLISTED; return m_aClients[ClientId].m_DnsblState == CClient::DNSBL_STATE_BLACKLISTED;
} }
void AuthRemoveKey(int KeySlot); void AuthRemoveKey(int KeySlot);
bool ClientPrevIngame(int ClientID) override { return m_aPrevStates[ClientID] == CClient::STATE_INGAME; } bool ClientPrevIngame(int ClientId) override { return m_aPrevStates[ClientId] == CClient::STATE_INGAME; }
const char *GetNetErrorString(int ClientID) override { return m_NetServer.ErrorString(ClientID); } const char *GetNetErrorString(int ClientId) override { return m_NetServer.ErrorString(ClientId); }
void ResetNetErrorString(int ClientID) override { m_NetServer.ResetErrorString(ClientID); } void ResetNetErrorString(int ClientId) override { m_NetServer.ResetErrorString(ClientId); }
bool SetTimedOut(int ClientID, int OrigID) override; bool SetTimedOut(int ClientId, int OrigId) override;
void SetTimeoutProtected(int ClientID) override { m_NetServer.SetTimeoutProtected(ClientID); } void SetTimeoutProtected(int ClientId) override { m_NetServer.SetTimeoutProtected(ClientId); }
void SendMsgRaw(int ClientID, const void *pData, int Size, int Flags) override; void SendMsgRaw(int ClientId, const void *pData, int Size, int Flags) override;
bool ErrorShutdown() const { return m_aErrorShutdownReason[0] != 0; } bool ErrorShutdown() const { return m_aErrorShutdownReason[0] != 0; }
void SetErrorShutdown(const char *pReason) override; void SetErrorShutdown(const char *pReason) override;
bool IsSixup(int ClientID) const override { return ClientID != SERVER_DEMO_CLIENT && m_aClients[ClientID].m_Sixup; } bool IsSixup(int ClientId) const override { return ClientId != SERVER_DEMO_CLIENT && m_aClients[ClientId].m_Sixup; }
void SetLoggers(std::shared_ptr<ILogger> &&pFileLogger, std::shared_ptr<ILogger> &&pStdoutLogger); void SetLoggers(std::shared_ptr<ILogger> &&pFileLogger, std::shared_ptr<ILogger> &&pStdoutLogger);

View file

@ -5,20 +5,20 @@
#include <base/system.h> #include <base/system.h>
CSnapIDPool::CSnapIDPool() CSnapIdPool::CSnapIdPool()
{ {
Reset(); Reset();
} }
void CSnapIDPool::Reset() void CSnapIdPool::Reset()
{ {
for(int i = 0; i < MAX_IDS; i++) for(int i = 0; i < MAX_IDS; i++)
{ {
m_aIDs[i].m_Next = i + 1; m_aIds[i].m_Next = i + 1;
m_aIDs[i].m_State = ID_FREE; m_aIds[i].m_State = ID_FREE;
} }
m_aIDs[MAX_IDS - 1].m_Next = -1; m_aIds[MAX_IDS - 1].m_Next = -1;
m_FirstFree = 0; m_FirstFree = 0;
m_FirstTimed = -1; m_FirstTimed = -1;
m_LastTimed = -1; m_LastTimed = -1;
@ -26,13 +26,13 @@ void CSnapIDPool::Reset()
m_InUsage = 0; m_InUsage = 0;
} }
void CSnapIDPool::RemoveFirstTimeout() void CSnapIdPool::RemoveFirstTimeout()
{ {
int NextTimed = m_aIDs[m_FirstTimed].m_Next; int NextTimed = m_aIds[m_FirstTimed].m_Next;
// add it to the free list // add it to the free list
m_aIDs[m_FirstTimed].m_Next = m_FirstFree; m_aIds[m_FirstTimed].m_Next = m_FirstFree;
m_aIDs[m_FirstTimed].m_State = ID_FREE; m_aIds[m_FirstTimed].m_State = ID_FREE;
m_FirstFree = m_FirstTimed; m_FirstFree = m_FirstTimed;
// remove it from the timed list // remove it from the timed list
@ -43,54 +43,54 @@ void CSnapIDPool::RemoveFirstTimeout()
m_Usage--; m_Usage--;
} }
int CSnapIDPool::NewID() int CSnapIdPool::NewId()
{ {
int64_t Now = time_get(); int64_t Now = time_get();
// process timed ids // process timed ids
while(m_FirstTimed != -1 && m_aIDs[m_FirstTimed].m_Timeout < Now) while(m_FirstTimed != -1 && m_aIds[m_FirstTimed].m_Timeout < Now)
RemoveFirstTimeout(); RemoveFirstTimeout();
int ID = m_FirstFree; int Id = m_FirstFree;
if(ID == -1) if(Id == -1)
{ {
dbg_msg("server", "invalid id"); dbg_msg("server", "invalid id");
return ID; return Id;
} }
m_FirstFree = m_aIDs[m_FirstFree].m_Next; m_FirstFree = m_aIds[m_FirstFree].m_Next;
m_aIDs[ID].m_State = ID_ALLOCATED; m_aIds[Id].m_State = ID_ALLOCATED;
m_Usage++; m_Usage++;
m_InUsage++; m_InUsage++;
return ID; return Id;
} }
void CSnapIDPool::TimeoutIDs() void CSnapIdPool::TimeoutIds()
{ {
// process timed ids // process timed ids
while(m_FirstTimed != -1) while(m_FirstTimed != -1)
RemoveFirstTimeout(); RemoveFirstTimeout();
} }
void CSnapIDPool::FreeID(int ID) void CSnapIdPool::FreeId(int Id)
{ {
if(ID < 0) if(Id < 0)
return; return;
dbg_assert((size_t)ID < std::size(m_aIDs), "id is out of range"); dbg_assert((size_t)Id < std::size(m_aIds), "id is out of range");
dbg_assert(m_aIDs[ID].m_State == ID_ALLOCATED, "id is not allocated"); dbg_assert(m_aIds[Id].m_State == ID_ALLOCATED, "id is not allocated");
m_InUsage--; m_InUsage--;
m_aIDs[ID].m_State = ID_TIMED; m_aIds[Id].m_State = ID_TIMED;
m_aIDs[ID].m_Timeout = time_get() + time_freq() * 5; m_aIds[Id].m_Timeout = time_get() + time_freq() * 5;
m_aIDs[ID].m_Next = -1; m_aIds[Id].m_Next = -1;
if(m_LastTimed != -1) if(m_LastTimed != -1)
{ {
m_aIDs[m_LastTimed].m_Next = ID; m_aIds[m_LastTimed].m_Next = Id;
m_LastTimed = ID; m_LastTimed = Id;
} }
else else
{ {
m_FirstTimed = ID; m_FirstTimed = Id;
m_LastTimed = ID; m_LastTimed = Id;
} }
} }

View file

@ -4,7 +4,7 @@
#ifndef ENGINE_SERVER_SNAP_ID_POOL_H #ifndef ENGINE_SERVER_SNAP_ID_POOL_H
#define ENGINE_SERVER_SNAP_ID_POOL_H #define ENGINE_SERVER_SNAP_ID_POOL_H
class CSnapIDPool class CSnapIdPool
{ {
enum enum
{ {
@ -27,7 +27,7 @@ class CSnapIDPool
int m_Timeout; int m_Timeout;
}; };
CID m_aIDs[MAX_IDS]; CID m_aIds[MAX_IDS];
int m_FirstFree; int m_FirstFree;
int m_FirstTimed; int m_FirstTimed;
@ -36,13 +36,13 @@ class CSnapIDPool
int m_InUsage; int m_InUsage;
public: public:
CSnapIDPool(); CSnapIdPool();
void Reset(); void Reset();
void RemoveFirstTimeout(); void RemoveFirstTimeout();
int NewID(); int NewId();
void TimeoutIDs(); void TimeoutIds();
void FreeID(int ID); void FreeId(int Id);
}; };
#endif #endif

View file

@ -56,7 +56,7 @@ void SIntConfigVariable::CommandCallback(IConsole::IResult *pResult, void *pUser
} }
*pData->m_pVariable = Value; *pData->m_pVariable = Value;
if(pResult->m_ClientID != IConsole::CLIENT_ID_GAME) if(pResult->m_ClientId != IConsole::CLIENT_ID_GAME)
pData->m_OldValue = Value; pData->m_OldValue = Value;
} }
else else
@ -121,7 +121,7 @@ void SColorConfigVariable::CommandCallback(IConsole::IResult *pResult, void *pUs
const unsigned Value = Color.Pack(pData->m_Light ? 0.5f : 0.0f, pData->m_Alpha); const unsigned Value = Color.Pack(pData->m_Light ? 0.5f : 0.0f, pData->m_Alpha);
*pData->m_pVariable = Value; *pData->m_pVariable = Value;
if(pResult->m_ClientID != IConsole::CLIENT_ID_GAME) if(pResult->m_ClientId != IConsole::CLIENT_ID_GAME)
pData->m_OldValue = Value; pData->m_OldValue = Value;
} }
else else
@ -230,7 +230,7 @@ void SStringConfigVariable::CommandCallback(IConsole::IResult *pResult, void *pU
else else
str_copy(pData->m_pStr, pString, pData->m_MaxSize); str_copy(pData->m_pStr, pString, pData->m_MaxSize);
if(pResult->m_ClientID != IConsole::CLIENT_ID_GAME) if(pResult->m_ClientId != IConsole::CLIENT_ID_GAME)
str_copy(pData->m_pOldValue, pData->m_pStr, pData->m_MaxSize); str_copy(pData->m_pOldValue, pData->m_pStr, pData->m_MaxSize);
} }
else else

View file

@ -30,7 +30,7 @@ MACRO_CONFIG_INT(ClNameplatesTeamcolors, cl_nameplates_teamcolors, 1, 0, 1, CFGF
MACRO_CONFIG_INT(ClNameplatesSize, cl_nameplates_size, 50, 0, 100, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Size of the name plates from 0 to 100%") MACRO_CONFIG_INT(ClNameplatesSize, cl_nameplates_size, 50, 0, 100, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Size of the name plates from 0 to 100%")
MACRO_CONFIG_INT(ClNameplatesClan, cl_nameplates_clan, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show clan in name plates") MACRO_CONFIG_INT(ClNameplatesClan, cl_nameplates_clan, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show clan in name plates")
MACRO_CONFIG_INT(ClNameplatesClanSize, cl_nameplates_clan_size, 30, 0, 100, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Size of the clan plates from 0 to 100%") MACRO_CONFIG_INT(ClNameplatesClanSize, cl_nameplates_clan_size, 30, 0, 100, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Size of the clan plates from 0 to 100%")
MACRO_CONFIG_INT(ClNameplatesIDs, cl_nameplates_ids, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show IDs in name plates") MACRO_CONFIG_INT(ClNameplatesIds, cl_nameplates_ids, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show IDs in name plates")
MACRO_CONFIG_INT(ClNameplatesOwn, cl_nameplates_own, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show own name plate (useful for demo recording)") MACRO_CONFIG_INT(ClNameplatesOwn, cl_nameplates_own, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show own name plate (useful for demo recording)")
MACRO_CONFIG_INT(ClNameplatesFriendMark, cl_nameplates_friendmark, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show friend mark (♥) in name plates") MACRO_CONFIG_INT(ClNameplatesFriendMark, cl_nameplates_friendmark, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show friend mark (♥) in name plates")
MACRO_CONFIG_INT(ClNameplatesStrong, cl_nameplates_strong, 0, 0, 2, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show strong/weak in name plates (0 - off, 1 - icons, 2 - icons + numbers)") MACRO_CONFIG_INT(ClNameplatesStrong, cl_nameplates_strong, 0, 0, 2, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show strong/weak in name plates (0 - off, 1 - icons, 2 - icons + numbers)")
@ -373,7 +373,7 @@ MACRO_CONFIG_INT(SvPort, sv_port, 0, 0, 65535, CFGFLAG_SERVER, "Port to use for
MACRO_CONFIG_STR(SvHostname, sv_hostname, 128, "", CFGFLAG_SERVER, "Server hostname (0.7 only)") MACRO_CONFIG_STR(SvHostname, sv_hostname, 128, "", CFGFLAG_SERVER, "Server hostname (0.7 only)")
MACRO_CONFIG_STR(SvMap, sv_map, 128, "Sunny Side Up", CFGFLAG_SERVER, "Map to use on the server") MACRO_CONFIG_STR(SvMap, sv_map, 128, "Sunny Side Up", CFGFLAG_SERVER, "Map to use on the server")
MACRO_CONFIG_INT(SvMaxClients, sv_max_clients, MAX_CLIENTS, 1, MAX_CLIENTS, CFGFLAG_SERVER, "Maximum number of clients that are allowed on a server") MACRO_CONFIG_INT(SvMaxClients, sv_max_clients, MAX_CLIENTS, 1, MAX_CLIENTS, CFGFLAG_SERVER, "Maximum number of clients that are allowed on a server")
MACRO_CONFIG_INT(SvMaxClientsPerIP, sv_max_clients_per_ip, 4, 1, MAX_CLIENTS, CFGFLAG_SERVER, "Maximum number of clients with the same IP that can connect to the server") MACRO_CONFIG_INT(SvMaxClientsPerIp, sv_max_clients_per_ip, 4, 1, MAX_CLIENTS, CFGFLAG_SERVER, "Maximum number of clients with the same IP that can connect to the server")
MACRO_CONFIG_INT(SvHighBandwidth, sv_high_bandwidth, 0, 0, 1, CFGFLAG_SERVER, "Use high bandwidth mode. Doubles the bandwidth required for the server. LAN use only") MACRO_CONFIG_INT(SvHighBandwidth, sv_high_bandwidth, 0, 0, 1, CFGFLAG_SERVER, "Use high bandwidth mode. Doubles the bandwidth required for the server. LAN use only")
MACRO_CONFIG_STR(SvRegister, sv_register, 16, "1", CFGFLAG_SERVER, "Register server with master server for public listing, can also accept a comma-separated list of protocols to register on, like 'ipv4,ipv6'") MACRO_CONFIG_STR(SvRegister, sv_register, 16, "1", CFGFLAG_SERVER, "Register server with master server for public listing, can also accept a comma-separated list of protocols to register on, like 'ipv4,ipv6'")
MACRO_CONFIG_STR(SvRegisterExtra, sv_register_extra, 256, "", CFGFLAG_SERVER, "Extra headers to send to the register endpoint, comma separated 'Header: Value' pairs") MACRO_CONFIG_STR(SvRegisterExtra, sv_register_extra, 256, "", CFGFLAG_SERVER, "Extra headers to send to the register endpoint, comma separated 'Header: Value' pairs")
@ -471,7 +471,7 @@ MACRO_CONFIG_INT(SvSaveSwapGamesDelay, sv_saveswapgames_delay, 30, 0, 10000, CFG
MACRO_CONFIG_INT(SvSaveSwapGamesPenalty, sv_saveswapgames_penalty, 60, 0, 10000, CFGFLAG_SERVER, "Penalty in seconds for saving or swapping position") MACRO_CONFIG_INT(SvSaveSwapGamesPenalty, sv_saveswapgames_penalty, 60, 0, 10000, CFGFLAG_SERVER, "Penalty in seconds for saving or swapping position")
MACRO_CONFIG_INT(SvSwapTimeout, sv_swap_timeout, 180, 0, 10000, CFGFLAG_SERVER, "Timeout in seconds before option to swap expires") MACRO_CONFIG_INT(SvSwapTimeout, sv_swap_timeout, 180, 0, 10000, CFGFLAG_SERVER, "Timeout in seconds before option to swap expires")
MACRO_CONFIG_INT(SvSwap, sv_swap, 1, 0, 1, CFGFLAG_SERVER, "Enable /swap") MACRO_CONFIG_INT(SvSwap, sv_swap, 1, 0, 1, CFGFLAG_SERVER, "Enable /swap")
MACRO_CONFIG_INT(SvUseSQL, sv_use_sql, 0, 0, 1, CFGFLAG_SERVER, "Enables MySQL backend instead of SQLite backend (sv_sqlite_file is still used as fallback write server when no MySQL server is reachable)") MACRO_CONFIG_INT(SvUseSql, sv_use_sql, 0, 0, 1, CFGFLAG_SERVER, "Enables MySQL backend instead of SQLite backend (sv_sqlite_file is still used as fallback write server when no MySQL server is reachable)")
MACRO_CONFIG_INT(SvSqlQueriesDelay, sv_sql_queries_delay, 1, 0, 20, CFGFLAG_SERVER, "Delay in seconds between SQL queries of a single player") MACRO_CONFIG_INT(SvSqlQueriesDelay, sv_sql_queries_delay, 1, 0, 20, CFGFLAG_SERVER, "Delay in seconds between SQL queries of a single player")
MACRO_CONFIG_STR(SvSqliteFile, sv_sqlite_file, 64, "ddnet-server.sqlite", CFGFLAG_SERVER, "File to store ranks in case sv_use_sql is turned off or used as backup sql server") MACRO_CONFIG_STR(SvSqliteFile, sv_sqlite_file, 64, "ddnet-server.sqlite", CFGFLAG_SERVER, "File to store ranks in case sv_use_sql is turned off or used as backup sql server")
@ -530,7 +530,7 @@ MACRO_CONFIG_COL(ClMessageFriendColor, cl_message_friend_color, 65425, CFGFLAG_C
MACRO_CONFIG_INT(ConnTimeout, conn_timeout, 100, 5, 1000, CFGFLAG_SAVE | CFGFLAG_CLIENT | CFGFLAG_SERVER, "Network timeout") MACRO_CONFIG_INT(ConnTimeout, conn_timeout, 100, 5, 1000, CFGFLAG_SAVE | CFGFLAG_CLIENT | CFGFLAG_SERVER, "Network timeout")
MACRO_CONFIG_INT(ConnTimeoutProtection, conn_timeout_protection, 1000, 5, 10000, CFGFLAG_SERVER, "Network timeout protection") MACRO_CONFIG_INT(ConnTimeoutProtection, conn_timeout_protection, 1000, 5, 10000, CFGFLAG_SERVER, "Network timeout protection")
MACRO_CONFIG_INT(ClShowIDs, cl_show_ids, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Whether to show client ids in scoreboard") MACRO_CONFIG_INT(ClShowIds, cl_show_ids, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Whether to show client ids in scoreboard")
MACRO_CONFIG_INT(ClScoreboardOnDeath, cl_scoreboard_on_death, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Whether to show scoreboard after death or not") MACRO_CONFIG_INT(ClScoreboardOnDeath, cl_scoreboard_on_death, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Whether to show scoreboard after death or not")
MACRO_CONFIG_INT(ClAutoRaceRecord, cl_auto_race_record, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Save the best demo of each race") MACRO_CONFIG_INT(ClAutoRaceRecord, cl_auto_race_record, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Save the best demo of each race")
MACRO_CONFIG_INT(ClReplays, cl_replays, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Enable/disable replays") MACRO_CONFIG_INT(ClReplays, cl_replays, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Enable/disable replays")
@ -664,7 +664,7 @@ MACRO_CONFIG_INT(Gfx3DTextureAnalysisRan, gfx_3d_texture_analysis_ran, 0, 0, 1,
MACRO_CONFIG_STR(Gfx3DTextureAnalysisRenderer, gfx_3d_texture_analysis_renderer, 128, "", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The renderer on which the analysis was performed") MACRO_CONFIG_STR(Gfx3DTextureAnalysisRenderer, gfx_3d_texture_analysis_renderer, 128, "", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The renderer on which the analysis was performed")
MACRO_CONFIG_STR(Gfx3DTextureAnalysisVersion, gfx_3d_texture_analysis_version, 128, "", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The version on which the analysis was performed") MACRO_CONFIG_STR(Gfx3DTextureAnalysisVersion, gfx_3d_texture_analysis_version, 128, "", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The version on which the analysis was performed")
MACRO_CONFIG_STR(GfxGPUName, gfx_gpu_name, 256, "auto", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The GPU's name, which will be selected by the backend. (if supported by the backend)") MACRO_CONFIG_STR(GfxGpuName, gfx_gpu_name, 256, "auto", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The GPU's name, which will be selected by the backend. (if supported by the backend)")
#if !defined(CONF_ARCH_IA32) && !defined(CONF_PLATFORM_MACOS) #if !defined(CONF_ARCH_IA32) && !defined(CONF_PLATFORM_MACOS)
MACRO_CONFIG_STR(GfxBackend, gfx_backend, 256, "Vulkan", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The backend to use (e.g. OpenGL or Vulkan)") MACRO_CONFIG_STR(GfxBackend, gfx_backend, 256, "Vulkan", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The backend to use (e.g. OpenGL or Vulkan)")
#else #else

View file

@ -402,7 +402,7 @@ bool CConsole::LineIsValid(const char *pStr)
return true; return true;
} }
void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, int ClientID, bool InterpretSemicolons) void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, int ClientId, bool InterpretSemicolons)
{ {
const char *pWithoutPrefix = str_startswith(pStr, "mc;"); const char *pWithoutPrefix = str_startswith(pStr, "mc;");
if(pWithoutPrefix) if(pWithoutPrefix)
@ -413,7 +413,7 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, int ClientID, bo
while(pStr && *pStr) while(pStr && *pStr)
{ {
CResult Result; CResult Result;
Result.m_ClientID = ClientID; Result.m_ClientId = ClientId;
const char *pEnd = pStr; const char *pEnd = pStr;
const char *pNextPart = 0; const char *pNextPart = 0;
int InString = 0; int InString = 0;
@ -448,14 +448,14 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, int ClientID, bo
return; return;
CCommand *pCommand; CCommand *pCommand;
if(ClientID == IConsole::CLIENT_ID_GAME) if(ClientId == IConsole::CLIENT_ID_GAME)
pCommand = FindCommand(Result.m_pCommand, m_FlagMask | CFGFLAG_GAME); pCommand = FindCommand(Result.m_pCommand, m_FlagMask | CFGFLAG_GAME);
else else
pCommand = FindCommand(Result.m_pCommand, m_FlagMask); pCommand = FindCommand(Result.m_pCommand, m_FlagMask);
if(pCommand) if(pCommand)
{ {
if(ClientID == IConsole::CLIENT_ID_GAME && !(pCommand->m_Flags & CFGFLAG_GAME)) if(ClientId == IConsole::CLIENT_ID_GAME && !(pCommand->m_Flags & CFGFLAG_GAME))
{ {
if(Stroke) if(Stroke)
{ {
@ -464,7 +464,7 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, int ClientID, bo
Print(OUTPUT_LEVEL_STANDARD, "console", aBuf); Print(OUTPUT_LEVEL_STANDARD, "console", aBuf);
} }
} }
else if(ClientID == IConsole::CLIENT_ID_NO_GAME && pCommand->m_Flags & CFGFLAG_GAME) else if(ClientId == IConsole::CLIENT_ID_NO_GAME && pCommand->m_Flags & CFGFLAG_GAME)
{ {
if(Stroke) if(Stroke)
{ {
@ -509,11 +509,11 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr, int ClientID, bo
if(m_pfnTeeHistorianCommandCallback && !(pCommand->m_Flags & CFGFLAG_NONTEEHISTORIC)) if(m_pfnTeeHistorianCommandCallback && !(pCommand->m_Flags & CFGFLAG_NONTEEHISTORIC))
{ {
m_pfnTeeHistorianCommandCallback(ClientID, m_FlagMask, pCommand->m_pName, &Result, m_pTeeHistorianCommandUserdata); m_pfnTeeHistorianCommandCallback(ClientId, m_FlagMask, pCommand->m_pName, &Result, m_pTeeHistorianCommandUserdata);
} }
if(Result.GetVictim() == CResult::VICTIM_ME) if(Result.GetVictim() == CResult::VICTIM_ME)
Result.SetVictim(ClientID); Result.SetVictim(ClientId);
if(Result.HasVictim() && Result.GetVictim() == CResult::VICTIM_ALL) if(Result.HasVictim() && Result.GetVictim() == CResult::VICTIM_ALL)
{ {
@ -590,21 +590,21 @@ CConsole::CCommand *CConsole::FindCommand(const char *pName, int FlagMask)
return 0x0; return 0x0;
} }
void CConsole::ExecuteLine(const char *pStr, int ClientID, bool InterpretSemicolons) void CConsole::ExecuteLine(const char *pStr, int ClientId, bool InterpretSemicolons)
{ {
CConsole::ExecuteLineStroked(1, pStr, ClientID, InterpretSemicolons); // press it CConsole::ExecuteLineStroked(1, pStr, ClientId, InterpretSemicolons); // press it
CConsole::ExecuteLineStroked(0, pStr, ClientID, InterpretSemicolons); // then release it CConsole::ExecuteLineStroked(0, pStr, ClientId, InterpretSemicolons); // then release it
} }
void CConsole::ExecuteLineFlag(const char *pStr, int FlagMask, int ClientID, bool InterpretSemicolons) void CConsole::ExecuteLineFlag(const char *pStr, int FlagMask, int ClientId, bool InterpretSemicolons)
{ {
int Temp = m_FlagMask; int Temp = m_FlagMask;
m_FlagMask = FlagMask; m_FlagMask = FlagMask;
ExecuteLine(pStr, ClientID, InterpretSemicolons); ExecuteLine(pStr, ClientId, InterpretSemicolons);
m_FlagMask = Temp; m_FlagMask = Temp;
} }
bool CConsole::ExecuteFile(const char *pFilename, int ClientID, bool LogFailure, int StorageType) bool CConsole::ExecuteFile(const char *pFilename, int ClientId, bool LogFailure, int StorageType)
{ {
// make sure that this isn't being executed already // make sure that this isn't being executed already
for(CExecFile *pCur = m_pFirstExec; pCur; pCur = pCur->m_pPrev) for(CExecFile *pCur = m_pFirstExec; pCur; pCur = pCur->m_pPrev)
@ -636,7 +636,7 @@ bool CConsole::ExecuteFile(const char *pFilename, int ClientID, bool LogFailure,
char *pLine; char *pLine;
while((pLine = Reader.Get())) while((pLine = Reader.Get()))
ExecuteLine(pLine, ClientID); ExecuteLine(pLine, ClientId);
io_close(File); io_close(File);
Success = true; Success = true;

View file

@ -61,7 +61,7 @@ class CConsole : public IConsole
static void ConCommandAccess(IResult *pResult, void *pUser); static void ConCommandAccess(IResult *pResult, void *pUser);
static void ConCommandStatus(IConsole::IResult *pResult, void *pUser); static void ConCommandStatus(IConsole::IResult *pResult, void *pUser);
void ExecuteLineStroked(int Stroke, const char *pStr, int ClientID = -1, bool InterpretSemicolons = true) override; void ExecuteLineStroked(int Stroke, const char *pStr, int ClientId = -1, bool InterpretSemicolons = true) override;
FTeeHistorianCommandCallback m_pfnTeeHistorianCommandCallback; FTeeHistorianCommandCallback m_pfnTeeHistorianCommandCallback;
void *m_pTeeHistorianCommandUserdata; void *m_pTeeHistorianCommandUserdata;
@ -207,9 +207,9 @@ public:
void StoreCommands(bool Store) override; void StoreCommands(bool Store) override;
bool LineIsValid(const char *pStr) override; bool LineIsValid(const char *pStr) override;
void ExecuteLine(const char *pStr, int ClientID = -1, bool InterpretSemicolons = true) override; void ExecuteLine(const char *pStr, int ClientId = -1, bool InterpretSemicolons = true) override;
void ExecuteLineFlag(const char *pStr, int FlagMask, int ClientID = -1, bool InterpretSemicolons = true) override; void ExecuteLineFlag(const char *pStr, int FlagMask, int ClientId = -1, bool InterpretSemicolons = true) override;
bool ExecuteFile(const char *pFilename, int ClientID = -1, bool LogFailure = false, int StorageType = IStorage::TYPE_ALL) override; bool ExecuteFile(const char *pFilename, int ClientId = -1, bool LogFailure = false, int StorageType = IStorage::TYPE_ALL) override;
char *Format(char *pBuf, int Size, const char *pFrom, const char *pStr) override; char *Format(char *pBuf, int Size, const char *pFrom, const char *pStr) override;
void Print(int Level, const char *pFrom, const char *pStr, ColorRGBA PrintColor = gs_ConsoleDefaultColor) const override; void Print(int Level, const char *pFrom, const char *pStr, ColorRGBA PrintColor = gs_ConsoleDefaultColor) const override;

View file

@ -53,13 +53,13 @@ struct CDatafileItemType
struct CDatafileItem struct CDatafileItem
{ {
int m_TypeAndID; int m_TypeAndId;
int m_Size; int m_Size;
}; };
struct CDatafileHeader struct CDatafileHeader
{ {
char m_aID[4]; char m_aId[4];
int m_Version; int m_Version;
int m_Size; int m_Size;
int m_Swaplen; int m_Swaplen;
@ -72,7 +72,7 @@ struct CDatafileHeader
constexpr size_t SizeOffset() constexpr size_t SizeOffset()
{ {
// The size of these members is not included in m_Size and m_Swaplen // The size of these members is not included in m_Size and m_Swaplen
return sizeof(m_aID) + sizeof(m_Version) + sizeof(m_Size) + sizeof(m_Swaplen); return sizeof(m_aId) + sizeof(m_Version) + sizeof(m_Size) + sizeof(m_Swaplen);
} }
}; };
@ -144,11 +144,11 @@ bool CDataFileReader::Open(class IStorage *pStorage, const char *pFilename, int
dbg_msg("datafile", "couldn't load header"); dbg_msg("datafile", "couldn't load header");
return false; return false;
} }
if(Header.m_aID[0] != 'A' || Header.m_aID[1] != 'T' || Header.m_aID[2] != 'A' || Header.m_aID[3] != 'D') if(Header.m_aId[0] != 'A' || Header.m_aId[1] != 'T' || Header.m_aId[2] != 'A' || Header.m_aId[3] != 'D')
{ {
if(Header.m_aID[0] != 'D' || Header.m_aID[1] != 'A' || Header.m_aID[2] != 'T' || Header.m_aID[3] != 'A') if(Header.m_aId[0] != 'D' || Header.m_aId[1] != 'A' || Header.m_aId[2] != 'T' || Header.m_aId[3] != 'A')
{ {
dbg_msg("datafile", "wrong signature. %x %x %x %x", Header.m_aID[0], Header.m_aID[1], Header.m_aID[2], Header.m_aID[3]); dbg_msg("datafile", "wrong signature. %x %x %x %x", Header.m_aId[0], Header.m_aId[1], Header.m_aId[2], Header.m_aId[3]);
return false; return false;
} }
} }
@ -490,23 +490,23 @@ int CDataFileReader::GetInternalItemType(int ExternalType)
{ {
continue; continue;
} }
int ID; int Id;
if(Uuid == ((const CItemEx *)GetItem(i, nullptr, &ID))->ToUuid()) if(Uuid == ((const CItemEx *)GetItem(i, nullptr, &Id))->ToUuid())
{ {
return ID; return Id;
} }
} }
return -1; return -1;
} }
void *CDataFileReader::GetItem(int Index, int *pType, int *pID, CUuid *pUuid) void *CDataFileReader::GetItem(int Index, int *pType, int *pId, CUuid *pUuid)
{ {
if(!m_pDataFile) if(!m_pDataFile)
{ {
if(pType) if(pType)
*pType = 0; *pType = 0;
if(pID) if(pId)
*pID = 0; *pId = 0;
if(pUuid) if(pUuid)
*pUuid = UUID_ZEROED; *pUuid = UUID_ZEROED;
return nullptr; return nullptr;
@ -515,14 +515,14 @@ void *CDataFileReader::GetItem(int Index, int *pType, int *pID, CUuid *pUuid)
CDatafileItem *pItem = (CDatafileItem *)(m_pDataFile->m_Info.m_pItemStart + m_pDataFile->m_Info.m_pItemOffsets[Index]); CDatafileItem *pItem = (CDatafileItem *)(m_pDataFile->m_Info.m_pItemStart + m_pDataFile->m_Info.m_pItemOffsets[Index]);
// remove sign extension // remove sign extension
const int Type = GetExternalItemType((pItem->m_TypeAndID >> 16) & 0xffff, pUuid); const int Type = GetExternalItemType((pItem->m_TypeAndId >> 16) & 0xffff, pUuid);
if(pType) if(pType)
{ {
*pType = Type; *pType = Type;
} }
if(pID) if(pId)
{ {
*pID = pItem->m_TypeAndID & 0xffff; *pId = pItem->m_TypeAndId & 0xffff;
} }
return (void *)(pItem + 1); return (void *)(pItem + 1);
} }
@ -547,7 +547,7 @@ void CDataFileReader::GetType(int Type, int *pStart, int *pNum)
} }
} }
int CDataFileReader::FindItemIndex(int Type, int ID) int CDataFileReader::FindItemIndex(int Type, int Id)
{ {
if(!m_pDataFile) if(!m_pDataFile)
{ {
@ -558,9 +558,9 @@ int CDataFileReader::FindItemIndex(int Type, int ID)
GetType(Type, &Start, &Num); GetType(Type, &Start, &Num);
for(int i = 0; i < Num; i++) for(int i = 0; i < Num; i++)
{ {
int ItemID; int ItemId;
GetItem(Start + i, nullptr, &ItemID); GetItem(Start + i, nullptr, &ItemId);
if(ID == ItemID) if(Id == ItemId)
{ {
return Start + i; return Start + i;
} }
@ -568,9 +568,9 @@ int CDataFileReader::FindItemIndex(int Type, int ID)
return -1; return -1;
} }
void *CDataFileReader::FindItem(int Type, int ID) void *CDataFileReader::FindItem(int Type, int Id)
{ {
int Index = FindItemIndex(Type, ID); int Index = FindItemIndex(Type, Id);
if(Index < 0) if(Index < 0)
{ {
return nullptr; return nullptr;
@ -690,10 +690,10 @@ int CDataFileWriter::GetExtendedItemTypeIndex(int Type, const CUuid *pUuid)
return Index; return Index;
} }
int CDataFileWriter::AddItem(int Type, int ID, size_t Size, const void *pData, const CUuid *pUuid) int CDataFileWriter::AddItem(int Type, int Id, size_t Size, const void *pData, const CUuid *pUuid)
{ {
dbg_assert((Type >= 0 && Type < MAX_ITEM_TYPES) || Type >= OFFSET_UUID || (Type == -1 && pUuid != nullptr), "Invalid type"); dbg_assert((Type >= 0 && Type < MAX_ITEM_TYPES) || Type >= OFFSET_UUID || (Type == -1 && pUuid != nullptr), "Invalid type");
dbg_assert(ID >= 0 && ID <= ITEMTYPE_EX, "Invalid ID"); dbg_assert(Id >= 0 && Id <= ITEMTYPE_EX, "Invalid ID");
dbg_assert(Size == 0 || pData != nullptr, "Data missing"); // Items without data are allowed dbg_assert(Size == 0 || pData != nullptr, "Data missing"); // Items without data are allowed
dbg_assert(Size <= (size_t)std::numeric_limits<int>::max(), "Data too large"); dbg_assert(Size <= (size_t)std::numeric_limits<int>::max(), "Data too large");
dbg_assert(Size % sizeof(int) == 0, "Invalid data boundary"); dbg_assert(Size % sizeof(int) == 0, "Invalid data boundary");
@ -707,7 +707,7 @@ int CDataFileWriter::AddItem(int Type, int ID, size_t Size, const void *pData, c
m_vItems.emplace_back(); m_vItems.emplace_back();
CItemInfo &Info = m_vItems.back(); CItemInfo &Info = m_vItems.back();
Info.m_Type = Type; Info.m_Type = Type;
Info.m_ID = ID; Info.m_Id = Id;
Info.m_Size = Size; Info.m_Size = Size;
// copy data // copy data
@ -851,10 +851,10 @@ void CDataFileWriter::Finish()
// Construct and write header // Construct and write header
{ {
CDatafileHeader Header; CDatafileHeader Header;
Header.m_aID[0] = 'D'; Header.m_aId[0] = 'D';
Header.m_aID[1] = 'A'; Header.m_aId[1] = 'A';
Header.m_aID[2] = 'T'; Header.m_aId[2] = 'T';
Header.m_aID[3] = 'A'; Header.m_aId[3] = 'A';
Header.m_Version = 4; Header.m_Version = 4;
Header.m_Size = FileSize - Header.SizeOffset(); Header.m_Size = FileSize - Header.SizeOffset();
Header.m_Swaplen = SwapSize - Header.SizeOffset(); Header.m_Swaplen = SwapSize - Header.SizeOffset();
@ -947,11 +947,11 @@ void CDataFileWriter::Finish()
for(int ItemIndex = m_aItemTypes[Type].m_First; ItemIndex != -1; ItemIndex = m_vItems[ItemIndex].m_Next) for(int ItemIndex = m_aItemTypes[Type].m_First; ItemIndex != -1; ItemIndex = m_vItems[ItemIndex].m_Next)
{ {
CDatafileItem Item; CDatafileItem Item;
Item.m_TypeAndID = (Type << 16) | m_vItems[ItemIndex].m_ID; Item.m_TypeAndId = (Type << 16) | m_vItems[ItemIndex].m_Id;
Item.m_Size = m_vItems[ItemIndex].m_Size; Item.m_Size = m_vItems[ItemIndex].m_Size;
if(DEBUG) if(DEBUG)
dbg_msg("datafile", "writing item. Type=%x ItemIndex=%d ID=%d Size=%d", Type, ItemIndex, m_vItems[ItemIndex].m_ID, m_vItems[ItemIndex].m_Size); dbg_msg("datafile", "writing item. Type=%x ItemIndex=%d Id=%d Size=%d", Type, ItemIndex, m_vItems[ItemIndex].m_Id, m_vItems[ItemIndex].m_Size);
#if defined(CONF_ARCH_ENDIAN_BIG) #if defined(CONF_ARCH_ENDIAN_BIG)
swap_endian(&Item, sizeof(int), sizeof(Item) / sizeof(int)); swap_endian(&Item, sizeof(int), sizeof(Item) / sizeof(int));

View file

@ -54,10 +54,10 @@ public:
int NumData() const; int NumData() const;
int GetItemSize(int Index) const; int GetItemSize(int Index) const;
void *GetItem(int Index, int *pType = nullptr, int *pID = nullptr, CUuid *pUuid = nullptr); void *GetItem(int Index, int *pType = nullptr, int *pId = nullptr, CUuid *pUuid = nullptr);
void GetType(int Type, int *pStart, int *pNum); void GetType(int Type, int *pStart, int *pNum);
int FindItemIndex(int Type, int ID); int FindItemIndex(int Type, int Id);
void *FindItem(int Type, int ID); void *FindItem(int Type, int Id);
int NumItems() const; int NumItems() const;
SHA256_DIGEST Sha256() const; SHA256_DIGEST Sha256() const;
@ -88,7 +88,7 @@ private:
struct CItemInfo struct CItemInfo
{ {
int m_Type; int m_Type;
int m_ID; int m_Id;
int m_Size; int m_Size;
int m_Next; int m_Next;
int m_Prev; int m_Prev;
@ -136,7 +136,7 @@ public:
~CDataFileWriter(); ~CDataFileWriter();
bool Open(class IStorage *pStorage, const char *pFilename, int StorageType = IStorage::TYPE_SAVE); bool Open(class IStorage *pStorage, const char *pFilename, int StorageType = IStorage::TYPE_SAVE);
int AddItem(int Type, int ID, size_t Size, const void *pData, const CUuid *pUuid = nullptr); int AddItem(int Type, int Id, size_t Size, const void *pData, const CUuid *pUuid = nullptr);
int AddData(size_t Size, const void *pData, ECompressionLevel CompressionLevel = COMPRESSION_DEFAULT); int AddData(size_t Size, const void *pData, ECompressionLevel CompressionLevel = COMPRESSION_DEFAULT);
int AddDataSwapped(size_t Size, const void *pData); int AddDataSwapped(size_t Size, const void *pData);
int AddDataString(const char *pStr); int AddDataString(const char *pStr);

View file

@ -9,35 +9,35 @@ CEcon::CEcon() :
{ {
} }
int CEcon::NewClientCallback(int ClientID, void *pUser) int CEcon::NewClientCallback(int ClientId, void *pUser)
{ {
CEcon *pThis = (CEcon *)pUser; CEcon *pThis = (CEcon *)pUser;
char aAddrStr[NETADDR_MAXSTRSIZE]; char aAddrStr[NETADDR_MAXSTRSIZE];
net_addr_str(pThis->m_NetConsole.ClientAddr(ClientID), aAddrStr, sizeof(aAddrStr), true); net_addr_str(pThis->m_NetConsole.ClientAddr(ClientId), aAddrStr, sizeof(aAddrStr), true);
char aBuf[128]; char aBuf[128];
str_format(aBuf, sizeof(aBuf), "client accepted. cid=%d addr=%s'", ClientID, aAddrStr); str_format(aBuf, sizeof(aBuf), "client accepted. cid=%d addr=%s'", ClientId, aAddrStr);
pThis->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "econ", aBuf); pThis->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "econ", aBuf);
pThis->m_aClients[ClientID].m_State = CClient::STATE_CONNECTED; pThis->m_aClients[ClientId].m_State = CClient::STATE_CONNECTED;
pThis->m_aClients[ClientID].m_TimeConnected = time_get(); pThis->m_aClients[ClientId].m_TimeConnected = time_get();
pThis->m_aClients[ClientID].m_AuthTries = 0; pThis->m_aClients[ClientId].m_AuthTries = 0;
pThis->m_NetConsole.Send(ClientID, "Enter password:"); pThis->m_NetConsole.Send(ClientId, "Enter password:");
return 0; return 0;
} }
int CEcon::DelClientCallback(int ClientID, const char *pReason, void *pUser) int CEcon::DelClientCallback(int ClientId, const char *pReason, void *pUser)
{ {
CEcon *pThis = (CEcon *)pUser; CEcon *pThis = (CEcon *)pUser;
char aAddrStr[NETADDR_MAXSTRSIZE]; char aAddrStr[NETADDR_MAXSTRSIZE];
net_addr_str(pThis->m_NetConsole.ClientAddr(ClientID), aAddrStr, sizeof(aAddrStr), true); net_addr_str(pThis->m_NetConsole.ClientAddr(ClientId), aAddrStr, sizeof(aAddrStr), true);
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "client dropped. cid=%d addr=%s reason='%s'", ClientID, aAddrStr, pReason); str_format(aBuf, sizeof(aBuf), "client dropped. cid=%d addr=%s reason='%s'", ClientId, aAddrStr, pReason);
pThis->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "econ", aBuf); pThis->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "econ", aBuf);
pThis->m_aClients[ClientID].m_State = CClient::STATE_EMPTY; pThis->m_aClients[ClientId].m_State = CClient::STATE_EMPTY;
return 0; return 0;
} }
@ -45,8 +45,8 @@ void CEcon::ConLogout(IConsole::IResult *pResult, void *pUserData)
{ {
CEcon *pThis = static_cast<CEcon *>(pUserData); CEcon *pThis = static_cast<CEcon *>(pUserData);
if(pThis->m_UserClientID >= 0 && pThis->m_UserClientID < NET_MAX_CONSOLE_CLIENTS && pThis->m_aClients[pThis->m_UserClientID].m_State != CClient::STATE_EMPTY) if(pThis->m_UserClientId >= 0 && pThis->m_UserClientId < NET_MAX_CONSOLE_CLIENTS && pThis->m_aClients[pThis->m_UserClientId].m_State != CClient::STATE_EMPTY)
pThis->m_NetConsole.Drop(pThis->m_UserClientID, "Logout"); pThis->m_NetConsole.Drop(pThis->m_UserClientId, "Logout");
} }
void CEcon::Init(CConfig *pConfig, IConsole *pConsole, CNetBan *pNetBan) void CEcon::Init(CConfig *pConfig, IConsole *pConsole, CNetBan *pNetBan)
@ -58,7 +58,7 @@ void CEcon::Init(CConfig *pConfig, IConsole *pConsole, CNetBan *pNetBan)
Client.m_State = CClient::STATE_EMPTY; Client.m_State = CClient::STATE_EMPTY;
m_Ready = false; m_Ready = false;
m_UserClientID = -1; m_UserClientId = -1;
if(g_Config.m_EcPort == 0 || g_Config.m_EcPassword[0] == 0) if(g_Config.m_EcPort == 0 || g_Config.m_EcPassword[0] == 0)
return; return;
@ -98,44 +98,44 @@ void CEcon::Update()
m_NetConsole.Update(); m_NetConsole.Update();
char aBuf[NET_MAX_PACKETSIZE]; char aBuf[NET_MAX_PACKETSIZE];
int ClientID; int ClientId;
while(m_NetConsole.Recv(aBuf, (int)(sizeof(aBuf)) - 1, &ClientID)) while(m_NetConsole.Recv(aBuf, (int)(sizeof(aBuf)) - 1, &ClientId))
{ {
dbg_assert(m_aClients[ClientID].m_State != CClient::STATE_EMPTY, "got message from empty slot"); dbg_assert(m_aClients[ClientId].m_State != CClient::STATE_EMPTY, "got message from empty slot");
if(m_aClients[ClientID].m_State == CClient::STATE_CONNECTED) if(m_aClients[ClientId].m_State == CClient::STATE_CONNECTED)
{ {
if(str_comp(aBuf, g_Config.m_EcPassword) == 0) if(str_comp(aBuf, g_Config.m_EcPassword) == 0)
{ {
m_aClients[ClientID].m_State = CClient::STATE_AUTHED; m_aClients[ClientId].m_State = CClient::STATE_AUTHED;
m_NetConsole.Send(ClientID, "Authentication successful. External console access granted."); m_NetConsole.Send(ClientId, "Authentication successful. External console access granted.");
str_format(aBuf, sizeof(aBuf), "cid=%d authed", ClientID); str_format(aBuf, sizeof(aBuf), "cid=%d authed", ClientId);
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "econ", aBuf); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "econ", aBuf);
} }
else else
{ {
m_aClients[ClientID].m_AuthTries++; m_aClients[ClientId].m_AuthTries++;
char aMsg[128]; char aMsg[128];
str_format(aMsg, sizeof(aMsg), "Wrong password %d/%d.", m_aClients[ClientID].m_AuthTries, MAX_AUTH_TRIES); str_format(aMsg, sizeof(aMsg), "Wrong password %d/%d.", m_aClients[ClientId].m_AuthTries, MAX_AUTH_TRIES);
m_NetConsole.Send(ClientID, aMsg); m_NetConsole.Send(ClientId, aMsg);
if(m_aClients[ClientID].m_AuthTries >= MAX_AUTH_TRIES) if(m_aClients[ClientId].m_AuthTries >= MAX_AUTH_TRIES)
{ {
if(!g_Config.m_EcBantime) if(!g_Config.m_EcBantime)
m_NetConsole.Drop(ClientID, "Too many authentication tries"); m_NetConsole.Drop(ClientId, "Too many authentication tries");
else else
m_NetConsole.NetBan()->BanAddr(m_NetConsole.ClientAddr(ClientID), g_Config.m_EcBantime * 60, "Too many authentication tries"); m_NetConsole.NetBan()->BanAddr(m_NetConsole.ClientAddr(ClientId), g_Config.m_EcBantime * 60, "Too many authentication tries");
} }
} }
} }
else if(m_aClients[ClientID].m_State == CClient::STATE_AUTHED) else if(m_aClients[ClientId].m_State == CClient::STATE_AUTHED)
{ {
char aFormatted[256]; char aFormatted[256];
str_format(aFormatted, sizeof(aFormatted), "cid=%d cmd='%s'", ClientID, aBuf); str_format(aFormatted, sizeof(aFormatted), "cid=%d cmd='%s'", ClientId, aBuf);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aFormatted); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aFormatted);
m_UserClientID = ClientID; m_UserClientId = ClientId;
Console()->ExecuteLine(aBuf); Console()->ExecuteLine(aBuf);
m_UserClientID = -1; m_UserClientId = -1;
} }
} }
@ -147,12 +147,12 @@ void CEcon::Update()
} }
} }
void CEcon::Send(int ClientID, const char *pLine) void CEcon::Send(int ClientId, const char *pLine)
{ {
if(!m_Ready) if(!m_Ready)
return; return;
if(ClientID == -1) if(ClientId == -1)
{ {
for(int i = 0; i < NET_MAX_CONSOLE_CLIENTS; i++) for(int i = 0; i < NET_MAX_CONSOLE_CLIENTS; i++)
{ {
@ -160,8 +160,8 @@ void CEcon::Send(int ClientID, const char *pLine)
m_NetConsole.Send(i, pLine); m_NetConsole.Send(i, pLine);
} }
} }
else if(ClientID >= 0 && ClientID < NET_MAX_CONSOLE_CLIENTS && m_aClients[ClientID].m_State == CClient::STATE_AUTHED) else if(ClientId >= 0 && ClientId < NET_MAX_CONSOLE_CLIENTS && m_aClients[ClientId].m_State == CClient::STATE_AUTHED)
m_NetConsole.Send(ClientID, pLine); m_NetConsole.Send(ClientId, pLine);
} }
void CEcon::Shutdown() void CEcon::Shutdown()

View file

@ -38,13 +38,13 @@ class CEcon
bool m_Ready; bool m_Ready;
int m_PrintCBIndex; int m_PrintCBIndex;
int m_UserClientID; int m_UserClientId;
static void SendLineCB(const char *pLine, void *pUserData, ColorRGBA PrintColor = {1, 1, 1, 1}); static void SendLineCB(const char *pLine, void *pUserData, ColorRGBA PrintColor = {1, 1, 1, 1});
static void ConLogout(IConsole::IResult *pResult, void *pUserData); static void ConLogout(IConsole::IResult *pResult, void *pUserData);
static int NewClientCallback(int ClientID, void *pUser); static int NewClientCallback(int ClientId, void *pUser);
static int DelClientCallback(int ClientID, const char *pReason, void *pUser); static int DelClientCallback(int ClientId, const char *pReason, void *pUser);
public: public:
CEcon(); CEcon();
@ -52,7 +52,7 @@ public:
void Init(CConfig *pConfig, IConsole *pConsole, CNetBan *pNetBan); void Init(CConfig *pConfig, IConsole *pConsole, CNetBan *pNetBan);
void Update(); void Update();
void Send(int ClientID, const char *pLine); void Send(int ClientId, const char *pLine);
void Shutdown(); void Shutdown();
}; };

View file

@ -45,9 +45,9 @@ int CMap::GetItemSize(int Index)
return m_DataFile.GetItemSize(Index); return m_DataFile.GetItemSize(Index);
} }
void *CMap::GetItem(int Index, int *pType, int *pID) void *CMap::GetItem(int Index, int *pType, int *pId)
{ {
return m_DataFile.GetItem(Index, pType, pID); return m_DataFile.GetItem(Index, pType, pId);
} }
void CMap::GetType(int Type, int *pStart, int *pNum) void CMap::GetType(int Type, int *pStart, int *pNum)
@ -55,14 +55,14 @@ void CMap::GetType(int Type, int *pStart, int *pNum)
m_DataFile.GetType(Type, pStart, pNum); m_DataFile.GetType(Type, pStart, pNum);
} }
int CMap::FindItemIndex(int Type, int ID) int CMap::FindItemIndex(int Type, int Id)
{ {
return m_DataFile.FindItemIndex(Type, ID); return m_DataFile.FindItemIndex(Type, Id);
} }
void *CMap::FindItem(int Type, int ID) void *CMap::FindItem(int Type, int Id)
{ {
return m_DataFile.FindItem(Type, ID); return m_DataFile.FindItem(Type, Id);
} }
int CMap::NumItems() const int CMap::NumItems() const

View file

@ -25,10 +25,10 @@ public:
int NumData() const override; int NumData() const override;
int GetItemSize(int Index) override; int GetItemSize(int Index) override;
void *GetItem(int Index, int *pType = nullptr, int *pID = nullptr) override; void *GetItem(int Index, int *pType = nullptr, int *pId = nullptr) override;
void GetType(int Type, int *pStart, int *pNum) override; void GetType(int Type, int *pStart, int *pNum) override;
int FindItemIndex(int Type, int ID) override; int FindItemIndex(int Type, int Id) override;
void *FindItem(int Type, int ID) override; void *FindItem(int Type, int Id) override;
int NumItems() const override; int NumItems() const override;
bool Load(const char *pMapName) override; bool Load(const char *pMapName) override;

View file

@ -211,7 +211,7 @@ template<class T>
int CNetBan::Ban(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason) int CNetBan::Ban(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason)
{ {
// do not ban localhost // do not ban localhost
if(NetMatch(pData, &m_LocalhostIPV4) || NetMatch(pData, &m_LocalhostIPV6)) if(NetMatch(pData, &m_LocalhostIpV4) || NetMatch(pData, &m_LocalhostIpV6))
{ {
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", "ban failed (localhost)"); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", "ban failed (localhost)");
return -1; return -1;
@ -276,8 +276,8 @@ void CNetBan::Init(IConsole *pConsole, IStorage *pStorage)
m_BanAddrPool.Reset(); m_BanAddrPool.Reset();
m_BanRangePool.Reset(); m_BanRangePool.Reset();
net_host_lookup("localhost", &m_LocalhostIPV4, NETTYPE_IPV4); net_host_lookup("localhost", &m_LocalhostIpV4, NETTYPE_IPV4);
net_host_lookup("localhost", &m_LocalhostIPV6, NETTYPE_IPV6); net_host_lookup("localhost", &m_LocalhostIpV6, NETTYPE_IPV6);
Console()->Register("ban", "s[ip|id] ?i[minutes] r[reason]", CFGFLAG_SERVER | CFGFLAG_MASTER | CFGFLAG_STORE, ConBan, this, "Ban ip for x minutes for any reason"); Console()->Register("ban", "s[ip|id] ?i[minutes] r[reason]", CFGFLAG_SERVER | CFGFLAG_MASTER | CFGFLAG_STORE, ConBan, this, "Ban ip for x minutes for any reason");
Console()->Register("ban_range", "s[first ip] s[last ip] ?i[minutes] r[reason]", CFGFLAG_SERVER | CFGFLAG_MASTER | CFGFLAG_STORE, ConBanRange, this, "Ban ip range for x minutes for any reason"); Console()->Register("ban_range", "s[first ip] s[last ip] ?i[minutes] r[reason]", CFGFLAG_SERVER | CFGFLAG_MASTER | CFGFLAG_STORE, ConBanRange, this, "Ban ip range for x minutes for any reason");

View file

@ -158,7 +158,7 @@ protected:
class IStorage *m_pStorage; class IStorage *m_pStorage;
CBanAddrPool m_BanAddrPool; CBanAddrPool m_BanAddrPool;
CBanRangePool m_BanRangePool; CBanRangePool m_BanRangePool;
NETADDR m_LocalhostIPV4, m_LocalhostIPV6; NETADDR m_LocalhostIpV4, m_LocalhostIpV6;
public: public:
enum enum

View file

@ -13,11 +13,11 @@ void CNetRecvUnpacker::Clear()
m_Valid = false; m_Valid = false;
} }
void CNetRecvUnpacker::Start(const NETADDR *pAddr, CNetConnection *pConnection, int ClientID) void CNetRecvUnpacker::Start(const NETADDR *pAddr, CNetConnection *pConnection, int ClientId)
{ {
m_Addr = *pAddr; m_Addr = *pAddr;
m_pConnection = pConnection; m_pConnection = pConnection;
m_ClientID = ClientID; m_ClientId = ClientId;
m_CurrentChunk = 0; m_CurrentChunk = 0;
m_Valid = true; m_Valid = true;
} }
@ -82,7 +82,7 @@ int CNetRecvUnpacker::FetchChunk(CNetChunk *pChunk)
} }
// fill in the info // fill in the info
pChunk->m_ClientID = m_ClientID; pChunk->m_ClientId = m_ClientId;
pChunk->m_Address = m_Addr; pChunk->m_Address = m_Addr;
pChunk->m_Flags = Header.m_Flags; pChunk->m_Flags = Header.m_Flags;
pChunk->m_DataSize = Header.m_Size; pChunk->m_DataSize = Header.m_Size;

View file

@ -107,17 +107,17 @@ enum
NET_SECURITY_TOKEN_UNSUPPORTED = 0, NET_SECURITY_TOKEN_UNSUPPORTED = 0,
}; };
typedef int (*NETFUNC_DELCLIENT)(int ClientID, const char *pReason, void *pUser); typedef int (*NETFUNC_DELCLIENT)(int ClientId, const char *pReason, void *pUser);
typedef int (*NETFUNC_NEWCLIENT_CON)(int ClientID, void *pUser); typedef int (*NETFUNC_NEWCLIENT_CON)(int ClientId, void *pUser);
typedef int (*NETFUNC_NEWCLIENT)(int ClientID, void *pUser, bool Sixup); typedef int (*NETFUNC_NEWCLIENT)(int ClientId, void *pUser, bool Sixup);
typedef int (*NETFUNC_NEWCLIENT_NOAUTH)(int ClientID, void *pUser); typedef int (*NETFUNC_NEWCLIENT_NOAUTH)(int ClientId, void *pUser);
typedef int (*NETFUNC_CLIENTREJOIN)(int ClientID, void *pUser); typedef int (*NETFUNC_CLIENTREJOIN)(int ClientId, void *pUser);
struct CNetChunk struct CNetChunk
{ {
// -1 means that it's a stateless packet // -1 means that it's a stateless packet
// 0 on the client means the server // 0 on the client means the server
int m_ClientID; int m_ClientId;
NETADDR m_Address; // only used when client_id == -1 NETADDR m_Address; // only used when client_id == -1
int m_Flags; int m_Flags;
int m_DataSize; int m_DataSize;
@ -334,13 +334,13 @@ public:
NETADDR m_Addr; NETADDR m_Addr;
CNetConnection *m_pConnection; CNetConnection *m_pConnection;
int m_CurrentChunk; int m_CurrentChunk;
int m_ClientID; int m_ClientId;
CNetPacketConstruct m_Data; CNetPacketConstruct m_Data;
unsigned char m_aBuffer[NET_MAX_PACKETSIZE]; unsigned char m_aBuffer[NET_MAX_PACKETSIZE];
CNetRecvUnpacker() { Clear(); } CNetRecvUnpacker() { Clear(); }
void Clear(); void Clear();
void Start(const NETADDR *pAddr, CNetConnection *pConnection, int ClientID); void Start(const NETADDR *pAddr, CNetConnection *pConnection, int ClientId);
int FetchChunk(CNetChunk *pChunk); int FetchChunk(CNetChunk *pChunk);
}; };
@ -365,7 +365,7 @@ class CNetServer
CNetBan *m_pNetBan; CNetBan *m_pNetBan;
CSlot m_aSlots[NET_MAX_CLIENTS]; CSlot m_aSlots[NET_MAX_CLIENTS];
int m_MaxClients; int m_MaxClients;
int m_MaxClientsPerIP; int m_MaxClientsPerIp;
NETFUNC_NEWCLIENT m_pfnNewClient; NETFUNC_NEWCLIENT m_pfnNewClient;
NETFUNC_NEWCLIENT_NOAUTH m_pfnNewClientNoAuth; NETFUNC_NEWCLIENT_NOAUTH m_pfnNewClientNoAuth;
@ -388,7 +388,7 @@ class CNetServer
void OnTokenCtrlMsg(NETADDR &Addr, int ControlMsg, const CNetPacketConstruct &Packet); void OnTokenCtrlMsg(NETADDR &Addr, int ControlMsg, const CNetPacketConstruct &Packet);
int OnSixupCtrlMsg(NETADDR &Addr, CNetChunk *pChunk, int ControlMsg, const CNetPacketConstruct &Packet, SECURITY_TOKEN &ResponseToken, SECURITY_TOKEN Token); int OnSixupCtrlMsg(NETADDR &Addr, CNetChunk *pChunk, int ControlMsg, const CNetPacketConstruct &Packet, SECURITY_TOKEN &ResponseToken, SECURITY_TOKEN Token);
void OnPreConnMsg(NETADDR &Addr, CNetPacketConstruct &Packet); void OnPreConnMsg(NETADDR &Addr, CNetPacketConstruct &Packet);
void OnConnCtrlMsg(NETADDR &Addr, int ClientID, int ControlMsg, const CNetPacketConstruct &Packet); void OnConnCtrlMsg(NETADDR &Addr, int ClientId, int ControlMsg, const CNetPacketConstruct &Packet);
bool ClientExists(const NETADDR &Addr) { return GetClientSlot(Addr) != -1; } bool ClientExists(const NETADDR &Addr) { return GetClientSlot(Addr) != -1; }
int GetClientSlot(const NETADDR &Addr); int GetClientSlot(const NETADDR &Addr);
void SendControl(NETADDR &Addr, int ControlMsg, const void *pExtra, int ExtraSize, SECURITY_TOKEN SecurityToken); void SendControl(NETADDR &Addr, int ControlMsg, const void *pExtra, int ExtraSize, SECURITY_TOKEN SecurityToken);
@ -403,7 +403,7 @@ public:
int SetCallbacks(NETFUNC_NEWCLIENT pfnNewClient, NETFUNC_NEWCLIENT_NOAUTH pfnNewClientNoAuth, NETFUNC_CLIENTREJOIN pfnClientRejoin, NETFUNC_DELCLIENT pfnDelClient, void *pUser); int SetCallbacks(NETFUNC_NEWCLIENT pfnNewClient, NETFUNC_NEWCLIENT_NOAUTH pfnNewClientNoAuth, NETFUNC_CLIENTREJOIN pfnClientRejoin, NETFUNC_DELCLIENT pfnDelClient, void *pUser);
// //
bool Open(NETADDR BindAddr, CNetBan *pNetBan, int MaxClients, int MaxClientsPerIP); bool Open(NETADDR BindAddr, CNetBan *pNetBan, int MaxClients, int MaxClientsPerIp);
int Close(); int Close();
// //
@ -412,11 +412,11 @@ public:
int Update(); int Update();
// //
int Drop(int ClientID, const char *pReason); int Drop(int ClientId, const char *pReason);
// status requests // status requests
const NETADDR *ClientAddr(int ClientID) const { return m_aSlots[ClientID].m_Connection.PeerAddress(); } const NETADDR *ClientAddr(int ClientId) const { return m_aSlots[ClientId].m_Connection.PeerAddress(); }
bool HasSecurityToken(int ClientID) const { return m_aSlots[ClientID].m_Connection.SecurityToken() != NET_SECURITY_TOKEN_UNSUPPORTED; } bool HasSecurityToken(int ClientId) const { return m_aSlots[ClientId].m_Connection.SecurityToken() != NET_SECURITY_TOKEN_UNSUPPORTED; }
NETADDR Address() const { return m_Address; } NETADDR Address() const { return m_Address; }
NETSOCKET Socket() const { return m_Socket; } NETSOCKET Socket() const { return m_Socket; }
CNetBan *NetBan() const { return m_pNetBan; } CNetBan *NetBan() const { return m_pNetBan; }
@ -427,12 +427,12 @@ public:
int SendConnlessSixup(CNetChunk *pChunk, SECURITY_TOKEN ResponseToken); int SendConnlessSixup(CNetChunk *pChunk, SECURITY_TOKEN ResponseToken);
// //
void SetMaxClientsPerIP(int Max); void SetMaxClientsPerIp(int Max);
bool SetTimedOut(int ClientID, int OrigID); bool SetTimedOut(int ClientId, int OrigId);
void SetTimeoutProtected(int ClientID); void SetTimeoutProtected(int ClientId);
int ResetErrorString(int ClientID); int ResetErrorString(int ClientId);
const char *ErrorString(int ClientID); const char *ErrorString(int ClientId);
// anti spoof // anti spoof
SECURITY_TOKEN GetGlobalToken(); SECURITY_TOKEN GetGlobalToken();
@ -466,16 +466,16 @@ public:
int Close(); int Close();
// //
int Recv(char *pLine, int MaxLength, int *pClientID = nullptr); int Recv(char *pLine, int MaxLength, int *pClientId = nullptr);
int Send(int ClientID, const char *pLine); int Send(int ClientId, const char *pLine);
int Update(); int Update();
// //
int AcceptClient(NETSOCKET Socket, const NETADDR *pAddr); int AcceptClient(NETSOCKET Socket, const NETADDR *pAddr);
int Drop(int ClientID, const char *pReason); int Drop(int ClientId, const char *pReason);
// status requests // status requests
const NETADDR *ClientAddr(int ClientID) const { return m_aSlots[ClientID].m_Connection.PeerAddress(); } const NETADDR *ClientAddr(int ClientId) const { return m_aSlots[ClientId].m_Connection.PeerAddress(); }
CNetBan *NetBan() const { return m_pNetBan; } CNetBan *NetBan() const { return m_pNetBan; }
}; };

View file

@ -90,7 +90,7 @@ int CNetClient::Recv(CNetChunk *pChunk)
if(m_RecvUnpacker.m_Data.m_Flags & NET_PACKETFLAG_CONNLESS) if(m_RecvUnpacker.m_Data.m_Flags & NET_PACKETFLAG_CONNLESS)
{ {
pChunk->m_Flags = NETSENDFLAG_CONNLESS; pChunk->m_Flags = NETSENDFLAG_CONNLESS;
pChunk->m_ClientID = -1; pChunk->m_ClientId = -1;
pChunk->m_Address = Addr; pChunk->m_Address = Addr;
pChunk->m_DataSize = m_RecvUnpacker.m_Data.m_DataSize; pChunk->m_DataSize = m_RecvUnpacker.m_Data.m_DataSize;
pChunk->m_pData = m_RecvUnpacker.m_Data.m_aChunkData; pChunk->m_pData = m_RecvUnpacker.m_Data.m_aChunkData;
@ -128,7 +128,7 @@ int CNetClient::Send(CNetChunk *pChunk)
else else
{ {
int Flags = 0; int Flags = 0;
dbg_assert(pChunk->m_ClientID == 0, "erroneous client id"); dbg_assert(pChunk->m_ClientId == 0, "erroneous client id");
if(pChunk->m_Flags & NETSENDFLAG_VITAL) if(pChunk->m_Flags & NETSENDFLAG_VITAL)
Flags = NET_CHUNKFLAG_VITAL; Flags = NET_CHUNKFLAG_VITAL;

View file

@ -42,12 +42,12 @@ int CNetConsole::Close()
return 0; return 0;
} }
int CNetConsole::Drop(int ClientID, const char *pReason) int CNetConsole::Drop(int ClientId, const char *pReason)
{ {
if(m_pfnDelClient) if(m_pfnDelClient)
m_pfnDelClient(ClientID, pReason, m_pUser); m_pfnDelClient(ClientId, pReason, m_pUser);
m_aSlots[ClientID].m_Connection.Disconnect(pReason); m_aSlots[ClientId].m_Connection.Disconnect(pReason);
return 0; return 0;
} }
@ -121,24 +121,24 @@ int CNetConsole::Update()
return 0; return 0;
} }
int CNetConsole::Recv(char *pLine, int MaxLength, int *pClientID) int CNetConsole::Recv(char *pLine, int MaxLength, int *pClientId)
{ {
for(int i = 0; i < NET_MAX_CONSOLE_CLIENTS; i++) for(int i = 0; i < NET_MAX_CONSOLE_CLIENTS; i++)
{ {
if(m_aSlots[i].m_Connection.State() == NET_CONNSTATE_ONLINE && m_aSlots[i].m_Connection.Recv(pLine, MaxLength)) if(m_aSlots[i].m_Connection.State() == NET_CONNSTATE_ONLINE && m_aSlots[i].m_Connection.Recv(pLine, MaxLength))
{ {
if(pClientID) if(pClientId)
*pClientID = i; *pClientId = i;
return 1; return 1;
} }
} }
return 0; return 0;
} }
int CNetConsole::Send(int ClientID, const char *pLine) int CNetConsole::Send(int ClientId, const char *pLine)
{ {
if(m_aSlots[ClientID].m_Connection.State() == NET_CONNSTATE_ONLINE) if(m_aSlots[ClientId].m_Connection.State() == NET_CONNSTATE_ONLINE)
return m_aSlots[ClientID].m_Connection.Send(pLine); return m_aSlots[ClientId].m_Connection.Send(pLine);
else else
return -1; return -1;
} }

View file

@ -41,7 +41,7 @@ static SECURITY_TOKEN ToSecurityToken(const unsigned char *pData)
return (int)pData[0] | (pData[1] << 8) | (pData[2] << 16) | (pData[3] << 24); return (int)pData[0] | (pData[1] << 8) | (pData[2] << 16) | (pData[3] << 24);
} }
bool CNetServer::Open(NETADDR BindAddr, CNetBan *pNetBan, int MaxClients, int MaxClientsPerIP) bool CNetServer::Open(NETADDR BindAddr, CNetBan *pNetBan, int MaxClients, int MaxClientsPerIp)
{ {
// zero out the whole structure // zero out the whole structure
this->~CNetServer(); this->~CNetServer();
@ -56,7 +56,7 @@ bool CNetServer::Open(NETADDR BindAddr, CNetBan *pNetBan, int MaxClients, int Ma
m_pNetBan = pNetBan; m_pNetBan = pNetBan;
m_MaxClients = clamp(MaxClients, 1, (int)NET_MAX_CLIENTS); m_MaxClients = clamp(MaxClients, 1, (int)NET_MAX_CLIENTS);
m_MaxClientsPerIP = MaxClientsPerIP; m_MaxClientsPerIp = MaxClientsPerIp;
m_NumConAttempts = 0; m_NumConAttempts = 0;
m_TimeNumConAttempts = time_get(); m_TimeNumConAttempts = time_get();
@ -97,14 +97,14 @@ int CNetServer::Close()
return net_udp_close(m_Socket); return net_udp_close(m_Socket);
} }
int CNetServer::Drop(int ClientID, const char *pReason) int CNetServer::Drop(int ClientId, const char *pReason)
{ {
// TODO: insert lots of checks here // TODO: insert lots of checks here
if(m_pfnDelClient) if(m_pfnDelClient)
m_pfnDelClient(ClientID, pReason, m_pUser); m_pfnDelClient(ClientId, pReason, m_pUser);
m_aSlots[ClientID].m_Connection.Disconnect(pReason); m_aSlots[ClientId].m_Connection.Disconnect(pReason);
return 0; return 0;
} }
@ -219,10 +219,10 @@ int CNetServer::TryAcceptClient(NETADDR &Addr, SECURITY_TOKEN SecurityToken, boo
} }
// check for sv_max_clients_per_ip // check for sv_max_clients_per_ip
if(NumClientsWithAddr(Addr) + 1 > m_MaxClientsPerIP) if(NumClientsWithAddr(Addr) + 1 > m_MaxClientsPerIp)
{ {
char aBuf[128]; char aBuf[128];
str_format(aBuf, sizeof(aBuf), "Only %d players with the same IP are allowed", m_MaxClientsPerIP); str_format(aBuf, sizeof(aBuf), "Only %d players with the same IP are allowed", m_MaxClientsPerIp);
CNetBase::SendControlMsg(m_Socket, &Addr, 0, NET_CTRLMSG_CLOSE, aBuf, str_length(aBuf) + 1, SecurityToken, Sixup); CNetBase::SendControlMsg(m_Socket, &Addr, 0, NET_CTRLMSG_CLOSE, aBuf, str_length(aBuf) + 1, SecurityToken, Sixup);
return -1; // failed to add client return -1; // failed to add client
} }
@ -465,7 +465,7 @@ void CNetServer::OnPreConnMsg(NETADDR &Addr, CNetPacketConstruct &Packet)
} }
} }
void CNetServer::OnConnCtrlMsg(NETADDR &Addr, int ClientID, int ControlMsg, const CNetPacketConstruct &Packet) void CNetServer::OnConnCtrlMsg(NETADDR &Addr, int ClientId, int ControlMsg, const CNetPacketConstruct &Packet)
{ {
if(ControlMsg == NET_CTRLMSG_CONNECT) if(ControlMsg == NET_CTRLMSG_CONNECT)
{ {
@ -483,7 +483,7 @@ void CNetServer::OnConnCtrlMsg(NETADDR &Addr, int ClientID, int ControlMsg, cons
} }
if(g_Config.m_Debug) if(g_Config.m_Debug)
dbg_msg("security", "client %d wants to reconnect", ClientID); dbg_msg("security", "client %d wants to reconnect", ClientId);
} }
else if(ControlMsg == NET_CTRLMSG_ACCEPT && Packet.m_DataSize == 1 + sizeof(SECURITY_TOKEN)) else if(ControlMsg == NET_CTRLMSG_ACCEPT && Packet.m_DataSize == 1 + sizeof(SECURITY_TOKEN))
{ {
@ -493,11 +493,11 @@ void CNetServer::OnConnCtrlMsg(NETADDR &Addr, int ClientID, int ControlMsg, cons
// correct token // correct token
// try to accept client // try to accept client
if(g_Config.m_Debug) if(g_Config.m_Debug)
dbg_msg("security", "client %d reconnect", ClientID); dbg_msg("security", "client %d reconnect", ClientId);
// reset netconn and process rejoin // reset netconn and process rejoin
m_aSlots[ClientID].m_Connection.Reset(true); m_aSlots[ClientId].m_Connection.Reset(true);
m_pfnClientRejoin(ClientID, m_pUser); m_pfnClientRejoin(ClientId, m_pUser);
} }
} }
} }
@ -557,7 +557,7 @@ int CNetServer::OnSixupCtrlMsg(NETADDR &Addr, CNetChunk *pChunk, int ControlMsg,
// Is this behaviour safe to rely on? // Is this behaviour safe to rely on?
pChunk->m_Flags = 0; pChunk->m_Flags = 0;
pChunk->m_ClientID = -1; pChunk->m_ClientId = -1;
pChunk->m_Address = Addr; pChunk->m_Address = Addr;
pChunk->m_DataSize = 0; pChunk->m_DataSize = 0;
return 1; return 1;
@ -654,7 +654,7 @@ int CNetServer::Recv(CNetChunk *pChunk, SECURITY_TOKEN *pResponseToken)
continue; continue;
pChunk->m_Flags = NETSENDFLAG_CONNLESS; pChunk->m_Flags = NETSENDFLAG_CONNLESS;
pChunk->m_ClientID = -1; pChunk->m_ClientId = -1;
pChunk->m_Address = Addr; pChunk->m_Address = Addr;
pChunk->m_DataSize = m_RecvUnpacker.m_Data.m_DataSize; pChunk->m_DataSize = m_RecvUnpacker.m_Data.m_DataSize;
pChunk->m_pData = m_RecvUnpacker.m_Data.m_aChunkData; pChunk->m_pData = m_RecvUnpacker.m_Data.m_aChunkData;
@ -740,20 +740,20 @@ int CNetServer::Send(CNetChunk *pChunk)
else else
{ {
int Flags = 0; int Flags = 0;
dbg_assert(pChunk->m_ClientID >= 0, "erroneous client id"); dbg_assert(pChunk->m_ClientId >= 0, "erroneous client id");
dbg_assert(pChunk->m_ClientID < MaxClients(), "erroneous client id"); dbg_assert(pChunk->m_ClientId < MaxClients(), "erroneous client id");
if(pChunk->m_Flags & NETSENDFLAG_VITAL) if(pChunk->m_Flags & NETSENDFLAG_VITAL)
Flags = NET_CHUNKFLAG_VITAL; Flags = NET_CHUNKFLAG_VITAL;
if(m_aSlots[pChunk->m_ClientID].m_Connection.QueueChunk(Flags, pChunk->m_DataSize, pChunk->m_pData) == 0) if(m_aSlots[pChunk->m_ClientId].m_Connection.QueueChunk(Flags, pChunk->m_DataSize, pChunk->m_pData) == 0)
{ {
if(pChunk->m_Flags & NETSENDFLAG_FLUSH) if(pChunk->m_Flags & NETSENDFLAG_FLUSH)
m_aSlots[pChunk->m_ClientID].m_Connection.Flush(); m_aSlots[pChunk->m_ClientId].m_Connection.Flush();
} }
else else
{ {
//Drop(pChunk->m_ClientID, "Error sending data"); //Drop(pChunk->m_ClientId, "Error sending data");
} }
} }
return 0; return 0;
@ -784,7 +784,7 @@ int CNetServer::SendConnlessSixup(CNetChunk *pChunk, SECURITY_TOKEN ResponseToke
return 0; return 0;
} }
void CNetServer::SetMaxClientsPerIP(int Max) void CNetServer::SetMaxClientsPerIp(int Max)
{ {
// clamp // clamp
if(Max < 1) if(Max < 1)
@ -792,31 +792,31 @@ void CNetServer::SetMaxClientsPerIP(int Max)
else if(Max > NET_MAX_CLIENTS) else if(Max > NET_MAX_CLIENTS)
Max = NET_MAX_CLIENTS; Max = NET_MAX_CLIENTS;
m_MaxClientsPerIP = Max; m_MaxClientsPerIp = Max;
} }
bool CNetServer::SetTimedOut(int ClientID, int OrigID) bool CNetServer::SetTimedOut(int ClientId, int OrigId)
{ {
if(m_aSlots[ClientID].m_Connection.State() != NET_CONNSTATE_ERROR) if(m_aSlots[ClientId].m_Connection.State() != NET_CONNSTATE_ERROR)
return false; return false;
m_aSlots[ClientID].m_Connection.SetTimedOut(ClientAddr(OrigID), m_aSlots[OrigID].m_Connection.SeqSequence(), m_aSlots[OrigID].m_Connection.AckSequence(), m_aSlots[OrigID].m_Connection.SecurityToken(), m_aSlots[OrigID].m_Connection.ResendBuffer(), m_aSlots[OrigID].m_Connection.m_Sixup); m_aSlots[ClientId].m_Connection.SetTimedOut(ClientAddr(OrigId), m_aSlots[OrigId].m_Connection.SeqSequence(), m_aSlots[OrigId].m_Connection.AckSequence(), m_aSlots[OrigId].m_Connection.SecurityToken(), m_aSlots[OrigId].m_Connection.ResendBuffer(), m_aSlots[OrigId].m_Connection.m_Sixup);
m_aSlots[OrigID].m_Connection.Reset(); m_aSlots[OrigId].m_Connection.Reset();
return true; return true;
} }
void CNetServer::SetTimeoutProtected(int ClientID) void CNetServer::SetTimeoutProtected(int ClientId)
{ {
m_aSlots[ClientID].m_Connection.m_TimeoutProtected = true; m_aSlots[ClientId].m_Connection.m_TimeoutProtected = true;
} }
int CNetServer::ResetErrorString(int ClientID) int CNetServer::ResetErrorString(int ClientId)
{ {
m_aSlots[ClientID].m_Connection.ResetErrorString(); m_aSlots[ClientId].m_Connection.ResetErrorString();
return 0; return 0;
} }
const char *CNetServer::ErrorString(int ClientID) const char *CNetServer::ErrorString(int ClientId)
{ {
return m_aSlots[ClientID].m_Connection.ErrorString(); return m_aSlots[ClientId].m_Connection.ErrorString();
} }

View file

@ -15,52 +15,52 @@ void RegisterUuids(CUuidManager *pManager)
#undef UUID #undef UUID
} }
int UnpackMessageID(int *pID, bool *pSys, CUuid *pUuid, CUnpacker *pUnpacker, CMsgPacker *pPacker) int UnpackMessageId(int *pId, bool *pSys, CUuid *pUuid, CUnpacker *pUnpacker, CMsgPacker *pPacker)
{ {
*pID = 0; *pId = 0;
*pSys = false; *pSys = false;
mem_zero(pUuid, sizeof(*pUuid)); mem_zero(pUuid, sizeof(*pUuid));
int MsgID = pUnpacker->GetInt(); int MsgId = pUnpacker->GetInt();
if(pUnpacker->Error()) if(pUnpacker->Error())
{ {
return UNPACKMESSAGE_ERROR; return UNPACKMESSAGE_ERROR;
} }
*pID = MsgID >> 1; *pId = MsgId >> 1;
*pSys = MsgID & 1; *pSys = MsgId & 1;
if(*pID < 0 || *pID >= OFFSET_UUID) if(*pId < 0 || *pId >= OFFSET_UUID)
{ {
return UNPACKMESSAGE_ERROR; return UNPACKMESSAGE_ERROR;
} }
if(*pID != 0) // NETMSG_EX, NETMSGTYPE_EX if(*pId != 0) // NETMSG_EX, NETMSGTYPE_EX
{ {
return UNPACKMESSAGE_OK; return UNPACKMESSAGE_OK;
} }
*pID = g_UuidManager.UnpackUuid(pUnpacker, pUuid); *pId = g_UuidManager.UnpackUuid(pUnpacker, pUuid);
if(*pID == UUID_INVALID || *pID == UUID_UNKNOWN) if(*pId == UUID_INVALID || *pId == UUID_UNKNOWN)
{ {
return UNPACKMESSAGE_ERROR; return UNPACKMESSAGE_ERROR;
} }
if(*pSys) if(*pSys)
{ {
switch(*pID) switch(*pId)
{ {
case NETMSG_WHATIS: case NETMSG_WHATIS:
{ {
CUuid Uuid2; CUuid Uuid2;
int ID2 = g_UuidManager.UnpackUuid(pUnpacker, &Uuid2); int Id2 = g_UuidManager.UnpackUuid(pUnpacker, &Uuid2);
if(ID2 == UUID_INVALID) if(Id2 == UUID_INVALID)
{ {
break; break;
} }
if(ID2 == UUID_UNKNOWN) if(Id2 == UUID_UNKNOWN)
{ {
new(pPacker) CMsgPacker(NETMSG_IDONTKNOW, true); new(pPacker) CMsgPacker(NETMSG_IDONTKNOW, true);
pPacker->AddRaw(&Uuid2, sizeof(Uuid2)); pPacker->AddRaw(&Uuid2, sizeof(Uuid2));
@ -69,7 +69,7 @@ int UnpackMessageID(int *pID, bool *pSys, CUuid *pUuid, CUnpacker *pUnpacker, CM
{ {
new(pPacker) CMsgPacker(NETMSG_ITIS, true); new(pPacker) CMsgPacker(NETMSG_ITIS, true);
pPacker->AddRaw(&Uuid2, sizeof(Uuid2)); pPacker->AddRaw(&Uuid2, sizeof(Uuid2));
pPacker->AddString(g_UuidManager.GetName(ID2), 0); pPacker->AddString(g_UuidManager.GetName(Id2), 0);
} }
return UNPACKMESSAGE_ANSWER; return UNPACKMESSAGE_ANSWER;
} }

View file

@ -33,8 +33,8 @@ enum
}; };
void RegisterUuids(CUuidManager *pManager); void RegisterUuids(CUuidManager *pManager);
bool NetworkExDefaultHandler(int *pID, CUuid *pUuid, CUnpacker *pUnpacker, CMsgPacker *pPacker, int Type); bool NetworkExDefaultHandler(int *pId, CUuid *pUuid, CUnpacker *pUnpacker, CMsgPacker *pPacker, int Type);
int UnpackMessageID(int *pID, bool *pSys, CUuid *pUuid, CUnpacker *pUnpacker, CMsgPacker *pPacker); int UnpackMessageId(int *pId, bool *pSys, CUuid *pUuid, CUnpacker *pUnpacker, CMsgPacker *pPacker);
#endif // ENGINE_SHARED_PROTOCOL_EX_H #endif // ENGINE_SHARED_PROTOCOL_EX_H

View file

@ -65,7 +65,7 @@ int CSnapshot::GetItemIndex(int Key) const
return -1; return -1;
} }
const void *CSnapshot::FindItem(int Type, int ID) const const void *CSnapshot::FindItem(int Type, int Id) const
{ {
int InternalType = Type; int InternalType = Type;
if(Type >= OFFSET_UUID) if(Type >= OFFSET_UUID)
@ -79,11 +79,11 @@ const void *CSnapshot::FindItem(int Type, int ID) const
for(int i = 0; i < m_NumItems; i++) for(int i = 0; i < m_NumItems; i++)
{ {
const CSnapshotItem *pItem = GetItem(i); const CSnapshotItem *pItem = GetItem(i);
if(pItem->Type() == 0 && pItem->ID() >= OFFSET_UUID_TYPE) // NETOBJTYPE_EX if(pItem->Type() == 0 && pItem->Id() >= OFFSET_UUID_TYPE) // NETOBJTYPE_EX
{ {
if(mem_comp(pItem->Data(), aTypeUuidItem, sizeof(CUuid)) == 0) if(mem_comp(pItem->Data(), aTypeUuidItem, sizeof(CUuid)) == 0)
{ {
InternalType = pItem->ID(); InternalType = pItem->Id();
Found = true; Found = true;
break; break;
} }
@ -94,7 +94,7 @@ const void *CSnapshot::FindItem(int Type, int ID) const
return nullptr; return nullptr;
} }
} }
int Index = GetItemIndex((InternalType << 16) | ID); int Index = GetItemIndex((InternalType << 16) | Id);
return Index < 0 ? nullptr : GetItem(Index)->Data(); return Index < 0 ? nullptr : GetItem(Index)->Data();
} }
@ -120,7 +120,7 @@ void CSnapshot::DebugDump() const
{ {
const CSnapshotItem *pItem = GetItem(i); const CSnapshotItem *pItem = GetItem(i);
int Size = GetItemSize(i); int Size = GetItemSize(i);
dbg_msg("snapshot", "\ttype=%d id=%d", pItem->Type(), pItem->ID()); dbg_msg("snapshot", "\ttype=%d id=%d", pItem->Type(), pItem->Id());
for(size_t b = 0; b < Size / sizeof(int32_t); b++) for(size_t b = 0; b < Size / sizeof(int32_t); b++)
dbg_msg("snapshot", "\t\t%3d %12d\t%08x", (int)b, pItem->Data()[b], pItem->Data()[b]); dbg_msg("snapshot", "\t\t%3d %12d\t%08x", (int)b, pItem->Data()[b], pItem->Data()[b]);
} }
@ -161,7 +161,7 @@ struct CItemList
int m_aIndex[HASHLIST_BUCKET_SIZE]; int m_aIndex[HASHLIST_BUCKET_SIZE];
}; };
inline size_t CalcHashID(int Key) inline size_t CalcHashId(int Key)
{ {
// djb2 (http://www.cse.yorku.ca/~oz/hash.html) // djb2 (http://www.cse.yorku.ca/~oz/hash.html)
unsigned Hash = 5381; unsigned Hash = 5381;
@ -178,23 +178,23 @@ static void GenerateHash(CItemList *pHashlist, const CSnapshot *pSnapshot)
for(int i = 0; i < pSnapshot->NumItems(); i++) for(int i = 0; i < pSnapshot->NumItems(); i++)
{ {
int Key = pSnapshot->GetItem(i)->Key(); int Key = pSnapshot->GetItem(i)->Key();
size_t HashID = CalcHashID(Key); size_t HashId = CalcHashId(Key);
if(pHashlist[HashID].m_Num < HASHLIST_BUCKET_SIZE) if(pHashlist[HashId].m_Num < HASHLIST_BUCKET_SIZE)
{ {
pHashlist[HashID].m_aIndex[pHashlist[HashID].m_Num] = i; pHashlist[HashId].m_aIndex[pHashlist[HashId].m_Num] = i;
pHashlist[HashID].m_aKeys[pHashlist[HashID].m_Num] = Key; pHashlist[HashId].m_aKeys[pHashlist[HashId].m_Num] = Key;
pHashlist[HashID].m_Num++; pHashlist[HashId].m_Num++;
} }
} }
} }
static int GetItemIndexHashed(int Key, const CItemList *pHashlist) static int GetItemIndexHashed(int Key, const CItemList *pHashlist)
{ {
size_t HashID = CalcHashID(Key); size_t HashId = CalcHashId(Key);
for(int i = 0; i < pHashlist[HashID].m_Num; i++) for(int i = 0; i < pHashlist[HashId].m_Num; i++)
{ {
if(pHashlist[HashID].m_aKeys[i] == Key) if(pHashlist[HashId].m_aKeys[i] == Key)
return pHashlist[HashID].m_aIndex[i]; return pHashlist[HashId].m_aIndex[i];
} }
return -1; return -1;
@ -326,7 +326,7 @@ int CSnapshotDelta::CreateDelta(const CSnapshot *pFrom, const CSnapshot *pTo, vo
if(DiffItem(pPastItem->Data(), pCurItem->Data(), pItemDataDst, ItemSize / sizeof(int32_t))) if(DiffItem(pPastItem->Data(), pCurItem->Data(), pItemDataDst, ItemSize / sizeof(int32_t)))
{ {
*pData++ = pCurItem->Type(); *pData++ = pCurItem->Type();
*pData++ = pCurItem->ID(); *pData++ = pCurItem->Id();
if(IncludeSize) if(IncludeSize)
*pData++ = ItemSize / sizeof(int32_t); *pData++ = ItemSize / sizeof(int32_t);
pData += ItemSize / sizeof(int32_t); pData += ItemSize / sizeof(int32_t);
@ -336,7 +336,7 @@ int CSnapshotDelta::CreateDelta(const CSnapshot *pFrom, const CSnapshot *pTo, vo
else else
{ {
*pData++ = pCurItem->Type(); *pData++ = pCurItem->Type();
*pData++ = pCurItem->ID(); *pData++ = pCurItem->Id();
if(IncludeSize) if(IncludeSize)
*pData++ = ItemSize / sizeof(int32_t); *pData++ = ItemSize / sizeof(int32_t);
@ -386,7 +386,7 @@ int CSnapshotDelta::UnpackDelta(const CSnapshot *pFrom, CSnapshot *pTo, const vo
if(Keep) if(Keep)
{ {
void *pObj = Builder.NewItem(pFromItem->Type(), pFromItem->ID(), ItemSize); void *pObj = Builder.NewItem(pFromItem->Type(), pFromItem->Id(), ItemSize);
if(!pObj) if(!pObj)
return -301; return -301;
@ -405,8 +405,8 @@ int CSnapshotDelta::UnpackDelta(const CSnapshot *pFrom, CSnapshot *pTo, const vo
if(Type < 0 || Type > CSnapshot::MAX_TYPE) if(Type < 0 || Type > CSnapshot::MAX_TYPE)
return -202; return -202;
const int ID = *pData++; const int Id = *pData++;
if(ID < 0 || ID > CSnapshot::MAX_ID) if(Id < 0 || Id > CSnapshot::MAX_ID)
return -203; return -203;
int ItemSize; int ItemSize;
@ -424,12 +424,12 @@ int CSnapshotDelta::UnpackDelta(const CSnapshot *pFrom, CSnapshot *pTo, const vo
if(ItemSize < 0 || (const char *)pEnd - (const char *)pData < ItemSize) if(ItemSize < 0 || (const char *)pEnd - (const char *)pData < ItemSize)
return -205; return -205;
const int Key = (Type << 16) | ID; const int Key = (Type << 16) | Id;
// create the item if needed // create the item if needed
int *pNewData = Builder.GetItemData(Key); int *pNewData = Builder.GetItemData(Key);
if(!pNewData) if(!pNewData)
pNewData = (int *)Builder.NewItem(Type, ID, ItemSize); pNewData = (int *)Builder.NewItem(Type, Id, ItemSize);
if(!pNewData) if(!pNewData)
return -302; return -302;
@ -612,8 +612,8 @@ int CSnapshotBuilder::GetTypeFromIndex(int Index) const
void CSnapshotBuilder::AddExtendedItemType(int Index) void CSnapshotBuilder::AddExtendedItemType(int Index)
{ {
dbg_assert(0 <= Index && Index < m_NumExtendedItemTypes, "index out of range"); dbg_assert(0 <= Index && Index < m_NumExtendedItemTypes, "index out of range");
int TypeID = m_aExtendedItemTypes[Index]; int TypeId = m_aExtendedItemTypes[Index];
CUuid Uuid = g_UuidManager.GetUuid(TypeID); CUuid Uuid = g_UuidManager.GetUuid(TypeId);
int *pUuidItem = (int *)NewItem(0, GetTypeFromIndex(Index), sizeof(Uuid)); // NETOBJTYPE_EX int *pUuidItem = (int *)NewItem(0, GetTypeFromIndex(Index), sizeof(Uuid)); // NETOBJTYPE_EX
if(pUuidItem) if(pUuidItem)
{ {
@ -622,25 +622,25 @@ void CSnapshotBuilder::AddExtendedItemType(int Index)
} }
} }
int CSnapshotBuilder::GetExtendedItemTypeIndex(int TypeID) int CSnapshotBuilder::GetExtendedItemTypeIndex(int TypeId)
{ {
for(int i = 0; i < m_NumExtendedItemTypes; i++) for(int i = 0; i < m_NumExtendedItemTypes; i++)
{ {
if(m_aExtendedItemTypes[i] == TypeID) if(m_aExtendedItemTypes[i] == TypeId)
{ {
return i; return i;
} }
} }
dbg_assert(m_NumExtendedItemTypes < MAX_EXTENDED_ITEM_TYPES, "too many extended item types"); dbg_assert(m_NumExtendedItemTypes < MAX_EXTENDED_ITEM_TYPES, "too many extended item types");
int Index = m_NumExtendedItemTypes; int Index = m_NumExtendedItemTypes;
m_aExtendedItemTypes[Index] = TypeID; m_aExtendedItemTypes[Index] = TypeId;
m_NumExtendedItemTypes++; m_NumExtendedItemTypes++;
return Index; return Index;
} }
void *CSnapshotBuilder::NewItem(int Type, int ID, int Size) void *CSnapshotBuilder::NewItem(int Type, int Id, int Size)
{ {
if(ID == -1) if(Id == -1)
{ {
return nullptr; return nullptr;
} }
@ -676,7 +676,7 @@ void *CSnapshotBuilder::NewItem(int Type, int ID, int Size)
return nullptr; return nullptr;
mem_zero(pObj, sizeof(CSnapshotItem) + Size); mem_zero(pObj, sizeof(CSnapshotItem) + Size);
pObj->m_TypeAndID = (Type << 16) | ID; pObj->m_TypeAndId = (Type << 16) | Id;
m_aOffsets[m_NumItems] = m_DataSize; m_aOffsets[m_NumItems] = m_DataSize;
m_DataSize += sizeof(CSnapshotItem) + Size; m_DataSize += sizeof(CSnapshotItem) + Size;
m_NumItems++; m_NumItems++;

View file

@ -15,12 +15,12 @@ class CSnapshotItem
int *Data() { return (int *)(this + 1); } int *Data() { return (int *)(this + 1); }
public: public:
int m_TypeAndID; int m_TypeAndId;
const int *Data() const { return (int *)(this + 1); } const int *Data() const { return (int *)(this + 1); }
int Type() const { return m_TypeAndID >> 16; } int Type() const { return m_TypeAndId >> 16; }
int ID() const { return m_TypeAndID & 0xffff; } int Id() const { return m_TypeAndId & 0xffff; }
int Key() const { return m_TypeAndID; } int Key() const { return m_TypeAndId; }
}; };
class CSnapshot class CSnapshot
@ -54,7 +54,7 @@ public:
int GetItemIndex(int Key) const; int GetItemIndex(int Key) const;
int GetItemType(int Index) const; int GetItemType(int Index) const;
int GetExternalItemType(int InternalType) const; int GetExternalItemType(int InternalType) const;
const void *FindItem(int Type, int ID) const; const void *FindItem(int Type, int Id) const;
unsigned Crc() const; unsigned Crc() const;
void DebugDump() const; void DebugDump() const;
@ -151,7 +151,7 @@ class CSnapshotBuilder
int m_NumExtendedItemTypes; int m_NumExtendedItemTypes;
void AddExtendedItemType(int Index); void AddExtendedItemType(int Index);
int GetExtendedItemTypeIndex(int TypeID); int GetExtendedItemTypeIndex(int TypeId);
int GetTypeFromIndex(int Index) const; int GetTypeFromIndex(int Index) const;
bool m_Sixup; bool m_Sixup;
@ -161,7 +161,7 @@ public:
void Init(bool Sixup = false); void Init(bool Sixup = false);
void *NewItem(int Type, int ID, int Size); void *NewItem(int Type, int Id, int Size);
CSnapshotItem *GetItem(int Index); CSnapshotItem *GetItem(int Index);
int *GetItemData(int Key); int *GetItemData(int Key);

View file

@ -106,19 +106,19 @@ bool CUuid::operator<(const CUuid &Other) const
return mem_comp(this, &Other, sizeof(*this)) < 0; return mem_comp(this, &Other, sizeof(*this)) < 0;
} }
static int GetIndex(int ID) static int GetIndex(int Id)
{ {
return ID - OFFSET_UUID; return Id - OFFSET_UUID;
} }
static int GetID(int Index) static int GetId(int Index)
{ {
return Index + OFFSET_UUID; return Index + OFFSET_UUID;
} }
void CUuidManager::RegisterName(int ID, const char *pName) void CUuidManager::RegisterName(int Id, const char *pName)
{ {
dbg_assert(GetIndex(ID) == (int)m_vNames.size(), "names must be registered with increasing ID"); dbg_assert(GetIndex(Id) == (int)m_vNames.size(), "names must be registered with increasing ID");
CName Name; CName Name;
Name.m_pName = pName; Name.m_pName = pName;
Name.m_Uuid = CalculateUuid(pName); Name.m_Uuid = CalculateUuid(pName);
@ -128,29 +128,29 @@ void CUuidManager::RegisterName(int ID, const char *pName)
CNameIndexed NameIndexed; CNameIndexed NameIndexed;
NameIndexed.m_Uuid = Name.m_Uuid; NameIndexed.m_Uuid = Name.m_Uuid;
NameIndexed.m_ID = GetIndex(ID); NameIndexed.m_Id = GetIndex(Id);
m_vNamesSorted.insert(std::lower_bound(m_vNamesSorted.begin(), m_vNamesSorted.end(), NameIndexed), NameIndexed); m_vNamesSorted.insert(std::lower_bound(m_vNamesSorted.begin(), m_vNamesSorted.end(), NameIndexed), NameIndexed);
} }
CUuid CUuidManager::GetUuid(int ID) const CUuid CUuidManager::GetUuid(int Id) const
{ {
return m_vNames[GetIndex(ID)].m_Uuid; return m_vNames[GetIndex(Id)].m_Uuid;
} }
const char *CUuidManager::GetName(int ID) const const char *CUuidManager::GetName(int Id) const
{ {
return m_vNames[GetIndex(ID)].m_pName; return m_vNames[GetIndex(Id)].m_pName;
} }
int CUuidManager::LookupUuid(CUuid Uuid) const int CUuidManager::LookupUuid(CUuid Uuid) const
{ {
CNameIndexed Needle; CNameIndexed Needle;
Needle.m_Uuid = Uuid; Needle.m_Uuid = Uuid;
Needle.m_ID = 0; Needle.m_Id = 0;
auto Range = std::equal_range(m_vNamesSorted.begin(), m_vNamesSorted.end(), Needle); auto Range = std::equal_range(m_vNamesSorted.begin(), m_vNamesSorted.end(), Needle);
if(std::distance(Range.first, Range.second) == 1) if(std::distance(Range.first, Range.second) == 1)
{ {
return GetID(Range.first->m_ID); return GetId(Range.first->m_Id);
} }
return UUID_UNKNOWN; return UUID_UNKNOWN;
} }
@ -177,9 +177,9 @@ int CUuidManager::UnpackUuid(CUnpacker *pUnpacker, CUuid *pOut) const
return LookupUuid(*pUuid); return LookupUuid(*pUuid);
} }
void CUuidManager::PackUuid(int ID, CPacker *pPacker) const void CUuidManager::PackUuid(int Id, CPacker *pPacker) const
{ {
CUuid Uuid = GetUuid(ID); CUuid Uuid = GetUuid(Id);
pPacker->AddRaw(&Uuid, sizeof(Uuid)); pPacker->AddRaw(&Uuid, sizeof(Uuid));
} }

View file

@ -40,7 +40,7 @@ struct CName
struct CNameIndexed struct CNameIndexed
{ {
CUuid m_Uuid; CUuid m_Uuid;
int m_ID; int m_Id;
bool operator<(const CNameIndexed &Other) const { return m_Uuid < Other.m_Uuid; } bool operator<(const CNameIndexed &Other) const { return m_Uuid < Other.m_Uuid; }
bool operator==(const CNameIndexed &Other) const { return m_Uuid == Other.m_Uuid; } bool operator==(const CNameIndexed &Other) const { return m_Uuid == Other.m_Uuid; }
@ -55,15 +55,15 @@ class CUuidManager
std::vector<CNameIndexed> m_vNamesSorted; std::vector<CNameIndexed> m_vNamesSorted;
public: public:
void RegisterName(int ID, const char *pName); void RegisterName(int Id, const char *pName);
CUuid GetUuid(int ID) const; CUuid GetUuid(int Id) const;
const char *GetName(int ID) const; const char *GetName(int Id) const;
int LookupUuid(CUuid Uuid) const; int LookupUuid(CUuid Uuid) const;
int NumUuids() const; int NumUuids() const;
int UnpackUuid(CUnpacker *pUnpacker) const; int UnpackUuid(CUnpacker *pUnpacker) const;
int UnpackUuid(CUnpacker *pUnpacker, CUuid *pOut) const; int UnpackUuid(CUnpacker *pUnpacker, CUuid *pOut) const;
void PackUuid(int ID, CPacker *pPacker) const; void PackUuid(int Id, CPacker *pPacker) const;
void DebugDump() const; void DebugDump() const;
}; };

View file

@ -28,7 +28,7 @@ public:
// unused // unused
struct CSampleHandle struct CSampleHandle
{ {
int m_SampleID; int m_SampleId;
}; };
struct CVoiceShapeCircle struct CVoiceShapeCircle
@ -67,13 +67,13 @@ public:
virtual int LoadWV(const char *pFilename, int StorageType = IStorage::TYPE_ALL) = 0; virtual int LoadWV(const char *pFilename, int StorageType = IStorage::TYPE_ALL) = 0;
virtual int LoadOpusFromMem(const void *pData, unsigned DataSize, bool FromEditor = false) = 0; virtual int LoadOpusFromMem(const void *pData, unsigned DataSize, bool FromEditor = false) = 0;
virtual int LoadWVFromMem(const void *pData, unsigned DataSize, bool FromEditor = false) = 0; virtual int LoadWVFromMem(const void *pData, unsigned DataSize, bool FromEditor = false) = 0;
virtual void UnloadSample(int SampleID) = 0; virtual void UnloadSample(int SampleId) = 0;
virtual float GetSampleTotalTime(int SampleID) = 0; // in s virtual float GetSampleTotalTime(int SampleId) = 0; // in s
virtual float GetSampleCurrentTime(int SampleID) = 0; // in s virtual float GetSampleCurrentTime(int SampleId) = 0; // in s
virtual void SetSampleCurrentTime(int SampleID, float Time) = 0; virtual void SetSampleCurrentTime(int SampleId, float Time) = 0;
virtual void SetChannel(int ChannelID, float Volume, float Panning) = 0; virtual void SetChannel(int ChannelId, float Volume, float Panning) = 0;
virtual void SetListenerPos(float x, float y) = 0; virtual void SetListenerPos(float x, float y) = 0;
virtual void SetVoiceVolume(CVoiceHandle Voice, float Volume) = 0; virtual void SetVoiceVolume(CVoiceHandle Voice, float Volume) = 0;
@ -84,13 +84,13 @@ public:
virtual void SetVoiceCircle(CVoiceHandle Voice, float Radius) = 0; virtual void SetVoiceCircle(CVoiceHandle Voice, float Radius) = 0;
virtual void SetVoiceRectangle(CVoiceHandle Voice, float Width, float Height) = 0; virtual void SetVoiceRectangle(CVoiceHandle Voice, float Width, float Height) = 0;
virtual CVoiceHandle PlayAt(int ChannelID, int SampleID, int Flags, float x, float y) = 0; virtual CVoiceHandle PlayAt(int ChannelId, int SampleId, int Flags, float x, float y) = 0;
virtual CVoiceHandle Play(int ChannelID, int SampleID, int Flags) = 0; virtual CVoiceHandle Play(int ChannelId, int SampleId, int Flags) = 0;
virtual void Pause(int SampleID) = 0; virtual void Pause(int SampleId) = 0;
virtual void Stop(int SampleID) = 0; virtual void Stop(int SampleId) = 0;
virtual void StopAll() = 0; virtual void StopAll() = 0;
virtual void StopVoice(CVoiceHandle Voice) = 0; virtual void StopVoice(CVoiceHandle Voice) = 0;
virtual bool IsPlaying(int SampleID) = 0; virtual bool IsPlaying(int SampleId) = 0;
virtual void Mix(short *pFinalOut, unsigned Frames) = 0; virtual void Mix(short *pFinalOut, unsigned Frames) = 0;
// useful for thread synchronization // useful for thread synchronization

View file

@ -8,7 +8,7 @@ class IGraphics *CComponent::Graphics() const { return m_pClient->Graphics(); }
class ITextRender *CComponent::TextRender() const { return m_pClient->TextRender(); } class ITextRender *CComponent::TextRender() const { return m_pClient->TextRender(); }
class IInput *CComponent::Input() const { return m_pClient->Input(); } class IInput *CComponent::Input() const { return m_pClient->Input(); }
class IStorage *CComponent::Storage() const { return m_pClient->Storage(); } class IStorage *CComponent::Storage() const { return m_pClient->Storage(); }
class CUI *CComponent::UI() const { return m_pClient->UI(); } class CUi *CComponent::Ui() const { return m_pClient->Ui(); }
class ISound *CComponent::Sound() const { return m_pClient->Sound(); } class ISound *CComponent::Sound() const { return m_pClient->Sound(); }
class CRenderTools *CComponent::RenderTools() const { return m_pClient->RenderTools(); } class CRenderTools *CComponent::RenderTools() const { return m_pClient->RenderTools(); }
class IConfigManager *CComponent::ConfigManager() const { return m_pClient->ConfigManager(); } class IConfigManager *CComponent::ConfigManager() const { return m_pClient->ConfigManager(); }

View file

@ -49,7 +49,7 @@ protected:
/** /**
* Get the ui interface. * Get the ui interface.
*/ */
class CUI *UI() const; class CUi *Ui() const;
/** /**
* Get the sound interface. * Get the sound interface.
*/ */

View file

@ -49,16 +49,16 @@ CBinds::~CBinds()
free(apKeyBinding[i]); free(apKeyBinding[i]);
} }
void CBinds::Bind(int KeyID, const char *pStr, bool FreeOnly, int ModifierCombination) void CBinds::Bind(int KeyId, const char *pStr, bool FreeOnly, int ModifierCombination)
{ {
if(KeyID < 0 || KeyID >= KEY_LAST) if(KeyId < 0 || KeyId >= KEY_LAST)
return; return;
if(FreeOnly && Get(KeyID, ModifierCombination)[0]) if(FreeOnly && Get(KeyId, ModifierCombination)[0])
return; return;
free(m_aapKeyBindings[ModifierCombination][KeyID]); free(m_aapKeyBindings[ModifierCombination][KeyId]);
m_aapKeyBindings[ModifierCombination][KeyID] = 0; m_aapKeyBindings[ModifierCombination][KeyId] = 0;
// skip modifiers for +xxx binds // skip modifiers for +xxx binds
if(pStr[0] == '+') if(pStr[0] == '+')
@ -67,14 +67,14 @@ void CBinds::Bind(int KeyID, const char *pStr, bool FreeOnly, int ModifierCombin
char aBuf[256]; char aBuf[256];
if(!pStr[0]) if(!pStr[0])
{ {
str_format(aBuf, sizeof(aBuf), "unbound %s%s (%d)", GetKeyBindModifiersName(ModifierCombination), Input()->KeyName(KeyID), KeyID); str_format(aBuf, sizeof(aBuf), "unbound %s%s (%d)", GetKeyBindModifiersName(ModifierCombination), Input()->KeyName(KeyId), KeyId);
} }
else else
{ {
int Size = str_length(pStr) + 1; int Size = str_length(pStr) + 1;
m_aapKeyBindings[ModifierCombination][KeyID] = (char *)malloc(Size); m_aapKeyBindings[ModifierCombination][KeyId] = (char *)malloc(Size);
str_copy(m_aapKeyBindings[ModifierCombination][KeyID], pStr, Size); str_copy(m_aapKeyBindings[ModifierCombination][KeyId], pStr, Size);
str_format(aBuf, sizeof(aBuf), "bound %s%s (%d) = %s", GetKeyBindModifiersName(ModifierCombination), Input()->KeyName(KeyID), KeyID, m_aapKeyBindings[ModifierCombination][KeyID]); str_format(aBuf, sizeof(aBuf), "bound %s%s (%d) = %s", GetKeyBindModifiersName(ModifierCombination), Input()->KeyName(KeyId), KeyId, m_aapKeyBindings[ModifierCombination][KeyId]);
} }
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "binds", aBuf, gs_BindPrintColor); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "binds", aBuf, gs_BindPrintColor);
} }
@ -187,10 +187,10 @@ void CBinds::UnbindAll()
} }
} }
const char *CBinds::Get(int KeyID, int ModifierCombination) const char *CBinds::Get(int KeyId, int ModifierCombination)
{ {
if(KeyID > 0 && KeyID < KEY_LAST && m_aapKeyBindings[ModifierCombination][KeyID]) if(KeyId > 0 && KeyId < KEY_LAST && m_aapKeyBindings[ModifierCombination][KeyId])
return m_aapKeyBindings[ModifierCombination][KeyID]; return m_aapKeyBindings[ModifierCombination][KeyId];
return ""; return "";
} }
@ -283,9 +283,9 @@ void CBinds::ConBind(IConsole::IResult *pResult, void *pUserData)
CBinds *pBinds = (CBinds *)pUserData; CBinds *pBinds = (CBinds *)pUserData;
const char *pBindStr = pResult->GetString(0); const char *pBindStr = pResult->GetString(0);
int Modifier; int Modifier;
int KeyID = pBinds->GetBindSlot(pBindStr, &Modifier); int KeyId = pBinds->GetBindSlot(pBindStr, &Modifier);
if(!KeyID) if(!KeyId)
{ {
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "key %s not found", pBindStr); str_format(aBuf, sizeof(aBuf), "key %s not found", pBindStr);
@ -298,16 +298,16 @@ void CBinds::ConBind(IConsole::IResult *pResult, void *pUserData)
char aBuf[256]; char aBuf[256];
const char *pKeyName = pResult->GetString(0); const char *pKeyName = pResult->GetString(0);
if(!pBinds->m_aapKeyBindings[Modifier][KeyID]) if(!pBinds->m_aapKeyBindings[Modifier][KeyId])
str_format(aBuf, sizeof(aBuf), "%s (%d) is not bound", pKeyName, KeyID); str_format(aBuf, sizeof(aBuf), "%s (%d) is not bound", pKeyName, KeyId);
else else
str_format(aBuf, sizeof(aBuf), "%s (%d) = %s", pKeyName, KeyID, pBinds->m_aapKeyBindings[Modifier][KeyID]); str_format(aBuf, sizeof(aBuf), "%s (%d) = %s", pKeyName, KeyId, pBinds->m_aapKeyBindings[Modifier][KeyId]);
pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf, gs_BindPrintColor); pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf, gs_BindPrintColor);
return; return;
} }
pBinds->Bind(KeyID, pResult->GetString(1), false, Modifier); pBinds->Bind(KeyId, pResult->GetString(1), false, Modifier);
} }
void CBinds::ConBinds(IConsole::IResult *pResult, void *pUserData) void CBinds::ConBinds(IConsole::IResult *pResult, void *pUserData)
@ -319,18 +319,18 @@ void CBinds::ConBinds(IConsole::IResult *pResult, void *pUserData)
const char *pKeyName = pResult->GetString(0); const char *pKeyName = pResult->GetString(0);
int Modifier; int Modifier;
int KeyID = pBinds->GetBindSlot(pKeyName, &Modifier); int KeyId = pBinds->GetBindSlot(pKeyName, &Modifier);
if(!KeyID) if(!KeyId)
{ {
str_format(aBuf, sizeof(aBuf), "key '%s' not found", pKeyName); str_format(aBuf, sizeof(aBuf), "key '%s' not found", pKeyName);
pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf, gs_BindPrintColor); pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf, gs_BindPrintColor);
} }
else else
{ {
if(!pBinds->m_aapKeyBindings[Modifier][KeyID]) if(!pBinds->m_aapKeyBindings[Modifier][KeyId])
str_format(aBuf, sizeof(aBuf), "%s (%d) is not bound", pKeyName, KeyID); str_format(aBuf, sizeof(aBuf), "%s (%d) is not bound", pKeyName, KeyId);
else else
str_format(aBuf, sizeof(aBuf), "%s (%d) = %s", pKeyName, KeyID, pBinds->m_aapKeyBindings[Modifier][KeyID]); str_format(aBuf, sizeof(aBuf), "%s (%d) = %s", pKeyName, KeyId, pBinds->m_aapKeyBindings[Modifier][KeyId]);
pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf, gs_BindPrintColor); pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf, gs_BindPrintColor);
} }
@ -357,9 +357,9 @@ void CBinds::ConUnbind(IConsole::IResult *pResult, void *pUserData)
CBinds *pBinds = (CBinds *)pUserData; CBinds *pBinds = (CBinds *)pUserData;
const char *pKeyName = pResult->GetString(0); const char *pKeyName = pResult->GetString(0);
int Modifier; int Modifier;
int KeyID = pBinds->GetBindSlot(pKeyName, &Modifier); int KeyId = pBinds->GetBindSlot(pKeyName, &Modifier);
if(!KeyID) if(!KeyId)
{ {
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "key %s not found", pKeyName); str_format(aBuf, sizeof(aBuf), "key %s not found", pKeyName);
@ -367,7 +367,7 @@ void CBinds::ConUnbind(IConsole::IResult *pResult, void *pUserData)
return; return;
} }
pBinds->Bind(KeyID, "", false, Modifier); pBinds->Bind(KeyId, "", false, Modifier);
} }
void CBinds::ConUnbindAll(IConsole::IResult *pResult, void *pUserData) void CBinds::ConUnbindAll(IConsole::IResult *pResult, void *pUserData)
@ -376,7 +376,7 @@ void CBinds::ConUnbindAll(IConsole::IResult *pResult, void *pUserData)
pBinds->UnbindAll(); pBinds->UnbindAll();
} }
int CBinds::GetKeyID(const char *pKeyName) int CBinds::GetKeyId(const char *pKeyName)
{ {
// check for numeric // check for numeric
if(pKeyName[0] == '&') if(pKeyName[0] == '&')
@ -420,7 +420,7 @@ int CBinds::GetBindSlot(const char *pBindString, int *pModifierCombination)
else else
break; break;
} }
return GetKeyID(*pModifierCombination == MODIFIER_NONE ? aMod : pKey + 1); return GetKeyId(*pModifierCombination == MODIFIER_NONE ? aMod : pKey + 1);
} }
const char *CBinds::GetModifierName(int Modifier) const char *CBinds::GetModifierName(int Modifier)

View file

@ -12,7 +12,7 @@ class IConfigManager;
class CBinds : public CComponent class CBinds : public CComponent
{ {
int GetKeyID(const char *pKeyName); int GetKeyId(const char *pKeyName);
static void ConBind(IConsole::IResult *pResult, void *pUserData); static void ConBind(IConsole::IResult *pResult, void *pUserData);
static void ConBinds(IConsole::IResult *pResult, void *pUserData); static void ConBinds(IConsole::IResult *pResult, void *pUserData);
@ -50,10 +50,10 @@ public:
CBindsSpecial m_SpecialBinds; CBindsSpecial m_SpecialBinds;
void Bind(int KeyID, const char *pStr, bool FreeOnly = false, int ModifierCombination = MODIFIER_NONE); void Bind(int KeyId, const char *pStr, bool FreeOnly = false, int ModifierCombination = MODIFIER_NONE);
void SetDefaults(); void SetDefaults();
void UnbindAll(); void UnbindAll();
const char *Get(int KeyID, int ModifierCombination); const char *Get(int KeyId, int ModifierCombination);
void GetKey(const char *pBindStr, char *pBuf, size_t BufSize); void GetKey(const char *pBindStr, char *pBuf, size_t BufSize);
int GetBindSlot(const char *pBindString, int *pModifierCombination); int GetBindSlot(const char *pBindString, int *pModifierCombination);
static int GetModifierMask(IInput *pInput); static int GetModifierMask(IInput *pInput);

View file

@ -303,11 +303,11 @@ bool CChat::OnInput(const IInput::CEvent &Event)
{ {
if(PlayerInfo) if(PlayerInfo)
{ {
PlayerName = m_pClient->m_aClients[PlayerInfo->m_ClientID].m_aName; PlayerName = m_pClient->m_aClients[PlayerInfo->m_ClientId].m_aName;
FoundInput = str_utf8_find_nocase(PlayerName, m_aCompletionBuffer); FoundInput = str_utf8_find_nocase(PlayerName, m_aCompletionBuffer);
if(FoundInput != 0) if(FoundInput != 0)
{ {
m_aPlayerCompletionList[m_PlayerCompletionListLength].ClientID = PlayerInfo->m_ClientID; m_aPlayerCompletionList[m_PlayerCompletionListLength].ClientId = PlayerInfo->m_ClientId;
// The score for suggesting a player name is determined by the distance of the search input to the beginning of the player name // The score for suggesting a player name is determined by the distance of the search input to the beginning of the player name
m_aPlayerCompletionList[m_PlayerCompletionListLength].Score = (int)(FoundInput - PlayerName); m_aPlayerCompletionList[m_PlayerCompletionListLength].Score = (int)(FoundInput - PlayerName);
m_PlayerCompletionListLength++; m_PlayerCompletionListLength++;
@ -411,7 +411,7 @@ bool CChat::OnInput(const IInput::CEvent &Event)
m_CompletionChosen %= m_PlayerCompletionListLength; m_CompletionChosen %= m_PlayerCompletionListLength;
m_CompletionUsed = true; m_CompletionUsed = true;
pCompletionClientData = &m_pClient->m_aClients[m_aPlayerCompletionList[m_CompletionChosen].ClientID]; pCompletionClientData = &m_pClient->m_aClients[m_aPlayerCompletionList[m_CompletionChosen].ClientId];
if(!pCompletionClientData->m_Active) if(!pCompletionClientData->m_Active)
{ {
continue; continue;
@ -551,7 +551,7 @@ void CChat::OnMessage(int MsgType, void *pRawMsg)
if(MsgType == NETMSGTYPE_SV_CHAT) if(MsgType == NETMSGTYPE_SV_CHAT)
{ {
CNetMsg_Sv_Chat *pMsg = (CNetMsg_Sv_Chat *)pRawMsg; CNetMsg_Sv_Chat *pMsg = (CNetMsg_Sv_Chat *)pRawMsg;
AddLine(pMsg->m_ClientID, pMsg->m_Team, pMsg->m_pMessage); AddLine(pMsg->m_ClientId, pMsg->m_Team, pMsg->m_pMessage);
} }
else if(MsgType == NETMSGTYPE_SV_COMMANDINFO) else if(MsgType == NETMSGTYPE_SV_COMMANDINFO)
{ {
@ -644,14 +644,14 @@ void CChat::StoreSave(const char *pText)
io_close(File); io_close(File);
} }
void CChat::AddLine(int ClientID, int Team, const char *pLine) void CChat::AddLine(int ClientId, int Team, const char *pLine)
{ {
if(*pLine == 0 || if(*pLine == 0 ||
(ClientID == SERVER_MSG && !g_Config.m_ClShowChatSystem) || (ClientId == SERVER_MSG && !g_Config.m_ClShowChatSystem) ||
(ClientID >= 0 && (m_pClient->m_aClients[ClientID].m_aName[0] == '\0' || // unknown client (ClientId >= 0 && (m_pClient->m_aClients[ClientId].m_aName[0] == '\0' || // unknown client
m_pClient->m_aClients[ClientID].m_ChatIgnore || m_pClient->m_aClients[ClientId].m_ChatIgnore ||
(m_pClient->m_Snap.m_LocalClientID != ClientID && g_Config.m_ClShowChatFriends && !m_pClient->m_aClients[ClientID].m_Friend) || (m_pClient->m_Snap.m_LocalClientId != ClientId && g_Config.m_ClShowChatFriends && !m_pClient->m_aClients[ClientId].m_Friend) ||
(m_pClient->m_Snap.m_LocalClientID != ClientID && m_pClient->m_aClients[ClientID].m_Foe)))) (m_pClient->m_Snap.m_LocalClientId != ClientId && m_pClient->m_aClients[ClientId].m_Foe))))
return; return;
// trim right and set maximum length to 256 utf8-characters // trim right and set maximum length to 256 utf8-characters
@ -688,14 +688,14 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
return; return;
auto &&FChatMsgCheckAndPrint = [this](CLine *pLine_) { auto &&FChatMsgCheckAndPrint = [this](CLine *pLine_) {
if(pLine_->m_ClientID < 0) // server or client message if(pLine_->m_ClientId < 0) // server or client message
{ {
if(Client()->State() != IClient::STATE_DEMOPLAYBACK) if(Client()->State() != IClient::STATE_DEMOPLAYBACK)
StoreSave(pLine_->m_aText); StoreSave(pLine_->m_aText);
} }
char aBuf[1024]; char aBuf[1024];
str_format(aBuf, sizeof(aBuf), "%s%s%s", pLine_->m_aName, pLine_->m_ClientID >= 0 ? ": " : "", pLine_->m_aText); str_format(aBuf, sizeof(aBuf), "%s%s%s", pLine_->m_aName, pLine_->m_ClientId >= 0 ? ": " : "", pLine_->m_aText);
ColorRGBA ChatLogColor{1, 1, 1, 1}; ColorRGBA ChatLogColor{1, 1, 1, 1};
if(pLine_->m_Highlighted) if(pLine_->m_Highlighted)
@ -708,9 +708,9 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageFriendColor)); ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageFriendColor));
else if(pLine_->m_Team) else if(pLine_->m_Team)
ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageTeamColor)); ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageTeamColor));
else if(pLine_->m_ClientID == SERVER_MSG) else if(pLine_->m_ClientId == SERVER_MSG)
ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageSystemColor)); ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageSystemColor));
else if(pLine_->m_ClientID == CLIENT_MSG) else if(pLine_->m_ClientId == CLIENT_MSG)
ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageClientColor)); ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageClientColor));
else // regular message else // regular message
ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageColor)); ChatLogColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageColor));
@ -739,7 +739,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
// 0 = global; 1 = team; 2 = sending whisper; 3 = receiving whisper // 0 = global; 1 = team; 2 = sending whisper; 3 = receiving whisper
// If it's a client message, m_aText will have ": " prepended so we have to work around it. // If it's a client message, m_aText will have ": " prepended so we have to work around it.
if(pCurrentLine->m_TeamNumber == Team && pCurrentLine->m_ClientID == ClientID && str_comp(pCurrentLine->m_aText, pLine) == 0) if(pCurrentLine->m_TeamNumber == Team && pCurrentLine->m_ClientId == ClientId && str_comp(pCurrentLine->m_aText, pLine) == 0)
{ {
pCurrentLine->m_TimesRepeated++; pCurrentLine->m_TimesRepeated++;
TextRender()->DeleteTextContainer(pCurrentLine->m_TextContainerIndex); TextRender()->DeleteTextContainer(pCurrentLine->m_TextContainerIndex);
@ -759,7 +759,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
pCurrentLine->m_Time = time(); pCurrentLine->m_Time = time();
pCurrentLine->m_aYOffset[0] = -1.0f; pCurrentLine->m_aYOffset[0] = -1.0f;
pCurrentLine->m_aYOffset[1] = -1.0f; pCurrentLine->m_aYOffset[1] = -1.0f;
pCurrentLine->m_ClientID = ClientID; pCurrentLine->m_ClientId = ClientId;
pCurrentLine->m_TeamNumber = Team; pCurrentLine->m_TeamNumber = Team;
pCurrentLine->m_Team = Team == 1; pCurrentLine->m_Team = Team == 1;
pCurrentLine->m_Whisper = Team >= 2; pCurrentLine->m_Whisper = Team >= 2;
@ -771,86 +771,86 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
// check for highlighted name // check for highlighted name
if(Client()->State() != IClient::STATE_DEMOPLAYBACK) if(Client()->State() != IClient::STATE_DEMOPLAYBACK)
{ {
if(ClientID >= 0 && ClientID != m_pClient->m_aLocalIDs[0] && (!m_pClient->Client()->DummyConnected() || ClientID != m_pClient->m_aLocalIDs[1])) if(ClientId >= 0 && ClientId != m_pClient->m_aLocalIds[0] && (!m_pClient->Client()->DummyConnected() || ClientId != m_pClient->m_aLocalIds[1]))
{ {
// main character // main character
Highlighted |= LineShouldHighlight(pLine, m_pClient->m_aClients[m_pClient->m_aLocalIDs[0]].m_aName); Highlighted |= LineShouldHighlight(pLine, m_pClient->m_aClients[m_pClient->m_aLocalIds[0]].m_aName);
// dummy // dummy
Highlighted |= m_pClient->Client()->DummyConnected() && LineShouldHighlight(pLine, m_pClient->m_aClients[m_pClient->m_aLocalIDs[1]].m_aName); Highlighted |= m_pClient->Client()->DummyConnected() && LineShouldHighlight(pLine, m_pClient->m_aClients[m_pClient->m_aLocalIds[1]].m_aName);
} }
} }
else else
{ {
// on demo playback use local id from snap directly, // on demo playback use local id from snap directly,
// since m_aLocalIDs isn't valid there // since m_aLocalIds isn't valid there
Highlighted |= m_pClient->m_Snap.m_LocalClientID >= 0 && LineShouldHighlight(pLine, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aName); Highlighted |= m_pClient->m_Snap.m_LocalClientId >= 0 && LineShouldHighlight(pLine, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientId].m_aName);
} }
pCurrentLine->m_Highlighted = Highlighted; pCurrentLine->m_Highlighted = Highlighted;
if(pCurrentLine->m_ClientID == SERVER_MSG) if(pCurrentLine->m_ClientId == SERVER_MSG)
{ {
str_copy(pCurrentLine->m_aName, "*** "); str_copy(pCurrentLine->m_aName, "*** ");
str_copy(pCurrentLine->m_aText, pLine); str_copy(pCurrentLine->m_aText, pLine);
} }
else if(pCurrentLine->m_ClientID == CLIENT_MSG) else if(pCurrentLine->m_ClientId == CLIENT_MSG)
{ {
str_copy(pCurrentLine->m_aName, ""); str_copy(pCurrentLine->m_aName, "");
str_copy(pCurrentLine->m_aText, pLine); str_copy(pCurrentLine->m_aText, pLine);
} }
else else
{ {
if(m_pClient->m_aClients[ClientID].m_Team == TEAM_SPECTATORS) if(m_pClient->m_aClients[ClientId].m_Team == TEAM_SPECTATORS)
pCurrentLine->m_NameColor = TEAM_SPECTATORS; pCurrentLine->m_NameColor = TEAM_SPECTATORS;
if(m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_TEAMS) if(m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_TEAMS)
{ {
if(m_pClient->m_aClients[ClientID].m_Team == TEAM_RED) if(m_pClient->m_aClients[ClientId].m_Team == TEAM_RED)
pCurrentLine->m_NameColor = TEAM_RED; pCurrentLine->m_NameColor = TEAM_RED;
else if(m_pClient->m_aClients[ClientID].m_Team == TEAM_BLUE) else if(m_pClient->m_aClients[ClientId].m_Team == TEAM_BLUE)
pCurrentLine->m_NameColor = TEAM_BLUE; pCurrentLine->m_NameColor = TEAM_BLUE;
} }
if(Team == 2) // whisper send if(Team == 2) // whisper send
{ {
str_format(pCurrentLine->m_aName, sizeof(pCurrentLine->m_aName), "→ %s", m_pClient->m_aClients[ClientID].m_aName); str_format(pCurrentLine->m_aName, sizeof(pCurrentLine->m_aName), "→ %s", m_pClient->m_aClients[ClientId].m_aName);
pCurrentLine->m_NameColor = TEAM_BLUE; pCurrentLine->m_NameColor = TEAM_BLUE;
pCurrentLine->m_Highlighted = false; pCurrentLine->m_Highlighted = false;
Highlighted = false; Highlighted = false;
} }
else if(Team == 3) // whisper recv else if(Team == 3) // whisper recv
{ {
str_format(pCurrentLine->m_aName, sizeof(pCurrentLine->m_aName), "← %s", m_pClient->m_aClients[ClientID].m_aName); str_format(pCurrentLine->m_aName, sizeof(pCurrentLine->m_aName), "← %s", m_pClient->m_aClients[ClientId].m_aName);
pCurrentLine->m_NameColor = TEAM_RED; pCurrentLine->m_NameColor = TEAM_RED;
pCurrentLine->m_Highlighted = true; pCurrentLine->m_Highlighted = true;
Highlighted = true; Highlighted = true;
} }
else else
str_copy(pCurrentLine->m_aName, m_pClient->m_aClients[ClientID].m_aName); str_copy(pCurrentLine->m_aName, m_pClient->m_aClients[ClientId].m_aName);
str_copy(pCurrentLine->m_aText, pLine); str_copy(pCurrentLine->m_aText, pLine);
pCurrentLine->m_Friend = m_pClient->m_aClients[ClientID].m_Friend; pCurrentLine->m_Friend = m_pClient->m_aClients[ClientId].m_Friend;
} }
pCurrentLine->m_HasRenderTee = false; pCurrentLine->m_HasRenderTee = false;
pCurrentLine->m_Friend = ClientID >= 0 ? m_pClient->m_aClients[ClientID].m_Friend : false; pCurrentLine->m_Friend = ClientId >= 0 ? m_pClient->m_aClients[ClientId].m_Friend : false;
if(pCurrentLine->m_ClientID >= 0 && pCurrentLine->m_aName[0] != '\0') if(pCurrentLine->m_ClientId >= 0 && pCurrentLine->m_aName[0] != '\0')
{ {
if(!g_Config.m_ClChatOld) if(!g_Config.m_ClChatOld)
{ {
pCurrentLine->m_CustomColoredSkin = m_pClient->m_aClients[pCurrentLine->m_ClientID].m_RenderInfo.m_CustomColoredSkin; pCurrentLine->m_CustomColoredSkin = m_pClient->m_aClients[pCurrentLine->m_ClientId].m_RenderInfo.m_CustomColoredSkin;
if(pCurrentLine->m_CustomColoredSkin) if(pCurrentLine->m_CustomColoredSkin)
pCurrentLine->m_RenderSkin = m_pClient->m_aClients[pCurrentLine->m_ClientID].m_RenderInfo.m_ColorableRenderSkin; pCurrentLine->m_RenderSkin = m_pClient->m_aClients[pCurrentLine->m_ClientId].m_RenderInfo.m_ColorableRenderSkin;
else else
pCurrentLine->m_RenderSkin = m_pClient->m_aClients[pCurrentLine->m_ClientID].m_RenderInfo.m_OriginalRenderSkin; pCurrentLine->m_RenderSkin = m_pClient->m_aClients[pCurrentLine->m_ClientId].m_RenderInfo.m_OriginalRenderSkin;
str_copy(pCurrentLine->m_aSkinName, m_pClient->m_aClients[pCurrentLine->m_ClientID].m_aSkinName); str_copy(pCurrentLine->m_aSkinName, m_pClient->m_aClients[pCurrentLine->m_ClientId].m_aSkinName);
pCurrentLine->m_ColorBody = m_pClient->m_aClients[pCurrentLine->m_ClientID].m_RenderInfo.m_ColorBody; pCurrentLine->m_ColorBody = m_pClient->m_aClients[pCurrentLine->m_ClientId].m_RenderInfo.m_ColorBody;
pCurrentLine->m_ColorFeet = m_pClient->m_aClients[pCurrentLine->m_ClientID].m_RenderInfo.m_ColorFeet; pCurrentLine->m_ColorFeet = m_pClient->m_aClients[pCurrentLine->m_ClientId].m_RenderInfo.m_ColorFeet;
pCurrentLine->m_RenderSkinMetrics = m_pClient->m_aClients[pCurrentLine->m_ClientID].m_RenderInfo.m_SkinMetrics; pCurrentLine->m_RenderSkinMetrics = m_pClient->m_aClients[pCurrentLine->m_ClientId].m_RenderInfo.m_SkinMetrics;
pCurrentLine->m_HasRenderTee = true; pCurrentLine->m_HasRenderTee = true;
} }
} }
@ -860,7 +860,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
// play sound // play sound
int64_t Now = time(); int64_t Now = time();
if(ClientID == SERVER_MSG) if(ClientId == SERVER_MSG)
{ {
if(Now - m_aLastSoundPlayed[CHAT_SERVER] >= time_freq() * 3 / 10) if(Now - m_aLastSoundPlayed[CHAT_SERVER] >= time_freq() * 3 / 10)
{ {
@ -871,7 +871,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine)
} }
} }
} }
else if(ClientID == CLIENT_MSG) else if(ClientId == CLIENT_MSG)
{ {
// No sound yet // No sound yet
} }
@ -982,24 +982,24 @@ void CChat::OnPrepareLines(float y)
char aName[64 + 12] = ""; char aName[64 + 12] = "";
if(g_Config.m_ClShowIDs && Line.m_ClientID >= 0 && Line.m_aName[0] != '\0') if(g_Config.m_ClShowIds && Line.m_ClientId >= 0 && Line.m_aName[0] != '\0')
{ {
if(Line.m_ClientID < 10) if(Line.m_ClientId < 10)
str_format(aName, sizeof(aName), "%d: ", Line.m_ClientID); str_format(aName, sizeof(aName), "%d: ", Line.m_ClientId);
else else
str_format(aName, sizeof(aName), "%d: ", Line.m_ClientID); str_format(aName, sizeof(aName), "%d: ", Line.m_ClientId);
} }
str_append(aName, Line.m_aName); str_append(aName, Line.m_aName);
char aCount[12]; char aCount[12];
if(Line.m_ClientID < 0) if(Line.m_ClientId < 0)
str_format(aCount, sizeof(aCount), "[%d] ", Line.m_TimesRepeated + 1); str_format(aCount, sizeof(aCount), "[%d] ", Line.m_TimesRepeated + 1);
else else
str_format(aCount, sizeof(aCount), " [%d]", Line.m_TimesRepeated + 1); str_format(aCount, sizeof(aCount), " [%d]", Line.m_TimesRepeated + 1);
const char *pText = Line.m_aText; const char *pText = Line.m_aText;
if(Config()->m_ClStreamerMode && Line.m_ClientID == SERVER_MSG) if(Config()->m_ClStreamerMode && Line.m_ClientId == SERVER_MSG)
{ {
if(str_startswith(Line.m_aText, "Team save in progress. You'll be able to load with '/load") && str_endswith(Line.m_aText, "if it fails")) if(str_startswith(Line.m_aText, "Team save in progress. You'll be able to load with '/load") && str_endswith(Line.m_aText, "if it fails"))
{ {
@ -1022,7 +1022,7 @@ void CChat::OnPrepareLines(float y)
TextRender()->SetCursor(&Cursor, TextBegin, 0.0f, FontSize, 0); TextRender()->SetCursor(&Cursor, TextBegin, 0.0f, FontSize, 0);
Cursor.m_LineWidth = LineWidth; Cursor.m_LineWidth = LineWidth;
if(Line.m_ClientID >= 0 && Line.m_aName[0] != '\0') if(Line.m_ClientId >= 0 && Line.m_aName[0] != '\0')
{ {
Cursor.m_X += RealMsgPaddingTee; Cursor.m_X += RealMsgPaddingTee;
@ -1036,7 +1036,7 @@ void CChat::OnPrepareLines(float y)
if(Line.m_TimesRepeated > 0) if(Line.m_TimesRepeated > 0)
TextRender()->TextEx(&Cursor, aCount); TextRender()->TextEx(&Cursor, aCount);
if(Line.m_ClientID >= 0 && Line.m_aName[0] != '\0') if(Line.m_ClientId >= 0 && Line.m_aName[0] != '\0')
{ {
TextRender()->TextEx(&Cursor, ": "); TextRender()->TextEx(&Cursor, ": ");
} }
@ -1071,7 +1071,7 @@ void CChat::OnPrepareLines(float y)
Cursor.m_LineWidth = LineWidth; Cursor.m_LineWidth = LineWidth;
// Message is from valid player // Message is from valid player
if(Line.m_ClientID >= 0 && Line.m_aName[0] != '\0') if(Line.m_ClientId >= 0 && Line.m_aName[0] != '\0')
{ {
Cursor.m_X += RealMsgPaddingTee; Cursor.m_X += RealMsgPaddingTee;
@ -1084,9 +1084,9 @@ void CChat::OnPrepareLines(float y)
// render name // render name
ColorRGBA NameColor; ColorRGBA NameColor;
if(Line.m_ClientID == SERVER_MSG) if(Line.m_ClientId == SERVER_MSG)
NameColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageSystemColor)); NameColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageSystemColor));
else if(Line.m_ClientID == CLIENT_MSG) else if(Line.m_ClientId == CLIENT_MSG)
NameColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageClientColor)); NameColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageClientColor));
else if(Line.m_Team) else if(Line.m_Team)
NameColor = CalculateNameColor(ColorHSLA(g_Config.m_ClMessageTeamColor)); NameColor = CalculateNameColor(ColorHSLA(g_Config.m_ClMessageTeamColor));
@ -1096,8 +1096,8 @@ void CChat::OnPrepareLines(float y)
NameColor = ColorRGBA(0.7f, 0.7f, 1.0f, 1.f); NameColor = ColorRGBA(0.7f, 0.7f, 1.0f, 1.f);
else if(Line.m_NameColor == TEAM_SPECTATORS) else if(Line.m_NameColor == TEAM_SPECTATORS)
NameColor = ColorRGBA(0.75f, 0.5f, 0.75f, 1.f); NameColor = ColorRGBA(0.75f, 0.5f, 0.75f, 1.f);
else if(Line.m_ClientID >= 0 && g_Config.m_ClChatTeamColors && m_pClient->m_Teams.Team(Line.m_ClientID)) else if(Line.m_ClientId >= 0 && g_Config.m_ClChatTeamColors && m_pClient->m_Teams.Team(Line.m_ClientId))
NameColor = m_pClient->GetDDTeamColor(m_pClient->m_Teams.Team(Line.m_ClientID), 0.75f); NameColor = m_pClient->GetDDTeamColor(m_pClient->m_Teams.Team(Line.m_ClientId), 0.75f);
else else
NameColor = ColorRGBA(0.8f, 0.8f, 0.8f, 1.f); NameColor = ColorRGBA(0.8f, 0.8f, 0.8f, 1.f);
@ -1110,7 +1110,7 @@ void CChat::OnPrepareLines(float y)
TextRender()->CreateOrAppendTextContainer(Line.m_TextContainerIndex, &Cursor, aCount); TextRender()->CreateOrAppendTextContainer(Line.m_TextContainerIndex, &Cursor, aCount);
} }
if(Line.m_ClientID >= 0 && Line.m_aName[0] != '\0') if(Line.m_ClientId >= 0 && Line.m_aName[0] != '\0')
{ {
TextRender()->TextColor(NameColor); TextRender()->TextColor(NameColor);
TextRender()->CreateOrAppendTextContainer(Line.m_TextContainerIndex, &Cursor, ": "); TextRender()->CreateOrAppendTextContainer(Line.m_TextContainerIndex, &Cursor, ": ");
@ -1118,9 +1118,9 @@ void CChat::OnPrepareLines(float y)
// render line // render line
ColorRGBA Color; ColorRGBA Color;
if(Line.m_ClientID == SERVER_MSG) if(Line.m_ClientId == SERVER_MSG)
Color = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageSystemColor)); Color = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageSystemColor));
else if(Line.m_ClientID == CLIENT_MSG) else if(Line.m_ClientId == CLIENT_MSG)
Color = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageClientColor)); Color = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageClientColor));
else if(Line.m_Highlighted) else if(Line.m_Highlighted)
Color = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageHighlightColor)); Color = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageHighlightColor));
@ -1229,7 +1229,7 @@ void CChat::OnRender()
else if(CaretPositionY + Cursor.m_FontSize > ClippingRect.y + ClippingRect.h) else if(CaretPositionY + Cursor.m_FontSize > ClippingRect.y + ClippingRect.h)
ScrollOffsetChange += CaretPositionY + Cursor.m_FontSize - (ClippingRect.y + ClippingRect.h); ScrollOffsetChange += CaretPositionY + Cursor.m_FontSize - (ClippingRect.y + ClippingRect.h);
UI()->DoSmoothScrollLogic(&ScrollOffset, &ScrollOffsetChange, ClippingRect.h, BoundingBox.m_H); Ui()->DoSmoothScrollLogic(&ScrollOffset, &ScrollOffsetChange, ClippingRect.h, BoundingBox.m_H);
m_Input.SetScrollOffset(ScrollOffset); m_Input.SetScrollOffset(ScrollOffset);
m_Input.SetScrollOffsetChange(ScrollOffsetChange); m_Input.SetScrollOffsetChange(ScrollOffsetChange);

View file

@ -30,7 +30,7 @@ class CChat : public CComponent
{ {
int64_t m_Time; int64_t m_Time;
float m_aYOffset[2]; float m_aYOffset[2];
int m_ClientID; int m_ClientId;
int m_TeamNumber; int m_TeamNumber;
bool m_Team; bool m_Team;
bool m_Whisper; bool m_Whisper;
@ -88,7 +88,7 @@ class CChat : public CComponent
static char ms_aDisplayText[MAX_LINE_LENGTH]; static char ms_aDisplayText[MAX_LINE_LENGTH];
struct CRateablePlayer struct CRateablePlayer
{ {
int ClientID; int ClientId;
int Score; int Score;
}; };
CRateablePlayer m_aPlayerCompletionList[MAX_CLIENTS]; CRateablePlayer m_aPlayerCompletionList[MAX_CLIENTS];
@ -152,7 +152,7 @@ public:
static constexpr float MESSAGE_TEE_PADDING_RIGHT = 0.5f; static constexpr float MESSAGE_TEE_PADDING_RIGHT = 0.5f;
bool IsActive() const { return m_Mode != MODE_NONE; } bool IsActive() const { return m_Mode != MODE_NONE; }
void AddLine(int ClientID, int Team, const char *pLine); void AddLine(int ClientId, int Team, const char *pLine);
void EnableMode(int Team); void EnableMode(int Team);
void DisableMode(); void DisableMode();
void Say(int Team, const char *pLine); void Say(int Team, const char *pLine);

View file

@ -238,7 +238,7 @@ void CGameConsole::CInstance::PumpBacklogPending()
m_BacklogPending.Init(); m_BacklogPending.Init();
} }
m_pGameConsole->UI()->MapScreen(); m_pGameConsole->Ui()->MapScreen();
for(CInstance::CBacklogEntry *pEntry : vpEntries) for(CInstance::CBacklogEntry *pEntry : vpEntries)
{ {
UpdateEntryTextAttributes(pEntry); UpdateEntryTextAttributes(pEntry);
@ -639,7 +639,7 @@ void CGameConsole::CInstance::UpdateEntryTextAttributes(CBacklogEntry *pEntry) c
{ {
CTextCursor Cursor; CTextCursor Cursor;
m_pGameConsole->TextRender()->SetCursor(&Cursor, 0.0f, 0.0f, FONT_SIZE, 0); m_pGameConsole->TextRender()->SetCursor(&Cursor, 0.0f, 0.0f, FONT_SIZE, 0);
Cursor.m_LineWidth = m_pGameConsole->UI()->Screen()->w - 10; Cursor.m_LineWidth = m_pGameConsole->Ui()->Screen()->w - 10;
Cursor.m_MaxLines = 10; Cursor.m_MaxLines = 10;
Cursor.m_LineSpacing = LINE_SPACING; Cursor.m_LineSpacing = LINE_SPACING;
m_pGameConsole->TextRender()->TextEx(&Cursor, pEntry->m_aText, -1); m_pGameConsole->TextRender()->TextEx(&Cursor, pEntry->m_aText, -1);
@ -679,8 +679,8 @@ void CGameConsole::CInstance::UpdateSearch()
m_HasSelection = false; m_HasSelection = false;
} }
ITextRender *pTextRender = m_pGameConsole->UI()->TextRender(); ITextRender *pTextRender = m_pGameConsole->Ui()->TextRender();
const int LineWidth = m_pGameConsole->UI()->Screen()->w - 10.0f; const int LineWidth = m_pGameConsole->Ui()->Screen()->w - 10.0f;
CBacklogEntry *pEntry = m_Backlog.Last(); CBacklogEntry *pEntry = m_Backlog.Last();
int EntryLine = 0, LineToScrollStart = 0, LineToScrollEnd = 0; int EntryLine = 0, LineToScrollStart = 0, LineToScrollEnd = 0;
@ -881,7 +881,7 @@ void CGameConsole::Prompt(char (&aPrompt)[32])
void CGameConsole::OnRender() void CGameConsole::OnRender()
{ {
CUIRect Screen = *UI()->Screen(); CUIRect Screen = *Ui()->Screen();
CInstance *pConsole = CurrentConsole(); CInstance *pConsole = CurrentConsole();
const float MaxConsoleHeight = Screen.h * 3 / 5.0f; const float MaxConsoleHeight = Screen.h * 3 / 5.0f;
@ -923,7 +923,7 @@ void CGameConsole::OnRender()
const float ConsoleHeight = ConsoleHeightScale * MaxConsoleHeight; const float ConsoleHeight = ConsoleHeightScale * MaxConsoleHeight;
UI()->MapScreen(); Ui()->MapScreen();
// do console shadow // do console shadow
Graphics()->TextureClear(); Graphics()->TextureClear();
@ -1098,7 +1098,7 @@ void CGameConsole::OnRender()
} }
} }
UI()->DoSmoothScrollLogic(&pConsole->m_CompletionRenderOffset, &pConsole->m_CompletionRenderOffsetChange, Info.m_Width, Info.m_TotalWidth); Ui()->DoSmoothScrollLogic(&pConsole->m_CompletionRenderOffset, &pConsole->m_CompletionRenderOffsetChange, Info.m_Width, Info.m_TotalWidth);
} }
else if(pConsole->m_Searching && !pConsole->m_Input.IsEmpty()) else if(pConsole->m_Searching && !pConsole->m_Input.IsEmpty())
{ // Render current match and match count { // Render current match and match count
@ -1281,7 +1281,7 @@ void CGameConsole::OnRender()
if(m_ConsoleType == CONSOLETYPE_REMOTE && Client()->ReceivingRconCommands()) if(m_ConsoleType == CONSOLETYPE_REMOTE && Client()->ReceivingRconCommands())
{ {
UI()->RenderProgressSpinner(vec2(Screen.w / 4.0f + FONT_SIZE / 2.f, FONT_SIZE), FONT_SIZE / 2.f); Ui()->RenderProgressSpinner(vec2(Screen.w / 4.0f + FONT_SIZE / 2.f, FONT_SIZE), FONT_SIZE / 2.f);
TextRender()->Text(Screen.w / 4.0f + FONT_SIZE + 2.0f, FONT_SIZE / 2.f, FONT_SIZE, Localize("Loading commands…")); TextRender()->Text(Screen.w / 4.0f + FONT_SIZE + 2.0f, FONT_SIZE / 2.f, FONT_SIZE, Localize("Loading commands…"));
} }
@ -1336,13 +1336,13 @@ void CGameConsole::Toggle(int Type)
if(m_ConsoleState == CONSOLE_CLOSED || m_ConsoleState == CONSOLE_CLOSING) if(m_ConsoleState == CONSOLE_CLOSED || m_ConsoleState == CONSOLE_CLOSING)
{ {
UI()->SetEnabled(false); Ui()->SetEnabled(false);
m_ConsoleState = CONSOLE_OPENING; m_ConsoleState = CONSOLE_OPENING;
} }
else else
{ {
Input()->MouseModeRelative(); Input()->MouseModeRelative();
UI()->SetEnabled(true); Ui()->SetEnabled(true);
m_pClient->OnRelease(); m_pClient->OnRelease();
m_ConsoleState = CONSOLE_CLOSING; m_ConsoleState = CONSOLE_CLOSING;
} }

View file

@ -427,7 +427,7 @@ bool CControls::OnCursorMove(float x, float y, IInput::ECursorType CursorType)
} }
} }
if(m_pClient->m_Snap.m_SpecInfo.m_Active && m_pClient->m_Snap.m_SpecInfo.m_SpectatorID < 0) if(m_pClient->m_Snap.m_SpecInfo.m_Active && m_pClient->m_Snap.m_SpecInfo.m_SpectatorId < 0)
Factor *= m_pClient->m_Camera.m_Zoom; Factor *= m_pClient->m_Camera.m_Zoom;
m_aMousePos[g_Config.m_ClDummy] += vec2(x, y) * Factor; m_aMousePos[g_Config.m_ClDummy] += vec2(x, y) * Factor;
@ -437,7 +437,7 @@ bool CControls::OnCursorMove(float x, float y, IInput::ECursorType CursorType)
void CControls::ClampMousePos() void CControls::ClampMousePos()
{ {
if(m_pClient->m_Snap.m_SpecInfo.m_Active && m_pClient->m_Snap.m_SpecInfo.m_SpectatorID < 0) if(m_pClient->m_Snap.m_SpecInfo.m_Active && m_pClient->m_Snap.m_SpecInfo.m_SpectatorId < 0)
{ {
m_aMousePos[g_Config.m_ClDummy].x = clamp(m_aMousePos[g_Config.m_ClDummy].x, -201.0f * 32, (Collision()->GetWidth() + 201.0f) * 32.0f); m_aMousePos[g_Config.m_ClDummy].x = clamp(m_aMousePos[g_Config.m_ClDummy].x, -201.0f * 32, (Collision()->GetWidth() + 201.0f) * 32.0f);
m_aMousePos[g_Config.m_ClDummy].y = clamp(m_aMousePos[g_Config.m_ClDummy].y, -201.0f * 32, (Collision()->GetHeight() + 201.0f) * 32.0f); m_aMousePos[g_Config.m_ClDummy].y = clamp(m_aMousePos[g_Config.m_ClDummy].y, -201.0f * 32, (Collision()->GetHeight() + 201.0f) * 32.0f);

View file

@ -33,7 +33,7 @@ void CDebugHud::RenderNetCorrections()
const float VelspeedX = m_pClient->m_Snap.m_pLocalCharacter->m_VelX / 256.0f * Client()->GameTickSpeed(); const float VelspeedX = m_pClient->m_Snap.m_pLocalCharacter->m_VelX / 256.0f * Client()->GameTickSpeed();
const float VelspeedY = m_pClient->m_Snap.m_pLocalCharacter->m_VelY / 256.0f * Client()->GameTickSpeed(); const float VelspeedY = m_pClient->m_Snap.m_pLocalCharacter->m_VelY / 256.0f * Client()->GameTickSpeed();
const float Ramp = VelocityRamp(Velspeed, m_pClient->m_aTuning[g_Config.m_ClDummy].m_VelrampStart, m_pClient->m_aTuning[g_Config.m_ClDummy].m_VelrampRange, m_pClient->m_aTuning[g_Config.m_ClDummy].m_VelrampCurvature); const float Ramp = VelocityRamp(Velspeed, m_pClient->m_aTuning[g_Config.m_ClDummy].m_VelrampStart, m_pClient->m_aTuning[g_Config.m_ClDummy].m_VelrampRange, m_pClient->m_aTuning[g_Config.m_ClDummy].m_VelrampCurvature);
const CCharacter *pCharacter = m_pClient->m_GameWorld.GetCharacterByID(m_pClient->m_Snap.m_LocalClientID); const CCharacter *pCharacter = m_pClient->m_GameWorld.GetCharacterById(m_pClient->m_Snap.m_LocalClientId);
const float FontSize = 5.0f; const float FontSize = 5.0f;
const float LineHeight = FontSize + 1.0f; const float LineHeight = FontSize + 1.0f;
@ -92,7 +92,7 @@ void CDebugHud::RenderTuning()
if(g_Config.m_DbgTuning == DBG_TUNING_OFF) if(g_Config.m_DbgTuning == DBG_TUNING_OFF)
return; return;
const CCharacter *pCharacter = m_pClient->m_GameWorld.GetCharacterByID(m_pClient->m_Snap.m_LocalClientID); const CCharacter *pCharacter = m_pClient->m_GameWorld.GetCharacterById(m_pClient->m_Snap.m_LocalClientId);
const CTuningParams StandardTuning; const CTuningParams StandardTuning;
const CTuningParams *pGlobalTuning = m_pClient->GetTuning(0); const CTuningParams *pGlobalTuning = m_pClient->GetTuning(0);

View file

@ -190,11 +190,11 @@ void CEffects::PlayerSpawn(vec2 Pos, float Alpha)
m_pClient->m_Sounds.PlayAt(CSounds::CHN_WORLD, SOUND_PLAYER_SPAWN, 1.0f, Pos); m_pClient->m_Sounds.PlayAt(CSounds::CHN_WORLD, SOUND_PLAYER_SPAWN, 1.0f, Pos);
} }
void CEffects::PlayerDeath(vec2 Pos, int ClientID, float Alpha) void CEffects::PlayerDeath(vec2 Pos, int ClientId, float Alpha)
{ {
ColorRGBA BloodColor(1.0f, 1.0f, 1.0f); ColorRGBA BloodColor(1.0f, 1.0f, 1.0f);
if(ClientID >= 0) if(ClientId >= 0)
{ {
// Use m_RenderInfo.m_CustomColoredSkin instead of m_UseCustomColor // Use m_RenderInfo.m_CustomColoredSkin instead of m_UseCustomColor
// m_UseCustomColor says if the player's skin has a custom color (value sent from the client side) // m_UseCustomColor says if the player's skin has a custom color (value sent from the client side)
@ -202,11 +202,11 @@ void CEffects::PlayerDeath(vec2 Pos, int ClientID, float Alpha)
// m_RenderInfo.m_CustomColoredSkin Defines if in the context of the game the color is being customized, // m_RenderInfo.m_CustomColoredSkin Defines if in the context of the game the color is being customized,
// Using this value if the game is teams (red and blue), this value will be true even if the skin is with the normal color. // Using this value if the game is teams (red and blue), this value will be true even if the skin is with the normal color.
// And will use the team body color to create player death effect instead of tee color // And will use the team body color to create player death effect instead of tee color
if(m_pClient->m_aClients[ClientID].m_RenderInfo.m_CustomColoredSkin) if(m_pClient->m_aClients[ClientId].m_RenderInfo.m_CustomColoredSkin)
BloodColor = m_pClient->m_aClients[ClientID].m_RenderInfo.m_ColorBody; BloodColor = m_pClient->m_aClients[ClientId].m_RenderInfo.m_ColorBody;
else else
{ {
BloodColor = m_pClient->m_aClients[ClientID].m_RenderInfo.m_BloodColor; BloodColor = m_pClient->m_aClients[ClientId].m_RenderInfo.m_BloodColor;
} }
} }

View file

@ -25,7 +25,7 @@ public:
void DamageIndicator(vec2 Pos, vec2 Dir, float Alpha = 1.0f); void DamageIndicator(vec2 Pos, vec2 Dir, float Alpha = 1.0f);
void ResetDamageIndicator(); void ResetDamageIndicator();
void PlayerSpawn(vec2 Pos, float Alpha = 1.0f); void PlayerSpawn(vec2 Pos, float Alpha = 1.0f);
void PlayerDeath(vec2 Pos, int ClientID, float Alpha = 1.0f); void PlayerDeath(vec2 Pos, int ClientId, float Alpha = 1.0f);
void PowerupShine(vec2 Pos, vec2 Size, float Alpha = 1.0f); void PowerupShine(vec2 Pos, vec2 Size, float Alpha = 1.0f);
void FreezingFlakes(vec2 Pos, vec2 Size, float Alpha = 1.0f); void FreezingFlakes(vec2 Pos, vec2 Size, float Alpha = 1.0f);

View file

@ -53,7 +53,7 @@ bool CEmoticon::OnCursorMove(float x, float y, IInput::ECursorType CursorType)
if(!m_Active) if(!m_Active)
return false; return false;
UI()->ConvertMouseMove(&x, &y, CursorType); Ui()->ConvertMouseMove(&x, &y, CursorType);
m_SelectorMouse += vec2(x, y); m_SelectorMouse += vec2(x, y);
return true; return true;
} }
@ -93,9 +93,9 @@ void CEmoticon::OnRender()
else if(length(m_SelectorMouse) > 40.0f) else if(length(m_SelectorMouse) > 40.0f)
m_SelectedEyeEmote = (int)(SelectedAngle / (2 * pi) * NUM_EMOTES); m_SelectedEyeEmote = (int)(SelectedAngle / (2 * pi) * NUM_EMOTES);
CUIRect Screen = *UI()->Screen(); CUIRect Screen = *Ui()->Screen();
UI()->MapScreen(); Ui()->MapScreen();
Graphics()->BlendNormal(); Graphics()->BlendNormal();
@ -135,7 +135,7 @@ void CEmoticon::OnRender()
Graphics()->DrawCircle(Screen.w / 2, Screen.h / 2, 100.0f, 64); Graphics()->DrawCircle(Screen.w / 2, Screen.h / 2, 100.0f, 64);
Graphics()->QuadsEnd(); Graphics()->QuadsEnd();
CTeeRenderInfo TeeInfo = m_pClient->m_aClients[m_pClient->m_aLocalIDs[g_Config.m_ClDummy]].m_RenderInfo; CTeeRenderInfo TeeInfo = m_pClient->m_aClients[m_pClient->m_aLocalIds[g_Config.m_ClDummy]].m_RenderInfo;
for(int i = 0; i < NUM_EMOTES; i++) for(int i = 0; i < NUM_EMOTES; i++)
{ {

View file

@ -2,16 +2,16 @@
#include "freezebars.h" #include "freezebars.h"
void CFreezeBars::RenderFreezeBar(const int ClientID) void CFreezeBars::RenderFreezeBar(const int ClientId)
{ {
const float FreezeBarWidth = 64.0f; const float FreezeBarWidth = 64.0f;
const float FreezeBarHalfWidth = 32.0f; const float FreezeBarHalfWidth = 32.0f;
const float FreezeBarHight = 16.0f; const float FreezeBarHight = 16.0f;
// pCharacter contains the predicted character for local players or the last snap for players who are spectated // pCharacter contains the predicted character for local players or the last snap for players who are spectated
CCharacterCore *pCharacter = &m_pClient->m_aClients[ClientID].m_Predicted; CCharacterCore *pCharacter = &m_pClient->m_aClients[ClientId].m_Predicted;
if(pCharacter->m_FreezeEnd <= 0 || pCharacter->m_FreezeStart == 0 || pCharacter->m_FreezeEnd <= pCharacter->m_FreezeStart || !m_pClient->m_Snap.m_aCharacters[ClientID].m_HasExtendedDisplayInfo || (pCharacter->m_IsInFreeze && g_Config.m_ClFreezeBarsAlphaInsideFreeze == 0)) if(pCharacter->m_FreezeEnd <= 0 || pCharacter->m_FreezeStart == 0 || pCharacter->m_FreezeEnd <= pCharacter->m_FreezeStart || !m_pClient->m_Snap.m_aCharacters[ClientId].m_HasExtendedDisplayInfo || (pCharacter->m_IsInFreeze && g_Config.m_ClFreezeBarsAlphaInsideFreeze == 0))
{ {
return; return;
} }
@ -23,11 +23,11 @@ void CFreezeBars::RenderFreezeBar(const int ClientID)
return; return;
} }
vec2 Position = m_pClient->m_aClients[ClientID].m_RenderPos; vec2 Position = m_pClient->m_aClients[ClientId].m_RenderPos;
Position.x -= FreezeBarHalfWidth; Position.x -= FreezeBarHalfWidth;
Position.y += 32; Position.y += 32;
float Alpha = m_pClient->IsOtherTeam(ClientID) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f; float Alpha = m_pClient->IsOtherTeam(ClientId) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f;
if(pCharacter->m_IsInFreeze) if(pCharacter->m_IsInFreeze)
{ {
Alpha *= g_Config.m_ClFreezeBarsAlphaInsideFreeze / 100.0f; Alpha *= g_Config.m_ClFreezeBarsAlphaInsideFreeze / 100.0f;
@ -187,10 +187,10 @@ void CFreezeBars::RenderFreezeBarPos(float x, const float y, const float width,
Graphics()->WrapNormal(); Graphics()->WrapNormal();
} }
inline bool CFreezeBars::IsPlayerInfoAvailable(int ClientID) const inline bool CFreezeBars::IsPlayerInfoAvailable(int ClientId) const
{ {
const void *pPrevInfo = Client()->SnapFindItem(IClient::SNAP_PREV, NETOBJTYPE_PLAYERINFO, ClientID); const void *pPrevInfo = Client()->SnapFindItem(IClient::SNAP_PREV, NETOBJTYPE_PLAYERINFO, ClientId);
const void *pInfo = Client()->SnapFindItem(IClient::SNAP_CURRENT, NETOBJTYPE_PLAYERINFO, ClientID); const void *pInfo = Client()->SnapFindItem(IClient::SNAP_CURRENT, NETOBJTYPE_PLAYERINFO, ClientId);
return pPrevInfo && pInfo; return pPrevInfo && pInfo;
} }
@ -213,27 +213,27 @@ void CFreezeBars::OnRender()
ScreenY0 -= BorderBuffer; ScreenY0 -= BorderBuffer;
ScreenY1 += BorderBuffer; ScreenY1 += BorderBuffer;
int LocalClientID = m_pClient->m_Snap.m_LocalClientID; int LocalClientId = m_pClient->m_Snap.m_LocalClientId;
// render everyone else's freeze bar, then our own // render everyone else's freeze bar, then our own
for(int ClientID = 0; ClientID < MAX_CLIENTS; ClientID++) for(int ClientId = 0; ClientId < MAX_CLIENTS; ClientId++)
{ {
if(ClientID == LocalClientID || !m_pClient->m_Snap.m_aCharacters[ClientID].m_Active || !IsPlayerInfoAvailable(ClientID)) if(ClientId == LocalClientId || !m_pClient->m_Snap.m_aCharacters[ClientId].m_Active || !IsPlayerInfoAvailable(ClientId))
{ {
continue; continue;
} }
//don't render if the tee is offscreen //don't render if the tee is offscreen
vec2 *pRenderPos = &m_pClient->m_aClients[ClientID].m_RenderPos; vec2 *pRenderPos = &m_pClient->m_aClients[ClientId].m_RenderPos;
if(pRenderPos->x < ScreenX0 || pRenderPos->x > ScreenX1 || pRenderPos->y < ScreenY0 || pRenderPos->y > ScreenY1) if(pRenderPos->x < ScreenX0 || pRenderPos->x > ScreenX1 || pRenderPos->y < ScreenY0 || pRenderPos->y > ScreenY1)
{ {
continue; continue;
} }
RenderFreezeBar(ClientID); RenderFreezeBar(ClientId);
} }
if(LocalClientID != -1 && m_pClient->m_Snap.m_aCharacters[LocalClientID].m_Active && IsPlayerInfoAvailable(LocalClientID)) if(LocalClientId != -1 && m_pClient->m_Snap.m_aCharacters[LocalClientId].m_Active && IsPlayerInfoAvailable(LocalClientId))
{ {
RenderFreezeBar(LocalClientID); RenderFreezeBar(LocalClientId);
} }
} }

View file

@ -4,9 +4,9 @@
class CFreezeBars : public CComponent class CFreezeBars : public CComponent
{ {
void RenderFreezeBar(const int ClientID); void RenderFreezeBar(const int ClientId);
void RenderFreezeBarPos(float x, const float y, const float width, const float height, float Progress, float Alpha = 1.0f); void RenderFreezeBarPos(float x, const float y, const float width, const float height, float Progress, float Alpha = 1.0f);
bool IsPlayerInfoAvailable(int ClientID) const; bool IsPlayerInfoAvailable(int ClientId) const;
public: public:
virtual int Sizeof() const override { return sizeof(*this); } virtual int Sizeof() const override { return sizeof(*this); }

View file

@ -287,7 +287,7 @@ void CGhost::OnNewSnapshot()
CheckStart(); CheckStart();
if(m_Recording) if(m_Recording)
AddInfos(m_pClient->m_Snap.m_pLocalCharacter, (m_pClient->m_Snap.m_LocalClientID != -1 && m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_LocalClientID].m_HasExtendedData) ? &m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_LocalClientID].m_ExtendedData : nullptr); AddInfos(m_pClient->m_Snap.m_pLocalCharacter, (m_pClient->m_Snap.m_LocalClientId != -1 && m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_LocalClientId].m_HasExtendedData) ? &m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_LocalClientId].m_ExtendedData : nullptr);
} }
// Record m_LastRaceTick for g_Config.m_ClConfirmDisconnect/QuitTime anyway // Record m_LastRaceTick for g_Config.m_ClConfirmDisconnect/QuitTime anyway
@ -415,7 +415,7 @@ void CGhost::StartRecord(int Tick)
m_CurGhost.Reset(); m_CurGhost.Reset();
m_CurGhost.m_StartTick = Tick; m_CurGhost.m_StartTick = Tick;
const CGameClient::CClientData *pData = &m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID]; const CGameClient::CClientData *pData = &m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientId];
str_copy(m_CurGhost.m_aPlayer, Client()->PlayerName()); str_copy(m_CurGhost.m_aPlayer, Client()->PlayerName());
GetGhostSkin(&m_CurGhost.m_Skin, pData->m_aSkinName, pData->m_UseCustomColor, pData->m_ColorBody, pData->m_ColorFeet); GetGhostSkin(&m_CurGhost.m_Skin, pData->m_aSkinName, pData->m_UseCustomColor, pData->m_ColorBody, pData->m_ColorFeet);
InitRenderInfos(&m_CurGhost); InitRenderInfos(&m_CurGhost);
@ -620,7 +620,7 @@ void CGhost::OnMessage(int MsgType, void *pRawMsg)
if(MsgType == NETMSGTYPE_SV_KILLMSG) if(MsgType == NETMSGTYPE_SV_KILLMSG)
{ {
CNetMsg_Sv_KillMsg *pMsg = (CNetMsg_Sv_KillMsg *)pRawMsg; CNetMsg_Sv_KillMsg *pMsg = (CNetMsg_Sv_KillMsg *)pRawMsg;
if(pMsg->m_Victim == m_pClient->m_Snap.m_LocalClientID) if(pMsg->m_Victim == m_pClient->m_Snap.m_LocalClientId)
{ {
if(m_Recording) if(m_Recording)
StopRecord(); StopRecord();
@ -633,7 +633,7 @@ void CGhost::OnMessage(int MsgType, void *pRawMsg)
CNetMsg_Sv_KillMsgTeam *pMsg = (CNetMsg_Sv_KillMsgTeam *)pRawMsg; CNetMsg_Sv_KillMsgTeam *pMsg = (CNetMsg_Sv_KillMsgTeam *)pRawMsg;
for(int i = 0; i < MAX_CLIENTS; i++) for(int i = 0; i < MAX_CLIENTS; i++)
{ {
if(m_pClient->m_Teams.Team(i) == pMsg->m_Team && i == m_pClient->m_Snap.m_LocalClientID) if(m_pClient->m_Teams.Team(i) == pMsg->m_Team && i == m_pClient->m_Snap.m_LocalClientId)
{ {
if(m_Recording) if(m_Recording)
StopRecord(); StopRecord();
@ -645,11 +645,11 @@ void CGhost::OnMessage(int MsgType, void *pRawMsg)
else if(MsgType == NETMSGTYPE_SV_CHAT) else if(MsgType == NETMSGTYPE_SV_CHAT)
{ {
CNetMsg_Sv_Chat *pMsg = (CNetMsg_Sv_Chat *)pRawMsg; CNetMsg_Sv_Chat *pMsg = (CNetMsg_Sv_Chat *)pRawMsg;
if(pMsg->m_ClientID == -1 && m_Recording) if(pMsg->m_ClientId == -1 && m_Recording)
{ {
char aName[MAX_NAME_LENGTH]; char aName[MAX_NAME_LENGTH];
int Time = CRaceHelper::TimeFromFinishMessage(pMsg->m_pMessage, aName, sizeof(aName)); int Time = CRaceHelper::TimeFromFinishMessage(pMsg->m_pMessage, aName, sizeof(aName));
if(Time > 0 && m_pClient->m_Snap.m_LocalClientID >= 0 && str_comp(aName, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aName) == 0) if(Time > 0 && m_pClient->m_Snap.m_LocalClientId >= 0 && str_comp(aName, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientId].m_aName) == 0)
{ {
StopRecord(Time); StopRecord(Time);
StopRender(); StopRender();

View file

@ -244,8 +244,8 @@ void CHud::RenderScoreHud()
else if(aFlagCarrier[t] >= 0) else if(aFlagCarrier[t] >= 0)
{ {
// draw name of the flag holder // draw name of the flag holder
int ID = aFlagCarrier[t] % MAX_CLIENTS; int Id = aFlagCarrier[t] % MAX_CLIENTS;
const char *pName = m_pClient->m_aClients[ID].m_aName; const char *pName = m_pClient->m_aClients[Id].m_aName;
if(str_comp(pName, m_aScoreInfo[t].m_aPlayerNameText) != 0 || RecreateRect) if(str_comp(pName, m_aScoreInfo[t].m_aPlayerNameText) != 0 || RecreateRect)
{ {
mem_copy(m_aScoreInfo[t].m_aPlayerNameText, pName, sizeof(m_aScoreInfo[t].m_aPlayerNameText)); mem_copy(m_aScoreInfo[t].m_aPlayerNameText, pName, sizeof(m_aScoreInfo[t].m_aPlayerNameText));
@ -266,7 +266,7 @@ void CHud::RenderScoreHud()
} }
// draw tee of the flag holder // draw tee of the flag holder
CTeeRenderInfo TeeInfo = m_pClient->m_aClients[ID].m_RenderInfo; CTeeRenderInfo TeeInfo = m_pClient->m_aClients[Id].m_RenderInfo;
TeeInfo.m_Size = ScoreSingleBoxHeight; TeeInfo.m_Size = ScoreSingleBoxHeight;
const CAnimState *pIdleState = CAnimState::GetIdle(); const CAnimState *pIdleState = CAnimState::GetIdle();
@ -291,7 +291,7 @@ void CHud::RenderScoreHud()
if(m_pClient->m_Snap.m_apInfoByScore[i]->m_Team != TEAM_SPECTATORS) if(m_pClient->m_Snap.m_apInfoByScore[i]->m_Team != TEAM_SPECTATORS)
{ {
apPlayerInfo[t] = m_pClient->m_Snap.m_apInfoByScore[i]; apPlayerInfo[t] = m_pClient->m_Snap.m_apInfoByScore[i];
if(apPlayerInfo[t]->m_ClientID == m_pClient->m_Snap.m_LocalClientID) if(apPlayerInfo[t]->m_ClientId == m_pClient->m_Snap.m_LocalClientId)
Local = t; Local = t;
++t; ++t;
} }
@ -303,7 +303,7 @@ void CHud::RenderScoreHud()
{ {
if(m_pClient->m_Snap.m_apInfoByScore[i]->m_Team != TEAM_SPECTATORS) if(m_pClient->m_Snap.m_apInfoByScore[i]->m_Team != TEAM_SPECTATORS)
++aPos[1]; ++aPos[1];
if(m_pClient->m_Snap.m_apInfoByScore[i]->m_ClientID == m_pClient->m_Snap.m_LocalClientID) if(m_pClient->m_Snap.m_apInfoByScore[i]->m_ClientId == m_pClient->m_Snap.m_LocalClientId)
{ {
apPlayerInfo[1] = m_pClient->m_Snap.m_apInfoByScore[i]; apPlayerInfo[1] = m_pClient->m_Snap.m_apInfoByScore[i];
Local = 1; Local = 1;
@ -330,9 +330,9 @@ void CHud::RenderScoreHud()
aScore[t][0] = 0; aScore[t][0] = 0;
} }
static int LocalClientID = -1; static int LocalClientId = -1;
bool RecreateScores = str_comp(aScore[0], m_aScoreInfo[0].m_aScoreText) != 0 || str_comp(aScore[1], m_aScoreInfo[1].m_aScoreText) != 0 || LocalClientID != m_pClient->m_Snap.m_LocalClientID; bool RecreateScores = str_comp(aScore[0], m_aScoreInfo[0].m_aScoreText) != 0 || str_comp(aScore[1], m_aScoreInfo[1].m_aScoreText) != 0 || LocalClientId != m_pClient->m_Snap.m_LocalClientId;
LocalClientID = m_pClient->m_Snap.m_LocalClientID; LocalClientId = m_pClient->m_Snap.m_LocalClientId;
bool RecreateRect = ForceScoreInfoInit; bool RecreateRect = ForceScoreInfoInit;
for(int t = 0; t < 2; t++) for(int t = 0; t < 2; t++)
@ -346,10 +346,10 @@ void CHud::RenderScoreHud()
if(apPlayerInfo[t]) if(apPlayerInfo[t])
{ {
int ID = apPlayerInfo[t]->m_ClientID; int Id = apPlayerInfo[t]->m_ClientId;
if(ID >= 0 && ID < MAX_CLIENTS) if(Id >= 0 && Id < MAX_CLIENTS)
{ {
const char *pName = m_pClient->m_aClients[ID].m_aName; const char *pName = m_pClient->m_aClients[Id].m_aName;
if(str_comp(pName, m_aScoreInfo[t].m_aPlayerNameText) != 0) if(str_comp(pName, m_aScoreInfo[t].m_aPlayerNameText) != 0)
RecreateRect = true; RecreateRect = true;
} }
@ -406,10 +406,10 @@ void CHud::RenderScoreHud()
if(apPlayerInfo[t]) if(apPlayerInfo[t])
{ {
// draw name // draw name
int ID = apPlayerInfo[t]->m_ClientID; int Id = apPlayerInfo[t]->m_ClientId;
if(ID >= 0 && ID < MAX_CLIENTS) if(Id >= 0 && Id < MAX_CLIENTS)
{ {
const char *pName = m_pClient->m_aClients[ID].m_aName; const char *pName = m_pClient->m_aClients[Id].m_aName;
if(RecreateRect) if(RecreateRect)
{ {
mem_copy(m_aScoreInfo[t].m_aPlayerNameText, pName, sizeof(m_aScoreInfo[t].m_aPlayerNameText)); mem_copy(m_aScoreInfo[t].m_aPlayerNameText, pName, sizeof(m_aScoreInfo[t].m_aPlayerNameText));
@ -429,7 +429,7 @@ void CHud::RenderScoreHud()
} }
// draw tee // draw tee
CTeeRenderInfo TeeInfo = m_pClient->m_aClients[ID].m_RenderInfo; CTeeRenderInfo TeeInfo = m_pClient->m_aClients[Id].m_RenderInfo;
TeeInfo.m_Size = ScoreSingleBoxHeight; TeeInfo.m_Size = ScoreSingleBoxHeight;
const CAnimState *pIdleState = CAnimState::GetIdle(); const CAnimState *pIdleState = CAnimState::GetIdle();
@ -754,18 +754,18 @@ void CHud::PreparePlayerStateQuads()
m_LockModeOffset = RenderTools()->QuadContainerAddSprite(m_HudQuadContainerIndex, 0.f, 0.f, 12.f, 12.f); m_LockModeOffset = RenderTools()->QuadContainerAddSprite(m_HudQuadContainerIndex, 0.f, 0.f, 12.f, 12.f);
} }
void CHud::RenderPlayerState(const int ClientID) void CHud::RenderPlayerState(const int ClientId)
{ {
Graphics()->SetColor(1.f, 1.f, 1.f, 1.f); Graphics()->SetColor(1.f, 1.f, 1.f, 1.f);
// pCharacter contains the predicted character for local players or the last snap for players who are spectated // pCharacter contains the predicted character for local players or the last snap for players who are spectated
CCharacterCore *pCharacter = &m_pClient->m_aClients[ClientID].m_Predicted; CCharacterCore *pCharacter = &m_pClient->m_aClients[ClientId].m_Predicted;
CNetObj_Character *pPlayer = &m_pClient->m_aClients[ClientID].m_RenderCur; CNetObj_Character *pPlayer = &m_pClient->m_aClients[ClientId].m_RenderCur;
int TotalJumpsToDisplay = 0; int TotalJumpsToDisplay = 0;
if(g_Config.m_ClShowhudJumpsIndicator) if(g_Config.m_ClShowhudJumpsIndicator)
{ {
int AvailableJumpsToDisplay; int AvailableJumpsToDisplay;
if(m_pClient->m_Snap.m_aCharacters[ClientID].m_HasExtendedDisplayInfo) if(m_pClient->m_Snap.m_aCharacters[ClientId].m_HasExtendedDisplayInfo)
{ {
bool Grounded = false; bool Grounded = false;
if(Collision()->CheckPoint(pPlayer->m_X + CCharacterCore::PhysicalSize() / 2, if(Collision()->CheckPoint(pPlayer->m_X + CCharacterCore::PhysicalSize() / 2,
@ -811,7 +811,7 @@ void CHud::RenderPlayerState(const int ClientID)
} }
else else
{ {
TotalJumpsToDisplay = AvailableJumpsToDisplay = absolute(m_pClient->m_Snap.m_aCharacters[ClientID].m_ExtendedData.m_Jumps); TotalJumpsToDisplay = AvailableJumpsToDisplay = absolute(m_pClient->m_Snap.m_aCharacters[ClientId].m_ExtendedData.m_Jumps);
} }
// render available and used jumps // render available and used jumps
@ -864,7 +864,7 @@ void CHud::RenderPlayerState(const int ClientID)
{ {
const int Max = g_pData->m_Weapons.m_Ninja.m_Duration * Client()->GameTickSpeed() / 1000; const int Max = g_pData->m_Weapons.m_Ninja.m_Duration * Client()->GameTickSpeed() / 1000;
float NinjaProgress = clamp(pCharacter->m_Ninja.m_ActivationTick + g_pData->m_Weapons.m_Ninja.m_Duration * Client()->GameTickSpeed() / 1000 - Client()->GameTick(g_Config.m_ClDummy), 0, Max) / (float)Max; float NinjaProgress = clamp(pCharacter->m_Ninja.m_ActivationTick + g_pData->m_Weapons.m_Ninja.m_Duration * Client()->GameTickSpeed() / 1000 - Client()->GameTick(g_Config.m_ClDummy), 0, Max) / (float)Max;
if(NinjaProgress > 0.0f && m_pClient->m_Snap.m_aCharacters[ClientID].m_HasExtendedDisplayInfo) if(NinjaProgress > 0.0f && m_pClient->m_Snap.m_aCharacters[ClientId].m_HasExtendedDisplayInfo)
{ {
RenderNinjaBarPos(x, y - 12, 6.f, 24.f, NinjaProgress); RenderNinjaBarPos(x, y - 12, 6.f, 24.f, NinjaProgress);
} }
@ -990,13 +990,13 @@ void CHud::RenderPlayerState(const int ClientID)
{ {
y += 12; y += 12;
} }
if(m_pClient->m_Snap.m_aCharacters[ClientID].m_HasExtendedDisplayInfo && m_pClient->m_Snap.m_aCharacters[ClientID].m_ExtendedData.m_Flags & CHARACTERFLAG_LOCK_MODE) if(m_pClient->m_Snap.m_aCharacters[ClientId].m_HasExtendedDisplayInfo && m_pClient->m_Snap.m_aCharacters[ClientId].m_ExtendedData.m_Flags & CHARACTERFLAG_LOCK_MODE)
{ {
Graphics()->TextureSet(m_pClient->m_HudSkin.m_SpriteHudLockMode); Graphics()->TextureSet(m_pClient->m_HudSkin.m_SpriteHudLockMode);
Graphics()->RenderQuadContainerAsSprite(m_HudQuadContainerIndex, m_LockModeOffset, x, y); Graphics()->RenderQuadContainerAsSprite(m_HudQuadContainerIndex, m_LockModeOffset, x, y);
x += 12; x += 12;
} }
if(m_pClient->m_Snap.m_aCharacters[ClientID].m_HasExtendedDisplayInfo && m_pClient->m_Snap.m_aCharacters[ClientID].m_ExtendedData.m_Flags & CHARACTERFLAG_PRACTICE_MODE) if(m_pClient->m_Snap.m_aCharacters[ClientId].m_HasExtendedDisplayInfo && m_pClient->m_Snap.m_aCharacters[ClientId].m_ExtendedData.m_Flags & CHARACTERFLAG_PRACTICE_MODE)
{ {
Graphics()->TextureSet(m_pClient->m_HudSkin.m_SpriteHudPracticeMode); Graphics()->TextureSet(m_pClient->m_HudSkin.m_SpriteHudPracticeMode);
Graphics()->RenderQuadContainerAsSprite(m_HudQuadContainerIndex, m_PracticeModeOffset, x, y); Graphics()->RenderQuadContainerAsSprite(m_HudQuadContainerIndex, m_PracticeModeOffset, x, y);
@ -1238,7 +1238,7 @@ inline float CHud::GetMovementInformationBoxHeight()
return BoxHeight; return BoxHeight;
} }
void CHud::RenderMovementInformation(const int ClientID) void CHud::RenderMovementInformation(const int ClientId)
{ {
// Draw the infomations depending on settings: Position, speed and target angle // Draw the infomations depending on settings: Position, speed and target angle
// This display is only to present the available information from the last snapshot, not to interpolate or predict // This display is only to present the available information from the last snapshot, not to interpolate or predict
@ -1261,8 +1261,8 @@ void CHud::RenderMovementInformation(const int ClientID)
Graphics()->DrawRect(StartX, StartY, BoxWidth, BoxHeight, ColorRGBA(0.0f, 0.0f, 0.0f, 0.4f), IGraphics::CORNER_L, 5.0f); Graphics()->DrawRect(StartX, StartY, BoxWidth, BoxHeight, ColorRGBA(0.0f, 0.0f, 0.0f, 0.4f), IGraphics::CORNER_L, 5.0f);
const CNetObj_Character *pPrevChar = &m_pClient->m_Snap.m_aCharacters[ClientID].m_Prev; const CNetObj_Character *pPrevChar = &m_pClient->m_Snap.m_aCharacters[ClientId].m_Prev;
const CNetObj_Character *pCurChar = &m_pClient->m_Snap.m_aCharacters[ClientID].m_Cur; const CNetObj_Character *pCurChar = &m_pClient->m_Snap.m_aCharacters[ClientId].m_Cur;
const float IntraTick = Client()->IntraGameTick(g_Config.m_ClDummy); const float IntraTick = Client()->IntraGameTick(g_Config.m_ClDummy);
// To make the player position relative to blocks we need to divide by the block size // To make the player position relative to blocks we need to divide by the block size
@ -1289,7 +1289,7 @@ void CHud::RenderMovementInformation(const int ClientID)
DisplaySpeedX *= Ramp; DisplaySpeedX *= Ramp;
float DisplaySpeedY = VelspeedY / 32; float DisplaySpeedY = VelspeedY / 32;
float Angle = m_pClient->m_Players.GetPlayerTargetAngle(pPrevChar, pCurChar, ClientID, IntraTick); float Angle = m_pClient->m_Players.GetPlayerTargetAngle(pPrevChar, pCurChar, ClientId, IntraTick);
if(Angle < 0) if(Angle < 0)
{ {
Angle += 2.0f * pi; Angle += 2.0f * pi;
@ -1377,7 +1377,7 @@ void CHud::RenderSpectatorHud()
// draw the text // draw the text
char aBuf[128]; char aBuf[128];
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Spectate"), GameClient()->m_MultiViewActivated ? Localize("Multi-View") : m_pClient->m_Snap.m_SpecInfo.m_SpectatorID != SPEC_FREEVIEW ? m_pClient->m_aClients[m_pClient->m_Snap.m_SpecInfo.m_SpectatorID].m_aName : Localize("Free-View")); str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Spectate"), GameClient()->m_MultiViewActivated ? Localize("Multi-View") : m_pClient->m_Snap.m_SpecInfo.m_SpectatorId != SPEC_FREEVIEW ? m_pClient->m_aClients[m_pClient->m_Snap.m_SpecInfo.m_SpectatorId].m_aName : Localize("Free-View"));
TextRender()->Text(m_Width - 174.0f, m_Height - 15.0f + (15.f - 8.f) / 2.f, 8.0f, aBuf, -1.0f); TextRender()->Text(m_Width - 174.0f, m_Height - 15.0f + (15.f - 8.f) / 2.f, 8.0f, aBuf, -1.0f);
} }
@ -1416,31 +1416,31 @@ void CHud::OnRender()
{ {
RenderAmmoHealthAndArmor(m_pClient->m_Snap.m_pLocalCharacter); RenderAmmoHealthAndArmor(m_pClient->m_Snap.m_pLocalCharacter);
} }
if(m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_LocalClientID].m_HasExtendedData && g_Config.m_ClShowhudDDRace && GameClient()->m_GameInfo.m_HudDDRace) if(m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_LocalClientId].m_HasExtendedData && g_Config.m_ClShowhudDDRace && GameClient()->m_GameInfo.m_HudDDRace)
{ {
RenderPlayerState(m_pClient->m_Snap.m_LocalClientID); RenderPlayerState(m_pClient->m_Snap.m_LocalClientId);
} }
RenderMovementInformation(m_pClient->m_Snap.m_LocalClientID); RenderMovementInformation(m_pClient->m_Snap.m_LocalClientId);
RenderDDRaceEffects(); RenderDDRaceEffects();
} }
else if(m_pClient->m_Snap.m_SpecInfo.m_Active) else if(m_pClient->m_Snap.m_SpecInfo.m_Active)
{ {
int SpectatorID = m_pClient->m_Snap.m_SpecInfo.m_SpectatorID; int SpectatorId = m_pClient->m_Snap.m_SpecInfo.m_SpectatorId;
if(SpectatorID != SPEC_FREEVIEW && g_Config.m_ClShowhudHealthAmmo) if(SpectatorId != SPEC_FREEVIEW && g_Config.m_ClShowhudHealthAmmo)
{ {
RenderAmmoHealthAndArmor(&m_pClient->m_Snap.m_aCharacters[SpectatorID].m_Cur); RenderAmmoHealthAndArmor(&m_pClient->m_Snap.m_aCharacters[SpectatorId].m_Cur);
} }
if(SpectatorID != SPEC_FREEVIEW && if(SpectatorId != SPEC_FREEVIEW &&
m_pClient->m_Snap.m_aCharacters[SpectatorID].m_HasExtendedData && m_pClient->m_Snap.m_aCharacters[SpectatorId].m_HasExtendedData &&
g_Config.m_ClShowhudDDRace && g_Config.m_ClShowhudDDRace &&
(!GameClient()->m_MultiViewActivated || GameClient()->m_MultiViewShowHud) && (!GameClient()->m_MultiViewActivated || GameClient()->m_MultiViewShowHud) &&
GameClient()->m_GameInfo.m_HudDDRace) GameClient()->m_GameInfo.m_HudDDRace)
{ {
RenderPlayerState(SpectatorID); RenderPlayerState(SpectatorId);
} }
if(SpectatorID != SPEC_FREEVIEW) if(SpectatorId != SPEC_FREEVIEW)
{ {
RenderMovementInformation(SpectatorID); RenderMovementInformation(SpectatorId);
} }
RenderSpectatorHud(); RenderSpectatorHud();
} }

View file

@ -57,9 +57,9 @@ class CHud : public CComponent
void RenderAmmoHealthAndArmor(const CNetObj_Character *pCharacter); void RenderAmmoHealthAndArmor(const CNetObj_Character *pCharacter);
void PreparePlayerStateQuads(); void PreparePlayerStateQuads();
void RenderPlayerState(const int ClientID); void RenderPlayerState(const int ClientId);
void RenderDummyActions(); void RenderDummyActions();
void RenderMovementInformation(const int ClientID); void RenderMovementInformation(const int ClientId);
void RenderGameTimer(); void RenderGameTimer();
void RenderPauseNotification(); void RenderPauseNotification();

View file

@ -83,7 +83,7 @@ CInfoMessages::CInfoMsg CInfoMessages::CreateInfoMsg(EType Type)
InfoMsg.m_aVictimName[0] = '\0'; InfoMsg.m_aVictimName[0] = '\0';
InfoMsg.m_VictimTextContainerIndex.Reset(); InfoMsg.m_VictimTextContainerIndex.Reset();
InfoMsg.m_KillerID = -1; InfoMsg.m_KillerId = -1;
InfoMsg.m_aKillerName[0] = '\0'; InfoMsg.m_aKillerName[0] = '\0';
InfoMsg.m_KillerTextContainerIndex.Reset(); InfoMsg.m_KillerTextContainerIndex.Reset();
InfoMsg.m_KillerRenderInfo.Reset(); InfoMsg.m_KillerRenderInfo.Reset();
@ -104,7 +104,7 @@ CInfoMessages::CInfoMsg CInfoMessages::CreateInfoMsg(EType Type)
void CInfoMessages::AddInfoMsg(const CInfoMsg &InfoMsg) void CInfoMessages::AddInfoMsg(const CInfoMsg &InfoMsg)
{ {
if(InfoMsg.m_KillerID >= 0 && !InfoMsg.m_KillerRenderInfo.Valid()) if(InfoMsg.m_KillerId >= 0 && !InfoMsg.m_KillerRenderInfo.Valid())
return; return;
for(int i = 0; i < InfoMsg.m_TeamSize; i++) for(int i = 0; i < InfoMsg.m_TeamSize; i++)
{ {
@ -129,9 +129,9 @@ void CInfoMessages::AddInfoMsg(const CInfoMsg &InfoMsg)
void CInfoMessages::CreateTextContainersIfNotCreated(CInfoMsg &InfoMsg) void CInfoMessages::CreateTextContainersIfNotCreated(CInfoMsg &InfoMsg)
{ {
const auto &&NameColor = [&](int ClientID) -> ColorRGBA { const auto &&NameColor = [&](int ClientId) -> ColorRGBA {
unsigned Color; unsigned Color;
if(ClientID == m_pClient->m_Snap.m_LocalClientID) if(ClientId == m_pClient->m_Snap.m_LocalClientId)
{ {
Color = g_Config.m_ClKillMessageHighlightColor; Color = g_Config.m_ClKillMessageHighlightColor;
} }
@ -154,7 +154,7 @@ void CInfoMessages::CreateTextContainersIfNotCreated(CInfoMsg &InfoMsg)
{ {
CTextCursor Cursor; CTextCursor Cursor;
TextRender()->SetCursor(&Cursor, 0, 0, FONT_SIZE, TEXTFLAG_RENDER); TextRender()->SetCursor(&Cursor, 0, 0, FONT_SIZE, TEXTFLAG_RENDER);
TextRender()->TextColor(NameColor(InfoMsg.m_KillerID)); TextRender()->TextColor(NameColor(InfoMsg.m_KillerId));
TextRender()->CreateTextContainer(InfoMsg.m_KillerTextContainerIndex, &Cursor, InfoMsg.m_aKillerName); TextRender()->CreateTextContainer(InfoMsg.m_KillerTextContainerIndex, &Cursor, InfoMsg.m_aKillerName);
} }
@ -210,8 +210,8 @@ void CInfoMessages::OnTeamKillMessage(const CNetMsg_Sv_KillMsgTeam *pMsg)
{ {
if(m_pClient->m_Teams.Team(i) == pMsg->m_Team) if(m_pClient->m_Teams.Team(i) == pMsg->m_Team)
{ {
CCharacter *pChr = m_pClient->m_GameWorld.GetCharacterByID(i); CCharacter *pChr = m_pClient->m_GameWorld.GetCharacterById(i);
vStrongWeakSorted.emplace_back(i, pMsg->m_First == i ? MAX_CLIENTS : pChr ? pChr->GetStrongWeakID() : 0); vStrongWeakSorted.emplace_back(i, pMsg->m_First == i ? MAX_CLIENTS : pChr ? pChr->GetStrongWeakId() : 0);
} }
} }
std::stable_sort(vStrongWeakSorted.begin(), vStrongWeakSorted.end(), [](auto &Left, auto &Right) { return Left.second > Right.second; }); std::stable_sort(vStrongWeakSorted.begin(), vStrongWeakSorted.end(), [](auto &Left, auto &Right) { return Left.second > Right.second; });
@ -243,9 +243,9 @@ void CInfoMessages::OnKillMessage(const CNetMsg_Sv_KillMsg *pMsg)
str_copy(Kill.m_aVictimName, m_pClient->m_aClients[Kill.m_aVictimIds[0]].m_aName); str_copy(Kill.m_aVictimName, m_pClient->m_aClients[Kill.m_aVictimIds[0]].m_aName);
Kill.m_aVictimRenderInfo[0] = m_pClient->m_aClients[Kill.m_aVictimIds[0]].m_RenderInfo; Kill.m_aVictimRenderInfo[0] = m_pClient->m_aClients[Kill.m_aVictimIds[0]].m_RenderInfo;
Kill.m_KillerID = pMsg->m_Killer; Kill.m_KillerId = pMsg->m_Killer;
str_copy(Kill.m_aKillerName, m_pClient->m_aClients[Kill.m_KillerID].m_aName); str_copy(Kill.m_aKillerName, m_pClient->m_aClients[Kill.m_KillerId].m_aName);
Kill.m_KillerRenderInfo = m_pClient->m_aClients[Kill.m_KillerID].m_RenderInfo; Kill.m_KillerRenderInfo = m_pClient->m_aClients[Kill.m_KillerId].m_RenderInfo;
Kill.m_Weapon = pMsg->m_Weapon; Kill.m_Weapon = pMsg->m_Weapon;
Kill.m_ModeSpecial = pMsg->m_ModeSpecial; Kill.m_ModeSpecial = pMsg->m_ModeSpecial;
@ -259,10 +259,10 @@ void CInfoMessages::OnRaceFinishMessage(const CNetMsg_Sv_RaceFinish *pMsg)
CInfoMsg Finish = CreateInfoMsg(TYPE_FINISH); CInfoMsg Finish = CreateInfoMsg(TYPE_FINISH);
Finish.m_TeamSize = 1; Finish.m_TeamSize = 1;
Finish.m_aVictimIds[0] = pMsg->m_ClientID; Finish.m_aVictimIds[0] = pMsg->m_ClientId;
Finish.m_VictimDDTeam = m_pClient->m_Teams.Team(Finish.m_aVictimIds[0]); Finish.m_VictimDDTeam = m_pClient->m_Teams.Team(Finish.m_aVictimIds[0]);
str_copy(Finish.m_aVictimName, m_pClient->m_aClients[Finish.m_aVictimIds[0]].m_aName); str_copy(Finish.m_aVictimName, m_pClient->m_aClients[Finish.m_aVictimIds[0]].m_aName);
Finish.m_aVictimRenderInfo[0] = m_pClient->m_aClients[pMsg->m_ClientID].m_RenderInfo; Finish.m_aVictimRenderInfo[0] = m_pClient->m_aClients[pMsg->m_ClientId].m_RenderInfo;
Finish.m_Diff = pMsg->m_Diff; Finish.m_Diff = pMsg->m_Diff;
Finish.m_RecordPersonal = pMsg->m_RecordPersonal || pMsg->m_RecordServer; Finish.m_RecordPersonal = pMsg->m_RecordPersonal || pMsg->m_RecordServer;
@ -333,13 +333,13 @@ void CInfoMessages::RenderKillMsg(const CInfoMsg &InfoMsg, float x, float y)
x -= 52.0f; x -= 52.0f;
// render killer (only if different from victim) // render killer (only if different from victim)
if(InfoMsg.m_aVictimIds[0] != InfoMsg.m_KillerID) if(InfoMsg.m_aVictimIds[0] != InfoMsg.m_KillerId)
{ {
// render killer flag // render killer flag
if(m_pClient->m_Snap.m_pGameInfoObj && (m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_FLAGS) && (InfoMsg.m_ModeSpecial & 2)) if(m_pClient->m_Snap.m_pGameInfoObj && (m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_FLAGS) && (InfoMsg.m_ModeSpecial & 2))
{ {
int QuadOffset; int QuadOffset;
if(InfoMsg.m_KillerID == InfoMsg.m_FlagCarrierBlue) if(InfoMsg.m_KillerId == InfoMsg.m_FlagCarrierBlue)
{ {
Graphics()->TextureSet(GameClient()->m_GameSkin.m_SpriteFlagBlue); Graphics()->TextureSet(GameClient()->m_GameSkin.m_SpriteFlagBlue);
QuadOffset = 2; QuadOffset = 2;
@ -354,7 +354,7 @@ void CInfoMessages::RenderKillMsg(const CInfoMsg &InfoMsg, float x, float y)
// render killer tee // render killer tee
x -= 24.0f; x -= 24.0f;
if(InfoMsg.m_KillerID >= 0) if(InfoMsg.m_KillerId >= 0)
{ {
vec2 OffsetToMid; vec2 OffsetToMid;
CRenderTools::GetRenderTeeOffsetToRenderedTee(CAnimState::GetIdle(), &InfoMsg.m_KillerRenderInfo, OffsetToMid); CRenderTools::GetRenderTeeOffsetToRenderedTee(CAnimState::GetIdle(), &InfoMsg.m_KillerRenderInfo, OffsetToMid);
@ -461,13 +461,13 @@ void CInfoMessages::OnRefreshSkins()
for(auto &InfoMsg : m_aInfoMsgs) for(auto &InfoMsg : m_aInfoMsgs)
{ {
InfoMsg.m_KillerRenderInfo.Reset(); InfoMsg.m_KillerRenderInfo.Reset();
if(InfoMsg.m_KillerID >= 0) if(InfoMsg.m_KillerId >= 0)
{ {
const CGameClient::CClientData &Client = GameClient()->m_aClients[InfoMsg.m_KillerID]; const CGameClient::CClientData &Client = GameClient()->m_aClients[InfoMsg.m_KillerId];
if(Client.m_Active && Client.m_aSkinName[0] != '\0') if(Client.m_Active && Client.m_aSkinName[0] != '\0')
InfoMsg.m_KillerRenderInfo = Client.m_RenderInfo; InfoMsg.m_KillerRenderInfo = Client.m_RenderInfo;
else else
InfoMsg.m_KillerID = -1; InfoMsg.m_KillerId = -1;
} }
for(int i = 0; i < MAX_KILLMSG_TEAM_MEMBERS; i++) for(int i = 0; i < MAX_KILLMSG_TEAM_MEMBERS; i++)

View file

@ -31,7 +31,7 @@ class CInfoMessages : public CComponent
char m_aVictimName[64]; char m_aVictimName[64];
STextContainerIndex m_VictimTextContainerIndex; STextContainerIndex m_VictimTextContainerIndex;
CTeeRenderInfo m_aVictimRenderInfo[MAX_KILLMSG_TEAM_MEMBERS]; CTeeRenderInfo m_aVictimRenderInfo[MAX_KILLMSG_TEAM_MEMBERS];
int m_KillerID; int m_KillerId;
char m_aKillerName[64]; char m_aKillerName[64];
STextContainerIndex m_KillerTextContainerIndex; STextContainerIndex m_KillerTextContainerIndex;
CTeeRenderInfo m_KillerRenderInfo; CTeeRenderInfo m_KillerRenderInfo;

View file

@ -23,7 +23,7 @@
#include "items.h" #include "items.h"
void CItems::RenderProjectile(const CProjectileData *pCurrent, int ItemID) void CItems::RenderProjectile(const CProjectileData *pCurrent, int ItemId)
{ {
int CurWeapon = clamp(pCurrent->m_Type, 0, NUM_WEAPONS - 1); int CurWeapon = clamp(pCurrent->m_Type, 0, NUM_WEAPONS - 1);
@ -50,7 +50,7 @@ void CItems::RenderProjectile(const CProjectileData *pCurrent, int ItemID)
bool LocalPlayerInGame = false; bool LocalPlayerInGame = false;
if(m_pClient->m_Snap.m_pLocalInfo) if(m_pClient->m_Snap.m_pLocalInfo)
LocalPlayerInGame = m_pClient->m_aClients[m_pClient->m_Snap.m_pLocalInfo->m_ClientID].m_Team != TEAM_SPECTATORS; LocalPlayerInGame = m_pClient->m_aClients[m_pClient->m_Snap.m_pLocalInfo->m_ClientId].m_Team != TEAM_SPECTATORS;
static float s_LastGameTickTime = Client()->GameTickTime(g_Config.m_ClDummy); static float s_LastGameTickTime = Client()->GameTickTime(g_Config.m_ClDummy);
if(m_pClient->m_Snap.m_pGameInfoObj && !(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED)) if(m_pClient->m_Snap.m_pGameInfoObj && !(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED))
@ -117,7 +117,7 @@ void CItems::RenderProjectile(const CProjectileData *pCurrent, int ItemID)
s_Time += LocalTime() - s_LastLocalTime; s_Time += LocalTime() - s_LastLocalTime;
} }
Graphics()->QuadsSetRotation(s_Time * pi * 2 * 2 + ItemID); Graphics()->QuadsSetRotation(s_Time * pi * 2 * 2 + ItemId);
s_LastLocalTime = LocalTime(); s_LastLocalTime = LocalTime();
} }
else else
@ -383,7 +383,7 @@ void CItems::OnRender()
continue; continue;
CProjectileData Data = pProj->GetData(); CProjectileData Data = pProj->GetData();
RenderProjectile(&Data, pProj->GetID()); RenderProjectile(&Data, pProj->GetId());
} }
for(CEntity *pEnt = GameClient()->m_PredictedWorld.FindFirst(CGameWorld::ENTTYPE_LASER); pEnt; pEnt = pEnt->NextEntity()) for(CEntity *pEnt = GameClient()->m_PredictedWorld.FindFirst(CGameWorld::ENTTYPE_LASER); pEnt; pEnt = pEnt->NextEntity())
{ {
@ -400,7 +400,7 @@ void CItems::OnRender()
if(pPickup->InDDNetTile()) if(pPickup->InDDNetTile())
{ {
if(auto *pPrev = (CPickup *)GameClient()->m_PrevPredictedWorld.GetEntity(pPickup->GetID(), CGameWorld::ENTTYPE_PICKUP)) if(auto *pPrev = (CPickup *)GameClient()->m_PrevPredictedWorld.GetEntity(pPickup->GetId(), CGameWorld::ENTTYPE_PICKUP))
{ {
CNetObj_Pickup Data, Prev; CNetObj_Pickup Data, Prev;
pPickup->FillInfo(&Data); pPickup->FillInfo(&Data);
@ -426,13 +426,13 @@ void CItems::OnRender()
if(UsePredicted) if(UsePredicted)
{ {
if(auto *pProj = (CProjectile *)GameClient()->m_GameWorld.FindMatch(Item.m_ID, Item.m_Type, pData)) if(auto *pProj = (CProjectile *)GameClient()->m_GameWorld.FindMatch(Item.m_Id, Item.m_Type, pData))
{ {
bool IsOtherTeam = m_pClient->IsOtherTeam(pProj->GetOwner()); bool IsOtherTeam = m_pClient->IsOtherTeam(pProj->GetOwner());
if(pProj->m_LastRenderTick <= 0 && (pProj->m_Type != WEAPON_SHOTGUN || (!pProj->m_Freeze && !pProj->m_Explosive)) // skip ddrace shotgun bullets if(pProj->m_LastRenderTick <= 0 && (pProj->m_Type != WEAPON_SHOTGUN || (!pProj->m_Freeze && !pProj->m_Explosive)) // skip ddrace shotgun bullets
&& (pProj->m_Type == WEAPON_SHOTGUN || absolute(length(pProj->m_Direction) - 1.f) < 0.02f) // workaround to skip grenades on ball mod && (pProj->m_Type == WEAPON_SHOTGUN || absolute(length(pProj->m_Direction) - 1.f) < 0.02f) // workaround to skip grenades on ball mod
&& (pProj->GetOwner() < 0 || !GameClient()->m_aClients[pProj->GetOwner()].m_IsPredictedLocal || IsOtherTeam) // skip locally predicted projectiles && (pProj->GetOwner() < 0 || !GameClient()->m_aClients[pProj->GetOwner()].m_IsPredictedLocal || IsOtherTeam) // skip locally predicted projectiles
&& !Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_ID)) && !Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_Id))
{ {
ReconstructSmokeTrail(&Data, pProj->m_DestroyTick); ReconstructSmokeTrail(&Data, pProj->m_DestroyTick);
} }
@ -441,7 +441,7 @@ void CItems::OnRender()
continue; continue;
} }
} }
RenderProjectile(&Data, Item.m_ID); RenderProjectile(&Data, Item.m_Id);
} }
else if(Item.m_Type == NETOBJTYPE_PICKUP || Item.m_Type == NETOBJTYPE_DDNETPICKUP) else if(Item.m_Type == NETOBJTYPE_PICKUP || Item.m_Type == NETOBJTYPE_DDNETPICKUP)
{ {
@ -452,11 +452,11 @@ void CItems::OnRender()
continue; continue;
if(UsePredicted) if(UsePredicted)
{ {
auto *pPickup = (CPickup *)GameClient()->m_GameWorld.FindMatch(Item.m_ID, Item.m_Type, pData); auto *pPickup = (CPickup *)GameClient()->m_GameWorld.FindMatch(Item.m_Id, Item.m_Type, pData);
if(pPickup && pPickup->InDDNetTile()) if(pPickup && pPickup->InDDNetTile())
continue; continue;
} }
const void *pPrev = Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_ID); const void *pPrev = Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_Id);
if(pPrev) if(pPrev)
RenderPickup((const CNetObj_Pickup *)pPrev, (const CNetObj_Pickup *)pData); RenderPickup((const CNetObj_Pickup *)pPrev, (const CNetObj_Pickup *)pData);
} }
@ -464,7 +464,7 @@ void CItems::OnRender()
{ {
if(UsePredicted) if(UsePredicted)
{ {
auto *pLaser = dynamic_cast<CLaser *>(GameClient()->m_GameWorld.FindMatch(Item.m_ID, Item.m_Type, pData)); auto *pLaser = dynamic_cast<CLaser *>(GameClient()->m_GameWorld.FindMatch(Item.m_Id, Item.m_Type, pData));
if(pLaser && pLaser->GetOwner() >= 0 && GameClient()->m_aClients[pLaser->GetOwner()].m_IsPredictedLocal) if(pLaser && pLaser->GetOwner() >= 0 && GameClient()->m_aClients[pLaser->GetOwner()].m_IsPredictedLocal)
continue; continue;
} }
@ -528,10 +528,10 @@ void CItems::OnRender()
if(Item.m_Type == NETOBJTYPE_FLAG) if(Item.m_Type == NETOBJTYPE_FLAG)
{ {
const void *pPrev = Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_ID); const void *pPrev = Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_Id);
if(pPrev) if(pPrev)
{ {
const void *pPrevGameData = Client()->SnapFindItem(IClient::SNAP_PREV, NETOBJTYPE_GAMEDATA, m_pClient->m_Snap.m_GameDataSnapID); const void *pPrevGameData = Client()->SnapFindItem(IClient::SNAP_PREV, NETOBJTYPE_GAMEDATA, m_pClient->m_Snap.m_GameDataSnapId);
RenderFlag(static_cast<const CNetObj_Flag *>(pPrev), static_cast<const CNetObj_Flag *>(pData), RenderFlag(static_cast<const CNetObj_Flag *>(pPrev), static_cast<const CNetObj_Flag *>(pData),
static_cast<const CNetObj_GameData *>(pPrevGameData), m_pClient->m_Snap.m_pGameDataObj); static_cast<const CNetObj_GameData *>(pPrevGameData), m_pClient->m_Snap.m_pGameDataObj);
} }
@ -599,7 +599,7 @@ void CItems::ReconstructSmokeTrail(const CProjectileData *pCurrent, int DestroyT
bool LocalPlayerInGame = false; bool LocalPlayerInGame = false;
if(m_pClient->m_Snap.m_pLocalInfo) if(m_pClient->m_Snap.m_pLocalInfo)
LocalPlayerInGame = m_pClient->m_aClients[m_pClient->m_Snap.m_pLocalInfo->m_ClientID].m_Team != TEAM_SPECTATORS; LocalPlayerInGame = m_pClient->m_aClients[m_pClient->m_Snap.m_pLocalInfo->m_ClientId].m_Team != TEAM_SPECTATORS;
if(!m_pClient->AntiPingGunfire() || !LocalPlayerInGame) if(!m_pClient->AntiPingGunfire() || !LocalPlayerInGame)
return; return;
if(Client()->PredGameTick(g_Config.m_ClDummy) == pCurrent->m_StartTick) if(Client()->PredGameTick(g_Config.m_ClDummy) == pCurrent->m_StartTick)

View file

@ -10,7 +10,7 @@ class CLaserData;
class CItems : public CComponent class CItems : public CComponent
{ {
void RenderProjectile(const CProjectileData *pCurrent, int ItemID); void RenderProjectile(const CProjectileData *pCurrent, int ItemId);
void RenderPickup(const CNetObj_Pickup *pPrev, const CNetObj_Pickup *pCurrent, bool IsPredicted = false); void RenderPickup(const CNetObj_Pickup *pPrev, const CNetObj_Pickup *pCurrent, bool IsPredicted = false);
void RenderFlag(const CNetObj_Flag *pPrev, const CNetObj_Flag *pCurrent, const CNetObj_GameData *pPrevGameData, const CNetObj_GameData *pCurGameData); void RenderFlag(const CNetObj_Flag *pPrev, const CNetObj_Flag *pCurrent, const CNetObj_GameData *pPrevGameData, const CNetObj_GameData *pCurGameData);
void RenderLaser(const CLaserData *pCurrent, bool IsPredicted = false); void RenderLaser(const CLaserData *pCurrent, bool IsPredicted = false);

View file

@ -813,36 +813,36 @@ void CMapLayers::OnMapLoad()
CQuad *pQuad = &pQuads[i]; CQuad *pQuad = &pQuads[i];
for(int j = 0; j < 4; ++j) for(int j = 0; j < 4; ++j)
{ {
int QuadIDX = j; int QuadIdX = j;
if(j == 2) if(j == 2)
QuadIDX = 3; QuadIdX = 3;
else if(j == 3) else if(j == 3)
QuadIDX = 2; QuadIdX = 2;
if(!Textured) if(!Textured)
{ {
// ignore the conversion for the position coordinates // ignore the conversion for the position coordinates
vtmpQuads[i].m_aVertices[j].m_X = (pQuad->m_aPoints[QuadIDX].x); vtmpQuads[i].m_aVertices[j].m_X = (pQuad->m_aPoints[QuadIdX].x);
vtmpQuads[i].m_aVertices[j].m_Y = (pQuad->m_aPoints[QuadIDX].y); vtmpQuads[i].m_aVertices[j].m_Y = (pQuad->m_aPoints[QuadIdX].y);
vtmpQuads[i].m_aVertices[j].m_CenterX = (pQuad->m_aPoints[4].x); vtmpQuads[i].m_aVertices[j].m_CenterX = (pQuad->m_aPoints[4].x);
vtmpQuads[i].m_aVertices[j].m_CenterY = (pQuad->m_aPoints[4].y); vtmpQuads[i].m_aVertices[j].m_CenterY = (pQuad->m_aPoints[4].y);
vtmpQuads[i].m_aVertices[j].m_R = (unsigned char)pQuad->m_aColors[QuadIDX].r; vtmpQuads[i].m_aVertices[j].m_R = (unsigned char)pQuad->m_aColors[QuadIdX].r;
vtmpQuads[i].m_aVertices[j].m_G = (unsigned char)pQuad->m_aColors[QuadIDX].g; vtmpQuads[i].m_aVertices[j].m_G = (unsigned char)pQuad->m_aColors[QuadIdX].g;
vtmpQuads[i].m_aVertices[j].m_B = (unsigned char)pQuad->m_aColors[QuadIDX].b; vtmpQuads[i].m_aVertices[j].m_B = (unsigned char)pQuad->m_aColors[QuadIdX].b;
vtmpQuads[i].m_aVertices[j].m_A = (unsigned char)pQuad->m_aColors[QuadIDX].a; vtmpQuads[i].m_aVertices[j].m_A = (unsigned char)pQuad->m_aColors[QuadIdX].a;
} }
else else
{ {
// ignore the conversion for the position coordinates // ignore the conversion for the position coordinates
vtmpQuadsTextured[i].m_aVertices[j].m_X = (pQuad->m_aPoints[QuadIDX].x); vtmpQuadsTextured[i].m_aVertices[j].m_X = (pQuad->m_aPoints[QuadIdX].x);
vtmpQuadsTextured[i].m_aVertices[j].m_Y = (pQuad->m_aPoints[QuadIDX].y); vtmpQuadsTextured[i].m_aVertices[j].m_Y = (pQuad->m_aPoints[QuadIdX].y);
vtmpQuadsTextured[i].m_aVertices[j].m_CenterX = (pQuad->m_aPoints[4].x); vtmpQuadsTextured[i].m_aVertices[j].m_CenterX = (pQuad->m_aPoints[4].x);
vtmpQuadsTextured[i].m_aVertices[j].m_CenterY = (pQuad->m_aPoints[4].y); vtmpQuadsTextured[i].m_aVertices[j].m_CenterY = (pQuad->m_aPoints[4].y);
vtmpQuadsTextured[i].m_aVertices[j].m_U = fx2f(pQuad->m_aTexcoords[QuadIDX].x); vtmpQuadsTextured[i].m_aVertices[j].m_U = fx2f(pQuad->m_aTexcoords[QuadIdX].x);
vtmpQuadsTextured[i].m_aVertices[j].m_V = fx2f(pQuad->m_aTexcoords[QuadIDX].y); vtmpQuadsTextured[i].m_aVertices[j].m_V = fx2f(pQuad->m_aTexcoords[QuadIdX].y);
vtmpQuadsTextured[i].m_aVertices[j].m_R = (unsigned char)pQuad->m_aColors[QuadIDX].r; vtmpQuadsTextured[i].m_aVertices[j].m_R = (unsigned char)pQuad->m_aColors[QuadIdX].r;
vtmpQuadsTextured[i].m_aVertices[j].m_G = (unsigned char)pQuad->m_aColors[QuadIDX].g; vtmpQuadsTextured[i].m_aVertices[j].m_G = (unsigned char)pQuad->m_aColors[QuadIdX].g;
vtmpQuadsTextured[i].m_aVertices[j].m_B = (unsigned char)pQuad->m_aColors[QuadIDX].b; vtmpQuadsTextured[i].m_aVertices[j].m_B = (unsigned char)pQuad->m_aColors[QuadIdX].b;
vtmpQuadsTextured[i].m_aVertices[j].m_A = (unsigned char)pQuad->m_aColors[QuadIDX].a; vtmpQuadsTextured[i].m_aVertices[j].m_A = (unsigned char)pQuad->m_aColors[QuadIdX].a;
} }
} }
} }

View file

@ -99,7 +99,7 @@ CMenus::CMenus()
m_PasswordInput.SetHidden(true); m_PasswordInput.SetHidden(true);
} }
int CMenus::DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, bool Active) int CMenus::DoButton_Toggle(const void *pId, int Checked, const CUIRect *pRect, bool Active)
{ {
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GUIBUTTONS].m_Id); Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GUIBUTTONS].m_Id);
Graphics()->QuadsBegin(); Graphics()->QuadsBegin();
@ -108,7 +108,7 @@ int CMenus::DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect,
RenderTools()->SelectSprite(Checked ? SPRITE_GUIBUTTON_ON : SPRITE_GUIBUTTON_OFF); RenderTools()->SelectSprite(Checked ? SPRITE_GUIBUTTON_ON : SPRITE_GUIBUTTON_OFF);
IGraphics::CQuadItem QuadItem(pRect->x, pRect->y, pRect->w, pRect->h); IGraphics::CQuadItem QuadItem(pRect->x, pRect->y, pRect->w, pRect->h);
Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsDrawTL(&QuadItem, 1);
if(UI()->HotItem() == pID && Active) if(Ui()->HotItem() == pId && Active)
{ {
RenderTools()->SelectSprite(SPRITE_GUIBUTTON_HOVER); RenderTools()->SelectSprite(SPRITE_GUIBUTTON_HOVER);
QuadItem = IGraphics::CQuadItem(pRect->x, pRect->y, pRect->w, pRect->h); QuadItem = IGraphics::CQuadItem(pRect->x, pRect->y, pRect->w, pRect->h);
@ -116,7 +116,7 @@ int CMenus::DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect,
} }
Graphics()->QuadsEnd(); Graphics()->QuadsEnd();
return Active ? UI()->DoButtonLogic(pID, Checked, pRect) : 0; return Active ? Ui()->DoButtonLogic(pId, Checked, pRect) : 0;
} }
int CMenus::DoButton_Menu(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName, int Corners, float Rounding, float FontFactor, ColorRGBA Color) int CMenus::DoButton_Menu(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName, int Corners, float Rounding, float FontFactor, ColorRGBA Color)
@ -125,7 +125,7 @@ int CMenus::DoButton_Menu(CButtonContainer *pButtonContainer, const char *pText,
if(Checked) if(Checked)
Color = ColorRGBA(0.6f, 0.6f, 0.6f, 0.5f); Color = ColorRGBA(0.6f, 0.6f, 0.6f, 0.5f);
Color.a *= UI()->ButtonColorMul(pButtonContainer); Color.a *= Ui()->ButtonColorMul(pButtonContainer);
pRect->Draw(Color, Corners, Rounding); pRect->Draw(Color, Corners, Rounding);
@ -138,7 +138,7 @@ int CMenus::DoButton_Menu(CButtonContainer *pButtonContainer, const char *pText,
const CMenuImage *pImage = FindMenuImage(pImageName); const CMenuImage *pImage = FindMenuImage(pImageName);
if(pImage) if(pImage)
{ {
Graphics()->TextureSet(UI()->HotItem() == pButtonContainer ? pImage->m_OrgTexture : pImage->m_GreyTexture); Graphics()->TextureSet(Ui()->HotItem() == pButtonContainer ? pImage->m_OrgTexture : pImage->m_GreyTexture);
Graphics()->WrapClamp(); Graphics()->WrapClamp();
Graphics()->QuadsBegin(); Graphics()->QuadsBegin();
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
@ -151,14 +151,14 @@ int CMenus::DoButton_Menu(CButtonContainer *pButtonContainer, const char *pText,
Text.HMargin(pRect->h >= 20.0f ? 2.0f : 1.0f, &Text); Text.HMargin(pRect->h >= 20.0f ? 2.0f : 1.0f, &Text);
Text.HMargin((Text.h * FontFactor) / 2.0f, &Text); Text.HMargin((Text.h * FontFactor) / 2.0f, &Text);
UI()->DoLabel(&Text, pText, Text.h * CUI::ms_FontmodHeight, TEXTALIGN_MC); Ui()->DoLabel(&Text, pText, Text.h * CUi::ms_FontmodHeight, TEXTALIGN_MC);
return UI()->DoButtonLogic(pButtonContainer, Checked, pRect); return Ui()->DoButtonLogic(pButtonContainer, Checked, pRect);
} }
int CMenus::DoButton_MenuTab(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator, const ColorRGBA *pDefaultColor, const ColorRGBA *pActiveColor, const ColorRGBA *pHoverColor, float EdgeRounding, const SCommunityIcon *pCommunityIcon) int CMenus::DoButton_MenuTab(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator, const ColorRGBA *pDefaultColor, const ColorRGBA *pActiveColor, const ColorRGBA *pHoverColor, float EdgeRounding, const SCommunityIcon *pCommunityIcon)
{ {
const bool MouseInside = UI()->HotItem() == pButtonContainer; const bool MouseInside = Ui()->HotItem() == pButtonContainer;
CUIRect Rect = *pRect; CUIRect Rect = *pRect;
if(pAnimator != NULL) if(pAnimator != NULL)
@ -239,13 +239,13 @@ int CMenus::DoButton_MenuTab(CButtonContainer *pButtonContainer, const char *pTe
{ {
CUIRect Label; CUIRect Label;
Rect.HMargin(2.0f, &Label); Rect.HMargin(2.0f, &Label);
UI()->DoLabel(&Label, pText, Label.h * CUI::ms_FontmodHeight, TEXTALIGN_MC); Ui()->DoLabel(&Label, pText, Label.h * CUi::ms_FontmodHeight, TEXTALIGN_MC);
} }
return UI()->DoButtonLogic(pButtonContainer, Checked, pRect); return Ui()->DoButtonLogic(pButtonContainer, Checked, pRect);
} }
int CMenus::DoButton_GridHeader(const void *pID, const char *pText, int Checked, const CUIRect *pRect) int CMenus::DoButton_GridHeader(const void *pId, const char *pText, int Checked, const CUIRect *pRect)
{ {
if(Checked == 2) if(Checked == 2)
pRect->Draw(ColorRGBA(1, 0.98f, 0.5f, 0.55f), IGraphics::CORNER_T, 5.0f); pRect->Draw(ColorRGBA(1, 0.98f, 0.5f, 0.55f), IGraphics::CORNER_T, 5.0f);
@ -254,52 +254,52 @@ int CMenus::DoButton_GridHeader(const void *pID, const char *pText, int Checked,
CUIRect Temp; CUIRect Temp;
pRect->VSplitLeft(5.0f, nullptr, &Temp); pRect->VSplitLeft(5.0f, nullptr, &Temp);
UI()->DoLabel(&Temp, pText, pRect->h * CUI::ms_FontmodHeight, TEXTALIGN_ML); Ui()->DoLabel(&Temp, pText, pRect->h * CUi::ms_FontmodHeight, TEXTALIGN_ML);
return UI()->DoButtonLogic(pID, Checked, pRect); return Ui()->DoButtonLogic(pId, Checked, pRect);
} }
int CMenus::DoButton_Favorite(const void *pButtonId, const void *pParentId, bool Checked, const CUIRect *pRect) int CMenus::DoButton_Favorite(const void *pButtonId, const void *pParentId, bool Checked, const CUIRect *pRect)
{ {
if(Checked || (pParentId != nullptr && UI()->HotItem() == pParentId) || UI()->HotItem() == pButtonId) if(Checked || (pParentId != nullptr && Ui()->HotItem() == pParentId) || Ui()->HotItem() == pButtonId)
{ {
TextRender()->SetFontPreset(EFontPreset::ICON_FONT); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
const float Alpha = UI()->HotItem() == pButtonId ? 0.2f : 0.0f; const float Alpha = Ui()->HotItem() == pButtonId ? 0.2f : 0.0f;
TextRender()->TextColor(Checked ? ColorRGBA(1.0f, 0.85f, 0.3f, 0.8f + Alpha) : ColorRGBA(0.5f, 0.5f, 0.5f, 0.8f + Alpha)); TextRender()->TextColor(Checked ? ColorRGBA(1.0f, 0.85f, 0.3f, 0.8f + Alpha) : ColorRGBA(0.5f, 0.5f, 0.5f, 0.8f + Alpha));
SLabelProperties Props; SLabelProperties Props;
Props.m_MaxWidth = pRect->w; Props.m_MaxWidth = pRect->w;
UI()->DoLabel(pRect, FONT_ICON_STAR, 12.0f, TEXTALIGN_MC, Props); Ui()->DoLabel(pRect, FONT_ICON_STAR, 12.0f, TEXTALIGN_MC, Props);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
} }
return UI()->DoButtonLogic(pButtonId, 0, pRect); return Ui()->DoButtonLogic(pButtonId, 0, pRect);
} }
int CMenus::DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect) int CMenus::DoButton_CheckBox_Common(const void *pId, const char *pText, const char *pBoxText, const CUIRect *pRect)
{ {
CUIRect Box, Label; CUIRect Box, Label;
pRect->VSplitLeft(pRect->h, &Box, &Label); pRect->VSplitLeft(pRect->h, &Box, &Label);
Label.VSplitLeft(5.0f, nullptr, &Label); Label.VSplitLeft(5.0f, nullptr, &Label);
Box.Margin(2.0f, &Box); Box.Margin(2.0f, &Box);
Box.Draw(ColorRGBA(1, 1, 1, 0.25f * UI()->ButtonColorMul(pID)), IGraphics::CORNER_ALL, 3.0f); Box.Draw(ColorRGBA(1, 1, 1, 0.25f * Ui()->ButtonColorMul(pId)), IGraphics::CORNER_ALL, 3.0f);
const bool Checkable = *pBoxText == 'X'; const bool Checkable = *pBoxText == 'X';
if(Checkable) if(Checkable)
{ {
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT);
TextRender()->SetFontPreset(EFontPreset::ICON_FONT); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
UI()->DoLabel(&Box, FONT_ICON_XMARK, Box.h * CUI::ms_FontmodHeight, TEXTALIGN_MC); Ui()->DoLabel(&Box, FONT_ICON_XMARK, Box.h * CUi::ms_FontmodHeight, TEXTALIGN_MC);
TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
} }
else else
UI()->DoLabel(&Box, pBoxText, Box.h * CUI::ms_FontmodHeight, TEXTALIGN_MC); Ui()->DoLabel(&Box, pBoxText, Box.h * CUi::ms_FontmodHeight, TEXTALIGN_MC);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
UI()->DoLabel(&Label, pText, Box.h * CUI::ms_FontmodHeight, TEXTALIGN_ML); Ui()->DoLabel(&Label, pText, Box.h * CUi::ms_FontmodHeight, TEXTALIGN_ML);
return UI()->DoButtonLogic(pID, 0, pRect); return Ui()->DoButtonLogic(pId, 0, pRect);
} }
void CMenus::DoLaserPreview(const CUIRect *pRect, const ColorHSLA LaserOutlineColor, const ColorHSLA LaserInnerColor, const int LaserType) void CMenus::DoLaserPreview(const CUIRect *pRect, const ColorHSLA LaserOutlineColor, const ColorHSLA LaserInnerColor, const int LaserType)
@ -373,7 +373,7 @@ void CMenus::DoLaserPreview(const CUIRect *pRect, const ColorHSLA LaserOutlineCo
} }
} }
ColorHSLA CMenus::DoLine_ColorPicker(CButtonContainer *pResetID, const float LineSize, const float LabelSize, const float BottomMargin, CUIRect *pMainRect, const char *pText, unsigned int *pColorValue, const ColorRGBA DefaultColor, bool CheckBoxSpacing, int *pCheckBoxValue, bool Alpha) ColorHSLA CMenus::DoLine_ColorPicker(CButtonContainer *pResetId, const float LineSize, const float LabelSize, const float BottomMargin, CUIRect *pMainRect, const char *pText, unsigned int *pColorValue, const ColorRGBA DefaultColor, bool CheckBoxSpacing, int *pCheckBoxValue, bool Alpha)
{ {
CUIRect Section, ColorPickerButton, ResetButton, Label; CUIRect Section, ColorPickerButton, ResetButton, Label;
@ -398,12 +398,12 @@ ColorHSLA CMenus::DoLine_ColorPicker(CButtonContainer *pResetID, const float Lin
Section.VSplitRight(8.0f, &Section, nullptr); Section.VSplitRight(8.0f, &Section, nullptr);
Section.VSplitRight(Section.h, &Section, &ColorPickerButton); Section.VSplitRight(Section.h, &Section, &ColorPickerButton);
UI()->DoLabel(&Label, pText, LabelSize, TEXTALIGN_ML); Ui()->DoLabel(&Label, pText, LabelSize, TEXTALIGN_ML);
ColorHSLA PickedColor = DoButton_ColorPicker(&ColorPickerButton, pColorValue, Alpha); ColorHSLA PickedColor = DoButton_ColorPicker(&ColorPickerButton, pColorValue, Alpha);
ResetButton.HMargin(2.0f, &ResetButton); ResetButton.HMargin(2.0f, &ResetButton);
if(DoButton_Menu(pResetID, Localize("Reset"), 0, &ResetButton, nullptr, IGraphics::CORNER_ALL, 4.0f, 0.1f, ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f))) if(DoButton_Menu(pResetId, Localize("Reset"), 0, &ResetButton, nullptr, IGraphics::CORNER_ALL, 4.0f, 0.1f, ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f)))
{ {
*pColorValue = color_cast<ColorHSLA>(DefaultColor).Pack(Alpha); *pColorValue = color_cast<ColorHSLA>(DefaultColor).Pack(Alpha);
} }
@ -416,7 +416,7 @@ ColorHSLA CMenus::DoButton_ColorPicker(const CUIRect *pRect, unsigned int *pHsla
ColorHSLA HslaColor = ColorHSLA(*pHslaColor, Alpha); ColorHSLA HslaColor = ColorHSLA(*pHslaColor, Alpha);
ColorRGBA Outline = ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f); ColorRGBA Outline = ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f);
Outline.a *= UI()->ButtonColorMul(pHslaColor); Outline.a *= Ui()->ButtonColorMul(pHslaColor);
CUIRect Rect; CUIRect Rect;
pRect->Margin(3.0f, &Rect); pRect->Margin(3.0f, &Rect);
@ -424,17 +424,17 @@ ColorHSLA CMenus::DoButton_ColorPicker(const CUIRect *pRect, unsigned int *pHsla
pRect->Draw(Outline, IGraphics::CORNER_ALL, 4.0f); pRect->Draw(Outline, IGraphics::CORNER_ALL, 4.0f);
Rect.Draw(color_cast<ColorRGBA>(HslaColor), IGraphics::CORNER_ALL, 4.0f); Rect.Draw(color_cast<ColorRGBA>(HslaColor), IGraphics::CORNER_ALL, 4.0f);
static CUI::SColorPickerPopupContext s_ColorPickerPopupContext; static CUi::SColorPickerPopupContext s_ColorPickerPopupContext;
if(UI()->DoButtonLogic(pHslaColor, 0, pRect)) if(Ui()->DoButtonLogic(pHslaColor, 0, pRect))
{ {
s_ColorPickerPopupContext.m_pHslaColor = pHslaColor; s_ColorPickerPopupContext.m_pHslaColor = pHslaColor;
s_ColorPickerPopupContext.m_HslaColor = HslaColor; s_ColorPickerPopupContext.m_HslaColor = HslaColor;
s_ColorPickerPopupContext.m_HsvaColor = color_cast<ColorHSVA>(HslaColor); s_ColorPickerPopupContext.m_HsvaColor = color_cast<ColorHSVA>(HslaColor);
s_ColorPickerPopupContext.m_RgbaColor = color_cast<ColorRGBA>(s_ColorPickerPopupContext.m_HsvaColor); s_ColorPickerPopupContext.m_RgbaColor = color_cast<ColorRGBA>(s_ColorPickerPopupContext.m_HsvaColor);
s_ColorPickerPopupContext.m_Alpha = Alpha; s_ColorPickerPopupContext.m_Alpha = Alpha;
UI()->ShowPopupColorPicker(UI()->MouseX(), UI()->MouseY(), &s_ColorPickerPopupContext); Ui()->ShowPopupColorPicker(Ui()->MouseX(), Ui()->MouseY(), &s_ColorPickerPopupContext);
} }
else if(UI()->IsPopupOpen(&s_ColorPickerPopupContext) && s_ColorPickerPopupContext.m_pHslaColor == pHslaColor) else if(Ui()->IsPopupOpen(&s_ColorPickerPopupContext) && s_ColorPickerPopupContext.m_pHslaColor == pHslaColor)
{ {
HslaColor = color_cast<ColorHSLA>(s_ColorPickerPopupContext.m_HsvaColor); HslaColor = color_cast<ColorHSLA>(s_ColorPickerPopupContext.m_HsvaColor);
} }
@ -442,12 +442,12 @@ ColorHSLA CMenus::DoButton_ColorPicker(const CUIRect *pRect, unsigned int *pHsla
return HslaColor; return HslaColor;
} }
int CMenus::DoButton_CheckBoxAutoVMarginAndSet(const void *pID, const char *pText, int *pValue, CUIRect *pRect, float VMargin) int CMenus::DoButton_CheckBoxAutoVMarginAndSet(const void *pId, const char *pText, int *pValue, CUIRect *pRect, float VMargin)
{ {
CUIRect CheckBoxRect; CUIRect CheckBoxRect;
pRect->HSplitTop(VMargin, &CheckBoxRect, pRect); pRect->HSplitTop(VMargin, &CheckBoxRect, pRect);
int Logic = DoButton_CheckBox_Common(pID, pText, *pValue ? "X" : "", &CheckBoxRect); int Logic = DoButton_CheckBox_Common(pId, pText, *pValue ? "X" : "", &CheckBoxRect);
if(Logic) if(Logic)
*pValue ^= 1; *pValue ^= 1;
@ -455,32 +455,32 @@ int CMenus::DoButton_CheckBoxAutoVMarginAndSet(const void *pID, const char *pTex
return Logic; return Logic;
} }
int CMenus::DoButton_CheckBox(const void *pID, const char *pText, int Checked, const CUIRect *pRect) int CMenus::DoButton_CheckBox(const void *pId, const char *pText, int Checked, const CUIRect *pRect)
{ {
return DoButton_CheckBox_Common(pID, pText, Checked ? "X" : "", pRect); return DoButton_CheckBox_Common(pId, pText, Checked ? "X" : "", pRect);
} }
int CMenus::DoButton_CheckBox_Number(const void *pID, const char *pText, int Checked, const CUIRect *pRect) int CMenus::DoButton_CheckBox_Number(const void *pId, const char *pText, int Checked, const CUIRect *pRect)
{ {
char aBuf[16]; char aBuf[16];
str_from_int(Checked, aBuf); str_from_int(Checked, aBuf);
return DoButton_CheckBox_Common(pID, pText, aBuf, pRect); return DoButton_CheckBox_Common(pId, pText, aBuf, pRect);
} }
int CMenus::DoKeyReader(const void *pID, const CUIRect *pRect, int Key, int ModifierCombination, int *pNewModifierCombination) int CMenus::DoKeyReader(const void *pId, const CUIRect *pRect, int Key, int ModifierCombination, int *pNewModifierCombination)
{ {
// process // process
static const void *s_pGrabbedID = nullptr; static const void *s_pGrabbedId = nullptr;
static bool s_MouseReleased = true; static bool s_MouseReleased = true;
static int s_ButtonUsed = 0; static int s_ButtonUsed = 0;
const bool Inside = UI()->MouseHovered(pRect); const bool Inside = Ui()->MouseHovered(pRect);
int NewKey = Key; int NewKey = Key;
*pNewModifierCombination = ModifierCombination; *pNewModifierCombination = ModifierCombination;
if(!UI()->MouseButton(0) && !UI()->MouseButton(1) && s_pGrabbedID == pID) if(!Ui()->MouseButton(0) && !Ui()->MouseButton(1) && s_pGrabbedId == pId)
s_MouseReleased = true; s_MouseReleased = true;
if(UI()->CheckActiveItem(pID)) if(Ui()->CheckActiveItem(pId))
{ {
if(m_Binder.m_GotKey) if(m_Binder.m_GotKey)
{ {
@ -491,54 +491,54 @@ int CMenus::DoKeyReader(const void *pID, const CUIRect *pRect, int Key, int Modi
*pNewModifierCombination = m_Binder.m_ModifierCombination; *pNewModifierCombination = m_Binder.m_ModifierCombination;
} }
m_Binder.m_GotKey = false; m_Binder.m_GotKey = false;
UI()->SetActiveItem(nullptr); Ui()->SetActiveItem(nullptr);
s_MouseReleased = false; s_MouseReleased = false;
s_pGrabbedID = pID; s_pGrabbedId = pId;
} }
if(s_ButtonUsed == 1 && !UI()->MouseButton(1)) if(s_ButtonUsed == 1 && !Ui()->MouseButton(1))
{ {
if(Inside) if(Inside)
NewKey = 0; NewKey = 0;
UI()->SetActiveItem(nullptr); Ui()->SetActiveItem(nullptr);
} }
} }
else if(UI()->HotItem() == pID) else if(Ui()->HotItem() == pId)
{ {
if(s_MouseReleased) if(s_MouseReleased)
{ {
if(UI()->MouseButton(0)) if(Ui()->MouseButton(0))
{ {
m_Binder.m_TakeKey = true; m_Binder.m_TakeKey = true;
m_Binder.m_GotKey = false; m_Binder.m_GotKey = false;
UI()->SetActiveItem(pID); Ui()->SetActiveItem(pId);
s_ButtonUsed = 0; s_ButtonUsed = 0;
} }
if(UI()->MouseButton(1)) if(Ui()->MouseButton(1))
{ {
UI()->SetActiveItem(pID); Ui()->SetActiveItem(pId);
s_ButtonUsed = 1; s_ButtonUsed = 1;
} }
} }
} }
if(Inside) if(Inside)
UI()->SetHotItem(pID); Ui()->SetHotItem(pId);
char aBuf[64]; char aBuf[64];
if(UI()->CheckActiveItem(pID) && s_ButtonUsed == 0) if(Ui()->CheckActiveItem(pId) && s_ButtonUsed == 0)
str_copy(aBuf, Localize("Press a key…")); str_copy(aBuf, Localize("Press a key…"));
else if(NewKey == 0) else if(NewKey == 0)
aBuf[0] = '\0'; aBuf[0] = '\0';
else else
str_format(aBuf, sizeof(aBuf), "%s%s", CBinds::GetKeyBindModifiersName(*pNewModifierCombination), Input()->KeyName(NewKey)); str_format(aBuf, sizeof(aBuf), "%s%s", CBinds::GetKeyBindModifiersName(*pNewModifierCombination), Input()->KeyName(NewKey));
const ColorRGBA Color = UI()->CheckActiveItem(pID) && m_Binder.m_TakeKey ? ColorRGBA(0.0f, 1.0f, 0.0f, 0.4f) : ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f * UI()->ButtonColorMul(pID)); const ColorRGBA Color = Ui()->CheckActiveItem(pId) && m_Binder.m_TakeKey ? ColorRGBA(0.0f, 1.0f, 0.0f, 0.4f) : ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f * Ui()->ButtonColorMul(pId));
pRect->Draw(Color, IGraphics::CORNER_ALL, 5.0f); pRect->Draw(Color, IGraphics::CORNER_ALL, 5.0f);
CUIRect Temp; CUIRect Temp;
pRect->HMargin(1.0f, &Temp); pRect->HMargin(1.0f, &Temp);
UI()->DoLabel(&Temp, aBuf, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_MC); Ui()->DoLabel(&Temp, aBuf, Temp.h * CUi::ms_FontmodHeight, TEXTALIGN_MC);
return NewKey; return NewKey;
} }
@ -785,14 +785,14 @@ void CMenus::RenderLoading(const char *pCaption, const char *pContent, int Incre
// need up date this here to get correct // need up date this here to get correct
ms_GuiColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_UiColor, true)); ms_GuiColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_UiColor, true));
UI()->MapScreen(); Ui()->MapScreen();
if(!RenderMenuBackgroundMap || !m_pBackground->Render()) if(!RenderMenuBackgroundMap || !m_pBackground->Render())
{ {
RenderBackground(); RenderBackground();
} }
CUIRect Box = *UI()->Screen(); CUIRect Box = *Ui()->Screen();
Box.Margin(160.0f, &Box); Box.Margin(160.0f, &Box);
Graphics()->BlendNormal(); Graphics()->BlendNormal();
@ -804,12 +804,12 @@ void CMenus::RenderLoading(const char *pCaption, const char *pContent, int Incre
Box.HSplitTop(20.f, nullptr, &Box); Box.HSplitTop(20.f, nullptr, &Box);
Box.HSplitTop(24.f, &Part, &Box); Box.HSplitTop(24.f, &Part, &Box);
Part.VMargin(20.f, &Part); Part.VMargin(20.f, &Part);
UI()->DoLabel(&Part, pCaption, 24.f, TEXTALIGN_MC); Ui()->DoLabel(&Part, pCaption, 24.f, TEXTALIGN_MC);
Box.HSplitTop(20.f, nullptr, &Box); Box.HSplitTop(20.f, nullptr, &Box);
Box.HSplitTop(24.f, &Part, &Box); Box.HSplitTop(24.f, &Part, &Box);
Part.VMargin(20.f, &Part); Part.VMargin(20.f, &Part);
UI()->DoLabel(&Part, pContent, 20.0f, TEXTALIGN_MC); Ui()->DoLabel(&Part, pContent, 20.0f, TEXTALIGN_MC);
if(RenderLoadingBar) if(RenderLoadingBar)
Graphics()->DrawRect(Box.x + 40, Box.y + Box.h - 75, (Box.w - 80) * Percent, 25, ColorRGBA(1.0f, 1.0f, 1.0f, 0.75f), IGraphics::CORNER_ALL, 5.0f); Graphics()->DrawRect(Box.x + 40, Box.y + Box.h - 75, (Box.w - 80) * Percent, 25, ColorRGBA(1.0f, 1.0f, 1.0f, 0.75f), IGraphics::CORNER_ALL, 5.0f);
@ -837,12 +837,12 @@ void CMenus::RenderNews(CUIRect MainView)
{ {
MainView.HSplitTop(30.0f, &Label, &MainView); MainView.HSplitTop(30.0f, &Label, &MainView);
aLine[Len - 1] = '\0'; aLine[Len - 1] = '\0';
UI()->DoLabel(&Label, aLine + 1, 20.0f, TEXTALIGN_ML); Ui()->DoLabel(&Label, aLine + 1, 20.0f, TEXTALIGN_ML);
} }
else else
{ {
MainView.HSplitTop(20.0f, &Label, &MainView); MainView.HSplitTop(20.0f, &Label, &MainView);
UI()->DoLabel(&Label, aLine, 15.f, TEXTALIGN_ML); Ui()->DoLabel(&Label, aLine, 15.f, TEXTALIGN_ML);
} }
} }
} }
@ -869,8 +869,8 @@ void CMenus::OnInit()
SetMenuPage(g_Config.m_UiPage); SetMenuPage(g_Config.m_UiPage);
m_RefreshButton.Init(UI(), -1); m_RefreshButton.Init(Ui(), -1);
m_ConnectButton.Init(UI(), -1); m_ConnectButton.Init(Ui(), -1);
Console()->Chain("add_favorite", ConchainFavoritesUpdate, this); Console()->Chain("add_favorite", ConchainFavoritesUpdate, this);
Console()->Chain("remove_favorite", ConchainFavoritesUpdate, this); Console()->Chain("remove_favorite", ConchainFavoritesUpdate, this);
@ -943,7 +943,7 @@ void CMenus::UpdateMusicState()
void CMenus::PopupMessage(const char *pTitle, const char *pMessage, const char *pButtonLabel, int NextPopup, FPopupButtonCallback pfnButtonCallback) void CMenus::PopupMessage(const char *pTitle, const char *pMessage, const char *pButtonLabel, int NextPopup, FPopupButtonCallback pfnButtonCallback)
{ {
// reset active item // reset active item
UI()->SetActiveItem(nullptr); Ui()->SetActiveItem(nullptr);
str_copy(m_aPopupTitle, pTitle); str_copy(m_aPopupTitle, pTitle);
str_copy(m_aPopupMessage, pMessage); str_copy(m_aPopupMessage, pMessage);
@ -957,7 +957,7 @@ void CMenus::PopupConfirm(const char *pTitle, const char *pMessage, const char *
FPopupButtonCallback pfnConfirmButtonCallback, int ConfirmNextPopup, FPopupButtonCallback pfnCancelButtonCallback, int CancelNextPopup) FPopupButtonCallback pfnConfirmButtonCallback, int ConfirmNextPopup, FPopupButtonCallback pfnCancelButtonCallback, int CancelNextPopup)
{ {
// reset active item // reset active item
UI()->SetActiveItem(nullptr); Ui()->SetActiveItem(nullptr);
str_copy(m_aPopupTitle, pTitle); str_copy(m_aPopupTitle, pTitle);
str_copy(m_aPopupMessage, pMessage); str_copy(m_aPopupMessage, pMessage);
@ -979,7 +979,7 @@ void CMenus::PopupWarning(const char *pTopic, const char *pBody, const char *pBu
dbg_msg(pTopic, "%s", BodyStr.c_str()); dbg_msg(pTopic, "%s", BodyStr.c_str());
// reset active item // reset active item
UI()->SetActiveItem(nullptr); Ui()->SetActiveItem(nullptr);
str_copy(m_aMessageTopic, pTopic); str_copy(m_aMessageTopic, pTopic);
str_copy(m_aMessageBody, pBody); str_copy(m_aMessageBody, pBody);
@ -1001,11 +1001,11 @@ void CMenus::Render()
if(Client()->State() == IClient::STATE_DEMOPLAYBACK && m_Popup == POPUP_NONE) if(Client()->State() == IClient::STATE_DEMOPLAYBACK && m_Popup == POPUP_NONE)
return; return;
CUIRect Screen = *UI()->Screen(); CUIRect Screen = *Ui()->Screen();
Screen.Margin(10.0f, &Screen); Screen.Margin(10.0f, &Screen);
UI()->MapScreen(); Ui()->MapScreen();
UI()->ResetMouseSlow(); Ui()->ResetMouseSlow();
static int s_Frame = 0; static int s_Frame = 0;
if(s_Frame == 0) if(s_Frame == 0)
@ -1161,10 +1161,10 @@ void CMenus::Render()
RenderPopupFullscreen(Screen); RenderPopupFullscreen(Screen);
} }
UI()->RenderPopupMenus(); Ui()->RenderPopupMenus();
// Handle this escape hotkey after popup menus // Handle this escape hotkey after popup menus
if(!m_ShowStart && Client()->State() == IClient::STATE_OFFLINE && UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE)) if(!m_ShowStart && Client()->State() == IClient::STATE_OFFLINE && Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE))
{ {
m_ShowStart = true; m_ShowStart = true;
} }
@ -1340,9 +1340,9 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
Props.m_MaxWidth = (int)Part.w; Props.m_MaxWidth = (int)Part.w;
if(TextRender()->TextWidth(24.f, pTitle, -1, -1.0f) > Part.w) if(TextRender()->TextWidth(24.f, pTitle, -1, -1.0f) > Part.w)
UI()->DoLabel(&Part, pTitle, 24.f, TEXTALIGN_ML, Props); Ui()->DoLabel(&Part, pTitle, 24.f, TEXTALIGN_ML, Props);
else else
UI()->DoLabel(&Part, pTitle, 24.f, TEXTALIGN_MC); Ui()->DoLabel(&Part, pTitle, 24.f, TEXTALIGN_MC);
Box.HSplitTop(20.f, &Part, &Box); Box.HSplitTop(20.f, &Part, &Box);
Box.HSplitTop(24.f, &Part, &Box); Box.HSplitTop(24.f, &Part, &Box);
@ -1355,18 +1355,18 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
SLabelProperties IpLabelProps; SLabelProperties IpLabelProps;
IpLabelProps.m_MaxWidth = Part.w; IpLabelProps.m_MaxWidth = Part.w;
IpLabelProps.m_EllipsisAtEnd = true; IpLabelProps.m_EllipsisAtEnd = true;
UI()->DoLabel(&Part, Client()->ConnectAddressString(), FontSize, TEXTALIGN_MC, IpLabelProps); Ui()->DoLabel(&Part, Client()->ConnectAddressString(), FontSize, TEXTALIGN_MC, IpLabelProps);
Box.HSplitTop(20.f, &Part, &Box); Box.HSplitTop(20.f, &Part, &Box);
Box.HSplitTop(24.f, &Part, &Box); Box.HSplitTop(24.f, &Part, &Box);
} }
Props.m_MaxWidth = (int)Part.w; Props.m_MaxWidth = (int)Part.w;
if(TopAlign) if(TopAlign)
UI()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_TL, Props); Ui()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_TL, Props);
else if(TextRender()->TextWidth(FontSize, pExtraText, -1, -1.0f) > Part.w) else if(TextRender()->TextWidth(FontSize, pExtraText, -1, -1.0f) > Part.w)
UI()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_ML, Props); Ui()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_ML, Props);
else else
UI()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_MC); Ui()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_MC);
if(m_Popup == POPUP_MESSAGE || m_Popup == POPUP_CONFIRM) if(m_Popup == POPUP_MESSAGE || m_Popup == POPUP_CONFIRM)
{ {
@ -1378,7 +1378,7 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
if(m_Popup == POPUP_MESSAGE) if(m_Popup == POPUP_MESSAGE)
{ {
static CButtonContainer s_ButtonConfirm; static CButtonContainer s_ButtonConfirm;
if(DoButton_Menu(&s_ButtonConfirm, m_aPopupButtons[BUTTON_CONFIRM].m_aLabel, 0, &ButtonBar) || UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER)) if(DoButton_Menu(&s_ButtonConfirm, m_aPopupButtons[BUTTON_CONFIRM].m_aLabel, 0, &ButtonBar) || Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE) || Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER))
{ {
m_Popup = m_aPopupButtons[BUTTON_CONFIRM].m_NextPopup; m_Popup = m_aPopupButtons[BUTTON_CONFIRM].m_NextPopup;
(this->*m_aPopupButtons[BUTTON_CONFIRM].m_pfnCallback)(); (this->*m_aPopupButtons[BUTTON_CONFIRM].m_pfnCallback)();
@ -1390,14 +1390,14 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
ButtonBar.VSplitMid(&CancelButton, &ConfirmButton, 40.0f); ButtonBar.VSplitMid(&CancelButton, &ConfirmButton, 40.0f);
static CButtonContainer s_ButtonCancel; static CButtonContainer s_ButtonCancel;
if(DoButton_Menu(&s_ButtonCancel, m_aPopupButtons[BUTTON_CANCEL].m_aLabel, 0, &CancelButton) || UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE)) if(DoButton_Menu(&s_ButtonCancel, m_aPopupButtons[BUTTON_CANCEL].m_aLabel, 0, &CancelButton) || Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE))
{ {
m_Popup = m_aPopupButtons[BUTTON_CANCEL].m_NextPopup; m_Popup = m_aPopupButtons[BUTTON_CANCEL].m_NextPopup;
(this->*m_aPopupButtons[BUTTON_CANCEL].m_pfnCallback)(); (this->*m_aPopupButtons[BUTTON_CANCEL].m_pfnCallback)();
} }
static CButtonContainer s_ButtonConfirm; static CButtonContainer s_ButtonConfirm;
if(DoButton_Menu(&s_ButtonConfirm, m_aPopupButtons[BUTTON_CONFIRM].m_aLabel, 0, &ConfirmButton) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER)) if(DoButton_Menu(&s_ButtonConfirm, m_aPopupButtons[BUTTON_CONFIRM].m_aLabel, 0, &ConfirmButton) || Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER))
{ {
m_Popup = m_aPopupButtons[BUTTON_CONFIRM].m_NextPopup; m_Popup = m_aPopupButtons[BUTTON_CONFIRM].m_NextPopup;
(this->*m_aPopupButtons[BUTTON_CONFIRM].m_pfnCallback)(); (this->*m_aPopupButtons[BUTTON_CONFIRM].m_pfnCallback)();
@ -1416,7 +1416,7 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
{ {
str_format(aBuf, sizeof(aBuf), "%s\n\n%s", Localize("There's an unsaved map in the editor, you might want to save it."), Localize("Continue anyway?")); str_format(aBuf, sizeof(aBuf), "%s\n\n%s", Localize("There's an unsaved map in the editor, you might want to save it."), Localize("Continue anyway?"));
Props.m_MaxWidth = Part.w - 20.0f; Props.m_MaxWidth = Part.w - 20.0f;
UI()->DoLabel(&Box, aBuf, 20.f, TEXTALIGN_ML, Props); Ui()->DoLabel(&Box, aBuf, 20.f, TEXTALIGN_ML, Props);
} }
// buttons // buttons
@ -1426,11 +1426,11 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
No.VMargin(20.0f, &No); No.VMargin(20.0f, &No);
static CButtonContainer s_ButtonAbort; static CButtonContainer s_ButtonAbort;
if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE)) if(DoButton_Menu(&s_ButtonAbort, Localize("No"), 0, &No) || Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE))
m_Popup = POPUP_NONE; m_Popup = POPUP_NONE;
static CButtonContainer s_ButtonTryAgain; static CButtonContainer s_ButtonTryAgain;
if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER)) if(DoButton_Menu(&s_ButtonTryAgain, Localize("Yes"), 0, &Yes) || Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER))
{ {
if(m_Popup == POPUP_RESTART) if(m_Popup == POPUP_RESTART)
{ {
@ -1458,11 +1458,11 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
Abort.VMargin(20.0f, &Abort); Abort.VMargin(20.0f, &Abort);
static CButtonContainer s_ButtonAbort; static CButtonContainer s_ButtonAbort;
if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE)) if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE))
m_Popup = POPUP_NONE; m_Popup = POPUP_NONE;
static CButtonContainer s_ButtonTryAgain; static CButtonContainer s_ButtonTryAgain;
if(DoButton_Menu(&s_ButtonTryAgain, Localize("Try again"), 0, &TryAgain) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER)) if(DoButton_Menu(&s_ButtonTryAgain, Localize("Try again"), 0, &TryAgain) || Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER))
{ {
Client()->Connect(g_Config.m_UiServerAddress, g_Config.m_Password); Client()->Connect(g_Config.m_UiServerAddress, g_Config.m_Password);
} }
@ -1474,8 +1474,8 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
Label.VSplitLeft(100.0f, 0, &TextBox); Label.VSplitLeft(100.0f, 0, &TextBox);
TextBox.VSplitLeft(20.0f, 0, &TextBox); TextBox.VSplitLeft(20.0f, 0, &TextBox);
TextBox.VSplitRight(60.0f, &TextBox, 0); TextBox.VSplitRight(60.0f, &TextBox, 0);
UI()->DoLabel(&Label, Localize("Password"), 18.0f, TEXTALIGN_ML); Ui()->DoLabel(&Label, Localize("Password"), 18.0f, TEXTALIGN_ML);
UI()->DoClearableEditBox(&m_PasswordInput, &TextBox, 12.0f); Ui()->DoClearableEditBox(&m_PasswordInput, &TextBox, 12.0f);
} }
else if(m_Popup == POPUP_CONNECTING) else if(m_Popup == POPUP_CONNECTING)
{ {
@ -1486,7 +1486,7 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
Part.VMargin(120.0f, &Part); Part.VMargin(120.0f, &Part);
static CButtonContainer s_Button; static CButtonContainer s_Button;
if(DoButton_Menu(&s_Button, pButtonText, 0, &Part) || UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE)) if(DoButton_Menu(&s_Button, pButtonText, 0, &Part) || Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE))
{ {
Client()->Disconnect(); Client()->Disconnect();
m_Popup = POPUP_NONE; m_Popup = POPUP_NONE;
@ -1518,7 +1518,7 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
Box.HSplitTop(64.f, 0, &Box); Box.HSplitTop(64.f, 0, &Box);
Box.HSplitTop(24.f, &Part, &Box); Box.HSplitTop(24.f, &Part, &Box);
str_format(aBuf, sizeof(aBuf), "%d/%d KiB (%.1f KiB/s)", Client()->MapDownloadAmount() / 1024, Client()->MapDownloadTotalsize() / 1024, m_DownloadSpeed / 1024.0f); str_format(aBuf, sizeof(aBuf), "%d/%d KiB (%.1f KiB/s)", Client()->MapDownloadAmount() / 1024, Client()->MapDownloadTotalsize() / 1024, m_DownloadSpeed / 1024.0f);
UI()->DoLabel(&Part, aBuf, 20.f, TEXTALIGN_MC); Ui()->DoLabel(&Part, aBuf, 20.f, TEXTALIGN_MC);
// time left // time left
int TimeLeft = maximum(1, m_DownloadSpeed > 0.0f ? static_cast<int>((Client()->MapDownloadTotalsize() - Client()->MapDownloadAmount()) / m_DownloadSpeed) : 1); int TimeLeft = maximum(1, m_DownloadSpeed > 0.0f ? static_cast<int>((Client()->MapDownloadTotalsize() - Client()->MapDownloadAmount()) / m_DownloadSpeed) : 1);
@ -1533,7 +1533,7 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
} }
Box.HSplitTop(20.f, 0, &Box); Box.HSplitTop(20.f, 0, &Box);
Box.HSplitTop(24.f, &Part, &Box); Box.HSplitTop(24.f, &Part, &Box);
UI()->DoLabel(&Part, aBuf, 20.f, TEXTALIGN_MC); Ui()->DoLabel(&Part, aBuf, 20.f, TEXTALIGN_MC);
// progress bar // progress bar
Box.HSplitTop(20.f, 0, &Box); Box.HSplitTop(20.f, 0, &Box);
@ -1557,7 +1557,7 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
Button.VMargin(120.0f, &Button); Button.VMargin(120.0f, &Button);
static CButtonContainer s_Button; static CButtonContainer s_Button;
if(DoButton_Menu(&s_Button, Localize("Ok"), 0, &Button) || UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER) || Activated) if(DoButton_Menu(&s_Button, Localize("Ok"), 0, &Button) || Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE) || Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER) || Activated)
m_Popup = POPUP_FIRST_LAUNCH; m_Popup = POPUP_FIRST_LAUNCH;
} }
else if(m_Popup == POPUP_RENAME_DEMO) else if(m_Popup == POPUP_RENAME_DEMO)
@ -1574,11 +1574,11 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
Abort.VMargin(20.0f, &Abort); Abort.VMargin(20.0f, &Abort);
static CButtonContainer s_ButtonAbort; static CButtonContainer s_ButtonAbort;
if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE)) if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE))
m_Popup = POPUP_NONE; m_Popup = POPUP_NONE;
static CButtonContainer s_ButtonOk; static CButtonContainer s_ButtonOk;
if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &Ok) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER)) if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &Ok) || Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER))
{ {
m_Popup = POPUP_NONE; m_Popup = POPUP_NONE;
// rename demo // rename demo
@ -1618,8 +1618,8 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
Label.VSplitLeft(120.0f, 0, &TextBox); Label.VSplitLeft(120.0f, 0, &TextBox);
TextBox.VSplitLeft(20.0f, 0, &TextBox); TextBox.VSplitLeft(20.0f, 0, &TextBox);
TextBox.VSplitRight(60.0f, &TextBox, 0); TextBox.VSplitRight(60.0f, &TextBox, 0);
UI()->DoLabel(&Label, Localize("New name:"), 18.0f, TEXTALIGN_ML); Ui()->DoLabel(&Label, Localize("New name:"), 18.0f, TEXTALIGN_ML);
UI()->DoEditBox(&m_DemoRenameInput, &TextBox, 12.0f); Ui()->DoEditBox(&m_DemoRenameInput, &TextBox, 12.0f);
} }
#if defined(CONF_VIDEORECORDER) #if defined(CONF_VIDEORECORDER)
else if(m_Popup == POPUP_RENDER_DEMO) else if(m_Popup == POPUP_RENDER_DEMO)
@ -1633,14 +1633,14 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
Row.VSplitMid(&Abort, &Ok, 40.0f); Row.VSplitMid(&Abort, &Ok, 40.0f);
static CButtonContainer s_ButtonAbort; static CButtonContainer s_ButtonAbort;
if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE)) if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE))
{ {
m_DemoRenderInput.Clear(); m_DemoRenderInput.Clear();
m_Popup = POPUP_NONE; m_Popup = POPUP_NONE;
} }
static CButtonContainer s_ButtonOk; static CButtonContainer s_ButtonOk;
if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &Ok) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER)) if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &Ok) || Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER))
{ {
m_Popup = POPUP_NONE; m_Popup = POPUP_NONE;
// render video // render video
@ -1710,7 +1710,7 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
char aBuffer[128]; char aBuffer[128];
const char *pPaused = m_StartPaused ? Localize("(paused)") : ""; const char *pPaused = m_StartPaused ? Localize("(paused)") : "";
str_format(aBuffer, sizeof(aBuffer), "%s: ×%g %s", Localize("Speed"), g_aSpeeds[m_Speed], pPaused); str_format(aBuffer, sizeof(aBuffer), "%s: ×%g %s", Localize("Speed"), g_aSpeeds[m_Speed], pPaused);
UI()->DoLabel(&Row, aBuffer, 12.8f, TEXTALIGN_ML); Ui()->DoLabel(&Row, aBuffer, 12.8f, TEXTALIGN_ML);
Box.HSplitBottom(16.0f, &Box, nullptr); Box.HSplitBottom(16.0f, &Box, nullptr);
Box.HSplitBottom(24.0f, &Box, &Row); Box.HSplitBottom(24.0f, &Box, &Row);
@ -1718,8 +1718,8 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
CUIRect Label, TextBox; CUIRect Label, TextBox;
Row.VSplitLeft(110.0f, &Label, &TextBox); Row.VSplitLeft(110.0f, &Label, &TextBox);
TextBox.VSplitLeft(10.0f, nullptr, &TextBox); TextBox.VSplitLeft(10.0f, nullptr, &TextBox);
UI()->DoLabel(&Label, Localize("Video name:"), 12.8f, TEXTALIGN_ML); Ui()->DoLabel(&Label, Localize("Video name:"), 12.8f, TEXTALIGN_ML);
UI()->DoEditBox(&m_DemoRenderInput, &TextBox, 12.8f); Ui()->DoEditBox(&m_DemoRenderInput, &TextBox, 12.8f);
} }
else if(m_Popup == POPUP_RENDER_DONE) else if(m_Popup == POPUP_RENDER_DONE)
{ {
@ -1749,7 +1749,7 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
} }
static CButtonContainer s_ButtonOk; static CButtonContainer s_ButtonOk;
if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &Ok) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER)) if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &Ok) || Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER))
{ {
m_Popup = POPUP_NONE; m_Popup = POPUP_NONE;
m_DemoRenderInput.Clear(); m_DemoRenderInput.Clear();
@ -1762,7 +1762,7 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
SLabelProperties MessageProps; SLabelProperties MessageProps;
MessageProps.m_MaxWidth = (int)Part.w; MessageProps.m_MaxWidth = (int)Part.w;
UI()->DoLabel(&Part, aBuf, 18.0f, TEXTALIGN_TL, MessageProps); Ui()->DoLabel(&Part, aBuf, 18.0f, TEXTALIGN_TL, MessageProps);
} }
#endif #endif
else if(m_Popup == POPUP_FIRST_LAUNCH) else if(m_Popup == POPUP_FIRST_LAUNCH)
@ -1777,7 +1777,7 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
Join.VMargin(20.0f, &Join); Join.VMargin(20.0f, &Join);
static CButtonContainer s_JoinTutorialButton; static CButtonContainer s_JoinTutorialButton;
if(DoButton_Menu(&s_JoinTutorialButton, Localize("Join Tutorial Server"), 0, &Join) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER)) if(DoButton_Menu(&s_JoinTutorialButton, Localize("Join Tutorial Server"), 0, &Join) || Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER))
{ {
m_JoinTutorial = true; m_JoinTutorial = true;
Client()->RequestDDNetInfo(); Client()->RequestDDNetInfo();
@ -1785,7 +1785,7 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
} }
static CButtonContainer s_SkipTutorialButton; static CButtonContainer s_SkipTutorialButton;
if(DoButton_Menu(&s_SkipTutorialButton, Localize("Skip Tutorial"), 0, &Skip) || UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE)) if(DoButton_Menu(&s_SkipTutorialButton, Localize("Skip Tutorial"), 0, &Skip) || Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE))
{ {
m_JoinTutorial = false; m_JoinTutorial = false;
Client()->RequestDDNetInfo(); Client()->RequestDDNetInfo();
@ -1810,10 +1810,10 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
Label.VSplitLeft(100.0f, 0, &TextBox); Label.VSplitLeft(100.0f, 0, &TextBox);
TextBox.VSplitLeft(20.0f, 0, &TextBox); TextBox.VSplitLeft(20.0f, 0, &TextBox);
TextBox.VSplitRight(60.0f, &TextBox, 0); TextBox.VSplitRight(60.0f, &TextBox, 0);
UI()->DoLabel(&Label, Localize("Nickname"), 16.0f, TEXTALIGN_ML); Ui()->DoLabel(&Label, Localize("Nickname"), 16.0f, TEXTALIGN_ML);
static CLineInput s_PlayerNameInput(g_Config.m_PlayerName, sizeof(g_Config.m_PlayerName)); static CLineInput s_PlayerNameInput(g_Config.m_PlayerName, sizeof(g_Config.m_PlayerName));
s_PlayerNameInput.SetEmptyText(Client()->PlayerName()); s_PlayerNameInput.SetEmptyText(Client()->PlayerName());
UI()->DoEditBox(&s_PlayerNameInput, &TextBox, 12.0f); Ui()->DoEditBox(&s_PlayerNameInput, &TextBox, 12.0f);
} }
else if(m_Popup == POPUP_POINTS) else if(m_Popup == POPUP_POINTS)
{ {
@ -1829,11 +1829,11 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
No.VMargin(20.0f, &No); No.VMargin(20.0f, &No);
static CButtonContainer s_ButtonNo; static CButtonContainer s_ButtonNo;
if(DoButton_Menu(&s_ButtonNo, Localize("No"), 0, &No) || UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE)) if(DoButton_Menu(&s_ButtonNo, Localize("No"), 0, &No) || Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE))
m_Popup = POPUP_FIRST_LAUNCH; m_Popup = POPUP_FIRST_LAUNCH;
static CButtonContainer s_ButtonYes; static CButtonContainer s_ButtonYes;
if(DoButton_Menu(&s_ButtonYes, Localize("Yes"), 0, &Yes) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER)) if(DoButton_Menu(&s_ButtonYes, Localize("Yes"), 0, &Yes) || Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER))
m_Popup = POPUP_NONE; m_Popup = POPUP_NONE;
} }
else if(m_Popup == POPUP_WARNING) else if(m_Popup == POPUP_WARNING)
@ -1843,7 +1843,7 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
Part.VMargin(120.0f, &Part); Part.VMargin(120.0f, &Part);
static CButtonContainer s_Button; static CButtonContainer s_Button;
if(DoButton_Menu(&s_Button, pButtonText, 0, &Part) || UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER) || (m_PopupWarningDuration > 0s && time_get_nanoseconds() - m_PopupWarningLastTime >= m_PopupWarningDuration)) if(DoButton_Menu(&s_Button, pButtonText, 0, &Part) || Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE) || Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER) || (m_PopupWarningDuration > 0s && time_get_nanoseconds() - m_PopupWarningLastTime >= m_PopupWarningDuration))
{ {
m_Popup = POPUP_NONE; m_Popup = POPUP_NONE;
SetActive(false); SetActive(false);
@ -1856,7 +1856,7 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
Part.VMargin(120.0f, &Part); Part.VMargin(120.0f, &Part);
static CButtonContainer s_Button; static CButtonContainer s_Button;
if(DoButton_Menu(&s_Button, pButtonText, 0, &Part) || UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER)) if(DoButton_Menu(&s_Button, pButtonText, 0, &Part) || Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE) || Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER))
{ {
if(m_Popup == POPUP_DISCONNECTED && Client()->ReconnectTime() > 0) if(m_Popup == POPUP_DISCONNECTED && Client()->ReconnectTime() > 0)
Client()->SetReconnectTime(0); Client()->SetReconnectTime(0);
@ -1865,7 +1865,7 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
} }
if(m_Popup == POPUP_NONE) if(m_Popup == POPUP_NONE)
UI()->SetActiveItem(nullptr); Ui()->SetActiveItem(nullptr);
} }
#if defined(CONF_VIDEORECORDER) #if defined(CONF_VIDEORECORDER)
@ -1949,7 +1949,7 @@ void CMenus::RenderThemeSelection(CUIRect MainView)
else // generic else // generic
str_copy(aName, Theme.m_Name.c_str()); str_copy(aName, Theme.m_Name.c_str());
UI()->DoLabel(&Label, aName, 16.0f * CUI::ms_FontmodHeight, TEXTALIGN_ML); Ui()->DoLabel(&Label, aName, 16.0f * CUi::ms_FontmodHeight, TEXTALIGN_ML);
} }
SelectedTheme = s_ListBox.DoEnd(); SelectedTheme = s_ListBox.DoEnd();
@ -1966,8 +1966,8 @@ void CMenus::SetActive(bool Active)
{ {
if(Active != m_MenuActive) if(Active != m_MenuActive)
{ {
UI()->SetHotItem(nullptr); Ui()->SetHotItem(nullptr);
UI()->SetActiveItem(nullptr); Ui()->SetActiveItem(nullptr);
} }
m_MenuActive = Active; m_MenuActive = Active;
if(!m_MenuActive) if(!m_MenuActive)
@ -2011,8 +2011,8 @@ bool CMenus::OnCursorMove(float x, float y, IInput::ECursorType CursorType)
if(!m_MenuActive) if(!m_MenuActive)
return false; return false;
UI()->ConvertMouseMove(&x, &y, CursorType); Ui()->ConvertMouseMove(&x, &y, CursorType);
UI()->OnCursorMove(x, y); Ui()->OnCursorMove(x, y);
return true; return true;
} }
@ -2022,7 +2022,7 @@ bool CMenus::OnInput(const IInput::CEvent &Event)
// Escape key is always handled to activate/deactivate menu // Escape key is always handled to activate/deactivate menu
if((Event.m_Flags & IInput::FLAG_PRESS && Event.m_Key == KEY_ESCAPE) || IsActive()) if((Event.m_Flags & IInput::FLAG_PRESS && Event.m_Key == KEY_ESCAPE) || IsActive())
{ {
UI()->OnInput(Event); Ui()->OnInput(Event);
return true; return true;
} }
return false; return false;
@ -2031,7 +2031,7 @@ bool CMenus::OnInput(const IInput::CEvent &Event)
void CMenus::OnStateChange(int NewState, int OldState) void CMenus::OnStateChange(int NewState, int OldState)
{ {
// reset active item // reset active item
UI()->SetActiveItem(nullptr); Ui()->SetActiveItem(nullptr);
if(OldState == IClient::STATE_ONLINE || OldState == IClient::STATE_OFFLINE) if(OldState == IClient::STATE_ONLINE || OldState == IClient::STATE_OFFLINE)
TextRender()->DeleteTextContainer(m_MotdTextContainerIndex); TextRender()->DeleteTextContainer(m_MotdTextContainerIndex);
@ -2047,7 +2047,7 @@ void CMenus::OnStateChange(int NewState, int OldState)
{ {
m_Popup = POPUP_PASSWORD; m_Popup = POPUP_PASSWORD;
m_PasswordInput.SelectAll(); m_PasswordInput.SelectAll();
UI()->SetActiveItem(&m_PasswordInput); Ui()->SetActiveItem(&m_PasswordInput);
} }
else else
m_Popup = POPUP_DISCONNECTED; m_Popup = POPUP_DISCONNECTED;
@ -2081,15 +2081,15 @@ void CMenus::OnWindowResize()
void CMenus::OnRender() void CMenus::OnRender()
{ {
UI()->StartCheck(); Ui()->StartCheck();
if(Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK) if(Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK)
SetActive(true); SetActive(true);
if(Client()->State() == IClient::STATE_DEMOPLAYBACK) if(Client()->State() == IClient::STATE_DEMOPLAYBACK)
{ {
UI()->MapScreen(); Ui()->MapScreen();
RenderDemoPlayer(*UI()->Screen()); RenderDemoPlayer(*Ui()->Screen());
} }
if(Client()->State() == IClient::STATE_ONLINE && m_pClient->m_ServerMode == CGameClient::SERVERMODE_PUREMOD) if(Client()->State() == IClient::STATE_ONLINE && m_pClient->m_ServerMode == CGameClient::SERVERMODE_PUREMOD)
@ -2101,29 +2101,29 @@ void CMenus::OnRender()
if(!IsActive()) if(!IsActive())
{ {
if(UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE)) if(Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE))
SetActive(true); SetActive(true);
UI()->FinishCheck(); Ui()->FinishCheck();
UI()->ClearHotkeys(); Ui()->ClearHotkeys();
return; return;
} }
UpdateColors(); UpdateColors();
UI()->Update(); Ui()->Update();
Render(); Render();
RenderTools()->RenderCursor(UI()->MousePos(), 24.0f); RenderTools()->RenderCursor(Ui()->MousePos(), 24.0f);
// render debug information // render debug information
if(g_Config.m_Debug) if(g_Config.m_Debug)
UI()->DebugRender(); Ui()->DebugRender();
if(UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE)) if(Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE))
SetActive(false); SetActive(false);
UI()->FinishCheck(); Ui()->FinishCheck();
UI()->ClearHotkeys(); Ui()->ClearHotkeys();
} }
void CMenus::UpdateColors() void CMenus::UpdateColors()
@ -2202,7 +2202,7 @@ void CMenus::RenderBackground()
Graphics()->QuadsEnd(); Graphics()->QuadsEnd();
// restore screen // restore screen
UI()->MapScreen(); Ui()->MapScreen();
} }
bool CMenus::CheckHotKey(int Key) const bool CMenus::CheckHotKey(int Key) const
@ -2212,16 +2212,16 @@ bool CMenus::CheckHotKey(int Key) const
Input()->KeyIsPressed(Key) && m_pClient->m_GameConsole.IsClosed(); Input()->KeyIsPressed(Key) && m_pClient->m_GameConsole.IsClosed();
} }
int CMenus::DoButton_CheckBox_Tristate(const void *pID, const char *pText, TRISTATE Checked, const CUIRect *pRect) int CMenus::DoButton_CheckBox_Tristate(const void *pId, const char *pText, TRISTATE Checked, const CUIRect *pRect)
{ {
switch(Checked) switch(Checked)
{ {
case TRISTATE::NONE: case TRISTATE::NONE:
return DoButton_CheckBox_Common(pID, pText, "", pRect); return DoButton_CheckBox_Common(pId, pText, "", pRect);
case TRISTATE::SOME: case TRISTATE::SOME:
return DoButton_CheckBox_Common(pID, pText, "O", pRect); return DoButton_CheckBox_Common(pId, pText, "O", pRect);
case TRISTATE::ALL: case TRISTATE::ALL:
return DoButton_CheckBox_Common(pID, pText, "X", pRect); return DoButton_CheckBox_Common(pId, pText, "X", pRect);
default: default:
dbg_assert(false, "invalid tristate"); dbg_assert(false, "invalid tristate");
} }

View file

@ -67,22 +67,22 @@ class CMenus : public CComponent
static ColorRGBA ms_ColorTabbarHover; static ColorRGBA ms_ColorTabbarHover;
int DoButton_FontIcon(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners = IGraphics::CORNER_ALL, bool Enabled = true); int DoButton_FontIcon(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners = IGraphics::CORNER_ALL, bool Enabled = true);
int DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, bool Active); int DoButton_Toggle(const void *pId, int Checked, const CUIRect *pRect, bool Active);
int DoButton_Menu(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName = nullptr, int Corners = IGraphics::CORNER_ALL, float Rounding = 5.0f, float FontFactor = 0.0f, ColorRGBA Color = ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f)); int DoButton_Menu(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName = nullptr, int Corners = IGraphics::CORNER_ALL, float Rounding = 5.0f, float FontFactor = 0.0f, ColorRGBA Color = ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f));
int DoButton_MenuTab(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator = nullptr, const ColorRGBA *pDefaultColor = nullptr, const ColorRGBA *pActiveColor = nullptr, const ColorRGBA *pHoverColor = nullptr, float EdgeRounding = 10.0f, const SCommunityIcon *pCommunityIcon = nullptr); int DoButton_MenuTab(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator = nullptr, const ColorRGBA *pDefaultColor = nullptr, const ColorRGBA *pActiveColor = nullptr, const ColorRGBA *pHoverColor = nullptr, float EdgeRounding = 10.0f, const SCommunityIcon *pCommunityIcon = nullptr);
int DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect); int DoButton_CheckBox_Common(const void *pId, const char *pText, const char *pBoxText, const CUIRect *pRect);
int DoButton_CheckBox(const void *pID, const char *pText, int Checked, const CUIRect *pRect); int DoButton_CheckBox(const void *pId, const char *pText, int Checked, const CUIRect *pRect);
int DoButton_CheckBoxAutoVMarginAndSet(const void *pID, const char *pText, int *pValue, CUIRect *pRect, float VMargin); int DoButton_CheckBoxAutoVMarginAndSet(const void *pId, const char *pText, int *pValue, CUIRect *pRect, float VMargin);
int DoButton_CheckBox_Number(const void *pID, const char *pText, int Checked, const CUIRect *pRect); int DoButton_CheckBox_Number(const void *pId, const char *pText, int Checked, const CUIRect *pRect);
ColorHSLA DoLine_ColorPicker(CButtonContainer *pResetID, float LineSize, float LabelSize, float BottomMargin, CUIRect *pMainRect, const char *pText, unsigned int *pColorValue, ColorRGBA DefaultColor, bool CheckBoxSpacing = true, int *pCheckBoxValue = nullptr, bool Alpha = false); ColorHSLA DoLine_ColorPicker(CButtonContainer *pResetId, float LineSize, float LabelSize, float BottomMargin, CUIRect *pMainRect, const char *pText, unsigned int *pColorValue, ColorRGBA DefaultColor, bool CheckBoxSpacing = true, int *pCheckBoxValue = nullptr, bool Alpha = false);
ColorHSLA DoButton_ColorPicker(const CUIRect *pRect, unsigned int *pHslaColor, bool Alpha); ColorHSLA DoButton_ColorPicker(const CUIRect *pRect, unsigned int *pHslaColor, bool Alpha);
void DoLaserPreview(const CUIRect *pRect, ColorHSLA OutlineColor, ColorHSLA InnerColor, const int LaserType); void DoLaserPreview(const CUIRect *pRect, ColorHSLA OutlineColor, ColorHSLA InnerColor, const int LaserType);
int DoButton_GridHeader(const void *pID, const char *pText, int Checked, const CUIRect *pRect); int DoButton_GridHeader(const void *pId, const char *pText, int Checked, const CUIRect *pRect);
int DoButton_Favorite(const void *pButtonId, const void *pParentId, bool Checked, const CUIRect *pRect); int DoButton_Favorite(const void *pButtonId, const void *pParentId, bool Checked, const CUIRect *pRect);
int DoKeyReader(const void *pID, const CUIRect *pRect, int Key, int ModifierCombination, int *pNewModifierCombination); int DoKeyReader(const void *pId, const CUIRect *pRect, int Key, int ModifierCombination, int *pNewModifierCombination);
void DoSettingsControlsButtons(int Start, int Stop, CUIRect View); void DoSettingsControlsButtons(int Start, int Stop, CUIRect View);
@ -489,7 +489,7 @@ protected:
int m_Selection; int m_Selection;
bool m_New; bool m_New;
}; };
static CUI::EPopupMenuFunctionResult PopupCountrySelection(void *pContext, CUIRect View, bool Active); static CUi::EPopupMenuFunctionResult PopupCountrySelection(void *pContext, CUIRect View, bool Active);
void RenderServerbrowserInfo(CUIRect View); void RenderServerbrowserInfo(CUIRect View);
void RenderServerbrowserInfoScoreboard(CUIRect View, const CServerInfo *pSelectedServer); void RenderServerbrowserInfoScoreboard(CUIRect View, const CServerInfo *pSelectedServer);
void RenderServerbrowserFriends(CUIRect View); void RenderServerbrowserFriends(CUIRect View);
@ -692,7 +692,7 @@ public:
SUIAnimator m_aAnimatorsSettingsTab[SETTINGS_LENGTH]; SUIAnimator m_aAnimatorsSettingsTab[SETTINGS_LENGTH];
// DDRace // DDRace
int DoButton_CheckBox_Tristate(const void *pID, const char *pText, TRISTATE Checked, const CUIRect *pRect); int DoButton_CheckBox_Tristate(const void *pId, const char *pText, TRISTATE Checked, const CUIRect *pRect);
std::vector<CDemoItem> m_vDemos; std::vector<CDemoItem> m_vDemos;
std::vector<CDemoItem *> m_vpFilteredDemos; std::vector<CDemoItem *> m_vpFilteredDemos;
void DemolistPopulate(); void DemolistPopulate();

View file

@ -92,7 +92,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
struct SColumn struct SColumn
{ {
int m_ID; int m_Id;
int m_Sort; int m_Sort;
const char *m_pCaption; const char *m_pCaption;
int m_Direction; int m_Direction;
@ -182,7 +182,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
if(PlayersOrPing && g_Config.m_BrSortOrder == 2 && (Col.m_Sort == IServerBrowser::SORT_NUMPLAYERS || Col.m_Sort == IServerBrowser::SORT_PING)) if(PlayersOrPing && g_Config.m_BrSortOrder == 2 && (Col.m_Sort == IServerBrowser::SORT_NUMPLAYERS || Col.m_Sort == IServerBrowser::SORT_PING))
Checked = 2; Checked = 2;
if(DoButton_GridHeader(&Col.m_ID, Localize(Col.m_pCaption), Checked, &Col.m_Rect)) if(DoButton_GridHeader(&Col.m_Id, Localize(Col.m_pCaption), Checked, &Col.m_Rect))
{ {
if(Col.m_Sort != -1) if(Col.m_Sort != -1)
{ {
@ -194,11 +194,11 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
} }
} }
if(Col.m_ID == COL_FRIENDS) if(Col.m_Id == COL_FRIENDS)
{ {
TextRender()->SetFontPreset(EFontPreset::ICON_FONT); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
UI()->DoLabel(&Col.m_Rect, FONT_ICON_HEART, 14.0f, TEXTALIGN_MC); Ui()->DoLabel(&Col.m_Rect, FONT_ICON_HEART, 14.0f, TEXTALIGN_MC);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
} }
@ -211,11 +211,11 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
{ {
if(!ServerBrowser()->NumServers() && ServerBrowser()->IsGettingServerlist()) if(!ServerBrowser()->NumServers() && ServerBrowser()->IsGettingServerlist())
{ {
UI()->DoLabel(&View, Localize("Getting server list from master server"), 16.0f, TEXTALIGN_MC); Ui()->DoLabel(&View, Localize("Getting server list from master server"), 16.0f, TEXTALIGN_MC);
} }
else if(!ServerBrowser()->NumServers()) else if(!ServerBrowser()->NumServers())
{ {
UI()->DoLabel(&View, Localize("No servers found"), 16.0f, TEXTALIGN_MC); Ui()->DoLabel(&View, Localize("No servers found"), 16.0f, TEXTALIGN_MC);
} }
else if(ServerBrowser()->NumServers() && !NumServers) else if(ServerBrowser()->NumServers() && !NumServers)
{ {
@ -224,7 +224,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
Label.HSplitTop(16.0f, &Label, &ResetButton); Label.HSplitTop(16.0f, &Label, &ResetButton);
ResetButton.HSplitTop(8.0f, nullptr, &ResetButton); ResetButton.HSplitTop(8.0f, nullptr, &ResetButton);
ResetButton.VMargin((ResetButton.w - 200.0f) / 2.0f, &ResetButton); ResetButton.VMargin((ResetButton.w - 200.0f) / 2.0f, &ResetButton);
UI()->DoLabel(&Label, Localize("No servers match your filter criteria"), 16.0f, TEXTALIGN_MC); Ui()->DoLabel(&Label, Localize("No servers match your filter criteria"), 16.0f, TEXTALIGN_MC);
static CButtonContainer s_ResetButton; static CButtonContainer s_ResetButton;
if(DoButton_Menu(&s_ResetButton, Localize("Reset filter"), 0, &ResetButton)) if(DoButton_Menu(&s_ResetButton, Localize("Reset filter"), 0, &ResetButton))
{ {
@ -233,7 +233,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
} }
} }
s_ListBox.SetActive(!UI()->IsPopupOpen()); s_ListBox.SetActive(!Ui()->IsPopupOpen());
s_ListBox.DoStart(ms_ListheaderHeight, NumServers, 1, 3, -1, &View, false); s_ListBox.DoStart(ms_ListheaderHeight, NumServers, 1, 3, -1, &View, false);
if(m_ServerBrowserShouldRevealSelection) if(m_ServerBrowserShouldRevealSelection)
@ -249,7 +249,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
TextRender()->TextColor(TextColor); TextRender()->TextColor(TextColor);
TextRender()->TextOutlineColor(TextOutlineColor); TextRender()->TextOutlineColor(TextOutlineColor);
UI()->DoLabelStreamed(UIRect, pRect, pText, FontSize, TextAlign); Ui()->DoLabelStreamed(UIRect, pRect, pText, FontSize, TextAlign);
TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor()); TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor());
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
@ -267,7 +267,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
if(vpServerBrowserUiElements[i] == nullptr) if(vpServerBrowserUiElements[i] == nullptr)
{ {
vpServerBrowserUiElements[i] = UI()->GetNewUIElement(NUM_UI_ELEMS); vpServerBrowserUiElements[i] = Ui()->GetNewUIElement(NUM_UI_ELEMS);
} }
CUIElement *pUiElement = vpServerBrowserUiElements[i]; CUIElement *pUiElement = vpServerBrowserUiElements[i];
@ -278,8 +278,8 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
if(!ListItem.m_Visible) if(!ListItem.m_Visible)
{ {
// reset active item, if not visible // reset active item, if not visible
if(UI()->CheckActiveItem(pItem)) if(Ui()->CheckActiveItem(pItem))
UI()->SetActiveItem(nullptr); Ui()->SetActiveItem(nullptr);
// don't render invisible items // don't render invisible items
continue; continue;
@ -295,22 +295,22 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
Button.h = ListItem.m_Rect.h; Button.h = ListItem.m_Rect.h;
Button.w = Col.m_Rect.w; Button.w = Col.m_Rect.w;
const int ID = Col.m_ID; const int Id = Col.m_Id;
if(ID == COL_FLAG_LOCK) if(Id == COL_FLAG_LOCK)
{ {
if(pItem->m_Flags & SERVER_FLAG_PASSWORD) if(pItem->m_Flags & SERVER_FLAG_PASSWORD)
{ {
RenderBrowserIcons(*pUiElement->Rect(UI_ELEM_LOCK_ICON), &Button, ColorRGBA(0.75f, 0.75f, 0.75f, 1.0f), TextRender()->DefaultTextOutlineColor(), FONT_ICON_LOCK, TEXTALIGN_MC); RenderBrowserIcons(*pUiElement->Rect(UI_ELEM_LOCK_ICON), &Button, ColorRGBA(0.75f, 0.75f, 0.75f, 1.0f), TextRender()->DefaultTextOutlineColor(), FONT_ICON_LOCK, TEXTALIGN_MC);
} }
} }
else if(ID == COL_FLAG_FAV) else if(Id == COL_FLAG_FAV)
{ {
if(pItem->m_Favorite != TRISTATE::NONE) if(pItem->m_Favorite != TRISTATE::NONE)
{ {
RenderBrowserIcons(*pUiElement->Rect(UI_ELEM_FAVORITE_ICON), &Button, ColorRGBA(1.0f, 0.85f, 0.3f, 1.0f), TextRender()->DefaultTextOutlineColor(), FONT_ICON_STAR, TEXTALIGN_MC); RenderBrowserIcons(*pUiElement->Rect(UI_ELEM_FAVORITE_ICON), &Button, ColorRGBA(1.0f, 0.85f, 0.3f, 1.0f), TextRender()->DefaultTextOutlineColor(), FONT_ICON_STAR, TEXTALIGN_MC);
} }
} }
else if(ID == COL_COMMUNITY) else if(Id == COL_COMMUNITY)
{ {
if(pCommunity != nullptr) if(pCommunity != nullptr)
{ {
@ -320,12 +320,12 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
CUIRect CommunityIcon; CUIRect CommunityIcon;
Button.Margin(2.0f, &CommunityIcon); Button.Margin(2.0f, &CommunityIcon);
RenderCommunityIcon(pIcon, CommunityIcon, true); RenderCommunityIcon(pIcon, CommunityIcon, true);
UI()->DoButtonLogic(&pItem->m_aCommunityId, 0, &CommunityIcon); Ui()->DoButtonLogic(&pItem->m_aCommunityId, 0, &CommunityIcon);
GameClient()->m_Tooltips.DoToolTip(&pItem->m_aCommunityId, &CommunityIcon, pCommunity->Name()); GameClient()->m_Tooltips.DoToolTip(&pItem->m_aCommunityId, &CommunityIcon, pCommunity->Name());
} }
} }
} }
else if(ID == COL_NAME) else if(Id == COL_NAME)
{ {
SLabelProperties Props; SLabelProperties Props;
Props.m_MaxWidth = Button.w; Props.m_MaxWidth = Button.w;
@ -334,16 +334,16 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
bool Printed = false; bool Printed = false;
if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit & IServerBrowser::QUICK_SERVERNAME)) if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit & IServerBrowser::QUICK_SERVERNAME))
Printed = PrintHighlighted(pItem->m_aName, [&](const char *pFilteredStr, const int FilterLen) { Printed = PrintHighlighted(pItem->m_aName, [&](const char *pFilteredStr, const int FilterLen) {
UI()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_NAME_1), &Button, pItem->m_aName, FontSize, TEXTALIGN_ML, Props, (int)(pFilteredStr - pItem->m_aName)); Ui()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_NAME_1), &Button, pItem->m_aName, FontSize, TEXTALIGN_ML, Props, (int)(pFilteredStr - pItem->m_aName));
TextRender()->TextColor(gs_HighlightedTextColor); TextRender()->TextColor(gs_HighlightedTextColor);
UI()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_NAME_2), &Button, pFilteredStr, FontSize, TEXTALIGN_ML, Props, FilterLen, &pUiElement->Rect(UI_ELEM_NAME_1)->m_Cursor); Ui()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_NAME_2), &Button, pFilteredStr, FontSize, TEXTALIGN_ML, Props, FilterLen, &pUiElement->Rect(UI_ELEM_NAME_1)->m_Cursor);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
UI()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_NAME_3), &Button, pFilteredStr + FilterLen, FontSize, TEXTALIGN_ML, Props, -1, &pUiElement->Rect(UI_ELEM_NAME_2)->m_Cursor); Ui()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_NAME_3), &Button, pFilteredStr + FilterLen, FontSize, TEXTALIGN_ML, Props, -1, &pUiElement->Rect(UI_ELEM_NAME_2)->m_Cursor);
}); });
if(!Printed) if(!Printed)
UI()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_NAME_1), &Button, pItem->m_aName, FontSize, TEXTALIGN_ML, Props); Ui()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_NAME_1), &Button, pItem->m_aName, FontSize, TEXTALIGN_ML, Props);
} }
else if(ID == COL_GAMETYPE) else if(Id == COL_GAMETYPE)
{ {
SLabelProperties Props; SLabelProperties Props;
Props.m_MaxWidth = Button.w; Props.m_MaxWidth = Button.w;
@ -353,10 +353,10 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
{ {
TextRender()->TextColor(GetGametypeTextColor(pItem->m_aGameType)); TextRender()->TextColor(GetGametypeTextColor(pItem->m_aGameType));
} }
UI()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_GAMETYPE), &Button, pItem->m_aGameType, FontSize, TEXTALIGN_ML, Props); Ui()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_GAMETYPE), &Button, pItem->m_aGameType, FontSize, TEXTALIGN_ML, Props);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
} }
else if(ID == COL_MAP) else if(Id == COL_MAP)
{ {
{ {
CUIRect Icon; CUIRect Icon;
@ -376,16 +376,16 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
bool Printed = false; bool Printed = false;
if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit & IServerBrowser::QUICK_MAPNAME)) if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit & IServerBrowser::QUICK_MAPNAME))
Printed = PrintHighlighted(pItem->m_aMap, [&](const char *pFilteredStr, const int FilterLen) { Printed = PrintHighlighted(pItem->m_aMap, [&](const char *pFilteredStr, const int FilterLen) {
UI()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_MAP_1), &Button, pItem->m_aMap, FontSize, TEXTALIGN_ML, Props, (int)(pFilteredStr - pItem->m_aMap)); Ui()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_MAP_1), &Button, pItem->m_aMap, FontSize, TEXTALIGN_ML, Props, (int)(pFilteredStr - pItem->m_aMap));
TextRender()->TextColor(gs_HighlightedTextColor); TextRender()->TextColor(gs_HighlightedTextColor);
UI()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_MAP_2), &Button, pFilteredStr, FontSize, TEXTALIGN_ML, Props, FilterLen, &pUiElement->Rect(UI_ELEM_MAP_1)->m_Cursor); Ui()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_MAP_2), &Button, pFilteredStr, FontSize, TEXTALIGN_ML, Props, FilterLen, &pUiElement->Rect(UI_ELEM_MAP_1)->m_Cursor);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
UI()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_MAP_3), &Button, pFilteredStr + FilterLen, FontSize, TEXTALIGN_ML, Props, -1, &pUiElement->Rect(UI_ELEM_MAP_2)->m_Cursor); Ui()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_MAP_3), &Button, pFilteredStr + FilterLen, FontSize, TEXTALIGN_ML, Props, -1, &pUiElement->Rect(UI_ELEM_MAP_2)->m_Cursor);
}); });
if(!Printed) if(!Printed)
UI()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_MAP_1), &Button, pItem->m_aMap, FontSize, TEXTALIGN_ML, Props); Ui()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_MAP_1), &Button, pItem->m_aMap, FontSize, TEXTALIGN_ML, Props);
} }
else if(ID == COL_FRIENDS) else if(Id == COL_FRIENDS)
{ {
if(pItem->m_FriendState != IFriends::FRIEND_NO) if(pItem->m_FriendState != IFriends::FRIEND_NO)
{ {
@ -395,22 +395,22 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
{ {
str_from_int(pItem->m_FriendNum, aTemp); str_from_int(pItem->m_FriendNum, aTemp);
TextRender()->TextColor(0.94f, 0.8f, 0.8f, 1.0f); TextRender()->TextColor(0.94f, 0.8f, 0.8f, 1.0f);
UI()->DoLabel(&Button, aTemp, 9.0f, TEXTALIGN_MC); Ui()->DoLabel(&Button, aTemp, 9.0f, TEXTALIGN_MC);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
} }
} }
} }
else if(ID == COL_PLAYERS) else if(Id == COL_PLAYERS)
{ {
str_format(aTemp, sizeof(aTemp), "%i/%i", pItem->m_NumFilteredPlayers, ServerBrowser()->Max(*pItem)); str_format(aTemp, sizeof(aTemp), "%i/%i", pItem->m_NumFilteredPlayers, ServerBrowser()->Max(*pItem));
if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit & IServerBrowser::QUICK_PLAYER)) if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit & IServerBrowser::QUICK_PLAYER))
{ {
TextRender()->TextColor(gs_HighlightedTextColor); TextRender()->TextColor(gs_HighlightedTextColor);
} }
UI()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_PLAYERS), &Button, aTemp, FontSize, TEXTALIGN_MR); Ui()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_PLAYERS), &Button, aTemp, FontSize, TEXTALIGN_MR);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
} }
else if(ID == COL_PING) else if(Id == COL_PING)
{ {
Button.VMargin(4.0f, &Button); Button.VMargin(4.0f, &Button);
FormatServerbrowserPing(aTemp, pItem); FormatServerbrowserPing(aTemp, pItem);
@ -418,7 +418,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View, bool &WasListboxItemAct
{ {
TextRender()->TextColor(GetPingTextColor(pItem->m_Latency)); TextRender()->TextColor(GetPingTextColor(pItem->m_Latency));
} }
UI()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_PING), &Button, aTemp, FontSize, TEXTALIGN_MR); Ui()->DoLabelStreamed(*pUiElement->Rect(UI_ELEM_PING), &Button, aTemp, FontSize, TEXTALIGN_MR);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
} }
} }
@ -489,7 +489,7 @@ void CMenus::RenderServerbrowserStatusBox(CUIRect StatusBox, bool WasListboxItem
{ {
TextRender()->SetFontPreset(EFontPreset::ICON_FONT); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 16.0f, TEXTALIGN_ML); Ui()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 16.0f, TEXTALIGN_ML);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
QuickSearch.VSplitLeft(ExcludeSearchIconMax, nullptr, &QuickSearch); QuickSearch.VSplitLeft(ExcludeSearchIconMax, nullptr, &QuickSearch);
@ -497,17 +497,17 @@ void CMenus::RenderServerbrowserStatusBox(CUIRect StatusBox, bool WasListboxItem
char aBufSearch[64]; char aBufSearch[64];
str_format(aBufSearch, sizeof(aBufSearch), "%s:", Localize("Search")); str_format(aBufSearch, sizeof(aBufSearch), "%s:", Localize("Search"));
UI()->DoLabel(&QuickSearch, aBufSearch, 14.0f, TEXTALIGN_ML); Ui()->DoLabel(&QuickSearch, aBufSearch, 14.0f, TEXTALIGN_ML);
QuickSearch.VSplitLeft(SearchExcludeAddrStrMax, nullptr, &QuickSearch); QuickSearch.VSplitLeft(SearchExcludeAddrStrMax, nullptr, &QuickSearch);
QuickSearch.VSplitLeft(5.0f, nullptr, &QuickSearch); QuickSearch.VSplitLeft(5.0f, nullptr, &QuickSearch);
static CLineInput s_FilterInput(g_Config.m_BrFilterString, sizeof(g_Config.m_BrFilterString)); static CLineInput s_FilterInput(g_Config.m_BrFilterString, sizeof(g_Config.m_BrFilterString));
if(!UI()->IsPopupOpen() && Input()->KeyPress(KEY_F) && Input()->ModifierIsPressed()) if(!Ui()->IsPopupOpen() && Input()->KeyPress(KEY_F) && Input()->ModifierIsPressed())
{ {
UI()->SetActiveItem(&s_FilterInput); Ui()->SetActiveItem(&s_FilterInput);
s_FilterInput.SelectAll(); s_FilterInput.SelectAll();
} }
if(UI()->DoClearableEditBox(&s_FilterInput, &QuickSearch, 12.0f)) if(Ui()->DoClearableEditBox(&s_FilterInput, &QuickSearch, 12.0f))
Client()->ServerBrowserUpdate(); Client()->ServerBrowserUpdate();
} }
@ -515,7 +515,7 @@ void CMenus::RenderServerbrowserStatusBox(CUIRect StatusBox, bool WasListboxItem
{ {
TextRender()->SetFontPreset(EFontPreset::ICON_FONT); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
UI()->DoLabel(&QuickExclude, FONT_ICON_BAN, 16.0f, TEXTALIGN_ML); Ui()->DoLabel(&QuickExclude, FONT_ICON_BAN, 16.0f, TEXTALIGN_ML);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
QuickExclude.VSplitLeft(ExcludeSearchIconMax, nullptr, &QuickExclude); QuickExclude.VSplitLeft(ExcludeSearchIconMax, nullptr, &QuickExclude);
@ -523,17 +523,17 @@ void CMenus::RenderServerbrowserStatusBox(CUIRect StatusBox, bool WasListboxItem
char aBufExclude[64]; char aBufExclude[64];
str_format(aBufExclude, sizeof(aBufExclude), "%s:", Localize("Exclude")); str_format(aBufExclude, sizeof(aBufExclude), "%s:", Localize("Exclude"));
UI()->DoLabel(&QuickExclude, aBufExclude, 14.0f, TEXTALIGN_ML); Ui()->DoLabel(&QuickExclude, aBufExclude, 14.0f, TEXTALIGN_ML);
QuickExclude.VSplitLeft(SearchExcludeAddrStrMax, nullptr, &QuickExclude); QuickExclude.VSplitLeft(SearchExcludeAddrStrMax, nullptr, &QuickExclude);
QuickExclude.VSplitLeft(5.0f, nullptr, &QuickExclude); QuickExclude.VSplitLeft(5.0f, nullptr, &QuickExclude);
static CLineInput s_ExcludeInput(g_Config.m_BrExcludeString, sizeof(g_Config.m_BrExcludeString)); static CLineInput s_ExcludeInput(g_Config.m_BrExcludeString, sizeof(g_Config.m_BrExcludeString));
if(!UI()->IsPopupOpen() && Input()->KeyPress(KEY_X) && Input()->ShiftIsPressed() && Input()->ModifierIsPressed()) if(!Ui()->IsPopupOpen() && Input()->KeyPress(KEY_X) && Input()->ShiftIsPressed() && Input()->ModifierIsPressed())
{ {
UI()->SetActiveItem(&s_ExcludeInput); Ui()->SetActiveItem(&s_ExcludeInput);
s_ExcludeInput.SelectAll(); s_ExcludeInput.SelectAll();
} }
if(UI()->DoClearableEditBox(&s_ExcludeInput, &QuickExclude, 12.0f)) if(Ui()->DoClearableEditBox(&s_ExcludeInput, &QuickExclude, 12.0f))
Client()->ServerBrowserUpdate(); Client()->ServerBrowserUpdate();
} }
@ -547,13 +547,13 @@ void CMenus::RenderServerbrowserStatusBox(CUIRect StatusBox, bool WasListboxItem
str_format(aBuf, sizeof(aBuf), Localize("%d of %d servers"), ServerBrowser()->NumSortedServers(), ServerBrowser()->NumServers()); str_format(aBuf, sizeof(aBuf), Localize("%d of %d servers"), ServerBrowser()->NumSortedServers(), ServerBrowser()->NumServers());
else else
str_format(aBuf, sizeof(aBuf), Localize("%d of %d server"), ServerBrowser()->NumSortedServers(), ServerBrowser()->NumServers()); str_format(aBuf, sizeof(aBuf), Localize("%d of %d server"), ServerBrowser()->NumSortedServers(), ServerBrowser()->NumServers());
UI()->DoLabel(&ServersOnline, aBuf, 12.0f, TEXTALIGN_MR); Ui()->DoLabel(&ServersOnline, aBuf, 12.0f, TEXTALIGN_MR);
if(ServerBrowser()->NumSortedPlayers() != 1) if(ServerBrowser()->NumSortedPlayers() != 1)
str_format(aBuf, sizeof(aBuf), Localize("%d players"), ServerBrowser()->NumSortedPlayers()); str_format(aBuf, sizeof(aBuf), Localize("%d players"), ServerBrowser()->NumSortedPlayers());
else else
str_format(aBuf, sizeof(aBuf), Localize("%d player"), ServerBrowser()->NumSortedPlayers()); str_format(aBuf, sizeof(aBuf), Localize("%d player"), ServerBrowser()->NumSortedPlayers());
UI()->DoLabel(&PlayersOnline, aBuf, 12.0f, TEXTALIGN_MR); Ui()->DoLabel(&PlayersOnline, aBuf, 12.0f, TEXTALIGN_MR);
} }
// address info // address info
@ -562,9 +562,9 @@ void CMenus::RenderServerbrowserStatusBox(CUIRect StatusBox, bool WasListboxItem
ServerAddr.Margin(2.0f, &ServerAddr); ServerAddr.Margin(2.0f, &ServerAddr);
ServerAddr.VSplitLeft(SearchExcludeAddrStrMax + 5.0f + ExcludeSearchIconMax + 5.0f, &ServerAddrLabel, &ServerAddrEditBox); ServerAddr.VSplitLeft(SearchExcludeAddrStrMax + 5.0f + ExcludeSearchIconMax + 5.0f, &ServerAddrLabel, &ServerAddrEditBox);
UI()->DoLabel(&ServerAddrLabel, Localize("Server address:"), 14.0f, TEXTALIGN_ML); Ui()->DoLabel(&ServerAddrLabel, Localize("Server address:"), 14.0f, TEXTALIGN_ML);
static CLineInput s_ServerAddressInput(g_Config.m_UiServerAddress, sizeof(g_Config.m_UiServerAddress)); static CLineInput s_ServerAddressInput(g_Config.m_UiServerAddress, sizeof(g_Config.m_UiServerAddress));
if(UI()->DoClearableEditBox(&s_ServerAddressInput, &ServerAddrEditBox, 12.0f)) if(Ui()->DoClearableEditBox(&s_ServerAddressInput, &ServerAddrEditBox, 12.0f))
m_ServerBrowserShouldRevealSelection = true; m_ServerBrowserShouldRevealSelection = true;
} }
@ -589,7 +589,7 @@ void CMenus::RenderServerbrowserStatusBox(CUIRect StatusBox, bool WasListboxItem
Props.m_UseIconFont = true; Props.m_UseIconFont = true;
static CButtonContainer s_RefreshButton; static CButtonContainer s_RefreshButton;
if(UI()->DoButton_Menu(m_RefreshButton, &s_RefreshButton, RefreshLabelFunc, &ButtonRefresh, Props) || (!UI()->IsPopupOpen() && (Input()->KeyPress(KEY_F5) || (Input()->KeyPress(KEY_R) && Input()->ModifierIsPressed())))) if(Ui()->DoButton_Menu(m_RefreshButton, &s_RefreshButton, RefreshLabelFunc, &ButtonRefresh, Props) || (!Ui()->IsPopupOpen() && (Input()->KeyPress(KEY_F5) || (Input()->KeyPress(KEY_R) && Input()->ModifierIsPressed()))))
{ {
RefreshBrowserTab(g_Config.m_UiPage); RefreshBrowserTab(g_Config.m_UiPage);
} }
@ -604,7 +604,7 @@ void CMenus::RenderServerbrowserStatusBox(CUIRect StatusBox, bool WasListboxItem
Props.m_Color = ColorRGBA(0.5f, 1.0f, 0.5f, 0.5f); Props.m_Color = ColorRGBA(0.5f, 1.0f, 0.5f, 0.5f);
static CButtonContainer s_ConnectButton; static CButtonContainer s_ConnectButton;
if(UI()->DoButton_Menu(m_ConnectButton, &s_ConnectButton, ConnectLabelFunc, &ButtonConnect, Props) || WasListboxItemActivated || (!UI()->IsPopupOpen() && UI()->ConsumeHotkey(CUI::HOTKEY_ENTER))) if(Ui()->DoButton_Menu(m_ConnectButton, &s_ConnectButton, ConnectLabelFunc, &ButtonConnect, Props) || WasListboxItemActivated || (!Ui()->IsPopupOpen() && Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER)))
{ {
Connect(g_Config.m_UiServerAddress); Connect(g_Config.m_UiServerAddress);
} }
@ -631,7 +631,7 @@ void CMenus::PopupConfirmSwitchServer()
void CMenus::RenderServerbrowserFilters(CUIRect View) void CMenus::RenderServerbrowserFilters(CUIRect View)
{ {
const float RowHeight = 18.0f; const float RowHeight = 18.0f;
const float FontSize = (RowHeight - 4.0f) * CUI::ms_FontmodHeight; // based on DoButton_CheckBox const float FontSize = (RowHeight - 4.0f) * CUi::ms_FontmodHeight; // based on DoButton_CheckBox
View.Draw(ColorRGBA(0.0f, 0.0f, 0.0f, 0.15f), IGraphics::CORNER_B, 4.0f); View.Draw(ColorRGBA(0.0f, 0.0f, 0.0f, 0.15f), IGraphics::CORNER_B, 4.0f);
View.Margin(5.0f, &View); View.Margin(5.0f, &View);
@ -666,20 +666,20 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
View.HSplitTop(3.0f, nullptr, &View); View.HSplitTop(3.0f, nullptr, &View);
View.HSplitTop(RowHeight, &Button, &View); View.HSplitTop(RowHeight, &Button, &View);
UI()->DoLabel(&Button, Localize("Game types:"), FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Button, Localize("Game types:"), FontSize, TEXTALIGN_ML);
Button.VSplitRight(60.0f, nullptr, &Button); Button.VSplitRight(60.0f, nullptr, &Button);
static CLineInput s_GametypeInput(g_Config.m_BrFilterGametype, sizeof(g_Config.m_BrFilterGametype)); static CLineInput s_GametypeInput(g_Config.m_BrFilterGametype, sizeof(g_Config.m_BrFilterGametype));
if(UI()->DoEditBox(&s_GametypeInput, &Button, FontSize)) if(Ui()->DoEditBox(&s_GametypeInput, &Button, FontSize))
Client()->ServerBrowserUpdate(); Client()->ServerBrowserUpdate();
// server address // server address
View.HSplitTop(6.0f, nullptr, &View); View.HSplitTop(6.0f, nullptr, &View);
View.HSplitTop(RowHeight, &Button, &View); View.HSplitTop(RowHeight, &Button, &View);
View.HSplitTop(6.0f, nullptr, &View); View.HSplitTop(6.0f, nullptr, &View);
UI()->DoLabel(&Button, Localize("Server address:"), FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Button, Localize("Server address:"), FontSize, TEXTALIGN_ML);
Button.VSplitRight(60.0f, nullptr, &Button); Button.VSplitRight(60.0f, nullptr, &Button);
static CLineInput s_FilterServerAddressInput(g_Config.m_BrFilterServerAddress, sizeof(g_Config.m_BrFilterServerAddress)); static CLineInput s_FilterServerAddressInput(g_Config.m_BrFilterServerAddress, sizeof(g_Config.m_BrFilterServerAddress));
if(UI()->DoEditBox(&s_FilterServerAddressInput, &Button, FontSize)) if(Ui()->DoEditBox(&s_FilterServerAddressInput, &Button, FontSize))
Client()->ServerBrowserUpdate(); Client()->ServerBrowserUpdate();
// player country // player country
@ -693,16 +693,16 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
const float OldWidth = Flag.w; const float OldWidth = Flag.w;
Flag.w = Flag.h * 2.0f; Flag.w = Flag.h * 2.0f;
Flag.x += (OldWidth - Flag.w) / 2.0f; Flag.x += (OldWidth - Flag.w) / 2.0f;
m_pClient->m_CountryFlags.Render(g_Config.m_BrFilterCountryIndex, ColorRGBA(1.0f, 1.0f, 1.0f, UI()->HotItem() == &g_Config.m_BrFilterCountryIndex ? 1.0f : g_Config.m_BrFilterCountry ? 0.9f : 0.5f), Flag.x, Flag.y, Flag.w, Flag.h); m_pClient->m_CountryFlags.Render(g_Config.m_BrFilterCountryIndex, ColorRGBA(1.0f, 1.0f, 1.0f, Ui()->HotItem() == &g_Config.m_BrFilterCountryIndex ? 1.0f : g_Config.m_BrFilterCountry ? 0.9f : 0.5f), Flag.x, Flag.y, Flag.w, Flag.h);
if(UI()->DoButtonLogic(&g_Config.m_BrFilterCountryIndex, 0, &Flag)) if(Ui()->DoButtonLogic(&g_Config.m_BrFilterCountryIndex, 0, &Flag))
{ {
static SPopupMenuId s_PopupCountryId; static SPopupMenuId s_PopupCountryId;
static SPopupCountrySelectionContext s_PopupCountryContext; static SPopupCountrySelectionContext s_PopupCountryContext;
s_PopupCountryContext.m_pMenus = this; s_PopupCountryContext.m_pMenus = this;
s_PopupCountryContext.m_Selection = g_Config.m_BrFilterCountryIndex; s_PopupCountryContext.m_Selection = g_Config.m_BrFilterCountryIndex;
s_PopupCountryContext.m_New = true; s_PopupCountryContext.m_New = true;
UI()->DoPopupMenu(&s_PopupCountryId, Flag.x, Flag.y + Flag.h, 490, 210, &s_PopupCountryContext, PopupCountrySelection); Ui()->DoPopupMenu(&s_PopupCountryId, Flag.x, Flag.y + Flag.h, 490, 210, &s_PopupCountryContext, PopupCountrySelection);
} }
} }
@ -851,7 +851,7 @@ void CMenus::RenderServerbrowserDDNetFilter(CUIRect View,
const char *pName = GetItemName(ItemIndex); const char *pName = GetItemName(ItemIndex);
const bool Active = !Filter.Filtered(pName); const bool Active = !Filter.Filtered(pName);
const int Click = UI()->DoButtonLogic(pItemId, 0, &Item); const int Click = Ui()->DoButtonLogic(pItemId, 0, &Item);
if(Click == 1 || Click == 2) if(Click == 1 || Click == 2)
{ {
// left/right click to toggle filter // left/right click to toggle filter
@ -914,7 +914,7 @@ void CMenus::RenderServerbrowserDDNetFilter(CUIRect View,
UpdateCommunityCache(true); UpdateCommunityCache(true);
} }
if(UI()->HotItem() == pItemId && !ScrollRegion.Animating()) if(Ui()->HotItem() == pItemId && !ScrollRegion.Animating())
Item.Draw(ColorRGBA(1.0f, 1.0f, 1.0f, 0.33f), IGraphics::CORNER_ALL, 2.0f); Item.Draw(ColorRGBA(1.0f, 1.0f, 1.0f, 0.33f), IGraphics::CORNER_ALL, 2.0f);
RenderItem(ItemIndex, Item, pItemId, Active); RenderItem(ItemIndex, Item, pItemId, Active);
} }
@ -927,7 +927,7 @@ void CMenus::RenderServerbrowserCommunitiesFilter(CUIRect View)
CUIRect Tab; CUIRect Tab;
View.HSplitTop(19.0f, &Tab, &View); View.HSplitTop(19.0f, &Tab, &View);
Tab.Draw(ColorRGBA(0.0f, 0.0f, 0.0f, 0.3f), IGraphics::CORNER_T, 4.0f); Tab.Draw(ColorRGBA(0.0f, 0.0f, 0.0f, 0.3f), IGraphics::CORNER_T, 4.0f);
UI()->DoLabel(&Tab, Localize("Communities"), 12.0f, TEXTALIGN_MC); Ui()->DoLabel(&Tab, Localize("Communities"), 12.0f, TEXTALIGN_MC);
View.Draw(ColorRGBA(0.0f, 0.0f, 0.0f, 0.15f), IGraphics::CORNER_B, 4.0f); View.Draw(ColorRGBA(0.0f, 0.0f, 0.0f, 0.15f), IGraphics::CORNER_B, 4.0f);
const int MaxEntries = ServerBrowser()->Communities().size(); const int MaxEntries = ServerBrowser()->Communities().size();
@ -947,7 +947,7 @@ void CMenus::RenderServerbrowserCommunitiesFilter(CUIRect View)
return ServerBrowser()->Communities()[ItemIndex].Name(); return ServerBrowser()->Communities()[ItemIndex].Name();
}; };
const auto &&RenderItem = [&](int ItemIndex, CUIRect Item, const void *pItemId, bool Active) { const auto &&RenderItem = [&](int ItemIndex, CUIRect Item, const void *pItemId, bool Active) {
const float Alpha = (Active ? 0.9f : 0.2f) + (UI()->HotItem() == pItemId ? 0.1f : 0.0f); const float Alpha = (Active ? 0.9f : 0.2f) + (Ui()->HotItem() == pItemId ? 0.1f : 0.0f);
CUIRect Icon, Label, FavoriteButton; CUIRect Icon, Label, FavoriteButton;
Item.VSplitRight(Item.h, &Item, &FavoriteButton); Item.VSplitRight(Item.h, &Item, &FavoriteButton);
@ -963,7 +963,7 @@ void CMenus::RenderServerbrowserCommunitiesFilter(CUIRect View)
} }
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha); TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
UI()->DoLabel(&Label, GetItemDisplayName(ItemIndex), Label.h * CUI::ms_FontmodHeight, TEXTALIGN_ML); Ui()->DoLabel(&Label, GetItemDisplayName(ItemIndex), Label.h * CUi::ms_FontmodHeight, TEXTALIGN_ML);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
const bool Favorite = ServerBrowser()->FavoriteCommunitiesFilter().Filtered(pItemName); const bool Favorite = ServerBrowser()->FavoriteCommunitiesFilter().Filtered(pItemName);
@ -1003,7 +1003,7 @@ void CMenus::RenderServerbrowserCountriesFilter(CUIRect View)
const float OldWidth = Item.w; const float OldWidth = Item.w;
Item.w = Item.h * 2.0f; Item.w = Item.h * 2.0f;
Item.x += (OldWidth - Item.w) / 2.0f; Item.x += (OldWidth - Item.w) / 2.0f;
m_pClient->m_CountryFlags.Render(m_CommunityCache.m_vpSelectableCountries[ItemIndex]->FlagId(), ColorRGBA(1.0f, 1.0f, 1.0f, (Active ? 0.9f : 0.2f) + (UI()->HotItem() == pItemId ? 0.1f : 0.0f)), Item.x, Item.y, Item.w, Item.h); m_pClient->m_CountryFlags.Render(m_CommunityCache.m_vpSelectableCountries[ItemIndex]->FlagId(), ColorRGBA(1.0f, 1.0f, 1.0f, (Active ? 0.9f : 0.2f) + (Ui()->HotItem() == pItemId ? 0.1f : 0.0f)), Item.x, Item.y, Item.w, Item.h);
}; };
RenderServerbrowserDDNetFilter(View, ServerBrowser()->CountriesFilter(), ItemHeight + 2.0f * Spacing, MaxEntries, EntriesPerRow, s_ScrollRegion, s_vItemIds, false, GetItemName, RenderItem); RenderServerbrowserDDNetFilter(View, ServerBrowser()->CountriesFilter(), ItemHeight + 2.0f * Spacing, MaxEntries, EntriesPerRow, s_ScrollRegion, s_vItemIds, false, GetItemName, RenderItem);
@ -1025,15 +1025,15 @@ void CMenus::RenderServerbrowserTypesFilter(CUIRect View)
}; };
const auto &&RenderItem = [&](int ItemIndex, CUIRect Item, const void *pItemId, bool Active) { const auto &&RenderItem = [&](int ItemIndex, CUIRect Item, const void *pItemId, bool Active) {
Item.Margin(Spacing, &Item); Item.Margin(Spacing, &Item);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, (Active ? 0.9f : 0.2f) + (UI()->HotItem() == pItemId ? 0.1f : 0.0f)); TextRender()->TextColor(1.0f, 1.0f, 1.0f, (Active ? 0.9f : 0.2f) + (Ui()->HotItem() == pItemId ? 0.1f : 0.0f));
UI()->DoLabel(&Item, GetItemName(ItemIndex), Item.h * CUI::ms_FontmodHeight, TEXTALIGN_MC); Ui()->DoLabel(&Item, GetItemName(ItemIndex), Item.h * CUi::ms_FontmodHeight, TEXTALIGN_MC);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
}; };
RenderServerbrowserDDNetFilter(View, ServerBrowser()->TypesFilter(), ItemHeight + 2.0f * Spacing, MaxEntries, EntriesPerRow, s_ScrollRegion, s_vItemIds, false, GetItemName, RenderItem); RenderServerbrowserDDNetFilter(View, ServerBrowser()->TypesFilter(), ItemHeight + 2.0f * Spacing, MaxEntries, EntriesPerRow, s_ScrollRegion, s_vItemIds, false, GetItemName, RenderItem);
} }
CUI::EPopupMenuFunctionResult CMenus::PopupCountrySelection(void *pContext, CUIRect View, bool Active) CUi::EPopupMenuFunctionResult CMenus::PopupCountrySelection(void *pContext, CUIRect View, bool Active)
{ {
SPopupCountrySelectionContext *pPopupContext = static_cast<SPopupCountrySelectionContext *>(pContext); SPopupCountrySelectionContext *pPopupContext = static_cast<SPopupCountrySelectionContext *>(pContext);
CMenus *pMenus = pPopupContext->m_pMenus; CMenus *pMenus = pPopupContext->m_pMenus;
@ -1065,7 +1065,7 @@ CUI::EPopupMenuFunctionResult CMenus::PopupCountrySelection(void *pContext, CUIR
FlagRect.x += (OldWidth - FlagRect.w) / 2.0f; FlagRect.x += (OldWidth - FlagRect.w) / 2.0f;
pMenus->m_pClient->m_CountryFlags.Render(pEntry->m_CountryCode, ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f), FlagRect.x, FlagRect.y, FlagRect.w, FlagRect.h); pMenus->m_pClient->m_CountryFlags.Render(pEntry->m_CountryCode, ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f), FlagRect.x, FlagRect.y, FlagRect.w, FlagRect.h);
pMenus->UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, TEXTALIGN_MC); pMenus->Ui()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, TEXTALIGN_MC);
} }
const int NewSelected = s_ListBox.DoEnd(); const int NewSelected = s_ListBox.DoEnd();
@ -1075,10 +1075,10 @@ CUI::EPopupMenuFunctionResult CMenus::PopupCountrySelection(void *pContext, CUIR
g_Config.m_BrFilterCountry = 1; g_Config.m_BrFilterCountry = 1;
g_Config.m_BrFilterCountryIndex = pPopupContext->m_Selection; g_Config.m_BrFilterCountryIndex = pPopupContext->m_Selection;
pMenus->Client()->ServerBrowserUpdate(); pMenus->Client()->ServerBrowserUpdate();
return CUI::POPUP_CLOSE_CURRENT; return CUi::POPUP_CLOSE_CURRENT;
} }
return CUI::POPUP_KEEP_OPEN; return CUi::POPUP_KEEP_OPEN;
} }
void CMenus::RenderServerbrowserInfo(CUIRect View) void CMenus::RenderServerbrowserInfo(CUIRect View)
@ -1086,7 +1086,7 @@ void CMenus::RenderServerbrowserInfo(CUIRect View)
const CServerInfo *pSelectedServer = ServerBrowser()->SortedGet(m_SelectedIndex); const CServerInfo *pSelectedServer = ServerBrowser()->SortedGet(m_SelectedIndex);
const float RowHeight = 18.0f; const float RowHeight = 18.0f;
const float FontSize = (RowHeight - 4.0f) * CUI::ms_FontmodHeight; // based on DoButton_CheckBox const float FontSize = (RowHeight - 4.0f) * CUi::ms_FontmodHeight; // based on DoButton_CheckBox
CUIRect ServerDetails, Scoreboard; CUIRect ServerDetails, Scoreboard;
View.HSplitTop(4.0f * 15.0f + RowHeight + 2.0f * 5.0f + 2.0f * 2.0f, &ServerDetails, &Scoreboard); View.HSplitTop(4.0f * 15.0f + RowHeight + 2.0f * 5.0f + 2.0f * 2.0f, &ServerDetails, &Scoreboard);
@ -1148,30 +1148,30 @@ void CMenus::RenderServerbrowserInfo(CUIRect View)
ServerDetails.VSplitLeft(80.0f, &LeftColumn, &RightColumn); ServerDetails.VSplitLeft(80.0f, &LeftColumn, &RightColumn);
LeftColumn.HSplitTop(15.0f, &Row, &LeftColumn); LeftColumn.HSplitTop(15.0f, &Row, &LeftColumn);
UI()->DoLabel(&Row, Localize("Version"), FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Row, Localize("Version"), FontSize, TEXTALIGN_ML);
RightColumn.HSplitTop(15.0f, &Row, &RightColumn); RightColumn.HSplitTop(15.0f, &Row, &RightColumn);
UI()->DoLabel(&Row, pSelectedServer->m_aVersion, FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Row, pSelectedServer->m_aVersion, FontSize, TEXTALIGN_ML);
LeftColumn.HSplitTop(15.0f, &Row, &LeftColumn); LeftColumn.HSplitTop(15.0f, &Row, &LeftColumn);
UI()->DoLabel(&Row, Localize("Game type"), FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Row, Localize("Game type"), FontSize, TEXTALIGN_ML);
RightColumn.HSplitTop(15.0f, &Row, &RightColumn); RightColumn.HSplitTop(15.0f, &Row, &RightColumn);
UI()->DoLabel(&Row, pSelectedServer->m_aGameType, FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Row, pSelectedServer->m_aGameType, FontSize, TEXTALIGN_ML);
LeftColumn.HSplitTop(15.0f, &Row, &LeftColumn); LeftColumn.HSplitTop(15.0f, &Row, &LeftColumn);
UI()->DoLabel(&Row, Localize("Ping"), FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Row, Localize("Ping"), FontSize, TEXTALIGN_ML);
char aTemp[16]; char aTemp[16];
FormatServerbrowserPing(aTemp, pSelectedServer); FormatServerbrowserPing(aTemp, pSelectedServer);
RightColumn.HSplitTop(15.0f, &Row, &RightColumn); RightColumn.HSplitTop(15.0f, &Row, &RightColumn);
UI()->DoLabel(&Row, aTemp, FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Row, aTemp, FontSize, TEXTALIGN_ML);
RenderServerbrowserInfoScoreboard(Scoreboard, pSelectedServer); RenderServerbrowserInfoScoreboard(Scoreboard, pSelectedServer);
} }
else else
{ {
UI()->DoLabel(&ServerDetails, Localize("No server selected"), FontSize, TEXTALIGN_MC); Ui()->DoLabel(&ServerDetails, Localize("No server selected"), FontSize, TEXTALIGN_MC);
} }
} }
@ -1268,7 +1268,7 @@ void CMenus::RenderServerbrowserInfoScoreboard(CUIRect View, const CServerInfo *
} }
} }
UI()->DoLabel(&Score, aTemp, FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Score, aTemp, FontSize, TEXTALIGN_ML);
// render tee if available // render tee if available
if(CurrentClient.m_aSkin[0] != '\0') if(CurrentClient.m_aSkin[0] != '\0')
@ -1399,12 +1399,12 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
CUIRect Header, GroupIcon, GroupLabel; CUIRect Header, GroupIcon, GroupLabel;
List.HSplitTop(ms_ListheaderHeight, &Header, &List); List.HSplitTop(ms_ListheaderHeight, &Header, &List);
s_ScrollRegion.AddRect(Header); s_ScrollRegion.AddRect(Header);
Header.Draw(ColorRGBA(1.0f, 1.0f, 1.0f, UI()->HotItem() == &s_aListExtended[FriendType] ? 0.4f : 0.25f), IGraphics::CORNER_ALL, 5.0f); Header.Draw(ColorRGBA(1.0f, 1.0f, 1.0f, Ui()->HotItem() == &s_aListExtended[FriendType] ? 0.4f : 0.25f), IGraphics::CORNER_ALL, 5.0f);
Header.VSplitLeft(Header.h, &GroupIcon, &GroupLabel); Header.VSplitLeft(Header.h, &GroupIcon, &GroupLabel);
GroupIcon.Margin(2.0f, &GroupIcon); GroupIcon.Margin(2.0f, &GroupIcon);
TextRender()->SetFontPreset(EFontPreset::ICON_FONT); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->TextColor(UI()->HotItem() == &s_aListExtended[FriendType] ? TextRender()->DefaultTextColor() : ColorRGBA(0.6f, 0.6f, 0.6f, 1.0f)); TextRender()->TextColor(Ui()->HotItem() == &s_aListExtended[FriendType] ? TextRender()->DefaultTextColor() : ColorRGBA(0.6f, 0.6f, 0.6f, 1.0f));
UI()->DoLabel(&GroupIcon, s_aListExtended[FriendType] ? FONT_ICON_SQUARE_MINUS : FONT_ICON_SQUARE_PLUS, GroupIcon.h * CUI::ms_FontmodHeight, TEXTALIGN_MC); Ui()->DoLabel(&GroupIcon, s_aListExtended[FriendType] ? FONT_ICON_SQUARE_MINUS : FONT_ICON_SQUARE_PLUS, GroupIcon.h * CUi::ms_FontmodHeight, TEXTALIGN_MC);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
switch(FriendType) switch(FriendType)
@ -1422,8 +1422,8 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
dbg_assert(false, "FriendType invalid"); dbg_assert(false, "FriendType invalid");
break; break;
} }
UI()->DoLabel(&GroupLabel, aBuf, FontSize, TEXTALIGN_ML); Ui()->DoLabel(&GroupLabel, aBuf, FontSize, TEXTALIGN_ML);
if(UI()->DoButtonLogic(&s_aListExtended[FriendType], 0, &Header)) if(Ui()->DoButtonLogic(&s_aListExtended[FriendType], 0, &Header))
{ {
s_aListExtended[FriendType] = !s_aListExtended[FriendType]; s_aListExtended[FriendType] = !s_aListExtended[FriendType];
} }
@ -1447,8 +1447,8 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
if(s_ScrollRegion.RectClipped(Rect)) if(s_ScrollRegion.RectClipped(Rect))
continue; continue;
const bool Inside = UI()->HotItem() == Friend.ListItemId() || UI()->HotItem() == Friend.RemoveButtonId() || UI()->HotItem() == Friend.CommunityTooltipId(); const bool Inside = Ui()->HotItem() == Friend.ListItemId() || Ui()->HotItem() == Friend.RemoveButtonId() || Ui()->HotItem() == Friend.CommunityTooltipId();
bool ButtonResult = UI()->DoButtonLogic(Friend.ListItemId(), 0, &Rect); bool ButtonResult = Ui()->DoButtonLogic(Friend.ListItemId(), 0, &Rect);
if(Friend.ServerInfo()) if(Friend.ServerInfo())
{ {
GameClient()->m_Tooltips.DoToolTip(Friend.ListItemId(), &Rect, Localize("Click to select server. Double click to join your friend.")); GameClient()->m_Tooltips.DoToolTip(Friend.ListItemId(), &Rect, Localize("Click to select server. Double click to join your friend."));
@ -1484,10 +1484,10 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
Rect.HSplitTop(11.0f, &NameLabel, &ClanLabel); Rect.HSplitTop(11.0f, &NameLabel, &ClanLabel);
// name // name
UI()->DoLabel(&NameLabel, Friend.Name(), FontSize - 1.0f, TEXTALIGN_ML); Ui()->DoLabel(&NameLabel, Friend.Name(), FontSize - 1.0f, TEXTALIGN_ML);
// clan // clan
UI()->DoLabel(&ClanLabel, Friend.Clan(), FontSize - 2.0f, TEXTALIGN_ML); Ui()->DoLabel(&ClanLabel, Friend.Clan(), FontSize - 2.0f, TEXTALIGN_ML);
// server info // server info
if(Friend.ServerInfo()) if(Friend.ServerInfo())
@ -1503,7 +1503,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
InfoLabel.VSplitLeft(21.0f, &CommunityIcon, &InfoLabel); InfoLabel.VSplitLeft(21.0f, &CommunityIcon, &InfoLabel);
InfoLabel.VSplitLeft(2.0f, nullptr, &InfoLabel); InfoLabel.VSplitLeft(2.0f, nullptr, &InfoLabel);
RenderCommunityIcon(pIcon, CommunityIcon, true); RenderCommunityIcon(pIcon, CommunityIcon, true);
UI()->DoButtonLogic(Friend.CommunityTooltipId(), 0, &CommunityIcon); Ui()->DoButtonLogic(Friend.CommunityTooltipId(), 0, &CommunityIcon);
GameClient()->m_Tooltips.DoToolTip(Friend.CommunityTooltipId(), &CommunityIcon, pCommunity->Name()); GameClient()->m_Tooltips.DoToolTip(Friend.CommunityTooltipId(), &CommunityIcon, pCommunity->Name());
} }
} }
@ -1515,20 +1515,20 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
str_format(aBuf, sizeof(aBuf), "%s | %s | %s", Friend.ServerInfo()->m_aMap, Friend.ServerInfo()->m_aGameType, aLatency); str_format(aBuf, sizeof(aBuf), "%s | %s | %s", Friend.ServerInfo()->m_aMap, Friend.ServerInfo()->m_aGameType, aLatency);
else else
str_format(aBuf, sizeof(aBuf), "%s | %s", Friend.ServerInfo()->m_aMap, Friend.ServerInfo()->m_aGameType); str_format(aBuf, sizeof(aBuf), "%s | %s", Friend.ServerInfo()->m_aMap, Friend.ServerInfo()->m_aGameType);
UI()->DoLabel(&InfoLabel, aBuf, FontSize - 2.0f, TEXTALIGN_ML); Ui()->DoLabel(&InfoLabel, aBuf, FontSize - 2.0f, TEXTALIGN_ML);
} }
// remove button // remove button
if(Inside) if(Inside)
{ {
TextRender()->TextColor(UI()->HotItem() == Friend.RemoveButtonId() ? TextRender()->DefaultTextColor() : ColorRGBA(0.4f, 0.4f, 0.4f, 1.0f)); TextRender()->TextColor(Ui()->HotItem() == Friend.RemoveButtonId() ? TextRender()->DefaultTextColor() : ColorRGBA(0.4f, 0.4f, 0.4f, 1.0f));
TextRender()->SetFontPreset(EFontPreset::ICON_FONT); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
UI()->DoLabel(&RemoveButton, FONT_ICON_TRASH, RemoveButton.h * CUI::ms_FontmodHeight, TEXTALIGN_MC); Ui()->DoLabel(&RemoveButton, FONT_ICON_TRASH, RemoveButton.h * CUi::ms_FontmodHeight, TEXTALIGN_MC);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
if(UI()->DoButtonLogic(Friend.RemoveButtonId(), 0, &RemoveButton)) if(Ui()->DoButtonLogic(Friend.RemoveButtonId(), 0, &RemoveButton))
{ {
m_pRemoveFriend = &Friend; m_pRemoveFriend = &Friend;
ButtonResult = false; ButtonResult = false;
@ -1553,7 +1553,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
CUIRect Label; CUIRect Label;
List.HSplitTop(12.0f, &Label, &List); List.HSplitTop(12.0f, &Label, &List);
s_ScrollRegion.AddRect(Label); s_ScrollRegion.AddRect(Label);
UI()->DoLabel(&Label, Localize("None"), Label.h * CUI::ms_FontmodHeight, TEXTALIGN_ML); Ui()->DoLabel(&Label, Localize("None"), Label.h * CUi::ms_FontmodHeight, TEXTALIGN_ML);
} }
} }
@ -1583,18 +1583,18 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
ServerFriends.HSplitTop(18.0f, &Button, &ServerFriends); ServerFriends.HSplitTop(18.0f, &Button, &ServerFriends);
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Name")); str_format(aBuf, sizeof(aBuf), "%s:", Localize("Name"));
UI()->DoLabel(&Button, aBuf, FontSize + 2.0f, TEXTALIGN_ML); Ui()->DoLabel(&Button, aBuf, FontSize + 2.0f, TEXTALIGN_ML);
Button.VSplitLeft(80.0f, nullptr, &Button); Button.VSplitLeft(80.0f, nullptr, &Button);
static CLineInputBuffered<MAX_NAME_LENGTH> s_NameInput; static CLineInputBuffered<MAX_NAME_LENGTH> s_NameInput;
UI()->DoEditBox(&s_NameInput, &Button, FontSize + 2.0f); Ui()->DoEditBox(&s_NameInput, &Button, FontSize + 2.0f);
ServerFriends.HSplitTop(3.0f, nullptr, &ServerFriends); ServerFriends.HSplitTop(3.0f, nullptr, &ServerFriends);
ServerFriends.HSplitTop(18.0f, &Button, &ServerFriends); ServerFriends.HSplitTop(18.0f, &Button, &ServerFriends);
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Clan")); str_format(aBuf, sizeof(aBuf), "%s:", Localize("Clan"));
UI()->DoLabel(&Button, aBuf, FontSize + 2.0f, TEXTALIGN_ML); Ui()->DoLabel(&Button, aBuf, FontSize + 2.0f, TEXTALIGN_ML);
Button.VSplitLeft(80.0f, nullptr, &Button); Button.VSplitLeft(80.0f, nullptr, &Button);
static CLineInputBuffered<MAX_CLAN_LENGTH> s_ClanInput; static CLineInputBuffered<MAX_CLAN_LENGTH> s_ClanInput;
UI()->DoEditBox(&s_ClanInput, &Button, FontSize + 2.0f); Ui()->DoEditBox(&s_ClanInput, &Button, FontSize + 2.0f);
ServerFriends.HSplitTop(3.0f, nullptr, &ServerFriends); ServerFriends.HSplitTop(3.0f, nullptr, &ServerFriends);
ServerFriends.HSplitTop(18.0f, &Button, &ServerFriends); ServerFriends.HSplitTop(18.0f, &Button, &ServerFriends);
@ -1640,7 +1640,7 @@ void CMenus::RenderServerbrowserTabBar(CUIRect TabBar)
const ColorRGBA ColorActive = ColorRGBA(0.0f, 0.0f, 0.0f, 0.3f); const ColorRGBA ColorActive = ColorRGBA(0.0f, 0.0f, 0.0f, 0.3f);
const ColorRGBA ColorInactive = ColorRGBA(0.0f, 0.0f, 0.0f, 0.15f); const ColorRGBA ColorInactive = ColorRGBA(0.0f, 0.0f, 0.0f, 0.15f);
if(!UI()->IsPopupOpen() && UI()->ConsumeHotkey(CUI::HOTKEY_TAB)) if(!Ui()->IsPopupOpen() && Ui()->ConsumeHotkey(CUi::HOTKEY_TAB))
{ {
const int Direction = Input()->ShiftIsPressed() ? -1 : 1; const int Direction = Input()->ShiftIsPressed() ? -1 : 1;
g_Config.m_UiToolboxPage = (g_Config.m_UiToolboxPage + NUM_UI_TOOLBOX_PAGES + Direction) % NUM_UI_TOOLBOX_PAGES; g_Config.m_UiToolboxPage = (g_Config.m_UiToolboxPage + NUM_UI_TOOLBOX_PAGES + Direction) % NUM_UI_TOOLBOX_PAGES;

View file

@ -30,7 +30,7 @@ using namespace std::chrono_literals;
int CMenus::DoButton_FontIcon(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, bool Enabled) int CMenus::DoButton_FontIcon(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, bool Enabled)
{ {
pRect->Draw(ColorRGBA(1.0f, 1.0f, 1.0f, (Checked ? 0.10f : 0.5f) * UI()->ButtonColorMul(pButtonContainer)), Corners, 5.0f); pRect->Draw(ColorRGBA(1.0f, 1.0f, 1.0f, (Checked ? 0.10f : 0.5f) * Ui()->ButtonColorMul(pButtonContainer)), Corners, 5.0f);
TextRender()->SetFontPreset(EFontPreset::ICON_FONT); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING);
@ -38,13 +38,13 @@ int CMenus::DoButton_FontIcon(CButtonContainer *pButtonContainer, const char *pT
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
CUIRect Temp; CUIRect Temp;
pRect->HMargin(2.0f, &Temp); pRect->HMargin(2.0f, &Temp);
UI()->DoLabel(&Temp, pText, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_MC); Ui()->DoLabel(&Temp, pText, Temp.h * CUi::ms_FontmodHeight, TEXTALIGN_MC);
if(!Enabled) if(!Enabled)
{ {
TextRender()->TextColor(ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f)); TextRender()->TextColor(ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f));
TextRender()->TextOutlineColor(ColorRGBA(0.0f, 0.0f, 0.0f, 0.0f)); TextRender()->TextOutlineColor(ColorRGBA(0.0f, 0.0f, 0.0f, 0.0f));
UI()->DoLabel(&Temp, FONT_ICON_SLASH, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_MC); Ui()->DoLabel(&Temp, FONT_ICON_SLASH, Temp.h * CUi::ms_FontmodHeight, TEXTALIGN_MC);
TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor()); TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor());
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
} }
@ -52,7 +52,7 @@ int CMenus::DoButton_FontIcon(CButtonContainer *pButtonContainer, const char *pT
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
return UI()->DoButtonLogic(pButtonContainer, Checked, pRect); return Ui()->DoButtonLogic(pButtonContainer, Checked, pRect);
} }
bool CMenus::DemoFilterChat(const void *pData, int Size, void *pUser) bool CMenus::DemoFilterChat(const void *pData, int Size, void *pUser)
@ -169,7 +169,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
// handle keyboard shortcuts independent of active menu // handle keyboard shortcuts independent of active menu
float PositionToSeek = -1.0f; float PositionToSeek = -1.0f;
float TimeToSeek = 0.0f; float TimeToSeek = 0.0f;
if(m_pClient->m_GameConsole.IsClosed() && m_DemoPlayerState == DEMOPLAYER_NONE && g_Config.m_ClDemoKeyboardShortcuts && !UI()->IsPopupOpen()) if(m_pClient->m_GameConsole.IsClosed() && m_DemoPlayerState == DEMOPLAYER_NONE && g_Config.m_ClDemoKeyboardShortcuts && !Ui()->IsPopupOpen())
{ {
// increase/decrease speed // increase/decrease speed
if(!Input()->ModifierIsPressed() && !Input()->ShiftIsPressed() && !Input()->AltIsPressed()) if(!Input()->ModifierIsPressed() && !Input()->ShiftIsPressed() && !Input()->AltIsPressed())
@ -271,7 +271,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor().WithMultipliedAlpha(Alpha)); TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor().WithMultipliedAlpha(Alpha));
TextRender()->SetFontPreset(EFontPreset::ICON_FONT); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING);
UI()->DoLabel(UI()->Screen(), pInfo->m_Paused ? FONT_ICON_PAUSE : FONT_ICON_PLAY, 36.0f + Time * 12.0f, TEXTALIGN_MC); Ui()->DoLabel(Ui()->Screen(), pInfo->m_Paused ? FONT_ICON_PAUSE : FONT_ICON_PLAY, 36.0f + Time * 12.0f, TEXTALIGN_MC);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor()); TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor());
TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
@ -282,7 +282,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
// Render speed info // Render speed info
if(g_Config.m_ClDemoShowSpeed && Client()->GlobalTime() - m_LastSpeedChange < 1.0f) if(g_Config.m_ClDemoShowSpeed && Client()->GlobalTime() - m_LastSpeedChange < 1.0f)
{ {
CUIRect Screen = *UI()->Screen(); CUIRect Screen = *Ui()->Screen();
char aSpeedBuf[16]; char aSpeedBuf[16];
str_format(aSpeedBuf, sizeof(aSpeedBuf), "×%.2f", pInfo->m_Speed); str_format(aSpeedBuf, sizeof(aSpeedBuf), "×%.2f", pInfo->m_Speed);
@ -349,18 +349,18 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
bool Clicked; bool Clicked;
bool Abrupted; bool Abrupted;
if(int Result = UI()->DoDraggableButtonLogic(&s_Operation, 8, &DemoControlsDragRect, &Clicked, &Abrupted)) if(int Result = Ui()->DoDraggableButtonLogic(&s_Operation, 8, &DemoControlsDragRect, &Clicked, &Abrupted))
{ {
if(s_Operation == OP_NONE && Result == 1) if(s_Operation == OP_NONE && Result == 1)
{ {
s_InitialMouse = UI()->MousePos(); s_InitialMouse = Ui()->MousePos();
s_Operation = OP_CLICKED; s_Operation = OP_CLICKED;
} }
if(Clicked || Abrupted) if(Clicked || Abrupted)
s_Operation = OP_NONE; s_Operation = OP_NONE;
if(s_Operation == OP_CLICKED && length(UI()->MousePos() - s_InitialMouse) > 5.0f) if(s_Operation == OP_CLICKED && length(Ui()->MousePos() - s_InitialMouse) > 5.0f)
{ {
s_Operation = OP_DRAGGING; s_Operation = OP_DRAGGING;
s_InitialMouse -= m_DemoControlsPositionOffset; s_InitialMouse -= m_DemoControlsPositionOffset;
@ -368,7 +368,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
if(s_Operation == OP_DRAGGING) if(s_Operation == OP_DRAGGING)
{ {
m_DemoControlsPositionOffset = UI()->MousePos() - s_InitialMouse; m_DemoControlsPositionOffset = Ui()->MousePos() - s_InitialMouse;
m_DemoControlsPositionOffset.x = clamp(m_DemoControlsPositionOffset.x, -DemoControlsOriginal.x, MainView.w - DemoControlsDragRect.w - DemoControlsOriginal.x); m_DemoControlsPositionOffset.x = clamp(m_DemoControlsPositionOffset.x, -DemoControlsOriginal.x, MainView.w - DemoControlsDragRect.w - DemoControlsOriginal.x);
m_DemoControlsPositionOffset.y = clamp(m_DemoControlsPositionOffset.y, -DemoControlsOriginal.y, MainView.h - DemoControlsDragRect.h - DemoControlsOriginal.y); m_DemoControlsPositionOffset.y = clamp(m_DemoControlsPositionOffset.y, -DemoControlsOriginal.y, MainView.h - DemoControlsDragRect.h - DemoControlsOriginal.y);
} }
@ -379,8 +379,8 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
{ {
const float Rounding = 5.0f; const float Rounding = 5.0f;
static int s_SeekBarID = 0; static int s_SeekBarId = 0;
void *pId = &s_SeekBarID; void *pId = &s_SeekBarId;
char aBuffer[128]; char aBuffer[128];
// draw seek bar // draw seek bar
@ -413,7 +413,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
Graphics()->TextureClear(); Graphics()->TextureClear();
Graphics()->QuadsBegin(); Graphics()->QuadsBegin();
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
IGraphics::CQuadItem QuadItem(2 * Rounding + SeekBar.x + (SeekBar.w - 2 * Rounding) * Ratio, SeekBar.y, UI()->PixelSize(), SeekBar.h); IGraphics::CQuadItem QuadItem(2 * Rounding + SeekBar.x + (SeekBar.w - 2 * Rounding) * Ratio, SeekBar.y, Ui()->PixelSize(), SeekBar.h);
Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsDrawTL(&QuadItem, 1);
Graphics()->QuadsEnd(); Graphics()->QuadsEnd();
} }
@ -426,7 +426,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
Graphics()->TextureClear(); Graphics()->TextureClear();
Graphics()->QuadsBegin(); Graphics()->QuadsBegin();
Graphics()->SetColor(1.0f, 0.0f, 0.0f, 1.0f); Graphics()->SetColor(1.0f, 0.0f, 0.0f, 1.0f);
IGraphics::CQuadItem QuadItem(2 * Rounding + SeekBar.x + (SeekBar.w - 2 * Rounding) * Ratio, SeekBar.y, UI()->PixelSize(), SeekBar.h); IGraphics::CQuadItem QuadItem(2 * Rounding + SeekBar.x + (SeekBar.w - 2 * Rounding) * Ratio, SeekBar.y, Ui()->PixelSize(), SeekBar.h);
Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsDrawTL(&QuadItem, 1);
Graphics()->QuadsEnd(); Graphics()->QuadsEnd();
} }
@ -438,7 +438,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
Graphics()->TextureClear(); Graphics()->TextureClear();
Graphics()->QuadsBegin(); Graphics()->QuadsBegin();
Graphics()->SetColor(1.0f, 0.0f, 0.0f, 1.0f); Graphics()->SetColor(1.0f, 0.0f, 0.0f, 1.0f);
IGraphics::CQuadItem QuadItem(2 * Rounding + SeekBar.x + (SeekBar.w - 2 * Rounding) * Ratio, SeekBar.y, UI()->PixelSize(), SeekBar.h); IGraphics::CQuadItem QuadItem(2 * Rounding + SeekBar.x + (SeekBar.w - 2 * Rounding) * Ratio, SeekBar.y, Ui()->PixelSize(), SeekBar.h);
Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsDrawTL(&QuadItem, 1);
Graphics()->QuadsEnd(); Graphics()->QuadsEnd();
} }
@ -449,19 +449,19 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
char aTotalTime[32]; char aTotalTime[32];
str_time((int64_t)TotalTicks / Client()->GameTickSpeed() * 100, TIME_HOURS, aTotalTime, sizeof(aTotalTime)); str_time((int64_t)TotalTicks / Client()->GameTickSpeed() * 100, TIME_HOURS, aTotalTime, sizeof(aTotalTime));
str_format(aBuffer, sizeof(aBuffer), "%s / %s", aCurrentTime, aTotalTime); str_format(aBuffer, sizeof(aBuffer), "%s / %s", aCurrentTime, aTotalTime);
UI()->DoLabel(&SeekBar, aBuffer, SeekBar.h * 0.70f, TEXTALIGN_MC); Ui()->DoLabel(&SeekBar, aBuffer, SeekBar.h * 0.70f, TEXTALIGN_MC);
// do the logic // do the logic
const bool Inside = UI()->MouseInside(&SeekBar); const bool Inside = Ui()->MouseInside(&SeekBar);
if(UI()->CheckActiveItem(pId)) if(Ui()->CheckActiveItem(pId))
{ {
if(!UI()->MouseButton(0)) if(!Ui()->MouseButton(0))
UI()->SetActiveItem(nullptr); Ui()->SetActiveItem(nullptr);
else else
{ {
static float s_PrevAmount = 0.0f; static float s_PrevAmount = 0.0f;
float AmountSeek = clamp((UI()->MouseX() - SeekBar.x - Rounding) / (float)(SeekBar.w - 2 * Rounding), 0.0f, 1.0f); float AmountSeek = clamp((Ui()->MouseX() - SeekBar.x - Rounding) / (float)(SeekBar.w - 2 * Rounding), 0.0f, 1.0f);
if(Input()->ShiftIsPressed()) if(Input()->ShiftIsPressed())
{ {
@ -481,15 +481,15 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
} }
} }
} }
else if(UI()->HotItem() == pId) else if(Ui()->HotItem() == pId)
{ {
if(UI()->MouseButton(0)) if(Ui()->MouseButton(0))
{ {
UI()->SetActiveItem(pId); Ui()->SetActiveItem(pId);
} }
else else
{ {
const int HoveredTick = (int)(clamp((UI()->MouseX() - SeekBar.x - Rounding) / (float)(SeekBar.w - 2 * Rounding), 0.0f, 1.0f) * TotalTicks); const int HoveredTick = (int)(clamp((Ui()->MouseX() - SeekBar.x - Rounding) / (float)(SeekBar.w - 2 * Rounding), 0.0f, 1.0f) * TotalTicks);
static char s_aHoveredTime[32]; static char s_aHoveredTime[32];
str_time((int64_t)HoveredTick / Client()->GameTickSpeed() * 100, TIME_HOURS, s_aHoveredTime, sizeof(s_aHoveredTime)); str_time((int64_t)HoveredTick / Client()->GameTickSpeed() * 100, TIME_HOURS, s_aHoveredTime, sizeof(s_aHoveredTime));
GameClient()->m_Tooltips.DoToolTip(pId, &SeekBar, s_aHoveredTime); GameClient()->m_Tooltips.DoToolTip(pId, &SeekBar, s_aHoveredTime);
@ -497,7 +497,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
} }
if(Inside) if(Inside)
UI()->SetHotItem(pId); Ui()->SetHotItem(pId);
} }
bool IncreaseDemoSpeed = false, DecreaseDemoSpeed = false; bool IncreaseDemoSpeed = false, DecreaseDemoSpeed = false;
@ -565,10 +565,10 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
s_vpDurationNames[i] = s_vDurationNames[i].c_str(); s_vpDurationNames[i] = s_vDurationNames[i].c_str();
} }
static CUI::SDropDownState s_SkipDurationDropDownState; static CUi::SDropDownState s_SkipDurationDropDownState;
static CScrollRegion s_SkipDurationDropDownScrollRegion; static CScrollRegion s_SkipDurationDropDownScrollRegion;
s_SkipDurationDropDownState.m_SelectionPopupContext.m_pScrollRegion = &s_SkipDurationDropDownScrollRegion; s_SkipDurationDropDownState.m_SelectionPopupContext.m_pScrollRegion = &s_SkipDurationDropDownScrollRegion;
s_SkipDurationIndex = UI()->DoDropDown(&Button, s_SkipDurationIndex, s_vpDurationNames.data(), NumDurationLabels, s_SkipDurationDropDownState); s_SkipDurationIndex = Ui()->DoDropDown(&Button, s_SkipDurationIndex, s_vpDurationNames.data(), NumDurationLabels, s_SkipDurationDropDownState);
GameClient()->m_Tooltips.DoToolTip(&s_SkipDurationDropDownState.m_ButtonContainer, &Button, Localize("Change the skip duration")); GameClient()->m_Tooltips.DoToolTip(&s_SkipDurationDropDownState.m_ButtonContainer, &Button, Localize("Change the skip duration"));
} }
@ -642,7 +642,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
ButtonBar.VSplitLeft(Margins * 12, &SpeedBar, &ButtonBar); ButtonBar.VSplitLeft(Margins * 12, &SpeedBar, &ButtonBar);
char aBuffer[64]; char aBuffer[64];
str_format(aBuffer, sizeof(aBuffer), "×%g", pInfo->m_Speed); str_format(aBuffer, sizeof(aBuffer), "×%g", pInfo->m_Speed);
UI()->DoLabel(&SpeedBar, aBuffer, Button.h * 0.7f, TEXTALIGN_MC); Ui()->DoLabel(&SpeedBar, aBuffer, Button.h * 0.7f, TEXTALIGN_MC);
// slice begin button // slice begin button
ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar);
@ -691,7 +691,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
char aDemoName[IO_MAX_PATH_LENGTH]; char aDemoName[IO_MAX_PATH_LENGTH];
DemoPlayer()->GetDemoName(aDemoName, sizeof(aDemoName)); DemoPlayer()->GetDemoName(aDemoName, sizeof(aDemoName));
m_DemoSliceInput.Set(aDemoName); m_DemoSliceInput.Set(aDemoName);
UI()->SetActiveItem(&m_DemoSliceInput); Ui()->SetActiveItem(&m_DemoSliceInput);
m_DemoPlayerState = DEMOPLAYER_SLICE_SAVE; m_DemoPlayerState = DEMOPLAYER_SLICE_SAVE;
} }
GameClient()->m_Tooltips.DoToolTip(&s_SliceSaveButton, &Button, Localize("Export cut as a separate demo")); GameClient()->m_Tooltips.DoToolTip(&s_SliceSaveButton, &Button, Localize("Export cut as a separate demo"));
@ -725,7 +725,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
Props.m_MaxWidth = NameBar.w; Props.m_MaxWidth = NameBar.w;
Props.m_EllipsisAtEnd = true; Props.m_EllipsisAtEnd = true;
Props.m_EnableWidthCheck = false; Props.m_EnableWidthCheck = false;
UI()->DoLabel(&NameBar, aBuf, Button.h * 0.5f, TEXTALIGN_ML, Props); Ui()->DoLabel(&NameBar, aBuf, Button.h * 0.5f, TEXTALIGN_ML, Props);
if(IncreaseDemoSpeed) if(IncreaseDemoSpeed)
{ {
@ -744,14 +744,14 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
if(m_DemoPlayerState != DEMOPLAYER_NONE) if(m_DemoPlayerState != DEMOPLAYER_NONE)
{ {
// prevent element under the active popup from being activated // prevent element under the active popup from being activated
UI()->SetHotItem(nullptr); Ui()->SetHotItem(nullptr);
} }
if(m_DemoPlayerState == DEMOPLAYER_SLICE_SAVE) if(m_DemoPlayerState == DEMOPLAYER_SLICE_SAVE)
{ {
RenderDemoPlayerSliceSavePopup(MainView); RenderDemoPlayerSliceSavePopup(MainView);
} }
UI()->RenderPopupMenus(); Ui()->RenderPopupMenus();
} }
void CMenus::RenderDemoPlayerSliceSavePopup(CUIRect MainView) void CMenus::RenderDemoPlayerSliceSavePopup(CUIRect MainView)
@ -769,7 +769,7 @@ void CMenus::RenderDemoPlayerSliceSavePopup(CUIRect MainView)
CUIRect Title; CUIRect Title;
Box.HSplitTop(24.0f, &Title, &Box); Box.HSplitTop(24.0f, &Title, &Box);
Box.HSplitTop(20.0f, nullptr, &Box); Box.HSplitTop(20.0f, nullptr, &Box);
UI()->DoLabel(&Title, Localize("Export demo cut"), 24.0f, TEXTALIGN_MC); Ui()->DoLabel(&Title, Localize("Export demo cut"), 24.0f, TEXTALIGN_MC);
// slice times // slice times
CUIRect SliceTimesBar, SliceInterval, SliceLength; CUIRect SliceTimesBar, SliceInterval, SliceLength;
@ -786,9 +786,9 @@ void CMenus::RenderDemoPlayerSliceSavePopup(CUIRect MainView)
str_time((RealSliceEnd - RealSliceBegin) / Client()->GameTickSpeed() * 100, TIME_HOURS, aSliceLength, sizeof(aSliceLength)); str_time((RealSliceEnd - RealSliceBegin) / Client()->GameTickSpeed() * 100, TIME_HOURS, aSliceLength, sizeof(aSliceLength));
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "%s: %s %s", Localize("Cut interval"), aSliceBegin, aSliceEnd); str_format(aBuf, sizeof(aBuf), "%s: %s %s", Localize("Cut interval"), aSliceBegin, aSliceEnd);
UI()->DoLabel(&SliceInterval, aBuf, 18.0f, TEXTALIGN_ML); Ui()->DoLabel(&SliceInterval, aBuf, 18.0f, TEXTALIGN_ML);
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Cut length"), aSliceLength); str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Cut length"), aSliceLength);
UI()->DoLabel(&SliceLength, aBuf, 18.0f, TEXTALIGN_ML); Ui()->DoLabel(&SliceLength, aBuf, 18.0f, TEXTALIGN_ML);
// file name // file name
CUIRect NameLabel, NameBox; CUIRect NameLabel, NameBox;
@ -796,8 +796,8 @@ void CMenus::RenderDemoPlayerSliceSavePopup(CUIRect MainView)
Box.HSplitTop(20.0f, nullptr, &Box); Box.HSplitTop(20.0f, nullptr, &Box);
NameLabel.VSplitLeft(150.0f, &NameLabel, &NameBox); NameLabel.VSplitLeft(150.0f, &NameLabel, &NameBox);
NameBox.VSplitLeft(20.0f, nullptr, &NameBox); NameBox.VSplitLeft(20.0f, nullptr, &NameBox);
UI()->DoLabel(&NameLabel, Localize("New name:"), 18.0f, TEXTALIGN_ML); Ui()->DoLabel(&NameLabel, Localize("New name:"), 18.0f, TEXTALIGN_ML);
UI()->DoEditBox(&m_DemoSliceInput, &NameBox, 12.0f); Ui()->DoEditBox(&m_DemoSliceInput, &NameBox, 12.0f);
// remove chat checkbox // remove chat checkbox
static int s_RemoveChat = 0; static int s_RemoveChat = 0;
@ -824,12 +824,12 @@ void CMenus::RenderDemoPlayerSliceSavePopup(CUIRect MainView)
ButtonBar.VSplitMid(&AbortButton, &OkButton, 40.0f); ButtonBar.VSplitMid(&AbortButton, &OkButton, 40.0f);
static CButtonContainer s_ButtonAbort; static CButtonContainer s_ButtonAbort;
if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &AbortButton) || (!UI()->IsPopupOpen() && UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE))) if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &AbortButton) || (!Ui()->IsPopupOpen() && Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE)))
m_DemoPlayerState = DEMOPLAYER_NONE; m_DemoPlayerState = DEMOPLAYER_NONE;
static CUI::SConfirmPopupContext s_ConfirmPopupContext; static CUi::SConfirmPopupContext s_ConfirmPopupContext;
static CButtonContainer s_ButtonOk; static CButtonContainer s_ButtonOk;
if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &OkButton) || (!UI()->IsPopupOpen() && UI()->ConsumeHotkey(CUI::HOTKEY_ENTER))) if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &OkButton) || (!Ui()->IsPopupOpen() && Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER)))
{ {
char aDemoName[IO_MAX_PATH_LENGTH]; char aDemoName[IO_MAX_PATH_LENGTH];
char aNameWithoutExt[IO_MAX_PATH_LENGTH]; char aNameWithoutExt[IO_MAX_PATH_LENGTH];
@ -840,10 +840,10 @@ void CMenus::RenderDemoPlayerSliceSavePopup(CUIRect MainView)
if(str_comp(aDemoName, m_DemoSliceInput.GetString()) == 0) if(str_comp(aDemoName, m_DemoSliceInput.GetString()) == 0)
{ {
static CUI::SMessagePopupContext s_MessagePopupContext; static CUi::SMessagePopupContext s_MessagePopupContext;
s_MessagePopupContext.ErrorColor(); s_MessagePopupContext.ErrorColor();
str_copy(s_MessagePopupContext.m_aMessage, Localize("Please use a different filename")); str_copy(s_MessagePopupContext.m_aMessage, Localize("Please use a different filename"));
UI()->ShowPopupMessage(UI()->MouseX(), OkButton.y + OkButton.h + 5.0f, &s_MessagePopupContext); Ui()->ShowPopupMessage(Ui()->MouseX(), OkButton.y + OkButton.h + 5.0f, &s_MessagePopupContext);
} }
else else
{ {
@ -854,14 +854,14 @@ void CMenus::RenderDemoPlayerSliceSavePopup(CUIRect MainView)
s_ConfirmPopupContext.Reset(); s_ConfirmPopupContext.Reset();
s_ConfirmPopupContext.YesNoButtons(); s_ConfirmPopupContext.YesNoButtons();
str_copy(s_ConfirmPopupContext.m_aMessage, Localize("File already exists, do you want to overwrite it?")); str_copy(s_ConfirmPopupContext.m_aMessage, Localize("File already exists, do you want to overwrite it?"));
UI()->ShowPopupConfirm(UI()->MouseX(), OkButton.y + OkButton.h + 5.0f, &s_ConfirmPopupContext); Ui()->ShowPopupConfirm(Ui()->MouseX(), OkButton.y + OkButton.h + 5.0f, &s_ConfirmPopupContext);
} }
else else
s_ConfirmPopupContext.m_Result = CUI::SConfirmPopupContext::CONFIRMED; s_ConfirmPopupContext.m_Result = CUi::SConfirmPopupContext::CONFIRMED;
} }
} }
if(s_ConfirmPopupContext.m_Result == CUI::SConfirmPopupContext::CONFIRMED) if(s_ConfirmPopupContext.m_Result == CUi::SConfirmPopupContext::CONFIRMED)
{ {
char aPath[IO_MAX_PATH_LENGTH]; char aPath[IO_MAX_PATH_LENGTH];
str_format(aPath, sizeof(aPath), "%s/%s.demo", m_aCurrentDemoFolder, m_DemoSliceInput.GetString()); str_format(aPath, sizeof(aPath), "%s/%s.demo", m_aCurrentDemoFolder, m_DemoSliceInput.GetString());
@ -879,13 +879,13 @@ void CMenus::RenderDemoPlayerSliceSavePopup(CUIRect MainView)
m_Popup = POPUP_RENDER_DEMO; m_Popup = POPUP_RENDER_DEMO;
m_StartPaused = false; m_StartPaused = false;
m_DemoRenderInput.Set(m_aCurrentDemoSelectionName); m_DemoRenderInput.Set(m_aCurrentDemoSelectionName);
UI()->SetActiveItem(&m_DemoRenderInput); Ui()->SetActiveItem(&m_DemoRenderInput);
if(m_DemolistStorageType != IStorage::TYPE_ALL && m_DemolistStorageType != IStorage::TYPE_SAVE) if(m_DemolistStorageType != IStorage::TYPE_ALL && m_DemolistStorageType != IStorage::TYPE_SAVE)
m_DemolistStorageType = IStorage::TYPE_ALL; // Select a storage type containing the sliced demo m_DemolistStorageType = IStorage::TYPE_ALL; // Select a storage type containing the sliced demo
} }
#endif #endif
} }
if(s_ConfirmPopupContext.m_Result != CUI::SConfirmPopupContext::UNSET) if(s_ConfirmPopupContext.m_Result != CUi::SConfirmPopupContext::UNSET)
{ {
s_ConfirmPopupContext.Reset(); s_ConfirmPopupContext.Reset();
} }
@ -1212,7 +1212,7 @@ void CMenus::RenderDemoBrowserList(CUIRect ListView, bool &WasListboxItemActivat
TextRender()->SetFontPreset(EFontPreset::ICON_FONT); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->TextColor(IconColor); TextRender()->TextColor(IconColor);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING);
UI()->DoLabel(&Button, pIconType, 12.0f, TEXTALIGN_ML); Ui()->DoLabel(&Button, pIconType, 12.0f, TEXTALIGN_ML);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
@ -1223,19 +1223,19 @@ void CMenus::RenderDemoBrowserList(CUIRect ListView, bool &WasListboxItemActivat
Props.m_MaxWidth = Button.w; Props.m_MaxWidth = Button.w;
Props.m_EllipsisAtEnd = true; Props.m_EllipsisAtEnd = true;
Props.m_EnableWidthCheck = false; Props.m_EnableWidthCheck = false;
UI()->DoLabel(&Button, pItem->m_aName, 12.0f, TEXTALIGN_ML, Props); Ui()->DoLabel(&Button, pItem->m_aName, 12.0f, TEXTALIGN_ML, Props);
} }
else if(Col.m_Id == COL_LENGTH && !pItem->m_IsDir && pItem->m_Valid) else if(Col.m_Id == COL_LENGTH && !pItem->m_IsDir && pItem->m_Valid)
{ {
str_time((int64_t)pItem->Length() * 100, TIME_HOURS, aBuf, sizeof(aBuf)); str_time((int64_t)pItem->Length() * 100, TIME_HOURS, aBuf, sizeof(aBuf));
Button.VMargin(4.0f, &Button); Button.VMargin(4.0f, &Button);
UI()->DoLabel(&Button, aBuf, 12.0f, TEXTALIGN_MR); Ui()->DoLabel(&Button, aBuf, 12.0f, TEXTALIGN_MR);
} }
else if(Col.m_Id == COL_DATE && !pItem->m_IsDir) else if(Col.m_Id == COL_DATE && !pItem->m_IsDir)
{ {
str_timestamp_ex(pItem->m_Date, aBuf, sizeof(aBuf), FORMAT_SPACE); str_timestamp_ex(pItem->m_Date, aBuf, sizeof(aBuf), FORMAT_SPACE);
Button.VMargin(4.0f, &Button); Button.VMargin(4.0f, &Button);
UI()->DoLabel(&Button, aBuf, 12.0f, TEXTALIGN_MR); Ui()->DoLabel(&Button, aBuf, 12.0f, TEXTALIGN_MR);
} }
} }
} }
@ -1276,7 +1276,7 @@ void CMenus::RenderDemoBrowserDetails(CUIRect DetailsView)
pHeaderLabel = Localize("Invalid Demo"); pHeaderLabel = Localize("Invalid Demo");
else else
pHeaderLabel = Localize("Demo"); pHeaderLabel = Localize("Demo");
UI()->DoLabel(&Header, pHeaderLabel, FontSize + 2.0f, TEXTALIGN_MC); Ui()->DoLabel(&Header, pHeaderLabel, FontSize + 2.0f, TEXTALIGN_MC);
if(pItem == nullptr || pItem->m_IsDir) if(pItem == nullptr || pItem->m_IsDir)
return; return;
@ -1285,10 +1285,10 @@ void CMenus::RenderDemoBrowserDetails(CUIRect DetailsView)
CUIRect Left, Right; CUIRect Left, Right;
Contents.HSplitTop(18.0f, &Left, &Contents); Contents.HSplitTop(18.0f, &Left, &Contents);
UI()->DoLabel(&Left, Localize("Created"), FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Left, Localize("Created"), FontSize, TEXTALIGN_ML);
str_timestamp_ex(pItem->m_Date, aBuf, sizeof(aBuf), FORMAT_SPACE); str_timestamp_ex(pItem->m_Date, aBuf, sizeof(aBuf), FORMAT_SPACE);
Contents.HSplitTop(18.0f, &Left, &Contents); Contents.HSplitTop(18.0f, &Left, &Contents);
UI()->DoLabel(&Left, aBuf, FontSize - 1.0f, TEXTALIGN_ML); Ui()->DoLabel(&Left, aBuf, FontSize - 1.0f, TEXTALIGN_ML);
Contents.HSplitTop(4.0f, nullptr, &Contents); Contents.HSplitTop(4.0f, nullptr, &Contents);
if(!pItem->m_Valid) if(!pItem->m_Valid)
@ -1296,41 +1296,41 @@ void CMenus::RenderDemoBrowserDetails(CUIRect DetailsView)
Contents.HSplitTop(18.0f, &Left, &Contents); Contents.HSplitTop(18.0f, &Left, &Contents);
Left.VSplitMid(&Left, &Right, 4.0f); Left.VSplitMid(&Left, &Right, 4.0f);
UI()->DoLabel(&Left, Localize("Type"), FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Left, Localize("Type"), FontSize, TEXTALIGN_ML);
UI()->DoLabel(&Right, Localize("Version"), FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Right, Localize("Version"), FontSize, TEXTALIGN_ML);
Contents.HSplitTop(18.0f, &Left, &Contents); Contents.HSplitTop(18.0f, &Left, &Contents);
Left.VSplitMid(&Left, &Right, 4.0f); Left.VSplitMid(&Left, &Right, 4.0f);
UI()->DoLabel(&Left, pItem->m_Info.m_aType, FontSize - 1.0f, TEXTALIGN_ML); Ui()->DoLabel(&Left, pItem->m_Info.m_aType, FontSize - 1.0f, TEXTALIGN_ML);
str_from_int(pItem->m_Info.m_Version, aBuf); str_from_int(pItem->m_Info.m_Version, aBuf);
UI()->DoLabel(&Right, aBuf, FontSize - 1.0f, TEXTALIGN_ML); Ui()->DoLabel(&Right, aBuf, FontSize - 1.0f, TEXTALIGN_ML);
Contents.HSplitTop(4.0f, nullptr, &Contents); Contents.HSplitTop(4.0f, nullptr, &Contents);
Contents.HSplitTop(18.0f, &Left, &Contents); Contents.HSplitTop(18.0f, &Left, &Contents);
Left.VSplitMid(&Left, &Right, 4.0f); Left.VSplitMid(&Left, &Right, 4.0f);
UI()->DoLabel(&Left, Localize("Length"), FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Left, Localize("Length"), FontSize, TEXTALIGN_ML);
UI()->DoLabel(&Right, Localize("Markers"), FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Right, Localize("Markers"), FontSize, TEXTALIGN_ML);
Contents.HSplitTop(18.0f, &Left, &Contents); Contents.HSplitTop(18.0f, &Left, &Contents);
Left.VSplitMid(&Left, &Right, 4.0f); Left.VSplitMid(&Left, &Right, 4.0f);
str_time((int64_t)pItem->Length() * 100, TIME_HOURS, aBuf, sizeof(aBuf)); str_time((int64_t)pItem->Length() * 100, TIME_HOURS, aBuf, sizeof(aBuf));
UI()->DoLabel(&Left, aBuf, FontSize - 1.0f, TEXTALIGN_ML); Ui()->DoLabel(&Left, aBuf, FontSize - 1.0f, TEXTALIGN_ML);
str_from_int(pItem->NumMarkers(), aBuf); str_from_int(pItem->NumMarkers(), aBuf);
UI()->DoLabel(&Right, aBuf, FontSize - 1.0f, TEXTALIGN_ML); Ui()->DoLabel(&Right, aBuf, FontSize - 1.0f, TEXTALIGN_ML);
Contents.HSplitTop(4.0f, nullptr, &Contents); Contents.HSplitTop(4.0f, nullptr, &Contents);
Contents.HSplitTop(18.0f, &Left, &Contents); Contents.HSplitTop(18.0f, &Left, &Contents);
UI()->DoLabel(&Left, Localize("Netversion"), FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Left, Localize("Netversion"), FontSize, TEXTALIGN_ML);
Contents.HSplitTop(18.0f, &Left, &Contents); Contents.HSplitTop(18.0f, &Left, &Contents);
UI()->DoLabel(&Left, pItem->m_Info.m_aNetversion, FontSize - 1.0f, TEXTALIGN_ML); Ui()->DoLabel(&Left, pItem->m_Info.m_aNetversion, FontSize - 1.0f, TEXTALIGN_ML);
Contents.HSplitTop(16.0f, nullptr, &Contents); Contents.HSplitTop(16.0f, nullptr, &Contents);
Contents.HSplitTop(18.0f, &Left, &Contents); Contents.HSplitTop(18.0f, &Left, &Contents);
UI()->DoLabel(&Left, Localize("Map"), FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Left, Localize("Map"), FontSize, TEXTALIGN_ML);
Contents.HSplitTop(18.0f, &Left, &Contents); Contents.HSplitTop(18.0f, &Left, &Contents);
UI()->DoLabel(&Left, pItem->m_Info.m_aMapName, FontSize - 1.0f, TEXTALIGN_ML); Ui()->DoLabel(&Left, pItem->m_Info.m_aMapName, FontSize - 1.0f, TEXTALIGN_ML);
Contents.HSplitTop(4.0f, nullptr, &Contents); Contents.HSplitTop(4.0f, nullptr, &Contents);
Contents.HSplitTop(18.0f, &Left, &Contents); Contents.HSplitTop(18.0f, &Left, &Contents);
UI()->DoLabel(&Left, Localize("Size"), FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Left, Localize("Size"), FontSize, TEXTALIGN_ML);
Contents.HSplitTop(18.0f, &Left, &Contents); Contents.HSplitTop(18.0f, &Left, &Contents);
const float Size = pItem->Size() / 1024.0f; const float Size = pItem->Size() / 1024.0f;
if(Size == 0.0f) if(Size == 0.0f)
@ -1339,13 +1339,13 @@ void CMenus::RenderDemoBrowserDetails(CUIRect DetailsView)
str_format(aBuf, sizeof(aBuf), Localize("%.2f MiB"), Size / 1024.0f); str_format(aBuf, sizeof(aBuf), Localize("%.2f MiB"), Size / 1024.0f);
else else
str_format(aBuf, sizeof(aBuf), Localize("%.2f KiB"), Size); str_format(aBuf, sizeof(aBuf), Localize("%.2f KiB"), Size);
UI()->DoLabel(&Left, aBuf, FontSize - 1.0f, TEXTALIGN_ML); Ui()->DoLabel(&Left, aBuf, FontSize - 1.0f, TEXTALIGN_ML);
Contents.HSplitTop(4.0f, nullptr, &Contents); Contents.HSplitTop(4.0f, nullptr, &Contents);
Contents.HSplitTop(18.0f, &Left, &Contents); Contents.HSplitTop(18.0f, &Left, &Contents);
if(pItem->m_MapInfo.m_Sha256 != SHA256_ZEROED) if(pItem->m_MapInfo.m_Sha256 != SHA256_ZEROED)
{ {
UI()->DoLabel(&Left, "SHA256", FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Left, "SHA256", FontSize, TEXTALIGN_ML);
Contents.HSplitTop(18.0f, &Left, &Contents); Contents.HSplitTop(18.0f, &Left, &Contents);
char aSha[SHA256_MAXSTRSIZE]; char aSha[SHA256_MAXSTRSIZE];
sha256_str(pItem->m_MapInfo.m_Sha256, aSha, sizeof(aSha)); sha256_str(pItem->m_MapInfo.m_Sha256, aSha, sizeof(aSha));
@ -1353,14 +1353,14 @@ void CMenus::RenderDemoBrowserDetails(CUIRect DetailsView)
Props.m_MaxWidth = Left.w; Props.m_MaxWidth = Left.w;
Props.m_EllipsisAtEnd = true; Props.m_EllipsisAtEnd = true;
Props.m_EnableWidthCheck = false; Props.m_EnableWidthCheck = false;
UI()->DoLabel(&Left, aSha, FontSize - 1.0f, TEXTALIGN_ML, Props); Ui()->DoLabel(&Left, aSha, FontSize - 1.0f, TEXTALIGN_ML, Props);
} }
else else
{ {
UI()->DoLabel(&Left, "CRC32", FontSize, TEXTALIGN_ML); Ui()->DoLabel(&Left, "CRC32", FontSize, TEXTALIGN_ML);
Contents.HSplitTop(18.0f, &Left, &Contents); Contents.HSplitTop(18.0f, &Left, &Contents);
str_format(aBuf, sizeof(aBuf), "%08x", pItem->m_MapInfo.m_Crc); str_format(aBuf, sizeof(aBuf), "%08x", pItem->m_MapInfo.m_Crc);
UI()->DoLabel(&Left, aBuf, FontSize - 1.0f, TEXTALIGN_ML); Ui()->DoLabel(&Left, aBuf, FontSize - 1.0f, TEXTALIGN_ML);
} }
Contents.HSplitTop(4.0f, nullptr, &Contents); Contents.HSplitTop(4.0f, nullptr, &Contents);
} }
@ -1392,16 +1392,16 @@ void CMenus::RenderDemoBrowserButtons(CUIRect ButtonsView, bool WasListboxItemAc
ButtonBarTop.VSplitLeft(ButtonBarTop.h / 2.0f, nullptr, &ButtonBarTop); ButtonBarTop.VSplitLeft(ButtonBarTop.h / 2.0f, nullptr, &ButtonBarTop);
DemoSearch.VSplitLeft(TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS), &SearchIcon, &DemoSearch); DemoSearch.VSplitLeft(TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS), &SearchIcon, &DemoSearch);
DemoSearch.VSplitLeft(5.0f, nullptr, &DemoSearch); DemoSearch.VSplitLeft(5.0f, nullptr, &DemoSearch);
UI()->DoLabel(&SearchIcon, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML); Ui()->DoLabel(&SearchIcon, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML);
SetIconMode(false); SetIconMode(false);
m_DemoSearchInput.SetEmptyText(Localize("Search")); m_DemoSearchInput.SetEmptyText(Localize("Search"));
if(Input()->KeyPress(KEY_F) && Input()->ModifierIsPressed()) if(Input()->KeyPress(KEY_F) && Input()->ModifierIsPressed())
{ {
UI()->SetActiveItem(&m_DemoSearchInput); Ui()->SetActiveItem(&m_DemoSearchInput);
m_DemoSearchInput.SelectAll(); m_DemoSearchInput.SelectAll();
} }
if(UI()->DoClearableEditBox(&m_DemoSearchInput, &DemoSearch, 12.0f)) if(Ui()->DoClearableEditBox(&m_DemoSearchInput, &DemoSearch, 12.0f))
{ {
RefreshFilteredDemos(); RefreshFilteredDemos();
DemolistOnUpdate(false); DemolistOnUpdate(false);
@ -1464,7 +1464,7 @@ void CMenus::RenderDemoBrowserButtons(CUIRect ButtonsView, bool WasListboxItemAc
ButtonBarBottom.VSplitRight(ButtonBarBottom.h, &ButtonBarBottom, nullptr); ButtonBarBottom.VSplitRight(ButtonBarBottom.h, &ButtonBarBottom, nullptr);
SetIconMode(true); SetIconMode(true);
static CButtonContainer s_PlayButton; static CButtonContainer s_PlayButton;
if(DoButton_Menu(&s_PlayButton, (m_DemolistSelectedIndex >= 0 && m_vpFilteredDemos[m_DemolistSelectedIndex]->m_IsDir) ? FONT_ICON_FOLDER_OPEN : FONT_ICON_PLAY, 0, &PlayButton) || WasListboxItemActivated || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER) || (Input()->KeyPress(KEY_P) && m_pClient->m_GameConsole.IsClosed() && !m_DemoSearchInput.IsActive())) if(DoButton_Menu(&s_PlayButton, (m_DemolistSelectedIndex >= 0 && m_vpFilteredDemos[m_DemolistSelectedIndex]->m_IsDir) ? FONT_ICON_FOLDER_OPEN : FONT_ICON_PLAY, 0, &PlayButton) || WasListboxItemActivated || Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER) || (Input()->KeyPress(KEY_P) && m_pClient->m_GameConsole.IsClosed() && !m_DemoSearchInput.IsActive()))
{ {
SetIconMode(false); SetIconMode(false);
if(m_vpFilteredDemos[m_DemolistSelectedIndex]->m_IsDir) // folder if(m_vpFilteredDemos[m_DemolistSelectedIndex]->m_IsDir) // folder
@ -1513,7 +1513,7 @@ void CMenus::RenderDemoBrowserButtons(CUIRect ButtonsView, bool WasListboxItemAc
} }
else else
{ {
UI()->SetActiveItem(nullptr); Ui()->SetActiveItem(nullptr);
return; return;
} }
} }
@ -1544,7 +1544,7 @@ void CMenus::RenderDemoBrowserButtons(CUIRect ButtonsView, bool WasListboxItemAc
fs_split_file_extension(m_vpFilteredDemos[m_DemolistSelectedIndex]->m_aFilename, aNameWithoutExt, sizeof(aNameWithoutExt)); fs_split_file_extension(m_vpFilteredDemos[m_DemolistSelectedIndex]->m_aFilename, aNameWithoutExt, sizeof(aNameWithoutExt));
m_DemoRenameInput.Set(aNameWithoutExt); m_DemoRenameInput.Set(aNameWithoutExt);
} }
UI()->SetActiveItem(&m_DemoRenameInput); Ui()->SetActiveItem(&m_DemoRenameInput);
return; return;
} }
@ -1553,7 +1553,7 @@ void CMenus::RenderDemoBrowserButtons(CUIRect ButtonsView, bool WasListboxItemAc
CUIRect DeleteButton; CUIRect DeleteButton;
ButtonBarBottom.VSplitRight(ButtonBarBottom.h * 3.0f, &ButtonBarBottom, &DeleteButton); ButtonBarBottom.VSplitRight(ButtonBarBottom.h * 3.0f, &ButtonBarBottom, &DeleteButton);
ButtonBarBottom.VSplitRight(ButtonBarBottom.h / 2.0f, &ButtonBarBottom, nullptr); ButtonBarBottom.VSplitRight(ButtonBarBottom.h / 2.0f, &ButtonBarBottom, nullptr);
if(DoButton_Menu(&s_DeleteButton, FONT_ICON_TRASH, 0, &DeleteButton) || UI()->ConsumeHotkey(CUI::HOTKEY_DELETE) || (Input()->KeyPress(KEY_D) && m_pClient->m_GameConsole.IsClosed() && !m_DemoSearchInput.IsActive())) if(DoButton_Menu(&s_DeleteButton, FONT_ICON_TRASH, 0, &DeleteButton) || Ui()->ConsumeHotkey(CUi::HOTKEY_DELETE) || (Input()->KeyPress(KEY_D) && m_pClient->m_GameConsole.IsClosed() && !m_DemoSearchInput.IsActive()))
{ {
SetIconMode(false); SetIconMode(false);
char aBuf[128 + IO_MAX_PATH_LENGTH]; char aBuf[128 + IO_MAX_PATH_LENGTH];
@ -1581,7 +1581,7 @@ void CMenus::RenderDemoBrowserButtons(CUIRect ButtonsView, bool WasListboxItemAc
char aNameWithoutExt[IO_MAX_PATH_LENGTH]; char aNameWithoutExt[IO_MAX_PATH_LENGTH];
fs_split_file_extension(m_vpFilteredDemos[m_DemolistSelectedIndex]->m_aFilename, aNameWithoutExt, sizeof(aNameWithoutExt)); fs_split_file_extension(m_vpFilteredDemos[m_DemolistSelectedIndex]->m_aFilename, aNameWithoutExt, sizeof(aNameWithoutExt));
m_DemoRenderInput.Set(aNameWithoutExt); m_DemoRenderInput.Set(aNameWithoutExt);
UI()->SetActiveItem(&m_DemoRenderInput); Ui()->SetActiveItem(&m_DemoRenderInput);
return; return;
} }
SetIconMode(false); SetIconMode(false);

View file

@ -116,10 +116,10 @@ void CMenus::RenderGame(CUIRect MainView)
bool Paused = false; bool Paused = false;
bool Spec = false; bool Spec = false;
if(m_pClient->m_Snap.m_LocalClientID >= 0) if(m_pClient->m_Snap.m_LocalClientId >= 0)
{ {
Paused = m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_Paused; Paused = m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientId].m_Paused;
Spec = m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_Spec; Spec = m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientId].m_Spec;
} }
if(m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pGameInfoObj && !Paused && !Spec) if(m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pGameInfoObj && !Paused && !Spec)
@ -232,12 +232,12 @@ void CMenus::RenderPlayers(CUIRect MainView)
Options.Draw(ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f), IGraphics::CORNER_ALL, 10.0f); Options.Draw(ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f), IGraphics::CORNER_ALL, 10.0f);
Options.Margin(10.0f, &Options); Options.Margin(10.0f, &Options);
Options.HSplitTop(50.0f, &Button, &Options); Options.HSplitTop(50.0f, &Button, &Options);
UI()->DoLabel(&Button, Localize("Player options"), 34.0f, TEXTALIGN_ML); Ui()->DoLabel(&Button, Localize("Player options"), 34.0f, TEXTALIGN_ML);
// headline // headline
Options.HSplitTop(34.0f, &ButtonBar, &Options); Options.HSplitTop(34.0f, &ButtonBar, &Options);
ButtonBar.VSplitRight(231.0f, &Player, &ButtonBar); ButtonBar.VSplitRight(231.0f, &Player, &ButtonBar);
UI()->DoLabel(&Player, Localize("Player"), 24.0f, TEXTALIGN_ML); Ui()->DoLabel(&Player, Localize("Player"), 24.0f, TEXTALIGN_ML);
ButtonBar.HMargin(1.0f, &ButtonBar); ButtonBar.HMargin(1.0f, &ButtonBar);
float Width = ButtonBar.h * 2.0f; float Width = ButtonBar.h * 2.0f;
@ -258,9 +258,9 @@ void CMenus::RenderPlayers(CUIRect MainView)
if(!pInfoByName) if(!pInfoByName)
continue; continue;
int Index = pInfoByName->m_ClientID; int Index = pInfoByName->m_ClientId;
if(Index == m_pClient->m_Snap.m_LocalClientID) if(Index == m_pClient->m_Snap.m_LocalClientId)
continue; continue;
TotalPlayers++; TotalPlayers++;
@ -270,15 +270,15 @@ void CMenus::RenderPlayers(CUIRect MainView)
s_ListBox.DoStart(24.0f, TotalPlayers, 1, 3, -1, &Options); s_ListBox.DoStart(24.0f, TotalPlayers, 1, 3, -1, &Options);
// options // options
static char s_aPlayerIDs[MAX_CLIENTS][3] = {{0}}; static char s_aPlayerIds[MAX_CLIENTS][3] = {{0}};
for(int i = 0, Count = 0; i < MAX_CLIENTS; ++i) for(int i = 0, Count = 0; i < MAX_CLIENTS; ++i)
{ {
if(!m_pClient->m_Snap.m_apInfoByName[i]) if(!m_pClient->m_Snap.m_apInfoByName[i])
continue; continue;
int Index = m_pClient->m_Snap.m_apInfoByName[i]->m_ClientID; int Index = m_pClient->m_Snap.m_apInfoByName[i]->m_ClientId;
if(Index == m_pClient->m_Snap.m_LocalClientID) if(Index == m_pClient->m_Snap.m_LocalClientId)
continue; continue;
CGameClient::CClientData &CurrentClient = m_pClient->m_aClients[Index]; CGameClient::CClientData &CurrentClient = m_pClient->m_aClients[Index];
@ -312,8 +312,8 @@ void CMenus::RenderPlayers(CUIRect MainView)
Player.VSplitMid(&Player, &Button); Player.VSplitMid(&Player, &Button);
Row.VSplitRight(210.0f, &Button2, &Row); Row.VSplitRight(210.0f, &Button2, &Row);
UI()->DoLabel(&Player, CurrentClient.m_aName, 14.0f, TEXTALIGN_ML); Ui()->DoLabel(&Player, CurrentClient.m_aName, 14.0f, TEXTALIGN_ML);
UI()->DoLabel(&Button, CurrentClient.m_aClan, 14.0f, TEXTALIGN_ML); Ui()->DoLabel(&Button, CurrentClient.m_aClan, 14.0f, TEXTALIGN_ML);
m_pClient->m_CountryFlags.Render(CurrentClient.m_Country, ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f), m_pClient->m_CountryFlags.Render(CurrentClient.m_Country, ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f),
Button2.x, Button2.y + Button2.h / 2.0f - 0.75f * Button2.h / 2.0f, 1.5f * Button2.h, 0.75f * Button2.h); Button2.x, Button2.y + Button2.h / 2.0f - 0.75f * Button2.h / 2.0f, 1.5f * Button2.h, 0.75f * Button2.h);
@ -324,8 +324,8 @@ void CMenus::RenderPlayers(CUIRect MainView)
Button.VSplitLeft((Width - Button.h) / 4.0f, nullptr, &Button); Button.VSplitLeft((Width - Button.h) / 4.0f, nullptr, &Button);
Button.VSplitLeft(Button.h, &Button, nullptr); Button.VSplitLeft(Button.h, &Button, nullptr);
if(g_Config.m_ClShowChatFriends && !CurrentClient.m_Friend) if(g_Config.m_ClShowChatFriends && !CurrentClient.m_Friend)
DoButton_Toggle(&s_aPlayerIDs[Index][0], 1, &Button, false); DoButton_Toggle(&s_aPlayerIds[Index][0], 1, &Button, false);
else if(DoButton_Toggle(&s_aPlayerIDs[Index][0], CurrentClient.m_ChatIgnore, &Button, true)) else if(DoButton_Toggle(&s_aPlayerIds[Index][0], CurrentClient.m_ChatIgnore, &Button, true))
CurrentClient.m_ChatIgnore ^= 1; CurrentClient.m_ChatIgnore ^= 1;
// ignore emoticon button // ignore emoticon button
@ -334,8 +334,8 @@ void CMenus::RenderPlayers(CUIRect MainView)
Button.VSplitLeft((Width - Button.h) / 4.0f, nullptr, &Button); Button.VSplitLeft((Width - Button.h) / 4.0f, nullptr, &Button);
Button.VSplitLeft(Button.h, &Button, nullptr); Button.VSplitLeft(Button.h, &Button, nullptr);
if(g_Config.m_ClShowChatFriends && !CurrentClient.m_Friend) if(g_Config.m_ClShowChatFriends && !CurrentClient.m_Friend)
DoButton_Toggle(&s_aPlayerIDs[Index][1], 1, &Button, false); DoButton_Toggle(&s_aPlayerIds[Index][1], 1, &Button, false);
else if(DoButton_Toggle(&s_aPlayerIDs[Index][1], CurrentClient.m_EmoticonIgnore, &Button, true)) else if(DoButton_Toggle(&s_aPlayerIds[Index][1], CurrentClient.m_EmoticonIgnore, &Button, true))
CurrentClient.m_EmoticonIgnore ^= 1; CurrentClient.m_EmoticonIgnore ^= 1;
// friend button // friend button
@ -343,7 +343,7 @@ void CMenus::RenderPlayers(CUIRect MainView)
Row.VSplitLeft(Width, &Button, &Row); Row.VSplitLeft(Width, &Button, &Row);
Button.VSplitLeft((Width - Button.h) / 4.0f, nullptr, &Button); Button.VSplitLeft((Width - Button.h) / 4.0f, nullptr, &Button);
Button.VSplitLeft(Button.h, &Button, nullptr); Button.VSplitLeft(Button.h, &Button, nullptr);
if(DoButton_Toggle(&s_aPlayerIDs[Index][2], CurrentClient.m_Friend, &Button, true)) if(DoButton_Toggle(&s_aPlayerIds[Index][2], CurrentClient.m_Friend, &Button, true))
{ {
if(CurrentClient.m_Friend) if(CurrentClient.m_Friend)
m_pClient->Friends()->RemoveFriend(CurrentClient.m_aName, CurrentClient.m_aClan); m_pClient->Friends()->RemoveFriend(CurrentClient.m_aName, CurrentClient.m_aClan);
@ -556,7 +556,7 @@ bool CMenus::RenderServerControlServer(CUIRect MainView)
CUIRect Label; CUIRect Label;
Item.m_Rect.VMargin(2.0f, &Label); Item.m_Rect.VMargin(2.0f, &Label);
UI()->DoLabel(&Label, pOption->m_aDescription, 13.0f, TEXTALIGN_ML); Ui()->DoLabel(&Label, pOption->m_aDescription, 13.0f, TEXTALIGN_ML);
} }
s_CurVoteOption = s_ListBox.DoEnd(); s_CurVoteOption = s_ListBox.DoEnd();
@ -569,14 +569,14 @@ bool CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators)
{ {
int NumOptions = 0; int NumOptions = 0;
int Selected = -1; int Selected = -1;
int aPlayerIDs[MAX_CLIENTS]; int aPlayerIds[MAX_CLIENTS];
for(const auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName) for(const auto &pInfoByName : m_pClient->m_Snap.m_apInfoByName)
{ {
if(!pInfoByName) if(!pInfoByName)
continue; continue;
int Index = pInfoByName->m_ClientID; int Index = pInfoByName->m_ClientId;
if(Index == m_pClient->m_Snap.m_LocalClientID || (FilterSpectators && pInfoByName->m_Team == TEAM_SPECTATORS)) if(Index == m_pClient->m_Snap.m_LocalClientId || (FilterSpectators && pInfoByName->m_Team == TEAM_SPECTATORS))
continue; continue;
if(!str_utf8_find_nocase(m_pClient->m_aClients[Index].m_aName, m_FilterInput.GetString())) if(!str_utf8_find_nocase(m_pClient->m_aClients[Index].m_aName, m_FilterInput.GetString()))
@ -584,7 +584,7 @@ bool CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators)
if(m_CallvoteSelectedPlayer == Index) if(m_CallvoteSelectedPlayer == Index)
Selected = NumOptions; Selected = NumOptions;
aPlayerIDs[NumOptions] = Index; aPlayerIds[NumOptions] = Index;
NumOptions++; NumOptions++;
} }
@ -593,14 +593,14 @@ bool CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators)
for(int i = 0; i < NumOptions; i++) for(int i = 0; i < NumOptions; i++)
{ {
const CListboxItem Item = s_ListBox.DoNextItem(&aPlayerIDs[i]); const CListboxItem Item = s_ListBox.DoNextItem(&aPlayerIds[i]);
if(!Item.m_Visible) if(!Item.m_Visible)
continue; continue;
CUIRect TeeRect, Label; CUIRect TeeRect, Label;
Item.m_Rect.VSplitLeft(Item.m_Rect.h, &TeeRect, &Label); Item.m_Rect.VSplitLeft(Item.m_Rect.h, &TeeRect, &Label);
CTeeRenderInfo TeeInfo = m_pClient->m_aClients[aPlayerIDs[i]].m_RenderInfo; CTeeRenderInfo TeeInfo = m_pClient->m_aClients[aPlayerIds[i]].m_RenderInfo;
TeeInfo.m_Size = TeeRect.h; TeeInfo.m_Size = TeeRect.h;
const CAnimState *pIdleState = CAnimState::GetIdle(); const CAnimState *pIdleState = CAnimState::GetIdle();
@ -610,11 +610,11 @@ bool CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators)
RenderTools()->RenderTee(pIdleState, &TeeInfo, EMOTE_NORMAL, vec2(1.0f, 0.0f), TeeRenderPos); RenderTools()->RenderTee(pIdleState, &TeeInfo, EMOTE_NORMAL, vec2(1.0f, 0.0f), TeeRenderPos);
UI()->DoLabel(&Label, m_pClient->m_aClients[aPlayerIDs[i]].m_aName, 16.0f, TEXTALIGN_ML); Ui()->DoLabel(&Label, m_pClient->m_aClients[aPlayerIds[i]].m_aName, 16.0f, TEXTALIGN_ML);
} }
Selected = s_ListBox.DoEnd(); Selected = s_ListBox.DoEnd();
m_CallvoteSelectedPlayer = Selected != -1 ? aPlayerIDs[Selected] : -1; m_CallvoteSelectedPlayer = Selected != -1 ? aPlayerIds[Selected] : -1;
return s_ListBox.WasItemActivated(); return s_ListBox.WasItemActivated();
} }
@ -676,7 +676,7 @@ void CMenus::RenderServerControl(CUIRect MainView)
TextRender()->SetFontPreset(EFontPreset::ICON_FONT); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML); Ui()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML);
float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f); float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
@ -685,12 +685,12 @@ void CMenus::RenderServerControl(CUIRect MainView)
if(m_ControlPageOpening || (Input()->KeyPress(KEY_F) && Input()->ModifierIsPressed())) if(m_ControlPageOpening || (Input()->KeyPress(KEY_F) && Input()->ModifierIsPressed()))
{ {
UI()->SetActiveItem(&m_FilterInput); Ui()->SetActiveItem(&m_FilterInput);
m_ControlPageOpening = false; m_ControlPageOpening = false;
m_FilterInput.SelectAll(); m_FilterInput.SelectAll();
} }
m_FilterInput.SetEmptyText(Localize("Search")); m_FilterInput.SetEmptyText(Localize("Search"));
UI()->DoClearableEditBox(&m_FilterInput, &QuickSearch, 14.0f); Ui()->DoClearableEditBox(&m_FilterInput, &QuickSearch, 14.0f);
// call vote // call vote
Bottom.VSplitRight(10.0f, &Bottom, 0); Bottom.VSplitRight(10.0f, &Bottom, 0);
@ -731,15 +731,15 @@ void CMenus::RenderServerControl(CUIRect MainView)
Bottom.VSplitRight(20.0f, &Bottom, 0); Bottom.VSplitRight(20.0f, &Bottom, 0);
Bottom.VSplitRight(200.0f, &Bottom, &Reason); Bottom.VSplitRight(200.0f, &Bottom, &Reason);
const char *pLabel = Localize("Reason:"); const char *pLabel = Localize("Reason:");
UI()->DoLabel(&Reason, pLabel, 14.0f, TEXTALIGN_ML); Ui()->DoLabel(&Reason, pLabel, 14.0f, TEXTALIGN_ML);
float w = TextRender()->TextWidth(14.0f, pLabel, -1, -1.0f); float w = TextRender()->TextWidth(14.0f, pLabel, -1, -1.0f);
Reason.VSplitLeft(w + 10.0f, 0, &Reason); Reason.VSplitLeft(w + 10.0f, 0, &Reason);
if(Input()->KeyPress(KEY_R) && Input()->ModifierIsPressed()) if(Input()->KeyPress(KEY_R) && Input()->ModifierIsPressed())
{ {
UI()->SetActiveItem(&m_CallvoteReasonInput); Ui()->SetActiveItem(&m_CallvoteReasonInput);
m_CallvoteReasonInput.SelectAll(); m_CallvoteReasonInput.SelectAll();
} }
UI()->DoEditBox(&m_CallvoteReasonInput, &Reason, 14.0f); Ui()->DoEditBox(&m_CallvoteReasonInput, &Reason, 14.0f);
// vote option loading indicator // vote option loading indicator
if(s_ControlPage == EServerControlTab::SETTINGS && m_pClient->m_Voting.IsReceivingOptions()) if(s_ControlPage == EServerControlTab::SETTINGS && m_pClient->m_Voting.IsReceivingOptions())
@ -749,8 +749,8 @@ void CMenus::RenderServerControl(CUIRect MainView)
Bottom.VSplitLeft(16.0f, &Spinner, &Bottom); Bottom.VSplitLeft(16.0f, &Spinner, &Bottom);
Bottom.VSplitLeft(5.0f, nullptr, &Bottom); Bottom.VSplitLeft(5.0f, nullptr, &Bottom);
Bottom.VSplitRight(10.0f, &LoadingLabel, nullptr); Bottom.VSplitRight(10.0f, &LoadingLabel, nullptr);
UI()->RenderProgressSpinner(Spinner.Center(), 8.0f); Ui()->RenderProgressSpinner(Spinner.Center(), 8.0f);
UI()->DoLabel(&LoadingLabel, Localize("Loading…"), 14.0f, TEXTALIGN_ML); Ui()->DoLabel(&LoadingLabel, Localize("Loading…"), 14.0f, TEXTALIGN_ML);
} }
// extended features (only available when authed in rcon) // extended features (only available when authed in rcon)
@ -806,10 +806,10 @@ void CMenus::RenderServerControl(CUIRect MainView)
RconExtension.HSplitTop(20.0f, &Bottom, &RconExtension); RconExtension.HSplitTop(20.0f, &Bottom, &RconExtension);
Bottom.VSplitLeft(5.0f, 0, &Bottom); Bottom.VSplitLeft(5.0f, 0, &Bottom);
Bottom.VSplitLeft(250.0f, &Button, &Bottom); Bottom.VSplitLeft(250.0f, &Button, &Bottom);
UI()->DoLabel(&Button, Localize("Vote description:"), 14.0f, TEXTALIGN_ML); Ui()->DoLabel(&Button, Localize("Vote description:"), 14.0f, TEXTALIGN_ML);
Bottom.VSplitLeft(20.0f, 0, &Button); Bottom.VSplitLeft(20.0f, 0, &Button);
UI()->DoLabel(&Button, Localize("Vote command:"), 14.0f, TEXTALIGN_ML); Ui()->DoLabel(&Button, Localize("Vote command:"), 14.0f, TEXTALIGN_ML);
static CLineInputBuffered<VOTE_DESC_LENGTH> s_VoteDescriptionInput; static CLineInputBuffered<VOTE_DESC_LENGTH> s_VoteDescriptionInput;
static CLineInputBuffered<VOTE_CMD_LENGTH> s_VoteCommandInput; static CLineInputBuffered<VOTE_CMD_LENGTH> s_VoteCommandInput;
@ -823,10 +823,10 @@ void CMenus::RenderServerControl(CUIRect MainView)
Bottom.VSplitLeft(5.0f, 0, &Bottom); Bottom.VSplitLeft(5.0f, 0, &Bottom);
Bottom.VSplitLeft(250.0f, &Button, &Bottom); Bottom.VSplitLeft(250.0f, &Button, &Bottom);
UI()->DoEditBox(&s_VoteDescriptionInput, &Button, 14.0f); Ui()->DoEditBox(&s_VoteDescriptionInput, &Button, 14.0f);
Bottom.VMargin(20.0f, &Button); Bottom.VMargin(20.0f, &Button);
UI()->DoEditBox(&s_VoteCommandInput, &Button, 14.0f); Ui()->DoEditBox(&s_VoteCommandInput, &Button, 14.0f);
} }
} }
} }
@ -1134,19 +1134,19 @@ void CMenus::RenderGhost(CUIRect MainView)
} }
else if(Id == COL_NAME) else if(Id == COL_NAME)
{ {
UI()->DoLabel(&Button, pGhost->m_aPlayer, 12.0f, TEXTALIGN_ML); Ui()->DoLabel(&Button, pGhost->m_aPlayer, 12.0f, TEXTALIGN_ML);
} }
else if(Id == COL_TIME) else if(Id == COL_TIME)
{ {
char aBuf[64]; char aBuf[64];
str_time(pGhost->m_Time / 10, TIME_HOURS_CENTISECS, aBuf, sizeof(aBuf)); str_time(pGhost->m_Time / 10, TIME_HOURS_CENTISECS, aBuf, sizeof(aBuf));
UI()->DoLabel(&Button, aBuf, 12.0f, TEXTALIGN_ML); Ui()->DoLabel(&Button, aBuf, 12.0f, TEXTALIGN_ML);
} }
else if(Id == COL_DATE) else if(Id == COL_DATE)
{ {
char aBuf[64]; char aBuf[64];
str_timestamp_ex(pGhost->m_Date, aBuf, sizeof(aBuf), FORMAT_SPACE); str_timestamp_ex(pGhost->m_Date, aBuf, sizeof(aBuf), FORMAT_SPACE);
UI()->DoLabel(&Button, aBuf, 12.0f, TEXTALIGN_ML); Ui()->DoLabel(&Button, aBuf, 12.0f, TEXTALIGN_ML);
} }
} }
@ -1275,5 +1275,5 @@ void CMenus::RenderIngameHint()
Graphics()->MapScreen(0, 0, Width, 300); Graphics()->MapScreen(0, 0, Width, 300);
TextRender()->TextColor(1, 1, 1, 1); TextRender()->TextColor(1, 1, 1, 1);
TextRender()->Text(5, 280, 5, Localize("Menu opened. Press Esc key again to close menu."), -1.0f); TextRender()->Text(5, 280, 5, Localize("Menu opened. Press Esc key again to close menu."), -1.0f);
UI()->MapScreen(); Ui()->MapScreen();
} }

File diff suppressed because it is too large Load diff

View file

@ -547,7 +547,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
CUIRect TextureRect; CUIRect TextureRect;
ItemRect.HSplitTop(15, &ItemRect, &TextureRect); ItemRect.HSplitTop(15, &ItemRect, &TextureRect);
TextureRect.HSplitTop(10, NULL, &TextureRect); TextureRect.HSplitTop(10, NULL, &TextureRect);
UI()->DoLabel(&ItemRect, pItem->m_aName, ItemRect.h - 2, TEXTALIGN_MC); Ui()->DoLabel(&ItemRect, pItem->m_aName, ItemRect.h - 2, TEXTALIGN_MC);
if(pItem->m_RenderTexture.IsValid()) if(pItem->m_RenderTexture.IsValid())
{ {
Graphics()->WrapClamp(); Graphics()->WrapClamp();
@ -607,7 +607,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
TextRender()->SetFontPreset(EFontPreset::ICON_FONT); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML); Ui()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML);
float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f); float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
@ -616,11 +616,11 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
QuickSearch.VSplitLeft(QuickSearch.w - 10.0f, &QuickSearch, &QuickSearchClearButton); QuickSearch.VSplitLeft(QuickSearch.w - 10.0f, &QuickSearch, &QuickSearchClearButton);
if(Input()->KeyPress(KEY_F) && Input()->ModifierIsPressed()) if(Input()->KeyPress(KEY_F) && Input()->ModifierIsPressed())
{ {
UI()->SetActiveItem(&s_aFilterInputs[s_CurCustomTab]); Ui()->SetActiveItem(&s_aFilterInputs[s_CurCustomTab]);
s_aFilterInputs[s_CurCustomTab].SelectAll(); s_aFilterInputs[s_CurCustomTab].SelectAll();
} }
s_aFilterInputs[s_CurCustomTab].SetEmptyText(Localize("Search")); s_aFilterInputs[s_CurCustomTab].SetEmptyText(Localize("Search"));
if(UI()->DoClearableEditBox(&s_aFilterInputs[s_CurCustomTab], &QuickSearch, 14.0f)) if(Ui()->DoClearableEditBox(&s_aFilterInputs[s_CurCustomTab], &QuickSearch, 14.0f))
gs_aInitCustomList[s_CurCustomTab] = true; gs_aInitCustomList[s_CurCustomTab] = true;
} }
@ -628,8 +628,8 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
DirectoryButton.VSplitRight(175.0f, 0, &DirectoryButton); DirectoryButton.VSplitRight(175.0f, 0, &DirectoryButton);
DirectoryButton.VSplitRight(25.0f, &DirectoryButton, &ReloadButton); DirectoryButton.VSplitRight(25.0f, &DirectoryButton, &ReloadButton);
DirectoryButton.VSplitRight(10.0f, &DirectoryButton, 0); DirectoryButton.VSplitRight(10.0f, &DirectoryButton, 0);
static CButtonContainer s_AssetsDirID; static CButtonContainer s_AssetsDirId;
if(DoButton_Menu(&s_AssetsDirID, Localize("Assets directory"), 0, &DirectoryButton)) if(DoButton_Menu(&s_AssetsDirId, Localize("Assets directory"), 0, &DirectoryButton))
{ {
char aBuf[IO_MAX_PATH_LENGTH]; char aBuf[IO_MAX_PATH_LENGTH];
char aBufFull[IO_MAX_PATH_LENGTH + 7]; char aBufFull[IO_MAX_PATH_LENGTH + 7];
@ -653,12 +653,12 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
dbg_msg("menus", "couldn't open file '%s'", aBuf); dbg_msg("menus", "couldn't open file '%s'", aBuf);
} }
} }
GameClient()->m_Tooltips.DoToolTip(&s_AssetsDirID, &DirectoryButton, Localize("Open the directory to add custom assets")); GameClient()->m_Tooltips.DoToolTip(&s_AssetsDirId, &DirectoryButton, Localize("Open the directory to add custom assets"));
TextRender()->SetFontPreset(EFontPreset::ICON_FONT); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
static CButtonContainer s_AssetsReloadBtnID; static CButtonContainer s_AssetsReloadBtnId;
if(DoButton_Menu(&s_AssetsReloadBtnID, FONT_ICON_ARROW_ROTATE_RIGHT, 0, &ReloadButton) || Input()->KeyPress(KEY_F5) || (Input()->KeyPress(KEY_R) && Input()->ModifierIsPressed())) if(DoButton_Menu(&s_AssetsReloadBtnId, FONT_ICON_ARROW_ROTATE_RIGHT, 0, &ReloadButton) || Input()->KeyPress(KEY_F5) || (Input()->KeyPress(KEY_R) && Input()->ModifierIsPressed()))
{ {
ClearCustomItems(s_CurCustomTab); ClearCustomItems(s_CurCustomTab);
} }

View file

@ -114,7 +114,7 @@ void CMenus::RenderStartMenu(CUIRect MainView)
Menu.HSplitBottom(40.0f, &Menu, &Button); Menu.HSplitBottom(40.0f, &Menu, &Button);
static CButtonContainer s_QuitButton; static CButtonContainer s_QuitButton;
bool UsedEscape = false; bool UsedEscape = false;
if(DoButton_Menu(&s_QuitButton, Localize("Quit"), 0, &Button, 0, IGraphics::CORNER_ALL, Rounding, 0.5f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f)) || (UsedEscape = UI()->ConsumeHotkey(CUI::HOTKEY_ESCAPE)) || CheckHotKey(KEY_Q)) if(DoButton_Menu(&s_QuitButton, Localize("Quit"), 0, &Button, 0, IGraphics::CORNER_ALL, Rounding, 0.5f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f)) || (UsedEscape = Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE)) || CheckHotKey(KEY_Q))
{ {
if(UsedEscape || m_pClient->Editor()->HasUnsavedData() || (Client()->GetCurrentRaceTime() / 60 >= g_Config.m_ClConfirmQuitTime && g_Config.m_ClConfirmQuitTime >= 0)) if(UsedEscape || m_pClient->Editor()->HasUnsavedData() || (Client()->GetCurrentRaceTime() / 60 >= g_Config.m_ClConfirmQuitTime && g_Config.m_ClConfirmQuitTime >= 0))
{ {
@ -189,7 +189,7 @@ void CMenus::RenderStartMenu(CUIRect MainView)
Menu.HSplitBottom(5.0f, &Menu, 0); // little space Menu.HSplitBottom(5.0f, &Menu, 0); // little space
Menu.HSplitBottom(40.0f, &Menu, &Button); Menu.HSplitBottom(40.0f, &Menu, &Button);
static CButtonContainer s_PlayButton; static CButtonContainer s_PlayButton;
if(DoButton_Menu(&s_PlayButton, Localize("Play", "Start menu"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "play_game" : 0, IGraphics::CORNER_ALL, Rounding, 0.5f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f)) || UI()->ConsumeHotkey(CUI::HOTKEY_ENTER) || CheckHotKey(KEY_P)) if(DoButton_Menu(&s_PlayButton, Localize("Play", "Start menu"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "play_game" : 0, IGraphics::CORNER_ALL, Rounding, 0.5f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f)) || Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER) || CheckHotKey(KEY_P))
{ {
NewPage = g_Config.m_UiPage >= PAGE_INTERNET && g_Config.m_UiPage <= PAGE_FAVORITE_COMMUNITY_3 ? g_Config.m_UiPage : PAGE_INTERNET; NewPage = g_Config.m_UiPage >= PAGE_INTERNET && g_Config.m_UiPage <= PAGE_FAVORITE_COMMUNITY_3 ? g_Config.m_UiPage : PAGE_INTERNET;
} }
@ -231,7 +231,7 @@ void CMenus::RenderStartMenu(CUIRect MainView)
str_format(aBuf, sizeof(aBuf), Localize("DDNet Client updated!")); str_format(aBuf, sizeof(aBuf), Localize("DDNet Client updated!"));
TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f); TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f);
} }
UI()->DoLabel(&VersionUpdate, aBuf, 14.0f, TEXTALIGN_ML); Ui()->DoLabel(&VersionUpdate, aBuf, 14.0f, TEXTALIGN_ML);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
VersionUpdate.VSplitLeft(TextRender()->TextWidth(14.0f, aBuf, -1, -1.0f) + 10.0f, 0, &Part); VersionUpdate.VSplitLeft(TextRender()->TextWidth(14.0f, aBuf, -1, -1.0f) + 10.0f, 0, &Part);
@ -274,12 +274,12 @@ void CMenus::RenderStartMenu(CUIRect MainView)
char aBuf[64]; char aBuf[64];
str_format(aBuf, sizeof(aBuf), Localize("DDNet %s is out!"), Client()->LatestVersion()); str_format(aBuf, sizeof(aBuf), Localize("DDNet %s is out!"), Client()->LatestVersion());
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
UI()->DoLabel(&VersionUpdate, aBuf, 14.0f, TEXTALIGN_MC); Ui()->DoLabel(&VersionUpdate, aBuf, 14.0f, TEXTALIGN_MC);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
} }
#endif #endif
UI()->DoLabel(&CurVersion, GAME_RELEASE_VERSION, 14.0f, TEXTALIGN_MR); Ui()->DoLabel(&CurVersion, GAME_RELEASE_VERSION, 14.0f, TEXTALIGN_MR);
if(NewPage != -1) if(NewPage != -1)
{ {

View file

@ -19,11 +19,11 @@ void CNamePlates::RenderNameplate(
const CNetObj_Character *pPlayerChar, const CNetObj_Character *pPlayerChar,
const CNetObj_PlayerInfo *pPlayerInfo) const CNetObj_PlayerInfo *pPlayerInfo)
{ {
int ClientID = pPlayerInfo->m_ClientID; int ClientId = pPlayerInfo->m_ClientId;
vec2 Position; vec2 Position;
if(ClientID >= 0 && ClientID < MAX_CLIENTS) if(ClientId >= 0 && ClientId < MAX_CLIENTS)
Position = m_pClient->m_aClients[ClientID].m_RenderPos; Position = m_pClient->m_aClients[ClientId].m_RenderPos;
else else
Position = mix(vec2(pPrevChar->m_X, pPrevChar->m_Y), vec2(pPlayerChar->m_X, pPlayerChar->m_Y), Client()->IntraGameTick(g_Config.m_ClDummy)); Position = mix(vec2(pPrevChar->m_X, pPrevChar->m_Y), vec2(pPlayerChar->m_X, pPlayerChar->m_Y), Client()->IntraGameTick(g_Config.m_ClDummy));
@ -32,9 +32,9 @@ void CNamePlates::RenderNameplate(
void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pPlayerInfo, float Alpha, bool ForceAlpha) void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pPlayerInfo, float Alpha, bool ForceAlpha)
{ {
int ClientID = pPlayerInfo->m_ClientID; int ClientId = pPlayerInfo->m_ClientId;
bool OtherTeam = m_pClient->IsOtherTeam(ClientID); bool OtherTeam = m_pClient->IsOtherTeam(ClientId);
float FontSize = 18.0f + 20.0f * g_Config.m_ClNameplatesSize / 100.0f; float FontSize = 18.0f + 20.0f * g_Config.m_ClNameplatesSize / 100.0f;
float FontSizeClan = 18.0f + 20.0f * g_Config.m_ClNameplatesClanSize / 100.0f; float FontSizeClan = 18.0f + 20.0f * g_Config.m_ClNameplatesClanSize / 100.0f;
@ -49,7 +49,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
if(IVideo::Current()) if(IVideo::Current())
ShowDirection = g_Config.m_ClVideoShowDirection; ShowDirection = g_Config.m_ClVideoShowDirection;
#endif #endif
if((ShowDirection && ShowDirection != 3 && !pPlayerInfo->m_Local) || (ShowDirection >= 2 && pPlayerInfo->m_Local) || (ShowDirection == 3 && Client()->DummyConnected() && Client()->State() != IClient::STATE_DEMOPLAYBACK && ClientID == m_pClient->m_aLocalIDs[!g_Config.m_ClDummy])) if((ShowDirection && ShowDirection != 3 && !pPlayerInfo->m_Local) || (ShowDirection >= 2 && pPlayerInfo->m_Local) || (ShowDirection == 3 && Client()->DummyConnected() && Client()->State() != IClient::STATE_DEMOPLAYBACK && ClientId == m_pClient->m_aLocalIds[!g_Config.m_ClDummy]))
{ {
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
Graphics()->QuadsSetRotation(0); Graphics()->QuadsSetRotation(0);
@ -58,9 +58,9 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
YOffset -= ShowDirectionImgSize; YOffset -= ShowDirectionImgSize;
vec2 ShowDirectionPos = vec2(Position.x - 11.0f, YOffset); vec2 ShowDirectionPos = vec2(Position.x - 11.0f, YOffset);
bool DirLeft = m_pClient->m_Snap.m_aCharacters[pPlayerInfo->m_ClientID].m_Cur.m_Direction == -1; bool DirLeft = m_pClient->m_Snap.m_aCharacters[pPlayerInfo->m_ClientId].m_Cur.m_Direction == -1;
bool DirRight = m_pClient->m_Snap.m_aCharacters[pPlayerInfo->m_ClientID].m_Cur.m_Direction == 1; bool DirRight = m_pClient->m_Snap.m_aCharacters[pPlayerInfo->m_ClientId].m_Cur.m_Direction == 1;
bool Jump = m_pClient->m_Snap.m_aCharacters[pPlayerInfo->m_ClientID].m_Cur.m_Jumped & 1; bool Jump = m_pClient->m_Snap.m_aCharacters[pPlayerInfo->m_ClientId].m_Cur.m_Jumped & 1;
if(pPlayerInfo->m_Local && Client()->State() != IClient::STATE_DEMOPLAYBACK) if(pPlayerInfo->m_Local && Client()->State() != IClient::STATE_DEMOPLAYBACK)
{ {
@ -68,7 +68,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
DirRight = m_pClient->m_Controls.m_aInputData[g_Config.m_ClDummy].m_Direction == 1; DirRight = m_pClient->m_Controls.m_aInputData[g_Config.m_ClDummy].m_Direction == 1;
Jump = m_pClient->m_Controls.m_aInputData[g_Config.m_ClDummy].m_Jump == 1; Jump = m_pClient->m_Controls.m_aInputData[g_Config.m_ClDummy].m_Jump == 1;
} }
if(Client()->DummyConnected() && Client()->State() != IClient::STATE_DEMOPLAYBACK && pPlayerInfo->m_ClientID == m_pClient->m_aLocalIDs[!g_Config.m_ClDummy]) if(Client()->DummyConnected() && Client()->State() != IClient::STATE_DEMOPLAYBACK && pPlayerInfo->m_ClientId == m_pClient->m_aLocalIds[!g_Config.m_ClDummy])
{ {
DirLeft = m_pClient->m_Controls.m_aInputData[!g_Config.m_ClDummy].m_Direction == -1; DirLeft = m_pClient->m_Controls.m_aInputData[!g_Config.m_ClDummy].m_Direction == -1;
DirRight = m_pClient->m_Controls.m_aInputData[!g_Config.m_ClDummy].m_Direction == 1; DirRight = m_pClient->m_Controls.m_aInputData[!g_Config.m_ClDummy].m_Direction == 1;
@ -102,11 +102,11 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
if(g_Config.m_ClNameplatesAlways == 0) if(g_Config.m_ClNameplatesAlways == 0)
a = clamp(1 - std::pow(distance(m_pClient->m_Controls.m_aTargetPos[g_Config.m_ClDummy], Position) / 200.0f, 16.0f), 0.0f, 1.0f); a = clamp(1 - std::pow(distance(m_pClient->m_Controls.m_aTargetPos[g_Config.m_ClDummy], Position) / 200.0f, 16.0f), 0.0f, 1.0f);
const char *pName = m_pClient->m_aClients[pPlayerInfo->m_ClientID].m_aName; const char *pName = m_pClient->m_aClients[pPlayerInfo->m_ClientId].m_aName;
if(str_comp(pName, m_aNamePlates[ClientID].m_aName) != 0 || FontSize != m_aNamePlates[ClientID].m_NameTextFontSize) if(str_comp(pName, m_aNamePlates[ClientId].m_aName) != 0 || FontSize != m_aNamePlates[ClientId].m_NameTextFontSize)
{ {
mem_copy(m_aNamePlates[ClientID].m_aName, pName, sizeof(m_aNamePlates[ClientID].m_aName)); mem_copy(m_aNamePlates[ClientId].m_aName, pName, sizeof(m_aNamePlates[ClientId].m_aName));
m_aNamePlates[ClientID].m_NameTextFontSize = FontSize; m_aNamePlates[ClientId].m_NameTextFontSize = FontSize;
CTextCursor Cursor; CTextCursor Cursor;
TextRender()->SetCursor(&Cursor, 0, 0, FontSize, TEXTFLAG_RENDER); TextRender()->SetCursor(&Cursor, 0, 0, FontSize, TEXTFLAG_RENDER);
@ -117,19 +117,19 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1); Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
RenderTools()->MapScreenToInterface(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y); RenderTools()->MapScreenToInterface(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y);
m_aNamePlates[ClientID].m_NameTextWidth = TextRender()->TextWidth(FontSize, pName, -1, -1.0f); m_aNamePlates[ClientId].m_NameTextWidth = TextRender()->TextWidth(FontSize, pName, -1, -1.0f);
TextRender()->RecreateTextContainer(m_aNamePlates[ClientID].m_NameTextContainerIndex, &Cursor, pName); TextRender()->RecreateTextContainer(m_aNamePlates[ClientId].m_NameTextContainerIndex, &Cursor, pName);
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1); Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
} }
if(g_Config.m_ClNameplatesClan) if(g_Config.m_ClNameplatesClan)
{ {
const char *pClan = m_pClient->m_aClients[ClientID].m_aClan; const char *pClan = m_pClient->m_aClients[ClientId].m_aClan;
if(str_comp(pClan, m_aNamePlates[ClientID].m_aClanName) != 0 || FontSizeClan != m_aNamePlates[ClientID].m_ClanNameTextFontSize) if(str_comp(pClan, m_aNamePlates[ClientId].m_aClanName) != 0 || FontSizeClan != m_aNamePlates[ClientId].m_ClanNameTextFontSize)
{ {
mem_copy(m_aNamePlates[ClientID].m_aClanName, pClan, sizeof(m_aNamePlates[ClientID].m_aClanName)); mem_copy(m_aNamePlates[ClientId].m_aClanName, pClan, sizeof(m_aNamePlates[ClientId].m_aClanName));
m_aNamePlates[ClientID].m_ClanNameTextFontSize = FontSizeClan; m_aNamePlates[ClientId].m_ClanNameTextFontSize = FontSizeClan;
CTextCursor Cursor; CTextCursor Cursor;
TextRender()->SetCursor(&Cursor, 0, 0, FontSizeClan, TEXTFLAG_RENDER); TextRender()->SetCursor(&Cursor, 0, 0, FontSizeClan, TEXTFLAG_RENDER);
@ -140,16 +140,16 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1); Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
RenderTools()->MapScreenToInterface(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y); RenderTools()->MapScreenToInterface(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y);
m_aNamePlates[ClientID].m_ClanNameTextWidth = TextRender()->TextWidth(FontSizeClan, pClan, -1, -1.0f); m_aNamePlates[ClientId].m_ClanNameTextWidth = TextRender()->TextWidth(FontSizeClan, pClan, -1, -1.0f);
TextRender()->RecreateTextContainer(m_aNamePlates[ClientID].m_ClanNameTextContainerIndex, &Cursor, pClan); TextRender()->RecreateTextContainer(m_aNamePlates[ClientId].m_ClanNameTextContainerIndex, &Cursor, pClan);
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1); Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
} }
} }
float tw = m_aNamePlates[ClientID].m_NameTextWidth; float tw = m_aNamePlates[ClientId].m_NameTextWidth;
if(g_Config.m_ClNameplatesTeamcolors && m_pClient->m_Teams.Team(ClientID)) if(g_Config.m_ClNameplatesTeamcolors && m_pClient->m_Teams.Team(ClientId))
rgb = m_pClient->GetDDTeamColor(m_pClient->m_Teams.Team(ClientID), 0.75f); rgb = m_pClient->GetDDTeamColor(m_pClient->m_Teams.Team(ClientId), 0.75f);
ColorRGBA TColor; ColorRGBA TColor;
ColorRGBA TOutlineColor; ColorRGBA TOutlineColor;
@ -166,29 +166,29 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
} }
if(g_Config.m_ClNameplatesTeamcolors && m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_TEAMS) if(g_Config.m_ClNameplatesTeamcolors && m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_TEAMS)
{ {
if(m_pClient->m_aClients[ClientID].m_Team == TEAM_RED) if(m_pClient->m_aClients[ClientId].m_Team == TEAM_RED)
TColor = ColorRGBA(1.0f, 0.5f, 0.5f, a); TColor = ColorRGBA(1.0f, 0.5f, 0.5f, a);
else if(m_pClient->m_aClients[ClientID].m_Team == TEAM_BLUE) else if(m_pClient->m_aClients[ClientId].m_Team == TEAM_BLUE)
TColor = ColorRGBA(0.7f, 0.7f, 1.0f, a); TColor = ColorRGBA(0.7f, 0.7f, 1.0f, a);
} }
TOutlineColor.a *= Alpha; TOutlineColor.a *= Alpha;
TColor.a *= Alpha; TColor.a *= Alpha;
if(m_aNamePlates[ClientID].m_NameTextContainerIndex.Valid()) if(m_aNamePlates[ClientId].m_NameTextContainerIndex.Valid())
{ {
YOffset -= FontSize; YOffset -= FontSize;
TextRender()->RenderTextContainer(m_aNamePlates[ClientID].m_NameTextContainerIndex, TColor, TOutlineColor, Position.x - tw / 2.0f, YOffset); TextRender()->RenderTextContainer(m_aNamePlates[ClientId].m_NameTextContainerIndex, TColor, TOutlineColor, Position.x - tw / 2.0f, YOffset);
} }
if(g_Config.m_ClNameplatesClan) if(g_Config.m_ClNameplatesClan)
{ {
YOffset -= FontSizeClan; YOffset -= FontSizeClan;
if(m_aNamePlates[ClientID].m_ClanNameTextContainerIndex.Valid()) if(m_aNamePlates[ClientId].m_ClanNameTextContainerIndex.Valid())
TextRender()->RenderTextContainer(m_aNamePlates[ClientID].m_ClanNameTextContainerIndex, TColor, TOutlineColor, Position.x - m_aNamePlates[ClientID].m_ClanNameTextWidth / 2.0f, YOffset); TextRender()->RenderTextContainer(m_aNamePlates[ClientId].m_ClanNameTextContainerIndex, TColor, TOutlineColor, Position.x - m_aNamePlates[ClientId].m_ClanNameTextWidth / 2.0f, YOffset);
} }
if(g_Config.m_ClNameplatesFriendMark && m_pClient->m_aClients[ClientID].m_Friend) if(g_Config.m_ClNameplatesFriendMark && m_pClient->m_aClients[ClientId].m_Friend)
{ {
YOffset -= FontSize; YOffset -= FontSize;
char aFriendMark[] = ""; char aFriendMark[] = "";
@ -207,11 +207,11 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
TextRender()->Text(Position.x - XOffSet, YOffset, FontSize, aFriendMark, -1.0f); TextRender()->Text(Position.x - XOffSet, YOffset, FontSize, aFriendMark, -1.0f);
} }
if(g_Config.m_Debug || g_Config.m_ClNameplatesIDs) // render client id when in debug as well if(g_Config.m_Debug || g_Config.m_ClNameplatesIds) // render client id when in debug as well
{ {
YOffset -= FontSize; YOffset -= FontSize;
char aBuf[128]; char aBuf[128];
str_from_int(pPlayerInfo->m_ClientID, aBuf); str_from_int(pPlayerInfo->m_ClientId, aBuf);
float XOffset = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f) / 2.0f; float XOffset = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f) / 2.0f;
TextRender()->TextColor(rgb); TextRender()->TextColor(rgb);
TextRender()->Text(Position.x - XOffset, YOffset, FontSize, aBuf, -1.0f); TextRender()->Text(Position.x - XOffset, YOffset, FontSize, aBuf, -1.0f);
@ -220,10 +220,10 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
if((g_Config.m_Debug || g_Config.m_ClNameplatesStrong) && g_Config.m_ClNameplates) if((g_Config.m_Debug || g_Config.m_ClNameplatesStrong) && g_Config.m_ClNameplates)
{ {
if(m_pClient->m_Snap.m_LocalClientID != -1 && m_pClient->m_Snap.m_aCharacters[pPlayerInfo->m_ClientID].m_HasExtendedData && m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_LocalClientID].m_HasExtendedData) if(m_pClient->m_Snap.m_LocalClientId != -1 && m_pClient->m_Snap.m_aCharacters[pPlayerInfo->m_ClientId].m_HasExtendedData && m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_LocalClientId].m_HasExtendedData)
{ {
CCharacter *pLocalChar = m_pClient->m_GameWorld.GetCharacterByID(m_pClient->m_Snap.m_LocalClientID); CCharacter *pLocalChar = m_pClient->m_GameWorld.GetCharacterById(m_pClient->m_Snap.m_LocalClientId);
CCharacter *pCharacter = m_pClient->m_GameWorld.GetCharacterByID(pPlayerInfo->m_ClientID); CCharacter *pCharacter = m_pClient->m_GameWorld.GetCharacterById(pPlayerInfo->m_ClientId);
if(pCharacter && pLocalChar) if(pCharacter && pLocalChar)
{ {
if(pPlayerInfo->m_Local) if(pPlayerInfo->m_Local)
@ -236,16 +236,16 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_STRONGWEAK].m_Id); Graphics()->TextureSet(g_pData->m_aImages[IMAGE_STRONGWEAK].m_Id);
Graphics()->QuadsBegin(); Graphics()->QuadsBegin();
ColorRGBA StrongWeakStatusColor; ColorRGBA StrongWeakStatusColor;
int StrongWeakSpriteID; int StrongWeakSpriteId;
if(pLocalChar->GetStrongWeakID() > pCharacter->GetStrongWeakID()) if(pLocalChar->GetStrongWeakId() > pCharacter->GetStrongWeakId())
{ {
StrongWeakStatusColor = color_cast<ColorRGBA>(ColorHSLA(6401973)); StrongWeakStatusColor = color_cast<ColorRGBA>(ColorHSLA(6401973));
StrongWeakSpriteID = SPRITE_HOOK_STRONG; StrongWeakSpriteId = SPRITE_HOOK_STRONG;
} }
else else
{ {
StrongWeakStatusColor = color_cast<ColorRGBA>(ColorHSLA(41131)); StrongWeakStatusColor = color_cast<ColorRGBA>(ColorHSLA(41131));
StrongWeakSpriteID = SPRITE_HOOK_WEAK; StrongWeakSpriteId = SPRITE_HOOK_WEAK;
} }
float ClampedAlpha = 1; float ClampedAlpha = 1;
@ -259,8 +259,8 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
StrongWeakStatusColor.a *= Alpha; StrongWeakStatusColor.a *= Alpha;
Graphics()->SetColor(StrongWeakStatusColor); Graphics()->SetColor(StrongWeakStatusColor);
RenderTools()->SelectSprite(StrongWeakSpriteID); RenderTools()->SelectSprite(StrongWeakSpriteId);
RenderTools()->GetSpriteScale(StrongWeakSpriteID, ScaleX, ScaleY); RenderTools()->GetSpriteScale(StrongWeakSpriteId, ScaleX, ScaleY);
TextRender()->TextColor(StrongWeakStatusColor); TextRender()->TextColor(StrongWeakStatusColor);
YOffset -= StrongWeakImgSize * ScaleY; YOffset -= StrongWeakImgSize * ScaleY;
@ -271,7 +271,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
{ {
YOffset -= FontSize; YOffset -= FontSize;
char aBuf[12]; char aBuf[12];
str_from_int(pCharacter->GetStrongWeakID(), aBuf); str_from_int(pCharacter->GetStrongWeakId(), aBuf);
float XOffset = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f) / 2.0f; float XOffset = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f) / 2.0f;
TextRender()->Text(Position.x - XOffset, YOffset, FontSize, aBuf, -1.0f); TextRender()->Text(Position.x - XOffset, YOffset, FontSize, aBuf, -1.0f);
} }

View file

@ -71,19 +71,19 @@ inline float AngularApproach(float Src, float Dst, float Amount)
float CPlayers::GetPlayerTargetAngle( float CPlayers::GetPlayerTargetAngle(
const CNetObj_Character *pPrevChar, const CNetObj_Character *pPrevChar,
const CNetObj_Character *pPlayerChar, const CNetObj_Character *pPlayerChar,
int ClientID, int ClientId,
float Intra) float Intra)
{ {
float AngleIntraTick = Intra; float AngleIntraTick = Intra;
// using unpredicted angle when rendering other players in-game // using unpredicted angle when rendering other players in-game
if(ClientID >= 0) if(ClientId >= 0)
AngleIntraTick = Client()->IntraGameTick(g_Config.m_ClDummy); AngleIntraTick = Client()->IntraGameTick(g_Config.m_ClDummy);
if(ClientID >= 0 && m_pClient->m_Snap.m_aCharacters[ClientID].m_HasExtendedDisplayInfo) if(ClientId >= 0 && m_pClient->m_Snap.m_aCharacters[ClientId].m_HasExtendedDisplayInfo)
{ {
CNetObj_DDNetCharacter *pExtendedData = &m_pClient->m_Snap.m_aCharacters[ClientID].m_ExtendedData; CNetObj_DDNetCharacter *pExtendedData = &m_pClient->m_Snap.m_aCharacters[ClientId].m_ExtendedData;
if(m_pClient->m_Snap.m_aCharacters[ClientID].m_PrevExtendedData) if(m_pClient->m_Snap.m_aCharacters[ClientId].m_PrevExtendedData)
{ {
const CNetObj_DDNetCharacter *PrevExtendedData = m_pClient->m_Snap.m_aCharacters[ClientID].m_PrevExtendedData; const CNetObj_DDNetCharacter *PrevExtendedData = m_pClient->m_Snap.m_aCharacters[ClientId].m_PrevExtendedData;
float MixX = mix((float)PrevExtendedData->m_TargetX, (float)pExtendedData->m_TargetX, AngleIntraTick); float MixX = mix((float)PrevExtendedData->m_TargetX, (float)pExtendedData->m_TargetX, AngleIntraTick);
float MixY = mix((float)PrevExtendedData->m_TargetY, (float)pExtendedData->m_TargetY, AngleIntraTick); float MixY = mix((float)PrevExtendedData->m_TargetY, (float)pExtendedData->m_TargetY, AngleIntraTick);
@ -118,7 +118,7 @@ float CPlayers::GetPlayerTargetAngle(
void CPlayers::RenderHookCollLine( void CPlayers::RenderHookCollLine(
const CNetObj_Character *pPrevChar, const CNetObj_Character *pPrevChar,
const CNetObj_Character *pPlayerChar, const CNetObj_Character *pPlayerChar,
int ClientID, int ClientId,
float Intra) float Intra)
{ {
CNetObj_Character Prev; CNetObj_Character Prev;
@ -126,36 +126,36 @@ void CPlayers::RenderHookCollLine(
Prev = *pPrevChar; Prev = *pPrevChar;
Player = *pPlayerChar; Player = *pPlayerChar;
bool Local = m_pClient->m_Snap.m_LocalClientID == ClientID; bool Local = m_pClient->m_Snap.m_LocalClientId == ClientId;
bool OtherTeam = m_pClient->IsOtherTeam(ClientID); bool OtherTeam = m_pClient->IsOtherTeam(ClientId);
float Alpha = (OtherTeam || ClientID < 0) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f; float Alpha = (OtherTeam || ClientId < 0) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f;
Alpha *= (float)g_Config.m_ClHookCollAlpha / 100; Alpha *= (float)g_Config.m_ClHookCollAlpha / 100;
float IntraTick = Intra; float IntraTick = Intra;
if(ClientID >= 0) if(ClientId >= 0)
IntraTick = m_pClient->m_aClients[ClientID].m_IsPredicted ? Client()->PredIntraGameTick(g_Config.m_ClDummy) : Client()->IntraGameTick(g_Config.m_ClDummy); IntraTick = m_pClient->m_aClients[ClientId].m_IsPredicted ? Client()->PredIntraGameTick(g_Config.m_ClDummy) : Client()->IntraGameTick(g_Config.m_ClDummy);
float Angle; float Angle;
if(Local && (!m_pClient->m_Snap.m_SpecInfo.m_Active || m_pClient->m_Snap.m_SpecInfo.m_SpectatorID != SPEC_FREEVIEW) && Client()->State() != IClient::STATE_DEMOPLAYBACK) if(Local && (!m_pClient->m_Snap.m_SpecInfo.m_Active || m_pClient->m_Snap.m_SpecInfo.m_SpectatorId != SPEC_FREEVIEW) && Client()->State() != IClient::STATE_DEMOPLAYBACK)
{ {
// just use the direct input if it's the local player we are rendering // just use the direct input if it's the local player we are rendering
Angle = angle(m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy] * m_pClient->m_Camera.m_Zoom); Angle = angle(m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy] * m_pClient->m_Camera.m_Zoom);
} }
else else
{ {
Angle = GetPlayerTargetAngle(&Prev, &Player, ClientID, IntraTick); Angle = GetPlayerTargetAngle(&Prev, &Player, ClientId, IntraTick);
} }
vec2 Direction = direction(Angle); vec2 Direction = direction(Angle);
vec2 Position; vec2 Position;
if(in_range(ClientID, MAX_CLIENTS - 1)) if(in_range(ClientId, MAX_CLIENTS - 1))
Position = m_pClient->m_aClients[ClientID].m_RenderPos; Position = m_pClient->m_aClients[ClientId].m_RenderPos;
else else
Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick); Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick);
// draw hook collision line // draw hook collision line
{ {
bool AlwaysRenderHookColl = GameClient()->m_GameInfo.m_AllowHookColl && (Local ? g_Config.m_ClShowHookCollOwn : g_Config.m_ClShowHookCollOther) == 2; bool AlwaysRenderHookColl = GameClient()->m_GameInfo.m_AllowHookColl && (Local ? g_Config.m_ClShowHookCollOwn : g_Config.m_ClShowHookCollOther) == 2;
bool RenderHookCollPlayer = ClientID >= 0 && Player.m_PlayerFlags & PLAYERFLAG_AIM && (Local ? g_Config.m_ClShowHookCollOwn : g_Config.m_ClShowHookCollOther) > 0; bool RenderHookCollPlayer = ClientId >= 0 && Player.m_PlayerFlags & PLAYERFLAG_AIM && (Local ? g_Config.m_ClShowHookCollOwn : g_Config.m_ClShowHookCollOther) > 0;
if(Local && GameClient()->m_GameInfo.m_AllowHookColl && Client()->State() != IClient::STATE_DEMOPLAYBACK) if(Local && GameClient()->m_GameInfo.m_AllowHookColl && Client()->State() != IClient::STATE_DEMOPLAYBACK)
RenderHookCollPlayer = GameClient()->m_Controls.m_aShowHookColl[g_Config.m_ClDummy] && g_Config.m_ClShowHookCollOwn > 0; RenderHookCollPlayer = GameClient()->m_Controls.m_aShowHookColl[g_Config.m_ClDummy] && g_Config.m_ClShowHookCollOwn > 0;
@ -167,7 +167,7 @@ void CPlayers::RenderHookCollLine(
{ {
vec2 ExDirection = Direction; vec2 ExDirection = Direction;
if(Local && (!m_pClient->m_Snap.m_SpecInfo.m_Active || m_pClient->m_Snap.m_SpecInfo.m_SpectatorID != SPEC_FREEVIEW) && Client()->State() != IClient::STATE_DEMOPLAYBACK) if(Local && (!m_pClient->m_Snap.m_SpecInfo.m_Active || m_pClient->m_Snap.m_SpecInfo.m_SpectatorId != SPEC_FREEVIEW) && Client()->State() != IClient::STATE_DEMOPLAYBACK)
{ {
ExDirection = normalize( ExDirection = normalize(
vec2((int)((int)m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy].x * m_pClient->m_Camera.m_Zoom), vec2((int)((int)m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy].x * m_pClient->m_Camera.m_Zoom),
@ -214,7 +214,7 @@ void CPlayers::RenderHookCollLine(
} }
} }
if(m_pClient->IntersectCharacter(OldPos, FinishPos, FinishPos, ClientID) != -1) if(m_pClient->IntersectCharacter(OldPos, FinishPos, FinishPos, ClientId) != -1)
{ {
HookCollColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClHookCollColorTeeColl)); HookCollColor = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClHookCollColorTeeColl));
break; break;
@ -264,7 +264,7 @@ void CPlayers::RenderHook(
const CNetObj_Character *pPrevChar, const CNetObj_Character *pPrevChar,
const CNetObj_Character *pPlayerChar, const CNetObj_Character *pPlayerChar,
const CTeeRenderInfo *pRenderInfo, const CTeeRenderInfo *pRenderInfo,
int ClientID, int ClientId,
float Intra) float Intra)
{ {
CNetObj_Character Prev; CNetObj_Character Prev;
@ -279,19 +279,19 @@ void CPlayers::RenderHook(
return; return;
float IntraTick = Intra; float IntraTick = Intra;
if(ClientID >= 0) if(ClientId >= 0)
IntraTick = (m_pClient->m_aClients[ClientID].m_IsPredicted) ? Client()->PredIntraGameTick(g_Config.m_ClDummy) : Client()->IntraGameTick(g_Config.m_ClDummy); IntraTick = (m_pClient->m_aClients[ClientId].m_IsPredicted) ? Client()->PredIntraGameTick(g_Config.m_ClDummy) : Client()->IntraGameTick(g_Config.m_ClDummy);
bool OtherTeam = m_pClient->IsOtherTeam(ClientID); bool OtherTeam = m_pClient->IsOtherTeam(ClientId);
float Alpha = (OtherTeam || ClientID < 0) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f; float Alpha = (OtherTeam || ClientId < 0) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f;
if(ClientID == -2) // ghost if(ClientId == -2) // ghost
Alpha = g_Config.m_ClRaceGhostAlpha / 100.0f; Alpha = g_Config.m_ClRaceGhostAlpha / 100.0f;
RenderInfo.m_Size = 64.0f; RenderInfo.m_Size = 64.0f;
vec2 Position; vec2 Position;
if(in_range(ClientID, MAX_CLIENTS - 1)) if(in_range(ClientId, MAX_CLIENTS - 1))
Position = m_pClient->m_aClients[ClientID].m_RenderPos; Position = m_pClient->m_aClients[ClientId].m_RenderPos;
else else
Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick); Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick);
@ -299,7 +299,7 @@ void CPlayers::RenderHook(
if(Prev.m_HookState > 0 && Player.m_HookState > 0) if(Prev.m_HookState > 0 && Player.m_HookState > 0)
{ {
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
if(ClientID < 0) if(ClientId < 0)
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.5f); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.5f);
vec2 Pos = Position; vec2 Pos = Position;
@ -346,7 +346,7 @@ void CPlayers::RenderPlayer(
const CNetObj_Character *pPrevChar, const CNetObj_Character *pPrevChar,
const CNetObj_Character *pPlayerChar, const CNetObj_Character *pPlayerChar,
const CTeeRenderInfo *pRenderInfo, const CTeeRenderInfo *pRenderInfo,
int ClientID, int ClientId,
float Intra) float Intra)
{ {
CNetObj_Character Prev; CNetObj_Character Prev;
@ -356,18 +356,18 @@ void CPlayers::RenderPlayer(
CTeeRenderInfo RenderInfo = *pRenderInfo; CTeeRenderInfo RenderInfo = *pRenderInfo;
bool Local = m_pClient->m_Snap.m_LocalClientID == ClientID; bool Local = m_pClient->m_Snap.m_LocalClientId == ClientId;
bool OtherTeam = m_pClient->IsOtherTeam(ClientID); bool OtherTeam = m_pClient->IsOtherTeam(ClientId);
float Alpha = (OtherTeam || ClientID < 0) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f; float Alpha = (OtherTeam || ClientId < 0) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f;
if(ClientID == -2) // ghost if(ClientId == -2) // ghost
Alpha = g_Config.m_ClRaceGhostAlpha / 100.0f; Alpha = g_Config.m_ClRaceGhostAlpha / 100.0f;
// set size // set size
RenderInfo.m_Size = 64.0f; RenderInfo.m_Size = 64.0f;
float IntraTick = Intra; float IntraTick = Intra;
if(ClientID >= 0) if(ClientId >= 0)
IntraTick = m_pClient->m_aClients[ClientID].m_IsPredicted ? Client()->PredIntraGameTick(g_Config.m_ClDummy) : Client()->IntraGameTick(g_Config.m_ClDummy); IntraTick = m_pClient->m_aClients[ClientId].m_IsPredicted ? Client()->PredIntraGameTick(g_Config.m_ClDummy) : Client()->IntraGameTick(g_Config.m_ClDummy);
static float s_LastGameTickTime = Client()->GameTickTime(g_Config.m_ClDummy); static float s_LastGameTickTime = Client()->GameTickTime(g_Config.m_ClDummy);
static float s_LastPredIntraTick = Client()->PredIntraGameTick(g_Config.m_ClDummy); static float s_LastPredIntraTick = Client()->PredIntraGameTick(g_Config.m_ClDummy);
@ -380,7 +380,7 @@ void CPlayers::RenderPlayer(
bool PredictLocalWeapons = false; bool PredictLocalWeapons = false;
float AttackTime = (Client()->PrevGameTick(g_Config.m_ClDummy) - Player.m_AttackTick) / (float)Client()->GameTickSpeed() + Client()->GameTickTime(g_Config.m_ClDummy); float AttackTime = (Client()->PrevGameTick(g_Config.m_ClDummy) - Player.m_AttackTick) / (float)Client()->GameTickSpeed() + Client()->GameTickTime(g_Config.m_ClDummy);
float LastAttackTime = (Client()->PrevGameTick(g_Config.m_ClDummy) - Player.m_AttackTick) / (float)Client()->GameTickSpeed() + s_LastGameTickTime; float LastAttackTime = (Client()->PrevGameTick(g_Config.m_ClDummy) - Player.m_AttackTick) / (float)Client()->GameTickSpeed() + s_LastGameTickTime;
if(ClientID >= 0 && m_pClient->m_aClients[ClientID].m_IsPredictedLocal && m_pClient->AntiPingGunfire()) if(ClientId >= 0 && m_pClient->m_aClients[ClientId].m_IsPredictedLocal && m_pClient->AntiPingGunfire())
{ {
PredictLocalWeapons = true; PredictLocalWeapons = true;
AttackTime = (Client()->PredIntraGameTick(g_Config.m_ClDummy) + (Client()->PredGameTick(g_Config.m_ClDummy) - 1 - Player.m_AttackTick)) / (float)Client()->GameTickSpeed(); AttackTime = (Client()->PredIntraGameTick(g_Config.m_ClDummy) + (Client()->PredGameTick(g_Config.m_ClDummy) - 1 - Player.m_AttackTick)) / (float)Client()->GameTickSpeed();
@ -389,20 +389,20 @@ void CPlayers::RenderPlayer(
float AttackTicksPassed = AttackTime * (float)Client()->GameTickSpeed(); float AttackTicksPassed = AttackTime * (float)Client()->GameTickSpeed();
float Angle; float Angle;
if(Local && (!m_pClient->m_Snap.m_SpecInfo.m_Active || m_pClient->m_Snap.m_SpecInfo.m_SpectatorID != SPEC_FREEVIEW) && Client()->State() != IClient::STATE_DEMOPLAYBACK) if(Local && (!m_pClient->m_Snap.m_SpecInfo.m_Active || m_pClient->m_Snap.m_SpecInfo.m_SpectatorId != SPEC_FREEVIEW) && Client()->State() != IClient::STATE_DEMOPLAYBACK)
{ {
// just use the direct input if it's the local player we are rendering // just use the direct input if it's the local player we are rendering
Angle = angle(m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy] * m_pClient->m_Camera.m_Zoom); Angle = angle(m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy] * m_pClient->m_Camera.m_Zoom);
} }
else else
{ {
Angle = GetPlayerTargetAngle(&Prev, &Player, ClientID, IntraTick); Angle = GetPlayerTargetAngle(&Prev, &Player, ClientId, IntraTick);
} }
vec2 Direction = direction(Angle); vec2 Direction = direction(Angle);
vec2 Position; vec2 Position;
if(in_range(ClientID, MAX_CLIENTS - 1)) if(in_range(ClientId, MAX_CLIENTS - 1))
Position = m_pClient->m_aClients[ClientID].m_RenderPos; Position = m_pClient->m_aClients[ClientId].m_RenderPos;
else else
Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick); Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick);
vec2 Vel = mix(vec2(Prev.m_VelX / 256.0f, Prev.m_VelY / 256.0f), vec2(Player.m_VelX / 256.0f, Player.m_VelY / 256.0f), IntraTick); vec2 Vel = mix(vec2(Prev.m_VelX / 256.0f, Prev.m_VelY / 256.0f), vec2(Player.m_VelX / 256.0f, Player.m_VelY / 256.0f), IntraTick);
@ -417,7 +417,7 @@ void CPlayers::RenderPlayer(
bool InAir = !Collision()->CheckPoint(Player.m_X, Player.m_Y + 16); bool InAir = !Collision()->CheckPoint(Player.m_X, Player.m_Y + 16);
bool Running = Player.m_VelX >= 5000 || Player.m_VelX <= -5000; bool Running = Player.m_VelX >= 5000 || Player.m_VelX <= -5000;
bool WantOtherDir = (Player.m_Direction == -1 && Vel.x > 0) || (Player.m_Direction == 1 && Vel.x < 0); bool WantOtherDir = (Player.m_Direction == -1 && Vel.x > 0) || (Player.m_Direction == 1 && Vel.x < 0);
bool Inactive = m_pClient->m_aClients[ClientID].m_Afk || m_pClient->m_aClients[ClientID].m_Paused; bool Inactive = m_pClient->m_aClients[ClientId].m_Afk || m_pClient->m_aClients[ClientId].m_Paused;
// evaluate animation // evaluate animation
float WalkTime = std::fmod(Position.x, 100.0f) / 100.0f; float WalkTime = std::fmod(Position.x, 100.0f) / 100.0f;
@ -481,7 +481,7 @@ void CPlayers::RenderPlayer(
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
Graphics()->QuadsSetRotation(State.GetAttach()->m_Angle * pi * 2 + Angle); Graphics()->QuadsSetRotation(State.GetAttach()->m_Angle * pi * 2 + Angle);
if(ClientID < 0) if(ClientId < 0)
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.5f); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.5f);
// normal weapons // normal weapons
@ -564,7 +564,7 @@ void CPlayers::RenderPlayer(
if(PredictLocalWeapons) if(PredictLocalWeapons)
Dir = vec2(pPlayerChar->m_X, pPlayerChar->m_Y) - vec2(pPrevChar->m_X, pPrevChar->m_Y); Dir = vec2(pPlayerChar->m_X, pPlayerChar->m_Y) - vec2(pPrevChar->m_X, pPrevChar->m_Y);
else else
Dir = vec2(m_pClient->m_Snap.m_aCharacters[ClientID].m_Cur.m_X, m_pClient->m_Snap.m_aCharacters[ClientID].m_Cur.m_Y) - vec2(m_pClient->m_Snap.m_aCharacters[ClientID].m_Prev.m_X, m_pClient->m_Snap.m_aCharacters[ClientID].m_Prev.m_Y); Dir = vec2(m_pClient->m_Snap.m_aCharacters[ClientId].m_Cur.m_X, m_pClient->m_Snap.m_aCharacters[ClientId].m_Cur.m_Y) - vec2(m_pClient->m_Snap.m_aCharacters[ClientId].m_Prev.m_X, m_pClient->m_Snap.m_aCharacters[ClientId].m_Prev.m_Y);
float HadOkenAngle = 0; float HadOkenAngle = 0;
if(absolute(Dir.x) > 0.0001f || absolute(Dir.y) > 0.0001f) if(absolute(Dir.x) > 0.0001f || absolute(Dir.y) > 0.0001f)
{ {
@ -661,10 +661,10 @@ void CPlayers::RenderPlayer(
if(Local && ((g_Config.m_Debug && g_Config.m_ClUnpredictedShadow >= 0) || g_Config.m_ClUnpredictedShadow == 1)) if(Local && ((g_Config.m_Debug && g_Config.m_ClUnpredictedShadow >= 0) || g_Config.m_ClUnpredictedShadow == 1))
{ {
vec2 ShadowPosition = Position; vec2 ShadowPosition = Position;
if(ClientID >= 0) if(ClientId >= 0)
ShadowPosition = mix( ShadowPosition = mix(
vec2(m_pClient->m_Snap.m_aCharacters[ClientID].m_Prev.m_X, m_pClient->m_Snap.m_aCharacters[ClientID].m_Prev.m_Y), vec2(m_pClient->m_Snap.m_aCharacters[ClientId].m_Prev.m_X, m_pClient->m_Snap.m_aCharacters[ClientId].m_Prev.m_Y),
vec2(m_pClient->m_Snap.m_aCharacters[ClientID].m_Cur.m_X, m_pClient->m_Snap.m_aCharacters[ClientID].m_Cur.m_Y), vec2(m_pClient->m_Snap.m_aCharacters[ClientId].m_Cur.m_X, m_pClient->m_Snap.m_aCharacters[ClientId].m_Cur.m_Y),
Client()->IntraGameTick(g_Config.m_ClDummy)); Client()->IntraGameTick(g_Config.m_ClDummy));
CTeeRenderInfo Shadow = RenderInfo; CTeeRenderInfo Shadow = RenderInfo;
@ -682,7 +682,7 @@ void CPlayers::RenderPlayer(
} }
int QuadOffsetToEmoticon = NUM_WEAPONS * 2 + 2 + 2; int QuadOffsetToEmoticon = NUM_WEAPONS * 2 + 2 + 2;
if((Player.m_PlayerFlags & PLAYERFLAG_CHATTING) && !m_pClient->m_aClients[ClientID].m_Afk) if((Player.m_PlayerFlags & PLAYERFLAG_CHATTING) && !m_pClient->m_aClients[ClientId].m_Afk)
{ {
int CurEmoticon = (SPRITE_DOTDOT - SPRITE_OOP); int CurEmoticon = (SPRITE_DOTDOT - SPRITE_OOP);
Graphics()->TextureSet(GameClient()->m_EmoticonsSkin.m_aSpriteEmoticons[CurEmoticon]); Graphics()->TextureSet(GameClient()->m_EmoticonsSkin.m_aSpriteEmoticons[CurEmoticon]);
@ -694,10 +694,10 @@ void CPlayers::RenderPlayer(
Graphics()->QuadsSetRotation(0); Graphics()->QuadsSetRotation(0);
} }
if(ClientID < 0) if(ClientId < 0)
return; return;
if(g_Config.m_ClAfkEmote && m_pClient->m_aClients[ClientID].m_Afk && !(Client()->DummyConnected() && ClientID == m_pClient->m_aLocalIDs[!g_Config.m_ClDummy])) if(g_Config.m_ClAfkEmote && m_pClient->m_aClients[ClientId].m_Afk && !(Client()->DummyConnected() && ClientId == m_pClient->m_aLocalIds[!g_Config.m_ClDummy]))
{ {
int CurEmoticon = (SPRITE_ZZZ - SPRITE_OOP); int CurEmoticon = (SPRITE_ZZZ - SPRITE_OOP);
Graphics()->TextureSet(GameClient()->m_EmoticonsSkin.m_aSpriteEmoticons[CurEmoticon]); Graphics()->TextureSet(GameClient()->m_EmoticonsSkin.m_aSpriteEmoticons[CurEmoticon]);
@ -709,9 +709,9 @@ void CPlayers::RenderPlayer(
Graphics()->QuadsSetRotation(0); Graphics()->QuadsSetRotation(0);
} }
if(g_Config.m_ClShowEmotes && !m_pClient->m_aClients[ClientID].m_EmoticonIgnore && m_pClient->m_aClients[ClientID].m_EmoticonStartTick != -1) if(g_Config.m_ClShowEmotes && !m_pClient->m_aClients[ClientId].m_EmoticonIgnore && m_pClient->m_aClients[ClientId].m_EmoticonStartTick != -1)
{ {
float SinceStart = (Client()->GameTick(g_Config.m_ClDummy) - m_pClient->m_aClients[ClientID].m_EmoticonStartTick) + (Client()->IntraGameTickSincePrev(g_Config.m_ClDummy) - m_pClient->m_aClients[ClientID].m_EmoticonStartFraction); float SinceStart = (Client()->GameTick(g_Config.m_ClDummy) - m_pClient->m_aClients[ClientId].m_EmoticonStartTick) + (Client()->IntraGameTickSincePrev(g_Config.m_ClDummy) - m_pClient->m_aClients[ClientId].m_EmoticonStartFraction);
float FromEnd = (2 * Client()->GameTickSpeed()) - SinceStart; float FromEnd = (2 * Client()->GameTickSpeed()) - SinceStart;
if(0 <= SinceStart && FromEnd > 0) if(0 <= SinceStart && FromEnd > 0)
@ -735,8 +735,8 @@ void CPlayers::RenderPlayer(
Graphics()->SetColor(1.0f, 1.0f, 1.0f, a * Alpha); Graphics()->SetColor(1.0f, 1.0f, 1.0f, a * Alpha);
// client_datas::emoticon is an offset from the first emoticon // client_datas::emoticon is an offset from the first emoticon
int QuadOffset = QuadOffsetToEmoticon + m_pClient->m_aClients[ClientID].m_Emoticon; int QuadOffset = QuadOffsetToEmoticon + m_pClient->m_aClients[ClientId].m_Emoticon;
Graphics()->TextureSet(GameClient()->m_EmoticonsSkin.m_aSpriteEmoticons[m_pClient->m_aClients[ClientID].m_Emoticon]); Graphics()->TextureSet(GameClient()->m_EmoticonsSkin.m_aSpriteEmoticons[m_pClient->m_aClients[ClientId].m_Emoticon]);
Graphics()->RenderQuadContainerAsSprite(m_WeaponEmoteQuadContainerIndex, QuadOffset, Position.x, Position.y - 23.f - 32.f * h, 1.f, (64.f * h) / 64.f); Graphics()->RenderQuadContainerAsSprite(m_WeaponEmoteQuadContainerIndex, QuadOffset, Position.x, Position.y - 23.f - 32.f * h, 1.f, (64.f * h) / 64.f);
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
@ -745,10 +745,10 @@ void CPlayers::RenderPlayer(
} }
} }
inline bool CPlayers::IsPlayerInfoAvailable(int ClientID) const inline bool CPlayers::IsPlayerInfoAvailable(int ClientId) const
{ {
const void *pPrevInfo = Client()->SnapFindItem(IClient::SNAP_PREV, NETOBJTYPE_PLAYERINFO, ClientID); const void *pPrevInfo = Client()->SnapFindItem(IClient::SNAP_PREV, NETOBJTYPE_PLAYERINFO, ClientId);
const void *pInfo = Client()->SnapFindItem(IClient::SNAP_CURRENT, NETOBJTYPE_PLAYERINFO, ClientID); const void *pInfo = Client()->SnapFindItem(IClient::SNAP_CURRENT, NETOBJTYPE_PLAYERINFO, ClientId);
return pPrevInfo && pInfo; return pPrevInfo && pInfo;
} }
@ -798,7 +798,7 @@ void CPlayers::OnRender()
RenderInfoSpec.m_SkinMetrics = pSkin->m_Metrics; RenderInfoSpec.m_SkinMetrics = pSkin->m_Metrics;
RenderInfoSpec.m_CustomColoredSkin = false; RenderInfoSpec.m_CustomColoredSkin = false;
RenderInfoSpec.m_Size = 64.0f; RenderInfoSpec.m_Size = 64.0f;
const int LocalClientID = m_pClient->m_Snap.m_LocalClientID; const int LocalClientId = m_pClient->m_Snap.m_LocalClientId;
// get screen edges to avoid rendering offscreen // get screen edges to avoid rendering offscreen
float ScreenX0, ScreenY0, ScreenX1, ScreenY1; float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
@ -814,18 +814,18 @@ void CPlayers::OnRender()
ScreenY1 += BorderBuffer; ScreenY1 += BorderBuffer;
// render everyone else's hook, then our own // render everyone else's hook, then our own
for(int ClientID = 0; ClientID < MAX_CLIENTS; ClientID++) for(int ClientId = 0; ClientId < MAX_CLIENTS; ClientId++)
{ {
if(ClientID == LocalClientID || !m_pClient->m_Snap.m_aCharacters[ClientID].m_Active || !IsPlayerInfoAvailable(ClientID)) if(ClientId == LocalClientId || !m_pClient->m_Snap.m_aCharacters[ClientId].m_Active || !IsPlayerInfoAvailable(ClientId))
{ {
continue; continue;
} }
RenderHook(&m_pClient->m_aClients[ClientID].m_RenderPrev, &m_pClient->m_aClients[ClientID].m_RenderCur, &aRenderInfo[ClientID], ClientID); RenderHook(&m_pClient->m_aClients[ClientId].m_RenderPrev, &m_pClient->m_aClients[ClientId].m_RenderCur, &aRenderInfo[ClientId], ClientId);
} }
if(LocalClientID != -1 && m_pClient->m_Snap.m_aCharacters[LocalClientID].m_Active && IsPlayerInfoAvailable(LocalClientID)) if(LocalClientId != -1 && m_pClient->m_Snap.m_aCharacters[LocalClientId].m_Active && IsPlayerInfoAvailable(LocalClientId))
{ {
const CGameClient::CClientData *pLocalClientData = &m_pClient->m_aClients[LocalClientID]; const CGameClient::CClientData *pLocalClientData = &m_pClient->m_aClients[LocalClientId];
RenderHook(&pLocalClientData->m_RenderPrev, &pLocalClientData->m_RenderCur, &aRenderInfo[LocalClientID], LocalClientID); RenderHook(&pLocalClientData->m_RenderPrev, &pLocalClientData->m_RenderCur, &aRenderInfo[LocalClientId], LocalClientId);
} }
// render spectating players // render spectating players
@ -839,30 +839,30 @@ void CPlayers::OnRender()
} }
// render everyone else's tee, then either our own or the tee we are spectating. // render everyone else's tee, then either our own or the tee we are spectating.
const int RenderLastID = (m_pClient->m_Snap.m_SpecInfo.m_SpectatorID != SPEC_FREEVIEW && m_pClient->m_Snap.m_SpecInfo.m_Active) ? m_pClient->m_Snap.m_SpecInfo.m_SpectatorID : LocalClientID; const int RenderLastId = (m_pClient->m_Snap.m_SpecInfo.m_SpectatorId != SPEC_FREEVIEW && m_pClient->m_Snap.m_SpecInfo.m_Active) ? m_pClient->m_Snap.m_SpecInfo.m_SpectatorId : LocalClientId;
for(int ClientID = 0; ClientID < MAX_CLIENTS; ClientID++) for(int ClientId = 0; ClientId < MAX_CLIENTS; ClientId++)
{ {
if(ClientID == RenderLastID || !m_pClient->m_Snap.m_aCharacters[ClientID].m_Active || !IsPlayerInfoAvailable(ClientID)) if(ClientId == RenderLastId || !m_pClient->m_Snap.m_aCharacters[ClientId].m_Active || !IsPlayerInfoAvailable(ClientId))
{ {
continue; continue;
} }
RenderHookCollLine(&m_pClient->m_aClients[ClientID].m_RenderPrev, &m_pClient->m_aClients[ClientID].m_RenderCur, ClientID); RenderHookCollLine(&m_pClient->m_aClients[ClientId].m_RenderPrev, &m_pClient->m_aClients[ClientId].m_RenderCur, ClientId);
// don't render offscreen // don't render offscreen
vec2 *pRenderPos = &m_pClient->m_aClients[ClientID].m_RenderPos; vec2 *pRenderPos = &m_pClient->m_aClients[ClientId].m_RenderPos;
if(pRenderPos->x < ScreenX0 || pRenderPos->x > ScreenX1 || pRenderPos->y < ScreenY0 || pRenderPos->y > ScreenY1) if(pRenderPos->x < ScreenX0 || pRenderPos->x > ScreenX1 || pRenderPos->y < ScreenY0 || pRenderPos->y > ScreenY1)
{ {
continue; continue;
} }
RenderPlayer(&m_pClient->m_aClients[ClientID].m_RenderPrev, &m_pClient->m_aClients[ClientID].m_RenderCur, &aRenderInfo[ClientID], ClientID); RenderPlayer(&m_pClient->m_aClients[ClientId].m_RenderPrev, &m_pClient->m_aClients[ClientId].m_RenderCur, &aRenderInfo[ClientId], ClientId);
} }
if(RenderLastID != -1 && m_pClient->m_Snap.m_aCharacters[RenderLastID].m_Active && IsPlayerInfoAvailable(RenderLastID)) if(RenderLastId != -1 && m_pClient->m_Snap.m_aCharacters[RenderLastId].m_Active && IsPlayerInfoAvailable(RenderLastId))
{ {
const CGameClient::CClientData *pClientData = &m_pClient->m_aClients[RenderLastID]; const CGameClient::CClientData *pClientData = &m_pClient->m_aClients[RenderLastId];
RenderHookCollLine(&pClientData->m_RenderPrev, &pClientData->m_RenderCur, RenderLastID); RenderHookCollLine(&pClientData->m_RenderPrev, &pClientData->m_RenderCur, RenderLastId);
RenderPlayer(&pClientData->m_RenderPrev, &pClientData->m_RenderCur, &aRenderInfo[RenderLastID], RenderLastID); RenderPlayer(&pClientData->m_RenderPrev, &pClientData->m_RenderCur, &aRenderInfo[RenderLastId], RenderLastId);
} }
} }

Some files were not shown because too many files have changed in this diff Show more