Uglily initialise player civ assignments to match their starting civ centre

This was SVN commit r8384.
This commit is contained in:
Ykkrosh 2010-10-16 23:07:20 +00:00
parent 1e53fa2e27
commit 0666dd6074

View File

@ -1066,15 +1066,20 @@ int CXMLReader::ReadEntities(XMBElement parent, double end_time)
if (!cmpOwner.null())
cmpOwner->SetOwner(PlayerID);
if (m_MapReader.m_CameraStartupTarget == INVALID_ENTITY && !cmpPosition.null())
if (boost::algorithm::ends_with(TemplateName, L"civil_centre"))
{
// HACK: we special-case civil centre files to initialise the camera.
// This ought to be based on a more generic mechanism for indicating
// per-player camera start locations.
if (PlayerID == m_MapReader.m_PlayerID && boost::algorithm::ends_with(TemplateName, L"civil_centre"))
{
if (m_MapReader.m_CameraStartupTarget == INVALID_ENTITY && PlayerID == m_MapReader.m_PlayerID && !cmpPosition.null())
m_MapReader.m_CameraStartupTarget = ent;
}
// HACK: we also special-case civil centres to set the reported civ
// for a (non-Gaia) player. This ought to be specified in the map file itself.
// (The Identity component is script-only and this is a temporary hack anyway,
// so we just eval a script.)
if (PlayerID >= 1)
sim.GetScriptInterface().Eval(("var ent = " + CStr(ent) + "; QueryOwnerInterface(ent, IID_Player).SetCiv(Engine.QueryInterface(ent, IID_Identity).GetCiv())").c_str());
}
}