complete rewrite of cmake files

This commit is contained in:
Enno Rehling 2012-06-03 18:41:07 -07:00
parent a928c6b45c
commit aeec7b9468
18 changed files with 207 additions and 476 deletions

4
CMakeLists.txt Normal file
View File

@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 2.4)
add_subdirectory (../dependencies "${CMAKE_CURRENT_BINARY_DIR}/dependencies")
add_subdirectory (src)

View File

@ -1,11 +1,189 @@
cmake_minimum_required(VERSION 2.4) cmake_minimum_required(VERSION 2.4)
project (eressea-core) project (eressea)
enable_testing() set (CORE_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "Eressea Core headers")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../../cmake/Modules/") find_package (Lua51 REQUIRED)
find_package (LibXml2 REQUIRED)
add_subdirectory (../../dependencies "${CMAKE_CURRENT_BINARY_DIR}/dependencies") include_directories (${CORE_INCLUDE_DIR})
add_subdirectory (util) include_directories (${CRITBIT_INCLUDE_DIR})
add_subdirectory (kernel) include_directories (${CRYPTO_INCLUDE_DIR})
add_subdirectory (gamecode) include_directories (${QUICKLIST_INCLUDE_DIR})
include_directories (${CUTEST_INCLUDE_DIR})
include_directories (${LUA_INCLUDE_DIR})
include_directories (${LIBXML2_INCLUDE_DIR})
include_directories (${BSON_INCLUDE_DIR})
include_directories (${INIPARSER_INCLUDE_DIR})
add_library(${PROJECT_NAME}
attributes/alliance.c
attributes/attributes.c
attributes/fleechance.c
attributes/follow.c
attributes/giveitem.c
attributes/gm.c
attributes/hate.c
attributes/iceberg.c
attributes/key.c
attributes/matmod.c
attributes/moved.c
attributes/movement.c
attributes/object.c
attributes/orcification.c
attributes/otherfaction.c
attributes/overrideroads.c
attributes/racename.c
attributes/raceprefix.c
attributes/reduceproduction.c
attributes/targetregion.c
bindings/bind_attrib.c
bindings/bind_building.c
bindings/bind_faction.c
bindings/bind_gmtool.c
bindings/bind_hashtable.c
bindings/bindings.c
bindings/bind_message.c
bindings/bind_region.c
bindings/bind_ship.c
bindings/bind_sqlite.c
bindings/bind_storage.c
bindings/bind_unit.c
bindings/helpers.c
eressea.c
gamecode/archetype.c
gamecode/creation.c
gamecode/creport.c
gamecode/economy.c
gamecode/economy_test.c
gamecode/give.c
gamecode/items.c
gamecode/laws.c
gamecode/laws_test.c
gamecode/market.c
gamecode/market_test.c
gamecode/monster.c
gamecode/randenc.c
gamecode/report.c
gamecode/spy.c
gamecode/study.c
gamecode/summary.c
gamecode/xmlreport.c
gmtool.c
items/artrewards.c
items/demonseye.c
items/itemtypes.c
items/phoenixcompass.c
items/seed.c
items/speedsail.c
items/weapons.c
items/xerewards.c
kernel/alchemy.c
kernel/alliance.c
kernel/battle.c
kernel/battle_test.c
kernel/binarystore.c
kernel/build.c
kernel/building.c
kernel/building_test.c
kernel/calendar.c
kernel/command.c
kernel/config.c
kernel/connection.c
kernel/curse.c
kernel/curse_test.c
kernel/equipment.c
kernel/equipment_test.c
kernel/faction.c
kernel/group.c
kernel/item.c
kernel/item_test.c
kernel/magic.c
kernel/magic_test.c
kernel/message.c
kernel/move.c
kernel/move_test.c
kernel/names.c
kernel/order.c
kernel/pathfinder.c
kernel/plane.c
kernel/player.c
kernel/pool.c
kernel/pool_test.c
kernel/race.c
kernel/region.c
kernel/reports.c
kernel/reports_test.c
kernel/resources.c
kernel/save.c
kernel/ship.c
kernel/ship_test.c
kernel/skill.c
kernel/spellbook.c
kernel/spellbook_test.c
kernel/spell.c
kernel/spell_test.c
kernel/sqlite.c
kernel/teleport.c
kernel/terrain.c
kernel/textstore.c
kernel/unit.c
kernel/xmlreader.c
modules/arena.c
modules/autoseed.c
modules/dungeon.c
modules/gmcmd.c
modules/museum.c
modules/score.c
modules/weather.c
modules/wormhole.c
modules/xecmd.c
modules/xmas.c
tests.c
tests_test.c
triggers/changefaction.c
triggers/changerace.c
triggers/clonedied.c
triggers/createcurse.c
triggers/createunit.c
triggers/gate.c
triggers/giveitem.c
triggers/killunit.c
triggers/removecurse.c
triggers/shock.c
triggers/timeout.c
triggers/triggers.c
triggers/unguard.c
triggers/unitmessage.c
util/attrib.c
util/base36.c
util/base36_test.c
util/bsdstring.c
util/bsdstring_test.c
util/console.c
util/crmessage.c
util/dice.c
util/eventbus.c
util/event.c
util/filereader.c
util/functions.c
util/functions_test.c
util/goodies.c
util/language.c
util/listbox.c
util/lists.c
util/log.c
util/message.c
util/nrmessage.c
util/os.c
util/parser.c
util/rand.c
util/resolve.c
util/sql.c
util/strings.c
util/translation.c
util/umlaut.c
util/umlaut_test.c
util/unicode.c
util/xml.c
)

