SendKilLFromNode

Moved globals to proper places
This commit is contained in:
krystalgamer 2024-07-18 18:46:12 +02:00
parent 62179b7336
commit 0e5e461af4
12 changed files with 125 additions and 27 deletions

View File

@ -8,9 +8,10 @@
#include "trig.h"
#include "ai.h"
CBaddy* ControlBaddyList;
EXPORT CBaddy* ControlBaddyList;
EXPORT CBaddy* BaddyList;
extern i16** gTrigNodes;
extern u16** gTrigNodes;
// @NotOk
// check when pathcheck is done <3
@ -814,8 +815,6 @@ void CBaddy::UnknownCBaddyFunctionFive(int)
{
}
extern CBaddy* BaddyList;
// @Ok
CBaddy* CBaddy::GetClosest(i32 baddyType, i32 inSight)
{

View File

@ -10,7 +10,8 @@
volatile static int BitCount = 0;
static int TotalBitUsage = 0;
CFlatBit *FlatBitList;
EXPORT CFlatBit *FlatBitList;
EXPORT CSpecialDisplay *SpecialDisplayList;
// @Ok
CFlatBit::~CFlatBit(void)
@ -637,6 +638,7 @@ void validate_CBit(void)
VALIDATE(CBit, mDead, 0x37);
VALIDATE(CBit, mFrigDeltaZ, 0x38);
VALIDATE(CBit, mProtected, 0x3A);
VALIDATE(CBit, mType, 0x3B);
}
void validate_CSmokeTrail(void)
@ -707,3 +709,8 @@ void validate_CMotionBlur(void)
{
VALIDATE_SIZE(CMotionBlur, 0x68);
}
void validate_CSpecialDisplay(void)
{
VALIDATE_SIZE(CSpecialDisplay, 0x3C);
}

15
bit.h
View File

@ -22,7 +22,7 @@ class CBit
unsigned char mDead;
unsigned __int16 mFrigDeltaZ;
unsigned char mProtected;
unsigned char bitBottomPad;
u8 mType;
EXPORT CBit();
EXPORT virtual ~CBit();
@ -145,10 +145,9 @@ class CSimpleTexturedRibbon : public CSpecialDisplay
public:
EXPORT void SetRGB(unsigned char, unsigned char, unsigned char);
unsigned __int16 field_3C;
unsigned char padAfter3C[0x48-0x3C-2];
int* field_48;
u16 field_3C;
u8 padAfter3C[0x48-0x3C-2];
i32* field_48;
};
class CGlow : public CBit
@ -190,9 +189,8 @@ class CTexturedRibbon : public CSpecialDisplay
{
public:
EXPORT void SetOuterRGBi(int, unsigned char, unsigned char, unsigned char);
unsigned char topPad[0x60-0x3C];
int* field_60;
u8 topPad[0x60-0x3C];
i32* field_60;
};
class CSimpleAnim : public CFlatBit
@ -229,5 +227,6 @@ void validate_CSimpleTexturedRibbon(void);
void validate_CSimpleAnim(void);
void validate_SCFT4BitTexture(void);
void validate_CMotionBlur(void);
void validate_CSpecialDisplay(void);
#endif

View File

@ -2,6 +2,11 @@
#include "validate.h"
void Exp_HitEnvItem(CItem* pItem, u32* pFace, i32 Damage)
{
printf("Exp_HitEnvItem");
}
void validate_CItemFrag(void)
{

1
exp.h
View File

@ -11,6 +11,7 @@ class CItemFrag : public CBit
unsigned char itemFragPad[0x7C];
};
EXPORT void Exp_HitEnvItem(CItem*, u32*, i32);
void validate_CItemFrag(void);
#endif

View File

@ -338,6 +338,7 @@ int main()
validate_SHitInfo();
validate_SCommandPoint();
validate_PendingListEntry();
validate_CSpecialDisplay();
puts("[*] Validation done!");

1
ob.cpp
View File

