more getstrtoken() removal.

remove obsolete argument to checkpasswd().
This commit is contained in:
Enno Rehling 2014-12-22 14:30:04 +01:00
parent 5cdc85f6bf
commit 870d8001ef
4 changed files with 30 additions and 25 deletions

View File

@ -278,9 +278,9 @@ unit *addplayer(region * r, faction * f)
return u; return u;
} }
bool checkpasswd(const faction * f, const char *passwd, bool shortp) bool checkpasswd(const faction * f, const char *passwd)
{ {
if (unicode_utf8_strcasecmp(f->passw, passwd) == 0) if (passwd && unicode_utf8_strcasecmp(f->passw, passwd) == 0)
return true; return true;
return false; return false;
} }

View File

@ -120,7 +120,7 @@ const char *factionname(const struct faction *f);
struct unit *addplayer(struct region *r, faction * f); struct unit *addplayer(struct region *r, faction * f);
struct faction *addfaction(const char *email, const char *password, struct faction *addfaction(const char *email, const char *password,
const struct race *frace, const struct locale *loc, int subscription); const struct race *frace, const struct locale *loc, int subscription);
bool checkpasswd(const faction * f, const char *passwd, bool shortp); bool checkpasswd(const faction * f, const char *passwd);
void destroyfaction(faction * f); void destroyfaction(faction * f);
extern void set_alliance(struct faction *a, struct faction *b, int status); extern void set_alliance(struct faction *a, struct faction *b, int status);

View File

