From 801d3ed94263f48566ad5bf80a9c96d3ae49bd56 Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Thu, 14 Jun 2018 21:51:58 +0200 Subject: [PATCH] Moved common, config and mapcache to C++ (#3200) Dropped BETA_THREAD_TEST and everything around it Dropped mt19937 Replaced msinttypes with cinttypes Removed IRC link and updated README name --- .gitignore | 8 - 3rdparty/CMakeLists.txt | 2 - 3rdparty/README.txt | 2 - 3rdparty/msinttypes/CMakeLists.txt | 9 - 3rdparty/msinttypes/include/inttypes.h | 305 ----- 3rdparty/msinttypes/include/stdint.h | 251 ---- 3rdparty/mt19937ar/CMakeLists.txt | 16 - 3rdparty/mt19937ar/Makefile.in | 26 - 3rdparty/mt19937ar/mt19937ar.c | 175 --- 3rdparty/mt19937ar/mt19937ar.h | 82 -- 3rdparty/mt19937ar/mt19937ar.out | 403 ------- 3rdparty/mt19937ar/mt19937ar.vcxproj | 158 --- 3rdparty/mt19937ar/mt19937ar.vcxproj.filters | 23 - 3rdparty/mt19937ar/mtTest.c | 65 -- 3rdparty/mt19937ar/readme-mt.txt | 79 -- Makefile.in | 14 +- conf/login_athena.conf | 2 +- configure | 5 +- configure.in | 4 +- doc/mapflags.txt | 2 +- doc/source_doc.txt | 9 - npc/mapflag/skill_damage.txt | 2 +- rAthena.sln | 44 +- src/CMakeLists.txt | 1 - src/char/Makefile.in | 21 +- src/char/char-server.vcxproj | 8 +- src/char/char.cpp | 26 +- src/char/char.hpp | 8 +- src/char/char_clif.cpp | 20 +- src/char/char_clif.hpp | 4 +- src/char/char_cnslif.cpp | 10 +- src/char/char_cnslif.hpp | 3 - src/char/char_logif.cpp | 14 +- src/char/char_logif.hpp | 2 +- src/char/char_mapif.cpp | 10 +- src/char/char_mapif.hpp | 2 +- src/char/int_achievement.cpp | 14 +- src/char/int_auction.cpp | 14 +- src/char/int_clan.cpp | 12 +- src/char/int_elemental.cpp | 10 +- src/char/int_guild.cpp | 14 +- src/char/int_guild.hpp | 2 +- src/char/int_homun.cpp | 12 +- src/char/int_homun.hpp | 2 +- src/char/int_mail.cpp | 10 +- src/char/int_mail.hpp | 2 +- src/char/int_mercenary.cpp | 10 +- src/char/int_mercenary.hpp | 2 +- src/char/int_party.cpp | 16 +- src/char/int_party.hpp | 2 +- src/char/int_pet.cpp | 14 +- src/char/int_pet.hpp | 2 +- src/char/int_quest.cpp | 10 +- src/char/int_storage.cpp | 12 +- src/char/int_storage.hpp | 2 +- src/char/inter.cpp | 12 +- src/char/inter.hpp | 4 +- src/common/CMakeLists.txt | 117 +- src/common/Makefile.in | 31 +- src/common/atomic.h | 153 --- src/common/{cbasetypes.h => cbasetypes.hpp} | 10 +- src/common/{cli.c => cli.cpp} | 19 +- src/common/{cli.h => cli.hpp} | 16 +- src/common/common-minicore.vcxproj | 80 +- src/common/common-minicore.vcxproj.filters | 64 +- src/common/common.vcxproj | 102 +- src/common/common.vcxproj.filters | 114 +- src/common/{conf.c => conf.cpp} | 4 +- src/common/{conf.h => conf.hpp} | 16 +- src/common/core.cpp | 28 +- src/common/{core.h => core.hpp} | 14 +- src/common/{db.c => db.cpp} | 20 +- src/common/{db.h => db.hpp} | 18 +- src/common/{des.c => des.cpp} | 4 +- src/common/{des.h => des.hpp} | 6 +- src/common/{ers.c => ers.cpp} | 22 +- src/common/{ers.h => ers.hpp} | 17 +- src/common/evdp.h | 168 --- src/common/evdp_epoll.c | 218 ---- src/common/{grfio.c => grfio.cpp} | 28 +- src/common/{grfio.h => grfio.hpp} | 14 +- src/common/{malloc.c => malloc.cpp} | 22 +- src/common/{malloc.h => malloc.hpp} | 16 +- src/common/{mapindex.c => mapindex.cpp} | 13 +- src/common/{mapindex.h => mapindex.hpp} | 16 +- src/common/{md5calc.c => md5calc.cpp} | 4 +- src/common/{md5calc.h => md5calc.hpp} | 14 +- src/common/mempool.c | 566 --------- src/common/mempool.h | 107 -- src/common/{mmo.h => mmo.hpp} | 14 +- src/common/{msg_conf.c => msg_conf.cpp} | 8 +- src/common/{msg_conf.h => msg_conf.hpp} | 16 +- src/common/mutex.c | 246 ---- src/common/mutex.h | 92 -- src/common/netbuffer.c | 206 ---- src/common/netbuffer.h | 83 -- src/common/network.c | 1034 ----------------- src/common/network.h | 189 --- src/common/{nullpo.c => nullpo.cpp} | 4 +- src/common/{nullpo.h => nullpo.hpp} | 16 +- src/common/raconf.c | 582 ---------- src/common/raconf.h | 59 - src/common/random.c | 83 -- src/common/random.cpp | 44 + src/common/random.h | 26 - src/common/random.hpp | 14 + src/common/{showmsg.c => showmsg.cpp} | 24 +- src/common/{showmsg.h => showmsg.hpp} | 14 +- src/common/{socket.c => socket.cpp} | 20 +- src/common/{socket.h => socket.hpp} | 16 +- src/common/spinlock.h | 102 -- src/common/{sql.c => sql.cpp} | 12 +- src/common/{sql.h => sql.hpp} | 16 +- src/common/{strlib.c => strlib.cpp} | 15 +- src/common/{strlib.h => strlib.hpp} | 18 +- src/common/thread.c | 327 ------ src/common/thread.h | 135 --- src/common/{timer.c => timer.cpp} | 16 +- src/common/{timer.h => timer.hpp} | 16 +- src/common/{utils.c => utils.cpp} | 8 +- src/common/{utils.h => utils.hpp} | 16 +- src/common/winapi.cpp | 2 +- src/common/winapi.hpp | 2 +- src/common/yamlwrapper.cpp | 242 ---- src/common/yamlwrapper.h | 97 -- src/config/classes/{general.h => general.hpp} | 6 +- src/config/{const.h => const.hpp} | 6 +- src/config/{core.h => core.hpp} | 25 +- src/config/{packets.h => packets.hpp} | 10 +- src/config/{renewal.h => renewal.hpp} | 6 +- src/config/{secure.h => secure.hpp} | 6 +- .../{defines_pre.h => defines_post.hpp} | 6 +- .../{defines_post.h => defines_pre.hpp} | 6 +- src/login/Makefile.in | 22 +- src/login/account.cpp | 12 +- src/login/account.hpp | 6 +- src/login/ipban.cpp | 10 +- src/login/ipban.hpp | 2 +- src/login/login-server.vcxproj | 8 +- src/login/login.cpp | 28 +- src/login/login.hpp | 8 +- src/login/loginchrif.cpp | 8 +- src/login/loginchrif.hpp | 2 +- src/login/loginclif.cpp | 16 +- src/login/logincnslif.cpp | 16 +- src/login/logincnslif.hpp | 10 +- src/login/loginlog.cpp | 12 +- src/login/loginlog.hpp | 2 +- src/map/Makefile.in | 25 +- src/map/achievement.cpp | 12 +- src/map/achievement.hpp | 4 +- src/map/atcommand.cpp | 25 +- src/map/atcommand.hpp | 4 +- src/map/battle.cpp | 20 +- src/map/battle.hpp | 6 +- src/map/battleground.cpp | 12 +- src/map/battleground.hpp | 4 +- src/map/buyingstore.cpp | 14 +- src/map/buyingstore.hpp | 2 +- src/map/cashshop.cpp | 6 +- src/map/cashshop.hpp | 6 +- src/map/channel.cpp | 16 +- src/map/channel.hpp | 4 +- src/map/chat.cpp | 12 +- src/map/chrif.cpp | 18 +- src/map/chrif.hpp | 4 +- src/map/clan.cpp | 10 +- src/map/clan.hpp | 2 +- src/map/clif.cpp | 24 +- src/map/clif.hpp | 6 +- src/map/date.hpp | 2 +- src/map/duel.cpp | 4 +- src/map/duel.hpp | 2 +- src/map/elemental.cpp | 18 +- src/map/elemental.hpp | 2 +- src/map/guild.cpp | 18 +- src/map/guild.hpp | 4 +- src/map/homunculus.cpp | 18 +- src/map/homunculus.hpp | 2 +- src/map/instance.cpp | 18 +- src/map/instance.hpp | 6 +- src/map/intif.cpp | 14 +- src/map/intif.hpp | 4 +- src/map/itemdb.cpp | 12 +- src/map/itemdb.hpp | 4 +- src/map/log.cpp | 78 +- src/map/log.hpp | 9 +- src/map/mail.cpp | 8 +- src/map/mail.hpp | 2 +- src/map/map-server.vcxproj | 8 +- src/map/map.cpp | 33 +- src/map/map.hpp | 46 +- src/map/mapreg.cpp | 16 +- src/map/mapreg.hpp | 4 +- src/map/mercenary.cpp | 18 +- src/map/mercenary.hpp | 2 +- src/map/mob.cpp | 22 +- src/map/mob.hpp | 2 +- src/map/npc.cpp | 22 +- src/map/npc_chat.cpp | 8 +- src/map/party.cpp | 18 +- src/map/party.hpp | 2 +- src/map/path.cpp | 12 +- src/map/path.hpp | 2 +- src/map/pc.cpp | 24 +- src/map/pc.hpp | 4 +- src/map/pc_groups.cpp | 12 +- src/map/pc_groups.hpp | 2 +- src/map/pet.cpp | 18 +- src/map/pet.hpp | 4 +- src/map/quest.cpp | 14 +- src/map/quest.hpp | 4 +- src/map/script.cpp | 316 +---- src/map/script.hpp | 10 +- src/map/searchstore.cpp | 8 +- src/map/searchstore.hpp | 4 +- src/map/skill.cpp | 22 +- src/map/skill.hpp | 6 +- src/map/status.cpp | 18 +- src/map/status.hpp | 4 +- src/map/storage.cpp | 8 +- src/map/storage.hpp | 2 +- src/map/trade.cpp | 4 +- src/map/unit.cpp | 16 +- src/map/unit.hpp | 2 +- src/map/vending.cpp | 10 +- src/map/vending.hpp | 4 +- src/test/CMakeLists.txt | 41 - src/test/basic_test.vcxproj | 171 --- src/test/basic_test.vcxproj.filters | 32 - src/test/basictest.cpp | 39 - src/test/test_spinlock.cpp | 102 -- src/test/test_spinlock.hpp | 12 - src/test/test_thread.cpp | 48 - src/test/test_thread.hpp | 12 - src/tool/CMakeLists.txt | 14 +- src/tool/Makefile.in | 12 +- src/tool/{mapcache.c => mapcache.cpp} | 16 +- src/tool/mapcache.vcxproj | 2 +- src/tool/mapcache.vcxproj.filters | 2 +- 240 files changed, 1163 insertions(+), 8613 deletions(-) delete mode 100644 3rdparty/msinttypes/CMakeLists.txt delete mode 100644 3rdparty/msinttypes/include/inttypes.h delete mode 100644 3rdparty/msinttypes/include/stdint.h delete mode 100644 3rdparty/mt19937ar/CMakeLists.txt delete mode 100644 3rdparty/mt19937ar/Makefile.in delete mode 100644 3rdparty/mt19937ar/mt19937ar.c delete mode 100644 3rdparty/mt19937ar/mt19937ar.h delete mode 100644 3rdparty/mt19937ar/mt19937ar.out delete mode 100644 3rdparty/mt19937ar/mt19937ar.vcxproj delete mode 100644 3rdparty/mt19937ar/mt19937ar.vcxproj.filters delete mode 100644 3rdparty/mt19937ar/mtTest.c delete mode 100644 3rdparty/mt19937ar/readme-mt.txt delete mode 100644 src/common/atomic.h rename src/common/{cbasetypes.h => cbasetypes.hpp} (98%) rename src/common/{cli.c => cli.cpp} (92%) rename src/common/{cli.h => cli.hpp} (90%) rename src/common/{conf.c => conf.cpp} (98%) rename src/common/{conf.h => conf.hpp} (68%) rename src/common/{core.h => core.hpp} (91%) rename src/common/{db.c => db.cpp} (99%) rename src/common/{db.h => db.hpp} (99%) rename src/common/{des.c => des.cpp} (99%) rename src/common/{des.h => des.hpp} (83%) rename src/common/{ers.c => ers.cpp} (92%) rename src/common/{ers.h => ers.hpp} (98%) delete mode 100644 src/common/evdp.h delete mode 100644 src/common/evdp_epoll.c rename src/common/{grfio.c => grfio.cpp} (97%) rename src/common/{grfio.h => grfio.hpp} (81%) rename src/common/{malloc.c => malloc.cpp} (98%) rename src/common/{malloc.h => malloc.hpp} (95%) rename src/common/{mapindex.c => mapindex.cpp} (96%) rename src/common/{mapindex.h => mapindex.hpp} (92%) rename src/common/{md5calc.c => md5calc.cpp} (99%) rename src/common/{md5calc.h => md5calc.hpp} (55%) delete mode 100644 src/common/mempool.c delete mode 100644 src/common/mempool.h rename src/common/{mmo.h => mmo.hpp} (99%) rename src/common/{msg_conf.c => msg_conf.cpp} (94%) rename src/common/{msg_conf.h => msg_conf.hpp} (85%) delete mode 100644 src/common/mutex.c delete mode 100644 src/common/mutex.h delete mode 100644 src/common/netbuffer.c delete mode 100644 src/common/netbuffer.h delete mode 100644 src/common/network.c delete mode 100644 src/common/network.h rename src/common/{nullpo.c => nullpo.cpp} (98%) rename src/common/{nullpo.h => nullpo.hpp} (97%) delete mode 100644 src/common/raconf.c delete mode 100644 src/common/raconf.h delete mode 100644 src/common/random.c create mode 100644 src/common/random.cpp delete mode 100644 src/common/random.h create mode 100644 src/common/random.hpp rename src/common/{showmsg.c => showmsg.cpp} (98%) rename src/common/{showmsg.h => showmsg.hpp} (95%) rename src/common/{socket.c => socket.cpp} (99%) rename src/common/{socket.h => socket.hpp} (97%) delete mode 100644 src/common/spinlock.h rename src/common/{sql.c => sql.cpp} (99%) rename src/common/{sql.h => sql.hpp} (98%) rename src/common/{strlib.c => strlib.cpp} (99%) rename src/common/{strlib.h => strlib.hpp} (96%) delete mode 100644 src/common/thread.c delete mode 100644 src/common/thread.h rename src/common/{timer.c => timer.cpp} (98%) rename src/common/{timer.h => timer.hpp} (90%) rename src/common/{utils.c => utils.cpp} (98%) rename src/common/{utils.h => utils.hpp} (92%) delete mode 100644 src/common/yamlwrapper.cpp delete mode 100644 src/common/yamlwrapper.h rename src/config/classes/{general.h => general.hpp} (86%) rename src/config/{const.h => const.hpp} (97%) rename src/config/{core.h => core.hpp} (83%) rename src/config/{packets.h => packets.hpp} (87%) rename src/config/{renewal.h => renewal.hpp} (96%) rename src/config/{secure.h => secure.hpp} (93%) rename src/custom/{defines_pre.h => defines_post.hpp} (67%) rename src/custom/{defines_post.h => defines_pre.hpp} (67%) delete mode 100644 src/test/CMakeLists.txt delete mode 100644 src/test/basic_test.vcxproj delete mode 100644 src/test/basic_test.vcxproj.filters delete mode 100644 src/test/basictest.cpp delete mode 100644 src/test/test_spinlock.cpp delete mode 100644 src/test/test_spinlock.hpp delete mode 100644 src/test/test_thread.cpp delete mode 100644 src/test/test_thread.hpp rename src/tool/{mapcache.c => mapcache.cpp} (95%) diff --git a/.gitignore b/.gitignore index 5727a20710..1fe0e65709 100644 --- a/.gitignore +++ b/.gitignore @@ -46,10 +46,6 @@ Thumbs.db /3rdparty/libconfig/*.o /3rdparty/libconfig/obj -# /3rdparty/mt19937ar/ -/3rdparty/mt19937ar/Makefile -/3rdparty/mt19937ar/*.o - # /3rdparty/yaml-cpp/ /3rdparty/yaml-cpp/Makefile @@ -86,10 +82,6 @@ Thumbs.db /src/map/obj_sql /src/map/pcre.h -# /src/test/ -/src/test/Makefile -/src/test/obj - # /src/tool/ /src/tool/Makefile /src/tool/obj_all diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 4ff5169bb3..9c373dd186 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -48,8 +48,6 @@ endmacro( CONFIGURE_WITH_LOCAL_OR_SYSTEM ) add_subdirectory( libconfig ) -add_subdirectory( msinttypes ) -add_subdirectory( mt19937ar ) add_subdirectory( mysql ) add_subdirectory( pcre ) add_subdirectory( zlib ) diff --git a/3rdparty/README.txt b/3rdparty/README.txt index a39a0dc974..06d04d0b87 100644 --- a/3rdparty/README.txt +++ b/3rdparty/README.txt @@ -2,8 +2,6 @@ This folder contains everything related to 3rdparty code or tools. cmake - scripts for the cmake build system (http://www.cmake.org) libconfig - library for processing structured configuration files (http://www.hyperrealm.com/libconfig/) -msinttypes - standard headers missing from Microsoft Visual Studio (http://code.google.com/p/msinttypes) -mt19937ar - code for Mersenne Twister pseudorandom number generator mysql - library for MySQL Community Server (http://www.mysql.com) pcre - library for Perl Compatible Regular Expressions (http://www.pcre.org) zlib - library for DEFLATE lossless compression algorithm (http://www.zlib.net) diff --git a/3rdparty/msinttypes/CMakeLists.txt b/3rdparty/msinttypes/CMakeLists.txt deleted file mode 100644 index c11c1d72a1..0000000000 --- a/3rdparty/msinttypes/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ - -if( MSVC ) -find_path( MSINTTYPES_INCLUDE_DIRS "inttypes.h" - PATHS "${CMAKE_CURRENT_SOURCE_DIR}/include" - NO_DEFAULT_PATH ) -mark_as_advanced( MSINTTYPES_INCLUDE_DIRS ) -message( STATUS "Adding global include directory: ${MSINTTYPES_INCLUDE_DIRS}" ) -set_property( CACHE GLOBAL_INCLUDE_DIRS PROPERTY VALUE ${GLOBAL_INCLUDE_DIRS} ${MSINTTYPES_INCLUDE_DIRS} ) -endif() diff --git a/3rdparty/msinttypes/include/inttypes.h b/3rdparty/msinttypes/include/inttypes.h deleted file mode 100644 index 4b3828a216..0000000000 --- a/3rdparty/msinttypes/include/inttypes.h +++ /dev/null @@ -1,305 +0,0 @@ -// ISO C9x compliant inttypes.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// -// Copyright (c) 2006 Alexander Chemeris -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. The name of the author may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] - -#ifndef _MSC_INTTYPES_H_ // [ -#define _MSC_INTTYPES_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif - -#include "stdint.h" - -// 7.8 Format conversion of integer types - -typedef struct { - intmax_t quot; - intmax_t rem; -} imaxdiv_t; - -// 7.8.1 Macros for format specifiers - -#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198 - -// The fprintf macros for signed integers are: -#define PRId8 "d" -#define PRIi8 "i" -#define PRIdLEAST8 "d" -#define PRIiLEAST8 "i" -#define PRIdFAST8 "d" -#define PRIiFAST8 "i" - -#define PRId16 "hd" -#define PRIi16 "hi" -#define PRIdLEAST16 "hd" -#define PRIiLEAST16 "hi" -#define PRIdFAST16 "hd" -#define PRIiFAST16 "hi" - -#define PRId32 "I32d" -#define PRIi32 "I32i" -#define PRIdLEAST32 "I32d" -#define PRIiLEAST32 "I32i" -#define PRIdFAST32 "I32d" -#define PRIiFAST32 "I32i" - -#define PRId64 "I64d" -#define PRIi64 "I64i" -#define PRIdLEAST64 "I64d" -#define PRIiLEAST64 "I64i" -#define PRIdFAST64 "I64d" -#define PRIiFAST64 "I64i" - -#define PRIdMAX "I64d" -#define PRIiMAX "I64i" - -#define PRIdPTR "Id" -#define PRIiPTR "Ii" - -// The fprintf macros for unsigned integers are: -#define PRIo8 "o" -#define PRIu8 "u" -#define PRIx8 "x" -#define PRIX8 "X" -#define PRIoLEAST8 "o" -#define PRIuLEAST8 "u" -#define PRIxLEAST8 "x" -#define PRIXLEAST8 "X" -#define PRIoFAST8 "o" -#define PRIuFAST8 "u" -#define PRIxFAST8 "x" -#define PRIXFAST8 "X" - -#define PRIo16 "ho" -#define PRIu16 "hu" -#define PRIx16 "hx" -#define PRIX16 "hX" -#define PRIoLEAST16 "ho" -#define PRIuLEAST16 "hu" -#define PRIxLEAST16 "hx" -#define PRIXLEAST16 "hX" -#define PRIoFAST16 "ho" -#define PRIuFAST16 "hu" -#define PRIxFAST16 "hx" -#define PRIXFAST16 "hX" - -#define PRIo32 "I32o" -#define PRIu32 "I32u" -#define PRIx32 "I32x" -#define PRIX32 "I32X" -#define PRIoLEAST32 "I32o" -#define PRIuLEAST32 "I32u" -#define PRIxLEAST32 "I32x" -#define PRIXLEAST32 "I32X" -#define PRIoFAST32 "I32o" -#define PRIuFAST32 "I32u" -#define PRIxFAST32 "I32x" -#define PRIXFAST32 "I32X" - -#define PRIo64 "I64o" -#define PRIu64 "I64u" -#define PRIx64 "I64x" -#define PRIX64 "I64X" -#define PRIoLEAST64 "I64o" -#define PRIuLEAST64 "I64u" -#define PRIxLEAST64 "I64x" -#define PRIXLEAST64 "I64X" -#define PRIoFAST64 "I64o" -#define PRIuFAST64 "I64u" -#define PRIxFAST64 "I64x" -#define PRIXFAST64 "I64X" - -#define PRIoMAX "I64o" -#define PRIuMAX "I64u" -#define PRIxMAX "I64x" -#define PRIXMAX "I64X" - -#define PRIoPTR "Io" -#define PRIuPTR "Iu" -#define PRIxPTR "Ix" -#define PRIXPTR "IX" - -// The fscanf macros for signed integers are: -#define SCNd8 "d" -#define SCNi8 "i" -#define SCNdLEAST8 "d" -#define SCNiLEAST8 "i" -#define SCNdFAST8 "d" -#define SCNiFAST8 "i" - -#define SCNd16 "hd" -#define SCNi16 "hi" -#define SCNdLEAST16 "hd" -#define SCNiLEAST16 "hi" -#define SCNdFAST16 "hd" -#define SCNiFAST16 "hi" - -#define SCNd32 "ld" -#define SCNi32 "li" -#define SCNdLEAST32 "ld" -#define SCNiLEAST32 "li" -#define SCNdFAST32 "ld" -#define SCNiFAST32 "li" - -#define SCNd64 "I64d" -#define SCNi64 "I64i" -#define SCNdLEAST64 "I64d" -#define SCNiLEAST64 "I64i" -#define SCNdFAST64 "I64d" -#define SCNiFAST64 "I64i" - -#define SCNdMAX "I64d" -#define SCNiMAX "I64i" - -#ifdef _WIN64 // [ -# define SCNdPTR "I64d" -# define SCNiPTR "I64i" -#else // _WIN64 ][ -# define SCNdPTR "ld" -# define SCNiPTR "li" -#endif // _WIN64 ] - -// The fscanf macros for unsigned integers are: -#define SCNo8 "o" -#define SCNu8 "u" -#define SCNx8 "x" -#define SCNX8 "X" -#define SCNoLEAST8 "o" -#define SCNuLEAST8 "u" -#define SCNxLEAST8 "x" -#define SCNXLEAST8 "X" -#define SCNoFAST8 "o" -#define SCNuFAST8 "u" -#define SCNxFAST8 "x" -#define SCNXFAST8 "X" - -#define SCNo16 "ho" -#define SCNu16 "hu" -#define SCNx16 "hx" -#define SCNX16 "hX" -#define SCNoLEAST16 "ho" -#define SCNuLEAST16 "hu" -#define SCNxLEAST16 "hx" -#define SCNXLEAST16 "hX" -#define SCNoFAST16 "ho" -#define SCNuFAST16 "hu" -#define SCNxFAST16 "hx" -#define SCNXFAST16 "hX" - -#define SCNo32 "lo" -#define SCNu32 "lu" -#define SCNx32 "lx" -#define SCNX32 "lX" -#define SCNoLEAST32 "lo" -#define SCNuLEAST32 "lu" -#define SCNxLEAST32 "lx" -#define SCNXLEAST32 "lX" -#define SCNoFAST32 "lo" -#define SCNuFAST32 "lu" -#define SCNxFAST32 "lx" -#define SCNXFAST32 "lX" - -#define SCNo64 "I64o" -#define SCNu64 "I64u" -#define SCNx64 "I64x" -#define SCNX64 "I64X" -#define SCNoLEAST64 "I64o" -#define SCNuLEAST64 "I64u" -#define SCNxLEAST64 "I64x" -#define SCNXLEAST64 "I64X" -#define SCNoFAST64 "I64o" -#define SCNuFAST64 "I64u" -#define SCNxFAST64 "I64x" -#define SCNXFAST64 "I64X" - -#define SCNoMAX "I64o" -#define SCNuMAX "I64u" -#define SCNxMAX "I64x" -#define SCNXMAX "I64X" - -#ifdef _WIN64 // [ -# define SCNoPTR "I64o" -# define SCNuPTR "I64u" -# define SCNxPTR "I64x" -# define SCNXPTR "I64X" -#else // _WIN64 ][ -# define SCNoPTR "lo" -# define SCNuPTR "lu" -# define SCNxPTR "lx" -# define SCNXPTR "lX" -#endif // _WIN64 ] - -#endif // __STDC_FORMAT_MACROS ] - -// 7.8.2 Functions for greatest-width integer types - -// 7.8.2.1 The imaxabs function -#define imaxabs _abs64 - -// 7.8.2.2 The imaxdiv function - -// This is modified version of div() function from Microsoft's div.c found -// in %MSVC.NET%\crt\src\div.c -#ifdef STATIC_IMAXDIV // [ -static -#else // STATIC_IMAXDIV ][ -_inline -#endif // STATIC_IMAXDIV ] -imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom) -{ - imaxdiv_t result; - - result.quot = numer / denom; - result.rem = numer % denom; - - if (numer < 0 && result.rem > 0) { - // did division wrong; must fix up - ++result.quot; - result.rem -= denom; - } - - return result; -} - -// 7.8.2.3 The strtoimax and strtoumax functions -#define strtoimax _strtoi64 -#define strtoumax _strtoui64 - -// 7.8.2.4 The wcstoimax and wcstoumax functions -#define wcstoimax _wcstoi64 -#define wcstoumax _wcstoui64 - - -#endif // _MSC_INTTYPES_H_ ] diff --git a/3rdparty/msinttypes/include/stdint.h b/3rdparty/msinttypes/include/stdint.h deleted file mode 100644 index cbb023bf93..0000000000 --- a/3rdparty/msinttypes/include/stdint.h +++ /dev/null @@ -1,251 +0,0 @@ -// ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// -// Copyright (c) 2006-2008 Alexander Chemeris -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. The name of the author may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] - -#ifndef _MSC_STDINT_H_ // [ -#define _MSC_STDINT_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif - -#include - -// For Visual Studio 6 in C++ mode and for many Visual Studio versions when -// compiling for ARM we should wrap include with 'extern "C++" {}' -// or compiler give many errors like this: -// error C2733: second C linkage of overloaded function 'wmemchr' not allowed -#ifdef __cplusplus -#if _MSC_VER < 1300 -extern "C++" { -#else -extern "C" { -#endif -#endif -# include -#ifdef __cplusplus -} -#endif - -// Define _W64 macros to mark types changing their size, like intptr_t. -#ifndef _W64 -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif -#endif - - -// 7.18.1 Integer types - -// 7.18.1.1 Exact-width integer types - -// Visual Studio 6 and Embedded Visual C++ 4 doesn't -// realize that, e.g. char has the same size as __int8 -// so we give up on __intX for them. -#if (_MSC_VER < 1300) - typedef signed char int8_t; - typedef signed short int16_t; - typedef signed int int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; -#else - typedef signed __int8 int8_t; - typedef signed __int16 int16_t; - typedef signed __int32 int32_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; -#endif -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; - - -// 7.18.1.2 Minimum-width integer types -typedef int8_t int_least8_t; -typedef int16_t int_least16_t; -typedef int32_t int_least32_t; -typedef int64_t int_least64_t; -typedef uint8_t uint_least8_t; -typedef uint16_t uint_least16_t; -typedef uint32_t uint_least32_t; -typedef uint64_t uint_least64_t; - -// 7.18.1.3 Fastest minimum-width integer types -typedef int8_t int_fast8_t; -typedef int16_t int_fast16_t; -typedef int32_t int_fast32_t; -typedef int64_t int_fast64_t; -typedef uint8_t uint_fast8_t; -typedef uint16_t uint_fast16_t; -typedef uint32_t uint_fast32_t; -typedef uint64_t uint_fast64_t; - -// 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ - typedef signed __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ - typedef _W64 signed int intptr_t; - typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] - -// 7.18.1.5 Greatest-width integer types -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - - -// 7.18.2 Limits of specified-width integer types - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 - -// 7.18.2.1 Limits of exact-width integer types -#define INT8_MIN ((int8_t)_I8_MIN) -#define INT8_MAX _I8_MAX -#define INT16_MIN ((int16_t)_I16_MIN) -#define INT16_MAX _I16_MAX -#define INT32_MIN ((int32_t)_I32_MIN) -#define INT32_MAX _I32_MAX -#define INT64_MIN ((int64_t)_I64_MIN) -#define INT64_MAX _I64_MAX -#define UINT8_MAX _UI8_MAX -#define UINT16_MAX _UI16_MAX -#define UINT32_MAX _UI32_MAX -#define UINT64_MAX _UI64_MAX - -// 7.18.2.2 Limits of minimum-width integer types -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MIN INT64_MIN -#define INT_LEAST64_MAX INT64_MAX -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -// 7.18.2.3 Limits of fastest minimum-width integer types -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MIN INT64_MIN -#define INT_FAST64_MAX INT64_MAX -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -// 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ -# define INTPTR_MIN INT64_MIN -# define INTPTR_MAX INT64_MAX -# define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ -# define INTPTR_MIN INT32_MIN -# define INTPTR_MAX INT32_MAX -# define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] - -// 7.18.2.5 Limits of greatest-width integer types -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -// 7.18.3 Limits of other integer types - -#ifdef _WIN64 // [ -# define PTRDIFF_MIN _I64_MIN -# define PTRDIFF_MAX _I64_MAX -#else // _WIN64 ][ -# define PTRDIFF_MIN _I32_MIN -# define PTRDIFF_MAX _I32_MAX -#endif // _WIN64 ] - -#define SIG_ATOMIC_MIN INT_MIN -#define SIG_ATOMIC_MAX INT_MAX - -#ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ -# define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ -# define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] -#endif // SIZE_MAX ] - -// WCHAR_MIN and WCHAR_MAX are also defined in -#ifndef WCHAR_MIN // [ -# define WCHAR_MIN 0 -#endif // WCHAR_MIN ] -#ifndef WCHAR_MAX // [ -# define WCHAR_MAX _UI16_MAX -#endif // WCHAR_MAX ] - -#define WINT_MIN 0 -#define WINT_MAX _UI16_MAX - -#endif // __STDC_LIMIT_MACROS ] - - -// 7.18.4 Limits of other integer types - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 - -// 7.18.4.1 Macros for minimum-width integer constants - -#define INT8_C(val) val##i8 -#define INT16_C(val) val##i16 -#define INT32_C(val) val##i32 -#define INT64_C(val) val##i64 - -#define UINT8_C(val) val##ui8 -#define UINT16_C(val) val##ui16 -#define UINT32_C(val) val##ui32 -#define UINT64_C(val) val##ui64 - -// 7.18.4.2 Macros for greatest-width integer constants -#define INTMAX_C INT64_C -#define UINTMAX_C UINT64_C - -#endif // __STDC_CONSTANT_MACROS ] - - -#endif // _MSC_STDINT_H_ ] diff --git a/3rdparty/mt19937ar/CMakeLists.txt b/3rdparty/mt19937ar/CMakeLists.txt deleted file mode 100644 index 08eff57909..0000000000 --- a/3rdparty/mt19937ar/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ - -find_path( MT19937AR_INCLUDE_DIRS "mt19937ar.h" - PATHS "${CMAKE_CURRENT_SOURCE_DIR}" - NO_DEFAULT_PATH ) -find_path( MT19937AR_SOURCE_DIR "mt19937ar.c" - PATHS "${CMAKE_CURRENT_SOURCE_DIR}" - NO_DEFAULT_PATH ) -mark_as_advanced( MT19937AR_INCLUDE_DIRS ) -mark_as_advanced( MT19937AR_SOURCE_DIR ) - -set( MT19937AR_HEADERS - "${CMAKE_CURRENT_SOURCE_DIR}/mt19937ar.h" - CACHE INTERNAL "mt19937ar headers" ) -set( MT19937AR_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/mt19937ar.c" - CACHE INTERNAL "mt19937ar sources" ) diff --git a/3rdparty/mt19937ar/Makefile.in b/3rdparty/mt19937ar/Makefile.in deleted file mode 100644 index 9afddc81cb..0000000000 --- a/3rdparty/mt19937ar/Makefile.in +++ /dev/null @@ -1,26 +0,0 @@ - -MT19937AR_OBJ = mt19937ar.o -MT19937AR_H = mt19937ar.h - -@SET_MAKE@ - -##################################################################### -.PHONY : all clean help - -all: $(MT19937AR_OBJ) - -clean: - @echo " CLEAN mt19937ar" - @rm -rf *.o - -help: - @echo "possible targets are 'all' 'clean' 'help'" - @echo "'all' - builds $(MT19937AR_OBJ)" - @echo "'clean' - deletes $(MT19937AR_OBJ)" - @echo "'help' - outputs this message" - -##################################################################### - -%.o: %.c $(MT19937AR_H) - @echo " CC $<" - @@CC@ @CFLAGS_AR@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/3rdparty/mt19937ar/mt19937ar.c b/3rdparty/mt19937ar/mt19937ar.c deleted file mode 100644 index 211aefde9c..0000000000 --- a/3rdparty/mt19937ar/mt19937ar.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - A C-program for MT19937, with initialization improved 2002/1/26. - Coded by Takuji Nishimura and Makoto Matsumoto. - - Before using, initialize the state by using init_genrand(seed) - or init_by_array(init_key, key_length). - - Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, - All rights reserved. - Copyright (C) 2005, Mutsuo Saito, - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The names of its contributors may not be used to endorse or promote - products derived from this software without specific prior written - permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - Any feedback is very welcome. - http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html - email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space) -*/ - -#include -#include "mt19937ar.h" - -/* Period parameters */ -#define N 624 -#define M 397 -#define MATRIX_A 0x9908b0dfUL /* constant vector a */ -#define UPPER_MASK 0x80000000UL /* most significant w-r bits */ -#define LOWER_MASK 0x7fffffffUL /* least significant r bits */ - -static unsigned long mt[N]; /* the array for the state vector */ -static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */ - -/* initializes mt[N] with a seed */ -void init_genrand(unsigned long s) -{ - mt[0]= s & 0xffffffffUL; - for (mti=1; mti> 30)) + mti); - /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ - /* In the previous versions, MSBs of the seed affect */ - /* only MSBs of the array mt[]. */ - /* 2002/01/09 modified by Makoto Matsumoto */ - mt[mti] &= 0xffffffffUL; - /* for >32 bit machines */ - } -} - -/* initialize by an array with array-length */ -/* init_key is the array for initializing keys */ -/* key_length is its length */ -/* slight change for C++, 2004/2/26 */ -void init_by_array(unsigned long init_key[], int key_length) -{ - int i, j, k; - init_genrand(19650218UL); - i=1; j=0; - k = (N>key_length ? N : key_length); - for (; k; k--) { - mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL)) - + init_key[j] + j; /* non linear */ - mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ - i++; j++; - if (i>=N) { mt[0] = mt[N-1]; i=1; } - if (j>=key_length) j=0; - } - for (k=N-1; k; k--) { - mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL)) - - i; /* non linear */ - mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ - i++; - if (i>=N) { mt[0] = mt[N-1]; i=1; } - } - - mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ -} - -/* generates a random number on [0,0xffffffff]-interval */ -unsigned long genrand_int32(void) -{ - unsigned long y; - static unsigned long mag01[2]={0x0UL, MATRIX_A}; - /* mag01[x] = x * MATRIX_A for x=0,1 */ - - if (mti >= N) { /* generate N words at one time */ - int kk; - - if (mti == N+1) /* if init_genrand() has not been called, */ - init_genrand(5489UL); /* a default initial seed is used */ - - for (kk=0;kk> 1) ^ mag01[y & 0x1UL]; - } - for (;kk> 1) ^ mag01[y & 0x1UL]; - } - y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL]; - - mti = 0; - } - - y = mt[mti++]; - - /* Tempering */ - y ^= (y >> 11); - y ^= (y << 7) & 0x9d2c5680UL; - y ^= (y << 15) & 0xefc60000UL; - y ^= (y >> 18); - - return y; -} - -/* generates a random number on [0,0x7fffffff]-interval */ -long genrand_int31(void) -{ - return (long)(genrand_int32()>>1); -} - -/* generates a random number on [0,1]-real-interval */ -double genrand_real1(void) -{ - return genrand_int32()*(1.0/4294967295.0); - /* divided by 2^32-1 */ -} - -/* generates a random number on [0,1)-real-interval */ -double genrand_real2(void) -{ - return genrand_int32()*(1.0/4294967296.0); - /* divided by 2^32 */ -} - -/* generates a random number on (0,1)-real-interval */ -double genrand_real3(void) -{ - return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0); - /* divided by 2^32 */ -} - -/* generates a random number on [0,1) with 53-bit resolution*/ -double genrand_res53(void) -{ - unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6; - return(a*67108864.0+b)*(1.0/9007199254740992.0); -} -/* These real versions are due to Isaku Wada, 2002/01/09 added */ diff --git a/3rdparty/mt19937ar/mt19937ar.h b/3rdparty/mt19937ar/mt19937ar.h deleted file mode 100644 index 1cc2f8d2f1..0000000000 --- a/3rdparty/mt19937ar/mt19937ar.h +++ /dev/null @@ -1,82 +0,0 @@ -#pragma once - -/* - A C-program for MT19937, with initialization improved 2002/1/26. - Coded by Takuji Nishimura and Makoto Matsumoto. - - Before using, initialize the state by using init_genrand(seed) - or init_by_array(init_key, key_length). - - Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, - All rights reserved. - Copyright (C) 2005, Mutsuo Saito - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The names of its contributors may not be used to endorse or promote - products derived from this software without specific prior written - permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - Any feedback is very welcome. - http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html - email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space) -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/* initializes mt[N] with a seed */ -void init_genrand(unsigned long s); - -/* initialize by an array with array-length */ -/* init_key is the array for initializing keys */ -/* key_length is its length */ -/* slight change for C++, 2004/2/26 */ -void init_by_array(unsigned long init_key[], int key_length); - -/* generates a random number on [0,0xffffffff]-interval */ -unsigned long genrand_int32(void); - -/* generates a random number on [0,0x7fffffff]-interval */ -long genrand_int31(void); - -/* These real versions are due to Isaku Wada, 2002/01/09 added */ -/* generates a random number on [0,1]-real-interval */ -double genrand_real1(void); - -/* generates a random number on [0,1)-real-interval */ -double genrand_real2(void); - -/* generates a random number on (0,1)-real-interval */ -double genrand_real3(void); - -/* generates a random number on [0,1) with 53-bit resolution*/ -double genrand_res53(void); - -#ifdef __cplusplus -} -#endif diff --git a/3rdparty/mt19937ar/mt19937ar.out b/3rdparty/mt19937ar/mt19937ar.out deleted file mode 100644 index 47abd073e3..0000000000 --- a/3rdparty/mt19937ar/mt19937ar.out +++ /dev/null @@ -1,403 +0,0 @@ -1000 outputs of genrand_int32() -1067595299 955945823 477289528 4107218783 4228976476 -3344332714 3355579695 227628506 810200273 2591290167 -2560260675 3242736208 646746669 1479517882 4245472273 -1143372638 3863670494 3221021970 1773610557 1138697238 -1421897700 1269916527 2859934041 1764463362 3874892047 -3965319921 72549643 2383988930 2600218693 3237492380 -2792901476 725331109 605841842 271258942 715137098 -3297999536 1322965544 4229579109 1395091102 3735697720 -2101727825 3730287744 2950434330 1661921839 2895579582 -2370511479 1004092106 2247096681 2111242379 3237345263 -4082424759 219785033 2454039889 3709582971 835606218 -2411949883 2735205030 756421180 2175209704 1873865952 -2762534237 4161807854 3351099340 181129879 3269891896 - 776029799 2218161979 3001745796 1866825872 2133627728 - 34862734 1191934573 3102311354 2916517763 1012402762 -2184831317 4257399449 2899497138 3818095062 3030756734 -1282161629 420003642 2326421477 2741455717 1278020671 -3744179621 271777016 2626330018 2560563991 3055977700 -4233527566 1228397661 3595579322 1077915006 2395931898 -1851927286 3013683506 1999971931 3006888962 1049781534 -1488758959 3491776230 104418065 2448267297 3075614115 -3872332600 891912190 3936547759 2269180963 2633455084 -1047636807 2604612377 2709305729 1952216715 207593580 -2849898034 670771757 2210471108 467711165 263046873 -3569667915 1042291111 3863517079 1464270005 2758321352 -3790799816 2301278724 3106281430 7974801 2792461636 - 555991332 621766759 1322453093 853629228 686962251 -1455120532 957753161 1802033300 1021534190 3486047311 -1902128914 3701138056 4176424663 1795608698 560858864 -3737752754 3141170998 1553553385 3367807274 711546358 -2475125503 262969859 251416325 2980076994 1806565895 - 969527843 3529327173 2736343040 2987196734 1649016367 -2206175811 3048174801 3662503553 3138851612 2660143804 -1663017612 1816683231 411916003 3887461314 2347044079 -1015311755 1203592432 2170947766 2569420716 813872093 -1105387678 1431142475 220570551 4243632715 4179591855 -2607469131 3090613241 282341803 1734241730 1391822177 -1001254810 827927915 1886687171 3935097347 2631788714 -3905163266 110554195 2447955646 3717202975 3304793075 -3739614479 3059127468 953919171 2590123714 1132511021 -3795593679 2788030429 982155079 3472349556 859942552 -2681007391 2299624053 647443547 233600422 608168955 -3689327453 1849778220 1608438222 3968158357 2692977776 -2851872572 246750393 3582818628 3329652309 4036366910 -1012970930 950780808 3959768744 2538550045 191422718 -2658142375 3276369011 2927737484 1234200027 1920815603 -3536074689 1535612501 2184142071 3276955054 428488088 -2378411984 4059769550 3913744741 2732139246 64369859 -3755670074 842839565 2819894466 2414718973 1010060670 -1839715346 2410311136 152774329 3485009480 4102101512 -2852724304 879944024 1785007662 2748284463 1354768064 -3267784736 2269127717 3001240761 3179796763 895723219 - 865924942 4291570937 89355264 1471026971 4114180745 -3201939751 2867476999 2460866060 3603874571 2238880432 -3308416168 2072246611 2755653839 3773737248 1709066580 -4282731467 2746170170 2832568330 433439009 3175778732 - 26248366 2551382801 183214346 3893339516 1928168445 -1337157619 3429096554 3275170900 1782047316 4264403756 -1876594403 4289659572 3223834894 1728705513 4068244734 -2867840287 1147798696 302879820 1730407747 1923824407 -1180597908 1569786639 198796327 560793173 2107345620 -2705990316 3448772106 3678374155 758635715 884524671 - 486356516 1774865603 3881226226 2635213607 1181121587 -1508809820 3178988241 1594193633 1235154121 326117244 -2304031425 937054774 2687415945 3192389340 2003740439 -1823766188 2759543402 10067710 1533252662 4132494984 - 82378136 420615890 3467563163 541562091 3535949864 -2277319197 3330822853 3215654174 4113831979 4204996991 -2162248333 3255093522 2219088909 2978279037 255818579 -2859348628 3097280311 2569721123 1861951120 2907080079 -2719467166 998319094 2521935127 2404125338 259456032 -2086860995 1839848496 1893547357 2527997525 1489393124 -2860855349 76448234 2264934035 744914583 2586791259 -1385380501 66529922 1819103258 1899300332 2098173828 -1793831094 276463159 360132945 4178212058 595015228 - 177071838 2800080290 1573557746 1548998935 378454223 -1460534296 1116274283 3112385063 3709761796 827999348 -3580042847 1913901014 614021289 4278528023 1905177404 - 45407939 3298183234 1184848810 3644926330 3923635459 -1627046213 3677876759 969772772 1160524753 1522441192 - 452369933 1527502551 832490847 1003299676 1071381111 -2891255476 973747308 4086897108 1847554542 3895651598 -2227820339 1621250941 2881344691 3583565821 3510404498 - 849362119 862871471 797858058 2867774932 2821282612 -3272403146 3997979905 209178708 1805135652 6783381 -2823361423 792580494 4263749770 776439581 3798193823 -2853444094 2729507474 1071873341 1329010206 1289336450 -3327680758 2011491779 80157208 922428856 1158943220 -1667230961 2461022820 2608845159 387516115 3345351910 -1495629111 4098154157 3156649613 3525698599 4134908037 - 446713264 2137537399 3617403512 813966752 1157943946 -3734692965 1680301658 3180398473 3509854711 2228114612 -1008102291 486805123 863791847 3189125290 1050308116 -3777341526 4291726501 844061465 1347461791 2826481581 - 745465012 2055805750 4260209475 2386693097 2980646741 - 447229436 2077782664 1232942813 4023002732 1399011509 -3140569849 2579909222 3794857471 900758066 2887199683 -1720257997 3367494931 2668921229 955539029 3818726432 -1105704962 3889207255 2277369307 2746484505 1761846513 -2413916784 2685127085 4240257943 1166726899 4215215715 -3082092067 3960461946 1663304043 2087473241 4162589986 -2507310778 1579665506 767234210 970676017 492207530 -1441679602 1314785090 3262202570 3417091742 1561989210 -3011406780 1146609202 3262321040 1374872171 1634688712 -1280458888 2230023982 419323804 3262899800 39783310 -1641619040 1700368658 2207946628 2571300939 2424079766 - 780290914 2715195096 3390957695 163151474 2309534542 -1860018424 555755123 280320104 1604831083 2713022383 -1728987441 3639955502 623065489 3828630947 4275479050 -3516347383 2343951195 2430677756 635534992 3868699749 - 808442435 3070644069 4282166003 2093181383 2023555632 -1568662086 3422372620 4134522350 3016979543 3259320234 -2888030729 3185253876 4258779643 1267304371 1022517473 - 815943045 929020012 2995251018 3371283296 3608029049 -2018485115 122123397 2810669150 1411365618 1238391329 -1186786476 3155969091 2242941310 1765554882 279121160 -4279838515 1641578514 3796324015 13351065 103516986 -1609694427 551411743 2493771609 1316337047 3932650856 -4189700203 463397996 2937735066 1855616529 2626847990 - 55091862 3823351211 753448970 4045045500 1274127772 -1124182256 92039808 2126345552 425973257 386287896 -2589870191 1987762798 4084826973 2172456685 3366583455 -3602966653 2378803535 2901764433 3716929006 3710159000 -2653449155 3469742630 3096444476 3932564653 2595257433 - 318974657 3146202484 853571438 144400272 3768408841 - 782634401 2161109003 570039522 1886241521 14249488 -2230804228 1604941699 3928713335 3921942509 2155806892 - 134366254 430507376 1924011722 276713377 196481886 -3614810992 1610021185 1785757066 851346168 3761148643 -2918835642 3364422385 3012284466 3735958851 2643153892 -3778608231 1164289832 205853021 2876112231 3503398282 -3078397001 3472037921 1748894853 2740861475 316056182 -1660426908 168885906 956005527 3984354789 566521563 -1001109523 1216710575 2952284757 3834433081 3842608301 -2467352408 3974441264 3256601745 1409353924 1329904859 -2307560293 3125217879 3622920184 3832785684 3882365951 -2308537115 2659155028 1450441945 3532257603 3186324194 -1225603425 1124246549 175808705 3009142319 2796710159 -3651990107 160762750 1902254979 1698648476 1134980669 - 497144426 3302689335 4057485630 3603530763 4087252587 - 427812652 286876201 823134128 1627554964 3745564327 -2589226092 4202024494 62878473 3275585894 3987124064 -2791777159 1916869511 2585861905 1375038919 1403421920 - 60249114 3811870450 3021498009 2612993202 528933105 -2757361321 3341402964 2621861700 273128190 4015252178 -3094781002 1621621288 2337611177 1796718448 1258965619 -4241913140 2138560392 3022190223 4174180924 450094611 -3274724580 617150026 2704660665 1469700689 1341616587 - 356715071 1188789960 2278869135 1766569160 2795896635 - 57824704 2893496380 1235723989 1630694347 3927960522 - 428891364 1814070806 2287999787 4125941184 3968103889 -3548724050 1025597707 1404281500 2002212197 92429143 -2313943944 2403086080 3006180634 3561981764 1671860914 -1768520622 1803542985 844848113 3006139921 1410888995 -1157749833 2125704913 1789979528 1799263423 741157179 -2405862309 767040434 2655241390 3663420179 2172009096 -2511931187 1680542666 231857466 1154981000 157168255 -1454112128 3505872099 1929775046 2309422350 2143329496 -2960716902 407610648 2938108129 2581749599 538837155 -2342628867 430543915 740188568 1937713272 3315215132 -2085587024 4030765687 766054429 3517641839 689721775 -1294158986 1753287754 4202601348 1974852792 33459103 -3568087535 3144677435 1686130825 4134943013 3005738435 -3599293386 426570142 754104406 3660892564 1964545167 - 829466833 821587464 1746693036 1006492428 1595312919 -1256599985 1024482560 1897312280 2902903201 691790057 -1037515867 3176831208 1968401055 2173506824 1089055278 -1748401123 2941380082 968412354 1818753861 2973200866 -3875951774 1119354008 3988604139 1647155589 2232450826 -3486058011 3655784043 3759258462 847163678 1082052057 - 989516446 2871541755 3196311070 3929963078 658187585 -3664944641 2175149170 2203709147 2756014689 2456473919 -3890267390 1293787864 2830347984 3059280931 4158802520 -1561677400 2586570938 783570352 1355506163 31495586 -3789437343 3340549429 2092501630 896419368 671715824 -3530450081 3603554138 1055991716 3442308219 1499434728 -3130288473 3639507000 17769680 2259741420 487032199 -4227143402 3693771256 1880482820 3924810796 381462353 -4017855991 2452034943 2736680833 2209866385 2128986379 - 437874044 595759426 641721026 1636065708 3899136933 - 629879088 3591174506 351984326 2638783544 2348444281 -2341604660 2123933692 143443325 1525942256 364660499 - 599149312 939093251 1523003209 106601097 376589484 -1346282236 1297387043 764598052 3741218111 933457002 -1886424424 3219631016 525405256 3014235619 323149677 -2038881721 4100129043 2851715101 2984028078 1888574695 -2014194741 3515193880 4180573530 3461824363 2641995497 -3179230245 2902294983 2217320456 4040852155 1784656905 -3311906931 87498458 2752971818 2635474297 2831215366 -3682231106 2920043893 3772929704 2816374944 309949752 -2383758854 154870719 385111597 1191604312 1840700563 - 872191186 2925548701 1310412747 2102066999 1504727249 -3574298750 1191230036 3330575266 3180292097 3539347721 - 681369118 3305125752 3648233597 950049240 4173257693 -1760124957 512151405 681175196 580563018 1169662867 -4015033554 2687781101 699691603 2673494188 1137221356 - 123599888 472658308 1053598179 1012713758 3481064843 -3759461013 3981457956 3830587662 1877191791 3650996736 - 988064871 3515461600 4089077232 2225147448 1249609188 -2643151863 3896204135 2416995901 1397735321 3460025646 - -1000 outputs of genrand_real2() -0.76275443 0.99000644 0.98670464 0.10143112 0.27933125 -0.69867227 0.94218740 0.03427201 0.78842173 0.28180608 -0.92179002 0.20785655 0.54534773 0.69644020 0.38107718 -0.23978165 0.65286910 0.07514568 0.22765211 0.94872929 -0.74557914 0.62664415 0.54708246 0.90959343 0.42043116 -0.86334511 0.19189126 0.14718544 0.70259889 0.63426346 -0.77408121 0.04531601 0.04605807 0.88595519 0.69398270 -0.05377184 0.61711170 0.05565708 0.10133577 0.41500776 -0.91810699 0.22320679 0.23353705 0.92871862 0.98897234 -0.19786706 0.80558809 0.06961067 0.55840445 0.90479405 -0.63288060 0.95009721 0.54948447 0.20645042 0.45000959 -0.87050869 0.70806991 0.19406895 0.79286390 0.49332866 -0.78483914 0.75145146 0.12341941 0.42030252 0.16728160 -0.59906494 0.37575460 0.97815160 0.39815952 0.43595080 -0.04952478 0.33917805 0.76509902 0.61034321 0.90654701 -0.92915732 0.85365931 0.18812377 0.65913428 0.28814566 -0.59476081 0.27835931 0.60722542 0.68310435 0.69387186 -0.03699800 0.65897714 0.17527003 0.02889304 0.86777366 -0.12352068 0.91439461 0.32022990 0.44445731 0.34903686 -0.74639273 0.65918367 0.92492794 0.31872642 0.77749724 -0.85413832 0.76385624 0.32744211 0.91326300 0.27458185 -0.22190155 0.19865383 0.31227402 0.85321225 0.84243342 -0.78544200 0.71854080 0.92503892 0.82703064 0.88306297 -0.47284073 0.70059042 0.48003761 0.38671694 0.60465770 -0.41747204 0.47163243 0.72750808 0.65830223 0.10955369 -0.64215401 0.23456345 0.95944940 0.72822249 0.40888451 -0.69980355 0.26677428 0.57333635 0.39791582 0.85377858 -0.76962816 0.72004885 0.90903087 0.51376506 0.37732665 -0.12691640 0.71249738 0.81217908 0.37037313 0.32772374 -0.14238259 0.05614811 0.74363008 0.39773267 0.94859135 -0.31452454 0.11730313 0.62962618 0.33334237 0.45547255 -0.10089665 0.56550662 0.60539371 0.16027624 0.13245301 -0.60959939 0.04671662 0.99356286 0.57660859 0.40269560 -0.45274629 0.06699735 0.85064246 0.87742744 0.54508392 -0.87242982 0.29321385 0.67660627 0.68230715 0.79052073 -0.48592054 0.25186266 0.93769755 0.28565487 0.47219067 -0.99054882 0.13155240 0.47110470 0.98556600 0.84397623 -0.12875246 0.90953202 0.49129015 0.23792727 0.79481194 -0.44337770 0.96564297 0.67749118 0.55684872 0.27286897 -0.79538393 0.61965356 0.22487929 0.02226018 0.49248200 -0.42247006 0.91797788 0.99250134 0.23449967 0.52531508 -0.10246337 0.78685622 0.34310922 0.89892996 0.40454552 -0.68608407 0.30752487 0.83601319 0.54956031 0.63777550 -0.82199797 0.24890696 0.48801123 0.48661910 0.51223987 -0.32969635 0.31075073 0.21393155 0.73453207 0.15565705 -0.58584522 0.28976728 0.97621478 0.61498701 0.23891470 -0.28518540 0.46809591 0.18371914 0.37597910 0.13492176 -0.66849449 0.82811466 0.56240330 0.37548956 0.27562998 -0.27521910 0.74096121 0.77176757 0.13748143 0.99747138 -0.92504502 0.09175241 0.21389176 0.21766512 0.31183245 -0.23271221 0.21207367 0.57903312 0.77523344 0.13242613 -0.31037988 0.01204835 0.71652949 0.84487594 0.14982178 -0.57423142 0.45677888 0.48420169 0.53465428 0.52667473 -0.46880526 0.49849733 0.05670710 0.79022476 0.03872047 -0.21697212 0.20443086 0.28949326 0.81678186 0.87629474 -0.92297064 0.27373097 0.84625273 0.51505586 0.00582792 -0.33295971 0.91848412 0.92537226 0.91760033 0.07541125 -0.71745848 0.61158698 0.00941650 0.03135554 0.71527471 -0.24821915 0.63636652 0.86159918 0.26450229 0.60160194 -0.35557725 0.24477500 0.07186456 0.51757096 0.62120362 -0.97981062 0.69954667 0.21065616 0.13382753 0.27693186 -0.59644095 0.71500764 0.04110751 0.95730081 0.91600724 -0.47704678 0.26183479 0.34706971 0.07545431 0.29398385 -0.93236070 0.60486023 0.48015011 0.08870451 0.45548581 -0.91872718 0.38142712 0.10668643 0.01397541 0.04520355 -0.93822273 0.18011940 0.57577277 0.91427606 0.30911399 -0.95853475 0.23611214 0.69619891 0.69601980 0.76765372 -0.58515930 0.49479057 0.11288752 0.97187699 0.32095365 -0.57563608 0.40760618 0.78703383 0.43261152 0.90877651 -0.84686346 0.10599030 0.72872803 0.19315490 0.66152912 -0.10210518 0.06257876 0.47950688 0.47062066 0.72701157 -0.48915116 0.66110261 0.60170685 0.24516994 0.12726050 -0.03451185 0.90864994 0.83494878 0.94800035 0.91035206 -0.14480751 0.88458997 0.53498312 0.15963215 0.55378627 -0.35171349 0.28719791 0.09097957 0.00667896 0.32309622 -0.87561479 0.42534520 0.91748977 0.73908457 0.41793223 -0.99279792 0.87908370 0.28458072 0.59132853 0.98672190 -0.28547393 0.09452165 0.89910674 0.53681109 0.37931425 -0.62683489 0.56609740 0.24801549 0.52948179 0.98328855 -0.66403523 0.55523786 0.75886666 0.84784685 0.86829981 -0.71448906 0.84670080 0.43922919 0.20771016 0.64157936 -0.25664246 0.73055695 0.86395782 0.65852932 0.99061803 -0.40280575 0.39146298 0.07291005 0.97200603 0.20555729 -0.59616495 0.08138254 0.45796388 0.33681125 0.33989127 -0.18717090 0.53545811 0.60550838 0.86520709 0.34290701 -0.72743276 0.73023855 0.34195926 0.65019733 0.02765254 -0.72575740 0.32709576 0.03420866 0.26061893 0.56997511 -0.28439072 0.84422744 0.77637570 0.55982168 0.06720327 -0.58449067 0.71657369 0.15819609 0.58042821 0.07947911 -0.40193792 0.11376012 0.88762938 0.67532159 0.71223735 -0.27829114 0.04806073 0.21144026 0.58830274 0.04140071 -0.43215628 0.12952729 0.94668759 0.87391019 0.98382450 -0.27750768 0.90849647 0.90962737 0.59269720 0.96102026 -0.49544979 0.32007095 0.62585546 0.03119821 0.85953001 -0.22017528 0.05834068 0.80731217 0.53799961 0.74166948 -0.77426600 0.43938444 0.54862081 0.58575513 0.15886492 -0.73214332 0.11649057 0.77463977 0.85788827 0.17061997 -0.66838056 0.96076133 0.07949296 0.68521946 0.89986254 -0.05667410 0.12741385 0.83470977 0.63969104 0.46612929 -0.10200126 0.01194925 0.10476340 0.90285217 0.31221221 -0.32980614 0.46041971 0.52024973 0.05425470 0.28330912 -0.60426543 0.00598243 0.97244013 0.21135841 0.78561597 -0.78428734 0.63422849 0.32909934 0.44771136 0.27380750 -0.14966697 0.18156268 0.65686758 0.28726350 0.97074787 -0.63676171 0.96649494 0.24526295 0.08297372 0.54257548 -0.03166785 0.33735355 0.15946671 0.02102971 0.46228045 -0.11892296 0.33408336 0.29875681 0.29847692 0.73767569 -0.02080745 0.62980060 0.08082293 0.22993106 0.25031439 -0.87787525 0.45150053 0.13673441 0.63407612 0.97907688 -0.52241942 0.50580158 0.06273902 0.05270283 0.77031811 -0.05113352 0.24393329 0.75036441 0.37436336 0.22877652 -0.59975358 0.85707591 0.88691457 0.85547165 0.36641027 -0.58720133 0.45462835 0.09243817 0.32981586 0.07820411 -0.25421519 0.36004706 0.60092307 0.46192412 0.36758683 -0.98424170 0.08019934 0.68594024 0.45826386 0.29962317 -0.79365413 0.89231296 0.49478547 0.87645944 0.23590734 -0.28106737 0.75026285 0.08136314 0.79582424 0.76010628 -0.82792971 0.27947652 0.72482861 0.82191216 0.46171689 -0.79189752 0.96043686 0.51609668 0.88995725 0.28998963 -0.55191845 0.03934737 0.83033700 0.49553013 0.98009549 -0.19017594 0.98347750 0.33452066 0.87144372 0.72106301 -0.71272114 0.71465963 0.88361677 0.85571283 0.73782329 -0.20920458 0.34855153 0.46766817 0.02780062 0.74898344 -0.03680650 0.44866557 0.77426312 0.91025891 0.25195236 -0.87319953 0.63265037 0.25552148 0.27422476 0.95217406 -0.39281839 0.66441573 0.09158900 0.94515992 0.07800798 -0.02507888 0.39901462 0.17382573 0.12141278 0.85502334 -0.19902911 0.02160210 0.44460522 0.14688742 0.68020336 -0.71323733 0.60922473 0.95400380 0.99611159 0.90897777 -0.41073520 0.66206647 0.32064685 0.62805003 0.50677209 -0.52690101 0.87473387 0.73918362 0.39826974 0.43683919 -0.80459118 0.32422684 0.01958019 0.95319576 0.98326137 -0.83931735 0.69060863 0.33671416 0.68062550 0.65152380 -0.33392969 0.03451730 0.95227244 0.68200635 0.85074171 -0.64721009 0.51234433 0.73402047 0.00969637 0.93835057 -0.80803854 0.31485260 0.20089527 0.01323282 0.59933780 -0.31584602 0.20209563 0.33754800 0.68604181 0.24443049 -0.19952227 0.78162632 0.10336988 0.11360736 0.23536740 -0.23262256 0.67803776 0.48749791 0.74658435 0.92156640 -0.56706407 0.36683221 0.99157136 0.23421374 0.45183767 -0.91609720 0.85573315 0.37706276 0.77042618 0.30891908 -0.40709595 0.06944866 0.61342849 0.88817388 0.58734506 -0.98711323 0.14744128 0.63242656 0.87704136 0.68347125 -0.84446569 0.43265239 0.25146321 0.04130111 0.34259839 -0.92697368 0.40878778 0.56990338 0.76204273 0.19820348 -0.66314909 0.02482844 0.06669207 0.50205581 0.26084093 -0.65139159 0.41650223 0.09733904 0.56344203 0.62651696 -0.67332139 0.58037374 0.47258086 0.21010758 0.05713135 -0.89390629 0.10781246 0.32037450 0.07628388 0.34227964 -0.42190597 0.58201860 0.77363549 0.49595133 0.86031236 -0.83906769 0.81098161 0.26694195 0.14215941 0.88210306 -0.53634237 0.12090720 0.82480459 0.75930318 0.31847147 -0.92768077 0.01037616 0.56201727 0.88107122 0.35925856 -0.85860762 0.61109408 0.70408301 0.58434977 0.92192494 -0.62667915 0.75988365 0.06858761 0.36156496 0.58057195 -0.13636150 0.57719713 0.59340255 0.63530602 0.22976282 -0.71915530 0.41162531 0.63979565 0.09931342 0.79344045 -0.10893790 0.84450224 0.23122236 0.99485593 0.73637397 -0.17276368 0.13357764 0.74965804 0.64991737 0.61990341 -0.41523170 0.05878239 0.05687301 0.05497131 0.42868366 -0.42571090 0.25810502 0.89642955 0.30439758 0.39310223 -0.11357431 0.04288255 0.23397550 0.11200634 0.85621396 -0.89733974 0.37508865 0.42077265 0.68597384 0.72781399 -0.19296476 0.61699087 0.31667128 0.67756410 0.00177323 -0.05725176 0.79474693 0.18885238 0.06724856 0.68193156 -0.42202167 0.22082041 0.28554673 0.64995708 0.87851940 -0.29124547 0.61009521 0.87374537 0.05743712 0.69902994 -0.81925115 0.45653873 0.37236821 0.31118709 0.52734307 -0.39672836 0.38185294 0.30163915 0.17374510 0.04913278 -0.90404879 0.25742801 0.58266467 0.97663209 0.79823377 -0.36437958 0.15206043 0.26529938 0.22690047 0.05839021 -0.84721160 0.18622435 0.37809403 0.55706977 0.49828704 -0.47659049 0.24289680 0.88477595 0.07807463 0.56245739 -0.73490635 0.21099431 0.13164942 0.75840044 0.66877037 -0.28988183 0.44046090 0.24967434 0.80048356 0.26029740 -0.30416821 0.64151867 0.52067892 0.12880774 0.85465381 -0.02690525 0.19149288 0.49630295 0.79682619 0.43566145 -0.00288078 0.81484193 0.03763639 0.68529083 0.01339574 -0.38405386 0.30537067 0.22994703 0.44000045 0.27217985 -0.53831243 0.02870435 0.86282045 0.61831306 0.09164956 -0.25609707 0.07445781 0.72185784 0.90058883 0.30070608 -0.94476583 0.56822213 0.21933909 0.96772793 0.80063440 -0.26307906 0.31183306 0.16501252 0.55436179 0.68562285 -0.23829083 0.86511559 0.57868991 0.81888344 0.20126869 -0.93172350 0.66028129 0.21786948 0.78515828 0.10262106 -0.35390326 0.79303876 0.63427924 0.90479631 0.31024934 -0.60635447 0.56198079 0.63573813 0.91854197 0.99701497 -0.83085849 0.31692291 0.01925964 0.97446405 0.98751283 -0.60944293 0.13751018 0.69519957 0.68956636 0.56969015 -0.46440193 0.88341765 0.36754434 0.89223647 0.39786427 -0.85055280 0.12749961 0.79452122 0.89449784 0.14567830 -0.45716830 0.74822309 0.28200437 0.42546044 0.17464886 -0.68308746 0.65496587 0.52935411 0.12736159 0.61523955 -0.81590528 0.63107864 0.39786553 0.20102294 0.53292914 -0.75485590 0.59847044 0.32861691 0.12125866 0.58917183 -0.07638293 0.86845380 0.29192617 0.03989733 0.52180460 -0.32503407 0.64071852 0.69516575 0.74254998 0.54587026 -0.48713246 0.32920155 0.08719954 0.63497059 0.54328459 -0.64178757 0.45583809 0.70694291 0.85212760 0.86074305 -0.33163422 0.85739792 0.59908488 0.74566046 0.72157152 diff --git a/3rdparty/mt19937ar/mt19937ar.vcxproj b/3rdparty/mt19937ar/mt19937ar.vcxproj deleted file mode 100644 index 3c6090c2d3..0000000000 --- a/3rdparty/mt19937ar/mt19937ar.vcxproj +++ /dev/null @@ -1,158 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - {7AE31676-6137-4FB3-AE9C-AD47D8A861CF} - Win32Proj - mt19937ar - - - - StaticLibrary - true - $(DefaultPlatformToolset) - MultiByte - - - StaticLibrary - true - $(DefaultPlatformToolset) - MultiByte - - - StaticLibrary - false - $(DefaultPlatformToolset) - true - MultiByte - - - StaticLibrary - false - $(DefaultPlatformToolset) - true - MultiByte - - - - - - - - - - - - - - - - - - - $(SolutionDir).vs\build\ - $(SolutionDir).vs\build\$(ProjectName)\$(Platform)\$(Configuration)\ - - - $(SolutionDir).vs\build\ - $(SolutionDir).vs\build\$(ProjectName)\$(Platform)\$(Configuration)\ - - - $(SolutionDir).vs\build\ - $(SolutionDir).vs\build\$(ProjectName)\$(Platform)\$(Configuration)\ - - - $(SolutionDir).vs\build\ - $(SolutionDir).vs\build\$(ProjectName)\$(Platform)\$(Configuration)\ - - - - - - Level3 - Disabled - $(DefineConstants);WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - MultiThreadedDebug - - - Windows - true - - - - - - - Level3 - Disabled - $(DefineConstants);WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - MultiThreadedDebug - - - Windows - true - - - - - Level3 - - - MaxSpeed - true - true - $(DefineConstants);WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - MultiThreaded - - - Windows - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - $(DefineConstants);WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - MultiThreaded - - - Windows - true - true - true - - - - - - diff --git a/3rdparty/mt19937ar/mt19937ar.vcxproj.filters b/3rdparty/mt19937ar/mt19937ar.vcxproj.filters deleted file mode 100644 index a8eea02cbd..0000000000 --- a/3rdparty/mt19937ar/mt19937ar.vcxproj.filters +++ /dev/null @@ -1,23 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - - - Header Files - - - - - Source Files - - - diff --git a/3rdparty/mt19937ar/mtTest.c b/3rdparty/mt19937ar/mtTest.c deleted file mode 100644 index b274068022..0000000000 --- a/3rdparty/mt19937ar/mtTest.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - A C-program for MT19937, with initialization improved 2002/1/26. - Coded by Takuji Nishimura and Makoto Matsumoto. - - Before using, initialize the state by using init_genrand(seed) - or init_by_array(init_key, key_length). - - Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, - All rights reserved. - Copyright (C) 2005, Mutsuo Saito, - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The names of its contributors may not be used to endorse or promote - products derived from this software without specific prior written - permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - Any feedback is very welcome. - http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html - email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space) -*/ - -#include -#include "mt19937ar.h" - -int main(void) -{ - int i; - unsigned long init[4]={0x123, 0x234, 0x345, 0x456}, length=4; - init_by_array(init, length); - printf("1000 outputs of genrand_int32()\n"); - for (i=0; i<1000; i++) { - printf("%10lu ", genrand_int32()); - if (i%5==4) printf("\n"); - } - printf("\n1000 outputs of genrand_real2()\n"); - for (i=0; i<1000; i++) { - printf("%10.8f ", genrand_real2()); - if (i%5==4) printf("\n"); - } - return 0; -} diff --git a/3rdparty/mt19937ar/readme-mt.txt b/3rdparty/mt19937ar/readme-mt.txt deleted file mode 100644 index 2d4c2e8a2d..0000000000 --- a/3rdparty/mt19937ar/readme-mt.txt +++ /dev/null @@ -1,79 +0,0 @@ -This is a Mersenne Twister pseudorandom number generator -with period 2^19937-1 with improved initialization scheme, -modified on 2002/1/26 by Takuji Nishimura and Makoto Matsumoto. -modified on 2005/4/26 by Mutsuo Saito - -Contents of this tar ball: -readme-mt.txt this file -mt19937ar.c the C source (ar: initialize by ARray) -mt19937ar.h the C header file for mt19937ar -mtTest.c the C test main program of mt19937ar.c -mt19937ar.out Test outputs of six types generators. 1000 for each - -1. Initialization - The initialization scheme for the previous versions of MT -(e.g. 1999/10/28 version or earlier) has a tiny problem, that -the most significant bits of the seed is not well reflected -to the state vector of MT. - -This version (2002/1/26) has two initialization schemes: -init_genrand(seed) and init_by_array(init_key, key_length). - -init_genrand(seed) initializes the state vector by using -one unsigned 32-bit integer "seed", which may be zero. - -init_by_array(init_key, key_length) initializes the state vector -by using an array init_key[] of unsigned 32-bit integers -of length key_kength. If key_length is smaller than 624, -then each array of 32-bit integers gives distinct initial -state vector. This is useful if you want a larger seed space -than 32-bit word. - -2. Generation -After initialization, the following type of pseudorandom numbers -are available. - -genrand_int32() generates unsigned 32-bit integers. -genrand_int31() generates unsigned 31-bit integers. -genrand_real1() generates uniform real in [0,1] (32-bit resolution). -genrand_real2() generates uniform real in [0,1) (32-bit resolution). -genrand_real3() generates uniform real in (0,1) (32-bit resolution). -genrand_res53() generates uniform real in [0,1) with 53-bit resolution. - -Note: the last five functions call the first one. -if you need more speed for these five functions, you may -suppress the function call by copying genrand_int32() and -replacing the last return(), following to these five functions. - -3. main() -main() is an example to initialize with an array of length 4, -then 1000 outputs of unsigned 32-bit integers, -then 1000 outputs of real [0,1) numbers. - -4. The outputs -The output of the mt19937ar.c is in the file mt19937ar.out. -If you revise or translate the code, check the output -by using this file. - -5. Cryptography -This generator is not cryptoraphically secure. -You need to use a one-way (or hash) function to obtain -a secure random sequence. - -6. Correspondence -See: -URL http://www.math.keio.ac.jp/matumoto/emt.html -email matumoto@math.keio.ac.jp, nisimura@sci.kj.yamagata-u.ac.jp - -7. Reference -M. Matsumoto and T. Nishimura, -"Mersenne Twister: A 623-Dimensionally Equidistributed Uniform -Pseudo-Random Number Generator", -ACM Transactions on Modeling and Computer Simulation, -Vol. 8, No. 1, January 1998, pp 3--30. - -------- -Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, -All rights reserved. -Copyright (C) 2005, Mutsuo Saito -All rights reserved. diff --git a/Makefile.in b/Makefile.in index 05e4d4e81e..8d58dc9ed5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -5,10 +5,10 @@ OMAP=@OMAP@ ifeq ($(HAVE_MYSQL),yes) ALL_DEPENDS=server tools SERVER_DEPENDS=common login char map import - COMMON_DEPENDS=mt19937ar libconfig yaml-cpp - LOGIN_DEPENDS=mt19937ar libconfig common - CHAR_DEPENDS=mt19937ar libconfig common yaml-cpp - MAP_DEPENDS=mt19937ar libconfig common yaml-cpp + COMMON_DEPENDS=libconfig yaml-cpp + LOGIN_DEPENDS=libconfig common + CHAR_DEPENDS=libconfig common yaml-cpp + MAP_DEPENDS=libconfig common yaml-cpp else ALL_DEPENDS=needs_mysql SERVER_DEPENDS=needs_mysql @@ -22,7 +22,6 @@ endif ##################################################################### .PHONY: all server sql \ common \ - mt19937ar \ login \ char \ map \ @@ -50,9 +49,6 @@ char: $(CHAR_DEPENDS) map: $(MAP_DEPENDS) @$(MAKE) -C src/map server -mt19937ar: - @$(MAKE) -C 3rdparty/mt19937ar - libconfig: @$(MAKE) -C 3rdparty/libconfig @@ -79,7 +75,6 @@ import: clean: @$(MAKE) -C src/common $@ - @$(MAKE) -C 3rdparty/mt19937ar $@ @$(MAKE) -C 3rdparty/libconfig $@ @$(MAKE) -C 3rdparty/yaml-cpp $@ @$(MAKE) -C src/login $@ @@ -91,7 +86,6 @@ help: @echo "most common targets are 'all' 'server' 'conf' 'clean' 'help'" @echo "possible targets are:" @echo "'common' - builds object files used for the three servers" - @echo "'mt19937ar' - builds object file of Mersenne Twister MT19937" @echo "'libconfig' - builds object files of libconfig" @echo "'yaml-cpp' - builds object files of yaml-cpp" @echo "'login' - builds login server" diff --git a/conf/login_athena.conf b/conf/login_athena.conf index ddd5ddd890..969b83bda2 100644 --- a/conf/login_athena.conf +++ b/conf/login_athena.conf @@ -98,7 +98,7 @@ chars_per_account: 0 // Increase the value of MAX_CHARS if you want to increase vip_char_increase. // Note: The amount of VIP characters = MAX_CHARS - chars_per_account. // Note 2: This setting must be set after chars_per_account. -// -1 will default to MAX_CHAR_VIP (src/config/core.h) +// -1 will default to MAX_CHAR_VIP (src/config/core.hpp) vip_char_increase: -1 // Create accounts with limited time? diff --git a/configure b/configure index 672d335780..ff74f6e053 100755 --- a/configure +++ b/configure @@ -584,7 +584,7 @@ PACKAGE_BUGREPORT= PACKAGE_URL= ac_unique_file="rAthena" -ac_unique_file="src/common/cbasetypes.h" +ac_unique_file="src/common/cbasetypes.hpp" # Factoring default headers for most tests. ac_includes_default="\ #include @@ -2736,7 +2736,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_config_files="$ac_config_files Makefile src/common/Makefile" -ac_config_files="$ac_config_files 3rdparty/mt19937ar/Makefile 3rdparty/libconfig/Makefile 3rdparty/yaml-cpp/Makefile" +ac_config_files="$ac_config_files 3rdparty/libconfig/Makefile 3rdparty/yaml-cpp/Makefile" ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile" @@ -7749,7 +7749,6 @@ do case $ac_config_target in "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/common/Makefile") CONFIG_FILES="$CONFIG_FILES src/common/Makefile" ;; - "3rdparty/mt19937ar/Makefile") CONFIG_FILES="$CONFIG_FILES 3rdparty/mt19937ar/Makefile" ;; "3rdparty/libconfig/Makefile") CONFIG_FILES="$CONFIG_FILES 3rdparty/libconfig/Makefile" ;; "3rdparty/yaml-cpp/Makefile") CONFIG_FILES="$CONFIG_FILES 3rdparty/yaml-cpp/Makefile" ;; "src/char/Makefile") CONFIG_FILES="$CONFIG_FILES src/char/Makefile" ;; diff --git a/configure.in b/configure.in index 2715af8578..5220e46ef6 100644 --- a/configure.in +++ b/configure.in @@ -6,9 +6,9 @@ AC_REVISION($Revision$) AC_PREREQ([2.59]) AC_LANG([C++]) AC_LANG_COMPILER_REQUIRE -AC_CONFIG_SRCDIR([src/common/cbasetypes.h]) +AC_CONFIG_SRCDIR([src/common/cbasetypes.hpp]) AC_CONFIG_FILES([Makefile src/common/Makefile]) -AC_CONFIG_FILES([3rdparty/mt19937ar/Makefile 3rdparty/libconfig/Makefile 3rdparty/yaml-cpp/Makefile]) +AC_CONFIG_FILES([3rdparty/libconfig/Makefile 3rdparty/yaml-cpp/Makefile]) AC_CONFIG_FILES([src/char/Makefile src/login/Makefile]) AC_CONFIG_FILES([src/map/Makefile src/tool/Makefile]) diff --git a/doc/mapflags.txt b/doc/mapflags.txt index afb174b260..9606c33504 100644 --- a/doc/mapflags.txt +++ b/doc/mapflags.txt @@ -320,7 +320,7 @@ This mapflag can also be used to adjust the damage of one skill by a percentage: 4 = against other (homunculus, mercenary, pet, elemental) Notes: - - You MUST enable ADJUST_SKILL_DAMAGE in 'src/config/core.h' for this mapflag to take effect. + - You MUST enable ADJUST_SKILL_DAMAGE in 'src/config/core.hpp' for this mapflag to take effect. - Each map can contain up to 5 adjustments (MAX_MAP_SKILL_MODIFIER in 'src/map/map.h'). --------------------------------------- diff --git a/doc/source_doc.txt b/doc/source_doc.txt index 1dbbda454d..d940041aa6 100644 --- a/doc/source_doc.txt +++ b/doc/source_doc.txt @@ -180,7 +180,6 @@ The following list describes each module and its purpose. Module Description ------ ----------- - atomic adapter to atomic operations for Windows API cbasetypes adapter to OS and arch specification (function name, bit representation) cli console Line Interface handling (get arguments from terminal at beginning and runtime) conf facade of libconfig api @@ -188,26 +187,18 @@ The following list describes each module and its purpose. db database module (create, parse, and destroy databases) des Data Encryption Standard algorithm modified for rAthena ers Entry Reusage System to help memory allocation - evdp handles events grfio handles *.grf files (searches for files in them and decodes them) malloc handles runtime memory allocation (so that memory manager could check for leaks) mapindex handles the processing and reading of the mapcache.dat md5calc offers md5 encryption - mempool handles shared memory pool for thread support mmo.h common structures and defines across serv msg_conf handles msg in src from configuration - mutex handles Mutual exclusion (Mutex) for thread support - netbuffer iobuffer initialisation for thread support - network updated socket module, with ipv6 and thread support nullpo checks and dumps info for debug mode - raconf processes the conf files random generation of random numbers showmsg display messages in console with a certain color socket handling of sockets (listening, close, open, etc.) - spinlock handles synchronization (waiting loop) for thread support sql.c MySQL database proxy strlib.c string handling - thread.c thread creation and destruction timer.c timer-related functions utils.c misc functions winapi.h Windows redefine and include diff --git a/npc/mapflag/skill_damage.txt b/npc/mapflag/skill_damage.txt index 143d713a77..d27f3fa00a 100644 --- a/npc/mapflag/skill_damage.txt +++ b/npc/mapflag/skill_damage.txt @@ -12,7 +12,7 @@ //= See the mapflag documentation for details about extra //= parameters. //= -//= You MUST enable ADJUST_SKILL_DAMAGE in 'src/config/core.h' +//= You MUST enable ADJUST_SKILL_DAMAGE in 'src/config/core.hpp' //= for this mapflag to take effect. //===== Additional Comments: ================================= //= 1.0 Initial script. [Cydh] diff --git a/rAthena.sln b/rAthena.sln index e8e96ac290..d90c563a39 100644 --- a/rAthena.sln +++ b/rAthena.sln @@ -8,27 +8,24 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "src\common\common.vcxproj", "{F8FD7B1E-8E1C-4CC3-9CD1-2E28F77B6559}" ProjectSection(ProjectDependencies) = postProject {F6CC5F60-BD13-41B1-81D3-822A45EC0DBD} = {F6CC5F60-BD13-41B1-81D3-822A45EC0DBD} - {7AE31676-6137-4FB3-AE9C-AD47D8A861CF} = {7AE31676-6137-4FB3-AE9C-AD47D8A861CF} {61D6A599-6BED-4154-A9FC-40553BD972E0} = {61D6A599-6BED-4154-A9FC-40553BD972E0} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libconfig", "3rdparty\libconfig\libconfig.vcxproj", "{F6CC5F60-BD13-41B1-81D3-822A45EC0DBD}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mt19937ar", "3rdparty\mt19937ar\mt19937ar.vcxproj", "{7AE31676-6137-4FB3-AE9C-AD47D8A861CF}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{60D3315D-FBF4-4FBF-8D44-99D5BED11D32}" ProjectSection(SolutionItems) = preProject - src\config\const.h = src\config\const.h - src\config\core.h = src\config\core.h - src\config\classes\general.h = src\config\classes\general.h - src\config\packets.h = src\config\packets.h - src\config\renewal.h = src\config\renewal.h - src\config\secure.h = src\config\secure.h + src\config\const.hpp = src\config\const.hpp + src\config\core.hpp = src\config\core.hpp + src\config\classes\general.hpp = src\config\classes\general.hpp + src\config\packets.hpp = src\config\packets.hpp + src\config\renewal.hpp = src\config\renewal.hpp + src\config\secure.hpp = src\config\secure.hpp EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "classes", "classes", "{33B49CB8-CBE3-4ED2-86DD-C9A351AC9026}" ProjectSection(SolutionItems) = preProject - src\config\classes\general.h = src\config\classes\general.h + src\config\classes\general.hpp = src\config\classes\general.hpp EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Custom", "Custom", "{6513C8D3-D15F-45D4-9AD8-6286CBA7EE36}" @@ -37,8 +34,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Custom", "Custom", "{6513C8 src\custom\atcommand_def.inc = src\custom\atcommand_def.inc src\custom\battle_config_init.inc = src\custom\battle_config_init.inc src\custom\battle_config_struct.inc = src\custom\battle_config_struct.inc - src\custom\defines_post.h = src\custom\defines_post.h - src\custom\defines_pre.h = src\custom\defines_pre.h + src\custom\defines_post.hpp = src\custom\defines_post.hpp + src\custom\defines_pre.hpp = src\custom\defines_pre.hpp src\custom\script.inc = src\custom\script.inc src\custom\script_def.inc = src\custom\script_def.inc EndProjectSection @@ -74,11 +71,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mapcache", "src\tool\mapcac EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yaml-cpp", "3rdparty\yaml-cpp\yaml-cpp.vcxproj", "{61D6A599-6BED-4154-A9FC-40553BD972E0}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic_test", "src\test\basic_test.vcxproj", "{99B4DF6A-6180-4E7F-9227-F812FF30414A}" - ProjectSection(ProjectDependencies) = postProject - {F8FD7B1E-8E1C-4CC3-9CD1-2E28F77B6559} = {F8FD7B1E-8E1C-4CC3-9CD1-2E28F77B6559} - EndProjectSection -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -103,14 +95,6 @@ Global {F6CC5F60-BD13-41B1-81D3-822A45EC0DBD}.Release|Win32.Build.0 = Release|Win32 {F6CC5F60-BD13-41B1-81D3-822A45EC0DBD}.Release|x64.ActiveCfg = Release|x64 {F6CC5F60-BD13-41B1-81D3-822A45EC0DBD}.Release|x64.Build.0 = Release|x64 - {7AE31676-6137-4FB3-AE9C-AD47D8A861CF}.Debug|Win32.ActiveCfg = Debug|Win32 - {7AE31676-6137-4FB3-AE9C-AD47D8A861CF}.Debug|Win32.Build.0 = Debug|Win32 - {7AE31676-6137-4FB3-AE9C-AD47D8A861CF}.Debug|x64.ActiveCfg = Debug|x64 - {7AE31676-6137-4FB3-AE9C-AD47D8A861CF}.Debug|x64.Build.0 = Debug|x64 - {7AE31676-6137-4FB3-AE9C-AD47D8A861CF}.Release|Win32.ActiveCfg = Release|Win32 - {7AE31676-6137-4FB3-AE9C-AD47D8A861CF}.Release|Win32.Build.0 = Release|Win32 - {7AE31676-6137-4FB3-AE9C-AD47D8A861CF}.Release|x64.ActiveCfg = Release|x64 - {7AE31676-6137-4FB3-AE9C-AD47D8A861CF}.Release|x64.Build.0 = Release|x64 {864805EA-FD39-453D-9248-C581951BA058}.Debug|Win32.ActiveCfg = Debug|Win32 {864805EA-FD39-453D-9248-C581951BA058}.Debug|Win32.Build.0 = Debug|Win32 {864805EA-FD39-453D-9248-C581951BA058}.Debug|x64.ActiveCfg = Debug|x64 @@ -159,14 +143,6 @@ Global {61D6A599-6BED-4154-A9FC-40553BD972E0}.Release|Win32.Build.0 = Release|Win32 {61D6A599-6BED-4154-A9FC-40553BD972E0}.Release|x64.ActiveCfg = Release|x64 {61D6A599-6BED-4154-A9FC-40553BD972E0}.Release|x64.Build.0 = Release|x64 - {99B4DF6A-6180-4E7F-9227-F812FF30414A}.Debug|Win32.ActiveCfg = Debug|Win32 - {99B4DF6A-6180-4E7F-9227-F812FF30414A}.Debug|Win32.Build.0 = Debug|Win32 - {99B4DF6A-6180-4E7F-9227-F812FF30414A}.Debug|x64.ActiveCfg = Debug|x64 - {99B4DF6A-6180-4E7F-9227-F812FF30414A}.Debug|x64.Build.0 = Debug|x64 - {99B4DF6A-6180-4E7F-9227-F812FF30414A}.Release|Win32.ActiveCfg = Release|Win32 - {99B4DF6A-6180-4E7F-9227-F812FF30414A}.Release|Win32.Build.0 = Release|Win32 - {99B4DF6A-6180-4E7F-9227-F812FF30414A}.Release|x64.ActiveCfg = Release|x64 - {99B4DF6A-6180-4E7F-9227-F812FF30414A}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -174,7 +150,6 @@ Global GlobalSection(NestedProjects) = preSolution {F8FD7B1E-8E1C-4CC3-9CD1-2E28F77B6559} = {C0A6FC9A-3A5C-48F8-A4B6-8D463C61C021} {F6CC5F60-BD13-41B1-81D3-822A45EC0DBD} = {6ABA1767-6242-4CA0-BA22-A30972DC8918} - {7AE31676-6137-4FB3-AE9C-AD47D8A861CF} = {6ABA1767-6242-4CA0-BA22-A30972DC8918} {33B49CB8-CBE3-4ED2-86DD-C9A351AC9026} = {60D3315D-FBF4-4FBF-8D44-99D5BED11D32} {864805EA-FD39-453D-9248-C581951BA058} = {6D9F5D00-2988-4812-844D-D155C4F588DC} {FED3A941-0AF7-49FE-85CF-E1DFDC0EBB23} = {6D9F5D00-2988-4812-844D-D155C4F588DC} @@ -182,7 +157,6 @@ Global {352B45B3-FE88-4431-9D89-48CF811446DB} = {C0A6FC9A-3A5C-48F8-A4B6-8D463C61C021} {FC4C071B-2C26-4B03-948A-335C94A88B5E} = {9F328FE9-129D-4C0C-820B-BE4AA5996652} {61D6A599-6BED-4154-A9FC-40553BD972E0} = {6ABA1767-6242-4CA0-BA22-A30972DC8918} - {99B4DF6A-6180-4E7F-9227-F812FF30414A} = {9F328FE9-129D-4C0C-820B-BE4AA5996652} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {026DA20F-820C-40AA-983E-0E231EA90AD5} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index be74eab3f1..f5b6d81ca4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,6 +16,5 @@ endif() add_subdirectory( login ) add_subdirectory( char ) add_subdirectory( map ) -add_subdirectory( test ) add_subdirectory( tool ) diff --git a/src/char/Makefile.in b/src/char/Makefile.in index 3fddf5ee15..2c91178cb3 100644 --- a/src/char/Makefile.in +++ b/src/char/Makefile.in @@ -1,18 +1,14 @@ -COMMON_H = $(shell ls ../common/*.h) +COMMON_H = $(shell ls ../common/*.hpp) COMMON_AR = ../common/obj/common.a COMMON_INCLUDE = -I../common/ -MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o -MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h -MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar - LIBCONFIG_H = $(shell ls ../../3rdparty/libconfig/*.h) LIBCONFIG_AR = ../../3rdparty/libconfig/obj/libconfig.a LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig COMMON_OBJ = ../common/obj/sql.o -COMMON_H = ../common/sql.h +COMMON_H = ../common/sql.hpp CHAR_OBJ = $(shell ls *.cpp | sed -e "s/\.cpp/\.o/g") CHAR_DIR_OBJ = $(CHAR_OBJ:%=obj/%) @@ -57,7 +53,7 @@ help: char-server: obj $(CHAR_DIR_OBJ) $(LIBCONFIG_AR) $(COMMON_AR) $(YAML_CPP_AR) @echo " LD @OCHR@@EXEEXT@" - @@CXX@ @LDFLAGS@ -o ../../@OCHR@@EXEEXT@ $(CHAR_DIR_OBJ) $(LIBCONFIG_AR) $(COMMON_AR) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) $(YAML_CPP_AR) @LIBS@ @MYSQL_LIBS@ + @@CXX@ @LDFLAGS@ -o ../../@OCHR@@EXEEXT@ $(CHAR_DIR_OBJ) $(LIBCONFIG_AR) $(COMMON_AR) $(LIBCONFIG_OBJ) $(YAML_CPP_AR) @LIBS@ @MYSQL_LIBS@ needs_mysql: @echo "MySQL not found or disabled by the configure script" @@ -66,22 +62,15 @@ needs_mysql: obj: @echo " MKDIR obj" @-mkdir obj - -obj/%.o: %.c $(CHAR_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) $(YAML_CPP_H) - @echo " CC $<" - @@CC@ @CFLAGS@ $(COMMON_INCLUDE) $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -obj/%.o: %.cpp $(CHAR_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) $(YAML_CPP_H) +obj/%.o: %.cpp $(CHAR_H) $(COMMON_H) $(LIBCONFIG_H) $(YAML_CPP_H) @echo " CXX $<" - @@CXX@ @CXXFLAGS@ $(COMMON_INCLUDE) $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @@CXX@ @CXXFLAGS@ $(COMMON_INCLUDE) $(LIBCONFIG_INCLUDE) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files $(COMMON_AR): @$(MAKE) -C ../common server -$(MT19937AR_OBJ): - @$(MAKE) -C ../../3rdparty/mt19937ar - $(LIBCONFIG_AR): @$(MAKE) -C ../../3rdparty/libconfig diff --git a/src/char/char-server.vcxproj b/src/char/char-server.vcxproj index 61f157ee4b..26774d09a7 100644 --- a/src/char/char-server.vcxproj +++ b/src/char/char-server.vcxproj @@ -99,7 +99,7 @@ Console true - ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir).vs\build\mt19937ar.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) + ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) @@ -115,7 +115,7 @@ Console true - ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir).vs\build\mt19937ar.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) + ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) @@ -135,7 +135,7 @@ true true true - ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir).vs\build\mt19937ar.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) + ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) @@ -155,7 +155,7 @@ true true true - ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir).vs\build\mt19937ar.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) + ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) diff --git a/src/char/char.cpp b/src/char/char.cpp index 407e07bb70..c5059f490e 100644 --- a/src/char/char.cpp +++ b/src/char/char.cpp @@ -10,18 +10,18 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/core.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/mapindex.h" -#include "../common/mmo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/cli.h" +#include "../common/cbasetypes.hpp" +#include "../common/core.hpp" +#include "../common/db.hpp" +#include "../common/malloc.hpp" +#include "../common/mapindex.hpp" +#include "../common/mmo.hpp" +#include "../common/random.hpp" +#include "../common/showmsg.hpp" +#include "../common/socket.hpp" +#include "../common/strlib.hpp" +#include "../common/timer.hpp" +#include "../common/cli.hpp" #include "int_guild.hpp" #include "int_homun.hpp" @@ -2737,7 +2737,7 @@ void char_set_defaults(){ charserv_config.log_inter = 1; // loggin inter or not [devil] charserv_config.char_check_db =1; - // See const.h to change the default values + // See const.hpp to change the default values charserv_config.start_point[0].map = mapindex_name2id(MAP_DEFAULT_NAME); charserv_config.start_point[0].x = MAP_DEFAULT_X; charserv_config.start_point[0].y = MAP_DEFAULT_Y; diff --git a/src/char/char.hpp b/src/char/char.hpp index ab76e89eb5..9243798bf6 100644 --- a/src/char/char.hpp +++ b/src/char/char.hpp @@ -4,10 +4,10 @@ #ifndef _CHAR_HPP_ #define _CHAR_HPP_ -#include "../config/core.h" -#include "../common/core.h" // CORE_ST_LAST -#include "../common/msg_conf.h" -#include "../common/mmo.h" +#include "../config/core.hpp" +#include "../common/core.hpp" // CORE_ST_LAST +#include "../common/msg_conf.hpp" +#include "../common/mmo.hpp" extern int login_fd; //login file descriptor extern int char_fd; //char file descriptor diff --git a/src/char/char_clif.cpp b/src/char/char_clif.cpp index 19bf1cf867..8353f4f050 100644 --- a/src/char/char_clif.cpp +++ b/src/char/char_clif.cpp @@ -6,16 +6,16 @@ #include #include -#include "../common/mmo.h" -#include "../common/socket.h" -#include "../common/sql.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/mapindex.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/timer.h" +#include "../common/mmo.hpp" +#include "../common/socket.hpp" +#include "../common/sql.hpp" +#include "../common/random.hpp" +#include "../common/showmsg.hpp" +#include "../common/mapindex.hpp" +#include "../common/malloc.hpp" +#include "../common/strlib.hpp" +#include "../common/utils.hpp" +#include "../common/timer.hpp" #include "inter.hpp" #include "char.hpp" #include "char_logif.hpp" diff --git a/src/char/char_clif.hpp b/src/char/char_clif.hpp index 0bd4f32086..13c7cf9e1d 100644 --- a/src/char/char_clif.hpp +++ b/src/char/char_clif.hpp @@ -4,8 +4,8 @@ #ifndef _CHAR_CLIF_HPP_ #define _CHAR_CLIF_HPP_ -#include "../common/cbasetypes.h" -#include "../common/timer.h" //time_t +#include "../common/cbasetypes.hpp" +#include "../common/timer.hpp" //time_t struct char_session_data; enum pincode_state : uint8; diff --git a/src/char/char_cnslif.cpp b/src/char/char_cnslif.cpp index 6468eee6d0..720dae2f30 100644 --- a/src/char/char_cnslif.cpp +++ b/src/char/char_cnslif.cpp @@ -6,11 +6,11 @@ #include #include -#include "../common/socket.h" -#include "../common/showmsg.h" -#include "../common/timer.h" -#include "../common/ers.h" -#include "../common/cli.h" +#include "../common/socket.hpp" +#include "../common/showmsg.hpp" +#include "../common/timer.hpp" +#include "../common/ers.hpp" +#include "../common/cli.hpp" #include "char.hpp" diff --git a/src/char/char_cnslif.hpp b/src/char/char_cnslif.hpp index 0216c2d04f..0d4979296d 100644 --- a/src/char/char_cnslif.hpp +++ b/src/char/char_cnslif.hpp @@ -7,9 +7,6 @@ int cnslif_parse(const char* buf); void do_init_chcnslif(void); -extern "C" { -void display_helpscreen(bool do_exit); -} #endif /* _CHAR_CNSLIF_HPP_ */ diff --git a/src/char/char_logif.cpp b/src/char/char_logif.cpp index f9090892bf..88cdd88187 100644 --- a/src/char/char_logif.cpp +++ b/src/char/char_logif.cpp @@ -6,12 +6,12 @@ #include #include -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/showmsg.h" -#include "../common/sql.h" -#include "../common/utils.h" -#include "../common/strlib.h" +#include "../common/socket.hpp" +#include "../common/timer.hpp" +#include "../common/showmsg.hpp" +#include "../common/sql.hpp" +#include "../common/utils.hpp" +#include "../common/strlib.hpp" #include "inter.hpp" #include "int_guild.hpp" @@ -349,7 +349,7 @@ int chlogif_parse_reqaccdata(int fd, struct char_session_data* sd){ sd->group_id = RFIFOB(fd,50); sd->char_slots = RFIFOB(fd,51); if( sd->char_slots > MAX_CHARS ) { - ShowError("Account '%d' `character_slots` column is higher than supported MAX_CHARS (%d), update MAX_CHARS in mmo.h! capping to MAX_CHARS...\n",sd->account_id,sd->char_slots); + ShowError("Account '%d' `character_slots` column is higher than supported MAX_CHARS (%d), update MAX_CHARS in mmo.hpp! capping to MAX_CHARS...\n",sd->account_id,sd->char_slots); sd->char_slots = MAX_CHARS;/* cap to maximum */ } else if ( !sd->char_slots )/* no value aka 0 in sql */ sd->char_slots = MIN_CHARS;/* cap to minimum */ diff --git a/src/char/char_logif.hpp b/src/char/char_logif.hpp index 792e9654f9..a076f48495 100644 --- a/src/char/char_logif.hpp +++ b/src/char/char_logif.hpp @@ -4,7 +4,7 @@ #ifndef _CHAR_LOGIF_HPP_ #define _CHAR_LOGIF_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" struct char_session_data; diff --git a/src/char/char_mapif.cpp b/src/char/char_mapif.cpp index 52044fd460..6e74b9d548 100644 --- a/src/char/char_mapif.cpp +++ b/src/char/char_mapif.cpp @@ -12,11 +12,11 @@ #include #include //memcpy -#include "../common/socket.h" -#include "../common/sql.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" +#include "../common/socket.hpp" +#include "../common/sql.hpp" +#include "../common/malloc.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" #include "inter.hpp" #include "char.hpp" diff --git a/src/char/char_mapif.hpp b/src/char/char_mapif.hpp index 0e3cbd7626..4d71e80921 100644 --- a/src/char/char_mapif.hpp +++ b/src/char/char_mapif.hpp @@ -10,7 +10,7 @@ #ifndef _CHAR_MAPIF_HPP_ #define _CHAR_MAPIF_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" int chmapif_sendall(unsigned char *buf, unsigned int len); int chmapif_sendallwos(int sfd, unsigned char *buf, unsigned int len); diff --git a/src/char/int_achievement.cpp b/src/char/int_achievement.cpp index 0a4c96f7b3..391bff6395 100644 --- a/src/char/int_achievement.cpp +++ b/src/char/int_achievement.cpp @@ -7,13 +7,13 @@ #include #include -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/sql.h" -#include "../common/strlib.h" +#include "../common/db.hpp" +#include "../common/malloc.hpp" +#include "../common/mmo.hpp" +#include "../common/showmsg.hpp" +#include "../common/socket.hpp" +#include "../common/sql.hpp" +#include "../common/strlib.hpp" #include "char.hpp" #include "inter.hpp" diff --git a/src/char/int_auction.cpp b/src/char/int_auction.cpp index 6e4afe28e7..7fc5182680 100644 --- a/src/char/int_auction.cpp +++ b/src/char/int_auction.cpp @@ -7,13 +7,13 @@ #include #include -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/sql.h" -#include "../common/timer.h" +#include "../common/mmo.hpp" +#include "../common/malloc.hpp" +#include "../common/showmsg.hpp" +#include "../common/socket.hpp" +#include "../common/strlib.hpp" +#include "../common/sql.hpp" +#include "../common/timer.hpp" #include "char.hpp" #include "char_mapif.hpp" diff --git a/src/char/int_clan.cpp b/src/char/int_clan.cpp index 1c06b0ecae..94ea35c005 100644 --- a/src/char/int_clan.cpp +++ b/src/char/int_clan.cpp @@ -6,12 +6,12 @@ #include #include //memset -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" +#include "../common/cbasetypes.hpp" +#include "../common/malloc.hpp" +#include "../common/mmo.hpp" +#include "../common/showmsg.hpp" +#include "../common/socket.hpp" +#include "../common/strlib.hpp" #include "char.hpp" #include "char_mapif.hpp" diff --git a/src/char/int_elemental.cpp b/src/char/int_elemental.cpp index 34f80a8c15..1416f7ba75 100644 --- a/src/char/int_elemental.cpp +++ b/src/char/int_elemental.cpp @@ -6,11 +6,11 @@ #include #include -#include "../common/mmo.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/sql.h" +#include "../common/mmo.hpp" +#include "../common/strlib.hpp" +#include "../common/showmsg.hpp" +#include "../common/socket.hpp" +#include "../common/sql.hpp" #include "char.hpp" #include "inter.hpp" diff --git a/src/char/int_guild.cpp b/src/char/int_guild.cpp index 600553836f..0a876de8a9 100644 --- a/src/char/int_guild.cpp +++ b/src/char/int_guild.cpp @@ -7,13 +7,13 @@ #define __STDC_WANT_LIB_EXT1__ 1 #include -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/timer.h" +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" +#include "../common/malloc.hpp" +#include "../common/socket.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" +#include "../common/timer.hpp" #include "char.hpp" #include "char_mapif.hpp" diff --git a/src/char/int_guild.hpp b/src/char/int_guild.hpp index d0ade43405..6702acf378 100644 --- a/src/char/int_guild.hpp +++ b/src/char/int_guild.hpp @@ -4,7 +4,7 @@ #ifndef _INT_GUILD_HPP_ #define _INT_GUILD_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" enum e_guild_action : uint32 { GS_BASIC = 0x0001, diff --git a/src/char/int_homun.cpp b/src/char/int_homun.cpp index c6c6bd3de1..085a6e2b9d 100644 --- a/src/char/int_homun.cpp +++ b/src/char/int_homun.cpp @@ -6,12 +6,12 @@ #include #include -#include "../common/mmo.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/utils.h" -#include "../common/sql.h" +#include "../common/mmo.hpp" +#include "../common/strlib.hpp" +#include "../common/showmsg.hpp" +#include "../common/socket.hpp" +#include "../common/utils.hpp" +#include "../common/sql.hpp" #include "char.hpp" #include "inter.hpp" diff --git a/src/char/int_homun.hpp b/src/char/int_homun.hpp index 4bcef6f92d..cab765d37e 100644 --- a/src/char/int_homun.hpp +++ b/src/char/int_homun.hpp @@ -4,7 +4,7 @@ #ifndef _INT_HOMUN_HPP_ #define _INT_HOMUN_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" struct s_homunculus; diff --git a/src/char/int_mail.cpp b/src/char/int_mail.cpp index ced2a4468c..e3a0724fcb 100644 --- a/src/char/int_mail.cpp +++ b/src/char/int_mail.cpp @@ -6,11 +6,11 @@ #include #include -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/sql.h" +#include "../common/mmo.hpp" +#include "../common/showmsg.hpp" +#include "../common/socket.hpp" +#include "../common/strlib.hpp" +#include "../common/sql.hpp" #include "char.hpp" #include "char_mapif.hpp" diff --git a/src/char/int_mail.hpp b/src/char/int_mail.hpp index 21cc726e55..864e7a5815 100644 --- a/src/char/int_mail.hpp +++ b/src/char/int_mail.hpp @@ -4,7 +4,7 @@ #ifndef _INT_MAIL_HPP_ #define _INT_MAIL_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" struct mail_message; diff --git a/src/char/int_mercenary.cpp b/src/char/int_mercenary.cpp index 0eaee859e6..caded55468 100644 --- a/src/char/int_mercenary.cpp +++ b/src/char/int_mercenary.cpp @@ -6,11 +6,11 @@ #include #include -#include "../common/mmo.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/sql.h" +#include "../common/mmo.hpp" +#include "../common/strlib.hpp" +#include "../common/showmsg.hpp" +#include "../common/socket.hpp" +#include "../common/sql.hpp" #include "char.hpp" #include "inter.hpp" diff --git a/src/char/int_mercenary.hpp b/src/char/int_mercenary.hpp index 2812bf7628..1cfd03dd40 100644 --- a/src/char/int_mercenary.hpp +++ b/src/char/int_mercenary.hpp @@ -4,7 +4,7 @@ #ifndef _INT_MERCENARY_HPP_ #define _INT_MERCENARY_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" int inter_mercenary_sql_init(void); void inter_mercenary_sql_final(void); diff --git a/src/char/int_party.cpp b/src/char/int_party.cpp index f3b1f2f8a2..b5f44b46ff 100644 --- a/src/char/int_party.cpp +++ b/src/char/int_party.cpp @@ -6,14 +6,14 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/socket.h" -#include "../common/showmsg.h" -#include "../common/mapindex.h" -#include "../common/sql.h" +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" +#include "../common/malloc.hpp" +#include "../common/strlib.hpp" +#include "../common/socket.hpp" +#include "../common/showmsg.hpp" +#include "../common/mapindex.hpp" +#include "../common/sql.hpp" #include "char.hpp" #include "char_mapif.hpp" diff --git a/src/char/int_party.hpp b/src/char/int_party.hpp index f72aa7f815..266cee57c7 100644 --- a/src/char/int_party.hpp +++ b/src/char/int_party.hpp @@ -4,7 +4,7 @@ #ifndef _INT_PARTY_HPP_ #define _INT_PARTY_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" //Party Flags on what to save/delete. enum e_PartySaveWhatFlag { diff --git a/src/char/int_pet.cpp b/src/char/int_pet.cpp index f7ff685ae3..40fe5261b8 100644 --- a/src/char/int_pet.cpp +++ b/src/char/int_pet.cpp @@ -6,13 +6,13 @@ #include #include -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/sql.h" +#include "../common/mmo.hpp" +#include "../common/malloc.hpp" +#include "../common/socket.hpp" +#include "../common/strlib.hpp" +#include "../common/showmsg.hpp" +#include "../common/utils.hpp" +#include "../common/sql.hpp" #include "char.hpp" #include "inter.hpp" diff --git a/src/char/int_pet.hpp b/src/char/int_pet.hpp index 5f92884bf0..76daad23b5 100644 --- a/src/char/int_pet.hpp +++ b/src/char/int_pet.hpp @@ -4,7 +4,7 @@ #ifndef _INT_PET_HPP_ #define _INT_PET_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" struct s_pet; diff --git a/src/char/int_quest.cpp b/src/char/int_quest.cpp index 37aebc38ce..fa74ca6698 100644 --- a/src/char/int_quest.cpp +++ b/src/char/int_quest.cpp @@ -6,11 +6,11 @@ #include #include -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/sql.h" +#include "../common/mmo.hpp" +#include "../common/malloc.hpp" +#include "../common/socket.hpp" +#include "../common/strlib.hpp" +#include "../common/sql.hpp" #include "char.hpp" #include "inter.hpp" diff --git a/src/char/int_storage.cpp b/src/char/int_storage.cpp index 24d7f42f28..eecf8cf725 100644 --- a/src/char/int_storage.cpp +++ b/src/char/int_storage.cpp @@ -7,12 +7,12 @@ #include #include -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" // StringBuf -#include "../common/sql.h" +#include "../common/malloc.hpp" +#include "../common/mmo.hpp" +#include "../common/showmsg.hpp" +#include "../common/socket.hpp" +#include "../common/strlib.hpp" // StringBuf +#include "../common/sql.hpp" #include "char.hpp" #include "inter.hpp" diff --git a/src/char/int_storage.hpp b/src/char/int_storage.hpp index 9a0ab0300e..72e5855f28 100644 --- a/src/char/int_storage.hpp +++ b/src/char/int_storage.hpp @@ -4,7 +4,7 @@ #ifndef _INT_STORAGE_HPP_ #define _INT_STORAGE_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" struct s_storage; diff --git a/src/char/inter.cpp b/src/char/inter.cpp index d2e86739a2..ee49a1857b 100644 --- a/src/char/inter.cpp +++ b/src/char/inter.cpp @@ -11,12 +11,12 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/timer.h" +#include "../common/cbasetypes.hpp" +#include "../common/malloc.hpp" +#include "../common/strlib.hpp" +#include "../common/showmsg.hpp" +#include "../common/socket.hpp" +#include "../common/timer.hpp" #include "char.hpp" #include "char_logif.hpp" diff --git a/src/char/inter.hpp b/src/char/inter.hpp index 130dcec398..9384c0fc7a 100644 --- a/src/char/inter.hpp +++ b/src/char/inter.hpp @@ -4,8 +4,8 @@ #ifndef _INTER_HPP_ #define _INTER_HPP_ -#include "../common/cbasetypes.h" -#include "../common/sql.h" +#include "../common/cbasetypes.hpp" +#include "../common/sql.hpp" #include #include diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index d9164f0409..c52ef05da8 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -41,24 +41,24 @@ mark_as_advanced( COMMON_SOURCE_DIR ) set( COMMON_ALL_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/svnversion.h" - "${COMMON_SOURCE_DIR}/cbasetypes.h" - "${COMMON_SOURCE_DIR}/mmo.h" + "${COMMON_SOURCE_DIR}/cbasetypes.hpp" + "${COMMON_SOURCE_DIR}/mmo.hpp" ) set( COMMON_MINI_HEADERS ${COMMON_ALL_HEADERS} - "${COMMON_SOURCE_DIR}/core.h" - "${COMMON_SOURCE_DIR}/malloc.h" - "${COMMON_SOURCE_DIR}/showmsg.h" - "${COMMON_SOURCE_DIR}/strlib.h" - ${LIBCONFIG_HEADERS} # needed by showmsg.h + "${COMMON_SOURCE_DIR}/core.hpp" + "${COMMON_SOURCE_DIR}/malloc.hpp" + "${COMMON_SOURCE_DIR}/showmsg.hpp" + "${COMMON_SOURCE_DIR}/strlib.hpp" + ${LIBCONFIG_HEADERS} # needed by showmsg.hpp CACHE INTERNAL "" ) set( COMMON_MINI_SOURCES "${COMMON_SOURCE_DIR}/core.cpp" - "${COMMON_SOURCE_DIR}/malloc.c" - "${COMMON_SOURCE_DIR}/showmsg.c" - "${COMMON_SOURCE_DIR}/strlib.c" - ${LIBCONFIG_SOURCES} # needed by showmsg.c + "${COMMON_SOURCE_DIR}/malloc.cpp" + "${COMMON_SOURCE_DIR}/showmsg.cpp" + "${COMMON_SOURCE_DIR}/strlib.cpp" + ${LIBCONFIG_SOURCES} # needed by showmsg.cpp CACHE INTERNAL "" ) set( COMMON_MINI_INCLUDE_DIRS ${LIBCONFIG_INCLUDE_DIRS} CACHE INTERNAL "" ) set( COMMON_MINI_DEFINITIONS "-DMINICORE ${LIBCONFIG_DEFINITIONS}" CACHE INTERNAL "" ) @@ -71,60 +71,48 @@ if( WITH_ZLIB ) message( STATUS "Creating target common_base" ) set( COMMON_BASE_HEADERS ${COMMON_ALL_HEADERS} - "${COMMON_SOURCE_DIR}/conf.h" - "${COMMON_SOURCE_DIR}/core.h" - "${COMMON_SOURCE_DIR}/db.h" - "${COMMON_SOURCE_DIR}/des.h" - "${COMMON_SOURCE_DIR}/ers.h" - "${COMMON_SOURCE_DIR}/grfio.h" - "${COMMON_SOURCE_DIR}/malloc.h" - "${COMMON_SOURCE_DIR}/mapindex.h" - "${COMMON_SOURCE_DIR}/md5calc.h" - "${COMMON_SOURCE_DIR}/nullpo.h" - "${COMMON_SOURCE_DIR}/random.h" - "${COMMON_SOURCE_DIR}/showmsg.h" - "${COMMON_SOURCE_DIR}/socket.h" - "${COMMON_SOURCE_DIR}/strlib.h" - "${COMMON_SOURCE_DIR}/timer.h" - "${COMMON_SOURCE_DIR}/utils.h" - "${COMMON_SOURCE_DIR}/atomic.h" - "${COMMON_SOURCE_DIR}/spinlock.h" - "${COMMON_SOURCE_DIR}/thread.h" - "${COMMON_SOURCE_DIR}/mutex.h" - "${COMMON_SOURCE_DIR}/raconf.h" - "${COMMON_SOURCE_DIR}/mempool.h" - "${COMMON_SOURCE_DIR}/msg_conf.h" - "${COMMON_SOURCE_DIR}/cli.h" - "${COMMON_SOURCE_DIR}/yamlwrapper.h" + "${COMMON_SOURCE_DIR}/conf.hpp" + "${COMMON_SOURCE_DIR}/core.hpp" + "${COMMON_SOURCE_DIR}/db.hpp" + "${COMMON_SOURCE_DIR}/des.hpp" + "${COMMON_SOURCE_DIR}/ers.hpp" + "${COMMON_SOURCE_DIR}/grfio.hpp" + "${COMMON_SOURCE_DIR}/malloc.hpp" + "${COMMON_SOURCE_DIR}/mapindex.hpp" + "${COMMON_SOURCE_DIR}/md5calc.hpp" + "${COMMON_SOURCE_DIR}/nullpo.hpp" + "${COMMON_SOURCE_DIR}/random.hpp" + "${COMMON_SOURCE_DIR}/showmsg.hpp" + "${COMMON_SOURCE_DIR}/socket.hpp" + "${COMMON_SOURCE_DIR}/strlib.hpp" + "${COMMON_SOURCE_DIR}/timer.hpp" + "${COMMON_SOURCE_DIR}/utils.hpp" + "${COMMON_SOURCE_DIR}/msg_conf.hpp" + "${COMMON_SOURCE_DIR}/cli.hpp" "${COMMON_SOURCE_DIR}/utilities.hpp" - ${LIBCONFIG_HEADERS} # needed by conf.h/showmsg.h + ${LIBCONFIG_HEADERS} # needed by conf.hpp/showmsg.hpp CACHE INTERNAL "common_base headers" ) set( COMMON_BASE_SOURCES - "${COMMON_SOURCE_DIR}/conf.c" + "${COMMON_SOURCE_DIR}/conf.cpp" "${COMMON_SOURCE_DIR}/core.cpp" - "${COMMON_SOURCE_DIR}/db.c" - "${COMMON_SOURCE_DIR}/des.c" - "${COMMON_SOURCE_DIR}/ers.c" - "${COMMON_SOURCE_DIR}/grfio.c" - "${COMMON_SOURCE_DIR}/malloc.c" - "${COMMON_SOURCE_DIR}/mapindex.c" - "${COMMON_SOURCE_DIR}/md5calc.c" - "${COMMON_SOURCE_DIR}/nullpo.c" - "${COMMON_SOURCE_DIR}/random.c" - "${COMMON_SOURCE_DIR}/showmsg.c" - "${COMMON_SOURCE_DIR}/socket.c" - "${COMMON_SOURCE_DIR}/strlib.c" - "${COMMON_SOURCE_DIR}/timer.c" - "${COMMON_SOURCE_DIR}/utils.c" - "${COMMON_SOURCE_DIR}/thread.c" - "${COMMON_SOURCE_DIR}/mutex.c" - "${COMMON_SOURCE_DIR}/mempool.c" - "${COMMON_SOURCE_DIR}/raconf.c" - "${COMMON_SOURCE_DIR}/msg_conf.c" - "${COMMON_SOURCE_DIR}/cli.c" - "${COMMON_SOURCE_DIR}/yamlwrapper.cpp" + "${COMMON_SOURCE_DIR}/db.cpp" + "${COMMON_SOURCE_DIR}/des.cpp" + "${COMMON_SOURCE_DIR}/ers.cpp" + "${COMMON_SOURCE_DIR}/grfio.cpp" + "${COMMON_SOURCE_DIR}/malloc.cpp" + "${COMMON_SOURCE_DIR}/mapindex.cpp" + "${COMMON_SOURCE_DIR}/md5calc.cpp" + "${COMMON_SOURCE_DIR}/nullpo.cpp" + "${COMMON_SOURCE_DIR}/random.cpp" + "${COMMON_SOURCE_DIR}/showmsg.cpp" + "${COMMON_SOURCE_DIR}/socket.cpp" + "${COMMON_SOURCE_DIR}/strlib.cpp" + "${COMMON_SOURCE_DIR}/timer.cpp" + "${COMMON_SOURCE_DIR}/utils.cpp" + "${COMMON_SOURCE_DIR}/msg_conf.cpp" + "${COMMON_SOURCE_DIR}/cli.cpp" "${COMMON_SOURCE_DIR}/utilities.cpp" - ${LIBCONFIG_SOURCES} # needed by conf.c/showmsg.c + ${LIBCONFIG_SOURCES} # needed by conf.cpp/showmsg.cpp CACHE INTERNAL "common_base sources" ) set( COMMON_BASE_INCLUDE_DIRS ${LIBCONFIG_INCLUDE_DIRS} @@ -134,10 +122,9 @@ set( COMMON_BASE_DEFINITIONS ${LIBCONFIG_DEFINITIONS} CACHE INTERNAL "common_base definitions" ) set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} yaml-cpp ) -set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${YAML_INCLUDE_DIRS} ${MT19937AR_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS}} ) +set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${YAML_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS}} ) set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS}" ) -set( SOURCE_FILES ${MT19937AR_HEADERS} ${MT19937AR_SOURCES} ${COMMON_BASE_HEADERS} ${COMMON_BASE_SOURCES} ) -source_group( mt19937ar FILES ${MT19937AR_HEADERS} ${MT19937AR_SOURCES} ) +set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_BASE_SOURCES} ) source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_BASE_SOURCES} ) add_library( common_base ${SOURCE_FILES} ) @@ -162,10 +149,10 @@ if( HAVE_common_base AND WITH_MYSQL ) message( STATUS "Creating target common" ) set( COMMON_HEADERS ${COMMON_ALL_HEADERS} - "${CMAKE_CURRENT_SOURCE_DIR}/sql.h" + "${CMAKE_CURRENT_SOURCE_DIR}/sql.hpp" CACHE INTERNAL "common headers" ) set( COMMON_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/sql.c" + "${CMAKE_CURRENT_SOURCE_DIR}/sql.cpp" CACHE INTERNAL "common sources" ) set( DEPENDENCIES common_base yaml-cpp ) set( LIBRARIES ${GLOBAL_LIBRARIES} ${MYSQL_LIBRARIES} ) diff --git a/src/common/Makefile.in b/src/common/Makefile.in index d36c795c2f..144941ea7f 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -1,17 +1,11 @@ -#COMMON_OBJ = $(ls *.c | grep -viw sql.c | sed -e "s/\.c/\.o/g") COMMON_OBJ = core.o socket.o timer.o db.o nullpo.o malloc.o showmsg.o strlib.o utils.o utilities.o \ grfio.o mapindex.o ers.o md5calc.o minicore.o minisocket.o minimalloc.o random.o des.o \ - conf.o thread.o mutex.o raconf.o mempool.o msg_conf.o cli.o sql.o yamlwrapper.o + conf.o msg_conf.o cli.o sql.o COMMON_DIR_OBJ = $(COMMON_OBJ:%=obj/%) -COMMON_H = $(shell ls ../common/*.h) -COMMON_H += $(shell ls ../common/*.hpp) +COMMON_H = $(shell ls ../common/*.hpp) COMMON_AR = obj/common.a -MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o -MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h -MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar - LIBCONFIG_H = $(shell ls ../../3rdparty/libconfig/*.h) LIBCONFIG_AR = ../../3rdparty/libconfig/obj/libconfig.a LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig @@ -64,28 +58,17 @@ $(COMMON_AR): $(COMMON_DIR_OBJ) @echo " AR $@" @@AR@ rcs $(COMMON_AR) $(COMMON_DIR_OBJ) -common: obj $(COMMON_DIR_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_AR) $(YAML_CPP_AR) $(COMMON_AR) +common: obj $(COMMON_DIR_OBJ) $(LIBCONFIG_AR) $(YAML_CPP_AR) $(COMMON_AR) -obj/%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) $(YAML_CPP_H) - @echo " CC $<" - @@CC@ @CFLAGS_AR@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< - -obj/%.o: %.cpp $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) $(YAML_CPP_H) +obj/%.o: %.cpp $(COMMON_H) $(LIBCONFIG_H) $(YAML_CPP_H) @echo " CXX $<" - @@CXX@ @CXXFLAGS@ @CFLAGS_AR@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @@CXX@ @CXXFLAGS@ @CFLAGS_AR@ $(LIBCONFIG_INCLUDE) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -obj/mini%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) $(YAML_CPP_H) - @echo " CC $<" - @@CC@ @CFLAGS_AR@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ -DMINICORE @CPPFLAGS@ -c $(OUTPUT_OPTION) $< - -obj/mini%.o: %.cpp $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) $(YAML_CPP_H) +obj/mini%.o: %.cpp $(COMMON_H) $(LIBCONFIG_H) $(YAML_CPP_H) @echo " CXX $<" - @@CXX@ @CXXFLAGS@ @CFLAGS_AR@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ -DMINICORE @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @@CXX@ @CXXFLAGS@ @CFLAGS_AR@ $(LIBCONFIG_INCLUDE) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ -DMINICORE @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files -$(MT19937AR_OBJ): - @$(MAKE) -C ../../3rdparty/mt19937ar - $(LIBCONFIG_AR): @$(MAKE) -C ../../3rdparty/libconfig diff --git a/src/common/atomic.h b/src/common/atomic.h deleted file mode 100644 index 3412c6db9c..0000000000 --- a/src/common/atomic.h +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _rA_ATOMIC_H_ -#define _rA_ATOMIC_H_ - -// Atomic Operations -// (Interlocked CompareExchange, Add .. and so on ..) -// -// Implementation varies / depends on: -// - Architecture -// - Compiler -// - Operating System -// -// our Abstraction is fully API-Compatible to Microsofts implementation @ NT5.0+ -// -#include "cbasetypes.h" - -#if defined(_MSC_VER) -#include "winapi.hpp" - -// This checks if C/C++ Compiler Version is 18.00 or Windows is older than Vista -#if _MSC_VER < 1800 || WINVER < _WIN32_WINNT_VISTA - -#if !defined(_M_X64) -// When compiling for windows 32bit, the 8byte interlocked operations are not provided by microsoft -// (because they need at least i586 so its not generic enough.. ... ) -forceinline int64 InterlockedCompareExchange64(volatile int64 *dest, int64 exch, int64 _cmp){ - _asm{ - lea esi,_cmp; - lea edi,exch; - - mov eax,[esi]; - mov edx,4[esi]; - mov ebx,[edi]; - mov ecx,4[edi]; - mov esi,dest; - - lock CMPXCHG8B [esi]; - } -} - - -forceinline volatile int64 InterlockedIncrement64(volatile int64 *addend){ - __int64 old; - do{ - old = *addend; - }while(InterlockedCompareExchange64(addend, (old+1), old) != old); - - return (old + 1); -} - - - -forceinline volatile int64 InterlockedDecrement64(volatile int64 *addend){ - __int64 old; - - do{ - old = *addend; - }while(InterlockedCompareExchange64(addend, (old-1), old) != old); - - return (old - 1); -} - -forceinline volatile int64 InterlockedExchangeAdd64(volatile int64 *addend, int64 increment){ - __int64 old; - - do{ - old = *addend; - }while(InterlockedCompareExchange64(addend, (old + increment), old) != old); - - return old; -} - -forceinline volatile int64 InterlockedExchange64(volatile int64 *target, int64 val){ - __int64 old; - do{ - old = *target; - }while(InterlockedCompareExchange64(target, val, old) != old); - - return old; -} - -#endif //endif 32bit windows - -#endif //endif _msc_ver check - -#elif defined(__GNUC__) - -// The __sync functions are available on x86 or ARMv6+ -//need to proper dig into arm macro, -//see http://sourceforge.net/p/predef/wiki/Architectures/ -#if !defined(__x86_64__) && !defined(__i386__) \ - && ( !defined(__ARM_ARCH_VERSION__) || __ARM_ARCH_VERSION__ < 6 ) \ - && ( !defined(__ARM_ARCH) && __ARM_ARCH < 6 ) -#error Your Target Platfrom is not supported -#endif - - -static forceinline int64 InterlockedExchangeAdd64(volatile int64 *addend, int64 increment){ - return __sync_fetch_and_add(addend, increment); -}//end: InterlockedExchangeAdd64() - - -static forceinline int32 InterlockedExchangeAdd(volatile int32 *addend, int32 increment){ - return __sync_fetch_and_add(addend, increment); -}//end: InterlockedExchangeAdd() - - -static forceinline int64 InterlockedIncrement64(volatile int64 *addend){ - return __sync_add_and_fetch(addend, 1); -}//end: InterlockedIncrement64() - - -static forceinline int32 InterlockedIncrement(volatile int32 *addend){ - return __sync_add_and_fetch(addend, 1); -}//end: InterlockedIncrement() - - -static forceinline int64 InterlockedDecrement64(volatile int64 *addend){ - return __sync_sub_and_fetch(addend, 1); -}//end: InterlockedDecrement64() - - -static forceinline int32 InterlockedDecrement(volatile int32 *addend){ - return __sync_sub_and_fetch(addend, 1); -}//end: InterlockedDecrement() - - -static forceinline int64 InterlockedCompareExchange64(volatile int64 *dest, int64 exch, int64 cmp){ - return __sync_val_compare_and_swap(dest, cmp, exch); -}//end: InterlockedCompareExchange64() - - -static forceinline int32 InterlockedCompareExchange(volatile int32 *dest, int32 exch, int32 cmp){ - return __sync_val_compare_and_swap(dest, cmp, exch); -}//end: InterlockedCompareExchnage() - - -static forceinline int64 InterlockedExchange64(volatile int64 *target, int64 val){ - return __sync_lock_test_and_set(target, val); -}//end: InterlockedExchange64() - - -static forceinline int32 InterlockedExchange(volatile int32 *target, int32 val){ - return __sync_lock_test_and_set(target, val); -}//end: InterlockedExchange() - - -#endif //endif compiler decission - - -#endif diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.hpp similarity index 98% rename from src/common/cbasetypes.h rename to src/common/cbasetypes.hpp index 2ad5fe159b..41f9ecfb5c 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.hpp @@ -1,5 +1,5 @@ -#ifndef _CBASETYPES_H_ -#define _CBASETYPES_H_ +#ifndef _CBASETYPES_HPP_ +#define _CBASETYPES_HPP_ /* +--------+-----------+--------+---------+ * | ILP32 | LP64 | ILP64 | (LL)P64 | @@ -75,7 +75,6 @@ ////////////////////////////////////////////////////////////////////////// // portable printf/scanf format macros and integer definitions -// NOTE: Visual C++ uses and provided in /3rdparty ////////////////////////////////////////////////////////////////////////// #ifdef __cplusplus #define __STDC_CONSTANT_MACROS @@ -83,8 +82,7 @@ #define __STDC_LIMIT_MACROS #endif -#include -#include +#include #include // temporary fix for bugreport:4961 (unintended conversion from signed to unsigned) @@ -437,4 +435,4 @@ static inline uint32 u32min(uint32 a, uint32 b){ return (a < b) ? a : b; } static inline uint64 u64min(uint64 a, uint64 b){ return (a < b) ? a : b; } static inline size_t zmin(size_t a, size_t b){ return (a < b) ? a : b; } -#endif /* _CBASETYPES_H_ */ +#endif /* _CBASETYPES_HPP_ */ diff --git a/src/common/cli.c b/src/common/cli.cpp similarity index 92% rename from src/common/cli.c rename to src/common/cli.cpp index 91b361f41b..aae8f2ca80 100644 --- a/src/common/cli.c +++ b/src/common/cli.cpp @@ -1,5 +1,5 @@ /** - * @file cli.c + * @file cli.cpp * Module purpose is to handle the console (cli=console line input) while the servers launch and run. * This contains functions common to all servers, but then dispatches them to a specific parser on each server. * Licensed under GNU GPL. @@ -16,10 +16,10 @@ #include #endif -#include "cbasetypes.h" -#include "showmsg.h" -#include "core.h" -#include "cli.h" +#include "cbasetypes.hpp" +#include "showmsg.hpp" +#include "core.hpp" +#include "cli.hpp" //map confs const char* MAP_CONF_NAME; @@ -67,15 +67,14 @@ void display_versionscreen(bool do_exit) { const char* svn = get_svn_revision(); if( svn[0] != UNKNOWN_VERSION ) - ShowInfo("rAthena SVN Revision: '"CL_WHITE"%s"CL_RESET"'\n", svn); + ShowInfo("rAthena SVN Revision: '" CL_WHITE "%s" CL_RESET "'\n", svn); else { const char* git = get_git_hash(); if( git[0] != UNKNOWN_VERSION ) - ShowInfo("rAthena Git Hash: '"CL_WHITE"%s"CL_RESET"'\n", git); + ShowInfo("rAthena Git Hash: '" CL_WHITE "%s" CL_RESET "'\n", git); } - ShowInfo(CL_GREEN"Website/Forum:"CL_RESET"\thttp://rathena.org/\n"); - ShowInfo(CL_GREEN"IRC Channel:"CL_RESET"\tirc://irc.rizon.net/#rathena\n"); - ShowInfo("Open "CL_WHITE"readme.txt"CL_RESET" for more information.\n"); + ShowInfo(CL_GREEN "Website/Forum:" CL_RESET "\thttp://rathena.org/\n"); + ShowInfo("Open " CL_WHITE "README.md" CL_RESET " for more information.\n"); if (do_exit) exit(EXIT_SUCCESS); } diff --git a/src/common/cli.h b/src/common/cli.hpp similarity index 90% rename from src/common/cli.h rename to src/common/cli.hpp index dac3cc5a8f..6de4ec7681 100644 --- a/src/common/cli.h +++ b/src/common/cli.hpp @@ -1,5 +1,5 @@ /** - * @file cli.h + * @file cli.hpp * Module purpose is to handle the console (cli=console line input) while the servers launch and run. * This contains functions common to all servers, but then dispatches them to a specific parser on each server. * Licensed under GNU GPL. @@ -7,12 +7,8 @@ * @author rAthena Dev Team */ -#ifndef CLI_H -#define CLI_H - -#ifdef __cplusplus -extern "C" { -#endif +#ifndef CLI_HPP +#define CLI_HPP #define MAX_CONSOLE_IN 200 //max is map... #define MIN_CONSOLE_IN 4 //min is help @@ -41,9 +37,5 @@ int cli_get_options(int argc, char ** argv); int parse_console_timer(int tid, unsigned int tick, int id, intptr_t data); extern int parse_console(const char* buf); //particular for each serv -#ifdef __cplusplus -} -#endif - -#endif /* CLI_H */ +#endif /* CLI_HPP */ diff --git a/src/common/common-minicore.vcxproj b/src/common/common-minicore.vcxproj index c7fc725b28..487798e099 100644 --- a/src/common/common-minicore.vcxproj +++ b/src/common/common-minicore.vcxproj @@ -19,43 +19,39 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - CompileAsCpp - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -130,8 +126,8 @@ Disabled $(DefineConstants);WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;LIBCONFIG_STATIC;YY_USE_CONST;MINICORE;_DEBUG;_LIB;%(PreprocessorDefinitions) MultiThreadedDebug - $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mysql\include\;$(SolutionDir)3rdparty\mt19937ar\;$(SolutionDir)3rdparty\libconfig\;$(SolutionDir)3rdparty\yaml-cpp\include\ - $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mt19937ar\;$(SolutionDir)3rdparty\libconfig\ + $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mysql\include\;$(SolutionDir)3rdparty\libconfig\;$(SolutionDir)3rdparty\yaml-cpp\include\ + $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\libconfig\ Windows @@ -146,8 +142,8 @@ Disabled $(DefineConstants);WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;LIBCONFIG_STATIC;YY_USE_CONST;MINICORE;_DEBUG;_LIB;%(PreprocessorDefinitions) MultiThreadedDebug - $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mysql\include\;$(SolutionDir)3rdparty\mt19937ar\;$(SolutionDir)3rdparty\libconfig\;$(SolutionDir)3rdparty\yaml-cpp\include\ - $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mt19937ar\;$(SolutionDir)3rdparty\libconfig\ + $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mysql\include\;$(SolutionDir)3rdparty\libconfig\;$(SolutionDir)3rdparty\yaml-cpp\include\ + $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\libconfig\ Windows @@ -164,8 +160,8 @@ true $(DefineConstants);WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;LIBCONFIG_STATIC;YY_USE_CONST;MINICORE;NDEBUG;_LIB;%(PreprocessorDefinitions) MultiThreaded - $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mysql\include\;$(SolutionDir)3rdparty\mt19937ar\;$(SolutionDir)3rdparty\libconfig\;$(SolutionDir)3rdparty\yaml-cpp\include\ - $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mt19937ar\;$(SolutionDir)3rdparty\libconfig\ + $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mysql\include\;$(SolutionDir)3rdparty\libconfig\;$(SolutionDir)3rdparty\yaml-cpp\include\ + $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\libconfig\ Windows @@ -184,8 +180,8 @@ true $(DefineConstants);WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;LIBCONFIG_STATIC;YY_USE_CONST;MINICORE;NDEBUG;_LIB;%(PreprocessorDefinitions) MultiThreaded - $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mysql\include\;$(SolutionDir)3rdparty\mt19937ar\;$(SolutionDir)3rdparty\libconfig\;$(SolutionDir)3rdparty\yaml-cpp\include\ - $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mt19937ar\;$(SolutionDir)3rdparty\libconfig\ + $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mysql\include\;$(SolutionDir)3rdparty\libconfig\;$(SolutionDir)3rdparty\yaml-cpp\include\ + $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\libconfig\ Windows diff --git a/src/common/common-minicore.vcxproj.filters b/src/common/common-minicore.vcxproj.filters index 5cb744f813..e9a4a6b998 100644 --- a/src/common/common-minicore.vcxproj.filters +++ b/src/common/common-minicore.vcxproj.filters @@ -11,55 +11,52 @@ - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - - Header Files - - + Header Files @@ -67,49 +64,46 @@ - + Source Files - + Source Files Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - - Source Files - - + Source Files diff --git a/src/common/common.vcxproj b/src/common/common.vcxproj index 8d72db2a24..b18eee6b82 100644 --- a/src/common/common.vcxproj +++ b/src/common/common.vcxproj @@ -19,65 +19,51 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - CompileAsCpp - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - @@ -151,7 +137,7 @@ Level3 Disabled $(DefineConstants);WIN32;FD_SETSIZE=4096;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;LIBCONFIG_STATIC;YY_USE_CONST;_DEBUG;_LIB;%(PreprocessorDefinitions) - $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mysql\include\;$(SolutionDir)3rdparty\mt19937ar\;$(SolutionDir)3rdparty\libconfig\;$(SolutionDir)3rdparty\yaml-cpp\include\ + $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mysql\include\;$(SolutionDir)3rdparty\libconfig\;$(SolutionDir)3rdparty\yaml-cpp\include\ MultiThreadedDebug @@ -169,7 +155,7 @@ Level3 Disabled $(DefineConstants);WIN32;FD_SETSIZE=4096;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;LIBCONFIG_STATIC;YY_USE_CONST;_DEBUG;_LIB;%(PreprocessorDefinitions) - $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mysql\include\;$(SolutionDir)3rdparty\mt19937ar\;$(SolutionDir)3rdparty\libconfig\;$(SolutionDir)3rdparty\yaml-cpp\include\ + $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mysql\include\;$(SolutionDir)3rdparty\libconfig\;$(SolutionDir)3rdparty\yaml-cpp\include\ MultiThreadedDebug @@ -189,7 +175,7 @@ true true $(DefineConstants);WIN32;FD_SETSIZE=4096;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;LIBCONFIG_STATIC;YY_USE_CONST;NDEBUG;_LIB;%(PreprocessorDefinitions) - $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mysql\include\;$(SolutionDir)3rdparty\mt19937ar\;$(SolutionDir)3rdparty\libconfig\;$(SolutionDir)3rdparty\yaml-cpp\include\ + $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mysql\include\;$(SolutionDir)3rdparty\libconfig\;$(SolutionDir)3rdparty\yaml-cpp\include\ MultiThreaded @@ -211,7 +197,7 @@ true true $(DefineConstants);WIN32;FD_SETSIZE=4096;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;LIBCONFIG_STATIC;YY_USE_CONST;NDEBUG;_LIB;%(PreprocessorDefinitions) - $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mysql\include\;$(SolutionDir)3rdparty\mt19937ar\;$(SolutionDir)3rdparty\libconfig\;$(SolutionDir)3rdparty\yaml-cpp\include\ + $(SolutionDir)3rdparty\zlib\include\;$(SolutionDir)3rdparty\mysql\include\;$(SolutionDir)3rdparty\libconfig\;$(SolutionDir)3rdparty\yaml-cpp\include\ MultiThreaded diff --git a/src/common/common.vcxproj.filters b/src/common/common.vcxproj.filters index f94aeb85d6..fe0d2941e7 100644 --- a/src/common/common.vcxproj.filters +++ b/src/common/common.vcxproj.filters @@ -11,173 +11,137 @@ - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - + Header Files Header Files - - Header Files - Header Files - + Source Files - + Source Files Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - - Source Files - - - Source Files - - - Source Files - - - Source Files - - + Source Files Source Files - - Source Files - Source Files diff --git a/src/common/conf.c b/src/common/conf.cpp similarity index 98% rename from src/common/conf.c rename to src/common/conf.cpp index 94a649ecc5..3964065e64 100644 --- a/src/common/conf.c +++ b/src/common/conf.cpp @@ -1,8 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "conf.h" -#include "showmsg.h" // ShowError +#include "conf.hpp" +#include "showmsg.hpp" // ShowError int conf_read_file(config_t *config, const char *config_filename) { diff --git a/src/common/conf.h b/src/common/conf.hpp similarity index 68% rename from src/common/conf.h rename to src/common/conf.hpp index 249372666e..f441d2d197 100644 --- a/src/common/conf.h +++ b/src/common/conf.hpp @@ -1,21 +1,13 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CONF_H_ -#define _CONF_H_ +#ifndef _CONF_HPP_ +#define _CONF_HPP_ -#ifdef __cplusplus -extern "C" { -#endif - -#include "cbasetypes.h" +#include "cbasetypes.hpp" #include "../../3rdparty/libconfig/libconfig.h" int conf_read_file(config_t *config, const char *config_filename); int config_setting_copy(config_setting_t *parent, const config_setting_t *src); -#ifdef __cplusplus -} -#endif - -#endif // _CONF_H_ +#endif // _CONF_HPP_ diff --git a/src/common/core.cpp b/src/common/core.cpp index 7c24f9858d..7eea502ff7 100644 --- a/src/common/core.cpp +++ b/src/common/core.cpp @@ -1,19 +1,17 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "mmo.h" -#include "cbasetypes.h" -#include "showmsg.h" -#include "malloc.h" -#include "core.h" -#include "strlib.h" +#include "mmo.hpp" +#include "cbasetypes.hpp" +#include "showmsg.hpp" +#include "malloc.hpp" +#include "core.hpp" +#include "strlib.hpp" #ifndef MINICORE -#include "ers.h" -#include "socket.h" -#include "timer.h" -#include "thread.h" -#include "mempool.h" -#include "sql.h" +#include "ers.hpp" +#include "socket.hpp" +#include "timer.hpp" +#include "sql.hpp" #endif #include #include @@ -125,7 +123,7 @@ static void sig_proc(int sn) { //run_flag = 0; // should we quit? break; case SIGPIPE: - //ShowInfo ("Broken pipe found... closing socket\n"); // set to eof in socket.c + //ShowInfo ("Broken pipe found... closing socket\n"); // set to eof in socket.cpp break; // does nothing here #endif } @@ -351,8 +349,6 @@ int main (int argc, char **argv) usercheck(); Sql_Init(); - rathread_init(); - mempool_init(); db_init(); signals_init(); @@ -376,8 +372,6 @@ int main (int argc, char **argv) timer_final(); socket_final(); db_final(); - mempool_final(); - rathread_final(); ers_final(); #endif diff --git a/src/common/core.h b/src/common/core.hpp similarity index 91% rename from src/common/core.h rename to src/common/core.hpp index 43551a2b42..c50fb1bd80 100644 --- a/src/common/core.h +++ b/src/common/core.hpp @@ -1,12 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CORE_H_ -#define _CORE_H_ - -#ifdef __cplusplus -extern "C" { -#endif +#ifndef _CORE_HPP_ +#define _CORE_HPP_ /* so that developers with --enable-debug can raise signals from any section of the code they'd like */ #ifdef DEBUG @@ -57,8 +53,4 @@ enum E_CORE_ST /// If NULL, runflag is set to CORE_ST_STOP instead. extern void (*shutdown_callback)(void); -#ifdef __cplusplus -} -#endif - -#endif /* _CORE_H_ */ +#endif /* _CORE_HPP_ */ diff --git a/src/common/db.c b/src/common/db.cpp similarity index 99% rename from src/common/db.c rename to src/common/db.cpp index a4348f2879..f49d21f43d 100644 --- a/src/common/db.c +++ b/src/common/db.cpp @@ -65,16 +65,16 @@ * @version 2006/12/21 * @author Athena Dev team * @encoding US-ASCII - * @see #db.h + * @see #db.hpp \*****************************************************************************/ -#include "db.h" +#include "db.hpp" -#include "ers.h" -#include "malloc.h" -#include "mmo.h" -#include "showmsg.h" -#include "strlib.h" +#include "ers.hpp" +#include "malloc.hpp" +#include "mmo.hpp" +#include "showmsg.hpp" +#include "strlib.hpp" #include #include @@ -2565,7 +2565,7 @@ DBMap* db_alloc(const char *file, const char *func, int line, DBType type, DBOpt db->free_lock = 0; /* Other */ snprintf(ers_name, 50, "db_alloc:nodes:%s:%s:%d",func,file,line); - db->nodes = ers_new(sizeof(struct dbn),ers_name,ERS_OPT_WAIT|ERS_OPT_FREE_NAME|ERS_OPT_CLEAN); + db->nodes = ers_new(sizeof(struct dbn),ers_name,ERS_DBN_OPTIONS); db->cmp = db_default_cmp(type); db->hash = db_default_hash(type); db->release = db_default_release(type, options); @@ -2758,8 +2758,8 @@ void* db_data2ptr(DBData *data) * @see #db_final(void) */ void db_init(void) { - db_iterator_ers = ers_new(sizeof(struct DBIterator_impl),"db.c::db_iterator_ers",ERS_OPT_CLEAN|ERS_OPT_FLEX_CHUNK); - db_alloc_ers = ers_new(sizeof(struct DBMap_impl),"db.c::db_alloc_ers",ERS_OPT_CLEAN|ERS_OPT_FLEX_CHUNK); + db_iterator_ers = ers_new(sizeof(struct DBIterator_impl),"db.cpp::db_iterator_ers",ERS_CACHE_OPTIONS); + db_alloc_ers = ers_new(sizeof(struct DBMap_impl),"db.cpp::db_alloc_ers",ERS_CACHE_OPTIONS); ers_chunk_size(db_alloc_ers, 50); ers_chunk_size(db_iterator_ers, 10); DB_COUNTSTAT(db_init); diff --git a/src/common/db.h b/src/common/db.hpp similarity index 99% rename from src/common/db.h rename to src/common/db.hpp index 99d5aa6310..065403975b 100644 --- a/src/common/db.h +++ b/src/common/db.hpp @@ -37,18 +37,14 @@ * @author (Athena build 4859) Flavio @ Amazon Project * * @author (up to Athena build 4706) Athena Dev Teams * * @encoding US-ASCII * - * @see common#db.c * + * @see common#db.cpp * \*****************************************************************************/ -#ifndef _DB_H_ -#define _DB_H_ +#ifndef _DB_HPP_ +#define _DB_HPP_ #include -#include "cbasetypes.h" - -#ifdef __cplusplus -extern "C" { -#endif +#include "cbasetypes.hpp" /*****************************************************************************\ * (1) Section with public typedefs, enums, unions, structures and defines. * @@ -1659,8 +1655,4 @@ void linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...); /// @return negative if v1 is top, positive if v2 is top, 0 if equal #define BHEAP_MAXTOPCMP(v1,v2) ( v1 == v2 ? 0 : v1 > v2 ? -1 : 1 ) -#ifdef __cplusplus -} -#endif - -#endif /* _DB_H_ */ +#endif /* _DB_HPP_ */ diff --git a/src/common/des.c b/src/common/des.cpp similarity index 99% rename from src/common/des.c rename to src/common/des.cpp index ee45731e79..5ff97b526a 100644 --- a/src/common/des.c +++ b/src/common/des.cpp @@ -1,7 +1,7 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "cbasetypes.h" -#include "des.h" +#include "cbasetypes.hpp" +#include "des.hpp" /// DES (Data Encryption Standard) algorithm, modified version. diff --git a/src/common/des.h b/src/common/des.hpp similarity index 83% rename from src/common/des.h rename to src/common/des.hpp index e42136436e..6bfb593a24 100644 --- a/src/common/des.h +++ b/src/common/des.hpp @@ -1,7 +1,7 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _DES_H_ -#define _DES_H_ +#ifndef _DES_HPP_ +#define _DES_HPP_ /// One 64-bit block. @@ -12,4 +12,4 @@ void des_decrypt_block(BIT64* block); void des_decrypt(unsigned char* data, size_t size); -#endif // _DES_H_ +#endif // _DES_HPP_ diff --git a/src/common/ers.c b/src/common/ers.cpp similarity index 92% rename from src/common/ers.c rename to src/common/ers.cpp index 98d1014c24..1ae9ad348b 100644 --- a/src/common/ers.c +++ b/src/common/ers.cpp @@ -37,15 +37,15 @@ * @version 1.0 - ERS Rework * * @author GreenBox @ rAthena Project * * @encoding US-ASCII * - * @see common#ers.h * + * @see common#ers.hpp * \*****************************************************************************/ -#include "cbasetypes.h" -#include "ers.h" -#include "malloc.h" // CREATE, RECREATE, aMalloc, aFree -#include "nullpo.h" -#include "showmsg.h" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL +#include "cbasetypes.hpp" +#include "ers.hpp" +#include "malloc.hpp" // CREATE, RECREATE, aMalloc, aFree +#include "nullpo.hpp" +#include "showmsg.hpp" // ShowMessage, ShowError, ShowFatalError, CL_BOLD, CL_NORMAL #include #include @@ -141,7 +141,7 @@ static ers_cache_t *ers_find_cache(unsigned int size, enum ERSOptions Options) { cache->UsedObjs = 0; cache->Max = 0; cache->ChunkSize = ERS_BLOCK_ENTRIES; - cache->Options = (Options & ERS_CACHE_OPTIONS); + cache->Options = (enum ERSOptions)(Options & ERS_CACHE_OPTIONS); if (CacheList == NULL) { @@ -335,7 +335,7 @@ void ers_report(void) { for (cache = CacheList; cache; cache = cache->Next) { cache_c++; - ShowMessage(CL_BOLD"[ERS Cache of size '"CL_NORMAL""CL_WHITE"%u"CL_NORMAL""CL_BOLD"' report]\n"CL_NORMAL, cache->ObjectSize); + ShowMessage(CL_BOLD"[ERS Cache of size '" CL_NORMAL "" CL_WHITE "%u" CL_NORMAL "" CL_BOLD "' report]\n" CL_NORMAL, cache->ObjectSize); ShowMessage("\tinstances : %u\n", cache->ReferenceCount); ShowMessage("\tblocks in use : %u/%u\n", cache->UsedObjs, cache->UsedObjs+cache->Free); ShowMessage("\tblocks unused : %u\n", cache->Free); @@ -346,9 +346,9 @@ void ers_report(void) { memory_b += cache->UsedObjs * cache->ObjectSize; memory_t += (cache->UsedObjs+cache->Free) * cache->ObjectSize; } - ShowInfo("ers_report: '"CL_WHITE"%u"CL_NORMAL"' caches in use\n",cache_c); - ShowInfo("ers_report: '"CL_WHITE"%u"CL_NORMAL"' blocks in use, consuming '"CL_WHITE"%.2f MB"CL_NORMAL"'\n",blocks_u,(double)((memory_b)/1024)/1024); - ShowInfo("ers_report: '"CL_WHITE"%u"CL_NORMAL"' blocks total, consuming '"CL_WHITE"%.2f MB"CL_NORMAL"' \n",blocks_a,(double)((memory_t)/1024)/1024); + ShowInfo("ers_report: '" CL_WHITE "%u" CL_NORMAL "' caches in use\n",cache_c); + ShowInfo("ers_report: '" CL_WHITE "%u" CL_NORMAL "' blocks in use, consuming '" CL_WHITE "%.2f MB" CL_NORMAL "'\n",blocks_u,(double)((memory_b)/1024)/1024); + ShowInfo("ers_report: '" CL_WHITE "%u" CL_NORMAL "' blocks total, consuming '" CL_WHITE "%.2f MB" CL_NORMAL "' \n",blocks_a,(double)((memory_t)/1024)/1024); } /** diff --git a/src/common/ers.h b/src/common/ers.hpp similarity index 98% rename from src/common/ers.h rename to src/common/ers.hpp index 51a45d951d..100e3cae61 100644 --- a/src/common/ers.h +++ b/src/common/ers.hpp @@ -37,14 +37,10 @@ * @author Flavio @ Amazon Project * * @encoding US-ASCII * \*****************************************************************************/ -#ifndef _ERS_H_ -#define _ERS_H_ +#ifndef _ERS_HPP_ +#define _ERS_HPP_ -#ifdef __cplusplus -extern "C" { -#endif - -#include "cbasetypes.h" +#include "cbasetypes.hpp" /*****************************************************************************\ * (1) All public parts of the Entry Reusage System. * @@ -85,6 +81,7 @@ enum ERSOptions { /* Compound, is used to determine whether it should be looking for a cache of matching options */ ERS_CACHE_OPTIONS = ERS_OPT_CLEAN|ERS_OPT_FLEX_CHUNK, ERS_CLEAN_OPTIONS = ERS_OPT_CLEAN|ERS_OPT_CLEAR, + ERS_DBN_OPTIONS = ERS_OPT_CLEAN|ERS_OPT_WAIT|ERS_OPT_FREE_NAME, }; /** @@ -180,8 +177,4 @@ void ers_report(void); void ers_final(void); #endif /* DISABLE_ERS / not DISABLE_ERS */ -#ifdef __cplusplus -} -#endif - -#endif /* _ERS_H_ */ +#endif /* _ERS_HPP_ */ diff --git a/src/common/evdp.h b/src/common/evdp.h deleted file mode 100644 index 7767a15140..0000000000 --- a/src/common/evdp.h +++ /dev/null @@ -1,168 +0,0 @@ -#ifndef _rA_EVDP_H_ -#define _rA_EVDP_H_ - -#include "cbasetypes.h" - -typedef struct EVDP_DATA EVDP_DATA; - - -//#idef EVDP_EPOLL -#include -struct EVDP_DATA{ - struct epoll_event ev_data; - bool ev_added; -}; -//#endif - - -enum EVDP_EVENTFLAGS{ - EVDP_EVENT_IN = 1, // Incomming data - EVDP_EVENT_OUT = 2, // Connection accepts writing. - EVDP_EVENT_HUP = 4 // Connection Closed. -}; - -typedef struct EVDP_EVENT{ - int32 events; // due to performance reasons, this should be the first member. - int32 fd; // Connection Identifier -} EVDP_EVENT; - - - -/** - * Network Event Dispatcher Initialization / Finalization routines - */ -void evdp_init(); -void evdp_final(); - - -/** - * Will Wait for events. - * - * @param *out_ev pointer to array in size at least of max_events. - * @param max_events max no of events to report with this call (coalesc) - * @param timeout_ticks max time to wait in ticks (milliseconds) - * - * @Note: - * The function will block until an event has occured on one of the monitored connections - * or the timeout of timeout_ticks has passed by. - * Upon successfull call (changed connections) this function will write the connection - * Identifier & event to the out_fds array. - * - * @return 0 -> Timeout, > 0 no of changed connections. - */ -int32 evdp_wait(EVDP_EVENT *out_fds, int32 max_events, int32 timeout_ticks); - - -/** - * Applys the given mask on the given connection. - * - * @param fd connection identifier - * @param *ep event data pointer for the connection - * @param mask new event mask we're monitoring for. - */ -//void evdp_apply(int32 fd, EVDP_DATA *ep, int32 mask); - - -/** - * Adds a connection (listner) to the event notification system. - * - * @param fd connection identifier - * @param *ep event data pointer for the connection - * - * @note: - * Listener type sockets are edge triggered, (see epoll manual for more information) - * - This basicaly means that youll receive one event, adn you have to accept until accept returns an error (nothing to accept) - * - * MONITORS by default: IN - * - * @return success indicator. - */ -bool evdp_addlistener(int32 fd, EVDP_DATA *ep); - -/** - * Adds a connection (client connectioN) to the event notification system - * - * @param fd connection identifier - * @param *ep event data pointr for the connection - * - * @note: - * - * MONITORS by default: IN, HUP - * - * @return success indicator. - */ -bool evdp_addclient(int32 fd, EVDP_DATA *ep); - -/** - * Adds a connection (pending / outgoing connection!) to the event notification system. - * - * @param fd connection identifier - * @param *ep event data pointer for the conneciton. - * - * @note: - * Outgoing connection type sockets are getting monitored for connection established - * successfull - * - if the connection has been established - we're generitng a writable notification .. (send) - * this is typical for BSD / posix conform network stacks. - * - Additinionally its edge triggered. - * - * @see evdp_outgoingconnection_established - * - * - * @return success indicator - */ -bool evdp_addconnecting(int32 fd, EVDP_DATA *ep); - -/** - * Adds an outgoing connection to the normal event notification system after it has been successfully established. - * - * @param fd connection identifier - * @param *ep event data pointer for the conneciton. - - * @note - * after this call, its handled like a normal "client" connection (incomming) - * - * @rturn success indicator - */ -bool evdp_outgoingconnection_established(int32 fd, EVDP_DATA *ep); - -/** - * Marks a connection to be monitored for writable. - * - * @param fd connection identifier - * @param *ep event data pointer for the connection - * - * @note: - * the connection must be already added (as client or listener) - * - * - * @return success indicator - */ -bool evdp_writable_add(int32 fd, EVDP_DATA *ep); - -/** - * Removes the connection from writable notification monitoring - * - * @param fd connection identifier - * @param *ep event data pointr for the connection - * - */ -void evdp_writable_remove(int32 fd, EVDP_DATA *ep); - -/** - * Removes an connectio from the event notification system. - * - * @param fd connection iditentfir - * @param *ep event data pointer for th connection - * - * - * @note: - * this will also clear the given EVENT_DATA block - * so the connection slot is in an "initial" blank status / ready to get reused. - * - */ -void evdp_remove(int32 fd, EVDP_DATA *ep); - - - -#endif diff --git a/src/common/evdp_epoll.c b/src/common/evdp_epoll.c deleted file mode 100644 index cd0cf5dacb..0000000000 --- a/src/common/evdp_epoll.c +++ /dev/null @@ -1,218 +0,0 @@ -// -// Event Dispatcher Abstraction for EPOLL -// -// Author: Florian Wilkemeyer -// -// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL -// For more information, see LICENCE in the main folder -// -// - - -#define EPOLL_MAX_PER_CYCLE 10 // Max Events to coalesc. per cycle. - - -static int epoll_fd = -1; - - -void evdp_init(){ - - epoll_fd = epoll_create( EPOLL_MAX_PER_CYCLE ); - if(epoll_fd == -1){ - ShowFatalError("evdp [EPOLL]: Cannot create event dispatcher (errno: %u / %s)\n", errno, strerror(errno) ); - exit(1); - } - -}//end: evdp_init() - - -void evdp_final(){ - - if(epoll_fd != -1){ - close(epoll_fd); - epoll_fd = -1; - } - -}//end: evdp_final() - - -int32 evdp_wait(EVDP_EVENT *out_fds, int32 max_events, int32 timeout_ticks){ - struct epoll_event l_events[EPOLL_MAX_PER_CYCLE]; - register struct epoll_event *ev; - register int nfds, n; - - if(max_events > EPOLL_MAX_PER_CYCLE) - max_events = EPOLL_MAX_PER_CYCLE; - - nfds = epoll_wait( epoll_fd, l_events, max_events, timeout_ticks); - if(nfds == -1){ - // @TODO: check if core is in shutdown mode. if - ignroe error. - - ShowFatalError("evdp [EPOLL]: epoll_wait returned bad / unexpected status (errno: %u / %s)\n", errno, strerror(errno)); - exit(1); //.. - } - - // Loop thru all events and copy it to the local ra evdp_event.. struct. - for(n = 0; n < nfds; n++){ - ev = &l_events[n]; - - out_fds->fd = ev->data.fd; - out_fds->events = 0; // clear - - if(ev->events & EPOLLHUP) - out_fds->events |= EVDP_EVENT_HUP; - - if(ev->events & EPOLLIN) - out_fds->events |= EVDP_EVENT_IN; - - if(ev->events & EPOLLOUT) - out_fds->events |= EVDP_EVENT_OUT; - - out_fds++; - } - - return nfds; // 0 on timeout or > 0 .. -}//end: evdp_wait() - - -void evdp_remove(int32 fd, EVDP_DATA *ep){ - - if(ep->ev_added == true){ - - if( epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fd, &ep->ev_data) != 0){ - ShowError("evdp [EPOLL]: evdp_remove - epoll_ctl (EPOLL_CTL_DEL) failed! fd #%u (errno %u / %s)\n", fd, errno, strerror(errno)); - } - - ep->ev_data.events = 0; // clear struct. - ep->ev_data.data.fd = -1; // .. clear struct .. - - ep->ev_added = false; // not added! - } - - -}//end: evdp_remove() - - -bool evdp_addlistener(int32 fd, EVDP_DATA *ep){ - - ep->ev_data.events = EPOLLET|EPOLLIN; - ep->ev_data.data.fd = fd; - - // No check here for 'added ?' - // listeners cannot be added twice. - // - if( epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ep->ev_data) != 0 ){ - ShowError("evdp [EPOLL]: evdp_addlistener - epoll_ctl (EPOLL_CTL_ADD) faield! fd #%u (errno %u / %s)\n", fd, errno, strerror(errno)); - ep->ev_data.events = 0; - ep->ev_data.data.fd = -1; - return false; - } - - ep->ev_added = true; - - return true; -}//end: evdp_addlistener() - - -bool evdp_addclient(int32 fd, EVDP_DATA *ep){ - - ep->ev_data.events = EPOLLIN | EPOLLHUP; - ep->ev_data.data.fd = fd; - - // No check for "added?" here, - // this function only gets called upon accpept. - // - - if( epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ep->ev_data) != 0){ - ShowError("evdp [EPOLL]: evdp_addclient - epoll_ctl (EPOLL_CTL_ADD) failed! fd #%u (errno %u / %s)\n", fd, errno, strerror(errno)); - ep->ev_data.events = 0; - ep->ev_data.data.fd = -1; - return false; - } - - ep->ev_added = true; - - return true; -}//end: evdp_addclient() - - -bool evdp_addconnecting(int32 fd, EVDP_DATA *ep){ - - ep->ev_data.events = EPOLLET | EPOLLOUT | EPOLLHUP; - ep->ev_data.data.fd = fd; - - if( epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ep->ev_data) != 0){ - ShowError("evdp [EPOLL]: evdp_addconnecting - epoll_ctl (EPOLL_CTL_ADD) failed! fd #%u (errno %u / %s)\n", fd, errno, strerror(errno)); - ep->ev_data.events = 0; - ep->ev_data.data.fd = -1; - } - - ep->ev_added = true; - - return true; -}//end: evdp_addconnecting() - - -bool evdp_outgoingconnection_established(int32 fd, EVDP_DATA *ep){ - int32 saved_mask; - - if(ep->ev_added != true){ - // ! - ShowError("evdp [EPOLL]: evdp_outgoingconnection_established fd #%u is not added to event dispatcher! invalid call.\n", fd); - return false; - } - - saved_mask = ep->ev_data.events; - - ep->ev_data.events = EPOLLIN | EPOLLHUP; - - if( epoll_ctl(epoll_fd, EPOLL_CTL_MOD, fd, &ep->ev_data) != 0){ - ep->ev_data.events = saved_mask; // restore old mask. - ShowError("evdp [EPOLL]: evdp_outgoingconnection_established - epoll_ctl (EPOLL_CTL_MOD) failed! fd #%u (errno %u / %s)\n", fd, errno, strerror(errno)); - return false; - } - - return true; -}//end: evdp_outgoingconnection_established() - - -bool evdp_writable_add(int32 fd, EVDP_DATA *ep){ - - if(ep->ev_added != true){ - ShowError("evdp [EPOLL]: evdp_writable_add - tried to add not added fd #%u\n",fd); - return false; - } - - if(! (ep->ev_data.events & EPOLLOUT) ){ // - - ep->ev_data.events |= EPOLLOUT; - if( epoll_ctl(epoll_fd, EPOLL_CTL_MOD, fd, &ep->ev_data) != 0 ){ - ShowError("evdp [EPOLL]: evdp_writable_add - epoll_ctl (EPOLL_CTL_MOD) failed! fd #%u (errno: %u / %s)\n", fd, errno, strerror(errno)); - ep->ev_data.events &= ~EPOLLOUT; // remove from local flagmask due to failed syscall. - return false; - } - } - - return true; -}//end: evdp_writable_add() - - -void evdp_writable_remove(int32 fd, EVDP_DATA *ep){ - - if(ep->ev_added != true){ - ShowError("evdp [EPOLL]: evdp_writable_remove - tried to remove not added fd #%u\n", fd); - return; - } - - if( ep->ev_data.events & EPOLLOUT ){ - - ep->ev_data.events &= ~EPOLLOUT; - if( epoll_ctl(epoll_fd, EPOLL_CTL_MOD, fd, &ep->ev_data) != 0){ - ShowError("evdp [EPOLL]: evdp_writable_remove - epoll_ctl (EPOLL_CTL_MOD) failed! fd #%u (errno %u / %s)\n", fd, errno, strerror(errno)); - ep->ev_data.events |= EPOLLOUT; // add back to local flagmask because of failed syscall. - return; - } - } - - return; -}//end: evdp_writable_remove() diff --git a/src/common/grfio.c b/src/common/grfio.cpp similarity index 97% rename from src/common/grfio.c rename to src/common/grfio.cpp index a596e7d4ce..2b0d00b035 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.cpp @@ -1,13 +1,13 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "cbasetypes.h" -#include "des.h" -#include "malloc.h" -#include "showmsg.h" -#include "strlib.h" -#include "utils.h" -#include "grfio.h" +#include "cbasetypes.hpp" +#include "des.hpp" +#include "malloc.hpp" +#include "showmsg.hpp" +#include "strlib.hpp" +#include "utils.hpp" +#include "grfio.hpp" #include #include @@ -395,9 +395,8 @@ void* grfio_reads(const char* fname, int* size) in = fopen(lfname, "rb"); if( in != NULL ) { - int declen; fseek(in,0,SEEK_END); - declen = ftell(in); + size_t declen = ftell(in); fseek(in,0,SEEK_SET); buf2 = (unsigned char *)aMalloc(declen+1); // +1 for resnametable zero-termination if(fread(buf2, 1, declen, in) != declen) ShowError("An error occured in fread grfio_reads, fname=%s \n",fname); @@ -419,7 +418,7 @@ void* grfio_reads(const char* fname, int* size) char* grfname = gentry_table[entry->gentry - 1]; FILE* in = fopen(grfname, "rb"); if( in != NULL ) { - int fsize = entry->srclen_aligned; + size_t fsize = entry->srclen_aligned; unsigned char *buf = (unsigned char *)aMalloc(fsize); fseek(in, entry->srcpos, 0); if(fread(buf, 1, fsize, in) != fsize) ShowError("An error occured in fread in grfio_reads, grfname=%s\n",grfname); @@ -515,8 +514,7 @@ static int grfio_entryread(const char* grfname, int gentry) grf_version = getlong(grf_header+0x2a) >> 8; if( grf_version == 0x01 ) {// ****** Grf version 01xx ****** - long list_size; - list_size = grf_size - ftell(fp); + size_t list_size = grf_size - ftell(fp); grf_filelist = (unsigned char *) aMalloc(list_size); if(fread(grf_filelist,1,list_size,fp) != list_size) { ShowError("Couldn't read all grf_filelist element of %s \n", grfname); } fclose(fp); @@ -695,7 +693,7 @@ static void grfio_resourcecheck(void) } fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", i, "resnametable.txt"); + ShowStatus("Done reading '" CL_WHITE "%d" CL_RESET "' entries in '" CL_WHITE "%s" CL_RESET "'.\n", i, "resnametable.txt"); return; // we're done here! } @@ -718,7 +716,7 @@ static void grfio_resourcecheck(void) } aFree(buf); - ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", i, "data\\resnametable.txt"); + ShowStatus("Done reading '" CL_WHITE "%d" CL_RESET "' entries in '" CL_WHITE "%s" CL_RESET "'.\n", i, "data\\resnametable.txt"); return; } } @@ -803,7 +801,7 @@ void grfio_init(const char* fname) } fclose(data_conf); - ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n", fname); + ShowStatus("Done reading '" CL_WHITE "%s" CL_RESET "'.\n", fname); } if( grf_num == 0 ) diff --git a/src/common/grfio.h b/src/common/grfio.hpp similarity index 81% rename from src/common/grfio.h rename to src/common/grfio.hpp index fd3c699314..90d05d6399 100644 --- a/src/common/grfio.h +++ b/src/common/grfio.hpp @@ -1,12 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _GRFIO_H_ -#define _GRFIO_H_ - -#ifdef __cplusplus -extern "C" { -#endif +#ifndef _GRFIO_HPP_ +#define _GRFIO_HPP_ void grfio_init(const char* fname); void grfio_final(void); @@ -18,8 +14,4 @@ unsigned long grfio_crc32(const unsigned char *buf, unsigned int len); int decode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen); int encode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen); -#ifdef __cplusplus -} -#endif - -#endif /* _GRFIO_H_ */ +#endif /* _GRFIO_HPP_ */ diff --git a/src/common/malloc.c b/src/common/malloc.cpp similarity index 98% rename from src/common/malloc.c rename to src/common/malloc.cpp index 179c73a9e0..064c4a16c2 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.cpp @@ -1,14 +1,16 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "malloc.h" -#include "core.h" -#include "showmsg.h" +#include "malloc.hpp" +#include "core.hpp" +#include "showmsg.hpp" #include #include #include +#define FREED_POINTER 0xdeadbeafL + ////////////// Memory Libraries ////////////////// #if defined(MEMWATCH) @@ -28,7 +30,7 @@ # include # include -# include "dmalloc.h" +# include "dmalloc.hpp" # define MALLOC(n,file,line,func) dmalloc_malloc((file),(line),(n),DMALLOC_FUNC_MALLOC,0,0) # define CALLOC(m,n,file,line,func) dmalloc_malloc((file),(line),(m)*(n),DMALLOC_FUNC_CALLOC,0,0) # define REALLOC(p,n,file,line,func) dmalloc_realloc((file),(line),(p),(n),DMALLOC_FUNC_REALLOC,0) @@ -255,7 +257,7 @@ void* _mmalloc(size_t size, const char *file, int line, const char *func ) p->next = unit_head_large_first; } unit_head_large_first = p; - *(long*)((char*)p + sizeof(struct unit_head_large) - sizeof(long) + size) = 0xdeadbeaf; + *(long*)((char*)p + sizeof(struct unit_head_large) - sizeof(long) + size) = FREED_POINTER; return (char *)p + sizeof(struct unit_head_large) - sizeof(long); } else { ShowFatalError("Memory manager::memmgr_alloc failed (allocating %d+%d bytes at %s:%d).\n", sizeof(struct unit_head_large), size, file, line); @@ -322,7 +324,7 @@ void* _mmalloc(size_t size, const char *file, int line, const char *func ) head->file = file; head->line = line; head->size = (unsigned short)size; - *(long*)((char*)head + sizeof(struct unit_head) - sizeof(long) + size) = 0xdeadbeaf; + *(long*)((char*)head + sizeof(struct unit_head) - sizeof(long) + size) = FREED_POINTER; return (char *)head + sizeof(struct unit_head) - sizeof(long); } @@ -383,7 +385,7 @@ void _mfree(void *ptr, const char *file, int line, const char *func ) struct unit_head_large *head_large = (struct unit_head_large *)((char *)ptr - sizeof(struct unit_head_large) + sizeof(long)); if( *(long*)((char*)head_large + sizeof(struct unit_head_large) - sizeof(long) + head_large->size) - != 0xdeadbeaf) + != FREED_POINTER) { ShowError("Memory manager: args of aFree 0x%p is overflowed pointer %s line %d\n", ptr, file, line); } else { @@ -406,11 +408,11 @@ void _mfree(void *ptr, const char *file, int line, const char *func ) } else { /* Release unit */ struct block *block = head->block; - if( (char*)head - (char*)block > sizeof(struct block) ) { + if( (size_t)((char*)head - (char*)block) > sizeof(struct block) ) { ShowError("Memory manager: args of aFree 0x%p is invalid pointer %s line %d\n", ptr, file, line); } else if(head->block == NULL) { ShowError("Memory manager: args of aFree 0x%p is freed pointer %s:%d@%s\n", ptr, file, line, func); - } else if(*(long*)((char*)head + sizeof(struct unit_head) - sizeof(long) + head->size) != 0xdeadbeaf) { + } else if(*(long*)((char*)head + sizeof(struct unit_head) - sizeof(long) + head->size) != FREED_POINTER) { ShowError("Memory manager: args of aFree 0x%p is overflowed pointer %s line %d\n", ptr, file, line); } else { memmgr_usage_bytes -= head->size; @@ -656,7 +658,7 @@ static void memmgr_init (void) { #ifdef LOG_MEMMGR sprintf(memmer_logfile, "log/%s.leaks", SERVER_NAME); - ShowStatus("Memory manager initialised: "CL_WHITE"%s"CL_RESET"\n", memmer_logfile); + ShowStatus("Memory manager initialised: " CL_WHITE "%s" CL_RESET "\n", memmer_logfile); memset(hash_unfill, 0, sizeof(hash_unfill)); #endif /* LOG_MEMMGR */ } diff --git a/src/common/malloc.h b/src/common/malloc.hpp similarity index 95% rename from src/common/malloc.h rename to src/common/malloc.hpp index 1660b870cd..40428bdbb3 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.hpp @@ -1,14 +1,10 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _MALLOC_H_ -#define _MALLOC_H_ +#ifndef _MALLOC_HPP_ +#define _MALLOC_HPP_ -#include "cbasetypes.h" - -#ifdef __cplusplus -extern "C" { -#endif +#include "cbasetypes.hpp" #define ALC_MARK __FILE__, __LINE__, __func__ @@ -93,8 +89,4 @@ size_t malloc_usage (void); void malloc_init (void); void malloc_final (void); -#ifdef __cplusplus -} -#endif - -#endif /* _MALLOC_H_ */ +#endif /* _MALLOC_HPP_ */ diff --git a/src/common/mapindex.c b/src/common/mapindex.cpp similarity index 96% rename from src/common/mapindex.c rename to src/common/mapindex.cpp index 4ece496329..81b98abb0b 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.cpp @@ -1,11 +1,11 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "mmo.h" -#include "core.h" -#include "mapindex.h" -#include "showmsg.h" -#include "strlib.h" +#include "mmo.hpp" +#include "core.hpp" +#include "mapindex.hpp" +#include "showmsg.hpp" +#include "strlib.hpp" #include @@ -137,12 +137,11 @@ void mapindex_init(void) { "map_index.txt", DBIMPORT"/map_index.txt" }; - int i; memset (&indexes, 0, sizeof (indexes)); mapindex_db = strdb_alloc(DB_OPT_DUP_KEY, MAP_NAME_LENGTH); - for( i = 0; i < ARRAYLENGTH(mapindex_cfgfile); i++ ){ + for( size_t i = 0; i < ARRAYLENGTH(mapindex_cfgfile); i++ ){ sprintf( path, "%s/%s", db_path, mapindex_cfgfile[i] ); if( ( fp = fopen( path, "r" ) ) == NULL ){ diff --git a/src/common/mapindex.h b/src/common/mapindex.hpp similarity index 92% rename from src/common/mapindex.h rename to src/common/mapindex.hpp index 68e8e23dd0..c1a0d0546a 100644 --- a/src/common/mapindex.h +++ b/src/common/mapindex.hpp @@ -1,14 +1,10 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _MAPINDEX_H_ -#define _MAPINDEX_H_ +#ifndef _MAPINDEX_HPP_ +#define _MAPINDEX_HPP_ -#ifdef __cplusplus -extern "C" { -#endif - -#include "../common/mmo.h" +#include "../common/mmo.hpp" #define MAX_MAPINDEX 2000 @@ -73,8 +69,4 @@ void mapindex_check_mapdefault(const char *mapname); void mapindex_init(void); void mapindex_final(void); -#ifdef __cplusplus -} -#endif - -#endif /* _MAPINDEX_H_ */ +#endif /* _MAPINDEX_HPP_ */ diff --git a/src/common/md5calc.c b/src/common/md5calc.cpp similarity index 99% rename from src/common/md5calc.c rename to src/common/md5calc.cpp index 50a1f711b5..840d47f999 100644 --- a/src/common/md5calc.c +++ b/src/common/md5calc.cpp @@ -6,8 +6,8 @@ * ***********************************************************/ -#include "../common/random.h" -#include "md5calc.h" +#include "../common/random.hpp" +#include "md5calc.hpp" #include #include diff --git a/src/common/md5calc.h b/src/common/md5calc.hpp similarity index 55% rename from src/common/md5calc.h rename to src/common/md5calc.hpp index 4a0b4be024..a13282ff22 100644 --- a/src/common/md5calc.h +++ b/src/common/md5calc.hpp @@ -1,16 +1,8 @@ -#ifndef _MD5CALC_H_ -#define _MD5CALC_H_ - -#ifdef __cplusplus -extern "C" { -#endif +#ifndef _MD5CALC_HPP_ +#define _MD5CALC_HPP_ void MD5_String(const char * string, char * output); void MD5_Binary(const char * string, unsigned char * output); void MD5_Salt(unsigned int len, char * output); -#ifdef __cplusplus -} -#endif - -#endif /* _MD5CALC_H_ */ +#endif /* _MD5CALC_HPP_ */ diff --git a/src/common/mempool.c b/src/common/mempool.c deleted file mode 100644 index 099cf5ca9d..0000000000 --- a/src/common/mempool.c +++ /dev/null @@ -1,566 +0,0 @@ - -// -// Memory Pool Implementation (Threadsafe) -// -// -// Author: Florian Wilkemeyer -// -// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL -// For more information, see LICENCE in the main folder -// -// - -#include -#include -#include - -#ifdef WIN32 -#include "winapi.hpp" -#else -#include -#endif - -#include "cbasetypes.h" -#include "showmsg.h" -#include "mempool.h" -#include "atomic.h" -#include "spinlock.h" -#include "malloc.h" -#include "mutex.h" - -#define ALIGN16 ra_align(16) -#define ALIGN_TO(x, a) (x + ( a - ( x % a) ) ) -#define ALIGN_TO_16(x) ALIGN_TO(x, 16) - -#undef MEMPOOL_DEBUG -#define MEMPOOLASSERT - - -#define NODE_TO_DATA(x) ( ((char*)x) + sizeof(struct node) ) -#define DATA_TO_NODE(x) ( (struct node*)(((char*)x) - sizeof(struct node)) ) -struct ra_align(16) node{ - void *next; - void *segment; -#ifdef MEMPOOLASSERT - bool used; - uint64 magic; - #define NODE_MAGIC 0xBEEF00EAEACAFE07ll -#endif -}; - - -// The Pointer to this struct is the base address of the segment itself. -struct pool_segment{ - pMempool pool; // pool, this segment belongs to - struct pool_segment *next; - int64 num_nodes_total; - int64 num_bytes; -}; - - -struct mempool{ - // Settings - char *name; - uint64 elem_size; - uint64 elem_realloc_step; - int64 elem_realloc_thresh; - - // Callbacks that get called for every node that gets allocated - // Example usage: initialization of mutex/lock for each node. - memPoolOnNodeAllocationProc onalloc; - memPoolOnNodeDeallocationProc ondealloc; - - // Locks - SPIN_LOCK segmentLock; - SPIN_LOCK nodeLock; - - - // Internal - struct pool_segment *segments; - struct node *free_list; - - volatile int64 num_nodes_total; - volatile int64 num_nodes_free; - - volatile int64 num_segments; - volatile int64 num_bytes_total; - - volatile int64 peak_nodes_used; // Peak Node Usage - volatile int64 num_realloc_events; // Number of reallocations done. (allocate additional nodes) - - // list (used for global management such as allocator..) - struct mempool *next; -} ra_align(8); // Dont touch the alignment, otherwise interlocked functions are broken .. - - -/// -// Implementation: -// -static void segment_allocate_add(pMempool p, uint64 count); - -static SPIN_LOCK l_mempoolListLock; -static pMempool l_mempoolList = NULL; -static prAthread l_async_thread = NULL; -static ramutex l_async_lock = NULL; -static racond l_async_cond = NULL; -static volatile int32 l_async_terminate = 0; - -static void *mempool_async_allocator(void *x){ - pMempool p; - - - while(1){ - if(l_async_terminate > 0) - break; - - EnterSpinLock(&l_mempoolListLock); - - for(p = l_mempoolList; p != NULL; p = p->next){ - - if(p->num_nodes_free < p->elem_realloc_thresh){ - // add new segment. - segment_allocate_add(p, p->elem_realloc_step); - // increase stats counter - InterlockedIncrement64(&p->num_realloc_events); - } - - } - - LeaveSpinLock(&l_mempoolListLock); - - ramutex_lock( l_async_lock ); - racond_wait( l_async_cond, l_async_lock, -1 ); - ramutex_unlock( l_async_lock ); - } - - - return NULL; -}//end: mempool_async_allocator() - - -void mempool_init(){ - - if( rand()%2 + 1 ) - return; - - if(sizeof(struct node)%16 != 0 ){ - ShowFatalError("mempool_init: struct node alignment failure. %u != multiple of 16\n", sizeof(struct node)); - exit(EXIT_FAILURE); - } - - // Global List start - InitializeSpinLock(&l_mempoolListLock); - l_mempoolList = NULL; - - // Initialize mutex + stuff needed for async allocator worker. - l_async_terminate = 0; - l_async_lock = ramutex_create(); - l_async_cond = racond_create(); - - l_async_thread = rathread_createEx(mempool_async_allocator, NULL, 1024*1024, RAT_PRIO_NORMAL); - if(l_async_thread == NULL){ - ShowFatalError("mempool_init: cannot spawn Async Allocator Thread.\n"); - exit(EXIT_FAILURE); - } - -}//end: mempool_init() - - -void mempool_final(){ - pMempool p, pn; - - if( rand()%2 + 1 ) - return; - - ShowStatus("Mempool: Terminating async. allocation worker and remaining pools.\n"); - - // Terminate worker / wait until its terminated. - InterlockedIncrement(&l_async_terminate); - racond_signal(l_async_cond); - rathread_wait(l_async_thread, NULL); - - // Destroy cond var and mutex. - racond_destroy( l_async_cond ); - ramutex_destroy( l_async_lock ); - - // Free remaining mempools - // ((bugged code! this should halppen, every mempool should - // be freed by the subsystem that has allocated it.) - // - EnterSpinLock(&l_mempoolListLock); - p = l_mempoolList; - while(1){ - if(p == NULL) - break; - - pn = p->next; - - ShowWarning("Mempool [%s] was not properly destroyed - forcing destroy.\n", p->name); - mempool_destroy(p); - - p = pn; - } - LeaveSpinLock(&l_mempoolListLock); - -}//end: mempool_final() - - -static void segment_allocate_add(pMempool p, uint64 count){ - - // Required Memory: - // sz( segment ) - // count * sz( real_node_size ) - // - // where real node size is: - // ALIGN_TO_16( sz( node ) ) + p->elem_size - // so the nodes usable address is nodebase + ALIGN_TO_16(sz(node)) - // - size_t total_sz; - struct pool_segment *seg = NULL; - struct node *nodeList = NULL; - struct node *node = NULL; - char *ptr = NULL; - uint64 i; - - total_sz = ALIGN_TO_16( sizeof(struct pool_segment) ) - + ( (size_t)count * (sizeof(struct node) + (size_t)p->elem_size) ) ; - -#ifdef MEMPOOL_DEBUG - ShowDebug("Mempool [%s] Segment AllocateAdd (num: %u, total size: %0.2fMiB)\n", p->name, count, (float)total_sz/1024.f/1024.f); -#endif - - // allocate! (spin forever until weve got the memory.) - i=0; - while(1){ - ptr = (char*)aMalloc(total_sz); - if(ptr != NULL) break; - - i++; // increase failcount. - if(!(i & 7)){ - ShowWarning("Mempool [%s] Segment AllocateAdd => System seems to be Out of Memory (%0.2f MiB). Try #%u\n", (float)total_sz/1024.f/1024.f, i); -#ifdef WIN32 - Sleep(1000); -#else - sleep(1); -#endif - }else{ - rathread_yield(); /// allow/force vuln. ctxswitch - } - }//endwhile: allocation spinloop. - - // Clear Memory. - memset(ptr, 0x00, total_sz); - - // Initialize segment struct. - seg = (struct pool_segment*)ptr; - ptr += ALIGN_TO_16(sizeof(struct pool_segment)); - - seg->pool = p; - seg->num_nodes_total = count; - seg->num_bytes = total_sz; - - - // Initialze nodes! - nodeList = NULL; - for(i = 0; i < count; i++){ - node = (struct node*)ptr; - ptr += sizeof(struct node); - ptr += p->elem_size; - - node->segment = seg; -#ifdef MEMPOOLASSERT - node->used = false; - node->magic = NODE_MAGIC; -#endif - - if(p->onalloc != NULL) p->onalloc( NODE_TO_DATA(node) ); - - node->next = nodeList; - nodeList = node; - } - - - - // Link in Segment. - EnterSpinLock(&p->segmentLock); - seg->next = p->segments; - p->segments = seg; - LeaveSpinLock(&p->segmentLock); - - // Link in Nodes - EnterSpinLock(&p->nodeLock); - nodeList->next = p->free_list; - p->free_list = nodeList; - LeaveSpinLock(&p->nodeLock); - - - // Increase Stats: - InterlockedExchangeAdd64(&p->num_nodes_total, count); - InterlockedExchangeAdd64(&p->num_nodes_free, count); - InterlockedIncrement64(&p->num_segments); - InterlockedExchangeAdd64(&p->num_bytes_total, total_sz); - -}//end: segment_allocate_add() - - -pMempool mempool_create(const char *name, - uint64 elem_size, - uint64 initial_count, - uint64 realloc_count, - memPoolOnNodeAllocationProc onNodeAlloc, - memPoolOnNodeDeallocationProc onNodeDealloc){ - //.. - uint64 realloc_thresh; - pMempool pool; - pool = (pMempool)aCalloc( 1, sizeof(struct mempool) ); - - if(pool == NULL){ - ShowFatalError("mempool_create: Failed to allocate %u bytes memory.\n", sizeof(struct mempool) ); - exit(EXIT_FAILURE); - } - - // Check minimum initial count / realloc count requirements. - if(initial_count < 50) - initial_count = 50; - if(realloc_count < 50) - realloc_count = 50; - - // Set Reallocation threshold to 5% of realloc_count, at least 10. - realloc_thresh = (realloc_count/100)*5; // - if(realloc_thresh < 10) - realloc_thresh = 10; - - // Initialize members.. - pool->name = aStrdup(name); - pool->elem_size = ALIGN_TO_16(elem_size); - pool->elem_realloc_step = realloc_count; - pool->elem_realloc_thresh = realloc_thresh; - pool->onalloc = onNodeAlloc; - pool->ondealloc = onNodeDealloc; - - InitializeSpinLock(&pool->segmentLock); - InitializeSpinLock(&pool->nodeLock); - - // Initial Statistic values: - pool->num_nodes_total = 0; - pool->num_nodes_free = 0; - pool->num_segments = 0; - pool->num_bytes_total = 0; - pool->peak_nodes_used = 0; - pool->num_realloc_events = 0; - - // -#ifdef MEMPOOL_DEBUG - ShowDebug("Mempool [%s] Init (ElemSize: %u, Initial Count: %u, Realloc Count: %u)\n", pool->name, pool->elem_size, initial_count, pool->elem_realloc_step); -#endif - - // Allocate first segment directly :) - segment_allocate_add(pool, initial_count); - - - // Add Pool to the global pool list - EnterSpinLock(&l_mempoolListLock); - pool->next = l_mempoolList; - l_mempoolList = pool; - LeaveSpinLock(&l_mempoolListLock); - - - return pool; -}//end: mempool_create() - - -void mempool_destroy(pMempool p){ - struct pool_segment *seg, *segnext; - struct node *niter; - pMempool piter, pprev; - char *ptr; - int64 i; - -#ifdef MEMPOOL_DEBUG - ShowDebug("Mempool [%s] Destroy\n", p->name); -#endif - - // Unlink from global list. - EnterSpinLock(&l_mempoolListLock); - piter = l_mempoolList; - pprev = l_mempoolList; - while(1){ - if(piter == NULL) - break; - - - if(piter == p){ - // unlink from list, - // - if(pprev == l_mempoolList){ - // this (p) is list begin. so set next as head. - l_mempoolList = p->next; - }else{ - // replace prevs next wuth our next. - pprev->next = p->next; - } - break; - } - - pprev = piter; - piter = piter->next; - } - - p->next = NULL; - LeaveSpinLock(&l_mempoolListLock); - - - // Get both locks. - EnterSpinLock(&p->segmentLock); - EnterSpinLock(&p->nodeLock); - - - if(p->num_nodes_free != p->num_nodes_total) - ShowWarning("Mempool [%s] Destroy - %u nodes are not freed properly!\n", p->name, (p->num_nodes_total - p->num_nodes_free) ); - - // Free All Segments (this will also free all nodes) - // The segment pointer is the base pointer to the whole segment. - seg = p->segments; - while(1){ - if(seg == NULL) - break; - - segnext = seg->next; - - // .. - if(p->ondealloc != NULL){ - // walk over the segment, and call dealloc callback! - ptr = (char*)seg; - ptr += ALIGN_TO_16(sizeof(struct pool_segment)); - for(i = 0; i < seg->num_nodes_total; i++){ - niter = (struct node*)ptr; - ptr += sizeof(struct node); - ptr += p->elem_size; -#ifdef MEMPOOLASSERT - if(niter->magic != NODE_MAGIC){ - ShowError("Mempool [%s] Destroy - walk over segment - node %p invalid magic!\n", p->name, niter); - continue; - } -#endif - - p->ondealloc( NODE_TO_DATA(niter) ); - - - } - }//endif: ondealloc callback? - - // simple .. - aFree(seg); - - seg = segnext; - } - - // Clear node ptr - p->free_list = NULL; - InterlockedExchange64(&p->num_nodes_free, 0); - InterlockedExchange64(&p->num_nodes_total, 0); - InterlockedExchange64(&p->num_segments, 0); - InterlockedExchange64(&p->num_bytes_total, 0); - - LeaveSpinLock(&p->nodeLock); - LeaveSpinLock(&p->segmentLock); - - // Free pool itself :D - aFree(p->name); - aFree(p); - -}//end: mempool_destroy() - - -void *mempool_node_get(pMempool p){ - struct node *node; - int64 num_used; - - if(p->num_nodes_free < p->elem_realloc_thresh) - racond_signal(l_async_cond); - - while(1){ - - EnterSpinLock(&p->nodeLock); - - node = p->free_list; - if(node != NULL) - p->free_list = node->next; - - LeaveSpinLock(&p->nodeLock); - - if(node != NULL) - break; - - rathread_yield(); - } - - InterlockedDecrement64(&p->num_nodes_free); - - // Update peak value - num_used = (p->num_nodes_total - p->num_nodes_free); - if(num_used > p->peak_nodes_used){ - InterlockedExchange64(&p->peak_nodes_used, num_used); - } - -#ifdef MEMPOOLASSERT - node->used = true; -#endif - - return NODE_TO_DATA(node); -}//end: mempool_node_get() - - -void mempool_node_put(pMempool p, void *data){ - struct node *node; - - node = DATA_TO_NODE(data); -#ifdef MEMPOOLASSERT - if(node->magic != NODE_MAGIC){ - ShowError("Mempool [%s] node_put failed, given address (%p) has invalid magic.\n", p->name, data); - return; // lost, - } - - { - struct pool_segment *node_seg = node->segment; - if(node_seg->pool != p){ - ShowError("Mempool [%s] node_put faild, given node (data address %p) doesnt belongs to this pool. ( Node Origin is [%s] )\n", p->name, data, node_seg->pool); - return; - } - } - - // reset used flag. - node->used = false; -#endif - - // - EnterSpinLock(&p->nodeLock); - node->next = p->free_list; - p->free_list = node; - LeaveSpinLock(&p->nodeLock); - - InterlockedIncrement64(&p->num_nodes_free); - -}//end: mempool_node_put() - - -mempool_stats mempool_get_stats(pMempool pool){ - mempool_stats stats; - - // initialize all with zeros - memset(&stats, 0x00, sizeof(mempool_stats)); - - stats.num_nodes_total = pool->num_nodes_total; - stats.num_nodes_free = pool->num_nodes_free; - stats.num_nodes_used = (stats.num_nodes_total - stats.num_nodes_free); - stats.num_segments = pool->num_segments; - stats.num_realloc_events= pool->num_realloc_events; - stats.peak_nodes_used = pool->peak_nodes_used; - stats.num_bytes_total = pool->num_bytes_total; - - // Pushing such a large block over the stack as return value isnt nice - // but lazy :) and should be okay in this case (Stats / Debug..) - // if you dont like it - feel free and refactor it. - return stats; -}//end: mempool_get_stats() - diff --git a/src/common/mempool.h b/src/common/mempool.h deleted file mode 100644 index bfd30ef1a0..0000000000 --- a/src/common/mempool.h +++ /dev/null @@ -1,107 +0,0 @@ -#ifndef _rA_MEMPOOL_H_ -#define _rA_MEMPOOL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "cbasetypes.h" - -typedef struct mempool *pMempool; - -typedef void (*memPoolOnNodeAllocationProc)(void *ptr); -typedef void (*memPoolOnNodeDeallocationProc)(void *ptr); - -typedef struct mempool_stats{ - int64 num_nodes_total; - int64 num_nodes_free; - int64 num_nodes_used; - - int64 num_segments; - int64 num_realloc_events; - - int64 peak_nodes_used; - - int64 num_bytes_total; -} mempool_stats; - - -// -void mempool_init(); -void mempool_final(); - - -/** - * Creates a new Mempool - * - * @param name - Name of the pool (used for debug / error messages) - * @param elem_size - size of each element - * @param initial_count - preallocation count - * @param realloc_count - #no of nodes being allocated when pool is running empty. - * @param onNodeAlloc - Node Allocation callback (see @note!) - * @param onNodeDealloc - Node Deallocation callback (see @note!) - * - * @note: - * The onNode(De)alloc callbacks are only called once during segment allocation - * (pool initialization / rallocation ) - * you can use this callbacks for example to initlaize a mutex or somethingelse - * you definitly need during runtime - * - * @return not NULL - */ -pMempool mempool_create(const char *name, - uint64 elem_size, - uint64 initial_count, - uint64 realloc_count, - - memPoolOnNodeAllocationProc onNodeAlloc, - memPoolOnNodeDeallocationProc onNodeDealloc); - - -/** - * Destroys a Mempool - * - * @param pool - the mempool to destroy - * - * @note: - * Everything gets deallocated, regardless if everything was freed properly! - * So you have to ensure that all references are cleared properly! - */ -void mempool_destroy(pMempool pool); - - -/** - * Gets a new / empty node from the given mempool. - * - * @param pool - the pool to get an empty node from. - * - * @return Address of empty Node - */ -void *mempool_node_get(pMempool pool); - - -/** - * Returns the given node to the given mempool - * - * @param pool - the pool to put the node, to - * @param node - the node to return - */ -void mempool_node_put(pMempool pool, void *node); - - -/** - * Returns Statistics for the given mempool - * - * @param pool - the pool to get thats for - * - * @note: i dont like pushing masses of values over the stack, too - but its lazy and okay for stats. (blacksirius) - * - * @return stats struct - */ -mempool_stats mempool_get_stats(pMempool pool); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/common/mmo.h b/src/common/mmo.hpp similarity index 99% rename from src/common/mmo.h rename to src/common/mmo.hpp index de1e253bcf..b188904e14 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.hpp @@ -1,16 +1,16 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _MMO_H_ -#define _MMO_H_ +#ifndef _MMO_HPP_ +#define _MMO_HPP_ -#include "cbasetypes.h" -#include "../config/core.h" -#include "db.h" +#include "cbasetypes.hpp" +#include "../config/core.hpp" +#include "db.hpp" #include #ifndef PACKETVER - #error Please define PACKETVER in src/config/packets.h + #error Please define PACKETVER in src/config/packets.hpp #endif ///Remove/Comment this line to disable sc_data saving. [Skotlex] @@ -1031,4 +1031,4 @@ struct clan{ #define MAX_CARTS 5 #endif -#endif /* _MMO_H_ */ +#endif /* _MMO_HPP_ */ diff --git a/src/common/msg_conf.c b/src/common/msg_conf.cpp similarity index 94% rename from src/common/msg_conf.c rename to src/common/msg_conf.cpp index 0cd5337ffe..471ca5da67 100644 --- a/src/common/msg_conf.c +++ b/src/common/msg_conf.cpp @@ -2,9 +2,9 @@ #include #include -#include "malloc.h" -#include "msg_conf.h" -#include "showmsg.h" +#include "malloc.hpp" +#include "msg_conf.hpp" +#include "showmsg.hpp" /* * Return the message string of the specified number by [Yor] @@ -62,7 +62,7 @@ int _msg_config_read(const char* cfgName,int size, char ** msg_table) } fclose(fp); - ShowInfo("Done reading "CL_WHITE"'%d'"CL_RESET" messages in "CL_WHITE"'%s'"CL_RESET".\n",msg_count,cfgName); + ShowInfo("Done reading " CL_WHITE "'%d'" CL_RESET " messages in " CL_WHITE "'%s'" CL_RESET ".\n",msg_count,cfgName); return 0; } diff --git a/src/common/msg_conf.h b/src/common/msg_conf.hpp similarity index 85% rename from src/common/msg_conf.h rename to src/common/msg_conf.hpp index d1feeb1d4c..f9a36f9b37 100644 --- a/src/common/msg_conf.h +++ b/src/common/msg_conf.hpp @@ -1,14 +1,10 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef MSG_CONF_H -#define MSG_CONF_H +#ifndef MSG_CONF_HPP +#define MSG_CONF_HPP -#include "../config/core.h" - -#ifdef __cplusplus -extern "C" { -#endif +#include "../config/core.hpp" enum lang_types { LANG_RUS = 0x01, @@ -42,9 +38,5 @@ const char* msg_langtype2langstr(int langtype); // Verify that the choosen langtype is enabled. int msg_checklangtype(int lang, bool display); -#ifdef __cplusplus -} -#endif - -#endif /* MSG_CONF_H */ +#endif /* MSG_CONF_HPP */ diff --git a/src/common/mutex.c b/src/common/mutex.c deleted file mode 100644 index 6bf1fc86fc..0000000000 --- a/src/common/mutex.c +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifdef WIN32 -#include "winapi.hpp" -#else -#include - -#endif - -#include "cbasetypes.h" -#include "malloc.h" -#include "showmsg.h" -#include "timer.h" -#include "mutex.h" - -struct ramutex{ -#ifdef WIN32 - CRITICAL_SECTION hMutex; -#else - pthread_mutex_t hMutex; -#endif -}; - - -struct racond{ -#ifdef WIN32 - HANDLE events[2]; - ra_align(8) volatile LONG nWaiters; - CRITICAL_SECTION waiters_lock; - -#define EVENT_COND_SIGNAL 0 -#define EVENT_COND_BROADCAST 1 - -#else - pthread_cond_t hCond; -#endif -}; - - -//////////////////// -// Mutex -// -// Implementation: -// - - -ramutex ramutex_create(){ - struct ramutex *m; - - m = (struct ramutex*)aMalloc( sizeof(struct ramutex) ); - if(m == NULL){ - ShowFatalError("ramutex_create: OOM while allocating %u bytes.\n", sizeof(struct ramutex)); - return NULL; - } - -#ifdef WIN32 - InitializeCriticalSection(&m->hMutex); -#else - pthread_mutex_init(&m->hMutex, NULL); -#endif - - return m; -}//end: ramutex_create() - - -void ramutex_destroy( ramutex m ){ - -#ifdef WIN32 - DeleteCriticalSection(&m->hMutex); -#else - pthread_mutex_destroy(&m->hMutex); -#endif - - aFree(m); - -}//end: ramutex_destroy() - - -void ramutex_lock( ramutex m ){ - -#ifdef WIN32 - EnterCriticalSection(&m->hMutex); -#else - pthread_mutex_lock(&m->hMutex); -#endif -}//end: ramutex_lock - - -bool ramutex_trylock( ramutex m ){ -#ifdef WIN32 - if(TryEnterCriticalSection(&m->hMutex) == TRUE) - return true; - - return false; -#else - if(pthread_mutex_trylock(&m->hMutex) == 0) - return true; - - return false; -#endif -}//end: ramutex_trylock() - - -void ramutex_unlock( ramutex m ){ -#ifdef WIN32 - LeaveCriticalSection(&m->hMutex); -#else - pthread_mutex_unlock(&m->hMutex); -#endif - -}//end: ramutex_unlock() - - - -/////////////// -// Condition Variables -// -// Implementation: -// - -racond racond_create(){ - struct racond *c; - - c = (struct racond*)aMalloc( sizeof(struct racond) ); - if(c == NULL){ - ShowFatalError("racond_create: OOM while allocating %u bytes\n", sizeof(struct racond)); - return NULL; - } - -#ifdef WIN32 - c->nWaiters = 0; - c->events[ EVENT_COND_SIGNAL ] = CreateEvent( NULL, FALSE, FALSE, NULL ); - c->events[ EVENT_COND_BROADCAST ] = CreateEvent( NULL, TRUE, FALSE, NULL ); - InitializeCriticalSection( &c->waiters_lock ); -#else - pthread_cond_init(&c->hCond, NULL); -#endif - - return c; -}//end: racond_create() - - -void racond_destroy( racond c ){ -#ifdef WIN32 - CloseHandle( c->events[ EVENT_COND_SIGNAL ] ); - CloseHandle( c->events[ EVENT_COND_BROADCAST ] ); - DeleteCriticalSection( &c->waiters_lock ); -#else - pthread_cond_destroy(&c->hCond); -#endif - - aFree(c); -}//end: racond_destroy() - - -void racond_wait( racond c, ramutex m, sysint timeout_ticks){ -#ifdef WIN32 - register DWORD ms; - int result; - bool is_last = false; - - - EnterCriticalSection(&c->waiters_lock); - c->nWaiters++; - LeaveCriticalSection(&c->waiters_lock); - - if(timeout_ticks < 0) - ms = INFINITE; - else - ms = (timeout_ticks > MAXDWORD) ? (MAXDWORD - 1) : (DWORD)timeout_ticks; - - - // we can release the mutex (m) here, cause win's - // manual reset events maintain state when used with - // SetEvent() - ramutex_unlock(m); - - result = WaitForMultipleObjects(2, c->events, FALSE, ms); - - - EnterCriticalSection(&c->waiters_lock); - c->nWaiters--; - if( (result == WAIT_OBJECT_0 + EVENT_COND_BROADCAST) && (c->nWaiters == 0) ) - is_last = true; // Broadcast called! - LeaveCriticalSection(&c->waiters_lock); - - - - // we are the last waiter that has to be notified, or to stop waiting - // so we have to do a manual reset - if(is_last == true) - ResetEvent( c->events[EVENT_COND_BROADCAST] ); - - - ramutex_lock(m); - -#else - if(timeout_ticks < 0){ - pthread_cond_wait( &c->hCond, &m->hMutex ); - }else{ - struct timespec wtime; - int64 exact_timeout = gettick() + timeout_ticks; - - wtime.tv_sec = exact_timeout/1000; - wtime.tv_nsec = (exact_timeout%1000)*1000000; - - pthread_cond_timedwait( &c->hCond, &m->hMutex, &wtime); - } - -#endif -}//end: racond_wait() - - -void racond_signal( racond c ){ -#ifdef WIN32 -// bool has_waiters = false; -// EnterCriticalSection(&c->waiters_lock); -// if(c->nWaiters > 0) -// has_waiters = true; -// LeaveCriticalSection(&c->waiters_lock); - -// if(has_waiters == true) - SetEvent( c->events[ EVENT_COND_SIGNAL ] ); -#else - pthread_cond_signal(&c->hCond); -#endif -}//end: racond_signal() - - -void racond_broadcast( racond c ){ -#ifdef WIN32 -// bool has_waiters = false; -// EnterCriticalSection(&c->waiters_lock); -// if(c->nWaiters > 0) -// has_waiters = true; -// LeaveCriticalSection(&c->waiters_lock); - -// if(has_waiters == true) - SetEvent( c->events[ EVENT_COND_BROADCAST ] ); -#else - pthread_cond_broadcast(&c->hCond); -#endif -}//end: racond_broadcast() - - diff --git a/src/common/mutex.h b/src/common/mutex.h deleted file mode 100644 index 1999627cdb..0000000000 --- a/src/common/mutex.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _rA_MUTEX_H_ -#define _rA_MUTEX_H_ - - -typedef struct ramutex *ramutex; // Mutex -typedef struct racond *racond; // Condition Var - -/** - * Creates a Mutex - * - * @return not NULL - */ -ramutex ramutex_create(); - -/** - * Destroys a Mutex - * - * @param m - the mutex to destroy - */ -void ramutex_destroy( ramutex m ); - -/** - * Gets a lock - * - * @param m - the mutex to lock - */ -void ramutex_lock( ramutex m); - -/** - * Trys to get the Lock - * - * @param m - the mutex try to lock - * - * @return boolean (true = got the lock) - */ -bool ramutex_trylock( ramutex m ); - -/** - * Unlocks a mutex - * - * @param m - the mutex to unlock - */ -void ramutex_unlock( ramutex m); - - -/** - * Creates a Condition variable - * - * @return not NULL - */ -racond racond_create(); - -/** - * Destroy a Condition variable - * - * @param c - the condition varaible to destroy - */ -void racond_destroy( racond c ); - -/** - * Waits Until state is signalled - * - * @param c - the condition var to wait for signalled state - * @param m - the mutex used for syncronization - * @param timeout_ticks - timeout in ticks ( -1 = INFINITE ) - */ -void racond_wait( racond c, ramutex m, sysint timeout_ticks); - -/** - * Sets the given condition var to signalled state - * - * @param c - condition var to set in signalled state. - * - * @note: - * Only one waiter gets notified. - */ -void racond_signal( racond c ); - -/** - * Sets notifys all waiting threads thats signalled. - * @param c - condition var to set in signalled state - * - * @note: - * All Waiters getting notified. - */ -void racond_broadcast( racond c ); - - -#endif diff --git a/src/common/netbuffer.c b/src/common/netbuffer.c deleted file mode 100644 index 37bac53e2e..0000000000 --- a/src/common/netbuffer.c +++ /dev/null @@ -1,206 +0,0 @@ - -// -// Network Buffer Subsystem (iobuffer) -// -// -// Author: Florian Wilkemeyer -// -// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL -// For more information, see LICENCE in the main folder -// -// - - -// -// Buffers are available in the following sizes: -// 48, 192, 2048, 8192 -// 65536 (inter server connects may use it for charstatus struct..) -// - - -/// -// Implementation: -// -static volatile int32 l_nEmergencyAllocations = 0; // stats. -static sysint l_nPools = 0; -static sysint *l_poolElemSize = NULL; -static mempool *l_pool = NULL; - - -void netbuffer_init(){ - char localsection[32]; - raconf conf; - sysint i; - - // Initialize Statistic counters: - l_nEmergencyAllocations = 0; - - // Set localsection name according to running serverype. - switch(SERVER_TYPE){ - case ATHENA_SERVER_LOGIN: strcpy(localsection, "login-netbuffer"); break; - case ATHENA_SERVER_CHAR: strcpy(localsection, "char-netbuffer"); break; - case ATHENA_SERVER_INTER: strcpy(localsection, "inter-netbuffer"); break; - case ATHENA_SERVER_MAP: strcpy(localsection, "map-netbuffer"); break; - default: strcpy(localsection, "unsupported_type"); break; - } - - - conf = raconf_parse("conf/network.conf"); - if(conf == NULL){ - ShowFatalError("Failed to Parse required Configuration (conf/network.conf)"); - exit(EXIT_FAILURE); - } - - // Get Values from config file - l_nPools = (sysint)raconf_getintEx(conf, localsection, "netbuffer", "num", 0); - if(l_nPools == 0){ - ShowFatalError("Netbuffer (network.conf) failure - requires at least 1 Pool.\n"); - exit(EXIT_FAILURE); - } - - // Allocate arrays. - l_poolElemSize = (sysint*)aCalloc( l_nPools, sizeof(sysint) ); - l_pool = (mempool*)aCalloc( l_nPools, sizeof(mempool) ); - - - for(i = 0; i < l_nPools; i++){ - int64 num_prealloc, num_realloc; - char key[32]; - - sprintf(key, "pool_%u_size", (uint32)i+1); - l_poolElemSize[i] = (sysint)raconf_getintEx(conf, localsection, "netbuffer", key, 4096); - if(l_poolElemSize[i] < 32){ - ShowWarning("Netbuffer (network.conf) failure - minimum allowed buffer size is 32 byte) - fixed.\n"); - l_poolElemSize[i] = 32; - } - - sprintf(key, "pool_%u_prealloc", (uint32)i+1); - num_prealloc = raconf_getintEx(conf, localsection, "netbuffer", key, 150); - - sprintf(key, "pool_%u_realloc_step", (uint32)i+1); - num_realloc = raconf_getintEx(conf, localsection, "netbuffer", key, 100); - - // Create Pool! - sprintf(key, "Netbuffer %u", (uint32)l_poolElemSize[i]); // name. - - // Info - ShowInfo("NetBuffer: Creating Pool %u (Prealloc: %u, Realloc Step: %u) - %0.2f MiB\n", l_poolElemSize[i], num_prealloc, num_realloc, (float)((sizeof(struct netbuf) + l_poolElemSize[i] - 32)* num_prealloc)/1024.0f/1024.0f); - - // - // Size Calculation: - // struct netbuf + requested buffer size - 32 (because the struct already contains 32 byte buffer space at the end of struct) - l_pool[i] = mempool_create(key, (sizeof(struct netbuf) + l_poolElemSize[i] - 32), num_prealloc, num_realloc, NULL, NULL); - if(l_pool[i] == NULL){ - ShowFatalError("Netbuffer: cannot create Pool for %u byte buffers.\n", l_poolElemSize[i]); - // @leak: clean everything :D - exit(EXIT_FAILURE); - } - - }// - - - raconf_destroy(conf); - -}//end: netbuffer_init() - - -void netbuffer_final(){ - sysint i; - - if(l_nPools > 0){ - /// .. finalize mempools - for(i = 0; i < l_nPools; i++){ - mempool_stats stats = mempool_get_stats(l_pool[i]); - - ShowInfo("Netbuffer: Freeing Pool %u (Peak Usage: %u, Realloc Events: %u)\n", l_poolElemSize[i], stats.peak_nodes_used, stats.num_realloc_events); - - mempool_destroy(l_pool[i]); - } - - if(l_nEmergencyAllocations > 0){ - ShowWarning("Netbuffer: did %u Emergency Allocations, please tune your network.conf!\n", l_nEmergencyAllocations); - l_nEmergencyAllocations = 0; - } - - aFree(l_poolElemSize); l_poolElemSize = NULL; - aFree(l_pool); l_pool = NULL; - l_nPools = 0; - } - - -}//end: netbuffer_final() - - -netbuf netbuffer_get( sysint sz ){ - sysint i; - netbuf nb = NULL; - - // Search an appropriate pool - for(i = 0; i < l_nPools; i++){ - if(sz <= l_poolElemSize[i]){ - // match - - nb = (netbuf)mempool_node_get(l_pool[i]); - nb->pool = i; - - break; - } - } - - // No Bufferpool found that mets there quirements?.. (thats bad..) - if(nb == NULL){ - ShowWarning("Netbuffer: get(%u): => no appropriate pool found - emergency allocation required.\n", sz); - ShowWarning("Please reconfigure your network.conf!"); - - InterlockedIncrement(&l_nEmergencyAllocations); - - // .. better to check (netbuf struct provides 32 byte bufferspace itself. - if(sz < 32) sz = 32; - - // allocate memory using malloc .. - while(1){ - nb = (netbuf) aMalloc( (sizeof(struct netbuf) + sz - 32) ); - if(nb != NULL){ - memset(nb, 0x00, (sizeof(struct netbuf) + sz - 32) ); // zero memory! (to enforce commit @ os.) - nb->pool = -1; // emergency alloc. - break; - } - - rathread_yield(); - }// spin allocation. - - } - - - nb->refcnt = 1; // Initial refcount is 1 - - return nb; -}//end: netbuffer_get() - - -void netbuffer_put( netbuf nb ){ - - // Decrement reference counter, if > 0 do nothing :) - if( InterlockedDecrement(&nb->refcnt) > 0 ) - return; - - // Is this buffer an emergency allocated buffer? - if(nb->pool == -1){ - aFree(nb); - return; - } - - - // Otherwise its a normal mempool based buffer - // return it to the according mempool: - mempool_node_put( l_pool[nb->pool], nb); - - -}//end: netbuffer_put() - - -void netbuffer_incref( netbuf nb ){ - - InterlockedIncrement(&nb->refcnt); - -}//end: netbuf_incref() diff --git a/src/common/netbuffer.h b/src/common/netbuffer.h deleted file mode 100644 index 236c60f222..0000000000 --- a/src/common/netbuffer.h +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _rA_NETBUFFER_H_ -#define _rA_NETBUFFER_H_ - -#include "cbasetypes.h" - -typedef struct netbuf{ - sysint pool; // The pool ID this buffer belongs to, - // is set to -1 if its an emergency allocated buffer - - struct netbuf *next; // Used by Network system. - - volatile int32 refcnt; // Internal Refcount, it gets lowered every call to netbuffer_put, - // if its getting zero, the buffer will returned back to the pool - // and can be reused. - - int32 dataPos; // Current Offset - // Used only for Reading (recv job) - // write cases are using the sessions local datapos member due to - // shared write buffer support. - - int32 dataLen; // read buffer case: - // The length expected to read to. - // when this->dataPos == dateLen, read job has been completed. - // write buffer case: - // The lngth of data in te buffer - // when s->dataPos == dataLen, write job has been completed - // - // Note: - // leftBytes = (dateLen - dataPos) - // - // Due to shared buffer support - // dataPos gets not used in write case (each connection has its local offset) - // - - // The Bufferspace itself. - char buf[32]; -} *netbuf; - - -void netbuffer_init(); -void netbuffer_final(); - -/** - * Gets a netbuffer that has atleast (sz) byes space. - * - * @note: The netbuffer system guarantees that youll always recevie a buffer. - * no check for null is required! - * - * @param sz - minimum size needed. - * - * @return pointer to netbuf struct - */ -netbuf netbuffer_get( sysint sz ); - - -/** - * Returns the given netbuffer (decreases refcount, if its 0 - the buffer will get returned to the pool) - * - * @param buf - the buffer to return - */ -void netbuffer_put( netbuf buf ); - - -/** - * Increases the Refcount on the given buffer - * (used for areasends .. etc) - * - */ -void netbuffer_incref( netbuf buf ); - - -// Some Useful macros -#define NBUFP(netbuf,pos) (((uint8*)(netbuf->buf)) + (pos)) -#define NBUFB(netbuf,pos) (*(uint8*)((netbuf->buf) + (pos))) -#define NBUFW(netbuf,pos) (*(uint16*)((netbuf->buf) + (pos))) -#define NBUFL(netbuf,pos) (*(uint32*)((netbuf->buf) + (pos))) - - - -#endif diff --git a/src/common/network.c b/src/common/network.c deleted file mode 100644 index e958bff33c..0000000000 --- a/src/common/network.c +++ /dev/null @@ -1,1034 +0,0 @@ -// -// Network Subsystem (previously known as socket system) -// -// Author: Florian Wilkemeyer -// -// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL -// For more information, see LICENCE in the main folder -// -// -//#ifdef HAVE_ACCETP4 -#define _GNU_SOURCE -//#endif - - -#define ENABLE_IPV6 -#define HAVE_ACCEPT4 -#define EVENTS_PER_CYCLE 10 -#define PARANOID_CHECKS - -// Local Vars (settings..) -static int l_ListenBacklog = 64; - -// -// Global Session Array (previously exported as session[] -// -SESSION g_Session[MAXCONN]; - - -// -static bool onSend(int32 fd); - - -#define _network_free_netbuf_async( buf ) add_timer( 0, _network_async_free_netbuf_proc, 0, (intptr_t) buf) -static int _network_async_free_netbuf_proc(int tid, unsigned int tick, int id, intptr_t data){ - // netbuf is in data - netbuffer_put( (netbuf)data ); - - return 0; -}//end: _network_async_free_netbuf_proc() - - - -void network_init(){ - SESSION *s; - int32 i; - - memset(g_Session, 0x00, (sizeof(SESSION) * MAXCONN) ); - - for(i = 0; i < MAXCONN; i++){ - s = &g_Session[i]; - - s->type = NST_FREE; - s->disconnect_in_progress = false; - } - - // Initialize the corresponding event dispatcher - evdp_init(); - - // - add_timer_func_list(_network_async_free_netbuf_proc, "_network_async_free_netbuf_proc"); - -}//end: network_init() - - -void network_final(){ - - // @TODO: - // .. disconnect and cleanup everything! - - evdp_final(); - -}//end: network_final() - - -void network_do(){ - struct EVDP_EVENT l_events[EVENTS_PER_CYCLE]; - register struct EVDP_EVENT *ev; - register int n, nfds; - register SESSION *s; - - nfds = evdp_wait( l_events, EVENTS_PER_CYCLE, 1000); // @TODO: timer_getnext() - - for(n = 0; n < nfds; n++){ - ev = &l_events[n]; - s = &g_Session[ ev->fd ]; - - if(ev->events & EVDP_EVENT_HUP){ - network_disconnect( ev->fd ); - continue; // no further event processing. - }// endif vent is HUP (disconnect) - - - if(ev->events & EVDP_EVENT_IN){ - - if(s->onRecv != NULL){ - if( false == s->onRecv(ev->fd) ){ - network_disconnect(ev->fd); - continue; // .. - } - }else{ - ShowError("network_do: fd #%u has no onRecv proc set. - disconnecting\n", ev->fd); - network_disconnect(ev->fd); - continue; - } - - }// endif event is IN (recv) - - - if(ev->events & EVDP_EVENT_OUT){ - if(s->onSend != NULL){ - if( false == s->onSend(ev->fd) ){ - network_disconnect(ev->fd); - continue; - } - }else{ - ShowError("network_do: fd #%u has no onSend proc set. - disconnecting\n", ev->fd); - network_disconnect(ev->fd); - continue; - } - }// endif event is OUT (send) - - }//endfor - -}//end: network_do() - - -static bool _setnonblock(int32 fd){ - int flags = fcntl(fd, F_GETFL, 0); - if(fcntl(fd, F_SETFL, flags | O_NONBLOCK) != 0) - return false; - - return true; -}//end: _setnonblock() - - -static bool _network_accept(int32 fd){ - SESSION *listener = &g_Session[fd]; - SESSION *s; - union{ - struct sockaddr_in v4; -#ifdef ENABLE_IPV6 - struct sockaddr_in6 v6; -#endif - } _addr; - int newfd; - socklen_t addrlen; - struct sockaddr *addr; - - // Accept until OS returns - nothing to accept anymore - // - this is required due to our EVDP abstraction. (which handles on listening sockets similar to epoll's EPOLLET flag.) - while(1){ -#ifdef ENABLE_IPV6 - if(listener->v6 == true){ - addrlen = sizeof(_addr.v6); - addr = (struct sockaddr*)&_addr.v6; - }else{ -#endif - addrlen = sizeof(_addr.v4); - addr = (struct sockaddr*)&_addr.v4; -#ifdef ENABLE_IPV6 - } -#endif - -#ifdef HAVE_ACCEPT4 - newfd = accept4(fd, addr, &addrlen, SOCK_NONBLOCK); -#else - newfd = accept(fd, addr, &addrlen); -#endif - - if(newfd == -1){ - if(errno == EAGAIN || errno == EWOULDBLOCK) - break; // this is fully valid & whished., se explaination on top of while(1) - - // Otherwis .. we have serious problems :( seems tahat our listner has gone away.. - // @TODO handle this .. - ShowError("_network_accept: accept() returned error. closing listener. (errno: %u / %s)\n", errno, strerror(errno)); - - return false; // will call disconnect after return. - //break; - } - -#ifndef HAVE_ACCEPT4 // no accept4 means, we have to set nonblock by ourself. .. - if(_setnonblock(newfd) == false){ - ShowError("_network_accept: failed to set newly accepted connection nonblocking (errno: %u / %s). - disconnecting.\n", errno, strerror(errno)); - close(newfd); - continue; - } -#endif - - // Check connection limits. - if(newfd >= MAXCONN){ - ShowError("_network_accept: failed to accept connection - MAXCONN (%u) exceeded.\n", MAXCONN); - close(newfd); - continue; // we have to loop over the events (and disconnect them too ..) but otherwise we would leak event notifications. - } - - - // Create new Session. - s = &g_Session[newfd]; - s->type = NST_CLIENT; - - // The new connection inherits listenr's handlers. - s->onDisconnect = listener->onDisconnect; - s->onConnect = listener->onConnect; // maybe useless but .. fear the future .. :~ - - // Register the new connection @ EVDP - if( evdp_addclient(newfd, &s->evdp_data) == false){ - ShowError("_network_accept: failed to accept connection - event subsystem returned an error.\n"); - close(newfd); - s->type = NST_FREE; - } - - // Call the onConnect handler on the listener. - if( listener->onConnect(newfd) == false ){ - // Resfused by onConnect handler.. - evdp_remove(newfd, &s->evdp_data); - - close(newfd); - s->type = NST_FREE; - - s->data = NULL; // be on the safe side ~ ! - continue; - } - - - } - - return true; -}//end: _network_accept() - - -void network_disconnect(int32 fd){ - SESSION *s = &g_Session[fd]; - netbuf b, bn; - - // Prevent recursive calls - // by wrong implemented on disconnect handlers.. and such.. - if(s->disconnect_in_progress == true) - return; - - s->disconnect_in_progress = true; - - - // Disconnect Todo: - // - Call onDisconnect Handler - // - Release all Assigned buffers. - // - remove from event system (notifications) - // - cleanup session structure - // - close connection. - // - - if(s->onDisconnect != NULL && - s->type != NST_LISTENER){ - - s->onDisconnect( fd ); - } - - // Read Buffer - if(s->read.buf != NULL){ - netbuffer_put(s->read.buf); - s->read.buf = NULL; - } - - // Write Buffer(s) - b = s->write.buf; - while(1){ - if(b == NULL) break; - - bn = b->next; - - netbuffer_put(b); - - b = bn; - } - s->write.buf = NULL; - s->write.buf_last = NULL; - - s->write.n_outstanding = 0; - s->write.max_outstanding = 0; - - - // Remove from event system. - evdp_remove(fd, &s->evdp_data); - - // Cleanup Session Structure. - s->type = NST_FREE; - s->data = NULL; // no application level data assigned - s->disconnect_in_progress = false; - - - // Close connection - close(fd); - -}//end: network_disconnect() - - -int32 network_addlistener(bool v6, const char *addr, uint16 port){ - SESSION *s; - int fd; -#ifdef SO_REUSEADDR - int optval; -#endif - -#if !defined(ENABLE_IPV6) - if(v6 == true){ - ShowError("network_addlistener(%c, '%s', %u): this release has no IPV6 support.\n", (v6==true?'t':'f'), addr, port); - return -1; - } -#endif - -#ifdef ENABLE_IPV6 - if(v6 == true) - fd = socket(AF_INET6, SOCK_STREAM, 0); - else -#endif - fd = socket(AF_INET, SOCK_STREAM, 0); - - // Error? - if(fd == -1){ - ShowError("network_addlistener(%c, '%s', %u): socket() failed (errno: %u / %s)\n", (v6==true?'t':'f'), addr, port, errno, strerror(errno)); - return -1; - } - - // Too many connections? - if(fd >= MAXCONN){ - ShowError("network_addlistener(%c, '%s', %u): cannot create listener, exceeds more than supported connections (%u).\n", (v6==true?'t':'f'), addr, port, MAXCONN); - close(fd); - return -1; - } - - s = &g_Session[fd]; - if(s->type != NST_FREE){ // additional checks.. :) - ShowError("network_addlistener(%c, '%s', %u): failed, got fd #%u which is already in use in local session table?!\n", (v6==true?'t':'f'), addr, port, fd); - close(fd); - return -1; - } - - // Fill ip addr structs -#ifdef ENABLE_IPV6 - if(v6 == true){ - memset(&s->addr.v6, 0x00, sizeof(s->addr.v6)); - s->addr.v6.sin6_family = AF_INET6; - s->addr.v6.sin6_port = htons(port); - if(inet_pton(AF_INET6, addr, &s->addr.v6.sin6_addr) != 1){ - ShowError("network_addlistener(t, '%s', %u): failed to parse the given IPV6 address.\n", addr, port); - close(fd); - return -1; - } - }else{ -#endif - memset(&s->addr.v4, 0x00, sizeof(s->addr.v4)); - s->addr.v4.sin_family = AF_INET; - s->addr.v4.sin_port = htons(port); - s->addr.v4.sin_addr.s_addr = inet_addr(addr); -#ifdef ENABLE_IPV6 - } -#endif - - // if OS has support for SO_REUSEADDR, apply the flag - // so the address could be used when there're still time_wait sockets outstanding from previous application run. -#ifdef SO_REUSEADDR - optval = 1; - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); -#endif - - // Bind -#ifdef ENABLE_IPV6 - if(v6 == true){ - if( bind(fd, (struct sockaddr*)&s->addr.v6, sizeof(s->addr.v6)) == -1) { - ShowError("network_addlistener(t, '%s', %u): bind failed (errno: %u / %s)\n", addr, port, errno, strerror(errno)); - close(fd); - return -1; - } - }else{ -#endif - if( bind(fd, (struct sockaddr*)&s->addr.v4, sizeof(s->addr.v4)) == -1) { - ShowError("network_addlistener(f, '%s', %u): bind failed (errno: %u / %s)\n", addr, port, errno, strerror(errno)); - close(fd); - return -1; - } -#ifdef ENABLE_IPV6 - } -#endif - - if( listen(fd, l_ListenBacklog) == -1){ - ShowError("network_addlistener(%c, '%s', %u): listen failed (errno: %u / %s)\n", (v6==true?'t':'f'), addr, port, errno, strerror(errno)); - close(fd); - return -1; - } - - - // Set to nonblock! - if(_setnonblock(fd) == false){ - ShowError("network_addlistener(%c, '%s', %u): cannot set to nonblock (errno: %u / %s)\n", (v6==true?'t':'f'), addr, port, errno, strerror(errno)); - close(fd); - return -1; - } - - // Rgister @ evdp. - if( evdp_addlistener(fd, &s->evdp_data) != true){ - ShowError("network_addlistener(%c, '%s', %u): eventdispatcher subsystem returned an error.\n", (v6==true?'t':'f'), addr, port); - close(fd); - return -1; - } - - // Apply flags on Session array for this conneciton. - if(v6 == true) s->v6 = true; - else s->v6 = false; - - s->type = NST_LISTENER; - s->onRecv = _network_accept; - - ShowStatus("Added Listener on '%s':%u\n", addr, port, (v6==true ? "(ipv6)":"(ipv4)") ); - - return fd; -}//end: network_addlistener() - - -static bool _network_connect_establishedHandler(int32 fd){ - register SESSION *s = &g_Session[fd]; - int val; - socklen_t val_len; - - if(s->type == NST_FREE) - return true; // due to multiple non coalesced event notifications - // this can happen .. when a previous handled event has already disconnected the connection - // within the same cycle.. - - val = -1; - val_len = sizeof(val); - getsockopt(fd, SOL_SOCKET, SO_ERROR, &val, &val_len); - - if(val != 0){ - // :( .. cleanup session.. - s->type = NST_FREE; - s->onSend = NULL; - s->onConnect = NULL; - s->onDisconnect = NULL; - - evdp_remove(fd, &s->evdp_data); - close(fd); - - return true; // we CANT return false, - // becuase the normal disconnect procedure would execute the ondisconnect handler, which we dont want .. in this case. - }else{ - // ok - if(s->onConnect(fd) == false) { - // onConnect handler has refused the connection .. - // cleanup .. and ok - s->type = NST_FREE; - s->onSend = NULL; - s->onConnect = NULL; - s->onDisconnect = NULL; - - evdp_remove(fd, &s->evdp_data); - close(fd); - - return true; // we dnot want the ondisconnect handler to be executed, so its okay to handle this by ourself. - } - - // connection established ! - // - if( evdp_outgoingconnection_established(fd, &s->evdp_data) == false ){ - return false; // we want the normal disconnect procedure.. with call to ondisconnect handler. - } - - s->onSend = NULL; - - ShowStatus("#%u connection successfull!\n", fd); - } - - return true; -}//end: _network_connect_establishedHandler() - - -int32 network_connect(bool v6, - const char *addr, - uint16 port, - const char *from_addr, - uint16 from_port, - bool (*onConnectionEstablishedHandler)(int32 fd), - void (*onConnectionLooseHandler)(int32 fd) -){ - register SESSION *s; - int32 fd, ret; - struct sockaddr_in ip4; -#ifdef SO_REUSEADDR - int optval; -#endif -#ifdef ENABLE_IPV6 - struct sockaddr_in6 ip6; -#endif - -#ifdef ENABLE_IPV6 - if(v6 == true) - fd = socket(AF_INET6, SOCK_STREAM, 0); - else -#endif - fd = socket(AF_INET, SOCK_STREAM, 0); - -#ifndef ENABLE_IPV6 - // check.. - if(v6 == true){ - ShowError("network_connect(%c, '%s', %u...): tried to create an ipv6 connection, IPV6 is not supported in this release.\n", (v6==true?'t':'f'), addr, port); - return -1; - } -#endif - - // check connection limits. - if(fd >= MAXCONN){ - ShowError("network_connect(%c, '%s', %u...): cannot create new connection, exceeeds more than supported connections (%u)\n", (v6==true?'t':'f'), addr, port ); - close(fd); - return -1; - } - - // Originating IP/Port pair given ? - if(from_addr != NULL && *from_addr != 0){ - //.. - #ifdef SO_REUSEADDR - optval=1; - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); - #endif - - #ifdef ENABLE_IPV6 - if(v6 == true){ - memset(&ip6, 0x00, sizeof(ip6)); - ip6.sin6_family = AF_INET6; - ip6.sin6_port = htons(from_port); - - if(inet_pton(AF_INET6, from_addr, &ip6.sin6_addr) != 1){ - ShowError("network_connect(t, '%s', %u...): cannot parse originating (from) IPV6 address (errno: %u / %s)\n", addr, port, errno, strerror(errno)); - close(fd); - return -1; - } - - ret = bind(fd, (struct sockaddr*)&ip6, sizeof(ip6)); - }else{ - #endif - memset(&ip4, 0x00, sizeof(ip4)); - - ip4.sin_family = AF_INET; - ip4.sin_port = htons(from_port); - ip4.sin_addr.s_addr = inet_addr(from_addr); - ret = bind(fd, (struct sockaddr*)&ip4, sizeof(ip4)); - #ifdef ENABLE_IPV6 - } - #endif - - } - - // Set non block - if(_setnonblock(fd) == false){ - ShowError("network_connect(%c, '%s', %u...): cannot set socket to nonblocking (errno: %u / %s)\n", (v6==true?'t':'f'), addr, port, errno, strerror(errno)); - close(fd); - return -1; - } - - - // Create ip addr block to connect to .. -#ifdef ENABLE_IPV6 - if(v6 == true){ - memset(&ip6, 0x00, sizeof(ip6)); - ip6.sin6_family = AF_INET6; - ip6.sin6_port = htons(port); - - if(inet_pton(AF_INET6, addr, &ip6.sin6_addr) != 1){ - ShowError("network_connect(t, '%s', %u...): cannot parse destination IPV6 address (errno: %u / %s)\n", addr, port, errno, strerror(errno)); - close(fd); - return -1; - } - - }else{ -#endif - memset(&ip4, 0x00, sizeof(ip4)); - - ip4.sin_family = AF_INET; - ip4.sin_port = htons(port); - ip4.sin_addr.s_addr = inet_addr(addr); -#ifdef ENABLE_IPV6 - } -#endif - - // Assign Session.. - s = &g_Session[fd]; - s->type = NST_OUTGOING; - s->v6 = v6; - s->onConnect = onConnectionEstablishedHandler; - s->onDisconnect = onConnectionLooseHandler; - s->onRecv = NULL; - s->onSend = _network_connect_establishedHandler; -#ifdef ENABLE_IPV6 - if(v6 == true) - memcpy(&s->addr.v6, &ip6, sizeof(ip6)); - else -#endif - memcpy(&s->addr.v4, &ip4, sizeof(ip4)); - - // Register @ EVDP. as outgoing (see doc of the function) - if(evdp_addconnecting(fd, &s->evdp_data) == false){ - ShowError("network_connect(%c, '%s', %u...): eventdispatcher subsystem returned an error.\n", (v6==true?'t':'f'), addr, port); - - // cleanup session x.x.. - s->type = NST_FREE; - s->onConnect = NULL; - s->onDisconnect = NULL; - s->onSend = NULL; - - // close, return error code. - close(fd); - return -1; - } - -#ifdef ENABLE_IPV6 - if(v6 == true) - ret = connect(fd, (struct sockaddr*)&ip6, sizeof(ip6)); - else -#endif - ret = connect(fd, (struct sockaddr*)&ip4, sizeof(ip4)); - - - // - if(ret != 0 && errno != EINPROGRESS){ - ShowWarning("network_connect(%c, '%s', %u...): connection failed (errno: %u / %s)\n", (v6==true?'t':'f'), addr, port, errno, strerror(errno)); - - // Cleanup session .. - s->type = NST_FREE; - s->onConnect = NULL; - s->onDisconnect = NULL; - s->onSend = NULL; - - // .. remove from evdp and close fd. - evdp_remove(fd, &s->evdp_data); - close(fd); - return -1; - } - - // ! The Info Message :~D - ShowStatus("network_connect fd#%u (%s:%u) in progress.. \n", fd, addr, port); - -return fd; -}//end: network_connect() - - -static bool _onSend(int32 fd){ - register SESSION *s = &g_Session[fd]; - register netbuf buf, buf_next; - register uint32 szNeeded; - register int wLen; - - if(s->type == NST_FREE) - return true; // Possible due to multipl non coalsced event notifications - // so onSend gets called after disconnect caused by an previous vent. - // we can ignore the call to onSend, then. - - buf = s->write.buf; - while(1){ - if(buf == NULL) - break; - - buf_next = buf->next; - - - szNeeded = (buf->dataLen - s->write.dataPos); // using th session-local .dataPos member, due to shared write buffer support. - - // try to write. - wLen = write(fd, &buf->buf[s->write.dataPos], szNeeded); - if(wLen == 0){ - return false; // eof. - }else if(wLen == -1){ - if(errno == EAGAIN || errno == EWOULDBLOCK) - return true; // dont disconnect / try again later. - - // all other errors. . - return false; - } - - // Wrote data.. => - szNeeded -= wLen; - if(szNeeded > 0){ - // still data left .. - // - s->write.dataPos += wLen; // fix offset. - return true; - }else{ - // this buffer has been written successfully - // could be returned to pool. - netbuffer_put(buf); - s->write.n_outstanding--; // When threadsafe -> Interlocked here. - s->write.dataPos = 0; - } - - - buf = buf_next; - } - - // okay, - // reaching this part means: - // while interrupted by break - - // which means all buffers are written, nothing left - // - - s->write.buf_last = NULL; - s->write.buf = NULL; - s->write.n_outstanding = 0; - s->write.dataPos = 0; - - // Remove from event dispatcher (write notification) - // - evdp_writable_remove(fd, &s->evdp_data); - - return true; -}//end: _onSend() - - -static bool _onRORecv(int32 fd){ - register SESSION *s = &g_Session[fd]; - register uint32 szNeeded; - register char *p; - register int rLen; - - if(s->type == NST_FREE) - return true; // Possible due to multiple non coalesced events by evdp. - // simply ignore this call returning positive result. - - // Initialize p and szNeeded depending on change - // - switch(s->read.state){ - case NRS_WAITOP: - szNeeded = s->read.head_left; - p = ((char*)&s->read.head[0]) + (2-szNeeded); - break; - - case NRS_WAITLEN: - szNeeded = s->read.head_left; - p = ((char*)&s->read.head[1]) + (2-szNeeded); - break; - - case NRS_WAITDATA:{ - register netbuf buf = s->read.buf; - - szNeeded = (buf->dataLen - buf->dataPos); - p = (char*)&buf->buf[ buf->dataPos ]; - } - break; - - default: - // .. the impossible gets possible .. - ShowError("_onRORecv: fd #%u has unknown read.state (%d) - disconnecting\n", fd, s->read.state); - return false; - break; - } - - - // - - rLen = read(fd, p, szNeeded); - if(rLen == 0){ - // eof.. - return false; - }else if(rLen == -1){ - - if(errno == EAGAIN || errno == EWOULDBLOCK){ - // try again later .. (this case shouldnt happen, because we're event trigered.. but .. sometimes it happens :) - return true; - } - - // an additional interesting case would be - // EINTR, this 'could' be handled .. but: - // posix says that its possible that data gets currupted during irq - // or data gor read and not reported.., so we'd have a data loss.. - // (which shouldnt happen with stream based protocols such as tcp) - // its better to disonnect the client in that case. - - return false; - } - - // - // Got Data: - // next action also depends on current state .. - // - szNeeded -= rLen; - switch(s->read.state){ - case NRS_WAITOP: - - if(szNeeded > 0){ - // still data missing .. - s->read.head_left = szNeeded; - return true; // wait for completion. - }else{ - // complete .. - // next state depends on packet type. - - s->read.head[1] = ((uint16*)s->netparser_data)[ s->read.head[0] ]; // store lenght of packet by opcode head[0] to head[1] - - if(s->read.head[1] == ROPACKET_UNKNOWN){ - // unknown packet - disconnect - ShowWarning("_onRORecv: fd #%u got unlnown packet 0x%04x - disconnecting.\n", fd, s->read.head[0]); - return false; - } - else if(s->read.head[1] == ROPACKET_DYNLEN){ - // dynamic length - // next state: requrie len. - s->read.state = NRS_WAITLEN; - s->read.head_left = 2; - return true; // - } - else if(s->read.head[1] == 2){ - // packet has no data (only opcode) - register netbuf buf = netbuffer_get(2); // :D whoohoo its giant! - - NBUFW(buf, 0) = s->read.head[0]; // store opcode @ packet begin. - buf->dataPos = 2; - buf->dataLen = 2; - buf->next = NULL; - - // Back to initial state -> Need opcode. - s->read.state = NRS_WAITOP; - s->read.head_left = 2; - s->read.buf = NULL; - - // Call completion routine here. - s->onPacketComplete(fd, s->read.head[0], 2, buf); - - return true; // done :) - } - else{ - // paket needs .. data .. - register netbuf buf = netbuffer_get( s->read.head[1] ); - - NBUFW(buf, 0) = s->read.head[0]; // store opcode @ packet begin. - buf->dataPos = 2; - buf->dataLen = s->read.head[1]; - buf->next = NULL; - - // attach buffer. - s->read.buf = buf; - - // set state: - s->read.state = NRS_WAITDATA; - - return true; - } - - }//endif: szNeeded > 0 (opcode read completed?) - - break; - - - case NRS_WAITLEN: - - if(szNeeded > 0){ - // incomplete .. - s->read.head_left = szNeeded; - return true; - }else{ - - if(s->read.head[1] == 4){ - // packet has no data (only opcode + length) - register netbuf buf = netbuffer_get( 4 ); - - NBUFL(buf, 0) = *((uint32*)&s->read.head[0]); // copy Opcode + length to netbuffer using MOVL - buf->dataPos = 4; - buf->dataLen = 4; - buf->next = NULL; - - // set initial state (need opcode) - s->read.state = NRS_WAITOP; - s->read.head_left = 2; - s->read.buf = NULL; - - // call completion routine. - s->onPacketComplete(fd, s->read.head[0], 4, buf); - - return true; - } - else if(s->read.head[1] < 4){ - // invalid header. - ShowWarning("_onRORecv: fd #%u invalid header - got packet 0x%04x, reported length < 4 - INVALID - disconnecting\n", fd, s->read.head[0]); - return false; - } - else{ - // Data needed - // next state -> waitdata! - register netbuf buf = netbuffer_get( s->read.head[1] ); - - NBUFL(buf, 0) = *((uint32*)&s->read.head[0]); // copy Opcode + length to netbuffer using MOVL - buf->dataPos = 4; - buf->dataLen = s->read.head[1]; - buf->next = NULL; - - // attach to session: - s->read.buf = buf; - s->read.state = NRS_WAITDATA; - - return true; - } - - }//endif: szNeeded > 0 (length read complete?) - - break; - - - case NRS_WAITDATA: - - if(szNeeded == 0){ - // Packet finished! - // compltion. - register netbuf buf = s->read.buf; - - // set initial state. - s->read.state = NRS_WAITOP; - s->read.head_left = 2; - s->read.buf = NULL; - - // Call completion routine. - s->onPacketComplete(fd, NBUFW(buf, 0), buf->dataLen, buf); - - return true; - }else{ - // still data needed - s->read.buf->dataPos += rLen; - - return true; - } - break; - - - // - default: - ShowError("_onRORecv: fd #%u has unknown read.state (%d) [2] - disconnecting\n", fd, s->read.state); - return false; - break; - } - - - return false; -}//end: _onRORecv() - - -void network_send(int32 fd, netbuf buf){ - register SESSION *s = &g_Session[fd]; - -#ifdef PARANOID_CHECKS - if(fd >= MAXCONN){ - ShowError("network_send: tried to attach buffer to connection idientifer #%u which is out of bounds.\n", fd); - _network_free_netbuf_async(buf); - return; - } -#endif - - - if(s->type == NST_FREE) - return; - - // Check Max Outstanding buffers limit. - if( (s->write.max_outstanding > 0) && - (s->write.n_outstanding >= s->write.max_outstanding) ){ - - ShowWarning("network_send: fd #%u max Outstanding buffers exceeded. - disconnecting.\n", fd); - network_disconnect(fd); - // - _network_free_netbuf_async(buf); - return; - } - - - // Attach to the end: - buf->next = NULL; - if(s->write.buf_last != NULL){ - s->write.buf_last->next = buf; - s->write.buf_last = buf; - - }else{ - // currently no buffer attached. - s->write.buf = s->write.buf_last = buf; - - // register @ evdp for writable notification. - evdp_writable_add(fd, &s->evdp_data); // - } - - - // - s->write.n_outstanding++; - -}//end: network_send() - - -void network_parser_set_ro(int32 fd, - int16 *packetlentable, - void (*onPacketCompleteProc)(int32 fd, uint16 op, uint16 len, netbuf buf) - ){ - register SESSION *s = &g_Session[fd]; - register netbuf b, nb; // used for potential free attached buffers. - - if(s->type == NST_FREE) - return; - - s->onPacketComplete = onPacketCompleteProc; - - s->onRecv = _onRORecv; // .. - s->onSend = _onSend; // Using the normal generic netbuf based send function. - - s->netparser_data = packetlentable; - - // Initial State -> Need Packet OPCode. - s->read.state = NRS_WAITOP; - s->read.head_left = 2; - - - // Detach (if..) all buffers. - if(s->read.buf != NULL){ - _network_free_netbuf_async(s->read.buf); // - s->read.buf = NULL; - } - - if(s->write.buf != NULL){ - b = s->write.buf; - while(1){ - nb = b->next; - - _network_free_netbuf_async(b); - - b = nb; - } - - s->write.buf = NULL; - s->write.buf_last = NULL; - s->write.n_outstanding = 0; - } - - // not changing any limits on outstanding .. - // - -}//end: network_parser_set_ro() diff --git a/src/common/network.h b/src/common/network.h deleted file mode 100644 index 18da682570..0000000000 --- a/src/common/network.h +++ /dev/null @@ -1,189 +0,0 @@ -#ifndef _rA_NETWORK_H_ -#define _rA_NETWORK_H_ - -#include -#include "cbasetypes.h" -#include "netbuffer.h" -#include "evdp.h" - -#ifndef MAXCONN -#define MAXCONN 16384 -#endif - - -typedef struct SESSION{ - EVDP_DATA evdp_data; // Must be always the frist member! (some evdp's may rely on this fact) - - // Connection Type - enum{ NST_FREE=0, NST_LISTENER = 1, NST_CLIENT=2, NST_OUTGOING=3} type; - - // Flags / Settings. - bool v6; // is v6? - bool disconnect_in_progress; // To prevent stack overflows / recursive calls. - - - union{ // union to save memory. - struct sockaddr_in v4; - struct sockaddr_in6 v6; - }addr; - - - // "lowlevel" Handlers - // (Implemented by the protocol specific parser) - // - bool (*onRecv)(int32 fd); // return false = disconnect - bool (*onSend)(int32 fd); // return false = disconnect - - // Event Handlers for LISTENER type sockets - // - // onConnect gets Called when a connection has been - // successfully accepted. - // Session entry is available in this Handler! - // A returncode of false will reejct the connection (disconnect) - // Note: When rejecting a connection in onConnect by returning false - // The onDisconnect handler wont get called! - // Note: the onConnect Handler is also responsible for setting - // the appropriate netparser (which implements onRecv/onSend..) [protocol specific] - // - // onDisconnect gets called when a connection gets disconnected - // (by peer as well as by core) - // - bool (*onConnect)(int32 fd); // return false = disconnect (wont accept) - void (*onDisconnect)(int32 fd); - - - // - // Parser specific data - // - void *netparser_data; // incase of RO Packet Parser, pointer to packet len table (uint16array) - void (*onPacketComplete)(int32 fd, uint16 op, uint16 len, netbuf buf); - - - // - // Buffers - // - struct{ - enum NETREADSTATE { NRS_WAITOP = 0, NRS_WAITLEN = 1, NRS_WAITDATA = 2} state; - - uint32 head_left; - uint16 head[2]; - - netbuf buf; - } read; - - struct{ - uint32 max_outstanding; - uint32 n_outstanding; - - uint32 dataPos; - - netbuf buf, buf_last; - } write; - - // Application Level data Pointer - // (required for backward compatibility with previous athena socket system.) - void *data; - -} SESSION; - - -/** - * Subsystem Initialization / Finalization. - * - */ -void network_init(); -void network_final(); - - -/** - * Will do the net work :) .. - */ -void network_do(); - - -/** - * Adds a new listner. - * - * @param v6 v6 listner? - * @param *addr the address to listen on. - * @param port port to listen on - * - * @return -1 on error otherwise the identifier of the new listener. - */ -int32 network_addlistener(bool v6, const char *addr, uint16 port); - - -/** - * Tries to establish an outgoing connection. - * - * @param v6 operate with IPv6 addresses? - * @param addr the address to connect to - * @param port the port to connect to - * @param from_addr the address to connect from (local source / optional if auto -> NULL) - * @param from_port the port to connect from (local source / optional if auto -> 0) - * @param onConnectionEstablishedHandler callback that gets called when the connection is established. - * @param onConnectionLooseHandler callback that gets called when the connection gets disconnected (or the connection couldnt be established) - * - * @return -1 on error otherwise the identifier of the new connection - */ -int32 network_connect(bool v6, - const char *addr, - uint16 port, - const char *from_addr, - uint16 from_port, - bool (*onConnectionEstablishedHandler)(int32 fd), - void (*onConnectionLooseHandler)(int32 fd) -); - - - -/** - * Disconnects the given connection - * - * @param fd connection identifier. - * - * @Note: - * - onDisconnect callback gets called! - * - cleares (returns) all assigned buffers - * - */ -void network_disconnect(int32 fd); - - -/** - * Attach's a netbuffer at the end of sending queue to the given connection - * - * @param fd connection identifier - * @param buf netbuffer to attach. - */ -void network_send(int32 fd, netbuf buf); - - -/** - * Sets the parser to RO Protocol like Packet Parser. - * - * @param fd connection identifier - * @param *packetlentable pointer to array of uint16 in size of UINT16_MAX, - * @param onComplteProc callback for packet completion. - * - * @note: - * PacketLen Table Fromat: - * each element's offsets represents th ro opcode. - * value is length. - * a length of 0 means the packet is dynamic. - * a length of UINT16_MAX means the packet is unknown. - * - * Static Packets must contain their hader in len so (0x64 == 55 ..) - * - */ -void network_parser_set_ro(int32 fd, - int16 *packetlentable, - void (*onPacketCompleteProc)(int32 fd, uint16 op, uint16 len, netbuf buf) - ); -#define ROPACKET_UNKNOWN UINT16_MAX -#define ROPACKET_DYNLEN 0 - - - - -#endif diff --git a/src/common/nullpo.c b/src/common/nullpo.cpp similarity index 98% rename from src/common/nullpo.c rename to src/common/nullpo.cpp index 8a3f1a33aa..26b301ebc2 100644 --- a/src/common/nullpo.c +++ b/src/common/nullpo.cpp @@ -4,8 +4,8 @@ #include #include #include -#include "nullpo.h" -#include "showmsg.h" +#include "nullpo.hpp" +#include "showmsg.hpp" static void nullpo_info_core(const char *file, int line, const char *func, const char *fmt, va_list ap); static void nullpo_info_core_(const char *file, int line, const char *func); diff --git a/src/common/nullpo.h b/src/common/nullpo.hpp similarity index 97% rename from src/common/nullpo.h rename to src/common/nullpo.hpp index 778788dc61..e7532b1a84 100644 --- a/src/common/nullpo.h +++ b/src/common/nullpo.hpp @@ -1,14 +1,10 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _NULLPO_H_ -#define _NULLPO_H_ +#ifndef _NULLPO_HPP_ +#define _NULLPO_HPP_ -#ifdef __cplusplus -extern "C" { -#endif - -#include "cbasetypes.h" +#include "cbasetypes.hpp" #define NLP_MARK __FILE__, __LINE__, __func__ @@ -211,8 +207,4 @@ void nullpo_info_f(const char *file, int line, const char *func, const char *fmt, ...) __attribute__((format(printf,4,5))); -#ifdef __cplusplus -} -#endif - -#endif /* _NULLPO_H_ */ +#endif /* _NULLPO_HPP_ */ diff --git a/src/common/raconf.c b/src/common/raconf.c deleted file mode 100644 index c0d715575c..0000000000 --- a/src/common/raconf.c +++ /dev/null @@ -1,582 +0,0 @@ -// -// Athena style config parser -// (would be better to have "one" implementation instead of .. 4 :) -// -// -// Author: Florian Wilkemeyer -// -// Copyright (c) RAthena Project (www.rathena.org) - Licensed under GNU GPL -// For more information, see LICENCE in the main folder -// - - -#include -#include -#include - -#include "cbasetypes.h" -#include "showmsg.h" -#include "db.h" -#include "malloc.h" - -#include "raconf.h" - -#define SECTION_LEN 32 -#define VARNAME_LEN 64 - -struct raconf { - DBMap *db; -}; - - -struct conf_value{ - int64 intval; - bool bval; - double floatval; - size_t strval_len; // not includung \0 - char strval[16]; -}; - - - -static struct conf_value *makeValue(const char *key, char *val, size_t val_len){ - struct conf_value *v; -/* size_t sz; - - sz = sizeof(struct conf_value); - if(val_len >= sizeof(v->strval)) - sz += (val_len - sizeof(v->strval) + 1);*/ - - v = (struct conf_value*)aCalloc(1, sizeof(struct conf_value)); - if(v == NULL){ - ShowFatalError("raconf: makeValue => Out of Memory while allocating new node.\n"); - return NULL; - } - - memcpy(v->strval, val, val_len); - v->strval[val_len+1] = '\0'; - v->strval_len = val_len; - - - // Parse boolean value: - if((val_len == 4) && (strncmpi("true", val, 4) == 0)) - v->bval = true; - else if((val_len == 3) && (strncmpi("yes", val, 3) == 0)) - v->bval = true; - else if((val_len == 3) && (strncmpi("oui", val, 3) == 0)) - v->bval = true; - else if((val_len == 2) && (strncmpi("si", val, 2) == 0)) - v->bval = true; - else if((val_len == 2) && (strncmpi("ja", val, 2) == 0)) - v->bval = true; - else if((val_len == 1) && (*val == '1')) - v->bval = true; - else if((val_len == 5) && (strncmpi("false", val, 5) == 0)) - v->bval = false; - else if((val_len == 2) && (strncmpi("no", val, 2) == 0)) - v->bval = false; - else if((val_len == 3) && (strncmpi("non", val, 3) == 0)) - v->bval = false; - else if((val_len == 4) && (strncmpi("nein", val, 4) == 0)) - v->bval = false; - else if((val_len == 1) && (*val == '0')) - v->bval = false; - else - v->bval = false; // assume false. - - // Parse number - // Supported formats: - // prefix: 0x hex . - // postix: h for hex - // b for bin (dual) - if( (val_len >= 1 && (val[val_len] == 'h')) || (val_len >= 2 && (val[0] == '0' && val[1] == 'x')) ){//HEX! - if(val[val_len] == 'h'){ - val[val_len]= '\0'; - v->intval = strtoull(val, NULL, 16); - val[val_len] = 'h'; - }else - v->intval = strtoull(&val[2], NULL, 16); - }else if( val_len >= 1 && (val[val_len] == 'b') ){ //BIN - val[val_len] = '\0'; - v->intval = strtoull(val, NULL, 2); - val[val_len] = 'b'; - }else if( *val >='0' && *val <= '9'){ // begins with normal digit, so assume its dec. - // is it float? - bool is_float = false; - char *p; - - for(p = val; *p != '\0'; p++){ - if(*p == '.'){ - v->floatval = strtod(val, NULL); - v->intval = (int64) v->floatval; - is_float = true; - break; - } - } - - if(is_float == false){ - v->intval = strtoull(val, NULL, 10); - v->floatval = (double) v->intval; - } - }else{ - // Everything else: lets use boolean for fallback - if(v->bval == true) - v->intval = 1; - else - v->intval = 0; - } - - return v; -}//end: makeValue() - - -static bool configParse(raconf inst, const char *fileName){ - FILE *fp; - char line[4096]; - char currentSection[SECTION_LEN]; - char *p; - char c; - int linecnt; - size_t linelen; - size_t currentSection_len; - - fp = fopen(fileName, "r"); - if(fp == NULL){ - ShowError("configParse: cannot open '%s' for reading.\n", fileName); - return false; - } - - - // Start with empty section: - currentSection[0] = '\0'; - currentSection_len = 0; - - // - linecnt = 0; - while(1){ - linecnt++; - - if(fgets(line, sizeof(line), fp) != line) - break; - - linelen = strlen(line); - p = line; - - // Skip whitespaces from beginning (space and tab) - _line_begin_skip_whities: - c = *p; - if(c == ' ' || c == '\t'){ - p++; - linelen--; - goto _line_begin_skip_whities; - } - - // Remove linebreaks as (cr or lf) and whitespaces from line end! - _line_end_skip_whities_and_breaks: - c = p[linelen-1]; - if(c == '\r' || c == '\n' || c == ' ' || c == '\t'){ - p[--linelen] = '\0'; - goto _line_end_skip_whities_and_breaks; - } - - // Empty line? - // or line starts with comment (commented out)? - if(linelen == 0 || (p[0] == '/' && p[1] == '/') || p[0] == ';') - continue; - - // Variable names can contain: - // A-Za-z-_.0-9 - // - // Sections start with [ .. ] (INI Style) - // - c = *p; - - // check what we have.. :) - if(c == '['){ // got section! - // Got Section! - // Search for ] - char *start = (p+1); - - while(1){ - ++p; - c = *p; - - if(c == '\0'){ - ShowError("Syntax Error: unterminated Section name in %s:%u (expected ']')\n", fileName, linecnt); - fclose(fp); - return false; - }else if(c == ']'){ // closing backet (section name termination) - if( (p - start + 1) > (sizeof(currentSection) ) ){ - ShowError("Syntax Error: Section name in %s:%u is too large (max Supported length: %u chars)\n", fileName, linecnt, sizeof(currentSection)-1); - fclose(fp); - return false; - } - - // Set section! - *p = '\0'; // add termination here. - memcpy(currentSection, start, (p-start)+1 ); // we'll copy \0, too! (we replaced the ] backet with \0.) - currentSection_len = (p-start); - - break; - - }else if( (c >= '0' && c <= '9') || (c == '-') || (c == ' ') || (c == '_') || (c == '.') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ){ - // skip .. (allowed char / specifier) - continue; - }else{ - ShowError("Syntax Error: Invalid Character '%c' in %s:%u (offset %u) for Section name.\n", c, fileName, linecnt, (p-line)); - fclose(fp); - return false; - } - - }//endwhile: parse section name - - - }else if( (c >= '0' && c <= '9') || (c == '-') || (c == '_') || (c == '.') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ){ - // Got variable! - // Search for '=' or ':' wich termiantes the name - char *start = p; - char *valuestart = NULL; - size_t start_len; - - while(1){ - ++p; - c = *p; - - if(c == '\0'){ - ShowError("Syntax Error: unterminated Variable name in %s:%u\n", fileName, linecnt); - fclose(fp); - return false; - }else if( (c == '=') || (c == ':') ){ - // got name termination - - *p = '\0'; // Terminate it so (start) will hold the pointer to the name. - - break; - - }else if( (c >= '0' && c <= '9') || (c == '-') || (c == '_') || (c == '.') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ){ - // skip .. allowed char - continue; - }else{ - ShowError("Syntax Error: Invalid Character '%c' in %s:%u (offset %u) for Variable name.\n", c, fileName, linecnt, (p-line)); - fclose(fp); - return false; - } - - }//endwhile: parse var name - - start_len = (p-start); - if(start_len >= VARNAME_LEN){ - ShowError("%s:%u Variable length exceeds limit of %u Characters.\n", fileName, linecnt, VARNAME_LEN-1); - fclose(fp); - return false; - }else if(start_len == 0){ - ShowError("%s:%u Empty Variable name is not allowed.\n", fileName, linecnt); - fclose(fp); - return false; - } - - - valuestart = (p+1); - - - // Skip whitespace from begin of value (tab and space) - _skip_value_begin_whities: - c = *valuestart; - if(c == ' ' || c == '\t'){ - valuestart++; - goto _skip_value_begin_whities; - } - - // Scan for value termination, - // wich can be \0 or comment start (// or ; (INI) ) - // - p = valuestart; - while(1){ - c = *p; - if(c == '\0'){ - // Terminated by line end. - break; - }else if(c == '/' && p[1] == '/'){ - // terminated by c++ style comment. - *p = '\0'; - break; - }else if(c == ';'){ - // terminated by ini style comment. - *p = '\0'; - break; - } - - p++; - }//endwhile: search var value end. - - - // Strip whitespaces from end of value. - if(valuestart != p){ // not empty! - p--; - _strip_value_end_whities: - c = *p; - if(c == ' ' || c == '\t'){ - *p = '\0'; - p--; - goto _strip_value_end_whities; - } - p++; - } - - - // Buildin Hook: - if( stricmp(start, "import") == 0){ - if( configParse(inst, valuestart) != true){ - ShowError("%s:%u - Import of '%s' failed!\n", fileName, linecnt, valuestart); - } - }else{ - // put it to db. - struct conf_value *v, *o; - char key[ (SECTION_LEN+VARNAME_LEN+1+1) ]; //+1 for delimiter, +1 for termination. - size_t section_len; - - if(*currentSection == '\0'){ // empty / none - strncpy(key, "",9); - section_len = 9; - }else{ - strncpy(key, currentSection, currentSection_len); - section_len = currentSection_len; - } - - key[section_len] = '.'; // Delim - - strncpy(&key[section_len+1], start, start_len); - - key[section_len + start_len + 1] = '\0'; - - - v = makeValue(key, valuestart, (p-valuestart) ); - - // Try to get the old one before - o = strdb_get(inst->db, key); - if(o != NULL){ - strdb_remove(inst->db, key); - aFree(o); // - } - - strdb_put( inst->db, key, v); - } - - - }else{ - ShowError("Syntax Error: unexpected Character '%c' in %s:%u (offset %u)\n", c, fileName, linecnt, (p-line) ); - fclose(fp); - return false; - } - - - - } - - - - fclose(fp); - return true; -}//end: configParse() - - -#define MAKEKEY(dest, section, key) { size_t section_len, key_len; \ - if(section == NULL || *section == '\0'){ \ - strncpy(dest, "", 9); \ - section_len = 9; \ - }else{ \ - section_len = strlen(section); \ - strncpy(dest, section, section_len); \ - } \ - \ - dest[section_len] = '.'; \ - \ - key_len = strlen(key); \ - strncpy(&dest[section_len+1], key, key_len); \ - dest[section_len + key_len + 1] = '\0'; \ - } - - -raconf raconf_parse(const char *file_name){ - struct raconf *rc; - - rc = aCalloc(1, sizeof(struct raconf) ); - if(rc == NULL){ - ShowFatalError("raconf_parse: failed to allocate memory for new handle\n"); - return NULL; - } - - rc->db = strdb_alloc(DB_OPT_BASE | DB_OPT_DUP_KEY, 98); - // - - if(configParse(rc, file_name) != true){ - ShowError("Failed to Parse Configuration file '%s'\n", file_name); - } - - return rc; -}//end: raconf_parse() - - -void raconf_destroy(raconf rc){ - DBIterator *iter; - struct conf_value *v; - - // Clear all entrys in db. - iter = db_iterator(rc->db); - for( v = (struct conf_value*)dbi_first(iter); dbi_exists(iter); v = (struct conf_value*)dbi_next(iter) ){ - aFree(v); - } - dbi_destroy(iter); - - db_destroy(rc->db); - - aFree(rc); - -}//end: raconf_destroy() - -bool raconf_getbool(raconf rc, const char *section, const char *key, bool _default){ - char keystr[SECTION_LEN + VARNAME_LEN + 1 + 1]; - struct conf_value *v; - - MAKEKEY(keystr, section, key); - - v = strdb_get(rc->db, keystr); - if(v == NULL) - return _default; - else - return v->bval; -}//end: raconf_getbool() - - -float raconf_getfloat(raconf rc,const char *section, const char *key, float _default){ - char keystr[SECTION_LEN + VARNAME_LEN + 1 + 1]; - struct conf_value *v; - - MAKEKEY(keystr, section, key); - - v = strdb_get(rc->db, keystr); - if(v == NULL) - return _default; - else - return (float)v->floatval; -}//end: raconf_getfloat() - - -int64 raconf_getint(raconf rc, const char *section, const char *key, int64 _default){ - char keystr[SECTION_LEN + VARNAME_LEN + 1 + 1]; - struct conf_value *v; - - MAKEKEY(keystr, section, key); - - v = strdb_get(rc->db, keystr); - if(v == NULL) - return _default; - else - return v->intval; - -}//end: raconf_getint() - - -const char* raconf_getstr(raconf rc, const char *section, const char *key, const char *_default){ - char keystr[SECTION_LEN + VARNAME_LEN + 1 + 1]; - struct conf_value *v; - - MAKEKEY(keystr, section, key); - - v = strdb_get(rc->db, keystr); - if(v == NULL) - return _default; - else - return v->strval; -}//end: raconf_getstr() - - -bool raconf_getboolEx(raconf rc, const char *section, const char *fallback_section, const char *key, bool _default){ - char keystr[SECTION_LEN + VARNAME_LEN + 1 + 1]; - struct conf_value *v; - - MAKEKEY(keystr, section, key); - v = strdb_get(rc->db, keystr); - if(v == NULL){ - - MAKEKEY(keystr, fallback_section, key); - v = strdb_get(rc->db, keystr); - if(v == NULL){ - return _default; - }else{ - return v->bval; - } - - }else{ - return v->bval; - } -}//end: raconf_getboolEx() - - -float raconf_getfloatEx(raconf rc,const char *section, const char *fallback_section, const char *key, float _default){ - char keystr[SECTION_LEN + VARNAME_LEN + 1 + 1]; - struct conf_value *v; - - MAKEKEY(keystr, section, key); - v = strdb_get(rc->db, keystr); - if(v == NULL){ - - MAKEKEY(keystr, fallback_section, key); - v = strdb_get(rc->db, keystr); - if(v == NULL){ - return _default; - }else{ - return (float)v->floatval; - } - - }else{ - return (float)v->floatval; - } - -}//end: raconf_getfloatEx() - - -int64 raconf_getintEx(raconf rc, const char *section, const char *fallback_section, const char *key, int64 _default){ - char keystr[SECTION_LEN + VARNAME_LEN + 1 + 1]; - struct conf_value *v; - - MAKEKEY(keystr, section, key); - v = strdb_get(rc->db, keystr); - if(v == NULL){ - - MAKEKEY(keystr, fallback_section, key); - v = strdb_get(rc->db, keystr); - if(v == NULL){ - return _default; - }else{ - return v->intval; - } - - }else{ - return v->intval; - } - -}//end: raconf_getintEx() - - -const char* raconf_getstrEx(raconf rc, const char *section, const char *fallback_section, const char *key, const char *_default){ - char keystr[SECTION_LEN + VARNAME_LEN + 1 + 1]; - struct conf_value *v; - - MAKEKEY(keystr, section, key); - v = strdb_get(rc->db, keystr); - if(v == NULL){ - - MAKEKEY(keystr, fallback_section, key); - v = strdb_get(rc->db, keystr); - if(v == NULL){ - return _default; - }else{ - return v->strval; - } - - }else{ - return v->strval; - } - -}//end: raconf_getstrEx() diff --git a/src/common/raconf.h b/src/common/raconf.h deleted file mode 100644 index fe8af3568d..0000000000 --- a/src/common/raconf.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _rA_CONF_H_ -#define _rA_CONF_H_ - -#include "cbasetypes.h" - -// rAthena generic configuration file parser -// -// Config file Syntax is athena style -// extended with ini style support (including sections) -// -// Comments are started with // or ; (ini style) -// - -typedef struct raconf *raconf; - - -/** - * Parses a rAthna Configuration file - * - * @param file_name path to the file to parse - * - * @returns not NULL incase of success - */ -raconf raconf_parse(const char *file_name); - - -/** - * Frees a Handle received from raconf_parse - * - * @param rc - the handle to free - */ -void raconf_destroy(raconf rc); - - -/** - * Gets the value for Section / Key pair, if key not exists returns _default! - * - */ -bool raconf_getbool(raconf rc, const char *section, const char *key, bool _default); -float raconf_getfloat(raconf rc,const char *section, const char *key, float _default); -int64 raconf_getint(raconf rc, const char *section, const char *key, int64 _default); -const char* raconf_getstr(raconf rc, const char *section, const char *key, const char *_default); - -/** - * Gets the value for Section / Key pair, but has fallback section option if not found in section, - * if not found in both - default gets returned. - * - */ -bool raconf_getboolEx(raconf rc, const char *section, const char *fallback_section, const char *key, bool _default); -float raconf_getfloatEx(raconf rc,const char *section, const char *fallback_section, const char *key, float _default); -int64 raconf_getintEx(raconf rc, const char *section, const char *fallback_section, const char *key, int64 _default); -const char* raconf_getstrEx(raconf rc, const char *section, const char *fallback_section, const char *key, const char *_default); - - - -#endif diff --git a/src/common/random.c b/src/common/random.c deleted file mode 100644 index ef051bb40b..0000000000 --- a/src/common/random.c +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "showmsg.h" -#include "timer.h" // gettick -#include "random.h" -#if defined(WIN32) - #include "winapi.hpp" -#elif defined(HAVE_GETPID) || defined(HAVE_GETTID) - #include - #include -#endif - -#include // init_genrand, genrand_int32, genrand_res53 - - -/// Initializes the random number generator with an appropriate seed. -void rnd_init(void) -{ - uint32 seed = gettick(); - seed += (uint32)time(NULL); -#if defined(WIN32) - seed += GetCurrentProcessId(); - seed += GetCurrentThreadId(); -#else -#if defined(HAVE_GETPID) - seed += (uint32)getpid(); -#endif // HAVE_GETPID -#if defined(HAVE_GETTID) - seed += (uint32)gettid(); -#endif // HAVE_GETTID -#endif - init_genrand(seed); -} - - -/// Initializes the random number generator. -void rnd_seed(uint32 seed) -{ - init_genrand(seed); -} - - -/// Generates a random number in the interval [0, SINT32_MAX] -int32 rnd(void) -{ - return (int32)genrand_int31(); -} - - -/// Generates a random number in the interval [0, dice_faces) -/// NOTE: interval is open ended, so dice_faces is excluded (unless it's 0) -uint32 rnd_roll(uint32 dice_faces) -{ - return (uint32)(rnd_uniform()*dice_faces); -} - - -/// Generates a random number in the interval [min, max] -/// Returns min if range is invalid. -int32 rnd_value(int32 min, int32 max) -{ - if( min >= max ) - return min; - return min + (int32)(rnd_uniform()*(max-min+1)); -} - - -/// Generates a random number in the interval [0.0, 1.0) -/// NOTE: interval is open ended, so 1.0 is excluded -double rnd_uniform(void) -{ - return ((uint32)genrand_int32())*(1.0/4294967296.0);// divided by 2^32 -} - - -/// Generates a random number in the interval [0.0, 1.0) with 53-bit resolution -/// NOTE: interval is open ended, so 1.0 is excluded -/// NOTE: 53 bits is the maximum precision of a double -double rnd_uniform53(void) -{ - return genrand_res53(); -} diff --git a/src/common/random.cpp b/src/common/random.cpp new file mode 100644 index 0000000000..c7aa1d0c43 --- /dev/null +++ b/src/common/random.cpp @@ -0,0 +1,44 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#include "random.hpp" + +#include + +std::mt19937 generator; +std::uniform_int_distribution int31_distribution; +std::uniform_int_distribution uint32_distribution; + +/// Initializes the random number generator +void rnd_init( void ){ + std::random_device device; + generator = std::mt19937( device() ); + int31_distribution = std::uniform_int_distribution( 0, SINT32_MAX ); + uint32_distribution = std::uniform_int_distribution( 0, UINT32_MAX ); +} + +/// Generates a random number in the interval [0, SINT32_MAX] +int32 rnd( void ){ + return int31_distribution( generator ); +} + +/// Generates a random number in the interval [0, UINT32_MAX] +uint32 rnd_uint32( void ){ + return uint32_distribution( generator ); +} + +/// Generates a random number in the interval [0.0, 1.0) +/// NOTE: interval is open ended, so 1.0 is excluded +double rnd_uniform( void ){ + return rnd_uint32() * ( 1.0 / 4294967296.0 );// divided by 2^32 +} + +/// Generates a random number in the interval [min, max] +/// Returns min if range is invalid. +int32 rnd_value( int32 min, int32 max ){ + if( min >= max ){ + return min; + } + + return min + (int32)( rnd_uniform() * ( max - min + 1 ) ); +} diff --git a/src/common/random.h b/src/common/random.h deleted file mode 100644 index 47980f26db..0000000000 --- a/src/common/random.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _RANDOM_H_ -#define _RANDOM_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "cbasetypes.h" - -void rnd_init(void); -void rnd_seed(uint32); - -int32 rnd(void);// [0, SINT32_MAX] -uint32 rnd_roll(uint32 dice_faces);// [0, dice_faces) -int32 rnd_value(int32 min, int32 max);// [min, max] -double rnd_uniform(void);// [0.0, 1.0) -double rnd_uniform53(void);// [0.0, 1.0) - -#ifdef __cplusplus -} -#endif - -#endif /* _RANDOM_H_ */ diff --git a/src/common/random.hpp b/src/common/random.hpp new file mode 100644 index 0000000000..97eb7cebd8 --- /dev/null +++ b/src/common/random.hpp @@ -0,0 +1,14 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#ifndef _RANDOM_HPP_ +#define _RANDOM_HPP_ + +#include "cbasetypes.hpp" + +void rnd_init(void); + +int32 rnd(void);// [0, SINT32_MAX] +int32 rnd_value(int32 min, int32 max);// [min, max] + +#endif /* _RANDOM_HPP_ */ diff --git a/src/common/showmsg.c b/src/common/showmsg.cpp similarity index 98% rename from src/common/showmsg.c rename to src/common/showmsg.cpp index f710c9e52b..03b189d6c9 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.cpp @@ -1,10 +1,10 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "cbasetypes.h" -#include "strlib.h" // StringBuf -#include "showmsg.h" -#include "core.h" //[Ind] - For SERVER_TYPE +#include "cbasetypes.hpp" +#include "strlib.hpp" // StringBuf +#include "showmsg.hpp" +#include "core.hpp" //[Ind] - For SERVER_TYPE #include #include // atexit @@ -727,28 +727,28 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap) case MSG_NONE: // direct printf replacement break; case MSG_STATUS: //Bright Green (To inform about good things) - strcat(prefix,CL_GREEN"[Status]"CL_RESET":"); + strcat(prefix,CL_GREEN "[Status]" CL_RESET":"); break; case MSG_SQL: //Bright Violet (For dumping out anything related with SQL) <- Actually, this is mostly used for SQL errors with the database, as successes can as well just be anything else... [Skotlex] - strcat(prefix,CL_MAGENTA"[SQL]"CL_RESET":"); + strcat(prefix,CL_MAGENTA "[SQL]" CL_RESET ":"); break; case MSG_INFORMATION: //Bright White (Variable information) - strcat(prefix,CL_WHITE"[Info]"CL_RESET":"); + strcat(prefix,CL_WHITE "[Info]" CL_RESET ":"); break; case MSG_NOTICE: //Bright White (Less than a warning) - strcat(prefix,CL_WHITE"[Notice]"CL_RESET":"); + strcat(prefix,CL_WHITE "[Notice]" CL_RESET ":"); break; case MSG_WARNING: //Bright Yellow - strcat(prefix,CL_YELLOW"[Warning]"CL_RESET":"); + strcat(prefix,CL_YELLOW "[Warning]" CL_RESET ":"); break; case MSG_DEBUG: //Bright Cyan, important stuff! - strcat(prefix,CL_CYAN"[Debug]"CL_RESET":"); + strcat(prefix,CL_CYAN "[Debug]" CL_RESET ":"); break; case MSG_ERROR: //Bright Red (Regular errors) - strcat(prefix,CL_RED"[Error]"CL_RESET":"); + strcat(prefix,CL_RED "[Error]" CL_RESET ":"); break; case MSG_FATALERROR: //Bright Red (Fatal errors, abort(); if possible) - strcat(prefix,CL_RED"[Fatal Error]"CL_RESET":"); + strcat(prefix,CL_RED "[Fatal Error]" CL_RESET ":"); break; default: ShowError("In function _vShowMessage() -> Invalid flag passed.\n"); diff --git a/src/common/showmsg.h b/src/common/showmsg.hpp similarity index 95% rename from src/common/showmsg.h rename to src/common/showmsg.hpp index 29935f991a..519f35489b 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.hpp @@ -1,12 +1,8 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _SHOWMSG_H_ -#define _SHOWMSG_H_ - -#ifdef __cplusplus -extern "C" { -#endif +#ifndef _SHOWMSG_HPP_ +#define _SHOWMSG_HPP_ #include "../../3rdparty/libconfig/libconfig.h" @@ -101,8 +97,4 @@ extern void ShowError(const char *, ...); extern void ShowFatalError(const char *, ...); extern void ShowConfigWarning(config_setting_t *config, const char *string, ...); -#ifdef __cplusplus -} -#endif - -#endif /* _SHOWMSG_H_ */ +#endif /* _SHOWMSG_HPP_ */ diff --git a/src/common/socket.c b/src/common/socket.cpp similarity index 99% rename from src/common/socket.c rename to src/common/socket.cpp index 21996abd5c..5dbadf5705 100644 --- a/src/common/socket.c +++ b/src/common/socket.cpp @@ -1,13 +1,13 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "cbasetypes.h" -#include "mmo.h" -#include "timer.h" -#include "malloc.h" -#include "showmsg.h" -#include "strlib.h" -#include "socket.h" +#include "cbasetypes.hpp" +#include "mmo.hpp" +#include "timer.hpp" +#include "malloc.hpp" +#include "showmsg.hpp" +#include "strlib.hpp" +#include "socket.hpp" #include @@ -239,7 +239,7 @@ struct socket_data* session[FD_SETSIZE]; #ifdef SEND_SHORTLIST int send_shortlist_array[FD_SETSIZE];// we only support FD_SETSIZE sockets, limit the array to that -int send_shortlist_count = 0;// how many fd's are in the shortlist +size_t send_shortlist_count = 0;// how many fd's are in the shortlist uint32 send_shortlist_set[(FD_SETSIZE+31)/32];// to know if specific fd's are already in the shortlist #endif @@ -1391,7 +1391,7 @@ int socket_getips(uint32* ips, int max) void socket_init(void) { - char *SOCKET_CONF_FILENAME = "conf/packet_athena.conf"; + const char *SOCKET_CONF_FILENAME = "conf/packet_athena.conf"; unsigned int rlim_cur = FD_SETSIZE; #ifdef WIN32 @@ -1463,7 +1463,7 @@ void socket_init(void) add_timer_interval(gettick()+1000, connect_check_clear, 0, 0, 5*60*1000); #endif - ShowInfo("Server supports up to '"CL_WHITE"%u"CL_RESET"' concurrent connections.\n", rlim_cur); + ShowInfo("Server supports up to '" CL_WHITE "%u" CL_RESET "' concurrent connections.\n", rlim_cur); } diff --git a/src/common/socket.h b/src/common/socket.hpp similarity index 97% rename from src/common/socket.h rename to src/common/socket.hpp index 87c71a71f3..7cfaa117cd 100644 --- a/src/common/socket.h +++ b/src/common/socket.hpp @@ -1,10 +1,10 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _SOCKET_H_ -#define _SOCKET_H_ +#ifndef _SOCKET_HPP_ +#define _SOCKET_HPP_ -#include "cbasetypes.h" +#include "cbasetypes.hpp" #ifdef WIN32 #include "winapi.hpp" @@ -17,10 +17,6 @@ #include -#ifdef __cplusplus -extern "C" { -#endif - #define FIFOSIZE_SERVERLINK 256*1024 // socket I/O macros @@ -186,8 +182,4 @@ void send_shortlist_add_fd(int fd); void send_shortlist_do_sends(); #endif -#ifdef __cplusplus -} -#endif - -#endif /* _SOCKET_H_ */ +#endif /* _SOCKET_HPP_ */ diff --git a/src/common/spinlock.h b/src/common/spinlock.h deleted file mode 100644 index 27f932aa55..0000000000 --- a/src/common/spinlock.h +++ /dev/null @@ -1,102 +0,0 @@ -#pragma once -#ifndef _rA_SPINLOCK_H_ -#define _rA_SPINLOCK_H_ - -// -// CAS based Spinlock Implementation -// -// CamelCase names are choosen to be consistent with microsofts winapi -// which implements CriticalSection by this naming... -// -// Author: Florian Wilkemeyer -// -// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL -// For more information, see LICENCE in the main folder -// -// - -#ifdef WIN32 -#include "winapi.hpp" -#endif - -#include "cbasetypes.h" -#include "atomic.h" -#include "thread.h" - -#ifdef WIN32 - -typedef struct __declspec( align(64) ) SPIN_LOCK{ - volatile LONG lock; - volatile LONG nest; - volatile LONG sync_lock; -} SPIN_LOCK, *PSPIN_LOCK; -#else -typedef struct SPIN_LOCK{ - volatile int32 lock; - volatile int32 nest; // nesting level. - - volatile int32 sync_lock; -} __attribute__((aligned(64))) SPIN_LOCK, *PSPIN_LOCK; -#endif - - - -static forceinline void InitializeSpinLock(PSPIN_LOCK lck){ - lck->lock = 0; - lck->nest = 0; - lck->sync_lock = 0; -} - -static forceinline void FinalizeSpinLock(PSPIN_LOCK lck){ - return; -} - - -#define getsynclock(l) { while(1){ if(InterlockedCompareExchange(l, 1, 0) == 0) break; rathread_yield(); } } -#define dropsynclock(l) { InterlockedExchange(l, 0); } - -static forceinline void EnterSpinLock(PSPIN_LOCK lck){ - int tid = rathread_get_tid(); - - // Get Sync Lock && Check if the requester thread already owns the lock. - // if it owns, increase nesting level - getsynclock(&lck->sync_lock); - if(InterlockedCompareExchange(&lck->lock, tid, tid) == tid){ - InterlockedIncrement(&lck->nest); - dropsynclock(&lck->sync_lock); - return; // Got Lock - } - // drop sync lock - dropsynclock(&lck->sync_lock); - - - // Spin until we've got it ! - while(1){ - if(InterlockedCompareExchange(&lck->lock, tid, RA_INVALID_THID) == RA_INVALID_THID){ - InterlockedIncrement(&lck->nest); - return; // Got Lock - } - rathread_yield(); // Force ctxswitch to another thread. - } - -} - - -static forceinline void LeaveSpinLock(PSPIN_LOCK lck){ - int tid = rathread_get_tid(); - - getsynclock(&lck->sync_lock); - - if(InterlockedCompareExchange(&lck->lock, tid, tid) == tid){ // this thread owns the lock. - if(InterlockedDecrement(&lck->nest) == 0) - InterlockedExchange(&lck->lock, RA_INVALID_THID); // Unlock! - } - - dropsynclock(&lck->sync_lock); -} - - -#undef getsynclock -#undef dropsynclock - -#endif diff --git a/src/common/sql.c b/src/common/sql.cpp similarity index 99% rename from src/common/sql.c rename to src/common/sql.cpp index 2d75a3e49b..b8b652c720 100644 --- a/src/common/sql.c +++ b/src/common/sql.cpp @@ -1,12 +1,12 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "cbasetypes.h" -#include "malloc.h" -#include "showmsg.h" -#include "strlib.h" -#include "timer.h" -#include "sql.h" +#include "cbasetypes.hpp" +#include "malloc.hpp" +#include "showmsg.hpp" +#include "strlib.hpp" +#include "timer.hpp" +#include "sql.hpp" #ifdef WIN32 #include "winapi.hpp" diff --git a/src/common/sql.h b/src/common/sql.hpp similarity index 98% rename from src/common/sql.h rename to src/common/sql.hpp index 8b03e1bf34..9625e1efcd 100644 --- a/src/common/sql.h +++ b/src/common/sql.hpp @@ -1,16 +1,12 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _COMMON_SQL_H_ -#define _COMMON_SQL_H_ +#ifndef _COMMON_SQL_HPP_ +#define _COMMON_SQL_HPP_ -#include "cbasetypes.h" +#include "cbasetypes.hpp" #include // va_list -#ifdef __cplusplus -extern "C" { -#endif - // Return codes #define SQL_ERROR -1 #define SQL_SUCCESS 0 @@ -350,8 +346,4 @@ void SqlStmt_Free(SqlStmt* self); void Sql_Init(void); -#ifdef __cplusplus -} -#endif - -#endif /* _COMMON_SQL_H_ */ +#endif /* _COMMON_SQL_HPP_ */ diff --git a/src/common/strlib.c b/src/common/strlib.cpp similarity index 99% rename from src/common/strlib.c rename to src/common/strlib.cpp index 9b2dd9948f..34b77814a5 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.cpp @@ -1,10 +1,10 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "cbasetypes.h" -#include "malloc.h" -#include "showmsg.h" -#include "strlib.h" +#include "cbasetypes.hpp" +#include "malloc.hpp" +#include "showmsg.hpp" +#include "strlib.hpp" #include @@ -688,10 +688,9 @@ int sv_parse(const char* str, int len, int startoff, char delim, int* out_pos, i /// @param nfields Size of the field array /// @param opt Options that determine the parsing behaviour /// @return Number of fields found in the string or -1 if an error occured -int sv_split(char* str, int len, int startoff, char delim, char** out_fields, int nfields, enum e_svopt opt) +int sv_split(char* str, int len, int startoff, char delim, char** out_fields, size_t nfields, enum e_svopt opt) { int pos[1024]; - int i; int done; char* end; int ret = sv_parse(str, len, startoff, delim, pos, ARRAYLENGTH(pos), opt); @@ -732,7 +731,7 @@ int sv_split(char* str, int len, int startoff, char delim, char** out_fields, in --nfields; // fields - i = 2; + size_t i = 2; done = 0; while( done < ret && nfields > 0 ) { @@ -1056,7 +1055,7 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc aFree(fields); aFree(line); fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", entries, path); + ShowStatus("Done reading '" CL_WHITE "%d" CL_RESET "' entries in '" CL_WHITE "%s" CL_RESET "'.\n", entries, path); return true; } diff --git a/src/common/strlib.h b/src/common/strlib.hpp similarity index 96% rename from src/common/strlib.h rename to src/common/strlib.hpp index 930f65526d..89199c3321 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.hpp @@ -1,10 +1,10 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _STRLIB_H_ -#define _STRLIB_H_ +#ifndef _STRLIB_HPP_ +#define _STRLIB_HPP_ -#include "cbasetypes.h" +#include "cbasetypes.hpp" #include #if !defined(__USE_GNU) @@ -17,10 +17,6 @@ #undef __USED_GNU #endif -#ifdef __cplusplus -extern "C" { -#endif - char* jstrescape (char* pt); char* jstrescapecpy (char* pt, const char* spt); int jmemescapecpy (char* pt, const char* spt, int size); @@ -120,7 +116,7 @@ int sv_parse(const char* str, int len, int startoff, char delim, int* out_pos, i /// out_fields[0] is the start of the next line. /// Other entries are the start of fields (nul-teminated). /// Returns the number of fields found or -1 if an error occurs. -int sv_split(char* str, int len, int startoff, char delim, char** out_fields, int nfields, enum e_svopt opt); +int sv_split(char* str, int len, int startoff, char delim, char** out_fields, size_t nfields, enum e_svopt opt); /// Escapes src to out_dest according to the format of the C compiler. /// Returns the length of the escaped string. @@ -162,8 +158,4 @@ void StringBuf_Clear(StringBuf* self); void StringBuf_Destroy(StringBuf* self); void StringBuf_Free(StringBuf* self); -#ifdef __cplusplus -} -#endif - -#endif /* _STRLIB_H_ */ +#endif /* _STRLIB_HPP_ */ diff --git a/src/common/thread.c b/src/common/thread.c deleted file mode 100644 index 6daadf7e8d..0000000000 --- a/src/common/thread.c +++ /dev/null @@ -1,327 +0,0 @@ -// -// Basic Threading abstraction (for pthread / win32 based systems) -// -// Author: Florian Wilkemeyer -// -// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifdef WIN32 -#include "winapi.hpp" -#define getpagesize() 4096 // @TODO: implement this properly (GetSystemInfo .. dwPageSize..). (Atm as on all supported win platforms its 4k its static.) -#define __thread __declspec( thread ) -#else -#include -#include -#include -#include -#include -#include -#endif - -#include "cbasetypes.h" -#include "malloc.h" -#include "showmsg.h" -#include "thread.h" - -// When Compiling using MSC (on win32..) we know we have support in any case! -#if defined(_MSC_VER ) && !defined(HAS_TLS) -#define HAS_TLS -#endif - - -#define RA_THREADS_MAX 64 - -struct rAthread { - unsigned int myID; - - RATHREAD_PRIO prio; - rAthreadProc proc; - void *param; - - #ifdef WIN32 - HANDLE hThread; - #else - pthread_t hThread; - #endif -}; - - -#ifdef HAS_TLS -__thread int g_rathread_ID = RA_INVALID_THID; -#endif - - -/// -/// Subystem Code -/// -static struct rAthread l_threads[RA_THREADS_MAX]; - -prAthread rathenat_getThread( int idx ) { - if(idx < RA_THREADS_MAX) - return &l_threads[idx]; - return NULL; -} - -void rathread_init(){ - register unsigned int i; - memset(&l_threads, 0x00, RA_THREADS_MAX * sizeof(struct rAthread) ); - - for(i = 0; i < RA_THREADS_MAX; i++){ - l_threads[i].myID = i; - } - - // now lets init thread id 0, which represnts the main thread -#ifdef HAS_TLS - g_rathread_ID = 0; -#endif - l_threads[0].prio = RAT_PRIO_NORMAL; -#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__) - l_threads[0].proc = (rAthreadProc)0xDEADCAFEDEADCAFE; -#else - l_threads[0].proc = (rAthreadProc)0xDEADCAFE; -#endif - -}//end: rathread_init() - - - -void rathread_final(){ - register unsigned int i; - - // Unterminated Threads Left? - // Should'nt happen .. - // Kill 'em all! - // - for(i = 1; i < RA_THREADS_MAX; i++){ - if(l_threads[i].proc != NULL){ - ShowWarning("rAthread_final: unterminated Thread (tid %u entryPoint %p) - forcing to terminate (kill)\n", i, l_threads[i].proc); - rathread_destroy(&l_threads[i]); - } - } - - -}//end: rathread_final() - - - -// gets called whenever a thread terminated .. -static void rat_thread_terminated( prAthread handle ){ - - int id_backup = handle->myID; - - // Simply set all members to 0 (except the id) - memset(handle, 0x00, sizeof(struct rAthread)); - - handle->myID = id_backup; // done ;) - -}//end: rat_thread_terminated() - -#ifdef WIN32 -DWORD WINAPI _raThreadMainRedirector(LPVOID p){ -#else -static void *_raThreadMainRedirector( void *p ){ - sigset_t set; // on Posix Thread platforms -#endif - void *ret; - - // Update myID @ TLS to right id. -#ifdef HAS_TLS - g_rathread_ID = ((prAthread)p)->myID; -#endif - -#ifndef WIN32 - // When using posix threads - // the threads inherits the Signal mask from the thread which's spawned - // this thread - // so we've to block everything we dont care about. - sigemptyset(&set); - sigaddset(&set, SIGINT); - sigaddset(&set, SIGTERM); - sigaddset(&set, SIGPIPE); - - pthread_sigmask(SIG_BLOCK, &set, NULL); - -#endif - - - ret = ((prAthread)p)->proc( ((prAthread)p)->param ) ; - -#ifdef WIN32 - CloseHandle( ((prAthread)p)->hThread ); -#endif - - rat_thread_terminated( (prAthread)p ); -#ifdef WIN32 - return (DWORD)ret; -#else - return ret; -#endif -}//end: _raThreadMainRedirector() - - - - - -/// -/// API Level -/// -prAthread rathread_create( rAthreadProc entryPoint, void *param ){ - return rathread_createEx( entryPoint, param, (1<<23) /*8MB*/, RAT_PRIO_NORMAL ); -}//end: rathread_create() - - -prAthread rathread_createEx( rAthreadProc entryPoint, void *param, size_t szStack, RATHREAD_PRIO prio ){ -#ifndef WIN32 - pthread_attr_t attr; -#endif - size_t tmp; - unsigned int i; - prAthread handle = NULL; - - - // given stacksize aligned to systems pagesize? - tmp = szStack % getpagesize(); - if(tmp != 0) - szStack += tmp; - - - // Get a free Thread Slot. - for(i = 0; i < RA_THREADS_MAX; i++){ - if(l_threads[i].proc == NULL){ - handle = &l_threads[i]; - break; - } - } - - if(handle == NULL){ - ShowError("rAthread: cannot create new thread (entryPoint: %p) - no free thread slot found!", entryPoint); - return NULL; - } - - - - handle->proc = entryPoint; - handle->param = param; - -#ifdef WIN32 - handle->hThread = CreateThread(NULL, szStack, _raThreadMainRedirector, (void*)handle, 0, NULL); -#else - pthread_attr_init(&attr); - pthread_attr_setstacksize(&attr, szStack); - - if(pthread_create(&handle->hThread, &attr, _raThreadMainRedirector, (void*)handle) != 0){ - handle->proc = NULL; - handle->param = NULL; - return NULL; - } - pthread_attr_destroy(&attr); -#endif - - rathread_prio_set( handle, prio ); - - return handle; -}//end: rathread_createEx - - -void rathread_destroy ( prAthread handle ){ -#ifdef WIN32 - if( TerminateThread(handle->hThread, 0) != FALSE){ - CloseHandle(handle->hThread); - rat_thread_terminated(handle); - } -#else - if(handle->hThread && pthread_cancel( handle->hThread ) == 0){ - - // We have to join it, otherwise pthread wont re-cycle its internal ressources assoc. with this thread. - // - pthread_join( handle->hThread, NULL ); - - // Tell our manager to release ressources ;) - rat_thread_terminated(handle); - } -#endif -}//end: rathread_destroy() - -prAthread rathread_self( ){ -#ifdef HAS_TLS - prAthread handle = &l_threads[g_rathread_ID]; - - if(handle->proc != NULL) // entry point set, so its used! - return handle; -#else - // .. so no tls means we have to search the thread by its api-handle .. - int i; - - #ifdef WIN32 - HANDLE hSelf; - hSelf = GetCurrent = GetCurrentThread(); - #else - pthread_t hSelf; - hSelf = pthread_self(); - #endif - - for(i = 0; i < RA_THREADS_MAX; i++){ - if(l_threads[i].hThread == hSelf && l_threads[i].proc != NULL) - return &l_threads[i]; - } - -#endif - - return NULL; -}//end: rathread_self() - - -int rathread_get_tid(){ - -#ifdef HAS_TLS - return g_rathread_ID; -#else - // todo - #ifdef WIN32 - return (int)GetCurrentThreadId(); - #else - return (intptr_t)pthread_self(); - #endif - -#endif - -}//end: rathread_get_tid() - - -bool rathread_wait( prAthread handle, void* *out_exitCode ){ - - // Hint: - // no thread data cleanup routine call here! - // its managed by the callProxy itself.. - // -#ifdef WIN32 - WaitForSingleObject(handle->hThread, INFINITE); - return true; -#else - if(pthread_join(handle->hThread, out_exitCode) == 0) - return true; - return false; -#endif - -}//end: rathread_wait() - - -void rathread_prio_set( prAthread handle, RATHREAD_PRIO prio ){ - handle->prio = RAT_PRIO_NORMAL; - //@TODO -}//end: rathread_prio_set() - - -RATHREAD_PRIO rathread_prio_get( prAthread handle){ - return handle->prio; -}//end: rathread_prio_get() - - -void rathread_yield(){ -#ifdef WIN32 - SwitchToThread(); -#else - sched_yield(); -#endif -}//end: rathread_yield() diff --git a/src/common/thread.h b/src/common/thread.h deleted file mode 100644 index 402917d1c5..0000000000 --- a/src/common/thread.h +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#pragma once -#ifndef _rA_THREAD_H_ -#define _rA_THREAD_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "cbasetypes.h" - -typedef struct rAthread *prAthread; -typedef void* (*rAthreadProc)(void*); - -typedef enum RATHREAD_PRIO { - RAT_PRIO_LOW = 0, - RAT_PRIO_NORMAL, - RAT_PRIO_HIGH -} RATHREAD_PRIO; - -#define RA_INVALID_THID -1 - -/** - * Get the handle of a specific thread - * - * @param idx - The index of the thread - * @return not NULL if success - */ -prAthread rathenat_getThread( int idx ); - -/** - * Creates a new Thread - * - * @param entyPoint - entryProc, - * @param param - general purpose parameter, would be given as parameter to the thread's entrypoint. - * - * @return not NULL if success - */ -prAthread rathread_create( rAthreadProc entryPoint, void *param ); - - -/** - * Creates a new Thread (with more creation options) - * - * @param entyPoint - entryProc, - * @param param - general purpose parameter, would be given as parameter to the thread's entrypoint - * @param szStack - stack Size in bytes - * @param prio - Priority of the Thread @ OS Scheduler.. - * - * @return not NULL if success - */ -prAthread rathread_createEx( rAthreadProc entryPoint, void *param, size_t szStack, RATHREAD_PRIO prio ); - - -/** - * Destroys the given Thread immediatly - * - * @note The Handle gets invalid after call! dont use it afterwards. - * - * @param handle - thread to destroy. - */ -void rathread_destroy ( prAthread handle ); - - -/** - * Returns the thread handle of the thread calling this function - * - * @note this wont work @ programms main thread - * @note the underlying implementation might not perform very well, cache the value received! - * - * @return not NULL if success - */ -prAthread rathread_self( ); - - -/** - * Returns own thrad id (TID) - * - * @note this is an unique identifier for the calling thread, and - * depends on platfrom / compiler, and may not be the systems Thread ID! - * - * @return -1 when fails, otherwise >= 0 - */ -int rathread_get_tid(); - - -/** - * Waits for the given thread to terminate - * - * @param handle - thread to wait (join) for - * @param out_Exitcode - [OPTIONAL] - if given => Exitcode (value) of the given thread - if it's terminated - * - * @return true - if the given thread has been terminated. - */ -bool rathread_wait( prAthread handle, void* *out_exitCode ); - - -/** - * Sets the given PRIORITY @ OS Task Scheduler - * - * @param handle - thread to set prio for - * @param rio - the priority (RAT_PRIO_LOW ... ) - */ -void rathread_prio_set( prAthread handle, RATHREAD_PRIO prio ); - - -/** - * Gets the current Prio of the given trhead - * - * @param handle - the thread to get the prio for. - */ -RATHREAD_PRIO rathread_prio_get( prAthread handle); - - -/** - * Tells the OS scheduler to yield the execution of the calling thread - * - * @note: this will not "pause" the thread, - * it just allows the OS to spent the remaining time - * of the slice to another thread. - */ -void rathread_yield(); - - - -void rathread_init(); -void rathread_final(); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/common/timer.c b/src/common/timer.cpp similarity index 98% rename from src/common/timer.c rename to src/common/timer.cpp index a5f0ff1e8e..0a16bbec19 100644 --- a/src/common/timer.c +++ b/src/common/timer.cpp @@ -1,13 +1,13 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "cbasetypes.h" -#include "db.h" -#include "malloc.h" -#include "showmsg.h" -#include "utils.h" -#include "nullpo.h" -#include "timer.h" +#include "cbasetypes.hpp" +#include "db.hpp" +#include "malloc.hpp" +#include "showmsg.hpp" +#include "utils.hpp" +#include "nullpo.hpp" +#include "timer.hpp" #include #include @@ -83,7 +83,7 @@ int add_timer_func_list(TimerFunc func, const char* name) } /// Returns the name of the timer function. -char* search_timer_func_list(TimerFunc func) +const char* search_timer_func_list(TimerFunc func) { struct timer_func_list* tfl; diff --git a/src/common/timer.h b/src/common/timer.hpp similarity index 90% rename from src/common/timer.h rename to src/common/timer.hpp index 06aef8f721..88533244b2 100644 --- a/src/common/timer.h +++ b/src/common/timer.hpp @@ -1,14 +1,10 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _TIMER_H_ -#define _TIMER_H_ +#ifndef _TIMER_HPP_ +#define _TIMER_HPP_ -#ifdef __cplusplus -extern "C" { -#endif - -#include "cbasetypes.h" +#include "cbasetypes.hpp" #include #define DIFF_TICK(a,b) ((int)((a)-(b))) @@ -64,8 +60,4 @@ int do_timer(unsigned int tick); void timer_init(void); void timer_final(void); -#ifdef __cplusplus -} -#endif - -#endif /* _TIMER_H_ */ +#endif /* _TIMER_HPP_ */ diff --git a/src/common/utils.c b/src/common/utils.cpp similarity index 98% rename from src/common/utils.c rename to src/common/utils.cpp index 9b7af8cc73..2d9f3613c0 100644 --- a/src/common/utils.c +++ b/src/common/utils.cpp @@ -1,10 +1,10 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include "cbasetypes.h" -#include "showmsg.h" -#include "socket.h" -#include "utils.h" +#include "cbasetypes.hpp" +#include "showmsg.hpp" +#include "socket.hpp" +#include "utils.hpp" #include #include diff --git a/src/common/utils.h b/src/common/utils.hpp similarity index 92% rename from src/common/utils.h rename to src/common/utils.hpp index 7a1e8fb86b..6807182d47 100644 --- a/src/common/utils.h +++ b/src/common/utils.hpp @@ -1,14 +1,10 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _UTILS_H_ -#define _UTILS_H_ +#ifndef _UTILS_HPP_ +#define _UTILS_HPP_ -#ifdef __cplusplus -extern "C" { -#endif - -#include "cbasetypes.h" +#include "cbasetypes.hpp" #include // FILE* // generate a hex dump of the first 'length' bytes of 'buffer' @@ -50,8 +46,4 @@ extern uint32 GetULong(const unsigned char* buf); extern int32 GetLong(const unsigned char* buf); extern float GetFloat(const unsigned char* buf); -#ifdef __cplusplus -} -#endif - -#endif /* _UTILS_H_ */ +#endif /* _UTILS_HPP_ */ diff --git a/src/common/winapi.cpp b/src/common/winapi.cpp index d424df5ca8..30cf636243 100644 --- a/src/common/winapi.cpp +++ b/src/common/winapi.cpp @@ -3,7 +3,7 @@ #include "winapi.hpp" -#include "cbasetypes.h" +#include "cbasetypes.hpp" // Taken from https://support.microsoft.com/de-de/help/118626/how-to-determine-whether-a-thread-is-running-in-user-context-of-local bool IsCurrentUserLocalAdministrator(void){ diff --git a/src/common/winapi.hpp b/src/common/winapi.hpp index ffb8b0c13b..910c02af8d 100644 --- a/src/common/winapi.hpp +++ b/src/common/winapi.hpp @@ -46,6 +46,6 @@ #include #include -#include "cbasetypes.h" +#include "cbasetypes.hpp" bool IsCurrentUserLocalAdministrator(void); diff --git a/src/common/yamlwrapper.cpp b/src/common/yamlwrapper.cpp deleted file mode 100644 index e6b5677220..0000000000 --- a/src/common/yamlwrapper.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/** -* This file is a part of rAthena++. -* Copyright(C) 2017 rAthena Development Team -* https://rathena.org - https://github.com/rathena -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* Author(s) -* Jittapan Pluemsumran -*/ - -#include "yamlwrapper.h" -#include -#include "malloc.h" -#include "showmsg.h" - -extern "C" { - -yamlwrapper::yamlwrapper(YAML::Node node) { - try { - this->root = node; - } - catch (std::exception) { - //ignore - } -} - -yamliterator::yamliterator(YAML::Node sequence_) { - this->sequence = sequence_; - this->index = 0; -} - -yamliterator* yamlwrapper::iterator() { - return new yamliterator(this->root); -} - -yamlwrapper* yaml_load_file(const char* file_name) { - YAML::Node node; - - try { - node = YAML::LoadFile(file_name); - } catch (YAML::ParserException &e) { - ShowError("YAML Exception Caught: %s\n", e.what()); - return NULL; - } catch (YAML::BadFile) { - return NULL; - } - - return new yamlwrapper(node); -} - -extern "C++" YAML::Node yaml_get_node(const YAML::Node& node,const std::string& key) { - if (key.empty()) - return node; - - size_t pos = key.find('.'); - - if (pos == std::string::npos) - return node[key]; - else - return yaml_get_node(node[key.substr(0, pos)], key.substr(pos+1)); -} - -void yaml_destroy_wrapper(yamlwrapper* wrapper) { - delete wrapper; -} - -char* yaml_get_c_string(yamlwrapper* wrapper, const char* key) { - std::string cpp_str = yaml_get_node(wrapper->root, std::string(key)).as(); - const char* c_str = cpp_str.c_str(); - size_t str_size = std::strlen(c_str) + 1; - char* buf = (char*)aCalloc(1, str_size); - strcpy(buf, c_str); - return buf; -} - -extern "C++" { - template - T yaml_get_value(yamlwrapper* wrapper, const char* key) { - if (wrapper == nullptr || key == nullptr) - return {}; - try { - return yaml_get_node(wrapper->root, std::string(key)).as(); - } - catch (const std::exception& e) { - ShowError("Error during YAML node value resolving in node %s.\n", e.what()); - return {}; - } - } -} - -int yaml_get_int(yamlwrapper* wrapper, const char* key) { - return yaml_get_value(wrapper, key); -} - -int16 yaml_get_int16(yamlwrapper* wrapper, const char* key) { - return yaml_get_value(wrapper, key); -} - -int32 yaml_get_int32(yamlwrapper* wrapper, const char* key) { - return yaml_get_value(wrapper, key); -} - -int64 yaml_get_int64(yamlwrapper* wrapper, const char* key) { - return yaml_get_value(wrapper, key); -} - -int yaml_get_uint(yamlwrapper* wrapper, const char* key) { - return yaml_get_value(wrapper, key); -} - -int16 yaml_get_uint16(yamlwrapper* wrapper, const char* key) { - return yaml_get_value(wrapper, key); -} - -int32 yaml_get_uint32(yamlwrapper* wrapper, const char* key) { - return yaml_get_value(wrapper, key); -} - -int64 yaml_get_uint64(yamlwrapper* wrapper, const char* key) { - return yaml_get_value(wrapper, key); -} - -bool yaml_get_boolean(yamlwrapper* wrapper, const char* key) { - return yaml_get_value(wrapper, key); -} - -char* yaml_as_c_string(yamlwrapper* wrapper) { - std::string cpp_str = wrapper->root.as(); - const char* c_str = cpp_str.c_str(); - size_t str_size = std::strlen(c_str) + 1; - char* buf = (char*)aCalloc(1, str_size); - strcpy(buf, c_str); - return buf; -} - -extern "C++" { - template - T yaml_as_value(yamlwrapper* wrapper) { - if (wrapper == nullptr) - return {}; - try { - return wrapper->root.as(); - } - catch (const std::exception& e) { - ShowError("Error during YAML node value resolving in node %s.\n", e.what()); - return {}; - } - } -} - -int yaml_as_int(yamlwrapper* wrapper) { - return yaml_as_value(wrapper); -} - -int16 yaml_as_int16(yamlwrapper* wrapper) { - return yaml_as_value(wrapper); -} - -int32 yaml_as_int32(yamlwrapper* wrapper) { - return yaml_as_value(wrapper); -} - -int64 yaml_as_int64(yamlwrapper* wrapper) { - return yaml_as_value(wrapper); -} - -int yaml_as_uint(yamlwrapper* wrapper) { - return yaml_as_value(wrapper); -} - -int16 yaml_as_uint16(yamlwrapper* wrapper) { - return yaml_as_value(wrapper); -} - -int32 yaml_as_uint32(yamlwrapper* wrapper) { - return yaml_as_value(wrapper); -} - -int64 yaml_as_uint64(yamlwrapper* wrapper) { - return yaml_as_value(wrapper); -} - -bool yaml_as_boolean(yamlwrapper* wrapper) { - return yaml_as_value(wrapper); -} - -bool yaml_node_is_defined(yamlwrapper* wrapper, const char* key) { - if (wrapper == nullptr || key == nullptr) - return false; - return yaml_get_node(wrapper->root, std::string(key)).IsDefined(); -} - -yamlwrapper* yaml_get_subnode(yamlwrapper* wrapper, const char* key) { - return new yamlwrapper(yaml_get_node(wrapper->root, std::string(key))); -} - -char* yaml_verify_nodes(yamlwrapper* wrapper, int amount, char** nodes) { - for (int i = 0; i < amount; i++) { - if (!yaml_node_is_defined(wrapper, nodes[i])) - return nodes[i]; - } - return NULL; -} - -yamliterator* yaml_get_iterator(yamlwrapper* wrapper) { - return new yamliterator(wrapper->root); -} - -bool yaml_iterator_is_valid(yamliterator* it) { - return it->sequence.IsSequence(); -} - -yamlwrapper* yaml_iterator_first(yamliterator* it) { - it->index++; - return new yamlwrapper(it->sequence[0]); -} - -yamlwrapper* yaml_iterator_next(yamliterator* it) { - return new yamlwrapper(it->sequence[it->index++]); -} - -bool yaml_iterator_has_next(yamliterator* it) { - return it->index <= it->sequence.size(); -} - -void yaml_iterator_destroy(yamliterator* it) { - delete it; -} - -} /* extern "C" */ diff --git a/src/common/yamlwrapper.h b/src/common/yamlwrapper.h deleted file mode 100644 index 3a01a75945..0000000000 --- a/src/common/yamlwrapper.h +++ /dev/null @@ -1,97 +0,0 @@ -/** -* This file is a part of rAthena++. -* Copyright(C) 2017 rAthena Development Team -* https://rathena.org - https://github.com/rathena -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* Author(s) -* Jittapan Pluemsumran -*/ - -#pragma once -#ifdef WIN32 -#pragma warning(disable:4099) // Damn it, Microsoft! [Secret] -#endif - -#ifndef YAMLWRAPPER_H -#define YAMLWRAPPER_H - -#ifdef __cplusplus -#include "yaml-cpp/yaml.h" -#include - -extern "C" { -#endif - -#include "cbasetypes.h" - -#ifdef __cplusplus -class yamliterator { -public: - YAML::Node sequence; - unsigned int index; - yamliterator(YAML::Node sequence_); -}; - -class yamlwrapper { -public: - YAML::Node root; - yamlwrapper(std::string file); - yamlwrapper(YAML::Node node); - yamliterator* iterator(); -}; -#else -typedef struct yamlwrapper yamlwrapper; -typedef struct yamliterator yamliterator; -#endif - -yamlwrapper* yaml_load_file(const char* file_name); -void yaml_destroy_wrapper(yamlwrapper* wrapper); -char* yaml_get_c_string(yamlwrapper* wrapper, const char* key); -int yaml_get_int(yamlwrapper* wrapper, const char* key); -int16 yaml_get_int16(yamlwrapper* wrapper, const char* key); -int32 yaml_get_int32(yamlwrapper* wrapper, const char* key); -int64 yaml_get_int64(yamlwrapper* wrapper, const char* key); -int yaml_get_uint(yamlwrapper* wrapper, const char* key); -int16 yaml_get_uint16(yamlwrapper* wrapper, const char* key); -int32 yaml_get_uint32(yamlwrapper* wrapper, const char* key); -int64 yaml_get_uint64(yamlwrapper* wrapper, const char* key); -bool yaml_get_boolean(yamlwrapper* wrapper, const char* key); -char* yaml_as_c_string(yamlwrapper* wrapper); -int yaml_as_int(yamlwrapper* wrapper); -int16 yaml_as_int16(yamlwrapper* wrapper); -int32 yaml_as_int32(yamlwrapper* wrapper); -int64 yaml_as_int64(yamlwrapper* wrapper); -int yaml_as_uint(yamlwrapper* wrapper); -int16 yaml_as_uint16(yamlwrapper* wrapper); -int32 yaml_as_uint32(yamlwrapper* wrapper); -int64 yaml_as_uint64(yamlwrapper* wrapper); -bool yaml_as_boolean(yamlwrapper* wrapper); -bool yaml_node_is_defined(yamlwrapper* wrapper, const char* key); -yamlwrapper* yaml_get_subnode(yamlwrapper* wrapper, const char* key); -char* yaml_verify_nodes(yamlwrapper* wrapper, int amount, char** nodes); -yamliterator* yaml_get_iterator(yamlwrapper* wrapper); - -bool yaml_iterator_is_valid(yamliterator* it); -yamlwrapper* yaml_iterator_first(yamliterator* it); -yamlwrapper* yaml_iterator_next(yamliterator* it); -bool yaml_iterator_has_next(yamliterator* it); -void yaml_iterator_destroy(yamliterator* it); - -#ifdef __cplusplus -} -#endif - -#endif /* extern "C" */ diff --git a/src/config/classes/general.h b/src/config/classes/general.hpp similarity index 86% rename from src/config/classes/general.h rename to src/config/classes/general.hpp index 6e6cc14254..50621bfa8e 100644 --- a/src/config/classes/general.h +++ b/src/config/classes/general.hpp @@ -1,7 +1,7 @@ // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CONFIG_GENERAL_H_ -#define _CONFIG_GENERAL_H_ +#ifndef _CONFIG_GENERAL_HPP_ +#define _CONFIG_GENERAL_HPP_ /** * rAthena configuration file (http://rathena.org) @@ -20,4 +20,4 @@ * No settings past this point **/ -#endif // _CONFIG_GENERAL_H_ +#endif // _CONFIG_GENERAL_HPP_ diff --git a/src/config/const.h b/src/config/const.hpp similarity index 97% rename from src/config/const.h rename to src/config/const.hpp index 75950908f6..10837637c9 100644 --- a/src/config/const.h +++ b/src/config/const.hpp @@ -1,7 +1,7 @@ // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _RRCONFIGS_CONST_ -#define _RRCONFIGS_CONST_ +#ifndef _CONFIG_CONST_H_ +#define _CONFIG_CONST_H_ /** * rAthena configuration file (http://rathena.org) @@ -111,4 +111,4 @@ /** * End of File **/ -#endif +#endif // _CONFIG_CONST_H_ diff --git a/src/config/core.h b/src/config/core.hpp similarity index 83% rename from src/config/core.h rename to src/config/core.hpp index 6f39af8b9c..de52af7744 100644 --- a/src/config/core.h +++ b/src/config/core.hpp @@ -1,14 +1,14 @@ // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CONFIG_CORE_H_ -#define _CONFIG_CORE_H_ +#ifndef _CONFIG_CORE_HPP_ +#define _CONFIG_CORE_HPP_ /** * rAthena configuration file (http://rathena.org) * For detailed guidance on these check http://rathena.org/wiki/SRC/config/ **/ -#include "../custom/defines_pre.h" +#include "../custom/defines_pre.hpp" /// Max number of items on @autolootid list #define AUTOLOOTITEM_SIZE 10 @@ -22,11 +22,6 @@ /// while with OFFICIAL_WALKPATH disabled if they click to walk around a obstacle the server will do it automatically #define OFFICIAL_WALKPATH -/// uncomment to enable query_sql script command and mysql logs to function on it's own thread -/// be aware this feature is under tests and you should use at your own risk, we however -/// welcome any feedback you may have regarding this feature, please send us all bug reports. -//#define BETA_THREAD_TEST - /// Uncomment to enable the Cell Stack Limit mod. /// It's only config is the battle_config custom_cell_stack_limit. /// Only chars affected are those defined in BL_CHAR @@ -80,16 +75,16 @@ /** * No settings past this point **/ -#include "./packets.h" -#include "./renewal.h" -#include "./secure.h" -#include "./classes/general.h" +#include "./packets.hpp" +#include "./renewal.hpp" +#include "./secure.hpp" +#include "./classes/general.hpp" /** * Constants come last; so they process anything that could've been modified in early includes **/ -#include "./const.h" +#include "./const.hpp" -#include "../custom/defines_post.h" +#include "../custom/defines_post.hpp" -#endif // _CONFIG_CORE_H_ +#endif // _CONFIG_CORE_HPP_ diff --git a/src/config/packets.h b/src/config/packets.hpp similarity index 87% rename from src/config/packets.h rename to src/config/packets.hpp index 6c1506837b..5e9c3f35b9 100644 --- a/src/config/packets.h +++ b/src/config/packets.hpp @@ -1,7 +1,7 @@ // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CONFIG_PACKETS_H_ -#define _CONFIG_PACKETS_H_ +#ifndef _CONFIG_PACKETS_HPP_ +#define _CONFIG_PACKETS_HPP_ /** * rAthena configuration file (http://rathena.org) @@ -10,7 +10,7 @@ #ifndef PACKETVER /// Do NOT edit this line! To set your client version, please do this instead: - /// In Windows: Add this line in your src\custom\defines_pre.h file: #define PACKETVER YYYYMMDD + /// In Windows: Add this line in your src\custom\defines_pre.hpp file: #define PACKETVER YYYYMMDD /// In Linux: The same as above or run the following command: ./configure --enable-packetver=YYYYMMDD #define PACKETVER 20151104 #endif @@ -28,7 +28,7 @@ #ifndef PACKET_OBFUSCATION #define PACKET_OBFUSCATION - // Define these inside src/custom/defines_pre.h or src/custom/defines_post.h + // Define these inside src/custom/defines_pre.hpp or src/custom/defines_post.hpp //#define PACKET_OBFUSCATION_KEY1 //#define PACKET_OBFUSCATION_KEY2 //#define PACKET_OBFUSCATION_KEY3 @@ -63,4 +63,4 @@ /// Check if the specified packetvresion supports the cashshop sale system #define PACKETVER_SUPPORTS_SALES PACKETVER >= 20131223 -#endif // _CONFIG_PACKETS_H_ +#endif // _CONFIG_PACKETS_HPP_ diff --git a/src/config/renewal.h b/src/config/renewal.hpp similarity index 96% rename from src/config/renewal.h rename to src/config/renewal.hpp index dae47098a8..2751e9ed9b 100644 --- a/src/config/renewal.h +++ b/src/config/renewal.hpp @@ -1,7 +1,7 @@ // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CONFIG_RENEWAL_H_ -#define _CONFIG_RENEWAL_H_ +#ifndef _CONFIG_RENEWAL_HPP_ +#define _CONFIG_RENEWAL_HPP_ //quick option to disable all renewal option, used by ./configure //#define PRERE @@ -74,4 +74,4 @@ #endif -#endif // _CONFIG_RENEWAL_H_ +#endif // _CONFIG_RENEWAL_HPP_ diff --git a/src/config/secure.h b/src/config/secure.hpp similarity index 93% rename from src/config/secure.h rename to src/config/secure.hpp index 2082aba96a..b0ce6b9f95 100644 --- a/src/config/secure.h +++ b/src/config/secure.hpp @@ -1,7 +1,7 @@ // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CONFIG_SECURE_H_ -#define _CONFIG_SECURE_H_ +#ifndef _CONFIG_SECURE_HPP_ +#define _CONFIG_SECURE_HPP_ /** * rAthena configuration file (http://rathena.org) @@ -46,4 +46,4 @@ **/ #define SECURE_NPCTIMEOUT_INTERVAL 1 -#endif // _CONFIG_SECURE_H_ +#endif // _CONFIG_SECURE_HPP_ diff --git a/src/custom/defines_pre.h b/src/custom/defines_post.hpp similarity index 67% rename from src/custom/defines_pre.h rename to src/custom/defines_post.hpp index ceed7e774c..295dbdb47c 100644 --- a/src/custom/defines_pre.h +++ b/src/custom/defines_post.hpp @@ -1,7 +1,7 @@ // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CONFIG_CUSTOM_DEFINES_PRE_H_ -#define _CONFIG_CUSTOM_DEFINES_PRE_H_ +#ifndef _CONFIG_CUSTOM_DEFINES_POST_HPP_ +#define _CONFIG_CUSTOM_DEFINES_POST_HPP_ /** * rAthena configuration file (http://rathena.org) @@ -10,4 +10,4 @@ -#endif // _CONFIG_CUSTOM_DEFINES_PRE_H_ +#endif // _CONFIG_CUSTOM_DEFINES_POST_HPP_ diff --git a/src/custom/defines_post.h b/src/custom/defines_pre.hpp similarity index 67% rename from src/custom/defines_post.h rename to src/custom/defines_pre.hpp index 33f34d4a77..54c5372d48 100644 --- a/src/custom/defines_post.h +++ b/src/custom/defines_pre.hpp @@ -1,7 +1,7 @@ // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _CONFIG_CUSTOM_DEFINES_POST_H_ -#define _CONFIG_CUSTOM_DEFINES_POST_H_ +#ifndef _CONFIG_CUSTOM_DEFINES_PRE_HPP_ +#define _CONFIG_CUSTOM_DEFINES_PRE_HPP_ /** * rAthena configuration file (http://rathena.org) @@ -10,4 +10,4 @@ -#endif // _CONFIG_CUSTOM_DEFINES_POST_H_ +#endif // _CONFIG_CUSTOM_DEFINES_PRE_HPP_ diff --git a/src/login/Makefile.in b/src/login/Makefile.in index c9a5515a1b..32ef7b80db 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -1,12 +1,8 @@ -COMMON_H = $(shell ls ../common/*.h) +COMMON_H = $(shell ls ../common/*.hpp) COMMON_AR = ../common/obj/common.a COMMON_INCLUDE = -I../common -MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o -MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h -MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar - LIBCONFIG_H = $(shell ls ../../3rdparty/libconfig/*.h) LIBCONFIG_AR = ../../3rdparty/libconfig/obj/libconfig.a LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig @@ -57,27 +53,19 @@ obj: #executables -login-server: obj $(LOGIN_DIR_OBJ) $(COMMON_AR) $(MT19937AR_OBJ) +login-server: obj $(LOGIN_DIR_OBJ) $(COMMON_AR) @echo " LD @OLOG@@EXEEXT@" - @@CC@ @LDFLAGS@ -o ../../@OLOG@@EXEEXT@ $(LOGIN_DIR_OBJ) $(COMMON_AR) $(MT19937AR_OBJ) $(LIBCONFIG_AR) @LIBS@ @MYSQL_LIBS@ - + @@CXX@ @LDFLAGS@ -o ../../@OLOG@@EXEEXT@ $(LOGIN_DIR_OBJ) $(COMMON_AR) $(LIBCONFIG_AR) @LIBS@ @MYSQL_LIBS@ # login object files -obj/%.o: %.c $(LOGIN_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) - @echo " CC $<" - @@CC@ @CFLAGS@ $(COMMON_INCLUDE) $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< - -obj/%.o: %.cpp $(LOGIN_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) +obj/%.o: %.cpp $(LOGIN_H) $(COMMON_H) $(LIBCONFIG_H) @echo " CXX $<" - @@CXX@ @CXXFLAGS@ $(COMMON_INCLUDE) $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @@CXX@ @CXXFLAGS@ $(COMMON_INCLUDE) $(LIBCONFIG_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files $(COMMON_AR): @$(MAKE) -C ../common server -$(MT19937AR_OBJ): - @$(MAKE) -C ../../3rdparty/mt19937ar - $(LIBCONFIG_AR): @$(MAKE) -C ../../3rdparty/libconfig diff --git a/src/login/account.cpp b/src/login/account.cpp index d8840dcabc..2297e2bfba 100644 --- a/src/login/account.cpp +++ b/src/login/account.cpp @@ -13,12 +13,12 @@ #include #include //min / max -#include "../common/malloc.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/sql.h" -#include "../common/strlib.h" +#include "../common/malloc.hpp" +#include "../common/mmo.hpp" +#include "../common/showmsg.hpp" +#include "../common/socket.hpp" +#include "../common/sql.hpp" +#include "../common/strlib.hpp" /// global defines diff --git a/src/login/account.hpp b/src/login/account.hpp index 319fc7fac4..7f6edf236f 100644 --- a/src/login/account.hpp +++ b/src/login/account.hpp @@ -11,9 +11,9 @@ #ifndef _ACCOUNT_HPP_ #define _ACCOUNT_HPP_ -#include "../common/cbasetypes.h" -#include "../common/mmo.h" // ACCOUNT_REG2_NUM -#include "../config/core.h" +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" // ACCOUNT_REG2_NUM +#include "../config/core.hpp" typedef struct AccountDB AccountDB; typedef struct AccountDBIterator AccountDBIterator; diff --git a/src/login/ipban.cpp b/src/login/ipban.cpp index 4363129e52..66696b1cbe 100644 --- a/src/login/ipban.cpp +++ b/src/login/ipban.cpp @@ -13,11 +13,11 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/showmsg.h" -#include "../common/sql.h" -#include "../common/strlib.h" -#include "../common/timer.h" +#include "../common/cbasetypes.hpp" +#include "../common/showmsg.hpp" +#include "../common/sql.hpp" +#include "../common/strlib.hpp" +#include "../common/timer.hpp" #include "login.hpp" #include "loginlog.hpp" diff --git a/src/login/ipban.hpp b/src/login/ipban.hpp index 64c91d6229..9de70de326 100644 --- a/src/login/ipban.hpp +++ b/src/login/ipban.hpp @@ -12,7 +12,7 @@ #ifndef _IPBAN_HPP_ #define _IPBAN_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" /** * Check if ip is in the active bans list. diff --git a/src/login/login-server.vcxproj b/src/login/login-server.vcxproj index 7b10d4ca41..cd6182fdc2 100644 --- a/src/login/login-server.vcxproj +++ b/src/login/login-server.vcxproj @@ -98,7 +98,7 @@ Console true - ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\mt19937ar.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) + ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) @@ -113,7 +113,7 @@ Console true - ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\mt19937ar.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) + ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) @@ -132,7 +132,7 @@ true true true - ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\mt19937ar.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) + ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) @@ -151,7 +151,7 @@ true true true - ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\mt19937ar.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) + ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) diff --git a/src/login/login.cpp b/src/login/login.cpp index da3bd8a3a0..fc5c1736db 100644 --- a/src/login/login.cpp +++ b/src/login/login.cpp @@ -15,20 +15,20 @@ #include #include -#include "../common/core.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/md5calc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" //ip2str -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/msg_conf.h" -#include "../common/cli.h" -#include "../common/utils.h" -#include "../common/mmo.h" -#include "../config/core.h" +#include "../common/core.hpp" +#include "../common/db.hpp" +#include "../common/malloc.hpp" +#include "../common/md5calc.hpp" +#include "../common/random.hpp" +#include "../common/showmsg.hpp" +#include "../common/socket.hpp" //ip2str +#include "../common/strlib.hpp" +#include "../common/timer.hpp" +#include "../common/msg_conf.hpp" +#include "../common/cli.hpp" +#include "../common/utils.hpp" +#include "../common/mmo.hpp" +#include "../config/core.hpp" #include "account.hpp" #include "ipban.hpp" #include "loginlog.hpp" diff --git a/src/login/login.hpp b/src/login/login.hpp index 1923c17e47..311b38e377 100644 --- a/src/login/login.hpp +++ b/src/login/login.hpp @@ -14,10 +14,10 @@ #include -#include "../config/core.h" -#include "../common/cbasetypes.h" -#include "../common/mmo.h" // NAME_LENGTH,SEX_* -#include "../common/core.h" // CORE_ST_LAST +#include "../config/core.hpp" +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" // NAME_LENGTH,SEX_* +#include "../common/core.hpp" // CORE_ST_LAST #include "account.hpp" diff --git a/src/login/loginchrif.cpp b/src/login/loginchrif.cpp index f364403b3b..cb3a634d4d 100644 --- a/src/login/loginchrif.cpp +++ b/src/login/loginchrif.cpp @@ -12,10 +12,10 @@ #include #include -#include "../common/timer.h" //difftick -#include "../common/strlib.h" //safeprint -#include "../common/showmsg.h" //show notice -#include "../common/socket.h" //wfifo session +#include "../common/timer.hpp" //difftick +#include "../common/strlib.hpp" //safeprint +#include "../common/showmsg.hpp" //show notice +#include "../common/socket.hpp" //wfifo session #include "account.hpp" #include "login.hpp" diff --git a/src/login/loginchrif.hpp b/src/login/loginchrif.hpp index 1e44939697..7ac1f547ed 100644 --- a/src/login/loginchrif.hpp +++ b/src/login/loginchrif.hpp @@ -11,7 +11,7 @@ #ifndef _LOGINCHRIF_HPP_ #define _LOGINCHRIF_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" /** * Entry point from char-server to log-server. diff --git a/src/login/loginclif.cpp b/src/login/loginclif.cpp index bcb9d84a41..dfaa40924d 100644 --- a/src/login/loginclif.cpp +++ b/src/login/loginclif.cpp @@ -12,14 +12,14 @@ #include #include -#include "../common/timer.h" //difftick -#include "../common/strlib.h" //safeprint -#include "../common/showmsg.h" //show notice -#include "../common/socket.h" //wfifo session -#include "../common/malloc.h" -#include "../common/utils.h" -#include "../common/md5calc.h" -#include "../common/random.h" +#include "../common/timer.hpp" //difftick +#include "../common/strlib.hpp" //safeprint +#include "../common/showmsg.hpp" //show notice +#include "../common/socket.hpp" //wfifo session +#include "../common/malloc.hpp" +#include "../common/utils.hpp" +#include "../common/md5calc.hpp" +#include "../common/random.hpp" #include "account.hpp" #include "ipban.hpp" //ipban_check diff --git a/src/login/logincnslif.cpp b/src/login/logincnslif.cpp index e5055b3589..820bafd262 100644 --- a/src/login/logincnslif.cpp +++ b/src/login/logincnslif.cpp @@ -12,13 +12,13 @@ #include #include -#include "../common/mmo.h" //cbasetype + NAME_LENGTH -#include "../common/showmsg.h" //show notice -#include "../common/md5calc.h" -#include "../common/ers.h" -#include "../common/cli.h" -#include "../common/timer.h" -#include "../common/strlib.h" +#include "../common/mmo.hpp" //cbasetype + NAME_LENGTH +#include "../common/showmsg.hpp" //show notice +#include "../common/md5calc.hpp" +#include "../common/ers.hpp" +#include "../common/cli.hpp" +#include "../common/timer.hpp" +#include "../common/strlib.hpp" #include "login.hpp" @@ -97,7 +97,7 @@ int logcnslif_get_options(int argc, char ** argv) { /** * Console Command Parser - * Transmited from command cli.c + * Transmited from command cli.cpp * note common name for all serv do not rename (extern in cli) * @author [Wizputer] * @param buf: buffer to parse, (from console) diff --git a/src/login/logincnslif.hpp b/src/login/logincnslif.hpp index 7ce329fee3..00c31a5005 100644 --- a/src/login/logincnslif.hpp +++ b/src/login/logincnslif.hpp @@ -11,18 +11,10 @@ #ifndef _LOGINCNSLIF_HPP_ #define _LOGINCNSLIF_HPP_ -extern "C" { -/** - * Login-server console help: starting option info. - * Do not rename function used as extern. - * @param do_exit: terminate program execution ? - */ -void display_helpscreen(bool do_exit); -} /** * Console Command Parser - * Transmited from command cli.c + * Transmited from command cli.cpp * note common name for all serv do not rename (extern in cli) * @author [Wizputer] * @param buf: buffer to parse, (from console) diff --git a/src/login/loginlog.cpp b/src/login/loginlog.cpp index 4c96afaf66..a0784acbf8 100644 --- a/src/login/loginlog.cpp +++ b/src/login/loginlog.cpp @@ -12,12 +12,12 @@ #include // exit #include -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/socket.h" -#include "../common/sql.h" -#include "../common/strlib.h" -#include "../common/showmsg.h" +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" +#include "../common/socket.hpp" +#include "../common/sql.hpp" +#include "../common/strlib.hpp" +#include "../common/showmsg.hpp" // global sql settings (in ipban_sql.c) static char global_db_hostname[64] = "127.0.0.1"; // Doubled to reflect the change on commit #0f2dd7f diff --git a/src/login/loginlog.hpp b/src/login/loginlog.hpp index 099d077eb0..73b03a2cde 100644 --- a/src/login/loginlog.hpp +++ b/src/login/loginlog.hpp @@ -13,7 +13,7 @@ #include -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" /** * Get the number of failed login attempts by the ip in the last minutes. diff --git a/src/map/Makefile.in b/src/map/Makefile.in index 6dca40358a..acd1d94f3c 100644 --- a/src/map/Makefile.in +++ b/src/map/Makefile.in @@ -1,12 +1,8 @@ -COMMON_H = $(shell ls ../common/*.h) +COMMON_H = $(shell ls ../common/*.hpp) COMMON_AR = ../common/obj/common.a COMMON_INCLUDE = -I../common/ -MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o -MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h -MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar - LIBCONFIG_H = $(shell ls ../../3rdparty/libconfig/*.h) LIBCONFIG_AR = ../../3rdparty/libconfig/obj/libconfig.a LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig @@ -21,7 +17,7 @@ MAP_OBJ = $(shell ls *.cpp | sed -e "s/\.cpp/\.o/g") #MAP_OBJ += $(shell ls *.c | sed -e "s/\.c/\.o/g") MAP_DIR_OBJ = $(MAP_OBJ:%=obj/%) MAP_H = $(shell ls ../map/*.hpp) \ - $(shell ls ../config/*.h) + $(shell ls ../config/*.hpp) HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) @@ -74,30 +70,23 @@ obj: map-server: obj $(MAP_DIR_OBJ) $(COMMON_AR) $(LIBCONFIG_AR) $(YAML_CPP_AR) @echo " LD @OMAP@@EXEEXT@" - @@CXX@ @LDFLAGS@ -o ../../@OMAP@@EXEEXT@ $(MAP_DIR_OBJ) $(COMMON_AR) $(MT19937AR_OBJ) $(LIBCONFIG_AR) $(YAML_CPP_AR) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ + @@CXX@ @LDFLAGS@ -o ../../@OMAP@@EXEEXT@ $(MAP_DIR_OBJ) $(COMMON_AR) $(LIBCONFIG_AR) $(YAML_CPP_AR) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ # map object files #cause this one failling otherwise -obj/npc.o: npc.cpp $(MAP_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) $(YAML_CPP_H) +obj/npc.o: npc.cpp $(MAP_H) $(COMMON_H) $(LIBCONFIG_H) $(YAML_CPP_H) @echo " CXX $< (custom rule)" - @@CXX@ @CXXFLAG_CLEARS@ $(COMMON_INCLUDE) $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< - -obj/%.o: %.c $(MAP_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) $(YAML_CPP_H) - @echo " CC $<" - @@CC@ @CFLAGS@ $(COMMON_INCLUDE) $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @@CXX@ @CXXFLAG_CLEARS@ $(COMMON_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -obj/%.o: %.cpp $(MAP_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) $(YAML_CPP_H) +obj/%.o: %.cpp $(MAP_H) $(COMMON_H) $(LIBCONFIG_H) $(YAML_CPP_H) @echo " CXX $<" - @@CXX@ @CXXFLAGS@ $(COMMON_INCLUDE) $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @@CXX@ @CXXFLAGS@ $(COMMON_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) $(YAML_CPP_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files $(COMMON_AR): @$(MAKE) -C ../common server -$(MT19937AR_OBJ): - @$(MAKE) -C ../../3rdparty/mt19937ar - $(LIBCONFIG_AR): @$(MAKE) -C ../../3rdparty/libconfig diff --git a/src/map/achievement.cpp b/src/map/achievement.cpp index 30aaabf20d..beefe9b53c 100644 --- a/src/map/achievement.cpp +++ b/src/map/achievement.cpp @@ -10,12 +10,12 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#include "../common/cbasetypes.hpp" +#include "../common/malloc.hpp" +#include "../common/nullpo.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" +#include "../common/utils.hpp" #include "battle.hpp" #include "chrif.hpp" diff --git a/src/map/achievement.hpp b/src/map/achievement.hpp index 5abecdf568..7e4c288cfb 100644 --- a/src/map/achievement.hpp +++ b/src/map/achievement.hpp @@ -10,8 +10,8 @@ #include #include -#include "../common/mmo.h" -#include "../common/db.h" +#include "../common/mmo.hpp" +#include "../common/db.hpp" struct map_session_data; struct block_list; diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index a28a67e37c..ea3249d252 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -6,18 +6,19 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" +#include "../common/cli.hpp" +#include "../common/timer.hpp" +#include "../common/nullpo.hpp" +#include "../common/showmsg.hpp" +#include "../common/malloc.hpp" +#include "../common/random.hpp" +#include "../common/socket.hpp" +#include "../common/strlib.hpp" +#include "../common/utils.hpp" #include "../common/utilities.hpp" -#include "../common/conf.h" +#include "../common/conf.hpp" #include "map.hpp" #include "battle.hpp" @@ -2970,7 +2971,7 @@ ACMD_FUNC(char_block) /*========================================== * accountban command (usage: ban <%time> ) * charban command (usage: charban <%time> ) - * %time see common/timer.c::solve_time() + * %time see common/timer.cpp::solve_time() *------------------------------------------*/ ACMD_FUNC(char_ban) { diff --git a/src/map/atcommand.hpp b/src/map/atcommand.hpp index ffce9a7412..b8f762bd59 100644 --- a/src/map/atcommand.hpp +++ b/src/map/atcommand.hpp @@ -4,8 +4,8 @@ #ifndef _ATCOMMAND_HPP_ #define _ATCOMMAND_HPP_ -#include "../common/cbasetypes.h" -#include "../common/mmo.h" +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" struct map_session_data; diff --git a/src/map/battle.cpp b/src/map/battle.cpp index efa2b93cd3..fdebbd327e 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -6,16 +6,16 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/ers.h" -#include "../common/random.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#include "../common/cbasetypes.hpp" +#include "../common/timer.hpp" +#include "../common/nullpo.hpp" +#include "../common/malloc.hpp" +#include "../common/showmsg.hpp" +#include "../common/ers.hpp" +#include "../common/random.hpp" +#include "../common/socket.hpp" +#include "../common/strlib.hpp" +#include "../common/utils.hpp" #include "map.hpp" #include "path.hpp" diff --git a/src/map/battle.hpp b/src/map/battle.hpp index 314510a26f..5bcf65ee41 100644 --- a/src/map/battle.hpp +++ b/src/map/battle.hpp @@ -4,10 +4,10 @@ #ifndef _BATTLE_HPP_ #define _BATTLE_HPP_ -#include "../common/cbasetypes.h" -#include "../common/mmo.h" +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" -#include "../config/core.h" +#include "../config/core.hpp" #include "map.hpp" //ELE_MAX diff --git a/src/map/battleground.cpp b/src/map/battleground.cpp index 6d11dbac06..3f7316741d 100644 --- a/src/map/battleground.cpp +++ b/src/map/battleground.cpp @@ -3,12 +3,12 @@ #include "battleground.hpp" -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" +#include "../common/cbasetypes.hpp" +#include "../common/timer.hpp" +#include "../common/malloc.hpp" +#include "../common/nullpo.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" #include "battle.hpp" #include "clif.hpp" diff --git a/src/map/battleground.hpp b/src/map/battleground.hpp index 507428320f..36de4f245f 100644 --- a/src/map/battleground.hpp +++ b/src/map/battleground.hpp @@ -4,8 +4,8 @@ #ifndef _BATTLEGROUND_HPP_ #define _BATTLEGROUND_HPP_ -#include "../common/cbasetypes.h" -#include "../common/mmo.h" // struct party +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" // struct party #define MAX_BG_MEMBERS 30 diff --git a/src/map/buyingstore.cpp b/src/map/buyingstore.cpp index 039b223fc3..8b1656ce77 100644 --- a/src/map/buyingstore.cpp +++ b/src/map/buyingstore.cpp @@ -5,13 +5,13 @@ #include // atoi -#include "../common/nullpo.h" -#include "../common/db.h" // ARR_FIND -#include "../common/malloc.h" // aMalloc, aFree -#include "../common/showmsg.h" // ShowWarning -#include "../common/socket.h" // RBUF* -#include "../common/strlib.h" // safestrncpy -#include "../common/timer.h" // gettick +#include "../common/nullpo.hpp" +#include "../common/db.hpp" // ARR_FIND +#include "../common/malloc.hpp" // aMalloc, aFree +#include "../common/showmsg.hpp" // ShowWarning +#include "../common/socket.hpp" // RBUF* +#include "../common/strlib.hpp" // safestrncpy +#include "../common/timer.hpp" // gettick #include "atcommand.hpp" // msg_txt #include "battle.hpp" // battle_config.* diff --git a/src/map/buyingstore.hpp b/src/map/buyingstore.hpp index 812a50212a..860cfdb610 100644 --- a/src/map/buyingstore.hpp +++ b/src/map/buyingstore.hpp @@ -4,7 +4,7 @@ #ifndef _BUYINGSTORE_HPP_ #define _BUYINGSTORE_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" #include "map.hpp" //MESSAGE_SIZE diff --git a/src/map/cashshop.cpp b/src/map/cashshop.cpp index 1000115329..5c554ff1ae 100644 --- a/src/map/cashshop.cpp +++ b/src/map/cashshop.cpp @@ -6,9 +6,9 @@ #include // memset #include // atoi -#include "../common/cbasetypes.h" // uint16, uint32 -#include "../common/malloc.h" // CREATE, RECREATE, aFree -#include "../common/showmsg.h" // ShowWarning, ShowStatus +#include "../common/cbasetypes.hpp" // uint16, uint32 +#include "../common/malloc.hpp" // CREATE, RECREATE, aFree +#include "../common/showmsg.hpp" // ShowWarning, ShowStatus #include "pc.hpp" // s_map_session_data #include "pet.hpp" // pet_create_egg diff --git a/src/map/cashshop.hpp b/src/map/cashshop.hpp index fcf355f1de..a8240823cf 100644 --- a/src/map/cashshop.hpp +++ b/src/map/cashshop.hpp @@ -4,10 +4,10 @@ #ifndef _CASHSHOP_HPP_ #define _CASHSHOP_HPP_ -#include "../common/cbasetypes.h" // uint16, uint32 -#include "../common/timer.h" // ShowWarning, ShowStatus +#include "../common/cbasetypes.hpp" // uint16, uint32 +#include "../common/timer.hpp" // ShowWarning, ShowStatus -#include "../config/core.h" +#include "../config/core.hpp" struct map_session_data; diff --git a/src/map/channel.cpp b/src/map/channel.cpp index d4a42fd30d..10888365b6 100644 --- a/src/map/channel.cpp +++ b/src/map/channel.cpp @@ -5,14 +5,14 @@ #include -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/conf.h" //libconfig -#include "../common/showmsg.h" -#include "../common/strlib.h" //safestrncpy -#include "../common/socket.h" //set_eof -#include "../common/timer.h" // DIFF_TICK -#include "../common/nullpo.h" +#include "../common/cbasetypes.hpp" +#include "../common/malloc.hpp" +#include "../common/conf.hpp" //libconfig +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" //safestrncpy +#include "../common/socket.hpp" //set_eof +#include "../common/timer.hpp" // DIFF_TICK +#include "../common/nullpo.hpp" #include "map.hpp" //msg_conf #include "clif.hpp" //clif_chsys_msg diff --git a/src/map/channel.hpp b/src/map/channel.hpp index 438d9da609..0b29dcf04a 100644 --- a/src/map/channel.hpp +++ b/src/map/channel.hpp @@ -4,8 +4,8 @@ #ifndef CHANNEL_H #define CHANNEL_H -#include "../common/cbasetypes.h" -#include "../common/mmo.h" +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" //namespace rA { diff --git a/src/map/chat.cpp b/src/map/chat.cpp index 1ba3d65cbe..65d819c891 100644 --- a/src/map/chat.cpp +++ b/src/map/chat.cpp @@ -5,12 +5,12 @@ #include -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/mmo.h" +#include "../common/cbasetypes.hpp" +#include "../common/malloc.hpp" +#include "../common/nullpo.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" +#include "../common/mmo.hpp" #include "map.hpp" #include "atcommand.hpp" // msg_txt() diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp index ffb52e5d47..a2937ea2f9 100644 --- a/src/map/chrif.cpp +++ b/src/map/chrif.cpp @@ -6,14 +6,14 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/ers.h" +#include "../common/cbasetypes.hpp" +#include "../common/malloc.hpp" +#include "../common/socket.hpp" +#include "../common/timer.hpp" +#include "../common/nullpo.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" +#include "../common/ers.hpp" #include "map.hpp" #include "battle.hpp" @@ -1705,7 +1705,7 @@ int chrif_bsdata_save(struct map_session_data *sd, bool quit) { } if (i != sd->bonus_script.count && sd->bonus_script.count > MAX_PC_BONUS_SCRIPT) - ShowWarning("Only allowed to save %d (mmo.h::MAX_PC_BONUS_SCRIPT) bonus script each player.\n", MAX_PC_BONUS_SCRIPT); + ShowWarning("Only allowed to save %d (mmo.hpp::MAX_PC_BONUS_SCRIPT) bonus script each player.\n", MAX_PC_BONUS_SCRIPT); } WFIFOB(char_fd, 8) = i; diff --git a/src/map/chrif.hpp b/src/map/chrif.hpp index c58a36d811..16990428f2 100644 --- a/src/map/chrif.hpp +++ b/src/map/chrif.hpp @@ -6,8 +6,8 @@ #include -#include "../common/cbasetypes.h" -#include "../common/socket.h" // enum chrif_req_op +#include "../common/cbasetypes.hpp" +#include "../common/socket.hpp" // enum chrif_req_op //fwd declaration struct map_session_data; diff --git a/src/map/clan.cpp b/src/map/clan.cpp index d2480f8c47..7840a28627 100644 --- a/src/map/clan.cpp +++ b/src/map/clan.cpp @@ -5,11 +5,11 @@ #include //memset -#include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" +#include "../common/malloc.hpp" +#include "../common/nullpo.hpp" +#include "../common/showmsg.hpp" #include "clif.hpp" #include "intif.hpp" diff --git a/src/map/clan.hpp b/src/map/clan.hpp index 54c85ec60f..5b4309d4ac 100644 --- a/src/map/clan.hpp +++ b/src/map/clan.hpp @@ -4,7 +4,7 @@ #ifndef _CLAN_HPP_ #define _CLAN_HPP_ -#include "../common/mmo.h" +#include "../common/mmo.hpp" struct clan; struct map_session_data; diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 87799f3326..7ae702bb3d 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -9,18 +9,18 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/grfio.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" -#include "../common/conf.h" +#include "../common/cbasetypes.hpp" +#include "../common/socket.hpp" +#include "../common/timer.hpp" +#include "../common/grfio.hpp" +#include "../common/malloc.hpp" +#include "../common/nullpo.hpp" +#include "../common/random.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" +#include "../common/utils.hpp" +#include "../common/ers.hpp" +#include "../common/conf.hpp" #include "map.hpp" #include "chrif.hpp" diff --git a/src/map/clif.hpp b/src/map/clif.hpp index f5c69d6b42..dfa29fe5ca 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -6,9 +6,9 @@ #include -#include "../common/cbasetypes.h" -#include "../common/db.h" //dbmap -#include "../common/mmo.h" +#include "../common/cbasetypes.hpp" +#include "../common/db.hpp" //dbmap +#include "../common/mmo.hpp" struct Channel; struct clan; diff --git a/src/map/date.hpp b/src/map/date.hpp index 6859b0403d..c12d78fe9e 100644 --- a/src/map/date.hpp +++ b/src/map/date.hpp @@ -4,7 +4,7 @@ #ifndef _DATE_HPP_ #define _DATE_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" enum e_month{ JANUARY = 1, diff --git a/src/map/duel.cpp b/src/map/duel.cpp index 09e1f72057..858519033c 100644 --- a/src/map/duel.cpp +++ b/src/map/duel.cpp @@ -8,8 +8,8 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/timer.h" +#include "../common/cbasetypes.hpp" +#include "../common/timer.hpp" #include "atcommand.hpp" // msg_txt #include "clif.hpp" diff --git a/src/map/duel.hpp b/src/map/duel.hpp index 03ac699dfb..fad6c4338c 100644 --- a/src/map/duel.hpp +++ b/src/map/duel.hpp @@ -4,7 +4,7 @@ #ifndef _DUEL_HPP_ #define _DUEL_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" struct duel { int members_count; diff --git a/src/map/elemental.cpp b/src/map/elemental.cpp index 203c5d49ed..7699f64b1b 100644 --- a/src/map/elemental.cpp +++ b/src/map/elemental.cpp @@ -8,15 +8,15 @@ #include //floor #include -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/showmsg.h" -#include "../common/random.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#include "../common/cbasetypes.hpp" +#include "../common/malloc.hpp" +#include "../common/timer.hpp" +#include "../common/nullpo.hpp" +#include "../common/mmo.hpp" +#include "../common/showmsg.hpp" +#include "../common/random.hpp" +#include "../common/strlib.hpp" +#include "../common/utils.hpp" #include "log.hpp" #include "clif.hpp" diff --git a/src/map/elemental.hpp b/src/map/elemental.hpp index 6c4df795cc..82b911ad64 100644 --- a/src/map/elemental.hpp +++ b/src/map/elemental.hpp @@ -4,7 +4,7 @@ #ifndef _ELEMENTAL_HPP_ #define _ELEMENTAL_HPP_ -#include "../common/mmo.h" +#include "../common/mmo.hpp" #include "status.hpp" // struct status_data, struct status_change #include "unit.hpp" // struct unit_data diff --git a/src/map/guild.cpp b/src/map/guild.cpp index cd85673b16..196c3dcb2d 100644 --- a/src/map/guild.cpp +++ b/src/map/guild.cpp @@ -5,15 +5,15 @@ #include -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/mapindex.h" -#include "../common/showmsg.h" -#include "../common/ers.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#include "../common/cbasetypes.hpp" +#include "../common/timer.hpp" +#include "../common/nullpo.hpp" +#include "../common/malloc.hpp" +#include "../common/mapindex.hpp" +#include "../common/showmsg.hpp" +#include "../common/ers.hpp" +#include "../common/strlib.hpp" +#include "../common/utils.hpp" #include "map.hpp" #include "storage.hpp" diff --git a/src/map/guild.hpp b/src/map/guild.hpp index df3303ee50..7553d154f7 100644 --- a/src/map/guild.hpp +++ b/src/map/guild.hpp @@ -4,8 +4,8 @@ #ifndef _GUILD_HPP_ #define _GUILD_HPP_ -#include "../common/cbasetypes.h" -#include "../common/mmo.h" +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" #include "map.hpp" // NAME_LENGTH diff --git a/src/map/homunculus.cpp b/src/map/homunculus.cpp index e9477d254c..484ad791c4 100644 --- a/src/map/homunculus.cpp +++ b/src/map/homunculus.cpp @@ -5,15 +5,15 @@ #include -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#include "../common/cbasetypes.hpp" +#include "../common/malloc.hpp" +#include "../common/timer.hpp" +#include "../common/nullpo.hpp" +#include "../common/mmo.hpp" +#include "../common/random.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" +#include "../common/utils.hpp" #include "log.hpp" #include "clif.hpp" diff --git a/src/map/homunculus.hpp b/src/map/homunculus.hpp index 44371dc0b3..5460a3d23c 100644 --- a/src/map/homunculus.hpp +++ b/src/map/homunculus.hpp @@ -4,7 +4,7 @@ #ifndef _HOMUNCULUS_HPP_ #define _HOMUNCULUS_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" #include "status.hpp" // struct status_data, struct status_change #include "unit.hpp" // struct unit_data diff --git a/src/map/instance.cpp b/src/map/instance.cpp index 3504f0cbbb..46731bc3f5 100644 --- a/src/map/instance.cpp +++ b/src/map/instance.cpp @@ -5,15 +5,15 @@ #include -#include "../common/cbasetypes.h" -#include "../common/socket.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/ers.h" // ers_destroy +#include "../common/cbasetypes.hpp" +#include "../common/socket.hpp" +#include "../common/timer.hpp" +#include "../common/nullpo.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" +#include "../common/db.hpp" +#include "../common/malloc.hpp" +#include "../common/ers.hpp" // ers_destroy #include "clan.hpp" #include "clif.hpp" diff --git a/src/map/instance.hpp b/src/map/instance.hpp index f9d65a4f23..8c47f7c40d 100644 --- a/src/map/instance.hpp +++ b/src/map/instance.hpp @@ -4,9 +4,9 @@ #ifndef _INSTANCE_HPP_ #define _INSTANCE_HPP_ -#include "../common/cbasetypes.h" -#include "../common/mmo.h" // struct point -#include "../common/strlib.h" +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" // struct point +#include "../common/strlib.hpp" #include "script.hpp" // struct reg_db diff --git a/src/map/intif.cpp b/src/map/intif.cpp index a7e8566aa8..e588ac7143 100644 --- a/src/map/intif.cpp +++ b/src/map/intif.cpp @@ -5,13 +5,13 @@ #include -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/strlib.h" -#include "../common/mmo.h" -#include "../common/timer.h" +#include "../common/showmsg.hpp" +#include "../common/socket.hpp" +#include "../common/nullpo.hpp" +#include "../common/malloc.hpp" +#include "../common/strlib.hpp" +#include "../common/mmo.hpp" +#include "../common/timer.hpp" #include "map.hpp" #include "battle.hpp" diff --git a/src/map/intif.hpp b/src/map/intif.hpp index e0768c8c2f..2222afdf84 100644 --- a/src/map/intif.hpp +++ b/src/map/intif.hpp @@ -4,8 +4,8 @@ #ifndef _INTIF_HPP_ #define _INTIF_HPP_ -#include "../common/cbasetypes.h" -#include "../common/mmo.h" +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" struct party_member; struct guild_member; diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp index 4268dc4aff..898513da34 100644 --- a/src/map/itemdb.cpp +++ b/src/map/itemdb.cpp @@ -5,12 +5,12 @@ #include -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#include "../common/nullpo.hpp" +#include "../common/malloc.hpp" +#include "../common/random.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" +#include "../common/utils.hpp" #include "battle.hpp" // struct battle_config #include "cashshop.hpp" diff --git a/src/map/itemdb.hpp b/src/map/itemdb.hpp index c59c40df81..0fea7b2e05 100644 --- a/src/map/itemdb.hpp +++ b/src/map/itemdb.hpp @@ -4,8 +4,8 @@ #ifndef _ITEMDB_HPP_ #define _ITEMDB_HPP_ -#include "../common/db.h" -#include "../common/mmo.h" // ITEM_NAME_LENGTH +#include "../common/db.hpp" +#include "../common/mmo.hpp" // ITEM_NAME_LENGTH ///Maximum allowed Item ID (range: 1 ~ 65,534) #define MAX_ITEMID USHRT_MAX diff --git a/src/map/log.cpp b/src/map/log.cpp index fbf01b9851..cd7453f6a2 100644 --- a/src/map/log.cpp +++ b/src/map/log.cpp @@ -5,11 +5,11 @@ #include -#include "../common/cbasetypes.h" -#include "../common/sql.h" // SQL_INNODB -#include "../common/strlib.h" -#include "../common/nullpo.h" -#include "../common/showmsg.h" +#include "../common/cbasetypes.hpp" +#include "../common/sql.hpp" // SQL_INNODB +#include "../common/strlib.hpp" +#include "../common/nullpo.hpp" +#include "../common/showmsg.hpp" #include "map.hpp" #include "battle.hpp" @@ -170,12 +170,6 @@ void log_branch(struct map_session_data* sd) return; if( log_config.sql_logs ) { -#ifdef BETA_THREAD_TEST - char entry[512]; - int e_length = 0; - e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', '%s', '%s')", log_config.log_branch, sd->status.account_id, sd->status.char_id, sd->status.name, mapindex_id2name(sd->mapindex)); - queryThread_log(entry,e_length); -#else SqlStmt* stmt; stmt = SqlStmt_Malloc(logmysql_handle); if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', ?, '%s')", log_config.log_branch, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) ) @@ -187,7 +181,6 @@ void log_branch(struct map_session_data* sd) return; } SqlStmt_Free(stmt); -#endif } else { @@ -218,20 +211,12 @@ void log_pick(int id, int16 m, e_log_pick_type type, int amount, struct item* it if( log_config.sql_logs ) { -#ifdef BETA_THREAD_TEST - char entry[512]; - int e_length = 0; - e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `unique_id`, `bound`) VALUES (NOW(), '%d', '%c', '%hu', '%d', '%d', '%hu', '%hu', '%hu', '%hu', '%s', '%" PRIu64 "', '%d')", - log_config.log_pick, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"", itm->unique_id, itm->bound); - queryThread_log(entry,e_length); -#else if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `unique_id`, `bound`) VALUES (NOW(), '%d', '%c', '%hu', '%d', '%d', '%hu', '%hu', '%hu', '%hu', '%s', '%" PRIu64 "', '%d')", log_config.log_pick, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"", itm->unique_id, itm->bound) ) { Sql_ShowDebug(logmysql_handle); return; } -#endif } else { @@ -273,20 +258,12 @@ void log_zeny(struct map_session_data* sd, e_log_pick_type type, struct map_sess if( log_config.sql_logs ) { -#ifdef BETA_THREAD_TEST - char entry[512]; - int e_length = 0; - e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')", - log_config.log_zeny, sd->status.char_id, src_sd->status.char_id, log_picktype2char(type), amount, mapindex_id2name(sd->mapindex)); - queryThread_log(entry,e_length); -#else if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')", log_config.log_zeny, sd->status.char_id, src_sd->status.char_id, log_picktype2char(type), amount, mapindex_id2name(sd->mapindex)) ) { Sql_ShowDebug(logmysql_handle); return; } -#endif } else { @@ -314,20 +291,12 @@ void log_mvpdrop(struct map_session_data* sd, int monster_id, unsigned int* log_ if( log_config.sql_logs ) { -#ifdef BETA_THREAD_TEST - char entry[512]; - int e_length = 0; - e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%hu', '%u', '%s') ", - log_config.log_mvpdrop, sd->status.char_id, monster_id, (unsigned short)log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex)); - queryThread_log(entry,e_length); -#else if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%hu', '%u', '%s') ", log_config.log_mvpdrop, sd->status.char_id, monster_id, (unsigned short)log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex)) ) { Sql_ShowDebug(logmysql_handle); return; } -#endif } else { @@ -356,12 +325,6 @@ void log_atcommand(struct map_session_data* sd, const char* message) if( log_config.sql_logs ) { -#ifdef BETA_THREAD_TEST - char entry[512]; - int e_length = 0; - e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES (NOW(), '%d', '%d', '%s', '%s', '%s')", log_config.log_gm, sd->status.account_id, sd->status.char_id, sd->status.name ,mapindex_id2name(sd->mapindex), message); - queryThread_log(entry,e_length); -#else SqlStmt* stmt; stmt = SqlStmt_Malloc(logmysql_handle); @@ -375,7 +338,6 @@ void log_atcommand(struct map_session_data* sd, const char* message) return; } SqlStmt_Free(stmt); -#endif } else { @@ -403,12 +365,6 @@ void log_npc(struct map_session_data* sd, const char* message) if( log_config.sql_logs ) { -#ifdef BETA_THREAD_TEST - char entry[512]; - int e_length = 0; - e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES (NOW(), '%d', '%d', '%s', '%s', '%s')", log_config.log_npc, sd->status.account_id, sd->status.char_id, sd->status.name, mapindex_id2name(sd->mapindex), message ); - queryThread_log(entry,e_length); -#else SqlStmt* stmt; stmt = SqlStmt_Malloc(logmysql_handle); if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", log_config.log_npc, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) ) @@ -421,7 +377,6 @@ void log_npc(struct map_session_data* sd, const char* message) return; } SqlStmt_Free(stmt); -#endif } else { @@ -453,12 +408,6 @@ void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, } if( log_config.sql_logs ) { -#ifdef BETA_THREAD_TEST - char entry[512]; - int e_length = 0; - e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', '%s', '%s')", log_config.log_chat, log_chattype2char(type), type_id, src_charid, src_accid, mapname, x, y, dst_charname, message ); - queryThread_log(entry,e_length); -#else SqlStmt* stmt; stmt = SqlStmt_Malloc(logmysql_handle); @@ -472,7 +421,6 @@ void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, return; } SqlStmt_Free(stmt); -#endif } else { @@ -497,20 +445,12 @@ void log_cash( struct map_session_data* sd, e_log_pick_type type, e_log_cash_typ return; if( log_config.sql_logs ){ -#ifdef BETA_THREAD_TEST - char entry[512]; - int e_length = 0; - e_length = sprintf( entry, LOG_QUERY " INTO `%s` ( `time`, `char_id`, `type`, `cash_type`, `amount`, `map` ) VALUES ( NOW(), '%d', '%c', '%c', '%d', '%s' )", - log_config.log_cash, sd->status.char_id, log_picktype2char( type ), log_cashtype2char( cash_type ), amount, mapindex_id2name( sd->mapindex ) ); - queryThread_log( entry, e_length ); -#else if( SQL_ERROR == Sql_Query( logmysql_handle, LOG_QUERY " INTO `%s` ( `time`, `char_id`, `type`, `cash_type`, `amount`, `map` ) VALUES ( NOW(), '%d', '%c', '%c', '%d', '%s' )", log_config.log_cash, sd->status.char_id, log_picktype2char( type ), log_cashtype2char( cash_type ), amount, mapindex_id2name( sd->mapindex ) ) ) { Sql_ShowDebug( logmysql_handle ); return; } -#endif }else{ char timestring[255]; time_t curtime; @@ -558,20 +498,12 @@ void log_feeding(struct map_session_data *sd, e_log_feeding_type type, unsigned } if (log_config.sql_logs) { -#ifdef BETA_THREAD_TEST - char entry[512]; - int e_length = 0; - e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`time`, `char_id`, `target_id`, `target_class`, `type`, `intimacy`, `item_id`, `map`, `x`, `y`) VALUES ( NOW(), '%" PRIu32 "', '%" PRIu32 "', '%hu', '%c', '%" PRIu32 "', '%hu', '%s', '%hu', '%hu' )", - log_config.log_feeding, sd->status.char_id, target_id, target_class, log_feedingtype2char(type), intimacy, nameid, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y); - queryThread_log(entry, e_length); -#else if (SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `target_id`, `target_class`, `type`, `intimacy`, `item_id`, `map`, `x`, `y`) VALUES ( NOW(), '%" PRIu32 "', '%" PRIu32 "', '%hu', '%c', '%" PRIu32 "', '%hu', '%s', '%hu', '%hu' )", log_config.log_feeding, sd->status.char_id, target_id, target_class, log_feedingtype2char(type), intimacy, nameid, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y)) { Sql_ShowDebug(logmysql_handle); return; } -#endif } else { char timestring[255]; time_t curtime; diff --git a/src/map/log.hpp b/src/map/log.hpp index a0b80accad..6dc3114974 100644 --- a/src/map/log.hpp +++ b/src/map/log.hpp @@ -4,7 +4,7 @@ #ifndef _LOG_HPP_ #define _LOG_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" struct block_list; struct map_session_data; @@ -97,11 +97,4 @@ extern struct Log_Config char log_feeding[64]; } log_config; -#ifdef BETA_THREAD_TEST - struct { - char** entry; - int count; - } logThreadData; -#endif - #endif /* _LOG_HPP_ */ diff --git a/src/map/mail.cpp b/src/map/mail.cpp index ee9c9635f3..3a028b8580 100644 --- a/src/map/mail.cpp +++ b/src/map/mail.cpp @@ -3,10 +3,10 @@ #include "mail.hpp" -#include "../common/nullpo.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/timer.h" +#include "../common/nullpo.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" +#include "../common/timer.hpp" #include "atcommand.hpp" #include "itemdb.hpp" diff --git a/src/map/mail.hpp b/src/map/mail.hpp index 99594b0c13..25796113e0 100644 --- a/src/map/mail.hpp +++ b/src/map/mail.hpp @@ -4,7 +4,7 @@ #ifndef _MAIL_HPP_ #define _MAIL_HPP_ -#include "../common/mmo.h" +#include "../common/mmo.hpp" enum mail_attach_result { MAIL_ATTACH_SUCCESS = 0, diff --git a/src/map/map-server.vcxproj b/src/map/map-server.vcxproj index 107b105b1f..4c634905d9 100644 --- a/src/map/map-server.vcxproj +++ b/src/map/map-server.vcxproj @@ -100,7 +100,7 @@ Console true - ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir).vs\build\mt19937ar.lib;$(SolutionDir)3rdparty\zlib\lib\$(Platform)\zlib.lib;$(SolutionDir)3rdparty\pcre\lib\$(Platform)\pcre8.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) + ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir)3rdparty\zlib\lib\$(Platform)\zlib.lib;$(SolutionDir)3rdparty\pcre\lib\$(Platform)\pcre8.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) @@ -117,7 +117,7 @@ Console true - ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir).vs\build\mt19937ar.lib;$(SolutionDir)3rdparty\zlib\lib\$(Platform)\zlib.lib;$(SolutionDir)3rdparty\pcre\lib\$(Platform)\pcre8.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) + ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir)3rdparty\zlib\lib\$(Platform)\zlib.lib;$(SolutionDir)3rdparty\pcre\lib\$(Platform)\pcre8.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) @@ -138,7 +138,7 @@ true true true - ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir).vs\build\mt19937ar.lib;$(SolutionDir)3rdparty\zlib\lib\$(Platform)\zlib.lib;$(SolutionDir)3rdparty\pcre\lib\$(Platform)\pcre8.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) + ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir)3rdparty\zlib\lib\$(Platform)\zlib.lib;$(SolutionDir)3rdparty\pcre\lib\$(Platform)\pcre8.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) @@ -159,7 +159,7 @@ true true true - ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir).vs\build\mt19937ar.lib;$(SolutionDir)3rdparty\zlib\lib\$(Platform)\zlib.lib;$(SolutionDir)3rdparty\pcre\lib\$(Platform)\pcre8.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) + ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir)3rdparty\zlib\lib\$(Platform)\zlib.lib;$(SolutionDir)3rdparty\pcre\lib\$(Platform)\pcre8.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) diff --git a/src/map/map.cpp b/src/map/map.cpp index c61ab14678..cf30daffca 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -6,19 +6,19 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/core.h" -#include "../common/timer.h" -#include "../common/grfio.h" -#include "../common/malloc.h" -#include "../common/socket.h" // WFIFO*() -#include "../common/showmsg.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/cli.h" -#include "../common/ers.h" +#include "../common/cbasetypes.hpp" +#include "../common/core.hpp" +#include "../common/timer.hpp" +#include "../common/grfio.hpp" +#include "../common/malloc.hpp" +#include "../common/socket.hpp" // WFIFO*() +#include "../common/showmsg.hpp" +#include "../common/nullpo.hpp" +#include "../common/random.hpp" +#include "../common/strlib.hpp" +#include "../common/utils.hpp" +#include "../common/cli.hpp" +#include "../common/ers.hpp" #include "path.hpp" #include "chrif.hpp" @@ -4106,20 +4106,19 @@ int map_sql_close(void) Sql_Free(qsmysql_handle); mmysql_handle = NULL; qsmysql_handle = NULL; -#ifndef BETA_THREAD_TEST + if (log_config.sql_logs) { ShowStatus("Close Log DB Connection....\n"); Sql_Free(logmysql_handle); logmysql_handle = NULL; } -#endif + return 0; } int log_sql_init(void) { -#ifndef BETA_THREAD_TEST // log db connection logmysql_handle = Sql_Malloc(); @@ -4136,7 +4135,7 @@ int log_sql_init(void) if( strlen(default_codepage) > 0 ) if ( SQL_ERROR == Sql_SetEncoding(logmysql_handle, default_codepage) ) Sql_ShowDebug(logmysql_handle); -#endif + return 0; } diff --git a/src/map/map.hpp b/src/map/map.hpp index 0f6a93a204..cfb6b8b996 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -6,26 +6,14 @@ #include -#include "../common/cbasetypes.h" -#include "../common/core.h" // CORE_ST_LAST -#include "../common/mmo.h" -#include "../common/mapindex.h" -#include "../common/db.h" -#include "../common/msg_conf.h" +#include "../common/cbasetypes.hpp" +#include "../common/core.hpp" // CORE_ST_LAST +#include "../common/mmo.hpp" +#include "../common/mapindex.hpp" +#include "../common/db.hpp" +#include "../common/msg_conf.hpp" -#include "../config/core.h" - -extern "C" { - //Options read in cli (c-linkage for now) - extern const char*INTER_CONF_NAME; - extern const char*LOG_CONF_NAME; - extern const char*MAP_CONF_NAME; - extern const char*BATTLE_CONF_FILENAME; - extern const char*ATCOMMAND_CONF_FILENAME; - extern const char*SCRIPT_CONF_NAME; - extern const char*MSG_CONF_NAME_EN; - extern const char*GRF_PATH_FILENAME; -} +#include "../config/core.hpp" struct npc_data; struct item_data; @@ -970,25 +958,7 @@ typedef struct elemental_data TBL_ELEM; #define BL_CAST(type_, bl) \ ( ((bl) == (struct block_list*)NULL || (bl)->type != (type_)) ? (T ## type_ *)NULL : (T ## type_ *)(bl) ) - -#ifdef BETA_THREAD_TEST - -extern char default_codepage[32]; -extern int map_server_port; -extern char map_server_ip[32]; -extern char map_server_id[32]; -extern char map_server_pw[32]; -extern char map_server_db[32]; - -extern char log_db_ip[32]; -extern int log_db_port; -extern char log_db_id[32]; -extern char log_db_pw[32]; -extern char log_db_db[32]; - -#endif - -#include "../common/sql.h" +#include "../common/sql.hpp" extern int db_use_sqldbs; diff --git a/src/map/mapreg.cpp b/src/map/mapreg.cpp index 77facc29f1..94ddf2b15e 100644 --- a/src/map/mapreg.cpp +++ b/src/map/mapreg.cpp @@ -5,14 +5,14 @@ #include -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/ers.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/sql.h" -#include "../common/strlib.h" -#include "../common/timer.h" +#include "../common/cbasetypes.hpp" +#include "../common/db.hpp" +#include "../common/ers.hpp" +#include "../common/malloc.hpp" +#include "../common/showmsg.hpp" +#include "../common/sql.hpp" +#include "../common/strlib.hpp" +#include "../common/timer.hpp" #include "map.hpp" // mmysql_handle #include "script.hpp" diff --git a/src/map/mapreg.hpp b/src/map/mapreg.hpp index 48b101fb8d..8b757e5a78 100644 --- a/src/map/mapreg.hpp +++ b/src/map/mapreg.hpp @@ -4,8 +4,8 @@ #ifndef _MAPREG_HPP_ #define _MAPREG_HPP_ -#include "../common/cbasetypes.h" -#include "../common/db.h" +#include "../common/cbasetypes.hpp" +#include "../common/db.hpp" struct mapreg_save { int64 uid; ///< Unique ID diff --git a/src/map/mercenary.cpp b/src/map/mercenary.cpp index c0c78b8451..b31a8a4b9f 100644 --- a/src/map/mercenary.cpp +++ b/src/map/mercenary.cpp @@ -9,15 +9,15 @@ #include "../common/utilities.hpp" -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/mmo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" +#include "../common/cbasetypes.hpp" +#include "../common/malloc.hpp" +#include "../common/timer.hpp" +#include "../common/nullpo.hpp" +#include "../common/mmo.hpp" +#include "../common/random.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" +#include "../common/utils.hpp" #include "log.hpp" #include "clif.hpp" diff --git a/src/map/mercenary.hpp b/src/map/mercenary.hpp index 6d3a447128..1b2139f73b 100644 --- a/src/map/mercenary.hpp +++ b/src/map/mercenary.hpp @@ -4,7 +4,7 @@ #ifndef _MERCENARY_HPP_ #define _MERCENARY_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" #include "status.hpp" // struct status_data, struct status_change #include "unit.hpp" // struct unit_data diff --git a/src/map/mob.cpp b/src/map/mob.cpp index e8a744c9ca..beb38d3c47 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -9,17 +9,17 @@ #include "../common/utilities.hpp" -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/db.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/ers.h" -#include "../common/random.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/socket.h" +#include "../common/cbasetypes.hpp" +#include "../common/timer.hpp" +#include "../common/db.hpp" +#include "../common/nullpo.hpp" +#include "../common/malloc.hpp" +#include "../common/showmsg.hpp" +#include "../common/ers.hpp" +#include "../common/random.hpp" +#include "../common/strlib.hpp" +#include "../common/utils.hpp" +#include "../common/socket.hpp" #include "map.hpp" #include "path.hpp" diff --git a/src/map/mob.hpp b/src/map/mob.hpp index efad1f2fdf..bfa7950b0b 100644 --- a/src/map/mob.hpp +++ b/src/map/mob.hpp @@ -4,7 +4,7 @@ #ifndef _MOB_HPP_ #define _MOB_HPP_ -#include "../common/mmo.h" // struct item +#include "../common/mmo.hpp" // struct item #include "status.hpp" // struct status data, struct status_change #include "unit.hpp" // unit_stop_walking(), unit_stop_attack() diff --git a/src/map/npc.cpp b/src/map/npc.cpp index 257b4710a7..35181ee5b6 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -9,15 +9,15 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" -#include "../common/db.h" +#include "../common/cbasetypes.hpp" +#include "../common/timer.hpp" +#include "../common/nullpo.hpp" +#include "../common/malloc.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" +#include "../common/utils.hpp" +#include "../common/ers.hpp" +#include "../common/db.hpp" #include "map.hpp" #include "log.hpp" @@ -267,7 +267,7 @@ struct npc_data* npc_name2id(const char* name) return (struct npc_data *) strdb_get(npcname_db, name); } /** - * For the Secure NPC Timeout option (check config/Secure.h) [RR] + * For the Secure NPC Timeout option (check src/config/secure.hpp) [RR] **/ #ifdef SECURE_NPCTIMEOUT /** @@ -4253,7 +4253,7 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con } } #else - ShowInfo("npc_parse_mapflag: skill_damage: ADJUST_SKILL_DAMAGE is inactive (core.h). Skipping this mapflag..\n"); + ShowInfo("npc_parse_mapflag: skill_damage: ADJUST_SKILL_DAMAGE is inactive (core.hpp). Skipping this mapflag..\n"); #endif } else diff --git a/src/map/npc_chat.cpp b/src/map/npc_chat.cpp index 8d8e5d1302..6cafb6219b 100644 --- a/src/map/npc_chat.cpp +++ b/src/map/npc_chat.cpp @@ -7,10 +7,10 @@ #include "../../3rdparty/pcre/include/pcre.h" -#include "../common/timer.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" +#include "../common/timer.hpp" +#include "../common/malloc.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" #include "mob.hpp" // struct mob_data #include "pc.hpp" // struct map_session_data diff --git a/src/map/party.cpp b/src/map/party.cpp index 8c96c62050..aa67d81e19 100644 --- a/src/map/party.cpp +++ b/src/map/party.cpp @@ -5,15 +5,15 @@ #include -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/socket.h" // last_tick -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/utils.h" -#include "../common/strlib.h" +#include "../common/cbasetypes.hpp" +#include "../common/timer.hpp" +#include "../common/socket.hpp" // last_tick +#include "../common/nullpo.hpp" +#include "../common/malloc.hpp" +#include "../common/random.hpp" +#include "../common/showmsg.hpp" +#include "../common/utils.hpp" +#include "../common/strlib.hpp" #include "atcommand.hpp" //msg_txt() #include "pc.hpp" diff --git a/src/map/party.hpp b/src/map/party.hpp index 3abb970828..f23e32fad5 100644 --- a/src/map/party.hpp +++ b/src/map/party.hpp @@ -6,7 +6,7 @@ #include -#include "../common/mmo.h" // struct party +#include "../common/mmo.hpp" // struct party struct block_list; struct map_session_data; diff --git a/src/map/path.cpp b/src/map/path.cpp index 8fd10d0ead..afd40775f3 100644 --- a/src/map/path.cpp +++ b/src/map/path.cpp @@ -8,12 +8,12 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" +#include "../common/cbasetypes.hpp" +#include "../common/db.hpp" +#include "../common/malloc.hpp" +#include "../common/nullpo.hpp" +#include "../common/random.hpp" +#include "../common/showmsg.hpp" #include "map.hpp" #include "battle.hpp" diff --git a/src/map/path.hpp b/src/map/path.hpp index 5227bcccc2..8c8172ce05 100644 --- a/src/map/path.hpp +++ b/src/map/path.hpp @@ -4,7 +4,7 @@ #ifndef _PATH_HPP_ #define _PATH_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" enum cell_chk : uint8; diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 32b3865e0a..5f762c3bfc 100755 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -6,18 +6,18 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/core.h" // get_svn_revision() -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" // session[] -#include "../common/strlib.h" // safestrncpy() -#include "../common/timer.h" -#include "../common/utils.h" -#include "../common/mmo.h" //NAME_LENGTH -#include "../common/ers.h" // ers_destroy +#include "../common/cbasetypes.hpp" +#include "../common/core.hpp" // get_svn_revision() +#include "../common/malloc.hpp" +#include "../common/nullpo.hpp" +#include "../common/random.hpp" +#include "../common/showmsg.hpp" +#include "../common/socket.hpp" // session[] +#include "../common/strlib.hpp" // safestrncpy() +#include "../common/timer.hpp" +#include "../common/utils.hpp" +#include "../common/mmo.hpp" //NAME_LENGTH +#include "../common/ers.hpp" // ers_destroy #include "atcommand.hpp" // get_atcommand_level() #include "map.hpp" diff --git a/src/map/pc.hpp b/src/map/pc.hpp index 3e56ee494e..05187a0505 100644 --- a/src/map/pc.hpp +++ b/src/map/pc.hpp @@ -6,8 +6,8 @@ #include -#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus -#include "../common/strlib.h"// StringBuf +#include "../common/mmo.hpp" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus +#include "../common/strlib.hpp"// StringBuf #include "map.hpp" // RC_ALL #include "itemdb.hpp" // MAX_ITEMGROUP diff --git a/src/map/pc_groups.cpp b/src/map/pc_groups.cpp index 5e74b240a6..608cc8ee85 100644 --- a/src/map/pc_groups.cpp +++ b/src/map/pc_groups.cpp @@ -3,12 +3,12 @@ #include "pc_groups.hpp" -#include "../common/conf.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" // strcmp -#include "../common/socket.h" +#include "../common/conf.hpp" +#include "../common/db.hpp" +#include "../common/malloc.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" // strcmp +#include "../common/socket.hpp" #include "atcommand.hpp" // AtCommandType #include "pc.hpp" // e_pc_permission diff --git a/src/map/pc_groups.hpp b/src/map/pc_groups.hpp index 4d44eb74bc..c4b89ce824 100644 --- a/src/map/pc_groups.hpp +++ b/src/map/pc_groups.hpp @@ -4,7 +4,7 @@ #ifndef _PC_GROUPS_HPP_ #define _PC_GROUPS_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" enum AtCommandType : uint8; diff --git a/src/map/pet.cpp b/src/map/pet.cpp index f6d3290998..f7acbe9546 100644 --- a/src/map/pet.cpp +++ b/src/map/pet.cpp @@ -9,15 +9,15 @@ #include "../common/utilities.hpp" -#include "../common/db.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" +#include "../common/db.hpp" +#include "../common/timer.hpp" +#include "../common/nullpo.hpp" +#include "../common/malloc.hpp" +#include "../common/random.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" +#include "../common/utils.hpp" +#include "../common/ers.hpp" #include "pc.hpp" #include "intif.hpp" diff --git a/src/map/pet.hpp b/src/map/pet.hpp index 1436a4d519..eba53c051e 100644 --- a/src/map/pet.hpp +++ b/src/map/pet.hpp @@ -4,8 +4,8 @@ #ifndef _PET_HPP_ #define _PET_HPP_ -#include "../common/cbasetypes.h" -#include "../common/mmo.h" +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" #include "script.hpp" #include "status.hpp" diff --git a/src/map/quest.cpp b/src/map/quest.cpp index 79d680514f..cb2dcb63f3 100644 --- a/src/map/quest.cpp +++ b/src/map/quest.cpp @@ -5,13 +5,13 @@ #include -#include "../common/cbasetypes.h" -#include "../common/socket.h" -#include "../common/malloc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" +#include "../common/cbasetypes.hpp" +#include "../common/socket.hpp" +#include "../common/malloc.hpp" +#include "../common/nullpo.hpp" +#include "../common/random.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" #include "itemdb.hpp" #include "map.hpp" diff --git a/src/map/quest.hpp b/src/map/quest.hpp index bb02651df3..a9a8fce886 100644 --- a/src/map/quest.hpp +++ b/src/map/quest.hpp @@ -4,8 +4,8 @@ #ifndef _QUEST_HPP_ #define _QUEST_HPP_ -#include "../common/cbasetypes.h" -#include "../common/strlib.h" +#include "../common/cbasetypes.hpp" +#include "../common/strlib.hpp" #include "map.hpp" diff --git a/src/map/script.cpp b/src/map/script.cpp index 7c818a232e..ac209fe65d 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -18,23 +18,17 @@ #include "../../3rdparty/pcre/include/pcre.h" // preg_match #endif -#include "../common/cbasetypes.h" -#include "../common/malloc.h" -#include "../common/md5calc.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/socket.h" -#include "../common/strlib.h" -#include "../common/timer.h" -#include "../common/utils.h" -#include "../common/ers.h" // ers_destroy -#ifdef BETA_THREAD_TEST - #include "../common/atomic.h" - #include "../common/spinlock.h" - #include "../common/thread.h" - #include "../common/mutex.h" -#endif +#include "../common/cbasetypes.hpp" +#include "../common/malloc.hpp" +#include "../common/md5calc.hpp" +#include "../common/nullpo.hpp" +#include "../common/random.hpp" +#include "../common/showmsg.hpp" +#include "../common/socket.hpp" +#include "../common/strlib.hpp" +#include "../common/timer.hpp" +#include "../common/utils.hpp" +#include "../common/ers.hpp" // ers_destroy #include "map.hpp" #include "path.hpp" @@ -379,30 +373,6 @@ extern script_function buildin_func[]; static struct linkdb_node *sleep_db; // int oid -> struct script_state * -#ifdef BETA_THREAD_TEST -/** - * MySQL Query Slave - **/ -static SPIN_LOCK queryThreadLock; -static rAthread queryThread = NULL; -static ramutex queryThreadMutex = NULL; -static racond queryThreadCond = NULL; -static volatile int32 queryThreadTerminate = 0; - -struct queryThreadEntry { - bool ok; - bool type; /* main db or log db? */ - struct script_state *st; -}; - -/* Ladies and Gentleman the Manager! */ -struct { - struct queryThreadEntry **entry;/* array of structs */ - int count; - int timer;/* used to receive processed entries */ -} queryThreadData; -#endif - /*========================================== * (Only those needed) local declaration prototype *------------------------------------------*/ @@ -4639,185 +4609,6 @@ void script_generic_ui_array_expand (unsigned int plus) RECREATE(generic_ui_array, unsigned int, generic_ui_array_size); } -int buildin_query_sql_sub(struct script_state *st, Sql *handle); - -#ifdef BETA_THREAD_TEST -/* used to receive items the queryThread has already processed */ -int queryThread_timer(int tid, unsigned int tick, int id, intptr_t data) { - int i, cursor = 0; - bool allOk = true; - - EnterSpinLock(&queryThreadLock); - - for( i = 0; i < queryThreadData.count; i++ ) { - struct queryThreadEntry *entry = queryThreadData.entry[i]; - - if( !entry->ok ) { - allOk = false; - continue; - } - - run_script_main(entry->st); - - entry->st = NULL;/* empty entries */ - aFree(entry); - queryThreadData.entry[i] = NULL; - } - - - if( allOk ) { - /* cancel the repeating timer -- it'll re-create itself when necessary, dont need to remain looping */ - delete_timer(queryThreadData.timer, queryThread_timer); - queryThreadData.timer = INVALID_TIMER; - } - - /* now lets clear the mess. */ - for( i = 0; i < queryThreadData.count; i++ ) { - struct queryThreadEntry *entry = queryThreadData.entry[i]; - if( entry == NULL ) - continue;/* entry on hold */ - - /* move */ - memmove(&queryThreadData.entry[cursor], &queryThreadData.entry[i], sizeof(struct queryThreadEntry*)); - - cursor++; - } - - queryThreadData.count = cursor; - - LeaveSpinLock(&queryThreadLock); - - return 0; -} - -void queryThread_add(struct script_state *st, bool type) { - int idx = 0; - struct queryThreadEntry* entry = NULL; - - EnterSpinLock(&queryThreadLock); - - if( queryThreadData.count++ != 0 ) - RECREATE(queryThreadData.entry, struct queryThreadEntry* , queryThreadData.count); - - idx = queryThreadData.count-1; - - CREATE(queryThreadData.entry[idx],struct queryThreadEntry,1); - - entry = queryThreadData.entry[idx]; - - entry->st = st; - entry->ok = false; - entry->type = type; - if( queryThreadData.timer == INVALID_TIMER ) { /* start the receiver timer */ - queryThreadData.timer = add_timer_interval(gettick() + 100, queryThread_timer, 0, 0, 100); - } - - LeaveSpinLock(&queryThreadLock); - - /* unlock the queryThread */ - racond_signal(queryThreadCond); -} -/* adds a new log to the queue */ -void queryThread_log(char * entry, int length) { - int idx = logThreadData.count; - - EnterSpinLock(&queryThreadLock); - - if( logThreadData.count++ != 0 ) - RECREATE(logThreadData.entry, char* , logThreadData.count); - - CREATE(logThreadData.entry[idx], char, length + 1 ); - safestrncpy(logThreadData.entry[idx], entry, length + 1 ); - - LeaveSpinLock(&queryThreadLock); - - /* unlock the queryThread */ - racond_signal(queryThreadCond); -} - -/* queryThread_main */ -static void *queryThread_main(void *x) { - Sql *queryThread_handle = Sql_Malloc(); - int i; - - if ( SQL_ERROR == Sql_Connect(queryThread_handle, map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db) ){ - ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n", - map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db); - Sql_ShowDebug(queryThread_handle); - Sql_Free(queryThread_handle); - exit(EXIT_FAILURE); - } - - if( strlen(default_codepage) > 0 ) - if ( SQL_ERROR == Sql_SetEncoding(queryThread_handle, default_codepage) ) - Sql_ShowDebug(queryThread_handle); - - if( log_config.sql_logs ) { - logmysql_handle = Sql_Malloc(); - - if ( SQL_ERROR == Sql_Connect(logmysql_handle, log_db_id, log_db_pw, log_db_ip, log_db_port, log_db_db) ){ - ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n", - log_db_id, log_db_pw, log_db_ip, log_db_port, log_db_db); - Sql_ShowDebug(logmysql_handle); - Sql_Free(logmysql_handle); - exit(EXIT_FAILURE); - } - - if( strlen(default_codepage) > 0 ) - if ( SQL_ERROR == Sql_SetEncoding(logmysql_handle, default_codepage) ) - Sql_ShowDebug(logmysql_handle); - } - - while( 1 ) { - - if(queryThreadTerminate > 0) - break; - - EnterSpinLock(&queryThreadLock); - - /* mess with queryThreadData within the lock */ - for( i = 0; i < queryThreadData.count; i++ ) { - struct queryThreadEntry *entry = queryThreadData.entry[i]; - - if( entry->ok ) - continue; - else if ( !entry->st || !entry->st->stack ) { - entry->ok = true;/* dispose */ - continue; - } - - buildin_query_sql_sub(entry->st, entry->type ? logmysql_handle : queryThread_handle); - - entry->ok = true;/* we're done with this */ - } - - /* also check for any logs in need to be sent */ - if( log_config.sql_logs ) { - for( i = 0; i < logThreadData.count; i++ ) { - if( SQL_ERROR == Sql_Query(logmysql_handle, logThreadData.entry[i]) ) - Sql_ShowDebug(logmysql_handle); - aFree(logThreadData.entry[i]); - } - logThreadData.count = 0; - } - - LeaveSpinLock(&queryThreadLock); - - ramutex_lock( queryThreadMutex ); - racond_wait( queryThreadCond, queryThreadMutex, -1 ); - ramutex_unlock( queryThreadMutex ); - - } - - Sql_Free(queryThread_handle); - - if( log_config.sql_logs ) { - Sql_Free(logmysql_handle); - } - - return NULL; -} -#endif /*========================================== * Destructor *------------------------------------------*/ @@ -4911,30 +4702,6 @@ void do_final_script() { ers_destroy(st_ers); ers_destroy(stack_ers); db_destroy(st_db); - -#ifdef BETA_THREAD_TEST - /* QueryThread */ - InterlockedIncrement(&queryThreadTerminate); - racond_signal(queryThreadCond); - rathread_wait(queryThread, NULL); - - // Destroy cond var and mutex. - racond_destroy( queryThreadCond ); - ramutex_destroy( queryThreadMutex ); - - /* Clear missing vars */ - for( i = 0; i < queryThreadData.count; i++ ) { - aFree(queryThreadData.entry[i]); - } - - aFree(queryThreadData.entry); - - for( i = 0; i < logThreadData.count; i++ ) { - aFree(logThreadData.entry[i]); - } - - aFree(logThreadData.entry); -#endif } /*========================================== * Initialization @@ -4956,29 +4723,6 @@ void do_init_script(void) { next_id = 0; mapreg_init(); -#ifdef BETA_THREAD_TEST - CREATE(queryThreadData.entry, struct queryThreadEntry*, 1); - queryThreadData.count = 0; - CREATE(logThreadData.entry, char *, 1); - logThreadData.count = 0; - /* QueryThread Start */ - - InitializeSpinLock(&queryThreadLock); - - queryThreadData.timer = INVALID_TIMER; - queryThreadTerminate = 0; - queryThreadMutex = ramutex_create(); - queryThreadCond = racond_create(); - - queryThread = rathread_create(queryThread_main, NULL); - - if(queryThread == NULL){ - ShowFatalError("do_init_script: cannot spawn Query Thread.\n"); - exit(EXIT_FAILURE); - } - - add_timer_func_list(queryThread_timer, "queryThread_timer"); -#endif } void script_reload(void) { @@ -4986,23 +4730,6 @@ void script_reload(void) { DBIterator *iter; struct script_state *st; -#ifdef BETA_THREAD_TEST - /* we're reloading so any queries undergoing should be...exterminated. */ - EnterSpinLock(&queryThreadLock); - - for( i = 0; i < queryThreadData.count; i++ ) { - aFree(queryThreadData.entry[i]); - } - queryThreadData.count = 0; - - if( queryThreadData.timer != INVALID_TIMER ) { - delete_timer(queryThreadData.timer, queryThread_timer); - queryThreadData.timer = INVALID_TIMER; - } - - LeaveSpinLock(&queryThreadLock); -#endif - userfunc_db->clear(userfunc_db, db_script_free_code_sub); db_clear(scriptlabel_db); @@ -16928,18 +16655,7 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle) } BUILDIN_FUNC(query_sql) { -#ifdef BETA_THREAD_TEST - if( st->state != RERUNLINE ) { - queryThread_add(st,false); - - st->state = RERUNLINE;/* will continue when the query is finished running. */ - } else - st->state = RUN; - - return SCRIPT_CMD_SUCCESS; -#else return buildin_query_sql_sub(st, qsmysql_handle); -#endif } BUILDIN_FUNC(query_logsql) { @@ -16948,18 +16664,8 @@ BUILDIN_FUNC(query_logsql) { script_pushint(st,-1); return SCRIPT_CMD_FAILURE; } -#ifdef BETA_THREAD_TEST - if( st->state != RERUNLINE ) { - queryThread_add(st,true); - st->state = RERUNLINE;/* will continue when the query is finished running. */ - } else - st->state = RUN; - - return SCRIPT_CMD_SUCCESS; -#else return buildin_query_sql_sub(st, logmysql_handle); -#endif } //Allows escaping of a given string. diff --git a/src/map/script.hpp b/src/map/script.hpp index f4511df4d5..51b196e1e4 100644 --- a/src/map/script.hpp +++ b/src/map/script.hpp @@ -4,9 +4,9 @@ #ifndef _SCRIPT_HPP_ #define _SCRIPT_HPP_ -#include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/mmo.h" +#include "../common/cbasetypes.hpp" +#include "../common/db.hpp" +#include "../common/mmo.hpp" #define NUM_WHISPER_VAR 10 @@ -1978,10 +1978,6 @@ int script_reg_destroy(DBKey key, DBData *data, va_list ap); void script_generic_ui_array_expand(unsigned int plus); unsigned int *script_array_cpy_list(struct script_array *sa); -#ifdef BETA_THREAD_TEST -void queryThread_log(char * entry, int length); -#endif - bool script_check_RegistryVariableLength(int pType, const char *val, size_t* vlen); #endif /* _SCRIPT_HPP_ */ diff --git a/src/map/searchstore.cpp b/src/map/searchstore.cpp index 0ba554af8a..412302b121 100644 --- a/src/map/searchstore.cpp +++ b/src/map/searchstore.cpp @@ -3,10 +3,10 @@ #include "searchstore.hpp" // struct s_search_store_info -#include "../common/cbasetypes.h" -#include "../common/malloc.h" // aMalloc, aRealloc, aFree -#include "../common/showmsg.h" // ShowError, ShowWarning -#include "../common/strlib.h" // safestrncpy +#include "../common/cbasetypes.hpp" +#include "../common/malloc.hpp" // aMalloc, aRealloc, aFree +#include "../common/showmsg.hpp" // ShowError, ShowWarning +#include "../common/strlib.hpp" // safestrncpy #include "battle.hpp" // battle_config.* #include "clif.hpp" // clif_open_search_store_info, clif_search_store_info_* diff --git a/src/map/searchstore.hpp b/src/map/searchstore.hpp index c52b8820d5..c072be4cfc 100644 --- a/src/map/searchstore.hpp +++ b/src/map/searchstore.hpp @@ -4,8 +4,8 @@ #ifndef _SEARCHSTORE_HPP_ #define _SEARCHSTORE_HPP_ -#include "../common/cbasetypes.h" -#include "../common/mmo.h" +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" #include "map.hpp" diff --git a/src/map/skill.cpp b/src/map/skill.cpp index e917786748..b8ee5b552a 100755 --- a/src/map/skill.cpp +++ b/src/map/skill.cpp @@ -9,15 +9,15 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/strlib.h" -#include "../common/utils.h" -#include "../common/ers.h" +#include "../common/cbasetypes.hpp" +#include "../common/timer.hpp" +#include "../common/nullpo.hpp" +#include "../common/malloc.hpp" +#include "../common/random.hpp" +#include "../common/showmsg.hpp" +#include "../common/strlib.hpp" +#include "../common/utils.hpp" +#include "../common/ers.hpp" #include "map.hpp" #include "path.hpp" @@ -20826,7 +20826,7 @@ static bool skill_parse_row_skilldb(char* split[], int columns, int current) if (!idx) { if (SKILL_MAX_DB() >= MAX_SKILL) { - ShowError("Cannot add new skill. Limit is reached '%d' (mmo.h::MAX_SKILL).\n", MAX_SKILL); + ShowError("Cannot add new skill. Limit is reached '%d' (mmo.hpp::MAX_SKILL).\n", MAX_SKILL); return false; } idx = skill_db_create(skill_id); @@ -21502,7 +21502,7 @@ static bool skill_parse_row_skilldamage(char* split[], int columns, int current) **/ static uint16 skill_db_create(uint16 skill_id) { if (skill_num >= MAX_SKILL) { - ShowError("Cannot add more skill. Limit is reached '%d'. Change 'MAX_SKILL' in mmo.h\n", MAX_SKILL); + ShowError("Cannot add more skill. Limit is reached '%d'. Change 'MAX_SKILL' in mmo.hpp\n", MAX_SKILL); return 0; } if (!skill_num) diff --git a/src/map/skill.hpp b/src/map/skill.hpp index aa201b4fb5..12153e50f8 100644 --- a/src/map/skill.hpp +++ b/src/map/skill.hpp @@ -4,9 +4,9 @@ #ifndef _SKILL_HPP_ #define _SKILL_HPP_ -#include "../common/cbasetypes.h" -#include "../common/mmo.h" // MAX_SKILL, struct square -#include "../common/db.h" +#include "../common/cbasetypes.hpp" +#include "../common/mmo.hpp" // MAX_SKILL, struct square +#include "../common/db.hpp" #include "map.hpp" // struct block_list diff --git a/src/map/status.cpp b/src/map/status.cpp index f3c824c56b..83250489a7 100644 --- a/src/map/status.cpp +++ b/src/map/status.cpp @@ -9,15 +9,15 @@ #include #include -#include "../common/cbasetypes.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/random.h" -#include "../common/showmsg.h" -#include "../common/malloc.h" -#include "../common/utils.h" -#include "../common/ers.h" -#include "../common/strlib.h" +#include "../common/cbasetypes.hpp" +#include "../common/timer.hpp" +#include "../common/nullpo.hpp" +#include "../common/random.hpp" +#include "../common/showmsg.hpp" +#include "../common/malloc.hpp" +#include "../common/utils.hpp" +#include "../common/ers.hpp" +#include "../common/strlib.hpp" #include "battle.hpp" #include "itemdb.hpp" diff --git a/src/map/status.hpp b/src/map/status.hpp index f82728cbca..402bfae417 100644 --- a/src/map/status.hpp +++ b/src/map/status.hpp @@ -4,7 +4,7 @@ #ifndef _STATUS_HPP_ #define _STATUS_HPP_ -#include "../common/mmo.h" +#include "../common/mmo.hpp" enum e_race2 : uint8; struct block_list; @@ -3162,7 +3162,7 @@ struct status_data { #endif aspd_rate; /** - * defType is RENEWAL dependent and defined in src/map/config/data/const.h + * defType is RENEWAL dependent and defined in src/config/const.hpp **/ defType def,mdef; diff --git a/src/map/storage.cpp b/src/map/storage.cpp index 7da5b791ef..f514320681 100644 --- a/src/map/storage.cpp +++ b/src/map/storage.cpp @@ -10,10 +10,10 @@ #include "../common/utilities.hpp" -#include "../common/cbasetypes.h" -#include "../common/nullpo.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" +#include "../common/cbasetypes.hpp" +#include "../common/nullpo.hpp" +#include "../common/malloc.hpp" +#include "../common/showmsg.hpp" #include "map.hpp" // struct map_session_data #include "chrif.hpp" diff --git a/src/map/storage.hpp b/src/map/storage.hpp index 15c913352f..4dfd46c323 100644 --- a/src/map/storage.hpp +++ b/src/map/storage.hpp @@ -4,7 +4,7 @@ #ifndef _STORAGE_HPP_ #define _STORAGE_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" struct s_storage; struct item; diff --git a/src/map/trade.cpp b/src/map/trade.cpp index ed932cfb0d..ff797cbd76 100644 --- a/src/map/trade.cpp +++ b/src/map/trade.cpp @@ -6,8 +6,8 @@ #include #include -#include "../common/nullpo.h" -#include "../common/socket.h" +#include "../common/nullpo.hpp" +#include "../common/socket.hpp" #include "clif.hpp" #include "itemdb.hpp" diff --git a/src/map/unit.cpp b/src/map/unit.cpp index e96802f756..d4a51ee839 100644 --- a/src/map/unit.cpp +++ b/src/map/unit.cpp @@ -6,14 +6,14 @@ #include #include -#include "../common/showmsg.h" -#include "../common/timer.h" -#include "../common/nullpo.h" -#include "../common/db.h" -#include "../common/malloc.h" -#include "../common/random.h" -#include "../common/socket.h" -#include "../common/ers.h" // ers_destroy +#include "../common/showmsg.hpp" +#include "../common/timer.hpp" +#include "../common/nullpo.hpp" +#include "../common/db.hpp" +#include "../common/malloc.hpp" +#include "../common/random.hpp" +#include "../common/socket.hpp" +#include "../common/ers.hpp" // ers_destroy #include "achievement.hpp" #include "map.hpp" diff --git a/src/map/unit.hpp b/src/map/unit.hpp index 137eb1eeee..9b000fac10 100644 --- a/src/map/unit.hpp +++ b/src/map/unit.hpp @@ -4,7 +4,7 @@ #ifndef _UNIT_HPP_ #define _UNIT_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" #include "path.hpp" // struct walkpath_data #include "skill.hpp" // struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset diff --git a/src/map/vending.cpp b/src/map/vending.cpp index 6de6acea29..eaada323fb 100755 --- a/src/map/vending.cpp +++ b/src/map/vending.cpp @@ -2,11 +2,11 @@ // For more information, see LICENCE in the main folder #include "vending.hpp" -#include "../common/nullpo.h" -#include "../common/malloc.h" // aMalloc, aFree -#include "../common/showmsg.h" // ShowInfo -#include "../common/strlib.h" -#include "../common/timer.h" // DIFF_TICK +#include "../common/nullpo.hpp" +#include "../common/malloc.hpp" // aMalloc, aFree +#include "../common/showmsg.hpp" // ShowInfo +#include "../common/strlib.hpp" +#include "../common/timer.hpp" // DIFF_TICK #include "buyingstore.hpp" #include "clif.hpp" diff --git a/src/map/vending.hpp b/src/map/vending.hpp index 0781dc0cbf..63bfa32cb6 100644 --- a/src/map/vending.hpp +++ b/src/map/vending.hpp @@ -4,9 +4,9 @@ #ifndef _VENDING_HPP_ #define _VENDING_HPP_ -#include "../common/cbasetypes.h" +#include "../common/cbasetypes.hpp" -#include "../common/db.h" +#include "../common/db.hpp" struct map_session_data; struct s_search_store_search; diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt deleted file mode 100644 index 9fb5d31174..0000000000 --- a/src/test/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ - -# -# basic_test -# - -option( BUILD_TESTS "build basic_test executable" ON ) - -if( BUILD_TESTS ) - - set( TESTS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" ) - message( STATUS "Creating target basic_test" ) - file(GLOB TESTS_HEADERS ${TESTS_SOURCE_DIR}/*.hpp) - file(GLOB TESTS_SOURCES ${TESTS_SOURCE_DIR}/*.cpp) - - - set( DEPENDENCIES common) - set( LIBRARIES ${GLOBAL_LIBRARIES}) - set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${COMMON_BASE_INCLUDE_DIRS} ) - set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_BASE_DEFINITIONS} -DCMAKE" ) - set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} ${TESTS_HEADERS} ${TESTS_SOURCES} ) - source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_HEADERS} ) - source_group( test FILES ${TESTS_HEADERS} ${TESTS_SOURCES} ) - include_directories( ${INCLUDE_DIRS} ) - - #message( STATUS "basic_test SOURCE_FILES=${SOURCE_FILES}") - add_executable( basic_test ${SOURCE_FILES} ) - #message( STATUS "basic_test LIBRARIES=${LIBRARIES}, DEPENDENCIES=${DEPENDENCIES} DEFINITIONS=${DEFINITIONS}") - add_dependencies( basic_test ${DEPENDENCIES} ) - target_link_libraries( basic_test ${LIBRARIES} ${DEPENDENCIES} ) - set_target_properties( basic_test PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" ) - - if( INSTALL_COMPONENT_RUNTIME ) - cpack_add_component( Runtime_tests DESCRIPTION "basic integration test" DISPLAY_NAME "basic_test" GROUP Runtime ) - install( TARGETS basic_test - DESTINATION "." - COMPONENT Runtime_tests ) - endif( INSTALL_COMPONENT_RUNTIME ) - set( TARGET_LIST ${TARGET_LIST} basic_test CACHE INTERNAL "" ) - message( STATUS "Creating target basic_test - done" ) - -endif( BUILD_TESTS ) diff --git a/src/test/basic_test.vcxproj b/src/test/basic_test.vcxproj deleted file mode 100644 index 1c32f3b872..0000000000 --- a/src/test/basic_test.vcxproj +++ /dev/null @@ -1,171 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {99B4DF6A-6180-4E7F-9227-F812FF30414A} - Win32Proj - basic_test - - - - Application - true - $(DefaultPlatformToolset) - MultiByte - - - Application - false - $(DefaultPlatformToolset) - true - MultiByte - - - Application - true - $(DefaultPlatformToolset) - MultiByte - - - Application - false - $(DefaultPlatformToolset) - true - MultiByte - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir) - $(SolutionDir).vs\build\$(ProjectName)\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir) - $(SolutionDir).vs\build\$(ProjectName)\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir) - $(SolutionDir).vs\build\$(ProjectName)\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir) - $(SolutionDir).vs\build\$(ProjectName)\$(Platform)\$(Configuration)\ - - - - NotUsing - Level3 - Disabled - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreadedDebug - - - Console - true - ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir).vs\build\mt19937ar.lib;$(SolutionDir)3rdparty\zlib\lib\$(Platform)\zlib.lib;$(SolutionDir)3rdparty\pcre\lib\$(Platform)\pcre8.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) - - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreadedDebug - - - Console - true - ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir).vs\build\mt19937ar.lib;$(SolutionDir)3rdparty\zlib\lib\$(Platform)\zlib.lib;$(SolutionDir)3rdparty\pcre\lib\$(Platform)\pcre8.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) - - - - - NotUsing - Level3 - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreaded - - - Console - true - true - true - ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir).vs\build\mt19937ar.lib;$(SolutionDir)3rdparty\zlib\lib\$(Platform)\zlib.lib;$(SolutionDir)3rdparty\pcre\lib\$(Platform)\pcre8.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) - - - - - NotUsing - Level3 - MaxSpeed - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreaded - - - Console - true - true - true - ws2_32.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir).vs\build\mt19937ar.lib;$(SolutionDir)3rdparty\zlib\lib\$(Platform)\zlib.lib;$(SolutionDir)3rdparty\pcre\lib\$(Platform)\pcre8.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;$(SolutionDir).vs\build\yaml-cpp.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/test/basic_test.vcxproj.filters b/src/test/basic_test.vcxproj.filters deleted file mode 100644 index 9a601b6035..0000000000 --- a/src/test/basic_test.vcxproj.filters +++ /dev/null @@ -1,32 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/src/test/basictest.cpp b/src/test/basictest.cpp deleted file mode 100644 index b44485252d..0000000000 --- a/src/test/basictest.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// basictest.cpp : Sets the entry point for the console application. -// - -#include -#include -#include - -#ifndef _WIN32 -#include -#endif - -#include "../common/core.h" -#include "test_thread.hpp" -#include "test_spinlock.hpp" - -using namespace ra::unit_tests; - -int do_init( int, char** ) -{ - test_thread_creation_and_wait(); - test_thread_spinlock(); - return 0; -} - -//just some empty function to comply link -void do_abort(void) {} -void do_final(void) {} -void set_server_type(void) {} - -//tmp tp avoid link issue in cmake -#if defined(CMAKE) -#ifdef __cplusplus -extern "C" { -#endif - void Sql_Init(void) {} -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/test/test_spinlock.cpp b/src/test/test_spinlock.cpp deleted file mode 100644 index 3068485f89..0000000000 --- a/src/test/test_spinlock.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include "test_spinlock.hpp" -#include -#include - -#include "../common/thread.h" -#include "../common/spinlock.h" -#include "../common/showmsg.h" -#include "test_thread.hpp" - -namespace ra -{ - namespace unit_tests - { - static SPIN_LOCK lSpinLock; - - void* thread_test_critical( void *x ) - { - size_t count = 0; - while ( count++ < 10 ) - { - EnterSpinLock( &lSpinLock ); - ShowStatus( "TH Entering critical_section recursion_count=%d iteration_count=%d\n", lSpinLock.nest,count ); - std::this_thread::sleep_for(std::chrono::milliseconds( 100 )); //a simple test with critical section - ShowStatus( "TH Leaving critical_section recursion_count=%d\n iteration_count=%d", lSpinLock.nest,count ); - LeaveSpinLock( &lSpinLock ); - rathread_yield(); - std::this_thread::sleep_for(std::chrono::milliseconds( 200 )); //let try to lose the lock here - } - return nullptr; - } - - void test_thread_spinlock() - { - ShowStatus( "Testing test_thread_spinlock\n" ); - InitializeSpinLock( &lSpinLock ); - - EnterSpinLock( &lSpinLock ); //fake critical section (we take it before creation to ensure we have the lock) - ShowStatus( "Main Entering critical_section recursion_count=%d\n", lSpinLock.nest ); - - prAthread lnd2th = rathread_create( &thread_test_critical, nullptr ); - int lMainID = rathread_get_tid(); - ShowStatus( "Continuing main th id=%d\n", lMainID ); - rathread_yield(); - std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); //fake doing stuff - ShowStatus( "Main Leaving critical_section recursion_count=%d\n", lSpinLock.nest ); - LeaveSpinLock( &lSpinLock ); - - std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); //fake doing stuff - EnterSpinLock( &lSpinLock ); //now we should be waiting - ShowStatus( "Main Entering critical_section recursion_count=%d\n", lSpinLock.nest ); - - EnterSpinLock( &lSpinLock ); //testing with a recursion - ShowStatus( "Main Entering critical_section recursion_count=%d\n", lSpinLock.nest ); - std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); //fake doing stuff - ShowStatus( "Main Leaving critical_section recursion_count=%d\n", lSpinLock.nest ); - LeaveSpinLock( &lSpinLock ); - - ShowStatus( "Main Leaving critical_section recursion_count=%d\n", lSpinLock.nest ); - LeaveSpinLock( &lSpinLock ); - - while ( !rathread_wait( lnd2th, nullptr ) ) - { - ShowStatus( "Waiting 2nd thread\n" ); - std::this_thread::sleep_for( std::chrono::seconds( 1 ) ); - } - rathread_destroy( lnd2th ); - FinalizeSpinLock( &lSpinLock ); - } - - } -} - -/* Expected result -[Status]: Testing test_thread_spinlock -[Status]: Main Entering critical_section recursion_count=1 -[Status]: Continuing main th id=0 -[Status]: Main Leaving critical_section recursion_count=1 -[Status]: TH Entering critical_section recursion_count=1 iteration_count=1 -[Status]: TH Leaving critical_section recursion_count=1 iteration_count=1 -[Status]: Main Entering critical_section recursion_count=1 -[Status]: Main Entering critical_section recursion_count=2 -[Status]: Main Leaving critical_section recursion_count=2 -[Status]: Main Leaving critical_section recursion_count=1 -[Status]: TH Entering critical_section recursion_count=1 iteration_count=2 -[Status]: TH Leaving critical_section recursion_count=1 iteration_count=2 -[Status]: TH Entering critical_section recursion_count=1 iteration_count=3 -[Status]: TH Leaving critical_section recursion_count=1 iteration_count=3 -[Status]: TH Entering critical_section recursion_count=1 iteration_count=4 -[Status]: TH Leaving critical_section recursion_count=1 iteration_count=4 -[Status]: TH Entering critical_section recursion_count=1 iteration_count=5 -[Status]: TH Leaving critical_section recursion_count=1 iteration_count=5 -[Status]: TH Entering critical_section recursion_count=1 iteration_count=6 -[Status]: TH Leaving critical_section recursion_count=1 iteration_count=6 -[Status]: TH Entering critical_section recursion_count=1 iteration_count=7 -[Status]: TH Leaving critical_section recursion_count=1 iteration_count=7 -[Status]: TH Entering critical_section recursion_count=1 iteration_count=8 -[Status]: TH Leaving critical_section recursion_count=1 iteration_count=8 -[Status]: TH Entering critical_section recursion_count=1 iteration_count=9 -[Status]: TH Leaving critical_section recursion_count=1 iteration_count=9 -[Status]: TH Entering critical_section recursion_count=1 iteration_count=10 -[Status]: TH Leaving critical_section recursion_count=1 iteration_count=10 -*/ \ No newline at end of file diff --git a/src/test/test_spinlock.hpp b/src/test/test_spinlock.hpp deleted file mode 100644 index 9e044865fc..0000000000 --- a/src/test/test_spinlock.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -namespace ra -{ - namespace unit_tests - { - //main - void test_thread_spinlock(); - //subs - void* thread_test_critical( void *x ); //must match rAthreadProc signature - } -} diff --git a/src/test/test_thread.cpp b/src/test/test_thread.cpp deleted file mode 100644 index 715ee39193..0000000000 --- a/src/test/test_thread.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "test_thread.hpp" -#include -#include - -#include "../common/thread.h" -#include "../common/showmsg.h" - - -namespace ra -{ - namespace unit_tests - { - void* thread_test(void *x) - { - ShowStatus( "Entering thread_test\n" ); - int lTHID = rathread_get_tid(); - ShowStatus( "test th id=%d\n",lTHID); - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - ShowStatus( "Leaving thread_test\n" ); - return nullptr; - } - - void test_thread_creation_and_wait() - { - ShowStatus( "Testing thread_creation_and_wait\n" ); - prAthread lnd2th = rathread_create(&thread_test,nullptr); - //rathread_yield(); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); //fake doing stuff - int lMainID = rathread_get_tid(); - ShowStatus( "Continuing main th id=%d\n",lMainID); - while ( !rathread_wait( lnd2th, nullptr ) ) - { - ShowStatus( "Waiting 2nd thread\n" ); - std::this_thread::sleep_for(std::chrono::seconds(1)); - } - rathread_destroy(lnd2th); //will be destroy anyway by manager if not - } - - } -} - -/* Expected result -[Status]: Testing thread_creation_and_wait -[Status]: Entering thread_test -[Status]: test th id=1 -[Status]: Continuing main th id=0 -[Status]: Leaving thread_test -*/ \ No newline at end of file diff --git a/src/test/test_thread.hpp b/src/test/test_thread.hpp deleted file mode 100644 index 2ca9880dc6..0000000000 --- a/src/test/test_thread.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -namespace ra -{ - namespace unit_tests - { - //main - void test_thread_creation_and_wait(); - //sub - void* thread_test( void *x ); //must match rAthreadProc signature - } -} diff --git a/src/tool/CMakeLists.txt b/src/tool/CMakeLists.txt index a54ffa0e22..f14c464d66 100644 --- a/src/tool/CMakeLists.txt +++ b/src/tool/CMakeLists.txt @@ -11,18 +11,18 @@ 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" + "${COMMON_SOURCE_DIR}/des.hpp" + "${COMMON_SOURCE_DIR}/grfio.hpp" + "${COMMON_SOURCE_DIR}/utils.hpp" ) set( COMMON_SOURCES ${COMMON_MINI_SOURCES} - "${COMMON_SOURCE_DIR}/des.c" - "${COMMON_SOURCE_DIR}/grfio.c" - "${COMMON_SOURCE_DIR}/utils.c" + "${COMMON_SOURCE_DIR}/des.cpp" + "${COMMON_SOURCE_DIR}/grfio.cpp" + "${COMMON_SOURCE_DIR}/utils.cpp" ) set( MAPCACHE_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/mapcache.c" + "${CMAKE_CURRENT_SOURCE_DIR}/mapcache.cpp" ) set( LIBRARIES ${GLOBAL_LIBRARIES} ${ZLIB_LIBRARIES} ) set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${COMMON_MINI_INCLUDE_DIRS} ) diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index 8e37c1113e..fdf5e6bccc 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -1,14 +1,14 @@ COMMON_OBJ = minicore.o malloc.o showmsg.o strlib.o utils.o des.o grfio.o COMMON_DIR_OBJ = $(COMMON_OBJ:%=../common/obj/%) -COMMON_H = $(shell ls ../common/*.h) +COMMON_H = $(shell ls ../common/*.hpp) COMMON_INCLUDE = -I../common/ LIBCONFIG_H = $(shell ls ../../3rdparty/libconfig/*.h) LIBCONFIG_AR = ../../3rdparty/libconfig/obj/libconfig.a LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig -OTHER_H = ../config/renewal.h +OTHER_H = ../config/renewal.hpp MAPCACHE_OBJ = obj_all/mapcache.o @@ -21,7 +21,7 @@ all: mapcache mapcache: obj_all $(MAPCACHE_OBJ) $(COMMON_DIR_OBJ) $(LIBCONFIG_OBJ) @echo " LD $@" - @@CC@ @LDFLAGS@ -o ../../mapcache@EXEEXT@ $(MAPCACHE_OBJ) $(COMMON_DIR_OBJ) $(LIBCONFIG_AR) @LIBS@ + @@CXX@ @LDFLAGS@ -o ../../mapcache@EXEEXT@ $(MAPCACHE_OBJ) $(COMMON_DIR_OBJ) $(LIBCONFIG_AR) @LIBS@ clean: @echo " CLEAN tool" @@ -39,9 +39,9 @@ help: obj_all: -mkdir obj_all -obj_all/%.o: %.c $(COMMON_H) $(OTHER_H) $(LIBCONFIG_H) - @echo " CC $<" - @@CC@ @CFLAGS@ $(COMMON_INCLUDE) $(LIBCONFIG_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $< +obj_all/%.o: %.cpp $(COMMON_H) $(OTHER_H) $(LIBCONFIG_H) + @echo " CXX $<" + @@CXX@ @CXXFLAGS@ $(COMMON_INCLUDE) $(LIBCONFIG_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing common object files $(COMMON_DIR_OBJ): diff --git a/src/tool/mapcache.c b/src/tool/mapcache.cpp similarity index 95% rename from src/tool/mapcache.c rename to src/tool/mapcache.cpp index 228595ae5c..af8a2765b5 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.cpp @@ -9,11 +9,11 @@ #include #endif -#include "../common/mmo.h" -#include "../common/grfio.h" -#include "../common/malloc.h" -#include "../common/showmsg.h" -#include "../common/utils.h" +#include "../common/mmo.hpp" +#include "../common/grfio.hpp" +#include "../common/malloc.hpp" +#include "../common/showmsg.hpp" +#include "../common/utils.hpp" #define NO_WATER 1000000 @@ -266,12 +266,12 @@ int do_init(int argc, char** argv) name[MAP_NAME_LENGTH_EXT-1] = '\0'; remove_extension(name); if(find_map(name)) - ShowInfo("Map '"CL_WHITE"%s"CL_RESET"' already in cache.\n", name); + ShowInfo("Map '" CL_WHITE "%s" CL_RESET "' already in cache.\n", name); else if(read_map(name, &map)) { cache_map(name, &map); - ShowInfo("Map '"CL_WHITE"%s"CL_RESET"' successfully cached.\n", name); + ShowInfo("Map '" CL_WHITE "%s" CL_RESET "' successfully cached.\n", name); } else - ShowError("Map '"CL_WHITE"%s"CL_RESET"' not found!\n", name); + ShowError("Map '" CL_WHITE "%s" CL_RESET "' not found!\n", name); } diff --git a/src/tool/mapcache.vcxproj b/src/tool/mapcache.vcxproj index 13ee343a3d..e23635dda0 100644 --- a/src/tool/mapcache.vcxproj +++ b/src/tool/mapcache.vcxproj @@ -155,7 +155,7 @@ - + diff --git a/src/tool/mapcache.vcxproj.filters b/src/tool/mapcache.vcxproj.filters index 9513bbba12..0980d8139d 100644 --- a/src/tool/mapcache.vcxproj.filters +++ b/src/tool/mapcache.vcxproj.filters @@ -11,7 +11,7 @@ - + Source Files