forked from github/server
moved more related functionality from shipcurse.c to flyingship.c
This commit is contained in:
parent
d93305b180
commit
fe0d038bf3
5 changed files with 76 additions and 66 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include <kernel/config.h>
|
#include <kernel/config.h>
|
||||||
|
#include <kernel/version.h>
|
||||||
#include "flyingship.h"
|
#include "flyingship.h"
|
||||||
|
|
||||||
#include <kernel/build.h>
|
#include <kernel/build.h>
|
||||||
|
@ -11,9 +12,51 @@
|
||||||
|
|
||||||
#include <spells/shipcurse.h>
|
#include <spells/shipcurse.h>
|
||||||
|
|
||||||
|
#include <storage.h>
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
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
|
/* Name: Luftschiff
|
||||||
* Stufe: 6
|
* Stufe: 6
|
||||||
|
@ -98,3 +141,29 @@ bool flying_ship(const ship * sh)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curse *shipcurse_flyingship(ship * sh, unit * mage, double power, int duration)
|
||||||
|
{
|
||||||
|
static const curse_type *ct_flyingship = NULL;
|
||||||
|
if (!ct_flyingship) {
|
||||||
|
ct_flyingship = ct_find("flyingship");
|
||||||
|
assert(ct_flyingship);
|
||||||
|
}
|
||||||
|
if (curse_active(get_curse(sh->attribs, ct_flyingship))) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else if (is_cursed(sh->attribs, C_SHIP_SPEEDUP, 0)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* mit C_SHIP_NODRIFT haben wir kein Problem */
|
||||||
|
curse *c =
|
||||||
|
create_curse(mage, &sh->attribs, ct_flyingship, power, duration, 0.0, 0);
|
||||||
|
c->data.v = sh;
|
||||||
|
if (c && c->duration > 0) {
|
||||||
|
sh->flags |= SF_FLYING;
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,12 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void register_flyingship(void);
|
||||||
|
|
||||||
int sp_flying_ship(castorder * co);
|
int sp_flying_ship(castorder * co);
|
||||||
|
|
||||||
|
struct curse *shipcurse_flyingship(struct ship *sh, struct unit *mage,
|
||||||
|
double power, int duration);
|
||||||
int levitate_ship(struct ship *sh, struct unit *mage, double power,
|
int levitate_ship(struct ship *sh, struct unit *mage, double power,
|
||||||
int duration);
|
int duration);
|
||||||
bool flying_ship(const ship * sh);
|
bool flying_ship(const ship * sh);
|
||||||
|
|
|
@ -6730,4 +6730,6 @@ void register_spells(void)
|
||||||
register_shipcurse();
|
register_shipcurse();
|
||||||
register_buildingcurse();
|
register_buildingcurse();
|
||||||
register_magicresistance();
|
register_magicresistance();
|
||||||
|
|
||||||
|
register_flyingship();
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,41 +78,6 @@ static struct curse_type ct_stormwind = { "stormwind",
|
||||||
CURSETYP_NORM, 0, NO_MERGE, cinfo_ship
|
CURSETYP_NORM, 0, NO_MERGE, cinfo_ship
|
||||||
};
|
};
|
||||||
|
|
||||||
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
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct curse_type ct_nodrift = { "nodrift",
|
static struct curse_type ct_nodrift = { "nodrift",
|
||||||
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR), cinfo_shipnodrift
|
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR), cinfo_shipnodrift
|
||||||
};
|
};
|
||||||
|
@ -121,35 +86,10 @@ static struct curse_type ct_shipspeedup = { "shipspeedup",
|
||||||
CURSETYP_NORM, 0, 0, cinfo_ship
|
CURSETYP_NORM, 0, 0, cinfo_ship
|
||||||
};
|
};
|
||||||
|
|
||||||
curse *shipcurse_flyingship(ship * sh, unit * mage, double power, int duration)
|
|
||||||
{
|
|
||||||
static const curse_type *ct_flyingship = NULL;
|
|
||||||
if (!ct_flyingship) {
|
|
||||||
ct_flyingship = ct_find("flyingship");
|
|
||||||
assert(ct_flyingship);
|
|
||||||
}
|
|
||||||
if (curse_active(get_curse(sh->attribs, ct_flyingship))) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else if (is_cursed(sh->attribs, C_SHIP_SPEEDUP, 0)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* mit C_SHIP_NODRIFT haben wir kein Problem */
|
|
||||||
curse *c =
|
|
||||||
create_curse(mage, &sh->attribs, ct_flyingship, power, duration, 0.0, 0);
|
|
||||||
c->data.v = sh;
|
|
||||||
if (c && c->duration > 0) {
|
|
||||||
sh->flags |= SF_FLYING;
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void register_shipcurse(void)
|
void register_shipcurse(void)
|
||||||
{
|
{
|
||||||
ct_register(&ct_stormwind);
|
ct_register(&ct_stormwind);
|
||||||
ct_register(&ct_flyingship);
|
|
||||||
ct_register(&ct_nodrift);
|
ct_register(&ct_nodrift);
|
||||||
ct_register(&ct_shipspeedup);
|
ct_register(&ct_shipspeedup);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,23 +13,18 @@
|
||||||
#ifndef _SCURSE_H
|
#ifndef _SCURSE_H
|
||||||
#define _SCURSE_H
|
#define _SCURSE_H
|
||||||
|
|
||||||
#include <kernel/objtypes.h>
|
//#include <kernel/objtypes.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct locale;
|
|
||||||
struct message;
|
struct message;
|
||||||
struct ship;
|
|
||||||
struct unit;
|
|
||||||
struct curse;
|
struct curse;
|
||||||
|
|
||||||
struct message *cinfo_ship(const void *obj, objtype_t typ,
|
struct message *cinfo_ship(const void *obj, objtype_t typ,
|
||||||
const struct curse *c, int self);
|
const struct curse *c, int self);
|
||||||
void register_shipcurse(void);
|
void register_shipcurse(void);
|
||||||
struct curse *shipcurse_flyingship(struct ship *sh, struct unit *mage,
|
|
||||||
double power, int duration);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue