forked from github/server
Schnellere Reporterzeugung durch Vermeindung von scat()
This commit is contained in:
parent
2241847cfb
commit
5aaf6bfed5
|
@ -58,6 +58,13 @@
|
||||||
|
|
||||||
const char * g_reportdir;
|
const char * g_reportdir;
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
strlcpy(char * dst, const char * src) {
|
||||||
|
size_t s = 0;
|
||||||
|
while ((*dst++ = *src++)!=0) ++s;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
const char *neue_gebiete[] = {
|
const char *neue_gebiete[] = {
|
||||||
"none",
|
"none",
|
||||||
"illaun",
|
"illaun",
|
||||||
|
@ -184,8 +191,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
||||||
if (fspecial(u->faction, FS_HIDDEN))
|
if (fspecial(u->faction, FS_HIDDEN))
|
||||||
a_fshidden = a_find(u->attribs, &at_fshidden);
|
a_fshidden = a_find(u->attribs, &at_fshidden);
|
||||||
|
|
||||||
strcpy(bufp, unitname(u));
|
bufp += strlcpy(bufp, unitname(u));
|
||||||
bufp += strlen(bufp);
|
|
||||||
|
|
||||||
if (!isbattle) {
|
if (!isbattle) {
|
||||||
attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction);
|
attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction);
|
||||||
|
@ -193,37 +199,30 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
||||||
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;
|
||||||
strcat(bufp, ", ");
|
bufp += strlcpy(bufp, ", ");
|
||||||
strcat(bufp + 2, groupid(g, f));
|
bufp += strlcpy(bufp, groupid(g, f));
|
||||||
bufp += strlen(bufp);
|
|
||||||
}
|
}
|
||||||
if (getarnt) {
|
if (getarnt) {
|
||||||
strcat(bufp, ", ");
|
bufp += strlcpy(bufp, ", ");
|
||||||
strcat(bufp + 2, LOC(f->locale, "anonymous"));
|
bufp += strlcpy(bufp, LOC(f->locale, "anonymous"));
|
||||||
bufp += 2 + strlen(bufp);
|
|
||||||
} else if (a_otherfaction) {
|
} else if (a_otherfaction) {
|
||||||
faction * otherfaction = get_otherfaction(a_otherfaction);
|
faction * otherfaction = get_otherfaction(a_otherfaction);
|
||||||
if (otherfaction) {
|
if (otherfaction) {
|
||||||
strcat(bufp, ", ");
|
bufp += strlcpy(bufp, ", ");
|
||||||
strcat(bufp + 2, factionname(otherfaction));
|
bufp += strlcpy(bufp, factionname(otherfaction));
|
||||||
bufp += 2 + strlen(bufp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (getarnt) {
|
if (getarnt) {
|
||||||
strcat(bufp, ", ");
|
bufp += strlcpy(bufp, ", ");
|
||||||
strcat(bufp + 2, LOC(f->locale, "anonymous"));
|
bufp += strlcpy(bufp, LOC(f->locale, "anonymous"));
|
||||||
bufp += 2 + strlen(bufp);
|
|
||||||
} else {
|
} else {
|
||||||
scat(", ");
|
if (a_otherfaction && alliedunit(u, f, HELP_FSTEALTH)) {
|
||||||
if(a_otherfaction
|
faction * f = get_otherfaction(a_otherfaction);
|
||||||
&& alliedunit(u, f, HELP_FSTEALTH)) {
|
bufp += sprintf(bufp, ", %s (%s)", factionname(f), factionname(u->faction));
|
||||||
scat(factionname(get_otherfaction(a_otherfaction)));
|
|
||||||
scat(" (");
|
|
||||||
scat(factionname(u->faction));
|
|
||||||
scat(")");
|
|
||||||
} else {
|
} else {
|
||||||
scat(factionname(fv));
|
bufp += strlcpy(bufp, ", ");
|
||||||
|
bufp += strlcpy(bufp, factionname(fv));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,86 +230,85 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
||||||
#ifdef USE_UGROUPS
|
#ifdef USE_UGROUPS
|
||||||
if (u->faction == f) {
|
if (u->faction == f) {
|
||||||
attrib *a = a_find(u->attribs, &at_ugroup);
|
attrib *a = a_find(u->attribs, &at_ugroup);
|
||||||
if(a) {
|
if (a) {
|
||||||
ugroup *ug = findugroupid(u->faction, a->data.i);
|
ugroup *ug = findugroupid(u->faction, a->data.i);
|
||||||
if(is_ugroupleader(u, ug)) {
|
if (is_ugroupleader(u, ug)) {
|
||||||
scat("*");
|
strcpy(bufp++, "*");
|
||||||
}
|
}
|
||||||
scat(itoa36(ug->id));
|
bufp += strlcpy(bufp, itoa36(ug->id));
|
||||||
}
|
}
|
||||||
scat(", ");
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
scat(", ");
|
bufp += strlcpy(bufp, ", ");
|
||||||
|
|
||||||
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) {
|
||||||
scat("? ");
|
bufp += strlcpy(bufp, "? ");
|
||||||
} else {
|
} else {
|
||||||
icat(u->number);
|
bufp += sprintf(bufp, "%d ", u->number);
|
||||||
scat(" ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pzTmp = get_racename(u->attribs);
|
pzTmp = get_racename(u->attribs);
|
||||||
if (pzTmp) {
|
if (pzTmp) {
|
||||||
scat(pzTmp);
|
scat(pzTmp);
|
||||||
if (u->faction==f && fval(u->race, RCF_SHAPESHIFTANY)) {
|
if (u->faction==f && fval(u->race, RCF_SHAPESHIFTANY)) {
|
||||||
scat(" (");
|
bufp += strlcpy(bufp, " (");
|
||||||
scat(racename(f->locale, u, u->race));
|
bufp += strlcpy(bufp, racename(f->locale, u, u->race));
|
||||||
scat(")");
|
strcpy(bufp++, ")");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
scat(racename(f->locale, u, u->irace));
|
bufp += strlcpy(bufp, racename(f->locale, u, u->irace));
|
||||||
if (u->faction==f && u->irace!=u->race) {
|
if (u->faction==f && u->irace!=u->race) {
|
||||||
scat(" (");
|
bufp += strlcpy(bufp, " (");
|
||||||
scat(racename(f->locale, u, u->race));
|
bufp += strlcpy(bufp, racename(f->locale, u, u->race));
|
||||||
scat(")");
|
strcpy(bufp++, ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HEROES
|
#ifdef HEROES
|
||||||
if (fval(u, UFL_HERO) && (u->faction == f || omniscient(f))) {
|
if (fval(u, UFL_HERO) && (u->faction == f || omniscient(f))) {
|
||||||
scat(", ");
|
bufp += strlcpy(bufp, ", ");
|
||||||
scat(LOC(f->locale, "hero"));
|
bufp += strlcpy(bufp, LOC(f->locale, "hero"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* status */
|
/* status */
|
||||||
|
|
||||||
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));
|
||||||
scat(", ");
|
bufp += strlcpy(bufp, ", ");
|
||||||
scat(report_kampfstatus(u, f->locale));
|
bufp += strlcpy(bufp, report_kampfstatus(u, f->locale));
|
||||||
if (c || fval(u, UFL_HUNGER)) {
|
if (c || fval(u, UFL_HUNGER)) {
|
||||||
scat(" (");
|
bufp += strlcpy(bufp, " (");
|
||||||
if(c) scat(c);
|
if (c) bufp += strlcpy(bufp, c);
|
||||||
if(fval(u, UFL_HUNGER)) {
|
if (fval(u, UFL_HUNGER)) {
|
||||||
if (c) scat(", hungert");
|
if (c) bufp += strlcpy(bufp, ", hungert");
|
||||||
else scat("hungert");
|
else bufp += strlcpy(bufp, "hungert");
|
||||||
}
|
}
|
||||||
scat(")");
|
strcpy(bufp++, ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getguard(u)) scat(", bewacht die Region");
|
if (getguard(u)) bufp += strlcpy(bufp, ", bewacht die Region");
|
||||||
|
|
||||||
if (u->faction==f || telepath_see) {
|
if (u->faction==f || telepath_see) {
|
||||||
attrib * a = a_find(u->attribs, &at_follow);
|
attrib * a = a_find(u->attribs, &at_follow);
|
||||||
if (a) {
|
if (a) {
|
||||||
unit * uf = (unit*)a->data.v;
|
unit * uf = (unit*)a->data.v;
|
||||||
if (uf) {
|
if (uf) {
|
||||||
scat(", folgt ");
|
bufp += strlcpy(bufp, ", folgt ");
|
||||||
scat(itoa36(uf->no));
|
bufp += strlcpy(bufp, itoa36(uf->no));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((b = usiege(u))!=NULL) {
|
if ((b = usiege(u))!=NULL) {
|
||||||
scat(", belagert ");
|
bufp += strlcpy(bufp, ", belagert ");
|
||||||
scat(buildingname(b));
|
bufp += strlcpy(bufp, buildingname(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
dh = 0;
|
dh = 0;
|
||||||
if (u->faction == f || telepath_see) {
|
if (u->faction == f || telepath_see) {
|
||||||
for (sk = 0; sk != MAXSKILLS; sk++) {
|
for (sk = 0; sk != MAXSKILLS; sk++) {
|
||||||
spskill(f->locale, u, sk, &dh, 1);
|
spskill(f->locale, u, sk, &dh, 1);
|
||||||
|
bufp += strlen(bufp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,18 +348,16 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
||||||
int in;
|
int in;
|
||||||
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;
|
||||||
scat(", ");
|
bufp += strlcpy(bufp, ", ");
|
||||||
|
|
||||||
if (!dh) {
|
if (!dh) {
|
||||||
sprintf(buf+strlen(buf), "%s: ", LOC(f->locale, "nr_inventory"));
|
bufp += sprintf(bufp, "%s: ", LOC(f->locale, "nr_inventory"));
|
||||||
dh = 1;
|
dh = 1;
|
||||||
}
|
}
|
||||||
if (in == 1) {
|
if (in == 1) {
|
||||||
scat(ic);
|
bufp += strlcpy(bufp, ic);
|
||||||
} else {
|
} else {
|
||||||
icat(in);
|
bufp += sprintf(bufp, "%d %s", in, ic);
|
||||||
scat(" ");
|
|
||||||
scat(ic);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (show!=u->items) while (show) i_free(i_remove(&show, show));
|
if (show!=u->items) while (show) i_free(i_remove(&show, show));
|
||||||
|
@ -370,10 +366,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
||||||
dh = 0;
|
dh = 0;
|
||||||
|
|
||||||
if (is_mage(u) == true) {
|
if (is_mage(u) == true) {
|
||||||
scat(". Aura ");
|
bufp += sprintf(bufp, ". Aura %d/%d", get_spellpoints(u), max_spellpoints(u->region,u));
|
||||||
icat(get_spellpoints(u));
|
|
||||||
scat("/");
|
|
||||||
icat(max_spellpoints(u->region,u));
|
|
||||||
{
|
{
|
||||||
spell_ptr *spt;
|
spell_ptr *spt;
|
||||||
int t = effskill(u, SK_MAGIC);
|
int t = effskill(u, SK_MAGIC);
|
||||||
|
@ -382,12 +375,12 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
||||||
sp = find_spellbyid(spt->spellid);
|
sp = find_spellbyid(spt->spellid);
|
||||||
if (sp->level > t) continue;
|
if (sp->level > t) continue;
|
||||||
if (!dh) {
|
if (!dh) {
|
||||||
sprintf(buf+strlen(buf),", %s: ", LOC(f->locale, "nr_spells"));
|
bufp += sprintf(bufp, ", %s: ", LOC(f->locale, "nr_spells"));
|
||||||
dh = 1;
|
dh = 1;
|
||||||
} else {
|
} else {
|
||||||
scat(", ");
|
bufp += strlcpy(bufp, ", ");
|
||||||
}
|
}
|
||||||
scat(spell_name(sp, f->locale));
|
bufp += strlcpy(bufp, spell_name(sp, f->locale));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dh = 0;
|
dh = 0;
|
||||||
|
@ -399,24 +392,22 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
||||||
}
|
}
|
||||||
if(dh){
|
if(dh){
|
||||||
dh = 0;
|
dh = 0;
|
||||||
sprintf(buf+strlen(buf),", %s: ", LOC(f->locale, "nr_combatspells"));
|
bufp += sprintf(bufp, ", %s: ", LOC(f->locale, "nr_combatspells"));
|
||||||
for (i = 0; i < MAXCOMBATSPELLS; i++){
|
for (i = 0; i < MAXCOMBATSPELLS; i++){
|
||||||
if (!dh){
|
if (!dh){
|
||||||
dh = 1;
|
dh = 1;
|
||||||
}else{
|
} else {
|
||||||
scat(", ");
|
bufp += strlcpy(bufp, ", ");
|
||||||
}
|
}
|
||||||
sp = get_combatspell(u,i);
|
sp = get_combatspell(u,i);
|
||||||
if (sp) {
|
if (sp) {
|
||||||
int sl;
|
int sl;
|
||||||
scat(spell_name(sp, u->faction->locale));
|
bufp += strlcpy(bufp, spell_name(sp, u->faction->locale));
|
||||||
if((sl = get_combatspelllevel(u,i)) > 0) {
|
if ((sl = get_combatspelllevel(u,i)) > 0) {
|
||||||
scat(" (");
|
bufp += sprintf(bufp, " (%d)", sl);
|
||||||
icat(sl);
|
|
||||||
scat(")");
|
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
scat(LOC(f->locale, "nr_nospells"));
|
bufp += strlcpy(bufp, LOC(f->locale, "nr_nospells"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -424,9 +415,9 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
||||||
#ifdef LASTORDER
|
#ifdef LASTORDER
|
||||||
if (!isbattle && u->lastorder) {
|
if (!isbattle && u->lastorder) {
|
||||||
char * cmd = getcommand(u->lastorder);
|
char * cmd = getcommand(u->lastorder);
|
||||||
scat(", \"");
|
bufp += strlcpy(bufp, ", \"");
|
||||||
scat(cmd);
|
bufp += strlcpy(bufp, cmd);
|
||||||
scat("\"");
|
strcpy(bufp++, "\"");
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -434,19 +425,19 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
if (u->display && u->display[0]) {
|
if (u->display && u->display[0]) {
|
||||||
scat("; ");
|
bufp += strlcpy(bufp, "; ");
|
||||||
scat(u->display);
|
bufp += strlcpy(bufp, u->display);
|
||||||
|
|
||||||
i = u->display[strlen(u->display) - 1];
|
i = u->display[strlen(u->display) - 1];
|
||||||
}
|
}
|
||||||
if (i != '!' && i != '?' && i != '.')
|
if (i != '!' && i != '?' && i != '.')
|
||||||
scat(".");
|
strcpy(bufp++, ".");
|
||||||
|
|
||||||
pzTmp = uprivate(u);
|
pzTmp = uprivate(u);
|
||||||
if (u->faction == f && pzTmp) {
|
if (u->faction == f && pzTmp) {
|
||||||
scat(" (Bem: ");
|
bufp += strlcpy(bufp, " (Bem: ");
|
||||||
scat(pzTmp);
|
bufp += strlcpy(bufp, pzTmp);
|
||||||
scat(")");
|
bufp += strlcpy(bufp, ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
dh=0;
|
dh=0;
|
||||||
|
@ -464,7 +455,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef USE_UGROUPS
|
#ifdef USE_UGROUPS
|
||||||
int
|
int
|
||||||
bufunit_ugroupleader(const faction * f, const unit * u, int indent, int mode)
|
bufunit_ugroupleader(const faction * f, const unit * u, int indent, int mode)
|
||||||
{
|
{
|
||||||
int i, dh;
|
int i, dh;
|
||||||
|
|
Loading…
Reference in New Issue