diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml
index 75f57a6b0..c9a2ae616 100644
--- a/res/core/de/strings.xml
+++ b/res/core/de/strings.xml
@@ -7574,4 +7574,22 @@
+
+ Groaamm...
+
+
+ Tschrrrk...
+ Tshrrrk...
+
+
+ Schhhhh...
+ Shhhhhh...
+
+
+ Roaarrr...
+
+
+ Chrrr...
+
+
diff --git a/res/core/messages.xml b/res/core/messages.xml
index 410b673e1..99cf4d145 100644
--- a/res/core/messages.xml
+++ b/res/core/messages.xml
@@ -8446,10 +8446,10 @@
-
+
- "$unit($dragon): \"$if($eq($choice,0), "Groaaaam... ", "")$if($eq($choice,1), "Chrrrr... ", "")$if($eq($choice,2), "Roooarrr... ", "")$if($eq($choice,3), "Tschrrrk... ", "")$if($eq($choice,4), "Shhhhhh... ", "")$if($eq($number,1), "Ich rieche", "Wir riechen") etwas in $region($target)\"."
- "$unit($dragon): \"$if($eq($choice,0), "Groaaaam... ", "")$if($eq($choice,1), "Chrrrr... ", "")$if($eq($choice,2), "Roooarrr... ", "")$if($eq($choice,3), "Tschrrrk... ", "")$if($eq($choice,4), "Shhhhhh... ", "")$if($eq($number,1), "I smell", "We smell") something in $region($target)\"."
+ "$unit($dragon): \"$localize($growl) $if($eq($number,1), "Ich rieche", "Wir riechen") etwas in $region($target)\"."
+ "$unit($dragon): \"$localize($growl) $if($eq($number,1), "I smell", "We smell") something in $region($target)\"."
diff --git a/src/kernel/messages.c b/src/kernel/messages.c
index ecdc588a8..330c2feeb 100644
--- a/src/kernel/messages.c
+++ b/src/kernel/messages.c
@@ -194,7 +194,6 @@ message *msg_message(const char *name, const char *sig, ...)
}
else {
log_error("invalid parameter %s for message type %s\n", paramname, mtype->name);
- assert(!"invalid parameter for message type");
}
while (*ic && !isalnum(*ic))
ic++;
@@ -202,7 +201,6 @@ message *msg_message(const char *name, const char *sig, ...)
va_end(vargs);
if (argnum != mtype->nparameters) {
log_error("not enough parameters for message type %s\n", mtype->name);
- assert(!"not enough parameters for message type");
}
return msg_create(mtype, args);
diff --git a/src/monsters.c b/src/monsters.c
index e5f07c2f8..2fc2fcde3 100644
--- a/src/monsters.c
+++ b/src/monsters.c
@@ -550,8 +550,18 @@ static order *monster_seeks_target(region * r, unit * u)
void random_growl(const unit *u, region *target, int rand)
{
const struct locale *lang = u->faction->locale;
+ const char *growl;
+ switch(rand){
+ case 1: growl = "growl1"; break;
+ case 2: growl = "growl2"; break;
+ case 3: growl = "growl3"; break;
+ case 4: growl = "growl4"; break;
+ default: growl = "growl0";
+ }
+
+
if (rname(target, lang)) {
- message *msg = msg_message("dragon_growl", "dragon number target choice", u, u->number, target, rand);
+ message *msg = msg_message("dragon_growl", "dragon number target growl", u, u->number, target, growl);
ADDMSG(&u->region->msgs, msg);
}
}
diff --git a/src/monsters.test.c b/src/monsters.test.c
index 387ac3d5d..06c434940 100644
--- a/src/monsters.test.c
+++ b/src/monsters.test.c
@@ -209,12 +209,16 @@ static void test_dragon_moves(CuTest * tc)
CuAssertPtrNotNull(tc, find_order("move east", m));
- mt_register(mt_new_va("dragon_growl", "dragon:unit", "number:int", "target:region", "choice:int", 0));
+ mt_register(mt_new_va("dragon_growl", "dragon:unit", "number:int", "target:region", "growl:string", 0));
random_growl(m, findregion(1, 0), 3);
msg = test_get_last_message(r->msgs);
- assert_message(tc, msg, "dragon_growl", 4, m, 1, findregion(1,0), 3);
+ assert_message(tc, msg, "dragon_growl", 4);
+ assert_pointer_parameter(tc, msg, 0, m);
+ assert_int_parameter(tc, msg, 1, 1);
+ assert_pointer_parameter(tc, msg, 2, findregion(1,0));
+ assert_string_parameter(tc, msg, 3, "growl3");
test_cleanup();
}
diff --git a/src/tests.c b/src/tests.c
index c50065e9c..5b8c2a945 100644
--- a/src/tests.c
+++ b/src/tests.c
@@ -390,27 +390,27 @@ void test_clear_messages(faction *f) {
}
}
-void assert_message(CuTest * tc, message *msg, char *name, int numpar, ...)
-{
- va_list vargs;
+void assert_message(CuTest * tc, message *msg, char *name, int numpar) {
const message_type *mtype = msg->type;
assert(mtype);
- int i;
-
- va_start(vargs, numpar);
CuAssertStrEquals(tc, name, mtype->name);
CuAssertIntEquals(tc, numpar, mtype->nparameters);
- for (i = 0; i != mtype->nparameters; ++i) {
- variant value = va_arg(vargs, variant);
- if (mtype->types[i]->vtype == VAR_VOIDPTR) {
- CuAssertPtrEquals(tc, value.v, msg->parameters[i].v);
- } else if (mtype->types[i]->vtype == VAR_INT) {
- CuAssertIntEquals(tc, value.i, msg->parameters[i].i);
- } else {
- assert(!"unknown variant type");
- }
- }
+}
+
+void assert_pointer_parameter(CuTest * tc, message *msg, int index, void *arg) {
+ const message_type *mtype = (msg)->type;
+ CuAssertIntEquals((tc), VAR_VOIDPTR, mtype->types[(index)]->vtype);CuAssertPtrEquals((tc), (arg), msg->parameters[(index)].v);
+}
+
+void assert_int_parameter(CuTest * tc, message *msg, int index, int arg) {
+ const message_type *mtype = (msg)->type;
+ CuAssertIntEquals((tc), VAR_INT, mtype->types[(index)]->vtype);CuAssertIntEquals((tc), (arg), msg->parameters[(index)].i);
+}
+
+void assert_string_parameter(CuTest * tc, message *msg, int index, const char *arg) {
+ const message_type *mtype = (msg)->type;
+ CuAssertIntEquals((tc), VAR_VOIDPTR, mtype->types[(index)]->vtype);CuAssertStrEquals((tc), (arg), msg->parameters[(index)].v);
}
void disabled_test(void *suite, void (*test)(CuTest *), const char *name) {
diff --git a/src/tests.h b/src/tests.h
index fafb1755d..d18ff6456 100644
--- a/src/tests.h
+++ b/src/tests.h
@@ -54,7 +54,11 @@ extern "C" {
struct message * test_find_messagetype(struct message_list *msgs, const char *name);
struct message * test_get_last_message(struct message_list *mlist);
void test_clear_messages(struct faction *f);
- void assert_message(struct CuTest * tc, struct message *msg, char *name, int numpar, ...);
+ void assert_message(struct CuTest * tc, struct message *msg, char *name, int numpar);
+
+ void assert_pointer_parameter(struct CuTest * tc, struct message *msg, int index, void *arg);
+ void assert_int_parameter(struct CuTest * tc, struct message *msg, int index, int arg);
+ void assert_string_parameter(struct CuTest * tc, struct message *msg, int index, const char *arg);
void disabled_test(void *suite, void (*)(struct CuTest *), const char *name);
diff --git a/src/util/log.test.c b/src/util/log.test.c
index 2750d4b1e..95cbefa96 100644
--- a/src/util/log.test.c
+++ b/src/util/log.test.c
@@ -23,10 +23,10 @@ static void test_logging(CuTest * tc)
struct log_t * id2 = log_create(LOG_CPWARNING, str2, log_string);
CuAssertTrue(tc, id1!=id2);
log_warning("Hello %s", "World");
- CuAssertStrEquals(tc, str1, "World");
- CuAssertStrEquals(tc, str2, "World");
log_destroy(id1);
log_destroy(id2);
+ CuAssertStrEquals(tc, "World", str1);
+ CuAssertStrEquals(tc, "World", str2);
}
CuSuite *get_log_suite(void)