From 578334f2d032cd9ba44070329971cc57bf2bd889 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 2 Jun 2012 10:44:37 -0700 Subject: [PATCH 1/9] fix a warning about %u not being the right format for size_t --- src/kernel/textstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/textstore.c b/src/kernel/textstore.c index 0bbbd48c7..643697bf9 100644 --- a/src/kernel/textstore.c +++ b/src/kernel/textstore.c @@ -98,7 +98,7 @@ static void txt_r_tok_buf(struct storage *store, char *result, size_t size) char format[16]; if (result && size > 0) { format[0] = '%'; - sprintf(format + 1, "%us", size); + sprintf(format + 1, "%lus", (unsigned long)size); fscanf((FILE *) store->userdata, format, result); if (result[0] == NULL_TOKEN) { result[0] = 0; From 533c267b9a191478d330ee500c9f4ae7e946f711 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 2 Jun 2012 12:49:48 -0700 Subject: [PATCH 2/9] Fixed a bug where a missing resource in E3 would crash the server --- scripts/spells.lua | 13 +++++++++---- src/bindings/bind_message.c | 9 +++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/scripts/spells.lua b/scripts/spells.lua index 8269e72e6..29991376c 100644 --- a/scripts/spells.lua +++ b/scripts/spells.lua @@ -1,9 +1,14 @@ function creation_message(mage, type, number) local msg = message.create("item_create_spell") - msg:set_unit("mage", mage) - msg:set_int("number", number) - msg:set_resource("item", type) - return msg + local err = 0 + err = err + msg:set_unit("mage", mage) + err = err + msg:set_int("number", number) + err = err + msg:set_resource("item", type) + if err ~= 0 then + return nil + else + return msg + end end local function create_item(mage, level, name, number) diff --git a/src/bindings/bind_message.c b/src/bindings/bind_message.c index ae27573d9..6ff30e98a 100644 --- a/src/bindings/bind_message.c +++ b/src/bindings/bind_message.c @@ -72,6 +72,7 @@ int msg_set_resource(lua_message * msg, const char *param, const char *resname) { if (msg->mtype) { int i = mtype_get_param(msg->mtype, param); + const resource_type * rtype; if (i == msg->mtype->nparameters) { return E_INVALID_PARAMETER_NAME; } @@ -79,8 +80,12 @@ int msg_set_resource(lua_message * msg, const char *param, const char *resname) return E_INVALID_PARAMETER_TYPE; } - msg->args[i].v = (void *)rt_find(resname); - + rtype = rt_find(resname); + if (rtype) { + msg->args[i].v = (void *)rtype; + } else { + return E_INVALID_PARAMETER_VALUE; + } return E_OK; } return E_INVALID_MESSAGE; From ee456c49b11741d0438758c95ee9c4912c97b5c8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Jun 2012 11:59:21 -0700 Subject: [PATCH 3/9] building new cmake files for the core (WIP) fixing a missign header in bsdstring.h (need size_t) --- src/CMakeLists.txt | 9 ++++++++ src/util/CMakeLists.txt | 48 +++++++++++++++++++++++++++++++++++++++++ src/util/bsdstring.h | 1 + 3 files changed, 58 insertions(+) create mode 100644 src/CMakeLists.txt create mode 100644 src/util/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 000000000..e74bd8a92 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 2.4) +project (eressea-core) + +enable_testing() + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../../cmake/Modules/") + +add_subdirectory (../../dependencies "${CMAKE_CURRENT_BINARY_DIR}/dependencies") +add_subdirectory (util) diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt new file mode 100644 index 000000000..8d2a38123 --- /dev/null +++ b/src/util/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required (VERSION 2.4) +project (util) + +find_package (Lua51 REQUIRED) +find_package (LibXml2 REQUIRED) +#find_package (CuTest REQUIRED HINTS ${DEPENDENCIES_DIR}) +#find_package (QuickList REQUIRED) +#find_package (CritBit REQUIRED) + +include_directories (${LUA_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR}) +include_directories (.. + ${CRITBIT_INCLUDE_DIR} + ${QUICKLIST_INCLUDE_DIR} + ${CUTEST_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/bsdstring.h b/src/util/bsdstring.h index b917baafa..91b89465d 100644 --- a/src/util/bsdstring.h +++ b/src/util/bsdstring.h @@ -1,6 +1,7 @@ #ifndef UTIL_BSDSTRING_H #define UTIL_BSDSTRING_H +#include extern int wrptr(char **ptr, size_t * size, int bytes); #ifndef HAVE_STRLCPY From 5cba331ad3c2e8eb429b8e5d4a9db745c1a743ea Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Jun 2012 12:51:35 -0700 Subject: [PATCH 4/9] cmake files for uil and kernel fixing a bunch of files that do not compile on their own --- src/CMakeLists.txt | 1 + src/kernel/CMakeLists.txt | 71 +++++++++++++++++++++++++++++++++++++++ src/kernel/equipment.c | 2 +- src/kernel/item.c | 1 + src/kernel/magic.h | 5 --- src/kernel/pool_test.c | 2 ++ src/kernel/types.h | 2 ++ src/kernel/unit.c | 4 ++- 8 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 src/kernel/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e74bd8a92..7ee7758de 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,3 +7,4 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../../cmake/Modu add_subdirectory (../../dependencies "${CMAKE_CURRENT_BINARY_DIR}/dependencies") add_subdirectory (util) +add_subdirectory (kernel) diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt new file mode 100644 index 000000000..d02f7dddc --- /dev/null +++ b/src/kernel/CMakeLists.txt @@ -0,0 +1,71 @@ +cmake_minimum_required (VERSION 2.4) +project (kernel) + +#find_package (Lua51 REQUIRED) +#find_package (LibXml2 REQUIRED) +#find_package (CuTest REQUIRED HINTS ${DEPENDENCIES_DIR}) +#find_package (QuickList REQUIRED) +#find_package (CritBit REQUIRED) + +include_directories (..) +#include_directories (${LUA_INCLUDE_DIR}) +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/equipment.c b/src/kernel/equipment.c index 956cc0626..42c505499 100644 --- a/src/kernel/equipment.c +++ b/src/kernel/equipment.c @@ -83,7 +83,7 @@ void equipment_setskill(equipment * eq, skill_t sk, const char *value) } } -void equipment_addspell(equipment * eq, spell * sp, int level) +void equipment_addspell(equipment * eq, struct spell * sp, int level) { if (eq) { if (!eq->spellbook) { diff --git a/src/kernel/item.c b/src/kernel/item.c index 35d8451a0..c588fbeca 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -24,6 +24,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "alchemy.h" #include "build.h" +#include "curse.h" #include "faction.h" #include "message.h" #include "pool.h" diff --git a/src/kernel/magic.h b/src/kernel/magic.h index f896be52d..07ec04772 100644 --- a/src/kernel/magic.h +++ b/src/kernel/magic.h @@ -22,11 +22,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. extern "C" { #endif -#include "curse.h" - struct fighter; - struct building; - struct spellbook; - /* ------------------------------------------------------------- */ #define MAXCOMBATSPELLS 3 /* PRECOMBAT COMBAT POSTCOMBAT */ diff --git a/src/kernel/pool_test.c b/src/kernel/pool_test.c index 5e521cff5..38be7aaae 100644 --- a/src/kernel/pool_test.c +++ b/src/kernel/pool_test.c @@ -1,9 +1,11 @@ #include +#include #include "pool.h" #include "unit.h" #include "item.h" #include "region.h" +#include "skill.h" #include #include diff --git a/src/kernel/types.h b/src/kernel/types.h index ef5ee6013..23cef5f51 100644 --- a/src/kernel/types.h +++ b/src/kernel/types.h @@ -38,6 +38,7 @@ struct attrib_type; struct building; struct building_type; struct curse; +struct curse_type; struct equipment; struct faction; struct fighter; @@ -48,6 +49,7 @@ struct luxury_type; struct order; struct plane; struct potion_type; +struct quicklist; struct race; struct region; struct region_list; diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 585696e3f..c24902076 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -18,12 +18,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +#include #include "unit.h" #include "building.h" #include "faction.h" #include "group.h" #include "connection.h" +#include "curse.h" #include "item.h" #include "move.h" #include "order.h" @@ -1757,4 +1759,4 @@ struct spellbook * unit_get_spellbook(const struct unit * u) } } return 0; -} \ No newline at end of file +} From a928c6b45c6d7c9e67b94695a17b2c4d71950922 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Jun 2012 13:39:42 -0700 Subject: [PATCH 5/9] cmake configuration for gamecode --- src/CMakeLists.txt | 1 + src/gamecode/CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ src/gamecode/creport.c | 1 + src/gamecode/economy.c | 2 ++ src/gamecode/economy_test.c | 3 ++- src/gamecode/give.c | 1 + src/gamecode/laws.c | 1 + src/gamecode/market_test.c | 3 ++- src/gamecode/report.c | 1 + src/gamecode/study.c | 1 + src/gamecode/xmlreport.c | 1 + src/kernel/CMakeLists.txt | 7 ------- src/util/CMakeLists.txt | 15 ++++++--------- 13 files changed, 50 insertions(+), 18 deletions(-) create mode 100644 src/gamecode/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7ee7758de..fe436cb47 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,3 +8,4 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../../cmake/Modu add_subdirectory (../../dependencies "${CMAKE_CURRENT_BINARY_DIR}/dependencies") add_subdirectory (util) add_subdirectory (kernel) +add_subdirectory (gamecode) diff --git a/src/gamecode/CMakeLists.txt b/src/gamecode/CMakeLists.txt new file mode 100644 index 000000000..dc74f267e --- /dev/null +++ b/src/gamecode/CMakeLists.txt @@ -0,0 +1,31 @@ +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/gamecode/creport.c b/src/gamecode/creport.c index 94abc0294..3f7d4fe1d 100644 --- a/src/gamecode/creport.c +++ b/src/gamecode/creport.c @@ -35,6 +35,7 @@ without prior permission by the authors of Eressea. #include #include #include +#include #include #include #include diff --git a/src/gamecode/economy.c b/src/gamecode/economy.c index cc516d784..cd47f880a 100644 --- a/src/gamecode/economy.c +++ b/src/gamecode/economy.c @@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +#include #include "economy.h" /* gamecode includes */ @@ -33,6 +34,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include #include #include #include diff --git a/src/gamecode/economy_test.c b/src/gamecode/economy_test.c index effe7e4e8..61294b1da 100644 --- a/src/gamecode/economy_test.c +++ b/src/gamecode/economy_test.c @@ -1,4 +1,5 @@ -#include "platform.h" +#include +#include #include "economy.h" #include diff --git a/src/gamecode/give.c b/src/gamecode/give.c index 755b97c26..b9254c7c2 100644 --- a/src/gamecode/give.c +++ b/src/gamecode/give.c @@ -17,6 +17,7 @@ #include "economy.h" /* kernel includes */ +#include #include #include #include diff --git a/src/gamecode/laws.c b/src/gamecode/laws.c index 2f1e0b252..6965a8f7d 100644 --- a/src/gamecode/laws.c +++ b/src/gamecode/laws.c @@ -39,6 +39,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include #include #include #include diff --git a/src/gamecode/market_test.c b/src/gamecode/market_test.c index 7da1963c0..71f9bcf24 100644 --- a/src/gamecode/market_test.c +++ b/src/gamecode/market_test.c @@ -1,4 +1,5 @@ -#include "platform.h" +#include +#include #include "market.h" #include "tests.h" diff --git a/src/gamecode/report.c b/src/gamecode/report.c index 03772de43..2127d2940 100644 --- a/src/gamecode/report.c +++ b/src/gamecode/report.c @@ -42,6 +42,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include #include #include #include diff --git a/src/gamecode/study.c b/src/gamecode/study.c index a25c56a52..2919e8b1f 100644 --- a/src/gamecode/study.c +++ b/src/gamecode/study.c @@ -25,6 +25,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +#include #include #include #include diff --git a/src/gamecode/xmlreport.c b/src/gamecode/xmlreport.c index 72025e98a..5b93dc887 100644 --- a/src/gamecode/xmlreport.c +++ b/src/gamecode/xmlreport.c @@ -32,6 +32,7 @@ without prior permission by the authors of Eressea. #include #include #include +#include #include #include #include diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index d02f7dddc..fc0a9369c 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -1,14 +1,7 @@ cmake_minimum_required (VERSION 2.4) project (kernel) -#find_package (Lua51 REQUIRED) -#find_package (LibXml2 REQUIRED) -#find_package (CuTest REQUIRED HINTS ${DEPENDENCIES_DIR}) -#find_package (QuickList REQUIRED) -#find_package (CritBit REQUIRED) - include_directories (..) -#include_directories (${LUA_INCLUDE_DIR}) include_directories (${LIBXML2_INCLUDE_DIR}) include_directories (${CRITBIT_INCLUDE_DIR}) include_directories (${QUICKLIST_INCLUDE_DIR}) diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 8d2a38123..dcdc1a3b1 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -3,16 +3,13 @@ project (util) find_package (Lua51 REQUIRED) find_package (LibXml2 REQUIRED) -#find_package (CuTest REQUIRED HINTS ${DEPENDENCIES_DIR}) -#find_package (QuickList REQUIRED) -#find_package (CritBit REQUIRED) -include_directories (${LUA_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR}) -include_directories (.. - ${CRITBIT_INCLUDE_DIR} - ${QUICKLIST_INCLUDE_DIR} - ${CUTEST_INCLUDE_DIR} - ) +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 From aeec7b94689778446ca5c92f83cc3a10ea46d303 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Jun 2012 18:41:07 -0700 Subject: [PATCH 6/9] complete rewrite of cmake files --- CMakeLists.txt | 4 + src/CMakeLists.txt | 192 +++++++++++++++++++++++++++++++++-- src/bindings/bind_attrib.h | 2 + src/bindings/bind_gmtool.c | 1 + src/bindings/bindings.c | 1 + src/gamecode/CMakeLists.txt | 31 ------ src/items/studypotion.c | 59 ----------- src/items/studypotion.h | 30 ------ src/kernel/CMakeLists.txt | 64 ------------ src/kernel/names.c | 3 +- src/kernel/race.c | 5 +- src/modules/autoseed.c | 2 - src/tests.c | 1 + src/tests_test.c | 6 +- src/util/CMakeLists.txt | 45 --------- src/util/graph.c | 193 ------------------------------------ src/util/graph.h | 38 ------- src/util/log.c | 6 +- 18 files changed, 207 insertions(+), 476 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 src/gamecode/CMakeLists.txt delete mode 100644 src/items/studypotion.c delete mode 100644 src/items/studypotion.h delete mode 100644 src/kernel/CMakeLists.txt delete mode 100644 src/util/CMakeLists.txt delete mode 100644 src/util/graph.c delete mode 100644 src/util/graph.h 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(); } } - From 5b06f5d2c8650ded28127a5e857bf43876d8414a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Jun 2012 18:56:30 -0700 Subject: [PATCH 7/9] complete rewrite of cmake files --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ba3c05278..08dd1d6e5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.4) -project (eressea) +project (eressea C) set (CORE_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "Eressea Core headers") From 9f04f80f45189c05120872adfd5d4049e2774f86 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Jun 2012 20:07:51 -0700 Subject: [PATCH 8/9] stop comlaints about missing C++ compiler fix directory --- CMakeLists.txt | 3 ++- src/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d526ed9a6..a2548de17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required(VERSION 2.4) +project (core C) add_subdirectory (../dependencies "${CMAKE_CURRENT_BINARY_DIR}/dependencies") -add_subdirectory (src) +add_subdirectory (src eressea) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 08dd1d6e5..918ad54e3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.4) project (eressea C) -set (CORE_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "Eressea Core headers") +set (CORE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "Eressea Core headers") find_package (Lua51 REQUIRED) find_package (LibXml2 REQUIRED) From 0eae68f34ed6a5c600835563afca9ff376cf678e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 4 Jun 2012 03:41:34 +0000 Subject: [PATCH 9/9] fix compilation on ARM (differnt char type) --- src/kernel/reports_test.c | 6 +++--- src/util/bsdstring_test.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/kernel/reports_test.c b/src/kernel/reports_test.c index c3ee0c3c1..0bfa47e34 100644 --- a/src/kernel/reports_test.c +++ b/src/kernel/reports_test.c @@ -62,16 +62,16 @@ static void test_regionid(CuTest * tc) { plain = test_create_terrain("plain", 0); r = test_create_region(0, 0, plain); - memset(buffer, 0xff, sizeof(buffer)); + memset(buffer, -2, sizeof(buffer)); len = f_regionid(r, 0, buffer, sizeof(buffer)); CuAssertIntEquals(tc, 11, len); CuAssertStrEquals(tc, "plain (0,0)", buffer); - memset(buffer, -1, sizeof(buffer)); + memset(buffer, -2, sizeof(buffer)); len = f_regionid(r, 0, buffer, 11); CuAssertIntEquals(tc, 10, len); CuAssertStrEquals(tc, "plain (0,0", buffer); - CuAssertIntEquals(tc, -1, buffer[11]); + CuAssertIntEquals(tc, (char)-2, buffer[11]); } CuSuite *get_reports_suite(void) diff --git a/src/util/bsdstring_test.c b/src/util/bsdstring_test.c index 25e7be60d..0f9cdaeac 100644 --- a/src/util/bsdstring_test.c +++ b/src/util/bsdstring_test.c @@ -15,11 +15,11 @@ static void test_strlcat(CuTest * tc) buffer[0] = '\0'; CuAssertIntEquals(tc, 4, strlcat(buffer, "herp", 8)); CuAssertStrEquals(tc, "herp", buffer); - CuAssertIntEquals(tc, -2, buffer[5]); + CuAssertIntEquals(tc, (char)-2, buffer[5]); CuAssertIntEquals(tc, 8, strlcat(buffer, "derp", 8)); CuAssertStrEquals(tc, "herpder", buffer); - CuAssertIntEquals(tc, -2, buffer[8]); + CuAssertIntEquals(tc, (char)-2, buffer[8]); } static void test_strlcpy(CuTest * tc) @@ -33,11 +33,11 @@ static void test_strlcpy(CuTest * tc) CuAssertIntEquals(tc, 4, strlcpy(buffer, "herp", 8)); CuAssertStrEquals(tc, "herp", buffer); - CuAssertIntEquals(tc, -2, buffer[5]); + CuAssertIntEquals(tc, (char)-2, buffer[5]); CuAssertIntEquals(tc, 8, strlcpy(buffer, "herpderp", 8)); CuAssertStrEquals(tc, "herpder", buffer); - CuAssertIntEquals(tc, -2, buffer[8]); + CuAssertIntEquals(tc, (char)-2, buffer[8]); } static void test_slprintf(CuTest * tc) @@ -51,11 +51,11 @@ static void test_slprintf(CuTest * tc) CuAssertIntEquals(tc, 4, slprintf(buffer, 8, "%s", "herp")); CuAssertStrEquals(tc, "herp", buffer); - CuAssertIntEquals(tc, -2, buffer[5]); + CuAssertIntEquals(tc, (char)-2, buffer[5]); CuAssertIntEquals(tc, 8, slprintf(buffer, 8, "%s", "herpderp")); CuAssertStrEquals(tc, "herpder", buffer); - CuAssertIntEquals(tc, -2, buffer[8]); + CuAssertIntEquals(tc, (char)-2, buffer[8]); } CuSuite *get_bsdstring_suite(void)