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/info.cc | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'src/info.cc') diff --git a/src/info.cc b/src/info.cc index 08433f2..e24b819 100644 --- a/src/info.cc +++ b/src/info.cc @@ -365,16 +365,24 @@ Object GetBodyObject(uint32 CreatureID, int Position){ Object GetTopObject(int x, int y, int z, bool Move){ Object Obj = GetFirstObject(x, y, z); - while(Obj != NONE){ - ObjectType ObjType = Obj.getObjectType(); - if(!ObjType.getFlag(BANK) - && !ObjType.getFlag(CLIP) - && !ObjType.getFlag(BOTTOM) - && !ObjType.getFlag(TOP) - && (!Move || !ObjType.isCreatureContainer())){ - break; + if(Obj != NONE){ + while(true){ + Object Next = Obj.getNextObject(); + if(Next == NONE){ + break; + } + + ObjectType ObjType = Obj.getObjectType(); + if(!ObjType.getFlag(BANK) + && !ObjType.getFlag(CLIP) + && !ObjType.getFlag(BOTTOM) + && !ObjType.getFlag(TOP) + && (!Move || !ObjType.isCreatureContainer())){ + break; + } + + Obj = Next; } - Obj = Obj.getNextObject(); } return Obj; } @@ -575,7 +583,7 @@ int CountInventoryObjects(uint32 CreatureID, ObjectType Type, uint32 Value){ return 0; } - Object Help = GetFirstContainerObject(Help); + Object Help = GetFirstContainerObject(Creature->CrObject); return CountObjects(Help, Type, Value); } @@ -1173,7 +1181,7 @@ bool ThrowPossible(int OrigX, int OrigY, int OrigZ, // origin and destination. int MaxT = std::max( std::abs(DestX - OrigX), - std::abs(DestY - OrigX)); + std::abs(DestY - OrigY)); int StartT = 1; if((DestX < OrigX && CoordinateFlag(OrigX, OrigY, OrigZ, HOOKEAST)) -- cgit v1.2.3