CBaddy::CleanUpAIProcList

This commit is contained in:
krystalgamer 2024-07-01 18:17:13 +01:00
parent 43dd67c57c
commit ab8e9acfa1
4 changed files with 34 additions and 42 deletions

34
ai.cpp
View File

@ -35,11 +35,11 @@ void __inline CAIProc::AttachProc(AIProcType a2, CBaddy* a3, int a4)
{
this->pBaddy = a3;
this->field_1C = reinterpret_cast<CAIProc*>(a3->field_28C);
if (this->field_1C)
this->field_1C->field_18 = this;
this->mNext = a3->mAIProcList;
if (this->mNext)
this->mNext->field_18 = this;
a3->field_28C = reinterpret_cast<unsigned int*>(this);
a3->mAIProcList = this;
if (!(a2 & 0x40000))
a3->MarkAIProcList(0, a2 & 0xFF00, 0);
@ -104,8 +104,8 @@ void CAIProc_LookAt::Execute(void)
{
if (this->Wait())
{
if (this->field_1C)
this->field_1C->Execute();
if (this->mNext)
this->mNext->Execute();
}
else
{
@ -152,8 +152,8 @@ void CAIProc_Fall::Execute(void)
this->field_10 |= 1;
}
if (this->field_1C)
this->field_1C->Execute();
if (this->mNext)
this->mNext->Execute();
}
// @Ok
@ -174,8 +174,8 @@ void CAIProc_StateSwitchSendMessage::Execute(void)
this->field_10 |= 1;
}
if (this->field_1C)
this->field_1C->Execute();
if (this->mNext)
this->mNext->Execute();
}
// @Ok
@ -225,8 +225,8 @@ void CAIProc_MonitorAttack::Execute(void)
}
if (this->field_1C)
this->field_1C->Execute();
if (this->mNext)
this->mNext->Execute();
}
// @Ok
@ -308,8 +308,8 @@ void CAIProc_AccZ::Execute(void)
}
}
if (this->field_1C)
this->field_1C->Execute();
if (this->mNext)
this->mNext->Execute();
}
// @Ok
@ -432,8 +432,8 @@ void CAIProc_MoveTo::Execute(void)
}
}
if (this->field_1C)
this->field_1C->Execute();
if (this->mNext)
this->mNext->Execute();
}
void validate_CAIProc(void)
@ -447,7 +447,7 @@ void validate_CAIProc(void)
VALIDATE(CAIProc, field_14, 0x14);
VALIDATE(CAIProc, field_18, 0x18);
VALIDATE(CAIProc, field_1C, 0x1C);
VALIDATE(CAIProc, mNext, 0x1C);
}
void validate_CAIProc_LookAt(void)

2
ai.h
View File

@ -50,7 +50,7 @@ class CAIProc : public CClass
int field_14;
CAIProc* field_18;
CAIProc* field_1C;
CAIProc* mNext;
};
class CAIProc_LookAt : public CAIProc

View File

@ -6,6 +6,7 @@
#include "web.h"
#include <cmath>
#include "trig.h"
#include "ai.h"
// @TODO
i32 CBaddy::GetNextWaypoint(void)
@ -442,29 +443,19 @@ int CBaddy::Die(int a2)
return 0;
}
// @NotOk
// Calling a vfunc with fastcall, basically matching but polluting edx
void CBaddy::CleanUpAIPRocList(int a2)
// @Ok
INLINE void CBaddy::CleanUpAIProcList(i32 a2)
{
int v2 = reinterpret_cast<int>(this->field_28C);
int v3;
while (v2)
CAIProc *pProc = this->mAIProcList;
while (pProc)
{
v3 = v2;
v2 = *reinterpret_cast<int*>(v2 + 28);
if (a2 || (*reinterpret_cast<unsigned char*>(v3 + 16) & 1))
CAIProc *curProc = pProc;
pProc = pProc->mNext;
if (
a2
|| curProc->field_10 & 1)
{
if (v3)
{
typedef void (FASTCALL *wtvHappeningPtr)(void*, void*, int);
wtvHappeningPtr wtvHappening = reinterpret_cast<wtvHappeningPtr>(**reinterpret_cast<int**>(v3));
wtvHappening(reinterpret_cast<void*>(v3), NULL, 1);
}
delete curProc;
}
}
}
@ -764,7 +755,7 @@ CBaddy* FindBaddyOfType(int type)
// @Ok
void CBaddy::MarkAIProcList(int a2, int a3, int a4)
{
unsigned int *head = this->field_28C;
unsigned int *head = reinterpret_cast<u32*>(this->mAIProcList);
while (head)
{
unsigned int *v5 = head;
@ -833,7 +824,7 @@ void validate_CBaddy(void){
VALIDATE(CBaddy, field_288, 0x288);
VALIDATE(CBaddy, field_28C, 0x28C);
VALIDATE(CBaddy, mAIProcList, 0x28C);
VALIDATE(CBaddy, pMessage, 0x290);
VALIDATE(CBaddy, field_294, 0x294);

View File

@ -14,6 +14,7 @@ union IntToBytes
};
class CMessage;
class CAIProc;
class CBaddy : public CSuper {
public:
@ -35,7 +36,7 @@ public:
EXPORT int SetHeight(int, int, int);
EXPORT void SendDeathPulse(void);
EXPORT int Die(int);
EXPORT void CleanUpAIPRocList(int);
EXPORT void CleanUpAIProcList(i32);
EXPORT int BumpedIntoSpidey(int);
EXPORT int ShouldFall(int, int);
EXPORT int CheckSightCone(int, int, int, int, CBody*);
@ -115,7 +116,7 @@ public:
int field_288;
unsigned int *field_28C;
CAIProc *mAIProcList;
CMessage* pMessage;
IntToBytes field_294;