@ -9,6 +9,7 @@
const char *gObjFile;
CBody* EnvironmentalObjectList;
CBody* PowerUpList;
// @Ok
CBody* CBody::FindBodyByNode(

View File

@ -8,7 +8,8 @@
#include "reloc.h"
#include "spidey.h"
CPlayer* MechList;
extern CPlayer* MechList;
extern CBaddy* BaddyList;
// @Ok
i32 CScorpion::ScorpPathCheck(
@ -184,7 +185,6 @@ void Scorpion_GetCurrentTarget(unsigned int* pScorp, unsigned int* pTarget)
*pTarget = reinterpret_cast<unsigned int>((*reinterpret_cast<CScorpion**>(pScorp))->GetCurrentTarget());
}
CBaddy* BaddyList;
// @NotOk
// globals

View File

@ -15,6 +15,8 @@
#include "m3dzone.h"
#include "ps2lowsfx.h"
EXPORT CPlayer* MechList;
// @SMALLTODO
void CPlayer::SetStartOrientation(CSVector*)
{

105
trig.cpp
View File

@ -4,9 +4,11 @@
#include "utils.h"
#include "spidey.h"
#include "baddy.h"
#include "spool.h"
#include "exp.h"
EXPORT void* gTrigFile;
EXPORT i16 **gTrigNodes;
EXPORT u16 **gTrigNodes;
EXPORT i32 NumNodes;
const i32 MAXPENDING = 16;
@ -19,6 +21,7 @@ EXPORT i32 Restart;
EXPORT i32 RestartNode;
EXPORT i32 gReStartDeathRelated;
EXPORT i32 EndLevelNode;
extern CSpecialDisplay *SpecialDisplayList;
extern i32 JoelJewCheatCode;
@ -26,6 +29,7 @@ extern CPlayer* MechList;
extern CBaddy* ControlBaddyList;
extern CBaddy* BaddyList;
extern CBody* EnvironmentalObjectList;
extern CBody* PowerUpList;
//@IGNORE
void trigLog(const char*, ...)
@ -33,6 +37,84 @@ void trigLog(const char*, ...)
printf("trigLog!");
}
// @NotOk
// SpecialDisplayList shitty ass polymorphism
// need to understand what's type 9
void SendKillFromNode(i32 Node, i32 How)
{
print_if_false(Node >= 0 && Node < NumNodes, "Bad node sent to SendKillFromNode");
u16 *pLinkInfo = Trig_GetLinksPointer(Node);
u16 NumLinks = *pLinkInfo;
u16* nodeIndexPtr = pLinkInfo + 1;
for (i32 i = 0; i < NumLinks; i++)
{
u16 nodeIndex = nodeIndexPtr[i];
u16 *node = gTrigNodes[nodeIndex];
switch (*node)
{
case 1:
if (node[1] == 409)
{
for (
CSpecialDisplay *cur = SpecialDisplayList;
cur;
cur = reinterpret_cast<CSpecialDisplay*>(cur->mNext))
{
if (cur->mType == 9)
{
if (*reinterpret_cast<u16*>(reinterpret_cast<u8*>(cur)+0x6A) == nodeIndex)
{
cur->Die();
}
}
}
}
else
{
KillInList(nodeIndex, BaddyList, How);
KillInList(nodeIndex, ControlBaddyList, How);
KillInList(nodeIndex, EnvironmentalObjectList, How);
}
break;
case 2:
case 9:
u32 v20;
CItem* EnviroItem;
v20 = reinterpret_cast<u32>(&node[node[1] + 1]);
if (v20 & 2)
v20 += 2;
EnviroItem = Spool_FindEnviroItem(v20);
if (EnviroItem)
{
if (How == 1)
{
Exp_HitEnvItem(EnviroItem, 0, 0xFFFF);
}
else
{
EnviroItem->mFlags |= 1;
}
}
break;
case 4:
case 20:
KillInList(nodeIndex, PowerUpList, How);
break;
default:
break;
}
}
}
// @Ok
void SendSuspendOrActivate(u16* pLinkInfo, i32 signalType)
{
@ -54,7 +136,7 @@ void SendSuspendOrActivate(u16* pLinkInfo, i32 signalType)
for (i32 i = 0; i < numIters; i++)
{
i16 *node = gTrigNodes[nodeIndexPtr[i]];
u16 *node = gTrigNodes[nodeIndexPtr[i]];
switch(*node)
{
@ -434,17 +516,18 @@ u16* Trig_GetPosition(CVector*, int)
}
// @Ok
u16* Trig_GetLinksPointer(int node)
INLINE u16* Trig_GetLinksPointer(int node)
{
print_if_false(node >= 0 && node < NumNodes, "Bad node sent to Trig_GetLinksPointer");
i16* trigNodePtr = reinterpret_cast<i16*>(gTrigNodes[node]);
u16* trigNodePtr = gTrigNodes[node];
i32 trigNodeValue = *reinterpret_cast<u16*>(trigNodePtr);
if (*trigNodePtr <= 0xD)
if (trigNodeValue <= 0xD)
{
if (*trigNodePtr < 0xC)
if (trigNodeValue < 0xC)
{
switch (*trigNodePtr)
switch (trigNodeValue)
{
case 1:
return reinterpret_cast<u16*>(trigNodePtr + 3);
@ -468,11 +551,11 @@ u16* Trig_GetLinksPointer(int node)
return reinterpret_cast<u16*>(trigNodePtr + 1);
}
}
else if (*trigNodePtr <= 0x3E9)
else if (trigNodeValue <= 0x3E9)
{
if (*trigNodePtr < 0x3E8)
if (trigNodeValue < 0x3E8)
{
if (*trigNodePtr != 0x14)
if (trigNodeValue != 0x14)
{
print_if_false(0, "Unrecognized node type in\n Trig_GetLinksPointer");
print_if_false(0, "Unrecognized node type in\n Trig_GetLinksPointer");
@ -484,7 +567,7 @@ u16* Trig_GetLinksPointer(int node)
return reinterpret_cast<u16*>(trigNodePtr + 1);
}
else if (*trigNodePtr != 0x3EA)
else if (trigNodeValue != 0x3EA)
{
print_if_false(0, "Unrecognized node type in\n Trig_GetLinksPointer");
print_if_false(0, "Unrecognized node type in\n Trig_GetLinksPointer");

1
trig.h
View File

@ -73,6 +73,7 @@ EXPORT void SendSuspend(CBody**, i32);
EXPORT void SendSignalToNode(CBody*, i32);
EXPORT void SendUnSuspend(CBody*, i32);
EXPORT void SendSuspendOrActivate(u16*, i32);
EXPORT void SendKillFromNode(i32, i32);
void validate_SLinkInfo(void);
void validate_SCommandPoint(void);

View File

@ -117,7 +117,6 @@ void validate_CTrapWebEffect(void)
{
VALIDATE_SIZE(CTrapWebEffect, 0x430);
VALIDATE(CTrapWebEffect, bitBottomPad, 0x3B);
VALIDATE(CTrapWebEffect, field_3C, 0x3C);
VALIDATE(CTrapWebEffect, field_44, 0x44);
VALIDATE(CTrapWebEffect, field_418, 0x418);