diff --git a/res/e3a/spells.xml b/res/e3a/spells.xml
index 4bb3470d8..12c52e8df 100644
--- a/res/e3a/spells.xml
+++ b/res/e3a/spells.xml
@@ -594,7 +594,7 @@
-
+
diff --git a/res/eressea/spells.xml b/res/eressea/spells.xml
index 015d64a7e..f7d81abfb 100644
--- a/res/eressea/spells.xml
+++ b/res/eressea/spells.xml
@@ -337,7 +337,7 @@
-
+
diff --git a/src/report.c b/src/report.c
index de44bc43d..9125cebdb 100644
--- a/src/report.c
+++ b/src/report.c
@@ -536,11 +536,17 @@ void nr_spell_syntax(stream *out, spellbook_entry * sbe, const struct locale *la
locp = LOC(lang, mkname("spellpar", substr));
syntaxp = substr + 1;
}
- bytes = (int)_snprintf(bufp, size, " <%s>", locp);
+ if (*params == '?') {
+ ++params;
+ bytes = (int)_snprintf(bufp, size, " [<%s>]", locp);
+ }
+ else {
+ bytes = (int)_snprintf(bufp, size, " <%s>", locp);
+ }
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} else {
- log_error("unknown spell parameter %c for spell", cp, sp->sname);
+ log_error("unknown spell parameter %c for spell %s", cp, sp->sname);
}
}
*bufp = 0;
diff --git a/src/reports.test.c b/src/reports.test.c
index da1c41a14..0955e8a6f 100644
--- a/src/reports.test.c
+++ b/src/reports.test.c
@@ -313,22 +313,17 @@ static void setup_spell_fixture(spell_fixture * spf) {
spf->sp = test_create_spell();
spellbook_add(spf->spb, spf->sp, 1);
spf->sbe = spellbook_get(spf->spb, spf->sp);
-
}
-static void test_spell_syntax(CuTest *tc, char *msg, spell_fixture *spell, char *syntax) {
+static void check_spell_syntax(CuTest *tc, char *msg, spell_fixture *spell, char *syntax) {
stream strm;
char buf[1024];
char *linestart, *newline;
size_t len;
mstream_init(&strm);
-
-
nr_spell_syntax(&strm, spell->sbe, spell->lang);
-
strm.api->rewind(strm.handle);
-
len = strm.api->read(strm.handle, buf, sizeof(buf));
buf[len] = '\0';
@@ -360,55 +355,53 @@ static void test_write_spell_syntax(CuTest *tc) {
test_cleanup();
setup_spell_fixture(&spell);
- test_spell_syntax(tc, "vanilla", &spell, " ZAUBERE \"Testzauber\"");
+ check_spell_syntax(tc, "vanilla", &spell, " ZAUBERE \"Testzauber\"");
spell.sp->sptyp |= FARCASTING;
- test_spell_syntax(tc, "far", &spell, " ZAUBERE [REGION x y] \"Testzauber\"");
+ check_spell_syntax(tc, "far", &spell, " ZAUBERE [REGION x y] \"Testzauber\"");
spell.sp->sptyp |= SPELLLEVEL;
- test_spell_syntax(tc, "farlevel", &spell, " ZAUBERE [REGION x y] [STUFE n] \"Testzauber\"");
+ check_spell_syntax(tc, "farlevel", &spell, " ZAUBERE [REGION x y] [STUFE n] \"Testzauber\"");
spell.sp->sptyp = 0;
set_parameter(spell, "kc");
- test_spell_syntax(tc, "kc", &spell, " ZAUBERE \"Testzauber\" ( REGION | EINHEIT | SCHIFF | BURG )");
+ check_spell_syntax(tc, "kc", &spell, " ZAUBERE \"Testzauber\" ( REGION | EINHEIT | SCHIFF | BURG )");
spell.sp->sptyp |= BUILDINGSPELL;
- test_spell_syntax(tc, "kc typed", &spell, " ZAUBERE \"Testzauber\" BURG ");
+ check_spell_syntax(tc, "kc typed", &spell, " ZAUBERE \"Testzauber\" BURG ");
spell.sp->sptyp = 0;
set_parameter(spell, "b");
- test_spell_syntax(tc, "b", &spell, " ZAUBERE \"Testzauber\" ");
+ check_spell_syntax(tc, "b", &spell, " ZAUBERE \"Testzauber\" ");
set_parameter(spell, "s");
- test_spell_syntax(tc, "s", &spell, " ZAUBERE \"Testzauber\" ");
+ check_spell_syntax(tc, "s", &spell, " ZAUBERE \"Testzauber\" ");
set_parameter(spell, "s+");
- test_spell_syntax(tc, "s+", &spell, " ZAUBERE \"Testzauber\" [ ...]");
+ check_spell_syntax(tc, "s+", &spell, " ZAUBERE \"Testzauber\" [ ...]");
set_parameter(spell, "u");
- test_spell_syntax(tc, "u", &spell, " ZAUBERE \"Testzauber\" ");
+ check_spell_syntax(tc, "u", &spell, " ZAUBERE \"Testzauber\" ");
set_parameter(spell, "r");
- test_spell_syntax(tc, "r", &spell, " ZAUBERE \"Testzauber\" ");
+ check_spell_syntax(tc, "r", &spell, " ZAUBERE \"Testzauber\" ");
set_parameter(spell, "bc");
free(spell.sp->syntax);
spell.sp->syntax = _strdup("hodor");
- test_spell_syntax(tc, "bc hodor", &spell, " ZAUBERE \"Testzauber\" ");
+ check_spell_syntax(tc, "bc hodor", &spell, " ZAUBERE \"Testzauber\" ");
free(spell.sp->syntax);
spell.sp->syntax = 0;
- /* There are no spells with optional parameters, so we don't force this, for now
set_parameter(spell, "c?");
free(spell.sp->syntax);
spell.sp->syntax = _strdup("hodor");
- test_spell_syntax(tc, "c?", &spell, " ZAUBERE \"Testzauber\" []");
+ check_spell_syntax(tc, "c?", &spell, " ZAUBERE \"Testzauber\" []");
free(spell.sp->syntax);
spell.sp->syntax = 0;
- */
set_parameter(spell, "kc+");
- test_spell_syntax(tc, "kc+", &spell,
+ check_spell_syntax(tc, "kc+", &spell,
" ZAUBERE \"Testzauber\" ( REGION | EINHEIT [ ...] | SCHIFF \n [ ...] | BURG [ ...] )");
test_cleanup();