forked from github/server
compiles, test fails, xmlreader includes need fixing
This commit is contained in:
parent
3d69f4e372
commit
2b2a79620c
|
@ -434,3 +434,17 @@ int change_effect(unit * u, const item_type * effect, int delta)
|
|||
log_error("change effect with delta==0 for unit %s\n", itoa36(u->no));
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool display_potions(struct unit *u)
|
||||
{
|
||||
int skill = effskill(u, SK_ALCHEMY, 0);
|
||||
int c = 0;
|
||||
const potion_type *ptype;
|
||||
for (ptype = potiontypes; ptype != NULL; ptype = ptype->next) {
|
||||
if (ptype->level * 2 <= skill) {
|
||||
show_item(u, ptype->itype);
|
||||
++c;
|
||||
}
|
||||
}
|
||||
return (c > 0);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#ifndef H_KRNL_ALCHEMY_H
|
||||
#define H_KRNL_ALCHEMY_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -68,8 +70,9 @@ extern "C" {
|
|||
int get_effect(const struct unit *u, const struct item_type *effect);
|
||||
int change_effect(struct unit *u, const struct item_type *effect,
|
||||
int value);
|
||||
bool display_potions(struct unit *u);
|
||||
|
||||
/* rausnehmen, sobald man attribute splitten kann: */
|
||||
/* TODO: rausnehmen, sobald man attribute splitten kann: */
|
||||
typedef struct effect_data {
|
||||
const struct item_type *type;
|
||||
int value;
|
||||
|
|
|
@ -980,3 +980,18 @@ void register_resources(void)
|
|||
register_function((pf_generic)res_changehp, "changehp");
|
||||
register_function((pf_generic)res_changeaura, "changeaura");
|
||||
}
|
||||
|
||||
void show_item(unit * u, const item_type * itype)
|
||||
{
|
||||
faction * f = u->faction;
|
||||
attrib *a;
|
||||
|
||||
a = a_find(f->attribs, &at_showitem);
|
||||
while (a && a->data.v != itype)
|
||||
a = a->next;
|
||||
if (!a) {
|
||||
a = a_add(&f->attribs, a_new(&at_showitem));
|
||||
a->data.v = (void *)itype;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -276,6 +276,10 @@ extern "C" {
|
|||
} resource_t;
|
||||
|
||||
extern const struct item_type *oldpotiontype[];
|
||||
extern struct attrib_type at_showitem; /* show this potion's description */
|
||||
|
||||
void show_item(struct unit * u, const struct item_type * itype);
|
||||
|
||||
const struct resource_type *get_resourcetype(resource_t rt);
|
||||
struct item *item_spoil(const struct race *rc, int size);
|
||||
|
||||
|
@ -285,8 +289,6 @@ extern "C" {
|
|||
int set_money(struct unit *, int);
|
||||
int change_money(struct unit *, int);
|
||||
|
||||
extern struct attrib_type at_showitem; /* show this potion's description */
|
||||
|
||||
void register_resources(void);
|
||||
void init_resources(void);
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@ without prior permission by the authors of Eressea.
|
|||
#include "prefix.h"
|
||||
#include "move.h"
|
||||
|
||||
/* TODO: core code should not include these files: */
|
||||
#include "alchemy.h"
|
||||
#include "vortex.h"
|
||||
|
||||
#include <modules/score.h>
|
||||
|
@ -483,12 +485,11 @@ static int parse_ships(xmlDocPtr doc)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static potion_type *xml_readpotion(xmlXPathContextPtr xpath, item_type * itype)
|
||||
static void xml_readpotion(xmlXPathContextPtr xpath, item_type * itype)
|
||||
{
|
||||
int level = xml_ivalue(xpath->node, "level", 0);
|
||||
|
||||
assert(level > 0);
|
||||
return new_potiontype(itype, level);
|
||||
new_potiontype(itype, level);
|
||||
}
|
||||
|
||||
static luxury_type *xml_readluxury(xmlXPathContextPtr xpath, item_type * itype)
|
||||
|
@ -741,7 +742,7 @@ static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype)
|
|||
itype->flags |= ITF_CANUSE;
|
||||
}
|
||||
xpath->node = result->nodesetval->nodeTab[0];
|
||||
rtype->ptype = xml_readpotion(xpath, itype);
|
||||
xml_readpotion(xpath, itype);
|
||||
}
|
||||
xmlXPathFreeObject(result);
|
||||
|
||||
|
|
32
src/laws.c
32
src/laws.c
|
@ -2234,6 +2234,10 @@ int send_cmd(unit * u, struct order *ord)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void display_potion(unit * u, const item_type * itype) {
|
||||
show_item(u, itype);
|
||||
}
|
||||
|
||||
static void display_item(unit * u, const item_type * itype)
|
||||
{
|
||||
faction * f = u->faction;
|
||||
|
@ -2252,20 +2256,6 @@ static void display_item(unit * u, const item_type * itype)
|
|||
itype->weight, itype->rtype, info));
|
||||
}
|
||||
|
||||
static void display_potion(unit * u, const item_type * itype)
|
||||
{
|
||||
faction * f = u->faction;
|
||||
attrib *a;
|
||||
|
||||
a = a_find(f->attribs, &at_showitem);
|
||||
while (a && a->data.v != itype)
|
||||
a = a->next;
|
||||
if (!a) {
|
||||
a = a_add(&f->attribs, a_new(&at_showitem));
|
||||
a->data.v = (void *)itype;
|
||||
}
|
||||
}
|
||||
|
||||
static void display_race(unit * u, const race * rc)
|
||||
{
|
||||
faction * f = u->faction;
|
||||
|
@ -2466,20 +2456,6 @@ static void reshow_other(unit * u, struct order *ord, const char *s) {
|
|||
cmistake(u, ord, err, MSG_EVENT);
|
||||
}
|
||||
|
||||
bool display_potions(unit *u)
|
||||
{
|
||||
int skill = effskill(u, SK_ALCHEMY, 0);
|
||||
int c = 0;
|
||||
const potion_type *ptype;
|
||||
for (ptype = potiontypes; ptype != NULL; ptype = ptype->next) {
|
||||
if (ptype->level * 2 <= skill) {
|
||||
display_potion(u, ptype);
|
||||
++c;
|
||||
}
|
||||
}
|
||||
return (c > 0);
|
||||
}
|
||||
|
||||
static void reshow(unit * u, struct order *ord, const char *s, param_t p)
|
||||
{
|
||||
switch (p) {
|
||||
|
|
Loading…
Reference in New Issue