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">
|
<message name="nr_population" section="nr">
|
||||||
<type>
|
<type>
|
||||||
<arg name="population" type="int"/>
|
<arg name="population" type="int"/>
|
||||||
|
<arg name="limit" type="int"/>
|
||||||
<arg name="units" type="int"/>
|
<arg name="units" type="int"/>
|
||||||
</type>
|
</type>
|
||||||
<text locale="de">"Deine Partei hat $int($population) Personen in $int($units) Einheiten."</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) units."</text>
|
<text locale="en">"Your faction has $int($population) people in $int($units) of $int($limit) possible units."</text>
|
||||||
</message>
|
</message>
|
||||||
<message name="nr_stat_header" section="nr">
|
<message name="nr_stat_header" section="nr">
|
||||||
<type>
|
<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\";Spiel\n", game_name());
|
||||||
fprintf(F, "\"%s\";Konfiguration\n", "Standard");
|
fprintf(F, "\"%s\";Konfiguration\n", "Standard");
|
||||||
fprintf(F, "\"%s\";Koordinaten\n", "Hex");
|
fprintf(F, "\"%s\";Koordinaten\n", "Hex");
|
||||||
|
fprintf(F, "%d;max_units\n", rule_faction_limit());
|
||||||
fprintf(F, "%d;Basis\n", 36);
|
fprintf(F, "%d;Basis\n", 36);
|
||||||
fprintf(F, "%d;Runde\n", turn);
|
fprintf(F, "%d;Runde\n", turn);
|
||||||
fprintf(F, "%d;Zeitalter\n", era);
|
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)
|
unsigned int getuint(void)
|
||||||
{
|
{
|
||||||
const char *s = getstrtoken();
|
const char *s = getstrtoken();
|
||||||
|
@ -1218,16 +1209,6 @@ typedef struct param {
|
||||||
char *data;
|
char *data;
|
||||||
} param;
|
} 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)
|
const char *get_param(const struct param *p, const char *key)
|
||||||
{
|
{
|
||||||
while (p != NULL) {
|
while (p != NULL) {
|
||||||
|
|
|
@ -112,19 +112,13 @@ extern "C" {
|
||||||
unsigned int getuint(void);
|
unsigned int getuint(void);
|
||||||
int getint(void);
|
int getint(void);
|
||||||
|
|
||||||
const char *igetstrtoken(const char *s);
|
|
||||||
|
|
||||||
param_t findparam(const char *s, const struct locale *lang);
|
param_t findparam(const char *s, const struct locale *lang);
|
||||||
param_t findparam_ex(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);
|
bool isparam(const char *s, const struct locale * lang, param_t param);
|
||||||
param_t getparam(const struct locale *lang);
|
param_t getparam(const struct locale *lang);
|
||||||
|
|
||||||
int getid(void);
|
|
||||||
#define unitid(x) itoa36((x)->no)
|
#define unitid(x) itoa36((x)->no)
|
||||||
|
|
||||||
#define getshipid() getid()
|
|
||||||
#define getfactionid() getid()
|
|
||||||
|
|
||||||
#define buildingid(x) itoa36((x)->no)
|
#define buildingid(x) itoa36((x)->no)
|
||||||
#define shipid(x) itoa36((x)->no)
|
#define shipid(x) itoa36((x)->no)
|
||||||
#define factionid(x) itoa36((x)->no)
|
#define factionid(x) itoa36((x)->no)
|
||||||
|
|
|
@ -246,13 +246,6 @@ static faction *factionorders(void)
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static param_t igetparam(const char *s, const struct locale *lang)
|
|
||||||
{
|
|
||||||
return findparam(igetstrtoken(s), lang);
|
|
||||||
}
|
|
||||||
|
|
||||||
int readorders(const char *filename)
|
int readorders(const char *filename)
|
||||||
{
|
{
|
||||||
FILE *F = NULL;
|
FILE *F = NULL;
|
||||||
|
@ -275,8 +268,12 @@ int readorders(const char *filename)
|
||||||
|
|
||||||
while (b) {
|
while (b) {
|
||||||
const struct locale *lang = f ? f->locale : default_locale;
|
const struct locale *lang = f ? f->locale : default_locale;
|
||||||
int p;
|
param_t p;
|
||||||
switch (igetparam(b, lang)) {
|
const char *s;
|
||||||
|
init_tokens_str(b, NULL);
|
||||||
|
s = getstrtoken();
|
||||||
|
p = s ? findparam(s, lang) : NOPARAM;
|
||||||
|
switch (p) {
|
||||||
#undef LOCALE_CHANGE
|
#undef LOCALE_CHANGE
|
||||||
#ifdef LOCALE_CHANGE
|
#ifdef LOCALE_CHANGE
|
||||||
case P_LOCALE:
|
case P_LOCALE:
|
||||||
|
@ -308,9 +305,12 @@ int readorders(const char *filename)
|
||||||
if (!f || !unitorders(F, enc_gamedata, f))
|
if (!f || !unitorders(F, enc_gamedata, f))
|
||||||
do {
|
do {
|
||||||
b = getbuf(F, enc_gamedata);
|
b = getbuf(F, enc_gamedata);
|
||||||
if (!b)
|
if (!b) {
|
||||||
break;
|
break;
|
||||||
p = (b[0] == '@') ? NOPARAM : igetparam(b, lang);
|
}
|
||||||
|
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
|
} while ((p != P_UNIT || !f) && p != P_FACTION && p != P_NEXT
|
||||||
&& p != P_GAMENAME);
|
&& p != P_GAMENAME);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -2615,7 +2615,8 @@ static int hunt(unit * u, order * ord)
|
||||||
/* In command steht jetzt das NACH-Kommando. */
|
/* In command steht jetzt das NACH-Kommando. */
|
||||||
|
|
||||||
/* NACH ignorieren und Parsing initialisieren. */
|
/* NACH ignorieren und Parsing initialisieren. */
|
||||||
igetstrtoken(command);
|
init_tokens_str(command, NULL);
|
||||||
|
getstrtoken();
|
||||||
/* NACH ausführen */
|
/* NACH ausführen */
|
||||||
move(u, false);
|
move(u, false);
|
||||||
return 1; /* true -> Einheitenliste von vorne durchgehen */
|
return 1; /* true -> Einheitenliste von vorne durchgehen */
|
||||||
|
|
|
@ -2195,7 +2195,7 @@ const char *charset)
|
||||||
no_people = f->num_people;
|
no_people = f->num_people;
|
||||||
}
|
}
|
||||||
#endif
|
#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);
|
nr_render(m, f->locale, buf, sizeof(buf), f);
|
||||||
msg_release(m);
|
msg_release(m);
|
||||||
centre(F, buf, true);
|
centre(F, buf, true);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "unicode.h"
|
#include "unicode.h"
|
||||||
|
#include "base36.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -200,3 +201,13 @@ const char *getstrtoken(void)
|
||||||
{
|
{
|
||||||
return parse_token((const char **)&states->current_token);
|
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" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void init_tokens_str(const char *initstr, char *cmd); /* initialize token parsing, take ownership of cmd */
|
void init_tokens_str(const char *initstr, char *cmd); /* initialize token parsing, take ownership of cmd */
|
||||||
extern void skip_token(void);
|
void skip_token(void);
|
||||||
extern const char *parse_token(const char **str);
|
const char *parse_token(const char **str);
|
||||||
extern void parser_pushstate(void);
|
void parser_pushstate(void);
|
||||||
extern void parser_popstate(void);
|
void parser_popstate(void);
|
||||||
extern bool parser_end(void);
|
bool parser_end(void);
|
||||||
extern const char *getstrtoken(void);
|
const char *getstrtoken(void);
|
||||||
|
int getid(void);
|
||||||
|
#define getshipid() getid()
|
||||||
|
#define getfactionid() getid()
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue