Merge branch 'master' of github.com:eressea/server

This commit is contained in:
Enno Rehling 2014-10-18 21:37:40 +02:00
commit f069df2345
27 changed files with 1211 additions and 1014 deletions

View file

@ -1,4 +1,4 @@
dofile('config.lua')
eressea.read_game(get_turn() + '.dat')
eressea.read_game(get_turn() .. '.dat')
init_reports()
write_reports()

View file

@ -4,6 +4,7 @@
#include "json.h"
#include <kernel/faction.h>
#include <kernel/types.h>
#include <kernel/config.h>
#include <kernel/save.h>

View file

@ -57,9 +57,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/bsdstring.h>
#include <util/event.h>
#include <util/goodies.h>
#include <util/lists.h>
#include <util/language.h>
#include <util/lists.h>
#include <util/log.h>
#include <util/parser.h>
#include <util/rng.h>
@ -1039,14 +1039,12 @@ static bool maintain(building * b, bool first)
u = building_owner(b);
if (u == NULL)
return false;
/* If the owner is the region owner, check if biggest castle has the dontpay flag */
/* If the owner is the region owner, check if dontpay flag is set for the building where he is in */
if (check_param(global.parameters, "rules.region_owner_pay_building", b->type->_name)) {
if (u == building_owner(largestbuilding(r, &cmp_taxes, false))) {
if (fval(u->building, BLD_DONTPAY)) {
return false;
}
}
}
for (c = 0; b->type->maintenance[c].number; ++c) {
const maintenance *m = b->type->maintenance + c;
int need = m->number;

View file

@ -102,7 +102,6 @@ struct settings global = {
bool lomem = false;
FILE *logfile;
FILE *updatelog;
bool battledebug = false;
int turn = -1;
@ -122,17 +121,6 @@ bool IsImmune(const faction * f)
return !fval(f, FFL_NPC) && f->age < NewbieImmunity();
}
static int MaxAge(void)
{
static int value = -1;
static int gamecookie = -1;
if (value < 0 || gamecookie != global.cookie) {
gamecookie = global.cookie;
value = get_param_int(global.parameters, "MaxAge", 0);
}
return value;
}
static int ally_flag(const char *s, int help_mask)
{
if ((help_mask & HELP_MONEY) && strcmp(s, "money") == 0)
@ -1510,9 +1498,9 @@ bool idle(faction * f)
int maxworkingpeasants(const struct region *r)
{
int i = production(r) * MAXPEASANTS_PER_AREA
- ((rtrees(r, 2) + rtrees(r, 1) / 2) * TREESIZE);
return _max(i, 0);
int size = production(r);
int treespace = (rtrees(r, 2) + rtrees(r, 1) / 2) * TREESIZE;
return _max(size-treespace, _min(size / 10 , 200));
}
int lighthouse_range(const building * b, const faction * f)
@ -2069,100 +2057,6 @@ char *_strdup(const char *s)
}
#endif
void remove_empty_factions(void)
{
faction **fp, *f3;
for (fp = &factions; *fp;) {
faction *f = *fp;
/* monster (0) werden nicht entfernt. alive kann beim readgame
* () auf 0 gesetzt werden, wenn monsters keine einheiten mehr
* haben. */
if ((f->units == NULL || f->alive == 0) && !is_monsters(f)) {
ursprung *ur = f->ursprung;
while (ur && ur->id != 0)
ur = ur->next;
if (verbosity >= 2)
log_printf(stdout, "\t%s\n", factionname(f));
/* Einfach in eine Datei schreiben und später vermailen */
if (updatelog)
fprintf(updatelog, "dropout %s\n", itoa36(f->no));
for (f3 = factions; f3; f3 = f3->next) {
ally *sf;
group *g;
ally **sfp = &f3->allies;
while (*sfp) {
sf = *sfp;
if (sf->faction == f || sf->faction == NULL) {
*sfp = sf->next;
free(sf);
}
else
sfp = &(*sfp)->next;
}
for (g = f3->groups; g; g = g->next) {
sfp = &g->allies;
while (*sfp) {
sf = *sfp;
if (sf->faction == f || sf->faction == NULL) {
*sfp = sf->next;
free(sf);
}
else
sfp = &(*sfp)->next;
}
}
}
*fp = f->next;
funhash(f);
free_faction(f);
free(f);
}
else
fp = &(*fp)->next;
}
}
void remove_empty_units_in_region(region * r)
{
unit **up = &r->units;
while (*up) {
unit *u = *up;
if (u->number) {
faction *f = u->faction;
if (f == NULL || !f->alive) {
set_number(u, 0);
}
if (MaxAge() > 0) {
if ((!fval(f, FFL_NOTIMEOUT) && f->age > MaxAge())) {
set_number(u, 0);
}
}
}
if ((u->number == 0 && u_race(u) != get_race(RC_SPELL)) || (u->age <= 0
&& u_race(u) == get_race(RC_SPELL))) {
remove_unit(up, u);
}
if (*up == u)
up = &u->next;
}
}
void remove_empty_units(void)
{
region *r;
for (r = regions; r; r = r->next) {
remove_empty_units_in_region(r);
}
}
bool faction_id_is_unused(int id)
{
return findfaction(id) == NULL;
@ -2715,20 +2609,12 @@ int entertainmoney(const region * r)
int rule_give(void)
{
static int value = -1;
if (value < 0) {
value = get_param_int(global.parameters, "rules.give", GIVE_DEFAULT);
}
return value;
return get_param_int(global.parameters, "rules.give", GIVE_DEFAULT);
}
int markets_module(void)
{
static int value = -1;
if (value < 0) {
value = get_param_int(global.parameters, "modules.markets", 0);
}
return value;
return get_param_int(global.parameters, "modules.markets", 0);
}
/** releases all memory associated with the game state.

View file

@ -46,8 +46,7 @@ extern "C" {
# define MAXUNITS 1048573 /* must be prime for hashing. 524287 was >90% full */
#endif
#define MAXPEASANTS_PER_AREA 10 /* number of peasants per region-size */
#define TREESIZE (MAXPEASANTS_PER_AREA-2) /* space used by trees (in #peasants) */
#define TREESIZE (8) /* space used by trees (in #peasants) */
#define PEASANTFORCE 0.75 /* Chance einer Vermehrung trotz 90% Auslastung */
#define HERBROTCHANCE 5 /* Verrottchance für Kräuter (ifdef HERBS_ROT) */
@ -107,10 +106,6 @@ extern "C" {
#define i2b(i) ((bool)((i)?(true):(false)))
void remove_empty_units_in_region(struct region *r);
void remove_empty_units(void);
void remove_empty_factions(void);
typedef struct strlist {
struct strlist *next;
char *s;

View file

@ -1,7 +1,7 @@
/*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Copyright (c) 1998-2014, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@ -115,7 +115,7 @@ void curse_init(attrib * a)
int curse_age(attrib * a)
{
curse *c = (curse *) a->data.v;
curse *c = (curse *)a->data.v;
int result = 0;
if (c_flags(c) & CURSE_NOAGE) {
@ -126,7 +126,8 @@ int curse_age(attrib * a)
}
if (result != 0) {
c->duration = 0;
} else if (c->duration != INT_MAX) {
}
else if (c->duration != INT_MAX) {
c->duration = _max(0, c->duration - 1);
}
return c->duration;
@ -140,7 +141,7 @@ void destroy_curse(curse * c)
void curse_done(attrib * a)
{
destroy_curse((curse *) a->data.v);
destroy_curse((curse *)a->data.v);
}
/** reads curses that have been removed from the code */
@ -150,9 +151,9 @@ static int read_ccompat(const char *cursename, struct storage *store)
const char *name;
const char *tokens;
} *seek, old_curses[] = { {
"disorientationzone", ""}, {
"shipdisorientation", ""}, {
NULL, NULL}};
"disorientationzone", "" }, {
"shipdisorientation", "" }, {
NULL, NULL } };
for (seek = old_curses; seek->name; ++seek) {
if (strcmp(seek->tokens, cursename) == 0) {
const char *p;
@ -183,7 +184,7 @@ static int read_ccompat(const char *cursename, struct storage *store)
int curse_read(attrib * a, void *owner, struct storage *store)
{
curse *c = (curse *) a->data.v;
curse *c = (curse *)a->data.v;
int ur;
char cursename[64];
int n;
@ -198,19 +199,22 @@ int curse_read(attrib * a, void *owner, struct storage *store)
if (global.data_version >= CURSEVIGOURISFLOAT_VERSION) {
READ_FLT(store, &flt);
c->vigour = flt;
} else {
}
else {
READ_INT(store, &n);
c->vigour = (float)n;
}
if (global.data_version < INTPAK_VERSION) {
ur = read_reference(&c->magician, store, read_int, resolve_unit);
} else {
}
else {
ur = read_reference(&c->magician, store, read_unit_reference, resolve_unit);
}
if (global.data_version < CURSEFLOAT_VERSION) {
READ_INT(store, &n);
c->effect = (float)n;
} else {
}
else {
READ_FLT(store, &flt);
c->effect = flt;
}
@ -225,7 +229,8 @@ int curse_read(attrib * a, void *owner, struct storage *store)
}
if (global.data_version < CURSEFLAGS_VERSION) {
c_setflag(c, flags);
} else {
}
else {
c->flags = flags;
}
c_clearflag(c, CURSE_ISNEW);
@ -250,7 +255,7 @@ int curse_read(attrib * a, void *owner, struct storage *store)
void curse_write(const attrib * a, const void *owner, struct storage *store)
{
unsigned int flags;
curse *c = (curse *) a->data.v;
curse *c = (curse *)a->data.v;
const curse_type *ct = c->type;
unit *mage = (c->magician && c->magician->number) ? c->magician : NULL;
@ -271,7 +276,7 @@ void curse_write(const attrib * a, const void *owner, struct storage *store)
WRITE_INT(store, c->data.i);
}
if (c->type->typ == CURSETYP_REGION) {
write_region_reference((region *) c->data.v, store);
write_region_reference((region *)c->data.v, store);
}
}
@ -308,11 +313,12 @@ const curse_type *ct_find(const char *c)
int qi;
for (qi = 0; ctl; ql_advance(&ctl, &qi, 1)) {
curse_type *type = (curse_type *) ql_get(ctl, qi);
curse_type *type = (curse_type *)ql_get(ctl, qi);
if (strcmp(c, type->cname) == 0) {
return type;
} else {
}
else {
size_t k = _min(strlen(c), strlen(type->cname));
if (!_memicmp(c, type->cname, k)) {
return type;
@ -327,39 +333,16 @@ const curse_type *ct_find(const char *c)
* einen pointer auf die struct zurück.
*/
bool cmp_curse(const attrib * a, const void *data)
static bool cmp_curse(const attrib * a, const void *data)
{
const curse *c = (const curse *)data;
if (a->type->flags & ATF_CURSE) {
if (!data || c == (curse *) a->data.v)
if (!data || c == (curse *)a->data.v)
return true;
}
return false;
}
bool cmp_cursetype(const attrib * a, const void *data)
{
const curse_type *ct = (const curse_type *)data;
if (a->type->flags & ATF_CURSE) {
if (!data || ct == ((curse *) a->data.v)->type)
return true;
}
return false;
}
curse *get_cursex(attrib * ap, const curse_type * ctype, variant data,
bool(*compare) (const curse *, variant))
{
attrib *a = a_select(ap, ctype, cmp_cursetype);
while (a) {
curse *c = (curse *) a->data.v;
if (compare(c, data))
return c;
a = a_select(a->next, ctype, cmp_cursetype);
}
return NULL;
}
curse *get_curse(attrib * ap, const curse_type * ctype)
{
attrib *a = ap;
@ -367,12 +350,13 @@ curse *get_curse(attrib * ap, const curse_type * ctype)
if (a->type->flags & ATF_CURSE) {
const attrib_type *at = a->type;
while (a && a->type == at) {
curse *c = (curse *) a->data.v;
curse *c = (curse *)a->data.v;
if (c->type == ctype)
return c;
a = a->next;
}
} else {
}
else {
a = a->nexttype;
}
}
@ -388,11 +372,10 @@ curse *findcurse(int cid)
}
/* ------------------------------------------------------------- */
void remove_curse(attrib ** ap, const curse * c)
bool remove_curse(attrib ** ap, const curse * c)
{
attrib *a = a_select(*ap, c, cmp_curse);
if (a)
a_remove(ap, a);
return a && a_remove(ap, a) == 1;
}
/* gibt die allgemeine Stärke der Verzauberung zurück. id2 wird wie
@ -423,7 +406,8 @@ float curse_changevigour(attrib ** ap, curse * c, float vigour)
if (vigour <= 0) {
remove_curse(ap, c);
vigour = 0;
} else {
}
else {
set_cursevigour(c, vigour);
}
return vigour;
@ -453,7 +437,7 @@ int curse_geteffect_int(const curse * c)
/* ------------------------------------------------------------- */
static void
set_curseingmagician(struct unit *magician, struct attrib *ap_target,
const curse_type * ct)
const curse_type * ct)
{
curse *c = get_curse(ap_target, ct);
if (c) {
@ -503,7 +487,7 @@ static curse *make_curse(unit * mage, attrib ** ap, const curse_type * ct,
a = a_new(&at_curse);
a_add(ap, a);
c = (curse *) a->data.v;
c = (curse *)a->data.v;
c->type = ct;
c->flags = 0;
@ -576,7 +560,8 @@ curse *create_curse(unit * magician, attrib ** ap, const curse_type * ct,
}
}
set_curseingmagician(magician, *ap, ct);
} else {
}
else {
c = make_curse(magician, ap, ct, vigour, duration, effect, men);
}
return c;
@ -639,7 +624,7 @@ void transfer_curse(unit * u, unit * u2, int n)
a = a_find(u->attribs, &at_curse);
while (a && a->type == &at_curse) {
curse *c = (curse *) a->data.v;
curse *c = (curse *)a->data.v;
do_transfer_curse(c, u, u2, n);
a = a->next;
}
@ -709,7 +694,7 @@ int resolve_curse(variant id, void *address)
result = -1;
}
}
*(curse **) address = c;
*(curse **)address = c;
return result;
}
@ -798,16 +783,19 @@ float destr_curse(curse * c, int cast_level, float force)
force -= c->vigour;
if (c->type->change_vigour) {
c->type->change_vigour(c, -((float)cast_level + 1) / 2);
} else {
}
else {
c->vigour -= cast_level + 1 / 2;
}
}
} else { /* Zauber ist stärker als curse */
}
else { /* Zauber ist stärker als curse */
if (force >= c->vigour) { /* reicht die Kraft noch aus? */
force -= c->vigour;
if (c->type->change_vigour) {
c->type->change_vigour(c, -c->vigour);
} else {
}
else {
c->vigour = 0;
}

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
Copyright (c) 1998-2014, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
@ -251,7 +251,7 @@ extern "C" {
bool is_cursed_internal(struct attrib *ap, const curse_type * ctype);
/* ignoriert CURSE_ISNEW */
extern void remove_curse(struct attrib **ap, const struct curse *c);
bool remove_curse(struct attrib **ap, const struct curse *c);
/* löscht einen konkreten Spruch auf einem Objekt.
*/
@ -280,11 +280,6 @@ extern "C" {
* unterschiedlich gewünscht sein
* */
extern struct curse *get_cursex(struct attrib *ap, const curse_type * ctype,
variant data, bool(*compare) (const struct curse *, variant));
/* gibt pointer auf die erste curse-struct zurück, deren Typ ctype ist,
* und für die compare() true liefert, oder einen NULL-pointer.
* */
extern struct curse *get_curse(struct attrib *ap, const curse_type * ctype);
/* gibt pointer auf die erste curse-struct zurück, deren Typ ctype ist,
* oder einen NULL-pointer
@ -303,9 +298,6 @@ extern "C" {
extern void curse_done(struct attrib *a);
extern int curse_age(struct attrib *a);
extern bool cmp_curse(const struct attrib *a, const void *data);
extern bool cmp_cursetype(const struct attrib *a, const void *data);
extern float destr_curse(struct curse *c, int cast_level, float force);
extern int resolve_curse(variant data, void *address);

View file

@ -126,7 +126,13 @@ faction *get_or_create_monsters(void)
if (!f) {
const race *rc = rc_find("dragon");
const char *email = get_param(global.parameters, "monster.email");
if (email) {
f = addfaction(email, NULL, rc, NULL, 0);
}
else {
f = addfaction("noreply@eressea.de", NULL, rc, NULL, 0);
}
renumber_faction(f, 666);
faction_setname(f, "Monster");
f->options = 0;
@ -340,7 +346,7 @@ void destroyfaction(faction * f)
if (rc->ec_flags & ECF_REC_HORSES) { /* Zentauren an die Pferde */
h += u->number;
}
else { /* Orks zählen nur zur Hälfte */
else { /* Orks zählen nur zur Hälfte */
p += (int)(u->number * rc->recruit_multi);
}
for (itm = u->items; itm; itm = itm->next) {
@ -365,7 +371,7 @@ void destroyfaction(faction * f)
group *g;
ally *sf, *sfn;
/* Alle HELFE für die Partei löschen */
/* Alle HELFE für die Partei löschen */
for (sf = ff->allies; sf; sf = sf->next) {
if (sf->faction == f) {
removelist(&ff->allies, sf);
@ -601,3 +607,57 @@ int skill_limit(faction * f, skill_t sk)
return m;
}
void remove_empty_factions(void)
{
faction **fp, *f3;
for (fp = &factions; *fp;) {
faction *f = *fp;
/* monster (0) werden nicht entfernt. alive kann beim readgame
* () auf 0 gesetzt werden, wenn monsters keine einheiten mehr
* haben. */
if ((f->units == NULL || f->alive == 0) && !is_monsters(f)) {
ursprung *ur = f->ursprung;
while (ur && ur->id != 0)
ur = ur->next;
if (verbosity >= 2)
log_printf(stdout, "\t%s\n", factionname(f));
/* Einfach in eine Datei schreiben und später vermailen */
for (f3 = factions; f3; f3 = f3->next) {
ally *sf;
group *g;
ally **sfp = &f3->allies;
while (*sfp) {
sf = *sfp;
if (sf->faction == f || sf->faction == NULL) {
*sfp = sf->next;
free(sf);
}
else
sfp = &(*sfp)->next;
}
for (g = f3->groups; g; g = g->next) {
sfp = &g->allies;
while (*sfp) {
sf = *sfp;
if (sf->faction == f || sf->faction == NULL) {
*sfp = sf->next;
free(sf);
}
else
sfp = &(*sfp)->next;
}
}
}
*fp = f->next;
funhash(f);
free_faction(f);
free(f);
}
else
fp = &(*fp)->next;
}
}

View file

@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define H_KRNL_FACTION
#include "skill.h"
#include "types.h"
#ifdef __cplusplus
extern "C" {
@ -48,10 +49,10 @@ extern "C" {
#define FFL_NOIDLEOUT (1<<24) /* Partei stirbt nicht an NMRs */
#define FFL_NPC (1<<25) /* eine Partei mit Monstern */
#define FFL_DBENTRY (1<<28) /* Partei ist in Datenbank eingetragen */
#define FFL_NOTIMEOUT (1<<29) /* ignore MaxAge() */
#define FFL_GM (1<<30) /* eine Partei mit Sonderrechten */
#define FFL_SAVEMASK (FFL_DEFENDER|FFL_NEWID|FFL_GM|FFL_NPC|FFL_NOTIMEOUT|FFL_DBENTRY|FFL_NOIDLEOUT)
#define FFL_SAVEMASK (FFL_DEFENDER|FFL_NEWID|FFL_GM|FFL_NPC|FFL_DBENTRY|FFL_NOIDLEOUT)
#define is_monsters(f) ((f)->flags&FFL_NPC)
@ -136,6 +137,7 @@ void destroyfaction(faction * f);
extern void renumber_faction(faction * f, int no);
void free_faction(struct faction *f);
void remove_empty_factions(void);
#ifdef SMART_INTERVALS
extern void update_interval(struct faction *f, struct region *r);

View file

@ -1,12 +1,71 @@
#include <platform.h>
#include <kernel/ally.h>
#include <kernel/faction.h>
#include <kernel/types.h>
#include <kernel/race.h>
#include <kernel/region.h>
#include <kernel/config.h>
#include <util/language.h>
#include "faction.h"
#include <CuTest.h>
#include <tests.h>
#include <assert.h>
#include <stdio.h>
static void test_remove_empty_factions_allies(CuTest *tc) {
faction *f1, *f2;
region *r;
test_cleanup();
r = test_create_region(0, 0, 0);
f1 = test_create_faction(0);
test_create_unit(f1, r);
f2 = test_create_faction(0);
ally_add(&f1->allies, f2);
remove_empty_factions();
CuAssertPtrEquals(tc, 0, f1->allies);
test_cleanup();
}
static void test_remove_empty_factions(CuTest *tc) {
faction *f, *fm;
int fno;
test_cleanup();
fm = get_or_create_monsters();
assert(fm);
f = test_create_faction(0);
fno = f->no;
remove_empty_factions();
CuAssertPtrEquals(tc, 0, findfaction(fno));
CuAssertPtrEquals(tc, fm, get_monsters());
test_cleanup();
}
static void test_remove_dead_factions(CuTest *tc) {
faction *f, *fm;
region *r;
test_cleanup();
r = test_create_region(0, 0, 0);
fm = get_or_create_monsters();
f = test_create_faction(0);
assert(fm && r && f);
test_create_unit(f, r);
test_create_unit(fm, r);
remove_empty_factions();
CuAssertPtrEquals(tc, f, findfaction(f->no));
CuAssertPtrNotNull(tc, get_monsters());
fm->alive = 0;
f->alive = 0;
remove_empty_factions();
CuAssertPtrEquals(tc, 0, findfaction(f->no));
CuAssertPtrEquals(tc, fm, get_monsters());
test_cleanup();
}
static void test_addfaction(CuTest *tc) {
faction *f = 0;
const struct race *rc = rc_get_or_create("human");
@ -51,6 +110,9 @@ CuSuite *get_faction_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_addfaction);
SUITE_ADD_TEST(suite, test_remove_empty_factions);
SUITE_ADD_TEST(suite, test_remove_empty_factions_allies);
SUITE_ADD_TEST(suite, test_remove_dead_factions);
SUITE_ADD_TEST(suite, test_get_monsters);
return suite;
}

View file

@ -1187,7 +1187,7 @@ void terraform_region(region * r, const terrain_type * terrain)
int production(const region * r)
{
/* muß rterrain(r) sein, nicht rterrain() wegen rekursion */
int p = r->terrain->size / MAXPEASANTS_PER_AREA;
int p = r->terrain->size;
if (curse_active(get_curse(r->attribs, ct_find("drought"))))
p /= 2;

View file

@ -113,8 +113,6 @@ char *rns(FILE * f, char *c, size_t size)
return c;
}
extern unsigned int __at_hashkey(const char *s);
static unit *unitorders(FILE * F, int enc, struct faction *f)
{
@ -1312,10 +1310,9 @@ faction *readfaction(struct gamedata * data)
READ_INT(data->store, &f->flags);
if (data->version < INTFLAGS_VERSION) {
if (f->no == 0 || f->no == 666) {
f->flags = FFL_NPC | FFL_NOTIMEOUT | FFL_NOIDLEOUT;
f->flags = FFL_NPC | FFL_NOIDLEOUT;
}
}
assert((f->flags&FFL_SAVEMASK) == f->flags);
a_read(data->store, &f->attribs, f);
if (data->version >= CLAIM_VERSION) {

View file

@ -232,9 +232,8 @@ int gift_items(unit * u, int flags)
int rule = rule_give();
assert(u->region);
assert(u->faction);
if ((u->faction->flags & FFL_QUIT) == 0 || (rule & GIVE_ONDEATH) == 0) {
if ((rule & GIVE_ONDEATH) == 0 || !u->faction || (u->faction->flags & FFL_QUIT) == 0) {
if ((rule & GIVE_ALLITEMS) == 0 && (flags & GIFT_FRIENDS))
flags -= GIFT_FRIENDS;
if ((rule & GIVE_PEASANTS) == 0 && (flags & GIFT_PEASANTS))
@ -1786,3 +1785,33 @@ int effskill(const unit * u, skill_t sk)
return eff_skill(u, sk, u->region);
}
void remove_empty_units_in_region(region * r)
{
unit **up = &r->units;
while (*up) {
unit *u = *up;
if (u->number) {
faction *f = u->faction;
if (f == NULL || !f->alive) {
set_number(u, 0);
}
}
if ((u->number == 0 && u_race(u) != get_race(RC_SPELL)) || (u->age <= 0
&& u_race(u) == get_race(RC_SPELL))) {
remove_unit(up, u);
}
if (*up == u)
up = &u->next;
}
}
void remove_empty_units(void)
{
region *r;
for (r = regions; r; r = r->next) {
remove_empty_units_in_region(r);
}
}

View file

@ -238,6 +238,8 @@ extern "C" {
struct spellbook * unit_get_spellbook(const struct unit * u);
void unit_add_spell(struct unit * u, struct sc_mage * m, struct spell * sp, int level);
void remove_empty_units_in_region(struct region * r);
void remove_empty_units(void);
extern struct attrib_type at_creator;
#ifdef __cplusplus

View file

@ -1,8 +1,10 @@
#include <platform.h>
#include <kernel/config.h>
#include "alchemy.h"
#include "faction.h"
#include "unit.h"
#include "item.h"
#include "race.h"
#include "region.h"
#include <CuTest.h>
@ -11,6 +13,94 @@
#include <stdlib.h>
#include <assert.h>
static void test_remove_empty_units(CuTest *tc) {
unit *u;
int uid;
test_cleanup();
test_create_world();
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
uid = u->no;
remove_empty_units();
CuAssertPtrNotNull(tc, findunit(uid));
u->number = 0;
remove_empty_units();
CuAssertPtrEquals(tc, 0, findunit(uid));
test_cleanup();
}
static void test_remove_empty_units_in_region(CuTest *tc) {
unit *u;
int uid;
test_cleanup();
test_create_world();
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
uid = u->no;
remove_empty_units_in_region(u->region);
CuAssertPtrNotNull(tc, findunit(uid));
u->number = 0;
remove_empty_units_in_region(u->region);
CuAssertPtrEquals(tc, 0, findunit(uid));
CuAssertPtrEquals(tc, 0, u->region);
CuAssertPtrEquals(tc, 0, u->faction);
test_cleanup();
}
static void test_remove_units_without_faction(CuTest *tc) {
unit *u;
int uid;
test_cleanup();
test_create_world();
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
uid = u->no;
u_setfaction(u, 0);
remove_empty_units_in_region(u->region);
CuAssertPtrEquals(tc, 0, findunit(uid));
CuAssertIntEquals(tc, 0, u->number);
test_cleanup();
}
static void test_remove_units_with_dead_faction(CuTest *tc) {
unit *u;
int uid;
test_cleanup();
test_create_world();
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
uid = u->no;
u->faction->alive = false;
remove_empty_units_in_region(u->region);
CuAssertPtrEquals(tc, 0, findunit(uid));
CuAssertIntEquals(tc, 0, u->number);
test_cleanup();
}
static void test_remove_units_ignores_spells(CuTest *tc) {
unit *u;
int uid;
test_cleanup();
test_create_world();
u = create_unit(findregion(0, 0), test_create_faction(test_create_race("human")), 1, get_race(RC_SPELL), 0, 0, 0);
uid = u->no;
u->number = 0;
u->age = 1;
remove_empty_units_in_region(u->region);
CuAssertPtrNotNull(tc, findunit(uid));
CuAssertPtrNotNull(tc, u->region);
u->age = 0;
remove_empty_units_in_region(u->region);
CuAssertPtrEquals(tc, 0, findunit(uid));
test_cleanup();
}
static void test_scale_number(CuTest *tc) {
unit *u;
const struct potion_type *ptype;
@ -37,5 +127,10 @@ CuSuite *get_unit_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_scale_number);
SUITE_ADD_TEST(suite, test_remove_empty_units);
SUITE_ADD_TEST(suite, test_remove_units_ignores_spells);
SUITE_ADD_TEST(suite, test_remove_units_without_faction);
SUITE_ADD_TEST(suite, test_remove_units_with_dead_faction);
SUITE_ADD_TEST(suite, test_remove_empty_units_in_region);
return suite;
}

View file

@ -267,7 +267,7 @@ static void peasants(region * r)
{
int peasants = rpeasants(r);
int money = rmoney(r);
int maxp = production(r) * MAXPEASANTS_PER_AREA;
int maxp = production(r);
int n, satiated;
int dead = 0;
@ -558,7 +558,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season)
/* Grundchance 1.0% */
/* Jeder Elf in der Region erhöht die Chance marginal */
elves = _min(elves, (production(r) * MAXPEASANTS_PER_AREA) / 8);
elves = _min(elves, production(r) / 8);
if (elves) {
seedchance += 1.0 - pow(0.99999, elves * RESOURCE_QUANTITY);
}
@ -693,7 +693,6 @@ void demographics(void)
for (r = regions; r; r = r->next) {
++r->age; /* also oceans. no idea why we didn't always do that */
live(r);
/* check_split_dragons(); */
if (!fval(r->terrain, SEA_REGION)) {
/* die Nachfrage nach Produkten steigt. */

View file

@ -23,8 +23,6 @@ extern "C" {
#endif
extern int writepasswd(void);
int getoption(void);
int wanderoff(struct region *r, int p);
void demographics(void);
void last_orders(void);
void find_address(void);

View file

@ -35,16 +35,6 @@
/* util includes */
#include <util/attrib.h>
#include <util/base36.h>
#include <util/event.h>
#include <util/goodies.h>
#include <util/language.h>
#include <util/lists.h>
#include <util/log.h>
#include <util/umlaut.h>
#include <util/parser.h>
#include <util/rng.h>
#include <storage.h>
/* libc includes */
@ -56,18 +46,11 @@
static int read_permissions(attrib * a, void *owner, struct storage *store)
{
attrib *attr = NULL;
a_read(store, &attr, NULL);
a_free(attr);
a_read(store, &attr, owner);
a_remove(&attr, a);
return AT_READ_OK;
}
struct attrib_type at_permissions = {
"GM:permissions",
NULL, NULL, NULL,
NULL, read_permissions,
ATF_UNIQUE
};
static int read_gmcreate(attrib * a, void *owner, struct storage *store)
{
char zText[32];
@ -75,15 +58,8 @@ static int read_gmcreate(attrib * a, void *owner, struct storage *store)
return AT_READ_OK;
}
/* at_gmcreate specifies that the owner can create items of a particular type */
attrib_type at_gmcreate = {
"GM:create",
NULL, NULL, NULL,
NULL, read_gmcreate
};
void register_gmcmd(void)
{
at_register(&at_gmcreate);
at_register(&at_permissions);
at_deprecate("GM:create", read_gmcreate);
at_deprecate("GM:permissions", read_permissions);
}

View file

@ -493,25 +493,37 @@ int teach_cmd(unit * u, struct order *ord)
return 0;
}
static double study_speedup(unit * u)
typedef enum study_rule_t {
STUDY_DEFAULT = 0,
STUDY_FASTER = 1,
STUDY_AUTOTEACH = 2
} study_rule_t;
static double study_speedup(unit * u, skill_t s, study_rule_t rule)
{
#define MINTURN 5 /* 5 */
#define OFSTURN 2 /* 2 */
if (turn > MINTURN) {
static int speed_rule = -1;
if (speed_rule < 0) {
speed_rule = get_param_int(global.parameters, "study.speedup", 0);
}
if (speed_rule == 1) {
double learn_age = OFSTURN;
#define MINTURN 16
double learnweeks = 0;
int i;
if (turn > MINTURN) {
if (rule == STUDY_FASTER) {
for (i = 0; i != u->skill_size; ++i) {
skill *sv = u->skills + i;
double learn_time = sv->level * (sv->level + 1) / 2.0;
learn_age += learn_time;
if (sv->id == s){
learnweeks = sv->level * (sv->level + 1) / 2.0;
if (learnweeks < turn / 3) {
return 2.0;
}
if (learn_age < turn) {
return 2.0 - learn_age / turn;
}
}
return 2.0; /* If the skill was not found it is the first study. */
}
if (rule == STUDY_AUTOTEACH) {
for (i = 0; i != u->skill_size; ++i) {
skill *sv = u->skills + i;
learnweeks = +(sv->level * (sv->level + 1) / 2.0);
}
if (learnweeks < turn / 2) {
return 2.0;
}
}
}
@ -531,6 +543,7 @@ int learn_cmd(unit * u, order * ord)
int money = 0;
skill_t sk;
int maxalchemy = 0;
int speed_rule = (study_rule_t)get_param_int(global.parameters, "study.speedup", 0);
static int learn_newskills = -1;
if (learn_newskills < 0) {
const char *str = get_param(global.parameters, "study.newskills");
@ -539,7 +552,6 @@ int learn_cmd(unit * u, order * ord)
else
learn_newskills = 1;
}
if ((u_race(u)->flags & RCF_NOLEARN) || fval(u, UFL_WERE)) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_race_nolearn", "race",
u_race(u)));
@ -732,7 +744,7 @@ int learn_cmd(unit * u, order * ord)
teach->value -= u->number * 10;
}
multi *= study_speedup(u);
multi *= study_speedup(u, sk, speed_rule);
days = study_days(u, sk);
days = (int)((days + teach->value) * multi);

View file

@ -30,6 +30,7 @@ int RunAllTests(void)
ADD_TESTS(suite, race);
/* util */
ADD_TESTS(suite, config);
ADD_TESTS(suite, attrib);
ADD_TESTS(suite, base36);
ADD_TESTS(suite, bsdstring);
ADD_TESTS(suite, functions);

View file

@ -34,25 +34,26 @@ struct race *test_create_race(const char *name)
struct region *test_create_region(int x, int y, const terrain_type *terrain)
{
region *r = new_region(x, y, NULL, 0);
terraform_region(r, terrain);
terraform_region(r, terrain ? terrain : get_or_create_terrain("plain"));
rsettrees(r, 0, 0);
rsettrees(r, 1, 0);
rsettrees(r, 2, 0);
rsethorses(r, 0);
rsetpeasants(r, terrain->size);
rsetpeasants(r, r->terrain->size);
return r;
}
struct faction *test_create_faction(const struct race *rc)
{
faction *f = addfaction("nobody@eressea.de", NULL, rc?rc:rc_find("human"), default_locale, 0);
faction *f = addfaction("nobody@eressea.de", NULL, rc?rc:rc_get_or_create("human"), default_locale, 0);
return f;
}
struct unit *test_create_unit(struct faction *f, struct region *r)
{
unit *u = create_unit(r, f, 1, f?f->race:rc_find("human"), 0, 0, 0);
return u;
const struct race * rc = f ? f->race : 0;
assert(f || !r);
return create_unit(r, f, 1, rc ? rc : rc_get_or_create("human"), 0, 0, 0);
}
void test_cleanup(void)

View file

@ -1,9 +1,22 @@
#ifndef ERESSEA_TESTS_H
#define ERESSEA_TESTS_H
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
struct region;
struct unit;
struct faction;
struct building;
struct ship;
struct item_type;
struct building_type;
struct ship_type;
struct terrain_type;
void test_cleanup(void);
struct terrain_type * test_create_terrain(const char * name, unsigned int flags);

View file

@ -1,7 +1,7 @@
/*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Copyright (c) 1998-2014, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@ -60,28 +60,26 @@ static int removecurse_handle(trigger * t, void *data)
/* call an event handler on removecurse.
* data.v -> ( variant event, int timer )
*/
removecurse_data *td = (removecurse_data *) t->data.v;
removecurse_data *td = (removecurse_data *)t->data.v;
if (td->curse && td->target) {
attrib *a = a_select(td->target->attribs, td->curse, cmp_curse);
if (a) {
a_remove(&td->target->attribs, a);
} else
if (!remove_curse(&td->target->attribs, td->curse)) {
log_error("could not perform removecurse::handle()\n");
}
}
unused_arg(data);
return 0;
}
static void removecurse_write(const trigger * t, struct storage *store)
{
removecurse_data *td = (removecurse_data *) t->data.v;
removecurse_data *td = (removecurse_data *)t->data.v;
WRITE_TOK(store, td->target ? itoa36(td->target->no) : 0);
WRITE_INT(store, td->curse ? td->curse->no : 0);
}
static int removecurse_read(trigger * t, struct storage *store)
{
removecurse_data *td = (removecurse_data *) t->data.v;
removecurse_data *td = (removecurse_data *)t->data.v;
read_reference(&td->target, store, read_unit_reference, resolve_unit);
read_reference(&td->curse, store, read_int, resolve_curse);
@ -101,7 +99,7 @@ trigger_type tt_removecurse = {
trigger *trigger_removecurse(curse * c, unit * target)
{
trigger *t = t_new(&tt_removecurse);
removecurse_data *td = (removecurse_data *) t->data.v;
removecurse_data *td = (removecurse_data *)t->data.v;
td->curse = c;
td->target = target;
return t;

View file

@ -2,6 +2,7 @@ project(util C)
SET(_TEST_FILES
base36.test.c
attrib.test.c
strings.test.c
bsdstring.test.c
functions.test.c

View file

@ -1,7 +1,7 @@
/*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@ -29,7 +29,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stdlib.h>
#define MAXATHASH 61
attrib_type *at_hash[MAXATHASH];
static attrib_type *at_hash[MAXATHASH];
static unsigned int __at_hashkey(const char *s)
{
@ -51,12 +51,14 @@ void at_register(attrib_type * at)
}
at->hashkey = __at_hashkey(at->name);
find = at_hash[at->hashkey % MAXATHASH];
while (find && at->hashkey != find->hashkey)
while (find && at->hashkey != find->hashkey) {
find = find->nexthash;
}
if (find && find == at) {
log_warning("attribute '%s' was registered more than once\n", at->name);
return;
} else {
}
else {
assert(!find || !"hashkey is already in use");
}
at->nexthash = at_hash[at->hashkey % MAXATHASH];
@ -66,9 +68,9 @@ void at_register(attrib_type * at)
static attrib_type *at_find(unsigned int hk)
{
const char *translate[3][2] = {
{"zielregion", "targetregion"}, /* remapping: from 'zielregion, heute targetregion */
{"verzaubert", "curse"}, /* remapping: früher verzaubert, jetzt curse */
{NULL, NULL}
{ "zielregion", "targetregion" }, /* remapping: from 'zielregion, heute targetregion */
{ "verzaubert", "curse" }, /* remapping: früher verzaubert, jetzt curse */
{ NULL, NULL }
};
attrib_type *find = at_hash[hk % MAXATHASH];
while (find && hk != find->hashkey)
@ -149,14 +151,6 @@ attrib *a_add(attrib ** pa, attrib * a)
return a;
}
void a_free(attrib * a)
{
const attrib_type *at = a->type;
if (at->finalize)
at->finalize(a);
free(a);
}
static int a_unlink(attrib ** pa, attrib * a)
{
attrib **pnexttype = pa;
@ -180,7 +174,8 @@ static int a_unlink(attrib ** pa, attrib * a)
return 1;
while (*pnext && (*pnext)->type != a->type)
pnext = &(*pnext)->next;
} else {
}
else {
pnext = &(*pnexttype)->next;
}
while (*pnext && (*pnext)->type == a->type) {
@ -194,6 +189,14 @@ static int a_unlink(attrib ** pa, attrib * a)
return 0;
}
static void a_free(attrib * a)
{
const attrib_type *at = a->type;
if (at->finalize)
at->finalize(a);
free(a);
}
int a_remove(attrib ** pa, attrib * a)
{
int ok;
@ -235,7 +238,7 @@ void a_removeall(attrib ** pa, const attrib_type * at)
attrib *a_new(const attrib_type * at)
{
attrib *a = (attrib *) calloc(1, sizeof(attrib));
attrib *a = (attrib *)calloc(1, sizeof(attrib));
assert(at != NULL);
a->type = at;
if (at->initialize)
@ -265,7 +268,7 @@ int a_age(attrib ** p)
static critbit_tree cb_deprecated = { 0 };
void at_deprecate(const char * name, int (*reader)(attrib *, void *, struct storage *))
void at_deprecate(const char * name, int(*reader)(attrib *, void *, struct storage *))
{
char buffer[64];
size_t len = strlen(name);
@ -287,19 +290,21 @@ int a_read(struct storage *store, attrib ** attribs, void *owner)
key = __at_hashkey(zText);
while (key != -1) {
int (*reader)(attrib *, void *, struct storage *) = 0;
int(*reader)(attrib *, void *, struct storage *) = 0;
attrib_type *at = at_find(key);
attrib * na = 0;
if (at) {
reader = at->read;
na = a_new(at);
} else {
}
else {
const void * kv;
cb_find_prefix(&cb_deprecated, zText, strlen(zText)+1, &kv, 1, 0);
cb_find_prefix(&cb_deprecated, zText, strlen(zText) + 1, &kv, 1, 0);
if (kv) {
cb_get_kv(kv, &reader, sizeof(reader));
} else {
}
else {
fprintf(stderr, "attribute hash: %d (%s)\n", key, zText);
assert(at || !"attribute not registered");
}
@ -320,7 +325,8 @@ int a_read(struct storage *store, attrib ** attribs, void *owner)
break;
}
}
} else {
}
else {
assert(!"error: no registered callback can read attribute");
}
@ -342,7 +348,8 @@ void a_write(struct storage *store, const attrib * attribs, const void *owner)
WRITE_TOK(store, na->type->name);
na->type->write(na, owner, store);
na = na->next;
} else {
}
else {
na = na->nexttype;
}
}

View file

@ -1,7 +1,7 @@
/*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@ -18,13 +18,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef ATTRIB_H
#define ATTRIB_H
#ifdef __cplusplus
extern "C" {
#endif
struct gamedata;
struct storage;
typedef void (*afun) (void);
typedef void(*afun) (void);
typedef struct attrib {
const struct attrib_type *type;
@ -49,9 +50,9 @@ extern "C" {
typedef struct attrib_type {
const char *name;
void (*initialize) (struct attrib *);
void (*finalize) (struct attrib *);
int (*age) (struct attrib *);
void(*initialize) (struct attrib *);
void(*finalize) (struct attrib *);
int(*age) (struct attrib *);
/* age returns 0 if the attribute needs to be removed, !=0 otherwise */
void(*write) (const struct attrib *, const void *owner, struct storage *);
int(*read) (struct attrib *, void *owner, struct storage *); /* return AT_READ_OK on success, AT_READ_FAIL if attrib needs removal */
@ -62,7 +63,7 @@ extern "C" {
} attrib_type;
extern void at_register(attrib_type * at);
extern void at_deprecate(const char * name, int (*reader)(attrib *, void *, struct storage *));
extern void at_deprecate(const char * name, int(*reader)(attrib *, void *, struct storage *));
extern attrib *a_select(attrib * a, const void *data,
bool(*compare) (const attrib *, const void *));
@ -72,7 +73,6 @@ extern "C" {
extern int a_remove(attrib ** pa, attrib * at);
extern void a_removeall(attrib ** a, const attrib_type * at);
extern attrib *a_new(const attrib_type * at);
extern void a_free(attrib * a);
extern int a_age(attrib ** attribs);
extern int a_read(struct storage *store, attrib ** attribs, void *owner);

84
src/util/attrib.test.c Normal file
View file

@ -0,0 +1,84 @@
#include <platform.h>
#include "attrib.h"
#include <CuTest.h>
#include <tests.h>
static void test_attrib_new(CuTest * tc)
{
attrib_type at_test = { "test" };
attrib * a;
CuAssertPtrNotNull(tc, (a = a_new(&at_test)));
CuAssertPtrEquals(tc, 0, a->next);
CuAssertPtrEquals(tc, 0, a->nexttype);
CuAssertPtrEquals(tc, (void *)a->type, (void *)&at_test);
a_remove(&a, a);
CuAssertPtrEquals(tc, 0, a);
}
static void test_attrib_add(CuTest * tc)
{
attrib_type at_foo = { "foo" };
attrib_type at_bar = { "bar" };
attrib *a, *alist = 0;
CuAssertPtrNotNull(tc, (a = a_new(&at_foo)));
CuAssertPtrEquals(tc, a, a_add(&alist, a));
CuAssertPtrEquals(tc, a, alist);
CuAssertPtrNotNull(tc, (a = a_add(&alist, a_new(&at_foo))));
CuAssertPtrEquals_Msg(tc, "new attribute not added after existing", alist->next, a);
CuAssertPtrNotNull(tc, (a = a_add(&alist, a_new(&at_bar))));
CuAssertPtrEquals_Msg(tc, "new atribute not added at end of list", alist->next->next, a);
CuAssertPtrNotNull(tc, (a = a_add(&alist, a_new(&at_foo))));
CuAssertPtrEquals_Msg(tc, "messages not sorted by type", alist->next->next, a);
a_removeall(&alist, &at_foo);
a_removeall(&alist, &at_bar);
}
static void test_attrib_remove(CuTest * tc)
{
attrib_type at_foo = { "foo" };
attrib *a, *alist = 0;
CuAssertPtrNotNull(tc, a_add(&alist, a_new(&at_foo)));
CuAssertPtrNotNull(tc, a = a_add(&alist, a_new(&at_foo)));
CuAssertIntEquals(tc, 1, a_remove(&alist, a));
CuAssertPtrNotNull(tc, alist);
CuAssertIntEquals(tc, 1, a_remove(&alist, alist));
CuAssertPtrEquals(tc, 0, alist);
}
static void test_attrib_nexttype(CuTest * tc)
{
attrib_type at_foo = { "foo" };
attrib_type at_bar = { "bar" };
attrib *a, *alist = 0;
CuAssertPtrNotNull(tc, (a = a_new(&at_foo)));
CuAssertPtrEquals(tc, 0, a->nexttype);
CuAssertPtrEquals(tc, a, a_add(&alist, a));
CuAssertPtrEquals(tc, 0, alist->nexttype);
CuAssertPtrNotNull(tc, a_add(&alist, a_new(&at_foo)));
CuAssertPtrEquals(tc, 0, alist->nexttype);
CuAssertPtrNotNull(tc, (a = a_add(&alist, a_new(&at_bar))));
CuAssertPtrEquals(tc, a, alist->nexttype);
CuAssertPtrEquals(tc, 0, a->nexttype);
a_removeall(&alist, &at_foo);
a_removeall(&alist, &at_bar);
}
CuSuite *get_attrib_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_attrib_new);
SUITE_ADD_TEST(suite, test_attrib_add);
SUITE_ADD_TEST(suite, test_attrib_remove);
SUITE_ADD_TEST(suite, test_attrib_nexttype);
return suite;
}