forked from github/server
limit equipment names to 15 byte plus nul.
This commit is contained in:
parent
6ab35d80d0
commit
e2f6ada862
|
@ -69,7 +69,7 @@
|
|||
</set>
|
||||
|
||||
<!-- equipment-sets for random encounters -->
|
||||
<set name="random_desert">
|
||||
<set name="rand_desert">
|
||||
<skill name="melee" level="d2"/>
|
||||
<skill name="trade" level="d3"/>
|
||||
<skill name="riding" level="d2+1"/>
|
||||
|
@ -79,53 +79,53 @@
|
|||
<item name="money" amount="d30+19"/>
|
||||
</set>
|
||||
|
||||
<set name="random_swamp">
|
||||
<set name="rand_swamp">
|
||||
<skill name="stealth" level="d3+1"/>
|
||||
<skill name="polearm" level="d3+1"/>
|
||||
<item name="spear" amount="1"/>
|
||||
<item name="money" amount="d20+9"/>
|
||||
</set>
|
||||
|
||||
<set name="random_glacier">
|
||||
<set name="rand_glacier">
|
||||
<skill name="armorer" level="d2+1"/>
|
||||
<skill name="melee" level="d2+1"/>
|
||||
<item name="sword" amount="1"/>
|
||||
<item name="money" amount="d20+19"/>
|
||||
</set>
|
||||
|
||||
<set name="random_mountain">
|
||||
<set name="rand_mountain">
|
||||
<skill name="armorer" level="d2+1"/>
|
||||
<skill name="melee" level="d2+1"/>
|
||||
<skill name="trade" level="d3"/>
|
||||
<item name="sword" amount="1"/>
|
||||
<item name="money" amount="d40+59"/>
|
||||
<subset chance="0.6">
|
||||
<set name="item_plate"/>
|
||||
<set name="i_plate"/>
|
||||
</subset>
|
||||
</set>
|
||||
|
||||
<set name="random_highland">
|
||||
<set name="rand_highland">
|
||||
<skill name="melee" level="d2"/>
|
||||
<item name="sword" amount="1"/>
|
||||
<item name="money" amount="d10+19"/>
|
||||
</set>
|
||||
|
||||
<set name="random_forest">
|
||||
<set name="rand_forest">
|
||||
<skill name="stealth" level="d2"/>
|
||||
<skill name="perception" level="d2+1"/>
|
||||
<skill name="bow" level="d3+1"/>
|
||||
<item name="bow" amount="1"/>
|
||||
<item name="money" amount="d20+9"/>
|
||||
<subset chance="0.2">
|
||||
<set name="random_herbalist"/>
|
||||
<set name="rand_herbalist"/>
|
||||
</subset>
|
||||
</set>
|
||||
|
||||
<set name="random_herbalist">
|
||||
<set name="rand_herbalist">
|
||||
<skill name="herbalism" level="d2"/>
|
||||
</set>
|
||||
|
||||
<set name="random_villagers">
|
||||
<set name="rand_villagers">
|
||||
<item name="money" amount="d80+19"/>
|
||||
<skill name="cartmaking" level="d2-1"/>
|
||||
<skill name="mining" level="d2-1"/>
|
||||
|
@ -136,43 +136,43 @@
|
|||
<item name="money" amount="d30+10"/>
|
||||
</set>
|
||||
|
||||
<set name="random_plain">
|
||||
<set name="rand_plain">
|
||||
<item name="money" amount="d80+19"/>
|
||||
<subset>
|
||||
<set name="random_sword" chance="0.25"/>
|
||||
<set name="random_spear" chance="0.25"/>
|
||||
<set name="random_crossbow" chance="0.25"/>
|
||||
<set name="random_bow" chance="0.25"/>
|
||||
<set name="rand_sword" chance="0.25"/>
|
||||
<set name="rand_spear" chance="0.25"/>
|
||||
<set name="rand_crossbow" chance="0.25"/>
|
||||
<set name="rand_bow" chance="0.25"/>
|
||||
</subset>
|
||||
<subset chance="0.4">
|
||||
<set name="item_chain"/>
|
||||
<set name="i_chain"/>
|
||||
</subset>
|
||||
<subset chance="0.3">
|
||||
<set name="random_rider"/>
|
||||
<set name="rand_rider"/>
|
||||
</subset>
|
||||
</set>
|
||||
|
||||
<set name="random_spear">
|
||||
<set name="rand_spear">
|
||||
<skill name="polearm" level="d3"/>
|
||||
<item name="spear" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="random_sword">
|
||||
<set name="rand_sword">
|
||||
<skill name="melee" level="d3"/>
|
||||
<item name="sword" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="random_crossbow">
|
||||
<set name="rand_crossbow">
|
||||
<skill name="crossbow" level="d3"/>
|
||||
<item name="crossbow" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="random_bow">
|
||||
<set name="rand_bow">
|
||||
<skill name="bow" level="d3"/>
|
||||
<item name="bow" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="random_rider">
|
||||
<set name="rand_rider">
|
||||
<item name="horse" amount="1"/>
|
||||
<skill name="riding" level="d3"/>
|
||||
</set>
|
||||
|
@ -184,9 +184,9 @@
|
|||
<skill name="bow" level="d3+1"/>
|
||||
<subset>
|
||||
<!-- dracoiden haben immer eine von drei waffen -->
|
||||
<set name="item_sword" chance="0.33"/>
|
||||
<set name="item_spear" chance="0.33"/>
|
||||
<set name="item_bow" chance="0.34"/>
|
||||
<set name="i_sword" chance="0.33"/>
|
||||
<set name="i_spear" chance="0.33"/>
|
||||
<set name="i_bow" chance="0.34"/>
|
||||
</subset>
|
||||
</set>
|
||||
|
||||
|
@ -195,38 +195,34 @@
|
|||
<item name="rustysword" amount="1"/>
|
||||
<item name="rustychainmail" amount="d2-1"/>
|
||||
<subset chance="0.3">
|
||||
<set name="item_rustyshield"/>
|
||||
<set name="i_rustyshield"/>
|
||||
</subset>
|
||||
</set>
|
||||
|
||||
|
||||
<!-- single-item sets (that can be given a percentage-chance in a subset) -->
|
||||
<set name="item_plate">
|
||||
<set name="i_plate">
|
||||
<item name="plate" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="item_spear">
|
||||
<set name="i_spear">
|
||||
<item name="spear" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="item_bow">
|
||||
<set name="i_bow">
|
||||
<item name="bow" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="item_sword">
|
||||
<set name="i_sword">
|
||||
<item name="sword" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="item_chain">
|
||||
<set name="i_chain">
|
||||
<item name="chainmail" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="item_log">
|
||||
<item name="log" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="item_rustychain">
|
||||
<item name="rustychainmail" amount="1"/>
|
||||
<set name="i_rustyshield">
|
||||
<item name="rustyshield" amount="1"/>
|
||||
</set>
|
||||
|
||||
<set name="spo_dragon">
|
||||
|
|
|
@ -213,7 +213,7 @@ equipment *get_equipment(const char *eqname)
|
|||
{
|
||||
const char *match;
|
||||
|
||||
assert(strlen(eqname) <= EQNAMELEN);
|
||||
assert(strlen(eqname) < EQNAMELEN);
|
||||
|
||||
match = cb_find_str(&cb_equipments, eqname);
|
||||
if (match) {
|
||||
|
@ -228,9 +228,9 @@ equipment *create_equipment(const char *eqname)
|
|||
size_t len = strlen(eqname);
|
||||
eq_entry ent;
|
||||
|
||||
if (len > EQNAMELEN) {
|
||||
log_error("equipment names should be no longer than %d bytes: %s", EQNAMELEN, eqname);
|
||||
len = EQNAMELEN;
|
||||
if (len >= EQNAMELEN) {
|
||||
log_error("equipment names should be no longer than %d bytes: %s", EQNAMELEN-1, eqname);
|
||||
len = EQNAMELEN-1;
|
||||
}
|
||||
memset(ent.key, 0, EQNAMELEN);
|
||||
memcpy(ent.key, eqname, len);
|
||||
|
|
|
@ -51,21 +51,21 @@ static void test_get_equipment(CuTest * tc)
|
|||
equipment * eq;
|
||||
|
||||
test_setup();
|
||||
eq = create_equipment("catapultammo");
|
||||
eq = create_equipment("catapultammo123");
|
||||
CuAssertPtrNotNull(tc, eq);
|
||||
CuAssertStrEquals(tc, "catapultammo", eq->name);
|
||||
eq = get_equipment("catapultammo");
|
||||
CuAssertStrEquals(tc, "catapultammo123", eq->name);
|
||||
eq = get_equipment("catapultammo123");
|
||||
CuAssertPtrNotNull(tc, eq);
|
||||
CuAssertStrEquals(tc, "catapultammo", eq->name);
|
||||
CuAssertStrEquals(tc, "catapultammo123", eq->name);
|
||||
eq = get_equipment("catapult");
|
||||
CuAssertPtrEquals(tc, NULL, eq);
|
||||
eq = create_equipment("catapult");
|
||||
eq = get_equipment("catapult");
|
||||
CuAssertPtrNotNull(tc, eq);
|
||||
CuAssertStrEquals(tc, "catapult", eq->name);
|
||||
eq = get_equipment("catapultammo");
|
||||
eq = get_equipment("catapultammo123");
|
||||
CuAssertPtrNotNull(tc, eq);
|
||||
CuAssertStrEquals(tc, "catapultammo", eq->name);
|
||||
CuAssertStrEquals(tc, "catapultammo123", eq->name);
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ static void get_villagers(region * r, unit * u)
|
|||
u);
|
||||
leave(newunit, true);
|
||||
fset(newunit, UFL_ISNEW | UFL_MOVED);
|
||||
equip_unit(newunit, get_equipment("random_villagers"));
|
||||
equip_unit(newunit, get_equipment("rand_villagers"));
|
||||
}
|
||||
|
||||
static void get_allies(region * r, unit * u)
|
||||
|
@ -282,7 +282,7 @@ static void get_allies(region * r, unit * u)
|
|||
if (get_money(u) / u->number < 100 + rng_int() % 200)
|
||||
return;
|
||||
name = "random_plain_men";
|
||||
equip = "random_plain";
|
||||
equip = "rand_plain";
|
||||
number = rng_int() % 8 + 2;
|
||||
break;
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ static void get_allies(region * r, unit * u)
|
|||
return;
|
||||
}
|
||||
name = "random_forest_men";
|
||||
equip = "random_forest";
|
||||
equip = "rand_forest";
|
||||
number = rng_int() % 6 + 2;
|
||||
}
|
||||
break;
|
||||
|
@ -303,7 +303,7 @@ static void get_allies(region * r, unit * u)
|
|||
return;
|
||||
}
|
||||
name = "random_swamp_men";
|
||||
equip = "random_swamp";
|
||||
equip = "rand_swamp";
|
||||
number = rng_int() % 6 + 2;
|
||||
break;
|
||||
|
||||
|
@ -312,7 +312,7 @@ static void get_allies(region * r, unit * u)
|
|||
return;
|
||||
}
|
||||
name = "random_desert_men";
|
||||
equip = "random_desert";
|
||||
equip = "rand_desert";
|
||||
number = rng_int() % 12 + 2;
|
||||
break;
|
||||
|
||||
|
@ -321,7 +321,7 @@ static void get_allies(region * r, unit * u)
|
|||
return;
|
||||
}
|
||||
name = "random_highland_men";
|
||||
equip = "random_highland";
|
||||
equip = "rand_highland";
|
||||
number = rng_int() % 8 + 2;
|
||||
break;
|
||||
|
||||
|
@ -330,7 +330,7 @@ static void get_allies(region * r, unit * u)
|
|||
return;
|
||||
}
|
||||
name = "random_mountain_men";
|
||||
equip = "random_mountain";
|
||||
equip = "rand_mountain";
|
||||
number = rng_int() % 6 + 2;
|
||||
break;
|
||||
|
||||
|
@ -339,7 +339,7 @@ static void get_allies(region * r, unit * u)
|
|||
return;
|
||||
}
|
||||
name = "random_glacier_men";
|
||||
equip = "random_glacier";
|
||||
equip = "rand_glacier";
|
||||
number = rng_int() % 4 + 2;
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in New Issue