From ec0091f3b6983ae6b33089480d4e1484cde7d5eb Mon Sep 17 00:00:00 2001 From: Gota7 Date: Tue, 5 Jan 2021 07:38:40 -0500 Subject: [PATCH] Partial Progress On zMovePoint.cpp And zLightEffect.cpp (#95) * Decomp Part Of zMusic.cpp Progress. * Cleanup zMusic Changes For merging. * Partial Decompilation Of zTaxi.cpp 9/13 functions done. * Decompile Most Of zCameraFly.cpp; Cleanup More progress. * zRumble, zFX, Snd zScript Partial Decpmpilation More general progress. * zRumble, zFX, And zScript Partial Decpmpilation More general progress. * Cleanup For Merging For progress. * Another Cleanup For Pull Request 3rd time's the charm. * Partial Decompilation Of iTime.cpp Progress! * Decompile Most Of Particle Manager So close to 100%ing it, but yet so far. * Start xBehaviour; Remove zScript.s I need sleep. * More Work On xBehaviour Progress. * Partial Decompilation Of Various Files Include xDebug, zPendulum, and zTaskBox. All work in progress. * Partial Decompilation Of zMovePoint And zLightEffect Progress. --- src/Core/p2/iLight.h | 10 ++ src/Core/x/xBase.h | 2 + src/Core/x/xMovePoint.cpp | 9 +- src/Core/x/xMovePoint.h | 8 +- src/Game/zLightEffect.cpp | 194 +++++++++++++++++++++++++++++--------- src/Game/zLightEffect.h | 71 ++++++++++++++ src/Game/zMovePoint.cpp | 155 +++++++++++++++++++++++++----- src/Game/zMovePoint.h | 19 ++++ src/Game/zNPCSupplement.h | 6 ++ src/Game/zTaskBox.cpp | 55 ++++++----- 10 files changed, 422 insertions(+), 107 deletions(-) diff --git a/src/Core/p2/iLight.h b/src/Core/p2/iLight.h index a6dbe22..edcb29f 100644 --- a/src/Core/p2/iLight.h +++ b/src/Core/p2/iLight.h @@ -17,15 +17,25 @@ #define ILIGHT_ENV_WORLD 2 #define ILIGHT_ENV_ATOMICWORLD 3 +// Size: 0x3C struct iLight { + + // 0x0 uint32 type; RpLight* hw; + + //0x8 xSphere sph; float32 radius_sq; + + //0x1C _xFColor color; + + //0x2C xVec3 dir; float32 coneangle; + }; extern RpWorld* gLightWorld; diff --git a/src/Core/x/xBase.h b/src/Core/x/xBase.h index 3217ab8..b8d90ee 100644 --- a/src/Core/x/xBase.h +++ b/src/Core/x/xBase.h @@ -4,6 +4,7 @@ #include "xLinkAsset.h" #include "xserializer.h" +// Size: 0x8 struct xBaseAsset { uint32 id; @@ -16,6 +17,7 @@ struct xBase; typedef int32 (*xBaseEventCB)(xBase*, xBase*, uint32, const float32*, xBase*); +// Size: 0x10 struct xBase { uint32 id; diff --git a/src/Core/x/xMovePoint.cpp b/src/Core/x/xMovePoint.cpp index fe1dcb4..397db40 100644 --- a/src/Core/x/xMovePoint.cpp +++ b/src/Core/x/xMovePoint.cpp @@ -55,7 +55,7 @@ void xMovePointReset(xMovePoint* m) void xMovePointSetup(xMovePoint* m, xScene* sc) { m->node_wt_sum = 0; - uint32* pointIds = (uint32*)(m->asset + 1); + uint32* pointIds = (uint32*)(m->asset + 1) - 1; for (uint16 idx = 0; idx < m->asset->numPoints; ++idx) { uint32 id = pointIds[idx]; @@ -79,13 +79,14 @@ void xMovePointSplineDestroy(xMovePoint* m) // func_800357B8 #if 1 -#pragma GLOBAL_ASM("asm/Core/x/xMovePoint.s", "xMovePointGetNext__FPC10xMovePointPC10xMovePointPP10xMovePointP5xVec3") +#pragma GLOBAL_ASM("asm/Core/x/xMovePoint.s", \ + "xMovePointGetNext__FPC10xMovePointPC10xMovePointPP10xMovePointP5xVec3") #else // If you uncomment the numPoints variable then this function is a perfect match // minus ordering. In the original assembly some variable fetches are lifted to // places earlier in the assembly listing than what this comiles to for some -// reason. -// The r27-30 registers used to hold the main varibles of the function are all +// reason. +// The r27-30 registers used to hold the main varibles of the function are all // perfect matches with this code. extern float xMovePoint_float_0; float32 xMovePointGetNext(xMovePoint* m, xMovePoint* prev, xMovePoint** next, xVec3* hdng) diff --git a/src/Core/x/xMovePoint.h b/src/Core/x/xMovePoint.h index 2cfbf1c..a4b4fed 100644 --- a/src/Core/x/xMovePoint.h +++ b/src/Core/x/xMovePoint.h @@ -12,17 +12,16 @@ struct xMovePointAsset : xBaseAsset xVec3 pos; uint16 wt; - // Offset: 0x16 uint8 on; uint8 bezIndex; uint8 flg_props; uint8 pad; uint16 numPoints; - // Offset: 0x1C float32 delay; float32 zoneRadius; float32 arenaRadius; + xLinkAsset* link; }; struct xMovePoint : xBase @@ -37,7 +36,7 @@ struct xMovePoint : xBase // Offset: 0x24 uint8 on; - uint8 pad[2]; + uint8 pad[3]; // Offset: 0x28 float32 delay; @@ -45,7 +44,8 @@ struct xMovePoint : xBase }; xVec3* xMovePointGetPos(xMovePoint* m); -float32 xMovePointGetNext(xMovePoint* m, xMovePoint* prev, xMovePoint** next, xVec3* hdng); +float32 xMovePointGetNext(const xMovePoint* m, const xMovePoint* prev, xMovePoint** next, + xVec3* hdng); void xMovePointSplineDestroy(xMovePoint* m); void xMovePointSplineSetup(xMovePoint* m); void xMovePointSetup(xMovePoint* m, xScene* sc); diff --git a/src/Game/zLightEffect.cpp b/src/Game/zLightEffect.cpp index 5448739..c995e5e 100644 --- a/src/Game/zLightEffect.cpp +++ b/src/Game/zLightEffect.cpp @@ -1,84 +1,186 @@ #include "zLightEffect.h" #include +#include -// func_8009E7F8 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectSet__FP7_zLighti") +extern lightInitFunc sEffectInitFuncs[18]; +extern float32 lbl_803CDB60; // 65535f +extern float32 lbl_803CDB68; // 176f +extern float32 lbl_803CDB70; // 0.0f +extern float32 lbl_803CDB74; // 0.1f +extern float32 lbl_803CDB78; // 0.2f +extern float32 lbl_803CDB80; // 0.05f +extern float32 lbl_803CDB84; // 0.3f -// func_8009E848 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightOn__FP7_zLighti") +void zLightEffectSet(_zLight* zlight, int32 idx) +{ + if (zlight->reg) + { + zlight->effect_idx = idx; + if (sEffectInitFuncs[zlight->effect_idx] != NULL) + { + sEffectInitFuncs[zlight->effect_idx](zlight); + } + } +} + +void zLightOn(_zLight* zl, int32 on) +{ + if (on) + { + zl->flags |= 1; + } + else + { + zl->flags &= 0xfffffffe; + } +} + +#if 1 // func_8009E870 #pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "leGetRandom__Fv") -// func_8009E8B4 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectInitStrobe__FP7_zLight") +#else -// func_8009E8B8 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectInitDim__FP7_zLight") +// WIP. +float32 leGetRandom() +{ + uint32 rnd = rand(); + return ((float)(rnd & 0xffff) - lbl_803CDB68) / lbl_803CDB60; +} -// func_8009E8BC -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectInitHalfDim__FP7_zLight") +#endif -// func_8009E8C0 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectInitRandomCol__FP7_zLight") +void zLightEffectInitStrobe(_zLight* zlight) +{ +} -// func_8009E8C4 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectInitFlicker__FP7_zLight") +void zLightEffectInitDim(_zLight* zlight) +{ +} + +void zLightEffectInitHalfDim(_zLight* zlight) +{ +} + +void zLightEffectInitRandomCol(_zLight* zlight) +{ +} + +void zLightEffectInitFlicker(_zLight* zlight) +{ + *zlight->reg = lbl_803CDB70; + zLightOn(zlight, true); +} + +#if 1 // func_8009E8F4 #pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "EffectFlicker__FP7_zLightfff") -// func_8009EA78 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectFlicker__FP7_zLightf") +#else -// func_8009EAA0 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectFlickerSlow__FP7_zLightf") +// WIP. +void EffectFlicker(_zLight* zlight, float32 seconds, float32 min, float32 rnd) +{ +} -// func_8009EAC8 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectFlickerErratic__FP7_zLightf") +#endif -// func_8009EAF0 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectStrobeSlow__FP7_zLightf") +void zLightEffectFlicker(_zLight* zlight, float32 seconds) +{ + EffectFlicker(zlight, seconds, lbl_803CDB80, lbl_803CDB78); +} -// func_8009EAF4 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectStrobe__FP7_zLightf") +void zLightEffectFlickerSlow(_zLight* zlight, float32 seconds) +{ + EffectFlicker(zlight, seconds, lbl_803CDB78, lbl_803CDB84); +} -// func_8009EAF8 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectStrobeFast__FP7_zLightf") +void zLightEffectFlickerErratic(_zLight* zlight, float32 seconds) +{ + EffectFlicker(zlight, seconds, lbl_803CDB70, lbl_803CDB74); +} -// func_8009EAFC -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectDimSlow__FP7_zLightf") +void zLightEffectStrobeSlow() +{ +} -// func_8009EB00 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectDim__FP7_zLightf") +void zLightEffectStrobe() +{ +} -// func_8009EB04 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectDimFast__FP7_zLightf") +void zLightEffectStrobeFast() +{ +} -// func_8009EB08 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectHalfDimSlow__FP7_zLightf") +void zLightEffectDimSlow() +{ +} -// func_8009EB0C -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectHalfDim__FP7_zLightf") +void zLightEffectDim() +{ +} -// func_8009EB10 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectHalfDimFast__FP7_zLightf") +void zLightEffectDimFast() +{ +} -// func_8009EB14 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectRandomColSlow__FP7_zLightf") +void zLightEffectHalfDimSlow() +{ +} -// func_8009EB18 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectRandomCol__FP7_zLightf") +void zLightEffectHalfDim() +{ +} -// func_8009EB1C -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectRandomColFast__FP7_zLightf") +void zLightEffectHalfDimFast() +{ +} -// func_8009EB20 -#pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectInitCauldron__FP7_zLight") +void zLightEffectRandomColSlow() +{ +} + +void zLightEffectRandomCol() +{ +} + +void zLightEffectRandomColFast() +{ +} + +void zLightEffectInitCauldron(_zLight* zlight) +{ + *zlight->reg = lbl_803CDB70; + zLightOn(zlight, true); +} + +#if 1 // func_8009EB50 #pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "leBlendToCol__Ffff") +#else + +// WIP. +float32 leBlendToCol(float32 f1, float32 f2, float32 f3) +{ +} + +#endif + +#if 1 + // func_8009EB84 #pragma GLOBAL_ASM("asm/Game/zLightEffect.s", "zLightEffectCauldron__FP7_zLightf") + +#else + +// WIP. +void zLightEffectCauldron(_zLight* zlight, float32 seconds) +{ +} + +#endif \ No newline at end of file diff --git a/src/Game/zLightEffect.h b/src/Game/zLightEffect.h index 9a901e0..591bf4f 100644 --- a/src/Game/zLightEffect.h +++ b/src/Game/zLightEffect.h @@ -1,4 +1,75 @@ #ifndef ZLIGHTEFFECT_H #define ZLIGHTEFFECT_H +#include "../Core/p2/iLight.h" +#include "../Core/x/xBase.h" + +#include + +// Size: 0x38 +struct zLightAsset : xBaseAsset +{ + // 0x8 + uint8 lightType; + uint8 lightEffect; + uint8 lightPad[2]; + uint32 lightFlags; + + // 0x10 + float32 lightColor[4]; + xVec3 lightDir; + + // 0x20 + float32 lightConeAngle; + xSphere lightSphere; + uint32 attachID; +}; + +// Size: 0x64 +struct _zLight : xBase +{ + // 0x10 + uint32 flags; + zLightAsset* tasset; + + // 0x18 + iLight light; + xBase* attached_to; + int32 true_idx; + float32* reg; + + // 0x60 + int32 effect_idx; +}; + +typedef void (*lightInitFunc)(_zLight*); + +void zLightEffectSet(_zLight* zlight, int32 idx); +void zLightOn(_zLight* zl, int32 on); +float32 leGetRandom(); +void zLightEffectInitStrobe(_zLight* zlight); +void zLightEffectInitDim(_zLight* zlight); +void zLightEffectInitHalfDim(_zLight* zlight); +void zLightEffectInitRandomCol(_zLight* zlight); +void zLightEffectInitFlicker(_zLight* zlight); +void EffectFlicker(_zLight* zlight, float32 seconds, float32 min, float32 rnd); +void zLightEffectFlicker(_zLight* zlight, float32 seconds); +void zLightEffectFlickerSlow(_zLight* zlight, float32 seconds); +void zLightEffectFlickerErratic(_zLight* zlight, float32 seconds); +void zLightEffectStrobeSlow(); +void zLightEffectStrobe(); +void zLightEffectStrobeFast(); +void zLightEffectDimSlow(); +void zLightEffectDim(); +void zLightEffectDimFast(); +void zLightEffectHalfDimSlow(); +void zLightEffectHalfDim(); +void zLightEffectHalfDimFast(); +void zLightEffectRandomColSlow(); +void zLightEffectRandomCol(); +void zLightEffectRandomColFast(); +void zLightEffectInitCauldron(_zLight* zlight); +float32 leBlendToCol(float32 f1, float32 f2, float32 f3); +void zLightEffectCauldron(_zLight* zlight, float32 seconds); + #endif \ No newline at end of file diff --git a/src/Game/zMovePoint.cpp b/src/Game/zMovePoint.cpp index 8eea7ec..c1e70b5 100644 --- a/src/Game/zMovePoint.cpp +++ b/src/Game/zMovePoint.cpp @@ -1,43 +1,148 @@ #include "zMovePoint.h" +#include "zNPCSupplement.h" + +#include "../Core/x/xEvent.h" #include +extern zMovePoint* g_mvpt_list; +extern int32 g_mvpt_cnt; +extern float32 lbl_803CDD40; +extern float32 lbl_803CDD44; + +#if 1 + // func_800A6BF8 #pragma GLOBAL_ASM("asm/Game/zMovePoint.s", "zMovePoint_GetMemPool__Fi") -// func_800A6C48 -#pragma GLOBAL_ASM("asm/Game/zMovePoint.s", "zMovePointInit__FP10zMovePointP15xMovePointAsset") +#else -// func_800A6CB8 -#pragma GLOBAL_ASM("asm/Game/zMovePoint.s", "zMovePoint_GetInst__Fi") +// Random load word at the end of the function for some reason. +zMovePoint* zMovePoint_GetMemPool(int32 cnt) +{ + /*if (cnt != 0) + { + g_mvpt_list = (zMovePoint*)xMemAlloc(cnt * sizeof(zMovePoint)); + } + else + { + g_mvpt_list = NULL; + } + g_mvpt_cnt = cnt; + return g_mvpt_list;*/ -// func_800A6CC8 -#pragma GLOBAL_ASM("asm/Game/zMovePoint.s", "zMovePointSetup__FP10zMovePointP6zScene") + g_mvpt_list = cnt ? (zMovePoint*)xMemAlloc(cnt * sizeof(zMovePoint)) : NULL; + g_mvpt_cnt = cnt; + return g_mvpt_list; +} -// func_800A6CE8 -#pragma GLOBAL_ASM("asm/Game/zMovePoint.s", "zMovePoint_From_xAssetID__FUi") +#endif -// func_800A6D28 -#pragma GLOBAL_ASM("asm/Game/zMovePoint.s", "zMovePointSave__FP10zMovePointP7xSerial") +void zMovePointInit(zMovePoint* m, xMovePointAsset* asset) +{ + xMovePointInit((xMovePoint*)m, asset); + m->eventFunc = zMovePointEventCB; + if (m->linkCount) + { + m->link = (xLinkAsset*)(&asset->link + *(uint16*)&asset->numPoints); + } + else + { + m->link = NULL; + } +} -// func_800A6D48 -#pragma GLOBAL_ASM("asm/Game/zMovePoint.s", "zMovePointLoad__FP10zMovePointP7xSerial") +zMovePoint* zMovePoint_GetInst(int32 n) +{ + return &g_mvpt_list[n]; +} -// func_800A6D68 -#pragma GLOBAL_ASM("asm/Game/zMovePoint.s", "zMovePointReset__FP10zMovePoint") +void zMovePointSetup(zMovePoint* mvpt, zScene* scn) +{ + xMovePointSetup((xMovePoint*)mvpt, (xScene*)scn); +} -// func_800A6D88 -#pragma GLOBAL_ASM("asm/Game/zMovePoint.s", "zMovePointEventCB__FP5xBaseP5xBaseUiPCfP5xBase") +zMovePoint* zMovePoint_From_xAssetID(uint32 aid) +{ + zMovePoint* pnt = g_mvpt_list; + zMovePoint* ret = NULL; + for (int32 i = g_mvpt_cnt; i > 0; i--) + { + if (pnt->asset->id == aid) + { + ret = pnt; + break; + } + pnt++; + } + return ret; +} -// func_800A6E34 -#pragma GLOBAL_ASM("asm/Game/zMovePoint.s", \ - "zMovePointGetNext__FPC10zMovePointPC10zMovePointPP10zMovePointP5xVec3") +void zMovePointSave(zMovePoint* ent, xSerial* s) +{ + xMovePointSave((xMovePoint*)ent, s); +} -// func_800A6E54 -#pragma GLOBAL_ASM("asm/Game/zMovePoint.s", "zMovePointGetPos__FPC10zMovePoint") +void zMovePointLoad(zMovePoint* ent, xSerial* s) +{ + xMovePointLoad((xMovePoint*)ent, s); +} -// func_800A6E74 -#pragma GLOBAL_ASM("asm/Game/zMovePoint.s", "zMovePointGetDelay__FPC10zMovePoint") +void zMovePointReset(zMovePoint* m) +{ + xMovePointReset((xMovePoint*)m); +} -// func_800A6E94 -#pragma GLOBAL_ASM("asm/Game/zMovePoint.s", "xMovePointGetDelay__FPC10xMovePoint") +int32 zMovePointEventCB(xBase* from, xBase* to, uint32 toEvent, const float32* toParam, xBase* b3) +{ + switch (toEvent) + { + case eEventOn: + ((zMovePoint*)to)->on = true; + break; + case eEventOff: + ((zMovePoint*)to)->on = false; + break; + case eEventArrive: + break; + case eEventReset: + zMovePointReset((zMovePoint*)to); + break; + case eEventMakeASplash: + xVec3* pos = ((zMovePoint*)to)->pos; + if (pos != NULL) + { + if (*toParam < lbl_803CDD40) + { + NPCC_MakeASplash(pos, lbl_803CDD44); + } + else + { + NPCC_MakeASplash(pos, *toParam); + } + } + break; + } + return eEventEnable; +} + +float32 zMovePointGetNext(const zMovePoint* current, const zMovePoint* prev, zMovePoint** next, + xVec3* hdng) +{ + return xMovePointGetNext((xMovePoint*)current, (xMovePoint*)prev, (xMovePoint**)next, hdng); +} + +xVec3* zMovePointGetPos(const zMovePoint* m) +{ + return xMovePointGetPos((xMovePoint*)m); +} + +float32 zMovePointGetDelay(const zMovePoint* m) +{ + return xMovePointGetDelay((xMovePoint*)m); +} + +float32 xMovePointGetDelay(const xMovePoint* m) +{ + return m->delay; +} diff --git a/src/Game/zMovePoint.h b/src/Game/zMovePoint.h index f8a203c..488f774 100644 --- a/src/Game/zMovePoint.h +++ b/src/Game/zMovePoint.h @@ -3,8 +3,27 @@ #include "../Core/x/xMovePoint.h" +#include "zScene.h" + +#include + struct zMovePoint : xMovePoint { }; +zMovePoint* zMovePoint_GetMemPool(int32 cnt); +void zMovePointInit(zMovePoint* m, xMovePointAsset* asset); +zMovePoint* zMovePoint_GetInst(int32 n); +void zMovePointSetup(zMovePoint* mvpt, zScene* scn); +zMovePoint* zMovePoint_From_xAssetID(uint32 aid); +void zMovePointSave(zMovePoint* ent, xSerial* s); +void zMovePointLoad(zMovePoint* ent, xSerial* s); +void zMovePointReset(zMovePoint* m); +int32 zMovePointEventCB(xBase* from, xBase* to, uint32 toEvent, const float32* toParam, xBase* b3); +float32 zMovePointGetNext(const zMovePoint* current, const zMovePoint* prev, zMovePoint** next, + xVec3* hdng); +xVec3* zMovePointGetPos(const zMovePoint* m); +float32 zMovePointGetDelay(const zMovePoint* m); +float32 xMovePointGetDelay(const xMovePoint* m); + #endif \ No newline at end of file diff --git a/src/Game/zNPCSupplement.h b/src/Game/zNPCSupplement.h index 5f17a75..9772b09 100644 --- a/src/Game/zNPCSupplement.h +++ b/src/Game/zNPCSupplement.h @@ -1,4 +1,10 @@ #ifndef ZNPCSUPPLEMENT_H #define ZNPCSUPPLEMENT_H +#include "../Core/x/xVec3.h" + +#include + +void NPCC_MakeASplash(const xVec3* pos, float32 radius); + #endif \ No newline at end of file diff --git a/src/Game/zTaskBox.cpp b/src/Game/zTaskBox.cpp index b93eba5..96756c3 100644 --- a/src/Game/zTaskBox.cpp +++ b/src/Game/zTaskBox.cpp @@ -99,41 +99,40 @@ void ztaskbox::talk_callback::reset(ztaskbox& task) this->answer = ztalkbox::ANSWER_CONTINUE; } -#if 1 - -// func_80134BD4 -#pragma GLOBAL_ASM("asm/Game/zTaskBox.s", "stop_talk__8ztaskboxFv") - -#else - -// Need to fix up the conditions. void ztaskbox::stop_talk() { ztaskbox* curr = this->current; - if (curr != NULL) + + if (curr == NULL) { - if (curr != this) - { - curr->stop_talk(); - } - else - { - if (this->flag.enabled && this->state != STATE_INVALID && - shared == this) // Does not like this condition. - { - ztalkbox* other = (ztalkbox*)zSceneFindObject(this->asset->talk_box); - if (other != NULL) - { - other->stop_talk(); - shared = NULL; - } - } - } + return; + } + + if (curr != this) + { + curr->stop_talk(); + return; + } + + if (!this->flag.enabled || this->state == STATE_INVALID) + { + return; + } + + if (shared != this) + { + return; + } + + ztalkbox* other = (ztalkbox*)zSceneFindObject(this->asset->talk_box); + + if (other) + { + other->stop_talk(); + shared = NULL; } } -#endif - void ztaskbox::enable() { if (!this->flag.enabled)