forked from github/server
Der neuer Code von Corwin verhinderte neue Einheiten, wenn game.maxunits im XML file nicht gesetzt war (Regel im alten Code war wenn maxunits=0, dann kein Limit). War nicht gut für HSE :-)
This commit is contained in:
parent
71296bfced
commit
2fc718b983
|
@ -3354,7 +3354,7 @@ ageing(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
maxunits(faction *f)
|
maxunits(const faction *f)
|
||||||
{
|
{
|
||||||
if (global.unitsperalliance == true) {
|
if (global.unitsperalliance == true) {
|
||||||
faction *f2;
|
faction *f2;
|
||||||
|
@ -3368,39 +3368,32 @@ maxunits(faction *f)
|
||||||
return (int) (global.maxunits * mult);
|
return (int) (global.maxunits * mult);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) (global.maxunits *
|
return (int) (global.maxunits * (1 + 0.4 * fspecial(f, FS_ADMINISTRATOR)));
|
||||||
(1 + 0.4 * fspecial(f, FS_ADMINISTRATOR)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
checkunitnumber(faction *f)
|
checkunitnumber(const faction *f, int add)
|
||||||
{
|
{
|
||||||
|
if (global.maxunits==0) return true;
|
||||||
if (global.unitsperalliance == true) {
|
if (global.unitsperalliance == true) {
|
||||||
|
/* if unitsperalliance is true, maxunits returns the
|
||||||
|
number of units allowed in an alliance */
|
||||||
faction *f2;
|
faction *f2;
|
||||||
int unitsinalliance = 0;
|
int unitsinalliance = add;
|
||||||
|
int maxu = maxunits(f);
|
||||||
|
|
||||||
for (f2 = factions; f2; f2 = f2->next) {
|
for (f2 = factions; f2; f2 = f2->next) {
|
||||||
if (f->alliance == f2->alliance) {
|
if (f->alliance == f2->alliance) {
|
||||||
unitsinalliance += f2->no_units;
|
unitsinalliance += f2->no_units;
|
||||||
}
|
}
|
||||||
}
|
if (unitsinalliance > maxu) return false;
|
||||||
|
|
||||||
/* if unitsperalliance is true, maxunits returns the
|
|
||||||
number of units allowed in an alliance */
|
|
||||||
if(unitsinalliance >= maxunits(f)) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(f->no_units >= maxunits(f)) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (f->no_units + add < maxunits(f));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
new_units (void)
|
new_units (void)
|
||||||
|
@ -3425,7 +3418,7 @@ new_units (void)
|
||||||
int g, alias;
|
int g, alias;
|
||||||
order ** newordersp;
|
order ** newordersp;
|
||||||
|
|
||||||
if (checkunitnumber(u->faction) == false) {
|
if (checkunitnumber(u->faction, 1) == false) {
|
||||||
if (global.unitsperalliance == false) {
|
if (global.unitsperalliance == false) {
|
||||||
ADDMSG(&u->faction->msgs, msg_message("too_many_units_in_faction",
|
ADDMSG(&u->faction->msgs, msg_message("too_many_units_in_faction",
|
||||||
"command unit region allowed",
|
"command unit region allowed",
|
||||||
|
|
|
@ -39,6 +39,7 @@ without prior permission by the authors of Eressea.
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static boolean gamecode_enabled = false;
|
static boolean gamecode_enabled = false;
|
||||||
|
@ -1179,12 +1180,7 @@ parse_main(xmlDocPtr doc)
|
||||||
}
|
}
|
||||||
|
|
||||||
global.unitsperalliance = xml_bvalue(node, "unitsperalliance", false);
|
global.unitsperalliance = xml_bvalue(node, "unitsperalliance", false);
|
||||||
|
global.maxunits = xml_ivalue(node, "units", INT_MAX);
|
||||||
property = xmlGetProp(node, BAD_CAST "units");
|
|
||||||
if (property!=NULL) {
|
|
||||||
global.maxunits = atoi((const char*)property);
|
|
||||||
xmlFree(property);
|
|
||||||
}
|
|
||||||
|
|
||||||
property = xmlGetProp(node, BAD_CAST "name");
|
property = xmlGetProp(node, BAD_CAST "name");
|
||||||
if (property!=NULL) {
|
if (property!=NULL) {
|
||||||
|
|
Loading…
Reference in New Issue