forked from github/server
Enforcing maximum size of units in give_men.
This commit is contained in:
parent
8fb509140c
commit
842f9038b8
|
@ -68,7 +68,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#define UNDEAD_REPRODUCTION 0 /* vermehrung */
|
|
||||||
#define MOVECHANCE 25 /* chance fuer bewegung */
|
#define MOVECHANCE 25 /* chance fuer bewegung */
|
||||||
|
|
||||||
#define MAXILLUSION_TEXTS 3
|
#define MAXILLUSION_TEXTS 3
|
||||||
|
|
|
@ -169,7 +169,6 @@ give_men(int n, unit * u, unit * u2, struct order * ord)
|
||||||
} else if (u2 && (fval(u2, UFL_LOCKED)|| is_cursed(u2->attribs, C_SLAVE, 0))) {
|
} else if (u2 && (fval(u2, UFL_LOCKED)|| is_cursed(u2->attribs, C_SLAVE, 0))) {
|
||||||
error = 75;
|
error = 75;
|
||||||
} else if (u2 && u2->faction != u->faction && !alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) {
|
} else if (u2 && u2->faction != u->faction && !alliedunit(u2, u->faction, HELP_GIVE) && !ucontact(u2, u)) {
|
||||||
|
|
||||||
error = 73;
|
error = 73;
|
||||||
} else if (u2 && (has_skill(u, SK_MAGIC) || has_skill(u2, SK_MAGIC))) {
|
} else if (u2 && (has_skill(u, SK_MAGIC) || has_skill(u2, SK_MAGIC))) {
|
||||||
error = 158;
|
error = 158;
|
||||||
|
@ -184,6 +183,10 @@ give_men(int n, unit * u, unit * u2, struct order * ord)
|
||||||
error = 139;
|
error = 139;
|
||||||
} else {
|
} else {
|
||||||
if (n > u->number) n = u->number;
|
if (n > u->number) n = u->number;
|
||||||
|
if (u2 && n+u2->number > UNIT_MAXSIZE) {
|
||||||
|
n = UNIT_MAXSIZE-u2->number;
|
||||||
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_unit_size", "maxsize", UNIT_MAXSIZE));
|
||||||
|
}
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
error = 96;
|
error = 96;
|
||||||
} else if (u2 && u->faction != u2->faction) {
|
} else if (u2 && u->faction != u2->faction) {
|
||||||
|
|
|
@ -947,10 +947,10 @@ void
|
||||||
set_number(unit * u, int count)
|
set_number(unit * u, int count)
|
||||||
{
|
{
|
||||||
assert (count >= 0);
|
assert (count >= 0);
|
||||||
assert (count <= USHRT_MAX);
|
assert (count <= UNIT_MAXSIZE);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
assert (u->faction != 0 || u->number > 0);
|
assert (u->faction != NULL || u->number > 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (playerrace(u->race)) {
|
if (playerrace(u->race)) {
|
||||||
|
|
|
@ -39,31 +39,6 @@ age_undead(unit *u)
|
||||||
region *r = u->region;
|
region *r = u->region;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
#if UNDEAD_REPRODUCTION > 0
|
|
||||||
if(fval(r->terrain, LAND_REGION)) {
|
|
||||||
int m;
|
|
||||||
#ifndef SLOW_UNDEADS
|
|
||||||
if (u->number>100) {
|
|
||||||
int k = u->number;
|
|
||||||
for (m=0;m!=100;++m) {
|
|
||||||
int d = k/(100-m);
|
|
||||||
k-=d;
|
|
||||||
if (rng_int() % 100 < UNDEAD_REPRODUCTION)
|
|
||||||
n+=d;
|
|
||||||
}
|
|
||||||
assert(k==0);
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
for (m = u->number; m; m--)
|
|
||||||
if (rng_int() % 100 < UNDEAD_REPRODUCTION)
|
|
||||||
n++;
|
|
||||||
set_number(u, u->number + n);
|
|
||||||
u->hp += n * unit_max_hp(u);
|
|
||||||
n = rpeasants(r) - n;
|
|
||||||
n = max(0, n);
|
|
||||||
rsetpeasants(r, n);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/* untote, die einer partei angehoeren, koennen sich
|
/* untote, die einer partei angehoeren, koennen sich
|
||||||
* absplitten, anstatt sich zu vermehren. monster
|
* absplitten, anstatt sich zu vermehren. monster
|
||||||
* untote vermehren sich nur noch */
|
* untote vermehren sich nur noch */
|
||||||
|
|
|
@ -5519,6 +5519,16 @@
|
||||||
<text locale="fr">"$unit($unit) in $region($region): '$order($command)' - The unit does not have these herbs."</text>
|
<text locale="fr">"$unit($unit) in $region($region): '$order($command)' - The unit does not have these herbs."</text>
|
||||||
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - The unit does not have these herbs."</text>
|
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - The unit does not have these herbs."</text>
|
||||||
</message>
|
</message>
|
||||||
|
<message name="unit_size" section="errors">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="region" type="region"/>
|
||||||
|
<arg name="command" type="order"/>
|
||||||
|
</type>
|
||||||
|
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Einheiten dürfen nicht mehr als $int($maxsize) Personen enthalten."</text>
|
||||||
|
<text locale="fr">"$unit($unit) in $region($region): '$order($command)' - Units may not have more than $int($maxsize) members."</text>
|
||||||
|
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - Units may not have more than $int($maxsize) members."</text>
|
||||||
|
</message>
|
||||||
<message name="enter_overload" section="errors">
|
<message name="enter_overload" section="errors">
|
||||||
<type>
|
<type>
|
||||||
<arg name="unit" type="unit"/>
|
<arg name="unit" type="unit"/>
|
||||||
|
|
Loading…
Reference in New Issue