From 8d565e911691a3740c283bd33ebc11d6d0fac6b7 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Thu, 4 Sep 2025 22:28:43 -0300 Subject: missing try-catch block in `CreateField` - fixes #21 The result DESTROYED was being caught at `UseMagicItem`, causing the cast to fail but not before partially spawning other fields in the case of `MassCreateField` and `CreateFieldWall`. --- src/crplayer.cc | 2 +- src/magic.cc | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/crplayer.cc b/src/crplayer.cc index 1339ada..c4dbd80 100644 --- a/src/crplayer.cc +++ b/src/crplayer.cc @@ -282,7 +282,7 @@ TPlayer::~TPlayer(void){ } // NOTE(fusion): This is used to reset skills back to default. See - // `LoadData`. + // `TPlayer::LoadData`. for(int SkillNr = 0; SkillNr < NARRAY(PlayerData->Minimum); SkillNr += 1){ diff --git a/src/magic.cc b/src/magic.cc index c69507f..c02e0f0 100644 --- a/src/magic.cc +++ b/src/magic.cc @@ -1042,9 +1042,15 @@ void CreateField(int x, int y, int z, int FieldType, uint32 Owner, bool Peaceful } // NOTE(fusion): Create field, at last. - Create(GetMapContainer(x, y, z), - GetSpecialObject(Meaning), - Owner); + try{ + Create(GetMapContainer(x, y, z), + GetSpecialObject(Meaning), + Owner); + }catch(RESULT r){ + if(r != DESTROYED){ + throw; + } + } } void CreateField(TCreature *Actor, Object Target, int ManaPoints, int SoulPoints, int FieldType){ -- cgit v1.2.3