forked from github/server
remember to set faction.lastorders (NMR count was off).
checker just removes comments now.
This commit is contained in:
parent
bbd57b6ae9
commit
6b983079b7
|
@ -2,10 +2,50 @@
|
|||
#include <platform.h>
|
||||
#endif
|
||||
|
||||
#include "util/parser.h"
|
||||
#include "util/order_parser.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct parser_state {
|
||||
FILE * F;
|
||||
} parser_state;
|
||||
|
||||
static void handle_order(void *userData, const char *str) {
|
||||
parser_state * state = (parser_state*)userData;
|
||||
fputs(str, state->F);
|
||||
fputc('\n', state->F);
|
||||
}
|
||||
|
||||
int parsefile(FILE *F) {
|
||||
OP_Parser parser;
|
||||
char buf[1024];
|
||||
int done = 0, err = 0;
|
||||
parser_state state = { NULL };
|
||||
|
||||
state.F = stdout;
|
||||
|
||||
parser = OP_ParserCreate();
|
||||
OP_SetOrderHandler(parser, handle_order);
|
||||
OP_SetUserData(parser, &state);
|
||||
|
||||
while (!done) {
|
||||
size_t len = (int)fread(buf, 1, sizeof(buf), F);
|
||||
if (ferror(F)) {
|
||||
/* TODO: error message */
|
||||
err = errno;
|
||||
break;
|
||||
}
|
||||
done = feof(F);
|
||||
if (OP_Parse(parser, buf, len, done) == OP_STATUS_ERROR) {
|
||||
/* TODO: error message */
|
||||
err = (int)OP_GetErrorCode(parser);
|
||||
break;
|
||||
}
|
||||
}
|
||||
OP_ParserFree(parser);
|
||||
return err;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
FILE * F = stdin;
|
||||
if (argc >= 1) {
|
||||
|
@ -15,8 +55,10 @@ int main(int argc, char **argv) {
|
|||
perror(filename);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
parsefile(F);
|
||||
if (F != stdin) {
|
||||
fclose(F);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -245,7 +245,10 @@ static void handle_faction(void *userData, int no, const char *password) {
|
|||
log_debug("orders for unknown faction %s", itoa36(no));
|
||||
}
|
||||
else {
|
||||
if (!checkpasswd(f, password)) {
|
||||
if (checkpasswd(f, password)) {
|
||||
f->lastorders = turn;
|
||||
}
|
||||
else {
|
||||
log_debug("invalid password for faction %s", itoa36(no));
|
||||
ADDMSG(&f->msgs, msg_message("wrongpasswd", "password", password));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue