From 56282843a829b169f803ed3ccc11d8abebb2127e Mon Sep 17 00:00:00 2001 From: intns <84647527+intns@users.noreply.github.com> Date: Mon, 11 Sep 2023 04:37:50 +0100 Subject: [PATCH] Name all of cellPyramid and PikiState progress --- include/Game/Creature.h | 2 +- include/Game/PikiState.h | 68 +- include/Game/cellPyramid.h | 40 +- src/plugProjectKandoU/aiBattle.cpp | 2 +- src/plugProjectKandoU/cellIterator.cpp | 26 +- src/plugProjectKandoU/cellPyramid.cpp | 816 ++++++------------ src/plugProjectKandoU/navi_demoCheck.cpp | 4 +- src/plugProjectKandoU/piki.cpp | 2 +- src/plugProjectKandoU/pikiState.cpp | 143 +-- src/plugProjectMorimuraU/bombState.cpp | 2 +- src/plugProjectNishimuraU/BigTreasure.cpp | 2 +- .../BigTreasureAttack.cpp | 2 +- src/plugProjectNishimuraU/ElecHiba.cpp | 2 +- src/plugProjectNishimuraU/Fart.cpp | 2 +- src/plugProjectNishimuraU/Fuefuki.cpp | 2 +- src/plugProjectNishimuraU/GasHiba.cpp | 2 +- src/plugProjectNishimuraU/Hiba.cpp | 2 +- src/plugProjectNishimuraU/ImomushiState.cpp | 2 +- src/plugProjectNishimuraU/Kabuto.cpp | 2 +- src/plugProjectNishimuraU/OtakaraBase.cpp | 2 +- src/plugProjectNishimuraU/Queen.cpp | 2 +- src/plugProjectNishimuraU/Tank.cpp | 2 +- 22 files changed, 400 insertions(+), 729 deletions(-) diff --git a/include/Game/Creature.h b/include/Game/Creature.h index 8ca589bca..354629c5e 100644 --- a/include/Game/Creature.h +++ b/include/Game/Creature.h @@ -386,7 +386,7 @@ struct Creature : public CellObject { CollPart* mStuckCollPart; // _0F8 Creature* mCaptured; // _0FC Creature* mCapture; // _100 - Vector3f _104; // _104 + Vector3f mClimbingPosition; // _104 s16 mHasStick; // _110 CollTree* mCollTree; // _114 f32 mMass; // _118 diff --git a/include/Game/PikiState.h b/include/Game/PikiState.h index 6679a9f64..a36b8f3ac 100644 --- a/include/Game/PikiState.h +++ b/include/Game/PikiState.h @@ -111,10 +111,10 @@ struct PikiAbsorbState : public PikiState { // _00 = VTBL // _00-_10 = PikiState - u8 _10; // _10 - Creature* _14; // _14 - u8 _18; // _18 - u8 _19; // _19 + u8 mState; // _10 + Creature* mAbsorbingCreature; // _14 + u8 mHasAbsorbed; // _18 + u8 mAbsorbTimer; // _19 }; struct PikiAutoNukiState : public PikiState { @@ -131,25 +131,25 @@ struct PikiAutoNukiState : public PikiState { // _00 = VTBL // _00-_10 = PikiState - f32 _10; // _10 - u16 _14; // _14 + f32 mTimer; // _10 + u16 mState; // _14 }; struct BlowStateArg : public StateArg { inline BlowStateArg(Vector3f& vec, f32 p1, u8 lethal, u16 p3, Creature* creature) { - _00 = vec; - _0C = p1; - mIsLethal = lethal; - _12 = p3; - _14 = creature; + mBlowDirection = vec; + mChanceToLeaf = p1; + mIsLethal = lethal; + _12 = p3; + mHeldNavi = creature; } - Vector3f _00; // _00 - f32 _0C; // _0C - bool mIsLethal; // _10 - u16 _12; // _12 - Creature* _14; // _14 + Vector3f mBlowDirection; // _00 + f32 mChanceToLeaf; // _0C + bool mIsLethal; // _10 + u16 _12; // _12 + Creature* mHeldNavi; // _14 }; struct PikiBlowState : public PikiState { @@ -174,13 +174,13 @@ struct PikiBlowState : public PikiState { // _00 = VTBL // _00-_10 = PikiState - int mState; // _10 - Creature* _14; // _14 - Vector3f _18; // _18 - f32 _24; // _24 - bool mIsWhistled; // _28 - bool mIsLethal; // _29 - u16 _2A; // _2A + int mState; // _10 + Creature* mHeldNavi; // _14 + Vector3f mBlowDirection; // _18 + f32 mChanceToLeaf; // _24 + bool mIsWhistled; // _28 + bool mIsLethal; // _29 + u16 _2A; // _2A }; struct PikiCarrotState : public PikiState { @@ -770,14 +770,14 @@ struct SuikomiStateArg : public StateArg { inline SuikomiStateArg(Creature* c, CollPart* p3, CollPart* p2) { - mCreature = c; - _04 = p3; - _08 = p2; + mCreature = c; + mCollpart = p3; + mStomachCollpart = p2; } - Creature* mCreature; // _00 - CollPart* _04; // _04 - CollPart* _08; // _08 + Creature* mCreature; // _00 + CollPart* mCollpart; // _04 + CollPart* mStomachCollpart; // _08 }; struct PikiSuikomiState : public PikiState { @@ -799,11 +799,11 @@ struct PikiSuikomiState : public PikiState { // _00 = VTBL // _00-_10 = PikiState - u8 _10; // _10 - Creature* mCreature; // _14 - CollPart* mCollpart; // _18 - CollPart* _1C; // _1C - f32 _20; // _20 + u8 mState; // _10 + Creature* mCreature; // _14 + CollPart* mCollpart; // _18 + CollPart* mStomachCollpart; // _1C + f32 mTimer; // _20 }; struct SwallowedStateArg : public StateArg { diff --git a/include/Game/cellPyramid.h b/include/Game/cellPyramid.h index 088c086de..cc9c440c1 100644 --- a/include/Game/cellPyramid.h +++ b/include/Game/cellPyramid.h @@ -93,19 +93,17 @@ struct Cell { void appendList(); void remove(); void exit(CellLeg*, bool); - void entry(CellLeg*, bool); - - Cell* _00[4]; // _00 - Cell* _10; // _10 - u16 _14; // _14 - u16 _16; // _16 - u16 _18; // _18 - u8 _1A[2]; // _1A - CellLeg* mLeg; // _1C - Cell* _20; // _20 - Cell* _24; // _24 - short _28; // _28 - u8 _2A[2]; // _2A + void entry(CellLeg* leg, bool isPikiOrNavi); + + Cell* mNeighboringCells[4]; // _00 + Cell* mHeadCell; // _10 + u16 mLocalPikiNaviCount; // _14 + u16 mTotalPikiNaviCount; // _16 + u16 mTotalObjectCount; // _18 + CellLeg* mLeg; // _1C + Cell* mNextCell; // _20 + Cell* mPrevCell; // _24 + short mLayerIdx; // _28 static CellPyramid* sCurrCellMgr; }; @@ -165,12 +163,12 @@ struct CellLayer { void assertExtent(Recti&) const; void checkPoint(Vector2i&) const; - u16 mSizeX; // _00 - u16 mSizeY; // _02 - u16 _04; // _04 - u16 _06; // _06 - Cell* mCells; // _08 - Cell mCell; // _0C // maybe this is a Cell? + u16 mSizeX; // _00 + u16 mSizeY; // _02 + u16 mLayerSize; // _04 + u16 mLayerIdx; // _06 + Cell* mCells; // _08 + Cell mCell; // _0C }; struct CellPyramid : public SweepPrune::World { @@ -223,9 +221,9 @@ struct CellIteratorArg { Sys::Sphere mSphere; // _00 CellIteratorCondition* mCondition; // _10, this is a ptr to something with a vtable, and 0x8 of vtable returns a bool ._. - int mUseCustomRadiusThreshold; // _14, UNUSED but a name is better than nothing + int mUseCustomRadius; // _14, UNUSED but a name is better than nothing CellPyramid* mCellMgr; // _18 - bool mIsCollSphereDisabled; // _1C, if false, will calc overlapping bounding spheres rather than just "in cell or no" + bool mIsSphereCollisionDisabled; // _1C, if false, will calc overlapping bounding spheres rather than just "in cell or no" u8 _1D; // _1D, set to 0 and unused }; diff --git a/src/plugProjectKandoU/aiBattle.cpp b/src/plugProjectKandoU/aiBattle.cpp index 0b120f509..f6f340475 100644 --- a/src/plugProjectKandoU/aiBattle.cpp +++ b/src/plugProjectKandoU/aiBattle.cpp @@ -182,7 +182,7 @@ void ActBattle::init(PikiAI::ActionArg* arg) Vector3f midPoint = (mParent->getPosition() + mOther->getPosition()) * 0.5f; Sys::Sphere itSphere(midPoint, 10.0f); Game::CellIteratorArg citArg(itSphere); - citArg.mIsCollSphereDisabled = false; + citArg.mIsSphereCollisionDisabled = false; Game::CellIterator cellIt(citArg); CI_LOOP(cellIt) diff --git a/src/plugProjectKandoU/cellIterator.cpp b/src/plugProjectKandoU/cellIterator.cpp index 555ba47cb..c01649bb2 100644 --- a/src/plugProjectKandoU/cellIterator.cpp +++ b/src/plugProjectKandoU/cellIterator.cpp @@ -9,16 +9,16 @@ namespace Game { */ CellIteratorArg::CellIteratorArg() { - mCondition = nullptr; - mUseCustomRadiusThreshold = 0; + mCondition = nullptr; + mUseCustomRadius = 0; mSphere.mPosition = Vector3f(0.0f); mSphere.mRadius = 0.0f; mCellMgr = cellMgr; - _1D = 0; - mIsCollSphereDisabled = false; + _1D = 0; + mIsSphereCollisionDisabled = false; } /* @@ -29,12 +29,12 @@ CellIteratorArg::CellIteratorArg() */ CellIteratorArg::CellIteratorArg(Sys::Sphere& sphere) { - mSphere = sphere; - mCondition = nullptr; - mUseCustomRadiusThreshold = 0; - mCellMgr = Game::cellMgr; - _1D = 0; - mIsCollSphereDisabled = false; + mSphere = sphere; + mCondition = nullptr; + mUseCustomRadius = 0; + mCellMgr = Game::cellMgr; + _1D = 0; + mIsSphereCollisionDisabled = false; } /* @@ -188,8 +188,8 @@ bool CellIterator::satisfy() Sys::Sphere boundingSphere; obj->getBoundingSphere(boundingSphere); - if (!mArg.mIsCollSphereDisabled) { - if (!mArg.mUseCustomRadiusThreshold) { + if (!mArg.mIsSphereCollisionDisabled) { + if (!mArg.mUseCustomRadius) { f32 radius = mArg.mSphere.mRadius + boundingSphere.mRadius; radius *= radius; if (sqrDistanceXZ(objPos, mArg.mSphere.mPosition) > radius) { @@ -338,7 +338,7 @@ void CellIterator::calcExtent() f32 a = mArg.mCellMgr->mRight; f32 b = mArg.mCellMgr->mLeft; - f32 norm = 1.0f / (mgr->mScale * mgr->mLayers[mCurrLayerIdx]._04); + f32 norm = 1.0f / (mgr->mScale * mgr->mLayers[mCurrLayerIdx].mLayerSize); mMinX = (x - r - a) * norm; mMinY = (z - r - b) * norm; diff --git a/src/plugProjectKandoU/cellPyramid.cpp b/src/plugProjectKandoU/cellPyramid.cpp index 4be72b38d..1418221af 100644 --- a/src/plugProjectKandoU/cellPyramid.cpp +++ b/src/plugProjectKandoU/cellPyramid.cpp @@ -75,18 +75,18 @@ void CellObject::exitCell() */ Cell::Cell() { - _00[3] = nullptr; - _00[2] = nullptr; - _00[1] = nullptr; - _00[0] = nullptr; - mLeg = nullptr; - _10 = nullptr; - _14 = 0; - _16 = 0; - _18 = 0; - _24 = nullptr; - _20 = nullptr; - _28 = -1; + mNeighboringCells[3] = nullptr; + mNeighboringCells[2] = nullptr; + mNeighboringCells[1] = nullptr; + mNeighboringCells[0] = nullptr; + mLeg = nullptr; + mHeadCell = nullptr; + mLocalPikiNaviCount = 0; + mTotalPikiNaviCount = 0; + mTotalObjectCount = 0; + mPrevCell = nullptr; + mNextCell = nullptr; + mLayerIdx = -1; } /* @@ -96,8 +96,8 @@ Cell::Cell() */ void Cell::clear() { - mLeg = nullptr; - _18 = 0; + mLeg = nullptr; + mTotalObjectCount = 0; } /* @@ -113,12 +113,12 @@ void Cell::mapSearch(IDelegate1* delegate, u32 passID) delegate->invoke(leg->mObject); } } - for (Cell* cell = _10; cell != nullptr; cell = cell->_10) { + for (Cell* cell = mHeadCell; cell != nullptr; cell = cell->mHeadCell) { cell->mapSearchUp(delegate, passID); } for (int cellIndex = 0; cellIndex < 4; cellIndex++) { - if (_00[cellIndex]) { - _00[cellIndex]->mapSearchDown(delegate, passID); + if (mNeighboringCells[cellIndex]) { + mNeighboringCells[cellIndex]->mapSearchDown(delegate, passID); } } } @@ -139,7 +139,7 @@ void Cell::mapSearchUp(IDelegate1* delegate, u32 passID) delegate->invoke(leg->mObject); } } - for (Cell* cell = _10; cell != nullptr; cell = cell->_10) { + for (Cell* cell = mHeadCell; cell != nullptr; cell = cell->mHeadCell) { cell->mapSearchUp(delegate, passID); } } @@ -158,8 +158,8 @@ void Cell::mapSearchDown(IDelegate1* delegate, u32 passID) } } for (int cellIndex = 0; cellIndex < 4; cellIndex++) { - if (_00[cellIndex]) { - _00[cellIndex]->mapSearchDown(delegate, passID); + if (mNeighboringCells[cellIndex]) { + mNeighboringCells[cellIndex]->mapSearchDown(delegate, passID); } } } @@ -542,7 +542,7 @@ void CellPyramid::resolveCollision() CellLayer* layer = &mLayers[mLayerCount - 1]; for (int i = 0; i < layer->mSizeX * layer->mSizeY; i++) { Cell* cell = &layer->mCells[i]; - if (cell->_18 != 0) { + if (cell->mTotalObjectCount != 0) { cell->rec_resolveColl(); } } @@ -551,16 +551,16 @@ void CellPyramid::resolveCollision() case 2: if (sSpeedUpResolveColl) { for (int i = 0; i < mLayerCount; i++) { - for (Cell* cell = mLayers[i].mCell._20; cell != nullptr; cell = cell->_20) { - if (cell->_18 != 0) { + for (Cell* cell = mLayers[i].mCell.mNextCell; cell != nullptr; cell = cell->mNextCell) { + if (cell->mTotalObjectCount != 0) { cell->resolveCollision_3(); } } } } else { for (int i = 0; i < mLayerCount; i++) { - for (Cell* cell = mLayers[i].mCell._20; cell != nullptr; cell = cell->_20) { - if (cell->_18 != 0) { + for (Cell* cell = mLayers[i].mCell.mNextCell; cell != nullptr; cell = cell->mNextCell) { + if (cell->mTotalObjectCount != 0) { cell->resolveCollision_1(); } } @@ -580,8 +580,8 @@ void CellPyramid::resolveCollision() inline void Cell::rec_resolveColl() { for (int i = 0; i < 4; i++) { - if ((_00[i] != nullptr) && (1 < _00[i]->_18)) { - _00[i]->rec_resolveColl(); + if ((mNeighboringCells[i] != nullptr) && (1 < mNeighboringCells[i]->mTotalObjectCount)) { + mNeighboringCells[i]->rec_resolveColl(); } } @@ -667,44 +667,57 @@ inline void Cell::remove() * Address: 801578B8 * Size: 000158 */ -inline void Cell::exit(CellLeg* aLeg, bool p2) +inline void Cell::exit(CellLeg* exitingLeg, bool isPikiOrNavi) { - if (mLeg == aLeg) { - mLeg = aLeg->mNext; + // If the exiting leg is the current leg, update the current leg + if (mLeg == exitingLeg) { + mLeg = exitingLeg->mNext; if (mLeg) { mLeg->mPrev = nullptr; } } - if ((p2) && (_14 != 0)) { - _14--; - for (Cell* iCell = _10; iCell != nullptr; iCell = iCell->_10) { - iCell->_16--; + + // If the exiting object is a Piki or Navi, update the local and total counts + if ((isPikiOrNavi) && (mLocalPikiNaviCount != 0)) { + mLocalPikiNaviCount--; + for (Cell* currentCell = mHeadCell; currentCell != nullptr; currentCell = currentCell->mHeadCell) { + currentCell->mTotalPikiNaviCount--; } } - _18--; - for (Cell* iCell = _10; iCell != nullptr; iCell = iCell->_10) { - iCell->_18--; + + // Decrease the total object count for this cell and all cells above it + mTotalObjectCount--; + for (Cell* currentCell = mHeadCell; currentCell != nullptr; currentCell = currentCell->mHeadCell) { + currentCell->mTotalObjectCount--; } - CellLeg* leg = aLeg->mPrev; - if (leg) { - leg->mNext = aLeg->mNext; + + // Update the previous leg's next leg if it exists + CellLeg* previousLeg = exitingLeg->mPrev; + if (previousLeg) { + previousLeg->mNext = exitingLeg->mNext; } - leg = aLeg->mNext; - if (leg) { - leg->mPrev = aLeg->mPrev; + + // Update the next leg's previous leg if it exists + CellLeg* nextLeg = exitingLeg->mNext; + if (nextLeg) { + nextLeg->mPrev = exitingLeg->mPrev; } - aLeg->mPrev = nullptr; - aLeg->mNext = nullptr; + + // Clear the exiting leg's previous and next legs + exitingLeg->mPrev = nullptr; + exitingLeg->mNext = nullptr; + + // If there are no more legs and a current cell manager exists, remove this cell from the cell list if ((mLeg == nullptr) && (Cell::sCurrCellMgr != nullptr)) { P2ASSERTLINE(786, Cell::sCurrCellMgr != nullptr); - if (_24) { - _24->_20 = _20; - if (_20) { - _20->_24 = _24; + if (mPrevCell) { + mPrevCell->mNextCell = mNextCell; + if (mNextCell) { + mNextCell->mPrevCell = mPrevCell; } } - _24 = nullptr; - _20 = nullptr; + mPrevCell = nullptr; + mNextCell = nullptr; } } @@ -713,14 +726,16 @@ inline void Cell::exit(CellLeg* aLeg, bool p2) * Address: 80157A10 * Size: 0002EC */ -void Cell::entry(CellLeg* leg, bool p2) +void Cell::entry(CellLeg* leg, bool isPikiOrNavi) { P2ASSERTLINE(836, leg != nullptr); if (leg->mCell) { - leg->mCell->exit(leg, p2); + leg->mCell->exit(leg, isPikiOrNavi); } + CellLeg* nextLeg; CellLeg* currLeg = mLeg; + if (currLeg) { if (currLeg != leg) { nextLeg = currLeg->mNext; @@ -737,39 +752,41 @@ void Cell::entry(CellLeg* leg, bool p2) mLeg->mPrev = nullptr; } - leg->mCell = this; + leg->mCell = this; + bool legCheck = mLeg->findLeg(leg); if (!legCheck) { JUT_PANICLINE(855, "leg entry failed !\n"); } - if (p2) { - _14++; - Cell* currCell1 = _10; - for (currCell1; currCell1; currCell1 = currCell1->_10) { - currCell1->_16++; + if (isPikiOrNavi) { + mLocalPikiNaviCount++; + + for (Cell* c = mHeadCell; c; c = c->mHeadCell) { + c->mTotalPikiNaviCount++; } } - _18++; - Cell* currCell2 = _10; - for (currCell2; currCell2; currCell2 = currCell2->_10) { - currCell2->_18++; + mTotalObjectCount++; + for (Cell* c = mHeadCell; c; c = c->mHeadCell) { + c->mTotalObjectCount++; } - Cell* currCell3 = _24; + Cell* currCell3 = mPrevCell; if (!currCell3 && Cell::sCurrCellMgr) { P2ASSERTLINE(763, Cell::sCurrCellMgr); - Cell* layerCell = &Cell::sCurrCellMgr->mLayers[_28].mCell; - Cell* nextCell = layerCell->_20; + + Cell* layerCell = &Cell::sCurrCellMgr->mLayers[mLayerIdx].mCell; + Cell* nextCell = layerCell->mNextCell; + if (nextCell) { - _20 = nextCell; - _20->_24 = this; - _24 = layerCell; - layerCell->_20 = this; + mNextCell = nextCell; + mNextCell->mPrevCell = this; + mPrevCell = layerCell; + layerCell->mNextCell = this; } else { - layerCell->_20 = this; - _24 = layerCell; + layerCell->mNextCell = this; + mPrevCell = layerCell; } } } @@ -782,11 +799,11 @@ void Cell::entry(CellLeg* leg, bool p2) inline void CellLayer::clear() { // UNUSED FUNCTION - mCell._20 = nullptr; - mCell._24 = nullptr; + mCell.mNextCell = nullptr; + mCell.mPrevCell = nullptr; for (int i = 0; i < mSizeX * mSizeY; i++) { mCells[i].clear(); - mCells[i]._28 = _06; + mCells[i].mLayerIdx = mLayerIdx; } } @@ -1460,503 +1477,158 @@ void CellPyramid::entry(CellObject* object, Sys::Sphere& sphere) */ // void entry__Q24Game11CellPyramidFPQ24Game10CellObjectRQ23Sys6SphereRiR7Rect< // int>() -void CellPyramid::entry(CellObject* param_1, Sys::Sphere& param_2, int& param_3, Recti& param_4) +void CellPyramid::entry(CellObject* object, Sys::Sphere& sphere, int& layerIndex, Recti& boundingRect) { Cell::sCurrCellMgr = this; - float dVar19 = log10(param_2.mRadius * 2.0f * mInverseScale); - float dVar18 = log10(2.0f); - float dVar17 = (dVar19 / dVar18); - // if (dVar17 < 0.0) { - // dVar17 = 0.0; - // } - int iVar9 = (int)ceil(MAX(dVar17, 0.0f)); - if (mLayerCount <= iVar9) { - iVar9 = mLayerCount - 1; + + float sphereRadiusLog = log10(sphere.mRadius * 2.0f * mInverseScale); + float log2 = log10(2.0f); + float layerIndexFloat = (sphereRadiusLog / log2); + + // Ensure the layer is non-negative + if (layerIndexFloat < 0.0f) { + layerIndexFloat = 0.0f; } - float fVar10 = param_2.mRadius; - float fVar11 = (param_2.mPosition).x; - float fVar1 = (param_2.mPosition).z; - float fVar2 = mRight; - float fVar3 = mLeft; - float fVar4 = 1.0f / ((mLayers[iVar9]._04) * mScale); // <--- SHORT_TO_FLOAT - param_4.p1.x = (int)(((fVar11 - fVar10) - fVar2) * fVar4); - param_4.p1.y = (int)(((fVar1 - fVar10) - fVar3) * fVar4); - param_4.p2.x = (int)(((fVar11 + fVar10) - fVar2) * fVar4); - param_4.p2.y = (int)(((fVar1 + fVar10) - fVar3) * fVar4); - param_3 = iVar9; - iVar9 = param_3; - if ((iVar9 < 0) || (mLayerCount <= iVar9)) { - JUT_PANICLINE(1206, "illegal layerLevel %d : out of bounds 0ã€?%d\n", iVar9, mLayerCount); + + layerIndex = (int)ceil(MAX(layerIndexFloat, 0.0f)); + + // Ensure that layerIndex is within bounds + if (mLayerCount <= layerIndex) { + layerIndex = mLayerCount - 1; } - int iVar12 = 0; - bool bVar5 = false; - CellLayer* layer = &mLayers[iVar9]; - bool bVar7 = param_1->isPiki(); - if ((bVar7 != false) || (bVar7 = param_1->isNavi(), bVar7 != false)) { - iVar12 = 1; - bVar5 = true; + + float sphereRadius = sphere.mRadius; + float sphereX = sphere.mPosition.x; + float sphereZ = sphere.mPosition.z; + float rightBoundary = mRight; + float leftBoundary = mLeft; + float inverseScaleFactor = 1.0f / ((mLayers[layerIndex].mLayerSize) * mScale); + + // Calculate the bounding rectangle + boundingRect.p1.x = (int)(((sphereX - sphereRadius) - rightBoundary) * inverseScaleFactor); + boundingRect.p1.y = (int)(((sphereZ - sphereRadius) - leftBoundary) * inverseScaleFactor); + boundingRect.p2.x = (int)(((sphereX + sphereRadius) - rightBoundary) * inverseScaleFactor); + boundingRect.p2.y = (int)(((sphereZ + sphereRadius) - leftBoundary) * inverseScaleFactor); + + // Update the layerIndex + layerIndex = layerIndex; + + // Check if layerIndex is out of bounds + if ((layerIndex < 0) || (mLayerCount <= layerIndex)) { + JUT_PANICLINE(1206, "illegal layerLevel %d : out of bounds 0`%d\n", layerIndex, mLayerCount); } - iVar9 = 0; - // for (iVar9 = 0; iVar9 < 4; iVar9++) { - // Cell* cell = param_1->mCellLegs.arrayView[iVar9].mCell; - // if (cell) { - // cell->exit(¶m_1->mCellLegs.arrayView[iVar9], bVar5); - // // if (cell->mLeg == ¶m_1.mCellLegs.arrayView[iVar9]) { - // // cell->mLeg = - // // param_1.mCellLegs.arrayView[iVar9].mNext; if - // // (cell->mLeg - // // ) { cell->mLeg->mPrev = nullptr; - // // } - // // } - // // if ((bVar5) && (cell->_14 != 0)) { - // // cell->_14--; - // // for (Cell* iCell = cell->_10; iCell != nullptr; - // // iCell = iCell->_10) { iCell->_16--; - // // } - // // } - // // cell->_18--; - // // for (Cell* iCell = cell->_10; iCell != nullptr; iCell = - // // iCell->_10) { iCell->_18--; - // // } - // // CellLeg* leg = - // // param_1.mCellLegs.arrayView[iVar9].mPrev; if (leg != - // // nullptr) { leg->mNext = - // // param_1.mCellLegs.arrayView[iVar9].mNext; - // // } - // // leg = param_1.mCellLegs.arrayView[iVar9].mNext; - // // if (leg ) { - // // leg->mPrev = - // // param_1.mCellLegs.arrayView[iVar9].mPrev; - // // } - // // param_1.mCellLegs.arrayView[iVar9].mPrev = nullptr; - // // param_1.mCellLegs.arrayView[iVar9].mNext = nullptr; - // // if ((cell->mLeg == nullptr) && - // // (Cell::sCurrCellMgr != nullptr)) { - // // if (Cell::sCurrCellMgr == nullptr) { - // // // #ifdef MATCHING - // // // HMM... why is this so much earlier... - // // #line 786 - // // // #endif - // // P2ASSERT(Cell::sCurrCellMgr != nullptr); - // // } - // // if (cell->_24 ) { - // // cell->_24->_20 = cell->_20; - // // if (cell->_20 ) { - // // cell->_20->_24 = cell->_24; - // // } - // // } - // // cell->_24 = nullptr; - // // cell->_20 = nullptr; - // // } - // param_1->mCellLegs.arrayView[iVar9].mCell = nullptr; - // } - // } - iVar9 = 0; + + int objectLayerIndex = 0; + bool isPikiOrNavi = false; + CellLayer* currentLayer = &mLayers[layerIndex]; + bool isPiki = object->isPiki(); + + if ((isPiki != false) || (isPiki = object->isNavi(), isPiki != false)) { + objectLayerIndex = 1; + isPikiOrNavi = true; + } + + layerIndex = objectLayerIndex; + + for (int i = 0; i < 4; i++) { + Cell* cell = object->mCellLegs->mCell; + + if (cell) { + cell->exit(object->mCellLegs, isPikiOrNavi); + + if (cell->mLeg == object->mCellLegs) { + cell->mLeg = object->mCellLegs->mNext; + + if (cell->mLeg) { + cell->mLeg->mPrev = nullptr; + } + } + + if (isPikiOrNavi && cell->mLocalPikiNaviCount != 0) { + cell->mLocalPikiNaviCount--; + + for (Cell* iCell = cell->mHeadCell; iCell != nullptr; iCell = iCell->mHeadCell) { + iCell->mTotalPikiNaviCount--; + } + } + + cell->mTotalObjectCount--; + for (Cell* iCell = cell->mHeadCell; iCell != nullptr; iCell = iCell->mHeadCell) { + iCell->mTotalObjectCount--; + } + + CellLeg* leg = object->mCellLegs->mPrev; + + if (leg != nullptr) { + leg->mNext = object->mCellLegs->mNext; + } + + leg = object->mCellLegs->mNext; + + if (leg) { + leg->mPrev = object->mCellLegs->mPrev; + } + + object->mCellLegs->mPrev = nullptr; + object->mCellLegs->mNext = nullptr; + + if (cell->mLeg == nullptr && Cell::sCurrCellMgr != nullptr) { + if (cell->mPrevCell) { + cell->mPrevCell->mNextCell = cell->mNextCell; + + if (cell->mNextCell) { + cell->mNextCell->mPrevCell = cell->mPrevCell; + } + } + + cell->mPrevCell = nullptr; + cell->mNextCell = nullptr; + } + + object->mCellLegs->mCell = nullptr; + } + } + + // int iVar9 = 0; + // if (10 < (param_4.p2.x - param_4.p1.x) * (param_4.p2.y - param_4.p1.y)) { + // for (int cellX = param_4.p1.x; cellX <= param_4.p2.x; cellX++) { + // for (int cellY = param_4.p1.y; cellY <= param_4.p2.y; cellY++) { + // Cell* cell = nullptr; - // for (int cellX = param_4.p1.x; cellX <= param_4.p2.x; cellX++) { - // for (int cellY = param_4.p1.y; cellY <= param_4.p2.y; cellY++) { - // Cell* cell; - // if ((cellX < 0) || (cellY < 0) || (layer->mSizeX <= cellX) || (layer->mSizeY <= cellY)) { - // cell = nullptr; - // } else { - // cell = &layer->mCells[cellX + (cellY * layer->mSizeX)]; - // } - // if (cell) { - // if (3 < iVar9) - // goto LAB_801589e8; - // cell->entry(param_1.mCellLegs.arrayView, SUB41((uint)-iVar12 >> 0x1f, 0)); - // for (pCVar6 = cell->mLeg; pCVar6 != (CellLeg*)0x0; pCVar6 = pCVar6->pNext) { - // if (pCVar6 == param_1->mCellLegs) { - // bVar5 = true; - // goto LAB_80158994; - // } + // if (cellX >= 0 && cellY >= 0 && cellX < layer->mSizeX && cellY < layer->mSizeY) { + // cell = &layer->mCells[cellX + (cellY * layer->mSizeX)]; // } - // bVar5 = false; - // LAB_80158994: - // if (!bVar5) { - // /* WARNING: Subroutine does not return */ - // // JUTException::panic_f("cellPyramid.cpp", 0x59f, "leg entry failed !!!!!!!!!!\n"); - // } - // } - // param_1 = (CellObject*)&(param_1->sweepPruneObject).minX.flags; - // param_1 = (CellObject*)&(param_1->sweepPruneObject).minX.flags; - // iVar9 += 1; - // } - // } - /* - .loc_0x0: - stwu r1, -0x80(r1) - mflr r0 - stw r0, 0x84(r1) - stfd f31, 0x70(r1) - psq_st f31,0x78(r1),0,0 - stfd f30, 0x60(r1) - psq_st f30,0x68(r1),0,0 - stmw r22, 0x38(r1) - mr r25, r3 - lis r3, 0x8048 - stw r25, -0x6D28(r13) - mr r26, r5 - lfs f2, -0x5D18(r2) - mr r24, r4 - lfs f1, 0xC(r5) - mr r22, r6 - lfs f0, 0x38(r25) - mr r23, r7 - fmuls f2, f2, f1 - lfd f1, -0x5D10(r2) - subi r31, r3, 0x3020 - fmuls f31, f2, f0 - bl -0x88BC0 - frsp f30, f1 - fmr f1, f31 - bl -0x88BCC - frsp f1, f1 - lfs f0, -0x5D38(r2) - fdivs f1, f1, f30 - fcmpo cr0, f1, f0 - bge- .loc_0x80 - fmr f1, f0 - .loc_0x80: - bl -0x8948C - frsp f0, f1 - lwz r3, 0x2C(r25) - fctiwz f0, f0 - stfd f0, 0x8(r1) - lwz r5, 0xC(r1) - cmpw r5, r3 - blt- .loc_0xA4 - subi r5, r3, 0x1 - - .loc_0xA4: - mulli r3, r5, 0x38 - lis r0, 0x4330 - lwz r4, 0x30(r25) - stw r0, 0x10(r1) - addi r0, r3, 0x4 - lfd f2, -0x5D28(r2) - lhzx r0, r4, r0 - lfs f1, 0x34(r25) - stw r0, 0x14(r1) - lfs f3, -0x5D08(r2) - lfd f0, 0x10(r1) - lfs f6, 0xC(r26) - fsubs f2, f0, f2 - lfs f4, 0x0(r26) - lfs f7, 0x8(r26) - fsubs f0, f4, f6 - lfs f9, 0x40(r25) - fmuls f1, f2, f1 - fadds f2, f4, f6 - lfs f8, 0x3C(r25) - fsubs f4, f7, f6 - fdivs f5, f3, f1 - fsubs f1, f0, f9 - fsubs f3, f4, f8 - fadds f0, f7, f6 - fmuls f1, f1, f5 - fsubs f4, f2, f9 - fmuls f2, f3, f5 - fctiwz f3, f1 - fsubs f0, f0, f8 - fmuls f1, f4, f5 - fctiwz f2, f2 - stfd f3, 0x18(r1) - fmuls f0, f0, f5 - fctiwz f1, f1 - lwz r0, 0x1C(r1) - stfd f2, 0x20(r1) - fctiwz f0, f0 - stfd f1, 0x28(r1) - lwz r3, 0x24(r1) - stw r0, 0x0(r23) - lwz r0, 0x2C(r1) - stw r3, 0x4(r23) - stfd f0, 0x30(r1) - stw r0, 0x8(r23) - lwz r0, 0x34(r1) - stw r0, 0xC(r23) - stw r5, 0x0(r22) - lwz r6, 0x0(r22) - cmpwi r6, 0 - blt- .loc_0x17C - lwz r0, 0x2C(r25) - cmpw r6, r0 - blt- .loc_0x198 - - .loc_0x17C: - lwz r7, 0x2C(r25) - addi r3, r31, 0xC - addi r5, r31, 0x3C - li r4, 0x4B6 - crclr 6, 0x6 - bl -0x12E0A4 - b .loc_0x494 - - .loc_0x198: - mr r3, r24 - lwz r4, 0x30(r25) - lwz r12, 0x0(r24) - mulli r0, r6, 0x38 - li r25, 0 - lwz r12, 0x18(r12) - add r27, r4, r0 - mtctr r12 - bctrl - rlwinm. r0,r3,0,24,31 - bne- .loc_0x1E0 - mr r3, r24 - lwz r12, 0x0(r24) - lwz r12, 0x1C(r12) - mtctr r12 - bctrl - rlwinm. r0,r3,0,24,31 - beq- .loc_0x1E4 + // if (cell) { + // if (3 < iVar9) { + // goto LAB_801589e8; + // } - .loc_0x1E0: - li r25, 0x1 + // cell->entry(object->mCellLegs.arrayView, SUB41((uint)-iVar12 >> 0x1f, 0)); - .loc_0x1E4: - rlwinm r3,r25,0,24,31 - mr r29, r24 - neg r0, r3 - li r26, 0 - or r0, r0, r3 - rlwinm r30,r0,1,31,31 + // for (CellLeg* pCVar6 = cell->mLeg; pCVar6 != nullptr; pCVar6 = pCVar6->pNext) { + // if (pCVar6 == object->mCellLegs) { + // bVar5 = true; + // goto LAB_80158994; + // } + // } - .loc_0x1FC: - lwz r28, 0x5C(r29) - cmplwi r28, 0 - beq- .loc_0x33C - lwz r3, 0x1C(r28) - addi r0, r29, 0x54 - cmplw r3, r0 - bne- .loc_0x234 - lwz r0, 0x54(r29) - stw r0, 0x1C(r28) - lwz r3, 0x1C(r28) - cmplwi r3, 0 - beq- .loc_0x234 - li r0, 0 - stw r0, 0x4(r3) - - .loc_0x234: - cmplwi r30, 0 - beq- .loc_0x270 - lhz r3, 0x14(r28) - cmplwi r3, 0 - beq- .loc_0x270 - subi r0, r3, 0x1 - sth r0, 0x14(r28) - lwz r4, 0x10(r28) - b .loc_0x268 - - .loc_0x258: - lhz r3, 0x16(r4) - subi r0, r3, 0x1 - sth r0, 0x16(r4) - lwz r4, 0x10(r4) - - .loc_0x268: - cmplwi r4, 0 - bne+ .loc_0x258 - - .loc_0x270: - lhz r3, 0x18(r28) - subi r0, r3, 0x1 - sth r0, 0x18(r28) - lwz r4, 0x10(r28) - b .loc_0x294 - - .loc_0x284: - lhz r3, 0x18(r4) - subi r0, r3, 0x1 - sth r0, 0x18(r4) - lwz r4, 0x10(r4) - - .loc_0x294: - cmplwi r4, 0 - bne+ .loc_0x284 - lwz r3, 0x58(r29) - cmplwi r3, 0 - beq- .loc_0x2B0 - lwz r0, 0x54(r29) - stw r0, 0x0(r3) - - .loc_0x2B0: - lwz r3, 0x54(r29) - cmplwi r3, 0 - beq- .loc_0x2C4 - lwz r0, 0x58(r29) - stw r0, 0x4(r3) - - .loc_0x2C4: - li r0, 0 - stw r0, 0x58(r29) - stw r0, 0x54(r29) - lwz r0, 0x1C(r28) - cmplwi r0, 0 - bne- .loc_0x334 - lwz r0, -0x6D28(r13) - cmplwi r0, 0 - beq- .loc_0x334 - bne- .loc_0x300 - addi r3, r31, 0xC - addi r5, r31, 0x1C - li r4, 0x312 - crclr 6, 0x6 - bl -0x12E210 - - .loc_0x300: - lwz r3, 0x24(r28) - cmplwi r3, 0 - beq- .loc_0x328 - lwz r0, 0x20(r28) - stw r0, 0x20(r3) - lwz r3, 0x20(r28) - cmplwi r3, 0 - beq- .loc_0x328 - lwz r0, 0x24(r28) - stw r0, 0x24(r3) - - .loc_0x328: - li r0, 0 - stw r0, 0x24(r28) - stw r0, 0x20(r28) + // bVar5 = false; - .loc_0x334: - li r0, 0 - stw r0, 0x5C(r29) - - .loc_0x33C: - addi r26, r26, 0x1 - addi r29, r29, 0x14 - cmpwi r26, 0x4 - blt+ .loc_0x1FC - lwz r5, 0x0(r23) - li r26, 0 - lwz r4, 0x8(r23) - lwz r3, 0x4(r23) - lwz r0, 0xC(r23) - sub r4, r4, r5 - sub r0, r0, r3 - mullw r0, r4, r0 - cmpwi r0, 0xA - ble- .loc_0x38C - addi r3, r31, 0xC - addi r5, r31, 0x6C - li r4, 0x57D - crclr 6, 0x6 - bl -0x12E298 - b .loc_0x494 - - .loc_0x38C: - mr r25, r5 - mr r28, r24 - b .loc_0x480 - - .loc_0x398: - lwz r24, 0x4(r23) - mr r29, r28 - b .loc_0x470 - - .loc_0x3A4: - cmpwi r25, 0 - blt- .loc_0x3CC - cmpwi r24, 0 - blt- .loc_0x3CC - lhz r3, 0x0(r27) - cmpw r25, r3 - bge- .loc_0x3CC - lhz r0, 0x2(r27) - cmpw r24, r0 - blt- .loc_0x3D4 - - .loc_0x3CC: - li r22, 0 - b .loc_0x3E8 - - .loc_0x3D4: - mullw r0, r24, r3 - lwz r3, 0x8(r27) - add r0, r25, r0 - mulli r0, r0, 0x2C - add r22, r3, r0 - - .loc_0x3E8: - cmplwi r22, 0 - beq- .loc_0x460 - cmpwi r26, 0x4 - blt- .loc_0x404 - li r0, 0 - stw r0, -0x6D28(r13) - b .loc_0x494 - - .loc_0x404: - mr r3, r22 - mr r5, r30 - addi r4, r29, 0x54 - bl -0xF54 - lwz r3, 0x1C(r22) - addi r0, r29, 0x54 - b .loc_0x434 - - .loc_0x420: - cmplw r3, r0 - bne- .loc_0x430 - li r0, 0x1 - b .loc_0x440 - - .loc_0x430: - lwz r3, 0x0(r3) - - .loc_0x434: - cmplwi r3, 0 - bne+ .loc_0x420 - li r0, 0 + // LAB_80158994: + // if (!bVar5) { + // // Handle the case when leg entry fails (uncomment if needed) + // // JUTException::panic_f("cellPyramid.cpp", 0x59f, "leg entry failed !!!!!!!!!!\n"); + // } + // } - .loc_0x440: - rlwinm. r0,r0,0,24,31 - bne- .loc_0x460 - addi r3, r31, 0xC - addi r5, r31, 0x88 - li r4, 0x59F - crclr 6, 0x6 - bl -0x12E36C - b .loc_0x494 - - .loc_0x460: - addi r29, r29, 0x14 - addi r28, r28, 0x14 - addi r26, r26, 0x1 - addi r24, r24, 0x1 - - .loc_0x470: - lwz r0, 0xC(r23) - cmpw r24, r0 - ble+ .loc_0x3A4 - addi r25, r25, 0x1 - - .loc_0x480: - lwz r0, 0x8(r23) - cmpw r25, r0 - ble+ .loc_0x398 - li r0, 0 - stw r0, -0x6D28(r13) - - .loc_0x494: - psq_l f31,0x78(r1),0,0 - lfd f31, 0x70(r1) - psq_l f30,0x68(r1),0,0 - lfd f30, 0x60(r1) - lmw r22, 0x38(r1) - lwz r0, 0x84(r1) - mtlr r0 - addi r1, r1, 0x80 - blr - */ + // object = (CellObject*)&(object->sweepPruneObject).minX.flags; + // object = (CellObject*)&(object->sweepPruneObject).minX.flags; + // iVar9 += 1; + // } + // } + // } } /* @@ -1989,19 +1661,19 @@ void CellPyramid::create(BoundBox2d& box, float scale) int layerCount = (f32)ceil((f32)log10((f32)maxDimension) / (f32)log10(2.0f)); pow(2.0, (double)layerCount); - mLayerCount = layerCount + 1; - mLayers = new CellLayer[mLayerCount]; - mLayers[0].mSizeX = pixelWidth; - mLayers[0].mSizeY = pixelHeight; - mLayers[0]._04 = 0; - mLayers[0]._06 = 1; - mLayers[0].mCells = new Cell[mLayers[0].mSizeX * mLayers[0].mSizeY]; - mLayers[0].mCell._20 = nullptr; - mLayers[0].mCell._24 = nullptr; + mLayerCount = layerCount + 1; + mLayers = new CellLayer[mLayerCount]; + mLayers[0].mSizeX = pixelWidth; + mLayers[0].mSizeY = pixelHeight; + mLayers[0].mLayerSize = 0; + mLayers[0].mLayerIdx = 1; + mLayers[0].mCells = new Cell[mLayers[0].mSizeX * mLayers[0].mSizeY]; + mLayers[0].mCell.mNextCell = nullptr; + mLayers[0].mCell.mPrevCell = nullptr; for (int i = 0; i < mLayers[0].mSizeX * mLayers[0].mSizeY; i++) { mLayers[0].mCells[i].clear(); - mLayers[0].mCells[i]._28 = mLayers[0]._06; + mLayers[0].mCells[i].mLayerIdx = mLayers[0].mLayerIdx; } for (int i = 1; i < mLayerCount; i++) { @@ -2276,7 +1948,7 @@ int CellPyramid::getPikiCount(int layerLevel, Recti& extent) for (int y = extent.p1.y; y <= extent.p2.y; y++) { Cell* cell = (*layer)(x, y); if (cell) { - sum += cell->_14 + cell->_16; + sum += cell->mLocalPikiNaviCount + cell->mTotalPikiNaviCount; } } } @@ -2337,7 +2009,7 @@ void Cell::resolveCollision_2() legA->mObject->checkCollision(legB->mObject); } } - for (Cell* cell = _10; cell != nullptr; cell = cell->_10) { + for (Cell* cell = mHeadCell; cell != nullptr; cell = cell->mHeadCell) { for (CellLeg* legB = cell->mLeg; legB != nullptr; legB = legB->mNext) { if (legA->mObject->collisionUpdatable()) { legA->mObject->checkCollision(legB->mObject); @@ -2362,7 +2034,7 @@ void Cell::resolveCollision_1() legA->mObject->checkCollision(legB->mObject); } } - for (Cell* cell = _10; cell != nullptr; cell = cell->_10) { + for (Cell* cell = mHeadCell; cell != nullptr; cell = cell->mHeadCell) { for (CellLeg* legB = cell->mLeg; legB != nullptr; legB = legB->mNext) { // TODO: What is going on with mPassID? if ((legA->mObject != legB->mObject) && (legB->mObject->mPassID != (u32)legA->mObject)) { @@ -2403,7 +2075,7 @@ void Cell::resolveCollision_3() } } } - for (Cell* cell = _10; cell != nullptr; cell = cell->_10) { + for (Cell* cell = mHeadCell; cell != nullptr; cell = cell->mHeadCell) { for (CellLeg* legB = cell->mLeg; legB != nullptr; legB = legB->mNext) { if (legA->mObject != legB->mObject) { if (*CellMgrParms::getInstance()->mCellParms.mP001()) { diff --git a/src/plugProjectKandoU/navi_demoCheck.cpp b/src/plugProjectKandoU/navi_demoCheck.cpp index 0efa9f74c..c489682e8 100644 --- a/src/plugProjectKandoU/navi_demoCheck.cpp +++ b/src/plugProjectKandoU/navi_demoCheck.cpp @@ -2159,8 +2159,8 @@ FakePiki* Navi::checkDemoNaviAndPiki(Sys::Sphere& bounds) } CellIteratorArg arg; - arg.mSphere = bounds; - arg.mUseCustomRadiusThreshold = 1; + arg.mSphere = bounds; + arg.mUseCustomRadius = 1; CellIterator cell(arg); CI_LOOP(cell) { diff --git a/src/plugProjectKandoU/piki.cpp b/src/plugProjectKandoU/piki.cpp index 3b8c47b36..431656908 100644 --- a/src/plugProjectKandoU/piki.cpp +++ b/src/plugProjectKandoU/piki.cpp @@ -1522,7 +1522,7 @@ void Piki::do_updateLookCreature() Sys::Sphere sphere(mPosition3, 200.0f); CellIteratorArg iterArg(sphere); - iterArg.mUseCustomRadiusThreshold = 1; + iterArg.mUseCustomRadius = 1; CellIterator iter(iterArg); int counter = 0; CI_LOOP(iter) diff --git a/src/plugProjectKandoU/pikiState.cpp b/src/plugProjectKandoU/pikiState.cpp index db9d75762..a2b331aab 100644 --- a/src/plugProjectKandoU/pikiState.cpp +++ b/src/plugProjectKandoU/pikiState.cpp @@ -2145,10 +2145,10 @@ void PikiLookAtState::cleanup(Piki* piki) { } */ void PikiAutoNukiState::init(Piki* piki, StateArg* stateArg) { - _10 = 0.2f * randFloat(); - _14 = 0; + mTimer = 0.2f * randFloat(); + mState = 0; piki->startMotion(IPikiAnims::KAIFUKU2, IPikiAnims::KAIFUKU2, piki, nullptr); - _14 = 1; + mState = 1; Vector3f position = piki->getPosition(); Sys::Sphere sphere(position, 10.0f); WaterBox* wbox = piki->checkWater(nullptr, sphere); @@ -2174,13 +2174,13 @@ void PikiAutoNukiState::init(Piki* piki, StateArg* stateArg) */ void PikiAutoNukiState::exec(Piki* piki) { - switch (_14) { + switch (mState) { case 0: - _10 -= sys->mDeltaTime; - if (_10 < 0.0f) { - _10 = 0.0f; + mTimer -= sys->mDeltaTime; + if (mTimer < 0.0f) { + mTimer = 0.0f; piki->startMotion(IPikiAnims::KAIFUKU2, IPikiAnims::KAIFUKU2, piki, nullptr); - _14 = 1; + mState = 1; Vector3f position = piki->getPosition(); Sys::Sphere sphere(position, 10.0f); @@ -2205,7 +2205,7 @@ void PikiAutoNukiState::exec(Piki* piki) case 1: if (!piki->assertMotion(IPikiAnims::KAIFUKU2)) { - _14 = 2; + mState = 2; } break; @@ -2239,7 +2239,7 @@ void PikiAutoNukiState::onKeyEvent(Piki* piki, SysShape::KeyEvent const& keyEven { switch (keyEvent.mType) { case 1000: - _14 = 2; + mState = 2; break; case 2: break; @@ -2595,7 +2595,7 @@ void PikiHipDropState::exec(Piki* piki) Vector3f position = piki->getPosition(); Sys::Sphere sphere(position, 50.0f); CellIteratorArg iterArg(sphere); - iterArg.mUseCustomRadiusThreshold = 1; + iterArg.mUseCustomRadius = 1; CellIterator iterator(iterArg); iterator.first(); @@ -3230,7 +3230,7 @@ void PikiHipDropState::earthquake(Piki* piki) f32 rad = pikiMgr->mParms->mPikiParms.mPoundAOERange.mValue; Sys::Sphere sphere(position, rad); CellIteratorArg iterArg(sphere); - iterArg.mUseCustomRadiusThreshold = 1; + iterArg.mUseCustomRadius = 1; CellIterator iterator(iterArg); iterator.first(); @@ -3741,10 +3741,10 @@ void PikiSuikomiState::init(Piki* piki, StateArg* stateArg) { SuikomiStateArg* suikomiArg = static_cast(stateArg); P2ASSERTLINE(2572, suikomiArg != nullptr); - mCreature = suikomiArg->mCreature; - mCollpart = suikomiArg->_04; - _1C = suikomiArg->_08; - _10 = 0; + mCreature = suikomiArg->mCreature; + mCollpart = suikomiArg->mCollpart; + mStomachCollpart = suikomiArg->mStomachCollpart; + mState = 0; piki->setMoveVelocity(false); piki->endStick(); } @@ -3763,9 +3763,9 @@ void PikiSuikomiState::exec(Piki* piki) return; } - if (_10 == 0) { + if (mState == 0) { execMouth(piki); - } else if (_10 == 1) { + } else if (mState == 1) { execString(piki); } else { execStomach(piki); @@ -3781,8 +3781,8 @@ void PikiSuikomiState::execMouth(Piki* piki) { Vector3f position; if (mCollpart == nullptr) { - position = _1C->mPosition; - position.y -= _1C->mRadius; + position = mStomachCollpart->mPosition; + position.y -= mStomachCollpart->mRadius; } else { Sys::Tube tube; @@ -3797,14 +3797,14 @@ void PikiSuikomiState::execMouth(Piki* piki) if (length < 10.0f) { if (mCollpart == nullptr) { piki->setMoveVelocity(true); - piki->startCaptureStomach(_1C); - _10 = 2; + piki->startCaptureStomach(mStomachCollpart); + mState = 2; piki->startMotion(IPikiAnims::ESA, IPikiAnims::ESA, piki, nullptr); - _20 = pikiMgr->mParms->mPikiParms.mKurageKillTime.mValue; + mTimer = pikiMgr->mParms->mPikiParms.mKurageKillTime.mValue; } else { piki->startStick(mCreature, mCollpart); piki->setMoveVelocity(true); - _10 = 1; + mState = 1; } } else { @@ -3840,12 +3840,12 @@ void PikiSuikomiState::execString(Piki* piki) piki->mSimVelocity = axisVec; piki->move(sys->mDeltaTime); - if (piki->_104.y >= 1.0f) { + if (piki->mClimbingPosition.y >= 1.0f) { piki->endStick(); - piki->startCaptureStomach(_1C); - _10 = 2; + piki->startCaptureStomach(mStomachCollpart); + mState = 2; piki->startMotion(IPikiAnims::ESA, IPikiAnims::ESA, nullptr, nullptr); - _20 = pikiMgr->mParms->mPikiParms.mKurageKillTime.mValue; + mTimer = pikiMgr->mParms->mPikiParms.mKurageKillTime.mValue; } } @@ -3864,20 +3864,21 @@ bool PikiSuikomiState::ignoreAtari(Piki* piki, Creature* creature) { return (u8) void PikiSuikomiState::execStomach(Piki* piki) { if (mCreature) { - if (mCreature->mObjectTypeID != 2) { + if (mCreature->mObjectTypeID != OBJTYPE_Teki) { JUT_PANICLINE(2680, "not teki (%s)!", mCreature->getCreatureName()); } + EnemyBase* enemy = static_cast(mCreature); if (!enemy->isEvent(0, EB_Bittered) && !(enemy->mHealth <= 0.0f)) { - _20 -= sys->mDeltaTime; + mTimer -= sys->mDeltaTime; } } - if (_10 == 3) { - f32 scale = _20 / 0.5f; + if (mState == 3) { + f32 scale = mTimer / 0.5f; scale *= piki->getBaseScale(); piki->mScale = Vector3f(scale); - if (_20 <= 0.0f) { + if (mTimer <= 0.0f) { if (piki->isPikmin()) { deathMgr->inc(0); } @@ -3890,9 +3891,9 @@ void PikiSuikomiState::execStomach(Piki* piki) BlowStateArg blowArg(vec, 0.0f, 0, 10, mCreature); transit(piki, PIKISTATE_Blow, &blowArg); - } else if (_20 <= 0.0f) { - _10 = 3; - _20 = 0.5f; + } else if (mTimer <= 0.0f) { + mState = 3; + mTimer = 0.5f; } } @@ -4532,19 +4533,19 @@ void PikiBlowState::init(Piki* piki, StateArg* stateArg) if (!blowArg) { JUT_PANICLINE(3223, "flick needs PikiBlowInitArg !\n"); } else { - _18 = blowArg->_00; - _24 = blowArg->_0C; - mIsLethal = blowArg->mIsLethal; - _2A = blowArg->_12; - _14 = blowArg->_14; + mBlowDirection = blowArg->mBlowDirection; + mChanceToLeaf = blowArg->mChanceToLeaf; + mIsLethal = blowArg->mIsLethal; + _2A = blowArg->_12; + mHeldNavi = blowArg->mHeldNavi; } mIsWhistled = false; piki->startMotion(IPikiAnims::JHIT, IPikiAnims::JHIT, piki, nullptr); mState = 0; - piki->mSimVelocity.y = _18.y * (0.1f * randFloat() + 1.0f); - piki->mFaceDir = roundAng(JMath::atanTable_.atan2_(_18.x, _18.z) + PI); + piki->mSimVelocity.y = mBlowDirection.y * (0.1f * randFloat() + 1.0f); + piki->mFaceDir = roundAng(JMath::atanTable_.atan2_(mBlowDirection.x, mBlowDirection.z) + PI); if (_2A & 0x4) { if ((int)piki->mHappaKind >= Bud) { @@ -4575,8 +4576,8 @@ void PikiBlowState::exec(Piki* piki) switch (mState) { case BLOW_Start: - piki->mSimVelocity.x = _18.x; - piki->mSimVelocity.z = _18.z; + piki->mSimVelocity.x = mBlowDirection.x; + piki->mSimVelocity.z = mBlowDirection.z; if (!piki->assertMotion(IPikiAnims::JHIT)) { mState = BLOW_Knockback; piki->startMotion(IPikiAnims::JKOKE, IPikiAnims::JKOKE, piki, nullptr); @@ -4634,15 +4635,15 @@ void PikiBlowState::bounceCallback(Piki* piki, Sys::Triangle* triangle) { u16 flag = (mIsWhistled ? 0x8000 : 0) | _2A; KokeDamageStateArg kokeArg(flag, 1.0f); - if (randFloat() < _24) { + if (randFloat() < mChanceToLeaf) { if ((int)piki->mHappaKind >= Bud) { efx::TPkEffect* effectsObj = piki->mEffectsObj; efx::createSimpleChiru(*effectsObj->_0C, effectsObj->mPikiColor); piki->mHappaKind = Leaf; } - if (_14) { - piki->startSound(_14, PSSE_PK_VC_DAMAGED, true); + if (mHeldNavi) { + piki->startSound(mHeldNavi, PSSE_PK_VC_DAMAGED, true); } } @@ -5824,17 +5825,17 @@ void PikiAbsorbState::init(Piki* piki, StateArg* stateArg) { AbsorbStateArg* absorbArg = static_cast(stateArg); P2ASSERTLINE(4210, absorbArg); - _14 = absorbArg->mCreature; - P2ASSERTLINE(4212, _14); + mAbsorbingCreature = absorbArg->mCreature; + P2ASSERTLINE(4212, mAbsorbingCreature); piki->startMotion(IPikiAnims::MIZUNOMI, IPikiAnims::MIZUNOMI, piki, nullptr); - _10 = 0; - _18 = 0; - Vector3f targetPos = _14->getPosition(); + mState = 0; + mHasAbsorbed = 0; + Vector3f targetPos = mAbsorbingCreature->getPosition(); piki->turnTo(targetPos); - P2ASSERTLINE(4219, _14->getJAIObject()); - piki->mSoundObj->startPikiSound(_14->getJAIObject(), PSSE_PK_VC_DRINK, 0); - _19 = 0; + P2ASSERTLINE(4219, mAbsorbingCreature->getJAIObject()); + piki->mSoundObj->startPikiSound(mAbsorbingCreature->getJAIObject(), PSSE_PK_VC_DRINK, 0); + mAbsorbTimer = 0; } /* @@ -5848,22 +5849,22 @@ void PikiAbsorbState::exec(Piki* piki) piki->mSimVelocity.x = 0.0f; piki->mVelocity = Vector3f(0.0f); - if (_10 == 1 && _14->isAlive() && !_18) { + if (mState == 1 && mAbsorbingCreature->isAlive() && !mHasAbsorbed) { InteractAbsorb absorb(piki); - _14->stimulate(absorb); - _18 = 1; + mAbsorbingCreature->stimulate(absorb); + mHasAbsorbed = 1; } - if (!_18) { - _19++; - if (_19 > 180) { - _18 = 1; - _19 = 180; + if (!mHasAbsorbed) { + mAbsorbTimer++; + if (mAbsorbTimer > 180) { + mHasAbsorbed = 1; + mAbsorbTimer = 180; } } if (!piki->assertMotion(IPikiAnims::MIZUNOMI)) { - if (_18) { + if (mHasAbsorbed) { transit(piki, PIKISTATE_Growup, nullptr); } else { transit(piki, PIKISTATE_Walk, nullptr); @@ -5880,22 +5881,22 @@ void PikiAbsorbState::onKeyEvent(Piki* piki, SysShape::KeyEvent const& event) { switch (event.mType) { case KEYEVENT_NULL: - _10 = 1; + mState = 1; break; case KEYEVENT_1: - Creature* creature = _14; + Creature* creature = mAbsorbingCreature; P2ASSERTLINE(4261, creature->mObjectTypeID == OBJTYPE_Honey); - ItemHoney::Item* nectar = (ItemHoney::Item*)_14; + ItemHoney::Item* nectar = (ItemHoney::Item*)mAbsorbingCreature; - if (!_14->isAlive() || _18 || !nectar->isShrinking()) { - _10 = 2; + if (!mAbsorbingCreature->isAlive() || mHasAbsorbed || !nectar->isShrinking()) { + mState = 2; piki->finishMotion(); } break; case KEYEVENT_END: - if (_18) { + if (mHasAbsorbed) { transit(piki, PIKISTATE_Growup, nullptr); } else { transit(piki, PIKISTATE_Walk, nullptr); diff --git a/src/plugProjectMorimuraU/bombState.cpp b/src/plugProjectMorimuraU/bombState.cpp index 4fb909b66..a280fd905 100644 --- a/src/plugProjectMorimuraU/bombState.cpp +++ b/src/plugProjectMorimuraU/bombState.cpp @@ -153,7 +153,7 @@ void StateBomb::exec(EnemyBase* enemy) sphere.mPosition = Vector3f(position); sphere.mRadius = parms->mGeneral.mAttackRadius.mValue; CellIteratorArg iteratorArg(sphere); - iteratorArg.mUseCustomRadiusThreshold = 1; + iteratorArg.mUseCustomRadius = 1; CellIterator iterator(iteratorArg); CI_LOOP(iterator) diff --git a/src/plugProjectNishimuraU/BigTreasure.cpp b/src/plugProjectNishimuraU/BigTreasure.cpp index aa7d9e851..cf9e5b3b8 100644 --- a/src/plugProjectNishimuraU/BigTreasure.cpp +++ b/src/plugProjectNishimuraU/BigTreasure.cpp @@ -360,7 +360,7 @@ bool Obj::isAttackLimitTime() Sys::Sphere sphere(mPosition, 300.0f); CellIteratorArg iterArg(sphere); - iterArg.mIsCollSphereDisabled = true; + iterArg.mIsSphereCollisionDisabled = true; CellIterator iter(iterArg); diff --git a/src/plugProjectNishimuraU/BigTreasureAttack.cpp b/src/plugProjectNishimuraU/BigTreasureAttack.cpp index c8d420ea0..a12b9adf3 100644 --- a/src/plugProjectNishimuraU/BigTreasureAttack.cpp +++ b/src/plugProjectNishimuraU/BigTreasureAttack.cpp @@ -102,7 +102,7 @@ bool BigTreasureFireAttack::update() Sys::Sphere sphere(pos, 25.0f); CellIteratorArg iterArg(sphere); - iterArg.mIsCollSphereDisabled = true; + iterArg.mIsSphereCollisionDisabled = true; CellIterator iter(iterArg); diff --git a/src/plugProjectNishimuraU/ElecHiba.cpp b/src/plugProjectNishimuraU/ElecHiba.cpp index 342da7551..d855ccb82 100644 --- a/src/plugProjectNishimuraU/ElecHiba.cpp +++ b/src/plugProjectNishimuraU/ElecHiba.cpp @@ -301,7 +301,7 @@ void Obj::interactDenkiAttack(Vector3f& position) // also some other constants pulled from parms CellIteratorArg iterArg(sphere); - iterArg.mIsCollSphereDisabled = true; + iterArg.mIsSphereCollisionDisabled = true; CellIterator iter(iterArg); diff --git a/src/plugProjectNishimuraU/Fart.cpp b/src/plugProjectNishimuraU/Fart.cpp index c39200057..6494da541 100644 --- a/src/plugProjectNishimuraU/Fart.cpp +++ b/src/plugProjectNishimuraU/Fart.cpp @@ -93,7 +93,7 @@ void Obj::interactFartGasAttack() sphere.mRadius = parms->mGeneral.mAttackRadius.mValue; CellIteratorArg arg(sphere); - arg.mIsCollSphereDisabled = true; + arg.mIsSphereCollisionDisabled = true; CellIterator iterator(arg); CI_LOOP(iterator) diff --git a/src/plugProjectNishimuraU/Fuefuki.cpp b/src/plugProjectNishimuraU/Fuefuki.cpp index 69520be8e..758d536a2 100644 --- a/src/plugProjectNishimuraU/Fuefuki.cpp +++ b/src/plugProjectNishimuraU/Fuefuki.cpp @@ -465,7 +465,7 @@ bool Obj::isJumpAway() f32 privateDiameter = privRad * privRad; CellIteratorArg iterArg(sphere); - iterArg.mIsCollSphereDisabled = true; + iterArg.mIsSphereCollisionDisabled = true; CellIterator iter(iterArg); diff --git a/src/plugProjectNishimuraU/GasHiba.cpp b/src/plugProjectNishimuraU/GasHiba.cpp index 1cc5a9dca..0c60d3d72 100644 --- a/src/plugProjectNishimuraU/GasHiba.cpp +++ b/src/plugProjectNishimuraU/GasHiba.cpp @@ -168,7 +168,7 @@ void Obj::interactGasAttack() sphere.mRadius = parms->mGeneral.mAttackRadius.mValue; CellIteratorArg arg(sphere); - arg.mIsCollSphereDisabled = true; + arg.mIsSphereCollisionDisabled = true; CellIterator iterator(arg); CI_LOOP(iterator) diff --git a/src/plugProjectNishimuraU/Hiba.cpp b/src/plugProjectNishimuraU/Hiba.cpp index 8b05ce7a4..81d8413a0 100644 --- a/src/plugProjectNishimuraU/Hiba.cpp +++ b/src/plugProjectNishimuraU/Hiba.cpp @@ -159,7 +159,7 @@ void Obj::interactFireAttack() sphere.mRadius = parms->mGeneral.mAttackRadius.mValue; CellIteratorArg arg(sphere); - arg.mIsCollSphereDisabled = true; + arg.mIsSphereCollisionDisabled = true; CellIterator iterator(arg); CI_LOOP(iterator) diff --git a/src/plugProjectNishimuraU/ImomushiState.cpp b/src/plugProjectNishimuraU/ImomushiState.cpp index f62e3f134..691b528f3 100644 --- a/src/plugProjectNishimuraU/ImomushiState.cpp +++ b/src/plugProjectNishimuraU/ImomushiState.cpp @@ -496,7 +496,7 @@ void StateClimb::exec(EnemyBase* enemy) imomushi->moveStickTube(); f32 val = imomushi->_2FC; - f32 yval = imomushi->_104.y; + f32 yval = imomushi->mClimbingPosition.y; if (yval > 1.0f - val) { CollPart* childPart = static_cast(imomushi->mStuckCollPart->mChild); if (childPart != nullptr && childPart->mPartType == COLLTYPE_TUBETREE) { diff --git a/src/plugProjectNishimuraU/Kabuto.cpp b/src/plugProjectNishimuraU/Kabuto.cpp index eef2a647f..cba3bd4fc 100644 --- a/src/plugProjectNishimuraU/Kabuto.cpp +++ b/src/plugProjectNishimuraU/Kabuto.cpp @@ -234,7 +234,7 @@ bool Obj::isAttackableTarget() sphere.mPosition = pos; CellIteratorArg iterArg(sphere); - iterArg.mIsCollSphereDisabled = true; + iterArg.mIsSphereCollisionDisabled = true; CellIterator iter(iterArg); CI_LOOP(iter) { diff --git a/src/plugProjectNishimuraU/OtakaraBase.cpp b/src/plugProjectNishimuraU/OtakaraBase.cpp index 24fe0f43a..e8c536397 100644 --- a/src/plugProjectNishimuraU/OtakaraBase.cpp +++ b/src/plugProjectNishimuraU/OtakaraBase.cpp @@ -609,7 +609,7 @@ void Obj::attackTarget() sphere.mRadius = radius; CellIteratorArg iterArg(sphere); - iterArg.mIsCollSphereDisabled = true; + iterArg.mIsSphereCollisionDisabled = true; CellIterator iter(iterArg); CI_LOOP(iter) diff --git a/src/plugProjectNishimuraU/Queen.cpp b/src/plugProjectNishimuraU/Queen.cpp index fed0607b0..334e0ae2c 100644 --- a/src/plugProjectNishimuraU/Queen.cpp +++ b/src/plugProjectNishimuraU/Queen.cpp @@ -298,7 +298,7 @@ void Obj::rollingAttack() Sys::Sphere sphere(mPosition, 250.0f); CellIteratorArg iterArg(sphere); - iterArg.mIsCollSphereDisabled = true; + iterArg.mIsSphereCollisionDisabled = true; CellIterator iter(iterArg); CI_LOOP(iter) diff --git a/src/plugProjectNishimuraU/Tank.cpp b/src/plugProjectNishimuraU/Tank.cpp index 230d36b2a..bc738fe54 100644 --- a/src/plugProjectNishimuraU/Tank.cpp +++ b/src/plugProjectNishimuraU/Tank.cpp @@ -289,7 +289,7 @@ bool Obj::isAttackable(bool check) sphere.mRadius = halfRatio; CellIteratorArg iterArg(sphere); - iterArg.mIsCollSphereDisabled = true; + iterArg.mIsSphereCollisionDisabled = true; CellIterator iter(iterArg);