Merge branch 'develop' into allies

This commit is contained in:
Enno Rehling 2018-10-26 14:13:28 +02:00
commit b3361e3ccb
1 changed files with 59 additions and 74 deletions

View File

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