diff --git a/src/build_vs2003.bat b/src/build_vs2003.bat new file mode 100644 index 000000000..31a76ed95 --- /dev/null +++ b/src/build_vs2003.bat @@ -0,0 +1,2 @@ +REM rebuild eressea projects for VC7.1 +premake --file premake.lua --target vs2003 diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index b93429ec3..4b7ea5eac 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -498,6 +498,14 @@ report_crtypes(FILE * F, const struct locale* lang) } } +static unsigned int +messagehash(const struct message * msg) +{ + variant var; + var.v = (void *)msg; + return (unsigned int)var.i; +} + static void render_messages(FILE * F, faction * f, message_list *msgs) { @@ -511,7 +519,7 @@ render_messages(FILE * F, faction * f, message_list *msgs) char nrbuffer[1024*32]; nrbuffer[0] = '\0'; if (nr_render(m->msg, f->locale, nrbuffer, sizeof(nrbuffer), f)>0 && nrbuffer[0]) { - fprintf(F, "MESSAGE %u\n", (unsigned int)m->msg);/*++msgno); */ + fprintf(F, "MESSAGE %u\n", messagehash(m->msg)); fprintf(F, "%d;type\n", hash); fwritestr(F, nrbuffer); fputs(";rendered\n", F); @@ -520,7 +528,7 @@ render_messages(FILE * F, faction * f, message_list *msgs) #endif crbuffer[0] = '\0'; if (cr_render(m->msg, crbuffer, (const void*)f)==0) { - if (!printed) fprintf(F, "MESSAGE %u\n", (unsigned int)m->msg);/*++msgno); */ + if (!printed) fprintf(F, "MESSAGE %u\n", messagehash(m->msg)); if (crbuffer[0]) fputs(crbuffer, F); } else { log_error(("could not render cr-message %p: %s\n", m->msg, m->msg->type->name)); diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 78b153c45..1caa549b6 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -741,7 +741,7 @@ see_border(const border * b, const faction * f, const region * r) return cs; } -const char * +const xmlChar * trailinto(const region * r, const struct locale * lang) { char ref[32]; @@ -2525,81 +2525,6 @@ writemonument(void) } -static void -writeadresses(void) -{ - faction *f; - FILE *F; - char zText[MAX_PATH]; - sprintf(zText, "%s/adressen", basepath()); - F = cfopen(zText, "w"); - if (!F) return; - - for (f = factions; f; f = f->next) { - if (f->no != MONSTER_FACTION && playerrace(f->race)) { - fprintf(F, "%s:%s:%s\n", factionname(f), f->email, f->banner); - } - } - fclose(F); -} - -static void -writenewssubscriptions(void) -{ - char zText[MAX_PATH]; - FILE *F; - - sprintf(zText, "%s/news-subscriptions", basepath()); - F = cfopen(zText, "w"); - if (!F) return; -#ifdef AT_OPTION - { - faction *f; - for(f=factions; f; f=f->next) { - attrib *a = a_find(f->attribs, &at_option_news); - if(!a) { - fprintf(F, "%s:0\n", f->email); - } else { - fprintf(F, "%s:%d\n", f->email, a->data.i); - } - } - } -#endif - fclose(F); -} - -static void -writeforward(void) -{ - FILE *forwardFile; - region *r; - faction *f; - unit *u; - - { - char zText[MAX_PATH]; - sprintf(zText, "%s/aliases", basepath()); - forwardFile = cfopen(zText, "w"); - if (!forwardFile) return; - } - - for (f = factions; f; f = f->next) { - if (f->no != MONSTER_FACTION) { - fprintf(forwardFile,"partei-%s: %s\n", factionid(f), f->email); - } - } - - for (r = regions; r; r = r->next) { - for (u = r->units; u; u = u->next) { - if (u->faction->no != MONSTER_FACTION) { - fprintf(forwardFile,"einheit-%s: %s\n", unitid(u), u->faction->email); - } - } - } - - fclose(forwardFile); -} - static void writeturn(void) { @@ -2790,11 +2715,6 @@ report_summary(summary * s, summary * o, boolean full) fclose(F); if (full) { - printf("Schreibe Liste der Adressen (adressen)...\n"); - writeadresses(); - writenewssubscriptions(); - writeforward(); - printf("writing date & turn\n"); writeturn(); diff --git a/src/common/gamecode/report.h b/src/common/gamecode/report.h index 79c1c39da..6c18c01f6 100644 --- a/src/common/gamecode/report.h +++ b/src/common/gamecode/report.h @@ -18,6 +18,10 @@ extern "C" { extern void report_init(void); extern void report_cleanup(void); + struct summary; + extern void report_summary(struct summary * n, struct summary * o, boolean full); + extern struct summary * make_summary(void); + #ifdef __cplusplus } #endif diff --git a/src/common/gamecode/spy.c b/src/common/gamecode/spy.c index f304c824a..6c8680160 100644 --- a/src/common/gamecode/spy.c +++ b/src/common/gamecode/spy.c @@ -44,6 +44,7 @@ /* util includes */ #include +#include #include #include #include @@ -63,138 +64,51 @@ void spy_message(int spy, const unit *u, const unit *target) { - char buf[4096]; - const char *c; + const xmlChar * str = report_kampfstatus(target, u->faction->locale); - /* Infos: - * - Kampfstatus - * - verborgene Gegenstände: Amulette, Ringe, Phiolen, Geld - * - Partei - * - Talentinfo - * - Zaubersprüche - * - Zauberwirkungen - */ - /* mit spy=100 (magische Spionage) soll alles herausgefunden werden */ - - buf[0]='\0'; - if (spy > 99){ - /* magische Spionage */ - /* Zauberwirkungen */ - } - if (spy > 20){ + ADDMSG(&u->faction->msgs, msg_message("spyreport", "spy target status", u, target, str)); + if (spy > 20) { sc_mage * m = get_mage(target); /* bei Magiern Zaubersprüche und Magiegebiet */ if (m) { - spell_list *slist = m->spells; - boolean first = true; - - scat("Magiegebiet: "); - scat(LOC(u->faction->locale, magietypen[find_magetype(target)])); - scat(", Sprüche: "); - - for (;slist; slist=slist->next) { - spell * sp = slist->data; - if (first) { - first = false; - } else { - scat(", "); - } - scat(spell_name(sp, u->faction->locale)); - } - if (first) scat("Keine"); - scat(". "); + ADDMSG(&u->faction->msgs, msg_message("spyreport_mage", "target type", target, magietypen[find_magetype(target)])); } } - if (spy > 6){ - /* wahre Partei */ - scat("Partei '"); - scat(factionname(target->faction)); - scat("'. "); - } else { - /* ist die Einheit in Spionage nicht gut genug, glaubt sie die - * Parteitarnung */ - faction *fv = visible_faction(u->faction,target); - - if (fv != target->faction){ - scat("Partei '"); - scat(factionname(fv)); - scat("'. "); - } else if (!fval(target, UFL_PARTEITARNUNG)){ - scat("Partei '"); - scat(factionname(target->faction)); - scat("'. "); + if (spy > 6) { + faction * fv = visible_faction(u->faction,target); + if (fv && fv!=target->faction) { + /* wahre Partei */ + ADDMSG(&u->faction->msgs, msg_message("spyreport_faction", "target faction", target, target->faction)); } } - if (spy > 0){ + if (spy > 0) { int first = 1; int found = 0; skill * sv; + char buf[4096]; - scat("Talente: "); + buf[0] = 0; for (sv = target->skills;sv!=target->skills+target->skill_size;++sv) { if (sv->level>0) { found++; if (first == 1) { first = 0; } else { - scat(", "); + strncat(buf, ", ", sizeof(buf)); } - scat(skillname(sv->id, u->faction->locale)); - scat(" "); - icat(eff_skill(target, sv->id, target->region)); + strncat(buf, (const char *)skillname(sv->id, u->faction->locale), sizeof(buf)); + strncat(buf, " ", sizeof(buf)); + strncat(buf, itoa10(eff_skill(target, sv->id, target->region)), sizeof(buf)); } } - if (found == 0) { - scat("Keine"); + if (found) { + ADDMSG(&u->faction->msgs, msg_message("spyreport_skills", "target skills", target, buf)); } - scat(". "); - scat("Im Gepäck sind"); - { - boolean first = true; - int found = 0; - item * itm; - for (itm=target->items;itm;itm=itm->next) { - if (itm->number>0) { - resource_type * rtype = itm->type->rtype; - ++found; - if (first) { - first = false; - scat(": "); - } else { - scat(", "); - } - - if (itm->number == 1) { - scat("1 "); - scat(locale_string(u->faction->locale, resourcename(rtype, 0))); - } else { - icat(itm->number); - scat(" "); - scat(locale_string(u->faction->locale, resourcename(rtype, NMF_PLURAL))); - } - } - } - if (found == 0) { - scat(" keine verborgenen Gegenstände"); - } - scat(". "); + if (target->items) { + ADDMSG(&u->faction->msgs, msg_message("spyreport_items", "target items", target, target->items)); } } - /* spion ist gleich gut wie Wahrnehmung Opfer */ - /* spion ist schlechter als Wahrnehmung Opfer */ - { /* immer */ - const xmlChar * str; - scat("Kampfstatus: "); - scat(report_kampfstatus(target, u->faction->locale)); - str = locale_string(u->faction->locale, hp_status(target)); - if (str && str[0]) - sprintf(buf, "%s (%s)", buf, str); - scat("."); - } - - ADDMSG(&u->faction->msgs, msg_message("spyreport", - "spy target report", u, target, strdup(buf))); } @@ -299,7 +213,7 @@ int setstealth_cmd(unit * u, struct order * ord) { const xmlChar *s; - char level; + int level; const race * trace; init_tokens(ord); @@ -360,7 +274,7 @@ setstealth_cmd(unit * u, struct order * ord) } else if (findparam(s, u->faction->locale) == P_NOT) { freset(u, UFL_PARTEITARNUNG); } else if (findkeyword(s, u->faction->locale) == K_NUMBER) { - const xmlChar *s2 = getstrtoken(); + const char *s2 = (const char *)getstrtoken(); int nr = -1; if (s2) nr = atoi36(s2); @@ -449,7 +363,7 @@ setstealth_cmd(unit * u, struct order * ord) default: if (isdigit(s[0])) { /* Tarnungslevel setzen */ - level = (char) atoip(s); + level = atoi((const char *)s); if (level > effskill(u, SK_STEALTH)) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_lowstealth", "")); return 0; diff --git a/src/common/kernel/reports.c b/src/common/kernel/reports.c index d433a1f53..b8e09ee6b 100644 --- a/src/common/kernel/reports.c +++ b/src/common/kernel/reports.c @@ -103,7 +103,7 @@ groupid(const struct group * g, const struct faction * f) return buf; } -const char * +const xmlChar * report_kampfstatus(const unit * u, const struct locale * lang) { static char fsbuf[64]; @@ -112,13 +112,13 @@ report_kampfstatus(const unit * u, const struct locale * lang) "status_rear", "status_defensive", "status_avoid", "status_flee" }; - strcpy(fsbuf, LOC(lang, azstatus[u->status])); + xstrlcpy(fsbuf, LOC(lang, azstatus[u->status]), sizeof(fsbuf)); if (fval(u, UFL_NOAID)) { strcat(fsbuf, ", "); - strcat(fsbuf, LOC(lang, "status_noaid")); + xstrcat(fsbuf, LOC(lang, "status_noaid")); } - return fsbuf; + return (xmlChar *)fsbuf; } const char * @@ -1443,6 +1443,24 @@ global_report(const char * filename) } #endif +void +writeaddresses(void) +{ + faction *f; + FILE *F; + char zText[MAX_PATH]; + sprintf(zText, "%s/addresses", basepath()); + F = cfopen(zText, "w"); + if (!F) return; + + for (f = factions; f; f = f->next) { + if (f->no != MONSTER_FACTION && playerrace(f->race)) { + fprintf(F, "%s:%s:%s\n", factionname(f), f->email, f->banner); + } + } + fclose(F); +} + int reports(void) { diff --git a/src/common/kernel/reports.h b/src/common/kernel/reports.h index 5182397e4..031ada85c 100644 --- a/src/common/kernel/reports.h +++ b/src/common/kernel/reports.h @@ -50,10 +50,6 @@ extern int init_reports(void); extern const struct unit *ucansee(const struct faction *f, const struct unit *u, const struct unit *x); -struct summary; -extern void report_summary(struct summary * n, struct summary * o, boolean full); -extern struct summary * make_summary(void); - int hat_in_region(item_t itm, struct region * r, struct faction * f); /* für fast_region und neuen CR: */ @@ -102,8 +98,9 @@ extern void report_building(FILE *F, const struct region * r, const struct build extern int bufunit(const struct faction * f, const struct unit * u, int indent, int mode, char * buf, size_t size); extern const char * reportpath(void); -extern const char * trailinto(const struct region * r, const struct locale * lang); -extern const char * report_kampfstatus(const struct unit * u, const struct locale * lang); +extern const xmlChar * trailinto(const struct region * r, const struct locale * lang); +extern const xmlChar * report_kampfstatus(const struct unit * u, const struct locale * lang); + extern void writeaddresses(void); extern void reports_init(void); diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index d35221653..eaee6b6de 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -78,7 +78,6 @@ #include #define xisdigit(c) (((c) >= '0' && (c) <= '9') || (c) == '-') -#define COMMENT_CHAR ';' #define ESCAPE_FIX #define MAXORDERS 256 diff --git a/src/common/kernel/unit.c b/src/common/kernel/unit.c index 30e7e2f6b..0c6b6e03b 100644 --- a/src/common/kernel/unit.c +++ b/src/common/kernel/unit.c @@ -29,7 +29,7 @@ #include "karma.h" #include "border.h" #include "item.h" -#include "movement.h" +#include "move.h" #include "order.h" #include "plane.h" #include "race.h" diff --git a/src/common/util/filereader.c b/src/common/util/filereader.c index 54a41ebdf..b89a4e4ad 100644 --- a/src/common/util/filereader.c +++ b/src/common/util/filereader.c @@ -1,3 +1,163 @@ #include #include "filereader.h" +#include +#include + +#define COMMENT_CHAR ';' +#define CONTINUE_CHAR '\\' +#define MAXLINE 4096*16 +static char lbuf[MAXLINE]; +static char fbuf[MAXLINE]; + +static void +unicode_warning(const char * bp) +{ + log_warning(("invalid sequence in UTF-8 string: %s\n", bp)); +} + +INLINE_FUNCTION int +eatwhite(const char * ptr, size_t * total_size) +{ + int ret = 0; + + *total_size = 0; +#ifdef USE_UNICODE + + while (*ptr) { + wint_t ucs; + size_t size = 0; + ret = unicode_utf8_to_ucs4(&ucs, (const xmlChar*)ptr, &size); + if (ret!=0) break; + if (!iswspace(ucs)) break; + *total_size += size; + ptr += size; + } +#else + *total_size = 0; + while (ptr[*total_size] && isspace(*(unsigned char*)ptr[*total_size])) ++*total_size; +#endif + return ret; +} + +const xmlChar * +getbuf(FILE * F, int encoding) +{ + boolean cont = false; + char quote = 0; + boolean comment = false; + char * cp = fbuf; + char * tail = lbuf+MAXLINE-2; + + tail[1] = '@'; /* if this gets overwritten by fgets then the line was very long. */ + do { + const char * bp = fgets(lbuf, MAXLINE, F); + size_t white; + if (bp==NULL) return NULL; + + eatwhite(bp, &white); /* decoding errors will get caught later on, don't have to check */ + bp += white; + + comment = (boolean)(comment && cont); + + if (tail[1]==0) { + /* we read he maximum number of bytes! */ + if (tail[0]!='\n') { + /* it wasn't enough space to finish the line, eat the rest */ + for (;;) { + tail[1] = '@'; + bp = fgets(lbuf, MAXLINE, F); + if (bp==NULL) return NULL; + if (tail[1]) { + /* read enough this time to end the line */ + break; + } + } + comment = false; + bp = NULL; + } else { + tail[1] = '@'; + } + } + cont = false; + while (*bp && cp - +#define USE_UNICODE extern int unicode_utf8_to_ucs4(wint_t *ucs4_character, const xmlChar *utf8_string, size_t *length); #ifdef __cplusplus diff --git a/src/eressea/lua/gamecode.cpp b/src/eressea/lua/gamecode.cpp index 16e84901b..452673ca6 100644 --- a/src/eressea/lua/gamecode.cpp +++ b/src/eressea/lua/gamecode.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -217,6 +218,7 @@ write_summary() summary * sum_end = make_summary(); report_summary(sum_end, sum_begin, false); report_summary(sum_end, sum_begin, true); + writeaddresses(); return 0; } return -1; diff --git a/src/eressea/server.cpp b/src/eressea/server.cpp index 815bdfb4f..4e6148798 100644 --- a/src/eressea/server.cpp +++ b/src/eressea/server.cpp @@ -61,7 +61,9 @@ #include #include #include +#ifdef REPORT_FORMAT_NR #include +#endif #include /* kernel includes */ @@ -162,7 +164,7 @@ static int nowrite = 0; static boolean g_writemap = false; static boolean g_ignore_errors = false; static boolean opt_reportonly = false; -static const char * luafile = "default.lua"; +static const char * luafile = NULL; static const char * script_path = "scripts"; struct settings global = { @@ -213,7 +215,9 @@ game_init(void) init_xmas(); reports_init(); +#ifdef REPORT_FORMAT_NR report_init(); +#endif creport_init(); xmlreport_init(); @@ -378,7 +382,9 @@ game_done(void) } creport_cleanup(); +#ifdef REPORT_FORMAT_NR report_cleanup(); +#endif calendar_cleanup(); } #endif @@ -419,7 +425,7 @@ usage(const char * prog, const char * arg) "-o reportdir : gibt das reportverzeichnis an\n" "-l path : specify the base script directory\n" "-C : run in interactive mode\n" - "-e script : main lua script (default: default.lua)\n" + "-e script : main lua script\n" "-R : erstellt nur die Reports neu\n" "--lomem : keine Messages (RAM sparen)\n" "--nobattle : keine Kämpfe\n" diff --git a/src/res/messages.xml b/src/res/messages.xml index 5621c7777..73a9d8590 100644 --- a/src/res/messages.xml +++ b/src/res/messages.xml @@ -3459,11 +3459,42 @@ - + - "$unit($spy) gelang es, Informationen über $unit($target) herauszubekommen: '$report'." - "$unit($spy) managed to gather information about $unit($target): '$report'." - "$unit($spy) managed to gather information about $unit($target): '$report'." + "$unit($spy) gelang es, Informationen über $unit($target) ($status) herauszubekommen." + "$unit($spy) managed to gather information about $unit($target)." + + + + + + + "$unit($target) ist ein $type-Magier." + "$unit($target) is a $type-magician" + + + + + + + "$unit($target) beherrscht $skills." + "$unit($target) has the skills $skills" + + + + + + + "In Gepäck von $unit($target) sind $resources($items)." + "$unit($target) carries $resources($items)" + + + + + + + "$unit($target) gehört der Partei $faction($faction) an." + "$unit($target) belongs to $faction($faction)." diff --git a/src/scripts/default.lua b/src/scripts/default.lua index a99492127..3bc259d71 100644 --- a/src/scripts/default.lua +++ b/src/scripts/default.lua @@ -1,13 +1,4 @@ -function loadscript(name) - local script = scriptpath .. "/" .. name - print("- loading " .. script) - if pcall(dofile, script)==0 then - print("Could not load " .. script) - end -end - -function write_emails() - local locales = { "de", "en" } +function write_emails(locales) local files = {} local key local locale @@ -27,62 +18,29 @@ function write_emails() end end -function process(orders) - -- initialize starting equipment for new players - equipment_setitem("new_faction", "conquesttoken", "1"); - equipment_setitem("new_faction", "log", "30"); - equipment_setitem("new_faction", "stone", "30"); - equipment_setitem("new_faction", "money", "4200"); +function write_aliases() + local file + local key + local locale - file = "" .. get_turn() - if read_game(file)~=0 then - print("could not read game") - return -1 + file = io.open(basepath .. "/aliases." .. locale, "w") + + local faction + for faction in factions() do + local unit + file:write("partei-" .. itoa36(faction.id) .. ": " .. faction.email .. "\n") + for unit in f.units do + file:write("einheit-" .. itoa36(unit.id) .. ": " .. faction.email .. "\n") + end end - init_summary() - - -- run the turn: - read_orders(orders) - - -- create new monsters: - spawn_dragons() - spawn_undead() - spawn_braineaters(0.25) - - plan_monsters() - process_orders() - - -- post-turn updates: - update_guards() - update_scores() - - - -- use newfactions file to place out new players - autoseed(basepath .. "/newfactions", true) + + file:close() +end +function write_files(locales) write_passwords() write_reports() - write_emails() + write_emails(locales) + write_aliases() write_summary() - - file = "" .. get_turn() - if write_game(file)~=0 then - print("could not write game") - return -1 - end end - - --- --- main body of script --- - --- orderfile: contains the name of the orders. -if orderfile==nil then - print "you must specify an orderfile" -else - loadscript("spells.lua") - loadscript("extensions.lua") - process(orderfile) -end - diff --git a/src/scripts/eressea.lua b/src/scripts/eressea.lua index 8b6706cd1..cda9d6cb6 100644 --- a/src/scripts/eressea.lua +++ b/src/scripts/eressea.lua @@ -1,3 +1,6 @@ +-- the locales that this gameworld supports. +local locales = { "de", "en" } + function loadscript(name) local script = scriptpath .. "/" .. name print("- loading " .. script) @@ -26,7 +29,7 @@ function run_scripts() "spells.lua", "extensions.lua", "familiars.lua", - "write_emails.lua", + "default.lua", "eressea/eternath.lua", "eressea/wedding-jadee.lua", "eressea/ponnuki.lua", @@ -96,10 +99,7 @@ function process(orders) -- use newfactions file to place out new players autoseed(basepath .. "/newfactions", false) - write_passwords() - write_reports() - write_emails() - write_summary() + write_files(locales) file = "" .. get_turn() if write_game(file)~=0 then diff --git a/src/scripts/hse3-run.lua b/src/scripts/hse3-run.lua index 9b59f4baa..82226779f 100644 --- a/src/scripts/hse3-run.lua +++ b/src/scripts/hse3-run.lua @@ -1,5 +1,8 @@ +local locales = { "de", "en" } + function run_scripts() scripts = { + "default.lua", "spells.lua", "extensions.lua", "familiars.lua", @@ -15,26 +18,6 @@ function run_scripts() end end -function write_emails() - local locales = { "de", "en" } - local files = {} - local key - for key in locales do - local locale = locales[key] - files[locale] = io.open(basepath .. "/emails." .. locale, "w") - end - - local faction - for faction in factions() do - -- print(faction.id .. " - " .. faction.locale) - files[faction.locale]:write(faction.email .. "\n") - end - - for key in files do - files[key]:close() - end -end - function refresh_pool() for f in factions do f:add_item("money", 50) @@ -56,10 +39,7 @@ function process(orders) plan_monsters() process_orders() - write_passwords() - write_reports() - - write_emails() + write_files(locales) file = "" .. get_turn() if write_game(file)~=0 then diff --git a/src/scripts/hse4-run.lua b/src/scripts/hse4-run.lua index 1cf154ba6..bc18868d7 100644 --- a/src/scripts/hse4-run.lua +++ b/src/scripts/hse4-run.lua @@ -1,5 +1,8 @@ +local locales = { "de", "en" } + function run_scripts() scripts = { + "default.lua", "spells.lua", "extensions.lua", "familiars.lua", @@ -15,26 +18,6 @@ function run_scripts() end end -function write_emails() - local locales = { "de", "en" } - local files = {} - local key - for key in locales do - local locale = locales[key] - files[locale] = io.open(basepath .. "/emails." .. locale, "w") - end - - local faction - for faction in factions() do - -- print(faction.id .. " - " .. faction.locale) - files[faction.locale]:write(faction.email .. "\n") - end - - for key in files do - files[key]:close() - end -end - function refresh_pool() for f in factions() do f:add_item("money", 50) @@ -58,10 +41,7 @@ function process(orders) refresh_pool() - write_passwords() - write_reports() - - write_emails() + write_files(locales) file = "" .. get_turn() if write_game(file)~=0 then diff --git a/src/scripts/kingdoms-run.lua b/src/scripts/kingdoms-run.lua index 5ec5981a6..a35c85f48 100644 --- a/src/scripts/kingdoms-run.lua +++ b/src/scripts/kingdoms-run.lua @@ -1,3 +1,6 @@ +-- the locales that this gameworld supports. +local locales = { "de", "en" } + function loadscript(name) local script = scriptpath .. "/" .. name print("- loading " .. script) @@ -6,26 +9,6 @@ function loadscript(name) end end -function write_emails() - local locales = { "de", "en" } - local files = {} - local key - for key in locales do - local locale = locales[key] - files[locale] = io.open(basepath .. "/emails." .. locale, "w") - end - - local faction - for faction in factions() do - -- print(faction.id .. " - " .. faction.locale) - files[faction.locale]:write(faction.email .. "\n") - end - - for key in files do - files[key]:close() - end -end - function update_resources() -- remaining contents of region pool rots -- wood falls from trees @@ -83,10 +66,7 @@ function process(orders) -- use newfactions file to place out new players autoseed(basepath .. "/newfactions", true) - write_passwords() - write_reports() - write_emails() - write_summary() + write_files(locales) file = "" .. get_turn() if write_game(file)~=0 then @@ -104,7 +84,7 @@ end if orderfile==nil then print "you must specify an orderfile" else - -- loadscript("spells.lua") + loadscript("default.lua") loadscript("extensions.lua") loadscript("kingdoms/extensions.lua") process(orderfile) diff --git a/src/scripts/rts-run.lua b/src/scripts/rts-run.lua index 59c4733f8..cac74f250 100644 --- a/src/scripts/rts-run.lua +++ b/src/scripts/rts-run.lua @@ -8,10 +8,10 @@ end function run_scripts() scripts = { + "default.lua", "spells.lua", "extensions.lua", - "familiars.lua", - "write_emails.lua" + "familiars.lua" } for index, name in pairs(scripts) do loadscript(name) @@ -58,10 +58,7 @@ function process(orders) -- use newfactions file to place out new players autoseed(basepath .. "/newfactions", false) - write_passwords() - write_reports() - write_emails() - write_summary() + write_files(locales) file = "" .. get_turn() if write_game(file)~=0 then diff --git a/src/scripts/wdw-run.lua b/src/scripts/wdw-run.lua index db90ff93d..3fc6a1f05 100644 --- a/src/scripts/wdw-run.lua +++ b/src/scripts/wdw-run.lua @@ -1,3 +1,6 @@ +-- the locales that this gameworld supports. +local locales = { "de", "en" } + function process(orders) -- read game and orders local turnfile = "" .. get_turn() @@ -30,11 +33,7 @@ function process(orders) update_guards() update_scores() - -- write out the initial reports (no need to run a turn) - write_passwords() - write_reports() - write_emails() - write_summary() + write_files(locales) -- siegbedingungen ausgeben write_standings() @@ -54,10 +53,10 @@ end print("- Running wdw-run.lua") scripts = { + "default.lua", "spells.lua", "extensions.lua", "familiars.lua", - "write_emails.lua", "wdw/sphinx.lua", "wdw/phoenix.lua", "wdw/standings.lua" diff --git a/src/scripts/write_emails.lua b/src/scripts/write_emails.lua deleted file mode 100644 index b7b3b4f2b..000000000 --- a/src/scripts/write_emails.lua +++ /dev/null @@ -1,20 +0,0 @@ - -function write_emails() - local locales = { "de", "en" } - local files = {} - local key - for key, locale in pairs(locales) do - files[locale] = io.open(basepath .. "/emails." .. locale, "w") - end - - local faction - for faction in factions() do - -- print(faction.id .. " - " .. faction.locale) - files[faction.locale]:write(faction.email .. "\n") - end - - for key, file in pairs(files) do - file:close() - end -end -