fixing the item use functions and making future fuckups less likely

This commit is contained in:
Enno Rehling 2007-12-03 19:26:17 +00:00
parent f3098d830d
commit 09a08fb84a
15 changed files with 88 additions and 75 deletions

View File

@ -23,7 +23,6 @@
#include <items/demonseye.h>
#include <util/attrib.h>
#include <util/functions.h>
#include <util/parser.h>
#include <util/rand.h>
@ -256,11 +255,11 @@ void
register_itemfunctions(void)
{
register_demonseye();
register_function((pf_generic)use_antimagiccrystal, "use_antimagiccrystal");
register_function((pf_generic)use_instantartsculpture, "use_instantartsculpture");
register_function((pf_generic)use_studypotion, "use_studypotion");
register_function((pf_generic)use_speedsail, "use_speedsail");
register_function((pf_generic)use_instantartacademy, "use_instantartacademy");
register_function((pf_generic)use_bagpipeoffear, "use_bagpipeoffear");
register_function((pf_generic)use_aurapotion50, "use_aurapotion50");
register_item_use(use_antimagiccrystal, "use_antimagiccrystal");
register_item_use(use_instantartsculpture, "use_instantartsculpture");
register_item_use(use_studypotion, "use_studypotion");
register_item_use(use_speedsail, "use_speedsail");
register_item_use(use_instantartacademy, "use_instantartacademy");
register_item_use(use_bagpipeoffear, "use_bagpipeoffear");
register_item_use(use_aurapotion50, "use_aurapotion50");
}

View File

@ -29,7 +29,6 @@
/* util includes */
#include <util/attrib.h>
#include <util/functions.h>
#include <util/rand.h>
/* libc includes */
@ -151,7 +150,7 @@ void
register_artrewards(void)
{
at_register(&at_peaceimmune);
register_function((pf_generic)use_hornofdancing, "use_hornofdancing");
register_function((pf_generic)use_trappedairelemental, "use_trappedairelemental");
register_function((pf_generic)useonother_trappedairelemental, "useonother_trappedairelemental");
register_item_use(use_hornofdancing, "use_hornofdancing");
register_item_use(use_trappedairelemental, "use_trappedairelemental");
register_item_useonother(useonother_trappedairelemental, "useonother_trappedairelemental");
}

View File

