diff --git a/configure.py b/configure.py index 92a7bd55..2d4a6b41 100644 --- a/configure.py +++ b/configure.py @@ -554,12 +554,12 @@ def MatchingFor(*versions): Object(NonMatching, "SB/Game/zNPCMessenger.cpp", extra_cflags=["-sym on"]), Object(NonMatching, "SB/Game/zNPCMgr.cpp", extra_cflags=["-sym on"]), Object(Matching, "SB/Game/zNPCTypes.cpp"), - Object(NonMatching, "SB/Game/zNPCTypeCommon.cpp"), + Object(NonMatching, "SB/Game/zNPCTypeCommon.cpp", extra_cflags=["-sym on"]), Object(NonMatching, "SB/Game/zNPCTypeRobot.cpp"), Object(NonMatching, "SB/Game/zNPCTypeVillager.cpp"), Object(NonMatching, "SB/Game/zNPCTypeAmbient.cpp"), Object(NonMatching, "SB/Game/zNPCTypeTiki.cpp", extra_cflags=["-sym on"]), - Object(NonMatching, "SB/Core/x/xBehaveMgr.cpp"), + Object(NonMatching, "SB/Core/x/xBehaveMgr.cpp", extra_cflags=["-sym on"]), Object(Matching, "SB/Core/x/xBehaviour.cpp", extra_cflags=["-sym on"]), Object(Matching, "SB/Core/x/xBehaveGoalSimple.cpp", extra_cflags=["-sym on"]), Object(NonMatching, "SB/Core/x/xSkyDome.cpp"), diff --git a/src/SB/Core/x/xBehaveMgr.cpp b/src/SB/Core/x/xBehaveMgr.cpp index 7e38c0ea..7d3abcf2 100644 --- a/src/SB/Core/x/xBehaveMgr.cpp +++ b/src/SB/Core/x/xBehaveMgr.cpp @@ -1,7 +1,4 @@ #include "xBehaveMgr.h" - -#include - #include "xBehaveGoalSimple.h" #include "xutil.h" @@ -55,18 +52,28 @@ void xBehaveMgr_SceneReset() g_behavmgr->SceneReset(); } +void xBehaveMgr::Startup(S32 size, S32 tmpAlloc) +{ + goalFactory = new ('BMGR', NULL) xFactory(tmpAlloc); + + g_behavmgr->RegBuiltIn(); + XOrdInit(&psylist, size, 0); + psypool = (xPsyche*)xMemAlloc(gActiveHeap, size * sizeof(xPsyche), 0); + memset(psypool, 0, size * sizeof(xPsyche)); +} + void xBehaveMgr::RegBuiltIn() { xGoalSimple_RegisterTypes(this->goalFactory); } -xPsyche* xBehaveMgr::Subscribe(xBase* owner, S32 i) +xPsyche* xBehaveMgr::Subscribe(xBase* owner, S32 unk) { - xPsyche* psyche = &this->psypool[this->psylist.cnt]; - XOrdAppend(&this->psylist, psyche); - psyche->FreshWipe(); - psyche->SetOwner(owner, NULL); - return psyche; + xPsyche* psy = &this->psypool[this->psylist.cnt]; + XOrdAppend(&this->psylist, psy); + psy->FreshWipe(); + psy->SetOwner(owner, NULL); + return psy; } void xBehaveMgr::UnSubscribe(xPsyche* psy) @@ -93,16 +100,6 @@ void xBehaveMgr::SceneReset() } } -void xBehaveMgr::Startup(S32 size, S32 tmpAlloc) -{ - goalFactory = new ('BMGR', NULL) xFactory(tmpAlloc); - - g_behavmgr->RegBuiltIn(); - XOrdInit(&psylist, size, 0); - psypool = (xPsyche*)xMemAlloc(gActiveHeap, size * 0x68, 0); - memset(psypool, 0, size * 0x68); -} - void xPsyche::BrainBegin() { xFactory* factory = xBehaveMgr_GoalFactory(); @@ -131,7 +128,7 @@ xGoal* xPsyche::AddGoal(S32 gid, void* createData) { if (this->goallist != NULL) { - this->goallist->Insert(goal); + goal->Insert(this->goallist); } else { @@ -146,23 +143,20 @@ xGoal* xPsyche::AddGoal(S32 gid, void* createData) return goal; } -extern F32 _750; void xPsyche::FreshWipe() { - this->goalstak[0] = NULL; - this->goalstak[1] = NULL; - this->goalstak[2] = NULL; - this->goalstak[3] = NULL; - this->goalstak[4] = NULL; + for (S32 i = 0; i < 5; ++i) + { + this->goalstak[i] = NULL; + } this->staktop = -1; this->gid_safegoal = 0; this->pendgoal = 0; this->pendtype = PEND_TRAN_NONE; - this->tmr_stack[0][0] = _750; - this->tmr_stack[0][1] = _750; - this->tmr_stack[0][2] = _750; - this->tmr_stack[0][3] = _750; - this->tmr_stack[0][4] = _750; + for (S32 i = 0; i < 5; ++i) + { + this->tmr_stack[0][i] = 0.0f; + } this->clt_owner = NULL; this->userContext = NULL; this->fun_remap = NULL; @@ -218,45 +212,22 @@ void xPsyche::Amnesia(S32 i) } } +// Non-matching: Loop/alloc issue S32 xPsyche::IndexInStack(S32 gid) const { - // This kinda sucks - S32 da_idx; - S32 i; - S32 temp; - S32 temp2; + S32 da_idx = -1; - da_idx = staktop; - - i = 0; - while ((temp = -1, i <= da_idx && (temp2 = goallist->GetID(), temp = i, gid != temp2))) + for (S32 i = 0; i <= this->staktop; i++) { - da_idx = da_idx + 4; - i++; - } + xGoal* tmpgoal = this->goalstak[i]; - return da_idx; -} - -S32 xPsyche::GoalPopToBase(S32 overpend) -{ - if (this->flg_psyche & 4) - { - return 0; - } - else if (this->staktop < 1) - { - return 0; - } - else - { - xPsyche::GoalPop(this->goalstak[0]->GetID(), overpend); - if ((this->pendtype != PEND_TRAN_NONE) && ((this->flg_psyche & 1))) + if (gid == tmpgoal->GetID()) { - this->ForceTran(0.01f, NULL); + da_idx = i; + break; } - return 1; } + return da_idx; } xGoal* xPsyche::GetCurGoal() const @@ -271,6 +242,25 @@ xGoal* xPsyche::GetCurGoal() const } } +// Non-matching: Loop/alloc issue +xGoal* xPsyche::GIDInStack(S32 gid) const +{ + xGoal* da_goal = NULL; + + for (S32 i = 0; i <= this->staktop; i++) + { + xGoal* tmpgoal = this->goalstak[i]; + + if (gid == tmpgoal->GetID()) + { + da_goal = tmpgoal; + break; + } + } + + return da_goal; +} + S32 xPsyche::GIDOfActive() const { if (this->staktop < 0) @@ -300,13 +290,12 @@ xGoal* xPsyche::GetPrevRecovery(S32 gid) const S32 idx_start = -1; S32 i; xGoal* recgoal = NULL; - xGoal* tmpgoal = NULL; if (gid == 0) { - for (idx_start = this->staktop; idx_start >= 0; idx_start--) + for (i = this->staktop; i >= 0; i--) { - tmpgoal = this->goalstak[idx_start]; + xGoal* tmpgoal = this->goalstak[i]; if (tmpgoal->GetFlags() & 8) { recgoal = tmpgoal; @@ -326,9 +315,9 @@ xGoal* xPsyche::GetPrevRecovery(S32 gid) const } if (idx_start > 0) { - for (S32 i = idx_start; i >= 0; i--) + for (i = idx_start; i >= 0; i--) { - tmpgoal = this->goalstak[i]; + xGoal* tmpgoal = this->goalstak[i]; if (tmpgoal->GetFlags() & 8) { recgoal = tmpgoal; @@ -340,6 +329,329 @@ xGoal* xPsyche::GetPrevRecovery(S32 gid) const return recgoal; } +S32 xPsyche::GoalSet(S32 gid, S32 unk) +{ + S32 result = FALSE; + + if ((this->flg_psyche & 4U)) + { + return result; + } + else + { + if (this->fun_remap != NULL) + { + en_trantype trantype = GOAL_TRAN_SET; + this->fun_remap(&gid, &trantype); + if (trantype != GOAL_TRAN_SET) + { + return FALSE; + } + } + if (this->gid_safegoal == 0) + { + this->SetSafety(gid); + } + if (this->pendgoal && !unk) + { + this->pendgoal->Name(); + } + xGoal* goal = this->FindGoal(gid); + if (goal != NULL) + { + this->pendgoal = goal; + result = TRUE; + this->pendtype = PEND_TRAN_SET; + this->SetTopState(GOAL_STAT_EXIT); + } + if ((result != 0 && this->pendtype != PEND_TRAN_NONE) && (this->flg_psyche & 1U)) + { + this->ForceTran(0.01f, 0); + } + } + return result; +} + +S32 xPsyche::GoalPush(S32 gid, S32 unk) +{ + S32 result = 0; + xGoal* goal; + en_trantype trantype; + + if (this->flg_psyche & 4) + { + return 0; + } + + if (this->fun_remap != NULL) + { + trantype = (en_trantype)2; + this->fun_remap(&gid, &trantype); + if (trantype != (en_trantype)2) + { + return 0; + } + } + + if (this->pendgoal && !unk) + { + this->pendgoal->Name(); + } + + if (this->staktop >= 4) + { + return 0; + } + + if (this->staktop >= 0) + { + if (!(this->goalstak[this->staktop]->GetFlags() & 4)) + { + return 0; + } + } + + goal = this->FindGoal(gid); + if (goal != NULL && (goal->GetFlags() & 2)) + { + this->pendgoal = goal; + result = 1; + this->pendtype = (en_pendtype)2; + this->SetTopState((en_GOALSTATE)4); + } + + if (result != 0 && this->pendtype != 0 && (this->flg_psyche & 1)) + { + this->ForceTran(0.01f, NULL); + } + + return result; +} + +S32 xPsyche::GoalPopToBase(S32 overpend) +{ + if (this->flg_psyche & 4) + { + return 0; + } + else if (this->staktop < 1) + { + return 0; + } + else + { + xPsyche::GoalPop(this->goalstak[0]->GetID(), overpend); + if ((this->pendtype != PEND_TRAN_NONE) && ((this->flg_psyche & 1))) + { + this->ForceTran(0.01f, NULL); + } + return 1; + } +} + +S32 xPsyche::GoalPopRecover(S32 overpend) +{ + S32 result = 0; + S32 i; + xGoal* tmpgoal; + xGoal* destgoal = NULL; + + if (flg_psyche & 0x4) + { + return 0; + } + if (staktop < 1) + { + return 0; + } + for (i = staktop - 1; i >= 0; i--) + { + tmpgoal = goalstak[i]; + if (tmpgoal->GetFlags() & 0x8) + { + destgoal = tmpgoal; + break; + } + } + if (destgoal) + { + this->GoalPop(destgoal->GetID(), overpend); + result = 1; + } + if (result != 0) + { + if (pendtype != PEND_TRAN_NONE && (flg_psyche & 0x1)) + { + this->ForceTran(0.01f, NULL); + } + } + return result; +} + +S32 xPsyche::GoalPop(S32 gid_popto, S32 unk) +{ + S32 result = 0; + xGoal* destgoal = NULL; + xGoal* tmpgoal; + + if ((this->flg_psyche & 4U) != 0) + { + return 0; + } + + if (this->pendgoal && !unk) + { + this->pendgoal->Name(); + } + + if (gid_popto != 0 && this->fun_remap != NULL) + { + en_trantype trantype = GOAL_TRAN_POPTO; + this->fun_remap(&gid_popto, &trantype); + if (trantype != GOAL_TRAN_POPTO) + { + return 0; + } + } + + if (this->staktop < 0) + { + return 0; + } + + if (this->staktop < 1) + { + result = 0; + } + else if (gid_popto == 0) + { + this->pendgoal = NULL; + this->pendtype = PEND_TRAN_POP; + this->SetTopState(GOAL_STAT_EXIT); + result = 1; + } + else + { + if (gid_popto == this->goalstak[this->staktop]->GetID()) + { + destgoal = NULL; + } + else + { + for (S32 i = 0; i < this->staktop; i++) + { + tmpgoal = this->goalstak[i]; + if (gid_popto == tmpgoal->GetID()) + { + destgoal = tmpgoal; + break; + } + } + } + + if (destgoal != NULL) + { + this->pendgoal = destgoal; + this->pendtype = PEND_TRAN_POPTO; + this->SetTopState(GOAL_STAT_EXIT); + result = 1; + } + } + + if (result != 0 && this->pendtype != PEND_TRAN_NONE && (this->flg_psyche & 1U) != 0) + { + this->ForceTran(0.01f, NULL); + } + + return result; +} + +S32 xPsyche::GoalSwap(S32 gid, S32 unk) +{ + xGoal* goal; + en_trantype trantype; + S32 result; + + result = 0; + if ((this->flg_psyche & 4U) != 0) + { + return 0; + } + else + { + if (this->fun_remap != NULL) + { + trantype = GOAL_TRAN_SWAP; + this->fun_remap(&gid, &trantype); + if (trantype != GOAL_TRAN_SWAP) + { + return 0; + } + } + if (this->pendgoal && !unk) + { + this->pendgoal->Name(); + } + goal = this->FindGoal(gid); + if (goal != NULL) + { + this->pendgoal = goal; + this->pendtype = PEND_TRAN_SWAP; + result = 1; + this->SetTopState(GOAL_STAT_EXIT); + } + if (result != 0 && this->pendtype != PEND_TRAN_NONE && (this->flg_psyche & 1U) != 0) + { + this->ForceTran(0.01f, NULL); + } + } + + return result; +} + +S32 xPsyche::GoalNone(S32 p1, S32 denyExplicit) +{ + if (this->flg_psyche & 4) + { + return 0; + } + else + { + if (p1 == 0 && this->pendgoal != NULL) + { + this->pendgoal->Name(); + } + this->pendgoal = NULL; + if (this->staktop < 0) + { + this->pendtype = PEND_TRAN_NONE; + } + else + { + this->pendtype = PEND_TRAN_POPALL; + this->SetTopState(GOAL_STAT_EXIT); + } + if (this->pendtype != PEND_TRAN_NONE && this->flg_psyche & 1) + { + if (denyExplicit) + { + S32 isActive = this->ExpTranIsOn(); + this->ExpTranOff(); + this->ForceTran(0.01f, NULL); + if (isActive) + { + this->ExpTranOn(); + } + } + else + { + this->ForceTran(0.01f, NULL); + } + } + } + return 1; +} + void xPsyche::SetTopState(en_GOALSTATE state) { if (this->staktop >= 0) @@ -348,13 +660,366 @@ void xPsyche::SetTopState(en_GOALSTATE state) } } +xGoal* xPsyche::FindGoal(S32 gid) +{ + xGoal* goal = this->goallist; + xGoal* safe = NULL; + while (goal != NULL) + { + if (this->gid_safegoal == goal->GetID()) + { + safe = goal; + } + + if (gid == goal->GetID()) + { + break; + } + + goal = goal->Next(); + } + if (goal == NULL) + { + xUtil_idtag2string(gid, 0); + + if (safe != NULL) + { + safe->Name(); + } + else + { + xUtil_idtag2string(this->gid_safegoal, 0); + } + } + if (goal == NULL) + { + goal = safe; + } + return goal; +} + +void xPsyche::ForceTran(F32 dt, void* ctx) +{ + this->flg_psyche |= 2; + this->Timestep(dt, ctx != NULL ? ctx : this->userContext); + this->flg_psyche &= ~0x2; +} + +S32 xPsyche::Timestep(F32 dt, void* updCtxt) +{ + S32 trangid = 0; + en_trantype trantyp = GOAL_TRAN_NONE; + S32 old_psyflags = this->flg_psyche; + this->flg_psyche &= ~0x1; + + if (this->flg_psyche & 0x2) + { + this->cnt_transLastTimestep++; + } + else + { + this->cnt_transLastTimestep = trangid; + } + + this->TimerUpdate(dt); + + do + { + trantyp = GOAL_TRAN_NONE; + S32 moretodo = 0; + + if (this->pendtype != PEND_TRAN_NONE) + { + moretodo = this->TranGoal(dt, updCtxt); + } + + if (moretodo != 0) + { + if (this->pendtype == PEND_TRAN_POPALL) + { + break; + } + } + if (moretodo != 0) + { + break; + } + + if (this->pendtype == PEND_TRAN_NONE) + { + if (this->staktop < 0) + { + break; + } + xGoal* curgoal = this->goalstak[this->staktop]; + + if (!(curgoal->GetFlags() & 0x10000) || + (curgoal->PreCalc(dt, updCtxt), this->pendtype == PEND_TRAN_NONE)) + { + if (curgoal->GetFlags() & 0x20000) + { + trangid = curgoal->EvalRules(&trantyp, dt, updCtxt); + if (trantyp != GOAL_TRAN_NONE || trangid != 0) + { + this->ParseTranRequest(trantyp, trangid); + } + + if (this->pendtype != PEND_TRAN_NONE) + continue; + } + + trantyp = GOAL_TRAN_NONE; + trangid = curgoal->Process(&trantyp, dt, updCtxt, NULL); + if (trantyp != GOAL_TRAN_NONE || trangid != 0) + { + this->ParseTranRequest(trantyp, trangid); + } + } + } + } while (this->pendtype != PEND_TRAN_NONE); + + this->flg_psyche |= (old_psyflags & 1); + + return 0; +} + +S32 xPsyche::ParseTranRequest(en_trantype trantyp, S32 trangid) + +{ + S32 rc = 0; + if (trantyp == GOAL_TRAN_NONE && trangid == 0) + { + rc = 1; + } + else if (trantyp == GOAL_TRAN_POP) + { + rc = this->GoalPop(0, 0); + } + else if (trantyp == GOAL_TRAN_POPALL) + { + rc = this->GoalNone(0, 0); + } + else if (trantyp == GOAL_TRAN_POPBASE) + { + rc = this->GoalPopToBase(0); + } + else if (trantyp == GOAL_TRAN_POPSAFE) + { + rc = this->GoalPopRecover(0); + } + else if (trangid != 0) + { + if (trantyp == GOAL_TRAN_PUSH) + { + rc = this->GoalPush(trangid, 1); + } + else if (trantyp == GOAL_TRAN_POPTO) + { + rc = this->GoalPop(trangid, 1); + } + else if (trantyp == GOAL_TRAN_SWAP) + { + rc = this->GoalSwap(trangid, 1); + } + else if (trantyp == GOAL_TRAN_SET) + { + rc = this->GoalSet(trangid, 1); + } + } + return rc; +} + +S32 xPsyche::TranGoal(F32 dt, void* updCtxt) +{ + S32 halfway = 0; + S32 just_switched = 0; + xGoal* topgoal; + + if (this->staktop < 0 && this->pendgoal != NULL) + { + this->staktop = 0; + this->goalstak[this->staktop] = this->pendgoal; + this->pendgoal->SetState(GOAL_STAT_ENTER); + this->DBG_HistAdd(this->pendgoal->GetID()); + this->pendgoal = NULL; + this->pendtype = PEND_TRAN_INPROG; + } + + if (this->staktop < 0) + { + return 0; + } + + if ((this->pendtype != 0) && (this->pendtype != 7)) + { + S32 moretodo = 0; + topgoal = this->goalstak[this->staktop]; + switch (topgoal->GetState()) + { + case GOAL_STAT_SUSPEND: + moretodo = topgoal->Suspend(dt, updCtxt); + if (moretodo == 0) + { + topgoal->SetState(GOAL_STAT_PAUSED); + } + break; + case GOAL_STAT_EXIT: + moretodo = topgoal->Exit(dt, updCtxt); + if (moretodo == 0) + { + topgoal->SetState(GOAL_STAT_DONE); + } + break; + default: + topgoal->GetState(); + break; + } + + if (moretodo != 0) + { + return moretodo; + } + halfway = 1; + } + + if (halfway != 0) + { + // FIXME: Unhandled enum values 'PEND_TRAN_NONE', 'PEND_TRAN_INPROG', and 'PEND_TRAN_NOMORE' + switch (this->pendtype) + { + case PEND_TRAN_SET: + if (this->staktop >= 0) + { + this->goalstak[this->staktop] = 0; + } + this->staktop -= 1; + if (this->staktop >= 0) + { + this->goalstak[this->staktop]->SetState(GOAL_STAT_EXIT); + break; + } + case PEND_TRAN_PUSH: + this->staktop += 1; + case PEND_TRAN_SWAP: + this->goalstak[this->staktop] = this->pendgoal; + topgoal = this->goalstak[this->staktop]; + topgoal->SetState(GOAL_STAT_ENTER); + this->DBG_HistAdd(topgoal->GetID()); + this->pendgoal = NULL; + this->pendtype = PEND_TRAN_INPROG; + break; + case PEND_TRAN_POP: + this->goalstak[this->staktop] = 0; + this->staktop -= 1; + topgoal = this->goalstak[this->staktop]; + topgoal->SetState(GOAL_STAT_RESUME); + this->DBG_HistAdd(topgoal->GetID()); + this->pendtype = PEND_TRAN_INPROG; + break; + case PEND_TRAN_POPTO: + this->goalstak[this->staktop] = 0; + this->staktop -= 1; + topgoal = this->goalstak[this->staktop]; + if (topgoal == this->pendgoal) + { + topgoal->SetState(GOAL_STAT_RESUME); + this->DBG_HistAdd(topgoal->GetID()); + this->pendgoal = NULL; + this->pendtype = PEND_TRAN_INPROG; + } + else + { + topgoal->SetState(GOAL_STAT_EXIT); + this->DBG_HistAdd(topgoal->GetID()); + } + break; + case PEND_TRAN_POPALL: + this->goalstak[this->staktop] = 0; + this->staktop -= 1; + if (this->staktop >= 0) + { + topgoal = this->goalstak[this->staktop]; + topgoal->SetState(GOAL_STAT_EXIT); + this->DBG_HistAdd(topgoal->GetID()); + } + else + { + this->pendgoal = NULL; + this->pendtype = PEND_TRAN_INPROG; + } + break; + } + + if (this->pendtype != PEND_TRAN_INPROG) + { + return 0; + } + just_switched = 1; + } + + if (this->staktop >= 0) + { + S32 moretodo = 0; + topgoal = this->goalstak[this->staktop]; + switch (topgoal->GetState()) + { + case GOAL_STAT_RESUME: + moretodo = topgoal->Resume(dt, updCtxt); + if (moretodo == 0) + { + topgoal->SetState(GOAL_STAT_PROCESS); + if (this->cb_notice != NULL) + { + this->cb_notice->Notice(PSY_NOTE_HASRESUMED, topgoal, NULL); + } + } + break; + case GOAL_STAT_ENTER: + if (just_switched != 0) + { + this->TimerClear(); + } + moretodo = topgoal->Enter(dt, updCtxt); + if (moretodo == 0) + { + topgoal->SetState(GOAL_STAT_PROCESS); + if (this->cb_notice != NULL) + { + this->cb_notice->Notice(PSY_NOTE_HASENTERED, topgoal, NULL); + } + } + break; + default: + topgoal->GetState(); + break; + } + + if (moretodo == 0) + { + this->pendtype = PEND_TRAN_NONE; + } + } + + if (this->pendtype != PEND_TRAN_NONE) + { + return 2; + } + + if (this->staktop >= 0) + { + this->goalstak[this->staktop]->Name(); + } + + return 0; +} + F32 xPsyche::TimerGet(en_xpsytime tymr) { if (this->staktop < 0) { return -1.0f; } - return *(&this->tmr_stack[0][this->staktop] + tymr); // ...what? + return (&this->tmr_stack[0][this->staktop])[tymr]; } void xPsyche::TimerClear() @@ -363,10 +1028,10 @@ void xPsyche::TimerClear() { return; } - // Missing unreachable branch here. Otherwise functionally identical. this->tmr_stack[0][this->staktop] = 0.0f; } +// Non-matching: Needs an extra branch that does the same `+= dt` void xPsyche::TimerUpdate(F32 dt) { F32* p; diff --git a/src/SB/Core/x/xBehaveMgr.h b/src/SB/Core/x/xBehaveMgr.h index da808156..18eec970 100644 --- a/src/SB/Core/x/xBehaveMgr.h +++ b/src/SB/Core/x/xBehaveMgr.h @@ -1,10 +1,7 @@ #ifndef XBEHAVEMGR_H #define XBEHAVEMGR_H -#include "xBase.h" #include "xBehaviour.h" -#include "xordarray.h" -#include "xFactory.h" struct xBehaveMgr : RyzMemData { diff --git a/src/SB/Core/x/xBehaviour.h b/src/SB/Core/x/xBehaviour.h index 7895be32..2adbda28 100644 --- a/src/SB/Core/x/xBehaviour.h +++ b/src/SB/Core/x/xBehaviour.h @@ -104,12 +104,8 @@ struct xPsyche : RyzMemData PSY_BRAIN_STATUS psystat; xBase fakebase; - xGoal* GIDInStack(S32 gid) const; - void ImmTranOn(); - void ImmTranOff(); - S32 ImmTranIsOn(); - S32 HasGoal(S32 goal); xGoal* GetCurGoal() const; + xGoal* GIDInStack(S32 gid) const; S32 GIDOfActive() const; S32 GIDOfPending() const; S32 GIDOfSafety() const @@ -118,10 +114,11 @@ struct xPsyche : RyzMemData } xGoal* GetPrevRecovery(S32 gid) const; S32 Timestep(F32 dt, void* updCtxt); + S32 ParseTranRequest(en_trantype trantyp, S32 trangid); xGoal* FindGoal(S32 gid); S32 GoalSet(S32 gid, S32 r5); S32 GoalPop(S32 gid_popto, S32 r5); - S32 GoalNone(S32 denyExplicit); + S32 GoalNone(S32 p1, S32 denyExplicit); S32 GoalSwap(S32 gid, S32 r5); S32 GoalPopRecover(S32 overpend); S32 GoalPopToBase(S32 overpend); @@ -132,21 +129,22 @@ struct xPsyche : RyzMemData void BrainExtend(); void BrainEnd(); xGoal* AddGoal(S32 gid, void* createData); - void ForceTran(F32, void*); + void ForceTran(F32 dt, void* ctx); void FreshWipe(); + S32 TranGoal(F32 dt, void* updCtxt); F32 TimerGet(en_xpsytime tymr); void TimerClear(); - void SetTopState(en_GOALSTATE); - void SetOwner(xBase*, void*); - void KillBrain(xFactory*); - void Lobotomy(xFactory*); + void SetTopState(en_GOALSTATE state); + void SetOwner(xBase* clt_owner, void* userContext); + void KillBrain(xFactory* factory); + void Lobotomy(xFactory* factory); void TimerUpdate(F32 dt); void SetSafety(S32 goalID) { gid_safegoal = goalID; } - void Amnesia(S32); - S32 IndexInStack(S32) const; + void Amnesia(S32 i); + S32 IndexInStack(S32 gid) const; void SetNotify(xPSYNote* notice) { cb_notice = notice; @@ -156,6 +154,41 @@ struct xPsyche : RyzMemData { return this->clt_owner; } + S32 ExpTranIsOn() + { + return !(this->flg_psyche & 4); + } + void ExpTranOff() + { + this->flg_psyche |= 4; + } + void ExpTranOn() + { + this->flg_psyche &= ~4; + } + void DBG_HistAdd(S32 gid) + { + } + + void ImmTranOn() + { + this->flg_psyche |= 1; + } + + void ImmTranOff() + { + this->flg_psyche &= ~1; + } + + S32 ImmTranIsOn() + { + return this->flg_psyche & 1; + } + + S32 HasGoal(S32 goal) + { + return FindGoal(goal) != NULL; + } }; struct xGoal : xListItem, xFactoryInst diff --git a/src/SB/Game/zNPCTypeCommon.cpp b/src/SB/Game/zNPCTypeCommon.cpp index a9ec0ae5..bb7d6973 100644 --- a/src/SB/Game/zNPCTypeCommon.cpp +++ b/src/SB/Game/zNPCTypeCommon.cpp @@ -754,7 +754,7 @@ S32 zNPCCommon::NPCMessage(NPCMsg* mail) void zNPCCommon::Move(xScene* xscn, F32 dt, xEntFrame* frm) { bool retval = false; - if ((npcset.useNavSplines) && ((flg_move)&8)) + if ((npcset.useNavSplines) && ((flg_move) & 8)) if (this->drv_data && (this->drv_data->driver || this->drv_data->odriver)) { retval = true; @@ -889,7 +889,7 @@ S32 zNPCCommon::SysEvent(xBase* from, xBase* to, U32 toEvent, const F32* toParam xPsyche* psy = this->psy_instinct; if (psy) { - psy->GoalNone(1); + psy->GoalNone(1, 1); } break; } @@ -2433,7 +2433,7 @@ void zNPCCommon_WonderReset() U32 zNPCCommon::CanDoSplines() { bool retval = false; - if ((npcset.useNavSplines) && ((flg_move)&8)) + if ((npcset.useNavSplines) && ((flg_move) & 8)) { retval = true; } @@ -3199,26 +3199,6 @@ void xNPCBasic::Render() xEntRender(this); } -void xPsyche::ImmTranOn() -{ - flg_psyche |= 1; -} - -void xPsyche::ImmTranOff() -{ - flg_psyche &= 0xfffffffe; -} - -S32 xPsyche::ImmTranIsOn() -{ - return flg_psyche & 1; -} - -S32 xPsyche::HasGoal(S32 goal) -{ - return FindGoal(goal) != NULL; -} - U32 xSndIsPlaying(U32 assetID, U32 parid) { return iSndIsPlaying(assetID, parid);