aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-09-04 22:28:43 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-09-04 22:28:43 -0300
commit8d565e911691a3740c283bd33ebc11d6d0fac6b7 (patch)
treebe1b47836834e018d6670cd3d36d4a9aebc3ea6b /src
parent9b2292bdce7667c1a32e478925ee28b8f71b8f35 (diff)
downloadgame-8d565e911691a3740c283bd33ebc11d6d0fac6b7.tar.gz
game-8d565e911691a3740c283bd33ebc11d6d0fac6b7.zip
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`.
Diffstat (limited to 'src')
-rw-r--r--src/crplayer.cc2
-rw-r--r--src/magic.cc12
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){