bugfix seed-registrierung

This commit is contained in:
Enno Rehling 2005-10-26 19:02:45 +00:00
parent b19c4f5cc6
commit 0e0f37d970
8 changed files with 41 additions and 20 deletions

View File

@ -258,7 +258,7 @@ use_aurapotion50(struct unit * u, const struct item_type * itype,
void
register_itemimplementations(void)
register_itemfunctions(void)
{
register_function((pf_generic)use_antimagiccrystal, "use_antimagiccrystal");
register_function((pf_generic)use_instantartsculpture, "use_instantartsculpture");

View File

@ -16,8 +16,7 @@ without prior permission by the authors of Eressea.
extern "C" {
#endif
extern void register_itemimplementations(void);
extern void init_itemimplementations(void);
extern void register_itemfunctions(void);
#ifdef __cplusplus
}

View File

@ -21,18 +21,13 @@
#include "seed.h"
void
register_itemtypes(void)
init_itemtypes(void)
{
register_weapons();
register_demonseye();
register_xerewards();
register_artrewards();
init_weapons();
register_seed();
register_mallornseed();
register_artrewards();
}
void
init_itemtypes(void)
{
init_weapons();
}

View File

@ -16,7 +16,6 @@
extern "C" {
#endif
extern void register_itemtypes(void);
extern void init_itemtypes(void);
#ifdef __cplusplus

View File

@ -83,6 +83,36 @@ init_familiar(unit * u)
equip_unit(u, get_equipment(fname));
}
static int
use_item(struct unit * u, const struct item_type * itype, int amount, struct order * ord)
{
int retval = 0;
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);
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()));
} else {
try {
retval = luabind::call_function<int>(luaState, fname, u, amount);
}
catch (luabind::error& e) {
lua_State* L = e.state();
const char* error = lua_tostring(L, -1);
log_error(("An exception occured while %s tried to call '%s': %s.\n",
unitname(u), fname, error));
lua_pop(L, 1);
std::terminate();
}
}
}
return retval;
}
void
bind_spell(lua_State * L)
{
@ -95,4 +125,5 @@ bind_spell(lua_State * L)
];
register_function((pf_generic)&call_spell, "luaspell");
register_function((pf_generic)&init_familiar, "luafamiliar");
register_function((pf_generic)&use_item, "luaitem");
}

View File

@ -156,8 +156,7 @@ game_init(void)
register_resources();
register_buildings();
register_ships();
register_itemimplementations();
register_itemtypes();
register_itemfunctions();
register_spells();
#ifdef DUNGEON_MODULE
register_dungeon();

View File

@ -209,8 +209,7 @@ game_init(void)
register_resources();
register_buildings();
register_ships();
register_itemimplementations();
register_itemtypes();
register_itemfunctions();
register_spells();
#ifdef DUNGEON_MODULE
register_dungeon();

View File

@ -1643,7 +1643,6 @@ main(int argc, char *argv[])
register_resources();
register_buildings();
register_ships();
register_itemtypes();
register_spells();
#ifdef MUSEUM_MODULE
register_museum();