View File

@ -10,6 +10,8 @@ This program may not be used, modified or distributed
without prior permission by the authors of Eressea. without prior permission by the authors of Eressea.
*/ */
#include <lua.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

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

View File

@ -21,6 +21,7 @@ without prior permission by the authors of Eressea.
#include <kernel/alliance.h> #include <kernel/alliance.h>
#include <kernel/building.h> #include <kernel/building.h>
#include <kernel/curse.h>
#include <kernel/skill.h> #include <kernel/skill.h>
#include <kernel/equipment.h> #include <kernel/equipment.h>
#include <kernel/calendar.h> #include <kernel/calendar.h>

View File

@ -1,31 +0,0 @@
cmake_minimum_required (VERSION 2.4)
project (gamecode)
include_directories (..)
include_directories (${LIBXML2_INCLUDE_DIR})
#include_directories (${CRITBIT_INCLUDE_DIR})
include_directories (${QUICKLIST_INCLUDE_DIR})
include_directories (${CUTEST_INCLUDE_DIR})
#include_directories (${INIPARSER_INCLUDE_DIR})
#include_directories (${CRYPTO_INCLUDE_DIR})
add_library (gamecode
# archetype.c
creation.c
creport.c
economy.c
economy_test.c
give.c
items.c
laws.c
laws_test.c
market.c
market_test.c
monster.c
randenc.c
report.c
spy.c
study.c
summary.c
xmlreport.c
)

View File

@ -1,59 +0,0 @@
#include <config.h>
#include <kernel/eressea.h>
#include "studypotion.h"
#include <kernel/faction.h>
#include <kernel/item.h>
#include <kernel/order.h>
#include <kernel/skill.h>
#include <kernel/study.h>
#include <kernel/unit.h>
#include <util/attrib.h>
#include <util/functions.h>
/* BEGIN it_studypotion */
#define MAXGAIN 15
static int
use_studypotion(struct unit *u, const struct item_type *itype, int amount,
struct order *ord)
{
if (get_keyword(u->thisorder) == K_STUDY) {
skill_t sk;
skill *sv;
init_tokens(u->thisorder);
skip_token();
sk = findskill(getstrtoken(), u->faction->locale);
sv = get_skill(u, sk);
if (sv && sv->level > 2) {
/* TODO: message */
} else if (study_cost(u, sk) > 0) {
/* TODO: message */
} else {
attrib *a = a_find(u->attribs, &at_learning);
teaching_info *teach;
if (a == NULL) {
a = a_add(&u->attribs, a_new(&at_learning));
}
teach = (teaching_info *) a->data.v;
if (amount > MAXGAIN)
amount = MAXGAIN;
teach->value += amount * 30;
if (teach->value > MAXGAIN * 30) {
teach->value = MAXGAIN * 30;
}
i_change(&u->items, itype, -amount);
return 0;
}
}
return EUNUSABLE;
}
void register_studypotion(void)
{
register_function((pf_generic) use_studypotion, "use_studypotion");
}
/* END it_studypotion */

View File

