Merge branch 'master' into automapper

This commit is contained in:
Aerll 2018-07-25 00:25:30 +02:00 committed by GitHub
commit d235036f7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 75 additions and 61 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

BIN
data/skins/coala_cammo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

BIN
data/skins/coala_pinky.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
data/skins/coala_saddo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

BIN
data/skins/coala_toptri.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
data/skins/santa_cammo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
data/skins/santa_coala.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
data/skins/santa_pinky.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
data/skins/santa_saddo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
data/skins/santa_toptri.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View file

@ -365,10 +365,9 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
void CMenus::RenderSettingsTee(CUIRect MainView)
{
CUIRect Button, Label, Button2, Dummy, DummyLabel, SkinList, QuickSearch, QuickSearchClearButton;
CUIRect Button, Label, Button2, Dummy, DummyLabel, SkinList, QuickSearch, QuickSearchClearButton, SkinPrefix, SkinPrefixLabel;
bool CheckSettings = false;
static int s_ClVanillaSkinsOnly = g_Config.m_ClVanillaSkinsOnly;
static float s_ClSkinPrefix = 0.0f;
static bool s_InitSkinlist = true;
MainView.HSplitTop(10.0f, 0, &MainView);
@ -406,6 +405,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
MainView.HSplitTop(20.0f, &Label, &MainView);
Label.VSplitLeft(280.0f, &Label, &Dummy);
Label.VSplitLeft(230.0f, &Label, 0);
Dummy.VSplitLeft(250.0f, &Dummy, &SkinPrefix);
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Your skin"));
UI()->DoLabelScaled(&Label, aBuf, 14.0f, -1);
@ -422,30 +422,20 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
if(DoButton_CheckBox(&g_Config.m_ClVanillaSkinsOnly, Localize("Vanilla skins only"), g_Config.m_ClVanillaSkinsOnly, &DummyLabel))
{
g_Config.m_ClVanillaSkinsOnly ^= 1;
CheckSettings = true;
}
Dummy.HSplitTop(20.0f, &DummyLabel, &Dummy);
if(DoButton_CheckBox(&g_Config.m_ClKittySkins, Localize("Kitty skins (DDCat)"), g_Config.m_ClKittySkins, &DummyLabel))
{
g_Config.m_ClKittySkins ^= 1;
}
Dummy.HSplitTop(20.0f, &DummyLabel, &Dummy);
if(DoButton_CheckBox(&g_Config.m_ClFatSkins, Localize("Fat skins (DDFat)"), g_Config.m_ClFatSkins, &DummyLabel))
if (DoButton_CheckBox(&g_Config.m_ClFatSkins, Localize("Fat skins (DDFat)"), g_Config.m_ClFatSkins, &DummyLabel))
{
g_Config.m_ClFatSkins ^= 1;
}
SkinPrefix.HSplitTop(20.0f, &SkinPrefixLabel, &SkinPrefix);
UI()->DoLabelScaled(&SkinPrefixLabel, Localize("Skin prefix (e.g. kitty, coala, santa)"), 14.0f, -1);
if(CheckSettings)
{
if(s_ClVanillaSkinsOnly == g_Config.m_ClVanillaSkinsOnly)
m_NeedRestartSkins = false;
else
m_NeedRestartSkins = true;
}
SkinPrefix.HSplitTop(20.0f, &SkinPrefixLabel, &SkinPrefix);
DoEditBox(g_Config.m_ClSkinPrefix, &SkinPrefixLabel, g_Config.m_ClSkinPrefix, sizeof(g_Config.m_ClSkinPrefix), 14.0f, &s_ClSkinPrefix);
Dummy.HSplitTop(20.0f, &DummyLabel, &Dummy);

View file

@ -11,39 +11,40 @@
#include "skins.h"
static const char* s_aaVanillaSkins[] = {"bluekitty.png", "bluestripe.png", "brownbear.png",
"cammo.png", "cammostripes.png", "coala.png", "default.png", "limekitty.png",
"pinky.png", "redbopp.png", "redstripe.png", "saddo.png", "toptri.png",
"twinbop.png", "twintri.png", "warpaint.png", "x_ninja.png"};
static const char *VANILLA_SKINS[] = {"bluekitty", "bluestripe", "brownbear",
"cammo", "cammostripes", "coala", "default", "limekitty",
"pinky", "redbopp", "redstripe", "saddo", "toptri",
"twinbop", "twintri", "warpaint", "x_ninja"};
static bool IsVanillaSkin(const char *pName)
{
for(unsigned int i = 0; i < sizeof(VANILLA_SKINS) / sizeof(VANILLA_SKINS[0]); i++)
{
if(str_comp(pName, VANILLA_SKINS[i]) == 0)
{
return true;
}
}
return false;
}
int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
{
if(g_Config.m_ClVanillaSkinsOnly)
{
bool Found = false;
for(unsigned int i = 0; i < sizeof(s_aaVanillaSkins) / sizeof(s_aaVanillaSkins[0]); i++)
{
if(str_comp(pName, s_aaVanillaSkins[i]) == 0)
{
Found = true;
break;
}
}
if(!Found)
return 0;
}
CSkins *pSelf = (CSkins *)pUser;
int l = str_length(pName);
if(l < 4 || IsDir || str_comp(pName+l-4, ".png") != 0)
return 0;
char aFilenameWithoutPng[128];
str_copy(aFilenameWithoutPng, pName, sizeof(aFilenameWithoutPng));
aFilenameWithoutPng[str_length(aFilenameWithoutPng) - 4] = 0;
// Don't add duplicate skins (one from user's config directory, other from
// client itself)
for(int i = 0; i < pSelf->Num(); i++)
{
const char* pExName = pSelf->Get(i)->m_aName;
const char *pExName = pSelf->Get(i)->m_aName;
if(str_comp_num(pExName, pName, l-4) == 0 && str_length(pExName) == l-4)
return 0;
}
@ -174,27 +175,39 @@ const CSkins::CSkin *CSkins::Get(int Index)
return &m_aSkins[max(0, Index%m_aSkins.size())];
}
int CSkins::Find(const char *pName)
int CSkins::Find(const char *pName) const
{
char aBuf[24];
if(g_Config.m_ClKittySkins)
if(g_Config.m_ClSkinPrefix[0])
{
for(unsigned int i = 0; i < sizeof(s_aaVanillaSkins) / sizeof(s_aaVanillaSkins[0]); i++)
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%s_%s", g_Config.m_ClSkinPrefix, pName);
// If we find something, use it, otherwise fall back to normal
// skins.
int Result = FindImpl(aBuf);
if(Result != -1)
{
// index 0 and 7 are bluekitty and limekitty
if(i != 0 && i != 7 && str_comp_num(pName, s_aaVanillaSkins[i], str_length(s_aaVanillaSkins[i])-4) == 0)
{
str_format(aBuf, sizeof(aBuf), "kitty_%s", pName);
pName = aBuf;
break;
}
return Result;
}
}
return FindImpl(pName);
}
int CSkins::FindImpl(const char *pName) const
{
for(int i = 0; i < m_aSkins.size(); i++)
{
if(str_comp(m_aSkins[i].m_aName, pName) == 0)
return i;
{
if(g_Config.m_ClVanillaSkinsOnly && !IsVanillaSkin(m_aSkins[i].m_aName))
{
return -1;
}
else
{
return i;
}
}
}
return -1;
}

View file

@ -26,11 +26,12 @@ public:
vec4 GetColorV4(int v);
int Num();
const CSkin *Get(int Index);
int Find(const char *pName);
int Find(const char *pName) const;
private:
sorted_array<CSkin> m_aSkins;
int FindImpl(const char *pName) const;
static int SkinScan(const char *pName, int IsDir, int DirType, void *pUser);
};
#endif

