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:
Enno Rehling 2005-05-20 22:51:37 +00:00
parent 71296bfced
commit 2fc718b983
2 changed files with 32 additions and 43 deletions

View File

@ -3354,54 +3354,47 @@ ageing(void)
}
static int
maxunits(faction *f)
maxunits(const faction *f)
{
if(global.unitsperalliance == true) {
faction *f2;
float mult = 1.0;
if (global.unitsperalliance == true) {
faction *f2;
float mult = 1.0;
for(f2 = factions; f2; f2 = f2->next) {
if(f2->alliance == f->alliance) {
mult += 0.4f * fspecial(f2, FS_ADMINISTRATOR);
}
}
return (int) (global.maxunits * mult);
}
for (f2 = factions; f2; f2 = f2->next) {
if (f2->alliance == f->alliance) {
mult += 0.4f * fspecial(f2, FS_ADMINISTRATOR);
}
}
return (int) (global.maxunits * mult);
}
return (int) (global.maxunits *
(1 + 0.4 * fspecial(f, FS_ADMINISTRATOR)));
return (int) (global.maxunits * (1 + 0.4 * fspecial(f, FS_ADMINISTRATOR)));
}
static boolean
checkunitnumber(faction *f)
checkunitnumber(const faction *f, int add)
{
if(global.unitsperalliance == true) {
faction *f2;
int unitsinalliance = 0;
if (global.maxunits==0) return true;
if (global.unitsperalliance == true) {
/* if unitsperalliance is true, maxunits returns the
number of units allowed in an alliance */
faction *f2;
int unitsinalliance = add;
int maxu = maxunits(f);
for(f2 = factions; f2; f2 = f2->next) {
if(f->alliance == f2->alliance) {
unitsinalliance += f2->no_units;
}
}
for (f2 = factions; f2; f2 = f2->next) {
if (f->alliance == f2->alliance) {
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;
}
}
return true;
}
if(f->no_units >= maxunits(f)) {
return false;
}
return true;
return (f->no_units + add < maxunits(f));
}
static void
new_units (void)
{
@ -3425,7 +3418,7 @@ new_units (void)
int g, alias;
order ** newordersp;
if (checkunitnumber(u->faction) == false) {
if (checkunitnumber(u->faction, 1) == false) {
if (global.unitsperalliance == false) {
ADDMSG(&u->faction->msgs, msg_message("too_many_units_in_faction",
"command unit region allowed",

View File

@ -39,6 +39,7 @@ without prior permission by the authors of Eressea.
/* libc includes */
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>
static boolean gamecode_enabled = false;
@ -1179,12 +1180,7 @@ parse_main(xmlDocPtr doc)
}
global.unitsperalliance = xml_bvalue(node, "unitsperalliance", false);
property = xmlGetProp(node, BAD_CAST "units");
if (property!=NULL) {
global.maxunits = atoi((const char*)property);
xmlFree(property);
}
global.maxunits = xml_ivalue(node, "units", INT_MAX);
property = xmlGetProp(node, BAD_CAST "name");
if (property!=NULL) {