Zu lange Kampfmeldung zerstört immer noch den Server.

This commit is contained in:
Enno Rehling 2005-06-17 19:12:55 +00:00
parent 71cbf35a72
commit 5971f1caf5
3 changed files with 22 additions and 28 deletions

View File

@ -66,6 +66,7 @@
#endif
/* util includes */
#include <util/bsdstring.h>
#include <functions.h>
#include <goodies.h>
#include <base36.h>
@ -816,26 +817,21 @@ rp_messages(FILE * F, message_list * msgs, faction * viewer, int indent, boolean
int k = 0;
struct mlist * m = msgs->begin;
while (m) {
boolean debug = viewer->options & want(O_DEBUG);
#ifdef MSG_LEVELS
if (!debug && get_msglevel(viewer->warnings, viewer->msglevels, m->type) < m->level) continue;
#endif
/* messagetype * mt = m->type; */
if (strcmp(nr_section(m->msg), category->name)==0)
{
char lbuf[8192], *s = lbuf;
nr_render(m->msg, viewer->locale, s, sizeof(lbuf), viewer);
char lbuf[8192], *bufp = lbuf;
size_t rsize, size = sizeof(lbuf);
if (!k && categorized) {
const char * name;
char cat_identifier[24];
sprintf(cat_identifier, "section_%s", category->name);
name = LOC(viewer->locale, cat_identifier);
if (debug) {
if (name!=lbuf) strcpy(lbuf, name);
sprintf(lbuf+strlen(name), " [%s]", cat_identifier);
name = lbuf;
}
k = 1;
rnl(F);
if (centered) centre(F, name, true);
@ -847,22 +843,19 @@ rp_messages(FILE * F, message_list * msgs, faction * viewer, int indent, boolean
rnl(F);
}
if (indent>0) {
strcpy(lbuf, " ");
strcpy(lbuf+indent, s);
s = lbuf;
rsize = strlcpy(lbuf, " ", indent);
if (rsize>size) rsize = size-1;
size -= rsize;
bufp += rsize;
rsize = nr_render(m->msg, viewer->locale, bufp, size, viewer);
if (rsize>size) rsize = size-1;
size -= rsize;
bufp += rsize;
}
#ifdef MSG_LEVELS
if (debug) {
int mylevel = get_msglevel(viewer->warnings, viewer->msglevels, m->type);
int level = msg_level(m);
if (s!=lbuf) strcpy(lbuf, s);
sprintf(buf+strlen(s), " [%d:%d(%d)]", m->type->hashkey, level, mylevel);
s = lbuf;
rpsnr(F, lbuf, 2);
}
#endif
rpsnr(F, s, 2);
}
m=m->next;
m = m->next;
}
}
}

View File

@ -16,6 +16,7 @@
#include "nrmessage_struct.h"
/* util includes */
#include "bsdstring.h"
#include "log.h"
#include "message.h"
#include "language.h"
@ -88,21 +89,21 @@ nrt_register(const struct message_type * mtype, const struct locale * lang, cons
}
}
int
nr_render(const struct message * msg, const struct locale * lang, char * buffer, size_t bufsize, const void * userdata)
size_t
nr_render(const struct message * msg, const struct locale * lang, char * buffer, size_t size, const void * userdata)
{
struct nrmessage_type * nrt = nrt_find(lang, msg->type);
if (nrt) {
const char * m = translate(nrt->string, userdata, nrt->vars, msg->parameters);
if (m) {
strcpy(buffer, m);
return 0;
return strlcpy(buffer, m, size);
} else {
log_error(("Couldn't render message %s\n", nrt->mtype->name));
}
}
return -1;
if (size>0 && buffer) buffer[0] = 0;
return 0;
}
int

View File

@ -29,7 +29,7 @@ extern struct nrmessage_type * nrt_find(const struct locale *,
extern const char * nrt_string(const struct nrmessage_type *type);
extern const char * nrt_section(const struct nrmessage_type * mt);
extern int nr_render(const struct message * msg, const struct locale * lang,
extern size_t nr_render(const struct message * msg, const struct locale * lang,
char * buffer, size_t size, const void * userdata);
extern int nr_level(const struct message *msg);
extern const char * nr_section(const struct message *msg);