forked from github/server
saving a little memory.
This commit is contained in:
parent
7e027ada71
commit
48284eda68
2 changed files with 21 additions and 18 deletions
|
@ -46,9 +46,10 @@
|
||||||
#include <resolve.h>
|
#include <resolve.h>
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <string.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define FIND_FOREIGN_TEMP
|
#define FIND_FOREIGN_TEMP
|
||||||
|
@ -59,9 +60,10 @@ int demonfix = 0;
|
||||||
const unit *
|
const unit *
|
||||||
u_peasants(void)
|
u_peasants(void)
|
||||||
{
|
{
|
||||||
static unit peasants = { NULL, NULL, NULL, NULL, NULL, 2, NULL };
|
static unit peasants = { 0 };
|
||||||
if (peasants.name==NULL) {
|
if (peasants.name==NULL) {
|
||||||
peasants.name = strdup("die Bauern");
|
peasants.name = strdup("die Bauern");
|
||||||
|
peasants.no = 2;
|
||||||
}
|
}
|
||||||
return &peasants;
|
return &peasants;
|
||||||
}
|
}
|
||||||
|
@ -69,9 +71,10 @@ u_peasants(void)
|
||||||
const unit *
|
const unit *
|
||||||
u_unknown(void)
|
u_unknown(void)
|
||||||
{
|
{
|
||||||
static unit unknown = { NULL, NULL, NULL, NULL, NULL, 1, NULL };
|
static unit unknown = { 0 };
|
||||||
if (unknown.name==NULL) {
|
if (unknown.name==NULL) {
|
||||||
unknown.name =strdup("eine unbekannte Einheit");
|
unknown.name =strdup("eine unbekannte Einheit");
|
||||||
|
unknown.no = 1;
|
||||||
}
|
}
|
||||||
return &unknown;
|
return &unknown;
|
||||||
}
|
}
|
||||||
|
@ -805,6 +808,7 @@ void
|
||||||
u_setfaction(unit * u, faction * f)
|
u_setfaction(unit * u, faction * f)
|
||||||
{
|
{
|
||||||
int cnt = u->number;
|
int cnt = u->number;
|
||||||
|
unit ** iunit;
|
||||||
if (u->faction==f) return;
|
if (u->faction==f) return;
|
||||||
if (u->faction) {
|
if (u->faction) {
|
||||||
set_number(u, 0);
|
set_number(u, 0);
|
||||||
|
@ -818,20 +822,18 @@ u_setfaction(unit * u, faction * f)
|
||||||
set_order(&u->lastorder, NULL);
|
set_order(&u->lastorder, NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (u->prevF) u->prevF->nextF = u->nextF;
|
|
||||||
else if (u->faction) {
|
iunit = &f->units;
|
||||||
assert(u->faction->units==u);
|
while (*iunit!=u) iunit=&(*iunit)->next;
|
||||||
u->faction->units = u->nextF;
|
assert(*iunit);
|
||||||
}
|
|
||||||
if (u->nextF) u->nextF->prevF = u->prevF;
|
*iunit = u->nextF;
|
||||||
|
|
||||||
if (f!=NULL) {
|
if (f!=NULL) {
|
||||||
u->nextF = f->units;
|
u->nextF = f->units;
|
||||||
f->units = u;
|
f->units = u;
|
||||||
}
|
}
|
||||||
else u->nextF = NULL;
|
else u->nextF = NULL;
|
||||||
if (u->nextF) u->nextF->prevF = u;
|
|
||||||
u->prevF = NULL;
|
|
||||||
|
|
||||||
u->faction = f;
|
u->faction = f;
|
||||||
if (u->region) update_interval(f, u->region);
|
if (u->region) update_interval(f, u->region);
|
||||||
|
@ -847,6 +849,8 @@ void
|
||||||
set_number(unit * u, int count)
|
set_number(unit * u, int count)
|
||||||
{
|
{
|
||||||
assert (count >= 0);
|
assert (count >= 0);
|
||||||
|
assert (count <= SHRT_MAX);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
assert (u->faction != 0 || u->number > 0);
|
assert (u->faction != 0 || u->number > 0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -860,7 +864,7 @@ set_number(unit * u, int count)
|
||||||
if (playerrace(u->race)) {
|
if (playerrace(u->race)) {
|
||||||
u->faction->num_people += count - u->number;
|
u->faction->num_people += count - u->number;
|
||||||
}
|
}
|
||||||
u->number = count;
|
u->number = (short)count;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
|
|
|
@ -69,20 +69,19 @@ typedef struct unit {
|
||||||
struct unit *next; /* needs to be first entry, for region's unitlist */
|
struct unit *next; /* needs to be first entry, for region's unitlist */
|
||||||
struct unit *nexthash;
|
struct unit *nexthash;
|
||||||
struct unit *nextF; /* nächste Einheit der Partei */
|
struct unit *nextF; /* nächste Einheit der Partei */
|
||||||
struct unit *prevF; /* letzte Einheit der Partei */
|
|
||||||
struct region *region;
|
struct region *region;
|
||||||
int no;
|
int no;
|
||||||
|
int hp;
|
||||||
char *name;
|
char *name;
|
||||||
char *display;
|
char *display;
|
||||||
int number;
|
|
||||||
int hp;
|
|
||||||
short age;
|
|
||||||
struct faction *faction;
|
struct faction *faction;
|
||||||
struct building *building;
|
struct building *building;
|
||||||
struct ship *ship;
|
struct ship *ship;
|
||||||
|
short age;
|
||||||
|
short number;
|
||||||
|
|
||||||
/* skill data */
|
/* skill data */
|
||||||
int skill_size;
|
short skill_size;
|
||||||
struct skill *skills;
|
struct skill *skills;
|
||||||
struct item * items;
|
struct item * items;
|
||||||
struct reservation {
|
struct reservation {
|
||||||
|
|
Loading…
Reference in a new issue