@ -1,30 +0,0 @@
/*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/
#ifndef H_ITM_STUDYPOTION
#define H_ITM_STUDYPOTION
#ifdef __cplusplus
extern "C" {
#endif
extern void register_studypotion(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,64 +0,0 @@
cmake_minimum_required (VERSION 2.4)
project (kernel)
include_directories (..)
include_directories (${LIBXML2_INCLUDE_DIR})
include_directories (${CRITBIT_INCLUDE_DIR})
include_directories (${QUICKLIST_INCLUDE_DIR})
include_directories (${CUTEST_INCLUDE_DIR})
include_directories (${INIPARSER_INCLUDE_DIR})
include_directories (${CRYPTO_INCLUDE_DIR})
add_library (kernel
alchemy.c
alliance.c
battle.c
battle_test.c
binarystore.c
build.c
building.c
building_test.c
calendar.c
command.c
config.c
connection.c
curse.c
curse_test.c
equipment.c
equipment_test.c
faction.c
group.c
item.c
item_test.c
magic.c
magic_test.c
message.c
move.c
move_test.c
names.c
order.c
pathfinder.c
plane.c
player.c
pool.c
pool_test.c
race.c
region.c
reports.c
reports_test.c
resources.c
save.c
ship.c
ship_test.c
skill.c
spellbook.c
spellbook_test.c
spell.c
spell_test.c
sqlite.c
teleport.c
terrain.c
textstore.c
unit.c
xmlreader.c
)

View File

@ -38,6 +38,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/unicode.h> #include <util/unicode.h>
/* libc includes */ /* libc includes */
#include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <wctype.h> #include <wctype.h>
#include <stdlib.h> #include <stdlib.h>
@ -466,7 +467,7 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars)
void register_names(void) void register_names(void)
{ {
register_function((pf_generic) describe_braineater, "describe_braineater"); register_function((pf_generic) describe_braineater, "describe_braineater");
/* function name /* function name
* generate a name for a nonplayerunit * generate a name for a nonplayerunit
* race->generate_name() */ * race->generate_name() */
register_function((pf_generic) undead_name, "nameundead"); register_function((pf_generic) undead_name, "nameundead");

View File

@ -50,11 +50,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <attributes/raceprefix.h> #include <attributes/raceprefix.h>
/* libc includes */ /* libc includes */
#include <assert.h>
#include <ctype.h>
#include <math.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h>
#include <ctype.h>
/** external variables **/ /** external variables **/
race *races; race *races;

View File

@ -40,8 +40,6 @@
#include <util/sql.h> #include <util/sql.h>
#include <util/unicode.h> #include <util/unicode.h>
#include <libxml/encoding.h>
/* libc includes */ /* libc includes */
#include <limits.h> #include <limits.h>
#include <memory.h> #include <memory.h>

View File

@ -2,6 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <platform.h> #include <platform.h>
#include <kernel/types.h>
#include "tests.h" #include "tests.h"
#include "tests_test.c" #include "tests_test.c"

View File

@ -1,7 +1,11 @@
#include <util/language.h> #include <platform.h>
#include <kernel/types.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/region.h> #include <kernel/region.h>
#include <util/language.h>
#include <CuTest.h> #include <CuTest.h>
static void test_recreate_world(CuTest * tc) static void test_recreate_world(CuTest * tc)

View File

@ -1,45 +0,0 @@
cmake_minimum_required (VERSION 2.4)
project (util)
find_package (Lua51 REQUIRED)
find_package (LibXml2 REQUIRED)
include_directories (..)
include_directories (${CRITBIT_INCLUDE_DIR})
include_directories (${QUICKLIST_INCLUDE_DIR})
include_directories (${CUTEST_INCLUDE_DIR})
include_directories (${LUA_INCLUDE_DIR})
include_directories (${LIBXML2_INCLUDE_DIR})
add_library (util attrib.c
base36.c
base36_test.c
bsdstring.c
bsdstring_test.c
console.c
crmessage.c
dice.c
eventbus.c
event.c
filereader.c
functions.c
functions_test.c
goodies.c
language.c
listbox.c
lists.c
log.c
message.c
nrmessage.c
os.c
parser.c
rand.c
resolve.c
sql.c
strings.c
translation.c
umlaut.c
umlaut_test.c
unicode.c
xml.c
)

View File

@ -1,193 +0,0 @@
/* vi: set ts=2:
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
| | Enno Rehling <enno@eressea.de>
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
+-------------------+ Stefan Reich <reich@halbling.de>
This program may not be used, modified or distributed
without prior permission by the authors of Eressea.
*/
/* This is a very simple graph library. It is not optimized in any
way, and relies heavily on the vset and stack routines. */
#include <stdlib.h>
#include "vset.h"
#include "graph.h"
void graph_init(graph * g)
{
vset_init(&g->nodes);
vset_init(&g->edges);
}
void graph_free(graph * g)
{
vset_destroy(&g->nodes);
vset_destroy(&g->edges);
}
void graph_add_node(graph * g, node * n)
{
vset_add(&g->nodes, n);
}
void graph_add_edge(graph * g, edge * v)
{
vset_add(&g->nodes, v);
}
void graph_remove_node(graph * g, node * n)
{
unsigned int i;
for (i = 0; i != g->edges.size; ++i) {
edge *v = g->edges.data[i];
if (v->node1 == n || v->node2 == n) {
vset_erase(&g->nodes, v);
i--;
}
}
vset_erase(&g->nodes, n);
}
node *graph_find_node(graph * g, void *object)
{
unsigned int i;
for (i = 0; i != g->nodes.size; ++i) {
node *node = g->nodes.data[i];
if (node->object == object) {
return g->nodes.data[i];
}
}
return NULL;
}
/* The vset returned has to freed externally, else this will be a
memory leak. */
vset *graph_neighbours(graph * g, node * n)
{
unsigned int i;
vset *vs = malloc(sizeof(vs));
vset_init(vs);
for (i = 0; i != g->edges.size; ++i) {
edge *v = g->edges.data[i];
if (v->node1 == n && vset_count(vs, v->node2) == 0) {
vset_add(vs, v->node2);
} else if (v->node2 == n && vset_count(vs, v->node1) == 0) {
vset_add(vs, v->node1);
}
}
return vs;
}
void graph_resetmarkers(graph * g)
{
unsigned int i;
for (i = 0; i != g->nodes.size; ++i) {
node *node = g->nodes.data[i];
node->marker = 0;
}
for (i = 0; i != g->edges.size; ++i) {
edge *edge = g->edges.data[i];
edge->marker = 0;
}
}
/* The vset returned has to freed externally, else this will be a
memory leak. */
vset *graph_connected_nodes(graph * g, node * n)
{
vset *vs = malloc(sizeof(vset));
vset s;
vset_init(vs);
vset_init(&s);
graph_resetmarkers(g);
vset_add(vs, n);
n->marker = 1;
vset_add(&s, n);
while (s.size > 0) {
node *n = vset_pop(&s);
vset *vs_nb = graph_neighbours(g, n);
unsigned int i;
for (i = 0; i != vs_nb->size; ++i) {
node *nb = vs_nb->data[i];
if (nb->marker == 0) {
nb->marker = 1;
vset_add(vs, nb);
vset_add(&s, nb);
}
}
vset_destroy(vs_nb);
free(vs_nb);
}
vset_destroy(&s);
return vs;
}
/* The vset returned has to freed externally, else this will be a
memory leak. */
vset *graph_disjunct_graphs(graph * g)
{
vset *dg = malloc(sizeof(vset));
vset nodes;
vset_init(dg);
vset_init(&nodes);
vset_concat(&nodes, &g->nodes);
while (nodes.size > 0) {
graph *gt = malloc(sizeof(graph));
vset s;
unsigned int i;
node *start;
graph_init(gt);
start = vset_pop(&nodes);
graph_resetmarkers(g);
graph_add_node(gt, start);
start->marker = 1;
vset_init(&s);
vset_add(&s, start);
while (s.size > 0) {
vset *nbs = graph_neighbours(g, vset_pop(&s));
for (i = 0; i != nbs->size; ++i) {
node *nb = nbs->data[i];
if (nb->marker == 0) {
nb->marker = 1;
graph_add_node(gt, nb);
vset_erase(&nodes, nb);
vset_add(&s, nb);
}
}
vset_destroy(nbs);
free(nbs);
}
vset_destroy(&s);
for (i = 0; i != g->edges.size; ++i) {
edge *v = g->edges.data[i];
if (vset_count(&g->nodes, v->node1)) {
graph_add_edge(gt, v);
}
}
vset_add(dg, gt);
}
vset_destroy(&nodes);
return dg;
}

View File

@ -1,38 +0,0 @@
/* vi: set ts=2:
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
| | Enno Rehling <enno@eressea.de>
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
+-------------------+ Stefan Reich <reich@halbling.de>
This program may not be used, modified or distributed
without prior permission by the authors of Eressea.
*/
#ifndef GRAPH_H
#define GRAPH_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct node {
int marker;
void *object;
} node;
typedef struct edge {
int marker;
node *node1;
node *node2;
} edge;
typedef struct graph {
vset nodes;
vset edges;
} graph;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -6,13 +6,14 @@
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de> | | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
+-------------------+ Stefan Reich <reich@halbling.de> +-------------------+ Stefan Reich <reich@halbling.de>
This program may not be used, modified or distributed This program may not be used, modified or distributed
without prior permission by the authors of Eressea. without prior permission by the authors of Eressea.
*/ */
#include <platform.h> #include <platform.h>
#include "log.h" #include "log.h"
#include "unicode.h" #include "unicode.h"
#include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -154,7 +155,7 @@ static void _log_write(FILE * stream, int codepage, const char * prefix, const c
if (codepage) { if (codepage) {
char buffer[MAXLENGTH]; char buffer[MAXLENGTH];
char converted[MAXLENGTH]; char converted[MAXLENGTH];
vsnprintf(buffer, sizeof(buffer), format, args); vsnprintf(buffer, sizeof(buffer), format, args);
if (cp_convert(buffer, converted, MAXLENGTH, codepage) == 0) { if (cp_convert(buffer, converted, MAXLENGTH, codepage) == 0) {
fputs(converted, stream); fputs(converted, stream);
@ -308,4 +309,3 @@ void log_printf(FILE * io, const char *format, ...)
log_flush(); log_flush();
} }
} }