View file

@ -73,7 +73,7 @@ void CAutoMapper::Load(const char* pTileName)
CIndexRule NewIndexRule;
NewIndexRule.m_ID = ID;
NewIndexRule.m_Flag = 0;
NewIndexRule.m_RandomValue = 0;
NewIndexRule.m_RandomProbability = 1.0;
NewIndexRule.m_DefaultRule = true;
if(str_length(aOrientation1) > 0)
@ -221,7 +221,17 @@ void CAutoMapper::Load(const char* pTileName)
}
else if(!str_comp_num(pLine, "Random", 6) && pCurrentIndex)
{
sscanf(pLine, "Random %d", &pCurrentIndex->m_RandomValue);
float Value;
char Specifier = ' ';
sscanf(pLine, "Random %f%c", &Value, &Specifier);
if(Specifier == '%')
{
pCurrentIndex->m_RandomProbability = Value / 100.0;
}
else
{
pCurrentIndex->m_RandomProbability = 1.0 / Value;
}
}
else if(!str_comp_num(pLine, "NoDefaultRule", 13) && pCurrentIndex)
{
@ -354,7 +364,7 @@ void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID)
}
if(RespectRules &&
(pRun->m_aIndexRules[i].m_RandomValue <= 1 || (int)((float)rand() / ((float)RAND_MAX + 1) * pRun->m_aIndexRules[i].m_RandomValue) == 1))
(pRun->m_aIndexRules[i].m_RandomProbability >= 1.0 || (float)rand() / ((float)RAND_MAX + 1) < pRun->m_aIndexRules[i].m_RandomProbability))
{
pTile->m_Index = pRun->m_aIndexRules[i].m_ID;
pTile->m_Flags = pRun->m_aIndexRules[i].m_Flag == -1 ? 0 : pRun->m_aIndexRules[i].m_Flag;
@ -423,7 +433,7 @@ void CAutoMapper::Proceed(CLayerTiles *pLayer, int ConfigID)
}
if(RespectRules &&
(pRun->m_aIndexRules[i].m_RandomValue <= 1 || (int)((float)rand() / ((float)RAND_MAX + 1) * pRun->m_aIndexRules[i].m_RandomValue) == 1))
(pRun->m_aIndexRules[i].m_RandomProbability >= 1.0 || (float)rand() / ((float)RAND_MAX + 1) < pRun->m_aIndexRules[i].m_RandomProbability))
{
pTile->m_Index = pRun->m_aIndexRules[i].m_ID;
pTile->m_Flags = pRun->m_aIndexRules[i].m_Flag == -1 ? 0 : pRun->m_aIndexRules[i].m_Flag;

View file

@ -31,7 +31,7 @@ class CAutoMapper
int m_ID;
array<CPosRule> m_aRules;
int m_Flag;
int m_RandomValue;
float m_RandomProbability;
bool m_DefaultRule;
};

