forked from github/server
more sbstring upgrades
This commit is contained in:
parent
4b5bd11f29
commit
5b0f3f9ea7
70
src/report.c
70
src/report.c
|
@ -79,6 +79,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include "util/bsdstring.h"
|
||||
#include <util/goodies.h>
|
||||
#include <util/language.h>
|
||||
#include <util/lists.h>
|
||||
|
@ -426,8 +427,6 @@ void nr_spell_syntax(char *buf, size_t size, spellbook_entry * sbe, const struct
|
|||
}
|
||||
}
|
||||
|
||||
#include "util/bsdstring.h"
|
||||
|
||||
void nr_spell(struct stream *out, spellbook_entry * sbe, const struct locale *lang)
|
||||
{
|
||||
int bytes, k, itemanz, costtyp;
|
||||
|
@ -1841,72 +1840,61 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f,
|
|||
static void
|
||||
nr_building(struct stream *out, const region *r, const building *b, const faction *f)
|
||||
{
|
||||
int i, bytes;
|
||||
int i;
|
||||
const char *name, *bname, *billusion = NULL;
|
||||
const struct locale *lang;
|
||||
char buffer[8192], *bufp = buffer;
|
||||
char buffer[8192];
|
||||
message *msg;
|
||||
size_t size = sizeof(buffer) - 1;
|
||||
size_t size;
|
||||
sbstring sbs;
|
||||
|
||||
assert(f);
|
||||
lang = f->locale;
|
||||
newline(out);
|
||||
bytes =
|
||||
snprintf(bufp, size, "%s, %s %d, ", buildingname(b), LOC(lang,
|
||||
"nr_size"), b->size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
sbs_init(&sbs, buffer, sizeof(buffer));
|
||||
|
||||
report_building(b, &bname, &billusion);
|
||||
|
||||
size = str_slprintf(buffer, sizeof(buffer), "%s, %s %d, ", buildingname(b),
|
||||
LOC(lang, "nr_size"), b->size);
|
||||
sbs.end += size;
|
||||
name = LOC(lang, billusion ? billusion : bname);
|
||||
bytes = (int)str_strlcpy(bufp, name, size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
sbs_strcat(&sbs, name);
|
||||
|
||||
if (billusion) {
|
||||
unit *owner = building_owner(b);
|
||||
if (owner && owner->faction == f) {
|
||||
/* illusion. report real type */
|
||||
name = LOC(lang, bname);
|
||||
bytes = snprintf(bufp, size, " (%s)", name);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
sbs_strcat(&sbs, " (");
|
||||
sbs_strcat(&sbs, LOC(lang, bname));
|
||||
sbs_strcat(&sbs, ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (!building_finished(b)) {
|
||||
bytes = (int)str_strlcpy(bufp, " ", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
bytes = (int)str_strlcpy(bufp, LOC(lang, "nr_building_inprogress"), size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
sbs_strcat(&sbs, " ");
|
||||
sbs_strcat(&sbs, LOC(lang, "nr_building_inprogress"));
|
||||
}
|
||||
|
||||
if (b->besieged > 0 && r->seen.mode >= seen_lighthouse) {
|
||||
msg = msg_message("nr_building_besieged", "soldiers diff", b->besieged,
|
||||
b->besieged - b->size * SIEGEFACTOR);
|
||||
bytes = (int)nr_render(msg, lang, bufp, size, f);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
|
||||
size = nr_render(msg, lang, sbs.end, sbs.size - (sbs.end - sbs.begin), f);
|
||||
sbs.end += size;
|
||||
|
||||
msg_release(msg);
|
||||
}
|
||||
i = 0;
|
||||
if (b->display && b->display[0]) {
|
||||
bytes = (int)str_strlcpy(bufp, "; ", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
bytes = (int)str_strlcpy(bufp, b->display, size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
sbs_strcat(&sbs, "; ");
|
||||
sbs_strcat(&sbs, b->display);
|
||||
i = b->display[strlen(b->display) - 1];
|
||||
}
|
||||
|
||||
if (i != '!' && i != '?' && i != '.') {
|
||||
bytes = (int)str_strlcpy(bufp, ".", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
sbs_strcat(&sbs, ".");
|
||||
}
|
||||
*bufp = 0;
|
||||
paragraph(out, buffer, 2, 0, 0);
|
||||
|
||||
if (r->seen.mode >= seen_lighthouse) {
|
||||
|
@ -1916,14 +1904,10 @@ nr_building(struct stream *out, const region *r, const building *b, const factio
|
|||
|
||||
static void nr_paragraph(struct stream *out, message * m, faction * f)
|
||||
{
|
||||
int bytes;
|
||||
char buf[4096], *bufp = buf;
|
||||
size_t size = sizeof(buf) - 1;
|
||||
char buf[4096];
|
||||
|
||||
assert(f);
|
||||
bytes = (int)nr_render(m, f->locale, bufp, size, f);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
nr_render(m, f->locale, buf, sizeof(buf), f);
|
||||
msg_release(m);
|
||||
|
||||
paragraph(out, buf, 0, 0, 0);
|
||||
|
@ -2027,6 +2011,8 @@ void report_travelthru(struct stream *out, region *r, const faction *f)
|
|||
}
|
||||
}
|
||||
|
||||
#include "util/bsdstring.h"
|
||||
|
||||
int
|
||||
report_plaintext(const char *filename, report_context * ctx,
|
||||
const char *bom)
|
||||
|
|
Loading…
Reference in New Issue