MACHEN Adamantium

- Adamantium and Laen require a mine (and this is now a xml-configuration)
- everything compiles with the latest luabind/boost/lua version
- fixed a broken assert
This commit is contained in:
Enno Rehling 2008-10-31 17:50:19 +00:00
parent 12574ac5b5
commit d305e983b2
7 changed files with 37 additions and 29 deletions

View File

@ -1348,20 +1348,25 @@ allocate_resource(unit * u, const resource_type * rtype, int want)
}
}
if (itype == olditemtype[I_LAEN]) {
struct building * b = inside_building(u);
const struct building_type * btype = b?b->type:NULL;
if (btype != bt_find("mine")) {
cmistake(u, u->thisorder, 104, MSG_PRODUCE);
return;
}
}
if (besieged(u)) {
cmistake(u, u->thisorder, 60, MSG_PRODUCE);
return;
}
if (rdata->modifiers) {
resource_mod * mod = rdata->modifiers;
for (;mod->flags!=0;++mod) {
if (mod->flags & RMF_REQUIREDBUILDING) {
struct building * b = inside_building(u);
const struct building_type * btype = b?b->type:NULL;
if (mod->btype && mod->btype!=btype) {
cmistake(u, u->thisorder, 104, MSG_PRODUCE);
return;
}
}
}
}
if (rdata->guard!=0) {
unit * u2;
for (u2 = r->units; u2; u2 = u2->next) {
@ -1472,21 +1477,6 @@ allocate_resource(unit * u, const resource_type * rtype, int want)
}
}
}
} else if (itype==olditemtype[I_IRON]) {
struct building * b = inside_building(u);
const struct building_type * btype = b?b->type:NULL;
if (btype==bt_find("mine"))
al->save *= 0.5;
if (u->race == new_race[RC_DWARF]) {
al->save *= 0.75;
}
} else if (itype==olditemtype[I_STONE]) {
struct building * b = inside_building(u);
const struct building_type * btype = b?b->type:NULL;
if (btype==bt_find("quarry"))
al->save = al->save*0.5;
if (u->race == new_race[RC_TROLL])
al->save = al->save*0.75;
}
}

View File

@ -78,6 +78,8 @@ extern const resource_type * findresourcetype(const char * name, const struct lo
#define RMF_SKILL 0x01 /* int, bonus on resource production skill */
#define RMF_SAVEMATERIAL 0x02 /* float, multiplier on resource usage */
#define RMF_SAVERESOURCE 0x03 /* int, bonus on resource production skill */
#define RMF_REQUIREDBUILDING 0x04 /* building, required to build */
typedef struct resource_mod {
variant value;
const struct building_type * btype;

View File

@ -1053,7 +1053,7 @@ set_number(unit * u, int count)
u->faction->num_people += count - u->number;
}
u->number = (unsigned short)count;
} else {
} else if (u->number>0) {
assert(!"why doesn't this unit have a faction? this will fuck up num_people");
}
}

View File

@ -1038,13 +1038,26 @@ parse_resources(xmlDocPtr doc)
assert(propValue!=NULL);
if (strcmp((const char *)propValue, "skill")==0) {
rdata->modifiers[k].value.i = xml_ivalue(node, "value", 0);
rdata->modifiers[k].flags |= RMF_SKILL;
rdata->modifiers[k].flags = RMF_SKILL;
} else if (strcmp((const char *)propValue, "material")==0) {
rdata->modifiers[k].value.f = (float)xml_fvalue(node, "value", 0);
rdata->modifiers[k].flags |= RMF_SAVEMATERIAL;
rdata->modifiers[k].flags = RMF_SAVEMATERIAL;
} else if (strcmp((const char *)propValue, "resource")==0) {
rdata->modifiers[k].value.f = (float)xml_fvalue(node, "value", 0);
rdata->modifiers[k].flags |= RMF_SAVERESOURCE;
rdata->modifiers[k].flags = RMF_SAVERESOURCE;
} else if (strcmp((const char *)propValue, "require")==0) {
xmlChar * propBldg = xmlGetProp(node, BAD_CAST "building");
if (propBldg!=NULL) {
btype = bt_find((const char*)propBldg);
if (btype==NULL) {
btype = calloc(sizeof(building_type), 1);
btype->_name = strdup((const char *)propBldg);
bt_register(btype);
}
rdata->modifiers[k].btype = btype;
rdata->modifiers[k].flags = RMF_REQUIREDBUILDING;
xmlFree(propBldg);
}
} else {
log_error(("unknown type '%s' for resourcelimit-modifier '%s'\n",
(const char*)propValue, rtype->_name[0]));

View File

@ -19,6 +19,7 @@ namespace eressea {
class iterator {
public:
iterator(const N& index) : m_index(index) {}
~iterator() {}
T operator*() { return nodetype::value(m_index); }
bool operator==(const iterator& iter) {
return iter.m_index==m_index;

View File

@ -169,6 +169,7 @@
<construction skill="mining" minskill="8" reqsize="1"/>
</item>
<resourcelimit>
<modifier type="require" building="mine"/>
<guard flag="mining"/>
</resourcelimit>
</resource>

View File

@ -96,6 +96,7 @@
<construction skill="mining" minskill="7" reqsize="1"/>
</item>
<resourcelimit>
<modifier type="require" building="mine"/>
<guard flag="mining"/>
</resourcelimit>
</resource>