forked from github/server
Wir machen jetzt wieder eine Kopie alter länglicher Befehle. Vielleciht hilft es.
This commit is contained in:
parent
f8ef91907a
commit
001d9461a1
|
@ -765,6 +765,14 @@ cr_output_unit(FILE * F, const region * r,
|
|||
fwriteorder(F, u->lastorder, f->locale);
|
||||
fputc('\n', F);
|
||||
}
|
||||
#else
|
||||
for (ord = u->old_orders; ord; ord = ord->next) {
|
||||
/* this new order will replace the old defaults */
|
||||
if (is_persistent(ord)) {
|
||||
fwriteorder(F, ord, f->locale);
|
||||
fputc('\n', F);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (ord = u->orders; ord; ord = ord->next) {
|
||||
#ifdef LASTORDER
|
||||
|
|
|
@ -3422,6 +3422,12 @@ setdefaults (void)
|
|||
#endif
|
||||
/* check all orders for a potential new long order this round: */
|
||||
for (ord = u->orders; ord; ord = ord->next) {
|
||||
#ifndef LASTORDER
|
||||
if (u->old_orders && is_repeated(ord)) {
|
||||
/* this new order will replace the old defaults */
|
||||
free_orders(&u->old_orders);
|
||||
}
|
||||
#endif
|
||||
if (is_exclusive(ord)) {
|
||||
/* Über dieser Zeile nur Befehle, die auch eine idle Faction machen darf */
|
||||
if (idle(u->faction)) {
|
||||
|
|
|
@ -1665,6 +1665,15 @@ order_template(FILE * F, faction * f)
|
|||
rps_nowrap(F, buf);
|
||||
rnl(F);
|
||||
|
||||
#ifndef LASTORDER
|
||||
for (ord = u->old_orders; ord; ord = ord->next) {
|
||||
/* this new order will replace the old defaults */
|
||||
strcpy(buf, " ");
|
||||
write_order(ord, u->faction->locale, buf+2, sizeof(buf)-2);
|
||||
rps_nowrap(F, buf);
|
||||
rnl(F);
|
||||
}
|
||||
#endif
|
||||
for (ord = u->orders; ord; ord = ord->next) {
|
||||
if (is_persistent(ord)) {
|
||||
strcpy(buf, " ");
|
||||
|
|
|
@ -166,6 +166,66 @@ parse_order(const char * s, const struct locale * lang)
|
|||
}
|
||||
}
|
||||
|
||||
boolean
|
||||
is_repeated(const order * ord)
|
||||
{
|
||||
const struct locale * lang = locale_array[ord->_lindex];
|
||||
param_t param;
|
||||
|
||||
switch (ord->_keyword) {
|
||||
case K_CAST:
|
||||
case K_BUY:
|
||||
case K_SELL:
|
||||
case K_ROUTE:
|
||||
case K_DRIVE:
|
||||
case K_WORK:
|
||||
case K_BESIEGE:
|
||||
case K_ENTERTAIN:
|
||||
case K_TAX:
|
||||
case K_RESEARCH:
|
||||
case K_SPY:
|
||||
case K_STEAL:
|
||||
case K_SABOTAGE:
|
||||
case K_STUDY:
|
||||
case K_TEACH:
|
||||
case K_ZUECHTE:
|
||||
case K_PIRACY:
|
||||
return true;
|
||||
|
||||
#if GROWING_TREES
|
||||
case K_PFLANZE:
|
||||
return true;
|
||||
#endif
|
||||
|
||||
case K_FOLLOW:
|
||||
/* FOLLOW is only a long order if we are following a ship. */
|
||||
parser_pushstate();
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
param = getparam(lang);
|
||||
parser_popstate();
|
||||
|
||||
if (param == P_SHIP) return true;
|
||||
break;
|
||||
|
||||
case K_MAKE:
|
||||
/* Falls wir MACHE TEMP haben, ignorieren wir es. Alle anderen
|
||||
* Arten von MACHE zaehlen aber als neue defaults und werden
|
||||
* behandelt wie die anderen (deswegen kein break nach case
|
||||
* K_MAKE) - und in thisorder (der aktuelle 30-Tage Befehl)
|
||||
* abgespeichert). */
|
||||
parser_pushstate();
|
||||
init_tokens(ord); /* initialize token-parser */
|
||||
skip_token();
|
||||
param = getparam(lang);
|
||||
parser_popstate();
|
||||
|
||||
if (param != P_TEMP) return true;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean
|
||||
is_exclusive(const order * ord)
|
||||
{
|
||||
|
@ -242,7 +302,7 @@ is_persistent(const order * ord)
|
|||
return true;
|
||||
}
|
||||
|
||||
return persist || is_exclusive(ord);
|
||||
return persist || is_repeated(ord);
|
||||
}
|
||||
|
||||
char *
|
||||
|
|
|
@ -50,6 +50,8 @@ extern void set_order(struct order ** destp, struct order * src);
|
|||
extern char * getcommand(const struct order * ord);
|
||||
extern boolean is_persistent(const struct order *ord);
|
||||
extern boolean is_exclusive(const struct order *ord);
|
||||
extern boolean is_repeated(const order * ord);
|
||||
|
||||
extern char * write_order(const struct order * ord, const struct locale * lang, char * buffer, size_t size);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -179,12 +179,13 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
|||
item * itm;
|
||||
item * show;
|
||||
faction *fv = visible_faction(f, u);
|
||||
char * bufp = buf;
|
||||
|
||||
if (fspecial(u->faction, FS_HIDDEN))
|
||||
a_fshidden = a_find(u->attribs, &at_fshidden);
|
||||
|
||||
strcpy(buf, unitname(u));
|
||||
|
||||
strcpy(bufp, unitname(u));
|
||||
bufp += strlen(bufp);
|
||||
|
||||
if (!isbattle) {
|
||||
attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction);
|
||||
|
@ -192,21 +193,27 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
|||
attrib *a = a_find(u->attribs, &at_group);
|
||||
if (a) {
|
||||
group * g = (group*)a->data.v;
|
||||
scat(", ");
|
||||
scat(groupid(g, f));
|
||||
strcat(bufp, ", ");
|
||||
strcat(bufp + 2, groupid(g, f));
|
||||
bufp += strlen(bufp);
|
||||
}
|
||||
if (getarnt) {
|
||||
scat(", "); scat(LOC(f->locale, "anonymous"));
|
||||
strcat(bufp, ", ");
|
||||
strcat(bufp + 2, LOC(f->locale, "anonymous"));
|
||||
bufp += 2 + strlen(bufp);
|
||||
} else if (a_otherfaction) {
|
||||
faction * otherfaction = get_otherfaction(a_otherfaction);
|
||||
if (otherfaction) {
|
||||
scat(", ");
|
||||
scat(factionname(otherfaction));
|
||||
strcat(bufp, ", ");
|
||||
strcat(bufp + 2, factionname(otherfaction));
|
||||
bufp += 2 + strlen(bufp);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (getarnt) {
|
||||
scat(", "); scat(LOC(f->locale, "anonymous"));
|
||||
strcat(bufp, ", ");
|
||||
strcat(bufp + 2, LOC(f->locale, "anonymous"));
|
||||
bufp += 2 + strlen(bufp);
|
||||
} else {
|
||||
scat(", ");
|
||||
if(a_otherfaction
|
||||
|
|
|
@ -479,7 +479,24 @@ unitorders(FILE * F, struct faction * f)
|
|||
printf(",_%4s_", itoa36(u->no));
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
if (!fval(u, UFL_ORDERS)) {
|
||||
/* alle wiederholbaren, langen befehle werden gesichert: */
|
||||
fset(u, UFL_ORDERS);
|
||||
u->old_orders = u->orders;
|
||||
ordp = &u->old_orders;
|
||||
while (*ordp) {
|
||||
order * ord = *ordp;
|
||||
if (!is_repeated(ord)) {
|
||||
ordp = &ord->next;
|
||||
free_order(ord);
|
||||
} else {
|
||||
ordp = &ord->next;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
free_orders(&u->orders);
|
||||
}
|
||||
u->orders = 0;
|
||||
|
||||
ordp = &u->orders;
|
||||
|
@ -1221,6 +1238,12 @@ writeunit(FILE * F, const unit * u)
|
|||
wi(F, u->status);
|
||||
wi(F, u->flags & UFL_SAVEMASK);
|
||||
wnl(F);
|
||||
#ifndef LASTORDER
|
||||
for (ord = u->old_orders; ord; ord=ord->next) {
|
||||
fwriteorder(F, ord, u->faction->locale);
|
||||
fputc(' ', F);
|
||||
}
|
||||
#endif
|
||||
for (ord = u->orders; ord; ord=ord->next) {
|
||||
if (is_persistent(ord)) {
|
||||
fwriteorder(F, ord, u->faction->locale);
|
||||
|
|
|
@ -50,7 +50,7 @@ struct skill;
|
|||
#define UFL_TRADER (1<<20) /* Händler, pseudolang */
|
||||
|
||||
#define UFL_NOAID (1<<22) /* Einheit hat Noaid-Status */
|
||||
|
||||
#define UFL_ORDERS (1<<24) /* Einheit hat Befehle erhalten */
|
||||
#define UFL_TAKEALL (1<<25) /* Einheit nimmt alle Gegenstände an */
|
||||
|
||||
/* Flags, die gespeichert werden sollen: */
|
||||
|
@ -96,6 +96,8 @@ typedef struct unit {
|
|||
struct order * thisorder;
|
||||
#ifdef LASTORDER
|
||||
struct order * lastorder;
|
||||
#else
|
||||
struct order * old_orders;
|
||||
#endif
|
||||
|
||||
/* race and illusionary race */
|
||||
|
|
|
@ -30,6 +30,7 @@ log_flush(void)
|
|||
void
|
||||
log_puts(const char * str)
|
||||
{
|
||||
fflush(stdout);
|
||||
if (!logfile) logfile = stderr;
|
||||
fputs(str, logfile);
|
||||
}
|
||||
|
@ -78,6 +79,7 @@ void
|
|||
_log_warn(const char * format, ...)
|
||||
{
|
||||
va_list marker;
|
||||
fflush(stdout);
|
||||
if (!logfile) logfile = stderr;
|
||||
fputs("WARNING: ", logfile);
|
||||
va_start(marker, format);
|
||||
|
@ -100,6 +102,7 @@ void
|
|||
_log_error(const char * format, ...)
|
||||
{
|
||||
va_list marker;
|
||||
fflush(stdout);
|
||||
if (!logfile) logfile = stderr;
|
||||
|
||||
fputs("ERROR: ", logfile);
|
||||
|
@ -121,6 +124,7 @@ void
|
|||
_log_info(unsigned int flag, const char * format, ...)
|
||||
{
|
||||
va_list marker;
|
||||
fflush(stdout);
|
||||
if (!logfile) logfile = stderr;
|
||||
|
||||
fprintf(logfile, "INFO[%u]: ", flag);
|
||||
|
|
Loading…
Reference in New Issue