forked from github/server
- Undo modifications to strlcpy from rev 3631
- Many more warnings when buffers too small.
This commit is contained in:
parent
28fa9e5d81
commit
a1865ee2fa
14 changed files with 478 additions and 458 deletions
|
@ -1914,7 +1914,7 @@ email_cmd(unit * u, struct order * ord)
|
||||||
static int
|
static int
|
||||||
password_cmd(unit * u, struct order * ord)
|
password_cmd(unit * u, struct order * ord)
|
||||||
{
|
{
|
||||||
char pbuf[32];
|
char pwbuf[32];
|
||||||
int i;
|
int i;
|
||||||
const char * s;
|
const char * s;
|
||||||
boolean pwok = true;
|
boolean pwok = true;
|
||||||
|
@ -1924,14 +1924,14 @@ password_cmd(unit * u, struct order * ord)
|
||||||
s = getstrtoken();
|
s = getstrtoken();
|
||||||
|
|
||||||
if (!s || !*s) {
|
if (!s || !*s) {
|
||||||
for(i=0; i<6; i++) pbuf[i] = (char)(97 + rng_int() % 26);
|
for(i=0; i<6; i++) pwbuf[i] = (char)(97 + rng_int() % 26);
|
||||||
pbuf[6] = 0;
|
pwbuf[6] = 0;
|
||||||
} else {
|
} else {
|
||||||
char *c;
|
char *c;
|
||||||
|
|
||||||
strlcpy(pbuf, (const char *)s, 31);
|
strlcpy(pwbuf, (const char *)s, 31);
|
||||||
pbuf[31] = 0;
|
pwbuf[31] = 0;
|
||||||
c = pbuf;
|
c = pwbuf;
|
||||||
while (*c && pwok) {
|
while (*c && pwok) {
|
||||||
if (!isalnum(*c)) pwok = false;
|
if (!isalnum(*c)) pwok = false;
|
||||||
c++;
|
c++;
|
||||||
|
@ -1942,7 +1942,7 @@ password_cmd(unit * u, struct order * ord)
|
||||||
cmistake(u, ord, 283, MSG_EVENT);
|
cmistake(u, ord, 283, MSG_EVENT);
|
||||||
u->faction->passw = strdup(itoa36(rng_int()));
|
u->faction->passw = strdup(itoa36(rng_int()));
|
||||||
} else {
|
} else {
|
||||||
u->faction->passw = strdup(pbuf);
|
u->faction->passw = strdup(pwbuf);
|
||||||
}
|
}
|
||||||
fset(u->faction, FFL_OVERRIDE);
|
fset(u->faction, FFL_OVERRIDE);
|
||||||
ADDMSG(&u->faction->msgs, msg_message("changepasswd",
|
ADDMSG(&u->faction->msgs, msg_message("changepasswd",
|
||||||
|
@ -2064,18 +2064,15 @@ display_race(faction *f, unit *u, const race * rc)
|
||||||
const char *name, *key;
|
const char *name, *key;
|
||||||
const char *info;
|
const char *info;
|
||||||
int a, at_count;
|
int a, at_count;
|
||||||
char buf[2048];
|
char buf[2048], * bufp = buf;
|
||||||
char buf2[128];
|
size_t size = sizeof(buf) - 1;
|
||||||
char * bufp = buf;
|
int bytes;
|
||||||
size_t size = sizeof(buf), rsize;
|
|
||||||
|
|
||||||
if (u && u->race != rc) return false;
|
if (u && u->race != rc) return false;
|
||||||
name = rc_name(rc, 0);
|
name = rc_name(rc, 0);
|
||||||
|
|
||||||
rsize = slprintf(bufp, size, "%s: ", LOC(f->locale, name));
|
bytes = slprintf(bufp, size, "%s: ", LOC(f->locale, name));
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
|
|
||||||
key = mkname("raceinfo", rc->_name[0]);
|
key = mkname("raceinfo", rc->_name[0]);
|
||||||
info = locale_getstring(f->locale, key);
|
info = locale_getstring(f->locale, key);
|
||||||
|
@ -2083,46 +2080,31 @@ display_race(faction *f, unit *u, const race * rc)
|
||||||
info = locale_string(f->locale, mkname("raceinfo", "no_info"));
|
info = locale_string(f->locale, mkname("raceinfo", "no_info"));
|
||||||
}
|
}
|
||||||
|
|
||||||
rsize = strlcpy(bufp, info, size);
|
bytes = (int)strlcpy(bufp, info, size);
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
|
|
||||||
/* hp_p : Trefferpunkte */
|
/* hp_p : Trefferpunkte */
|
||||||
sprintf(buf2, " %d %s", rc->hitpoints, LOC(f->locale, "stat_hitpoints"));
|
bytes = snprintf(bufp, size, " %d %s", rc->hitpoints, LOC(f->locale, "stat_hitpoints"));
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
rsize = strlcpy(bufp, buf2, size);
|
|
||||||
if (rsize>size) rsize = size-1;
|
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
|
|
||||||
/* b_attacke : Angriff */
|
/* b_attacke : Angriff */
|
||||||
sprintf(buf2, ", %s: %d", LOC(f->locale, "stat_attack"), (rc->at_default+rc->at_bonus));
|
bytes = snprintf(bufp, size, ", %s: %d", LOC(f->locale, "stat_attack"), (rc->at_default+rc->at_bonus));
|
||||||
rsize = strlcpy(bufp, buf2, size);
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
if (rsize>size) rsize = size-1;
|
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
|
|
||||||
/* b_defense : Verteidigung */
|
/* b_defense : Verteidigung */
|
||||||
sprintf(buf2, ", %s: %d", LOC(f->locale, "stat_defense"), (rc->df_default+rc->df_bonus));
|
bytes = snprintf(bufp, size, ", %s: %d", LOC(f->locale, "stat_defense"), (rc->df_default+rc->df_bonus));
|
||||||
rsize = strlcpy(bufp, buf2, size);
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
if (rsize>size) rsize = size-1;
|
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
|
|
||||||
/* b_armor : Rüstung */
|
/* b_armor : Rüstung */
|
||||||
if (rc->armor > 0) {
|
if (rc->armor > 0) {
|
||||||
sprintf(buf2, ", %s: %d", LOC(f->locale, "stat_armor"), rc->armor);
|
bytes = snprintf(bufp, size, ", %s: %d", LOC(f->locale, "stat_armor"), rc->armor);
|
||||||
rsize = strlcpy(bufp, buf2, size);
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
if (rsize>size) rsize = size-1;
|
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size>1) {
|
if (size>1) {
|
||||||
strcpy(bufp++, ".");
|
*bufp++ ='.';
|
||||||
--size;
|
--size;
|
||||||
}
|
} else WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
/* b_damage : Schaden */
|
/* b_damage : Schaden */
|
||||||
at_count=0;
|
at_count=0;
|
||||||
|
@ -2132,72 +2114,61 @@ display_race(faction *f, unit *u, const race * rc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rc->battle_flags & BF_EQUIPMENT) {
|
if (rc->battle_flags & BF_EQUIPMENT) {
|
||||||
rsize = snprintf(bufp, size, " %s", LOC(f->locale, "stat_equipment"));
|
bytes = snprintf(bufp, size, " %s", LOC(f->locale, "stat_equipment"));
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
}
|
}
|
||||||
if (rc->battle_flags & BF_RES_PIERCE) {
|
if (rc->battle_flags & BF_RES_PIERCE) {
|
||||||
rsize = snprintf(bufp, size, " %s", LOC(f->locale, "stat_pierce"));
|
bytes = snprintf(bufp, size, " %s", LOC(f->locale, "stat_pierce"));
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
}
|
}
|
||||||
if (rc->battle_flags & BF_RES_CUT) {
|
if (rc->battle_flags & BF_RES_CUT) {
|
||||||
rsize = snprintf(bufp, size, " %s", LOC(f->locale, "stat_cut"));
|
bytes = snprintf(bufp, size, " %s", LOC(f->locale, "stat_cut"));
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
}
|
}
|
||||||
if (rc->battle_flags & BF_RES_BASH) {
|
if (rc->battle_flags & BF_RES_BASH) {
|
||||||
rsize = snprintf(bufp, size, " %s", LOC(f->locale, "stat_bash"));
|
bytes = snprintf(bufp, size, " %s", LOC(f->locale, "stat_bash"));
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(buf2, " %d %s", at_count, LOC(f->locale, (at_count==1)?"stat_attack":"stat_attacks"));
|
bytes = snprintf(bufp, size, " %d %s", at_count, LOC(f->locale, (at_count==1)?"stat_attack":"stat_attacks"));
|
||||||
rsize = strlcpy(bufp, buf2, size);
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
if (rsize>size) rsize = size-1;
|
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
|
|
||||||
for (a = 0; a < 6; a++) {
|
for (a = 0; a < 6; a++) {
|
||||||
if (rc->attack[a].type != AT_NONE){
|
if (rc->attack[a].type != AT_NONE){
|
||||||
if (size>2) {
|
if (a!=0) bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (a!=0) strcat(bufp, ", ");
|
else strlcpy(bufp, ": ", size);
|
||||||
else strcat(bufp, ": ");
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= 2;
|
|
||||||
bufp += 2;
|
|
||||||
}
|
|
||||||
switch(rc->attack[a].type) {
|
switch(rc->attack[a].type) {
|
||||||
case AT_STANDARD:
|
case AT_STANDARD:
|
||||||
sprintf(buf2, "%s (%s)", LOC(f->locale, "attack_standard"), rc->def_damage);
|
bytes = snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_standard"), rc->def_damage);
|
||||||
break;
|
break;
|
||||||
case AT_NATURAL:
|
case AT_NATURAL:
|
||||||
sprintf(buf2, "%s (%s)", LOC(f->locale, "attack_natural"), rc->attack[a].data.dice);
|
bytes = snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_natural"), rc->attack[a].data.dice);
|
||||||
break;
|
break;
|
||||||
case AT_SPELL:
|
case AT_SPELL:
|
||||||
case AT_COMBATSPELL:
|
case AT_COMBATSPELL:
|
||||||
case AT_DRAIN_ST:
|
case AT_DRAIN_ST:
|
||||||
case AT_DAZZLE:
|
case AT_DAZZLE:
|
||||||
sprintf(buf2, "%s", LOC(f->locale, "attack_natural"));
|
bytes = snprintf(bufp, size, "%s", LOC(f->locale, "attack_natural"));
|
||||||
break;
|
break;
|
||||||
case AT_STRUCTURAL:
|
case AT_STRUCTURAL:
|
||||||
sprintf(buf2, "%s (%s)", LOC(f->locale, "attack_structural"), rc->attack[a].data.dice);
|
bytes = snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_structural"), rc->attack[a].data.dice);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
bytes = 0;
|
||||||
}
|
}
|
||||||
rsize = strlcpy(bufp, buf2, size);
|
|
||||||
if (rsize>size) rsize = size-1;
|
if (bytes && wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size>1) {
|
if (size>1) {
|
||||||
strcat(bufp++, ".");
|
*bufp++ = '.';
|
||||||
--size;
|
--size;
|
||||||
}
|
} else WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
|
*bufp = 0;
|
||||||
addmessage(0, f, buf, MSG_EVENT, ML_IMPORTANT);
|
addmessage(0, f, buf, MSG_EVENT, ML_IMPORTANT);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -452,26 +452,32 @@ make_movement_order(unit * u, const region * target, int moves, boolean (*allowe
|
||||||
{
|
{
|
||||||
region * r = u->region;
|
region * r = u->region;
|
||||||
region ** plan;
|
region ** plan;
|
||||||
int position = 0;
|
int bytes, position = 0;
|
||||||
char zOrder[128];
|
char zOrder[128], * bufp = zOrder;
|
||||||
char * c = zOrder;
|
size_t size = sizeof(zOrder) - 1;
|
||||||
|
|
||||||
if (is_waiting(u)) return NULL;
|
if (is_waiting(u)) return NULL;
|
||||||
|
|
||||||
plan = path_find(r, target, DRAGON_RANGE*5, allowed);
|
plan = path_find(r, target, DRAGON_RANGE*5, allowed);
|
||||||
if (plan==NULL) return NULL;
|
if (plan==NULL) return NULL;
|
||||||
|
|
||||||
c += strlcpy(c, (const char *)LOC(u->faction->locale, keywords[K_MOVE]), sizeof(zOrder));
|
bytes = (int)strlcpy(bufp, (const char *)LOC(u->faction->locale, keywords[K_MOVE]), size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
while (position!=moves && plan[position+1]) {
|
while (position!=moves && plan[position+1]) {
|
||||||
region * prev = plan[position];
|
region * prev = plan[position];
|
||||||
region * next = plan[++position];
|
region * next = plan[++position];
|
||||||
direction_t dir = reldirection(prev, next);
|
direction_t dir = reldirection(prev, next);
|
||||||
assert(dir!=NODIRECTION && dir!=D_SPECIAL);
|
assert(dir!=NODIRECTION && dir!=D_SPECIAL);
|
||||||
*c++ = ' ';
|
if (size>1) {
|
||||||
c += strlcpy(c, (const char *)LOC(u->faction->locale, directions[dir]), sizeof(zOrder)-(c-(const char *)zOrder));
|
*bufp++ = ' ';
|
||||||
|
--size;
|
||||||
|
}
|
||||||
|
bytes = (int)strlcpy(bufp, (const char *)LOC(u->faction->locale, directions[dir]), size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*bufp = 0;
|
||||||
return parse_order(zOrder, u->faction->locale);
|
return parse_order(zOrder, u->faction->locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,9 +101,6 @@ extern int *storms;
|
||||||
extern int weeks_per_month;
|
extern int weeks_per_month;
|
||||||
extern int months_per_year;
|
extern int months_per_year;
|
||||||
|
|
||||||
#define WARN_STATIC_BUFFER() \
|
|
||||||
log_warning(("static buffer too small in %s:%d\n", __FILE__, __LINE__))
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
gamedate_season(const struct locale * lang)
|
gamedate_season(const struct locale * lang)
|
||||||
{
|
{
|
||||||
|
@ -231,18 +228,18 @@ report_spell(FILE * F, spell *sp, const struct locale * lang)
|
||||||
rparagraph(F, LOC(lang, "nr_spell_description"), 0, 0, 0);
|
rparagraph(F, LOC(lang, "nr_spell_description"), 0, 0, 0);
|
||||||
rparagraph(F, spell_info(sp, lang), 2, 0, 0);
|
rparagraph(F, spell_info(sp, lang), 2, 0, 0);
|
||||||
|
|
||||||
bytes = strlcpy(bufp, LOC(lang, "nr_spell_type"), size);
|
bytes = (int)strlcpy(bufp, LOC(lang, "nr_spell_type"), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
if (size) { *bufp++ = ' '; --size; }
|
if (size) { *bufp++ = ' '; --size; }
|
||||||
if (sp->sptyp & PRECOMBATSPELL) {
|
if (sp->sptyp & PRECOMBATSPELL) {
|
||||||
bytes = strlcpy(bufp, LOC(lang, "sptype_precombat"), size);
|
bytes = (int)strlcpy(bufp, LOC(lang, "sptype_precombat"), size);
|
||||||
} else if (sp->sptyp & COMBATSPELL) {
|
} else if (sp->sptyp & COMBATSPELL) {
|
||||||
bytes = strlcpy(bufp, LOC(lang, "sptype_combat"), size);
|
bytes = (int)strlcpy(bufp, LOC(lang, "sptype_combat"), size);
|
||||||
} else if (sp->sptyp & POSTCOMBATSPELL) {
|
} else if (sp->sptyp & POSTCOMBATSPELL) {
|
||||||
bytes = strlcpy(bufp, LOC(lang, "sptype_postcombat"), size);
|
bytes = (int)strlcpy(bufp, LOC(lang, "sptype_postcombat"), size);
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, LOC(lang, "sptype_normal"), size);
|
bytes = (int)strlcpy(bufp, LOC(lang, "sptype_normal"), size);
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
*bufp = 0;
|
*bufp = 0;
|
||||||
|
@ -283,44 +280,44 @@ report_spell(FILE * F, spell *sp, const struct locale * lang)
|
||||||
|
|
||||||
size = sizeof(buf) - 1;
|
size = sizeof(buf) - 1;
|
||||||
bufp = buf;
|
bufp = buf;
|
||||||
bytes = strlcpy(buf, LOC(lang, "nr_spell_modifiers"), size);
|
bytes = (int)strlcpy(buf, LOC(lang, "nr_spell_modifiers"), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
if (sp->sptyp & FARCASTING) {
|
if (sp->sptyp & FARCASTING) {
|
||||||
bytes = strlcpy(bufp, " Fernzauber", size);
|
bytes = (int)strlcpy(bufp, " Fernzauber", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
dh = 1;
|
dh = 1;
|
||||||
}
|
}
|
||||||
if (sp->sptyp & OCEANCASTABLE) {
|
if (sp->sptyp & OCEANCASTABLE) {
|
||||||
if (dh == 1) {
|
if (dh == 1) {
|
||||||
bytes = strlcpy(bufp, ",", size);
|
bytes = (int)strlcpy(bufp, ",", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
bytes = strlcpy(bufp, " Seezauber", size);
|
bytes = (int)strlcpy(bufp, " Seezauber", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
dh = 1;
|
dh = 1;
|
||||||
}
|
}
|
||||||
if (sp->sptyp & ONSHIPCAST) {
|
if (sp->sptyp & ONSHIPCAST) {
|
||||||
if (dh == 1){
|
if (dh == 1){
|
||||||
bytes = strlcpy(bufp, ",", size);
|
bytes = (int)strlcpy(bufp, ",", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
bytes = strlcpy(bufp, " Schiffszauber", size);
|
bytes = (int)strlcpy(bufp, " Schiffszauber", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
dh = 1;
|
dh = 1;
|
||||||
}
|
}
|
||||||
if (sp->sptyp & NOTFAMILIARCAST) {
|
if (sp->sptyp & NOTFAMILIARCAST) {
|
||||||
if (dh == 1) {
|
if (dh == 1) {
|
||||||
bytes = strlcpy(bufp, ", k", size);
|
bytes = (int)strlcpy(bufp, ", k", size);
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, " K", size);
|
bytes = (int)strlcpy(bufp, " K", size);
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, "ann nicht vom Vertrauten gezaubert werden", size);
|
bytes = (int)strlcpy(bufp, "ann nicht vom Vertrauten gezaubert werden", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
dh = 1;
|
dh = 1;
|
||||||
}
|
}
|
||||||
if (dh == 0) {
|
if (dh == 0) {
|
||||||
bytes = strlcpy(bufp, " Keine", size);
|
bytes = (int)strlcpy(bufp, " Keine", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
*bufp = 0;
|
*bufp = 0;
|
||||||
|
@ -331,9 +328,9 @@ report_spell(FILE * F, spell *sp, const struct locale * lang)
|
||||||
bufp = buf;
|
bufp = buf;
|
||||||
size = sizeof(buf) - 1;
|
size = sizeof(buf) - 1;
|
||||||
if (sp->sptyp & ISCOMBATSPELL) {
|
if (sp->sptyp & ISCOMBATSPELL) {
|
||||||
bytes = strlcpy(buf, LOC(lang, keywords[K_COMBAT]), size);
|
bytes = (int)strlcpy(buf, LOC(lang, keywords[K_COMBAT]), size);
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(buf, LOC(lang, keywords[K_CAST]), size);
|
bytes = (int)strlcpy(buf, LOC(lang, keywords[K_CAST]), size);
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
|
@ -347,33 +344,33 @@ report_spell(FILE * F, spell *sp, const struct locale * lang)
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
bytes = strlcpy(bufp, " \"", size);
|
bytes = (int)strlcpy(bufp, " \"", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
bytes = strlcpy(bufp, spell_name(sp, lang), size);
|
bytes = (int)strlcpy(bufp, spell_name(sp, lang), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
bytes = strlcpy(bufp, "\" ", size);
|
bytes = (int)strlcpy(bufp, "\" ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
if (sp->sptyp & ONETARGET){
|
if (sp->sptyp & ONETARGET){
|
||||||
if (sp->sptyp & UNITSPELL) {
|
if (sp->sptyp & UNITSPELL) {
|
||||||
bytes = strlcpy(bufp, "<Einheit-Nr>", size);
|
bytes = (int)strlcpy(bufp, "<Einheit-Nr>", size);
|
||||||
} else if (sp->sptyp & SHIPSPELL) {
|
} else if (sp->sptyp & SHIPSPELL) {
|
||||||
bytes = strlcpy(bufp, "<Schiff-Nr>", size);
|
bytes = (int)strlcpy(bufp, "<Schiff-Nr>", size);
|
||||||
} else if (sp->sptyp & BUILDINGSPELL) {
|
} else if (sp->sptyp & BUILDINGSPELL) {
|
||||||
bytes = strlcpy(bufp, "<Gebaeude-Nr>", size);
|
bytes = (int)strlcpy(bufp, "<Gebaeude-Nr>", size);
|
||||||
} else {
|
} else {
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
} else {
|
} else {
|
||||||
if (sp->sptyp & UNITSPELL) {
|
if (sp->sptyp & UNITSPELL) {
|
||||||
bytes = strlcpy(bufp, "<Einheit-Nr> [<Einheit-Nr> ...]", size);
|
bytes = (int)strlcpy(bufp, "<Einheit-Nr> [<Einheit-Nr> ...]", size);
|
||||||
} else if (sp->sptyp & SHIPSPELL) {
|
} else if (sp->sptyp & SHIPSPELL) {
|
||||||
bytes = strlcpy(bufp, "<Schiff-Nr> [<Schiff-Nr> ...]", size);
|
bytes = (int)strlcpy(bufp, "<Schiff-Nr> [<Schiff-Nr> ...]", size);
|
||||||
} else if (sp->sptyp & BUILDINGSPELL) {
|
} else if (sp->sptyp & BUILDINGSPELL) {
|
||||||
bytes = strlcpy(bufp, "<Gebaeude-Nr> [<Gebaeude-Nr> ...]", size);
|
bytes = (int)strlcpy(bufp, "<Gebaeude-Nr> [<Gebaeude-Nr> ...]", size);
|
||||||
} else {
|
} else {
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
}
|
}
|
||||||
|
@ -685,40 +682,40 @@ prices(FILE * F, const region * r, const faction * f)
|
||||||
m = msg_message("nr_market_sale", "product price",
|
m = msg_message("nr_market_sale", "product price",
|
||||||
sale->itype->rtype, sale->price);
|
sale->itype->rtype, sale->price);
|
||||||
|
|
||||||
bytes = nr_render(m, f->locale, bufp, size, f);
|
bytes = (int)nr_render(m, f->locale, bufp, size, f);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
msg_release(m);
|
msg_release(m);
|
||||||
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
bytes = strlcpy(bufp, " ", size);
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, "nr_trade_intro"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_intro"), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, " ", size);
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
for (dmd=r->land->demands;dmd;dmd=dmd->next) if(dmd->value > 0) {
|
for (dmd=r->land->demands;dmd;dmd=dmd->next) if(dmd->value > 0) {
|
||||||
m = msg_message("nr_market_price", "product price",
|
m = msg_message("nr_market_price", "product price",
|
||||||
dmd->type->itype->rtype, dmd->value * dmd->type->price);
|
dmd->type->itype->rtype, dmd->value * dmd->type->price);
|
||||||
bytes = nr_render(m, f->locale, bufp, size, f);
|
bytes = (int)nr_render(m, f->locale, bufp, size, f);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
msg_release(m);
|
msg_release(m);
|
||||||
n--;
|
n--;
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, "nr_trade_end"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_end"), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
else if (n == 1) {
|
else if (n == 1) {
|
||||||
bytes = strlcpy(bufp, " ", size);
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, "nr_trade_final"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_final"), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, " ", size);
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, "nr_trade_next"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_next"), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, " ", size);
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -803,28 +800,28 @@ describe(FILE * F, const region * r, int partial, faction * f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes = f_regionid(r, f, bufp, size);
|
bytes = (int)f_regionid(r, f, bufp, size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
if (partial == 1) {
|
if (partial == 1) {
|
||||||
bytes = strlcpy(bufp, " (durchgereist)", size);
|
bytes = (int)strlcpy(bufp, " (durchgereist)", size);
|
||||||
}
|
}
|
||||||
else if (partial == 3) {
|
else if (partial == 3) {
|
||||||
bytes = strlcpy(bufp, " (benachbart)", size);
|
bytes = (int)strlcpy(bufp, " (benachbart)", size);
|
||||||
}
|
}
|
||||||
else if (partial == 2) {
|
else if (partial == 2) {
|
||||||
bytes = strlcpy(bufp, " (vom Turm erblickt)", size);
|
bytes = (int)strlcpy(bufp, " (vom Turm erblickt)", size);
|
||||||
} else {
|
} else {
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
/* Terrain */
|
/* Terrain */
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
tname = terrain_name(r);
|
tname = terrain_name(r);
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, tname), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, tname), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
/* Trees */
|
/* Trees */
|
||||||
|
@ -837,15 +834,15 @@ describe(FILE * F, const region * r, int partial, faction * f)
|
||||||
|
|
||||||
if (fval(r, RF_MALLORN)) {
|
if (fval(r, RF_MALLORN)) {
|
||||||
if (trees == 1) {
|
if (trees == 1) {
|
||||||
bytes= strlcpy(bufp, LOC(f->locale, "nr_mallorntree"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_mallorntree"), size);
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, "nr_mallorntree_p"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_mallorntree_p"), size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (trees == 1) {
|
else if (trees == 1) {
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, "nr_tree"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_tree"), size);
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, "nr_tree_p"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_tree_p"), size);
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
|
@ -893,21 +890,21 @@ describe(FILE * F, const region * r, int partial, faction * f)
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
if (fval(r, RF_ORCIFIED)) {
|
if (fval(r, RF_ORCIFIED)) {
|
||||||
bytes = strlcpy(bufp, " ", size);
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, n==1?"rc_orc":"rc_orc_p"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, n==1?"rc_orc":"rc_orc_p"), size);
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, " ", size);
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, n==1?"peasant":"peasant_p"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, n==1?"peasant":"peasant_p"), size);
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
if (rmoney(r) && partial == 0) {
|
if (rmoney(r) && partial == 0) {
|
||||||
bytes = snprintf(bufp, size, ", %d ", rmoney(r));
|
bytes = snprintf(bufp, size, ", %d ", rmoney(r));
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, resourcename(oldresourcetype[R_SILVER], rmoney(r)!=1)), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, resourcename(oldresourcetype[R_SILVER], rmoney(r)!=1)), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
/* Pferde */
|
/* Pferde */
|
||||||
|
@ -915,22 +912,22 @@ describe(FILE * F, const region * r, int partial, faction * f)
|
||||||
if (rhorses(r)) {
|
if (rhorses(r)) {
|
||||||
bytes = snprintf(bufp, size, ", %d ", rhorses(r));
|
bytes = snprintf(bufp, size, ", %d ", rhorses(r));
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, resourcename(oldresourcetype[R_HORSE], (rhorses(r)>1)?GR_PLURAL:0)), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, resourcename(oldresourcetype[R_HORSE], (rhorses(r)>1)?GR_PLURAL:0)), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
bytes = strlcpy(bufp, ".", size);
|
bytes = (int)strlcpy(bufp, ".", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
|
|
||||||
if (r->display && r->display[0]) {
|
if (r->display && r->display[0]) {
|
||||||
bytes = strlcpy(bufp, " ", size);
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, r->display, size);
|
bytes = (int)strlcpy(bufp, r->display, size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
n = r->display[strlen(r->display) - 1];
|
n = r->display[strlen(r->display) - 1];
|
||||||
if (n != '!' && n != '?' && n != '.') {
|
if (n != '!' && n != '?' && n != '.') {
|
||||||
bytes = strlcpy(bufp, ".", size);
|
bytes = (int)strlcpy(bufp, ".", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -946,9 +943,9 @@ describe(FILE * F, const region * r, int partial, faction * f)
|
||||||
|
|
||||||
a = a_find(r->attribs, &at_overrideroads);
|
a = a_find(r->attribs, &at_overrideroads);
|
||||||
if (a) {
|
if (a) {
|
||||||
bytes = strlcpy(bufp, " ", size);
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, (char *)a->data.v, size);
|
bytes = (int)strlcpy(bufp, (char *)a->data.v, size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
} else {
|
} else {
|
||||||
int nrd = 0;
|
int nrd = 0;
|
||||||
|
@ -967,23 +964,23 @@ describe(FILE * F, const region * r, int partial, faction * f)
|
||||||
if (dh) {
|
if (dh) {
|
||||||
char regname[4096];
|
char regname[4096];
|
||||||
if (nrd == 0) {
|
if (nrd == 0) {
|
||||||
bytes = strlcpy(bufp, " ", size);
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, "nr_nb_final"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_nb_final"), size);
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, "nr_nb_next"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_nb_next"), size);
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, directions[d]), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, directions[d]), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp++, " ", size);
|
bytes = (int)strlcpy(bufp++, " ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
f_regionid(r2, f, regname, sizeof(regname));
|
f_regionid(r2, f, regname, sizeof(regname));
|
||||||
bytes = snprintf(bufp, size, trailinto(r2, f->locale), regname);
|
bytes = snprintf(bufp, size, trailinto(r2, f->locale), regname);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bytes = strlcpy(bufp, " ", size);
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
MSG(("nr_vicinitystart", "dir region", d, r2), bufp, size, f->locale, f);
|
MSG(("nr_vicinitystart", "dir region", d, r2), bufp, size, f->locale, f);
|
||||||
bufp += strlen(bufp);
|
bufp += strlen(bufp);
|
||||||
|
@ -993,17 +990,17 @@ describe(FILE * F, const region * r, int partial, faction * f)
|
||||||
/* Spezielle Richtungen */
|
/* Spezielle Richtungen */
|
||||||
for (a = a_find(r->attribs, &at_direction);a && a->type==&at_direction;a=a->next) {
|
for (a = a_find(r->attribs, &at_direction);a && a->type==&at_direction;a=a->next) {
|
||||||
spec_direction * d = (spec_direction *)(a->data.v);
|
spec_direction * d = (spec_direction *)(a->data.v);
|
||||||
bytes = strlcpy(bufp, " ", size);
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, d->desc), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, d->desc), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, " (\"", size);
|
bytes = (int)strlcpy(bufp, " (\"", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, d->keyword), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, d->keyword), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, "\")", size);
|
bytes = (int)strlcpy(bufp, "\")", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, ".", size);
|
bytes = (int)strlcpy(bufp, ".", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
dh = 1;
|
dh = 1;
|
||||||
}
|
}
|
||||||
|
@ -1021,19 +1018,19 @@ describe(FILE * F, const region * r, int partial, faction * f)
|
||||||
if (rl) {
|
if (rl) {
|
||||||
bufp = buf;
|
bufp = buf;
|
||||||
size = sizeof(buf) - 1;
|
size = sizeof(buf) - 1;
|
||||||
bytes = strlcpy(bufp, "Schemen der Regionen ", size);
|
bytes = (int)strlcpy(bufp, "Schemen der Regionen ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
rl2 = rl;
|
rl2 = rl;
|
||||||
while (rl2) {
|
while (rl2) {
|
||||||
bytes = f_regionid(rl2->data, f, bufp, size);
|
bytes = (int)f_regionid(rl2->data, f, bufp, size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
rl2 = rl2->next;
|
rl2 = rl2->next;
|
||||||
if (rl2) {
|
if (rl2) {
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strlcpy(bufp, " sind erkennbar.", size);
|
bytes = (int)strlcpy(bufp, " sind erkennbar.", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
free_regionlist(rl);
|
free_regionlist(rl);
|
||||||
/* Schreibe Paragraphen */
|
/* Schreibe Paragraphen */
|
||||||
|
@ -1062,21 +1059,21 @@ describe(FILE * F, const region * r, int partial, faction * f)
|
||||||
size = sizeof(buf) - 1;
|
size = sizeof(buf) - 1;
|
||||||
for (d=0;d!=MAXDIRECTIONS;++d) {
|
for (d=0;d!=MAXDIRECTIONS;++d) {
|
||||||
if (!e->exist[d]) continue;
|
if (!e->exist[d]) continue;
|
||||||
if (first) bytes = strlcpy(bufp, "Im ", size);
|
if (first) bytes = (int)strlcpy(bufp, "Im ", size);
|
||||||
else if (e->lastd==d) bytes = strlcpy(bufp, " und im ", size);
|
else if (e->lastd==d) bytes = (int)strlcpy(bufp, " und im ", size);
|
||||||
else bytes= strlcpy(bufp, ", im ", size );
|
else bytes = (int)strlcpy(bufp, ", im ", size );
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, directions[d]), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, directions[d]), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
if (!e->transparent) bytes = strlcpy(bufp, " versperrt ", size);
|
if (!e->transparent) bytes = (int)strlcpy(bufp, " versperrt ", size);
|
||||||
else bytes = strlcpy(bufp, " befindet sich ", size);
|
else bytes = (int)strlcpy(bufp, " befindet sich ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, e->name, size);
|
bytes = (int)strlcpy(bufp, e->name, size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
if (!e->transparent) bytes = strlcpy(bufp, " die Sicht.", size);
|
if (!e->transparent) bytes = (int)strlcpy(bufp, " die Sicht.", size);
|
||||||
else bytes = strlcpy(bufp, ".", size);
|
else bytes = (int)strlcpy(bufp, ".", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
*bufp = 0;
|
*bufp = 0;
|
||||||
rparagraph(F, buf, 0, 0, 0);
|
rparagraph(F, buf, 0, 0, 0);
|
||||||
|
@ -1202,31 +1199,31 @@ durchreisende(FILE * F, const region * r, const faction * f)
|
||||||
++counter;
|
++counter;
|
||||||
if (u->ship != NULL) {
|
if (u->ship != NULL) {
|
||||||
if (counter == 1) {
|
if (counter == 1) {
|
||||||
bytes = strlcpy(bufp, "Die ", size);
|
bytes = (int)strlcpy(bufp, "Die ", size);
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, "die ", size);
|
bytes = (int)strlcpy(bufp, "die ", size);
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, shipname(u->ship), size);
|
bytes = (int)strlcpy(bufp, shipname(u->ship), size);
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, unitname(u), size);
|
bytes = (int)strlcpy(bufp, unitname(u), size);
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
if (counter + 1 < maxtravel) {
|
if (counter + 1 < maxtravel) {
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
} else if (counter + 1 == maxtravel) {
|
} else if (counter + 1 == maxtravel) {
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, "list_and"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "list_and"), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (maxtravel == 1) {
|
if (maxtravel == 1) {
|
||||||
bytes = strlcpy(bufp, " hat die Region durchquert.", size);
|
bytes = (int)strlcpy(bufp, " hat die Region durchquert.", size);
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, " haben die Region durchquert.", size);
|
bytes = (int)strlcpy(bufp, " haben die Region durchquert.", size);
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
*bufp = 0;
|
*bufp = 0;
|
||||||
|
@ -1348,26 +1345,26 @@ report_template(const char * filename, report_context * ctx, const char * charse
|
||||||
int cost = buildingmaintenance(b, r_silver);
|
int cost = buildingmaintenance(b, r_silver);
|
||||||
|
|
||||||
if (cost > 0) {
|
if (cost > 0) {
|
||||||
bytes = strlcpy(bufp, ",U", size);
|
bytes = (int)strlcpy(bufp, ",U", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, itoa10(cost), size);
|
bytes = (int)strlcpy(bufp, itoa10(cost), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
} else if (u->ship) {
|
} else if (u->ship) {
|
||||||
if (fval(u, UFL_OWNER)) {
|
if (fval(u, UFL_OWNER)) {
|
||||||
bytes = strlcpy(bufp, ",S", size);
|
bytes = (int)strlcpy(bufp, ",S", size);
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, ",s", size);
|
bytes = (int)strlcpy(bufp, ",s", size);
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, shipid(u->ship), size);
|
bytes = (int)strlcpy(bufp, shipid(u->ship), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
if (lifestyle(u) == 0) {
|
if (lifestyle(u) == 0) {
|
||||||
bytes = strlcpy(bufp, ",I", size);
|
bytes = (int)strlcpy(bufp, ",I", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
bytes = strlcpy(bufp, "]", size);
|
bytes = (int)strlcpy(bufp, "]", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
*bufp = 0;
|
*bufp = 0;
|
||||||
|
@ -1420,9 +1417,11 @@ show_allies(FILE * F, const faction * f, const ally * allies, char * buf, size_t
|
||||||
{
|
{
|
||||||
int allierte = 0;
|
int allierte = 0;
|
||||||
int i=0, h, hh = 0;
|
int i=0, h, hh = 0;
|
||||||
int dh = 0;
|
int bytes, dh = 0;
|
||||||
const ally * sf;
|
const ally * sf;
|
||||||
char * bufp = buf + strlen(buf); /* buf already contains data */
|
char * bufp = buf; /* buf already contains data */
|
||||||
|
|
||||||
|
--size; /* leave room for a null-terminator */
|
||||||
|
|
||||||
for (sf = allies; sf; sf = sf->next) {
|
for (sf = allies; sf; sf = sf->next) {
|
||||||
int mode = alliedgroup(NULL, f, sf->faction, sf, HELP_ALL);
|
int mode = alliedgroup(NULL, f, sf->faction, sf, HELP_ALL);
|
||||||
|
@ -1434,17 +1433,22 @@ show_allies(FILE * F, const faction * f, const ally * allies, char * buf, size_t
|
||||||
if (mode <= 0) continue;
|
if (mode <= 0) continue;
|
||||||
i++;
|
i++;
|
||||||
if (dh) {
|
if (dh) {
|
||||||
if (i == allierte)
|
if (i == allierte) {
|
||||||
bufp += strlcpy(bufp, LOC(f->locale, "list_and"), size-(bufp-buf));
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "list_and"), size);
|
||||||
else
|
} else {
|
||||||
bufp += strlcpy(bufp, ", ", size-(bufp-buf));
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
|
}
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
dh = 1;
|
dh = 1;
|
||||||
hh = 0;
|
hh = 0;
|
||||||
bufp += strlcpy(bufp, factionname(sf->faction), size-(bufp-buf));
|
bytes = (int)strlcpy(bufp, factionname(sf->faction), size);
|
||||||
bufp += strlcpy(bufp, " (", size-(bufp-buf));
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
bytes = (int)strlcpy(bufp, " (", size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
if ((mode & HELP_ALL) == HELP_ALL) {
|
if ((mode & HELP_ALL) == HELP_ALL) {
|
||||||
bufp += strlcpy(bufp, "Alles", size-(bufp-buf));
|
bytes = (int)strlcpy(bufp, "Alles", size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
} else {
|
} else {
|
||||||
for (h = 1; h < HELP_ALL; h *= 2) {
|
for (h = 1; h < HELP_ALL; h *= 2) {
|
||||||
int p = MAXPARAMS;
|
int p = MAXPARAMS;
|
||||||
|
@ -1471,15 +1475,22 @@ show_allies(FILE * F, const faction * f, const ally * allies, char * buf, size_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p!=MAXPARAMS) {
|
if (p!=MAXPARAMS) {
|
||||||
if (hh) bufp += strlcpy(bufp, ", ", size-(bufp-buf));
|
if (hh) {
|
||||||
bufp += strlcpy(bufp, parameters[p], size-(bufp-buf));
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
}
|
||||||
|
bytes = (int)strlcpy(bufp, parameters[p], size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
hh = 1;
|
hh = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bufp += strlcpy(bufp, ")", size-(bufp-buf));
|
bytes = (int)strlcpy(bufp, ")", size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
bufp += strlcpy(bufp, ".", size-(bufp-buf));
|
bytes = (int)strlcpy(bufp, ".", size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
*bufp = 0;
|
||||||
rparagraph(F, buf, 0, 0, 0);
|
rparagraph(F, buf, 0, 0, 0);
|
||||||
rnl(F);
|
rnl(F);
|
||||||
}
|
}
|
||||||
|
@ -1491,22 +1502,28 @@ allies(FILE * F, const faction * f)
|
||||||
char buf[16384];
|
char buf[16384];
|
||||||
|
|
||||||
if (f->allies) {
|
if (f->allies) {
|
||||||
|
int bytes;
|
||||||
|
size_t size = sizeof(buf);
|
||||||
if (!f->allies->next) {
|
if (!f->allies->next) {
|
||||||
strcpy(buf, "Wir helfen der Partei ");
|
bytes = (int)strlcpy(buf, "Wir helfen der Partei ", size);
|
||||||
} else {
|
} else {
|
||||||
strcpy(buf, "Wir helfen den Parteien ");
|
bytes = (int)strlcpy(buf, "Wir helfen den Parteien ", size);
|
||||||
}
|
}
|
||||||
show_allies(F, f, f->allies, buf, sizeof(buf));
|
size -= bytes;
|
||||||
|
show_allies(F, f, f->allies, buf + bytes, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (g) {
|
while (g) {
|
||||||
if (g->allies) {
|
if (g->allies) {
|
||||||
|
int bytes;
|
||||||
|
size_t size = sizeof(buf);
|
||||||
if (!g->allies->next) {
|
if (!g->allies->next) {
|
||||||
sprintf(buf, "%s hilft der Partei ", g->name);
|
bytes = snprintf(buf, size, "%s hilft der Partei ", g->name);
|
||||||
} else {
|
} else {
|
||||||
sprintf(buf, "%s hilft den Parteien ", g->name);
|
bytes = snprintf(buf, size, "%s hilft den Parteien ", g->name);
|
||||||
}
|
}
|
||||||
show_allies(F, f, g->allies, buf, sizeof(buf));
|
size -= bytes;
|
||||||
|
show_allies(F, f, g->allies, buf + bytes, size);
|
||||||
}
|
}
|
||||||
g = g->next;
|
g = g->next;
|
||||||
}
|
}
|
||||||
|
@ -1576,26 +1593,26 @@ guards(FILE * F, const region * r, const faction * see)
|
||||||
size_t size = sizeof(buf) - 1;
|
size_t size = sizeof(buf) - 1;
|
||||||
int bytes;
|
int bytes;
|
||||||
|
|
||||||
bytes = strlcpy(bufp, "Die Region wird von ", size);
|
bytes = (int)strlcpy(bufp, "Die Region wird von ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
for (i = 0; i!=nextguard+(tarned?1:0); ++i) {
|
for (i = 0; i!=nextguard+(tarned?1:0); ++i) {
|
||||||
if (i!=0) {
|
if (i!=0) {
|
||||||
if (i == nextguard-(tarned?0:1)) {
|
if (i == nextguard-(tarned?0:1)) {
|
||||||
bytes = strlcpy(bufp, LOC(see->locale, "list_and"), size);
|
bytes = (int)strlcpy(bufp, LOC(see->locale, "list_and"), size);
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
if (i<nextguard) {
|
if (i<nextguard) {
|
||||||
bytes = strlcpy(bufp, factionname(guardians[i]), size);
|
bytes = (int)strlcpy(bufp, factionname(guardians[i]), size);
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, "unbekannten Einheiten", size);
|
bytes = (int)strlcpy(bufp, "unbekannten Einheiten", size);
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
bytes = strlcpy(bufp, " bewacht.", size);
|
bytes = (int)strlcpy(bufp, " bewacht.", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
rnl(F);
|
rnl(F);
|
||||||
*bufp = 0;
|
*bufp = 0;
|
||||||
|
@ -1674,7 +1691,7 @@ report_building(FILE *F, const region * r, const building * b, const faction * f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bname = LOC(lang, buildingtype(type, b, b->size));
|
bname = LOC(lang, buildingtype(type, b, b->size));
|
||||||
bytes = strlcpy(bufp, bname, size);
|
bytes = (int)strlcpy(bufp, bname, size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
if (type!=b->type) {
|
if (type!=b->type) {
|
||||||
unit * owner = buildingowner(r, b);
|
unit * owner = buildingowner(r, b);
|
||||||
|
@ -1687,27 +1704,27 @@ report_building(FILE *F, const region * r, const building * b, const faction * f
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b->size < type->maxsize) {
|
if (b->size < type->maxsize) {
|
||||||
bytes = strlcpy(bufp, " (im Bau)", size);
|
bytes = (int)strlcpy(bufp, " (im Bau)", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b->besieged > 0 && mode>=see_lighthouse) {
|
if (b->besieged > 0 && mode>=see_lighthouse) {
|
||||||
bytes = strlcpy(bufp, ", belagert von ", size);
|
bytes = (int)strlcpy(bufp, ", belagert von ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, itoa10(b->besieged), size);
|
bytes = (int)strlcpy(bufp, itoa10(b->besieged), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, " Personen ", size);
|
bytes = (int)strlcpy(bufp, " Personen ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
if (b->besieged >= b->size * SIEGEFACTOR) {
|
if (b->besieged >= b->size * SIEGEFACTOR) {
|
||||||
bytes = strlcpy(bufp, "(abgeschnitten)", size);
|
bytes = (int)strlcpy(bufp, "(abgeschnitten)", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i = 0;
|
i = 0;
|
||||||
if (b->display && b->display[0]) {
|
if (b->display && b->display[0]) {
|
||||||
bytes = strlcpy(bufp, "; ", size);
|
bytes = (int)strlcpy(bufp, "; ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, b->display, size);
|
bytes = (int)strlcpy(bufp, b->display, size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
i = b->display[strlen(b->display) - 1];
|
i = b->display[strlen(b->display) - 1];
|
||||||
}
|
}
|
||||||
|
@ -1765,7 +1782,7 @@ report_building(FILE *F, const region * r, const building * b, const faction * f
|
||||||
#else
|
#else
|
||||||
|
|
||||||
if (i != '!' && i != '?' && i != '.') {
|
if (i != '!' && i != '?' && i != '.') {
|
||||||
bytes = strlcpy(bufp, ".", size);
|
bytes = (int)strlcpy(bufp, ".", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1953,9 +1970,9 @@ report_plaintext(const char * filename, report_context * ctx, const char * chars
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
for (op = 0; op != MAXOPTIONS; op++) {
|
for (op = 0; op != MAXOPTIONS; op++) {
|
||||||
if (f->options & want(op)) {
|
if (f->options & want(op)) {
|
||||||
bytes = strlcpy(bufp, " ", size);
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, options[op]), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, options[op]), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
#ifdef AT_OPTION
|
#ifdef AT_OPTION
|
||||||
if(op == O_NEWS) {
|
if(op == O_NEWS) {
|
||||||
|
@ -1966,20 +1983,20 @@ report_plaintext(const char * filename, report_context * ctx, const char * chars
|
||||||
} else {
|
} else {
|
||||||
int sec = a->data.i;
|
int sec = a->data.i;
|
||||||
int i;
|
int i;
|
||||||
bytes = strlcpy(bufp, "(", size);
|
bytes = (int)strlcpy(bufp, "(", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
for (i=1; sec != 0; i *= 2) {
|
for (i=1; sec != 0; i *= 2) {
|
||||||
if(sec & i) {
|
if(sec & i) {
|
||||||
bytes = strlcpy(bufp, itoa10(i), size);
|
bytes = (int)strlcpy(bufp, itoa10(i), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
sec = sec & ~i;
|
sec = sec & ~i;
|
||||||
if (sec) {
|
if (sec) {
|
||||||
bytes = strlcpy(bufp, ",", size);
|
bytes = (int)strlcpy(bufp, ",", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bytes = strlcpy(bufp, ")", size);
|
bytes = (int)strlcpy(bufp, ")", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2032,11 +2049,11 @@ report_plaintext(const char * filename, report_context * ctx, const char * chars
|
||||||
bytes = snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_herbsrequired"));
|
bytes = snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_herbsrequired"));
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
while (m->number) {
|
while (m->number) {
|
||||||
bytes = strlcpy(bufp, resourcename(m->rtype, 0), size);
|
bytes = (int)strlcpy(bufp, resourcename(m->rtype, 0), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
++m;
|
++m;
|
||||||
if (m->number)
|
if (m->number)
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
*bufp = 0;
|
*bufp = 0;
|
||||||
|
@ -2175,22 +2192,22 @@ report_plaintext(const char * filename, report_context * ctx, const char * chars
|
||||||
}
|
}
|
||||||
if (!fval(r->terrain, SEA_REGION)) {
|
if (!fval(r->terrain, SEA_REGION)) {
|
||||||
if (sh->coast != NODIRECTION) {
|
if (sh->coast != NODIRECTION) {
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, coasts[sh->coast]), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, coasts[sh->coast]), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ch = 0;
|
ch = 0;
|
||||||
if (sh->display && sh->display[0]) {
|
if (sh->display && sh->display[0]) {
|
||||||
bytes = strlcpy(bufp, "; ", size);
|
bytes = (int)strlcpy(bufp, "; ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, sh->display, size);
|
bytes = (int)strlcpy(bufp, sh->display, size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
ch = sh->display[strlen(sh->display) - 1];
|
ch = sh->display[strlen(sh->display) - 1];
|
||||||
}
|
}
|
||||||
if (ch != '!' && ch != '?' && ch != '.') {
|
if (ch != '!' && ch != '?' && ch != '.') {
|
||||||
bytes = strlcpy(bufp, ".", size);
|
bytes = (int)strlcpy(bufp, ".", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
*bufp = 0;
|
*bufp = 0;
|
||||||
|
|
|
@ -2638,14 +2638,18 @@ print_header(battle * b)
|
||||||
boolean first = false;
|
boolean first = false;
|
||||||
side * s;
|
side * s;
|
||||||
char * bufp = zText;
|
char * bufp = zText;
|
||||||
|
size_t size = sizeof(zText) - 1;
|
||||||
|
int bytes;
|
||||||
|
|
||||||
for (s=b->sides; s; s=s->next) {
|
for (s=b->sides; s; s=s->next) {
|
||||||
fighter *df;
|
fighter *df;
|
||||||
for (df=s->fighters;df;df=df->next) {
|
for (df=s->fighters;df;df=df->next) {
|
||||||
if (is_attacker(df)) {
|
if (is_attacker(df)) {
|
||||||
if (first) bufp += strlcpy(bufp, ", ", sizeof(zText) - (bufp-zText));
|
if (first) bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
if (lastf) {
|
if (lastf) {
|
||||||
bufp += strlcpy(bufp, (const char *)lastf, sizeof(zText) - (bufp-zText));
|
bytes = (int)strlcpy(bufp, (const char *)lastf, size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
first = true;
|
first = true;
|
||||||
}
|
}
|
||||||
if (seematrix(f, s) == true)
|
if (seematrix(f, s) == true)
|
||||||
|
@ -2657,11 +2661,17 @@ print_header(battle * b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (first) {
|
if (first) {
|
||||||
bufp += strlcpy(bufp, " ", sizeof(zText) - (bufp-zText));
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
bufp += strlcpy(bufp, (const char *)LOC(f->locale, "and"), sizeof(zText) - (bufp-zText));
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bufp += strlcpy(bufp, " ", sizeof(zText) - (bufp-zText));
|
bytes = (int)strlcpy(bufp, (const char *)LOC(f->locale, "and"), size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
}
|
||||||
|
if (lastf) {
|
||||||
|
bytes = (int)strlcpy(bufp, (const char *)lastf, size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
if (lastf) bufp += strlcpy(bufp, (const char *)lastf, sizeof(zText) - (bufp-zText));
|
|
||||||
|
|
||||||
m = msg_message("battle::starters", "factions", zText);
|
m = msg_message("battle::starters", "factions", zText);
|
||||||
message_faction(b, f, m);
|
message_faction(b, f, m);
|
||||||
|
@ -3310,7 +3320,8 @@ battle_report(battle * b)
|
||||||
faction * fac = bf->faction;
|
faction * fac = bf->faction;
|
||||||
char buf[32*MAXSIDES];
|
char buf[32*MAXSIDES];
|
||||||
char * bufp = buf;
|
char * bufp = buf;
|
||||||
size_t size = sizeof(buf), rsize;
|
int bytes;
|
||||||
|
size_t size = sizeof(buf) - 1;
|
||||||
message * m;
|
message * m;
|
||||||
|
|
||||||
message_faction(b, fac, msg_separator);
|
message_faction(b, fac, msg_separator);
|
||||||
|
@ -3330,40 +3341,30 @@ battle_report(battle * b)
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
|
|
||||||
if (komma) {
|
if (komma) {
|
||||||
rsize = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
}
|
}
|
||||||
snprintf(buffer, sizeof(buffer), "%s %2d(%s): ",
|
snprintf(buffer, sizeof(buffer), "%s %2d(%s): ",
|
||||||
loc_army, army_index(s), abbrev);
|
loc_army, army_index(s), abbrev);
|
||||||
buffer[sizeof(buffer)-1] = 0;
|
buffer[sizeof(buffer)-1] = 0;
|
||||||
|
|
||||||
rsize = strlcpy(bufp, buffer, size);
|
bytes = (int)strlcpy(bufp, buffer, size);
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
|
|
||||||
for (r=FIGHT_ROW;r!=NUMROWS;++r) {
|
for (r=FIGHT_ROW;r!=NUMROWS;++r) {
|
||||||
if (alive[r]) {
|
if (alive[r]) {
|
||||||
if (l!=FIGHT_ROW) {
|
if (l!=FIGHT_ROW) {
|
||||||
rsize = strlcpy(bufp, "+", size);
|
bytes = (int)strlcpy(bufp, "+", size);
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
}
|
}
|
||||||
while (k--) {
|
while (k--) {
|
||||||
rsize = strlcpy(bufp, "0+", size);
|
bytes = (int)strlcpy(bufp, "0+", size);
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
}
|
}
|
||||||
sprintf(buffer, "%d", alive[r]);
|
sprintf(buffer, "%d", alive[r]);
|
||||||
|
|
||||||
rsize = strlcpy(bufp, buffer, size);
|
bytes = (int)strlcpy(bufp, buffer, size);
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
|
|
||||||
k = 0;
|
k = 0;
|
||||||
l = r+1;
|
l = r+1;
|
||||||
|
@ -3373,6 +3374,7 @@ battle_report(battle * b)
|
||||||
komma = true;
|
komma = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*bufp = 0;
|
||||||
fbattlerecord(b, fac, buf);
|
fbattlerecord(b, fac, buf);
|
||||||
}
|
}
|
||||||
return cont;
|
return cont;
|
||||||
|
|
|
@ -1597,7 +1597,7 @@ cstring(const char *s)
|
||||||
{
|
{
|
||||||
char *ibuf = idbuf[(++nextbuf) % 8];
|
char *ibuf = idbuf[(++nextbuf) % 8];
|
||||||
|
|
||||||
strlcpy(ibuf,s, sizeof(name));
|
strlcpy(ibuf, s, sizeof(name));
|
||||||
return cstring_i(ibuf);
|
return cstring_i(ibuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
#include <util/goodies.h>
|
#include <util/goodies.h>
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
#include <util/lists.h>
|
#include <util/lists.h>
|
||||||
|
#include <util/log.h>
|
||||||
#include <util/parser.h>
|
#include <util/parser.h>
|
||||||
#include <util/rand.h>
|
#include <util/rand.h>
|
||||||
#include <util/rng.h>
|
#include <util/rng.h>
|
||||||
|
@ -902,15 +903,15 @@ static const char *shortdirections[MAXDIRECTIONS] =
|
||||||
static void
|
static void
|
||||||
cycle_route(order * ord, unit *u, int gereist)
|
cycle_route(order * ord, unit *u, int gereist)
|
||||||
{
|
{
|
||||||
int cm = 0;
|
int bytes, cm = 0;
|
||||||
char tail[1024];
|
char tail[1024], * bufp = tail;
|
||||||
char neworder[2048];
|
char neworder[2048];
|
||||||
const char *token;
|
const char *token;
|
||||||
direction_t d = NODIRECTION;
|
direction_t d = NODIRECTION;
|
||||||
boolean paused = false;
|
boolean paused = false;
|
||||||
boolean pause;
|
boolean pause;
|
||||||
order * norder;
|
order * norder;
|
||||||
char * tail_end = tail;
|
size_t size = sizeof(tail) - 1;
|
||||||
|
|
||||||
if (get_keyword(ord) != K_ROUTE) return;
|
if (get_keyword(ord) != K_ROUTE) return;
|
||||||
tail[0] = '\0';
|
tail[0] = '\0';
|
||||||
|
@ -933,18 +934,20 @@ cycle_route(order * ord, unit *u, int gereist)
|
||||||
/* hier sollte keine PAUSE auftreten */
|
/* hier sollte keine PAUSE auftreten */
|
||||||
assert(!pause);
|
assert(!pause);
|
||||||
if (!pause) {
|
if (!pause) {
|
||||||
size_t size = sizeof(tail)-(tail_end-tail);
|
|
||||||
const char * loc = LOC(lang, shortdirections[d]);
|
const char * loc = LOC(lang, shortdirections[d]);
|
||||||
*tail_end++ = ' ';
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
tail_end += strlcpy(tail_end, loc, size-1);
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
bytes = (int)strlcpy(bufp, loc, size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strlen(neworder)>sizeof(neworder)/2) break;
|
else if (strlen(neworder)>sizeof(neworder)/2) break;
|
||||||
else if (cm == gereist && !paused && pause) {
|
else if (cm == gereist && !paused && pause) {
|
||||||
size_t size = sizeof(tail)-(tail_end-tail);
|
|
||||||
const char * loc = LOC(lang, parameters[P_PAUSE]);
|
const char * loc = LOC(lang, parameters[P_PAUSE]);
|
||||||
*tail_end++ = ' ';
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
tail_end += strlcpy(tail_end, loc, size-1);
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
bytes = (int)strlcpy(bufp, loc, size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
paused = true;
|
paused = true;
|
||||||
}
|
}
|
||||||
else if (pause) {
|
else if (pause) {
|
||||||
|
@ -2256,9 +2259,9 @@ static int
|
||||||
hunt(unit *u, order * ord)
|
hunt(unit *u, order * ord)
|
||||||
{
|
{
|
||||||
region *rc = u->region;
|
region *rc = u->region;
|
||||||
int moves, id, speed;
|
int bytes, moves, id, speed;
|
||||||
char command[256];
|
char command[256], * bufp = command;
|
||||||
char * bufp = command;
|
size_t size = sizeof(command);
|
||||||
direction_t dir;
|
direction_t dir;
|
||||||
|
|
||||||
if (fval(u, UFL_NOTMOVING)) {
|
if (fval(u, UFL_NOTMOVING)) {
|
||||||
|
@ -2296,8 +2299,11 @@ hunt(unit *u, order * ord)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bufp = command + sprintf(command, "%s %s", locale_string(u->faction->locale, keywords[K_MOVE]),
|
bufp = command;
|
||||||
locale_string(u->faction->locale, directions[dir]));
|
bytes = snprintf(bufp, size, "%s %s", LOC(u->faction->locale, keywords[K_MOVE]),
|
||||||
|
LOC(u->faction->locale, directions[dir]));
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
moves = 1;
|
moves = 1;
|
||||||
|
|
||||||
speed = getuint();
|
speed = getuint();
|
||||||
|
@ -2310,8 +2316,10 @@ hunt(unit *u, order * ord)
|
||||||
rc = rconnect(rc, dir);
|
rc = rconnect(rc, dir);
|
||||||
while (moves < speed && (dir = hunted_dir(rc->attribs, id)) != NODIRECTION)
|
while (moves < speed && (dir = hunted_dir(rc->attribs, id)) != NODIRECTION)
|
||||||
{
|
{
|
||||||
bufp += strlcpy(bufp, " ", sizeof(command) - (bufp-command));
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
bufp += strlcpy(bufp, LOC(u->faction->locale, directions[dir]), sizeof(command) - (bufp-command));
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
bytes = (int)strlcpy(bufp, LOC(u->faction->locale, directions[dir]), size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
moves++;
|
moves++;
|
||||||
rc = rconnect(rc, dir);
|
rc = rconnect(rc, dir);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <util/base36.h>
|
#include <util/base36.h>
|
||||||
#include <util/bsdstring.h>
|
#include <util/bsdstring.h>
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
|
#include <util/log.h>
|
||||||
#include <util/parser.h>
|
#include <util/parser.h>
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
|
@ -86,25 +87,35 @@ get_keyword(const order * ord)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
get_command(const order * ord, char * sbuffer, size_t bufsize)
|
get_command(const order * ord, char * sbuffer, size_t size)
|
||||||
{
|
{
|
||||||
char * str = sbuffer;
|
char * bufp = sbuffer;
|
||||||
const char * text = ORD_STRING(ord);
|
const char * text = ORD_STRING(ord);
|
||||||
keyword_t kwd = ORD_KEYWORD(ord);
|
keyword_t kwd = ORD_KEYWORD(ord);
|
||||||
|
int bytes;
|
||||||
|
|
||||||
if (ord->_persistent) *str++ = '@';
|
if (ord->_persistent) {
|
||||||
if (kwd!=NOKEYWORD) {
|
if (size>0) {
|
||||||
const struct locale * lang = ORD_LOCALE(ord);
|
*bufp++ = '@';
|
||||||
size_t size = bufsize-(str-sbuffer);
|
--size;
|
||||||
if (text) --size;
|
} else {
|
||||||
str += strlcpy(str, (const char*)LOC(lang, keywords[kwd]), size);
|
WARN_STATIC_BUFFER();
|
||||||
if (text) {
|
|
||||||
*str++ = ' ';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (text) {
|
if (kwd!=NOKEYWORD) {
|
||||||
str += strlcpy(str, (const char *)text, bufsize-(str-sbuffer));
|
const struct locale * lang = ORD_LOCALE(ord);
|
||||||
|
if (size>0) {
|
||||||
|
if (text) --size;
|
||||||
|
bytes = (int)strlcpy(bufp, (const char*)LOC(lang, keywords[kwd]), size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
if (text) *bufp++ = ' ';
|
||||||
|
} else WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
|
if (text) {
|
||||||
|
bytes = (int)strlcpy(bufp, (const char *)text, size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
}
|
||||||
|
*bufp = 0;
|
||||||
return sbuffer;
|
return sbuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +278,9 @@ create_order(keyword_t kwd, const struct locale * lang, const char * params, ...
|
||||||
{
|
{
|
||||||
char zBuffer[DISPLAYSIZE];
|
char zBuffer[DISPLAYSIZE];
|
||||||
if (params) {
|
if (params) {
|
||||||
char * sptr = zBuffer;
|
char * bufp = zBuffer;
|
||||||
|
int bytes;
|
||||||
|
size_t size = sizeof(zBuffer) - 1;
|
||||||
va_list marker;
|
va_list marker;
|
||||||
|
|
||||||
va_start(marker, params);
|
va_start(marker, params);
|
||||||
|
@ -279,26 +292,30 @@ create_order(keyword_t kwd, const struct locale * lang, const char * params, ...
|
||||||
switch (*params) {
|
switch (*params) {
|
||||||
case 's':
|
case 's':
|
||||||
s = va_arg(marker, const char *);
|
s = va_arg(marker, const char *);
|
||||||
sptr += strlcpy(sptr, s, sizeof(zBuffer)-(sptr-zBuffer));
|
bytes = (int)strlcpy(bufp, s, size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
i = va_arg(marker, int);
|
i = va_arg(marker, int);
|
||||||
sptr += strlcpy(sptr, itoa10(i), sizeof(zBuffer)-(sptr-zBuffer));
|
bytes = (int)strlcpy(bufp, itoa10(i), size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
i = va_arg(marker, int);
|
i = va_arg(marker, int);
|
||||||
sptr += strlcpy(sptr, itoa36(i), sizeof(zBuffer)-(sptr-zBuffer));
|
bytes = (int)strlcpy(bufp, itoa36(i), size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(!"unknown format-character in create_order");
|
assert(!"unknown format-character in create_order");
|
||||||
}
|
}
|
||||||
} else {
|
} else if (size>0) {
|
||||||
*sptr++ = *params;
|
*bufp++ = *params;
|
||||||
|
--size;
|
||||||
}
|
}
|
||||||
++params;
|
++params;
|
||||||
}
|
}
|
||||||
va_end(marker);
|
va_end(marker);
|
||||||
*sptr = 0;
|
*bufp = 0;
|
||||||
} else {
|
} else {
|
||||||
zBuffer[0] = 0;
|
zBuffer[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,13 +252,19 @@ racename(const struct locale *loc, const unit *u, const race * rc)
|
||||||
|
|
||||||
if (prefix!=NULL) {
|
if (prefix!=NULL) {
|
||||||
static char lbuf[80];
|
static char lbuf[80];
|
||||||
char * s = lbuf;
|
char * bufp = lbuf;
|
||||||
int ch;
|
size_t size = sizeof(lbuf) - 1;
|
||||||
s += strlcpy(lbuf, LOC(loc, mkname("prefix", prefix)), sizeof(lbuf));
|
int ch, bytes;
|
||||||
strlcpy(s, LOC(loc, rc_name(rc, u->number != 1)), sizeof(lbuf)-(s-lbuf));
|
|
||||||
assert(~s[0] & 0x80|| !"unicode/not implemented");
|
bytes = (int)strlcpy(bufp, LOC(loc, mkname("prefix", prefix)), size);
|
||||||
ch = tolower(*(unsigned char *)s);
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
*s = (char)ch;
|
bytes = (int)strlcpy(bufp, LOC(loc, rc_name(rc, u->number != 1)), size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
*bufp = 0;
|
||||||
|
|
||||||
|
assert(~lbuf[0] & 0x80|| !"unicode/not implemented");
|
||||||
|
ch = tolower(*(unsigned char *)lbuf);
|
||||||
|
lbuf[0] = (char)ch;
|
||||||
return lbuf;
|
return lbuf;
|
||||||
}
|
}
|
||||||
return LOC(loc, rc_name(rc, u->number != 1));
|
return LOC(loc, rc_name(rc, u->number != 1));
|
||||||
|
|
|
@ -71,9 +71,6 @@ boolean nocr = false;
|
||||||
boolean nonr = false;
|
boolean nonr = false;
|
||||||
boolean noreports = false;
|
boolean noreports = false;
|
||||||
|
|
||||||
#define WARN_STATIC_BUFFER() \
|
|
||||||
log_warning(("static buffer too small in %s:%d\n", __FILE__, __LINE__))
|
|
||||||
|
|
||||||
const char * g_reportdir;
|
const char * g_reportdir;
|
||||||
const char * visibility[] = {
|
const char * visibility[] = {
|
||||||
"none",
|
"none",
|
||||||
|
@ -95,21 +92,6 @@ const char *coasts[MAXDIRECTIONS] =
|
||||||
"coast::w"
|
"coast::w"
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
|
||||||
wrptr(char ** ptr, size_t * size, int bytes)
|
|
||||||
{
|
|
||||||
if (bytes<=*size) {
|
|
||||||
*ptr += bytes;
|
|
||||||
*size -= bytes;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
*ptr += *size;
|
|
||||||
*size = 0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
reportpath(void)
|
reportpath(void)
|
||||||
{
|
{
|
||||||
|
@ -231,29 +213,30 @@ update_nmrs(void)
|
||||||
static size_t
|
static size_t
|
||||||
buforder(char * bufp, size_t size, const order * ord, int mode)
|
buforder(char * bufp, size_t size, const order * ord, int mode)
|
||||||
{
|
{
|
||||||
size_t tsize = 0, rsize;
|
size_t tsize = 0;
|
||||||
|
int bytes;
|
||||||
|
|
||||||
rsize = strlcpy(bufp, ", \"", size);
|
bytes = (int)strlcpy(bufp, ", \"", size);
|
||||||
tsize += rsize;
|
tsize += bytes;
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
if (mode<ORDERS_IN_NR) {
|
if (mode<ORDERS_IN_NR) {
|
||||||
char * cmd = getcommand(ord);
|
char * cmd = getcommand(ord);
|
||||||
rsize = strlcpy(bufp, cmd, size);
|
bytes = (int)strlcpy(bufp, cmd, size);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
} else {
|
} else {
|
||||||
rsize = strlcpy(bufp, "...", size);
|
bytes = (int)strlcpy(bufp, "...", size);
|
||||||
}
|
}
|
||||||
tsize += rsize;
|
tsize += bytes;
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
|
|
||||||
if (size>1) {
|
if (size>1) {
|
||||||
strcpy(bufp, "\"");
|
*bufp++ ='\"';
|
||||||
++tsize;
|
--size;
|
||||||
|
} else {
|
||||||
|
WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
|
++tsize;
|
||||||
|
|
||||||
return tsize;
|
return tsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +274,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
telepath_see = fspecial(f, FS_TELEPATHY);
|
telepath_see = fspecial(f, FS_TELEPATHY);
|
||||||
#endif /* KARMA_MODULE */
|
#endif /* KARMA_MODULE */
|
||||||
|
|
||||||
bytes = strlcpy(bufp, unitname(u), size);
|
bytes = (int)strlcpy(bufp, unitname(u), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
if (!isbattle) {
|
if (!isbattle) {
|
||||||
|
@ -301,31 +284,31 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
attrib *a = a_find(u->attribs, &at_group);
|
attrib *a = a_find(u->attribs, &at_group);
|
||||||
if (a) {
|
if (a) {
|
||||||
group * g = (group*)a->data.v;
|
group * g = (group*)a->data.v;
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, groupid(g, f), size);
|
bytes = (int)strlcpy(bufp, groupid(g, f), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getarnt) {
|
if (getarnt) {
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, "anonymous"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "anonymous"), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
} else if (a_otherfaction) {
|
} else if (a_otherfaction) {
|
||||||
faction * otherfaction = get_otherfaction(a_otherfaction);
|
faction * otherfaction = get_otherfaction(a_otherfaction);
|
||||||
if (otherfaction) {
|
if (otherfaction) {
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, factionname(otherfaction), size);
|
bytes = (int)strlcpy(bufp, factionname(otherfaction), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (getarnt) {
|
if (getarnt) {
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, "anonymous"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "anonymous"), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
} else {
|
} else {
|
||||||
if (a_otherfaction && alliedunit(u, f, HELP_FSTEALTH)) {
|
if (a_otherfaction && alliedunit(u, f, HELP_FSTEALTH)) {
|
||||||
|
@ -333,20 +316,20 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
bytes = snprintf(bufp, size, ", %s (%s)", factionname(f), factionname(u->faction));
|
bytes = snprintf(bufp, size, ", %s (%s)", factionname(f), factionname(u->faction));
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, factionname(fv), size);
|
bytes = (int)strlcpy(bufp, factionname(fv), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
if (u->faction != f && a_fshidden && a_fshidden->data.ca[0] == 1 && effskill(u, SK_STEALTH) >= 6) {
|
if (u->faction != f && a_fshidden && a_fshidden->data.ca[0] == 1 && effskill(u, SK_STEALTH) >= 6) {
|
||||||
bytes = strlcpy(bufp, "? ", size);
|
bytes = (int)strlcpy(bufp, "? ", size);
|
||||||
} else {
|
} else {
|
||||||
bytes = snprintf(bufp, size, "%d ", u->number);
|
bytes = snprintf(bufp, size, "%d ", u->number);
|
||||||
}
|
}
|
||||||
|
@ -354,12 +337,12 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
|
|
||||||
pzTmp = get_racename(u->attribs);
|
pzTmp = get_racename(u->attribs);
|
||||||
if (pzTmp) {
|
if (pzTmp) {
|
||||||
bytes = strlcpy(bufp, pzTmp, size);
|
bytes = (int)strlcpy(bufp, pzTmp, size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
if (u->faction==f && fval(u->race, RCF_SHAPESHIFTANY)) {
|
if (u->faction==f && fval(u->race, RCF_SHAPESHIFTANY)) {
|
||||||
bytes = strlcpy(bufp, " (", size);
|
bytes = (int)strlcpy(bufp, " (", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, racename(f->locale, u, u->race), size);
|
bytes = (int)strlcpy(bufp, racename(f->locale, u, u->race), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
if (size>1) {
|
if (size>1) {
|
||||||
strcpy(bufp++, ")");
|
strcpy(bufp++, ")");
|
||||||
|
@ -367,12 +350,12 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, racename(f->locale, u, u->irace), size);
|
bytes = (int)strlcpy(bufp, racename(f->locale, u, u->irace), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
if (u->faction==f && u->irace!=u->race) {
|
if (u->faction==f && u->irace!=u->race) {
|
||||||
bytes = strlcpy(bufp, " (", size);
|
bytes = (int)strlcpy(bufp, " (", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, racename(f->locale, u, u->race), size);
|
bytes = (int)strlcpy(bufp, racename(f->locale, u, u->race), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
if (size>1) {
|
if (size>1) {
|
||||||
strcpy(bufp++, ")");
|
strcpy(bufp++, ")");
|
||||||
|
@ -383,9 +366,9 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
|
|
||||||
#ifdef HEROES
|
#ifdef HEROES
|
||||||
if (fval(u, UFL_HERO) && (u->faction == f || omniscient(f))) {
|
if (fval(u, UFL_HERO) && (u->faction == f || omniscient(f))) {
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, "hero"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "hero"), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -393,20 +376,20 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
|
|
||||||
if (u->number && (u->faction == f || telepath_see || isbattle)) {
|
if (u->number && (u->faction == f || telepath_see || isbattle)) {
|
||||||
const char * c = locale_string(f->locale, hp_status(u));
|
const char * c = locale_string(f->locale, hp_status(u));
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, report_kampfstatus(u, f->locale), size);
|
bytes = (int)strlcpy(bufp, report_kampfstatus(u, f->locale), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
if (c || fval(u, UFL_HUNGER)) {
|
if (c || fval(u, UFL_HUNGER)) {
|
||||||
bytes = strlcpy(bufp, " (", size);
|
bytes = (int)strlcpy(bufp, " (", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
if (c) {
|
if (c) {
|
||||||
bytes = strlcpy(bufp, c, size);
|
bytes = (int)strlcpy(bufp, c, size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
if (fval(u, UFL_HUNGER)) {
|
if (fval(u, UFL_HUNGER)) {
|
||||||
if (c) bytes = strlcpy(bufp, ", hungert", size);
|
if (c) bytes = (int)strlcpy(bufp, ", hungert", size);
|
||||||
else bytes = strlcpy(bufp, "hungert", size);
|
else bytes = (int)strlcpy(bufp, "hungert", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
if (size>1) {
|
if (size>1) {
|
||||||
|
@ -416,16 +399,16 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getguard(u)) {
|
if (getguard(u)) {
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, "unit_guards"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "unit_guards"), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((b = usiege(u))!=NULL) {
|
if ((b = usiege(u))!=NULL) {
|
||||||
bytes = strlcpy(bufp, ", belagert ", size);
|
bytes = (int)strlcpy(bufp, ", belagert ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, buildingname(b), size);
|
bytes = (int)strlcpy(bufp, buildingname(b), size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +416,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
if (u->faction == f || telepath_see) {
|
if (u->faction == f || telepath_see) {
|
||||||
skill * sv;
|
skill * sv;
|
||||||
for (sv = u->skills;sv!=u->skills+u->skill_size;++sv) {
|
for (sv = u->skills;sv!=u->skills+u->skill_size;++sv) {
|
||||||
bytes = spskill(bufp, size, f->locale, u, sv, &dh, 1);
|
bytes = (int)spskill(bufp, size, f->locale, u, sv, &dh, 1);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -474,7 +457,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
int in, bytes;
|
int in, bytes;
|
||||||
report_item(u, itm, f, &ic, NULL, &in, false);
|
report_item(u, itm, f, &ic, NULL, &in, false);
|
||||||
if (in==0 || ic==NULL) continue;
|
if (in==0 || ic==NULL) continue;
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
if (!dh) {
|
if (!dh) {
|
||||||
|
@ -483,7 +466,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
dh = 1;
|
dh = 1;
|
||||||
}
|
}
|
||||||
if (in == 1) {
|
if (in == 1) {
|
||||||
bytes = strlcpy(bufp, ic, size);
|
bytes = (int)strlcpy(bufp, ic, size);
|
||||||
} else {
|
} else {
|
||||||
bytes = snprintf(bufp, size, "%d %s", in, ic);
|
bytes = snprintf(bufp, size, "%d %s", in, ic);
|
||||||
}
|
}
|
||||||
|
@ -507,10 +490,10 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
bytes = snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_spells"));
|
bytes = snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_spells"));
|
||||||
dh = 1;
|
dh = 1;
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
}
|
}
|
||||||
if (bytes && wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (bytes && wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, spell_name(sp, f->locale), size);
|
bytes = (int)strlcpy(bufp, spell_name(sp, f->locale), size);
|
||||||
if (bytes && wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (bytes && wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,7 +510,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
if (!dh){
|
if (!dh){
|
||||||
dh = 1;
|
dh = 1;
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (bytes && wrptr(&bufp, &size, bytes)!=0) {
|
if (bytes && wrptr(&bufp, &size, bytes)!=0) {
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
|
@ -535,7 +518,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
sp = get_combatspell(u,i);
|
sp = get_combatspell(u,i);
|
||||||
if (sp) {
|
if (sp) {
|
||||||
int sl = get_combatspelllevel(u, i);
|
int sl = get_combatspelllevel(u, i);
|
||||||
bytes = strlcpy(bufp, spell_name(sp, u->faction->locale), size);
|
bytes = (int)strlcpy(bufp, spell_name(sp, u->faction->locale), size);
|
||||||
if (bytes && wrptr(&bufp, &size, bytes)!=0) {
|
if (bytes && wrptr(&bufp, &size, bytes)!=0) {
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
|
@ -545,7 +528,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
if (bytes && wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (bytes && wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bytes = strlcpy(bufp, LOC(f->locale, "nr_nospells"), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_nospells"), size);
|
||||||
if (bytes && wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (bytes && wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -563,7 +546,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
for (ord=u->old_orders;ord;ord=ord->next) {
|
for (ord=u->old_orders;ord;ord=ord->next) {
|
||||||
if (is_repeated(ord)) {
|
if (is_repeated(ord)) {
|
||||||
if (printed<ORDERS_IN_NR) {
|
if (printed<ORDERS_IN_NR) {
|
||||||
bytes = buforder(bufp, size, ord, printed++);
|
bytes = (int)buforder(bufp, size, ord, printed++);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
} else break;
|
} else break;
|
||||||
}
|
}
|
||||||
|
@ -571,7 +554,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
if (printed<ORDERS_IN_NR) for (ord=u->orders;ord;ord=ord->next) {
|
if (printed<ORDERS_IN_NR) for (ord=u->orders;ord;ord=ord->next) {
|
||||||
if (is_repeated(ord)) {
|
if (is_repeated(ord)) {
|
||||||
if (printed<ORDERS_IN_NR) {
|
if (printed<ORDERS_IN_NR) {
|
||||||
bytes = buforder(bufp, size, ord, printed++);
|
bytes = (int)buforder(bufp, size, ord, printed++);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
} else break;
|
} else break;
|
||||||
}
|
}
|
||||||
|
@ -583,10 +566,10 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
|
|
||||||
str = u_description(u, f->locale);
|
str = u_description(u, f->locale);
|
||||||
if (str) {
|
if (str) {
|
||||||
bytes = strlcpy(bufp, "; ", size);
|
bytes = (int)strlcpy(bufp, "; ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
bytes = strlcpy(bufp, str, size);
|
bytes = (int)strlcpy(bufp, str, size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
i = str[strlen(str) - 1];
|
i = str[strlen(str) - 1];
|
||||||
|
@ -599,11 +582,11 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char * buf, siz
|
||||||
}
|
}
|
||||||
pzTmp = uprivate(u);
|
pzTmp = uprivate(u);
|
||||||
if (u->faction == f && pzTmp) {
|
if (u->faction == f && pzTmp) {
|
||||||
bytes = strlcpy(bufp, " (Bem: ", size);
|
bytes = (int)strlcpy(bufp, " (Bem: ", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, pzTmp, size);
|
bytes = (int)strlcpy(bufp, pzTmp, size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
bytes = strlcpy(bufp, ")", size);
|
bytes = (int)strlcpy(bufp, ")", size);
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -629,7 +612,7 @@ spskill(char * buffer, size_t size, const struct locale * lang, const struct uni
|
||||||
{
|
{
|
||||||
char * bufp = buffer;
|
char * bufp = buffer;
|
||||||
int i, effsk;
|
int i, effsk;
|
||||||
size_t rsize;
|
int bytes;
|
||||||
size_t tsize = 0;
|
size_t tsize = 0;
|
||||||
|
|
||||||
if (!u->number) return 0;
|
if (!u->number) return 0;
|
||||||
|
@ -639,72 +622,54 @@ spskill(char * buffer, size_t size, const struct locale * lang, const struct uni
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rsize = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
tsize += rsize;
|
tsize += bytes;
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
|
|
||||||
if (!*dh) {
|
if (!*dh) {
|
||||||
rsize = strlcpy(bufp, LOC(lang, "nr_skills"), size);
|
bytes = (int)strlcpy(bufp, LOC(lang, "nr_skills"), size);
|
||||||
tsize += rsize;
|
tsize += bytes;
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
|
|
||||||
rsize = strlcpy(bufp, ": ", size);
|
bytes = (int)strlcpy(bufp, ": ", size);
|
||||||
tsize += rsize;
|
tsize += bytes;
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
|
|
||||||
*dh = 1;
|
*dh = 1;
|
||||||
}
|
}
|
||||||
rsize = strlcpy(bufp, skillname(sv->id, lang), size);
|
bytes = (int)strlcpy(bufp, skillname(sv->id, lang), size);
|
||||||
tsize += rsize;
|
tsize += bytes;
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
|
|
||||||
rsize = strlcpy(bufp, " ", size);
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
tsize += rsize;
|
tsize += bytes;
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
|
|
||||||
if (sv->id == SK_MAGIC){
|
if (sv->id == SK_MAGIC){
|
||||||
if (find_magetype(u) != M_GRAU){
|
if (find_magetype(u) != M_GRAU){
|
||||||
rsize = strlcpy(bufp, LOC(lang, mkname("school", magietypen[find_magetype(u)])), size);
|
bytes = (int)strlcpy(bufp, LOC(lang, mkname("school", magietypen[find_magetype(u)])), size);
|
||||||
tsize += rsize;
|
tsize += bytes;
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
|
|
||||||
rsize = strlcpy(bufp, " ", size);
|
bytes = (int)strlcpy(bufp, " ", size);
|
||||||
tsize += rsize;
|
tsize += bytes;
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sv->id == SK_STEALTH && fval(u, UFL_STEALTH)) {
|
if (sv->id == SK_STEALTH && fval(u, UFL_STEALTH)) {
|
||||||
i = u_geteffstealth(u);
|
i = u_geteffstealth(u);
|
||||||
if (i>=0) {
|
if (i>=0) {
|
||||||
rsize = slprintf(bufp, size, "%d/", i);
|
bytes = slprintf(bufp, size, "%d/", i);
|
||||||
tsize += rsize;
|
tsize += bytes;
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
effsk = effskill(u, sv->id);
|
effsk = effskill(u, sv->id);
|
||||||
rsize = slprintf(bufp, size, "%d", effsk);
|
bytes = slprintf(bufp, size, "%d", effsk);
|
||||||
tsize += rsize;
|
tsize += bytes;
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
|
|
||||||
if (u->faction->options & want(O_SHOWSKCHANGE)) {
|
if (u->faction->options & want(O_SHOWSKCHANGE)) {
|
||||||
int oldeff = 0;
|
int oldeff = 0;
|
||||||
|
@ -718,11 +683,9 @@ spskill(char * buffer, size_t size, const struct locale * lang, const struct uni
|
||||||
diff = effsk - oldeff;
|
diff = effsk - oldeff;
|
||||||
|
|
||||||
if (diff != 0) {
|
if (diff != 0) {
|
||||||
rsize = slprintf(bufp, size, " (%s%d)", (diff>0)?"+":"", diff);
|
bytes = slprintf(bufp, size, " (%s%d)", (diff>0)?"+":"", diff);
|
||||||
tsize += rsize;
|
tsize += bytes;
|
||||||
if (rsize>size) rsize = size-1;
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
size -= rsize;
|
|
||||||
bufp += rsize;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tsize;
|
return tsize;
|
||||||
|
@ -1846,7 +1809,7 @@ eval_regions(struct opstack ** stack, const void * userdata) /* order -> string
|
||||||
}
|
}
|
||||||
for (i=begin;i<end;++i) {
|
for (i=begin;i<end;++i) {
|
||||||
const char * rname = (const char*)regionname(regions->regions[i], report);
|
const char * rname = (const char*)regionname(regions->regions[i], report);
|
||||||
int bytes = strlcpy(bufp, rname, size);
|
int bytes = (int)strlcpy(bufp, rname, size);
|
||||||
if (bytes && wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (bytes && wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
if (i+1<end && size>2) {
|
if (i+1<end && size>2) {
|
||||||
|
@ -1881,9 +1844,9 @@ eval_trail(struct opstack ** stack, const void * userdata) /* order -> string */
|
||||||
if (bytes && wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (bytes && wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
||||||
if (i+2<end) {
|
if (i+2<end) {
|
||||||
bytes = strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
} else if (i+1<end) {
|
} else if (i+1<end) {
|
||||||
bytes = strlcpy(bufp, LOC(report->locale, "list_and"), size);
|
bytes = (int)strlcpy(bufp, LOC(report->locale, "list_and"), size);
|
||||||
} else bytes = 0;
|
} else bytes = 0;
|
||||||
|
|
||||||
if (bytes && wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
if (bytes && wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
|
|
|
@ -46,7 +46,6 @@ void lparagraph(struct strlist ** SP, char *s, int indent, char mark);
|
||||||
const char *hp_status(const struct unit * u);
|
const char *hp_status(const struct unit * u);
|
||||||
extern size_t spskill(char * pbuf, size_t siz, const struct locale * lang, const struct unit * u, struct skill * sv, int *dh, int days); /* mapper */
|
extern size_t spskill(char * pbuf, size_t siz, const struct locale * lang, const struct unit * u, struct skill * sv, int *dh, int days); /* mapper */
|
||||||
extern void spunit(struct strlist ** SP, const struct faction * f, const struct unit * u, int indent, int mode);
|
extern void spunit(struct strlist ** SP, const struct faction * f, const struct unit * u, int indent, int mode);
|
||||||
extern int wrptr(char ** ptr, size_t * size, int bytes);
|
|
||||||
|
|
||||||
extern int reports(void);
|
extern int reports(void);
|
||||||
extern int write_reports(struct faction * f, time_t ltime);
|
extern int write_reports(struct faction * f, time_t ltime);
|
||||||
|
|
|
@ -542,11 +542,11 @@ sp_summon_familiar(castorder *co)
|
||||||
int cast_level = co->level;
|
int cast_level = co->level;
|
||||||
const race * rc;
|
const race * rc;
|
||||||
skill_t sk;
|
skill_t sk;
|
||||||
int dh, dh1;
|
int dh, dh1, bytes;
|
||||||
direction_t d;
|
direction_t d;
|
||||||
message * msg;
|
message * msg;
|
||||||
char zText[NAMESIZE];
|
char zText[NAMESIZE], * bufp = zText;
|
||||||
char * bufp = zText;
|
size_t size = sizeof(zText) - 1;
|
||||||
|
|
||||||
if (get_familiar(mage) != NULL ) {
|
if (get_familiar(mage) != NULL ) {
|
||||||
cmistake(mage, co->order, 199, MSG_MAGIC);
|
cmistake(mage, co->order, 199, MSG_MAGIC);
|
||||||
|
@ -601,12 +601,14 @@ sp_summon_familiar(castorder *co)
|
||||||
dh1 = 1;
|
dh1 = 1;
|
||||||
} else {
|
} else {
|
||||||
if (dh == 0) {
|
if (dh == 0) {
|
||||||
bufp += strlcpy(bufp, (const char*)LOC(mage->faction->locale, "list_and"), sizeof(zText) - (bufp-zText));
|
bytes = (int)strlcpy(bufp, (const char*)LOC(mage->faction->locale, "list_and"), size);
|
||||||
} else {
|
} else {
|
||||||
bufp += strlcpy(bufp, (const char*)", ", sizeof(zText) - (bufp-zText));
|
bytes = (int)strlcpy(bufp, (const char*)", ", size);
|
||||||
}
|
}
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
bufp += strlcpy(bufp, (const char*)skillname(sk, mage->faction->locale), sizeof(zText) - (bufp-zText));
|
bytes = (int)strlcpy(bufp, (const char*)skillname(sk, mage->faction->locale), size);
|
||||||
|
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ADDMSG(&mage->faction->msgs, msg_message("familiar_describe",
|
ADDMSG(&mage->faction->msgs, msg_message("familiar_describe",
|
||||||
|
|
|
@ -1,6 +1,24 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#ifndef HAVE_INLINE
|
||||||
#include "bsdstring.h"
|
#include "bsdstring.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
INLINE_FUNCTION int
|
||||||
|
wrptr(char ** ptr, size_t * size, int bytes)
|
||||||
|
{
|
||||||
|
if (bytes<=*(int*)size) {
|
||||||
|
*ptr += bytes;
|
||||||
|
*size -= bytes;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ptr += *size;
|
||||||
|
*size = 0;
|
||||||
|
return ENAMETOOLONG;
|
||||||
|
}
|
||||||
|
|
||||||
#if !defined(HAVE_STRLCPY)
|
#if !defined(HAVE_STRLCPY)
|
||||||
INLINE_FUNCTION size_t
|
INLINE_FUNCTION size_t
|
||||||
|
@ -22,10 +40,11 @@ strlcpy(char *dst, const char *src, size_t siz) /* copied from OpenBSD source
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
if (siz != 0)
|
if (siz != 0)
|
||||||
*d = '\0'; /* NUL-terminate dst */
|
*d = '\0'; /* NUL-terminate dst */
|
||||||
|
while (*s++)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return(s - src - 1); count does not include NUL */
|
return(s - src - 1); /* count does not include NUL */
|
||||||
return siz - n - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
#ifndef UTIL_BSDSTRING_H
|
#ifndef UTIL_BSDSTRING_H
|
||||||
#define UTIL_BSDSTRING_H
|
#define UTIL_BSDSTRING_H
|
||||||
|
|
||||||
#if !defined(HAVE_STRLCPY)
|
#ifdef HAVE_INLINE
|
||||||
# ifdef HAVE_INLINE
|
# include "bsdstring.c"
|
||||||
# include "bsdstring.c"
|
#else
|
||||||
# define HAVE_STRLCPY
|
extern size_t strlcpy(char *dst, const char *src, size_t siz);
|
||||||
# else
|
extern size_t strlcat(char * dst, const char * src, size_t siz);
|
||||||
extern size_t strlcpy(char *dst, const char *src, size_t siz);
|
extern int wrptr(char ** ptr, size_t * size, int bytes);
|
||||||
extern size_t strlcat(char * dst, const char * src, size_t siz);
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_STRLCPY)
|
||||||
|
# define HAVE_STRLCPY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define WARN_STATIC_BUFFER() log_warning(("static buffer too small in %s:%d\n", __FILE__, __LINE__))
|
||||||
|
|
||||||
#if !defined(HAVE_STRLPRINTF)
|
#if !defined(HAVE_STRLPRINTF)
|
||||||
# define HAVE_STRLPRINTF
|
# define HAVE_STRLPRINTF
|
||||||
# define slprintf snprintf
|
# define slprintf snprintf
|
||||||
|
|
|
@ -249,6 +249,7 @@ parse_string(opstack ** stack, const char* in, const void * userdata) /* (char*)
|
||||||
{
|
{
|
||||||
char * c;
|
char * c;
|
||||||
char * buffer = balloc(TOKENSIZE);
|
char * buffer = balloc(TOKENSIZE);
|
||||||
|
size_t size = TOKENSIZE - 1;
|
||||||
const char * ic = in;
|
const char * ic = in;
|
||||||
char * oc = buffer;
|
char * oc = buffer;
|
||||||
/* mode flags */
|
/* mode flags */
|
||||||
|
@ -261,16 +262,18 @@ parse_string(opstack ** stack, const char* in, const void * userdata) /* (char*)
|
||||||
f_escape = false;
|
f_escape = false;
|
||||||
switch (*ic) {
|
switch (*ic) {
|
||||||
case 'n':
|
case 'n':
|
||||||
*oc++='\n';
|
if (size>0) { *oc++='\n'; --size; }
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
*oc++='\t';
|
if (size>0) { *oc++='\t'; --size; }
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
*oc++=*ic;
|
if (size>0) { *oc++=*ic; --size; }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int ch = (unsigned char)(*ic);
|
int ch = (unsigned char)(*ic);
|
||||||
|
int bytes;
|
||||||
|
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case '\\':
|
case '\\':
|
||||||
f_escape = true;
|
f_escape = true;
|
||||||
|
@ -284,11 +287,14 @@ parse_string(opstack ** stack, const char* in, const void * userdata) /* (char*)
|
||||||
ic = parse_symbol(stack, ++ic, userdata);
|
ic = parse_symbol(stack, ++ic, userdata);
|
||||||
if (ic==NULL) return NULL;
|
if (ic==NULL) return NULL;
|
||||||
c = (char*)opop_v(stack);
|
c = (char*)opop_v(stack);
|
||||||
oc += strlcpy(oc, c, TOKENSIZE-(oc-buffer));
|
bytes = (int)strlcpy(oc, c, size);
|
||||||
|
if (bytes<(int)size) oc += bytes;
|
||||||
|
else oc += size;
|
||||||
bfree(c);
|
bfree(c);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
*oc++=*ic++;
|
if (size>0) { *oc++=*ic++; --size; }
|
||||||
|
else ++ic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue