From 67252e29247b84155e6e2ee434462a9c88113ac8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 15:03:47 +0100 Subject: [PATCH 1/3] add conversion program --- src/CMakeLists.txt | 10 ++++++++++ src/convert.c | 3 +++ 2 files changed, 13 insertions(+) create mode 100644 src/convert.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 43f109fed..7be3dd3b1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -187,6 +187,15 @@ target_link_libraries(eressea ${INIPARSER_LIBRARIES} ) +add_executable(convert convert.c) +target_link_libraries(convert + game + ${LUA_MATH_LIBRARY} + ${STORAGE_LIBRARIES} + ${CLIBS_LIBRARIES} + ${INIPARSER_LIBRARIES} +) + set(TESTS_SRC monsters.test.c names.test.c @@ -268,6 +277,7 @@ endif(CURSES_FOUND) if (LIBXML2_FOUND) include_directories (${LIBXML2_INCLUDE_DIR}) target_link_libraries(eressea ${LIBXML2_LIBRARIES}) +target_link_libraries(convert ${LIBXML2_LIBRARIES}) target_link_libraries(test_eressea ${LIBXML2_LIBRARIES}) add_definitions(-DUSE_LIBXML2) endif (LIBXML2_FOUND) diff --git a/src/convert.c b/src/convert.c new file mode 100644 index 000000000..4558ed3ab --- /dev/null +++ b/src/convert.c @@ -0,0 +1,3 @@ +int main(void) { + return -1; +} From f406c476574a86657b7f679ebba398366187d465 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 15:30:58 +0100 Subject: [PATCH 2/3] use converter frm noxml branch --- src/convert.c | 26 ++++++++++++++++++++++++-- src/kernel/CMakeLists.txt | 1 + src/kernel/rules.c | 12 ++++++++++++ src/kernel/rules.h | 5 +++++ 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 src/kernel/rules.c create mode 100644 src/kernel/rules.h diff --git a/src/convert.c b/src/convert.c index 4558ed3ab..3b982e64f 100644 --- a/src/convert.c +++ b/src/convert.c @@ -1,3 +1,25 @@ -int main(void) { - return -1; +#include + +#include +#include +#include + +#include + +#include + +#include + +int main(int argc, char **argv) { + const char * xmlfile, *catalog; + + register_races(); + register_xmlreader(); + + if (argc < 3) return -1; + xmlfile = argv[1]; + catalog = argv[2]; + read_xml(xmlfile, catalog); + write_rules("rules.dat"); + return 0; } diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index d3a2e8e56..b8423ae03 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -54,6 +54,7 @@ pool.c race.c region.c resources.c +rules.c save.c ship.c skills.c diff --git a/src/kernel/rules.c b/src/kernel/rules.c new file mode 100644 index 000000000..c7499fe0c --- /dev/null +++ b/src/kernel/rules.c @@ -0,0 +1,12 @@ +#include +#include "rules.h" + +int write_rules(const char *filename) { + return -1; +} + +int read_rules(const char *filename) +{ + return -1; +} + diff --git a/src/kernel/rules.h b/src/kernel/rules.h new file mode 100644 index 000000000..98f0bf240 --- /dev/null +++ b/src/kernel/rules.h @@ -0,0 +1,5 @@ +#pragma once + +int read_rules(const char *filename); +int write_rules(const char * filename); + From 71e5d101a82272d2c67d35201314cf52cf292002 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 26 Feb 2017 15:33:32 +0100 Subject: [PATCH 3/3] converter compiles fine, does nothing --- src/convert.c | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/convert.c b/src/convert.c index 3b982e64f..a67c5a287 100644 --- a/src/convert.c +++ b/src/convert.c @@ -1,25 +1,44 @@ #include + +#ifdef USE_LIBXML2 +#include +#include +#endif #include #include -#include - #include -#include - #include +#include + +static int usage(void) { + return -1; +} + int main(int argc, char **argv) { - const char * xmlfile, *catalog; + const char *mode; register_races(); +#ifdef USE_LIBXML2 register_xmlreader(); - - if (argc < 3) return -1; - xmlfile = argv[1]; - catalog = argv[2]; - read_xml(xmlfile, catalog); - write_rules("rules.dat"); - return 0; +#endif + if (argc < 2) return usage(); + mode = argv[1]; +#ifdef USE_LIBXML2 + if (strcmp(mode, "rules")==0) { + const char *xmlfile, *catalog; + if (argc < 4) return usage(); + xmlfile = argv[2]; + catalog = argv[3]; + read_xml(xmlfile, catalog); + write_rules("rules.dat"); + return 0; + } +#endif + if (strcmp(mode, "po")==0) { + return 0; + } + return usage(); }