Merge pull request #85 from badgerman/master

remove some more code.feature: show unit limit in NR & CR
This commit is contained in:
Enno Rehling 2014-12-19 20:07:26 +01:00
commit e9dda0d702
9 changed files with 46 additions and 54 deletions

View File

@ -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>

View File

@ -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);

View File

@ -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) {

View File

@ -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)

View File

@ -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:
@ -308,9 +305,12 @@ int readorders(const char *filename)
if (!f || !unitorders(F, enc_gamedata, f))
do {
b = getbuf(F, enc_gamedata);
if (!b)
if (!b) {
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
&& p != P_GAMENAME);
break;

View File

@ -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 */

View File

@ -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);

View File

@ -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;
}

View File

@ -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
}