forked from github/server
also apply noerror rules to msg_feedback.
This commit is contained in:
parent
b44c5e54bf
commit
868f4e6cef
|
@ -78,14 +78,15 @@ variant v)
|
|||
struct message *msg_feedback(const struct unit *u, struct order *ord,
|
||||
const char *name, const char *sig, ...)
|
||||
{
|
||||
va_list marker;
|
||||
const message_type *mtype = mt_find(name);
|
||||
char paramname[64];
|
||||
const char *ic = sig;
|
||||
variant args[16];
|
||||
variant var;
|
||||
memset(args, 0, sizeof(args));
|
||||
|
||||
if (ord && ord->_noerror) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!mtype) {
|
||||
log_warning("trying to create message of unknown type \"%s\"\n", name);
|
||||
if (!mt_find("missing_feedback")) {
|
||||
|
@ -103,10 +104,15 @@ struct message *msg_feedback(const struct unit *u, struct order *ord,
|
|||
var.v = (void *)ord;
|
||||
arg_set(args, mtype, "command", var);
|
||||
|
||||
if (sig) {
|
||||
const char *ic = sig;
|
||||
va_list marker;
|
||||
|
||||
va_start(marker, sig);
|
||||
while (*ic && !isalnum(*ic))
|
||||
ic++;
|
||||
while (*ic) {
|
||||
char paramname[64];
|
||||
char *oc = paramname;
|
||||
int i;
|
||||
|
||||
|
@ -137,7 +143,7 @@ struct message *msg_feedback(const struct unit *u, struct order *ord,
|
|||
ic++;
|
||||
}
|
||||
va_end(marker);
|
||||
|
||||
}
|
||||
return msg_create(mtype, args);
|
||||
}
|
||||
|
||||
|
@ -245,9 +251,6 @@ void addmessage(region * r, faction * f, const char *s, msg_t mtype, int level)
|
|||
message * msg_error(const unit * u, struct order *ord, int mno) {
|
||||
static char msgname[20];
|
||||
|
||||
if (ord && ord->_noerror) {
|
||||
return NULL;
|
||||
}
|
||||
if (fval(u->faction, FFL_NPC)) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ static void test_noerror(CuTest *tc) {
|
|||
CuAssertTrue(tc, u->thisorder->_persistent);
|
||||
CuAssertTrue(tc, u->thisorder->_noerror);
|
||||
CuAssertPtrEquals(tc, NULL, msg_error(u, u->thisorder, 100));
|
||||
CuAssertPtrEquals(tc, NULL, msg_feedback(u, u->thisorder, "error_unit_not_found", NULL));
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue