# Support rejoining multiplayer games after disconnection.

This was SVN commit r10437.
This commit is contained in:
Ykkrosh
2011-10-27 16:46:48 +00:00
parent 6d071123cc
commit bfe2126a17
16 changed files with 1038 additions and 81 deletions
+7 -7
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2010 Wildfire Games.
/* Copyright (C) 2011 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -94,12 +94,12 @@ public:
};
CSimulationMessage::CSimulationMessage(ScriptInterface& scriptInterface) :
CNetMessage(NMT_SIMULATION_COMMAND), m_ScriptInterface(scriptInterface)
CNetMessage(NMT_SIMULATION_COMMAND), m_ScriptInterface(&scriptInterface)
{
}
CSimulationMessage::CSimulationMessage(ScriptInterface& scriptInterface, u32 client, i32 player, u32 turn, jsval data) :
CNetMessage(NMT_SIMULATION_COMMAND), m_ScriptInterface(scriptInterface),
CNetMessage(NMT_SIMULATION_COMMAND), m_ScriptInterface(&scriptInterface),
m_Client(client), m_Player(player), m_Turn(turn), m_Data(scriptInterface.GetContext(), data)
{
}
@@ -110,7 +110,7 @@ u8* CSimulationMessage::Serialize(u8* pBuffer) const
// TODO: ought to represent common commands more efficiently
u8* pos = CNetMessage::Serialize(pBuffer);
CBufferBinarySerializer serializer(m_ScriptInterface, pos);
CBufferBinarySerializer serializer(*m_ScriptInterface, pos);
serializer.NumberU32_Unbounded("client", m_Client);
serializer.NumberI32_Unbounded("player", m_Player);
serializer.NumberU32_Unbounded("turn", m_Turn);
@@ -125,7 +125,7 @@ const u8* CSimulationMessage::Deserialize(const u8* pStart, const u8* pEnd)
const u8* pos = CNetMessage::Deserialize(pStart, pEnd);
std::istringstream stream(std::string(pos, pEnd));
CStdDeserializer deserializer(m_ScriptInterface, stream);
CStdDeserializer deserializer(*m_ScriptInterface, stream);
deserializer.NumberU32_Unbounded("client", m_Client);
deserializer.NumberI32_Unbounded("player", m_Player);
deserializer.NumberU32_Unbounded("turn", m_Turn);
@@ -138,7 +138,7 @@ size_t CSimulationMessage::GetSerializedLength() const
// TODO: serializing twice is stupidly inefficient - we should just
// do it once, store the result, and use it here and in Serialize
CLengthBinarySerializer serializer(m_ScriptInterface);
CLengthBinarySerializer serializer(*m_ScriptInterface);
serializer.NumberU32_Unbounded("client", m_Client);
serializer.NumberI32_Unbounded("player", m_Player);
serializer.NumberU32_Unbounded("turn", m_Turn);
@@ -148,7 +148,7 @@ size_t CSimulationMessage::GetSerializedLength() const
CStr CSimulationMessage::ToString() const
{
std::string source = utf8_from_wstring(m_ScriptInterface.ToString(m_Data.get()));
std::string source = utf8_from_wstring(m_ScriptInterface->ToString(m_Data.get()));
std::stringstream stream;
stream << "CSimulationMessage { m_Client: " << m_Client << ", m_Player: " << m_Player << ", m_Turn: " << m_Turn << ", m_Data: " << source << " }";