Merge pull request #48 from badgerman/master

more refactoring, no new features.
This commit is contained in:
Enno Rehling 2014-11-02 10:34:37 +01:00
commit 00ba5538f5
106 changed files with 681 additions and 569 deletions

View File

@ -1,18 +1,19 @@
[eressea] [eressea]
base = . base = .
report = reports report = reports
verbose = 0 verbose = 0
lomem = 0 lomem = 0
debug = 0 debug = 0
memcheck = 0 memcheck = 0
locales = de,en locales = de,en
;game_id = 0
[lua] [lua]
install = ../git install = ../git
paths = ../git/lunit:../git/scripts paths = lunit:scripts
maxnmrs = 20 maxnmrs = 20
rules = e2 ; can use -r to override rules = e2
[editor] [editor]
color = 1 color = 1

View File

@ -67,7 +67,6 @@ set (ERESSEA_SRC
spells.c spells.c
battle.c battle.c
alchemy.c alchemy.c
stealth.c
upkeep.c upkeep.c
vortex.c vortex.c
names.c names.c
@ -84,6 +83,7 @@ set (ERESSEA_SRC
give.c give.c
items.c items.c
laws.c laws.c
magic.c
market.c market.c
monster.c monster.c
randenc.c randenc.c
@ -161,17 +161,18 @@ set(TESTS_SRC
vortex.test.c vortex.test.c
tests.test.c tests.test.c
reports.test.c reports.test.c
stealth.test.c
callback.test.c callback.test.c
direction.test.c direction.test.c
economy.test.c economy.test.c
json.test.c json.test.c
keyword.test.c keyword.test.c
laws.test.c laws.test.c
magic.test.c
market.test.c market.test.c
move.test.c move.test.c
skill.test.c skill.test.c
upkeep.test.c upkeep.test.c
${ATTRIBUTES_TESTS}
${UTIL_TESTS} ${UTIL_TESTS}
${KERNEL_TESTS} ${KERNEL_TESTS}
${ERESSEA_SRC} ${ERESSEA_SRC}

View File

@ -26,7 +26,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/build.h> #include <kernel/build.h>
#include <kernel/magic.h>
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/pool.h> #include <kernel/pool.h>
#include <kernel/race.h> #include <kernel/race.h>

View File

@ -23,6 +23,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
extern "C" { extern "C" {
#endif #endif
struct potion_type;
struct unit;
struct region;
struct item_type;
struct order;
enum { enum {
/* Stufe 1 */ /* Stufe 1 */
P_FAST, P_FAST,

View File

@ -1,4 +1,8 @@
PROJECT(attributes C) PROJECT(attributes C)
SET(_TEST_FILES
stealth.test.c
)
SET(_FILES SET(_FILES
alliance.c alliance.c
attributes.c attributes.c
@ -18,10 +22,14 @@ overrideroads.c
racename.c racename.c
raceprefix.c raceprefix.c
reduceproduction.c reduceproduction.c
stealth.c
targetregion.c targetregion.c
) )
FOREACH(_FILE ${_FILES}) FOREACH(_FILE ${_FILES})
LIST(APPEND _SOURCES ${PROJECT_NAME}/${_FILE}) LIST(APPEND _SOURCES ${PROJECT_NAME}/${_FILE})
ENDFOREACH(_FILE) ENDFOREACH(_FILE)
SET(ATTRIBUTES_SRC ${_SOURCES} PARENT_SCOPE) SET(ATTRIBUTES_SRC ${_SOURCES} PARENT_SCOPE)
FOREACH(_FILE ${_TEST_FILES})
LIST(APPEND _TESTS ${PROJECT_NAME}/${_FILE})
ENDFOREACH(_FILE)
SET(ATTRIBUTES_TESTS ${_TESTS} PARENT_SCOPE)

View File

@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/ **/
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include "alliance.h" #include "alliance.h"
#include <kernel/save.h> #include <kernel/save.h>

View File

@ -26,6 +26,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "hate.h" #include "hate.h"
#include "iceberg.h" #include "iceberg.h"
#include "key.h" #include "key.h"
#include "stealth.h"
#include "moved.h" #include "moved.h"
#include "movement.h" #include "movement.h"
#include "object.h" #include "object.h"
@ -57,7 +58,8 @@ attrib_type at_unitdissolve = {
void register_attributes(void) void register_attributes(void)
{ {
at_register(&at_object); at_register(&at_stealth);
at_register(&at_object);
at_register(&at_unitdissolve); at_register(&at_unitdissolve);
at_register(&at_overrideroads); at_register(&at_overrideroads);
at_register(&at_raceprefix); at_register(&at_raceprefix);

View File

@ -1,10 +1,10 @@
#include <config.h> #include <config.h>
#include <platform.h> #include <platform.h>
#include "stealth.h"
#include <kernel/unit.h> #include <kernel/unit.h>
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/save.h> #include <kernel/save.h>
#include <util/attrib.h> #include <util/attrib.h>
#include <attributes/stealth.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -21,6 +21,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "battle.h" #include "battle.h"
#include "alchemy.h" #include "alchemy.h"
#include "move.h" #include "move.h"
#include "laws.h"
#include "skill.h" #include "skill.h"
#include <kernel/alliance.h> #include <kernel/alliance.h>
@ -31,7 +32,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/group.h> #include <kernel/group.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/plane.h> #include <kernel/plane.h>
@ -210,34 +210,6 @@ static void message_faction(battle * b, faction * f, struct message *m)
add_message(&f->battles->msgs, m); add_message(&f->battles->msgs, m);
} }
int armedmen(const unit * u, bool siege_weapons)
{
item *itm;
int n = 0;
if (!(urace(u)->flags & RCF_NOWEAPONS)) {
if (effskill(u, SK_WEAPONLESS) >= 1) {
/* kann ohne waffen bewachen: fuer drachen */
n = u->number;
}
else {
/* alle Waffen werden gezaehlt, und dann wird auf die Anzahl
* Personen minimiert */
for (itm = u->items; itm; itm = itm->next) {
const weapon_type *wtype = resource2weapon(itm->type->rtype);
if (wtype == NULL || (!siege_weapons && (wtype->flags & WTF_SIEGE)))
continue;
if (effskill(u, wtype->skill) >= wtype->minskill)
n += itm->number;
/* if (effskill(u, wtype->skill) >= wtype->minskill) n += itm->number; */
if (n > u->number)
break;
}
n = _min(n, u->number);
}
}
return n;
}
void message_all(battle * b, message * m) void message_all(battle * b, message * m)
{ {
bfaction *bf; bfaction *bf;

View File

@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef H_KRNL_BATTLE #ifndef H_KRNL_BATTLE
#define H_KRNL_BATTLE #define H_KRNL_BATTLE
#include <kernel/types.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -1,4 +1,3 @@
#include <kernel/types.h>
#include <platform.h> #include <platform.h>
#include "battle.h" #include "battle.h"

View File

@ -1,7 +1,6 @@
#include "bind_config.h" #include "bind_config.h"
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include <kernel/jsonconf.h> #include <kernel/jsonconf.h>
#include <util/log.h> #include <util/log.h>
#include <util/language.h> #include <util/language.h>

View File

@ -5,7 +5,6 @@
#include "json.h" #include "json.h"
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/types.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/save.h> #include <kernel/save.h>

View File

@ -11,7 +11,6 @@ without prior permission by the authors of Eressea.
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include "bind_faction.h" #include "bind_faction.h"
#include "bind_unit.h" #include "bind_unit.h"
#include "bindings.h" #include "bindings.h"

View File

@ -1,6 +1,5 @@
#include <platform.h> #include <platform.h>
#include <curses.h> #include <curses.h>
#include <kernel/types.h>
#include "bind_gmtool.h" #include "bind_gmtool.h"
#include "gmtool.h" #include "gmtool.h"

View File

@ -1,10 +1,8 @@
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include "spells/shipcurse.h" #include "spells/shipcurse.h"
#include <kernel/equipment.h> #include <kernel/equipment.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/magic.h>
#include <kernel/race.h> #include <kernel/race.h>
#include <kernel/ship.h> #include <kernel/ship.h>
#include <kernel/spellbook.h> #include <kernel/spellbook.h>

View File

@ -1,21 +1,20 @@
#include "bind_process.h" #include "bind_process.h"
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include <kernel/alliance.h> #include <kernel/alliance.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/magic.h>
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/terrain.h> #include <kernel/terrain.h>
#include <kernel/unit.h> #include <kernel/unit.h>
#include "battle.h" #include "battle.h"
#include "move.h"
#include "economy.h" #include "economy.h"
#include "laws.h"
#include "market.h"
#include "study.h"
#include "keyword.h" #include "keyword.h"
#include "laws.h"
#include "magic.h"
#include "market.h"
#include "move.h"
#include "study.h"
#define PROC_LAND_REGION 0x0001 #define PROC_LAND_REGION 0x0001
#define PROC_LONG_ORDER 0x0002 #define PROC_LONG_ORDER 0x0002

View File

@ -1,7 +1,6 @@
#include "bind_settings.h" #include "bind_settings.h"
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include <kernel/config.h> #include <kernel/config.h>
const char * settings_get(const char *key) const char * settings_get(const char *key)

View File

@ -11,7 +11,6 @@ without prior permission by the authors of Eressea.
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include "bind_ship.h" #include "bind_ship.h"
#include "bind_unit.h" #include "bind_unit.h"

View File

@ -12,7 +12,6 @@ without prior permission by the authors of Eressea.
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/types.h>
#include "bind_storage.h" #include "bind_storage.h"
#include <kernel/save.h> #include <kernel/save.h>

View File

@ -11,7 +11,6 @@ without prior permission by the authors of Eressea.
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include "bind_unit.h" #include "bind_unit.h"
#ifdef BSON_ATTRIB #ifdef BSON_ATTRIB
@ -31,7 +30,6 @@ without prior permission by the authors of Eressea.
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/group.h> #include <kernel/group.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/pool.h> #include <kernel/pool.h>

View File

@ -11,7 +11,6 @@ without prior permission by the authors of Eressea.
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include "bindings.h" #include "bindings.h"
#include "bind_unit.h" #include "bind_unit.h"
#include "bind_storage.h" #include "bind_storage.h"

View File

@ -1,5 +1,5 @@
/* /*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de> Copyright (c) 1998-2014, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de> Christian Schlittchen <corwin@amber.kn-bremen.de>
@ -26,7 +26,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/build.h> #include <kernel/build.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/plane.h> #include <kernel/plane.h>
#include <kernel/race.h> #include <kernel/race.h>
#include <kernel/region.h> #include <kernel/region.h>

View File

@ -9,7 +9,7 @@ without prior permission by the authors of Eressea.
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include "build.h" #include "buildno.h"
#include "creport.h" #include "creport.h"
/* tweakable features */ /* tweakable features */
@ -22,15 +22,15 @@ without prior permission by the authors of Eressea.
/* attributes include */ /* attributes include */
#include <attributes/follow.h> #include <attributes/follow.h>
#include <attributes/racename.h>
#include <attributes/orcification.h> #include <attributes/orcification.h>
#include <attributes/otherfaction.h> #include <attributes/otherfaction.h>
#include <attributes/racename.h>
#include <attributes/raceprefix.h> #include <attributes/raceprefix.h>
#include <attributes/stealth.h>
/* gamecode includes */ /* gamecode includes */
#include "laws.h" #include "laws.h"
#include "economy.h" #include "economy.h"
#include "stealth.h"
#include "move.h" #include "move.h"
#include "reports.h" #include "reports.h"
#include "alchemy.h" #include "alchemy.h"

View File

@ -1,5 +1,4 @@
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include "direction.h" #include "direction.h"
#include "tests.h" #include "tests.h"

View File

@ -19,7 +19,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/types.h>
#include "economy.h" #include "economy.h"
#include "alchemy.h" #include "alchemy.h"
@ -38,7 +37,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/equipment.h> #include <kernel/equipment.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/plane.h> #include <kernel/plane.h>

View File

@ -1,6 +1,5 @@
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/types.h>
#include "economy.h" #include "economy.h"
#include <util/message.h> #include <util/message.h>

View File

@ -20,7 +20,6 @@
#include <kernel/curse.h> #include <kernel/curse.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/pool.h> #include <kernel/pool.h>

View File

@ -14,10 +14,12 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
struct lua_State;
struct selection; struct lua_State;
struct state; struct selection;
struct region; struct state;
struct region;
struct terrain_type;
int gmmain(int argc, char *argv[]); int gmmain(int argc, char *argv[]);
int curses_readline(struct lua_State *L, char *buffer, size_t size, int curses_readline(struct lua_State *L, char *buffer, size_t size,

View File

@ -4,12 +4,12 @@
#include "study.h" #include "study.h"
#include "move.h" #include "move.h"
#include "magic.h"
#include <kernel/curse.h> #include <kernel/curse.h>
#include <kernel/building.h> #include <kernel/building.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/plane.h> #include <kernel/plane.h>

View File

@ -29,7 +29,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/save.h> #include <kernel/save.h>
#include <kernel/curse.h> #include <kernel/curse.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/magic.h>
#include <kernel/ship.h> #include <kernel/ship.h>
/* util includes */ /* util includes */

View File

@ -20,6 +20,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/config.h> #include <kernel/config.h>
#include "xerewards.h" #include "xerewards.h"
#include "magic.h"
/* kernel includes */ /* kernel includes */
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/region.h> #include <kernel/region.h>
@ -27,7 +29,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/unit.h> #include <kernel/unit.h>
#include <kernel/curse.h> #include <kernel/curse.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/magic.h>
#include <kernel/pool.h> #include <kernel/pool.h>
/* util includes */ /* util includes */

View File

@ -3,7 +3,6 @@
#include "json.h" #include "json.h"
#include <kernel/types.h>
#include <kernel/plane.h> #include <kernel/plane.h>
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/faction.h> #include <kernel/faction.h>

View File

@ -3,7 +3,6 @@
#include <stream.h> #include <stream.h>
#include <memstream.h> #include <memstream.h>
#include <kernel/types.h>
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/terrain.h> #include <kernel/terrain.h>

View File

@ -3,6 +3,7 @@ project(kernel C)
SET(_TEST_FILES SET(_TEST_FILES
build.test.c build.test.c
config.test.c config.test.c
group.test.c
faction.test.c faction.test.c
unit.test.c unit.test.c
save.test.c save.test.c
@ -10,7 +11,6 @@ ship.test.c
spell.test.c spell.test.c
ally.test.c ally.test.c
building.test.c building.test.c
magic.test.c
equipment.test.c equipment.test.c
curse.test.c curse.test.c
item.test.c item.test.c
@ -36,7 +36,6 @@ equipment.c
faction.c faction.c
group.c group.c
item.c item.c
magic.c
messages.c messages.c
order.c order.c
pathfinder.c pathfinder.c

View File

@ -20,28 +20,29 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/config.h> #include <kernel/config.h>
#include "build.h" #include "build.h"
/* kernel includes */
#include "alchemy.h" #include "alchemy.h"
#include "alliance.h"
#include "connection.h"
#include "direction.h" #include "direction.h"
#include "building.h"
#include "curse.h"
#include "faction.h"
#include "group.h"
#include "item.h"
#include "magic.h"
#include "messages.h"
#include "move.h" #include "move.h"
#include "order.h" #include "laws.h"
#include "pool.h"
#include "race.h"
#include "region.h"
#include "ship.h"
#include "skill.h" #include "skill.h"
#include "terrain.h"
#include "terrainid.h" /* kernel includes */
#include "unit.h" #include <kernel/alliance.h>
#include <kernel/connection.h>
#include <kernel/building.h>
#include <kernel/curse.h>
#include <kernel/faction.h>
#include <kernel/group.h>
#include <kernel/item.h>
#include <kernel/messages.h>
#include <kernel/order.h>
#include <kernel/pool.h>
#include <kernel/race.h>
#include <kernel/region.h>
#include <kernel/ship.h>
#include <kernel/terrain.h>
#include <kernel/terrainid.h>
#include <kernel/unit.h>
/* from libutil */ /* from libutil */
#include <util/attrib.h> #include <util/attrib.h>

View File

@ -29,7 +29,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "race.h" #include "race.h"
#include "region.h" #include "region.h"
#include "skill.h" #include "skill.h"
#include "magic.h"
#include "save.h" #include "save.h"
#include "version.h" #include "version.h"

View File

@ -1,7 +1,6 @@
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/types.h>
#include <kernel/race.h> #include <kernel/race.h>
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/building.h> #include <kernel/building.h>

View File

@ -36,7 +36,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "group.h" #include "group.h"
#include "item.h" #include "item.h"
#include "keyword.h" #include "keyword.h"
#include "magic.h"
#include "messages.h" #include "messages.h"
#include "move.h" #include "move.h"
#include "objtypes.h" #include "objtypes.h"
@ -50,10 +49,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "ship.h" #include "ship.h"
#include "skill.h" #include "skill.h"
#include "terrain.h" #include "terrain.h"
#include "types.h"
#include "unit.h" #include "unit.h"
#include <kernel/spell.h> #include <kernel/spell.h>
#include <kernel/spellbook.h> #include <kernel/spellbook.h>
/* util includes */ /* util includes */
#include <util/attrib.h> #include <util/attrib.h>
#include <util/base36.h> #include <util/base36.h>
@ -74,8 +75,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/umlaut.h> #include <util/umlaut.h>
#include <util/xml.h> #include <util/xml.h>
#include <stealth.h>
#ifdef USE_LIBXML2 #ifdef USE_LIBXML2
/* libxml includes */ /* libxml includes */
#include <libxml/tree.h> #include <libxml/tree.h>
@ -521,34 +520,6 @@ int shipspeed(const ship * sh, const unit * u)
return (int)k; return (int)k;
} }
#define FMAXHASH 2039
faction *factionhash[FMAXHASH];
void fhash(faction * f)
{
int index = f->no % FMAXHASH;
f->nexthash = factionhash[index];
factionhash[index] = f;
}
void funhash(faction * f)
{
int index = f->no % FMAXHASH;
faction **fp = factionhash + index;
while (*fp && (*fp) != f)
fp = &(*fp)->nexthash;
*fp = f->nexthash;
}
static faction *ffindhash(int no)
{
int index = no % FMAXHASH;
faction *f = factionhash[index];
while (f && f->no != no)
f = f->nexthash;
return f;
}
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
void verify_data(void) void verify_data(void)
@ -634,29 +605,6 @@ unsigned int atoip(const char *s)
return n; return n;
} }
region *findunitregion(const unit * su)
{
#ifndef SLOW_REGION
return su->region;
#else
region *r;
const unit *u;
for (r = regions; r; r = r->next) {
for (u = r->units; u; u = u->next) {
if (su == u) {
return r;
}
}
}
/* This should never happen */
assert(!"Die unit wurde nicht gefunden");
return (region *) NULL;
#endif
}
bool unit_has_cursed_item(unit * u) bool unit_has_cursed_item(unit * u)
{ {
item *itm = u->items; item *itm = u->items;
@ -787,161 +735,6 @@ int alliedunit(const unit * u, const faction * f2, int mode)
return 0; return 0;
} }
bool
seefaction(const faction * f, const region * r, const unit * u, int modifier)
{
if (((f == u->faction) || !fval(u, UFL_ANON_FACTION))
&& cansee(f, r, u, modifier))
return true;
return false;
}
bool
cansee(const faction * f, const region * r, const unit * u, int modifier)
/* r kann != u->region sein, wenn es um durchreisen geht */
/* und es muss niemand aus f in der region sein, wenn sie vom Turm
* erblickt wird */
{
int stealth, rings;
unit *u2 = r->units;
if (u->faction == f || omniscient(f)) {
return true;
}
else if (fval(u_race(u), RCF_INVISIBLE)) {
return false;
}
else if (u->number == 0) {
attrib *a = a_find(u->attribs, &at_creator);
if (a) { /* u is an empty temporary unit. In this special case
we look at the creating unit. */
u = (unit *)a->data.v;
}
else {
return false;
}
}
if (leftship(u))
return true;
while (u2 && u2->faction != f)
u2 = u2->next;
if (u2 == NULL)
return false;
/* simple visibility, just gotta have a unit in the region to see 'em */
if (is_guard(u, GUARD_ALL) != 0 || usiege(u) || u->building || u->ship) {
return true;
}
rings = invisible(u, NULL);
stealth = eff_stealth(u, r) - modifier;
while (u2) {
if (rings < u->number || invisible(u, u2) < u->number) {
if (skill_enabled(SK_PERCEPTION)) {
int observation = eff_skill(u2, SK_PERCEPTION, r);
if (observation >= stealth) {
return true;
}
}
else {
return true;
}
}
/* find next unit in our faction */
do {
u2 = u2->next;
} while (u2 && u2->faction != f);
}
return false;
}
bool cansee_unit(const unit * u, const unit * target, int modifier)
/* target->region kann != u->region sein, wenn es um durchreisen geht */
{
if (fval(u_race(target), RCF_INVISIBLE) || target->number == 0)
return false;
else if (target->faction == u->faction)
return true;
else {
int n, rings, o;
if (is_guard(target, GUARD_ALL) != 0 || usiege(target) || target->building
|| target->ship) {
return true;
}
n = eff_stealth(target, target->region) - modifier;
rings = invisible(target, NULL);
if (rings == 0 && n <= 0) {
return true;
}
if (rings && invisible(target, u) >= target->number) {
return false;
}
if (skill_enabled(SK_PERCEPTION)) {
o = eff_skill(u, SK_PERCEPTION, target->region);
if (o >= n) {
return true;
}
}
else {
return true;
}
}
return false;
}
bool
cansee_durchgezogen(const faction * f, const region * r, const unit * u,
int modifier)
/* r kann != u->region sein, wenn es um durchreisen geht */
/* und es muss niemand aus f in der region sein, wenn sie vom Turm
* erblickt wird */
{
int n;
unit *u2;
if (fval(u_race(u), RCF_INVISIBLE) || u->number == 0)
return false;
else if (u->faction == f)
return true;
else {
int rings;
if (is_guard(u, GUARD_ALL) != 0 || usiege(u) || u->building || u->ship) {
return true;
}
n = eff_stealth(u, r) - modifier;
rings = invisible(u, NULL);
if (rings == 0 && n <= 0) {
return true;
}
for (u2 = r->units; u2; u2 = u2->next) {
if (u2->faction == f) {
int o;
if (rings && invisible(u, u2) >= u->number)
continue;
o = eff_skill(u2, SK_PERCEPTION, r);
if (o >= n) {
return true;
}
}
}
}
return false;
}
#ifndef NDEBUG #ifndef NDEBUG
const char *strcheck(const char *s, size_t maxlen) const char *strcheck(const char *s, size_t maxlen)
{ {
@ -1192,50 +985,11 @@ param_t getparam(const struct locale * lang)
return s ? findparam(s, lang) : NOPARAM; return s ? findparam(s, lang) : NOPARAM;
} }
faction *findfaction(int n)
{
faction *f = ffindhash(n);
return f;
}
faction *getfaction(void) faction *getfaction(void)
{ {
return findfaction(getid()); return findfaction(getid());
} }
unit *findunitr(const region * r, int n)
{
unit *u;
/* findunit regional! */
for (u = r->units; u; u = u->next)
if (u->no == n)
return u;
return 0;
}
unit *findunit(int n)
{
if (n <= 0) {
return NULL;
}
return ufindhash(n);
}
unit *findunitg(int n, const region * hint)
{
/* Abfangen von Syntaxfehlern. */
if (n <= 0)
return NULL;
/* findunit global! */
hint = 0;
return ufindhash(n);
}
unit *getnewunit(const region * r, const faction * f) unit *getnewunit(const region * r, const faction * f)
{ {
int n; int n;
@ -1685,42 +1439,6 @@ void *gc_add(void *p)
return p; return p;
} }
void add_translation(critbit_tree **cbp, const char *key, int i) {
char buffer[256];
char * str = transliterate(buffer, sizeof(buffer) - sizeof(int), key);
critbit_tree * cb = *cbp;
if (str) {
size_t len = strlen(str);
if (!cb) {
*cbp = cb = (critbit_tree *)calloc(1, sizeof(critbit_tree *));
}
len = cb_new_kv(str, len, &i, sizeof(int), buffer);
cb_insert(cb, buffer, len);
}
else {
log_error("could not transliterate '%s'\n", key);
}
}
void init_translations(const struct locale *lang, int ut, const char * (*string_cb)(int i), int maxstrings)
{
void **tokens;
int i;
assert(string_cb);
assert(maxstrings > 0);
tokens = get_translations(lang, ut);
for (i = 0; i != maxstrings; ++i) {
const char * s = string_cb(i);
const char * key = s ? locale_string(lang, s) : 0;
key = key ? key : s;
if (key) {
critbit_tree ** cb = (critbit_tree **)tokens;
add_translation(cb, key, 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);
@ -2503,7 +2221,6 @@ void attrib_init(void)
at_register(&at_clone); at_register(&at_clone);
at_register(&at_clonemage); at_register(&at_clonemage);
at_register(&at_eventhandler); at_register(&at_eventhandler);
at_register(&at_stealth);
at_register(&at_mage); at_register(&at_mage);
at_register(&at_countdown); at_register(&at_countdown);
at_register(&at_curse); at_register(&at_curse);

View File

@ -27,7 +27,6 @@ extern "C" {
#include "types.h" #include "types.h"
struct _dictionary_; struct _dictionary_;
struct critbit_tree;
/* experimental gameplay features (that don't affect the savefile) */ /* experimental gameplay features (that don't affect the savefile) */
/* TODO: move these settings to settings.h or into configuration files */ /* TODO: move these settings to settings.h or into configuration files */
#define GOBLINKILL /* Goblin-Spezialklau kann tödlich enden */ #define GOBLINKILL /* Goblin-Spezialklau kann tödlich enden */
@ -91,25 +90,18 @@ extern "C" {
#define OBJECTIDSIZE (NAMESIZE+5+IDSIZE) /* max. Länge der Strings, die #define OBJECTIDSIZE (NAMESIZE+5+IDSIZE) /* max. Länge der Strings, die
* von struct unitname, etc. zurückgegeben werden. ohne die 0 */ * von struct unitname, etc. zurückgegeben werden. ohne die 0 */
#define BAGCAPACITY 20000 /* soviel paßt in einen Bag of Holding */ #define BAGCAPACITY 20000 /* soviel paßt in einen Bag of Holding */
#define STRENGTHCAPACITY 50000 /* zusätzliche Tragkraft beim Kraftzauber (deprecated) */ #define STRENGTHCAPACITY 50000 /* zusätzliche Tragkraft beim Kraftzauber (deprecated) */
#define STRENGTHMULTIPLIER 50 /* multiplier for trollbelt */ #define STRENGTHMULTIPLIER 50 /* multiplier for trollbelt */
/* ----------------- Befehle ----------------------------------- */ /* ----------------- Befehle ----------------------------------- */
#define want(option) (1<<option) #define want(option) (1<<option)
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
void add_translation(struct critbit_tree **cb, const char *str, int i);
void init_translations(const struct locale *lang, int ut, const char * (*string_cb)(int i), int maxstrings);
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)))
typedef struct strlist {
struct strlist *next;
char *s;
} strlist;
#define fval(u, i) ((u)->flags & (i)) #define fval(u, i) ((u)->flags & (i))
#define fset(u, i) ((u)->flags |= (i)) #define fset(u, i) ((u)->flags |= (i))
#define freset(u, i) ((u)->flags &= ~(i)) #define freset(u, i) ((u)->flags &= ~(i))
@ -129,9 +121,13 @@ extern "C" {
/* special units */ /* special units */
void make_undead_unit(struct unit *); void make_undead_unit(struct unit *);
void addstrlist(strlist ** SP, const char *s); typedef struct strlist {
struct strlist *next;
char *s;
} strlist;
int armedmen(const struct unit *u, bool siege_weapons); void addstrlist(strlist ** SP, const char *s);
void freestrlist(strlist * s);
unsigned int atoip(const char *s); unsigned int atoip(const char *s);
unsigned int getuint(void); unsigned int getuint(void);
@ -155,15 +151,6 @@ 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)
bool cansee(const struct faction *f, const struct region *r,
const struct unit *u, int modifier);
bool cansee_durchgezogen(const struct faction *f, const struct region *r,
const struct unit *u, int modifier);
bool cansee_unit(const struct unit *u, const struct unit *target,
int modifier);
bool seefaction(const struct faction *f, const struct region *r,
const struct unit *u, int modifier);
const char * game_name(void); const char * game_name(void);
int game_id(void); int game_id(void);
int lovar(double xpct_x2); int lovar(double xpct_x2);
@ -191,15 +178,8 @@ extern "C" {
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 *getfaction(void); struct faction *getfaction(void);
struct unit *findunitg(int n, const struct region *hint);
struct unit *findunit(int n);
struct unit *findunitr(const struct region *r, int n);
struct region *findunitregion(const struct unit *su);
char *estring(const char *s); char *estring(const char *s);
char *estring_i(char *s); char *estring_i(char *s);
char *cstring(const char *s); char *cstring(const char *s);
@ -252,7 +232,6 @@ extern "C" {
* sonst großes Unglück. Durch asserts an ein paar Stellen abgesichert. */ * sonst großes Unglück. Durch asserts an ein paar Stellen abgesichert. */
void verify_data(void); void verify_data(void);
void freestrlist(strlist * s);
int change_hitpoints(struct unit *u, int value); int change_hitpoints(struct unit *u, int value);
@ -263,9 +242,6 @@ extern "C" {
struct region *firstregion(struct faction *f); struct region *firstregion(struct faction *f);
struct region *lastregion(struct faction *f); struct region *lastregion(struct faction *f);
void fhash(struct faction *f);
void funhash(struct faction *f);
bool idle(struct faction *f); bool idle(struct faction *f);
bool unit_has_cursed_item(struct unit *u); bool unit_has_cursed_item(struct unit *u);

View File

@ -25,6 +25,13 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
extern "C" { extern "C" {
#endif #endif
struct attrib;
struct attrib_type;
struct faction;
struct region;
struct storage;
struct unit;
extern int nextborder; extern int nextborder;
typedef struct connection { typedef struct connection {

View File

@ -23,7 +23,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* kernel includes */ /* kernel includes */
#include "building.h" #include "building.h"
#include "faction.h" #include "faction.h"
#include "magic.h"
#include "messages.h" #include "messages.h"
#include "objtypes.h" #include "objtypes.h"
#include "race.h" #include "race.h"

View File

@ -24,34 +24,36 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
struct spell; struct spell;
struct item;
struct unit;
typedef struct itemdata { typedef struct itemdata {
const struct item_type *itype; const struct item_type *itype;
char *value; char *value;
struct itemdata *next; struct itemdata *next;
} itemdata; } itemdata;
typedef struct subsetitem {
struct equipment *set;
float chance;
} subsetitem;
typedef struct subset {
float chance;
subsetitem *sets;
} subset;
typedef struct equipment {
char *name;
struct itemdata *items;
char *skills[MAXSKILLS];
struct spellbook *spellbook;
struct subset *subsets;
struct equipment *next;
void (*callback) (const struct equipment *, struct unit *);
} equipment;
typedef struct subsetitem {
struct equipment *set;
float chance;
} subsetitem;
typedef struct subset {
float chance;
subsetitem *sets;
} subset;
typedef struct equipment {
char *name;
struct itemdata *items;
char *skills[MAXSKILLS];
struct spellbook *spellbook;
struct subset *subsets;
struct equipment *next;
void (*callback) (const struct equipment *, struct unit *);
} equipment;
extern struct equipment *create_equipment(const char *eqname); extern struct equipment *create_equipment(const char *eqname);
extern struct equipment *get_equipment(const char *eqname); extern struct equipment *get_equipment(const char *eqname);

View File

@ -1,10 +1,10 @@
#include <platform.h> #include <platform.h>
#include <kernel/types.h> #include "magic.h"
#include <kernel/equipment.h> #include <kernel/equipment.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/unit.h> #include <kernel/unit.h>
#include <kernel/magic.h>
#include <kernel/spell.h> #include <kernel/spell.h>
#include <quicklist.h> #include <quicklist.h>

View File

@ -99,6 +99,40 @@ void free_faction(faction * f)
freelist(f->ursprung); freelist(f->ursprung);
} }
#define FMAXHASH 2039
faction *factionhash[FMAXHASH];
void fhash(faction * f)
{
int index = f->no % FMAXHASH;
f->nexthash = factionhash[index];
factionhash[index] = f;
}
void funhash(faction * f)
{
int index = f->no % FMAXHASH;
faction **fp = factionhash + index;
while (*fp && (*fp) != f)
fp = &(*fp)->nexthash;
*fp = f->nexthash;
}
static faction *ffindhash(int no)
{
int index = no % FMAXHASH;
faction *f = factionhash[index];
while (f && f->no != no)
f = f->nexthash;
return f;
}
faction *findfaction(int n)
{
faction *f = ffindhash(n);
return f;
}
void set_show_item(faction * f, const struct item_type *itype) void set_show_item(faction * f, const struct item_type *itype)
{ {
attrib *a = a_add(&f->attribs, a_new(&at_showitem)); attrib *a = a_add(&f->attribs, a_new(&at_showitem));
@ -215,7 +249,7 @@ faction *addfaction(const char *email, const char *password,
char buf[128]; char buf[128];
if (set_email(&f->email, email) != 0) { if (set_email(&f->email, email) != 0) {
log_error("Invalid email address for faction %s: %s\n", itoa36(f->no), email); log_warning("Invalid email address for faction %s: %s\n", itoa36(f->no), email);
} }
faction_setpassword(f, password); faction_setpassword(f, password);

View File

@ -112,6 +112,10 @@ typedef struct faction {
extern struct faction *factions; extern struct faction *factions;
void fhash(struct faction *f);
void funhash(struct faction *f);
struct faction *findfaction(int n);
struct faction *get_monsters(void); struct faction *get_monsters(void);
struct faction *get_or_create_monsters(void); struct faction *get_or_create_monsters(void);
int max_magicians(const faction * f); int max_magicians(const faction * f);

View File

@ -2,7 +2,6 @@
#include <kernel/ally.h> #include <kernel/ally.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/types.h>
#include <kernel/race.h> #include <kernel/race.h>
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/config.h> #include <kernel/config.h>
@ -47,6 +46,7 @@ static void test_remove_empty_factions(CuTest *tc) {
static void test_remove_dead_factions(CuTest *tc) { static void test_remove_dead_factions(CuTest *tc) {
faction *f, *fm; faction *f, *fm;
region *r; region *r;
int fno;
test_cleanup(); test_cleanup();
r = test_create_region(0, 0, 0); r = test_create_region(0, 0, 0);
@ -60,8 +60,9 @@ static void test_remove_dead_factions(CuTest *tc) {
CuAssertPtrNotNull(tc, get_monsters()); CuAssertPtrNotNull(tc, get_monsters());
fm->alive = 0; fm->alive = 0;
f->alive = 0; f->alive = 0;
fno = f->no;
remove_empty_factions(); remove_empty_factions();
CuAssertPtrEquals(tc, 0, findfaction(f->no)); CuAssertPtrEquals(tc, 0, findfaction(fno));
CuAssertPtrEquals(tc, fm, get_monsters()); CuAssertPtrEquals(tc, fm, get_monsters());
test_cleanup(); test_cleanup();
} }

View File

@ -22,9 +22,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
extern "C" { extern "C" {
#endif #endif
/* bitfield value for group::flags */
#define GFL_ALIVE 0x01 /* There is at least one struct unit in the group */
struct gamedata; struct gamedata;
typedef struct group { typedef struct group {
@ -34,7 +31,6 @@ extern "C" {
struct attrib *attribs; struct attrib *attribs;
char *name; char *name;
struct ally *allies; struct ally *allies;
int flags;
int gid; int gid;
int members; int members;
} group; } group;

45
src/kernel/group.test.c Normal file
View File

@ -0,0 +1,45 @@
#include <platform.h>
#include "types.h"
#include "group.h"
#include "faction.h"
#include "unit.h"
#include "region.h"
#include <CuTest.h>
#include <tests.h>
#include <assert.h>
static void test_group(CuTest * tc)
{
unit *u;
region *r;
faction *f;
group *g;
test_cleanup();
test_create_world();
r = findregion(0, 0);
f = test_create_faction(0);
assert(r && f);
u = test_create_unit(f, r);
assert(u);
CuAssertTrue(tc, join_group(u, "hodor"));
CuAssertPtrNotNull(tc, (g = get_group(u)));
CuAssertStrEquals(tc, "hodor", g->name);
CuAssertIntEquals(tc, 1, g->members);
set_group(u, 0);
CuAssertIntEquals(tc, 0, g->members);
CuAssertPtrEquals(tc, 0, get_group(u));
set_group(u, g);
CuAssertIntEquals(tc, 1, g->members);
CuAssertPtrEquals(tc, g, get_group(u));
test_cleanup();
}
CuSuite *get_group_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_group);
return suite;
}

View File

@ -26,13 +26,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
extern "C" { extern "C" {
#endif #endif
struct unit; struct unit;
struct attrib; struct attrib;
struct attrib_type; struct attrib_type;
struct region; struct region;
struct resource_type; struct resource_type;
struct locale; struct locale;
struct troop; struct troop;
struct item;
struct order;
typedef struct item { typedef struct item {
struct item *next; struct item *next;

View File

@ -1,6 +1,5 @@
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/pool.h> #include <kernel/pool.h>
#include <kernel/unit.h> #include <kernel/unit.h>

View File

@ -22,6 +22,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
extern "C" { extern "C" {
#endif #endif
struct region;
struct plane;
struct storage;
#define PFL_NOCOORDS 1 /* not in use */ #define PFL_NOCOORDS 1 /* not in use */
#define PFL_NORECRUITS 2 #define PFL_NORECRUITS 2
#define PFL_NOALLIANCES 4 #define PFL_NOALLIANCES 4

View File

@ -22,7 +22,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "faction.h" #include "faction.h"
#include "item.h" #include "item.h"
#include "magic.h"
#include "order.h" #include "order.h"
#include "region.h" #include "region.h"
#include "race.h" #include "race.h"

View File

@ -22,6 +22,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
extern "C" { extern "C" {
#endif #endif
struct unit;
struct resource_type;
struct region;
/* bitfield values for get/use/change operations */ /* bitfield values for get/use/change operations */
#define GET_SLACK 0x01 #define GET_SLACK 0x01
#define GET_RESERVE 0x02 #define GET_RESERVE 0x02

View File

@ -1,5 +1,4 @@
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include "ally.h" #include "ally.h"
#include "pool.h" #include "pool.h"
@ -15,6 +14,34 @@
#include <assert.h> #include <assert.h>
#include <limits.h> #include <limits.h>
void test_reservation(CuTest *tc) {
unit *u;
faction *f;
region *r;
struct resource_type *rtype;
test_cleanup();
test_create_world();
rtype = rt_get_or_create("money");
it_get_or_create(rtype);
f = test_create_faction(0);
r = findregion(0, 0);
assert(r && f && rtype && rtype->itype);
u = test_create_unit(f, r);
assert(u);
i_change(&u->items, rtype->itype, 100);
CuAssertIntEquals(tc, 100, get_resource(u, rtype));
CuAssertIntEquals(tc, 0, get_reservation(u, rtype));
CuAssertIntEquals(tc, 50, change_reservation(u, rtype, 50));
CuAssertIntEquals(tc, 100, change_reservation(u, rtype, 50));
CuAssertIntEquals(tc, 50, set_resvalue(u, rtype, 50));
CuAssertIntEquals(tc, 100, get_resource(u, rtype));
CuAssertIntEquals(tc, 200, change_resource(u, rtype, 100));
CuAssertIntEquals(tc, 200, get_resource(u, rtype));
CuAssertIntEquals(tc, 200, i_get(u->items, rtype->itype));
test_cleanup();
}
void test_pool(CuTest *tc) { void test_pool(CuTest *tc) {
unit *u1, *u2, *u3; unit *u1, *u2, *u3;
faction *f; faction *f;
@ -60,6 +87,52 @@ void test_pool(CuTest *tc) {
CuAssertIntEquals(tc, 300, get_pooled(u1, rtype, GET_ALL, INT_MAX)); CuAssertIntEquals(tc, 300, get_pooled(u1, rtype, GET_ALL, INT_MAX));
} }
void test_pool_use(CuTest *tc) {
unit *u1, *u2, *u3;
faction *f;
region *r;
struct resource_type *rtype;
ally *al;
test_cleanup();
test_create_world();
rtype = rt_get_or_create("money");
it_get_or_create(rtype);
f = test_create_faction(0);
r = findregion(0, 0);
assert(r && f && rtype && rtype->itype);
u1 = test_create_unit(f, r);
u2 = test_create_unit(f, r);
u3 = test_create_unit(test_create_faction(0), r);
assert(u1 && u2);
i_change(&u1->items, rtype->itype, 100);
set_resvalue(u1, rtype, 50);
i_change(&u2->items, rtype->itype, 200);
set_resvalue(u2, rtype, 100);
i_change(&u3->items, rtype->itype, 400);
set_resvalue(u3, rtype, 200);
al = ally_add(&u3->faction->allies, f);
al->status = HELP_MONEY;
CuAssertIntEquals(tc, 10, use_pooled(u1, rtype, GET_SLACK, 10));
CuAssertIntEquals(tc, 40, use_pooled(u1, rtype, GET_SLACK, 50));
CuAssertIntEquals(tc, 50, i_get(u1->items, rtype->itype));
CuAssertIntEquals(tc, 50, get_reservation(u1, rtype));
CuAssertIntEquals(tc, 10, use_pooled(u1, rtype, GET_RESERVE, 10));
CuAssertIntEquals(tc, 40, i_get(u1->items, rtype->itype));
CuAssertIntEquals(tc, 40, get_reservation(u1, rtype));
CuAssertIntEquals(tc, 40, use_pooled(u1, rtype, GET_RESERVE, 50));
CuAssertIntEquals(tc, 10, use_pooled(u1, rtype, GET_POOLED_SLACK, 10));
CuAssertIntEquals(tc, 90, use_pooled(u1, rtype, GET_POOLED_SLACK, 100));
CuAssertIntEquals(tc, 100, i_get(u2->items, rtype->itype));
CuAssertIntEquals(tc, 10, use_pooled(u1, rtype, GET_POOLED_RESERVE, 10));
CuAssertIntEquals(tc, 90, get_reservation(u2, rtype));
CuAssertIntEquals(tc, 90, use_pooled(u1, rtype, GET_POOLED_RESERVE, 100));
CuAssertIntEquals(tc, 0, i_get(u2->items, rtype->itype));
}
void test_change_resource(CuTest * tc) void test_change_resource(CuTest * tc)
{ {
struct unit * u; struct unit * u;
@ -90,7 +163,9 @@ void test_change_resource(CuTest * tc)
CuSuite *get_pool_suite(void) CuSuite *get_pool_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_reservation);
SUITE_ADD_TEST(suite, test_pool); SUITE_ADD_TEST(suite, test_pool);
SUITE_ADD_TEST(suite, test_pool_use);
SUITE_ADD_TEST(suite, test_change_resource); SUITE_ADD_TEST(suite, test_change_resource);
return suite; return suite;
} }

View File

@ -27,7 +27,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "faction.h" #include "faction.h"
#include "group.h" #include "group.h"
#include "item.h" #include "item.h"
#include "magic.h"
#include "names.h" #include "names.h"
#include "pathfinder.h" #include "pathfinder.h"
#include "region.h" #include "region.h"

View File

@ -20,7 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/config.h> #include <kernel/config.h>
#include "save.h" #include "save.h"
#include "../build.h" #include "../buildno.h"
#include "alchemy.h" #include "alchemy.h"
#include "alliance.h" #include "alliance.h"
@ -30,7 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "faction.h" #include "faction.h"
#include "group.h" #include "group.h"
#include "item.h" #include "item.h"
#include "magic.h"
#include "messages.h" #include "messages.h"
#include "move.h" #include "move.h"
#include "objtypes.h" #include "objtypes.h"

View File

@ -22,6 +22,13 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
extern "C" { extern "C" {
#endif #endif
struct attrib;
struct item;
struct storage;
struct spell;
struct spellbook;
struct unit;
typedef struct gamedata { typedef struct gamedata {
struct storage *store; struct storage *store;
int version; int version;

View File

@ -1,7 +1,6 @@
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/types.h>
#include <kernel/race.h> #include <kernel/race.h>
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/ship.h> #include <kernel/ship.h>

View File

@ -22,7 +22,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "curse.h" #include "curse.h"
#include "item.h" #include "item.h"
#include "magic.h"
#include "race.h" #include "race.h"
#include "region.h" #include "region.h"
#include "terrain.h" #include "terrain.h"

View File

@ -22,7 +22,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
extern "C" { extern "C" {
#endif #endif
struct castorder; struct castorder;
struct unit;
struct region;
struct spell;
struct spell_component;
struct quicklist;
struct attrib_type;
typedef int (*spell_f)(struct castorder * co); typedef int (*spell_f)(struct castorder * co);
typedef void(*fumble_f)(const struct castorder * co); typedef void(*fumble_f)(const struct castorder * co);

View File

@ -1,9 +1,7 @@
#include <platform.h> #include <platform.h>
#include <quicklist.h> #include <quicklist.h>
#include <kernel/types.h>
#include <kernel/spell.h> #include <kernel/spell.h>
#include <kernel/magic.h>
#include <CuTest.h> #include <CuTest.h>
#include <tests.h> #include <tests.h>

View File

@ -1,7 +1,6 @@
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/spell.h> #include <kernel/spell.h>
#include <kernel/magic.h>
#include <quicklist.h> #include <quicklist.h>
#include <util/log.h> #include <util/log.h>

View File

@ -1,7 +1,5 @@
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include <kernel/magic.h>
#include <kernel/spell.h> #include <kernel/spell.h>
#include <kernel/spellbook.h> #include <kernel/spellbook.h>
#include <quicklist.h> #include <quicklist.h>

View File

@ -18,7 +18,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/types.h>
#include "unit.h" #include "unit.h"
#include "building.h" #include "building.h"
@ -42,6 +41,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <attributes/moved.h> #include <attributes/moved.h>
#include <attributes/otherfaction.h> #include <attributes/otherfaction.h>
#include <attributes/racename.h> #include <attributes/racename.h>
#include <attributes/stealth.h>
/* util includes */ /* util includes */
#include <util/attrib.h> #include <util/attrib.h>
@ -56,8 +56,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/rng.h> #include <util/rng.h>
#include <util/variant.h> #include <util/variant.h>
#include <stealth.h>
#include <storage.h> #include <storage.h>
/* libc includes */ /* libc includes */
@ -74,6 +72,39 @@ attrib_type at_creator = {
/* Rest ist NULL; temporaeres, nicht alterndes Attribut */ /* Rest ist NULL; temporaeres, nicht alterndes Attribut */
}; };
unit *findunitr(const region * r, int n)
{
unit *u;
/* findunit regional! */
for (u = r->units; u; u = u->next)
if (u->no == n)
return u;
return 0;
}
unit *findunit(int n)
{
if (n <= 0) {
return NULL;
}
return ufindhash(n);
}
unit *findunitg(int n, const region * hint)
{
/* Abfangen von Syntaxfehlern. */
if (n <= 0)
return NULL;
/* findunit global! */
hint = 0;
return ufindhash(n);
}
#define UMAXHASH MAXUNITS #define UMAXHASH MAXUNITS
static unit *unithash[UMAXHASH]; static unit *unithash[UMAXHASH];
static unit *delmarker = (unit *)unithash; /* a funny hack */ static unit *delmarker = (unit *)unithash; /* a funny hack */
@ -702,6 +733,7 @@ void set_level(unit * u, skill_t sk, int value)
{ {
skill *sv = u->skills; skill *sv = u->skills;
assert(sk != SK_MAGIC || !u->faction || is_monsters(u->faction) || u->number == 1);
if (!skill_enabled(sk)) if (!skill_enabled(sk))
return; return;
@ -1165,8 +1197,8 @@ skill *add_skill(unit * u, skill_t id)
sv->weeks = 1; sv->weeks = 1;
sv->old = 0; sv->old = 0;
sv->id = id; sv->id = id;
if (id == SK_MAGIC && u->faction) { if (id == SK_MAGIC && u->faction && !is_monsters(u->faction)) {
assert(max_magicians(u->faction) >= u->number); assert(u->number==1 && max_magicians(u->faction) >= u->number);
} }
return sv; return sv;
} }

View File

@ -114,6 +114,7 @@ extern "C" {
int wants; /* enno: attribut? */ int wants; /* enno: attribut? */
} unit; } unit;
extern struct attrib_type at_creator;
extern struct attrib_type at_alias; extern struct attrib_type at_alias;
extern struct attrib_type at_siege; extern struct attrib_type at_siege;
extern struct attrib_type at_target; extern struct attrib_type at_target;
@ -216,9 +217,9 @@ extern "C" {
int number, const struct race *rc, int id, const char *dname, int number, const struct race *rc, int id, const char *dname,
struct unit *creator); struct unit *creator);
extern void uhash(struct unit *u); void uhash(struct unit *u);
extern void uunhash(struct unit *u); void uunhash(struct unit *u);
extern struct unit *ufindhash(int i); struct unit *ufindhash(int i);
const char *unit_getname(const struct unit *u); const char *unit_getname(const struct unit *u);
void unit_setname(struct unit *u, const char *name); void unit_setname(struct unit *u, const char *name);
@ -241,7 +242,11 @@ extern "C" {
void remove_empty_units_in_region(struct region * r); void remove_empty_units_in_region(struct region * r);
void remove_empty_units(void); void remove_empty_units(void);
extern struct attrib_type at_creator; struct unit *findunitg(int n, const struct region *hint);
struct unit *findunit(int n);
struct unit *findunitr(const struct region *r, int n);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,5 +1,4 @@
#include <platform.h> #include <platform.h>
#include "kernel/types.h"
#include "kernel/config.h" #include "kernel/config.h"
#include "kernel/order.h" #include "kernel/order.h"
#include "keyword.h" #include "keyword.h"

View File

@ -45,7 +45,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/group.h> #include <kernel/group.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/plane.h> #include <kernel/plane.h>
@ -63,9 +62,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/unit.h> #include <kernel/unit.h>
/* attributes includes */ /* attributes includes */
#include <attributes/object.h>
#include <attributes/racename.h> #include <attributes/racename.h>
#include <attributes/raceprefix.h> #include <attributes/raceprefix.h>
#include <attributes/object.h> #include <attributes/stealth.h>
/* util includes */ /* util includes */
#include <util/attrib.h> #include <util/attrib.h>
@ -4182,6 +4182,34 @@ void process(void)
} }
int armedmen(const unit * u, bool siege_weapons)
{
item *itm;
int n = 0;
if (!(urace(u)->flags & RCF_NOWEAPONS)) {
if (effskill(u, SK_WEAPONLESS) >= 1) {
/* kann ohne waffen bewachen: fuer drachen */
n = u->number;
}
else {
/* alle Waffen werden gezaehlt, und dann wird auf die Anzahl
* Personen minimiert */
for (itm = u->items; itm; itm = itm->next) {
const weapon_type *wtype = resource2weapon(itm->type->rtype);
if (wtype == NULL || (!siege_weapons && (wtype->flags & WTF_SIEGE)))
continue;
if (effskill(u, wtype->skill) >= wtype->minskill)
n += itm->number;
/* if (effskill(u, wtype->skill) >= wtype->minskill) n += itm->number; */
if (n > u->number)
break;
}
n = _min(n, u->number);
}
}
return n;
}
int siege_cmd(unit * u, order * ord) int siege_cmd(unit * u, order * ord)
{ {
region *r = u->region; region *r = u->region;
@ -4554,3 +4582,158 @@ void update_subscriptions(void)
} }
fclose(F); fclose(F);
} }
bool
cansee(const faction * f, const region * r, const unit * u, int modifier)
/* r kann != u->region sein, wenn es um durchreisen geht */
/* und es muss niemand aus f in der region sein, wenn sie vom Turm
* erblickt wird */
{
int stealth, rings;
unit *u2 = r->units;
if (u->faction == f || omniscient(f)) {
return true;
}
else if (fval(u_race(u), RCF_INVISIBLE)) {
return false;
}
else if (u->number == 0) {
attrib *a = a_find(u->attribs, &at_creator);
if (a) { /* u is an empty temporary unit. In this special case
we look at the creating unit. */
u = (unit *)a->data.v;
}
else {
return false;
}
}
if (leftship(u))
return true;
while (u2 && u2->faction != f)
u2 = u2->next;
if (u2 == NULL)
return false;
/* simple visibility, just gotta have a unit in the region to see 'em */
if (is_guard(u, GUARD_ALL) != 0 || usiege(u) || u->building || u->ship) {
return true;
}
rings = invisible(u, NULL);
stealth = eff_stealth(u, r) - modifier;
while (u2) {
if (rings < u->number || invisible(u, u2) < u->number) {
if (skill_enabled(SK_PERCEPTION)) {
int observation = eff_skill(u2, SK_PERCEPTION, r);
if (observation >= stealth) {
return true;
}
}
else {
return true;
}
}
/* find next unit in our faction */
do {
u2 = u2->next;
} while (u2 && u2->faction != f);
}
return false;
}
bool cansee_unit(const unit * u, const unit * target, int modifier)
/* target->region kann != u->region sein, wenn es um durchreisen geht */
{
if (fval(u_race(target), RCF_INVISIBLE) || target->number == 0)
return false;
else if (target->faction == u->faction)
return true;
else {
int n, rings, o;
if (is_guard(target, GUARD_ALL) != 0 || usiege(target) || target->building
|| target->ship) {
return true;
}
n = eff_stealth(target, target->region) - modifier;
rings = invisible(target, NULL);
if (rings == 0 && n <= 0) {
return true;
}
if (rings && invisible(target, u) >= target->number) {
return false;
}
if (skill_enabled(SK_PERCEPTION)) {
o = eff_skill(u, SK_PERCEPTION, target->region);
if (o >= n) {
return true;
}
}
else {
return true;
}
}
return false;
}
bool
cansee_durchgezogen(const faction * f, const region * r, const unit * u,
int modifier)
/* r kann != u->region sein, wenn es um durchreisen geht */
/* und es muss niemand aus f in der region sein, wenn sie vom Turm
* erblickt wird */
{
int n;
unit *u2;
if (fval(u_race(u), RCF_INVISIBLE) || u->number == 0)
return false;
else if (u->faction == f)
return true;
else {
int rings;
if (is_guard(u, GUARD_ALL) != 0 || usiege(u) || u->building || u->ship) {
return true;
}
n = eff_stealth(u, r) - modifier;
rings = invisible(u, NULL);
if (rings == 0 && n <= 0) {
return true;
}
for (u2 = r->units; u2; u2 = u2->next) {
if (u2->faction == f) {
int o;
if (rings && invisible(u, u2) >= u->number)
continue;
o = eff_skill(u2, SK_PERCEPTION, r);
if (o >= n) {
return true;
}
}
}
}
return false;
}
bool
seefaction(const faction * f, const region * r, const unit * u, int modifier)
{
if (((f == u->faction) || !fval(u, UFL_ANON_FACTION))
&& cansee(f, r, u, modifier))
return true;
return false;
}

View File

@ -22,17 +22,24 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
extern "C" { extern "C" {
#endif #endif
extern int writepasswd(void); struct unit;
void demographics(void); struct region;
void update_guards(void); struct building;
void update_subscriptions(void); struct faction;
void deliverMail(struct faction *f, struct region *r, struct unit *u, struct order;
const char *s, struct unit *receiver); struct attrib_type;
bool renamed_building(const struct building * b); int writepasswd(void);
int rename_building(struct unit * u, struct order * ord, struct building * b, const char *name); void demographics(void);
void get_food(struct region * r); void update_guards(void);
extern int can_contact(const struct region *r, const struct unit *u, const struct unit *u2); void update_subscriptions(void);
void deliverMail(struct faction *f, struct region *r, struct unit *u,
const char *s, struct unit *receiver);
bool renamed_building(const struct building * b);
int rename_building(struct unit * u, struct order * ord, struct building * b, const char *name);
void get_food(struct region * r);
int can_contact(const struct region *r, const struct unit *u, const struct unit *u2);
/* eressea-specific. put somewhere else, please. */ /* eressea-specific. put somewhere else, please. */
void processorders(void); void processorders(void);
@ -84,6 +91,17 @@ extern "C" {
extern int claim_cmd(struct unit *u, struct order *ord); extern int claim_cmd(struct unit *u, struct order *ord);
extern int follow_cmd(struct unit *u, struct order *ord); extern int follow_cmd(struct unit *u, struct order *ord);
bool cansee(const struct faction *f, const struct region *r,
const struct unit *u, int modifier);
bool cansee_durchgezogen(const struct faction *f, const struct region *r,
const struct unit *u, int modifier);
bool cansee_unit(const struct unit *u, const struct unit *target,
int modifier);
bool seefaction(const struct faction *f, const struct region *r,
const struct unit *u, int modifier);
int armedmen(const struct unit *u, bool siege_weapons);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,5 +1,4 @@
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include "laws.h" #include "laws.h"
#include <kernel/ally.h> #include <kernel/ally.h>

View File

@ -19,30 +19,31 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/types.h>
#include "magic.h" #include "magic.h"
#include "building.h"
#include "curse.h"
#include "faction.h"
#include "item.h"
#include "messages.h"
#include "objtypes.h"
#include "order.h"
#include "pathfinder.h"
#include "plane.h"
#include "pool.h"
#include "race.h"
#include "region.h"
#include "save.h"
#include "ship.h"
#include "skill.h" #include "skill.h"
#include "spell.h" #include "laws.h"
#include "spellbook.h"
#include "teleport.h" #include <kernel/building.h>
#include "terrain.h" #include <kernel/curse.h>
#include "unit.h" #include <kernel/faction.h>
#include "version.h" #include <kernel/item.h>
#include <kernel/messages.h>
#include <kernel/objtypes.h>
#include <kernel/order.h>
#include <kernel/pathfinder.h>
#include <kernel/plane.h>
#include <kernel/pool.h>
#include <kernel/race.h>
#include <kernel/region.h>
#include <kernel/save.h>
#include <kernel/ship.h>
#include <kernel/spell.h>
#include <kernel/spellbook.h>
#include <kernel/teleport.h>
#include <kernel/terrain.h>
#include <kernel/unit.h>
#include <kernel/version.h>
#include <triggers/timeout.h> #include <triggers/timeout.h>
#include <triggers/shock.h> #include <triggers/shock.h>

View File

@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef H_KRNL_MAGIC #ifndef H_KRNL_MAGIC
#define H_KRNL_MAGIC #define H_KRNL_MAGIC
#include <kernel/types.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -1,9 +1,9 @@
#include <platform.h> #include <platform.h>
#include <kernel/types.h> #include "magic.h"
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/spell.h> #include <kernel/spell.h>
#include <kernel/spellbook.h> #include <kernel/spellbook.h>

View File

@ -20,7 +20,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/log.h> #include <util/log.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/types.h>
#include <kernel/save.h> #include <kernel/save.h>
#include <kernel/version.h> #include <kernel/version.h>
#include "eressea.h" #include "eressea.h"
@ -28,7 +27,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "gmtool.h" #include "gmtool.h"
#endif #endif
#include "build.h" #include "buildno.h"
#include "bindings.h" #include "bindings.h"
#include "races/races.h" #include "races/races.h"
#include "spells.h" #include "spells.h"

View File

@ -1,5 +1,4 @@
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include "market.h" #include "market.h"
#include "tests.h" #include "tests.h"

View File

@ -32,7 +32,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/building.h> #include <kernel/building.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/plane.h> #include <kernel/plane.h>

View File

@ -26,7 +26,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/building.h> #include <kernel/building.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/race.h> #include <kernel/race.h>
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/ship.h> #include <kernel/ship.h>

View File

@ -25,6 +25,7 @@
#include "economy.h" #include "economy.h"
#include "give.h" #include "give.h"
#include "monster.h" #include "monster.h"
#include "laws.h"
/* triggers includes */ /* triggers includes */
#include <triggers/removecurse.h> #include <triggers/removecurse.h>

View File

@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include "move.h" #include "move.h"
#include "laws.h"
#include "reports.h" #include "reports.h"
#include "alchemy.h" #include "alchemy.h"
#include "vortex.h" #include "vortex.h"
@ -31,7 +32,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/curse.h> #include <kernel/curse.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/plane.h> #include <kernel/plane.h>
@ -60,15 +60,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/rand.h> #include <util/rand.h>
#include <util/rng.h> #include <util/rng.h>
#include <stealth.h>
#include <storage.h> #include <storage.h>
/* attributes includes */ /* attributes includes */
#include <attributes/follow.h> #include <attributes/follow.h>
#include <attributes/targetregion.h>
#include <attributes/movement.h> #include <attributes/movement.h>
#include <attributes/otherfaction.h> #include <attributes/otherfaction.h>
#include <attributes/stealth.h>
#include <attributes/targetregion.h>
/* libc includes */ /* libc includes */
#include <assert.h> #include <assert.h>

View File

@ -26,6 +26,8 @@ extern "C" {
#endif #endif
struct unit; struct unit;
struct region;
struct region_list;
struct ship; struct ship;
struct building_type; struct building_type;

View File

@ -1,4 +1,3 @@
#include <kernel/types.h>
#include <platform.h> #include <platform.h>
#include <stdlib.h> #include <stdlib.h>
#include "move.h" #include "move.h"

View File

@ -24,7 +24,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/unit.h> #include <kernel/unit.h>
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/magic.h>
#include <kernel/race.h> #include <kernel/race.h>
#include <kernel/terrain.h> #include <kernel/terrain.h>
#include <kernel/terrainid.h> #include <kernel/terrainid.h>

View File

@ -31,7 +31,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/equipment.h> #include <kernel/equipment.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/plane.h> #include <kernel/plane.h>

View File

@ -22,6 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/config.h> #include <kernel/config.h>
#include "reports.h" #include "reports.h"
#include "laws.h"
/* modules includes */ /* modules includes */
#include <modules/score.h> #include <modules/score.h>

View File

@ -19,6 +19,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include "reports.h" #include "reports.h"
#include "laws.h"
/* kernel includes */ /* kernel includes */
#include <kernel/alliance.h> #include <kernel/alliance.h>
@ -64,9 +65,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <attributes/follow.h> #include <attributes/follow.h>
#include <attributes/otherfaction.h> #include <attributes/otherfaction.h>
#include <attributes/racename.h> #include <attributes/racename.h>
#include <attributes/stealth.h>
#include "move.h" #include "move.h"
#include "stealth.h"
bool nocr = false; bool nocr = false;
bool nonr = false; bool nonr = false;

View File

@ -21,6 +21,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <time.h> #include <time.h>
#include <kernel/objtypes.h> #include <kernel/objtypes.h>
#include <kernel/types.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -1,5 +1,4 @@
#include <config.h> #include <config.h>
#include <kernel/types.h>
#include "reports.h" #include "reports.h"
#include <kernel/building.h> #include <kernel/building.h>

View File

@ -1,5 +1,4 @@
#include <platform.h> #include <platform.h>
#include "kernel/types.h"
#include "skill.h" #include "skill.h"
#include "util/language.h" #include "util/language.h"
#include "tests.h" #include "tests.h"

View File

@ -13,11 +13,11 @@
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include <kernel/config.h> #include <kernel/config.h>
#include "spy.h" #include "spy.h"
#include "vortex.h" #include "vortex.h"
#include "laws.h"
#include "spells.h" #include "spells.h"
#include "direction.h" #include "direction.h"
@ -37,7 +37,6 @@
#include <kernel/spellid.h> #include <kernel/spellid.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/objtypes.h> #include <kernel/objtypes.h>
#include <kernel/order.h> #include <kernel/order.h>

View File

@ -17,7 +17,6 @@
#include <kernel/curse.h> #include <kernel/curse.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/magic.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/race.h> #include <kernel/race.h>
#include <kernel/region.h> #include <kernel/region.h>

View File

@ -1,5 +1,4 @@
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include "borders.h" #include "borders.h"

View File

@ -11,7 +11,6 @@
*/ */
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/types.h>
#include "combatspells.h" #include "combatspells.h"
/* kernel includes */ /* kernel includes */
@ -20,7 +19,6 @@
#include <kernel/curse.h> #include <kernel/curse.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/race.h> #include <kernel/race.h>

View File

@ -14,10 +14,10 @@
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include "regioncurse.h" #include "regioncurse.h"
#include "magic.h"
/* kernel includes */ /* kernel includes */
#include <kernel/curse.h> #include <kernel/curse.h>
#include <kernel/magic.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/objtypes.h> #include <kernel/objtypes.h>
#include <kernel/region.h> #include <kernel/region.h>

View File

@ -20,15 +20,19 @@
extern "C" { extern "C" {
#endif #endif
struct locale; struct locale;
struct message; struct message;
extern struct message *cinfo_ship(const void *obj, objtype_t typ, struct ship;
const struct curse *c, int self); struct unit;
extern void register_shipcurse(void); struct curse;
extern struct curse *shipcurse_flyingship(struct ship *sh, struct unit *mage,
float power, int duration); struct message *cinfo_ship(const void *obj, objtype_t typ,
int levitate_ship(struct ship *sh, struct unit *mage, float power, const struct curse *c, int self);
int duration); void register_shipcurse(void);
struct curse *shipcurse_flyingship(struct ship *sh, struct unit *mage,
float power, int duration);
int levitate_ship(struct ship *sh, struct unit *mage, float power,
int duration);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -20,14 +20,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/config.h> #include <kernel/config.h>
#include "spy.h" #include "spy.h"
#include "laws.h" #include "laws.h"
#include "stealth.h"
#include "move.h" #include "move.h"
#include "reports.h" #include "reports.h"
/* kernel includes */ /* kernel includes */
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/magic.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/race.h> #include <kernel/race.h>
@ -37,8 +35,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/unit.h> #include <kernel/unit.h>
/* attributes includes */ /* attributes includes */
#include <attributes/racename.h>
#include <attributes/otherfaction.h> #include <attributes/otherfaction.h>
#include <attributes/racename.h>
#include <attributes/stealth.h>
/* util includes */ /* util includes */
#include <util/attrib.h> #include <util/attrib.h>

View File

@ -29,7 +29,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/curse.h> #include <kernel/curse.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/plane.h> #include <kernel/plane.h>

View File

@ -40,6 +40,7 @@ int RunAllTests(void)
/* kernel */ /* kernel */
ADD_TESTS(suite, unit); ADD_TESTS(suite, unit);
ADD_TESTS(suite, faction); ADD_TESTS(suite, faction);
ADD_TESTS(suite, group);
ADD_TESTS(suite, build); ADD_TESTS(suite, build);
ADD_TESTS(suite, pool); ADD_TESTS(suite, pool);
ADD_TESTS(suite, curse); ADD_TESTS(suite, curse);

Some files were not shown because too many files have changed in this diff Show More