-
-
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.
- Loading branch information
Showing
2 changed files
with
147 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
#include "Body.h" | ||
#include <Helpers/Macro.h> | ||
#include <EventClass.h> | ||
bool EventExt::AddEvent() | ||
{ | ||
return EventClass::AddEvent(*reinterpret_cast<EventClass*>(this)); | ||
} | ||
void EventExt::RespondEvent() | ||
{ | ||
switch (this->Type) | ||
{ | ||
case EventTypeExt::Sample: | ||
// Place the handler here | ||
break; | ||
} | ||
} | ||
size_t EventExt::GetDataSize(EventTypeExt type) | ||
{ | ||
switch (type) | ||
{ | ||
case EventTypeExt::Sample: | ||
return sizeof(EventExt::Sample); | ||
} | ||
return 0; | ||
} | ||
bool EventExt::IsValidType(EventTypeExt type) | ||
{ | ||
return (type >= EventTypeExt::FIRST && type <= EventTypeExt::LAST); | ||
} | ||
// hooks | ||
DEFINE_HOOK(0x4C6CC8, Networking_RespondToEvent, 0x5) | ||
{ | ||
GET(EventExt*, pEvent, ESI); | ||
if (EventExt::IsValidType(pEvent->Type)) | ||
{ | ||
pEvent->RespondEvent(); | ||
} | ||
return 0; | ||
} | ||
DEFINE_HOOK(0x64B6FE, sub_64B660_GetEventSize, 0x6) | ||
{ | ||
const auto eventType = static_cast<EventTypeExt>(R->EDI() & 0xFF); | ||
if (EventExt::IsValidType(eventType)) | ||
{ | ||
const size_t eventSize = EventExt::GetDataSize(eventType); | ||
R->EDX(eventSize); | ||
R->EBP(eventSize); | ||
return 0x64B71D; | ||
} | ||
return 0; | ||
} | ||
DEFINE_HOOK(0x64BE7D, sub_64BDD0_GetEventSize1, 0x6) | ||
{ | ||
const auto eventType = static_cast<EventTypeExt>(R->EDI() & 0xFF); | ||
if (EventExt::IsValidType(eventType)) | ||
{ | ||
const size_t eventSize = EventExt::GetDataSize(eventType); | ||
REF_STACK(size_t, eventSizeInStack, STACK_OFFSET(0xAC, -0x8C)); | ||
eventSizeInStack = eventSize; | ||
R->ECX(eventSize); | ||
R->EBP(eventSize); | ||
return 0x64BE97; | ||
} | ||
return 0; | ||
} | ||
DEFINE_HOOK(0x64C30E, sub_64BDD0_GetEventSize2, 0x6) | ||
{ | ||
const auto eventType = static_cast<EventTypeExt>(R->ESI() & 0xFF); | ||
if (EventExt::IsValidType(eventType)) | ||
{ | ||
const size_t eventSize = EventExt::GetDataSize(eventType); | ||
R->ECX(eventSize); | ||
R->EBP(eventSize); | ||
return 0x64C321; | ||
} | ||
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,46 @@ | ||
#pragma once | ||
/* | ||
#include <cstddef> | ||
#include <stdint.h> | ||
enum class EventTypeExt : uint8_t | ||
{ | ||
// Vanilla game used Events from 0x00 to 0x2F | ||
// CnCNet reserved Events from 0x30 to 0x3F | ||
// Ares used Events 0x60 and 0x61 | ||
Sample = 0x40, // Sample event, remove it when Phobos needs its own events | ||
FIRST = Sample, | ||
LAST = Sample | ||
}; | ||
#pragma pack(push, 1) | ||
class EventExt | ||
{ | ||
public: | ||
EventTypeExt Type; | ||
bool IsExecuted; | ||
char HouseIndex; | ||
uint32_t Frame; | ||
union | ||
{ | ||
char DataBuffer[104]; | ||
struct Sample | ||
{ | ||
char DataBuffer[104]; | ||
} Sample; | ||
}; | ||
bool AddEvent(); | ||
void RespondEvent(); | ||
static size_t GetDataSize(EventTypeExt type); | ||
static bool IsValidType(EventTypeExt type); | ||
}; | ||
static_assert(sizeof(EventExt) == 111); | ||
static_assert(offsetof(EventExt, DataBuffer) == 7); | ||
#pragma pack(pop) | ||
*/ |