From 870d8001ef8b983eeade71b01961d0dd013a02f6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 22 Dec 2014 14:30:04 +0100 Subject: [PATCH] more getstrtoken() removal. remove obsolete argument to checkpasswd(). --- src/kernel/faction.c | 4 ++-- src/kernel/faction.h | 2 +- src/kernel/save.c | 5 +++-- src/laws.c | 44 ++++++++++++++++++++++++-------------------- 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/kernel/faction.c b/src/kernel/faction.c index f300a11c8..731d817bb 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -278,9 +278,9 @@ unit *addplayer(region * r, faction * f) 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 false; } diff --git a/src/kernel/faction.h b/src/kernel/faction.h index c8764392d..20c6f9785 100644 --- a/src/kernel/faction.h +++ b/src/kernel/faction.h @@ -120,7 +120,7 @@ const char *factionname(const struct faction *f); struct unit *addplayer(struct region *r, faction * f); struct faction *addfaction(const char *email, const char *password, 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); extern void set_alliance(struct faction *a, struct faction *b, int status); diff --git a/src/kernel/save.c b/src/kernel/save.c index f47c3a9be..01cc9fc70 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -224,9 +224,10 @@ static faction *factionorders(void) f = findfaction(fid); 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)); ADDMSG(&f->msgs, msg_message("wrongpasswd", "faction password", f->no, pass)); diff --git a/src/laws.c b/src/laws.c index 341d2b656..95894ad9b 100755 --- a/src/laws.c +++ b/src/laws.c @@ -946,14 +946,15 @@ static bool EnhancedQuit(void) int quit_cmd(unit * u, struct order *ord) { + char token[128]; faction *f = u->faction; const char *passwd; keyword_t kwd; kwd = init_order(ord); assert(kwd == K_QUIT); - passwd = getstrtoken(); - if (checkpasswd(f, (const char *)passwd, false)) { + passwd = getstrtok(token, sizeof(token)); + if (checkpasswd(f, (const char *)passwd)) { if (EnhancedQuit()) { int f2_id = getid(); if (f2_id > 0) { @@ -1340,6 +1341,7 @@ void quit(void) int ally_cmd(unit * u, struct order *ord) { + char token[128]; ally *sf, **sfp; faction *f; int keyword, not_kw; @@ -1355,7 +1357,7 @@ int ally_cmd(unit * u, struct order *ord) if (f == u->faction) return 0; - s = getstrtoken(); + s = getstrtok(token, sizeof(token)); if (!s[0]) keyword = P_ANY; @@ -2924,13 +2926,14 @@ void restack_units(void) struct order *ord; for (ord = u->orders; ord; ord = ord->next) { if (getkeyword(ord) == K_SORT) { + char token[128]; const char *s; param_t p; int id; unit *v; init_order(ord); - s = getstrtoken(); + s = getstrtok(token, sizeof(token)); p = findparam(s, u->faction->locale); id = getid(); v = findunit(id); @@ -3000,16 +3003,17 @@ void restack_units(void) int renumber_cmd(unit * u, order * ord) { + char token[128]; const char *s; int i; faction *f = u->faction; init_order(ord); - s = getstrtoken(); + s = getstrtok(token, sizeof(token)); switch (findparam_ex(s, u->faction->locale)) { case P_FACTION: - s = getstrtoken(); + s = getstrtok(token, sizeof(token)); if (s && *s) { int id = atoi36((const char *)s); attrib *a = a_find(f->attribs, &at_number); @@ -3020,7 +3024,7 @@ int renumber_cmd(unit * u, order * ord) break; case P_UNIT: - s = getstrtoken(); + s = getstrtok(token, sizeof(token)); if (s == NULL || *s == 0) { i = newunitid(); } @@ -3063,7 +3067,7 @@ int renumber_cmd(unit * u, order * ord) cmistake(u, ord, 116, MSG_EVENT); break; } - s = getstrtoken(); + s = getstrtok(token, sizeof(token)); if (s == NULL || *s == 0) { i = newcontainerid(); } @@ -3092,7 +3096,7 @@ int renumber_cmd(unit * u, order * ord) cmistake(u, ord, 148, MSG_EVENT); break; } - s = getstrtoken(); + s = getstrtok(token, sizeof(token)); if (*s == 0) { i = newcontainerid(); } @@ -3358,8 +3362,8 @@ void new_units(void) while (*ordp) { order *makeord = *ordp; if (getkeyword(makeord) == K_MAKETEMP) { - const char *token; - char *name = NULL; + char token[128], *name = NULL; + const char *s; int alias; ship *sh; order **newordersp; @@ -3393,9 +3397,9 @@ void new_units(void) init_order(makeord); alias = getid(); - token = getstrtoken(); - if (token && token[0]) { - name = _strdup(token); + s = getstrtok(token, sizeof(token)); + if (s && s[0]) { + name = _strdup(s); } u2 = create_unit(r, u->faction, 0, u->faction->race, alias, name, u); if (name != NULL) @@ -3703,10 +3707,9 @@ void defaultorders(void) order *new_order = 0; const char *s; init_order(ord); - s = getstrtoken(); + s = getstrtok(lbuf, sizeof(lbuf)); if (s) { - strcpy(lbuf, s); - new_order = parse_order(lbuf, u->faction->locale); + new_order = parse_order(s, u->faction->locale); } *ordp = ord->next; ord->next = NULL; @@ -3813,19 +3816,20 @@ static void update_spells(void) int use_cmd(unit * u, struct order *ord) { + char token[128]; const char *t; int n, err = ENOITEM; const item_type *itype; init_order(ord); - t = getstrtoken(); + t = getstrtok(token, sizeof(token)); n = atoi((const char *)t); if (n == 0) { if (isparam(t, u->faction->locale, P_ANY)) { /* BENUTZE ALLES Yanxspirit */ n = INT_MAX; - t = getstrtoken(); + t = getstrtok(token, sizeof(token)); } else { /* BENUTZE Yanxspirit */ @@ -3834,7 +3838,7 @@ int use_cmd(unit * u, struct order *ord) } else { /* BENUTZE 42 Yanxspirit */ - t = getstrtoken(); + t = getstrtok(token, sizeof(token)); } itype = t ? finditemtype(t, u->faction->locale) : NULL;