Skip to content
Open

FOW #33

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<ClCompile Include="src\Commands\Commands.cpp" />
<ClCompile Include="src\Commands\Dummy.h" />
<ClCompile Include="src\Ext\AnimType\Hooks.cpp" />
<ClCompile Include="src\Ext\Cell\Body.cpp" />
<ClCompile Include="src\Ext\Scenario\Hooks.Variables.cpp" />
<ClCompile Include="src\Ext\Sidebar\Body.cpp" />
<ClCompile Include="src\Ext\Sidebar\Hooks.cpp" />
Expand All @@ -34,9 +35,12 @@
<ClCompile Include="src\Ext\TEvent\Body.cpp" />
<ClCompile Include="src\Ext\Trigger\Hooks.cpp" />
<ClCompile Include="src\Misc\CaptureManager.cpp" />
<ClCompile Include="src\Misc\FogOfWar.cpp" />
<ClCompile Include="src\Misc\Hooks.Image.cpp" />
<ClCompile Include="src\Misc\MapRevealer.cpp" />
<ClCompile Include="src\Misc\PhobosToolTip.cpp" />
<ClCompile Include="src\Misc\TextInput.cpp" />
<ClCompile Include="src\New\Entity\FoggedObject.cpp" />
<ClCompile Include="src\New\Entity\ShieldClass.cpp" />
<ClCompile Include="src\Misc\RetryDialog.cpp" />
<ClCompile Include="src\New\Type\RadTypeClass.cpp" />
Expand Down Expand Up @@ -111,13 +115,16 @@
<ClInclude Include="src\Commands\ObjectInfo.h" />
<ClInclude Include="src\Commands\Commands.h" />
<ClInclude Include="src\Commands\QuickSave.h" />
<ClInclude Include="src\Ext\Cell\Body.h" />
<ClInclude Include="src\Ext\Sidebar\Body.h" />
<ClInclude Include="src\Ext\Anim\Body.h" />
<ClInclude Include="src\Ext\TAction\Body.h" />
<ClInclude Include="src\Ext\Team\Body.h" />
<ClInclude Include="src\Ext\TEvent\Body.h" />
<ClInclude Include="src\Misc\CaptureManager.h" />
<ClInclude Include="src\Misc\MapRevealer.h" />
<ClInclude Include="src\Misc\PhobosToolTip.h" />
<ClInclude Include="src\New\Entity\FoggedObject.h" />
<ClInclude Include="src\New\Entity\ShieldClass.h" />
<ClInclude Include="src\New\Type\RadTypeClass.h" />
<ClInclude Include="src\New\Type\ShieldTypeClass.h" />
Expand Down
81 changes: 81 additions & 0 deletions src/Ext/Cell/Body.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#include "Body.h"

template<> const DWORD Extension<CellClass>::Canary = 0xFDC49191;
CellExt::ExtContainer CellExt::ExtMap;

// =============================
// load / save

template <typename T>
void CellExt::ExtData::Serialize(T& Stm)
{
Stm
.Process(this->FoggedObjects)
;
}

void CellExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)
{
Extension<CellClass>::LoadFromStream(Stm);
this->Serialize(Stm);
}

void CellExt::ExtData::SaveToStream(PhobosStreamWriter& Stm)
{
Extension<CellClass>::SaveToStream(Stm);
this->Serialize(Stm);
}


// =============================
// container

CellExt::ExtContainer::ExtContainer() : Container("CellClass")
{
}

CellExt::ExtContainer::~ExtContainer() = default;

// =============================
// container hooks

DEFINE_HOOK(0x47BBF0, CellClass_CTOR, 0x6)
{
GET(CellClass*, pItem, ECX);

CellExt::ExtMap.FindOrAllocate(pItem);

return 0;
}

DEFINE_HOOK(0x47BB60, CellClass_DTOR, 0x6)
{
GET(CellClass*, pItem, ECX);

CellExt::ExtMap.Remove(pItem);

return 0;
}

DEFINE_HOOK_AGAIN(0x483C10, CellClass_SaveLoad_Prefix, 0x5)
DEFINE_HOOK(0x4839F0, CellClass_SaveLoad_Prefix, 0x7)
{
GET_STACK(CellClass*, pItem, 0x4);
GET_STACK(IStream*, pStm, 0x8);

CellExt::ExtMap.PrepareStream(pItem, pStm);

return 0;
}

DEFINE_HOOK(0x483C00, CellClass_Load_Suffix, 5)
{
CellExt::ExtMap.LoadStatic();
return 0;
}

DEFINE_HOOK(0x483C79, CellClass_Save_Suffix, 0x6)
{
CellExt::ExtMap.SaveStatic();
return 0;
}
49 changes: 49 additions & 0 deletions src/Ext/Cell/Body.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#pragma once
#include <CellClass.h>

#include <Helpers/Macro.h>

#include <Utilities/Container.h>
#include <Utilities/TemplateDef.h>

#include <New/Entity/FoggedObject.h>

class FoggedObject;

class CellExt
{
public:
using base_type = CellClass;

class ExtData final : public Extension<CellClass>
{
public:
DynamicVectorClass<FoggedObject*> FoggedObjects;

ExtData(CellClass* OwnerObject) : Extension<CellClass>(OwnerObject),
FoggedObjects {}
{ }

virtual ~ExtData() = default;

// virtual void LoadFromINIFile(CCINIClass * pINI) override;

virtual void InvalidatePointer(void* ptr, bool bRemoved) override { }

virtual void LoadFromStream(PhobosStreamReader& Stm) override;

virtual void SaveToStream(PhobosStreamWriter& Stm) override;
private:
template <typename T>
void Serialize(T& Stm);
};

class ExtContainer final : public Container<CellExt>
{
public:
ExtContainer();
~ExtContainer();
};

static ExtContainer ExtMap;
};
Loading