forked from github/server
Eigener Block für BOTSCHAFTen im NR Ausserdem den ungenutzten REPORT Befehl entfernt.
This commit is contained in:
parent
a04cb3efbd
commit
dda37aaee6
|
@ -2034,21 +2034,6 @@ mail_cmd(unit * u, struct order * ord)
|
|||
}
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
report_option(unit * u, const char * sec, struct order * ord)
|
||||
{
|
||||
const messageclass * mc;
|
||||
const char *s;
|
||||
|
||||
mc = mc_find(sec);
|
||||
|
||||
if (mc == NULL) {
|
||||
cmistake(u, ord, 135, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
s = getstrtoken();
|
||||
}
|
||||
|
||||
static int
|
||||
banner_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
|
@ -2123,28 +2108,6 @@ password_cmd(unit * u, struct order * ord)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
report_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const char * s;
|
||||
int i;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
s = getstrtoken();
|
||||
|
||||
i = atoi(s);
|
||||
sprintf(buf, "%d", i);
|
||||
if (!strcmp(buf, s)) {
|
||||
/* int level;
|
||||
level = geti();
|
||||
not implemented yet. set individual levels for f->msglevels */
|
||||
} else {
|
||||
report_option(u, s, ord);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
send_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
|
@ -2225,10 +2188,6 @@ set_passw(void)
|
|||
if (password_cmd(u, ord)!=0) ord = NULL;
|
||||
break;
|
||||
|
||||
case K_REPORT:
|
||||
if (report_cmd(u, ord)!=0) ord = NULL;
|
||||
break;
|
||||
|
||||
case K_SEND:
|
||||
if (send_cmd(u, ord)!=0) ord = NULL;
|
||||
break;
|
||||
|
|
|
@ -585,24 +585,24 @@ rpunit(FILE * F, const faction * f, const unit * u, int indent, int mode)
|
|||
static void
|
||||
rp_messages(FILE * F, message_list * msgs, faction * viewer, int indent, boolean categorized)
|
||||
{
|
||||
messageclass * category;
|
||||
nrsection * section;
|
||||
if (!msgs) return;
|
||||
for (category=msgclasses; category; category=category->next) {
|
||||
for (section = sections; section; section=section->next) {
|
||||
int k = 0;
|
||||
struct mlist * m = msgs->begin;
|
||||
while (m) {
|
||||
/* messagetype * mt = m->type; */
|
||||
if (strcmp(nr_section(m->msg), category->name)==0) {
|
||||
if (strcmp(nr_section(m->msg), section->name)==0) {
|
||||
char lbuf[8192];
|
||||
|
||||
if (!k && categorized) {
|
||||
const char * category_title;
|
||||
const char * section_title;
|
||||
char cat_identifier[24];
|
||||
|
||||
rnl(F);
|
||||
sprintf(cat_identifier, "section_%s", category->name);
|
||||
category_title = LOC(viewer->locale, cat_identifier);
|
||||
centre(F, category_title, true);
|
||||
sprintf(cat_identifier, "section_%s", section->name);
|
||||
section_title = LOC(viewer->locale, cat_identifier);
|
||||
centre(F, section_title, true);
|
||||
rnl(F);
|
||||
k = 1;
|
||||
}
|
||||
|
|
|
@ -381,7 +381,6 @@ const char *keywords[MAXKEYWORDS] =
|
|||
"ZERSTOEREN",
|
||||
"ZUECHTEN",
|
||||
"DEFAULT",
|
||||
"REPORT",
|
||||
"URSPRUNG",
|
||||
"EMAIL",
|
||||
"MEINUNG",
|
||||
|
|
|
@ -403,7 +403,6 @@ enum {
|
|||
K_DESTROY,
|
||||
K_BREED,
|
||||
K_DEFAULT,
|
||||
K_REPORT,
|
||||
K_URSPRUNG,
|
||||
K_EMAIL,
|
||||
K_VOTE,
|
||||
|
|
|
@ -58,37 +58,6 @@ typedef struct msg_setting {
|
|||
#include "region.h"
|
||||
#include "eressea.h"
|
||||
|
||||
messageclass * msgclasses;
|
||||
|
||||
const messageclass *
|
||||
mc_find(const char * name)
|
||||
{
|
||||
messageclass ** mcp = &msgclasses;
|
||||
if (name==NULL) return NULL;
|
||||
for (;*mcp;mcp=&(*mcp)->next) {
|
||||
messageclass * mc = *mcp;
|
||||
if (!strcmp(mc->name, name)) break;
|
||||
}
|
||||
return *mcp;
|
||||
}
|
||||
|
||||
const messageclass *
|
||||
mc_add(const char * name)
|
||||
{
|
||||
messageclass ** mcp = &msgclasses;
|
||||
if (name==NULL) return NULL;
|
||||
for (;*mcp;mcp=&(*mcp)->next) {
|
||||
messageclass * mc = *mcp;
|
||||
if (!strcmp(mc->name, name)) break;
|
||||
}
|
||||
if (!*mcp) {
|
||||
messageclass * mc = calloc(sizeof(messageclass), 1);
|
||||
mc->name = strdup(name);
|
||||
*mcp = mc;
|
||||
}
|
||||
return *mcp;
|
||||
}
|
||||
|
||||
static void
|
||||
arg_set(variant args[], const message_type * mtype, const char * buffer, variant v)
|
||||
{
|
||||
|
|
|
@ -21,7 +21,6 @@ extern "C" {
|
|||
#include <util/message.h>
|
||||
|
||||
struct message;
|
||||
struct messageclass;
|
||||
struct faction;
|
||||
struct msglevel;
|
||||
|
||||
|
@ -36,11 +35,6 @@ typedef struct message_list {
|
|||
|
||||
extern void free_messagelist(message_list * msgs);
|
||||
|
||||
typedef struct messageclass {
|
||||
struct messageclass * next;
|
||||
const char * name;
|
||||
} messageclass;
|
||||
|
||||
typedef struct msglevel {
|
||||
/* used to set specialized msg-levels */
|
||||
struct msglevel *next;
|
||||
|
@ -53,11 +47,6 @@ extern struct message * msg_feedback(const struct unit *, struct order *cmd,
|
|||
const char * name, const char* sig, ...);
|
||||
extern struct message * add_message(struct message_list** pm, struct message * m);
|
||||
|
||||
/* message sections */
|
||||
extern struct messageclass * msgclasses;
|
||||
extern const struct messageclass * mc_add(const char * name);
|
||||
extern const struct messageclass * mc_find(const char * name);
|
||||
|
||||
#define ADDMSG(msgs, mcreate) { message * m = mcreate; if (m) { assert(m->refcount>=1); add_message(msgs, m); msg_release(m); } }
|
||||
|
||||
extern void cmistake(const struct unit * u, struct order *ord, int mno, int mtype);
|
||||
|
|
|
@ -1758,7 +1758,6 @@ parse_messages(xmlDocPtr doc)
|
|||
|
||||
section = xmlGetProp(node, BAD_CAST "section");
|
||||
if (section==NULL) section = BAD_CAST default_section;
|
||||
mc_add((const char*)section);
|
||||
|
||||
/* strings */
|
||||
xpath->node = node;
|
||||
|
|
|
@ -34,98 +34,135 @@ static nrmessage_type * messagetypes[NRT_MAXHASH];
|
|||
const char *
|
||||
nrt_string(const struct nrmessage_type *type)
|
||||
{
|
||||
return type->string;
|
||||
return type->string;
|
||||
}
|
||||
|
||||
nrmessage_type *
|
||||
nrt_find(const struct locale * lang, const struct message_type * mtype)
|
||||
{
|
||||
nrmessage_type * found = NULL;
|
||||
unsigned int hash = hashstring(mtype->name) % NRT_MAXHASH;
|
||||
nrmessage_type * type = messagetypes[hash];
|
||||
while (type) {
|
||||
if (type->mtype==mtype) {
|
||||
if (found==NULL) found = type;
|
||||
else if (type->lang==NULL) found = type;
|
||||
if (lang==type->lang) {
|
||||
found = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
type = type->next;
|
||||
}
|
||||
nrmessage_type * found = NULL;
|
||||
unsigned int hash = hashstring(mtype->name) % NRT_MAXHASH;
|
||||
nrmessage_type * type = messagetypes[hash];
|
||||
while (type) {
|
||||
if (type->mtype==mtype) {
|
||||
if (found==NULL) found = type;
|
||||
else if (type->lang==NULL) found = type;
|
||||
if (lang==type->lang) {
|
||||
found = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
type = type->next;
|
||||
}
|
||||
if (lang && found->lang!=lang) {
|
||||
log_warning(("could not find nr-type %s for locale %s, substituting with %s\n",
|
||||
mtype->name, locale_name(lang), locale_name(found->lang)));
|
||||
}
|
||||
return found;
|
||||
return found;
|
||||
}
|
||||
|
||||
nrsection * sections;
|
||||
|
||||
const nrsection *
|
||||
section_find(const char * name)
|
||||
{
|
||||
nrsection ** mcp = §ions;
|
||||
if (name==NULL) return NULL;
|
||||
for (;*mcp;mcp=&(*mcp)->next) {
|
||||
nrsection * mc = *mcp;
|
||||
if (!strcmp(mc->name, name)) break;
|
||||
}
|
||||
return *mcp;
|
||||
}
|
||||
|
||||
const nrsection *
|
||||
section_add(const char * name)
|
||||
{
|
||||
nrsection ** mcp = §ions;
|
||||
if (name==NULL) return NULL;
|
||||
for (;*mcp;mcp=&(*mcp)->next) {
|
||||
nrsection * mc = *mcp;
|
||||
if (!strcmp(mc->name, name)) break;
|
||||
}
|
||||
if (!*mcp) {
|
||||
nrsection * mc = calloc(sizeof(nrsection), 1);
|
||||
mc->name = strdup(name);
|
||||
*mcp = mc;
|
||||
}
|
||||
return *mcp;
|
||||
}
|
||||
|
||||
void
|
||||
nrt_register(const struct message_type * mtype, const struct locale * lang, const char * string, int level, const char * section)
|
||||
{
|
||||
unsigned int hash = hashstring(mtype->name) % NRT_MAXHASH;
|
||||
nrmessage_type * nrt = messagetypes[hash];
|
||||
while (nrt && (nrt->lang!=lang || nrt->mtype!=mtype)) {
|
||||
nrt = nrt->next;
|
||||
}
|
||||
if (!nrt) {
|
||||
int i;
|
||||
char zNames[256];
|
||||
char * c = zNames;
|
||||
nrt = malloc(sizeof(nrmessage_type));
|
||||
nrt->lang = lang;
|
||||
nrt->mtype = mtype;
|
||||
nrt->next = messagetypes[hash];
|
||||
nrt->level=level;
|
||||
if (section) nrt->section = strdup(section);
|
||||
else nrt->section = NULL;
|
||||
messagetypes[hash] = nrt;
|
||||
assert(string && *string);
|
||||
nrt->string = strdup(string);
|
||||
unsigned int hash = hashstring(mtype->name) % NRT_MAXHASH;
|
||||
nrmessage_type * nrt = messagetypes[hash];
|
||||
while (nrt && (nrt->lang!=lang || nrt->mtype!=mtype)) {
|
||||
nrt = nrt->next;
|
||||
}
|
||||
if (!nrt) {
|
||||
int i;
|
||||
char zNames[256];
|
||||
char * c = zNames;
|
||||
nrt = malloc(sizeof(nrmessage_type));
|
||||
nrt->lang = lang;
|
||||
nrt->mtype = mtype;
|
||||
nrt->next = messagetypes[hash];
|
||||
nrt->level=level;
|
||||
if (section) {
|
||||
const nrsection * s = section_find(section);
|
||||
if (s==NULL) {
|
||||
s = section_add(section);
|
||||
}
|
||||
nrt->section = s->name;
|
||||
}
|
||||
else nrt->section = NULL;
|
||||
messagetypes[hash] = nrt;
|
||||
assert(string && *string);
|
||||
nrt->string = strdup(string);
|
||||
*c = '\0';
|
||||
for (i=0;i!=mtype->nparameters;++i) {
|
||||
if (i!=0) *c++ = ' ';
|
||||
c+= strlen(strcpy(c, mtype->pnames[i]));
|
||||
}
|
||||
nrt->vars = strdup(zNames);
|
||||
/* TODO: really necessary to strdup them all? here? better to extend the caller? hash? */
|
||||
}
|
||||
for (i=0;i!=mtype->nparameters;++i) {
|
||||
if (i!=0) *c++ = ' ';
|
||||
c+= strlen(strcpy(c, mtype->pnames[i]));
|
||||
}
|
||||
nrt->vars = strdup(zNames);
|
||||
/* TODO: really necessary to strdup them all? here? better to extend the caller? hash? */
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
struct nrmessage_type * nrt = nrt_find(lang, msg->type);
|
||||
|
||||
if (nrt) {
|
||||
const char * m = translate(nrt->string, userdata, nrt->vars, msg->parameters);
|
||||
if (m) {
|
||||
return strlcpy(buffer, m, size);
|
||||
} else {
|
||||
log_error(("Couldn't render message %s\n", nrt->mtype->name));
|
||||
}
|
||||
}
|
||||
if (nrt) {
|
||||
const char * m = translate(nrt->string, userdata, nrt->vars, msg->parameters);
|
||||
if (m) {
|
||||
return strlcpy(buffer, m, size);
|
||||
} else {
|
||||
log_error(("Couldn't render message %s\n", nrt->mtype->name));
|
||||
}
|
||||
}
|
||||
if (size>0 && buffer) buffer[0] = 0;
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
nr_level(const struct message *msg)
|
||||
{
|
||||
nrmessage_type * nrt = nrt_find(NULL, msg->type);
|
||||
return nrt->level;
|
||||
nrmessage_type * nrt = nrt_find(NULL, msg->type);
|
||||
return nrt->level;
|
||||
}
|
||||
|
||||
const char *
|
||||
nr_section(const struct message *msg)
|
||||
{
|
||||
nrmessage_type * nrt = nrt_find(default_locale, msg->type);
|
||||
return nrt->section;
|
||||
nrmessage_type * nrt = nrt_find(default_locale, msg->type);
|
||||
return nrt->section;
|
||||
}
|
||||
|
||||
const char *
|
||||
nrt_section(const nrmessage_type * nrt)
|
||||
{
|
||||
return nrt->section;
|
||||
return nrt->section;
|
||||
}
|
||||
|
|
|
@ -21,11 +21,18 @@ struct message;
|
|||
struct message_type;
|
||||
struct nrmessage_type;
|
||||
|
||||
typedef struct nrsection {
|
||||
char * name;
|
||||
struct nrsection * next;
|
||||
} nrsection;
|
||||
|
||||
extern nrsection * sections;
|
||||
|
||||
extern void nrt_register(const struct message_type * mtype,
|
||||
const struct locale * lang, const char * script,
|
||||
int level, const char * section);
|
||||
int level, const char * section);
|
||||
extern struct nrmessage_type * nrt_find(const struct locale *,
|
||||
const struct message_type *);
|
||||
const struct message_type *);
|
||||
extern const char * nrt_string(const struct nrmessage_type *type);
|
||||
extern const char * nrt_section(const struct nrmessage_type * mt);
|
||||
|
||||
|
|
|
@ -674,7 +674,10 @@
|
|||
|
||||
<!--Meldungssektionen -->
|
||||
<string name="section_events">
|
||||
<text locale="de">Meldungen und Ereignisse</text>
|
||||
<text locale="de">Ereignisse</text>
|
||||
</string>
|
||||
<string name="section_mail">
|
||||
<text locale="de">Botschaften</text>
|
||||
</string>
|
||||
<string name="section_errors">
|
||||
<text locale="de">Warnungen und Fehler</text>
|
||||
|
|
|
@ -257,8 +257,11 @@
|
|||
<text locale="en">an unknown unit</text>
|
||||
</string>
|
||||
|
||||
<string name="section_mail">
|
||||
<text locale="en">Dispatches</text>
|
||||
</string>
|
||||
<string name="section_events">
|
||||
<text locale="en">Messages and Events</text>
|
||||
<text locale="en">Events</text>
|
||||
</string>
|
||||
<string name="section_errors">
|
||||
<text locale="en">Warnings and Errors</text>
|
||||
|
|
|
@ -611,7 +611,7 @@
|
|||
<text locale="fr">"$unit($unit) in $region($region): '$order($command)' - $race($race,0) do not give things away."</text>
|
||||
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - $race($race,0) do not give things away."</text>
|
||||
</message>
|
||||
<message name="regionmessage" section="events">
|
||||
<message name="regionmessage" section="mail">
|
||||
<type>
|
||||
<arg name="sender" type="unit"/>
|
||||
<arg name="region" type="region"/>
|
||||
|
@ -620,7 +620,7 @@
|
|||
<text locale="de">"Eine Botschaft von $unit($sender) aus $region($region): '$string'"</text>
|
||||
<text locale="en">"A message by $unit($sender) from $region($region): '$string'"</text>
|
||||
</message>
|
||||
<message name="unitmessage" section="events">
|
||||
<message name="unitmessage" section="mail">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
<arg name="region" type="region"/>
|
||||
|
|
Loading…
Reference in New Issue