upgrade to luabind beta-7 devel-2

upgrade to g++ 4.0
This commit is contained in:
Enno Rehling 2005-10-31 22:34:45 +00:00
parent 40fb0c5528
commit dfc6f83c62
20 changed files with 76 additions and 113 deletions

View File

@ -1,9 +1,9 @@
C++ = g++-3.3 ;
CC = gcc-3.3 ;
LINK = gcc-3.3 ;
#CC = tcc ;
#LINK = tcc ;
#C++ = g++-3.3 ;
#CC = gcc-3.3 ;
#LINK = gcc-3.3 ;
C++ = g++ ;
CC = gcc ;
LINK = gcc ;
# ECHO $(JAMUNAME) ;

View File

@ -2572,7 +2572,7 @@ breedhorses(region *r, unit *u)
for (c = 0; c < n; c++) {
if (rand() % 100 < eff_skill(u, SK_HORSE_TRAINING, r)) {
change_item(u, I_HORSE, 1);
i_change(&u->items, olditemtype[I_HORSE], 1);
gezuechtet++;
}
}

View File

@ -3249,7 +3249,7 @@ age_building(building * b)
int n, unicorns = 0;
for (n=0; n!=u->number; ++n) {
if (chance(0.02)) {
change_item(u, I_UNICORN, 1);
i_change(&u->items, olditemtype[I_UNICORN], 1);
++unicorns;
}
if (unicorns) {

View File

@ -676,7 +676,7 @@ damage_unit(unit *u, const char *dam, boolean physical, boolean magic)
if (get_effect(u, oldpotiontype[P_HEAL]) > 0) {
change_effect(u, oldpotiontype[P_HEAL], -1);
heiltrank = 1;
} else if (get_potion(u, P_HEAL) > 0) {
} else if (i_get(u->items, oldpotiontype[P_HEAL]->itype) > 0) {
i_change(&u->items, oldpotiontype[P_HEAL]->itype, -1);
change_effect(u, oldpotiontype[P_HEAL], 3);
heiltrank = 1;

View File

@ -30,11 +30,6 @@
#include <assert.h>
#include <stdlib.h>
static weapon_mod wm_catapult[] = {
{ 4, WMF_MISSILE_TARGET },
{ 0, 0 }
};
static weapon_mod wm_spear[] = {
{ 1, WMF_SKILL|WMF_RIDING|WMF_AGAINST_ANYONE|WMF_OFFENSIVE },
{ 1, WMF_SKILL|WMF_WALKING|WMF_AGAINST_RIDING|WMF_DEFENSIVE },
@ -48,19 +43,12 @@ static weapon_mod wm_lance[] = {
enum {
WP_EOGSWORD,
WP_CATAPULT,
WP_SPEAR,
WP_LANCE,
WP_NONE,
WP_MAX
};
enum {
RL_CATAPULT,
RL_MAX,
RL_NONE
};
/* damage types */
#define CUT (1<<0)
@ -89,17 +77,15 @@ static weapondata weapontable[WP_MAX + 1] =
/* MagRes, Schaden/Fuß, Schaden/Pferd, Item, Skill, OffMod, DefMod,
* missile, is_magic */
{
{0.30, "3d6+10", "3d6+10", I_LAENSWORD, SK_MELEE, 1, 1, false, false, { RL_NONE, 0}, CUT },
/* Katapult */
{0.00, "3d10+5", "3d10+5", I_CATAPULT, SK_CATAPULT, 0, 0, true, false, { RL_CATAPULT, 5 }, BASH },
{0.30, "3d6+10", "3d6+10", I_LAENSWORD, SK_MELEE, 1, 1, false, false, { 0, 0}, CUT },
/* Speer */
{0.00, "1d10+0", "1d12+2", I_SPEAR, SK_SPEAR, 0, 0, false, false, { RL_NONE, 0}, PIERCE },
{0.00, "1d10+0", "1d12+2", I_SPEAR, SK_SPEAR, 0, 0, false, false, { 0, 0}, PIERCE },
/* Lanze */
{0.00, "1d5", "2d6+5", I_LANCE, SK_SPEAR, 0, -2, false, false, { RL_NONE, 0}, PIERCE },
{0.00, "1d5", "2d6+5", I_LANCE, SK_SPEAR, 0, -2, false, false, { 0, 0}, PIERCE },
/* Unbewaffnet */
{0.00, "1d5+0", "1d6+0", I_WOOD, SK_MELEE, 0, 0, false, false, { RL_NONE, 0}, BASH },
{0.00, "1d5+0", "1d6+0", I_WOOD, SK_MELEE, 0, 0, false, false, { 0, 0}, BASH },
/* Dummy */
{0.00, "0d0+0", "0d0+0", I_WOOD, SK_MELEE, 0, 0, false, false, { RL_NONE, 0}, 0 }
{0.00, "0d0+0", "0d0+0", I_WOOD, SK_MELEE, 0, 0, false, false, { 0, 0}, 0 }
};
weapon_type * oldweapontype[WP_MAX];
@ -236,10 +222,6 @@ init_oldweapons(void)
case WP_LANCE:
modifiers = wm_lance;
break;
case WP_CATAPULT:
modifiers = wm_catapult;
attack = attack_catapult;
break;
case WP_SPEAR:
modifiers = wm_spear;
break;
@ -278,12 +260,12 @@ init_oldweapons(void)
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");
}
void
init_weapons(void)
{
init_oldweapons();
init_oldweapons();
}

View File

@ -1708,7 +1708,7 @@ attack_message(const troop at, const troop dt, const weapon * wp, int dist)
return smallbuf;
}
if (dist > 1 || wp->type->itype == olditemtype[I_CATAPULT]) {
if (dist > 1 || wp->type->missile) {
sprintf(smallbuf, "%s schießt mit %s auf %s",
a_unit,
locale_string(default_locale, resourcename(wp->type->itype->rtype, GR_INDEFINITE_ARTICLE)), d_unit);

View File

@ -197,10 +197,12 @@ siege_cmd(unit * u, order * ord)
static boolean init = false;
static const curse_type * magicwalls_ct;
static item_type * it_catapultammo = NULL;
static item_type * it_catapult = NULL;
if (!init) {
init = true;
magicwalls_ct = ct_find("magicwalls");
it_catapultammo = it_find("catapultammo");
it_catapult = it_find("catapult");
}
/* gibt es ueberhaupt Burgen? */
@ -220,8 +222,8 @@ siege_cmd(unit * u, order * ord)
}
/* schaden durch katapulte */
d = min(u->number,
min(get_pooled(u, it_catapultammo->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK), get_item(u, I_CATAPULT)));
d = min(u->number, i_get(u->items, it_catapult));
d = min(get_pooled(u, it_catapultammo->rtype, GET_DEFAULT), d);
if (eff_skill(u, SK_CATAPULT, r) >= 1) {
katapultiere = d;
d *= eff_skill(u, SK_CATAPULT, r);

View File

@ -47,7 +47,6 @@ extern "C" {
#define skill_t short
#define typ_t short
#define herb_t short
#define potion_t short
#define luxury_t short
#define weapon_t short
#define item_t short

View File

@ -625,31 +625,6 @@ set_item(unit * u, item_t it, int value)
return value;
}
int
change_item(unit * u, item_t it, int value)
{
const item_type * type = olditemtype[it];
item * i = *i_find(&u->items, type);
if (!i) {
if (!value) return 0;
assert(value>0);
i = i_add(&u->items, i_new(type, value));
} else {
i->number += value;
}
return i->number;
}
/*** alte potions ***/
int
get_potion(const unit * u, potion_t p)
{
const item_type * type = oldpotiontype[p]->itype;
item * it = *i_find((item**)&u->items, type);
return it?it->number:0;
}
void use_birthdayamulet(region * r, unit * magician, int amount, struct order * ord);
enum {
@ -718,10 +693,6 @@ static t_item itemdata[MAXITEMS] = {
{"Wagen", "Wagen", "Wagen", "Wagen"},
IS_PRODUCT, SK_CARTMAKER, 1, {0, 5, 0, 0, 0, 0}, 4000, 0, FL_ITEM_NOTINBAG, NULL
},
{ /* I_CATAPULT */
{"Katapult", "Katapulte", "Katapult", "Katapulte"},
IS_PRODUCT, SK_CARTMAKER, 5, {0, 10, 0, 0, 0, 0}, 10000, 0, FL_ITEM_NOTINBAG, NULL
},
{ /* I_SPEAR */
{"Speer", "Speere", "Speer", "Speere"},
IS_PRODUCT, SK_WEAPONSMITH, 2, {0, 1, 0, 0, 0, 0}, 100, 0, 0, NULL
@ -1354,7 +1325,7 @@ init_oldpotions(void)
"p0", "goliathwater", "p2", "p3", "p4", "peasantblood", "p6",
"p7", "nestwarmth", "p9", "p10", "p11", "truthpotion", "p13", "p14"
};
potion_t p;
int p;
for (p=0;p!=MAXPOTIONS;++p) {
item_type * itype = it_find(potionnames[p]);

View File

@ -262,7 +262,6 @@ enum {
I_STONE,
I_HORSE,
I_WAGON,
I_CATAPULT,
I_SPEAR,
/* alte Artefakte */
I_AMULET_OF_HEALING,
@ -301,7 +300,6 @@ enum {
R_STONE,
R_HORSE,
R_WAGON,
R_CATAPULT,
R_SPEAR,
/**/
R_AMULET_OF_HEALING,
@ -346,9 +344,6 @@ extern struct resource_type * oldresourcetype[];
int get_item(const struct unit *, item_t);
int set_item(struct unit *, item_t, int);
int change_item(struct unit *, item_t, int);
int get_potion(const struct unit *, potion_t);
int get_money(const struct unit *);
int set_money(struct unit *, int);

View File

@ -706,7 +706,7 @@ gm_addquest(const char * email, const char * name, short radius, unsigned int fl
a_add((attrib**)&a->data.v, make_atgmcreate(resource2item(r_silver)));
for (i=0;i<=I_SPEAR;++i) {
for (i=0;i<=I_WAGON;++i) {
a_add((attrib**)&a->data.v, make_atgmcreate(olditemtype[i]));
}
for (i=I_LAENSWORD;i!=I_DRACHENBLUT;++i) {
@ -771,7 +771,7 @@ gm_addfaction(const char * email, plane * p, region * r)
a_add((attrib**)&a->data.v, make_atgmcreate(resource2item(r_silver)));
for (i=0;i<=I_SPEAR;++i) {
for (i=0;i<=I_WAGON;++i) {
a_add((attrib**)&a->data.v, make_atgmcreate(olditemtype[i]));
}
for (i=I_LAENSWORD;i!=I_DRACHENBLUT;++i) {

View File

@ -559,7 +559,7 @@ update_gmquests(void)
faction * f = findfaction(atoi36("gm04"));
if (f) {
unit * u = f->units;
potion_t p;
int p;
attrib * permissions = a_find(f->attribs, &at_permissions);
if (u!=NULL) {

View File

@ -43,14 +43,14 @@ lc_age(struct attrib * a)
if (fname==NULL) return -1;
try {
luabind::object globals = luabind::get_globals(L);
luabind::object fun = globals.at(fname);
luabind::object globals = luabind::globals(L);
luabind::object fun = globals[fname];
if (!fun.is_valid()) {
log_error(("Could not index function %s\n", fname));
return -1;
}
if (fun.type()!=LUA_TFUNCTION) {
log_error(("Lua global object %s is not a function, type is %u\n", fname, fun.type()));
if (type(fun)!=LUA_TFUNCTION) {
log_error(("Lua global object %s is not a function, type is %u\n", fname, type(fun)));
return -1;
}
}

View File

@ -159,11 +159,11 @@ lua_planmonsters(void)
}
static void
race_setscript(const char * rcname, const functor<void>& f)
race_setscript(const char * rcname, const luabind::object& f)
{
race * rc = rc_find(rcname);
if (rc!=NULL) {
luabind::functor<void> * fptr = new luabind::functor<void>(f);
luabind::object * fptr = new luabind::object(f);
setscript(&rc->attribs, fptr);
}
}

View File

@ -26,8 +26,8 @@ lua_useitem(struct unit * u, const struct item_type * itype,
strcat(strcpy(fname, iname), "_use");
{
luabind::object globals = luabind::get_globals(L);
if (globals.at(fname).type()!=LUA_TFUNCTION) return -1;
luabind::object globals = luabind::globals(L);
if (type(globals[fname])!=LUA_TFUNCTION) return -1;
}
retval = luabind::call_function<int>(L, fname, *u, amount);

View File

@ -37,7 +37,7 @@ static lua_State * luaState;
static void
free_script(attrib * a) {
if (a->data.v!=NULL) {
luabind::functor<void> * f = (luabind::functor<void> *)a->data.v;
luabind::object * f = (luabind::object *)a->data.v;
delete f;
}
}
@ -54,7 +54,7 @@ call_script(struct unit * u)
const attrib * a = a_findc(u->attribs, &at_script);
if (a==NULL) a = a_findc(u->race->attribs, &at_script);
if (a!=NULL && a->data.v!=NULL) {
luabind::functor<void> * func = (luabind::functor<void> *)a->data.v;
luabind::object * func = (luabind::object *)a->data.v;
try {
func->operator()(u);
}
@ -76,7 +76,7 @@ setscript(struct attrib ** ap, void * fptr)
if (a == NULL) {
a = a_add(ap, a_new(&at_script));
} else if (a->data.v!=NULL) {
luabind::functor<void> * f = (luabind::functor<void> *)a->data.v;
luabind::object * f = (luabind::object *)a->data.v;
delete f;
}
a->data.v = fptr;
@ -116,11 +116,11 @@ lua_useitem(struct unit * u, const struct item_type * itype, int amount, struct
char fname[64];
snprintf(fname, sizeof(fname), "use_%s", itype->rtype->_name[0]);
luabind::object globals = luabind::get_globals(luaState);
luabind::object fun = globals.at(fname);
luabind::object globals = luabind::globals(luaState);
luabind::object fun = globals[fname];
if (fun.is_valid()) {
if (fun.type()!=LUA_TFUNCTION) {
log_warning(("Lua global object %s is not a function, type is %u\n", fname, fun.type()));
if (luabind::type(fun)!=LUA_TFUNCTION) {
log_warning(("Lua global object %s is not a function, type is %u\n", fname, luabind::type(fun)));
} else {
try {
retval = luabind::call_function<int>(luaState, fname, u, amount);
@ -145,11 +145,11 @@ lua_initfamiliar(unit * u)
char fname[64];
snprintf(fname, sizeof(fname), "initfamiliar_%s", u->race->_name[0]);
luabind::object globals = luabind::get_globals(luaState);
luabind::object fun = globals.at(fname);
luabind::object globals = luabind::globals(luaState);
luabind::object fun = globals[fname];
if (fun.is_valid()) {
if (fun.type()!=LUA_TFUNCTION) {
log_warning(("Lua global object %s is not a function, type is %u\n", fname, fun.type()));
if (luabind::type(fun)!=LUA_TFUNCTION) {
log_warning(("Lua global object %s is not a function, type is %u\n", fname, luabind::type(fun)));
} else {
try {
luabind::call_function<int>(luaState, fname, u);
@ -176,11 +176,11 @@ lua_changeresource(unit * u, const struct resource_type * rtype, int delta)
snprintf(fname, sizeof(fname), "%s_changeresource", rtype->_name[0]);
int retval = -1;
luabind::object globals = luabind::get_globals(luaState);
luabind::object fun = globals.at(fname);
luabind::object globals = luabind::globals(luaState);
luabind::object fun = globals[fname];
if (fun.is_valid()) {
if (fun.type()!=LUA_TFUNCTION) {
log_warning(("Lua global object %s is not a function, type is %u\n", fname, fun.type()));
if (luabind::type(fun)!=LUA_TFUNCTION) {
log_warning(("Lua global object %s is not a function, type is %u\n", fname, luabind::type(fun)));
} else {
try {
retval = luabind::call_function<int>(luaState, fname, u, delta);
@ -206,11 +206,11 @@ lua_getresource(unit * u, const struct resource_type * rtype)
snprintf(fname, sizeof(fname), "%s_getresource", rtype->_name[0]);
int retval = -1;
luabind::object globals = luabind::get_globals(luaState);
luabind::object fun = globals.at(fname);
luabind::object globals = luabind::globals(luaState);
luabind::object fun = globals[fname];
if (fun.is_valid()) {
if (fun.type()!=LUA_TFUNCTION) {
log_warning(("Lua global object %s is not a function, type is %u\n", fname, fun.type()));
if (luabind::type(fun)!=LUA_TFUNCTION) {
log_warning(("Lua global object %s is not a function, type is %u\n", fname, luabind::type(fun)));
} else {
try {
retval = luabind::call_function<int>(luaState, fname, u);

View File

@ -429,9 +429,9 @@ unit_clearorders(unit& u)
}
static void
unit_setscript(struct unit& u, const functor<void>& f)
unit_setscript(struct unit& u, const luabind::object& f)
{
luabind::functor<void> * fptr = new luabind::functor<void>(f);
luabind::object * fptr = new luabind::object(f);
setscript(&u.attribs, fptr);
}
@ -443,7 +443,7 @@ unit_weight(const struct unit& u)
typedef struct fctr_data {
unit * target;
luabind::functor<void> * fptr;
luabind::object * fptr;
} fctr_data;
#include <exception>
@ -489,9 +489,9 @@ static struct trigger_type tt_functor = {
};
static trigger *
trigger_functor(struct unit& u, const functor<void>& f)
trigger_functor(struct unit& u, const object& f)
{
luabind::functor<void> * fptr = new luabind::functor<void>(f);
luabind::object * fptr = new luabind::object(f);
trigger * t = t_new(&tt_functor);
fctr_data * td = (fctr_data*)t->data.v;
td->target = &u;
@ -500,7 +500,7 @@ trigger_functor(struct unit& u, const functor<void>& f)
}
static void
unit_addhandler(struct unit& u, const char * event, const functor<void>& f)
unit_addhandler(struct unit& u, const char * event, const object& f)
{
add_trigger(&u.attribs, event, trigger_functor(u, f));
}

View File

@ -487,14 +487,14 @@ usage(const char * prog, const char * arg)
static void
setLuaString(lua_State * luaState, const char * name, const char * value)
{
luabind::object globals = luabind::get_globals(luaState);
luabind::object globals = luabind::globals(luaState);
globals[name] = value;
}
static void
setLuaNumber(lua_State * luaState, const char * name, double value)
{
luabind::object globals = luabind::get_globals(luaState);
luabind::object globals = luabind::globals(luaState);
globals[name] = value;
}

View File

@ -156,7 +156,7 @@ give_latestart_bonus(region *r, unit *u, int b)
unit *u2 = createunit(r, u->faction, 2*b, u->race);
change_level(u2, SK_SPEAR, 3);
change_level(u2, SK_TAXING, 3);
change_item(u2, I_SPEAR, u2->number);
i_change(&u2->items, olditemtype[I_SPEAR], u2->number);
u2->irace = u->irace;
/* fset(u2, UFL_PARTEITARNUNG); */
}

View File

@ -236,6 +236,20 @@
</item>
</resource>
<resource name="catapult">
<item weight="4000">
<construction skill="cartmaking" minskill="1" reqsize="1">
<requirement type="log" quantity="5"/>
</construction>
<weapon bash="true" missile="true" skill="catapult" offmod="0" defmod="0" reload="5">
<damage type="rider" value="3d10+5"/>
<damage type="footman" value="3d10+5"/>
<modifier type="missile_target" value="4"/>
<function name="attack" value="attack_catapult"/>
</weapon>
</item>
</resource>
<resource name="crossbow">
<item weight="100">
<construction skill="weaponsmithing" minskill="3" reqsize="1">