From b99293c9d75e375cfa5e3e0fd5b2aa57d28d2f01 Mon Sep 17 00:00:00 2001 From: Exynox Date: Sun, 6 Mar 2022 00:01:03 +0200 Subject: [PATCH] Remove hackshield and unused function, game now compiles and runs --- cmake/Modules/FindCryptoPP.cmake | 108 - db/src/AuctionManager.h | 12 +- db/src/ClientManager.cpp | 12 +- db/src/ClientManager.h | 26 +- db/src/ClientManagerBoot.cpp | 20 +- db/src/ClientManagerEventFlag.cpp | 2 +- db/src/ClientManagerGuild.cpp | 4 +- db/src/ClientManagerHorseName.cpp | 4 +- db/src/ClientManagerLogin.cpp | 24 +- db/src/ClientManagerPlayer.cpp | 14 +- db/src/GuildManager.cpp | 16 +- db/src/HB.cpp | 4 +- db/src/Marriage.cpp | 12 +- db/src/stdafx.h | 3 + game/CMakeLists.txt | 23 +- game/src/ClientPackageCryptInfo.cpp | 4 - game/src/ClientPackageCryptInfo.h | 4 +- game/src/DragonLair.cpp | 2 +- game/src/DragonLair.h | 4 +- game/src/FileMonitor_FreeBSD.cpp | 136 -- game/src/FileMonitor_FreeBSD.h | 47 - game/src/HackShield.cpp | 54 - game/src/HackShield.h | 24 - game/src/HackShield_Impl.cpp | 202 -- game/src/HackShield_Impl.h | 51 - game/src/IFileMonitor.h | 2 +- game/src/MarkImage.h | 2 +- game/src/PetSystem.h | 2 +- game/src/XTrapManager.cpp | 329 --- game/src/XTrapManager.h | 67 - game/src/auction_manager.h | 16 +- game/src/banword.h | 4 +- game/src/char.cpp | 19 +- game/src/char.h | 18 +- game/src/char_change_empire.cpp | 6 +- game/src/char_hackshield.cpp | 93 - game/src/char_manager.cpp | 10 - game/src/char_manager.h | 8 +- game/src/char_skill.cpp | 2 +- game/src/check_server.cpp | 4 - game/src/check_server.h | 48 - game/src/cipher.cpp | 5 +- game/src/cipher.h | 4 +- game/src/cmd_gm.cpp | 10 +- game/src/config.cpp | 59 +- game/src/config.h | 5 - game/src/cube.cpp | 4 +- game/src/db.cpp | 4 +- game/src/debug_allocator_adapter.h | 11 +- game/src/desc.cpp | 12 - game/src/desc.h | 1 - game/src/desc_manager.h | 8 +- game/src/dungeon.h | 2 +- game/src/entity.h | 2 +- game/src/fifo_allocator.h | 10 +- game/src/guild.cpp | 6 +- game/src/guild_manager.cpp | 4 +- game/src/input.cpp | 16 - game/src/input.h | 1 - game/src/input_auth.cpp | 26 - game/src/input_db.cpp | 27 +- game/src/input_login.cpp | 19 - game/src/input_main.cpp | 45 +- game/src/item_manager.cpp | 10 +- game/src/item_manager.h | 2 +- game/src/limit_time.h | 8 - game/src/log.h | 2 +- game/src/lzo_manager.h | 2 +- game/src/main.cpp | 201 +- game/src/marriage.h | 2 +- game/src/matrix_card.cpp | 4 +- game/src/minilzo.c | 2937 --------------------------- game/src/minilzo.h | 100 - game/src/over9refine.h | 4 +- game/src/p2p.cpp | 8 +- game/src/p2p.h | 8 +- game/src/packet.h | 12 - game/src/packet_info.cpp | 5 - game/src/passpod.cpp | 10 +- game/src/polymorph.cpp | 2 +- game/src/polymorph.h | 8 +- game/src/pool.h | 2 +- game/src/profiler.h | 4 +- game/src/pvp.cpp | 6 +- game/src/pvp.h | 2 +- game/src/questlua_building.cpp | 2 +- game/src/questlua_pc.cpp | 2 +- game/src/questmanager.h | 6 +- game/src/sectree_manager.cpp | 4 +- game/src/sectree_manager.h | 2 +- game/src/shop.h | 2 +- game/src/skill.h | 2 +- game/src/stdafx.h | 14 +- game/src/threeway_war.cpp | 2 +- game/src/threeway_war.h | 6 +- game/src/typedef.h | 4 +- game/src/update_limit_time.py | 16 - game/src/version.cpp | 2 +- libthecore/include/stdafx.h | 2 +- libthecore/include/xdirent.h | 50 - libthecore/include/xgetopt.h | 23 - libthecore/src/xdirent.cpp | 152 -- libthecore/src/xgetopt.cpp | 228 --- 103 files changed, 217 insertions(+), 5364 deletions(-) delete mode 100644 cmake/Modules/FindCryptoPP.cmake delete mode 100644 game/src/FileMonitor_FreeBSD.cpp delete mode 100644 game/src/FileMonitor_FreeBSD.h delete mode 100644 game/src/HackShield.cpp delete mode 100644 game/src/HackShield.h delete mode 100644 game/src/HackShield_Impl.cpp delete mode 100644 game/src/HackShield_Impl.h delete mode 100644 game/src/XTrapManager.cpp delete mode 100644 game/src/XTrapManager.h delete mode 100644 game/src/char_hackshield.cpp delete mode 100644 game/src/check_server.cpp delete mode 100644 game/src/check_server.h delete mode 100644 game/src/limit_time.h delete mode 100644 game/src/minilzo.c delete mode 100644 game/src/minilzo.h delete mode 100644 game/src/update_limit_time.py delete mode 100644 libthecore/include/xdirent.h delete mode 100644 libthecore/include/xgetopt.h delete mode 100644 libthecore/src/xdirent.cpp delete mode 100644 libthecore/src/xgetopt.cpp diff --git a/cmake/Modules/FindCryptoPP.cmake b/cmake/Modules/FindCryptoPP.cmake deleted file mode 100644 index 5ca01e4..0000000 --- a/cmake/Modules/FindCryptoPP.cmake +++ /dev/null @@ -1,108 +0,0 @@ -# Module for locating the Crypto++ encryption library. -# -# Customizable variables: -# CRYPTOPP_ROOT_DIR -# This variable points to the CryptoPP root directory. On Windows the -# library location typically will have to be provided explicitly using the -# -D command-line option. The directory should include the include/cryptopp, -# lib and/or bin sub-directories. -# -# Read-only variables: -# CRYPTOPP_FOUND -# Indicates whether the library has been found. -# -# CRYPTOPP_INCLUDE_DIRS -# Points to the CryptoPP include directory. -# -# CRYPTOPP_LIBRARIES -# Points to the CryptoPP libraries that should be passed to -# target_link_libararies. -# -# -# Copyright (c) 2012 Sergiu Dotenco -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -INCLUDE (FindPackageHandleStandardArgs) - -FIND_PATH (CRYPTOPP_ROOT_DIR - NAMES cryptopp/cryptlib.h include/cryptopp/cryptlib.h - PATHS ENV CRYPTOPPROOT - DOC "CryptoPP root directory") - -# Re-use the previous path: -FIND_PATH (CRYPTOPP_INCLUDE_DIR - NAMES cryptopp/cryptlib.h - HINTS ${CRYPTOPP_ROOT_DIR} - PATH_SUFFIXES include - DOC "CryptoPP include directory") - -FIND_LIBRARY (CRYPTOPP_LIBRARY_DEBUG - NAMES cryptlibd cryptoppd - HINTS ${CRYPTOPP_ROOT_DIR} - PATH_SUFFIXES lib - DOC "CryptoPP debug library") - -FIND_LIBRARY (CRYPTOPP_LIBRARY_RELEASE - NAMES cryptlib cryptopp - HINTS ${CRYPTOPP_ROOT_DIR} - PATH_SUFFIXES lib - DOC "CryptoPP release library") - -IF (CRYPTOPP_LIBRARY_DEBUG AND CRYPTOPP_LIBRARY_RELEASE) - SET (CRYPTOPP_LIBRARY - optimized ${CRYPTOPP_LIBRARY_RELEASE} - debug ${CRYPTOPP_LIBRARY_DEBUG} CACHE DOC "CryptoPP library") -ELSEIF (CRYPTOPP_LIBRARY_RELEASE) - SET (CRYPTOPP_LIBRARY ${CRYPTOPP_LIBRARY_RELEASE} CACHE DOC - "CryptoPP library") -ENDIF (CRYPTOPP_LIBRARY_DEBUG AND CRYPTOPP_LIBRARY_RELEASE) - -IF (CRYPTOPP_INCLUDE_DIR) - SET (_CRYPTOPP_VERSION_HEADER ${CRYPTOPP_INCLUDE_DIR}/cryptopp/config.h) - - IF (EXISTS ${_CRYPTOPP_VERSION_HEADER}) - FILE (STRINGS ${_CRYPTOPP_VERSION_HEADER} _CRYPTOPP_VERSION_TMP REGEX - "^#define CRYPTOPP_VERSION[ \t]+[0-9]+$") - - STRING (REGEX REPLACE - "^#define CRYPTOPP_VERSION[ \t]+([0-9]+)" "\\1" _CRYPTOPP_VERSION_TMP - ${_CRYPTOPP_VERSION_TMP}) - - STRING (REGEX REPLACE "([0-9]+)[0-9][0-9]" "\\1" CRYPTOPP_VERSION_MAJOR - ${_CRYPTOPP_VERSION_TMP}) - STRING (REGEX REPLACE "[0-9]([0-9])[0-9]" "\\1" CRYPTOPP_VERSION_MINOR - ${_CRYPTOPP_VERSION_TMP}) - STRING (REGEX REPLACE "[0-9][0-9]([0-9])" "\\1" CRYPTOPP_VERSION_PATCH - ${_CRYPTOPP_VERSION_TMP}) - - SET (CRYPTOPP_VERSION_COUNT 3) - SET (CRYPTOPP_VERSION - ${CRYPTOPP_VERSION_MAJOR}.${CRYPTOPP_VERSION_MINOR}.${CRYPTOPP_VERSION_PATCH}) - ENDIF (EXISTS ${_CRYPTOPP_VERSION_HEADER}) -ENDIF (CRYPTOPP_INCLUDE_DIR) - -SET (CRYPTOPP_INCLUDE_DIRS ${CRYPTOPP_INCLUDE_DIR}) -SET (CRYPTOPP_LIBRARIES ${CRYPTOPP_LIBRARY}) - -MARK_AS_ADVANCED (CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARY CRYPTOPP_LIBRARY_DEBUG - CRYPTOPP_LIBRARY_RELEASE) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS (CryptoPP REQUIRED_VARS CRYPTOPP_ROOT_DIR - CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARY VERSION_VAR CRYPTOPP_VERSION) \ No newline at end of file diff --git a/db/src/AuctionManager.h b/db/src/AuctionManager.h index 5643e99..bb6c2c8 100644 --- a/db/src/AuctionManager.h +++ b/db/src/AuctionManager.h @@ -3,7 +3,7 @@ #ifndef __INC_AUCTION_MANAGER_H__ #define __INC_AUCTION_MANAGER_H__ -#include +#include #include "Cache.h" #include @@ -98,7 +98,7 @@ public: return true; } private: - typedef boost::unordered_map TItemInfoCacheMap; + typedef std::unordered_map TItemInfoCacheMap; TItemInfoCacheMap item_cache_map; }; @@ -169,7 +169,7 @@ public: } private: - typedef boost::unordered_map TItemInfoCacheMap; + typedef std::unordered_map TItemInfoCacheMap; TItemInfoCacheMap item_cache_map; }; @@ -239,7 +239,7 @@ public: return true; } private: - typedef boost::unordered_map TItemInfoCacheMap; + typedef std::unordered_map TItemInfoCacheMap; TItemInfoCacheMap item_cache_map; }; @@ -260,7 +260,7 @@ public: private: typedef std::map TItemMap; - typedef boost::unordered_map TMyBidBoard; + typedef std::unordered_map TMyBidBoard; TMyBidBoard pc_map; }; @@ -268,7 +268,7 @@ class AuctionManager : public singleton { private: // auction¿¡ µî·ÏµÈ ¾ÆÀÌÅÛµé. - typedef boost::unordered_map TItemCacheMap; + typedef std::unordered_map TItemCacheMap; TItemCacheMap auction_item_cache_map; // auction¿¡ µî·ÏµÈ Á¤º¸ Áß °¡°Ý, µîµî ¾ÆÀÌÅÛ Å×ÀÌºí¿¡ Æ÷ÇÔµÇÁö ¾Ê´Â Á¤º¸µéÀ» °ü¸®ÇÏ´Â °Íµé diff --git a/db/src/ClientManager.cpp b/db/src/ClientManager.cpp index 6d09043..7ed0de2 100644 --- a/db/src/ClientManager.cpp +++ b/db/src/ClientManager.cpp @@ -780,7 +780,7 @@ void CClientManager::RESULT_SAFEBOX_LOAD(CPeer * pkPeer, SQLMsg * msg) pItemAward->dwVnum, pItemAward->dwCount, pItemAward->dwSocket0, pItemAward->dwSocket1, dwSocket2); } - std::auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); SQLResult * pRes = pmsg->Get(); sys_log(0, "SAFEBOX Query : [%s]", szQuery); @@ -1001,7 +1001,7 @@ void CClientManager::QUERY_EMPIRE_SELECT(CPeer * pkPeer, DWORD dwHandle, TEmpire snprintf(szQuery, sizeof(szQuery), "SELECT pid1, pid2, pid3, pid4 FROM player_index%s WHERE id=%u", GetTablePostfix(), p->dwAccountID); - std::auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); SQLResult * pRes = pmsg->Get(); @@ -1046,7 +1046,7 @@ void CClientManager::QUERY_EMPIRE_SELECT(CPeer * pkPeer, DWORD dwHandle, TEmpire g_start_position[p->bEmpire][1], pids[i]); - std::auto_ptr pmsg2(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg2(CDBManager::instance().DirectQuery(szQuery)); } } } @@ -1985,7 +1985,7 @@ void CClientManager::CreateObject(TPacketGDCreateObject * p) "INSERT INTO object%s (land_id, vnum, map_index, x, y, x_rot, y_rot, z_rot) VALUES(%u, %u, %d, %d, %d, %f, %f, %f)", GetTablePostfix(), p->dwLandID, p->dwVnum, p->lMapIndex, p->x, p->y, p->xRot, p->yRot, p->zRot); - std::auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); if (pmsg->Get()->uiInsertID == 0) { @@ -2019,7 +2019,7 @@ void CClientManager::DeleteObject(DWORD dwID) snprintf(szQuery, sizeof(szQuery), "DELETE FROM object%s WHERE id=%u", GetTablePostfix(), dwID); - std::auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); if (pmsg->Get()->uiAffectedRows == 0 || pmsg->Get()->uiAffectedRows == (uint32_t)-1) { @@ -2095,7 +2095,7 @@ void CClientManager::BlockChat(TPacketBlockChat* p) snprintf(szQuery, sizeof(szQuery), "SELECT id FROM player%s WHERE name = '%s' collate sjis_japanese_ci", GetTablePostfix(), p->szName); else snprintf(szQuery, sizeof(szQuery), "SELECT id FROM player%s WHERE name = '%s'", GetTablePostfix(), p->szName); - std::auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); SQLResult * pRes = pmsg->Get(); if (pRes->uiNumRows) diff --git a/db/src/ClientManager.h b/db/src/ClientManager.h index b5db23c..82bf4e4 100644 --- a/db/src/ClientManager.h +++ b/db/src/ClientManager.h @@ -2,8 +2,8 @@ #ifndef __INC_CLIENTMANAGER_H__ #define __INC_CLIENTMANAGER_H__ -#include -#include +#include +#include #include #include @@ -32,12 +32,12 @@ class CClientManager : public CNetBase, public singleton { public: typedef std::list TPeerList; - typedef boost::unordered_map TPlayerTableCacheMap; - typedef boost::unordered_map TItemCacheMap; - typedef boost::unordered_set > TItemCacheSet; - typedef boost::unordered_map TItemCacheSetPtrMap; - typedef boost::unordered_map TItemPriceListCacheMap; - typedef boost::unordered_map TChannelStatusMap; + typedef std::unordered_map TPlayerTableCacheMap; + typedef std::unordered_map TItemCacheMap; + typedef std::unordered_set > TItemCacheSet; + typedef std::unordered_map TItemCacheSetPtrMap; + typedef std::unordered_map TItemPriceListCacheMap; + typedef std::unordered_map TChannelStatusMap; // MYSHOP_PRICE_LIST /// ¾ÆÀÌÅÛ °¡°ÝÁ¤º¸ ¸®½ºÆ® ¿äû Á¤º¸ @@ -392,19 +392,19 @@ class CClientManager : public CNetBase, public singleton CPeer * m_pkAuthPeer; // LoginKey, LoginData pair - typedef boost::unordered_map TLoginDataByLoginKey; + typedef std::unordered_map TLoginDataByLoginKey; TLoginDataByLoginKey m_map_pkLoginData; // Login LoginData pair - typedef boost::unordered_map TLoginDataByLogin; + typedef std::unordered_map TLoginDataByLogin; TLoginDataByLogin m_map_pkLoginDataByLogin; // AccountID LoginData pair - typedef boost::unordered_map TLoginDataByAID; + typedef std::unordered_map TLoginDataByAID; TLoginDataByAID m_map_pkLoginDataByAID; // Login LoginData pair (½ÇÁ¦ ·Î±×ÀÎ µÇ¾îÀÖ´Â °èÁ¤) - typedef boost::unordered_map TLogonAccountMap; + typedef std::unordered_map TLogonAccountMap; TLogonAccountMap m_map_kLogonAccount; int m_iPlayerIDStart; @@ -510,7 +510,7 @@ class CClientManager : public CNetBase, public singleton } }; - typedef boost::unordered_map TLogoutPlayerMap; + typedef std::unordered_map TLogoutPlayerMap; TLogoutPlayerMap m_map_logout; void InsertLogoutPlayer(DWORD pid); diff --git a/db/src/ClientManagerBoot.cpp b/db/src/ClientManagerBoot.cpp index eb5b021..23e040d 100644 --- a/db/src/ClientManagerBoot.cpp +++ b/db/src/ClientManagerBoot.cpp @@ -109,7 +109,7 @@ bool CClientManager::InitializeRefineTable() "SELECT id, cost, prob, vnum0, count0, vnum1, count1, vnum2, count2, vnum3, count3, vnum4, count4 FROM refine_proto%s", GetTablePostfix()); - std::auto_ptr pkMsg(CDBManager::instance().DirectQuery(query)); + std::unique_ptr pkMsg(CDBManager::instance().DirectQuery(query)); SQLResult * pRes = pkMsg->Get(); if (!pRes->uiNumRows) @@ -445,7 +445,7 @@ bool CClientManager::InitializeShopTable() "FROM shop LEFT JOIN shop_item " "ON shop.vnum = shop_item.shop_vnum ORDER BY shop.vnum, shop_item.item_vnum"; - std::auto_ptr pkMsg2(CDBManager::instance().DirectQuery(s_szQuery)); + std::unique_ptr pkMsg2(CDBManager::instance().DirectQuery(s_szQuery)); // shopÀÇ vnumÀº Àִµ¥ shop_item ÀÌ ¾øÀ»°æ¿ì... ½ÇÆзΠó¸®µÇ´Ï ÁÖÀÇ ¿ä¸Á. // °íó¾ßÇҺκР@@ -524,7 +524,7 @@ bool CClientManager::InitializeQuestItemTable() char query[1024]; snprintf(query, sizeof(query), s_szQuery, g_stLocaleNameColumn.c_str()); - std::auto_ptr pkMsg(CDBManager::instance().DirectQuery(query)); + std::unique_ptr pkMsg(CDBManager::instance().DirectQuery(query)); SQLResult * pRes = pkMsg->Get(); if (!pRes->uiNumRows) @@ -860,7 +860,7 @@ bool CClientManager::InitializeSkillTable() "FROM skill_proto%s ORDER BY dwVnum", GetTablePostfix()); - std::auto_ptr pkMsg(CDBManager::instance().DirectQuery(query)); + std::unique_ptr pkMsg(CDBManager::instance().DirectQuery(query)); SQLResult * pRes = pkMsg->Get(); if (!pRes->uiNumRows) @@ -941,7 +941,7 @@ bool CClientManager::InitializeBanwordTable() { m_vec_banwordTable.clear(); - std::auto_ptr pkMsg(CDBManager::instance().DirectQuery("SELECT word FROM banword")); + std::unique_ptr pkMsg(CDBManager::instance().DirectQuery("SELECT word FROM banword")); SQLResult * pRes = pkMsg->Get(); @@ -972,7 +972,7 @@ bool CClientManager::InitializeItemAttrTable() "SELECT apply, apply+0, prob, lv1, lv2, lv3, lv4, lv5, weapon, body, wrist, foots, neck, head, shield, ear FROM item_attr%s ORDER BY apply", GetTablePostfix()); - std::auto_ptr pkMsg(CDBManager::instance().DirectQuery(query)); + std::unique_ptr pkMsg(CDBManager::instance().DirectQuery(query)); SQLResult * pRes = pkMsg->Get(); if (!pRes->uiNumRows) @@ -1046,7 +1046,7 @@ bool CClientManager::InitializeItemRareTable() "SELECT apply, apply+0, prob, lv1, lv2, lv3, lv4, lv5, weapon, body, wrist, foots, neck, head, shield, ear FROM item_attr_rare%s ORDER BY apply", GetTablePostfix()); - std::auto_ptr pkMsg(CDBManager::instance().DirectQuery(query)); + std::unique_ptr pkMsg(CDBManager::instance().DirectQuery(query)); SQLResult * pRes = pkMsg->Get(); if (!pRes->uiNumRows) @@ -1124,7 +1124,7 @@ bool CClientManager::InitializeLandTable() "FROM land%s WHERE enable='YES' ORDER BY id", GetTablePostfix()); - std::auto_ptr pkMsg(CDBManager::instance().DirectQuery(query)); + std::unique_ptr pkMsg(CDBManager::instance().DirectQuery(query)); SQLResult * pRes = pkMsg->Get(); if (!m_vec_kLandTable.empty()) @@ -1227,7 +1227,7 @@ bool CClientManager::InitializeObjectProto() "FROM object_proto%s ORDER BY vnum", GetTablePostfix()); - std::auto_ptr pkMsg(CDBManager::instance().DirectQuery(query)); + std::unique_ptr pkMsg(CDBManager::instance().DirectQuery(query)); SQLResult * pRes = pkMsg->Get(); if (!m_vec_kObjectProto.empty()) @@ -1296,7 +1296,7 @@ bool CClientManager::InitializeObjectTable() char query[4096]; snprintf(query, sizeof(query), "SELECT id, land_id, vnum, map_index, x, y, x_rot, y_rot, z_rot, life FROM object%s ORDER BY id", GetTablePostfix()); - std::auto_ptr pkMsg(CDBManager::instance().DirectQuery(query)); + std::unique_ptr pkMsg(CDBManager::instance().DirectQuery(query)); SQLResult * pRes = pkMsg->Get(); if (!m_map_pkObjectTable.empty()) diff --git a/db/src/ClientManagerEventFlag.cpp b/db/src/ClientManagerEventFlag.cpp index c0fcf22..95df025 100644 --- a/db/src/ClientManagerEventFlag.cpp +++ b/db/src/ClientManagerEventFlag.cpp @@ -10,7 +10,7 @@ void CClientManager::LoadEventFlag() { char szQuery[1024]; snprintf(szQuery, sizeof(szQuery), "SELECT szName, lValue FROM quest%s WHERE dwPID = 0", GetTablePostfix()); - std::auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); SQLResult* pRes = pmsg->Get(); if (pRes->uiNumRows) diff --git a/db/src/ClientManagerGuild.cpp b/db/src/ClientManagerGuild.cpp index 1b6c9f0..53a9b3f 100644 --- a/db/src/ClientManagerGuild.cpp +++ b/db/src/ClientManagerGuild.cpp @@ -33,12 +33,12 @@ void CClientManager::GuildAddMember(CPeer* peer, TPacketGDGuildAddMember * p) "INSERT INTO guild_member%s VALUES(%u, %u, %d, 0, 0)", GetTablePostfix(), p->dwPID, p->dwGuild, p->bGrade); - std::auto_ptr pmsg_insert(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg_insert(CDBManager::instance().DirectQuery(szQuery)); snprintf(szQuery, sizeof(szQuery), "SELECT pid, grade, is_general, offer, level, job, name FROM guild_member%s, player%s WHERE guild_id = %u and pid = id and pid = %u", GetTablePostfix(), GetTablePostfix(), p->dwGuild, p->dwPID); - std::auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); if (pmsg->Get()->uiNumRows == 0) { diff --git a/db/src/ClientManagerHorseName.cpp b/db/src/ClientManagerHorseName.cpp index f66d8dc..655248d 100644 --- a/db/src/ClientManagerHorseName.cpp +++ b/db/src/ClientManagerHorseName.cpp @@ -8,7 +8,7 @@ void CClientManager::UpdateHorseName(TPacketUpdateHorseName* data, CPeer* peer) snprintf(szQuery, sizeof(szQuery), "REPLACE INTO horse_name VALUES(%u, '%s')", data->dwPlayerID, data->szHorseName); - std::auto_ptr pmsg_insert(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg_insert(CDBManager::instance().DirectQuery(szQuery)); ForwardPacket(HEADER_DG_UPDATE_HORSE_NAME, data, sizeof(TPacketUpdateHorseName), 0, peer); } @@ -19,7 +19,7 @@ void CClientManager::AckHorseName(DWORD dwPID, CPeer* peer) snprintf(szQuery, sizeof(szQuery), "SELECT name FROM horse_name WHERE id = %u", dwPID); - std::auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); TPacketUpdateHorseName packet; packet.dwPlayerID = dwPID; diff --git a/db/src/ClientManagerLogin.cpp b/db/src/ClientManagerLogin.cpp index 2621e4b..a69cb00 100644 --- a/db/src/ClientManagerLogin.cpp +++ b/db/src/ClientManagerLogin.cpp @@ -81,24 +81,6 @@ bool CClientManager::FindLogonAccount(const char * c_pszLogin) void CClientManager::QUERY_LOGIN_BY_KEY(CPeer * pkPeer, DWORD dwHandle, TPacketGDLoginByKey * p) { -#ifdef ENABLE_LIMIT_TIME - static int s_updateCount = 0; - static int s_curTime = time(0); - if (s_updateCount > 100) - { - s_curTime = time(0); - s_updateCount = 0; - } - ++s_updateCount; - - if (s_curTime >= GLOBAL_LIMIT_TIME) - { - sys_err("Server life time expired."); - exit(0); - return; - } -#endif - CLoginData * pkLoginData = GetLoginData(p->dwLoginKey); char szLogin[LOGIN_MAX_LEN + 1]; trim_and_lower(p->szLogin, szLogin, sizeof(szLogin)); @@ -180,7 +162,7 @@ void CClientManager::RESULT_LOGIN_BY_KEY(CPeer * peer, SQLMsg * msg) DWORD account_id = info->pAccountTable->id; char szQuery[QUERY_MAX_LEN]; snprintf(szQuery, sizeof(szQuery), "SELECT pid1, pid2, pid3, pid4, empire FROM player_index%s WHERE id=%u", GetTablePostfix(), account_id); - std::auto_ptr pMsg(CDBManager::instance().DirectQuery(szQuery, SQL_PLAYER)); + std::unique_ptr pMsg(CDBManager::instance().DirectQuery(szQuery, SQL_PLAYER)); sys_log(0, "RESULT_LOGIN_BY_KEY FAIL player_index's NULL : ID:%d", account_id); @@ -506,7 +488,7 @@ void CClientManager::QUERY_CHANGE_NAME(CPeer * peer, DWORD dwHandle, TPacketGDCh snprintf(queryStr, sizeof(queryStr), "SELECT COUNT(*) as count FROM player%s WHERE name='%s' AND id <> %u", GetTablePostfix(), p->name, p->pid); - std::auto_ptr pMsg(CDBManager::instance().DirectQuery(queryStr, SQL_PLAYER)); + std::unique_ptr pMsg(CDBManager::instance().DirectQuery(queryStr, SQL_PLAYER)); if (pMsg->Get()->uiNumRows) { @@ -533,7 +515,7 @@ void CClientManager::QUERY_CHANGE_NAME(CPeer * peer, DWORD dwHandle, TPacketGDCh snprintf(queryStr, sizeof(queryStr), "UPDATE player%s SET name='%s',change_name=0 WHERE id=%u", GetTablePostfix(), p->name, p->pid); - std::auto_ptr pMsg0(CDBManager::instance().DirectQuery(queryStr, SQL_PLAYER)); + std::unique_ptr pMsg0(CDBManager::instance().DirectQuery(queryStr, SQL_PLAYER)); TPacketDGChangeName pdg; peer->EncodeHeader(HEADER_DG_CHANGE_NAME, dwHandle, sizeof(TPacketDGChangeName)); diff --git a/db/src/ClientManagerPlayer.cpp b/db/src/ClientManagerPlayer.cpp index 3c51b2b..2859ba7 100644 --- a/db/src/ClientManagerPlayer.cpp +++ b/db/src/ClientManagerPlayer.cpp @@ -549,7 +549,7 @@ bool CreatePlayerTableFromRes(MYSQL_RES * res, TPlayerTable * pkTab) void CClientManager::RESULT_COMPOSITE_PLAYER(CPeer * peer, SQLMsg * pMsg, DWORD dwQID) { CQueryInfo * qi = (CQueryInfo *) pMsg->pvUserData; - std::auto_ptr info((ClientHandleInfo *) qi->pvData); + std::unique_ptr info((ClientHandleInfo *) qi->pvData); MYSQL_RES * pSQLResult = pMsg->Get()->pSQLResult; if (!pSQLResult) @@ -813,7 +813,7 @@ void CClientManager::__QUERY_PLAYER_CREATE(CPeer *peer, DWORD dwHandle, TPlayerC queryLen = snprintf(queryStr, sizeof(queryStr), "SELECT pid%u FROM player_index%s WHERE id=%d", packet->account_index + 1, GetTablePostfix(), packet->account_id); - std::auto_ptr pMsg0(CDBManager::instance().DirectQuery(queryStr)); + std::unique_ptr pMsg0(CDBManager::instance().DirectQuery(queryStr)); if (pMsg0->Get()->uiNumRows != 0) { @@ -847,7 +847,7 @@ void CClientManager::__QUERY_PLAYER_CREATE(CPeer *peer, DWORD dwHandle, TPlayerC snprintf(queryStr, sizeof(queryStr), "SELECT COUNT(*) as count FROM player%s WHERE name='%s'", GetTablePostfix(), packet->player_table.name); - std::auto_ptr pMsg1(CDBManager::instance().DirectQuery(queryStr)); + std::unique_ptr pMsg1(CDBManager::instance().DirectQuery(queryStr)); if (pMsg1->Get()->uiNumRows) { @@ -905,7 +905,7 @@ void CClientManager::__QUERY_PLAYER_CREATE(CPeer *peer, DWORD dwHandle, TPlayerC CDBManager::instance().EscapeString(text, packet->player_table.quickslot, sizeof(packet->player_table.quickslot)); queryLen += snprintf(queryStr + queryLen, sizeof(queryStr) - queryLen, "'%s')", text); - std::auto_ptr pMsg2(CDBManager::instance().DirectQuery(queryStr)); + std::unique_ptr pMsg2(CDBManager::instance().DirectQuery(queryStr)); if (g_test_server) sys_log(0, "Create_Player queryLen[%d] TEXT[%s]", queryLen, text); @@ -920,7 +920,7 @@ void CClientManager::__QUERY_PLAYER_CREATE(CPeer *peer, DWORD dwHandle, TPlayerC snprintf(queryStr, sizeof(queryStr), "UPDATE player_index%s SET pid%d=%d WHERE id=%d", GetTablePostfix(), packet->account_index + 1, player_id, packet->account_id); - std::auto_ptr pMsg3(CDBManager::instance().DirectQuery(queryStr)); + std::unique_ptr pMsg3(CDBManager::instance().DirectQuery(queryStr)); if (pMsg3->Get()->uiAffectedRows <= 0) { @@ -1067,7 +1067,7 @@ void CClientManager::__RESULT_PLAYER_DELETE(CPeer *peer, SQLMsg* msg) snprintf(queryStr, sizeof(queryStr), "INSERT INTO player%s_deleted SELECT * FROM player%s WHERE id=%d", GetTablePostfix(), GetTablePostfix(), pi->player_id); - std::auto_ptr pIns(CDBManager::instance().DirectQuery(queryStr)); + std::unique_ptr pIns(CDBManager::instance().DirectQuery(queryStr)); if (pIns->Get()->uiAffectedRows == 0 || pIns->Get()->uiAffectedRows == (uint32_t)-1) { @@ -1119,7 +1119,7 @@ void CClientManager::__RESULT_PLAYER_DELETE(CPeer *peer, SQLMsg* msg) pi->account_index + 1, pi->player_id); - std::auto_ptr pMsg(CDBManager::instance().DirectQuery(queryStr)); + std::unique_ptr pMsg(CDBManager::instance().DirectQuery(queryStr)); if (pMsg->Get()->uiAffectedRows == 0 || pMsg->Get()->uiAffectedRows == (uint32_t)-1) { diff --git a/db/src/GuildManager.cpp b/db/src/GuildManager.cpp index 1a0a3b8..cb489e5 100644 --- a/db/src/GuildManager.cpp +++ b/db/src/GuildManager.cpp @@ -159,7 +159,7 @@ void CGuildManager::Initialize() { char szQuery[1024]; snprintf(szQuery, sizeof(szQuery), "SELECT id, name, ladder_point, win, draw, loss, gold, level FROM guild%s", GetTablePostfix()); - std::auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); if (pmsg->Get()->uiNumRows) ParseResult(pmsg->Get()); @@ -190,7 +190,7 @@ void CGuildManager::Load(DWORD dwGuildID) char szQuery[1024]; snprintf(szQuery, sizeof(szQuery), "SELECT id, name, ladder_point, win, draw, loss, gold, level FROM guild%s WHERE id=%u", GetTablePostfix(), dwGuildID); - std::auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); if (pmsg->Get()->uiNumRows) ParseResult(pmsg->Get()); @@ -901,7 +901,7 @@ void CGuildManager::BootReserveWar() for (int i = 0; i < 2; ++i) { - std::auto_ptr pmsg(CDBManager::instance().DirectQuery(c_apszQuery[i])); + std::unique_ptr pmsg(CDBManager::instance().DirectQuery(c_apszQuery[i])); if (pmsg->Get()->uiNumRows == 0) continue; @@ -962,7 +962,7 @@ int GetAverageGuildMemberLevel(DWORD dwGID) "SELECT AVG(level) FROM guild_member%s, player%s AS p WHERE guild_id=%u AND guild_member%s.pid=p.id", GetTablePostfix(), GetTablePostfix(), dwGID, GetTablePostfix()); - std::auto_ptr msg(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr msg(CDBManager::instance().DirectQuery(szQuery)); MYSQL_ROW row; row = mysql_fetch_row(msg->Get()->pSQLResult); @@ -977,7 +977,7 @@ int GetGuildMemberCount(DWORD dwGID) snprintf(szQuery, sizeof(szQuery), "SELECT COUNT(*) FROM guild_member%s WHERE guild_id=%u", GetTablePostfix(), dwGID); - std::auto_ptr msg(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr msg(CDBManager::instance().DirectQuery(szQuery)); MYSQL_ROW row; row = mysql_fetch_row(msg->Get()->pSQLResult); @@ -1065,7 +1065,7 @@ bool CGuildManager::ReserveWar(TPacketGuildWar * p) "VALUES(%u, %u, DATE_ADD(NOW(), INTERVAL 180 SECOND), %u, %ld, %ld, %ld, %ld, %ld)", GID1, GID2, p->bType, p->lWarPrice, p->lInitialScore, t.lPowerFrom, t.lPowerTo, t.lHandicap); - std::auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); if (pmsg->Get()->uiAffectedRows == 0 || pmsg->Get()->uiInsertID == 0 || pmsg->Get()->uiAffectedRows == (uint32_t)-1) { @@ -1214,7 +1214,7 @@ void CGuildWarReserve::Initialize() char szQuery[256]; snprintf(szQuery, sizeof(szQuery), "SELECT login, guild, gold FROM guild_war_bet WHERE war_id=%u", m_data.dwID); - std::auto_ptr msgbet(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr msgbet(CDBManager::instance().DirectQuery(szQuery)); if (msgbet->Get()->uiNumRows) { @@ -1291,7 +1291,7 @@ bool CGuildWarReserve::Bet(const char * pszLogin, DWORD dwGold, DWORD dwGuild) "INSERT INTO guild_war_bet (war_id, login, gold, guild) VALUES(%u, '%s', %u, %u)", m_data.dwID, pszLogin, dwGold, dwGuild); - std::auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); if (pmsg->Get()->uiAffectedRows == 0 || pmsg->Get()->uiAffectedRows == (uint32_t)-1) { diff --git a/db/src/HB.cpp b/db/src/HB.cpp index 1a2498f..4caea8a 100644 --- a/db/src/HB.cpp +++ b/db/src/HB.cpp @@ -19,7 +19,7 @@ bool PlayerHB::Initialize() char szQuery[128]; snprintf(szQuery, sizeof(szQuery), "SHOW CREATE TABLE player%s", GetTablePostfix()); - std::auto_ptr pMsg(CDBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pMsg(CDBManager::instance().DirectQuery(szQuery)); if (pMsg->Get()->uiNumRows == 0) return false; @@ -75,7 +75,7 @@ bool PlayerHB::Query(DWORD id) snprintf(szQuery, sizeof(szQuery), "CREATE TABLE IF NOT EXISTS %s%s", szTableName, m_stCreateTableQuery.c_str() + strlen(szFind)); // sys_log(0, "%s", szQuery); - std::auto_ptr pMsg(CDBManager::instance().DirectQuery(szQuery, SQL_HOTBACKUP)); + std::unique_ptr pMsg(CDBManager::instance().DirectQuery(szQuery, SQL_HOTBACKUP)); m_stTableName = szTableName; } diff --git a/db/src/Marriage.cpp b/db/src/Marriage.cpp index 3c70aa6..858428a 100644 --- a/db/src/Marriage.cpp +++ b/db/src/Marriage.cpp @@ -40,8 +40,8 @@ namespace marriage "SELECT pid1, pid2, love_point, time, is_married, p1.name, p2.name FROM marriage, player%s as p1, player%s as p2 WHERE p1.id = pid1 AND p2.id = pid2", GetTablePostfix(), GetTablePostfix()); - auto_ptr pmsg_delete(CDBManager::instance().DirectQuery("DELETE FROM marriage WHERE is_married = 0")); - auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + unique_ptr pmsg_delete(CDBManager::instance().DirectQuery("DELETE FROM marriage WHERE is_married = 0")); + unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); SQLResult * pRes = pmsg->Get(); sys_log(0, "MarriageList(size=%lu)", pRes->uiNumRows); @@ -101,7 +101,7 @@ namespace marriage char szQuery[512]; snprintf(szQuery, sizeof(szQuery), "INSERT INTO marriage(pid1, pid2, love_point, time) VALUES (%u, %u, 0, %u)", dwPID1, dwPID2, now); - auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); SQLResult* res = pmsg->Get(); if (res->uiAffectedRows == 0 || res->uiAffectedRows == (uint32_t)-1) @@ -141,7 +141,7 @@ namespace marriage snprintf(szQuery, sizeof(szQuery), "UPDATE marriage SET love_point = %d, is_married = %d WHERE pid1 = %u AND pid2 = %u", iLovePoint, byMarried, pMarriage->pid1, pMarriage->pid2); - auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); SQLResult* res = pmsg->Get(); if (res->uiAffectedRows == 0 || res->uiAffectedRows == (uint32_t)-1) @@ -187,7 +187,7 @@ namespace marriage char szQuery[512]; snprintf(szQuery, sizeof(szQuery), "DELETE FROM marriage WHERE pid1 = %u AND pid2 = %u", dwPID1, dwPID2); - auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); SQLResult* res = pmsg->Get(); if (res->uiAffectedRows == 0 || res->uiAffectedRows == (uint32_t)-1) @@ -231,7 +231,7 @@ namespace marriage snprintf(szQuery, sizeof(szQuery), "UPDATE marriage SET is_married = 1 WHERE pid1 = %u AND pid2 = %u", pMarriage->pid1, pMarriage->pid2); - auto_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); + unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); SQLResult* res = pmsg->Get(); if (res->uiAffectedRows == 0 || res->uiAffectedRows == (uint32_t)-1) diff --git a/db/src/stdafx.h b/db/src/stdafx.h index 3a801ad..7617a8a 100644 --- a/db/src/stdafx.h +++ b/db/src/stdafx.h @@ -17,4 +17,7 @@ #include #include +#include +#include + #endif diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index 54bcb27..6128124 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -6,7 +6,7 @@ file(GLOB_RECURSE sources src/*.cpp src/*.h ) -include_directories(${PROJECT_BINARY_DIR}/src/system/) +include_directories(${PROJECT_BINARY_DIR}/src/) include_directories(src/) @@ -15,18 +15,21 @@ find_package(libmysql REQUIRED) find_package(Boost COMPONENTS system REQUIRED) find_package(DevIL REQUIRED) find_package(LZO REQUIRED) +find_package(cryptopp CONFIG REQUIRED) +find_package(GTest REQUIRED) add_executable(${PROJECT_NAME} ${sources}) # Link dependencies if found -if (libmysql_FOUND) - target_link_libraries (${PROJECT_NAME} ${MYSQL_LIBRARIES}) -endif (libmysql_FOUND) +target_link_libraries (${PROJECT_NAME} ${MYSQL_LIBRARIES}) + +# Crypto++ +target_link_libraries (${PROJECT_NAME} cryptopp-static) + +# Boost +include_directories(${Boost_INCLUDE_DIR}) +target_link_libraries (${PROJECT_NAME} ${Boost_LIBRARIES}) -if (Boost_FOUND) - include_directories(${Boost_INCLUDE_DIRS}) - target_link_libraries (${PROJECT_NAME} ${Boost_LIBRARIES} ${Boost_SYSTEM_LIBRARY}) -endif (Boost_FOUND) if (IL_FOUND) include_directories(${IL_INCLUDE_DIR}) @@ -39,14 +42,12 @@ if (LZO_FOUND) endif (LZO_FOUND) -target_link_libraries(${PROJECT_NAME} md) - # Pthreads set(THREADS_PREFER_PTHREAD_FLAG ON) find_package (Threads REQUIRED) target_link_libraries (${PROJECT_NAME} Threads::Threads) -find_package(GTest REQUIRED) +# Google test if (GTEST_FOUND) include_directories(${GTEST_INCLUDE_DIRS}) target_link_libraries (${PROJECT_NAME} ${GTEST_BOTH_LIBRARIES}) diff --git a/game/src/ClientPackageCryptInfo.cpp b/game/src/ClientPackageCryptInfo.cpp index 96c635d..6b106b3 100644 --- a/game/src/ClientPackageCryptInfo.cpp +++ b/game/src/ClientPackageCryptInfo.cpp @@ -2,10 +2,6 @@ #include "ClientPackageCryptInfo.h" #include -#ifndef __FreeBSD__ -#include "../../libthecore/include/xdirent.h" -#endif - CClientPackageCryptInfo::CClientPackageCryptInfo() : m_pSerializedCryptKeyStream(NULL), m_nCryptKeyPackageCnt(0) { } diff --git a/game/src/ClientPackageCryptInfo.h b/game/src/ClientPackageCryptInfo.h index 662a325..e17dfd9 100644 --- a/game/src/ClientPackageCryptInfo.h +++ b/game/src/ClientPackageCryptInfo.h @@ -1,7 +1,7 @@ #ifndef __INC_CLIENTPACKAGE_CRYPTINFO_H #define __INC_CLIENTPACKAGE_CRYPTINFO_H -#include +#include #pragma pack(1) @@ -103,7 +103,7 @@ private: } TPerFileSDBInfo; - typedef boost::unordered_map TPackageSDBMap; //key: related map name + typedef std::unordered_map TPackageSDBMap; //key: related map name TPackageSDBMap m_mapPackageSDB; diff --git a/game/src/DragonLair.cpp b/game/src/DragonLair.cpp index 9535a83..fcf3d73 100644 --- a/game/src/DragonLair.cpp +++ b/game/src/DragonLair.cpp @@ -222,7 +222,7 @@ void CDragonLairManager::OnDragonDead(LPCHARACTER pDragon, DWORD KillerGuildID) if (false == pDragon->IsMonster()) return; - boost::unordered_map::iterator iter = LairMap_.find( KillerGuildID ); + std::unordered_map::iterator iter = LairMap_.find( KillerGuildID ); if (LairMap_.end() == iter) { diff --git a/game/src/DragonLair.h b/game/src/DragonLair.h index b8f9b76..b17e718 100644 --- a/game/src/DragonLair.h +++ b/game/src/DragonLair.h @@ -1,5 +1,5 @@ -#include +#include #include @@ -32,6 +32,6 @@ class CDragonLairManager : public singleton size_t GetLairCount () const { return LairMap_.size(); } private: - boost::unordered_map LairMap_; + std::unordered_map LairMap_; }; diff --git a/game/src/FileMonitor_FreeBSD.cpp b/game/src/FileMonitor_FreeBSD.cpp deleted file mode 100644 index e44a65e..0000000 --- a/game/src/FileMonitor_FreeBSD.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include "stdafx.h" -#include "FileMonitor_FreeBSD.h" -#include "../../libthecore/include/log.h" - - -#define INVALID_KERNEL_EVENT -1 - -FileMonitorFreeBSD::FileMonitorFreeBSD() -{ - m_KernelEventQueue = INVALID_KERNEL_EVENT; -} - -FileMonitorFreeBSD::~FileMonitorFreeBSD() -{ - if( m_KernelEventQueue != INVALID_KERNEL_EVENT ) - { - close ( m_KernelEventQueue ); - m_KernelEventQueue = INVALID_KERNEL_EVENT; - } - - TMonitorFileHashMap::iterator it; - for( it = m_FileLists.begin(); it != m_FileLists.end(); ++it ) - { - close(it->second.fhMonitor); - } - - m_FileLists.clear(); - - m_MonitoredEventLists.clear(); - m_TriggeredEventLists.clear(); -} - - -void FileMonitorFreeBSD::Update(DWORD dwPulses) -{ - if( m_KernelEventQueue == INVALID_KERNEL_EVENT || m_FileLists.size() == 0 ) - return; - - int nEvent = kevent(m_KernelEventQueue, &m_TriggeredEventLists[0], (int)m_TriggeredEventLists.size(), &m_MonitoredEventLists[0], (int)m_MonitoredEventLists.size(), NULL ); - if( nEvent == INVALID_KERNEL_EVENT ) - { - return; - } - else if( nEvent > 0 ) - { - for( int i = 0; i < nEvent; ++i ) - { - int nEventFlags = m_MonitoredEventLists[i].flags; - eFileUpdatedOptions eUpdateOption = e_FileUpdate_None; - - if (nEventFlags & EV_ERROR) - eUpdateOption = e_FileUpdate_Error; - - else if (nEventFlags & NOTE_DELETE) - eUpdateOption = e_FileUpdate_Deleted; - - else if (nEventFlags & NOTE_EXTEND || nEventFlags & NOTE_WRITE) - eUpdateOption = e_FileUpdate_Modified; - - else if (nEventFlags & NOTE_ATTRIB) - eUpdateOption = e_FileUpdate_AttrModified; - - else if (nEventFlags & NOTE_LINK) - eUpdateOption = e_FileUpdate_Linked; - - else if (nEventFlags & NOTE_RENAME) - eUpdateOption = e_FileUpdate_Renamed; - - else if (nEventFlags & NOTE_REVOKE) - eUpdateOption = e_FileUpdate_Revoked; - - if( eUpdateOption != e_FileUpdate_None ) - { - TMonitorFileHashMap::iterator it; - for( it = m_FileLists.begin(); it != m_FileLists.end(); ++it ) - { - FileIOContext_FreeBSD& context = it->second; - if( context.idxToEventList == i ) - { - std::string strModifedFileName = it->first; - context.pListenFunc( strModifedFileName, eUpdateOption ); - break; - } - } - } - } - } -} - -void FileMonitorFreeBSD::AddWatch(const std::string& strFileName, PFN_FileChangeListener pListenerFunc) -{ - int iFileHandle = -1; - if( (iFileHandle = open(strFileName.c_str(), O_RDONLY)) == -1) - { - sys_err("FileMonitorFreeBSD:AddWatch : can`t open file(%s).\n", strFileName.c_str()); - return; - } - - //create kqueue if not exists - if( m_KernelEventQueue == INVALID_KERNEL_EVENT ) - m_KernelEventQueue = kqueue(); - - if( m_KernelEventQueue == INVALID_KERNEL_EVENT ) - { - sys_err("FileMonitorFreeBSD:AddWatch : failed to create kqueue.\n"); - return; - } - - TMonitorFileHashMap::iterator it = m_FileLists.find( strFileName ); - if( it != m_FileLists.end() ) - { - sys_log(0, "FileMonitorFreeBSD:AddWatch : trying to add duplicated watch on file(%s).\n", strFileName.c_str() ); - return; - } - - //set file context - FileIOContext_FreeBSD context; - { - context.fhMonitor = iFileHandle; - context.idxToEventList = (int)m_MonitoredEventLists.size(); - context.pListenFunc = pListenerFunc; - } - - m_FileLists[strFileName] = context; - - //set events - struct kevent kTriggerEvent, kMonitorEvent; - - EV_SET(&kTriggerEvent, iFileHandle, EVFILT_VNODE, - EV_ADD | EV_ENABLE | EV_ONESHOT, - NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | NOTE_LINK | NOTE_RENAME | NOTE_REVOKE, - 0, 0); - - m_TriggeredEventLists.push_back( kTriggerEvent ); - m_MonitoredEventLists.push_back( kMonitorEvent ); -} \ No newline at end of file diff --git a/game/src/FileMonitor_FreeBSD.h b/game/src/FileMonitor_FreeBSD.h deleted file mode 100644 index 23e2170..0000000 --- a/game/src/FileMonitor_FreeBSD.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef FILEMONITOR_FREEBSD_INCLUDED -#define FILEMONITOR_FREEBSD_INCLUDED - -#include "IFileMonitor.h" -#include -#include -#include -#include -#include - -struct FileIOContext_FreeBSD -{ - int fhMonitor; - int idxToEventList; // evtTrigger & evtMonitor index should be same - PFN_FileChangeListener pListenFunc; -}; - -class FileMonitorFreeBSD : public IFileMonitor -{ -private: - FileMonitorFreeBSD(); //hidden - -public: - virtual ~FileMonitorFreeBSD(); - - void AddWatch (const std::string& strFileName, PFN_FileChangeListener pListenerFunc); - void Update (DWORD dwPulses); - - static FileMonitorFreeBSD& Instance() - { - static FileMonitorFreeBSD theMonitor; - return theMonitor; - } - -private: - typedef boost::unordered_map TMonitorFileHashMap; - typedef std::vector TEventList; - - TMonitorFileHashMap m_FileLists; - TEventList m_MonitoredEventLists; - TEventList m_TriggeredEventLists; - - int m_KernelEventQueue; -}; - - -#endif //FILEMONITOR_FREEBSD_INCLUDED diff --git a/game/src/HackShield.cpp b/game/src/HackShield.cpp deleted file mode 100644 index 9b7ddfa..0000000 --- a/game/src/HackShield.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -#include "stdafx.h" - -#include "HackShield.h" - -#include "HackShield_Impl.h" -#include "config.h" - -bool CHackShieldManager::Initialize() -{ - impl_ = M2_NEW CHackShieldImpl; - - if (NULL == impl_) - { - return false; - } - - return impl_->Initialize(); -} - -void CHackShieldManager::Release() -{ - if (NULL != impl_) - { - impl_->Release(); - - M2_DELETE(impl_); - - impl_ = NULL; - } -} - -bool CHackShieldManager::CreateClientHandle(DWORD dwPlayerID) -{ - return impl_->CreateClientHandle(dwPlayerID); -} - -void CHackShieldManager::DeleteClientHandle(DWORD dwPlayerID) -{ - impl_->DeleteClientHandle(dwPlayerID); -} - -bool CHackShieldManager::SendCheckPacket(LPCHARACTER ch) -{ - return impl_->SendCheckPacket(ch); -} - -bool CHackShieldManager::VerifyAck(LPCHARACTER ch, const void* buf) -{ - TPacketGCHSCheck* p = reinterpret_cast(const_cast(buf)); - - return impl_->VerifyAck(ch, p); -} - diff --git a/game/src/HackShield.h b/game/src/HackShield.h deleted file mode 100644 index f9954cb..0000000 --- a/game/src/HackShield.h +++ /dev/null @@ -1,24 +0,0 @@ - -#ifndef HACK_SHIELD_MANAGER_H_ -#define HACK_SHIELD_MANAGER_H_ - -class CHackShieldImpl; - -class CHackShieldManager : public singleton -{ - public: - bool Initialize (); - void Release (); - - bool CreateClientHandle (DWORD dwPlayerID); - void DeleteClientHandle (DWORD dwPlayerID); - - bool SendCheckPacket (LPCHARACTER ch); - bool VerifyAck (LPCHARACTER ch, const void* buf); - - private: - CHackShieldImpl* impl_; -}; - -#endif /* HACK_SHIELD_MANAGER_H_ */ - diff --git a/game/src/HackShield_Impl.cpp b/game/src/HackShield_Impl.cpp deleted file mode 100644 index 1cdd0f1..0000000 --- a/game/src/HackShield_Impl.cpp +++ /dev/null @@ -1,202 +0,0 @@ -#include "stdafx.h" - -#include "HackShield_Impl.h" - -#ifdef __FreeBSD__ - -#include "char.h" -#include "packet.h" -#include "desc.h" -#include "log.h" - -bool CHackShieldImpl::Initialize() -{ - handle_ = _AhnHS_CreateServerObject("metin2client.bin.hsb"); - - if (ANTICPX_INVALID_HANDLE_VALUE == handle_) - { - return false; - } - - sys_log(0, "HShield: Success to CreateServerObject"); - - return true; -} - -void CHackShieldImpl::Release() -{ - _AhnHS_CloseServerHandle(handle_); - - sys_log(0, "HShield: Server Handle Closed"); -} - -bool CHackShieldImpl::CreateClientHandle(DWORD dwPlayerID) -{ - ClientHandleContainer::const_iterator iter = CliehtHandleMap_.find( dwPlayerID ); - - if (iter != CliehtHandleMap_.end()) - { - sys_log(0, "HShield: Client Handle is already created for Player(%u)", dwPlayerID); - - return false; - } - - AHNHS_CLIENT_HANDLE handle = _AhnHS_CreateClientObject(handle_); - - if (ANTICPX_INVALID_HANDLE_VALUE == handle) - { - sys_log(0, "HShield: Failed to create client handle for Player(%u)", dwPlayerID); - - return false; - } - - CliehtHandleMap_.insert( std::make_pair(dwPlayerID, handle) ); - - sys_log(0, "HShield: Success to create client handle for Player(%u)", dwPlayerID); - - return true; -} - -void CHackShieldImpl::DeleteClientHandle(DWORD dwPlayerID) -{ - ClientHandleContainer::iterator iter = CliehtHandleMap_.find( dwPlayerID ); - - if (iter == CliehtHandleMap_.end()) - { - sys_log(0, "HShield: there is no client handle for Player(%u)", dwPlayerID); - - return; - } - - _AhnHS_CloseClientHandle(iter->second); - - CliehtHandleMap_.erase(iter); - - sys_log(0, "HShield: client handle deleted for Player(%u)", dwPlayerID); -} - -bool CHackShieldImpl::SendCheckPacket(LPCHARACTER ch) -{ - if (NULL == ch) - { - return false; - } - - ClientHandleContainer::const_iterator iter = CliehtHandleMap_.find( ch->GetPlayerID() ); - - if (iter == CliehtHandleMap_.end()) - { - sys_log(0, "HShield: Client Handle not create for Player(%u)", ch->GetPlayerID()); - return false; - } - - TPacketGCHSCheck pack; - pack.bHeader = HEADER_GC_HS_REQUEST; - - memset( &pack.Req, 0, sizeof(pack.Req)); - unsigned long ret = _AhnHS_MakeRequest( iter->second, &(pack.Req) ); - - if (0 != ret) - { - sys_log(0, "HShield: _AhnHS_MakeRequest return error(%u) for Player(%u)", ret, ch->GetPlayerID()); - return false; - } - else - { - sys_log(0, "HShield: _AhnHS_MakeRequest success ret(%d)", ret); - } - - if (NULL != ch->GetDesc()) - { - ch->GetDesc()->Packet( &pack, sizeof(pack) ); - sys_log(0, "HShield: Send Check Request for Player(%u)", ch->GetPlayerID()); - - return true; - } - - sys_log(0, "HShield: Failed to get DESC for Player(%u)", ch->GetPlayerID()); - - return false; -} - -bool CHackShieldImpl::VerifyAck(LPCHARACTER ch, TPacketGCHSCheck* buf) -{ - if (NULL == ch) - { - return false; - } - - bool NeedDisconnect = false; - - ClientHandleContainer::const_iterator iter = CliehtHandleMap_.find( ch->GetPlayerID() ); - - if (iter == CliehtHandleMap_.end()) - { - sys_log(0, "HShield: Cannot Find ClientHandle For Verify"); - - NeedDisconnect = true; - } - - unsigned long dwError = 0; - - unsigned long ret = _AhnHS_VerifyResponseEx( iter->second, buf->Req.byBuffer, buf->Req.nLength, &dwError ); - - if (ANTICPX_RECOMMAND_CLOSE_SESSION == ret) - { - sys_log(0, "HShield: not a valid ack ret(%u) error(%u) from Player(%u)", ret, dwError, ch->GetPlayerID()); - NeedDisconnect = true; - - ch->StopHackShieldCheckCycle(); - } - - if (NULL != ch->GetDesc()) - { - if (true == NeedDisconnect) - { - ch->GetDesc()->SetPhase(PHASE_CLOSE); - LogManager::instance().HackShieldLog(dwError, ch); - return false; - } - else - { - ch->SetHackShieldCheckMode(false); - } - } - - sys_log(0, "HShield: Valid Ack from Player(%u)", ch->GetPlayerID()); - - return true; -} - -#else - -bool CHackShieldImpl::Initialize() -{ - return true; -} - -void CHackShieldImpl::Release() -{ -} - -bool CHackShieldImpl::CreateClientHandle(DWORD dwPlayerID) -{ - return true; -} - -void CHackShieldImpl::DeleteClientHandle(DWORD dwPlayerID) -{ -} - -bool CHackShieldImpl::SendCheckPacket(LPCHARACTER ch) -{ - return true; -} - -bool CHackShieldImpl::VerifyAck(LPCHARACTER ch, TPacketGCHSCheck* buf) -{ - return true; -} - -#endif - diff --git a/game/src/HackShield_Impl.h b/game/src/HackShield_Impl.h deleted file mode 100644 index af32445..0000000 --- a/game/src/HackShield_Impl.h +++ /dev/null @@ -1,51 +0,0 @@ - -#ifndef HACK_SHIELD_IMPL_H_ -#define HACK_SHIELD_IMPL_H_ - -#include - -#ifdef __FreeBSD__ -// Live build only -#define UNIX -#include -#undef UNIX -#endif - -#pragma pack(1) - -typedef struct SPacketGCHSCheck -{ - BYTE bHeader; -#ifdef __FreeBSD__ - AHNHS_TRANS_BUFFER Req; -#endif -} TPacketGCHSCheck; - -#pragma pack() - -class CHackShieldImpl -{ - public: - bool Initialize (); - void Release (); - - bool CreateClientHandle (DWORD dwPlayerID); - void DeleteClientHandle (DWORD dwPlayerID); - - bool SendCheckPacket (LPCHARACTER ch); - bool VerifyAck (LPCHARACTER ch, TPacketGCHSCheck* buf); - - private: -#ifdef __FreeBSD__ - AHNHS_SERVER_HANDLE handle_; - - typedef boost::unordered_map ClientHandleContainer; - ClientHandleContainer CliehtHandleMap_; - - typedef boost::unordered_map ClientCheckContainer; - ClientCheckContainer ClientCheckMap_; -#endif -}; - -#endif /* HACK_SHIELD_IMPL_H_ */ - diff --git a/game/src/IFileMonitor.h b/game/src/IFileMonitor.h index 8ed621a..808919e 100644 --- a/game/src/IFileMonitor.h +++ b/game/src/IFileMonitor.h @@ -2,7 +2,7 @@ #define IFILEMONITOR_INCLUDED //#include -#include +#include enum eFileUpdatedOptions { diff --git a/game/src/MarkImage.h b/game/src/MarkImage.h index ef55c8b..4cf75fc 100644 --- a/game/src/MarkImage.h +++ b/game/src/MarkImage.h @@ -2,7 +2,7 @@ #define __INC_METIN_II_MARKIMAGE_H__ #include -#include "minilzo.h" +#include typedef unsigned long Pixel; diff --git a/game/src/PetSystem.h b/game/src/PetSystem.h index 586d3c2..6348403 100644 --- a/game/src/PetSystem.h +++ b/game/src/PetSystem.h @@ -95,7 +95,7 @@ private: class CPetSystem { public: - typedef boost::unordered_map TPetActorMap; /// map. (ÇÑ Ä³¸¯ÅÍ°¡ °°Àº vnumÀÇ ÆêÀ» ¿©·¯°³ °¡Áú ÀÏÀÌ ÀÖÀ»±î..??) + typedef std::unordered_map TPetActorMap; /// map. (ÇÑ Ä³¸¯ÅÍ°¡ °°Àº vnumÀÇ ÆêÀ» ¿©·¯°³ °¡Áú ÀÏÀÌ ÀÖÀ»±î..??) public: CPetSystem(LPCHARACTER owner); diff --git a/game/src/XTrapManager.cpp b/game/src/XTrapManager.cpp deleted file mode 100644 index bf4a92c..0000000 --- a/game/src/XTrapManager.cpp +++ /dev/null @@ -1,329 +0,0 @@ -#include "stdafx.h" - -#include -#include - -#if defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64) -#include -#include -#include -#else -#include -#include -#endif - -#include - -#include "char.h" -#include "config.h" -#include "event.h" -#include "log.h" -#include "desc.h" -#include "packet.h" -#include "XTrapManager.h" - -#define CSFILE_NUM 2 -#define XTRAP_CS1_CHECK_CYCLE PASSES_PER_SEC(20) // per 20sec - -unsigned char g_XTrap_ClientMap[CSFILE_NUM][XTRAP_CS4_BUFSIZE_MAP]; - - -struct CXTrapManager::sXTrapContext -{ - //API function pointers - PFN_XTrap_S_Start XTrap_S_Start; - PFN_XTrap_S_SessionInit XTrap_S_SessionInit; - PFN_XTrap_CS_Step1 XTrap_CS_Step1; - PFN_XTrap_CS_Step3 XTrap_CS_Step3; - - PFN_XTrap_S_SetActiveCode XTrap_S_SetActiveCode; - PFN_XTrap_S_SetOption XTrap_S_SetOption; - PFN_XTrap_S_SetAllowDelay XTrap_S_SetAllowDelay; - PFN_XTrap_S_SendGamePacket XTrap_S_SendGamePacket; - PFN_XTrap_S_RecvGamePacket XTrap_S_RecvGamePacket; - - //handle - void* hXTrap4Server; -}; - - -CXTrapManager::CXTrapManager() -{ - m_pImpl = M2_NEW sXTrapContext; - memset( m_pImpl, 0x00, sizeof(sXTrapContext) ); -} - -CXTrapManager::~CXTrapManager() -{ -#ifdef __FreeBSD__ - if (m_pImpl->hXTrap4Server) - { - dlclose(m_pImpl->hXTrap4Server); - } -#endif - - M2_DELETE(m_pImpl); -} - -#ifdef __FreeBSD__ -void CXTrapManager::MapReloadSignalHandler( int signal ) -{ - for(int i=0; ihXTrap4Server = dlopen(sDllBinFile, RTLD_LAZY); - - if (m_pImpl->hXTrap4Server == 0) - { - sys_err("XTrap-failed to load so reason:%s", dlerror()) ; - return false; - } - - void* hXTrapHandle = m_pImpl->hXTrap4Server; - - m_pImpl->XTrap_S_Start = (PFN_XTrap_S_Start) dlsym(hXTrapHandle, "XTrap_S_Start"); - m_pImpl->XTrap_S_SessionInit = (PFN_XTrap_S_SessionInit) dlsym(hXTrapHandle, "XTrap_S_SessionInit"); - m_pImpl->XTrap_CS_Step1 = (PFN_XTrap_CS_Step1) dlsym(hXTrapHandle, "XTrap_CS_Step1"); - m_pImpl->XTrap_CS_Step3 = (PFN_XTrap_CS_Step3) dlsym(hXTrapHandle, "XTrap_CS_Step3"); - m_pImpl->XTrap_S_SetActiveCode = (PFN_XTrap_S_SetActiveCode) dlsym(hXTrapHandle, "XTrap_S_SetActiveCode"); - m_pImpl->XTrap_S_SetOption = (PFN_XTrap_S_SetOption) dlsym(hXTrapHandle, "XTrap_S_SetOption"); - m_pImpl->XTrap_S_SetAllowDelay = (PFN_XTrap_S_SetAllowDelay) dlsym(hXTrapHandle, "XTrap_S_SetAllowDelay"); - m_pImpl->XTrap_S_SendGamePacket = (PFN_XTrap_S_SendGamePacket) dlsym(hXTrapHandle, "XTrap_S_SendGamePacket"); - m_pImpl->XTrap_S_RecvGamePacket = (PFN_XTrap_S_RecvGamePacket) dlsym(hXTrapHandle, "XTrap_S_RecvGamePacket"); - - if (m_pImpl->XTrap_S_Start == NULL || - m_pImpl->XTrap_S_SessionInit == NULL || - m_pImpl->XTrap_CS_Step1 == NULL || - m_pImpl->XTrap_CS_Step3 == NULL || - m_pImpl->XTrap_S_SetOption == NULL || - m_pImpl->XTrap_S_SetAllowDelay == NULL || - m_pImpl->XTrap_S_SendGamePacket == NULL || - m_pImpl->XTrap_S_RecvGamePacket == NULL) - { - sys_err("XTrap-failed to load function ptrs"); - return false; - } - - //start server module - m_pImpl->XTrap_S_Start( 600, CSFILE_NUM, g_XTrap_ClientMap, NULL ); - - //NOTE : ÀÏ´Ü XProtect¸ðµâ¿¡ ¹ö±×°¡ À־ Äڵ念¿ª üũ¸¦ ²ö´Ù. - m_pImpl->XTrap_S_SetActiveCode( XTRAP_ACTIVE_CODE_THEMIDA ); - - //setup signal - signal(SIGUSR2, CXTrapManager::MapReloadSignalHandler); - -#endif - return true; -} - -bool CXTrapManager::LoadClientMapFile( unsigned int iMapIndex ) -{ -#ifdef __FreeBSD__ - //index check - if( iMapIndex >= CSFILE_NUM ) - { - return false; - } - - char szFileName[1024] = {0,}; - snprintf(szFileName, sizeof(szFileName), "map%d.CS3", iMapIndex+1); - - FILE* fi = 0; - fi = fopen(szFileName, "rb"); - if (fi == NULL) - { - return false; - } - - fread(g_XTrap_ClientMap[iMapIndex], XTRAP_CS4_BUFSIZE_MAP, 1, fi); - fclose(fi); -#endif - - return true; -} - -EVENTINFO(xtrap_cs1_check_info) -{ - DynamicCharacterPtr ptrPC; -}; - -EVENTFUNC(xtrap_cs1_check_event) -{ - xtrap_cs1_check_info* info = dynamic_cast( event->info ); - - if ( info == NULL ) - { - sys_err( " info null pointer" ); - return 0; - } - - TPacketXTrapCSVerify pack; - pack.bHeader = HEADER_GC_XTRAP_CS1_REQUEST; - - bool bSuccess = CXTrapManager::instance().Verify_CSStep1( info->ptrPC, pack.bPacketData ); - - LPDESC lpClientDesc = info->ptrPC.Get()->GetDesc(); - if( !lpClientDesc ) - { - sys_err( " client session is invalid" ); - return 0; - } - - lpClientDesc->Packet( &pack, sizeof(pack) ); - - if( bSuccess ) - { - return XTRAP_CS1_CHECK_CYCLE; - } - - sys_err( "XTrap: hack is detected %s", lpClientDesc->GetHostName() ); - - info->ptrPC.Get()->Disconnect("XTrapCheckInvalid"); - lpClientDesc->SetPhase(PHASE_CLOSE); - - return 0; -} - -bool CXTrapManager::CreateClientSession( LPCHARACTER lpCharSession ) -{ - if( !bXTrapEnabled ) - return true; - - if( !lpCharSession ) - return false; - - DWORD dwSessionID = lpCharSession->GetPlayerID(); - - ClientSessionMap::iterator it = m_mapClientSessions.find( dwSessionID ); - if( it != m_mapClientSessions.end() ) - { - sys_err("XTrap: client session is alreay registered"); - return false; - } - - //init session info - sSessionInfo infoData; - - //xtrap session init - DWORD dwReturn = m_pImpl->XTrap_S_SessionInit( 600, CSFILE_NUM, g_XTrap_ClientMap, infoData.szSessionBuf ); - if( dwReturn != 0 ) - { - sys_err("XTrap: client session init failed"); - } - - xtrap_cs1_check_info* event_info = AllocEventInfo(); - event_info->ptrPC = lpCharSession; - - infoData.m_pCheckEvent = event_create(xtrap_cs1_check_event, event_info, XTRAP_CS1_CHECK_CYCLE); - m_mapClientSessions[dwSessionID] = infoData; - - return true; -} - -void CXTrapManager::DestroyClientSession( LPCHARACTER lpCharSession ) -{ - if( !bXTrapEnabled ) - return; - - if( !lpCharSession ) - return; - - DWORD dwSessionID = lpCharSession->GetPlayerID(); - - ClientSessionMap::iterator it = m_mapClientSessions.find( dwSessionID ); - if( it == m_mapClientSessions.end() ) - { - sys_err("XTrap: client session is already destroyed"); - return; - } - - event_cancel(&(it->second.m_pCheckEvent) ); - m_mapClientSessions.erase(it); -} - - -bool CXTrapManager::Verify_CSStep1( LPCHARACTER lpCharSession, BYTE* pBufData ) -{ - if( !bXTrapEnabled ) - return false; - - if( !lpCharSession ) - return false; - - DWORD dwSessionID = lpCharSession->GetPlayerID(); - - ClientSessionMap::iterator it = m_mapClientSessions.find( dwSessionID ); - if( it == m_mapClientSessions.end() ) - { - sys_err("XTrap: client session is already destroyed"); - return false; - } - - int nReturn = m_pImpl->XTrap_CS_Step1( it->second.szSessionBuf, it->second.szPackBuf ); - - memcpy( pBufData, it->second.szPackBuf, VERIFY_PACK_LEN ); - - return (nReturn == 0) ? true : false; -} - -void CXTrapManager::Verify_CSStep3( LPCHARACTER lpCharSession, BYTE* pBufData ) -{ - if( !bXTrapEnabled ) - return; - - if( !lpCharSession ) - return; - - DWORD dwSessionID = lpCharSession->GetPlayerID(); - - ClientSessionMap::iterator it = m_mapClientSessions.find( dwSessionID ); - if( it == m_mapClientSessions.end() ) - { - sys_log(0, "XTrap: client session is alreay destroyed"); - return; - } - - memcpy( it->second.szPackBuf, pBufData, VERIFY_PACK_LEN ); - m_pImpl->XTrap_CS_Step3( it->second.szSessionBuf, it->second.szPackBuf ); - - //if( XTRAP_API_RETURN_DETECTHACK == m_pImpl->XTrap_CS_Step3( it->second.szSessionBuf, pBufData ) ) - //{ - // sys_error(0, "XTrap: client session is alreay destroyed"); - //} -} diff --git a/game/src/XTrapManager.h b/game/src/XTrapManager.h deleted file mode 100644 index 3b0e2ab..0000000 --- a/game/src/XTrapManager.h +++ /dev/null @@ -1,67 +0,0 @@ - -#ifndef _XTRAP_MANAGER_H_ -#define _XTRAP_MANAGER_H_ - -#include "IFileMonitor.h" - -#define SESSION_BUF_LEN 320 -#define VERIFY_PACK_LEN 128 -#define SESSION_CSSTEP1_LEN 256 - -#pragma pack(1) - -typedef struct PacketXTrapVerify -{ - BYTE bHeader; - BYTE bPacketData[VERIFY_PACK_LEN]; - -} TPacketXTrapCSVerify; - -#pragma pack() - -class CXTrapManager : public singleton -{ -public: - CXTrapManager(); - virtual ~CXTrapManager(); - - bool LoadXTrapModule(); - bool LoadClientMapFile( unsigned int iMapIndex ); - - bool CreateClientSession( LPCHARACTER lpCharSession ); - void DestroyClientSession( LPCHARACTER lpCharSession ); - - bool Verify_CSStep1( LPCHARACTER lpCharSession, BYTE* pOutBufData ); - void Verify_CSStep3( LPCHARACTER lpCharSession, BYTE* pBufData ); -#ifdef __FreeBSD__ - static void MapReloadSignalHandler( int signal ); - - static void NotifyMapFileChanged( const std::string& fileName, eFileUpdatedOptions eUpdateOption ); -#endif - -private: - //pimpl`s idiom - struct sXTrapContext; - sXTrapContext* m_pImpl; - - struct sSessionInfo - { - sSessionInfo() - { - m_pCheckEvent = NULL; - memset(szSessionBuf, 0x00, sizeof(szSessionBuf) ); - memset(szPackBuf, 0x00, sizeof(szPackBuf) ); - } - - BYTE szSessionBuf[SESSION_BUF_LEN]; - BYTE szPackBuf[VERIFY_PACK_LEN]; - LPEVENT m_pCheckEvent; - }; - - typedef boost::unordered_map ClientSessionMap; - - ClientSessionMap m_mapClientSessions; - -}; - -#endif /* _XTRAP_MANAGER_H_ */ diff --git a/game/src/auction_manager.h b/game/src/auction_manager.h index 9b4a95a..598f3a8 100644 --- a/game/src/auction_manager.h +++ b/game/src/auction_manager.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include #define GRADE_LOW 30 @@ -55,11 +55,11 @@ public: private: - typedef boost::unordered_map TItemInfoMap; + typedef std::unordered_map TItemInfoMap; TItemInfoMap item_map; typedef std::map TItemMap; - typedef boost::unordered_map TPCMap; + typedef std::unordered_map TPCMap; TPCMap offer_map; @@ -83,11 +83,11 @@ public: class SaleBoard { private: - typedef boost::unordered_map TItemInfoMap; + typedef std::unordered_map TItemInfoMap; TItemInfoMap item_map; typedef std::map TItemMap; - typedef boost::unordered_map TPCMap; + typedef std::unordered_map TPCMap; TPCMap wisher_map; TPCMap seller_map; @@ -111,7 +111,7 @@ class WishBoard { private: typedef std::map TItemMap; - typedef boost::unordered_map TPCMap; + typedef std::unordered_map TPCMap; TPCMap wisher_map; public: @@ -130,7 +130,7 @@ class MyBidBoard private: typedef std::pair BidInfo; typedef std::map TItemMap; - typedef boost::unordered_map TMyBidBoard; + typedef std::unordered_map TMyBidBoard; // bidder_id°¡ key TMyBidBoard pc_map; @@ -153,7 +153,7 @@ public: class AuctionManager : public singleton { private : - typedef boost::unordered_map TItemMap; + typedef std::unordered_map TItemMap; TItemMap auction_item_map; // auction¿¡ µî·ÏµÈ Á¤º¸ Áß °¡°Ý, µîµî ¾ÆÀÌÅÛ Å×ÀÌºí¿¡ Æ÷ÇÔµÇÁö ¾Ê´Â Á¤º¸µéÀ» °ü¸®ÇÏ´Â °Íµé diff --git a/game/src/banword.h b/game/src/banword.h index 644a8d0..3c4d3f9 100644 --- a/game/src/banword.h +++ b/game/src/banword.h @@ -2,7 +2,7 @@ #ifndef BANWORD_MANAGER_H_ #define BANWORD_MANAGER_H_ -#include +#include class CBanwordManager : public singleton { @@ -16,7 +16,7 @@ class CBanwordManager : public singleton void ConvertString(char * c_pszString, size_t _len); protected: - typedef boost::unordered_map TBanwordHashmap; + typedef std::unordered_map TBanwordHashmap; TBanwordHashmap m_hashmap_words; }; diff --git a/game/src/char.cpp b/game/src/char.cpp index a7db90d..f659bf7 100644 --- a/game/src/char.cpp +++ b/game/src/char.cpp @@ -53,9 +53,7 @@ #include "gm.h" #include "map_location.h" #include "BlueDragon_Binder.h" -#include "HackShield.h" #include "skill_power.h" -#include "XTrapManager.h" #include "buff_on_attributes.h" #ifdef __PET_SYSTEM__ @@ -358,9 +356,6 @@ void CHARACTER::Initialize() m_dwLastGoldDropTime = 0; - m_HackShieldCheckEvent = NULL; - m_HackShieldCheckMode = false; - m_bIsLoadedAffect = false; cannot_dead = false; @@ -428,14 +423,6 @@ void CHARACTER::Destroy() if (GetRider()) GetRider()->ClearHorseInfo(); - if( IsPC() ) - { - if (isHackShieldEnable) - { - CHackShieldManager::instance().DeleteClientHandle(GetPlayerID()); - } - } - if (GetDesc()) { GetDesc()->BindCharacter(NULL); @@ -528,8 +515,6 @@ void CHARACTER::Destroy() event_cancel(&m_pkMiningEvent); // END_OF_MINING - StopHackShieldCheckCycle(); - for (itertype(m_mapMobSkillEvent) it = m_mapMobSkillEvent.begin(); it != m_mapMobSkillEvent.end(); ++it) { LPEVENT pkEvent = it->second; @@ -1407,8 +1392,6 @@ void CHARACTER::Disconnect(const char * c_pszReason) // BindDesc(NULL); } - CXTrapManager::instance().DestroyClientSession(this); - M2_DESTROY_CHARACTER(this); } @@ -3692,7 +3675,7 @@ void CHARACTER::ApplyPoint(BYTE bApplyType, int iVal) if (0 == iAdd) iChange = -iChange; - boost::unordered_map::iterator iter = m_SkillDamageBonus.find(bSkillVnum); + std::unordered_map::iterator iter = m_SkillDamageBonus.find(bSkillVnum); if (iter == m_SkillDamageBonus.end()) m_SkillDamageBonus.insert(std::make_pair(bSkillVnum, iChange)); diff --git a/game/src/char.h b/game/src/char.h index c1bf38a..bb03ba1 100644 --- a/game/src/char.h +++ b/game/src/char.h @@ -1,7 +1,7 @@ #ifndef __INC_METIN_II_CHAR_H__ #define __INC_METIN_II_CHAR_H__ -#include +#include #include #include "entity.h" @@ -455,7 +455,7 @@ struct TSkillUseInfo DWORD dwVID; bool isGrandMaster; - boost::unordered_map TargetVIDMap; + std::map TargetVIDMap; TSkillUseInfo() : iHitCount(0), iMaxHitCount(0), iSplashCount(0), dwNextSkillUsableTime(0), iRange(0), bUsed(false), @@ -1449,7 +1449,7 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider // protected: TPlayerSkill* m_pSkillLevels; - boost::unordered_map m_SkillDamageBonus; + std::unordered_map m_SkillDamageBonus; std::map m_SkillUseInfo; //////////////////////////////////////////////////////////////////////////////////////// @@ -1939,18 +1939,6 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider private: DWORD m_dwLastGoldDropTime; - public: - void StartHackShieldCheckCycle(int seconds); - void StopHackShieldCheckCycle(); - - bool GetHackShieldCheckMode() const { return m_HackShieldCheckMode; } - void SetHackShieldCheckMode(bool m) { m_HackShieldCheckMode = m; } - - LPEVENT m_HackShieldCheckEvent; - - private: - bool m_HackShieldCheckMode; - public: void AutoRecoveryItemProcess (const EAffectTypes); diff --git a/game/src/char_change_empire.cpp b/game/src/char_change_empire.cpp index 69ced20..59d25c1 100644 --- a/game/src/char_change_empire.cpp +++ b/game/src/char_change_empire.cpp @@ -32,7 +32,7 @@ int CHARACTER::ChangeEmpire(BYTE empire) "SELECT id, pid1, pid2, pid3, pid4 FROM player_index%s WHERE pid1=%u OR pid2=%u OR pid3=%u OR pid4=%u AND empire=%u", get_table_postfix(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetEmpire()); - std::auto_ptr msg(DBManager::instance().DirectQuery(szQuery)); + std::unique_ptr msg(DBManager::instance().DirectQuery(szQuery)); if (msg->Get()->uiNumRows == 0) { @@ -105,7 +105,7 @@ int CHARACTER::ChangeEmpire(BYTE empire) snprintf(szQuery, sizeof(szQuery), "UPDATE player_index%s SET empire=%u WHERE pid1=%u OR pid2=%u OR pid3=%u OR pid4=%u AND empire=%u", get_table_postfix(), empire, GetPlayerID(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetEmpire()); - std::auto_ptr msg(DBManager::instance().DirectQuery(szQuery)); + std::unique_ptr msg(DBManager::instance().DirectQuery(szQuery)); if (msg->Get()->uiAffectedRows > 0) { @@ -173,7 +173,7 @@ void CHARACTER::SetChangeEmpireCount() snprintf(szQuery, sizeof(szQuery), "UPDATE change_empire SET change_count=%d WHERE account_id=%u", count, dwAID); } - std::auto_ptr pmsg(DBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg(DBManager::instance().DirectQuery(szQuery)); } DWORD CHARACTER::GetAID() const diff --git a/game/src/char_hackshield.cpp b/game/src/char_hackshield.cpp deleted file mode 100644 index fb800ce..0000000 --- a/game/src/char_hackshield.cpp +++ /dev/null @@ -1,93 +0,0 @@ - -#include "stdafx.h" - -#include "char.h" - -#include "config.h" -#include "event.h" -#include "HackShield.h" -#include "log.h" -#include "desc.h" -#include "packet.h" - -EVENTINFO(hackshield_event_info) -{ - DynamicCharacterPtr CharPtr; -}; - -EVENTFUNC(hackshield_event) -{ - hackshield_event_info* info = dynamic_cast( event->info ); - - if ( info == NULL ) - { - sys_err( "hackshield_event> Null pointer" ); - return 0; - } - - LPCHARACTER ch = info->CharPtr; - - if (NULL == ch) - { - sys_err("HShield: character pointer is null"); - return 0; - } - - if (NULL == ch->GetDesc()) - { - sys_err("HShield: character has no descriptor"); - return 0; - } - - if (false == ch->GetHackShieldCheckMode()) - { - if (false == CHackShieldManager::instance().SendCheckPacket(ch)) - { - return 0; - } - else - { - ch->SetHackShieldCheckMode(true); - - return HackShield_CheckCycleTime; - } - } - - sys_log(0, "HShield: no response from Player(%u)", ch->GetPlayerID()); - - LogManager::instance().HackShieldLog(0, ch); - - ch->m_HackShieldCheckEvent = NULL; - - ch->GetDesc()->SetPhase(PHASE_CLOSE); - - return 0; -} - -void CHARACTER::StartHackShieldCheckCycle(int seconds) -{ - StopHackShieldCheckCycle(); - - if (false == isHackShieldEnable) - return; - - hackshield_event_info* info = AllocEventInfo(); - - info->CharPtr = this; - - m_HackShieldCheckEvent = event_create(hackshield_event, info, seconds); - - sys_log(0, "HShield: StartHackShieldCheckCycle %d", seconds); -} - -void CHARACTER::StopHackShieldCheckCycle() -{ - if (NULL != m_HackShieldCheckEvent) - { - event_cancel(&m_HackShieldCheckEvent); - m_HackShieldCheckEvent = NULL; - - sys_log(0, "HShield: StopHackShieldCheckCycle"); - } -} - diff --git a/game/src/char_manager.cpp b/game/src/char_manager.cpp index 001c164..478225b 100644 --- a/game/src/char_manager.cpp +++ b/game/src/char_manager.cpp @@ -15,7 +15,6 @@ #include "questmanager.h" #include "questlua.h" #include "locale_service.h" -#include "XTrapManager.h" #ifndef __GNUC__ #include @@ -713,15 +712,6 @@ void CHARACTER_MANAGER::Update(int iPulse) for (itertype(m_map_dwMobKillCount) it = m_map_dwMobKillCount.begin(); it != m_map_dwMobKillCount.end(); ++it) DBManager::instance().SendMoneyLog(MONEY_LOG_MONSTER_KILL, it->first, it->second); -#ifdef _USE_SERVER_KEY_ - extern bool Metin2Server_IsInvalid(); - extern bool g_bShutdown; - if (Metin2Server_IsInvalid()) - { - g_bShutdown = true; - } -#endif - m_map_dwMobKillCount.clear(); } diff --git a/game/src/char_manager.h b/game/src/char_manager.h index 8609ff9..e1b72b1 100644 --- a/game/src/char_manager.h +++ b/game/src/char_manager.h @@ -17,7 +17,7 @@ class CharacterVectorInteractor; class CHARACTER_MANAGER : public singleton { public: - typedef TR1_NS::unordered_map NAME_MAP; + typedef std::unordered_map NAME_MAP; CHARACTER_MANAGER(); virtual ~CHARACTER_MANAGER(); @@ -119,8 +119,8 @@ class CHARACTER_MANAGER : public singleton int m_iUserDamageRatePremium; int m_iVIDCount; - TR1_NS::unordered_map m_map_pkChrByVID; - TR1_NS::unordered_map m_map_pkChrByPID; + std::unordered_map m_map_pkChrByVID; + std::unordered_map m_map_pkChrByPID; NAME_MAP m_map_pkPCChr; char dummy1[1024]; // memory barrier @@ -146,7 +146,7 @@ class CHARACTER_MANAGER : public singleton template Func CHARACTER_MANAGER::for_each_pc(Func f) { - TR1_NS::unordered_map::iterator it; + std::unordered_map::iterator it; for (it = m_map_pkChrByPID.begin(); it != m_map_pkChrByPID.end(); ++it) f(it->second); diff --git a/game/src/char_skill.cpp b/game/src/char_skill.cpp index 0efdb2e..d92e231 100644 --- a/game/src/char_skill.cpp +++ b/game/src/char_skill.cpp @@ -3556,7 +3556,7 @@ bool CHARACTER::CheckSkillHitCount(const BYTE SkillID, const VID TargetVID) return false; } - boost::unordered_map::iterator iterTargetMap = rSkillUseInfo.TargetVIDMap.find(TargetVID); + auto iterTargetMap = rSkillUseInfo.TargetVIDMap.find(TargetVID); if (rSkillUseInfo.TargetVIDMap.end() != iterTargetMap) { diff --git a/game/src/check_server.cpp b/game/src/check_server.cpp deleted file mode 100644 index 0b4698f..0000000 --- a/game/src/check_server.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "check_server.h" - -std::vector CheckServer::keys_; -bool CheckServer::fail_ = true; diff --git a/game/src/check_server.h b/game/src/check_server.h deleted file mode 100644 index 4cd7b51..0000000 --- a/game/src/check_server.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef _M2_CHECK_SERVER_KEY_H_ -#define _M2_CHECK_SERVER_KEY_H_ - -#include -#include -#include "CheckServerKey.h" - -class CheckServer -{ -public: - static FORCEINLINE void AddServerKey(const char* serverKey) - { - keys_.push_back(serverKey); - } - - static FORCEINLINE bool CheckIp(const char* ip) - { - // µðÆÄÀÎ ¾È°É¸®¸é üũ ¾ÈÇÔ - #ifndef _USE_SERVER_KEY_ - fail_ = false; - return true; - #endif - - for (int i = 0; i < keys_.size(); i++) - { - // Çϳª¶óµµ ¸Â´Â ¼­¹öÅ°°¡ ÀÖÀ¸¸é ok - std::string errorString; - if (CheckServerKey(keys_[i].c_str(), ip, "", errorString)) - { - fail_ = false; - break; - } - } - - return !IsFail(); - } - - static FORCEINLINE bool IsFail() - { - return fail_; - } - -private: - static std::vector keys_; - static bool fail_; -}; - -#endif // #ifndef _M2_CHECK_SERVER_KEY_H_ diff --git a/game/src/cipher.cpp b/game/src/cipher.cpp index a57ddd4..9e3e776 100644 --- a/game/src/cipher.cpp +++ b/game/src/cipher.cpp @@ -29,7 +29,6 @@ #include #include #include -#include using namespace CryptoPP; @@ -192,8 +191,8 @@ bool Cipher::SetUp(bool polarity) { BlockCipherAlgorithm* detail_1 = BlockCipherAlgorithm::Pick(hint_1); assert(detail_0 != NULL); assert(detail_1 != NULL); - std::auto_ptr algorithm_0(detail_0); - std::auto_ptr algorithm_1(detail_1); + std::unique_ptr algorithm_0(detail_0); + std::unique_ptr algorithm_1(detail_1); const size_t key_length_0 = algorithm_0->GetDefaultKeyLength(); const size_t iv_length_0 = algorithm_0->GetBlockSize(); diff --git a/game/src/cipher.h b/game/src/cipher.h index 9230dcf..ac08054 100644 --- a/game/src/cipher.h +++ b/game/src/cipher.h @@ -28,7 +28,7 @@ class Cipher { if (!activated_) { return; } - encoder_->ProcessData((byte*)buffer, (const byte*)buffer, length); + encoder_->ProcessData((CryptoPP::byte*)buffer, (const CryptoPP::byte*)buffer, length); } // Decrypts the given block of data. (no padding required) void Decrypt(void* buffer, size_t length) { @@ -36,7 +36,7 @@ class Cipher { if (!activated_) { return; } - decoder_->ProcessData((byte*)buffer, (const byte*)buffer, length); + decoder_->ProcessData((CryptoPP::byte*)buffer, (const CryptoPP::byte*)buffer, length); } bool activated() const { return activated_; } diff --git a/game/src/cmd_gm.cpp b/game/src/cmd_gm.cpp index e67bfb3..b41d14f 100644 --- a/game/src/cmd_gm.cpp +++ b/game/src/cmd_gm.cpp @@ -974,17 +974,17 @@ ACMD(do_state) snprintf(buf, sizeof(buf), "%s's State: ", tch->GetName()); if (tch->IsPosition(POS_FIGHTING)) - strlcat(buf, "Battle", sizeof(buf)); + strncat(buf, "Battle", sizeof(buf)); else if (tch->IsPosition(POS_DEAD)) - strlcat(buf, "Dead", sizeof(buf)); + strncat(buf, "Dead", sizeof(buf)); else - strlcat(buf, "Standing", sizeof(buf)); + strncat(buf, "Standing", sizeof(buf)); if (ch->GetShop()) - strlcat(buf, ", Shop", sizeof(buf)); + strncat(buf, ", Shop", sizeof(buf)); if (ch->GetExchange()) - strlcat(buf, ", Exchange", sizeof(buf)); + strncat(buf, ", Exchange", sizeof(buf)); ch->ChatPacket(CHAT_TYPE_INFO, "%s", buf); diff --git a/game/src/config.cpp b/game/src/config.cpp index ae56716..00ac9d0 100644 --- a/game/src/config.cpp +++ b/game/src/config.cpp @@ -19,7 +19,6 @@ #include "dev_log.h" #include "db.h" #include "skill_power.h" -#include "check_server.h" using std::string; @@ -121,12 +120,6 @@ bool LoadClientVersion(); bool g_protectNormalPlayer = false; // ¹ü¹ýÀÚ°¡ "ÆòÈ­¸ðµå" ÀÎ ÀϹÝÀ¯Àú¸¦ °ø°ÝÇÏÁö ¸øÇÔ bool g_noticeBattleZone = false; // Á߸³Áö´ë¿¡ ÀÔÀåÇÏ¸é ¾È³»¸Þ¼¼Áö¸¦ ¾Ë·ÁÁÜ -bool isHackShieldEnable = false; -int HackShield_FirstCheckWaitTime = passes_per_sec * 30; -int HackShield_CheckCycleTime = passes_per_sec * 180; - -bool bXTrapEnabled = false; - int gPlayerMaxLevel = 99; bool g_BlockCharCreation = false; @@ -560,7 +553,7 @@ void config_init(const string& st_localeServiceName) char szQuery[512]; snprintf(szQuery, sizeof(szQuery), "SELECT mKey, mValue FROM locale"); - std::auto_ptr pMsg(AccountDB::instance().DirectQuery(szQuery)); + std::unique_ptr pMsg(AccountDB::instance().DirectQuery(szQuery)); if (pMsg->Get()->uiNumRows == 0) { @@ -625,7 +618,7 @@ void config_init(const string& st_localeServiceName) { char szQuery[256]; snprintf(szQuery, sizeof(szQuery), "SELECT mValue FROM locale WHERE mKey='SKILL_POWER_BY_LEVEL'"); - std::auto_ptr pMsg(AccountDB::instance().DirectQuery(szQuery)); + std::unique_ptr pMsg(AccountDB::instance().DirectQuery(szQuery)); if (pMsg->Get()->uiNumRows == 0) { @@ -666,7 +659,7 @@ void config_init(const string& st_localeServiceName) for (int job = 0; job < JOB_MAX_NUM * 2; ++job) { snprintf(szQuery, sizeof(szQuery), "SELECT mValue from locale where mKey='SKILL_POWER_BY_LEVEL_TYPE%d' ORDER BY CAST(mValue AS unsigned)", job); - std::auto_ptr pMsg(AccountDB::instance().DirectQuery(szQuery)); + std::unique_ptr pMsg(AccountDB::instance().DirectQuery(szQuery)); // ¼¼ÆÃÀÌ ¾ÈµÇ¾îÀÖÀ¸¸é ±âº»Å×À̺íÀ» »ç¿ëÇÑ´Ù. if (pMsg->Get()->uiNumRows == 0) @@ -1052,46 +1045,6 @@ void config_init(const string& st_localeServiceName) str_to_number(g_noticeBattleZone, value_string); } - TOKEN("hackshield_enable") - { - int flag = 0; - - str_to_number(flag, value_string); - - //if (1 == flag && LC_IsEurope() ) - if (1 == flag) - { - isHackShieldEnable = true; - } - } - - TOKEN("hackshield_first_check_time") - { - int secs = 30; - str_to_number(secs, value_string); - - HackShield_FirstCheckWaitTime = passes_per_sec * secs; - } - - TOKEN("hackshield_check_cycle_time") - { - int secs = 180; - str_to_number(secs, value_string); - - HackShield_CheckCycleTime = passes_per_sec * secs; - } - - TOKEN("xtrap_enable") - { - int flag = 0; - str_to_number(flag, value_string); - - if (1 == flag ) - { - bXTrapEnabled = true; - } - } - TOKEN("pk_protect_level") { str_to_number(PK_PROTECT_LEVEL, value_string); @@ -1120,12 +1073,6 @@ void config_init(const string& st_localeServiceName) continue; } - - TOKEN("server_key") - { - CheckServer::AddServerKey(value_string); - continue; - } } if (g_setQuestObjectDir.empty()) diff --git a/game/src/config.h b/game/src/config.h index d8c3242..8d2f635 100644 --- a/game/src/config.h +++ b/game/src/config.h @@ -107,11 +107,6 @@ extern bool g_noticeBattleZone; // extern DWORD g_GoldDropTimeLimitValue; -extern bool isHackShieldEnable; -extern int HackShield_FirstCheckWaitTime; -extern int HackShield_CheckCycleTime; -extern bool bXTrapEnabled; - extern int gPlayerMaxLevel; extern bool g_BlockCharCreation; diff --git a/game/src/cube.cpp b/game/src/cube.cpp index abc5066..baf3904 100644 --- a/game/src/cube.cpp +++ b/game/src/cube.cpp @@ -78,8 +78,8 @@ struct SItemNameAndLevel // ÀڷᱸÁ¶³ª ÀÌ·±°Å º´½ÅÀ롂 ÀÌÇØÁ»... ´©±¸¶«¿¡ ¿µÈ¥ÀÌ ¾ø´Â »óÅ¿¡¼­ ¸¸µé¾ú¾¸ typedef std::vector TCubeResultList; -typedef boost::unordered_map TCubeMapByNPC; // °¢°¢ÀÇ NPCº°·Î ¾î¶² °É ¸¸µé ¼ö ÀÖ°í Àç·á°¡ ¹ºÁö... -typedef boost::unordered_map TCubeResultInfoTextByNPC; // °¢°¢ÀÇ NPCº°·Î ¸¸µé ¼ö ÀÖ´Â ¸ñ·ÏÀ» Á¤ÇØÁø Æ÷¸ËÀ¸·Î Á¤¸®ÇÑ Á¤º¸ +typedef std::unordered_map TCubeMapByNPC; // °¢°¢ÀÇ NPCº°·Î ¾î¶² °É ¸¸µé ¼ö ÀÖ°í Àç·á°¡ ¹ºÁö... +typedef std::unordered_map TCubeResultInfoTextByNPC; // °¢°¢ÀÇ NPCº°·Î ¸¸µé ¼ö ÀÖ´Â ¸ñ·ÏÀ» Á¤ÇØÁø Æ÷¸ËÀ¸·Î Á¤¸®ÇÑ Á¤º¸ TCubeMapByNPC cube_info_map; TCubeResultInfoTextByNPC cube_result_info_map_by_npc; // ³×ÀÌ¹Ö Á¸³ª º´½Å°°´Ù ¤»¤»¤» diff --git a/game/src/db.cpp b/game/src/db.cpp index 7cdc68f..8e4dcdb 100644 --- a/game/src/db.cpp +++ b/game/src/db.cpp @@ -872,7 +872,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg) char szQuery[1024]; snprintf(szQuery, sizeof(szQuery), "UPDATE account SET last_play=NOW() WHERE id=%u", dwID); - std::auto_ptr msg( DBManager::instance().DirectQuery(szQuery) ); + std::unique_ptr msg( DBManager::instance().DirectQuery(szQuery) ); } TAccountTable & r = d->GetAccountTable(); @@ -1104,7 +1104,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg) char szQuery[1024]; snprintf(szQuery, sizeof(szQuery), "UPDATE account SET last_play=NOW() WHERE id=%u", dwID); - std::auto_ptr msg( DBManager::instance().DirectQuery(szQuery) ); + std::unique_ptr msg( DBManager::instance().DirectQuery(szQuery) ); } TAccountTable & r = d->GetAccountTable(); diff --git a/game/src/debug_allocator_adapter.h b/game/src/debug_allocator_adapter.h index d554e5f..18ee6f9 100644 --- a/game/src/debug_allocator_adapter.h +++ b/game/src/debug_allocator_adapter.h @@ -12,13 +12,8 @@ #include #include -#ifdef __GNUC__ -#include -#define TR1_NS std::tr1 -#else -#include -#define TR1_NS boost -#endif +#include +#define std std #define DBGALLOC_LOG_FILENAME "dbgalloc.log" #define DBGALLOC_REPORT_FILENAME "dbgalloc_report.log" @@ -308,7 +303,7 @@ private: } #endif - typedef TR1_NS::unordered_map AllocMapType; + typedef std::unordered_map AllocMapType; Detail detail_; AllocMapType alloc_map_; diff --git a/game/src/desc.cpp b/game/src/desc.cpp index 90310b4..98ae5d7 100644 --- a/game/src/desc.cpp +++ b/game/src/desc.cpp @@ -16,7 +16,6 @@ #include "guild_manager.h" #include "TrafficProfiler.h" #include "locale_service.h" -#include "HackShield.h" #include "log.h" extern int max_bytes_written; @@ -94,7 +93,6 @@ void DESC::Initialize() m_bCRCMagicCubeIdx = 0; m_dwProcCRC = 0; m_dwFileCRC = 0; - m_bHackCRCQuery = 0; m_dwBillingExpireSecond = 0; @@ -199,16 +197,6 @@ EVENTFUNC(ping_event) desc->SetPong(false); } -#ifdef ENABLE_LIMIT_TIME - if ((unsigned)get_global_time() >= GLOBAL_LIMIT_TIME) - { - extern void ClearAdminPages(); - ClearAdminPages(); - extern g_bShutdown; - g_bShutdown = true; - } -#endif - desc->SendHandshake(get_dword_time(), 0); return (ping_event_second_cycle); diff --git a/game/src/desc.h b/game/src/desc.h index ca0bb5c..3664bb5 100644 --- a/game/src/desc.h +++ b/game/src/desc.h @@ -247,7 +247,6 @@ class DESC BYTE m_bCRCMagicCubeIdx; DWORD m_dwProcCRC; DWORD m_dwFileCRC; - bool m_bHackCRCQuery; DWORD m_dwBillingExpireSecond; std::string m_stClientVersion; diff --git a/game/src/desc_manager.h b/game/src/desc_manager.h index 6ad0f2c..7048c71 100644 --- a/game/src/desc_manager.h +++ b/game/src/desc_manager.h @@ -1,7 +1,7 @@ #ifndef __INC_METIN_II_GAME_DESC_MANAGER_H__ #define __INC_METIN_II_GAME_DESC_MANAGER_H__ -#include +#include #include #include @@ -13,12 +13,12 @@ class CClientPackageCryptInfo; class DESC_MANAGER : public singleton { public: - typedef TR1_NS::unordered_set DESC_SET; - typedef TR1_NS::unordered_set CLIENT_DESC_SET; + typedef std::unordered_set DESC_SET; + typedef std::unordered_set CLIENT_DESC_SET; typedef std::map DESC_HANDLE_MAP; typedef std::map DESC_HANDSHAKE_MAP; typedef std::map DESC_ACCOUNTID_MAP; - typedef boost::unordered_map DESC_LOGINNAME_MAP; + typedef std::unordered_map DESC_LOGINNAME_MAP; typedef std::map DESC_HANDLE_RANDOM_KEY_MAP; public: diff --git a/game/src/dungeon.h b/game/src/dungeon.h index 454db94..cf9dbbc 100644 --- a/game/src/dungeon.h +++ b/game/src/dungeon.h @@ -7,7 +7,7 @@ class CParty; class CDungeon { - typedef TR1_NS::unordered_map TPartyMap; + typedef std::unordered_map TPartyMap; typedef std::map TUniqueMobMap; public: diff --git a/game/src/entity.h b/game/src/entity.h index 1816e3b..93f8b89 100644 --- a/game/src/entity.h +++ b/game/src/entity.h @@ -6,7 +6,7 @@ class SECTREE; class CEntity { public: - typedef TR1_NS::unordered_map ENTITY_MAP; + typedef std::unordered_map ENTITY_MAP; public: CEntity(); diff --git a/game/src/fifo_allocator.h b/game/src/fifo_allocator.h index e689abf..1a6e806 100644 --- a/game/src/fifo_allocator.h +++ b/game/src/fifo_allocator.h @@ -5,10 +5,10 @@ #ifdef __GNUC__ #include -#define TR1_NS std::tr1 +#define std std::tr1 #else -#include -#define TR1_NS boost +#include +#define std boost #endif // Allocator implementation detail with simple FIFO grow-only pool. @@ -70,8 +70,8 @@ private: } typedef std::deque PoolType; - typedef TR1_NS::unordered_map PoolMapType; - typedef TR1_NS::unordered_map AllocMapType; + typedef std::unordered_map PoolMapType; + typedef std::unordered_map AllocMapType; static const size_t kWatermark = 4; // FIFO enforcement level diff --git a/game/src/guild.cpp b/game/src/guild.cpp index 34aebc5..735adba 100644 --- a/game/src/guild.cpp +++ b/game/src/guild.cpp @@ -72,7 +72,7 @@ CGuild::CGuild(TGuildCreateParameter & cp) m_data.grade_array[i].auth_flag = 0; } - std::auto_ptr pmsg (DBManager::instance().DirectQuery( + std::unique_ptr pmsg (DBManager::instance().DirectQuery( "INSERT INTO guild%s(name, master, sp, level, exp, skill_point, skill) " "VALUES('%s', %u, 1000, 1, 0, 0, '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0')", get_table_postfix(), m_data.name, m_data.master_pid)); @@ -1052,7 +1052,7 @@ void CGuild::RefreshCommentForce(DWORD player_id) return; } - std::auto_ptr pmsg (DBManager::instance().DirectQuery("SELECT id, name, content FROM guild_comment%s WHERE guild_id = %u ORDER BY notice DESC, id DESC LIMIT %d", get_table_postfix(), m_data.guild_id, GUILD_COMMENT_MAX_COUNT)); + std::unique_ptr pmsg (DBManager::instance().DirectQuery("SELECT id, name, content FROM guild_comment%s WHERE guild_id = %u ORDER BY notice DESC, id DESC LIMIT %d", get_table_postfix(), m_data.guild_id, GUILD_COMMENT_MAX_COUNT)); TPacketGCGuild pack; pack.header = HEADER_GC_GUILD; @@ -2090,7 +2090,7 @@ CGuild::GuildJoinErrCode CGuild::VerifyGuildJoinableCondition( const LPCHARACTER } else if ( LC_IsBrazil() == true ) { - std::auto_ptr pMsg( DBManager::instance().DirectQuery("SELECT value FROM guild_invite_limit WHERE id=%d", GetID()) ); + std::unique_ptr pMsg( DBManager::instance().DirectQuery("SELECT value FROM guild_invite_limit WHERE id=%d", GetID()) ); if ( pMsg->Get()->uiNumRows > 0 ) { diff --git a/game/src/guild_manager.cpp b/game/src/guild_manager.cpp index 0ca3d7d..f2e5390 100644 --- a/game/src/guild_manager.cpp +++ b/game/src/guild_manager.cpp @@ -81,7 +81,7 @@ DWORD CGuildManager::CreateGuild(TGuildCreateParameter& gcp) return 0; } - std::auto_ptr pmsg(DBManager::instance().DirectQuery("SELECT COUNT(*) FROM guild%s WHERE name = '%s'", + std::unique_ptr pmsg(DBManager::instance().DirectQuery("SELECT COUNT(*) FROM guild%s WHERE name = '%s'", get_table_postfix(), gcp.name)); if (pmsg->Get()->uiNumRows > 0) @@ -205,7 +205,7 @@ void CGuildManager::Initialize() return; } - std::auto_ptr pmsg(DBManager::instance().DirectQuery("SELECT id FROM guild%s", get_table_postfix())); + std::unique_ptr pmsg(DBManager::instance().DirectQuery("SELECT id FROM guild%s", get_table_postfix())); std::vector vecGuildID; vecGuildID.reserve(pmsg->Get()->uiNumRows); diff --git a/game/src/input.cpp b/game/src/input.cpp index 0274c9a..1b2ea1a 100644 --- a/game/src/input.cpp +++ b/game/src/input.cpp @@ -17,11 +17,6 @@ #include "priv_manager.h" #include "castle.h" #include "dev_log.h" -#include "HackShield_Impl.h" - -#ifndef __WIN32__ - #include "limit_time.h" -#endif extern time_t get_global_time(); extern bool g_bNoPasspod; @@ -180,17 +175,6 @@ bool CInputProcessor::Process(LPDESC lpDesc, const void * c_pvOrig, int iBytes, void CInputProcessor::Pong(LPDESC d) { d->SetPong(true); - - extern bool Metin2Server_IsInvalid(); - -#ifdef ENABLE_LIMIT_TIME - if (Metin2Server_IsInvalid()) - { - extern bool g_bShutdown; - g_bShutdown = true; - ClearAdminPages(); - } -#endif } void CInputProcessor::Handshake(LPDESC d, const char * c_pData) diff --git a/game/src/input.h b/game/src/input.h index 0372a8e..89af4c1 100644 --- a/game/src/input.h +++ b/game/src/input.h @@ -152,7 +152,6 @@ class CInputMain : public CInputProcessor void Fishing(LPCHARACTER ch, const char* c_pData); void ItemGive(LPCHARACTER ch, const char* c_pData); - void Hack(LPCHARACTER ch, const char * c_pData); int MyShop(LPCHARACTER ch, const char * c_pData, size_t uiBytes); void Refine(LPCHARACTER ch, const char* c_pData); diff --git a/game/src/input_auth.cpp b/game/src/input_auth.cpp index e7687cd..a03e595 100644 --- a/game/src/input_auth.cpp +++ b/game/src/input_auth.cpp @@ -11,10 +11,6 @@ #include "auth_brazil.h" #include "db.h" -#ifndef __WIN32__ - #include "limit_time.h" -#endif - extern time_t get_global_time(); extern int openid_server; @@ -109,17 +105,6 @@ CInputAuth::CInputAuth() void CInputAuth::Login(LPDESC d, const char * c_pData) { - extern bool Metin2Server_IsInvalid(); - -#ifdef ENABLE_LIMIT_TIME - if (Metin2Server_IsInvalid()) - { - extern void ClearAdminPages(); - ClearAdminPages(); - exit(1); - return; - } -#endif TPacketCGLogin3 * pinfo = (TPacketCGLogin3 *) c_pData; if (!g_bAuthServer) @@ -240,17 +225,6 @@ void CInputAuth::Login(LPDESC d, const char * c_pData) void CInputAuth::LoginOpenID(LPDESC d, const char * c_pData) { - extern bool Metin2Server_IsInvalid(); - -#ifdef ENABLE_LIMIT_TIME - if (Metin2Server_IsInvalid()) - { - extern void ClearAdminPages(); - ClearAdminPages(); - exit(1); - return; - } -#endif //OpenID test code. TPacketCGLogin5 *tempInfo1 = (TPacketCGLogin5 *)c_pData; diff --git a/game/src/input_db.cpp b/game/src/input_db.cpp index ab6c130..4b95d04 100644 --- a/game/src/input_db.cpp +++ b/game/src/input_db.cpp @@ -44,8 +44,6 @@ #include "gm.h" #include "panama.h" #include "map_location.h" -#include "HackShield.h" -#include "XTrapManager.h" #include "DragonSoul.h" @@ -477,20 +475,6 @@ void CInputDB::PlayerLoad(LPDESC d, const char * data) ch->GetGMLevel()); ch->QuerySafeboxSize(); - - if (isHackShieldEnable) - { - if (! CHackShieldManager::instance().CreateClientHandle(ch->GetPlayerID())) - { - d->SetPhase(PHASE_CLOSE); - } - else - { - ch->StartHackShieldCheckCycle( HackShield_CheckCycleTime ); - } - } - - CXTrapManager::instance().CreateClientSession( ch ); } void CInputDB::Boot(const char* data) @@ -1995,7 +1979,7 @@ void CInputDB::VCard(const char * c_pData) sys_log(0, "VCARD: %u %s %s %s %s", p->dwID, p->szSellCharacter, p->szSellAccount, p->szBuyCharacter, p->szBuyAccount); - std::auto_ptr pmsg(DBManager::instance().DirectQuery("SELECT sell_account, buy_account, time FROM vcard WHERE id=%u", p->dwID)); + std::unique_ptr pmsg(DBManager::instance().DirectQuery("SELECT sell_account, buy_account, time FROM vcard WHERE id=%u", p->dwID)); if (pmsg->Get()->uiNumRows != 1) { sys_log(0, "VCARD_FAIL: no data"); @@ -2025,7 +2009,7 @@ void CInputDB::VCard(const char * c_pData) return; } - std::auto_ptr pmsg1(DBManager::instance().DirectQuery("UPDATE GameTime SET LimitTime=LimitTime+%d WHERE UserID='%s'", time, p->szBuyAccount)); + std::unique_ptr pmsg1(DBManager::instance().DirectQuery("UPDATE GameTime SET LimitTime=LimitTime+%d WHERE UserID='%s'", time, p->szBuyAccount)); if (pmsg1->Get()->uiAffectedRows == 0 || pmsg1->Get()->uiAffectedRows == (uint32_t)-1) { @@ -2033,7 +2017,7 @@ void CInputDB::VCard(const char * c_pData) return; } - std::auto_ptr pmsg2(DBManager::instance().DirectQuery("UPDATE vcard,GameTime SET sell_pid='%s', buy_pid='%s', buy_account='%s', sell_time=NOW(), new_time=GameTime.LimitTime WHERE vcard.id=%u AND GameTime.UserID='%s'", p->szSellCharacter, p->szBuyCharacter, p->szBuyAccount, p->dwID, p->szBuyAccount)); + std::unique_ptr pmsg2(DBManager::instance().DirectQuery("UPDATE vcard,GameTime SET sell_pid='%s', buy_pid='%s', buy_account='%s', sell_time=NOW(), new_time=GameTime.LimitTime WHERE vcard.id=%u AND GameTime.UserID='%s'", p->szSellCharacter, p->szBuyCharacter, p->szBuyAccount, p->dwID, p->szBuyAccount)); if (pmsg2->Get()->uiAffectedRows == 0 || pmsg2->Get()->uiAffectedRows == (uint32_t)-1) { @@ -2671,11 +2655,6 @@ void CInputDB::DetailLog(const TPacketNeedLoginLogInfo* info) if (NULL != pChar) { LogManager::instance().DetailLoginLog(true, pChar); - - if (isHackShieldEnable) - { - pChar->StartHackShieldCheckCycle( HackShield_FirstCheckWaitTime ); - } } } } diff --git a/game/src/input_login.cpp b/game/src/input_login.cpp index 20d3b60..beb0259 100644 --- a/game/src/input_login.cpp +++ b/game/src/input_login.cpp @@ -30,8 +30,6 @@ #include "log.h" #include "horsename_manager.h" #include "MarkManager.h" -#include "HackShield.h" -#include "XTrapManager.h" static void _send_bonus_info(LPCHARACTER ch) { @@ -1083,9 +1081,6 @@ int CInputLogin::Analyze(LPDESC d, BYTE bHeader, const char * c_pData) break; ///////////////////////////////////// - case HEADER_CG_HACK: - break; - case HEADER_CG_CHANGE_NAME: ChangeName(d, c_pData); break; @@ -1098,20 +1093,6 @@ int CInputLogin::Analyze(LPDESC d, BYTE bHeader, const char * c_pData) Version(d->GetCharacter(), c_pData); break; - case HEADER_CG_HS_ACK: - if (isHackShieldEnable) - { - CHackShieldManager::instance().VerifyAck(d->GetCharacter(), c_pData); - } - break; - - case HEADER_CG_XTRAP_ACK: - { - TPacketXTrapCSVerify* p = reinterpret_cast((void*)c_pData); - CXTrapManager::instance().Verify_CSStep3(d->GetCharacter(), p->bPacketData); - } - break; - default: sys_err("login phase does not handle this packet! header %d", bHeader); //d->SetPhase(PHASE_CLOSE); diff --git a/game/src/input_main.cpp b/game/src/input_main.cpp index 0ebe0d9..e502646 100644 --- a/game/src/input_main.cpp +++ b/game/src/input_main.cpp @@ -38,8 +38,6 @@ #include "motion.h" #include "OXEvent.h" #include "locale_service.h" -#include "HackShield.h" -#include "XTrapManager.h" #include "DragonSoul.h" extern void SendShout(const char * szText, BYTE bEmpire); @@ -88,7 +86,7 @@ EVENTINFO(spam_event_info) } }; -typedef boost::unordered_map > spam_score_of_ip_t; +typedef std::unordered_map > spam_score_of_ip_t; spam_score_of_ip_t spam_score_of_ip; EVENTFUNC(block_chat_by_ip_event) @@ -567,12 +565,9 @@ struct FEmpireChatPacket else { // »ç¶÷¸¶´Ù ½ºÅ³·¹º§ÀÌ ´Ù¸£´Ï ¸Å¹ø ÇؾßÇÕ´Ï´Ù - size_t len = strncpy(converted_msg, orig_msg, sizeof(converted_msg)); + strncpy(converted_msg, orig_msg, sizeof(converted_msg)); - if (len >= sizeof(converted_msg)) - len = sizeof(converted_msg) - 1; - - ConvertEmpireText(bEmpire, converted_msg + namelen, len - namelen, 10 + 2 * d->GetCharacter()->GetSkillPower(SKILL_LANGUAGE1 + bEmpire - 1)); + ConvertEmpireText(bEmpire, converted_msg + namelen, sizeof(converted_msg) - namelen, 10 + 2 * d->GetCharacter()->GetSkillPower(SKILL_LANGUAGE1 + bEmpire - 1)); d->Packet(converted_msg, orig_len); } } @@ -2913,19 +2908,6 @@ void CInputMain::ItemGive(LPCHARACTER ch, const char* c_pData) ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¾ÆÀÌÅÛÀ» °Ç³×ÁÙ ¼ö ¾ø½À´Ï´Ù.")); } -void CInputMain::Hack(LPCHARACTER ch, const char * c_pData) -{ - TPacketCGHack * p = (TPacketCGHack *) c_pData; - - char buf[sizeof(p->szBuf)]; - strncpy(buf, p->szBuf, sizeof(buf)); - - sys_err("HACK_DETECT: %s %s", ch->GetName(), buf); - - // ÇöÀç Ŭ¶óÀ̾ðÆ®¿¡¼­ ÀÌ ÆÐŶÀ» º¸³»´Â °æ¿ì°¡ ¾øÀ¸¹Ç·Î ¹«Á¶°Ç ²÷µµ·Ï ÇÑ´Ù - ch->GetDesc()->SetPhase(PHASE_CLOSE); -} - int CInputMain::MyShop(LPCHARACTER ch, const char * c_pData, size_t uiBytes) { TPacketCGMyShop * p = (TPacketCGMyShop *) c_pData; @@ -3276,10 +3258,6 @@ int CInputMain::Analyze(LPDESC d, BYTE bHeader, const char * c_pData) Fishing(ch, c_pData); break; - case HEADER_CG_HACK: - Hack(ch, c_pData); - break; - case HEADER_CG_MYSHOP: if ((iExtraLen = MyShop(ch, c_pData, m_iBufferLeft)) < 0) return -1; @@ -3293,19 +3271,6 @@ int CInputMain::Analyze(LPDESC d, BYTE bHeader, const char * c_pData) Version(ch, c_pData); break; - case HEADER_CG_HS_ACK: - if (isHackShieldEnable) - { - CHackShieldManager::instance().VerifyAck(d->GetCharacter(), c_pData); - } - break; - - case HEADER_CG_XTRAP_ACK: - { - TPacketXTrapCSVerify* p = reinterpret_cast((void*)c_pData); - CXTrapManager::instance().Verify_CSStep3(d->GetCharacter(), p->bPacketData); - } - break; case HEADER_CG_DRAGON_SOUL_REFINE: { TPacketCGDragonSoulRefine* p = reinterpret_cast ((void*)c_pData); @@ -3371,10 +3336,6 @@ int CInputDead::Analyze(LPDESC d, BYTE bHeader, const char * c_pData) break; - case HEADER_CG_HACK: - Hack(ch, c_pData); - break; - default: return (0); } diff --git a/game/src/item_manager.cpp b/game/src/item_manager.cpp index d2ef828..42c12f9 100644 --- a/game/src/item_manager.cpp +++ b/game/src/item_manager.cpp @@ -49,7 +49,7 @@ void ITEM_MANAGER::Destroy() void ITEM_MANAGER::GracefulShutdown() { - TR1_NS::unordered_set::iterator it = m_set_pkItemForDelayedSave.begin(); + std::unordered_set::iterator it = m_set_pkItemForDelayedSave.begin(); while (it != m_set_pkItemForDelayedSave.end()) SaveSingleItem(*(it++)); @@ -424,7 +424,7 @@ void ITEM_MANAGER::DelayedSave(LPITEM item) void ITEM_MANAGER::FlushDelayedSave(LPITEM item) { - TR1_NS::unordered_set::iterator it = m_set_pkItemForDelayedSave.find(item); + std::unordered_set::iterator it = m_set_pkItemForDelayedSave.find(item); if (it == m_set_pkItemForDelayedSave.end()) { @@ -469,8 +469,8 @@ void ITEM_MANAGER::SaveSingleItem(LPITEM item) void ITEM_MANAGER::Update() { - TR1_NS::unordered_set::iterator it = m_set_pkItemForDelayedSave.begin(); - TR1_NS::unordered_set::iterator this_it; + std::unordered_set::iterator it = m_set_pkItemForDelayedSave.begin(); + std::unordered_set::iterator this_it; while (it != m_set_pkItemForDelayedSave.end()) { @@ -540,7 +540,7 @@ void ITEM_MANAGER::DestroyItem(LPITEM item, const char* file, size_t line) } } - TR1_NS::unordered_set::iterator it = m_set_pkItemForDelayedSave.find(item); + std::unordered_set::iterator it = m_set_pkItemForDelayedSave.find(item); if (it != m_set_pkItemForDelayedSave.end()) m_set_pkItemForDelayedSave.erase(it); diff --git a/game/src/item_manager.h b/game/src/item_manager.h index 11806b2..8259209 100644 --- a/game/src/item_manager.h +++ b/game/src/item_manager.h @@ -427,7 +427,7 @@ class ITEM_MANAGER : public singleton TItemIDRangeTable m_ItemIDRange; TItemIDRangeTable m_ItemIDSpareRange; - TR1_NS::unordered_set m_set_pkItemForDelayedSave; + std::unordered_set m_set_pkItemForDelayedSave; std::map m_map_pkItemByID; std::map m_map_dwEtcItemDropProb; std::map m_map_pkDropItemGroup; diff --git a/game/src/limit_time.h b/game/src/limit_time.h deleted file mode 100644 index 39c1e93..0000000 --- a/game/src/limit_time.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __LIMIT_TIME__ -#define __LIMIT_TIME__ - -#define ENABLE_LIMIT_TIME -#define GLOBAL_LIMIT_TIME 1409996783UL // Sat Sep 6 18:46:23 2014 -#define TIME_OVER_PONG_DOWN_RATE 50000 -#define TIME_OVER_LOGIN_DOWN_RATE 10000 -#endif diff --git a/game/src/log.h b/game/src/log.h index 14d9fab..47fdd3e 100644 --- a/game/src/log.h +++ b/game/src/log.h @@ -1,7 +1,7 @@ #ifndef __INC_LOG_MANAGER_H__ #define __INC_LOG_MANAGER_H__ -#include +#include #include "any_function.h" enum GOLDBAR_HOW diff --git a/game/src/lzo_manager.h b/game/src/lzo_manager.h index 662f430..fd40d6d 100644 --- a/game/src/lzo_manager.h +++ b/game/src/lzo_manager.h @@ -1,7 +1,7 @@ #ifndef __INC_LZO_MANAGER_H #define __INC_LZO_MANAGER_H -#include "minilzo.h" +#include class LZOManager : public singleton { diff --git a/game/src/main.cpp b/game/src/main.cpp index 8c46d54..2f7ef92 100644 --- a/game/src/main.cpp +++ b/game/src/main.cpp @@ -2,7 +2,6 @@ #include "constants.h" #include "config.h" #include "event.h" -#include "minilzo.h" #include "packet.h" #include "desc_manager.h" #include "item_manager.h" @@ -58,21 +57,10 @@ #include "threeway_war.h" #include "auth_brazil.h" #include "DragonLair.h" -#include "HackShield.h" #include "skill_power.h" #include "SpeedServer.h" -#include "XTrapManager.h" #include "DragonSoul.h" #include -#ifndef __WIN32__ - #include "limit_time.h" -#endif - -//#define __FILEMONITOR__ - -#if defined (__FreeBSD__) && defined(__FILEMONITOR__) - #include "FileMonitor_FreeBSD.h" -#endif #ifdef __AUCTION__ #include "auction_manager.h" @@ -86,12 +74,6 @@ #include #endif -// À©µµ¿ì¿¡¼­ Å×½ºÆ®ÇÒ ¶§´Â Ç×»ó ¼­¹öÅ° üũ -#ifdef _WIN32 - //#define _USE_SERVER_KEY_ -#endif -#include "check_server.h" - extern void WriteVersion(); //extern const char * _malloc_options; #if defined(__FreeBSD__) && defined(DEBUG_ALLOC) @@ -250,13 +232,6 @@ void heartbeat(LPHEART ht, int pulse) // 1Ãʸ¶´Ù if (!(pulse % ht->passes_per_sec)) { -#ifdef ENABLE_LIMIT_TIME - if ((unsigned)get_global_time() >= GLOBAL_LIMIT_TIME) - { - g_bShutdown = true; - } -#endif - if (g_bAuthServer && LC_IsBrazil() && !test_server) auth_brazil_log(); @@ -316,14 +291,6 @@ void heartbeat(LPHEART ht, int pulse) if (!(pulse % (passes_per_sec + 4))) CHARACTER_MANAGER::instance().ProcessDelayedSave(); - //4ÃÊ ¸¶´Ù -#if defined (__FreeBSD__) && defined(__FILEMONITOR__) - if (!(pulse % (passes_per_sec * 5))) - { - FileMonitorFreeBSD::Instance().Update(pulse); - } -#endif - // ¾à 5.08Ãʸ¶´Ù if (!(pulse % (passes_per_sec * 5 + 2))) { @@ -357,87 +324,6 @@ void heartbeat(LPHEART ht, int pulse) } } -static bool g_isInvalidServer = false; - -bool Metin2Server_IsInvalid() -{ - return g_isInvalidServer; -} - -void Metin2Server_Check() -{ -#ifdef _SERVER_CHECK_ - -#ifdef _USE_SERVER_KEY_ - if (false == CheckServer::CheckIp(g_szPublicIP)) - { -#ifdef _WIN32 - fprintf(stderr, "check ip failed\n"); -#endif - g_isInvalidServer = true; - } - return; -#endif - - if (LC_IsEurope() || test_server) - return; - - - // ºê¶óÁú ip - if (strncmp (g_szPublicIP, "189.112.1", 9) == 0) - { - return; - } - - // ij³ª´Ù ip - if (strncmp (g_szPublicIP, "74.200.6", 8) == 0) - { - return; - } - - return; - - static const size_t CheckServerListSize = 1; - static const char* CheckServerList[] = { "202.31.178.251"}; - static const int CheckServerPort = 7120; - - socket_t sockConnector = INVALID_SOCKET; - - for (size_t i = 0 ; i < CheckServerListSize ; i++) - { - sockConnector = socket_connect( CheckServerList[i], CheckServerPort ); - - if (0 < sockConnector) - break; - } - - if (0 > sockConnector) - { - if (true != LC_IsEurope()) // À¯·´Àº Á¢¼ÓÀ» ÇÏÁö ¸øÇϸé ÀÎÁõµÈ °ÍÀ¸·Î °£ÁÖ - g_isInvalidServer = true; - - return; - } - - char buf[256] = { 0, }; - - socket_read(sockConnector, buf, sizeof(buf) - 1); - - sys_log(0, "recv[%s]", buf); - - if (strncmp(buf, "OK", 2) == 0) - g_isInvalidServer = false; - else if (strncmp(buf, "CK", 2) == 0) - g_isInvalidServer = true; - - socket_close(sockConnector); -#else - g_isInvalidServer = false; - return; -#endif - -} - static void CleanUpForEarlyExit() { CancelReloadSpamEvent(); } @@ -511,9 +397,6 @@ int main(int argc, char **argv) CThreeWayWar threeway_war; CDragonLairManager dl_manager; - CHackShieldManager HSManager; - CXTrapManager XTManager; - CSpeedServerManager SSManager; DSManager dsManager; @@ -545,53 +428,9 @@ int main(int argc, char **argv) ani_init(); PanamaLoad(); - Metin2Server_Check(); - -#if defined(_WIN32) && defined(_USE_SERVER_KEY_) - if (CheckServer::IsFail()) - { - return 1; - } -#endif - if ( g_bTrafficProfileOn ) TrafficProfiler::instance().Initialize( TRAFFIC_PROFILE_FLUSH_CYCLE, "ProfileLog" ); - //if game server - if (!g_bAuthServer) - { - //hackshield - if (isHackShieldEnable) - { - if (!HSManager.Initialize()) - { - fprintf(stderr, "Failed To Initialize HS"); - CleanUpForEarlyExit(); - return 0; - } - } - - //xtrap - if(bXTrapEnabled) - { - if (!XTManager.LoadXTrapModule()) - { - CleanUpForEarlyExit(); - return 0; - } -#if defined (__FreeBSD__) && defined(__FILEMONITOR__) - //PFN_FileChangeListener pNotifyFunc = boost::bind( &CXTrapManager::NotifyMapFileChanged, CXTrapManager::instance(), _1 ); - PFN_FileChangeListener pNotifyFunc = &(CXTrapManager::NotifyMapFileChanged); - - const std::string strMap1Name = "map1.CS3"; - const std::string strMap2Name = "map2.CS3"; - - FileMonitorFreeBSD::Instance().AddWatch( strMap1Name, pNotifyFunc ); - FileMonitorFreeBSD::Instance().AddWatch( strMap2Name, pNotifyFunc ); -#endif - } - } - // Client PackageCrypt //TODO : make it config @@ -601,11 +440,6 @@ int main(int argc, char **argv) sys_err("Failed to Load ClientPackageCryptInfo File(%s)", strPackageCryptInfoDir.c_str()); } -#if defined (__FreeBSD__) && defined(__FILEMONITOR__) - PFN_FileChangeListener pPackageNotifyFunc = &(DESC_MANAGER::NotifyClientPackageFileChanged); - //FileMonitorFreeBSD::Instance().AddWatch( strPackageCryptInfoName, pPackageNotifyFunc ); -#endif - while (idle()); sys_log(0, " Starting..."); @@ -666,15 +500,6 @@ int main(int argc, char **argv) sys_log(0, " Destroying building::CManager..."); building_manager.Destroy(); - if (!g_bAuthServer) - { - if (isHackShieldEnable) - { - sys_log(0, " Releasing HackShield manager..."); - HSManager.Release(); - } - } - sys_log(0, " Flushing TrafficProfiler..."); trafficProfiler.Flush(); @@ -708,12 +533,6 @@ int start(int argc, char **argv) #if defined(__FreeBSD__) && defined(DEBUG_ALLOC) _malloc_message = WriteMallocMessage; #endif -#ifdef ENABLE_LIMIT_TIME - if ((unsigned)get_global_time() >= GLOBAL_LIMIT_TIME) - { - return 0; - } -#endif while ((ch = getopt(argc, argv, "npverltI")) != -1) { @@ -726,8 +545,7 @@ int start(int argc, char **argv) printf("IP %s\n", g_szPublicIP); - optind++; - optreset = 1; + optind = 0; break; case 'p': // port @@ -741,8 +559,7 @@ int start(int argc, char **argv) printf("port %d\n", mother_port); - optind++; - optreset = 1; + optind = 0; break; case 'l': @@ -751,8 +568,7 @@ int start(int argc, char **argv) log_set_level(l); - optind++; - optreset = 1; + optind = 0; } break; @@ -761,8 +577,9 @@ int start(int argc, char **argv) { if (optind < argc) { - st_localeServiceName = argv[optind++]; - optreset = 1; + st_localeServiceName = argv[optind]; + + optind = 0; } } break; @@ -976,12 +793,6 @@ int idle() memset(&thecore_profiler[0], 0, sizeof(thecore_profiler)); memset(&s_dwProfiler[0], 0, sizeof(s_dwProfiler)); } -#ifdef _USE_SERVER_KEY_ - if (Metin2Server_IsInvalid() && 0 == (thecore_random() % 7146)) - { - return 0; // shutdown - } -#endif #ifdef __WIN32__ if (_kbhit()) { diff --git a/game/src/marriage.h b/game/src/marriage.h index 0bf3e33..08d48cb 100644 --- a/game/src/marriage.h +++ b/game/src/marriage.h @@ -129,7 +129,7 @@ namespace marriage Func for_each_wedding(Func f); private: - TR1_NS::unordered_set m_Marriages; + std::unordered_set m_Marriages; std::map m_MarriageByPID; std::set > m_setWedding; }; diff --git a/game/src/matrix_card.cpp b/game/src/matrix_card.cpp index 262747c..c65447c 100644 --- a/game/src/matrix_card.cpp +++ b/game/src/matrix_card.cpp @@ -42,7 +42,7 @@ bool EncodeMatrix(const char* szsrc, const char* szpwd, char* lpdes, const unsig char dc = sc ^ pc; char szhex[3]; snprintf(szhex, sizeof(szhex), "%02X", dc); - strlcat(lpdes, szhex, usize); + strncat(lpdes, szhex, usize); } return (i == nlen) ? true : false; @@ -148,7 +148,7 @@ void GetRightAnswer(const unsigned long rows, const unsigned long cols, const ch { char sztemp[3] = { 0, 0, 0 }; memcpy(sztemp, (char*)(pmatrix + (ROW(rows, i) * MAX_COLS + COL(cols, i))), 2); - strlcat(answer, sztemp, nsize); + strncat(answer, sztemp, nsize); } } diff --git a/game/src/minilzo.c b/game/src/minilzo.c deleted file mode 100644 index fd68650..0000000 --- a/game/src/minilzo.c +++ /dev/null @@ -1,2937 +0,0 @@ -/* minilzo.c -- mini subset of the LZO real-time data compression library - -This file is part of the LZO real-time data compression library. - -Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer -Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer -Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer -Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer -Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer -Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer -Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer -All Rights Reserved. - -The LZO library 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 2 of -the License, or (at your option) any later version. - -The LZO library 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 the LZO library; see the file COPYING. -If not, write to the Free Software Foundation, Inc., -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Markus F.X.J. Oberhumer - -http://www.oberhumer.com/opensource/lzo/ -*/ - -/* -* NOTE: -* the full LZO package can be found at -* http://www.oberhumer.com/opensource/lzo/ -*/ - -#define __LZO_IN_MINILZO -#define LZO_BUILD - -#ifdef MINILZO_HAVE_CONFIG_H -# include -#endif - -#undef LZO_HAVE_CONFIG_H -#include "minilzo.h" - -#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x1080) -# error "version mismatch in miniLZO source files" -#endif - -#ifdef MINILZO_HAVE_CONFIG_H -# define LZO_HAVE_CONFIG_H -#endif - -#if !defined(LZO_NO_SYS_TYPES_H) -# include -#endif -#include - -#ifndef __LZO_CONF_H -#define __LZO_CONF_H - -#if !defined(__LZO_IN_MINILZO) -# ifndef __LZOCONF_H -# include -# endif -#endif - -#if defined(__BOUNDS_CHECKING_ON) -# include -#else -# define BOUNDS_CHECKING_OFF_DURING(stmt) stmt -# define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) -#endif - -#if !defined(LZO_HAVE_CONFIG_H) -# include -# include -# if !defined(NO_STDLIB_H) -# include -# endif -# define HAVE_MEMCMP -# define HAVE_MEMCPY -# define HAVE_MEMMOVE -# define HAVE_MEMSET -#else -# include -# if defined(HAVE_STDDEF_H) -# include -# endif -# if defined(STDC_HEADERS) -# include -# include -# endif -#endif - -#if defined(__LZO_DOS16) || defined(__LZO_WIN16) -# define HAVE_MALLOC_H -# define HAVE_HALLOC -#endif - -#undef NDEBUG -#if !defined(LZO_DEBUG) -# define NDEBUG -#endif -#if defined(LZO_DEBUG) || !defined(NDEBUG) -# if !defined(NO_STDIO_H) -# include -# endif -#endif -#include - -#if !defined(LZO_COMPILE_TIME_ASSERT) -# define LZO_COMPILE_TIME_ASSERT(expr) \ - { typedef int __lzo_compile_time_assert_fail[1 - 2 * !(expr)]; } -#endif - -#if !defined(LZO_UNUSED) -# if 1 -# define LZO_UNUSED(var) ((void)&var) -# elif 0 -# define LZO_UNUSED(var) { typedef int __lzo_unused[sizeof(var) ? 2 : 1]; } -# else -# define LZO_UNUSED(parm) (parm = parm) -# endif -#endif - -#if !defined(__inline__) && !defined(__GNUC__) -# if defined(__cplusplus) -# define __inline__ inline -# else -# define __inline__ -# endif -#endif - -#if defined(NO_MEMCMP) -# undef HAVE_MEMCMP -#endif - -#if !defined(HAVE_MEMCMP) -# undef memcmp -# define memcmp lzo_memcmp -#endif -#if !defined(HAVE_MEMCPY) -# undef memcpy -# define memcpy lzo_memcpy -#endif -#if !defined(HAVE_MEMMOVE) -# undef memmove -# define memmove lzo_memmove -#endif -#if !defined(HAVE_MEMSET) -# undef memset -# define memset lzo_memset -#endif - -#if 0 -# define LZO_BYTE(x) ((unsigned char) (x)) -#else -# define LZO_BYTE(x) ((unsigned char) ((x) & 0xff)) -#endif - -#define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b)) -#define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b)) -#define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c)) -#define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c)) - -#define lzo_sizeof(type) ((lzo_uint) (sizeof(type))) - -#define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array)))) - -#define LZO_SIZE(bits) (1u << (bits)) -#define LZO_MASK(bits) (LZO_SIZE(bits) - 1) - -#define LZO_LSIZE(bits) (1ul << (bits)) -#define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1) - -#define LZO_USIZE(bits) ((lzo_uint) 1 << (bits)) -#define LZO_UMASK(bits) (LZO_USIZE(bits) - 1) - -#define LZO_STYPE_MAX(b) (((1l << (8*(b)-2)) - 1l) + (1l << (8*(b)-2))) -#define LZO_UTYPE_MAX(b) (((1ul << (8*(b)-1)) - 1ul) + (1ul << (8*(b)-1))) - -#if !defined(SIZEOF_UNSIGNED) -# if (UINT_MAX == 0xffff) -# define SIZEOF_UNSIGNED 2 -# elif (UINT_MAX == LZO_0xffffffffL) -# define SIZEOF_UNSIGNED 4 -# elif (UINT_MAX >= LZO_0xffffffffL) -# define SIZEOF_UNSIGNED 8 -# else -# error "SIZEOF_UNSIGNED" -# endif -#endif - -#if !defined(SIZEOF_UNSIGNED_LONG) -# if (ULONG_MAX == LZO_0xffffffffL) -# define SIZEOF_UNSIGNED_LONG 4 -# elif (ULONG_MAX >= LZO_0xffffffffL) -# define SIZEOF_UNSIGNED_LONG 8 -# else -# error "SIZEOF_UNSIGNED_LONG" -# endif -#endif - -#if !defined(SIZEOF_SIZE_T) -# define SIZEOF_SIZE_T SIZEOF_UNSIGNED -#endif -#if !defined(SIZE_T_MAX) -# define SIZE_T_MAX LZO_UTYPE_MAX(SIZEOF_SIZE_T) -#endif - -#if 1 && defined(__LZO_i386) && (UINT_MAX == LZO_0xffffffffL) -# if !defined(LZO_UNALIGNED_OK_2) && (USHRT_MAX == 0xffff) -# define LZO_UNALIGNED_OK_2 -# endif -# if !defined(LZO_UNALIGNED_OK_4) && (LZO_UINT32_MAX == LZO_0xffffffffL) -# define LZO_UNALIGNED_OK_4 -# endif -#endif - -#if defined(LZO_UNALIGNED_OK_2) || defined(LZO_UNALIGNED_OK_4) -# if !defined(LZO_UNALIGNED_OK) -# define LZO_UNALIGNED_OK -# endif -#endif - -#if defined(__LZO_NO_UNALIGNED) -# undef LZO_UNALIGNED_OK -# undef LZO_UNALIGNED_OK_2 -# undef LZO_UNALIGNED_OK_4 -#endif - -#if defined(LZO_UNALIGNED_OK_2) && (USHRT_MAX != 0xffff) -# error "LZO_UNALIGNED_OK_2 must not be defined on this system" -#endif -#if defined(LZO_UNALIGNED_OK_4) && (LZO_UINT32_MAX != LZO_0xffffffffL) -# error "LZO_UNALIGNED_OK_4 must not be defined on this system" -#endif - -#if defined(__LZO_NO_ALIGNED) -# undef LZO_ALIGNED_OK_4 -#endif - -#if defined(LZO_ALIGNED_OK_4) && (LZO_UINT32_MAX != LZO_0xffffffffL) -# error "LZO_ALIGNED_OK_4 must not be defined on this system" -#endif - -#define LZO_LITTLE_ENDIAN 1234 -#define LZO_BIG_ENDIAN 4321 -#define LZO_PDP_ENDIAN 3412 - -#if !defined(LZO_BYTE_ORDER) -# if defined(MFX_BYTE_ORDER) -# define LZO_BYTE_ORDER MFX_BYTE_ORDER -# elif defined(__LZO_i386) -# define LZO_BYTE_ORDER LZO_LITTLE_ENDIAN -# elif defined(BYTE_ORDER) -# define LZO_BYTE_ORDER BYTE_ORDER -# elif defined(__BYTE_ORDER) -# define LZO_BYTE_ORDER __BYTE_ORDER -# endif -#endif - -#if defined(LZO_BYTE_ORDER) -# if (LZO_BYTE_ORDER != LZO_LITTLE_ENDIAN) && \ - (LZO_BYTE_ORDER != LZO_BIG_ENDIAN) -# error "invalid LZO_BYTE_ORDER" -# endif -#endif - -#if defined(LZO_UNALIGNED_OK) && !defined(LZO_BYTE_ORDER) -# error "LZO_BYTE_ORDER is not defined" -#endif - -#define LZO_OPTIMIZE_GNUC_i386_IS_BUGGY - -#if defined(NDEBUG) && !defined(LZO_DEBUG) && !defined(__LZO_CHECKER) -# if defined(__GNUC__) && defined(__i386__) -# if !defined(LZO_OPTIMIZE_GNUC_i386_IS_BUGGY) -# define LZO_OPTIMIZE_GNUC_i386 -# endif -# endif -#endif - -__LZO_EXTERN_C int __lzo_init_done; -__LZO_EXTERN_C const lzo_byte __lzo_copyright[]; -LZO_EXTERN(const lzo_byte *) lzo_copyright(void); -__LZO_EXTERN_C const lzo_uint32 _lzo_crc32_table[256]; - -#define _LZO_STRINGIZE(x) #x -#define _LZO_MEXPAND(x) _LZO_STRINGIZE(x) - -#define _LZO_CONCAT2(a,b) a ## b -#define _LZO_CONCAT3(a,b,c) a ## b ## c -#define _LZO_CONCAT4(a,b,c,d) a ## b ## c ## d -#define _LZO_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e - -#define _LZO_ECONCAT2(a,b) _LZO_CONCAT2(a,b) -#define _LZO_ECONCAT3(a,b,c) _LZO_CONCAT3(a,b,c) -#define _LZO_ECONCAT4(a,b,c,d) _LZO_CONCAT4(a,b,c,d) -#define _LZO_ECONCAT5(a,b,c,d,e) _LZO_CONCAT5(a,b,c,d,e) - -#if 0 - -#define __LZO_IS_COMPRESS_QUERY(i,il,o,ol,w) ((lzo_voidp)(o) == (w)) -#define __LZO_QUERY_COMPRESS(i,il,o,ol,w,n,s) \ - (*ol = (n)*(s), LZO_E_OK) - -#define __LZO_IS_DECOMPRESS_QUERY(i,il,o,ol,w) ((lzo_voidp)(o) == (w)) -#define __LZO_QUERY_DECOMPRESS(i,il,o,ol,w,n,s) \ - (*ol = (n)*(s), LZO_E_OK) - -#define __LZO_IS_OPTIMIZE_QUERY(i,il,o,ol,w) ((lzo_voidp)(o) == (w)) -#define __LZO_QUERY_OPTIMIZE(i,il,o,ol,w,n,s) \ - (*ol = (n)*(s), LZO_E_OK) - -#endif - -#ifndef __LZO_PTR_H -#define __LZO_PTR_H - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(__LZO_DOS16) || defined(__LZO_WIN16) -# include -# if 1 && defined(__WATCOMC__) -# include - __LZO_EXTERN_C unsigned char _HShift; -# define __LZO_HShift _HShift -# elif 1 && defined(_MSC_VER) - __LZO_EXTERN_C unsigned short __near _AHSHIFT; -# define __LZO_HShift ((unsigned) &_AHSHIFT) -# elif defined(__LZO_WIN16) -# define __LZO_HShift 3 -# else -# define __LZO_HShift 12 -# endif -# if !defined(_FP_SEG) && defined(FP_SEG) -# define _FP_SEG FP_SEG -# endif -# if !defined(_FP_OFF) && defined(FP_OFF) -# define _FP_OFF FP_OFF -# endif -#endif - -#if !defined(lzo_ptrdiff_t) -# if (UINT_MAX >= LZO_0xffffffffL) - typedef ptrdiff_t lzo_ptrdiff_t; -# else - typedef long lzo_ptrdiff_t; -# endif -#endif - -#if !defined(__LZO_HAVE_PTR_T) -# if defined(lzo_ptr_t) -# define __LZO_HAVE_PTR_T -# endif -#endif -#if !defined(__LZO_HAVE_PTR_T) -# if defined(SIZEOF_CHAR_P) && defined(SIZEOF_UNSIGNED_LONG) -# if (SIZEOF_CHAR_P == SIZEOF_UNSIGNED_LONG) - typedef unsigned long lzo_ptr_t; - typedef long lzo_sptr_t; -# define __LZO_HAVE_PTR_T -# endif -# endif -#endif -#if !defined(__LZO_HAVE_PTR_T) -# if defined(SIZEOF_CHAR_P) && defined(SIZEOF_UNSIGNED) -# if (SIZEOF_CHAR_P == SIZEOF_UNSIGNED) - typedef unsigned int lzo_ptr_t; - typedef int lzo_sptr_t; -# define __LZO_HAVE_PTR_T -# endif -# endif -#endif -#if !defined(__LZO_HAVE_PTR_T) -# if defined(SIZEOF_CHAR_P) && defined(SIZEOF_UNSIGNED_SHORT) -# if (SIZEOF_CHAR_P == SIZEOF_UNSIGNED_SHORT) - typedef unsigned short lzo_ptr_t; - typedef short lzo_sptr_t; -# define __LZO_HAVE_PTR_T -# endif -# endif -#endif -#if !defined(__LZO_HAVE_PTR_T) -# if defined(LZO_HAVE_CONFIG_H) || defined(SIZEOF_CHAR_P) -# error "no suitable type for lzo_ptr_t" -# else - typedef unsigned long lzo_ptr_t; - typedef long lzo_sptr_t; -# define __LZO_HAVE_PTR_T -# endif -#endif - -#if defined(__LZO_DOS16) || defined(__LZO_WIN16) -#define PTR(a) ((lzo_bytep) (a)) -#define PTR_ALIGNED_4(a) ((_FP_OFF(a) & 3) == 0) -#define PTR_ALIGNED2_4(a,b) (((_FP_OFF(a) | _FP_OFF(b)) & 3) == 0) -#else -#define PTR(a) ((lzo_ptr_t) (a)) -#define PTR_LINEAR(a) PTR(a) -#define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0) -#define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0) -#define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0) -#define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0) -#endif - -#define PTR_LT(a,b) (PTR(a) < PTR(b)) -#define PTR_GE(a,b) (PTR(a) >= PTR(b)) -#define PTR_DIFF(a,b) ((lzo_ptrdiff_t) (PTR(a) - PTR(b))) -#define pd(a,b) ((lzo_uint) ((a)-(b))) - - LZO_EXTERN(lzo_ptr_t) - __lzo_ptr_linear(const lzo_voidp ptr); - - typedef union - { - char a_char; - unsigned char a_uchar; - short a_short; - unsigned short a_ushort; - int a_int; - unsigned int a_uint; - long a_long; - unsigned long a_ulong; - lzo_int a_lzo_int; - lzo_uint a_lzo_uint; - lzo_int32 a_lzo_int32; - lzo_uint32 a_lzo_uint32; - ptrdiff_t a_ptrdiff_t; - lzo_ptrdiff_t a_lzo_ptrdiff_t; - lzo_ptr_t a_lzo_ptr_t; - lzo_voidp a_lzo_voidp; - void * a_void_p; - lzo_bytep a_lzo_bytep; - lzo_bytepp a_lzo_bytepp; - lzo_uintp a_lzo_uintp; - lzo_uint * a_lzo_uint_p; - lzo_uint32p a_lzo_uint32p; - lzo_uint32 * a_lzo_uint32_p; - unsigned char * a_uchar_p; - char * a_char_p; - } - lzo_full_align_t; - -#ifdef __cplusplus -} -#endif - -#endif - -#define LZO_DETERMINISTIC - -#define LZO_DICT_USE_PTR -#if defined(__LZO_DOS16) || defined(__LZO_WIN16) || defined(__LZO_STRICT_16BIT) -# undef LZO_DICT_USE_PTR -#endif - -#if defined(LZO_DICT_USE_PTR) -# define lzo_dict_t const lzo_bytep -# define lzo_dict_p lzo_dict_t __LZO_MMODEL * -#else -# define lzo_dict_t lzo_uint -# define lzo_dict_p lzo_dict_t __LZO_MMODEL * -#endif - -#if !defined(lzo_moff_t) -#define lzo_moff_t lzo_uint -#endif - -#endif - -LZO_PUBLIC(lzo_ptr_t) -__lzo_ptr_linear(const lzo_voidp ptr) -{ - lzo_ptr_t p; - -#if defined(__LZO_DOS16) || defined(__LZO_WIN16) - p = (((lzo_ptr_t)(_FP_SEG(ptr))) << (16 - __LZO_HShift)) + (_FP_OFF(ptr)); -#else - p = PTR_LINEAR(ptr); -#endif - - return p; -} - -LZO_PUBLIC(unsigned) -__lzo_align_gap(const lzo_voidp ptr, lzo_uint size) -{ - lzo_ptr_t p, s, n; - - assert(size > 0); - - p = __lzo_ptr_linear(ptr); - s = (lzo_ptr_t) (size - 1); -#if 0 - assert((size & (size - 1)) == 0); - n = ((p + s) & ~s) - p; -#else - n = (((p + s) / size) * size) - p; -#endif - - assert((long)n >= 0); - assert(n <= s); - - return (unsigned)n; -} - -#ifndef __LZO_UTIL_H -#define __LZO_UTIL_H - -#ifndef __LZO_CONF_H -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#if 1 && defined(HAVE_MEMCPY) -#if !defined(__LZO_DOS16) && !defined(__LZO_WIN16) - -#define MEMCPY8_DS(dest,src,len) \ - memcpy(dest,src,len); \ - dest += len; \ - src += len - -#endif -#endif - -#if 0 && !defined(MEMCPY8_DS) - -#define MEMCPY8_DS(dest,src,len) \ - { do { \ - *dest++ = *src++; \ - *dest++ = *src++; \ - *dest++ = *src++; \ - *dest++ = *src++; \ - *dest++ = *src++; \ - *dest++ = *src++; \ - *dest++ = *src++; \ - *dest++ = *src++; \ - len -= 8; \ -} while (len > 0); } - -#endif - -#if !defined(MEMCPY8_DS) - -#define MEMCPY8_DS(dest,src,len) \ - { register lzo_uint __l = (len) / 8; \ - do { \ - *dest++ = *src++; \ - *dest++ = *src++; \ - *dest++ = *src++; \ - *dest++ = *src++; \ - *dest++ = *src++; \ - *dest++ = *src++; \ - *dest++ = *src++; \ - *dest++ = *src++; \ - } while (--__l > 0); } - -#endif - -#define MEMCPY_DS(dest,src,len) \ - do *dest++ = *src++; \ - while (--len > 0) - -#define MEMMOVE_DS(dest,src,len) \ - do *dest++ = *src++; \ - while (--len > 0) - -#if 0 && defined(LZO_OPTIMIZE_GNUC_i386) - -#define BZERO8_PTR(s,l,n) \ - __asm__ __volatile__( \ - "movl %0,%%eax \n" \ - "movl %1,%%edi \n" \ - "movl %2,%%ecx \n" \ - "cld \n" \ - "rep \n" \ - "stosl %%eax,(%%edi) \n" \ - : \ - :"g" (0),"g" (s),"g" (n) \ - :"eax","edi","ecx", "memory", "cc" \ - ) - -#elif (LZO_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMSET) - -#if 1 -#define BZERO8_PTR(s,l,n) memset((s),0,(lzo_uint)(l)*(n)) -#else -#define BZERO8_PTR(s,l,n) memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n)) -#endif - -#else - -#define BZERO8_PTR(s,l,n) \ - lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n)) - -#endif - -#if 0 -#if defined(__GNUC__) && defined(__i386__) - - unsigned char lzo_rotr8(unsigned char value, int shift); - extern __inline__ unsigned char lzo_rotr8(unsigned char value, int shift) - { - unsigned char result; - - __asm__ __volatile__ ("movb %b1, %b0; rorb %b2, %b0" - : "=a"(result) : "g"(value), "c"(shift)); - return result; - } - - unsigned short lzo_rotr16(unsigned short value, int shift); - extern __inline__ unsigned short lzo_rotr16(unsigned short value, int shift) - { - unsigned short result; - - __asm__ __volatile__ ("movw %b1, %b0; rorw %b2, %b0" - : "=a"(result) : "g"(value), "c"(shift)); - return result; - } - -#endif -#endif - -#ifdef __cplusplus -} -#endif - -#endif - -LZO_PUBLIC(lzo_bool) -lzo_assert(int expr) -{ - return (expr) ? 1 : 0; -} - -/* If you use the LZO library in a product, you *must* keep this -* copyright string in the executable of your product. -*/ - -const lzo_byte __lzo_copyright[] = -#if !defined(__LZO_IN_MINLZO) -LZO_VERSION_STRING; -#else -"\n\n\n" -"LZO real-time data compression library.\n" -"Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 Markus Franz Xaver Johannes Oberhumer\n" -"\n" -"http://www.oberhumer.com/opensource/lzo/\n" -"\n" -"LZO version: v" LZO_VERSION_STRING ", " LZO_VERSION_DATE "\n" -"LZO build date: " __DATE__ " " __TIME__ "\n\n" -"LZO special compilation options:\n" -#ifdef __cplusplus -" __cplusplus\n" -#endif -#if defined(__PIC__) -" __PIC__\n" -#elif defined(__pic__) -" __pic__\n" -#endif -#if (UINT_MAX < LZO_0xffffffffL) -" 16BIT\n" -#endif -#if defined(__LZO_STRICT_16BIT) -" __LZO_STRICT_16BIT\n" -#endif -#if (UINT_MAX > LZO_0xffffffffL) -" UINT_MAX=" _LZO_MEXPAND(UINT_MAX) "\n" -#endif -#if (ULONG_MAX > LZO_0xffffffffL) -" ULONG_MAX=" _LZO_MEXPAND(ULONG_MAX) "\n" -#endif -#if defined(LZO_BYTE_ORDER) -" LZO_BYTE_ORDER=" _LZO_MEXPAND(LZO_BYTE_ORDER) "\n" -#endif -#if defined(LZO_UNALIGNED_OK_2) -" LZO_UNALIGNED_OK_2\n" -#endif -#if defined(LZO_UNALIGNED_OK_4) -" LZO_UNALIGNED_OK_4\n" -#endif -#if defined(LZO_ALIGNED_OK_4) -" LZO_ALIGNED_OK_4\n" -#endif -#if defined(LZO_DICT_USE_PTR) -" LZO_DICT_USE_PTR\n" -#endif -#if defined(__LZO_QUERY_COMPRESS) -" __LZO_QUERY_COMPRESS\n" -#endif -#if defined(__LZO_QUERY_DECOMPRESS) -" __LZO_QUERY_DECOMPRESS\n" -#endif -#if defined(__LZO_IN_MINILZO) -" __LZO_IN_MINILZO\n" -#endif -"\n\n" -"$Id: LZO " LZO_VERSION_STRING " built " __DATE__ " " __TIME__ -#if defined(__GNUC__) && defined(__VERSION__) -" by gcc " __VERSION__ -#elif defined(__BORLANDC__) -" by Borland C " _LZO_MEXPAND(__BORLANDC__) -#elif defined(_MSC_VER) -" by Microsoft C " _LZO_MEXPAND(_MSC_VER) -#elif defined(__PUREC__) -" by Pure C " _LZO_MEXPAND(__PUREC__) -#elif defined(__SC__) -" by Symantec C " _LZO_MEXPAND(__SC__) -#elif defined(__TURBOC__) -" by Turbo C " _LZO_MEXPAND(__TURBOC__) -#elif defined(__WATCOMC__) -" by Watcom C " _LZO_MEXPAND(__WATCOMC__) -#endif -" $\n" -"$Copyright: LZO (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 Markus Franz Xaver Johannes Oberhumer $\n"; -#endif - -LZO_PUBLIC(const lzo_byte *) -lzo_copyright(void) -{ - return __lzo_copyright; -} - -LZO_PUBLIC(unsigned) -lzo_version(void) -{ - return LZO_VERSION; -} - -LZO_PUBLIC(const char *) -lzo_version_string(void) -{ - return LZO_VERSION_STRING; -} - -LZO_PUBLIC(const char *) -lzo_version_date(void) -{ - return LZO_VERSION_DATE; -} - -LZO_PUBLIC(const lzo_charp) -_lzo_version_string(void) -{ - return LZO_VERSION_STRING; -} - -LZO_PUBLIC(const lzo_charp) -_lzo_version_date(void) -{ - return LZO_VERSION_DATE; -} - -#define LZO_BASE 65521u -#define LZO_NMAX 5552 - -#define LZO_DO1(buf,i) {s1 += buf[i]; s2 += s1;} -#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1); -#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2); -#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4); -#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8); - -LZO_PUBLIC(lzo_uint32) -lzo_adler32(lzo_uint32 adler, const lzo_byte *buf, lzo_uint len) -{ - lzo_uint32 s1 = adler & 0xffff; - lzo_uint32 s2 = (adler >> 16) & 0xffff; - int k; - - if (buf == NULL) - return 1; - - while (len > 0) - { - k = len < LZO_NMAX ? (int) len : LZO_NMAX; - len -= k; - if (k >= 16) do - { - LZO_DO16(buf,0); - buf += 16; - k -= 16; - } while (k >= 16); - if (k != 0) do - { - s1 += *buf++; - s2 += s1; - } while (--k > 0); - s1 %= LZO_BASE; - s2 %= LZO_BASE; - } - return (s2 << 16) | s1; -} - -LZO_PUBLIC(int) -lzo_memcmp(const lzo_voidp s1, const lzo_voidp s2, lzo_uint len) -{ -#if (LZO_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMCMP) - return memcmp(s1,s2,len); -#else - const lzo_byte *p1 = (const lzo_byte *) s1; - const lzo_byte *p2 = (const lzo_byte *) s2; - int d; - - if (len > 0) do - { - d = *p1 - *p2; - if (d != 0) - return d; - p1++; - p2++; - } - while (--len > 0); - return 0; -#endif -} - -LZO_PUBLIC(lzo_voidp) -lzo_memcpy(lzo_voidp dest, const lzo_voidp src, lzo_uint len) -{ -#if (LZO_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMCPY) - return memcpy(dest,src,len); -#else - lzo_byte *p1 = (lzo_byte *) dest; - const lzo_byte *p2 = (const lzo_byte *) src; - - if (len <= 0 || p1 == p2) - return dest; - do - *p1++ = *p2++; - while (--len > 0); - return dest; -#endif -} - -LZO_PUBLIC(lzo_voidp) -lzo_memmove(lzo_voidp dest, const lzo_voidp src, lzo_uint len) -{ -#if (LZO_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMMOVE) - return memmove(dest,src,len); -#else - lzo_byte *p1 = (lzo_byte *) dest; - const lzo_byte *p2 = (const lzo_byte *) src; - - if (len <= 0 || p1 == p2) - return dest; - - if (p1 < p2) - { - do - *p1++ = *p2++; - while (--len > 0); - } - else - { - p1 += len; - p2 += len; - do - *--p1 = *--p2; - while (--len > 0); - } - return dest; -#endif -} - -LZO_PUBLIC(lzo_voidp) -lzo_memset(lzo_voidp s, int c, lzo_uint len) -{ -#if (LZO_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMSET) - return memset(s,c,len); -#else - lzo_byte *p = (lzo_byte *) s; - - if (len > 0) do - *p++ = LZO_BYTE(c); - while (--len > 0); - return s; -#endif -} - -#if 0 -# define IS_SIGNED(type) (((type) (1ul << (8 * sizeof(type) - 1))) < 0) -# define IS_UNSIGNED(type) (((type) (1ul << (8 * sizeof(type) - 1))) > 0) -#else -# define IS_SIGNED(type) (((type) (-1)) < ((type) 0)) -# define IS_UNSIGNED(type) (((type) (-1)) > ((type) 0)) -#endif - -#define IS_POWER_OF_2(x) (((x) & ((x) - 1)) == 0) - -static lzo_bool schedule_insns_bug(void); -static lzo_bool strength_reduce_bug(int *); - -#if 0 || defined(LZO_DEBUG) -#include -static lzo_bool __lzo_assert_fail(const char *s, unsigned line) -{ -#if defined(__palmos__) - printf("LZO assertion failed in line %u: '%s'\n",line,s); -#else - fprintf(stderr,"LZO assertion failed in line %u: '%s'\n",line,s); -#endif - return 0; -} -# define __lzo_assert(x) ((x) ? 1 : __lzo_assert_fail(#x,__LINE__)) -#else -# define __lzo_assert(x) ((x) ? 1 : 0) -#endif - -#undef COMPILE_TIME_ASSERT -#if 0 -# define COMPILE_TIME_ASSERT(expr) r &= __lzo_assert(expr) -#else -# define COMPILE_TIME_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr) -#endif - -static lzo_bool basic_integral_check(void) -{ - lzo_bool r = 1; - - COMPILE_TIME_ASSERT(CHAR_BIT == 8); - COMPILE_TIME_ASSERT(sizeof(char) == 1); - COMPILE_TIME_ASSERT(sizeof(short) >= 2); - COMPILE_TIME_ASSERT(sizeof(long) >= 4); - COMPILE_TIME_ASSERT(sizeof(int) >= sizeof(short)); - COMPILE_TIME_ASSERT(sizeof(long) >= sizeof(int)); - - COMPILE_TIME_ASSERT(sizeof(lzo_uint) == sizeof(lzo_int)); - COMPILE_TIME_ASSERT(sizeof(lzo_uint32) == sizeof(lzo_int32)); - - COMPILE_TIME_ASSERT(sizeof(lzo_uint32) >= 4); - COMPILE_TIME_ASSERT(sizeof(lzo_uint32) >= sizeof(unsigned)); -#if defined(__LZO_STRICT_16BIT) - COMPILE_TIME_ASSERT(sizeof(lzo_uint) == 2); -#else - COMPILE_TIME_ASSERT(sizeof(lzo_uint) >= 4); - COMPILE_TIME_ASSERT(sizeof(lzo_uint) >= sizeof(unsigned)); -#endif - -#if (USHRT_MAX == 65535u) - COMPILE_TIME_ASSERT(sizeof(short) == 2); -#elif (USHRT_MAX == LZO_0xffffffffL) - COMPILE_TIME_ASSERT(sizeof(short) == 4); -#elif (USHRT_MAX >= LZO_0xffffffffL) - COMPILE_TIME_ASSERT(sizeof(short) > 4); -#endif -#if (UINT_MAX == 65535u) - COMPILE_TIME_ASSERT(sizeof(int) == 2); -#elif (UINT_MAX == LZO_0xffffffffL) - COMPILE_TIME_ASSERT(sizeof(int) == 4); -#elif (UINT_MAX >= LZO_0xffffffffL) - COMPILE_TIME_ASSERT(sizeof(int) > 4); -#endif -#if (ULONG_MAX == 65535ul) - COMPILE_TIME_ASSERT(sizeof(long) == 2); -#elif (ULONG_MAX == LZO_0xffffffffL) - COMPILE_TIME_ASSERT(sizeof(long) == 4); -#elif (ULONG_MAX >= LZO_0xffffffffL) - COMPILE_TIME_ASSERT(sizeof(long) > 4); -#endif - -#if defined(SIZEOF_UNSIGNED) - COMPILE_TIME_ASSERT(SIZEOF_UNSIGNED == sizeof(unsigned)); -#endif -#if defined(SIZEOF_UNSIGNED_LONG) - COMPILE_TIME_ASSERT(SIZEOF_UNSIGNED_LONG == sizeof(unsigned long)); -#endif -#if defined(SIZEOF_UNSIGNED_SHORT) - COMPILE_TIME_ASSERT(SIZEOF_UNSIGNED_SHORT == sizeof(unsigned short)); -#endif -#if !defined(__LZO_IN_MINILZO) -#if defined(SIZEOF_SIZE_T) - COMPILE_TIME_ASSERT(SIZEOF_SIZE_T == sizeof(size_t)); -#endif -#endif - - COMPILE_TIME_ASSERT(IS_UNSIGNED(unsigned char)); - COMPILE_TIME_ASSERT(IS_UNSIGNED(unsigned short)); - COMPILE_TIME_ASSERT(IS_UNSIGNED(unsigned)); - COMPILE_TIME_ASSERT(IS_UNSIGNED(unsigned long)); - COMPILE_TIME_ASSERT(IS_SIGNED(short)); - COMPILE_TIME_ASSERT(IS_SIGNED(int)); - COMPILE_TIME_ASSERT(IS_SIGNED(long)); - - COMPILE_TIME_ASSERT(IS_UNSIGNED(lzo_uint32)); - COMPILE_TIME_ASSERT(IS_UNSIGNED(lzo_uint)); - COMPILE_TIME_ASSERT(IS_SIGNED(lzo_int32)); - COMPILE_TIME_ASSERT(IS_SIGNED(lzo_int)); - - COMPILE_TIME_ASSERT(INT_MAX == LZO_STYPE_MAX(sizeof(int))); - COMPILE_TIME_ASSERT(UINT_MAX == LZO_UTYPE_MAX(sizeof(unsigned))); - COMPILE_TIME_ASSERT(LONG_MAX == LZO_STYPE_MAX(sizeof(long))); - COMPILE_TIME_ASSERT(ULONG_MAX == LZO_UTYPE_MAX(sizeof(unsigned long))); - COMPILE_TIME_ASSERT(SHRT_MAX == LZO_STYPE_MAX(sizeof(short))); - COMPILE_TIME_ASSERT(USHRT_MAX == LZO_UTYPE_MAX(sizeof(unsigned short))); - COMPILE_TIME_ASSERT(LZO_UINT32_MAX == LZO_UTYPE_MAX(sizeof(lzo_uint32))); - COMPILE_TIME_ASSERT(LZO_UINT_MAX == LZO_UTYPE_MAX(sizeof(lzo_uint))); -#if !defined(__LZO_IN_MINILZO) - COMPILE_TIME_ASSERT(SIZE_T_MAX == LZO_UTYPE_MAX(sizeof(size_t))); -#endif - - r &= __lzo_assert(LZO_BYTE(257) == 1); - - return r; -} - -static lzo_bool basic_ptr_check(void) -{ - lzo_bool r = 1; - - COMPILE_TIME_ASSERT(sizeof(char *) >= sizeof(int)); - COMPILE_TIME_ASSERT(sizeof(lzo_byte *) >= sizeof(char *)); - - COMPILE_TIME_ASSERT(sizeof(lzo_voidp) == sizeof(lzo_byte *)); - COMPILE_TIME_ASSERT(sizeof(lzo_voidp) == sizeof(lzo_voidpp)); - COMPILE_TIME_ASSERT(sizeof(lzo_voidp) == sizeof(lzo_bytepp)); - COMPILE_TIME_ASSERT(sizeof(lzo_voidp) >= sizeof(lzo_uint)); - - COMPILE_TIME_ASSERT(sizeof(lzo_ptr_t) == sizeof(lzo_voidp)); - COMPILE_TIME_ASSERT(sizeof(lzo_ptr_t) == sizeof(lzo_sptr_t)); - COMPILE_TIME_ASSERT(sizeof(lzo_ptr_t) >= sizeof(lzo_uint)); - - COMPILE_TIME_ASSERT(sizeof(lzo_ptrdiff_t) >= 4); - COMPILE_TIME_ASSERT(sizeof(lzo_ptrdiff_t) >= sizeof(ptrdiff_t)); - - COMPILE_TIME_ASSERT(sizeof(ptrdiff_t) >= sizeof(size_t)); - COMPILE_TIME_ASSERT(sizeof(lzo_ptrdiff_t) >= sizeof(lzo_uint)); - -#if defined(SIZEOF_CHAR_P) - COMPILE_TIME_ASSERT(SIZEOF_CHAR_P == sizeof(char *)); -#endif -#if defined(SIZEOF_PTRDIFF_T) - COMPILE_TIME_ASSERT(SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t)); -#endif - - COMPILE_TIME_ASSERT(IS_SIGNED(ptrdiff_t)); - COMPILE_TIME_ASSERT(IS_UNSIGNED(size_t)); - COMPILE_TIME_ASSERT(IS_SIGNED(lzo_ptrdiff_t)); - COMPILE_TIME_ASSERT(IS_SIGNED(lzo_sptr_t)); - COMPILE_TIME_ASSERT(IS_UNSIGNED(lzo_ptr_t)); - COMPILE_TIME_ASSERT(IS_UNSIGNED(lzo_moff_t)); - - return r; -} - -static lzo_bool ptr_check(void) -{ - lzo_bool r = 1; - int i; - char _wrkmem[10 * sizeof(lzo_byte *) + sizeof(lzo_full_align_t)]; - lzo_bytep wrkmem; - lzo_bytepp dict; - unsigned char x[4 * sizeof(lzo_full_align_t)]; - long d; - lzo_full_align_t a; - lzo_full_align_t u; - - for (i = 0; i < (int) sizeof(x); ++i) - x[i] = LZO_BYTE(i); - - wrkmem = LZO_PTR_ALIGN_UP((lzo_byte *)_wrkmem,sizeof(lzo_full_align_t)); - -#if 0 - dict = (lzo_bytepp) wrkmem; -#else - - u.a_lzo_bytep = wrkmem; dict = u.a_lzo_bytepp; -#endif - - d = (long) ((const lzo_bytep) dict - (const lzo_bytep) _wrkmem); - r &= __lzo_assert(d >= 0); - r &= __lzo_assert(d < (long) sizeof(lzo_full_align_t)); - - memset(&a,0,sizeof(a)); - r &= __lzo_assert(a.a_lzo_voidp == NULL); - - memset(&a,0xff,sizeof(a)); - r &= __lzo_assert(a.a_ushort == USHRT_MAX); - r &= __lzo_assert(a.a_uint == UINT_MAX); - r &= __lzo_assert(a.a_ulong == ULONG_MAX); - r &= __lzo_assert(a.a_lzo_uint == LZO_UINT_MAX); - r &= __lzo_assert(a.a_lzo_uint32 == LZO_UINT32_MAX); - - if (r == 1) - { - for (i = 0; i < 8; ++i) - r &= __lzo_assert((const lzo_voidp) (&dict[i]) == (const lzo_voidp) (&wrkmem[i * sizeof(lzo_byte *)])); - } - - memset(&a,0,sizeof(a)); - r &= __lzo_assert(a.a_char_p == NULL); - r &= __lzo_assert(a.a_lzo_bytep == NULL); - r &= __lzo_assert(NULL == (void *)0); - if (r == 1) - { - for (i = 0; i < 10; ++i) - dict[i] = wrkmem; - BZERO8_PTR(dict+1,sizeof(dict[0]),8); - r &= __lzo_assert(dict[0] == wrkmem); - for (i = 1; i < 9; ++i) - r &= __lzo_assert(dict[i] == NULL); - r &= __lzo_assert(dict[9] == wrkmem); - } - - if (r == 1) - { - unsigned k = 1; - const unsigned n = (unsigned) sizeof(lzo_uint32); - lzo_byte *p0; - lzo_byte *p1; - - k += __lzo_align_gap(&x[k],n); - p0 = (lzo_bytep) &x[k]; -#if defined(PTR_LINEAR) - r &= __lzo_assert((PTR_LINEAR(p0) & (n-1)) == 0); -#else - r &= __lzo_assert(n == 4); - r &= __lzo_assert(PTR_ALIGNED_4(p0)); -#endif - - r &= __lzo_assert(k >= 1); - p1 = (lzo_bytep) &x[1]; - r &= __lzo_assert(PTR_GE(p0,p1)); - - r &= __lzo_assert(k < 1+n); - p1 = (lzo_bytep) &x[1+n]; - r &= __lzo_assert(PTR_LT(p0,p1)); - - if (r == 1) - { - lzo_uint32 v0, v1; -#if 0 - v0 = * (lzo_uint32 *) &x[k]; - v1 = * (lzo_uint32 *) &x[k+n]; -#else - - u.a_uchar_p = &x[k]; - v0 = *u.a_lzo_uint32_p; - u.a_uchar_p = &x[k+n]; - v1 = *u.a_lzo_uint32_p; -#endif - r &= __lzo_assert(v0 > 0); - r &= __lzo_assert(v1 > 0); - } - } - - return r; -} - -LZO_PUBLIC(int) -_lzo_config_check(void) -{ - lzo_bool r = 1; - int i; - union { - lzo_uint32 a; - unsigned short b; - lzo_uint32 aa[4]; - unsigned char x[4*sizeof(lzo_full_align_t)]; - } u; - - COMPILE_TIME_ASSERT( (int) ((unsigned char) ((signed char) -1)) == 255); - COMPILE_TIME_ASSERT( (((unsigned char)128) << (int)(8*sizeof(int)-8)) < 0); - -#if 0 - r &= __lzo_assert((const void *)&u == (const void *)&u.a); - r &= __lzo_assert((const void *)&u == (const void *)&u.b); - r &= __lzo_assert((const void *)&u == (const void *)&u.x[0]); - r &= __lzo_assert((const void *)&u == (const void *)&u.aa[0]); -#endif - - r &= basic_integral_check(); - r &= basic_ptr_check(); - if (r != 1) - return LZO_E_ERROR; - - u.a = 0; u.b = 0; - for (i = 0; i < (int) sizeof(u.x); ++i) - u.x[i] = LZO_BYTE(i); - -#if defined(LZO_BYTE_ORDER) - if (r == 1) - { -# if (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN) - lzo_uint32 a = (lzo_uint32) (u.a & LZO_0xffffffffL); - unsigned short b = (unsigned short) (u.b & 0xffff); - r &= __lzo_assert(a == 0x03020100L); - r &= __lzo_assert(b == 0x0100); -# elif (LZO_BYTE_ORDER == LZO_BIG_ENDIAN) - lzo_uint32 a = u.a >> (8 * sizeof(u.a) - 32); - unsigned short b = u.b >> (8 * sizeof(u.b) - 16); - r &= __lzo_assert(a == 0x00010203L); - r &= __lzo_assert(b == 0x0001); -# else -# error "invalid LZO_BYTE_ORDER" -# endif - } -#endif - -#if defined(LZO_UNALIGNED_OK_2) - COMPILE_TIME_ASSERT(sizeof(short) == 2); - if (r == 1) - { - unsigned short b[4]; - - for (i = 0; i < 4; ++i) - b[i] = * (const unsigned short *) &u.x[i]; - -# if (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN) - r &= __lzo_assert(b[0] == 0x0100); - r &= __lzo_assert(b[1] == 0x0201); - r &= __lzo_assert(b[2] == 0x0302); - r &= __lzo_assert(b[3] == 0x0403); -# elif (LZO_BYTE_ORDER == LZO_BIG_ENDIAN) - r &= __lzo_assert(b[0] == 0x0001); - r &= __lzo_assert(b[1] == 0x0102); - r &= __lzo_assert(b[2] == 0x0203); - r &= __lzo_assert(b[3] == 0x0304); -# endif - } -#endif - -#if defined(LZO_UNALIGNED_OK_4) - COMPILE_TIME_ASSERT(sizeof(lzo_uint32) == 4); - if (r == 1) - { - lzo_uint32 a[4]; - - for (i = 0; i < 4; ++i) - a[i] = * (const lzo_uint32 *) &u.x[i]; - -# if (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN) - r &= __lzo_assert(a[0] == 0x03020100L); - r &= __lzo_assert(a[1] == 0x04030201L); - r &= __lzo_assert(a[2] == 0x05040302L); - r &= __lzo_assert(a[3] == 0x06050403L); -# elif (LZO_BYTE_ORDER == LZO_BIG_ENDIAN) - r &= __lzo_assert(a[0] == 0x00010203L); - r &= __lzo_assert(a[1] == 0x01020304L); - r &= __lzo_assert(a[2] == 0x02030405L); - r &= __lzo_assert(a[3] == 0x03040506L); -# endif - } -#endif - -#if defined(LZO_ALIGNED_OK_4) - COMPILE_TIME_ASSERT(sizeof(lzo_uint32) == 4); -#endif - - COMPILE_TIME_ASSERT(lzo_sizeof_dict_t == sizeof(lzo_dict_t)); - -#if defined(__LZO_IN_MINLZO) - if (r == 1) - { - lzo_uint32 adler; - adler = lzo_adler32(0, NULL, 0); - adler = lzo_adler32(adler, lzo_copyright(), 200); - r &= __lzo_assert(adler == 0xc76f1751L); - } -#endif - - if (r == 1) - { - r &= __lzo_assert(!schedule_insns_bug()); - } - - if (r == 1) - { - static int x[3]; - static unsigned xn = 3; - register unsigned j; - - for (j = 0; j < xn; ++j) - x[j] = (int)j - 3; - r &= __lzo_assert(!strength_reduce_bug(x)); - } - - if (r == 1) - { - r &= ptr_check(); - } - - return r == 1 ? LZO_E_OK : LZO_E_ERROR; -} - -static lzo_bool schedule_insns_bug(void) -{ -#if defined(__LZO_CHECKER) - return 0; -#else - const int clone[] = {1, 2, 0}; - const int *q; - q = clone; - return (*q) ? 0 : 1; -#endif -} - -static lzo_bool strength_reduce_bug(int *x) -{ - return x[0] != -3 || x[1] != -2 || x[2] != -1; -} - -#undef COMPILE_TIME_ASSERT - -int __lzo_init_done = 0; - -LZO_PUBLIC(int) -__lzo_init2(unsigned v, int s1, int s2, int s3, int s4, int s5, - int s6, int s7, int s8, int s9) -{ - int r; - - __lzo_init_done = 1; - - if (v == 0) - return LZO_E_ERROR; - - r = (s1 == -1 || s1 == (int) sizeof(short)) && - (s2 == -1 || s2 == (int) sizeof(int)) && - (s3 == -1 || s3 == (int) sizeof(long)) && - (s4 == -1 || s4 == (int) sizeof(lzo_uint32)) && - (s5 == -1 || s5 == (int) sizeof(lzo_uint)) && - (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) && - (s7 == -1 || s7 == (int) sizeof(char *)) && - (s8 == -1 || s8 == (int) sizeof(lzo_voidp)) && - (s9 == -1 || s9 == (int) sizeof(lzo_compress_t)); - if (!r) - return LZO_E_ERROR; - - r = _lzo_config_check(); - if (r != LZO_E_OK) - return r; - - return r; -} - -#if !defined(__LZO_IN_MINILZO) - -LZO_EXTERN(int) -__lzo_init(unsigned v,int s1,int s2,int s3,int s4,int s5,int s6,int s7); - -LZO_PUBLIC(int) -__lzo_init(unsigned v,int s1,int s2,int s3,int s4,int s5,int s6,int s7) -{ - if (v == 0 || v > 0x1010) - return LZO_E_ERROR; - return __lzo_init2(v,s1,s2,s3,s4,s5,-1,-1,s6,s7); -} - -#endif - -#define do_compress _lzo1x_1_do_compress - -#define LZO_NEED_DICT_H -#define D_BITS 14 -#define D_INDEX1(d,p) d = DM((0x21*DX3(p,5,5,6)) >> 5) -#define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f) - -#ifndef __LZO_CONFIG1X_H -#define __LZO_CONFIG1X_H - -#if !defined(LZO1X) && !defined(LZO1Y) && !defined(LZO1Z) -# define LZO1X -#endif - -#if !defined(__LZO_IN_MINILZO) -#include -#endif - -#define LZO_EOF_CODE -#undef LZO_DETERMINISTIC - -#define M1_MAX_OFFSET 0x0400 -#ifndef M2_MAX_OFFSET -#define M2_MAX_OFFSET 0x0800 -#endif -#define M3_MAX_OFFSET 0x4000 -#define M4_MAX_OFFSET 0xbfff - -#define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET) - -#define M1_MIN_LEN 2 -#define M1_MAX_LEN 2 -#define M2_MIN_LEN 3 -#ifndef M2_MAX_LEN -#define M2_MAX_LEN 8 -#endif -#define M3_MIN_LEN 3 -#define M3_MAX_LEN 33 -#define M4_MIN_LEN 3 -#define M4_MAX_LEN 9 - -#define M1_MARKER 0 -#define M2_MARKER 64 -#define M3_MARKER 32 -#define M4_MARKER 16 - -#ifndef MIN_LOOKAHEAD -#define MIN_LOOKAHEAD (M2_MAX_LEN + 1) -#endif - -#if defined(LZO_NEED_DICT_H) - -#ifndef LZO_HASH -#define LZO_HASH LZO_HASH_LZO_INCREMENTAL_B -#endif -#define DL_MIN_LEN M2_MIN_LEN - -#ifndef __LZO_DICT_H -#define __LZO_DICT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(D_BITS) && defined(DBITS) -# define D_BITS DBITS -#endif -#if !defined(D_BITS) -# error "D_BITS is not defined" -#endif -#if (D_BITS < 16) -# define D_SIZE LZO_SIZE(D_BITS) -# define D_MASK LZO_MASK(D_BITS) -#else -# define D_SIZE LZO_USIZE(D_BITS) -# define D_MASK LZO_UMASK(D_BITS) -#endif -#define D_HIGH ((D_MASK >> 1) + 1) - -#if !defined(DD_BITS) -# define DD_BITS 0 -#endif -#define DD_SIZE LZO_SIZE(DD_BITS) -#define DD_MASK LZO_MASK(DD_BITS) - -#if !defined(DL_BITS) -# define DL_BITS (D_BITS - DD_BITS) -#endif -#if (DL_BITS < 16) -# define DL_SIZE LZO_SIZE(DL_BITS) -# define DL_MASK LZO_MASK(DL_BITS) -#else -# define DL_SIZE LZO_USIZE(DL_BITS) -# define DL_MASK LZO_UMASK(DL_BITS) -#endif - -#if (D_BITS != DL_BITS + DD_BITS) -# error "D_BITS does not match" -#endif -#if (D_BITS < 8 || D_BITS > 18) -# error "invalid D_BITS" -#endif -#if (DL_BITS < 8 || DL_BITS > 20) -# error "invalid DL_BITS" -#endif -#if (DD_BITS < 0 || DD_BITS > 6) -# error "invalid DD_BITS" -#endif - -#if !defined(DL_MIN_LEN) -# define DL_MIN_LEN 3 -#endif -#if !defined(DL_SHIFT) -# define DL_SHIFT ((DL_BITS + (DL_MIN_LEN - 1)) / DL_MIN_LEN) -#endif - -#define LZO_HASH_GZIP 1 -#define LZO_HASH_GZIP_INCREMENTAL 2 -#define LZO_HASH_LZO_INCREMENTAL_A 3 -#define LZO_HASH_LZO_INCREMENTAL_B 4 - -#if !defined(LZO_HASH) -# error "choose a hashing strategy" -#endif - -#if (DL_MIN_LEN == 3) -# define _DV2_A(p,shift1,shift2) \ - (((( (lzo_uint32)((p)[0]) << shift1) ^ (p)[1]) << shift2) ^ (p)[2]) -# define _DV2_B(p,shift1,shift2) \ - (((( (lzo_uint32)((p)[2]) << shift1) ^ (p)[1]) << shift2) ^ (p)[0]) -# define _DV3_B(p,shift1,shift2,shift3) \ - ((_DV2_B((p)+1,shift1,shift2) << (shift3)) ^ (p)[0]) -#elif (DL_MIN_LEN == 2) -# define _DV2_A(p,shift1,shift2) \ - (( (lzo_uint32)(p[0]) << shift1) ^ p[1]) -# define _DV2_B(p,shift1,shift2) \ - (( (lzo_uint32)(p[1]) << shift1) ^ p[2]) -#else -# error "invalid DL_MIN_LEN" -#endif -#define _DV_A(p,shift) _DV2_A(p,shift,shift) -#define _DV_B(p,shift) _DV2_B(p,shift,shift) -#define DA2(p,s1,s2) \ - (((((lzo_uint32)((p)[2]) << (s2)) + (p)[1]) << (s1)) + (p)[0]) -#define DS2(p,s1,s2) \ - (((((lzo_uint32)((p)[2]) << (s2)) - (p)[1]) << (s1)) - (p)[0]) -#define DX2(p,s1,s2) \ - (((((lzo_uint32)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0]) -#define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0]) -#define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0]) -#define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0]) -#define DMS(v,s) ((lzo_uint) (((v) & (D_MASK >> (s))) << (s))) -#define DM(v) DMS(v,0) - -#if (LZO_HASH == LZO_HASH_GZIP) -# define _DINDEX(dv,p) (_DV_A((p),DL_SHIFT)) - -#elif (LZO_HASH == LZO_HASH_GZIP_INCREMENTAL) -# define __LZO_HASH_INCREMENTAL -# define DVAL_FIRST(dv,p) dv = _DV_A((p),DL_SHIFT) -# define DVAL_NEXT(dv,p) dv = (((dv) << DL_SHIFT) ^ p[2]) -# define _DINDEX(dv,p) (dv) -# define DVAL_LOOKAHEAD DL_MIN_LEN - -#elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_A) -# define __LZO_HASH_INCREMENTAL -# define DVAL_FIRST(dv,p) dv = _DV_A((p),5) -# define DVAL_NEXT(dv,p) \ - dv ^= (lzo_uint32)(p[-1]) << (2*5); dv = (((dv) << 5) ^ p[2]) -# define _DINDEX(dv,p) ((0x9f5f * (dv)) >> 5) -# define DVAL_LOOKAHEAD DL_MIN_LEN - -#elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B) -# define __LZO_HASH_INCREMENTAL -# define DVAL_FIRST(dv,p) dv = _DV_B((p),5) -# define DVAL_NEXT(dv,p) \ - dv ^= p[-1]; dv = (((dv) >> 5) ^ ((lzo_uint32)(p[2]) << (2*5))) -# define _DINDEX(dv,p) ((0x9f5f * (dv)) >> 5) -# define DVAL_LOOKAHEAD DL_MIN_LEN - -#else -# error "choose a hashing strategy" -#endif - -#ifndef DINDEX -#define DINDEX(dv,p) ((lzo_uint)((_DINDEX(dv,p)) & DL_MASK) << DD_BITS) -#endif -#if !defined(DINDEX1) && defined(D_INDEX1) -#define DINDEX1 D_INDEX1 -#endif -#if !defined(DINDEX2) && defined(D_INDEX2) -#define DINDEX2 D_INDEX2 -#endif - -#if !defined(__LZO_HASH_INCREMENTAL) -# define DVAL_FIRST(dv,p) ((void) 0) -# define DVAL_NEXT(dv,p) ((void) 0) -# define DVAL_LOOKAHEAD 0 -#endif - -#if !defined(DVAL_ASSERT) -#if defined(__LZO_HASH_INCREMENTAL) && !defined(NDEBUG) - static void DVAL_ASSERT(lzo_uint32 dv, const lzo_byte *p) - { - lzo_uint32 df; - DVAL_FIRST(df,(p)); - assert(DINDEX(dv,p) == DINDEX(df,p)); - } -#else -# define DVAL_ASSERT(dv,p) ((void) 0) -#endif -#endif - -#if defined(LZO_DICT_USE_PTR) -# define DENTRY(p,in) (p) -# define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex] -#else -# define DENTRY(p,in) ((lzo_uint) ((p)-(in))) -# define GINDEX(m_pos,m_off,dict,dindex,in) m_off = dict[dindex] -#endif - -#if (DD_BITS == 0) - -# define UPDATE_D(dict,drun,dv,p,in) dict[ DINDEX(dv,p) ] = DENTRY(p,in) -# define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in) -# define UPDATE_P(ptr,drun,p,in) (ptr)[0] = DENTRY(p,in) - -#else - -# define UPDATE_D(dict,drun,dv,p,in) \ - dict[ DINDEX(dv,p) + drun++ ] = DENTRY(p,in); drun &= DD_MASK -# define UPDATE_I(dict,drun,index,p,in) \ - dict[ (index) + drun++ ] = DENTRY(p,in); drun &= DD_MASK -# define UPDATE_P(ptr,drun,p,in) \ - (ptr) [ drun++ ] = DENTRY(p,in); drun &= DD_MASK - -#endif - -#if defined(LZO_DICT_USE_PTR) - -#define LZO_CHECK_FPOS_DET(m_pos,m_off,in,ip,max_offset) \ - (m_pos == NULL || (m_off = (lzo_moff_t) (ip - m_pos)) > max_offset) - -#define LZO_CHECK_FPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \ - (BOUNDS_CHECKING_OFF_IN_EXPR( \ - (PTR_LT(m_pos,in) || \ - (m_off = (lzo_moff_t) PTR_DIFF(ip,m_pos)) <= 0 || \ - m_off > max_offset) )) - -#else - -#define LZO_CHECK_FPOS_DET(m_pos,m_off,in,ip,max_offset) \ - (m_off == 0 || \ - ((m_off = (lzo_moff_t) ((ip)-(in)) - m_off) > max_offset) || \ - (m_pos = (ip) - (m_off), 0) ) - -#define LZO_CHECK_FPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \ - ((lzo_moff_t) ((ip)-(in)) <= m_off || \ - ((m_off = (lzo_moff_t) ((ip)-(in)) - m_off) > max_offset) || \ - (m_pos = (ip) - (m_off), 0) ) - -#endif - -#if defined(LZO_DETERMINISTIC) -# define LZO_CHECK_FPOS LZO_CHECK_MPOS_DET -#else -# define LZO_CHECK_FPOS LZO_CHECK_MPOS_NON_DET -#endif - -#ifdef __cplusplus -} -#endif - -#endif - -#endif - -#endif - -#define DO_COMPRESS lzo1x_1_compress - -static -lzo_uint do_compress ( const lzo_byte *in , lzo_uint in_len, - lzo_byte *out, lzo_uintp out_len, - lzo_voidp wrkmem ) -{ -#if 0 && defined(__GNUC__) && defined(__i386__) - register const lzo_byte *ip __asm__("%esi"); -#else - register const lzo_byte *ip; -#endif - lzo_byte *op; - const lzo_byte * const in_end = in + in_len; - const lzo_byte * const ip_end = in + in_len - M2_MAX_LEN - 5; - const lzo_byte *ii; - lzo_dict_p const dict = (lzo_dict_p) wrkmem; - - op = out; - ip = in; - ii = ip; - - ip += 4; - for (;;) - { -#if 0 && defined(__GNUC__) && defined(__i386__) - register const lzo_byte *m_pos __asm__("%edi"); -#else - register const lzo_byte *m_pos; -#endif - lzo_moff_t m_off; - lzo_uint m_len; - lzo_uint dindex; - - DINDEX1(dindex,ip); - GINDEX(m_pos,m_off,dict,dindex,in); - if (LZO_CHECK_FPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET)) - goto literal; -#if 1 - if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) - goto try_match; - DINDEX2(dindex,ip); -#endif - GINDEX(m_pos,m_off,dict,dindex,in); - if (LZO_CHECK_FPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET)) - goto literal; - if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) - goto try_match; - goto literal; - -try_match: -#if 1 && defined(LZO_UNALIGNED_OK_2) - if (* (const lzo_ushortp) m_pos != * (const lzo_ushortp) ip) -#else - if (m_pos[0] != ip[0] || m_pos[1] != ip[1]) -#endif - { - } - else - { - if (m_pos[2] == ip[2]) - { -#if 0 - if (m_off <= M2_MAX_OFFSET) - goto match; - if (lit <= 3) - goto match; - if (lit == 3) - { - assert(op - 2 > out); op[-2] |= LZO_BYTE(3); - *op++ = *ii++; *op++ = *ii++; *op++ = *ii++; - goto code_match; - } - if (m_pos[3] == ip[3]) -#endif - goto match; - } - else - { -#if 0 -#if 0 - if (m_off <= M1_MAX_OFFSET && lit > 0 && lit <= 3) -#else - if (m_off <= M1_MAX_OFFSET && lit == 3) -#endif - { - register lzo_uint t; - - t = lit; - assert(op - 2 > out); op[-2] |= LZO_BYTE(t); - do *op++ = *ii++; while (--t > 0); - assert(ii == ip); - m_off -= 1; - *op++ = LZO_BYTE(M1_MARKER | ((m_off & 3) << 2)); - *op++ = LZO_BYTE(m_off >> 2); - ip += 2; - goto match_done; - } -#endif - } - } - - literal: - UPDATE_I(dict,0,dindex,ip,in); - ++ip; - - if (ip >= ip_end) - break; - - continue; - -match: - UPDATE_I(dict,0,dindex,ip,in); - if (pd(ip,ii) > 0) - { - register lzo_uint t = pd(ip,ii); - - if (t <= 3) - { - assert(op - 2 > out); - op[-2] |= LZO_BYTE(t); - } - else if (t <= 18) - *op++ = LZO_BYTE(t - 3); - else - { - register lzo_uint tt = t - 18; - - *op++ = 0; - while (tt > 255) - { - tt -= 255; - *op++ = 0; - } - assert(tt > 0); - *op++ = LZO_BYTE(tt); - } - do *op++ = *ii++; while (--t > 0); - } - - assert(ii == ip); - ip += 3; - if (m_pos[3] != *ip++ || m_pos[4] != *ip++ || m_pos[5] != *ip++ || - m_pos[6] != *ip++ || m_pos[7] != *ip++ || m_pos[8] != *ip++ -#ifdef LZO1Y - || m_pos[ 9] != *ip++ || m_pos[10] != *ip++ || m_pos[11] != *ip++ - || m_pos[12] != *ip++ || m_pos[13] != *ip++ || m_pos[14] != *ip++ -#endif - ) - { - --ip; - m_len = ip - ii; - assert(m_len >= 3); assert(m_len <= M2_MAX_LEN); - - if (m_off <= M2_MAX_OFFSET) - { - m_off -= 1; -#if defined(LZO1X) - *op++ = LZO_BYTE(((m_len - 1) << 5) | ((m_off & 7) << 2)); - *op++ = LZO_BYTE(m_off >> 3); -#elif defined(LZO1Y) - *op++ = LZO_BYTE(((m_len + 1) << 4) | ((m_off & 3) << 2)); - *op++ = LZO_BYTE(m_off >> 2); -#endif - } - else if (m_off <= M3_MAX_OFFSET) - { - m_off -= 1; - *op++ = LZO_BYTE(M3_MARKER | (m_len - 2)); - goto m3_m4_offset; - } - else -#if defined(LZO1X) - { - m_off -= 0x4000; - assert(m_off > 0); assert(m_off <= 0x7fff); - *op++ = LZO_BYTE(M4_MARKER | - ((m_off & 0x4000) >> 11) | (m_len - 2)); - goto m3_m4_offset; - } -#elif defined(LZO1Y) - goto m4_match; -#endif - } - else - { - { - const lzo_byte *end = in_end; - const lzo_byte *m = m_pos + M2_MAX_LEN + 1; - while (ip < end && *m == *ip) - m++, ip++; - m_len = (ip - ii); - } - assert(m_len > M2_MAX_LEN); - - if (m_off <= M3_MAX_OFFSET) - { - m_off -= 1; - if (m_len <= 33) - *op++ = LZO_BYTE(M3_MARKER | (m_len - 2)); - else - { - m_len -= 33; - *op++ = M3_MARKER | 0; - goto m3_m4_len; - } - } - else - { -#if defined(LZO1Y) -m4_match: -#endif - m_off -= 0x4000; - assert(m_off > 0); assert(m_off <= 0x7fff); - if (m_len <= M4_MAX_LEN) - *op++ = LZO_BYTE(M4_MARKER | - ((m_off & 0x4000) >> 11) | (m_len - 2)); - else - { - m_len -= M4_MAX_LEN; - *op++ = LZO_BYTE(M4_MARKER | ((m_off & 0x4000) >> 11)); -m3_m4_len: - while (m_len > 255) - { - m_len -= 255; - *op++ = 0; - } - assert(m_len > 0); - *op++ = LZO_BYTE(m_len); - } - } - -m3_m4_offset: - *op++ = LZO_BYTE((m_off & 63) << 2); - *op++ = LZO_BYTE(m_off >> 6); - } - -#if 0 -match_done: -#endif - ii = ip; - if (ip >= ip_end) - break; - } - - *out_len = op - out; - return pd(in_end,ii); -} - -LZO_PUBLIC(int) -DO_COMPRESS ( const lzo_byte *in , lzo_uint in_len, - lzo_byte *out, lzo_uintp out_len, - lzo_voidp wrkmem ) -{ - lzo_byte *op = out; - lzo_uint t; - -#if defined(__LZO_QUERY_COMPRESS) - if (__LZO_IS_COMPRESS_QUERY(in,in_len,out,out_len,wrkmem)) - return __LZO_QUERY_COMPRESS(in,in_len,out,out_len,wrkmem,D_SIZE,lzo_sizeof(lzo_dict_t)); -#endif - - if (in_len <= M2_MAX_LEN + 5) - t = in_len; - else - { - t = do_compress(in,in_len,op,out_len,wrkmem); - op += *out_len; - } - - if (t > 0) - { - const lzo_byte *ii = in + in_len - t; - - if (op == out && t <= 238) - *op++ = LZO_BYTE(17 + t); - else if (t <= 3) - op[-2] |= LZO_BYTE(t); - else if (t <= 18) - *op++ = LZO_BYTE(t - 3); - else - { - lzo_uint tt = t - 18; - - *op++ = 0; - while (tt > 255) - { - tt -= 255; - *op++ = 0; - } - assert(tt > 0); - *op++ = LZO_BYTE(tt); - } - do *op++ = *ii++; while (--t > 0); - } - - *op++ = M4_MARKER | 1; - *op++ = 0; - *op++ = 0; - - *out_len = op - out; - return LZO_E_OK; -} - -#undef do_compress -#undef DO_COMPRESS -#undef LZO_HASH - -#undef LZO_TEST_DECOMPRESS_OVERRUN -#undef LZO_TEST_DECOMPRESS_OVERRUN_INPUT -#undef LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT -#undef LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND -#undef DO_DECOMPRESS -#define DO_DECOMPRESS lzo1x_decompress - -#if defined(LZO_TEST_DECOMPRESS_OVERRUN) -# if !defined(LZO_TEST_DECOMPRESS_OVERRUN_INPUT) -# define LZO_TEST_DECOMPRESS_OVERRUN_INPUT 2 -# endif -# if !defined(LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT) -# define LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT 2 -# endif -# if !defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND) -# define LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND -# endif -#endif - -#undef TEST_IP -#undef TEST_OP -#undef TEST_LOOKBEHIND -#undef NEED_IP -#undef NEED_OP -#undef HAVE_TEST_IP -#undef HAVE_TEST_OP -#undef HAVE_NEED_IP -#undef HAVE_NEED_OP -#undef HAVE_ANY_IP -#undef HAVE_ANY_OP - -#if defined(LZO_TEST_DECOMPRESS_OVERRUN_INPUT) -# if (LZO_TEST_DECOMPRESS_OVERRUN_INPUT >= 1) -# define TEST_IP (ip < ip_end) -# endif -# if (LZO_TEST_DECOMPRESS_OVERRUN_INPUT >= 2) -# define NEED_IP(x) \ - if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun -# endif -#endif - -#if defined(LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT) -# if (LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT >= 1) -# define TEST_OP (op <= op_end) -# endif -# if (LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT >= 2) -# undef TEST_OP -# define NEED_OP(x) \ - if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun -# endif -#endif - -#if defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND) -# define TEST_LOOKBEHIND(m_pos,out) if (m_pos < out) goto lookbehind_overrun -#else -# define TEST_LOOKBEHIND(m_pos,op) ((void) 0) -#endif - -#if !defined(LZO_EOF_CODE) && !defined(TEST_IP) -# define TEST_IP (ip < ip_end) -#endif - -#if defined(TEST_IP) -# define HAVE_TEST_IP -#else -# define TEST_IP 1 -#endif -#if defined(TEST_OP) -# define HAVE_TEST_OP -#else -# define TEST_OP 1 -#endif - -#if defined(NEED_IP) -# define HAVE_NEED_IP -#else -# define NEED_IP(x) ((void) 0) -#endif -#if defined(NEED_OP) -# define HAVE_NEED_OP -#else -# define NEED_OP(x) ((void) 0) -#endif - -#if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) -# define HAVE_ANY_IP -#endif -#if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP) -# define HAVE_ANY_OP -#endif - -#undef __COPY4 -#define __COPY4(dst,src) * (lzo_uint32p)(dst) = * (const lzo_uint32p)(src) - -#undef COPY4 -#if defined(LZO_UNALIGNED_OK_4) -# define COPY4(dst,src) __COPY4(dst,src) -#elif defined(LZO_ALIGNED_OK_4) -# define COPY4(dst,src) __COPY4((lzo_ptr_t)(dst),(lzo_ptr_t)(src)) -#endif - -#if defined(DO_DECOMPRESS) -LZO_PUBLIC(int) -DO_DECOMPRESS ( const lzo_byte *in , lzo_uint in_len, - lzo_byte *out, lzo_uintp out_len, - lzo_voidp wrkmem ) -#endif -{ - register lzo_byte *op; - register const lzo_byte *ip; - register lzo_uint t; -#if defined(COPY_DICT) - lzo_uint m_off; - const lzo_byte *dict_end; -#else - register const lzo_byte *m_pos; -#endif - - const lzo_byte * const ip_end = in + in_len; -#if defined(HAVE_ANY_OP) - lzo_byte * const op_end = out + *out_len; -#endif -#if defined(LZO1Z) - lzo_uint last_m_off = 0; -#endif - - LZO_UNUSED(wrkmem); - -#if defined(__LZO_QUERY_DECOMPRESS) - if (__LZO_IS_DECOMPRESS_QUERY(in,in_len,out,out_len,wrkmem)) - return __LZO_QUERY_DECOMPRESS(in,in_len,out,out_len,wrkmem,0,0); -#endif - -#if defined(COPY_DICT) - if (dict) - { - if (dict_len > M4_MAX_OFFSET) - { - dict += dict_len - M4_MAX_OFFSET; - dict_len = M4_MAX_OFFSET; - } - dict_end = dict + dict_len; - } - else - { - dict_len = 0; - dict_end = NULL; - } -#endif - - *out_len = 0; - - op = out; - ip = in; - - if (*ip > 17) - { - t = *ip++ - 17; - if (t < 4) - goto match_next; - assert(t > 0); NEED_OP(t); NEED_IP(t+1); - do *op++ = *ip++; while (--t > 0); - goto first_literal_run; - } - - while (TEST_IP && TEST_OP) - { - t = *ip++; - if (t >= 16) - goto match; - if (t == 0) - { - NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; - NEED_IP(1); - } - t += 15 + *ip++; - } - assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); -#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) -#if !defined(LZO_UNALIGNED_OK_4) - if (PTR_ALIGNED2_4(op,ip)) - { -#endif - COPY4(op,ip); - op += 4; ip += 4; - if (--t > 0) - { - if (t >= 4) - { - do { - COPY4(op,ip); - op += 4; ip += 4; t -= 4; - } while (t >= 4); - if (t > 0) do *op++ = *ip++; while (--t > 0); - } - else - do *op++ = *ip++; while (--t > 0); - } -#if !defined(LZO_UNALIGNED_OK_4) - } - else -#endif -#endif -#if !defined(LZO_UNALIGNED_OK_4) - { - *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; - do *op++ = *ip++; while (--t > 0); - } -#endif - -first_literal_run: - - t = *ip++; - if (t >= 16) - goto match; -#if defined(COPY_DICT) -#if defined(LZO1Z) - m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); - last_m_off = m_off; -#else - m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2); -#endif - NEED_OP(3); - t = 3; COPY_DICT(t,m_off) -#else -#if defined(LZO1Z) - t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); - m_pos = op - t; - last_m_off = t; -#else - m_pos = op - (1 + M2_MAX_OFFSET); - m_pos -= t >> 2; - m_pos -= *ip++ << 2; -#endif - TEST_LOOKBEHIND(m_pos,out); NEED_OP(3); - *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos; -#endif - goto match_done; - - while (TEST_IP && TEST_OP) - { -match: - if (t >= 64) - { -#if defined(COPY_DICT) -#if defined(LZO1X) - m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3); - t = (t >> 5) - 1; -#elif defined(LZO1Y) - m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2); - t = (t >> 4) - 3; -#elif defined(LZO1Z) - m_off = t & 0x1f; - if (m_off >= 0x1c) - m_off = last_m_off; - else - { - m_off = 1 + (m_off << 6) + (*ip++ >> 2); - last_m_off = m_off; - } - t = (t >> 5) - 1; -#endif -#else -#if defined(LZO1X) - m_pos = op - 1; - m_pos -= (t >> 2) & 7; - m_pos -= *ip++ << 3; - t = (t >> 5) - 1; -#elif defined(LZO1Y) - m_pos = op - 1; - m_pos -= (t >> 2) & 3; - m_pos -= *ip++ << 2; - t = (t >> 4) - 3; -#elif defined(LZO1Z) - { - lzo_uint off = t & 0x1f; - m_pos = op; - if (off >= 0x1c) - { - assert(last_m_off > 0); - m_pos -= last_m_off; - } - else - { - off = 1 + (off << 6) + (*ip++ >> 2); - m_pos -= off; - last_m_off = off; - } - } - t = (t >> 5) - 1; -#endif - TEST_LOOKBEHIND(m_pos,out); assert(t > 0); NEED_OP(t+3-1); - goto copy_match; -#endif - } - else if (t >= 32) - { - t &= 31; - if (t == 0) - { - NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; - NEED_IP(1); - } - t += 31 + *ip++; - } -#if defined(COPY_DICT) -#if defined(LZO1Z) - m_off = 1 + (ip[0] << 6) + (ip[1] >> 2); - last_m_off = m_off; -#else - m_off = 1 + (ip[0] >> 2) + (ip[1] << 6); -#endif -#else -#if defined(LZO1Z) - { - lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2); - m_pos = op - off; - last_m_off = off; - } -#elif defined(LZO_UNALIGNED_OK_2) && (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN) - m_pos = op - 1; - m_pos -= (* (const lzo_ushortp) ip) >> 2; -#else - m_pos = op - 1; - m_pos -= (ip[0] >> 2) + (ip[1] << 6); -#endif -#endif - ip += 2; - } - else if (t >= 16) - { -#if defined(COPY_DICT) - m_off = (t & 8) << 11; -#else - m_pos = op; - m_pos -= (t & 8) << 11; -#endif - t &= 7; - if (t == 0) - { - NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; - NEED_IP(1); - } - t += 7 + *ip++; - } -#if defined(COPY_DICT) -#if defined(LZO1Z) - m_off += (ip[0] << 6) + (ip[1] >> 2); -#else - m_off += (ip[0] >> 2) + (ip[1] << 6); -#endif - ip += 2; - if (m_off == 0) - goto eof_found; - m_off += 0x4000; -#if defined(LZO1Z) - last_m_off = m_off; -#endif -#else -#if defined(LZO1Z) - m_pos -= (ip[0] << 6) + (ip[1] >> 2); -#elif defined(LZO_UNALIGNED_OK_2) && (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN) - m_pos -= (* (const lzo_ushortp) ip) >> 2; -#else - m_pos -= (ip[0] >> 2) + (ip[1] << 6); -#endif - ip += 2; - if (m_pos == op) - goto eof_found; - m_pos -= 0x4000; -#if defined(LZO1Z) - last_m_off = op - m_pos; -#endif -#endif - } - else - { -#if defined(COPY_DICT) -#if defined(LZO1Z) - m_off = 1 + (t << 6) + (*ip++ >> 2); - last_m_off = m_off; -#else - m_off = 1 + (t >> 2) + (*ip++ << 2); -#endif - NEED_OP(2); - t = 2; COPY_DICT(t,m_off) -#else -#if defined(LZO1Z) - t = 1 + (t << 6) + (*ip++ >> 2); - m_pos = op - t; - last_m_off = t; -#else - m_pos = op - 1; - m_pos -= t >> 2; - m_pos -= *ip++ << 2; -#endif - TEST_LOOKBEHIND(m_pos,out); NEED_OP(2); - *op++ = *m_pos++; *op++ = *m_pos; -#endif - goto match_done; - } - -#if defined(COPY_DICT) - - NEED_OP(t+3-1); - t += 3-1; COPY_DICT(t,m_off) - -#else - - TEST_LOOKBEHIND(m_pos,out); assert(t > 0); NEED_OP(t+3-1); -#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) -#if !defined(LZO_UNALIGNED_OK_4) - if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) - { - assert((op - m_pos) >= 4); -#else - if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) - { -#endif - COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4 - (3 - 1); - do { - COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4; - } while (t >= 4); - if (t > 0) do *op++ = *m_pos++; while (--t > 0); - } - else -#endif - { -copy_match: - *op++ = *m_pos++; *op++ = *m_pos++; - do *op++ = *m_pos++; while (--t > 0); - } - -#endif - -match_done: -#if defined(LZO1Z) - t = ip[-1] & 3; -#else - t = ip[-2] & 3; -#endif - if (t == 0) - break; - -match_next: - assert(t > 0); NEED_OP(t); NEED_IP(t+1); - do *op++ = *ip++; while (--t > 0); - t = *ip++; - } - } - -#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) - *out_len = op - out; - return LZO_E_EOF_NOT_FOUND; -#endif - -eof_found: - assert(t == 1); - *out_len = op - out; - return (ip == ip_end ? LZO_E_OK : - (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); - -#if defined(HAVE_NEED_IP) -input_overrun: - *out_len = op - out; - return LZO_E_INPUT_OVERRUN; -#endif - -#if defined(HAVE_NEED_OP) -output_overrun: - *out_len = op - out; - return LZO_E_OUTPUT_OVERRUN; -#endif - -#if defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND) -lookbehind_overrun: - *out_len = op - out; - return LZO_E_LOOKBEHIND_OVERRUN; -#endif -} - -#define LZO_TEST_DECOMPRESS_OVERRUN -#undef DO_DECOMPRESS -#define DO_DECOMPRESS lzo1x_decompress_safe - -#if defined(LZO_TEST_DECOMPRESS_OVERRUN) -# if !defined(LZO_TEST_DECOMPRESS_OVERRUN_INPUT) -# define LZO_TEST_DECOMPRESS_OVERRUN_INPUT 2 -# endif -# if !defined(LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT) -# define LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT 2 -# endif -# if !defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND) -# define LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND -# endif -#endif - -#undef TEST_IP -#undef TEST_OP -#undef TEST_LOOKBEHIND -#undef NEED_IP -#undef NEED_OP -#undef HAVE_TEST_IP -#undef HAVE_TEST_OP -#undef HAVE_NEED_IP -#undef HAVE_NEED_OP -#undef HAVE_ANY_IP -#undef HAVE_ANY_OP - -#if defined(LZO_TEST_DECOMPRESS_OVERRUN_INPUT) -# if (LZO_TEST_DECOMPRESS_OVERRUN_INPUT >= 1) -# define TEST_IP (ip < ip_end) -# endif -# if (LZO_TEST_DECOMPRESS_OVERRUN_INPUT >= 2) -# define NEED_IP(x) \ - if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun -# endif -#endif - -#if defined(LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT) -# if (LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT >= 1) -# define TEST_OP (op <= op_end) -# endif -# if (LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT >= 2) -# undef TEST_OP -# define NEED_OP(x) \ - if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun -# endif -#endif - -#if defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND) -# define TEST_LOOKBEHIND(m_pos,out) if (m_pos < out) goto lookbehind_overrun -#else -# define TEST_LOOKBEHIND(m_pos,op) ((void) 0) -#endif - -#if !defined(LZO_EOF_CODE) && !defined(TEST_IP) -# define TEST_IP (ip < ip_end) -#endif - -#if defined(TEST_IP) -# define HAVE_TEST_IP -#else -# define TEST_IP 1 -#endif -#if defined(TEST_OP) -# define HAVE_TEST_OP -#else -# define TEST_OP 1 -#endif - -#if defined(NEED_IP) -# define HAVE_NEED_IP -#else -# define NEED_IP(x) ((void) 0) -#endif -#if defined(NEED_OP) -# define HAVE_NEED_OP -#else -# define NEED_OP(x) ((void) 0) -#endif - -#if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) -# define HAVE_ANY_IP -#endif -#if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP) -# define HAVE_ANY_OP -#endif - -#undef __COPY4 -#define __COPY4(dst,src) * (lzo_uint32p)(dst) = * (const lzo_uint32p)(src) - -#undef COPY4 -#if defined(LZO_UNALIGNED_OK_4) -# define COPY4(dst,src) __COPY4(dst,src) -#elif defined(LZO_ALIGNED_OK_4) -# define COPY4(dst,src) __COPY4((lzo_ptr_t)(dst),(lzo_ptr_t)(src)) -#endif - -#if defined(DO_DECOMPRESS) -LZO_PUBLIC(int) -DO_DECOMPRESS ( const lzo_byte *in , lzo_uint in_len, - lzo_byte *out, lzo_uintp out_len, - lzo_voidp wrkmem ) -#endif -{ - register lzo_byte *op; - register const lzo_byte *ip; - register lzo_uint t; -#if defined(COPY_DICT) - lzo_uint m_off; - const lzo_byte *dict_end; -#else - register const lzo_byte *m_pos; -#endif - - const lzo_byte * const ip_end = in + in_len; -#if defined(HAVE_ANY_OP) - lzo_byte * const op_end = out + *out_len; -#endif -#if defined(LZO1Z) - lzo_uint last_m_off = 0; -#endif - - LZO_UNUSED(wrkmem); - -#if defined(__LZO_QUERY_DECOMPRESS) - if (__LZO_IS_DECOMPRESS_QUERY(in,in_len,out,out_len,wrkmem)) - return __LZO_QUERY_DECOMPRESS(in,in_len,out,out_len,wrkmem,0,0); -#endif - -#if defined(COPY_DICT) - if (dict) - { - if (dict_len > M4_MAX_OFFSET) - { - dict += dict_len - M4_MAX_OFFSET; - dict_len = M4_MAX_OFFSET; - } - dict_end = dict + dict_len; - } - else - { - dict_len = 0; - dict_end = NULL; - } -#endif - - *out_len = 0; - - op = out; - ip = in; - - if (*ip > 17) - { - t = *ip++ - 17; - if (t < 4) - goto match_next; - assert(t > 0); NEED_OP(t); NEED_IP(t+1); - do *op++ = *ip++; while (--t > 0); - goto first_literal_run; - } - - while (TEST_IP && TEST_OP) - { - t = *ip++; - if (t >= 16) - goto match; - if (t == 0) - { - NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; - NEED_IP(1); - } - t += 15 + *ip++; - } - assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); -#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) -#if !defined(LZO_UNALIGNED_OK_4) - if (PTR_ALIGNED2_4(op,ip)) - { -#endif - COPY4(op,ip); - op += 4; ip += 4; - if (--t > 0) - { - if (t >= 4) - { - do { - COPY4(op,ip); - op += 4; ip += 4; t -= 4; - } while (t >= 4); - if (t > 0) do *op++ = *ip++; while (--t > 0); - } - else - do *op++ = *ip++; while (--t > 0); - } -#if !defined(LZO_UNALIGNED_OK_4) - } - else -#endif -#endif -#if !defined(LZO_UNALIGNED_OK_4) - { - *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; - do *op++ = *ip++; while (--t > 0); - } -#endif - -first_literal_run: - - t = *ip++; - if (t >= 16) - goto match; -#if defined(COPY_DICT) -#if defined(LZO1Z) - m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); - last_m_off = m_off; -#else - m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2); -#endif - NEED_OP(3); - t = 3; COPY_DICT(t,m_off) -#else -#if defined(LZO1Z) - t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); - m_pos = op - t; - last_m_off = t; -#else - m_pos = op - (1 + M2_MAX_OFFSET); - m_pos -= t >> 2; - m_pos -= *ip++ << 2; -#endif - TEST_LOOKBEHIND(m_pos,out); NEED_OP(3); - *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos; -#endif - goto match_done; - - while (TEST_IP && TEST_OP) - { -match: - if (t >= 64) - { -#if defined(COPY_DICT) -#if defined(LZO1X) - m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3); - t = (t >> 5) - 1; -#elif defined(LZO1Y) - m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2); - t = (t >> 4) - 3; -#elif defined(LZO1Z) - m_off = t & 0x1f; - if (m_off >= 0x1c) - m_off = last_m_off; - else - { - m_off = 1 + (m_off << 6) + (*ip++ >> 2); - last_m_off = m_off; - } - t = (t >> 5) - 1; -#endif -#else -#if defined(LZO1X) - m_pos = op - 1; - m_pos -= (t >> 2) & 7; - m_pos -= *ip++ << 3; - t = (t >> 5) - 1; -#elif defined(LZO1Y) - m_pos = op - 1; - m_pos -= (t >> 2) & 3; - m_pos -= *ip++ << 2; - t = (t >> 4) - 3; -#elif defined(LZO1Z) - { - lzo_uint off = t & 0x1f; - m_pos = op; - if (off >= 0x1c) - { - assert(last_m_off > 0); - m_pos -= last_m_off; - } - else - { - off = 1 + (off << 6) + (*ip++ >> 2); - m_pos -= off; - last_m_off = off; - } - } - t = (t >> 5) - 1; -#endif - TEST_LOOKBEHIND(m_pos,out); assert(t > 0); NEED_OP(t+3-1); - goto copy_match; -#endif - } - else if (t >= 32) - { - t &= 31; - if (t == 0) - { - NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; - NEED_IP(1); - } - t += 31 + *ip++; - } -#if defined(COPY_DICT) -#if defined(LZO1Z) - m_off = 1 + (ip[0] << 6) + (ip[1] >> 2); - last_m_off = m_off; -#else - m_off = 1 + (ip[0] >> 2) + (ip[1] << 6); -#endif -#else -#if defined(LZO1Z) - { - lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2); - m_pos = op - off; - last_m_off = off; - } -#elif defined(LZO_UNALIGNED_OK_2) && (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN) - m_pos = op - 1; - m_pos -= (* (const lzo_ushortp) ip) >> 2; -#else - m_pos = op - 1; - m_pos -= (ip[0] >> 2) + (ip[1] << 6); -#endif -#endif - ip += 2; - } - else if (t >= 16) - { -#if defined(COPY_DICT) - m_off = (t & 8) << 11; -#else - m_pos = op; - m_pos -= (t & 8) << 11; -#endif - t &= 7; - if (t == 0) - { - NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; - NEED_IP(1); - } - t += 7 + *ip++; - } -#if defined(COPY_DICT) -#if defined(LZO1Z) - m_off += (ip[0] << 6) + (ip[1] >> 2); -#else - m_off += (ip[0] >> 2) + (ip[1] << 6); -#endif - ip += 2; - if (m_off == 0) - goto eof_found; - m_off += 0x4000; -#if defined(LZO1Z) - last_m_off = m_off; -#endif -#else -#if defined(LZO1Z) - m_pos -= (ip[0] << 6) + (ip[1] >> 2); -#elif defined(LZO_UNALIGNED_OK_2) && (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN) - m_pos -= (* (const lzo_ushortp) ip) >> 2; -#else - m_pos -= (ip[0] >> 2) + (ip[1] << 6); -#endif - ip += 2; - if (m_pos == op) - goto eof_found; - m_pos -= 0x4000; -#if defined(LZO1Z) - last_m_off = op - m_pos; -#endif -#endif - } - else - { -#if defined(COPY_DICT) -#if defined(LZO1Z) - m_off = 1 + (t << 6) + (*ip++ >> 2); - last_m_off = m_off; -#else - m_off = 1 + (t >> 2) + (*ip++ << 2); -#endif - NEED_OP(2); - t = 2; COPY_DICT(t,m_off) -#else -#if defined(LZO1Z) - t = 1 + (t << 6) + (*ip++ >> 2); - m_pos = op - t; - last_m_off = t; -#else - m_pos = op - 1; - m_pos -= t >> 2; - m_pos -= *ip++ << 2; -#endif - TEST_LOOKBEHIND(m_pos,out); NEED_OP(2); - *op++ = *m_pos++; *op++ = *m_pos; -#endif - goto match_done; - } - -#if defined(COPY_DICT) - - NEED_OP(t+3-1); - t += 3-1; COPY_DICT(t,m_off) - -#else - - TEST_LOOKBEHIND(m_pos,out); assert(t > 0); NEED_OP(t+3-1); -#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) -#if !defined(LZO_UNALIGNED_OK_4) - if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) - { - assert((op - m_pos) >= 4); -#else - if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) - { -#endif - COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4 - (3 - 1); - do { - COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4; - } while (t >= 4); - if (t > 0) do *op++ = *m_pos++; while (--t > 0); - } - else -#endif - { -copy_match: - *op++ = *m_pos++; *op++ = *m_pos++; - do *op++ = *m_pos++; while (--t > 0); - } - -#endif - -match_done: -#if defined(LZO1Z) - t = ip[-1] & 3; -#else - t = ip[-2] & 3; -#endif - if (t == 0) - break; - -match_next: - assert(t > 0); NEED_OP(t); NEED_IP(t+1); - do *op++ = *ip++; while (--t > 0); - t = *ip++; - } - } - -#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) - *out_len = op - out; - return LZO_E_EOF_NOT_FOUND; -#endif - -eof_found: - assert(t == 1); - *out_len = op - out; - return (ip == ip_end ? LZO_E_OK : - (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); - -#if defined(HAVE_NEED_IP) -input_overrun: - *out_len = op - out; - return LZO_E_INPUT_OVERRUN; -#endif - -#if defined(HAVE_NEED_OP) -output_overrun: - *out_len = op - out; - return LZO_E_OUTPUT_OVERRUN; -#endif - -#if defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND) -lookbehind_overrun: - *out_len = op - out; - return LZO_E_LOOKBEHIND_OVERRUN; -#endif -} - -/***** End of minilzo.c *****/ - diff --git a/game/src/minilzo.h b/game/src/minilzo.h deleted file mode 100644 index 7715a4c..0000000 --- a/game/src/minilzo.h +++ /dev/null @@ -1,100 +0,0 @@ -/* minilzo.h -- mini subset of the LZO real-time data compression library - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library 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 2 of - the License, or (at your option) any later version. - - The LZO library 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 the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Markus F.X.J. Oberhumer - -http://www.oberhumer.com/opensource/lzo/ - */ - -/* - * NOTE: - * the full LZO package can be found at - * http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __MINILZO_H -#define __MINILZO_H - -#define MINILZO_VERSION 0x1080 - -#ifdef __LZOCONF_H -# error "you cannot use both LZO and miniLZO" -#endif - -#undef LZO_HAVE_CONFIG_H -#include "lzo/lzoconf.h" - -#if !defined(LZO_VERSION) || (LZO_VERSION != MINILZO_VERSION) -# error "version mismatch in header files" -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - - - /*********************************************************************** - // - ************************************************************************/ - - /* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS -#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) -#define LZO1X_MEM_DECOMPRESS (0) - - - /* compression */ - LZO_EXTERN(int) - lzo1x_1_compress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - /* decompression */ - LZO_EXTERN(int) - lzo1x_decompress ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - /* safe decompression with overrun testing */ - LZO_EXTERN(int) - lzo1x_decompress_safe ( const lzo_byte *src, lzo_uint src_len, - lzo_byte *dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - diff --git a/game/src/over9refine.h b/game/src/over9refine.h index 9314d2b..2352184 100644 --- a/game/src/over9refine.h +++ b/game/src/over9refine.h @@ -2,12 +2,12 @@ #ifndef OVER_9_REFINE_MANAGER_H_ #define OVER_9_REFINE_MANAGER_H_ -#include +#include class COver9RefineManager : public singleton { private : - typedef boost::unordered_map OVER9ITEM_MAP; + typedef std::unordered_map OVER9ITEM_MAP; OVER9ITEM_MAP m_mapItem; public : diff --git a/game/src/p2p.cpp b/game/src/p2p.cpp index 0990dca..7b09a6e 100644 --- a/game/src/p2p.cpp +++ b/game/src/p2p.cpp @@ -53,7 +53,7 @@ void P2P_MANAGER::Boot(LPDESC d) void P2P_MANAGER::FlushOutput() { - TR1_NS::unordered_set::iterator it = m_set_pkPeers.begin(); + std::unordered_set::iterator it = m_set_pkPeers.begin(); while (it != m_set_pkPeers.end()) { @@ -91,7 +91,7 @@ void P2P_MANAGER::RegisterConnector(LPDESC d) void P2P_MANAGER::UnregisterConnector(LPDESC d) { - TR1_NS::unordered_set::iterator it = m_set_pkPeers.find(d); + std::unordered_set::iterator it = m_set_pkPeers.find(d); if (it != m_set_pkPeers.end()) { @@ -117,7 +117,7 @@ void P2P_MANAGER::EraseUserByDesc(LPDESC d) void P2P_MANAGER::Send(const void * c_pvData, int iSize, LPDESC except) { - TR1_NS::unordered_set::iterator it = m_set_pkPeers.begin(); + std::unordered_set::iterator it = m_set_pkPeers.begin(); while (it != m_set_pkPeers.end()) { @@ -271,7 +271,7 @@ int P2P_MANAGER::GetDescCount() void P2P_MANAGER::GetP2PHostNames(std::string& hostNames) { - TR1_NS::unordered_set::iterator it = m_set_pkPeers.begin(); + std::unordered_set::iterator it = m_set_pkPeers.begin(); std::ostringstream oss(std::ostringstream::out); diff --git a/game/src/p2p.h b/game/src/p2p.h index f1f1043..a4c0baa 100644 --- a/game/src/p2p.h +++ b/game/src/p2p.h @@ -2,7 +2,7 @@ #ifndef P2P_MANAGER_H_ #define P2P_MANAGER_H_ -#include +#include #include "input.h" #include @@ -57,10 +57,10 @@ class P2P_MANAGER : public singleton CInputProcessor * m_pkInputProcessor; int m_iHandleCount; - typedef boost::unordered_map TCCIMap; - typedef boost::unordered_map TPIDCCIMap; + typedef std::unordered_map TCCIMap; + typedef std::unordered_map TPIDCCIMap; - TR1_NS::unordered_set m_set_pkPeers; + std::unordered_set m_set_pkPeers; TCCIMap m_map_pkCCI; TPIDCCIMap m_map_dwPID_pkCCI; int m_aiEmpireUserCount[EMPIRE_MAX_NUM]; diff --git a/game/src/packet.h b/game/src/packet.h index 4b5c3d8..a880c53 100644 --- a/game/src/packet.h +++ b/game/src/packet.h @@ -79,7 +79,6 @@ enum HEADER_CG_MARK_UPLOAD = 102, HEADER_CG_MARK_IDXLIST = 104, - HEADER_CG_HACK = 105, HEADER_CG_CHANGE_NAME = 106, HEADER_CG_LOGIN2 = 109, HEADER_CG_DUNGEON = 110, @@ -104,8 +103,6 @@ enum //enumÀ» º°µµ·Î ±¸º°À» ÇÏ´ø°¡. ¾Æ´Ô namepsace·Î ±¸º°À» ÇÏ´ø°¡.. //Á¤¸» packet generator±îÁö´Â ¹Ù¶óÁöµµ ¾Ê´Â´Ù. ÀÌ·± ¾¾XX //ÀÌ·¯´Ù°¡ ¼ýÀÚ °ãÄ¡¸é ´©°¡ Ã¥ÀÓÁö´Âµ¥??? - HEADER_CG_HS_ACK = 203, - HEADER_CG_XTRAP_ACK = 204, HEADER_CG_DRAGON_SOUL_REFINE = 205, HEADER_CG_STATE_CHECKER = 206, @@ -288,9 +285,6 @@ enum HEADER_GC_REQUEST_PASSPOD = 202, HEADER_GC_REQUEST_PASSPOD_FAILED = 203, - HEADER_GC_HS_REQUEST = 204, - HEADER_GC_XTRAP_CS1_REQUEST = 205, - HEADER_GC_SPECIFIC_EFFECT = 208, HEADER_GC_DRAGON_SOUL_REFINE = 209, @@ -1895,12 +1889,6 @@ typedef struct command_give_item BYTE byItemCount; } TPacketCGGiveItem; -typedef struct SPacketCGHack -{ - BYTE bHeader; - char szBuf[255 + 1]; -} TPacketCGHack; - // SubHeader - Dungeon enum { diff --git a/game/src/packet_info.cpp b/game/src/packet_info.cpp index 3af506f..a3bf012 100644 --- a/game/src/packet_info.cpp +++ b/game/src/packet_info.cpp @@ -2,8 +2,6 @@ #include #include "constants.h" #include "packet_info.h" -#include "HackShield_Impl.h" -#include "XTrapManager.h" CPacketInfo::CPacketInfo() : m_pCurrentPacket(NULL), m_dwStartTime(0) @@ -210,7 +208,6 @@ CPacketInfoCG::CPacketInfoCG() Set(HEADER_CG_FISHING, sizeof(TPacketCGFishing), "Fishing", true); Set(HEADER_CG_ITEM_GIVE, sizeof(TPacketCGGiveItem), "ItemGive", true); - Set(HEADER_CG_HACK, sizeof(TPacketCGHack), "Hack", true); Set(HEADER_CG_MYSHOP, sizeof(TPacketCGMyShop), "MyShop", true); Set(HEADER_CG_REFINE, sizeof(TPacketCGRefine), "Refine", true); @@ -224,8 +221,6 @@ CPacketInfoCG::CPacketInfoCG() Set(HEADER_CG_SCRIPT_SELECT_ITEM, sizeof(TPacketCGScriptSelectItem), "ScriptSelectItem", true); Set(HEADER_CG_PASSPOD_ANSWER, sizeof(TPacketCGPasspod), "PasspodAnswer", true); - Set(HEADER_CG_HS_ACK, sizeof(TPacketGCHSCheck), "HackShieldResponse", false); - Set(HEADER_CG_XTRAP_ACK, sizeof(TPacketXTrapCSVerify), "XTrapResponse", false); Set(HEADER_CG_DRAGON_SOUL_REFINE, sizeof(TPacketCGDragonSoulRefine), "DragonSoulRefine", false); Set(HEADER_CG_STATE_CHECKER, sizeof(BYTE), "ServerStateCheck", false); diff --git a/game/src/passpod.cpp b/game/src/passpod.cpp index afe4050..f94e2fc 100644 --- a/game/src/passpod.cpp +++ b/game/src/passpod.cpp @@ -51,12 +51,12 @@ int CPasspod::ConfirmPasspod( const char * account, const char * passpod ) snprintf( szRequest, sizeof(szRequest), "username=%s&systemname=%s&passpod=%s&algname=%s", account, servername, passpod, algname ); snprintf( szResult, sizeof(szResult), "POST %s%s HTTP/1.0\r\n", posspod_server, auth ); snprintf( szTmp, sizeof(szTmp), "Host: %s\r\n", "218.99.6.103" ); - strlcat( szResult, szTmp, sizeof(szResult) ); - strlcat( szResult, "Content-type: application/x-www-form-urlencoded\r\n", sizeof(szResult) ); + strncat( szResult, szTmp, sizeof(szResult) ); + strncat( szResult, "Content-type: application/x-www-form-urlencoded\r\n", sizeof(szResult) ); snprintf( szTmp, sizeof(szTmp), "Content-length: %d\r\n", strlen(szRequest)); - strlcat( szResult, szTmp, sizeof(szResult) ); - strlcat( szResult, "Connection: Close\r\n\r\n", sizeof(szResult) ); - strlcat( szResult, szRequest, sizeof(szResult) ); + strncat( szResult, szTmp, sizeof(szResult) ); + strncat( szResult, "Connection: Close\r\n\r\n", sizeof(szResult) ); + strncat( szResult, szRequest, sizeof(szResult) ); if ( !Connect( NULL ) ) { diff --git a/game/src/polymorph.cpp b/game/src/polymorph.cpp index b875346..32c4111 100644 --- a/game/src/polymorph.cpp +++ b/game/src/polymorph.cpp @@ -13,7 +13,7 @@ CPolymorphUtils::CPolymorphUtils() POLYMORPH_BONUS_TYPE CPolymorphUtils::GetBonusType(DWORD dwVnum) { - boost::unordered_map::iterator iter; + std::unordered_map::iterator iter; iter = m_mapSPDType.find(dwVnum); diff --git a/game/src/polymorph.h b/game/src/polymorph.h index 6305d40..ec8d381 100644 --- a/game/src/polymorph.h +++ b/game/src/polymorph.h @@ -2,7 +2,7 @@ #ifndef __POLYMORPH_UTILS__ #define __POLYMORPH_UTILS__ -#include +#include #define POLYMORPH_SKILL_ID 129 #define POLYMORPH_BOOK_ID 50322 @@ -18,9 +18,9 @@ enum POLYMORPH_BONUS_TYPE class CPolymorphUtils : public singleton { private : - boost::unordered_map m_mapSPDType; - boost::unordered_map m_mapATKType; - boost::unordered_map m_mapDEFType; + std::unordered_map m_mapSPDType; + std::unordered_map m_mapATKType; + std::unordered_map m_mapDEFType; public : CPolymorphUtils(); diff --git a/game/src/pool.h b/game/src/pool.h index 90bfd41..77a0658 100644 --- a/game/src/pool.h +++ b/game/src/pool.h @@ -232,7 +232,7 @@ public: pool->Release(p); } private: - typedef TR1_NS::unordered_map PoolMapType; + typedef std::unordered_map PoolMapType; PoolMapType pools_; }; diff --git a/game/src/profiler.h b/game/src/profiler.h index 58a9b37..b074c46 100644 --- a/game/src/profiler.h +++ b/game/src/profiler.h @@ -1,7 +1,7 @@ #ifndef __INC_METIN_II_GAME_PROFILER_H__ #define __INC_METIN_II_GAME_PROFILER_H__ -#include +#include class CProfiler : public singleton { @@ -50,7 +50,7 @@ class CProfiler : public singleton } }; - typedef boost::unordered_map TProfileAccumDataMap; + typedef std::unordered_map TProfileAccumDataMap; public: CProfiler() diff --git a/game/src/pvp.cpp b/game/src/pvp.cpp index 0c656f2..fd36701 100644 --- a/game/src/pvp.cpp +++ b/game/src/pvp.cpp @@ -239,7 +239,7 @@ void CPVPManager::ConnectEx(LPCHARACTER pkChr, bool bDisconnect) DWORD dwVID = bDisconnect ? 0 : pkChr->GetVID(); - TR1_NS::unordered_set::iterator it2 = it->second.begin(); + std::unordered_set::iterator it2 = it->second.begin(); while (it2 != it->second.end()) { @@ -266,7 +266,7 @@ void CPVPManager::GiveUp(LPCHARACTER pkChr, DWORD dwKillerPID) // This method is return; sys_log(1, "PVPManager::Dead %d", pkChr->GetPlayerID()); - TR1_NS::unordered_set::iterator it2 = it->second.begin(); + std::unordered_set::iterator it2 = it->second.begin(); while (it2 != it->second.end()) { @@ -311,7 +311,7 @@ bool CPVPManager::Dead(LPCHARACTER pkChr, DWORD dwKillerPID) bool found = false; sys_log(1, "PVPManager::Dead %d", pkChr->GetPlayerID()); - TR1_NS::unordered_set::iterator it2 = it->second.begin(); + std::unordered_set::iterator it2 = it->second.begin(); while (it2 != it->second.end()) { diff --git a/game/src/pvp.h b/game/src/pvp.h index 135322b..116c632 100644 --- a/game/src/pvp.h +++ b/game/src/pvp.h @@ -49,7 +49,7 @@ class CPVP class CPVPManager : public singleton { - typedef std::map > CPVPSetMap; + typedef std::map > CPVPSetMap; public: CPVPManager(); diff --git a/game/src/questlua_building.cpp b/game/src/questlua_building.cpp index 38bc1de..24c84b0 100644 --- a/game/src/questlua_building.cpp +++ b/game/src/questlua_building.cpp @@ -97,7 +97,7 @@ namespace quest lua_pushboolean(L, false); */ - std::auto_ptr pmsg(DBManager::instance().DirectQuery("SELECT COUNT(*) FROM land%s WHERE guild_id = %d", get_table_postfix(), (DWORD)lua_tonumber(L,1))); + std::unique_ptr pmsg(DBManager::instance().DirectQuery("SELECT COUNT(*) FROM land%s WHERE guild_id = %d", get_table_postfix(), (DWORD)lua_tonumber(L,1))); if ( pmsg->Get()->uiNumRows > 0 ) { diff --git a/game/src/questlua_pc.cpp b/game/src/questlua_pc.cpp index 9b36702..021e37d 100644 --- a/game/src/questlua_pc.cpp +++ b/game/src/questlua_pc.cpp @@ -2100,7 +2100,7 @@ teleport_area: char szQuery[1024]; snprintf(szQuery, sizeof(szQuery), "SELECT COUNT(*) FROM player%s WHERE name='%s'", get_table_postfix(), szName); - std::auto_ptr pmsg(DBManager::instance().DirectQuery(szQuery)); + std::unique_ptr pmsg(DBManager::instance().DirectQuery(szQuery)); if ( pmsg->Get()->uiNumRows > 0 ) { diff --git a/game/src/questmanager.h b/game/src/questmanager.h index 4bf4600..b946b53 100644 --- a/game/src/questmanager.h +++ b/game/src/questmanager.h @@ -1,7 +1,7 @@ #ifndef __METIN2_SERVER_QUEST_MANAGER__ #define __METIN2_SERVER_QUEST_MANAGER__ -#include +#include #include "questnpc.h" @@ -234,8 +234,8 @@ namespace quest } }; - typedef boost::unordered_map THashMapQuestName; - typedef boost::unordered_map > THashMapQuestStartScript; + typedef std::unordered_map THashMapQuestName; + typedef std::unordered_map > THashMapQuestStartScript; THashMapQuestName m_hmQuestName; THashMapQuestStartScript m_hmQuestStartScript; diff --git a/game/src/sectree_manager.cpp b/game/src/sectree_manager.cpp index 7ef83ac..41fac75 100644 --- a/game/src/sectree_manager.cpp +++ b/game/src/sectree_manager.cpp @@ -465,8 +465,8 @@ bool SECTREE_MANAGER::LoadAttribute(LPSECTREE_MAP pkMapSectree, const char * c_p int maxMemSize = LZOManager::instance().GetMaxCompressedSize(sizeof(DWORD) * (SECTREE_SIZE / CELL_SIZE) * (SECTREE_SIZE / CELL_SIZE)); - unsigned int uiSize; - unsigned int uiDestSize; + size_t uiSize; + lzo_uint uiDestSize; #ifndef _MSC_VER BYTE abComp[maxMemSize]; diff --git a/game/src/sectree_manager.h b/game/src/sectree_manager.h index fd52cb7..aab7c99 100644 --- a/game/src/sectree_manager.h +++ b/game/src/sectree_manager.h @@ -225,7 +225,7 @@ class SECTREE_MANAGER : public singleton std::map > m_mapNPCPosition; // Circular private map indexing - typedef TR1_NS::unordered_map PrivateIndexMapType; + typedef std::unordered_map PrivateIndexMapType; PrivateIndexMapType next_private_index_map_; }; diff --git a/game/src/shop.h b/game/src/shop.h index 5c174cb..15713b9 100644 --- a/game/src/shop.h +++ b/game/src/shop.h @@ -68,7 +68,7 @@ class CShop CGrid * m_pGrid; - typedef TR1_NS::unordered_map GuestMapType; + typedef std::unordered_map GuestMapType; GuestMapType m_map_guest; std::vector m_itemVector; // ÀÌ »óÁ¡¿¡¼­ Ãë±ÞÇÏ´Â ¹°°Çµé diff --git a/game/src/skill.h b/game/src/skill.h index 6ee1810..94faf87 100644 --- a/game/src/skill.h +++ b/game/src/skill.h @@ -1,7 +1,7 @@ #ifndef __INC_METIN_II_GAME_CSkillManager_H__ #define __INC_METIN_II_GAME_CSkillManager_H__ -#include "../../libpoly/Poly.h" +#include enum ESkillFlags { diff --git a/game/src/stdafx.h b/game/src/stdafx.h index 7bb9696..53c0548 100644 --- a/game/src/stdafx.h +++ b/game/src/stdafx.h @@ -20,19 +20,11 @@ #include #include #include +#include -#ifdef __GNUC__ #include -#include -#include -#define TR1_NS std::tr1 -#else -#include -#include -#define TR1_NS boost -#define isdigit iswdigit -#define isspace iswspace -#endif +#include +#include #include "typedef.h" #include "locale.hpp" diff --git a/game/src/threeway_war.cpp b/game/src/threeway_war.cpp index 75170cb..5a32ced 100644 --- a/game/src/threeway_war.cpp +++ b/game/src/threeway_war.cpp @@ -245,7 +245,7 @@ void CThreeWayWar::RandomEventMapSet() bool CThreeWayWar::IsRegisteredUser(DWORD PlayerID) const { - boost::unordered_map::const_iterator iter = RegisterUserMap_.find(PlayerID); + std::unordered_map::const_iterator iter = RegisterUserMap_.find(PlayerID); if (iter == RegisterUserMap_.end()) { diff --git a/game/src/threeway_war.h b/game/src/threeway_war.h index 5b257f1..f800978 100644 --- a/game/src/threeway_war.h +++ b/game/src/threeway_war.h @@ -2,7 +2,7 @@ #ifndef THREE_WAY_WAR_EVENT_ #define THREE_WAY_WAR_EVENT_ -#include +#include #include @@ -63,8 +63,8 @@ class CThreeWayWar : public singleton std::vector PassInfoMap_; std::vector SungZiInfoMap_; - boost::unordered_map RegisterUserMap_; - boost::unordered_map ReviveTokenMap_; + std::unordered_map RegisterUserMap_; + std::unordered_map ReviveTokenMap_; }; const char* GetSungziMapPath(); diff --git a/game/src/typedef.h b/game/src/typedef.h index 4467874..e6ce8b7 100644 --- a/game/src/typedef.h +++ b/game/src/typedef.h @@ -30,7 +30,7 @@ typedef CHARACTER* LPCHARACTER; #endif typedef std::vector CHARACTER_VECTOR; typedef std::list CHARACTER_LIST; -typedef TR1_NS::unordered_set CHARACTER_SET; +typedef std::unordered_set CHARACTER_SET; class CItem; #ifdef USE_DEBUG_PTR @@ -58,7 +58,7 @@ typedef DebugPtr LPENTITY; typedef CEntity* LPENTITY; #endif typedef std::vector ENTITY_VECTOR; -typedef TR1_NS::unordered_set ENTITY_SET; +typedef std::unordered_set ENTITY_SET; class SECTREE; #ifdef USE_DEBUG_PTR diff --git a/game/src/update_limit_time.py b/game/src/update_limit_time.py deleted file mode 100644 index fb1e931..0000000 --- a/game/src/update_limit_time.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/local/bin/python -import time - -desc = """#ifndef __LIMIT_TIME__ -#define __LIMIT_TIME__ - -#define ENABLE_LIMIT_TIME -#define GLOBAL_LIMIT_TIME %dUL // %s -#define TIME_OVER_PONG_DOWN_RATE 50000 -#define TIME_OVER_LOGIN_DOWN_RATE 10000 -#endif -""" - -limitTime = time.mktime(time.localtime()) + 3600 * 24 * 180 * 2 - -open("limit_time.h", "w").write(desc % (limitTime, time.asctime(time.localtime(limitTime)))) diff --git a/game/src/version.cpp b/game/src/version.cpp index a5b234a..f042c2b 100644 --- a/game/src/version.cpp +++ b/game/src/version.cpp @@ -7,7 +7,7 @@ void WriteVersion() if (fp) { - fprintf(fp, "emulated game server revision: %s\n", __SVN_VERSION__); + fprintf(fp, "emulated game server\n"); //fprintf(fp, "%s@%s:%s\n", __USER__, __HOSTNAME__, __PWD__); fclose(fp); } diff --git a/libthecore/include/stdafx.h b/libthecore/include/stdafx.h index cfce8bc..21b4a8b 100644 --- a/libthecore/include/stdafx.h +++ b/libthecore/include/stdafx.h @@ -46,7 +46,7 @@ struct timespec #define PATH_MAX _MAX_PATH // C runtime library adjustments -#define strlcat(dst, src, size) strcat_s(dst, size, src) +#define strncat(dst, src, size) strcat_s(dst, size, src) #define strncpy(dst, src, size) strncpy_s(dst, size, src, _TRUNCATE) #define strtoull(str, endptr, base) _strtoui64(str, endptr, base) #define strtof(str, endptr) (float)strtod(str, endptr) diff --git a/libthecore/include/xdirent.h b/libthecore/include/xdirent.h deleted file mode 100644 index a02a0d8..0000000 --- a/libthecore/include/xdirent.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef DIRENT_INCLUDED -#define DIRENT_INCLUDED - -/* - - Declaration of POSIX directory browsing functions and types for Win32. - - Author: Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com) - History: Created March 1997. Updated June 2003. - Rights: See end of file. - -*/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -typedef struct DIR DIR; - -struct dirent -{ - char *d_name; -}; - -DIR *opendir(const char *); -int closedir(DIR *); -struct dirent *readdir(DIR *); -void rewinddir(DIR *); - -/* - - Copyright Kevlin Henney, 1997, 2003. All rights reserved. - - Permission to use, copy, modify, and distribute this software and its - documentation for any purpose is hereby granted without fee, provided - that this copyright and permissions notice appear in all copies and - derivatives. - - This software is supplied "as is" without express or implied warranty. - - But that said, if there are any problems please get in touch. - -*/ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libthecore/include/xgetopt.h b/libthecore/include/xgetopt.h deleted file mode 100644 index f6cf073..0000000 --- a/libthecore/include/xgetopt.h +++ /dev/null @@ -1,23 +0,0 @@ -// XGetopt.h Version 1.2 -// -// Author: Hans Dietrich -// hdietrich2@hotmail.com -// -// This software is released into the public domain. -// You are free to use it in any way you like. -// -// This software is provided "as is" with no expressed -// or implied warranty. I accept no liability for any -// damage or loss of business that this software may cause. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef XGETOPT_H -#define XGETOPT_H - -extern int optind, opterr, optreset; -extern TCHAR *optarg; - -int getopt(int argc, TCHAR *argv[], TCHAR *optstring); - -#endif //XGETOPT_H diff --git a/libthecore/src/xdirent.cpp b/libthecore/src/xdirent.cpp deleted file mode 100644 index 8c2c059..0000000 --- a/libthecore/src/xdirent.cpp +++ /dev/null @@ -1,152 +0,0 @@ -#include "stdafx.h" - -#ifdef __WIN32__ - -/* - - Implementation of POSIX directory browsing functions and types for Win32. - - Author: Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com) - History: Created March 1997. Updated June 2003. - Rights: See end of file. - -*/ - -#include "xdirent.h" - -#include -#include /* _findfirst and _findnext set errno iff they return -1 */ -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -struct DIR -{ - long handle; /* -1 for failed rewind */ - struct _finddata_t info; - struct dirent result; /* d_name null iff first time */ - char *name; /* null-terminated char string */ -}; - -DIR *opendir(const char *name) -{ - DIR *dir = 0; - - if(name && name[0]) - { - size_t base_length = strlen(name); - const char *all = /* search pattern must end with suitable wildcard */ - strchr("/\\", name[base_length - 1]) ? "*" : "/*"; - - if((dir = (DIR *) malloc(sizeof *dir)) != 0 && - (dir->name = (char *) malloc(base_length + strlen(all) + 1)) != 0) - { - strcat(strcpy(dir->name, name), all); - - if((dir->handle = (long) _findfirst(dir->name, &dir->info)) != -1) - { - dir->result.d_name = 0; - } - else /* rollback */ - { - free(dir->name); - free(dir); - dir = 0; - } - } - else /* rollback */ - { - free(dir); - dir = 0; - errno = ENOMEM; - } - } - else - { - errno = EINVAL; - } - - return dir; -} - -int closedir(DIR *dir) -{ - int result = -1; - - if(dir) - { - if(dir->handle != -1) - { - result = _findclose(dir->handle); - } - - free(dir->name); - free(dir); - } - - if(result == -1) /* map all errors to EBADF */ - { - errno = EBADF; - } - - return result; -} - -struct dirent *readdir(DIR *dir) -{ - struct dirent *result = 0; - - if(dir && dir->handle != -1) - { - if(!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1) - { - result = &dir->result; - result->d_name = dir->info.name; - } - } - else - { - errno = EBADF; - } - - return result; -} - -void rewinddir(DIR *dir) -{ - if(dir && dir->handle != -1) - { - _findclose(dir->handle); - dir->handle = (long) _findfirst(dir->name, &dir->info); - dir->result.d_name = 0; - } - else - { - errno = EBADF; - } -} - -#ifdef __cplusplus -} -#endif - -/* - - Copyright Kevlin Henney, 1997, 2003. All rights reserved. - - Permission to use, copy, modify, and distribute this software and its - documentation for any purpose is hereby granted without fee, provided - that this copyright and permissions notice appear in all copies and - derivatives. - - This software is supplied "as is" without express or implied warranty. - - But that said, if there are any problems please get in touch. - -*/ - -#endif // #ifdef __WIN32__ \ No newline at end of file diff --git a/libthecore/src/xgetopt.cpp b/libthecore/src/xgetopt.cpp deleted file mode 100644 index 868831b..0000000 --- a/libthecore/src/xgetopt.cpp +++ /dev/null @@ -1,228 +0,0 @@ -// XGetopt.cpp Version 1.2 -// -// Author: Hans Dietrich -// hdietrich2@hotmail.com -// -// Description: -// XGetopt.cpp implements getopt(), a function to parse command lines. -// -// History -// Version 1.2 - 2003 May 17 -// - Added Unicode support -// -// Version 1.1 - 2002 March 10 -// - Added example to XGetopt.cpp module header -// -// This software is released into the public domain. -// You are free to use it in any way you like. -// -// This software is provided "as is" with no expressed -// or implied warranty. I accept no liability for any -// damage or loss of business that this software may cause. -// -/////////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -// if you are using precompiled headers then include this line: -#include "stdafx.h" -/////////////////////////////////////////////////////////////////////////////// - -#ifdef __WIN32__ - -/////////////////////////////////////////////////////////////////////////////// -// if you are not using precompiled headers then include these lines: -//#include -//#include -//#include -/////////////////////////////////////////////////////////////////////////////// - - -#include "xgetopt.h" - - -/////////////////////////////////////////////////////////////////////////////// -// -// X G e t o p t . c p p -// -// -// NAME -// getopt -- parse command line options -// -// SYNOPSIS -// int getopt(int argc, TCHAR *argv[], TCHAR *optstring) -// -// extern TCHAR *optarg; -// extern int optind; -// -// DESCRIPTION -// The getopt() function parses the command line arguments. Its -// arguments argc and argv are the argument count and array as -// passed into the application on program invocation. In the case -// of Visual C++ programs, argc and argv are available via the -// variables __argc and __argv (double underscores), respectively. -// getopt returns the next option letter in argv that matches a -// letter in optstring. (Note: Unicode programs should use -// __targv instead of __argv. Also, all character and string -// literals should be enclosed in _T( ) ). -// -// optstring is a string of recognized option letters; if a letter -// is followed by a colon, the option is expected to have an argument -// that may or may not be separated from it by white space. optarg -// is set to point to the start of the option argument on return from -// getopt. -// -// Option letters may be combined, e.g., "-ab" is equivalent to -// "-a -b". Option letters are case sensitive. -// -// getopt places in the external variable optind the argv index -// of the next argument to be processed. optind is initialized -// to 0 before the first call to getopt. -// -// When all options have been processed (i.e., up to the first -// non-option argument), getopt returns EOF, optarg will point -// to the argument, and optind will be set to the argv index of -// the argument. If there are no non-option arguments, optarg -// will be set to NULL. -// -// The special option "--" may be used to delimit the end of the -// options; EOF will be returned, and "--" (and everything after it) -// will be skipped. -// -// RETURN VALUE -// For option letters contained in the string optstring, getopt -// will return the option letter. getopt returns a question mark (?) -// when it encounters an option letter not included in optstring. -// EOF is returned when processing is finished. -// -// BUGS -// 1) Long options are not supported. -// 2) The GNU double-colon extension is not supported. -// 3) The environment variable POSIXLY_CORRECT is not supported. -// 4) The + syntax is not supported. -// 5) The automatic permutation of arguments is not supported. -// 6) This implementation of getopt() returns EOF if an error is -// encountered, instead of -1 as the latest standard requires. -// -// EXAMPLE -// BOOL CMyApp::ProcessCommandLine(int argc, TCHAR *argv[]) -// { -// int c; -// -// while ((c = getopt(argc, argv, _T("aBn:"))) != EOF) -// { -// switch (c) -// { -// case _T('a'): -// TRACE(_T("option a\n")); -// // -// // set some flag here -// // -// break; -// -// case _T('B'): -// TRACE( _T("option B\n")); -// // -// // set some other flag here -// // -// break; -// -// case _T('n'): -// TRACE(_T("option n: value=%d\n"), atoi(optarg)); -// // -// // do something with value here -// // -// break; -// -// case _T('?'): -// TRACE(_T("ERROR: illegal option %s\n"), argv[optind-1]); -// return FALSE; -// break; -// -// default: -// TRACE(_T("WARNING: no handler for option %c\n"), c); -// return FALSE; -// break; -// } -// } -// // -// // check for non-option args here -// // -// return TRUE; -// } -// -/////////////////////////////////////////////////////////////////////////////// - -TCHAR *optarg; // global argument pointer -int optind = 0; // global argv index -int optreset = 0; - -int getopt(int argc, TCHAR *argv[], TCHAR *optstring) -{ - static TCHAR *next = NULL; - - if (optreset != 0) { - optind = 0; - } - - if (optind == 0) - next = NULL; - - optarg = NULL; - - if (next == NULL || *next == _T('\0')) - { - if (optind == 0) - optind++; - - if (optind >= argc || argv[optind][0] != _T('-') || argv[optind][1] == _T('\0')) - { - optarg = NULL; - if (optind < argc) - optarg = argv[optind]; - return EOF; - } - - if (_tcscmp(argv[optind], _T("--")) == 0) - { - optind++; - optarg = NULL; - if (optind < argc) - optarg = argv[optind]; - return EOF; - } - - next = argv[optind]; - next++; // skip past - - optind++; - } - - TCHAR c = *next++; - TCHAR *cp = _tcschr(optstring, c); - - if (cp == NULL || c == _T(':')) - return _T('?'); - - cp++; - if (*cp == _T(':')) - { - if (*next != _T('\0')) - { - optarg = next; - next = NULL; - } - else if (optind < argc) - { - optarg = argv[optind]; - optind++; - } - else - { - return _T('?'); - } - } - - return c; -} - -#endif // #ifdef __WIN32__ \ No newline at end of file