diff --git a/process/run-turn b/process/run-turn index 9fa6a325c..bb12976c1 100755 --- a/process/run-turn +++ b/process/run-turn @@ -11,7 +11,7 @@ fi cd "$ERESSEA/game-$GAME" || exit echo "running turn $TURN, game $GAME" -"$ERESSEA/server/bin/eressea" -v3 -t "$TURN" run-turn.lua +"$ERESSEA/server/bin/eressea" -t "$TURN" run-turn.lua mkdir -p log ln -f eressea.log "log/eressea.log.$TURN" diff --git a/src/creport.c b/src/creport.c index 3d2c46e7d..89cf4c9ce 100644 --- a/src/creport.c +++ b/src/creport.c @@ -723,18 +723,6 @@ static void cr_output_ship_compat(FILE *F, const ship *sh, const unit *u, cr_output_ship(&strm, sh, u, fcaptain, f, r); } -static int stream_order(stream *out, const struct order *ord, const struct locale *lang) { - const char *str; - char ebuf[1025]; - char obuf[1024]; - write_order(ord, lang, obuf, sizeof(obuf)); - str = escape_string(obuf, ebuf, sizeof(ebuf)); - if (str == ebuf) { - ebuf[1024] = 0; - } - return stream_printf(out, "\"%s\"\n", str); -} - static void cr_output_spells(stream *out, const unit * u, int maxlevel) { spellbook * book = unit_get_spellbook(u); @@ -925,7 +913,9 @@ void cr_output_unit(stream *out, const region * r, const faction * f, for (ord = u->old_orders; ord; ord = ord->next) { /* this new order will replace the old defaults */ if (is_persistent(ord)) { - stream_order(out, ord, lang); + swrite("\"", 1, 1, out); + stream_order(out, ord, lang, true); + swrite("\"\n", 1, 2, out); } } for (ord = u->orders; ord; ord = ord->next) { @@ -933,7 +923,9 @@ void cr_output_unit(stream *out, const region * r, const faction * f, if (u->old_orders && is_repeated(kwd)) continue; /* unit has defaults */ if (is_persistent(ord)) { - stream_order(out, ord, lang); + swrite("\"", 1, 1, out); + stream_order(out, ord, lang, true); + swrite("\"\n", 1, 2, out); } } diff --git a/src/kernel/order.c b/src/kernel/order.c index 7d218d3ff..baf26f615 100644 --- a/src/kernel/order.c +++ b/src/kernel/order.c @@ -23,6 +23,9 @@ #include #include #include +#include + +#include /* libc includes */ #include @@ -135,6 +138,49 @@ char* get_command(const order *ord, const struct locale *lang, char *sbuffer, si return sbuffer; } +int stream_order(struct stream *out, const struct order *ord, const struct locale *lang, bool escape) +{ + const char *str, *text; + order_data *od = NULL; + keyword_t kwd = ORD_KEYWORD(ord); + + if (ord->command & CMD_QUIET) { + swrite("!", 1, 1, out); + } + if (ord->command & CMD_PERSIST) { + swrite("@", 1, 1, out); + } + + if (ord->id < 0) { + skill_t sk = (skill_t)(100 + ord->id); + assert(kwd == K_STUDY && sk != SK_MAGIC && sk < MAXSKILLS); + text = skillname(sk, lang); + } + else { + od = odata_load(ord->id); + text = OD_STRING(od); + } + if (kwd != NOKEYWORD) { + str = (const char *)LOC(lang, keyword(kwd)); + assert(str); + swrite(str, 1, strlen(str), out); + } + + if (text) { + char obuf[1024]; + swrite(" ", 1, 1, out); + if (escape) { + text = escape_string(text, obuf, sizeof(obuf)); + } + swrite(text, 1, strlen(text), out); + } + if (od) { + odata_release(od); + } + + return 0; +} + void free_order(order * ord) { if (ord != NULL) { diff --git a/src/kernel/order.h b/src/kernel/order.h index 0cbe4989c..02e03ff56 100644 --- a/src/kernel/order.h +++ b/src/kernel/order.h @@ -22,6 +22,7 @@ extern "C" { #endif struct locale; + struct stream; /* Encapsulation of an order * @@ -69,6 +70,7 @@ extern "C" { char *write_order(const order * ord, const struct locale *lang, char *buffer, size_t size); + int stream_order(struct stream *out, const struct order *ord, const struct locale *lang, bool escape); keyword_t init_order_depr(const struct order *ord); keyword_t init_order(const struct order *ord, const struct locale *lang);