aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-08-30 16:23:35 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-08-30 16:23:35 -0300
commitae47fb12e6121c57c9229f599ef48986a5a46fe7 (patch)
treed0b0bb6c62afbf3167361e71359deb579e31a0b3
parent6ad338408ad1f729853a63f5fc8a3bea0555590a (diff)
downloadgame-ae47fb12e6121c57c9229f599ef48986a5a46fe7.tar.gz
game-ae47fb12e6121c57c9229f599ef48986a5a46fe7.zip
fix issue with `CheckForSpell` - fixes #11
`CheckForSpell` would return the spell type if the first syllable was a spell syllable, even if it failed to match any actual spell.
-rw-r--r--src/magic.cc58
1 files changed, 30 insertions, 28 deletions
diff --git a/src/magic.cc b/src/magic.cc
index 42f04ee..d436960 100644
--- a/src/magic.cc
+++ b/src/magic.cc
@@ -3962,40 +3962,42 @@ int CheckForSpell(uint32 CreatureID, const char *Text){
}
int SpellNr = FindSpell(Syllable);
- if(SpellNr != 0){
- try{
- switch(SpellType){
- case 1: CharacterRightSpell(CreatureID, SpellNr, SpellStr); break;
- case 2: RuneSpell(CreatureID, SpellNr); break;
- case 3: CastSpell(CreatureID, SpellNr, SpellStr); break;
- case 4: CastSpell(CreatureID, SpellNr, SpellStr); break;
- case 5: AccountRightSpell(CreatureID, SpellNr, SpellStr); break;
- default:{
- error("CheckForSpell: Spruchklasse %d existiert nicht.\n", SpellType);
- break;
- }
+ if(SpellNr == 0){
+ return 0;
+ }
+
+ try{
+ switch(SpellType){
+ case 1: CharacterRightSpell(CreatureID, SpellNr, SpellStr); break;
+ case 2: RuneSpell(CreatureID, SpellNr); break;
+ case 3: CastSpell(CreatureID, SpellNr, SpellStr); break;
+ case 4: CastSpell(CreatureID, SpellNr, SpellStr); break;
+ case 5: AccountRightSpell(CreatureID, SpellNr, SpellStr); break;
+ default:{
+ error("CheckForSpell: Spruchklasse %d existiert nicht.\n", SpellType);
+ break;
}
- }catch(RESULT r){
- // TODO(fusion): `SpellFailed` is inlined in here but I think it's
- // cleaner to keep it this way.
- TCreature *Actor = GetCreature(CreatureID);
- if(Actor == NULL){
- error("SpellFailed: Kreatur existiert nicht.\n");
- }else{
- if(r != ERROR){
- GraphicalEffect(Actor->posx, Actor->posy, Actor->posz, EFFECT_POFF);
- }
+ }
- if(Actor->Type == PLAYER){
- SendResult(Actor->Connection, r);
- }
+ return SpellType;
+ }catch(RESULT r){
+ // TODO(fusion): `SpellFailed` is inlined in here but I think it's
+ // cleaner to keep it this way.
+ TCreature *Actor = GetCreature(CreatureID);
+ if(Actor == NULL){
+ error("SpellFailed: Kreatur existiert nicht.\n");
+ }else{
+ if(r != ERROR){
+ GraphicalEffect(Actor->posx, Actor->posy, Actor->posz, EFFECT_POFF);
}
- return -SpellType;
+ if(Actor->Type == PLAYER){
+ SendResult(Actor->Connection, r);
+ }
}
- }
- return SpellType;
+ return -SpellType;
+ }
}
static void DeleteRune(Object Obj){