@ -55,6 +55,6 @@ give_igjarjuk(const struct unit * src, const struct unit * d, const struct item_
void
register_demonseye(void)
{
register_function((pf_generic)summon_igjarjuk, "useigjarjuk");
register_function((pf_generic)give_igjarjuk, "giveigjarjuk");
register_item_use(summon_igjarjuk, "useigjarjuk");
register_function((pf_generic)give_igjarjuk, "giveigjarjuk");
}

View File

@ -119,6 +119,6 @@ use_phoenixcompass(struct unit * u, const struct item_type * itype,
void
register_phoenixcompass(void)
{
register_function((pf_generic)use_phoenixcompass, "use_phoenixcompass");
register_item_use(use_phoenixcompass, "use_phoenixcompass");
}

View File

@ -28,7 +28,6 @@
/* util includes */
#include <util/attrib.h>
#include <util/functions.h>
#include <util/log.h>
/* libc includes */
@ -66,5 +65,5 @@ use_speedsail(struct unit * u, const struct item_type * itype, int amount, struc
void
register_speedsail(void)
{
register_function((pf_generic)use_speedsail, "use_speedsail");
register_item_use(use_speedsail, "use_speedsail");
}

View File

@ -80,7 +80,7 @@ use_manacrystal(struct unit * u, const struct item_type * itype, int amount, str
void
register_xerewards(void)
{
register_function((pf_generic)use_skillpotion, "use_skillpotion");
register_function((pf_generic)use_manacrystal, "use_manacrystal");
register_item_use(use_skillpotion, "use_skillpotion");
register_item_use(use_manacrystal, "use_manacrystal");
}

View File

@ -21,9 +21,6 @@
#include <config.h>
#include "eressea.h"
/* modules includes */
#include <modules/xecmd.h>
/* attributes includes */
#include <attributes/reduceproduction.h>
#include <attributes/gm.h>
@ -97,6 +94,17 @@ const struct race * new_race[MAXRACES];
boolean sqlpatch = false;
int turn;
#ifdef XECMD_MODULE
attrib_type at_xontormiaexpress = {
"xontormiaexpress",
DEFAULT_INIT,
DEFAULT_FINALIZE,
DEFAULT_AGE,
a_writeint,
a_readint,
ATF_UNIQUE
};
#endif
int
NewbieImmunity(void) {
static int value = -1;
@ -1920,24 +1928,6 @@ gc_add(void * p)
return p;
}
void
use_birthdayamulet(region * r, unit * magician, order * ord)
{
region *tr;
direction_t d;
message * msg = msg_message("meow", "");
unused(ord);
unused(magician);
add_message(&r->msgs, msg);
for(d=0;d<MAXDIRECTIONS;d++) {
tr = rconnect(r, d);
if (tr) add_message(&tr->msgs, msg);
}
msg_release(msg);
}
static void
init_directions(tnode * root, const struct locale * lang)
{

View File

@ -421,6 +421,10 @@ extern struct attrib_type at_guard;
# define count_unit(u) 1
#endif
#ifdef XECMD_MODULE
extern struct attrib_type at_xontormiaexpress;
#endif
#ifdef __cplusplus
}
#endif

View File

@ -628,7 +628,25 @@ set_item(unit * u, item_t it, int value)
return value;
}
void use_birthdayamulet(region * r, unit * magician, int amount, struct order * ord);
static int
use_birthdayamulet(unit * u, const struct item_type * itype, int amount, struct order * ord)
{
direction_t d;
message * msg = msg_message("meow", "");
unused(ord);
unused(amount);
unused(itype);
add_message(&u->region->msgs, msg);
for(d=0;d<MAXDIRECTIONS;d++) {
region * tr = rconnect(u->region, d);
if (tr) add_message(&tr->msgs, msg);
}
msg_release(msg);
return 0;
}
/* t_item::flags */
#define FL_ITEM_CURSED (1<<0)
@ -640,8 +658,8 @@ void use_birthdayamulet(region * r, unit * magician, int amount, struct order *
/* ------------------------------------------------------------- */
/* Kann auch von Nichtmagier benutzt werden, modifiziert Taktik für diese
* Runde um -1 - 4 Punkte. */
static void
use_tacticcrystal(region * r, unit * u, int amount, struct order * ord)
static int
use_tacticcrystal(unit * u, const struct item_type * itype, int amount, struct order * ord)
{
int i;
for (i=0;i!=amount;++i) {
@ -658,10 +676,10 @@ use_tacticcrystal(region * r, unit * u, int amount, struct order * ord)
c->data.i = SK_TACTICS;
unused(ord);
}
use_pooled(u, oldresourcetype[R_TACTICCRYSTAL], GET_DEFAULT, amount);
use_pooled(u, itype->rtype, GET_DEFAULT, amount);
ADDMSG(&u->faction->msgs, msg_message("use_tacticcrystal",
"unit region", u, r));
return;
"unit region", u, u->region));
return 0;
}
typedef struct t_item {
@ -729,6 +747,18 @@ heal(unit * user, int effect)
return effect;
}
void
register_item_use(int (*foo) (struct unit *, const struct item_type *, int, struct order *), const char * name)
{
register_function((pf_generic)foo, name);
}
void
register_item_useonother(int (*foo) (struct unit *, int, const struct item_type *, int, struct order *), const char * name)
{
register_function((pf_generic)foo, name);
}
static int
use_healingpotion(struct unit *user, const struct item_type *itype, int amount, struct order * ord)
{
@ -1104,16 +1134,16 @@ register_resources(void)
register_function((pf_generic)res_changehp, "changehp");
register_function((pf_generic)res_changeaura, "changeaura");
register_function((pf_generic)use_potion, "usepotion");
register_function((pf_generic)use_tacticcrystal, "use_tacticcrystal");
register_function((pf_generic)use_birthdayamulet, "use_birthdayamulet");
register_function((pf_generic)use_warmthpotion, "usewarmthpotion");
register_function((pf_generic)use_bloodpotion, "usebloodpotion");
register_function((pf_generic)use_healingpotion, "usehealingpotion");
register_function((pf_generic)use_foolpotion, "usefoolpotion");
register_function((pf_generic)use_mistletoe, "usemistletoe");
register_function((pf_generic)use_magicboost, "usemagicboost");
register_function((pf_generic)use_snowball, "usesnowball");
register_item_use(use_potion, "usepotion");
register_item_use(use_tacticcrystal, "use_tacticcrystal");
register_item_use(use_birthdayamulet, "use_birthdayamulet");
register_item_use(use_warmthpotion, "usewarmthpotion");
register_item_use(use_bloodpotion, "usebloodpotion");
register_item_use(use_healingpotion, "usehealingpotion");
register_item_useonother(use_foolpotion, "usefoolpotion");
register_item_use(use_mistletoe, "usemistletoe");
register_item_use(use_magicboost, "usemagicboost");
register_item_use(use_snowball, "usesnowball");
register_function((pf_generic)give_horses, "givehorses");

View File

@ -333,6 +333,9 @@ extern struct attrib_type at_seenitem; /* knows this potion's description, no ne
extern void register_resources(void);
extern void init_resources(void);
extern void register_item_use(int (*foo) (struct unit *, const struct item_type *, int, struct order *), const char * name);
extern void register_item_useonother(int (*foo) (struct unit *, int, const struct item_type *, int, struct order *), const char * name);
extern struct item_type *i_silver;
#ifdef __cplusplus

View File

@ -519,11 +519,11 @@ create_arena(void)
void
register_arena(void)
{
at_register(&at_hurting);
register_function((pf_generic)use_wand_of_tears, "use_wand_of_tears");
register_function((pf_generic)enter_arena, "enter_arena");
register_function((pf_generic)leave_arena, "leave_arena");
tt_register(&tt_caldera);
at_register(&at_hurting);
register_item_use(use_wand_of_tears, "use_wand_of_tears");
register_function((pf_generic)enter_arena, "enter_arena");
register_function((pf_generic)leave_arena, "leave_arena");
tt_register(&tt_caldera);
}
#endif /* def ARENA_MODULE */

View File

@ -384,8 +384,8 @@ register_museum(void)
at_register(&at_museumgivebackcookie);
at_register(&at_museumgiveback);
register_function((pf_generic)use_museumticket, "use_museumticket");
register_function((pf_generic)use_museumexitticket, "use_museumexitticket");
register_item_use(use_museumticket, "use_museumticket");
register_item_use(use_museumexitticket, "use_museumexitticket");
}
#endif

View File

@ -39,16 +39,6 @@
#include <stdlib.h>
#include <string.h>
attrib_type at_xontormiaexpress = {
"xontormiaexpress",
DEFAULT_INIT,
DEFAULT_FINALIZE,
DEFAULT_AGE,
a_writeint,
a_readint,
ATF_UNIQUE
};
static void
xe_givelaen(unit *u, struct order * ord)
{

View File

@ -17,7 +17,6 @@ extern "C" {
#endif
#ifdef XECMD_MODULE
extern struct attrib_type at_xontormiaexpress;
int xecmd(struct unit * u, struct order * ord);
#endif

View File

@ -334,7 +334,7 @@ bind_script(lua_State * L)
{
register_function((pf_generic)&lua_callspell, "lua_castspell");
register_function((pf_generic)&lua_initfamiliar, "lua_initfamiliar");
register_function((pf_generic)&lua_useitem, "lua_useitem");
register_item_use(&lua_useitem, "lua_useitem");
register_function((pf_generic)&lua_getresource, "lua_getresource");
register_function((pf_generic)&lua_changeresource, "lua_changeresource");
register_function((pf_generic)&lua_equipmentcallback, "lua_equip");