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/moveuse.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/moveuse.cc') diff --git a/src/moveuse.cc b/src/moveuse.cc index 81fa948..e4d76db 100644 --- a/src/moveuse.cc +++ b/src/moveuse.cc @@ -1176,7 +1176,7 @@ void ExecuteAction(MoveUseEventType EventType, TMoveUseAction *Action, } // TODO(fusion): Some helper function to format text? - char Text[256]; + char Text[256] = {}; { int ReadPos = 0; int WritePos = 0; @@ -1331,12 +1331,13 @@ void ExecuteAction(MoveUseEventType EventType, TMoveUseAction *Action, } case MOVEUSE_ACTION_MOVEREL:{ - int ObjX, ObjY, ObjZ, RelX, RelY, RelZ; - Object Obj = GetEventObject(Action->Parameters[0], User, Obj1, Obj2, *Temp); - UnpackRelativeCoordinate(Action->Parameters[1], &RelX, &RelY, &RelZ); - GetObjectCoordinates(Obj, &ObjX, &ObjY, &ObjZ); - Object Dest = GetMapContainer((ObjX + RelX), (ObjY + RelY), (ObjZ + RelZ)); - MoveOneObject(Obj, Dest); + int RefX, RefY, RefZ, RelX, RelY, RelZ; + Object MovObj = GetEventObject(Action->Parameters[0], User, Obj1, Obj2, *Temp); + Object RefObj = GetEventObject(Action->Parameters[1], User, Obj1, Obj2, *Temp); + UnpackRelativeCoordinate(Action->Parameters[2], &RelX, &RelY, &RelZ); + GetObjectCoordinates(RefObj, &RefX, &RefY, &RefZ); + Object Dest = GetMapContainer((RefX + RelX), (RefY + RelY), (RefZ + RelZ)); + MoveOneObject(MovObj, Dest); break; } @@ -1520,9 +1521,10 @@ bool HandleEvent(MoveUseEventType EventType, Object User, Object Obj1, Object Ob ActionNr <= Rule->LastAction; ActionNr += 1){ TMoveUseAction *Action = MoveUseActions.at(ActionNr); - ExecuteAction(EventType, Action, User, Obj2, Obj2, &Temp); + ExecuteAction(EventType, Action, User, Obj1, Obj2, &Temp); } Result = true; + break; } } RecursionDepth -= 1; @@ -1842,7 +1844,7 @@ void UseFood(uint32 CreatureID, Object Obj){ } Player->SetTimer(SKILL_FED, (CurFoodTime + ObjFoodTime), 0, 0, -1); - Delete(Obj, -1); + Delete(Obj, 1); } void UseTextObject(uint32 CreatureID, Object Obj){ -- cgit v1.2.3