summaryrefslogtreecommitdiff
path: root/src/tool
diff options
context:
space:
mode:
Diffstat (limited to 'src/tool')
-rw-r--r--src/tool/CMakeLists.txt45
-rw-r--r--src/tool/Makefile.in88
-rw-r--r--src/tool/mapcache.c80
3 files changed, 72 insertions, 141 deletions
diff --git a/src/tool/CMakeLists.txt b/src/tool/CMakeLists.txt
deleted file mode 100644
index a54ffa0e2..000000000
--- a/src/tool/CMakeLists.txt
+++ /dev/null
@@ -1,45 +0,0 @@
-
-#
-# mapcache
-#
-if( WITH_ZLIB )
- option( BUILD_MAPCACHE "build mapcache executable" ON )
-else()
- message( STATUS "Disabled mapcache target (required ZLIB)" )
-endif()
-if( BUILD_MAPCACHE )
-message( STATUS "Creating target mapcache" )
-set( COMMON_HEADERS
- ${COMMON_MINI_HEADERS}
- "${COMMON_SOURCE_DIR}/des.h"
- "${COMMON_SOURCE_DIR}/grfio.h"
- "${COMMON_SOURCE_DIR}/utils.h"
- )
-set( COMMON_SOURCES
- ${COMMON_MINI_SOURCES}
- "${COMMON_SOURCE_DIR}/des.c"
- "${COMMON_SOURCE_DIR}/grfio.c"
- "${COMMON_SOURCE_DIR}/utils.c"
- )
-set( MAPCACHE_SOURCES
- "${CMAKE_CURRENT_SOURCE_DIR}/mapcache.c"
- )
-set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} )
-set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${COMMON_MINI_INCLUDE_DIRS} )
-set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_MINI_DEFINITIONS}" )
-set( SOURCE_FILES ${COMMON_HEADERS} ${COMMON_SOURCES} ${MAPCACHE_SOURCES} )
-source_group( common FILES ${COMMON_HEADERS} ${COMMON_SOURCES} )
-source_group( mapcache FILES ${MAPCACHE_SOURCES} )
-add_executable( mapcache ${SOURCE_FILES} )
-include_directories( ${INCLUDE_DIRS} )
-target_link_libraries( mapcache ${LIBRARIES} )
-set_target_properties( mapcache PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
-if( INSTALL_COMPONENT_RUNTIME )
- cpack_add_component( Runtime_mapcache DESCRIPTION "mapcache generator" DISPLAY_NAME "mapcache" GROUP Runtime )
- install( TARGETS mapcache
- DESTINATION "."
- COMPONENT Runtime_mapcache )
-endif( INSTALL_COMPONENT_RUNTIME )
-set( TARGET_LIST ${TARGET_LIST} mapcache CACHE INTERNAL "" )
-message( STATUS "Creating target mapcache - done" )
-endif( BUILD_MAPCACHE )
diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in
index 1e149c2b3..127d3841b 100644
--- a/src/tool/Makefile.in
+++ b/src/tool/Makefile.in
@@ -1,60 +1,82 @@
+# Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+# See the LICENSE file
-COMMON_OBJ = ../common/obj_all/minicore.o ../common/obj_all/malloc.o \
- ../common/obj_all/showmsg.o ../common/obj_all/strlib.o \
- ../common/obj_all/utils.o ../common/obj_all/des.o ../common/obj_all/grfio.o ../common/obj_all/miniconsole.o
-COMMON_H = ../common/core.h ../common/mmo.h \
- ../common/malloc.h ../common/showmsg.h ../common/strlib.h \
- ../common/utils.h ../common/cbasetypes.h ../common/des.h ../common/grfio.h ../common/console.h ../config/renewal.h
+# @configure_input@
-LIBCONFIG_OBJ = ../../3rdparty/libconfig/libconfig.o ../../3rdparty/libconfig/grammar.o \
- ../../3rdparty/libconfig/scanctx.o ../../3rdparty/libconfig/scanner.o ../../3rdparty/libconfig/strbuf.o
-LIBCONFIG_H = ../../3rdparty/libconfig/libconfig.h ../../3rdparty/libconfig/grammar.h \
- ../../3rdparty/libconfig/parsectx.h ../../3rdparty/libconfig/scanctx.h ../../3rdparty/libconfig/scanner.h \
- ../../3rdparty/libconfig/strbuf.h ../../3rdparty/libconfig/wincompat.h
-LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig
+CONFIG_D = ../config
+CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h)
-OTHER_H = ../config/renewal.h
+COMMON_D = ../common
+COMMON_H = $(wildcard $(COMMON_D)/*.h)
+SYSINFO_INC = $(COMMON_D)/sysinfo.inc
+
+LIBCONFIG_D = ../../3rdparty/libconfig
+LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
+ scanner.o strbuf.o)
+LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \
+ scanctx.h scanner.h strbuf.h wincompat.h)
+LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D)
MAPCACHE_OBJ = obj_all/mapcache.o
+MAPCACHE_C = mapcache.c
+MAPCACHE_H =
+MAPCACHE_DEPENDS = $(MAPCACHE_OBJ) $(COMMON_D)/obj_all/common_mini.a $(LIBCONFIG_OBJ $(SYSINFO_INC))
@SET_MAKE@
+CC = @CC@
+export CC
+
#####################################################################
-.PHONY : all mapcache clean help
+.PHONY: all mapcache clean buildclean help
+
+all: mapcache Makefile
+
+mapcache: ../../mapcache@EXEEXT@
-all: mapcache
+../../mapcache@EXEEXT@: $(MAPCACHE_DEPENDS) Makefile
+ @echo " LD $(notdir $@)"
+ @$(CC) @LDFLAGS@ -o ../../mapcache@EXEEXT@ $(MAPCACHE_DEPENDS) @LIBS@
-mapcache: obj_all $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ)
- @echo " LD $@"
- @@CC@ @LDFLAGS@ $(LIBCONFIG_INCLUDE) -o ../../mapcache@EXEEXT@ $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ) @LIBS@
+buildclean:
+ @echo " CLEAN tool (build temp files)"
+ @rm -rf obj_all/*.o
-clean:
+clean: buildclean
@echo " CLEAN tool"
- @rm -rf obj_all/*.o ../../mapcache@EXEEXT@
+ @rm -rf ../../mapcache@EXEEXT@
help:
@echo "possible targets are 'mapcache' 'all' 'clean' 'help'"
- @echo "'mapcache' - mapcache generator"
- @echo "'all' - builds all above targets"
- @echo "'clean' - cleans builds and objects"
- @echo "'help' - outputs this message"
+ @echo "'mapcache' - mapcache generator"
+ @echo "'all' - builds all above targets"
+ @echo "'clean' - cleans builds and objects"
+ @echo "'buildclean' - cleans build temporary (object) files, without deleting the"
+ @echo " executables"
+ @echo "'help' - outputs this message"
#####################################################################
+Makefile: Makefile.in
+ @$(MAKE) -C ../.. src/tool/Makefile
+
+$(SYSINFO_INC): $(MAPCACHE_C) $(MAPCACHE_H) $(COMMON_H) $(CONFIG_H) $(LIBCONFIG_H)
+ @echo " MAKE $@"
+ @$(MAKE) -C ../.. sysinfo
+
obj_all:
@echo " MKDIR obj_all"
@-mkdir obj_all
-obj_all/%.o: %.c $(COMMON_H) $(OTHER_H) $(LIBCONFIG_H)
+obj_all/%.o: %.c $(MAPCACHE_H) $(COMMON_H) $(CONFIG_H) $(LIBCONFIG_H) | obj_all
@echo " CC $<"
- @@CC@ @CFLAGS@ $(LIBCONFIG_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
+ @$(CC) @CFLAGS@ @DEFS@ $(LIBCONFIG_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
# missing common object files
-../common/obj_all/%.o:
- @$(MAKE) -C ../common sql
-
-../common/obj_all/mini%.o:
- @$(MAKE) -C ../common sql
+$(COMMON_D)/obj_all/common_mini.a:
+ @echo " MAKE $@"
+ @$(MAKE) -C $(COMMON_D) common_mini
-LIBCONFIG_OBJ:
- @$(MAKE) -C ../../3rdparty/libconfig
+$(LIBCONFIG_OBJ):
+ @echo " MAKE $@"
+ @$(MAKE) -C $(LIBCONFIG_D)
diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c
index 49f948709..2ead5edbb 100644
--- a/src/tool/mapcache.c
+++ b/src/tool/mapcache.c
@@ -1,18 +1,21 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
-#include "../common/cbasetypes.h"
-#include "../common/grfio.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
+#define HERCULES_CORE
-#include "../config/renewal.h"
+#include "../config/core.h" // RENEWAL
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "../common/cbasetypes.h"
+#include "../common/grfio.h"
+#include "../common/malloc.h"
+#include "../common/mmo.h"
+#include "../common/showmsg.h"
+#include "../common/utils.h"
+
#ifndef _WIN32
#include <unistd.h>
#endif
@@ -49,60 +52,10 @@ struct map_info {
int32 len;
};
-
-/*************************************
-* Big-endian compatibility functions *
-*************************************/
-
-// Converts an int16 from current machine order to little-endian
-int16 MakeShortLE(int16 val)
-{
- unsigned char buf[2];
- buf[0] = (unsigned char)( (val & 0x00FF) );
- buf[1] = (unsigned char)( (val & 0xFF00) >> 0x08 );
- return *((int16*)buf);
-}
-
-// Converts an int32 from current machine order to little-endian
-int32 MakeLongLE(int32 val)
-{
- unsigned char buf[4];
- buf[0] = (unsigned char)( (val & 0x000000FF) );
- buf[1] = (unsigned char)( (val & 0x0000FF00) >> 0x08 );
- buf[2] = (unsigned char)( (val & 0x00FF0000) >> 0x10 );
- buf[3] = (unsigned char)( (val & 0xFF000000) >> 0x18 );
- return *((int32*)buf);
-}
-
-// Reads an uint16 in little-endian from the buffer
-uint16 GetUShort(const unsigned char* buf)
-{
- return ( ((uint16)(buf[0])) )
- |( ((uint16)(buf[1])) << 0x08 );
-}
-
-// Reads an uint32 in little-endian from the buffer
-uint32 GetULong(const unsigned char* buf)
-{
- return ( ((uint32)(buf[0])) )
- |( ((uint32)(buf[1])) << 0x08 )
- |( ((uint32)(buf[2])) << 0x10 )
- |( ((uint32)(buf[3])) << 0x18 );
-}
-
-// Reads an int32 in little-endian from the buffer
-int32 GetLong(const unsigned char* buf)
-{
- return (int32)GetULong(buf);
-}
-
-// Reads a float (32 bits) from the buffer
-float GetFloat(const unsigned char* buf)
-{
- uint32 val = GetULong(buf);
- return *((float*)(void*)&val);
-}
-
+ /*************************************
+ * Big-endian compatibility functions *
+ * Moved to utils.h *
+ *************************************/
// Reads a map from GRF's GAT and RSW files
int read_map(char *name, struct map_data *m)
@@ -176,12 +129,13 @@ void cache_map(char *name, struct map_data *m)
encode_zip(write_buf, &len, m->cells, m->xs*m->ys);
// Fill the map header
- if (strlen(name) > MAP_NAME_LENGTH) // It does not hurt to warn that there are maps with name longer than allowed.
- ShowWarning ("Map name '%s' size '%d' is too long. Truncating to '%d'.\n", name, strlen(name), MAP_NAME_LENGTH);
strncpy(info.name, name, MAP_NAME_LENGTH);
+ if (strlen(name) > MAP_NAME_LENGTH) // It does not hurt to warn that there are maps with name longer than allowed.
+ ShowWarning("Map name '%s' (length %"PRIuS") is too long. Truncating to '%s' (lentgh %d).\n",
+ name, strlen(name), info.name, MAP_NAME_LENGTH);
info.xs = MakeShortLE(m->xs);
info.ys = MakeShortLE(m->ys);
- info.len = MakeLongLE(len);
+ info.len = MakeLongLE((uint32)len);
// Append map header then compressed cells at the end of the file
fseek(map_cache_fp, header.file_size, SEEK_SET);