- German text in gmcmd will break UTF-8. hacked it to be English for now

- (re)moving mistake() function
This commit is contained in:
Enno Rehling 2007-09-02 15:17:09 +00:00
parent abca6ab6a1
commit 810e411821
4 changed files with 36 additions and 38 deletions

View File

@ -235,15 +235,6 @@ addmessage(region * r, faction * f, const char *s, msg_t mtype, int level)
caddmessage(r, f, s, mtype, level); caddmessage(r, f, s, mtype, level);
} }
void
mistake(const unit * u, struct order * ord, const char *comment, int mtype)
{
if (u->faction->no != MONSTER_FACTION) {
ADDMSG(&u->faction->msgs, msg_message("mistake",
"command error unit region", ord, comment, u, u->region));
}
}
void void
cmistake(const unit * u, struct order *ord, int mno, int mtype) cmistake(const unit * u, struct order *ord, int mno, int mtype)
{ {

View File

@ -50,8 +50,6 @@ extern struct message * add_message(struct message_list** pm, struct message * m
#define ADDMSG(msgs, mcreate) { message * m = mcreate; if (m) { assert(m->refcount>=1); add_message(msgs, m); msg_release(m); } } #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); extern void cmistake(const struct unit * u, struct order *ord, int mno, int mtype);
extern void mistake(const struct unit * u, struct order *ord, const char *text, int mtype);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -794,9 +794,9 @@ new_region(short x, short y)
region *r = rfindhash(x, y); region *r = rfindhash(x, y);
if (r) { if (r) {
fprintf(stderr, "\ndoppelte regionen entdeckt: %s(%d,%d)\n", regionname(r, NULL), x, y); log_error(("duplicate region discovered: %s(%d,%d)\n", regionname(r, NULL), x, y));
if (r->units) if (r->units)
fprintf(stderr, "doppelte region enthält einheiten\n"); log_error(("duplicate region contains units\n"));
return r; return r;
} }
r = calloc(1, sizeof(region)); r = calloc(1, sizeof(region));

View File

@ -54,6 +54,15 @@
** at_permissions ** at_permissions
**/ **/
static void
mistake(const unit * u, struct order * ord, const char *comment)
{
if (u->faction->no != MONSTER_FACTION) {
ADDMSG(&u->faction->msgs, msg_message("mistake",
"command error unit region", ord, comment, u, u->region));
}
}
static void static void
write_permissions(const attrib * a, FILE * F) write_permissions(const attrib * a, FILE * F)
{ {
@ -153,13 +162,13 @@ gm_create(const tnode * tnext, void * data, struct order * ord)
const char * iname = getstrtoken(); const char * iname = getstrtoken();
const item_type * itype = finditemtype(iname, u->faction->locale); const item_type * itype = finditemtype(iname, u->faction->locale);
if (itype==NULL) { if (itype==NULL) {
mistake(u, ord, "Unbekannter Gegenstand.", 0); mistake(u, ord, "unknown item.");
} else { } else {
attrib * a = a_find(permissions, &at_gmcreate); attrib * a = a_find(permissions, &at_gmcreate);
while (a && a->type==&at_gmcreate && a->data.v!=(void*)itype) a=a->next; while (a && a->type==&at_gmcreate && a->data.v!=(void*)itype) a=a->next;
if (a) i_change(&u->items, itype, i); if (a) i_change(&u->items, itype, i);
else mistake(u, ord, "Diesen Gegenstand darf deine Partei nicht machen.", 0); else mistake(u, ord, "your faction cannot create this item.");
} }
} }
} }
@ -186,7 +195,7 @@ gm_gate(const tnode * tnext, void * data, struct order * ord)
region * r = findregion(x, y); region * r = findregion(x, y);
building * b = findbuilding(id); building * b = findbuilding(id);
if (b==NULL || r==NULL || p!=rplane(b->region) || p!=rplane(r)) { if (b==NULL || r==NULL || p!=rplane(b->region) || p!=rplane(r)) {
mistake(u, ord, "Dieses Gebäude kann die Einheit nicht umwandeln.", 0); mistake(u, ord, "the unit cannot transform this building.");
return; return;
} else { } else {
/* checking permissions */ /* checking permissions */
@ -221,7 +230,7 @@ gm_terraform(const tnode * tnext, void * data, struct order * ord)
tnode * tokens = get_translations(u->faction->locale, UT_TERRAINS); tnode * tokens = get_translations(u->faction->locale, UT_TERRAINS);
if (r==NULL || p!=rplane(r)) { if (r==NULL || p!=rplane(r)) {
mistake(u, ord, "Diese Region kann die Einheit nicht umwandeln.", 0); mistake(u, ord, "region is in another plane.");
return; return;
} else { } else {
/* checking permissions */ /* checking permissions */
@ -250,7 +259,7 @@ gm_teleport(const tnode * tnext, void * data, struct order * ord)
region * r = findregion(x, y); region * r = findregion(x, y);
if (r==NULL || p!=rplane(r)) { if (r==NULL || p!=rplane(r)) {
mistake(u, ord, "In diese Region kann die Einheit nicht teleportieren.", 0); mistake(u, ord, "region is in another plane.");
} else if (to==NULL) { } else if (to==NULL) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", "")); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", ""));
} else if (rplane(to->region)!=rplane(r) && !ucontact(to, u)) { } else if (rplane(to->region)!=rplane(r) && !ucontact(to, u)) {
@ -259,7 +268,7 @@ gm_teleport(const tnode * tnext, void * data, struct order * ord)
/* checking permissions */ /* checking permissions */
attrib * permissions = a_find(u->faction->attribs, &at_permissions); attrib * permissions = a_find(u->faction->attribs, &at_permissions);
if (!permissions || !has_permission(permissions, atoi36("gmtele"))) { if (!permissions || !has_permission(permissions, atoi36("gmtele"))) {
mistake(u, ord, "Unzureichende Rechte für diesen Befehl.", 0); mistake(u, ord, "permission denied.");
} }
else move_unit(to, r, NULL); else move_unit(to, r, NULL);
} }
@ -276,12 +285,12 @@ gm_messageplane(const tnode * tnext, void * data, struct order * ord)
const struct plane * p = rplane(u->region); const struct plane * p = rplane(u->region);
const char * zmsg = getstrtoken(); const char * zmsg = getstrtoken();
if (p==NULL) { if (p==NULL) {
mistake(u, ord, "In diese Ebene kann keine Nachricht gesandt werden.", 0); mistake(u, ord, "In diese Ebene kann keine Nachricht gesandt werden.");
} else { } else {
/* checking permissions */ /* checking permissions */
attrib * permissions = a_find(u->faction->attribs, &at_permissions); attrib * permissions = a_find(u->faction->attribs, &at_permissions);
if (!permissions || !has_permission(permissions, atoi36("gmmsgr"))) { if (!permissions || !has_permission(permissions, atoi36("gmmsgr"))) {
mistake(u, ord, "Unzureichende Rechte für diesen Befehl.", 0); mistake(u, ord, "permission denied.");
} }
else { else {
message * msg = msg_message("msg_event", "string", zmsg); message * msg = msg_message("msg_event", "string", zmsg);
@ -314,7 +323,7 @@ gm_messagefaction(const tnode * tnext, void * data, struct order * ord)
plane * p = rplane(u->region); plane * p = rplane(u->region);
attrib * permissions = a_find(u->faction->attribs, &at_permissions); attrib * permissions = a_find(u->faction->attribs, &at_permissions);
if (!permissions || !has_permission(permissions, atoi36("gmmsgr"))) { if (!permissions || !has_permission(permissions, atoi36("gmmsgr"))) {
mistake(u, ord, "Unzureichende Rechte für diesen Befehl.", 0); mistake(u, ord, "permission denied.");
return; return;
} }
if (f!=NULL) { if (f!=NULL) {
@ -327,7 +336,7 @@ gm_messagefaction(const tnode * tnext, void * data, struct order * ord)
} }
} }
} }
mistake(u, ord, "An diese Partei kann keine Nachricht gesandt werden.", 0); mistake(u, ord, "cannot send messages to this faction.");
} }
/** /**
@ -345,12 +354,12 @@ gm_messageregion(const tnode * tnext, void * data, struct order * ord)
region * r = findregion(x, y); region * r = findregion(x, y);
if (r==NULL || p!=rplane(r)) { if (r==NULL || p!=rplane(r)) {
mistake(u, ord, "In diese Region kann keine Nachricht gesandt werden.", 0); mistake(u, ord, "region is in another plane.");
} else { } else {
/* checking permissions */ /* checking permissions */
attrib * permissions = a_find(u->faction->attribs, &at_permissions); attrib * permissions = a_find(u->faction->attribs, &at_permissions);
if (!permissions || !has_permission(permissions, atoi36("gmmsgr"))) { if (!permissions || !has_permission(permissions, atoi36("gmmsgr"))) {
mistake(u, ord, "Unzureichende Rechte für diesen Befehl.", 0); mistake(u, ord, "permission denied.");
} }
else { else {
add_message(&r->msgs, msg_message("msg_event", "string", msg)); add_message(&r->msgs, msg_message("msg_event", "string", msg));
@ -372,12 +381,12 @@ gm_killunit(const tnode * tnext, void * data, struct order * ord)
region * r = target->region; region * r = target->region;
if (r==NULL || p!=rplane(r)) { if (r==NULL || p!=rplane(r)) {
mistake(u, ord, "In dieser Region kann niemand getötet werden.", 0); mistake(u, ord, "region is in another plane.");
} else { } else {
/* checking permissions */ /* checking permissions */
attrib * permissions = a_find(u->faction->attribs, &at_permissions); attrib * permissions = a_find(u->faction->attribs, &at_permissions);
if (!permissions || !has_permission(permissions, atoi36("gmkill"))) { if (!permissions || !has_permission(permissions, atoi36("gmkill"))) {
mistake(u, ord, "Unzureichende Rechte für diesen Befehl.", 0); mistake(u, ord, "permission denied.");
} }
else { else {
scale_number(target, 0); scale_number(target, 0);
@ -402,7 +411,7 @@ gm_killfaction(const tnode * tnext, void * data, struct order * ord)
plane * p = rplane(u->region); plane * p = rplane(u->region);
attrib * permissions = a_find(u->faction->attribs, &at_permissions); attrib * permissions = a_find(u->faction->attribs, &at_permissions);
if (!permissions || !has_permission(permissions, atoi36("gmkill"))) { if (!permissions || !has_permission(permissions, atoi36("gmkill"))) {
mistake(u, ord, "Unzureichende Rechte für diesen Befehl.", 0); mistake(u, ord, "permission denied.");
return; return;
} }
if (f!=NULL) { if (f!=NULL) {
@ -419,7 +428,7 @@ gm_killfaction(const tnode * tnext, void * data, struct order * ord)
} }
} }
} }
mistake(u, ord, "Aus dieser Partei kann niemand gelöscht werden.", 0); mistake(u, ord, "cannot remove a unit from this faction.");
} }
/** /**
@ -443,12 +452,12 @@ gm_messageunit(const tnode * tnext, void * data, struct order * ord)
r = target->region; r = target->region;
if (r==NULL || p!=rplane(r)) { if (r==NULL || p!=rplane(r)) {
mistake(u, ord, "In diese Region kann keine Nachricht gesandt werden.", 0); mistake(u, ord, "region is in another plane.");
} else { } else {
/* checking permissions */ /* checking permissions */
attrib * permissions = a_find(u->faction->attribs, &at_permissions); attrib * permissions = a_find(u->faction->attribs, &at_permissions);
if (!permissions || !has_permission(permissions, atoi36("gmmsgu"))) { if (!permissions || !has_permission(permissions, atoi36("gmmsgu"))) {
mistake(u, ord, "Unzureichende Rechte für diesen Befehl.", 0); mistake(u, ord, "permission denied.");
} }
else { else {
add_message(&target->faction->msgs, add_message(&target->faction->msgs,
@ -474,12 +483,12 @@ gm_give(const tnode * tnext, void * data, struct order * ord)
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", "")); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", ""));
} else if (itype==NULL || i_get(u->items, itype)==0) { } else if (itype==NULL || i_get(u->items, itype)==0) {
/* unknown or not enough */ /* unknown or not enough */
mistake(u, ord, "So einen Gegenstand hat die Einheit nicht.", 0); mistake(u, ord, "invalid item or item not found.");
} else { } else {
/* checking permissions */ /* checking permissions */
attrib * permissions = a_find(u->faction->attribs, &at_permissions); attrib * permissions = a_find(u->faction->attribs, &at_permissions);
if (!permissions || !has_permission(permissions, atoi36("gmgive"))) { if (!permissions || !has_permission(permissions, atoi36("gmgive"))) {
mistake(u, ord, "Unzureichende Rechte für diesen Befehl.", 0); mistake(u, ord, "permission denied.");
} }
else { else {
int i = i_get(u->items, itype); int i = i_get(u->items, itype);
@ -509,12 +518,12 @@ gm_take(const tnode * tnext, void * data, struct order * ord)
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", "")); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", ""));
} else if (itype==NULL || i_get(to->items, itype)==0) { } else if (itype==NULL || i_get(to->items, itype)==0) {
/* unknown or not enough */ /* unknown or not enough */
mistake(u, ord, "So einen Gegenstand hat die Einheit nicht.", 0); mistake(u, ord, "invalid item or item not found.");
} else { } else {
/* checking permissions */ /* checking permissions */
attrib * permissions = a_find(u->faction->attribs, &at_permissions); attrib * permissions = a_find(u->faction->attribs, &at_permissions);
if (!permissions || !has_permission(permissions, atoi36("gmtake"))) { if (!permissions || !has_permission(permissions, atoi36("gmtake"))) {
mistake(u, ord, "Unzureichende Rechte für diesen Befehl.", 0); mistake(u, ord, "permission denied.");
} }
else { else {
int i = i_get(to->items, itype); int i = i_get(to->items, itype);
@ -544,15 +553,15 @@ gm_skill(const tnode * tnext, void * data, struct order * ord)
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", "")); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", ""));
} else if (skill==NOSKILL || skill==SK_MAGIC || skill==SK_ALCHEMY) { } else if (skill==NOSKILL || skill==SK_MAGIC || skill==SK_ALCHEMY) {
/* unknown or not enough */ /* unknown or not enough */
mistake(u, ord, "Dieses Talent ist unbekannt, oder kann nicht erhöht werden.", 0); mistake(u, ord, "unknown skill, or skill cannot be raised.");
} else if (num<0 || num>30) { } else if (num<0 || num>30) {
/* sanity check failed */ /* sanity check failed */
mistake(u, ord, "Der gewählte Wert ist nicht zugelassen.", 0); mistake(u, ord, "invalid value.");
} else { } else {
/* checking permissions */ /* checking permissions */
attrib * permissions = a_find(u->faction->attribs, &at_permissions); attrib * permissions = a_find(u->faction->attribs, &at_permissions);
if (!permissions || !has_permission(permissions, atoi36("gmskil"))) { if (!permissions || !has_permission(permissions, atoi36("gmskil"))) {
mistake(u, ord, "Unzureichende Rechte für diesen Befehl.", 0); mistake(u, ord, "permission denied.");
} }
else { else {
set_level(to, skill, num); set_level(to, skill, num);