Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/network/NetClientTurnManager.cpp
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | void CNetClientTurnManager::OnSyncError(u32 turn, const CStr& expectedHash, const std::vector<CSyncErrorMessage::S_m_PlayerNames>& playerNames) | ||||
OsPath path = psLogDir() / "oos_dump.txt"; | OsPath path = psLogDir() / "oos_dump.txt"; | ||||
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); | ||||
m_Simulation2.DumpDebugState(file); | m_Simulation2.DumpDebugState(file); | ||||
file.close(); | file.close(); | ||||
hash = Hexify(hash); | hash = Hexify(hash); | ||||
std::stringstream msg; | std::stringstream playerNamesString; | ||||
msg << "Out of sync on turn " << turn; | std::vector<CStr> playerNamesStrings; | ||||
playerNamesStrings.reserve(playerNames.size()); | |||||
for (size_t i = 0; i < playerNames.size(); ++i) | for (size_t i = 0; i < playerNames.size(); ++i) | ||||
msg << (i == 0 ? "\nPlayers: " : ", ") << utf8_from_wstring(playerNames[i].m_Name); | { | ||||
CStr name = utf8_from_wstring(playerNames[i].m_Name); | |||||
msg << "\n\n" << "Your game state is " << (expectedHash == hash ? "identical to" : "different from") << " the hosts game state."; | playerNamesString << (i == 0 ? "" : ", ") << name; | ||||
playerNamesStrings.push_back(name); | |||||
msg << "\n\n" << "Dumping current state to " << CStr(path.string8()).EscapeToPrintableASCII(); | } | ||||
LOGERROR("%s", msg.str()); | LOGERROR("Out-Of-Sync on turn %d\nPlayers: %s\nDumping state to %s", turn, playerNamesString.str().c_str(), path.string8()); | ||||
if (g_GUI) | ScriptInterface& scriptInterface = m_NetClient.GetScriptInterface(); | ||||
g_GUI->DisplayMessageBox(600, 350, L"Sync error", wstring_from_utf8(msg.str())); | JSContext* cx = scriptInterface.GetContext(); | ||||
JSAutoRequest rq(cx); | |||||
JS::RootedValue msg(cx); | |||||
scriptInterface.Eval("({ 'type':'out-of-sync' })", &msg); | |||||
scriptInterface.SetProperty(msg, "turn", turn); | |||||
scriptInterface.SetProperty(msg, "players", playerNamesStrings); | |||||
scriptInterface.SetProperty(msg, "expectedHash", expectedHash); | |||||
scriptInterface.SetProperty(msg, "hash", hash); | |||||
scriptInterface.SetProperty(msg, "path_oos_dump", path.string8()); | |||||
scriptInterface.SetProperty(msg, "path_replay", m_Replay.GetDirectory().string8()); | |||||
m_NetClient.PushGuiMessage(msg); | |||||
} | } |
Wildfire Games · Phabricator