From e4b8bf807b76f6f446d9617d9a3957dc77dd6e90 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Mon, 21 Jul 2025 19:23:42 -0300 Subject: multiple bug-fixes and improvements - Make uint32 -> Object conversion explicit. This can be more verbose but will get a lot of small mistakes, especially with function overloads. - Fix problem with the path finder not including the last step when `MustReach` was false. - Fix problem with NPC conditions. - Fix problem with monster homes continuously spawning monsters. - Fix problem with creating the standard inventory. - Fix problem with creature timers (IMPORTANT). - Fix problem with `ThrowPossible` (IMPORTANT). - Fix problem with rune casting. - Fix problem with executing moveuse events. - Fix problem with `MoveRel` and `WriteName` moveuse actions. - Fix problem with eating food deleting the whole stack. - Many other bug-fixes and improvements. --- src/cract.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/cract.cc') diff --git a/src/cract.cc b/src/cract.cc index f30415d..41bbcca 100644 --- a/src/cract.cc +++ b/src/cract.cc @@ -151,7 +151,7 @@ void TShortway::Expand(TShortwayPoint *Node){ // add waypoints two more times. int NeighborWaylength = MinNeighborWaylength; if(OffsetX != 0 && OffsetY != 0){ - NeighborWaylength += Node->Waylength * 2; + NeighborWaylength += Node->Waypoints * 2; } if(NeighborWaylength < Neighbor->Waylength){ @@ -238,15 +238,12 @@ bool TShortway::Calculate(int DestX, int DestY, bool MustReach, int MaxSteps){ } // NOTE(fusion): Walk back from the origin to reconstruct the path. + int CurDistance = std::max( + std::abs(Node->x - DestX), + std::abs(Node->y - DestY)); Node = Node->Predecessor; - while(Node != NULL && MaxSteps > 0){ - int MaxDistance = std::max( - std::abs(Node->x - DestX), - std::abs(Node->y - DestY)); - if(!MustReach && MaxDistance <= 1){ - break; - } - + while(Node != NULL && MaxSteps > 0 + && (MustReach || CurDistance > 1)){ TToDoEntry TD = {}; TD.Code = TDGo; TD.Go.x = this->StartX + Node->x; @@ -254,6 +251,9 @@ bool TShortway::Calculate(int DestX, int DestY, bool MustReach, int MaxSteps){ TD.Go.z = this->StartZ; Creature->ToDoAdd(TD); + CurDistance = std::max( + std::abs(Node->x - DestX), + std::abs(Node->y - DestY)); Node = Node->Predecessor; MaxSteps -= 1; } @@ -768,22 +768,22 @@ void TCreature::Execute(void){ } case TDMove:{ - this->Move(TD.Move.Obj, TD.Move.x, TD.Move.y, TD.Move.z, (uint8)TD.Move.Count); + this->Move(Object(TD.Move.Obj), TD.Move.x, TD.Move.y, TD.Move.z, (uint8)TD.Move.Count); break; } case TDTrade:{ - this->Trade(TD.Trade.Obj, TD.Trade.Partner); + this->Trade(Object(TD.Trade.Obj), TD.Trade.Partner); break; } case TDUse:{ - this->Use(TD.Use.Obj1, TD.Use.Obj2, TD.Use.Dummy); + this->Use(Object(TD.Use.Obj1), Object(TD.Use.Obj2), TD.Use.Dummy); break; } case TDTurn:{ - this->Turn(TD.Turn.Obj); + this->Turn(Object(TD.Turn.Obj)); break; } -- cgit v1.2.3