forked from github/server
splitting quit in two parts so that the analysis can be done in instant_orders, and dying does not interfere with quitting.
This commit is contained in:
parent
af59e2f09c
commit
8ca86912cf
5 changed files with 75 additions and 55 deletions
|
@ -71,6 +71,7 @@
|
||||||
#include <attributes/racename.h>
|
#include <attributes/racename.h>
|
||||||
#include <attributes/raceprefix.h>
|
#include <attributes/raceprefix.h>
|
||||||
#include <attributes/synonym.h>
|
#include <attributes/synonym.h>
|
||||||
|
#include <attributes/variable.h>
|
||||||
|
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <util/base36.h>
|
#include <util/base36.h>
|
||||||
|
@ -1021,49 +1022,69 @@ EnhancedQuit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
quit(unit * u, struct order * ord)
|
quit_cmd(unit * u, struct order * ord)
|
||||||
{
|
{
|
||||||
|
faction * f = u->faction;
|
||||||
const char * passwd;
|
const char * passwd;
|
||||||
|
|
||||||
init_tokens(ord);
|
init_tokens(ord);
|
||||||
skip_token(); /* skip keyword */
|
skip_token(); /* skip keyword */
|
||||||
|
|
||||||
passwd = getstrtoken();
|
passwd = getstrtoken();
|
||||||
if (checkpasswd(u->faction, passwd, false)) {
|
if (checkpasswd(f, passwd, false)) {
|
||||||
if (EnhancedQuit()) {
|
if (EnhancedQuit()) {
|
||||||
int f2_id = getid();
|
const char * token = getstrtoken();
|
||||||
|
int f2_id = atoi36(token);
|
||||||
if (f2_id > 0) {
|
if (f2_id>0) {
|
||||||
faction *f2 = findfaction(f2_id);
|
faction *f2 = findfaction(f2_id);
|
||||||
faction * f = u->faction;
|
|
||||||
|
|
||||||
if(f2 == NULL) {
|
if(f2 == NULL) {
|
||||||
cmistake(u, ord, 66, MSG_EVENT);
|
cmistake(u, ord, 66, MSG_EVENT);
|
||||||
} else if(f == f2) {
|
return 0;
|
||||||
cmistake(u, ord, 8, MSG_EVENT);
|
|
||||||
} else if (!u->faction->alliance || u->faction->alliance != f2->alliance) {
|
} else if (!u->faction->alliance || u->faction->alliance != f2->alliance) {
|
||||||
cmistake(u, ord, 315, MSG_EVENT);
|
cmistake(u, ord, 315, MSG_EVENT);
|
||||||
|
return 0;
|
||||||
} else if(!alliedfaction(NULL, f, f2, HELP_MONEY)) {
|
} else if(!alliedfaction(NULL, f, f2, HELP_MONEY)) {
|
||||||
cmistake(u, ord, 316, MSG_EVENT);
|
cmistake(u, ord, 316, MSG_EVENT);
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
transfer_faction(f,f2);
|
set_variable(&f->attribs, "quit", token);
|
||||||
destroyfaction(f);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
destroyfaction(u->faction);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
destroyfaction(u->faction);
|
fset(f, FFL_QUIT);
|
||||||
return -1;
|
|
||||||
} else {
|
} else {
|
||||||
cmistake(u, ord, 86, MSG_EVENT);
|
cmistake(u, ord, 86, MSG_EVENT);
|
||||||
log_warning(("STIRB mit falschem Passwort für Partei %s: %s\n",
|
log_warning(("STIRB mit falschem Passwort für Partei %s: %s\n",
|
||||||
factionid(u->faction), passwd));
|
factionid(f), passwd));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parse_quit(void)
|
quit(void)
|
||||||
|
{
|
||||||
|
faction ** fptr = &factions;
|
||||||
|
while (*fptr) {
|
||||||
|
faction * f = *fptr;
|
||||||
|
if (f->flags & FFL_QUIT) {
|
||||||
|
if (EnhancedQuit()) {
|
||||||
|
const char * token = get_variable(f->attribs, "quit");
|
||||||
|
int f2_id = atoi36(token);
|
||||||
|
faction *f2 = findfaction(f2_id);
|
||||||
|
|
||||||
|
assert(f2_id>0);
|
||||||
|
assert(f2!=NULL);
|
||||||
|
transfer_faction(f, f2);
|
||||||
|
}
|
||||||
|
destroyfaction(f);
|
||||||
|
}
|
||||||
|
if (*fptr==f) fptr=&f->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
parse_restart(void)
|
||||||
{
|
{
|
||||||
region *r;
|
region *r;
|
||||||
faction *f;
|
faction *f;
|
||||||
|
@ -1075,19 +1096,16 @@ parse_quit(void)
|
||||||
unit * u, * un;
|
unit * u, * un;
|
||||||
for (u = r->units; u;) {
|
for (u = r->units; u;) {
|
||||||
order * ord;
|
order * ord;
|
||||||
|
|
||||||
un = u->next;
|
un = u->next;
|
||||||
for (ord = u->orders; ord; ord = ord->next) {
|
for (ord = u->orders; ord!=NULL; ord = ord->next) {
|
||||||
switch (get_keyword(ord)) {
|
if (get_keyword(ord) == K_RESTART) {
|
||||||
case K_QUIT:
|
if (u->number > 0) {
|
||||||
if (quit(u, ord)!=0) ord = NULL;
|
if (restart_cmd(u, ord)!=0) {
|
||||||
break;
|
break;
|
||||||
case K_RESTART:
|
|
||||||
if (u->number > 0) {
|
|
||||||
if (restart_cmd(u, ord)!=0) ord = NULL;
|
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
if (ord==NULL) break;
|
|
||||||
}
|
}
|
||||||
u = un;
|
u = un;
|
||||||
}
|
}
|
||||||
|
@ -2718,43 +2736,46 @@ instant_orders(void)
|
||||||
freset(u, UFL_MOVED);
|
freset(u, UFL_MOVED);
|
||||||
for (ord = u->orders; ord; ord = ord->next) {
|
for (ord = u->orders; ord; ord = ord->next) {
|
||||||
switch (get_keyword(ord)) {
|
switch (get_keyword(ord)) {
|
||||||
|
case K_QUIT:
|
||||||
|
quit_cmd(u, ord);
|
||||||
|
break;
|
||||||
case K_URSPRUNG:
|
case K_URSPRUNG:
|
||||||
if (origin_cmd(u, ord)!=0) ord=NULL;
|
origin_cmd(u, ord);
|
||||||
break;
|
break;
|
||||||
case K_ALLY:
|
case K_ALLY:
|
||||||
if (ally_cmd(u, ord)!=0) ord = NULL;
|
ally_cmd(u, ord);
|
||||||
break;
|
break;
|
||||||
case K_PREFIX:
|
case K_PREFIX:
|
||||||
if (prefix_cmd(u, ord)!=0) ord = NULL;
|
prefix_cmd(u, ord);
|
||||||
break;
|
break;
|
||||||
case K_SYNONYM:
|
case K_SYNONYM:
|
||||||
if (synonym_cmd(u, ord)!=0) ord = NULL;
|
synonym_cmd(u, ord);
|
||||||
break;
|
break;
|
||||||
case K_SETSTEALTH:
|
case K_SETSTEALTH:
|
||||||
if (setstealth_cmd(u, ord)!=0) ord = NULL;
|
setstealth_cmd(u, ord);
|
||||||
break;
|
break;
|
||||||
case K_WEREWOLF:
|
case K_WEREWOLF:
|
||||||
if (setwere_cmd(u, ord)!=0) ord = NULL;
|
setwere_cmd(u, ord);
|
||||||
break;
|
break;
|
||||||
case K_STATUS:
|
case K_STATUS:
|
||||||
/* KAEMPFE [ NICHT | AGGRESSIV | DEFENSIV | HINTEN | FLIEHE ] */
|
/* KAEMPFE [ NICHT | AGGRESSIV | DEFENSIV | HINTEN | FLIEHE ] */
|
||||||
if (status_cmd(u, ord)!=0) ord = NULL;
|
status_cmd(u, ord);
|
||||||
break;
|
break;
|
||||||
case K_COMBAT:
|
case K_COMBAT:
|
||||||
/* KAMPFZAUBER [[STUFE n] "<Spruchname>"] [NICHT] */
|
/* KAMPFZAUBER [[STUFE n] "<Spruchname>"] [NICHT] */
|
||||||
if (combatspell_cmd(u, ord)!=0) ord = NULL;
|
combatspell_cmd(u, ord);
|
||||||
break;
|
break;
|
||||||
case K_DISPLAY:
|
case K_DISPLAY:
|
||||||
if (display_cmd(u, ord)!=0) ord = NULL;
|
display_cmd(u, ord);
|
||||||
break;
|
break;
|
||||||
case K_NAME:
|
case K_NAME:
|
||||||
if (name_cmd(u, ord)!=0) ord = NULL;
|
name_cmd(u, ord);
|
||||||
break;
|
break;
|
||||||
case K_GUARD:
|
case K_GUARD:
|
||||||
if (guard_off_cmd(u, ord)!=0) ord = NULL;
|
guard_off_cmd(u, ord);
|
||||||
break;
|
break;
|
||||||
case K_RESHOW:
|
case K_RESHOW:
|
||||||
if (reshow_cmd(u, ord)!=0) ord = NULL;
|
reshow_cmd(u, ord);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3966,8 +3987,9 @@ processorders (void)
|
||||||
puts(" - Gebäudeunterhalt (1. Versuch)");
|
puts(" - Gebäudeunterhalt (1. Versuch)");
|
||||||
maintain_buildings(false);
|
maintain_buildings(false);
|
||||||
|
|
||||||
puts(" - Sterben");
|
puts(" - Sterben, Neustart");
|
||||||
parse_quit();
|
quit();
|
||||||
|
parse_restart();
|
||||||
|
|
||||||
puts(" - Zaubern");
|
puts(" - Zaubern");
|
||||||
magic();
|
magic();
|
||||||
|
|
|
@ -839,14 +839,15 @@ typedef struct strlist {
|
||||||
} strlist;
|
} strlist;
|
||||||
|
|
||||||
#define FL_DH (1<<18) /* ehemals f->dh, u->dh, r->dh, etc... */
|
#define FL_DH (1<<18) /* ehemals f->dh, u->dh, r->dh, etc... */
|
||||||
|
#define FL_MARK (1<<23) /* für markierende algorithmen, die das
|
||||||
|
* hinterher auch wieder löschen müssen!
|
||||||
|
* (FL_DH muss man vorher initialisieren,
|
||||||
|
* FL_MARK hinterher löschen) */
|
||||||
|
|
||||||
/* alle vierstelligen zahlen: */
|
/* alle vierstelligen zahlen: */
|
||||||
#define MAX_UNIT_NR (36*36*36*36-1)
|
#define MAX_UNIT_NR (36*36*36*36-1)
|
||||||
#define MAX_CONTAINER_NR (36*36*36*36-1)
|
#define MAX_CONTAINER_NR (36*36*36*36-1)
|
||||||
|
|
||||||
#define FL_MARK (1<<23) /* für markierende algorithmen, die das hinterher auch wieder
|
|
||||||
löschen müssen! (Ist dafür nicht eigentlich FL_DH gedacht?) */
|
|
||||||
|
|
||||||
#define fval(u, i) ((u)->flags & (i))
|
#define fval(u, i) ((u)->flags & (i))
|
||||||
#define fset(u, i) ((u)->flags |= (i))
|
#define fset(u, i) ((u)->flags |= (i))
|
||||||
#define freset(u, i) ((u)->flags &= ~(i))
|
#define freset(u, i) ((u)->flags &= ~(i))
|
||||||
|
|
|
@ -33,9 +33,12 @@ typedef struct shortpwd {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* faction flags */
|
/* faction flags */
|
||||||
#define FFL_NOIDLEOUT (1<<24) /* Partei stirbt nicht an NMRs */
|
|
||||||
#define FFL_NOAID (1<<21) /* Hilfsflag Kampf */
|
|
||||||
#define FFL_RESTART (1<<2)
|
#define FFL_RESTART (1<<2)
|
||||||
|
#define FFL_QUIT (1<<3)
|
||||||
|
/* #define FL_DH (1<<18) */
|
||||||
|
#define FFL_NOAID (1<<21) /* Hilfsflag Kampf */
|
||||||
|
/* #define FL_MARK (1<<23) */
|
||||||
|
#define FFL_NOIDLEOUT (1<<24) /* Partei stirbt nicht an NMRs */
|
||||||
#define FFL_OVERRIDE (1<<27) /* Override-Passwort wurde benutzt */
|
#define FFL_OVERRIDE (1<<27) /* Override-Passwort wurde benutzt */
|
||||||
#define FFL_DBENTRY (1<<28) /* Partei ist in Datenbank eingetragen */
|
#define FFL_DBENTRY (1<<28) /* Partei ist in Datenbank eingetragen */
|
||||||
#define FFL_NOTIMEOUT (1<<29) /* ignore MaxAge() */
|
#define FFL_NOTIMEOUT (1<<29) /* ignore MaxAge() */
|
||||||
|
|
|
@ -6778,12 +6778,6 @@
|
||||||
</string>
|
</string>
|
||||||
</namespace>
|
</namespace>
|
||||||
|
|
||||||
<string name="claimable">
|
|
||||||
<text locale="de">Einheiten können die folgenden Gegenstände beanspruchen:
|
|
||||||
</text>
|
|
||||||
<text locale="en">Units can claim the following items: </text>
|
|
||||||
</string>
|
|
||||||
|
|
||||||
<string name="santa2004">
|
<string name="santa2004">
|
||||||
<text locale="de">'Ho ho ho!' Ein dicker Gnom fliegt auf einem von
|
<text locale="de">'Ho ho ho!' Ein dicker Gnom fliegt auf einem von
|
||||||
8 Jungdrachen gezogenen Schlitten durch die Nacht und vermacht Deiner
|
8 Jungdrachen gezogenen Schlitten durch die Nacht und vermacht Deiner
|
||||||
|
|
|
@ -381,11 +381,11 @@
|
||||||
<arg name="unit" type="unit"/>
|
<arg name="unit" type="unit"/>
|
||||||
<arg name="region" type="region"/>
|
<arg name="region" type="region"/>
|
||||||
<arg name="command" type="order"/>
|
<arg name="command" type="order"/>
|
||||||
<arg name="required" type="string"/>
|
<arg name="required" type="items"/>
|
||||||
</type>
|
</type>
|
||||||
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Dafür braucht die Einheit${required}."</text>
|
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Dafür braucht die Einheit $items($required)."</text>
|
||||||
<text locale="fr">"$unit($unit) in $region($region): '$order($command)' -$required is required to build this."</text>
|
<text locale="fr">"$unit($unit) in $region($region): '$order($command)' - for this, the unit needs $items($required)."</text>
|
||||||
<text locale="en">"$unit($unit) in $region($region): '$order($command)' -$required is required to build this."</text>
|
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - for this, the unit needs $items($required)."</text>
|
||||||
</message>
|
</message>
|
||||||
<message name="travelthru_trail" section="events">
|
<message name="travelthru_trail" section="events">
|
||||||
<type>
|
<type>
|
||||||
|
|
Loading…
Reference in a new issue