From 3b5b4c9ece694784c6ffa51113f860899d832376 Mon Sep 17 00:00:00 2001 From: Joey Ballentine Date: Wed, 26 Mar 2025 18:30:55 -0500 Subject: [PATCH 1/6] Startup --- src/SB/Game/zNPCMgr.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/SB/Game/zNPCMgr.cpp b/src/SB/Game/zNPCMgr.cpp index 8b784f829..d3d3f729a 100644 --- a/src/SB/Game/zNPCMgr.cpp +++ b/src/SB/Game/zNPCMgr.cpp @@ -1,4 +1,5 @@ #include "zNPCMgr.h" +#include "xRMemData.h" #include "zNPCTypeCommon.h" #include "zNPCTypeRobot.h" #include "zNPCTypeVillager.h" @@ -8,7 +9,9 @@ #include "zNPCTypes.h" #include "zNPCSpawner.h" #include "zNPCMessenger.h" +#include "zNPCGoals.h" #include "zGlobals.h" +#include "xFactory.h" #include "xBehaveMgr.h" @@ -56,7 +59,7 @@ void zNPCMgr_Startup() if (g_modinit++ == 0) { xBehaveMgr_Startup(); - zNPCMgr* npc = new (0x4e50434d, NULL) zNPCMgr(); //NPCM + zNPCMgr* npc = new ('NPCM', NULL) zNPCMgr(); g_npcmgr = npc; npc->Startup(); } @@ -228,7 +231,6 @@ S32 zNPCMgr_OrdComp_npcid(void* vkey, void* vitem) return rc; } - zNPCMgr::zNPCMgr() { } @@ -261,3 +263,18 @@ void zNPCCommon::RenderExtra() void zNPCCommon::RenderExtraPostParticles() { } + +void zNPCMgr::Startup() +{ + PrepTypeTable(); + selfbase.id = 'NPCM'; + selfbase.baseType = 0xAB; + npcFactory = new ('NPCM', NULL) xFactory(0x60); + zNPCMsg_Startup(); + zNPCSpawner_Startup(); + zNPCTypes_StartupTypes(); + zNPCTypes_RegisterTypes(npcFactory); + bmgr = xBehaveMgr_GetSelf(); + xFactory* behaveMgrFactory = bmgr->GetFactory(); + zNPCGoals_RegisterTypes(behaveMgrFactory); +} From b6220773724aac34a28a43201cc68a9d4e279f97 Mon Sep 17 00:00:00 2001 From: Joey Ballentine Date: Thu, 27 Mar 2025 01:16:02 -0500 Subject: [PATCH 2/6] wip ScenePostRender --- src/SB/Game/zNPCMgr.cpp | 50 ++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/src/SB/Game/zNPCMgr.cpp b/src/SB/Game/zNPCMgr.cpp index d3d3f729a..764bae688 100644 --- a/src/SB/Game/zNPCMgr.cpp +++ b/src/SB/Game/zNPCMgr.cpp @@ -12,6 +12,7 @@ #include "zNPCGoals.h" #include "zGlobals.h" #include "xFactory.h" +#include "zRenderState.h" #include "xBehaveMgr.h" @@ -20,6 +21,9 @@ extern S32 g_modinit; extern zNPCMgr* g_npcmgr; +extern xLightKit* DAT_803c0c68; +extern RpWorld* DAT_803c0bb0; + S32 g_firstFrameUpdateAllNPC; struct NPCMTypeTable @@ -127,6 +131,21 @@ xEnt* zNPCMgr_createNPCInst(S32, xEntAsset* assdat) return zNPCMgrSelf()->CreateNPC(assdat); } +void zNPCMgr::Startup() +{ + PrepTypeTable(); + selfbase.id = 'NPCM'; + selfbase.baseType = 0xAB; + npcFactory = new ('NPCM', NULL) xFactory(0x60); + zNPCMsg_Startup(); + zNPCSpawner_Startup(); + zNPCTypes_StartupTypes(); + zNPCTypes_RegisterTypes(npcFactory); + bmgr = xBehaveMgr_GetSelf(); + xFactory* behaveMgrFactory = bmgr->GetFactory(); + zNPCGoals_RegisterTypes(behaveMgrFactory); +} + void zNPCMgr::Shutdown() { if (this->npcFactory != NULL) @@ -263,18 +282,23 @@ void zNPCCommon::RenderExtra() void zNPCCommon::RenderExtraPostParticles() { } - -void zNPCMgr::Startup() +void zNPCMgr::ScenePostRender() { - PrepTypeTable(); - selfbase.id = 'NPCM'; - selfbase.baseType = 0xAB; - npcFactory = new ('NPCM', NULL) xFactory(0x60); - zNPCMsg_Startup(); - zNPCSpawner_Startup(); - zNPCTypes_StartupTypes(); - zNPCTypes_RegisterTypes(npcFactory); - bmgr = xBehaveMgr_GetSelf(); - xFactory* behaveMgrFactory = bmgr->GetFactory(); - zNPCGoals_RegisterTypes(behaveMgrFactory); + xLightKit_Enable(DAT_803c0c68, DAT_803c0bb0); + enum _SDRenderState old_rendstat = zRenderStateCurrent(); + zRenderState(SDRS_NPCVisual); + for (int i = 0; i < npclist.cnt; i++) + { + zNPCCommon* npc = (zNPCCommon*)npclist.list[i]; + if (npc->flg_xtrarend & 0x1 && (npc->flg_xtrarend = npc->flg_xtrarend & 0xfffffffe), + !(npc->baseFlags & 0x40)) + { + if (npc->model == NULL || !(npc->model->Flags & 0x400)) + { + npc->RenderExtra(); + } + } + } + xLightKit_Enable(0, DAT_803c0bb0); + zRenderState(old_rendstat); } From 8a99963fcc77fe81aa8e7442db88166af5e8504a Mon Sep 17 00:00:00 2001 From: Joey Ballentine Date: Thu, 27 Mar 2025 12:06:52 -0500 Subject: [PATCH 3/6] slightly more matching, more readable code --- src/SB/Game/zNPCMgr.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/SB/Game/zNPCMgr.cpp b/src/SB/Game/zNPCMgr.cpp index 764bae688..6bff1d1ff 100644 --- a/src/SB/Game/zNPCMgr.cpp +++ b/src/SB/Game/zNPCMgr.cpp @@ -290,13 +290,23 @@ void zNPCMgr::ScenePostRender() for (int i = 0; i < npclist.cnt; i++) { zNPCCommon* npc = (zNPCCommon*)npclist.list[i]; - if (npc->flg_xtrarend & 0x1 && (npc->flg_xtrarend = npc->flg_xtrarend & 0xfffffffe), - !(npc->baseFlags & 0x40)) + if (npc->flg_xtrarend & 0x1) { - if (npc->model == NULL || !(npc->model->Flags & 0x400)) - { - npc->RenderExtra(); - } + npc->flg_xtrarend &= ~0x1; + } + else + { + continue; + } + + if (npc->baseFlags & 0x40) + { + continue; + } + + if (npc->model == NULL || !(npc->model->Flags & 0x400)) + { + npc->RenderExtra(); } } xLightKit_Enable(0, DAT_803c0bb0); From 0762f6994c61c0046e20f34fa5917b51d4a43151 Mon Sep 17 00:00:00 2001 From: Joey Ballentine Date: Thu, 27 Mar 2025 12:22:11 -0500 Subject: [PATCH 4/6] ScenePostRender finished --- src/SB/Game/zNPCMgr.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SB/Game/zNPCMgr.cpp b/src/SB/Game/zNPCMgr.cpp index 6bff1d1ff..103d6b19e 100644 --- a/src/SB/Game/zNPCMgr.cpp +++ b/src/SB/Game/zNPCMgr.cpp @@ -1,4 +1,5 @@ #include "zNPCMgr.h" +#include "xLightKit.h" #include "xRMemData.h" #include "zNPCTypeCommon.h" #include "zNPCTypeRobot.h" @@ -22,7 +23,6 @@ extern S32 g_modinit; extern zNPCMgr* g_npcmgr; extern xLightKit* DAT_803c0c68; -extern RpWorld* DAT_803c0bb0; S32 g_firstFrameUpdateAllNPC; @@ -284,7 +284,7 @@ void zNPCCommon::RenderExtraPostParticles() } void zNPCMgr::ScenePostRender() { - xLightKit_Enable(DAT_803c0c68, DAT_803c0bb0); + xLightKit_Enable(globals.player.ent.lightKit, globals.currWorld); enum _SDRenderState old_rendstat = zRenderStateCurrent(); zRenderState(SDRS_NPCVisual); for (int i = 0; i < npclist.cnt; i++) @@ -309,6 +309,6 @@ void zNPCMgr::ScenePostRender() npc->RenderExtra(); } } - xLightKit_Enable(0, DAT_803c0bb0); + xLightKit_Enable(0, globals.currWorld); zRenderState(old_rendstat); } From 3f6b8da680047a610875b38fb9f889373fc4fd4d Mon Sep 17 00:00:00 2001 From: Joey Ballentine Date: Thu, 27 Mar 2025 12:23:16 -0500 Subject: [PATCH 5/6] remove DAT --- src/SB/Game/zNPCMgr.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/SB/Game/zNPCMgr.cpp b/src/SB/Game/zNPCMgr.cpp index 103d6b19e..c1ffd4502 100644 --- a/src/SB/Game/zNPCMgr.cpp +++ b/src/SB/Game/zNPCMgr.cpp @@ -22,8 +22,6 @@ extern S32 g_modinit; extern zNPCMgr* g_npcmgr; -extern xLightKit* DAT_803c0c68; - S32 g_firstFrameUpdateAllNPC; struct NPCMTypeTable From 4348a0da72ba11d66dae92abec318be5cd23cadb Mon Sep 17 00:00:00 2001 From: Joey Ballentine Date: Thu, 27 Mar 2025 12:24:16 -0500 Subject: [PATCH 6/6] spacing --- src/SB/Game/zNPCMgr.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SB/Game/zNPCMgr.cpp b/src/SB/Game/zNPCMgr.cpp index c1ffd4502..f13481289 100644 --- a/src/SB/Game/zNPCMgr.cpp +++ b/src/SB/Game/zNPCMgr.cpp @@ -280,6 +280,7 @@ void zNPCCommon::RenderExtra() void zNPCCommon::RenderExtraPostParticles() { } + void zNPCMgr::ScenePostRender() { xLightKit_Enable(globals.player.ent.lightKit, globals.currWorld);