From b795602b5dfb8263d6406452c59388ff44f0639b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 17 Feb 2014 02:26:59 -0800 Subject: [PATCH] const-correctness: fumbles are not allowed to change castorder --- core/src/kernel/magic.c | 4 ++-- core/src/kernel/magic.h | 4 ++-- core/src/kernel/spell.h | 2 +- src/spells/spells.c | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/src/kernel/magic.c b/core/src/kernel/magic.c index d59113ba0..95b5ec0ff 100644 --- a/core/src/kernel/magic.c +++ b/core/src/kernel/magic.c @@ -2048,11 +2048,11 @@ static spellparameter *add_spellparameter(region * target_r, unit * u, return par; } -struct unit * co_get_caster(struct castorder * co) { +struct unit * co_get_caster(const struct castorder * co) { return co->_familiar ? co->_familiar : co->magician.u; } -struct region * co_get_region(struct castorder * co) { +struct region * co_get_region(const struct castorder * co) { return co->_rtarget; } diff --git a/core/src/kernel/magic.h b/core/src/kernel/magic.h index eb3c27d4c..00a752cf3 100644 --- a/core/src/kernel/magic.h +++ b/core/src/kernel/magic.h @@ -135,8 +135,8 @@ typedef struct sc_mage { struct spellparameter *par; /* für weitere Parameter */ } castorder; - struct unit * co_get_caster(struct castorder * co); - struct region * co_get_region(struct castorder * co); + struct unit * co_get_caster(const struct castorder * co); + struct region * co_get_region(const struct castorder * co); typedef struct spell_component { const struct resource_type *type; diff --git a/core/src/kernel/spell.h b/core/src/kernel/spell.h index 53be0b6cc..40404b4d2 100644 --- a/core/src/kernel/spell.h +++ b/core/src/kernel/spell.h @@ -24,7 +24,7 @@ extern "C" { struct castorder; typedef int (*spell_f)(struct castorder * co); - typedef void(*fumble_f)(struct castorder * co); + typedef void(*fumble_f)(const struct castorder * co); typedef struct spell { unsigned int id; diff --git a/src/spells/spells.c b/src/spells/spells.c index 234edee51..e595000ff 100644 --- a/src/spells/spells.c +++ b/src/spells/spells.c @@ -1167,7 +1167,7 @@ static int sp_mallornhain(castorder * co) return cast_level; } -void patzer_ents(castorder * co) +static void fumble_ents(const castorder * co) { int ents; unit *u; @@ -2301,7 +2301,7 @@ static int sp_earthquake(castorder * co) /* ------------------------------------------------------------- */ /* CHAOS / M_DRAIG / Draig */ /* ------------------------------------------------------------- */ -void patzer_peasantmob(castorder * co) +void patzer_peasantmob(const castorder * co) { int anteil = 6, n; unit *u; @@ -2488,7 +2488,7 @@ static int sp_fumblecurse(castorder * co) return cast_level; } -void patzer_fumblecurse(castorder * co) +void patzer_fumblecurse(const castorder * co) { unit *mage = co->magician.u; int cast_level = co->level; @@ -6469,13 +6469,13 @@ static spelldata spell_functions[] = { /* M_GWYRRD */ { "stonegolem", sp_create_stonegolem, 0}, { "irongolem", sp_create_irongolem, 0}, - { "treegrow", sp_hain, patzer_ents}, + { "treegrow", sp_hain, fumble_ents}, { "rustweapon", sp_rosthauch, 0}, { "cold_protection", sp_kaelteschutz, 0}, { "ironkeeper", sp_ironkeeper, 0}, { "magicstreet", sp_magicstreet, 0}, { "windshield", sp_windshield, 0}, - { "mallorntreegrow", sp_mallornhain, patzer_ents}, + { "mallorntreegrow", sp_mallornhain, fumble_ents}, { "goodwinds", sp_goodwinds, 0}, { "healing", sp_healing, 0}, { "reelingarrows", sp_reeling_arrows, 0},