Skip to content

Commit 910c13f

Browse files
committed
Merge remote-tracking branch 'origin/main' into work
2 parents 07d38ae + 22dc041 commit 910c13f

17 files changed

+334
-128
lines changed

.DS_Store

6 KB
Binary file not shown.

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build
22

33
on:
44
push:
5-
pull_request:
5+
pull_request_target:
66

77
jobs:
88
build:
@@ -144,7 +144,7 @@ jobs:
144144
needs:
145145
- build
146146
- build-previous
147-
if: github.ref == 'refs/heads/main'
147+
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && github.event_name != 'pull_request_target'
148148
steps:
149149
- name: Checkout website code
150150
uses: actions/checkout@v4

src/SB/Game/zEnt.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "iModel.h"
1414
#include "xSnd.h"
1515
#include "xCollide.h"
16+
#include "zNPCTypes.h"
1617
#include <cstring>
1718
#include <stdio.h>
1819

@@ -855,11 +856,11 @@ S32 zParamGetVector(xModelAssetParam* param, U32 size, char* tok, xVec3 vec1, xV
855856

856857
// clang-format off
857858
_ShadowParams gShadowParams[] = {
858-
{'NTR0', 0.33f, 2.0f},
859-
{'NTR3', 0.0f, 1.25f},
860-
{'NTFA', -0.25f, 0.75f},
861-
{'NTR5', 0.5f, 1.0f},
862-
{'NTB0', 1.0f, 2.0f},
859+
{NPC_TYPE_HAMMER, 0.33f, 2.0f},
860+
{NPC_TYPE_GLOVE, 0.0f, 1.25f},
861+
{NPC_TYPE_PLANKNPC, -0.25f, 0.75f},
862+
{NPC_TYPE_SLEEPY, 0.5f, 1.0f},
863+
{NPC_TYPE_BOSSSANDY, 1.0f, 2.0f},
863864
};
864865
// clang-format on
865866

src/SB/Game/zEntPlayer.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3686,9 +3686,9 @@ static void load_player_ini()
36863686
void zEntPlayer_RestoreSounds()
36873687
{
36883688
sPlayerIgnoreSound--;
3689-
if (sPlayerIgnoreSound < 0)
3690-
{
3691-
sPlayerIgnoreSound = 0;
3689+
if (sPlayerIgnoreSound < 0)
3690+
{
3691+
sPlayerIgnoreSound = 0;
36923692
}
36933693
}
36943694

@@ -3706,12 +3706,12 @@ void zEntPlayerUpdateModelSB();
37063706

37073707
void zEntPlayerUpdateModel()
37083708
{
3709-
zPlayerGlobals* pg = &globals.player;
3710-
3711-
if (pg->ent.model == pg->model_spongebob)
3712-
{
3713-
zEntPlayerUpdateModelSB();
3714-
}
3709+
zPlayerGlobals* pg = &globals.player;
3710+
3711+
if (pg->ent.model == pg->model_spongebob)
3712+
{
3713+
zEntPlayerUpdateModelSB();
3714+
}
37153715
}
37163716

37173717
S32 zEntPlayer_Damage(xBase* src, U32 damage, const xVec3* knockback)

src/SB/Game/zNPCGoalRobo.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,22 +1257,20 @@ S32 zNPCGoalAttackTarTar::Enter(F32 dt, void* updCtxt)
12571257

12581258
S32 zNPCGoalAttackChomper::Enter(F32 dt, void* updCtxt)
12591259
{
1260-
zNPCCommon* com = ((zNPCCommon*)(psyche->clt_owner));
1261-
com->VelStop();
1262-
com->SndPlayRandom(NPC_STYP_ATTACK);
1260+
zNPCCommon* npc = ((zNPCCommon*)(psyche->clt_owner));
1261+
npc->VelStop();
1262+
npc->SndPlayRandom(NPC_STYP_ATTACK);
12631263

12641264
return zNPCGoalPushAnim::Enter(dt, updCtxt);
12651265
}
12661266

12671267
S32 zNPCGoalEvilPat::Enter(F32 dt, void* updCtxt)
12681268
{
1269-
zNPCCommon* com = ((zNPCCommon*)(psyche->clt_owner));
1270-
1271-
S32 typ = com->SelfType();
1269+
zNPCCommon* npc = ((zNPCCommon*)(psyche->clt_owner));
12721270

1273-
if ((typ - 'NT\0\0') == 'R3')
1271+
if (npc->SelfType() == NPC_TYPE_GLOVE)
12741272
{
1275-
com->flg_vuln |= 0x80000000;
1273+
npc->flg_vuln |= 0x80000000;
12761274
}
12771275

12781276
GlyphStart();
@@ -1282,16 +1280,14 @@ S32 zNPCGoalEvilPat::Enter(F32 dt, void* updCtxt)
12821280

12831281
S32 zNPCGoalEvilPat::Exit(F32 dt, void* updCtxt)
12841282
{
1285-
zNPCCommon* com = ((zNPCCommon*)(psyche->clt_owner));
1286-
1287-
S32 typ = com->SelfType();
1283+
zNPCCommon* npc = ((zNPCCommon*)(psyche->clt_owner));
12881284

1289-
if ((typ - 'NT\0\0') == 'R3')
1285+
if (npc->SelfType() == NPC_TYPE_GLOVE)
12901286
{
1291-
com->flg_vuln &= 0x7FFFFFFF;
1287+
npc->flg_vuln &= 0x7FFFFFFF;
12921288
}
12931289

1294-
*(F32*)(&com->snd_queue[6].flg_snd) = -1.0f;
1290+
*(F32*)(&npc->snd_queue[6].flg_snd) = -1.0f;
12951291

12961292
GlyphStop();
12971293

src/SB/Game/zNPCMessenger.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,26 @@ void zNPCMsg_Startup();
1010
void zNPCMsg_Shutdown();
1111
void zNPCMsg_AreaNotify(zNPCCommon* sender, en_NPC_MSG_ID msgid, F32 rad, S32 filter,
1212
en_NPCTYPES toNPCType);
13+
void zNPCMsg_Timestep(xScene* xscn, F32 dt);
1314

14-
struct NPCPSClt {
15+
struct NPCPSClt
16+
{
1517
// total size: 0x10
16-
void (* notify)(void *, class NPCMsg *); // offset 0x0, size 0x4
17-
void * notedata; // offset 0x4, size 0x4
18+
void (*notify)(void*, NPCMsg*); // offset 0x0, size 0x4
19+
void* notedata; // offset 0x4, size 0x4
1820
signed int flg_filter; // offset 0x8, size 0x4
19-
class NPCPSClt * next; // offset 0xC, size 0x4
21+
NPCPSClt* next; // offset 0xC, size 0x4
2022
};
2123

22-
struct NPCPSData {
24+
struct NPCPSData
25+
{
2326
// total size: 0x30
24-
NPCPSClt * cltblob; // offset 0x0, size 0x4
25-
NPCPSClt * cltfree; // offset 0x4, size 0x4
26-
st_XORDEREDARRAY cltlist; // offset 0x8, size 0x10
27-
NPCMsg * msgblob; // offset 0x18, size 0x4
28-
NPCMsg * msgfree; // offset 0x1C, size 0x4
29-
st_XORDEREDARRAY quelist; // offset 0x20, size 0x10
27+
NPCPSClt* cltblob; // offset 0x0, size 0x4
28+
NPCPSClt* cltfree; // offset 0x4, size 0x4
29+
st_XORDEREDARRAY cltlist; // offset 0x8, size 0x10
30+
NPCMsg* msgblob; // offset 0x18, size 0x4
31+
NPCMsg* msgfree; // offset 0x1C, size 0x4
32+
st_XORDEREDARRAY quelist; // offset 0x20, size 0x10
3033
};
3134

3235
#endif

src/SB/Game/zNPCMgr.cpp

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
#include "zNPCSpawner.h"
1212
#include "zNPCMessenger.h"
1313
#include "zNPCGoals.h"
14+
#include "zNPCTypeTiki.h"
1415
#include "zGlobals.h"
1516
#include "xFactory.h"
1617
#include "zRenderState.h"
1718

1819
#include "xBehaveMgr.h"
20+
#include "xstransvc.h"
1921

2022
#include <types.h>
2123

@@ -303,7 +305,7 @@ void zNPCCommon::RenderExtraPostParticles()
303305
void zNPCMgr::ScenePostRender()
304306
{
305307
xLightKit_Enable(globals.player.ent.lightKit, globals.currWorld);
306-
enum _SDRenderState old_rendstat = zRenderStateCurrent();
308+
_SDRenderState old_rendstat = zRenderStateCurrent();
307309
zRenderState(SDRS_NPCVisual);
308310
for (int i = 0; i < npclist.cnt; i++)
309311
{
@@ -330,3 +332,118 @@ void zNPCMgr::ScenePostRender()
330332
xLightKit_Enable(0, globals.currWorld);
331333
zRenderState(old_rendstat);
332334
}
335+
336+
void zNPCMgr::ScenePostParticleRender()
337+
{
338+
xLightKit_Enable(globals.player.ent.lightKit, globals.currWorld);
339+
_SDRenderState old_rendstat = zRenderStateCurrent();
340+
zRenderState(SDRS_NPCVisual);
341+
for (int i = 0; i < npclist.cnt; i++)
342+
{
343+
zNPCCommon* npc = (zNPCCommon*)npclist.list[i];
344+
if (npc->flg_xtrarend & 0x2)
345+
{
346+
npc->flg_xtrarend &= ~0x2;
347+
}
348+
else
349+
{
350+
continue;
351+
}
352+
353+
if (npc->baseFlags & 0x40)
354+
{
355+
continue;
356+
}
357+
358+
if (npc->model == NULL || !(npc->model->Flags & 0x400))
359+
{
360+
npc->RenderExtraPostParticles();
361+
}
362+
}
363+
xLightKit_Enable(0, globals.currWorld);
364+
zRenderState(old_rendstat);
365+
}
366+
367+
void zNPCMgr::SceneTimestep(xScene* xscn, F32 dt)
368+
{
369+
DBG_PerfTrack();
370+
if (g_firstFrameUpdateAllNPC != 0)
371+
{
372+
BackdoorUpdateAllNPCsOnce(xscn, dt);
373+
g_firstFrameUpdateAllNPC = 0;
374+
}
375+
zNPCMsg_Timestep(xscn, dt);
376+
zNPCTiki_Timestep(xscn, dt);
377+
zNPCCommon_Timestep(xscn, dt);
378+
zNPCRobot_Timestep(xscn, dt);
379+
zNPCVillager_SceneTimestep(xscn, dt);
380+
}
381+
382+
void zNPCMgr::BackdoorUpdateAllNPCsOnce(xScene* xscn, F32 dt)
383+
{
384+
for (int i = 0; i < npclist.cnt; i++)
385+
{
386+
zNPCCommon* npc = (zNPCCommon*)npclist.list[i];
387+
xSceneID2Name(globals.sceneCur, npc->id);
388+
389+
if (npc->baseFlags & 0x40 && npc->update != NULL)
390+
{
391+
npc->update(npc, xscn, 1.0f / 60);
392+
}
393+
}
394+
}
395+
396+
en_NPCTYPES zNPCMgr::NPCTypeForModel(U32 brainID, U32 mdl_hash)
397+
{
398+
if (brainID != NULL)
399+
{
400+
for (int i = 0; i < sizeof(g_brainTable) / sizeof(g_brainTable[0]); i++)
401+
{
402+
if (brainID == g_brainTable[i].id)
403+
{
404+
return g_brainTable[i].type;
405+
}
406+
}
407+
}
408+
409+
en_NPCTYPES usetype = NPC_TYPE_UNKNOWN;
410+
for (NPCMTypeTable* rec = g_tbltype; rec->useNPCType != NPC_TYPE_UNKNOWN; rec++)
411+
{
412+
if (rec->hashOfName == mdl_hash)
413+
{
414+
usetype = rec->useNPCType;
415+
break;
416+
}
417+
}
418+
419+
if (usetype == NPC_TYPE_UNKNOWN)
420+
{
421+
usetype = NPC_TYPE_COMMON;
422+
}
423+
424+
return usetype;
425+
}
426+
427+
xEnt* zNPCMgr::CreateNPC(xEntAsset* asset)
428+
{
429+
zNPCCommon* npc;
430+
en_NPCTYPES nt;
431+
U32 size;
432+
xModelAssetInfo* modelAsset = (xModelAssetInfo*)xSTFindAsset(asset->modelInfoID, &size);
433+
434+
// FIXME: Replace with actually getting the right model hash from the packed data
435+
nt = this->NPCTypeForModel(modelAsset->BrainID, *(&asset->modelInfoID + 3));
436+
npc = (zNPCCommon*)npcFactory->CreateItem(nt, NULL, NULL);
437+
438+
npc->Init(asset);
439+
XOrdAppend(&npclist, npc);
440+
441+
if (npclist.cnt == npclist.max)
442+
{
443+
XOrdSort(&npclist, zNPCMgr_OrdComp_npcid);
444+
}
445+
446+
this->DBG_Reset();
447+
448+
return npc;
449+
}

src/SB/Game/zNPCMgr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "xFactory.h"
55
#include "xBehaveMgr.h"
6+
#include "zNPCTypes.h"
67

78
#include <types.h>
89

@@ -14,7 +15,7 @@ struct zNPCMgr : RyzMemData
1415
xBase selfbase;
1516

1617
zNPCMgr();
17-
S32 NPCTypeForModel(U32, U32);
18+
enum en_NPCTYPES NPCTypeForModel(U32 brainID, U32 mdl_hash);
1819
void BackdoorUpdateAllNPCsOnce(xScene*, F32);
1920
void PrepTypeTable();
2021
void Startup();

src/SB/Game/zNPCTypeCommon.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ void zNPCCommon_WonderReset();
640640
void ZNPC_Common_Shutdown();
641641
void NPCC_BuildStandardAnimTran(xAnimTable* table, char** namelist, S32* ourAnims, S32 idx_dflt,
642642
F32 blend);
643+
void zNPCCommon_Timestep(xScene* xscn, F32 dt);
643644

644645
xAnimTable* ZNPC_AnimTable_Common();
645646
xAnimTable* ZNPC_AnimTable_LassoGuide();

0 commit comments

Comments
 (0)