diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..d526ed9a6 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 2.4) + +add_subdirectory (../dependencies "${CMAKE_CURRENT_BINARY_DIR}/dependencies") +add_subdirectory (src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fe436cb47..ba3c05278 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,11 +1,189 @@ 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") -add_subdirectory (util) -add_subdirectory (kernel) -add_subdirectory (gamecode) +include_directories (${CORE_INCLUDE_DIR}) +include_directories (${CRITBIT_INCLUDE_DIR}) +include_directories (${CRYPTO_INCLUDE_DIR}) +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 +) diff --git a/src/bindings/bind_attrib.h b/src/bindings/bind_attrib.h index 5ab8daad5..6195e109d 100644 --- a/src/bindings/bind_attrib.h +++ b/src/bindings/bind_attrib.h @@ -10,6 +10,8 @@ This program may not be used, modified or distributed without prior permission by the authors of Eressea. */ +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/bindings/bind_gmtool.c b/src/bindings/bind_gmtool.c index a38e8d32c..a55cb75b7 100644 --- a/src/bindings/bind_gmtool.c +++ b/src/bindings/bind_gmtool.c @@ -1,4 +1,5 @@ #include +#include #include #include "bind_gmtool.h" diff --git a/src/bindings/bindings.c b/src/bindings/bindings.c index e12c1756b..444997c19 100644 --- a/src/bindings/bindings.c +++ b/src/bindings/bindings.c @@ -21,6 +21,7 @@ without prior permission by the authors of Eressea. #include #include +#include #include #include #include diff --git a/src/gamecode/CMakeLists.txt b/src/gamecode/CMakeLists.txt deleted file mode 100644 index dc74f267e..000000000 --- a/src/gamecode/CMakeLists.txt +++ /dev/null @@ -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 -) diff --git a/src/items/studypotion.c b/src/items/studypotion.c deleted file mode 100644 index df77793e1..000000000 --- a/src/items/studypotion.c +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include -#include "studypotion.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -/* 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 */ diff --git a/src/items/studypotion.h b/src/items/studypotion.h deleted file mode 100644 index 454f137c2..000000000 --- a/src/items/studypotion.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (c) 1998-2010, Enno Rehling - Katja Zedel - -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 diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt deleted file mode 100644 index fc0a9369c..000000000 --- a/src/kernel/CMakeLists.txt +++ /dev/null @@ -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 -) diff --git a/src/kernel/names.c b/src/kernel/names.c index f50289654..d44c49132 100644 --- a/src/kernel/names.c +++ b/src/kernel/names.c @@ -38,6 +38,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include /* libc includes */ +#include #include #include #include @@ -466,7 +467,7 @@ const char *abkz(const char *s, char *buf, size_t buflen, size_t maxchars) void register_names(void) { register_function((pf_generic) describe_braineater, "describe_braineater"); - /* function name + /* function name * generate a name for a nonplayerunit * race->generate_name() */ register_function((pf_generic) undead_name, "nameundead"); diff --git a/src/kernel/race.c b/src/kernel/race.c index c89c5fb32..48c8b3a4a 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -50,11 +50,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include /* libc includes */ +#include +#include +#include #include #include #include -#include -#include /** external variables **/ race *races; diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c index 18ae8e51a..9a0b5d233 100644 --- a/src/modules/autoseed.c +++ b/src/modules/autoseed.c @@ -40,8 +40,6 @@ #include #include -#include - /* libc includes */ #include #include diff --git a/src/tests.c b/src/tests.c index 2ea35d16e..67df8c8ba 100644 --- a/src/tests.c +++ b/src/tests.c @@ -2,6 +2,7 @@ #include #include +#include #include "tests.h" #include "tests_test.c" diff --git a/src/tests_test.c b/src/tests_test.c index da4db4103..c685d8a50 100644 --- a/src/tests_test.c +++ b/src/tests_test.c @@ -1,7 +1,11 @@ -#include +#include + +#include #include #include +#include + #include static void test_recreate_world(CuTest * tc) diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt deleted file mode 100644 index dcdc1a3b1..000000000 --- a/src/util/CMakeLists.txt +++ /dev/null @@ -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 -) diff --git a/src/util/graph.c b/src/util/graph.c deleted file mode 100644 index ec234aebf..000000000 --- a/src/util/graph.c +++ /dev/null @@ -1,193 +0,0 @@ -/* vi: set ts=2: - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - 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 -#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; -} diff --git a/src/util/graph.h b/src/util/graph.h deleted file mode 100644 index 19303acc8..000000000 --- a/src/util/graph.h +++ /dev/null @@ -1,38 +0,0 @@ -/* vi: set ts=2: - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - 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 diff --git a/src/util/log.c b/src/util/log.c index 48155cde3..40222bdd8 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -6,13 +6,14 @@ | | Ingo Wilken +-------------------+ Stefan Reich -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. */ #include #include "log.h" #include "unicode.h" +#include #include #include #include @@ -154,7 +155,7 @@ static void _log_write(FILE * stream, int codepage, const char * prefix, const c if (codepage) { char buffer[MAXLENGTH]; char converted[MAXLENGTH]; - + vsnprintf(buffer, sizeof(buffer), format, args); if (cp_convert(buffer, converted, MAXLENGTH, codepage) == 0) { fputs(converted, stream); @@ -308,4 +309,3 @@ void log_printf(FILE * io, const char *format, ...) log_flush(); } } -