Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/Simulation2.cpp
Show First 20 Lines • Show All 526 Lines • ▼ Show 20 Lines | |||||
void CSimulation2Impl::UpdateComponents(CSimContext& simContext, fixed turnLengthFixed, const std::vector<SimulationCommand>& commands) | void CSimulation2Impl::UpdateComponents(CSimContext& simContext, fixed turnLengthFixed, const std::vector<SimulationCommand>& commands) | ||||
{ | { | ||||
// TODO: the update process is pretty ugly, with lots of messages and dependencies | // TODO: the update process is pretty ugly, with lots of messages and dependencies | ||||
// between different components. Ought to work out a nicer way to do this. | // between different components. Ought to work out a nicer way to do this. | ||||
CComponentManager& componentManager = simContext.GetComponentManager(); | CComponentManager& componentManager = simContext.GetComponentManager(); | ||||
{ | { | ||||
PROFILE2("Sim - Update Start"); | PROFILE3("Sim - Update Start"); | ||||
CMessageTurnStart msgTurnStart; | CMessageTurnStart msgTurnStart; | ||||
componentManager.BroadcastMessage(msgTurnStart); | componentManager.BroadcastMessage(msgTurnStart); | ||||
} | } | ||||
CmpPtr<ICmpPathfinder> cmpPathfinder(simContext, SYSTEM_ENTITY); | CmpPtr<ICmpPathfinder> cmpPathfinder(simContext, SYSTEM_ENTITY); | ||||
if (cmpPathfinder) | if (cmpPathfinder) | ||||
{ | { | ||||
cmpPathfinder->UpdateGrid(); | cmpPathfinder->UpdateGrid(); | ||||
Show All 10 Lines | if (cmpCommandQueue) | ||||
cmpCommandQueue->FlushTurn(commands); | cmpCommandQueue->FlushTurn(commands); | ||||
// Process newly generated move commands so the UI feels snappy | // Process newly generated move commands so the UI feels snappy | ||||
if (cmpPathfinder) | if (cmpPathfinder) | ||||
cmpPathfinder->ProcessSameTurnMoves(); | cmpPathfinder->ProcessSameTurnMoves(); | ||||
// Send all the update phases | // Send all the update phases | ||||
{ | { | ||||
PROFILE2("Sim - Update"); | PROFILE3("Sim - Update"); | ||||
CMessageUpdate msgUpdate(turnLengthFixed); | CMessageUpdate msgUpdate(turnLengthFixed); | ||||
componentManager.BroadcastMessage(msgUpdate); | componentManager.BroadcastMessage(msgUpdate); | ||||
} | } | ||||
{ | { | ||||
CMessageUpdate_MotionFormation msgUpdate(turnLengthFixed); | CMessageUpdate_MotionFormation msgUpdate(turnLengthFixed); | ||||
componentManager.BroadcastMessage(msgUpdate); | componentManager.BroadcastMessage(msgUpdate); | ||||
} | } | ||||
// Process move commands for formations (group proxy) | // Process move commands for formations (group proxy) | ||||
if (cmpPathfinder) | if (cmpPathfinder) | ||||
cmpPathfinder->ProcessSameTurnMoves(); | cmpPathfinder->ProcessSameTurnMoves(); | ||||
{ | { | ||||
PROFILE2("Sim - Motion Unit"); | PROFILE3("Sim - Motion Unit"); | ||||
CMessageUpdate_MotionUnit msgUpdate(turnLengthFixed); | CMessageUpdate_MotionUnit msgUpdate(turnLengthFixed); | ||||
componentManager.BroadcastMessage(msgUpdate); | componentManager.BroadcastMessage(msgUpdate); | ||||
} | } | ||||
{ | { | ||||
PROFILE2("Sim - Update Final"); | PROFILE3("Sim - Update Final"); | ||||
CMessageUpdate_Final msgUpdate(turnLengthFixed); | CMessageUpdate_Final msgUpdate(turnLengthFixed); | ||||
componentManager.BroadcastMessage(msgUpdate); | componentManager.BroadcastMessage(msgUpdate); | ||||
} | } | ||||
// Process moves resulting from group proxy movement (unit needs to catch up or realign) and any others | // Process moves resulting from group proxy movement (unit needs to catch up or realign) and any others | ||||
if (cmpPathfinder) | if (cmpPathfinder) | ||||
cmpPathfinder->ProcessSameTurnMoves(); | cmpPathfinder->ProcessSameTurnMoves(); | ||||
Show All 11 Lines | void CSimulation2Impl::Interpolate(float simFrameLength, float frameOffset, float realFrameLength) | ||||
m_ComponentManager.BroadcastMessage(msg); | m_ComponentManager.BroadcastMessage(msg); | ||||
// Clean up any entities destroyed during interpolate (e.g. local corpses) | // Clean up any entities destroyed during interpolate (e.g. local corpses) | ||||
m_ComponentManager.FlushDestroyedComponents(); | m_ComponentManager.FlushDestroyedComponents(); | ||||
} | } | ||||
void CSimulation2Impl::DumpState() | void CSimulation2Impl::DumpState() | ||||
{ | { | ||||
PROFILE("DumpState"); | PROFILE3("DumpState"); | ||||
std::stringstream name;\ | std::stringstream name;\ | ||||
name << std::setw(5) << std::setfill('0') << m_TurnNumber << ".txt"; | name << std::setw(5) << std::setfill('0') << m_TurnNumber << ".txt"; | ||||
const OsPath path = m_OOSLogPath / name.str(); | const OsPath path = m_OOSLogPath / name.str(); | ||||
std::ofstream file (OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc); | std::ofstream file (OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc); | ||||
if (!DirectoryExists(m_OOSLogPath)) | if (!DirectoryExists(m_OOSLogPath)) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 372 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator