Skip to content

Commit

Permalink
Merge pull request ddnet#9116 from Robyt3/Skin-Name-Length-Constant
Browse files Browse the repository at this point in the history
Add `MAX_SKIN_LENGTH` constant
  • Loading branch information
def- authored Oct 5, 2024
2 parents bba8223 + 768d95d commit c6f2c84
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/engine/serverbrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class CServerInfo
bool m_Afk;

// skin info
char m_aSkin[24 + 1];
char m_aSkin[MAX_SKIN_LENGTH];
bool m_CustomSkinColors;
int m_CustomSkinColorBody;
int m_CustomSkinColorFeet;
Expand Down
1 change: 1 addition & 0 deletions src/engine/shared/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ enum

MAX_NAME_LENGTH = 16,
MAX_CLAN_LENGTH = 12,
MAX_SKIN_LENGTH = 24,

// message packing
MSGFLAG_VITAL = 1,
Expand Down
2 changes: 1 addition & 1 deletion src/engine/shared/serverinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CServerInfo2
int m_Score;
bool m_IsPlayer;
bool m_IsAfk;
char m_aSkin[24 + 1];
char m_aSkin[MAX_SKIN_LENGTH];
bool m_CustomSkinColors;
int m_CustomSkinColorBody;
int m_CustomSkinColorFeet;
Expand Down
4 changes: 2 additions & 2 deletions src/game/client/components/ghost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ void CGhost::OnRender()

void CGhost::InitRenderInfos(CGhostItem *pGhost)
{
char aSkinName[24];
char aSkinName[MAX_SKIN_LENGTH];
IntsToStr(&pGhost->m_Skin.m_Skin0, 6, aSkinName, std::size(aSkinName));
CTeeRenderInfo *pRenderInfo = &pGhost->m_RenderInfo;

Expand Down Expand Up @@ -685,7 +685,7 @@ void CGhost::OnRefreshSkins()
const auto &&RefindSkin = [&](auto &Ghost) {
if(Ghost.Empty())
return;
char aSkinName[24];
char aSkinName[MAX_SKIN_LENGTH];
IntsToStr(&Ghost.m_Skin.m_Skin0, 6, aSkinName, std::size(aSkinName));
CTeeRenderInfo *pRenderInfo = &Ghost.m_RenderInfo;
if(aSkinName[0] != '\0')
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/components/menus.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ class CMenus : public CComponent
bool m_IsPlayer;
bool m_IsAfk;
// skin
char m_aSkin[24 + 1];
char m_aSkin[MAX_SKIN_LENGTH];
bool m_CustomSkinColors;
int m_CustomSkinColorBody;
int m_CustomSkinColorFeet;
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/components/skins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ void CSkins::RandomizeSkin(int Dummy)
}

const size_t SkinNameSize = Dummy ? sizeof(g_Config.m_ClDummySkin) : sizeof(g_Config.m_ClPlayerSkin);
char aRandomSkinName[24];
char aRandomSkinName[MAX_SKIN_LENGTH];
str_copy(aRandomSkinName, "default", SkinNameSize);
if(!m_pClient->m_Skins.GetSkinsUnsafe().empty())
{
Expand Down
4 changes: 2 additions & 2 deletions src/game/client/components/skins.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CSkins : public CComponent
struct CDownloadSkin
{
private:
char m_aName[24];
char m_aName[MAX_SKIN_LENGTH];

public:
std::shared_ptr<CSkins::CGetPngFile> m_pTask;
Expand Down Expand Up @@ -82,7 +82,7 @@ class CSkins : public CComponent
std::unordered_map<std::string_view, std::unique_ptr<CDownloadSkin>> m_DownloadSkins;
CSkin m_PlaceholderSkin;
size_t m_DownloadingSkins = 0;
char m_aEventSkinPrefix[24];
char m_aEventSkinPrefix[MAX_SKIN_LENGTH];

bool LoadSkinPng(CImageInfo &Info, const char *pName, const char *pPath, int DirType);
const CSkin *LoadSkin(const char *pName, const char *pPath, int DirType);
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/gameclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ class CGameClient : public IGameClient
char m_aName[MAX_NAME_LENGTH];
char m_aClan[MAX_CLAN_LENGTH];
int m_Country;
char m_aSkinName[24];
char m_aSkinName[MAX_SKIN_LENGTH];
int m_SkinColor;
int m_Team;
int m_Emoticon;
Expand Down
6 changes: 5 additions & 1 deletion src/game/client/skin.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#ifndef GAME_CLIENT_SKIN_H
#define GAME_CLIENT_SKIN_H

#include <base/color.h>
#include <base/system.h>
#include <base/vmath.h>

#include <engine/graphics.h>
#include <engine/shared/protocol.h>

#include <limits>

// do this better and nicer
struct CSkin
{
private:
char m_aName[24];
char m_aName[MAX_SKIN_LENGTH];

public:
struct SSkinTextures
Expand Down
4 changes: 3 additions & 1 deletion src/game/server/teeinfo.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#ifndef GAME_SERVER_TEEINFO_H
#define GAME_SERVER_TEEINFO_H

#include <engine/shared/protocol.h>

class CTeeInfo
{
public:
char m_aSkinName[24] = {'\0'};
char m_aSkinName[MAX_SKIN_LENGTH] = "";
int m_UseCustomColor = 0;
int m_ColorBody = 0;
int m_ColorFeet = 0;
Expand Down

0 comments on commit c6f2c84

Please sign in to comment.