Fix most of the new vs2017 induced warnings.

Refs: https://code.wildfiregames.com/D3096
https://code.wildfiregames.com/D3103 #5862
Reviewed by: @wraitii
Comments by: @Angen
Differential Revision: https://code.wildfiregames.com/D3126
This was SVN commit r24268.
This commit is contained in:
Stan 2020-11-26 22:28:50 +00:00
parent d7d0f142d8
commit 9ae084519f
42 changed files with 313 additions and 307 deletions

View File

@ -55,6 +55,10 @@
#include <boost/algorithm/string/predicate.hpp>
#if defined(_MSC_VER) && _MSC_VER > 1900
#pragma warning(disable: 4456) // Declaration hides previous local declaration.
#pragma warning(disable: 4458) // Declaration hides class member.
#endif
CMapReader::CMapReader()
: xml_reader(0), m_PatchesPerSide(0), m_MapGen(0)
@ -421,7 +425,9 @@ private:
int el_garrison;
int el_turrets;
int el_actor;
int at_x, at_y, at_z;
int at_x;
int at_y;
int at_z;
int at_group, at_group2;
int at_angle;
int at_uid;
@ -656,20 +662,20 @@ void CXMLReader::ReadEnvironment(XMBElement parent)
{
XERO_ITER_EL(element, fog)
{
int element_name = fog.GetNodeName();
if (element_name == el_fogcolor)
int fog_element_name = fog.GetNodeName();
if (fog_element_name == el_fogcolor)
{
XMBAttributeList attrs = fog.GetAttributes();
XMBAttributeList fogAttributes = fog.GetAttributes();
m_MapReader.m_LightEnv.m_FogColor = RGBColor(
attrs.GetNamedItem(at_r).ToFloat(),
attrs.GetNamedItem(at_g).ToFloat(),
attrs.GetNamedItem(at_b).ToFloat());
fogAttributes.GetNamedItem(at_r).ToFloat(),
fogAttributes.GetNamedItem(at_g).ToFloat(),
fogAttributes.GetNamedItem(at_b).ToFloat());
}
else if (element_name == el_fogfactor)
else if (fog_element_name == el_fogfactor)
{
m_MapReader.m_LightEnv.m_FogFactor = fog.GetText().ToFloat();
}
else if (element_name == el_fogthickness)
else if (fog_element_name == el_fogthickness)
{
m_MapReader.m_LightEnv.m_FogMax = fog.GetText().ToFloat();
}
@ -679,24 +685,24 @@ void CXMLReader::ReadEnvironment(XMBElement parent)
{
XERO_ITER_EL(element, postproc)
{
int element_name = postproc.GetNodeName();
if (element_name == el_brightness)
int post_element_name = postproc.GetNodeName();
if (post_element_name == el_brightness)
{
m_MapReader.m_LightEnv.m_Brightness = postproc.GetText().ToFloat();
}
else if (element_name == el_contrast)
else if (post_element_name == el_contrast)
{
m_MapReader.m_LightEnv.m_Contrast = postproc.GetText().ToFloat();
}
else if (element_name == el_saturation)
else if (post_element_name == el_saturation)
{
m_MapReader.m_LightEnv.m_Saturation = postproc.GetText().ToFloat();
}
else if (element_name == el_bloom)
else if (post_element_name == el_bloom)
{
m_MapReader.m_LightEnv.m_Bloom = postproc.GetText().ToFloat();
}
else if (element_name == el_posteffect)
else if (post_element_name == el_posteffect)
{
if (m_MapReader.pPostproc)
m_MapReader.pPostproc->SetPostEffect(postproc.GetText().FromUTF8());
@ -710,8 +716,8 @@ void CXMLReader::ReadEnvironment(XMBElement parent)
ENSURE(waterbody.GetNodeName() == el_waterbody);
XERO_ITER_EL(waterbody, waterelement)
{
int element_name = waterelement.GetNodeName();
if (element_name == el_height)
int water_element_name = waterelement.GetNodeName();
if (water_element_name == el_height)
{
CmpPtr<ICmpWaterManager> cmpWaterManager(*m_MapReader.pSimContext, SYSTEM_ENTITY);
ENSURE(cmpWaterManager);
@ -724,7 +730,7 @@ void CXMLReader::ReadEnvironment(XMBElement parent)
if (!m_MapReader.pWaterMan)
continue;
if (element_name == el_type)
if (water_element_name == el_type)
{
if (waterelement.GetText() == "default")
m_MapReader.pWaterMan->m_WaterType = L"ocean";
@ -732,18 +738,18 @@ void CXMLReader::ReadEnvironment(XMBElement parent)
m_MapReader.pWaterMan->m_WaterType = waterelement.GetText().FromUTF8();
}
#define READ_COLOR(el, out) \
else if (element_name == el) \
else if (water_element_name == el) \
{ \
XMBAttributeList attrs = waterelement.GetAttributes(); \
XMBAttributeList colorAttrs = waterelement.GetAttributes(); \
out = CColor( \
attrs.GetNamedItem(at_r).ToFloat(), \
attrs.GetNamedItem(at_g).ToFloat(), \
attrs.GetNamedItem(at_b).ToFloat(), \
colorAttrs.GetNamedItem(at_r).ToFloat(), \
colorAttrs.GetNamedItem(at_g).ToFloat(), \
colorAttrs.GetNamedItem(at_b).ToFloat(), \
1.f); \
}
#define READ_FLOAT(el, out) \
else if (element_name == el) \
else if (water_element_name == el) \
{ \
out = waterelement.GetText().ToFloat(); \
} \
@ -981,28 +987,28 @@ int CXMLReader::ReadEntities(XMBElement parent, double end_time)
// <position>
else if (element_name == el_position)
{
XMBAttributeList attrs = setting.GetAttributes();
XMBAttributeList positionAttrs = setting.GetAttributes();
Position = CFixedVector3D(
fixed::FromString(attrs.GetNamedItem(at_x)),
fixed::FromString(attrs.GetNamedItem(at_y)),
fixed::FromString(attrs.GetNamedItem(at_z)));
fixed::FromString(positionAttrs.GetNamedItem(at_x)),
fixed::FromString(positionAttrs.GetNamedItem(at_y)),
fixed::FromString(positionAttrs.GetNamedItem(at_z)));
}
// <orientation>
else if (element_name == el_orientation)
{
XMBAttributeList attrs = setting.GetAttributes();
XMBAttributeList orientationAttrs = setting.GetAttributes();
Orientation = CFixedVector3D(
fixed::FromString(attrs.GetNamedItem(at_x)),
fixed::FromString(attrs.GetNamedItem(at_y)),
fixed::FromString(attrs.GetNamedItem(at_z)));
fixed::FromString(orientationAttrs.GetNamedItem(at_x)),
fixed::FromString(orientationAttrs.GetNamedItem(at_y)),
fixed::FromString(orientationAttrs.GetNamedItem(at_z)));
// TODO: what happens if some attributes are missing?
}
// <obstruction>
else if (element_name == el_obstruction)
{
XMBAttributeList attrs = setting.GetAttributes();
ControlGroup = attrs.GetNamedItem(at_group).ToInt();
ControlGroup2 = attrs.GetNamedItem(at_group2).ToInt();
XMBAttributeList obstructionAttrs = setting.GetAttributes();
ControlGroup = obstructionAttrs.GetNamedItem(at_group).ToInt();
ControlGroup2 = obstructionAttrs.GetNamedItem(at_group2).ToInt();
}
// <garrison>
else if (element_name == el_garrison)
@ -1011,8 +1017,8 @@ int CXMLReader::ReadEntities(XMBElement parent, double end_time)
Garrison.reserve(garrison.size());
for (const XMBElement& garr_ent : garrison)
{
XMBAttributeList attrs = garr_ent.GetAttributes();
Garrison.push_back(attrs.GetNamedItem(at_uid).ToInt());
XMBAttributeList garrisonAttrs = garr_ent.GetAttributes();
Garrison.push_back(garrisonAttrs.GetNamedItem(at_uid).ToInt());
}
}
// <turrets>
@ -1022,10 +1028,10 @@ int CXMLReader::ReadEntities(XMBElement parent, double end_time)
Turrets.reserve(turrets.size());
for (const XMBElement& turretPoint : turrets)
{
XMBAttributeList attrs = turretPoint.GetAttributes();
XMBAttributeList turretAttrs = turretPoint.GetAttributes();
Turrets.push_back(std::make_pair(
attrs.GetNamedItem(at_turret),
attrs.GetNamedItem(at_uid).ToInt()
turretAttrs.GetNamedItem(at_turret),
turretAttrs.GetNamedItem(at_uid).ToInt()
));
}
}

View File

@ -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
@ -69,7 +69,7 @@ CParticleEmitter::CParticleEmitter(const CParticleEmitterTypePtr& type) :
m_IndexArray.SetNumVertices(m_Type->m_MaxParticles * 6);
m_IndexArray.Layout();
VertexArrayIterator<u16> index = m_IndexArray.GetIterator();
for (size_t i = 0; i < m_Type->m_MaxParticles; ++i)
for (u16 i = 0; i < m_Type->m_MaxParticles; ++i)
{
*index++ = i*4 + 0;
*index++ = i*4 + 1;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2011 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
@ -100,7 +100,7 @@ private:
bool m_UseRelativeVelocity;
float m_MaxLifetime;
size_t m_MaxParticles;
u16 m_MaxParticles;
CBoundingBoxAligned m_MaxBounds;
typedef shared_ptr<IParticleVar> IParticleVarPtr;

View File

@ -128,7 +128,7 @@ public:
void CompareQuads(const CCamera::Quad& quad, const CCamera::Quad& expected_quad)
{
const float EPS = 1e-4;
const float EPS = 1e-4f;
for (size_t index = 0; index < expected_quad.size(); ++index)
{
TS_ASSERT_DELTA(quad[index].X, expected_quad[index].X, EPS);

View File

@ -451,16 +451,16 @@ public:
ss << "Terrain (" << terrain.GetPatchesPerSide()
<< "x" << terrain.GetPatchesPerSide() << "):";
TS_WARN(ss.str());
for (ssize_t jTile = 0; jTile < expectedSize; ++jTile)
for (ssize_t jj = 0; jj < expectedSize; ++jj)
{
ss.str(std::string());
ss << "[";
for (ssize_t iTile = 0; iTile < expectedSize; ++iTile)
for (ssize_t ii = 0; ii < expectedSize; ++ii)
{
if (iTile)
if (ii)
ss << ", ";
ss << GetVertex(terrain, iTile * PATCH_SIZE,
jTile * PATCH_SIZE);
ss << GetVertex(terrain, ii * PATCH_SIZE,
jj * PATCH_SIZE);
}
ss << "]";
TS_WARN(ss.str());

View File

@ -122,7 +122,7 @@ void CGUIManager::PopPage(ScriptInterface::StructuredClone args)
}
CGUIManager::SGUIPage::SGUIPage(const CStrW& pageName, const ScriptInterface::StructuredClone initData)
: name(pageName), initData(initData), inputs(), gui(), callbackFunction()
: m_Name(pageName), initData(initData), inputs(), gui(), callbackFunction()
{
}
@ -147,7 +147,7 @@ void CGUIManager::SGUIPage::LoadPage(shared_ptr<ScriptContext> scriptContext)
gui->AddObjectTypes();
VfsPath path = VfsPath("gui") / name;
VfsPath path = VfsPath("gui") / m_Name;
inputs.insert(path);
CXeromyces xero;
@ -162,7 +162,7 @@ void CGUIManager::SGUIPage::LoadPage(shared_ptr<ScriptContext> scriptContext)
if (root.GetNodeName() != elmt_page)
{
LOGERROR("GUI page '%s' must have root element <page>", utf8_from_wstring(name));
LOGERROR("GUI page '%s' must have root element <page>", utf8_from_wstring(m_Name));
return;
}
@ -170,12 +170,12 @@ void CGUIManager::SGUIPage::LoadPage(shared_ptr<ScriptContext> scriptContext)
{
if (node.GetNodeName() != elmt_include)
{
LOGERROR("GUI page '%s' must only have <include> elements inside <page>", utf8_from_wstring(name));
LOGERROR("GUI page '%s' must only have <include> elements inside <page>", utf8_from_wstring(m_Name));
continue;
}
std::string name = node.GetText();
CStrW nameW (node.GetText().FromUTF8());
CStr8 name = node.GetText();
CStrW nameW = node.GetText().FromUTF8();
PROFILE2("load gui xml");
PROFILE2_ATTR("name: %s", name.c_str());
@ -183,16 +183,16 @@ void CGUIManager::SGUIPage::LoadPage(shared_ptr<ScriptContext> scriptContext)
TIMER(nameW.c_str());
if (name.back() == '/')
{
VfsPath directory = VfsPath("gui") / nameW;
VfsPaths pathnames;
vfs::GetPathnames(g_VFS, directory, L"*.xml", pathnames);
for (const VfsPath& path : pathnames)
gui->LoadXmlFile(path, inputs);
VfsPath currentDirectory = VfsPath("gui") / nameW;
VfsPaths directories;
vfs::GetPathnames(g_VFS, currentDirectory, L"*.xml", directories);
for (const VfsPath& directory : directories)
gui->LoadXmlFile(directory, inputs);
}
else
{
VfsPath path = VfsPath("gui") / nameW;
gui->LoadXmlFile(path, inputs);
VfsPath directory = VfsPath("gui") / nameW;
gui->LoadXmlFile(directory, inputs);
}
}
@ -213,7 +213,7 @@ void CGUIManager::SGUIPage::LoadPage(shared_ptr<ScriptContext> scriptContext)
if (scriptInterface->HasProperty(global, "init") &&
!scriptInterface->CallFunctionVoid(global, "init", initDataVal, hotloadDataVal))
LOGERROR("GUI page '%s': Failed to call init() function", utf8_from_wstring(name));
LOGERROR("GUI page '%s': Failed to call init() function", utf8_from_wstring(m_Name));
}
void CGUIManager::SGUIPage::SetCallbackFunction(ScriptInterface& scriptInterface, JS::HandleValue callbackFunc)
@ -268,7 +268,7 @@ Status CGUIManager::ReloadChangedFile(const VfsPath& path)
for (SGUIPage& p : m_PageStack)
if (p.inputs.find(path) != p.inputs.end())
{
LOGMESSAGE("GUI file '%s' changed - reloading page '%s'", path.string8(), utf8_from_wstring(p.name));
LOGMESSAGE("GUI file '%s' changed - reloading page '%s'", path.string8(), utf8_from_wstring(p.m_Name));
p.LoadPage(m_ScriptContext);
// TODO: this can crash if LoadPage runs an init script which modifies the page stack and breaks our iterators
}

View File

@ -149,7 +149,7 @@ private:
*/
void PerformCallbackFunction(ScriptInterface::StructuredClone args);
CStrW name;
CStrW m_Name;
std::unordered_set<VfsPath> inputs; // for hotloading
ScriptInterface::StructuredClone initData; // data to be passed to the init() function
shared_ptr<CGUI> gui; // the actual GUI page

View File

@ -70,14 +70,8 @@ void CChart::HandleMessage(SGUIMessage& Message)
// IGUITextOwner::HandleMessage(Message); performed in UpdateSeries
// TODO: implement zoom
switch (Message.type)
{
case GUIM_SETTINGS_UPDATED:
{
if(Message.type == GUIM_SETTINGS_UPDATED)
UpdateSeries();
break;
}
}
}
void CChart::DrawLine(const CShaderProgramPtr& shader, const CGUIColor& color, const std::vector<float>& vertices) const

View File

@ -1280,18 +1280,18 @@ void CInput::Draw()
// Anyway, since the drawing procedure needs "To" to be
// greater than from, we need virtual values that might switch
// place.
int VirtualFrom, VirtualTo;
int virtualFrom = 0;
int virtualTo = 0;
if (m_iBufferPos_Tail >= m_iBufferPos)
{
VirtualFrom = m_iBufferPos;
VirtualTo = m_iBufferPos_Tail;
virtualFrom = m_iBufferPos;
virtualTo = m_iBufferPos_Tail;
}
else
{
VirtualFrom = m_iBufferPos_Tail;
VirtualTo = m_iBufferPos;
virtualFrom = m_iBufferPos_Tail;
virtualTo = m_iBufferPos;
}
@ -1307,7 +1307,7 @@ void CInput::Draw()
// (often compared against ints, so don't make it size_t)
for (int i = 0; i < (int)it->m_ListOfX.size()+2; ++i)
{
if (it->m_ListStart + i == VirtualFrom)
if (it->m_ListStart + i == virtualFrom)
{
// we won't actually draw it now, because we don't
// know the width of each glyph to that position.
@ -1321,13 +1321,13 @@ void CInput::Draw()
const bool at_end = (i == (int)it->m_ListOfX.size()+1);
if (drawing_box && (it->m_ListStart + i == VirtualTo || at_end))
if (drawing_box && (it->m_ListStart + i == virtualTo || at_end))
{
// Depending on if it's just a row change, or if it's
// the end of the select box, do slightly different things.
if (at_end)
{
if (it->m_ListStart + i != VirtualFrom)
if (it->m_ListStart + i != virtualFrom)
// and actually add a white space! yes, this is done in any common input
x_pointer += font.GetCharacterWidth(L' ');
}
@ -1755,10 +1755,10 @@ void CInput::UpdateText(int from, int to_before, int to_after)
// actually remove the entire lines they are on, it'll all have
// to be redone. And when going along, we'll delete a row at a time
// when continuing to see how much more after 'to' we need to remake.
int i = 0;
for (std::list<SRow>::iterator it = m_CharacterPositions.begin();
it != m_CharacterPositions.end();
++it, ++i)
++it)
{
if (!destroy_row_from_used && it->m_ListStart > check_point_row_start)
{

View File

@ -592,9 +592,9 @@ void CMiniMap::Draw()
}
// Add the pinged vertices at the end, so they are drawn on top
for (size_t v = 0; v < pingingVertices.size(); ++v)
for (const MinimapUnitVertex& vertex : pingingVertices)
{
addVertex(pingingVertices[v], attrColor, attrPos);
addVertex(vertex, attrColor, attrPos);
++m_EntitiesDrawn;
}

View File

@ -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
@ -364,21 +364,21 @@ void COList::DrawList(const int& selected, const CGUISpriteInstance& sprite, con
// Draw sort arrows in colum header
if (m_Sortable)
{
const CGUISpriteInstance* sprite;
const CGUISpriteInstance* pSprite;
if (m_SelectedColumn == column.m_Id)
{
if (m_SelectedColumnOrder == 0)
LOGERROR("selected_column_order must not be 0");
if (m_SelectedColumnOrder != -1)
sprite = &m_SpriteAsc;
pSprite = &m_SpriteAsc;
else
sprite = &m_SpriteDesc;
pSprite = &m_SpriteDesc;
}
else
sprite = &m_SpriteNotSorted;
pSprite = &m_SpriteNotSorted;
m_pGUI.DrawSprite(*sprite, m_CellID, bz + 0.1f, CRect(leftTopCorner + CPos(width - SORT_SPRITE_DIM, 0), leftTopCorner + CPos(width, SORT_SPRITE_DIM)));
m_pGUI.DrawSprite(*pSprite, m_CellID, bz + 0.1f, CRect(leftTopCorner + CPos(width - SORT_SPRITE_DIM, 0), leftTopCorner + CPos(width, SORT_SPRITE_DIM)));
}
// Draw column header text
@ -413,14 +413,11 @@ void COList::DrawList(const int& selected, const CGUISpriteInstance& sprite, con
// Draw all items for that column
xpos = 0;
size_t col = 0;
for (const COListColumn& column : m_Columns)
for (size_t colIdx = 0; colIdx < m_Columns.size(); ++colIdx)
{
const COListColumn& column = m_Columns[i];
if (column.m_Hidden)
{
++col;
continue;
}
// Determine text position and width
const CPos textPos = rect.TopLeft() + CPos(xpos, -scroll + m_ItemsYPositions[i]);
@ -436,9 +433,8 @@ void COList::DrawList(const int& selected, const CGUISpriteInstance& sprite, con
cliparea2.bottom = std::min(cliparea2.bottom, textPos.y + rowHeight);
// Draw list item
DrawText(objectsCount * (i +/*Heading*/1) + col, column.m_TextColor, textPos, bz + 0.1f, cliparea2);
DrawText(objectsCount * (i +/*Heading*/1) + colIdx, column.m_TextColor, textPos, bz + 0.1f, cliparea2);
xpos += width;
++col;
}
}
}

View File

@ -367,7 +367,7 @@ bool CNetServerWorker::Broadcast(const CNetMessage* message, const std::vector<N
// of remote peers; could do it more efficiently if that's a real problem
for (CNetServerSession* session : m_Sessions)
if (std::find(targetStates.begin(), targetStates.end(), session->GetCurrState()) != targetStates.end() &&
if (std::find(targetStates.begin(), targetStates.end(), static_cast<NetServerSessionState>(session->GetCurrState())) != targetStates.end() &&
!session->SendMessage(message))
ok = false;
@ -1452,11 +1452,9 @@ bool CNetServerWorker::OnClientPaused(void* context, CFsmEvent* event)
}
// Send messages to clients that are in game, and are not the client who paused.
for (CNetServerSession* session : server.m_Sessions)
{
if (session->GetCurrState() == NSS_INGAME && message->m_GUID != session->GetGUID())
session->SendMessage(message);
}
for (CNetServerSession* netSession : server.m_Sessions)
if (netSession->GetCurrState() == NSS_INGAME && message->m_GUID != netSession->GetGUID())
netSession->SendMessage(message);
return true;
}

View File

@ -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
@ -153,10 +153,10 @@ void CNetServerTurnManager::NotifyFinishedClientUpdate(CNetServerSession& sessio
CSyncErrorMessage msg;
msg.m_Turn = clientStateHash.first;
msg.m_HashExpected = expected;
for (const CStrW& playername : OOSPlayerNames)
for (const CStrW& oosPlayername : OOSPlayerNames)
{
CSyncErrorMessage::S_m_PlayerNames h;
h.m_Name = playername;
h.m_Name = oosPlayername;
msg.m_PlayerNames.push_back(h);
}
m_NetServer.Broadcast(&msg, { NSS_INGAME });

View File

@ -38,12 +38,12 @@ u16 JSI_Network::GetDefaultPort(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivat
bool JSI_Network::HasNetServer(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return g_NetServer;
return !!g_NetServer;
}
bool JSI_Network::HasNetClient(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return g_NetClient;
return !!g_NetClient;
}
JS::Value JSI_Network::FindStunEndpoint(ScriptInterface::CmptPrivate* pCmptPrivate, int port)
@ -58,7 +58,7 @@ void JSI_Network::StartNetworkHost(ScriptInterface::CmptPrivate* pCmptPrivate, c
ENSURE(!g_Game);
// Always use lobby authentication for lobby matches to prevent impersonation and smurfing, in particular through mods that implemented an UI for arbitrary or other players nicknames.
g_NetServer = new CNetServer(static_cast<bool>(g_XmppClient));
g_NetServer = new CNetServer(!!g_XmppClient);
if (!g_NetServer->SetupConnection(serverPort))
{
ScriptRequest rq(pCmptPrivate->pScriptInterface);

View File

@ -1359,8 +1359,8 @@ bool Autostart(const CmdLineArgs& args)
int playerID = civArgs[i].BeforeFirst(":").ToInt();
// Instead of overwriting existing player data, modify the array
JS::RootedValue player(rq.cx);
if (!scriptInterface.GetPropertyInt(playerData, playerID-offset, &player) || player.isUndefined())
JS::RootedValue currentPlayer(rq.cx);
if (!scriptInterface.GetPropertyInt(playerData, playerID-offset, &currentPlayer) || currentPlayer.isUndefined())
{
if (mapDirectory == L"skirmishes")
{
@ -1368,12 +1368,12 @@ bool Autostart(const CmdLineArgs& args)
LOGWARNING("Autostart: Invalid player %d in autostart-team option", playerID);
continue;
}
ScriptInterface::CreateObject(rq, &player);
ScriptInterface::CreateObject(rq, &currentPlayer);
}
int teamID = civArgs[i].AfterFirst(":").ToInt() - 1;
scriptInterface.SetProperty(player, "Team", teamID);
scriptInterface.SetPropertyInt(playerData, playerID-offset, player);
scriptInterface.SetProperty(currentPlayer, "Team", teamID);
scriptInterface.SetPropertyInt(playerData, playerID-offset, currentPlayer);
}
}
@ -1390,8 +1390,8 @@ bool Autostart(const CmdLineArgs& args)
int playerID = aiArgs[i].BeforeFirst(":").ToInt();
// Instead of overwriting existing player data, modify the array
JS::RootedValue player(rq.cx);
if (!scriptInterface.GetPropertyInt(playerData, playerID-offset, &player) || player.isUndefined())
JS::RootedValue currentPlayer(rq.cx);
if (!scriptInterface.GetPropertyInt(playerData, playerID-offset, &currentPlayer) || currentPlayer.isUndefined())
{
if (mapDirectory == L"scenarios" || mapDirectory == L"skirmishes")
{
@ -1399,13 +1399,13 @@ bool Autostart(const CmdLineArgs& args)
LOGWARNING("Autostart: Invalid player %d in autostart-ai option", playerID);
continue;
}
ScriptInterface::CreateObject(rq, &player);
ScriptInterface::CreateObject(rq, &currentPlayer);
}
scriptInterface.SetProperty(player, "AI", aiArgs[i].AfterFirst(":"));
scriptInterface.SetProperty(player, "AIDiff", 3);
scriptInterface.SetProperty(player, "AIBehavior", "balanced");
scriptInterface.SetPropertyInt(playerData, playerID-offset, player);
scriptInterface.SetProperty(currentPlayer, "AI", aiArgs[i].AfterFirst(":"));
scriptInterface.SetProperty(currentPlayer, "AIDiff", 3);
scriptInterface.SetProperty(currentPlayer, "AIBehavior", "balanced");
scriptInterface.SetPropertyInt(playerData, playerID-offset, currentPlayer);
}
}
// Set AI difficulty
@ -1417,8 +1417,8 @@ bool Autostart(const CmdLineArgs& args)
int playerID = civArgs[i].BeforeFirst(":").ToInt();
// Instead of overwriting existing player data, modify the array
JS::RootedValue player(rq.cx);
if (!scriptInterface.GetPropertyInt(playerData, playerID-offset, &player) || player.isUndefined())
JS::RootedValue currentPlayer(rq.cx);
if (!scriptInterface.GetPropertyInt(playerData, playerID-offset, &currentPlayer) || currentPlayer.isUndefined())
{
if (mapDirectory == L"scenarios" || mapDirectory == L"skirmishes")
{
@ -1426,11 +1426,11 @@ bool Autostart(const CmdLineArgs& args)
LOGWARNING("Autostart: Invalid player %d in autostart-aidiff option", playerID);
continue;
}
ScriptInterface::CreateObject(rq, &player);
ScriptInterface::CreateObject(rq, &currentPlayer);
}
scriptInterface.SetProperty(player, "AIDiff", civArgs[i].AfterFirst(":").ToInt());
scriptInterface.SetPropertyInt(playerData, playerID-offset, player);
scriptInterface.SetProperty(currentPlayer, "AIDiff", civArgs[i].AfterFirst(":").ToInt());
scriptInterface.SetPropertyInt(playerData, playerID-offset, currentPlayer);
}
}
// Set player data for Civs
@ -1444,8 +1444,8 @@ bool Autostart(const CmdLineArgs& args)
int playerID = civArgs[i].BeforeFirst(":").ToInt();
// Instead of overwriting existing player data, modify the array
JS::RootedValue player(rq.cx);
if (!scriptInterface.GetPropertyInt(playerData, playerID-offset, &player) || player.isUndefined())
JS::RootedValue currentPlayer(rq.cx);
if (!scriptInterface.GetPropertyInt(playerData, playerID-offset, &currentPlayer) || currentPlayer.isUndefined())
{
if (mapDirectory == L"skirmishes")
{
@ -1453,11 +1453,11 @@ bool Autostart(const CmdLineArgs& args)
LOGWARNING("Autostart: Invalid player %d in autostart-civ option", playerID);
continue;
}
ScriptInterface::CreateObject(rq, &player);
ScriptInterface::CreateObject(rq, &currentPlayer);
}
scriptInterface.SetProperty(player, "Civ", civArgs[i].AfterFirst(":"));
scriptInterface.SetPropertyInt(playerData, playerID-offset, player);
scriptInterface.SetProperty(currentPlayer, "Civ", civArgs[i].AfterFirst(":"));
scriptInterface.SetPropertyInt(playerData, playerID-offset, currentPlayer);
}
}
else

View File

@ -418,12 +418,11 @@ bool ModIo::AdvanceRequest(const ScriptInterface& scriptInterface)
if (!message)
continue;
CURLcode err = message->data.result;
if (err == CURLE_OK)
if (message->data.result == CURLE_OK)
continue;
std::string error = fmt::sprintf(
g_L10n.Translate("Download failure. Server response: %s; %s."), curl_easy_strerror(err), m_ErrorBuffer);
g_L10n.Translate("Download failure. Server response: %s; %s."), curl_easy_strerror(message->data.result), m_ErrorBuffer);
TearDownRequest();
if (m_DownloadProgressData.status == DownloadProgressStatus::GAMEID)
m_DownloadProgressData.status = DownloadProgressStatus::FAILED_GAMEID;

View File

@ -282,19 +282,19 @@ void CProfileViewer::RenderProfile()
currentExpandId++;
}
float colX = 0.0f;
float rowColX = 0.0f;
for (size_t col = 0; col < columns.size(); ++col)
{
CStrW text = table->GetCellText(row, col).FromUTF8();
int w, h;
font.CalculateStringSize(text.c_str(), w, h);
float x = colX;
float x = rowColX;
if (col > 0) // right-align all but the first column
x += columns[col].width - w;
textRenderer.Put(x, 0.0f, text.c_str());
colX += columns[col].width;
rowColX += columns[col].width;
}
textRenderer.Translate(0.0f, lineSpacing, 0.0f);

View File

@ -178,14 +178,14 @@ void OverlayRendererInternals::Initialize()
// indices are always the same; we can therefore fill in all the indices once and pretty much forget about
// them. We then also no longer need its backing store, since we never change any indices afterwards.
VertexArrayIterator<u16> index = quadIndices.GetIterator();
for (size_t i = 0; i < MAX_QUAD_OVERLAYS; ++i)
for (u16 i = 0; i < static_cast<u16>(MAX_QUAD_OVERLAYS); ++i)
{
*index++ = i*4 + 0;
*index++ = i*4 + 1;
*index++ = i*4 + 2;
*index++ = i*4 + 2;
*index++ = i*4 + 3;
*index++ = i*4 + 0;
*index++ = i * 4 + 0;
*index++ = i * 4 + 1;
*index++ = i * 4 + 2;
*index++ = i * 4 + 2;
*index++ = i * 4 + 3;
*index++ = i * 4 + 0;
}
quadIndices.Upload();
quadIndices.FreeBackingStore();

View File

@ -308,7 +308,7 @@ void CPatchRData::BuildBlends()
// Update the indices to include the base offset of the vertex data
for (size_t k = 0; k < blendIndices.size(); ++k)
blendIndices[k] += m_VBBlends->m_Index;
blendIndices[k] += static_cast<u16>(m_VBBlends->m_Index);
m_VBBlendIndices = g_VBMan.Allocate(sizeof(u16), blendIndices.size(), GL_STATIC_DRAW, GL_ELEMENT_ARRAY_BUFFER);
m_VBBlendIndices->m_Owner->UpdateChunkVertices(m_VBBlendIndices, &blendIndices[0]);
@ -369,7 +369,7 @@ void CPatchRData::AddBlend(std::vector<SBlendVertex>& blendVertices, std::vector
CVector3D normal;
size_t index = blendVertices.size();
u16 index = static_cast<u16>(blendVertices.size());
terrain->CalcPosition(gx, gz, dst.m_Position);
terrain->CalcNormal(gx, gz, normal);
@ -464,10 +464,11 @@ void CPatchRData::BuildIndices()
// build indices for base splats
size_t base=m_VBBase->m_Index;
for (size_t i=0;i<m_Splats.size();i++) {
CTerrainTextureEntry* tex=textures[i];
for (size_t k = 0; k < m_Splats.size(); ++k)
{
CTerrainTextureEntry* tex = textures[k];
SSplat& splat=m_Splats[i];
SSplat& splat=m_Splats[k];
splat.m_Texture=tex;
splat.m_IndexStart=indices.size();
@ -1101,23 +1102,22 @@ void CPatchRData::RenderBlends(const std::vector<CPatchRData*>& patches, const C
void CPatchRData::RenderStreams(const std::vector<CPatchRData*>& patches, const CShaderProgramPtr& shader, int streamflags)
{
// Each batch has a list of index counts, and a list of pointers-to-first-indexes
typedef std::pair<std::vector<GLint>, std::vector<void*> > BatchElements;
using StreamBatchElements = std::pair<std::vector<GLint>, std::vector<void*> > ;
// Group batches by index buffer
typedef std::map<CVertexBuffer*, BatchElements> IndexBufferBatches;
using StreamIndexBufferBatches = std::map<CVertexBuffer*, StreamBatchElements> ;
// Group batches by vertex buffer
typedef std::map<CVertexBuffer*, IndexBufferBatches> VertexBufferBatches;
using StreamVertexBufferBatches = std::map<CVertexBuffer*, StreamIndexBufferBatches> ;
VertexBufferBatches batches;
StreamVertexBufferBatches batches;
PROFILE_START("compute batches");
// Collect all the patches into their appropriate batches
for (size_t i = 0; i < patches.size(); ++i)
{
CPatchRData* patch = patches[i];
BatchElements& batch = batches[patch->m_VBBase->m_Owner][patch->m_VBBaseIndices->m_Owner];
for (const CPatchRData* patch : patches)
{
StreamBatchElements& batch = batches[patch->m_VBBase->m_Owner][patch->m_VBBaseIndices->m_Owner];
batch.first.push_back(patch->m_VBBaseIndices->m_Count);
@ -1130,10 +1130,10 @@ void CPatchRData::RenderStreams(const std::vector<CPatchRData*>& patches, const
ENSURE(!(streamflags & ~(STREAM_POS|STREAM_POSTOUV0|STREAM_POSTOUV1)));
// Render each batch
for (VertexBufferBatches::iterator itv = batches.begin(); itv != batches.end(); ++itv)
for (const std::pair<CVertexBuffer*, StreamIndexBufferBatches>& streamBatch : batches)
{
GLsizei stride = sizeof(SBaseVertex);
SBaseVertex *base = (SBaseVertex *)itv->first->Bind();
SBaseVertex *base = (SBaseVertex *)streamBatch.first->Bind();
shader->VertexPointer(3, GL_FLOAT, stride, &base->m_Position);
if (streamflags & STREAM_POSTOUV0)
@ -1143,11 +1143,11 @@ void CPatchRData::RenderStreams(const std::vector<CPatchRData*>& patches, const
shader->AssertPointersBound();
for (IndexBufferBatches::iterator it = itv->second.begin(); it != itv->second.end(); ++it)
for (const std::pair<CVertexBuffer*, StreamBatchElements>& batchIndexBuffer : streamBatch.second)
{
it->first->Bind();
batchIndexBuffer.first->Bind();
BatchElements& batch = it->second;
const StreamBatchElements& batch = batchIndexBuffer.second;
if (!g_Renderer.m_SkipSubmit)
{
@ -1381,7 +1381,7 @@ void CPatchRData::BuildWater()
vertex.m_WaterData = CVector2D(WaterMgr->m_WindStrength[xx + zz*mapSize], depth);
water_index_map[z+moves[i][1]][x+moves[i][0]] = water_vertex_data.size();
water_index_map[z+moves[i][1]][x+moves[i][0]] = static_cast<u16>(water_vertex_data.size());
water_vertex_data.push_back(vertex);
}
water_indices.push_back(water_index_map[z + moves[2][1]][x + moves[2][0]]);
@ -1414,7 +1414,7 @@ void CPatchRData::BuildWater()
vertex.m_WaterData = CVector2D(0.0f, -5.0f);
water_shore_index_map[z+moves[i][1]][x+moves[i][0]] = water_vertex_data_shore.size();
water_shore_index_map[z+moves[i][1]][x+moves[i][0]] = static_cast<u16>(water_vertex_data_shore.size());
water_vertex_data_shore.push_back(vertex);
}
if (terrain->GetTriangulationDir(x + px, z + pz))

View File

@ -557,11 +557,11 @@ std::vector<CStrW> CPostprocManager::GetPostEffects()
{
std::vector<CStrW> effects;
const VfsPath path(L"shaders/effects/postproc/");
const VfsPath folder(L"shaders/effects/postproc/");
VfsPaths pathnames;
if (vfs::GetPathnames(g_VFS, path, 0, pathnames) < 0)
LOGERROR("Error finding Post effects in '%s'", path.string8());
if (vfs::GetPathnames(g_VFS, folder, 0, pathnames) < 0)
LOGERROR("Error finding Post effects in '%s'", folder.string8());
for (const VfsPath& path : pathnames)
if (path.Extension() == L".xml")

View File

@ -167,8 +167,9 @@ void CTexturedLineRData::Update(const SOverlayTexturedLine& line)
vertices.push_back(vertex1);
vertices.push_back(vertex2);
u16 index1 = vertices.size() - 2; // index of vertex1 in this iteration (TR of this quad)
u16 index2 = vertices.size() - 1; // index of the vertex2 in this iteration (TL of this quad)
u16 vertexCount = static_cast<u16>(vertices.size());
u16 index1 = vertexCount - 2; // index of vertex1 in this iteration (TR of this quad)
u16 index2 = vertexCount - 1; // index of the vertex2 in this iteration (TL of this quad)
if (i == 0)
{
@ -178,10 +179,10 @@ void CTexturedLineRData::Update(const SOverlayTexturedLine& line)
}
else
{
u16 index1Prev = vertices.size() - 4; // index of the vertex1 in the previous iteration (BR of this quad)
u16 index2Prev = vertices.size() - 3; // index of the vertex2 in the previous iteration (BL of this quad)
ENSURE(index1Prev < vertices.size());
ENSURE(index2Prev < vertices.size());
u16 index1Prev = vertexCount - 4; // index of the vertex1 in the previous iteration (BR of this quad)
u16 index2Prev = vertexCount - 3; // index of the vertex2 in the previous iteration (BL of this quad)
ENSURE(index1Prev < vertexCount);
ENSURE(index2Prev < vertexCount);
// Add two corner points from last iteration and join with one of our own corners to create triangle 1
// (don't need to do this if i == 1 because i == 0 are the first two ones, they don't need to be copied)
if (i > 1)
@ -227,12 +228,13 @@ void CTexturedLineRData::Update(const SOverlayTexturedLine& line)
// close the path
if (n % 2 == 0)
{
indices.push_back(vertices.size()-2);
indices.push_back(vertices.size()-1);
u16 vertexCount = static_cast<u16>(vertices.size());
indices.push_back(vertexCount - 2);
indices.push_back(vertexCount - 1);
indices.push_back(0);
indices.push_back(0);
indices.push_back(vertices.size()-1);
indices.push_back(vertexCount - 1);
indices.push_back(1);
}
else
@ -243,13 +245,14 @@ void CTexturedLineRData::Update(const SOverlayTexturedLine& line)
vertices.push_back(vertex1);
vertices.push_back(vertex2);
indices.push_back(vertices.size()-4);
indices.push_back(vertices.size()-3);
indices.push_back(vertices.size()-2);
u16 vertexCount = static_cast<u16>(vertices.size());
indices.push_back(vertexCount - 4);
indices.push_back(vertexCount - 3);
indices.push_back(vertexCount - 2);
indices.push_back(vertices.size()-2);
indices.push_back(vertices.size()-3);
indices.push_back(vertices.size()-1);
indices.push_back(vertexCount - 2);
indices.push_back(vertexCount - 3);
indices.push_back(vertexCount - 1);
}
}
else
@ -274,7 +277,7 @@ void CTexturedLineRData::Update(const SOverlayTexturedLine& line)
);
for (unsigned i = 0; i < capIndices.size(); i++)
capIndices[i] += vertices.size();
capIndices[i] += static_cast<u16>(vertices.size());
vertices.insert(vertices.end(), capVertices.begin(), capVertices.end());
indices.insert(indices.end(), capIndices.begin(), capIndices.end());
@ -296,7 +299,7 @@ void CTexturedLineRData::Update(const SOverlayTexturedLine& line)
);
for (unsigned i = 0; i < capIndices.size(); i++)
capIndices[i] += vertices.size();
capIndices[i] += static_cast<u16>(vertices.size());
vertices.insert(vertices.end(), capVertices.begin(), capVertices.end());
indices.insert(indices.end(), capIndices.begin(), capIndices.end());
@ -314,7 +317,7 @@ void CTexturedLineRData::Update(const SOverlayTexturedLine& line)
m_VB->m_Owner->UpdateChunkVertices(m_VB, &vertices[0]); // copy data into VBO
for (size_t k = 0; k < indices.size(); ++k)
indices[k] += m_VB->m_Index;
indices[k] += static_cast<u16>(m_VB->m_Index);
m_VBIndices = g_VBMan.Allocate(sizeof(u16), indices.size(), GL_STATIC_DRAW, GL_ELEMENT_ARRAY_BUFFER);
if (m_VBIndices)
@ -347,7 +350,7 @@ void CTexturedLineRData::CreateLineCap(const SOverlayTexturedLine& line, const C
CVector3D centerPoint = (corner1 + corner2) * 0.5f;
SVertex centerVertex(centerPoint, 0.5f, 0.5f);
u16 indexOffset = verticesOut.size(); // index offset in verticesOut from where we start adding our vertices
u16 indexOffset = static_cast<u16>(verticesOut.size()); // index offset in verticesOut from where we start adding our vertices
switch (endCapType)
{

View File

@ -611,20 +611,20 @@ void WaterManager::CreateWaveMeshes()
}
// Fourth step: create waves themselves, using those chains. We basically create subchains.
size_t waveSizes = 14; // maximal size in width.
GLushort waveSizes = 14; // maximal size in width.
// Construct indices buffer (we can afford one for all of them)
std::vector<GLushort> water_indices;
for (size_t a = 0; a < waveSizes-1;++a)
for (GLushort a = 0; a < waveSizes - 1; ++a)
{
for (size_t rect = 0; rect < 7; ++rect)
for (GLushort rect = 0; rect < 7; ++rect)
{
water_indices.push_back(a*9 + rect);
water_indices.push_back(a*9 + 9 + rect);
water_indices.push_back(a*9 + 1 + rect);
water_indices.push_back(a*9 + 9 + rect);
water_indices.push_back(a*9 + 10 + rect);
water_indices.push_back(a*9 + 1 + rect);
water_indices.push_back(a * 9 + rect);
water_indices.push_back(a * 9 + 9 + rect);
water_indices.push_back(a * 9 + 1 + rect);
water_indices.push_back(a * 9 + 9 + rect);
water_indices.push_back(a * 9 + 10 + rect);
water_indices.push_back(a * 9 + 1 + rect);
}
}
// Generic indexes, max-length
@ -640,14 +640,14 @@ void WaterManager::CreateWaveMeshes()
if (CoastalPointsChains[i].size()- 1 - j < waveSizes)
break;
size_t width = waveSizes;
GLushort width = waveSizes;
// First pass to get some parameters out.
float outmost = 0.0f; // how far to move on the shore.
float avgDepth = 0.0f;
int sign = 1;
CVector2D firstPerp(0,0), perp(0,0), lastPerp(0,0);
for (size_t a = 0; a < waveSizes;++a)
for (GLushort a = 0; a < waveSizes;++a)
{
lastPerp = perp;
perp = CVector2D(0,0);
@ -728,9 +728,9 @@ void WaterManager::CreateWaveMeshes()
shoreWave->m_TimeDiff = diff;
diff += (rand() % 100) / 25.0f + 4.0f;
for (size_t a = 0; a < width;++a)
for (GLushort a = 0; a < width;++a)
{
CVector2D perp = CVector2D(0,0);
perp = CVector2D(0,0);
int nb = 0;
CVector2D pos = CoastalPointsChains[i][j+a].position;
CVector2D posPlus;

View File

@ -198,12 +198,12 @@ bool CSimulation2Impl::LoadScripts(CComponentManager& componentManager, std::set
return false;
bool ok = true;
for (const VfsPath& path : pathnames)
for (const VfsPath& scriptPath : pathnames)
{
if (loadedScripts)
loadedScripts->insert(path);
LOGMESSAGE("Loading simulation script '%s'", path.string8());
if (!componentManager.LoadScript(path))
loadedScripts->insert(scriptPath);
LOGMESSAGE("Loading simulation script '%s'", scriptPath.string8());
if (!componentManager.LoadScript(scriptPath))
ok = false;
}
return ok;
@ -921,10 +921,10 @@ static std::vector<std::string> GetJSONData(const VfsPath& path)
{
// Load JSON file
CVFSFile file;
PSRETURN ret = file.Load(g_VFS, p);
if (ret != PSRETURN_OK)
PSRETURN loadStatus = file.Load(g_VFS, p);
if (loadStatus != PSRETURN_OK)
{
LOGERROR("GetJSONData: Failed to load file '%s': %s", p.string8(), GetErrorString(ret));
LOGERROR("GetJSONData: Failed to load file '%s': %s", p.string8(), GetErrorString(loadStatus));
continue;
}

View File

@ -771,18 +771,15 @@ public:
return;
// Attempt to replace colliding entities' control groups with a persistent one.
for (std::vector<entity_id_t>::iterator it = normalEnts.begin(); it != normalEnts.end(); ++it)
for (const entity_id_t normalEnt : normalEnts)
{
entity_id_t ent = *it;
CmpPtr<ICmpObstruction> cmpObstruction(GetSimContext(), ent);
for (std::vector<entity_id_t>::iterator it = persistentEnts.begin(); it != persistentEnts.end(); ++it)
CmpPtr<ICmpObstruction> cmpObstruction(GetSimContext(), normalEnt);
for (const entity_id_t persistent : normalEnts)
{
entity_id_t persistent = *it;
entity_id_t group = cmpObstruction->GetControlGroup();
// Only clobber 'default' control groups.
if (group == ent)
if (group == normalEnt)
cmpObstruction->SetControlGroup(persistent);
else if (cmpObstruction->GetControlGroup2() == INVALID_ENTITY && group != persistent)
cmpObstruction->SetControlGroup2(persistent);

View File

@ -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
@ -825,8 +825,8 @@ bool CCmpObstructionManager::IsInPointRange(entity_id_t ent, entity_pos_t px, en
fixed dist = DistanceToPoint(ent, px, pz);
// Treat -1 max range as infinite
return dist != fixed::FromInt(-1) &&
(dist <= (maxRange + fixed::FromFloat(0.0001)) || maxRange < fixed::Zero()) &&
(opposite ? MaxDistanceToPoint(ent, px, pz) : dist) >= minRange - fixed::FromFloat(0.0001);
(dist <= (maxRange + fixed::FromFloat(0.0001f)) || maxRange < fixed::Zero()) &&
(opposite ? MaxDistanceToPoint(ent, px, pz) : dist) >= minRange - fixed::FromFloat(0.0001f);
}
bool CCmpObstructionManager::IsInTargetRange(entity_id_t ent, entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange, bool opposite) const
@ -834,15 +834,15 @@ bool CCmpObstructionManager::IsInTargetRange(entity_id_t ent, entity_id_t target
fixed dist = DistanceToTarget(ent, target);
// Treat -1 max range as infinite
return dist != fixed::FromInt(-1) &&
(dist <= (maxRange + fixed::FromFloat(0.0001)) || maxRange < fixed::Zero()) &&
(opposite ? MaxDistanceToTarget(ent, target) : dist) >= minRange - fixed::FromFloat(0.0001);
(dist <= (maxRange + fixed::FromFloat(0.0001f)) || maxRange < fixed::Zero()) &&
(opposite ? MaxDistanceToTarget(ent, target) : dist) >= minRange - fixed::FromFloat(0.0001f);
}
bool CCmpObstructionManager::IsPointInPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t px, entity_pos_t pz, entity_pos_t minRange, entity_pos_t maxRange) const
{
entity_pos_t distance = (CFixedVector2D(x, z) - CFixedVector2D(px, pz)).Length();
// Treat -1 max range as infinite
return (distance <= (maxRange + fixed::FromFloat(0.0001)) || maxRange < fixed::Zero()) &&
distance >= minRange - fixed::FromFloat(0.0001);
return (distance <= (maxRange + fixed::FromFloat(0.0001f)) || maxRange < fixed::Zero()) &&
distance >= minRange - fixed::FromFloat(0.0001f);
}
bool CCmpObstructionManager::AreShapesInRange(const ObstructionSquare& source, const ObstructionSquare& target, entity_pos_t minRange, entity_pos_t maxRange, bool opposite) const
@ -850,8 +850,8 @@ bool CCmpObstructionManager::AreShapesInRange(const ObstructionSquare& source, c
fixed dist = DistanceBetweenShapes(source, target);
// Treat -1 max range as infinite
return dist != fixed::FromInt(-1) &&
(dist <= (maxRange + fixed::FromFloat(0.0001)) || maxRange < fixed::Zero()) &&
(opposite ? MaxDistanceBetweenShapes(source, target) : dist) >= minRange - fixed::FromFloat(0.0001);
(dist <= (maxRange + fixed::FromFloat(0.0001f)) || maxRange < fixed::Zero()) &&
(opposite ? MaxDistanceBetweenShapes(source, target) : dist) >= minRange - fixed::FromFloat(0.0001f);
}
bool CCmpObstructionManager::TestLine(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, bool relaxClearanceForUnits) const

View File

@ -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
@ -835,15 +835,15 @@ public:
if (newTerritory != m_Territory)
{
m_Territory = newTerritory;
CMessageTerritoryPositionChanged msg(GetEntityId(), m_Territory);
GetSimContext().GetComponentManager().PostMessage(GetEntityId(), msg);
CMessageTerritoryPositionChanged posMsg(GetEntityId(), m_Territory);
GetSimContext().GetComponentManager().PostMessage(GetEntityId(), posMsg);
}
}
else if (m_Territory != INVALID_PLAYER)
{
m_Territory = INVALID_PLAYER;
CMessageTerritoryPositionChanged msg(GetEntityId(), m_Territory);
GetSimContext().GetComponentManager().PostMessage(GetEntityId(), msg);
CMessageTerritoryPositionChanged posMsg(GetEntityId(), m_Territory);
GetSimContext().GetComponentManager().PostMessage(GetEntityId(), posMsg);
}
break;
}

View File

@ -126,7 +126,7 @@ static inline bool IsVisibilityDirty(u16 dirty, player_id_t player)
*/
static inline bool HasVisionSharing(u16 visionSharing, player_id_t player)
{
return visionSharing & 1 << (player-1);
return (visionSharing & (1 << (player - 1))) != 0;
}
/**
@ -1051,12 +1051,12 @@ public:
virtual std::vector<entity_id_t> GetNonGaiaEntities() const
{
return GetEntitiesByMask(~3); // bit 0 for owner=-1 and bit 1 for gaia
return GetEntitiesByMask(~3u); // bit 0 for owner=-1 and bit 1 for gaia
}
virtual std::vector<entity_id_t> GetGaiaAndNonGaiaEntities() const
{
return GetEntitiesByMask(~1); // bit 0 for owner=-1
return GetEntitiesByMask(~1u); // bit 0 for owner=-1
}
std::vector<entity_id_t> GetEntitiesByMask(u32 ownerMask) const
@ -1452,8 +1452,8 @@ public:
else
{
// elevation bonus is part of the 3D position. As if the unit is really that much higher
CFixedVector3D pos = cmpSourcePosition->GetPosition();
pos.Y += q.elevationBonus;
CFixedVector3D pos3D = cmpSourcePosition->GetPosition();
pos3D.Y += q.elevationBonus;
std::vector<entity_pos_t> coords;
@ -1461,7 +1461,7 @@ public:
if (ParabolicRangesOutlines.find(q.source.GetId()) != ParabolicRangesOutlines.end())
{
EntityParabolicRangeOutline e = ParabolicRangesOutlines[q.source.GetId()];
if (e.position == pos && e.range == q.maxRange)
if (e.position == pos3D && e.range == q.maxRange)
{
// outline is cached correctly, use it
coords = e.outline;
@ -1471,10 +1471,10 @@ public:
// outline was cached, but important parameters changed
// (position, elevation, range)
// update it
coords = getParabolicRangeForm(pos,q.maxRange,q.maxRange*2, entity_pos_t::Zero(), entity_pos_t::FromFloat(2.0f*3.14f),70);
coords = getParabolicRangeForm(pos3D,q.maxRange,q.maxRange*2, entity_pos_t::Zero(), entity_pos_t::FromFloat(2.0f*3.14f),70);
e.outline = coords;
e.range = q.maxRange;
e.position = pos;
e.position = pos3D;
ParabolicRangesOutlines[q.source.GetId()] = e;
}
}
@ -1483,11 +1483,11 @@ public:
// outline wasn't cached (first time you enable the range overlay
// or you created a new entiy)
// cache a new outline
coords = getParabolicRangeForm(pos,q.maxRange,q.maxRange*2, entity_pos_t::Zero(), entity_pos_t::FromFloat(2.0f*3.14f),70);
coords = getParabolicRangeForm(pos3D,q.maxRange,q.maxRange*2, entity_pos_t::Zero(), entity_pos_t::FromFloat(2.0f*3.14f),70);
EntityParabolicRangeOutline e;
e.source = q.source.GetId();
e.range = q.maxRange;
e.position = pos;
e.position = pos3D;
e.outline = coords;
ParabolicRangesOutlines[q.source.GetId()] = e;
}
@ -1498,10 +1498,10 @@ public:
for (size_t i = 3; i < coords.size(); i += 2)
{
std::vector<float> c;
c.push_back((coords[i-3]+pos.X).ToFloat());
c.push_back((coords[i-2]+pos.Z).ToFloat());
c.push_back((coords[i-1]+pos.X).ToFloat());
c.push_back((coords[i]+pos.Z).ToFloat());
c.push_back((coords[i - 3] + pos3D.X).ToFloat());
c.push_back((coords[i - 2] + pos3D.Z).ToFloat());
c.push_back((coords[i - 1] + pos3D.X).ToFloat());
c.push_back((coords[i] + pos3D.Z).ToFloat());
m_DebugOverlayLines.push_back(SOverlayLine());
m_DebugOverlayLines.back().m_Color = thiscolor;
SimRender::ConstructLineOnGround(GetSimContext(), c, m_DebugOverlayLines.back(), true);

View File

@ -347,11 +347,11 @@ private:
/// Total duration of a single fade, in seconds. Assumed constant for now; feel free to change this into
/// a member variable if you need to adjust it per component.
static const double FADE_DURATION;
static const float FADE_DURATION;
static const char* TEXTUREBASEPATH;
};
const double CCmpSelectable::FADE_DURATION = 0.3;
const float CCmpSelectable::FADE_DURATION = 0.3f;
const char* CCmpSelectable::TEXTUREBASEPATH = "art/textures/selection/";
void CCmpSelectable::HandleMessage(const CMessage& msg, bool UNUSED(global))

View File

@ -209,8 +209,7 @@ public:
if (m_TriggerEvent)
{
m_TriggerEvent = false;
CMessageTerritoriesChanged msg;
GetSimContext().GetComponentManager().BroadcastMessage(msg);
GetSimContext().GetComponentManager().BroadcastMessage(CMessageTerritoriesChanged());
}
break;
}
@ -326,7 +325,7 @@ struct Tile
};
// Floodfill templates that expand neighbours from a certain source onwards
// (x, z) are the coordinates of the currently expanded tile
// (posX, posZ) are the coordinates of the currently expanded tile
// (nx, nz) are the coordinates of the current neighbour handled
// The user of this floodfill should use "continue" on every neighbour that
// shouldn't be expanded on its own. (without continue, an infinite loop will happen)
@ -339,13 +338,13 @@ struct Tile
openTiles.emplace(i, j);\
while (!openTiles.empty())\
{\
u16 x = openTiles.front().x;\
u16 z = openTiles.front().z;\
u16 posX = openTiles.front().x;\
u16 posZ = openTiles.front().z;\
openTiles.pop();\
for (int n = 0; n < NUM_NEIGHBOURS; ++n)\
{\
u16 nx = x + NEIGHBOURS_X[n];\
u16 nz = z + NEIGHBOURS_Z[n];\
u16 nx = posX + NEIGHBOURS_X[n];\
u16 nz = posZ + NEIGHBOURS_Z[n];\
/* Check the bounds, underflow will cause the values to be big again */\
if (nx >= tilesW || nz >= tilesH)\
continue;\
@ -505,16 +504,16 @@ void CCmpTerritoryManager::CalculateTerritories()
u32 dg = falloff * m_CostGrid->get(nx, nz);
// diagonal neighbour -> multiply with approx sqrt(2)
if (nx != x && nz != z)
if (nx != posX && nz != posZ)
dg = (dg * 362) / 256;
// Don't expand if new cost is not better than previous value for that tile
// (arranged to avoid underflow if entityGrid.get(x, z) < dg)
if (entityGrid.get(x, z) <= entityGrid.get(nx, nz) + dg)
if (entityGrid.get(posX, posZ) <= entityGrid.get(nx, nz) + dg)
continue;
// weight of this tile = weight of predecessor - falloff from predecessor
u32 newWeight = entityGrid.get(x, z) - dg;
u32 newWeight = entityGrid.get(posX, posZ) - dg;
u32 totalWeight = playerGrid.get(nx, nz) - entityGrid.get(nx, nz) + newWeight;
playerGrid.set(nx, nz, totalWeight);
entityGrid.set(nx, nz, newWeight);

View File

@ -834,7 +834,7 @@ void CCmpUnitMotion::PathResult(u32 ticket, const WaypointPath& path)
{
// Get close enough - this will likely help the short path efficiency, and if we end up taking a wrong way
// we'll easily be able to revert it using a long path.
PathGoal goal = { PathGoal::CIRCLE, m_LongPath.m_Waypoints.back().x, m_LongPath.m_Waypoints.back().z, ShortPathWaypointRange(m_LongPath) };
goal = { PathGoal::CIRCLE, m_LongPath.m_Waypoints.back().x, m_LongPath.m_Waypoints.back().z, ShortPathWaypointRange(m_LongPath) };
RequestShortPath(pos, goal, true);
return;
}
@ -1087,7 +1087,7 @@ bool CCmpUnitMotion::HandleObstructedMove()
{
// Get close enough - this will likely help the short path efficiency, and if we end up taking a wrong way
// we'll easily be able to revert it using a long path.
PathGoal goal = { PathGoal::CIRCLE, m_LongPath.m_Waypoints.back().x, m_LongPath.m_Waypoints.back().z, ShortPathWaypointRange(m_LongPath) };
goal = { PathGoal::CIRCLE, m_LongPath.m_Waypoints.back().x, m_LongPath.m_Waypoints.back().z, ShortPathWaypointRange(m_LongPath) };
RequestShortPath(pos, goal, true);
return true;
}

View File

@ -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
@ -74,8 +74,8 @@ public:
{
// test that the map has the same global region everywhere
HierarchicalPathfinder::GlobalRegionID globalRegionID = hierPath.GetGlobalRegion(35, 23, PASS_1);
for (size_t i = 0; i < mapSize; ++i)
for (size_t j = 0; j < mapSize; ++j)
for (u16 i = 0; i < mapSize; ++i)
for (u16 j = 0; j < mapSize; ++j)
{
TS_ASSERT(globalRegionID == hierPath.GetGlobalRegion(i, j, PASS_1));
TS_ASSERT(hierPath.GetGlobalRegion(i, j, PASS_2) == 0);
@ -137,19 +137,19 @@ public:
// Global region: check we are now split in two.
TS_ASSERT(hierPath.GetGlobalRegion(50, 50, PASS_1) != hierPath.GetGlobalRegion(150, 50, PASS_1));
for (size_t j = 0; j < mapSize; ++j)
for (u16 j = 0; j < mapSize; ++j)
{
TS_ASSERT(hierPath.Get(125, j, PASS_1).r == 0);
TS_ASSERT(hierPath.GetGlobalRegion(125, j, PASS_1) == 0);
}
for (size_t i = 0; i < 125; ++i)
for (size_t j = 0; j < mapSize; ++j)
for (u16 i = 0; i < 125; ++i)
for (u16 j = 0; j < mapSize; ++j)
{
TS_ASSERT(hierPath.GetGlobalRegion(50, 50, PASS_1) == hierPath.GetGlobalRegion(i, j, PASS_1));
TS_ASSERT(hierPath.GetGlobalRegion(i, j, PASS_2) == 0);
}
for (size_t i = 126; i < mapSize; ++i)
for (size_t j = 0; j < mapSize; ++j)
for (u16 i = 126; i < mapSize; ++i)
for (u16 j = 0; j < mapSize; ++j)
{
TS_ASSERT(hierPath.GetGlobalRegion(150, 50, PASS_1) == hierPath.GetGlobalRegion(i, j, PASS_1));
TS_ASSERT(hierPath.GetGlobalRegion(i, j, PASS_2) == 0);

View File

@ -562,21 +562,21 @@ public:
TS_ASSERT_EQUALS(fixed::Zero(), cmp->DistanceToTarget(ent3, ent2));
// Due to rounding errors we need to use some leeway
TS_ASSERT_DELTA(fixed::FromFloat(std::sqrt(80)), cmp->MaxDistanceToTarget(ent2, ent3), fixed::FromFloat(0.0001));
TS_ASSERT_DELTA(fixed::FromFloat(std::sqrt(80)), cmp->MaxDistanceToTarget(ent3, ent2), fixed::FromFloat(0.0001));
TS_ASSERT_DELTA(fixed::FromFloat(std::sqrt(80)), cmp->MaxDistanceToTarget(ent2, ent3), fixed::FromFloat(0.0001f));
TS_ASSERT_DELTA(fixed::FromFloat(std::sqrt(80)), cmp->MaxDistanceToTarget(ent3, ent2), fixed::FromFloat(0.0001f));
TS_ASSERT_EQUALS(fixed::Zero(), cmp->DistanceToTarget(ent1, ent3));
TS_ASSERT_EQUALS(fixed::Zero(), cmp->DistanceToTarget(ent3, ent1));
TS_ASSERT_EQUALS(fixed::FromInt(6), cmp->DistanceToTarget(ent1, ent4));
TS_ASSERT_EQUALS(fixed::FromInt(6), cmp->DistanceToTarget(ent4, ent1));
TS_ASSERT_DELTA(fixed::FromFloat(std::sqrt(125) + 3), cmp->MaxDistanceToTarget(ent1, ent4), fixed::FromFloat(0.0001));
TS_ASSERT_DELTA(fixed::FromFloat(std::sqrt(125) + 3), cmp->MaxDistanceToTarget(ent4, ent1), fixed::FromFloat(0.0001));
TS_ASSERT_DELTA(fixed::FromFloat(std::sqrt(125) + 3), cmp->MaxDistanceToTarget(ent1, ent4), fixed::FromFloat(0.0001f));
TS_ASSERT_DELTA(fixed::FromFloat(std::sqrt(125) + 3), cmp->MaxDistanceToTarget(ent4, ent1), fixed::FromFloat(0.0001f));
TS_ASSERT_EQUALS(fixed::FromInt(7), cmp->DistanceToTarget(ent1, ent5));
TS_ASSERT_EQUALS(fixed::FromInt(7), cmp->DistanceToTarget(ent5, ent1));
TS_ASSERT_DELTA(fixed::FromFloat(std::sqrt(178)), cmp->MaxDistanceToTarget(ent1, ent5), fixed::FromFloat(0.0001));
TS_ASSERT_DELTA(fixed::FromFloat(std::sqrt(178)), cmp->MaxDistanceToTarget(ent5, ent1), fixed::FromFloat(0.0001));
TS_ASSERT_DELTA(fixed::FromFloat(std::sqrt(178)), cmp->MaxDistanceToTarget(ent1, ent5), fixed::FromFloat(0.0001f));
TS_ASSERT_DELTA(fixed::FromFloat(std::sqrt(178)), cmp->MaxDistanceToTarget(ent5, ent1), fixed::FromFloat(0.0001f));
TS_ASSERT(cmp->IsInTargetRange(ent1, ent2, fixed::Zero(), fixed::FromInt(1), true));
TS_ASSERT(cmp->IsInTargetRange(ent1, ent2, fixed::Zero(), fixed::FromInt(1), false));

View File

@ -640,8 +640,8 @@ void HierarchicalPathfinder::UpdateGlobalRegions(const std::map<pass_class_t, st
GlobalRegionID ID = m_NextGlobalRegionID++;
for (const RegionID& reg : reachable)
globalRegions[reg] = ID;
for (const RegionID& regionId : reachable)
globalRegions[regionId] = ID;
}
}
@ -825,9 +825,9 @@ Grid<u16> HierarchicalPathfinder::GetConnectivityGrid(pass_class_t passClass) co
u16 idx = 1;
for (size_t i = 0; i < m_W; ++i)
for (u16 i = 0; i < m_W; ++i)
{
for (size_t j = 0; j < m_H; ++j)
for (u16 j = 0; j < m_H; ++j)
{
if (connectivityGrid.get(i, j) != 0)
continue;

View File

@ -306,11 +306,14 @@ public:
virtual void BuildTextureRGBA(u8* data, size_t w, size_t h)
{
ENSURE(h <= std::numeric_limits<u16>::max() && w <= std::numeric_limits<u16>::max());
u16 height = static_cast<u16>(h);
u16 width = static_cast<u16>(w);
pass_class_t passClass = m_PathfinderHier.GetPassabilityClass("default");
for (size_t j = 0; j < h; ++j)
for (u16 j = 0; j < height; ++j)
{
for (size_t i = 0; i < w; ++i)
for (u16 i = 0; i < width; ++i)
{
SColor4ub color;

View File

@ -1079,8 +1079,8 @@ void CComponentManager::SendGlobalMessage(entity_id_t ent, const CMessage& msg)
// them accidentally picking up non-network-synchronised data.
if (ENTITY_IS_LOCAL(ent))
{
std::map<ComponentTypeId, ComponentType>::const_iterator it = m_ComponentTypesById.find(*ctit);
if (it != m_ComponentTypesById.end() && it->second.type == CT_Script)
std::map<ComponentTypeId, ComponentType>::const_iterator cit = m_ComponentTypesById.find(*ctit);
if (cit != m_ComponentTypesById.end() && cit->second.type == CT_Script)
continue;
}

View File

@ -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
@ -78,14 +78,14 @@ bool CComponentManager::DumpDebugState(std::ostream& stream, bool includeDebugIn
if (ENTITY_IS_LOCAL(cit->first))
serializer.TextLine(" type: local");
std::map<ComponentTypeId, IComponent*>::const_iterator ctit = cit->second.begin();
for (; ctit != cit->second.end(); ++ctit)
std::map<ComponentTypeId, IComponent*>::const_iterator it = cit->second.begin();
for (; it != cit->second.end(); ++it)
{
std::stringstream n;
n << " " << LookupComponentTypeName(ctit->first) << ":";
serializer.TextLine(n.str());
std::stringstream st;
st << " " << LookupComponentTypeName(it->first) << ":";
serializer.TextLine(st.str());
serializer.Indent(4);
ctit->second->Serialize(serializer);
it->second->Serialize(serializer);
serializer.Dedent(4);
}
serializer.TextLine("");

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2017 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
@ -187,6 +187,8 @@ void CParamNode::ApplyLayer(const XMBFile& xmb, const XMBElement& element, const
case MUL_ROUND:
node.m_Value = fixed::FromInt(oldval.Multiply(mod).ToInt_RoundToNearest()).ToString().FromUTF8();
break;
default:
break;
}
hasSetValue = true;
}
@ -428,8 +430,8 @@ void CParamNode::ConstructJSVal(const ScriptRequest& rq, JS::MutableHandleValue
return; // TODO: report error
}
JS::RootedValue childVal(rq.cx, JS::StringValue(str));
if (!JS_SetProperty(rq.cx, obj, "_string", childVal))
JS::RootedValue subChildVal(rq.cx, JS::StringValue(str));
if (!JS_SetProperty(rq.cx, obj, "_string", subChildVal))
{
ret.setUndefined();
return; // TODO: report error

View File

@ -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
@ -99,7 +99,7 @@ float CSoundGroup::RadiansOffCenter(const CVector3D& position, bool& onScreen, f
const int screenHeight = g_Game->GetView()->GetCamera()->GetViewPort().m_Height;
const float xBufferSize = screenWidth * 0.1f;
const float yBufferSize = 15.f;
const float radianCap = M_PI / 3.f;
const float radianCap = static_cast<float>(M_PI / 3);
float x, y;
g_Game->GetView()->GetCamera()->GetScreenCoordinates(position, x, y);

View File

@ -8,6 +8,7 @@
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
# pragma warning(disable: 4505) // Unreferenced function has been removed.
#endif
#include <vector>

View File

@ -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
@ -18,12 +18,13 @@
#include "AtlasObject.h"
#include "AtlasObjectImpl.h"
#include "JSONSpiritInclude.h"
#if defined(_MSC_VER)
# pragma warning(disable:4996) // deprecated CRT
# pragma warning(disable: 4459) // global declaration hidden
#endif
#include "JSONSpiritInclude.h"
#include <sstream>
static AtSmartPtr<AtNode> ConvertNode(json_spirit::Value node);

View File

@ -56,6 +56,11 @@
#include "simulation2/components/ICmpVisual.h"
#include "simulation2/system/ParamNode.h"
#ifdef _MSC_VER
# pragma warning(disable: 4458) // Declaration hides class member.
#endif
namespace
{
void InitGame()

View File

@ -486,18 +486,20 @@ MESSAGEHANDLER(MoveObjectPreview)
CFixedVector3D fTargetPos(entity_pos_t::FromFloat(targetPos.X), entity_pos_t::FromFloat(targetPos.Y), entity_pos_t::FromFloat(targetPos.Z));
CFixedVector3D dir = fTargetPos - referencePos;
for (size_t i = 0; i < g_PreviewEntitiesID.size(); ++i)
for (const entity_id_t id : g_PreviewEntitiesID)
{
entity_id_t id = (entity_id_t)g_PreviewEntitiesID[i];
CFixedVector3D posFinal;
CmpPtr<ICmpPosition> cmpPosition(*g_Game->GetSimulation2(), id);
if (cmpPosition && cmpPosition->IsInWorld())
CmpPtr<ICmpPosition> cmpPreviewPosition(*g_Game->GetSimulation2(), id);
if (cmpPreviewPosition)
{
// Calculate this object's position
CFixedVector3D posFixed = cmpPosition->GetPosition();
posFinal = posFixed + dir;
CFixedVector3D posFinal;
if (cmpPreviewPosition->IsInWorld())
{
// Calculate this object's position
CFixedVector3D posFixed = cmpPreviewPosition->GetPosition();
posFinal = posFixed + dir;
}
cmpPreviewPosition->JumpTo(posFinal.X, posFinal.Z);
}
cmpPosition->JumpTo(posFinal.X, posFinal.Z);
CheckObstructionAndUpdateVisual(id);
}
@ -729,11 +731,11 @@ BEGIN_COMMAND(MoveObjects)
CVector3D pivotPos(0, 0, 0);
bool pivotFloating = false;
CmpPtr<ICmpPosition> cmpPosition(*g_Game->GetSimulation2(), (entity_id_t)msg->pivot);
if (cmpPosition && cmpPosition->IsInWorld())
CmpPtr<ICmpPosition> cmpPositionPivot(*g_Game->GetSimulation2(), (entity_id_t)msg->pivot);
if (cmpPositionPivot && cmpPositionPivot->IsInWorld())
{
pivotFloating = cmpPosition->CanFloat();
CFixedVector3D pivotFixed = cmpPosition->GetPosition();
pivotFloating = cmpPositionPivot->CanFloat();
CFixedVector3D pivotFixed = cmpPositionPivot->GetPosition();
pivotPos = CVector3D(pivotFixed.X.ToFloat(), pivotFixed.Y.ToFloat(), pivotFixed.Z.ToFloat());
}