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/operate.cc | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'src/operate.cc') diff --git a/src/operate.cc b/src/operate.cc index 14fab8a..92ba83e 100644 --- a/src/operate.cc +++ b/src/operate.cc @@ -145,7 +145,7 @@ void AnnounceChangedContainer(Object Obj, int Type){ } for(int ContainerNr = 0; - ContainerNr <= NARRAY(Player->OpenContainer); + ContainerNr < NARRAY(Player->OpenContainer); ContainerNr += 1){ if(Player->GetOpenContainer(ContainerNr) != Con){ continue; @@ -282,13 +282,13 @@ void AnnounceMissile(int OrigX, int OrigY, int OrigZ, continue; } - if(!Player->Connection->IsVisible(OrigX, OrigY, OrigY) + if(!Player->Connection->IsVisible(OrigX, OrigY, OrigZ) && !Player->Connection->IsVisible(DestX, DestY, DestZ)){ continue; } SendMissileEffect(Player->Connection, - OrigX, OrigY, OrigY, + OrigX, OrigY, OrigZ, DestX, DestY, DestZ, Type); } } @@ -449,10 +449,6 @@ void CheckMoveObject(uint32 CreatureID, Object Obj, bool Take){ // NOTE(fusion): This is a helper function for `CheckMapDestination` and `CheckMapPlace` // and improves the readability of otherwise two convoluted functions. static bool IsMapBlocked(int DestX, int DestY, int DestZ, ObjectType Type){ - if(Type.isCreatureContainer()){ - return false; - } - bool HasBank = CoordinateFlag(DestX, DestY, DestZ, BANK); if(HasBank && !CoordinateFlag(DestX, DestY, DestZ, UNPASS)){ return false; @@ -480,16 +476,20 @@ void CheckMapDestination(uint32 CreatureID, Object Obj, Object MapCon){ return; } + int OrigX, OrigY, OrigZ; int DestX, DestY, DestZ; ObjectType ObjType = Obj.getObjectType(); + GetObjectCoordinates(Obj, &OrigX, &OrigY, &OrigZ); GetObjectCoordinates(MapCon, &DestX, &DestY, &DestZ); - if(IsMapBlocked(DestX, DestY, DestZ, ObjType)){ - throw NOROOM; - } + if(!ObjType.isCreatureContainer()){ + if(IsMapBlocked(DestX, DestY, DestZ, ObjType)){ + throw NOROOM; + } - int OrigX, OrigY, OrigZ; - GetObjectCoordinates(Obj, &OrigX, &OrigY, &OrigZ); - if(ObjType.isCreatureContainer()){ + if(!ObjType.getFlag(TAKE) && !ObjectInRange(CreatureID, MapCon, 2)){ + throw OUTOFRANGE; + } + }else{ if(std::abs(OrigX - DestX) > 1 || std::abs(OrigY - DestY) > 1 || std::abs(OrigZ - DestZ) > 1){ @@ -531,10 +531,6 @@ void CheckMapDestination(uint32 CreatureID, Object Obj, Object MapCon){ } } } - }else{ - if(!ObjType.getFlag(TAKE) && !ObjectInRange(CreatureID, MapCon, 2)){ - throw OUTOFRANGE; - } } // TODO(fusion): This looks awfully similar to `ObjectAccessible` outside @@ -1169,19 +1165,19 @@ Object Create(Object Con, ObjectType Type, uint32 Value){ } if(Type.getFlag(LIQUIDPOOL)){ - ChangeObject(POOLLIQUIDTYPE, Value); + ChangeObject(Obj, POOLLIQUIDTYPE, Value); } if(Type.getFlag(LIQUIDCONTAINER)){ - ChangeObject(CONTAINERLIQUIDTYPE, Value); + ChangeObject(Obj, CONTAINERLIQUIDTYPE, Value); } if(Type.getFlag(KEY)){ - ChangeObject(KEYNUMBER, Value); + ChangeObject(Obj, KEYNUMBER, Value); } if(Type.getFlag(RUNE)){ - ChangeObject(CHARGES, Value); + ChangeObject(Obj, CHARGES, Value); } if(Type.isCreatureContainer()){ @@ -1895,7 +1891,7 @@ void Look(uint32 CreatureID, Object Obj){ if(Yourself){ strcpy(Membership, "You are "); }else{ - snprintf(Membership, sizeof(Membership), "%s id ", Pronoun); + snprintf(Membership, sizeof(Membership), "%s is ", Pronoun); } if(TargetPlayer->Rank[0] != 0){ @@ -2456,10 +2452,13 @@ void Talk(uint32 CreatureID, int Mode, const char *Addressee, const char *Text, } TCreature *Spectator = GetCreature(SpectatorID); - if(Spectator != NULL){ - Spectator->TalkStimulus(CreatureID, Text); - }else{ + if(Spectator == NULL){ error("Talk: Kreatur existiert nicht.\n"); + continue; + } + + if(Spectator->posz == Creature->posz){ + Spectator->TalkStimulus(CreatureID, Text); } } } -- cgit v1.2.3