forked from github/server
keyword_t and direction_t are moving into their own module.
direction parser gets new initialization function, for use in jsonconf later. add unit tests for directions.
This commit is contained in:
parent
812cb98dff
commit
a9f0538d8e
|
@ -1,6 +1,5 @@
|
||||||
[eressea]
|
[eressea]
|
||||||
base = .
|
base = .
|
||||||
load = setup.lua
|
|
||||||
report = reports
|
report = reports
|
||||||
verbose = 0
|
verbose = 0
|
||||||
lomem = 0
|
lomem = 0
|
||||||
|
@ -9,7 +8,6 @@ memcheck = 0
|
||||||
locales = de,en
|
locales = de,en
|
||||||
|
|
||||||
[config]
|
[config]
|
||||||
game = arda
|
|
||||||
source_dir = ..
|
source_dir = ..
|
||||||
maxnmrs = 10
|
maxnmrs = 10
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
local srcpath = config.source_dir
|
|
||||||
local respath = srcpath .. '/res'
|
|
||||||
local paths = {
|
|
||||||
'scripts/?.lua',
|
|
||||||
'core/scripts/?.lua',
|
|
||||||
'lunit/?.lua'
|
|
||||||
}
|
|
||||||
|
|
||||||
for idx, path in pairs(paths) do
|
|
||||||
package.path = srcpath .. '/' .. path .. ';' .. package.path
|
|
||||||
end
|
|
||||||
|
|
||||||
read_xml(respath..'/config-arda.xml', respath..'/catalog-arda.xml')
|
|
||||||
|
|
||||||
require "init"
|
|
|
@ -262,6 +262,7 @@
|
||||||
<F N="../src/kernel/curse.c"/>
|
<F N="../src/kernel/curse.c"/>
|
||||||
<F N="../src/items/demonseye.c"/>
|
<F N="../src/items/demonseye.c"/>
|
||||||
<F N="../src/util/dice.c"/>
|
<F N="../src/util/dice.c"/>
|
||||||
|
<F N="../src/direction.c"/>
|
||||||
<F N="../src/races/dragons.c"/>
|
<F N="../src/races/dragons.c"/>
|
||||||
<F N="../src/modules/dungeon.c"/>
|
<F N="../src/modules/dungeon.c"/>
|
||||||
<F N="../src/economy.c"/>
|
<F N="../src/economy.c"/>
|
||||||
|
@ -291,6 +292,7 @@
|
||||||
<F N="../src/json.c"/>
|
<F N="../src/json.c"/>
|
||||||
<F N="../src/kernel/jsonconf.c"/>
|
<F N="../src/kernel/jsonconf.c"/>
|
||||||
<F N="../src/attributes/key.c"/>
|
<F N="../src/attributes/key.c"/>
|
||||||
|
<F N="../src/keyword.c"/>
|
||||||
<F N="../src/triggers/killunit.c"/>
|
<F N="../src/triggers/killunit.c"/>
|
||||||
<F N="../src/util/language.c"/>
|
<F N="../src/util/language.c"/>
|
||||||
<F N="../src/laws.c"/>
|
<F N="../src/laws.c"/>
|
||||||
|
@ -415,6 +417,7 @@
|
||||||
<F N="../src/util/crmessage.h"/>
|
<F N="../src/util/crmessage.h"/>
|
||||||
<F N="../src/kernel/curse.h"/>
|
<F N="../src/kernel/curse.h"/>
|
||||||
<F N="../src/items/demonseye.h"/>
|
<F N="../src/items/demonseye.h"/>
|
||||||
|
<F N="../src/direction.h"/>
|
||||||
<F N="../src/modules/dungeon.h"/>
|
<F N="../src/modules/dungeon.h"/>
|
||||||
<F N="../src/economy.h"/>
|
<F N="../src/economy.h"/>
|
||||||
<F N="../src/util/encoding.h"/>
|
<F N="../src/util/encoding.h"/>
|
||||||
|
@ -442,6 +445,7 @@
|
||||||
<F N="../src/json.h"/>
|
<F N="../src/json.h"/>
|
||||||
<F N="../src/kernel/jsonconf.h"/>
|
<F N="../src/kernel/jsonconf.h"/>
|
||||||
<F N="../src/attributes/key.h"/>
|
<F N="../src/attributes/key.h"/>
|
||||||
|
<F N="../src/keyword.h"/>
|
||||||
<F N="../src/triggers/killunit.h"/>
|
<F N="../src/triggers/killunit.h"/>
|
||||||
<F N="../src/util/language.h"/>
|
<F N="../src/util/language.h"/>
|
||||||
<F N="../src/util/language_struct.h"/>
|
<F N="../src/util/language_struct.h"/>
|
||||||
|
|
|
@ -246,6 +246,7 @@
|
||||||
<F N="../src/util/bsdstring_test.c"/>
|
<F N="../src/util/bsdstring_test.c"/>
|
||||||
<F N="../src/kernel/building_test.c"/>
|
<F N="../src/kernel/building_test.c"/>
|
||||||
<F N="../src/kernel/curse_test.c"/>
|
<F N="../src/kernel/curse_test.c"/>
|
||||||
|
<F N="../src/direction_test.c"/>
|
||||||
<F N="../src/economy_test.c"/>
|
<F N="../src/economy_test.c"/>
|
||||||
<F N="../src/kernel/equipment_test.c"/>
|
<F N="../src/kernel/equipment_test.c"/>
|
||||||
<F N="../src/util/functions_test.c"/>
|
<F N="../src/util/functions_test.c"/>
|
||||||
|
@ -268,7 +269,8 @@
|
||||||
</Folder>
|
</Folder>
|
||||||
<Folder
|
<Folder
|
||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"/>
|
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
|
||||||
|
</Folder>
|
||||||
<Folder
|
<Folder
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
Filters="*.ico;*.cur;*.dlg"/>
|
Filters="*.ico;*.cur;*.dlg"/>
|
||||||
|
|
|
@ -58,6 +58,8 @@ ENDIF()
|
||||||
|
|
||||||
set (ERESSEA_SRC
|
set (ERESSEA_SRC
|
||||||
eressea.c
|
eressea.c
|
||||||
|
direction.c
|
||||||
|
keyword.c
|
||||||
json.c
|
json.c
|
||||||
creation.c
|
creation.c
|
||||||
creport.c
|
creport.c
|
||||||
|
@ -141,6 +143,7 @@ set(TESTS_SRC
|
||||||
test_eressea.c
|
test_eressea.c
|
||||||
tests.c
|
tests.c
|
||||||
tests_test.c
|
tests_test.c
|
||||||
|
direction_test.c
|
||||||
json_test.c
|
json_test.c
|
||||||
economy_test.c
|
economy_test.c
|
||||||
market_test.c
|
market_test.c
|
||||||
|
|
|
@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#ifndef H_ATTRIBUTE_ICEBERG
|
#ifndef H_ATTRIBUTE_ICEBERG
|
||||||
#define H_ATTRIBUTE_ICEBERG
|
#define H_ATTRIBUTE_ICEBERG
|
||||||
|
|
||||||
|
#include "direction.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "laws.h"
|
#include "laws.h"
|
||||||
#include "market.h"
|
#include "market.h"
|
||||||
#include "study.h"
|
#include "study.h"
|
||||||
|
#include "keyword.h"
|
||||||
|
|
||||||
#define PROC_LAND_REGION 0x0001
|
#define PROC_LAND_REGION 0x0001
|
||||||
#define PROC_LONG_ORDER 0x0002
|
#define PROC_LONG_ORDER 0x0002
|
||||||
|
@ -144,151 +145,152 @@ void process_name(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_group(void) {
|
void process_group(void) {
|
||||||
process_cmd(K_GROUP, group_cmd, 0);
|
process_cmd(K_GROUP, group_cmd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_origin(void) {
|
void process_origin(void) {
|
||||||
process_cmd(K_URSPRUNG, origin_cmd, 0);
|
process_cmd(K_URSPRUNG, origin_cmd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_quit(void) {
|
void process_quit(void) {
|
||||||
process_cmd(K_QUIT, quit_cmd, 0);
|
process_cmd(K_QUIT, quit_cmd, 0);
|
||||||
quit();
|
quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_study(void) {
|
void process_study(void) {
|
||||||
process_cmd(K_TEACH, teach_cmd, PROC_LONG_ORDER);
|
process_cmd(K_TEACH, teach_cmd, PROC_LONG_ORDER);
|
||||||
process_cmd(K_STUDY, learn_cmd, PROC_LONG_ORDER);
|
process_cmd(K_STUDY, learn_cmd, PROC_LONG_ORDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_movement(void) {
|
void process_movement(void) {
|
||||||
region * r;
|
region *r;
|
||||||
|
|
||||||
movement();
|
movement();
|
||||||
for (r=regions; r; r=r->next) {
|
for (r = regions; r; r = r->next) {
|
||||||
if (r->ships) {
|
if (r->ships) {
|
||||||
sinkships(r);
|
sinkships(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_use(void) {
|
void process_use(void) {
|
||||||
process_cmd(K_USE, use_cmd, 0);
|
process_cmd(K_USE, use_cmd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_leave(void) {
|
void process_leave(void) {
|
||||||
process_cmd(K_LEAVE, leave_cmd, 0);
|
process_cmd(K_LEAVE, leave_cmd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_promote(void) {
|
void process_promote(void) {
|
||||||
process_cmd(K_PROMOTION, promotion_cmd, 0);
|
process_cmd(K_PROMOTION, promotion_cmd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_renumber(void) {
|
void process_renumber(void) {
|
||||||
process_cmd(K_NUMBER, renumber_cmd, 0);
|
process_cmd(K_NUMBER, renumber_cmd, 0);
|
||||||
renumber_factions();
|
renumber_factions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_restack(void) {
|
void process_restack(void) {
|
||||||
restack_units();
|
restack_units();
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_setspells(void) {
|
void process_setspells(void) {
|
||||||
process_cmd(K_COMBATSPELL, combatspell_cmd, 0);
|
process_cmd(K_COMBATSPELL, combatspell_cmd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_sethelp(void) {
|
void process_sethelp(void) {
|
||||||
process_cmd(K_ALLY, ally_cmd, 0);
|
process_cmd(K_ALLY, ally_cmd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_contact(void) {
|
void process_contact(void) {
|
||||||
process_cmd(K_CONTACT, contact_cmd, 0);
|
process_cmd(K_CONTACT, contact_cmd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_magic(void) {
|
void process_magic(void) {
|
||||||
magic();
|
magic();
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_give_control(void) {
|
void process_give_control(void) {
|
||||||
process_cmd(K_CONTACT, give_control_cmd, 0);
|
process_cmd(K_CONTACT, give_control_cmd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_guard_on(void) {
|
void process_guard_on(void) {
|
||||||
process_cmd(K_GUARD, guard_on_cmd, PROC_LAND_REGION);
|
process_cmd(K_GUARD, guard_on_cmd, PROC_LAND_REGION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_explain(void) {
|
void process_explain(void) {
|
||||||
process_cmd(K_RESHOW, reshow_cmd, 0);
|
process_cmd(K_RESHOW, reshow_cmd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_reserve(void) {
|
void process_reserve(void) {
|
||||||
process_cmd(K_RESERVE, reserve_cmd, 0);
|
process_cmd(K_RESERVE, reserve_cmd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_claim(void) {
|
void process_claim(void) {
|
||||||
process_cmd(K_CLAIM, claim_cmd, 0);
|
process_cmd(K_CLAIM, claim_cmd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_follow(void) {
|
void process_follow(void) {
|
||||||
struct region *r;
|
struct region *r;
|
||||||
for (r = regions; r; r = r->next) {
|
for (r = regions; r; r = r->next) {
|
||||||
unit * u;
|
unit *u;
|
||||||
for (u=r->units; u; u=u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
follow_unit(u);
|
follow_unit(u);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_messages(void) {
|
void process_messages(void) {
|
||||||
process_cmd(K_MAIL, mail_cmd, 0);
|
process_cmd(K_MAIL, mail_cmd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_guard_off(void) {
|
void process_guard_off(void) {
|
||||||
process_cmd(K_GUARD, guard_off_cmd, PROC_LAND_REGION);
|
process_cmd(K_GUARD, guard_off_cmd, PROC_LAND_REGION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_regeneration(void) {
|
void process_regeneration(void) {
|
||||||
monthly_healing();
|
monthly_healing();
|
||||||
regenerate_aura();
|
regenerate_aura();
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_enter(int final) {
|
void process_enter(int final) {
|
||||||
region * r;
|
region *r;
|
||||||
for (r=regions; r; r=r->next) {
|
for (r = regions; r; r = r->next) {
|
||||||
do_enter(r, final);
|
do_enter(r, final);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_maintenance(void) {
|
void process_maintenance(void) {
|
||||||
region * r;
|
region *r;
|
||||||
for (r=regions; r; r=r->next) {
|
for (r = regions; r; r = r->next) {
|
||||||
unit * u;
|
unit *u;
|
||||||
for (u=r->units; u; u=u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
order * ord;
|
order *ord;
|
||||||
for (ord=u->orders; ord; ord=ord->next) {
|
for (ord = u->orders; ord; ord = ord->next) {
|
||||||
keyword_t kwd = get_keyword(ord);
|
keyword_t kwd = get_keyword(ord);
|
||||||
if (kwd==K_PAY) {
|
if (kwd == K_PAY) {
|
||||||
pay_cmd(u, ord);
|
pay_cmd(u, ord);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
maintain_buildings(r, 0);
|
||||||
}
|
}
|
||||||
maintain_buildings(r, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_alliance(void) {
|
void process_alliance(void) {
|
||||||
alliance_cmd();
|
alliance_cmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_idle(void) {
|
void process_idle(void) {
|
||||||
region * r;
|
region *r;
|
||||||
for (r=regions; r; r=r->next) {
|
for (r = regions; r; r = r->next) {
|
||||||
auto_work(r);
|
auto_work(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_set_default(void) {
|
void process_set_default(void) {
|
||||||
if (!global.disabled[K_DEFAULT]) {
|
if (!keyword_disabled(K_DEFAULT)) {
|
||||||
defaultorders();
|
defaultorders();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
#include <platform.h>
|
||||||
|
#include <kernel/config.h>
|
||||||
|
#include "direction.h"
|
||||||
|
|
||||||
|
#include "util/language.h"
|
||||||
|
#include "util/umlaut.h"
|
||||||
|
|
||||||
|
void init_direction(const struct locale *lang, direction_t dir, const char *str) {
|
||||||
|
void **tokens = get_translations(lang, UT_DIRECTIONS);
|
||||||
|
variant token;
|
||||||
|
token.i = dir;
|
||||||
|
addtoken(tokens, str, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_directions(const struct locale *lang) {
|
||||||
|
/* mit dieser routine kann man mehrere namen für eine direction geben,
|
||||||
|
* das ist für die hexes ideal. */
|
||||||
|
const struct {
|
||||||
|
const char *name;
|
||||||
|
direction_t direction;
|
||||||
|
} dirs[] = {
|
||||||
|
{ "dir_ne", D_NORTHEAST },
|
||||||
|
{ "dir_nw", D_NORTHWEST },
|
||||||
|
{ "dir_se", D_SOUTHEAST },
|
||||||
|
{ "dir_sw", D_SOUTHWEST },
|
||||||
|
{ "dir_east", D_EAST },
|
||||||
|
{ "dir_west", D_WEST },
|
||||||
|
{ "northeast", D_NORTHEAST },
|
||||||
|
{ "northwest", D_NORTHWEST },
|
||||||
|
{ "southeast", D_SOUTHEAST },
|
||||||
|
{ "southwest", D_SOUTHWEST },
|
||||||
|
{ "east", D_EAST },
|
||||||
|
{ "west", D_WEST },
|
||||||
|
{ "PAUSE", D_PAUSE },
|
||||||
|
{ NULL, NODIRECTION }
|
||||||
|
};
|
||||||
|
int i;
|
||||||
|
void **tokens = get_translations(lang, UT_DIRECTIONS);
|
||||||
|
|
||||||
|
for (i = 0; dirs[i].direction != NODIRECTION; ++i) {
|
||||||
|
variant token;
|
||||||
|
const char *str = locale_string(lang, dirs[i].name);
|
||||||
|
token.i = dirs[i].direction;
|
||||||
|
addtoken(tokens, str, token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
direction_t finddirection(const char *s, const struct locale *lang)
|
||||||
|
{
|
||||||
|
void **tokens = get_translations(lang, UT_DIRECTIONS);
|
||||||
|
variant token;
|
||||||
|
|
||||||
|
if (findtoken(*tokens, s, &token) == E_TOK_SUCCESS) {
|
||||||
|
return (direction_t)token.i;
|
||||||
|
}
|
||||||
|
return NODIRECTION;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef H_DIRECTION_H
|
||||||
|
#define H_DIRECTION_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct locale;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
D_NORTHWEST,
|
||||||
|
D_NORTHEAST,
|
||||||
|
D_EAST,
|
||||||
|
D_SOUTHEAST,
|
||||||
|
D_SOUTHWEST,
|
||||||
|
D_WEST,
|
||||||
|
MAXDIRECTIONS,
|
||||||
|
D_PAUSE,
|
||||||
|
D_SPECIAL,
|
||||||
|
NODIRECTION = -1
|
||||||
|
} direction_t;
|
||||||
|
|
||||||
|
direction_t finddirection(const char *s, const struct locale *);
|
||||||
|
void init_directions(const struct locale *lang);
|
||||||
|
void init_direction(const struct locale *lang, direction_t dir, const char *str);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#endif
|
||||||
|
#endif
|
|
@ -0,0 +1,54 @@
|
||||||
|
#include <platform.h>
|
||||||
|
#include "kernel/types.h"
|
||||||
|
#include "direction.h"
|
||||||
|
#include "util/language.h"
|
||||||
|
#include "tests.h"
|
||||||
|
|
||||||
|
#include <CuTest.h>
|
||||||
|
|
||||||
|
void test_init_directions(CuTest *tc) {
|
||||||
|
struct locale *lang;
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
lang = make_locale("en");
|
||||||
|
locale_setstring(lang, "dir_nw", "NW");
|
||||||
|
init_directions(lang);
|
||||||
|
CuAssertIntEquals(tc, D_NORTHWEST, finddirection("nw", lang));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_init_direction(CuTest *tc) {
|
||||||
|
struct locale *lang;
|
||||||
|
test_cleanup();
|
||||||
|
|
||||||
|
lang = make_locale("de");
|
||||||
|
init_direction(lang, D_NORTHWEST, "NW");
|
||||||
|
init_direction(lang, D_EAST, "OST");
|
||||||
|
CuAssertIntEquals(tc, D_NORTHWEST, finddirection("nw", lang));
|
||||||
|
CuAssertIntEquals(tc, D_EAST, finddirection("ost", lang));
|
||||||
|
CuAssertIntEquals(tc, NODIRECTION, finddirection("east", lang));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_finddirection_default(CuTest *tc) {
|
||||||
|
struct locale *lang;
|
||||||
|
test_cleanup();
|
||||||
|
lang = make_locale("en");
|
||||||
|
CuAssertIntEquals(tc, NODIRECTION, finddirection("potato", lang));
|
||||||
|
CuAssertIntEquals(tc, D_SOUTHWEST, finddirection("southwest", lang));
|
||||||
|
CuAssertIntEquals(tc, D_SOUTHEAST, finddirection("southeast", lang));
|
||||||
|
CuAssertIntEquals(tc, D_NORTHWEST, finddirection("northwest", lang));
|
||||||
|
CuAssertIntEquals(tc, D_NORTHEAST, finddirection("northeast", lang));
|
||||||
|
CuAssertIntEquals(tc, D_WEST, finddirection("west", lang));
|
||||||
|
CuAssertIntEquals(tc, D_EAST, finddirection("east", lang));
|
||||||
|
}
|
||||||
|
|
||||||
|
CuSuite *get_direction_suite(void)
|
||||||
|
{
|
||||||
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
SUITE_ADD_TEST(suite, test_init_direction);
|
||||||
|
SUITE_ADD_TEST(suite, test_init_directions);
|
||||||
|
SUITE_ADD_TEST(suite, test_finddirection_default);
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <kernel/types.h>
|
#include <kernel/types.h>
|
||||||
#include "economy.h"
|
#include "economy.h"
|
||||||
|
|
||||||
/* gamecode includes */
|
#include "direction.h"
|
||||||
#include "give.h"
|
#include "give.h"
|
||||||
#include "laws.h"
|
#include "laws.h"
|
||||||
#include "randenc.h"
|
#include "randenc.h"
|
||||||
|
|
|
@ -25,3 +25,4 @@ CuSuite *get_ally_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_ally);
|
SUITE_ADD_TEST(suite, test_ally);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "alchemy.h"
|
#include "alchemy.h"
|
||||||
#include "alliance.h"
|
#include "alliance.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
|
#include "direction.h"
|
||||||
#include "building.h"
|
#include "building.h"
|
||||||
#include "curse.h"
|
#include "curse.h"
|
||||||
#include "faction.h"
|
#include "faction.h"
|
||||||
|
@ -93,7 +94,7 @@ ship *getship(const struct region * r)
|
||||||
|
|
||||||
static void destroy_road(unit * u, int nmax, struct order *ord)
|
static void destroy_road(unit * u, int nmax, struct order *ord)
|
||||||
{
|
{
|
||||||
direction_t d = getdirection(u->faction->locale);
|
direction_t d = finddirection(getstrtoken(), u->faction->locale);
|
||||||
unit *u2;
|
unit *u2;
|
||||||
region *r = u->region;
|
region *r = u->region;
|
||||||
short n = (short)nmax;
|
short n = (short)nmax;
|
||||||
|
|
|
@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#define H_KRNL_BUILD
|
#define H_KRNL_BUILD
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "direction.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -32,6 +32,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "building.h"
|
#include "building.h"
|
||||||
#include "calendar.h"
|
#include "calendar.h"
|
||||||
#include "curse.h"
|
#include "curse.h"
|
||||||
|
#include "direction.h"
|
||||||
#include "faction.h"
|
#include "faction.h"
|
||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
|
@ -55,7 +56,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <util/attrib.h>
|
#include <util/attrib.h>
|
||||||
#include <util/base36.h>
|
#include <util/base36.h>
|
||||||
#include <util/bsdstring.h>
|
#include <util/bsdstring.h>
|
||||||
#include <critbit.h>
|
|
||||||
#include <util/crmessage.h>
|
#include <util/crmessage.h>
|
||||||
#include <util/event.h>
|
#include <util/event.h>
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
|
@ -80,6 +80,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
/* external libraries */
|
/* external libraries */
|
||||||
#include <iniparser.h>
|
#include <iniparser.h>
|
||||||
|
#include <critbit.h>
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -386,69 +387,6 @@ const char *parameters[MAXPARAMS] = {
|
||||||
"ALLIANZ"
|
"ALLIANZ"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *keywords[MAXKEYWORDS] = {
|
|
||||||
"//",
|
|
||||||
"BANNER",
|
|
||||||
"ARBEITEN",
|
|
||||||
"ATTACKIEREN",
|
|
||||||
"BEKLAUEN",
|
|
||||||
"BELAGERE",
|
|
||||||
"BENENNEN",
|
|
||||||
"BENUTZEN",
|
|
||||||
"BESCHREIBEN",
|
|
||||||
"BETRETEN",
|
|
||||||
"BEWACHEN",
|
|
||||||
"BOTSCHAFT",
|
|
||||||
"ENDE",
|
|
||||||
"FAHREN",
|
|
||||||
"NUMMER",
|
|
||||||
"FOLGEN",
|
|
||||||
"FORSCHEN",
|
|
||||||
"GIB",
|
|
||||||
"HELFEN",
|
|
||||||
"KAEMPFEN",
|
|
||||||
"KAMPFZAUBER",
|
|
||||||
"KAUFEN",
|
|
||||||
"KONTAKTIEREN",
|
|
||||||
"LEHREN",
|
|
||||||
"LERNEN",
|
|
||||||
"MACHEN",
|
|
||||||
"NACH",
|
|
||||||
"PASSWORT",
|
|
||||||
"REKRUTIEREN",
|
|
||||||
"RESERVIEREN",
|
|
||||||
"ROUTE",
|
|
||||||
"SABOTIEREN",
|
|
||||||
"OPTION",
|
|
||||||
"SPIONIEREN",
|
|
||||||
"STIRB",
|
|
||||||
"TARNEN",
|
|
||||||
"TRANSPORTIEREN",
|
|
||||||
"TREIBEN",
|
|
||||||
"UNTERHALTEN",
|
|
||||||
"VERKAUFEN",
|
|
||||||
"VERLASSEN",
|
|
||||||
"VERGESSEN",
|
|
||||||
"ZAUBERE",
|
|
||||||
"ZEIGEN",
|
|
||||||
"ZERSTOEREN",
|
|
||||||
"ZUECHTEN",
|
|
||||||
"DEFAULT",
|
|
||||||
"URSPRUNG",
|
|
||||||
"EMAIL",
|
|
||||||
"PIRATERIE",
|
|
||||||
"GRUPPE",
|
|
||||||
"SORTIEREN",
|
|
||||||
"GM",
|
|
||||||
"INFO",
|
|
||||||
"PRAEFIX",
|
|
||||||
"PFLANZEN",
|
|
||||||
"ALLIANZ",
|
|
||||||
"BEANSPRUCHEN",
|
|
||||||
"PROMOTION",
|
|
||||||
"BEZAHLEN",
|
|
||||||
};
|
|
||||||
|
|
||||||
const char *report_options[MAX_MSG] = {
|
const char *report_options[MAX_MSG] = {
|
||||||
"Kampf",
|
"Kampf",
|
||||||
"Ereignisse",
|
"Ereignisse",
|
||||||
|
@ -1346,34 +1284,6 @@ skill_t findskill(const char *s, const struct locale * lang)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyword_t findkeyword(const char *s, const struct locale * lang)
|
|
||||||
{
|
|
||||||
keyword_t result = NOKEYWORD;
|
|
||||||
char buffer[64];
|
|
||||||
|
|
||||||
assert(lang);
|
|
||||||
assert(s);
|
|
||||||
while (*s == '@') ++s;
|
|
||||||
|
|
||||||
if (*s) {
|
|
||||||
char * str = transliterate(buffer, sizeof(buffer)-sizeof(int), s);
|
|
||||||
|
|
||||||
if (str) {
|
|
||||||
int i;
|
|
||||||
const void * match;
|
|
||||||
void **tokens = get_translations(lang, UT_KEYWORDS);
|
|
||||||
critbit_tree *cb = (critbit_tree *)*tokens;
|
|
||||||
assert(cb);
|
|
||||||
if (cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) {
|
|
||||||
cb_get_kv(match, &i, sizeof(int));
|
|
||||||
result = (keyword_t)i;
|
|
||||||
return global.disabled[result] ? NOKEYWORD : result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NOKEYWORD;
|
|
||||||
}
|
|
||||||
|
|
||||||
param_t findparam(const char *s, const struct locale * lang)
|
param_t findparam(const char *s, const struct locale * lang)
|
||||||
{
|
{
|
||||||
param_t result = NOPARAM;
|
param_t result = NOPARAM;
|
||||||
|
@ -1906,57 +1816,7 @@ void *gc_add(void *p)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_directions(void ** root, const struct locale *lang)
|
void init_translations(const struct locale *lang, int ut, const char * (*string_cb)(int i), int maxstrings)
|
||||||
{
|
|
||||||
/* mit dieser routine kann man mehrere namen für eine direction geben,
|
|
||||||
* das ist für die hexes ideal. */
|
|
||||||
const struct {
|
|
||||||
const char *name;
|
|
||||||
int direction;
|
|
||||||
} dirs[] = {
|
|
||||||
{
|
|
||||||
"dir_ne", D_NORTHEAST}, {
|
|
||||||
"dir_nw", D_NORTHWEST}, {
|
|
||||||
"dir_se", D_SOUTHEAST}, {
|
|
||||||
"dir_sw", D_SOUTHWEST}, {
|
|
||||||
"dir_east", D_EAST}, {
|
|
||||||
"dir_west", D_WEST}, {
|
|
||||||
"northeast", D_NORTHEAST}, {
|
|
||||||
"northwest", D_NORTHWEST}, {
|
|
||||||
"southeast", D_SOUTHEAST}, {
|
|
||||||
"southwest", D_SOUTHWEST}, {
|
|
||||||
"east", D_EAST}, {
|
|
||||||
"west", D_WEST}, {
|
|
||||||
"PAUSE", D_PAUSE}, {
|
|
||||||
NULL, NODIRECTION}
|
|
||||||
};
|
|
||||||
int i;
|
|
||||||
void **tokens = get_translations(lang, UT_DIRECTIONS);
|
|
||||||
|
|
||||||
for (i = 0; dirs[i].direction != NODIRECTION; ++i) {
|
|
||||||
variant token;
|
|
||||||
token.i = dirs[i].direction;
|
|
||||||
addtoken(tokens, LOC(lang, dirs[i].name), token);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
direction_t finddirection(const char *s, const struct locale *lang)
|
|
||||||
{
|
|
||||||
void **tokens = get_translations(lang, UT_DIRECTIONS);
|
|
||||||
variant token;
|
|
||||||
|
|
||||||
if (findtoken(*tokens, s, &token) == E_TOK_SUCCESS) {
|
|
||||||
return (direction_t) token.i;
|
|
||||||
}
|
|
||||||
return NODIRECTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
direction_t getdirection(const struct locale * lang)
|
|
||||||
{
|
|
||||||
return finddirection(getstrtoken(), lang);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void init_translations(const struct locale *lang, int ut, const char * (*string_cb)(int i), int maxstrings)
|
|
||||||
{
|
{
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
void **tokens;
|
void **tokens;
|
||||||
|
@ -1986,12 +1846,6 @@ static void init_translations(const struct locale *lang, int ut, const char * (*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * keyword_key(int i)
|
|
||||||
{
|
|
||||||
assert(i<MAXKEYWORDS&& i>=0);
|
|
||||||
return keywords[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char * parameter_key(int i)
|
static const char * parameter_key(int i)
|
||||||
{
|
{
|
||||||
assert(i<MAXPARAMS && i>=0);
|
assert(i<MAXPARAMS && i>=0);
|
||||||
|
@ -2034,8 +1888,7 @@ static void init_locale(const struct locale *lang)
|
||||||
free(sstr);
|
free(sstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
tokens = get_translations(lang, UT_DIRECTIONS);
|
init_directions(lang);
|
||||||
init_directions(tokens, lang);
|
|
||||||
|
|
||||||
tokens = get_translations(lang, UT_RACES);
|
tokens = get_translations(lang, UT_RACES);
|
||||||
for (rc = races; rc; rc = rc->next) {
|
for (rc = races; rc; rc = rc->next) {
|
||||||
|
@ -2046,7 +1899,7 @@ static void init_locale(const struct locale *lang)
|
||||||
|
|
||||||
init_translations(lang, UT_PARAMS, parameter_key, MAXPARAMS);
|
init_translations(lang, UT_PARAMS, parameter_key, MAXPARAMS);
|
||||||
init_translations(lang, UT_SKILLS, skill_key, MAXSKILLS);
|
init_translations(lang, UT_SKILLS, skill_key, MAXSKILLS);
|
||||||
init_translations(lang, UT_KEYWORDS, keyword_key, MAXKEYWORDS);
|
// init_translations(lang, UT_KEYWORDS, keyword_key, MAXKEYWORDS);
|
||||||
|
|
||||||
tokens = get_translations(lang, UT_OPTIONS);
|
tokens = get_translations(lang, UT_OPTIONS);
|
||||||
for (i = 0; i != MAXOPTIONS; ++i) {
|
for (i = 0; i != MAXOPTIONS; ++i) {
|
||||||
|
@ -2434,7 +2287,7 @@ void guard(unit * u, unsigned int mask)
|
||||||
int besieged(const unit * u)
|
int besieged(const unit * u)
|
||||||
{
|
{
|
||||||
/* belagert kann man in schiffen und burgen werden */
|
/* belagert kann man in schiffen und burgen werden */
|
||||||
return (u && !global.disabled[K_BESIEGE]
|
return (u && !keyword_disabled(K_BESIEGE)
|
||||||
&& u->building && u->building->besieged
|
&& u->building && u->building->besieged
|
||||||
&& u->building->besieged >= u->building->size * SIEGEFACTOR);
|
&& u->building->besieged >= u->building->size * SIEGEFACTOR);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,6 @@ extern "C" {
|
||||||
|
|
||||||
/* ----------------- Befehle ----------------------------------- */
|
/* ----------------- Befehle ----------------------------------- */
|
||||||
|
|
||||||
extern const char *keywords[MAXKEYWORDS];
|
|
||||||
extern const char *parameters[MAXPARAMS];
|
extern const char *parameters[MAXPARAMS];
|
||||||
|
|
||||||
/** report options **/
|
/** report options **/
|
||||||
|
@ -108,8 +107,8 @@ extern "C" {
|
||||||
extern const char *options[MAXOPTIONS];
|
extern const char *options[MAXOPTIONS];
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
void init_translations(const struct locale *lang, int ut, const char * (*string_cb)(int i), int maxstrings);
|
||||||
extern int shipspeed(const struct ship *sh, const struct unit *u);
|
int shipspeed(const struct ship *sh, const struct unit *u);
|
||||||
|
|
||||||
#define i2b(i) ((bool)((i)?(true):(false)))
|
#define i2b(i) ((bool)((i)?(true):(false)))
|
||||||
|
|
||||||
|
@ -130,23 +129,22 @@ extern "C" {
|
||||||
extern int verbosity;
|
extern int verbosity;
|
||||||
|
|
||||||
/* parteinummern */
|
/* parteinummern */
|
||||||
extern bool faction_id_is_unused(int);
|
bool faction_id_is_unused(int);
|
||||||
|
|
||||||
/* leuchtturm */
|
/* leuchtturm */
|
||||||
extern bool check_leuchtturm(struct region *r, struct faction *f);
|
bool check_leuchtturm(struct region *r, struct faction *f);
|
||||||
extern void update_lighthouse(struct building *lh);
|
void update_lighthouse(struct building *lh);
|
||||||
extern int lighthouse_range(const struct building *b,
|
int lighthouse_range(const struct building *b,
|
||||||
const struct faction *f);
|
const struct faction *f);
|
||||||
|
|
||||||
/* skills */
|
/* skills */
|
||||||
extern int skill_limit(struct faction *f, skill_t sk);
|
int skill_limit(struct faction *f, skill_t sk);
|
||||||
extern int count_skill(struct faction *f, skill_t sk);
|
int count_skill(struct faction *f, skill_t sk);
|
||||||
|
|
||||||
/* direction, geography */
|
/* direction, geography */
|
||||||
extern const char *directions[];
|
extern const char *directions[];
|
||||||
extern direction_t finddirection(const char *s, const struct locale *);
|
|
||||||
|
|
||||||
extern int findoption(const char *s, const struct locale *lang);
|
int findoption(const char *s, const struct locale *lang);
|
||||||
|
|
||||||
/* special units */
|
/* special units */
|
||||||
void make_undead_unit(struct unit *);
|
void make_undead_unit(struct unit *);
|
||||||
|
@ -159,20 +157,16 @@ extern "C" {
|
||||||
unsigned int getuint(void);
|
unsigned int getuint(void);
|
||||||
int getint(void);
|
int getint(void);
|
||||||
|
|
||||||
direction_t getdirection(const struct locale *);
|
const char *igetstrtoken(const char *s);
|
||||||
|
|
||||||
extern const char *igetstrtoken(const char *s);
|
skill_t findskill(const char *s, const struct locale *lang);
|
||||||
|
|
||||||
extern skill_t findskill(const char *s, const struct locale *lang);
|
|
||||||
|
|
||||||
extern keyword_t findkeyword(const char *s, const struct locale *lang);
|
|
||||||
|
|
||||||
param_t findparam(const char *s, const struct locale *lang);
|
param_t findparam(const char *s, const struct locale *lang);
|
||||||
param_t findparam_ex(const char *s, const struct locale * lang);
|
param_t findparam_ex(const char *s, const struct locale * lang);
|
||||||
bool isparam(const char *s, const struct locale * lang, param_t param);
|
bool isparam(const char *s, const struct locale * lang, param_t param);
|
||||||
param_t getparam(const struct locale *lang);
|
param_t getparam(const struct locale *lang);
|
||||||
|
|
||||||
extern int getid(void);
|
int getid(void);
|
||||||
#define unitid(x) itoa36((x)->no)
|
#define unitid(x) itoa36((x)->no)
|
||||||
|
|
||||||
#define getshipid() getid()
|
#define getshipid() getid()
|
||||||
|
@ -183,39 +177,40 @@ extern "C" {
|
||||||
#define factionid(x) itoa36((x)->no)
|
#define factionid(x) itoa36((x)->no)
|
||||||
#define curseid(x) itoa36((x)->no)
|
#define curseid(x) itoa36((x)->no)
|
||||||
|
|
||||||
extern bool cansee(const struct faction *f, const struct region *r,
|
bool cansee(const struct faction *f, const struct region *r,
|
||||||
const struct unit *u, int modifier);
|
const struct unit *u, int modifier);
|
||||||
bool cansee_durchgezogen(const struct faction *f, const struct region *r,
|
bool cansee_durchgezogen(const struct faction *f, const struct region *r,
|
||||||
const struct unit *u, int modifier);
|
const struct unit *u, int modifier);
|
||||||
extern bool cansee_unit(const struct unit *u, const struct unit *target,
|
bool cansee_unit(const struct unit *u, const struct unit *target,
|
||||||
int modifier);
|
int modifier);
|
||||||
bool seefaction(const struct faction *f, const struct region *r,
|
bool seefaction(const struct faction *f, const struct region *r,
|
||||||
const struct unit *u, int modifier);
|
const struct unit *u, int modifier);
|
||||||
extern int effskill(const struct unit *u, skill_t sk);
|
int effskill(const struct unit *u, skill_t sk);
|
||||||
|
|
||||||
extern int lovar(double xpct_x2);
|
int lovar(double xpct_x2);
|
||||||
/* returns a value between [0..xpct_2], generated with two dice */
|
/* returns a value between [0..xpct_2], generated with two dice */
|
||||||
|
|
||||||
int distribute(int old, int new_value, int n);
|
int distribute(int old, int new_value, int n);
|
||||||
|
void init_locales(void);
|
||||||
|
|
||||||
int newunitid(void);
|
int newunitid(void);
|
||||||
int forbiddenid(int id);
|
int forbiddenid(int id);
|
||||||
int newcontainerid(void);
|
int newcontainerid(void);
|
||||||
|
|
||||||
extern struct unit *createunit(struct region *r, struct faction *f,
|
struct unit *createunit(struct region *r, struct faction *f,
|
||||||
int number, const struct race *rc);
|
int number, const struct race *rc);
|
||||||
extern void create_unitid(struct unit *u, int id);
|
void create_unitid(struct unit *u, int id);
|
||||||
extern bool getunitpeasants;
|
extern bool getunitpeasants;
|
||||||
extern struct unit *getunitg(const struct region *r, const struct faction *f);
|
struct unit *getunitg(const struct region *r, const struct faction *f);
|
||||||
extern struct unit *getunit(const struct region *r, const struct faction *f);
|
struct unit *getunit(const struct region *r, const struct faction *f);
|
||||||
|
|
||||||
extern int read_unitid(const struct faction *f, const struct region *r);
|
int read_unitid(const struct faction *f, const struct region *r);
|
||||||
|
|
||||||
extern int alliedunit(const struct unit *u, const struct faction *f2,
|
int alliedunit(const struct unit *u, const struct faction *f2,
|
||||||
int mode);
|
int mode);
|
||||||
extern int alliedfaction(const struct plane *pl, const struct faction *f,
|
int alliedfaction(const struct plane *pl, const struct faction *f,
|
||||||
const struct faction *f2, int mode);
|
const struct faction *f2, int mode);
|
||||||
extern int alliedgroup(const struct plane *pl, const struct faction *f,
|
int alliedgroup(const struct plane *pl, const struct faction *f,
|
||||||
const struct faction *f2, const struct ally *sf, int mode);
|
const struct faction *f2, const struct ally *sf, int mode);
|
||||||
|
|
||||||
struct faction *findfaction(int n);
|
struct faction *findfaction(int n);
|
||||||
|
@ -227,12 +222,12 @@ extern "C" {
|
||||||
struct unit *findunitr(const struct region *r, int n);
|
struct unit *findunitr(const struct region *r, int n);
|
||||||
struct region *findunitregion(const struct unit *su);
|
struct region *findunitregion(const struct unit *su);
|
||||||
|
|
||||||
extern char *estring(const char *s);
|
char *estring(const char *s);
|
||||||
extern char *estring_i(char *s);
|
char *estring_i(char *s);
|
||||||
extern char *cstring(const char *s);
|
char *cstring(const char *s);
|
||||||
extern char *cstring_i(char *s);
|
char *cstring_i(char *s);
|
||||||
extern const char *unitname(const struct unit *u);
|
const char *unitname(const struct unit *u);
|
||||||
extern char *write_unitname(const struct unit *u, char *buffer, size_t size);
|
char *write_unitname(const struct unit *u, char *buffer, size_t size);
|
||||||
|
|
||||||
typedef int (*cmp_building_cb) (const struct building * b,
|
typedef int (*cmp_building_cb) (const struct building * b,
|
||||||
const struct building * a);
|
const struct building * a);
|
||||||
|
@ -252,9 +247,9 @@ extern "C" {
|
||||||
#define HARVEST_WORK 0x00
|
#define HARVEST_WORK 0x00
|
||||||
#define HARVEST_TAXES 0x01
|
#define HARVEST_TAXES 0x01
|
||||||
int rule_blessed_harvest(void);
|
int rule_blessed_harvest(void);
|
||||||
extern int rule_give(void);
|
int rule_give(void);
|
||||||
extern int rule_alliance_limit(void);
|
int rule_alliance_limit(void);
|
||||||
extern int rule_faction_limit(void);
|
int rule_faction_limit(void);
|
||||||
|
|
||||||
#define COUNT_MONSTERS 0x01
|
#define COUNT_MONSTERS 0x01
|
||||||
#define COUNT_MIGRANTS 0x02
|
#define COUNT_MIGRANTS 0x02
|
||||||
|
@ -275,8 +270,6 @@ extern "C" {
|
||||||
int ispresent(const struct faction *f, const struct region *r);
|
int ispresent(const struct faction *f, const struct region *r);
|
||||||
|
|
||||||
int check_option(struct faction *f, int option);
|
int check_option(struct faction *f, int option);
|
||||||
extern void parse_kwd(keyword_t kword, int (*dofun) (struct unit *,
|
|
||||||
struct order *), bool thisorder);
|
|
||||||
|
|
||||||
/* Anzahl Personen in einer Einheit festlegen. NUR (!) mit dieser Routine,
|
/* Anzahl Personen in einer Einheit festlegen. NUR (!) mit dieser Routine,
|
||||||
* sonst großes Unglück. Durch asserts an ein paar Stellen abgesichert. */
|
* sonst großes Unglück. Durch asserts an ein paar Stellen abgesichert. */
|
||||||
|
@ -290,8 +283,8 @@ extern "C" {
|
||||||
void changeblockchaos(void);
|
void changeblockchaos(void);
|
||||||
|
|
||||||
/* intervall, in dem die regionen der partei zu finden sind */
|
/* intervall, in dem die regionen der partei zu finden sind */
|
||||||
extern struct region *firstregion(struct faction *f);
|
struct region *firstregion(struct faction *f);
|
||||||
extern struct region *lastregion(struct faction *f);
|
struct region *lastregion(struct faction *f);
|
||||||
|
|
||||||
void fhash(struct faction *f);
|
void fhash(struct faction *f);
|
||||||
void funhash(struct faction *f);
|
void funhash(struct faction *f);
|
||||||
|
@ -335,32 +328,32 @@ extern "C" {
|
||||||
/* Verhindert Abbau von Resourcen mit RTF_LIMITED */
|
/* Verhindert Abbau von Resourcen mit RTF_LIMITED */
|
||||||
#define GUARD_ALL 0xFFFF
|
#define GUARD_ALL 0xFFFF
|
||||||
|
|
||||||
extern void setstatus(struct unit *u, int status);
|
void setstatus(struct unit *u, int status);
|
||||||
/* !< sets combatstatus of a unit */
|
/* !< sets combatstatus of a unit */
|
||||||
extern void setguard(struct unit *u, unsigned int flags);
|
void setguard(struct unit *u, unsigned int flags);
|
||||||
/* !< setzt die guard-flags der Einheit */
|
/* !< setzt die guard-flags der Einheit */
|
||||||
extern unsigned int getguard(const struct unit *u);
|
unsigned int getguard(const struct unit *u);
|
||||||
/* liest die guard-flags der Einheit */
|
/* liest die guard-flags der Einheit */
|
||||||
extern void guard(struct unit *u, unsigned int mask);
|
void guard(struct unit *u, unsigned int mask);
|
||||||
/* Einheit setzt "BEWACHE", rassenspezifzisch.
|
/* Einheit setzt "BEWACHE", rassenspezifzisch.
|
||||||
* 'mask' kann einzelne flags zusätzlich und-maskieren.
|
* 'mask' kann einzelne flags zusätzlich und-maskieren.
|
||||||
*/
|
*/
|
||||||
unsigned int guard_flags(const struct unit *u);
|
unsigned int guard_flags(const struct unit *u);
|
||||||
|
|
||||||
extern bool hunger(int number, struct unit *u);
|
bool hunger(int number, struct unit *u);
|
||||||
extern int lifestyle(const struct unit *);
|
int lifestyle(const struct unit *);
|
||||||
extern int besieged(const struct unit *u);
|
int besieged(const struct unit *u);
|
||||||
extern int maxworkingpeasants(const struct region *r);
|
int maxworkingpeasants(const struct region *r);
|
||||||
extern bool has_horses(const struct unit *u);
|
bool has_horses(const struct unit *u);
|
||||||
extern int markets_module(void);
|
int markets_module(void);
|
||||||
extern int wage(const struct region *r, const struct faction *f,
|
int wage(const struct region *r, const struct faction *f,
|
||||||
const struct race *rc, int in_turn);
|
const struct race *rc, int in_turn);
|
||||||
extern int maintenance_cost(const struct unit *u);
|
int maintenance_cost(const struct unit *u);
|
||||||
extern struct message *movement_error(struct unit *u, const char *token,
|
struct message *movement_error(struct unit *u, const char *token,
|
||||||
struct order *ord, int error_code);
|
struct order *ord, int error_code);
|
||||||
extern bool move_blocked(const struct unit *u, const struct region *src,
|
bool move_blocked(const struct unit *u, const struct region *src,
|
||||||
const struct region *dest);
|
const struct region *dest);
|
||||||
extern void add_income(struct unit *u, int type, int want, int qty);
|
void add_income(struct unit *u, int type, int want, int qty);
|
||||||
|
|
||||||
/* movewhere error codes */
|
/* movewhere error codes */
|
||||||
enum {
|
enum {
|
||||||
|
@ -368,26 +361,26 @@ extern "C" {
|
||||||
E_MOVE_NOREGION, /* no region exists in this direction */
|
E_MOVE_NOREGION, /* no region exists in this direction */
|
||||||
E_MOVE_BLOCKED /* cannot see this region, there is a blocking connection. */
|
E_MOVE_BLOCKED /* cannot see this region, there is a blocking connection. */
|
||||||
};
|
};
|
||||||
extern int movewhere(const struct unit *u, const char *token,
|
int movewhere(const struct unit *u, const char *token,
|
||||||
struct region *r, struct region **resultp);
|
struct region *r, struct region **resultp);
|
||||||
|
|
||||||
extern const char *datapath(void);
|
const char *datapath(void);
|
||||||
extern void set_datapath(const char *path);
|
void set_datapath(const char *path);
|
||||||
|
|
||||||
extern const char *basepath(void);
|
const char *basepath(void);
|
||||||
extern void set_basepath(const char *);
|
void set_basepath(const char *);
|
||||||
void load_inifile(struct _dictionary_ *d);
|
void load_inifile(struct _dictionary_ *d);
|
||||||
|
|
||||||
extern const char *reportpath(void);
|
const char *reportpath(void);
|
||||||
extern void set_reportpath(const char *);
|
void set_reportpath(const char *);
|
||||||
|
|
||||||
extern void kernel_init(void);
|
void kernel_init(void);
|
||||||
extern void kernel_done(void);
|
void kernel_done(void);
|
||||||
|
|
||||||
extern const char *localenames[];
|
extern const char *localenames[];
|
||||||
|
|
||||||
/** compatibility: **/
|
/** compatibility: **/
|
||||||
extern race_t old_race(const struct race *);
|
race_t old_race(const struct race *);
|
||||||
extern const struct race *new_race[];
|
extern const struct race *new_race[];
|
||||||
|
|
||||||
/* globale settings des Spieles */
|
/* globale settings des Spieles */
|
||||||
|
@ -395,7 +388,7 @@ extern "C" {
|
||||||
const char *gamename;
|
const char *gamename;
|
||||||
struct attrib *attribs;
|
struct attrib *attribs;
|
||||||
unsigned int data_turn;
|
unsigned int data_turn;
|
||||||
bool disabled[MAXKEYWORDS];
|
// bool disabled[MAXKEYWORDS];
|
||||||
struct param *parameters;
|
struct param *parameters;
|
||||||
void *vm_state;
|
void *vm_state;
|
||||||
float producexpchance;
|
float producexpchance;
|
||||||
|
@ -412,33 +405,33 @@ extern "C" {
|
||||||
} settings;
|
} settings;
|
||||||
extern settings global;
|
extern settings global;
|
||||||
|
|
||||||
extern int produceexp(struct unit *u, skill_t sk, int n);
|
int produceexp(struct unit *u, skill_t sk, int n);
|
||||||
|
|
||||||
extern bool battledebug;
|
extern bool battledebug;
|
||||||
extern bool sqlpatch;
|
extern bool sqlpatch;
|
||||||
extern bool lomem; /* save memory */
|
extern bool lomem; /* save memory */
|
||||||
|
|
||||||
extern const char *dbrace(const struct race *rc);
|
const char *dbrace(const struct race *rc);
|
||||||
|
|
||||||
extern void set_param(struct param **p, const char *name, const char *data);
|
void set_param(struct param **p, const char *name, const char *data);
|
||||||
extern const char *get_param(const struct param *p, const char *name);
|
const char *get_param(const struct param *p, const char *name);
|
||||||
extern int get_param_int(const struct param *p, const char *name, int def);
|
int get_param_int(const struct param *p, const char *name, int def);
|
||||||
extern float get_param_flt(const struct param *p, const char *name,
|
float get_param_flt(const struct param *p, const char *name,
|
||||||
float def);
|
float def);
|
||||||
|
|
||||||
extern bool ExpensiveMigrants(void);
|
bool ExpensiveMigrants(void);
|
||||||
extern int NMRTimeout(void);
|
int NMRTimeout(void);
|
||||||
extern int LongHunger(const struct unit *u);
|
int LongHunger(const struct unit *u);
|
||||||
extern int SkillCap(skill_t sk);
|
int SkillCap(skill_t sk);
|
||||||
extern int NewbieImmunity(void);
|
int NewbieImmunity(void);
|
||||||
extern bool IsImmune(const struct faction *f);
|
bool IsImmune(const struct faction *f);
|
||||||
extern int AllianceAuto(void); /* flags that allied factions get automatically */
|
int AllianceAuto(void); /* flags that allied factions get automatically */
|
||||||
extern int AllianceRestricted(void); /* flags restricted to allied factions */
|
int AllianceRestricted(void); /* flags restricted to allied factions */
|
||||||
extern int HelpMask(void); /* flags restricted to allied factions */
|
int HelpMask(void); /* flags restricted to allied factions */
|
||||||
extern struct order *default_order(const struct locale *lang);
|
struct order *default_order(const struct locale *lang);
|
||||||
extern int entertainmoney(const struct region *r);
|
int entertainmoney(const struct region *r);
|
||||||
|
|
||||||
extern void plagues(struct region *r, bool ismagic);
|
void plagues(struct region *r, bool ismagic);
|
||||||
typedef struct helpmode {
|
typedef struct helpmode {
|
||||||
const char *name;
|
const char *name;
|
||||||
int status;
|
int status;
|
||||||
|
@ -456,7 +449,7 @@ extern "C" {
|
||||||
#define GIVE_DEFAULT (GIVE_SELF|GIVE_PEASANTS|GIVE_LUXURIES|GIVE_HERBS|GIVE_GOODS)
|
#define GIVE_DEFAULT (GIVE_SELF|GIVE_PEASANTS|GIVE_LUXURIES|GIVE_HERBS|GIVE_GOODS)
|
||||||
|
|
||||||
extern struct attrib_type at_guard;
|
extern struct attrib_type at_guard;
|
||||||
extern void free_gamedata(void);
|
void free_gamedata(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "building.h"
|
#include "building.h"
|
||||||
#include "calendar.h"
|
#include "calendar.h"
|
||||||
#include "curse.h"
|
#include "curse.h"
|
||||||
|
#include "direction.h"
|
||||||
#include "faction.h"
|
#include "faction.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "magic.h"
|
#include "magic.h"
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "order.h"
|
#include "order.h"
|
||||||
|
|
||||||
#include "skill.h"
|
#include "skill.h"
|
||||||
|
#include "keyword.h"
|
||||||
|
|
||||||
#include <util/base36.h>
|
#include <util/base36.h>
|
||||||
#include <util/bsdstring.h>
|
#include <util/bsdstring.h>
|
||||||
|
@ -87,53 +88,50 @@ keyword_t get_keyword(const order * ord)
|
||||||
* This is the inverse function to the parse_order command. Note that
|
* This is the inverse function to the parse_order command. Note that
|
||||||
* keywords are expanded to their full length.
|
* keywords are expanded to their full length.
|
||||||
*/
|
*/
|
||||||
static char *get_command(const order * ord, char *sbuffer, size_t size)
|
static char* get_command(const order *ord, char *sbuffer, size_t size) {
|
||||||
{
|
char *bufp = sbuffer;
|
||||||
char *bufp = sbuffer;
|
const char *text = ORD_STRING(ord);
|
||||||
const char *text = ORD_STRING(ord);
|
keyword_t kwd = ORD_KEYWORD(ord);
|
||||||
keyword_t kwd = ORD_KEYWORD(ord);
|
int bytes;
|
||||||
int bytes;
|
|
||||||
|
|
||||||
if (ord->_persistent) {
|
if (ord->_persistent) {
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
*bufp++ = '@';
|
*bufp++ = '@';
|
||||||
--size;
|
--size;
|
||||||
} else {
|
} else {
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
}
|
|
||||||
}
|
|
||||||
if (kwd != NOKEYWORD) {
|
|
||||||
const struct locale *lang = ORD_LOCALE(ord);
|
|
||||||
if (size > 0) {
|
|
||||||
if (text)
|
|
||||||
--size;
|
|
||||||
bytes = (int)strlcpy(bufp, (const char *)LOC(lang, keywords[kwd]), size);
|
|
||||||
if (wrptr(&bufp, &size, bytes) != 0)
|
|
||||||
WARN_STATIC_BUFFER();
|
|
||||||
if (text)
|
|
||||||
*bufp++ = ' ';
|
|
||||||
} else {
|
|
||||||
WARN_STATIC_BUFFER();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (text) {
|
|
||||||
bytes = (int)strlcpy(bufp, (const char *)text, size);
|
|
||||||
if (wrptr(&bufp, &size, bytes) != 0) {
|
|
||||||
WARN_STATIC_BUFFER();
|
|
||||||
if (bufp - sbuffer >= 6) {
|
|
||||||
bufp -= 6;
|
|
||||||
while (bufp > sbuffer && (*bufp & 0x80) != 0) {
|
|
||||||
++size;
|
|
||||||
--bufp;
|
|
||||||
}
|
}
|
||||||
memcpy(bufp, "[...]", 6); /* TODO: make sure this only happens in eval_command */
|
|
||||||
bufp += 6;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
if (kwd != NOKEYWORD) {
|
||||||
if (size > 0)
|
const struct locale *lang = ORD_LOCALE(ord);
|
||||||
*bufp = 0;
|
if (size > 0) {
|
||||||
return sbuffer;
|
const char *str = (const char *)LOC(lang, keywords[kwd]);
|
||||||
|
assert(str);
|
||||||
|
if (text) --size;
|
||||||
|
bytes = (int)strlcpy(bufp, str, size);
|
||||||
|
if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER();
|
||||||
|
if (text) *bufp++ = ' ';
|
||||||
|
} else {
|
||||||
|
WARN_STATIC_BUFFER();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (text) {
|
||||||
|
bytes = (int)strlcpy(bufp, (const char *)text, size);
|
||||||
|
if (wrptr(&bufp, &size, bytes) != 0) {
|
||||||
|
WARN_STATIC_BUFFER();
|
||||||
|
if (bufp - sbuffer >= 6) {
|
||||||
|
bufp -= 6;
|
||||||
|
while (bufp > sbuffer && (*bufp & 0x80) != 0) {
|
||||||
|
++size;
|
||||||
|
--bufp;
|
||||||
|
}
|
||||||
|
memcpy(bufp, "[...]", 6); /* TODO: make sure this only happens in eval_command */
|
||||||
|
bufp += 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (size > 0) *bufp = 0;
|
||||||
|
return sbuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *getcommand(const order * ord)
|
char *getcommand(const order * ord)
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "keyword.h"
|
||||||
|
|
||||||
/* Encapsulation of an order
|
/* Encapsulation of an order
|
||||||
*
|
*
|
||||||
* This structure contains one order given by a unit. These used to be
|
* This structure contains one order given by a unit. These used to be
|
||||||
|
|
|
@ -24,6 +24,7 @@ extern "C" {
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "direction.h"
|
||||||
|
|
||||||
/* FAST_CONNECT: regions are directly connected to neighbours, saves doing
|
/* FAST_CONNECT: regions are directly connected to neighbours, saves doing
|
||||||
a hash-access each time a neighbour is needed */
|
a hash-access each time a neighbour is needed */
|
||||||
|
|
|
@ -42,7 +42,6 @@ extern "C" {
|
||||||
extern const char *game_name;
|
extern const char *game_name;
|
||||||
extern int enc_gamedata;
|
extern int enc_gamedata;
|
||||||
|
|
||||||
extern void init_locales(void);
|
|
||||||
extern int current_turn(void);
|
extern int current_turn(void);
|
||||||
|
|
||||||
extern void read_items(struct storage *store, struct item **it);
|
extern void read_items(struct storage *store, struct item **it);
|
||||||
|
|
|
@ -23,6 +23,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "direction.h"
|
||||||
|
|
||||||
#define DAMAGE_SCALE 100 /* multiplier for sh->damage */
|
#define DAMAGE_SCALE 100 /* multiplier for sh->damage */
|
||||||
|
|
||||||
|
|
|
@ -73,73 +73,6 @@ typedef struct ursprung {
|
||||||
int x, y;
|
int x, y;
|
||||||
} ursprung;
|
} ursprung;
|
||||||
|
|
||||||
/* ----------------- Befehle ----------------------------------- */
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
K_KOMMENTAR,
|
|
||||||
K_BANNER,
|
|
||||||
K_WORK,
|
|
||||||
K_ATTACK,
|
|
||||||
K_STEAL,
|
|
||||||
K_BESIEGE,
|
|
||||||
K_NAME,
|
|
||||||
K_USE,
|
|
||||||
K_DISPLAY,
|
|
||||||
K_ENTER,
|
|
||||||
K_GUARD,
|
|
||||||
K_MAIL,
|
|
||||||
K_END,
|
|
||||||
K_DRIVE,
|
|
||||||
K_NUMBER,
|
|
||||||
K_FOLLOW,
|
|
||||||
K_RESEARCH,
|
|
||||||
K_GIVE,
|
|
||||||
K_ALLY,
|
|
||||||
K_STATUS,
|
|
||||||
K_COMBATSPELL,
|
|
||||||
K_BUY,
|
|
||||||
K_CONTACT,
|
|
||||||
K_TEACH,
|
|
||||||
K_STUDY,
|
|
||||||
K_MAKE,
|
|
||||||
K_MOVE,
|
|
||||||
K_PASSWORD,
|
|
||||||
K_RECRUIT,
|
|
||||||
K_RESERVE,
|
|
||||||
K_ROUTE,
|
|
||||||
K_SABOTAGE,
|
|
||||||
K_SEND,
|
|
||||||
K_SPY,
|
|
||||||
K_QUIT,
|
|
||||||
K_SETSTEALTH,
|
|
||||||
K_TRANSPORT,
|
|
||||||
K_TAX,
|
|
||||||
K_ENTERTAIN,
|
|
||||||
K_SELL,
|
|
||||||
K_LEAVE,
|
|
||||||
K_FORGET,
|
|
||||||
K_CAST,
|
|
||||||
K_RESHOW,
|
|
||||||
K_DESTROY,
|
|
||||||
K_BREED,
|
|
||||||
K_DEFAULT,
|
|
||||||
K_URSPRUNG,
|
|
||||||
K_EMAIL,
|
|
||||||
K_PIRACY,
|
|
||||||
K_GROUP,
|
|
||||||
K_SORT,
|
|
||||||
K_GM, /* perform GM commands */
|
|
||||||
K_INFO, /* set player-info */
|
|
||||||
K_PREFIX,
|
|
||||||
K_PLANT,
|
|
||||||
K_ALLIANCE,
|
|
||||||
K_CLAIM,
|
|
||||||
K_PROMOTION,
|
|
||||||
K_PAY,
|
|
||||||
MAXKEYWORDS,
|
|
||||||
NOKEYWORD = -1
|
|
||||||
} keyword_t;
|
|
||||||
|
|
||||||
/* ------------------ Status von Einheiten --------------------- */
|
/* ------------------ Status von Einheiten --------------------- */
|
||||||
|
|
||||||
typedef unsigned char status_t;
|
typedef unsigned char status_t;
|
||||||
|
@ -354,20 +287,6 @@ typedef enum {
|
||||||
NORACE = -1
|
NORACE = -1
|
||||||
} race_t;
|
} race_t;
|
||||||
|
|
||||||
/* Richtungen */
|
|
||||||
typedef enum {
|
|
||||||
D_NORTHWEST,
|
|
||||||
D_NORTHEAST,
|
|
||||||
D_EAST,
|
|
||||||
D_SOUTHEAST,
|
|
||||||
D_SOUTHWEST,
|
|
||||||
D_WEST,
|
|
||||||
MAXDIRECTIONS,
|
|
||||||
D_PAUSE,
|
|
||||||
D_SPECIAL,
|
|
||||||
NODIRECTION = -1
|
|
||||||
} direction_t;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
M_GRAY = 0, /* Gray */
|
M_GRAY = 0, /* Gray */
|
||||||
M_ILLAUN = 1, /* Illaun */
|
M_ILLAUN = 1, /* Illaun */
|
||||||
|
|
|
@ -2307,7 +2307,7 @@ static int parse_main(xmlDocPtr doc)
|
||||||
int k;
|
int k;
|
||||||
for (k = 0; k != MAXKEYWORDS; ++k) {
|
for (k = 0; k != MAXKEYWORDS; ++k) {
|
||||||
if (strcmp(keywords[k], (const char *)propName) == 0) {
|
if (strcmp(keywords[k], (const char *)propName) == 0) {
|
||||||
global.disabled[k] = 1;
|
enable_keyword(k, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
#include <platform.h>
|
||||||
|
#include <kernel/config.h>
|
||||||
|
#include "keyword.h"
|
||||||
|
|
||||||
|
#include "util/language.h"
|
||||||
|
#include "util/umlaut.h"
|
||||||
|
|
||||||
|
#include <critbit.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
static const char * keyword_key(int i)
|
||||||
|
{
|
||||||
|
assert(i<MAXKEYWORDS&& i>=0);
|
||||||
|
return keywords[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
keyword_t findkeyword(const char *s, const struct locale *lang) {
|
||||||
|
keyword_t result = NOKEYWORD;
|
||||||
|
char buffer[64];
|
||||||
|
|
||||||
|
init_translations(lang, UT_KEYWORDS, keyword_key, MAXKEYWORDS);
|
||||||
|
assert(lang);
|
||||||
|
assert(s);
|
||||||
|
while (*s == '@') ++s;
|
||||||
|
|
||||||
|
if (*s) {
|
||||||
|
char *str = transliterate(buffer, sizeof(buffer) - sizeof(int), s);
|
||||||
|
|
||||||
|
if (str) {
|
||||||
|
int i;
|
||||||
|
const void *match;
|
||||||
|
void **tokens = get_translations(lang, UT_KEYWORDS);
|
||||||
|
critbit_tree *cb = (critbit_tree *)*tokens;
|
||||||
|
assert(cb);
|
||||||
|
if (cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) {
|
||||||
|
cb_get_kv(match, &i, sizeof(int));
|
||||||
|
result = (keyword_t)i;
|
||||||
|
return keyword_disabled(result) ? NOKEYWORD : result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NOKEYWORD;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool disabled_kwd[MAXKEYWORDS];
|
||||||
|
|
||||||
|
void enable_keyword(keyword_t kwd, bool enabled) {
|
||||||
|
assert(kwd<MAXKEYWORDS);
|
||||||
|
disabled_kwd[kwd] = !enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool keyword_disabled(keyword_t kwd) {
|
||||||
|
assert(kwd<MAXKEYWORDS);
|
||||||
|
return disabled_kwd[kwd];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *keywords[MAXKEYWORDS] = {
|
||||||
|
"//",
|
||||||
|
"BANNER",
|
||||||
|
"ARBEITEN",
|
||||||
|
"ATTACKIEREN",
|
||||||
|
"BEKLAUEN",
|
||||||
|
"BELAGERE",
|
||||||
|
"BENENNEN",
|
||||||
|
"BENUTZEN",
|
||||||
|
"BESCHREIBEN",
|
||||||
|
"BETRETEN",
|
||||||
|
"BEWACHEN",
|
||||||
|
"BOTSCHAFT",
|
||||||
|
"ENDE",
|
||||||
|
"FAHREN",
|
||||||
|
"NUMMER",
|
||||||
|
"FOLGEN",
|
||||||
|
"FORSCHEN",
|
||||||
|
"GIB",
|
||||||
|
"HELFEN",
|
||||||
|
"KAEMPFEN",
|
||||||
|
"KAMPFZAUBER",
|
||||||
|
"KAUFEN",
|
||||||
|
"KONTAKTIEREN",
|
||||||
|
"LEHREN",
|
||||||
|
"LERNEN",
|
||||||
|
"MACHEN",
|
||||||
|
"NACH",
|
||||||
|
"PASSWORT",
|
||||||
|
"REKRUTIEREN",
|
||||||
|
"RESERVIEREN",
|
||||||
|
"ROUTE",
|
||||||
|
"SABOTIEREN",
|
||||||
|
"OPTION",
|
||||||
|
"SPIONIEREN",
|
||||||
|
"STIRB",
|
||||||
|
"TARNEN",
|
||||||
|
"TRANSPORTIEREN",
|
||||||
|
"TREIBEN",
|
||||||
|
"UNTERHALTEN",
|
||||||
|
"VERKAUFEN",
|
||||||
|
"VERLASSEN",
|
||||||
|
"VERGESSEN",
|
||||||
|
"ZAUBERE",
|
||||||
|
"ZEIGEN",
|
||||||
|
"ZERSTOEREN",
|
||||||
|
"ZUECHTEN",
|
||||||
|
"DEFAULT",
|
||||||
|
"URSPRUNG",
|
||||||
|
"EMAIL",
|
||||||
|
"PIRATERIE",
|
||||||
|
"GRUPPE",
|
||||||
|
"SORTIEREN",
|
||||||
|
"PRAEFIX",
|
||||||
|
"PFLANZEN",
|
||||||
|
"ALLIANZ",
|
||||||
|
"BEANSPRUCHEN",
|
||||||
|
"PROMOTION",
|
||||||
|
"BEZAHLEN",
|
||||||
|
};
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
#ifndef H_KEYWORD_H
|
||||||
|
#define H_KEYWORD_H
|
||||||
|
|
||||||
|
#include "kernel/types.h"
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct locale;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
K_KOMMENTAR,
|
||||||
|
K_BANNER,
|
||||||
|
K_WORK,
|
||||||
|
K_ATTACK,
|
||||||
|
K_STEAL,
|
||||||
|
K_BESIEGE,
|
||||||
|
K_NAME,
|
||||||
|
K_USE,
|
||||||
|
K_DISPLAY,
|
||||||
|
K_ENTER,
|
||||||
|
K_GUARD,
|
||||||
|
K_MAIL,
|
||||||
|
K_END,
|
||||||
|
K_DRIVE,
|
||||||
|
K_NUMBER,
|
||||||
|
K_FOLLOW,
|
||||||
|
K_RESEARCH,
|
||||||
|
K_GIVE,
|
||||||
|
K_ALLY,
|
||||||
|
K_STATUS,
|
||||||
|
K_COMBATSPELL,
|
||||||
|
K_BUY,
|
||||||
|
K_CONTACT,
|
||||||
|
K_TEACH,
|
||||||
|
K_STUDY,
|
||||||
|
K_MAKE,
|
||||||
|
K_MOVE,
|
||||||
|
K_PASSWORD,
|
||||||
|
K_RECRUIT,
|
||||||
|
K_RESERVE,
|
||||||
|
K_ROUTE,
|
||||||
|
K_SABOTAGE,
|
||||||
|
K_SEND,
|
||||||
|
K_SPY,
|
||||||
|
K_QUIT,
|
||||||
|
K_SETSTEALTH,
|
||||||
|
K_TRANSPORT,
|
||||||
|
K_TAX,
|
||||||
|
K_ENTERTAIN,
|
||||||
|
K_SELL,
|
||||||
|
K_LEAVE,
|
||||||
|
K_FORGET,
|
||||||
|
K_CAST,
|
||||||
|
K_RESHOW,
|
||||||
|
K_DESTROY,
|
||||||
|
K_BREED,
|
||||||
|
K_DEFAULT,
|
||||||
|
K_URSPRUNG,
|
||||||
|
K_EMAIL,
|
||||||
|
K_PIRACY,
|
||||||
|
K_GROUP,
|
||||||
|
K_SORT,
|
||||||
|
K_PREFIX,
|
||||||
|
K_PLANT,
|
||||||
|
K_ALLIANCE,
|
||||||
|
K_CLAIM,
|
||||||
|
K_PROMOTION,
|
||||||
|
K_PAY,
|
||||||
|
MAXKEYWORDS,
|
||||||
|
NOKEYWORD = -1
|
||||||
|
} keyword_t;
|
||||||
|
|
||||||
|
extern const char *keywords[MAXKEYWORDS];
|
||||||
|
keyword_t findkeyword(const char *s, const struct locale *lang);
|
||||||
|
bool keyword_disabled(keyword_t kwd);
|
||||||
|
void enable_keyword(keyword_t kwd, bool enabled);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
20
src/laws.c
20
src/laws.c
|
@ -23,13 +23,13 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <modules/gmcmd.h>
|
#include <modules/gmcmd.h>
|
||||||
#include <modules/wormhole.h>
|
#include <modules/wormhole.h>
|
||||||
|
|
||||||
/* gamecode includes */
|
|
||||||
#include "economy.h"
|
#include "economy.h"
|
||||||
#include "monster.h"
|
#include "monster.h"
|
||||||
#include "randenc.h"
|
#include "randenc.h"
|
||||||
#include "spy.h"
|
#include "spy.h"
|
||||||
#include "study.h"
|
#include "study.h"
|
||||||
#include "market.h"
|
#include "market.h"
|
||||||
|
#include "keyword.h"
|
||||||
|
|
||||||
/* kernel includes */
|
/* kernel includes */
|
||||||
#include <kernel/alchemy.h>
|
#include <kernel/alchemy.h>
|
||||||
|
@ -3855,7 +3855,7 @@ void defaultorders(void)
|
||||||
{
|
{
|
||||||
region *r;
|
region *r;
|
||||||
|
|
||||||
assert(!global.disabled[K_DEFAULT]);
|
assert(!keyword_disabled(K_DEFAULT));
|
||||||
for (r = regions; r; r = r->next) {
|
for (r = regions; r; r = r->next) {
|
||||||
unit *u;
|
unit *u;
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
|
@ -4162,7 +4162,7 @@ void
|
||||||
add_proc_order(int priority, keyword_t kword, int (*parser) (struct unit *,
|
add_proc_order(int priority, keyword_t kword, int (*parser) (struct unit *,
|
||||||
struct order *), unsigned int flags, const char *name)
|
struct order *), unsigned int flags, const char *name)
|
||||||
{
|
{
|
||||||
if (!global.disabled[kword]) {
|
if (!keyword_disabled(kword)) {
|
||||||
processor *proc = add_proc(priority, name, PR_ORDER);
|
processor *proc = add_proc(priority, name, PR_ORDER);
|
||||||
if (proc) {
|
if (proc) {
|
||||||
proc->data.per_order.process = parser;
|
proc->data.per_order.process = parser;
|
||||||
|
@ -4516,7 +4516,7 @@ void init_processor(void)
|
||||||
|
|
||||||
add_proc_region(p, &do_battle, "Attackieren");
|
add_proc_region(p, &do_battle, "Attackieren");
|
||||||
|
|
||||||
if (!global.disabled[K_BESIEGE]) {
|
if (!keyword_disabled(K_BESIEGE)) {
|
||||||
p += 10;
|
p += 10;
|
||||||
add_proc_region(p, &do_siege, "Belagern");
|
add_proc_region(p, &do_siege, "Belagern");
|
||||||
}
|
}
|
||||||
|
@ -4531,7 +4531,7 @@ void init_processor(void)
|
||||||
add_proc_region(p, &economics, "Zerstoeren, Geben, Rekrutieren, Vergessen");
|
add_proc_region(p, &economics, "Zerstoeren, Geben, Rekrutieren, Vergessen");
|
||||||
|
|
||||||
p += 10;
|
p += 10;
|
||||||
if (!global.disabled[K_PAY]) {
|
if (!keyword_disabled(K_PAY)) {
|
||||||
add_proc_order(p, K_PAY, &pay_cmd, 0, "Gebaeudeunterhalt (disable)");
|
add_proc_order(p, K_PAY, &pay_cmd, 0, "Gebaeudeunterhalt (disable)");
|
||||||
}
|
}
|
||||||
add_proc_postregion(p, &maintain_buildings_1,
|
add_proc_postregion(p, &maintain_buildings_1,
|
||||||
|
@ -4540,7 +4540,7 @@ void init_processor(void)
|
||||||
p += 10; /* QUIT fuer sich alleine */
|
p += 10; /* QUIT fuer sich alleine */
|
||||||
add_proc_global(p, quit, "Sterben");
|
add_proc_global(p, quit, "Sterben");
|
||||||
|
|
||||||
if (!global.disabled[K_CAST]) {
|
if (!keyword_disabled(K_CAST)) {
|
||||||
p += 10;
|
p += 10;
|
||||||
add_proc_global(p, &magic, "Zaubern");
|
add_proc_global(p, &magic, "Zaubern");
|
||||||
}
|
}
|
||||||
|
@ -4591,17 +4591,17 @@ void init_processor(void)
|
||||||
|
|
||||||
add_proc_global(p, &monthly_healing, "Regeneration (HP)");
|
add_proc_global(p, &monthly_healing, "Regeneration (HP)");
|
||||||
add_proc_global(p, ®enerate_aura, "Regeneration (Aura)");
|
add_proc_global(p, ®enerate_aura, "Regeneration (Aura)");
|
||||||
if (!global.disabled[K_DEFAULT]) {
|
if (!keyword_disabled(K_DEFAULT)) {
|
||||||
add_proc_global(p, &defaultorders, "Defaults setzen");
|
add_proc_global(p, &defaultorders, "Defaults setzen");
|
||||||
}
|
}
|
||||||
add_proc_global(p, &demographics, "Nahrung, Seuchen, Wachstum, Wanderung");
|
add_proc_global(p, &demographics, "Nahrung, Seuchen, Wachstum, Wanderung");
|
||||||
|
|
||||||
if (!global.disabled[K_SORT]) {
|
if (!keyword_disabled(K_SORT)) {
|
||||||
p += 10;
|
p += 10;
|
||||||
add_proc_global(p, restack_units, "Einheiten sortieren");
|
add_proc_global(p, restack_units, "Einheiten sortieren");
|
||||||
}
|
}
|
||||||
add_proc_order(p, K_PROMOTION, &promotion_cmd, 0, "Heldenbefoerderung");
|
add_proc_order(p, K_PROMOTION, &promotion_cmd, 0, "Heldenbefoerderung");
|
||||||
if (!global.disabled[K_NUMBER]) {
|
if (!keyword_disabled(K_NUMBER)) {
|
||||||
add_proc_order(p, K_NUMBER, &renumber_cmd, 0, "Neue Nummern (Einheiten)");
|
add_proc_order(p, K_NUMBER, &renumber_cmd, 0, "Neue Nummern (Einheiten)");
|
||||||
p += 10;
|
p += 10;
|
||||||
add_proc_global(p, &renumber_factions, "Neue Nummern");
|
add_proc_global(p, &renumber_factions, "Neue Nummern");
|
||||||
|
@ -4703,8 +4703,6 @@ int init_data(const char *filename, const char *catalog)
|
||||||
if (l)
|
if (l)
|
||||||
return l;
|
return l;
|
||||||
|
|
||||||
init_locales();
|
|
||||||
|
|
||||||
if (turn < 0) {
|
if (turn < 0) {
|
||||||
turn = first_turn;
|
turn = first_turn;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "spells.h"
|
#include "spells.h"
|
||||||
#include "borders.h"
|
#include "borders.h"
|
||||||
#include "buildingcurse.h"
|
#include "buildingcurse.h"
|
||||||
|
#include "direction.h"
|
||||||
#include "regioncurse.h"
|
#include "regioncurse.h"
|
||||||
#include "unitcurse.h"
|
#include "unitcurse.h"
|
||||||
#include "shipcurse.h"
|
#include "shipcurse.h"
|
||||||
|
|
|
@ -25,6 +25,7 @@ CuSuite *get_bsdstring_suite(void);
|
||||||
CuSuite *get_functions_suite(void);
|
CuSuite *get_functions_suite(void);
|
||||||
CuSuite *get_umlaut_suite(void);
|
CuSuite *get_umlaut_suite(void);
|
||||||
CuSuite *get_ally_suite(void);
|
CuSuite *get_ally_suite(void);
|
||||||
|
CuSuite *get_direction_suite(void);
|
||||||
|
|
||||||
int RunAllTests(void)
|
int RunAllTests(void)
|
||||||
{
|
{
|
||||||
|
@ -38,6 +39,7 @@ int RunAllTests(void)
|
||||||
CuSuiteAddSuite(suite, get_tests_suite());
|
CuSuiteAddSuite(suite, get_tests_suite());
|
||||||
CuSuiteAddSuite(suite, get_json_suite());
|
CuSuiteAddSuite(suite, get_json_suite());
|
||||||
CuSuiteAddSuite(suite, get_jsonconf_suite());
|
CuSuiteAddSuite(suite, get_jsonconf_suite());
|
||||||
|
CuSuiteAddSuite(suite, get_direction_suite());
|
||||||
/* util */
|
/* util */
|
||||||
CuSuiteAddSuite(suite, get_base36_suite());
|
CuSuiteAddSuite(suite, get_base36_suite());
|
||||||
CuSuiteAddSuite(suite, get_bsdstring_suite());
|
CuSuiteAddSuite(suite, get_bsdstring_suite());
|
||||||
|
|
|
@ -128,6 +128,7 @@ const char *locale_getstring(const locale * lang, const char *key)
|
||||||
const char *locale_string(const locale * lang, const char *key)
|
const char *locale_string(const locale * lang, const char *key)
|
||||||
{
|
{
|
||||||
assert(lang);
|
assert(lang);
|
||||||
|
assert(key);
|
||||||
|
|
||||||
if (key != NULL) {
|
if (key != NULL) {
|
||||||
unsigned int hkey = hashstring(key);
|
unsigned int hkey = hashstring(key);
|
||||||
|
@ -154,7 +155,7 @@ const char *locale_string(const locale * lang, const char *key)
|
||||||
if (lang->fallback) {
|
if (lang->fallback) {
|
||||||
return locale_string(lang->fallback, key);
|
return locale_string(lang->fallback, key);
|
||||||
}
|
}
|
||||||
return 0;
|
return key;
|
||||||
}
|
}
|
||||||
return find->str;
|
return find->str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#define _UMLAUT_H
|
#define _UMLAUT_H
|
||||||
|
|
||||||
#include "variant.h"
|
#include "variant.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
Loading…
Reference in New Issue