mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-15 11:46:56 +02:00
Make some non-const static variables const or constexpr
This commit is contained in:
parent
6db405167d
commit
6e399eb21a
@ -191,7 +191,7 @@ void CGuiHandler::drawFPSCounter()
|
|||||||
int y = screen->h-20;
|
int y = screen->h-20;
|
||||||
int width3digitFPSIncludingPadding = 48;
|
int width3digitFPSIncludingPadding = 48;
|
||||||
int heightFPSTextIncludingPadding = 11;
|
int heightFPSTextIncludingPadding = 11;
|
||||||
static SDL_Rect overlay = { x, y, width3digitFPSIncludingPadding, heightFPSTextIncludingPadding};
|
SDL_Rect overlay = { x, y, width3digitFPSIncludingPadding, heightFPSTextIncludingPadding};
|
||||||
uint32_t black = SDL_MapRGB(screen->format, 10, 10, 10);
|
uint32_t black = SDL_MapRGB(screen->format, 10, 10, 10);
|
||||||
SDL_FillRect(screen, &overlay, black);
|
SDL_FillRect(screen, &overlay, black);
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ void CBonusSelection::createBonusesIcons()
|
|||||||
const std::vector<CampaignBonus> & bonDescs = scenario.travelOptions.bonusesToChoose;
|
const std::vector<CampaignBonus> & bonDescs = scenario.travelOptions.bonusesToChoose;
|
||||||
groupBonuses = std::make_shared<CToggleGroup>(std::bind(&IServerAPI::setCampaignBonus, CSH, _1));
|
groupBonuses = std::make_shared<CToggleGroup>(std::bind(&IServerAPI::setCampaignBonus, CSH, _1));
|
||||||
|
|
||||||
static const char * bonusPics[] =
|
constexpr std::array bonusPics =
|
||||||
{
|
{
|
||||||
"SPELLBON.DEF", // Spell
|
"SPELLBON.DEF", // Spell
|
||||||
"TWCRPORT.DEF", // Monster
|
"TWCRPORT.DEF", // Monster
|
||||||
|
@ -154,7 +154,7 @@ InfoCard::InfoCard()
|
|||||||
|
|
||||||
iconDifficulty = std::make_shared<CToggleGroup>(0);
|
iconDifficulty = std::make_shared<CToggleGroup>(0);
|
||||||
{
|
{
|
||||||
static const char * difButns[] = {"GSPBUT3.DEF", "GSPBUT4.DEF", "GSPBUT5.DEF", "GSPBUT6.DEF", "GSPBUT7.DEF"};
|
constexpr std::array difButns = {"GSPBUT3.DEF", "GSPBUT4.DEF", "GSPBUT5.DEF", "GSPBUT6.DEF", "GSPBUT7.DEF"};
|
||||||
|
|
||||||
for(int i = 0; i < 5; i++)
|
for(int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
|
@ -278,9 +278,9 @@ CMainMenuConfig::CMainMenuConfig()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CMainMenuConfig & CMainMenuConfig::get()
|
const CMainMenuConfig & CMainMenuConfig::get()
|
||||||
{
|
{
|
||||||
static CMainMenuConfig config;
|
static const CMainMenuConfig config;
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ public:
|
|||||||
class CMainMenuConfig
|
class CMainMenuConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static CMainMenuConfig & get();
|
static const CMainMenuConfig & get();
|
||||||
const JsonNode & getConfig() const;
|
const JsonNode & getConfig() const;
|
||||||
const JsonNode & getCampaigns() const;
|
const JsonNode & getCampaigns() const;
|
||||||
|
|
||||||
|
@ -157,11 +157,11 @@ SDL_Surface * BitmapHandler::loadBitmapFromDir(const ImagePath & path)
|
|||||||
ret->format->palette->colors[0].g == 0 &&
|
ret->format->palette->colors[0].g == 0 &&
|
||||||
ret->format->palette->colors[0].b == 255 )
|
ret->format->palette->colors[0].b == 255 )
|
||||||
{
|
{
|
||||||
static SDL_Color shadow[3] =
|
constexpr std::array shadow =
|
||||||
{
|
{
|
||||||
{ 0, 0, 0, 0},// 100% - transparency
|
SDL_Color{ 0, 0, 0, 0},// 100% - transparency
|
||||||
{ 0, 0, 0, 32},// 75% - shadow border,
|
SDL_Color{ 0, 0, 0, 32},// 75% - shadow border,
|
||||||
{ 0, 0, 0, 128},// 50% - shadow body
|
SDL_Color{ 0, 0, 0, 128},// 50% - shadow body
|
||||||
};
|
};
|
||||||
|
|
||||||
CSDL_Ext::setColorKey(ret, ret->format->palette->colors[0]);
|
CSDL_Ext::setColorKey(ret, ret->format->palette->colors[0]);
|
||||||
|
@ -1427,11 +1427,11 @@ CHallInterface::CBuildingBox::CBuildingBox(int x, int y, const CGTownInstance *
|
|||||||
|
|
||||||
state = LOCPLINT->cb->canBuildStructure(town, building->bid);
|
state = LOCPLINT->cb->canBuildStructure(town, building->bid);
|
||||||
|
|
||||||
static int panelIndex[12] =
|
constexpr std::array panelIndex =
|
||||||
{
|
{
|
||||||
3, 3, 3, 0, 0, 2, 2, 1, 2, 2, 3, 3
|
3, 3, 3, 0, 0, 2, 2, 1, 2, 2, 3, 3
|
||||||
};
|
};
|
||||||
static int iconIndex[12] =
|
constexpr std::array iconIndex =
|
||||||
{
|
{
|
||||||
-1, -1, -1, 0, 0, 1, 2, -1, 1, 1, -1, -1
|
-1, -1, -1, 0, 0, 1, 2, -1, 1, 1, -1, -1
|
||||||
};
|
};
|
||||||
|
@ -76,7 +76,7 @@ void CPuzzleWindow::showAll(Canvas & to)
|
|||||||
|
|
||||||
void CPuzzleWindow::show(Canvas & to)
|
void CPuzzleWindow::show(Canvas & to)
|
||||||
{
|
{
|
||||||
static int animSpeed = 2;
|
constexpr int animSpeed = 2;
|
||||||
|
|
||||||
if(currentAlpha < animSpeed)
|
if(currentAlpha < animSpeed)
|
||||||
{
|
{
|
||||||
|
@ -1558,7 +1558,7 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
|
|||||||
|
|
||||||
//data for information table:
|
//data for information table:
|
||||||
// fields[row][column] = list of id's of players for this box
|
// fields[row][column] = list of id's of players for this box
|
||||||
static std::vector< std::vector< PlayerColor > > SThievesGuildInfo::* fields[] =
|
constexpr std::vector< std::vector< PlayerColor > > SThievesGuildInfo::* fields[] =
|
||||||
{ &SThievesGuildInfo::numOfTowns, &SThievesGuildInfo::numOfHeroes, &SThievesGuildInfo::gold,
|
{ &SThievesGuildInfo::numOfTowns, &SThievesGuildInfo::numOfHeroes, &SThievesGuildInfo::gold,
|
||||||
&SThievesGuildInfo::woodOre, &SThievesGuildInfo::mercSulfCrystGems, &SThievesGuildInfo::obelisks,
|
&SThievesGuildInfo::woodOre, &SThievesGuildInfo::mercSulfCrystGems, &SThievesGuildInfo::obelisks,
|
||||||
&SThievesGuildInfo::artifacts, &SThievesGuildInfo::army, &SThievesGuildInfo::income };
|
&SThievesGuildInfo::artifacts, &SThievesGuildInfo::army, &SThievesGuildInfo::income };
|
||||||
|
@ -54,9 +54,7 @@ CDownloadManager::FileEntry & CDownloadManager::getEntry(QNetworkReply * reply)
|
|||||||
if(entry.reply == reply)
|
if(entry.reply == reply)
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
assert(0);
|
throw std::runtime_error("Failed to find download entry");
|
||||||
static FileEntry errorValue;
|
|
||||||
return errorValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDownloadManager::downloadFinished(QNetworkReply * reply)
|
void CDownloadManager::downloadFinished(QNetworkReply * reply)
|
||||||
|
@ -38,7 +38,7 @@ QString CModListModel::modIndexToName(const QModelIndex & index) const
|
|||||||
|
|
||||||
QString CModListModel::modTypeName(QString modTypeID) const
|
QString CModListModel::modTypeName(QString modTypeID) const
|
||||||
{
|
{
|
||||||
static QMap<QString, QString> modTypes = {
|
static const QMap<QString, QString> modTypes = {
|
||||||
{"Translation", tr("Translation")},
|
{"Translation", tr("Translation")},
|
||||||
{"Town", tr("Town") },
|
{"Town", tr("Town") },
|
||||||
{"Test", tr("Test") },
|
{"Test", tr("Test") },
|
||||||
|
@ -502,7 +502,7 @@ CGeneralTextHandler::CGeneralTextHandler():
|
|||||||
readToVector("core.mineevnt", "DATA/MINEEVNT.TXT" );
|
readToVector("core.mineevnt", "DATA/MINEEVNT.TXT" );
|
||||||
readToVector("core.xtrainfo", "DATA/XTRAINFO.TXT" );
|
readToVector("core.xtrainfo", "DATA/XTRAINFO.TXT" );
|
||||||
|
|
||||||
static const char * QE_MOD_COMMANDS = "DATA/QECOMMANDS.TXT";
|
static const std::string QE_MOD_COMMANDS = "DATA/QECOMMANDS.TXT";
|
||||||
if (CResourceHandler::get()->existsResource(TextPath::builtin(QE_MOD_COMMANDS)))
|
if (CResourceHandler::get()->existsResource(TextPath::builtin(QE_MOD_COMMANDS)))
|
||||||
readToVector("vcmi.quickExchange", QE_MOD_COMMANDS);
|
readToVector("vcmi.quickExchange", QE_MOD_COMMANDS);
|
||||||
|
|
||||||
|
@ -1259,7 +1259,7 @@ namespace Validation
|
|||||||
|
|
||||||
const TFormatMap & getKnownFormats()
|
const TFormatMap & getKnownFormats()
|
||||||
{
|
{
|
||||||
static TFormatMap knownFormats = createFormatMap();
|
static const TFormatMap knownFormats = createFormatMap();
|
||||||
return knownFormats;
|
return knownFormats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, TerrainId terrain, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//native terrain bonuses
|
//native terrain bonuses
|
||||||
static auto nativeTerrain = std::make_shared<CreatureTerrainLimiter>();
|
auto nativeTerrain = std::make_shared<CreatureTerrainLimiter>();
|
||||||
|
|
||||||
curB->addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::STACKS_SPEED, BonusSource::TERRAIN_NATIVE, 1, BonusSourceID())->addLimiter(nativeTerrain));
|
curB->addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::STACKS_SPEED, BonusSource::TERRAIN_NATIVE, 1, BonusSourceID())->addLimiter(nativeTerrain));
|
||||||
curB->addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::PRIMARY_SKILL, BonusSource::TERRAIN_NATIVE, 1, BonusSourceID(), BonusSubtypeID(PrimarySkill::ATTACK))->addLimiter(nativeTerrain));
|
curB->addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::PRIMARY_SKILL, BonusSource::TERRAIN_NATIVE, 1, BonusSourceID(), BonusSubtypeID(PrimarySkill::ATTACK))->addLimiter(nativeTerrain));
|
||||||
|
@ -161,7 +161,7 @@ DefFile::DefFile(std::string Name):
|
|||||||
#endif // 0
|
#endif // 0
|
||||||
|
|
||||||
//First 8 colors in def palette used for transparency
|
//First 8 colors in def palette used for transparency
|
||||||
static QRgb H3Palette[8] =
|
constexpr std::array H3Palette =
|
||||||
{
|
{
|
||||||
qRgba(0, 0, 0, 0), // 100% - transparency
|
qRgba(0, 0, 0, 0), // 100% - transparency
|
||||||
qRgba(0, 0, 0, 32), // 75% - shadow border,
|
qRgba(0, 0, 0, 32), // 75% - shadow border,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user