forked from github/server
fix indentation in every file
fix copyright date remove vi ts=2 code remove a couple of superfluous extern declarations
This commit is contained in:
parent
45ebe35681
commit
abca25d1d5
346 changed files with 19574 additions and 19283 deletions
src
alchemy.calchemy.h
attributes
attributes.cattributes.hdict.cdict.hfleechance.cfleechance.hfollow.cfollow.hhate.chate.hiceberg.ciceberg.hkey.ckey.hmatmod.cmatmod.hmoved.cmoved.hmovement.cmovement.horcification.corcification.hotherfaction.cotherfaction.hoverrideroads.coverrideroads.hracename.cracename.hraceprefix.craceprefix.hreduceproduction.creduceproduction.htargetregion.ctargetregion.h
battle.cbattle.hbattle.test.cbind_building.cbind_building.hbind_config.cbind_config.hbind_dict.cbind_dict.hbind_faction.cbind_faction.hbind_gmtool.cbind_message.cbind_message.hbind_monsters.cbind_process.cbind_region.cbind_region.hbind_settings.hbind_ship.cbind_ship.hbind_sqlite.cbind_storage.cbind_storage.hbind_unit.cbind_unit.hbindings.cbindings.hbuilding_action.ccallback.ccallback.hchaos.cchaos.hconsole.cconsole.hcreport.ccreport.hdirection.cdirection.heconomy.ceconomy.hgive.cgive.hgmtool.cgmtool.hgmtool_structs.hhelpers.chelpers.hitems.citems.hitems
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -82,7 +82,8 @@ void herbsearch(region * r, unit * u, int max)
|
|||
i_change(&u->items, whichherb, herbsfound);
|
||||
ADDMSG(&u->faction->msgs, msg_message("herbfound",
|
||||
"unit region amount herb", u, r, herbsfound, whichherb->rtype));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ADDMSG(&u->faction->msgs, msg_message("researchherb_none",
|
||||
"unit region", u, u->region));
|
||||
}
|
||||
|
@ -135,7 +136,8 @@ static int do_potion(unit * u, region *r, const potion_type * ptype, int amount)
|
|||
if (fval(r, RF_MALLORN)) {
|
||||
holz = use_pooled(u, rt_find("mallorn"),
|
||||
GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, tree_count * amount);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
holz = use_pooled(u, rt_find("log"),
|
||||
GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, tree_count * amount);
|
||||
}
|
||||
|
@ -151,25 +153,31 @@ static int do_potion(unit * u, region *r, const potion_type * ptype, int amount)
|
|||
rsettrees(r, tree_type, rtrees(r, tree_type) + holz);
|
||||
ADDMSG(&u->faction->msgs, msg_message("growtree_effect",
|
||||
"mage amount", u, holz));
|
||||
} else if (ptype == oldpotiontype[P_HEILWASSER]) {
|
||||
}
|
||||
else if (ptype == oldpotiontype[P_HEILWASSER]) {
|
||||
u->hp = _min(unit_max_hp(u) * u->number, u->hp + 400 * amount);
|
||||
} else if (ptype == oldpotiontype[P_PEOPLE]) {
|
||||
attrib *a = (attrib *) a_find(r->attribs, &at_peasantluck);
|
||||
}
|
||||
else if (ptype == oldpotiontype[P_PEOPLE]) {
|
||||
attrib *a = (attrib *)a_find(r->attribs, &at_peasantluck);
|
||||
if (!a)
|
||||
a = a_add(&r->attribs, a_new(&at_peasantluck));
|
||||
a->data.i += amount;
|
||||
} else if (ptype == oldpotiontype[P_HORSE]) {
|
||||
attrib *a = (attrib *) a_find(r->attribs, &at_horseluck);
|
||||
}
|
||||
else if (ptype == oldpotiontype[P_HORSE]) {
|
||||
attrib *a = (attrib *)a_find(r->attribs, &at_horseluck);
|
||||
if (!a)
|
||||
a = a_add(&r->attribs, a_new(&at_horseluck));
|
||||
a->data.i += amount;
|
||||
} else if (ptype == oldpotiontype[P_WAHRHEIT]) {
|
||||
}
|
||||
else if (ptype == oldpotiontype[P_WAHRHEIT]) {
|
||||
fset(u, UFL_DISBELIEVES);
|
||||
amount = 1;
|
||||
} else if (ptype == oldpotiontype[P_MACHT]) {
|
||||
}
|
||||
else if (ptype == oldpotiontype[P_MACHT]) {
|
||||
/* Verfünffacht die HP von max. 10 Personen in der Einheit */
|
||||
u->hp += _min(u->number, 10 * amount) * unit_max_hp(u) * 4;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
change_effect(u, ptype, 10 * amount);
|
||||
}
|
||||
return amount;
|
||||
|
@ -181,7 +189,8 @@ int use_potion(unit * u, const item_type * itype, int amount, struct order *ord)
|
|||
|
||||
if (oldpotiontype[P_HEAL] && ptype == oldpotiontype[P_HEAL]) {
|
||||
return EUNUSABLE;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
int result = begin_potion(u, ptype, ord);
|
||||
if (result)
|
||||
return result;
|
||||
|
@ -210,7 +219,7 @@ static void free_potiondelay(attrib * a)
|
|||
|
||||
static int age_potiondelay(attrib * a)
|
||||
{
|
||||
potiondelay *pd = (potiondelay *) a->data.v;
|
||||
potiondelay *pd = (potiondelay *)a->data.v;
|
||||
pd->amount = do_potion(pd->u, pd->r, pd->ptype, pd->amount);
|
||||
return AT_AGE_REMOVE;
|
||||
}
|
||||
|
@ -225,7 +234,7 @@ attrib_type at_potiondelay = {
|
|||
static attrib *make_potiondelay(unit * u, const potion_type * ptype, int amount)
|
||||
{
|
||||
attrib *a = a_new(&at_potiondelay);
|
||||
potiondelay *pd = (potiondelay *) a->data.v;
|
||||
potiondelay *pd = (potiondelay *)a->data.v;
|
||||
pd->u = u;
|
||||
pd->r = u->region;
|
||||
pd->ptype = ptype;
|
||||
|
@ -235,7 +244,7 @@ static attrib *make_potiondelay(unit * u, const potion_type * ptype, int amount)
|
|||
|
||||
int
|
||||
use_potion_delayed(unit * u, const item_type * itype, int amount,
|
||||
struct order *ord)
|
||||
struct order *ord)
|
||||
{
|
||||
const potion_type *ptype = resource2potion(itype->rtype);
|
||||
int result = begin_potion(u, ptype, ord);
|
||||
|
@ -265,7 +274,7 @@ static void a_finalizeeffect(attrib * a)
|
|||
static void
|
||||
a_writeeffect(const attrib * a, const void *owner, struct storage *store)
|
||||
{
|
||||
effect_data *edata = (effect_data *) a->data.v;
|
||||
effect_data *edata = (effect_data *)a->data.v;
|
||||
WRITE_TOK(store, resourcename(edata->type->itype->rtype, 0));
|
||||
WRITE_INT(store, edata->value);
|
||||
}
|
||||
|
@ -274,7 +283,7 @@ static int a_readeffect(attrib * a, void *owner, struct storage *store)
|
|||
{
|
||||
int power;
|
||||
const resource_type *rtype;
|
||||
effect_data *edata = (effect_data *) a->data.v;
|
||||
effect_data *edata = (effect_data *)a->data.v;
|
||||
char zText[32];
|
||||
|
||||
READ_TOK(store, zText, sizeof(zText));
|
||||
|
@ -317,12 +326,13 @@ int change_effect(unit * u, const potion_type * effect, int delta)
|
|||
effect_data *data = NULL;
|
||||
|
||||
while (a && a->type == &at_effect) {
|
||||
data = (effect_data *) a->data.v;
|
||||
data = (effect_data *)a->data.v;
|
||||
if (data->type == effect) {
|
||||
if (data->value + delta == 0) {
|
||||
a_remove(&u->attribs, a);
|
||||
return 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
data->value += delta;
|
||||
return data->value;
|
||||
}
|
||||
|
@ -331,7 +341,7 @@ int change_effect(unit * u, const potion_type * effect, int delta)
|
|||
}
|
||||
|
||||
a = a_add(&u->attribs, a_new(&at_effect));
|
||||
data = (effect_data *) a->data.v;
|
||||
data = (effect_data *)a->data.v;
|
||||
data->type = effect;
|
||||
data->value = delta;
|
||||
return data->value;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -69,7 +69,7 @@ extern "C" {
|
|||
int value);
|
||||
extern struct attrib_type at_effect;
|
||||
|
||||
/* rausnehmen, sobald man attribute splitten kann: */
|
||||
/* rausnehmen, sobald man attribute splitten kann: */
|
||||
typedef struct effect_data {
|
||||
const struct potion_type *type;
|
||||
int value;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
|
@ -26,12 +26,12 @@ extern "C" {
|
|||
|
||||
extern struct attrib_type at_dict;
|
||||
|
||||
extern struct attrib *dict_create(const char *name, dict_type type,
|
||||
struct attrib *dict_create(const char *name, dict_type type,
|
||||
variant value);
|
||||
extern void dict_get(const struct attrib *a, dict_type * type,
|
||||
void dict_get(const struct attrib *a, dict_type * type,
|
||||
variant * value);
|
||||
extern void dict_set(struct attrib *a, dict_type type, variant value);
|
||||
extern const char *dict_name(const struct attrib *a);
|
||||
void dict_set(struct attrib *a, dict_type type, variant value);
|
||||
const char *dict_name(const struct attrib *a);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -24,8 +24,8 @@ extern "C" {
|
|||
|
||||
extern struct attrib_type at_fleechance;
|
||||
|
||||
extern struct attrib *make_fleechance(float fleechance);
|
||||
extern void init_fleechance(void);
|
||||
struct attrib *make_fleechance(float fleechance);
|
||||
void init_fleechance(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -26,7 +26,7 @@ extern "C" {
|
|||
|
||||
struct unit;
|
||||
|
||||
extern struct attrib *make_follow(struct unit *u);
|
||||
struct attrib *make_follow(struct unit *u);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -39,7 +39,7 @@ static int verify_hate(attrib * a)
|
|||
static void
|
||||
write_hate(const attrib * a, const void *owner, struct storage *store)
|
||||
{
|
||||
write_unit_reference((unit *) a->data.v, store);
|
||||
write_unit_reference((unit *)a->data.v, store);
|
||||
}
|
||||
|
||||
static int read_hate(attrib * a, void *owner, struct storage *store)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -27,7 +27,7 @@ extern "C" {
|
|||
|
||||
extern struct attrib_type at_iceberg;
|
||||
|
||||
extern struct attrib *make_iceberg(direction_t dir);
|
||||
struct attrib *make_iceberg(direction_t dir);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -24,9 +24,9 @@ extern "C" {
|
|||
|
||||
extern struct attrib_type at_key;
|
||||
|
||||
extern struct attrib *make_key(int key);
|
||||
extern struct attrib *find_key(struct attrib *alist, int key);
|
||||
extern struct attrib *add_key(struct attrib **alist, int key);
|
||||
struct attrib *make_key(int key);
|
||||
struct attrib *find_key(struct attrib *alist, int key);
|
||||
struct attrib *add_key(struct attrib **alist, int key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -34,6 +34,6 @@ attrib_type at_matmod = {
|
|||
attrib *make_matmod(mm_fun function)
|
||||
{
|
||||
attrib *a = a_new(&at_matmod);
|
||||
a->data.f = (void (*)(void))function;
|
||||
a->data.f = (void(*)(void))function;
|
||||
return a;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -25,7 +25,7 @@ extern "C" {
|
|||
|
||||
struct resource_type;
|
||||
struct unit;
|
||||
typedef int (*mm_fun) (const struct unit * u,
|
||||
typedef int(*mm_fun) (const struct unit * u,
|
||||
const struct resource_type * rtype, int value);
|
||||
|
||||
extern struct attrib_type at_matmod;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -33,7 +33,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
void write_of(const struct attrib *a, const void *owner, struct storage *store)
|
||||
{
|
||||
const faction *f = (faction *) a->data.v;
|
||||
const faction *f = (faction *)a->data.v;
|
||||
WRITE_INT(store, f->no);
|
||||
}
|
||||
|
||||
|
@ -41,12 +41,12 @@ int read_of(struct attrib *a, void *owner, struct storage *store)
|
|||
{ /* return 1 on success, 0 if attrib needs removal */
|
||||
int of;
|
||||
static int rule = -1;
|
||||
if (rule<0) {
|
||||
if (rule < 0) {
|
||||
rule = rule_stealth_faction();
|
||||
}
|
||||
|
||||
READ_INT(store, &of);
|
||||
if (rule&2) {
|
||||
if (rule & 2) {
|
||||
a->data.v = findfaction(of);
|
||||
if (a->data.v) {
|
||||
return AT_READ_OK;
|
||||
|
@ -61,7 +61,7 @@ attrib_type at_otherfaction = {
|
|||
|
||||
struct faction *get_otherfaction(const struct attrib *a)
|
||||
{
|
||||
return (faction *) (a->data.v);
|
||||
return (faction *)(a->data.v);
|
||||
}
|
||||
|
||||
struct attrib *make_otherfaction(struct faction *f)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -45,9 +45,11 @@ void set_racename(attrib ** palist, const char *name)
|
|||
if (!a && name) {
|
||||
a = a_add(palist, a_new(&at_racename));
|
||||
a->data.v = _strdup(name);
|
||||
} else if (a && !name) {
|
||||
}
|
||||
else if (a && !name) {
|
||||
a_remove(palist, a);
|
||||
} else if (a) {
|
||||
}
|
||||
else if (a) {
|
||||
if (strcmp(a->data.v, name) != 0) {
|
||||
free(a->data.v);
|
||||
a->data.v = _strdup(name);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -37,7 +37,8 @@ void set_prefix(attrib ** ap, const char *str)
|
|||
attrib *a = a_find(*ap, &at_raceprefix);
|
||||
if (a == NULL) {
|
||||
a = a_add(ap, a_new(&at_raceprefix));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
free(a->data.v);
|
||||
}
|
||||
assert(a->type == &at_raceprefix);
|
||||
|
@ -53,7 +54,7 @@ const char *get_prefix(const attrib * a)
|
|||
str = (char *)a->data.v;
|
||||
/* conversion of old prefixes */
|
||||
if (strncmp(str, "prefix_", 7) == 0) {
|
||||
((attrib *) a)->data.v = _strdup(str + 7);
|
||||
((attrib *)a)->data.v = _strdup(str + 7);
|
||||
free(str);
|
||||
str = (char *)a->data.v;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -32,7 +32,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
static void
|
||||
write_targetregion(const attrib * a, const void *owner, struct storage *store)
|
||||
{
|
||||
write_region_reference((region *) a->data.v, store);
|
||||
write_region_reference((region *)a->data.v, store);
|
||||
}
|
||||
|
||||
static int read_targetregion(attrib * a, void *owner, struct storage *store)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
|
|
26
src/battle.h
26
src/battle.h
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -121,8 +121,8 @@ extern "C" {
|
|||
int count, used;
|
||||
const struct weapon_type *type;
|
||||
# ifdef LOMEM
|
||||
int attackskill:8;
|
||||
int defenseskill:8;
|
||||
int attackskill : 8;
|
||||
int defenseskill : 8;
|
||||
# else
|
||||
int attackskill;
|
||||
int defenseskill;
|
||||
|
@ -174,15 +174,15 @@ extern "C" {
|
|||
struct person {
|
||||
int hp; /* Trefferpunkte der Personen */
|
||||
#ifdef LOMEM
|
||||
int attack:8; /* (Magie) Attackenbonus der Personen */
|
||||
int defence:8; /* (Magie) Paradenbonus der Personen */
|
||||
int damage:8; /* (Magie) Schadensbonus der Personen im Nahkampf */
|
||||
int damage_rear:8; /* (Magie) Schadensbonus der Personen im Fernkampf */
|
||||
int flags:8; /* (Magie) Diverse Flags auf Kämpfern */
|
||||
int speed:8; /* (Magie) Geschwindigkeitsmultiplkator. */
|
||||
int reload:4; /* Anzahl Runden, die die Waffe x noch laden muss.
|
||||
int attack : 8; /* (Magie) Attackenbonus der Personen */
|
||||
int defence : 8; /* (Magie) Paradenbonus der Personen */
|
||||
int damage : 8; /* (Magie) Schadensbonus der Personen im Nahkampf */
|
||||
int damage_rear : 8; /* (Magie) Schadensbonus der Personen im Fernkampf */
|
||||
int flags : 8; /* (Magie) Diverse Flags auf Kämpfern */
|
||||
int speed : 8; /* (Magie) Geschwindigkeitsmultiplkator. */
|
||||
int reload : 4; /* Anzahl Runden, die die Waffe x noch laden muss.
|
||||
* dahinter steckt ein array[RL_MAX] wenn er min. eine hat. */
|
||||
int last_action:4; /* In welcher Runde haben wir zuletzt etwas getan */
|
||||
int last_action : 4; /* In welcher Runde haben wir zuletzt etwas getan */
|
||||
#else
|
||||
int attack;
|
||||
int defence;
|
||||
|
|
|
@ -190,7 +190,7 @@ static void test_building_defence_bonus(CuTest * tc)
|
|||
r = findregion(0, 0);
|
||||
register_buildings();
|
||||
btype = bt_get_or_create("castle");
|
||||
btype->protection = (int (*)(struct building *, struct unit *, building_bonus))get_function("building_protection");
|
||||
btype->protection = (int(*)(struct building *, struct unit *, building_bonus))get_function("building_protection");
|
||||
btype->construction->defense_bonus = 3;
|
||||
bld = test_create_building(r, btype);
|
||||
bld->size = 1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
@ -28,26 +28,27 @@ without prior permission by the authors of Eressea.
|
|||
int tolua_buildinglist_next(lua_State * L)
|
||||
{
|
||||
building **building_ptr =
|
||||
(building **) lua_touserdata(L, lua_upvalueindex(1));
|
||||
(building **)lua_touserdata(L, lua_upvalueindex(1));
|
||||
building *u = *building_ptr;
|
||||
if (u != NULL) {
|
||||
tolua_pushusertype(L, (void *)u, TOLUA_CAST "building");
|
||||
*building_ptr = u->next;
|
||||
return 1;
|
||||
} else
|
||||
}
|
||||
else
|
||||
return 0; /* no more values to return */
|
||||
}
|
||||
|
||||
static int tolua_building_get_objects(lua_State * L)
|
||||
{
|
||||
building *self = (building *) tolua_tousertype(L, 1, 0);
|
||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushusertype(L, (void *)&self->attribs, TOLUA_CAST "hashtable");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_building_set_working(lua_State * L)
|
||||
{
|
||||
building *self = (building *) tolua_tousertype(L, 1, 0);
|
||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||
bool flag = !!lua_toboolean(L, 2);
|
||||
if (flag) self->flags |= BLD_WORKING;
|
||||
else self->flags &= ~BLD_WORKING;
|
||||
|
@ -56,36 +57,36 @@ static int tolua_building_set_working(lua_State * L)
|
|||
|
||||
static int tolua_building_get_working(lua_State * L)
|
||||
{
|
||||
building *self = (building *) tolua_tousertype(L, 1, 0);
|
||||
bool flag = (self->flags&BLD_WORKING)!=0;
|
||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||
bool flag = (self->flags&BLD_WORKING) != 0;
|
||||
lua_pushboolean(L, flag);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_building_get_region(lua_State * L)
|
||||
{
|
||||
building *self = (building *) tolua_tousertype(L, 1, 0);
|
||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushusertype(L, building_getregion(self), TOLUA_CAST "region");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_building_set_region(lua_State * L)
|
||||
{
|
||||
building *self = (building *) tolua_tousertype(L, 1, 0);
|
||||
building_setregion(self, (region *) tolua_tousertype(L, 2, 0));
|
||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||
building_setregion(self, (region *)tolua_tousertype(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_building_get_info(lua_State * L)
|
||||
{
|
||||
building *self = (building *) tolua_tousertype(L, 1, 0);
|
||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, self->display);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_building_set_info(lua_State * L)
|
||||
{
|
||||
building *self = (building *) tolua_tousertype(L, 1, 0);
|
||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||
const char *info = tolua_tostring(L, 2, 0);
|
||||
free(self->display);
|
||||
if (info)
|
||||
|
@ -97,36 +98,36 @@ static int tolua_building_set_info(lua_State * L)
|
|||
|
||||
static int tolua_building_get_name(lua_State * L)
|
||||
{
|
||||
building *self = (building *) tolua_tousertype(L, 1, 0);
|
||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, building_getname(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_building_set_name(lua_State * L)
|
||||
{
|
||||
building *self = (building *) tolua_tousertype(L, 1, 0);
|
||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||
building_setname(self, tolua_tostring(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_building_get_size(lua_State * L)
|
||||
{
|
||||
building *self = (building *) tolua_tousertype(L, 1, 0);
|
||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, self->size);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_building_set_size(lua_State * L)
|
||||
{
|
||||
building *self = (building *) tolua_tousertype(L, 1, 0);
|
||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||
self->size = (int)tolua_tonumber(L, 2, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_building_get_units(lua_State * L)
|
||||
{
|
||||
building *self = (building *) tolua_tousertype(L, 1, 0);
|
||||
unit **unit_ptr = (unit **) lua_newuserdata(L, sizeof(unit *));
|
||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||
unit **unit_ptr = (unit **)lua_newuserdata(L, sizeof(unit *));
|
||||
unit *u = self->region->units;
|
||||
|
||||
while (u && u->building != self)
|
||||
|
@ -142,21 +143,21 @@ static int tolua_building_get_units(lua_State * L)
|
|||
|
||||
static int tolua_building_get_id(lua_State * L)
|
||||
{
|
||||
building *self = (building *) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) self->no);
|
||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number)self->no);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_building_get_type(lua_State * L)
|
||||
{
|
||||
building *self = (building *) tolua_tousertype(L, 1, 0);
|
||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, self->type->_name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_building_get_typename(lua_State * L)
|
||||
{
|
||||
building *b = (building *) tolua_tousertype(L, 1, 0);
|
||||
building *b = (building *)tolua_tousertype(L, 1, 0);
|
||||
if (b) {
|
||||
int size = (int)tolua_tonumber(L, 2, b->size);
|
||||
tolua_pushstring(L, buildingtype(b->type, b, size));
|
||||
|
@ -167,7 +168,7 @@ static int tolua_building_get_typename(lua_State * L)
|
|||
|
||||
static int tolua_building_get_owner(lua_State * L)
|
||||
{
|
||||
building *b = (building *) tolua_tousertype(L, 1, 0);
|
||||
building *b = (building *)tolua_tousertype(L, 1, 0);
|
||||
unit *u = b ? building_owner(b) : NULL;
|
||||
tolua_pushusertype(L, u, TOLUA_CAST "unit");
|
||||
return 1;
|
||||
|
@ -175,9 +176,9 @@ static int tolua_building_get_owner(lua_State * L)
|
|||
|
||||
static int tolua_building_set_owner(lua_State * L)
|
||||
{
|
||||
building *b = (building *) tolua_tousertype(L, 1, 0);
|
||||
unit *u = (unit *) tolua_tousertype(L, 2, 0);
|
||||
if (b!=u->building) {
|
||||
building *b = (building *)tolua_tousertype(L, 1, 0);
|
||||
unit *u = (unit *)tolua_tousertype(L, 2, 0);
|
||||
if (b != u->building) {
|
||||
u_set_building(u, b);
|
||||
}
|
||||
building_set_owner(u);
|
||||
|
@ -186,7 +187,7 @@ static int tolua_building_set_owner(lua_State * L)
|
|||
|
||||
static int tolua_building_create(lua_State * L)
|
||||
{
|
||||
region *r = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||
const char *bname = tolua_tostring(L, 2, 0);
|
||||
if (bname) {
|
||||
const building_type *btype = bt_find(bname);
|
||||
|
@ -201,14 +202,14 @@ static int tolua_building_create(lua_State * L)
|
|||
|
||||
static int tolua_building_tostring(lua_State * L)
|
||||
{
|
||||
building *self = (building *) tolua_tousertype(L, 1, 0);
|
||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushstring(L, buildingname(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_building_destroy(lua_State * L)
|
||||
{
|
||||
building *self = (building *) tolua_tousertype(L, 1, 0);
|
||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||
remove_building(&self->region->buildings, self);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
|
|
@ -34,18 +34,19 @@ int config_parse(const char *json)
|
|||
cJSON_Delete(conf);
|
||||
init_locales();
|
||||
return 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
int line;
|
||||
char buffer[10];
|
||||
const char *xp = json, *lp, *ep = cJSON_GetErrorPtr();
|
||||
for (line=1,lp=xp;xp && xp<ep;++line,lp=xp+1) {
|
||||
for (line = 1, lp = xp; xp && xp<ep; ++line, lp = xp + 1) {
|
||||
xp = strchr(lp, '\n');
|
||||
if (xp>=ep) break;
|
||||
if (xp >= ep) break;
|
||||
}
|
||||
xp = (ep > json + 10) ? ep - 10 : json;
|
||||
strncpy(buffer, xp, sizeof(buffer));
|
||||
buffer[9] = 0;
|
||||
log_error("json parse error in line %d, position %d, near `%s`\n", line, ep-lp, buffer);
|
||||
log_error("json parse error in line %d, position %d, near `%s`\n", line, ep - lp, buffer);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void config_reset(void);
|
||||
int config_parse(const char *json);
|
||||
int config_read(const char *filename, const char * relpath);
|
||||
void config_reset(void);
|
||||
int config_parse(const char *json);
|
||||
int config_read(const char *filename, const char * relpath);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
@ -37,20 +37,21 @@ without prior permission by the authors of Eressea.
|
|||
|
||||
int tolua_factionlist_next(lua_State * L)
|
||||
{
|
||||
faction **faction_ptr = (faction **) lua_touserdata(L, lua_upvalueindex(1));
|
||||
faction **faction_ptr = (faction **)lua_touserdata(L, lua_upvalueindex(1));
|
||||
faction *f = *faction_ptr;
|
||||
if (f != NULL) {
|
||||
tolua_pushusertype(L, (void *)f, TOLUA_CAST "faction");
|
||||
*faction_ptr = f->next;
|
||||
return 1;
|
||||
} else
|
||||
}
|
||||
else
|
||||
return 0; /* no more values to return */
|
||||
}
|
||||
|
||||
static int tolua_faction_get_units(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
unit **unit_ptr = (unit **) lua_newuserdata(L, sizeof(unit *));
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
unit **unit_ptr = (unit **)lua_newuserdata(L, sizeof(unit *));
|
||||
|
||||
luaL_getmetatable(L, TOLUA_CAST "unit");
|
||||
lua_setmetatable(L, -2);
|
||||
|
@ -63,7 +64,7 @@ static int tolua_faction_get_units(lua_State * L)
|
|||
|
||||
int tolua_faction_add_item(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
const char *iname = tolua_tostring(L, 2, 0);
|
||||
int number = (int)tolua_tonumber(L, 3, 0);
|
||||
int result = -1;
|
||||
|
@ -81,40 +82,41 @@ int tolua_faction_add_item(lua_State * L)
|
|||
|
||||
static int tolua_faction_get_maxheroes(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) maxheroes(self));
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number)maxheroes(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_get_heroes(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) countheroes(self));
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number)countheroes(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_get_score(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) self->score);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number)self->score);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_get_id(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) self->no);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number)self->no);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_set_id(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
int id = (int)tolua_tonumber(L, 2, 0);
|
||||
if (findfaction(id) == NULL) {
|
||||
renumber_faction(self, id);
|
||||
lua_pushboolean(L, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lua_pushboolean(L, 0);
|
||||
}
|
||||
return 1;
|
||||
|
@ -122,14 +124,14 @@ static int tolua_faction_set_id(lua_State * L)
|
|||
|
||||
static int tolua_faction_get_magic(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushstring(L, magic_school[self->magiegebiet]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_set_magic(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
const char *type = tolua_tostring(L, 2, 0);
|
||||
int mtype;
|
||||
|
||||
|
@ -144,14 +146,14 @@ static int tolua_faction_set_magic(lua_State * L)
|
|||
|
||||
static int tolua_faction_get_age(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) self->age);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number)self->age);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_set_age(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
int age = (int)tolua_tonumber(L, 2, 0);
|
||||
self->age = age;
|
||||
return 0;
|
||||
|
@ -159,14 +161,14 @@ static int tolua_faction_set_age(lua_State * L)
|
|||
|
||||
static int tolua_faction_get_flags(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) self->flags);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number)self->flags);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_set_flags(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
int flags = (int)tolua_tonumber(L, 2, self->flags);
|
||||
self->flags = flags;
|
||||
return 1;
|
||||
|
@ -174,14 +176,14 @@ static int tolua_faction_set_flags(lua_State * L)
|
|||
|
||||
static int tolua_faction_get_options(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) self->options);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number)self->options);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_set_options(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
int options = (int)tolua_tonumber(L, 2, self->options);
|
||||
self->options = options;
|
||||
return 1;
|
||||
|
@ -189,14 +191,14 @@ static int tolua_faction_set_options(lua_State * L)
|
|||
|
||||
static int tolua_faction_get_lastturn(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) self->lastorders);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number)self->lastorders);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_set_lastturn(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
if (self) {
|
||||
self->lastorders = (int)tolua_tonumber(L, 2, self->lastorders);
|
||||
}
|
||||
|
@ -205,7 +207,7 @@ static int tolua_faction_set_lastturn(lua_State * L)
|
|||
|
||||
static int tolua_faction_renumber(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
int no = (int)tolua_tonumber(L, 2, 0);
|
||||
|
||||
renumber_faction(self, no);
|
||||
|
@ -223,15 +225,15 @@ static int tolua_faction_addnotice(lua_State * L)
|
|||
|
||||
static int tolua_faction_get_objects(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushusertype(L, (void *)&self->attribs, TOLUA_CAST "hashtable");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_get_policy(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *other = (faction *) tolua_tousertype(L, 2, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
faction *other = (faction *)tolua_tousertype(L, 2, 0);
|
||||
const char *policy = tolua_tostring(L, 3, 0);
|
||||
|
||||
int result = 0, mode;
|
||||
|
@ -242,14 +244,14 @@ static int tolua_faction_get_policy(lua_State * L)
|
|||
}
|
||||
}
|
||||
|
||||
tolua_pushnumber(L, (lua_Number) result);
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_set_policy(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *other = (faction *) tolua_tousertype(L, 2, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
faction *other = (faction *)tolua_tousertype(L, 2, 0);
|
||||
const char *policy = tolua_tostring(L, 3, 0);
|
||||
int value = tolua_toboolean(L, 4, 0);
|
||||
|
||||
|
@ -259,7 +261,8 @@ static int tolua_faction_set_policy(lua_State * L)
|
|||
if (value) {
|
||||
set_alliance(self, other, get_alliance(self,
|
||||
other) | helpmodes[mode].status);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
set_alliance(self, other, get_alliance(self,
|
||||
other) & ~helpmodes[mode].status);
|
||||
}
|
||||
|
@ -272,15 +275,15 @@ static int tolua_faction_set_policy(lua_State * L)
|
|||
|
||||
static int tolua_faction_normalize(lua_State * L)
|
||||
{
|
||||
faction *f = (faction *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *) tolua_tousertype(L, 2, 0);
|
||||
faction *f = (faction *)tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 2, 0);
|
||||
if (r) {
|
||||
plane *pl = rplane(r);
|
||||
int nx = r->x, ny = r->y;
|
||||
pnormalize(&nx, &ny, pl);
|
||||
adjust_coordinates(f, &nx, &ny, pl, r);
|
||||
tolua_pushnumber(L, (lua_Number) nx);
|
||||
tolua_pushnumber(L, (lua_Number) ny);
|
||||
tolua_pushnumber(L, (lua_Number)nx);
|
||||
tolua_pushnumber(L, (lua_Number)ny);
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
|
@ -288,8 +291,8 @@ static int tolua_faction_normalize(lua_State * L)
|
|||
|
||||
static int tolua_faction_set_origin(lua_State * L)
|
||||
{
|
||||
faction *f = (faction *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *) tolua_tousertype(L, 2, 0);
|
||||
faction *f = (faction *)tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 2, 0);
|
||||
plane *pl = rplane(r);
|
||||
int id = pl ? pl->id : 0;
|
||||
|
||||
|
@ -299,7 +302,7 @@ static int tolua_faction_set_origin(lua_State * L)
|
|||
|
||||
static int tolua_faction_get_origin(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
|
||||
ursprung *origin = self->ursprung;
|
||||
int x, y;
|
||||
|
@ -309,19 +312,20 @@ static int tolua_faction_get_origin(lua_State * L)
|
|||
if (origin) {
|
||||
x = origin->x;
|
||||
y = origin->y;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
tolua_pushnumber(L, (lua_Number) x);
|
||||
tolua_pushnumber(L, (lua_Number) y);
|
||||
tolua_pushnumber(L, (lua_Number)x);
|
||||
tolua_pushnumber(L, (lua_Number)y);
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int tolua_faction_destroy(lua_State * L)
|
||||
{
|
||||
faction *f = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *f = (faction *)tolua_tousertype(L, 1, 0);
|
||||
destroyfaction(f);
|
||||
return 0;
|
||||
}
|
||||
|
@ -354,42 +358,42 @@ static int tolua_faction_create(lua_State * L)
|
|||
|
||||
static int tolua_faction_get_password(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, faction_getpassword(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_set_password(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
faction_setpassword(self, tolua_tostring(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_faction_get_email(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, faction_getemail(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_set_email(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
faction_setemail(self, tolua_tostring(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_faction_get_locale(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, locale_name(self->locale));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_set_locale(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
const char *name = tolua_tostring(L, 2, 0);
|
||||
const struct locale *loc = get_locale(name);
|
||||
if (loc) {
|
||||
|
@ -404,14 +408,14 @@ static int tolua_faction_set_locale(lua_State * L)
|
|||
|
||||
static int tolua_faction_get_race(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, self->race->_name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_set_race(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
const char *name = tolua_tostring(L, 2, 0);
|
||||
const race *rc = rc_find(name);
|
||||
if (rc != NULL) {
|
||||
|
@ -423,49 +427,49 @@ static int tolua_faction_set_race(lua_State * L)
|
|||
|
||||
static int tolua_faction_get_name(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, faction_getname(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_set_name(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
faction_setname(self, tolua_tostring(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_faction_get_uid(lua_State * L)
|
||||
{
|
||||
faction *f = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *f = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, f->subscription);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_set_uid(lua_State * L)
|
||||
{
|
||||
faction *f = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *f = (faction *)tolua_tousertype(L, 1, 0);
|
||||
f->subscription = (int)tolua_tonumber(L, 2, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_faction_get_info(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, faction_getbanner(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_faction_set_info(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
faction_setbanner(self, tolua_tostring(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_faction_get_alliance(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushusertype(L, f_get_alliance(self), TOLUA_CAST "alliance");
|
||||
return 1;
|
||||
}
|
||||
|
@ -482,8 +486,8 @@ static int tolua_faction_set_alliance(lua_State * L)
|
|||
|
||||
static int tolua_faction_get_items(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
item **item_ptr = (item **) lua_newuserdata(L, sizeof(item *));
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
item **item_ptr = (item **)lua_newuserdata(L, sizeof(item *));
|
||||
|
||||
luaL_getmetatable(L, TOLUA_CAST "item");
|
||||
lua_setmetatable(L, -2);
|
||||
|
@ -497,7 +501,7 @@ static int tolua_faction_get_items(lua_State * L)
|
|||
|
||||
static int tolua_faction_tostring(lua_State * L)
|
||||
{
|
||||
faction *self = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *self = (faction *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushstring(L, factionname(self));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
|
|
@ -96,7 +96,8 @@ void tag_rewind(tag_iterator * iter)
|
|||
if (!iter->r) {
|
||||
tag_advance(iter);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
iter->node = 0;
|
||||
iter->hash = MAXTHASH;
|
||||
}
|
||||
|
@ -104,12 +105,13 @@ void tag_rewind(tag_iterator * iter)
|
|||
|
||||
static int tolua_tags_next(lua_State * L)
|
||||
{
|
||||
tag_iterator *iter = (tag_iterator *) lua_touserdata(L, lua_upvalueindex(1));
|
||||
tag_iterator *iter = (tag_iterator *)lua_touserdata(L, lua_upvalueindex(1));
|
||||
if (iter->node) {
|
||||
tolua_pushusertype(L, (void *)iter->r, TOLUA_CAST "region");
|
||||
tag_advance(iter);
|
||||
return 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return 0; /* no more values to return */
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +119,7 @@ static int tolua_tags_next(lua_State * L)
|
|||
static int tolua_selected_regions(lua_State * L)
|
||||
{
|
||||
tag_iterator *iter =
|
||||
(tag_iterator *) lua_newuserdata(L, sizeof(tag_iterator));
|
||||
(tag_iterator *)lua_newuserdata(L, sizeof(tag_iterator));
|
||||
|
||||
luaL_getmetatable(L, "tag_iterator");
|
||||
lua_setmetatable(L, -2);
|
||||
|
@ -171,7 +173,8 @@ static void lua_paint_info(struct window *wnd, const struct state *st)
|
|||
log_error("paint function failed: %s\n", error);
|
||||
lua_pop(L, 1);
|
||||
tolua_error(L, TOLUA_CAST "event handler call failed", NULL);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const char *result = lua_tostring(L, -1);
|
||||
WINDOW *win = wnd->handle;
|
||||
int size = getmaxx(win) - 2;
|
||||
|
@ -203,7 +206,8 @@ static int tolua_set_display(lua_State * L)
|
|||
paint_state = L;
|
||||
|
||||
set_info_function(&lua_paint_info);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
set_info_function(NULL);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -50,15 +50,15 @@ static lua_message *msg_create_message(const char *type)
|
|||
lmsg->args = 0;
|
||||
lmsg->mtype = mt_find(type);
|
||||
if (lmsg->mtype) {
|
||||
lmsg->args = (variant *) calloc(lmsg->mtype->nparameters, sizeof(variant));
|
||||
lmsg->args = (variant *)calloc(lmsg->mtype->nparameters, sizeof(variant));
|
||||
}
|
||||
return lmsg;
|
||||
}
|
||||
|
||||
/*
|
||||
static void
|
||||
msg_destroy_message(lua_message * msg)
|
||||
{
|
||||
msg_destroy_message(lua_message * msg)
|
||||
{
|
||||
if (msg->msg) msg_release(msg->msg);
|
||||
if (msg->mtype) {
|
||||
int i;
|
||||
|
@ -68,8 +68,8 @@ msg_destroy_message(lua_message * msg)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
*/
|
||||
int msg_set_resource(lua_message * msg, const char *param, const char *resname)
|
||||
{
|
||||
if (msg->mtype) {
|
||||
|
@ -85,7 +85,8 @@ int msg_set_resource(lua_message * msg, const char *param, const char *resname)
|
|||
rtype = rt_find(resname);
|
||||
if (rtype) {
|
||||
msg->args[i].v = (void *)rtype;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return E_INVALID_PARAMETER_VALUE;
|
||||
}
|
||||
return E_OK;
|
||||
|
@ -207,51 +208,51 @@ static int tolua_msg_create(lua_State * L)
|
|||
|
||||
static int tolua_msg_set_string(lua_State * L)
|
||||
{
|
||||
lua_message *lmsg = (lua_message *) tolua_tousertype(L, 1, 0);
|
||||
lua_message *lmsg = (lua_message *)tolua_tousertype(L, 1, 0);
|
||||
const char *param = tolua_tostring(L, 2, 0);
|
||||
const char *value = tolua_tostring(L, 3, 0);
|
||||
int result = msg_set_string(lmsg, param, value);
|
||||
tolua_pushnumber(L, (lua_Number) result);
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_msg_set_int(lua_State * L)
|
||||
{
|
||||
lua_message *lmsg = (lua_message *) tolua_tousertype(L, 1, 0);
|
||||
lua_message *lmsg = (lua_message *)tolua_tousertype(L, 1, 0);
|
||||
const char *param = tolua_tostring(L, 2, 0);
|
||||
int value = (int)tolua_tonumber(L, 3, 0);
|
||||
int result = msg_set_int(lmsg, param, value);
|
||||
tolua_pushnumber(L, (lua_Number) result);
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_msg_set_resource(lua_State * L)
|
||||
{
|
||||
lua_message *lmsg = (lua_message *) tolua_tousertype(L, 1, 0);
|
||||
lua_message *lmsg = (lua_message *)tolua_tousertype(L, 1, 0);
|
||||
const char *param = tolua_tostring(L, 2, 0);
|
||||
const char *value = tolua_tostring(L, 3, 0);
|
||||
int result = msg_set_resource(lmsg, param, value);
|
||||
tolua_pushnumber(L, (lua_Number) result);
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_msg_set_unit(lua_State * L)
|
||||
{
|
||||
lua_message *lmsg = (lua_message *) tolua_tousertype(L, 1, 0);
|
||||
lua_message *lmsg = (lua_message *)tolua_tousertype(L, 1, 0);
|
||||
const char *param = tolua_tostring(L, 2, 0);
|
||||
unit *value = (unit *) tolua_tousertype(L, 3, 0);
|
||||
unit *value = (unit *)tolua_tousertype(L, 3, 0);
|
||||
int result = msg_set_unit(lmsg, param, value);
|
||||
tolua_pushnumber(L, (lua_Number) result);
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_msg_set_region(lua_State * L)
|
||||
{
|
||||
lua_message *lmsg = (lua_message *) tolua_tousertype(L, 1, 0);
|
||||
lua_message *lmsg = (lua_message *)tolua_tousertype(L, 1, 0);
|
||||
const char *param = tolua_tostring(L, 2, 0);
|
||||
region *value = (region *) tolua_tousertype(L, 3, 0);
|
||||
region *value = (region *)tolua_tousertype(L, 3, 0);
|
||||
int result = msg_set_region(lmsg, param, value);
|
||||
tolua_pushnumber(L, (lua_Number) result);
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -260,45 +261,47 @@ static int tolua_msg_set(lua_State * L)
|
|||
tolua_Error err;
|
||||
if (tolua_isnumber(L, 3, 0, &err)) {
|
||||
return tolua_msg_set_int(L);
|
||||
} else if (tolua_isusertype(L, 3, TOLUA_CAST "region", 0, &err)) {
|
||||
}
|
||||
else if (tolua_isusertype(L, 3, TOLUA_CAST "region", 0, &err)) {
|
||||
return tolua_msg_set_region(L);
|
||||
} else if (tolua_isusertype(L, 3, TOLUA_CAST "unit", 0, &err)) {
|
||||
}
|
||||
else if (tolua_isusertype(L, 3, TOLUA_CAST "unit", 0, &err)) {
|
||||
return tolua_msg_set_unit(L);
|
||||
}
|
||||
tolua_pushnumber(L, (lua_Number) - 1);
|
||||
tolua_pushnumber(L, (lua_Number)-1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_msg_send_region(lua_State * L)
|
||||
{
|
||||
lua_message *lmsg = (lua_message *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *) tolua_tousertype(L, 2, 0);
|
||||
lua_message *lmsg = (lua_message *)tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 2, 0);
|
||||
int result = msg_send_region(lmsg, r);
|
||||
tolua_pushnumber(L, (lua_Number) result);
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_msg_report_action(lua_State * L)
|
||||
{
|
||||
lua_message *lmsg = (lua_message *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *) tolua_tousertype(L, 2, 0);
|
||||
unit *u = (unit *) tolua_tousertype(L, 3, 0);
|
||||
lua_message *lmsg = (lua_message *)tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 2, 0);
|
||||
unit *u = (unit *)tolua_tousertype(L, 3, 0);
|
||||
int result, flags = (int)tolua_tonumber(L, 4, 0);
|
||||
if (lmsg->msg == NULL) {
|
||||
lmsg->msg = msg_create(lmsg->mtype, lmsg->args);
|
||||
}
|
||||
result = report_action(r, u, lmsg->msg, flags);
|
||||
tolua_pushnumber(L, (lua_Number) result);
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_msg_send_faction(lua_State * L)
|
||||
{
|
||||
lua_message *lmsg = (lua_message *) tolua_tousertype(L, 1, 0);
|
||||
faction *f = (faction *) tolua_tousertype(L, 2, 0);
|
||||
lua_message *lmsg = (lua_message *)tolua_tousertype(L, 1, 0);
|
||||
faction *f = (faction *)tolua_tousertype(L, 2, 0);
|
||||
if (f && lmsg) {
|
||||
int result = msg_send_faction(lmsg, f);
|
||||
tolua_pushnumber(L, (lua_Number) result);
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
|
||||
static int tolua_levitate_ship(lua_State * L)
|
||||
{
|
||||
ship *sh = (ship *) tolua_tousertype(L, 1, 0);
|
||||
unit *mage = (unit *) tolua_tousertype(L, 2, 0);
|
||||
ship *sh = (ship *)tolua_tousertype(L, 1, 0);
|
||||
unit *mage = (unit *)tolua_tousertype(L, 2, 0);
|
||||
float power = (float)tolua_tonumber(L, 3, 0);
|
||||
int duration = (int)tolua_tonumber(L, 4, 0);
|
||||
int cno = levitate_ship(sh, mage, power, duration);
|
||||
tolua_pushnumber(L, (lua_Number) cno);
|
||||
tolua_pushnumber(L, (lua_Number)cno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ extern void plan_monsters(struct faction *f);
|
|||
|
||||
static int 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) {
|
||||
plan_monsters(f);
|
||||
}
|
||||
|
|
|
@ -19,29 +19,30 @@
|
|||
#define PROC_LAND_REGION 0x0001
|
||||
#define PROC_LONG_ORDER 0x0002
|
||||
|
||||
static void process_cmd(keyword_t kwd, int (*callback)(unit *, order *), int flags)
|
||||
static void process_cmd(keyword_t kwd, int(*callback)(unit *, order *), int flags)
|
||||
{
|
||||
region * r;
|
||||
for (r=regions; r; r=r->next) {
|
||||
for (r = regions; r; r = r->next) {
|
||||
unit * u;
|
||||
|
||||
/* look for shortcuts */
|
||||
if (flags&PROC_LAND_REGION) {
|
||||
/* only execute when we are on solid terrain */
|
||||
while (r && (r->terrain->flags&LAND_REGION)==0) {
|
||||
while (r && (r->terrain->flags&LAND_REGION) == 0) {
|
||||
r = r->next;
|
||||
}
|
||||
if (!r) break;
|
||||
}
|
||||
|
||||
for (u=r->units; u; u=u->next) {
|
||||
for (u = r->units; u; u = u->next) {
|
||||
if (flags & PROC_LONG_ORDER) {
|
||||
if (kwd == getkeyword(u->thisorder)) {
|
||||
callback(u, u->thisorder);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
order * ord;
|
||||
for (ord=u->orders; ord; ord=ord->next) {
|
||||
for (ord = u->orders; ord; ord = ord->next) {
|
||||
if (kwd == getkeyword(ord)) {
|
||||
callback(u, ord);
|
||||
}
|
||||
|
@ -55,9 +56,9 @@ void process_produce(void) {
|
|||
struct region *r;
|
||||
for (r = regions; r; r = r->next) {
|
||||
unit * u;
|
||||
for (u=r->units; u; u=u->next) {
|
||||
for (u = r->units; u; u = u->next) {
|
||||
order * ord;
|
||||
for (ord=u->orders; ord; ord=ord->next) {
|
||||
for (ord = u->orders; ord; ord = ord->next) {
|
||||
if (K_MAKE == getkeyword(ord)) {
|
||||
make_cmd(u, ord);
|
||||
}
|
||||
|
@ -81,9 +82,9 @@ void process_siege(void) {
|
|||
|
||||
void process_update_long_order(void) {
|
||||
region * r;
|
||||
for (r=regions; r; r=r->next) {
|
||||
for (r = regions; r; r = r->next) {
|
||||
unit * u;
|
||||
for (u=r->units; u; u=u->next) {
|
||||
for (u = r->units; u; u = u->next) {
|
||||
update_long_order(u);
|
||||
}
|
||||
}
|
||||
|
@ -99,22 +100,22 @@ void process_make_temp(void) {
|
|||
|
||||
void process_settings(void) {
|
||||
region * r;
|
||||
for (r=regions; r; r=r->next) {
|
||||
for (r = regions; r; r = r->next) {
|
||||
unit * u;
|
||||
for (u=r->units; u; u=u->next) {
|
||||
for (u = r->units; u; u = u->next) {
|
||||
order * ord;
|
||||
for (ord=u->orders; ord; ord=ord->next) {
|
||||
for (ord = u->orders; ord; ord = ord->next) {
|
||||
keyword_t kwd = getkeyword(ord);
|
||||
if (kwd==K_BANNER) {
|
||||
if (kwd == K_BANNER) {
|
||||
banner_cmd(u, ord);
|
||||
}
|
||||
else if (kwd==K_EMAIL) {
|
||||
else if (kwd == K_EMAIL) {
|
||||
email_cmd(u, ord);
|
||||
}
|
||||
else if (kwd==K_SEND) {
|
||||
else if (kwd == K_SEND) {
|
||||
send_cmd(u, ord);
|
||||
}
|
||||
else if (kwd==K_PASSWORD) {
|
||||
else if (kwd == K_PASSWORD) {
|
||||
password_cmd(u, ord);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
@ -47,27 +47,28 @@ without prior permission by the authors of Eressea.
|
|||
|
||||
int tolua_regionlist_next(lua_State * L)
|
||||
{
|
||||
region **region_ptr = (region **) lua_touserdata(L, lua_upvalueindex(1));
|
||||
region **region_ptr = (region **)lua_touserdata(L, lua_upvalueindex(1));
|
||||
region *r = *region_ptr;
|
||||
if (r != NULL) {
|
||||
tolua_pushusertype(L, (void *)r, TOLUA_CAST "region");
|
||||
*region_ptr = r->next;
|
||||
return 1;
|
||||
} else
|
||||
}
|
||||
else
|
||||
return 0; /* no more values to return */
|
||||
}
|
||||
|
||||
static int tolua_region_get_id(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) self->uid);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number)self->uid);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_region_get_blocked(lua_State * L)
|
||||
{
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushboolean(L, (self->flags&RF_BLOCKED)!=0);
|
||||
lua_pushboolean(L, (self->flags&RF_BLOCKED) != 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -82,35 +83,35 @@ static int tolua_region_set_blocked(lua_State * L)
|
|||
|
||||
static int tolua_region_get_x(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) self->x);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number)self->x);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_region_get_y(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) self->y);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number)self->y);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_region_get_plane(lua_State * L)
|
||||
{
|
||||
region *r = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushusertype(L, rplane(r), TOLUA_CAST "plane");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_region_get_terrain(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, self->terrain->_name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_region_set_terrain(lua_State * L)
|
||||
{
|
||||
region *r = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||
const char *tname = tolua_tostring(L, 2, 0);
|
||||
if (tname) {
|
||||
const terrain_type *terrain = get_terrain(tname);
|
||||
|
@ -123,7 +124,7 @@ static int tolua_region_set_terrain(lua_State * L)
|
|||
|
||||
static int tolua_region_get_terrainname(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
attrib *a = a_find(self->attribs, &at_racename);
|
||||
if (a) {
|
||||
tolua_pushstring(L, get_racename(a));
|
||||
|
@ -134,7 +135,7 @@ static int tolua_region_get_terrainname(lua_State * L)
|
|||
|
||||
static int tolua_region_set_owner(lua_State * L)
|
||||
{
|
||||
region *r = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||
struct faction *f = (struct faction *)tolua_tousertype(L, 2, 0);
|
||||
if (r) {
|
||||
region_set_owner(r, f, turn);
|
||||
|
@ -144,7 +145,7 @@ static int tolua_region_set_owner(lua_State * L)
|
|||
|
||||
static int tolua_region_get_owner(lua_State * L)
|
||||
{
|
||||
region *r = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||
if (r) {
|
||||
struct faction *f = region_get_owner(r);
|
||||
tolua_pushusertype(L, f, TOLUA_CAST "faction");
|
||||
|
@ -155,11 +156,12 @@ static int tolua_region_get_owner(lua_State * L)
|
|||
|
||||
static int tolua_region_set_terrainname(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
const char *name = tolua_tostring(L, 2, 0);
|
||||
if (name == NULL) {
|
||||
a_removeall(&self->attribs, &at_racename);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
set_racename(&self->attribs, name);
|
||||
}
|
||||
return 0;
|
||||
|
@ -167,49 +169,49 @@ static int tolua_region_set_terrainname(lua_State * L)
|
|||
|
||||
static int tolua_region_get_info(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, region_getinfo(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_region_set_info(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
region_setinfo(self, tolua_tostring(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_region_get_name(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, region_getname(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_region_set_name(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
region_setname(self, tolua_tostring(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_region_get_morale(lua_State * L)
|
||||
{
|
||||
region *r = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, region_get_morale(r));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_region_set_morale(lua_State * L)
|
||||
{
|
||||
region *r = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||
region_set_morale(r, (int)tolua_tonumber(L, 2, 0), turn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_region_get_adj(lua_State * L)
|
||||
{
|
||||
region *r = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||
region *rn[MAXDIRECTIONS];
|
||||
int d, idx;
|
||||
get_neighbours(r, rn);
|
||||
|
@ -226,7 +228,7 @@ static int tolua_region_get_adj(lua_State * L)
|
|||
|
||||
static int tolua_region_get_luxury(lua_State * L)
|
||||
{
|
||||
region *r = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||
if (r->land) {
|
||||
const item_type *lux = r_luxury(r);
|
||||
if (lux) {
|
||||
|
@ -240,7 +242,7 @@ static int tolua_region_get_luxury(lua_State * L)
|
|||
|
||||
static int tolua_region_set_luxury(lua_State * L)
|
||||
{
|
||||
region *r = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||
const char *name = tolua_tostring(L, 2, 0);
|
||||
if (r->land && name) {
|
||||
const item_type *lux = r_luxury(r);
|
||||
|
@ -255,7 +257,7 @@ static int tolua_region_set_luxury(lua_State * L)
|
|||
|
||||
static int tolua_region_set_herb(lua_State * L)
|
||||
{
|
||||
region *r = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||
if (r->land) {
|
||||
const char *name = tolua_tostring(L, 2, 0);
|
||||
const item_type *itype = it_find(name);
|
||||
|
@ -268,7 +270,7 @@ static int tolua_region_set_herb(lua_State * L)
|
|||
|
||||
static int tolua_region_get_herb(lua_State * L)
|
||||
{
|
||||
region *r = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||
if (r->land && r->land->herbtype) {
|
||||
const char *name = r->land->herbtype->rtype->_name;
|
||||
tolua_pushstring(L, name);
|
||||
|
@ -279,8 +281,8 @@ static int tolua_region_get_herb(lua_State * L)
|
|||
|
||||
static int tolua_region_get_next(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
direction_t dir = (direction_t) tolua_tonumber(L, 2, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
direction_t dir = (direction_t)tolua_tonumber(L, 2, 0);
|
||||
|
||||
if (dir >= 0 && dir < MAXDIRECTIONS) {
|
||||
tolua_pushusertype(L, (void *)r_connect(self, dir), TOLUA_CAST "region");
|
||||
|
@ -291,7 +293,7 @@ static int tolua_region_get_next(lua_State * L)
|
|||
|
||||
static int tolua_region_get_flag(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
int bit = (int)tolua_tonumber(L, 2, 0);
|
||||
|
||||
lua_pushboolean(L, (self->flags & (1 << bit)));
|
||||
|
@ -300,7 +302,7 @@ static int tolua_region_get_flag(lua_State * L)
|
|||
|
||||
static int tolua_region_set_flag(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
int bit = (int)tolua_tonumber(L, 2, 0);
|
||||
int set = tolua_toboolean(L, 3, 1);
|
||||
|
||||
|
@ -313,14 +315,14 @@ static int tolua_region_set_flag(lua_State * L)
|
|||
|
||||
static int tolua_region_get_resourcelevel(lua_State * L)
|
||||
{
|
||||
region *r = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||
const char *type = tolua_tostring(L, 2, 0);
|
||||
const resource_type *rtype = rt_find(type);
|
||||
if (rtype != NULL) {
|
||||
const rawmaterial *rm;
|
||||
for (rm = r->resources; rm; rm = rm->next) {
|
||||
if (rm->type->rtype == rtype) {
|
||||
tolua_pushnumber(L, (lua_Number) rm->level);
|
||||
tolua_pushnumber(L, (lua_Number)rm->level);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -337,7 +339,7 @@ static critbit_tree * special_resources(void)
|
|||
const char * special[] = { "seed", "sapling", "tree", "grave", "chaos", 0 };
|
||||
char buffer[32];
|
||||
int i;
|
||||
for (i=0;special[i];++i) {
|
||||
for (i = 0; special[i]; ++i) {
|
||||
size_t len = strlen(special[i]);
|
||||
len = cb_new_kv(special[i], len, &i, sizeof(int), buffer);
|
||||
cb_insert(&cb, buffer, len);
|
||||
|
@ -355,12 +357,12 @@ static int tolua_region_get_resource(lua_State * L)
|
|||
const void * matches;
|
||||
critbit_tree * cb = special_resources();
|
||||
|
||||
r = (region *) tolua_tousertype(L, 1, 0);
|
||||
r = (region *)tolua_tousertype(L, 1, 0);
|
||||
LUA_ASSERT(r != NULL, "invalid parameter");
|
||||
type = tolua_tostring(L, 2, 0);
|
||||
LUA_ASSERT(type != NULL, "invalid parameter");
|
||||
|
||||
if (cb_find_prefix(cb, type, strlen(type)+1, &matches, 1, 0)) {
|
||||
if (cb_find_prefix(cb, type, strlen(type) + 1, &matches, 1, 0)) {
|
||||
cb_get_kv(matches, &result, sizeof(result));
|
||||
switch (result) {
|
||||
case 0:
|
||||
|
@ -375,28 +377,30 @@ static int tolua_region_get_resource(lua_State * L)
|
|||
result = get_chaoscount(r);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
rtype = rt_find(type);
|
||||
if (rtype) {
|
||||
result = region_getresource(r, rtype);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
|
||||
tolua_pushnumber(L, (lua_Number) result);
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_region_set_resource(lua_State * L)
|
||||
{
|
||||
region *r = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||
const char *type = tolua_tostring(L, 2, 0);
|
||||
int result, value = (int)tolua_tonumber(L, 3, 0);
|
||||
critbit_tree * cb = special_resources();
|
||||
const void * matches;
|
||||
|
||||
if (cb_find_prefix(cb, type, strlen(type)+1, &matches, 1, 0)) {
|
||||
if (cb_find_prefix(cb, type, strlen(type) + 1, &matches, 1, 0)) {
|
||||
cb_get_kv(matches, &result, sizeof(result));
|
||||
switch (result) {
|
||||
case 0:
|
||||
|
@ -411,7 +415,8 @@ static int tolua_region_set_resource(lua_State * L)
|
|||
add_chaoscount(r, value - get_chaoscount(r));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const resource_type *rtype = rt_find(type);
|
||||
if (rtype != NULL) {
|
||||
region_setresource(r, rtype, value);
|
||||
|
@ -422,14 +427,14 @@ static int tolua_region_set_resource(lua_State * L)
|
|||
|
||||
static int tolua_region_get_objects(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushusertype(L, (void *)&self->attribs, TOLUA_CAST "hashtable");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_region_destroy(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
remove_region(®ions, self);
|
||||
return 0;
|
||||
}
|
||||
|
@ -453,7 +458,8 @@ static int tolua_region_create(lua_State * L)
|
|||
if (terrain == NULL && r != NULL && r->units != NULL) {
|
||||
/* TODO: error message */
|
||||
result = NULL;
|
||||
} else if (r == NULL) {
|
||||
}
|
||||
else if (r == NULL) {
|
||||
result = new_region(x, y, pl, 0);
|
||||
}
|
||||
if (result) {
|
||||
|
@ -471,8 +477,8 @@ static int tolua_region_create(lua_State * L)
|
|||
|
||||
static int tolua_region_get_units(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
unit **unit_ptr = (unit **) lua_newuserdata(L, sizeof(unit *));
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
unit **unit_ptr = (unit **)lua_newuserdata(L, sizeof(unit *));
|
||||
|
||||
luaL_getmetatable(L, "unit");
|
||||
lua_setmetatable(L, -2);
|
||||
|
@ -485,9 +491,9 @@ static int tolua_region_get_units(lua_State * L)
|
|||
|
||||
static int tolua_region_get_buildings(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
building **building_ptr =
|
||||
(building **) lua_newuserdata(L, sizeof(building *));
|
||||
(building **)lua_newuserdata(L, sizeof(building *));
|
||||
|
||||
luaL_getmetatable(L, "building");
|
||||
lua_setmetatable(L, -2);
|
||||
|
@ -500,8 +506,8 @@ static int tolua_region_get_buildings(lua_State * L)
|
|||
|
||||
static int tolua_region_get_ships(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
ship **ship_ptr = (ship **) lua_newuserdata(L, sizeof(ship *));
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
ship **ship_ptr = (ship **)lua_newuserdata(L, sizeof(ship *));
|
||||
|
||||
luaL_getmetatable(L, "ship");
|
||||
lua_setmetatable(L, -2);
|
||||
|
@ -514,7 +520,7 @@ static int tolua_region_get_ships(lua_State * L)
|
|||
|
||||
static int tolua_region_get_age(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
|
||||
if (self) {
|
||||
lua_pushnumber(L, self->age);
|
||||
|
@ -525,7 +531,7 @@ static int tolua_region_get_age(lua_State * L)
|
|||
|
||||
static int tolua_region_getkey(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
const char *name = tolua_tostring(L, 2, 0);
|
||||
|
||||
int flag = atoi36(name);
|
||||
|
@ -537,7 +543,7 @@ static int tolua_region_getkey(lua_State * L)
|
|||
|
||||
static int tolua_region_setkey(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
const char *name = tolua_tostring(L, 2, 0);
|
||||
int value = tolua_toboolean(L, 3, 0);
|
||||
|
||||
|
@ -545,7 +551,8 @@ static int tolua_region_setkey(lua_State * L)
|
|||
attrib *a = find_key(self->attribs, flag);
|
||||
if (a == NULL && value) {
|
||||
add_key(&self->attribs, flag);
|
||||
} else if (a != NULL && !value) {
|
||||
}
|
||||
else if (a != NULL && !value) {
|
||||
a_remove(&self->attribs, a);
|
||||
}
|
||||
return 0;
|
||||
|
@ -553,7 +560,7 @@ static int tolua_region_setkey(lua_State * L)
|
|||
|
||||
static int tolua_region_tostring(lua_State * L)
|
||||
{
|
||||
region *self = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushstring(L, regionname(self, NULL));
|
||||
return 1;
|
||||
}
|
||||
|
@ -585,14 +592,14 @@ static int tolua_plane_create(lua_State * L)
|
|||
|
||||
static int tolua_plane_get_name(lua_State * L)
|
||||
{
|
||||
plane *self = (plane *) tolua_tousertype(L, 1, 0);
|
||||
plane *self = (plane *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, self->name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_plane_set_name(lua_State * L)
|
||||
{
|
||||
plane *self = (plane *) tolua_tousertype(L, 1, 0);
|
||||
plane *self = (plane *)tolua_tousertype(L, 1, 0);
|
||||
const char *str = tolua_tostring(L, 2, 0);
|
||||
free(self->name);
|
||||
if (str)
|
||||
|
@ -604,32 +611,32 @@ static int tolua_plane_set_name(lua_State * L)
|
|||
|
||||
static int tolua_plane_get_id(lua_State * L)
|
||||
{
|
||||
plane *self = (plane *) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) self->id);
|
||||
plane *self = (plane *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number)self->id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_plane_normalize(lua_State * L)
|
||||
{
|
||||
plane *self = (plane *) tolua_tousertype(L, 1, 0);
|
||||
plane *self = (plane *)tolua_tousertype(L, 1, 0);
|
||||
int x = (int)tolua_tonumber(L, 2, 0);
|
||||
int y = (int)tolua_tonumber(L, 3, 0);
|
||||
pnormalize(&x, &y, self);
|
||||
tolua_pushnumber(L, (lua_Number) x);
|
||||
tolua_pushnumber(L, (lua_Number) y);
|
||||
tolua_pushnumber(L, (lua_Number)x);
|
||||
tolua_pushnumber(L, (lua_Number)y);
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int tolua_plane_tostring(lua_State * L)
|
||||
{
|
||||
plane *self = (plane *) tolua_tousertype(L, 1, 0);
|
||||
plane *self = (plane *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushstring(L, self->name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_plane_get_size(lua_State * L)
|
||||
{
|
||||
plane *pl = (plane *) tolua_tousertype(L, 1, 0);
|
||||
plane *pl = (plane *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushnumber(L, plane_width(pl));
|
||||
lua_pushnumber(L, plane_height(pl));
|
||||
return 2;
|
||||
|
@ -641,7 +648,7 @@ static int tolua_distance(lua_State * L)
|
|||
int y1 = (int)tolua_tonumber(L, 2, 0);
|
||||
int x2 = (int)tolua_tonumber(L, 3, 0);
|
||||
int y2 = (int)tolua_tonumber(L, 4, 0);
|
||||
plane *pl = (plane *) tolua_tousertype(L, 5, 0);
|
||||
plane *pl = (plane *)tolua_tousertype(L, 5, 0);
|
||||
int result;
|
||||
|
||||
if (!pl)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
const char * settings_get(const char *key);
|
||||
void settings_set(const char *key, const char *value);
|
||||
const char * settings_get(const char *key);
|
||||
void settings_set(const char *key, const char *value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
@ -30,40 +30,41 @@ without prior permission by the authors of Eressea.
|
|||
|
||||
int tolua_shiplist_next(lua_State * L)
|
||||
{
|
||||
ship **ship_ptr = (ship **) lua_touserdata(L, lua_upvalueindex(1));
|
||||
ship **ship_ptr = (ship **)lua_touserdata(L, lua_upvalueindex(1));
|
||||
ship *u = *ship_ptr;
|
||||
if (u != NULL) {
|
||||
tolua_pushusertype(L, (void *)u, TOLUA_CAST "ship");
|
||||
*ship_ptr = u->next;
|
||||
return 1;
|
||||
} else
|
||||
}
|
||||
else
|
||||
return 0; /* no more values to return */
|
||||
}
|
||||
|
||||
static int tolua_ship_get_id(lua_State * L)
|
||||
{
|
||||
ship *self = (ship *) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) self->no);
|
||||
ship *self = (ship *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number)self->no);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_ship_get_name(lua_State * L)
|
||||
{
|
||||
ship *self = (ship *) tolua_tousertype(L, 1, 0);
|
||||
ship *self = (ship *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, ship_getname(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_ship_get_display(lua_State * L)
|
||||
{
|
||||
ship *self = (ship *) tolua_tousertype(L, 1, 0);
|
||||
ship *self = (ship *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, self->display);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_ship_get_region(lua_State * L)
|
||||
{
|
||||
ship *self = (ship *) tolua_tousertype(L, 1, 0);
|
||||
ship *self = (ship *)tolua_tousertype(L, 1, 0);
|
||||
if (self) {
|
||||
tolua_pushusertype(L, self->region, TOLUA_CAST "region");
|
||||
return 1;
|
||||
|
@ -73,8 +74,8 @@ static int tolua_ship_get_region(lua_State * L)
|
|||
|
||||
static int tolua_ship_set_region(lua_State * L)
|
||||
{
|
||||
ship *self = (ship *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *) tolua_tousertype(L, 1, 0);
|
||||
ship *self = (ship *)tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||
if (self) {
|
||||
move_ship(self, self->region, r, NULL);
|
||||
}
|
||||
|
@ -83,14 +84,14 @@ static int tolua_ship_set_region(lua_State * L)
|
|||
|
||||
static int tolua_ship_set_name(lua_State * L)
|
||||
{
|
||||
ship *self = (ship *) tolua_tousertype(L, 1, 0);
|
||||
ship *self = (ship *)tolua_tousertype(L, 1, 0);
|
||||
ship_setname(self, tolua_tostring(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_ship_set_display(lua_State * L)
|
||||
{
|
||||
ship *self = (ship *) tolua_tousertype(L, 1, 0);
|
||||
ship *self = (ship *)tolua_tousertype(L, 1, 0);
|
||||
free(self->display);
|
||||
self->display = _strdup(tolua_tostring(L, 2, 0));
|
||||
return 0;
|
||||
|
@ -98,8 +99,8 @@ static int tolua_ship_set_display(lua_State * L)
|
|||
|
||||
static int tolua_ship_get_units(lua_State * L)
|
||||
{
|
||||
ship *self = (ship *) tolua_tousertype(L, 1, 0);
|
||||
unit **unit_ptr = (unit **) lua_newuserdata(L, sizeof(unit *));
|
||||
ship *self = (ship *)tolua_tousertype(L, 1, 0);
|
||||
unit **unit_ptr = (unit **)lua_newuserdata(L, sizeof(unit *));
|
||||
unit *u = self->region->units;
|
||||
|
||||
while (u && u->ship != self)
|
||||
|
@ -115,14 +116,14 @@ static int tolua_ship_get_units(lua_State * L)
|
|||
|
||||
static int tolua_ship_get_objects(lua_State * L)
|
||||
{
|
||||
ship *self = (ship *) tolua_tousertype(L, 1, 0);
|
||||
ship *self = (ship *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushusertype(L, (void *)&self->attribs, TOLUA_CAST "hashtable");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_ship_create(lua_State * L)
|
||||
{
|
||||
region *r = (region *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||
const char *sname = tolua_tostring(L, 2, 0);
|
||||
if (sname) {
|
||||
const ship_type *stype = st_find(sname);
|
||||
|
@ -131,7 +132,8 @@ static int tolua_ship_create(lua_State * L)
|
|||
sh->size = stype->construction ? stype->construction->maxsize : 1;
|
||||
tolua_pushusertype(L, (void *)sh, TOLUA_CAST "ship");
|
||||
return 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
log_error("Unknown ship type '%s'\n", sname);
|
||||
}
|
||||
}
|
||||
|
@ -139,41 +141,42 @@ static int tolua_ship_create(lua_State * L)
|
|||
}
|
||||
|
||||
static int
|
||||
tolua_ship_tostring(lua_State * L)
|
||||
tolua_ship_tostring(lua_State * L)
|
||||
{
|
||||
ship *self = (ship *) tolua_tousertype(L, 1, 0);
|
||||
ship *self = (ship *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushstring(L, shipname(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_ship_get_flags(lua_State * L)
|
||||
{
|
||||
ship *self = (ship *) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) self->flags);
|
||||
ship *self = (ship *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number)self->flags);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_ship_set_flags(lua_State * L)
|
||||
{
|
||||
ship *self = (ship *) tolua_tousertype(L, 1, 0);
|
||||
ship *self = (ship *)tolua_tousertype(L, 1, 0);
|
||||
self->flags = (int)tolua_tonumber(L, 2, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_ship_set_coast(lua_State * L)
|
||||
{
|
||||
ship *self = (ship *) tolua_tousertype(L, 1, 0);
|
||||
ship *self = (ship *)tolua_tousertype(L, 1, 0);
|
||||
if (lua_isnil(L, 2)) {
|
||||
self->coast = NODIRECTION;
|
||||
} else if (lua_isnumber(L, 2)) {
|
||||
self->coast = (direction_t) tolua_tonumber(L, 2, 0);
|
||||
}
|
||||
else if (lua_isnumber(L, 2)) {
|
||||
self->coast = (direction_t)tolua_tonumber(L, 2, 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_ship_get_coast(lua_State * L)
|
||||
{
|
||||
ship *self = (ship *) tolua_tousertype(L, 1, 0);
|
||||
ship *self = (ship *)tolua_tousertype(L, 1, 0);
|
||||
if (self->coast) {
|
||||
tolua_pushnumber(L, self->coast);
|
||||
return 1;
|
||||
|
@ -183,7 +186,7 @@ static int tolua_ship_get_coast(lua_State * L)
|
|||
|
||||
static int tolua_ship_get_type(lua_State * L)
|
||||
{
|
||||
ship *self = (ship *) tolua_tousertype(L, 1, 0);
|
||||
ship *self = (ship *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, self->type->_name);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
|
207
src/bind_unit.c
207
src/bind_unit.c
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
@ -58,7 +58,7 @@ without prior permission by the authors of Eressea.
|
|||
|
||||
static int tolua_unit_get_objects(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushusertype(L, (void *)&self->attribs, TOLUA_CAST "hashtable");
|
||||
return 1;
|
||||
}
|
||||
|
@ -82,19 +82,20 @@ static int tolua_unit_get_attribs(lua_State * L)
|
|||
|
||||
int tolua_unitlist_nextf(lua_State * L)
|
||||
{
|
||||
unit **unit_ptr = (unit **) lua_touserdata(L, lua_upvalueindex(1));
|
||||
unit **unit_ptr = (unit **)lua_touserdata(L, lua_upvalueindex(1));
|
||||
unit *u = *unit_ptr;
|
||||
if (u != NULL) {
|
||||
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
|
||||
*unit_ptr = u->nextF;
|
||||
return 1;
|
||||
} else
|
||||
}
|
||||
else
|
||||
return 0; /* no more values to return */
|
||||
}
|
||||
|
||||
int tolua_unitlist_nextb(lua_State * L)
|
||||
{
|
||||
unit **unit_ptr = (unit **) lua_touserdata(L, lua_upvalueindex(1));
|
||||
unit **unit_ptr = (unit **)lua_touserdata(L, lua_upvalueindex(1));
|
||||
unit *u = *unit_ptr;
|
||||
if (u != NULL) {
|
||||
unit *unext = u->next;
|
||||
|
@ -106,13 +107,14 @@ int tolua_unitlist_nextb(lua_State * L)
|
|||
*unit_ptr = unext;
|
||||
|
||||
return 1;
|
||||
} else
|
||||
}
|
||||
else
|
||||
return 0; /* no more values to return */
|
||||
}
|
||||
|
||||
int tolua_unitlist_nexts(lua_State * L)
|
||||
{
|
||||
unit **unit_ptr = (unit **) lua_touserdata(L, lua_upvalueindex(1));
|
||||
unit **unit_ptr = (unit **)lua_touserdata(L, lua_upvalueindex(1));
|
||||
unit *u = *unit_ptr;
|
||||
if (u != NULL) {
|
||||
unit *unext = u->next;
|
||||
|
@ -124,25 +126,27 @@ int tolua_unitlist_nexts(lua_State * L)
|
|||
*unit_ptr = unext;
|
||||
|
||||
return 1;
|
||||
} else
|
||||
}
|
||||
else
|
||||
return 0; /* no more values to return */
|
||||
}
|
||||
|
||||
int tolua_unitlist_next(lua_State * L)
|
||||
{
|
||||
unit **unit_ptr = (unit **) lua_touserdata(L, lua_upvalueindex(1));
|
||||
unit **unit_ptr = (unit **)lua_touserdata(L, lua_upvalueindex(1));
|
||||
unit *u = *unit_ptr;
|
||||
if (u != NULL) {
|
||||
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
|
||||
*unit_ptr = u->next;
|
||||
return 1;
|
||||
} else
|
||||
}
|
||||
else
|
||||
return 0; /* no more values to return */
|
||||
}
|
||||
|
||||
static int tolua_unit_get_group(lua_State * L)
|
||||
{
|
||||
unit *u = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *u = (unit *)tolua_tousertype(L, 1, 0);
|
||||
group *g = get_group(u);
|
||||
if (g) {
|
||||
tolua_pushstring(L, g->name);
|
||||
|
@ -153,7 +157,7 @@ static int tolua_unit_get_group(lua_State * L)
|
|||
|
||||
static int tolua_unit_set_group(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
int result = join_group(self, tolua_tostring(L, 2, 0));
|
||||
tolua_pushnumber(L, result);
|
||||
return 1;
|
||||
|
@ -161,82 +165,83 @@ static int tolua_unit_set_group(lua_State * L)
|
|||
|
||||
static int tolua_unit_get_name(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, self->name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_unit_set_name(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
unit_setname(self, tolua_tostring(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_unit_get_info(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, unit_getinfo(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_unit_set_info(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
unit_setinfo(self, tolua_tostring(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_unit_get_id(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushinteger(L, unit_getid(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_unit_set_id(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
unit_setid(self, (int)tolua_tonumber(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_unit_get_hpmax(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushinteger(L, unit_max_hp(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_unit_get_hp(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushinteger(L, unit_gethp(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_unit_set_hp(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
unit_sethp(self, (int)tolua_tonumber(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_unit_get_number(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushinteger(L, self->number);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_unit_set_number(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
int number = (int)tolua_tonumber(L, 2, 0);
|
||||
if (self->number == 0) {
|
||||
set_number(self, number);
|
||||
self->hp = unit_max_hp(self) * number;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
scale_number(self, number);
|
||||
}
|
||||
return 0;
|
||||
|
@ -244,14 +249,14 @@ static int tolua_unit_set_number(lua_State * L)
|
|||
|
||||
static int tolua_unit_get_flags(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushinteger(L, self->flags);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_unit_set_flags(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
self->flags = (int)tolua_tonumber(L, 2, 0);
|
||||
return 0;
|
||||
}
|
||||
|
@ -264,7 +269,7 @@ static const char *unit_getmagic(const unit * u)
|
|||
|
||||
static int tolua_unit_get_magic(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushstring(L, unit_getmagic(self));
|
||||
return 1;
|
||||
}
|
||||
|
@ -286,7 +291,7 @@ static void unit_setmagic(unit * u, const char *type)
|
|||
|
||||
static int tolua_unit_set_magic(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *type = tolua_tostring(L, 2, 0);
|
||||
unit_setmagic(self, type);
|
||||
return 0;
|
||||
|
@ -294,49 +299,49 @@ static int tolua_unit_set_magic(lua_State * L)
|
|||
|
||||
static int tolua_unit_get_aura(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushinteger(L, get_spellpoints(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_unit_set_aura(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
set_spellpoints(self, (int)tolua_tonumber(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_unit_get_age(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushinteger(L, self->age);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_unit_set_age(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
self->age = (short)tolua_tonumber(L, 2, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_unit_get_status(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushinteger(L, unit_getstatus(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_unit_set_status(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit_setstatus(self, (status_t) tolua_tonumber(L, 2, 0));
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
unit_setstatus(self, (status_t)tolua_tonumber(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_unit_get_item(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *iname = tolua_tostring(L, 2, 0);
|
||||
int result = -1;
|
||||
|
||||
|
@ -370,7 +375,7 @@ static int tolua_unit_get_effect(lua_State * L)
|
|||
|
||||
static int tolua_unit_add_item(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *iname = tolua_tostring(L, 2, 0);
|
||||
int number = (int)tolua_tonumber(L, 3, 0);
|
||||
int result = -1;
|
||||
|
@ -388,7 +393,7 @@ static int tolua_unit_add_item(lua_State * L)
|
|||
|
||||
static int tolua_unit_getskill(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *skname = tolua_tostring(L, 2, 0);
|
||||
skill_t sk = findskill(skname);
|
||||
int value = -1;
|
||||
|
@ -396,7 +401,8 @@ static int tolua_unit_getskill(lua_State * L)
|
|||
skill *sv = unit_skill(self, sk);
|
||||
if (sv) {
|
||||
value = sv->level;
|
||||
} else
|
||||
}
|
||||
else
|
||||
value = 0;
|
||||
}
|
||||
lua_pushinteger(L, value);
|
||||
|
@ -405,7 +411,7 @@ static int tolua_unit_getskill(lua_State * L)
|
|||
|
||||
static int tolua_unit_effskill(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *skname = tolua_tostring(L, 2, 0);
|
||||
skill_t sk = findskill(skname);
|
||||
int value = (sk == NOSKILL) ? -1 : eff_skill(self, sk, self->region);
|
||||
|
@ -427,11 +433,11 @@ int fctr_handle(struct trigger *tp, void *data)
|
|||
{
|
||||
trigger *t = tp;
|
||||
event evt = { 0 };
|
||||
fctr_data *fd = (fctr_data *) t->data.v;
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
fctr_data *fd = (fctr_data *)t->data.v;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
unit *u = fd->target;
|
||||
|
||||
evt.args = (event_arg *) data;
|
||||
evt.args = (event_arg *)data;
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, fd->fhandle);
|
||||
tolua_pushusertype(L, u, TOLUA_CAST "unit");
|
||||
tolua_pushusertype(L, &evt, TOLUA_CAST "event");
|
||||
|
@ -452,8 +458,8 @@ static void fctr_init(trigger * t)
|
|||
|
||||
static void fctr_done(trigger * t)
|
||||
{
|
||||
fctr_data *fd = (fctr_data *) t->data.v;
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
fctr_data *fd = (fctr_data *)t->data.v;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, fd->fhandle);
|
||||
free(fd);
|
||||
}
|
||||
|
@ -468,7 +474,7 @@ static struct trigger_type tt_lua = {
|
|||
static trigger *trigger_lua(struct unit *u, int handle)
|
||||
{
|
||||
trigger *t = t_new(&tt_lua);
|
||||
fctr_data *td = (fctr_data *) t->data.v;
|
||||
fctr_data *td = (fctr_data *)t->data.v;
|
||||
td->target = u;
|
||||
td->fhandle = handle;
|
||||
return t;
|
||||
|
@ -476,7 +482,7 @@ static trigger *trigger_lua(struct unit *u, int handle)
|
|||
|
||||
static int tolua_unit_addhandler(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *ename = tolua_tostring(L, 2, 0);
|
||||
int handle;
|
||||
|
||||
|
@ -489,7 +495,7 @@ static int tolua_unit_addhandler(lua_State * L)
|
|||
|
||||
static int tolua_unit_addnotice(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *str = tolua_tostring(L, 2, 0);
|
||||
|
||||
addmessage(self->region, self->faction, str, MSG_MESSAGE, ML_IMPORTANT);
|
||||
|
@ -505,7 +511,8 @@ static void unit_castspell(unit * u, const char *name, int level)
|
|||
if (spellbook_get(book, sp)) {
|
||||
if (!sp->cast) {
|
||||
log_error("spell '%s' has no function.\n", sp->sname);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
castorder co;
|
||||
create_castorder(&co, u, 0, sp, u->region, level, level * MagicPower(), 0, 0, 0);
|
||||
sp->cast(&co);
|
||||
|
@ -517,7 +524,7 @@ static void unit_castspell(unit * u, const char *name, int level)
|
|||
|
||||
static int tolua_unit_castspell(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *str = tolua_tostring(L, 2, 0);
|
||||
int level = (int)tolua_tonumber(L, 3, 1);
|
||||
|
||||
|
@ -527,7 +534,7 @@ static int tolua_unit_castspell(lua_State * L)
|
|||
|
||||
static int tolua_unit_addspell(lua_State * L)
|
||||
{
|
||||
unit *u = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *u = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *str = tolua_tostring(L, 2, 0);
|
||||
int level = (int)tolua_tonumber(L, 3, 1);
|
||||
int err = 0;
|
||||
|
@ -536,7 +543,8 @@ static int tolua_unit_addspell(lua_State * L)
|
|||
if (!sp) {
|
||||
log_error("spell %s could not be found\n", str);
|
||||
return EINVAL;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
unit_add_spell(u, 0, sp, level);
|
||||
}
|
||||
|
||||
|
@ -546,7 +554,7 @@ static int tolua_unit_addspell(lua_State * L)
|
|||
|
||||
static int tolua_unit_set_racename(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *str = tolua_tostring(L, 2, 0);
|
||||
|
||||
set_racename(&self->attribs, str);
|
||||
|
@ -555,7 +563,7 @@ static int tolua_unit_set_racename(lua_State * L)
|
|||
|
||||
static int tolua_unit_get_racename(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
attrib *a = a_find(self->attribs, &at_racename);
|
||||
if (a) {
|
||||
tolua_pushstring(L, get_racename(a));
|
||||
|
@ -566,13 +574,14 @@ static int tolua_unit_get_racename(lua_State * L)
|
|||
|
||||
static int tolua_unit_setskill(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *skname = tolua_tostring(L, 2, 0);
|
||||
int level = (int)tolua_tonumber(L, 3, 0);
|
||||
skill_t sk = findskill(skname);
|
||||
if (sk != NOSKILL) {
|
||||
set_level(self, sk, level);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
level = -1;
|
||||
}
|
||||
lua_pushinteger(L, level);
|
||||
|
@ -581,7 +590,7 @@ static int tolua_unit_setskill(lua_State * L)
|
|||
|
||||
static int tolua_unit_use_pooled(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *iname = tolua_tostring(L, 2, 0);
|
||||
int number = (int)tolua_tonumber(L, 3, 0);
|
||||
const resource_type *rtype = rt_find(iname);
|
||||
|
@ -595,7 +604,7 @@ static int tolua_unit_use_pooled(lua_State * L)
|
|||
|
||||
static int tolua_unit_get_pooled(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *iname = tolua_tostring(L, 2, 0);
|
||||
const resource_type *rtype = rt_find(iname);
|
||||
int result = -1;
|
||||
|
@ -610,38 +619,38 @@ static unit *unit_getfamiliar(const unit * u)
|
|||
{
|
||||
attrib *a = a_find(u->attribs, &at_familiar);
|
||||
if (a != NULL) {
|
||||
return (unit *) a->data.v;
|
||||
return (unit *)a->data.v;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int tolua_unit_get_familiar(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushusertype(L, unit_getfamiliar(self), TOLUA_CAST "unit");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_unit_set_familiar(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
create_newfamiliar(self, (unit *) tolua_tousertype(L, 2, 0));
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
create_newfamiliar(self, (unit *)tolua_tousertype(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_unit_get_building(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushusertype(L, self->building, TOLUA_CAST "building");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_unit_set_building(lua_State * L)
|
||||
{
|
||||
unit *u = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *u = (unit *)tolua_tousertype(L, 1, 0);
|
||||
if (u->faction) {
|
||||
building * b = (building *) tolua_tousertype(L, 2, 0);
|
||||
if (b!=u->building) {
|
||||
building * b = (building *)tolua_tousertype(L, 2, 0);
|
||||
if (b != u->building) {
|
||||
leave(u, true);
|
||||
if (b) {
|
||||
if (u->region != b->region) {
|
||||
|
@ -656,7 +665,7 @@ static int tolua_unit_set_building(lua_State * L)
|
|||
|
||||
static int tolua_unit_get_ship(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushusertype(L, self->ship, TOLUA_CAST "ship");
|
||||
return 1;
|
||||
}
|
||||
|
@ -672,16 +681,16 @@ static void unit_setship(unit * u, ship * s)
|
|||
|
||||
static int tolua_unit_set_ship(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
if (self->faction) {
|
||||
unit_setship(self, (ship *) tolua_tousertype(L, 2, 0));
|
||||
unit_setship(self, (ship *)tolua_tousertype(L, 2, 0));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_unit_get_region(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushusertype(L, self->region, TOLUA_CAST "region");
|
||||
return 1;
|
||||
}
|
||||
|
@ -693,14 +702,14 @@ static void unit_setregion(unit * u, region * r)
|
|||
|
||||
static int tolua_unit_set_region(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit_setregion(self, (region *) tolua_tousertype(L, 2, 0));
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
unit_setregion(self, (region *)tolua_tousertype(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_unit_add_order(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *str = tolua_tostring(L, 2, 0);
|
||||
order *ord = parse_order(str, self->faction->locale);
|
||||
unit_addorder(self, ord);
|
||||
|
@ -709,16 +718,16 @@ static int tolua_unit_add_order(lua_State * L)
|
|||
|
||||
static int tolua_unit_clear_orders(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
free_orders(&self->orders);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_unit_get_items(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
|
||||
item **item_ptr = (item **) lua_newuserdata(L, sizeof(item *));
|
||||
item **item_ptr = (item **)lua_newuserdata(L, sizeof(item *));
|
||||
|
||||
luaL_getmetatable(L, TOLUA_CAST "item");
|
||||
lua_setmetatable(L, -2);
|
||||
|
@ -767,9 +776,9 @@ static int tolua_unit_removespell(lua_State * L)
|
|||
|
||||
static int tolua_unit_get_orders(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
|
||||
order **order_ptr = (order **) lua_newuserdata(L, sizeof(order *));
|
||||
order **order_ptr = (order **)lua_newuserdata(L, sizeof(order *));
|
||||
|
||||
luaL_getmetatable(L, TOLUA_CAST "order");
|
||||
lua_setmetatable(L, -2);
|
||||
|
@ -783,7 +792,7 @@ static int tolua_unit_get_orders(lua_State * L)
|
|||
|
||||
static int tolua_unit_get_flag(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *name = tolua_tostring(L, 2, 0);
|
||||
int flag = atoi36(name);
|
||||
attrib *a = find_key(self->attribs, flag);
|
||||
|
@ -793,14 +802,15 @@ static int tolua_unit_get_flag(lua_State * L)
|
|||
|
||||
static int tolua_unit_set_flag(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *name = tolua_tostring(L, 2, 0);
|
||||
int value = (int)tolua_tonumber(L, 3, 0);
|
||||
int flag = atoi36(name);
|
||||
attrib *a = find_key(self->attribs, flag);
|
||||
if (a == NULL && value) {
|
||||
add_key(&self->attribs, flag);
|
||||
} else if (a != NULL && !value) {
|
||||
}
|
||||
else if (a != NULL && !value) {
|
||||
a_remove(&self->attribs, a);
|
||||
}
|
||||
return 0;
|
||||
|
@ -808,43 +818,43 @@ static int tolua_unit_set_flag(lua_State * L)
|
|||
|
||||
static int tolua_unit_get_weight(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushinteger(L, unit_getweight(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_unit_get_capacity(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushinteger(L, unit_getcapacity(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_unit_get_faction(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushusertype(L, (void *)self->faction, TOLUA_CAST "faction");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_unit_set_faction(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
faction *f = (faction *) tolua_tousertype(L, 2, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
faction *f = (faction *)tolua_tousertype(L, 2, 0);
|
||||
u_setfaction(self, f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_unit_get_race(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, u_race(self)->_name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_unit_set_race(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *rcname = tolua_tostring(L, 2, 0);
|
||||
const race *rc = rc_find(rcname);
|
||||
if (rc != NULL) {
|
||||
|
@ -858,7 +868,7 @@ static int tolua_unit_set_race(lua_State * L)
|
|||
|
||||
static int tolua_unit_destroy(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
if (self) {
|
||||
remove_unit(&self->region->units, self);
|
||||
}
|
||||
|
@ -867,8 +877,8 @@ static int tolua_unit_destroy(lua_State * L)
|
|||
|
||||
static int tolua_unit_create(lua_State * L)
|
||||
{
|
||||
faction *f = (faction *) tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *) tolua_tousertype(L, 2, 0);
|
||||
faction *f = (faction *)tolua_tousertype(L, 1, 0);
|
||||
region *r = (region *)tolua_tousertype(L, 2, 0);
|
||||
int num = (int)tolua_tonumber(L, 3, 1);
|
||||
if (f && r) {
|
||||
const race *rc = f->race;
|
||||
|
@ -886,14 +896,14 @@ static int tolua_unit_create(lua_State * L)
|
|||
|
||||
static int tolua_unit_tostring(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushstring(L, unitname(self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_event_gettype(lua_State * L)
|
||||
{
|
||||
event *self = (event *) tolua_tousertype(L, 1, 0);
|
||||
event *self = (event *)tolua_tousertype(L, 1, 0);
|
||||
int index = (int)tolua_tonumber(L, 2, 0);
|
||||
lua_pushstring(L, self->args[index].type);
|
||||
return 1;
|
||||
|
@ -909,11 +919,14 @@ static int tolua_event_get(lua_State * L)
|
|||
if (arg->type) {
|
||||
if (strcmp(arg->type, "string") == 0) {
|
||||
tolua_pushstring(L, (const char *)arg->data.v);
|
||||
} else if (strcmp(arg->type, "int") == 0) {
|
||||
}
|
||||
else if (strcmp(arg->type, "int") == 0) {
|
||||
lua_pushinteger(L, arg->data.i);
|
||||
} else if (strcmp(arg->type, "float") == 0) {
|
||||
lua_pushnumber(L, (lua_Number) arg->data.f);
|
||||
} else {
|
||||
}
|
||||
else if (strcmp(arg->type, "float") == 0) {
|
||||
lua_pushnumber(L, (lua_Number)arg->data.f);
|
||||
}
|
||||
else {
|
||||
/* this is pretty lazy */
|
||||
tolua_pushusertype(L, (void *)arg->data.v, TOLUA_CAST arg->type);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
|
104
src/bindings.c
104
src/bindings.c
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
@ -100,7 +100,7 @@ int log_lua_error(lua_State * L)
|
|||
|
||||
int tolua_orderlist_next(lua_State * L)
|
||||
{
|
||||
order **order_ptr = (order **) lua_touserdata(L, lua_upvalueindex(1));
|
||||
order **order_ptr = (order **)lua_touserdata(L, lua_upvalueindex(1));
|
||||
order *ord = *order_ptr;
|
||||
if (ord != NULL) {
|
||||
char cmd[8192];
|
||||
|
@ -114,7 +114,7 @@ int tolua_orderlist_next(lua_State * L)
|
|||
|
||||
static int tolua_quicklist_iter(lua_State * L)
|
||||
{
|
||||
quicklist **qlp = (quicklist **) lua_touserdata(L, lua_upvalueindex(1));
|
||||
quicklist **qlp = (quicklist **)lua_touserdata(L, lua_upvalueindex(1));
|
||||
quicklist *ql = *qlp;
|
||||
if (ql != NULL) {
|
||||
int index = lua_tointeger(L, lua_upvalueindex(2));
|
||||
|
@ -134,14 +134,15 @@ int tolua_quicklist_push(struct lua_State *L, const char *list_type,
|
|||
{
|
||||
if (list) {
|
||||
quicklist **qlist_ptr =
|
||||
(quicklist **) lua_newuserdata(L, sizeof(quicklist *));
|
||||
(quicklist **)lua_newuserdata(L, sizeof(quicklist *));
|
||||
*qlist_ptr = list;
|
||||
luaL_getmetatable(L, list_type);
|
||||
lua_setmetatable(L, -2);
|
||||
lua_pushnumber(L, 0);
|
||||
lua_pushstring(L, elem_type);
|
||||
lua_pushcclosure(L, tolua_quicklist_iter, 3); /* OBS: this closure has multiple upvalues (list, index, type_name) */
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
return 1;
|
||||
|
@ -149,7 +150,7 @@ int tolua_quicklist_push(struct lua_State *L, const char *list_type,
|
|||
|
||||
int tolua_itemlist_next(lua_State * L)
|
||||
{
|
||||
item **item_ptr = (item **) lua_touserdata(L, lua_upvalueindex(1));
|
||||
item **item_ptr = (item **)lua_touserdata(L, lua_upvalueindex(1));
|
||||
item *itm = *item_ptr;
|
||||
if (itm != NULL) {
|
||||
tolua_pushstring(L, itm->type->rtype->_name);
|
||||
|
@ -208,7 +209,8 @@ static int tolua_setkey(lua_State * L)
|
|||
attrib *a = find_key(global.attribs, flag);
|
||||
if (a == NULL && value) {
|
||||
add_key(&global.attribs, flag);
|
||||
} else if (a != NULL && !value) {
|
||||
}
|
||||
else if (a != NULL && !value) {
|
||||
a_remove(&global.attribs, a);
|
||||
}
|
||||
return 0;
|
||||
|
@ -216,7 +218,7 @@ static int tolua_setkey(lua_State * L)
|
|||
|
||||
static int tolua_rng_int(lua_State * L)
|
||||
{
|
||||
lua_pushnumber(L, (lua_Number) rng_int());
|
||||
lua_pushnumber(L, (lua_Number)rng_int());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -224,14 +226,14 @@ static int tolua_read_orders(lua_State * L)
|
|||
{
|
||||
const char *filename = tolua_tostring(L, 1, 0);
|
||||
int result = readorders(filename);
|
||||
lua_pushnumber(L, (lua_Number) result);
|
||||
lua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_message_unit(lua_State * L)
|
||||
{
|
||||
unit *sender = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *target = (unit *) tolua_tousertype(L, 2, 0);
|
||||
unit *sender = (unit *)tolua_tousertype(L, 1, 0);
|
||||
unit *target = (unit *)tolua_tousertype(L, 2, 0);
|
||||
const char *str = tolua_tostring(L, 3, 0);
|
||||
if (!target)
|
||||
tolua_error(L, TOLUA_CAST "target is nil", NULL);
|
||||
|
@ -243,8 +245,8 @@ static int tolua_message_unit(lua_State * L)
|
|||
|
||||
static int tolua_message_faction(lua_State * L)
|
||||
{
|
||||
unit *sender = (unit *) tolua_tousertype(L, 1, 0);
|
||||
faction *target = (faction *) tolua_tousertype(L, 2, 0);
|
||||
unit *sender = (unit *)tolua_tousertype(L, 1, 0);
|
||||
faction *target = (faction *)tolua_tousertype(L, 2, 0);
|
||||
const char *str = tolua_tostring(L, 3, 0);
|
||||
if (!target)
|
||||
tolua_error(L, TOLUA_CAST "target is nil", NULL);
|
||||
|
@ -256,7 +258,7 @@ static int tolua_message_faction(lua_State * L)
|
|||
|
||||
static int tolua_message_region(lua_State * L)
|
||||
{
|
||||
unit *sender = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *sender = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *str = tolua_tostring(L, 2, 0);
|
||||
if (!sender)
|
||||
tolua_error(L, TOLUA_CAST "sender is nil", NULL);
|
||||
|
@ -279,14 +281,14 @@ static int tolua_set_turn(lua_State * L)
|
|||
|
||||
static int tolua_get_turn(lua_State * L)
|
||||
{
|
||||
tolua_pushnumber(L, (lua_Number) turn);
|
||||
tolua_pushnumber(L, (lua_Number)turn);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_atoi36(lua_State * L)
|
||||
{
|
||||
const char *s = tolua_tostring(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) atoi36(s));
|
||||
tolua_pushnumber(L, (lua_Number)atoi36(s));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -317,7 +319,7 @@ static int tolua_addequipment(lua_State * L)
|
|||
result = 0;
|
||||
}
|
||||
}
|
||||
lua_pushnumber(L, (lua_Number) result);
|
||||
lua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -332,23 +334,26 @@ static int tolua_get_season(lua_State * L)
|
|||
|
||||
static int tolua_create_curse(lua_State * L)
|
||||
{
|
||||
unit *u = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *u = (unit *)tolua_tousertype(L, 1, 0);
|
||||
tolua_Error tolua_err;
|
||||
attrib **ap = NULL;
|
||||
if (tolua_isusertype(L, 2, TOLUA_CAST "unit", 0, &tolua_err)) {
|
||||
unit *target = (unit *) tolua_tousertype(L, 2, 0);
|
||||
unit *target = (unit *)tolua_tousertype(L, 2, 0);
|
||||
if (target)
|
||||
ap = &target->attribs;
|
||||
} else if (tolua_isusertype(L, 2, TOLUA_CAST "region", 0, &tolua_err)) {
|
||||
region *target = (region *) tolua_tousertype(L, 2, 0);
|
||||
}
|
||||
else if (tolua_isusertype(L, 2, TOLUA_CAST "region", 0, &tolua_err)) {
|
||||
region *target = (region *)tolua_tousertype(L, 2, 0);
|
||||
if (target)
|
||||
ap = &target->attribs;
|
||||
} else if (tolua_isusertype(L, 2, TOLUA_CAST "ship", 0, &tolua_err)) {
|
||||
ship *target = (ship *) tolua_tousertype(L, 2, 0);
|
||||
}
|
||||
else if (tolua_isusertype(L, 2, TOLUA_CAST "ship", 0, &tolua_err)) {
|
||||
ship *target = (ship *)tolua_tousertype(L, 2, 0);
|
||||
if (target)
|
||||
ap = &target->attribs;
|
||||
} else if (tolua_isusertype(L, 2, TOLUA_CAST "building", 0, &tolua_err)) {
|
||||
building *target = (building *) tolua_tousertype(L, 2, 0);
|
||||
}
|
||||
else if (tolua_isusertype(L, 2, TOLUA_CAST "building", 0, &tolua_err)) {
|
||||
building *target = (building *)tolua_tousertype(L, 2, 0);
|
||||
if (target)
|
||||
ap = &target->attribs;
|
||||
}
|
||||
|
@ -373,7 +378,7 @@ static int tolua_create_curse(lua_State * L)
|
|||
|
||||
static int tolua_learn_skill(lua_State * L)
|
||||
{
|
||||
unit *u = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *u = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *skname = tolua_tostring(L, 2, 0);
|
||||
float chances = (float)tolua_tonumber(L, 3, 0);
|
||||
skill_t sk = findskill(skname);
|
||||
|
@ -420,13 +425,13 @@ static int tolua_get_nmrs(lua_State * L)
|
|||
}
|
||||
result = nmrs[n];
|
||||
}
|
||||
tolua_pushnumber(L, (lua_Number) result);
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_equipunit(lua_State * L)
|
||||
{
|
||||
unit *u = (unit *) tolua_tousertype(L, 1, 0);
|
||||
unit *u = (unit *)tolua_tousertype(L, 1, 0);
|
||||
const char *eqname = tolua_tostring(L, 2, 0);
|
||||
equip_unit(u, get_equipment(eqname));
|
||||
return 0;
|
||||
|
@ -445,7 +450,7 @@ static int tolua_equipment_setitem(lua_State * L)
|
|||
result = 0;
|
||||
}
|
||||
}
|
||||
tolua_pushnumber(L, (lua_Number) result);
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -459,13 +464,13 @@ static int tolua_spawn_braineaters(lua_State * L)
|
|||
static int tolua_init_reports(lua_State * L)
|
||||
{
|
||||
int result = init_reports();
|
||||
tolua_pushnumber(L, (lua_Number) result);
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_write_report(lua_State * L)
|
||||
{
|
||||
faction *f = (faction *) tolua_tousertype(L, 1, 0);
|
||||
faction *f = (faction *)tolua_tousertype(L, 1, 0);
|
||||
if (f) {
|
||||
time_t ltime = time(0);
|
||||
int result = write_reports(f, ltime);
|
||||
|
@ -482,7 +487,7 @@ static int tolua_write_reports(lua_State * L)
|
|||
int result;
|
||||
init_reports();
|
||||
result = reports();
|
||||
tolua_pushnumber(L, (lua_Number) result);
|
||||
tolua_pushnumber(L, (lua_Number)result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -528,7 +533,7 @@ static int tolua_process_orders(lua_State * L)
|
|||
static int tolua_write_passwords(lua_State * L)
|
||||
{
|
||||
int result = writepasswd();
|
||||
lua_pushnumber(L, (lua_Number) result);
|
||||
lua_pushnumber(L, (lua_Number)result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -562,7 +567,7 @@ static int tolua_write_map(lua_State * L)
|
|||
static int tolua_read_turn(lua_State * L)
|
||||
{
|
||||
int cturn = current_turn();
|
||||
tolua_pushnumber(L, (lua_Number) cturn);
|
||||
tolua_pushnumber(L, (lua_Number)cturn);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -628,7 +633,7 @@ static int tolua_alliance_create(lua_State * L)
|
|||
|
||||
static int tolua_get_regions(lua_State * L)
|
||||
{
|
||||
region **region_ptr = (region **) lua_newuserdata(L, sizeof(region *));
|
||||
region **region_ptr = (region **)lua_newuserdata(L, sizeof(region *));
|
||||
luaL_getmetatable(L, "region");
|
||||
lua_setmetatable(L, -2);
|
||||
*region_ptr = regions;
|
||||
|
@ -638,7 +643,7 @@ static int tolua_get_regions(lua_State * L)
|
|||
|
||||
static int tolua_get_factions(lua_State * L)
|
||||
{
|
||||
faction **faction_ptr = (faction **) lua_newuserdata(L, sizeof(faction *));
|
||||
faction **faction_ptr = (faction **)lua_newuserdata(L, sizeof(faction *));
|
||||
luaL_getmetatable(L, "faction");
|
||||
lua_setmetatable(L, -2);
|
||||
*faction_ptr = factions;
|
||||
|
@ -648,27 +653,27 @@ static int tolua_get_factions(lua_State * L)
|
|||
|
||||
static int tolua_get_alliance_factions(lua_State * L)
|
||||
{
|
||||
alliance *self = (alliance *) tolua_tousertype(L, 1, 0);
|
||||
alliance *self = (alliance *)tolua_tousertype(L, 1, 0);
|
||||
return tolua_quicklist_push(L, "faction_list", "faction", self->members);
|
||||
}
|
||||
|
||||
static int tolua_get_alliance_id(lua_State * L)
|
||||
{
|
||||
alliance *self = (alliance *) tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number) self->id);
|
||||
alliance *self = (alliance *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushnumber(L, (lua_Number)self->id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_get_alliance_name(lua_State * L)
|
||||
{
|
||||
alliance *self = (alliance *) tolua_tousertype(L, 1, 0);
|
||||
alliance *self = (alliance *)tolua_tousertype(L, 1, 0);
|
||||
tolua_pushstring(L, self->name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_set_alliance_name(lua_State * L)
|
||||
{
|
||||
alliance *self = (alliance *) tolua_tousertype(L, 1, 0);
|
||||
alliance *self = (alliance *)tolua_tousertype(L, 1, 0);
|
||||
alliance_setname(self, tolua_tostring(L, 2, 0));
|
||||
return 0;
|
||||
}
|
||||
|
@ -753,7 +758,7 @@ static int config_get_ships(lua_State * L)
|
|||
int qi, i = 0;
|
||||
lua_createtable(L, ql_length(shiptypes), 0);
|
||||
for (qi = 0, ql = shiptypes; ql; ql_advance(&ql, &qi, 1)) {
|
||||
ship_type *stype = (ship_type *) ql_get(ql, qi);
|
||||
ship_type *stype = (ship_type *)ql_get(ql, qi);
|
||||
tolua_pushstring(L, TOLUA_CAST stype->_name);
|
||||
lua_rawseti(L, -2, ++i);
|
||||
}
|
||||
|
@ -766,7 +771,7 @@ static int config_get_buildings(lua_State * L)
|
|||
int qi, i = 0;
|
||||
lua_createtable(L, ql_length(buildingtypes), 0);
|
||||
for (qi = 0, ql = buildingtypes; ql; ql_advance(&ql, &qi, 1)) {
|
||||
building_type *btype = (building_type *) ql_get(ql, qi);
|
||||
building_type *btype = (building_type *)ql_get(ql, qi);
|
||||
tolua_pushstring(L, TOLUA_CAST btype->_name);
|
||||
lua_rawseti(L, -2, ++i);
|
||||
}
|
||||
|
@ -924,7 +929,7 @@ static int config_get_stype(lua_State * L)
|
|||
const terrain_type *coast = *stype->coasts;
|
||||
lua_pushstring(L, "coasts");
|
||||
lua_newtable(L);
|
||||
while(coast) {
|
||||
while (coast) {
|
||||
lua_pushstring(L, coast->_name);
|
||||
lua_pushinteger(L, 1);
|
||||
lua_settable(L, -3);
|
||||
|
@ -960,7 +965,7 @@ static int config_get_stype(lua_State * L)
|
|||
static int tolua_get_spell_text(lua_State * L)
|
||||
{
|
||||
const struct locale *loc = default_locale;
|
||||
spell *self = (spell *) tolua_tousertype(L, 1, 0);
|
||||
spell *self = (spell *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushstring(L, spell_info(self, loc));
|
||||
return 1;
|
||||
}
|
||||
|
@ -984,7 +989,7 @@ static int tolua_get_spell_level(lua_State * L)
|
|||
static int tolua_get_spell_name(lua_State * L)
|
||||
{
|
||||
const struct locale *lang = default_locale;
|
||||
spell *self = (spell *) tolua_tousertype(L, 1, 0);
|
||||
spell *self = (spell *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushstring(L, spell_name(self, lang));
|
||||
return 1;
|
||||
}
|
||||
|
@ -1026,8 +1031,8 @@ typedef struct event_args {
|
|||
static int tolua_report_unit(lua_State * L)
|
||||
{
|
||||
char buffer[512];
|
||||
unit *u = (unit *) tolua_tousertype(L, 1, 0);
|
||||
faction *f = (faction *) tolua_tousertype(L, 2, 0);
|
||||
unit *u = (unit *)tolua_tousertype(L, 1, 0);
|
||||
faction *f = (faction *)tolua_tousertype(L, 2, 0);
|
||||
bufunit(f, u, 0, see_unit, buffer, sizeof(buffer));
|
||||
tolua_pushstring(L, buffer);
|
||||
return 1;
|
||||
|
@ -1236,7 +1241,8 @@ int eressea_run(lua_State *L, const char *luafile)
|
|||
err = lua_pcall(L, 1, 1, -3);
|
||||
if (err != 0) {
|
||||
log_lua_error(L);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (lua_isnumber(L, -1)) {
|
||||
err = (int)lua_tonumber(L, -1);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
@ -35,7 +35,7 @@ typedef struct building_action {
|
|||
|
||||
static int lc_age(struct attrib *a)
|
||||
{
|
||||
building_action *data = (building_action *) a->data.v;
|
||||
building_action *data = (building_action *)a->data.v;
|
||||
const char *fname = data->fname;
|
||||
const char *fparam = data->param;
|
||||
building *b = data->b;
|
||||
|
@ -43,7 +43,7 @@ static int lc_age(struct attrib *a)
|
|||
|
||||
assert(b != NULL);
|
||||
if (fname != NULL) {
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
|
@ -56,11 +56,13 @@ static int lc_age(struct attrib *a)
|
|||
const char *error = lua_tostring(L, -1);
|
||||
log_error("lc_age(%s) calling '%s': %s.\n", buildingname(b), fname, error);
|
||||
lua_pop(L, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = (int)lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
log_error("lc_age(%s) calling '%s': not a function.\n", buildingname(b), fname);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ HCALLBACK create_callback(void(*cbv)(va_list va)) {
|
|||
}
|
||||
|
||||
void reset_callbacks(void) {
|
||||
while(registry) {
|
||||
while (registry) {
|
||||
struct reg *r = registry;
|
||||
registry = r->next;
|
||||
free(r->name);
|
||||
|
@ -38,8 +38,8 @@ HCALLBACK register_callback(const char *name, void(*cbv)(va_list va))
|
|||
int find_callback(const char *name, HCALLBACK *result) {
|
||||
if (result && name) {
|
||||
struct reg *r;
|
||||
for (r=registry;r;r=r->next) {
|
||||
if (strcmp(r->name, name)==0) {
|
||||
for (r = registry; r; r = r->next) {
|
||||
if (strcmp(r->name, name) == 0) {
|
||||
*result = r->cb;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <stdarg.h>
|
||||
|
||||
typedef struct {
|
||||
void (*cbv)(va_list va);
|
||||
void(*cbv)(va_list va);
|
||||
} HCALLBACK;
|
||||
|
||||
HCALLBACK register_callback(const char *name, void(*cbv)(va_list va));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 1998-2014, Enno Rehling <enno@eressea.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
|
|
|
@ -44,13 +44,14 @@
|
|||
#define lua_freeline(L,b) { (void)L; (void)b; }
|
||||
#endif
|
||||
|
||||
static int (*my_readline) (lua_State * l, char *, size_t, const char *prompt) =
|
||||
NULL;
|
||||
static int(*my_readline) (lua_State * l, char *, size_t, const char *prompt) =
|
||||
NULL;
|
||||
static int lua_readline(lua_State * l, char *b, const char *prompt)
|
||||
{
|
||||
if (my_readline) {
|
||||
return my_readline(l, b, LUA_MAXINPUT, prompt);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return default_readline(l, b, prompt);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+ Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| (c) 1998 - 2008 | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
|
@ -8,19 +8,17 @@
|
|||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
*/
|
||||
#ifndef H_GC_CREPORT
|
||||
#define H_GC_CREPORT
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
void creport_cleanup(void);
|
||||
void register_cr(void);
|
||||
|
||||
extern void creport_cleanup(void);
|
||||
extern void register_cr(void);
|
||||
|
||||
extern int crwritemap(const char *filename);
|
||||
int crwritemap(const char *filename);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -65,15 +65,15 @@ direction_t get_direction(const char *s, const struct locale *lang)
|
|||
|
||||
direction_t finddirection(const char *str) {
|
||||
int i;
|
||||
for (i=0;i!=MAXDIRECTIONS+2;++i) {
|
||||
if (directions[i] && strcmp(str, directions[i])==0) {
|
||||
for (i = 0; i != MAXDIRECTIONS + 2; ++i) {
|
||||
if (directions[i] && strcmp(str, directions[i]) == 0) {
|
||||
return (direction_t)i;
|
||||
}
|
||||
}
|
||||
return NODIRECTION;
|
||||
}
|
||||
|
||||
const char * directions[MAXDIRECTIONS+2] = {
|
||||
"northwest", "northeast", "east", "southeast", "southwest", "west", 0, "pause"
|
||||
const char * directions[MAXDIRECTIONS + 2] = {
|
||||
"northwest", "northeast", "east", "southeast", "southwest", "west", 0, "pause"
|
||||
};
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ extern "C"
|
|||
{
|
||||
#endif
|
||||
|
||||
struct locale;
|
||||
struct locale;
|
||||
|
||||
typedef enum {
|
||||
typedef enum {
|
||||
D_NORTHWEST,
|
||||
D_NORTHEAST,
|
||||
D_EAST,
|
||||
|
@ -19,15 +19,15 @@ typedef enum {
|
|||
D_PAUSE,
|
||||
D_SPECIAL,
|
||||
NODIRECTION = -1
|
||||
} direction_t;
|
||||
} direction_t;
|
||||
|
||||
direction_t get_direction(const char *s, const struct locale *);
|
||||
void init_directions(struct locale *lang);
|
||||
void init_direction(const struct locale *lang, direction_t dir, const char *str);
|
||||
direction_t get_direction(const char *s, const struct locale *);
|
||||
void init_directions(struct locale *lang);
|
||||
void init_direction(const struct locale *lang, direction_t dir, const char *str);
|
||||
|
||||
direction_t finddirection(const char *str);
|
||||
direction_t finddirection(const char *str);
|
||||
|
||||
extern const char * directions[];
|
||||
extern const char * directions[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
#endif
|
||||
|
|
|
@ -2923,7 +2923,7 @@ static void expandloot(region * r, request * lootorders)
|
|||
int m = region_get_morale(r);
|
||||
if (m) {
|
||||
/*Nur Moral -1, turns is not changed, so the first time nothing happens if the morale is good*/
|
||||
region_set_morale(r, m-1, -1);
|
||||
region_set_morale(r, m - 1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -22,22 +22,22 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Welchen Teil des Silbers die Bauern fuer Unterhaltung ausgeben (1/20), und
|
||||
/* Welchen Teil des Silbers die Bauern fuer Unterhaltung ausgeben (1/20), und
|
||||
* wiviel Silber ein Unterhalter pro Talentpunkt bekommt. */
|
||||
|
||||
/* Wieviele Silbermuenzen jeweils auf einmal "getaxed" werden. */
|
||||
/* Wieviele Silbermuenzen jeweils auf einmal "getaxed" werden. */
|
||||
|
||||
#define TAXFRACTION 10
|
||||
|
||||
/* Wieviel Silber pro Talentpunkt geklaut wird. */
|
||||
/* Wieviel Silber pro Talentpunkt geklaut wird. */
|
||||
|
||||
#define STEALINCOME 50
|
||||
|
||||
/* Teil der Bauern, welche Luxusgueter kaufen und verkaufen (1/100). */
|
||||
/* Teil der Bauern, welche Luxusgueter kaufen und verkaufen (1/100). */
|
||||
|
||||
#define TRADE_FRACTION 100
|
||||
|
||||
/* Wieviel Fremde eine Partei pro Woche aufnehmen kann */
|
||||
/* Wieviel Fremde eine Partei pro Woche aufnehmen kann */
|
||||
#define MAXNEWBIES 5
|
||||
|
||||
struct unit;
|
||||
|
@ -54,12 +54,12 @@ extern "C" {
|
|||
|
||||
enum { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL, IC_MAGIC, IC_LOOT };
|
||||
void maintain_buildings(struct region *r, bool crash);
|
||||
extern void add_spende(struct faction *f1, struct faction *f2, int betrag, struct region *r);
|
||||
extern int make_cmd(struct unit *u, struct order *ord);
|
||||
extern void split_allocations(struct region *r);
|
||||
extern int recruit_archetypes(void);
|
||||
extern int give_control_cmd(struct unit *u, struct order *ord);
|
||||
extern void give_control(struct unit * u, struct unit * u2);
|
||||
void add_spende(struct faction *f1, struct faction *f2, int betrag, struct region *r);
|
||||
int make_cmd(struct unit *u, struct order *ord);
|
||||
void split_allocations(struct region *r);
|
||||
int recruit_archetypes(void);
|
||||
int give_control_cmd(struct unit *u, struct order *ord);
|
||||
void give_control(struct unit * u, struct unit * u2);
|
||||
|
||||
struct message * check_steal(const struct unit * u, struct order *ord);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
|
|
125
src/gmtool.c
125
src/gmtool.c
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
* +-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
* | | Enno Rehling <enno@eressea.de>
|
||||
* | Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
|
@ -141,7 +141,8 @@ static window *win_create(WINDOW * hwin)
|
|||
wnd->next = wnd_first;
|
||||
wnd_first->prev = wnd;
|
||||
wnd_first = wnd;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
wnd_first = wnd;
|
||||
wnd_last = wnd;
|
||||
}
|
||||
|
@ -211,7 +212,8 @@ static chtype mr_tile(const map_region * mr, int highlight)
|
|||
case 'f':
|
||||
if (r->terrain->_name[1] == 'o') { /* fog */
|
||||
return '.' | COLOR_PAIR(hl + COLOR_YELLOW) | A_NORMAL;
|
||||
} else if (r->terrain->_name[1] == 'i') { /* firewall */
|
||||
}
|
||||
else if (r->terrain->_name[1] == 'i') { /* firewall */
|
||||
return '%' | COLOR_PAIR(hl + COLOR_RED) | A_BOLD;
|
||||
}
|
||||
break;
|
||||
|
@ -224,7 +226,8 @@ static chtype mr_tile(const map_region * mr, int highlight)
|
|||
if (r_isforest(r))
|
||||
return '#' | COLOR_PAIR(hl + COLOR_GREEN) | A_NORMAL;
|
||||
return '+' | COLOR_PAIR(hl + COLOR_GREEN) | A_BOLD;
|
||||
} else if (r->terrain->_name[1] == 'a') { /* packice */
|
||||
}
|
||||
else if (r->terrain->_name[1] == 'a') { /* packice */
|
||||
return ':' | COLOR_PAIR(hl + COLOR_WHITE) | A_BOLD;
|
||||
}
|
||||
break;
|
||||
|
@ -287,7 +290,7 @@ map_region *cursor_region(const view * v, const coordinate * c)
|
|||
|
||||
static void
|
||||
draw_cursor(WINDOW * win, selection * s, const view * v, const coordinate * c,
|
||||
int show)
|
||||
int show)
|
||||
{
|
||||
int lines = getmaxy(win) / THEIGHT;
|
||||
int xp, yp, nx, ny;
|
||||
|
@ -314,13 +317,15 @@ draw_cursor(WINDOW * win, selection * s, const view * v, const coordinate * c,
|
|||
if (mr->r->flags & RF_MAPPER_HIGHLIGHT)
|
||||
hl = 1;
|
||||
mvwaddch(win, yp, xp, mr_tile(mr, hl) | attr);
|
||||
} else
|
||||
}
|
||||
else
|
||||
mvwaddch(win, yp, xp, ' ' | attr | COLOR_PAIR(COLOR_YELLOW));
|
||||
if (show) {
|
||||
attr = A_BOLD;
|
||||
mvwaddch(win, yp, xp - 1, '<' | attr | COLOR_PAIR(COLOR_YELLOW));
|
||||
mvwaddch(win, yp, xp + 1, '>' | attr | COLOR_PAIR(COLOR_YELLOW));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
attr = A_NORMAL;
|
||||
mvwaddch(win, yp, xp - 1, ' ' | attr | COLOR_PAIR(COLOR_WHITE));
|
||||
mvwaddch(win, yp, xp + 1, ' ' | attr | COLOR_PAIR(COLOR_WHITE));
|
||||
|
@ -340,7 +345,8 @@ static void paint_status(window * wnd, const state * st)
|
|||
uid = mr->r->uid;
|
||||
if (mr->r->land) {
|
||||
name = (const char *)mr->r->land->name;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
name = mr->r->terrain->_name;
|
||||
}
|
||||
terrain = mr->r->terrain->_name;
|
||||
|
@ -370,7 +376,8 @@ static void paint_info_region(window * wnd, const state * st)
|
|||
const region *r = mr->r;
|
||||
if (r->land) {
|
||||
mvwaddnstr(win, line++, 1, (char *)r->land->name, size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mvwaddnstr(win, line++, 1, r->terrain->_name, size);
|
||||
}
|
||||
line++;
|
||||
|
@ -422,7 +429,7 @@ static void paint_info_region(window * wnd, const state * st)
|
|||
}
|
||||
}
|
||||
|
||||
static void (*paint_info) (struct window * wnd, const struct state * st);
|
||||
static void(*paint_info) (struct window * wnd, const struct state * st);
|
||||
|
||||
static void paint_info_default(window * wnd, const state * st)
|
||||
{
|
||||
|
@ -432,7 +439,7 @@ static void paint_info_default(window * wnd, const state * st)
|
|||
paint_info_region(wnd, st);
|
||||
}
|
||||
|
||||
void set_info_function(void (*callback) (struct window *, const struct state *))
|
||||
void set_info_function(void(*callback) (struct window *, const struct state *))
|
||||
{
|
||||
paint_info = callback;
|
||||
}
|
||||
|
@ -518,7 +525,7 @@ static faction *select_faction(state * st)
|
|||
|
||||
if (selected == NULL)
|
||||
return NULL;
|
||||
return (faction *) selected->data;
|
||||
return (faction *)selected->data;
|
||||
}
|
||||
|
||||
static const terrain_type *select_terrain(state * st,
|
||||
|
@ -610,13 +617,15 @@ static void select_regions(state * st, int selectmode)
|
|||
free(t);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
region *r;
|
||||
for (r = regions; r; r = r->next) {
|
||||
r->flags &= ~RF_MAPPER_HIGHLIGHT;
|
||||
}
|
||||
}
|
||||
} else if (findmode == 'm') {
|
||||
}
|
||||
else if (findmode == 'm') {
|
||||
region *r;
|
||||
sprintf(sbuffer, "%smonsters", status);
|
||||
statusline(st->wnd_status->handle, sbuffer);
|
||||
|
@ -630,12 +639,14 @@ static void select_regions(state * st, int selectmode)
|
|||
if (selectmode & MODE_SELECT) {
|
||||
select_coordinate(st->selected, r->x, r->y,
|
||||
selectmode == MODE_SELECT);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
highlight_region(r, selectmode == MODE_MARK);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (findmode == 'p') {
|
||||
}
|
||||
else if (findmode == 'p') {
|
||||
region *r;
|
||||
sprintf(sbuffer, "%splayers", status);
|
||||
statusline(st->wnd_status->handle, sbuffer);
|
||||
|
@ -649,12 +660,14 @@ static void select_regions(state * st, int selectmode)
|
|||
if (selectmode & MODE_SELECT) {
|
||||
select_coordinate(st->selected, r->x, r->y,
|
||||
selectmode == MODE_SELECT);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
highlight_region(r, selectmode == MODE_MARK);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (findmode == 'u') {
|
||||
}
|
||||
else if (findmode == 'u') {
|
||||
region *r;
|
||||
sprintf(sbuffer, "%sunits", status);
|
||||
statusline(st->wnd_status->handle, sbuffer);
|
||||
|
@ -663,12 +676,14 @@ static void select_regions(state * st, int selectmode)
|
|||
if (selectmode & MODE_SELECT) {
|
||||
select_coordinate(st->selected, r->x, r->y,
|
||||
selectmode == MODE_SELECT);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
highlight_region(r, selectmode == MODE_MARK);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (findmode == 's') {
|
||||
}
|
||||
else if (findmode == 's') {
|
||||
region *r;
|
||||
sprintf(sbuffer, "%sships", status);
|
||||
statusline(st->wnd_status->handle, sbuffer);
|
||||
|
@ -677,12 +692,14 @@ static void select_regions(state * st, int selectmode)
|
|||
if (selectmode & MODE_SELECT) {
|
||||
select_coordinate(st->selected, r->x, r->y,
|
||||
selectmode == MODE_SELECT);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
highlight_region(r, selectmode == MODE_MARK);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (findmode == 'f') {
|
||||
}
|
||||
else if (findmode == 'f') {
|
||||
char fbuffer[12];
|
||||
sprintf(sbuffer, "%sfaction:", status);
|
||||
askstring(st->wnd_status->handle, sbuffer, fbuffer, 12);
|
||||
|
@ -699,17 +716,20 @@ static void select_regions(state * st, int selectmode)
|
|||
if (selectmode & MODE_SELECT) {
|
||||
select_coordinate(st->selected, r->x, r->y,
|
||||
selectmode == MODE_SELECT);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
highlight_region(r, selectmode == MODE_MARK);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
statusline(st->wnd_status->handle, "faction not found.");
|
||||
beep();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (findmode == 't') {
|
||||
}
|
||||
else if (findmode == 't') {
|
||||
const struct terrain_type *terrain;
|
||||
sprintf(sbuffer, "%sterrain: ", status);
|
||||
statusline(st->wnd_status->handle, sbuffer);
|
||||
|
@ -723,13 +743,15 @@ static void select_regions(state * st, int selectmode)
|
|||
if (selectmode & MODE_SELECT) {
|
||||
select_coordinate(st->selected, r->x, r->y,
|
||||
selectmode == MODE_SELECT);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
highlight_region(r, selectmode == MODE_MARK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
statusline(st->wnd_status->handle, "unknown command.");
|
||||
beep();
|
||||
return;
|
||||
|
@ -860,10 +882,12 @@ static void handlekey(state * st, int c)
|
|||
}
|
||||
if (pl && pl->next) {
|
||||
cursor->pl = pl->next;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cursor->pl = get_homeplane();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cursor->pl = planes;
|
||||
}
|
||||
}
|
||||
|
@ -877,14 +901,17 @@ static void handlekey(state * st, int c)
|
|||
plane *pl = rplane(cur);
|
||||
if (pl == NULL) {
|
||||
cur = r_standard_to_astral(cur);
|
||||
} else if (is_astral(cur)) {
|
||||
}
|
||||
else if (is_astral(cur)) {
|
||||
cur = r_astral_to_standard(cur);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cur = NULL;
|
||||
}
|
||||
if (cur != NULL) {
|
||||
region2coord(cur, &st->cursor);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
beep();
|
||||
}
|
||||
}
|
||||
|
@ -1017,20 +1044,25 @@ static void handlekey(state * st, int c)
|
|||
if (findmode == 'r') {
|
||||
askstring(st->wnd_status->handle, "find-region:", locate,
|
||||
sizeof(locate));
|
||||
} else if (findmode == 'u') {
|
||||
}
|
||||
else if (findmode == 'u') {
|
||||
askstring(st->wnd_status->handle, "find-unit:", locate, sizeof(locate));
|
||||
} else if (findmode == 'f') {
|
||||
}
|
||||
else if (findmode == 'f') {
|
||||
askstring(st->wnd_status->handle, "find-faction:", locate,
|
||||
sizeof(locate));
|
||||
} else if (findmode == 'F') {
|
||||
}
|
||||
else if (findmode == 'F') {
|
||||
faction *f = select_faction(st);
|
||||
if (f != NULL) {
|
||||
strcpy(locate, itoa36(f->no));
|
||||
findmode = 'f';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
statusline(st->wnd_status->handle, "unknown command.");
|
||||
beep();
|
||||
break;
|
||||
|
@ -1042,7 +1074,8 @@ static void handlekey(state * st, int c)
|
|||
if (findmode == 'u') {
|
||||
unit *u = findunit(atoi36(locate));
|
||||
r = u ? u->region : NULL;
|
||||
} else if (findmode && regions != NULL) {
|
||||
}
|
||||
else if (findmode && regions != NULL) {
|
||||
struct faction *f = NULL;
|
||||
map_region *mr = cursor_region(&st->display, cursor);
|
||||
region *first = (mr && mr->r && mr->r->next) ? mr->r->next : regions;
|
||||
|
@ -1061,7 +1094,8 @@ static void handlekey(state * st, int c)
|
|||
if (findmode == 'r' && r->land && r->land->name
|
||||
&& strstr((const char *)r->land->name, locate)) {
|
||||
break;
|
||||
} else if (findmode == 'f') {
|
||||
}
|
||||
else if (findmode == 'f') {
|
||||
unit *u;
|
||||
for (u = r->units; u; u = u->next) {
|
||||
if (u->faction == f) {
|
||||
|
@ -1081,7 +1115,8 @@ static void handlekey(state * st, int c)
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
r = NULL;
|
||||
}
|
||||
if (r != NULL) {
|
||||
|
@ -1105,7 +1140,7 @@ static void handlekey(state * st, int c)
|
|||
strcpy(kbuffer, "getch:");
|
||||
}
|
||||
sprintf(sbuffer, " 0x%x", c);
|
||||
strncat(kbuffer, sbuffer, sizeof(kbuffer)-1);
|
||||
strncat(kbuffer, sbuffer, sizeof(kbuffer) - 1);
|
||||
statusline(st->wnd_status->handle, kbuffer);
|
||||
if (strlen(kbuffer) > 70)
|
||||
kbuffer[0] = 0;
|
||||
|
@ -1223,7 +1258,8 @@ void run_mapper(void)
|
|||
if (p.y < tl.y) {
|
||||
vi->topleft.y = st->cursor.y - vi->size.height / 2;
|
||||
st->wnd_map->update |= 1;
|
||||
} else if (p.y >= tl.y + vi->size.height * THEIGHT) {
|
||||
}
|
||||
else if (p.y >= tl.y + vi->size.height * THEIGHT) {
|
||||
vi->topleft.y = st->cursor.y - vi->size.height / 2;
|
||||
st->wnd_map->update |= 1;
|
||||
}
|
||||
|
@ -1231,7 +1267,8 @@ void run_mapper(void)
|
|||
vi->topleft.x =
|
||||
st->cursor.x + (st->cursor.y - vi->topleft.y) / 2 - vi->size.width / 2;
|
||||
st->wnd_map->update |= 1;
|
||||
} else if (p.x >= tl.x + vi->size.width * TWIDTH - 1) {
|
||||
}
|
||||
else if (p.x >= tl.x + vi->size.width * TWIDTH - 1) {
|
||||
vi->topleft.x =
|
||||
st->cursor.x + (st->cursor.y - vi->topleft.y) / 2 - vi->size.width / 2;
|
||||
st->wnd_map->update |= 1;
|
||||
|
@ -1269,7 +1306,7 @@ void run_mapper(void)
|
|||
|
||||
int
|
||||
curses_readline(struct lua_State *L, char *buffer, size_t size,
|
||||
const char *prompt)
|
||||
const char *prompt)
|
||||
{
|
||||
unused_arg(L);
|
||||
askstring(hstatus, prompt, buffer, size);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
* +-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
* | | Enno Rehling <enno@eressea.de>
|
||||
* | Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
* +-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
* | | Enno Rehling <enno@eressea.de>
|
||||
* | Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
|
|
154
src/helpers.c
154
src/helpers.c
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
@ -44,7 +44,7 @@ without prior permission by the authors of Eressea.
|
|||
static int
|
||||
lua_giveitem(unit * s, unit * d, const item_type * itype, int n, struct order *ord)
|
||||
{
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
char fname[64];
|
||||
int result = -1;
|
||||
const char *iname = itype->rtype->_name;
|
||||
|
@ -58,17 +58,19 @@ lua_giveitem(unit * s, unit * d, const item_type * itype, int n, struct order *o
|
|||
tolua_pushusertype(L, s, TOLUA_CAST "unit");
|
||||
tolua_pushusertype(L, d, TOLUA_CAST "unit");
|
||||
tolua_pushstring(L, iname);
|
||||
tolua_pushnumber(L, (lua_Number) n);
|
||||
tolua_pushnumber(L, (lua_Number)n);
|
||||
|
||||
if (lua_pcall(L, 4, 1, 0) != 0) {
|
||||
const char *error = lua_tostring(L, -1);
|
||||
log_error("unit %s calling '%s': %s.\n", unitname(s), fname, error);
|
||||
lua_pop(L, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = (int)lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
log_error("unit %s trying to call '%s' : not a function.\n", unitname(s), fname);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
@ -80,7 +82,7 @@ static int limit_resource(const region * r, const resource_type * rtype)
|
|||
{
|
||||
char fname[64];
|
||||
int result = -1;
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
|
||||
strlcpy(fname, rtype->_name, sizeof(fname));
|
||||
strlcat(fname, "_limit", sizeof(fname));
|
||||
|
@ -93,11 +95,13 @@ static int limit_resource(const region * r, const resource_type * rtype)
|
|||
const char *error = lua_tostring(L, -1);
|
||||
log_error("limit(%s) calling '%s': %s.\n", regionname(r, NULL), fname, error);
|
||||
lua_pop(L, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = (int)lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
log_error("limit(%s) calling '%s': not a function.\n", regionname(r, NULL), fname);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
@ -108,7 +112,7 @@ static int limit_resource(const region * r, const resource_type * rtype)
|
|||
static void
|
||||
produce_resource(region * r, const resource_type * rtype, int norders)
|
||||
{
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
char fname[64];
|
||||
|
||||
strlcpy(fname, rtype->_name, sizeof(fname));
|
||||
|
@ -117,14 +121,15 @@ produce_resource(region * r, const resource_type * rtype, int norders)
|
|||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, (void *)r, TOLUA_CAST "region");
|
||||
tolua_pushnumber(L, (lua_Number) norders);
|
||||
tolua_pushnumber(L, (lua_Number)norders);
|
||||
|
||||
if (lua_pcall(L, 2, 0, 0) != 0) {
|
||||
const char *error = lua_tostring(L, -1);
|
||||
log_error("produce(%s) calling '%s': %s.\n", regionname(r, NULL), fname, error);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
log_error("produce(%s) calling '%s': not a function.\n", regionname(r, NULL), fname);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
@ -151,7 +156,7 @@ static void push_param(lua_State * L, char c, spllprm * param)
|
|||
/** callback to use lua for spell functions */
|
||||
static int lua_callspell(castorder * co)
|
||||
{
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
const char *fname = co->sp->sname;
|
||||
unit *caster = co_get_caster(co);
|
||||
region * r = co_get_region(co);
|
||||
|
@ -172,8 +177,8 @@ static int lua_callspell(castorder * co)
|
|||
int nparam = 4;
|
||||
tolua_pushusertype(L, r, TOLUA_CAST "region");
|
||||
tolua_pushusertype(L, caster, TOLUA_CAST "unit");
|
||||
tolua_pushnumber(L, (lua_Number) co->level);
|
||||
tolua_pushnumber(L, (lua_Number) co->force);
|
||||
tolua_pushnumber(L, (lua_Number)co->level);
|
||||
tolua_pushnumber(L, (lua_Number)co->force);
|
||||
if (co->sp->parameter && co->par->length) {
|
||||
const char *synp = co->sp->parameter;
|
||||
int i = 0;
|
||||
|
@ -184,7 +189,8 @@ static int lua_callspell(castorder * co)
|
|||
char c = *synp;
|
||||
if (c == '+') {
|
||||
push_param(L, *(synp - 1), param);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
push_param(L, c, param);
|
||||
++synp;
|
||||
}
|
||||
|
@ -196,11 +202,13 @@ static int lua_callspell(castorder * co)
|
|||
const char *error = lua_tostring(L, -1);
|
||||
log_error("spell(%s) calling '%s': %s.\n", unitname(caster), fname, error);
|
||||
lua_pop(L, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = (int)lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
int ltype = lua_type(L, -1);
|
||||
log_error("spell(%s) calling '%s': not a function, has type %d.\n", unitname(caster), fname, ltype);
|
||||
lua_pop(L, 1);
|
||||
|
@ -212,7 +220,7 @@ static int lua_callspell(castorder * co)
|
|||
/** callback to initialize a familiar from lua. */
|
||||
static int lua_initfamiliar(unit * u)
|
||||
{
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
char fname[64];
|
||||
int result = -1;
|
||||
|
||||
|
@ -227,11 +235,13 @@ static int lua_initfamiliar(unit * u)
|
|||
const char *error = lua_tostring(L, -1);
|
||||
log_error("familiar(%s) calling '%s': %s.\n", unitname(u), fname, error);
|
||||
lua_pop(L, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = (int)lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
log_warning("familiar(%s) calling '%s': not a function.\n", unitname(u), fname);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
@ -247,7 +257,7 @@ static int lua_initfamiliar(unit * u)
|
|||
static int
|
||||
lua_changeresource(unit * u, const struct resource_type *rtype, int delta)
|
||||
{
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
int result = -1;
|
||||
char fname[64];
|
||||
|
||||
|
@ -257,17 +267,19 @@ lua_changeresource(unit * u, const struct resource_type *rtype, int delta)
|
|||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, u, TOLUA_CAST "unit");
|
||||
tolua_pushnumber(L, (lua_Number) delta);
|
||||
tolua_pushnumber(L, (lua_Number)delta);
|
||||
|
||||
if (lua_pcall(L, 2, 1, 0) != 0) {
|
||||
const char *error = lua_tostring(L, -1);
|
||||
log_error("change(%s) calling '%s': %s.\n", unitname(u), fname, error);
|
||||
lua_pop(L, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = (int)lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
log_error("change(%s) calling '%s': not a function.\n", unitname(u), fname);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
@ -277,7 +289,7 @@ lua_changeresource(unit * u, const struct resource_type *rtype, int delta)
|
|||
|
||||
static int lua_getresource(unit * u, const struct resource_type *rtype)
|
||||
{
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
int result = -1;
|
||||
char fname[64];
|
||||
|
||||
|
@ -292,11 +304,13 @@ static int lua_getresource(unit * u, const struct resource_type *rtype)
|
|||
const char *error = lua_tostring(L, -1);
|
||||
log_error("get(%s) calling '%s': %s.\n", unitname(u), fname, error);
|
||||
lua_pop(L, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = (int)lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
log_error("get(%s) calling '%s': not a function.\n", unitname(u), fname);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
@ -310,7 +324,7 @@ static bool lua_canuse_item(const unit * u, const struct item_type *itype)
|
|||
bool result = true;
|
||||
|
||||
if (function_exists) {
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
const char *fname = "item_canuse";
|
||||
|
||||
lua_getglobal(L, fname);
|
||||
|
@ -322,11 +336,13 @@ static bool lua_canuse_item(const unit * u, const struct item_type *itype)
|
|||
const char *error = lua_tostring(L, -1);
|
||||
log_error("get(%s) calling '%s': %s.\n", unitname(u), fname, error);
|
||||
lua_pop(L, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = lua_toboolean(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
function_exists = 0;
|
||||
log_error("get(%s) calling '%s': not a function.\n", unitname(u), fname);
|
||||
lua_pop(L, 1);
|
||||
|
@ -338,7 +354,7 @@ static bool lua_canuse_item(const unit * u, const struct item_type *itype)
|
|||
static int
|
||||
lua_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
||||
{
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
const char *fname = "wage";
|
||||
int result = -1;
|
||||
|
||||
|
@ -347,17 +363,19 @@ lua_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
|||
tolua_pushusertype(L, (void *)r, TOLUA_CAST "region");
|
||||
tolua_pushusertype(L, (void *)f, TOLUA_CAST "faction");
|
||||
tolua_pushstring(L, rc ? rc->_name : 0);
|
||||
tolua_pushnumber(L, (lua_Number) in_turn);
|
||||
tolua_pushnumber(L, (lua_Number)in_turn);
|
||||
|
||||
if (lua_pcall(L, 3, 1, 0) != 0) {
|
||||
const char *error = lua_tostring(L, -1);
|
||||
log_error("wage(%s) calling '%s': %s.\n", regionname(r, NULL), fname, error);
|
||||
lua_pop(L, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = (int)lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
log_error("wage(%s) calling '%s': not a function.\n", regionname(r, NULL), fname);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
@ -367,7 +385,7 @@ lua_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
|||
|
||||
static void lua_agebuilding(building * b)
|
||||
{
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
char fname[64];
|
||||
|
||||
strlcpy(fname, "age_", sizeof(fname));
|
||||
|
@ -382,7 +400,8 @@ static void lua_agebuilding(building * b)
|
|||
log_error("agebuilding(%s) calling '%s': %s.\n", buildingname(b), fname, error);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
log_error("agebuilding(%s) calling '%s': not a function.\n", buildingname(b), fname);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
@ -390,7 +409,7 @@ static void lua_agebuilding(building * b)
|
|||
|
||||
static double lua_building_taxes(building * b, int level)
|
||||
{
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
const char *fname = "building_taxes";
|
||||
double result = 0.0F;
|
||||
|
||||
|
@ -403,11 +422,13 @@ static double lua_building_taxes(building * b, int level)
|
|||
const char *error = lua_tostring(L, -1);
|
||||
log_error("building_taxes(%s) calling '%s': %s.\n", buildingname(b), fname, error);
|
||||
lua_pop(L, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = (double)lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
log_error("building_taxes(%s) calling '%s': not a function.\n", buildingname(b), fname);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
@ -416,7 +437,7 @@ static double lua_building_taxes(building * b, int level)
|
|||
|
||||
static int lua_maintenance(const unit * u)
|
||||
{
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
const char *fname = "maintenance";
|
||||
int result = -1;
|
||||
|
||||
|
@ -428,11 +449,13 @@ static int lua_maintenance(const unit * u)
|
|||
const char *error = lua_tostring(L, -1);
|
||||
log_error("maintenance(%s) calling '%s': %s.\n", unitname(u), fname, error);
|
||||
lua_pop(L, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = (int)lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
log_error("maintenance(%s) calling '%s': not a function.\n", unitname(u), fname);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
@ -442,7 +465,7 @@ static int lua_maintenance(const unit * u)
|
|||
|
||||
static int lua_equipmentcallback(const struct equipment *eq, unit * u)
|
||||
{
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
char fname[64];
|
||||
int result = -1;
|
||||
|
||||
|
@ -457,11 +480,13 @@ static int lua_equipmentcallback(const struct equipment *eq, unit * u)
|
|||
const char *error = lua_tostring(L, -1);
|
||||
log_error("equip(%s) calling '%s': %s.\n", unitname(u), fname, error);
|
||||
lua_pop(L, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = (int)lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
log_error("equip(%s) calling '%s': not a function.\n", unitname(u), fname);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
@ -471,9 +496,9 @@ static int lua_equipmentcallback(const struct equipment *eq, unit * u)
|
|||
/** callback for an item-use function written in lua. */
|
||||
int
|
||||
lua_useitem(struct unit *u, const struct item_type *itype, int amount,
|
||||
struct order *ord)
|
||||
struct order *ord)
|
||||
{
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
lua_State *L = (lua_State *)global.vm_state;
|
||||
int result = 0;
|
||||
char fname[64];
|
||||
|
||||
|
@ -483,17 +508,19 @@ lua_useitem(struct unit *u, const struct item_type *itype, int amount,
|
|||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
|
||||
tolua_pushnumber(L, (lua_Number) amount);
|
||||
tolua_pushnumber(L, (lua_Number)amount);
|
||||
|
||||
if (lua_pcall(L, 2, 1, 0) != 0) {
|
||||
const char *error = lua_tostring(L, -1);
|
||||
log_error("use(%s) calling '%s': %s.\n", unitname(u), fname, error);
|
||||
lua_pop(L, 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = (int)lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
log_error("use(%s) calling '%s': not a function.\n", unitname(u), fname);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
@ -507,7 +534,8 @@ int tolua_toid(lua_State * L, int idx, int def)
|
|||
int type = lua_type(L, idx);
|
||||
if (type == LUA_TNUMBER) {
|
||||
no = (int)tolua_tonumber(L, idx, def);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
const char *str = tolua_tostring(L, idx, NULL);
|
||||
no = str ? atoi36(str) : def;
|
||||
}
|
||||
|
@ -519,30 +547,30 @@ void register_tolua_helpers(void)
|
|||
at_register(&at_direction);
|
||||
at_register(&at_building_action);
|
||||
|
||||
register_function((pf_generic) & lua_building_taxes,
|
||||
register_function((pf_generic)& lua_building_taxes,
|
||||
TOLUA_CAST "lua_building_taxes");
|
||||
register_function((pf_generic) & lua_agebuilding,
|
||||
register_function((pf_generic)& lua_agebuilding,
|
||||
TOLUA_CAST "lua_agebuilding");
|
||||
register_function((pf_generic) & lua_callspell, TOLUA_CAST "lua_castspell");
|
||||
register_function((pf_generic) & lua_initfamiliar,
|
||||
register_function((pf_generic)& lua_callspell, TOLUA_CAST "lua_castspell");
|
||||
register_function((pf_generic)& lua_initfamiliar,
|
||||
TOLUA_CAST "lua_initfamiliar");
|
||||
register_item_use(&lua_useitem, TOLUA_CAST "lua_useitem");
|
||||
register_function((pf_generic) & lua_getresource,
|
||||
register_function((pf_generic)& lua_getresource,
|
||||
TOLUA_CAST "lua_getresource");
|
||||
register_function((pf_generic) & lua_canuse_item,
|
||||
register_function((pf_generic)& lua_canuse_item,
|
||||
TOLUA_CAST "lua_canuse_item");
|
||||
register_function((pf_generic) & lua_changeresource,
|
||||
register_function((pf_generic)& lua_changeresource,
|
||||
TOLUA_CAST "lua_changeresource");
|
||||
register_function((pf_generic) & lua_equipmentcallback,
|
||||
register_function((pf_generic)& lua_equipmentcallback,
|
||||
TOLUA_CAST "lua_equip");
|
||||
|
||||
register_function((pf_generic) & lua_wage, TOLUA_CAST "lua_wage");
|
||||
register_function((pf_generic) & lua_maintenance,
|
||||
register_function((pf_generic)& lua_wage, TOLUA_CAST "lua_wage");
|
||||
register_function((pf_generic)& lua_maintenance,
|
||||
TOLUA_CAST "lua_maintenance");
|
||||
|
||||
register_function((pf_generic) produce_resource,
|
||||
register_function((pf_generic)produce_resource,
|
||||
TOLUA_CAST "lua_produceresource");
|
||||
register_function((pf_generic) limit_resource,
|
||||
register_function((pf_generic)limit_resource,
|
||||
TOLUA_CAST "lua_limitresource");
|
||||
register_item_give(lua_giveitem, TOLUA_CAST "lua_giveitem");
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
|
|
@ -48,7 +48,7 @@ struct order *ord)
|
|||
if (sv && sv->level > 2) {
|
||||
/* TODO: message */
|
||||
}
|
||||
else if (sk!=NOSKILL && study_cost(u, sk) > 0) {
|
||||
else if (sk != NOSKILL && study_cost(u, sk) > 0) {
|
||||
/* TODO: message */
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -60,7 +60,7 @@ static attrib_type at_peaceimmune = {
|
|||
|
||||
static int
|
||||
use_hornofdancing(struct unit *u, const struct item_type *itype,
|
||||
int amount, struct order *ord)
|
||||
int amount, struct order *ord)
|
||||
{
|
||||
region *r;
|
||||
int regionsPacified = 0;
|
||||
|
@ -80,7 +80,8 @@ use_hornofdancing(struct unit *u, const struct item_type *itype,
|
|||
"unit region", u, u->region));
|
||||
|
||||
regionsPacified++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ADDMSG(&r->msgs, msg_message("hornofpeace_r_nosuccess",
|
||||
"unit region", u, u->region));
|
||||
}
|
||||
|
@ -90,7 +91,8 @@ use_hornofdancing(struct unit *u, const struct item_type *itype,
|
|||
if (regionsPacified > 0) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "hornofpeace_u_success",
|
||||
"pacified", regionsPacified));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "hornofpeace_u_nosuccess",
|
||||
""));
|
||||
}
|
||||
|
@ -102,7 +104,7 @@ use_hornofdancing(struct unit *u, const struct item_type *itype,
|
|||
|
||||
static int
|
||||
useonother_trappedairelemental(struct unit *u, int shipId,
|
||||
const struct item_type *itype, int amount, struct order *ord)
|
||||
const struct item_type *itype, int amount, struct order *ord)
|
||||
{
|
||||
curse *c;
|
||||
ship *sh;
|
||||
|
@ -133,7 +135,7 @@ useonother_trappedairelemental(struct unit *u, int shipId,
|
|||
|
||||
static int
|
||||
use_trappedairelemental(struct unit *u,
|
||||
const struct item_type *itype, int amount, struct order *ord)
|
||||
const struct item_type *itype, int amount, struct order *ord)
|
||||
{
|
||||
ship *sh = u->ship;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -36,7 +36,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
static int
|
||||
summon_igjarjuk(struct unit *u, const struct item_type *itype, int amount,
|
||||
struct order *ord)
|
||||
struct order *ord)
|
||||
{
|
||||
struct plane *p = rplane(u->region);
|
||||
unused_arg(amount);
|
||||
|
@ -44,7 +44,8 @@ summon_igjarjuk(struct unit *u, const struct item_type *itype, int amount,
|
|||
if (p != NULL) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "use_realworld_only", ""));
|
||||
return EUNUSABLE;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
assert(!"not implemented");
|
||||
return EUNUSABLE;
|
||||
}
|
||||
|
@ -52,7 +53,7 @@ summon_igjarjuk(struct unit *u, const struct item_type *itype, int amount,
|
|||
|
||||
static int
|
||||
give_igjarjuk(struct unit *src, struct unit *d, const struct item_type *itype,
|
||||
int n, struct order *ord)
|
||||
int n, struct order *ord)
|
||||
{
|
||||
ADDMSG(&src->faction->msgs, msg_feedback(src, ord, "error_giveeye", ""));
|
||||
return 0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -22,7 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void register_demonseye(void);
|
||||
void register_demonseye(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
|
@ -8,7 +8,7 @@
|
|||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
*/
|
||||
|
||||
#include <platform.h>
|
||||
#include <kernel/config.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
|
@ -8,7 +8,7 @@
|
|||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifndef H_ITM_ITEMS
|
||||
#define H_ITM_ITEMS
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -40,7 +40,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
static int
|
||||
use_phoenixcompass(struct unit *u, const struct item_type *itype,
|
||||
int amount, struct order *ord)
|
||||
int amount, struct order *ord)
|
||||
{
|
||||
region *r;
|
||||
unit *closest_phoenix = NULL;
|
||||
|
@ -66,13 +66,15 @@ use_phoenixcompass(struct unit *u, const struct item_type *itype,
|
|||
closest_phoenix = u2;
|
||||
closest_phoenix_distance =
|
||||
distance(u->region, closest_phoenix->region);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
int dist = distance(u->region, r);
|
||||
if (dist < closest_phoenix_distance) {
|
||||
closest_phoenix = u2;
|
||||
closest_phoenix_distance = dist;
|
||||
confusion = false;
|
||||
} else if (dist == closest_phoenix_distance) {
|
||||
}
|
||||
else if (dist == closest_phoenix_distance) {
|
||||
confusion = true;
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +106,8 @@ use_phoenixcompass(struct unit *u, const struct item_type *itype,
|
|||
if (dist < closest_neighbour_distance) {
|
||||
closest_neighbour_direction = direction;
|
||||
closest_neighbour_distance = dist;
|
||||
} else if (dist == closest_neighbour_distance && rng_int() % 100 < 50) {
|
||||
}
|
||||
else if (dist == closest_neighbour_distance && rng_int() % 100 < 50) {
|
||||
/* there can never be more than two neighbours with the same
|
||||
* distance (except when you are standing in the same region
|
||||
* as the phoenix, but that case has already been handled).
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
/*
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
**/
|
||||
|
||||
#include <platform.h>
|
||||
#include <kernel/config.h>
|
||||
|
@ -51,7 +57,7 @@ void init_seed(void)
|
|||
rtype = rt_find("seed");
|
||||
if (rtype != NULL) {
|
||||
a = a_add(&rtype->attribs, a_new(&at_resourcelimit));
|
||||
rdata = (resource_limit *) a->data.v;
|
||||
rdata = (resource_limit *)a->data.v;
|
||||
rdata->limit = limit_seeds;
|
||||
rdata->produce = produce_seeds;
|
||||
}
|
||||
|
@ -86,7 +92,7 @@ void init_mallornseed(void)
|
|||
rtype->flags |= RTF_POOLED;
|
||||
|
||||
a = a_add(&rtype->attribs, a_new(&at_resourcelimit));
|
||||
rdata = (resource_limit *) a->data.v;
|
||||
rdata = (resource_limit *)a->data.v;
|
||||
rdata->limit = limit_mallornseeds;
|
||||
rdata->produce = produce_mallornseeds;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -40,14 +40,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
static int
|
||||
use_speedsail(struct unit *u, const struct item_type *itype, int amount,
|
||||
struct order *ord)
|
||||
struct order *ord)
|
||||
{
|
||||
struct plane *p = rplane(u->region);
|
||||
unused_arg(amount);
|
||||
unused_arg(itype);
|
||||
if (p != NULL) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "use_realworld_only", ""));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (u->ship) {
|
||||
attrib *a = a_find(u->ship->attribs, &at_speedup);
|
||||
if (a == NULL) {
|
||||
|
@ -58,10 +59,12 @@ use_speedsail(struct unit *u, const struct item_type *itype, int amount,
|
|||
/* Ticket abziehen */
|
||||
i_change(&u->items, itype, -1);
|
||||
return 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cmistake(u, ord, 211, MSG_EVENT);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cmistake(u, ord, 144, MSG_EVENT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
Copyright (c) 1998-2015, Enno Rehling Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -40,7 +40,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
static bool
|
||||
attack_firesword(const troop * at, const struct weapon_type *wtype,
|
||||
int *casualties)
|
||||
int *casualties)
|
||||
{
|
||||
fighter *fi = at->fighter;
|
||||
troop dt;
|
||||
|
@ -86,7 +86,7 @@ attack_firesword(const troop * at, const struct weapon_type *wtype,
|
|||
|
||||
static bool
|
||||
attack_catapult(const troop * at, const struct weapon_type *wtype,
|
||||
int *casualties)
|
||||
int *casualties)
|
||||
{
|
||||
fighter *af = at->fighter;
|
||||
unit *au = af->unit;
|
||||
|
@ -100,7 +100,7 @@ attack_catapult(const troop * at, const struct weapon_type *wtype,
|
|||
assert(af->person[at->index].reload == 0);
|
||||
|
||||
if (rtype) {
|
||||
if (get_pooled(au, rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, 1) <= 0) {
|
||||
if (get_pooled(au, rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, 1) <= 0) {
|
||||
/* No ammo. Use other weapon if available. */
|
||||
return true;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ attack_catapult(const troop * at, const struct weapon_type *wtype,
|
|||
}
|
||||
|
||||
if (rtype) {
|
||||
use_pooled(au, rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, 1);
|
||||
use_pooled(au, rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, 1);
|
||||
}
|
||||
|
||||
while (--enemies >= 0) {
|
||||
|
@ -144,7 +144,8 @@ attack_catapult(const troop * at, const struct weapon_type *wtype,
|
|||
float dmg =
|
||||
get_param_flt(global.parameters, "rules.building.damage.catapult", 1);
|
||||
damage_building(b, dt.fighter->unit->building, dmg);
|
||||
} else if (dt.fighter->unit->ship && rng_int() % 100 < 5) {
|
||||
}
|
||||
else if (dt.fighter->unit->ship && rng_int() % 100 < 5) {
|
||||
float dmg =
|
||||
get_param_flt(global.parameters, "rules.ship.damage.catapult", 0.01);
|
||||
damage_ship(dt.fighter->unit->ship, dmg)
|
||||
|
@ -161,6 +162,6 @@ attack_catapult(const troop * at, const struct weapon_type *wtype,
|
|||
|
||||
void register_weapons(void)
|
||||
{
|
||||
register_function((pf_generic) attack_catapult, "attack_catapult");
|
||||
register_function((pf_generic) attack_firesword, "attack_firesword");
|
||||
register_function((pf_generic)attack_catapult, "attack_catapult");
|
||||
register_function((pf_generic)attack_firesword, "attack_firesword");
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* vi: set ts=2:
|
||||
/*
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue