From 098abcc144eb319137b79547fa177c8d1f917ded Mon Sep 17 00:00:00 2001 From: Philipp Dreher Date: Mon, 2 Nov 2015 14:01:38 +0100 Subject: [PATCH] internal restructuring in flyingship --- src/flyingship.c | 89 ++++++++++++++++++++++++------------------------ src/flyingship.h | 7 ++-- 2 files changed, 47 insertions(+), 49 deletions(-) diff --git a/src/flyingship.c b/src/flyingship.c index 090c3a445..af026c242 100644 --- a/src/flyingship.c +++ b/src/flyingship.c @@ -17,45 +17,6 @@ /* libc includes */ #include -static int flyingship_read(storage * store, curse * c, void *target) -{ - ship *sh = (ship *)target; - c->data.v = sh; - if (global.data_version < FOSS_VERSION) { - sh->flags |= SF_FLYING; - return 0; - } - assert(sh->flags & SF_FLYING); - return 0; -} - -static int flyingship_write(storage * store, const curse * c, - const void *target) -{ - const ship *sh = (const ship *)target; - assert(sh->flags & SF_FLYING); - return 0; -} - -static int flyingship_age(curse * c) -{ - ship *sh = (ship *)c->data.v; - if (sh && c->duration == 1) { - freset(sh, SF_FLYING); - return 1; - } - return 0; -} - -static struct curse_type ct_flyingship = { "flyingship", -CURSETYP_NORM, 0, NO_MERGE, cinfo_ship, NULL, flyingship_read, -flyingship_write, NULL, flyingship_age -}; - -void register_flyingship(void) -{ - ct_register(&ct_flyingship); -} /* ------------------------------------------------------------- */ /* Name: Luftschiff @@ -124,15 +85,46 @@ int sp_flying_ship(castorder * co) return cast_level; } -int levitate_ship(ship * sh, unit * mage, double power, int duration) +static int flyingship_read(storage * store, curse * c, void *target) { - curse *c = shipcurse_flyingship(sh, mage, power, duration); - if (c) { - return c->no; + ship *sh = (ship *)target; + c->data.v = sh; + if (global.data_version < FOSS_VERSION) { + sh->flags |= SF_FLYING; + return 0; + } + assert(sh->flags & SF_FLYING); + return 0; +} + +static int flyingship_write(storage * store, const curse * c, + const void *target) +{ + const ship *sh = (const ship *)target; + assert(sh->flags & SF_FLYING); + return 0; +} + +static int flyingship_age(curse * c) +{ + ship *sh = (ship *)c->data.v; + if (sh && c->duration == 1) { + freset(sh, SF_FLYING); + return 1; } return 0; } +static struct curse_type ct_flyingship = { "flyingship", +CURSETYP_NORM, 0, NO_MERGE, cinfo_ship, NULL, flyingship_read, +flyingship_write, NULL, flyingship_age +}; + +void register_flyingship(void) +{ + ct_register(&ct_flyingship); +} + bool flying_ship(const ship * sh) { if (sh->type->flags & SFL_FLY) @@ -142,7 +134,7 @@ bool flying_ship(const ship * sh) return false; } -curse *shipcurse_flyingship(ship * sh, unit * mage, double power, int duration) +static curse *shipcurse_flyingship(ship * sh, unit * mage, double power, int duration) { static const curse_type *ct_flyingship = NULL; if (!ct_flyingship) { @@ -167,3 +159,12 @@ curse *shipcurse_flyingship(ship * sh, unit * mage, double power, int duration) } } +int levitate_ship(ship * sh, unit * mage, double power, int duration) +{ + curse *c = shipcurse_flyingship(sh, mage, power, duration); + if (c) { + return c->no; + } + return 0; +} + diff --git a/src/flyingship.h b/src/flyingship.h index db7c9c716..92e81ad27 100644 --- a/src/flyingship.h +++ b/src/flyingship.h @@ -11,15 +11,12 @@ extern "C" { #endif - void register_flyingship(void); - int sp_flying_ship(castorder * co); - struct curse *shipcurse_flyingship(struct ship *sh, struct unit *mage, - double power, int duration); + void register_flyingship(void); + bool flying_ship(const ship * sh); int levitate_ship(struct ship *sh, struct unit *mage, double power, int duration); - bool flying_ship(const ship * sh); #ifdef __cplusplus }