-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new tag [WeaponType]->DiskLaser.Radius= (double)
- Loading branch information
1 parent
66e6fbd
commit 9eb1aa3
Showing
6 changed files
with
197 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#include "Body.h" | ||
|
||
template<> const DWORD Extension<WeaponTypeClass>::Canary = 0x22222222; | ||
WeaponTypeExt::ExtContainer WeaponTypeExt::ExtMap; | ||
|
||
// ============================= | ||
// load / save | ||
|
||
void WeaponTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI) { | ||
auto pThis = this->OwnerObject(); | ||
const char* pSection = pThis->ID; | ||
|
||
if (!pINI->GetSection(pSection)) { | ||
return; | ||
} | ||
|
||
this->DiskLaser_Radius = pINI->ReadDouble(pSection, "DiskLaser.Radius", this->DiskLaser_Radius); | ||
this->DiskLaser_Circumference = (int)(this->DiskLaser_Radius * Math::Pi * 2); | ||
} | ||
|
||
void WeaponTypeExt::ExtData::LoadFromStream(IStream* Stm) { | ||
#define STM_Process(A) Stm->Read(&A, sizeof(A), 0); | ||
#include "Serialize.hpp" | ||
#undef STM_Process | ||
} | ||
|
||
void WeaponTypeExt::ExtData::SaveToStream(IStream* Stm) { | ||
#define STM_Process(A) Stm->Write(&A, sizeof(A), 0); | ||
#include "Serialize.hpp" | ||
#undef STM_Process | ||
} | ||
|
||
// ============================= | ||
// container | ||
|
||
WeaponTypeExt::ExtContainer::ExtContainer() : Container("WeaponTypeClass") { | ||
} | ||
|
||
WeaponTypeExt::ExtContainer::~ExtContainer() = default; | ||
|
||
// ============================= | ||
// container hooks | ||
|
||
DEFINE_HOOK(771EE9, WeaponTypeClass_CTOR, 5) | ||
{ | ||
GET(WeaponTypeClass*, pItem, ESI); | ||
|
||
WeaponTypeExt::ExtMap.FindOrAllocate(pItem); | ||
return 0; | ||
} | ||
|
||
DEFINE_HOOK(77311D, WeaponTypeClass_SDDTOR, 6) | ||
{ | ||
GET(WeaponTypeClass*, pItem, ESI); | ||
|
||
WeaponTypeExt::ExtMap.Remove(pItem); | ||
return 0; | ||
} | ||
|
||
DEFINE_HOOK_AGAIN(772EB0, WeaponTypeClass_SaveLoad_Prefix, 5) | ||
DEFINE_HOOK(772CD0, WeaponTypeClass_SaveLoad_Prefix, 7) | ||
{ | ||
GET_STACK(WeaponTypeClass*, pItem, 0x4); | ||
GET_STACK(IStream*, pStm, 0x8); | ||
|
||
WeaponTypeExt::ExtMap.PrepareStream(pItem, pStm); | ||
|
||
return 0; | ||
} | ||
|
||
DEFINE_HOOK(772EA6, WeaponTypeClass_Load_Suffix, 6) | ||
{ | ||
auto pItem = WeaponTypeExt::ExtMap.Find(WeaponTypeExt::ExtMap.SavingObject); | ||
IStream* pStm = WeaponTypeExt::ExtMap.SavingStream; | ||
|
||
pItem->LoadFromStream(pStm); | ||
return 0; | ||
} | ||
|
||
DEFINE_HOOK(772F8C, WeaponTypeClass_Save, 5) | ||
{ | ||
auto pItem = WeaponTypeExt::ExtMap.Find(WeaponTypeExt::ExtMap.SavingObject); | ||
IStream* pStm = WeaponTypeExt::ExtMap.SavingStream; | ||
|
||
pItem->SaveToStream(pStm); | ||
return 0; | ||
} | ||
|
||
DEFINE_HOOK_AGAIN(7729C7, WeaponTypeClass_LoadFromINI, 5) | ||
DEFINE_HOOK_AGAIN(7729D6, WeaponTypeClass_LoadFromINI, 5) | ||
DEFINE_HOOK(7729B0, WeaponTypeClass_LoadFromINI, 5) | ||
{ | ||
GET(WeaponTypeClass*, pItem, ESI); | ||
GET_STACK(CCINIClass*, pINI, 0xE4); | ||
|
||
WeaponTypeExt::ExtMap.LoadFromINI(pItem, pINI); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
|
||
#include <CCINIClass.h> | ||
#include <WeaponTypeClass.h> | ||
|
||
#include "../_Container.hpp" | ||
#include "../../Phobos.h" | ||
|
||
#include "../../Utilities/Debug.h" | ||
|
||
class WeaponTypeExt | ||
{ | ||
public: | ||
using base_type = WeaponTypeClass; | ||
|
||
class ExtData final : public Extension<WeaponTypeClass> | ||
{ | ||
public: | ||
|
||
double DiskLaser_Radius; | ||
int DiskLaser_Circumference; | ||
|
||
ExtData(WeaponTypeClass* OwnerObject) : Extension<WeaponTypeClass>(OwnerObject), | ||
DiskLaser_Radius(38.2), | ||
DiskLaser_Circumference(240) | ||
{ } | ||
|
||
virtual void LoadFromINIFile(CCINIClass* pINI) override; | ||
virtual ~ExtData() = default; | ||
|
||
virtual void InvalidatePointer(void* ptr, bool bRemoved) override {} | ||
|
||
virtual void LoadFromStream(IStream* Stm); | ||
|
||
virtual void SaveToStream(IStream* Stm); | ||
}; | ||
|
||
class ExtContainer final : public Container<WeaponTypeExt> { | ||
public: | ||
ExtContainer(); | ||
~ExtContainer(); | ||
}; | ||
|
||
static ExtContainer ExtMap; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "Body.h" | ||
|
||
int old_Circumference = 240; | ||
DEFINE_HOOK(4A757B, DiskLaser_Circle, 6) | ||
{ | ||
GET(WeaponTypeClass*, pWeapon, EDX); | ||
int new_Circumference = WeaponTypeExt::ExtMap.Find(pWeapon)->DiskLaser_Circumference; | ||
|
||
if (old_Circumference != new_Circumference) { | ||
old_Circumference = new_Circumference; | ||
|
||
Point2D* DiscLaserCoords = reinterpret_cast<Point2D*>(0x8A0180); | ||
DiscLaserCoords[0].X = 0; | ||
DiscLaserCoords[0].Y = -1 * new_Circumference; | ||
DiscLaserCoords[1].X = (int)(0.3746065934159128 * new_Circumference); | ||
DiscLaserCoords[1].Y = (int)(-0.9271838545667871 * new_Circumference); | ||
DiscLaserCoords[2].X = (int)(0.707106781186548 * new_Circumference); | ||
DiscLaserCoords[2].Y = -1 * DiscLaserCoords[2].X; | ||
DiscLaserCoords[3].X = (int)(0.9205048534524406 * new_Circumference); | ||
DiscLaserCoords[3].Y = (int)(-0.39073112848927305 * new_Circumference); | ||
DiscLaserCoords[4].X = new_Circumference; | ||
DiscLaserCoords[4].Y = 0; | ||
DiscLaserCoords[5].X = -1 * DiscLaserCoords[1].Y; | ||
DiscLaserCoords[5].Y = DiscLaserCoords[1].X; | ||
DiscLaserCoords[6].X = DiscLaserCoords[2].X; | ||
DiscLaserCoords[6].Y = DiscLaserCoords[2].X; | ||
DiscLaserCoords[7].X = -1 * DiscLaserCoords[3].Y; | ||
DiscLaserCoords[7].Y = DiscLaserCoords[3].X; | ||
DiscLaserCoords[8].X = 0; | ||
DiscLaserCoords[8].Y = DiscLaserCoords[4].X; | ||
DiscLaserCoords[9].X = -1 * DiscLaserCoords[1].X; | ||
DiscLaserCoords[9].Y = DiscLaserCoords[5].X; | ||
DiscLaserCoords[10].X = DiscLaserCoords[2].Y; | ||
DiscLaserCoords[10].Y = DiscLaserCoords[6].Y; | ||
DiscLaserCoords[11].X = -1 * DiscLaserCoords[3].X; | ||
DiscLaserCoords[11].Y = DiscLaserCoords[7].X; | ||
DiscLaserCoords[12].X = DiscLaserCoords[0].Y; | ||
DiscLaserCoords[12].Y = 0; | ||
DiscLaserCoords[13].X = DiscLaserCoords[1].Y; | ||
DiscLaserCoords[13].Y = DiscLaserCoords[9].X; | ||
DiscLaserCoords[14].X = (int)(-0.5735764363510456 * new_Circumference); | ||
DiscLaserCoords[14].Y = (int)(-0.8191520442889921 * new_Circumference); | ||
DiscLaserCoords[15].Y = (int)(-0.9743700647852354 * new_Circumference); | ||
DiscLaserCoords[15].X = (int)(-0.2249510543438644 * new_Circumference); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
STM_Process(this->DiskLaser_Radius) | ||
STM_Process(this->DiskLaser_Circumference) |