forked from github/server
Merge pull request #85 from badgerman/master
remove some more code.feature: show unit limit in NR & CR
This commit is contained in:
commit
e9dda0d702
|
@ -787,10 +787,11 @@
|
|||
<message name="nr_population" section="nr">
|
||||
<type>
|
||||
<arg name="population" type="int"/>
|
||||
<arg name="limit" type="int"/>
|
||||
<arg name="units" type="int"/>
|
||||
</type>
|
||||
<text locale="de">"Deine Partei hat $int($population) Personen in $int($units) Einheiten."</text>
|
||||
<text locale="en">"Your faction has $int($population) people in $int($units) units."</text>
|
||||
<text locale="de">"Deine Partei hat $int($population) Personen in $int($units) von maximal $int($limit) Einheiten."</text>
|
||||
<text locale="en">"Your faction has $int($population) people in $int($units) of $int($limit) possible units."</text>
|
||||
</message>
|
||||
<message name="nr_stat_header" section="nr">
|
||||
<type>
|
||||
|
|
|
@ -1523,6 +1523,7 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
|
|||
fprintf(F, "\"%s\";Spiel\n", game_name());
|
||||
fprintf(F, "\"%s\";Konfiguration\n", "Standard");
|
||||
fprintf(F, "\"%s\";Koordinaten\n", "Hex");
|
||||
fprintf(F, "%d;max_units\n", rule_faction_limit());
|
||||
fprintf(F, "%d;Basis\n", 36);
|
||||
fprintf(F, "%d;Runde\n", turn);
|
||||
fprintf(F, "%d;Zeitalter\n", era);
|
||||
|
|
|
@ -794,15 +794,6 @@ parse(keyword_t kword, int(*dofun) (unit *, struct order *), bool thisorder)
|
|||
}
|
||||
}
|
||||
|
||||
const char *igetstrtoken(const char *initstr)
|
||||
{
|
||||
if (initstr != NULL) {
|
||||
init_tokens_str(initstr, NULL);
|
||||
}
|
||||
|
||||
return getstrtoken();
|
||||
}
|
||||
|
||||
unsigned int getuint(void)
|
||||
{
|
||||
const char *s = getstrtoken();
|
||||
|
@ -1218,16 +1209,6 @@ typedef struct param {
|
|||
char *data;
|
||||
} param;
|
||||
|
||||
int getid(void)
|
||||
{
|
||||
const char *str = getstrtoken();
|
||||
int i = str ? atoi36(str) : 0;
|
||||
if (i < 0) {
|
||||
return -1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
const char *get_param(const struct param *p, const char *key)
|
||||
{
|
||||
while (p != NULL) {
|
||||
|
|
|
@ -112,19 +112,13 @@ extern "C" {
|
|||
unsigned int getuint(void);
|
||||
int getint(void);
|
||||
|
||||
const char *igetstrtoken(const char *s);
|
||||
|
||||
param_t findparam(const char *s, const struct locale *lang);
|
||||
param_t findparam_ex(const char *s, const struct locale * lang);
|
||||
bool isparam(const char *s, const struct locale * lang, param_t param);
|
||||
param_t getparam(const struct locale *lang);
|
||||
|
||||
int getid(void);
|
||||
#define unitid(x) itoa36((x)->no)
|
||||
|
||||
#define getshipid() getid()
|
||||
#define getfactionid() getid()
|
||||
|
||||
#define buildingid(x) itoa36((x)->no)
|
||||
#define shipid(x) itoa36((x)->no)
|
||||
#define factionid(x) itoa36((x)->no)
|
||||
|
|
|
@ -246,13 +246,6 @@ static faction *factionorders(void)
|
|||
return f;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
static param_t igetparam(const char *s, const struct locale *lang)
|
||||
{
|
||||
return findparam(igetstrtoken(s), lang);
|
||||
}
|
||||
|
||||
int readorders(const char *filename)
|
||||
{
|
||||
FILE *F = NULL;
|
||||
|
@ -275,8 +268,12 @@ int readorders(const char *filename)
|
|||
|
||||
while (b) {
|
||||
const struct locale *lang = f ? f->locale : default_locale;
|
||||
int p;
|
||||
switch (igetparam(b, lang)) {
|
||||
param_t p;
|
||||
const char *s;
|
||||
init_tokens_str(b, NULL);
|
||||
s = getstrtoken();
|
||||
p = s ? findparam(s, lang) : NOPARAM;
|
||||
switch (p) {
|
||||
#undef LOCALE_CHANGE
|
||||
#ifdef LOCALE_CHANGE
|
||||
case P_LOCALE:
|
||||
|
@ -286,8 +283,8 @@ int readorders(const char *filename)
|
|||
f->locale = get_locale(s);
|
||||
}
|
||||
}
|
||||
b = getbuf(F, enc_gamedata);
|
||||
break;
|
||||
b = getbuf(F, enc_gamedata);
|
||||
break;
|
||||
#endif
|
||||
case P_GAMENAME:
|
||||
case P_FACTION:
|
||||
|
@ -307,10 +304,13 @@ int readorders(const char *filename)
|
|||
case P_UNIT:
|
||||
if (!f || !unitorders(F, enc_gamedata, f))
|
||||
do {
|
||||
b = getbuf(F, enc_gamedata);
|
||||
if (!b)
|
||||
break;
|
||||
p = (b[0] == '@') ? NOPARAM : igetparam(b, lang);
|
||||
b = getbuf(F, enc_gamedata);
|
||||
if (!b) {
|
||||
break;
|
||||
}
|
||||
init_tokens_str(b, NULL);
|
||||
b = getstrtoken();
|
||||
p = (!b || b[0] == '@') ? NOPARAM : findparam(b, lang);
|
||||
} while ((p != P_UNIT || !f) && p != P_FACTION && p != P_NEXT
|
||||
&& p != P_GAMENAME);
|
||||
break;
|
||||
|
@ -1030,8 +1030,8 @@ void writeregion(struct gamedata *data, const region * r)
|
|||
WRITE_INT(data->store, rmoney(r));
|
||||
if (r->land)
|
||||
for (demand = r->land->demands; demand; demand = demand->next) {
|
||||
WRITE_TOK(data->store, resourcename(demand->type->itype->rtype, 0));
|
||||
WRITE_INT(data->store, demand->value);
|
||||
WRITE_TOK(data->store, resourcename(demand->type->itype->rtype, 0));
|
||||
WRITE_INT(data->store, demand->value);
|
||||
}
|
||||
WRITE_TOK(data->store, "end");
|
||||
write_items(data->store, r->land->items);
|
||||
|
@ -1856,7 +1856,7 @@ int writegame(const char *filename)
|
|||
|
||||
log_printf(stdout, "\nOk.\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int a_readint(attrib * a, void *owner, struct storage *store)
|
||||
{
|
||||
|
|
|
@ -2615,7 +2615,8 @@ static int hunt(unit * u, order * ord)
|
|||
/* In command steht jetzt das NACH-Kommando. */
|
||||
|
||||
/* NACH ignorieren und Parsing initialisieren. */
|
||||
igetstrtoken(command);
|
||||
init_tokens_str(command, NULL);
|
||||
getstrtoken();
|
||||
/* NACH ausführen */
|
||||
move(u, false);
|
||||
return 1; /* true -> Einheitenliste von vorne durchgehen */
|
||||
|
|
|
@ -2195,7 +2195,7 @@ const char *charset)
|
|||
no_people = f->num_people;
|
||||
}
|
||||
#endif
|
||||
m = msg_message("nr_population", "population units", no_people, no_units);
|
||||
m = msg_message("nr_population", "population units limit", no_people, no_units, rule_faction_limit());
|
||||
nr_render(m, f->locale, buf, sizeof(buf), f);
|
||||
msg_release(m);
|
||||
centre(F, buf, true);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <platform.h>
|
||||
#include "parser.h"
|
||||
#include "unicode.h"
|
||||
#include "base36.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -200,3 +201,13 @@ const char *getstrtoken(void)
|
|||
{
|
||||
return parse_token((const char **)&states->current_token);
|
||||
}
|
||||
|
||||
int getid(void)
|
||||
{
|
||||
const char *str = getstrtoken();
|
||||
int i = str ? atoi36(str) : 0;
|
||||
if (i < 0) {
|
||||
return -1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -14,13 +14,16 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void init_tokens_str(const char *initstr, char *cmd); /* initialize token parsing, take ownership of cmd */
|
||||
extern void skip_token(void);
|
||||
extern const char *parse_token(const char **str);
|
||||
extern void parser_pushstate(void);
|
||||
extern void parser_popstate(void);
|
||||
extern bool parser_end(void);
|
||||
extern const char *getstrtoken(void);
|
||||
void init_tokens_str(const char *initstr, char *cmd); /* initialize token parsing, take ownership of cmd */
|
||||
void skip_token(void);
|
||||
const char *parse_token(const char **str);
|
||||
void parser_pushstate(void);
|
||||
void parser_popstate(void);
|
||||
bool parser_end(void);
|
||||
const char *getstrtoken(void);
|
||||
int getid(void);
|
||||
#define getshipid() getid()
|
||||
#define getfactionid() getid()
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue