begin writing a map exporter

This commit is contained in:
Enno Rehling 2014-03-06 07:15:43 -08:00
parent afe355e9b9
commit 18203cfdbf
7 changed files with 50 additions and 12 deletions

13
.gitattributes vendored Normal file
View File

@ -0,0 +1,13 @@
*.json text
*.xml text
*.py text
*.md text
*.txt text
*.lua text
# Shell scripts should *always* be LF, regardless of platfrom
s/* text eol=lf
*.sh text eol=lf
# All third-party code should not be EOL-normalized
#third-party/** -text

20
.gitmodules vendored
View File

@ -1,31 +1,31 @@
[submodule "lunit"] [submodule "lunit"]
path = lunit path = lunit
url = git://github.com/badgerman/lunit.git url = git@github.com:badgerman/lunit.git
[submodule "crypto"] [submodule "crypto"]
path = crypto path = crypto
url = git://github.com/badgerman/crypto.git url = git@github.com:badgerman/crypto.git
[submodule "cmake"] [submodule "cmake"]
path = cmake path = cmake
url = git://github.com/badgerman/cmake.git url = git@github.com:badgerman/cmake.git
[submodule "quicklist"] [submodule "quicklist"]
path = quicklist path = quicklist
url = git://github.com/badgerman/quicklist.git url = git@github.com:badgerman/quicklist.git
[submodule "critbit"] [submodule "critbit"]
path = critbit path = critbit
url = git://github.com/badgerman/critbit.git url = git@github.com:badgerman/critbit.git
[submodule "dlmalloc"] [submodule "dlmalloc"]
path = dlmalloc path = dlmalloc
url = git://github.com/badgerman/dlmalloc.git url = git@github.com:badgerman/dlmalloc.git
[submodule "cutest"] [submodule "cutest"]
path = cutest path = cutest
url = git://github.com/badgerman/cutest.git url = git@github.com:badgerman/cutest.git
[submodule "iniparser"] [submodule "iniparser"]
path = iniparser path = iniparser
url = git://github.com/badgerman/iniparser.git url = git@github.com:badgerman/iniparser.git
[submodule "cJSON"] [submodule "cJSON"]
path = cJSON path = cJSON
url = git://github.com/kbranigan/cJSON.git url = git@github.com:badgerman/cJSON.git
[submodule "storage"] [submodule "storage"]
path = storage path = storage
url = git://github.com/badgerman/storage.git url = git@github.com:badgerman/storage.git
branch = master branch = master

View File

@ -37,6 +37,7 @@ find_package (ToLua REQUIRED)
add_subdirectory (cutest) add_subdirectory (cutest)
add_subdirectory (crypto) add_subdirectory (crypto)
add_subdirectory (cJSON)
add_subdirectory (storage) add_subdirectory (storage)
add_subdirectory (iniparser) add_subdirectory (iniparser)
add_subdirectory (quicklist) add_subdirectory (quicklist)

2
cJSON

@ -1 +1 @@
Subproject commit 43241a78df3abc76ad7fc3d80f81e0b1db83a890 Subproject commit 43c04ad61258ec3d54a2167eb3a43915bd003ab1

2
cmake

@ -1 +1 @@
Subproject commit 923b5e3651c8849fb0769e158447d24646a11cca Subproject commit cd779ba36efb4045a040af170588a8dfe496d7b9

View File

@ -15,6 +15,7 @@ find_package (SQLite3 REQUIRED)
include_directories (${CMAKE_CURRENT_SOURCE_DIR}) include_directories (${CMAKE_CURRENT_SOURCE_DIR})
include_directories (${CRITBIT_INCLUDE_DIR}) include_directories (${CRITBIT_INCLUDE_DIR})
include_directories (${CJSON_INCLUDE_DIR})
include_directories (${STORAGE_INCLUDE_DIR}) include_directories (${STORAGE_INCLUDE_DIR})
include_directories (${CRYPTO_INCLUDE_DIR}) include_directories (${CRYPTO_INCLUDE_DIR})
include_directories (${QUICKLIST_INCLUDE_DIR}) include_directories (${QUICKLIST_INCLUDE_DIR})
@ -67,6 +68,7 @@ set (SERVER_SRC
eressea.pkg.c eressea.pkg.c
settings.pkg.c settings.pkg.c
eressea.c eressea.c
export.c
archetype.c archetype.c
creation.c creation.c
creport.c creport.c
@ -120,6 +122,7 @@ target_link_libraries(eressea
${SQLITE3_LIBRARIES} ${SQLITE3_LIBRARIES}
${CRITBIT_LIBRARIES} ${CRITBIT_LIBRARIES}
${CRYPTO_LIBRARIES} ${CRYPTO_LIBRARIES}
${CJSON_LIBRARIES}
${CURSES_LIBRARIES} ${CURSES_LIBRARIES}
${INIPARSER_LIBRARIES} ${INIPARSER_LIBRARIES}
) )
@ -146,6 +149,7 @@ target_link_libraries(test_eressea
${SQLITE3_LIBRARIES} ${SQLITE3_LIBRARIES}
${CRITBIT_LIBRARIES} ${CRITBIT_LIBRARIES}
${CRYPTO_LIBRARIES} ${CRYPTO_LIBRARIES}
${CJSON_LIBRARIES}
${CURSES_LIBRARIES} ${CURSES_LIBRARIES}
${INIPARSER_LIBRARIES} ${INIPARSER_LIBRARIES}
) )

20
src/export.c Normal file
View File

@ -0,0 +1,20 @@
#include <platform.h>
#include <kernel/types.h>
#include <kernel/region.h>
#include <kernel/terrain.h>
#include "cJSON.h"
void export_json(const char *filename) {
region * r;
cJSON *json, *root = cJSON_CreateObject();
cJSON_AddItemToObject(root, "regions", json = cJSON_CreateObject());
for (r=regions; r; r=r->next) {
char id[32];
cJSON *data;
snprintf(id, sizeof(id), "%u", r->uid);
cJSON_AddItemToObject(json, id, data = cJSON_CreateObject());
cJSON_AddNumberToObject(data, "x", r->x);
cJSON_AddNumberToObject(data, "y", r->y);
cJSON_AddStringToObject(data, "terrain", r->terrain->_name);
}
}