parent
4942cabab5
commit
e009d322cc
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2019 Wildfire Games.
|
||||
/* Copyright (C) 2020 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -76,7 +76,7 @@ void CCinemaManager::DrawPaths() const
|
||||
if (!cmpCinemaManager)
|
||||
return;
|
||||
|
||||
for (const std::pair<CStrW, CCinemaPath>& p : cmpCinemaManager->GetPaths())
|
||||
for (const std::pair<const CStrW, CCinemaPath>& p : cmpCinemaManager->GetPaths())
|
||||
{
|
||||
DrawSpline(p.second, CColor(0.2f, 0.2f, 1.f, 0.9f), 128, true);
|
||||
DrawNodes(p.second, CColor(0.1f, 1.f, 0.f, 1.f));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2020 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -46,7 +46,7 @@ CObjectEntry::CObjectEntry(CObjectBase* base, CSimulation2& simulation) :
|
||||
|
||||
CObjectEntry::~CObjectEntry()
|
||||
{
|
||||
for (const std::pair<CStr, CSkeletonAnim*>& anim : m_Animations)
|
||||
for (const std::pair<const CStr, CSkeletonAnim*>& anim : m_Animations)
|
||||
delete anim.second;
|
||||
|
||||
delete m_Model;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
/* Copyright (C) 2020 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -170,11 +170,11 @@ void CObjectManager::DeleteObject(CObjectEntry* entry)
|
||||
|
||||
void CObjectManager::UnloadObjects()
|
||||
{
|
||||
for (const std::pair<ObjectKey, CObjectEntry*>& p : m_Objects)
|
||||
for (const std::pair<const ObjectKey, CObjectEntry*>& p : m_Objects)
|
||||
delete p.second;
|
||||
m_Objects.clear();
|
||||
|
||||
for (const std::pair<CStrW, CObjectBase*>& p : m_ObjectBases)
|
||||
for (const std::pair<const CStrW, CObjectBase*>& p : m_ObjectBases)
|
||||
delete p.second;
|
||||
m_ObjectBases.clear();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2020 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -63,7 +63,7 @@ void CTerrainTextureManager::UnloadTerrainTextures()
|
||||
delete te;
|
||||
m_TextureEntries.clear();
|
||||
|
||||
for (const std::pair<CStr, CTerrainGroup*>& tg : m_TerrainGroups)
|
||||
for (const std::pair<const CStr, CTerrainGroup*>& tg : m_TerrainGroups)
|
||||
delete tg.second;
|
||||
m_TerrainGroups.clear();
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2016 Wildfire Games.
|
||||
/* Copyright (C) 2020 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -90,7 +90,7 @@ void CUnit::SetEntitySelection(const CStr& key, const CStr& selection)
|
||||
|
||||
void CUnit::SetEntitySelection(const std::map<CStr, CStr>& selections)
|
||||
{
|
||||
for (const std::pair<CStr, CStr>& s : selections)
|
||||
for (const std::pair<const CStr, CStr>& s : selections)
|
||||
m_EntitySelections[s.first] = s.second.LowerCase();
|
||||
|
||||
ReloadObject();
|
||||
@ -105,7 +105,7 @@ void CUnit::SetActorSelections(const std::set<CStr>& selections)
|
||||
void CUnit::ReloadObject()
|
||||
{
|
||||
std::set<CStr> entitySelections;
|
||||
for (const std::pair<CStr, CStr>& selection : m_EntitySelections)
|
||||
for (const std::pair<const CStr, CStr>& selection : m_EntitySelections)
|
||||
entitySelections.insert(selection.second);
|
||||
std::vector<std::set<CStr> > selections;
|
||||
selections.push_back(entitySelections);
|
||||
|
@ -79,10 +79,10 @@ CGUI::CGUI(const shared_ptr<ScriptContext>& context)
|
||||
|
||||
CGUI::~CGUI()
|
||||
{
|
||||
for (const std::pair<CStr, IGUIObject*>& p : m_pAllObjects)
|
||||
for (const std::pair<const CStr, IGUIObject*>& p : m_pAllObjects)
|
||||
delete p.second;
|
||||
|
||||
for (const std::pair<CStr, const CGUISprite*>& p : m_Sprites)
|
||||
for (const std::pair<const CStr, const CGUISprite*>& p : m_Sprites)
|
||||
delete p.second;
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ IGUIObject::IGUIObject(CGUI& pGUI)
|
||||
|
||||
IGUIObject::~IGUIObject()
|
||||
{
|
||||
for (const std::pair<CStr, IGUISetting*>& p : m_Settings)
|
||||
for (const std::pair<const CStr, IGUISetting*>& p : m_Settings)
|
||||
delete p.second;
|
||||
|
||||
if (!m_ScriptHandlers.empty())
|
||||
@ -282,7 +282,7 @@ bool IGUIObject::ApplyStyle(const CStr& StyleName)
|
||||
// Other styles are reported if they specify a Setting that does not exist,
|
||||
// so that the XML author is informed and can correct the style.
|
||||
|
||||
for (const std::pair<CStr, CStrW>& p : m_pGUI.GetStyle(StyleName).m_SettingsDefaults)
|
||||
for (const std::pair<const CStr, CStrW>& p : m_pGUI.GetStyle(StyleName).m_SettingsDefaults)
|
||||
{
|
||||
if (SettingExists(p.first))
|
||||
SetSettingFromString(p.first, p.second, true);
|
||||
|
@ -304,11 +304,11 @@ InReaction CDropDown::ManuallyHandleKeys(const SDL_Event_* ev)
|
||||
break;
|
||||
|
||||
default:
|
||||
// If we have inputed a character try to get the closest element to it.
|
||||
// If we have typed a character try to get the closest element to it.
|
||||
// TODO: not too nice and doesn't deal with dashes.
|
||||
if (m_Open && ((szChar >= SDLK_a && szChar <= SDLK_z) || szChar == SDLK_SPACE
|
||||
|| (szChar >= SDLK_0 && szChar <= SDLK_9)
|
||||
|| (szChar >= SDLK_KP_0 && szChar <= SDLK_KP_9)))
|
||||
|| (szChar >= SDLK_KP_1 && szChar <= SDLK_KP_0)))
|
||||
{
|
||||
// arbitrary 1 second limit to add to string or start fresh.
|
||||
// maximal amount of characters is 100, which imo is far more than enough.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2019 Wildfire Games.
|
||||
/* Copyright (c) 2020 Wildfire Games.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -80,6 +80,9 @@ inline void ignore_result(const T&) {}
|
||||
#if GCC_VERSION
|
||||
# define NOTHROW_DECLARE __attribute__((nothrow))
|
||||
# define NOTHROW_DEFINE // not supported for definitions
|
||||
#elif CLANG_VERSION
|
||||
# define NOTHROW_DECLARE __attribute__((nothrow))
|
||||
# define NOTHROW_DEFINE // not supported for definitions
|
||||
#elif MSC_VERSION
|
||||
// Kevin Frei, 2006-03-23: "I work on the Visual C++ compiler team,
|
||||
// and agree completely with Paul Parks: don't use throw(), because
|
||||
|
@ -288,7 +288,7 @@ private:
|
||||
// annoying and inefficient. we allow either type of separators,
|
||||
// appending whichever was first encountered. when modifying the path,
|
||||
// we ensure the same separator is used.
|
||||
wchar_t separator;
|
||||
wchar_t separator = L'/';
|
||||
};
|
||||
|
||||
static inline std::wostream& operator<<(std::wostream& s, const Path& path)
|
||||
|
@ -545,7 +545,7 @@ void XmppClient::GUIGetPlayerList(const ScriptInterface& scriptInterface, JS::Mu
|
||||
ScriptInterface::CreateArray(rq, ret);
|
||||
int j = 0;
|
||||
|
||||
for (const std::pair<glooxwrapper::string, SPlayer>& p : m_PlayerMap)
|
||||
for (const std::pair<const glooxwrapper::string, SPlayer>& p : m_PlayerMap)
|
||||
{
|
||||
JS::RootedValue player(rq.cx);
|
||||
|
||||
|
@ -277,7 +277,7 @@ void CNetClient::PostPlayerAssignmentsToScript()
|
||||
JS::RootedValue newAssignments(rq.cx);
|
||||
ScriptInterface::CreateObject(rq, &newAssignments);
|
||||
|
||||
for (const std::pair<CStr, PlayerAssignment>& p : m_PlayerAssignments)
|
||||
for (const std::pair<const CStr, PlayerAssignment>& p : m_PlayerAssignments)
|
||||
{
|
||||
JS::RootedValue assignment(rq.cx);
|
||||
|
||||
|
@ -738,7 +738,7 @@ void CNetServerWorker::AddPlayer(const CStr& guid, const CStrW& name)
|
||||
{
|
||||
// Find all player IDs in active use; we mustn't give them to a second player (excluding the unassigned ID: -1)
|
||||
std::set<i32> usedIDs;
|
||||
for (const std::pair<CStr, PlayerAssignment>& p : m_PlayerAssignments)
|
||||
for (const std::pair<const CStr, PlayerAssignment>& p : m_PlayerAssignments)
|
||||
if (p.second.m_Enabled && p.second.m_PlayerID != -1)
|
||||
usedIDs.insert(p.second.m_PlayerID);
|
||||
|
||||
|
@ -72,7 +72,7 @@ void CNetServerTurnManager::NotifyFinishedClientCommands(CNetServerSession& sess
|
||||
void CNetServerTurnManager::CheckClientsReady()
|
||||
{
|
||||
// See if all clients (including self) are ready for a new turn
|
||||
for (const std::pair<int, u32>& clientReady : m_ClientsReady)
|
||||
for (const std::pair<const int, u32>& clientReady : m_ClientsReady)
|
||||
{
|
||||
NETSERVERTURN_LOG(" %d: %d <=? %d\n", clientReady.first, clientReady.second, m_ReadyTurn);
|
||||
if (clientReady.second <= m_ReadyTurn)
|
||||
@ -122,7 +122,7 @@ void CNetServerTurnManager::NotifyFinishedClientUpdate(CNetServerSession& sessio
|
||||
|
||||
// Find the newest turn which we know all clients have simulated
|
||||
u32 newest = std::numeric_limits<u32>::max();
|
||||
for (const std::pair<int, u32>& clientSimulated : m_ClientsSimulated)
|
||||
for (const std::pair<const int, u32>& clientSimulated : m_ClientsSimulated)
|
||||
if (clientSimulated.second < newest)
|
||||
newest = clientSimulated.second;
|
||||
|
||||
@ -137,7 +137,7 @@ void CNetServerTurnManager::NotifyFinishedClientUpdate(CNetServerSession& sessio
|
||||
|
||||
// Find all players that are OOS on that turn
|
||||
std::vector<CStrW> OOSPlayerNames;
|
||||
for (const std::pair<int, std::string>& hashPair : clientStateHash.second)
|
||||
for (const std::pair<const int, std::string>& hashPair : clientStateHash.second)
|
||||
{
|
||||
NETSERVERTURN_LOG("sync check %d: %d = %hs\n", it->first, cit->first, Hexify(cit->second).c_str());
|
||||
if (hashPair.second != expected)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2019 Wildfire Games.
|
||||
/* Copyright (C) 2020 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -188,11 +188,11 @@ std::map<CStr, CConfigValueSet> CConfigDB::GetValuesWithPrefix(EConfigNamespace
|
||||
// Loop upwards so that values in later namespaces can override
|
||||
// values in earlier namespaces
|
||||
for (int search_ns = 0; search_ns <= ns; ++search_ns)
|
||||
for (const std::pair<CStr, CConfigValueSet>& p : m_Map[search_ns])
|
||||
for (const std::pair<const CStr, CConfigValueSet>& p : m_Map[search_ns])
|
||||
if (boost::algorithm::starts_with(p.first, prefix))
|
||||
ret[p.first] = p.second;
|
||||
|
||||
for (const std::pair<CStr, CConfigValueSet>& p : m_Map[CFG_COMMAND])
|
||||
for (const std::pair<const CStr, CConfigValueSet>& p : m_Map[CFG_COMMAND])
|
||||
if (boost::algorithm::starts_with(p.first, prefix))
|
||||
ret[p.first] = p.second;
|
||||
|
||||
@ -431,7 +431,8 @@ bool CConfigDB::WriteFile(EConfigNamespace ns, const VfsPath& path) const
|
||||
shared_ptr<u8> buf;
|
||||
AllocateAligned(buf, 1*MiB, maxSectorSize);
|
||||
char* pos = (char*)buf.get();
|
||||
for (const std::pair<CStr, CConfigValueSet>& p : m_Map[ns])
|
||||
|
||||
for (const std::pair<const CStr, CConfigValueSet>& p : m_Map[ns])
|
||||
{
|
||||
size_t i;
|
||||
pos += sprintf(pos, "%s = ", p.first.c_str());
|
||||
|
@ -40,7 +40,7 @@ static_assert(SDL_USEREVENT_ == SDL_USEREVENT, "SDL_USEREVENT_ is not the same t
|
||||
// all key combinations that trigger it.
|
||||
static void LoadConfigBindings()
|
||||
{
|
||||
for (const std::pair<CStr, CConfigValueSet>& configPair : g_ConfigDB.GetValuesWithPrefix(CFG_COMMAND, "hotkey."))
|
||||
for (const std::pair<const CStr, CConfigValueSet>& configPair : g_ConfigDB.GetValuesWithPrefix(CFG_COMMAND, "hotkey."))
|
||||
{
|
||||
std::string hotkeyName = configPair.first.substr(7); // strip the "hotkey." prefix
|
||||
for (const CStr& hotkey : configPair.second)
|
||||
@ -93,7 +93,7 @@ void LoadHotkeys()
|
||||
// Set up the state of the hotkeys given no key is down.
|
||||
// i.e. find those hotkeys triggered by all negations.
|
||||
|
||||
for (const std::pair<int, KeyMapping>& p : g_HotkeyMap)
|
||||
for (const std::pair<const int, KeyMapping>& p : g_HotkeyMap)
|
||||
for (const SHotkeyMapping& hotkey : p.second)
|
||||
{
|
||||
if (!hotkey.negated)
|
||||
|
@ -402,10 +402,11 @@ void CProfileViewer::AddRootTable(AbstractProfileTable* table, bool front)
|
||||
|
||||
namespace
|
||||
{
|
||||
struct WriteTable
|
||||
class WriteTable
|
||||
{
|
||||
std::ofstream& f;
|
||||
WriteTable(std::ofstream& f) : f(f) {}
|
||||
public:
|
||||
WriteTable(std::ofstream& outputStream) : m_OutputStream(outputStream) {}
|
||||
WriteTable(const WriteTable& writeTable) = default;
|
||||
|
||||
void operator() (AbstractProfileTable* table)
|
||||
{
|
||||
@ -435,7 +436,7 @@ namespace
|
||||
|
||||
// Output data as a formatted table:
|
||||
|
||||
f << "\n\n" << table->GetTitle() << "\n";
|
||||
m_OutputStream << "\n\n" << table->GetTitle() << "\n";
|
||||
|
||||
if (cols == 0) // avoid divide-by-zero
|
||||
return;
|
||||
@ -443,14 +444,14 @@ namespace
|
||||
for (size_t r = 0; r < data.size()/cols; ++r)
|
||||
{
|
||||
for (size_t c = 0; c < cols; ++c)
|
||||
f << (c ? " | " : "\n")
|
||||
m_OutputStream << (c ? " | " : "\n")
|
||||
<< data[r*cols + c].Pad(PS_TRIM_RIGHT, columnWidths[c]);
|
||||
|
||||
// Add dividers under some rows. (Currently only the first, since
|
||||
// that contains the column headers.)
|
||||
if (r == 0)
|
||||
for (size_t c = 0; c < cols; ++c)
|
||||
f << (c ? "-|-" : "\n")
|
||||
m_OutputStream << (c ? "-|-" : "\n")
|
||||
<< CStr::Repeat("-", columnWidths[c]);
|
||||
}
|
||||
}
|
||||
@ -480,6 +481,7 @@ namespace
|
||||
}
|
||||
|
||||
private:
|
||||
std::ofstream& m_OutputStream;
|
||||
const WriteTable& operator=(const WriteTable&);
|
||||
};
|
||||
|
||||
|
@ -599,7 +599,7 @@ void rewriteBuffer(u8* buffer, u32& bufferSize)
|
||||
curTime += 0.000001;
|
||||
}
|
||||
// sub-events, aggregated
|
||||
for (const std::pair<std::string, infoPerType>& type : timeByType)
|
||||
for (const std::pair<const std::string, infoPerType>& type : timeByType)
|
||||
{
|
||||
CProfiler2::SItem_dt_id item = { (float)curTime, std::get<0>(type.second) };
|
||||
buffer[writePos] = (u8)CProfiler2::ITEM_ENTER;
|
||||
|
@ -195,7 +195,7 @@ public:
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
|
||||
iterator(size_t size, const char* ptr, const char* endptr = NULL)
|
||||
: m_Size(size), m_CurItemID(endptr ? size : 0), m_CurPointer(endptr ? endptr : ptr), m_Pointer(ptr) {}
|
||||
: m_Size(size), m_CurItemID(endptr ? size : 0), m_CurPointer(endptr ? endptr : ptr) {}
|
||||
XMBElement operator*() const { return XMBElement(m_CurPointer); }
|
||||
XMBElement operator->() const { return **this; }
|
||||
iterator& operator++();
|
||||
@ -211,7 +211,6 @@ public:
|
||||
size_t m_Size;
|
||||
size_t m_CurItemID;
|
||||
const char* m_CurPointer;
|
||||
const char* m_Pointer;
|
||||
};
|
||||
iterator begin() { return iterator(m_Size, m_Pointer); }
|
||||
iterator end() { return iterator(m_Size, m_Pointer, m_EndPointer); }
|
||||
@ -264,7 +263,7 @@ public:
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
|
||||
iterator(size_t size, const char* ptr, const char* endptr = NULL)
|
||||
: m_Size(size), m_CurItemID(endptr ? size : 0), m_CurPointer(endptr ? endptr : ptr), m_Pointer(ptr) {}
|
||||
: m_Size(size), m_CurItemID(endptr ? size : 0), m_CurPointer(endptr ? endptr : ptr) {}
|
||||
XMBAttribute operator*() const;
|
||||
XMBAttribute operator->() const { return **this; }
|
||||
iterator& operator++();
|
||||
@ -280,7 +279,6 @@ public:
|
||||
size_t m_Size;
|
||||
size_t m_CurItemID;
|
||||
const char* m_CurPointer;
|
||||
const char* m_Pointer;
|
||||
};
|
||||
iterator begin() const { return iterator(m_Size, m_Pointer); }
|
||||
iterator end() const { return iterator(m_Size, m_Pointer, m_EndPointer); }
|
||||
|
@ -75,7 +75,7 @@ JS::Value GetHotkeyMap(ScriptInterface::CmptPrivate* pCmptPrivate)
|
||||
JS::RootedValue hotkeyMap(rq.cx);
|
||||
|
||||
std::unordered_map<std::string, std::vector<std::vector<std::string>>> hotkeys;
|
||||
for (const std::pair<SDL_Scancode_, KeyMapping>& key : g_HotkeyMap)
|
||||
for (const std::pair<const SDL_Scancode_, KeyMapping>& key : g_HotkeyMap)
|
||||
for (const SHotkeyMapping& mapping : key.second)
|
||||
{
|
||||
std::vector<std::string> keymap;
|
||||
|
@ -99,7 +99,7 @@ JS::Value JSI_ModIo::GetMods(ScriptInterface::CmptPrivate* pCmptPrivate)
|
||||
JS::RootedValue m(rq.cx);
|
||||
ScriptInterface::CreateObject(rq, &m);
|
||||
|
||||
for (const std::pair<std::string, std::string>& prop : mod.properties)
|
||||
for (const std::pair<const std::string, std::string>& prop : mod.properties)
|
||||
scriptInterface->SetProperty(m, prop.first.c_str(), prop.second, true);
|
||||
|
||||
scriptInterface->SetProperty(m, "dependencies", mod.dependencies, true);
|
||||
|
Loading…
Reference in New Issue
Block a user