indentation rules, strictly applied

This commit is contained in:
Enno 2011-03-07 08:03:10 +01:00
parent 6286c3212d
commit 347a888b67
24 changed files with 4472 additions and 3270 deletions

View file

@ -10,28 +10,34 @@
#include <tolua.h> #include <tolua.h>
static int static int tolua_levitate_ship(lua_State * L)
tolua_levitate_ship(lua_State * L)
{ {
ship * sh = (ship *)tolua_tousertype(L, 1, 0); ship *sh = (ship *) tolua_tousertype(L, 1, 0);
unit * mage = (unit *)tolua_tousertype(L, 2, 0);
unit *mage = (unit *) tolua_tousertype(L, 2, 0);
double power = (double)tolua_tonumber(L, 3, 0); double power = (double)tolua_tonumber(L, 3, 0);
int duration = (int)tolua_tonumber(L, 4, 0); int duration = (int)tolua_tonumber(L, 4, 0);
int cno = levitate_ship(sh, mage, power, duration); int cno = levitate_ship(sh, mage, power, duration);
tolua_pushnumber(L, (lua_Number)cno);
tolua_pushnumber(L, (lua_Number) cno);
return 1; return 1;
} }
extern void spawn_undead(void); extern void spawn_undead(void);
extern void spawn_dragons(void); extern void spawn_dragons(void);
extern void plan_monsters(struct faction * f);
extern void plan_monsters(struct faction *f);
static int static int tolua_planmonsters(lua_State * L)
tolua_planmonsters(lua_State * L)
{ {
faction * f = (faction *)tolua_tousertype(L, 1, get_monsters()); faction *f = (faction *) tolua_tousertype(L, 1, get_monsters());
if (f) { if (f) {
plan_monsters(f); plan_monsters(f);
} }
@ -39,31 +45,32 @@ tolua_planmonsters(lua_State * L)
return 0; return 0;
} }
static int static int tolua_spawn_dragons(lua_State * L)
tolua_spawn_dragons(lua_State * L)
{ {
spawn_dragons(); spawn_dragons();
return 0; return 0;
} }
static int static int tolua_spawn_undead(lua_State * L)
tolua_spawn_undead(lua_State * L)
{ {
spawn_undead(); spawn_undead();
return 0; return 0;
} }
static int static int fix_familiars(struct lua_State *L)
fix_familiars(struct lua_State * L)
{ {
faction * f; faction *f;
for (f=factions;f;f=f->next) {
unit * u; for (f = factions; f; f = f->next) {
for (u=f->units;u;u=u->nextF) { unit *u;
struct sc_mage * mage = get_mage(u);
for (u = f->units; u; u = u->nextF) {
struct sc_mage *mage = get_mage(u);
if (mage && is_familiar(u)) { if (mage && is_familiar(u)) {
if (mage->spells && mage->magietyp==M_GRAY) { if (mage->spells && mage->magietyp == M_GRAY) {
equipment * eq; equipment *eq;
char buffer[64]; char buffer[64];
ql_free(mage->spells); ql_free(mage->spells);
@ -80,8 +87,7 @@ fix_familiars(struct lua_State * L)
return 0; return 0;
} }
void void bind_eressea(struct lua_State *L)
bind_eressea(struct lua_State * L)
{ {
tolua_module(L, NULL, 0); tolua_module(L, NULL, 0);
tolua_beginmodule(L, NULL); tolua_beginmodule(L, NULL);
@ -94,4 +100,3 @@ bind_eressea(struct lua_State * L)
} }
tolua_endmodule(L); tolua_endmodule(L);
} }

View file

@ -29,38 +29,42 @@
#include <assert.h> #include <assert.h>
typedef struct wallcurse { typedef struct wallcurse {
curse * buddy; curse *buddy;
connection * wall; connection *wall;
} wallcurse; } wallcurse;
void void cw_init(attrib * a)
cw_init(attrib * a) { {
curse * c; curse *c;
curse_init(a); curse_init(a);
c = (curse*)a->data.v; c = (curse *) a->data.v;
c->data.v = calloc(sizeof(wallcurse), 1); c->data.v = calloc(sizeof(wallcurse), 1);
} }
void void cw_write(const attrib * a, const void *target, storage * store)
cw_write(const attrib * a, const void * target, storage * store) { {
connection * b = ((wallcurse*)((curse*)a->data.v)->data.v)->wall; connection *b = ((wallcurse *) ((curse *) a->data.v)->data.v)->wall;
curse_write(a, target, store); curse_write(a, target, store);
store->w_int(store, b->id); store->w_int(store, b->id);
} }
typedef struct bresvole { typedef struct bresvole {
unsigned int id; unsigned int id;
curse * self; curse *self;
} bresolve; } bresolve;
static int resolve_buddy(variant data, void * addr); static int resolve_buddy(variant data, void *addr);
static int static int cw_read(attrib * a, void *target, storage * store)
cw_read(attrib * a, void * target, storage * store)
{ {
bresolve * br = calloc(sizeof(bresolve), 1); bresolve *br = calloc(sizeof(bresolve), 1);
curse * c = (curse*)a->data.v;
wallcurse * wc = (wallcurse*)c->data.v; curse *c = (curse *) a->data.v;
wallcurse *wc = (wallcurse *) c->data.v;
variant var; variant var;
curse_read(a, store, target); curse_read(a, store, target);
@ -75,8 +79,7 @@ cw_read(attrib * a, void * target, storage * store)
return AT_READ_OK; return AT_READ_OK;
} }
attrib_type at_cursewall = attrib_type at_cursewall = {
{
"cursewall", "cursewall",
cw_init, cw_init,
curse_done, curse_done,
@ -87,69 +90,77 @@ attrib_type at_cursewall =
}; };
static int static int resolve_buddy(variant data, void *addr)
resolve_buddy(variant data, void * addr)
{ {
curse * result = NULL; curse *result = NULL;
bresolve * br = (bresolve*)data.v;
if (br->id>=0) { bresolve *br = (bresolve *) data.v;
connection * b = find_border(br->id);
if (br->id >= 0) {
connection *b = find_border(br->id);
if (b && b->from && b->to) { if (b && b->from && b->to) {
attrib * a = a_find(b->from->attribs, &at_cursewall); attrib *a = a_find(b->from->attribs, &at_cursewall);
while (a && a->data.v!=br->self) {
curse * c = (curse*)a->data.v; while (a && a->data.v != br->self) {
wallcurse * wc = (wallcurse*)c->data.v; curse *c = (curse *) a->data.v;
if (wc->wall->id==br->id) break;
wallcurse *wc = (wallcurse *) c->data.v;
if (wc->wall->id == br->id)
break;
a = a->next; a = a->next;
} }
if (!a || a->type!=&at_cursewall) { if (!a || a->type != &at_cursewall) {
a = a_find(b->to->attribs, &at_cursewall); a = a_find(b->to->attribs, &at_cursewall);
while (a && a->type==&at_cursewall && a->data.v!=br->self) { while (a && a->type == &at_cursewall && a->data.v != br->self) {
curse * c = (curse*)a->data.v; curse *c = (curse *) a->data.v;
wallcurse * wc = (wallcurse*)c->data.v;
if (wc->wall->id==br->id) break; wallcurse *wc = (wallcurse *) c->data.v;
if (wc->wall->id == br->id)
break;
a = a->next; a = a->next;
} }
} }
if (a && a->type==&at_cursewall) { if (a && a->type == &at_cursewall) {
curse * c = (curse*)a->data.v; curse *c = (curse *) a->data.v;
free(br); free(br);
result = c; result = c;
} }
} else { } else {
/* fail, object does not exist (but if you're still loading then /* fail, object does not exist (but if you're still loading then
* you may want to try again later) */ * you may want to try again later) */
*(curse**)addr = NULL; *(curse **) addr = NULL;
return -1; return -1;
} }
} }
*(curse**)addr = result; *(curse **) addr = result;
return 0; return 0;
} }
static void static void wall_init(connection * b)
wall_init(connection * b)
{ {
wall_data * fd = (wall_data*)calloc(sizeof(wall_data), 1); wall_data *fd = (wall_data *) calloc(sizeof(wall_data), 1);
fd->countdown = -1; /* infinite */
fd->countdown = -1; /* infinite */
b->data.v = fd; b->data.v = fd;
} }
static void static void wall_destroy(connection * b)
wall_destroy(connection * b)
{ {
free(b->data.v); free(b->data.v);
} }
static void static void wall_read(connection * b, storage * store)
wall_read(connection * b, storage * store)
{ {
wall_data * fd = (wall_data*)b->data.v; wall_data *fd = (wall_data *) b->data.v;
variant mno; variant mno;
assert(fd); assert(fd);
if (store->version<STORAGE_VERSION) { if (store->version < STORAGE_VERSION) {
mno.i = store->r_int(store); mno.i = store->r_int(store);
fd->mage = findunit(mno.i); fd->mage = findunit(mno.i);
if (!fd->mage) { if (!fd->mage) {
@ -159,43 +170,46 @@ wall_read(connection * b, storage * store)
read_reference(&fd->mage, store, read_unit_reference, resolve_unit); read_reference(&fd->mage, store, read_unit_reference, resolve_unit);
} }
fd->force = store->r_int(store); fd->force = store->r_int(store);
if (store->version>=NOBORDERATTRIBS_VERSION) { if (store->version >= NOBORDERATTRIBS_VERSION) {
fd->countdown = store->r_int(store); fd->countdown = store->r_int(store);
} }
fd->active = true; fd->active = true;
} }
static void static void wall_write(const connection * b, storage * store)
wall_write(const connection * b, storage * store)
{ {
wall_data * fd = (wall_data*)b->data.v; wall_data *fd = (wall_data *) b->data.v;
write_unit_reference(fd->mage, store); write_unit_reference(fd->mage, store);
store->w_int(store, fd->force); store->w_int(store, fd->force);
store->w_int(store, fd->countdown); store->w_int(store, fd->countdown);
} }
static int static int wall_age(connection * b)
wall_age(connection * b)
{ {
wall_data * fd = (wall_data*)b->data.v; wall_data *fd = (wall_data *) b->data.v;
--fd->countdown; --fd->countdown;
return (fd->countdown>0)?AT_AGE_KEEP:AT_AGE_REMOVE; return (fd->countdown > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE;
} }
static region * static region *wall_move(const connection * b, struct unit *u,
wall_move(const connection * b, struct unit * u, struct region * from, struct region * to, boolean routing) struct region *from, struct region *to, boolean routing)
{ {
wall_data * fd = (wall_data*)b->data.v; wall_data *fd = (wall_data *) b->data.v;
if (!routing && fd->active) { if (!routing && fd->active) {
int hp = dice(3, fd->force) * u->number; int hp = dice(3, fd->force) * u->number;
hp = MIN(u->hp, hp); hp = MIN(u->hp, hp);
u->hp -= hp; u->hp -= hp;
if (u->hp) { if (u->hp) {
ADDMSG(&u->faction->msgs, msg_message("firewall_damage", ADDMSG(&u->faction->msgs, msg_message("firewall_damage",
"region unit", from, u)); "region unit", from, u));
} } else
else ADDMSG(&u->faction->msgs, msg_message("firewall_death", "region unit", from, u)); ADDMSG(&u->faction->msgs, msg_message("firewall_death", "region unit",
if (u->number>u->hp) { from, u));
if (u->number > u->hp) {
scale_number(u, u->hp); scale_number(u, u->hp);
u->hp = u->number; u->hp = u->number;
} }
@ -203,32 +217,36 @@ wall_move(const connection * b, struct unit * u, struct region * from, struct re
return to; return to;
} }
static const char * static const char *b_namefirewall(const connection * b, const region * r,
b_namefirewall(const connection * b, const region * r, const faction * f, int gflags) const faction * f, int gflags)
{ {
const char * bname; const char *bname;
unused(f); unused(f);
unused(r); unused(r);
unused(b); unused(b);
if (gflags & GF_ARTICLE) bname = "a_firewall"; if (gflags & GF_ARTICLE)
else bname = "firewall"; bname = "a_firewall";
else
bname = "firewall";
if (gflags & GF_PURE) return bname; if (gflags & GF_PURE)
return bname;
return LOC(f->locale, mkname("border", bname)); return LOC(f->locale, mkname("border", bname));
} }
border_type bt_firewall = { border_type bt_firewall = {
"firewall", VAR_VOIDPTR, "firewall", VAR_VOIDPTR,
b_transparent, /* transparent */ b_transparent, /* transparent */
wall_init, /* init */ wall_init, /* init */
wall_destroy, /* destroy */ wall_destroy, /* destroy */
wall_read, /* read */ wall_read, /* read */
wall_write, /* write */ wall_write, /* write */
b_blocknone, /* block */ b_blocknone, /* block */
b_namefirewall, /* name */ b_namefirewall, /* name */
b_rvisible, /* rvisible */ b_rvisible, /* rvisible */
b_finvisible, /* fvisible */ b_finvisible, /* fvisible */
b_uinvisible, /* uvisible */ b_uinvisible, /* uvisible */
NULL, NULL,
wall_move, wall_move,
wall_age wall_age
@ -237,17 +255,19 @@ border_type bt_firewall = {
void convert_firewall_timeouts(connection * b, attrib * a) void convert_firewall_timeouts(connection * b, attrib * a)
{ {
while (a) { while (a) {
if (b->type==&bt_firewall && a->type==&at_countdown) { if (b->type == &bt_firewall && a->type == &at_countdown) {
wall_data * fd = (wall_data *)b->data.v; wall_data *fd = (wall_data *) b->data.v;
fd->countdown = a->data.i; fd->countdown = a->data.i;
} }
} }
} }
static const char * static const char *wisps_name(const connection * b, const region * r,
wisps_name(const connection * b, const region * r, const faction * f, int gflags) const faction * f, int gflags)
{ {
const char * bname; const char *bname;
unused(f); unused(f);
unused(r); unused(r);
unused(b); unused(b);
@ -256,7 +276,8 @@ wisps_name(const connection * b, const region * r, const faction * f, int gflags
} else { } else {
bname = "wisps"; bname = "wisps";
} }
if (gflags & GF_PURE) return bname; if (gflags & GF_PURE)
return bname;
return LOC(f->locale, mkname("border", bname)); return LOC(f->locale, mkname("border", bname));
} }
@ -265,31 +286,39 @@ typedef struct wisps_data {
int rnd; int rnd;
} wisps_data; } wisps_data;
static region * static region *wisps_move(const connection * b, struct unit *u,
wisps_move(const connection * b, struct unit * u, struct region * from, struct region * next, boolean routing) struct region *from, struct region *next, boolean routing)
{ {
direction_t reldir = reldirection(from, next); direction_t reldir = reldirection(from, next);
wisps_data * wd = (wisps_data*)b->data.v;
assert(reldir!=D_SPECIAL); wisps_data *wd = (wisps_data *) b->data.v;
assert(reldir != D_SPECIAL);
if (routing && wd->wall.active) { if (routing && wd->wall.active) {
region * rl = rconnect(from, (direction_t)((reldir+MAXDIRECTIONS-1)%MAXDIRECTIONS)); region *rl =
region * rr = rconnect(from, (direction_t)((reldir+1)%MAXDIRECTIONS)); rconnect(from,
(direction_t) ((reldir + MAXDIRECTIONS - 1) % MAXDIRECTIONS));
region *rr = rconnect(from, (direction_t) ((reldir + 1) % MAXDIRECTIONS));
/* pick left and right region: */ /* pick left and right region: */
if (wd->rnd<0) { if (wd->rnd < 0) {
wd->rnd = rng_int() % 3; wd->rnd = rng_int() % 3;
} }
if (wd->rnd == 1 && rl && fval(rl->terrain, LAND_REGION)==fval(next, LAND_REGION)) return rl; if (wd->rnd == 1 && rl
if (wd->rnd == 2 && rr && fval(rr->terrain, LAND_REGION)==fval(next, LAND_REGION)) return rr; && fval(rl->terrain, LAND_REGION) == fval(next, LAND_REGION))
return rl;
if (wd->rnd == 2 && rr
&& fval(rr->terrain, LAND_REGION) == fval(next, LAND_REGION))
return rr;
} }
return next; return next;
} }
static void static void wisps_init(connection * b)
wisps_init(connection * b)
{ {
wisps_data * wd = (wisps_data*)calloc(sizeof(wisps_data), 1); wisps_data *wd = (wisps_data *) calloc(sizeof(wisps_data), 1);
b->data.v = wd; b->data.v = wd;
wd->rnd = -1; wd->rnd = -1;
@ -297,22 +326,21 @@ wisps_init(connection * b)
border_type bt_wisps = { border_type bt_wisps = {
"wisps", VAR_VOIDPTR, "wisps", VAR_VOIDPTR,
b_transparent, /* transparent */ b_transparent, /* transparent */
wisps_init, /* init */ wisps_init, /* init */
wall_destroy, /* destroy */ wall_destroy, /* destroy */
wall_read, /* read */ wall_read, /* read */
wall_write, /* write */ wall_write, /* write */
b_blocknone, /* block */ b_blocknone, /* block */
wisps_name, /* name */ wisps_name, /* name */
b_rvisible, /* rvisible */ b_rvisible, /* rvisible */
b_fvisible, /* fvisible */ b_fvisible, /* fvisible */
b_uvisible, /* uvisible */ b_uvisible, /* uvisible */
NULL, /* visible */ NULL, /* visible */
wisps_move wisps_move
}; };
void void register_curses(void)
register_curses(void)
{ {
border_convert_cb = &convert_firewall_timeouts; border_convert_cb = &convert_firewall_timeouts;
at_register(&at_cursewall); at_register(&at_cursewall);

View file

@ -7,14 +7,14 @@ extern "C" {
extern void register_curses(void); extern void register_curses(void);
/* für Feuerwände: in movement muß das noch explizit getestet werden. /* für Feuerwände: in movement muß das noch explizit getestet werden.
** besser wäre eine blcok_type::move() routine, die den effekt ** besser wäre eine blcok_type::move() routine, die den effekt
** der Bewegung auf eine struct unit anwendet. ** der Bewegung auf eine struct unit anwendet.
**/ **/
extern struct border_type bt_chaosgate; extern struct border_type bt_chaosgate;
extern struct border_type bt_firewall; extern struct border_type bt_firewall;
typedef struct wall_data { typedef struct wall_data {
struct unit * mage; struct unit *mage;
int force; int force;
boolean active; boolean active;
int countdown; int countdown;

View file

@ -14,14 +14,18 @@
#include <tests.h> #include <tests.h>
static const char * luafile = "setup.lua"; static const char *luafile = "setup.lua";
static const char * entry_point = NULL;
static const char * inifile = "eressea.ini"; static const char *entry_point = NULL;
static const char *inifile = "eressea.ini";
static int memdebug = 0; static int memdebug = 0;
static void parse_config(const char * filename) static void parse_config(const char *filename)
{ {
dictionary * d = iniparser_new(filename); dictionary *d = iniparser_new(filename);
if (d) { if (d) {
load_inifile(d); load_inifile(d);
@ -38,8 +42,7 @@ static void parse_config(const char * filename)
global.inifile = d; global.inifile = d;
} }
static int static int usage(const char *prog, const char *arg)
usage(const char * prog, const char * arg)
{ {
if (arg) { if (arg) {
fprintf(stderr, "unknown argument: %s\n\n", arg); fprintf(stderr, "unknown argument: %s\n\n", arg);
@ -50,64 +53,61 @@ usage(const char * prog, const char * arg)
"-v <level> : verbosity level\n" "-v <level> : verbosity level\n"
"-C : run in interactive mode\n" "-C : run in interactive mode\n"
"--color : force curses to use colors even when not detected\n" "--color : force curses to use colors even when not detected\n"
"--tests : run testsuite\n" "--tests : run testsuite\n" "--help : help\n", prog);
"--help : help\n", prog);
return -1; return -1;
} }
static int static int parse_args(int argc, char **argv, int *exitcode)
parse_args(int argc, char **argv, int *exitcode)
{ {
int i; int i;
int run_tests = 0; int run_tests = 0;
for (i=1;i!=argc;++i) { for (i = 1; i != argc; ++i) {
if (argv[i][0]!='-') { if (argv[i][0] != '-') {
return usage(argv[0], argv[i]); return usage(argv[0], argv[i]);
} else if (argv[i][1]=='-') { /* long format */ } else if (argv[i][1] == '-') { /* long format */
if (strcmp(argv[i]+2, "version")==0) { if (strcmp(argv[i] + 2, "version") == 0) {
printf("\n%s PBEM host\n" printf("\n%s PBEM host\n"
"Copyright (C) 1996-2005 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\n" "Copyright (C) 1996-2005 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\n"
"Compilation: " __DATE__ " at " __TIME__ "\nVersion: %f\n\n", global.gamename, version()); "Compilation: " __DATE__ " at " __TIME__ "\nVersion: %f\n\n",
} global.gamename, version());
else if (strcmp(argv[i]+2, "color")==0) { } else if (strcmp(argv[i] + 2, "color") == 0) {
/* force the editor to have colors */ /* force the editor to have colors */
force_color = 1; force_color = 1;
} } else if (strcmp(argv[i] + 2, "tests") == 0) {
else if (strcmp(argv[i]+2, "tests")==0) {
/* force the editor to have colors */ /* force the editor to have colors */
run_tests = 1; run_tests = 1;
} } else if (strcmp(argv[i] + 2, "help") == 0) {
else if (strcmp(argv[i]+2, "help")==0) {
return usage(argv[0], NULL); return usage(argv[0], NULL);
} } else {
else {
return usage(argv[0], argv[i]); return usage(argv[0], argv[i]);
} }
} else switch(argv[i][1]) { } else
case 'C': switch (argv[i][1]) {
entry_point = NULL; case 'C':
break; entry_point = NULL;
case 'e': break;
entry_point = argv[++i]; case 'e':
break; entry_point = argv[++i];
case 't': break;
turn = atoi(argv[++i]); case 't':
break; turn = atoi(argv[++i]);
case 'q': break;
verbosity = 0; case 'q':
break; verbosity = 0;
case 'v': break;
verbosity = atoi(argv[++i]); case 'v':
break; verbosity = atoi(argv[++i]);
case 'h': break;
usage(argv[0], NULL); case 'h':
return 1; usage(argv[0], NULL);
default: return 1;
*exitcode = -1; default:
usage(argv[0], argv[i]); *exitcode = -1;
return 1; usage(argv[0], argv[i]);
} return 1;
}
} }
if (run_tests) { if (run_tests) {
@ -122,11 +122,12 @@ parse_args(int argc, char **argv, int *exitcode)
#include <execinfo.h> #include <execinfo.h>
#include <signal.h> #include <signal.h>
static void static void report_segfault(int signo, siginfo_t * sinf, void *arg)
report_segfault(int signo, siginfo_t * sinf, void * arg)
{ {
void * btrace[50]; void *btrace[50];
size_t size; size_t size;
int fd = fileno(stderr); int fd = fileno(stderr);
fflush(stdout); fflush(stdout);
@ -136,8 +137,7 @@ report_segfault(int signo, siginfo_t * sinf, void * arg)
abort(); abort();
} }
static int static int setup_signal_handler(void)
setup_signal_handler(void)
{ {
struct sigaction act; struct sigaction act;
@ -147,8 +147,7 @@ setup_signal_handler(void)
return sigaction(SIGSEGV, &act, NULL); return sigaction(SIGSEGV, &act, NULL);
} }
#else #else
static int static int setup_signal_handler(void)
setup_signal_handler(void)
{ {
return 0; return 0;
} }
@ -157,19 +156,19 @@ setup_signal_handler(void)
#undef CRTDBG #undef CRTDBG
#ifdef CRTDBG #ifdef CRTDBG
#include <crtdbg.h> #include <crtdbg.h>
void void init_crtdbg(void)
init_crtdbg(void)
{ {
#if (defined(_MSC_VER)) #if (defined(_MSC_VER))
int flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); int flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
if (memdebug==1) {
flags |= _CRTDBG_CHECK_ALWAYS_DF; /* expensive */ if (memdebug == 1) {
} else if (memdebug==2) { flags |= _CRTDBG_CHECK_ALWAYS_DF; /* expensive */
flags = (flags&0x0000FFFF) | _CRTDBG_CHECK_EVERY_16_DF; } else if (memdebug == 2) {
} else if (memdebug==3) { flags = (flags & 0x0000FFFF) | _CRTDBG_CHECK_EVERY_16_DF;
flags = (flags&0x0000FFFF) | _CRTDBG_CHECK_EVERY_128_DF; } else if (memdebug == 3) {
} else if (memdebug==4) { flags = (flags & 0x0000FFFF) | _CRTDBG_CHECK_EVERY_128_DF;
flags = (flags&0x0000FFFF) | _CRTDBG_CHECK_EVERY_1024_DF; } else if (memdebug == 4) {
flags = (flags & 0x0000FFFF) | _CRTDBG_CHECK_EVERY_1024_DF;
} }
_CrtSetDbgFlag(flags); _CrtSetDbgFlag(flags);
#endif #endif
@ -177,51 +176,63 @@ init_crtdbg(void)
#endif #endif
static void static void dump_spells(void)
dump_spells(void)
{ {
struct locale * loc = find_locale("de"); struct locale *loc = find_locale("de");
FILE * F = fopen("spells.csv", "w");
quicklist * ql; FILE *F = fopen("spells.csv", "w");
quicklist *ql;
int qi; int qi;
for (ql=spells,qi=0;ql;ql_advance(&ql, &qi, 1)) { for (ql = spells, qi = 0; ql; ql_advance(&ql, &qi, 1)) {
spell * sp = (spell *)ql_get(ql, qi); spell *sp = (spell *) ql_get(ql, qi);
spell_component * spc = sp->components;
spell_component *spc = sp->components;
char components[128]; char components[128];
components[0]=0;
for (;spc->type;++spc) { components[0] = 0;
for (; spc->type; ++spc) {
strcat(components, LOC(loc, spc->type->_name[0])); strcat(components, LOC(loc, spc->type->_name[0]));
strcat(components, ","); strcat(components, ",");
} }
fprintf(F, "%s;%d;%s;%s\n", LOC(loc, mkname("spell", sp->sname)), sp->level, LOC(loc, mkname("school", magic_school[sp->magietyp])), components); fprintf(F, "%s;%d;%s;%s\n", LOC(loc, mkname("spell", sp->sname)), sp->level,
LOC(loc, mkname("school", magic_school[sp->magietyp])), components);
} }
fclose(F); fclose(F);
} }
static void static void dump_skills(void)
dump_skills(void)
{ {
struct locale * loc = find_locale("de"); struct locale *loc = find_locale("de");
FILE * F = fopen("skills.csv", "w");
race * rc; FILE *F = fopen("skills.csv", "w");
race *rc;
skill_t sk; skill_t sk;
fputs("\"Rasse\",", F); fputs("\"Rasse\",", F);
for (rc=races;rc;rc = rc->next) { for (rc = races; rc; rc = rc->next) {
if (playerrace(rc)) { if (playerrace(rc)) {
fprintf(F, "\"%s\",", LOC(loc, mkname("race", rc->_name[0]))); fprintf(F, "\"%s\",", LOC(loc, mkname("race", rc->_name[0])));
} }
} }
fputc('\n', F); fputc('\n', F);
for (sk=0;sk!=MAXSKILLS;++sk) { for (sk = 0; sk != MAXSKILLS; ++sk) {
const char * str = skillname(sk, loc); const char *str = skillname(sk, loc);
if (str) { if (str) {
fprintf(F, "\"%s\",", str); fprintf(F, "\"%s\",", str);
for (rc=races;rc;rc = rc->next) { for (rc = races; rc; rc = rc->next) {
if (playerrace(rc)) { if (playerrace(rc)) {
if (rc->bonus[sk]) fprintf(F, "%d,", rc->bonus[sk]); if (rc->bonus[sk])
else fputc(',', F); fprintf(F, "%d,", rc->bonus[sk]);
else
fputc(',', F);
} }
} }
fputc('\n', F); fputc('\n', F);
@ -234,16 +245,19 @@ void locale_init(void)
{ {
setlocale(LC_CTYPE, ""); setlocale(LC_CTYPE, "");
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");
if (towlower(0xC4)!=0xE4) { /* &Auml; => &auml; */ if (towlower(0xC4) != 0xE4) { /* &Auml; => &auml; */
log_error(("Umlaut conversion is not working properly. Wrong locale? LANG=%s\n", getenv("LANG"))); log_error(
("Umlaut conversion is not working properly. Wrong locale? LANG=%s\n",
getenv("LANG")));
} }
} }
extern void bind_eressea(struct lua_State * L); extern void bind_eressea(struct lua_State *L);
int main(int argc, char ** argv) int main(int argc, char **argv)
{ {
static int write_csv = 0; static int write_csv = 0;
int err, result = 0; int err, result = 0;
setup_signal_handler(); setup_signal_handler();
@ -282,13 +296,14 @@ int main(int argc, char ** argv)
log_error(("server execution failed with code %d\n", err)); log_error(("server execution failed with code %d\n", err));
return err; return err;
} }
#ifdef MSPACES #ifdef MSPACES
malloc_stats(); malloc_stats();
#endif #endif
eressea_done(); eressea_done();
log_close(); log_close();
if (global.inifile) iniparser_free(global.inifile); if (global.inifile)
iniparser_free(global.inifile);
return 0; return 0;
} }

File diff suppressed because it is too large Load diff

View file

@ -27,26 +27,25 @@
#define DRAGONAGE 27 #define DRAGONAGE 27
#define WYRMAGE 68 #define WYRMAGE 68
void void age_firedragon(unit * u)
age_firedragon(unit *u)
{ {
if (u->number>0 && rng_int()%100 < age_chance(u->age, DRAGONAGE, 1)) { if (u->number > 0 && rng_int() % 100 < age_chance(u->age, DRAGONAGE, 1)) {
double q = (double) u->hp / (double) (unit_max_hp(u) * u->number); double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
u->race = new_race[RC_DRAGON]; u->race = new_race[RC_DRAGON];
u->irace = NULL; u->irace = NULL;
scale_number(u,1); scale_number(u, 1);
u->hp = (int) (unit_max_hp(u) * u->number * q); u->hp = (int)(unit_max_hp(u) * u->number * q);
} }
} }
void void age_dragon(unit * u)
age_dragon(unit *u)
{ {
if (u->number>0 && rng_int()%100 < age_chance(u->age, WYRMAGE, 1)) { if (u->number > 0 && rng_int() % 100 < age_chance(u->age, WYRMAGE, 1)) {
double q = (double) u->hp / (double) (unit_max_hp(u) * u->number); double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
u->race = new_race[RC_WYRM]; u->race = new_race[RC_WYRM];
u->irace = NULL; u->irace = NULL;
u->hp = (int) (unit_max_hp(u) * u->number * q); u->hp = (int)(unit_max_hp(u) * u->number * q);
} }
} }

View file

@ -26,13 +26,11 @@
#define ILLUSIONMAX 6 #define ILLUSIONMAX 6
void void age_illusion(unit * u)
age_illusion(unit *u)
{ {
if (u->faction->race!=new_race[RC_ILLUSION]) { if (u->faction->race != new_race[RC_ILLUSION]) {
if (u->age == ILLUSIONMAX) { if (u->age == ILLUSIONMAX) {
ADDMSG(&u->faction->msgs, msg_message("warnillusiondissolve", ADDMSG(&u->faction->msgs, msg_message("warnillusiondissolve", "unit", u));
"unit", u));
} else if (u->age > ILLUSIONMAX) { } else if (u->age > ILLUSIONMAX) {
set_number(u, 0); set_number(u, 0);
ADDMSG(&u->faction->msgs, msg_message("illusiondissolve", "unit", u)); ADDMSG(&u->faction->msgs, msg_message("illusiondissolve", "unit", u));

View file

@ -28,97 +28,104 @@
#include <util/rng.h> #include <util/rng.h>
void age_firedragon(struct unit *u); void age_firedragon(struct unit *u);
void age_dragon(struct unit *u); void age_dragon(struct unit *u);
void age_illusion(struct unit *u); void age_illusion(struct unit *u);
void age_undead(struct unit *u); void age_undead(struct unit *u);
void age_skeleton(struct unit *u); void age_skeleton(struct unit *u);
void age_zombie(struct unit *u); void age_zombie(struct unit *u);
void age_ghoul(struct unit *u); void age_ghoul(struct unit *u);
static void static void oldfamiliars(unit * u)
oldfamiliars(unit * u)
{ {
char fname[64]; char fname[64];
/* these familiars have no special skills. /* these familiars have no special skills.
*/ */
snprintf(fname, sizeof(fname), "%s_familiar", u->race->_name[0]); snprintf(fname, sizeof(fname), "%s_familiar", u->race->_name[0]);
create_mage(u, M_GRAY); create_mage(u, M_GRAY);
equip_unit(u, get_equipment(fname)); equip_unit(u, get_equipment(fname));
} }
static void static void set_show_item(faction * f, item_t i)
set_show_item(faction *f, item_t i)
{ {
attrib *a = a_add(&f->attribs, a_new(&at_showitem)); attrib *a = a_add(&f->attribs, a_new(&at_showitem));
a->data.v = (void*)olditemtype[i];
a->data.v = (void *)olditemtype[i];
} }
static void static void equip_newunits(const struct equipment *eq, struct unit *u)
equip_newunits(const struct equipment * eq, struct unit *u)
{ {
struct region *r = u->region; struct region *r = u->region;
switch (old_race(u->race)) { switch (old_race(u->race)) {
case RC_ELF: case RC_ELF:
set_show_item(u->faction, I_FEENSTIEFEL); set_show_item(u->faction, I_FEENSTIEFEL);
break; break;
case RC_GOBLIN: case RC_GOBLIN:
set_show_item(u->faction, I_RING_OF_INVISIBILITY); set_show_item(u->faction, I_RING_OF_INVISIBILITY);
set_number(u, 10); set_number(u, 10);
break; break;
case RC_HUMAN: case RC_HUMAN:
if (u->building==NULL) { if (u->building == NULL) {
const building_type * btype = bt_find("castle"); const building_type *btype = bt_find("castle");
if (btype!=NULL) {
building *b = new_building(btype, r, u->faction->locale); if (btype != NULL) {
b->size = 10; building *b = new_building(btype, r, u->faction->locale);
u->building = b;
fset(u, UFL_OWNER); b->size = 10;
u->building = b;
fset(u, UFL_OWNER);
}
} }
} break;
break; case RC_CAT:
case RC_CAT: set_show_item(u->faction, I_RING_OF_INVISIBILITY);
set_show_item(u->faction, I_RING_OF_INVISIBILITY); break;
break; case RC_AQUARIAN:
case RC_AQUARIAN:
{ {
ship *sh = new_ship(st_find("boat"), u->faction->locale, r); ship *sh = new_ship(st_find("boat"), u->faction->locale, r);
sh->size = sh->type->construction->maxsize; sh->size = sh->type->construction->maxsize;
u->ship = sh; u->ship = sh;
fset(u, UFL_OWNER); fset(u, UFL_OWNER);
} }
break; break;
case RC_CENTAUR: case RC_CENTAUR:
rsethorses(r, 250+rng_int()%51+rng_int()%51); rsethorses(r, 250 + rng_int() % 51 + rng_int() % 51);
break; break;
} }
} }
/* Die Funktionen werden über den hier registrierten Namen in races.xml /* Die Funktionen werden über den hier registrierten Namen in races.xml
* in die jeweilige Rassendefiniton eingebunden */ * in die jeweilige Rassendefiniton eingebunden */
void void register_races(void)
register_races(void)
{ {
/* function initfamiliar */ /* function initfamiliar */
register_function((pf_generic)oldfamiliars, "oldfamiliars"); register_function((pf_generic) oldfamiliars, "oldfamiliars");
register_function((pf_generic)allowed_dragon, "movedragon"); register_function((pf_generic) allowed_dragon, "movedragon");
register_function((pf_generic)allowed_swim, "moveswimming"); register_function((pf_generic) allowed_swim, "moveswimming");
register_function((pf_generic)allowed_fly, "moveflying"); register_function((pf_generic) allowed_fly, "moveflying");
register_function((pf_generic)allowed_walk, "movewalking"); register_function((pf_generic) allowed_walk, "movewalking");
/* function age for race->age() */ /* function age for race->age() */
register_function((pf_generic)age_undead, "ageundead"); register_function((pf_generic) age_undead, "ageundead");
register_function((pf_generic)age_illusion, "ageillusion"); register_function((pf_generic) age_illusion, "ageillusion");
register_function((pf_generic)age_skeleton, "ageskeleton"); register_function((pf_generic) age_skeleton, "ageskeleton");
register_function((pf_generic)age_zombie, "agezombie"); register_function((pf_generic) age_zombie, "agezombie");
register_function((pf_generic)age_ghoul, "ageghoul"); register_function((pf_generic) age_ghoul, "ageghoul");
register_function((pf_generic)age_dragon, "agedragon"); register_function((pf_generic) age_dragon, "agedragon");
register_function((pf_generic)age_firedragon, "agefiredragon"); register_function((pf_generic) age_firedragon, "agefiredragon");
/* function itemdrop /* function itemdrop
* to generate battle spoils * to generate battle spoils
* race->itemdrop() */ * race->itemdrop() */
register_function((pf_generic)equip_newunits, "equip_newunits"); register_function((pf_generic) equip_newunits, "equip_newunits");
} }

View file

@ -20,6 +20,4 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View file

@ -26,29 +26,32 @@
/* libc includes */ /* libc includes */
#include <stdlib.h> #include <stdlib.h>
#define UNDEAD_MIN 90 /* mind. zahl vor weg gehen */ #define UNDEAD_MIN 90 /* mind. zahl vor weg gehen */
#define UNDEAD_BREAKUP 25 /* chance dafuer */ #define UNDEAD_BREAKUP 25 /* chance dafuer */
#define UNDEAD_BREAKUP_FRACTION (25+rng_int()%70) /* anteil der weg geht */ #define UNDEAD_BREAKUP_FRACTION (25+rng_int()%70) /* anteil der weg geht */
#define age_chance(a,b,p) (MAX(0,a-b)*p) #define age_chance(a,b,p) (MAX(0,a-b)*p)
void void age_undead(unit * u)
age_undead(unit *u)
{ {
region *r = u->region; region *r = u->region;
int n = 0; int n = 0;
/* untote, die einer partei angehoeren, koennen sich /* untote, die einer partei angehoeren, koennen sich
* absplitten, anstatt sich zu vermehren. monster * absplitten, anstatt sich zu vermehren. monster
* untote vermehren sich nur noch */ * untote vermehren sich nur noch */
if (u->number > UNDEAD_MIN && !is_monsters(u->faction) && rng_int() % 100 < UNDEAD_BREAKUP) { if (u->number > UNDEAD_MIN && !is_monsters(u->faction)
&& rng_int() % 100 < UNDEAD_BREAKUP) {
int m; int m;
unit *u2; unit *u2;
n = 0; n = 0;
for (m = u->number; m; m--) { for (m = u->number; m; m--) {
if (rng_int() % 100 < UNDEAD_BREAKUP_FRACTION) ++n; if (rng_int() % 100 < UNDEAD_BREAKUP_FRACTION)
++n;
} }
u2 = create_unit(r, get_monsters(), 0, new_race[RC_UNDEAD], 0, NULL, u); u2 = create_unit(r, get_monsters(), 0, new_race[RC_UNDEAD], 0, NULL, u);
make_undead_unit(u2); make_undead_unit(u2);
@ -56,42 +59,44 @@ age_undead(unit *u)
} }
} }
void void age_skeleton(unit * u)
age_skeleton(unit *u)
{ {
if (is_monsters(u->faction) && rng_int()%100 < age_chance(u->age, 27, 1)) { if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
int n = MAX(1,u->number/2); int n = MAX(1, u->number / 2);
double q = (double) u->hp / (double) (unit_max_hp(u) * u->number);
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
u->race = new_race[RC_SKELETON_LORD]; u->race = new_race[RC_SKELETON_LORD];
u->irace = NULL; u->irace = NULL;
scale_number(u,n); scale_number(u, n);
u->hp = (int) (unit_max_hp(u) * u->number * q); u->hp = (int)(unit_max_hp(u) * u->number * q);
} }
} }
void void age_zombie(unit * u)
age_zombie(unit *u)
{ {
if (is_monsters(u->faction) && rng_int()%100 < age_chance(u->age, 27, 1)) { if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
int n = MAX(1,u->number/2); int n = MAX(1, u->number / 2);
double q = (double) u->hp / (double) (unit_max_hp(u) * u->number);
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
u->race = new_race[RC_ZOMBIE_LORD]; u->race = new_race[RC_ZOMBIE_LORD];
u->irace = NULL; u->irace = NULL;
scale_number(u,n); scale_number(u, n);
u->hp = (int) (unit_max_hp(u) * u->number * q); u->hp = (int)(unit_max_hp(u) * u->number * q);
} }
} }
void void age_ghoul(unit * u)
age_ghoul(unit *u)
{ {
if (is_monsters(u->faction) && rng_int()%100 < age_chance(u->age, 27, 1)) { if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
int n = MAX(1,u->number/2); int n = MAX(1, u->number / 2);
double q = (double) u->hp / (double) (unit_max_hp(u) * u->number);
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
u->race = new_race[RC_GHOUL_LORD]; u->race = new_race[RC_GHOUL_LORD];
u->irace = NULL; u->irace = NULL;
scale_number(u,n); scale_number(u, n);
u->hp = (int) (unit_max_hp(u) * u->number * q); u->hp = (int)(unit_max_hp(u) * u->number * q);
} }
} }

View file

@ -44,45 +44,47 @@
extern const char *directions[]; extern const char *directions[];
typedef struct alp_data { typedef struct alp_data {
unit * mage; unit *mage;
unit * target; unit *target;
} alp_data; } alp_data;
static void static void alp_init(attrib * a)
alp_init(attrib * a)
{ {
a->data.v = calloc(sizeof(alp_data), 1); a->data.v = calloc(sizeof(alp_data), 1);
}
static void alp_done(attrib * a)
{
free(a->data.v);
}
static int alp_verify(attrib * a)
{
alp_data *ad = (alp_data *) a->data.v;
if (ad->mage && ad->target)
return 1;
return 0; /* remove the attribute */
} }
static void static void
alp_done(attrib * a) alp_write(const attrib * a, const void *owner, struct storage *store)
{ {
free(a->data.v); alp_data *ad = (alp_data *) a->data.v;
}
static int
alp_verify(attrib * a)
{
alp_data * ad = (alp_data*)a->data.v;
if (ad->mage && ad->target) return 1;
return 0; /* remove the attribute */
}
static void
alp_write(const attrib * a, const void * owner, struct storage * store)
{
alp_data * ad = (alp_data*)a->data.v;
write_unit_reference(ad->mage, store); write_unit_reference(ad->mage, store);
write_unit_reference(ad->target, store); write_unit_reference(ad->target, store);
} }
static int static int alp_read(attrib * a, void *owner, struct storage *store)
alp_read(attrib * a, void * owner, struct storage * store)
{ {
alp_data * ad = (alp_data*)a->data.v; alp_data *ad = (alp_data *) a->data.v;
int rm = read_reference(&ad->mage, store, read_unit_reference, resolve_unit); int rm = read_reference(&ad->mage, store, read_unit_reference, resolve_unit);
int rt = read_reference(&ad->target, store, read_unit_reference, resolve_unit);
if (rt==0 && rm==0 && (!ad->target || !ad->mage)) { int rt =
read_reference(&ad->target, store, read_unit_reference, resolve_unit);
if (rt == 0 && rm == 0 && (!ad->target || !ad->mage)) {
/* the target or mage disappeared. */ /* the target or mage disappeared. */
return AT_READ_FAIL; return AT_READ_FAIL;
} }
@ -99,31 +101,39 @@ static attrib_type at_alp = {
ATF_UNIQUE ATF_UNIQUE
}; };
int int sp_summon_alp(struct castorder *co)
sp_summon_alp(struct castorder *co)
{ {
unit *alp, *opfer; unit *alp, *opfer;
region *r = co->rt; region *r = co->rt;
unit *mage = co->magician.u; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
spellparameter *pa = co->par; spellparameter *pa = co->par;
const struct race * rc = new_race[RC_ALP];
struct faction * f = get_monsters(); const struct race *rc = new_race[RC_ALP];
struct message * msg;
struct faction *f = get_monsters();
struct message *msg;
opfer = pa->param[0]->data.u; opfer = pa->param[0]->data.u;
/* Der Alp gehört den Monstern, darum erhält der Magier auch keine /* Der Alp gehört den Monstern, darum erhält der Magier auch keine
* Regionsberichte von ihm. Er erhält aber später eine Mitteilung, * Regionsberichte von ihm. Er erhält aber später eine Mitteilung,
* sobald der Alp sein Opfer erreicht hat. * sobald der Alp sein Opfer erreicht hat.
*/ */
alp = create_unit(r, f, 1, rc, 0, NULL, NULL); alp = create_unit(r, f, 1, rc, 0, NULL, NULL);
set_level(alp, SK_STEALTH, 7); set_level(alp, SK_STEALTH, 7);
setstatus(alp, ST_FLEE); /* flieht */ setstatus(alp, ST_FLEE); /* flieht */
{ {
attrib * a = a_add(&alp->attribs, a_new(&at_alp)); attrib *a = a_add(&alp->attribs, a_new(&at_alp));
alp_data * ad = (alp_data*) a->data.v;
alp_data *ad = (alp_data *) a->data.v;
ad->mage = mage; ad->mage = mage;
ad->target = opfer; ad->target = opfer;
} }
@ -131,7 +141,7 @@ sp_summon_alp(struct castorder *co)
{ {
/* Wenn der Alp stirbt, den Magier nachrichtigen */ /* Wenn der Alp stirbt, den Magier nachrichtigen */
add_trigger(&alp->attribs, "destroy", trigger_unitmessage(mage, add_trigger(&alp->attribs, "destroy", trigger_unitmessage(mage,
"trigger_alp_destroy", MSG_EVENT, ML_INFO)); "trigger_alp_destroy", MSG_EVENT, ML_INFO));
/* Wenn Opfer oder Magier nicht mehr existieren, dann stirbt der Alp */ /* Wenn Opfer oder Magier nicht mehr existieren, dann stirbt der Alp */
add_trigger(&mage->attribs, "destroy", trigger_killunit(alp)); add_trigger(&mage->attribs, "destroy", trigger_killunit(alp));
add_trigger(&opfer->attribs, "destroy", trigger_killunit(alp)); add_trigger(&opfer->attribs, "destroy", trigger_killunit(alp));
@ -144,16 +154,21 @@ sp_summon_alp(struct castorder *co)
} }
void void alp_findet_opfer(unit * alp, region * r)
alp_findet_opfer(unit *alp, region *r)
{ {
curse * c; curse *c;
attrib * a = a_find(alp->attribs, &at_alp);
alp_data * ad = (alp_data*)a->data.v; attrib *a = a_find(alp->attribs, &at_alp);
alp_data *ad = (alp_data *) a->data.v;
unit *mage = ad->mage; unit *mage = ad->mage;
unit *opfer = ad->target; unit *opfer = ad->target;
double effect; double effect;
message * msg;
message *msg;
assert(opfer); assert(opfer);
assert(mage); assert(mage);
@ -165,41 +180,42 @@ alp_findet_opfer(unit *alp, region *r)
msg_release(msg); msg_release(msg);
/* Relations werden in destroy_unit(alp) automatisch gelöscht. /* Relations werden in destroy_unit(alp) automatisch gelöscht.
* Die Aktionen, die beim Tod des Alps ausgelöst werden sollen, * Die Aktionen, die beim Tod des Alps ausgelöst werden sollen,
* müssen jetzt aber deaktiviert werden, sonst werden sie gleich * müssen jetzt aber deaktiviert werden, sonst werden sie gleich
* beim destroy_unit(alp) ausgelöst. * beim destroy_unit(alp) ausgelöst.
*/ */
a_removeall(&alp->attribs, &at_eventhandler); a_removeall(&alp->attribs, &at_eventhandler);
/* Alp umwandeln in Curse */ /* Alp umwandeln in Curse */
effect = -2; effect = -2;
c = create_curse(mage, &opfer->attribs, ct_find("worse"), 2, 2, effect, opfer->number); c =
create_curse(mage, &opfer->attribs, ct_find("worse"), 2, 2, effect,
opfer->number);
/* solange es noch keine spezielle alp-Antimagie gibt, reagiert der /* solange es noch keine spezielle alp-Antimagie gibt, reagiert der
* auch auf normale */ * auch auf normale */
set_number(alp, 0); set_number(alp, 0);
/* wenn der Magier stirbt, wird der Curse wieder vom Opfer genommen */ /* wenn der Magier stirbt, wird der Curse wieder vom Opfer genommen */
add_trigger(&mage->attribs, "destroy", trigger_removecurse(c, opfer)); add_trigger(&mage->attribs, "destroy", trigger_removecurse(c, opfer));
} }
void void register_alp(void)
register_alp(void)
{ {
at_register(&at_alp); at_register(&at_alp);
} }
unit * unit *alp_target(unit * alp)
alp_target(unit *alp)
{ {
alp_data* ad; alp_data *ad;
unit * target = NULL;
attrib * a = a_find(alp->attribs, &at_alp); unit *target = NULL;
if (a) { attrib *a = a_find(alp->attribs, &at_alp);
ad = (alp_data*) a->data.v;
target = ad->target; if (a) {
} ad = (alp_data *) a->data.v;
return target; target = ad->target;
}
return target;
} }

View file

@ -18,9 +18,9 @@
extern "C" { extern "C" {
#endif #endif
struct castorder; struct castorder;
struct region; struct region;
struct unit; struct unit;
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
/* Name: Alp /* Name: Alp
* Stufe: 15 * Stufe: 15
@ -41,11 +41,11 @@ struct unit;
* (UNITSPELL | SEARCHGLOBAL | TESTRESISTANCE) * (UNITSPELL | SEARCHGLOBAL | TESTRESISTANCE)
*/ */
extern int sp_summon_alp(struct castorder *co); extern int sp_summon_alp(struct castorder *co);
extern void register_alp(void); extern void register_alp(void);
struct unit* alp_target(struct unit *alp); struct unit *alp_target(struct unit *alp);
void alp_findet_opfer(struct unit *alp, struct region *r); void alp_findet_opfer(struct unit *alp, struct region *r);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -34,13 +34,13 @@
#include <assert.h> #include <assert.h>
static message * static message *cinfo_building(const void *obj, typ_t typ, const curse * c,
cinfo_building(const void * obj, typ_t typ, const curse *c, int self) int self)
{ {
unused(typ); unused(typ);
assert(typ == TYP_BUILDING); assert(typ == TYP_BUILDING);
if (self != 0){ /* owner or inside */ if (self != 0) { /* owner or inside */
return msg_message(mkname("curseinfo", c->type->cname), "id", c->no); return msg_message(mkname("curseinfo", c->type->cname), "id", c->no);
} }
return msg_message(mkname("curseinfo", "buildingunknown"), "id", c->no); return msg_message(mkname("curseinfo", "buildingunknown"), "id", c->no);
@ -49,26 +49,31 @@ cinfo_building(const void * obj, typ_t typ, const curse *c, int self)
/* CurseInfo mit Spezialabfragen */ /* CurseInfo mit Spezialabfragen */
/* C_MAGICWALLS*/ /* C_MAGICWALLS*/
static message * static message *cinfo_magicrunes(const void *obj, typ_t typ, const curse * c,
cinfo_magicrunes(const void * obj, typ_t typ, const curse *c, int self) int self)
{ {
message * msg = NULL; message *msg = NULL;
if (typ == TYP_BUILDING){
building * b; if (typ == TYP_BUILDING) {
b = (building*)obj; building *b;
b = (building *) obj;
if (self != 0) { if (self != 0) {
msg = msg_message("curseinfo::magicrunes_building", "building id", b, c->no); msg =
msg_message("curseinfo::magicrunes_building", "building id", b, c->no);
} }
} else if (typ == TYP_SHIP) { } else if (typ == TYP_SHIP) {
ship *sh; ship *sh;
sh = (ship*)obj;
if (self != 0){ sh = (ship *) obj;
if (self != 0) {
msg = msg_message("curseinfo::magicrunes_ship", "ship id", sh, c->no); msg = msg_message("curseinfo::magicrunes_ship", "ship id", sh, c->no);
} }
} }
return msg; return msg;
} }
static struct curse_type ct_magicrunes = { "magicrunes", static struct curse_type ct_magicrunes = { "magicrunes",
CURSETYP_NORM, 0, M_SUMEFFECT, cinfo_magicrunes CURSETYP_NORM, 0, M_SUMEFFECT, cinfo_magicrunes
}; };
@ -85,12 +90,11 @@ static struct curse_type ct_strongwall = { "strongwall",
/* Ewige Mauern-Zauber */ /* Ewige Mauern-Zauber */
static struct curse_type ct_nocostbuilding = { "nocostbuilding", static struct curse_type ct_nocostbuilding = { "nocostbuilding",
CURSETYP_NORM, CURSE_NOAGE|CURSE_ONLYONE, NO_MERGE, cinfo_building CURSETYP_NORM, CURSE_NOAGE | CURSE_ONLYONE, NO_MERGE, cinfo_building
}; };
void void register_buildingcurse(void)
register_buildingcurse(void)
{ {
ct_register(&ct_magicwalls); ct_register(&ct_magicwalls);
ct_register(&ct_strongwall); ct_register(&ct_strongwall);

View file

@ -17,12 +17,12 @@
extern "C" { extern "C" {
#endif #endif
struct locale; struct locale;
struct curse; struct curse;
extern void register_buildingcurse(void); extern void register_buildingcurse(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* _BCURSE_H */ #endif /* _BCURSE_H */

File diff suppressed because it is too large Load diff

View file

@ -20,36 +20,66 @@ extern "C" {
struct fighter; struct fighter;
/* Kampfzauber */ /* Kampfzauber */
extern int sp_fumbleshield(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_fumbleshield(struct fighter *fi, int level, double power,
extern int sp_shadowknights(struct fighter * fi, int level, double power, struct spell * sp); struct spell *sp);
extern int sp_combatrosthauch(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_shadowknights(struct fighter *fi, int level, double power,
extern int sp_kampfzauber(struct fighter * fi, int level, double power, struct spell * sp); struct spell *sp);
extern int sp_healing(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_combatrosthauch(struct fighter *fi, int level, double power,
extern int sp_keeploot(struct fighter * fi, int level, double power, struct spell * sp); struct spell *sp);
extern int sp_reanimate(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_kampfzauber(struct fighter *fi, int level, double power,
extern int sp_chaosrow(struct fighter * fi, int level, double power, struct spell * sp); struct spell *sp);
extern int sp_flee(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_healing(struct fighter *fi, int level, double power,
extern int sp_berserk(struct fighter * fi, int level, double power, struct spell * sp); struct spell *sp);
extern int sp_tiredsoldiers(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_keeploot(struct fighter *fi, int level, double power,
extern int sp_reeling_arrows(struct fighter * fi, int level, double power, struct spell * sp); struct spell *sp);
extern int sp_denyattack(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_reanimate(struct fighter *fi, int level, double power,
extern int sp_sleep(struct fighter * fi, int level, double power, struct spell * sp); struct spell *sp);
extern int sp_windshield(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_chaosrow(struct fighter *fi, int level, double power,
extern int sp_strong_wall(struct fighter * fi, int level, double power, struct spell * sp); struct spell *sp);
extern int sp_petrify(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_flee(struct fighter *fi, int level, double power,
extern int sp_hero(struct fighter * fi, int level, double power, struct spell * sp); struct spell *sp);
extern int sp_frighten(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_berserk(struct fighter *fi, int level, double power,
extern int sp_mindblast(struct fighter * fi, int level, double power, struct spell * sp); struct spell *sp);
extern int sp_mindblast_temp(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_tiredsoldiers(struct fighter *fi, int level, double power,
extern int sp_speed(struct fighter * fi, int level, double power, struct spell * sp); struct spell *sp);
extern int sp_wolfhowl(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_reeling_arrows(struct fighter *fi, int level, double power,
extern int sp_dragonodem(struct fighter * fi, int level, double power, struct spell * sp); struct spell *sp);
extern int sp_reduceshield(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_denyattack(struct fighter *fi, int level, double power,
extern int sp_armorshield(struct fighter * fi, int level, double power, struct spell * sp); struct spell *sp);
extern int sp_stun(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_sleep(struct fighter *fi, int level, double power,
extern int sp_undeadhero(struct fighter * fi, int level, double power, struct spell * sp); struct spell *sp);
extern int sp_shadowcall(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_windshield(struct fighter *fi, int level, double power,
extern int sp_immolation(struct fighter * fi, int level, double power, struct spell * sp); struct spell *sp);
extern int sp_strong_wall(struct fighter *fi, int level, double power,
struct spell *sp);
extern int sp_petrify(struct fighter *fi, int level, double power,
struct spell *sp);
extern int sp_hero(struct fighter *fi, int level, double power,
struct spell *sp);
extern int sp_frighten(struct fighter *fi, int level, double power,
struct spell *sp);
extern int sp_mindblast(struct fighter *fi, int level, double power,
struct spell *sp);
extern int sp_mindblast_temp(struct fighter *fi, int level, double power,
struct spell *sp);
extern int sp_speed(struct fighter *fi, int level, double power,
struct spell *sp);
extern int sp_wolfhowl(struct fighter *fi, int level, double power,
struct spell *sp);
extern int sp_dragonodem(struct fighter *fi, int level, double power,
struct spell *sp);
extern int sp_reduceshield(struct fighter *fi, int level, double power,
struct spell *sp);
extern int sp_armorshield(struct fighter *fi, int level, double power,
struct spell *sp);
extern int sp_stun(struct fighter *fi, int level, double power,
struct spell *sp);
extern int sp_undeadhero(struct fighter *fi, int level, double power,
struct spell *sp);
extern int sp_shadowcall(struct fighter *fi, int level, double power,
struct spell *sp);
extern int sp_immolation(struct fighter *fi, int level, double power,
struct spell *sp);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -41,10 +41,10 @@
/* /*
* godcursezone * godcursezone
*/ */
static message * static message *cinfo_cursed_by_the_gods(const void *obj, typ_t typ,
cinfo_cursed_by_the_gods(const void * obj, typ_t typ, const curse *c, int self) const curse * c, int self)
{ {
region *r = (region *)obj; region *r = (region *) obj;
unused(typ); unused(typ);
unused(self); unused(self);
@ -58,7 +58,8 @@ cinfo_cursed_by_the_gods(const void * obj, typ_t typ, const curse *c, int self)
static struct curse_type ct_godcursezone = { static struct curse_type ct_godcursezone = {
"godcursezone", "godcursezone",
CURSETYP_NORM, CURSE_IMMUNE|CURSE_ISNEW, (NO_MERGE), cinfo_cursed_by_the_gods, CURSETYP_NORM, CURSE_IMMUNE | CURSE_ISNEW, (NO_MERGE),
cinfo_cursed_by_the_gods,
}; };
@ -66,8 +67,8 @@ static struct curse_type ct_godcursezone = {
/* /*
* C_GBDREAM * C_GBDREAM
*/ */
static message * static message *cinfo_dreamcurse(const void *obj, typ_t typ, const curse * c,
cinfo_dreamcurse(const void * obj, typ_t typ, const curse *c, int self) int self)
{ {
unused(self); unused(self);
unused(typ); unused(typ);
@ -90,8 +91,8 @@ static struct curse_type ct_gbdream = {
* C_MAGICSTREET * C_MAGICSTREET
* erzeugt Straßennetz * erzeugt Straßennetz
*/ */
static message * static message *cinfo_magicstreet(const void *obj, typ_t typ, const curse * c,
cinfo_magicstreet(const void * obj, typ_t typ, const curse *c, int self) int self)
{ {
unused(typ); unused(typ);
unused(self); unused(self);
@ -113,8 +114,8 @@ static struct curse_type ct_magicstreet = {
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
static message * static message *cinfo_antimagiczone(const void *obj, typ_t typ, const curse * c,
cinfo_antimagiczone(const void * obj, typ_t typ, const curse *c, int self) int self)
{ {
unused(typ); unused(typ);
unused(self); unused(self);
@ -131,19 +132,22 @@ cinfo_antimagiczone(const void * obj, typ_t typ, const curse *c, int self)
/* alle Magier können eine Antimagiezone wahrnehmen */ /* alle Magier können eine Antimagiezone wahrnehmen */
static int static int
cansee_antimagiczone(const struct faction *viewer, const void * obj, typ_t typ, const curse *c, int self) cansee_antimagiczone(const struct faction *viewer, const void *obj, typ_t typ,
const curse * c, int self)
{ {
region *r; region *r;
unit *u = NULL; unit *u = NULL;
unit *mage = c->magician; unit *mage = c->magician;
unused(typ); unused(typ);
assert(typ == TYP_REGION); assert(typ == TYP_REGION);
r = (region *)obj; r = (region *) obj;
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
if (u->faction==viewer) { if (u->faction == viewer) {
if (u==mage) { if (u == mage) {
self = 2; self = 2;
break; break;
} }
@ -154,6 +158,7 @@ cansee_antimagiczone(const struct faction *viewer, const void * obj, typ_t typ,
} }
return self; return self;
} }
static struct curse_type ct_antimagiczone = { static struct curse_type ct_antimagiczone = {
"antimagiczone", "antimagiczone",
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR), CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
@ -161,8 +166,8 @@ static struct curse_type ct_antimagiczone = {
}; };
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
static message * static message *cinfo_farvision(const void *obj, typ_t typ, const curse * c,
cinfo_farvision(const void * obj, typ_t typ, const curse *c, int self) int self)
{ {
unused(typ); unused(typ);
unused(obj); unused(obj);
@ -191,6 +196,7 @@ static struct curse_type ct_fogtrap = {
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR), CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
cinfo_simple cinfo_simple
}; };
static struct curse_type ct_maelstrom = { static struct curse_type ct_maelstrom = {
"maelstrom", "maelstrom",
CURSETYP_NORM, CURSE_ISNEW, (M_DURATION | M_VIGOUR), CURSETYP_NORM, CURSE_ISNEW, (M_DURATION | M_VIGOUR),
@ -199,24 +205,26 @@ static struct curse_type ct_maelstrom = {
static struct curse_type ct_blessedharvest = { static struct curse_type ct_blessedharvest = {
"blessedharvest", "blessedharvest",
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR ), CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
cinfo_simple cinfo_simple
}; };
static struct curse_type ct_drought = { static struct curse_type ct_drought = {
"drought", "drought",
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR ), CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
cinfo_simple cinfo_simple
}; };
static struct curse_type ct_badlearn = { static struct curse_type ct_badlearn = {
"badlearn", "badlearn",
CURSETYP_NORM, CURSE_ISNEW, ( M_DURATION | M_VIGOUR ), CURSETYP_NORM, CURSE_ISNEW, (M_DURATION | M_VIGOUR),
cinfo_simple cinfo_simple
}; };
/* Trübsal-Zauber */ /* Trübsal-Zauber */
static struct curse_type ct_depression = { static struct curse_type ct_depression = {
"depression", "depression",
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR ), CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
cinfo_simple cinfo_simple
}; };
@ -226,18 +234,21 @@ static struct curse_type ct_astralblock = {
CURSETYP_NORM, 0, NO_MERGE, CURSETYP_NORM, 0, NO_MERGE,
cinfo_simple cinfo_simple
}; };
/* Unterhaltungsanteil vermehren */ /* Unterhaltungsanteil vermehren */
static struct curse_type ct_generous = { static struct curse_type ct_generous = {
"generous", "generous",
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR | M_MAXEFFECT ), CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR | M_MAXEFFECT),
cinfo_simple cinfo_simple
}; };
/* verhindert Attackiere regional */ /* verhindert Attackiere regional */
static struct curse_type ct_peacezone = { static struct curse_type ct_peacezone = {
"peacezone", "peacezone",
CURSETYP_NORM, 0, NO_MERGE, CURSETYP_NORM, 0, NO_MERGE,
cinfo_simple cinfo_simple
}; };
/* erniedigt Magieresistenz von nicht-aliierten Einheiten, wirkt nur 1x /* erniedigt Magieresistenz von nicht-aliierten Einheiten, wirkt nur 1x
* pro Einheit */ * pro Einheit */
static struct curse_type ct_badmagicresistancezone = { static struct curse_type ct_badmagicresistancezone = {
@ -245,6 +256,7 @@ static struct curse_type ct_badmagicresistancezone = {
CURSETYP_NORM, 0, NO_MERGE, CURSETYP_NORM, 0, NO_MERGE,
cinfo_simple cinfo_simple
}; };
/* erhöht Magieresistenz von aliierten Einheiten, wirkt nur 1x pro /* erhöht Magieresistenz von aliierten Einheiten, wirkt nur 1x pro
* Einheit */ * Einheit */
static struct curse_type ct_goodmagicresistancezone = { static struct curse_type ct_goodmagicresistancezone = {
@ -252,16 +264,19 @@ static struct curse_type ct_goodmagicresistancezone = {
CURSETYP_NORM, 0, NO_MERGE, CURSETYP_NORM, 0, NO_MERGE,
cinfo_simple cinfo_simple
}; };
static struct curse_type ct_riotzone = { static struct curse_type ct_riotzone = {
"riotzone", "riotzone",
CURSETYP_NORM, 0, (M_DURATION), CURSETYP_NORM, 0, (M_DURATION),
cinfo_simple cinfo_simple
}; };
static struct curse_type ct_holyground = { static struct curse_type ct_holyground = {
"holyground", "holyground",
CURSETYP_NORM, CURSE_NOAGE, (M_VIGOUR_ADD), CURSETYP_NORM, CURSE_NOAGE, (M_VIGOUR_ADD),
cinfo_simple cinfo_simple
}; };
static struct curse_type ct_healing = { static struct curse_type ct_healing = {
"healingzone", "healingzone",
CURSETYP_NORM, 0, (M_VIGOUR | M_DURATION), CURSETYP_NORM, 0, (M_VIGOUR | M_DURATION),
@ -269,8 +284,7 @@ static struct curse_type ct_healing = {
}; };
void void register_regioncurse(void)
register_regioncurse(void)
{ {
ct_register(&ct_fogtrap); ct_register(&ct_fogtrap);
ct_register(&ct_antimagiczone); ct_register(&ct_antimagiczone);
@ -292,5 +306,3 @@ register_regioncurse(void)
ct_register(&ct_holyground); ct_register(&ct_holyground);
ct_register(&ct_healing); ct_register(&ct_healing);
} }

View file

@ -17,12 +17,12 @@
extern "C" { extern "C" {
#endif #endif
struct curse; struct curse;
struct locale; struct locale;
extern void register_regioncurse(void); extern void register_regioncurse(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* _RCURSE_H */ #endif /* _RCURSE_H */

View file

@ -35,21 +35,20 @@
#include <assert.h> #include <assert.h>
message * message *cinfo_ship(const void *obj, typ_t typ, const curse * c, int self)
cinfo_ship(const void * obj, typ_t typ, const curse *c, int self)
{ {
message * msg; message *msg;
unused(typ); unused(typ);
unused(obj); unused(obj);
assert(typ == TYP_SHIP); assert(typ == TYP_SHIP);
if (self != 0) { /* owner or inside */ if (self != 0) { /* owner or inside */
msg = msg_message(mkname("curseinfo", c->type->cname), "id", c->no); msg = msg_message(mkname("curseinfo", c->type->cname), "id", c->no);
} else { } else {
msg = msg_message("curseinfo::ship_unknown", "id", c->no); msg = msg_message("curseinfo::ship_unknown", "id", c->no);
} }
if (msg==NULL) { if (msg == NULL) {
log_error(("There is no curseinfo for %s.\n", c->type->cname)); log_error(("There is no curseinfo for %s.\n", c->type->cname));
} }
return msg; return msg;
@ -58,16 +57,17 @@ cinfo_ship(const void * obj, typ_t typ, const curse *c, int self)
/* CurseInfo mit Spezialabfragen */ /* CurseInfo mit Spezialabfragen */
/* C_SHIP_NODRIFT */ /* C_SHIP_NODRIFT */
static message * static message *cinfo_shipnodrift(const void *obj, typ_t typ, const curse * c,
cinfo_shipnodrift(const void * obj, typ_t typ, const curse *c, int self) int self)
{ {
ship * sh = (ship *)obj; ship *sh = (ship *) obj;
unused(typ); unused(typ);
assert(typ == TYP_SHIP); assert(typ == TYP_SHIP);
if (self != 0) { if (self != 0) {
return msg_message("curseinfo::shipnodrift_1", "ship duration id", sh, c->duration, c->no); return msg_message("curseinfo::shipnodrift_1", "ship duration id", sh,
c->duration, c->no);
} }
return msg_message("curseinfo::shipnodrift_0", "ship id", sh, c->no); return msg_message("curseinfo::shipnodrift_0", "ship id", sh, c->no);
} }
@ -76,26 +76,33 @@ 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) { static int flyingship_read(storage * store, curse * c, void *target)
ship * sh = (ship *)target; {
ship *sh = (ship *) target;
c->data.v = sh; c->data.v = sh;
if (store->version<FOSS_VERSION) { if (store->version < FOSS_VERSION) {
sh->flags |= SF_FLYING; sh->flags |= SF_FLYING;
return 0; return 0;
} }
assert(sh->flags&SF_FLYING); assert(sh->flags & SF_FLYING);
return 0; return 0;
} }
static int flyingship_write(storage * store, const curse * c, const void * target) { static int flyingship_write(storage * store, const curse * c,
const ship * sh = (const ship *)target; const void *target)
assert(sh->flags&SF_FLYING); {
const ship *sh = (const ship *)target;
assert(sh->flags & SF_FLYING);
return 0; return 0;
} }
static int flyingship_age(curse * c) { static int flyingship_age(curse * c)
ship * sh = (ship *)c->data.v; {
if (sh && c->duration==1) { ship *sh = (ship *) c->data.v;
if (sh && c->duration == 1) {
freset(sh, SF_FLYING); freset(sh, SF_FLYING);
return 1; return 1;
} }
@ -103,19 +110,22 @@ static int flyingship_age(curse * c) {
} }
static struct curse_type ct_flyingship = { "flyingship", static struct curse_type ct_flyingship = { "flyingship",
CURSETYP_NORM, 0, NO_MERGE, cinfo_ship, NULL, flyingship_read, flyingship_write, NULL, flyingship_age 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
}; };
static struct curse_type ct_shipspeedup = { "shipspeedup", static struct curse_type ct_shipspeedup = { "shipspeedup",
CURSETYP_NORM, 0, 0, cinfo_ship CURSETYP_NORM, 0, 0, cinfo_ship
}; };
curse * curse *shipcurse_flyingship(ship * sh, unit * mage, double power, int duration)
shipcurse_flyingship(ship* sh, unit * mage, double power, int duration)
{ {
static const curse_type * ct_flyingship = NULL; static const curse_type *ct_flyingship = NULL;
if (!ct_flyingship) { if (!ct_flyingship) {
ct_flyingship = ct_find("flyingship"); ct_flyingship = ct_find("flyingship");
assert(ct_flyingship); assert(ct_flyingship);
@ -126,31 +136,30 @@ shipcurse_flyingship(ship* sh, unit * mage, double power, int duration)
return NULL; return NULL;
} else { } else {
/* mit C_SHIP_NODRIFT haben wir kein Problem */ /* mit C_SHIP_NODRIFT haben wir kein Problem */
curse * c = create_curse(mage, &sh->attribs, ct_flyingship, power, duration, 0.0, 0); curse *c =
create_curse(mage, &sh->attribs, ct_flyingship, power, duration, 0.0, 0);
c->data.v = sh; c->data.v = sh;
if (c && c->duration>0) { if (c && c->duration > 0) {
sh->flags |= SF_FLYING; sh->flags |= SF_FLYING;
} }
return c; return c;
} }
} }
int int levitate_ship(ship * sh, unit * mage, double power, int duration)
levitate_ship(ship * sh, unit * mage, double power, int duration)
{ {
curse * c = shipcurse_flyingship(sh, mage, power, duration); curse *c = shipcurse_flyingship(sh, mage, power, duration);
if (c) { if (c) {
return c->no; return c->no;
} }
return 0; return 0;
} }
void void register_shipcurse(void)
register_shipcurse(void)
{ {
ct_register(&ct_stormwind); ct_register(&ct_stormwind);
ct_register(&ct_flyingship); ct_register(&ct_flyingship);
ct_register(&ct_nodrift); ct_register(&ct_nodrift);
ct_register(&ct_shipspeedup); ct_register(&ct_shipspeedup);
} }

View file

@ -17,14 +17,17 @@
extern "C" { extern "C" {
#endif #endif
struct locale; struct locale;
struct message; struct message;
extern struct message * cinfo_ship(const void * obj, typ_t typ, const struct curse *c, int self); extern struct message *cinfo_ship(const void *obj, typ_t typ,
extern void register_shipcurse(void); const struct curse *c, int self);
extern struct curse * shipcurse_flyingship(struct ship* sh, struct unit * mage, double power, int duration); extern void register_shipcurse(void);
int levitate_ship(struct ship * sh, struct unit * mage, double power, int duration); extern 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 duration);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* _SCURSE_H */ #endif /* _SCURSE_H */

File diff suppressed because it is too large Load diff

View file

@ -24,7 +24,7 @@ extern "C" {
extern void register_spells(void); extern void register_spells(void);
void set_spelldata(struct spell * sp); void set_spelldata(struct spell *sp);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -43,15 +43,16 @@
* C_AURA * C_AURA
*/ */
/* erhöht/senkt regeneration und maxaura um effect% */ /* erhöht/senkt regeneration und maxaura um effect% */
static message * static message *cinfo_auraboost(const void *obj, typ_t typ, const curse * c,
cinfo_auraboost(const void * obj, typ_t typ, const curse *c, int self) int self)
{ {
struct unit *u = (struct unit *)obj; struct unit *u = (struct unit *)obj;
unused(typ); unused(typ);
assert(typ == TYP_UNIT); assert(typ == TYP_UNIT);
if (self != 0){ if (self != 0) {
if (curse_geteffect(c) > 100){ if (curse_geteffect(c) > 100) {
return msg_message("curseinfo::auraboost_0", "unit id", u, c->no); return msg_message("curseinfo::auraboost_0", "unit id", u, c->no);
} else { } else {
return msg_message("curseinfo::auraboost_1", "unit id", u, c->no); return msg_message("curseinfo::auraboost_1", "unit id", u, c->no);
@ -59,6 +60,7 @@ cinfo_auraboost(const void * obj, typ_t typ, const curse *c, int self)
} }
return NULL; return NULL;
} }
static struct curse_type ct_auraboost = { static struct curse_type ct_auraboost = {
"auraboost", "auraboost",
CURSETYP_NORM, CURSE_SPREADMODULO, (NO_MERGE), CURSETYP_NORM, CURSE_SPREADMODULO, (NO_MERGE),
@ -68,27 +70,30 @@ static struct curse_type ct_auraboost = {
/* Magic Boost - Gabe des Chaos */ /* Magic Boost - Gabe des Chaos */
static struct curse_type ct_magicboost = { static struct curse_type ct_magicboost = {
"magicboost", "magicboost",
CURSETYP_UNIT, CURSE_SPREADMODULO|CURSE_IMMUNE, M_MEN, cinfo_simple CURSETYP_UNIT, CURSE_SPREADMODULO | CURSE_IMMUNE, M_MEN, cinfo_simple
}; };
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
/* /*
* C_SLAVE * C_SLAVE
*/ */
static message * static message *cinfo_slave(const void *obj, typ_t typ, const curse * c,
cinfo_slave(const void * obj, typ_t typ, const curse *c, int self) int self)
{ {
unit *u; unit *u;
unused(typ); unused(typ);
assert(typ == TYP_UNIT); assert(typ == TYP_UNIT);
u = (unit *)obj; u = (unit *) obj;
if (self != 0){ if (self != 0) {
return msg_message("curseinfo::slave_1", "unit duration id", u, c->duration, c->no); return msg_message("curseinfo::slave_1", "unit duration id", u, c->duration,
c->no);
} }
return NULL; return NULL;
} }
static struct curse_type ct_slavery = { "slavery", static struct curse_type ct_slavery = { "slavery",
CURSETYP_NORM, 0, NO_MERGE, CURSETYP_NORM, 0, NO_MERGE,
cinfo_slave cinfo_slave
@ -98,18 +103,20 @@ static struct curse_type ct_slavery = { "slavery",
/* /*
* C_CALM * C_CALM
*/ */
static message * static message *cinfo_calm(const void *obj, typ_t typ, const curse * c,
cinfo_calm(const void * obj, typ_t typ, const curse *c, int self) int self)
{ {
unused(typ); unused(typ);
assert(typ == TYP_UNIT); assert(typ == TYP_UNIT);
if (c->magician && c->magician->faction) { if (c->magician && c->magician->faction) {
faction *f = c->magician->faction; faction *f = c->magician->faction;
unit *u = (unit *)obj;
if (f==NULL || self == 0) { unit *u = (unit *) obj;
const struct race * rc = u_irace(c->magician);
if (f == NULL || self == 0) {
const struct race *rc = u_irace(c->magician);
return msg_message("curseinfo::calm_0", "unit race id", u, rc, c->no); return msg_message("curseinfo::calm_0", "unit race id", u, rc, c->no);
} }
return msg_message("curseinfo::calm_1", "unit faction id", u, f, c->no); return msg_message("curseinfo::calm_1", "unit faction id", u, f, c->no);
@ -119,7 +126,7 @@ cinfo_calm(const void * obj, typ_t typ, const curse *c, int self)
static struct curse_type ct_calmmonster = { static struct curse_type ct_calmmonster = {
"calmmonster", "calmmonster",
CURSETYP_NORM, CURSE_SPREADNEVER|CURSE_ONLYONE, NO_MERGE, CURSETYP_NORM, CURSE_SPREADNEVER | CURSE_ONLYONE, NO_MERGE,
cinfo_calm cinfo_calm
}; };
@ -127,18 +134,21 @@ static struct curse_type ct_calmmonster = {
/* /*
* C_SPEED * C_SPEED
*/ */
static message * static message *cinfo_speed(const void *obj, typ_t typ, const curse * c,
cinfo_speed(const void * obj, typ_t typ, const curse *c, int self) int self)
{ {
unused(typ); unused(typ);
assert(typ == TYP_UNIT); assert(typ == TYP_UNIT);
if (self != 0){ if (self != 0) {
unit *u = (unit *)obj; unit *u = (unit *) obj;
return msg_message("curseinfo::speed_1", "unit number duration id", u, c->data.i, c->duration, c->no);
return msg_message("curseinfo::speed_1", "unit number duration id", u,
c->data.i, c->duration, c->no);
} }
return NULL; return NULL;
} }
static struct curse_type ct_speed = { static struct curse_type ct_speed = {
"speed", "speed",
CURSETYP_UNIT, CURSE_SPREADNEVER, M_MEN, CURSETYP_UNIT, CURSE_SPREADNEVER, M_MEN,
@ -149,22 +159,23 @@ static struct curse_type ct_speed = {
/* /*
* C_ORC * C_ORC
*/ */
message * message *cinfo_unit(const void *obj, typ_t typ, const curse * c, int self)
cinfo_unit(const void * obj, typ_t typ, const curse *c, int self)
{ {
unused(typ); unused(typ);
assert(typ == TYP_UNIT); assert(typ == TYP_UNIT);
if (self != 0){ if (self != 0) {
unit * u = (unit *)obj; unit *u = (unit *) obj;
return msg_message(mkname("curseinfo", c->type->cname), "unit id", u, c->no);
return msg_message(mkname("curseinfo", c->type->cname), "unit id", u,
c->no);
} }
return NULL; return NULL;
} }
static struct curse_type ct_orcish = { static struct curse_type ct_orcish = {
"orcish", "orcish",
CURSETYP_UNIT, CURSE_SPREADMODULO|CURSE_ISNEW, M_MEN, CURSETYP_UNIT, CURSE_SPREADMODULO | CURSE_ISNEW, M_MEN,
cinfo_unit cinfo_unit
}; };
@ -172,21 +183,24 @@ static struct curse_type ct_orcish = {
/* /*
* C_KAELTESCHUTZ * C_KAELTESCHUTZ
*/ */
static message * static message *cinfo_kaelteschutz(const void *obj, typ_t typ, const curse * c,
cinfo_kaelteschutz(const void * obj, typ_t typ, const curse *c, int self) int self)
{ {
unused(typ); unused(typ);
assert(typ == TYP_UNIT); assert(typ == TYP_UNIT);
if (self != 0) { if (self != 0) {
unit * u = (unit *)obj; unit *u = (unit *) obj;
return msg_message("curseinfo::warmth_1", "unit number id", u, get_cursedmen(u, c), c->no);
return msg_message("curseinfo::warmth_1", "unit number id", u,
get_cursedmen(u, c), c->no);
} }
return NULL; return NULL;
} }
static struct curse_type ct_insectfur = { static struct curse_type ct_insectfur = {
"insectfur", "insectfur",
CURSETYP_UNIT, CURSE_SPREADMODULO, ( M_MEN | M_DURATION ), CURSETYP_UNIT, CURSE_SPREADMODULO, (M_MEN | M_DURATION),
cinfo_kaelteschutz cinfo_kaelteschutz
}; };
@ -194,60 +208,68 @@ static struct curse_type ct_insectfur = {
/* /*
* C_SPARKLE * C_SPARKLE
*/ */
static message * static message *cinfo_sparkle(const void *obj, typ_t typ, const curse * c,
cinfo_sparkle(const void * obj, typ_t typ, const curse *c, int self) int self)
{ {
const char * effects[] = { const char *effects[] = {
NULL, /* end grau*/ NULL, /* end grau */
"sparkle_1", "sparkle_1",
"sparkle_2", "sparkle_2",
NULL, /* end traum */ NULL, /* end traum */
"sparkle_3", "sparkle_3",
"sparkle_4", "sparkle_4",
NULL, /* end tybied */ NULL, /* end tybied */
"sparkle_5", "sparkle_5",
"sparkle_6", "sparkle_6",
"sparkle_7", "sparkle_7",
"sparkle_8", "sparkle_8",
NULL, /* end cerrdor */ NULL, /* end cerrdor */
"sparkle_9", "sparkle_9",
"sparkle_10", "sparkle_10",
"sparkle_11", "sparkle_11",
"sparkle_12", "sparkle_12",
NULL, /* end gwyrrd */ NULL, /* end gwyrrd */
"sparkle_13", "sparkle_13",
"sparkle_14", "sparkle_14",
"sparkle_15", "sparkle_15",
"sparkle_16", "sparkle_16",
"sparkle_17", "sparkle_17",
"sparkle_18", "sparkle_18",
NULL, /* end draig */ NULL, /* end draig */
}; };
int m, begin=0, end=0; int m, begin = 0, end = 0;
unit *u; unit *u;
unused(typ); unused(typ);
assert(typ == TYP_UNIT); assert(typ == TYP_UNIT);
u = (unit *)obj; u = (unit *) obj;
if (!c->magician || !c->magician->faction) return NULL; if (!c->magician || !c->magician->faction)
return NULL;
for (m=0;m!=c->magician->faction->magiegebiet;++m) { for (m = 0; m != c->magician->faction->magiegebiet; ++m) {
while (effects[end]!=NULL) ++end; while (effects[end] != NULL)
begin = end+1; ++end;
begin = end + 1;
end = begin; end = begin;
} }
while (effects[end]!=NULL) ++end; while (effects[end] != NULL)
if (end==begin) return NULL; ++end;
if (end == begin)
return NULL;
else { else {
int index = begin + curse_geteffect_int(c) % (end-begin); int index = begin + curse_geteffect_int(c) % (end - begin);
return msg_message(mkname("curseinfo", effects[index]), "unit id", u, c->no);
return msg_message(mkname("curseinfo", effects[index]), "unit id", u,
c->no);
} }
} }
static struct curse_type ct_sparkle = { "sparkle", static struct curse_type ct_sparkle = { "sparkle",
CURSETYP_UNIT, CURSE_SPREADMODULO, ( M_MEN | M_DURATION ), cinfo_sparkle CURSETYP_UNIT, CURSE_SPREADMODULO, (M_MEN | M_DURATION), cinfo_sparkle
}; };
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
@ -263,7 +285,7 @@ static struct curse_type ct_strength = { "strength",
* C_ALLSKILLS (Alp) * C_ALLSKILLS (Alp)
*/ */
static struct curse_type ct_worse = { static struct curse_type ct_worse = {
"worse", CURSETYP_UNIT, CURSE_SPREADMODULO|CURSE_NOAGE, M_MEN, cinfo_unit "worse", CURSETYP_UNIT, CURSE_SPREADMODULO | CURSE_NOAGE, M_MEN, cinfo_unit
}; };
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
@ -274,11 +296,14 @@ static struct curse_type ct_worse = {
static struct curse_type ct_itemcloak = { static struct curse_type ct_itemcloak = {
"itemcloak", CURSETYP_UNIT, CURSE_SPREADNEVER, M_DURATION, cinfo_unit "itemcloak", CURSETYP_UNIT, CURSE_SPREADNEVER, M_DURATION, cinfo_unit
}; };
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
static struct curse_type ct_fumble = { static struct curse_type ct_fumble = {
"fumble", CURSETYP_NORM, CURSE_SPREADNEVER|CURSE_ONLYONE, NO_MERGE, cinfo_unit "fumble", CURSETYP_NORM, CURSE_SPREADNEVER | CURSE_ONLYONE, NO_MERGE,
cinfo_unit
}; };
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
@ -296,12 +321,13 @@ static struct curse_type ct_magicresistance = {
* C_SKILL * C_SKILL
*/ */
static int static int read_skill(struct storage *store, curse * c, void *target)
read_skill(struct storage * store, curse * c, void * target)
{ {
int skill; int skill;
if (store->version<CURSETYPE_VERSION) {
if (store->version < CURSETYPE_VERSION) {
int men; int men;
skill = store->r_int(store); skill = store->r_int(store);
men = store->r_int(store); men = store->r_int(store);
} else { } else {
@ -312,23 +338,25 @@ read_skill(struct storage * store, curse * c, void * target)
} }
static int static int
write_skill(struct storage * store, const curse * c, const void * target) write_skill(struct storage *store, const curse * c, const void *target)
{ {
store->w_int(store, c->data.i); store->w_int(store, c->data.i);
return 0; return 0;
} }
static message * static message *cinfo_skillmod(const void *obj, typ_t typ, const curse * c,
cinfo_skillmod(const void * obj, typ_t typ, const curse *c, int self) int self)
{ {
unused(typ); unused(typ);
if (self != 0) { if (self != 0) {
unit *u = (unit *)obj; unit *u = (unit *) obj;
int sk = c->data.i; int sk = c->data.i;
if (c->effect>0) {
if (c->effect > 0) {
return msg_message("curseinfo::skill_1", "unit skill id", u, sk, c->no); return msg_message("curseinfo::skill_1", "unit skill id", u, sk, c->no);
} else if (c->effect<0) { } else if (c->effect < 0) {
return msg_message("curseinfo::skill_2", "unit skill id", u, sk, c->no); return msg_message("curseinfo::skill_2", "unit skill id", u, sk, c->no);
} }
} }
@ -341,8 +369,7 @@ static struct curse_type ct_skillmod = {
}; };
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
void void register_unitcurse(void)
register_unitcurse(void)
{ {
ct_register(&ct_auraboost); ct_register(&ct_auraboost);
ct_register(&ct_magicboost); ct_register(&ct_magicboost);
@ -360,4 +387,3 @@ register_unitcurse(void)
ct_register(&ct_oldrace); ct_register(&ct_oldrace);
ct_register(&ct_magicresistance); ct_register(&ct_magicresistance);
} }

View file

@ -17,13 +17,14 @@
extern "C" { extern "C" {
#endif #endif
struct curse; struct curse;
struct message; struct message;
extern struct message * cinfo_unit(const void * obj, typ_t typ, const struct curse *c, int self); extern struct message *cinfo_unit(const void *obj, typ_t typ,
const struct curse *c, int self);
extern void register_unitcurse(void); extern void register_unitcurse(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* _UCURSE_H */ #endif /* _UCURSE_H */