forked from github/server
refactoring: split out a module for race prefixes
This commit is contained in:
parent
767ef13722
commit
f1476c2167
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"prefixes": [
|
||||
"Dunkel",
|
||||
"Licht",
|
||||
"Klein",
|
||||
"Hoch",
|
||||
"Huegel",
|
||||
"Berg",
|
||||
"Wald",
|
||||
"Sumpf",
|
||||
"Schnee",
|
||||
"Sonnen",
|
||||
"Mond",
|
||||
"See",
|
||||
"Tal",
|
||||
"Schatten",
|
||||
"Hoehlen",
|
||||
"Blut",
|
||||
"Wild",
|
||||
"Chaos",
|
||||
"Nacht",
|
||||
"Nebel",
|
||||
"Grau",
|
||||
"Frost",
|
||||
"Finster",
|
||||
"Duester",
|
||||
"flame",
|
||||
"ice",
|
||||
"star",
|
||||
"black"
|
||||
]
|
||||
}
|
|
@ -86,6 +86,7 @@ set (ERESSEA_SRC
|
|||
names.c
|
||||
lighthouse.c
|
||||
reports.c
|
||||
prefix.c
|
||||
donations.c
|
||||
seen.c
|
||||
eressea.c
|
||||
|
@ -197,6 +198,7 @@ set(TESTS_SRC
|
|||
magic.test.c
|
||||
market.test.c
|
||||
move.test.c
|
||||
prefix.test.c
|
||||
skill.test.c
|
||||
spells.test.c
|
||||
spy.test.c
|
||||
|
|
|
@ -77,6 +77,21 @@ static void test_settings(CuTest * tc)
|
|||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_prefixes(CuTest * tc)
|
||||
{
|
||||
const char * data = "{\"prefixes\": [ "
|
||||
"\"snow\","
|
||||
"\"sea\","
|
||||
"\"dark\""
|
||||
"]}";
|
||||
cJSON *json = cJSON_Parse(data);
|
||||
|
||||
test_cleanup();
|
||||
json_config(json);
|
||||
// CuAssertStrEquals("dark", get_prefix("snow"));
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_races(CuTest * tc)
|
||||
{
|
||||
const char * data = "{\"races\": { \"orc\" : { "
|
||||
|
@ -553,6 +568,7 @@ CuSuite *get_jsonconf_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_spells);
|
||||
SUITE_ADD_TEST(suite, test_flags);
|
||||
SUITE_ADD_TEST(suite, test_settings);
|
||||
SUITE_ADD_TEST(suite, test_prefixes);
|
||||
SUITE_ADD_TEST(suite, test_infinitive_from_config);
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -212,22 +212,6 @@ bool allowed_dragon(const region * src, const region * target)
|
|||
return allowed_fly(src, target);
|
||||
}
|
||||
|
||||
char **race_prefixes = NULL;
|
||||
|
||||
extern void add_raceprefix(const char *prefix)
|
||||
{
|
||||
static size_t size = 4;
|
||||
static unsigned int next = 0;
|
||||
if (race_prefixes == NULL)
|
||||
race_prefixes = malloc(size * sizeof(char *));
|
||||
if (next + 1 == size) {
|
||||
size *= 2;
|
||||
race_prefixes = realloc(race_prefixes, size * sizeof(char *));
|
||||
}
|
||||
race_prefixes[next++] = _strdup(prefix);
|
||||
race_prefixes[next] = NULL;
|
||||
}
|
||||
|
||||
bool r_insectstalled(const region * r)
|
||||
{
|
||||
return fval(r->terrain, ARCTIC_REGION);
|
||||
|
|
|
@ -249,9 +249,6 @@ extern "C" {
|
|||
|
||||
extern bool r_insectstalled(const struct region *r);
|
||||
|
||||
extern void add_raceprefix(const char *);
|
||||
extern char **race_prefixes;
|
||||
|
||||
extern void write_race_reference(const struct race *rc,
|
||||
struct storage *store);
|
||||
extern variant read_race_reference(struct storage *store);
|
||||
|
|
|
@ -28,6 +28,7 @@ without prior permission by the authors of Eressea.
|
|||
#include "spell.h"
|
||||
#include "spellbook.h"
|
||||
#include "calendar.h"
|
||||
#include "prefix.h"
|
||||
|
||||
#include "vortex.h"
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include "spy.h"
|
||||
#include "study.h"
|
||||
#include "wormhole.h"
|
||||
#include "prefix.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include <kernel/alliance.h>
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#include "prefix.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char **race_prefixes = NULL;
|
||||
|
||||
void add_raceprefix(const char *prefix)
|
||||
{
|
||||
static size_t size = 4;
|
||||
static unsigned int next = 0;
|
||||
if (race_prefixes == NULL)
|
||||
race_prefixes = malloc(size * sizeof(char *));
|
||||
if (next + 1 == size) {
|
||||
size *= 2;
|
||||
race_prefixes = realloc(race_prefixes, size * sizeof(char *));
|
||||
}
|
||||
race_prefixes[next++] = _strdup(prefix);
|
||||
race_prefixes[next] = NULL;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef PREFIX_H
|
||||
#define PREFIX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void add_raceprefix(const char *);
|
||||
char **race_prefixes;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,9 @@
|
|||
#include "prefix.h"
|
||||
|
||||
#include <CuTest.h>
|
||||
|
||||
CuSuite *get_prefix_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
return suite;
|
||||
}
|
|
@ -80,6 +80,7 @@ int RunAllTests(void)
|
|||
RUN_TESTS(suite, ally);
|
||||
RUN_TESTS(suite, messages);
|
||||
/* gamecode */
|
||||
RUN_TESTS(suite, prefix);
|
||||
RUN_TESTS(suite, battle);
|
||||
RUN_TESTS(suite, donations);
|
||||
RUN_TESTS(suite, travelthru);
|
||||
|
|
Loading…
Reference in New Issue