forked from github/server
remove debug stuff, use new parser for the game.
This commit is contained in:
parent
730b94fa4a
commit
bbd57b6ae9
3 changed files with 6 additions and 37 deletions
|
@ -41,7 +41,7 @@ int eressea_read_orders(const char * filename) {
|
|||
return -1;
|
||||
}
|
||||
log_info("reading orders from %s", filename);
|
||||
return readorders(F);
|
||||
return parseorders(F);
|
||||
}
|
||||
|
||||
int eressea_export_json(const char * filename, int flags) {
|
||||
|
|
|
@ -21,9 +21,6 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static FILE *dlog;
|
||||
static int orders_parsed, units_parsed, factions_parsed;
|
||||
|
||||
static void begin_orders(unit *u) {
|
||||
if (u->flags & UFL_ORDERS) {
|
||||
order **ordp;
|
||||
|
@ -55,7 +52,6 @@ static unit *unitorders(input *in, faction *f)
|
|||
int i;
|
||||
unit *u;
|
||||
|
||||
++units_parsed;
|
||||
if (!f)
|
||||
return NULL;
|
||||
|
||||
|
@ -113,11 +109,6 @@ static unit *unitorders(input *in, faction *f)
|
|||
}
|
||||
}
|
||||
/* Nun wird der Befehl erzeut und eingeh<65>ngt */
|
||||
++orders_parsed;
|
||||
if (dlog) {
|
||||
fputs(s, dlog);
|
||||
fputc('\n', dlog);
|
||||
}
|
||||
*ordp = parse_order(s, u->faction->locale);
|
||||
if (*ordp) {
|
||||
ordp = &(*ordp)->next;
|
||||
|
@ -140,7 +131,6 @@ static faction *factionorders(void)
|
|||
int fid = getid();
|
||||
faction *f = findfaction(fid);
|
||||
|
||||
++factions_parsed;
|
||||
if (f != NULL && (f->flags & FFL_NPC) == 0) {
|
||||
char token[128];
|
||||
const char *pass = gettoken(token, sizeof(token));
|
||||
|
@ -251,7 +241,6 @@ typedef struct parser_state {
|
|||
static void handle_faction(void *userData, int no, const char *password) {
|
||||
parser_state *state = (parser_state *)userData;
|
||||
faction * f = state->f = findfaction(no);
|
||||
++factions_parsed;
|
||||
if (!f) {
|
||||
log_debug("orders for unknown faction %s", itoa36(no));
|
||||
}
|
||||
|
@ -269,7 +258,6 @@ static void handle_unit(void *userData, int no) {
|
|||
parser_state *state = (parser_state *)userData;
|
||||
unit * u = findunit(no);
|
||||
|
||||
++units_parsed;
|
||||
state->u = NULL;
|
||||
if (!u) {
|
||||
/* TODO: error message */
|
||||
|
@ -325,11 +313,6 @@ static void handle_order(void *userData, const char *str) {
|
|||
else if (state->u) {
|
||||
unit * u = state->u;
|
||||
order * ord = parse_order(str, lang);
|
||||
++orders_parsed;
|
||||
if (dlog) {
|
||||
fputs(str, dlog);
|
||||
fputc('\n', dlog);
|
||||
}
|
||||
if (ord) {
|
||||
*state->next_order = ord;
|
||||
state->next_order = &ord->next;
|
||||
|
@ -373,28 +356,13 @@ int parseorders(FILE *F)
|
|||
return err;
|
||||
}
|
||||
|
||||
#define NEW_PARSER
|
||||
int readorders(FILE *F)
|
||||
{
|
||||
int result;
|
||||
|
||||
orders_parsed = 0;
|
||||
units_parsed = 0;
|
||||
factions_parsed = 0;
|
||||
|
||||
#ifdef NEW_PARSER
|
||||
dlog = fopen("orders.new.log", "w+");
|
||||
result = parseorders(F);
|
||||
#else
|
||||
dlog = fopen("orders.old.log", "w+");
|
||||
{
|
||||
input in;
|
||||
in.getbuf = file_getbuf;
|
||||
in.data = F;
|
||||
result = read_orders(&in);
|
||||
}
|
||||
#endif
|
||||
fclose(dlog);
|
||||
log_debug("%d orders read.", orders_parsed);
|
||||
input in;
|
||||
in.getbuf = file_getbuf;
|
||||
in.data = F;
|
||||
result = read_orders(&in);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ extern "C" {
|
|||
|
||||
int read_orders(struct input *in);
|
||||
int readorders(FILE *F);
|
||||
int parseorders(FILE *F);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue