From 7783077517499caa5a9e320bec43575b21b359b2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 20 Nov 2005 12:58:59 +0000 Subject: [PATCH] simplified the work() functions splitting more functionality from process_orders into separate functions --- src/common/gamecode/creport.c | 10 +-- src/common/gamecode/economy.c | 6 +- src/common/gamecode/laws.c | 6 +- src/common/gamecode/laws.h | 2 +- src/common/gamecode/report.c | 14 ++-- src/common/kernel/eressea.c | 133 ++++++++++++---------------------- src/common/kernel/eressea.h | 8 +- src/common/kernel/faction.c | 2 +- src/common/kernel/faction.h | 4 +- src/common/kernel/movement.c | 13 ++-- src/common/kernel/region.c | 28 ++++--- src/common/kernel/region.h | 7 +- src/common/kernel/save.c | 10 +-- src/common/modules/score.c | 1 + src/config.h | 2 +- src/eressea/lua/eressea.cpp | 39 ++++++++++ src/eressea/lua/region.cpp | 12 +++ src/eressea/main.c | 2 +- src/eressea/server.cpp | 38 ---------- src/scripts/default.lua | 2 +- src/scripts/eressea.lua | 7 ++ src/scripts/extensions.lua | 4 - src/scripts/wdw-run.lua | 4 +- 23 files changed, 169 insertions(+), 185 deletions(-) diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index 7d222c210..f2dad53fc 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -866,7 +866,7 @@ show_allies(FILE * F, const faction * f, const ally * sf) } } -#ifdef REGIONOWNERS +#ifdef ENEMIES static void show_enemies(FILE * F, const faction_list* flist) { @@ -1137,7 +1137,7 @@ report_computer(const char * filename, report_context * ctx) for (i=0;i!=MAXOPTIONS;++i) { fprintf(F, "%d;%s\n", (f->options&want(i))?1:0, options[i]); } -#ifdef REGIONOWNERS +#ifdef ENEMIES show_enemies(F, f->enemies); #endif show_allies(F, f, f->allies); @@ -1237,9 +1237,9 @@ report_computer(const char * filename, report_context * ctx) if (sd->mode!=see_unit) fprintf(F, "\"%s\";visibility\n", visibility[sd->mode]); { - unit * owner = region_owner(r); + faction * owner = region_owner(r); if (owner) { - fprintf(F, "%d;owner\n", owner->faction->no); + fprintf(F, "%d;owner\n", owner->no); } } if (sd->mode == see_neighbour) { @@ -1285,7 +1285,7 @@ report_computer(const char * filename, report_context * ctx) fprintf(F, "%d;Rekruten\n", rpeasants(r) / RECRUITFRACTION); } if (production(r)) { - fprintf(F, "%d;Lohn\n", fwage(r, f, true)); + fprintf(F, "%d;Lohn\n", wage(r, NULL, NULL)); } while (res) { diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index 6a9c711d5..e04ea6e58 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -2884,7 +2884,7 @@ expandwork(region * r) /* n: verbleibende Einnahmen */ /* m: maximale Arbeiter */ int m = maxworkingpeasants(r); - int p_wage = wage(r,NULL,false); + int p_wage = wage(r, NULL, NULL); int verdienst = 0; request *o; @@ -2902,7 +2902,7 @@ expandwork(region * r) assert(workers>=0); - u->n = workers * wage(u->region, u, false); + u->n = workers * wage(u->region, u->faction, u->race); m -= workers; assert(m>=0); @@ -2954,7 +2954,7 @@ work(unit * u, order * ord) cmistake(u, ord, 69, MSG_INCOME); return; } - w = wage(r,u,false); + w = wage(r, u->faction, u->race); u->wants = u->number * w; o = nextworker++; o->unit = u; diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 03b3b98c6..d11a67169 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -2764,7 +2764,7 @@ instant_orders(void) /* Beachten: einige Monster sollen auch unbewaffent die Region bewachen * können */ void -remove_unequipped_guarded(void) +update_guards(void) { region *r; unit *u; @@ -3038,7 +3038,7 @@ evict(void) } #endif -#ifdef REGIONOWNERS +#ifdef ENEMIES static void declare_war(void) { @@ -4037,7 +4037,7 @@ processorders (void) #ifdef ALLIANCEJOIN alliancejoin(); #endif -#ifdef REGIONOWNERS +#ifdef ENEMIES puts(" - Krieg & Frieden"); declare_war(); #endif diff --git a/src/common/gamecode/laws.h b/src/common/gamecode/laws.h index 3bdc811af..b45c9b3e9 100644 --- a/src/common/gamecode/laws.h +++ b/src/common/gamecode/laws.h @@ -32,7 +32,7 @@ void demographics(void); void last_orders(void); void stripunit(struct unit * u); void find_address(void); -void remove_unequipped_guarded(void); +void update_guards(void); /* eressea-specific. put somewhere else, please. */ #include "resolve.h" diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 63aac69fe..0cf558f79 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -1126,10 +1126,10 @@ describe(FILE * F, const region * r, int partial, faction * f) } { - const unit * u = region_owner(r); - if (u) { + const faction * owner = region_owner(r); + if (owner!=NULL) { bufp += strxcpy(bufp, " Die Region ist im Besitz von "); - bufp += strxcpy(bufp, factionname(u->faction)); + bufp += strxcpy(bufp, factionname(owner)); strcpy(bufp++, "."); } } @@ -1290,7 +1290,7 @@ statistics(FILE * F, const region * r, const faction * f) msg_release(m); } if (production(r) && (!fval(r->terrain, SEA_REGION) || f->race == new_race[RC_AQUARIAN])) { - m = msg_message("nr_stat_salary", "max", fwage(r, f, true)); + m = msg_message("nr_stat_salary", "max", wage(r, f, f->race)); nr_render(m, f->locale, buf, sizeof(buf), f); rps(F, buf); msg_release(m); @@ -1470,7 +1470,7 @@ report_template(const char * filename, report_context * ctx) } rps_nowrap(F, buf); rnl(F); - sprintf(buf,"; ECheck Lohn %d", fwage(r,f,true)); + sprintf(buf,"; ECheck Lohn %d", wage(r, f, f->race)); rps_nowrap(F, buf); rnl(F); rps_nowrap(F, ""); @@ -1655,7 +1655,7 @@ allies(FILE * F, const faction * f) } } -#ifdef REGIONOWNERS +#ifdef ENEMIES static void enemies(FILE * F, const faction * f) { @@ -2150,7 +2150,7 @@ report_plaintext(const char * filename, report_context * ctx) centre(F, LOC(f->locale, "nr_alliances"), false); rnl(F); -#ifdef REGIONOWNERS +#ifdef ENEMIES enemies(F, f); #endif allies(F, f); diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index d9ff91c61..8c3fc6235 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -2784,7 +2784,7 @@ plagues(region * r, boolean ismagic) /* Seuchenwahrscheinlichkeit in % */ prob = pow((double) rpeasants(r) / - (mwp * (((double)wage(r,NULL,false)) / 10.0) * 1.3), 4.0) + (mwp * (((double)wage(r, NULL, NULL)) / 10.0) * 1.3), 4.0) * (double) SEUCHE; if (rand() % 100 >= (int)prob && !ismagic) return; @@ -2823,43 +2823,46 @@ static const int wagetable[7][4] = { {15, 13, 16, 2} /* Zitadelle */ }; +/* Gibt Arbeitslohn für entsprechende Rasse zurück, oder für +* die Bauern wenn f == NULL. */ int -wage(const region *r, const unit *u, boolean img) - /* Gibt Arbeitslohn für entsprechende Rasse zurück, oder für - * die Bauern wenn ra == NORACE. */ +wage(const region *r, const faction * f, const race * rc) { - building *b = largestbuilding(r, img); - int esize = 0; - curse * c; - int wage; - attrib *a; + building *b = largestbuilding(r, false); + int esize = 0; + curse * c; + int wage; + attrib *a; const building_type *artsculpture_type = bt_find("artsculpture"); - static const curse_type * drought_ct, * blessedharvest_ct; - static boolean init; + static const curse_type * drought_ct, * blessedharvest_ct; + static boolean init; - if (!init) { - init = true; - drought_ct = ct_find("drought"); - blessedharvest_ct = ct_find("blessedharvest"); - } + if (!init) { + init = true; + drought_ct = ct_find("drought"); + blessedharvest_ct = ct_find("blessedharvest"); + } - if (b) esize = buildingeffsize(b, img); + if (b!=NULL) { + /* TODO: this reveals imaginary castles */ + esize = buildingeffsize(b, false); + } - if (u) { - wage = wagetable[esize][u->race == new_race[RC_ORC] || u->race == new_race[RC_SNOTLING] || u->race == new_race[RC_URUK]]; - if (fspecial(u->faction, FS_URBAN)) { - wage += wagetable[esize][3]; - } - } else { - if (fval(r->terrain, SEA_REGION)) { - wage = 11; - } else if (fval(r, RF_ORCIFIED)) { - wage = wagetable[esize][1]; - } else { - wage = wagetable[esize][2]; - } - wage += curse_geteffect(get_curse(r->attribs, blessedharvest_ct)); - } + if (f!=NULL) { + wage = wagetable[esize][rc == new_race[RC_ORC]]; + if (fspecial(f, FS_URBAN)) { + wage += wagetable[esize][3]; + } + } else { + if (fval(r->terrain, SEA_REGION)) { + wage = 11; + } else if (fval(r, RF_ORCIFIED)) { + wage = wagetable[esize][1]; + } else { + wage = wagetable[esize][2]; + } + wage += curse_geteffect(get_curse(r->attribs, blessedharvest_ct)); + } /* Artsculpture: Income +5 */ for(b=r->buildings; b; b=b->next) { @@ -2868,63 +2871,21 @@ wage(const region *r, const unit *u, boolean img) } } - /* Godcurse: Income -10 */ - if (curse_active(get_curse(r->attribs, ct_find("godcursezone")))) { - wage = max(0,wage-10); - } + /* Godcurse: Income -10 */ + if (curse_active(get_curse(r->attribs, ct_find("godcursezone")))) { + wage = max(0,wage-10); + } - /* Bei einer Dürre verdient man nur noch ein Viertel */ - if (drought_ct) { - c = get_curse(r->attribs, drought_ct); - if (curse_active(c)) wage /= curse_geteffect(c); - } + /* Bei einer Dürre verdient man nur noch ein Viertel */ + if (drought_ct) { + c = get_curse(r->attribs, drought_ct); + if (curse_active(c)) wage /= curse_geteffect(c); + } - a = a_find(r->attribs, &at_reduceproduction); - if (a) wage = (wage * a->data.sa[0])/100; + a = a_find(r->attribs, &at_reduceproduction); + if (a) wage = (wage * a->data.sa[0])/100; - return wage; -} - -int -fwage(const region *r, const faction *f, boolean img) -{ - building *b = largestbuilding(r, img); - int esize = 0; - int wage; - attrib *a; - curse * c; - - if (b) esize = buildingeffsize(b, img); - - if (f) { - wage = wagetable[esize][f->race == new_race[RC_ORC]]; - if (fspecial(f, FS_URBAN)) { - wage += wagetable[esize][3]; - } - } else { - if (fval(r->terrain, SEA_REGION)) { - wage = 11; - } else if (fval(r, RF_ORCIFIED)) { - wage = wagetable[esize][1]; - } else { - wage = wagetable[esize][2]; - } - wage += curse_geteffect(get_curse(r->attribs, ct_find("blessedharvest"))); - } - - /* Godcurse: Income -10 */ - if (curse_active(get_curse(r->attribs, ct_find("godcursezone")))) { - wage = max(0,wage-10); - } - - /* Bei einer Dürre verdient man nur noch ein Viertel */ - c = get_curse(r->attribs, ct_find("drought")); - if (curse_active(c)) wage /= curse_geteffect(c); - - a = a_find(r->attribs, &at_reduceproduction); - if (a) wage = (wage * a->data.sa[0])/100; - - return wage; + return wage; } static region * diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index 70f434938..d45b3ff70 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -181,8 +181,8 @@ struct building_type; #define REGIONOWNERS_VERSION 400 #define UGROUPS_VERSION 500 /* nicht aktivieren, nicht fertig */ -#ifdef REGIONOWNERS -# define RELEASE_VERSION REGIONOWNERS_VERSION +#ifdef ENEMIES +# define RELEASE_VERSION ENEMIES_VERSION #else # define RELEASE_VERSION TERRAIN_VERSION #endif @@ -1121,8 +1121,7 @@ extern int lifestyle(const struct unit*); extern int besieged(const struct unit * u); extern int maxworkingpeasants(const struct region * r); -extern int wage(const struct region *r, const struct unit *u, boolean img); -extern int fwage(const struct region *r, const struct faction *f, boolean img); +extern int wage(const struct region *r, const struct faction *f, const struct race * rc); extern int movewhere(const struct unit *u, const char * token, struct region * r, struct region** resultp); extern struct message * movement_error(struct unit * u, const char * token, struct order * ord, int error_code); extern boolean move_blocked(const struct unit * u, const struct region *src, const struct region *dest); @@ -1159,6 +1158,7 @@ typedef struct settings { boolean disabled[MAXKEYWORDS]; struct param * parameters; void * vm_state; + } settings; extern settings global; diff --git a/src/common/kernel/faction.c b/src/common/kernel/faction.c index 89183f4c4..ecddd7baf 100644 --- a/src/common/kernel/faction.c +++ b/src/common/kernel/faction.c @@ -314,7 +314,7 @@ update_interval(struct faction * f, struct region * r) } #endif -#ifdef REGIONOWNERS +#ifdef ENEMIES boolean is_enemy(const struct faction * f, const struct faction * enemy) { diff --git a/src/common/kernel/faction.h b/src/common/kernel/faction.h index 7bf256de5..0e286bd31 100644 --- a/src/common/kernel/faction.h +++ b/src/common/kernel/faction.h @@ -95,7 +95,7 @@ typedef struct faction { struct unit * units; struct attrib *attribs; struct message_list * msgs; -#ifdef REGIONOWNERS +#ifdef ENEMIES struct faction_list * enemies; #endif struct bmsg { @@ -124,7 +124,7 @@ extern void destroyfaction(faction * f); extern void set_alliance(struct faction * a, struct faction * b, int status); extern int get_alliance(const struct faction * a, const struct faction * b); -#ifdef REGIONOWNERS +#ifdef ENEMIES extern boolean is_enemy(const struct faction * f, const struct faction * enemy); extern void add_enemy(struct faction * f, struct faction * enemy); extern void remove_enemy(struct faction * f, struct faction * enemy); diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c index 88f41cdd1..4c7b583b3 100644 --- a/src/common/kernel/movement.c +++ b/src/common/kernel/movement.c @@ -191,13 +191,16 @@ static boolean entrance_allowed(const struct unit * u, const struct region * r) { #ifdef REGIONOWNERS - unit * owner = region_owner(r); - if (owner == NULL || u->faction == owner->faction) return true; - if (alliedunit(owner, u->faction, HELP_TRAVEL)) return true; - if (is_enemy(u->faction, owner->faction)) return true; - return false; + faction * owner = region_owner(r); + if (owner == NULL || u->faction == owner) return true; + if (alliedfaction(r->planep, owner, u->faction, HELP_TRAVEL)) return true; +#ifdef ENEMIES + if (is_enemy(u->faction, owner)) return true; #endif + return false; +#else return true; +#endif } int diff --git a/src/common/kernel/region.c b/src/common/kernel/region.c index 716cf786f..5b1e36eb2 100644 --- a/src/common/kernel/region.c +++ b/src/common/kernel/region.c @@ -1002,7 +1002,7 @@ terraform_region(region * r, const terrain_type * terrain) peasants = MAXPEASANTS_PER_AREA * (rand() % (terrain->size / MAXPEASANTS_PER_AREA / 2)); #endif rsetpeasants(r, max(100, peasants)); - rsetmoney(r, rpeasants(r) * ((wage(r, NULL, false)+1) + rand() % 5)); + rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL)+1) + rand() % 5)); } } } @@ -1079,24 +1079,22 @@ r_addmessage(struct region * r, const struct faction * viewer, struct message * return add_message(&imsg->msgs, msg); } -struct unit * +struct faction * region_owner(const struct region * r) { #ifdef REGIONOWNERS - struct unit * owner = NULL; - int maxsize = 0; - building * b = r->buildings; - for (;b!=NULL;b=b->next) { - if (b->size>maxsize) { - struct unit * u = buildingowner(r, b); - if (u) { - owner = u; - maxsize=b->size; - } - } - } - return owner; + return r->owner; #else return NULL; #endif } + +void +region_setowner(struct region * r, struct faction * owner) +{ +#ifdef REGIONOWNERS + r->owner = owner; +#else + unused(r, owner); +#endif +} diff --git a/src/common/kernel/region.h b/src/common/kernel/region.h index b774b7ce1..0a2ce3a52 100644 --- a/src/common/kernel/region.h +++ b/src/common/kernel/region.h @@ -106,6 +106,9 @@ typedef struct region { struct donation * donations; const struct terrain_type * terrain; struct rawmaterial * resources; +#ifdef REGIONOWNERS + struct faction * owner; +#endif #ifdef FAST_CONNECT struct region * connect[MAXDIRECTIONS]; #endif @@ -232,7 +235,9 @@ extern int production(const struct region *r); extern int read_region_reference(struct region ** r, FILE * F); extern void write_region_reference(const struct region * r, FILE * F); -extern struct unit * region_owner(const struct region * r); +void region_setowner(struct region * r, struct faction * owner); +extern struct faction * region_owner(const struct region * r); + extern struct region * r_connect(const struct region *, direction_t dir); #ifdef FAST_CONNECT # define rconnect(r, dir) ((r)->connect[dir]?(r)->connect[dir]:r_connect(r, dir)) diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index 81225381e..c808fd066 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -425,11 +425,11 @@ getbuf(FILE * F) return buf; } -#ifdef REGIONOWNERS +#ifdef ENEMIES static void read_enemies(FILE * F, faction * f) { - if (global.data_versionenemies = NULL; for (;;) { char zText[32]; @@ -448,12 +448,10 @@ read_enemies(FILE * F, faction * f) static void write_enemies(FILE * F, const faction_list * flist) { -#if RELEASE_VERSION>=REGIONOWNERS_VERSION while (flist) { fprintf(F, "%s ", itoa36(flist->data->no)); } fputs("end \n", F); -#endif } #endif @@ -1666,7 +1664,7 @@ readfaction(FILE * F) } } read_groups(F, f); -#ifdef REGIONOWNERS +#ifdef ENEMIES read_enemies(F, f); #endif return f; @@ -1731,7 +1729,7 @@ writefaction(FILE * F, const faction * f) fprintf(F, "end "); wnl(F); write_groups(F, f->groups); -#ifdef REGIONOWNERS +#ifdef ENEMIES write_enemies(F, f->enemies); #endif } diff --git a/src/common/modules/score.c b/src/common/modules/score.c index a8d1ae0aa..cef3509d1 100644 --- a/src/common/modules/score.c +++ b/src/common/modules/score.c @@ -22,6 +22,7 @@ #include #include "eressea.h" #ifdef SCORE_MODULE +#include "score.h" /* kernel includes */ #include diff --git a/src/config.h b/src/config.h index b07b9fd5a..12006b325 100644 --- a/src/config.h +++ b/src/config.h @@ -220,7 +220,7 @@ extern char * strdup(const char *s); #endif #endif -#define unused(var) var = var +#define unused(var) (var) /**** **** diff --git a/src/eressea/lua/eressea.cpp b/src/eressea/lua/eressea.cpp index dafa59757..46a844d64 100644 --- a/src/eressea/lua/eressea.cpp +++ b/src/eressea/lua/eressea.cpp @@ -6,6 +6,7 @@ #include #include +#include // gamecode includes #include @@ -218,6 +219,40 @@ lua_equipunit(unit& u, const char * eqname) equip_unit(&u, get_equipment(eqname)); } +static void +update_subscriptions(void) +{ + FILE * F; + char zText[MAX_PATH]; + faction * f; + strcat(strcpy(zText, basepath()), "/subscriptions"); + F = fopen(zText, "r"); + if (F==NULL) { + log_info((0, "could not open %s.\n", zText)); + return; + } + for (;;) { + char zFaction[5]; + int subscription, fno; + if (fscanf(F, "%d %s", &subscription, zFaction)<=0) break; + fno = atoi36(zFaction); + f = findfaction(fno); + if (f!=NULL) { + f->subscription=subscription; + } + } + fclose(F); + + sprintf(zText, "subscriptions.%u", turn); + F = fopen(zText, "w"); + for (f=factions;f!=NULL;f=f->next) { + fprintf(F, "%s:%u:%s:%s:%s:%u:\n", + itoa36(f->no), f->subscription, f->email, f->override, + dbrace(f->race), f->lastorders); + } + fclose(F); +} + static void lua_learnskill(unit& u, const char * skname, float chances) { @@ -248,6 +283,10 @@ bind_eressea(lua_State * L) def("get_turn", &get_turn), def("remove_empty_units", &remove_empty_units), + def("update_subscriptions", &update_subscriptions), + def("update_guards", &update_guards), + def("update_scores", &score), + def("equip_unit", &lua_equipunit), def("learn_skill", &lua_learnskill), diff --git a/src/eressea/lua/region.cpp b/src/eressea/lua/region.cpp index 8427335f6..fc2c1153e 100644 --- a/src/eressea/lua/region.cpp +++ b/src/eressea/lua/region.cpp @@ -4,6 +4,7 @@ // kernel includes #include +#include #include #include #include @@ -58,6 +59,16 @@ region_getname(const region& r) { return r.terrain->_name; } +static void +lua_region_setowner(region& r, faction * f) { + region_setowner(&r, f); +} + +static faction * +lua_region_getowner(const region& r) { + return region_owner(&r); +} + static void region_setinfo(region& r, const char * info) { set_string(&r.display, info); @@ -244,6 +255,7 @@ bind_region(lua_State * L) .def(self == region()) .property("name", ®ion_getname, ®ion_setname) .property("info", ®ion_getinfo, ®ion_setinfo) + .property("owner", &lua_region_getowner, &lua_region_setowner) .property("terrain", ®ion_getterrain) .def("add_notice", ®ion_addnotice) .def("add_direction", ®ion_adddirection) diff --git a/src/eressea/main.c b/src/eressea/main.c index 546a534b2..b7b45aed5 100644 --- a/src/eressea/main.c +++ b/src/eressea/main.c @@ -268,7 +268,7 @@ processturn(char *filename) autoseed(&players, k, true); } score(); - remove_unequipped_guarded(); + update_guards(); if (!noreports) reports(); free_units(); puts(" - Beseitige leere Parteien"); diff --git a/src/eressea/server.cpp b/src/eressea/server.cpp index 52b59bddb..af5bed104 100644 --- a/src/eressea/server.cpp +++ b/src/eressea/server.cpp @@ -37,7 +37,6 @@ #include /* modules includes */ -#include #include #include #include @@ -324,40 +323,6 @@ lua_done(lua_State * luaState) lua_close(luaState); } -static void -update_subscriptions(void) -{ - FILE * F; - char zText[MAX_PATH]; - faction * f; - strcat(strcpy(zText, basepath()), "/subscriptions"); - F = fopen(zText, "r"); - if (F==NULL) { - log_info((0, "could not open %s.\n", zText)); - return; - } - for (;;) { - char zFaction[5]; - int subscription, fno; - if (fscanf(F, "%d %s", &subscription, zFaction)<=0) break; - fno = atoi36(zFaction); - f = findfaction(fno); - if (f!=NULL) { - f->subscription=subscription; - } - } - fclose(F); - - sprintf(zText, "subscriptions.%u", turn); - F = fopen(zText, "w"); - for (f=factions;f!=NULL;f=f->next) { - fprintf(F, "%s:%u:%s:%s:%s:%u:\n", - itoa36(f->no), f->subscription, f->email, f->override, - dbrace(f->race), f->lastorders); - } - fclose(F); -} - int process_orders() { @@ -369,10 +334,7 @@ process_orders() #endif turn++; processorders(); - score(); - remove_unequipped_guarded(); - update_subscriptions(); return 0; } diff --git a/src/scripts/default.lua b/src/scripts/default.lua index cea755376..6455e02bf 100644 --- a/src/scripts/default.lua +++ b/src/scripts/default.lua @@ -29,7 +29,7 @@ end function process(orders) -- initialize starting equipment for new players equipment_setitem("new_faction", "conquesttoken", "1"); - equipment_setitem("new_faction", "wood", "30"); + equipment_setitem("new_faction", "log", "30"); equipment_setitem("new_faction", "stone", "30"); equipment_setitem("new_faction", "money", "4200"); diff --git a/src/scripts/eressea.lua b/src/scripts/eressea.lua index 70d0526fe..d3ae91222 100644 --- a/src/scripts/eressea.lua +++ b/src/scripts/eressea.lua @@ -81,6 +81,8 @@ function process(orders) spawn_braineaters(0.25) plan_monsters() process_orders() + update_guards() + update_scores() change_locales() @@ -99,6 +101,11 @@ function process(orders) end end +-- demo: how to add a special familiars-constructor +function initfamiliar_lynx(u) + print("a lynx is born ;-)") +end + -- -- main body of script diff --git a/src/scripts/extensions.lua b/src/scripts/extensions.lua index cbb2ebdd7..e9b9d7ded 100644 --- a/src/scripts/extensions.lua +++ b/src/scripts/extensions.lua @@ -1,7 +1,3 @@ -function initfamiliar_lynx(u) - print("a lynx is born :-)") -end - function peasant_getresource(u) return u.region:get_resource("peasant") end diff --git a/src/scripts/wdw-run.lua b/src/scripts/wdw-run.lua index 1bfe095ed..e4d999b6b 100644 --- a/src/scripts/wdw-run.lua +++ b/src/scripts/wdw-run.lua @@ -18,7 +18,8 @@ function process(orders) -- (no more braineaters) spawn_braineaters(0.25) plan_monsters() process_orders() - outfile = "" .. get_turn() + update_guards() + update_scores() -- write out the initial reports (no need to run a turn) write_passwords() @@ -28,6 +29,7 @@ function process(orders) write_standings() -- save the game + outfile = "" .. get_turn() if write_game(outfile)~=0 then print("could not write game") return -1