forked from github/server
cleaning up the lists functionality a bit. I have plans.
This commit is contained in:
parent
e8d00d8744
commit
0adf7899dd
9 changed files with 73 additions and 91 deletions
|
@ -31,7 +31,6 @@ without prior permission by the authors of Eressea.
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <util/attrib.h>
|
#include <util/attrib.h>
|
||||||
#include <util/base36.h>
|
#include <util/base36.h>
|
||||||
#include <util/lists.h>
|
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
#include <util/parser.h>
|
#include <util/parser.h>
|
||||||
#include <util/rng.h>
|
#include <util/rng.h>
|
||||||
|
|
|
@ -58,7 +58,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <util/bsdstring.h>
|
#include <util/bsdstring.h>
|
||||||
#include <util/cvector.h>
|
#include <util/cvector.h>
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
#include <util/lists.h>
|
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
#include <util/parser.h>
|
#include <util/parser.h>
|
||||||
#include <util/rand.h>
|
#include <util/rand.h>
|
||||||
|
@ -4175,7 +4174,11 @@ battle_stats(FILE * F, battle * b)
|
||||||
for (stat=stats;stat!=NULL;stat=stat->next) {
|
for (stat=stats;stat!=NULL;stat=stat->next) {
|
||||||
fprintf(F, "%s %u : %u\n", stat->wtype?stat->wtype->itype->rtype->_name[0]:"none", stat->level, stat->number);
|
fprintf(F, "%s %u : %u\n", stat->wtype?stat->wtype->itype->rtype->_name[0]:"none", stat->level, stat->number);
|
||||||
}
|
}
|
||||||
freelist(stats);
|
while(stats) {
|
||||||
|
stat_info * stat = stats;
|
||||||
|
stats = stat->next;
|
||||||
|
free(stat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <util/event.h>
|
#include <util/event.h>
|
||||||
#include <util/functions.h>
|
#include <util/functions.h>
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
#include <util/lists.h>
|
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
#include <util/resolve.h>
|
#include <util/resolve.h>
|
||||||
#include <util/storage.h>
|
#include <util/storage.h>
|
||||||
|
@ -454,6 +453,7 @@ add_buildinglist(building_list **blist, building *b)
|
||||||
building *
|
building *
|
||||||
new_building(const struct building_type * btype, region * r, const struct locale * lang)
|
new_building(const struct building_type * btype, region * r, const struct locale * lang)
|
||||||
{
|
{
|
||||||
|
building ** bptr = &r->buildings;
|
||||||
building *b = (building *) calloc(1, sizeof(building));
|
building *b = (building *) calloc(1, sizeof(building));
|
||||||
static boolean init_lighthouse = false;
|
static boolean init_lighthouse = false;
|
||||||
static const struct building_type * bt_lighthouse = 0;
|
static const struct building_type * bt_lighthouse = 0;
|
||||||
|
@ -469,7 +469,8 @@ new_building(const struct building_type * btype, region * r, const struct locale
|
||||||
|
|
||||||
b->type = btype;
|
b->type = btype;
|
||||||
b->region = r;
|
b->region = r;
|
||||||
addlist(&r->buildings, b);
|
while (*bptr) bptr=&(*bptr)->next;
|
||||||
|
*bptr = b;
|
||||||
|
|
||||||
if (b->type==bt_lighthouse) {
|
if (b->type==bt_lighthouse) {
|
||||||
r->flags |= RF_LIGHTHOUSE;
|
r->flags |= RF_LIGHTHOUSE;
|
||||||
|
|
|
@ -729,7 +729,7 @@ verify_data(void)
|
||||||
|
|
||||||
if (verbosity>=1) puts(" - Überprüfe Daten auf Korrektheit...");
|
if (verbosity>=1) puts(" - Überprüfe Daten auf Korrektheit...");
|
||||||
|
|
||||||
list_foreach(faction, factions, f) {
|
for (f=factions; f; f=f->next) {
|
||||||
mage = 0;
|
mage = 0;
|
||||||
alchemist = 0;
|
alchemist = 0;
|
||||||
for (u=f->units;u;u=u->nextF) {
|
for (u=f->units;u;u=u->nextF) {
|
||||||
|
@ -751,7 +751,6 @@ verify_data(void)
|
||||||
if (alchemist > 3)
|
if (alchemist > 3)
|
||||||
log_error(("Partei %s hat %d Alchemisten.\n", factionid(f), alchemist));
|
log_error(("Partei %s hat %d Alchemisten.\n", factionid(f), alchemist));
|
||||||
}
|
}
|
||||||
list_next(f);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,8 @@ typedef struct faction {
|
||||||
int max_spelllevel;
|
int max_spelllevel;
|
||||||
struct spell_list * spellbook;
|
struct spell_list * spellbook;
|
||||||
const struct locale * locale;
|
const struct locale * locale;
|
||||||
int lastorders; /* enno: short? */
|
int lastorders;
|
||||||
int age; /* enno: short? */
|
int age;
|
||||||
struct ursprung *ursprung;
|
struct ursprung *ursprung;
|
||||||
const struct race * race;
|
const struct race * race;
|
||||||
magic_t magiegebiet;
|
magic_t magiegebiet;
|
||||||
|
|
|
@ -609,3 +609,8 @@ write_order(const order * ord, char * buffer, size_t size)
|
||||||
}
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void push_order(order ** ordp, order * ord) {
|
||||||
|
while (*ordp) ordp=&(*ordp)->next;
|
||||||
|
*ordp = ord;
|
||||||
|
}
|
|
@ -44,6 +44,8 @@ extern order * copy_order(const order * ord);
|
||||||
extern void free_order(order * ord);
|
extern void free_order(order * ord);
|
||||||
extern void free_orders(order ** olist);
|
extern void free_orders(order ** olist);
|
||||||
|
|
||||||
|
extern void push_order(struct order ** olist, struct order * ord);
|
||||||
|
|
||||||
/* access functions for orders */
|
/* access functions for orders */
|
||||||
extern keyword_t get_keyword(const order * ord);
|
extern keyword_t get_keyword(const order * ord);
|
||||||
extern void set_order(order ** destp, order * src);
|
extern void set_order(order ** destp, order * src);
|
||||||
|
|
|
@ -22,6 +22,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include "lists.h"
|
#include "lists.h"
|
||||||
|
|
||||||
|
typedef struct void_list {
|
||||||
|
struct void_list * next;
|
||||||
|
void * data;
|
||||||
|
} void_list;
|
||||||
|
|
||||||
void
|
void
|
||||||
addlist(void *l1, void *p1)
|
addlist(void *l1, void *p1)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +48,7 @@ addlist(void *l1, void *p1)
|
||||||
*l = p;
|
*l = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
choplist(void * a, void * b)
|
choplist(void * a, void * b)
|
||||||
{
|
{
|
||||||
void_list **l = (void_list**)a, *p = (void_list*)b;
|
void_list **l = (void_list**)a, *p = (void_list*)b;
|
||||||
|
@ -122,22 +127,3 @@ listlen(void *l)
|
||||||
for (p = (void_list *)l, i = 0; p; p = p->next, i++);
|
for (p = (void_list *)l, i = 0; p; p = p->next, i++);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hilfsfunktion, um das Debugging zu erleichtern. Statt print
|
|
||||||
* (cast)foo->next->next->next->next nur noch
|
|
||||||
* print (cast)listelem(foo, 3) */
|
|
||||||
|
|
||||||
void *
|
|
||||||
listelem(void *l, int n)
|
|
||||||
{
|
|
||||||
int i=0;
|
|
||||||
|
|
||||||
while(i < n && l != NULL) {
|
|
||||||
l = ((void_list *)l)->next;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,17 +24,7 @@ extern "C" {
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
typedef struct void_list {
|
|
||||||
struct void_list * next;
|
|
||||||
void * data;
|
|
||||||
} void_list;
|
|
||||||
|
|
||||||
#define list_foreach(type, list, item) item=list; while (item!=NULL) { type* __next__=item->next;
|
|
||||||
#define list_continue(item) { item=__next__; continue; }
|
|
||||||
#define list_next(item) item=__next__; }
|
|
||||||
|
|
||||||
void addlist(void *l1, void *p1);
|
void addlist(void *l1, void *p1);
|
||||||
void choplist(void * l, void * p);
|
|
||||||
void translist(void *l1, void *l2, void *p);
|
void translist(void *l1, void *l2, void *p);
|
||||||
#ifndef MALLOCDBG
|
#ifndef MALLOCDBG
|
||||||
void freelist(void *p1);
|
void freelist(void *p1);
|
||||||
|
@ -45,9 +35,6 @@ void removelist(void *l, void *p);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned int listlen(void *l);
|
unsigned int listlen(void *l);
|
||||||
#define addlist2(l, p) (*l = p, l = &p->next)
|
|
||||||
|
|
||||||
void *listelem(void *l, int n);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue