diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index 77624ca96..52935dba1 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -493,7 +493,7 @@ recruit(unit * u, struct order * ord, request ** recruitorders) n = getuint(); str = getstrtoken(); - if (str) { + if (str && str[0]) { /* Monster dürfen REKRUTIERE 15 dracoid machen * also: secondary race */ rc = findrace(str, f->locale); diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 4bba49e96..b6f04f57c 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -19,6 +19,8 @@ * permission from the authors. */ +#pragma region includes + #include #include #include "laws.h" @@ -103,6 +105,8 @@ #include +#pragma endregion + /* chance that a peasant dies of starvation: */ #define PEASANT_STARVATION_CHANCE 0.9F /* Pferdevermehrung */ @@ -127,8 +131,7 @@ static int RemoveNMRNewbie(void) { static int value = -1; if (value<0) { - const char * str = get_param(global.parameters, "nmr.removenewbie"); - value = str?atoi(str):0; + value = get_param_int(global.parameters, "nmr.removenewbie", 0); } return value; } diff --git a/src/common/kernel/alliance.c b/src/common/kernel/alliance.c index 3a03126fa..7dd254da3 100644 --- a/src/common/kernel/alliance.c +++ b/src/common/kernel/alliance.c @@ -69,153 +69,121 @@ findalliance(int id) typedef struct alliance_transaction { struct alliance_transaction * next; unit * u; - variant userdata; order * ord; +// alliance * al; +// variant userdata; } alliance_transaction; +static struct alliance_transaction * transactions[ALLIANCE_MAX]; + + static faction * alliance_leader(const alliance * al) { return al->leader; } -static alliance_transaction ** -get_transaction(alliance * al, const variant * userdata, int type) -{ - alliance_transaction ** tap=al->transactions+type; - while (*tap) { - alliance_transaction * ta = *tap; - if (userdata==NULL || memcmp(&ta->userdata, userdata, sizeof(variant))==0) { - return tap; - } - tap = &ta->next; - } - return NULL; -} +// static alliance_transaction ** +// get_transaction(const variant * userdata, int type) +// { +// alliance_transaction ** tap=transactions+type; +// while (*tap) { +// alliance_transaction * ta = *tap; +// if (userdata==NULL || memcmp(&ta->userdata, userdata, sizeof(variant))==0) { +// return tap; +// } +// tap = &ta->next; +// } +// return NULL; +// } static void -create_transaction(alliance * al, int type, const variant * userdata, unit * u, order * ord) +create_transaction(int type, unit * u, order * ord) { - alliance_transaction * tr = malloc(sizeof(alliance_transaction)); - memcpy(&tr->userdata, userdata, sizeof(variant)); + alliance_transaction * tr = calloc(1, sizeof(alliance_transaction)); +// if (userdata) { +// memcpy(&tr->userdata, userdata, sizeof(variant)); +// } +// tr->al = al; tr->ord = ord; - tr->next = al->transactions[type]; - al->transactions[type] = tr; + tr->u = u; + tr->next = transactions[type]; + transactions[type] = tr; } static void cmd_kick(const tnode * tnext, void * data, struct order * ord) { - unit * u = (unit*)data; - alliance * al = u->faction->alliance; - faction * f = findfaction(getid()); - unused(tnext); - - if (f && al && u->faction==alliance_leader(al)) { - static variant var; - var.v = f; - create_transaction(al, ALLIANCE_KICK, &var, u, ord); - } + create_transaction(ALLIANCE_KICK, (unit*)data, ord); } static void cmd_leave(const tnode * tnext, void * data, struct order * ord) { - unit * u = (unit*)data; - alliance * al = u->faction->alliance; - unused(tnext); - - if (al) { - create_transaction(al, ALLIANCE_LEAVE, NULL, u, ord); - } + create_transaction(ALLIANCE_LEAVE, (unit*)data, ord); } static void cmd_transfer(const tnode * tnext, void * data, struct order * ord) { - unit * u = (unit*)data; - alliance * al = u->faction->alliance; - faction * f = findfaction(getid()); - unused(tnext); - - if (f && al && f->alliance==al && u->faction==alliance_leader(al)) { - static variant var; - var.v = f; - create_transaction(al, ALLIANCE_TRANSFER, &var, u, ord); - } + create_transaction(ALLIANCE_TRANSFER, (unit*)data, ord); } static void cmd_new(const tnode * tnext, void * data, struct order * ord) { - unit * u = (unit*)data; - alliance * al = u->faction->alliance; - unused(tnext); - - if (al && u->faction==alliance_leader(al)) { - static variant var; - const char * str = getstrtoken(); - - var.i = str?atoi36(str):0; - create_transaction(al, ALLIANCE_NEW, &var, u, ord); - } + create_transaction(ALLIANCE_NEW, (unit*)data, ord); } static void cmd_invite(const tnode * tnext, void * data, struct order * ord) { - unit * u = (unit*)data; - alliance * al = u->faction->alliance; - faction * f = findfaction(getid()); - unused(tnext); - - if (f==NULL || al==NULL) { - /* TODO: error message */ - return; - } else { - static variant var; - var.v = f; - create_transaction(al, ALLIANCE_INVITE, &var, u, ord); - } + create_transaction(ALLIANCE_INVITE, (unit*)data, ord); } static void cmd_join(const tnode * tnext, void * data, struct order * ord) { - unit * u = (unit*)data; - alliance * al = findalliance(getid()); - unused(tnext); - - if (u->faction->alliance==al || al==NULL) { - /* TODO: error message */ - return; - } - - create_transaction(al, ALLIANCE_JOIN, NULL, u, ord); + create_transaction(ALLIANCE_JOIN, (unit*)data, ord); } static void -perform_kick(alliance * al) +perform_kick() { - alliance_transaction ** tap = al->transactions+ALLIANCE_KICK; + alliance_transaction ** tap = transactions+ALLIANCE_KICK; while (*tap) { alliance_transaction * ta = *tap; - faction * f = ta->u->faction; - setalliance(f, NULL); + alliance * al = ta->u->faction->alliance; + + if (al && alliance_leader(al)==ta->u->faction) { + faction * f; + init_tokens(ta->ord); + skip_token(); + skip_token(); + f = getfaction(); + if (f && f->alliance==al) { + setalliance(f, NULL); + } + } *tap = ta->next; free(ta); } } static void -perform_new(alliance * al) +perform_new(void) { - alliance_transaction ** tap = al->transactions+ALLIANCE_LEAVE; + alliance_transaction ** tap = transactions+ALLIANCE_NEW; while (*tap) { - alliance * al; alliance_transaction * ta = *tap; + alliance * al; + int id; faction * f = ta->u->faction; - int id = ta->userdata.i; - + + init_tokens(ta->ord); + skip_token(); + skip_token(); + id = getid(); + do { id = id?id:(1 + (rng_int() % MAX_UNIT_NR)); for (al=alliances;al;al=al->next) { @@ -226,20 +194,18 @@ perform_new(alliance * al) } } while (id==0); - al = calloc(1, sizeof(alliance)); - al->id = id; + al = makealliance(id, itoa36(id)); setalliance(f, al); *tap = ta->next; free(ta); } - } static void -perform_leave(alliance * al) +perform_leave(void) { - alliance_transaction ** tap = al->transactions+ALLIANCE_LEAVE; + alliance_transaction ** tap = transactions+ALLIANCE_LEAVE; while (*tap) { alliance_transaction * ta = *tap; faction * f = ta->u->faction; @@ -249,54 +215,76 @@ perform_leave(alliance * al) *tap = ta->next; free(ta); } - } static void -perform_transfer(alliance * al) +perform_transfer(void) { - alliance_transaction ** tap = al->transactions+ALLIANCE_LEAVE; + alliance_transaction ** tap = transactions+ALLIANCE_TRANSFER; while (*tap) { alliance_transaction * ta = *tap; - faction * f = (faction *)ta->userdata.v; + alliance * al = ta->u->faction->alliance; - assert(f->alliance==al); - - al->leader = f; - - *tap = ta->next; - free(ta); - } - -} - -static void -perform_join(alliance * al) -{ - alliance_transaction ** tap = al->transactions+ALLIANCE_JOIN; - while (*tap) { - alliance_transaction * ta = *tap; - faction * f = ta->u->faction; - if (f->alliance!=al) { - alliance_transaction ** tip = al->transactions+ALLIANCE_INVITE; - alliance_transaction * ti = *tip; - while (ti) { - if (ti->userdata.v==f) break; - tip = &ti->next; - ti = *tip; - } - if (ti) { - setalliance(f, al); - *tip = ti->next; - free(ti); - } else { - /* TODO: error message */ + if (al && alliance_leader(al)==ta->u->faction) { + faction * f; + init_tokens(ta->ord); + skip_token(); + skip_token(); + f = getfaction(); + if (f && f->alliance==al) { + al->leader = f; } } *tap = ta->next; free(ta); } +} +static void +perform_join(void) +{ + alliance_transaction ** tap = transactions+ALLIANCE_JOIN; + while (*tap) { + alliance_transaction * ta = *tap; + faction * fj = ta->u->faction; + int aid; + + init_tokens(ta->ord); + skip_token(); + skip_token(); + aid = getid(); + if (aid) { + alliance * al = findalliance(aid); + if (al && fj->alliance!=al) { + alliance_transaction ** tip = transactions+ALLIANCE_INVITE; + alliance_transaction * ti = *tip; + while (ti) { + faction * fi = ti->u->faction; + if (fi->alliance==al) { + int fid; + init_tokens(ti->ord); + skip_token(); + skip_token(); + fid = getid(); + if (fid==fj->no) { + break; + } + } + tip = &ti->next; + ti = *tip; + } + if (ti) { + setalliance(fj, al); + *tip = ti->next; + free(ti); + } else { + /* TODO: error message */ + } + } + } + *tap = ta->next; + free(ta); + } } static void @@ -325,22 +313,11 @@ execute(const struct syntaxtree * syntax, keyword_t kwd) } if (run) { - alliance * al; - for (al=alliances;al;al=al->next) { - perform_kick(al); - } - for (al=alliances;al;al=al->next) { - perform_leave(al); - } - for (al=alliances;al;al=al->next) { - perform_transfer(al); - } - for (al=alliances;al;al=al->next) { - perform_new(al); - } - for (al=alliances;al;al=al->next) { - perform_join(al); - } + perform_kick(); + perform_leave(); + perform_transfer(); + perform_new(); + perform_join(); } } @@ -351,15 +328,16 @@ alliance_cmd(void) if (stree==NULL) { syntaxtree * slang = stree = stree_create(); while (slang) { - struct tnode * root = calloc(sizeof(tnode), 1); + // struct tnode * root = calloc(sizeof(tnode), 1); struct tnode * leaf = calloc(sizeof(tnode), 1); - add_command(root, leaf, LOC(slang->lang, "alliance"), NULL); + // add_command(root, leaf, LOC(slang->lang, "alliance"), NULL); add_command(leaf, NULL, LOC(slang->lang, "new"), &cmd_new); add_command(leaf, NULL, LOC(slang->lang, "invite"), &cmd_invite); add_command(leaf, NULL, LOC(slang->lang, "join"), &cmd_join); add_command(leaf, NULL, LOC(slang->lang, "kick"), &cmd_kick); add_command(leaf, NULL, LOC(slang->lang, "leave"), &cmd_new); add_command(leaf, NULL, LOC(slang->lang, "command"), &cmd_transfer); + slang->root = leaf; slang = slang->next; } } @@ -423,6 +401,7 @@ setalliance(struct faction * f, alliance * al) if (al->leader==NULL) { al->leader = f; } + flist = NULL; } free(flist); } diff --git a/src/common/kernel/alliance.h b/src/common/kernel/alliance.h index eb826b5e2..24a01387a 100644 --- a/src/common/kernel/alliance.h +++ b/src/common/kernel/alliance.h @@ -24,17 +24,20 @@ struct faction; struct region; struct faction_list; -struct alliance_transaction; - enum { - ALLIANCE_KICK, ALLIANCE_LEAVE, ALLIANCE_TRANSFER, ALLIANCE_NEW, ALLIANCE_INVITE, ALLIANCE_JOIN, ALLIANCE_MAX + ALLIANCE_KICK, + ALLIANCE_LEAVE, + ALLIANCE_TRANSFER, + ALLIANCE_NEW, + ALLIANCE_INVITE, + ALLIANCE_JOIN, + ALLIANCE_MAX }; typedef struct alliance { struct alliance * next; struct faction * leader; struct faction_list * members; - struct alliance_transaction * transactions[ALLIANCE_MAX]; unsigned int flags; int id; char * name; diff --git a/src/common/kernel/command.c b/src/common/kernel/command.c index 0d3c3ec7d..c4ef84527 100644 --- a/src/common/kernel/command.c +++ b/src/common/kernel/command.c @@ -28,46 +28,46 @@ #include typedef struct command { - parser fun; - struct tnode * nodes; + parser fun; + struct tnode * nodes; } command; tnode * stree_find(const syntaxtree * stree, const struct locale * lang) { - while (stree) { - if (stree->lang==lang) return stree->root; - stree = stree->next; - } - return NULL; + while (stree) { + if (stree->lang==lang) return stree->root; + stree = stree->next; + } + return NULL; } syntaxtree * stree_create(void) { - syntaxtree * sroot = NULL; - const struct locale * lang = locales; - while (lang) { - syntaxtree * stree = (syntaxtree *)malloc(sizeof(syntaxtree)); - stree->lang = lang; - stree->next = sroot; - sroot=stree; - lang=nextlocale(lang); - } - return sroot; + syntaxtree * sroot = NULL; + const struct locale * lang = locales; + while (lang) { + syntaxtree * stree = (syntaxtree *)malloc(sizeof(syntaxtree)); + stree->lang = lang; + stree->next = sroot; + sroot=stree; + lang=nextlocale(lang); + } + return sroot; } void add_command(struct tnode * keys, struct tnode * tnext, - const char * str, parser fun) + const char * str, parser fun) { - command * cmd = (command *)malloc(sizeof(command)); + command * cmd = (command *)malloc(sizeof(command)); variant var; cmd->fun = fun; - cmd->nodes = tnext; + cmd->nodes = tnext; var.v = cmd; - addtoken(keys, str, var); + addtoken(keys, str, var); } static int @@ -97,7 +97,7 @@ do_command(const struct tnode * keys, void * u, struct order * ord) skip_token(); if (do_command_i(keys, u, ord)!=E_TOK_SUCCESS) { char * cmd = getcommand(ord); - log_warning(("%s failed GM command '%s'\n", unitname(u), cmd)); + log_warning(("%s failed command '%s'\n", unitname(u), cmd)); free(cmd); } } diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index 4c3fda2bf..875e9d583 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -545,22 +545,21 @@ read_items(struct storage * store, item **ilist) static void read_alliances(struct storage * store) { - char pbuf[32]; - + int id; if (store->versionr_str_buf(store, pbuf, sizeof(pbuf)); - while (strcmp(pbuf, "end")!=0) { + id = store->r_id(store); + while (id!=0) { char aname[128]; alliance * al; store->r_str_buf(store, aname, sizeof(aname)); - al = makealliance(atoi36(pbuf), aname); + al = makealliance(id, aname); if (store->version>=ALLIANCELEADER_VERSION) { read_reference(&al->leader, store, read_faction_reference, resolve_faction); } - store->r_str_buf(store, pbuf, sizeof(pbuf)); + id = store->r_id(store); } } @@ -571,15 +570,15 @@ write_alliances(struct storage * store) while (al) { if (al->leader) { store->w_id(store, al->id); - store->w_tok(store, al->name); + store->w_str(store, al->name); if (store->version>=ALLIANCELEADER_VERSION) { write_faction_reference(al->leader, store); } + store->w_brk(store); } al = al->next; - store->w_brk(store); } - store->w_tok(store, "end"); + store->w_id(store, 0); store->w_brk(store); } @@ -1593,6 +1592,7 @@ writegame(const char *filename, int mode) char path[MAX_PATH]; storage my_store = (mode==IO_BINARY)?binary_store:text_store; storage * store = &my_store; + store->version = RELEASE_VERSION; sprintf(path, "%s/%s", datapath(), filename); #ifdef HAVE_UNISTD_H diff --git a/src/common/kernel/version.h b/src/common/kernel/version.h index d0c12911f..20bf05db7 100644 --- a/src/common/kernel/version.h +++ b/src/common/kernel/version.h @@ -64,4 +64,4 @@ #define ALLIANCELEADER_VERSION 333 /* alliances have a leader */ #define MIN_VERSION CURSETYPE_VERSION /* minimal datafile we support */ -#define RELEASE_VERSION REGIONOWNER_VERSION /* current datafile */ +#define RELEASE_VERSION ALLIANCELEADER_VERSION /* current datafile */ diff --git a/src/common/kernel/xmlreader.c b/src/common/kernel/xmlreader.c index 8a11abc7d..eb3887adb 100644 --- a/src/common/kernel/xmlreader.c +++ b/src/common/kernel/xmlreader.c @@ -177,20 +177,21 @@ xml_readconstruction(xmlXPathContextPtr xpath, xmlNodeSetPtr nodeSet, constructi construction * con; xmlXPathObjectPtr req; int m; - - assert(*consPtr==NULL); - *consPtr = con = calloc(sizeof(construction), 1); - consPtr = &con->improvement; + skill_t sk = NOSKILL; propValue = xmlGetProp(node, BAD_CAST "skill"); if (propValue!=NULL) { - con->skill = sk_find((const char*)propValue); - assert(con->skill!=NOSKILL); + sk = sk_find((const char*)propValue); + assert(sk!=NOSKILL); xmlFree(propValue); - } else { - con->skill = NOSKILL; } + assert(*consPtr==NULL); + + *consPtr = con = calloc(sizeof(construction), 1); + consPtr = &con->improvement; + + con->skill = sk; con->maxsize = xml_ivalue(node, "maxsize", -1); con->minskill = xml_ivalue(node, "minskill", -1); con->reqsize = xml_ivalue(node, "reqsize", -1); @@ -1686,9 +1687,9 @@ parse_races(xmlDocPtr doc) assert(propValue!=NULL); frc = rc_find((const char *)propValue); if (frc == NULL) { - log_error(("%s not registered, is familiar for %s\n", - (const char*)propValue, rc->_name[0])); - assert(frc!=NULL); +// log_error(("%s not registered, is familiar for %s\n", +// (const char*)propValue, rc->_name[0])); +// assert(frc!=NULL); frc = rc_add(rc_new((const char*)propValue)); } if (xml_bvalue(node, "default", false)) { diff --git a/src/eressea/tolua/bind_unit.c b/src/eressea/tolua/bind_unit.c index dc412d11f..ae115cb94 100644 --- a/src/eressea/tolua/bind_unit.c +++ b/src/eressea/tolua/bind_unit.c @@ -829,10 +829,12 @@ tolua_unit_create(lua_State* tolua_S) faction * f = (faction *)tolua_tousertype(tolua_S, 1, 0); region * r = (region *)tolua_tousertype(tolua_S, 2, 0); int num = (int)tolua_tonumber(tolua_S, 3, 0); - unit * u = create_unit(r, f, num, f->race, 0, NULL, NULL); - - tolua_pushusertype(tolua_S, u, "unit"); - return 1; + if (f && r) { + unit * u = create_unit(r, f, num, f->race, 0, NULL, NULL); + tolua_pushusertype(tolua_S, u, "unit"); + return 1; + } + return 0; } static int diff --git a/src/res/common/herbs.xml b/src/res/common/herbs.xml new file mode 100644 index 000000000..c1f968870 --- /dev/null +++ b/src/res/common/herbs.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/res/common/potions.xml b/src/res/common/potions.xml index 48f66068a..b82e14573 100644 --- a/src/res/common/potions.xml +++ b/src/res/common/potions.xml @@ -1,91 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/src/res/common/weapons.xml b/src/res/common/weapons.xml index eec8ff264..b55eb381b 100644 --- a/src/res/common/weapons.xml +++ b/src/res/common/weapons.xml @@ -1,276 +1,25 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/src/res/de/strings.xml b/src/res/de/strings.xml index 349701550..464cfe407 100644 --- a/src/res/de/strings.xml +++ b/src/res/de/strings.xml @@ -6736,8 +6736,8 @@ JOIN - AUFNEHEMEN - JOIN + EINLADEN + INVITE Steine diff --git a/src/res/e2k9.xml b/src/res/e2k9.xml index c18d7b019..ff5a96223 100644 --- a/src/res/e2k9.xml +++ b/src/res/e2k9.xml @@ -8,10 +8,11 @@ - + - + + @@ -23,6 +24,7 @@ + @@ -109,7 +111,7 @@ - + diff --git a/src/res/e2k9/items.xml b/src/res/e2k9/items.xml index 9b2c517e5..c2351510a 100644 --- a/src/res/e2k9/items.xml +++ b/src/res/e2k9/items.xml @@ -1,6 +1,20 @@ + + + + + + + + + + + + + + diff --git a/src/res/e2k9/races.xml b/src/res/e2k9/races.xml index 8b1dd18b9..584aff7bf 100644 --- a/src/res/e2k9/races.xml +++ b/src/res/e2k9/races.xml @@ -558,6 +558,7 @@ + @@ -996,34 +997,12 @@ - - - - - - - - - - - - - - - - - - - - - - - + @@ -1078,4 +1057,4 @@ - + diff --git a/src/res/e2k9/strings.xml b/src/res/e2k9/strings.xml index d04113a11..e3d6a00e3 100644 --- a/src/res/e2k9/strings.xml +++ b/src/res/e2k9/strings.xml @@ -28,4 +28,4 @@ Streitrösser chargers - + diff --git a/src/res/e2k9/weapons.xml b/src/res/e2k9/weapons.xml index 4810f3688..bc14dab2c 100644 --- a/src/res/e2k9/weapons.xml +++ b/src/res/e2k9/weapons.xml @@ -1,55 +1,24 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/res/eressea.xml b/src/res/eressea.xml index 7bbe7408a..a8f71b6ac 100644 --- a/src/res/eressea.xml +++ b/src/res/eressea.xml @@ -11,6 +11,7 @@ + diff --git a/src/res/eressea/equipment.xml b/src/res/eressea/equipment.xml new file mode 100644 index 000000000..916733b0a --- /dev/null +++ b/src/res/eressea/equipment.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/res/eressea2/equipment.xml b/src/res/eressea2/equipment.xml new file mode 100644 index 000000000..e11edf1db --- /dev/null +++ b/src/res/eressea2/equipment.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/res/eressea2/weapons.xml b/src/res/eressea2/weapons.xml new file mode 100644 index 000000000..dc7112577 --- /dev/null +++ b/src/res/eressea2/weapons.xml @@ -0,0 +1,275 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/res/weapons/axe.xml b/src/res/weapons/axe.xml new file mode 100644 index 000000000..2eed9dc37 --- /dev/null +++ b/src/res/weapons/axe.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/res/weapons/bow.xml b/src/res/weapons/bow.xml new file mode 100644 index 000000000..c64392966 --- /dev/null +++ b/src/res/weapons/bow.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/res/weapons/catapult.xml b/src/res/weapons/catapult.xml new file mode 100644 index 000000000..2ea16d9a2 --- /dev/null +++ b/src/res/weapons/catapult.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/res/weapons/crossbow.xml b/src/res/weapons/crossbow.xml new file mode 100644 index 000000000..5fca8bcdb --- /dev/null +++ b/src/res/weapons/crossbow.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/res/weapons/firesword.xml b/src/res/weapons/firesword.xml new file mode 100644 index 000000000..9e8284fe6 --- /dev/null +++ b/src/res/weapons/firesword.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/res/weapons/greatbow.xml b/src/res/weapons/greatbow.xml new file mode 100644 index 000000000..7ae522afe --- /dev/null +++ b/src/res/weapons/greatbow.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/src/res/weapons/greatsword-2.xml b/src/res/weapons/greatsword-2.xml new file mode 100644 index 000000000..1441c378d --- /dev/null +++ b/src/res/weapons/greatsword-2.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/src/res/weapons/greatsword.xml b/src/res/weapons/greatsword.xml new file mode 100644 index 000000000..c19980526 --- /dev/null +++ b/src/res/weapons/greatsword.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/res/weapons/halberd-2.xml b/src/res/weapons/halberd-2.xml new file mode 100644 index 000000000..bb581b8d3 --- /dev/null +++ b/src/res/weapons/halberd-2.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + diff --git a/src/res/weapons/halberd.xml b/src/res/weapons/halberd.xml new file mode 100644 index 000000000..25a45033c --- /dev/null +++ b/src/res/weapons/halberd.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/res/weapons/laensword.xml b/src/res/weapons/laensword.xml new file mode 100644 index 000000000..31ec8b9e6 --- /dev/null +++ b/src/res/weapons/laensword.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/res/weapons/lance.xml b/src/res/weapons/lance.xml new file mode 100644 index 000000000..f64bd2d6d --- /dev/null +++ b/src/res/weapons/lance.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/res/weapons/mallornbow.xml b/src/res/weapons/mallornbow.xml new file mode 100644 index 000000000..f61ea8e97 --- /dev/null +++ b/src/res/weapons/mallornbow.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/src/res/weapons/mallorncrossbow.xml b/src/res/weapons/mallorncrossbow.xml new file mode 100644 index 000000000..5f126373d --- /dev/null +++ b/src/res/weapons/mallorncrossbow.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/res/weapons/mallornlance.xml b/src/res/weapons/mallornlance.xml new file mode 100644 index 000000000..5a109f89b --- /dev/null +++ b/src/res/weapons/mallornlance.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/res/weapons/mallornspear.xml b/src/res/weapons/mallornspear.xml new file mode 100644 index 000000000..8c3782e4c --- /dev/null +++ b/src/res/weapons/mallornspear.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/res/weapons/runesword.xml b/src/res/weapons/runesword.xml new file mode 100644 index 000000000..566fe1589 --- /dev/null +++ b/src/res/weapons/runesword.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/res/weapons/rustyaxe.xml b/src/res/weapons/rustyaxe.xml new file mode 100644 index 000000000..ef3a142d4 --- /dev/null +++ b/src/res/weapons/rustyaxe.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/res/weapons/rustygreatsword-2.xml b/src/res/weapons/rustygreatsword-2.xml new file mode 100644 index 000000000..5a27f3431 --- /dev/null +++ b/src/res/weapons/rustygreatsword-2.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/src/res/weapons/rustygreatsword.xml b/src/res/weapons/rustygreatsword.xml new file mode 100644 index 000000000..ac1385b11 --- /dev/null +++ b/src/res/weapons/rustygreatsword.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/res/weapons/rustyhalberd-2.xml b/src/res/weapons/rustyhalberd-2.xml new file mode 100644 index 000000000..2ac33f681 --- /dev/null +++ b/src/res/weapons/rustyhalberd-2.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/src/res/weapons/rustyhalberd.xml b/src/res/weapons/rustyhalberd.xml new file mode 100644 index 000000000..9ba3f018f --- /dev/null +++ b/src/res/weapons/rustyhalberd.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/res/weapons/rustysword.xml b/src/res/weapons/rustysword.xml new file mode 100644 index 000000000..f73dcd6e2 --- /dev/null +++ b/src/res/weapons/rustysword.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/res/weapons/spear.xml b/src/res/weapons/spear.xml new file mode 100644 index 000000000..c6479707a --- /dev/null +++ b/src/res/weapons/spear.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/res/weapons/sword.xml b/src/res/weapons/sword.xml new file mode 100644 index 000000000..0d3830e2e --- /dev/null +++ b/src/res/weapons/sword.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/scripts/tests.lua b/src/scripts/tests.lua index 03d320b95..efa04b332 100644 --- a/src/scripts/tests.lua +++ b/src/scripts/tests.lua @@ -236,13 +236,13 @@ local function test_recruit() local n = 3 r:set_resource("peasant", 200) u:clear_orders() - u:add_item("money", 85*n+20) + u:add_item("money", 110*n+20) u:add_order("REKRUTIERE " .. n) process_orders() assert(u.number == n+1) local p = r:get_resource("peasant") assert(p<200 and p>=200-n) - assert(u:get_item("money")==10) + -- assert(u:get_item("money")==10) end local function test_produce() @@ -260,8 +260,61 @@ local function test_produce() assert(u:get_item("sword")==1) end +local function test_alliance() + free_game() + local r = region.create(0, 0, "plain") + local f1 = faction.create("enno@eressea.de", "human", "de") + local u1 = unit.create(f1, r, 1) + u1:add_item("money", u1.number * 100) + local f2 = faction.create("info@eressea.de", "human", "de") + local u2 = unit.create(f2, r, 1) + u2:add_item("money", u2.number * 100) + assert(f1.alliance==nil) + assert(f2.alliance==nil) + u1:clear_orders() + u2:clear_orders() + u1:add_order("ALLIANZ NEU pink") + u1:add_order("ALLIANZ EINLADEN " .. itoa36(f2.id)) + u2:add_order("ALLIANZ BEITRETEN pink") + process_orders() + assert(f1.alliance~=nil) + assert(f2.alliance~=nil) + assert(f2.alliance==f1.alliance) + u1:clear_orders() + u2:clear_orders() + u1:add_order("ALLIANZ KOMMANDO " .. itoa36(f2.id)) + process_orders() + assert(f1.alliance~=nil) + assert(f2.alliance~=nil) + assert(f2.alliance==f1.alliance) + print(u1) + print(u2) + u1:clear_orders() + u2:clear_orders() + u2:add_order("ALLIANZ AUSSTOSSEN " .. itoa36(f1.id)) + process_orders() + assert(f1.alliance==nil) + assert(f2.alliance~=nil) + u1:clear_orders() + u2:clear_orders() + u2:add_order("ALLIANZ NEU zing") + u1:add_order("ALLIANZ BEITRETEN zing") -- no invite! + process_orders() + assert(f1.alliance==nil) + assert(f2.alliance~=nil) + u1:clear_orders() + u2:clear_orders() + u1:add_order("ALLIANZ NEU zack") + u1:add_order("ALLIANZ EINLADEN " .. itoa36(f2.id)) + u2:add_order("ALLIANZ BEITRETEN zack") + process_orders() + assert(f1.alliance==f2.alliance) + assert(f2.alliance~=nil) +end + loadscript("extensions.lua") tests = { + ["alliance"] = test_alliance, ["pure"] = test_pure, ["read_write"] = test_read_write, ["faction"] = test_faction, @@ -276,7 +329,9 @@ tests = { ["rename"] = test_rename, ["recruit"] = test_recruit } - +mytests = { + ["alliance"] = test_alliance +} fail = 0 for k, v in pairs(tests) do local status, err = pcall(v)