@ -224,9 +224,10 @@ static faction *factionorders(void)
f = findfaction(fid); f = findfaction(fid);
if (f != NULL && !fval(f, FFL_NPC)) { if (f != NULL && !fval(f, FFL_NPC)) {
const char *pass = getstrtoken(); char token[128];
const char *pass = getstrtok(token, sizeof(token));
if (!checkpasswd(f, (const char *)pass, true)) { if (!checkpasswd(f, (const char *)pass)) {
log_debug("Invalid password for faction %s\n", itoa36(fid)); log_debug("Invalid password for faction %s\n", itoa36(fid));
ADDMSG(&f->msgs, msg_message("wrongpasswd", "faction password", ADDMSG(&f->msgs, msg_message("wrongpasswd", "faction password",
f->no, pass)); f->no, pass));

View File

@ -946,14 +946,15 @@ static bool EnhancedQuit(void)
int quit_cmd(unit * u, struct order *ord) int quit_cmd(unit * u, struct order *ord)
{ {
char token[128];
faction *f = u->faction; faction *f = u->faction;
const char *passwd; const char *passwd;
keyword_t kwd; keyword_t kwd;
kwd = init_order(ord); kwd = init_order(ord);
assert(kwd == K_QUIT); assert(kwd == K_QUIT);
passwd = getstrtoken(); passwd = getstrtok(token, sizeof(token));
if (checkpasswd(f, (const char *)passwd, false)) { if (checkpasswd(f, (const char *)passwd)) {
if (EnhancedQuit()) { if (EnhancedQuit()) {
int f2_id = getid(); int f2_id = getid();
if (f2_id > 0) { if (f2_id > 0) {
@ -1340,6 +1341,7 @@ void quit(void)
int ally_cmd(unit * u, struct order *ord) int ally_cmd(unit * u, struct order *ord)
{ {
char token[128];
ally *sf, **sfp; ally *sf, **sfp;
faction *f; faction *f;
int keyword, not_kw; int keyword, not_kw;
@ -1355,7 +1357,7 @@ int ally_cmd(unit * u, struct order *ord)
if (f == u->faction) if (f == u->faction)
return 0; return 0;
s = getstrtoken(); s = getstrtok(token, sizeof(token));
if (!s[0]) if (!s[0])
keyword = P_ANY; keyword = P_ANY;
@ -2924,13 +2926,14 @@ void restack_units(void)
struct order *ord; struct order *ord;
for (ord = u->orders; ord; ord = ord->next) { for (ord = u->orders; ord; ord = ord->next) {
if (getkeyword(ord) == K_SORT) { if (getkeyword(ord) == K_SORT) {
char token[128];
const char *s; const char *s;
param_t p; param_t p;
int id; int id;
unit *v; unit *v;
init_order(ord); init_order(ord);
s = getstrtoken(); s = getstrtok(token, sizeof(token));
p = findparam(s, u->faction->locale); p = findparam(s, u->faction->locale);
id = getid(); id = getid();
v = findunit(id); v = findunit(id);
@ -3000,16 +3003,17 @@ void restack_units(void)
int renumber_cmd(unit * u, order * ord) int renumber_cmd(unit * u, order * ord)
{ {
char token[128];
const char *s; const char *s;
int i; int i;
faction *f = u->faction; faction *f = u->faction;
init_order(ord); init_order(ord);
s = getstrtoken(); s = getstrtok(token, sizeof(token));
switch (findparam_ex(s, u->faction->locale)) { switch (findparam_ex(s, u->faction->locale)) {
case P_FACTION: case P_FACTION:
s = getstrtoken(); s = getstrtok(token, sizeof(token));
if (s && *s) { if (s && *s) {
int id = atoi36((const char *)s); int id = atoi36((const char *)s);
attrib *a = a_find(f->attribs, &at_number); attrib *a = a_find(f->attribs, &at_number);
@ -3020,7 +3024,7 @@ int renumber_cmd(unit * u, order * ord)
break; break;
case P_UNIT: case P_UNIT:
s = getstrtoken(); s = getstrtok(token, sizeof(token));
if (s == NULL || *s == 0) { if (s == NULL || *s == 0) {
i = newunitid(); i = newunitid();
} }
@ -3063,7 +3067,7 @@ int renumber_cmd(unit * u, order * ord)
cmistake(u, ord, 116, MSG_EVENT); cmistake(u, ord, 116, MSG_EVENT);
break; break;
} }
s = getstrtoken(); s = getstrtok(token, sizeof(token));
if (s == NULL || *s == 0) { if (s == NULL || *s == 0) {
i = newcontainerid(); i = newcontainerid();
} }
@ -3092,7 +3096,7 @@ int renumber_cmd(unit * u, order * ord)
cmistake(u, ord, 148, MSG_EVENT); cmistake(u, ord, 148, MSG_EVENT);
break; break;
} }
s = getstrtoken(); s = getstrtok(token, sizeof(token));
if (*s == 0) { if (*s == 0) {
i = newcontainerid(); i = newcontainerid();
} }
@ -3358,8 +3362,8 @@ void new_units(void)
while (*ordp) { while (*ordp) {
order *makeord = *ordp; order *makeord = *ordp;
if (getkeyword(makeord) == K_MAKETEMP) { if (getkeyword(makeord) == K_MAKETEMP) {
const char *token; char token[128], *name = NULL;
char *name = NULL; const char *s;
int alias; int alias;
ship *sh; ship *sh;
order **newordersp; order **newordersp;
@ -3393,9 +3397,9 @@ void new_units(void)
init_order(makeord); init_order(makeord);
alias = getid(); alias = getid();
token = getstrtoken(); s = getstrtok(token, sizeof(token));
if (token && token[0]) { if (s && s[0]) {
name = _strdup(token); name = _strdup(s);
} }
u2 = create_unit(r, u->faction, 0, u->faction->race, alias, name, u); u2 = create_unit(r, u->faction, 0, u->faction->race, alias, name, u);
if (name != NULL) if (name != NULL)
@ -3703,10 +3707,9 @@ void defaultorders(void)
order *new_order = 0; order *new_order = 0;
const char *s; const char *s;
init_order(ord); init_order(ord);
s = getstrtoken(); s = getstrtok(lbuf, sizeof(lbuf));
if (s) { if (s) {
strcpy(lbuf, s); new_order = parse_order(s, u->faction->locale);
new_order = parse_order(lbuf, u->faction->locale);
} }
*ordp = ord->next; *ordp = ord->next;
ord->next = NULL; ord->next = NULL;
@ -3813,19 +3816,20 @@ static void update_spells(void)
int use_cmd(unit * u, struct order *ord) int use_cmd(unit * u, struct order *ord)
{ {
char token[128];
const char *t; const char *t;
int n, err = ENOITEM; int n, err = ENOITEM;
const item_type *itype; const item_type *itype;
init_order(ord); init_order(ord);
t = getstrtoken(); t = getstrtok(token, sizeof(token));
n = atoi((const char *)t); n = atoi((const char *)t);
if (n == 0) { if (n == 0) {
if (isparam(t, u->faction->locale, P_ANY)) { if (isparam(t, u->faction->locale, P_ANY)) {
/* BENUTZE ALLES Yanxspirit */ /* BENUTZE ALLES Yanxspirit */
n = INT_MAX; n = INT_MAX;
t = getstrtoken(); t = getstrtok(token, sizeof(token));
} }
else { else {
/* BENUTZE Yanxspirit */ /* BENUTZE Yanxspirit */
@ -3834,7 +3838,7 @@ int use_cmd(unit * u, struct order *ord)
} }
else { else {
/* BENUTZE 42 Yanxspirit */ /* BENUTZE 42 Yanxspirit */
t = getstrtoken(); t = getstrtok(token, sizeof(token));
} }
itype = t ? finditemtype(t, u->faction->locale) : NULL; itype = t ? finditemtype(t, u->faction->locale) : NULL;