ongoing config.c cleanup: getid()

This commit is contained in:
Enno Rehling 2014-12-18 07:09:22 +01:00
parent 484e52d491
commit da1d3c49c3
4 changed files with 21 additions and 21 deletions

View File

@ -1218,16 +1218,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

@ -119,12 +119,8 @@ extern "C" {
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

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