forked from github/server
"ID zu groß" - fixed parameters for some lua functions (pointers/objects) Issue: 1457
This commit is contained in:
parent
cf789999cf
commit
67c4b861f1
|
@ -75,11 +75,11 @@ lc_age(struct attrib * a)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
building_addaction(building& b, const char * fname, const char * param)
|
building_addaction(building * b, const char * fname, const char * param)
|
||||||
{
|
{
|
||||||
attrib * a = a_add(&b.attribs, a_new(&at_building_action));
|
attrib * a = a_add(&b->attribs, a_new(&at_building_action));
|
||||||
building_action * data = (building_action*)a->data.v;
|
building_action * data = (building_action*)a->data.v;
|
||||||
data->b = &b;
|
data->b = b;
|
||||||
data->fname = strdup(fname);
|
data->fname = strdup(fname);
|
||||||
if (param) data->param = strdup(param);
|
if (param) data->param = strdup(param);
|
||||||
|
|
||||||
|
@ -87,41 +87,41 @@ building_addaction(building& b, const char * fname, const char * param)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
building_getinfo(const building& b)
|
building_getinfo(const building * b)
|
||||||
{
|
{
|
||||||
return (const char*)b.display;
|
return (const char*)b->display;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
building_setinfo(building& b, const char * info)
|
building_setinfo(building * b, const char * info)
|
||||||
{
|
{
|
||||||
free(b.display);
|
free(b->display);
|
||||||
b.display = strdup(info);
|
b->display = strdup(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
building_getname(const building& b)
|
building_getname(const building * b)
|
||||||
{
|
{
|
||||||
return (const char *)b.name;
|
return (const char *)b->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
building_setname(building& b, const char * name)
|
building_setname(building * b, const char * name)
|
||||||
{
|
{
|
||||||
free(b.name);
|
free(b->name);
|
||||||
b.name = strdup(name);
|
b->name = strdup(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static region *
|
static region *
|
||||||
building_getregion(const building& b)
|
building_getregion(const building * b)
|
||||||
{
|
{
|
||||||
return b.region;
|
return b->region;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
building_setregion(building& bld, region& r)
|
building_setregion(building * bld, region * r)
|
||||||
{
|
{
|
||||||
building * b = &bld;
|
building * b = bld;
|
||||||
building ** blist = &b->region->buildings;
|
building ** blist = &b->region->buildings;
|
||||||
while (*blist && *blist!=b) {
|
while (*blist && *blist!=b) {
|
||||||
blist = &(*blist)->next;
|
blist = &(*blist)->next;
|
||||||
|
@ -129,11 +129,11 @@ building_setregion(building& bld, region& r)
|
||||||
*blist = b->next;
|
*blist = b->next;
|
||||||
b->next = NULL;
|
b->next = NULL;
|
||||||
|
|
||||||
blist = &r.buildings;
|
blist = &r->buildings;
|
||||||
while (*blist && *blist!=b) blist = &(*blist)->next;
|
while (*blist && *blist!=b) blist = &(*blist)->next;
|
||||||
*blist = b;
|
*blist = b;
|
||||||
|
|
||||||
b->region = &r;
|
b->region = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::ostream&
|
static std::ostream&
|
||||||
|
|
|
@ -159,9 +159,9 @@ get_direction(const char * name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
lua_equipunit(unit& u, const char * eqname)
|
lua_equipunit(unit * u, const char * eqname)
|
||||||
{
|
{
|
||||||
equip_unit(&u, get_equipment(eqname));
|
equip_unit(u, get_equipment(eqname));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -199,11 +199,11 @@ update_subscriptions(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
lua_learnskill(unit& u, const char * skname, float chances)
|
lua_learnskill(unit * u, const char * skname, float chances)
|
||||||
{
|
{
|
||||||
skill_t sk = sk_find(skname);
|
skill_t sk = sk_find(skname);
|
||||||
if (sk!=NOSKILL) {
|
if (sk!=NOSKILL) {
|
||||||
learn_skill(&u, sk, chances);
|
learn_skill(u, sk, chances);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,33 +65,33 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
static eressea::list<unit *, unit *, factionunit>
|
static eressea::list<unit *, unit *, factionunit>
|
||||||
faction_units(const faction& f)
|
faction_units(const faction * f)
|
||||||
{
|
{
|
||||||
return eressea::list<unit *, unit *, factionunit>(f.units);
|
return eressea::list<unit *, unit *, factionunit>(f->units);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
faction_setalliance(faction& f, alliance * team)
|
faction_setalliance(faction * f, alliance * team)
|
||||||
{
|
{
|
||||||
if (f.alliance==0) setalliance(&f, team);
|
if (f->alliance==0) setalliance(f, team);
|
||||||
}
|
}
|
||||||
|
|
||||||
static alliance *
|
static alliance *
|
||||||
faction_getalliance(const faction& f)
|
faction_getalliance(const faction * f)
|
||||||
{
|
{
|
||||||
return f.alliance;
|
return f->alliance;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
faction_getlocale(const faction& f)
|
faction_getlocale(const faction * f)
|
||||||
{
|
{
|
||||||
return locale_name(f.locale);
|
return locale_name(f->locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
faction_setlocale(faction& f, const char * name)
|
faction_setlocale(faction * f, const char * name)
|
||||||
{
|
{
|
||||||
f.locale = find_locale(name);
|
f->locale = find_locale(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::ostream&
|
static std::ostream&
|
||||||
|
@ -108,57 +108,57 @@ operator==(const faction& a, const faction&b)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
faction_getpolicy(const faction& a, const faction& b, const char * flag)
|
faction_getpolicy(const faction * a, const faction * b, const char * flag)
|
||||||
{
|
{
|
||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
for (mode=0;helpmodes[mode].name!=NULL;++mode) {
|
for (mode=0;helpmodes[mode].name!=NULL;++mode) {
|
||||||
if (strcmp(flag, helpmodes[mode].name)==0) {
|
if (strcmp(flag, helpmodes[mode].name)==0) {
|
||||||
return get_alliance(&a, &b) & mode;
|
return get_alliance(a, b) & mode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
faction_setpolicy(faction& a, faction& b, const char * flag, bool value)
|
faction_setpolicy(faction * a, faction * b, const char * flag, bool value)
|
||||||
{
|
{
|
||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
for (mode=0;helpmodes[mode].name!=NULL;++mode) {
|
for (mode=0;helpmodes[mode].name!=NULL;++mode) {
|
||||||
if (strcmp(flag, helpmodes[mode].name)==0) {
|
if (strcmp(flag, helpmodes[mode].name)==0) {
|
||||||
if (value) set_alliance(&a, &b, get_alliance(&a, &b) | helpmodes[mode].status);
|
if (value) set_alliance(a, b, get_alliance(a, b) | helpmodes[mode].status);
|
||||||
else set_alliance(&a, &b, get_alliance(&a, &b) & ~helpmodes[mode].status);
|
else set_alliance(a, b, get_alliance(a, b) & ~helpmodes[mode].status);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
faction_get_variable(faction& f, const char *key)
|
faction_get_variable(faction * f, const char *key)
|
||||||
{
|
{
|
||||||
return get_variable((&f)->attribs, key);
|
return get_variable(f->attribs, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
faction_set_variable(faction& f, const char *key, const char *value)
|
faction_set_variable(faction * f, const char *key, const char *value)
|
||||||
{
|
{
|
||||||
set_variable(&((&f)->attribs), key, value);
|
set_variable(&f->attribs, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
faction_delete_variable(faction& f, const char *key)
|
faction_delete_variable(faction * f, const char *key)
|
||||||
{
|
{
|
||||||
return delete_variable(&((&f)->attribs), key);
|
return delete_variable(&f->attribs, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
faction_additem(faction& f, const char * iname, int number)
|
faction_additem(faction * f, const char * iname, int number)
|
||||||
{
|
{
|
||||||
if (iname!=NULL) {
|
if (iname!=NULL) {
|
||||||
const item_type * itype = it_find(iname);
|
const item_type * itype = it_find(iname);
|
||||||
if (itype!=NULL) {
|
if (itype!=NULL) {
|
||||||
item * i = i_change(&f.items, itype, number);
|
item * i = i_change(&f->items, itype, number);
|
||||||
return i?i->number:0;
|
return i?i->number:0;
|
||||||
} // if (itype!=NULL)
|
} // if (itype!=NULL)
|
||||||
}
|
}
|
||||||
|
@ -166,78 +166,78 @@ faction_additem(faction& f, const char * iname, int number)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
faction_addnotice(faction& f, const char * str)
|
faction_addnotice(faction * f, const char * str)
|
||||||
{
|
{
|
||||||
const char * loc = LOC(f.locale, str);
|
const char * loc = LOC(f->locale, str);
|
||||||
ADDMSG(&f.msgs, msg_message("msg_event", "string", loc));
|
ADDMSG(&f->msgs, msg_message("msg_event", "string", loc));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
faction_getrace(const faction& f)
|
faction_getrace(const faction * f)
|
||||||
{
|
{
|
||||||
return f.race->_name[0];
|
return f->race->_name[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
faction_setrace(faction& f, const char * rcname)
|
faction_setrace(faction * f, const char * rcname)
|
||||||
{
|
{
|
||||||
race * rc = rc_find(rcname);
|
race * rc = rc_find(rcname);
|
||||||
if (rc!=NULL) {
|
if (rc!=NULL) {
|
||||||
f.race = rc;
|
f->race = rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static eressea::list<std::string, item *, eressea::bind_items>
|
static eressea::list<std::string, item *, eressea::bind_items>
|
||||||
faction_items(const faction& f) {
|
faction_items(const faction * f) {
|
||||||
return eressea::list<std::string, item *, eressea::bind_items>(f.items);
|
return eressea::list<std::string, item *, eressea::bind_items>(f->items);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
faction_set_passw(faction& f, const char * passw)
|
faction_set_passw(faction * f, const char * passw)
|
||||||
{
|
{
|
||||||
free(f.passw);
|
free(f->passw);
|
||||||
f.passw = strdup(passw);
|
f->passw = strdup(passw);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
faction_get_passw(const faction& f)
|
faction_get_passw(const faction * f)
|
||||||
{
|
{
|
||||||
return f.passw;
|
return f->passw;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
faction_set_banner(faction& f, const char * banner)
|
faction_set_banner(faction * f, const char * banner)
|
||||||
{
|
{
|
||||||
free(f.banner);
|
free(f->banner);
|
||||||
f.banner = strdup(banner);
|
f->banner = strdup(banner);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
faction_get_banner(const faction& f)
|
faction_get_banner(const faction * f)
|
||||||
{
|
{
|
||||||
if (f.banner) {
|
if (f->banner) {
|
||||||
return (const char*)f.banner;
|
return (const char*)f->banner;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
faction_set_email(faction& f, const char * email)
|
faction_set_email(faction * f, const char * email)
|
||||||
{
|
{
|
||||||
free(f.email);
|
free(f->email);
|
||||||
f.email = strdup(email);
|
f->email = strdup(email);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
faction_get_email(const faction& f)
|
faction_get_email(const faction * f)
|
||||||
{
|
{
|
||||||
return f.email;
|
return f->email;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
faction_getorigin(const faction& f, int &x, int &y)
|
faction_getorigin(const faction * f, int &x, int &y)
|
||||||
{
|
{
|
||||||
ursprung * origin = f.ursprung;
|
ursprung * origin = f->ursprung;
|
||||||
while (origin!=NULL && origin->id!=0) {
|
while (origin!=NULL && origin->id!=0) {
|
||||||
origin = origin->next;
|
origin = origin->next;
|
||||||
}
|
}
|
||||||
|
@ -249,49 +249,41 @@ faction_getorigin(const faction& f, int &x, int &y)
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
faction_setorigin(faction& f, int x, int y)
|
|
||||||
{
|
|
||||||
x = 0;
|
|
||||||
y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
short
|
short
|
||||||
faction_getorigin_x(const faction& f) {
|
faction_getorigin_x(const faction * f) {
|
||||||
return f.ursprung->x;
|
return f->ursprung->x;
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
faction_setorigin_x(faction& f, short x) {
|
faction_setorigin_x(faction * f, short x) {
|
||||||
f.ursprung->x = x;
|
f->ursprung->x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static short
|
static short
|
||||||
faction_getorigin_y(const faction& f) {
|
faction_getorigin_y(const faction * f) {
|
||||||
return f.ursprung->y;
|
return f->ursprung->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
faction_setorigin_y(faction& f, short y) {
|
faction_setorigin_y(faction * f, short y) {
|
||||||
f.ursprung->y = y;
|
f->ursprung->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
faction_countheroes(const faction& f)
|
faction_countheroes(const faction * f)
|
||||||
{
|
{
|
||||||
return countheroes(&f);
|
return countheroes(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
faction_renumber(faction& f, int no)
|
faction_renumber(faction * f, int no)
|
||||||
{
|
{
|
||||||
renumber_faction(&f, no);
|
renumber_faction(f, no);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
faction_maxheroes(const faction& f)
|
faction_maxheroes(const faction * f)
|
||||||
{
|
{
|
||||||
return maxheroes(&f);
|
return maxheroes(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -304,7 +296,7 @@ bind_faction(lua_State * L)
|
||||||
def("faction_origin", &faction_getorigin, pure_out_value(_2) + pure_out_value(_3)),
|
def("faction_origin", &faction_getorigin, pure_out_value(_2) + pure_out_value(_3)),
|
||||||
|
|
||||||
class_<struct faction>("faction")
|
class_<struct faction>("faction")
|
||||||
.def(tostring(self))
|
.def(tostring(const_self))
|
||||||
.def(self == faction())
|
.def(self == faction())
|
||||||
.def("set_policy", &faction_setpolicy)
|
.def("set_policy", &faction_setpolicy)
|
||||||
.def("get_policy", &faction_getpolicy)
|
.def("get_policy", &faction_getpolicy)
|
||||||
|
@ -331,7 +323,6 @@ bind_faction(lua_State * L)
|
||||||
.property("items", &faction_items, return_stl_iterator)
|
.property("items", &faction_items, return_stl_iterator)
|
||||||
.property("x", &faction_getorigin_x, &faction_setorigin_x)
|
.property("x", &faction_getorigin_x, &faction_setorigin_x)
|
||||||
.property("y", &faction_getorigin_y, &faction_setorigin_y)
|
.property("y", &faction_getorigin_y, &faction_setorigin_y)
|
||||||
//.property("origin", &faction_getorigin, &faction_setorigin, pure_out_value(_2) + pure_out_value(_3), copy)
|
|
||||||
|
|
||||||
.def("renum", &faction_renumber)
|
.def("renum", &faction_renumber)
|
||||||
.def("add_notice", &faction_addnotice)
|
.def("add_notice", &faction_addnotice)
|
||||||
|
|
|
@ -95,21 +95,21 @@ lua_writereports(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
message_unit(unit& sender, unit& target, const char * str)
|
message_unit(unit * sender, unit * target, const char * str)
|
||||||
{
|
{
|
||||||
deliverMail(target.faction, sender.region, &sender, str, &target);
|
deliverMail(target->faction, sender->region, sender, str, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
message_faction(unit& sender, faction& target, const char * str)
|
message_faction(unit * sender, faction * target, const char * str)
|
||||||
{
|
{
|
||||||
deliverMail(&target, sender.region, &sender, str, NULL);
|
deliverMail(target, sender->region, sender, str, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
message_region(unit& sender, const char * str)
|
message_region(unit * sender, const char * str)
|
||||||
{
|
{
|
||||||
ADDMSG(&sender.region->msgs, msg_message("mail_result", "unit message", &sender, str));
|
ADDMSG(&sender->region->msgs, msg_message("mail_result", "unit message", sender, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -181,9 +181,9 @@ process_orders(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
levitate_ship(ship& sh, unit& mage, double power, int duration)
|
levitate_ship(ship * sh, unit * mage, double power, int duration)
|
||||||
{
|
{
|
||||||
curse * c = shipcurse_flyingship(&sh, &mage, power, duration);
|
curse * c = shipcurse_flyingship(sh, mage, power, duration);
|
||||||
if (c) {
|
if (c) {
|
||||||
return c->no;
|
return c->no;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ public:
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_unit(const char * param, const unit& u) {
|
int set_unit(const char * param, const unit * u) {
|
||||||
if (mtype==0) return E_INVALID_MESSAGE;
|
if (mtype==0) return E_INVALID_MESSAGE;
|
||||||
|
|
||||||
int i = get_param(param);
|
int i = get_param(param);
|
||||||
|
@ -83,12 +83,12 @@ public:
|
||||||
return E_INVALID_PARAMETER_TYPE;
|
return E_INVALID_PARAMETER_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
args[i].v = (void*)&u;
|
args[i].v = (void*)u;
|
||||||
|
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_region(const char * param, const region& r) {
|
int set_region(const char * param, const region * r) {
|
||||||
if (mtype==0) return E_INVALID_MESSAGE;
|
if (mtype==0) return E_INVALID_MESSAGE;
|
||||||
|
|
||||||
int i = get_param(param);
|
int i = get_param(param);
|
||||||
|
@ -99,7 +99,7 @@ public:
|
||||||
return E_INVALID_PARAMETER_TYPE;
|
return E_INVALID_PARAMETER_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
args[i].v = (void*)&r;
|
args[i].v = (void*)r;
|
||||||
|
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
@ -138,21 +138,21 @@ public:
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int send_faction(faction& f) {
|
int send_faction(faction * f) {
|
||||||
if (mtype==0) return E_INVALID_MESSAGE;
|
if (mtype==0) return E_INVALID_MESSAGE;
|
||||||
if (msg==NULL) {
|
if (msg==NULL) {
|
||||||
msg = msg_create(mtype, args);
|
msg = msg_create(mtype, args);
|
||||||
}
|
}
|
||||||
add_message(&f.msgs, msg);
|
add_message(&f->msgs, msg);
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int send_region(region& r) {
|
int send_region(region * r) {
|
||||||
if (mtype==0) return E_INVALID_MESSAGE;
|
if (mtype==0) return E_INVALID_MESSAGE;
|
||||||
if (msg==NULL) {
|
if (msg==NULL) {
|
||||||
msg = msg_create(mtype, args);
|
msg = msg_create(mtype, args);
|
||||||
}
|
}
|
||||||
add_message(&r.msgs, msg);
|
add_message(&r->msgs, msg);
|
||||||
return E_OK;
|
return E_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,143 +43,143 @@ get_regions(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static eressea::list<unit *>
|
static eressea::list<unit *>
|
||||||
region_units(const region& r) {
|
region_units(const region * r) {
|
||||||
return eressea::list<unit *>(r.units);
|
return eressea::list<unit *>(r->units);
|
||||||
}
|
}
|
||||||
|
|
||||||
static eressea::list<building *>
|
static eressea::list<building *>
|
||||||
region_buildings(const region& r) {
|
region_buildings(const region * r) {
|
||||||
return eressea::list<building *>(r.buildings);
|
return eressea::list<building *>(r->buildings);
|
||||||
}
|
}
|
||||||
|
|
||||||
static eressea::list<ship *>
|
static eressea::list<ship *>
|
||||||
region_ships(const region& r) {
|
region_ships(const region * r) {
|
||||||
return eressea::list<ship *>(r.ships);
|
return eressea::list<ship *>(r->ships);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
region_setname(region& r, const char * name) {
|
region_setname(region * r, const char * name) {
|
||||||
if (r.land) rsetname((&r), name);
|
if (r->land) rsetname(r, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
region_getterrain(const region& r) {
|
region_getterrain(const region * r) {
|
||||||
return (const char *)r.terrain->_name;
|
return (const char *)r->terrain->_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
region_getname(const region& r) {
|
region_getname(const region * r) {
|
||||||
if (r.land) return (const char *)r.land->name;
|
if (r->land) return (const char *)r->land->name;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
lua_region_setowner(region& r, faction * f) {
|
lua_region_setowner(region * r, faction * f) {
|
||||||
region_setowner(&r, f);
|
region_setowner(r, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static faction *
|
static faction *
|
||||||
lua_region_getowner(const region& r) {
|
lua_region_getowner(const region * r) {
|
||||||
return region_owner(&r);
|
return region_owner(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
region_setherbtype(region& r, const char * str) {
|
region_setherbtype(region * r, const char * str) {
|
||||||
const struct resource_type * rtype = rt_find(str);
|
const struct resource_type * rtype = rt_find(str);
|
||||||
if (rtype!=NULL && rtype->itype!=NULL) {
|
if (rtype!=NULL && rtype->itype!=NULL) {
|
||||||
rsetherbtype(&r, rtype->itype);
|
rsetherbtype(r, rtype->itype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
region_getherbtype(const region& r) {
|
region_getherbtype(const region * r) {
|
||||||
const struct item_type * itype = rherbtype(&r);
|
const struct item_type * itype = rherbtype(r);
|
||||||
if (itype==NULL) return NULL;
|
if (itype==NULL) return NULL;
|
||||||
return itype->rtype->_name[0];
|
return itype->rtype->_name[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
region_setinfo(region& r, const char * info)
|
region_setinfo(region * r, const char * info)
|
||||||
{
|
{
|
||||||
free(r.display);
|
free(r->display);
|
||||||
r.display = strdup(info);
|
r->display = strdup(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
region_getinfo(const region& r) {
|
region_getinfo(const region * r) {
|
||||||
return (const char *)r.display;
|
return (const char *)r->display;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
region_plane(const region& r)
|
region_plane(const region * r)
|
||||||
{
|
{
|
||||||
if (r.planep==NULL) return 0;
|
if (r->planep==NULL) return 0;
|
||||||
return r.planep->id;
|
return r->planep->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
region_addnotice(region& r, const char * str)
|
region_addnotice(region * r, const char * str)
|
||||||
{
|
{
|
||||||
addmessage(&r, NULL, str, MSG_MESSAGE, ML_IMPORTANT);
|
addmessage(r, NULL, str, MSG_MESSAGE, ML_IMPORTANT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::ostream&
|
static std::ostream&
|
||||||
operator<<(std::ostream& stream, const region& r)
|
operator<<(std::ostream& stream, const region& r)
|
||||||
{
|
{
|
||||||
stream << regionname(&r, NULL) << ", " << region_getterrain(r);
|
stream << regionname(&r, NULL) << ", " << (const char *)r.terrain->_name;
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
operator==(const region& a, const region&b)
|
operator==(const region& a, const region& b)
|
||||||
{
|
{
|
||||||
return a.x==b.x && a.y==b.y;
|
return a.x==b.x && a.y==b.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
region_getflag(const region& r, int bit)
|
region_getflag(const region * r, int bit)
|
||||||
{
|
{
|
||||||
if (r.flags & (1<<bit)) return true;
|
if (r->flags & (1<<bit)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
region_setflag(region& r, int bit, bool set)
|
region_setflag(region * r, int bit, bool set)
|
||||||
{
|
{
|
||||||
if (set) r.flags |= (1<<bit);
|
if (set) r->flags |= (1<<bit);
|
||||||
else r.flags &= ~(1<<bit);
|
else r->flags &= ~(1<<bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
region_getresource(const region& r, const char * type)
|
region_getresource(const region * r, const char * type)
|
||||||
{
|
{
|
||||||
const resource_type * rtype = rt_find(type);
|
const resource_type * rtype = rt_find(type);
|
||||||
if (rtype!=NULL) {
|
if (rtype!=NULL) {
|
||||||
const rawmaterial * rm;
|
const rawmaterial * rm;
|
||||||
for (rm=r.resources;rm;rm=rm->next) {
|
for (rm=r->resources;rm;rm=rm->next) {
|
||||||
if (rm->type->rtype==rtype) {
|
if (rm->type->rtype==rtype) {
|
||||||
return rm->amount;
|
return rm->amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rtype==rt_find("money")) return rmoney(&r);
|
if (rtype==rt_find("money")) return rmoney(r);
|
||||||
if (rtype==rt_find("horse")) return rhorses(&r);
|
if (rtype==rt_find("horse")) return rhorses(r);
|
||||||
if (rtype==rt_find("peasant")) return rpeasants(&r);
|
if (rtype==rt_find("peasant")) return rpeasants(r);
|
||||||
} else {
|
} else {
|
||||||
if (strcmp(type, "seed")==0) return rtrees(&r, 0);
|
if (strcmp(type, "seed")==0) return rtrees(r, 0);
|
||||||
if (strcmp(type, "sapling")==0) return rtrees(&r, 1);
|
if (strcmp(type, "sapling")==0) return rtrees(r, 1);
|
||||||
if (strcmp(type, "tree")==0) return rtrees(&r, 2);
|
if (strcmp(type, "tree")==0) return rtrees(r, 2);
|
||||||
if (strcmp(type, "grave")==0) return deathcount(&r);
|
if (strcmp(type, "grave")==0) return deathcount(r);
|
||||||
if (strcmp(type, "chaos")==0) return chaoscount(&r);
|
if (strcmp(type, "chaos")==0) return chaoscount(r);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
region_setresource(region& r, const char * type, int value)
|
region_setresource(region * r, const char * type, int value)
|
||||||
{
|
{
|
||||||
const resource_type * rtype = rt_find(type);
|
const resource_type * rtype = rt_find(type);
|
||||||
if (rtype!=NULL) {
|
if (rtype!=NULL) {
|
||||||
rawmaterial * rm = r.resources;
|
rawmaterial * rm = r->resources;
|
||||||
while (rm) {
|
while (rm) {
|
||||||
if (rm->type->rtype==rtype) {
|
if (rm->type->rtype==rtype) {
|
||||||
rm->amount = value;
|
rm->amount = value;
|
||||||
|
@ -188,41 +188,41 @@ region_setresource(region& r, const char * type, int value)
|
||||||
rm=rm->next;
|
rm=rm->next;
|
||||||
}
|
}
|
||||||
if (!rm) {
|
if (!rm) {
|
||||||
if (rtype==rt_find("money")) rsetmoney(&r, value);
|
if (rtype==rt_find("money")) rsetmoney(r, value);
|
||||||
else if (rtype==rt_find("peasant")) rsetpeasants(&r, value);
|
else if (rtype==rt_find("peasant")) rsetpeasants(r, value);
|
||||||
else if (rtype==rt_find("horse")) rsethorses(&r, value);
|
else if (rtype==rt_find("horse")) rsethorses(r, value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (strcmp(type, "seed")==0) {
|
if (strcmp(type, "seed")==0) {
|
||||||
rsettrees(&r, 0, value);
|
rsettrees(r, 0, value);
|
||||||
} else if (strcmp(type, "sapling")==0) {
|
} else if (strcmp(type, "sapling")==0) {
|
||||||
rsettrees(&r, 1, value);
|
rsettrees(r, 1, value);
|
||||||
} else if (strcmp(type, "tree")==0) {
|
} else if (strcmp(type, "tree")==0) {
|
||||||
rsettrees(&r, 2, value);
|
rsettrees(r, 2, value);
|
||||||
} else if (strcmp(type, "grave")==0) {
|
} else if (strcmp(type, "grave")==0) {
|
||||||
int fallen = value-deathcount(&r);
|
int fallen = value-deathcount(r);
|
||||||
deathcounts(&r, fallen);
|
deathcounts(r, fallen);
|
||||||
} else if (strcmp(type, "chaos")==0) {
|
} else if (strcmp(type, "chaos")==0) {
|
||||||
int fallen = value-chaoscount(&r);
|
int fallen = value-chaoscount(r);
|
||||||
chaoscounts(&r, fallen);
|
chaoscounts(r, fallen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
region_setroad(region& r, int dir, lua_Number size)
|
region_setroad(region * r, int dir, lua_Number size)
|
||||||
{
|
{
|
||||||
if (r.terrain->max_road>0) {
|
if (r->terrain->max_road>0) {
|
||||||
rsetroad(&r, (direction_t)dir, (short)(r.terrain->max_road * size));
|
rsetroad(r, (direction_t)dir, (short)(r->terrain->max_road * size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static lua_Number
|
static lua_Number
|
||||||
region_getroad(region& r, int dir)
|
region_getroad(region * r, int dir)
|
||||||
{
|
{
|
||||||
lua_Number result = rroad(&r, (direction_t)dir);
|
lua_Number result = rroad(r, (direction_t)dir);
|
||||||
if (r.terrain->max_road<=0 || result<=0) return 0;
|
if (r->terrain->max_road<=0 || result<=0) return 0;
|
||||||
return r.terrain->max_road / result;
|
return r->terrain->max_road / result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static region *
|
static region *
|
||||||
|
@ -247,24 +247,24 @@ region_terraform(short x, short y, const char * tname)
|
||||||
}
|
}
|
||||||
|
|
||||||
static region *
|
static region *
|
||||||
region_next(const region& r, int dir)
|
region_next(const region * r, int dir)
|
||||||
{
|
{
|
||||||
if (dir<0 || dir >=MAXDIRECTIONS) return NULL;
|
if (dir<0 || dir >=MAXDIRECTIONS) return NULL;
|
||||||
return r_connect(&r, (direction_t)dir);
|
return r_connect(r, (direction_t)dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
region_adddirection(region& r, region &rt, const char * name, const char * info)
|
region_adddirection(region * r, region * rt, const char * name, const char * info)
|
||||||
{
|
{
|
||||||
create_special_direction(&r, &rt, -1, info, name);
|
create_special_direction(r, rt, -1, info, name);
|
||||||
spec_direction * sd = special_direction(&r, &rt);
|
spec_direction * sd = special_direction(r, rt);
|
||||||
sd->active = 1;
|
sd->active = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
region_remove(region& r)
|
region_remove(region * r)
|
||||||
{
|
{
|
||||||
remove_region(®ions, &r);
|
remove_region(®ions, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -282,7 +282,7 @@ plane_remove(int plane_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
region_move(region& r, short x, short y)
|
region_move(region * r, short x, short y)
|
||||||
{
|
{
|
||||||
if (findregion(x,y)) {
|
if (findregion(x,y)) {
|
||||||
log_error(("Bei %d, %d gibt es schon eine Region.\n", x, y));
|
log_error(("Bei %d, %d gibt es schon eine Region.\n", x, y));
|
||||||
|
@ -291,41 +291,41 @@ region_move(region& r, short x, short y)
|
||||||
#ifdef FAST_CONNECT
|
#ifdef FAST_CONNECT
|
||||||
direction_t dir;
|
direction_t dir;
|
||||||
for (dir=0;dir!=MAXDIRECTIONS;++dir) {
|
for (dir=0;dir!=MAXDIRECTIONS;++dir) {
|
||||||
region * rn = r.connect[dir];
|
region * rn = r->connect[dir];
|
||||||
if (rn!=NULL) {
|
if (rn!=NULL) {
|
||||||
direction_t reldir = reldirection(rn, &r);
|
direction_t reldir = reldirection(rn, r);
|
||||||
rn->connect[reldir] = NULL;
|
rn->connect[reldir] = NULL;
|
||||||
}
|
}
|
||||||
rn = findregion(x+delta_x[dir], y+delta_y[dir]);
|
rn = findregion(x+delta_x[dir], y+delta_y[dir]);
|
||||||
if (rn!=NULL) {
|
if (rn!=NULL) {
|
||||||
direction_t reldir = (direction_t)((dir + 3) % MAXDIRECTIONS);
|
direction_t reldir = (direction_t)((dir + 3) % MAXDIRECTIONS);
|
||||||
rn->connect[reldir] = &r;
|
rn->connect[reldir] = r;
|
||||||
}
|
}
|
||||||
r.connect[dir] = rn;
|
r->connect[dir] = rn;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
runhash(&r);
|
runhash(r);
|
||||||
r.x = x;
|
r->x = x;
|
||||||
r.y = y;
|
r->y = y;
|
||||||
rhash(&r);
|
rhash(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static eressea::list<std::string, item *, eressea::bind_items>
|
static eressea::list<std::string, item *, eressea::bind_items>
|
||||||
region_items(const region& r) {
|
region_items(const region * r) {
|
||||||
if (r.land) {
|
if (r->land) {
|
||||||
return eressea::list<std::string, item *, eressea::bind_items>(r.land->items);
|
return eressea::list<std::string, item *, eressea::bind_items>(r->land->items);
|
||||||
} else {
|
} else {
|
||||||
return eressea::list<std::string, item *, eressea::bind_items>(NULL);
|
return eressea::list<std::string, item *, eressea::bind_items>(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
region_additem(region& r, const char * iname, int number)
|
region_additem(region * r, const char * iname, int number)
|
||||||
{
|
{
|
||||||
if (iname!=NULL) {
|
if (iname!=NULL) {
|
||||||
const item_type * itype = it_find(iname);
|
const item_type * itype = it_find(iname);
|
||||||
if (itype!=NULL && r.land) {
|
if (itype!=NULL && r->land) {
|
||||||
item * i = i_change(&r.land->items, itype, number);
|
item * i = i_change(&r->land->items, itype, number);
|
||||||
return i?i->number:0;
|
return i?i->number:0;
|
||||||
} // if (itype!=NULL)
|
} // if (itype!=NULL)
|
||||||
}
|
}
|
||||||
|
@ -333,22 +333,22 @@ region_additem(region& r, const char * iname, int number)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
region_getkey(region& r, const char * name)
|
region_getkey(region * r, const char * name)
|
||||||
{
|
{
|
||||||
int flag = atoi36(name);
|
int flag = atoi36(name);
|
||||||
attrib * a = find_key(r.attribs, flag);
|
attrib * a = find_key(r->attribs, flag);
|
||||||
return (a!=NULL);
|
return (a!=NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
region_setkey(region& r, const char * name, bool value)
|
region_setkey(region * r, const char * name, bool value)
|
||||||
{
|
{
|
||||||
int flag = atoi36(name);
|
int flag = atoi36(name);
|
||||||
attrib * a = find_key(r.attribs, flag);
|
attrib * a = find_key(r->attribs, flag);
|
||||||
if (a==NULL && value) {
|
if (a==NULL && value) {
|
||||||
add_key(&r.attribs, flag);
|
add_key(&r->attribs, flag);
|
||||||
} else if (a!=NULL && !value) {
|
} else if (a!=NULL && !value) {
|
||||||
a_remove(&r.attribs, a);
|
a_remove(&r->attribs, a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -274,10 +274,10 @@ lua_maintenance(const unit * u)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_setscript(struct unit& u, const luabind::object& f)
|
unit_setscript(struct unit * u, const luabind::object& f)
|
||||||
{
|
{
|
||||||
luabind::object * fptr = new luabind::object(f);
|
luabind::object * fptr = new luabind::object(f);
|
||||||
setscript(&u.attribs, fptr);
|
setscript(&u->attribs, fptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -45,46 +45,46 @@ operator==(const ship& a, const ship& sh)
|
||||||
}
|
}
|
||||||
|
|
||||||
static ship *
|
static ship *
|
||||||
add_ship(region& r, const char * sname)
|
add_ship(region * r, const char * sname)
|
||||||
{
|
{
|
||||||
const ship_type * stype = st_find(sname);
|
const ship_type * stype = st_find(sname);
|
||||||
ship * sh = new_ship(stype, NULL, &r);
|
ship * sh = new_ship(stype, NULL, r);
|
||||||
sh->size = stype->construction->maxsize;
|
sh->size = stype->construction->maxsize;
|
||||||
return sh;
|
return sh;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ship_maxsize(const ship& s) {
|
ship_maxsize(const ship * s) {
|
||||||
return s.type->construction->maxsize;
|
return s->type->construction->maxsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
ship_gettype(const ship& s) {
|
ship_gettype(const ship * s) {
|
||||||
return s.type->name[0];
|
return s->type->name[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ship_getweight(const ship& s) {
|
ship_getweight(const ship * s) {
|
||||||
int w, c;
|
int w, c;
|
||||||
getshipweight(&s, &w, &c);
|
getshipweight(s, &w, &c);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ship_getcapacity(const ship& s) {
|
ship_getcapacity(const ship * s) {
|
||||||
return shipcapacity(&s);
|
return shipcapacity(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ship_setregion(ship& sh, region& r)
|
ship_setregion(ship * sh, region * r)
|
||||||
{
|
{
|
||||||
move_ship(&sh, sh.region, &r, NULL);
|
move_ship(sh, sh->region, r, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static region *
|
static region *
|
||||||
ship_getregion(const ship& sh)
|
ship_getregion(const ship * sh)
|
||||||
{
|
{
|
||||||
return sh.region;
|
return sh->region;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -57,8 +57,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
static eressea::list<spell *, spell_list *, bind_spell_ptr>
|
static eressea::list<spell *, spell_list *, bind_spell_ptr>
|
||||||
unit_spells(const unit& u) {
|
unit_spells(const unit * u) {
|
||||||
sc_mage * mage = get_mage(&u);
|
sc_mage * mage = get_mage(u);
|
||||||
if (mage==NULL) return eressea::list<spell *, spell_list *, bind_spell_ptr>(NULL);
|
if (mage==NULL) return eressea::list<spell *, spell_list *, bind_spell_ptr>(NULL);
|
||||||
spell_list * splist = mage->spells;
|
spell_list * splist = mage->spells;
|
||||||
return eressea::list<spell *, spell_list *, bind_spell_ptr>(splist);
|
return eressea::list<spell *, spell_list *, bind_spell_ptr>(splist);
|
||||||
|
@ -82,13 +82,13 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
static eressea::list<std::string, order *, bind_orders>
|
static eressea::list<std::string, order *, bind_orders>
|
||||||
unit_orders(const unit& u) {
|
unit_orders(const unit * u) {
|
||||||
return eressea::list<std::string, order *, bind_orders>(u.orders);
|
return eressea::list<std::string, order *, bind_orders>(u->orders);
|
||||||
}
|
}
|
||||||
|
|
||||||
static eressea::list<std::string, item *, eressea::bind_items>
|
static eressea::list<std::string, item *, eressea::bind_items>
|
||||||
unit_items(const unit& u) {
|
unit_items(const unit * u) {
|
||||||
return eressea::list<std::string, item *, eressea::bind_items>(u.items);
|
return eressea::list<std::string, item *, eressea::bind_items>(u->items);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unit *
|
static unit *
|
||||||
|
@ -99,84 +99,84 @@ add_unit(faction * f, region * r)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_setnumber(unit& u, int number)
|
unit_setnumber(unit * u, int number)
|
||||||
{
|
{
|
||||||
if (u.number==0) {
|
if (u->number==0) {
|
||||||
set_number(&u, number);
|
set_number(u, number);
|
||||||
u.hp = unit_max_hp(&u) * number;
|
u->hp = unit_max_hp(u) * number;
|
||||||
} else {
|
} else {
|
||||||
scale_number(&u, number);
|
scale_number(u, number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_setracename(unit& u, const char * name)
|
unit_setracename(unit * u, const char * name)
|
||||||
{
|
{
|
||||||
set_racename(&u.attribs, name);
|
set_racename(&u->attribs, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unit_getnumber(const unit& u)
|
unit_getnumber(const unit * u)
|
||||||
{
|
{
|
||||||
return u.number;
|
return u->number;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unit_getitem(const unit& u, const char * iname)
|
unit_getitem(const unit * u, const char * iname)
|
||||||
{
|
{
|
||||||
if (iname!=NULL) {
|
if (iname!=NULL) {
|
||||||
const item_type * itype = it_find(iname);
|
const item_type * itype = it_find(iname);
|
||||||
if (itype!=NULL) {
|
if (itype!=NULL) {
|
||||||
return i_get(u.items, itype);
|
return i_get(u->items, itype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unit_additem(unit& u, const char * iname, int number)
|
unit_additem(unit * u, const char * iname, int number)
|
||||||
{
|
{
|
||||||
if (iname!=NULL) {
|
if (iname!=NULL) {
|
||||||
const item_type * itype = it_find(iname);
|
const item_type * itype = it_find(iname);
|
||||||
if (itype!=NULL) {
|
if (itype!=NULL) {
|
||||||
item * i = i_change(&u.items, itype, number);
|
item * i = i_change(&u->items, itype, number);
|
||||||
return i?i->number:0;
|
return i?i->number:0;
|
||||||
} // if (itype!=NULL)
|
} // if (itype!=NULL)
|
||||||
}
|
}
|
||||||
const item_type * itype = it_find(iname);
|
const item_type * itype = it_find(iname);
|
||||||
if (itype!=NULL) {
|
if (itype!=NULL) {
|
||||||
item * i = i_change(&u.items, itype, number);
|
item * i = i_change(&u->items, itype, number);
|
||||||
return i?i->number:0;
|
return i?i->number:0;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unit_usepooled(unit& u, const char * iname, int number)
|
unit_usepooled(unit * u, const char * iname, int number)
|
||||||
{
|
{
|
||||||
const resource_type * rtype = rt_find(iname);
|
const resource_type * rtype = rt_find(iname);
|
||||||
if (rtype!=NULL) {
|
if (rtype!=NULL) {
|
||||||
return use_pooled(&u, rtype, GET_DEFAULT, number);
|
return use_pooled(u, rtype, GET_DEFAULT, number);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unit_getpooled(unit& u, const char * iname)
|
unit_getpooled(unit * u, const char * iname)
|
||||||
{
|
{
|
||||||
const resource_type * rtype = rt_find(iname);
|
const resource_type * rtype = rt_find(iname);
|
||||||
if (rtype!=NULL) {
|
if (rtype!=NULL) {
|
||||||
return get_pooled(&u, rtype, GET_DEFAULT, INT_MAX);
|
return get_pooled(u, rtype, GET_DEFAULT, INT_MAX);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unit_getskill(const unit& u, const char * skname)
|
unit_getskill(const unit * u, const char * skname)
|
||||||
{
|
{
|
||||||
skill_t sk = sk_find(skname);
|
skill_t sk = sk_find(skname);
|
||||||
if (sk!=NOSKILL) {
|
if (sk!=NOSKILL) {
|
||||||
skill * sv = get_skill(&u, sk);
|
skill * sv = get_skill(u, sk);
|
||||||
if (sv==NULL) return 0;
|
if (sv==NULL) return 0;
|
||||||
return sv->level;
|
return sv->level;
|
||||||
}
|
}
|
||||||
|
@ -184,44 +184,44 @@ unit_getskill(const unit& u, const char * skname)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unit_effskill(const unit& u, const char * skname)
|
unit_effskill(const unit * u, const char * skname)
|
||||||
{
|
{
|
||||||
skill_t sk = sk_find(skname);
|
skill_t sk = sk_find(skname);
|
||||||
if (sk!=NOSKILL) {
|
if (sk!=NOSKILL) {
|
||||||
return effskill(&u, sk);
|
return effskill(u, sk);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unit_setskill(unit& u, const char * skname, int level)
|
unit_setskill(unit * u, const char * skname, int level)
|
||||||
{
|
{
|
||||||
skill_t sk = sk_find(skname);
|
skill_t sk = sk_find(skname);
|
||||||
if (sk!=NOSKILL) {
|
if (sk!=NOSKILL) {
|
||||||
set_level(&u, sk, level);
|
set_level(u, sk, level);
|
||||||
return level;
|
return level;
|
||||||
} // if (sk!=NULL)
|
} // if (sk!=NULL)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
unit_getrace(const unit& u)
|
unit_getrace(const unit * u)
|
||||||
{
|
{
|
||||||
return u.race->_name[0];
|
return u->race->_name[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_setrace(unit& u, const char * rcname)
|
unit_setrace(unit * u, const char * rcname)
|
||||||
{
|
{
|
||||||
race * rc = rc_find(rcname);
|
race * rc = rc_find(rcname);
|
||||||
if (rc!=NULL) {
|
if (rc!=NULL) {
|
||||||
if (u.irace==u.race) u.irace = rc;
|
if (u->irace==u->race) u->irace = rc;
|
||||||
u.race = rc;
|
u->race = rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_castspell(unit& u, const char * name)
|
unit_castspell(unit * u, const char * name)
|
||||||
{
|
{
|
||||||
spell_list * slist = spells;
|
spell_list * slist = spells;
|
||||||
while (slist!=NULL) {
|
while (slist!=NULL) {
|
||||||
|
@ -232,10 +232,10 @@ unit_castspell(unit& u, const char * name)
|
||||||
co->familiar = NULL;
|
co->familiar = NULL;
|
||||||
co->force = sp->level;
|
co->force = sp->level;
|
||||||
co->level = sp->level;
|
co->level = sp->level;
|
||||||
co->magician.u = &u;
|
co->magician.u = u;
|
||||||
co->order = NULL;
|
co->order = NULL;
|
||||||
co->par = NULL;
|
co->par = NULL;
|
||||||
co->rt = u.region;
|
co->rt = u->region;
|
||||||
co->sp = sp;
|
co->sp = sp;
|
||||||
if (sp->sp_function==NULL) {
|
if (sp->sp_function==NULL) {
|
||||||
log_error(("spell '%s' has no function.\n", sp->sname));
|
log_error(("spell '%s' has no function.\n", sp->sname));
|
||||||
|
@ -250,14 +250,14 @@ unit_castspell(unit& u, const char * name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_addspell(unit& u, const char * name)
|
unit_addspell(unit * u, const char * name)
|
||||||
{
|
{
|
||||||
bool add = false;
|
bool add = false;
|
||||||
spell_list * slist = spells;
|
spell_list * slist = spells;
|
||||||
while (slist!=NULL) {
|
while (slist!=NULL) {
|
||||||
spell * sp = slist->data;
|
spell * sp = slist->data;
|
||||||
if (strcmp(name, sp->sname)==0) {
|
if (strcmp(name, sp->sname)==0) {
|
||||||
struct sc_mage * mage = get_mage(&u);
|
struct sc_mage * mage = get_mage(u);
|
||||||
if (add) log_error(("two spells are called %s.\n", name));
|
if (add) log_error(("two spells are called %s.\n", name));
|
||||||
add_spell(mage, sp);
|
add_spell(mage, sp);
|
||||||
add = true;
|
add = true;
|
||||||
|
@ -268,9 +268,9 @@ unit_addspell(unit& u, const char * name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static unit *
|
static unit *
|
||||||
unit_isfamiliar(const unit& u)
|
unit_isfamiliar(const unit * u)
|
||||||
{
|
{
|
||||||
attrib * a = a_find(u.attribs, &at_familiarmage);
|
attrib * a = a_find(u->attribs, &at_familiarmage);
|
||||||
if (a!=NULL) {
|
if (a!=NULL) {
|
||||||
return (unit*)a->data.v;
|
return (unit*)a->data.v;
|
||||||
}
|
}
|
||||||
|
@ -278,9 +278,9 @@ unit_isfamiliar(const unit& u)
|
||||||
}
|
}
|
||||||
|
|
||||||
static unit *
|
static unit *
|
||||||
unit_getfamiliar(const unit& u)
|
unit_getfamiliar(const unit * u)
|
||||||
{
|
{
|
||||||
attrib * a = a_find(u.attribs, &at_familiar);
|
attrib * a = a_find(u->attribs, &at_familiar);
|
||||||
if (a!=NULL) {
|
if (a!=NULL) {
|
||||||
return (unit*)a->data.v;
|
return (unit*)a->data.v;
|
||||||
}
|
}
|
||||||
|
@ -288,15 +288,15 @@ unit_getfamiliar(const unit& u)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_setfamiliar(unit& mage, unit& familiar)
|
unit_setfamiliar(unit * mage, unit * familiar)
|
||||||
{
|
{
|
||||||
create_newfamiliar(&mage, &familiar);
|
create_newfamiliar(mage, familiar);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_removespell(unit& u, const spell * sp)
|
unit_removespell(unit * u, const spell * sp)
|
||||||
{
|
{
|
||||||
sc_mage * mage = get_mage(&u);
|
sc_mage * mage = get_mage(u);
|
||||||
if (mage!=NULL) {
|
if (mage!=NULL) {
|
||||||
spell_list ** isptr = &mage->spells;
|
spell_list ** isptr = &mage->spells;
|
||||||
while (*isptr && (*isptr)->data != sp) {
|
while (*isptr && (*isptr)->data != sp) {
|
||||||
|
@ -311,9 +311,9 @@ unit_removespell(unit& u, const spell * sp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unit_hpmax(const unit& u)
|
unit_hpmax(const unit * u)
|
||||||
{
|
{
|
||||||
return unit_max_hp(&u);
|
return unit_max_hp(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -323,25 +323,25 @@ unit_setregion(unit * u, region * r)
|
||||||
}
|
}
|
||||||
|
|
||||||
static region *
|
static region *
|
||||||
unit_getregion(const unit& u)
|
unit_getregion(const unit * u)
|
||||||
{
|
{
|
||||||
return u.region;
|
return u->region;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_setship(unit& u, const ship& s)
|
unit_setship(unit * u, ship * s)
|
||||||
{
|
{
|
||||||
leave(u.region, &u);
|
leave(u->region, u);
|
||||||
if (u.region!=s.region) {
|
if (u->region!=s->region) {
|
||||||
move_unit(&u, s.region, NULL);
|
move_unit(u, s->region, NULL);
|
||||||
}
|
}
|
||||||
u.ship = findship(s.no);
|
u->ship = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ship *
|
static ship *
|
||||||
unit_getship(const unit& u)
|
unit_getship(const unit * u)
|
||||||
{
|
{
|
||||||
return u.ship;
|
return u->ship;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -351,76 +351,75 @@ unit_setbuilding(unit * u, building * b)
|
||||||
if (u->region!=b->region) {
|
if (u->region!=b->region) {
|
||||||
move_unit(u, b->region, NULL);
|
move_unit(u, b->region, NULL);
|
||||||
}
|
}
|
||||||
assert(b==findbuilding(b->no));
|
|
||||||
u->building = b;
|
u->building = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
static building *
|
static building *
|
||||||
unit_getbuilding(const unit& u)
|
unit_getbuilding(const unit * u)
|
||||||
{
|
{
|
||||||
return u.building;
|
return u->building;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unit_getid(const unit& u)
|
unit_getid(const unit * u)
|
||||||
{
|
{
|
||||||
return u.no;
|
return u->no;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_setid(unit& u, int id)
|
unit_setid(unit * u, int id)
|
||||||
{
|
{
|
||||||
unit * nu = findunit(id);
|
unit * nu = findunit(id);
|
||||||
if (nu==NULL) {
|
if (nu==NULL) {
|
||||||
uunhash(&u);
|
uunhash(u);
|
||||||
u.no = id;
|
u->no = id;
|
||||||
uhash(&u);
|
uhash(u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
unit_getname(const unit& u)
|
unit_getname(const unit * u)
|
||||||
{
|
{
|
||||||
return (const char *)u.name;
|
return (const char *)u->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_setname(unit& u, const char * name)
|
unit_setname(unit * u, const char * name)
|
||||||
{
|
{
|
||||||
free(u.name);
|
free(u->name);
|
||||||
u.name = strdup(name);
|
u->name = strdup(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
unit_getinfo(const unit& u)
|
unit_getinfo(const unit * u)
|
||||||
{
|
{
|
||||||
return (const char *)u.display;
|
return (const char *)u->display;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_setinfo(unit& u, const char * info)
|
unit_setinfo(unit * u, const char * info)
|
||||||
{
|
{
|
||||||
free(u.display);
|
free(u->display);
|
||||||
u.display = strdup(info);
|
u->display = strdup(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
get_flag(const unit& u, const char * name)
|
get_flag(const unit * u, const char * name)
|
||||||
{
|
{
|
||||||
int flag = atoi36(name);
|
int flag = atoi36(name);
|
||||||
attrib * a = find_key(u.attribs, flag);
|
attrib * a = find_key(u->attribs, flag);
|
||||||
return (a!=NULL);
|
return (a!=NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_flag(unit& u, const char * name, bool value)
|
set_flag(unit * u, const char * name, bool value)
|
||||||
{
|
{
|
||||||
int flag = atoi36(name);
|
int flag = atoi36(name);
|
||||||
attrib * a = find_key(u.attribs, flag);
|
attrib * a = find_key(u->attribs, flag);
|
||||||
if (a==NULL && value) {
|
if (a==NULL && value) {
|
||||||
add_key(&u.attribs, flag);
|
add_key(&u->attribs, flag);
|
||||||
} else if (a!=NULL && !value) {
|
} else if (a!=NULL && !value) {
|
||||||
a_remove(&u.attribs, a);
|
a_remove(&u->attribs, a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,74 +433,74 @@ operator<<(std::ostream& stream, const unit& u)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
operator==(const unit& a, const unit&b)
|
operator==(const unit& a, const unit &b)
|
||||||
{
|
{
|
||||||
return a.no==b.no;
|
return a.no==b.no;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unit_getaura(const unit& u)
|
unit_getaura(const unit * u)
|
||||||
{
|
{
|
||||||
return get_spellpoints(&u);
|
return get_spellpoints(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_setaura(unit& u, int points)
|
unit_setaura(unit * u, int points)
|
||||||
{
|
{
|
||||||
return set_spellpoints(&u, points);
|
return set_spellpoints(u, points);
|
||||||
}
|
}
|
||||||
|
|
||||||
static faction *
|
static faction *
|
||||||
unit_getfaction(const unit& u)
|
unit_getfaction(const unit * u)
|
||||||
{
|
{
|
||||||
return u.faction;
|
return u->faction;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_setfaction(unit& u, faction& f)
|
unit_setfaction(unit * u, faction * f)
|
||||||
{
|
{
|
||||||
u_setfaction(&u, &f);
|
u_setfaction(u, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
unit_getmagic(const unit& u)
|
unit_getmagic(const unit * u)
|
||||||
{
|
{
|
||||||
sc_mage * mage = get_mage(&u);
|
sc_mage * mage = get_mage(u);
|
||||||
return mage?magietypen[mage->magietyp]:NULL;
|
return mage?magietypen[mage->magietyp]:NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_setmagic(unit& u, const char * type)
|
unit_setmagic(unit * u, const char * type)
|
||||||
{
|
{
|
||||||
sc_mage * mage = get_mage(&u);
|
sc_mage * mage = get_mage(u);
|
||||||
magic_t mtype;
|
magic_t mtype;
|
||||||
for (mtype=0;mtype!=MAXMAGIETYP;++mtype) {
|
for (mtype=0;mtype!=MAXMAGIETYP;++mtype) {
|
||||||
if (strcmp(magietypen[mtype], type)==0) break;
|
if (strcmp(magietypen[mtype], type)==0) break;
|
||||||
}
|
}
|
||||||
if (mtype==MAXMAGIETYP) return;
|
if (mtype==MAXMAGIETYP) return;
|
||||||
if (mage==NULL) {
|
if (mage==NULL) {
|
||||||
mage = create_mage(&u, mtype);
|
mage = create_mage(u, mtype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_addorder(unit& u, const char * str)
|
unit_addorder(unit * u, const char * str)
|
||||||
{
|
{
|
||||||
order * ord = parse_order(str, u.faction->locale);
|
order * ord = parse_order(str, u->faction->locale);
|
||||||
addlist(&u.orders, ord);
|
addlist(&u->orders, ord);
|
||||||
u.faction->lastorders = turn;
|
u->faction->lastorders = turn;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_clearorders(unit& u)
|
unit_clearorders(unit * u)
|
||||||
{
|
{
|
||||||
free_orders(&u.orders);
|
free_orders(&u->orders);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unit_weight(const struct unit& u)
|
unit_weight(const struct unit * u)
|
||||||
{
|
{
|
||||||
return weight(&u);
|
return weight(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct fctr_data {
|
typedef struct fctr_data {
|
||||||
|
@ -552,32 +551,32 @@ static struct trigger_type tt_functor = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static trigger *
|
static trigger *
|
||||||
trigger_functor(struct unit& u, const object& f)
|
trigger_functor(struct unit * u, const object& f)
|
||||||
{
|
{
|
||||||
luabind::object * fptr = new luabind::object(f);
|
luabind::object * fptr = new luabind::object(f);
|
||||||
trigger * t = t_new(&tt_functor);
|
trigger * t = t_new(&tt_functor);
|
||||||
fctr_data * td = (fctr_data*)t->data.v;
|
fctr_data * td = (fctr_data*)t->data.v;
|
||||||
td->target = &u;
|
td->target = u;
|
||||||
td->fptr = fptr;
|
td->fptr = fptr;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_addhandler(struct unit& u, const char * event, const object& f)
|
unit_addhandler(struct unit * u, const char * event, const object& f)
|
||||||
{
|
{
|
||||||
add_trigger(&u.attribs, event, trigger_functor(u, f));
|
add_trigger(&u->attribs, event, trigger_functor(u, f));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
unit_capacity(const struct unit& u)
|
unit_capacity(const struct unit * u)
|
||||||
{
|
{
|
||||||
return walkingcapacity(&u);
|
return walkingcapacity(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_addnotice(unit& u, const char * str)
|
unit_addnotice(unit * u, const char * str)
|
||||||
{
|
{
|
||||||
addmessage(u.region, u.faction, str, MSG_MESSAGE, ML_IMPORTANT);
|
addmessage(u->region, u->faction, str, MSG_MESSAGE, ML_IMPORTANT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue