From a056345a7b31ff015565ed8024514a068cda438e Mon Sep 17 00:00:00 2001 From: Exynox Date: Sat, 12 Mar 2022 11:39:41 +0200 Subject: [PATCH] Rewrote network stack, started working on porting to 64-bit --- .idea/inspectionProfiles/Project_Default.xml | 19 + common/building.h | 20 +- common/length.h | 3 - common/service.h | 1 - common/singleton.h | 2 +- common/tables.h | 169 +++--- common/utils.h | 39 +- db/src/BlockCountry.cpp | 2 +- db/src/Cache.cpp | 10 +- db/src/ClientManager.cpp | 13 +- db/src/ClientManager.h | 8 +- db/src/ClientManagerPlayer.cpp | 12 +- db/src/DBManager.cpp | 2 +- db/src/DBManager.h | 2 +- db/src/GuildManager.cpp | 12 +- db/src/GuildManager.h | 12 +- db/src/LoginData.cpp | 6 +- db/src/LoginData.h | 8 +- db/src/Peer.cpp | 2 +- db/src/Peer.h | 6 +- game/CMakeLists.txt | 4 + game/src/BlueDragon_Skill.h | 8 +- game/src/DragonLair.cpp | 14 +- game/src/DragonLair.h | 8 +- game/src/DragonSoul.cpp | 2 +- game/src/MarkImage.h | 2 +- game/src/PetSystem.cpp | 10 +- game/src/affect.h | 6 +- game/src/arena.cpp | 26 +- game/src/arena.h | 2 +- game/src/battle.cpp | 6 +- game/src/battle.h | 6 +- game/src/block_country.cpp | 2 +- game/src/building.cpp | 36 +- game/src/building.h | 14 +- game/src/castle.cpp | 12 +- game/src/char.cpp | 80 +-- game/src/char.h | 36 +- game/src/char_affect.cpp | 10 +- game/src/char_battle.cpp | 12 +- game/src/char_dragonsoul.cpp | 2 + game/src/char_horse.cpp | 6 +- game/src/char_item.cpp | 58 +- game/src/char_manager.cpp | 26 +- game/src/char_manager.h | 16 +- game/src/char_skill.cpp | 22 +- game/src/char_state.cpp | 16 +- game/src/cipher.cpp | 401 -------------- game/src/cipher.h | 60 --- game/src/cmd_emotion.cpp | 4 +- game/src/cmd_gm.cpp | 34 +- game/src/config.cpp | 12 +- game/src/config.h | 5 +- game/src/constants.cpp | 6 +- game/src/constants.h | 6 +- game/src/crc32.cpp | 4 +- game/src/crc32.h | 2 +- game/src/cube.cpp | 2 +- game/src/db.cpp | 64 +-- game/src/db.h | 2 +- game/src/desc.cpp | 534 +++++-------------- game/src/desc.h | 72 +-- game/src/desc_client.cpp | 128 +++-- game/src/desc_client.h | 13 +- game/src/desc_manager.cpp | 77 +-- game/src/desc_manager.h | 10 +- game/src/desc_p2p.cpp | 45 +- game/src/desc_p2p.h | 2 +- game/src/dungeon.cpp | 60 +-- game/src/dungeon.h | 34 +- game/src/entity.h | 14 +- game/src/event.cpp | 16 +- game/src/event.h | 12 +- game/src/exchange.cpp | 4 +- game/src/exchange.h | 4 +- game/src/fishing.cpp | 2 +- game/src/guild.cpp | 40 +- game/src/guild.h | 2 +- game/src/guild_manager.cpp | 10 +- game/src/guild_manager.h | 2 +- game/src/guild_war.cpp | 30 +- game/src/input.cpp | 74 +-- game/src/input.h | 2 - game/src/input_auth.cpp | 62 +-- game/src/input_db.cpp | 31 +- game/src/input_login.cpp | 15 +- game/src/input_main.cpp | 14 +- game/src/input_p2p.cpp | 2 +- game/src/ip_ban.cpp | 372 ------------- game/src/ip_ban.h | 7 - game/src/item.cpp | 31 +- game/src/item.h | 28 +- game/src/item_attribute.cpp | 2 +- game/src/item_manager.cpp | 4 +- game/src/log.cpp | 4 +- game/src/log.h | 2 +- game/src/login_data.cpp | 4 +- game/src/login_data.h | 6 +- game/src/main.cpp | 239 ++++----- game/src/map_location.cpp | 10 +- game/src/map_location.h | 10 +- game/src/marriage.cpp | 2 +- game/src/marriage.h | 2 +- game/src/matrix_card.cpp | 16 +- game/src/matrix_card.h | 4 +- game/src/messenger_manager.cpp | 10 +- game/src/motion.cpp | 2 +- game/src/p2p.cpp | 2 +- game/src/p2p.h | 2 +- game/src/packet.h | 179 +++---- game/src/packet_info.cpp | 4 - game/src/panama.cpp | 2 +- game/src/party.cpp | 2 +- game/src/party.h | 10 +- game/src/passpod.cpp | 196 ------- game/src/passpod.h | 28 - game/src/pcbang.h | 4 +- game/src/profiler.h | 6 +- game/src/protocol.h | 21 - game/src/questevent.cpp | 4 +- game/src/questlua.cpp | 16 +- game/src/questlua.h | 22 +- game/src/questlua_affect.cpp | 18 +- game/src/questlua_dragonlair.cpp | 2 +- game/src/questlua_dungeon.cpp | 52 +- game/src/questlua_game.cpp | 4 +- game/src/questlua_item.cpp | 2 +- game/src/questlua_monarch.cpp | 8 +- game/src/questlua_party.cpp | 20 +- game/src/questlua_pc.cpp | 22 +- game/src/questmanager.cpp | 4 +- game/src/questnpc.cpp | 2 +- game/src/questpc.cpp | 2 +- game/src/regen.cpp | 8 +- game/src/regen.h | 10 +- game/src/safebox.h | 2 +- game/src/sectree.cpp | 6 +- game/src/sectree.h | 6 +- game/src/sectree_manager.cpp | 114 ++-- game/src/sectree_manager.h | 60 +-- game/src/shop.cpp | 4 +- game/src/shop.h | 2 +- game/src/shopEx.cpp | 4 +- game/src/shop_manager.cpp | 2 +- game/src/skill.h | 2 +- game/src/start_position.cpp | 2 +- game/src/start_position.h | 2 +- game/src/trigger.cpp | 6 +- game/src/utils.cpp | 6 +- game/src/utils.h | 2 +- game/src/vector.cpp | 2 +- game/src/vector.h | 2 +- game/src/war_map.cpp | 24 +- game/src/war_map.h | 20 +- game/src/xmas_event.cpp | 8 +- game/src/xmas_event.h | 2 +- libsql/include/CAsyncSQL.h | 2 +- libsql/include/CStatement.h | 2 +- libsql/src/CAsyncSQL.cpp | 4 +- libsql/src/CStatement.cpp | 2 +- libthecore/include/buffer.h | 2 +- libthecore/include/stdafx.h | 1 + libthecore/include/utils.h | 10 +- libthecore/src/log.cpp | 14 +- libthecore/src/utils.cpp | 42 ++ quest/src/crc32.cc | 4 +- quest/src/crc32.h | 2 +- 167 files changed, 1388 insertions(+), 3085 deletions(-) create mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 game/src/cipher.cpp delete mode 100644 game/src/cipher.h delete mode 100644 game/src/ip_ban.cpp delete mode 100644 game/src/ip_ban.h delete mode 100644 game/src/passpod.cpp delete mode 100644 game/src/passpod.h diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..4ccab0a --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,19 @@ + + + + \ No newline at end of file diff --git a/common/building.h b/common/building.h index d42af04..6fcd8d9 100644 --- a/common/building.h +++ b/common/building.h @@ -11,9 +11,9 @@ namespace building typedef struct SLand { DWORD dwID; - long lMapIndex; - long x, y; - long width, height; + int lMapIndex; + int x, y; + int width, height; DWORD dwGuildID; BYTE bGuildLevelLimit; DWORD dwPrice; @@ -34,12 +34,12 @@ namespace building DWORD dwUpgradeVnum; DWORD dwUpgradeLimitTime; - long lLife; - long lRegion[4]; + int lLife; + int lRegion[4]; DWORD dwNPCVnum; - long lNPCX; - long lNPCY; + int lNPCX; + int lNPCY; DWORD dwGroupVnum; // °°Àº ±×·ìÀº Çϳª¸¸ °Ç¼³°¡´É DWORD dwDependOnGroupVnum; // Áö¾îÁ® ÀÖ¾î¾ßÇÏ´Â ±×·ì @@ -50,13 +50,13 @@ namespace building DWORD dwID; DWORD dwLandID; DWORD dwVnum; - long lMapIndex; - long x, y; + int lMapIndex; + int x, y; float xRot; float yRot; float zRot; - long lLife; + int lLife; } TObject; }; diff --git a/common/length.h b/common/length.h index df3853f..d8f2dc9 100644 --- a/common/length.h +++ b/common/length.h @@ -66,9 +66,6 @@ enum EMisc //LIMIT_GOLD GOLD_MAX = 2000000000, - - MAX_PASSPOD = 8 , - //END_LIMIT_GOLD diff --git a/common/service.h b/common/service.h index f4cd567..dc5131d 100644 --- a/common/service.h +++ b/common/service.h @@ -1,7 +1,6 @@ #ifndef __INC_SERVICE_H__ #define __INC_SERVICE_H__ -#define _IMPROVED_PACKET_ENCRYPTION_ // ÆÐŶ ¾Ïȣȭ °³¼± //#define __AUCTION__ #define __PET_SYSTEM__ #endif diff --git a/common/singleton.h b/common/singleton.h index da4e135..8f133cb 100644 --- a/common/singleton.h +++ b/common/singleton.h @@ -11,7 +11,7 @@ template class singleton singleton() { assert(!ms_singleton); - long offset = (long) (T*) 1 - (long) (singleton *) (T*) 1; + long offset = (long) (T*) 1 - (long) (singleton *) (T*) 1; ms_singleton = (T*) ((long) this + offset); } diff --git a/common/tables.h b/common/tables.h index 74d439f..41a912d 100644 --- a/common/tables.h +++ b/common/tables.h @@ -292,37 +292,8 @@ enum HEADER_DG_MAP_LOCATIONS = 0xfe, HEADER_DG_P2P = 0xff, - - HEADER_GP_CONFIRM_PASSPOD = 1, - HEADER_PG_CONFIRM_PASSPOD = 2, - }; -enum E_PASSPOD -{ - E_PASSPOD_SUCCESS = 0, - E_PASSPOD_FAILED_PASSPOD_ERROR, - E_PASSPOD_FAILED_USER_NOT_FOUND, - E_PASSPOD_FAILED_SYSTEM_NOT_FOUND, - E_PASSPOD_FAILED_TOKEN_DISABLED, - E_PASSPOD_FAILED_EMPTY, -}; - - -typedef struct SRequestConfirmPasspod -{ - int pid; - char passpod[MAX_PASSPOD + 1]; - char login[LOGIN_MAX_LEN + 1]; - -} RequestConfirmPasspod; - -typedef struct SResultConfirmPasspod -{ - int pid; - int ret_code; - char login[LOGIN_MAX_LEN + 1]; -} ResultConfirmPasspod; /* ---------------------------------------------- * table * ---------------------------------------------- @@ -356,8 +327,8 @@ typedef struct SSimplePlayer BYTE bChangeName; WORD wHairPart; BYTE bDummy[4]; - long x, y; - long lAddr; + LONG x, y; + LONG lAddr; WORD wPort; BYTE skill_group; } TSimplePlayer; @@ -382,7 +353,7 @@ typedef struct SPacketDGCreateSuccess typedef struct TPlayerItemAttribute { BYTE bType; - short sValue; + WORD sValue; } TPlayerItemAttribute; typedef struct SPlayerItem @@ -393,7 +364,7 @@ typedef struct SPlayerItem DWORD count; DWORD vnum; - long alSockets[ITEM_SOCKET_MAX_NUM]; // ¼ÒÄϹøÈ£ + LONG alSockets[ITEM_SOCKET_MAX_NUM]; // ¼ÒÄϹøÈ£ TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM]; @@ -417,8 +388,8 @@ struct THorseInfo { BYTE bLevel; BYTE bRiding; - short sStamina; - short sHealth; + WORD sStamina; + WORD sHealth; DWORD dwHorseHealthDropTime; }; @@ -434,7 +405,7 @@ typedef struct SPlayerTable BYTE level; BYTE level_step; - short st, ht, dx, iq; + WORD st, ht, dx, iq; DWORD exp; INT gold; @@ -443,21 +414,21 @@ typedef struct SPlayerTable INT x, y, z; INT lMapIndex; - long lExitX, lExitY; - long lExitMapIndex; + LONG lExitX, lExitY; + LONG lExitMapIndex; - short hp; - short sp; + WORD hp; + WORD sp; - short sRandomHP; - short sRandomSP; + WORD sRandomHP; + WORD sRandomSP; - int playtime; + DWORD playtime; - short stat_point; - short skill_point; - short sub_skill_point; - short horse_skill_point; + WORD stat_point; + WORD skill_point; + WORD sub_skill_point; + WORD horse_skill_point; TPlayerSkill skills[SKILL_MAX_NUM]; @@ -466,19 +437,19 @@ typedef struct SPlayerTable BYTE part_base; WORD parts[PART_MAX_NUM]; - short stamina; + WORD stamina; BYTE skill_group; - long lAlignment; + LONG lAlignment; char szMobile[MOBILE_MAX_LEN + 1]; - short stat_reset_count; + WORD stat_reset_count; THorseInfo horse; DWORD logoff_interval; - int aiPremiumTimes[PREMIUM_MAX_NUM]; + DWORD aiPremiumTimes[PREMIUM_MAX_NUM]; } TPlayerTable; typedef struct SMobSkillLevel @@ -518,8 +489,8 @@ typedef struct SMobTable : public SEntityTable BYTE bStr, bDex, bCon, bInt; DWORD dwDamageRange[2]; - short sAttackSpeed; - short sMovingSpeed; + WORD sAttackSpeed; + WORD sMovingSpeed; BYTE bAggresiveHPPct; WORD wAggressiveSight; WORD wAttackRange; @@ -588,7 +559,7 @@ typedef struct SSkillTable DWORD preSkillVnum; BYTE preSkillLevel; - long lMaxHit; + LONG lMaxHit; char szSplashAroundDamageAdjustPoly[100 + 1]; BYTE bSkillAttrType; @@ -623,19 +594,19 @@ typedef struct SQuestTable DWORD dwPID; char szName[QUEST_NAME_MAX_LEN + 1]; char szState[QUEST_STATE_MAX_LEN + 1]; - long lValue; + LONG lValue; } TQuestTable; typedef struct SItemLimit { BYTE bType; - long lValue; + LONG lValue; } TItemLimit; typedef struct SItemApply { BYTE bType; - long lValue; + LONG lValue; } TItemApply; typedef struct SItemTable : public SEntityTable @@ -659,15 +630,15 @@ typedef struct SItemTable : public SEntityTable TItemLimit aLimits[ITEM_LIMIT_MAX_NUM]; TItemApply aApplies[ITEM_APPLY_MAX_NUM]; - long alValues[ITEM_VALUES_MAX_NUM]; - long alSockets[ITEM_SOCKET_MAX_NUM]; + LONG alValues[ITEM_VALUES_MAX_NUM]; + LONG alSockets[ITEM_SOCKET_MAX_NUM]; DWORD dwRefinedVnum; WORD wRefineSet; BYTE bAlterToMagicItemPct; BYTE bSpecular; BYTE bGainSocketPct; - short int sAddonType; // ±âº» ¼Ó¼º + WORD sAddonType; // ±âº» ¼Ó¼º // ¾Æ·¡ limit flagµéÀº realtime¿¡ üũ ÇÒ ÀÏÀÌ ¸¹°í, ¾ÆÀÌÅÛ VNUM´ç °íÁ¤µÈ °ªÀε¥, // ÇöÀç ±¸Á¶´ë·Î ¸Å¹ø ¾ÆÀÌÅÛ¸¶´Ù ÇÊ¿äÇÑ °æ¿ì¿¡ LIMIT_MAX_NUM±îÁö ·çÇÁµ¹¸é¼­ üũÇÏ´Â ºÎÇÏ°¡ Ä¿¼­ ¹Ì¸® ÀúÀå ÇØ µÒ. @@ -690,7 +661,7 @@ struct TItemAttrTable char szApply[APPLY_NAME_MAX_LEN + 1]; DWORD dwApplyIndex; DWORD dwProb; - long lValues[5]; + LONG lValues[5]; BYTE bMaxLevelBySet[ATTRIBUTE_SET_MAX_NUM]; }; @@ -790,7 +761,7 @@ typedef struct SPacketGDSetup BYTE bChannel; // ä³Î WORD wListenPort; // Ŭ¶óÀ̾ðÆ®°¡ Á¢¼ÓÇÏ´Â Æ÷Æ® ¹øÈ£ WORD wP2PPort; // ¼­¹ö³¢¸® ¿¬°á ½ÃÅ°´Â P2P Æ÷Æ® ¹øÈ£ - long alMaps[32]; + LONG alMaps[32]; DWORD dwLoginCount; BYTE bAuthServer; } TPacketGDSetup; @@ -802,7 +773,7 @@ typedef struct SPacketDGMapLocations typedef struct SMapLocation { - long alMaps[32]; + LONG alMaps[32]; char szHost[MAX_HOST_LENGTH + 1]; WORD wPort; } TMapLocation; @@ -830,7 +801,7 @@ typedef struct SPacketDGDirectEnter typedef struct SPacketGuildSkillUpdate { DWORD guild_id; - int amount; + DWORD amount; BYTE skill_levels[12]; BYTE skill_point; BYTE save; @@ -839,7 +810,7 @@ typedef struct SPacketGuildSkillUpdate typedef struct SPacketGuildExpUpdate { DWORD guild_id; - int amount; + DWORD amount; } TPacketGuildExpUpdate; typedef struct SPacketGuildChangeMemberData @@ -861,10 +832,10 @@ typedef struct TPacketAffectElement { DWORD dwType; BYTE bApplyOn; - long lApplyValue; + LONG lApplyValue; DWORD dwFlag; - long lDuration; - long lSPCost; + LONG lDuration; + LONG lSPCost; } TPacketAffectElement; typedef struct SPacketGDAddAffect @@ -883,7 +854,7 @@ typedef struct SPacketGDRemoveAffect typedef struct SPacketGDHighscore { DWORD dwPID; - long lValue; + LONG lValue; char cDir; char szBoard[21]; } TPacketGDHighscore; @@ -963,8 +934,8 @@ typedef struct SPacketGuildWar BYTE bWar; DWORD dwGuildFrom; DWORD dwGuildTo; - long lWarPrice; - long lInitialScore; + LONG lWarPrice; + LONG lInitialScore; } TPacketGuildWar; // Game -> DB : »ó´ëÀû º¯È­°ª @@ -973,14 +944,14 @@ typedef struct SPacketGuildWarScore { DWORD dwGuildGainPoint; DWORD dwGuildOpponent; - long lScore; - long lBetScore; + LONG lScore; + LONG lBetScore; } TPacketGuildWarScore; typedef struct SRefineMaterial { DWORD vnum; - int count; + DWORD count; } TRefineMaterial; typedef struct SRefineTable @@ -989,8 +960,8 @@ typedef struct SRefineTable //DWORD result_vnum; DWORD id; BYTE material_count; - int cost; // ¼Ò¿ä ºñ¿ë - int prob; // È®·ü + DWORD cost; // ¼Ò¿ä ºñ¿ë + DWORD prob; // È®·ü TRefineMaterial materials[REFINE_MATERIAL_MAX_NUM]; } TRefineTable; @@ -1014,16 +985,16 @@ typedef struct SPacketDGChangeName typedef struct SPacketGuildLadder { DWORD dwGuild; - long lLadderPoint; - long lWin; - long lDraw; - long lLoss; + LONG lLadderPoint; + LONG lWin; + LONG lDraw; + LONG lLoss; } TPacketGuildLadder; typedef struct SPacketGuildLadderPoint { DWORD dwGuild; - long lChange; + LONG lChange; } TPacketGuildLadderPoint; typedef struct SPacketGDSMS @@ -1063,7 +1034,7 @@ typedef struct SPacketGDAuthLogin DWORD adwClientKey[4]; BYTE bBillType; DWORD dwBillID; - int iPremiumTimes[PREMIUM_MAX_NUM]; + DWORD iPremiumTimes[PREMIUM_MAX_NUM]; } TPacketGDAuthLogin; typedef struct SPacketGDLoginByKey @@ -1080,21 +1051,21 @@ typedef struct SPacketGDLoginByKey typedef struct SPacketGiveGuildPriv { BYTE type; - int value; + DWORD value; DWORD guild_id; time_t duration_sec; ///< Áö¼Ó½Ã°£ } TPacketGiveGuildPriv; typedef struct SPacketGiveEmpirePriv { BYTE type; - int value; + DWORD value; BYTE empire; time_t duration_sec; } TPacketGiveEmpirePriv; typedef struct SPacketGiveCharacterPriv { BYTE type; - int value; + DWORD value; DWORD pid; } TPacketGiveCharacterPriv; typedef struct SPacketRemoveGuildPriv @@ -1111,7 +1082,7 @@ typedef struct SPacketRemoveEmpirePriv typedef struct SPacketDGChangeCharacterPriv { BYTE type; - int value; + DWORD value; DWORD pid; BYTE bLog; } TPacketDGChangeCharacterPriv; @@ -1122,7 +1093,7 @@ typedef struct SPacketDGChangeCharacterPriv typedef struct SPacketDGChangeGuildPriv { BYTE type; - int value; + DWORD value; DWORD guild_id; BYTE bLog; time_t end_time_sec; ///< Áö¼Ó½Ã°£ @@ -1131,7 +1102,7 @@ typedef struct SPacketDGChangeGuildPriv typedef struct SPacketDGChangeEmpirePriv { BYTE type; - int value; + DWORD value; BYTE empire; BYTE bLog; time_t end_time_sec; @@ -1172,7 +1143,7 @@ typedef struct SPacketGDGuildMoneyWithdrawGiveReply typedef struct SPacketSetEventFlag { char szFlagName[EVENT_FLAG_NAME_MAX_LEN + 1]; - long lValue; + LONG lValue; } TPacketSetEventFlag; typedef struct SPacketBillingLogin @@ -1238,14 +1209,14 @@ typedef struct SGuildReserve DWORD dwGuildTo; DWORD dwTime; BYTE bType; - long lWarPrice; - long lInitialScore; + LONG lWarPrice; + LONG lInitialScore; bool bStarted; DWORD dwBetFrom; DWORD dwBetTo; - long lPowerFrom; - long lPowerTo; - long lHandicap; + LONG lPowerFrom; + LONG lPowerTo; + LONG lHandicap; } TGuildWarReserve; typedef struct @@ -1332,7 +1303,7 @@ typedef struct SItemPriceListTable typedef struct { char szName[CHARACTER_NAME_MAX_LEN + 1]; - long lDuration; + LONG lDuration; } TPacketBlockChat; // PCBANG_IP_LIST @@ -1347,12 +1318,12 @@ typedef struct SPacketPCBangIP //ADMIN_MANAGER typedef struct TAdminInfo { - int m_ID; //°íÀ¯ID + DWORD m_ID; //°íÀ¯ID char m_szAccount[32]; //°èÁ¤ char m_szName[32]; //ij¸¯ÅÍÀ̸§ char m_szContactIP[16]; //Á¢±Ù¾ÆÀÌÇÇ char m_szServerIP[16]; //¼­¹ö¾ÆÀÌÇÇ - int m_Authority; //±ÇÇÑ + DWORD m_Authority; //±ÇÇÑ } tAdminInfo; //END_ADMIN_MANAGER @@ -1463,7 +1434,7 @@ typedef struct tItemAwardInformer { char login[LOGIN_MAX_LEN + 1]; char command[20]; //¸í·É¾î - unsigned int vnum; //¾ÆÀÌÅÛ + DWORD vnum; //¾ÆÀÌÅÛ } TPacketItemAwardInfromer; // ¼±¹° ¾Ë¸² ±â´É »èÁ¦¿ë ÆÐŶ Á¤º¸ typedef struct tDeleteAwardID @@ -1473,7 +1444,7 @@ typedef struct tDeleteAwardID typedef struct SChannelStatus { - short nPort; + WORD nPort; BYTE bStatus; } TChannelStatus; diff --git a/common/utils.h b/common/utils.h index 5a32c42..9069c90 100644 --- a/common/utils.h +++ b/common/utils.h @@ -55,27 +55,11 @@ inline bool str_to_number (unsigned int& out, const char *in) return true; } -inline bool str_to_number (long& out, const char *in) +inline bool str_to_number (int64_t& out, const char *in) { if (0==in || 0==in[0]) return false; - out = (long) strtol(in, NULL, 10); - return true; -} - -inline bool str_to_number (unsigned long& out, const char *in) -{ - if (0==in || 0==in[0]) return false; - - out = (unsigned long) strtoul(in, NULL, 10); - return true; -} - -inline bool str_to_number (long long& out, const char *in) -{ - if (0==in || 0==in[0]) return false; - - out = (long long) strtoull(in, NULL, 10); + out = (int64_t) strtoull(in, NULL, 10); return true; } @@ -87,23 +71,4 @@ inline bool str_to_number (float& out, const char *in) return true; } -inline bool str_to_number (double& out, const char *in) -{ - if (0==in || 0==in[0]) return false; - - out = (double) strtod(in, NULL); - return true; -} - -#ifdef __FreeBSD__ -inline bool str_to_number (long double& out, const char *in) -{ - if (0==in || 0==in[0]) return false; - - out = (long double) strtold(in, NULL); - return true; -} -#endif - - /*----- atoi function -----*/ diff --git a/db/src/BlockCountry.cpp b/db/src/BlockCountry.cpp index 4a05025..3cd77f4 100644 --- a/db/src/BlockCountry.cpp +++ b/db/src/BlockCountry.cpp @@ -109,7 +109,7 @@ bool CBlockCountry::IsBlockedCountryIp(const char *user_ip) #ifndef __WIN32__ if (0 == inet_aton(user_ip, &st_addr)) #else - unsigned long in_address; + unsigned int in_address; in_address = inet_addr(user_ip); st_addr.s_addr = in_address; if (INADDR_NONE == in_address) diff --git a/db/src/Cache.cpp b/db/src/Cache.cpp index ac08730..236ad02 100644 --- a/db/src/Cache.cpp +++ b/db/src/Cache.cpp @@ -69,16 +69,16 @@ void CItemCache::OnFlush() } else { - long alSockets[ITEM_SOCKET_MAX_NUM]; + int alSockets[ITEM_SOCKET_MAX_NUM]; TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM]; bool isSocket = false, isAttr = false; - memset(&alSockets, 0, sizeof(long) * ITEM_SOCKET_MAX_NUM); + memset(&alSockets, 0, sizeof(int) * ITEM_SOCKET_MAX_NUM); memset(&aAttr, 0, sizeof(TPlayerItemAttribute) * ITEM_ATTRIBUTE_MAX_NUM); TPlayerItem * p = &m_data; - if (memcmp(alSockets, p->alSockets, sizeof(long) * ITEM_SOCKET_MAX_NUM)) + if (memcmp(alSockets, p->alSockets, sizeof(int) * ITEM_SOCKET_MAX_NUM)) isSocket = true; if (memcmp(aAttr, p->aAttr, sizeof(TPlayerItemAttribute) * ITEM_ATTRIBUTE_MAX_NUM)) @@ -100,9 +100,9 @@ void CItemCache::OnFlush() { iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen, ", socket0, socket1, socket2"); iValueLen += snprintf(szValues + iValueLen, sizeof(szValues) - iValueLen, - ", %lu, %lu, %lu", p->alSockets[0], p->alSockets[1], p->alSockets[2]); + ", %d, %d, %d", p->alSockets[0], p->alSockets[1], p->alSockets[2]); iUpdateLen += snprintf(szUpdate + iUpdateLen, sizeof(szUpdate) - iUpdateLen, - ", socket0=%lu, socket1=%lu, socket2=%lu", p->alSockets[0], p->alSockets[1], p->alSockets[2]); + ", socket0=%d, socket1=%d, socket2=%d", p->alSockets[0], p->alSockets[1], p->alSockets[2]); } if (isAttr) diff --git a/db/src/ClientManager.cpp b/db/src/ClientManager.cpp index a8dfb74..bae7f61 100644 --- a/db/src/ClientManager.cpp +++ b/db/src/ClientManager.cpp @@ -58,7 +58,7 @@ static void AcceptConnection( CPeer* peer = clientManager->AddPeer(bev, address); // Set the event handlers for this peer - bufferevent_setcb(bev, ReadHandler, WriteHandler, EventHandler, peer); + bufferevent_setcb(bev, DescReadHandler, DescWriteHandler, DescEventHandler, peer); // Enable the events bufferevent_enable(bev, EV_READ|EV_WRITE); @@ -73,7 +73,7 @@ static void AcceptError(evconnlistener *listener, void *ctx) { event_base_loopexit(base, NULL); } -static void ReadHandler(bufferevent *bev, void *ctx) { +static void DescReadHandler(bufferevent *bev, void *ctx) { auto* peer = (CPeer*) ctx; if (peer == CClientManager::Instance().GetAuthPeer()) @@ -83,7 +83,7 @@ static void ReadHandler(bufferevent *bev, void *ctx) { CClientManager::Instance().ProcessPackets(peer); } -static void WriteHandler(bufferevent *bev, void *ctx) { +static void DescWriteHandler(bufferevent *bev, void *ctx) { auto* peer = (CPeer*) ctx; if (peer == CClientManager::Instance().GetAuthPeer()) @@ -91,7 +91,7 @@ static void WriteHandler(bufferevent *bev, void *ctx) { sys_log(0, "AUTH_PEER_WRITE: size %d", peer->GetSendLength()); } -static void EventHandler(bufferevent *bev, short events, void *ctx) { +static void DescEventHandler(bufferevent *bev, short events, void *ctx) { auto* peer = (CPeer*) ctx; if (events & BEV_EVENT_ERROR) @@ -195,7 +195,6 @@ bool CClientManager::Initialize() strncpy(szBindIP, "0", sizeof(szBindIP)); // Create a new libevent base and listen for new connections - event_enable_debug_mode(); m_base = event_base_new(); if (!m_base) { sys_err("Libevent base initialization FAILED!"); @@ -1717,8 +1716,8 @@ void CClientManager::QUERY_SMS(CPeer * pkPeer, TPacketGDSMS * pack) char szQuery[QUERY_MAX_LEN]; char szMsg[256+1]; - //unsigned long len = CDBManager::instance().EscapeString(szMsg, pack->szMsg, strlen(pack->szMsg), SQL_ACCOUNT); - unsigned long len = CDBManager::instance().EscapeString(szMsg, pack->szMsg, strlen(pack->szMsg)); + //unsigned int len = CDBManager::instance().EscapeString(szMsg, pack->szMsg, strlen(pack->szMsg), SQL_ACCOUNT); + unsigned int len = CDBManager::instance().EscapeString(szMsg, pack->szMsg, strlen(pack->szMsg)); szMsg[len] = '\0'; snprintf(szQuery, sizeof(szQuery), diff --git a/db/src/ClientManager.h b/db/src/ClientManager.h index 6cc2d70..3d38f9f 100644 --- a/db/src/ClientManager.h +++ b/db/src/ClientManager.h @@ -32,9 +32,9 @@ size_t CreatePlayerSaveQuery(char * pszQuery, size_t querySize, TPlayerTable * p static void AcceptConnection(evconnlistener *listener, evutil_socket_t fd, sockaddr *address, int socklen, void *ctx); static void AcceptError(evconnlistener *listener, void *ctx); -static void ReadHandler(bufferevent *bev, void *ctx); -static void WriteHandler(bufferevent *bev, void *ctx); -static void EventHandler(bufferevent *bev, short events, void *ctx); +static void DescReadHandler(bufferevent *bev, void *ctx); +static void DescWriteHandler(bufferevent *bev, void *ctx); +static void DescEventHandler(bufferevent *bev, short events, void *ctx); class CClientManager : public singleton { @@ -472,7 +472,7 @@ class CClientManager : public singleton typedef std::map TPartyChannelMap; TPartyChannelMap m_map_pkChannelParty; - typedef std::map TEventFlagMap; + typedef std::map TEventFlagMap; TEventFlagMap m_map_lEventFlag; BYTE m_bLastHeader; diff --git a/db/src/ClientManagerPlayer.cpp b/db/src/ClientManagerPlayer.cpp index 25c298c..10e1c72 100644 --- a/db/src/ClientManagerPlayer.cpp +++ b/db/src/ClientManagerPlayer.cpp @@ -160,7 +160,7 @@ size_t CreatePlayerSaveQuery(char * pszQuery, size_t querySize, TPlayerTable * p pkTab->horse_skill_point); // Binary ·Î ¹Ù²Ù±â À§ÇÑ Àӽà °ø°£ - static char text[8192 + 1]; + char text[8192 + 1]; CDBManager::instance().EscapeString(text, pkTab->skills, sizeof(pkTab->skills)); queryLen += snprintf(pszQuery + queryLen, querySize - queryLen, "skill_level = '%s', ", text); @@ -794,14 +794,14 @@ void CClientManager::__QUERY_PLAYER_CREATE(CPeer *peer, DWORD dwHandle, TPlayerC { char queryStr[QUERY_MAX_LEN]; int queryLen; - int player_id; + DWORD player_id; // ÇÑ °èÁ¤¿¡ XÃÊ ³»·Î ij¸¯ÅÍ »ý¼ºÀ» ÇÒ ¼ö ¾ø´Ù. - time_by_id_map_t::iterator it = s_createTimeByAccountID.find(packet->account_id); + auto it = s_createTimeByAccountID.find(packet->account_id); if (it != s_createTimeByAccountID.end()) { - time_t curtime = time(0); + time_t curtime = time(nullptr); if (curtime - it->second < 30) { @@ -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::unique_ptr pMsg1(CDBManager::instance().DirectQuery(queryStr)); + std::unique_ptr pMsg1(CDBManager::instance().DirectQuery(queryStr)); if (pMsg1->Get()->uiNumRows) { @@ -895,7 +895,7 @@ void CClientManager::__QUERY_PLAYER_CREATE(CPeer *peer, DWORD dwHandle, TPlayerC packet->player_table.ht, packet->player_table.job); - static char text[4096 + 1]; + char text[8192 + 1]; CDBManager::instance().EscapeString(text, packet->player_table.skills, sizeof(packet->player_table.skills)); queryLen += snprintf(queryStr + queryLen, sizeof(queryStr) - queryLen, "'%s', ", text); diff --git a/db/src/DBManager.cpp b/db/src/DBManager.cpp index c3058c7..2ee66f3 100644 --- a/db/src/DBManager.cpp +++ b/db/src/DBManager.cpp @@ -157,7 +157,7 @@ void CDBManager::AsyncQuery(const char * c_pszQuery, int iSlot) ++g_query_count[1]; } -unsigned long CDBManager::EscapeString(void *to, const void *from, unsigned long length, int iSlot) +unsigned int CDBManager::EscapeString(void *to, const void *from, unsigned int length, int iSlot) { assert(iSlot < SQL_MAX_NUM); return mysql_real_escape_string(m_directSQL[iSlot]->GetSQLHandle(), (char *) to, (const char *) from, length); diff --git a/db/src/DBManager.h b/db/src/DBManager.h index 7129e8b..f8b1d39 100644 --- a/db/src/DBManager.h +++ b/db/src/DBManager.h @@ -49,7 +49,7 @@ class CDBManager : public singleton SQLMsg * PopResult(); SQLMsg * PopResult(eSQL_SLOT slot ); - unsigned long EscapeString(void * to, const void * from, unsigned long length, int iSlot = SQL_PLAYER); + unsigned int EscapeString(void * to, const void * from, unsigned int length, int iSlot = SQL_PLAYER); DWORD CountReturnQuery(int i) { return m_mainSQL[i] ? m_mainSQL[i]->CountQuery() : 0; } DWORD CountReturnResult(int i) { return m_mainSQL[i] ? m_mainSQL[i]->CountResult() : 0; } diff --git a/db/src/GuildManager.cpp b/db/src/GuildManager.cpp index 9e6bc3b..4cbfd7f 100644 --- a/db/src/GuildManager.cpp +++ b/db/src/GuildManager.cpp @@ -525,7 +525,7 @@ void CGuildManager::WarEnd(DWORD GID1, DWORD GID2, bool bForceDraw) // // ±æµåÀü Á¤»ó Á¾·á // -void CGuildManager::RecvWarOver(DWORD dwGuildWinner, DWORD dwGuildLoser, bool bDraw, long lWarPrice) +void CGuildManager::RecvWarOver(DWORD dwGuildWinner, DWORD dwGuildLoser, bool bDraw, int lWarPrice) { sys_log(0, "GuildWar: RecvWarOver : winner %u vs %u draw? %d war_price %d", dwGuildWinner, dwGuildLoser, bDraw ? 1 : 0, lWarPrice); @@ -666,7 +666,7 @@ void CGuildManager::RemoveDeclare(DWORD guild_from, DWORD guild_to) sys_log(0, "GuildWar: RemoveDeclare(from:%d,to:%d)", guild_from, guild_to); } -bool CGuildManager::TakeBetPrice(DWORD dwGuildTo, DWORD dwGuildFrom, long lWarPrice) +bool CGuildManager::TakeBetPrice(DWORD dwGuildTo, DWORD dwGuildFrom, int lWarPrice) { itertype(m_map_kGuild) it_from = m_map_kGuild.find(dwGuildFrom); itertype(m_map_kGuild) it_to = m_map_kGuild.find(dwGuildTo); @@ -1023,7 +1023,7 @@ bool CGuildManager::ReserveWar(TPacketGuildWar * p) polyPower.SetVar("alv", alv); polyPower.SetVar("mc", mc); - t.lPowerFrom = (long) polyPower.Eval(); + t.lPowerFrom = (int) polyPower.Eval(); sys_log(0, "GuildWar: %u lvp %d rkp %d alv %d mc %d power %d", GID1, lvp, rkp, alv, mc, t.lPowerFrom); // ÆÄ¿ö °è»ê @@ -1039,7 +1039,7 @@ bool CGuildManager::ReserveWar(TPacketGuildWar * p) polyPower.SetVar("alv", alv); polyPower.SetVar("mc", mc); - t.lPowerTo = (long) polyPower.Eval(); + t.lPowerTo = (int) polyPower.Eval(); sys_log(0, "GuildWar: %u lvp %d rkp %d alv %d mc %d power %d", GID2, lvp, rkp, alv, mc, t.lPowerTo); // ÇÚµðĸ °è»ê @@ -1054,7 +1054,7 @@ bool CGuildManager::ReserveWar(TPacketGuildWar * p) polyHandicap.SetVar("pB", t.lPowerTo); } - t.lHandicap = (long) polyHandicap.Eval(); + t.lHandicap = (int) polyHandicap.Eval(); sys_log(0, "GuildWar: handicap %d", t.lHandicap); // Äõ¸® @@ -1062,7 +1062,7 @@ bool CGuildManager::ReserveWar(TPacketGuildWar * p) snprintf(szQuery, sizeof(szQuery), "INSERT INTO guild_war_reservation (guild1, guild2, time, type, warprice, initscore, power1, power2, handicap) " - "VALUES(%u, %u, DATE_ADD(NOW(), INTERVAL 180 SECOND), %u, %ld, %ld, %ld, %ld, %ld)", + "VALUES(%u, %u, DATE_ADD(NOW(), INTERVAL 180 SECOND), %u, %d, %d, %d, %d, %d)", GID1, GID2, p->bType, p->lWarPrice, p->lInitialScore, t.lPowerFrom, t.lPowerTo, t.lHandicap); std::unique_ptr pmsg(CDBManager::instance().DirectQuery(szQuery)); diff --git a/db/src/GuildManager.h b/db/src/GuildManager.h index fc91079..26227bc 100644 --- a/db/src/GuildManager.h +++ b/db/src/GuildManager.h @@ -45,15 +45,15 @@ struct TGuildWaitStartInfo { BYTE bType; DWORD GID[2]; - long lWarPrice; - long lInitialScore; + int lWarPrice; + int lInitialScore; CGuildWarReserve * pkReserve; TGuildWaitStartInfo(BYTE _bType, DWORD _g1, DWORD _g2, - long _lWarPrice, - long _lInitialScore, + int _lWarPrice, + int _lInitialScore, CGuildWarReserve * _pkReserve) : bType(_bType), lWarPrice(_lWarPrice), lInitialScore(_lInitialScore), pkReserve(_pkReserve) { @@ -180,12 +180,12 @@ class CGuildManager : public singleton void AddDeclare(BYTE bType, DWORD guild_from, DWORD guild_to); void RemoveDeclare(DWORD guild_from, DWORD guild_to); - bool TakeBetPrice(DWORD dwGuildTo, DWORD dwGuildFrom, long lWarPrice); + bool TakeBetPrice(DWORD dwGuildTo, DWORD dwGuildFrom, int lWarPrice); bool WaitStart(TPacketGuildWar * p); void RecvWarEnd(DWORD GID1, DWORD GID2); - void RecvWarOver(DWORD dwGuildWinner, DWORD dwGuildLoser, bool bDraw, long lWarPrice); + void RecvWarOver(DWORD dwGuildWinner, DWORD dwGuildLoser, bool bDraw, int lWarPrice); void ChangeLadderPoint(DWORD GID, int change); diff --git a/db/src/LoginData.cpp b/db/src/LoginData.cpp index e2a2b96..052194d 100644 --- a/db/src/LoginData.cpp +++ b/db/src/LoginData.cpp @@ -103,12 +103,12 @@ bool CLoginData::IsDeleted() return m_bDeleted; } -void CLoginData::SetPremium(int * paiPremiumTimes) +void CLoginData::SetPremium(DWORD * paiPremiumTimes) { memcpy(m_aiPremiumTimes, paiPremiumTimes, sizeof(m_aiPremiumTimes)); } -int CLoginData::GetPremium(BYTE type) +DWORD CLoginData::GetPremium(BYTE type) { if (type >= PREMIUM_MAX_NUM) return 0; @@ -116,7 +116,7 @@ int CLoginData::GetPremium(BYTE type) return m_aiPremiumTimes[type]; } -int * CLoginData::GetPremiumPtr() +DWORD * CLoginData::GetPremiumPtr() { return &m_aiPremiumTimes[0]; } diff --git a/db/src/LoginData.h b/db/src/LoginData.h index 73e20a7..9c6c085 100644 --- a/db/src/LoginData.h +++ b/db/src/LoginData.h @@ -37,9 +37,9 @@ class CLoginData time_t GetLastPlayTime() { return m_lastPlayTime; } - void SetPremium(int * paiPremiumTimes); - int GetPremium(BYTE type); - int * GetPremiumPtr(); + void SetPremium(DWORD * paiPremiumTimes); + DWORD GetPremium(BYTE type); + DWORD * GetPremiumPtr(); DWORD GetLastPlayerID() const { return m_dwLastPlayerID; } void SetLastPlayerID(DWORD id) { m_dwLastPlayerID = id; } @@ -56,7 +56,7 @@ class CLoginData BYTE m_bBillType; DWORD m_dwBillID; time_t m_lastPlayTime; - int m_aiPremiumTimes[PREMIUM_MAX_NUM]; + DWORD m_aiPremiumTimes[PREMIUM_MAX_NUM]; DWORD m_dwLastPlayerID; diff --git a/db/src/Peer.cpp b/db/src/Peer.cpp index a7f3193..8b2292e 100644 --- a/db/src/Peer.cpp +++ b/db/src/Peer.cpp @@ -113,7 +113,7 @@ void CPeer::SetP2PPort(WORD wPort) m_wP2PPort = wPort; } -void CPeer::SetMaps(long * pl) +void CPeer::SetMaps(LONG * pl) { memcpy(m_alMaps, pl, sizeof(m_alMaps)); } diff --git a/db/src/Peer.h b/db/src/Peer.h index 8a05590..acd743f 100644 --- a/db/src/Peer.h +++ b/db/src/Peer.h @@ -50,8 +50,8 @@ class CPeer : public CPeerBase void SetP2PPort(WORD wPort); WORD GetP2PPort() { return m_wP2PPort; } - void SetMaps(long* pl); - long * GetMaps() { return &m_alMaps[0]; } + void SetMaps(LONG* pl); + LONG * GetMaps() { return &m_alMaps[0]; } bool SetItemIDRange(TItemIDRangeTable itemRange); bool SetSpareItemIDRange(TItemIDRangeTable itemRange); @@ -66,7 +66,7 @@ class CPeer : public CPeerBase DWORD m_dwUserCount; WORD m_wListenPort; // °ÔÀÓ¼­¹ö°¡ Ŭ¶óÀ̾ðÆ®¸¦ À§ÇØ listen ÇÏ´Â Æ÷Æ® WORD m_wP2PPort; // °ÔÀÓ¼­¹ö°¡ °ÔÀÓ¼­¹ö P2P Á¢¼ÓÀ» À§ÇØ listen ÇÏ´Â Æ÷Æ® - long m_alMaps[32]; // ¾î¶² ¸ÊÀ» °üÀåÇÏ°í Àִ°¡? + LONG m_alMaps[32]; // ¾î¶² ¸ÊÀ» °üÀåÇÏ°í Àִ°¡? TItemIDRangeTable m_itemRange; TItemIDRangeTable m_itemSpareRange; diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index bffdaba..288156a 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -29,6 +29,10 @@ target_link_libraries (${PROJECT_NAME} cryptopp-static) include_directories(${Boost_INCLUDE_DIR}) target_link_libraries (${PROJECT_NAME} ${Boost_LIBRARIES}) +# Libevent +find_package(Libevent CONFIG REQUIRED) +target_link_libraries(${PROJECT_NAME} libevent::core libevent::extra libevent::pthreads) + if (IL_FOUND) include_directories(${IL_INCLUDE_DIR}) target_link_libraries (${PROJECT_NAME} ${IL_LIBRARIES}) diff --git a/game/src/BlueDragon_Skill.h b/game/src/BlueDragon_Skill.h index 12c3690..f3b1c0e 100644 --- a/game/src/BlueDragon_Skill.h +++ b/game/src/BlueDragon_Skill.h @@ -178,7 +178,7 @@ struct FSkillEarthQuake EJobs Set1; EJobs Set2; ESex gender; - long MaxDistance; + int MaxDistance; LPCHARACTER pAttacker; LPCHARACTER pFarthestChar; @@ -286,8 +286,8 @@ struct FSkillEarthQuake const int nFlyDistance = 1000; - long tx = ch->GetX() + vec.x * nFlyDistance; - long ty = ch->GetY() + vec.y * nFlyDistance; + int tx = ch->GetX() + vec.x * nFlyDistance; + int ty = ch->GetY() + vec.y * nFlyDistance; for (int i=0 ; i < 5 ; ++i) { @@ -327,7 +327,7 @@ struct FSkillEarthQuake ch->SyncPacket(); - long dist = DISTANCE_APPROX( pAttacker->GetX() - ch->GetX(), pAttacker->GetY() - ch->GetY() ); + int dist = DISTANCE_APPROX( pAttacker->GetX() - ch->GetX(), pAttacker->GetY() - ch->GetY() ); if (dist > MaxDistance) { diff --git a/game/src/DragonLair.cpp b/game/src/DragonLair.cpp index fcf3d73..31374e8 100644 --- a/game/src/DragonLair.cpp +++ b/game/src/DragonLair.cpp @@ -17,10 +17,10 @@ extern int passes_per_sec; struct FWarpToDragronLairWithGuildMembers { DWORD dwGuildID; - long mapIndex; - long x, y; + int mapIndex; + int x, y; - FWarpToDragronLairWithGuildMembers( DWORD guildID, long map, long X, long Y ) + FWarpToDragronLairWithGuildMembers( DWORD guildID, int map, int X, int Y ) : dwGuildID(guildID), mapIndex(map), x(X), y(Y) { } @@ -68,7 +68,7 @@ EVENTINFO(tag_DragonLair_Collapse_EventInfo) { int step; CDragonLair* pLair; - long InstanceMapIndex; + int InstanceMapIndex; tag_DragonLair_Collapse_EventInfo() : step( 0 ) @@ -129,7 +129,7 @@ EVENTFUNC( DragonLair_Collapse_Event ) -CDragonLair::CDragonLair(DWORD guildID, long BaseMapID, long PrivateMapID) +CDragonLair::CDragonLair(DWORD guildID, int BaseMapID, int PrivateMapID) : GuildID_(guildID), BaseMapIndex_(BaseMapID), PrivateMapIndex_(PrivateMapID) { StartTime_ = get_global_time(); @@ -170,9 +170,9 @@ CDragonLairManager::~CDragonLairManager() { } -bool CDragonLairManager::Start(long MapIndexFrom, long BaseMapIndex, DWORD GuildID) +bool CDragonLairManager::Start(int MapIndexFrom, int BaseMapIndex, DWORD GuildID) { - long instanceMapIndex = SECTREE_MANAGER::instance().CreatePrivateMap(BaseMapIndex); + int instanceMapIndex = SECTREE_MANAGER::instance().CreatePrivateMap(BaseMapIndex); if (instanceMapIndex == 0) { sys_err("CDragonLairManager::Start() : no private map index available"); return false; diff --git a/game/src/DragonLair.h b/game/src/DragonLair.h index b17e718..4710833 100644 --- a/game/src/DragonLair.h +++ b/game/src/DragonLair.h @@ -6,7 +6,7 @@ class CDragonLair { public: - CDragonLair (DWORD dwGuildID, long BaseMapID, long PrivateMapID); + CDragonLair (DWORD dwGuildID, int BaseMapID, int PrivateMapID); virtual ~CDragonLair (); DWORD GetEstimatedTime () const; @@ -16,8 +16,8 @@ class CDragonLair private: DWORD StartTime_; DWORD GuildID_; - long BaseMapIndex_; - long PrivateMapIndex_; + int BaseMapIndex_; + int PrivateMapIndex_; }; class CDragonLairManager : public singleton @@ -26,7 +26,7 @@ class CDragonLairManager : public singleton CDragonLairManager (); virtual ~CDragonLairManager (); - bool Start (long MapIndexFrom, long BaseMapIndex, DWORD GuildID); + bool Start (int MapIndexFrom, int BaseMapIndex, DWORD GuildID); void OnDragonDead (LPCHARACTER pDragon, DWORD KillerGuildID); size_t GetLairCount () const { return LairMap_.size(); } diff --git a/game/src/DragonSoul.cpp b/game/src/DragonSoul.cpp index 6e526b7..928dd46 100644 --- a/game/src/DragonSoul.cpp +++ b/game/src/DragonSoul.cpp @@ -466,7 +466,7 @@ bool DSManager::PullOut(LPCHARACTER ch, TItemPos DestCell, LPITEM& pItem, LPITEM } else { - sprintf(buf, "dice(%d) prob(%d)", fDice, fProb); + sprintf(buf, "dice(%d) prob(%d)", (int)fDice, (int)fProb); } LogManager::instance().ItemLog(ch, pItem, "DS_PULL_OUT_SUCCESS", buf); ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¿ëÈ¥¼® ÃßÃâ¿¡ ¼º°øÇÏ¿´½À´Ï´Ù.")); diff --git a/game/src/MarkImage.h b/game/src/MarkImage.h index 4cf75fc..c12b591 100644 --- a/game/src/MarkImage.h +++ b/game/src/MarkImage.h @@ -4,7 +4,7 @@ #include #include -typedef unsigned long Pixel; +typedef unsigned int Pixel; struct SGuildMark { diff --git a/game/src/PetSystem.cpp b/game/src/PetSystem.cpp index 4dfcb9e..9b80409 100644 --- a/game/src/PetSystem.cpp +++ b/game/src/PetSystem.cpp @@ -135,9 +135,9 @@ void CPetActor::Unsummon() DWORD CPetActor::Summon(const char* petName, LPITEM pSummonItem, bool bSpawnFar) { - long x = m_pkOwner->GetX(); - long y = m_pkOwner->GetY(); - long z = m_pkOwner->GetZ(); + int x = m_pkOwner->GetX(); + int y = m_pkOwner->GetY(); + int z = m_pkOwner->GetZ(); if (true == bSpawnFar) { @@ -248,8 +248,8 @@ bool CPetActor::_UpdateFollowAI() DWORD currentTime = get_dword_time(); - long ownerX = m_pkOwner->GetX(); long ownerY = m_pkOwner->GetY(); - long charX = m_pkChar->GetX(); long charY = m_pkChar->GetY(); + int ownerX = m_pkOwner->GetX(); int ownerY = m_pkOwner->GetY(); + int charX = m_pkChar->GetX(); int charY = m_pkChar->GetY(); float fDist = DISTANCE_APPROX(charX - ownerX, charY - ownerY); diff --git a/game/src/affect.h b/game/src/affect.h index 756e778..90e610b 100644 --- a/game/src/affect.h +++ b/game/src/affect.h @@ -6,10 +6,10 @@ class CAffect public: DWORD dwType; BYTE bApplyOn; - long lApplyValue; + int lApplyValue; DWORD dwFlag; - long lDuration; - long lSPCost; + int lDuration; + int lSPCost; static CAffect* Acquire(); static void Release(CAffect* p); diff --git a/game/src/arena.cpp b/game/src/arena.cpp index de2d8b1..eb4790c 100644 --- a/game/src/arena.cpp +++ b/game/src/arena.cpp @@ -76,11 +76,9 @@ bool CArenaManager::AddArena(DWORD mapIdx, WORD startA_X, WORD startA_Y, WORD st bool CArenaMap::AddArena(DWORD mapIdx, WORD startA_X, WORD startA_Y, WORD startB_X, WORD startB_Y) { - itertype(m_listArena) iter = m_listArena.begin(); - - for (; iter != m_listArena.end(); iter++) + for (auto iter: m_listArena) { - if ((CArena*)(*iter)->CheckArea(startA_X, startA_Y, startB_X, startB_Y) == false) + if (iter->CheckArea(startA_X, startA_Y, startB_X, startB_Y) == false) { sys_log(0, "CArenaMap::AddArena - Same Start Position set. stA(%d, %d) stB(%d, %d)", startA_X, startA_Y, startB_X, startB_Y); return false; @@ -89,7 +87,7 @@ bool CArenaMap::AddArena(DWORD mapIdx, WORD startA_X, WORD startA_Y, WORD startB m_dwMapIndex = mapIdx; - CArena *pArena = M2_NEW CArena(startA_X, startA_Y, startB_X, startB_Y); + CArena * pArena = new CArena(startA_X, startA_Y, startB_X, startB_Y); m_listArena.push_back(pArena); return true; @@ -146,15 +144,13 @@ void CArenaManager::SendArenaMapListTo(LPCHARACTER pChar) void CArenaMap::SendArenaMapListTo(LPCHARACTER pChar, DWORD mapIdx) { - if (pChar == NULL) return; + if (pChar == nullptr) return; - itertype(m_listArena) iter = m_listArena.begin(); - - for (; iter != m_listArena.end(); iter++) - { + for (auto& arena: m_listArena) { pChar->ChatPacket(CHAT_TYPE_INFO, "ArenaMapInfo Map: %d stA(%d, %d) stB(%d, %d)", mapIdx, - (CArena*)(*iter)->GetStartPointA().x, (CArena*)(*iter)->GetStartPointA().y, - (CArena*)(*iter)->GetStartPointB().x, (CArena*)(*iter)->GetStartPointB().y); + arena->GetStartPointA().x, arena->GetStartPointA().y, + arena->GetStartPointB().x, arena->GetStartPointB().y + ); } } @@ -649,7 +645,7 @@ bool CArenaManager::CanAttack(LPCHARACTER pCharAttacker, LPCHARACTER pCharVictim if (pCharAttacker == pCharVictim) return false; - long mapIndex = pCharAttacker->GetMapIndex(); + int mapIndex = pCharAttacker->GetMapIndex(); if (mapIndex != pCharVictim->GetMapIndex()) return false; itertype(m_mapArenaMap) iter = m_mapArenaMap.find(mapIndex); @@ -693,7 +689,7 @@ bool CArenaManager::OnDead(LPCHARACTER pCharKiller, LPCHARACTER pCharVictim) { if (pCharKiller == NULL || pCharVictim == NULL) return false; - long mapIndex = pCharKiller->GetMapIndex(); + int mapIndex = pCharKiller->GetMapIndex(); if (mapIndex != pCharVictim->GetMapIndex()) return false; itertype(m_mapArenaMap) iter = m_mapArenaMap.find(mapIndex); @@ -1101,7 +1097,7 @@ bool CArena::RegisterObserverPtr(LPCHARACTER pChar) return true; } -bool CArenaManager::IsLimitedItem( long lMapIndex, DWORD dwVnum ) +bool CArenaManager::IsLimitedItem( int lMapIndex, DWORD dwVnum ) { if ( IsArenaMap( lMapIndex ) == true ) { diff --git a/game/src/arena.h b/game/src/arena.h index 7c906b9..7d683d8 100644 --- a/game/src/arena.h +++ b/game/src/arena.h @@ -132,7 +132,7 @@ class CArenaManager : public singleton bool IsArenaMap(DWORD dwMapIndex); MEMBER_IDENTITY IsMember(DWORD dwMapIndex, DWORD PID); - bool IsLimitedItem( long lMapIndex, DWORD dwVnum ); + bool IsLimitedItem( int lMapIndex, DWORD dwVnum ); }; #endif /*__CLASS_ARENA_MANAGER__*/ diff --git a/game/src/battle.cpp b/game/src/battle.cpp index 2c7a2b2..98bf17b 100644 --- a/game/src/battle.cpp +++ b/game/src/battle.cpp @@ -24,9 +24,9 @@ int battle_hit(LPCHARACTER ch, LPCHARACTER victim, int & iRetDam); -bool battle_distance_valid_by_xy(long x, long y, long tx, long ty) +bool battle_distance_valid_by_xy(int x, int y, int tx, int ty) { - long distance = DISTANCE_APPROX(x - tx, y - ty); + int distance = DISTANCE_APPROX(x - tx, y - ty); if (distance > 170) return false; @@ -524,7 +524,7 @@ int CalcMeleeDamage(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, bool bIgnoreDe if (iDam != DEBUG_iPureDam) snprintf(szUnknownDam, sizeof(szUnknownDam), "+?(%d)", iDam-DEBUG_iPureDam); - char szMeleeAttack[128]; + char szMeleeAttack[256]; snprintf(szMeleeAttack, sizeof(szMeleeAttack), "%s(%d)-%s(%d)=%d%s, ATK=LV(%d)+ST(%d)+WP(%d)%s%s%s, AR=%.3g%s", diff --git a/game/src/battle.h b/game/src/battle.h index 84c1490..89a45c1 100644 --- a/game/src/battle.h +++ b/game/src/battle.h @@ -22,7 +22,7 @@ extern bool battle_is_attackable(LPCHARACTER ch, LPCHARACTER victim); extern int battle_melee_attack(LPCHARACTER ch, LPCHARACTER victim); extern void battle_end(LPCHARACTER ch); -extern bool battle_distance_valid_by_xy(long x, long y, long tx, long ty); +extern bool battle_distance_valid_by_xy(int x, int y, int tx, int ty); extern bool battle_distance_valid(LPCHARACTER ch, LPCHARACTER victim); extern int battle_count_attackers(LPCHARACTER ch); @@ -35,7 +35,7 @@ inline void AttackAffect(LPCHARACTER pkAttacker, DWORD immune_flag, DWORD affect_idx, BYTE affect_point, - long affect_amount, + int affect_amount, DWORD affect_flag, int time, const char* name) @@ -63,7 +63,7 @@ inline void SkillAttackAffect(LPCHARACTER pkVictim, DWORD immune_flag, DWORD affect_idx, BYTE affect_point, - long affect_amount, + int affect_amount, DWORD affect_flag, int time, const char* name) diff --git a/game/src/block_country.cpp b/game/src/block_country.cpp index 5f59fe0..a05aa25 100644 --- a/game/src/block_country.cpp +++ b/game/src/block_country.cpp @@ -113,7 +113,7 @@ bool is_blocked_country_ip(const char *user_ip) #ifndef __WIN32__ if (0 == inet_aton(user_ip, &st_addr)) #else - unsigned long in_address; + unsigned int in_address; in_address = inet_addr(user_ip); st_addr.s_addr = in_address; if (INADDR_NONE == in_address) diff --git a/game/src/building.cpp b/game/src/building.cpp index 0d2d775..201f425 100644 --- a/game/src/building.cpp +++ b/game/src/building.cpp @@ -54,7 +54,7 @@ void CObject::Destroy() GetY() + m_pProto->lRegion[1], GetX() + m_pProto->lRegion[2], GetY() + m_pProto->lRegion[3], - (long)m_data.zRot, // ADD_BUILDING_ROTATION + (int)m_data.zRot, // ADD_BUILDING_ROTATION ATTR_OBJECT, ATTR_REGION_MODE_REMOVE); } @@ -147,7 +147,7 @@ void CObject::SetVID(DWORD dwVID) m_dwVID = dwVID; } -bool CObject::Show(long lMapIndex, long x, long y) +bool CObject::Show(int lMapIndex, int x, int y) { LPSECTREE tree = SECTREE_MANAGER::instance().Get(lMapIndex, x, y); @@ -180,7 +180,7 @@ bool CObject::Show(long lMapIndex, long x, long y) y + m_pProto->lRegion[1], x + m_pProto->lRegion[2], y + m_pProto->lRegion[3], - (long)m_data.zRot, + (int)m_data.zRot, ATTR_OBJECT, ATTR_REGION_MODE_SET); @@ -473,11 +473,11 @@ void CLand::DeleteObject(DWORD dwID) struct FIsIn { - long sx, sy; - long ex, ey; + int sx, sy; + int ex, ey; bool bIn; - FIsIn ( long sx_, long sy_, long ex_, long ey_) + FIsIn ( int sx_, int sy_, int ex_, int ey_) : sx(sx_), sy(sy_), ex(ex_), ey(ey_), bIn(false) {} @@ -499,7 +499,7 @@ struct FIsIn } }; -bool CLand::RequestCreateObject(DWORD dwVnum, long lMapIndex, long x, long y, float xRot, float yRot, float zRot, bool checkAnother) +bool CLand::RequestCreateObject(DWORD dwVnum, int lMapIndex, int x, int y, float xRot, float yRot, float zRot, bool checkAnother) { SECTREE_MANAGER& rkSecTreeMgr = SECTREE_MANAGER::instance(); TObjectProto * pkProto = CManager::instance().GetObjectProto(dwVnum); @@ -546,7 +546,7 @@ bool CLand::RequestCreateObject(DWORD dwVnum, long lMapIndex, long x, long y, fl // ADD_BUILDING_ROTATION if ( checkAnother ) { - if (rkSecTreeMgr.ForAttrRegion(lMapIndex, osx, osy, oex, oey, (long)zRot, ATTR_OBJECT, ATTR_REGION_MODE_CHECK)) + if (rkSecTreeMgr.ForAttrRegion(lMapIndex, osx, osy, oex, oey, (int)zRot, ATTR_OBJECT, ATTR_REGION_MODE_CHECK)) { sys_err("another object already exist"); return false; @@ -748,7 +748,7 @@ void CManager::UpdateLand(TLand * pTable) // we must send the guild name first d->GetCharacter()->SendGuildName(guild); - d->BufferedPacket(&p, sizeof(TPacketGCLandList)); + d->RawPacket(&p, sizeof(TPacketGCLandList)); d->Packet(&e, sizeof(TLandPacketElement)); } } @@ -764,7 +764,7 @@ CLand * CManager::FindLand(DWORD dwID) return it->second; } -CLand * CManager::FindLand(long lMapIndex, long x, long y) +CLand * CManager::FindLand(int lMapIndex, int x, int y) { sys_log(0, "BUILDING: FindLand %d %d %d", lMapIndex, x, y); @@ -937,7 +937,7 @@ void CManager::UnregisterObject(LPOBJECT pkObj) m_map_pkObjByVID.erase(pkObj->GetVID()); } -void CManager::SendLandList(LPDESC d, long lMapIndex) +void CManager::SendLandList(LPDESC d, int lMapIndex) { TLandPacketElement e; @@ -984,7 +984,7 @@ void CManager::SendLandList(LPDESC d, long lMapIndex) p.header = HEADER_GC_LAND_LIST; p.size = sizeof(TPacketGCLandList) + buf.size(); - d->BufferedPacket(&p, sizeof(TPacketGCLandList)); + d->RawPacket(&p, sizeof(TPacketGCLandList)); d->Packet(buf.read_peek(), buf.size()); } } @@ -1040,7 +1040,7 @@ void CLand::ClearLand() // END_LAND_CLEAR // BUILD_WALL -void CLand::DrawWall(DWORD dwVnum, long nMapIndex, long& x, long& y, char length, float zRot) +void CLand::DrawWall(DWORD dwVnum, int nMapIndex, int& x, int& y, char length, float zRot) { int rot = (int)zRot; rot = ((rot%360) / 90) * 90; @@ -1079,7 +1079,7 @@ void CLand::DrawWall(DWORD dwVnum, long nMapIndex, long& x, long& y, char length } -bool CLand::RequestCreateWall(long nMapIndex, float rot) +bool CLand::RequestCreateWall(int nMapIndex, float rot) { const bool WALL_ANOTHER_CHECKING_ENABLE = false; @@ -1171,19 +1171,19 @@ void CLand::RequestDeleteWall() } } -bool CLand::RequestCreateWallBlocks(DWORD dwVnum, long nMapIndex, char wallSize, bool doorEast, bool doorWest, bool doorSouth, bool doorNorth) +bool CLand::RequestCreateWallBlocks(DWORD dwVnum, int nMapIndex, char wallSize, bool doorEast, bool doorWest, bool doorSouth, bool doorNorth) { const TLand & r = GetData(); - long startX = r.x + (r.width / 2) - (1300 + wallSize*500); - long startY = r.y + (r.height / 2) + (1300 + wallSize*500); + int startX = r.x + (r.width / 2) - (1300 + wallSize*500); + int startY = r.y + (r.height / 2) + (1300 + wallSize*500); DWORD corner = dwVnum - 4; DWORD wall = dwVnum - 3; DWORD door = dwVnum - 1; bool checkAnother = false; - long* ptr = NULL; + int* ptr = NULL; int delta = 1; int rot = 270; diff --git a/game/src/building.h b/game/src/building.h index 2adda9a..edfb5ab 100644 --- a/game/src/building.h +++ b/game/src/building.h @@ -23,7 +23,7 @@ namespace building void SetVID(DWORD dwVID); DWORD GetVID() { return m_dwVID; } - bool Show(long lMapIndex, long x, long y); + bool Show(int lMapIndex, int x, int y); void Save(); @@ -76,7 +76,7 @@ namespace building LPOBJECT FindObjectByNPC(LPCHARACTER npc); void DeleteObject(DWORD dwID); - bool RequestCreateObject(DWORD dwVnum, long lMapIndex, long x, long y, float xRot, float yRot, float zRot, bool checkAnother); + bool RequestCreateObject(DWORD dwVnum, int lMapIndex, int x, int y, float xRot, float yRot, float zRot, bool checkAnother); void RequestDeleteObject(DWORD dwID); void RequestDeleteObjectByVID(DWORD dwVID); @@ -87,10 +87,10 @@ namespace building // END_LAND_CLEAR // BUILD_WALL - bool RequestCreateWall(long nMapIndex, float rot); + bool RequestCreateWall(int nMapIndex, float rot); void RequestDeleteWall(); - bool RequestCreateWallBlocks(DWORD dwVnum, long nMapIndex, char wallSize, bool doorEast, bool doorWest, bool doorSouth, bool doorNorth); + bool RequestCreateWallBlocks(DWORD dwVnum, int nMapIndex, char wallSize, bool doorEast, bool doorWest, bool doorSouth, bool doorNorth); void RequestDeleteWallBlocks(DWORD dwVnum); // END_BUILD_WALL @@ -103,7 +103,7 @@ namespace building // BUILD_WALL private : - void DrawWall(DWORD dwVnum, long nMapIndex, long& centerX, long& centerY, char length, float zRot); + void DrawWall(DWORD dwVnum, int nMapIndex, int& centerX, int& centerY, char length, float zRot); // END_BUILD_WALL }; @@ -122,7 +122,7 @@ namespace building bool LoadLand(TLand * pTable); CLand * FindLand(DWORD dwID); - CLand * FindLand(long lMapIndex, long x, long y); + CLand * FindLand(int lMapIndex, int x, int y); CLand * FindLandByGuild(DWORD GID); void UpdateLand(TLand * pTable); @@ -132,7 +132,7 @@ namespace building LPOBJECT FindObjectByVID(DWORD dwVID); - void SendLandList(LPDESC d, long lMapIndex); + void SendLandList(LPDESC d, int lMapIndex); // LAND_CLEAR void ClearLand(DWORD dwLandID); diff --git a/game/src/castle.cpp b/game/src/castle.cpp index 2866e4f..fb42df1 100644 --- a/game/src/castle.cpp +++ b/game/src/castle.cpp @@ -220,7 +220,7 @@ static GUARD_REGION s_tower_region[4] = { }; -static long FN_castle_map_index(int empire); +static int FN_castle_map_index(int empire); EVENTINFO(castle_event_info) { @@ -324,7 +324,7 @@ EVENTFUNC(castle_stone_event) return 0; } - long map_index = FN_castle_map_index(GET_SIEGE_EMPIRE()); + int map_index = FN_castle_map_index(GET_SIEGE_EMPIRE()); SECTREE_MAP *sectree_map = SECTREE_MANAGER::instance().GetMap(map_index); @@ -363,7 +363,7 @@ EVENTFUNC(castle_stone_event) LPCHARACTER castle_spawn_frog_force(int empire, int empty_index); -static long FN_castle_map_index(int empire) +static int FN_castle_map_index(int empire) { switch (empire) { @@ -647,7 +647,7 @@ void castle_end_siege() LPCHARACTER castle_spawn_frog(int empire) { int dir = 1; - long map_index = FN_castle_map_index(empire); + int map_index = FN_castle_map_index(empire); /* Ȳ±ÝµÎ²¨ºñ ¼ÒȯÇÒ °÷ÀÌ ÀÖ³ª? */ POSITION *empty_pos = FN_empty_frog_pos(empire); @@ -677,7 +677,7 @@ LPCHARACTER castle_spawn_frog(int empire) LPCHARACTER castle_spawn_frog_force(int empire, int empty_index) { int dir = 1; - long map_index = FN_castle_map_index(empire); + int map_index = FN_castle_map_index(empire); POSITION *empty_pos = &GET_FROG_POS(empire, empty_index); @@ -706,7 +706,7 @@ LPCHARACTER castle_spawn_guard(int empire, DWORD group_vnum, int region_index) { LPCHARACTER mob; int sx, sy, ex, ey; - long map_index = FN_castle_map_index(empire); + int map_index = FN_castle_map_index(empire); SECTREE_MAP *sectree_map = SECTREE_MANAGER::instance().GetMap(map_index); if (NULL == sectree_map) diff --git a/game/src/char.cpp b/game/src/char.cpp index 039aead..3de9100 100644 --- a/game/src/char.cpp +++ b/game/src/char.cpp @@ -1306,14 +1306,14 @@ void CHARACTER::Disconnect(const char * c_pszReason) strncpy(p.szName, GetName(), sizeof(p.szName)); P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGLogout)); char buf[51]; - snprintf(buf, sizeof(buf), "%s %d %d %ld %d", - inet_ntoa(GetDesc()->GetAddr().sin_addr), GetGold(), g_bChannel, GetMapIndex(), GetAlignment()); + snprintf(buf, sizeof(buf), "%s %d %d %d %d", + GetDesc()->GetHostName(), GetGold(), g_bChannel, GetMapIndex(), GetAlignment()); LogManager::instance().CharLog(this, 0, "LOGOUT", buf); if (LC_IsYMIR() || LC_IsKorea() || LC_IsBrazil()) { - long playTime = GetRealPoint(POINT_PLAYTIME) - m_dwLoginPlayTime; + int playTime = GetRealPoint(POINT_PLAYTIME) - m_dwLoginPlayTime; LogManager::instance().LoginLog(false, GetDesc()->GetAccountTable().id, GetPlayerID(), GetLevel(), GetJob(), playTime); if (LC_IsBrazil() != true) @@ -1395,7 +1395,7 @@ void CHARACTER::Disconnect(const char * c_pszReason) M2_DESTROY_CHARACTER(this); } -bool CHARACTER::Show(long lMapIndex, long x, long y, long z, bool bShowSpawnMotion/* = false */) +bool CHARACTER::Show(int lMapIndex, int x, int y, int z, bool bShowSpawnMotion/* = false */) { LPSECTREE sectree = SECTREE_MANAGER::instance().Get(lMapIndex, x, y); @@ -2195,22 +2195,22 @@ void CHARACTER::ComputeBattlePoints() void CHARACTER::ComputePoints() { - long lStat = GetPoint(POINT_STAT); - long lStatResetCount = GetPoint(POINT_STAT_RESET_COUNT); - long lSkillActive = GetPoint(POINT_SKILL); - long lSkillSub = GetPoint(POINT_SUB_SKILL); - long lSkillHorse = GetPoint(POINT_HORSE_SKILL); - long lLevelStep = GetPoint(POINT_LEVEL_STEP); + int lStat = GetPoint(POINT_STAT); + int lStatResetCount = GetPoint(POINT_STAT_RESET_COUNT); + int lSkillActive = GetPoint(POINT_SKILL); + int lSkillSub = GetPoint(POINT_SUB_SKILL); + int lSkillHorse = GetPoint(POINT_HORSE_SKILL); + int lLevelStep = GetPoint(POINT_LEVEL_STEP); - long lAttackerBonus = GetPoint(POINT_PARTY_ATTACKER_BONUS); - long lTankerBonus = GetPoint(POINT_PARTY_TANKER_BONUS); - long lBufferBonus = GetPoint(POINT_PARTY_BUFFER_BONUS); - long lSkillMasterBonus = GetPoint(POINT_PARTY_SKILL_MASTER_BONUS); - long lHasteBonus = GetPoint(POINT_PARTY_HASTE_BONUS); - long lDefenderBonus = GetPoint(POINT_PARTY_DEFENDER_BONUS); + int lAttackerBonus = GetPoint(POINT_PARTY_ATTACKER_BONUS); + int lTankerBonus = GetPoint(POINT_PARTY_TANKER_BONUS); + int lBufferBonus = GetPoint(POINT_PARTY_BUFFER_BONUS); + int lSkillMasterBonus = GetPoint(POINT_PARTY_SKILL_MASTER_BONUS); + int lHasteBonus = GetPoint(POINT_PARTY_HASTE_BONUS); + int lDefenderBonus = GetPoint(POINT_PARTY_DEFENDER_BONUS); - long lHPRecovery = GetPoint(POINT_HP_RECOVERY); - long lSPRecovery = GetPoint(POINT_SP_RECOVERY); + int lHPRecovery = GetPoint(POINT_HP_RECOVERY); + int lSPRecovery = GetPoint(POINT_SP_RECOVERY); memset(m_pointsInstant.points, 0, sizeof(m_pointsInstant.points)); BuffOnAttr_ClearAll(); @@ -2564,7 +2564,7 @@ void CHARACTER::SetRotation(float fRot) } // x, y ¹æÇâÀ¸·Î º¸°í ¼±´Ù. -void CHARACTER::SetRotationToXY(long x, long y) +void CHARACTER::SetRotationToXY(int x, int y) { SetRotation(GetDegreeFromPositionXY(GetX(), GetY(), x, y)); } @@ -2591,7 +2591,7 @@ bool CHARACTER::CanMove() const } // ¹«Á¶°Ç x, y À§Ä¡·Î À̵¿ ½ÃŲ´Ù. -bool CHARACTER::Sync(long x, long y) +bool CHARACTER::Sync(int x, int y) { if (!GetSectree()) return false; @@ -2670,7 +2670,7 @@ void CHARACTER::Stop() m_posDest.y = m_posStart.y = GetY(); } -bool CHARACTER::Goto(long x, long y) +bool CHARACTER::Goto(int x, int y) { // TODO °Å¸®Ã¼Å© ÇÊ¿ä // °°Àº À§Ä¡¸é À̵¿ÇÒ ÇÊ¿ä ¾øÀ½ (ÀÚµ¿ ¼º°ø) @@ -2808,7 +2808,7 @@ void CHARACTER::CalculateMoveDuration() // Ŭ¶ó¿¡¼­´Â ÀÌÀü À§Ä¡¿¡¼­ ¹Ù²Û x, y±îÁö interpolationÇÑ´Ù. // °È°Å³ª ¶Ù´Â °ÍÀº charÀÇ m_bNowWalking¿¡ ´Þ·ÁÀÖ´Ù. // Warp¸¦ ÀǵµÇÑ °ÍÀ̶ó¸é Show¸¦ »ç¿ëÇÒ °Í. -bool CHARACTER::Move(long x, long y) +bool CHARACTER::Move(int x, int y) { // °°Àº À§Ä¡¸é À̵¿ÇÒ ÇÊ¿ä ¾øÀ½ (ÀÚµ¿ ¼º°ø) if (GetX() == x && GetY() == y) @@ -5165,7 +5165,7 @@ void CHARACTER::CheckTarget() SetTarget(NULL); } -void CHARACTER::SetWarpLocation(long lMapIndex, long x, long y) +void CHARACTER::SetWarpLocation(int lMapIndex, int x, int y) { m_posWarp.x = x * 100; m_posWarp.y = y * 100; @@ -5191,13 +5191,13 @@ void CHARACTER::ExitToSavedLocation() // Áö±Ý±îÁø privateMapIndex °¡ ÇöÀç ¸Ê À妽º¿Í °°ÀºÁö üũ ÇÏ´Â °ÍÀ» ¿ÜºÎ¿¡¼­ ÇÏ°í, // ´Ù¸£¸é warpsetÀ» ºÒ·¶´Âµ¥ // À̸¦ warpset ¾ÈÀ¸·Î ³ÖÀÚ. -bool CHARACTER::WarpSet(long x, long y, long lPrivateMapIndex) +bool CHARACTER::WarpSet(int x, int y, int lPrivateMapIndex) { if (!IsPC()) return false; - long lAddr; - long lMapIndex; + LONG lAddr; + int lMapIndex; WORD wPort; if (!CMapLocation::instance().Get(x, y, lMapIndex, lAddr, wPort)) @@ -5208,8 +5208,8 @@ bool CHARACTER::WarpSet(long x, long y, long lPrivateMapIndex) //Send Supplementary Data Block if new map requires security packages in loading this map { - long lCurAddr; - long lCurMapIndex = 0; + LONG lCurAddr; + int lCurMapIndex = 0; WORD wCurPort; CMapLocation::instance().Get(GetX(), GetY(), lCurMapIndex, lCurAddr, wCurPort); @@ -5265,7 +5265,7 @@ bool CHARACTER::WarpSet(long x, long y, long lPrivateMapIndex) //if (!LC_IsNewCIBN()) { char buf[256]; - snprintf(buf, sizeof(buf), "%s MapIdx %ld DestMapIdx%ld DestX%ld DestY%ld Empire%d", GetName(), GetMapIndex(), lPrivateMapIndex, x, y, GetEmpire()); + snprintf(buf, sizeof(buf), "%s MapIdx %d DestMapIdx%d DestX%d DestY%d Empire%d", GetName(), GetMapIndex(), lPrivateMapIndex, x, y, GetEmpire()); LogManager::instance().CharLog(this, 0, "WARP", buf); } @@ -5379,8 +5379,8 @@ bool CHARACTER::Follow(LPCHARACTER pkChr, float fMinDistance) } // END_OF_TRENT_MONSTER - long x = pkChr->GetX(); - long y = pkChr->GetY(); + int x = pkChr->GetX(); + int y = pkChr->GetY(); if (pkChr->IsPC()) // ÂѾư¡´Â »ó´ë°¡ PCÀÏ ¶§ { @@ -5430,14 +5430,14 @@ bool CHARACTER::Follow(LPCHARACTER pkChr, float fMinDistance) { GetDeltaByDegree(pkChr->GetRotation(), fMeetTime * yourSpeed, &fYourMoveEstimateX, &fYourMoveEstimateY); - x += (long) fYourMoveEstimateX; - y += (long) fYourMoveEstimateY; + x += (int) fYourMoveEstimateX; + y += (int) fYourMoveEstimateY; float fDistNew = sqrt(((double)x - GetX())*(x-GetX())+((double)y - GetY())*(y-GetY())); if (fDist < fDistNew) { - x = (long)(GetX() + (x - GetX()) * fDist / fDistNew); - y = (long)(GetY() + (y - GetY()) * fDist / fDistNew); + x = (int)(GetX() + (x - GetX()) * fDist / fDistNew); + y = (int)(GetY() + (y - GetY()) * fDist / fDistNew); } } } @@ -6325,7 +6325,7 @@ namespace { char szTmp[64]; - if (3 != sscanf(pkWarp->GetName(), " %s %ld %ld ", szTmp, &m_lTargetX, &m_lTargetY)) + if (3 != sscanf(pkWarp->GetName(), " %s %d %d ", szTmp, &m_lTargetX, &m_lTargetY)) { if (number(1, 100) < 5) sys_err("Warp NPC name wrong : vnum(%d) name(%s)", pkWarp->GetRaceNum(), pkWarp->GetName()); @@ -6393,10 +6393,10 @@ namespace { bool m_bInvalid; bool m_bUseWarp; - long m_lX; - long m_lY; - long m_lTargetX; - long m_lTargetY; + int m_lX; + int m_lY; + int m_lTargetX; + int m_lTargetY; BYTE m_bEmpire; }; diff --git a/game/src/char.h b/game/src/char.h index bb03ba1..c2ba563 100644 --- a/game/src/char.h +++ b/game/src/char.h @@ -355,14 +355,14 @@ struct DynamicCharacterPtr { /* ÀúÀåÇÏ´Â µ¥ÀÌÅÍ */ typedef struct character_point { - long points[POINT_MAX_NUM]; + int points[POINT_MAX_NUM]; BYTE job; BYTE voice; BYTE level; DWORD exp; - long gold; + int gold; int hp; int sp; @@ -378,16 +378,16 @@ typedef struct character_point /* ÀúÀåµÇÁö ¾Ê´Â ij¸¯ÅÍ µ¥ÀÌÅÍ */ typedef struct character_point_instant { - long points[POINT_MAX_NUM]; + int points[POINT_MAX_NUM]; float fRot; int iMaxHP; int iMaxSP; - long position; + int position; - long instant_flag; + int instant_flag; DWORD dwAIFlag; DWORD dwImmuneFlag; DWORD dwLastShoutPulse; @@ -425,7 +425,7 @@ typedef struct trigger { BYTE type; int (*func) (TRIGGERPARAM); - long value; + int value; } TRIGGER; class CTrigger @@ -726,13 +726,13 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider void ApplyPoint(BYTE bApplyType, int iVal); void CheckMaximumPoints(); // HP, SP µîÀÇ ÇöÀç °ªÀÌ ÃÖ´ë°ª º¸´Ù ³ôÀºÁö °Ë»çÇÏ°í ³ô´Ù¸é ³·Ãá´Ù. - bool Show(long lMapIndex, long x, long y, long z = LONG_MAX, bool bShowSpawnMotion = false); + bool Show(int lMapIndex, int x, int y, int z = INT_MAX, bool bShowSpawnMotion = false); void Sitdown(int is_ground); void Standup(); void SetRotation(float fRot); - void SetRotationToXY(long x, long y); + void SetRotationToXY(int x, int y); float GetRotation() const { return m_pointsInstant.fRot; } void MotionPacketEncode(BYTE motion, LPCHARACTER victim, struct packet_motion * packet); @@ -806,14 +806,14 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider void SetNowWalking(bool bWalkFlag); void ResetWalking() { SetNowWalking(m_bWalking); } - bool Goto(long x, long y); // ¹Ù·Î À̵¿ ½ÃÅ°Áö ¾Ê°í ¸ñÇ¥ À§Ä¡·Î BLENDING ½ÃŲ´Ù. + bool Goto(int x, int y); // ¹Ù·Î À̵¿ ½ÃÅ°Áö ¾Ê°í ¸ñÇ¥ À§Ä¡·Î BLENDING ½ÃŲ´Ù. void Stop(); bool CanMove() const; // À̵¿ÇÒ ¼ö Àִ°¡? void SyncPacket(); - bool Sync(long x, long y); // ½ÇÁ¦ ÀÌ ¸Þ¼Òµå·Î À̵¿ ÇÑ´Ù (°¢ Á¾ Á¶°Ç¿¡ ÀÇÇÑ À̵¿ ºÒ°¡°¡ ¾øÀ½) - bool Move(long x, long y); // Á¶°ÇÀ» °Ë»çÇÏ°í Sync ¸Þ¼Òµå¸¦ ÅëÇØ À̵¿ ÇÑ´Ù. + bool Sync(int x, int y); // ½ÇÁ¦ ÀÌ ¸Þ¼Òµå·Î À̵¿ ÇÑ´Ù (°¢ Á¾ Á¶°Ç¿¡ ÀÇÇÑ À̵¿ ºÒ°¡°¡ ¾øÀ½) + bool Move(int x, int y); // Á¶°ÇÀ» °Ë»çÇÏ°í Sync ¸Þ¼Òµå¸¦ ÅëÇØ À̵¿ ÇÑ´Ù. void OnMove(bool bIsAttack = false); // ¿òÁ÷À϶§ ºÒ¸°´Ù. Move() ¸Þ¼Òµå ÀÌ¿Ü¿¡¼­µµ ºÒ¸± ¼ö ÀÖ´Ù. DWORD GetMotionMode() const; float GetMoveMotionSpeed() const; @@ -830,8 +830,8 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider bool SetSyncOwner(LPCHARACTER ch, bool bRemoveFromList = true); bool IsSyncOwner(LPCHARACTER ch) const; - bool WarpSet(long x, long y, long lRealMapIndex = 0); - void SetWarpLocation(long lMapIndex, long x, long y); + bool WarpSet(int x, int y, int lRealMapIndex = 0); + void SetWarpLocation(int lMapIndex, int x, int y); void WarpEnd(); const PIXEL_POSITION & GetWarpPosition() const { return m_posWarp; } bool WarpToPID(DWORD dwPID); @@ -857,10 +857,10 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider PIXEL_POSITION m_posDest; PIXEL_POSITION m_posStart; PIXEL_POSITION m_posWarp; - long m_lWarpMapIndex; + int m_lWarpMapIndex; PIXEL_POSITION m_posExit; - long m_lExitMapIndex; + int m_lExitMapIndex; DWORD m_dwMoveStartTime; DWORD m_dwMoveDuration; @@ -893,7 +893,7 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider void StartAffectEvent(); void ClearAffect(bool bSave=false); void ComputeAffect(CAffect * pkAff, bool bAdd); - bool AddAffect(DWORD dwType, BYTE bApplyOn, long lApplyValue, DWORD dwFlag, long lDuration, long lSPCost, bool bOverride, bool IsCube = false); + bool AddAffect(DWORD dwType, BYTE bApplyOn, int lApplyValue, DWORD dwFlag, int lDuration, int lSPCost, bool bOverride, bool IsCube = false); void RefreshAffect(); bool RemoveAffect(DWORD dwType); bool IsAffectFlag(DWORD dwAff) const; @@ -1122,7 +1122,7 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider bool SwapItem(BYTE bCell, BYTE bDestCell); LPITEM AutoGiveItem(DWORD dwItemVnum, BYTE bCount=1, int iRarePct = -1, bool bMsg = true); - void AutoGiveItem(LPITEM item, bool longOwnerShip = false); + void AutoGiveItem(LPITEM item, bool intOwnerShip = false); int GetEmptyInventory(BYTE size) const; int GetEmptyDragonSoulInventory(LPITEM pItem) const; @@ -1249,7 +1249,7 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider void RewardGold(LPCHARACTER pkAttacker); bool Shoot(BYTE bType); - void FlyTarget(DWORD dwTargetVID, long x, long y, BYTE bHeader); + void FlyTarget(DWORD dwTargetVID, int x, int y, BYTE bHeader); void ForgetMyAttacker(); void AggregateMonster(); diff --git a/game/src/char_affect.cpp b/game/src/char_affect.cpp index 1c454d1..db8d099 100644 --- a/game/src/char_affect.cpp +++ b/game/src/char_affect.cpp @@ -272,8 +272,8 @@ int CHARACTER::ProcessAffect() CHorseNameManager::instance().Validate(this); TAffectFlag afOld = m_afAffectFlag; - long lMovSpd = GetPoint(POINT_MOV_SPEED); - long lAttSpd = GetPoint(POINT_ATT_SPEED); + int lMovSpd = GetPoint(POINT_MOV_SPEED); + int lAttSpd = GetPoint(POINT_ATT_SPEED); itertype(m_list_pkAffect) it; @@ -467,8 +467,8 @@ void CHARACTER::LoadAffect(DWORD dwCount, TPacketAffectElement * pElements) TAffectFlag afOld = m_afAffectFlag; - long lMovSpd = GetPoint(POINT_MOV_SPEED); - long lAttSpd = GetPoint(POINT_ATT_SPEED); + int lMovSpd = GetPoint(POINT_MOV_SPEED); + int lAttSpd = GetPoint(POINT_ATT_SPEED); for (DWORD i = 0; i < dwCount; ++i, ++pElements) { @@ -533,7 +533,7 @@ void CHARACTER::LoadAffect(DWORD dwCount, TPacketAffectElement * pElements) DragonSoul_Initialize(); } -bool CHARACTER::AddAffect(DWORD dwType, BYTE bApplyOn, long lApplyValue, DWORD dwFlag, long lDuration, long lSPCost, bool bOverride, bool IsCube ) +bool CHARACTER::AddAffect(DWORD dwType, BYTE bApplyOn, int lApplyValue, DWORD dwFlag, int lDuration, int lSPCost, bool bOverride, bool IsCube ) { // CHAT_BLOCK if (dwType == AFFECT_BLOCK_CHAT && lDuration > 1) diff --git a/game/src/char_battle.cpp b/game/src/char_battle.cpp index 41aa5dd..65759f6 100644 --- a/game/src/char_battle.cpp +++ b/game/src/char_battle.cpp @@ -1433,7 +1433,7 @@ void CHARACTER::Dead(LPCHARACTER pkKiller, bool bImmediateDead) if (GetMobRank() >= MOB_RANK_BOSS && pkKiller && pkKiller->IsPC()) { char buf[51]; - snprintf(buf, sizeof(buf), "%d %ld", g_bChannel, pkKiller->GetMapIndex()); + snprintf(buf, sizeof(buf), "%d %d", g_bChannel, pkKiller->GetMapIndex()); if (IsStone()) LogManager::instance().CharLog(pkKiller, GetRaceNum(), "STONE_KILL", buf); else @@ -2077,7 +2077,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu // Á¦±¹À¸·Î ÀÎÇÑ º¸³Ê½º (Çѱ¹ ¿Ãµå ¹öÀü¸¸ Àû¿ë) // int iEmpire = GetEmpire(); - long lMapIndex = GetMapIndex(); + int lMapIndex = GetMapIndex(); int iMapEmpire = SECTREE_MANAGER::instance().GetEmpireFromMapIndex(lMapIndex); if (LC_IsYMIR() == true) @@ -2854,7 +2854,7 @@ class CFuncShoot BYTE m_bType; bool m_bSucceed; - CFuncShoot(LPCHARACTER ch, BYTE bType) : m_me(ch), m_bType(bType), m_bSucceed(FALSE) + CFuncShoot(LPCHARACTER ch, BYTE bType) : m_me(ch), m_bType(bType), m_bSucceed(false) { } @@ -3159,7 +3159,7 @@ bool CHARACTER::Shoot(BYTE bType) return f.m_bSucceed; } -void CHARACTER::FlyTarget(DWORD dwTargetVID, long x, long y, BYTE bHeader) +void CHARACTER::FlyTarget(DWORD dwTargetVID, int x, int y, BYTE bHeader) { LPCHARACTER pkVictim = CHARACTER_MANAGER::instance().Find(dwTargetVID); TPacketGCFlyTargeting pack; @@ -3479,8 +3479,8 @@ struct FuncPullMonster float fy; GetDeltaByDegree(degree, fDist - fNewDist, &fx, &fy); - long tx = (long)(ch->GetX() + fx); - long ty = (long)(ch->GetY() + fy); + int tx = (int)(ch->GetX() + fx); + int ty = (int)(ch->GetY() + fy); ch->Sync(tx, ty); ch->Goto(tx, ty); diff --git a/game/src/char_dragonsoul.cpp b/game/src/char_dragonsoul.cpp index 308ccaa..e561447 100644 --- a/game/src/char_dragonsoul.cpp +++ b/game/src/char_dragonsoul.cpp @@ -88,6 +88,8 @@ bool CHARACTER::DragonSoul_ActivateDeck(int deck_idx) if (NULL != pItem) DSManager::instance().ActivateDragonSoul(pItem); } + + return true; } void CHARACTER::DragonSoul_DeactivateAll() diff --git a/game/src/char_horse.cpp b/game/src/char_horse.cpp index aafd0cc..fd19442 100644 --- a/game/src/char_horse.cpp +++ b/game/src/char_horse.cpp @@ -153,8 +153,8 @@ void CHARACTER::HorseSummon(bool bSummon, bool bFromFar, DWORD dwVnum, const cha sys_log(0, "HorseSummon : %s lv:%d bSummon:%d fromFar:%d", GetName(), GetLevel(), bSummon, bFromFar); - long x = GetX(); - long y = GetY(); + int x = GetX(); + int y = GetY(); if (GetHorseHealth() <= 0) bFromFar = false; @@ -245,7 +245,7 @@ void CHARACTER::HorseSummon(bool bSummon, bool bFromFar, DWORD dwVnum, const cha float fx, fy; chHorse->SetRotation(GetDegreeFromPositionXY(chHorse->GetX(), chHorse->GetY(), GetX(), GetY())+180); GetDeltaByDegree(chHorse->GetRotation(), 3500, &fx, &fy); - chHorse->Goto((long)(chHorse->GetX()+fx), (long) (chHorse->GetY()+fy)); + chHorse->Goto((int)(chHorse->GetX()+fx), (int) (chHorse->GetY()+fy)); chHorse->SendMovePacket(FUNC_WAIT, 0, 0, 0, 0); } diff --git a/game/src/char_item.cpp b/game/src/char_item.cpp index 079d739..6efe4ab 100644 --- a/game/src/char_item.cpp +++ b/game/src/char_item.cpp @@ -676,6 +676,8 @@ bool CHARACTER::IsEmptyItemGrid(TItemPos Cell, BYTE bSize, int iExceptionCell) c } } } + + return false; } int CHARACTER::GetEmptyInventory(BYTE size) const @@ -755,7 +757,7 @@ void TransformRefineItem(LPITEM pkOldItem, LPITEM pkNewItem) for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i) { - long socket = pkOldItem->GetSocket(i); + int socket = pkOldItem->GetSocket(i); if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM) pkNewItem->SetSocket(slot++, socket); @@ -866,7 +868,7 @@ bool CHARACTER::DoRefine(LPITEM item, bool bMoneyOnly) { for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i) { - long limit = pProto->aLimits[i].lValue; + int limit = pProto->aLimits[i].lValue; switch (pProto->aLimits[i].bType) { @@ -1071,7 +1073,7 @@ bool CHARACTER::DoRefineWithScroll(LPITEM item) { for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i) { - long limit = pProto->aLimits[i].lValue; + int limit = pProto->aLimits[i].lValue; switch (pProto->aLimits[i].bType) { @@ -1390,7 +1392,7 @@ bool CHARACTER::RefineItem(LPITEM pkItem, LPITEM pkTarget) for (int i = 0; i < ITEM_SOCKET_MAX_NUM; i++) { - long socket = pkTarget->GetSocket(i); + int socket = pkTarget->GetSocket(i); if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM) { bHasMetinStone = true; @@ -1402,7 +1404,7 @@ bool CHARACTER::RefineItem(LPITEM pkItem, LPITEM pkTarget) { for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i) { - long socket = pkTarget->GetSocket(i); + int socket = pkTarget->GetSocket(i); if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM) { AutoGiveItem(socket); @@ -1672,7 +1674,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell) BYTE bDestInven = DestCell.window_type; for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i) { - long limitValue = item->GetProto()->aLimits[i].lValue; + int limitValue = item->GetProto()->aLimits[i].lValue; switch (item->GetProto()->aLimits[i].bType) { @@ -1712,7 +1714,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell) if (0 == item->GetSocket(1)) { // »ç¿ë°¡´É½Ã°£Àº Default °ªÀ¸·Î Limit Value °ªÀ» »ç¿ëÇϵÇ, Socket0¿¡ °ªÀÌ ÀÖÀ¸¸é ±× °ªÀ» »ç¿ëÇϵµ·Ï ÇÑ´Ù. (´ÜÀ§´Â ÃÊ) - long duration = (0 != item->GetSocket(0)) ? item->GetSocket(0) : item->GetProto()->aLimits[iLimitRealtimeStartFirstUseFlagIndex].lValue; + int duration = (0 != item->GetSocket(0)) ? item->GetSocket(0) : item->GetProto()->aLimits[iLimitRealtimeStartFirstUseFlagIndex].lValue; if (0 == duration) duration = 60 * 60 * 24 * 7; @@ -1761,7 +1763,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell) float fx, fy; GetDeltaByDegree(GetRotation(), 100.0f, &fx, &fy); - LPSECTREE tree = SECTREE_MANAGER::instance().Get(GetMapIndex(), (long)(GetX()+fx), (long)(GetY()+fy)); + LPSECTREE tree = SECTREE_MANAGER::instance().Get(GetMapIndex(), (int)(GetX()+fx), (int)(GetY()+fy)); if (!tree) { @@ -1769,13 +1771,13 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell) return false; } - if (tree->IsAttr((long)(GetX()+fx), (long)(GetY()+fy), ATTR_WATER)) + if (tree->IsAttr((int)(GetX()+fx), (int)(GetY()+fy), ATTR_WATER)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¹° ¼Ó¿¡ ¸ð´ÚºÒÀ» ÇÇ¿ï ¼ö ¾ø½À´Ï´Ù.")); return false; } - LPCHARACTER campfire = CHARACTER_MANAGER::instance().SpawnMob(fishing::CAMPFIRE_MOB, GetMapIndex(), (long)(GetX()+fx), (long)(GetY()+fy), 0, false, number(0, 359)); + LPCHARACTER campfire = CHARACTER_MANAGER::instance().SpawnMob(fishing::CAMPFIRE_MOB, GetMapIndex(), (int)(GetX()+fx), (int)(GetY()+fy), 0, false, number(0, 359)); char_event_info* info = AllocEventInfo(); @@ -1962,7 +1964,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell) DWORD dwBoxVnum = item2->GetVnum(); std::vector dwVnums; std::vector dwCounts; - std::vector item_gets(NULL); + std::vector item_gets; int count = 0; if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count)) @@ -2026,7 +2028,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell) DWORD dwBoxVnum = item->GetVnum(); std::vector dwVnums; std::vector dwCounts; - std::vector item_gets(NULL); + std::vector item_gets; int count = 0; if (dwBoxVnum == 50033 && LC_IsYMIR()) // ¾Ë¼ö¾ø´Â »óÀÚ @@ -2468,10 +2470,10 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell) ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ÀÌ¹Ì È¿°ú°¡ °É·Á ÀÖ½À´Ï´Ù.")); return false; } - long time = item->GetValue(0); - long moveSpeedPer = item->GetValue(1); - long attPer = item->GetValue(2); - long expPer = item->GetValue(3); + int time = item->GetValue(0); + int moveSpeedPer = item->GetValue(1); + int attPer = item->GetValue(2); + int expPer = item->GetValue(3); AddAffect(AFFECT_NOG_ABILITY, POINT_MOV_SPEED, moveSpeedPer, AFF_MOV_SPEED_POTION, time, 0, true, true); AddAffect(AFFECT_NOG_ABILITY, POINT_MALL_ATTBONUS, attPer, AFF_NONE, time, 0, true, true); AddAffect(AFFECT_NOG_ABILITY, POINT_MALL_EXPBONUS, expPer, AFF_NONE, time, 0, true, true); @@ -2490,10 +2492,10 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell) Áö¼Ó½Ã°£ value 0 (´ÜÀ§ ÃÊ) */ - long time = item->GetValue(0); - long moveSpeedPer = item->GetValue(1); - long attPer = item->GetValue(2); - long expPer = item->GetValue(3); + int time = item->GetValue(0); + int moveSpeedPer = item->GetValue(1); + int attPer = item->GetValue(2); + int expPer = item->GetValue(3); AddAffect(AFFECT_RAMADAN_ABILITY, POINT_MOV_SPEED, moveSpeedPer, AFF_MOV_SPEED_POTION, time, 0, true, true); AddAffect(AFFECT_RAMADAN_ABILITY, POINT_MALL_ATTBONUS, attPer, AFF_NONE, time, 0, true, true); AddAffect(AFFECT_RAMADAN_ABILITY, POINT_MALL_EXPBONUS, expPer, AFF_NONE, time, 0, true, true); @@ -3499,7 +3501,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell) return false; } - std::stack socket; + std::stack socket; for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i) socket.push(item2->GetSocket(i)); @@ -3609,7 +3611,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell) DWORD dwBoxVnum = item->GetVnum(); std::vector dwVnums; std::vector dwCounts; - std::vector item_gets(NULL); + std::vector item_gets; int count = 0; @@ -3633,7 +3635,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell) DWORD dwBoxVnum = item->GetVnum(); std::vector dwVnums; std::vector dwCounts; - std::vector item_gets(NULL); + std::vector item_gets; int count = 0; @@ -3656,7 +3658,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell) DWORD dwBoxVnum = 50011; std::vector dwVnums; std::vector dwCounts; - std::vector item_gets(NULL); + std::vector item_gets; int count = 0; if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count)) @@ -6156,7 +6158,7 @@ bool CHARACTER::EquipItem(LPITEM item, int iCandidateCell) if (0 == item->GetSocket(1)) { // »ç¿ë°¡´É½Ã°£Àº Default °ªÀ¸·Î Limit Value °ªÀ» »ç¿ëÇϵÇ, Socket0¿¡ °ªÀÌ ÀÖÀ¸¸é ±× °ªÀ» »ç¿ëÇϵµ·Ï ÇÑ´Ù. (´ÜÀ§´Â ÃÊ) - long duration = (0 != item->GetSocket(0)) ? item->GetSocket(0) : item->GetProto()->aLimits[item->GetProto()->cLimitRealTimeFirstUseIndex].lValue; + int duration = (0 != item->GetSocket(0)) ? item->GetSocket(0) : item->GetProto()->aLimits[item->GetProto()->cLimitRealTimeFirstUseIndex].lValue; if (0 == duration) duration = 60 * 60 * 24 * 7; @@ -7309,8 +7311,8 @@ void CHARACTER::AutoRecoveryItemProcess(const EAffectTypes type) { if (false == CArenaManager::instance().IsArenaMap(GetMapIndex())) { - const long amount_of_used = pItem->GetSocket(idx_of_amount_of_used); - const long amount_of_full = pItem->GetSocket(idx_of_amount_of_full); + const int amount_of_used = pItem->GetSocket(idx_of_amount_of_used); + const int amount_of_full = pItem->GetSocket(idx_of_amount_of_full); const int32_t avail = amount_of_full - amount_of_used; @@ -7446,7 +7448,7 @@ bool CHARACTER::CanEquipNow(const LPITEM item, const TItemPos& srcCell, const TI for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i) { - long limit = itemTable->aLimits[i].lValue; + int limit = itemTable->aLimits[i].lValue; switch (itemTable->aLimits[i].bType) { case LIMIT_LEVEL: diff --git a/game/src/char_manager.cpp b/game/src/char_manager.cpp index 478225b..f33264b 100644 --- a/game/src/char_manager.cpp +++ b/game/src/char_manager.cpp @@ -110,7 +110,7 @@ void CHARACTER_MANAGER::DestroyCharacter(LPCHARACTER ch, const char* file, size_ // Check whether it has been already deleted or not. itertype(m_map_pkChrByVID) it = m_map_pkChrByVID.find(ch->GetVID()); if (it == m_map_pkChrByVID.end()) { - sys_err("[CHARACTER_MANAGER::DestroyCharacter] %d not found", (long)(ch->GetVID())); + sys_err("[CHARACTER_MANAGER::DestroyCharacter] %d not found", (int)(ch->GetVID())); return; // prevent duplicated destrunction } @@ -228,7 +228,7 @@ LPCHARACTER CHARACTER_MANAGER::FindPC(const char * name) return found; } -LPCHARACTER CHARACTER_MANAGER::SpawnMobRandomPosition(DWORD dwVnum, long lMapIndex) +LPCHARACTER CHARACTER_MANAGER::SpawnMobRandomPosition(DWORD dwVnum, int lMapIndex) { // ¿Ö±¸ ½ºÆùÇÒÁö¸»Áö¸¦ °áÁ¤ÇÒ ¼ö ÀÖ°ÔÇÔ { @@ -277,7 +277,7 @@ LPCHARACTER CHARACTER_MANAGER::SpawnMobRandomPosition(DWORD dwVnum, long lMapInd } int i; - long x, y; + int x, y; for (i=0; i<2000; i++) { x = number(1, (pkSectreeMap->m_setting.iWidth / 100) - 1) * 100 + pkSectreeMap->m_setting.iBaseX; @@ -338,9 +338,9 @@ LPCHARACTER CHARACTER_MANAGER::SpawnMobRandomPosition(DWORD dwVnum, long lMapInd } char buf[512+1]; - long local_x = x - pkSectreeMap->m_setting.iBaseX; - long local_y = y - pkSectreeMap->m_setting.iBaseY; - snprintf(buf, sizeof(buf), "spawn %s[%d] random position at %ld %ld %ld %ld (time: %d)", ch->GetName(), dwVnum, x, y, local_x, local_y, get_global_time()); + int local_x = x - pkSectreeMap->m_setting.iBaseX; + int local_y = y - pkSectreeMap->m_setting.iBaseY; + snprintf(buf, sizeof(buf), "spawn %s[%d] random position at %d %d %d %d (time: %ld)", ch->GetName(), dwVnum, x, y, local_x, local_y, get_global_time()); if (test_server) SendNotice(buf); @@ -349,7 +349,7 @@ LPCHARACTER CHARACTER_MANAGER::SpawnMobRandomPosition(DWORD dwVnum, long lMapInd return (ch); } -LPCHARACTER CHARACTER_MANAGER::SpawnMob(DWORD dwVnum, long lMapIndex, long x, long y, long z, bool bSpawnMotion, int iRot, bool bShow) +LPCHARACTER CHARACTER_MANAGER::SpawnMob(DWORD dwVnum, int lMapIndex, int x, int y, int z, bool bSpawnMotion, int iRot, bool bShow) { const CMob * pkMob = CMobManager::instance().Get(dwVnum); if (!pkMob) @@ -441,7 +441,7 @@ LPCHARACTER CHARACTER_MANAGER::SpawnMob(DWORD dwVnum, long lMapIndex, long x, lo return (ch); } -LPCHARACTER CHARACTER_MANAGER::SpawnMobRange(DWORD dwVnum, long lMapIndex, int sx, int sy, int ex, int ey, bool bIsException, bool bSpawnMotion, bool bAggressive ) +LPCHARACTER CHARACTER_MANAGER::SpawnMobRange(DWORD dwVnum, int lMapIndex, int sx, int sy, int ex, int ey, bool bIsException, bool bSpawnMotion, bool bAggressive ) { const CMob * pkMob = CMobManager::instance().Get(dwVnum); @@ -481,7 +481,7 @@ void CHARACTER_MANAGER::SelectStone(LPCHARACTER pkChr) m_pkChrSelectedStone = pkChr; } -bool CHARACTER_MANAGER::SpawnMoveGroup(DWORD dwVnum, long lMapIndex, int sx, int sy, int ex, int ey, int tx, int ty, LPREGEN pkRegen, bool bAggressive_) +bool CHARACTER_MANAGER::SpawnMoveGroup(DWORD dwVnum, int lMapIndex, int sx, int sy, int ex, int ey, int tx, int ty, LPREGEN pkRegen, bool bAggressive_) { CMobGroup * pkGroup = CMobManager::Instance().GetGroup(dwVnum); @@ -547,7 +547,7 @@ bool CHARACTER_MANAGER::SpawnMoveGroup(DWORD dwVnum, long lMapIndex, int sx, int return true; } -bool CHARACTER_MANAGER::SpawnGroupGroup(DWORD dwVnum, long lMapIndex, int sx, int sy, int ex, int ey, LPREGEN pkRegen, bool bAggressive_, LPDUNGEON pDungeon) +bool CHARACTER_MANAGER::SpawnGroupGroup(DWORD dwVnum, int lMapIndex, int sx, int sy, int ex, int ey, LPREGEN pkRegen, bool bAggressive_, LPDUNGEON pDungeon) { const DWORD dwGroupID = CMobManager::Instance().GetGroupFromGroupGroup(dwVnum); @@ -562,7 +562,7 @@ bool CHARACTER_MANAGER::SpawnGroupGroup(DWORD dwVnum, long lMapIndex, int sx, in } } -LPCHARACTER CHARACTER_MANAGER::SpawnGroup(DWORD dwVnum, long lMapIndex, int sx, int sy, int ex, int ey, LPREGEN pkRegen, bool bAggressive_, LPDUNGEON pDungeon) +LPCHARACTER CHARACTER_MANAGER::SpawnGroup(DWORD dwVnum, int lMapIndex, int sx, int sy, int ex, int ey, LPREGEN pkRegen, bool bAggressive_, LPDUNGEON pDungeon) { CMobGroup * pkGroup = CMobManager::Instance().GetGroup(dwVnum); @@ -885,7 +885,7 @@ bool CHARACTER_MANAGER::GetCharactersByRaceNum(DWORD dwRaceNum, CharacterVectorI // // (job+1)*3+(skill_group) // -LPCHARACTER CHARACTER_MANAGER::FindSpecifyPC(unsigned int uiJobFlag, long lMapIndex, LPCHARACTER except, int iMinLevel, int iMaxLevel) +LPCHARACTER CHARACTER_MANAGER::FindSpecifyPC(unsigned int uiJobFlag, int lMapIndex, LPCHARACTER except, int iMinLevel, int iMaxLevel) { LPCHARACTER chFind = NULL; itertype(m_map_pkChrByPID) it; @@ -1034,7 +1034,7 @@ int CHARACTER_MANAGER::GetUserDamageRate(LPCHARACTER ch) return m_iUserDamageRate; } -void CHARACTER_MANAGER::SendScriptToMap(long lMapIndex, const std::string & s) +void CHARACTER_MANAGER::SendScriptToMap(int lMapIndex, const std::string & s) { LPSECTREE_MAP pSecMap = SECTREE_MANAGER::instance().GetMap(lMapIndex); diff --git a/game/src/char_manager.h b/game/src/char_manager.h index e1b72b1..7b1fc0b 100644 --- a/game/src/char_manager.h +++ b/game/src/char_manager.h @@ -37,12 +37,12 @@ class CHARACTER_MANAGER : public singleton void Update(int iPulse); - LPCHARACTER SpawnMob(DWORD dwVnum, long lMapIndex, long x, long y, long z, bool bSpawnMotion = false, int iRot = -1, bool bShow = true); - LPCHARACTER SpawnMobRange(DWORD dwVnum, long lMapIndex, int sx, int sy, int ex, int ey, bool bIsException=false, bool bSpawnMotion = false , bool bAggressive = false); - LPCHARACTER SpawnGroup(DWORD dwVnum, long lMapIndex, int sx, int sy, int ex, int ey, LPREGEN pkRegen = NULL, bool bAggressive_ = false, LPDUNGEON pDungeon = NULL); - bool SpawnGroupGroup(DWORD dwVnum, long lMapIndex, int sx, int sy, int ex, int ey, LPREGEN pkRegen = NULL, bool bAggressive_ = false, LPDUNGEON pDungeon = NULL); - bool SpawnMoveGroup(DWORD dwVnum, long lMapIndex, int sx, int sy, int ex, int ey, int tx, int ty, LPREGEN pkRegen = NULL, bool bAggressive_ = false); - LPCHARACTER SpawnMobRandomPosition(DWORD dwVnum, long lMapIndex); + LPCHARACTER SpawnMob(DWORD dwVnum, int lMapIndex, int x, int y, int z, bool bSpawnMotion = false, int iRot = -1, bool bShow = true); + LPCHARACTER SpawnMobRange(DWORD dwVnum, int lMapIndex, int sx, int sy, int ex, int ey, bool bIsException=false, bool bSpawnMotion = false , bool bAggressive = false); + LPCHARACTER SpawnGroup(DWORD dwVnum, int lMapIndex, int sx, int sy, int ex, int ey, LPREGEN pkRegen = NULL, bool bAggressive_ = false, LPDUNGEON pDungeon = NULL); + bool SpawnGroupGroup(DWORD dwVnum, int lMapIndex, int sx, int sy, int ex, int ey, LPREGEN pkRegen = NULL, bool bAggressive_ = false, LPDUNGEON pDungeon = NULL); + bool SpawnMoveGroup(DWORD dwVnum, int lMapIndex, int sx, int sy, int ex, int ey, int tx, int ty, LPREGEN pkRegen = NULL, bool bAggressive_ = false); + LPCHARACTER SpawnMobRandomPosition(DWORD dwVnum, int lMapIndex); void SelectStone(LPCHARACTER pkChrStone); @@ -76,7 +76,7 @@ class CHARACTER_MANAGER : public singleton void UnregisterRaceNumMap(LPCHARACTER ch); bool GetCharactersByRaceNum(DWORD dwRaceNum, CharacterVectorInteractor & i); - LPCHARACTER FindSpecifyPC(unsigned int uiJobFlag, long lMapIndex, LPCHARACTER except=NULL, int iMinLevel = 1, int iMaxLevel = PLAYER_MAX_LEVEL_CONST); + LPCHARACTER FindSpecifyPC(unsigned int uiJobFlag, int lMapIndex, LPCHARACTER except=NULL, int iMinLevel = 1, int iMaxLevel = PLAYER_MAX_LEVEL_CONST); void SetMobItemRate(int value) { m_iMobItemRate = value; } void SetMobDamageRate(int value) { m_iMobDamageRate = value; } @@ -98,7 +98,7 @@ class CHARACTER_MANAGER : public singleton int GetMobExpRate(LPCHARACTER ch); int GetUserDamageRate(LPCHARACTER ch); - void SendScriptToMap(long lMapIndex, const std::string & s); + void SendScriptToMap(int lMapIndex, const std::string & s); bool BeginPendingDestroy(); void FlushPendingDestroy(); diff --git a/game/src/char_skill.cpp b/game/src/char_skill.cpp index 517251c..689b992 100644 --- a/game/src/char_skill.cpp +++ b/game/src/char_skill.cpp @@ -1478,9 +1478,9 @@ struct FuncSplashDamage } GetDeltaByDegree(degree, fCrushSlidingLength, &fx, &fy); - sys_log(0, "CRUSH! %s -> %s (%d %d) -> (%d %d)", m_pkChr->GetName(), pkChrVictim->GetName(), pkChrVictim->GetX(), pkChrVictim->GetY(), (long)(pkChrVictim->GetX()+fx), (long)(pkChrVictim->GetY()+fy)); - long tx = (long)(pkChrVictim->GetX()+fx); - long ty = (long)(pkChrVictim->GetY()+fy); + sys_log(0, "CRUSH! %s -> %s (%d %d) -> (%d %d)", m_pkChr->GetName(), pkChrVictim->GetName(), pkChrVictim->GetX(), pkChrVictim->GetY(), (int)(pkChrVictim->GetX()+fx), (int)(pkChrVictim->GetY()+fy)); + int tx = (int)(pkChrVictim->GetX()+fx); + int ty = (int)(pkChrVictim->GetY()+fy); pkChrVictim->Sync(tx, ty); pkChrVictim->Goto(tx, ty); @@ -1909,7 +1909,7 @@ int CHARACTER::ComputeSkillAtPosition(DWORD dwVnum, const PIXEL_POSITION& posTar iAmount, pkSk->dwAffectFlag, iDur, - (long) pkSk->kDurationSPCostPoly.Eval(), + (int) pkSk->kDurationSPCostPoly.Eval(), !bAdded); bAdded = true; @@ -2003,7 +2003,7 @@ int CHARACTER::ComputeSkill(DWORD dwVnum, LPCHARACTER pkVictim, BYTE bSkillLevel dwVnum, GetName(), pkVictim->GetName(), - (long)DISTANCE_SQRT(GetX() - pkVictim->GetX(), GetY() - pkVictim->GetY()), + (int)DISTANCE_SQRT(GetX() - pkVictim->GetX(), GetY() - pkVictim->GetY()), pkSk->dwTargetRange); return BATTLE_NONE; @@ -2249,7 +2249,7 @@ int CHARACTER::ComputeSkill(DWORD dwVnum, LPCHARACTER pkVictim, BYTE bSkillLevel pkSk->kDurationPoly.SetVar("k", k/*bSkillLevel*/); pkSk->kDurationSPCostPoly.SetVar("k", k/*bSkillLevel*/); - int iDur = (long) pkSk->kDurationPoly.Eval(); + int iDur = (int) pkSk->kDurationPoly.Eval(); iDur += GetPoint(POINT_PARTY_BUFFER_BONUS); if (pkVictim == this) @@ -2257,7 +2257,7 @@ int CHARACTER::ComputeSkill(DWORD dwVnum, LPCHARACTER pkVictim, BYTE bSkillLevel POINT_NONE, 0, AFF_MUYEONG, iDur, - (long) pkSk->kDurationSPCostPoly.Eval(), + (int) pkSk->kDurationSPCostPoly.Eval(), true); return BATTLE_NONE; @@ -2318,7 +2318,7 @@ int CHARACTER::ComputeSkill(DWORD dwVnum, LPCHARACTER pkVictim, BYTE bSkillLevel iAmount, affact_flag, iDur, - (long) pkSk->kDurationSPCostPoly.Eval(), + (int) pkSk->kDurationSPCostPoly.Eval(), false); } else @@ -2336,7 +2336,7 @@ int CHARACTER::ComputeSkill(DWORD dwVnum, LPCHARACTER pkVictim, BYTE bSkillLevel iAmount, pkSk->dwAffectFlag, iDur, - (long) pkSk->kDurationSPCostPoly.Eval(), + (int) pkSk->kDurationSPCostPoly.Eval(), // ADD_GRANDMASTER_SKILL !bAdded); // END_OF_ADD_GRANDMASTER_SKILL @@ -2952,8 +2952,8 @@ bool CHARACTER::UseMobSkill(unsigned int idx) { float fx, fy; GetDeltaByDegree(GetRotation(), rInfo.dwHitDistance, &fx, &fy); - pos.x += (long) fx; - pos.y += (long) fy; + pos.x += (int) fx; + pos.y += (int) fy; } if (rInfo.dwTiming) diff --git a/game/src/char_state.cpp b/game/src/char_state.cpp index 9414569..1b6ee77 100644 --- a/game/src/char_state.cpp +++ b/game/src/char_state.cpp @@ -225,8 +225,8 @@ namespace int m_iMinDistance; int m_iMaxDistance; - long m_lx; - long m_ly; + int m_lx; + int m_ly; LPCHARACTER m_pkChrVictim; }; @@ -543,12 +543,12 @@ void CHARACTER::__StateIdle_NPC() /* * »êŸ¿ë const int WARP_MAP_INDEX_NUM = 4; - static const long c_lWarpMapIndexs[WARP_MAP_INDEX_NUM] = {61, 62, 63, 64}; + static const int c_lWarpMapIndexs[WARP_MAP_INDEX_NUM] = {61, 62, 63, 64}; */ // ½Å¼±ÀÚ ³ëÇØ¿ë const int WARP_MAP_INDEX_NUM = 7; - static const long c_lWarpMapIndexs[WARP_MAP_INDEX_NUM] = { 61, 62, 63, 64, 3, 23, 43 }; - long lNextMapIndex; + static const int c_lWarpMapIndexs[WARP_MAP_INDEX_NUM] = { 61, 62, 63, 64, 3, 23, 43 }; + int lNextMapIndex; lNextMapIndex = c_lWarpMapIndexs[number(1, WARP_MAP_INDEX_NUM) - 1]; if (map_allow_find(lNextMapIndex)) @@ -853,8 +853,8 @@ void CHARACTER::StateMove() // ¿öÇÁ Å×½ºÆ® float fx, fy; GetDeltaByDegree(victim->GetRotation(), 400, &fx, &fy); - long new_x = victim->GetX() + (long)fx; - long new_y = victim->GetY() + (long)fy; + int new_x = victim->GetX() + (int)fx; + int new_y = victim->GetY() + (int)fy; SetRotation(GetDegreeFromPositionXY(new_x, new_y, victim->GetX(), victim->GetY())); Show(victim->GetMapIndex(), new_x, new_y, 0, true); GotoState(m_stateBattle); @@ -980,7 +980,7 @@ void CHARACTER::StateBattle() SetRotation(GetDegreeFromPosition(dx, dy)); - if (Goto((long) dx, (long) dy)) + if (Goto((int) dx, (int) dy)) { sys_log(0, "KILL_AND_GO: %s distance %.1f", GetName(), fDist); SendMovePacket(FUNC_WAIT, 0, 0, 0, 0); diff --git a/game/src/cipher.cpp b/game/src/cipher.cpp deleted file mode 100644 index 9e3e776..0000000 --- a/game/src/cipher.cpp +++ /dev/null @@ -1,401 +0,0 @@ -#include "stdafx.h" - -#include "cipher.h" - -#ifdef _IMPROVED_PACKET_ENCRYPTION_ - -#include -#include -#include - -// Diffie-Hellman key agreement -#include -#include - -// AES winner and candidates -//#include -#include -#include -#include -#include -#include -// Other block ciphers -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace CryptoPP; - -// Block cipher algorithm selector abstract base class. -struct BlockCipherAlgorithm { - enum { - kDefault, // to give more chances to default algorithm - // AES winner and candidates -// kAES, // Rijndael - kRC6, - kMARS, - kTwofish, - kSerpent, - kCAST256, - // Other block ciphers - kIDEA, - k3DES, // DES-EDE2 - kCamellia, - kSEED, - kRC5, - kBlowfish, - kTEA, -// kSKIPJACK, - kSHACAL2, - // End sentinel - kMaxAlgorithms - }; - - BlockCipherAlgorithm() {} - virtual ~BlockCipherAlgorithm() {} - - static BlockCipherAlgorithm* Pick(int hint); - - virtual int GetBlockSize() const = 0; - virtual int GetDefaultKeyLength() const = 0; - virtual int GetIVLength() const = 0; - - virtual SymmetricCipher* CreateEncoder(const byte* key, size_t keylen, - const byte* iv) const = 0; - virtual SymmetricCipher* CreateDecoder(const byte* key, size_t keylen, - const byte* iv) const = 0; -}; - -// Block cipher (with CTR mode) algorithm selector template class. -template -struct BlockCipherDetail : public BlockCipherAlgorithm { - BlockCipherDetail() {} - virtual ~BlockCipherDetail() {} - - virtual int GetBlockSize() const { return T::BLOCKSIZE; } - virtual int GetDefaultKeyLength() const { return T::DEFAULT_KEYLENGTH; } - virtual int GetIVLength() const { return T::IV_LENGTH; } - - virtual SymmetricCipher* CreateEncoder(const byte* key, size_t keylen, - const byte* iv) const { - return new typename CTR_Mode::Encryption(key, keylen, iv); - } - virtual SymmetricCipher* CreateDecoder(const byte* key, size_t keylen, - const byte* iv) const { - return new typename CTR_Mode::Decryption(key, keylen, iv); - } -}; - -// Key agreement scheme abstract class. -class KeyAgreement { - public: - KeyAgreement() {} - virtual ~KeyAgreement() {} - - virtual size_t Prepare(void* buffer, size_t* length) = 0; - virtual bool Agree(size_t agreed_length, const void* buffer, size_t length) = 0; - - const SecByteBlock& shared() const { return shared_; } - - protected: - SecByteBlock shared_; -}; - -// Crypto++ Unified Diffie-Hellman key agreement scheme implementation. -class DH2KeyAgreement : public KeyAgreement { - public: - DH2KeyAgreement(); - virtual ~DH2KeyAgreement(); - - virtual size_t Prepare(void* buffer, size_t* length); - virtual bool Agree(size_t agreed_length, const void* buffer, size_t length); - - private: - DH dh_; - DH2 dh2_; - SecByteBlock spriv_key_; - SecByteBlock epriv_key_; -}; - -Cipher::Cipher() - : activated_(false), encoder_(NULL), decoder_(NULL), key_agreement_(NULL) { -} - -Cipher::~Cipher() { - if (activated_) { - CleanUp(); - } -} - -void Cipher::CleanUp() { - if (encoder_ != NULL) { - delete encoder_; - encoder_ = NULL; - } - if (decoder_ != NULL) { - delete decoder_; - decoder_ = NULL; - } - if (key_agreement_ != NULL) { - delete key_agreement_; - key_agreement_ = NULL; - } - activated_ = false; -} - -size_t Cipher::Prepare(void* buffer, size_t* length) { - assert(key_agreement_ == NULL); - key_agreement_ = new DH2KeyAgreement(); - assert(key_agreement_ != NULL); - size_t agreed_length = key_agreement_->Prepare(buffer, length); - if (agreed_length == 0) { - delete key_agreement_; - key_agreement_ = NULL; - } - return agreed_length; -} - -bool Cipher::Activate(bool polarity, size_t agreed_length, - const void* buffer, size_t length) { - assert(activated_ == false); - assert(key_agreement_ != NULL); - if (activated_ != false) - return false; - - if (key_agreement_->Agree(agreed_length, buffer, length)) { - activated_ = SetUp(polarity); - } - delete key_agreement_; - key_agreement_ = NULL; - return activated_; -} - -bool Cipher::SetUp(bool polarity) { - assert(key_agreement_ != NULL); - const SecByteBlock& shared = key_agreement_->shared(); - - // Pick a block cipher algorithm - - if (shared.size() < 2) { - return false; - } - int hint_0 = shared.BytePtr()[*(shared.BytePtr()) % shared.size()]; - int hint_1 = shared.BytePtr()[*(shared.BytePtr() + 1) % shared.size()]; - BlockCipherAlgorithm* detail_0 = BlockCipherAlgorithm::Pick(hint_0); - BlockCipherAlgorithm* detail_1 = BlockCipherAlgorithm::Pick(hint_1); - assert(detail_0 != NULL); - assert(detail_1 != NULL); - 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(); - if (shared.size() < key_length_0 || shared.size() < iv_length_0) { - return false; - } - const size_t key_length_1 = algorithm_1->GetDefaultKeyLength(); - const size_t iv_length_1 = algorithm_1->GetBlockSize(); - if (shared.size() < key_length_1 || shared.size() < iv_length_1) { - return false; - } - - // Pick encryption keys and initial vectors - - SecByteBlock key_0(key_length_0), iv_0(iv_length_0); - SecByteBlock key_1(key_length_1), iv_1(iv_length_1); - - size_t offset; - - key_0.Assign(shared, key_length_0); - offset = key_length_0; -#ifdef __GNUC__ - offset = std::min(key_length_0, shared.size() - key_length_1); -#else - offset = min(key_length_0, shared.size() - key_length_1); -#endif - key_1.Assign(shared.BytePtr() + offset, key_length_1); - - offset = shared.size() - iv_length_0; - iv_0.Assign(shared.BytePtr() + offset, iv_length_0); - offset = (offset < iv_length_1 ? 0 : offset - iv_length_1); - iv_1.Assign(shared.BytePtr() + offset, iv_length_1); - - // Create encryption/decryption objects - - if (polarity) { - encoder_ = algorithm_1->CreateEncoder(key_1, key_1.size(), iv_1); - decoder_ = algorithm_0->CreateDecoder(key_0, key_0.size(), iv_0); - } else { - encoder_ = algorithm_0->CreateEncoder(key_0, key_0.size(), iv_0); - decoder_ = algorithm_1->CreateDecoder(key_1, key_1.size(), iv_1); - } - assert(encoder_ != NULL); - assert(decoder_ != NULL); - return true; -} - -BlockCipherAlgorithm* BlockCipherAlgorithm::Pick(int hint) { - BlockCipherAlgorithm* detail; - int selector = hint % kMaxAlgorithms; - switch (selector) { -// case kAES: -// detail = new BlockCipherDetail(); - break; - case kRC6: - detail = new BlockCipherDetail(); - break; - case kMARS: - detail = new BlockCipherDetail(); - break; - case kTwofish: - detail = new BlockCipherDetail(); - break; - case kSerpent: - detail = new BlockCipherDetail(); - break; - case kCAST256: - detail = new BlockCipherDetail(); - break; - case kIDEA: - detail = new BlockCipherDetail(); - break; - case k3DES: - detail = new BlockCipherDetail(); - break; - case kCamellia: - detail = new BlockCipherDetail(); - break; - case kSEED: - detail = new BlockCipherDetail(); - break; - case kRC5: - detail = new BlockCipherDetail(); - break; - case kBlowfish: - detail = new BlockCipherDetail(); - break; - case kTEA: - detail = new BlockCipherDetail(); - break; -// case kSKIPJACK: -// detail = new BlockCipherDetail(); -// break; - case kSHACAL2: - detail = new BlockCipherDetail(); - break; - case kDefault: - default: - detail = new BlockCipherDetail(); // default algorithm - break; - } - return detail; -} - -DH2KeyAgreement::DH2KeyAgreement() : dh_(), dh2_(dh_) { -} - -DH2KeyAgreement::~DH2KeyAgreement() { -} - -size_t DH2KeyAgreement::Prepare(void* buffer, size_t* length) { - // RFC 5114, 1024-bit MODP Group with 160-bit Prime Order Subgroup - // http://tools.ietf.org/html/rfc5114#section-2.1 - Integer p("0xB10B8F96A080E01DDE92DE5EAE5D54EC52C99FBCFB06A3C6" - "9A6A9DCA52D23B616073E28675A23D189838EF1E2EE652C0" - "13ECB4AEA906112324975C3CD49B83BFACCBDD7D90C4BD70" - "98488E9C219A73724EFFD6FAE5644738FAA31A4FF55BCCC0" - "A151AF5F0DC8B4BD45BF37DF365C1A65E68CFDA76D4DA708" - "DF1FB2BC2E4A4371"); - - Integer g("0xA4D1CBD5C3FD34126765A442EFB99905F8104DD258AC507F" - "D6406CFF14266D31266FEA1E5C41564B777E690F5504F213" - "160217B4B01B886A5E91547F9E2749F4D7FBD7D3B9A92EE1" - "909D0D2263F80A76A6A24C087A091F531DBF0A0169B6A28A" - "D662A4D18E73AFA32D779D5918D08BC8858F4DCEF97C2A24" - "855E6EEB22B3B2E5"); - - Integer q("0xF518AA8781A8DF278ABA4E7D64B7CB9D49462353"); - - // Schnorr Group primes are of the form p = rq + 1, p and q prime. They - // provide a subgroup order. In the case of 1024-bit MODP Group, the - // security level is 80 bits (based on the 160-bit prime order subgroup). - - // For a compare/contrast of using the maximum security level, see - // dh-unified.zip. Also see http://www.cryptopp.com/wiki/Diffie-Hellman - // and http://www.cryptopp.com/wiki/Security_level . - - AutoSeededRandomPool rnd; - - dh_.AccessGroupParameters().Initialize(p, q, g); - - if(!dh_.GetGroupParameters().ValidateGroup(rnd, 3)) { - // Failed to validate prime and generator - return 0; - } - - p = dh_.GetGroupParameters().GetModulus(); - q = dh_.GetGroupParameters().GetSubgroupOrder(); - g = dh_.GetGroupParameters().GetGenerator(); - - // http://groups.google.com/group/sci.crypt/browse_thread/thread/7dc7eeb04a09f0ce - Integer v = ModularExponentiation(g, q, p); - if(v != Integer::One()) { - // Failed to verify order of the subgroup - return 0; - } - - ////////////////////////////////////////////////////////////// - - spriv_key_.New(dh2_.StaticPrivateKeyLength()); - epriv_key_.New(dh2_.EphemeralPrivateKeyLength()); - SecByteBlock spub_key(dh2_.StaticPublicKeyLength()); - SecByteBlock epub_key(dh2_.EphemeralPublicKeyLength()); - - dh2_.GenerateStaticKeyPair(rnd, spriv_key_, spub_key); - dh2_.GenerateEphemeralKeyPair(rnd, epriv_key_, epub_key); - - // Prepare key agreement data - const size_t spub_key_length = spub_key.size(); - const size_t epub_key_length = epub_key.size(); - const size_t data_length = spub_key_length + epub_key_length; - if (*length < data_length) { - // Not enough data buffer length - return 0; - } - *length = data_length; - byte* buf = (byte*)buffer; - memcpy(buf, spub_key.BytePtr(), spub_key_length); - memcpy(buf + spub_key_length, epub_key.BytePtr(), epub_key_length); - - return dh2_.AgreedValueLength(); -} - -bool DH2KeyAgreement::Agree(size_t agreed_length, const void* buffer, size_t length) { - if (agreed_length != dh2_.AgreedValueLength()) { - // Shared secret size mismatch - return false; - } - const size_t spub_key_length = dh2_.StaticPublicKeyLength(); - const size_t epub_key_length = dh2_.EphemeralPublicKeyLength(); - if (length != (spub_key_length + epub_key_length)) { - // Wrong data length - return false; - } - shared_.New(dh2_.AgreedValueLength()); - const byte* buf = (const byte*)buffer; - if (!dh2_.Agree(shared_, spriv_key_, epriv_key_, buf, buf + spub_key_length)) { - // Failed to reach shared secret - return false; - } - return true; -} - -#endif // _IMPROVED_PACKET_ENCRYPTION_ - -// EOF cipher.cpp diff --git a/game/src/cipher.h b/game/src/cipher.h deleted file mode 100644 index ac08054..0000000 --- a/game/src/cipher.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef __CIPHER_H__ -#define __CIPHER_H__ - -#ifdef _IMPROVED_PACKET_ENCRYPTION_ - -#include - -// Forward declaration -class KeyAgreement; - -// Communication channel encryption handler. -class Cipher { - public: - Cipher(); - ~Cipher(); - - void CleanUp(); - - // Returns agreed value length in bytes, or zero on failure. - size_t Prepare(void* buffer, size_t* length); - // Try to activate cipher algorithm with agreement data received from peer. - bool Activate(bool polarity, size_t agreed_length, - const void* buffer, size_t length); - - // Encrypts the given block of data. (no padding required) - void Encrypt(void* buffer, size_t length) { - assert(activated_); - if (!activated_) { - return; - } - 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) { - assert(activated_); - if (!activated_) { - return; - } - decoder_->ProcessData((CryptoPP::byte*)buffer, (const CryptoPP::byte*)buffer, length); - } - - bool activated() const { return activated_; } - void set_activated(bool value) { activated_ = value; } - - bool IsKeyPrepared() { return key_agreement_ != NULL; } - - private: - bool SetUp(bool polarity); - - bool activated_; - - CryptoPP::SymmetricCipher* encoder_; - CryptoPP::SymmetricCipher* decoder_; - - KeyAgreement* key_agreement_; -}; - -#endif // _IMPROVED_PACKET_ENCRYPTION_ - -#endif // __CIPHER_H__ diff --git a/game/src/cmd_emotion.cpp b/game/src/cmd_emotion.cpp index 0d1ab5d..111cb31 100644 --- a/game/src/cmd_emotion.cpp +++ b/game/src/cmd_emotion.cpp @@ -20,7 +20,7 @@ struct emotion_type_s { const char * command; const char * command_to_client; - long flag; + int flag; float extra_delay; } emotion_types[] = { { "Å°½º", "french_kiss", NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM, 2.0f }, @@ -188,7 +188,7 @@ ACMD(do_emotion) return; } - long distance = DISTANCE_APPROX(ch->GetX() - victim->GetX(), ch->GetY() - victim->GetY()); + int distance = DISTANCE_APPROX(ch->GetX() - victim->GetX(), ch->GetY() - victim->GetY()); if (distance < 10) { diff --git a/game/src/cmd_gm.cpp b/game/src/cmd_gm.cpp index 00e436f..8aa4c84 100644 --- a/game/src/cmd_gm.cpp +++ b/game/src/cmd_gm.cpp @@ -87,7 +87,7 @@ ACMD(do_pcbang_update) char arg1[256]; one_argument(argument, arg1, sizeof(arg1)); - unsigned long PCBangID = 0; + unsigned int PCBangID = 0; if (*arg1 == '\0') PCBangID = 0; @@ -852,7 +852,7 @@ ACMD(do_mob_ld) } int dir = 1; - long x, y; + int x, y; if (*arg2) str_to_number(x, arg2); @@ -974,22 +974,22 @@ ACMD(do_state) snprintf(buf, sizeof(buf), "%s's State: ", tch->GetName()); if (tch->IsPosition(POS_FIGHTING)) - strncat(buf, "Battle", sizeof(buf)); + strncat(buf, "Battle", sizeof(buf) - strlen(buf) - 1); else if (tch->IsPosition(POS_DEAD)) - strncat(buf, "Dead", sizeof(buf)); + strncat(buf, "Dead", sizeof(buf) - strlen(buf) - 1); else - strncat(buf, "Standing", sizeof(buf)); + strncat(buf, "Standing", sizeof(buf) - strlen(buf) - 1); if (ch->GetShop()) - strncat(buf, ", Shop", sizeof(buf)); + strncat(buf, ", Shop", sizeof(buf) - strlen(buf) - 1); if (ch->GetExchange()) - strncat(buf, ", Exchange", sizeof(buf)); + strncat(buf, ", Exchange", sizeof(buf) - strlen(buf) - 1); ch->ChatPacket(CHAT_TYPE_INFO, "%s", buf); int len; - len = snprintf(buf, sizeof(buf), "Coordinate %ldx%ld (%ldx%ld)", + len = snprintf(buf, sizeof(buf), "Coordinate %dx%d (%dx%d)", tch->GetX(), tch->GetY(), tch->GetX() / 100, tch->GetY() / 100); if (len < 0 || len >= (int) sizeof(buf)) @@ -1000,7 +1000,7 @@ ACMD(do_state) if (pSec) { TMapSetting& map_setting = SECTREE_MANAGER::instance().GetMap(tch->GetMapIndex())->m_setting; - snprintf(buf + len, sizeof(buf) - len, " MapIndex %ld Attribute %08X Local Position (%ld x %ld)", + snprintf(buf + len, sizeof(buf) - len, " MapIndex %d Attribute %08X Local Position (%d x %d)", tch->GetMapIndex(), pSec->GetAttribute(tch->GetX(), tch->GetY()), (tch->GetX() - map_setting.iBaseX)/100, (tch->GetY() - map_setting.iBaseY)/100); } @@ -1754,8 +1754,8 @@ ACMD(do_private) return; } - long lMapIndex; - long map_index = 0; + int lMapIndex; + int map_index = 0; str_to_number(map_index, arg1); if ((lMapIndex = SECTREE_MANAGER::instance().CreatePrivateMap(map_index))) { @@ -2705,7 +2705,7 @@ ACMD(do_vote_block_chat) } const char* name = arg1; - long lBlockDuration = 10; + int lBlockDuration = 10; sys_log(0, "vote_block_chat %s %d", name, lBlockDuration); LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(name); @@ -2764,7 +2764,7 @@ ACMD(do_block_chat) } const char* name = arg1; - long lBlockDuration = parse_time_str(argument); + int lBlockDuration = parse_time_str(argument); if (lBlockDuration < 0) { @@ -2956,9 +2956,9 @@ ACMD(do_build) } */ - long map_x = 0; + int map_x = 0; str_to_number(map_x, arg2); - long map_y = 0; + int map_y = 0; str_to_number(map_y, arg3); bool isSuccess = pkLand->RequestCreateObject(dwVnum, @@ -3234,7 +3234,7 @@ ACMD(do_save_attribute_to_image) // command "/saveati" for alias return; } - long lMapIndex = 0; + int lMapIndex = 0; str_to_number(lMapIndex, szMapIndex); if (SECTREE_MANAGER::instance().SaveAttributeToImage(lMapIndex, szFileName)) @@ -3932,7 +3932,7 @@ ACMD(do_set_stat) two_arguments (argument, szName, sizeof (szName), szChangeAmount, sizeof(szChangeAmount)); - if (*szName == NULL || *szChangeAmount == '\0') + if (*szName == '\0' || *szChangeAmount == '\0') { ch->ChatPacket (CHAT_TYPE_INFO, "Invalid argument."); return; diff --git a/game/src/config.cpp b/game/src/config.cpp index cbb5a62..4669444 100644 --- a/game/src/config.cpp +++ b/game/src/config.cpp @@ -12,7 +12,6 @@ #include "item_manager.h" #include "p2p.h" #include "char.h" -#include "ip_ban.h" #include "war_map.h" #include "locale_service.h" #include "config.h" @@ -32,7 +31,6 @@ int save_event_second_cycle = passes_per_sec * 120; // 3 int ping_event_second_cycle = passes_per_sec * 60; bool g_bNoMoreClient = false; bool g_bNoRegen = false; -bool g_bNoPasspod = false; // TRAFFIC_PROFILER bool g_bTrafficProfileOn = false; @@ -171,7 +169,7 @@ void map_allow_add(int index) s_set_map_allows.insert(index); } -void map_allow_copy(long * pl, int size) +void map_allow_copy(LONG * pl, int size) { int iCount = 0; std::set::iterator it = s_set_map_allows.begin(); @@ -419,7 +417,7 @@ void config_init(const string& st_localeServiceName) const char * line = two_arguments(value_string, db_host[0], sizeof(db_host[0]), db_user[0], sizeof(db_user[0])); line = two_arguments(line, db_pwd[0], sizeof(db_pwd[0]), db_db[0], sizeof(db_db[0])); - if (NULL != line[0]) + if ('\0' != line[0]) { char buf[256]; one_argument(line, buf, sizeof(buf)); @@ -443,7 +441,7 @@ void config_init(const string& st_localeServiceName) const char * line = two_arguments(value_string, db_host[1], sizeof(db_host[1]), db_user[1], sizeof(db_user[1])); line = two_arguments(line, db_pwd[1], sizeof(db_pwd[1]), db_db[1], sizeof(db_db[1])); - if (NULL != line[0]) + if ('\0' != line[0]) { char buf[256]; one_argument(line, buf, sizeof(buf)); @@ -467,7 +465,7 @@ void config_init(const string& st_localeServiceName) const char * line = two_arguments(value_string, log_host, sizeof(log_host), log_user, sizeof(log_user)); line = two_arguments(line, log_pwd, sizeof(log_pwd), log_db, sizeof(log_db)); - if (NULL != line[0]) + if ('\0' != line[0]) { char buf[256]; one_argument(line, buf, sizeof(buf)); @@ -892,8 +890,6 @@ void config_init(const string& st_localeServiceName) g_bAuthServer = true; - LoadBanIP("BANIP"); - if (!strcasecmp(szIP, "master")) fprintf(stdout, "AUTH_SERVER: I am the master\n"); else diff --git a/game/src/config.h b/game/src/config.h index 8d2f635..2ccfa7e 100644 --- a/game/src/config.h +++ b/game/src/config.h @@ -20,9 +20,6 @@ extern WORD db_port; extern char teen_addr[ADDRESS_MAX_LEN + 1]; extern WORD teen_port; -extern char passpod_addr[ADDRESS_MAX_LEN + 1]; -extern WORD passpod_port; - extern int passes_per_sec; extern int save_event_second_cycle; extern int ping_event_second_cycle; @@ -40,7 +37,7 @@ extern bool g_bTrafficProfileOn; ///< true extern BYTE g_bChannel; extern bool map_allow_find(int index); -extern void map_allow_copy(long * pl, int size); +extern void map_allow_copy(LONG * pl, int size); extern bool no_wander; extern int g_iUserLimit; diff --git a/game/src/constants.cpp b/game/src/constants.cpp index 4102516..9ca411e 100644 --- a/game/src/constants.cpp +++ b/game/src/constants.cpp @@ -1138,7 +1138,7 @@ const int aiPolymorphPowerByLevel[SKILL_MAX_LEVEL + 1] = TGuildWarInfo KOR_aGuildWarInfo[GUILD_WAR_TYPE_MAX_NUM] = /* { - long lMapIndex; + int lMapIndex; int iWarPrice; int iWinnerPotionRewardPctToWinner; int iLoserPotionRewardPctToWinner; @@ -1186,7 +1186,7 @@ const int aiAccessorySocketPutPct[ITEM_ACCESSORY_SOCKET_MAX_NUM + 1] = typedef struct SValueName { const char * c_pszName; - long lValue; + int lValue; } TValueName; TValueName c_aApplyTypeNames[] = @@ -1285,7 +1285,7 @@ TValueName c_aApplyTypeNames[] = }; // from import_item_proto.c -long FN_get_apply_type(const char *apply_type_string) +int FN_get_apply_type(const char *apply_type_string) { TValueName *value_name; for (value_name = c_aApplyTypeNames; value_name->c_pszName; ++value_name) diff --git a/game/src/constants.h b/game/src/constants.h index 8c9cf0f..827e87a 100644 --- a/game/src/constants.h +++ b/game/src/constants.h @@ -161,7 +161,7 @@ extern const SStoneDropInfo aStoneDrop[STONE_INFO_MAX_NUM]; typedef struct { - long lMapIndex; + int lMapIndex; int iWarPrice; int iWinnerPotionRewardPctToWinner; int iLoserPotionRewardPctToWinner; @@ -181,10 +181,10 @@ extern const int aiAccessorySocketAddPct[ITEM_ACCESSORY_SOCKET_MAX_NUM]; extern const int aiAccessorySocketEffectivePct[ITEM_ACCESSORY_SOCKET_MAX_NUM + 1]; extern const int aiAccessorySocketDegradeTime[ITEM_ACCESSORY_SOCKET_MAX_NUM + 1]; extern const int aiAccessorySocketPutPct[ITEM_ACCESSORY_SOCKET_MAX_NUM + 1]; -long FN_get_apply_type(const char *apply_type_string); +int FN_get_apply_type(const char *apply_type_string); // END_OF_ACCESSORY_REFINE -long FN_get_apply_type(const char *apply_type_string); +int FN_get_apply_type(const char *apply_type_string); #endif diff --git a/game/src/crc32.cpp b/game/src/crc32.cpp index 64c5d78..e833432 100644 --- a/game/src/crc32.cpp +++ b/game/src/crc32.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "crc32.h" -static unsigned long CRCTable[256] = +static unsigned int CRCTable[256] = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, @@ -123,7 +123,7 @@ crc_t GetCaseCRC32(const char * buf, size_t len) crc_t GetFastHash(const char * key, size_t len) { const char * end = key + len; - unsigned long h = 0; + unsigned int h = 0; while (key < end) { diff --git a/game/src/crc32.h b/game/src/crc32.h index 17b4346..b239523 100644 --- a/game/src/crc32.h +++ b/game/src/crc32.h @@ -1,7 +1,7 @@ #ifndef __INC_CRC32_H__ #define __INC_CRC32_H__ -typedef unsigned long crc_t; +typedef unsigned int crc_t; crc_t GetCRC32(const char * buffer, size_t count); crc_t GetCaseCRC32(const char * buffer, size_t count); diff --git a/game/src/cube.cpp b/game/src/cube.cpp index baf3904..7cac20a 100644 --- a/game/src/cube.cpp +++ b/game/src/cube.cpp @@ -322,7 +322,7 @@ void Cube_open (LPCHARACTER ch) return; } - long distance = DISTANCE_APPROX(ch->GetX() - npc->GetX(), ch->GetY() - npc->GetY()); + int distance = DISTANCE_APPROX(ch->GetX() - npc->GetX(), ch->GetY() - npc->GetY()); if (distance >= CUBE_MAX_DISTANCE) { diff --git a/game/src/db.cpp b/game/src/db.cpp index 0499599..1fa383d 100644 --- a/game/src/db.cpp +++ b/game/src/db.cpp @@ -20,40 +20,8 @@ #include "pcbang.h" #include "spam.h" -extern bool g_bNoPasspod; extern std::string g_stBlockDate; -//Áß±¹ passpod Àü¿ë ÇÔ¼ö -bool CheckPasspod(const char * account) -{ - char szQuery[1024]; - - snprintf(szQuery, sizeof(szQuery), "SELECT ID FROM passpod WHERE Login='%s'", account); - SQLMsg * pMsg = DBManager::instance().DirectQuery(szQuery); - - if (!pMsg) - { - //fprintf(stderr, "cannot get the MATRIX\n"); - sys_log(0, "cannot get the PASSPOD"); - delete pMsg; - return false; - } - - if (pMsg->Get()->uiNumRows == 0) - { - puts(szQuery); - sys_log(0, "[PASSPOD]DirectQuery failed(%s)", szQuery); - - delete pMsg; - return false; - } - - delete pMsg; - - return true; -} - - DBManager::DBManager() : m_bIsConnect(false) { } @@ -240,7 +208,7 @@ void DBManager::PushBilling(CLoginData * pkLD) return; pkLD->SetLogonTime(); - long lRemainSecs = pkLD->GetRemainSecs() - t.dwUseSec; + int lRemainSecs = pkLD->GetRemainSecs() - t.dwUseSec; pkLD->SetRemainSecs(MAX(0, lRemainSecs)); t.dwLoginKey = pkLD->GetKey(); @@ -497,7 +465,7 @@ void DBManager::SendAuthLogin(LPDESC d) SendLoginPing(r.login); } -void DBManager::LoginPrepare(BYTE bBillType, DWORD dwBillID, long lRemainSecs, LPDESC d, DWORD * pdwClientKey, int * paiPremiumTimes) +void DBManager::LoginPrepare(BYTE bBillType, DWORD dwBillID, int lRemainSecs, LPDESC d, DWORD * pdwClientKey, int * paiPremiumTimes) { const TAccountTable & r = d->GetAccountTable(); @@ -518,7 +486,7 @@ void DBManager::LoginPrepare(BYTE bBillType, DWORD dwBillID, long lRemainSecs, L if (*d->GetMatrixCode()) { - unsigned long rows = 0, cols = 0; + unsigned int rows = 0, cols = 0; MatrixCardRndCoordinate(rows, cols); d->SetMatrixCardRowsAndColumns(rows, cols); @@ -545,29 +513,7 @@ void DBManager::LoginPrepare(BYTE bBillType, DWORD dwBillID, long lRemainSecs, L } else { - if (LC_IsNewCIBN()) - { - if (!g_bNoPasspod) - { - if (CheckPasspod(r.login)) - { - BYTE id = HEADER_GC_REQUEST_PASSPOD; - d->Packet(&id, sizeof(BYTE)); - sys_log(0, "%s request passpod", r.login); - } - else - { - SendAuthLogin(d); - - } - } - else - { - SendAuthLogin(d); - } - } - else - SendAuthLogin(d); + SendAuthLogin(d); } } @@ -798,7 +744,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg) if (LC_IsEurope() || test_server) { - long retValue = 0; + int retValue = 0; str_to_number(retValue, row[col]); time_t create_time = retValue; diff --git a/game/src/db.h b/game/src/db.h index be0239d..21db8fc 100644 --- a/game/src/db.h +++ b/game/src/db.h @@ -93,7 +93,7 @@ class DBManager : public singleton void SendMoneyLog(BYTE type, DWORD vnum, int gold); - void LoginPrepare(BYTE bBillType, DWORD dwBillID, long lRemainSecs, LPDESC d, DWORD * pdwClientKey, int * paiPremiumTimes = NULL); + void LoginPrepare(BYTE bBillType, DWORD dwBillID, int lRemainSecs, LPDESC d, DWORD * pdwClientKey, int * paiPremiumTimes = NULL); void SendAuthLogin(LPDESC d); void SendLoginPing(const char * c_pszLogin); diff --git a/game/src/desc.cpp b/game/src/desc.cpp index 196b11c..d1a39ba 100644 --- a/game/src/desc.cpp +++ b/game/src/desc.cpp @@ -22,6 +22,60 @@ extern int max_bytes_written; extern int current_bytes_written; extern int total_bytes_written; +void DescReadHandler(bufferevent *bev, void *ctx) { + auto* d = (LPDESC) ctx; + + if (db_clientdesc == d) + { + int size = d->ProcessInput(); + + if (size) + sys_log(1, "DB_BYTES_READ: %d", size); + + if (size < 0) + { + d->SetPhase(PHASE_CLOSE); + } + } + else if (d->ProcessInput() < 0) + { + d->SetPhase(PHASE_CLOSE); + } +} + +void DescWriteHandler(bufferevent *bev, void *ctx) { + auto* d = (LPDESC) ctx; + + if (db_clientdesc == d) + { + evbuffer *output = bufferevent_get_output(bev); + size_t buf_size = evbuffer_get_length(output); + if (buf_size) + sys_log(1, "DB_BYTES_WRITE: size %d", buf_size); + } + else if (g_TeenDesc==d) + { + evbuffer *output = bufferevent_get_output(bev); + size_t buf_size = evbuffer_get_length(output); + if (buf_size) + sys_log(0, "TEEN::Send(size %d)", buf_size); + } +} + +void DescEventHandler(bufferevent *bev, short events, void *ctx) { + auto* d = (LPDESC) ctx; + + if (events & BEV_EVENT_ERROR) + sys_err("DESC libevent error, handle: %d", d->GetHandle()); + + if (events & BEV_EVENT_EOF) + sys_log(0, "DESC disconnected: handle %d", d->GetHandle()); + + // Either the socket was closed or an error occured, therefore we can disconnect this peer. + if (events & (BEV_EVENT_EOF | BEV_EVENT_ERROR)) + d->SetPhase(PHASE_CLOSE); +} + DESC::DESC() { Initialize(); @@ -36,38 +90,26 @@ void DESC::Initialize() m_bDestroyed = false; m_pInputProcessor = NULL; - m_lpFdw = NULL; - m_sock = INVALID_SOCKET; + m_evbase = nullptr; + m_bufevent = nullptr; m_iPhase = PHASE_CLOSE; m_dwHandle = 0; m_wPort = 0; m_LastTryToConnectTime = 0; - m_lpInputBuffer = NULL; - m_iMinInputBufferLen = 0; - m_dwHandshake = 0; m_dwHandshakeSentTime = 0; m_iHandshakeRetry = 0; m_dwClientTime = 0; m_bHandshaking = false; - m_lpBufferedOutputBuffer = NULL; - m_lpOutputBuffer = NULL; - m_pkPingEvent = NULL; m_lpCharacter = NULL; memset( &m_accountTable, 0, sizeof(m_accountTable) ); - memset( &m_SockAddr, 0, sizeof(m_SockAddr) ); - m_pLogFile = NULL; -#ifndef _IMPROVED_PACKET_ENCRYPTION_ - m_bEncrypted = false; -#endif - m_wP2PPort = 0; m_bP2PChannel = 0; @@ -84,11 +126,6 @@ void DESC::Initialize() m_dwLoginKey = 0; m_dwPanamaKey = 0; -#ifndef _IMPROVED_PACKET_ENCRYPTION_ - memset( m_adwDecryptionKey, 0, sizeof(m_adwDecryptionKey) ); - memset( m_adwEncryptionKey, 0, sizeof(m_adwEncryptionKey) ); -#endif - m_bCRCMagicCubeIdx = 0; m_dwProcCRC = 0; m_dwFileCRC = 0; @@ -129,9 +166,6 @@ void DESC::Destroy() m_lpCharacter = NULL; } - SAFE_BUFFER_DELETE(m_lpOutputBuffer); - SAFE_BUFFER_DELETE(m_lpInputBuffer); - event_cancel(&m_pkPingEvent); event_cancel(&m_pkDisconnectEvent); @@ -148,18 +182,13 @@ void DESC::Destroy() } } - if (m_sock != INVALID_SOCKET) + if (m_bufevent != nullptr) { - sys_log(0, "SYSTEM: closing socket. DESC #%d", m_sock); - Log("SYSTEM: closing socket. DESC #%d", m_sock); - fdwatch_del_fd(m_lpFdw, m_sock); + sys_log(0, "SYSTEM: closing socket."); + Log("SYSTEM: closing socket."); -#ifdef _IMPROVED_PACKET_ENCRYPTION_ - cipher_.CleanUp(); -#endif - - socket_close(m_sock); - m_sock = INVALID_SOCKET; + bufferevent_free(m_bufevent); + m_bufevent = nullptr; } m_seq_vector.clear(); @@ -211,29 +240,25 @@ void DESC::SetPong(bool b) m_bPong = b; } -bool DESC::Setup(LPFDWATCH _fdw, socket_t _fd, const struct sockaddr_in & c_rSockAddr, DWORD _handle, DWORD _handshake) +bool DESC::Setup(event_base * evbase, evutil_socket_t fd, const sockaddr * c_rSockAddr, DWORD _handle, DWORD _handshake) { - m_lpFdw = _fdw; - m_sock = _fd; + m_bufevent = bufferevent_socket_new(evbase, fd, BEV_OPT_CLOSE_ON_FREE); + if (m_bufevent == nullptr) { + sys_err("DESC::Setup : Could not set up bufferevent!"); + return false; + } - m_stHost = inet_ntoa(c_rSockAddr.sin_addr); - m_wPort = c_rSockAddr.sin_port; + // Set the event handlers for this peer + bufferevent_setcb(m_bufevent, DescReadHandler, DescWriteHandler, DescEventHandler, this); + + // Enable the events + bufferevent_enable(m_bufevent, EV_READ|EV_WRITE); + + m_stHost = GetSocketHost(c_rSockAddr); + m_wPort = GetSocketPort(c_rSockAddr); m_dwHandle = _handle; - //if (LC_IsEurope() == true || LC_IsNewCIBN()) - // m_lpOutputBuffer = buffer_new(DEFAULT_PACKET_BUFFER_SIZE * 2); - //else - //NOTE: ÀÌ°É ³ª¶óº°·Î ´Ù¸£°Ô Àâ¾Æ¾ßÇÒ ÀÌÀ¯°¡ ÀÖ³ª? - m_lpOutputBuffer = buffer_new(DEFAULT_PACKET_BUFFER_SIZE * 2); - - m_iMinInputBufferLen = MAX_INPUT_LEN >> 1; - m_lpInputBuffer = buffer_new(MAX_INPUT_LEN); - - m_SockAddr = c_rSockAddr; - - fdwatch_add_fd(m_lpFdw, m_sock, this, FDW_READ, false); - - // Ping Event + // Ping Event desc_event_info* info = AllocEventInfo(); info->desc = this; @@ -241,178 +266,71 @@ bool DESC::Setup(LPFDWATCH _fdw, socket_t _fd, const struct sockaddr_in & c_rSoc m_pkPingEvent = event_create(ping_event, info, ping_event_second_cycle); -#ifndef _IMPROVED_PACKET_ENCRYPTION_ - if (LC_IsEurope()) - { - memcpy(m_adwEncryptionKey, "1234abcd5678efgh", sizeof(DWORD) * 4); - memcpy(m_adwDecryptionKey, "1234abcd5678efgh", sizeof(DWORD) * 4); - } - else - { - memcpy(m_adwEncryptionKey, "testtesttesttest", sizeof(DWORD) * 4); - memcpy(m_adwDecryptionKey, "testtesttesttest", sizeof(DWORD) * 4); - } -#endif // _IMPROVED_PACKET_ENCRYPTION_ - // Set Phase to handshake SetPhase(PHASE_HANDSHAKE); StartHandshake(_handshake); - sys_log(0, "SYSTEM: new connection from [%s] fd: %d handshake %u output input_len %d, ptr %p", - m_stHost.c_str(), m_sock, m_dwHandshake, buffer_size(m_lpInputBuffer), this); + sys_log(0, "SYSTEM: new connection from [%s] handshake %u, ptr %p", + m_stHost.c_str(), m_dwHandshake, this); - Log("SYSTEM: new connection from [%s] fd: %d handshake %u ptr %p", m_stHost.c_str(), m_sock, m_dwHandshake, this); + Log("SYSTEM: new connection from [%s] handshake %u ptr %p", m_stHost.c_str(), m_dwHandshake, this); return true; } int DESC::ProcessInput() { - ssize_t bytes_read; + evbuffer *input = bufferevent_get_input(m_bufevent); + if (input == nullptr) { + sys_err("DESC::ProcessInput : nil input buffer"); + return -1; + } - if (!m_lpInputBuffer) - { - sys_err("DESC::ProcessInput : nil input buffer"); - return -1; - } - - buffer_adjust_size(m_lpInputBuffer, m_iMinInputBufferLen); - bytes_read = socket_read(m_sock, (char *) buffer_write_peek(m_lpInputBuffer), buffer_has_space(m_lpInputBuffer)); + size_t bytes_read = evbuffer_get_length(input); if (bytes_read < 0) return -1; else if (bytes_read == 0) return 0; - buffer_write_proceed(m_lpInputBuffer, bytes_read); - if (!m_pInputProcessor) sys_err("no input processor"); -#ifdef _IMPROVED_PACKET_ENCRYPTION_ - else - { - if (cipher_.activated()) { - cipher_.Decrypt(const_cast(buffer_read_peek(m_lpInputBuffer)), buffer_size(m_lpInputBuffer)); - } - int iBytesProceed = 0; - // false°¡ ¸®ÅÏ µÇ¸é ´Ù¸¥ phase·Î ¹Ù²ï °ÍÀ̹ǷΠ´Ù½Ã ÇÁ·Î¼¼½º·Î µ¹ÀÔÇÑ´Ù! - while (!m_pInputProcessor->Process(this, buffer_read_peek(m_lpInputBuffer), buffer_size(m_lpInputBuffer), iBytesProceed)) - { - buffer_read_proceed(m_lpInputBuffer, iBytesProceed); - iBytesProceed = 0; - } + // Get the received data + void * data = evbuffer_pullup(input, bytes_read); - buffer_read_proceed(m_lpInputBuffer, iBytesProceed); - } -#else - else if (!m_bEncrypted) - { - int iBytesProceed = 0; + int iBytesProceed = 0; - // false°¡ ¸®ÅÏ µÇ¸é ´Ù¸¥ phase·Î ¹Ù²ï °ÍÀ̹ǷΠ´Ù½Ã ÇÁ·Î¼¼½º·Î µ¹ÀÔÇÑ´Ù! - while (!m_pInputProcessor->Process(this, buffer_read_peek(m_lpInputBuffer), buffer_size(m_lpInputBuffer), iBytesProceed)) - { - buffer_read_proceed(m_lpInputBuffer, iBytesProceed); - iBytesProceed = 0; - } + // false°¡ ¸®ÅÏ µÇ¸é ´Ù¸¥ phase·Î ¹Ù²ï °ÍÀ̹ǷΠ´Ù½Ã ÇÁ·Î¼¼½º·Î µ¹ÀÔÇÑ´Ù! + while (!m_pInputProcessor->Process(this, data, bytes_read, iBytesProceed)) + { + // Flush the read bytes from the network buffer + evbuffer_drain(input, iBytesProceed); + iBytesProceed = 0; + } - buffer_read_proceed(m_lpInputBuffer, iBytesProceed); - } - else - { - int iSizeBuffer = buffer_size(m_lpInputBuffer); + // Flush the read bytes from the network buffer + evbuffer_drain(input, iBytesProceed); - // 8¹ÙÀÌÆ® ´ÜÀ§·Î¸¸ ó¸®ÇÑ´Ù. 8¹ÙÀÌÆ® ´ÜÀ§¿¡ ºÎÁ·Çϸé À߸øµÈ ¾Ïȣȭ ¹öÆÛ¸¦ º¹È£È­ - // ÇÒ °¡´É¼ºÀÌ ÀÖÀ¸¹Ç·Î ©¶ó¼­ ó¸®Çϱâ·Î ÇÑ´Ù. - if (iSizeBuffer & 7) // & 7Àº % 8°ú °°´Ù. 2ÀÇ ½Â¼ö¿¡¼­¸¸ °¡´É - iSizeBuffer -= iSizeBuffer & 7; - - if (iSizeBuffer > 0) - { - TEMP_BUFFER tempbuf; - LPBUFFER lpBufferDecrypt = tempbuf.getptr(); - buffer_adjust_size(lpBufferDecrypt, iSizeBuffer); - - int iSizeAfter = TEA_Decrypt((DWORD *) buffer_write_peek(lpBufferDecrypt), - (DWORD *) buffer_read_peek(m_lpInputBuffer), - GetDecryptionKey(), - iSizeBuffer); - - buffer_write_proceed(lpBufferDecrypt, iSizeAfter); - - int iBytesProceed = 0; - - // false°¡ ¸®ÅÏ µÇ¸é ´Ù¸¥ phase·Î ¹Ù²ï °ÍÀ̹ǷΠ´Ù½Ã ÇÁ·Î¼¼½º·Î µ¹ÀÔÇÑ´Ù! - while (!m_pInputProcessor->Process(this, buffer_read_peek(lpBufferDecrypt), buffer_size(lpBufferDecrypt), iBytesProceed)) - { - if (iBytesProceed > iSizeBuffer) - { - buffer_read_proceed(m_lpInputBuffer, iSizeBuffer); - iSizeBuffer = 0; - iBytesProceed = 0; - break; - } - - buffer_read_proceed(m_lpInputBuffer, iBytesProceed); - iSizeBuffer -= iBytesProceed; - - buffer_read_proceed(lpBufferDecrypt, iBytesProceed); - iBytesProceed = 0; - } - - buffer_read_proceed(m_lpInputBuffer, iBytesProceed); - } - } -#endif // _IMPROVED_PACKET_ENCRYPTION_ - - return (bytes_read); + return bytes_read; } -int DESC::ProcessOutput() -{ - if (buffer_size(m_lpOutputBuffer) <= 0) - return 0; - - int buffer_left = fdwatch_get_buffer_size(m_lpFdw, m_sock); - - if (buffer_left <= 0) - return 0; - - int bytes_to_write = MIN(buffer_left, buffer_size(m_lpOutputBuffer)); - - if (bytes_to_write == 0) - return 0; - - int result = socket_write(m_sock, (const char *) buffer_read_peek(m_lpOutputBuffer), bytes_to_write); - - if (result == 0) - { - //sys_log(0, "%d bytes written to %s first %u", bytes_to_write, GetHostName(), *(BYTE *) buffer_read_peek(m_lpOutputBuffer)); - //Log("%d bytes written", bytes_to_write); - max_bytes_written = MAX(bytes_to_write, max_bytes_written); - - total_bytes_written += bytes_to_write; - current_bytes_written += bytes_to_write; - - buffer_read_proceed(m_lpOutputBuffer, bytes_to_write); - - if (buffer_size(m_lpOutputBuffer) != 0) - fdwatch_add_fd(m_lpFdw, m_sock, this, FDW_WRITE, true); - } - - return (result); -} - -void DESC::BufferedPacket(const void * c_pvData, int iSize) +bool DESC::RawPacket(const void * c_pvData, int iSize) { if (m_iPhase == PHASE_CLOSE) - return; + return false; - if (!m_lpBufferedOutputBuffer) - m_lpBufferedOutputBuffer = buffer_new(MAX(1024, iSize)); + if (!m_bufevent) { + sys_err("Bufferevent not ready!"); + return false; + } - buffer_write(m_lpBufferedOutputBuffer, c_pvData, iSize); + if (bufferevent_write(m_bufevent, c_pvData, iSize) != 0) { + sys_err("Buffer write error!"); + return false; + } + + return true; } void DESC::Packet(const void * c_pvData, int iSize) @@ -431,7 +349,7 @@ void DESC::Packet(const void * c_pvData, int iSize) strncpy(p.szName, m_stRelayName.c_str(), sizeof(p.szName)); p.lSize = iSize; - if (!packet_encode(m_lpOutputBuffer, &p, sizeof(p))) + if (!RawPacket(&p, sizeof(p))) { m_iPhase = PHASE_CLOSE; return; @@ -439,7 +357,7 @@ void DESC::Packet(const void * c_pvData, int iSize) m_stRelayName.clear(); - if (!packet_encode(m_lpOutputBuffer, c_pvData, iSize)) + if (!RawPacket(c_pvData, iSize)) { m_iPhase = PHASE_CLOSE; return; @@ -447,81 +365,17 @@ void DESC::Packet(const void * c_pvData, int iSize) } else { - if (m_lpBufferedOutputBuffer) - { - buffer_write(m_lpBufferedOutputBuffer, c_pvData, iSize); - - c_pvData = buffer_read_peek(m_lpBufferedOutputBuffer); - iSize = buffer_size(m_lpBufferedOutputBuffer); - } - // TRAFFIC_PROFILE if (g_bTrafficProfileOn) TrafficProfiler::instance().Report(TrafficProfiler::IODIR_OUTPUT, *(BYTE *) c_pvData, iSize); // END_OF_TRAFFIC_PROFILER -#ifdef _IMPROVED_PACKET_ENCRYPTION_ - void* buf = buffer_write_peek(m_lpOutputBuffer); - - - if (packet_encode(m_lpOutputBuffer, c_pvData, iSize)) - { - if (cipher_.activated()) { - cipher_.Encrypt(buf, iSize); - } - } - else - { + if (!RawPacket(c_pvData, iSize)) { m_iPhase = PHASE_CLOSE; } -#else - if (!m_bEncrypted) - { - if (!packet_encode(m_lpOutputBuffer, c_pvData, iSize)) - { - m_iPhase = PHASE_CLOSE; - } - } - else - { - if (buffer_has_space(m_lpOutputBuffer) < iSize + 8) - { - sys_err("desc buffer mem_size overflow. memsize(%u) write_pos(%u) iSize(%d)", - m_lpOutputBuffer->mem_size, m_lpOutputBuffer->write_point_pos, iSize); - - m_iPhase = PHASE_CLOSE; - } - else - { - // ¾Ïȣȭ¿¡ ÇÊ¿äÇÑ ÃæºÐÇÑ ¹öÆÛ Å©±â¸¦ È®º¸ÇÑ´Ù. - /* buffer_adjust_size(m_lpOutputBuffer, iSize + 8); */ - DWORD * pdwWritePoint = (DWORD *) buffer_write_peek(m_lpOutputBuffer); - - if (packet_encode(m_lpOutputBuffer, c_pvData, iSize)) - { - int iSize2 = TEA_Encrypt(pdwWritePoint, pdwWritePoint, GetEncryptionKey(), iSize); - - if (iSize2 > iSize) - buffer_write_proceed(m_lpOutputBuffer, iSize2 - iSize); - } - } - } -#endif // _IMPROVED_PACKET_ENCRYPTION_ - - SAFE_BUFFER_DELETE(m_lpBufferedOutputBuffer); - } + } //sys_log(0, "%d bytes written (first byte %d)", iSize, *(BYTE *) c_pvData); - if (m_iPhase != PHASE_CLOSE) - fdwatch_add_fd(m_lpFdw, m_sock, this, FDW_WRITE, true); -} - -void DESC::LargePacket(const void * c_pvData, int iSize) -{ - buffer_adjust_size(m_lpOutputBuffer, iSize); - sys_log(0, "LargePacket Size %d", iSize, buffer_size(m_lpOutputBuffer)); - - Packet(c_pvData, iSize); } void DESC::SetPhase(int _phase) @@ -550,24 +404,15 @@ void DESC::SetPhase(int _phase) //MessengerManager::instance().Logout(GetAccountTable().login); // ÀǵµÀûÀ¸·Î break ¾È°Ë case PHASE_LOGIN: case PHASE_LOADING: -#ifndef _IMPROVED_PACKET_ENCRYPTION_ - m_bEncrypted = true; -#endif m_pInputProcessor = &m_inputLogin; break; case PHASE_GAME: case PHASE_DEAD: -#ifndef _IMPROVED_PACKET_ENCRYPTION_ - m_bEncrypted = true; -#endif m_pInputProcessor = &m_inputMain; break; case PHASE_AUTH: -#ifndef _IMPROVED_PACKET_ENCRYPTION_ - m_bEncrypted = true; -#endif m_pInputProcessor = &m_inputAuth; sys_log(0, "AUTH_PHASE %p", this); break; @@ -618,7 +463,7 @@ void DESC::StartHandshake(DWORD _handshake) m_iHandshakeRetry = 0; } -void DESC::SendHandshake(DWORD dwCurTime, long lNewDelta) +void DESC::SendHandshake(DWORD dwCurTime, LONG lNewDelta) { TPacketGCHandshake pack; @@ -633,7 +478,7 @@ void DESC::SendHandshake(DWORD dwCurTime, long lNewDelta) m_bHandshaking = true; } -bool DESC::HandshakeProcess(DWORD dwTime, long lDelta, bool bInfiniteRetry) +bool DESC::HandshakeProcess(DWORD dwTime, LONG lDelta, bool bInfiniteRetry) { DWORD dwCurTime = get_dword_time(); @@ -643,7 +488,7 @@ bool DESC::HandshakeProcess(DWORD dwTime, long lDelta, bool bInfiniteRetry) return false; } - int bias = (int) (dwCurTime - (dwTime + lDelta)); + int bias = (int) (dwCurTime - (dwTime + lDelta)); if (bias >= 0 && bias <= 50) { @@ -663,7 +508,7 @@ bool DESC::HandshakeProcess(DWORD dwTime, long lDelta, bool bInfiniteRetry) return true; } - long lNewDelta = (long) (dwCurTime - dwTime) / 2; + LONG lNewDelta = (LONG) (dwCurTime - dwTime) / 2; if (lNewDelta < 0) { @@ -696,47 +541,6 @@ DWORD DESC::GetClientTime() return m_dwClientTime; } -#ifdef _IMPROVED_PACKET_ENCRYPTION_ -void DESC::SendKeyAgreement() -{ - TPacketKeyAgreement packet; - - size_t data_length = TPacketKeyAgreement::MAX_DATA_LEN; - size_t agreed_length = cipher_.Prepare(packet.data, &data_length); - if (agreed_length == 0) { - // Initialization failure - SetPhase(PHASE_CLOSE); - return; - } - assert(data_length <= TPacketKeyAgreement::MAX_DATA_LEN); - - packet.bHeader = HEADER_GC_KEY_AGREEMENT; - packet.wAgreedLength = (WORD)agreed_length; - packet.wDataLength = (WORD)data_length; - - Packet(&packet, sizeof(packet)); -} - -void DESC::SendKeyAgreementCompleted() -{ - TPacketKeyAgreementCompleted packet; - - packet.bHeader = HEADER_GC_KEY_AGREEMENT_COMPLETED; - - Packet(&packet, sizeof(packet)); -} - -bool DESC::FinishHandshake(size_t agreed_length, const void* buffer, size_t length) -{ - return cipher_.Activate(false, agreed_length, buffer, length); -} - -bool DESC::IsCipherPrepared() -{ - return cipher_.IsKeyPrepared(); -} -#endif // #ifdef _IMPROVED_PACKET_ENCRYPTION_ - void DESC::SetRelay(const char * c_pszName) { m_stRelayName = c_pszName; @@ -749,82 +553,13 @@ void DESC::BindCharacter(LPCHARACTER ch) void DESC::FlushOutput() { - if (m_sock == INVALID_SOCKET) { - return; - } - - if (buffer_size(m_lpOutputBuffer) <= 0) + if (m_bufevent == nullptr) return; - struct timeval sleep_tv, now_tv, start_tv; - int event_triggered = false; - - gettimeofday(&start_tv, NULL); - - socket_block(m_sock); - sys_log(0, "FLUSH START %d", buffer_size(m_lpOutputBuffer)); - - while (buffer_size(m_lpOutputBuffer) > 0) - { - gettimeofday(&now_tv, NULL); - - int iSecondsPassed = now_tv.tv_sec - start_tv.tv_sec; - - if (iSecondsPassed > 10) - { - if (!event_triggered || iSecondsPassed > 20) - { - SetPhase(PHASE_CLOSE); - break; - } - } - - sleep_tv.tv_sec = 0; - sleep_tv.tv_usec = 10000; - - int num_events = fdwatch(m_lpFdw, &sleep_tv); - - if (num_events < 0) - { - sys_err("num_events < 0 : %d", num_events); - break; - } - - int event_idx; - - for (event_idx = 0; event_idx < num_events; ++event_idx) - { - LPDESC d2 = (LPDESC) fdwatch_get_client_data(m_lpFdw, event_idx); - - if (d2 != this) - continue; - - switch (fdwatch_check_event(m_lpFdw, m_sock, event_idx)) - { - case FDW_WRITE: - event_triggered = true; - - if (ProcessOutput() < 0) - { - sys_err("Cannot flush output buffer"); - SetPhase(PHASE_CLOSE); - } - break; - - case FDW_EOF: - SetPhase(PHASE_CLOSE); - break; - } - } - - if (IsPhase(PHASE_CLOSE)) - break; - } - - if (buffer_size(m_lpOutputBuffer) == 0) - sys_log(0, "FLUSH SUCCESS"); - else - sys_log(0, "FLUSH FAIL"); + if (bufferevent_flush(m_bufevent, EV_WRITE, BEV_FLUSH) < 0) + sys_log(0, "FLUSH FAIL"); + else + sys_log(0, "FLUSH SUCCESS"); usleep(250000); } @@ -948,18 +683,18 @@ void DESC::SendLoginSuccessPacket() // //printf("STATE_CHECK PACKET PROCESSED.\n"); //} -void DESC::SetMatrixCardRowsAndColumns(unsigned long rows, unsigned long cols) +void DESC::SetMatrixCardRowsAndColumns(unsigned int rows, unsigned int cols) { m_dwMatrixRows = rows; m_dwMatrixCols = cols; } -unsigned long DESC::GetMatrixRows() +unsigned int DESC::GetMatrixRows() { return m_dwMatrixRows; } -unsigned long DESC::GetMatrixCols() +unsigned int DESC::GetMatrixCols() { return m_dwMatrixCols; } @@ -1013,23 +748,6 @@ const BYTE* GetKey_20050304Myevan() return (const BYTE*)s_adwKey; } -#ifndef _IMPROVED_PACKET_ENCRYPTION_ -void DESC::SetSecurityKey(const DWORD * c_pdwKey) -{ - const BYTE * c_pszKey = (const BYTE *) "JyTxtHljHJlVJHorRM301vf@4fvj10-v"; - - if (g_iUseLocale && !LC_IsKorea()) - c_pszKey = GetKey_20050304Myevan() + 37; - - memcpy(&m_adwDecryptionKey, c_pdwKey, 16); - TEA_Encrypt(&m_adwEncryptionKey[0], &m_adwDecryptionKey[0], (const DWORD *) c_pszKey, 16); - - sys_log(0, "SetSecurityKey decrypt %u %u %u %u encrypt %u %u %u %u", - m_adwDecryptionKey[0], m_adwDecryptionKey[1], m_adwDecryptionKey[2], m_adwDecryptionKey[3], - m_adwEncryptionKey[0], m_adwEncryptionKey[1], m_adwEncryptionKey[2], m_adwEncryptionKey[3]); -} -#endif // _IMPROVED_PACKET_ENCRYPTION_ - void DESC::AssembleCRCMagicCube(BYTE bProcPiece, BYTE bFilePiece) { static BYTE abXORTable[32] = diff --git a/game/src/desc.h b/game/src/desc.h index d2d10c9..577ec5e 100644 --- a/game/src/desc.h +++ b/game/src/desc.h @@ -1,11 +1,12 @@ #ifndef __INC_METIN_II_GAME_DESC_H__ #define __INC_METIN_II_GAME_DESC_H__ +#include +#include +#include + #include "constants.h" #include "input.h" -#ifdef _IMPROVED_PACKET_ENCRYPTION_ -#include "cipher.h" -#endif #define MAX_ALLOW_USER 4096 //#define MAX_INPUT_LEN 2048 @@ -55,6 +56,10 @@ struct seq_t typedef std::vector seq_vector_t; // sequence ¹ö±× ã±â¿ë µ¥ÀÌŸ +extern void DescReadHandler(bufferevent *bev, void *ctx); +extern void DescWriteHandler(bufferevent *bev, void *ctx); +extern void DescEventHandler(bufferevent *bev, short events, void *ctx); + class DESC { public: @@ -78,28 +83,23 @@ class DESC void FlushOutput(); - bool Setup(LPFDWATCH _fdw, socket_t _fd, const struct sockaddr_in & c_rSockAddr, DWORD _handle, DWORD _handshake); + bool Setup(event_base * evbase, evutil_socket_t fd, const sockaddr * c_rSockAddr, DWORD _handle, DWORD _handshake); - socket_t GetSocket() const { return m_sock; } const char * GetHostName() { return m_stHost.c_str(); } WORD GetPort() { return m_wPort; } - void SetP2P(const char * h, WORD w, BYTE b) { m_stP2PHost = h; m_wP2PPort = w; m_bP2PChannel = b; } - const char * GetP2PHost() { return m_stP2PHost.c_str(); } + void SetP2P(WORD w, BYTE b) { m_wP2PPort = w; m_bP2PChannel = b; } WORD GetP2PPort() const { return m_wP2PPort; } BYTE GetP2PChannel() const { return m_bP2PChannel; } - void BufferedPacket(const void * c_pvData, int iSize); - void Packet(const void * c_pvData, int iSize); - void LargePacket(const void * c_pvData, int iSize); + bool RawPacket(const void * c_pvData, int iSize); + void Packet(const void * c_pvData, int iSize); int ProcessInput(); // returns -1 if error - int ProcessOutput(); // returns -1 if error CInputProcessor * GetInputProcessor() { return m_pInputProcessor; } DWORD GetHandle() const { return m_dwHandle; } - LPBUFFER GetOutputBuffer() { return m_lpOutputBuffer; } void BindAccountTable(TAccountTable * pTable); TAccountTable & GetAccountTable() { return m_accountTable; } @@ -109,31 +109,17 @@ class DESC bool IsPhase(int phase) const { return m_iPhase == phase ? true : false; } - const struct sockaddr_in & GetAddr() { return m_SockAddr; } - void Log(const char * format, ...); // Çڵ彦ÀÌÅ© (½Ã°£ µ¿±âÈ­) void StartHandshake(DWORD _dw); - void SendHandshake(DWORD dwCurTime, long lNewDelta); - bool HandshakeProcess(DWORD dwTime, long lDelta, bool bInfiniteRetry=false); + void SendHandshake(DWORD dwCurTime, LONG lNewDelta); + bool HandshakeProcess(DWORD dwTime, LONG lDelta, bool bInfiniteRetry=false); bool IsHandshaking(); DWORD GetHandshake() const { return m_dwHandshake; } DWORD GetClientTime(); -#ifdef _IMPROVED_PACKET_ENCRYPTION_ - void SendKeyAgreement(); - void SendKeyAgreementCompleted(); - bool FinishHandshake(size_t agreed_length, const void* buffer, size_t length); - bool IsCipherPrepared(); -#else - // Obsolete encryption stuff here - void SetSecurityKey(const DWORD * c_pdwKey); - const DWORD * GetEncryptionKey() const { return &m_adwEncryptionKey[0]; } - const DWORD * GetDecryptionKey() const { return &m_adwDecryptionKey[0]; } -#endif - // Á¦±¹ BYTE GetEmpire(); @@ -157,9 +143,9 @@ class DESC void SetMatrixCode(const char * c_psz) { m_stMatrixCode = c_psz; } const char * GetMatrixCode() { return m_stMatrixCode.c_str(); } - void SetMatrixCardRowsAndColumns(unsigned long rows, unsigned long cols); - unsigned long GetMatrixRows(); - unsigned long GetMatrixCols(); + void SetMatrixCardRowsAndColumns(unsigned int rows, unsigned int cols); + unsigned int GetMatrixRows(); + unsigned int GetMatrixCols(); bool CheckMatrixTryCount(); void SetPanamaKey(DWORD dwKey) {m_dwPanamaKey = dwKey;} @@ -192,9 +178,8 @@ class DESC CInputDead m_inputDead; CInputAuth m_inputAuth; - - LPFDWATCH m_lpFdw; - socket_t m_sock; + event_base * m_evbase; + bufferevent * m_bufevent; int m_iPhase; DWORD m_dwHandle; @@ -202,28 +187,19 @@ class DESC WORD m_wPort; time_t m_LastTryToConnectTime; - LPBUFFER m_lpInputBuffer; - int m_iMinInputBufferLen; - DWORD m_dwHandshake; DWORD m_dwHandshakeSentTime; int m_iHandshakeRetry; DWORD m_dwClientTime; bool m_bHandshaking; - LPBUFFER m_lpBufferedOutputBuffer; - LPBUFFER m_lpOutputBuffer; - LPEVENT m_pkPingEvent; LPCHARACTER m_lpCharacter; TAccountTable m_accountTable; - struct sockaddr_in m_SockAddr; - FILE * m_pLogFile; std::string m_stRelayName; - std::string m_stP2PHost; WORD m_wP2PPort; BYTE m_bP2PChannel; @@ -256,15 +232,6 @@ class DESC bool m_bDestroyed; bool m_bChannelStatusRequested; -#ifdef _IMPROVED_PACKET_ENCRYPTION_ - Cipher cipher_; -#else - // Obsolete encryption stuff here - bool m_bEncrypted; - DWORD m_adwDecryptionKey[4]; - DWORD m_adwEncryptionKey[4]; -#endif - public: LPEVENT m_pkDisconnectEvent; @@ -286,7 +253,6 @@ class DESC void SetOffTime( int offtime ) { m_offtime = offtime; } void SetPlayTime( int playtime ) { m_playtime = playtime; } - void RawPacket(const void * c_pvData, int iSize); void ChatPacket(BYTE type, const char * format, ...); /* ½ÃÄö½º ¹ö±× ã±â¿ë ÄÚµå */ diff --git a/game/src/desc_client.cpp b/game/src/desc_client.cpp index 26dd536..5e6e257 100644 --- a/game/src/desc_client.cpp +++ b/game/src/desc_client.cpp @@ -9,16 +9,12 @@ #include "buffer_manager.h" #include "guild_manager.h" #include "db.h" - #include "party.h" -extern LPFDWATCH main_fdw; - LPCLIENT_DESC db_clientdesc = NULL; LPCLIENT_DESC g_pkAuthMasterDesc = NULL; LPCLIENT_DESC g_NetmarbleDBDesc = NULL; LPCLIENT_DESC g_TeenDesc = NULL; -LPCLIENT_DESC g_PasspodDesc = NULL; static const char* GetKnownClientDescName(LPCLIENT_DESC desc) { if (desc == db_clientdesc) { @@ -29,12 +25,32 @@ static const char* GetKnownClientDescName(LPCLIENT_DESC desc) { return "g_NetmarbleDBDesc"; } else if (desc == g_TeenDesc) { return "g_TeenDesc"; - } else if (desc == g_PasspodDesc) { - return "g_PasspodDesc"; } return "unknown"; } +void ClientDescEventHandler(bufferevent *bev, short events, void *ptr) { + auto * clientDesc = static_cast(ptr); + + if (events & BEV_EVENT_CONNECTED) { + sys_log(0, "SYSTEM: connected to server (ptr %p)", clientDesc); + clientDesc->OnConnectSuccessful(); + + // Now that we're connected, we can set the read/write/event handlers (and therefore stop using this handler) + auto * desc = static_cast(clientDesc); + bufferevent_setcb(bev, DescReadHandler, DescWriteHandler, DescEventHandler, desc); + } else if (events & (BEV_EVENT_ERROR|BEV_EVENT_EOF)) { + if (events & BEV_EVENT_ERROR) { + int err = bufferevent_socket_get_dns_error(bev); + if (err) + sys_err("SYSTEM: Client connection DNS error: %s", evutil_gai_strerror(err)); + } + + sys_log(0, "SYSTEM: closing client connection (ptr %p)", clientDesc); + clientDesc->SetPhase(PHASE_CLOSE); + } +} + CLIENT_DESC::CLIENT_DESC() { m_iPhaseWhenSucceed = 0; @@ -49,9 +65,8 @@ CLIENT_DESC::~CLIENT_DESC() void CLIENT_DESC::Destroy() { - if (m_sock == INVALID_SOCKET) { + if (m_bufevent == nullptr) return; - } P2P_MANAGER::instance().UnregisterConnector(this); @@ -63,12 +78,10 @@ void CLIENT_DESC::Destroy() DBManager::instance().StopAllBilling(); } - fdwatch_del_fd(m_lpFdw, m_sock); + sys_log(0, "SYSTEM: closing client socket."); - sys_log(0, "SYSTEM: closing client socket. DESC #%d", m_sock); - - socket_close(m_sock); - m_sock = INVALID_SOCKET; + bufferevent_free(m_bufevent); + m_bufevent = nullptr; // Chain up to base class Destroy() DESC::Destroy(); @@ -89,38 +102,41 @@ bool CLIENT_DESC::Connect(int iPhaseWhenSucceed) m_LastTryToConnectTime = get_global_time(); - if (m_sock != INVALID_SOCKET) + if (m_bufevent != nullptr) return false; sys_log(0, "SYSTEM: Trying to connect to %s:%d", m_stHost.c_str(), m_wPort); - m_sock = socket_connect(m_stHost.c_str(), m_wPort); + if (m_evbase == nullptr) { + sys_err("SYSTEM: event base not set!"); + return false; + } + if (m_dnsBase == nullptr) { + sys_err("SYSTEM: DNS event base not set!"); + return false; + } - if (m_sock != INVALID_SOCKET) - { - sys_log(0, "SYSTEM: connected to server (fd %d, ptr %p)", m_sock, this); - fdwatch_add_fd(m_lpFdw, m_sock, this, FDW_READ, false); - fdwatch_add_fd(m_lpFdw, m_sock, this, FDW_WRITE, false); - SetPhase(m_iPhaseWhenSucceed); - return true; - } - else - { - SetPhase(PHASE_CLIENT_CONNECTING); - return false; - } + m_bufevent = bufferevent_socket_new(m_evbase, -1, BEV_OPT_CLOSE_ON_FREE); + bufferevent_setcb(m_bufevent, NULL, NULL, ClientDescEventHandler, this); + bufferevent_enable(m_bufevent, EV_READ|EV_WRITE); + bufferevent_socket_connect_hostname(m_bufevent, m_dnsBase, AF_UNSPEC, m_stHost.c_str(), m_wPort); + + SetPhase(PHASE_CLIENT_CONNECTING); + return true; } -void CLIENT_DESC::Setup(LPFDWATCH _fdw, const char * _host, WORD _port) +void CLIENT_DESC::OnConnectSuccessful() { + sys_log(0, "SYSTEM: connected to server (ptr %p)", this); + SetPhase(m_iPhaseWhenSucceed); +} + +void CLIENT_DESC::Setup(event_base* base, evdns_base * dns_base, const char * _host, WORD _port) { - // 1MB input/output buffer - m_lpFdw = _fdw; + m_evbase = base; + m_dnsBase = dns_base; m_stHost = _host; m_wPort = _port; - - InitializeBuffers(); - - m_sock = INVALID_SOCKET; + m_bufevent = nullptr; } void CLIENT_DESC::SetPhase(int iPhase) @@ -196,9 +212,6 @@ void CLIENT_DESC::SetPhase(int iPhase) strncpy(pck.szSocialID, r.social_id, sizeof(pck.szSocialID)); strncpy(pck.szHost, d->GetHostName(), sizeof(pck.szHost)); pck.dwLoginKey = d->GetLoginKey(); -#ifndef _IMPROVED_PACKET_ENCRYPTION_ - memcpy(pck.adwClientKey, d->GetDecryptionKey(), 16); -#endif buf.write(&pck, sizeof(TPacketLoginOnSetup)); } @@ -224,13 +237,6 @@ void CLIENT_DESC::SetPhase(int iPhase) case PHASE_P2P: sys_log(1, "PHASE_P2P"); - - if (m_lpInputBuffer) - buffer_reset(m_lpInputBuffer); - - if (m_lpOutputBuffer) - buffer_reset(m_lpOutputBuffer); - m_pInputProcessor = &m_inputP2P; break; @@ -250,33 +256,34 @@ void CLIENT_DESC::SetPhase(int iPhase) void CLIENT_DESC::DBPacketHeader(BYTE bHeader, DWORD dwHandle, DWORD dwSize) { - buffer_write(m_lpOutputBuffer, encode_byte(bHeader), sizeof(BYTE)); - buffer_write(m_lpOutputBuffer, encode_4bytes(dwHandle), sizeof(DWORD)); - buffer_write(m_lpOutputBuffer, encode_4bytes(dwSize), sizeof(DWORD)); + DESC::RawPacket(encode_byte(bHeader), sizeof(BYTE)); + DESC::RawPacket(encode_4bytes(dwHandle), sizeof(DWORD)); + DESC::RawPacket(encode_4bytes(dwSize), sizeof(DWORD)); } void CLIENT_DESC::DBPacket(BYTE bHeader, DWORD dwHandle, const void * c_pvData, DWORD dwSize) { - if (m_sock == INVALID_SOCKET) { + if (m_bufevent == nullptr) { sys_log(0, "CLIENT_DESC [%s] trying DBPacket() while not connected", GetKnownClientDescName(this)); return; } - sys_log(1, "DB_PACKET: header %d handle %d size %d buffer_size %d", bHeader, dwHandle, dwSize, buffer_size(m_lpOutputBuffer)); + sys_log(1, "DB_PACKET: header %d handle %d size %d", bHeader, dwHandle, dwSize); DBPacketHeader(bHeader, dwHandle, dwSize); if (c_pvData) - buffer_write(m_lpOutputBuffer, c_pvData, dwSize); + DESC::RawPacket(c_pvData, dwSize); } void CLIENT_DESC::Packet(const void * c_pvData, int iSize) { - if (m_sock == INVALID_SOCKET) { + if (m_bufevent == nullptr) { sys_log(0, "CLIENT_DESC [%s] trying Packet() while not connected", GetKnownClientDescName(this)); return; } - buffer_write(m_lpOutputBuffer, c_pvData, iSize); + + DESC::RawPacket(c_pvData, iSize); } bool CLIENT_DESC::IsRetryWhenClosed() @@ -316,7 +323,7 @@ void CLIENT_DESC::UpdateChannelStatus(DWORD t, bool fForce) void CLIENT_DESC::Reset() { // Backup connection target info - LPFDWATCH fdw = m_lpFdw; + event_base * evbase = m_evbase; std::string host = m_stHost; WORD port = m_wPort; @@ -324,16 +331,7 @@ void CLIENT_DESC::Reset() Initialize(); // Restore connection target info - m_lpFdw = fdw; + m_evbase = evbase; m_stHost = host; m_wPort = port; - - InitializeBuffers(); -} - -void CLIENT_DESC::InitializeBuffers() -{ - m_lpOutputBuffer = buffer_new(1024 * 1024); - m_lpInputBuffer = buffer_new(1024 * 1024); - m_iMinInputBufferLen = 1024 * 1024; -} +} \ No newline at end of file diff --git a/game/src/desc_client.h b/game/src/desc_client.h index 6c3c35a..03169a1 100644 --- a/game/src/desc_client.h +++ b/game/src/desc_client.h @@ -3,6 +3,8 @@ #include "desc.h" +#include + class CLIENT_DESC : public DESC { public: @@ -14,7 +16,8 @@ class CLIENT_DESC : public DESC virtual void SetPhase(int phase); bool Connect(int iPhaseWhenSucceed = 0); - void Setup(LPFDWATCH _fdw, const char * _host, WORD _port); + void OnConnectSuccessful(); + void Setup(event_base* base, evdns_base * dns_base, const char * _host, WORD _port); void SetRetryWhenClosed(bool); @@ -29,11 +32,10 @@ class CLIENT_DESC : public DESC // Non-destructive close for reuse void Reset(); - private: - void InitializeBuffers(); - protected: - int m_iPhaseWhenSucceed; + evdns_base * m_dnsBase; + + int m_iPhaseWhenSucceed; bool m_bRetryWhenClosed; time_t m_LastTryToConnectTime; time_t m_tLastChannelStatusUpdateTime; @@ -48,6 +50,5 @@ extern LPCLIENT_DESC db_clientdesc; extern LPCLIENT_DESC g_pkAuthMasterDesc; extern LPCLIENT_DESC g_NetmarbleDBDesc; extern LPCLIENT_DESC g_TeenDesc; -extern LPCLIENT_DESC g_PasspodDesc; #endif diff --git a/game/src/desc_manager.cpp b/game/src/desc_manager.cpp index a141157..fa32124 100644 --- a/game/src/desc_manager.cpp +++ b/game/src/desc_manager.cpp @@ -10,7 +10,6 @@ #include "protocol.h" #include "messenger_manager.h" #include "p2p.h" -#include "ip_ban.h" #include "dev_log.h" #include "ClientPackageCryptInfo.h" @@ -146,47 +145,27 @@ RETRY: return (crc); } -LPDESC DESC_MANAGER::AcceptDesc(LPFDWATCH fdw, socket_t s) +LPDESC DESC_MANAGER::AcceptDesc(evconnlistener* listener, evutil_socket_t fd, sockaddr* address) { - socket_t desc; - LPDESC newd; - static struct sockaddr_in peer; - static char host[MAX_HOST_LENGTH + 1]; - - if ((desc = socket_accept(s, &peer)) == -1) - return NULL; - - strncpy(host, inet_ntoa(peer.sin_addr), sizeof(host)); - - if (g_bAuthServer) - { - if (IsBanIP(peer.sin_addr)) - { - sys_log(0, "connection from %s was banned.", host); - socket_close(desc); - return NULL; - } - } - - if (!IsValidIP(admin_ip, host)) // admin_ip ¿¡ µî·ÏµÈ IP ´Â ÃÖ´ë »ç¿ëÀÚ ¼ö¿¡ ±¸¾Ö¹ÞÁö ¾Ê´Â´Ù. + if (!IsValidIP(admin_ip, GetSocketHost(address).c_str())) // admin_ip ¿¡ µî·ÏµÈ IP ´Â ÃÖ´ë »ç¿ëÀÚ ¼ö¿¡ ±¸¾Ö¹ÞÁö ¾Ê´Â´Ù. { if (m_iSocketsConnected >= MAX_ALLOW_USER) { sys_err("max connection reached. MAX_ALLOW_USER = %d", MAX_ALLOW_USER); - socket_close(desc); - return NULL; + return nullptr; } } - newd = M2_NEW DESC; - crc_t handshake = CreateHandshake(); + event_base *base = evconnlistener_get_base(listener); - if (!newd->Setup(fdw, desc, peer, ++m_iHandleCount, handshake)) - { - socket_close(desc); - M2_DELETE(newd); - return NULL; - } + // Create the peer + LPDESC newd = new DESC; + crc_t handshake = CreateHandshake(); + + if(!newd->Setup(base, fd, address, ++m_iHandleCount, handshake)) { + delete newd; + return nullptr; + } m_map_handshake.insert(DESC_HANDSHAKE_MAP::value_type(handshake, newd)); m_map_handle.insert(DESC_HANDLE_MAP::value_type(newd->GetHandle(), newd)); @@ -196,31 +175,23 @@ LPDESC DESC_MANAGER::AcceptDesc(LPFDWATCH fdw, socket_t s) return (newd); } -LPDESC DESC_MANAGER::AcceptP2PDesc(LPFDWATCH fdw, socket_t bind_fd) +LPDESC DESC_MANAGER::AcceptP2PDesc(evconnlistener* listener, evutil_socket_t fd, sockaddr* address) { - socket_t fd; - struct sockaddr_in peer; - char host[MAX_HOST_LENGTH + 1]; + event_base *base = evconnlistener_get_base(listener); - if ((fd = socket_accept(bind_fd, &peer)) == -1) - return NULL; + LPDESC_P2P pkDesc = new DESC_P2P; - strncpy(host, inet_ntoa(peer.sin_addr), sizeof(host)); - - LPDESC_P2P pkDesc = M2_NEW DESC_P2P; - - if (!pkDesc->Setup(fdw, fd, host, peer.sin_port)) + if (!pkDesc->Setup(base, fd, address)) { sys_err("DESC_MANAGER::AcceptP2PDesc : Setup failed"); - socket_close(fd); - M2_DELETE(pkDesc); - return NULL; + delete pkDesc; + return nullptr; } m_set_pkDesc.insert(pkDesc); ++m_iSocketsConnected; - sys_log(0, "DESC_MANAGER::AcceptP2PDesc %s:%u", host, peer.sin_port); + sys_log(0, "DESC_MANAGER::AcceptP2PDesc %s:%u", GetSocketHost(address).c_str(), GetSocketPort(address)); P2P_MANAGER::instance().RegisterAcceptor(pkDesc); return (pkDesc); } @@ -334,13 +305,11 @@ LPDESC DESC_MANAGER::FindByCharacterName(const char *name) return (it == m_set_pkDesc.end()) ? NULL : (*it); } -LPCLIENT_DESC DESC_MANAGER::CreateConnectionDesc(LPFDWATCH fdw, const char * host, WORD port, int iPhaseWhenSucceed, bool bRetryWhenClosed) +LPCLIENT_DESC DESC_MANAGER::CreateConnectionDesc(event_base * base, evdns_base * dns_base, const char * host, WORD port, int iPhaseWhenSucceed, bool bRetryWhenClosed) { - LPCLIENT_DESC newd; + LPCLIENT_DESC newd = new CLIENT_DESC; - newd = M2_NEW CLIENT_DESC; - - newd->Setup(fdw, host, port); + newd->Setup(base, dns_base, host, port); newd->Connect(iPhaseWhenSucceed); newd->SetRetryWhenClosed(bRetryWhenClosed); @@ -373,7 +342,7 @@ bool DESC_MANAGER::IsP2PDescExist(const char * szHost, WORD wPort) { LPCLIENT_DESC d = *(it++); - if (!strcmp(d->GetP2PHost(), szHost) && d->GetP2PPort() == wPort) + if (!strcmp(d->GetHostName(), szHost) && d->GetP2PPort() == wPort) return true; } diff --git a/game/src/desc_manager.h b/game/src/desc_manager.h index 7048c71..bcb9ca8 100644 --- a/game/src/desc_manager.h +++ b/game/src/desc_manager.h @@ -7,6 +7,10 @@ #include #include "IFileMonitor.h" +#include +#include +#include + class CLoginKey; class CClientPackageCryptInfo; @@ -28,13 +32,13 @@ class DESC_MANAGER : public singleton void Initialize(); void Destroy(); - LPDESC AcceptDesc(LPFDWATCH fdw, socket_t s); - LPDESC AcceptP2PDesc(LPFDWATCH fdw, socket_t s); + LPDESC AcceptDesc(evconnlistener* listener, evutil_socket_t fd, sockaddr* address); + LPDESC AcceptP2PDesc(evconnlistener* listener, evutil_socket_t fd, sockaddr* address); void DestroyDesc(LPDESC d, bool erase_from_set = true); DWORD CreateHandshake(); - LPCLIENT_DESC CreateConnectionDesc(LPFDWATCH fdw, const char * host, WORD port, int iPhaseWhenSucceed, bool bRetryWhenClosed); + LPCLIENT_DESC CreateConnectionDesc(event_base * base, evdns_base * dns_base, const char * host, WORD port, int iPhaseWhenSucceed, bool bRetryWhenClosed); void TryConnect(); LPDESC FindByHandle(DWORD handle); diff --git a/game/src/desc_p2p.cpp b/game/src/desc_p2p.cpp index 74f0326..8c0a815 100644 --- a/game/src/desc_p2p.cpp +++ b/game/src/desc_p2p.cpp @@ -9,43 +9,41 @@ DESC_P2P::~DESC_P2P() void DESC_P2P::Destroy() { - if (m_sock == INVALID_SOCKET) { + if (m_bufevent == nullptr) return; - } P2P_MANAGER::instance().UnregisterAcceptor(this); - fdwatch_del_fd(m_lpFdw, m_sock); + sys_log(0, "SYSTEM: closing p2p socket."); - sys_log(0, "SYSTEM: closing p2p socket. DESC #%d", m_sock); - - socket_close(m_sock); - m_sock = INVALID_SOCKET; + bufferevent_free(m_bufevent); + m_bufevent = nullptr; // Chain up to base class Destroy() DESC::Destroy(); } -bool DESC_P2P::Setup(LPFDWATCH fdw, socket_t fd, const char * host, WORD wPort) +bool DESC_P2P::Setup(event_base * evbase, evutil_socket_t fd, const sockaddr * c_rSockAddr) { - m_lpFdw = fdw; - m_stHost = host; - m_wPort = wPort; - m_sock = fd; + m_bufevent = bufferevent_socket_new(evbase, fd, BEV_OPT_CLOSE_ON_FREE); + if (m_bufevent == nullptr) { + sys_err("DESC::Setup : Could not set up bufferevent!"); + return false; + } - if (!(m_lpOutputBuffer = buffer_new(1024 * 1024))) - return false; + // Set the event handlers for this peer + bufferevent_setcb(m_bufevent, DescReadHandler, DescWriteHandler, DescEventHandler, (LPDESC) this); - if (!(m_lpInputBuffer = buffer_new(1024 * 1024))) - return false; + // Enable the events + bufferevent_enable(m_bufevent, EV_READ|EV_WRITE); - fdwatch_add_fd(m_lpFdw, m_sock, this, FDW_READ, false); - - m_iMinInputBufferLen = 1024 * 1024; + m_stHost = GetSocketHost(c_rSockAddr); + m_wPort = GetSocketPort(c_rSockAddr); SetPhase(PHASE_P2P); - sys_log(0, "SYSTEM: new p2p connection from [%s] fd: %d", host, m_sock); + sys_log(0, "SYSTEM: new p2p connection from [%s]", m_stHost.c_str()); + return true; } @@ -57,13 +55,6 @@ void DESC_P2P::SetPhase(int iPhase) { case PHASE_P2P: sys_log(1, "PHASE_P2P"); - - if (m_lpInputBuffer) - buffer_reset(m_lpInputBuffer); - - if (m_lpOutputBuffer) - buffer_reset(m_lpOutputBuffer); - m_pInputProcessor = &s_inputP2P; break; diff --git a/game/src/desc_p2p.h b/game/src/desc_p2p.h index 6db35bc..31cb38c 100644 --- a/game/src/desc_p2p.h +++ b/game/src/desc_p2p.h @@ -7,6 +7,6 @@ class DESC_P2P : public DESC virtual void Destroy(); virtual void SetPhase(int iPhase); - bool Setup(LPFDWATCH _fdw, socket_t fd, const char * host, WORD wPort); + bool Setup(event_base * evbase, evutil_socket_t fd, const sockaddr * c_rSockAddr); }; diff --git a/game/src/dungeon.cpp b/game/src/dungeon.cpp index 1280e37..4478c7f 100644 --- a/game/src/dungeon.cpp +++ b/game/src/dungeon.cpp @@ -14,7 +14,7 @@ #include "utils.h" #include "questmanager.h" -CDungeon::CDungeon(IdType id, long lOriginalMapIndex, long lMapIndex) +CDungeon::CDungeon(IdType id, int lOriginalMapIndex, int lMapIndex) : m_id(id), m_lOrigMapIndex(lOriginalMapIndex), m_lMapIndex(lMapIndex), @@ -86,7 +86,7 @@ int CDungeon::GetFlag(std::string name) struct FSendDestPosition { - FSendDestPosition(long x, long y) + FSendDestPosition(int x, int y) { p1.bHeader = HEADER_GC_DUNGEON; p1.subheader = DUNGEON_SUBHEADER_GC_DESTINATION_POSITION; @@ -97,7 +97,7 @@ struct FSendDestPosition void operator()(LPCHARACTER ch) { - ch->GetDesc()->BufferedPacket(&p1, sizeof(TPacketGCDungeon)); + ch->GetDesc()->RawPacket(&p1, sizeof(TPacketGCDungeon)); ch->GetDesc()->Packet(&p2, sizeof(TPacketGCDungeonDestPosition)); } @@ -105,7 +105,7 @@ struct FSendDestPosition TPacketGCDungeonDestPosition p2; }; -void CDungeon::SendDestPositionToParty(LPPARTY pParty, long x, long y) +void CDungeon::SendDestPositionToParty(LPPARTY pParty, int x, int y) { if (m_map_pkParty.find(pParty) == m_map_pkParty.end()) { @@ -119,7 +119,7 @@ void CDungeon::SendDestPositionToParty(LPPARTY pParty, long x, long y) struct FWarpToDungeon { - FWarpToDungeon(long lMapIndex, LPDUNGEON d) + FWarpToDungeon(int lMapIndex, LPDUNGEON d) : m_lMapIndex(lMapIndex), m_pkDungeon(d) { LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(lMapIndex); @@ -134,9 +134,9 @@ struct FWarpToDungeon //m_pkDungeon->IncPartyMember(ch->GetParty()); } - long m_lMapIndex; - long m_x; - long m_y; + int m_lMapIndex; + int m_x; + int m_y; LPDUNGEON m_pkDungeon; }; @@ -265,10 +265,10 @@ void CDungeon::DecPartyMember(LPPARTY pParty, LPCHARACTER ch) struct FWarpToPosition { - long lMapIndex; - long x; - long y; - FWarpToPosition(long lMapIndex, long x, long y) + int lMapIndex; + int x; + int y; + FWarpToPosition(int lMapIndex, int x, int y) : lMapIndex(lMapIndex), x(x), y(y) {} @@ -295,10 +295,10 @@ struct FWarpToPosition struct FWarpToPositionForce { - long lMapIndex; - long x; - long y; - FWarpToPositionForce(long lMapIndex, long x, long y) + int lMapIndex; + int x; + int y; + FWarpToPositionForce(int lMapIndex, int x, int y) : lMapIndex(lMapIndex), x(x), y(y) {} @@ -315,7 +315,7 @@ struct FWarpToPositionForce } }; -void CDungeon::JumpAll(long lFromMapIndex, int x, int y) +void CDungeon::JumpAll(int lFromMapIndex, int x, int y) { x *= 100; y *= 100; @@ -334,7 +334,7 @@ void CDungeon::JumpAll(long lFromMapIndex, int x, int y) pMap->for_each(f); } -void CDungeon::WarpAll(long lFromMapIndex, int x, int y) +void CDungeon::WarpAll(int lFromMapIndex, int x, int y) { x *= 100; y *= 100; @@ -353,7 +353,7 @@ void CDungeon::WarpAll(long lFromMapIndex, int x, int y) pMap->for_each(f); } -void CDungeon::JumpParty(LPPARTY pParty, long lFromMapIndex, int x, int y) +void CDungeon::JumpParty(LPPARTY pParty, int lFromMapIndex, int x, int y) { x *= 100; y *= 100; @@ -400,7 +400,7 @@ void CDungeonManager::Destroy(CDungeon::IdType dungeon_id) } m_map_pkDungeon.erase(dungeon_id); - long lMapIndex = pDungeon->m_lMapIndex; + int lMapIndex = pDungeon->m_lMapIndex; m_map_pkMapDungeon.erase(lMapIndex); DWORD server_timer_arg = lMapIndex; @@ -418,7 +418,7 @@ LPDUNGEON CDungeonManager::Find(CDungeon::IdType dungeon_id) return NULL; } -LPDUNGEON CDungeonManager::FindByMapIndex(long lMapIndex) +LPDUNGEON CDungeonManager::FindByMapIndex(int lMapIndex) { itertype(m_map_pkMapDungeon) it = m_map_pkMapDungeon.find(lMapIndex); if (it != m_map_pkMapDungeon.end()) { @@ -427,7 +427,7 @@ LPDUNGEON CDungeonManager::FindByMapIndex(long lMapIndex) return NULL; } -LPDUNGEON CDungeonManager::Create(long lOriginalMapIndex) +LPDUNGEON CDungeonManager::Create(int lOriginalMapIndex) { DWORD lMapIndex = SECTREE_MANAGER::instance().CreatePrivateMap(lOriginalMapIndex); @@ -779,7 +779,7 @@ void CDungeon::SpawnNameMob(DWORD vnum, int x, int y, const char* name) } } -void CDungeon::SpawnGotoMob(long lFromX, long lFromY, long lToX, long lToY) +void CDungeon::SpawnGotoMob(int lFromX, int lFromY, int lToX, int lToY) { const int MOB_GOTO_VNUM = 20039; @@ -799,14 +799,14 @@ void CDungeon::SpawnGotoMob(long lFromX, long lFromY, long lToX, long lToY) if (ch) { char buf[30+1]; - snprintf(buf, sizeof(buf), ". %ld %ld", lToX, lToY); + snprintf(buf, sizeof(buf), ". %d %d", lToX, lToY); ch->SetName(buf); ch->SetDungeon(this); } } -LPCHARACTER CDungeon::SpawnGroup(DWORD vnum, long x, long y, float radius, bool bAggressive, int count) +LPCHARACTER CDungeon::SpawnGroup(DWORD vnum, int x, int y, float radius, bool bAggressive, int count) { LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(m_lMapIndex); if (pkSectreeMap == NULL) { @@ -1241,14 +1241,14 @@ void CDungeon::CheckEliminated() sys_log(0, "CheckEliminated: none"); } -void CDungeon::SetExitAllAtEliminate(long time) +void CDungeon::SetExitAllAtEliminate(int time) { sys_log(0, "SetExitAllAtEliminate: time %d", time); m_bExitAllAtEliminate = true; m_iWarpDelay = time; } -void CDungeon::SetWarpAtEliminate(long time, long lMapIndex, int x, int y, const char* regen_file) +void CDungeon::SetWarpAtEliminate(int time, int lMapIndex, int x, int y, const char* regen_file) { m_bWarpAtEliminate = true; m_iWarpDelay = time; @@ -1298,12 +1298,12 @@ void CDungeon::JumpToEliminateLocation() struct FNearPosition { - long x; - long y; + int x; + int y; int dist; bool ret; - FNearPosition(long x, long y, int d) : + FNearPosition(int x, int y, int d) : x(x), y(y), dist(d), ret(true) { } diff --git a/game/src/dungeon.h b/game/src/dungeon.h index cf9dbbc..1be70ce 100644 --- a/game/src/dungeon.h +++ b/game/src/dungeon.h @@ -52,15 +52,15 @@ class CDungeon void UsePotion(LPCHARACTER ch); void UseRevive(LPCHARACTER ch); - long GetMapIndex() { return m_lMapIndex; } + int GetMapIndex() { return m_lMapIndex; } void Spawn(DWORD vnum, const char* pos); LPCHARACTER SpawnMob(DWORD vnum, int x, int y, int dir = 0); LPCHARACTER SpawnMob_ac_dir(DWORD vnum, int x, int y, int dir = 0); - LPCHARACTER SpawnGroup(DWORD vnum, long x, long y, float radius, bool bAggressive=false, int count=1); + LPCHARACTER SpawnGroup(DWORD vnum, int x, int y, float radius, bool bAggressive=false, int count=1); void SpawnNameMob(DWORD vnum, int x, int y, const char* name); - void SpawnGotoMob(long lFromX, long lFromY, long lToX, long lToY); + void SpawnGotoMob(int lFromX, int lFromY, int lToX, int lToY); void SpawnRegen(const char* filename, bool bOnce = true); void AddRegen(LPREGEN regen); @@ -85,23 +85,23 @@ class CDungeon void UniqueSetHP(const std::string& key, int iHP); void UniqueSetDefGrade(const std::string& key, int iGrade); - void SendDestPositionToParty(LPPARTY pParty, long x, long y); + void SendDestPositionToParty(LPPARTY pParty, int x, int y); void CheckEliminated(); - void JumpAll(long lFromMapIndex, int x, int y); - void WarpAll(long lFromMapIndex, int x, int y); - void JumpParty(LPPARTY pParty, long lFromMapIndex, int x, int y); + void JumpAll(int lFromMapIndex, int x, int y); + void WarpAll(int lFromMapIndex, int x, int y); + void JumpParty(LPPARTY pParty, int lFromMapIndex, int x, int y); void ExitAll(); void ExitAllToStartPosition(); void JumpToEliminateLocation(); - void SetExitAllAtEliminate(long time); - void SetWarpAtEliminate(long time, long lMapIndex, int x, int y, const char* regen_file); + void SetExitAllAtEliminate(int time); + void SetWarpAtEliminate(int time, int lMapIndex, int x, int y, const char* regen_file); int GetFlag(std::string name); void SetFlag(std::string name, int value); - void SetWarpLocation (long map_index, int x, int y); + void SetWarpLocation (int map_index, int x, int y); // item groupÀº item_vnum°ú item_count·Î ±¸¼º. typedef std::vector > ItemGroup; @@ -114,7 +114,7 @@ class CDungeon bool IsAllPCNearTo( int x, int y, int dist ); protected: - CDungeon(IdType id, long lOriginalMapIndex, long lMapIndex); + CDungeon(IdType id, int lOriginalMapIndex, int lMapIndex); void Initialize(); void CheckDestroy(); @@ -144,9 +144,9 @@ class CDungeon // Àû Àü¸ê½Ã ¿öÇÁÇÏ´Â À§Ä¡ int m_iWarpDelay; - long m_lWarpMapIndex; - long m_lWarpX; - long m_lWarpY; + int m_lWarpMapIndex; + int m_lWarpX; + int m_lWarpY; std::string m_stRegenFile; std::vector m_regen; @@ -175,16 +175,16 @@ class CDungeon class CDungeonManager : public singleton { typedef std::map TDungeonMap; - typedef std::map TMapDungeon; + typedef std::map TMapDungeon; public: CDungeonManager(); virtual ~CDungeonManager(); - LPDUNGEON Create(long lOriginalMapIndex); + LPDUNGEON Create(int lOriginalMapIndex); void Destroy(CDungeon::IdType dungeon_id); LPDUNGEON Find(CDungeon::IdType dungeon_id); - LPDUNGEON FindByMapIndex(long lMapIndex); + LPDUNGEON FindByMapIndex(int lMapIndex); private: TDungeonMap m_map_pkDungeon; diff --git a/game/src/entity.h b/game/src/entity.h index 93f8b89..a314f1e 100644 --- a/game/src/entity.h +++ b/game/src/entity.h @@ -32,12 +32,12 @@ class CEntity int GetViewAge() const { return m_iViewAge; } - long GetX() const { return m_pos.x; } - long GetY() const { return m_pos.y; } - long GetZ() const { return m_pos.z; } + int GetX() const { return m_pos.x; } + int GetY() const { return m_pos.y; } + int GetZ() const { return m_pos.z; } const PIXEL_POSITION & GetXYZ() const { return m_pos; } - void SetXYZ(long x, long y, long z) { m_pos.x = x, m_pos.y = y, m_pos.z = z; } + void SetXYZ(int x, int y, int z) { m_pos.x = x, m_pos.y = y, m_pos.z = z; } void SetXYZ(const PIXEL_POSITION & pos) { m_pos = pos; } LPSECTREE GetSectree() const { return m_pSectree; } @@ -50,8 +50,8 @@ class CEntity void BindDesc(LPDESC _d) { m_lpDesc = _d; } LPDESC GetDesc() const { return m_lpDesc; } - void SetMapIndex(long l) { m_lMapIndex = l; } - long GetMapIndex() const { return m_lMapIndex; } + void SetMapIndex(int l) { m_lMapIndex = l; } + int GetMapIndex() const { return m_lMapIndex; } void SetObserverMode(bool bFlag); bool IsObserverMode() const { return m_bIsObserver; } @@ -60,7 +60,7 @@ class CEntity bool m_bIsObserver; bool m_bObserverModeChange; ENTITY_MAP m_map_view; - long m_lMapIndex; + int m_lMapIndex; private: LPDESC m_lpDesc; diff --git a/game/src/event.cpp b/game/src/event.cpp index acf60ed..a1e6d1a 100644 --- a/game/src/event.cpp +++ b/game/src/event.cpp @@ -19,7 +19,7 @@ static ObjectPool event_pool; static CEventQueue cxx_q; /* À̺¥Æ®¸¦ »ý¼ºÇÏ°í ¸®ÅÏÇÑ´Ù */ -LPEVENT event_create_ex(TEVENTFUNC func, event_info_data* info, long when) +LPEVENT event_create_ex(TEVENTFUNC func, event_info_data* info, int when) { LPEVENT new_event = NULL; @@ -87,7 +87,7 @@ void event_cancel(LPEVENT * ppevent) *ppevent = NULL; } -void event_reset_time(LPEVENT event, long when) +void event_reset_time(LPEVENT event, int when) { if (!event->is_processing) { @@ -101,7 +101,7 @@ void event_reset_time(LPEVENT event, long when) /* À̺¥Æ®¸¦ ½ÇÇàÇÒ ½Ã°£¿¡ µµ´ÞÇÑ À̺¥Æ®µéÀ» ½ÇÇàÇÑ´Ù */ int event_process(int pulse) { - long new_time; + int new_time; int num_events = 0; // event_q Áï À̺¥Æ® Å¥ÀÇ ÇìµåÀÇ ½Ã°£º¸´Ù ÇöÀçÀÇ pulse °¡ ÀûÀ¸¸é ·çÇÁ¹®ÀÌ @@ -119,7 +119,7 @@ int event_process(int pulse) new_time = pElem->iKey; LPEVENT the_event = pElem->pvData; - long processing_time = event_processing_time(the_event); + int processing_time = event_processing_time(the_event); cxx_q.Delete(pElem); /* @@ -157,9 +157,9 @@ int event_process(int pulse) } /* À̺¥Æ®°¡ ¼öÇà½Ã°£À» pulse ´ÜÀ§·Î ¸®ÅÏÇØ ÁØ´Ù */ -long event_processing_time(LPEVENT event) +int event_processing_time(LPEVENT event) { - long start_time; + int start_time; if (!event->q_el) return 0; @@ -169,9 +169,9 @@ long event_processing_time(LPEVENT event) } /* À̺¥Æ®°¡ ³²Àº ½Ã°£À» pulse ´ÜÀ§·Î ¸®ÅÏÇØ ÁØ´Ù */ -long event_time(LPEVENT event) +int event_time(LPEVENT event) { - long when; + int when; if (!event->q_el) return 0; diff --git a/game/src/event.h b/game/src/event.h index 8a9fccd..ee1abcf 100644 --- a/game/src/event.h +++ b/game/src/event.h @@ -35,9 +35,9 @@ private: typedef struct event EVENT; typedef boost::intrusive_ptr LPEVENT; -typedef long (*TEVENTFUNC) (LPEVENT event, long processing_time); +typedef int (*TEVENTFUNC) (LPEVENT event, int processing_time); -#define EVENTFUNC(name) long (name) (LPEVENT event, long processing_time) +#define EVENTFUNC(name) int (name) (LPEVENT event, int processing_time) #define EVENTINFO(name) struct name : public event_info_data struct TQueueElement; @@ -80,11 +80,11 @@ extern int event_process(int pulse); extern int event_count(); #define event_create(func, info, when) event_create_ex(func, info, when) -extern LPEVENT event_create_ex(TEVENTFUNC func, event_info_data* info, long when); +extern LPEVENT event_create_ex(TEVENTFUNC func, event_info_data* info, int when); extern void event_cancel(LPEVENT * event); // À̺¥Æ® Ãë¼Ò -extern long event_processing_time(LPEVENT event); // ¼öÇà ½Ã°£ ¸®ÅÏ -extern long event_time(LPEVENT event); // ³²Àº ½Ã°£ ¸®ÅÏ -extern void event_reset_time(LPEVENT event, long when); // ½ÇÇà ½Ã°£ Àç ¼³Á¤ +extern int event_processing_time(LPEVENT event); // ¼öÇà ½Ã°£ ¸®ÅÏ +extern int event_time(LPEVENT event); // ³²Àº ½Ã°£ ¸®ÅÏ +extern void event_reset_time(LPEVENT event, int when); // ½ÇÇà ½Ã°£ Àç ¼³Á¤ extern void event_set_verbose(int level); extern event_info_data* FindEventInfo(DWORD dwID); diff --git a/game/src/exchange.cpp b/game/src/exchange.cpp index 42a6501..0d6ec06 100644 --- a/game/src/exchange.cpp +++ b/game/src/exchange.cpp @@ -241,7 +241,7 @@ bool CExchange::RemoveItem(BYTE pos) return true; } -bool CExchange::AddGold(long gold) +bool CExchange::AddGold(int gold) { if (gold <= 0) return false; @@ -546,7 +546,7 @@ bool CExchange::Accept(bool bAccept) goto EXCHANGE_END; } - if (db_clientdesc->GetSocket() == INVALID_SOCKET) + if (!db_clientdesc->IsPhase(PHASE_DBCLIENT)) { sys_err("Cannot use exchange feature while DB cache connection is dead."); victim->ChatPacket(CHAT_TYPE_INFO, "Unknown error"); diff --git a/game/src/exchange.h b/game/src/exchange.h index d30e97a..9f6e02b 100644 --- a/game/src/exchange.h +++ b/game/src/exchange.h @@ -18,7 +18,7 @@ class CExchange bool Accept(bool bIsAccept = true); void Cancel(); - bool AddGold(long lGold); + bool AddGold(int lGold); bool AddItem(TItemPos item_pos, BYTE display_pos); bool RemoveItem(BYTE pos); @@ -44,7 +44,7 @@ class CExchange BYTE m_abItemDisplayPos[EXCHANGE_ITEM_MAX_NUM]; bool m_bAccept; - long m_lGold; + int m_lGold; CGrid * m_pGrid; diff --git a/game/src/fishing.cpp b/game/src/fishing.cpp index 73af830..1bc3ac4 100644 --- a/game/src/fishing.cpp +++ b/game/src/fishing.cpp @@ -602,7 +602,7 @@ void Take(fishing_event_info* info, LPCHARACTER ch) { if (info->step == 1) // °í±â°¡ °É¸° »óŸé.. { - long ms = (long) ((get_dword_time() - info->hang_time)); + int ms = (int) ((get_dword_time() - info->hang_time)); DWORD item_vnum = 0; int ret = Compute(info->fish_id, ms, &item_vnum, GetFishingLevel(ch)); diff --git a/game/src/guild.cpp b/game/src/guild.cpp index 29332ee..2485499 100644 --- a/game/src/guild.cpp +++ b/game/src/guild.cpp @@ -41,8 +41,8 @@ namespace if (d) { - d->BufferedPacket(&p, sizeof(p)); - d->BufferedPacket(&id, sizeof(id)); + d->RawPacket(&p, sizeof(p)); + d->RawPacket(&id, sizeof(id)); d->Packet(name, GUILD_NAME_MAX_LEN); } } @@ -903,7 +903,7 @@ void CGuild::SendGuildInfoPacket(LPCHARACTER ch) sys_log(0, "GMC guild_name %s", m_data.name); sys_log(0, "GMC master %d", m_data.master_pid); - d->BufferedPacket(&pack, sizeof(TPacketGCGuild)); + d->RawPacket(&pack, sizeof(TPacketGCGuild)); d->Packet(&pack_sub, sizeof(TPacketGCGuildInfo)); } @@ -953,7 +953,7 @@ bool CGuild::OfferExp(LPCHARACTER ch, int amount) { pack.subheader = GUILD_SUBHEADER_GC_LIST; pack.size = sizeof(pack) + 13; - d->BufferedPacket(&pack, sizeof(pack)); + d->RawPacket(&pack, sizeof(pack)); d->Packet(&(cit->second), sizeof(DWORD) * 3 + 1); } } @@ -1067,8 +1067,8 @@ void CGuild::RefreshCommentForce(DWORD player_id) return; pack.size += (sizeof(DWORD)+CHARACTER_NAME_MAX_LEN+1+GUILD_COMMENT_MAX_LEN+1)*(WORD)count; - d->BufferedPacket(&pack,sizeof(pack)); - d->BufferedPacket(&count, 1); + d->RawPacket(&pack, sizeof(pack)); + d->RawPacket(&count, 1); char szName[CHARACTER_NAME_MAX_LEN + 1]; char szContent[GUILD_COMMENT_MAX_LEN + 1]; memset(szName, 0, sizeof(szName)); @@ -1082,13 +1082,13 @@ void CGuild::RefreshCommentForce(DWORD player_id) strncpy(szName, row[1], sizeof(szName)); strncpy(szContent, row[2], sizeof(szContent)); - d->BufferedPacket(&id, sizeof(id)); - d->BufferedPacket(szName, sizeof(szName)); + d->RawPacket(&id, sizeof(id)); + d->RawPacket(szName, sizeof(szName)); if (i == pmsg->Get()->uiNumRows - 1) d->Packet(szContent, sizeof(szContent)); // ¸¶Áö¸· ÁÙÀÌ¸é º¸³»±â else - d->BufferedPacket(szContent, sizeof(szContent)); + d->RawPacket(szContent, sizeof(szContent)); } } @@ -1129,8 +1129,8 @@ bool CGuild::ChangeMemberGeneral(DWORD pid, BYTE is_general) if (!d) continue; - d->BufferedPacket(&pack, sizeof(pack)); - d->BufferedPacket(&pid, sizeof(pid)); + d->RawPacket(&pack, sizeof(pack)); + d->RawPacket(&pid, sizeof(pid)); d->Packet(&is_general, sizeof(is_general)); } @@ -1164,8 +1164,8 @@ void CGuild::ChangeMemberGrade(DWORD pid, BYTE grade) if (!d) continue; - d->BufferedPacket(&pack, sizeof(pack)); - d->BufferedPacket(&pid, sizeof(pid)); + d->RawPacket(&pack, sizeof(pack)); + d->RawPacket(&pid, sizeof(pid)); d->Packet(&grade, sizeof(grade)); } @@ -1400,10 +1400,10 @@ void CGuild::SendSkillInfoPacket(LPCHARACTER ch) const pack.size = sizeof(pack) + 6 + GUILD_SKILL_COUNT; pack.subheader = GUILD_SUBHEADER_GC_SKILL_INFO; - d->BufferedPacket(&pack, sizeof(pack)); - d->BufferedPacket(&m_data.skill_point, 1); - d->BufferedPacket(&m_data.abySkill, GUILD_SKILL_COUNT); - d->BufferedPacket(&m_data.power, 2); + d->RawPacket(&pack, sizeof(pack)); + d->RawPacket(&m_data.skill_point, 1); + d->RawPacket(&m_data.abySkill, GUILD_SKILL_COUNT); + d->RawPacket(&m_data.power, 2); d->Packet(&m_data.max_power, 2); } @@ -1612,7 +1612,7 @@ void CGuild::LevelChange(DWORD pid, BYTE level) { pack.subheader = GUILD_SUBHEADER_GC_LIST; pack.size = sizeof(pack) + 13; - d->BufferedPacket(&pack, sizeof(pack)); + d->RawPacket(&pack, sizeof(pack)); d->Packet(&(cit->second), sizeof(DWORD) * 3 + 1); } } @@ -1641,7 +1641,7 @@ void CGuild::ChangeMemberData(DWORD pid, DWORD offer, BYTE level, BYTE grade) { pack.subheader = GUILD_SUBHEADER_GC_LIST; pack.size = sizeof(pack) + 13; - d->BufferedPacket(&pack, sizeof(pack)); + d->RawPacket(&pack, sizeof(pack)); d->Packet(&(cit->second), sizeof(DWORD) * 3 + 1); } } @@ -1871,7 +1871,7 @@ void CGuild::RecvMoneyChange(int iGold) { LPCHARACTER ch = *it; LPDESC d = ch->GetDesc(); - d->BufferedPacket(&p, sizeof(p)); + d->RawPacket(&p, sizeof(p)); d->Packet(&iGold, sizeof(int)); } } diff --git a/game/src/guild.h b/game/src/guild.h index c6a5300..b9e0aa9 100644 --- a/game/src/guild.h +++ b/game/src/guild.h @@ -281,7 +281,7 @@ class CGuild DWORD UnderAnyWar(BYTE bType = GUILD_WAR_TYPE_MAX_NUM); // War map relative - void SetGuildWarMapIndex(DWORD dwGuildID, long lMapIndex); + void SetGuildWarMapIndex(DWORD dwGuildID, int lMapIndex); int GetGuildWarType(DWORD dwGuildOpponent); DWORD GetGuildWarMapIndex(DWORD dwGuildOpponent); diff --git a/game/src/guild_manager.cpp b/game/src/guild_manager.cpp index 0b86a0f..3002844 100644 --- a/game/src/guild_manager.cpp +++ b/game/src/guild_manager.cpp @@ -34,8 +34,8 @@ namespace if (d) { - d->BufferedPacket(&p, sizeof(p)); - d->BufferedPacket(&id, sizeof(id)); + d->RawPacket(&p, sizeof(p)); + d->RawPacket(&id, sizeof(id)); d->Packet(name, GUILD_NAME_MAX_LEN); } } @@ -489,7 +489,7 @@ void CGuildManager::RequestEndWar(DWORD guild_id1, DWORD guild_id2) db_clientdesc->DBPacket(HEADER_GD_GUILD_WAR, 0, &p, sizeof(p)); } -void CGuildManager::RequestWarOver(DWORD dwGuild1, DWORD dwGuild2, DWORD dwGuildWinner, long lReward) +void CGuildManager::RequestWarOver(DWORD dwGuild1, DWORD dwGuild2, DWORD dwGuildWinner, int lReward) { CGuild * g1 = TouchGuild(dwGuild1); CGuild * g2 = TouchGuild(dwGuild2); @@ -602,8 +602,8 @@ struct FSendWarList if (d) { - d->BufferedPacket(&p, sizeof(p)); - d->BufferedPacket(&gid1, sizeof(DWORD)); + d->RawPacket(&p, sizeof(p)); + d->RawPacket(&gid1, sizeof(DWORD)); d->Packet(&gid2, sizeof(DWORD)); } } diff --git a/game/src/guild_manager.h b/game/src/guild_manager.h index a9c37d9..c5f7444 100644 --- a/game/src/guild_manager.h +++ b/game/src/guild_manager.h @@ -43,7 +43,7 @@ class CGuildManager : public singleton void RequestEndWar(DWORD guild_id1, DWORD guild_id2); void RequestCancelWar(DWORD guild_id1, DWORD guild_id2); - void RequestWarOver(DWORD dwGuild1, DWORD dwGuild2, DWORD dwGuildWinner, long lReward); + void RequestWarOver(DWORD dwGuild1, DWORD dwGuild2, DWORD dwGuildWinner, int lReward); void DeclareWar(DWORD guild_id1, DWORD guild_id2, BYTE bType); void RefuseWar(DWORD guild_id1, DWORD guild_id2); diff --git a/game/src/guild_war.cpp b/game/src/guild_war.cpp index 36953f3..d358b20 100644 --- a/game/src/guild_war.cpp +++ b/game/src/guild_war.cpp @@ -51,7 +51,7 @@ void CGuild::GuildWarPacket(DWORD dwOppGID, BYTE bWarType, BYTE bWarState) { ch->SendGuildName( dwOppGID ); - d->BufferedPacket(&pack, sizeof(pack)); + d->RawPacket(&pack, sizeof(pack)); d->Packet(&pack2, sizeof(pack2)); } } @@ -74,7 +74,7 @@ void CGuild::SendEnemyGuild(LPCHARACTER ch) TPacketGCGuild p; p.header = HEADER_GC_GUILD; p.subheader = GUILD_SUBHEADER_GC_WAR_SCORE; - p.size = sizeof(p) + sizeof(DWORD) + sizeof(DWORD) + sizeof(long); + p.size = sizeof(p) + sizeof(DWORD) + sizeof(DWORD) + sizeof(int); for (itertype(m_EnemyGuild) it = m_EnemyGuild.begin(); it != m_EnemyGuild.end(); ++it) { @@ -84,26 +84,26 @@ void CGuild::SendEnemyGuild(LPCHARACTER ch) pack2.bType = it->second.type; pack2.bWarState = it->second.state; - d->BufferedPacket(&pack, sizeof(pack)); + d->RawPacket(&pack, sizeof(pack)); d->Packet(&pack2, sizeof(pack2)); if (it->second.state == GUILD_WAR_ON_WAR) { - long lScore; + int lScore; lScore = GetWarScoreAgainstTo(pack2.dwGuildOpp); - d->BufferedPacket(&p, sizeof(p)); - d->BufferedPacket(&pack2.dwGuildSelf, sizeof(DWORD)); - d->BufferedPacket(&pack2.dwGuildOpp, sizeof(DWORD)); - d->Packet(&lScore, sizeof(long)); + d->RawPacket(&p, sizeof(p)); + d->RawPacket(&pack2.dwGuildSelf, sizeof(DWORD)); + d->RawPacket(&pack2.dwGuildOpp, sizeof(DWORD)); + d->Packet(&lScore, sizeof(int)); lScore = CGuildManager::instance().TouchGuild(pack2.dwGuildOpp)->GetWarScoreAgainstTo(pack2.dwGuildSelf); - d->BufferedPacket(&p, sizeof(p)); - d->BufferedPacket(&pack2.dwGuildOpp, sizeof(DWORD)); - d->BufferedPacket(&pack2.dwGuildSelf, sizeof(DWORD)); - d->Packet(&lScore, sizeof(long)); + d->RawPacket(&p, sizeof(p)); + d->RawPacket(&pack2.dwGuildOpp, sizeof(DWORD)); + d->RawPacket(&pack2.dwGuildSelf, sizeof(DWORD)); + d->Packet(&lScore, sizeof(int)); } } } @@ -201,14 +201,14 @@ void CGuild::SetWarScoreAgainstTo(DWORD dwOppGID, int iScore) p.header = HEADER_GC_GUILD; p.subheader = GUILD_SUBHEADER_GC_WAR_SCORE; - p.size = sizeof(p) + sizeof(DWORD) + sizeof(DWORD) + sizeof(long); + p.size = sizeof(p) + sizeof(DWORD) + sizeof(DWORD) + sizeof(int); TEMP_BUFFER buf; buf.write(&p, sizeof(p)); buf.write(&dwSelfGID, sizeof(DWORD)); buf.write(&dwOppGID, sizeof(DWORD)); - buf.write(&iScore, sizeof(long)); + buf.write(&iScore, sizeof(int)); Packet(buf.read_peek(), buf.size()); @@ -626,7 +626,7 @@ void CGuild::EndWar(DWORD dwOppGID) } } -void CGuild::SetGuildWarMapIndex(DWORD dwOppGID, long lMapIndex) +void CGuild::SetGuildWarMapIndex(DWORD dwOppGID, int lMapIndex) { itertype(m_EnemyGuild) it = m_EnemyGuild.find(dwOppGID); diff --git a/game/src/input.cpp b/game/src/input.cpp index 1b2ea1a..7ad3c85 100644 --- a/game/src/input.cpp +++ b/game/src/input.cpp @@ -19,7 +19,6 @@ #include "dev_log.h" extern time_t get_global_time(); -extern bool g_bNoPasspod; bool IsEmptyAdminPage() { @@ -78,8 +77,8 @@ bool CInputProcessor::Process(LPDESC lpDesc, const void * c_pvOrig, int iBytes, iPacketLen = 1; else if (!m_pPacketInfo->Get(bHeader, &iPacketLen, &c_pszName)) { - sys_err("UNKNOWN HEADER: %d, LAST HEADER: %d(%d), REMAIN BYTES: %d, fd: %d", - bHeader, bLastHeader, iLastPacketLen, m_iBufferLeft, lpDesc->GetSocket()); + sys_err("UNKNOWN HEADER: %d, LAST HEADER: %d(%d), REMAIN BYTES: %d", + bHeader, bLastHeader, iLastPacketLen, m_iBufferLeft); //printdata((BYTE *) c_pvOrig, m_iBufferLeft); lpDesc->SetPhase(PHASE_CLOSE); return true; @@ -183,7 +182,7 @@ void CInputProcessor::Handshake(LPDESC d, const char * c_pData) if (d->GetHandshake() != p->dwHandshake) { - sys_err("Invalid Handshake on %d", d->GetSocket()); + sys_err("Invalid Handshake"); d->SetPhase(PHASE_CLOSE); } else @@ -192,14 +191,10 @@ void CInputProcessor::Handshake(LPDESC d, const char * c_pData) { if (d->HandshakeProcess(p->dwTime, p->lDelta, false)) { -#ifdef _IMPROVED_PACKET_ENCRYPTION_ - d->SendKeyAgreement(); -#else if (g_bAuthServer) d->SetPhase(PHASE_AUTH); else d->SetPhase(PHASE_LOGIN); -#endif // #ifdef _IMPROVED_PACKET_ENCRYPTION_ } } else @@ -212,7 +207,7 @@ void CInputProcessor::Version(LPCHARACTER ch, const char* c_pData) if (!ch) return; - TPacketCGClientVersion * p = (TPacketCGClientVersion *) c_pData; + TPacketCGClientVersion * p = (TPacketCGClientVersion *) c_pData; sys_log(0, "VERSION: %s %s %s", ch->GetName(), p->timestamp, p->filename); ch->GetDesc()->SetClientVersion(p->timestamp); } @@ -286,22 +281,15 @@ int CInputHandshake::Analyze(LPDESC d, BYTE bHeader, const char * c_pData) else stResult = "YES"; } - else if (!stBuf.compare("IS_PASSPOD_UP")) - { - if (g_bNoPasspod) - stResult = "NO"; - else - stResult = "YES"; - } //else if (!stBuf.compare("SHOWMETHEMONEY")) else if (stBuf == g_stAdminPagePassword) { if (!IsEmptyAdminPage()) { - if (!IsAdminPage(inet_ntoa(d->GetAddr().sin_addr))) + if (!IsAdminPage(d->GetHostName())) { char szTmp[64]; - snprintf(szTmp, sizeof(szTmp), "WEBADMIN : Wrong Connector : %s", inet_ntoa(d->GetAddr().sin_addr)); + snprintf(szTmp, sizeof(szTmp), "WEBADMIN : Wrong Connector : %s", d->GetHostName()); stResult += szTmp; } else @@ -322,9 +310,9 @@ int CInputHandshake::Analyze(LPDESC d, BYTE bHeader, const char * c_pData) if (!IsEmptyAdminPage()) { - if (!IsAdminPage(inet_ntoa(d->GetAddr().sin_addr))) + if (!IsAdminPage(d->GetHostName())) { - snprintf(szTmp, sizeof(szTmp), "WEBADMIN : Wrong Connector : %s", inet_ntoa(d->GetAddr().sin_addr)); + snprintf(szTmp, sizeof(szTmp), "WEBADMIN : Wrong Connector : %s", d->GetHostName()); } else { @@ -396,16 +384,6 @@ int CInputHandshake::Analyze(LPDESC d, BYTE bHeader, const char * c_pData) LogManager::instance().CharLog(0, 0, 0, 1, "NOTICE", msg.c_str(), d->GetHostName()); BroadcastNotice(msg.c_str()); } - else if (!stBuf.compare("CLOSE_PASSPOD")) - { - g_bNoPasspod = true; - stResult += "CLOSE_PASSPOD"; - } - else if (!stBuf.compare("OPEN_PASSPOD")) - { - g_bNoPasspod = false; - stResult += "OPEN_PASSPOD"; - } else if (!stBuf.compare("SHUTDOWN")) { LogManager::instance().CharLog(0, 0, 0, 2, "SHUTDOWN", "", d->GetHostName()); @@ -502,7 +480,7 @@ dev_log(LOG_DEB0, "DC : '%s'", msg.c_str()); { std::istringstream is(stBuf); std::string strEvent, strFlagName; - long lValue; + int lValue; is >> strEvent >> strFlagName >> lValue; if (!is.fail()) @@ -522,7 +500,7 @@ dev_log(LOG_DEB0, "DC : '%s'", msg.c_str()); { std::istringstream is(stBuf); std::string strBlockChat, strCharName; - long lDuration; + int lDuration; is >> strBlockChat >> strCharName >> lDuration; if (!is.fail()) @@ -620,38 +598,8 @@ dev_log(LOG_DEB0, "DC : '%s'", msg.c_str()); Pong(d); else if (bHeader == HEADER_CG_HANDSHAKE) Handshake(d, c_pData); -#ifdef _IMPROVED_PACKET_ENCRYPTION_ - else if (bHeader == HEADER_CG_KEY_AGREEMENT) - { - // Send out the key agreement completion packet first - // to help client to enter encryption mode - d->SendKeyAgreementCompleted(); - // Flush socket output before going encrypted - d->ProcessOutput(); - - TPacketKeyAgreement* p = (TPacketKeyAgreement*)c_pData; - if (!d->IsCipherPrepared()) - { - sys_err ("Cipher isn't prepared. %s maybe a Hacker.", inet_ntoa(d->GetAddr().sin_addr)); - d->DelayedDisconnect(5); - return 0; - } - if (d->FinishHandshake(p->wAgreedLength, p->data, p->wDataLength)) { - // Handshaking succeeded - if (g_bAuthServer) { - d->SetPhase(PHASE_AUTH); - } else { - d->SetPhase(PHASE_LOGIN); - } - } else { - sys_log(0, "[CInputHandshake] Key agreement failed: al=%u dl=%u", - p->wAgreedLength, p->wDataLength); - d->SetPhase(PHASE_CLOSE); - } - } -#endif // _IMPROVED_PACKET_ENCRYPTION_ else - sys_err("Handshake phase does not handle packet %d (fd %d)", bHeader, d->GetSocket()); + sys_err("Handshake phase does not handle packet %d", bHeader); return 0; } diff --git a/game/src/input.h b/game/src/input.h index 3d51d31..3a05164 100644 --- a/game/src/input.h +++ b/game/src/input.h @@ -345,8 +345,6 @@ class CInputAuth : public CInputProcessor public: void Login(LPDESC d, const char * c_pData); - void PasspodAnswer(LPDESC d, const char * c_pData ); - }; class CInputTeen : public CInputProcessor diff --git a/game/src/input_auth.cpp b/game/src/input_auth.cpp index ac97dc7..f4e02c0 100644 --- a/game/src/input_auth.cpp +++ b/game/src/input_auth.cpp @@ -6,7 +6,6 @@ #include "desc_manager.h" #include "protocol.h" #include "matrix_card.h" -#include "passpod.h" #include "locale_service.h" #include "db.h" @@ -107,8 +106,7 @@ void CInputAuth::Login(LPDESC d, const char * c_pData) if (!g_bAuthServer) { - sys_err ("CInputAuth class is not for game server. IP %s might be a hacker.", - inet_ntoa(d->GetAddr().sin_addr)); + sys_err ("CInputAuth class is not for game server. IP %s might be a hacker.", d->GetHostName()); d->DelayedDisconnect(5); return; } @@ -206,8 +204,7 @@ int CInputAuth::Analyze(LPDESC d, BYTE bHeader, const char * c_pData) if (!g_bAuthServer) { - sys_err ("CInputAuth class is not for game server. IP %s might be a hacker.", - inet_ntoa(d->GetAddr().sin_addr)); + sys_err ("CInputAuth class is not for game server. IP %s might be a hacker.", d->GetHostName()); d->DelayedDisconnect(5); return 0; } @@ -227,10 +224,6 @@ int CInputAuth::Analyze(LPDESC d, BYTE bHeader, const char * c_pData) Login(d, c_pData); break; - case HEADER_CG_PASSPOD_ANSWER: - PasspodAnswer(d, c_pData); - break; - case HEADER_CG_HANDSHAKE: break; @@ -241,54 +234,3 @@ int CInputAuth::Analyze(LPDESC d, BYTE bHeader, const char * c_pData) return iExtraLen; } - -void CInputAuth::PasspodAnswer(LPDESC d, const char * c_pData) -{ - - if (!g_bAuthServer) - { - sys_err ("CInputAuth class is not for game server. IP %s might be a hacker.", - inet_ntoa(d->GetAddr().sin_addr)); - d->DelayedDisconnect(5); - return; - } - - TPacketCGPasspod * packet = (TPacketCGPasspod*)c_pData; - - RequestConfirmPasspod Confirm; - - memcpy(Confirm.passpod, packet->szAnswer, MAX_PASSPOD + 1); - memcpy(Confirm.login, d->GetAccountTable().login, LOGIN_MAX_LEN + 1); - - - if (!d->GetAccountTable().id) - { - sys_err("HEADER_CG_PASSPOD_ANSWER received to desc with no account table binded"); - return; - } - - int ret_code = 1; - sys_log(0, "Passpod start %s %s", d->GetAccountTable().login, packet->szAnswer); - ret_code = CPasspod::instance().ConfirmPasspod(d->GetAccountTable().login, packet->szAnswer); - - if (ret_code != 0) - { - sys_log(0, "PASSPOD: wrong answer: %s ret_code %d", d->GetAccountTable().login, ret_code); - - LoginFailure(d, ERR_MESSAGE[ret_code]); - - if (!d->CheckMatrixTryCount()) - { - LoginFailure(d, "QUIT"); - d->SetPhase(PHASE_CLOSE); - } - } - else - { - sys_log(0, "PASSPOD: success: %s", d->GetAccountTable().login); - DBManager::instance().SendAuthLogin(d); - } -// g_PasspodDesc->DBPacket(HEADER_GP_CONFIRM_PASSPOD, 0, &Confirm, sizeof(Confirm)); - -// sys_log(0, "PASSPOD %s %d", Confirm.login, Confirm.passpod); -} diff --git a/game/src/input_db.cpp b/game/src/input_db.cpp index c67139b..16ccdee 100644 --- a/game/src/input_db.cpp +++ b/game/src/input_db.cpp @@ -70,7 +70,7 @@ bool GetServerLocation(TAccountTable & rTab, BYTE bEmpire) continue; bFound = true; - long lIndex = 0; + int lIndex = 0; if (!CMapLocation::instance().Get(rTab.players[i].x, rTab.players[i].y, @@ -206,7 +206,7 @@ void CInputDB::PlayerCreateSuccess(LPDESC d, const char * data) return; } - long lIndex = 0; + int lIndex = 0; if (!CMapLocation::instance().Get(pPacketDB->player.x, pPacketDB->player.y, @@ -288,7 +288,7 @@ void CInputDB::PlayerDeleteSuccess(LPDESC d, const char * data) BYTE account_index; account_index = decode_byte(data); - d->BufferedPacket(encode_byte(HEADER_GC_CHARACTER_DELETE_SUCCESS), 1); + d->RawPacket(encode_byte(HEADER_GC_CHARACTER_DELETE_SUCCESS), 1); d->Packet(encode_byte(account_index), 1); d->GetAccountTable().players[account_index].dwID = 0; @@ -341,7 +341,7 @@ void CInputDB::PlayerLoad(LPDESC d, const char * data) if (!d) return; - long lMapIndex = pTab->lMapIndex; + int lMapIndex = pTab->lMapIndex; PIXEL_POSITION pos; if (lMapIndex == 0) @@ -414,8 +414,8 @@ void CInputDB::PlayerLoad(LPDESC d, const char * data) P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGLogin)); char buf[51]; - snprintf(buf, sizeof(buf), "%s %d %d %ld %d", - inet_ntoa(ch->GetDesc()->GetAddr().sin_addr), ch->GetGold(), g_bChannel, ch->GetMapIndex(), ch->GetAlignment()); + snprintf(buf, sizeof(buf), "%s %d %d %d %d", + ch->GetDesc()->GetHostName(), ch->GetGold(), g_bChannel, ch->GetMapIndex(), ch->GetAlignment()); LogManager::instance().CharLog(ch, 0, "LOGIN", buf); if (LC_IsYMIR() || LC_IsKorea() || LC_IsBrazil() || LC_IsJapan()) @@ -433,7 +433,7 @@ void CInputDB::PlayerLoad(LPDESC d, const char * data) d->SetPhase(PHASE_LOADING); ch->MainCharacterPacket(); - long lPublicMapIndex = lMapIndex >= 10000 ? lMapIndex / 10000 : lMapIndex; + int lPublicMapIndex = lMapIndex >= 10000 ? lMapIndex / 10000 : lMapIndex; //Send Supplementary Data Block if new map requires security packages in loading this map const TMapRegion * rMapRgn = SECTREE_MANAGER::instance().GetMapRegion(lPublicMapIndex); @@ -1326,7 +1326,8 @@ void CInputDB::MapLocations(const char * c_pData) void CInputDB::P2P(const char * c_pData) { - extern LPFDWATCH main_fdw; + extern event_base* ev_base; + extern evdns_base* dns_base; TPacketDGP2P * p = (TPacketDGP2P *) c_pData; @@ -1336,9 +1337,9 @@ void CInputDB::P2P(const char * c_pData) { LPCLIENT_DESC pkDesc = NULL; sys_log(0, "InputDB:P2P %s:%u", p->szHost, p->wPort); - pkDesc = DESC_MANAGER::instance().CreateConnectionDesc(main_fdw, p->szHost, p->wPort, PHASE_P2P, false); + pkDesc = DESC_MANAGER::instance().CreateConnectionDesc(ev_base, dns_base, p->szHost, p->wPort, PHASE_P2P, false); mgr.RegisterConnector(pkDesc); - pkDesc->SetP2P(p->szHost, p->wPort, p->bChannel); + pkDesc->SetP2P(p->wPort, p->bChannel); } } @@ -2498,8 +2499,8 @@ bool CInputDB::Process(LPDESC d, const void * orig, int bytes, int & r_iBytesPro if (Analyze(d, bHeader, pRealData) < 0) { - sys_err("in InputDB: UNKNOWN HEADER: %d, LAST HEADER: %d(%d), REMAIN BYTES: %d, DESC: %d", - bHeader, bLastHeader, iLastPacketLen, m_iBufferLeft, d->GetSocket()); + sys_err("in InputDB: UNKNOWN HEADER: %d, LAST HEADER: %d(%d), REMAIN BYTES: %d", + bHeader, bLastHeader, iLastPacketLen, m_iBufferLeft); //printdata((BYTE*) orig, bytes); //d->SetPhase(PHASE_CLOSE); @@ -2650,10 +2651,10 @@ void CInputDB::RespondChannelStatus(LPDESC desc, const char* pcData) pcData += sizeof(nSize); BYTE bHeader = HEADER_GC_RESPOND_CHANNELSTATUS; - desc->BufferedPacket(&bHeader, sizeof(BYTE)); - desc->BufferedPacket(&nSize, sizeof(nSize)); + desc->RawPacket(&bHeader, sizeof(BYTE)); + desc->RawPacket(&nSize, sizeof(nSize)); if (0 < nSize) { - desc->BufferedPacket(pcData, sizeof(TChannelStatus)*nSize); + desc->RawPacket(pcData, sizeof(TChannelStatus) * nSize); } BYTE bSuccess = 1; desc->Packet(&bSuccess, sizeof(bSuccess)); diff --git a/game/src/input_login.cpp b/game/src/input_login.cpp index f3eaf80..ca6762a 100644 --- a/game/src/input_login.cpp +++ b/game/src/input_login.cpp @@ -188,9 +188,6 @@ void CInputLogin::LoginByKey(LPDESC d, const char * data) sys_log(0, "LOGIN_BY_KEY: %s key %u", login, pinfo->dwLoginKey); d->SetLoginKey(pinfo->dwLoginKey); -#ifndef _IMPROVED_PACKET_ENCRYPTION_ - d->SetSecurityKey(pinfo->adwClientKey); -#endif TPacketGDLoginByKey ptod; @@ -774,7 +771,7 @@ void CInputLogin::Entergame(LPDESC d, const char * data) } // û¼Ò³â º¸È£ - if (g_TeenDesc) // BufferedPacket »ç¿ë ±ÝÁö + if (g_TeenDesc) // RawPacket »ç¿ë ±ÝÁö { TPacketGTLogin p; @@ -896,7 +893,7 @@ void CInputLogin::GuildSymbolCRC(LPDESC d, const char* c_pData) GCPacket.size = sizeof(GCPacket) + pkGS->raw.size(); GCPacket.guild_id = CGPacket.guild_id; - d->BufferedPacket(&GCPacket, sizeof(GCPacket)); + d->RawPacket(&GCPacket, sizeof(GCPacket)); d->Packet(&pkGS->raw[0], pkGS->raw.size()); sys_log(0, "SendGuildSymbolHead %02X%02X%02X%02X Size %d", @@ -958,8 +955,8 @@ void CInputLogin::GuildMarkIDXList(LPDESC d, const char* c_pData) if (buf) { - d->BufferedPacket(&p, sizeof(p)); - d->LargePacket(buf, bufSize); + d->RawPacket(&p, sizeof(p)); + d->Packet(buf, bufSize); free(buf); } else @@ -1001,8 +998,8 @@ void CInputLogin::GuildMarkCRCList(LPDESC d, const char* c_pData) if (buf.size() > 0) { - d->BufferedPacket(&pGC, sizeof(TPacketGCMarkBlock)); - d->LargePacket(buf.read_peek(), buf.size()); + d->RawPacket(&pGC, sizeof(TPacketGCMarkBlock)); + d->Packet(buf.read_peek(), buf.size()); } else d->Packet(&pGC, sizeof(TPacketGCMarkBlock)); diff --git a/game/src/input_main.cpp b/game/src/input_main.cpp index e502646..1aa16d4 100644 --- a/game/src/input_main.cpp +++ b/game/src/input_main.cpp @@ -56,10 +56,10 @@ void SendBlockChatInfo(LPCHARACTER ch, int sec) return; } - long hour = sec / 3600; + int hour = sec / 3600; sec -= hour * 3600; - long min = (sec / 60); + int min = (sec / 60); sec -= min * 60; char buf[128+1]; @@ -464,7 +464,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes) pack.wSize = sizeof(TPacketGCWhisper) + len; strncpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom)); - ch->GetDesc()->BufferedPacket(&pack, sizeof(pack)); + ch->GetDesc()->RawPacket(&pack, sizeof(pack)); ch->GetDesc()->Packet(buf, len); sys_log(0, "WHISPER: not enough %s: char: %s", pTable->szLocaleName, ch->GetName()); @@ -553,7 +553,7 @@ struct FEmpireChatPacket if (d->GetCharacter()->GetMapIndex() != iMapIndex) return; - d->BufferedPacket(&p, sizeof(packet_chat)); + d->RawPacket(&p, sizeof(packet_chat)); if (d->GetEmpire() == bEmpire || bEmpire == 0 || @@ -624,14 +624,14 @@ struct FYmirChatPacket { packet.size = m_len_orig_msg + sizeof(TPacketGCChat); - d->BufferedPacket(&packet, sizeof(packet_chat)); + d->RawPacket(&packet, sizeof(packet_chat)); d->Packet(m_orig_msg, m_len_orig_msg); } else { packet.size = m_len_conv_msg + sizeof(TPacketGCChat); - d->BufferedPacket(&packet, sizeof(packet_chat)); + d->RawPacket(&packet, sizeof(packet_chat)); d->Packet(m_conv_msg, m_len_conv_msg); } } @@ -1877,7 +1877,7 @@ int CInputMain::SyncPosition(LPCHARACTER ch, const char * c_pcData, size_t uiByt } const float fDist = DISTANCE_SQRT( (victim->GetX() - e->lX) / 100, (victim->GetY() - e->lY) / 100 ); - static const long g_lValidSyncInterval = 50 * 1000; // 100ms -> 50ms 2013 09 11 CYH + static const int g_lValidSyncInterval = 50 * 1000; // 100ms -> 50ms 2013 09 11 CYH const timeval &tvLastSyncTime = victim->GetLastSyncTime(); timeval *tvDiff = timediff(&tvCurTime, &tvLastSyncTime); diff --git a/game/src/input_p2p.cpp b/game/src/input_p2p.cpp index 43f901d..63d3b08 100644 --- a/game/src/input_p2p.cpp +++ b/game/src/input_p2p.cpp @@ -257,7 +257,7 @@ void CInputP2P::Setup(LPDESC d, const char * c_pData) { TPacketGGSetup * p = (TPacketGGSetup *) c_pData; sys_log(0, "P2P: Setup %s:%d", d->GetHostName(), p->wPort); - d->SetP2P(d->GetHostName(), p->wPort, p->bChannel); + d->SetP2P(p->wPort, p->bChannel); } void CInputP2P::MessengerAdd(const char * c_pData) diff --git a/game/src/ip_ban.cpp b/game/src/ip_ban.cpp deleted file mode 100644 index 1437e94..0000000 --- a/game/src/ip_ban.cpp +++ /dev/null @@ -1,372 +0,0 @@ -//#define __MAIN__ -#ifdef __MAIN__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -typedef unsigned char BYTE; -typedef unsigned long DWORD; - -#else - -#include "stdafx.h" -#include "ip_ban.h" - -#endif - -class IP -{ - public: - IP() - : dwStart(0), dwEnd(0), dwMask(0) - {} - - IP(const IP & r) - { - dwStart = r.dwStart; - dwEnd = r.dwEnd; - dwMask = r.dwMask; - } - - IP(const char * c_pszStart, const char * c_pszEnd = NULL) - { - BYTE start[4]; - BYTE end[4]; - BYTE mask[4]; - - Read(c_pszStart, start); - - if (c_pszEnd && *c_pszEnd) - Read(c_pszEnd, end); - else - memcpy(end, start, sizeof(BYTE) * 4); - - mask[0] = 255 - (start[0] ^ end[0]); - mask[1] = 255 - (start[1] ^ end[1]); - mask[2] = 255 - (start[2] ^ end[2]); - mask[3] = 255 - (start[3] ^ end[3]); - - dwStart = (start[3] << 24) | (start[2] << 16) | (start[1] << 8) | start[0]; - dwEnd = (end[3] << 24) | (end[2] << 16) | (end[1] << 8) | end[0]; - dwMask = (mask[3] << 24) | (mask[2] << 16) | (mask[1] << 8) | mask[0]; - - Print(); - } - - IP(struct in_addr in) - { - dwStart = in.s_addr; - dwEnd = dwStart; - dwMask = 4294967295UL; - } - - bool IsEqual(const IP & r) const - { - return (dwStart == r.dwStart && dwEnd == r.dwEnd && dwMask == r.dwMask); - } - - bool IsChildOf(IP & r) - { - if ((r.dwStart & r.dwMask) != (dwStart & r.dwMask)) - return false; - - DWORD m = r.dwMask | dwMask; - - return (dwStart & ~m) == (dwStart & ~dwMask) && (dwEnd & ~m) == (dwEnd & ~dwMask); - } - - int hash() - { - return (dwStart & 0x000000FF); - } - - void Print() - { - struct in_addr in_ip, in_mask, in_end; - - in_ip.s_addr = dwStart; - in_mask.s_addr = dwMask; - in_end.s_addr = dwEnd; - - fprintf(stderr, "\t%s", inet_ntoa(in_ip)); - fprintf(stderr, "\t%s", inet_ntoa(in_end)); - fprintf(stderr, "\t%s\tfirst %d\n", inet_ntoa(in_mask), hash()); - } - - protected: - bool Read(const char * s, BYTE * dest) - { - BYTE bClass = 0; - const char * p = s; - - while (bClass < 3) - { - char szNum[4]; - char * pDot = const_cast(strchr(p, '.')); - - if (!pDot) - break; - - strncpy(szNum, p, sizeof(szNum)); - - str_to_number(dest[bClass++], szNum); - p = pDot + 1; - } - - if (bClass != 3) - { - fprintf(stderr, "error reading start %s\n", s); - return false; - } - - str_to_number(dest[bClass], p); - return true; - } - - DWORD dwStart; - DWORD dwEnd; - DWORD dwMask; -}; - -std::map > mapBanIP; - -bool LoadBanIP(const char * filename) -{ - FILE * fp = fopen(filename, "r"); - - if (!fp) - return false; - - char buf[256]; - char start[256]; - char end[256]; - - fprintf(stderr, "LOADING BANNED IP LIST\n"); - - while (fgets(buf, 256, fp)) - { - *strchr(buf, '\n') = '\0'; - char * p = strchr(buf, '\t'); - - if (!p) - { - strncpy(start, buf, sizeof(start)); - *end = '\0'; - } - else - { - char * p2 = strchr(p + 1, '\t'); - - if (p2) - *p2 = '\0'; - - strncpy(end, p + 1, sizeof(end)); - - *p = '\0'; - strncpy(start, buf, sizeof(start)); - } - - IP ip(start, end); - - itertype(mapBanIP) it = mapBanIP.find(ip.hash()); - - if (it == mapBanIP.end()) - { - std::vector v; - v.push_back(ip); - mapBanIP.insert(std::map >::value_type(ip.hash(), v)); - } - else - it->second.push_back(ip); - } - - fclose(fp); - - return true; -} - -bool IsBanIP(struct in_addr in) -{ - IP ip(in); - - itertype(mapBanIP) it = mapBanIP.find(ip.hash()); - - if (it == mapBanIP.end()) - return false; - - itertype(it->second) it2 = it->second.begin(); - - while (it2 != it->second.end()) - if (ip.IsChildOf(*(it2++))) - return true; - - return false; -} - -#ifdef __MAIN__ -void UniqueIP(std::vector & v) -{ - using namespace std; - - bool found; - vector::iterator it1; - - do - { - vector o; - it1 = v.begin(); - - while (it1 != v.end()) - { - IP & ip1 = *(it1++); - - found = false; - - if (it1 != v.end()) - { - vector::iterator it2 = it1; - - while (it2 != v.end()) - { - IP & ip2 = *(it2++); - - if (ip1.IsEqual(ip2)) - { - found = true; - break; - } - } - } - - if (!found) - o.push_back(ip1); - } - - if (o.size() == v.size()) - break; - - v.clear(); - it1 = o.begin(); - - while (it1 != o.end()) - v.push_back(*(it1++)); - } - while (1); -} - -void FilterIP(std::vector & v) -{ - using namespace std; - - bool found; - vector::iterator it1; - - do - { - vector o; - it1 = v.begin(); - - while (it1 != v.end()) - { - IP & ip1 = *(it1++); - - found = false; - - vector::iterator it2 = v.begin(); - - while (it2 != v.end()) - { - IP & ip2 = *(it2++); - - if (ip1.IsEqual(ip2)) - continue; - - if (ip1.IsChildOf(ip2)) - { - found = true; - break; - } - } - - if (!found) - o.push_back(ip1); - } - - if (o.size() == v.size()) - break; - - v.clear(); - it1 = o.begin(); - - while (it1 != o.end()) - v.push_back(*(it1++)); - } - while (1); -} - -int main(int argc, char **argv) -{ - using namespace std; - - if (argc != 2) - { - printf("Syntax: %s \n", *argv); - return 1; - } - - argc--, argv++; - - FILE * fp = fopen(*argv, "r"); - - if (!fp) - return 0; - - vector v; - char buf[256]; - char start[32]; - char end[32]; - - while (fgets(buf, 256, fp)) - { - *strchr(buf, '\n') = '\0'; - char * p = strchr(buf, '\t'); - - if (!p) - { - strncpy(start, buf, sizeof(start)); - *end = '\0'; - } - else - { - strncpy(end, p + 1, sizeof(end)); - *p = '\0'; - strncpy(start, buf, sizeof(start)); - } - - v.push_back(IP(start, end)); - } - - fclose(fp); - - printf("size %d\n", v.size()); - UniqueIP(v); - printf("result1 %d\n", v.size()); - FilterIP(v); - printf("result2 %d\n", v.size()); - - vector::iterator it = v.begin(); - - while (it != v.end()) - (*(it++)).Print(); - - return 1; -} - -#endif diff --git a/game/src/ip_ban.h b/game/src/ip_ban.h deleted file mode 100644 index 9f18064..0000000 --- a/game/src/ip_ban.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __INC_METIN_II_GAME_BAN_IP_H__ -#define __INC_METIN_II_GAME_BAN_IP_H__ - -extern bool LoadBanIP(const char * filename); -extern bool IsBanIP(struct in_addr in); - -#endif diff --git a/game/src/item.cpp b/game/src/item.cpp index d42eb5f..4f2fc04 100644 --- a/game/src/item.cpp +++ b/game/src/item.cpp @@ -192,12 +192,12 @@ void CItem::UsePacketEncode(LPCHARACTER ch, LPCHARACTER victim, struct packet_it packet->vnum = GetVnum(); } -void CItem::RemoveFlag(long bit) +void CItem::RemoveFlag(int bit) { REMOVE_BIT(m_lFlag, bit); } -void CItem::AddFlag(long bit) +void CItem::AddFlag(int bit) { SET_BIT(m_lFlag, bit); } @@ -389,7 +389,7 @@ LPITEM CItem::RemoveFromGround() return (this); } -bool CItem::AddToGround(long lMapIndex, const PIXEL_POSITION & pos, bool skipOwnerCheck) +bool CItem::AddToGround(int lMapIndex, const PIXEL_POSITION & pos, bool skipOwnerCheck) { if (0 == lMapIndex) { @@ -638,7 +638,7 @@ void CItem::ModifyPoints(bool bAdd) if (m_pProto->aApplies[i].bType == APPLY_NONE) continue; - long value = m_pProto->aApplies[i].lValue; + int value = m_pProto->aApplies[i].lValue; if (m_pProto->aApplies[i].bType == APPLY_SKILL) { @@ -952,7 +952,7 @@ bool CItem::Unequip() return true; } -long CItem::GetValue(DWORD idx) +int CItem::GetValue(DWORD idx) { assert(idx < ITEM_VALUES_MAX_NUM); return GetProto()->alValues[idx]; @@ -992,13 +992,13 @@ bool CItem::CreateSocket(BYTE bSlot, BYTE bGold) return true; } -void CItem::SetSockets(const long * c_al) +void CItem::SetSockets(const LONG * c_al) { memcpy(m_alSockets, c_al, sizeof(m_alSockets)); Save(); } -void CItem::SetSocket(int i, long v, bool bLog) +void CItem::SetSocket(int i, int v, bool bLog) { assert(i < ITEM_SOCKET_MAX_NUM); m_alSockets[i] = v; @@ -1367,17 +1367,10 @@ EVENTFUNC(real_time_expire_event) const time_t current = get_global_time(); - if (current > item->GetSocket(0)) - { - switch (item->GetVnum()) - { - if(item->IsNewMountItem()) - { - if (item->GetSocket(2) != 0) - item->ClearMountAttributeAndAffect(); - } - break; - } + if (current > item->GetSocket(0)) { + if(item->IsNewMountItem()) + if (item->GetSocket(2) != 0) + item->ClearMountAttributeAndAffect(); ITEM_MANAGER::instance().RemoveItem(item, "REAL_TIME_EXPIRE"); @@ -1864,7 +1857,7 @@ bool CItem::CheckItemUseLevel(int nLevel) return true; } -long CItem::FindApplyValue(BYTE bApplyType) +int CItem::FindApplyValue(BYTE bApplyType) { if (m_pProto == NULL) return 0; diff --git a/game/src/item.h b/game/src/item.h index 2c012f5..063ef4c 100644 --- a/game/src/item.h +++ b/game/src/item.h @@ -20,7 +20,7 @@ class CItem : public CEntity bool IsPCBangItem(); - long FindApplyValue(BYTE bApplyType); + int FindApplyValue(BYTE bApplyType); bool IsStackable() { return (GetFlag() & ITEM_FLAG_STACKABLE)?true:false; } @@ -44,11 +44,11 @@ class CItem : public CEntity const char * GetBaseName() { return m_pProto ? m_pProto->szName : NULL; } BYTE GetSize() { return m_pProto ? m_pProto->bSize : 0; } - void SetFlag(long flag) { m_lFlag = flag; } - long GetFlag() { return m_lFlag; } + void SetFlag(int flag) { m_lFlag = flag; } + int GetFlag() { return m_lFlag; } - void AddFlag(long bit); - void RemoveFlag(long bit); + void AddFlag(int bit); + void RemoveFlag(int bit); DWORD GetWearFlag() { return m_pProto ? m_pProto->dwWearFlags : 0; } DWORD GetAntiFlag() { return m_pProto ? m_pProto->dwAntiFlags : 0; } @@ -70,9 +70,9 @@ class CItem : public CEntity BYTE GetType() const { return m_pProto ? m_pProto->bType : 0; } BYTE GetSubType() const { return m_pProto ? m_pProto->bSubType : 0; } BYTE GetLimitType(DWORD idx) const { return m_pProto ? m_pProto->aLimits[idx].bType : 0; } - long GetLimitValue(DWORD idx) const { return m_pProto ? m_pProto->aLimits[idx].lValue : 0; } + int GetLimitValue(DWORD idx) const { return m_pProto ? m_pProto->aLimits[idx].lValue : 0; } - long GetValue(DWORD idx); + int GetValue(DWORD idx); void SetCell(LPCHARACTER ch, WORD pos) { m_pOwner = ch, m_wCell = pos; } WORD GetCell() { return m_wCell; } @@ -82,7 +82,7 @@ class CItem : public CEntity LPCHARACTER GetOwner() { return m_pOwner; } LPITEM RemoveFromGround(); - bool AddToGround(long lMapIndex, const PIXEL_POSITION & pos, bool skipOwnerCheck = false); + bool AddToGround(int lMapIndex, const PIXEL_POSITION & pos, bool skipOwnerCheck = false); int FindEquipCell(LPCHARACTER ch, int bCandidateCell = -1); bool IsEquipped() const { return m_bEquipped; } @@ -106,11 +106,11 @@ class CItem : public CEntity void ModifyPoints(bool bAdd); // ¾ÆÀÌÅÛÀÇ È¿°ú¸¦ ij¸¯ÅÍ¿¡ ºÎ¿© ÇÑ´Ù. bAdd°¡ falseÀ̸é Á¦°ÅÇÔ bool CreateSocket(BYTE bSlot, BYTE bGold); - const long * GetSockets() { return &m_alSockets[0]; } - long GetSocket(int i) { return m_alSockets[i]; } + const int * GetSockets() { return &m_alSockets[0]; } + int GetSocket(int i) { return m_alSockets[i]; } - void SetSockets(const long * al); - void SetSocket(int i, long v, bool bLog = true); + void SetSockets(const LONG * al); + void SetSocket(int i, int v, bool bLog = true); int GetSocketCount(); bool AddSocket(); @@ -271,12 +271,12 @@ class CItem : public CEntity DWORD m_dwVID; // VID WORD m_wCell; // À§Ä¡ DWORD m_dwCount; // °³¼ö - long m_lFlag; // Ãß°¡ flag + int m_lFlag; // Ãß°¡ flag DWORD m_dwLastOwnerPID; // ¸¶Áö¸· °¡Áö°í ÀÖ¾ú´ø »ç¶÷ÀÇ PID bool m_bExchanging; ///< ÇöÀç ±³È¯Áß »óÅ - long m_alSockets[ITEM_SOCKET_MAX_NUM]; // ¾ÆÀÌÅÛ ¼ÒĹ + int m_alSockets[ITEM_SOCKET_MAX_NUM]; // ¾ÆÀÌÅÛ ¼ÒĹ TPlayerItemAttribute m_aAttr[ITEM_ATTRIBUTE_MAX_NUM]; LPEVENT m_pkDestroyEvent; diff --git a/game/src/item_attribute.cpp b/game/src/item_attribute.cpp index 9864166..8c6290c 100644 --- a/game/src/item_attribute.cpp +++ b/game/src/item_attribute.cpp @@ -104,7 +104,7 @@ void CItem::AddAttr(BYTE bApply, BYTE bLevel) else { const TItemAttrTable & r = g_map_itemAttr[bApply]; - long lVal = r.lValues[MIN(4, bLevel - 1)]; + int lVal = r.lValues[MIN(4, bLevel - 1)]; if (lVal) SetAttribute(i, bApply, lVal); diff --git a/game/src/item_manager.cpp b/game/src/item_manager.cpp index 23fa79b..d3df5f7 100644 --- a/game/src/item_manager.cpp +++ b/game/src/item_manager.cpp @@ -315,7 +315,7 @@ LPITEM ITEM_MANAGER::CreateItem(DWORD vnum, DWORD count, DWORD id, bool bTryMagi } else if(0 == id) { - long duration = item->GetSocket(0); + int duration = item->GetSocket(0); if (0 == duration) duration = item->GetLimitValue(i); @@ -1764,7 +1764,7 @@ void ITEM_MANAGER::CopyAllAttrTo(LPITEM pkOldItem, LPITEM pkNewItem) for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i) { - long socket = pkOldItem->GetSocket(i); + int socket = pkOldItem->GetSocket(i); const int ITEM_BROKEN_METIN_VNUM = 28960; // ÀÌ°Ç ¹¹ ¶È°°Àº »ó¼ö°¡ 3±ºµ¥³ª ÀÖ³Ä... Çϳª·Î ÇسõÁö¤Ð¤Ð¤Ð ³ª´Â Æнº È«ÀÌ ÇÒ²¨ÀÓ if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM) pkNewItem->SetSocket(slot++, socket); diff --git a/game/src/log.cpp b/game/src/log.cpp index 879b2c6..a7c48dc 100644 --- a/game/src/log.cpp +++ b/game/src/log.cpp @@ -314,14 +314,14 @@ void LogManager::DragonSlayLog(DWORD dwGuildID, DWORD dwDragonVnum, DWORD dwStar dwGuildID, dwDragonVnum, dwStartTime, dwEndTime); } -void LogManager::HackShieldLog(unsigned long ErrorCode, LPCHARACTER ch) +void LogManager::HackShieldLog(unsigned int ErrorCode, LPCHARACTER ch) { struct in_addr st_addr; #ifndef __WIN32__ if (0 == inet_aton(ch->GetDesc()->GetHostName(), &st_addr)) #else - unsigned long in_address; + unsigned int in_address; in_address = inet_addr(ch->GetDesc()->GetHostName()); st_addr.s_addr = in_address; if (INADDR_NONE == in_address) diff --git a/game/src/log.h b/game/src/log.h index 47fdd3e..f5a119c 100644 --- a/game/src/log.h +++ b/game/src/log.h @@ -52,7 +52,7 @@ class LogManager : public singleton void QuestRewardLog(const char * c_pszQuestName, DWORD dwPID, DWORD dwLevel, int iValue1, int iValue2); void DetailLoginLog(bool isLogin, LPCHARACTER ch); void DragonSlayLog(DWORD dwGuildID, DWORD dwDragonVnum, DWORD dwStartTime, DWORD dwEndTime); - void HackShieldLog(unsigned long ErrorCode, LPCHARACTER ch); + void HackShieldLog(unsigned int ErrorCode, LPCHARACTER ch); private: void Query(const char * c_pszFormat, ...); diff --git a/game/src/login_data.cpp b/game/src/login_data.cpp index 52237d5..f82d8c7 100644 --- a/game/src/login_data.cpp +++ b/game/src/login_data.cpp @@ -89,13 +89,13 @@ const char * CLoginData::GetIP() return m_szIP; } -void CLoginData::SetRemainSecs(long l) +void CLoginData::SetRemainSecs(int l) { m_lRemainSecs = l; sys_log(0, "SetRemainSecs %s %d type %u", m_stLogin.c_str(), m_lRemainSecs, m_bBillType); } -long CLoginData::GetRemainSecs() +int CLoginData::GetRemainSecs() { return m_lRemainSecs; } diff --git a/game/src/login_data.h b/game/src/login_data.h index 3b68bef..474c8c0 100644 --- a/game/src/login_data.h +++ b/game/src/login_data.h @@ -30,8 +30,8 @@ class CLoginData void SetIP(const char * c_pszIP); const char * GetIP(); - void SetRemainSecs(long l); - long GetRemainSecs(); + void SetRemainSecs(int l); + int GetRemainSecs(); void SetBilling(bool bOn); bool IsBilling(); @@ -51,7 +51,7 @@ class CLoginData DWORD m_dwBillID; DWORD m_dwConnectedPeerHandle; DWORD m_dwLogonTime; - long m_lRemainSecs; + int m_lRemainSecs; char m_szIP[MAX_HOST_LENGTH+1]; bool m_bBilling; bool m_bDeleted; diff --git a/game/src/main.cpp b/game/src/main.cpp index 718db39..d65336e 100644 --- a/game/src/main.cpp +++ b/game/src/main.cpp @@ -45,7 +45,6 @@ #include "polymorph.h" #include "blend_item.h" #include "castle.h" -#include "passpod.h" #include "ani.h" #include "BattleArena.h" #include "over9refine.h" @@ -59,7 +58,9 @@ #include "skill_power.h" #include "SpeedServer.h" #include "DragonSoul.h" -#include +#include +#include +#include #ifdef __AUCTION__ #include "auction_manager.h" @@ -95,12 +96,17 @@ int current_bytes_written = 0; int total_bytes_written = 0; BYTE g_bLogLevel = 0; -socket_t tcp_socket = 0; -socket_t p2p_socket = 0; +evconnlistener * tcp_listener = nullptr; +evconnlistener * p2p_listener = nullptr; -LPFDWATCH main_fdw = NULL; +event_base * ev_base = nullptr; +evdns_base * dns_base = nullptr; -int io_loop(LPFDWATCH fdw); +static void AcceptError(evconnlistener *listener, void *ctx); +static void AcceptTCPConnection(evconnlistener* listener, evutil_socket_t fd, sockaddr* address, int socklen, void* ctx); +static void AcceptP2PConnection(evconnlistener* listener, evutil_socket_t fd, sockaddr* address, int socklen, void* ctx); + +int io_loop(event_base * base); int start(int argc, char **argv); int idle(); @@ -367,7 +373,6 @@ int main(int argc, char **argv) CTableBySkill SkillPowerByLevel; CPolymorphUtils polymorph_utils; CProfiler profiler; - CPasspod passpod; CBattleArena ba; COver9RefineManager o9r; SpamManager spam_mgr; @@ -541,7 +546,7 @@ int start(int argc, char **argv) case 'l': { - long l = strtol(argv[optind], &ep, 10); + int l = strtol(argv[optind], &ep, 10); log_set_level(l); @@ -607,27 +612,59 @@ int start(int argc, char **argv) } signal_timer_disable(); - - main_fdw = fdwatch_new(4096); - if ((tcp_socket = socket_tcp_bind(g_szPublicIP, mother_port)) == INVALID_SOCKET) - { - perror("socket_tcp_bind: tcp_socket"); - return 0; - } + // Initialize the network stack + // Create a new libevent base and listen for new connections + ev_base = event_base_new(); + if (!ev_base) { + sys_err("Libevent base initialization FAILED!"); + return 0; + } - // if internal ip exists, p2p socket uses internal ip, if not use public ip - //if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET) - if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET) - { - perror("socket_tcp_bind: p2p_socket"); - return 0; - } + dns_base = evdns_base_new(ev_base, 1); + if (!dns_base) { + sys_err("Libevent DNS base initialization FAILED!"); + return 0; + } - fdwatch_add_fd(main_fdw, tcp_socket, NULL, FDW_READ, false); - fdwatch_add_fd(main_fdw, p2p_socket, NULL, FDW_READ, false); + sockaddr_in sin = {}; - db_clientdesc = DESC_MANAGER::instance().CreateConnectionDesc(main_fdw, db_addr, db_port, PHASE_DBCLIENT, true); + // Main TCP listener + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = inet_addr(g_szPublicIP); + sin.sin_port = htons(mother_port); + + tcp_listener = evconnlistener_new_bind( + ev_base, + AcceptTCPConnection, nullptr, + LEV_OPT_CLOSE_ON_FREE|LEV_OPT_REUSEABLE, -1, + (const sockaddr*)&sin, sizeof(sin) + ); + if (!tcp_listener) { + sys_err("TCP listener initialization FAILED!"); + return 0; + } + evconnlistener_set_error_cb(tcp_listener, AcceptError); + + // Game P2P listener + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = inet_addr(g_szPublicIP); + sin.sin_port = htons(p2p_port); + + p2p_listener = evconnlistener_new_bind( + ev_base, + AcceptP2PConnection, nullptr, + LEV_OPT_CLOSE_ON_FREE|LEV_OPT_REUSEABLE, -1, + (const sockaddr*)&sin, sizeof(sin) + ); + if (!p2p_listener) { + sys_err("P2P listener initialization FAILED!"); + return 0; + } + evconnlistener_set_error_cb(p2p_listener, AcceptError); + + // Create client connections + db_clientdesc = DESC_MANAGER::instance().CreateConnectionDesc(ev_base, dns_base, db_addr, db_port, PHASE_DBCLIENT, true); if (!g_bAuthServer) { db_clientdesc->UpdateChannelStatus(0, true); } @@ -637,9 +674,9 @@ int start(int argc, char **argv) if (g_stAuthMasterIP.length() != 0) { fprintf(stderr, "SlaveAuth"); - g_pkAuthMasterDesc = DESC_MANAGER::instance().CreateConnectionDesc(main_fdw, g_stAuthMasterIP.c_str(), g_wAuthMasterPort, PHASE_P2P, true); + g_pkAuthMasterDesc = DESC_MANAGER::instance().CreateConnectionDesc(ev_base, dns_base, g_stAuthMasterIP.c_str(), g_wAuthMasterPort, PHASE_P2P, true); P2P_MANAGER::instance().RegisterConnector(g_pkAuthMasterDesc); - g_pkAuthMasterDesc->SetP2P(g_stAuthMasterIP.c_str(), g_wAuthMasterPort, g_bChannel); + g_pkAuthMasterDesc->SetP2P(g_wAuthMasterPort, g_bChannel); } else @@ -651,7 +688,7 @@ int start(int argc, char **argv) else { if (teen_addr[0] && teen_port) - g_TeenDesc = DESC_MANAGER::instance().CreateConnectionDesc(main_fdw, teen_addr, teen_port, PHASE_TEEN, true); + g_TeenDesc = DESC_MANAGER::instance().CreateConnectionDesc(ev_base, dns_base, teen_addr, teen_port, PHASE_TEEN, true); extern unsigned int g_uiSpamBlockDuration; extern unsigned int g_uiSpamBlockScore; @@ -676,12 +713,26 @@ void destroy() sys_log(0, " regen_free()..."); regen_free(); - sys_log(0, " Closing sockets..."); - socket_close(tcp_socket); - socket_close(p2p_socket); + sys_log(0, " Closing network stack..."); + if (tcp_listener) { + evconnlistener_free(tcp_listener); + tcp_listener = nullptr; + } - sys_log(0, " fdwatch_delete()..."); - fdwatch_delete(main_fdw); + if (p2p_listener) { + evconnlistener_free(p2p_listener); + tcp_listener = nullptr; + } + + if (dns_base) { + evdns_base_free(dns_base, 0); + ev_base = nullptr; + } + + if (ev_base) { + event_base_free(ev_base); + ev_base = nullptr; + } sys_log(0, " event_destroy()..."); event_destroy(); @@ -724,7 +775,7 @@ int idle() s_dwProfiler[PROF_CHR_UPDATE] += (get_dword_time() - t); t = get_dword_time(); - if (!io_loop(main_fdw)) return 0; + if (!io_loop(ev_base)) return 0; s_dwProfiler[PROF_IO] += (get_dword_time() - t); log_rotate(); @@ -772,7 +823,29 @@ int idle() return 1; } -int io_loop(LPFDWATCH fdw) +static void AcceptError(evconnlistener *listener, void *ctx) { + struct event_base *base = evconnlistener_get_base(listener); + int err = EVUTIL_SOCKET_ERROR(); + fprintf(stderr, "Got an error %d (%s) on the listener. " + "Shutting down.\n", err, evutil_socket_error_to_string(err)); + + event_base_loopexit(base, nullptr); + ShutdownOnFatalError(); +} + +static void AcceptTCPConnection(evconnlistener* listener, evutil_socket_t fd, sockaddr* address, int socklen, void* ctx) +{ + // Initialize the peer + DESC_MANAGER::instance().AcceptDesc(listener, fd, address); +} + +static void AcceptP2PConnection(evconnlistener* listener, evutil_socket_t fd, sockaddr* address, int socklen, void* ctx) +{ + // Initialize the peer + DESC_MANAGER::instance().AcceptP2PDesc(listener, fd, address); +} + +int io_loop(event_base * base) { LPDESC d; int num_events, event_idx; @@ -780,100 +853,8 @@ int io_loop(LPFDWATCH fdw) DESC_MANAGER::instance().DestroyClosed(); // PHASE_CLOSEÀÎ Á¢¼ÓµéÀ» ²÷¾îÁØ´Ù. DESC_MANAGER::instance().TryConnect(); - if ((num_events = fdwatch(fdw, 0)) < 0) - return 0; - - for (event_idx = 0; event_idx < num_events; ++event_idx) - { - d = (LPDESC) fdwatch_get_client_data(fdw, event_idx); - - if (!d) - { - if (FDW_READ == fdwatch_check_event(fdw, tcp_socket, event_idx)) - { - DESC_MANAGER::instance().AcceptDesc(fdw, tcp_socket); - fdwatch_clear_event(fdw, tcp_socket, event_idx); - } - else if (FDW_READ == fdwatch_check_event(fdw, p2p_socket, event_idx)) - { - DESC_MANAGER::instance().AcceptP2PDesc(fdw, p2p_socket); - fdwatch_clear_event(fdw, p2p_socket, event_idx); - } - continue; - } - - int iRet = fdwatch_check_event(fdw, d->GetSocket(), event_idx); - - switch (iRet) - { - case FDW_READ: - if (db_clientdesc == d) - { - int size = d->ProcessInput(); - - if (size) - sys_log(1, "DB_BYTES_READ: %d", size); - - if (size < 0) - { - d->SetPhase(PHASE_CLOSE); - } - } - else if (d->ProcessInput() < 0) - { - d->SetPhase(PHASE_CLOSE); - } - break; - - case FDW_WRITE: - if (db_clientdesc == d) - { - int buf_size = buffer_size(d->GetOutputBuffer()); - int sock_buf_size = fdwatch_get_buffer_size(fdw, d->GetSocket()); - - int ret = d->ProcessOutput(); - - if (ret < 0) - { - d->SetPhase(PHASE_CLOSE); - } - - if (buf_size) - sys_log(1, "DB_BYTES_WRITE: size %d sock_buf %d ret %d", buf_size, sock_buf_size, ret); - } - else if (d->ProcessOutput() < 0) - { - d->SetPhase(PHASE_CLOSE); - } - else if (g_TeenDesc==d) - { - int buf_size = buffer_size(d->GetOutputBuffer()); - int sock_buf_size = fdwatch_get_buffer_size(fdw, d->GetSocket()); - - int ret = d->ProcessOutput(); - - if (ret < 0) - { - d->SetPhase(PHASE_CLOSE); - } - - if (buf_size) - sys_log(0, "TEEN::Send(size %d sock_buf %d ret %d)", buf_size, sock_buf_size, ret); - } - break; - - case FDW_EOF: - { - d->SetPhase(PHASE_CLOSE); - } - break; - - default: - sys_err("fdwatch_check_event returned unknown %d", iRet); - d->SetPhase(PHASE_CLOSE); - break; - } - } + // Process network events + event_base_loop(base, EVLOOP_NONBLOCK); return 1; } diff --git a/game/src/map_location.cpp b/game/src/map_location.cpp index 40dbd96..5d8a835 100644 --- a/game/src/map_location.cpp +++ b/game/src/map_location.cpp @@ -7,14 +7,14 @@ CMapLocation g_mapLocations; -bool CMapLocation::Get(long x, long y, long & lIndex, long & lAddr, WORD & wPort) +bool CMapLocation::Get(int x, int y, int & lIndex, LONG & lAddr, WORD & wPort) { lIndex = SECTREE_MANAGER::instance().GetMapIndex(x, y); return Get(lIndex, lAddr, wPort); } -bool CMapLocation::Get(int iIndex, long & lAddr, WORD & wPort) +bool CMapLocation::Get(int iIndex, LONG & lAddr, WORD & wPort) { if (iIndex == 0) { @@ -22,12 +22,12 @@ bool CMapLocation::Get(int iIndex, long & lAddr, WORD & wPort) return false; } - std::map::iterator it = m_map_address.find(iIndex); + std::map::iterator it = m_map_address.find(iIndex); if (m_map_address.end() == it) { sys_log(0, "CMapLocation::Get - Error MapIndex[%d]", iIndex); - std::map::iterator i; + std::map::iterator i; for ( i = m_map_address.begin(); i != m_map_address.end(); ++i) { sys_log(0, "Map(%d): Server(%x:%d)", i->first, i->second.addr, i->second.port); @@ -40,7 +40,7 @@ bool CMapLocation::Get(int iIndex, long & lAddr, WORD & wPort) return true; } -void CMapLocation::Insert(long lIndex, const char * c_pszHost, WORD wPort) +void CMapLocation::Insert(int lIndex, const char * c_pszHost, WORD wPort) { TLocation loc; diff --git a/game/src/map_location.h b/game/src/map_location.h index f5009cc..ce5c1e8 100644 --- a/game/src/map_location.h +++ b/game/src/map_location.h @@ -6,15 +6,15 @@ class CMapLocation : public singleton public: typedef struct SLocation { - long addr; + int addr; WORD port; } TLocation; - bool Get(long x, long y, long & lMapIndex, long & lAddr, WORD & wPort); - bool Get(int iIndex, long & lAddr, WORD & wPort); - void Insert(long lIndex, const char * c_pszHost, WORD wPort); + bool Get(int x, int y, int& lMapIndex, LONG & lAddr, WORD & wPort); + bool Get(int iIndex, LONG & lAddr, WORD & wPort); + void Insert(int lIndex, const char * c_pszHost, WORD wPort); protected: - std::map m_map_address; + std::map m_map_address; }; diff --git a/game/src/marriage.cpp b/game/src/marriage.cpp index 9544db9..48e6b9e 100644 --- a/game/src/marriage.cpp +++ b/game/src/marriage.cpp @@ -602,7 +602,7 @@ namespace marriage db_clientdesc->DBPacket(HEADER_GD_MARRIAGE_UPDATE, 0, &p, sizeof(p)); } - void CManager::Update(DWORD dwPID1, DWORD dwPID2, long lTotalPoint, BYTE byMarried) + void CManager::Update(DWORD dwPID1, DWORD dwPID2, int lTotalPoint, BYTE byMarried) { TMarriage* pMarriage = Get(dwPID1); diff --git a/game/src/marriage.h b/game/src/marriage.h index 08d48cb..e895ffb 100644 --- a/game/src/marriage.h +++ b/game/src/marriage.h @@ -106,7 +106,7 @@ namespace marriage void Add(DWORD dwPID1, DWORD dwPID2, time_t tMarryTime, const char* szName1, const char* szName2); void RequestUpdate(DWORD dwPID1, DWORD dwPID2, int iUpdatePoint, BYTE byMarried); - void Update(DWORD dwPID1, DWORD dwPID2, long lTotalPoint, BYTE byMarried); + void Update(DWORD dwPID1, DWORD dwPID2, int lTotalPoint, BYTE byMarried); void RequestRemove(DWORD dwPID1, DWORD dwPID2); void Remove(DWORD dwPID1, DWORD dwPID2); diff --git a/game/src/matrix_card.cpp b/game/src/matrix_card.cpp index c65447c..a9d47a2 100644 --- a/game/src/matrix_card.cpp +++ b/game/src/matrix_card.cpp @@ -74,16 +74,16 @@ bool DecodeMatrix(const char* szsrc, const char* szpwd, char* lpdes, const unsig return (i == nlen) ? true : false; } -void MatrixCardRndCoordinate(unsigned long & rows, unsigned long & cols) +void MatrixCardRndCoordinate(unsigned int & rows, unsigned int & cols) { - for (register unsigned long i = 0; i < (ASLENGTH >> 1); i++) + for (register unsigned int i = 0; i < (ASLENGTH >> 1); i++) { rows |= ((thecore_random() % MAX_ROWS) & 0x000000FF) << ((4 - i - 1) * 8); cols |= ((thecore_random() % MAX_COLS) & 0x000000FF) << ((4 - i - 1) * 8); } } -bool ChkCoordinate(const unsigned long rows, const unsigned long cols, const char* matrix, const char* answer) +bool ChkCoordinate(const unsigned int rows, const unsigned int cols, const char* matrix, const char* answer) { unsigned int max_lens = strlen(matrix); int answer_lens = strlen(answer); @@ -99,7 +99,7 @@ bool ChkCoordinate(const unsigned long rows, const unsigned long cols, const cha unsigned short * pmatrix = (unsigned short *)matrix; unsigned short * panswer = (unsigned short *)answer; - for (register unsigned long i = 0; i < (ASLENGTH >> 1); i++) + for (register unsigned int i = 0; i < (ASLENGTH >> 1); i++) { if (*(pmatrix + (ROW(rows, i) * MAX_COLS + COL(cols, i))) != *(panswer + i)) { @@ -111,7 +111,7 @@ bool ChkCoordinate(const unsigned long rows, const unsigned long cols, const cha return fResult; } -bool MatrixCardCheck(const char * src, const char * answer, unsigned long rows, unsigned cols) +bool MatrixCardCheck(const char * src, const char * answer, unsigned int rows, unsigned cols) { const char * szpasswd = "xEwx3Lb5fH2mnPaMh215cHTbCrFCSmh9yQ3FrybwPnD89QkNX4UTA8UdH41LnU4P94UnaeXDTk17dY5DLaSDPAwvEpMUNTxV"; @@ -134,7 +134,7 @@ bool MatrixCardCheck(const char * src, const char * answer, unsigned long rows, #ifdef __MATRIX_MAIN_ENABLE__ -void GetRightAnswer(const unsigned long rows, const unsigned long cols, const char* matrix, char* answer, const unsigned int nsize) +void GetRightAnswer(const unsigned int rows, const unsigned int cols, const char* matrix, char* answer, const unsigned int nsize) { if (strlen(matrix) != MAX_LENS || answer == NULL || nsize < (ASLENGTH + 1)) return; @@ -144,7 +144,7 @@ void GetRightAnswer(const unsigned long rows, const unsigned long cols, const ch memset(answer, 0, nsize); - for (register unsigned long i = 0; i < (ASLENGTH >> 1); i++) + for (register unsigned int i = 0; i < (ASLENGTH >> 1); i++) { char sztemp[3] = { 0, 0, 0 }; memcpy(sztemp, (char*)(pmatrix + (ROW(rows, i) * MAX_COLS + COL(cols, i))), 2); @@ -168,7 +168,7 @@ int main(int argc, char* argv[]) printf("Decode result: %s\r\n", decode_result); // matrix rand password test - unsigned long rand_rows = 0, rand_cols = 0; + unsigned int rand_rows = 0, rand_cols = 0; MatrixCardRndCoordinate(rand_rows, rand_cols); // get rand position of matrix // display rand position diff --git a/game/src/matrix_card.h b/game/src/matrix_card.h index 02dedfd..b61dd0e 100644 --- a/game/src/matrix_card.h +++ b/game/src/matrix_card.h @@ -1,8 +1,8 @@ #ifndef __INC_DB_MATRIXCARD_H__ #define __INC_DB_MATRIXCARD_H__ -extern bool MatrixCardCheck(const char * src, const char * answer, unsigned long rows, unsigned cols); -extern void MatrixCardRndCoordinate(unsigned long & rows, unsigned long & cols); +extern bool MatrixCardCheck(const char * src, const char * answer, unsigned int rows, unsigned cols); +extern void MatrixCardRndCoordinate(unsigned int & rows, unsigned int & cols); #define MATRIX_CARD_ROW(rows, i) ((rows >> ((4 - i - 1) * 8)) & 0x000000FF) #define MATRIX_CARD_COL(cols, i) ((cols >> ((4 - i - 1) * 8)) & 0x000000FF) diff --git a/game/src/messenger_manager.cpp b/game/src/messenger_manager.cpp index 9fc94bf..ead3f8a 100644 --- a/game/src/messenger_manager.cpp +++ b/game/src/messenger_manager.cpp @@ -323,7 +323,7 @@ void MessengerManager::SendList(MessengerManager::keyA account) pack.size += buf.size(); - d->BufferedPacket(&pack, sizeof(TPacketGCMessenger)); + d->RawPacket(&pack, sizeof(TPacketGCMessenger)); d->Packet(buf.read_peek(), buf.size()); } @@ -349,8 +349,8 @@ void MessengerManager::SendLogin(MessengerManager::keyA account, MessengerManage pack.subheader = MESSENGER_SUBHEADER_GC_LOGIN; pack.size = sizeof(TPacketGCMessenger) + sizeof(BYTE) + bLen; - d->BufferedPacket(&pack, sizeof(TPacketGCMessenger)); - d->BufferedPacket(&bLen, sizeof(BYTE)); + d->RawPacket(&pack, sizeof(TPacketGCMessenger)); + d->RawPacket(&bLen, sizeof(BYTE)); d->Packet(companion.c_str(), companion.size()); } @@ -373,8 +373,8 @@ void MessengerManager::SendLogout(MessengerManager::keyA account, MessengerManag pack.subheader = MESSENGER_SUBHEADER_GC_LOGOUT; pack.size = sizeof(TPacketGCMessenger) + sizeof(BYTE) + bLen; - d->BufferedPacket(&pack, sizeof(TPacketGCMessenger)); - d->BufferedPacket(&bLen, sizeof(BYTE)); + d->RawPacket(&pack, sizeof(TPacketGCMessenger)); + d->RawPacket(&bLen, sizeof(BYTE)); d->Packet(companion.c_str(), companion.size()); } diff --git a/game/src/motion.cpp b/game/src/motion.cpp index 9089eaa..83319b4 100644 --- a/game/src/motion.cpp +++ b/game/src/motion.cpp @@ -56,7 +56,7 @@ static float MOB_GetNormalAttackDuration(TMobTable* mobTable) sscanf(line, "%s %s %s %d", mode, type, msaName, &percent); if (strcmp(mode, "GENERAL") == 0 && strncmp(type, "NORMAL_ATTACK", 13) == 0) { - char msaPath[1024]; + char msaPath[4096]; snprintf(msaPath, sizeof(msaPath), "data/monster/%s/%s", folder, msaName); float curDuration = MSA_GetNormalAttackDuration(msaPath); if (curDuration < minDuration) diff --git a/game/src/p2p.cpp b/game/src/p2p.cpp index 7b09a6e..36e9c33 100644 --- a/game/src/p2p.cpp +++ b/game/src/p2p.cpp @@ -279,7 +279,7 @@ void P2P_MANAGER::GetP2PHostNames(std::string& hostNames) { LPDESC pkDesc = *it++; - oss << pkDesc->GetP2PHost() << " " << pkDesc->GetP2PPort() << "\n"; + oss << pkDesc->GetHostName() << " " << pkDesc->GetP2PPort() << "\n"; } hostNames += oss.str(); diff --git a/game/src/p2p.h b/game/src/p2p.h index a4c0baa..0db231c 100644 --- a/game/src/p2p.h +++ b/game/src/p2p.h @@ -12,7 +12,7 @@ typedef struct _CCI char szName[CHARACTER_NAME_MAX_LEN + 1]; DWORD dwPID; BYTE bEmpire; - long lMapIndex; + int lMapIndex; BYTE bChannel; LPDESC pkDesc; diff --git a/game/src/packet.h b/game/src/packet.h index ab0e230..2c45949 100644 --- a/game/src/packet.h +++ b/game/src/packet.h @@ -6,7 +6,6 @@ enum HEADER_CG_HANDSHAKE = 0xff, HEADER_CG_PONG = 0xfe, HEADER_CG_TIME_SYNC = 0xfc, - HEADER_CG_KEY_AGREEMENT = 0xfb, // _IMPROVED_PACKET_ENCRYPTION_ HEADER_CG_LOGIN = 1, HEADER_CG_ATTACK = 2, @@ -94,9 +93,6 @@ enum // HEADER_CG_ROULETTE = 200, // HEADER_CG_RUNUP_MATRIX_ANSWER = 201, - // - HEADER_CG_PASSPOD_ANSWER = 202, - //NOTE : ÀÌ·± °³XXX Á¤¸» ÀÌ°Å Packet¼³°èÇÑ »ç¶÷Àº ´©±¸³Ä. ÀÌ·¸°Ô ÄÚµùÇÏ°í ¹äÀÌ ³Ñ¾î°¡³ª. //enumÀ» º°µµ·Î ±¸º°À» ÇÏ´ø°¡. ¾Æ´Ô namepsace·Î ±¸º°À» ÇÏ´ø°¡.. //Á¤¸» packet generator±îÁö´Â ¹Ù¶óÁöµµ ¾Ê´Â´Ù. ÀÌ·± ¾¾XX @@ -109,8 +105,6 @@ enum HEADER_CG_CLIENT_VERSION2 = 0xf1, /********************************************************/ - HEADER_GC_KEY_AGREEMENT_COMPLETED = 0xfa, // _IMPROVED_PACKET_ENCRYPTION_ - HEADER_GC_KEY_AGREEMENT = 0xfb, // _IMPROVED_PACKET_ENCRYPTION_ HEADER_GC_TIME_SYNC = 0xfc, HEADER_GC_PHASE = 0xfd, HEADER_GC_HANDSHAKE = 0xff, @@ -277,8 +271,6 @@ enum HEADER_GC_ROULETTE = 200, // END_ROULETTE // - HEADER_GC_REQUEST_PASSPOD = 202, - HEADER_GC_REQUEST_PASSPOD_FAILED = 203, HEADER_GC_SPECIFIC_EFFECT = 208, @@ -334,7 +326,7 @@ typedef struct SPacketGGLogin char szName[CHARACTER_NAME_MAX_LEN + 1]; DWORD dwPID; BYTE bEmpire; - long lMapIndex; + LONG lMapIndex; BYTE bChannel; } TPacketGGLogin; @@ -348,20 +340,20 @@ typedef struct SPacketGGRelay { BYTE bHeader; char szName[CHARACTER_NAME_MAX_LEN + 1]; - long lSize; + LONG lSize; } TPacketGGRelay; typedef struct SPacketGGNotice { BYTE bHeader; - long lSize; + LONG lSize; } TPacketGGNotice; typedef struct SPacketGGMonarchNotice { BYTE bHeader; BYTE bEmpire; - long lSize; + LONG lSize; } TPacketGGMonarchNotice; //FORKED_ROAD @@ -431,7 +423,7 @@ typedef struct SPacketGGXmasWarpSanta { BYTE bHeader; BYTE bChannel; - long lMapIndex; + LONG lMapIndex; } TPacketGGXmasWarpSanta; typedef struct SPacketGGXmasWarpSantaReply @@ -470,8 +462,8 @@ typedef struct SPacketGGWarpCharacter { BYTE header; DWORD pid; - long x; - long y; + LONG x; + LONG y; } TPacketGGWarpCharacter; // HEADER_GG_GUILD_WAR_ZONE_MAP_INDEX = 15, @@ -481,14 +473,14 @@ typedef struct SPacketGGGuildWarMapIndex BYTE bHeader; DWORD dwGuildID1; DWORD dwGuildID2; - long lMapIndex; + LONG lMapIndex; } TPacketGGGuildWarMapIndex; typedef struct SPacketGGTransfer { BYTE bHeader; char szName[CHARACTER_NAME_MAX_LEN + 1]; - long lX, lY; + LONG lX, lY; } TPacketGGTransfer; typedef struct SPacketGGLoginPing @@ -501,7 +493,7 @@ typedef struct SPacketGGBlockChat { BYTE bHeader; char szName[CHARACTER_NAME_MAX_LEN + 1]; - long lBlockDuration; + LONG lBlockDuration; } TPacketGGBlockChat; /* Ŭ¶óÀ̾ðÆ® Ãø¿¡¼­ º¸³»´Â ÆÐŶ */ @@ -517,7 +509,7 @@ typedef struct command_handshake BYTE bHeader; DWORD dwHandshake; DWORD dwTime; - long lDelta; + LONG lDelta; } TPacketCGHandshake; typedef struct command_login @@ -624,16 +616,16 @@ typedef struct command_move BYTE bFunc; BYTE bArg; BYTE bRot; - long lX; - long lY; + LONG lX; + LONG lY; DWORD dwTime; } TPacketCGMove; typedef struct command_sync_position_element { DWORD dwVID; - long lX; - long lY; + LONG lX; + LONG lY; } TPacketCGSyncPositionElement; // À§Ä¡ µ¿±âÈ­ @@ -794,7 +786,7 @@ typedef struct command_script_answer typedef struct command_script_button { BYTE header; - unsigned int idx; + UINT idx; } TPacketCGScriptButton; typedef struct command_quest_input_string @@ -817,7 +809,7 @@ typedef struct packet_quest_confirm { BYTE header; char msg[64+1]; - long timeout; + LONG timeout; DWORD requestPID; } TPacketGCQuestConfirm; @@ -826,7 +818,7 @@ typedef struct packet_handshake BYTE bHeader; DWORD dwHandshake; DWORD dwTime; - long lDelta; + LONG lDelta; } TPacketGCHandshake; enum EPhase @@ -844,7 +836,6 @@ enum EPhase PHASE_P2P, PHASE_AUTH, PHASE_TEEN, - PHASE_PASSPOD, }; typedef struct packet_phase @@ -918,9 +909,9 @@ typedef struct packet_add_char DWORD dwVID; float angle; - long x; - long y; - long z; + LONG x; + LONG y; + LONG z; BYTE bType; WORD wRaceNum; @@ -1013,7 +1004,7 @@ typedef struct packet_main_character DWORD dwVID; WORD wRaceNum; char szName[CHARACTER_NAME_MAX_LEN + 1]; - long lx, ly, lz; + LONG lx, ly, lz; BYTE empire; BYTE skill_group; } TPacketGCMainCharacter; @@ -1031,7 +1022,7 @@ typedef struct packet_main_character3_bgm WORD wRaceNum; char szChrName[CHARACTER_NAME_MAX_LEN + 1]; char szBGMName[MUSIC_NAME_LEN + 1]; - long lx, ly, lz; + LONG lx, ly, lz; BYTE empire; BYTE skill_group; } TPacketGCMainCharacter3_BGM; @@ -1049,7 +1040,7 @@ typedef struct packet_main_character4_bgm_vol char szChrName[CHARACTER_NAME_MAX_LEN + 1]; char szBGMName[MUSIC_NAME_LEN + 1]; float fBGMVol; - long lx, ly, lz; + LONG lx, ly, lz; BYTE empire; BYTE skill_group; } TPacketGCMainCharacter4_BGM_VOL; @@ -1069,11 +1060,11 @@ typedef struct packet_skill_level typedef struct packet_point_change { - int header; + INT header; DWORD dwVID; BYTE type; - long amount; - long value; + LONG amount; + LONG value; } TPacketGCPointChange; typedef struct packet_stun @@ -1094,7 +1085,7 @@ struct TPacketGCItemDelDeprecated TItemPos Cell; DWORD vnum; BYTE count; - long alSockets[ITEM_SOCKET_MAX_NUM]; + LONG alSockets[ITEM_SOCKET_MAX_NUM]; TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM]; }; @@ -1107,7 +1098,7 @@ typedef struct packet_item_set DWORD flags; DWORD anti_flags; bool highlight; - long alSockets[ITEM_SOCKET_MAX_NUM]; + LONG alSockets[ITEM_SOCKET_MAX_NUM]; TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM]; } TPacketGCItemSet; @@ -1138,14 +1129,14 @@ typedef struct packet_item_update BYTE header; TItemPos Cell; BYTE count; - long alSockets[ITEM_SOCKET_MAX_NUM]; + LONG alSockets[ITEM_SOCKET_MAX_NUM]; TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM]; } TPacketGCItemUpdate; typedef struct packet_item_ground_add { BYTE bHeader; - long x, y, z; + LONG x, y, z; DWORD dwVID; DWORD dwVnum; } TPacketGCItemGroundAdd; @@ -1213,7 +1204,7 @@ struct packet_shop_item DWORD price; BYTE count; BYTE display_pos; - long alSockets[ITEM_SOCKET_MAX_NUM]; + LONG alSockets[ITEM_SOCKET_MAX_NUM]; TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM]; }; @@ -1243,7 +1234,7 @@ typedef struct packet_shop_update_item typedef struct packet_shop_update_price { - int iPrice; + INT iPrice; } TPacketGCShopUpdatePrice; typedef struct packet_shop // °¡º¯ ÆÐŶ @@ -1261,7 +1252,7 @@ struct packet_exchange DWORD arg1; // vnum TItemPos arg2; // cell DWORD arg3; // count - long alSockets[ITEM_SOCKET_MAX_NUM]; + LONG alSockets[ITEM_SOCKET_MAX_NUM]; TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM]; }; @@ -1320,8 +1311,8 @@ typedef struct packet_move BYTE bArg; BYTE bRot; DWORD dwVID; - long lX; - long lY; + LONG lX; + LONG lY; DWORD dwTime; DWORD dwDuration; } TPacketGCMove; @@ -1338,8 +1329,8 @@ typedef struct packet_ownership typedef struct packet_sync_position_element { DWORD dwVID; - long lX; - long lY; + LONG lX; + LONG lY; } TPacketGCSyncPositionElement; // À§Ä¡ µ¿±âÈ­ @@ -1361,7 +1352,7 @@ typedef struct command_fly_targeting { BYTE bHeader; DWORD dwTargetVID; - long x, y; + LONG x, y; } TPacketCGFlyTargeting; typedef struct packet_fly_targeting @@ -1369,7 +1360,7 @@ typedef struct packet_fly_targeting BYTE bHeader; DWORD dwShooterVID; DWORD dwTargetVID; - long x, y; + LONG x, y; } TPacketGCFlyTargeting; typedef struct packet_shoot @@ -1423,9 +1414,9 @@ typedef struct packet_target typedef struct packet_warp { BYTE bHeader; - long lX; - long lY; - long lAddr; + LONG lX; + LONG lY; + LONG lAddr; WORD wPort; } TPacketGCWarp; @@ -1665,13 +1656,13 @@ typedef struct command_safebox_money { BYTE bHeader; BYTE bState; - long lMoney; + LONG lMoney; } TPacketCGSafeboxMoney; typedef struct packet_safebox_money_change { BYTE bHeader; - long lMoney; + LONG lMoney; } TPacketGCSafeboxMoneyChange; // Guild @@ -1878,8 +1869,8 @@ typedef struct packet_dungeon typedef struct packet_dungeon_dest_position { - long x; - long y; + LONG x; + LONG y; } TPacketGCDungeonDestPosition; typedef struct SPacketGCShopSign @@ -1942,8 +1933,8 @@ typedef struct SPacketGCRefineInformaion DWORD src_vnum; DWORD result_vnum; BYTE material_count; - int cost; // ¼Ò¿ä ºñ¿ë - int prob; // È®·ü + INT cost; // ¼Ò¿ä ºñ¿ë + INT prob; // È®·ü TRefineMaterial materials[REFINE_MATERIAL_MAX_NUM]; } TPacketGCRefineInformation; @@ -1951,8 +1942,8 @@ struct TNPCPosition { BYTE bType; char name[CHARACTER_NAME_MAX_LEN+1]; - long x; - long y; + LONG x; + LONG y; }; typedef struct SPacketGCNPCPosition @@ -2013,7 +2004,7 @@ typedef struct pakcet_view_equip struct { DWORD vnum; BYTE count; - long alSockets[ITEM_SOCKET_MAX_NUM]; + LONG alSockets[ITEM_SOCKET_MAX_NUM]; TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM]; } equips[WEAR_MAX_NUM]; } TPacketViewEquip; @@ -2021,8 +2012,8 @@ typedef struct pakcet_view_equip typedef struct { DWORD dwID; - long x, y; - long width, height; + LONG x, y; + LONG width, height; DWORD dwGuildID; } TLandPacketElement; @@ -2035,7 +2026,7 @@ typedef struct packet_land_list typedef struct { BYTE bHeader; - long lID; + LONG lID; char szName[32+1]; DWORD dwVID; BYTE bType; @@ -2044,14 +2035,14 @@ typedef struct typedef struct { BYTE bHeader; - long lID; - long lX, lY; + LONG lID; + LONG lX, lY; } TPacketGCTargetUpdate; typedef struct { BYTE bHeader; - long lID; + LONG lID; } TPacketGCTargetDelete; typedef struct @@ -2103,7 +2094,7 @@ typedef struct packet_damage_info BYTE header; DWORD dwVID; BYTE flag; - int damage; + INT damage; } TPacketGCDamageInfo; enum @@ -2125,18 +2116,6 @@ typedef struct command_runup_matrix_answer char szAnswer[RUNUP_MATRIX_ANSWER_MAX_LEN + 1]; } TPacketCGRunupMatrixAnswer; -typedef struct packet_passpod -{ - BYTE bHeader; - char szAnswer[8+1]; -} TPacketCGPasspod; - -typedef struct packet_passpod_failed -{ - BYTE bHeader; - char szMessage[128]; -} TPacketCGPasspodFailed; - typedef struct tag_GGSiege { BYTE bHeader; @@ -2148,14 +2127,14 @@ typedef struct SPacketGGMonarchTransfer { BYTE bHeader; DWORD dwTargetPID; - long x; - long y; + LONG x; + LONG y; } TPacketMonarchGGTransfer; typedef struct SPacketGGPCBangUpdate { BYTE bHeader; - unsigned long ulPCBangID; + ULONG ulPCBangID; } TPacketPCBangUpdate; typedef struct SPacketGGCheckAwakeness @@ -2186,7 +2165,7 @@ typedef struct SPacketGCHybridCryptKeys DWORD GetStreamSize() { - return sizeof(bHeader) + sizeof(WORD) + sizeof(int) + KeyStreamLen; + return sizeof(bHeader) + sizeof(WORD) + sizeof(INT) + KeyStreamLen; } BYTE* GetStreamData() @@ -2210,7 +2189,7 @@ typedef struct SPacketGCHybridCryptKeys BYTE bHeader; WORD uDynamicPacketSize; // ºô¾î¸ÔÀ» Ŭ¶ó DynamicPacketHeader ±¸Á¶¶§¹®¿¡ ¸ÂÃçÁà¾ßÇÑ´Ù -_-; - int KeyStreamLen; + INT KeyStreamLen; BYTE* pDataKeyStream; private: @@ -2234,7 +2213,7 @@ typedef struct SPacketGCPackageSDB DWORD GetStreamSize() { - return sizeof(bHeader) + sizeof(WORD) + sizeof(int) + iStreamLen; + return sizeof(bHeader) + sizeof(WORD) + sizeof(INT) + iStreamLen; } BYTE* GetStreamData() @@ -2258,7 +2237,7 @@ typedef struct SPacketGCPackageSDB BYTE bHeader; WORD uDynamicPacketSize; // ºô¾î¸ÔÀ» Ŭ¶ó DynamicPacketHeader ±¸Á¶¶§¹®¿¡ ¸ÂÃçÁà¾ßÇÑ´Ù -_-; - int iStreamLen; + INT iStreamLen; BYTE* m_pDataSDBStream; private: @@ -2267,24 +2246,6 @@ private: } TPacketGCPackageSDB; -#ifdef _IMPROVED_PACKET_ENCRYPTION_ -struct TPacketKeyAgreement -{ - static const int MAX_DATA_LEN = 256; - BYTE bHeader; - WORD wAgreedLength; - WORD wDataLength; - BYTE data[MAX_DATA_LEN]; -}; - -struct TPacketKeyAgreementCompleted -{ - BYTE bHeader; - BYTE data[3]; // dummy (not used) -}; - -#endif // _IMPROVED_PACKET_ENCRYPTION_ - #define MAX_EFFECT_FILE_NAME 128 typedef struct SPacketGCSpecificEffect { @@ -2337,15 +2298,15 @@ typedef struct SPacketGCDragonSoulRefine typedef struct SPacketCGStateCheck { BYTE header; - unsigned long key; - unsigned long index; + ULONG key; + ULONG index; } TPacketCGStateCheck; typedef struct SPacketGCStateCheck { BYTE header; - unsigned long key; - unsigned long index; + ULONG key; + ULONG index; unsigned char state; } TPacketGCStateCheck; diff --git a/game/src/packet_info.cpp b/game/src/packet_info.cpp index c65b52a..2ee3fb4 100644 --- a/game/src/packet_info.cpp +++ b/game/src/packet_info.cpp @@ -137,9 +137,6 @@ CPacketInfoCG::CPacketInfoCG() Set(HEADER_CG_MARK_IDXLIST, sizeof(TPacketCGMarkIDXList), "MarkIdxList", false); Set(HEADER_CG_MARK_CRCLIST, sizeof(TPacketCGMarkCRCList), "MarkCrcList", false); Set(HEADER_CG_MARK_UPLOAD, sizeof(TPacketCGMarkUpload), "MarkUpload", false); -#ifdef _IMPROVED_PACKET_ENCRYPTION_ - Set(HEADER_CG_KEY_AGREEMENT, sizeof(TPacketKeyAgreement), "KeyAgreement", false); -#endif Set(HEADER_CG_GUILD_SYMBOL_UPLOAD, sizeof(TPacketCGGuildSymbolUpload), "SymbolUpload", false); Set(HEADER_CG_SYMBOL_CRC, sizeof(TPacketCGSymbolCRC), "SymbolCRC", false); @@ -218,7 +215,6 @@ CPacketInfoCG::CPacketInfoCG() Set(HEADER_CG_MALL_CHECKOUT, sizeof(TPacketCGSafeboxCheckout), "MallCheckout", true); Set(HEADER_CG_SCRIPT_SELECT_ITEM, sizeof(TPacketCGScriptSelectItem), "ScriptSelectItem", true); - Set(HEADER_CG_PASSPOD_ANSWER, sizeof(TPacketCGPasspod), "PasspodAnswer", true); Set(HEADER_CG_DRAGON_SOUL_REFINE, sizeof(TPacketCGDragonSoulRefine), "DragonSoulRefine", false); Set(HEADER_CG_STATE_CHECKER, sizeof(BYTE), "ServerStateCheck", false); diff --git a/game/src/panama.cpp b/game/src/panama.cpp index 04f76a4..8abd026 100644 --- a/game/src/panama.cpp +++ b/game/src/panama.cpp @@ -19,7 +19,7 @@ size_t PanamaLoad() while (fgets(buf, 256, fp)) { char szPackName[256]; - char szIVFileName[256]; + char szIVFileName[512]; char szIVFileNameConfig[256]; sscanf(buf, " %s %s ", szPackName, szIVFileNameConfig); diff --git a/game/src/party.cpp b/game/src/party.cpp index 57ea1fb..7b6f5a6 100644 --- a/game/src/party.cpp +++ b/game/src/party.cpp @@ -1182,7 +1182,7 @@ void CParty::IncreaseOwnership() } } -LPCHARACTER CParty::GetNextOwnership(LPCHARACTER ch, long x, long y) +LPCHARACTER CParty::GetNextOwnership(LPCHARACTER ch, int x, int y) { if (m_itNextOwner == m_memberMap.end()) return ch; diff --git a/game/src/party.h b/game/src/party.h index a15cc09..809bdc8 100644 --- a/game/src/party.h +++ b/game/src/party.h @@ -156,8 +156,8 @@ class CParty template void ForEachMemberPtr(Func & f); template void ForEachOnlineMember(Func & f); template void ForEachNearMember(Func & f); - template void ForEachOnMapMember (Func & f, long lMapIndex); - template bool ForEachOnMapMemberBool (Func & f, long lMapIndex); + template void ForEachOnMapMember (Func & f, int lMapIndex); + template bool ForEachOnMapMemberBool (Func & f, int lMapIndex); void Update(); @@ -177,7 +177,7 @@ class CParty void SetPCParty(bool b) { m_bPCParty = b; } - LPCHARACTER GetNextOwnership(LPCHARACTER ch, long x, long y); + LPCHARACTER GetNextOwnership(LPCHARACTER ch, int x, int y); void SetFlag(const std::string& name, int value); int GetFlag(const std::string& name); @@ -289,7 +289,7 @@ template void CParty::ForEachNearMember(Func & f) f(it->second.pCharacter); } -template void CParty::ForEachOnMapMember (Func & f, long lMapIndex) +template void CParty::ForEachOnMapMember (Func & f, int lMapIndex) { TMemberMap::iterator it; @@ -304,7 +304,7 @@ template void CParty::ForEachOnMapMember (Func & f, long lMapIndex) } } -template bool CParty::ForEachOnMapMemberBool(Func & f, long lMapIndex) +template bool CParty::ForEachOnMapMemberBool(Func & f, int lMapIndex) { TMemberMap::iterator it; diff --git a/game/src/passpod.cpp b/game/src/passpod.cpp deleted file mode 100644 index f94e2fc..0000000 --- a/game/src/passpod.cpp +++ /dev/null @@ -1,196 +0,0 @@ -#include "stdafx.h" -#include "constants.h" -#include "passpod.h" - -extern BOOL g_test_server; -extern int test_server; -const char ERR_STRINGS[6][32] = -{ - "AUTH_SUCCESS" , - "AUTH_FAILURE:PASSPOD_ERROR" , - "AUTH_FAILURE:USER_NOT_FOUND" , - "AUTH_FAILURE:SYSTEM_NOT_FOUND" , - "AUTH_FAILURE:TOKEN_DISABLED" , - "AUTH_FAILURE:EMPTY", -}; - -const char ERR_MESSAGE[6][64] = -{ - "SUCCESS", - "PASERR1", - "PASERR2", - "PASERR3", - "PASERR4", - "PASERR5" -}; - -CPasspod::CPasspod() - : m_sock(INVALID_SOCKET), m_lpFDW(NULL) -{ -} - - -CPasspod::~CPasspod() -{ -} - -int CPasspod::ConfirmPasspod( const char * account, const char * passpod ) -{ - const char * servername = "1001"; - const char * algname = "plaintext"; - const char * posspod_server = "/passpod-server"; - const char * auth = "/auth.s"; - - - char szRequest[1024]; - char szResult[1024]; - char szTmp[128]; - - int ret_code = 1; // 0 ÀÌ ¼º°ø - - 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" ); - 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)); - strncat( szResult, szTmp, sizeof(szResult) ); - strncat( szResult, "Connection: Close\r\n\r\n", sizeof(szResult) ); - strncat( szResult, szRequest, sizeof(szResult) ); - - if ( !Connect( NULL ) ) - { - sys_log( 0, "PASSPOD : Can not connect to passpod server" ); - Disconnect(); - return ret_code; - } - - int ret = socket_write( m_sock, (const char *)szResult, strlen(szResult)); - - sys_log( 0, "PASSPOD : Write End %s %s", account, passpod ); - if ( test_server ) - { - sys_log( 0, "PASSPOD : %s", szResult ); - - } - char Read[1024]; - int nCount = 5; - while (--nCount) - { - ret = recv(m_sock, Read, 1024, 0); - - if ( ret > 0 ) - { - if ( test_server ) - { - sys_log( 0, "PASSPOD : %d", ret ); - } - break; - } - else - { - if ( test_server ) - { - sys_log( 0, "PASSPOD : %d", ret ); - } - Disconnect(); - return ret_code; - } - } - sys_log( 0, "PASSPOD : Read End %s %s \n %s\n", account, passpod, Read ); - - char * pos = Read; - nCount = 15; - while ( --nCount ) - { - int n = 0; - - //¶óÀγѱâ±â - for (; pos[n]!='\n'; ++n ) {} - - //\n¿¡¼­ ¸ØÃß±â Çϳª´õ ³²°ÜÁÖÀÚ - pos = pos+n+1; - - - //Return Value ¸¦ ºñ±³ - if ( 0 == strncmp( pos, "AUTH_SUCCESS", strlen(ERR_STRINGS[0]) ) ) - { - ret_code = E_PASSPOD_SUCCESS; - break; - } - if ( 0 == strncmp( pos, "AUTH_FAILURE:PASSPOD_ERROR", strlen(ERR_STRINGS[1]) ) ) - { - ret_code = E_PASSPOD_FAILED_PASSPOD_ERROR; - break; - } - if ( 0 == strncmp( pos, "AUTH_FAILURE:USER_NOT_FOUND", strlen(ERR_STRINGS[2] ) ) ) - { - ret_code = E_PASSPOD_FAILED_USER_NOT_FOUND; - break; - } - if ( 0 == strncmp( pos, "AUTH_FAILURE:SYSTEM_NOT_FOUND", strlen(ERR_STRINGS[3] ) ) ) - { - ret_code = E_PASSPOD_FAILED_SYSTEM_NOT_FOUND; - break; - } - if ( 0 == strncmp( pos, "AUTH_FAILURE:TOKEN_DISABLED", strlen(ERR_STRINGS[4] ) ) ) - { - ret_code = E_PASSPOD_FAILED_TOKEN_DISABLED; - break; - } - if ( 0 == strncmp( pos, "AUTH_FAILURE:EMPTY", strlen(ERR_STRINGS[5] ) ) ) - { - ret_code = E_PASSPOD_FAILED_EMPTY; - break; - } - - } - - sys_log(0, "PASSPOD Ret Value = %s ", ERR_STRINGS[ret_code] ); - - - this->Disconnect(); - return ret_code; - -} - -bool CPasspod::Connect( LPFDWATCH fdw ) -{ - -// m_lpFDW = fdw; - - if ( m_sock != INVALID_SOCKET ) - { - sys_err( "Sock != INVALID_SOCKET " ); - return false; - } - - m_sock = socket_connect( "218.99.6.103", 8080 ); - - if ( m_sock == INVALID_SOCKET ) - { - sys_err( "Sock == INVALID_SOCKET " ); - return false; - } - - - - //fdwatch_add_fd( m_lpFDW, m_sock, this, FDW_READ, false ); - //fdwatch_add_fd( m_lpFDW, m_sock, this, FDW_WRITE, false ); - - - return true; -} - -bool CPasspod::Disconnect() -{ - //fdwatch_del_fd( m_lpFDW, m_sock ); - socket_close(m_sock); - m_sock = INVALID_SOCKET; - return true; -} - -bool CPasspod::IConv( const char * src, char * desc ) -{ - return true; -} diff --git a/game/src/passpod.h b/game/src/passpod.h deleted file mode 100644 index f8a03cc..0000000 --- a/game/src/passpod.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef PASSPOD_H -#define PASSPOD_H - -class CPasspod : public singleton -{ -public: - CPasspod(); - ~CPasspod(); - - int ConfirmPasspod( const char * account,const char* passpod ); - bool Connect( LPFDWATCH fdw ); - bool Disconnect(); - - -private: - bool IConv( const char * src, char * desc ); - - -private: - - socket_t m_sock; - LPFDWATCH m_lpFDW; -}; - -extern const char ERR_STRINGS[6][32]; -extern const char ERR_MESSAGE[6][64]; - -#endif diff --git a/game/src/pcbang.h b/game/src/pcbang.h index 57131e3..d6ebd91 100644 --- a/game/src/pcbang.h +++ b/game/src/pcbang.h @@ -1,6 +1,6 @@ -typedef unsigned long PCBang_IP; -typedef unsigned long PCBang_ID; +typedef unsigned int PCBang_IP; +typedef unsigned int PCBang_ID; class CPCBangManager : public singleton { diff --git a/game/src/profiler.h b/game/src/profiler.h index b074c46..a53964f 100644 --- a/game/src/profiler.h +++ b/game/src/profiler.h @@ -15,8 +15,8 @@ class CProfiler : public singleton typedef struct SProfileStackData { int iCallStep; - long iStartTime; - long iEndTime; + int iStartTime; + int iEndTime; std::string strName; } TProfileStackData; @@ -165,7 +165,7 @@ class CProfiler : public singleton for (int i = 0; i < rProfileStackData.iCallStep; ++i) fprintf(fp, "\t"); - fprintf(fp, "%-24s: %lu\n", rProfileStackData.strName.c_str(), rProfileStackData.iEndTime - rProfileStackData.iStartTime); + fprintf(fp, "%-24s: %d\n", rProfileStackData.strName.c_str(), rProfileStackData.iEndTime - rProfileStackData.iStartTime); } fprintf(fp, "Name Call/Load Ratio\n"); diff --git a/game/src/protocol.h b/game/src/protocol.h index 58e85d8..c1725ce 100644 --- a/game/src/protocol.h +++ b/game/src/protocol.h @@ -37,25 +37,4 @@ inline INT decode_4bytes(const void *a) return (*((INT *) a)); } -#define packet_encode(buf, data, len) __packet_encode(buf, data, len, __FILE__, __LINE__) - -//#define DEFAULT_PACKET_BUFFER_SIZE 32768 -#define DEFAULT_PACKET_BUFFER_SIZE 65536 - -inline bool __packet_encode(LPBUFFER pbuf, const void * data, int length, const char * file, int line) -{ - assert(NULL != pbuf); - assert(NULL != data); - - if (buffer_has_space(pbuf) < length) - { - //sys_err("buffer length exceeded buffer size: %d, encoding %d bytes (%s:%d)", buffer_size(pbuf), length, file, line); - return false; - } - - //buffer_adjust_size(pbuf, length); - buffer_write(pbuf, data, length); - return true; -} - #endif diff --git a/game/src/questevent.cpp b/game/src/questevent.cpp index 5cfc372..3c29bbf 100644 --- a/game/src/questevent.cpp +++ b/game/src/questevent.cpp @@ -87,7 +87,7 @@ END_OF_TIMER_EVENT: { const int nameCapacity = strlen(name) + 1; - long ltime_cycle = (long) (rint(PASSES_PER_SEC(when))); + int ltime_cycle = (int) (rint(PASSES_PER_SEC(when))); quest_server_event_info* info = AllocEventInfo(); @@ -106,7 +106,7 @@ END_OF_TIMER_EVENT: { const int nameCapacity = strlen(name) + 1; - long ltime_cycle = (int) (rint(PASSES_PER_SEC(when))); + int ltime_cycle = (int) (rint(PASSES_PER_SEC(when))); quest_event_info* info = AllocEventInfo(); diff --git a/game/src/questlua.cpp b/game/src/questlua.cpp index 7dd20b1..30a9d8d 100644 --- a/game/src/questlua.cpp +++ b/game/src/questlua.cpp @@ -270,8 +270,8 @@ namespace quest } DWORD mob_vnum = (DWORD)lua_tonumber(L, 1); - long local_x = (long) lua_tonumber(L, 2)*100; - long local_y = (long) lua_tonumber(L, 3)*100; + int local_x = (int) lua_tonumber(L, 2)*100; + int local_y = (int) lua_tonumber(L, 3)*100; float radius = (float) lua_tonumber(L, 4)*100; bool bAggressive = lua_toboolean(L, 5); DWORD count = (lua_isnumber(L, 6))?(DWORD) lua_tonumber(L, 6):1; @@ -301,8 +301,8 @@ namespace quest float angle = number(0, 999) * M_PI * 2 / 1000; float r = number(0, 999) * radius / 1000; - long x = local_x + pMap->m_setting.iBaseX + (long)(r * cos(angle)); - long y = local_y + pMap->m_setting.iBaseY + (long)(r * sin(angle)); + int x = local_x + pMap->m_setting.iBaseX + (int)(r * cos(angle)); + int y = local_y + pMap->m_setting.iBaseY + (int)(r * sin(angle)); mob = CHARACTER_MANAGER::instance().SpawnMob(mob_vnum, ch->GetMapIndex(), x, y, 0); @@ -341,8 +341,8 @@ namespace quest } DWORD group_vnum = (DWORD)lua_tonumber(L, 1); - long local_x = (long) lua_tonumber(L, 2) * 100; - long local_y = (long) lua_tonumber(L, 3) * 100; + int local_x = (int) lua_tonumber(L, 2) * 100; + int local_y = (int) lua_tonumber(L, 3) * 100; float radius = (float) lua_tonumber(L, 4) * 100; bool bAggressive = lua_toboolean(L, 5); DWORD count = (DWORD) lua_tonumber(L, 6); @@ -373,8 +373,8 @@ namespace quest float angle = number(0, 999) * M_PI * 2 / 1000; float r = number(0, 999)*radius/1000; - long x = local_x + pMap->m_setting.iBaseX + (long)(r * cos(angle)); - long y = local_y + pMap->m_setting.iBaseY + (long)(r * sin(angle)); + int x = local_x + pMap->m_setting.iBaseX + (int)(r * cos(angle)); + int y = local_y + pMap->m_setting.iBaseY + (int)(r * sin(angle)); mob = CHARACTER_MANAGER::instance().SpawnGroup(group_vnum, ch->GetMapIndex(), x, y, x, y, NULL, bAggressive); diff --git a/game/src/questlua.h b/game/src/questlua.h index 43b7043..b7f6aa3 100644 --- a/game/src/questlua.h +++ b/game/src/questlua.h @@ -39,11 +39,11 @@ namespace quest struct FSetWarpLocation { - long map_index; - long x; - long y; + int map_index; + int x; + int y; - FSetWarpLocation (long _map_index, long _x, long _y) : + FSetWarpLocation (int _map_index, int _x, int _y) : map_index (_map_index), x (_x), y (_y) {} void operator () (LPCHARACTER ch); @@ -97,9 +97,9 @@ namespace quest struct FWarpEmpire { BYTE m_bEmpire; - long m_lMapIndexTo; - long m_x; - long m_y; + int m_lMapIndexTo; + int m_x; + int m_y; void operator() (LPENTITY ent); }; @@ -107,10 +107,10 @@ namespace quest EVENTINFO(warp_all_to_map_my_empire_event_info) { BYTE m_bEmpire; - long m_lMapIndexFrom; - long m_lMapIndexTo; - long m_x; - long m_y; + int m_lMapIndexFrom; + int m_lMapIndexTo; + int m_x; + int m_y; warp_all_to_map_my_empire_event_info() : m_bEmpire( 0 ) diff --git a/game/src/questlua_affect.cpp b/game/src/questlua_affect.cpp index 108d835..c7b6227 100644 --- a/game/src/questlua_affect.cpp +++ b/game/src/questlua_affect.cpp @@ -34,8 +34,8 @@ namespace quest if (ch->FindAffect(AFFECT_QUEST_START_IDX, applyOn)) // Äù½ºÆ®·Î ÀÎÇØ °°Àº °÷¿¡ È¿°ú°¡ °É·ÁÀÖÀ¸¸é ½ºÅµ return 0; - long value = (long) lua_tonumber(L, 2); - long duration = (long) lua_tonumber(L, 3); + int value = (int) lua_tonumber(L, 2); + int duration = (int) lua_tonumber(L, 3); ch->AddAffect(AFFECT_QUEST_START_IDX, aApplyInfo[applyOn].bPointType, value, 0, duration, 0, false); @@ -96,8 +96,8 @@ namespace quest return 0; } - long value = (long) lua_tonumber(L, 2); - long duration = (long) lua_tonumber(L, 3); + int value = (int) lua_tonumber(L, 2); + int duration = (int) lua_tonumber(L, 3); ch->AddAffect(AFFECT_HAIR, aApplyInfo[applyOn].bPointType, value, 0, duration, 0, false); @@ -168,8 +168,8 @@ namespace quest return 0; } - long value = (long) lua_tonumber(L, 2); - long duration = (long) lua_tonumber(L, 3); + int value = (int) lua_tonumber(L, 2); + int duration = (int) lua_tonumber(L, 3); ch->AddAffect(AFFECT_COLLECT, aApplyInfo[applyOn].bPointType, value, 0, duration, 0, false); @@ -196,8 +196,8 @@ namespace quest return 0; } - long value = (long) lua_tonumber(L, 2); - long duration = (long) lua_tonumber(L, 3); + int value = (int) lua_tonumber(L, 2); + int duration = (int) lua_tonumber(L, 3); ch->AddAffect(AFFECT_COLLECT, point_type, value, 0, duration, 0, false); @@ -215,7 +215,7 @@ namespace quest if ( bApply >= MAX_APPLY_NUM ) return 0; bApply = aApplyInfo[bApply].bPointType; - long value = (long)lua_tonumber(L, 2); + int value = (int)lua_tonumber(L, 2); const std::list& rList = ch->GetAffectContainer(); const CAffect* pAffect = NULL; diff --git a/game/src/questlua_dragonlair.cpp b/game/src/questlua_dragonlair.cpp index 29835a6..3bf1914 100644 --- a/game/src/questlua_dragonlair.cpp +++ b/game/src/questlua_dragonlair.cpp @@ -11,7 +11,7 @@ namespace quest int dl_startRaid(lua_State* L) { LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); - long baseMapIndex = lua_tonumber(L, -1); + int baseMapIndex = lua_tonumber(L, -1); CDragonLairManager::instance().Start(ch->GetMapIndex(), baseMapIndex, ch->GetGuild()->GetID()); diff --git a/game/src/questlua_dungeon.cpp b/game/src/questlua_dungeon.cpp index 228e192..4fe156d 100644 --- a/game/src/questlua_dungeon.cpp +++ b/game/src/questlua_dungeon.cpp @@ -225,7 +225,7 @@ namespace quest LPDUNGEON pDungeon = q.GetCurrentDungeon(); if (pDungeon) - pDungeon->SetExitAllAtEliminate((long)lua_tonumber(L, 1)); + pDungeon->SetExitAllAtEliminate((int)lua_tonumber(L, 1)); return 0; } @@ -266,10 +266,10 @@ namespace quest if (pDungeon) { - pDungeon->SetWarpAtEliminate((long)lua_tonumber(L,1), - (long)lua_tonumber(L,2), - (long)lua_tonumber(L,3), - (long)lua_tonumber(L,4), + pDungeon->SetWarpAtEliminate((int)lua_tonumber(L,1), + (int)lua_tonumber(L,2), + (int)lua_tonumber(L,3), + (int)lua_tonumber(L,4), c_pszRegenFile); } else @@ -292,7 +292,7 @@ namespace quest return 0; } - long lMapIndex = (long)lua_tonumber(L,1); + int lMapIndex = (int)lua_tonumber(L,1); LPDUNGEON pDungeon = CDungeonManager::instance().Create(lMapIndex); @@ -317,7 +317,7 @@ namespace quest return 0; } - long lMapIndex = (long)lua_tonumber(L,1); + int lMapIndex = (int)lua_tonumber(L,1); LPDUNGEON pDungeon = CDungeonManager::instance().Create(lMapIndex); @@ -342,7 +342,7 @@ namespace quest return 0; } - long lMapIndex = (long)lua_tonumber(L,1); + int lMapIndex = (int)lua_tonumber(L,1); LPDUNGEON pDungeon = CDungeonManager::instance().Create(lMapIndex); @@ -814,8 +814,8 @@ namespace quest if (pDungeon) { DWORD dwVnum = (DWORD) lua_tonumber(L, 1); - long x = (long) lua_tonumber(L, 2); - long y = (long) lua_tonumber(L, 3); + int x = (int) lua_tonumber(L, 2); + int y = (int) lua_tonumber(L, 3); float radius = lua_isnumber(L, 4) ? (float) lua_tonumber(L, 4) : 0; DWORD count = (lua_isnumber(L, 5)) ? (DWORD) lua_tonumber(L, 5) : 1; @@ -837,8 +837,8 @@ namespace quest float angle = number(0, 999) * M_PI * 2 / 1000; float r = number(0, 999) * radius / 1000; - long nx = x + (long)(r * cos(angle)); - long ny = y + (long)(r * sin(angle)); + int nx = x + (int)(r * cos(angle)); + int ny = y + (int)(r * sin(angle)); LPCHARACTER ch = pDungeon->SpawnMob(dwVnum, nx, ny); if (ch && !vid) @@ -867,8 +867,8 @@ namespace quest if (pDungeon) { DWORD dwVnum = (DWORD) lua_tonumber(L, 1); - long x = (long) lua_tonumber(L, 2); - long y = (long) lua_tonumber(L, 3); + int x = (int) lua_tonumber(L, 2); + int y = (int) lua_tonumber(L, 3); BYTE dir = (int) lua_tonumber(L, 4); LPCHARACTER ch = pDungeon->SpawnMob(dwVnum, x, y, dir); @@ -895,8 +895,8 @@ namespace quest if (pDungeon) { DWORD dwVnum = (DWORD) lua_tonumber(L, 1); - long x = (long) lua_tonumber(L, 2); - long y = (long) lua_tonumber(L, 3); + int x = (int) lua_tonumber(L, 2); + int y = (int) lua_tonumber(L, 3); BYTE dir = (int) lua_tonumber(L, 4); LPCHARACTER ch = pDungeon->SpawnMob_ac_dir(dwVnum, x, y, dir); @@ -912,10 +912,10 @@ namespace quest if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2) || !lua_isnumber(L, 3) || !lua_isnumber(L, 4)) return 0; - long lFromX = (long)lua_tonumber(L, 1); - long lFromY = (long)lua_tonumber(L, 2); - long lToX = (long)lua_tonumber(L, 3); - long lToY = (long)lua_tonumber(L, 4); + int lFromX = (int)lua_tonumber(L, 1); + int lFromY = (int)lua_tonumber(L, 2); + int lToX = (int)lua_tonumber(L, 3); + int lToY = (int)lua_tonumber(L, 4); CQuestManager& q = CQuestManager::instance(); LPDUNGEON pDungeon = q.GetCurrentDungeon(); @@ -937,8 +937,8 @@ namespace quest if (pDungeon) { DWORD dwVnum = (DWORD) lua_tonumber(L, 1); - long x = (long)lua_tonumber(L, 2); - long y = (long)lua_tonumber(L, 3); + int x = (int)lua_tonumber(L, 2); + int y = (int)lua_tonumber(L, 3); pDungeon->SpawnNameMob(dwVnum, x, y, lua_tostring(L, 4)); } return 0; @@ -963,8 +963,8 @@ namespace quest if (pDungeon) { DWORD group_vnum = (DWORD)lua_tonumber(L, 1); - long local_x = (long) lua_tonumber(L, 2) * 100; - long local_y = (long) lua_tonumber(L, 3) * 100; + int local_x = (int) lua_tonumber(L, 2) * 100; + int local_y = (int) lua_tonumber(L, 3) * 100; float radius = (float) lua_tonumber(L, 4) * 100; bool bAggressive = lua_toboolean(L, 5); DWORD count = (DWORD) lua_tonumber(L, 6); @@ -983,7 +983,7 @@ namespace quest if (lua_gettop(L) < 1 || !lua_isnumber(L, 1)) return 0; - long lMapIndex = (long)lua_tonumber(L, 1); + int lMapIndex = (int)lua_tonumber(L, 1); LPDUNGEON pDungeon = CDungeonManager::instance().Create(lMapIndex); if (!pDungeon) @@ -1284,7 +1284,7 @@ namespace quest else { sys_err("not in a dungeon"); - lua_pushnumber(L, LONG_MAX); + lua_pushnumber(L, INT_MAX); } return 1; diff --git a/game/src/questlua_game.cpp b/game/src/questlua_game.cpp index bb8439b..72caa51 100644 --- a/game/src/questlua_game.cpp +++ b/game/src/questlua_game.cpp @@ -101,8 +101,8 @@ namespace quest DWORD item_vnum = (DWORD) lua_tonumber(L, 1); int count = (int) lua_tonumber(L, 2); - long x = ch->GetX(); - long y = ch->GetY(); + int x = ch->GetX(); + int y = ch->GetY(); LPITEM item = ITEM_MANAGER::instance().CreateItem(item_vnum, count); diff --git a/game/src/questlua_item.cpp b/game/src/questlua_item.cpp index befc676..da0ac35 100644 --- a/game/src/questlua_item.cpp +++ b/game/src/questlua_item.cpp @@ -167,7 +167,7 @@ namespace quest return 1; } - long lCheckFlag = (long) lua_tonumber(L, 1); + int lCheckFlag = (int) lua_tonumber(L, 1); lua_pushboolean(L, IS_SET(item->GetFlag(), lCheckFlag)); return 1; diff --git a/game/src/questlua_monarch.cpp b/game/src/questlua_monarch.cpp index ea3e551..e1749dc 100644 --- a/game/src/questlua_monarch.cpp +++ b/game/src/questlua_monarch.cpp @@ -42,8 +42,8 @@ namespace quest { BYTE bHeader; DWORD dwTargetPID; - long x; - long y; + int x; + int y; monarch_transfer2_event_info() : bHeader( 0 ) @@ -331,8 +331,8 @@ namespace quest LPCHARACTER mob = NULL; { - long x = ch->GetX(); - long y = ch->GetY(); + int x = ch->GetX(); + int y = ch->GetY(); #if 0 if (11505 == mob_vnum) // Ȳ±ÝµÎ²¨ºñ { diff --git a/game/src/questlua_party.cpp b/game/src/questlua_party.cpp index b934255..16ed660 100644 --- a/game/src/questlua_party.cpp +++ b/game/src/questlua_party.cpp @@ -71,7 +71,7 @@ namespace quest if (ch->GetDesc()) { sys_log(0, "CINEMASEND %s", ch->GetName()); - ch->GetDesc()->BufferedPacket(&pack, sizeof(struct packet_script)); + ch->GetDesc()->RawPacket(&pack, sizeof(struct packet_script)); ch->GetDesc()->Packet(data.c_str(),data.size()); } } @@ -120,7 +120,7 @@ namespace quest if (ch->GetDesc()) { sys_log(0, "CINEMASEND %s", ch->GetName()); - ch->GetDesc()->BufferedPacket(&packet_script, sizeof(struct packet_script)); + ch->GetDesc()->RawPacket(&packet_script, sizeof(struct packet_script)); ch->GetDesc()->Packet(str,len); } } @@ -312,15 +312,15 @@ namespace quest { DWORD dwType; BYTE bApplyOn; - long lApplyValue; + int lApplyValue; DWORD dwFlag; - long lDuration; - long lSPCost; + int lDuration; + int lSPCost; bool bOverride; bool IsCube; - FGiveBuff (DWORD _dwType, BYTE _bApplyOn, long _lApplyValue, DWORD _dwFlag, long _lDuration, - long _lSPCost, bool _bOverride, bool _IsCube = false) + FGiveBuff (DWORD _dwType, BYTE _bApplyOn, int _lApplyValue, DWORD _dwFlag, int _lDuration, + int _lSPCost, bool _bOverride, bool _IsCube = false) : dwType (_dwType), bApplyOn (_bApplyOn), lApplyValue (_lApplyValue), dwFlag(_dwFlag), lDuration(_lDuration), lSPCost(_lSPCost), bOverride(_bOverride), IsCube(_IsCube) {} @@ -345,10 +345,10 @@ namespace quest } DWORD dwType = lua_tonumber(L, 1); BYTE bApplyOn = lua_tonumber(L, 2); - long lApplyValue = lua_tonumber(L, 3); + int lApplyValue = lua_tonumber(L, 3); DWORD dwFlag = lua_tonumber(L, 4); - long lDuration = lua_tonumber(L, 5); - long lSPCost = lua_tonumber(L, 6); + int lDuration = lua_tonumber(L, 5); + int lSPCost = lua_tonumber(L, 6); bool bOverride = lua_toboolean(L, 7); bool IsCube = lua_toboolean(L, 8); diff --git a/game/src/questlua_pc.cpp b/game/src/questlua_pc.cpp index 021e37d..abc5b19 100644 --- a/game/src/questlua_pc.cpp +++ b/game/src/questlua_pc.cpp @@ -80,7 +80,7 @@ namespace quest return 0; } - lua_pushboolean(L, ch->LearnGrandMasterSkill((long)lua_tonumber(L, 1))); + lua_pushboolean(L, ch->LearnGrandMasterSkill((int)lua_tonumber(L, 1))); return 1; } @@ -100,7 +100,7 @@ namespace quest return 0; } - ch->SetWarpLocation((long)lua_tonumber(L,1), (long)lua_tonumber(L,2), (long)lua_tonumber(L,3)); + ch->SetWarpLocation((int)lua_tonumber(L,1), (int)lua_tonumber(L,2), (int)lua_tonumber(L,3)); return 0; } @@ -120,7 +120,7 @@ namespace quest return 0; } - long lMapIndex = (long) lua_tonumber(L, 1); + int lMapIndex = (int) lua_tonumber(L, 1); const TMapRegion * region = SECTREE_MANAGER::instance().GetMapRegion(lMapIndex); if (!region) @@ -168,7 +168,7 @@ namespace quest return 1; } - long map_index = 0; + int map_index = 0; if (lua_isnumber(L, 3)) map_index = (int) lua_tonumber(L,3); @@ -205,7 +205,7 @@ namespace quest return 0; } - long lMapIndex = (long) lua_tonumber(L, 1); + int lMapIndex = (int) lua_tonumber(L, 1); const TMapRegion * region = SECTREE_MANAGER::instance().GetMapRegion(lMapIndex); if (!region) @@ -395,7 +395,7 @@ namespace quest std::vector dwVnums; std::vector dwCounts; - std::vector item_gets(NULL); + std::vector item_gets; int count = 0; ch->GiveItemFromSpecialItemGroup(dwGroupVnum, dwVnums, dwCounts, item_gets, count); @@ -800,7 +800,7 @@ namespace quest return 1; } - long val = (long) lua_tonumber(L, 1); + int val = (int) lua_tonumber(L, 1); if (val == 0) { @@ -1309,8 +1309,8 @@ namespace quest int pc_mount_bonus(lua_State* L) { BYTE applyOn = static_cast(lua_tonumber(L, 1)); - long value = static_cast(lua_tonumber(L, 2)); - long duration = static_cast(lua_tonumber(L, 3)); + int value = static_cast(lua_tonumber(L, 2)); + int duration = static_cast(lua_tonumber(L, 3)); LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); @@ -1548,7 +1548,7 @@ namespace quest int set = 0; for (int i=0; iGetSocket(i); + int socket = item->GetSocket(i); if (socket > 2 && socket != 28960) { pkNewItem->SetSocket(set++, socket); @@ -2373,7 +2373,7 @@ teleport_area: int j = 0; for (; j < ITEM_SOCKET_MAX_NUM; j++ ) { - long socket = pItem->GetSocket(j); + int socket = pItem->GetSocket(j); if ( socket > 2 && socket != ITEM_BROKEN_METIN_VNUM ) { diff --git a/game/src/questmanager.cpp b/game/src/questmanager.cpp index 61dae50..8af4b32 100644 --- a/game/src/questmanager.cpp +++ b/game/src/questmanager.cpp @@ -1286,7 +1286,7 @@ namespace quest // ¾øÀ¸¸é ¸¸µé¾îÁØ´Ù struct SNPCSellFireworkPosition { - long lMapIndex; + int lMapIndex; int x; int y; } positions[] = { @@ -1338,7 +1338,7 @@ namespace quest struct SEventNPCPosition { - long lMapIndex; + int lMapIndex; int x; int y; } positions[] = { diff --git a/game/src/questnpc.cpp b/game/src/questnpc.cpp index 1cd83bf..ad2d096 100644 --- a/game/src/questnpc.cpp +++ b/game/src/questnpc.cpp @@ -7,7 +7,7 @@ #include "char.h" // questpc.h: PC::typedef Quest -// questpc.h: PC::typedef map QuestInfo; +// questpc.h: PC::typedef map QuestInfo; // typedef diff --git a/game/src/questpc.cpp b/game/src/questpc.cpp index 0be7d4d..8e4d76a 100644 --- a/game/src/questpc.cpp +++ b/game/src/questpc.cpp @@ -530,7 +530,7 @@ namespace quest while (it != m_FlagSaveMap.end()) { const std::string & stComp = it->first; - long lValue = it->second; + int lValue = it->second; ++it; diff --git a/game/src/regen.cpp b/game/src/regen.cpp index 1978e98..bfedb05 100644 --- a/game/src/regen.cpp +++ b/game/src/regen.cpp @@ -239,7 +239,7 @@ static bool read_line(FILE *fp, LPREGEN regen) return false; } -bool is_regen_exception(long x, long y) +bool is_regen_exception(int x, int y) { LPREGEN_EXCEPTION exc; @@ -407,7 +407,7 @@ EVENTFUNC(dungeon_regen_event) return PASSES_PER_SEC(regen->time); } -bool regen_do(const char* filename, long lMapIndex, int base_x, int base_y, LPDUNGEON pDungeon, bool bOnce) +bool regen_do(const char* filename, int lMapIndex, int base_x, int base_y, LPDUNGEON pDungeon, bool bOnce) { if (g_bNoRegen) return true; @@ -510,7 +510,7 @@ bool regen_do(const char* filename, long lMapIndex, int base_x, int base_y, LPDU return true; } -bool regen_load_in_file(const char* filename, long lMapIndex, int base_x, int base_y) +bool regen_load_in_file(const char* filename, int lMapIndex, int base_x, int base_y) { if (g_bNoRegen) return true; @@ -604,7 +604,7 @@ EVENTFUNC(regen_event) return PASSES_PER_SEC(regen->time); } -bool regen_load(const char* filename, long lMapIndex, int base_x, int base_y) +bool regen_load(const char* filename, int lMapIndex, int base_x, int base_y) { if (g_bNoRegen) return true; diff --git a/game/src/regen.h b/game/src/regen.h index 5964866..f439b1a 100644 --- a/game/src/regen.h +++ b/game/src/regen.h @@ -13,7 +13,7 @@ enum typedef struct regen { LPREGEN prev, next; - long lMapIndex; + int lMapIndex; int type; int sx, sy, ex, ey; BYTE z_section; @@ -83,10 +83,10 @@ EVENTINFO(dungeon_regen_event_info) } }; -extern bool regen_load(const char *filename, long lMapIndex, int base_x, int base_y); -extern bool regen_do(const char* filename, long lMapIndex, int base_x, int base_y, LPDUNGEON pDungeon, bool bOnce = true ); -extern bool regen_load_in_file(const char* filename, long lMapIndex, int base_x, int base_y ); +extern bool regen_load(const char *filename, int lMapIndex, int base_x, int base_y); +extern bool regen_do(const char* filename, int lMapIndex, int base_x, int base_y, LPDUNGEON pDungeon, bool bOnce = true ); +extern bool regen_load_in_file(const char* filename, int lMapIndex, int base_x, int base_y ); extern void regen_free(); -extern bool is_regen_exception(long x, long y); +extern bool is_regen_exception(int x, int y); extern void regen_reset(int x, int y); diff --git a/game/src/safebox.h b/game/src/safebox.h index 5afb20c..c57700d 100644 --- a/game/src/safebox.h +++ b/game/src/safebox.h @@ -33,7 +33,7 @@ class CSafebox LPITEM m_pkItems[SAFEBOX_MAX_NUM]; CGrid * m_pkGrid; int m_iSize; - long m_lGold; + int m_lGold; BYTE m_bWindowMode; }; diff --git a/game/src/sectree.cpp b/game/src/sectree.cpp index 8bdf51a..8d1e548 100644 --- a/game/src/sectree.cpp +++ b/game/src/sectree.cpp @@ -199,13 +199,13 @@ void SECTREE::RemoveAttribute(DWORD x, DWORD y, DWORD dwAttr) m_pkAttribute->Remove(x, y, dwAttr); } -DWORD SECTREE::GetAttribute(long x, long y) +DWORD SECTREE::GetAttribute(int x, int y) { assert(m_pkAttribute != NULL); return m_pkAttribute->Get((x % SECTREE_SIZE) / CELL_SIZE, (y % SECTREE_SIZE) / CELL_SIZE); } -bool SECTREE::IsAttr(long x, long y, DWORD dwFlag) +bool SECTREE::IsAttr(int x, int y, DWORD dwFlag) { if (IS_SET(GetAttribute(x, y), dwFlag)) return true; @@ -213,7 +213,7 @@ bool SECTREE::IsAttr(long x, long y, DWORD dwFlag) return false; } -int SECTREE::GetEventAttribute(long x, long y) +int SECTREE::GetEventAttribute(int x, int y) { return GetAttribute(x, y) >> 8; } diff --git a/game/src/sectree.h b/game/src/sectree.h index 8ce4ae9..2b0b3df 100644 --- a/game/src/sectree.h +++ b/game/src/sectree.h @@ -173,12 +173,12 @@ class SECTREE CAttribute * GetAttributePtr() { return m_pkAttribute; } - DWORD GetAttribute(long x, long y); - bool IsAttr(long x, long y, DWORD dwFlag); + DWORD GetAttribute(int x, int y); + bool IsAttr(int x, int y, DWORD dwFlag); void CloneAttribute(LPSECTREE tree); // private map 󸮽à »ç¿ë - int GetEventAttribute(long x, long y); // 20050313 ÇöÀç´Â »ç¿ëÇÏÁö ¾ÊÀ½ + int GetEventAttribute(int x, int y); // 20050313 ÇöÀç´Â »ç¿ëÇÏÁö ¾ÊÀ½ void SetAttribute(DWORD x, DWORD y, DWORD dwAttr); void RemoveAttribute(DWORD x, DWORD y, DWORD dwAttr); diff --git a/game/src/sectree_manager.cpp b/game/src/sectree_manager.cpp index 41fac75..bc5bd32 100644 --- a/game/src/sectree_manager.cpp +++ b/game/src/sectree_manager.cpp @@ -202,7 +202,7 @@ SECTREE_MANAGER::~SECTREE_MANAGER() */ } -LPSECTREE_MAP SECTREE_MANAGER::GetMap(long lMapIndex) +LPSECTREE_MAP SECTREE_MANAGER::GetMap(int lMapIndex) { std::map::iterator it = m_map_pkSectree.find(lMapIndex); @@ -233,7 +233,7 @@ LPSECTREE SECTREE_MANAGER::Get(DWORD dwIndex, DWORD x, DWORD y) // ----------------------------------------------------------------------------- // Setting.txt ·Î ºÎÅÍ SECTREE ¸¸µé±â // ----------------------------------------------------------------------------- -int SECTREE_MANAGER::LoadSettingFile(long lMapIndex, const char * c_pszSettingFileName, TMapSetting & r_setting) +int SECTREE_MANAGER::LoadSettingFile(int lMapIndex, const char * c_pszSettingFileName, TMapSetting & r_setting) { memset(&r_setting, 0, sizeof(TMapSetting)); @@ -458,21 +458,17 @@ bool SECTREE_MANAGER::LoadAttribute(LPSECTREE_MAP pkMapSectree, const char * c_p return false; } - int iWidth, iHeight; + int32_t iWidth, iHeight; - fread(&iWidth, sizeof(int), 1, fp); - fread(&iHeight, sizeof(int), 1, fp); + fread(&iWidth, sizeof(int32_t), 1, fp); + fread(&iHeight, sizeof(int32_t), 1, fp); - int maxMemSize = LZOManager::instance().GetMaxCompressedSize(sizeof(DWORD) * (SECTREE_SIZE / CELL_SIZE) * (SECTREE_SIZE / CELL_SIZE)); + size_t maxMemSize = LZOManager::instance().GetMaxCompressedSize(sizeof(DWORD) * (SECTREE_SIZE / CELL_SIZE) * (SECTREE_SIZE / CELL_SIZE)); size_t uiSize; lzo_uint uiDestSize; -#ifndef _MSC_VER - BYTE abComp[maxMemSize]; -#else BYTE* abComp = M2_NEW BYTE[maxMemSize]; -#endif DWORD * attr = M2_NEW DWORD[maxMemSize]; for (int y = 0; y < iHeight; ++y) @@ -497,9 +493,8 @@ bool SECTREE_MANAGER::LoadAttribute(LPSECTREE_MAP pkMapSectree, const char * c_p abort(); M2_DELETE_ARRAY(attr); -#ifdef _MSC_VER M2_DELETE_ARRAY(abComp); -#endif + return false; } // END_OF_SERVER_ATTR_LOAD_ERROR @@ -511,14 +506,13 @@ bool SECTREE_MANAGER::LoadAttribute(LPSECTREE_MAP pkMapSectree, const char * c_p fclose(fp); M2_DELETE_ARRAY(attr); -#ifdef _MSC_VER M2_DELETE_ARRAY(abComp); -#endif + return false; } - fread(&uiSize, sizeof(int), 1, fp); - fread(abComp, sizeof(char), uiSize, fp); + fread(&uiSize, sizeof(int32_t), 1, fp); + fread(abComp, sizeof(BYTE), uiSize, fp); //LZOManager::instance().Decompress(abComp, uiSize, (BYTE *) tree->GetAttributePointer(), &uiDestSize); uiDestSize = sizeof(DWORD) * maxMemSize; @@ -531,9 +525,8 @@ bool SECTREE_MANAGER::LoadAttribute(LPSECTREE_MAP pkMapSectree, const char * c_p fclose(fp); M2_DELETE_ARRAY(attr); -#ifdef _MSC_VER M2_DELETE_ARRAY(abComp); -#endif + return false; } @@ -543,9 +536,8 @@ bool SECTREE_MANAGER::LoadAttribute(LPSECTREE_MAP pkMapSectree, const char * c_p fclose(fp); M2_DELETE_ARRAY(attr); -#ifdef _MSC_VER M2_DELETE_ARRAY(abComp); -#endif + return true; } @@ -577,7 +569,7 @@ bool SECTREE_MANAGER::GetRecallPositionByEmpire(int iMapIndex, BYTE bEmpire, PIX return false; } -bool SECTREE_MANAGER::GetCenterPositionOfMap(long lMapIndex, PIXEL_POSITION & r_pos) +bool SECTREE_MANAGER::GetCenterPositionOfMap(int lMapIndex, PIXEL_POSITION & r_pos) { std::vector::iterator it = m_vec_mapRegion.begin(); @@ -597,7 +589,7 @@ bool SECTREE_MANAGER::GetCenterPositionOfMap(long lMapIndex, PIXEL_POSITION & r_ return false; } -bool SECTREE_MANAGER::GetSpawnPositionByMapIndex(long lMapIndex, PIXEL_POSITION& r_pos) +bool SECTREE_MANAGER::GetSpawnPositionByMapIndex(int lMapIndex, PIXEL_POSITION& r_pos) { if (lMapIndex> 10000) lMapIndex /= 10000; std::vector::iterator it = m_vec_mapRegion.begin(); @@ -616,7 +608,7 @@ bool SECTREE_MANAGER::GetSpawnPositionByMapIndex(long lMapIndex, PIXEL_POSITION& return false; } -bool SECTREE_MANAGER::GetSpawnPosition(long x, long y, PIXEL_POSITION & r_pos) +bool SECTREE_MANAGER::GetSpawnPosition(int x, int y, PIXEL_POSITION & r_pos) { std::vector::iterator it = m_vec_mapRegion.begin(); @@ -634,7 +626,7 @@ bool SECTREE_MANAGER::GetSpawnPosition(long x, long y, PIXEL_POSITION & r_pos) return false; } -bool SECTREE_MANAGER::GetMapBasePositionByMapIndex(long lMapIndex, PIXEL_POSITION & r_pos) +bool SECTREE_MANAGER::GetMapBasePositionByMapIndex(int lMapIndex, PIXEL_POSITION & r_pos) { if (lMapIndex> 10000) lMapIndex /= 10000; std::vector::iterator it = m_vec_mapRegion.begin(); @@ -656,7 +648,7 @@ bool SECTREE_MANAGER::GetMapBasePositionByMapIndex(long lMapIndex, PIXEL_POSITIO return false; } -bool SECTREE_MANAGER::GetMapBasePosition(long x, long y, PIXEL_POSITION & r_pos) +bool SECTREE_MANAGER::GetMapBasePosition(int x, int y, PIXEL_POSITION & r_pos) { std::vector::iterator it = m_vec_mapRegion.begin(); @@ -693,7 +685,7 @@ const TMapRegion * SECTREE_MANAGER::FindRegionByPartialName(const char* szMapNam return NULL; } -const TMapRegion * SECTREE_MANAGER::GetMapRegion(long lMapIndex) +const TMapRegion * SECTREE_MANAGER::GetMapRegion(int lMapIndex) { std::vector::iterator it = m_vec_mapRegion.begin(); @@ -708,7 +700,7 @@ const TMapRegion * SECTREE_MANAGER::GetMapRegion(long lMapIndex) return NULL; } -int SECTREE_MANAGER::GetMapIndex(long x, long y) +int SECTREE_MANAGER::GetMapIndex(int x, int y) { std::vector::iterator it = m_vec_mapRegion.begin(); @@ -745,7 +737,7 @@ int SECTREE_MANAGER::Build(const char * c_pszListFileName, const char* c_pszMapB return 0; char buf[256 + 1]; - char szFilename[256]; + char szFilename[1024]; char szMapName[256]; int iIndex; @@ -815,7 +807,7 @@ int SECTREE_MANAGER::Build(const char * c_pszListFileName, const char* c_pszMapB return 1; } -bool SECTREE_MANAGER::IsMovablePosition(long lMapIndex, long x, long y) +bool SECTREE_MANAGER::IsMovablePosition(int lMapIndex, int x, int y) { LPSECTREE tree = SECTREE_MANAGER::instance().Get(lMapIndex, x, y); @@ -825,14 +817,14 @@ bool SECTREE_MANAGER::IsMovablePosition(long lMapIndex, long x, long y) return (!tree->IsAttr(x, y, ATTR_BLOCK | ATTR_OBJECT)); } -bool SECTREE_MANAGER::GetMovablePosition(long lMapIndex, long x, long y, PIXEL_POSITION & pos) +bool SECTREE_MANAGER::GetMovablePosition(int lMapIndex, int x, int y, PIXEL_POSITION & pos) { int i = 0; do { - long dx = x + aArroundCoords[i].x; - long dy = y + aArroundCoords[i].y; + int dx = x + aArroundCoords[i].x; + int dy = y + aArroundCoords[i].y; LPSECTREE tree = SECTREE_MANAGER::instance().Get(lMapIndex, dx, dy); @@ -852,7 +844,7 @@ bool SECTREE_MANAGER::GetMovablePosition(long lMapIndex, long x, long y, PIXEL_P return false; } -bool SECTREE_MANAGER::GetValidLocation(long lMapIndex, long x, long y, long & r_lValidMapIndex, PIXEL_POSITION & r_pos, BYTE empire) +bool SECTREE_MANAGER::GetValidLocation(int lMapIndex, int x, int y, int & r_lValidMapIndex, PIXEL_POSITION & r_pos, BYTE empire) { LPSECTREE_MAP pkSectreeMap = GetMap(lMapIndex); @@ -860,7 +852,7 @@ bool SECTREE_MANAGER::GetValidLocation(long lMapIndex, long x, long y, long & r_ { if (lMapIndex >= 10000) { -/* long m = lMapIndex / 10000; +/* int m = lMapIndex / 10000; if (m == 216) { if (GetRecallPositionByEmpire (m, empire, r_pos)) @@ -880,7 +872,7 @@ bool SECTREE_MANAGER::GetValidLocation(long lMapIndex, long x, long y, long & r_ } } - long lRealMapIndex = lMapIndex; + int lRealMapIndex = lMapIndex; if (lRealMapIndex >= 10000) lRealMapIndex = lRealMapIndex / 10000; @@ -912,7 +904,7 @@ bool SECTREE_MANAGER::GetValidLocation(long lMapIndex, long x, long y, long & r_ return false; } -bool SECTREE_MANAGER::GetRandomLocation(long lMapIndex, PIXEL_POSITION & r_pos, DWORD dwCurrentX, DWORD dwCurrentY, int iMaxDistance) +bool SECTREE_MANAGER::GetRandomLocation(int lMapIndex, PIXEL_POSITION & r_pos, DWORD dwCurrentX, DWORD dwCurrentY, int iMaxDistance) { LPSECTREE_MAP pkSectreeMap = GetMap(lMapIndex); @@ -979,7 +971,7 @@ bool SECTREE_MANAGER::GetRandomLocation(long lMapIndex, PIXEL_POSITION & r_pos, return false; } -long SECTREE_MANAGER::CreatePrivateMap(long lMapIndex) +int SECTREE_MANAGER::CreatePrivateMap(int lMapIndex) { if (lMapIndex >= 10000) // 10000¹ø ÀÌ»óÀÇ ¸ÊÀº ¾ø´Ù. (ȤÀº ÀÌ¹Ì private ÀÌ´Ù) return 0; @@ -993,7 +985,7 @@ long SECTREE_MANAGER::CreatePrivateMap(long lMapIndex) } // Circular private map indexing - long base = lMapIndex * 10000; + int base = lMapIndex * 10000; int index_cap = 10000; if ( lMapIndex == 107 || lMapIndex == 108 || lMapIndex == 109 ) { index_cap = (test_server ? 1 : 51); @@ -1015,7 +1007,7 @@ long SECTREE_MANAGER::CreatePrivateMap(long lMapIndex) // No available index return 0; } - long lNewMapIndex = base + next_index; + int lNewMapIndex = base + next_index; if (++next_index >= index_cap) { next_index = 0; } @@ -1054,7 +1046,7 @@ long SECTREE_MANAGER::CreatePrivateMap(long lMapIndex) return 0; } - long lNewMapIndex = lMapIndex * 10000 + i; + int lNewMapIndex = lMapIndex * 10000 + i; */ pkMapSectree = M2_NEW SECTREE_MAP(*pkMapSectree); @@ -1090,7 +1082,7 @@ struct FDestroyPrivateMapEntity } }; -void SECTREE_MANAGER::DestroyPrivateMap(long lMapIndex) +void SECTREE_MANAGER::DestroyPrivateMap(int lMapIndex) { if (lMapIndex < 10000) // private map Àº À妽º°¡ 10000 ÀÌ»ó ÀÌ´Ù. return; @@ -1114,7 +1106,7 @@ void SECTREE_MANAGER::DestroyPrivateMap(long lMapIndex) sys_log(0, "PRIVATE_MAP: %d destroyed", lMapIndex); } -TAreaMap& SECTREE_MANAGER::GetDungeonArea(long lMapIndex) +TAreaMap& SECTREE_MANAGER::GetDungeonArea(int lMapIndex) { itertype(m_map_pkArea) it = m_map_pkArea.find(lMapIndex); @@ -1131,7 +1123,7 @@ void SECTREE_MANAGER::SendNPCPosition(LPCHARACTER ch) if (!d) return; - long lMapIndex = ch->GetMapIndex(); + int lMapIndex = ch->GetMapIndex(); if (m_mapNPCPosition[lMapIndex].empty()) return; @@ -1159,19 +1151,19 @@ void SECTREE_MANAGER::SendNPCPosition(LPCHARACTER ch) if (buf.size()) { - d->BufferedPacket(&p, sizeof(TPacketGCNPCPosition)); + d->RawPacket(&p, sizeof(TPacketGCNPCPosition)); d->Packet(buf.read_peek(), buf.size()); } else d->Packet(&p, sizeof(TPacketGCNPCPosition)); } -void SECTREE_MANAGER::InsertNPCPosition(long lMapIndex, BYTE bType, const char* szName, long x, long y) +void SECTREE_MANAGER::InsertNPCPosition(int lMapIndex, BYTE bType, const char* szName, int x, int y) { m_mapNPCPosition[lMapIndex].push_back(npc_info(bType, szName, x, y)); } -BYTE SECTREE_MANAGER::GetEmpireFromMapIndex(long lMapIndex) +BYTE SECTREE_MANAGER::GetEmpireFromMapIndex(int lMapIndex) { if (lMapIndex >= 1 && lMapIndex <= 20) return 1; @@ -1242,15 +1234,15 @@ class FRemoveIfAttr DWORD m_dwCheckAttr; }; -bool SECTREE_MANAGER::ForAttrRegionCell( long lMapIndex, long lCX, long lCY, DWORD dwAttr, EAttrRegionMode mode ) +bool SECTREE_MANAGER::ForAttrRegionCell( int lMapIndex, int lCX, int lCY, DWORD dwAttr, EAttrRegionMode mode ) { SECTREEID id; id.coord.x = lCX / (SECTREE_SIZE / CELL_SIZE); id.coord.y = lCY / (SECTREE_SIZE / CELL_SIZE); - long lTreeCX = id.coord.x * (SECTREE_SIZE / CELL_SIZE); - long lTreeCY = id.coord.y * (SECTREE_SIZE / CELL_SIZE); + int lTreeCX = id.coord.x * (SECTREE_SIZE / CELL_SIZE); + int lTreeCY = id.coord.y * (SECTREE_SIZE / CELL_SIZE); LPSECTREE pSec = Get( lMapIndex, id.package ); if ( !pSec ) @@ -1279,7 +1271,7 @@ bool SECTREE_MANAGER::ForAttrRegionCell( long lMapIndex, long lCX, long lCY, DWO return false; } -bool SECTREE_MANAGER::ForAttrRegionRightAngle( long lMapIndex, long lCX, long lCY, long lCW, long lCH, long lRotate, DWORD dwAttr, EAttrRegionMode mode ) +bool SECTREE_MANAGER::ForAttrRegionRightAngle( int lMapIndex, int lCX, int lCY, int lCW, int lCH, int lRotate, DWORD dwAttr, EAttrRegionMode mode ) { if (1 == lRotate/90 || 3 == lRotate/90) { @@ -1306,7 +1298,7 @@ bool SECTREE_MANAGER::ForAttrRegionRightAngle( long lMapIndex, long lCX, long lC #define min( l, r ) ((l) < (r) ? (l) : (r)) #define max( l, r ) ((l) < (r) ? (r) : (l)) -bool SECTREE_MANAGER::ForAttrRegionFreeAngle( long lMapIndex, long lCX, long lCY, long lCW, long lCH, long lRotate, DWORD dwAttr, EAttrRegionMode mode ) +bool SECTREE_MANAGER::ForAttrRegionFreeAngle( int lMapIndex, int lCX, int lCY, int lCW, int lCH, int lRotate, DWORD dwAttr, EAttrRegionMode mode ) { float fx1 = (-lCW/2) * sinf(float(lRotate)/180.0f*3.14f) + (-lCH/2) * cosf(float(lRotate)/180.0f*3.14f); float fy1 = (-lCW/2) * cosf(float(lRotate)/180.0f*3.14f) - (-lCH/2) * sinf(float(lRotate)/180.0f*3.14f); @@ -1368,7 +1360,7 @@ bool SECTREE_MANAGER::ForAttrRegionFreeAngle( long lMapIndex, long lCX, long lCY return mode == ATTR_REGION_MODE_CHECK ? false : true; } -bool SECTREE_MANAGER::ForAttrRegion(long lMapIndex, long lStartX, long lStartY, long lEndX, long lEndY, long lRotate, DWORD dwAttr, EAttrRegionMode mode) +bool SECTREE_MANAGER::ForAttrRegion(int lMapIndex, int lStartX, int lStartY, int lEndX, int lEndY, int lRotate, DWORD dwAttr, EAttrRegionMode mode) { LPSECTREE_MAP pkMapSectree = GetMap(lMapIndex); @@ -1391,10 +1383,10 @@ bool SECTREE_MANAGER::ForAttrRegion(long lMapIndex, long lStartX, long lStartY, // Cell ÁÂÇ¥¸¦ ±¸ÇÑ´Ù. // - long lCX = lStartX / CELL_SIZE; - long lCY = lStartY / CELL_SIZE; - long lCW = (lEndX - lStartX) / CELL_SIZE; - long lCH = (lEndY - lStartY) / CELL_SIZE; + int lCX = lStartX / CELL_SIZE; + int lCY = lStartY / CELL_SIZE; + int lCW = (lEndX - lStartX) / CELL_SIZE; + int lCH = (lEndY - lStartY) / CELL_SIZE; sys_log(1, "ForAttrRegion %d %d ~ %d %d", lStartX, lStartY, lEndX, lEndY); @@ -1527,7 +1519,7 @@ struct FPurgeMonsters } }; -void SECTREE_MANAGER::PurgeMonstersInMap(long lMapIndex) +void SECTREE_MANAGER::PurgeMonstersInMap(int lMapIndex) { LPSECTREE_MAP sectree = SECTREE_MANAGER::instance().GetMap(lMapIndex); @@ -1555,7 +1547,7 @@ struct FPurgeStones } }; -void SECTREE_MANAGER::PurgeStonesInMap(long lMapIndex) +void SECTREE_MANAGER::PurgeStonesInMap(int lMapIndex) { LPSECTREE_MAP sectree = SECTREE_MANAGER::instance().GetMap(lMapIndex); @@ -1583,7 +1575,7 @@ struct FPurgeNPCs } }; -void SECTREE_MANAGER::PurgeNPCsInMap(long lMapIndex) +void SECTREE_MANAGER::PurgeNPCsInMap(int lMapIndex) { LPSECTREE_MAP sectree = SECTREE_MANAGER::instance().GetMap(lMapIndex); @@ -1613,7 +1605,7 @@ struct FCountMonsters } }; -size_t SECTREE_MANAGER::GetMonsterCountInMap(long lMapIndex) +size_t SECTREE_MANAGER::GetMonsterCountInMap(int lMapIndex) { LPSECTREE_MAP sectree = SECTREE_MANAGER::instance().GetMap(lMapIndex); @@ -1653,7 +1645,7 @@ struct FCountSpecifiedMonster } }; -size_t SECTREE_MANAGER::GetMonsterCountInMap(long lMapIndex, DWORD dwVnum) +size_t SECTREE_MANAGER::GetMonsterCountInMap(int lMapIndex, DWORD dwVnum) { LPSECTREE_MAP sectree = SECTREE_MANAGER::instance().GetMap(lMapIndex); diff --git a/game/src/sectree_manager.h b/game/src/sectree_manager.h index aab7c99..6f5d081 100644 --- a/game/src/sectree_manager.h +++ b/game/src/sectree_manager.h @@ -28,8 +28,8 @@ struct npc_info { BYTE bType; const char* name; - long x, y; - npc_info(BYTE bType, const char* name, long x, long y) + int x, y; + npc_info(BYTE bType, const char* name, int x, int y) : bType(bType), name(name), x(x), y(y) {} }; @@ -114,7 +114,7 @@ class SECTREE_MANAGER : public singleton SECTREE_MANAGER(); virtual ~SECTREE_MANAGER(); - LPSECTREE_MAP GetMap(long lMapIndex); + LPSECTREE_MAP GetMap(int lMapIndex); LPSECTREE Get(DWORD dwIndex, DWORD package); LPSECTREE Get(DWORD dwIndex, DWORD x, DWORD y); @@ -128,42 +128,42 @@ class SECTREE_MANAGER : public singleton } } - int LoadSettingFile(long lIndex, const char * c_pszSettingFileName, TMapSetting & r_setting); + int LoadSettingFile(int lIndex, const char * c_pszSettingFileName, TMapSetting & r_setting); bool LoadMapRegion(const char * c_pszFileName, TMapSetting & r_Setting, const char * c_pszMapName); int Build(const char * c_pszListFileName, const char* c_pszBasePath); LPSECTREE_MAP BuildSectreeFromSetting(TMapSetting & r_setting); bool LoadAttribute(LPSECTREE_MAP pkMapSectree, const char * c_pszFileName, TMapSetting & r_setting); void LoadDungeon(int iIndex, const char * c_pszFileName); - bool GetValidLocation(long lMapIndex, long x, long y, long & r_lValidMapIndex, PIXEL_POSITION & r_pos, BYTE empire = 0); - bool GetSpawnPosition(long x, long y, PIXEL_POSITION & r_pos); - bool GetSpawnPositionByMapIndex(long lMapIndex, PIXEL_POSITION & r_pos); + bool GetValidLocation(int lMapIndex, int x, int y, int& r_lValidMapIndex, PIXEL_POSITION & r_pos, BYTE empire = 0); + bool GetSpawnPosition(int x, int y, PIXEL_POSITION & r_pos); + bool GetSpawnPositionByMapIndex(int lMapIndex, PIXEL_POSITION & r_pos); bool GetRecallPositionByEmpire(int iMapIndex, BYTE bEmpire, PIXEL_POSITION & r_pos); - const TMapRegion * GetMapRegion(long lMapIndex); - int GetMapIndex(long x, long y); + const TMapRegion * GetMapRegion(int lMapIndex); + int GetMapIndex(int x, int y); const TMapRegion * FindRegionByPartialName(const char* szMapName); - bool GetMapBasePosition(long x, long y, PIXEL_POSITION & r_pos); - bool GetMapBasePositionByMapIndex(long lMapIndex, PIXEL_POSITION & r_pos); - bool GetMovablePosition(long lMapIndex, long x, long y, PIXEL_POSITION & pos); - bool IsMovablePosition(long lMapIndex, long x, long y); - bool GetCenterPositionOfMap(long lMapIndex, PIXEL_POSITION & r_pos); - bool GetRandomLocation(long lMapIndex, PIXEL_POSITION & r_pos, DWORD dwCurrentX = 0, DWORD dwCurrentY = 0, int iMaxDistance = 0); + bool GetMapBasePosition(int x, int y, PIXEL_POSITION & r_pos); + bool GetMapBasePositionByMapIndex(int lMapIndex, PIXEL_POSITION & r_pos); + bool GetMovablePosition(int lMapIndex, int x, int y, PIXEL_POSITION & pos); + bool IsMovablePosition(int lMapIndex, int x, int y); + bool GetCenterPositionOfMap(int lMapIndex, PIXEL_POSITION & r_pos); + bool GetRandomLocation(int lMapIndex, PIXEL_POSITION & r_pos, DWORD dwCurrentX = 0, DWORD dwCurrentY = 0, int iMaxDistance = 0); - long CreatePrivateMap(long lMapIndex); // returns new private map index, returns 0 when fail - void DestroyPrivateMap(long lMapIndex); + int CreatePrivateMap(int lMapIndex); // returns new private map index, returns 0 when fail + void DestroyPrivateMap(int lMapIndex); - TAreaMap& GetDungeonArea(long lMapIndex); + TAreaMap& GetDungeonArea(int lMapIndex); void SendNPCPosition(LPCHARACTER ch); - void InsertNPCPosition(long lMapIndex, BYTE bType, const char* szName, long x, long y); + void InsertNPCPosition(int lMapIndex, BYTE bType, const char* szName, int x, int y); - BYTE GetEmpireFromMapIndex(long lMapIndex); + BYTE GetEmpireFromMapIndex(int lMapIndex); - void PurgeMonstersInMap(long lMapIndex); - void PurgeStonesInMap(long lMapIndex); - void PurgeNPCsInMap(long lMapIndex); - size_t GetMonsterCountInMap(long lMapIndex); - size_t GetMonsterCountInMap(long lMpaIndex, DWORD dwVnum); + void PurgeMonstersInMap(int lMapIndex); + void PurgeStonesInMap(int lMapIndex); + void PurgeNPCsInMap(int lMapIndex); + size_t GetMonsterCountInMap(int lMapIndex); + size_t GetMonsterCountInMap(int lMpaIndex, DWORD dwVnum); /// ¿µ¿ª¿¡ ´ëÇØ Sectree ÀÇ Attribute ¿¡ ´ëÇØ Æ¯Á¤ÇÑ Ã³¸®¸¦ ¼öÇàÇÑ´Ù. /** @@ -176,7 +176,7 @@ class SECTREE_MANAGER : public singleton * @param [in] dwAttr Àû¿ëÇÒ Attribute * @param [in] mode Attribute ¿¡ ´ëÇØ Ã³¸®ÇÒ type */ - bool ForAttrRegion(long lMapIndex, long lStartX, long lStartY, long lEndX, long lEndY, long lRotate, DWORD dwAttr, EAttrRegionMode mode); + bool ForAttrRegion(int lMapIndex, int lStartX, int lStartY, int lEndX, int lEndY, int lRotate, DWORD dwAttr, EAttrRegionMode mode); bool SaveAttributeToImage(int lMapIndex, const char * c_pszFileName, LPSECTREE_MAP pMapSrc = NULL); @@ -193,7 +193,7 @@ class SECTREE_MANAGER : public singleton * @param [in] dwAttr Àû¿ëÇÒ Attribute * @param [in] mode Attribute ¿¡ ´ëÇØ Ã³¸®ÇÒ type */ - bool ForAttrRegionRightAngle( long lMapIndex, long lCX, long lCY, long lCW, long lCH, long lRotate, DWORD dwAttr, EAttrRegionMode mode ); + bool ForAttrRegionRightAngle( int lMapIndex, int lCX, int lCY, int lCW, int lCH, int lRotate, DWORD dwAttr, EAttrRegionMode mode ); /// Á÷°¢ ÀÌ¿ÜÀÇ »ç°¢Çü ¿µ¿ª¿¡ ´ëÇØ Sectree ÀÇ Attribute ¿¡ ´ëÇØ Æ¯Á¤ÇÑ Ã³¸®¸¦ ¼öÇàÇÑ´Ù. /** @@ -206,7 +206,7 @@ class SECTREE_MANAGER : public singleton * @param [in] dwAttr Àû¿ëÇÒ Attribute * @param [in] mode Attribute ¿¡ ´ëÇØ Ã³¸®ÇÒ type */ - bool ForAttrRegionFreeAngle( long lMapIndex, long lCX, long lCY, long lCW, long lCH, long lRotate, DWORD dwAttr, EAttrRegionMode mode ); + bool ForAttrRegionFreeAngle( int lMapIndex, int lCX, int lCY, int lCW, int lCH, int lRotate, DWORD dwAttr, EAttrRegionMode mode ); /// ÇÑ Cell ÀÇ Attribute ¿¡ ´ëÇØ Æ¯Á¤ÇÑ Ã³¸®¸¦ ¼öÇàÇÑ´Ù. /** @@ -216,7 +216,7 @@ class SECTREE_MANAGER : public singleton * @param [in] dwAttr Àû¿ëÇÒ Attribute * @param [in] mode Attribute ¿¡ ´ëÇØ Ã³¸®ÇÒ type */ - bool ForAttrRegionCell( long lMapIndex, long lCX, long lCY, DWORD dwAttr, EAttrRegionMode mode ); + bool ForAttrRegionCell( int lMapIndex, int lCX, int lCY, DWORD dwAttr, EAttrRegionMode mode ); static WORD current_sectree_version; std::map m_map_pkSectree; @@ -225,7 +225,7 @@ class SECTREE_MANAGER : public singleton std::map > m_mapNPCPosition; // Circular private map indexing - typedef std::unordered_map PrivateIndexMapType; + typedef std::unordered_map PrivateIndexMapType; PrivateIndexMapType next_private_index_map_; }; diff --git a/game/src/shop.cpp b/game/src/shop.cpp index cb01c02..d47809b 100644 --- a/game/src/shop.cpp +++ b/game/src/shop.cpp @@ -179,7 +179,7 @@ void CShop::SetShopItems(TShopItemTable * pTable, BYTE bItemCount) item.price = item_table->dwGold * item.count; } - char name[36]; + char name[64]; snprintf(name, sizeof(name), "%-20s(#%-5d) (x %d)", item_table->szName, (int) item.vnum, item.count); sys_log(0, "SHOP_ITEM: %-36s PRICE %-5d", name, item.price); @@ -470,7 +470,7 @@ bool CShop::AddGuest(LPCHARACTER ch, DWORD owner_vid, bool bOtherEmpire) pack.size = sizeof(pack) + sizeof(pack2); - ch->GetDesc()->BufferedPacket(&pack, sizeof(TPacketGCShop)); + ch->GetDesc()->RawPacket(&pack, sizeof(TPacketGCShop)); ch->GetDesc()->Packet(&pack2, sizeof(TPacketGCShopStart)); return true; } diff --git a/game/src/shop.h b/game/src/shop.h index 15713b9..adde8b3 100644 --- a/game/src/shop.h +++ b/game/src/shop.h @@ -15,7 +15,7 @@ class CShop typedef struct shop_item { DWORD vnum; // ¾ÆÀÌÅÛ ¹øÈ£ - long price; // °¡°Ý + int price; // °¡°Ý BYTE count; // ¾ÆÀÌÅÛ °³¼ö LPITEM pkItem; diff --git a/game/src/shopEx.cpp b/game/src/shopEx.cpp index 5f291cc..2d0ea04 100644 --- a/game/src/shopEx.cpp +++ b/game/src/shopEx.cpp @@ -106,8 +106,8 @@ bool CShopEx::AddGuest(LPCHARACTER ch,DWORD owner_vid, bool bOtherEmpire) pack.size = sizeof(pack) + sizeof(pack2) + size; - ch->GetDesc()->BufferedPacket(&pack, sizeof(TPacketGCShop)); - ch->GetDesc()->BufferedPacket(&pack2, sizeof(TPacketGCShopStartEx)); + ch->GetDesc()->RawPacket(&pack, sizeof(TPacketGCShop)); + ch->GetDesc()->RawPacket(&pack2, sizeof(TPacketGCShopStartEx)); ch->GetDesc()->Packet(temp, size); return true; diff --git a/game/src/shop_manager.cpp b/game/src/shop_manager.cpp index 37d623f..e3d8a48 100644 --- a/game/src/shop_manager.cpp +++ b/game/src/shop_manager.cpp @@ -117,7 +117,7 @@ bool CShopManager::StartShopping(LPCHARACTER pkChr, LPCHARACTER pkChrShopKeeper, } //END_PREVENT_TRADE_WINDOW - long distance = DISTANCE_APPROX(pkChr->GetX() - pkChrShopKeeper->GetX(), pkChr->GetY() - pkChrShopKeeper->GetY()); + int distance = DISTANCE_APPROX(pkChr->GetX() - pkChrShopKeeper->GetX(), pkChr->GetY() - pkChrShopKeeper->GetY()); if (distance >= SHOP_MAX_DISTANCE) { diff --git a/game/src/skill.h b/game/src/skill.h index 94faf87..824890e 100644 --- a/game/src/skill.h +++ b/game/src/skill.h @@ -200,7 +200,7 @@ class CSkillProto DWORD preSkillVnum; // ¹è¿ì´Âµ¥ ÇÊ¿äÇÑ ÀÌÀü¿¡ ¹è¿ö¾ßÇÒ ½ºÅ³ BYTE preSkillLevel; // ÀÌÀü¿¡ ¹è¿ö¾ßÇÒ ½ºÅ³ÀÇ ·¹º§ - long lMaxHit; + int lMaxHit; BYTE bSkillAttrType; diff --git a/game/src/start_position.cpp b/game/src/start_position.cpp index 0cb6b6c..c191102 100644 --- a/game/src/start_position.cpp +++ b/game/src/start_position.cpp @@ -14,7 +14,7 @@ char g_nation_name[4][32] = // LC_TEXT("õÁ¶±¹") // LC_TEXT("Áø³ë±¹") -long g_start_map[4] = +int g_start_map[4] = { 0, // reserved 1, // ½Å¼ö±¹ diff --git a/game/src/start_position.h b/game/src/start_position.h index da8b3ee..6b90645 100644 --- a/game/src/start_position.h +++ b/game/src/start_position.h @@ -5,7 +5,7 @@ extern char g_nation_name[4][32]; extern DWORD g_start_position[4][2]; -extern long g_start_map[4]; +extern int g_start_map[4]; extern DWORD g_create_position[4][2]; extern DWORD g_create_position_canada[4][2]; extern DWORD arena_return_position[4][2]; diff --git a/game/src/trigger.cpp b/game/src/trigger.cpp index 73db88b..059fccf 100644 --- a/game/src/trigger.cpp +++ b/game/src/trigger.cpp @@ -61,7 +61,7 @@ class FuncFindMobVictim public: FuncFindMobVictim(LPCHARACTER pkChr, int iMaxDistance) : m_pkChr(pkChr), - m_iMinDistance(~(1L << 31)), + m_iMinDistance(~(1 << 31)), m_iMaxDistance(iMaxDistance), m_lx(pkChr->GetX()), m_ly(pkChr->GetY()), @@ -151,8 +151,8 @@ class FuncFindMobVictim int m_iMinDistance; int m_iMaxDistance; - long m_lx; - long m_ly; + int m_lx; + int m_ly; LPCHARACTER m_pkChrVictim; LPCHARACTER m_pkChrBuilding; diff --git a/game/src/utils.cpp b/game/src/utils.cpp index 7473a17..301a278 100644 --- a/game/src/utils.cpp +++ b/game/src/utils.cpp @@ -240,7 +240,7 @@ bool WildCaseCmp(const char *w, const char *s) switch(*w) { case '*': - if (NULL == w[1]) + if ('\0' == w[1]) return true; { for (size_t i = 0; i <= strlen(s); ++i) @@ -252,7 +252,7 @@ bool WildCaseCmp(const char *w, const char *s) return false; case '?': - if (NULL == *s) + if ('\0' == *s) return false; ++w; @@ -266,7 +266,7 @@ bool WildCaseCmp(const char *w, const char *s) return false; } - if (NULL == *w) + if ('\0' == *w) return true; ++w; diff --git a/game/src/utils.h b/game/src/utils.h index 707107f..ca513a1 100644 --- a/game/src/utils.h +++ b/game/src/utils.h @@ -9,7 +9,7 @@ #define REMOVE_BIT(var, bit) ((var) &= ~(bit)) #define TOGGLE_BIT(var, bit) ((var) = (var) ^ (bit)) -inline float DISTANCE_SQRT(long dx, long dy) +inline float DISTANCE_SQRT(int dx, int dy) { return ::sqrt((float)dx * dx + (float)dy * dy); } diff --git a/game/src/vector.cpp b/game/src/vector.cpp index 15d9726..3efdfa2 100644 --- a/game/src/vector.cpp +++ b/game/src/vector.cpp @@ -46,7 +46,7 @@ float GetDegreeFromPosition(float x, float y) return (ret); } -float GetDegreeFromPositionXY(long sx, long sy, long ex, long ey) +float GetDegreeFromPositionXY(int sx, int sy, int ex, int ey) { return GetDegreeFromPosition(ex - sx, ey - sy); } diff --git a/game/src/vector.h b/game/src/vector.h index 81463e1..02eaeea 100644 --- a/game/src/vector.h +++ b/game/src/vector.h @@ -10,7 +10,7 @@ typedef struct SVector extern void Normalize(VECTOR * pV1, VECTOR * pV2); extern float GetDegreeFromPosition(float x, float y); -extern float GetDegreeFromPositionXY(long sx, long sy, long ex, long ey); +extern float GetDegreeFromPositionXY(int sx, int sy, int ex, int ey); extern void GetDeltaByDegree(float fDegree, float fDistance, float *x, float *y); extern float GetDegreeDelta(float iDegree, float iDegree2); diff --git a/game/src/war_map.cpp b/game/src/war_map.cpp index 6d26f17..81456a6 100644 --- a/game/src/war_map.cpp +++ b/game/src/war_map.cpp @@ -95,7 +95,7 @@ void CWarMap::STeamData::Initialize() set_pidJoiner.clear(); } -CWarMap::CWarMap(long lMapIndex, const TGuildWarInfo & r_info, TWarMapInfo * pkWarMapInfo, DWORD dwGuildID1, DWORD dwGuildID2) +CWarMap::CWarMap(int lMapIndex, const TGuildWarInfo & r_info, TWarMapInfo * pkWarMapInfo, DWORD dwGuildID1, DWORD dwGuildID2) { m_kMapInfo = *pkWarMapInfo; m_kMapInfo.lMapIndex = lMapIndex; @@ -223,7 +223,7 @@ CGuild * CWarMap::GetGuild(BYTE bIdx) return m_TeamData[bIdx].pkGuild; } -long CWarMap::GetMapIndex() +int CWarMap::GetMapIndex() { return m_kMapInfo.lMapIndex; } @@ -634,7 +634,7 @@ void CWarMap::SendWarPacket(LPDESC d) pack2.bType = CGuildManager::instance().TouchGuild(m_TeamData[0].dwID)->GetGuildWarType(m_TeamData[1].dwID); pack2.bWarState = CGuildManager::instance().TouchGuild(m_TeamData[0].dwID)->GetGuildWarState(m_TeamData[1].dwID); - d->BufferedPacket(&pack, sizeof(pack)); + d->RawPacket(&pack, sizeof(pack)); d->Packet(&pack2, sizeof(pack2)); } @@ -644,13 +644,13 @@ void CWarMap::SendScorePacket(BYTE bIdx, LPDESC d) p.header = HEADER_GC_GUILD; p.subheader = GUILD_SUBHEADER_GC_WAR_SCORE; - p.size = sizeof(p) + sizeof(DWORD) + sizeof(DWORD) + sizeof(long); + p.size = sizeof(p) + sizeof(DWORD) + sizeof(DWORD) + sizeof(int); TEMP_BUFFER buf; buf.write(&p, sizeof(p)); buf.write(&m_TeamData[bIdx].dwID, sizeof(DWORD)); buf.write(&m_TeamData[bIdx ? 0 : 1].dwID, sizeof(DWORD)); - buf.write(&m_TeamData[bIdx].iScore, sizeof(long)); + buf.write(&m_TeamData[bIdx].iScore, sizeof(int)); if (d) d->Packet(buf.read_peek(), buf.size()); @@ -971,7 +971,7 @@ CWarMapManager::CWarMapManager() CWarMapManager::~CWarMapManager() { - for( std::map::const_iterator iter = m_map_kWarMapInfo.begin() ; iter != m_map_kWarMapInfo.end() ; ++iter ) + for( std::map::const_iterator iter = m_map_kWarMapInfo.begin() ; iter != m_map_kWarMapInfo.end() ; ++iter ) { M2_DELETE(iter->second); } @@ -1011,12 +1011,12 @@ bool CWarMapManager::LoadWarMapInfo(const char * c_pszFileName) return true; } -bool CWarMapManager::IsWarMap(long lMapIndex) +bool CWarMapManager::IsWarMap(int lMapIndex) { return GetWarMapInfo(lMapIndex) ? true : false; } -bool CWarMapManager::GetStartPosition(long lMapIndex, BYTE bIdx, PIXEL_POSITION & pos) +bool CWarMapManager::GetStartPosition(int lMapIndex, BYTE bIdx, PIXEL_POSITION & pos) { assert(bIdx < 3); @@ -1039,7 +1039,7 @@ bool CWarMapManager::GetStartPosition(long lMapIndex, BYTE bIdx, PIXEL_POSITION return true; } -long CWarMapManager::CreateWarMap(const TGuildWarInfo& guildWarInfo, DWORD dwGuildID1, DWORD dwGuildID2) +int CWarMapManager::CreateWarMap(const TGuildWarInfo& guildWarInfo, DWORD dwGuildID1, DWORD dwGuildID2) { TWarMapInfo * pkInfo = GetWarMapInfo(guildWarInfo.lMapIndex); if (!pkInfo) @@ -1058,7 +1058,7 @@ long CWarMapManager::CreateWarMap(const TGuildWarInfo& guildWarInfo, DWORD dwGui return lMapIndex; } -TWarMapInfo * CWarMapManager::GetWarMapInfo(long lMapIndex) +TWarMapInfo * CWarMapManager::GetWarMapInfo(int lMapIndex) { if (lMapIndex >= 10000) lMapIndex /= 10000; @@ -1073,7 +1073,7 @@ TWarMapInfo * CWarMapManager::GetWarMapInfo(long lMapIndex) void CWarMapManager::DestroyWarMap(CWarMap* pMap) { - long mapIdx = pMap->GetMapIndex(); + int mapIdx = pMap->GetMapIndex(); sys_log(0, "WarMap::DestroyWarMap : %d", mapIdx); @@ -1083,7 +1083,7 @@ void CWarMapManager::DestroyWarMap(CWarMap* pMap) SECTREE_MANAGER::instance().DestroyPrivateMap(mapIdx); } -CWarMap * CWarMapManager::Find(long lMapIndex) +CWarMap * CWarMapManager::Find(int lMapIndex) { itertype(m_mapWarMap) it = m_mapWarMap.find(lMapIndex); diff --git a/game/src/war_map.h b/game/src/war_map.h index b87da03..d57950c 100644 --- a/game/src/war_map.h +++ b/game/src/war_map.h @@ -13,7 +13,7 @@ enum EWarMapTypes typedef struct SWarMapInfo { BYTE bType; - long lMapIndex; + int lMapIndex; PIXEL_POSITION posStart[3]; } TWarMapInfo; @@ -50,7 +50,7 @@ class CWarMap public: friend class CGuild; - CWarMap(long lMapIndex, const TGuildWarInfo & r_info, TWarMapInfo * pkWarMapInfo, DWORD dwGuildID1, DWORD dwGuildID2); + CWarMap(int lMapIndex, const TGuildWarInfo & r_info, TWarMapInfo * pkWarMapInfo, DWORD dwGuildID1, DWORD dwGuildID2); ~CWarMap(); bool GetTeamIndex(DWORD dwGuild, BYTE & bIdx); @@ -62,7 +62,7 @@ class CWarMap DWORD GetGuildID(BYTE bIdx); BYTE GetType(); - long GetMapIndex(); + int GetMapIndex(); DWORD GetGuildOpponent(LPCHARACTER ch); DWORD GetWinnerGuild(); @@ -149,21 +149,21 @@ class CWarMapManager : public singleton virtual ~CWarMapManager(); bool LoadWarMapInfo(const char * c_pszFileName); - bool IsWarMap(long lMapIndex); - TWarMapInfo * GetWarMapInfo(long lMapIndex); - bool GetStartPosition(long lMapIndex, BYTE bIdx, PIXEL_POSITION & pos); + bool IsWarMap(int lMapIndex); + TWarMapInfo * GetWarMapInfo(int lMapIndex); + bool GetStartPosition(int lMapIndex, BYTE bIdx, PIXEL_POSITION & pos); template Func for_each(Func f); - long CreateWarMap(const TGuildWarInfo & r_WarInfo, DWORD dwGuildID1, DWORD dwGuildID2); + int CreateWarMap(const TGuildWarInfo & r_WarInfo, DWORD dwGuildID1, DWORD dwGuildID2); void DestroyWarMap(CWarMap* pMap); - CWarMap * Find(long lMapIndex); + CWarMap * Find(int lMapIndex); int CountWarMap() { return m_mapWarMap.size(); } void OnShutdown(); private: - std::map m_map_kWarMapInfo; - std::map m_mapWarMap; + std::map m_map_kWarMapInfo; + std::map m_mapWarMap; }; template Func CWarMapManager::for_each(Func f) diff --git a/game/src/xmas_event.cpp b/game/src/xmas_event.cpp index 511ba2b..8985db7 100644 --- a/game/src/xmas_event.cpp +++ b/game/src/xmas_event.cpp @@ -104,7 +104,7 @@ namespace xmas EVENTINFO(spawn_santa_info) { - long lMapIndex; + int lMapIndex; spawn_santa_info() : lMapIndex( 0 ) @@ -122,7 +122,7 @@ namespace xmas return 0; } - long lMapIndex = info->lMapIndex; + int lMapIndex = info->lMapIndex; if (quest::CQuestManager::instance().GetEventFlag("xmas_santa") == 0) return 0; @@ -141,7 +141,7 @@ namespace xmas return PASSES_PER_SEC(5); } - void SpawnSanta(long lMapIndex, int iTimeGapSec) + void SpawnSanta(int lMapIndex, int iTimeGapSec) { if (test_server) { @@ -163,7 +163,7 @@ namespace xmas // ¾øÀ¸¸é ¸¸µé¾îÁØ´Ù struct SNPCSellFireworkPosition { - long lMapIndex; + int lMapIndex; int x; int y; } positions[] = { diff --git a/game/src/xmas_event.h b/game/src/xmas_event.h index 443e95e..1fb568e 100644 --- a/game/src/xmas_event.h +++ b/game/src/xmas_event.h @@ -12,7 +12,7 @@ namespace xmas }; void ProcessEventFlag(const std::string& name, int prev_value, int value); - void SpawnSanta(long lMapIndex, int iTimeGapSec); + void SpawnSanta(int lMapIndex, int iTimeGapSec); void SpawnEventHelper(bool spawn); } #endif diff --git a/libsql/include/CAsyncSQL.h b/libsql/include/CAsyncSQL.h index 2b71f75..915590d 100644 --- a/libsql/include/CAsyncSQL.h +++ b/libsql/include/CAsyncSQL.h @@ -196,7 +196,7 @@ class CAsyncSQL int m_iQueryFinished; - unsigned long m_ulThreadID; + unsigned int m_ulThreadID; bool m_bConnected; int m_iCopiedQuery; }; diff --git a/libsql/include/CStatement.h b/libsql/include/CStatement.h index 4e1bcd3..4938400 100644 --- a/libsql/include/CStatement.h +++ b/libsql/include/CStatement.h @@ -32,7 +32,7 @@ class CStmt std::vector m_vec_param; unsigned int m_uiParamCount; - long unsigned int * m_puiParamLen; + uint64_t * m_puiParamLen; std::vector m_vec_result; unsigned int m_uiResultCount; diff --git a/libsql/src/CAsyncSQL.cpp b/libsql/src/CAsyncSQL.cpp index 3a4c596..aeeb510 100644 --- a/libsql/src/CAsyncSQL.cpp +++ b/libsql/src/CAsyncSQL.cpp @@ -517,8 +517,8 @@ class cProfiler } struct timeval * GetResult() { return &interval; } - long GetResultSec() { return interval.tv_sec; } - long GetResultUSec() { return interval.tv_usec; } + int GetResultSec() { return interval.tv_sec; } + int GetResultUSec() { return interval.tv_usec; } private: int m_nInterval; diff --git a/libsql/src/CStatement.cpp b/libsql/src/CStatement.cpp index e429960..2bb5348 100644 --- a/libsql/src/CStatement.cpp +++ b/libsql/src/CStatement.cpp @@ -59,7 +59,7 @@ bool CStmt::Prepare(CAsyncSQL * sql, const char * c_pszQuery) m_vec_param.resize(iParamCount); memset(&m_vec_param[0], 0, sizeof(MYSQL_BIND) * iParamCount); - m_puiParamLen = (long unsigned int *) calloc(iParamCount, sizeof(long unsigned int)); + m_puiParamLen = (uint64_t *) calloc(iParamCount, sizeof(uint64_t)); } m_vec_result.resize(48); diff --git a/libthecore/include/buffer.h b/libthecore/include/buffer.h index 5a1bc9e..8644ea1 100644 --- a/libthecore/include/buffer.h +++ b/libthecore/include/buffer.h @@ -25,7 +25,7 @@ char * mem_data; int mem_size; - long flag; + int flag; }; extern LPBUFFER buffer_new(int size); // »õ ¹öÆÛ »ý¼º diff --git a/libthecore/include/stdafx.h b/libthecore/include/stdafx.h index 52608a1..fc5f2b8 100644 --- a/libthecore/include/stdafx.h +++ b/libthecore/include/stdafx.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/libthecore/include/utils.h b/libthecore/include/utils.h index 346a452..f42998a 100644 --- a/libthecore/include/utils.h +++ b/libthecore/include/utils.h @@ -1,10 +1,6 @@ #ifndef __INC_LIBTHECORE_UTILS_H__ #define __INC_LIBTHECORE_UTILS_H__ -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ #define SAFE_FREE(p) { if (p) { free( (void *) p); (p) = NULL; } } #define SAFE_DELETE(p) { if (p) { delete (p); (p) = NULL; } } @@ -62,6 +58,9 @@ extern "C" extern char * time_str(time_t ct); + std::string GetSocketHost(const sockaddr * address); + in_port_t GetSocketPort(const sockaddr * address); + #define CREATE(result, type, number) do { \ if (!((result) = (type *) calloc ((number), sizeof(type)))) { \ sys_err("calloc failed [%d] %s", errno, strerror(errno)); \ @@ -127,9 +126,6 @@ extern "C" ((DWORD)(BYTE) (ch2) << 16) | ((DWORD)(BYTE) (ch3) << 24)) #endif // defined(MAKEFOURCC) -#ifdef __cplusplus -} -#endif // __cplusplus // _countof for gcc/g++ #if !defined(_countof) diff --git a/libthecore/src/log.cpp b/libthecore/src/log.cpp index 979b72d..fdaa39d 100644 --- a/libthecore/src/log.cpp +++ b/libthecore/src/log.cpp @@ -126,7 +126,7 @@ void _sys_err(const char *func, int line, const char *format, ...) return; time_s[strlen(time_s) - 1] = '\0'; - len = snprintf(buf, 1024, "SYSERR: %-15.15s.%d :: %s: ", time_s + 4, tv.tv_usec, func); + len = snprintf(buf, 1024, "SYSERR: %-15.15s.%ld :: %s: ", time_s + 4, tv.tv_usec, func); buf[1025] = '\0'; if (len < 1024) @@ -211,7 +211,7 @@ void sys_log(unsigned int bit, const char *format, ...) fprintf(log_file_sys->fp, sys_log_header_string); time_s[strlen(time_s) - 1] = '\0'; - fprintf(log_file_sys->fp, "%-15.15s.%d :: ", time_s + 4, tv.tv_usec ); + fprintf(log_file_sys->fp, "%-15.15s.%ld :: ", time_s + 4, tv.tv_usec ); va_start(args, format); vfprintf(log_file_sys->fp, format, args); @@ -403,8 +403,8 @@ void log_file_rotate(LPLOGFILE logfile) { struct tm curr_tm; time_t time_s; - char dir[128]; - char system_cmd[128]; + char dir[256]; + char system_cmd[256]; time_s = time(0); curr_tm = *localtime(&time_s); @@ -429,7 +429,7 @@ void log_file_rotate(LPLOGFILE logfile) if (curr_tm.tm_hour != logfile->last_hour) { struct stat stat_buf; - snprintf(dir, 128, "%s/%04d%02d%02d", log_dir, curr_tm.tm_year + 1900, curr_tm.tm_mon + 1, curr_tm.tm_mday); + snprintf(dir, sizeof(dir), "%s/%04d%02d%02d", log_dir, curr_tm.tm_year + 1900, curr_tm.tm_mon + 1, curr_tm.tm_mday); if (stat(dir, &stat_buf) != 0 || S_ISDIR(stat_buf.st_mode)) { @@ -448,9 +448,9 @@ void log_file_rotate(LPLOGFILE logfile) // ¿Å±ä´Ù. #ifndef __WIN32__ - snprintf(system_cmd, 128, "mv %s %s/%s.%02d", logfile->filename, dir, logfile->filename, logfile->last_hour); + snprintf(system_cmd, sizeof(system_cmd), "mv %s %s/%s.%02d", logfile->filename, dir, logfile->filename, logfile->last_hour); #else - snprintf(system_cmd, 128, "move %s %s\\%s.%02d", logfile->filename, dir, logfile->filename, logfile->last_hour); + snprintf(system_cmd, sizeof(system_cmd), "move %s %s\\%s.%02d", logfile->filename, dir, logfile->filename, logfile->last_hour); #endif system(system_cmd); diff --git a/libthecore/src/utils.cpp b/libthecore/src/utils.cpp index 49bf6e0..16b8eaa 100644 --- a/libthecore/src/utils.cpp +++ b/libthecore/src/utils.cpp @@ -6,6 +6,7 @@ */ #define __LIBTHECORE__ #include "stdafx.h" +#include static struct timeval null_time = { 0, 0 }; @@ -473,3 +474,44 @@ DWORD get_dword_time() tv.tv_sec -= get_boot_sec(); return (tv.tv_sec * 1000 + tv.tv_usec / 1000); } + +std::string GetSocketHost(const sockaddr * address) { + sockaddr_in* peer; + sockaddr_in6* peer6; + char host[MAX_HOST_LENGTH + 1]; + + switch (address->sa_family) { + case AF_INET: + peer = (sockaddr_in*) address; + return inet_ntop(AF_INET, &(peer->sin_addr), host, INET_ADDRSTRLEN); + + case AF_INET6: + peer6 = (sockaddr_in6*) address; + return inet_ntop(AF_INET, &(peer6->sin6_addr), host, INET6_ADDRSTRLEN); + + default: + break; + } + + return ""; +} + +in_port_t GetSocketPort(const sockaddr * address) { + sockaddr_in* peer; + sockaddr_in6* peer6; + + switch (address->sa_family) { + case AF_INET: + peer = (sockaddr_in*) address; + return peer->sin_port; + + case AF_INET6: + peer6 = (sockaddr_in6*) address; + return peer6->sin6_port; + + default: + break; + } + + return 0; +} \ No newline at end of file diff --git a/quest/src/crc32.cc b/quest/src/crc32.cc index 6d82114..47cabd6 100644 --- a/quest/src/crc32.cc +++ b/quest/src/crc32.cc @@ -1,6 +1,6 @@ #include "crc32.h" -static unsigned long CRCTable[256] = +static unsigned int CRCTable[256] = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, @@ -122,7 +122,7 @@ crc_t get_crc32_case(const char * buf, size_t len) crc_t get_fast_hash(const char * key, size_t len) { const char * end = key + len; - unsigned long h = 0; + unsigned int h = 0; while (key < end) { diff --git a/quest/src/crc32.h b/quest/src/crc32.h index 11dc16d..c4aebeb 100644 --- a/quest/src/crc32.h +++ b/quest/src/crc32.h @@ -5,7 +5,7 @@ #include #endif -typedef unsigned long crc_t; +typedef unsigned int crc_t; crc_t get_crc32(const char * buffer, size_t count); crc_t get_crc32_case(const char * buffer, size_t count);