Compare commits

...

5 commits

Author SHA1 Message Date
Chiller Dragon faff4dc800
Merge 2a71c7fce2 into 5a4d8e26e6 2024-09-13 21:40:39 -03:00
Dennis Felsing 5a4d8e26e6
Merge pull request #8941 from Robyt3/Client-Skin07-Dummy-Skin-Name
Fix dummy 0.7 tee skin name not being used, fix some unused config variables not being detected
2024-09-13 21:30:19 +00:00
Robert Müller ffabdee953 Fix some unused config variables not being detected
Unused config variables were not detected if they were the prefix of a longer config variable which is used.
2024-09-13 21:37:25 +02:00
Robert Müller 7e1881263d Fix dummy 0.7 tee skin name not being used
The dummy 0.7 skin name was not being updated and used, causing the wrong skin to be selected when switching between player and dummy settings.
2024-09-13 21:36:31 +02:00
ChillerDragon 2a71c7fce2 Share fng and vanilla tiles with the server
While implementing a ddnet based fng mod I realized that I reimplemented
the same enum that already exists on the client side.

So this encourages fng mod developers to use the indecies that the ddnet
client already knows.
2024-09-10 09:50:26 +08:00
9 changed files with 72 additions and 54 deletions

View file

@ -2162,6 +2162,8 @@ set_src(GAME_SHARED GLOB src/game
mapitems_ex.cpp mapitems_ex.cpp
mapitems_ex.h mapitems_ex.h
mapitems_ex_types.h mapitems_ex_types.h
mapitems_fng.h
mapitems_vanilla.h
prng.cpp prng.cpp
prng.h prng.h
teamscore.cpp teamscore.cpp

View file

@ -17,7 +17,7 @@ def parse_config_variables(lines):
return matches return matches
def generate_regex(variable_code): def generate_regex(variable_code):
return fr'(g_Config\.m_{variable_code}|Config\(\)->m_{variable_code}|m_pConfig->m_{variable_code})' return fr'(g_Config\.m_{variable_code}\b|Config\(\)->m_{variable_code}\b|m_pConfig->m_{variable_code}\b)'
def find_config_variables(config_variables): def find_config_variables(config_variables):
"""Returns the config variables which were not found.""" """Returns the config variables which were not found."""

View file

@ -313,7 +313,6 @@ void CMenus::RenderSettingsTeeCustom7(CUIRect MainView)
if(DoButton_Menu(&s_RandomSkinButton, s_apDice[s_CurrentDie], 0, &RandomSkinButton, nullptr, IGraphics::CORNER_ALL, 5.0f, -0.2f)) if(DoButton_Menu(&s_RandomSkinButton, s_apDice[s_CurrentDie], 0, &RandomSkinButton, nullptr, IGraphics::CORNER_ALL, 5.0f, -0.2f))
{ {
m_pClient->m_Skins7.RandomizeSkin(m_Dummy); m_pClient->m_Skins7.RandomizeSkin(m_Dummy);
Config()->m_ClPlayer7Skin[0] = '\0';
SetNeedSendInfo(); SetNeedSendInfo();
s_CurrentDie = rand() % std::size(s_apDice); s_CurrentDie = rand() % std::size(s_apDice);
} }
@ -356,7 +355,7 @@ void CMenus::RenderSkinSelection7(CUIRect MainView)
const CSkins7::CSkin *pSkin = s_vpSkinList[i]; const CSkins7::CSkin *pSkin = s_vpSkinList[i];
if(pSkin == nullptr) if(pSkin == nullptr)
continue; continue;
if(!str_comp(pSkin->m_aName, Config()->m_ClPlayer7Skin)) if(!str_comp(pSkin->m_aName, CSkins7::ms_apSkinNameVariables[m_Dummy]))
{ {
m_pSelectedSkin = pSkin; m_pSelectedSkin = pSkin;
s_OldSelected = i; s_OldSelected = i;
@ -401,7 +400,7 @@ void CMenus::RenderSkinSelection7(CUIRect MainView)
{ {
s_LastSelectionTime = Client()->GlobalTime(); s_LastSelectionTime = Client()->GlobalTime();
m_pSelectedSkin = s_vpSkinList[NewSelected]; m_pSelectedSkin = s_vpSkinList[NewSelected];
str_copy(Config()->m_ClPlayer7Skin, m_pSelectedSkin->m_aName); str_copy(CSkins7::ms_apSkinNameVariables[m_Dummy], m_pSelectedSkin->m_aName, protocol7::MAX_SKIN_ARRAY_SIZE);
for(int Part = 0; Part < protocol7::NUM_SKINPARTS; Part++) for(int Part = 0; Part < protocol7::NUM_SKINPARTS; Part++)
{ {
str_copy(CSkins7::ms_apSkinVariables[(int)m_Dummy][Part], m_pSelectedSkin->m_apParts[Part]->m_aName, protocol7::MAX_SKIN_ARRAY_SIZE); str_copy(CSkins7::ms_apSkinVariables[(int)m_Dummy][Part], m_pSelectedSkin->m_apParts[Part]->m_aName, protocol7::MAX_SKIN_ARRAY_SIZE);
@ -492,7 +491,7 @@ void CMenus::RenderSkinPartSelection7(CUIRect MainView)
if(NewSelected != -1 && NewSelected != s_OldSelected) if(NewSelected != -1 && NewSelected != s_OldSelected)
{ {
str_copy(CSkins7::ms_apSkinVariables[(int)m_Dummy][m_TeePartSelected], s_paList[m_TeePartSelected][NewSelected]->m_aName, protocol7::MAX_SKIN_ARRAY_SIZE); str_copy(CSkins7::ms_apSkinVariables[(int)m_Dummy][m_TeePartSelected], s_paList[m_TeePartSelected][NewSelected]->m_aName, protocol7::MAX_SKIN_ARRAY_SIZE);
Config()->m_ClPlayer7Skin[0] = '\0'; CSkins7::ms_apSkinNameVariables[m_Dummy][0] = '\0';
SetNeedSendInfo(); SetNeedSendInfo();
} }
s_OldSelected = NewSelected; s_OldSelected = NewSelected;

View file

@ -23,6 +23,7 @@ const char *const CSkins7::ms_apSkinPartNames[protocol7::NUM_SKINPARTS] = {"body
const char *const CSkins7::ms_apSkinPartNamesLocalized[protocol7::NUM_SKINPARTS] = {Localizable("Body", "skins"), Localizable("Marking", "skins"), Localizable("Decoration", "skins"), Localizable("Hands", "skins"), Localizable("Feet", "skins"), Localizable("Eyes", "skins")}; const char *const CSkins7::ms_apSkinPartNamesLocalized[protocol7::NUM_SKINPARTS] = {Localizable("Body", "skins"), Localizable("Marking", "skins"), Localizable("Decoration", "skins"), Localizable("Hands", "skins"), Localizable("Feet", "skins"), Localizable("Eyes", "skins")};
const char *const CSkins7::ms_apColorComponents[NUM_COLOR_COMPONENTS] = {"hue", "sat", "lgt", "alp"}; const char *const CSkins7::ms_apColorComponents[NUM_COLOR_COMPONENTS] = {"hue", "sat", "lgt", "alp"};
char *CSkins7::ms_apSkinNameVariables[NUM_DUMMIES] = {0};
char *CSkins7::ms_apSkinVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS] = {{0}}; char *CSkins7::ms_apSkinVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS] = {{0}};
int *CSkins7::ms_apUCCVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS] = {{0}}; int *CSkins7::ms_apUCCVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS] = {{0}};
int unsigned *CSkins7::ms_apColorVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS] = {{0}}; int unsigned *CSkins7::ms_apColorVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS] = {{0}};
@ -231,6 +232,7 @@ int CSkins7::GetInitAmount() const
void CSkins7::OnInit() void CSkins7::OnInit()
{ {
int Dummy = 0; int Dummy = 0;
ms_apSkinNameVariables[Dummy] = Config()->m_ClPlayer7Skin;
ms_apSkinVariables[Dummy][protocol7::SKINPART_BODY] = Config()->m_ClPlayer7SkinBody; ms_apSkinVariables[Dummy][protocol7::SKINPART_BODY] = Config()->m_ClPlayer7SkinBody;
ms_apSkinVariables[Dummy][protocol7::SKINPART_MARKING] = Config()->m_ClPlayer7SkinMarking; ms_apSkinVariables[Dummy][protocol7::SKINPART_MARKING] = Config()->m_ClPlayer7SkinMarking;
ms_apSkinVariables[Dummy][protocol7::SKINPART_DECORATION] = Config()->m_ClPlayer7SkinDecoration; ms_apSkinVariables[Dummy][protocol7::SKINPART_DECORATION] = Config()->m_ClPlayer7SkinDecoration;
@ -251,6 +253,7 @@ void CSkins7::OnInit()
ms_apColorVariables[Dummy][protocol7::SKINPART_EYES] = &Config()->m_ClPlayer7ColorEyes; ms_apColorVariables[Dummy][protocol7::SKINPART_EYES] = &Config()->m_ClPlayer7ColorEyes;
Dummy = 1; Dummy = 1;
ms_apSkinNameVariables[Dummy] = Config()->m_ClDummy7Skin;
ms_apSkinVariables[Dummy][protocol7::SKINPART_BODY] = Config()->m_ClDummy7SkinBody; ms_apSkinVariables[Dummy][protocol7::SKINPART_BODY] = Config()->m_ClDummy7SkinBody;
ms_apSkinVariables[Dummy][protocol7::SKINPART_MARKING] = Config()->m_ClDummy7SkinMarking; ms_apSkinVariables[Dummy][protocol7::SKINPART_MARKING] = Config()->m_ClDummy7SkinMarking;
ms_apSkinVariables[Dummy][protocol7::SKINPART_DECORATION] = Config()->m_ClDummy7SkinDecoration; ms_apSkinVariables[Dummy][protocol7::SKINPART_DECORATION] = Config()->m_ClDummy7SkinDecoration;
@ -463,17 +466,19 @@ void CSkins7::RandomizeSkin(int Dummy)
if(Part == protocol7::SKINPART_MARKING) if(Part == protocol7::SKINPART_MARKING)
Alp = rand() % 255; Alp = rand() % 255;
int ColorVariable = (Alp << 24) | (Hue << 16) | (Sat << 8) | Lgt; int ColorVariable = (Alp << 24) | (Hue << 16) | (Sat << 8) | Lgt;
*CSkins7::ms_apUCCVariables[Dummy][Part] = true; *ms_apUCCVariables[Dummy][Part] = true;
*CSkins7::ms_apColorVariables[Dummy][Part] = ColorVariable; *ms_apColorVariables[Dummy][Part] = ColorVariable;
} }
for(int Part = 0; Part < protocol7::NUM_SKINPARTS; Part++) for(int Part = 0; Part < protocol7::NUM_SKINPARTS; Part++)
{ {
const CSkins7::CSkinPart *pSkinPart = GetSkinPart(Part, rand() % NumSkinPart(Part)); const CSkinPart *pSkinPart = GetSkinPart(Part, rand() % NumSkinPart(Part));
while(pSkinPart->m_Flags & CSkins7::SKINFLAG_SPECIAL) while(pSkinPart->m_Flags & SKINFLAG_SPECIAL)
pSkinPart = GetSkinPart(Part, rand() % NumSkinPart(Part)); pSkinPart = GetSkinPart(Part, rand() % NumSkinPart(Part));
mem_copy(CSkins7::ms_apSkinVariables[Dummy][Part], pSkinPart->m_aName, protocol7::MAX_SKIN_ARRAY_SIZE); str_copy(ms_apSkinVariables[Dummy][Part], pSkinPart->m_aName, protocol7::MAX_SKIN_ARRAY_SIZE);
} }
ms_apSkinNameVariables[Dummy][0] = '\0';
} }
ColorRGBA CSkins7::GetColor(int Value, bool UseAlpha) const ColorRGBA CSkins7::GetColor(int Value, bool UseAlpha) const

