From adda48a1bf56a0f3f8f8f18ca4fabca99b71d726 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 12 Apr 2016 01:01:24 -0700 Subject: [PATCH] Initial ScriptMailbox imps --- Runtime/CScriptMailbox.cpp | 34 +++++++++++++++++++++++++++++++++ Runtime/CScriptMailbox.hpp | 25 ++++++++++++++++++++++++ Runtime/ScriptObjectSupport.hpp | 1 + 3 files changed, 60 insertions(+) diff --git a/Runtime/CScriptMailbox.cpp b/Runtime/CScriptMailbox.cpp index 78e8c9493..2111f3e5a 100644 --- a/Runtime/CScriptMailbox.cpp +++ b/Runtime/CScriptMailbox.cpp @@ -1,6 +1,40 @@ #include "CScriptMailbox.hpp" +#include "CStateManager.hpp" namespace urde { +CScriptMailbox::CScriptMailbox(CBitStreamReader&) +{ +} + +void CScriptMailbox::AddMsg(TEditorId id, EScriptObjectMessage msg, bool flag) +{ + /* TODO: Verify this behavior */ + CMailMessage mail{id, msg, flag}; + auto it = std::find(x0_messages.begin(), x0_messages.end(), mail); + + if (it != x0_messages.end()) + *it = mail; + else + x0_messages.push_back(mail); +} + +void CScriptMailbox::RemoveMsg(TEditorId id, EScriptObjectMessage msg, bool flag) +{ + CMailMessage mail{id, msg, flag}; + auto it = std::find(x0_messages.begin(), x0_messages.end(), mail); + if (it != x0_messages.end()) + x0_messages.erase(it); +} + +void CScriptMailbox::SendMsgs(const TAreaId& areaId, CStateManager& stateMgr) +{ +} + +void CScriptMailbox::PutTo(CBitStreamWriter&) +{ + +} + } diff --git a/Runtime/CScriptMailbox.hpp b/Runtime/CScriptMailbox.hpp index b8eeb6c0e..04c485cb5 100644 --- a/Runtime/CScriptMailbox.hpp +++ b/Runtime/CScriptMailbox.hpp @@ -1,11 +1,36 @@ #ifndef __PSHAG_CSCRIPTMAILBOX_HPP__ #define __PSHAG_CSCRIPTMAILBOX_HPP__ +#include "IOStreams.hpp" +#include "ScriptObjectSupport.hpp" +#include "RetroTypes.hpp" + namespace urde { +class CStateManager; +struct CMailMessage +{ + TEditorId x0_id; + EScriptObjectMessage x4_msg; + bool x8_; + CMailMessage(TEditorId id, EScriptObjectMessage msg, bool flag) : x0_id(id), x4_msg(msg), x8_(flag) {} + CMailMessage(const CMailMessage& other) : x0_id(other.x0_id), x4_msg(other.x4_msg), x8_(other.x8_) {} + + bool operator==(const CMailMessage& other) const + { return (x0_id == other.x0_id && x4_msg == other.x4_msg); } +}; class CScriptMailbox { + rstl::reserved_vector x0_messages; +public: + CScriptMailbox() = default; + CScriptMailbox(CBitStreamReader&); + + void AddMsg(TEditorId, EScriptObjectMessage, bool); + void RemoveMsg(TEditorId, EScriptObjectMessage, bool); + void SendScriptMsgs(const TAreaId&, CStateManager&); + void PutTo(CBitStreamWriter&); }; } diff --git a/Runtime/ScriptObjectSupport.hpp b/Runtime/ScriptObjectSupport.hpp index e8c5107b3..9f8f8aee0 100644 --- a/Runtime/ScriptObjectSupport.hpp +++ b/Runtime/ScriptObjectSupport.hpp @@ -6,6 +6,7 @@ namespace urde enum class EScriptObjectState { + Any = -1, Active, Arrived, Closed,