Merge branch 'develop' of https://github.com/ennorehling/eressea into develop

This commit is contained in:
Enno Rehling 2018-10-26 16:08:26 +02:00
commit d1b4a47e1f

View file

@ -1514,93 +1514,78 @@ static void
show_allies(const faction * f, const ally * allies, char *buf, size_t size) show_allies(const faction * f, const ally * allies, char *buf, size_t size)
{ {
int allierte = 0; int allierte = 0;
int i = 0, h, hh = 0; int i = 0, h, hh = 0, dh = 0;
int bytes, dh = 0;
const ally *sf; const ally *sf;
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);
if (mode > 0) if (mode > 0) {
++allierte; ++allierte;
}
} }
for (sf = allies; sf; sf = sf->next) { if (allierte > 0) {
int mode = alliedgroup(NULL, f, sf->faction, sf, HELP_ALL); sbstring sbs;
if (mode <= 0) sbs_init(&sbs, buf, size);
continue;
i++; for (sf = allies; sf; sf = sf->next) {
if (dh) { int mode = alliedgroup(NULL, f, sf->faction, sf, HELP_ALL);
if (i == allierte) { if (mode <= 0)
bytes = (int)str_strlcpy(bufp, LOC(f->locale, "list_and"), size); continue;
i++;
if (dh) {
if (i == allierte) {
sbs_strcat(&sbs, LOC(f->locale, "list_and"));
}
else {
sbs_strcat(&sbs, ", ");
}
}
dh = 1;
hh = 0;
sbs_strcat(&sbs, factionname(sf->faction));
sbs_strcat(&sbs, " (");
if ((mode & HELP_ALL) == HELP_ALL) {
sbs_strcat(&sbs, LOC(f->locale, parameters[P_ANY]));
} }
else { else {
bytes = (int)str_strlcpy(bufp, ", ", size); for (h = 1; h <= HELP_TRAVEL; h *= 2) {
} int p = MAXPARAMS;
if (wrptr(&bufp, &size, bytes) != 0) if ((mode & h) == h) {
WARN_STATIC_BUFFER(); switch (h) {
} case HELP_TRAVEL:
dh = 1; p = P_TRAVEL;
hh = 0; break;
bytes = (int)str_strlcpy(bufp, factionname(sf->faction), size); case HELP_MONEY:
if (wrptr(&bufp, &size, bytes) != 0) p = P_MONEY;
WARN_STATIC_BUFFER(); break;
bytes = (int)str_strlcpy(bufp, " (", size); case HELP_FIGHT:
if (wrptr(&bufp, &size, bytes) != 0) p = P_FIGHT;
WARN_STATIC_BUFFER(); break;
if ((mode & HELP_ALL) == HELP_ALL) { case HELP_GIVE:
bytes = (int)str_strlcpy(bufp, LOC(f->locale, parameters[P_ANY]), size); p = P_GIVE;
if (wrptr(&bufp, &size, bytes) != 0) break;
WARN_STATIC_BUFFER(); case HELP_GUARD:
} p = P_GUARD;
else { break;
for (h = 1; h <= HELP_TRAVEL; h *= 2) { case HELP_FSTEALTH:
int p = MAXPARAMS; p = P_FACTIONSTEALTH;
if ((mode & h) == h) { break;
switch (h) { }
case HELP_TRAVEL: }
p = P_TRAVEL; if (p != MAXPARAMS) {
break; if (hh) {
case HELP_MONEY: sbs_strcat(&sbs, ", ");
p = P_MONEY; }
break; sbs_strcat(&sbs, LOC(f->locale, parameters[p]));
case HELP_FIGHT: hh = 1;
p = P_FIGHT;
break;
case HELP_GIVE:
p = P_GIVE;
break;
case HELP_GUARD:
p = P_GUARD;
break;
case HELP_FSTEALTH:
p = P_FACTIONSTEALTH;
break;
} }
} }
if (p != MAXPARAMS) {
if (hh) {
bytes = (int)str_strlcpy(bufp, ", ", size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
}
bytes = (int)str_strlcpy(bufp, LOC(f->locale, parameters[p]), size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
hh = 1;
}
} }
sbs_strcat(&sbs, ")");
} }
bytes = (int)str_strlcpy(bufp, ")", size); sbs_strcat(&sbs, ".");
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} }
bytes = (int)str_strlcpy(bufp, ".", size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
*bufp = 0;
} }
static void allies(struct stream *out, const faction * f) static void allies(struct stream *out, const faction * f)