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

View File

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