From dfc6f83c62b616ed5d4e2b7b2656cc76f52f12b5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 31 Oct 2005 22:34:45 +0000 Subject: [PATCH] upgrade to luabind beta-7 devel-2 upgrade to g++ 4.0 --- src/Jamrules | 12 +++++------ src/common/gamecode/economy.c | 2 +- src/common/gamecode/laws.c | 2 +- src/common/gamecode/randenc.c | 2 +- src/common/items/weapons.c | 34 ++++++++----------------------- src/common/kernel/battle.c | 2 +- src/common/kernel/build.c | 6 ++++-- src/common/kernel/eressea.h | 1 - src/common/kernel/item.c | 31 +--------------------------- src/common/kernel/item.h | 5 ----- src/common/modules/gmcmd.c | 4 ++-- src/eressea/korrektur.c | 2 +- src/eressea/lua/building.cpp | 8 ++++---- src/eressea/lua/eressea.cpp | 4 ++-- src/eressea/lua/item.cpp | 4 ++-- src/eressea/lua/script.cpp | 38 +++++++++++++++++------------------ src/eressea/lua/unit.cpp | 12 +++++------ src/eressea/server.cpp | 4 ++-- src/mapper/map_partei.c | 2 +- src/res/resources.xml | 14 +++++++++++++ 20 files changed, 76 insertions(+), 113 deletions(-) diff --git a/src/Jamrules b/src/Jamrules index b62dde115..d929d2ebb 100644 --- a/src/Jamrules +++ b/src/Jamrules @@ -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) ; diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index 10d56a963..8431b80df 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -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++; } } diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index b124cdb58..06aef5518 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -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) { diff --git a/src/common/gamecode/randenc.c b/src/common/gamecode/randenc.c index 03d6ce713..fa2976642 100644 --- a/src/common/gamecode/randenc.c +++ b/src/common/gamecode/randenc.c @@ -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; diff --git a/src/common/items/weapons.c b/src/common/items/weapons.c index 842071fdc..dc9dc4242 100644 --- a/src/common/items/weapons.c +++ b/src/common/items/weapons.c @@ -30,11 +30,6 @@ #include #include -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(); } diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index 10e8b28db..6a624b881 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -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); diff --git a/src/common/kernel/build.c b/src/common/kernel/build.c index a0c0bc5af..b6b4e93f4 100644 --- a/src/common/kernel/build.c +++ b/src/common/kernel/build.c @@ -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); diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index 973d00ac4..0cb29d82c 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -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 diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index 7e6cf75c8..5acda932e 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -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]); diff --git a/src/common/kernel/item.h b/src/common/kernel/item.h index adbaa5879..336f61642 100644 --- a/src/common/kernel/item.h +++ b/src/common/kernel/item.h @@ -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); diff --git a/src/common/modules/gmcmd.c b/src/common/modules/gmcmd.c index 27b704f1a..f37b0afc2 100644 --- a/src/common/modules/gmcmd.c +++ b/src/common/modules/gmcmd.c @@ -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) { diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c index d27cb906d..9a3f41796 100644 --- a/src/eressea/korrektur.c +++ b/src/eressea/korrektur.c @@ -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) { diff --git a/src/eressea/lua/building.cpp b/src/eressea/lua/building.cpp index 12389d090..dc840944b 100644 --- a/src/eressea/lua/building.cpp +++ b/src/eressea/lua/building.cpp @@ -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; } } diff --git a/src/eressea/lua/eressea.cpp b/src/eressea/lua/eressea.cpp index dfcf3cc69..dafa59757 100644 --- a/src/eressea/lua/eressea.cpp +++ b/src/eressea/lua/eressea.cpp @@ -159,11 +159,11 @@ lua_planmonsters(void) } static void -race_setscript(const char * rcname, const functor& f) +race_setscript(const char * rcname, const luabind::object& f) { race * rc = rc_find(rcname); if (rc!=NULL) { - luabind::functor * fptr = new luabind::functor(f); + luabind::object * fptr = new luabind::object(f); setscript(&rc->attribs, fptr); } } diff --git a/src/eressea/lua/item.cpp b/src/eressea/lua/item.cpp index 93487e7bf..46794b476 100644 --- a/src/eressea/lua/item.cpp +++ b/src/eressea/lua/item.cpp @@ -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(L, fname, *u, amount); diff --git a/src/eressea/lua/script.cpp b/src/eressea/lua/script.cpp index b080c6e91..f207e3163 100644 --- a/src/eressea/lua/script.cpp +++ b/src/eressea/lua/script.cpp @@ -37,7 +37,7 @@ static lua_State * luaState; static void free_script(attrib * a) { if (a->data.v!=NULL) { - luabind::functor * f = (luabind::functor *)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 * func = (luabind::functor *)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 * f = (luabind::functor *)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(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(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(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(luaState, fname, u); diff --git a/src/eressea/lua/unit.cpp b/src/eressea/lua/unit.cpp index 94bc2c0e0..89e432867 100644 --- a/src/eressea/lua/unit.cpp +++ b/src/eressea/lua/unit.cpp @@ -429,9 +429,9 @@ unit_clearorders(unit& u) } static void -unit_setscript(struct unit& u, const functor& f) +unit_setscript(struct unit& u, const luabind::object& f) { - luabind::functor * fptr = new luabind::functor(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 * fptr; + luabind::object * fptr; } fctr_data; #include @@ -489,9 +489,9 @@ static struct trigger_type tt_functor = { }; static trigger * -trigger_functor(struct unit& u, const functor& f) +trigger_functor(struct unit& u, const object& f) { - luabind::functor * fptr = new luabind::functor(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& f) } static void -unit_addhandler(struct unit& u, const char * event, const functor& f) +unit_addhandler(struct unit& u, const char * event, const object& f) { add_trigger(&u.attribs, event, trigger_functor(u, f)); } diff --git a/src/eressea/server.cpp b/src/eressea/server.cpp index 3b049aa52..fc784e120 100644 --- a/src/eressea/server.cpp +++ b/src/eressea/server.cpp @@ -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; } diff --git a/src/mapper/map_partei.c b/src/mapper/map_partei.c index 16e4a1cdf..0900b7e0b 100644 --- a/src/mapper/map_partei.c +++ b/src/mapper/map_partei.c @@ -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); */ } diff --git a/src/res/resources.xml b/src/res/resources.xml index 27179e4f7..655035fae 100644 --- a/src/res/resources.xml +++ b/src/res/resources.xml @@ -236,6 +236,20 @@ + + + + + + + + + + + + + +