View file

@ -55,6 +55,7 @@ public:
static const char *const ms_apSkinPartNamesLocalized[protocol7::NUM_SKINPARTS]; static const char *const ms_apSkinPartNamesLocalized[protocol7::NUM_SKINPARTS];
static const char *const ms_apColorComponents[NUM_COLOR_COMPONENTS]; static const char *const ms_apColorComponents[NUM_COLOR_COMPONENTS];
static char *ms_apSkinNameVariables[NUM_DUMMIES];
static char *ms_apSkinVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS]; static char *ms_apSkinVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS];
static int *ms_apUCCVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS]; // use custom color static int *ms_apUCCVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS]; // use custom color
static unsigned int *ms_apColorVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS]; static unsigned int *ms_apColorVariables[NUM_DUMMIES][protocol7::NUM_SKINPARTS];

View file

@ -1044,50 +1044,6 @@ public:
TILE_PUB_ENTITIES_OFF2, TILE_PUB_ENTITIES_OFF2,
}; };
enum
{
TILE_FNG_SPIKE_GOLD = 7,
TILE_FNG_SPIKE_NORMAL,
TILE_FNG_SPIKE_RED,
TILE_FNG_SPIKE_BLUE,
TILE_FNG_SCORE_RED,
TILE_FNG_SCORE_BLUE,
TILE_FNG_SPIKE_GREEN = 14,
TILE_FNG_SPIKE_PURPLE,
TILE_FNG_SPAWN = 192,
TILE_FNG_SPAWN_RED,
TILE_FNG_SPAWN_BLUE,
TILE_FNG_FLAG_RED,
TILE_FNG_FLAG_BLUE,
TILE_FNG_SHIELD,
TILE_FNG_HEART,
TILE_FNG_SHOTGUN,
TILE_FNG_GRENADE,
TILE_FNG_NINJA,
TILE_FNG_LASER,
TILE_FNG_SPIKE_OLD1 = 208,
TILE_FNG_SPIKE_OLD2,
TILE_FNG_SPIKE_OLD3
};
enum
{
TILE_VANILLA_SPAWN = 192,
TILE_VANILLA_SPAWN_RED,
TILE_VANILLA_SPAWN_BLUE,
TILE_VANILLA_FLAG_RED,
TILE_VANILLA_FLAG_BLUE,
TILE_VANILLA_SHIELD,
TILE_VANILLA_HEART,
TILE_VANILLA_SHOTGUN,
TILE_VANILLA_GRENADE,
TILE_VANILLA_NINJA,
TILE_VANILLA_LASER,
};
// Explanations // Explanations
enum class EExplanation enum class EExplanation
{ {

View file

@ -1,3 +1,6 @@
#include <game/mapitems_fng.h>
#include <game/mapitems_vanilla.h>
#include "editor.h" #include "editor.h"
// DDNet entity explanations by Lady Saavik // DDNet entity explanations by Lady Saavik

33
src/game/mapitems_fng.h Normal file
View file

@ -0,0 +1,33 @@
#ifndef GAME_MAPITEMS_FNG_H
#define GAME_MAPITEMS_FNG_H
enum
{
TILE_FNG_SPIKE_GOLD = 7,
TILE_FNG_SPIKE_NORMAL,
TILE_FNG_SPIKE_RED,
TILE_FNG_SPIKE_BLUE,
TILE_FNG_SCORE_RED,
TILE_FNG_SCORE_BLUE,
TILE_FNG_SPIKE_GREEN = 14,
TILE_FNG_SPIKE_PURPLE,
TILE_FNG_SPAWN = 192,
TILE_FNG_SPAWN_RED,
TILE_FNG_SPAWN_BLUE,
TILE_FNG_FLAG_RED,
TILE_FNG_FLAG_BLUE,
TILE_FNG_SHIELD,
TILE_FNG_HEART,
TILE_FNG_SHOTGUN,
TILE_FNG_GRENADE,
TILE_FNG_NINJA,
TILE_FNG_LASER,
TILE_FNG_SPIKE_OLD1 = 208,
TILE_FNG_SPIKE_OLD2,
TILE_FNG_SPIKE_OLD3
};
#endif

View file

@ -0,0 +1,19 @@
#ifndef GAME_MAPITEMS_VANILLA_H
#define GAME_MAPITEMS_VANILLA_H
enum
{
TILE_VANILLA_SPAWN = 192,
TILE_VANILLA_SPAWN_RED,
TILE_VANILLA_SPAWN_BLUE,
TILE_VANILLA_FLAG_RED,
TILE_VANILLA_FLAG_BLUE,
TILE_VANILLA_SHIELD,
TILE_VANILLA_HEART,
TILE_VANILLA_SHOTGUN,
TILE_VANILLA_GRENADE,
TILE_VANILLA_NINJA,
TILE_VANILLA_LASER,
};
#endif