View file

@ -80,7 +80,7 @@ MACRO_CONFIG_INT(ClPlayerUseCustomColor, player_use_custom_color, 0, 0, 1, CFGFL
MACRO_CONFIG_INT(ClPlayerColorBody, player_color_body, 65408, 0, 0xFFFFFF, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player body color")
MACRO_CONFIG_INT(ClPlayerColorFeet, player_color_feet, 65408, 0, 0xFFFFFF, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player feet color")
MACRO_CONFIG_STR(ClPlayerSkin, player_skin, 24, "default", CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player skin")
MACRO_CONFIG_INT(ClKittySkins, cl_kitty_skins, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Enable kitty skins instead of vanilla skins")
MACRO_CONFIG_STR(ClSkinPrefix, cl_skin_prefix, 100, "", CFGFLAG_CLIENT|CFGFLAG_SAVE, "Replace the skins by skins with this prefix (e.g. kitty, coala, santa)")
MACRO_CONFIG_INT(ClFatSkins, cl_fat_skins, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Enable fat skins")
MACRO_CONFIG_INT(UiPage, ui_page, 9, 0, 11, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Interface page")

View file

@ -2,9 +2,9 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#ifndef GAME_VERSION_H
#define GAME_VERSION_H
#define GAME_VERSION "0.6.4, 11.2.1"
#define GAME_VERSION "0.6.4, 11.3"
#define GAME_NETVERSION "0.6 626fce9a778df4d4"
#define GAME_RELEASE_VERSION "11.2.1"
#define CLIENT_VERSIONNR 11021
#define GAME_RELEASE_VERSION "11.3"
#define CLIENT_VERSIONNR 11030
extern const char *GIT_SHORTREV_HASH;
#endif