Changeset View
Changeset View
Standalone View
Standalone View
source/network/NetMessage.h
/* Copyright (C) 2017 Wildfire Games. | /* Copyright (C) 2022 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Special message type for simulation commands. | * Special message type for simulation commands. | ||||
* These commands are exposed as arbitrary JS objects, associated with a specific player. | * These commands are exposed as arbitrary JS objects, associated with a specific player. | ||||
*/ | */ | ||||
class CSimulationMessage : public CNetMessage | class CSimulationMessage : public CNetMessage | ||||
{ | { | ||||
public: | public: | ||||
CSimulationMessage(const ScriptInterface& scriptInterface); | CSimulationMessage(const ScriptInterface& scriptInterface); | ||||
CSimulationMessage(const ScriptInterface& scriptInterface, u32 client, i32 player, u32 turn, JS::HandleValue data); | CSimulationMessage(const ScriptInterface& scriptInterface, u32 clientId, i32 player, u32 turn, JS::HandleValue data); | ||||
/** The compiler can't create a copy constructor because of the PersistentRooted member, | /** The compiler can't create a copy constructor because of the PersistentRooted member, | ||||
* so we have to write it manually. | * so we have to write it manually. | ||||
* NOTE: It doesn't clone the m_Data member and the copy will reference the same JS::Value! | * NOTE: It doesn't clone the m_Data member and the copy will reference the same JS::Value! | ||||
*/ | */ | ||||
CSimulationMessage(const CSimulationMessage& orig); | CSimulationMessage(const CSimulationMessage& orig); | ||||
virtual u8* Serialize(u8* pBuffer) const; | virtual u8* Serialize(u8* pBuffer) const; | ||||
virtual const u8* Deserialize(const u8* pStart, const u8* pEnd); | virtual const u8* Deserialize(const u8* pStart, const u8* pEnd); | ||||
virtual size_t GetSerializedLength() const; | virtual size_t GetSerializedLength() const; | ||||
virtual CStr ToString() const; | virtual CStr ToString() const; | ||||
u32 m_Client; | u32 m_ClientId; | ||||
i32 m_Player; | i32 m_Player; | ||||
u32 m_Turn; | u32 m_Turn; | ||||
JS::PersistentRooted<JS::Value> m_Data; | JS::PersistentRooted<JS::Value> m_Data; | ||||
private: | private: | ||||
const ScriptInterface& m_ScriptInterface; | const ScriptInterface& m_ScriptInterface; | ||||
}; | }; | ||||
/** | /** | ||||
Show All 22 Lines |
Wildfire Games · Phabricator