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/map.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/map.cc') diff --git a/src/map.cc b/src/map.cc index 78e54db..aad27c3 100644 --- a/src/map.cc +++ b/src/map.cc @@ -623,7 +623,7 @@ void SwapObject(TWriteBinaryFile *File, Object Obj, uintptr FileNumber){ File->writeBytes((const uint8*)Entry, sizeof(TObject)); if(Entry->Type.getFlag(CONTAINER) || Entry->Type.getFlag(CHEST)){ - Object Current = Obj.getAttribute(CONTENT); + Object Current = Object(Obj.getAttribute(CONTENT)); while(Current != NONE){ Object Next = Current.getNextObject(); SwapObject(File, Current, FileNumber); @@ -1116,7 +1116,7 @@ void SaveObjects(Object Obj, TWriteStream *Stream, bool Stop){ Object First = NONE; if(ObjType.getAttributeOffset(CONTENT) != -1){ - First = Obj.getAttribute(CONTENT); + First = Object(Obj.getAttribute(CONTENT)); } if(First != NONE){ @@ -1330,7 +1330,7 @@ void RefreshSector(int SectorX, int SectorY, int SectorZ, TReadStream *Stream){ // TODO(fusion): This loop was done a bit differently but I suppose // iterating it directly is clearer and as long as we don't access // the object after `DeleteObject`, it should work the same. - Object Obj = Con.getAttribute(CONTENT); + Object Obj = Object(Con.getAttribute(CONTENT)); while(Obj != NONE){ Object Next = Obj.getNextObject(); if(!Obj.getObjectType().isCreatureContainer()){ @@ -1419,7 +1419,7 @@ void PatchSector(int SectorX, int SectorY, int SectorZ, bool FullSector, // NOTE(fusion): Similar to `RefreshSector`. Object Con = Sec->MapCon[OffsetX][OffsetY]; - Object Obj = Con.getAttribute(CONTENT); + Object Obj = Object(Con.getAttribute(CONTENT)); while(Obj != NONE){ Object Next = Obj.getNextObject(); if(!Obj.getObjectType().isCreatureContainer()){ @@ -1511,7 +1511,7 @@ void PatchSector(int SectorX, int SectorY, int SectorZ, bool FullSector, // NOTE(fusion): Same as in the parsing loop above. Object Con = Sec->MapCon[OffsetX][OffsetY]; - Object Obj = Con.getAttribute(CONTENT); + Object Obj = Object(Con.getAttribute(CONTENT)); while(Obj != NONE){ Object Next = Obj.getNextObject(); if(!Obj.getObjectType().isCreatureContainer()){ @@ -1641,7 +1641,7 @@ void PatchSector(int SectorX, int SectorY, int SectorZ, bool FullSector, } Object Con = Sec->MapCon[OffsetX][OffsetY]; - Object First = Con.getAttribute(CONTENT); + Object First = Object(Con.getAttribute(CONTENT)); uint8 Flags = GetMapContainerFlags(Con); if(First != NONE || Flags != 0){ OUT.writeNumber(OffsetX); @@ -1853,7 +1853,7 @@ static void DestroyObject(Object Obj){ if(ObjType.getFlag(CONTAINER) || ObjType.getFlag(CHEST)){ while(true){ - Object Inner = Obj.getAttribute(CONTENT); + Object Inner = Object(Obj.getAttribute(CONTENT)); if(Inner == NONE){ break; } @@ -2020,7 +2020,7 @@ void PlaceObject(Object Obj, Object Con, bool Append){ } Object Prev = NONE; - Object Cur(Con.getAttribute(CONTENT)); + Object Cur = Object(Con.getAttribute(CONTENT)); if(ConType.isMapContainer()){ // TODO(fusion): Review. The loop below was a bit rough but it seems that // append is forced for non PRIORITY_CREATURE and PRIORITY_LOW. @@ -2358,7 +2358,7 @@ Object GetFirstSpecObject(int x, int y, int z, ObjectType Type){ } Obj = Obj.getNextObject(); } - return NONE; + return Obj; } uint8 GetMapContainerFlags(Object Obj){ -- cgit v1.2.3