forked from github/server
bugfix seed-registrierung
This commit is contained in:
parent
b19c4f5cc6
commit
0e0f37d970
8 changed files with 41 additions and 20 deletions
|
@ -258,7 +258,7 @@ use_aurapotion50(struct unit * u, const struct item_type * itype,
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
register_itemimplementations(void)
|
register_itemfunctions(void)
|
||||||
{
|
{
|
||||||
register_function((pf_generic)use_antimagiccrystal, "use_antimagiccrystal");
|
register_function((pf_generic)use_antimagiccrystal, "use_antimagiccrystal");
|
||||||
register_function((pf_generic)use_instantartsculpture, "use_instantartsculpture");
|
register_function((pf_generic)use_instantartsculpture, "use_instantartsculpture");
|
||||||
|
|
|
@ -16,8 +16,7 @@ without prior permission by the authors of Eressea.
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void register_itemimplementations(void);
|
extern void register_itemfunctions(void);
|
||||||
extern void init_itemimplementations(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,19 +20,14 @@
|
||||||
#include "weapons.h"
|
#include "weapons.h"
|
||||||
#include "seed.h"
|
#include "seed.h"
|
||||||
|
|
||||||
void
|
|
||||||
register_itemtypes(void)
|
|
||||||
{
|
|
||||||
register_weapons();
|
|
||||||
register_demonseye();
|
|
||||||
register_xerewards();
|
|
||||||
register_seed();
|
|
||||||
register_mallornseed();
|
|
||||||
register_artrewards();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
init_itemtypes(void)
|
init_itemtypes(void)
|
||||||
{
|
{
|
||||||
|
register_weapons();
|
||||||
|
register_demonseye();
|
||||||
|
register_xerewards();
|
||||||
|
register_artrewards();
|
||||||
init_weapons();
|
init_weapons();
|
||||||
|
register_seed();
|
||||||
|
register_mallornseed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void register_itemtypes(void);
|
|
||||||
extern void init_itemtypes(void);
|
extern void init_itemtypes(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -83,6 +83,36 @@ init_familiar(unit * u)
|
||||||
equip_unit(u, get_equipment(fname));
|
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
|
void
|
||||||
bind_spell(lua_State * L)
|
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)&call_spell, "luaspell");
|
||||||
register_function((pf_generic)&init_familiar, "luafamiliar");
|
register_function((pf_generic)&init_familiar, "luafamiliar");
|
||||||
|
register_function((pf_generic)&use_item, "luaitem");
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,8 +156,7 @@ game_init(void)
|
||||||
register_resources();
|
register_resources();
|
||||||
register_buildings();
|
register_buildings();
|
||||||
register_ships();
|
register_ships();
|
||||||
register_itemimplementations();
|
register_itemfunctions();
|
||||||
register_itemtypes();
|
|
||||||
register_spells();
|
register_spells();
|
||||||
#ifdef DUNGEON_MODULE
|
#ifdef DUNGEON_MODULE
|
||||||
register_dungeon();
|
register_dungeon();
|
||||||
|
|
|
@ -209,8 +209,7 @@ game_init(void)
|
||||||
register_resources();
|
register_resources();
|
||||||
register_buildings();
|
register_buildings();
|
||||||
register_ships();
|
register_ships();
|
||||||
register_itemimplementations();
|
register_itemfunctions();
|
||||||
register_itemtypes();
|
|
||||||
register_spells();
|
register_spells();
|
||||||
#ifdef DUNGEON_MODULE
|
#ifdef DUNGEON_MODULE
|
||||||
register_dungeon();
|
register_dungeon();
|
||||||
|
|
|
@ -1643,7 +1643,6 @@ main(int argc, char *argv[])
|
||||||
register_resources();
|
register_resources();
|
||||||
register_buildings();
|
register_buildings();
|
||||||
register_ships();
|
register_ships();
|
||||||
register_itemtypes();
|
|
||||||
register_spells();
|
register_spells();
|
||||||
#ifdef MUSEUM_MODULE
|
#ifdef MUSEUM_MODULE
|
||||||
register_museum();
|
register_museum();
|
||||||
|
|
Loading…
Reference in a new issue