forked from metin2/server
Rewrote network stack, started working on porting to 64-bit
This commit is contained in:
parent
64596d344c
commit
a056345a7b
|
@ -0,0 +1,19 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="ConstantConditionsOC" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="ConstantFunctionResult" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="ConstantParameter" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="DanglingPointer" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="EndlessLoop" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="InfiniteRecursion" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="LocalValueEscapesScope" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="LoopDoesntUseConditionVariable" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="NullDereference" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="UnreachableCallsOfFunction" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="UnreachableCode" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="UnusedLocalVariable" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="UnusedParameter" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="UnusedValue" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
|
@ -11,9 +11,9 @@ namespace building
|
||||||
typedef struct SLand
|
typedef struct SLand
|
||||||
{
|
{
|
||||||
DWORD dwID;
|
DWORD dwID;
|
||||||
long lMapIndex;
|
int lMapIndex;
|
||||||
long x, y;
|
int x, y;
|
||||||
long width, height;
|
int width, height;
|
||||||
DWORD dwGuildID;
|
DWORD dwGuildID;
|
||||||
BYTE bGuildLevelLimit;
|
BYTE bGuildLevelLimit;
|
||||||
DWORD dwPrice;
|
DWORD dwPrice;
|
||||||
|
@ -34,12 +34,12 @@ namespace building
|
||||||
|
|
||||||
DWORD dwUpgradeVnum;
|
DWORD dwUpgradeVnum;
|
||||||
DWORD dwUpgradeLimitTime;
|
DWORD dwUpgradeLimitTime;
|
||||||
long lLife;
|
int lLife;
|
||||||
long lRegion[4];
|
int lRegion[4];
|
||||||
|
|
||||||
DWORD dwNPCVnum;
|
DWORD dwNPCVnum;
|
||||||
long lNPCX;
|
int lNPCX;
|
||||||
long lNPCY;
|
int lNPCY;
|
||||||
|
|
||||||
DWORD dwGroupVnum; // 같은 그룹은 하나만 건설가능
|
DWORD dwGroupVnum; // 같은 그룹은 하나만 건설가능
|
||||||
DWORD dwDependOnGroupVnum; // 지어져 있어야하는 그룹
|
DWORD dwDependOnGroupVnum; // 지어져 있어야하는 그룹
|
||||||
|
@ -50,13 +50,13 @@ namespace building
|
||||||
DWORD dwID;
|
DWORD dwID;
|
||||||
DWORD dwLandID;
|
DWORD dwLandID;
|
||||||
DWORD dwVnum;
|
DWORD dwVnum;
|
||||||
long lMapIndex;
|
int lMapIndex;
|
||||||
long x, y;
|
int x, y;
|
||||||
|
|
||||||
float xRot;
|
float xRot;
|
||||||
float yRot;
|
float yRot;
|
||||||
float zRot;
|
float zRot;
|
||||||
long lLife;
|
int lLife;
|
||||||
} TObject;
|
} TObject;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -67,9 +67,6 @@ enum EMisc
|
||||||
//LIMIT_GOLD
|
//LIMIT_GOLD
|
||||||
GOLD_MAX = 2000000000,
|
GOLD_MAX = 2000000000,
|
||||||
|
|
||||||
MAX_PASSPOD = 8 ,
|
|
||||||
|
|
||||||
|
|
||||||
//END_LIMIT_GOLD
|
//END_LIMIT_GOLD
|
||||||
|
|
||||||
SHOP_TAB_NAME_MAX = 32,
|
SHOP_TAB_NAME_MAX = 32,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#ifndef __INC_SERVICE_H__
|
#ifndef __INC_SERVICE_H__
|
||||||
#define __INC_SERVICE_H__
|
#define __INC_SERVICE_H__
|
||||||
|
|
||||||
#define _IMPROVED_PACKET_ENCRYPTION_ // 패킷 암호화 개선
|
|
||||||
//#define __AUCTION__
|
//#define __AUCTION__
|
||||||
#define __PET_SYSTEM__
|
#define __PET_SYSTEM__
|
||||||
#endif
|
#endif
|
||||||
|
|
169
common/tables.h
169
common/tables.h
|
@ -292,37 +292,8 @@ enum
|
||||||
|
|
||||||
HEADER_DG_MAP_LOCATIONS = 0xfe,
|
HEADER_DG_MAP_LOCATIONS = 0xfe,
|
||||||
HEADER_DG_P2P = 0xff,
|
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
|
* table
|
||||||
* ----------------------------------------------
|
* ----------------------------------------------
|
||||||
|
@ -356,8 +327,8 @@ typedef struct SSimplePlayer
|
||||||
BYTE bChangeName;
|
BYTE bChangeName;
|
||||||
WORD wHairPart;
|
WORD wHairPart;
|
||||||
BYTE bDummy[4];
|
BYTE bDummy[4];
|
||||||
long x, y;
|
LONG x, y;
|
||||||
long lAddr;
|
LONG lAddr;
|
||||||
WORD wPort;
|
WORD wPort;
|
||||||
BYTE skill_group;
|
BYTE skill_group;
|
||||||
} TSimplePlayer;
|
} TSimplePlayer;
|
||||||
|
@ -382,7 +353,7 @@ typedef struct SPacketDGCreateSuccess
|
||||||
typedef struct TPlayerItemAttribute
|
typedef struct TPlayerItemAttribute
|
||||||
{
|
{
|
||||||
BYTE bType;
|
BYTE bType;
|
||||||
short sValue;
|
WORD sValue;
|
||||||
} TPlayerItemAttribute;
|
} TPlayerItemAttribute;
|
||||||
|
|
||||||
typedef struct SPlayerItem
|
typedef struct SPlayerItem
|
||||||
|
@ -393,7 +364,7 @@ typedef struct SPlayerItem
|
||||||
DWORD count;
|
DWORD count;
|
||||||
|
|
||||||
DWORD vnum;
|
DWORD vnum;
|
||||||
long alSockets[ITEM_SOCKET_MAX_NUM]; // 소켓번호
|
LONG alSockets[ITEM_SOCKET_MAX_NUM]; // 소켓번호
|
||||||
|
|
||||||
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
||||||
|
|
||||||
|
@ -417,8 +388,8 @@ struct THorseInfo
|
||||||
{
|
{
|
||||||
BYTE bLevel;
|
BYTE bLevel;
|
||||||
BYTE bRiding;
|
BYTE bRiding;
|
||||||
short sStamina;
|
WORD sStamina;
|
||||||
short sHealth;
|
WORD sHealth;
|
||||||
DWORD dwHorseHealthDropTime;
|
DWORD dwHorseHealthDropTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -434,7 +405,7 @@ typedef struct SPlayerTable
|
||||||
|
|
||||||
BYTE level;
|
BYTE level;
|
||||||
BYTE level_step;
|
BYTE level_step;
|
||||||
short st, ht, dx, iq;
|
WORD st, ht, dx, iq;
|
||||||
|
|
||||||
DWORD exp;
|
DWORD exp;
|
||||||
INT gold;
|
INT gold;
|
||||||
|
@ -443,21 +414,21 @@ typedef struct SPlayerTable
|
||||||
INT x, y, z;
|
INT x, y, z;
|
||||||
INT lMapIndex;
|
INT lMapIndex;
|
||||||
|
|
||||||
long lExitX, lExitY;
|
LONG lExitX, lExitY;
|
||||||
long lExitMapIndex;
|
LONG lExitMapIndex;
|
||||||
|
|
||||||
short hp;
|
WORD hp;
|
||||||
short sp;
|
WORD sp;
|
||||||
|
|
||||||
short sRandomHP;
|
WORD sRandomHP;
|
||||||
short sRandomSP;
|
WORD sRandomSP;
|
||||||
|
|
||||||
int playtime;
|
DWORD playtime;
|
||||||
|
|
||||||
short stat_point;
|
WORD stat_point;
|
||||||
short skill_point;
|
WORD skill_point;
|
||||||
short sub_skill_point;
|
WORD sub_skill_point;
|
||||||
short horse_skill_point;
|
WORD horse_skill_point;
|
||||||
|
|
||||||
TPlayerSkill skills[SKILL_MAX_NUM];
|
TPlayerSkill skills[SKILL_MAX_NUM];
|
||||||
|
|
||||||
|
@ -466,19 +437,19 @@ typedef struct SPlayerTable
|
||||||
BYTE part_base;
|
BYTE part_base;
|
||||||
WORD parts[PART_MAX_NUM];
|
WORD parts[PART_MAX_NUM];
|
||||||
|
|
||||||
short stamina;
|
WORD stamina;
|
||||||
|
|
||||||
BYTE skill_group;
|
BYTE skill_group;
|
||||||
long lAlignment;
|
LONG lAlignment;
|
||||||
char szMobile[MOBILE_MAX_LEN + 1];
|
char szMobile[MOBILE_MAX_LEN + 1];
|
||||||
|
|
||||||
short stat_reset_count;
|
WORD stat_reset_count;
|
||||||
|
|
||||||
THorseInfo horse;
|
THorseInfo horse;
|
||||||
|
|
||||||
DWORD logoff_interval;
|
DWORD logoff_interval;
|
||||||
|
|
||||||
int aiPremiumTimes[PREMIUM_MAX_NUM];
|
DWORD aiPremiumTimes[PREMIUM_MAX_NUM];
|
||||||
} TPlayerTable;
|
} TPlayerTable;
|
||||||
|
|
||||||
typedef struct SMobSkillLevel
|
typedef struct SMobSkillLevel
|
||||||
|
@ -518,8 +489,8 @@ typedef struct SMobTable : public SEntityTable
|
||||||
BYTE bStr, bDex, bCon, bInt;
|
BYTE bStr, bDex, bCon, bInt;
|
||||||
DWORD dwDamageRange[2];
|
DWORD dwDamageRange[2];
|
||||||
|
|
||||||
short sAttackSpeed;
|
WORD sAttackSpeed;
|
||||||
short sMovingSpeed;
|
WORD sMovingSpeed;
|
||||||
BYTE bAggresiveHPPct;
|
BYTE bAggresiveHPPct;
|
||||||
WORD wAggressiveSight;
|
WORD wAggressiveSight;
|
||||||
WORD wAttackRange;
|
WORD wAttackRange;
|
||||||
|
@ -588,7 +559,7 @@ typedef struct SSkillTable
|
||||||
DWORD preSkillVnum;
|
DWORD preSkillVnum;
|
||||||
BYTE preSkillLevel;
|
BYTE preSkillLevel;
|
||||||
|
|
||||||
long lMaxHit;
|
LONG lMaxHit;
|
||||||
char szSplashAroundDamageAdjustPoly[100 + 1];
|
char szSplashAroundDamageAdjustPoly[100 + 1];
|
||||||
|
|
||||||
BYTE bSkillAttrType;
|
BYTE bSkillAttrType;
|
||||||
|
@ -623,19 +594,19 @@ typedef struct SQuestTable
|
||||||
DWORD dwPID;
|
DWORD dwPID;
|
||||||
char szName[QUEST_NAME_MAX_LEN + 1];
|
char szName[QUEST_NAME_MAX_LEN + 1];
|
||||||
char szState[QUEST_STATE_MAX_LEN + 1];
|
char szState[QUEST_STATE_MAX_LEN + 1];
|
||||||
long lValue;
|
LONG lValue;
|
||||||
} TQuestTable;
|
} TQuestTable;
|
||||||
|
|
||||||
typedef struct SItemLimit
|
typedef struct SItemLimit
|
||||||
{
|
{
|
||||||
BYTE bType;
|
BYTE bType;
|
||||||
long lValue;
|
LONG lValue;
|
||||||
} TItemLimit;
|
} TItemLimit;
|
||||||
|
|
||||||
typedef struct SItemApply
|
typedef struct SItemApply
|
||||||
{
|
{
|
||||||
BYTE bType;
|
BYTE bType;
|
||||||
long lValue;
|
LONG lValue;
|
||||||
} TItemApply;
|
} TItemApply;
|
||||||
|
|
||||||
typedef struct SItemTable : public SEntityTable
|
typedef struct SItemTable : public SEntityTable
|
||||||
|
@ -659,15 +630,15 @@ typedef struct SItemTable : public SEntityTable
|
||||||
|
|
||||||
TItemLimit aLimits[ITEM_LIMIT_MAX_NUM];
|
TItemLimit aLimits[ITEM_LIMIT_MAX_NUM];
|
||||||
TItemApply aApplies[ITEM_APPLY_MAX_NUM];
|
TItemApply aApplies[ITEM_APPLY_MAX_NUM];
|
||||||
long alValues[ITEM_VALUES_MAX_NUM];
|
LONG alValues[ITEM_VALUES_MAX_NUM];
|
||||||
long alSockets[ITEM_SOCKET_MAX_NUM];
|
LONG alSockets[ITEM_SOCKET_MAX_NUM];
|
||||||
DWORD dwRefinedVnum;
|
DWORD dwRefinedVnum;
|
||||||
WORD wRefineSet;
|
WORD wRefineSet;
|
||||||
BYTE bAlterToMagicItemPct;
|
BYTE bAlterToMagicItemPct;
|
||||||
BYTE bSpecular;
|
BYTE bSpecular;
|
||||||
BYTE bGainSocketPct;
|
BYTE bGainSocketPct;
|
||||||
|
|
||||||
short int sAddonType; // 기본 속성
|
WORD sAddonType; // 기본 속성
|
||||||
|
|
||||||
// 아래 limit flag들은 realtime에 체크 할 일이 많고, 아이템 VNUM당 고정된 값인데,
|
// 아래 limit flag들은 realtime에 체크 할 일이 많고, 아이템 VNUM당 고정된 값인데,
|
||||||
// 현재 구조대로 매번 아이템마다 필요한 경우에 LIMIT_MAX_NUM까지 루프돌면서 체크하는 부하가 커서 미리 저장 해 둠.
|
// 현재 구조대로 매번 아이템마다 필요한 경우에 LIMIT_MAX_NUM까지 루프돌면서 체크하는 부하가 커서 미리 저장 해 둠.
|
||||||
|
@ -690,7 +661,7 @@ struct TItemAttrTable
|
||||||
char szApply[APPLY_NAME_MAX_LEN + 1];
|
char szApply[APPLY_NAME_MAX_LEN + 1];
|
||||||
DWORD dwApplyIndex;
|
DWORD dwApplyIndex;
|
||||||
DWORD dwProb;
|
DWORD dwProb;
|
||||||
long lValues[5];
|
LONG lValues[5];
|
||||||
BYTE bMaxLevelBySet[ATTRIBUTE_SET_MAX_NUM];
|
BYTE bMaxLevelBySet[ATTRIBUTE_SET_MAX_NUM];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -790,7 +761,7 @@ typedef struct SPacketGDSetup
|
||||||
BYTE bChannel; // 채널
|
BYTE bChannel; // 채널
|
||||||
WORD wListenPort; // 클라이언트가 접속하는 포트 번호
|
WORD wListenPort; // 클라이언트가 접속하는 포트 번호
|
||||||
WORD wP2PPort; // 서버끼리 연결 시키는 P2P 포트 번호
|
WORD wP2PPort; // 서버끼리 연결 시키는 P2P 포트 번호
|
||||||
long alMaps[32];
|
LONG alMaps[32];
|
||||||
DWORD dwLoginCount;
|
DWORD dwLoginCount;
|
||||||
BYTE bAuthServer;
|
BYTE bAuthServer;
|
||||||
} TPacketGDSetup;
|
} TPacketGDSetup;
|
||||||
|
@ -802,7 +773,7 @@ typedef struct SPacketDGMapLocations
|
||||||
|
|
||||||
typedef struct SMapLocation
|
typedef struct SMapLocation
|
||||||
{
|
{
|
||||||
long alMaps[32];
|
LONG alMaps[32];
|
||||||
char szHost[MAX_HOST_LENGTH + 1];
|
char szHost[MAX_HOST_LENGTH + 1];
|
||||||
WORD wPort;
|
WORD wPort;
|
||||||
} TMapLocation;
|
} TMapLocation;
|
||||||
|
@ -830,7 +801,7 @@ typedef struct SPacketDGDirectEnter
|
||||||
typedef struct SPacketGuildSkillUpdate
|
typedef struct SPacketGuildSkillUpdate
|
||||||
{
|
{
|
||||||
DWORD guild_id;
|
DWORD guild_id;
|
||||||
int amount;
|
DWORD amount;
|
||||||
BYTE skill_levels[12];
|
BYTE skill_levels[12];
|
||||||
BYTE skill_point;
|
BYTE skill_point;
|
||||||
BYTE save;
|
BYTE save;
|
||||||
|
@ -839,7 +810,7 @@ typedef struct SPacketGuildSkillUpdate
|
||||||
typedef struct SPacketGuildExpUpdate
|
typedef struct SPacketGuildExpUpdate
|
||||||
{
|
{
|
||||||
DWORD guild_id;
|
DWORD guild_id;
|
||||||
int amount;
|
DWORD amount;
|
||||||
} TPacketGuildExpUpdate;
|
} TPacketGuildExpUpdate;
|
||||||
|
|
||||||
typedef struct SPacketGuildChangeMemberData
|
typedef struct SPacketGuildChangeMemberData
|
||||||
|
@ -861,10 +832,10 @@ typedef struct TPacketAffectElement
|
||||||
{
|
{
|
||||||
DWORD dwType;
|
DWORD dwType;
|
||||||
BYTE bApplyOn;
|
BYTE bApplyOn;
|
||||||
long lApplyValue;
|
LONG lApplyValue;
|
||||||
DWORD dwFlag;
|
DWORD dwFlag;
|
||||||
long lDuration;
|
LONG lDuration;
|
||||||
long lSPCost;
|
LONG lSPCost;
|
||||||
} TPacketAffectElement;
|
} TPacketAffectElement;
|
||||||
|
|
||||||
typedef struct SPacketGDAddAffect
|
typedef struct SPacketGDAddAffect
|
||||||
|
@ -883,7 +854,7 @@ typedef struct SPacketGDRemoveAffect
|
||||||
typedef struct SPacketGDHighscore
|
typedef struct SPacketGDHighscore
|
||||||
{
|
{
|
||||||
DWORD dwPID;
|
DWORD dwPID;
|
||||||
long lValue;
|
LONG lValue;
|
||||||
char cDir;
|
char cDir;
|
||||||
char szBoard[21];
|
char szBoard[21];
|
||||||
} TPacketGDHighscore;
|
} TPacketGDHighscore;
|
||||||
|
@ -963,8 +934,8 @@ typedef struct SPacketGuildWar
|
||||||
BYTE bWar;
|
BYTE bWar;
|
||||||
DWORD dwGuildFrom;
|
DWORD dwGuildFrom;
|
||||||
DWORD dwGuildTo;
|
DWORD dwGuildTo;
|
||||||
long lWarPrice;
|
LONG lWarPrice;
|
||||||
long lInitialScore;
|
LONG lInitialScore;
|
||||||
} TPacketGuildWar;
|
} TPacketGuildWar;
|
||||||
|
|
||||||
// Game -> DB : 상대적 변화값
|
// Game -> DB : 상대적 변화값
|
||||||
|
@ -973,14 +944,14 @@ typedef struct SPacketGuildWarScore
|
||||||
{
|
{
|
||||||
DWORD dwGuildGainPoint;
|
DWORD dwGuildGainPoint;
|
||||||
DWORD dwGuildOpponent;
|
DWORD dwGuildOpponent;
|
||||||
long lScore;
|
LONG lScore;
|
||||||
long lBetScore;
|
LONG lBetScore;
|
||||||
} TPacketGuildWarScore;
|
} TPacketGuildWarScore;
|
||||||
|
|
||||||
typedef struct SRefineMaterial
|
typedef struct SRefineMaterial
|
||||||
{
|
{
|
||||||
DWORD vnum;
|
DWORD vnum;
|
||||||
int count;
|
DWORD count;
|
||||||
} TRefineMaterial;
|
} TRefineMaterial;
|
||||||
|
|
||||||
typedef struct SRefineTable
|
typedef struct SRefineTable
|
||||||
|
@ -989,8 +960,8 @@ typedef struct SRefineTable
|
||||||
//DWORD result_vnum;
|
//DWORD result_vnum;
|
||||||
DWORD id;
|
DWORD id;
|
||||||
BYTE material_count;
|
BYTE material_count;
|
||||||
int cost; // 소요 비용
|
DWORD cost; // 소요 비용
|
||||||
int prob; // 확률
|
DWORD prob; // 확률
|
||||||
TRefineMaterial materials[REFINE_MATERIAL_MAX_NUM];
|
TRefineMaterial materials[REFINE_MATERIAL_MAX_NUM];
|
||||||
} TRefineTable;
|
} TRefineTable;
|
||||||
|
|
||||||
|
@ -1014,16 +985,16 @@ typedef struct SPacketDGChangeName
|
||||||
typedef struct SPacketGuildLadder
|
typedef struct SPacketGuildLadder
|
||||||
{
|
{
|
||||||
DWORD dwGuild;
|
DWORD dwGuild;
|
||||||
long lLadderPoint;
|
LONG lLadderPoint;
|
||||||
long lWin;
|
LONG lWin;
|
||||||
long lDraw;
|
LONG lDraw;
|
||||||
long lLoss;
|
LONG lLoss;
|
||||||
} TPacketGuildLadder;
|
} TPacketGuildLadder;
|
||||||
|
|
||||||
typedef struct SPacketGuildLadderPoint
|
typedef struct SPacketGuildLadderPoint
|
||||||
{
|
{
|
||||||
DWORD dwGuild;
|
DWORD dwGuild;
|
||||||
long lChange;
|
LONG lChange;
|
||||||
} TPacketGuildLadderPoint;
|
} TPacketGuildLadderPoint;
|
||||||
|
|
||||||
typedef struct SPacketGDSMS
|
typedef struct SPacketGDSMS
|
||||||
|
@ -1063,7 +1034,7 @@ typedef struct SPacketGDAuthLogin
|
||||||
DWORD adwClientKey[4];
|
DWORD adwClientKey[4];
|
||||||
BYTE bBillType;
|
BYTE bBillType;
|
||||||
DWORD dwBillID;
|
DWORD dwBillID;
|
||||||
int iPremiumTimes[PREMIUM_MAX_NUM];
|
DWORD iPremiumTimes[PREMIUM_MAX_NUM];
|
||||||
} TPacketGDAuthLogin;
|
} TPacketGDAuthLogin;
|
||||||
|
|
||||||
typedef struct SPacketGDLoginByKey
|
typedef struct SPacketGDLoginByKey
|
||||||
|
@ -1080,21 +1051,21 @@ typedef struct SPacketGDLoginByKey
|
||||||
typedef struct SPacketGiveGuildPriv
|
typedef struct SPacketGiveGuildPriv
|
||||||
{
|
{
|
||||||
BYTE type;
|
BYTE type;
|
||||||
int value;
|
DWORD value;
|
||||||
DWORD guild_id;
|
DWORD guild_id;
|
||||||
time_t duration_sec; ///< 지속시간
|
time_t duration_sec; ///< 지속시간
|
||||||
} TPacketGiveGuildPriv;
|
} TPacketGiveGuildPriv;
|
||||||
typedef struct SPacketGiveEmpirePriv
|
typedef struct SPacketGiveEmpirePriv
|
||||||
{
|
{
|
||||||
BYTE type;
|
BYTE type;
|
||||||
int value;
|
DWORD value;
|
||||||
BYTE empire;
|
BYTE empire;
|
||||||
time_t duration_sec;
|
time_t duration_sec;
|
||||||
} TPacketGiveEmpirePriv;
|
} TPacketGiveEmpirePriv;
|
||||||
typedef struct SPacketGiveCharacterPriv
|
typedef struct SPacketGiveCharacterPriv
|
||||||
{
|
{
|
||||||
BYTE type;
|
BYTE type;
|
||||||
int value;
|
DWORD value;
|
||||||
DWORD pid;
|
DWORD pid;
|
||||||
} TPacketGiveCharacterPriv;
|
} TPacketGiveCharacterPriv;
|
||||||
typedef struct SPacketRemoveGuildPriv
|
typedef struct SPacketRemoveGuildPriv
|
||||||
|
@ -1111,7 +1082,7 @@ typedef struct SPacketRemoveEmpirePriv
|
||||||
typedef struct SPacketDGChangeCharacterPriv
|
typedef struct SPacketDGChangeCharacterPriv
|
||||||
{
|
{
|
||||||
BYTE type;
|
BYTE type;
|
||||||
int value;
|
DWORD value;
|
||||||
DWORD pid;
|
DWORD pid;
|
||||||
BYTE bLog;
|
BYTE bLog;
|
||||||
} TPacketDGChangeCharacterPriv;
|
} TPacketDGChangeCharacterPriv;
|
||||||
|
@ -1122,7 +1093,7 @@ typedef struct SPacketDGChangeCharacterPriv
|
||||||
typedef struct SPacketDGChangeGuildPriv
|
typedef struct SPacketDGChangeGuildPriv
|
||||||
{
|
{
|
||||||
BYTE type;
|
BYTE type;
|
||||||
int value;
|
DWORD value;
|
||||||
DWORD guild_id;
|
DWORD guild_id;
|
||||||
BYTE bLog;
|
BYTE bLog;
|
||||||
time_t end_time_sec; ///< 지속시간
|
time_t end_time_sec; ///< 지속시간
|
||||||
|
@ -1131,7 +1102,7 @@ typedef struct SPacketDGChangeGuildPriv
|
||||||
typedef struct SPacketDGChangeEmpirePriv
|
typedef struct SPacketDGChangeEmpirePriv
|
||||||
{
|
{
|
||||||
BYTE type;
|
BYTE type;
|
||||||
int value;
|
DWORD value;
|
||||||
BYTE empire;
|
BYTE empire;
|
||||||
BYTE bLog;
|
BYTE bLog;
|
||||||
time_t end_time_sec;
|
time_t end_time_sec;
|
||||||
|
@ -1172,7 +1143,7 @@ typedef struct SPacketGDGuildMoneyWithdrawGiveReply
|
||||||
typedef struct SPacketSetEventFlag
|
typedef struct SPacketSetEventFlag
|
||||||
{
|
{
|
||||||
char szFlagName[EVENT_FLAG_NAME_MAX_LEN + 1];
|
char szFlagName[EVENT_FLAG_NAME_MAX_LEN + 1];
|
||||||
long lValue;
|
LONG lValue;
|
||||||
} TPacketSetEventFlag;
|
} TPacketSetEventFlag;
|
||||||
|
|
||||||
typedef struct SPacketBillingLogin
|
typedef struct SPacketBillingLogin
|
||||||
|
@ -1238,14 +1209,14 @@ typedef struct SGuildReserve
|
||||||
DWORD dwGuildTo;
|
DWORD dwGuildTo;
|
||||||
DWORD dwTime;
|
DWORD dwTime;
|
||||||
BYTE bType;
|
BYTE bType;
|
||||||
long lWarPrice;
|
LONG lWarPrice;
|
||||||
long lInitialScore;
|
LONG lInitialScore;
|
||||||
bool bStarted;
|
bool bStarted;
|
||||||
DWORD dwBetFrom;
|
DWORD dwBetFrom;
|
||||||
DWORD dwBetTo;
|
DWORD dwBetTo;
|
||||||
long lPowerFrom;
|
LONG lPowerFrom;
|
||||||
long lPowerTo;
|
LONG lPowerTo;
|
||||||
long lHandicap;
|
LONG lHandicap;
|
||||||
} TGuildWarReserve;
|
} TGuildWarReserve;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -1332,7 +1303,7 @@ typedef struct SItemPriceListTable
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char szName[CHARACTER_NAME_MAX_LEN + 1];
|
char szName[CHARACTER_NAME_MAX_LEN + 1];
|
||||||
long lDuration;
|
LONG lDuration;
|
||||||
} TPacketBlockChat;
|
} TPacketBlockChat;
|
||||||
|
|
||||||
// PCBANG_IP_LIST
|
// PCBANG_IP_LIST
|
||||||
|
@ -1347,12 +1318,12 @@ typedef struct SPacketPCBangIP
|
||||||
//ADMIN_MANAGER
|
//ADMIN_MANAGER
|
||||||
typedef struct TAdminInfo
|
typedef struct TAdminInfo
|
||||||
{
|
{
|
||||||
int m_ID; //고유ID
|
DWORD m_ID; //고유ID
|
||||||
char m_szAccount[32]; //계정
|
char m_szAccount[32]; //계정
|
||||||
char m_szName[32]; //캐릭터이름
|
char m_szName[32]; //캐릭터이름
|
||||||
char m_szContactIP[16]; //접근아이피
|
char m_szContactIP[16]; //접근아이피
|
||||||
char m_szServerIP[16]; //서버아이피
|
char m_szServerIP[16]; //서버아이피
|
||||||
int m_Authority; //권한
|
DWORD m_Authority; //권한
|
||||||
} tAdminInfo;
|
} tAdminInfo;
|
||||||
//END_ADMIN_MANAGER
|
//END_ADMIN_MANAGER
|
||||||
|
|
||||||
|
@ -1463,7 +1434,7 @@ typedef struct tItemAwardInformer
|
||||||
{
|
{
|
||||||
char login[LOGIN_MAX_LEN + 1];
|
char login[LOGIN_MAX_LEN + 1];
|
||||||
char command[20]; //명령어
|
char command[20]; //명령어
|
||||||
unsigned int vnum; //아이템
|
DWORD vnum; //아이템
|
||||||
} TPacketItemAwardInfromer;
|
} TPacketItemAwardInfromer;
|
||||||
// 선물 알림 기능 삭제용 패킷 정보
|
// 선물 알림 기능 삭제용 패킷 정보
|
||||||
typedef struct tDeleteAwardID
|
typedef struct tDeleteAwardID
|
||||||
|
@ -1473,7 +1444,7 @@ typedef struct tDeleteAwardID
|
||||||
|
|
||||||
typedef struct SChannelStatus
|
typedef struct SChannelStatus
|
||||||
{
|
{
|
||||||
short nPort;
|
WORD nPort;
|
||||||
BYTE bStatus;
|
BYTE bStatus;
|
||||||
} TChannelStatus;
|
} TChannelStatus;
|
||||||
|
|
||||||
|
|
|
@ -55,27 +55,11 @@ inline bool str_to_number (unsigned int& out, const char *in)
|
||||||
return true;
|
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;
|
if (0==in || 0==in[0]) return false;
|
||||||
|
|
||||||
out = (long) strtol(in, NULL, 10);
|
out = (int64_t) strtoull(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);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,23 +71,4 @@ inline bool str_to_number (float& out, const char *in)
|
||||||
return true;
|
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 -----*/
|
/*----- atoi function -----*/
|
||||||
|
|
|
@ -109,7 +109,7 @@ bool CBlockCountry::IsBlockedCountryIp(const char *user_ip)
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
if (0 == inet_aton(user_ip, &st_addr))
|
if (0 == inet_aton(user_ip, &st_addr))
|
||||||
#else
|
#else
|
||||||
unsigned long in_address;
|
unsigned int in_address;
|
||||||
in_address = inet_addr(user_ip);
|
in_address = inet_addr(user_ip);
|
||||||
st_addr.s_addr = in_address;
|
st_addr.s_addr = in_address;
|
||||||
if (INADDR_NONE == in_address)
|
if (INADDR_NONE == in_address)
|
||||||
|
|
|
@ -69,16 +69,16 @@ void CItemCache::OnFlush()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
long alSockets[ITEM_SOCKET_MAX_NUM];
|
int alSockets[ITEM_SOCKET_MAX_NUM];
|
||||||
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
||||||
bool isSocket = false, isAttr = false;
|
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);
|
memset(&aAttr, 0, sizeof(TPlayerItemAttribute) * ITEM_ATTRIBUTE_MAX_NUM);
|
||||||
|
|
||||||
TPlayerItem * p = &m_data;
|
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;
|
isSocket = true;
|
||||||
|
|
||||||
if (memcmp(aAttr, p->aAttr, sizeof(TPlayerItemAttribute) * ITEM_ATTRIBUTE_MAX_NUM))
|
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");
|
iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen, ", socket0, socket1, socket2");
|
||||||
iValueLen += snprintf(szValues + iValueLen, sizeof(szValues) - iValueLen,
|
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,
|
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)
|
if (isAttr)
|
||||||
|
|
|
@ -58,7 +58,7 @@ static void AcceptConnection(
|
||||||
CPeer* peer = clientManager->AddPeer(bev, address);
|
CPeer* peer = clientManager->AddPeer(bev, address);
|
||||||
|
|
||||||
// Set the event handlers for this peer
|
// Set the event handlers for this peer
|
||||||
bufferevent_setcb(bev, ReadHandler, WriteHandler, EventHandler, peer);
|
bufferevent_setcb(bev, DescReadHandler, DescWriteHandler, DescEventHandler, peer);
|
||||||
|
|
||||||
// Enable the events
|
// Enable the events
|
||||||
bufferevent_enable(bev, EV_READ|EV_WRITE);
|
bufferevent_enable(bev, EV_READ|EV_WRITE);
|
||||||
|
@ -73,7 +73,7 @@ static void AcceptError(evconnlistener *listener, void *ctx) {
|
||||||
event_base_loopexit(base, NULL);
|
event_base_loopexit(base, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReadHandler(bufferevent *bev, void *ctx) {
|
static void DescReadHandler(bufferevent *bev, void *ctx) {
|
||||||
auto* peer = (CPeer*) ctx;
|
auto* peer = (CPeer*) ctx;
|
||||||
|
|
||||||
if (peer == CClientManager::Instance().GetAuthPeer())
|
if (peer == CClientManager::Instance().GetAuthPeer())
|
||||||
|
@ -83,7 +83,7 @@ static void ReadHandler(bufferevent *bev, void *ctx) {
|
||||||
CClientManager::Instance().ProcessPackets(peer);
|
CClientManager::Instance().ProcessPackets(peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WriteHandler(bufferevent *bev, void *ctx) {
|
static void DescWriteHandler(bufferevent *bev, void *ctx) {
|
||||||
auto* peer = (CPeer*) ctx;
|
auto* peer = (CPeer*) ctx;
|
||||||
|
|
||||||
if (peer == CClientManager::Instance().GetAuthPeer())
|
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());
|
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;
|
auto* peer = (CPeer*) ctx;
|
||||||
|
|
||||||
if (events & BEV_EVENT_ERROR)
|
if (events & BEV_EVENT_ERROR)
|
||||||
|
@ -195,7 +195,6 @@ bool CClientManager::Initialize()
|
||||||
strncpy(szBindIP, "0", sizeof(szBindIP));
|
strncpy(szBindIP, "0", sizeof(szBindIP));
|
||||||
|
|
||||||
// Create a new libevent base and listen for new connections
|
// Create a new libevent base and listen for new connections
|
||||||
event_enable_debug_mode();
|
|
||||||
m_base = event_base_new();
|
m_base = event_base_new();
|
||||||
if (!m_base) {
|
if (!m_base) {
|
||||||
sys_err("Libevent base initialization FAILED!");
|
sys_err("Libevent base initialization FAILED!");
|
||||||
|
@ -1717,8 +1716,8 @@ void CClientManager::QUERY_SMS(CPeer * pkPeer, TPacketGDSMS * pack)
|
||||||
char szQuery[QUERY_MAX_LEN];
|
char szQuery[QUERY_MAX_LEN];
|
||||||
|
|
||||||
char szMsg[256+1];
|
char szMsg[256+1];
|
||||||
//unsigned long len = CDBManager::instance().EscapeString(szMsg, pack->szMsg, strlen(pack->szMsg), SQL_ACCOUNT);
|
//unsigned int 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));
|
||||||
szMsg[len] = '\0';
|
szMsg[len] = '\0';
|
||||||
|
|
||||||
snprintf(szQuery, sizeof(szQuery),
|
snprintf(szQuery, sizeof(szQuery),
|
||||||
|
|
|
@ -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 AcceptConnection(evconnlistener *listener, evutil_socket_t fd, sockaddr *address, int socklen, void *ctx);
|
||||||
static void AcceptError(evconnlistener *listener, void *ctx);
|
static void AcceptError(evconnlistener *listener, void *ctx);
|
||||||
static void ReadHandler(bufferevent *bev, void *ctx);
|
static void DescReadHandler(bufferevent *bev, void *ctx);
|
||||||
static void WriteHandler(bufferevent *bev, void *ctx);
|
static void DescWriteHandler(bufferevent *bev, void *ctx);
|
||||||
static void EventHandler(bufferevent *bev, short events, void *ctx);
|
static void DescEventHandler(bufferevent *bev, short events, void *ctx);
|
||||||
|
|
||||||
class CClientManager : public singleton<CClientManager>
|
class CClientManager : public singleton<CClientManager>
|
||||||
{
|
{
|
||||||
|
@ -472,7 +472,7 @@ class CClientManager : public singleton<CClientManager>
|
||||||
typedef std::map<BYTE, TPartyMap> TPartyChannelMap;
|
typedef std::map<BYTE, TPartyMap> TPartyChannelMap;
|
||||||
TPartyChannelMap m_map_pkChannelParty;
|
TPartyChannelMap m_map_pkChannelParty;
|
||||||
|
|
||||||
typedef std::map<std::string, long> TEventFlagMap;
|
typedef std::map<std::string, int> TEventFlagMap;
|
||||||
TEventFlagMap m_map_lEventFlag;
|
TEventFlagMap m_map_lEventFlag;
|
||||||
|
|
||||||
BYTE m_bLastHeader;
|
BYTE m_bLastHeader;
|
||||||
|
|
|
@ -160,7 +160,7 @@ size_t CreatePlayerSaveQuery(char * pszQuery, size_t querySize, TPlayerTable * p
|
||||||
pkTab->horse_skill_point);
|
pkTab->horse_skill_point);
|
||||||
|
|
||||||
// Binary 로 바꾸기 위한 임시 공간
|
// Binary 로 바꾸기 위한 임시 공간
|
||||||
static char text[8192 + 1];
|
char text[8192 + 1];
|
||||||
|
|
||||||
CDBManager::instance().EscapeString(text, pkTab->skills, sizeof(pkTab->skills));
|
CDBManager::instance().EscapeString(text, pkTab->skills, sizeof(pkTab->skills));
|
||||||
queryLen += snprintf(pszQuery + queryLen, querySize - queryLen, "skill_level = '%s', ", text);
|
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];
|
char queryStr[QUERY_MAX_LEN];
|
||||||
int queryLen;
|
int queryLen;
|
||||||
int player_id;
|
DWORD player_id;
|
||||||
|
|
||||||
// 한 계정에 X초 내로 캐릭터 생성을 할 수 없다.
|
// 한 계정에 X초 내로 캐릭터 생성을 할 수 없다.
|
||||||
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())
|
if (it != s_createTimeByAccountID.end())
|
||||||
{
|
{
|
||||||
time_t curtime = time(0);
|
time_t curtime = time(nullptr);
|
||||||
|
|
||||||
if (curtime - it->second < 30)
|
if (curtime - it->second < 30)
|
||||||
{
|
{
|
||||||
|
@ -895,7 +895,7 @@ void CClientManager::__QUERY_PLAYER_CREATE(CPeer *peer, DWORD dwHandle, TPlayerC
|
||||||
packet->player_table.ht,
|
packet->player_table.ht,
|
||||||
packet->player_table.job);
|
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));
|
CDBManager::instance().EscapeString(text, packet->player_table.skills, sizeof(packet->player_table.skills));
|
||||||
queryLen += snprintf(queryStr + queryLen, sizeof(queryStr) - queryLen, "'%s', ", text);
|
queryLen += snprintf(queryStr + queryLen, sizeof(queryStr) - queryLen, "'%s', ", text);
|
||||||
|
|
|
@ -157,7 +157,7 @@ void CDBManager::AsyncQuery(const char * c_pszQuery, int iSlot)
|
||||||
++g_query_count[1];
|
++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);
|
assert(iSlot < SQL_MAX_NUM);
|
||||||
return mysql_real_escape_string(m_directSQL[iSlot]->GetSQLHandle(), (char *) to, (const char *) from, length);
|
return mysql_real_escape_string(m_directSQL[iSlot]->GetSQLHandle(), (char *) to, (const char *) from, length);
|
||||||
|
|
|
@ -49,7 +49,7 @@ class CDBManager : public singleton<CDBManager>
|
||||||
SQLMsg * PopResult();
|
SQLMsg * PopResult();
|
||||||
SQLMsg * PopResult(eSQL_SLOT slot );
|
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 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; }
|
DWORD CountReturnResult(int i) { return m_mainSQL[i] ? m_mainSQL[i]->CountResult() : 0; }
|
||||||
|
|
|
@ -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);
|
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);
|
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_from = m_map_kGuild.find(dwGuildFrom);
|
||||||
itertype(m_map_kGuild) it_to = m_map_kGuild.find(dwGuildTo);
|
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("alv", alv);
|
||||||
polyPower.SetVar("mc", mc);
|
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);
|
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("alv", alv);
|
||||||
polyPower.SetVar("mc", mc);
|
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);
|
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);
|
polyHandicap.SetVar("pB", t.lPowerTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
t.lHandicap = (long) polyHandicap.Eval();
|
t.lHandicap = (int) polyHandicap.Eval();
|
||||||
sys_log(0, "GuildWar: handicap %d", t.lHandicap);
|
sys_log(0, "GuildWar: handicap %d", t.lHandicap);
|
||||||
|
|
||||||
// 쿼리
|
// 쿼리
|
||||||
|
@ -1062,7 +1062,7 @@ bool CGuildManager::ReserveWar(TPacketGuildWar * p)
|
||||||
|
|
||||||
snprintf(szQuery, sizeof(szQuery),
|
snprintf(szQuery, sizeof(szQuery),
|
||||||
"INSERT INTO guild_war_reservation (guild1, guild2, time, type, warprice, initscore, power1, power2, handicap) "
|
"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);
|
GID1, GID2, p->bType, p->lWarPrice, p->lInitialScore, t.lPowerFrom, t.lPowerTo, t.lHandicap);
|
||||||
|
|
||||||
std::unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery));
|
std::unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery));
|
||||||
|
|
|
@ -45,15 +45,15 @@ struct TGuildWaitStartInfo
|
||||||
{
|
{
|
||||||
BYTE bType;
|
BYTE bType;
|
||||||
DWORD GID[2];
|
DWORD GID[2];
|
||||||
long lWarPrice;
|
int lWarPrice;
|
||||||
long lInitialScore;
|
int lInitialScore;
|
||||||
CGuildWarReserve * pkReserve;
|
CGuildWarReserve * pkReserve;
|
||||||
|
|
||||||
TGuildWaitStartInfo(BYTE _bType,
|
TGuildWaitStartInfo(BYTE _bType,
|
||||||
DWORD _g1,
|
DWORD _g1,
|
||||||
DWORD _g2,
|
DWORD _g2,
|
||||||
long _lWarPrice,
|
int _lWarPrice,
|
||||||
long _lInitialScore,
|
int _lInitialScore,
|
||||||
CGuildWarReserve * _pkReserve)
|
CGuildWarReserve * _pkReserve)
|
||||||
: bType(_bType), lWarPrice(_lWarPrice), lInitialScore(_lInitialScore), pkReserve(_pkReserve)
|
: bType(_bType), lWarPrice(_lWarPrice), lInitialScore(_lInitialScore), pkReserve(_pkReserve)
|
||||||
{
|
{
|
||||||
|
@ -180,12 +180,12 @@ class CGuildManager : public singleton<CGuildManager>
|
||||||
void AddDeclare(BYTE bType, DWORD guild_from, DWORD guild_to);
|
void AddDeclare(BYTE bType, DWORD guild_from, DWORD guild_to);
|
||||||
void RemoveDeclare(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);
|
bool WaitStart(TPacketGuildWar * p);
|
||||||
|
|
||||||
void RecvWarEnd(DWORD GID1, DWORD GID2);
|
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);
|
void ChangeLadderPoint(DWORD GID, int change);
|
||||||
|
|
||||||
|
|
|
@ -103,12 +103,12 @@ bool CLoginData::IsDeleted()
|
||||||
return m_bDeleted;
|
return m_bDeleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLoginData::SetPremium(int * paiPremiumTimes)
|
void CLoginData::SetPremium(DWORD * paiPremiumTimes)
|
||||||
{
|
{
|
||||||
memcpy(m_aiPremiumTimes, paiPremiumTimes, sizeof(m_aiPremiumTimes));
|
memcpy(m_aiPremiumTimes, paiPremiumTimes, sizeof(m_aiPremiumTimes));
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLoginData::GetPremium(BYTE type)
|
DWORD CLoginData::GetPremium(BYTE type)
|
||||||
{
|
{
|
||||||
if (type >= PREMIUM_MAX_NUM)
|
if (type >= PREMIUM_MAX_NUM)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -116,7 +116,7 @@ int CLoginData::GetPremium(BYTE type)
|
||||||
return m_aiPremiumTimes[type];
|
return m_aiPremiumTimes[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
int * CLoginData::GetPremiumPtr()
|
DWORD * CLoginData::GetPremiumPtr()
|
||||||
{
|
{
|
||||||
return &m_aiPremiumTimes[0];
|
return &m_aiPremiumTimes[0];
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,9 @@ class CLoginData
|
||||||
|
|
||||||
time_t GetLastPlayTime() { return m_lastPlayTime; }
|
time_t GetLastPlayTime() { return m_lastPlayTime; }
|
||||||
|
|
||||||
void SetPremium(int * paiPremiumTimes);
|
void SetPremium(DWORD * paiPremiumTimes);
|
||||||
int GetPremium(BYTE type);
|
DWORD GetPremium(BYTE type);
|
||||||
int * GetPremiumPtr();
|
DWORD * GetPremiumPtr();
|
||||||
|
|
||||||
DWORD GetLastPlayerID() const { return m_dwLastPlayerID; }
|
DWORD GetLastPlayerID() const { return m_dwLastPlayerID; }
|
||||||
void SetLastPlayerID(DWORD id) { m_dwLastPlayerID = id; }
|
void SetLastPlayerID(DWORD id) { m_dwLastPlayerID = id; }
|
||||||
|
@ -56,7 +56,7 @@ class CLoginData
|
||||||
BYTE m_bBillType;
|
BYTE m_bBillType;
|
||||||
DWORD m_dwBillID;
|
DWORD m_dwBillID;
|
||||||
time_t m_lastPlayTime;
|
time_t m_lastPlayTime;
|
||||||
int m_aiPremiumTimes[PREMIUM_MAX_NUM];
|
DWORD m_aiPremiumTimes[PREMIUM_MAX_NUM];
|
||||||
|
|
||||||
DWORD m_dwLastPlayerID;
|
DWORD m_dwLastPlayerID;
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ void CPeer::SetP2PPort(WORD wPort)
|
||||||
m_wP2PPort = wPort;
|
m_wP2PPort = wPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPeer::SetMaps(long * pl)
|
void CPeer::SetMaps(LONG * pl)
|
||||||
{
|
{
|
||||||
memcpy(m_alMaps, pl, sizeof(m_alMaps));
|
memcpy(m_alMaps, pl, sizeof(m_alMaps));
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,8 @@ class CPeer : public CPeerBase
|
||||||
void SetP2PPort(WORD wPort);
|
void SetP2PPort(WORD wPort);
|
||||||
WORD GetP2PPort() { return m_wP2PPort; }
|
WORD GetP2PPort() { return m_wP2PPort; }
|
||||||
|
|
||||||
void SetMaps(long* pl);
|
void SetMaps(LONG* pl);
|
||||||
long * GetMaps() { return &m_alMaps[0]; }
|
LONG * GetMaps() { return &m_alMaps[0]; }
|
||||||
|
|
||||||
bool SetItemIDRange(TItemIDRangeTable itemRange);
|
bool SetItemIDRange(TItemIDRangeTable itemRange);
|
||||||
bool SetSpareItemIDRange(TItemIDRangeTable itemRange);
|
bool SetSpareItemIDRange(TItemIDRangeTable itemRange);
|
||||||
|
@ -66,7 +66,7 @@ class CPeer : public CPeerBase
|
||||||
DWORD m_dwUserCount;
|
DWORD m_dwUserCount;
|
||||||
WORD m_wListenPort; // 게임서버가 클라이언트를 위해 listen 하는 포트
|
WORD m_wListenPort; // 게임서버가 클라이언트를 위해 listen 하는 포트
|
||||||
WORD m_wP2PPort; // 게임서버가 게임서버 P2P 접속을 위해 listen 하는 포트
|
WORD m_wP2PPort; // 게임서버가 게임서버 P2P 접속을 위해 listen 하는 포트
|
||||||
long m_alMaps[32]; // 어떤 맵을 관장하고 있는가?
|
LONG m_alMaps[32]; // 어떤 맵을 관장하고 있는가?
|
||||||
|
|
||||||
TItemIDRangeTable m_itemRange;
|
TItemIDRangeTable m_itemRange;
|
||||||
TItemIDRangeTable m_itemSpareRange;
|
TItemIDRangeTable m_itemSpareRange;
|
||||||
|
|
|
@ -29,6 +29,10 @@ target_link_libraries (${PROJECT_NAME} cryptopp-static)
|
||||||
include_directories(${Boost_INCLUDE_DIR})
|
include_directories(${Boost_INCLUDE_DIR})
|
||||||
target_link_libraries (${PROJECT_NAME} ${Boost_LIBRARIES})
|
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)
|
if (IL_FOUND)
|
||||||
include_directories(${IL_INCLUDE_DIR})
|
include_directories(${IL_INCLUDE_DIR})
|
||||||
target_link_libraries (${PROJECT_NAME} ${IL_LIBRARIES})
|
target_link_libraries (${PROJECT_NAME} ${IL_LIBRARIES})
|
||||||
|
|
|
@ -178,7 +178,7 @@ struct FSkillEarthQuake
|
||||||
EJobs Set1;
|
EJobs Set1;
|
||||||
EJobs Set2;
|
EJobs Set2;
|
||||||
ESex gender;
|
ESex gender;
|
||||||
long MaxDistance;
|
int MaxDistance;
|
||||||
LPCHARACTER pAttacker;
|
LPCHARACTER pAttacker;
|
||||||
LPCHARACTER pFarthestChar;
|
LPCHARACTER pFarthestChar;
|
||||||
|
|
||||||
|
@ -286,8 +286,8 @@ struct FSkillEarthQuake
|
||||||
|
|
||||||
const int nFlyDistance = 1000;
|
const int nFlyDistance = 1000;
|
||||||
|
|
||||||
long tx = ch->GetX() + vec.x * nFlyDistance;
|
int tx = ch->GetX() + vec.x * nFlyDistance;
|
||||||
long ty = ch->GetY() + vec.y * nFlyDistance;
|
int ty = ch->GetY() + vec.y * nFlyDistance;
|
||||||
|
|
||||||
for (int i=0 ; i < 5 ; ++i)
|
for (int i=0 ; i < 5 ; ++i)
|
||||||
{
|
{
|
||||||
|
@ -327,7 +327,7 @@ struct FSkillEarthQuake
|
||||||
|
|
||||||
ch->SyncPacket();
|
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)
|
if (dist > MaxDistance)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,10 +17,10 @@ extern int passes_per_sec;
|
||||||
struct FWarpToDragronLairWithGuildMembers
|
struct FWarpToDragronLairWithGuildMembers
|
||||||
{
|
{
|
||||||
DWORD dwGuildID;
|
DWORD dwGuildID;
|
||||||
long mapIndex;
|
int mapIndex;
|
||||||
long x, y;
|
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)
|
: dwGuildID(guildID), mapIndex(map), x(X), y(Y)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ EVENTINFO(tag_DragonLair_Collapse_EventInfo)
|
||||||
{
|
{
|
||||||
int step;
|
int step;
|
||||||
CDragonLair* pLair;
|
CDragonLair* pLair;
|
||||||
long InstanceMapIndex;
|
int InstanceMapIndex;
|
||||||
|
|
||||||
tag_DragonLair_Collapse_EventInfo()
|
tag_DragonLair_Collapse_EventInfo()
|
||||||
: step( 0 )
|
: 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)
|
: GuildID_(guildID), BaseMapIndex_(BaseMapID), PrivateMapIndex_(PrivateMapID)
|
||||||
{
|
{
|
||||||
StartTime_ = get_global_time();
|
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) {
|
if (instanceMapIndex == 0) {
|
||||||
sys_err("CDragonLairManager::Start() : no private map index available");
|
sys_err("CDragonLairManager::Start() : no private map index available");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
class CDragonLair
|
class CDragonLair
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CDragonLair (DWORD dwGuildID, long BaseMapID, long PrivateMapID);
|
CDragonLair (DWORD dwGuildID, int BaseMapID, int PrivateMapID);
|
||||||
virtual ~CDragonLair ();
|
virtual ~CDragonLair ();
|
||||||
|
|
||||||
DWORD GetEstimatedTime () const;
|
DWORD GetEstimatedTime () const;
|
||||||
|
@ -16,8 +16,8 @@ class CDragonLair
|
||||||
private:
|
private:
|
||||||
DWORD StartTime_;
|
DWORD StartTime_;
|
||||||
DWORD GuildID_;
|
DWORD GuildID_;
|
||||||
long BaseMapIndex_;
|
int BaseMapIndex_;
|
||||||
long PrivateMapIndex_;
|
int PrivateMapIndex_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDragonLairManager : public singleton<CDragonLairManager>
|
class CDragonLairManager : public singleton<CDragonLairManager>
|
||||||
|
@ -26,7 +26,7 @@ class CDragonLairManager : public singleton<CDragonLairManager>
|
||||||
CDragonLairManager ();
|
CDragonLairManager ();
|
||||||
virtual ~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);
|
void OnDragonDead (LPCHARACTER pDragon, DWORD KillerGuildID);
|
||||||
|
|
||||||
size_t GetLairCount () const { return LairMap_.size(); }
|
size_t GetLairCount () const { return LairMap_.size(); }
|
||||||
|
|
|
@ -466,7 +466,7 @@ bool DSManager::PullOut(LPCHARACTER ch, TItemPos DestCell, LPITEM& pItem, LPITEM
|
||||||
}
|
}
|
||||||
else
|
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);
|
LogManager::instance().ItemLog(ch, pItem, "DS_PULL_OUT_SUCCESS", buf);
|
||||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("용혼석 추출에 성공하였습니다."));
|
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("용혼석 추출에 성공하였습니다."));
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <IL/il.h>
|
#include <IL/il.h>
|
||||||
#include <lzo/lzo1x.h>
|
#include <lzo/lzo1x.h>
|
||||||
|
|
||||||
typedef unsigned long Pixel;
|
typedef unsigned int Pixel;
|
||||||
|
|
||||||
struct SGuildMark
|
struct SGuildMark
|
||||||
{
|
{
|
||||||
|
|
|
@ -135,9 +135,9 @@ void CPetActor::Unsummon()
|
||||||
|
|
||||||
DWORD CPetActor::Summon(const char* petName, LPITEM pSummonItem, bool bSpawnFar)
|
DWORD CPetActor::Summon(const char* petName, LPITEM pSummonItem, bool bSpawnFar)
|
||||||
{
|
{
|
||||||
long x = m_pkOwner->GetX();
|
int x = m_pkOwner->GetX();
|
||||||
long y = m_pkOwner->GetY();
|
int y = m_pkOwner->GetY();
|
||||||
long z = m_pkOwner->GetZ();
|
int z = m_pkOwner->GetZ();
|
||||||
|
|
||||||
if (true == bSpawnFar)
|
if (true == bSpawnFar)
|
||||||
{
|
{
|
||||||
|
@ -248,8 +248,8 @@ bool CPetActor::_UpdateFollowAI()
|
||||||
|
|
||||||
DWORD currentTime = get_dword_time();
|
DWORD currentTime = get_dword_time();
|
||||||
|
|
||||||
long ownerX = m_pkOwner->GetX(); long ownerY = m_pkOwner->GetY();
|
int ownerX = m_pkOwner->GetX(); int ownerY = m_pkOwner->GetY();
|
||||||
long charX = m_pkChar->GetX(); long charY = m_pkChar->GetY();
|
int charX = m_pkChar->GetX(); int charY = m_pkChar->GetY();
|
||||||
|
|
||||||
float fDist = DISTANCE_APPROX(charX - ownerX, charY - ownerY);
|
float fDist = DISTANCE_APPROX(charX - ownerX, charY - ownerY);
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@ class CAffect
|
||||||
public:
|
public:
|
||||||
DWORD dwType;
|
DWORD dwType;
|
||||||
BYTE bApplyOn;
|
BYTE bApplyOn;
|
||||||
long lApplyValue;
|
int lApplyValue;
|
||||||
DWORD dwFlag;
|
DWORD dwFlag;
|
||||||
long lDuration;
|
int lDuration;
|
||||||
long lSPCost;
|
int lSPCost;
|
||||||
|
|
||||||
static CAffect* Acquire();
|
static CAffect* Acquire();
|
||||||
static void Release(CAffect* p);
|
static void Release(CAffect* p);
|
||||||
|
|
|
@ -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)
|
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 (auto iter: m_listArena)
|
||||||
|
|
||||||
for (; iter != m_listArena.end(); iter++)
|
|
||||||
{
|
{
|
||||||
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);
|
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;
|
return false;
|
||||||
|
@ -89,7 +87,7 @@ bool CArenaMap::AddArena(DWORD mapIdx, WORD startA_X, WORD startA_Y, WORD startB
|
||||||
|
|
||||||
m_dwMapIndex = mapIdx;
|
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);
|
m_listArena.push_back(pArena);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -146,15 +144,13 @@ void CArenaManager::SendArenaMapListTo(LPCHARACTER pChar)
|
||||||
|
|
||||||
void CArenaMap::SendArenaMapListTo(LPCHARACTER pChar, DWORD mapIdx)
|
void CArenaMap::SendArenaMapListTo(LPCHARACTER pChar, DWORD mapIdx)
|
||||||
{
|
{
|
||||||
if (pChar == NULL) return;
|
if (pChar == nullptr) return;
|
||||||
|
|
||||||
itertype(m_listArena) iter = m_listArena.begin();
|
for (auto& arena: m_listArena) {
|
||||||
|
|
||||||
for (; iter != m_listArena.end(); iter++)
|
|
||||||
{
|
|
||||||
pChar->ChatPacket(CHAT_TYPE_INFO, "ArenaMapInfo Map: %d stA(%d, %d) stB(%d, %d)", mapIdx,
|
pChar->ChatPacket(CHAT_TYPE_INFO, "ArenaMapInfo Map: %d stA(%d, %d) stB(%d, %d)", mapIdx,
|
||||||
(CArena*)(*iter)->GetStartPointA().x, (CArena*)(*iter)->GetStartPointA().y,
|
arena->GetStartPointA().x, arena->GetStartPointA().y,
|
||||||
(CArena*)(*iter)->GetStartPointB().x, (CArena*)(*iter)->GetStartPointB().y);
|
arena->GetStartPointB().x, arena->GetStartPointB().y
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,7 +645,7 @@ bool CArenaManager::CanAttack(LPCHARACTER pCharAttacker, LPCHARACTER pCharVictim
|
||||||
|
|
||||||
if (pCharAttacker == pCharVictim) return false;
|
if (pCharAttacker == pCharVictim) return false;
|
||||||
|
|
||||||
long mapIndex = pCharAttacker->GetMapIndex();
|
int mapIndex = pCharAttacker->GetMapIndex();
|
||||||
if (mapIndex != pCharVictim->GetMapIndex()) return false;
|
if (mapIndex != pCharVictim->GetMapIndex()) return false;
|
||||||
|
|
||||||
itertype(m_mapArenaMap) iter = m_mapArenaMap.find(mapIndex);
|
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;
|
if (pCharKiller == NULL || pCharVictim == NULL) return false;
|
||||||
|
|
||||||
long mapIndex = pCharKiller->GetMapIndex();
|
int mapIndex = pCharKiller->GetMapIndex();
|
||||||
if (mapIndex != pCharVictim->GetMapIndex()) return false;
|
if (mapIndex != pCharVictim->GetMapIndex()) return false;
|
||||||
|
|
||||||
itertype(m_mapArenaMap) iter = m_mapArenaMap.find(mapIndex);
|
itertype(m_mapArenaMap) iter = m_mapArenaMap.find(mapIndex);
|
||||||
|
@ -1101,7 +1097,7 @@ bool CArena::RegisterObserverPtr(LPCHARACTER pChar)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CArenaManager::IsLimitedItem( long lMapIndex, DWORD dwVnum )
|
bool CArenaManager::IsLimitedItem( int lMapIndex, DWORD dwVnum )
|
||||||
{
|
{
|
||||||
if ( IsArenaMap( lMapIndex ) == true )
|
if ( IsArenaMap( lMapIndex ) == true )
|
||||||
{
|
{
|
||||||
|
|
|
@ -132,7 +132,7 @@ class CArenaManager : public singleton<CArenaManager>
|
||||||
bool IsArenaMap(DWORD dwMapIndex);
|
bool IsArenaMap(DWORD dwMapIndex);
|
||||||
MEMBER_IDENTITY IsMember(DWORD dwMapIndex, DWORD PID);
|
MEMBER_IDENTITY IsMember(DWORD dwMapIndex, DWORD PID);
|
||||||
|
|
||||||
bool IsLimitedItem( long lMapIndex, DWORD dwVnum );
|
bool IsLimitedItem( int lMapIndex, DWORD dwVnum );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*__CLASS_ARENA_MANAGER__*/
|
#endif /*__CLASS_ARENA_MANAGER__*/
|
||||||
|
|
|
@ -24,9 +24,9 @@
|
||||||
|
|
||||||
int battle_hit(LPCHARACTER ch, LPCHARACTER victim, int & iRetDam);
|
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)
|
if (distance > 170)
|
||||||
return false;
|
return false;
|
||||||
|
@ -524,7 +524,7 @@ int CalcMeleeDamage(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, bool bIgnoreDe
|
||||||
if (iDam != DEBUG_iPureDam)
|
if (iDam != DEBUG_iPureDam)
|
||||||
snprintf(szUnknownDam, sizeof(szUnknownDam), "+?(%d)", iDam-DEBUG_iPureDam);
|
snprintf(szUnknownDam, sizeof(szUnknownDam), "+?(%d)", iDam-DEBUG_iPureDam);
|
||||||
|
|
||||||
char szMeleeAttack[128];
|
char szMeleeAttack[256];
|
||||||
|
|
||||||
snprintf(szMeleeAttack, sizeof(szMeleeAttack),
|
snprintf(szMeleeAttack, sizeof(szMeleeAttack),
|
||||||
"%s(%d)-%s(%d)=%d%s, ATK=LV(%d)+ST(%d)+WP(%d)%s%s%s, AR=%.3g%s",
|
"%s(%d)-%s(%d)=%d%s, ATK=LV(%d)+ST(%d)+WP(%d)%s%s%s, AR=%.3g%s",
|
||||||
|
|
|
@ -22,7 +22,7 @@ extern bool battle_is_attackable(LPCHARACTER ch, LPCHARACTER victim);
|
||||||
extern int battle_melee_attack(LPCHARACTER ch, LPCHARACTER victim);
|
extern int battle_melee_attack(LPCHARACTER ch, LPCHARACTER victim);
|
||||||
extern void battle_end(LPCHARACTER ch);
|
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 bool battle_distance_valid(LPCHARACTER ch, LPCHARACTER victim);
|
||||||
extern int battle_count_attackers(LPCHARACTER ch);
|
extern int battle_count_attackers(LPCHARACTER ch);
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ inline void AttackAffect(LPCHARACTER pkAttacker,
|
||||||
DWORD immune_flag,
|
DWORD immune_flag,
|
||||||
DWORD affect_idx,
|
DWORD affect_idx,
|
||||||
BYTE affect_point,
|
BYTE affect_point,
|
||||||
long affect_amount,
|
int affect_amount,
|
||||||
DWORD affect_flag,
|
DWORD affect_flag,
|
||||||
int time,
|
int time,
|
||||||
const char* name)
|
const char* name)
|
||||||
|
@ -63,7 +63,7 @@ inline void SkillAttackAffect(LPCHARACTER pkVictim,
|
||||||
DWORD immune_flag,
|
DWORD immune_flag,
|
||||||
DWORD affect_idx,
|
DWORD affect_idx,
|
||||||
BYTE affect_point,
|
BYTE affect_point,
|
||||||
long affect_amount,
|
int affect_amount,
|
||||||
DWORD affect_flag,
|
DWORD affect_flag,
|
||||||
int time,
|
int time,
|
||||||
const char* name)
|
const char* name)
|
||||||
|
|
|
@ -113,7 +113,7 @@ bool is_blocked_country_ip(const char *user_ip)
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
if (0 == inet_aton(user_ip, &st_addr))
|
if (0 == inet_aton(user_ip, &st_addr))
|
||||||
#else
|
#else
|
||||||
unsigned long in_address;
|
unsigned int in_address;
|
||||||
in_address = inet_addr(user_ip);
|
in_address = inet_addr(user_ip);
|
||||||
st_addr.s_addr = in_address;
|
st_addr.s_addr = in_address;
|
||||||
if (INADDR_NONE == in_address)
|
if (INADDR_NONE == in_address)
|
||||||
|
|
|
@ -54,7 +54,7 @@ void CObject::Destroy()
|
||||||
GetY() + m_pProto->lRegion[1],
|
GetY() + m_pProto->lRegion[1],
|
||||||
GetX() + m_pProto->lRegion[2],
|
GetX() + m_pProto->lRegion[2],
|
||||||
GetY() + m_pProto->lRegion[3],
|
GetY() + m_pProto->lRegion[3],
|
||||||
(long)m_data.zRot, // ADD_BUILDING_ROTATION
|
(int)m_data.zRot, // ADD_BUILDING_ROTATION
|
||||||
ATTR_OBJECT,
|
ATTR_OBJECT,
|
||||||
ATTR_REGION_MODE_REMOVE);
|
ATTR_REGION_MODE_REMOVE);
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ void CObject::SetVID(DWORD dwVID)
|
||||||
m_dwVID = 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);
|
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],
|
y + m_pProto->lRegion[1],
|
||||||
x + m_pProto->lRegion[2],
|
x + m_pProto->lRegion[2],
|
||||||
y + m_pProto->lRegion[3],
|
y + m_pProto->lRegion[3],
|
||||||
(long)m_data.zRot,
|
(int)m_data.zRot,
|
||||||
ATTR_OBJECT,
|
ATTR_OBJECT,
|
||||||
ATTR_REGION_MODE_SET);
|
ATTR_REGION_MODE_SET);
|
||||||
|
|
||||||
|
@ -473,11 +473,11 @@ void CLand::DeleteObject(DWORD dwID)
|
||||||
|
|
||||||
struct FIsIn
|
struct FIsIn
|
||||||
{
|
{
|
||||||
long sx, sy;
|
int sx, sy;
|
||||||
long ex, ey;
|
int ex, ey;
|
||||||
|
|
||||||
bool bIn;
|
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)
|
: 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();
|
SECTREE_MANAGER& rkSecTreeMgr = SECTREE_MANAGER::instance();
|
||||||
TObjectProto * pkProto = CManager::instance().GetObjectProto(dwVnum);
|
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
|
// ADD_BUILDING_ROTATION
|
||||||
if ( checkAnother )
|
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");
|
sys_err("another object already exist");
|
||||||
return false;
|
return false;
|
||||||
|
@ -748,7 +748,7 @@ void CManager::UpdateLand(TLand * pTable)
|
||||||
// we must send the guild name first
|
// we must send the guild name first
|
||||||
d->GetCharacter()->SendGuildName(guild);
|
d->GetCharacter()->SendGuildName(guild);
|
||||||
|
|
||||||
d->BufferedPacket(&p, sizeof(TPacketGCLandList));
|
d->RawPacket(&p, sizeof(TPacketGCLandList));
|
||||||
d->Packet(&e, sizeof(TLandPacketElement));
|
d->Packet(&e, sizeof(TLandPacketElement));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -764,7 +764,7 @@ CLand * CManager::FindLand(DWORD dwID)
|
||||||
return it->second;
|
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);
|
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());
|
m_map_pkObjByVID.erase(pkObj->GetVID());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CManager::SendLandList(LPDESC d, long lMapIndex)
|
void CManager::SendLandList(LPDESC d, int lMapIndex)
|
||||||
{
|
{
|
||||||
TLandPacketElement e;
|
TLandPacketElement e;
|
||||||
|
|
||||||
|
@ -984,7 +984,7 @@ void CManager::SendLandList(LPDESC d, long lMapIndex)
|
||||||
p.header = HEADER_GC_LAND_LIST;
|
p.header = HEADER_GC_LAND_LIST;
|
||||||
p.size = sizeof(TPacketGCLandList) + buf.size();
|
p.size = sizeof(TPacketGCLandList) + buf.size();
|
||||||
|
|
||||||
d->BufferedPacket(&p, sizeof(TPacketGCLandList));
|
d->RawPacket(&p, sizeof(TPacketGCLandList));
|
||||||
d->Packet(buf.read_peek(), buf.size());
|
d->Packet(buf.read_peek(), buf.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1040,7 +1040,7 @@ void CLand::ClearLand()
|
||||||
// END_LAND_CLEAR
|
// END_LAND_CLEAR
|
||||||
|
|
||||||
// BUILD_WALL
|
// 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;
|
int rot = (int)zRot;
|
||||||
rot = ((rot%360) / 90) * 90;
|
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;
|
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();
|
const TLand & r = GetData();
|
||||||
|
|
||||||
long startX = r.x + (r.width / 2) - (1300 + wallSize*500);
|
int startX = r.x + (r.width / 2) - (1300 + wallSize*500);
|
||||||
long startY = r.y + (r.height / 2) + (1300 + wallSize*500);
|
int startY = r.y + (r.height / 2) + (1300 + wallSize*500);
|
||||||
|
|
||||||
DWORD corner = dwVnum - 4;
|
DWORD corner = dwVnum - 4;
|
||||||
DWORD wall = dwVnum - 3;
|
DWORD wall = dwVnum - 3;
|
||||||
DWORD door = dwVnum - 1;
|
DWORD door = dwVnum - 1;
|
||||||
|
|
||||||
bool checkAnother = false;
|
bool checkAnother = false;
|
||||||
long* ptr = NULL;
|
int* ptr = NULL;
|
||||||
int delta = 1;
|
int delta = 1;
|
||||||
int rot = 270;
|
int rot = 270;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace building
|
||||||
void SetVID(DWORD dwVID);
|
void SetVID(DWORD dwVID);
|
||||||
DWORD GetVID() { return m_dwVID; }
|
DWORD GetVID() { return m_dwVID; }
|
||||||
|
|
||||||
bool Show(long lMapIndex, long x, long y);
|
bool Show(int lMapIndex, int x, int y);
|
||||||
|
|
||||||
void Save();
|
void Save();
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ namespace building
|
||||||
LPOBJECT FindObjectByNPC(LPCHARACTER npc);
|
LPOBJECT FindObjectByNPC(LPCHARACTER npc);
|
||||||
void DeleteObject(DWORD dwID);
|
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 RequestDeleteObject(DWORD dwID);
|
||||||
void RequestDeleteObjectByVID(DWORD dwVID);
|
void RequestDeleteObjectByVID(DWORD dwVID);
|
||||||
|
|
||||||
|
@ -87,10 +87,10 @@ namespace building
|
||||||
// END_LAND_CLEAR
|
// END_LAND_CLEAR
|
||||||
|
|
||||||
// BUILD_WALL
|
// BUILD_WALL
|
||||||
bool RequestCreateWall(long nMapIndex, float rot);
|
bool RequestCreateWall(int nMapIndex, float rot);
|
||||||
void RequestDeleteWall();
|
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);
|
void RequestDeleteWallBlocks(DWORD dwVnum);
|
||||||
// END_BUILD_WALL
|
// END_BUILD_WALL
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ namespace building
|
||||||
|
|
||||||
// BUILD_WALL
|
// BUILD_WALL
|
||||||
private :
|
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
|
// END_BUILD_WALL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ namespace building
|
||||||
|
|
||||||
bool LoadLand(TLand * pTable);
|
bool LoadLand(TLand * pTable);
|
||||||
CLand * FindLand(DWORD dwID);
|
CLand * FindLand(DWORD dwID);
|
||||||
CLand * FindLand(long lMapIndex, long x, long y);
|
CLand * FindLand(int lMapIndex, int x, int y);
|
||||||
CLand * FindLandByGuild(DWORD GID);
|
CLand * FindLandByGuild(DWORD GID);
|
||||||
void UpdateLand(TLand * pTable);
|
void UpdateLand(TLand * pTable);
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ namespace building
|
||||||
|
|
||||||
LPOBJECT FindObjectByVID(DWORD dwVID);
|
LPOBJECT FindObjectByVID(DWORD dwVID);
|
||||||
|
|
||||||
void SendLandList(LPDESC d, long lMapIndex);
|
void SendLandList(LPDESC d, int lMapIndex);
|
||||||
|
|
||||||
// LAND_CLEAR
|
// LAND_CLEAR
|
||||||
void ClearLand(DWORD dwLandID);
|
void ClearLand(DWORD dwLandID);
|
||||||
|
|
|
@ -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)
|
EVENTINFO(castle_event_info)
|
||||||
{
|
{
|
||||||
|
@ -324,7 +324,7 @@ EVENTFUNC(castle_stone_event)
|
||||||
return 0;
|
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);
|
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);
|
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)
|
switch (empire)
|
||||||
{
|
{
|
||||||
|
@ -647,7 +647,7 @@ void castle_end_siege()
|
||||||
LPCHARACTER castle_spawn_frog(int empire)
|
LPCHARACTER castle_spawn_frog(int empire)
|
||||||
{
|
{
|
||||||
int dir = 1;
|
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);
|
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)
|
LPCHARACTER castle_spawn_frog_force(int empire, int empty_index)
|
||||||
{
|
{
|
||||||
int dir = 1;
|
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);
|
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;
|
LPCHARACTER mob;
|
||||||
int sx, sy, ex, ey;
|
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);
|
SECTREE_MAP *sectree_map = SECTREE_MANAGER::instance().GetMap(map_index);
|
||||||
if (NULL == sectree_map)
|
if (NULL == sectree_map)
|
||||||
|
|
|
@ -1306,14 +1306,14 @@ void CHARACTER::Disconnect(const char * c_pszReason)
|
||||||
strncpy(p.szName, GetName(), sizeof(p.szName));
|
strncpy(p.szName, GetName(), sizeof(p.szName));
|
||||||
P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGLogout));
|
P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGLogout));
|
||||||
char buf[51];
|
char buf[51];
|
||||||
snprintf(buf, sizeof(buf), "%s %d %d %ld %d",
|
snprintf(buf, sizeof(buf), "%s %d %d %d %d",
|
||||||
inet_ntoa(GetDesc()->GetAddr().sin_addr), GetGold(), g_bChannel, GetMapIndex(), GetAlignment());
|
GetDesc()->GetHostName(), GetGold(), g_bChannel, GetMapIndex(), GetAlignment());
|
||||||
|
|
||||||
LogManager::instance().CharLog(this, 0, "LOGOUT", buf);
|
LogManager::instance().CharLog(this, 0, "LOGOUT", buf);
|
||||||
|
|
||||||
if (LC_IsYMIR() || LC_IsKorea() || LC_IsBrazil())
|
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);
|
LogManager::instance().LoginLog(false, GetDesc()->GetAccountTable().id, GetPlayerID(), GetLevel(), GetJob(), playTime);
|
||||||
|
|
||||||
if (LC_IsBrazil() != true)
|
if (LC_IsBrazil() != true)
|
||||||
|
@ -1395,7 +1395,7 @@ void CHARACTER::Disconnect(const char * c_pszReason)
|
||||||
M2_DESTROY_CHARACTER(this);
|
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);
|
LPSECTREE sectree = SECTREE_MANAGER::instance().Get(lMapIndex, x, y);
|
||||||
|
|
||||||
|
@ -2195,22 +2195,22 @@ void CHARACTER::ComputeBattlePoints()
|
||||||
|
|
||||||
void CHARACTER::ComputePoints()
|
void CHARACTER::ComputePoints()
|
||||||
{
|
{
|
||||||
long lStat = GetPoint(POINT_STAT);
|
int lStat = GetPoint(POINT_STAT);
|
||||||
long lStatResetCount = GetPoint(POINT_STAT_RESET_COUNT);
|
int lStatResetCount = GetPoint(POINT_STAT_RESET_COUNT);
|
||||||
long lSkillActive = GetPoint(POINT_SKILL);
|
int lSkillActive = GetPoint(POINT_SKILL);
|
||||||
long lSkillSub = GetPoint(POINT_SUB_SKILL);
|
int lSkillSub = GetPoint(POINT_SUB_SKILL);
|
||||||
long lSkillHorse = GetPoint(POINT_HORSE_SKILL);
|
int lSkillHorse = GetPoint(POINT_HORSE_SKILL);
|
||||||
long lLevelStep = GetPoint(POINT_LEVEL_STEP);
|
int lLevelStep = GetPoint(POINT_LEVEL_STEP);
|
||||||
|
|
||||||
long lAttackerBonus = GetPoint(POINT_PARTY_ATTACKER_BONUS);
|
int lAttackerBonus = GetPoint(POINT_PARTY_ATTACKER_BONUS);
|
||||||
long lTankerBonus = GetPoint(POINT_PARTY_TANKER_BONUS);
|
int lTankerBonus = GetPoint(POINT_PARTY_TANKER_BONUS);
|
||||||
long lBufferBonus = GetPoint(POINT_PARTY_BUFFER_BONUS);
|
int lBufferBonus = GetPoint(POINT_PARTY_BUFFER_BONUS);
|
||||||
long lSkillMasterBonus = GetPoint(POINT_PARTY_SKILL_MASTER_BONUS);
|
int lSkillMasterBonus = GetPoint(POINT_PARTY_SKILL_MASTER_BONUS);
|
||||||
long lHasteBonus = GetPoint(POINT_PARTY_HASTE_BONUS);
|
int lHasteBonus = GetPoint(POINT_PARTY_HASTE_BONUS);
|
||||||
long lDefenderBonus = GetPoint(POINT_PARTY_DEFENDER_BONUS);
|
int lDefenderBonus = GetPoint(POINT_PARTY_DEFENDER_BONUS);
|
||||||
|
|
||||||
long lHPRecovery = GetPoint(POINT_HP_RECOVERY);
|
int lHPRecovery = GetPoint(POINT_HP_RECOVERY);
|
||||||
long lSPRecovery = GetPoint(POINT_SP_RECOVERY);
|
int lSPRecovery = GetPoint(POINT_SP_RECOVERY);
|
||||||
|
|
||||||
memset(m_pointsInstant.points, 0, sizeof(m_pointsInstant.points));
|
memset(m_pointsInstant.points, 0, sizeof(m_pointsInstant.points));
|
||||||
BuffOnAttr_ClearAll();
|
BuffOnAttr_ClearAll();
|
||||||
|
@ -2564,7 +2564,7 @@ void CHARACTER::SetRotation(float fRot)
|
||||||
}
|
}
|
||||||
|
|
||||||
// x, y 방향으로 보고 선다.
|
// x, y 방향으로 보고 선다.
|
||||||
void CHARACTER::SetRotationToXY(long x, long y)
|
void CHARACTER::SetRotationToXY(int x, int y)
|
||||||
{
|
{
|
||||||
SetRotation(GetDegreeFromPositionXY(GetX(), GetY(), x, y));
|
SetRotation(GetDegreeFromPositionXY(GetX(), GetY(), x, y));
|
||||||
}
|
}
|
||||||
|
@ -2591,7 +2591,7 @@ bool CHARACTER::CanMove() const
|
||||||
}
|
}
|
||||||
|
|
||||||
// 무조건 x, y 위치로 이동 시킨다.
|
// 무조건 x, y 위치로 이동 시킨다.
|
||||||
bool CHARACTER::Sync(long x, long y)
|
bool CHARACTER::Sync(int x, int y)
|
||||||
{
|
{
|
||||||
if (!GetSectree())
|
if (!GetSectree())
|
||||||
return false;
|
return false;
|
||||||
|
@ -2670,7 +2670,7 @@ void CHARACTER::Stop()
|
||||||
m_posDest.y = m_posStart.y = GetY();
|
m_posDest.y = m_posStart.y = GetY();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CHARACTER::Goto(long x, long y)
|
bool CHARACTER::Goto(int x, int y)
|
||||||
{
|
{
|
||||||
// TODO 거리체크 필요
|
// TODO 거리체크 필요
|
||||||
// 같은 위치면 이동할 필요 없음 (자동 성공)
|
// 같은 위치면 이동할 필요 없음 (자동 성공)
|
||||||
|
@ -2808,7 +2808,7 @@ void CHARACTER::CalculateMoveDuration()
|
||||||
// 클라에서는 이전 위치에서 바꾼 x, y까지 interpolation한다.
|
// 클라에서는 이전 위치에서 바꾼 x, y까지 interpolation한다.
|
||||||
// 걷거나 뛰는 것은 char의 m_bNowWalking에 달려있다.
|
// 걷거나 뛰는 것은 char의 m_bNowWalking에 달려있다.
|
||||||
// Warp를 의도한 것이라면 Show를 사용할 것.
|
// Warp를 의도한 것이라면 Show를 사용할 것.
|
||||||
bool CHARACTER::Move(long x, long y)
|
bool CHARACTER::Move(int x, int y)
|
||||||
{
|
{
|
||||||
// 같은 위치면 이동할 필요 없음 (자동 성공)
|
// 같은 위치면 이동할 필요 없음 (자동 성공)
|
||||||
if (GetX() == x && GetY() == y)
|
if (GetX() == x && GetY() == y)
|
||||||
|
@ -5165,7 +5165,7 @@ void CHARACTER::CheckTarget()
|
||||||
SetTarget(NULL);
|
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.x = x * 100;
|
||||||
m_posWarp.y = y * 100;
|
m_posWarp.y = y * 100;
|
||||||
|
@ -5191,13 +5191,13 @@ void CHARACTER::ExitToSavedLocation()
|
||||||
// 지금까진 privateMapIndex 가 현재 맵 인덱스와 같은지 체크 하는 것을 외부에서 하고,
|
// 지금까진 privateMapIndex 가 현재 맵 인덱스와 같은지 체크 하는 것을 외부에서 하고,
|
||||||
// 다르면 warpset을 불렀는데
|
// 다르면 warpset을 불렀는데
|
||||||
// 이를 warpset 안으로 넣자.
|
// 이를 warpset 안으로 넣자.
|
||||||
bool CHARACTER::WarpSet(long x, long y, long lPrivateMapIndex)
|
bool CHARACTER::WarpSet(int x, int y, int lPrivateMapIndex)
|
||||||
{
|
{
|
||||||
if (!IsPC())
|
if (!IsPC())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
long lAddr;
|
LONG lAddr;
|
||||||
long lMapIndex;
|
int lMapIndex;
|
||||||
WORD wPort;
|
WORD wPort;
|
||||||
|
|
||||||
if (!CMapLocation::instance().Get(x, y, lMapIndex, lAddr, 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
|
//Send Supplementary Data Block if new map requires security packages in loading this map
|
||||||
{
|
{
|
||||||
long lCurAddr;
|
LONG lCurAddr;
|
||||||
long lCurMapIndex = 0;
|
int lCurMapIndex = 0;
|
||||||
WORD wCurPort;
|
WORD wCurPort;
|
||||||
|
|
||||||
CMapLocation::instance().Get(GetX(), GetY(), lCurMapIndex, lCurAddr, 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())
|
//if (!LC_IsNewCIBN())
|
||||||
{
|
{
|
||||||
char buf[256];
|
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);
|
LogManager::instance().CharLog(this, 0, "WARP", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5379,8 +5379,8 @@ bool CHARACTER::Follow(LPCHARACTER pkChr, float fMinDistance)
|
||||||
}
|
}
|
||||||
// END_OF_TRENT_MONSTER
|
// END_OF_TRENT_MONSTER
|
||||||
|
|
||||||
long x = pkChr->GetX();
|
int x = pkChr->GetX();
|
||||||
long y = pkChr->GetY();
|
int y = pkChr->GetY();
|
||||||
|
|
||||||
if (pkChr->IsPC()) // 쫓아가는 상대가 PC일 때
|
if (pkChr->IsPC()) // 쫓아가는 상대가 PC일 때
|
||||||
{
|
{
|
||||||
|
@ -5430,14 +5430,14 @@ bool CHARACTER::Follow(LPCHARACTER pkChr, float fMinDistance)
|
||||||
{
|
{
|
||||||
GetDeltaByDegree(pkChr->GetRotation(), fMeetTime * yourSpeed, &fYourMoveEstimateX, &fYourMoveEstimateY);
|
GetDeltaByDegree(pkChr->GetRotation(), fMeetTime * yourSpeed, &fYourMoveEstimateX, &fYourMoveEstimateY);
|
||||||
|
|
||||||
x += (long) fYourMoveEstimateX;
|
x += (int) fYourMoveEstimateX;
|
||||||
y += (long) fYourMoveEstimateY;
|
y += (int) fYourMoveEstimateY;
|
||||||
|
|
||||||
float fDistNew = sqrt(((double)x - GetX())*(x-GetX())+((double)y - GetY())*(y-GetY()));
|
float fDistNew = sqrt(((double)x - GetX())*(x-GetX())+((double)y - GetY())*(y-GetY()));
|
||||||
if (fDist < fDistNew)
|
if (fDist < fDistNew)
|
||||||
{
|
{
|
||||||
x = (long)(GetX() + (x - GetX()) * fDist / fDistNew);
|
x = (int)(GetX() + (x - GetX()) * fDist / fDistNew);
|
||||||
y = (long)(GetY() + (y - GetY()) * fDist / fDistNew);
|
y = (int)(GetY() + (y - GetY()) * fDist / fDistNew);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6325,7 +6325,7 @@ namespace {
|
||||||
|
|
||||||
char szTmp[64];
|
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)
|
if (number(1, 100) < 5)
|
||||||
sys_err("Warp NPC name wrong : vnum(%d) name(%s)", pkWarp->GetRaceNum(), pkWarp->GetName());
|
sys_err("Warp NPC name wrong : vnum(%d) name(%s)", pkWarp->GetRaceNum(), pkWarp->GetName());
|
||||||
|
@ -6393,10 +6393,10 @@ namespace {
|
||||||
bool m_bInvalid;
|
bool m_bInvalid;
|
||||||
bool m_bUseWarp;
|
bool m_bUseWarp;
|
||||||
|
|
||||||
long m_lX;
|
int m_lX;
|
||||||
long m_lY;
|
int m_lY;
|
||||||
long m_lTargetX;
|
int m_lTargetX;
|
||||||
long m_lTargetY;
|
int m_lTargetY;
|
||||||
|
|
||||||
BYTE m_bEmpire;
|
BYTE m_bEmpire;
|
||||||
};
|
};
|
||||||
|
|
|
@ -355,14 +355,14 @@ struct DynamicCharacterPtr {
|
||||||
/* 저장하는 데이터 */
|
/* 저장하는 데이터 */
|
||||||
typedef struct character_point
|
typedef struct character_point
|
||||||
{
|
{
|
||||||
long points[POINT_MAX_NUM];
|
int points[POINT_MAX_NUM];
|
||||||
|
|
||||||
BYTE job;
|
BYTE job;
|
||||||
BYTE voice;
|
BYTE voice;
|
||||||
|
|
||||||
BYTE level;
|
BYTE level;
|
||||||
DWORD exp;
|
DWORD exp;
|
||||||
long gold;
|
int gold;
|
||||||
|
|
||||||
int hp;
|
int hp;
|
||||||
int sp;
|
int sp;
|
||||||
|
@ -378,16 +378,16 @@ typedef struct character_point
|
||||||
/* 저장되지 않는 캐릭터 데이터 */
|
/* 저장되지 않는 캐릭터 데이터 */
|
||||||
typedef struct character_point_instant
|
typedef struct character_point_instant
|
||||||
{
|
{
|
||||||
long points[POINT_MAX_NUM];
|
int points[POINT_MAX_NUM];
|
||||||
|
|
||||||
float fRot;
|
float fRot;
|
||||||
|
|
||||||
int iMaxHP;
|
int iMaxHP;
|
||||||
int iMaxSP;
|
int iMaxSP;
|
||||||
|
|
||||||
long position;
|
int position;
|
||||||
|
|
||||||
long instant_flag;
|
int instant_flag;
|
||||||
DWORD dwAIFlag;
|
DWORD dwAIFlag;
|
||||||
DWORD dwImmuneFlag;
|
DWORD dwImmuneFlag;
|
||||||
DWORD dwLastShoutPulse;
|
DWORD dwLastShoutPulse;
|
||||||
|
@ -425,7 +425,7 @@ typedef struct trigger
|
||||||
{
|
{
|
||||||
BYTE type;
|
BYTE type;
|
||||||
int (*func) (TRIGGERPARAM);
|
int (*func) (TRIGGERPARAM);
|
||||||
long value;
|
int value;
|
||||||
} TRIGGER;
|
} TRIGGER;
|
||||||
|
|
||||||
class CTrigger
|
class CTrigger
|
||||||
|
@ -726,13 +726,13 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||||
void ApplyPoint(BYTE bApplyType, int iVal);
|
void ApplyPoint(BYTE bApplyType, int iVal);
|
||||||
void CheckMaximumPoints(); // HP, SP 등의 현재 값이 최대값 보다 높은지 검사하고 높다면 낮춘다.
|
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 Sitdown(int is_ground);
|
||||||
void Standup();
|
void Standup();
|
||||||
|
|
||||||
void SetRotation(float fRot);
|
void SetRotation(float fRot);
|
||||||
void SetRotationToXY(long x, long y);
|
void SetRotationToXY(int x, int y);
|
||||||
float GetRotation() const { return m_pointsInstant.fRot; }
|
float GetRotation() const { return m_pointsInstant.fRot; }
|
||||||
|
|
||||||
void MotionPacketEncode(BYTE motion, LPCHARACTER victim, struct packet_motion * packet);
|
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 SetNowWalking(bool bWalkFlag);
|
||||||
void ResetWalking() { SetNowWalking(m_bWalking); }
|
void ResetWalking() { SetNowWalking(m_bWalking); }
|
||||||
|
|
||||||
bool Goto(long x, long y); // 바로 이동 시키지 않고 목표 위치로 BLENDING 시킨다.
|
bool Goto(int x, int y); // 바로 이동 시키지 않고 목표 위치로 BLENDING 시킨다.
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
bool CanMove() const; // 이동할 수 있는가?
|
bool CanMove() const; // 이동할 수 있는가?
|
||||||
|
|
||||||
void SyncPacket();
|
void SyncPacket();
|
||||||
bool Sync(long x, long y); // 실제 이 메소드로 이동 한다 (각 종 조건에 의한 이동 불가가 없음)
|
bool Sync(int x, int y); // 실제 이 메소드로 이동 한다 (각 종 조건에 의한 이동 불가가 없음)
|
||||||
bool Move(long x, long y); // 조건을 검사하고 Sync 메소드를 통해 이동 한다.
|
bool Move(int x, int y); // 조건을 검사하고 Sync 메소드를 통해 이동 한다.
|
||||||
void OnMove(bool bIsAttack = false); // 움직일때 불린다. Move() 메소드 이외에서도 불릴 수 있다.
|
void OnMove(bool bIsAttack = false); // 움직일때 불린다. Move() 메소드 이외에서도 불릴 수 있다.
|
||||||
DWORD GetMotionMode() const;
|
DWORD GetMotionMode() const;
|
||||||
float GetMoveMotionSpeed() const;
|
float GetMoveMotionSpeed() const;
|
||||||
|
@ -830,8 +830,8 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||||
bool SetSyncOwner(LPCHARACTER ch, bool bRemoveFromList = true);
|
bool SetSyncOwner(LPCHARACTER ch, bool bRemoveFromList = true);
|
||||||
bool IsSyncOwner(LPCHARACTER ch) const;
|
bool IsSyncOwner(LPCHARACTER ch) const;
|
||||||
|
|
||||||
bool WarpSet(long x, long y, long lRealMapIndex = 0);
|
bool WarpSet(int x, int y, int lRealMapIndex = 0);
|
||||||
void SetWarpLocation(long lMapIndex, long x, long y);
|
void SetWarpLocation(int lMapIndex, int x, int y);
|
||||||
void WarpEnd();
|
void WarpEnd();
|
||||||
const PIXEL_POSITION & GetWarpPosition() const { return m_posWarp; }
|
const PIXEL_POSITION & GetWarpPosition() const { return m_posWarp; }
|
||||||
bool WarpToPID(DWORD dwPID);
|
bool WarpToPID(DWORD dwPID);
|
||||||
|
@ -857,10 +857,10 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||||
PIXEL_POSITION m_posDest;
|
PIXEL_POSITION m_posDest;
|
||||||
PIXEL_POSITION m_posStart;
|
PIXEL_POSITION m_posStart;
|
||||||
PIXEL_POSITION m_posWarp;
|
PIXEL_POSITION m_posWarp;
|
||||||
long m_lWarpMapIndex;
|
int m_lWarpMapIndex;
|
||||||
|
|
||||||
PIXEL_POSITION m_posExit;
|
PIXEL_POSITION m_posExit;
|
||||||
long m_lExitMapIndex;
|
int m_lExitMapIndex;
|
||||||
|
|
||||||
DWORD m_dwMoveStartTime;
|
DWORD m_dwMoveStartTime;
|
||||||
DWORD m_dwMoveDuration;
|
DWORD m_dwMoveDuration;
|
||||||
|
@ -893,7 +893,7 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||||
void StartAffectEvent();
|
void StartAffectEvent();
|
||||||
void ClearAffect(bool bSave=false);
|
void ClearAffect(bool bSave=false);
|
||||||
void ComputeAffect(CAffect * pkAff, bool bAdd);
|
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();
|
void RefreshAffect();
|
||||||
bool RemoveAffect(DWORD dwType);
|
bool RemoveAffect(DWORD dwType);
|
||||||
bool IsAffectFlag(DWORD dwAff) const;
|
bool IsAffectFlag(DWORD dwAff) const;
|
||||||
|
@ -1122,7 +1122,7 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||||
|
|
||||||
bool SwapItem(BYTE bCell, BYTE bDestCell);
|
bool SwapItem(BYTE bCell, BYTE bDestCell);
|
||||||
LPITEM AutoGiveItem(DWORD dwItemVnum, BYTE bCount=1, int iRarePct = -1, bool bMsg = true);
|
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 GetEmptyInventory(BYTE size) const;
|
||||||
int GetEmptyDragonSoulInventory(LPITEM pItem) const;
|
int GetEmptyDragonSoulInventory(LPITEM pItem) const;
|
||||||
|
@ -1249,7 +1249,7 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||||
void RewardGold(LPCHARACTER pkAttacker);
|
void RewardGold(LPCHARACTER pkAttacker);
|
||||||
|
|
||||||
bool Shoot(BYTE bType);
|
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 ForgetMyAttacker();
|
||||||
void AggregateMonster();
|
void AggregateMonster();
|
||||||
|
|
|
@ -272,8 +272,8 @@ int CHARACTER::ProcessAffect()
|
||||||
CHorseNameManager::instance().Validate(this);
|
CHorseNameManager::instance().Validate(this);
|
||||||
|
|
||||||
TAffectFlag afOld = m_afAffectFlag;
|
TAffectFlag afOld = m_afAffectFlag;
|
||||||
long lMovSpd = GetPoint(POINT_MOV_SPEED);
|
int lMovSpd = GetPoint(POINT_MOV_SPEED);
|
||||||
long lAttSpd = GetPoint(POINT_ATT_SPEED);
|
int lAttSpd = GetPoint(POINT_ATT_SPEED);
|
||||||
|
|
||||||
itertype(m_list_pkAffect) it;
|
itertype(m_list_pkAffect) it;
|
||||||
|
|
||||||
|
@ -467,8 +467,8 @@ void CHARACTER::LoadAffect(DWORD dwCount, TPacketAffectElement * pElements)
|
||||||
|
|
||||||
TAffectFlag afOld = m_afAffectFlag;
|
TAffectFlag afOld = m_afAffectFlag;
|
||||||
|
|
||||||
long lMovSpd = GetPoint(POINT_MOV_SPEED);
|
int lMovSpd = GetPoint(POINT_MOV_SPEED);
|
||||||
long lAttSpd = GetPoint(POINT_ATT_SPEED);
|
int lAttSpd = GetPoint(POINT_ATT_SPEED);
|
||||||
|
|
||||||
for (DWORD i = 0; i < dwCount; ++i, ++pElements)
|
for (DWORD i = 0; i < dwCount; ++i, ++pElements)
|
||||||
{
|
{
|
||||||
|
@ -533,7 +533,7 @@ void CHARACTER::LoadAffect(DWORD dwCount, TPacketAffectElement * pElements)
|
||||||
DragonSoul_Initialize();
|
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
|
// CHAT_BLOCK
|
||||||
if (dwType == AFFECT_BLOCK_CHAT && lDuration > 1)
|
if (dwType == AFFECT_BLOCK_CHAT && lDuration > 1)
|
||||||
|
|
|
@ -1433,7 +1433,7 @@ void CHARACTER::Dead(LPCHARACTER pkKiller, bool bImmediateDead)
|
||||||
if (GetMobRank() >= MOB_RANK_BOSS && pkKiller && pkKiller->IsPC())
|
if (GetMobRank() >= MOB_RANK_BOSS && pkKiller && pkKiller->IsPC())
|
||||||
{
|
{
|
||||||
char buf[51];
|
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())
|
if (IsStone())
|
||||||
LogManager::instance().CharLog(pkKiller, GetRaceNum(), "STONE_KILL", buf);
|
LogManager::instance().CharLog(pkKiller, GetRaceNum(), "STONE_KILL", buf);
|
||||||
else
|
else
|
||||||
|
@ -2077,7 +2077,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
|
||||||
// 제국으로 인한 보너스 (한국 올드 버전만 적용)
|
// 제국으로 인한 보너스 (한국 올드 버전만 적용)
|
||||||
//
|
//
|
||||||
int iEmpire = GetEmpire();
|
int iEmpire = GetEmpire();
|
||||||
long lMapIndex = GetMapIndex();
|
int lMapIndex = GetMapIndex();
|
||||||
int iMapEmpire = SECTREE_MANAGER::instance().GetEmpireFromMapIndex(lMapIndex);
|
int iMapEmpire = SECTREE_MANAGER::instance().GetEmpireFromMapIndex(lMapIndex);
|
||||||
|
|
||||||
if (LC_IsYMIR() == true)
|
if (LC_IsYMIR() == true)
|
||||||
|
@ -2854,7 +2854,7 @@ class CFuncShoot
|
||||||
BYTE m_bType;
|
BYTE m_bType;
|
||||||
bool m_bSucceed;
|
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;
|
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);
|
LPCHARACTER pkVictim = CHARACTER_MANAGER::instance().Find(dwTargetVID);
|
||||||
TPacketGCFlyTargeting pack;
|
TPacketGCFlyTargeting pack;
|
||||||
|
@ -3479,8 +3479,8 @@ struct FuncPullMonster
|
||||||
float fy;
|
float fy;
|
||||||
|
|
||||||
GetDeltaByDegree(degree, fDist - fNewDist, &fx, &fy);
|
GetDeltaByDegree(degree, fDist - fNewDist, &fx, &fy);
|
||||||
long tx = (long)(ch->GetX() + fx);
|
int tx = (int)(ch->GetX() + fx);
|
||||||
long ty = (long)(ch->GetY() + fy);
|
int ty = (int)(ch->GetY() + fy);
|
||||||
|
|
||||||
ch->Sync(tx, ty);
|
ch->Sync(tx, ty);
|
||||||
ch->Goto(tx, ty);
|
ch->Goto(tx, ty);
|
||||||
|
|
|
@ -88,6 +88,8 @@ bool CHARACTER::DragonSoul_ActivateDeck(int deck_idx)
|
||||||
if (NULL != pItem)
|
if (NULL != pItem)
|
||||||
DSManager::instance().ActivateDragonSoul(pItem);
|
DSManager::instance().ActivateDragonSoul(pItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHARACTER::DragonSoul_DeactivateAll()
|
void CHARACTER::DragonSoul_DeactivateAll()
|
||||||
|
|
|
@ -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);
|
sys_log(0, "HorseSummon : %s lv:%d bSummon:%d fromFar:%d", GetName(), GetLevel(), bSummon, bFromFar);
|
||||||
|
|
||||||
long x = GetX();
|
int x = GetX();
|
||||||
long y = GetY();
|
int y = GetY();
|
||||||
|
|
||||||
if (GetHorseHealth() <= 0)
|
if (GetHorseHealth() <= 0)
|
||||||
bFromFar = false;
|
bFromFar = false;
|
||||||
|
@ -245,7 +245,7 @@ void CHARACTER::HorseSummon(bool bSummon, bool bFromFar, DWORD dwVnum, const cha
|
||||||
float fx, fy;
|
float fx, fy;
|
||||||
chHorse->SetRotation(GetDegreeFromPositionXY(chHorse->GetX(), chHorse->GetY(), GetX(), GetY())+180);
|
chHorse->SetRotation(GetDegreeFromPositionXY(chHorse->GetX(), chHorse->GetY(), GetX(), GetY())+180);
|
||||||
GetDeltaByDegree(chHorse->GetRotation(), 3500, &fx, &fy);
|
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);
|
chHorse->SendMovePacket(FUNC_WAIT, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -676,6 +676,8 @@ bool CHARACTER::IsEmptyItemGrid(TItemPos Cell, BYTE bSize, int iExceptionCell) c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CHARACTER::GetEmptyInventory(BYTE size) const
|
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)
|
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)
|
if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM)
|
||||||
pkNewItem->SetSocket(slot++, socket);
|
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)
|
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)
|
switch (pProto->aLimits[i].bType)
|
||||||
{
|
{
|
||||||
|
@ -1071,7 +1073,7 @@ bool CHARACTER::DoRefineWithScroll(LPITEM item)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
|
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)
|
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++)
|
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)
|
if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM)
|
||||||
{
|
{
|
||||||
bHasMetinStone = true;
|
bHasMetinStone = true;
|
||||||
|
@ -1402,7 +1404,7 @@ bool CHARACTER::RefineItem(LPITEM pkItem, LPITEM pkTarget)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
|
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)
|
if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM)
|
||||||
{
|
{
|
||||||
AutoGiveItem(socket);
|
AutoGiveItem(socket);
|
||||||
|
@ -1672,7 +1674,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
BYTE bDestInven = DestCell.window_type;
|
BYTE bDestInven = DestCell.window_type;
|
||||||
for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
|
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)
|
switch (item->GetProto()->aLimits[i].bType)
|
||||||
{
|
{
|
||||||
|
@ -1712,7 +1714,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
if (0 == item->GetSocket(1))
|
if (0 == item->GetSocket(1))
|
||||||
{
|
{
|
||||||
// 사용가능시간은 Default 값으로 Limit Value 값을 사용하되, Socket0에 값이 있으면 그 값을 사용하도록 한다. (단위는 초)
|
// 사용가능시간은 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)
|
if (0 == duration)
|
||||||
duration = 60 * 60 * 24 * 7;
|
duration = 60 * 60 * 24 * 7;
|
||||||
|
@ -1761,7 +1763,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
float fx, fy;
|
float fx, fy;
|
||||||
GetDeltaByDegree(GetRotation(), 100.0f, &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)
|
if (!tree)
|
||||||
{
|
{
|
||||||
|
@ -1769,13 +1771,13 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
return false;
|
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("물 속에 모닥불을 피울 수 없습니다."));
|
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("물 속에 모닥불을 피울 수 없습니다."));
|
||||||
return false;
|
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<char_event_info>();
|
char_event_info* info = AllocEventInfo<char_event_info>();
|
||||||
|
|
||||||
|
@ -1962,7 +1964,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
DWORD dwBoxVnum = item2->GetVnum();
|
DWORD dwBoxVnum = item2->GetVnum();
|
||||||
std::vector <DWORD> dwVnums;
|
std::vector <DWORD> dwVnums;
|
||||||
std::vector <DWORD> dwCounts;
|
std::vector <DWORD> dwCounts;
|
||||||
std::vector <LPITEM> item_gets(NULL);
|
std::vector <LPITEM> item_gets;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
|
if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
|
||||||
|
@ -2026,7 +2028,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
DWORD dwBoxVnum = item->GetVnum();
|
DWORD dwBoxVnum = item->GetVnum();
|
||||||
std::vector <DWORD> dwVnums;
|
std::vector <DWORD> dwVnums;
|
||||||
std::vector <DWORD> dwCounts;
|
std::vector <DWORD> dwCounts;
|
||||||
std::vector <LPITEM> item_gets(NULL);
|
std::vector <LPITEM> item_gets;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
if (dwBoxVnum == 50033 && LC_IsYMIR()) // 알수없는 상자
|
if (dwBoxVnum == 50033 && LC_IsYMIR()) // 알수없는 상자
|
||||||
|
@ -2468,10 +2470,10 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이미 효과가 걸려 있습니다."));
|
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이미 효과가 걸려 있습니다."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
long time = item->GetValue(0);
|
int time = item->GetValue(0);
|
||||||
long moveSpeedPer = item->GetValue(1);
|
int moveSpeedPer = item->GetValue(1);
|
||||||
long attPer = item->GetValue(2);
|
int attPer = item->GetValue(2);
|
||||||
long expPer = item->GetValue(3);
|
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_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_ATTBONUS, attPer, AFF_NONE, time, 0, true, true);
|
||||||
AddAffect(AFFECT_NOG_ABILITY, POINT_MALL_EXPBONUS, expPer, 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 (단위 초)
|
지속시간 value 0 (단위 초)
|
||||||
|
|
||||||
*/
|
*/
|
||||||
long time = item->GetValue(0);
|
int time = item->GetValue(0);
|
||||||
long moveSpeedPer = item->GetValue(1);
|
int moveSpeedPer = item->GetValue(1);
|
||||||
long attPer = item->GetValue(2);
|
int attPer = item->GetValue(2);
|
||||||
long expPer = item->GetValue(3);
|
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_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_ATTBONUS, attPer, AFF_NONE, time, 0, true, true);
|
||||||
AddAffect(AFFECT_RAMADAN_ABILITY, POINT_MALL_EXPBONUS, expPer, 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stack<long> socket;
|
std::stack<int> socket;
|
||||||
|
|
||||||
for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
|
for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
|
||||||
socket.push(item2->GetSocket(i));
|
socket.push(item2->GetSocket(i));
|
||||||
|
@ -3609,7 +3611,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
DWORD dwBoxVnum = item->GetVnum();
|
DWORD dwBoxVnum = item->GetVnum();
|
||||||
std::vector <DWORD> dwVnums;
|
std::vector <DWORD> dwVnums;
|
||||||
std::vector <DWORD> dwCounts;
|
std::vector <DWORD> dwCounts;
|
||||||
std::vector <LPITEM> item_gets(NULL);
|
std::vector <LPITEM> item_gets;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
|
||||||
|
@ -3633,7 +3635,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
DWORD dwBoxVnum = item->GetVnum();
|
DWORD dwBoxVnum = item->GetVnum();
|
||||||
std::vector <DWORD> dwVnums;
|
std::vector <DWORD> dwVnums;
|
||||||
std::vector <DWORD> dwCounts;
|
std::vector <DWORD> dwCounts;
|
||||||
std::vector <LPITEM> item_gets(NULL);
|
std::vector <LPITEM> item_gets;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
|
||||||
|
@ -3656,7 +3658,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
DWORD dwBoxVnum = 50011;
|
DWORD dwBoxVnum = 50011;
|
||||||
std::vector <DWORD> dwVnums;
|
std::vector <DWORD> dwVnums;
|
||||||
std::vector <DWORD> dwCounts;
|
std::vector <DWORD> dwCounts;
|
||||||
std::vector <LPITEM> item_gets(NULL);
|
std::vector <LPITEM> item_gets;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
|
if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
|
||||||
|
@ -6156,7 +6158,7 @@ bool CHARACTER::EquipItem(LPITEM item, int iCandidateCell)
|
||||||
if (0 == item->GetSocket(1))
|
if (0 == item->GetSocket(1))
|
||||||
{
|
{
|
||||||
// 사용가능시간은 Default 값으로 Limit Value 값을 사용하되, Socket0에 값이 있으면 그 값을 사용하도록 한다. (단위는 초)
|
// 사용가능시간은 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)
|
if (0 == duration)
|
||||||
duration = 60 * 60 * 24 * 7;
|
duration = 60 * 60 * 24 * 7;
|
||||||
|
@ -7309,8 +7311,8 @@ void CHARACTER::AutoRecoveryItemProcess(const EAffectTypes type)
|
||||||
{
|
{
|
||||||
if (false == CArenaManager::instance().IsArenaMap(GetMapIndex()))
|
if (false == CArenaManager::instance().IsArenaMap(GetMapIndex()))
|
||||||
{
|
{
|
||||||
const long amount_of_used = pItem->GetSocket(idx_of_amount_of_used);
|
const int 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_full = pItem->GetSocket(idx_of_amount_of_full);
|
||||||
|
|
||||||
const int32_t avail = amount_of_full - amount_of_used;
|
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)
|
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)
|
switch (itemTable->aLimits[i].bType)
|
||||||
{
|
{
|
||||||
case LIMIT_LEVEL:
|
case LIMIT_LEVEL:
|
||||||
|
|
|
@ -110,7 +110,7 @@ void CHARACTER_MANAGER::DestroyCharacter(LPCHARACTER ch, const char* file, size_
|
||||||
// <Factor> Check whether it has been already deleted or not.
|
// <Factor> Check whether it has been already deleted or not.
|
||||||
itertype(m_map_pkChrByVID) it = m_map_pkChrByVID.find(ch->GetVID());
|
itertype(m_map_pkChrByVID) it = m_map_pkChrByVID.find(ch->GetVID());
|
||||||
if (it == m_map_pkChrByVID.end()) {
|
if (it == m_map_pkChrByVID.end()) {
|
||||||
sys_err("[CHARACTER_MANAGER::DestroyCharacter] <Factor> %d not found", (long)(ch->GetVID()));
|
sys_err("[CHARACTER_MANAGER::DestroyCharacter] <Factor> %d not found", (int)(ch->GetVID()));
|
||||||
return; // prevent duplicated destrunction
|
return; // prevent duplicated destrunction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ LPCHARACTER CHARACTER_MANAGER::FindPC(const char * name)
|
||||||
return found;
|
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;
|
int i;
|
||||||
long x, y;
|
int x, y;
|
||||||
for (i=0; i<2000; i++)
|
for (i=0; i<2000; i++)
|
||||||
{
|
{
|
||||||
x = number(1, (pkSectreeMap->m_setting.iWidth / 100) - 1) * 100 + pkSectreeMap->m_setting.iBaseX;
|
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];
|
char buf[512+1];
|
||||||
long local_x = x - pkSectreeMap->m_setting.iBaseX;
|
int local_x = x - pkSectreeMap->m_setting.iBaseX;
|
||||||
long local_y = y - pkSectreeMap->m_setting.iBaseY;
|
int 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());
|
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)
|
if (test_server)
|
||||||
SendNotice(buf);
|
SendNotice(buf);
|
||||||
|
@ -349,7 +349,7 @@ LPCHARACTER CHARACTER_MANAGER::SpawnMobRandomPosition(DWORD dwVnum, long lMapInd
|
||||||
return (ch);
|
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);
|
const CMob * pkMob = CMobManager::instance().Get(dwVnum);
|
||||||
if (!pkMob)
|
if (!pkMob)
|
||||||
|
@ -441,7 +441,7 @@ LPCHARACTER CHARACTER_MANAGER::SpawnMob(DWORD dwVnum, long lMapIndex, long x, lo
|
||||||
return (ch);
|
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);
|
const CMob * pkMob = CMobManager::instance().Get(dwVnum);
|
||||||
|
|
||||||
|
@ -481,7 +481,7 @@ void CHARACTER_MANAGER::SelectStone(LPCHARACTER pkChr)
|
||||||
m_pkChrSelectedStone = 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);
|
CMobGroup * pkGroup = CMobManager::Instance().GetGroup(dwVnum);
|
||||||
|
|
||||||
|
@ -547,7 +547,7 @@ bool CHARACTER_MANAGER::SpawnMoveGroup(DWORD dwVnum, long lMapIndex, int sx, int
|
||||||
return true;
|
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);
|
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);
|
CMobGroup * pkGroup = CMobManager::Instance().GetGroup(dwVnum);
|
||||||
|
|
||||||
|
@ -885,7 +885,7 @@ bool CHARACTER_MANAGER::GetCharactersByRaceNum(DWORD dwRaceNum, CharacterVectorI
|
||||||
//
|
//
|
||||||
// (job+1)*3+(skill_group)
|
// (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;
|
LPCHARACTER chFind = NULL;
|
||||||
itertype(m_map_pkChrByPID) it;
|
itertype(m_map_pkChrByPID) it;
|
||||||
|
@ -1034,7 +1034,7 @@ int CHARACTER_MANAGER::GetUserDamageRate(LPCHARACTER ch)
|
||||||
return m_iUserDamageRate;
|
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);
|
LPSECTREE_MAP pSecMap = SECTREE_MANAGER::instance().GetMap(lMapIndex);
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,12 @@ class CHARACTER_MANAGER : public singleton<CHARACTER_MANAGER>
|
||||||
|
|
||||||
void Update(int iPulse);
|
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 SpawnMob(DWORD dwVnum, int lMapIndex, int x, int y, int 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 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, long lMapIndex, int sx, int sy, int ex, int ey, LPREGEN pkRegen = NULL, bool bAggressive_ = false, LPDUNGEON pDungeon = NULL);
|
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, long 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, long lMapIndex, int sx, int sy, int ex, int ey, int tx, int ty, LPREGEN pkRegen = NULL, bool bAggressive_ = false);
|
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, long lMapIndex);
|
LPCHARACTER SpawnMobRandomPosition(DWORD dwVnum, int lMapIndex);
|
||||||
|
|
||||||
void SelectStone(LPCHARACTER pkChrStone);
|
void SelectStone(LPCHARACTER pkChrStone);
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class CHARACTER_MANAGER : public singleton<CHARACTER_MANAGER>
|
||||||
void UnregisterRaceNumMap(LPCHARACTER ch);
|
void UnregisterRaceNumMap(LPCHARACTER ch);
|
||||||
bool GetCharactersByRaceNum(DWORD dwRaceNum, CharacterVectorInteractor & i);
|
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 SetMobItemRate(int value) { m_iMobItemRate = value; }
|
||||||
void SetMobDamageRate(int value) { m_iMobDamageRate = value; }
|
void SetMobDamageRate(int value) { m_iMobDamageRate = value; }
|
||||||
|
@ -98,7 +98,7 @@ class CHARACTER_MANAGER : public singleton<CHARACTER_MANAGER>
|
||||||
int GetMobExpRate(LPCHARACTER ch);
|
int GetMobExpRate(LPCHARACTER ch);
|
||||||
|
|
||||||
int GetUserDamageRate(LPCHARACTER ch);
|
int GetUserDamageRate(LPCHARACTER ch);
|
||||||
void SendScriptToMap(long lMapIndex, const std::string & s);
|
void SendScriptToMap(int lMapIndex, const std::string & s);
|
||||||
|
|
||||||
bool BeginPendingDestroy();
|
bool BeginPendingDestroy();
|
||||||
void FlushPendingDestroy();
|
void FlushPendingDestroy();
|
||||||
|
|
|
@ -1478,9 +1478,9 @@ struct FuncSplashDamage
|
||||||
}
|
}
|
||||||
|
|
||||||
GetDeltaByDegree(degree, fCrushSlidingLength, &fx, &fy);
|
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));
|
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));
|
||||||
long tx = (long)(pkChrVictim->GetX()+fx);
|
int tx = (int)(pkChrVictim->GetX()+fx);
|
||||||
long ty = (long)(pkChrVictim->GetY()+fy);
|
int ty = (int)(pkChrVictim->GetY()+fy);
|
||||||
|
|
||||||
pkChrVictim->Sync(tx, ty);
|
pkChrVictim->Sync(tx, ty);
|
||||||
pkChrVictim->Goto(tx, ty);
|
pkChrVictim->Goto(tx, ty);
|
||||||
|
@ -1909,7 +1909,7 @@ int CHARACTER::ComputeSkillAtPosition(DWORD dwVnum, const PIXEL_POSITION& posTar
|
||||||
iAmount,
|
iAmount,
|
||||||
pkSk->dwAffectFlag,
|
pkSk->dwAffectFlag,
|
||||||
iDur,
|
iDur,
|
||||||
(long) pkSk->kDurationSPCostPoly.Eval(),
|
(int) pkSk->kDurationSPCostPoly.Eval(),
|
||||||
!bAdded);
|
!bAdded);
|
||||||
|
|
||||||
bAdded = true;
|
bAdded = true;
|
||||||
|
@ -2003,7 +2003,7 @@ int CHARACTER::ComputeSkill(DWORD dwVnum, LPCHARACTER pkVictim, BYTE bSkillLevel
|
||||||
dwVnum,
|
dwVnum,
|
||||||
GetName(),
|
GetName(),
|
||||||
pkVictim->GetName(),
|
pkVictim->GetName(),
|
||||||
(long)DISTANCE_SQRT(GetX() - pkVictim->GetX(), GetY() - pkVictim->GetY()),
|
(int)DISTANCE_SQRT(GetX() - pkVictim->GetX(), GetY() - pkVictim->GetY()),
|
||||||
pkSk->dwTargetRange);
|
pkSk->dwTargetRange);
|
||||||
|
|
||||||
return BATTLE_NONE;
|
return BATTLE_NONE;
|
||||||
|
@ -2249,7 +2249,7 @@ int CHARACTER::ComputeSkill(DWORD dwVnum, LPCHARACTER pkVictim, BYTE bSkillLevel
|
||||||
pkSk->kDurationPoly.SetVar("k", k/*bSkillLevel*/);
|
pkSk->kDurationPoly.SetVar("k", k/*bSkillLevel*/);
|
||||||
pkSk->kDurationSPCostPoly.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);
|
iDur += GetPoint(POINT_PARTY_BUFFER_BONUS);
|
||||||
|
|
||||||
if (pkVictim == this)
|
if (pkVictim == this)
|
||||||
|
@ -2257,7 +2257,7 @@ int CHARACTER::ComputeSkill(DWORD dwVnum, LPCHARACTER pkVictim, BYTE bSkillLevel
|
||||||
POINT_NONE, 0,
|
POINT_NONE, 0,
|
||||||
AFF_MUYEONG,
|
AFF_MUYEONG,
|
||||||
iDur,
|
iDur,
|
||||||
(long) pkSk->kDurationSPCostPoly.Eval(),
|
(int) pkSk->kDurationSPCostPoly.Eval(),
|
||||||
true);
|
true);
|
||||||
|
|
||||||
return BATTLE_NONE;
|
return BATTLE_NONE;
|
||||||
|
@ -2318,7 +2318,7 @@ int CHARACTER::ComputeSkill(DWORD dwVnum, LPCHARACTER pkVictim, BYTE bSkillLevel
|
||||||
iAmount,
|
iAmount,
|
||||||
affact_flag,
|
affact_flag,
|
||||||
iDur,
|
iDur,
|
||||||
(long) pkSk->kDurationSPCostPoly.Eval(),
|
(int) pkSk->kDurationSPCostPoly.Eval(),
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2336,7 +2336,7 @@ int CHARACTER::ComputeSkill(DWORD dwVnum, LPCHARACTER pkVictim, BYTE bSkillLevel
|
||||||
iAmount,
|
iAmount,
|
||||||
pkSk->dwAffectFlag,
|
pkSk->dwAffectFlag,
|
||||||
iDur,
|
iDur,
|
||||||
(long) pkSk->kDurationSPCostPoly.Eval(),
|
(int) pkSk->kDurationSPCostPoly.Eval(),
|
||||||
// ADD_GRANDMASTER_SKILL
|
// ADD_GRANDMASTER_SKILL
|
||||||
!bAdded);
|
!bAdded);
|
||||||
// END_OF_ADD_GRANDMASTER_SKILL
|
// END_OF_ADD_GRANDMASTER_SKILL
|
||||||
|
@ -2952,8 +2952,8 @@ bool CHARACTER::UseMobSkill(unsigned int idx)
|
||||||
{
|
{
|
||||||
float fx, fy;
|
float fx, fy;
|
||||||
GetDeltaByDegree(GetRotation(), rInfo.dwHitDistance, &fx, &fy);
|
GetDeltaByDegree(GetRotation(), rInfo.dwHitDistance, &fx, &fy);
|
||||||
pos.x += (long) fx;
|
pos.x += (int) fx;
|
||||||
pos.y += (long) fy;
|
pos.y += (int) fy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rInfo.dwTiming)
|
if (rInfo.dwTiming)
|
||||||
|
|
|
@ -225,8 +225,8 @@ namespace
|
||||||
|
|
||||||
int m_iMinDistance;
|
int m_iMinDistance;
|
||||||
int m_iMaxDistance;
|
int m_iMaxDistance;
|
||||||
long m_lx;
|
int m_lx;
|
||||||
long m_ly;
|
int m_ly;
|
||||||
|
|
||||||
LPCHARACTER m_pkChrVictim;
|
LPCHARACTER m_pkChrVictim;
|
||||||
};
|
};
|
||||||
|
@ -543,12 +543,12 @@ void CHARACTER::__StateIdle_NPC()
|
||||||
/*
|
/*
|
||||||
* 산타용
|
* 산타용
|
||||||
const int WARP_MAP_INDEX_NUM = 4;
|
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;
|
const int WARP_MAP_INDEX_NUM = 7;
|
||||||
static const long c_lWarpMapIndexs[WARP_MAP_INDEX_NUM] = { 61, 62, 63, 64, 3, 23, 43 };
|
static const int c_lWarpMapIndexs[WARP_MAP_INDEX_NUM] = { 61, 62, 63, 64, 3, 23, 43 };
|
||||||
long lNextMapIndex;
|
int lNextMapIndex;
|
||||||
lNextMapIndex = c_lWarpMapIndexs[number(1, WARP_MAP_INDEX_NUM) - 1];
|
lNextMapIndex = c_lWarpMapIndexs[number(1, WARP_MAP_INDEX_NUM) - 1];
|
||||||
|
|
||||||
if (map_allow_find(lNextMapIndex))
|
if (map_allow_find(lNextMapIndex))
|
||||||
|
@ -853,8 +853,8 @@ void CHARACTER::StateMove()
|
||||||
// 워프 테스트
|
// 워프 테스트
|
||||||
float fx, fy;
|
float fx, fy;
|
||||||
GetDeltaByDegree(victim->GetRotation(), 400, &fx, &fy);
|
GetDeltaByDegree(victim->GetRotation(), 400, &fx, &fy);
|
||||||
long new_x = victim->GetX() + (long)fx;
|
int new_x = victim->GetX() + (int)fx;
|
||||||
long new_y = victim->GetY() + (long)fy;
|
int new_y = victim->GetY() + (int)fy;
|
||||||
SetRotation(GetDegreeFromPositionXY(new_x, new_y, victim->GetX(), victim->GetY()));
|
SetRotation(GetDegreeFromPositionXY(new_x, new_y, victim->GetX(), victim->GetY()));
|
||||||
Show(victim->GetMapIndex(), new_x, new_y, 0, true);
|
Show(victim->GetMapIndex(), new_x, new_y, 0, true);
|
||||||
GotoState(m_stateBattle);
|
GotoState(m_stateBattle);
|
||||||
|
@ -980,7 +980,7 @@ void CHARACTER::StateBattle()
|
||||||
|
|
||||||
SetRotation(GetDegreeFromPosition(dx, dy));
|
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);
|
sys_log(0, "KILL_AND_GO: %s distance %.1f", GetName(), fDist);
|
||||||
SendMovePacket(FUNC_WAIT, 0, 0, 0, 0);
|
SendMovePacket(FUNC_WAIT, 0, 0, 0, 0);
|
||||||
|
|
|
@ -1,401 +0,0 @@
|
||||||
#include "stdafx.h"
|
|
||||||
|
|
||||||
#include "cipher.h"
|
|
||||||
|
|
||||||
#ifdef _IMPROVED_PACKET_ENCRYPTION_
|
|
||||||
|
|
||||||
#include <cryptopp/modes.h>
|
|
||||||
#include <cryptopp/nbtheory.h>
|
|
||||||
#include <cryptopp/osrng.h>
|
|
||||||
|
|
||||||
// Diffie-Hellman key agreement
|
|
||||||
#include <cryptopp/dh.h>
|
|
||||||
#include <cryptopp/dh2.h>
|
|
||||||
|
|
||||||
// AES winner and candidates
|
|
||||||
//#include <cryptopp/aes.h>
|
|
||||||
#include <cryptopp/cast.h>
|
|
||||||
#include <cryptopp/rc6.h>
|
|
||||||
#include <cryptopp/mars.h>
|
|
||||||
#include <cryptopp/serpent.h>
|
|
||||||
#include <cryptopp/twofish.h>
|
|
||||||
// Other block ciphers
|
|
||||||
#include <cryptopp/blowfish.h>
|
|
||||||
#include <cryptopp/camellia.h>
|
|
||||||
#include <cryptopp/des.h>
|
|
||||||
#include <cryptopp/idea.h>
|
|
||||||
#include <cryptopp/rc5.h>
|
|
||||||
#include <cryptopp/seed.h>
|
|
||||||
#include <cryptopp/shacal2.h>
|
|
||||||
#include <cryptopp/skipjack.h>
|
|
||||||
#include <cryptopp/tea.h>
|
|
||||||
|
|
||||||
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<class T>
|
|
||||||
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<T>::Encryption(key, keylen, iv);
|
|
||||||
}
|
|
||||||
virtual SymmetricCipher* CreateDecoder(const byte* key, size_t keylen,
|
|
||||||
const byte* iv) const {
|
|
||||||
return new typename CTR_Mode<T>::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<BlockCipherAlgorithm> algorithm_0(detail_0);
|
|
||||||
std::unique_ptr<BlockCipherAlgorithm> 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<AES>();
|
|
||||||
break;
|
|
||||||
case kRC6:
|
|
||||||
detail = new BlockCipherDetail<RC6>();
|
|
||||||
break;
|
|
||||||
case kMARS:
|
|
||||||
detail = new BlockCipherDetail<MARS>();
|
|
||||||
break;
|
|
||||||
case kTwofish:
|
|
||||||
detail = new BlockCipherDetail<Twofish>();
|
|
||||||
break;
|
|
||||||
case kSerpent:
|
|
||||||
detail = new BlockCipherDetail<Serpent>();
|
|
||||||
break;
|
|
||||||
case kCAST256:
|
|
||||||
detail = new BlockCipherDetail<CAST256>();
|
|
||||||
break;
|
|
||||||
case kIDEA:
|
|
||||||
detail = new BlockCipherDetail<IDEA>();
|
|
||||||
break;
|
|
||||||
case k3DES:
|
|
||||||
detail = new BlockCipherDetail<DES_EDE2>();
|
|
||||||
break;
|
|
||||||
case kCamellia:
|
|
||||||
detail = new BlockCipherDetail<Camellia>();
|
|
||||||
break;
|
|
||||||
case kSEED:
|
|
||||||
detail = new BlockCipherDetail<SEED>();
|
|
||||||
break;
|
|
||||||
case kRC5:
|
|
||||||
detail = new BlockCipherDetail<RC5>();
|
|
||||||
break;
|
|
||||||
case kBlowfish:
|
|
||||||
detail = new BlockCipherDetail<Blowfish>();
|
|
||||||
break;
|
|
||||||
case kTEA:
|
|
||||||
detail = new BlockCipherDetail<TEA>();
|
|
||||||
break;
|
|
||||||
// case kSKIPJACK:
|
|
||||||
// detail = new BlockCipherDetail<SKIPJACK>();
|
|
||||||
// break;
|
|
||||||
case kSHACAL2:
|
|
||||||
detail = new BlockCipherDetail<SHACAL2>();
|
|
||||||
break;
|
|
||||||
case kDefault:
|
|
||||||
default:
|
|
||||||
detail = new BlockCipherDetail<Twofish>(); // 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
|
|
|
@ -1,60 +0,0 @@
|
||||||
#ifndef __CIPHER_H__
|
|
||||||
#define __CIPHER_H__
|
|
||||||
|
|
||||||
#ifdef _IMPROVED_PACKET_ENCRYPTION_
|
|
||||||
|
|
||||||
#include <cryptopp/cryptlib.h>
|
|
||||||
|
|
||||||
// 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__
|
|
|
@ -20,7 +20,7 @@ struct emotion_type_s
|
||||||
{
|
{
|
||||||
const char * command;
|
const char * command;
|
||||||
const char * command_to_client;
|
const char * command_to_client;
|
||||||
long flag;
|
int flag;
|
||||||
float extra_delay;
|
float extra_delay;
|
||||||
} emotion_types[] = {
|
} emotion_types[] = {
|
||||||
{ "Å°½º", "french_kiss", NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM, 2.0f },
|
{ "Å°½º", "french_kiss", NEED_PC | OTHER_SEX_ONLY | BOTH_DISARM, 2.0f },
|
||||||
|
@ -188,7 +188,7 @@ ACMD(do_emotion)
|
||||||
return;
|
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)
|
if (distance < 10)
|
||||||
{
|
{
|
||||||
|
|
|
@ -87,7 +87,7 @@ ACMD(do_pcbang_update)
|
||||||
char arg1[256];
|
char arg1[256];
|
||||||
one_argument(argument, arg1, sizeof(arg1));
|
one_argument(argument, arg1, sizeof(arg1));
|
||||||
|
|
||||||
unsigned long PCBangID = 0;
|
unsigned int PCBangID = 0;
|
||||||
|
|
||||||
if (*arg1 == '\0')
|
if (*arg1 == '\0')
|
||||||
PCBangID = 0;
|
PCBangID = 0;
|
||||||
|
@ -852,7 +852,7 @@ ACMD(do_mob_ld)
|
||||||
}
|
}
|
||||||
|
|
||||||
int dir = 1;
|
int dir = 1;
|
||||||
long x, y;
|
int x, y;
|
||||||
|
|
||||||
if (*arg2)
|
if (*arg2)
|
||||||
str_to_number(x, arg2);
|
str_to_number(x, arg2);
|
||||||
|
@ -974,22 +974,22 @@ ACMD(do_state)
|
||||||
snprintf(buf, sizeof(buf), "%s's State: ", tch->GetName());
|
snprintf(buf, sizeof(buf), "%s's State: ", tch->GetName());
|
||||||
|
|
||||||
if (tch->IsPosition(POS_FIGHTING))
|
if (tch->IsPosition(POS_FIGHTING))
|
||||||
strncat(buf, "Battle", sizeof(buf));
|
strncat(buf, "Battle", sizeof(buf) - strlen(buf) - 1);
|
||||||
else if (tch->IsPosition(POS_DEAD))
|
else if (tch->IsPosition(POS_DEAD))
|
||||||
strncat(buf, "Dead", sizeof(buf));
|
strncat(buf, "Dead", sizeof(buf) - strlen(buf) - 1);
|
||||||
else
|
else
|
||||||
strncat(buf, "Standing", sizeof(buf));
|
strncat(buf, "Standing", sizeof(buf) - strlen(buf) - 1);
|
||||||
|
|
||||||
if (ch->GetShop())
|
if (ch->GetShop())
|
||||||
strncat(buf, ", Shop", sizeof(buf));
|
strncat(buf, ", Shop", sizeof(buf) - strlen(buf) - 1);
|
||||||
|
|
||||||
if (ch->GetExchange())
|
if (ch->GetExchange())
|
||||||
strncat(buf, ", Exchange", sizeof(buf));
|
strncat(buf, ", Exchange", sizeof(buf) - strlen(buf) - 1);
|
||||||
|
|
||||||
ch->ChatPacket(CHAT_TYPE_INFO, "%s", buf);
|
ch->ChatPacket(CHAT_TYPE_INFO, "%s", buf);
|
||||||
|
|
||||||
int len;
|
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);
|
tch->GetX(), tch->GetY(), tch->GetX() / 100, tch->GetY() / 100);
|
||||||
|
|
||||||
if (len < 0 || len >= (int) sizeof(buf))
|
if (len < 0 || len >= (int) sizeof(buf))
|
||||||
|
@ -1000,7 +1000,7 @@ ACMD(do_state)
|
||||||
if (pSec)
|
if (pSec)
|
||||||
{
|
{
|
||||||
TMapSetting& map_setting = SECTREE_MANAGER::instance().GetMap(tch->GetMapIndex())->m_setting;
|
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);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long lMapIndex;
|
int lMapIndex;
|
||||||
long map_index = 0;
|
int map_index = 0;
|
||||||
str_to_number(map_index, arg1);
|
str_to_number(map_index, arg1);
|
||||||
if ((lMapIndex = SECTREE_MANAGER::instance().CreatePrivateMap(map_index)))
|
if ((lMapIndex = SECTREE_MANAGER::instance().CreatePrivateMap(map_index)))
|
||||||
{
|
{
|
||||||
|
@ -2705,7 +2705,7 @@ ACMD(do_vote_block_chat)
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* name = arg1;
|
const char* name = arg1;
|
||||||
long lBlockDuration = 10;
|
int lBlockDuration = 10;
|
||||||
sys_log(0, "vote_block_chat %s %d", name, lBlockDuration);
|
sys_log(0, "vote_block_chat %s %d", name, lBlockDuration);
|
||||||
|
|
||||||
LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(name);
|
LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(name);
|
||||||
|
@ -2764,7 +2764,7 @@ ACMD(do_block_chat)
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* name = arg1;
|
const char* name = arg1;
|
||||||
long lBlockDuration = parse_time_str(argument);
|
int lBlockDuration = parse_time_str(argument);
|
||||||
|
|
||||||
if (lBlockDuration < 0)
|
if (lBlockDuration < 0)
|
||||||
{
|
{
|
||||||
|
@ -2956,9 +2956,9 @@ ACMD(do_build)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
long map_x = 0;
|
int map_x = 0;
|
||||||
str_to_number(map_x, arg2);
|
str_to_number(map_x, arg2);
|
||||||
long map_y = 0;
|
int map_y = 0;
|
||||||
str_to_number(map_y, arg3);
|
str_to_number(map_y, arg3);
|
||||||
|
|
||||||
bool isSuccess = pkLand->RequestCreateObject(dwVnum,
|
bool isSuccess = pkLand->RequestCreateObject(dwVnum,
|
||||||
|
@ -3234,7 +3234,7 @@ ACMD(do_save_attribute_to_image) // command "/saveati" for alias
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long lMapIndex = 0;
|
int lMapIndex = 0;
|
||||||
str_to_number(lMapIndex, szMapIndex);
|
str_to_number(lMapIndex, szMapIndex);
|
||||||
|
|
||||||
if (SECTREE_MANAGER::instance().SaveAttributeToImage(lMapIndex, szFileName))
|
if (SECTREE_MANAGER::instance().SaveAttributeToImage(lMapIndex, szFileName))
|
||||||
|
@ -3932,7 +3932,7 @@ ACMD(do_set_stat)
|
||||||
|
|
||||||
two_arguments (argument, szName, sizeof (szName), szChangeAmount, sizeof(szChangeAmount));
|
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.");
|
ch->ChatPacket (CHAT_TYPE_INFO, "Invalid argument.");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "item_manager.h"
|
#include "item_manager.h"
|
||||||
#include "p2p.h"
|
#include "p2p.h"
|
||||||
#include "char.h"
|
#include "char.h"
|
||||||
#include "ip_ban.h"
|
|
||||||
#include "war_map.h"
|
#include "war_map.h"
|
||||||
#include "locale_service.h"
|
#include "locale_service.h"
|
||||||
#include "config.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;
|
int ping_event_second_cycle = passes_per_sec * 60;
|
||||||
bool g_bNoMoreClient = false;
|
bool g_bNoMoreClient = false;
|
||||||
bool g_bNoRegen = false;
|
bool g_bNoRegen = false;
|
||||||
bool g_bNoPasspod = false;
|
|
||||||
|
|
||||||
// TRAFFIC_PROFILER
|
// TRAFFIC_PROFILER
|
||||||
bool g_bTrafficProfileOn = false;
|
bool g_bTrafficProfileOn = false;
|
||||||
|
@ -171,7 +169,7 @@ void map_allow_add(int index)
|
||||||
s_set_map_allows.insert(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;
|
int iCount = 0;
|
||||||
std::set<int>::iterator it = s_set_map_allows.begin();
|
std::set<int>::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]));
|
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]));
|
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];
|
char buf[256];
|
||||||
one_argument(line, buf, sizeof(buf));
|
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]));
|
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]));
|
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];
|
char buf[256];
|
||||||
one_argument(line, buf, sizeof(buf));
|
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));
|
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));
|
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];
|
char buf[256];
|
||||||
one_argument(line, buf, sizeof(buf));
|
one_argument(line, buf, sizeof(buf));
|
||||||
|
@ -892,8 +890,6 @@ void config_init(const string& st_localeServiceName)
|
||||||
|
|
||||||
g_bAuthServer = true;
|
g_bAuthServer = true;
|
||||||
|
|
||||||
LoadBanIP("BANIP");
|
|
||||||
|
|
||||||
if (!strcasecmp(szIP, "master"))
|
if (!strcasecmp(szIP, "master"))
|
||||||
fprintf(stdout, "AUTH_SERVER: I am the master\n");
|
fprintf(stdout, "AUTH_SERVER: I am the master\n");
|
||||||
else
|
else
|
||||||
|
|
|
@ -20,9 +20,6 @@ extern WORD db_port;
|
||||||
extern char teen_addr[ADDRESS_MAX_LEN + 1];
|
extern char teen_addr[ADDRESS_MAX_LEN + 1];
|
||||||
extern WORD teen_port;
|
extern WORD teen_port;
|
||||||
|
|
||||||
extern char passpod_addr[ADDRESS_MAX_LEN + 1];
|
|
||||||
extern WORD passpod_port;
|
|
||||||
|
|
||||||
extern int passes_per_sec;
|
extern int passes_per_sec;
|
||||||
extern int save_event_second_cycle;
|
extern int save_event_second_cycle;
|
||||||
extern int ping_event_second_cycle;
|
extern int ping_event_second_cycle;
|
||||||
|
@ -40,7 +37,7 @@ extern bool g_bTrafficProfileOn; ///< true
|
||||||
extern BYTE g_bChannel;
|
extern BYTE g_bChannel;
|
||||||
|
|
||||||
extern bool map_allow_find(int index);
|
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 bool no_wander;
|
||||||
|
|
||||||
extern int g_iUserLimit;
|
extern int g_iUserLimit;
|
||||||
|
|
|
@ -1138,7 +1138,7 @@ const int aiPolymorphPowerByLevel[SKILL_MAX_LEVEL + 1] =
|
||||||
TGuildWarInfo KOR_aGuildWarInfo[GUILD_WAR_TYPE_MAX_NUM] =
|
TGuildWarInfo KOR_aGuildWarInfo[GUILD_WAR_TYPE_MAX_NUM] =
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
long lMapIndex;
|
int lMapIndex;
|
||||||
int iWarPrice;
|
int iWarPrice;
|
||||||
int iWinnerPotionRewardPctToWinner;
|
int iWinnerPotionRewardPctToWinner;
|
||||||
int iLoserPotionRewardPctToWinner;
|
int iLoserPotionRewardPctToWinner;
|
||||||
|
@ -1186,7 +1186,7 @@ const int aiAccessorySocketPutPct[ITEM_ACCESSORY_SOCKET_MAX_NUM + 1] =
|
||||||
typedef struct SValueName
|
typedef struct SValueName
|
||||||
{
|
{
|
||||||
const char * c_pszName;
|
const char * c_pszName;
|
||||||
long lValue;
|
int lValue;
|
||||||
} TValueName;
|
} TValueName;
|
||||||
|
|
||||||
TValueName c_aApplyTypeNames[] =
|
TValueName c_aApplyTypeNames[] =
|
||||||
|
@ -1285,7 +1285,7 @@ TValueName c_aApplyTypeNames[] =
|
||||||
};
|
};
|
||||||
// from import_item_proto.c
|
// 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;
|
TValueName *value_name;
|
||||||
for (value_name = c_aApplyTypeNames; value_name->c_pszName; ++value_name)
|
for (value_name = c_aApplyTypeNames; value_name->c_pszName; ++value_name)
|
||||||
|
|
|
@ -161,7 +161,7 @@ extern const SStoneDropInfo aStoneDrop[STONE_INFO_MAX_NUM];
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
long lMapIndex;
|
int lMapIndex;
|
||||||
int iWarPrice;
|
int iWarPrice;
|
||||||
int iWinnerPotionRewardPctToWinner;
|
int iWinnerPotionRewardPctToWinner;
|
||||||
int iLoserPotionRewardPctToWinner;
|
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 aiAccessorySocketEffectivePct[ITEM_ACCESSORY_SOCKET_MAX_NUM + 1];
|
||||||
extern const int aiAccessorySocketDegradeTime[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];
|
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
|
// 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
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "crc32.h"
|
#include "crc32.h"
|
||||||
|
|
||||||
static unsigned long CRCTable[256] =
|
static unsigned int CRCTable[256] =
|
||||||
{
|
{
|
||||||
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F,
|
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F,
|
||||||
0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
|
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)
|
crc_t GetFastHash(const char * key, size_t len)
|
||||||
{
|
{
|
||||||
const char * end = key + len;
|
const char * end = key + len;
|
||||||
unsigned long h = 0;
|
unsigned int h = 0;
|
||||||
|
|
||||||
while (key < end)
|
while (key < end)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __INC_CRC32_H__
|
#ifndef __INC_CRC32_H__
|
||||||
#define __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 GetCRC32(const char * buffer, size_t count);
|
||||||
crc_t GetCaseCRC32(const char * buffer, size_t count);
|
crc_t GetCaseCRC32(const char * buffer, size_t count);
|
||||||
|
|
|
@ -322,7 +322,7 @@ void Cube_open (LPCHARACTER ch)
|
||||||
return;
|
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)
|
if (distance >= CUBE_MAX_DISTANCE)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,40 +20,8 @@
|
||||||
#include "pcbang.h"
|
#include "pcbang.h"
|
||||||
#include "spam.h"
|
#include "spam.h"
|
||||||
|
|
||||||
extern bool g_bNoPasspod;
|
|
||||||
extern std::string g_stBlockDate;
|
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)
|
DBManager::DBManager() : m_bIsConnect(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -240,7 +208,7 @@ void DBManager::PushBilling(CLoginData * pkLD)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pkLD->SetLogonTime();
|
pkLD->SetLogonTime();
|
||||||
long lRemainSecs = pkLD->GetRemainSecs() - t.dwUseSec;
|
int lRemainSecs = pkLD->GetRemainSecs() - t.dwUseSec;
|
||||||
pkLD->SetRemainSecs(MAX(0, lRemainSecs));
|
pkLD->SetRemainSecs(MAX(0, lRemainSecs));
|
||||||
|
|
||||||
t.dwLoginKey = pkLD->GetKey();
|
t.dwLoginKey = pkLD->GetKey();
|
||||||
|
@ -497,7 +465,7 @@ void DBManager::SendAuthLogin(LPDESC d)
|
||||||
SendLoginPing(r.login);
|
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();
|
const TAccountTable & r = d->GetAccountTable();
|
||||||
|
|
||||||
|
@ -518,7 +486,7 @@ void DBManager::LoginPrepare(BYTE bBillType, DWORD dwBillID, long lRemainSecs, L
|
||||||
|
|
||||||
if (*d->GetMatrixCode())
|
if (*d->GetMatrixCode())
|
||||||
{
|
{
|
||||||
unsigned long rows = 0, cols = 0;
|
unsigned int rows = 0, cols = 0;
|
||||||
MatrixCardRndCoordinate(rows, cols);
|
MatrixCardRndCoordinate(rows, cols);
|
||||||
|
|
||||||
d->SetMatrixCardRowsAndColumns(rows, cols);
|
d->SetMatrixCardRowsAndColumns(rows, cols);
|
||||||
|
@ -545,28 +513,6 @@ void DBManager::LoginPrepare(BYTE bBillType, DWORD dwBillID, long lRemainSecs, L
|
||||||
}
|
}
|
||||||
else
|
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)
|
if (LC_IsEurope() || test_server)
|
||||||
{
|
{
|
||||||
long retValue = 0;
|
int retValue = 0;
|
||||||
str_to_number(retValue, row[col]);
|
str_to_number(retValue, row[col]);
|
||||||
|
|
||||||
time_t create_time = retValue;
|
time_t create_time = retValue;
|
||||||
|
|
|
@ -93,7 +93,7 @@ class DBManager : public singleton<DBManager>
|
||||||
|
|
||||||
void SendMoneyLog(BYTE type, DWORD vnum, int gold);
|
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 SendAuthLogin(LPDESC d);
|
||||||
void SendLoginPing(const char * c_pszLogin);
|
void SendLoginPing(const char * c_pszLogin);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,60 @@ extern int max_bytes_written;
|
||||||
extern int current_bytes_written;
|
extern int current_bytes_written;
|
||||||
extern int total_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()
|
DESC::DESC()
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
|
@ -36,38 +90,26 @@ void DESC::Initialize()
|
||||||
m_bDestroyed = false;
|
m_bDestroyed = false;
|
||||||
|
|
||||||
m_pInputProcessor = NULL;
|
m_pInputProcessor = NULL;
|
||||||
m_lpFdw = NULL;
|
m_evbase = nullptr;
|
||||||
m_sock = INVALID_SOCKET;
|
m_bufevent = nullptr;
|
||||||
m_iPhase = PHASE_CLOSE;
|
m_iPhase = PHASE_CLOSE;
|
||||||
m_dwHandle = 0;
|
m_dwHandle = 0;
|
||||||
|
|
||||||
m_wPort = 0;
|
m_wPort = 0;
|
||||||
m_LastTryToConnectTime = 0;
|
m_LastTryToConnectTime = 0;
|
||||||
|
|
||||||
m_lpInputBuffer = NULL;
|
|
||||||
m_iMinInputBufferLen = 0;
|
|
||||||
|
|
||||||
m_dwHandshake = 0;
|
m_dwHandshake = 0;
|
||||||
m_dwHandshakeSentTime = 0;
|
m_dwHandshakeSentTime = 0;
|
||||||
m_iHandshakeRetry = 0;
|
m_iHandshakeRetry = 0;
|
||||||
m_dwClientTime = 0;
|
m_dwClientTime = 0;
|
||||||
m_bHandshaking = false;
|
m_bHandshaking = false;
|
||||||
|
|
||||||
m_lpBufferedOutputBuffer = NULL;
|
|
||||||
m_lpOutputBuffer = NULL;
|
|
||||||
|
|
||||||
m_pkPingEvent = NULL;
|
m_pkPingEvent = NULL;
|
||||||
m_lpCharacter = NULL;
|
m_lpCharacter = NULL;
|
||||||
memset( &m_accountTable, 0, sizeof(m_accountTable) );
|
memset( &m_accountTable, 0, sizeof(m_accountTable) );
|
||||||
|
|
||||||
memset( &m_SockAddr, 0, sizeof(m_SockAddr) );
|
|
||||||
|
|
||||||
m_pLogFile = NULL;
|
m_pLogFile = NULL;
|
||||||
|
|
||||||
#ifndef _IMPROVED_PACKET_ENCRYPTION_
|
|
||||||
m_bEncrypted = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_wP2PPort = 0;
|
m_wP2PPort = 0;
|
||||||
m_bP2PChannel = 0;
|
m_bP2PChannel = 0;
|
||||||
|
|
||||||
|
@ -84,11 +126,6 @@ void DESC::Initialize()
|
||||||
m_dwLoginKey = 0;
|
m_dwLoginKey = 0;
|
||||||
m_dwPanamaKey = 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_bCRCMagicCubeIdx = 0;
|
||||||
m_dwProcCRC = 0;
|
m_dwProcCRC = 0;
|
||||||
m_dwFileCRC = 0;
|
m_dwFileCRC = 0;
|
||||||
|
@ -129,9 +166,6 @@ void DESC::Destroy()
|
||||||
m_lpCharacter = NULL;
|
m_lpCharacter = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SAFE_BUFFER_DELETE(m_lpOutputBuffer);
|
|
||||||
SAFE_BUFFER_DELETE(m_lpInputBuffer);
|
|
||||||
|
|
||||||
event_cancel(&m_pkPingEvent);
|
event_cancel(&m_pkPingEvent);
|
||||||
event_cancel(&m_pkDisconnectEvent);
|
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);
|
sys_log(0, "SYSTEM: closing socket.");
|
||||||
Log("SYSTEM: closing socket. DESC #%d", m_sock);
|
Log("SYSTEM: closing socket.");
|
||||||
fdwatch_del_fd(m_lpFdw, m_sock);
|
|
||||||
|
|
||||||
#ifdef _IMPROVED_PACKET_ENCRYPTION_
|
bufferevent_free(m_bufevent);
|
||||||
cipher_.CleanUp();
|
m_bufevent = nullptr;
|
||||||
#endif
|
|
||||||
|
|
||||||
socket_close(m_sock);
|
|
||||||
m_sock = INVALID_SOCKET;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_seq_vector.clear();
|
m_seq_vector.clear();
|
||||||
|
@ -211,28 +240,24 @@ void DESC::SetPong(bool b)
|
||||||
m_bPong = 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_bufevent = bufferevent_socket_new(evbase, fd, BEV_OPT_CLOSE_ON_FREE);
|
||||||
m_sock = _fd;
|
if (m_bufevent == nullptr) {
|
||||||
|
sys_err("DESC::Setup : Could not set up bufferevent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
m_stHost = inet_ntoa(c_rSockAddr.sin_addr);
|
// Set the event handlers for this peer
|
||||||
m_wPort = c_rSockAddr.sin_port;
|
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;
|
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<desc_event_info>();
|
desc_event_info* info = AllocEventInfo<desc_event_info>();
|
||||||
|
|
||||||
|
@ -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);
|
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
|
// Set Phase to handshake
|
||||||
SetPhase(PHASE_HANDSHAKE);
|
SetPhase(PHASE_HANDSHAKE);
|
||||||
StartHandshake(_handshake);
|
StartHandshake(_handshake);
|
||||||
|
|
||||||
sys_log(0, "SYSTEM: new connection from [%s] fd: %d handshake %u output input_len %d, ptr %p",
|
sys_log(0, "SYSTEM: new connection from [%s] handshake %u, ptr %p",
|
||||||
m_stHost.c_str(), m_sock, m_dwHandshake, buffer_size(m_lpInputBuffer), this);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DESC::ProcessInput()
|
int DESC::ProcessInput()
|
||||||
{
|
{
|
||||||
ssize_t bytes_read;
|
evbuffer *input = bufferevent_get_input(m_bufevent);
|
||||||
|
if (input == nullptr) {
|
||||||
if (!m_lpInputBuffer)
|
|
||||||
{
|
|
||||||
sys_err("DESC::ProcessInput : nil input buffer");
|
sys_err("DESC::ProcessInput : nil input buffer");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer_adjust_size(m_lpInputBuffer, m_iMinInputBufferLen);
|
size_t bytes_read = evbuffer_get_length(input);
|
||||||
bytes_read = socket_read(m_sock, (char *) buffer_write_peek(m_lpInputBuffer), buffer_has_space(m_lpInputBuffer));
|
|
||||||
|
|
||||||
if (bytes_read < 0)
|
if (bytes_read < 0)
|
||||||
return -1;
|
return -1;
|
||||||
else if (bytes_read == 0)
|
else if (bytes_read == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
buffer_write_proceed(m_lpInputBuffer, bytes_read);
|
|
||||||
|
|
||||||
if (!m_pInputProcessor)
|
if (!m_pInputProcessor)
|
||||||
sys_err("no input processor");
|
sys_err("no input processor");
|
||||||
#ifdef _IMPROVED_PACKET_ENCRYPTION_
|
|
||||||
else
|
|
||||||
{
|
// Get the received data
|
||||||
if (cipher_.activated()) {
|
void * data = evbuffer_pullup(input, bytes_read);
|
||||||
cipher_.Decrypt(const_cast<void*>(buffer_read_peek(m_lpInputBuffer)), buffer_size(m_lpInputBuffer));
|
|
||||||
}
|
|
||||||
|
|
||||||
int iBytesProceed = 0;
|
int iBytesProceed = 0;
|
||||||
|
|
||||||
// false가 리턴 되면 다른 phase로 바뀐 것이므로 다시 프로세스로 돌입한다!
|
// false가 리턴 되면 다른 phase로 바뀐 것이므로 다시 프로세스로 돌입한다!
|
||||||
while (!m_pInputProcessor->Process(this, buffer_read_peek(m_lpInputBuffer), buffer_size(m_lpInputBuffer), iBytesProceed))
|
while (!m_pInputProcessor->Process(this, data, bytes_read, iBytesProceed))
|
||||||
{
|
{
|
||||||
buffer_read_proceed(m_lpInputBuffer, iBytesProceed);
|
// Flush the read bytes from the network buffer
|
||||||
|
evbuffer_drain(input, iBytesProceed);
|
||||||
iBytesProceed = 0;
|
iBytesProceed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer_read_proceed(m_lpInputBuffer, iBytesProceed);
|
// Flush the read bytes from the network buffer
|
||||||
}
|
evbuffer_drain(input, iBytesProceed);
|
||||||
#else
|
|
||||||
else if (!m_bEncrypted)
|
|
||||||
{
|
|
||||||
int iBytesProceed = 0;
|
|
||||||
|
|
||||||
// false가 리턴 되면 다른 phase로 바뀐 것이므로 다시 프로세스로 돌입한다!
|
return bytes_read;
|
||||||
while (!m_pInputProcessor->Process(this, buffer_read_peek(m_lpInputBuffer), buffer_size(m_lpInputBuffer), iBytesProceed))
|
|
||||||
{
|
|
||||||
buffer_read_proceed(m_lpInputBuffer, iBytesProceed);
|
|
||||||
iBytesProceed = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer_read_proceed(m_lpInputBuffer, iBytesProceed);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int iSizeBuffer = buffer_size(m_lpInputBuffer);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int DESC::ProcessOutput()
|
bool DESC::RawPacket(const void * c_pvData, int iSize)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
if (m_iPhase == PHASE_CLOSE)
|
if (m_iPhase == PHASE_CLOSE)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
if (!m_lpBufferedOutputBuffer)
|
if (!m_bufevent) {
|
||||||
m_lpBufferedOutputBuffer = buffer_new(MAX(1024, iSize));
|
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)
|
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));
|
strncpy(p.szName, m_stRelayName.c_str(), sizeof(p.szName));
|
||||||
p.lSize = iSize;
|
p.lSize = iSize;
|
||||||
|
|
||||||
if (!packet_encode(m_lpOutputBuffer, &p, sizeof(p)))
|
if (!RawPacket(&p, sizeof(p)))
|
||||||
{
|
{
|
||||||
m_iPhase = PHASE_CLOSE;
|
m_iPhase = PHASE_CLOSE;
|
||||||
return;
|
return;
|
||||||
|
@ -439,7 +357,7 @@ void DESC::Packet(const void * c_pvData, int iSize)
|
||||||
|
|
||||||
m_stRelayName.clear();
|
m_stRelayName.clear();
|
||||||
|
|
||||||
if (!packet_encode(m_lpOutputBuffer, c_pvData, iSize))
|
if (!RawPacket(c_pvData, iSize))
|
||||||
{
|
{
|
||||||
m_iPhase = PHASE_CLOSE;
|
m_iPhase = PHASE_CLOSE;
|
||||||
return;
|
return;
|
||||||
|
@ -447,81 +365,17 @@ void DESC::Packet(const void * c_pvData, int iSize)
|
||||||
}
|
}
|
||||||
else
|
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
|
// TRAFFIC_PROFILE
|
||||||
if (g_bTrafficProfileOn)
|
if (g_bTrafficProfileOn)
|
||||||
TrafficProfiler::instance().Report(TrafficProfiler::IODIR_OUTPUT, *(BYTE *) c_pvData, iSize);
|
TrafficProfiler::instance().Report(TrafficProfiler::IODIR_OUTPUT, *(BYTE *) c_pvData, iSize);
|
||||||
// END_OF_TRAFFIC_PROFILER
|
// END_OF_TRAFFIC_PROFILER
|
||||||
|
|
||||||
#ifdef _IMPROVED_PACKET_ENCRYPTION_
|
if (!RawPacket(c_pvData, iSize)) {
|
||||||
void* buf = buffer_write_peek(m_lpOutputBuffer);
|
|
||||||
|
|
||||||
|
|
||||||
if (packet_encode(m_lpOutputBuffer, c_pvData, iSize))
|
|
||||||
{
|
|
||||||
if (cipher_.activated()) {
|
|
||||||
cipher_.Encrypt(buf, iSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_iPhase = PHASE_CLOSE;
|
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);
|
//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)
|
void DESC::SetPhase(int _phase)
|
||||||
|
@ -550,24 +404,15 @@ void DESC::SetPhase(int _phase)
|
||||||
//MessengerManager::instance().Logout(GetAccountTable().login); // 의도적으로 break 안검
|
//MessengerManager::instance().Logout(GetAccountTable().login); // 의도적으로 break 안검
|
||||||
case PHASE_LOGIN:
|
case PHASE_LOGIN:
|
||||||
case PHASE_LOADING:
|
case PHASE_LOADING:
|
||||||
#ifndef _IMPROVED_PACKET_ENCRYPTION_
|
|
||||||
m_bEncrypted = true;
|
|
||||||
#endif
|
|
||||||
m_pInputProcessor = &m_inputLogin;
|
m_pInputProcessor = &m_inputLogin;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PHASE_GAME:
|
case PHASE_GAME:
|
||||||
case PHASE_DEAD:
|
case PHASE_DEAD:
|
||||||
#ifndef _IMPROVED_PACKET_ENCRYPTION_
|
|
||||||
m_bEncrypted = true;
|
|
||||||
#endif
|
|
||||||
m_pInputProcessor = &m_inputMain;
|
m_pInputProcessor = &m_inputMain;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PHASE_AUTH:
|
case PHASE_AUTH:
|
||||||
#ifndef _IMPROVED_PACKET_ENCRYPTION_
|
|
||||||
m_bEncrypted = true;
|
|
||||||
#endif
|
|
||||||
m_pInputProcessor = &m_inputAuth;
|
m_pInputProcessor = &m_inputAuth;
|
||||||
sys_log(0, "AUTH_PHASE %p", this);
|
sys_log(0, "AUTH_PHASE %p", this);
|
||||||
break;
|
break;
|
||||||
|
@ -618,7 +463,7 @@ void DESC::StartHandshake(DWORD _handshake)
|
||||||
m_iHandshakeRetry = 0;
|
m_iHandshakeRetry = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DESC::SendHandshake(DWORD dwCurTime, long lNewDelta)
|
void DESC::SendHandshake(DWORD dwCurTime, LONG lNewDelta)
|
||||||
{
|
{
|
||||||
TPacketGCHandshake pack;
|
TPacketGCHandshake pack;
|
||||||
|
|
||||||
|
@ -633,7 +478,7 @@ void DESC::SendHandshake(DWORD dwCurTime, long lNewDelta)
|
||||||
m_bHandshaking = true;
|
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();
|
DWORD dwCurTime = get_dword_time();
|
||||||
|
|
||||||
|
@ -663,7 +508,7 @@ bool DESC::HandshakeProcess(DWORD dwTime, long lDelta, bool bInfiniteRetry)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
long lNewDelta = (long) (dwCurTime - dwTime) / 2;
|
LONG lNewDelta = (LONG) (dwCurTime - dwTime) / 2;
|
||||||
|
|
||||||
if (lNewDelta < 0)
|
if (lNewDelta < 0)
|
||||||
{
|
{
|
||||||
|
@ -696,47 +541,6 @@ DWORD DESC::GetClientTime()
|
||||||
return m_dwClientTime;
|
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)
|
void DESC::SetRelay(const char * c_pszName)
|
||||||
{
|
{
|
||||||
m_stRelayName = c_pszName;
|
m_stRelayName = c_pszName;
|
||||||
|
@ -749,82 +553,13 @@ void DESC::BindCharacter(LPCHARACTER ch)
|
||||||
|
|
||||||
void DESC::FlushOutput()
|
void DESC::FlushOutput()
|
||||||
{
|
{
|
||||||
if (m_sock == INVALID_SOCKET) {
|
if (m_bufevent == nullptr)
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buffer_size(m_lpOutputBuffer) <= 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
struct timeval sleep_tv, now_tv, start_tv;
|
if (bufferevent_flush(m_bufevent, EV_WRITE, BEV_FLUSH) < 0)
|
||||||
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");
|
sys_log(0, "FLUSH FAIL");
|
||||||
|
else
|
||||||
|
sys_log(0, "FLUSH SUCCESS");
|
||||||
|
|
||||||
usleep(250000);
|
usleep(250000);
|
||||||
}
|
}
|
||||||
|
@ -948,18 +683,18 @@ void DESC::SendLoginSuccessPacket()
|
||||||
// //printf("STATE_CHECK PACKET PROCESSED.\n");
|
// //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_dwMatrixRows = rows;
|
||||||
m_dwMatrixCols = cols;
|
m_dwMatrixCols = cols;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long DESC::GetMatrixRows()
|
unsigned int DESC::GetMatrixRows()
|
||||||
{
|
{
|
||||||
return m_dwMatrixRows;
|
return m_dwMatrixRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long DESC::GetMatrixCols()
|
unsigned int DESC::GetMatrixCols()
|
||||||
{
|
{
|
||||||
return m_dwMatrixCols;
|
return m_dwMatrixCols;
|
||||||
}
|
}
|
||||||
|
@ -1013,23 +748,6 @@ const BYTE* GetKey_20050304Myevan()
|
||||||
return (const BYTE*)s_adwKey;
|
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)
|
void DESC::AssembleCRCMagicCube(BYTE bProcPiece, BYTE bFilePiece)
|
||||||
{
|
{
|
||||||
static BYTE abXORTable[32] =
|
static BYTE abXORTable[32] =
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#ifndef __INC_METIN_II_GAME_DESC_H__
|
#ifndef __INC_METIN_II_GAME_DESC_H__
|
||||||
#define __INC_METIN_II_GAME_DESC_H__
|
#define __INC_METIN_II_GAME_DESC_H__
|
||||||
|
|
||||||
|
#include <event2/event.h>
|
||||||
|
#include <event2/buffer.h>
|
||||||
|
#include <event2/bufferevent.h>
|
||||||
|
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#ifdef _IMPROVED_PACKET_ENCRYPTION_
|
|
||||||
#include "cipher.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MAX_ALLOW_USER 4096
|
#define MAX_ALLOW_USER 4096
|
||||||
//#define MAX_INPUT_LEN 2048
|
//#define MAX_INPUT_LEN 2048
|
||||||
|
@ -55,6 +56,10 @@ struct seq_t
|
||||||
typedef std::vector<seq_t> seq_vector_t;
|
typedef std::vector<seq_t> seq_vector_t;
|
||||||
// sequence 버그 찾기용 데이타
|
// 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
|
class DESC
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -78,28 +83,23 @@ class DESC
|
||||||
|
|
||||||
void FlushOutput();
|
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(); }
|
const char * GetHostName() { return m_stHost.c_str(); }
|
||||||
WORD GetPort() { return m_wPort; }
|
WORD GetPort() { return m_wPort; }
|
||||||
|
|
||||||
void SetP2P(const char * h, WORD w, BYTE b) { m_stP2PHost = h; m_wP2PPort = w; m_bP2PChannel = b; }
|
void SetP2P(WORD w, BYTE b) { m_wP2PPort = w; m_bP2PChannel = b; }
|
||||||
const char * GetP2PHost() { return m_stP2PHost.c_str(); }
|
|
||||||
WORD GetP2PPort() const { return m_wP2PPort; }
|
WORD GetP2PPort() const { return m_wP2PPort; }
|
||||||
BYTE GetP2PChannel() const { return m_bP2PChannel; }
|
BYTE GetP2PChannel() const { return m_bP2PChannel; }
|
||||||
|
|
||||||
void BufferedPacket(const void * c_pvData, int iSize);
|
bool RawPacket(const void * c_pvData, int iSize);
|
||||||
void Packet(const void * c_pvData, int iSize);
|
void Packet(const void * c_pvData, int iSize);
|
||||||
void LargePacket(const void * c_pvData, int iSize);
|
|
||||||
|
|
||||||
int ProcessInput(); // returns -1 if error
|
int ProcessInput(); // returns -1 if error
|
||||||
int ProcessOutput(); // returns -1 if error
|
|
||||||
|
|
||||||
CInputProcessor * GetInputProcessor() { return m_pInputProcessor; }
|
CInputProcessor * GetInputProcessor() { return m_pInputProcessor; }
|
||||||
|
|
||||||
DWORD GetHandle() const { return m_dwHandle; }
|
DWORD GetHandle() const { return m_dwHandle; }
|
||||||
LPBUFFER GetOutputBuffer() { return m_lpOutputBuffer; }
|
|
||||||
|
|
||||||
void BindAccountTable(TAccountTable * pTable);
|
void BindAccountTable(TAccountTable * pTable);
|
||||||
TAccountTable & GetAccountTable() { return m_accountTable; }
|
TAccountTable & GetAccountTable() { return m_accountTable; }
|
||||||
|
@ -109,31 +109,17 @@ class DESC
|
||||||
|
|
||||||
bool IsPhase(int phase) const { return m_iPhase == phase ? true : false; }
|
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 Log(const char * format, ...);
|
||||||
|
|
||||||
// 핸드쉐이크 (시간 동기화)
|
// 핸드쉐이크 (시간 동기화)
|
||||||
void StartHandshake(DWORD _dw);
|
void StartHandshake(DWORD _dw);
|
||||||
void SendHandshake(DWORD dwCurTime, long lNewDelta);
|
void SendHandshake(DWORD dwCurTime, LONG lNewDelta);
|
||||||
bool HandshakeProcess(DWORD dwTime, long lDelta, bool bInfiniteRetry=false);
|
bool HandshakeProcess(DWORD dwTime, LONG lDelta, bool bInfiniteRetry=false);
|
||||||
bool IsHandshaking();
|
bool IsHandshaking();
|
||||||
|
|
||||||
DWORD GetHandshake() const { return m_dwHandshake; }
|
DWORD GetHandshake() const { return m_dwHandshake; }
|
||||||
DWORD GetClientTime();
|
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();
|
BYTE GetEmpire();
|
||||||
|
|
||||||
|
@ -157,9 +143,9 @@ class DESC
|
||||||
void SetMatrixCode(const char * c_psz) { m_stMatrixCode = c_psz; }
|
void SetMatrixCode(const char * c_psz) { m_stMatrixCode = c_psz; }
|
||||||
const char * GetMatrixCode() { return m_stMatrixCode.c_str(); }
|
const char * GetMatrixCode() { return m_stMatrixCode.c_str(); }
|
||||||
|
|
||||||
void SetMatrixCardRowsAndColumns(unsigned long rows, unsigned long cols);
|
void SetMatrixCardRowsAndColumns(unsigned int rows, unsigned int cols);
|
||||||
unsigned long GetMatrixRows();
|
unsigned int GetMatrixRows();
|
||||||
unsigned long GetMatrixCols();
|
unsigned int GetMatrixCols();
|
||||||
bool CheckMatrixTryCount();
|
bool CheckMatrixTryCount();
|
||||||
|
|
||||||
void SetPanamaKey(DWORD dwKey) {m_dwPanamaKey = dwKey;}
|
void SetPanamaKey(DWORD dwKey) {m_dwPanamaKey = dwKey;}
|
||||||
|
@ -192,9 +178,8 @@ class DESC
|
||||||
CInputDead m_inputDead;
|
CInputDead m_inputDead;
|
||||||
CInputAuth m_inputAuth;
|
CInputAuth m_inputAuth;
|
||||||
|
|
||||||
|
event_base * m_evbase;
|
||||||
LPFDWATCH m_lpFdw;
|
bufferevent * m_bufevent;
|
||||||
socket_t m_sock;
|
|
||||||
int m_iPhase;
|
int m_iPhase;
|
||||||
DWORD m_dwHandle;
|
DWORD m_dwHandle;
|
||||||
|
|
||||||
|
@ -202,28 +187,19 @@ class DESC
|
||||||
WORD m_wPort;
|
WORD m_wPort;
|
||||||
time_t m_LastTryToConnectTime;
|
time_t m_LastTryToConnectTime;
|
||||||
|
|
||||||
LPBUFFER m_lpInputBuffer;
|
|
||||||
int m_iMinInputBufferLen;
|
|
||||||
|
|
||||||
DWORD m_dwHandshake;
|
DWORD m_dwHandshake;
|
||||||
DWORD m_dwHandshakeSentTime;
|
DWORD m_dwHandshakeSentTime;
|
||||||
int m_iHandshakeRetry;
|
int m_iHandshakeRetry;
|
||||||
DWORD m_dwClientTime;
|
DWORD m_dwClientTime;
|
||||||
bool m_bHandshaking;
|
bool m_bHandshaking;
|
||||||
|
|
||||||
LPBUFFER m_lpBufferedOutputBuffer;
|
|
||||||
LPBUFFER m_lpOutputBuffer;
|
|
||||||
|
|
||||||
LPEVENT m_pkPingEvent;
|
LPEVENT m_pkPingEvent;
|
||||||
LPCHARACTER m_lpCharacter;
|
LPCHARACTER m_lpCharacter;
|
||||||
TAccountTable m_accountTable;
|
TAccountTable m_accountTable;
|
||||||
|
|
||||||
struct sockaddr_in m_SockAddr;
|
|
||||||
|
|
||||||
FILE * m_pLogFile;
|
FILE * m_pLogFile;
|
||||||
std::string m_stRelayName;
|
std::string m_stRelayName;
|
||||||
|
|
||||||
std::string m_stP2PHost;
|
|
||||||
WORD m_wP2PPort;
|
WORD m_wP2PPort;
|
||||||
BYTE m_bP2PChannel;
|
BYTE m_bP2PChannel;
|
||||||
|
|
||||||
|
@ -256,15 +232,6 @@ class DESC
|
||||||
bool m_bDestroyed;
|
bool m_bDestroyed;
|
||||||
bool m_bChannelStatusRequested;
|
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:
|
public:
|
||||||
LPEVENT m_pkDisconnectEvent;
|
LPEVENT m_pkDisconnectEvent;
|
||||||
|
|
||||||
|
@ -286,7 +253,6 @@ class DESC
|
||||||
void SetOffTime( int offtime ) { m_offtime = offtime; }
|
void SetOffTime( int offtime ) { m_offtime = offtime; }
|
||||||
void SetPlayTime( int playtime ) { m_playtime = playtime; }
|
void SetPlayTime( int playtime ) { m_playtime = playtime; }
|
||||||
|
|
||||||
void RawPacket(const void * c_pvData, int iSize);
|
|
||||||
void ChatPacket(BYTE type, const char * format, ...);
|
void ChatPacket(BYTE type, const char * format, ...);
|
||||||
|
|
||||||
/* 시퀀스 버그 찾기용 코드 */
|
/* 시퀀스 버그 찾기용 코드 */
|
||||||
|
|
|
@ -9,16 +9,12 @@
|
||||||
#include "buffer_manager.h"
|
#include "buffer_manager.h"
|
||||||
#include "guild_manager.h"
|
#include "guild_manager.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
|
||||||
#include "party.h"
|
#include "party.h"
|
||||||
|
|
||||||
extern LPFDWATCH main_fdw;
|
|
||||||
|
|
||||||
LPCLIENT_DESC db_clientdesc = NULL;
|
LPCLIENT_DESC db_clientdesc = NULL;
|
||||||
LPCLIENT_DESC g_pkAuthMasterDesc = NULL;
|
LPCLIENT_DESC g_pkAuthMasterDesc = NULL;
|
||||||
LPCLIENT_DESC g_NetmarbleDBDesc = NULL;
|
LPCLIENT_DESC g_NetmarbleDBDesc = NULL;
|
||||||
LPCLIENT_DESC g_TeenDesc = NULL;
|
LPCLIENT_DESC g_TeenDesc = NULL;
|
||||||
LPCLIENT_DESC g_PasspodDesc = NULL;
|
|
||||||
|
|
||||||
static const char* GetKnownClientDescName(LPCLIENT_DESC desc) {
|
static const char* GetKnownClientDescName(LPCLIENT_DESC desc) {
|
||||||
if (desc == db_clientdesc) {
|
if (desc == db_clientdesc) {
|
||||||
|
@ -29,12 +25,32 @@ static const char* GetKnownClientDescName(LPCLIENT_DESC desc) {
|
||||||
return "g_NetmarbleDBDesc";
|
return "g_NetmarbleDBDesc";
|
||||||
} else if (desc == g_TeenDesc) {
|
} else if (desc == g_TeenDesc) {
|
||||||
return "g_TeenDesc";
|
return "g_TeenDesc";
|
||||||
} else if (desc == g_PasspodDesc) {
|
|
||||||
return "g_PasspodDesc";
|
|
||||||
}
|
}
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientDescEventHandler(bufferevent *bev, short events, void *ptr) {
|
||||||
|
auto * clientDesc = static_cast<LPCLIENT_DESC>(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<LPDESC>(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()
|
CLIENT_DESC::CLIENT_DESC()
|
||||||
{
|
{
|
||||||
m_iPhaseWhenSucceed = 0;
|
m_iPhaseWhenSucceed = 0;
|
||||||
|
@ -49,9 +65,8 @@ CLIENT_DESC::~CLIENT_DESC()
|
||||||
|
|
||||||
void CLIENT_DESC::Destroy()
|
void CLIENT_DESC::Destroy()
|
||||||
{
|
{
|
||||||
if (m_sock == INVALID_SOCKET) {
|
if (m_bufevent == nullptr)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
P2P_MANAGER::instance().UnregisterConnector(this);
|
P2P_MANAGER::instance().UnregisterConnector(this);
|
||||||
|
|
||||||
|
@ -63,12 +78,10 @@ void CLIENT_DESC::Destroy()
|
||||||
DBManager::instance().StopAllBilling();
|
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);
|
bufferevent_free(m_bufevent);
|
||||||
|
m_bufevent = nullptr;
|
||||||
socket_close(m_sock);
|
|
||||||
m_sock = INVALID_SOCKET;
|
|
||||||
|
|
||||||
// Chain up to base class Destroy()
|
// Chain up to base class Destroy()
|
||||||
DESC::Destroy();
|
DESC::Destroy();
|
||||||
|
@ -89,38 +102,41 @@ bool CLIENT_DESC::Connect(int iPhaseWhenSucceed)
|
||||||
|
|
||||||
m_LastTryToConnectTime = get_global_time();
|
m_LastTryToConnectTime = get_global_time();
|
||||||
|
|
||||||
if (m_sock != INVALID_SOCKET)
|
if (m_bufevent != nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
sys_log(0, "SYSTEM: Trying to connect to %s:%d", m_stHost.c_str(), m_wPort);
|
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!");
|
||||||
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (m_dnsBase == nullptr) {
|
||||||
|
sys_err("SYSTEM: DNS event base not set!");
|
||||||
|
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_evbase = base;
|
||||||
m_lpFdw = _fdw;
|
m_dnsBase = dns_base;
|
||||||
m_stHost = _host;
|
m_stHost = _host;
|
||||||
m_wPort = _port;
|
m_wPort = _port;
|
||||||
|
m_bufevent = nullptr;
|
||||||
InitializeBuffers();
|
|
||||||
|
|
||||||
m_sock = INVALID_SOCKET;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLIENT_DESC::SetPhase(int iPhase)
|
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.szSocialID, r.social_id, sizeof(pck.szSocialID));
|
||||||
strncpy(pck.szHost, d->GetHostName(), sizeof(pck.szHost));
|
strncpy(pck.szHost, d->GetHostName(), sizeof(pck.szHost));
|
||||||
pck.dwLoginKey = d->GetLoginKey();
|
pck.dwLoginKey = d->GetLoginKey();
|
||||||
#ifndef _IMPROVED_PACKET_ENCRYPTION_
|
|
||||||
memcpy(pck.adwClientKey, d->GetDecryptionKey(), 16);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
buf.write(&pck, sizeof(TPacketLoginOnSetup));
|
buf.write(&pck, sizeof(TPacketLoginOnSetup));
|
||||||
}
|
}
|
||||||
|
@ -224,13 +237,6 @@ void CLIENT_DESC::SetPhase(int iPhase)
|
||||||
|
|
||||||
case PHASE_P2P:
|
case PHASE_P2P:
|
||||||
sys_log(1, "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;
|
m_pInputProcessor = &m_inputP2P;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -250,33 +256,34 @@ void CLIENT_DESC::SetPhase(int iPhase)
|
||||||
|
|
||||||
void CLIENT_DESC::DBPacketHeader(BYTE bHeader, DWORD dwHandle, DWORD dwSize)
|
void CLIENT_DESC::DBPacketHeader(BYTE bHeader, DWORD dwHandle, DWORD dwSize)
|
||||||
{
|
{
|
||||||
buffer_write(m_lpOutputBuffer, encode_byte(bHeader), sizeof(BYTE));
|
DESC::RawPacket(encode_byte(bHeader), sizeof(BYTE));
|
||||||
buffer_write(m_lpOutputBuffer, encode_4bytes(dwHandle), sizeof(DWORD));
|
DESC::RawPacket(encode_4bytes(dwHandle), sizeof(DWORD));
|
||||||
buffer_write(m_lpOutputBuffer, encode_4bytes(dwSize), sizeof(DWORD));
|
DESC::RawPacket(encode_4bytes(dwSize), sizeof(DWORD));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLIENT_DESC::DBPacket(BYTE bHeader, DWORD dwHandle, const void * c_pvData, DWORD dwSize)
|
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",
|
sys_log(0, "CLIENT_DESC [%s] trying DBPacket() while not connected",
|
||||||
GetKnownClientDescName(this));
|
GetKnownClientDescName(this));
|
||||||
return;
|
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);
|
DBPacketHeader(bHeader, dwHandle, dwSize);
|
||||||
|
|
||||||
if (c_pvData)
|
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)
|
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",
|
sys_log(0, "CLIENT_DESC [%s] trying Packet() while not connected",
|
||||||
GetKnownClientDescName(this));
|
GetKnownClientDescName(this));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buffer_write(m_lpOutputBuffer, c_pvData, iSize);
|
|
||||||
|
DESC::RawPacket(c_pvData, iSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CLIENT_DESC::IsRetryWhenClosed()
|
bool CLIENT_DESC::IsRetryWhenClosed()
|
||||||
|
@ -316,7 +323,7 @@ void CLIENT_DESC::UpdateChannelStatus(DWORD t, bool fForce)
|
||||||
void CLIENT_DESC::Reset()
|
void CLIENT_DESC::Reset()
|
||||||
{
|
{
|
||||||
// Backup connection target info
|
// Backup connection target info
|
||||||
LPFDWATCH fdw = m_lpFdw;
|
event_base * evbase = m_evbase;
|
||||||
std::string host = m_stHost;
|
std::string host = m_stHost;
|
||||||
WORD port = m_wPort;
|
WORD port = m_wPort;
|
||||||
|
|
||||||
|
@ -324,16 +331,7 @@ void CLIENT_DESC::Reset()
|
||||||
Initialize();
|
Initialize();
|
||||||
|
|
||||||
// Restore connection target info
|
// Restore connection target info
|
||||||
m_lpFdw = fdw;
|
m_evbase = evbase;
|
||||||
m_stHost = host;
|
m_stHost = host;
|
||||||
m_wPort = port;
|
m_wPort = port;
|
||||||
|
|
||||||
InitializeBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CLIENT_DESC::InitializeBuffers()
|
|
||||||
{
|
|
||||||
m_lpOutputBuffer = buffer_new(1024 * 1024);
|
|
||||||
m_lpInputBuffer = buffer_new(1024 * 1024);
|
|
||||||
m_iMinInputBufferLen = 1024 * 1024;
|
|
||||||
}
|
}
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include "desc.h"
|
#include "desc.h"
|
||||||
|
|
||||||
|
#include <event2/event.h>
|
||||||
|
|
||||||
class CLIENT_DESC : public DESC
|
class CLIENT_DESC : public DESC
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -14,7 +16,8 @@ class CLIENT_DESC : public DESC
|
||||||
virtual void SetPhase(int phase);
|
virtual void SetPhase(int phase);
|
||||||
|
|
||||||
bool Connect(int iPhaseWhenSucceed = 0);
|
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);
|
void SetRetryWhenClosed(bool);
|
||||||
|
|
||||||
|
@ -29,10 +32,9 @@ class CLIENT_DESC : public DESC
|
||||||
// Non-destructive close for reuse
|
// Non-destructive close for reuse
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
private:
|
|
||||||
void InitializeBuffers();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
evdns_base * m_dnsBase;
|
||||||
|
|
||||||
int m_iPhaseWhenSucceed;
|
int m_iPhaseWhenSucceed;
|
||||||
bool m_bRetryWhenClosed;
|
bool m_bRetryWhenClosed;
|
||||||
time_t m_LastTryToConnectTime;
|
time_t m_LastTryToConnectTime;
|
||||||
|
@ -48,6 +50,5 @@ extern LPCLIENT_DESC db_clientdesc;
|
||||||
extern LPCLIENT_DESC g_pkAuthMasterDesc;
|
extern LPCLIENT_DESC g_pkAuthMasterDesc;
|
||||||
extern LPCLIENT_DESC g_NetmarbleDBDesc;
|
extern LPCLIENT_DESC g_NetmarbleDBDesc;
|
||||||
extern LPCLIENT_DESC g_TeenDesc;
|
extern LPCLIENT_DESC g_TeenDesc;
|
||||||
extern LPCLIENT_DESC g_PasspodDesc;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "messenger_manager.h"
|
#include "messenger_manager.h"
|
||||||
#include "p2p.h"
|
#include "p2p.h"
|
||||||
#include "ip_ban.h"
|
|
||||||
#include "dev_log.h"
|
#include "dev_log.h"
|
||||||
#include "ClientPackageCryptInfo.h"
|
#include "ClientPackageCryptInfo.h"
|
||||||
|
|
||||||
|
@ -146,46 +145,26 @@ RETRY:
|
||||||
return (crc);
|
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;
|
if (!IsValidIP(admin_ip, GetSocketHost(address).c_str())) // admin_ip 에 등록된 IP 는 최대 사용자 수에 구애받지 않는다.
|
||||||
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 (m_iSocketsConnected >= MAX_ALLOW_USER)
|
if (m_iSocketsConnected >= MAX_ALLOW_USER)
|
||||||
{
|
{
|
||||||
sys_err("max connection reached. MAX_ALLOW_USER = %d", MAX_ALLOW_USER);
|
sys_err("max connection reached. MAX_ALLOW_USER = %d", MAX_ALLOW_USER);
|
||||||
socket_close(desc);
|
return nullptr;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newd = M2_NEW DESC;
|
event_base *base = evconnlistener_get_base(listener);
|
||||||
|
|
||||||
|
// Create the peer
|
||||||
|
LPDESC newd = new DESC;
|
||||||
crc_t handshake = CreateHandshake();
|
crc_t handshake = CreateHandshake();
|
||||||
|
|
||||||
if (!newd->Setup(fdw, desc, peer, ++m_iHandleCount, handshake))
|
if(!newd->Setup(base, fd, address, ++m_iHandleCount, handshake)) {
|
||||||
{
|
delete newd;
|
||||||
socket_close(desc);
|
return nullptr;
|
||||||
M2_DELETE(newd);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_map_handshake.insert(DESC_HANDSHAKE_MAP::value_type(handshake, newd));
|
m_map_handshake.insert(DESC_HANDSHAKE_MAP::value_type(handshake, newd));
|
||||||
|
@ -196,31 +175,23 @@ LPDESC DESC_MANAGER::AcceptDesc(LPFDWATCH fdw, socket_t s)
|
||||||
return (newd);
|
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;
|
event_base *base = evconnlistener_get_base(listener);
|
||||||
struct sockaddr_in peer;
|
|
||||||
char host[MAX_HOST_LENGTH + 1];
|
|
||||||
|
|
||||||
if ((fd = socket_accept(bind_fd, &peer)) == -1)
|
LPDESC_P2P pkDesc = new DESC_P2P;
|
||||||
return NULL;
|
|
||||||
|
|
||||||
strncpy(host, inet_ntoa(peer.sin_addr), sizeof(host));
|
if (!pkDesc->Setup(base, fd, address))
|
||||||
|
|
||||||
LPDESC_P2P pkDesc = M2_NEW DESC_P2P;
|
|
||||||
|
|
||||||
if (!pkDesc->Setup(fdw, fd, host, peer.sin_port))
|
|
||||||
{
|
{
|
||||||
sys_err("DESC_MANAGER::AcceptP2PDesc : Setup failed");
|
sys_err("DESC_MANAGER::AcceptP2PDesc : Setup failed");
|
||||||
socket_close(fd);
|
delete pkDesc;
|
||||||
M2_DELETE(pkDesc);
|
return nullptr;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_set_pkDesc.insert(pkDesc);
|
m_set_pkDesc.insert(pkDesc);
|
||||||
++m_iSocketsConnected;
|
++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);
|
P2P_MANAGER::instance().RegisterAcceptor(pkDesc);
|
||||||
return (pkDesc);
|
return (pkDesc);
|
||||||
}
|
}
|
||||||
|
@ -334,13 +305,11 @@ LPDESC DESC_MANAGER::FindByCharacterName(const char *name)
|
||||||
return (it == m_set_pkDesc.end()) ? NULL : (*it);
|
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(base, dns_base, host, port);
|
||||||
|
|
||||||
newd->Setup(fdw, host, port);
|
|
||||||
newd->Connect(iPhaseWhenSucceed);
|
newd->Connect(iPhaseWhenSucceed);
|
||||||
newd->SetRetryWhenClosed(bRetryWhenClosed);
|
newd->SetRetryWhenClosed(bRetryWhenClosed);
|
||||||
|
|
||||||
|
@ -373,7 +342,7 @@ bool DESC_MANAGER::IsP2PDescExist(const char * szHost, WORD wPort)
|
||||||
{
|
{
|
||||||
LPCLIENT_DESC d = *(it++);
|
LPCLIENT_DESC d = *(it++);
|
||||||
|
|
||||||
if (!strcmp(d->GetP2PHost(), szHost) && d->GetP2PPort() == wPort)
|
if (!strcmp(d->GetHostName(), szHost) && d->GetP2PPort() == wPort)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
#include <common/length.h>
|
#include <common/length.h>
|
||||||
#include "IFileMonitor.h"
|
#include "IFileMonitor.h"
|
||||||
|
|
||||||
|
#include <event2/event.h>
|
||||||
|
#include <event2/bufferevent.h>
|
||||||
|
#include <event2/listener.h>
|
||||||
|
|
||||||
class CLoginKey;
|
class CLoginKey;
|
||||||
class CClientPackageCryptInfo;
|
class CClientPackageCryptInfo;
|
||||||
|
|
||||||
|
@ -28,13 +32,13 @@ class DESC_MANAGER : public singleton<DESC_MANAGER>
|
||||||
void Initialize();
|
void Initialize();
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
|
||||||
LPDESC AcceptDesc(LPFDWATCH fdw, socket_t s);
|
LPDESC AcceptDesc(evconnlistener* listener, evutil_socket_t fd, sockaddr* address);
|
||||||
LPDESC AcceptP2PDesc(LPFDWATCH fdw, socket_t s);
|
LPDESC AcceptP2PDesc(evconnlistener* listener, evutil_socket_t fd, sockaddr* address);
|
||||||
void DestroyDesc(LPDESC d, bool erase_from_set = true);
|
void DestroyDesc(LPDESC d, bool erase_from_set = true);
|
||||||
|
|
||||||
DWORD CreateHandshake();
|
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();
|
void TryConnect();
|
||||||
|
|
||||||
LPDESC FindByHandle(DWORD handle);
|
LPDESC FindByHandle(DWORD handle);
|
||||||
|
|
|
@ -9,43 +9,41 @@ DESC_P2P::~DESC_P2P()
|
||||||
|
|
||||||
void DESC_P2P::Destroy()
|
void DESC_P2P::Destroy()
|
||||||
{
|
{
|
||||||
if (m_sock == INVALID_SOCKET) {
|
if (m_bufevent == nullptr)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
P2P_MANAGER::instance().UnregisterAcceptor(this);
|
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);
|
bufferevent_free(m_bufevent);
|
||||||
|
m_bufevent = nullptr;
|
||||||
socket_close(m_sock);
|
|
||||||
m_sock = INVALID_SOCKET;
|
|
||||||
|
|
||||||
// Chain up to base class Destroy()
|
// Chain up to base class Destroy()
|
||||||
DESC::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_bufevent = bufferevent_socket_new(evbase, fd, BEV_OPT_CLOSE_ON_FREE);
|
||||||
m_stHost = host;
|
if (m_bufevent == nullptr) {
|
||||||
m_wPort = wPort;
|
sys_err("DESC::Setup : Could not set up bufferevent!");
|
||||||
m_sock = fd;
|
|
||||||
|
|
||||||
if (!(m_lpOutputBuffer = buffer_new(1024 * 1024)))
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(m_lpInputBuffer = buffer_new(1024 * 1024)))
|
// Set the event handlers for this peer
|
||||||
return false;
|
bufferevent_setcb(m_bufevent, DescReadHandler, DescWriteHandler, DescEventHandler, (LPDESC) this);
|
||||||
|
|
||||||
fdwatch_add_fd(m_lpFdw, m_sock, this, FDW_READ, false);
|
// Enable the events
|
||||||
|
bufferevent_enable(m_bufevent, EV_READ|EV_WRITE);
|
||||||
|
|
||||||
m_iMinInputBufferLen = 1024 * 1024;
|
m_stHost = GetSocketHost(c_rSockAddr);
|
||||||
|
m_wPort = GetSocketPort(c_rSockAddr);
|
||||||
|
|
||||||
SetPhase(PHASE_P2P);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,13 +55,6 @@ void DESC_P2P::SetPhase(int iPhase)
|
||||||
{
|
{
|
||||||
case PHASE_P2P:
|
case PHASE_P2P:
|
||||||
sys_log(1, "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;
|
m_pInputProcessor = &s_inputP2P;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,6 @@ class DESC_P2P : public DESC
|
||||||
|
|
||||||
virtual void Destroy();
|
virtual void Destroy();
|
||||||
virtual void SetPhase(int iPhase);
|
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "questmanager.h"
|
#include "questmanager.h"
|
||||||
|
|
||||||
CDungeon::CDungeon(IdType id, long lOriginalMapIndex, long lMapIndex)
|
CDungeon::CDungeon(IdType id, int lOriginalMapIndex, int lMapIndex)
|
||||||
: m_id(id),
|
: m_id(id),
|
||||||
m_lOrigMapIndex(lOriginalMapIndex),
|
m_lOrigMapIndex(lOriginalMapIndex),
|
||||||
m_lMapIndex(lMapIndex),
|
m_lMapIndex(lMapIndex),
|
||||||
|
@ -86,7 +86,7 @@ int CDungeon::GetFlag(std::string name)
|
||||||
|
|
||||||
struct FSendDestPosition
|
struct FSendDestPosition
|
||||||
{
|
{
|
||||||
FSendDestPosition(long x, long y)
|
FSendDestPosition(int x, int y)
|
||||||
{
|
{
|
||||||
p1.bHeader = HEADER_GC_DUNGEON;
|
p1.bHeader = HEADER_GC_DUNGEON;
|
||||||
p1.subheader = DUNGEON_SUBHEADER_GC_DESTINATION_POSITION;
|
p1.subheader = DUNGEON_SUBHEADER_GC_DESTINATION_POSITION;
|
||||||
|
@ -97,7 +97,7 @@ struct FSendDestPosition
|
||||||
|
|
||||||
void operator()(LPCHARACTER ch)
|
void operator()(LPCHARACTER ch)
|
||||||
{
|
{
|
||||||
ch->GetDesc()->BufferedPacket(&p1, sizeof(TPacketGCDungeon));
|
ch->GetDesc()->RawPacket(&p1, sizeof(TPacketGCDungeon));
|
||||||
ch->GetDesc()->Packet(&p2, sizeof(TPacketGCDungeonDestPosition));
|
ch->GetDesc()->Packet(&p2, sizeof(TPacketGCDungeonDestPosition));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ struct FSendDestPosition
|
||||||
TPacketGCDungeonDestPosition p2;
|
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())
|
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
|
struct FWarpToDungeon
|
||||||
{
|
{
|
||||||
FWarpToDungeon(long lMapIndex, LPDUNGEON d)
|
FWarpToDungeon(int lMapIndex, LPDUNGEON d)
|
||||||
: m_lMapIndex(lMapIndex), m_pkDungeon(d)
|
: m_lMapIndex(lMapIndex), m_pkDungeon(d)
|
||||||
{
|
{
|
||||||
LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(lMapIndex);
|
LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(lMapIndex);
|
||||||
|
@ -134,9 +134,9 @@ struct FWarpToDungeon
|
||||||
//m_pkDungeon->IncPartyMember(ch->GetParty());
|
//m_pkDungeon->IncPartyMember(ch->GetParty());
|
||||||
}
|
}
|
||||||
|
|
||||||
long m_lMapIndex;
|
int m_lMapIndex;
|
||||||
long m_x;
|
int m_x;
|
||||||
long m_y;
|
int m_y;
|
||||||
LPDUNGEON m_pkDungeon;
|
LPDUNGEON m_pkDungeon;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -265,10 +265,10 @@ void CDungeon::DecPartyMember(LPPARTY pParty, LPCHARACTER ch)
|
||||||
|
|
||||||
struct FWarpToPosition
|
struct FWarpToPosition
|
||||||
{
|
{
|
||||||
long lMapIndex;
|
int lMapIndex;
|
||||||
long x;
|
int x;
|
||||||
long y;
|
int y;
|
||||||
FWarpToPosition(long lMapIndex, long x, long y)
|
FWarpToPosition(int lMapIndex, int x, int y)
|
||||||
: lMapIndex(lMapIndex), x(x), y(y)
|
: lMapIndex(lMapIndex), x(x), y(y)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -295,10 +295,10 @@ struct FWarpToPosition
|
||||||
|
|
||||||
struct FWarpToPositionForce
|
struct FWarpToPositionForce
|
||||||
{
|
{
|
||||||
long lMapIndex;
|
int lMapIndex;
|
||||||
long x;
|
int x;
|
||||||
long y;
|
int y;
|
||||||
FWarpToPositionForce(long lMapIndex, long x, long y)
|
FWarpToPositionForce(int lMapIndex, int x, int y)
|
||||||
: lMapIndex(lMapIndex), x(x), y(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;
|
x *= 100;
|
||||||
y *= 100;
|
y *= 100;
|
||||||
|
@ -334,7 +334,7 @@ void CDungeon::JumpAll(long lFromMapIndex, int x, int y)
|
||||||
pMap->for_each(f);
|
pMap->for_each(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDungeon::WarpAll(long lFromMapIndex, int x, int y)
|
void CDungeon::WarpAll(int lFromMapIndex, int x, int y)
|
||||||
{
|
{
|
||||||
x *= 100;
|
x *= 100;
|
||||||
y *= 100;
|
y *= 100;
|
||||||
|
@ -353,7 +353,7 @@ void CDungeon::WarpAll(long lFromMapIndex, int x, int y)
|
||||||
pMap->for_each(f);
|
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;
|
x *= 100;
|
||||||
y *= 100;
|
y *= 100;
|
||||||
|
@ -400,7 +400,7 @@ void CDungeonManager::Destroy(CDungeon::IdType dungeon_id)
|
||||||
}
|
}
|
||||||
m_map_pkDungeon.erase(dungeon_id);
|
m_map_pkDungeon.erase(dungeon_id);
|
||||||
|
|
||||||
long lMapIndex = pDungeon->m_lMapIndex;
|
int lMapIndex = pDungeon->m_lMapIndex;
|
||||||
m_map_pkMapDungeon.erase(lMapIndex);
|
m_map_pkMapDungeon.erase(lMapIndex);
|
||||||
|
|
||||||
DWORD server_timer_arg = lMapIndex;
|
DWORD server_timer_arg = lMapIndex;
|
||||||
|
@ -418,7 +418,7 @@ LPDUNGEON CDungeonManager::Find(CDungeon::IdType dungeon_id)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPDUNGEON CDungeonManager::FindByMapIndex(long lMapIndex)
|
LPDUNGEON CDungeonManager::FindByMapIndex(int lMapIndex)
|
||||||
{
|
{
|
||||||
itertype(m_map_pkMapDungeon) it = m_map_pkMapDungeon.find(lMapIndex);
|
itertype(m_map_pkMapDungeon) it = m_map_pkMapDungeon.find(lMapIndex);
|
||||||
if (it != m_map_pkMapDungeon.end()) {
|
if (it != m_map_pkMapDungeon.end()) {
|
||||||
|
@ -427,7 +427,7 @@ LPDUNGEON CDungeonManager::FindByMapIndex(long lMapIndex)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LPDUNGEON CDungeonManager::Create(long lOriginalMapIndex)
|
LPDUNGEON CDungeonManager::Create(int lOriginalMapIndex)
|
||||||
{
|
{
|
||||||
DWORD lMapIndex = SECTREE_MANAGER::instance().CreatePrivateMap(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;
|
const int MOB_GOTO_VNUM = 20039;
|
||||||
|
|
||||||
|
@ -799,14 +799,14 @@ void CDungeon::SpawnGotoMob(long lFromX, long lFromY, long lToX, long lToY)
|
||||||
if (ch)
|
if (ch)
|
||||||
{
|
{
|
||||||
char buf[30+1];
|
char buf[30+1];
|
||||||
snprintf(buf, sizeof(buf), ". %ld %ld", lToX, lToY);
|
snprintf(buf, sizeof(buf), ". %d %d", lToX, lToY);
|
||||||
|
|
||||||
ch->SetName(buf);
|
ch->SetName(buf);
|
||||||
ch->SetDungeon(this);
|
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);
|
LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(m_lMapIndex);
|
||||||
if (pkSectreeMap == NULL) {
|
if (pkSectreeMap == NULL) {
|
||||||
|
@ -1241,14 +1241,14 @@ void CDungeon::CheckEliminated()
|
||||||
sys_log(0, "CheckEliminated: none");
|
sys_log(0, "CheckEliminated: none");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDungeon::SetExitAllAtEliminate(long time)
|
void CDungeon::SetExitAllAtEliminate(int time)
|
||||||
{
|
{
|
||||||
sys_log(0, "SetExitAllAtEliminate: time %d", time);
|
sys_log(0, "SetExitAllAtEliminate: time %d", time);
|
||||||
m_bExitAllAtEliminate = true;
|
m_bExitAllAtEliminate = true;
|
||||||
m_iWarpDelay = time;
|
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_bWarpAtEliminate = true;
|
||||||
m_iWarpDelay = time;
|
m_iWarpDelay = time;
|
||||||
|
@ -1298,12 +1298,12 @@ void CDungeon::JumpToEliminateLocation()
|
||||||
|
|
||||||
struct FNearPosition
|
struct FNearPosition
|
||||||
{
|
{
|
||||||
long x;
|
int x;
|
||||||
long y;
|
int y;
|
||||||
int dist;
|
int dist;
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
FNearPosition(long x, long y, int d) :
|
FNearPosition(int x, int y, int d) :
|
||||||
x(x), y(y), dist(d), ret(true)
|
x(x), y(y), dist(d), ret(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,15 +52,15 @@ class CDungeon
|
||||||
void UsePotion(LPCHARACTER ch);
|
void UsePotion(LPCHARACTER ch);
|
||||||
void UseRevive(LPCHARACTER ch);
|
void UseRevive(LPCHARACTER ch);
|
||||||
|
|
||||||
long GetMapIndex() { return m_lMapIndex; }
|
int GetMapIndex() { return m_lMapIndex; }
|
||||||
|
|
||||||
void Spawn(DWORD vnum, const char* pos);
|
void Spawn(DWORD vnum, const char* pos);
|
||||||
LPCHARACTER SpawnMob(DWORD vnum, int x, int y, int dir = 0);
|
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 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 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 SpawnRegen(const char* filename, bool bOnce = true);
|
||||||
void AddRegen(LPREGEN regen);
|
void AddRegen(LPREGEN regen);
|
||||||
|
@ -85,23 +85,23 @@ class CDungeon
|
||||||
void UniqueSetHP(const std::string& key, int iHP);
|
void UniqueSetHP(const std::string& key, int iHP);
|
||||||
void UniqueSetDefGrade(const std::string& key, int iGrade);
|
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 CheckEliminated();
|
||||||
|
|
||||||
void JumpAll(long lFromMapIndex, int x, int y);
|
void JumpAll(int lFromMapIndex, int x, int y);
|
||||||
void WarpAll(long lFromMapIndex, int x, int y);
|
void WarpAll(int lFromMapIndex, int x, int y);
|
||||||
void JumpParty(LPPARTY pParty, long lFromMapIndex, int x, int y);
|
void JumpParty(LPPARTY pParty, int lFromMapIndex, int x, int y);
|
||||||
|
|
||||||
void ExitAll();
|
void ExitAll();
|
||||||
void ExitAllToStartPosition();
|
void ExitAllToStartPosition();
|
||||||
void JumpToEliminateLocation();
|
void JumpToEliminateLocation();
|
||||||
void SetExitAllAtEliminate(long time);
|
void SetExitAllAtEliminate(int time);
|
||||||
void SetWarpAtEliminate(long time, long lMapIndex, int x, int y, const char* regen_file);
|
void SetWarpAtEliminate(int time, int lMapIndex, int x, int y, const char* regen_file);
|
||||||
|
|
||||||
int GetFlag(std::string name);
|
int GetFlag(std::string name);
|
||||||
void SetFlag(std::string name, int value);
|
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로 구성.
|
// item group은 item_vnum과 item_count로 구성.
|
||||||
typedef std::vector <std::pair <DWORD, int> > ItemGroup;
|
typedef std::vector <std::pair <DWORD, int> > ItemGroup;
|
||||||
|
@ -114,7 +114,7 @@ class CDungeon
|
||||||
bool IsAllPCNearTo( int x, int y, int dist );
|
bool IsAllPCNearTo( int x, int y, int dist );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CDungeon(IdType id, long lOriginalMapIndex, long lMapIndex);
|
CDungeon(IdType id, int lOriginalMapIndex, int lMapIndex);
|
||||||
|
|
||||||
void Initialize();
|
void Initialize();
|
||||||
void CheckDestroy();
|
void CheckDestroy();
|
||||||
|
@ -144,9 +144,9 @@ class CDungeon
|
||||||
|
|
||||||
// 적 전멸시 워프하는 위치
|
// 적 전멸시 워프하는 위치
|
||||||
int m_iWarpDelay;
|
int m_iWarpDelay;
|
||||||
long m_lWarpMapIndex;
|
int m_lWarpMapIndex;
|
||||||
long m_lWarpX;
|
int m_lWarpX;
|
||||||
long m_lWarpY;
|
int m_lWarpY;
|
||||||
std::string m_stRegenFile;
|
std::string m_stRegenFile;
|
||||||
|
|
||||||
std::vector<LPREGEN> m_regen;
|
std::vector<LPREGEN> m_regen;
|
||||||
|
@ -175,16 +175,16 @@ class CDungeon
|
||||||
class CDungeonManager : public singleton<CDungeonManager>
|
class CDungeonManager : public singleton<CDungeonManager>
|
||||||
{
|
{
|
||||||
typedef std::map<CDungeon::IdType, LPDUNGEON> TDungeonMap;
|
typedef std::map<CDungeon::IdType, LPDUNGEON> TDungeonMap;
|
||||||
typedef std::map<long, LPDUNGEON> TMapDungeon;
|
typedef std::map<int, LPDUNGEON> TMapDungeon;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CDungeonManager();
|
CDungeonManager();
|
||||||
virtual ~CDungeonManager();
|
virtual ~CDungeonManager();
|
||||||
|
|
||||||
LPDUNGEON Create(long lOriginalMapIndex);
|
LPDUNGEON Create(int lOriginalMapIndex);
|
||||||
void Destroy(CDungeon::IdType dungeon_id);
|
void Destroy(CDungeon::IdType dungeon_id);
|
||||||
LPDUNGEON Find(CDungeon::IdType dungeon_id);
|
LPDUNGEON Find(CDungeon::IdType dungeon_id);
|
||||||
LPDUNGEON FindByMapIndex(long lMapIndex);
|
LPDUNGEON FindByMapIndex(int lMapIndex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TDungeonMap m_map_pkDungeon;
|
TDungeonMap m_map_pkDungeon;
|
||||||
|
|
|
@ -32,12 +32,12 @@ class CEntity
|
||||||
|
|
||||||
int GetViewAge() const { return m_iViewAge; }
|
int GetViewAge() const { return m_iViewAge; }
|
||||||
|
|
||||||
long GetX() const { return m_pos.x; }
|
int GetX() const { return m_pos.x; }
|
||||||
long GetY() const { return m_pos.y; }
|
int GetY() const { return m_pos.y; }
|
||||||
long GetZ() const { return m_pos.z; }
|
int GetZ() const { return m_pos.z; }
|
||||||
const PIXEL_POSITION & GetXYZ() const { return m_pos; }
|
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; }
|
void SetXYZ(const PIXEL_POSITION & pos) { m_pos = pos; }
|
||||||
|
|
||||||
LPSECTREE GetSectree() const { return m_pSectree; }
|
LPSECTREE GetSectree() const { return m_pSectree; }
|
||||||
|
@ -50,8 +50,8 @@ class CEntity
|
||||||
void BindDesc(LPDESC _d) { m_lpDesc = _d; }
|
void BindDesc(LPDESC _d) { m_lpDesc = _d; }
|
||||||
LPDESC GetDesc() const { return m_lpDesc; }
|
LPDESC GetDesc() const { return m_lpDesc; }
|
||||||
|
|
||||||
void SetMapIndex(long l) { m_lMapIndex = l; }
|
void SetMapIndex(int l) { m_lMapIndex = l; }
|
||||||
long GetMapIndex() const { return m_lMapIndex; }
|
int GetMapIndex() const { return m_lMapIndex; }
|
||||||
|
|
||||||
void SetObserverMode(bool bFlag);
|
void SetObserverMode(bool bFlag);
|
||||||
bool IsObserverMode() const { return m_bIsObserver; }
|
bool IsObserverMode() const { return m_bIsObserver; }
|
||||||
|
@ -60,7 +60,7 @@ class CEntity
|
||||||
bool m_bIsObserver;
|
bool m_bIsObserver;
|
||||||
bool m_bObserverModeChange;
|
bool m_bObserverModeChange;
|
||||||
ENTITY_MAP m_map_view;
|
ENTITY_MAP m_map_view;
|
||||||
long m_lMapIndex;
|
int m_lMapIndex;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LPDESC m_lpDesc;
|
LPDESC m_lpDesc;
|
||||||
|
|
|
@ -19,7 +19,7 @@ static ObjectPool<EVENT> event_pool;
|
||||||
static CEventQueue cxx_q;
|
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;
|
LPEVENT new_event = NULL;
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ void event_cancel(LPEVENT * ppevent)
|
||||||
*ppevent = NULL;
|
*ppevent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void event_reset_time(LPEVENT event, long when)
|
void event_reset_time(LPEVENT event, int when)
|
||||||
{
|
{
|
||||||
if (!event->is_processing)
|
if (!event->is_processing)
|
||||||
{
|
{
|
||||||
|
@ -101,7 +101,7 @@ void event_reset_time(LPEVENT event, long when)
|
||||||
/* 이벤트를 실행할 시간에 도달한 이벤트들을 실행한다 */
|
/* 이벤트를 실행할 시간에 도달한 이벤트들을 실행한다 */
|
||||||
int event_process(int pulse)
|
int event_process(int pulse)
|
||||||
{
|
{
|
||||||
long new_time;
|
int new_time;
|
||||||
int num_events = 0;
|
int num_events = 0;
|
||||||
|
|
||||||
// event_q 즉 이벤트 큐의 헤드의 시간보다 현재의 pulse 가 적으면 루프문이
|
// event_q 즉 이벤트 큐의 헤드의 시간보다 현재의 pulse 가 적으면 루프문이
|
||||||
|
@ -119,7 +119,7 @@ int event_process(int pulse)
|
||||||
new_time = pElem->iKey;
|
new_time = pElem->iKey;
|
||||||
|
|
||||||
LPEVENT the_event = pElem->pvData;
|
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);
|
cxx_q.Delete(pElem);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -157,9 +157,9 @@ int event_process(int pulse)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 이벤트가 수행시간을 pulse 단위로 리턴해 준다 */
|
/* 이벤트가 수행시간을 pulse 단위로 리턴해 준다 */
|
||||||
long event_processing_time(LPEVENT event)
|
int event_processing_time(LPEVENT event)
|
||||||
{
|
{
|
||||||
long start_time;
|
int start_time;
|
||||||
|
|
||||||
if (!event->q_el)
|
if (!event->q_el)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -169,9 +169,9 @@ long event_processing_time(LPEVENT event)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 이벤트가 남은 시간을 pulse 단위로 리턴해 준다 */
|
/* 이벤트가 남은 시간을 pulse 단위로 리턴해 준다 */
|
||||||
long event_time(LPEVENT event)
|
int event_time(LPEVENT event)
|
||||||
{
|
{
|
||||||
long when;
|
int when;
|
||||||
|
|
||||||
if (!event->q_el)
|
if (!event->q_el)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -35,9 +35,9 @@ private:
|
||||||
|
|
||||||
typedef struct event EVENT;
|
typedef struct event EVENT;
|
||||||
typedef boost::intrusive_ptr<EVENT> LPEVENT;
|
typedef boost::intrusive_ptr<EVENT> 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
|
#define EVENTINFO(name) struct name : public event_info_data
|
||||||
|
|
||||||
struct TQueueElement;
|
struct TQueueElement;
|
||||||
|
@ -80,11 +80,11 @@ extern int event_process(int pulse);
|
||||||
extern int event_count();
|
extern int event_count();
|
||||||
|
|
||||||
#define event_create(func, info, when) event_create_ex(func, info, when)
|
#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 void event_cancel(LPEVENT * event); // À̺¥Æ® Ãë¼Ò
|
||||||
extern long event_processing_time(LPEVENT event); // 수행 시간 리턴
|
extern int event_processing_time(LPEVENT event); // 수행 시간 리턴
|
||||||
extern long event_time(LPEVENT event); // 남은 시간 리턴
|
extern int event_time(LPEVENT event); // 남은 시간 리턴
|
||||||
extern void event_reset_time(LPEVENT event, long when); // 실행 시간 재 설정
|
extern void event_reset_time(LPEVENT event, int when); // 실행 시간 재 설정
|
||||||
extern void event_set_verbose(int level);
|
extern void event_set_verbose(int level);
|
||||||
|
|
||||||
extern event_info_data* FindEventInfo(DWORD dwID);
|
extern event_info_data* FindEventInfo(DWORD dwID);
|
||||||
|
|
|
@ -241,7 +241,7 @@ bool CExchange::RemoveItem(BYTE pos)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CExchange::AddGold(long gold)
|
bool CExchange::AddGold(int gold)
|
||||||
{
|
{
|
||||||
if (gold <= 0)
|
if (gold <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -546,7 +546,7 @@ bool CExchange::Accept(bool bAccept)
|
||||||
goto EXCHANGE_END;
|
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.");
|
sys_err("Cannot use exchange feature while DB cache connection is dead.");
|
||||||
victim->ChatPacket(CHAT_TYPE_INFO, "Unknown error");
|
victim->ChatPacket(CHAT_TYPE_INFO, "Unknown error");
|
||||||
|
|
|
@ -18,7 +18,7 @@ class CExchange
|
||||||
bool Accept(bool bIsAccept = true);
|
bool Accept(bool bIsAccept = true);
|
||||||
void Cancel();
|
void Cancel();
|
||||||
|
|
||||||
bool AddGold(long lGold);
|
bool AddGold(int lGold);
|
||||||
bool AddItem(TItemPos item_pos, BYTE display_pos);
|
bool AddItem(TItemPos item_pos, BYTE display_pos);
|
||||||
bool RemoveItem(BYTE pos);
|
bool RemoveItem(BYTE pos);
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class CExchange
|
||||||
BYTE m_abItemDisplayPos[EXCHANGE_ITEM_MAX_NUM];
|
BYTE m_abItemDisplayPos[EXCHANGE_ITEM_MAX_NUM];
|
||||||
|
|
||||||
bool m_bAccept;
|
bool m_bAccept;
|
||||||
long m_lGold;
|
int m_lGold;
|
||||||
|
|
||||||
CGrid * m_pGrid;
|
CGrid * m_pGrid;
|
||||||
|
|
||||||
|
|
|
@ -602,7 +602,7 @@ void Take(fishing_event_info* info, LPCHARACTER ch)
|
||||||
{
|
{
|
||||||
if (info->step == 1) // 고기가 걸린 상태면..
|
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;
|
DWORD item_vnum = 0;
|
||||||
int ret = Compute(info->fish_id, ms, &item_vnum, GetFishingLevel(ch));
|
int ret = Compute(info->fish_id, ms, &item_vnum, GetFishingLevel(ch));
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,8 @@ namespace
|
||||||
|
|
||||||
if (d)
|
if (d)
|
||||||
{
|
{
|
||||||
d->BufferedPacket(&p, sizeof(p));
|
d->RawPacket(&p, sizeof(p));
|
||||||
d->BufferedPacket(&id, sizeof(id));
|
d->RawPacket(&id, sizeof(id));
|
||||||
d->Packet(name, GUILD_NAME_MAX_LEN);
|
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 guild_name %s", m_data.name);
|
||||||
sys_log(0, "GMC master %d", m_data.master_pid);
|
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));
|
d->Packet(&pack_sub, sizeof(TPacketGCGuildInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -953,7 +953,7 @@ bool CGuild::OfferExp(LPCHARACTER ch, int amount)
|
||||||
{
|
{
|
||||||
pack.subheader = GUILD_SUBHEADER_GC_LIST;
|
pack.subheader = GUILD_SUBHEADER_GC_LIST;
|
||||||
pack.size = sizeof(pack) + 13;
|
pack.size = sizeof(pack) + 13;
|
||||||
d->BufferedPacket(&pack, sizeof(pack));
|
d->RawPacket(&pack, sizeof(pack));
|
||||||
d->Packet(&(cit->second), sizeof(DWORD) * 3 + 1);
|
d->Packet(&(cit->second), sizeof(DWORD) * 3 + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1067,8 +1067,8 @@ void CGuild::RefreshCommentForce(DWORD player_id)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pack.size += (sizeof(DWORD)+CHARACTER_NAME_MAX_LEN+1+GUILD_COMMENT_MAX_LEN+1)*(WORD)count;
|
pack.size += (sizeof(DWORD)+CHARACTER_NAME_MAX_LEN+1+GUILD_COMMENT_MAX_LEN+1)*(WORD)count;
|
||||||
d->BufferedPacket(&pack,sizeof(pack));
|
d->RawPacket(&pack, sizeof(pack));
|
||||||
d->BufferedPacket(&count, 1);
|
d->RawPacket(&count, 1);
|
||||||
char szName[CHARACTER_NAME_MAX_LEN + 1];
|
char szName[CHARACTER_NAME_MAX_LEN + 1];
|
||||||
char szContent[GUILD_COMMENT_MAX_LEN + 1];
|
char szContent[GUILD_COMMENT_MAX_LEN + 1];
|
||||||
memset(szName, 0, sizeof(szName));
|
memset(szName, 0, sizeof(szName));
|
||||||
|
@ -1082,13 +1082,13 @@ void CGuild::RefreshCommentForce(DWORD player_id)
|
||||||
strncpy(szName, row[1], sizeof(szName));
|
strncpy(szName, row[1], sizeof(szName));
|
||||||
strncpy(szContent, row[2], sizeof(szContent));
|
strncpy(szContent, row[2], sizeof(szContent));
|
||||||
|
|
||||||
d->BufferedPacket(&id, sizeof(id));
|
d->RawPacket(&id, sizeof(id));
|
||||||
d->BufferedPacket(szName, sizeof(szName));
|
d->RawPacket(szName, sizeof(szName));
|
||||||
|
|
||||||
if (i == pmsg->Get()->uiNumRows - 1)
|
if (i == pmsg->Get()->uiNumRows - 1)
|
||||||
d->Packet(szContent, sizeof(szContent)); // ¸¶Áö¸· ÁÙÀÌ¸é º¸³»±â
|
d->Packet(szContent, sizeof(szContent)); // ¸¶Áö¸· ÁÙÀÌ¸é º¸³»±â
|
||||||
else
|
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)
|
if (!d)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
d->BufferedPacket(&pack, sizeof(pack));
|
d->RawPacket(&pack, sizeof(pack));
|
||||||
d->BufferedPacket(&pid, sizeof(pid));
|
d->RawPacket(&pid, sizeof(pid));
|
||||||
d->Packet(&is_general, sizeof(is_general));
|
d->Packet(&is_general, sizeof(is_general));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1164,8 +1164,8 @@ void CGuild::ChangeMemberGrade(DWORD pid, BYTE grade)
|
||||||
if (!d)
|
if (!d)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
d->BufferedPacket(&pack, sizeof(pack));
|
d->RawPacket(&pack, sizeof(pack));
|
||||||
d->BufferedPacket(&pid, sizeof(pid));
|
d->RawPacket(&pid, sizeof(pid));
|
||||||
d->Packet(&grade, sizeof(grade));
|
d->Packet(&grade, sizeof(grade));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1400,10 +1400,10 @@ void CGuild::SendSkillInfoPacket(LPCHARACTER ch) const
|
||||||
pack.size = sizeof(pack) + 6 + GUILD_SKILL_COUNT;
|
pack.size = sizeof(pack) + 6 + GUILD_SKILL_COUNT;
|
||||||
pack.subheader = GUILD_SUBHEADER_GC_SKILL_INFO;
|
pack.subheader = GUILD_SUBHEADER_GC_SKILL_INFO;
|
||||||
|
|
||||||
d->BufferedPacket(&pack, sizeof(pack));
|
d->RawPacket(&pack, sizeof(pack));
|
||||||
d->BufferedPacket(&m_data.skill_point, 1);
|
d->RawPacket(&m_data.skill_point, 1);
|
||||||
d->BufferedPacket(&m_data.abySkill, GUILD_SKILL_COUNT);
|
d->RawPacket(&m_data.abySkill, GUILD_SKILL_COUNT);
|
||||||
d->BufferedPacket(&m_data.power, 2);
|
d->RawPacket(&m_data.power, 2);
|
||||||
d->Packet(&m_data.max_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.subheader = GUILD_SUBHEADER_GC_LIST;
|
||||||
pack.size = sizeof(pack) + 13;
|
pack.size = sizeof(pack) + 13;
|
||||||
d->BufferedPacket(&pack, sizeof(pack));
|
d->RawPacket(&pack, sizeof(pack));
|
||||||
d->Packet(&(cit->second), sizeof(DWORD) * 3 + 1);
|
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.subheader = GUILD_SUBHEADER_GC_LIST;
|
||||||
pack.size = sizeof(pack) + 13;
|
pack.size = sizeof(pack) + 13;
|
||||||
d->BufferedPacket(&pack, sizeof(pack));
|
d->RawPacket(&pack, sizeof(pack));
|
||||||
d->Packet(&(cit->second), sizeof(DWORD) * 3 + 1);
|
d->Packet(&(cit->second), sizeof(DWORD) * 3 + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1871,7 +1871,7 @@ void CGuild::RecvMoneyChange(int iGold)
|
||||||
{
|
{
|
||||||
LPCHARACTER ch = *it;
|
LPCHARACTER ch = *it;
|
||||||
LPDESC d = ch->GetDesc();
|
LPDESC d = ch->GetDesc();
|
||||||
d->BufferedPacket(&p, sizeof(p));
|
d->RawPacket(&p, sizeof(p));
|
||||||
d->Packet(&iGold, sizeof(int));
|
d->Packet(&iGold, sizeof(int));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,7 +281,7 @@ class CGuild
|
||||||
DWORD UnderAnyWar(BYTE bType = GUILD_WAR_TYPE_MAX_NUM);
|
DWORD UnderAnyWar(BYTE bType = GUILD_WAR_TYPE_MAX_NUM);
|
||||||
|
|
||||||
// War map relative
|
// War map relative
|
||||||
void SetGuildWarMapIndex(DWORD dwGuildID, long lMapIndex);
|
void SetGuildWarMapIndex(DWORD dwGuildID, int lMapIndex);
|
||||||
int GetGuildWarType(DWORD dwGuildOpponent);
|
int GetGuildWarType(DWORD dwGuildOpponent);
|
||||||
DWORD GetGuildWarMapIndex(DWORD dwGuildOpponent);
|
DWORD GetGuildWarMapIndex(DWORD dwGuildOpponent);
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@ namespace
|
||||||
|
|
||||||
if (d)
|
if (d)
|
||||||
{
|
{
|
||||||
d->BufferedPacket(&p, sizeof(p));
|
d->RawPacket(&p, sizeof(p));
|
||||||
d->BufferedPacket(&id, sizeof(id));
|
d->RawPacket(&id, sizeof(id));
|
||||||
d->Packet(name, GUILD_NAME_MAX_LEN);
|
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));
|
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 * g1 = TouchGuild(dwGuild1);
|
||||||
CGuild * g2 = TouchGuild(dwGuild2);
|
CGuild * g2 = TouchGuild(dwGuild2);
|
||||||
|
@ -602,8 +602,8 @@ struct FSendWarList
|
||||||
|
|
||||||
if (d)
|
if (d)
|
||||||
{
|
{
|
||||||
d->BufferedPacket(&p, sizeof(p));
|
d->RawPacket(&p, sizeof(p));
|
||||||
d->BufferedPacket(&gid1, sizeof(DWORD));
|
d->RawPacket(&gid1, sizeof(DWORD));
|
||||||
d->Packet(&gid2, sizeof(DWORD));
|
d->Packet(&gid2, sizeof(DWORD));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ class CGuildManager : public singleton<CGuildManager>
|
||||||
|
|
||||||
void RequestEndWar(DWORD guild_id1, DWORD guild_id2);
|
void RequestEndWar(DWORD guild_id1, DWORD guild_id2);
|
||||||
void RequestCancelWar(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 DeclareWar(DWORD guild_id1, DWORD guild_id2, BYTE bType);
|
||||||
void RefuseWar(DWORD guild_id1, DWORD guild_id2);
|
void RefuseWar(DWORD guild_id1, DWORD guild_id2);
|
||||||
|
|
|
@ -51,7 +51,7 @@ void CGuild::GuildWarPacket(DWORD dwOppGID, BYTE bWarType, BYTE bWarState)
|
||||||
{
|
{
|
||||||
ch->SendGuildName( dwOppGID );
|
ch->SendGuildName( dwOppGID );
|
||||||
|
|
||||||
d->BufferedPacket(&pack, sizeof(pack));
|
d->RawPacket(&pack, sizeof(pack));
|
||||||
d->Packet(&pack2, sizeof(pack2));
|
d->Packet(&pack2, sizeof(pack2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ void CGuild::SendEnemyGuild(LPCHARACTER ch)
|
||||||
TPacketGCGuild p;
|
TPacketGCGuild p;
|
||||||
p.header = HEADER_GC_GUILD;
|
p.header = HEADER_GC_GUILD;
|
||||||
p.subheader = GUILD_SUBHEADER_GC_WAR_SCORE;
|
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)
|
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.bType = it->second.type;
|
||||||
pack2.bWarState = it->second.state;
|
pack2.bWarState = it->second.state;
|
||||||
|
|
||||||
d->BufferedPacket(&pack, sizeof(pack));
|
d->RawPacket(&pack, sizeof(pack));
|
||||||
d->Packet(&pack2, sizeof(pack2));
|
d->Packet(&pack2, sizeof(pack2));
|
||||||
|
|
||||||
if (it->second.state == GUILD_WAR_ON_WAR)
|
if (it->second.state == GUILD_WAR_ON_WAR)
|
||||||
{
|
{
|
||||||
long lScore;
|
int lScore;
|
||||||
|
|
||||||
lScore = GetWarScoreAgainstTo(pack2.dwGuildOpp);
|
lScore = GetWarScoreAgainstTo(pack2.dwGuildOpp);
|
||||||
|
|
||||||
d->BufferedPacket(&p, sizeof(p));
|
d->RawPacket(&p, sizeof(p));
|
||||||
d->BufferedPacket(&pack2.dwGuildSelf, sizeof(DWORD));
|
d->RawPacket(&pack2.dwGuildSelf, sizeof(DWORD));
|
||||||
d->BufferedPacket(&pack2.dwGuildOpp, sizeof(DWORD));
|
d->RawPacket(&pack2.dwGuildOpp, sizeof(DWORD));
|
||||||
d->Packet(&lScore, sizeof(long));
|
d->Packet(&lScore, sizeof(int));
|
||||||
|
|
||||||
lScore = CGuildManager::instance().TouchGuild(pack2.dwGuildOpp)->GetWarScoreAgainstTo(pack2.dwGuildSelf);
|
lScore = CGuildManager::instance().TouchGuild(pack2.dwGuildOpp)->GetWarScoreAgainstTo(pack2.dwGuildSelf);
|
||||||
|
|
||||||
d->BufferedPacket(&p, sizeof(p));
|
d->RawPacket(&p, sizeof(p));
|
||||||
d->BufferedPacket(&pack2.dwGuildOpp, sizeof(DWORD));
|
d->RawPacket(&pack2.dwGuildOpp, sizeof(DWORD));
|
||||||
d->BufferedPacket(&pack2.dwGuildSelf, sizeof(DWORD));
|
d->RawPacket(&pack2.dwGuildSelf, sizeof(DWORD));
|
||||||
d->Packet(&lScore, sizeof(long));
|
d->Packet(&lScore, sizeof(int));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,14 +201,14 @@ void CGuild::SetWarScoreAgainstTo(DWORD dwOppGID, int iScore)
|
||||||
|
|
||||||
p.header = HEADER_GC_GUILD;
|
p.header = HEADER_GC_GUILD;
|
||||||
p.subheader = GUILD_SUBHEADER_GC_WAR_SCORE;
|
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;
|
TEMP_BUFFER buf;
|
||||||
buf.write(&p, sizeof(p));
|
buf.write(&p, sizeof(p));
|
||||||
|
|
||||||
buf.write(&dwSelfGID, sizeof(DWORD));
|
buf.write(&dwSelfGID, sizeof(DWORD));
|
||||||
buf.write(&dwOppGID, sizeof(DWORD));
|
buf.write(&dwOppGID, sizeof(DWORD));
|
||||||
buf.write(&iScore, sizeof(long));
|
buf.write(&iScore, sizeof(int));
|
||||||
|
|
||||||
Packet(buf.read_peek(), buf.size());
|
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);
|
itertype(m_EnemyGuild) it = m_EnemyGuild.find(dwOppGID);
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include "dev_log.h"
|
#include "dev_log.h"
|
||||||
|
|
||||||
extern time_t get_global_time();
|
extern time_t get_global_time();
|
||||||
extern bool g_bNoPasspod;
|
|
||||||
|
|
||||||
bool IsEmptyAdminPage()
|
bool IsEmptyAdminPage()
|
||||||
{
|
{
|
||||||
|
@ -78,8 +77,8 @@ bool CInputProcessor::Process(LPDESC lpDesc, const void * c_pvOrig, int iBytes,
|
||||||
iPacketLen = 1;
|
iPacketLen = 1;
|
||||||
else if (!m_pPacketInfo->Get(bHeader, &iPacketLen, &c_pszName))
|
else if (!m_pPacketInfo->Get(bHeader, &iPacketLen, &c_pszName))
|
||||||
{
|
{
|
||||||
sys_err("UNKNOWN HEADER: %d, LAST HEADER: %d(%d), REMAIN BYTES: %d, fd: %d",
|
sys_err("UNKNOWN HEADER: %d, LAST HEADER: %d(%d), REMAIN BYTES: %d",
|
||||||
bHeader, bLastHeader, iLastPacketLen, m_iBufferLeft, lpDesc->GetSocket());
|
bHeader, bLastHeader, iLastPacketLen, m_iBufferLeft);
|
||||||
//printdata((BYTE *) c_pvOrig, m_iBufferLeft);
|
//printdata((BYTE *) c_pvOrig, m_iBufferLeft);
|
||||||
lpDesc->SetPhase(PHASE_CLOSE);
|
lpDesc->SetPhase(PHASE_CLOSE);
|
||||||
return true;
|
return true;
|
||||||
|
@ -183,7 +182,7 @@ void CInputProcessor::Handshake(LPDESC d, const char * c_pData)
|
||||||
|
|
||||||
if (d->GetHandshake() != p->dwHandshake)
|
if (d->GetHandshake() != p->dwHandshake)
|
||||||
{
|
{
|
||||||
sys_err("Invalid Handshake on %d", d->GetSocket());
|
sys_err("Invalid Handshake");
|
||||||
d->SetPhase(PHASE_CLOSE);
|
d->SetPhase(PHASE_CLOSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -192,14 +191,10 @@ void CInputProcessor::Handshake(LPDESC d, const char * c_pData)
|
||||||
{
|
{
|
||||||
if (d->HandshakeProcess(p->dwTime, p->lDelta, false))
|
if (d->HandshakeProcess(p->dwTime, p->lDelta, false))
|
||||||
{
|
{
|
||||||
#ifdef _IMPROVED_PACKET_ENCRYPTION_
|
|
||||||
d->SendKeyAgreement();
|
|
||||||
#else
|
|
||||||
if (g_bAuthServer)
|
if (g_bAuthServer)
|
||||||
d->SetPhase(PHASE_AUTH);
|
d->SetPhase(PHASE_AUTH);
|
||||||
else
|
else
|
||||||
d->SetPhase(PHASE_LOGIN);
|
d->SetPhase(PHASE_LOGIN);
|
||||||
#endif // #ifdef _IMPROVED_PACKET_ENCRYPTION_
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -286,22 +281,15 @@ int CInputHandshake::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
||||||
else
|
else
|
||||||
stResult = "YES";
|
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.compare("SHOWMETHEMONEY"))
|
||||||
else if (stBuf == g_stAdminPagePassword)
|
else if (stBuf == g_stAdminPagePassword)
|
||||||
{
|
{
|
||||||
if (!IsEmptyAdminPage())
|
if (!IsEmptyAdminPage())
|
||||||
{
|
{
|
||||||
if (!IsAdminPage(inet_ntoa(d->GetAddr().sin_addr)))
|
if (!IsAdminPage(d->GetHostName()))
|
||||||
{
|
{
|
||||||
char szTmp[64];
|
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;
|
stResult += szTmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -322,9 +310,9 @@ int CInputHandshake::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
||||||
|
|
||||||
if (!IsEmptyAdminPage())
|
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
|
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());
|
LogManager::instance().CharLog(0, 0, 0, 1, "NOTICE", msg.c_str(), d->GetHostName());
|
||||||
BroadcastNotice(msg.c_str());
|
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"))
|
else if (!stBuf.compare("SHUTDOWN"))
|
||||||
{
|
{
|
||||||
LogManager::instance().CharLog(0, 0, 0, 2, "SHUTDOWN", "", d->GetHostName());
|
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::istringstream is(stBuf);
|
||||||
std::string strEvent, strFlagName;
|
std::string strEvent, strFlagName;
|
||||||
long lValue;
|
int lValue;
|
||||||
is >> strEvent >> strFlagName >> lValue;
|
is >> strEvent >> strFlagName >> lValue;
|
||||||
|
|
||||||
if (!is.fail())
|
if (!is.fail())
|
||||||
|
@ -522,7 +500,7 @@ dev_log(LOG_DEB0, "DC : '%s'", msg.c_str());
|
||||||
{
|
{
|
||||||
std::istringstream is(stBuf);
|
std::istringstream is(stBuf);
|
||||||
std::string strBlockChat, strCharName;
|
std::string strBlockChat, strCharName;
|
||||||
long lDuration;
|
int lDuration;
|
||||||
is >> strBlockChat >> strCharName >> lDuration;
|
is >> strBlockChat >> strCharName >> lDuration;
|
||||||
|
|
||||||
if (!is.fail())
|
if (!is.fail())
|
||||||
|
@ -620,38 +598,8 @@ dev_log(LOG_DEB0, "DC : '%s'", msg.c_str());
|
||||||
Pong(d);
|
Pong(d);
|
||||||
else if (bHeader == HEADER_CG_HANDSHAKE)
|
else if (bHeader == HEADER_CG_HANDSHAKE)
|
||||||
Handshake(d, c_pData);
|
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
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -345,8 +345,6 @@ class CInputAuth : public CInputProcessor
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void Login(LPDESC d, const char * c_pData);
|
void Login(LPDESC d, const char * c_pData);
|
||||||
void PasspodAnswer(LPDESC d, const char * c_pData );
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CInputTeen : public CInputProcessor
|
class CInputTeen : public CInputProcessor
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include "desc_manager.h"
|
#include "desc_manager.h"
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "matrix_card.h"
|
#include "matrix_card.h"
|
||||||
#include "passpod.h"
|
|
||||||
#include "locale_service.h"
|
#include "locale_service.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
|
||||||
|
@ -107,8 +106,7 @@ void CInputAuth::Login(LPDESC d, const char * c_pData)
|
||||||
|
|
||||||
if (!g_bAuthServer)
|
if (!g_bAuthServer)
|
||||||
{
|
{
|
||||||
sys_err ("CInputAuth class is not for game server. IP %s might be a hacker.",
|
sys_err ("CInputAuth class is not for game server. IP %s might be a hacker.", d->GetHostName());
|
||||||
inet_ntoa(d->GetAddr().sin_addr));
|
|
||||||
d->DelayedDisconnect(5);
|
d->DelayedDisconnect(5);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -206,8 +204,7 @@ int CInputAuth::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
||||||
|
|
||||||
if (!g_bAuthServer)
|
if (!g_bAuthServer)
|
||||||
{
|
{
|
||||||
sys_err ("CInputAuth class is not for game server. IP %s might be a hacker.",
|
sys_err ("CInputAuth class is not for game server. IP %s might be a hacker.", d->GetHostName());
|
||||||
inet_ntoa(d->GetAddr().sin_addr));
|
|
||||||
d->DelayedDisconnect(5);
|
d->DelayedDisconnect(5);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -227,10 +224,6 @@ int CInputAuth::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
||||||
Login(d, c_pData);
|
Login(d, c_pData);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HEADER_CG_PASSPOD_ANSWER:
|
|
||||||
PasspodAnswer(d, c_pData);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HEADER_CG_HANDSHAKE:
|
case HEADER_CG_HANDSHAKE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -241,54 +234,3 @@ int CInputAuth::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
||||||
|
|
||||||
return iExtraLen;
|
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);
|
|
||||||
}
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ bool GetServerLocation(TAccountTable & rTab, BYTE bEmpire)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bFound = true;
|
bFound = true;
|
||||||
long lIndex = 0;
|
int lIndex = 0;
|
||||||
|
|
||||||
if (!CMapLocation::instance().Get(rTab.players[i].x,
|
if (!CMapLocation::instance().Get(rTab.players[i].x,
|
||||||
rTab.players[i].y,
|
rTab.players[i].y,
|
||||||
|
@ -206,7 +206,7 @@ void CInputDB::PlayerCreateSuccess(LPDESC d, const char * data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long lIndex = 0;
|
int lIndex = 0;
|
||||||
|
|
||||||
if (!CMapLocation::instance().Get(pPacketDB->player.x,
|
if (!CMapLocation::instance().Get(pPacketDB->player.x,
|
||||||
pPacketDB->player.y,
|
pPacketDB->player.y,
|
||||||
|
@ -288,7 +288,7 @@ void CInputDB::PlayerDeleteSuccess(LPDESC d, const char * data)
|
||||||
|
|
||||||
BYTE account_index;
|
BYTE account_index;
|
||||||
account_index = decode_byte(data);
|
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->Packet(encode_byte(account_index), 1);
|
||||||
|
|
||||||
d->GetAccountTable().players[account_index].dwID = 0;
|
d->GetAccountTable().players[account_index].dwID = 0;
|
||||||
|
@ -341,7 +341,7 @@ void CInputDB::PlayerLoad(LPDESC d, const char * data)
|
||||||
if (!d)
|
if (!d)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
long lMapIndex = pTab->lMapIndex;
|
int lMapIndex = pTab->lMapIndex;
|
||||||
PIXEL_POSITION pos;
|
PIXEL_POSITION pos;
|
||||||
|
|
||||||
if (lMapIndex == 0)
|
if (lMapIndex == 0)
|
||||||
|
@ -414,8 +414,8 @@ void CInputDB::PlayerLoad(LPDESC d, const char * data)
|
||||||
P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGLogin));
|
P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGLogin));
|
||||||
|
|
||||||
char buf[51];
|
char buf[51];
|
||||||
snprintf(buf, sizeof(buf), "%s %d %d %ld %d",
|
snprintf(buf, sizeof(buf), "%s %d %d %d %d",
|
||||||
inet_ntoa(ch->GetDesc()->GetAddr().sin_addr), ch->GetGold(), g_bChannel, ch->GetMapIndex(), ch->GetAlignment());
|
ch->GetDesc()->GetHostName(), ch->GetGold(), g_bChannel, ch->GetMapIndex(), ch->GetAlignment());
|
||||||
LogManager::instance().CharLog(ch, 0, "LOGIN", buf);
|
LogManager::instance().CharLog(ch, 0, "LOGIN", buf);
|
||||||
|
|
||||||
if (LC_IsYMIR() || LC_IsKorea() || LC_IsBrazil() || LC_IsJapan())
|
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);
|
d->SetPhase(PHASE_LOADING);
|
||||||
ch->MainCharacterPacket();
|
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
|
//Send Supplementary Data Block if new map requires security packages in loading this map
|
||||||
const TMapRegion * rMapRgn = SECTREE_MANAGER::instance().GetMapRegion(lPublicMapIndex);
|
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)
|
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;
|
TPacketDGP2P * p = (TPacketDGP2P *) c_pData;
|
||||||
|
|
||||||
|
@ -1336,9 +1337,9 @@ void CInputDB::P2P(const char * c_pData)
|
||||||
{
|
{
|
||||||
LPCLIENT_DESC pkDesc = NULL;
|
LPCLIENT_DESC pkDesc = NULL;
|
||||||
sys_log(0, "InputDB:P2P %s:%u", p->szHost, p->wPort);
|
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);
|
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)
|
if (Analyze(d, bHeader, pRealData) < 0)
|
||||||
{
|
{
|
||||||
sys_err("in InputDB: UNKNOWN HEADER: %d, LAST HEADER: %d(%d), REMAIN BYTES: %d, DESC: %d",
|
sys_err("in InputDB: UNKNOWN HEADER: %d, LAST HEADER: %d(%d), REMAIN BYTES: %d",
|
||||||
bHeader, bLastHeader, iLastPacketLen, m_iBufferLeft, d->GetSocket());
|
bHeader, bLastHeader, iLastPacketLen, m_iBufferLeft);
|
||||||
|
|
||||||
//printdata((BYTE*) orig, bytes);
|
//printdata((BYTE*) orig, bytes);
|
||||||
//d->SetPhase(PHASE_CLOSE);
|
//d->SetPhase(PHASE_CLOSE);
|
||||||
|
@ -2650,10 +2651,10 @@ void CInputDB::RespondChannelStatus(LPDESC desc, const char* pcData)
|
||||||
pcData += sizeof(nSize);
|
pcData += sizeof(nSize);
|
||||||
|
|
||||||
BYTE bHeader = HEADER_GC_RESPOND_CHANNELSTATUS;
|
BYTE bHeader = HEADER_GC_RESPOND_CHANNELSTATUS;
|
||||||
desc->BufferedPacket(&bHeader, sizeof(BYTE));
|
desc->RawPacket(&bHeader, sizeof(BYTE));
|
||||||
desc->BufferedPacket(&nSize, sizeof(nSize));
|
desc->RawPacket(&nSize, sizeof(nSize));
|
||||||
if (0 < nSize) {
|
if (0 < nSize) {
|
||||||
desc->BufferedPacket(pcData, sizeof(TChannelStatus)*nSize);
|
desc->RawPacket(pcData, sizeof(TChannelStatus) * nSize);
|
||||||
}
|
}
|
||||||
BYTE bSuccess = 1;
|
BYTE bSuccess = 1;
|
||||||
desc->Packet(&bSuccess, sizeof(bSuccess));
|
desc->Packet(&bSuccess, sizeof(bSuccess));
|
||||||
|
|
|
@ -188,9 +188,6 @@ void CInputLogin::LoginByKey(LPDESC d, const char * data)
|
||||||
sys_log(0, "LOGIN_BY_KEY: %s key %u", login, pinfo->dwLoginKey);
|
sys_log(0, "LOGIN_BY_KEY: %s key %u", login, pinfo->dwLoginKey);
|
||||||
|
|
||||||
d->SetLoginKey(pinfo->dwLoginKey);
|
d->SetLoginKey(pinfo->dwLoginKey);
|
||||||
#ifndef _IMPROVED_PACKET_ENCRYPTION_
|
|
||||||
d->SetSecurityKey(pinfo->adwClientKey);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TPacketGDLoginByKey ptod;
|
TPacketGDLoginByKey ptod;
|
||||||
|
|
||||||
|
@ -774,7 +771,7 @@ void CInputLogin::Entergame(LPDESC d, const char * data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// û¼Ò³â º¸È£
|
// û¼Ò³â º¸È£
|
||||||
if (g_TeenDesc) // BufferedPacket »ç¿ë ±ÝÁö
|
if (g_TeenDesc) // RawPacket 사용 금지
|
||||||
{
|
{
|
||||||
TPacketGTLogin p;
|
TPacketGTLogin p;
|
||||||
|
|
||||||
|
@ -896,7 +893,7 @@ void CInputLogin::GuildSymbolCRC(LPDESC d, const char* c_pData)
|
||||||
GCPacket.size = sizeof(GCPacket) + pkGS->raw.size();
|
GCPacket.size = sizeof(GCPacket) + pkGS->raw.size();
|
||||||
GCPacket.guild_id = CGPacket.guild_id;
|
GCPacket.guild_id = CGPacket.guild_id;
|
||||||
|
|
||||||
d->BufferedPacket(&GCPacket, sizeof(GCPacket));
|
d->RawPacket(&GCPacket, sizeof(GCPacket));
|
||||||
d->Packet(&pkGS->raw[0], pkGS->raw.size());
|
d->Packet(&pkGS->raw[0], pkGS->raw.size());
|
||||||
|
|
||||||
sys_log(0, "SendGuildSymbolHead %02X%02X%02X%02X Size %d",
|
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)
|
if (buf)
|
||||||
{
|
{
|
||||||
d->BufferedPacket(&p, sizeof(p));
|
d->RawPacket(&p, sizeof(p));
|
||||||
d->LargePacket(buf, bufSize);
|
d->Packet(buf, bufSize);
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1001,8 +998,8 @@ void CInputLogin::GuildMarkCRCList(LPDESC d, const char* c_pData)
|
||||||
|
|
||||||
if (buf.size() > 0)
|
if (buf.size() > 0)
|
||||||
{
|
{
|
||||||
d->BufferedPacket(&pGC, sizeof(TPacketGCMarkBlock));
|
d->RawPacket(&pGC, sizeof(TPacketGCMarkBlock));
|
||||||
d->LargePacket(buf.read_peek(), buf.size());
|
d->Packet(buf.read_peek(), buf.size());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
d->Packet(&pGC, sizeof(TPacketGCMarkBlock));
|
d->Packet(&pGC, sizeof(TPacketGCMarkBlock));
|
||||||
|
|
|
@ -56,10 +56,10 @@ void SendBlockChatInfo(LPCHARACTER ch, int sec)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long hour = sec / 3600;
|
int hour = sec / 3600;
|
||||||
sec -= hour * 3600;
|
sec -= hour * 3600;
|
||||||
|
|
||||||
long min = (sec / 60);
|
int min = (sec / 60);
|
||||||
sec -= min * 60;
|
sec -= min * 60;
|
||||||
|
|
||||||
char buf[128+1];
|
char buf[128+1];
|
||||||
|
@ -464,7 +464,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes)
|
||||||
pack.wSize = sizeof(TPacketGCWhisper) + len;
|
pack.wSize = sizeof(TPacketGCWhisper) + len;
|
||||||
strncpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom));
|
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);
|
ch->GetDesc()->Packet(buf, len);
|
||||||
|
|
||||||
sys_log(0, "WHISPER: not enough %s: char: %s", pTable->szLocaleName, ch->GetName());
|
sys_log(0, "WHISPER: not enough %s: char: %s", pTable->szLocaleName, ch->GetName());
|
||||||
|
@ -553,7 +553,7 @@ struct FEmpireChatPacket
|
||||||
if (d->GetCharacter()->GetMapIndex() != iMapIndex)
|
if (d->GetCharacter()->GetMapIndex() != iMapIndex)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
d->BufferedPacket(&p, sizeof(packet_chat));
|
d->RawPacket(&p, sizeof(packet_chat));
|
||||||
|
|
||||||
if (d->GetEmpire() == bEmpire ||
|
if (d->GetEmpire() == bEmpire ||
|
||||||
bEmpire == 0 ||
|
bEmpire == 0 ||
|
||||||
|
@ -624,14 +624,14 @@ struct FYmirChatPacket
|
||||||
{
|
{
|
||||||
packet.size = m_len_orig_msg + sizeof(TPacketGCChat);
|
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);
|
d->Packet(m_orig_msg, m_len_orig_msg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
packet.size = m_len_conv_msg + sizeof(TPacketGCChat);
|
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);
|
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 );
|
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();
|
const timeval &tvLastSyncTime = victim->GetLastSyncTime();
|
||||||
timeval *tvDiff = timediff(&tvCurTime, &tvLastSyncTime);
|
timeval *tvDiff = timediff(&tvCurTime, &tvLastSyncTime);
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,7 @@ void CInputP2P::Setup(LPDESC d, const char * c_pData)
|
||||||
{
|
{
|
||||||
TPacketGGSetup * p = (TPacketGGSetup *) c_pData;
|
TPacketGGSetup * p = (TPacketGGSetup *) c_pData;
|
||||||
sys_log(0, "P2P: Setup %s:%d", d->GetHostName(), p->wPort);
|
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)
|
void CInputP2P::MessengerAdd(const char * c_pData)
|
||||||
|
|
|
@ -1,372 +0,0 @@
|
||||||
//#define __MAIN__
|
|
||||||
#ifdef __MAIN__
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
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<char*>(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<int, std::vector<IP> > 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<IP> v;
|
|
||||||
v.push_back(ip);
|
|
||||||
mapBanIP.insert(std::map<DWORD, std::vector<IP> >::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<IP> & v)
|
|
||||||
{
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
bool found;
|
|
||||||
vector<IP>::iterator it1;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
vector<IP> o;
|
|
||||||
it1 = v.begin();
|
|
||||||
|
|
||||||
while (it1 != v.end())
|
|
||||||
{
|
|
||||||
IP & ip1 = *(it1++);
|
|
||||||
|
|
||||||
found = false;
|
|
||||||
|
|
||||||
if (it1 != v.end())
|
|
||||||
{
|
|
||||||
vector<IP>::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<IP> & v)
|
|
||||||
{
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
bool found;
|
|
||||||
vector<IP>::iterator it1;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
vector<IP> o;
|
|
||||||
it1 = v.begin();
|
|
||||||
|
|
||||||
while (it1 != v.end())
|
|
||||||
{
|
|
||||||
IP & ip1 = *(it1++);
|
|
||||||
|
|
||||||
found = false;
|
|
||||||
|
|
||||||
vector<IP>::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 <filename>\n", *argv);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
argc--, argv++;
|
|
||||||
|
|
||||||
FILE * fp = fopen(*argv, "r");
|
|
||||||
|
|
||||||
if (!fp)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
vector<IP> 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<IP>::iterator it = v.begin();
|
|
||||||
|
|
||||||
while (it != v.end())
|
|
||||||
(*(it++)).Print();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -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
|
|
|
@ -192,12 +192,12 @@ void CItem::UsePacketEncode(LPCHARACTER ch, LPCHARACTER victim, struct packet_it
|
||||||
packet->vnum = GetVnum();
|
packet->vnum = GetVnum();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CItem::RemoveFlag(long bit)
|
void CItem::RemoveFlag(int bit)
|
||||||
{
|
{
|
||||||
REMOVE_BIT(m_lFlag, bit);
|
REMOVE_BIT(m_lFlag, bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CItem::AddFlag(long bit)
|
void CItem::AddFlag(int bit)
|
||||||
{
|
{
|
||||||
SET_BIT(m_lFlag, bit);
|
SET_BIT(m_lFlag, bit);
|
||||||
}
|
}
|
||||||
|
@ -389,7 +389,7 @@ LPITEM CItem::RemoveFromGround()
|
||||||
return (this);
|
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)
|
if (0 == lMapIndex)
|
||||||
{
|
{
|
||||||
|
@ -638,7 +638,7 @@ void CItem::ModifyPoints(bool bAdd)
|
||||||
if (m_pProto->aApplies[i].bType == APPLY_NONE)
|
if (m_pProto->aApplies[i].bType == APPLY_NONE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
long value = m_pProto->aApplies[i].lValue;
|
int value = m_pProto->aApplies[i].lValue;
|
||||||
|
|
||||||
if (m_pProto->aApplies[i].bType == APPLY_SKILL)
|
if (m_pProto->aApplies[i].bType == APPLY_SKILL)
|
||||||
{
|
{
|
||||||
|
@ -952,7 +952,7 @@ bool CItem::Unequip()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
long CItem::GetValue(DWORD idx)
|
int CItem::GetValue(DWORD idx)
|
||||||
{
|
{
|
||||||
assert(idx < ITEM_VALUES_MAX_NUM);
|
assert(idx < ITEM_VALUES_MAX_NUM);
|
||||||
return GetProto()->alValues[idx];
|
return GetProto()->alValues[idx];
|
||||||
|
@ -992,13 +992,13 @@ bool CItem::CreateSocket(BYTE bSlot, BYTE bGold)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CItem::SetSockets(const long * c_al)
|
void CItem::SetSockets(const LONG * c_al)
|
||||||
{
|
{
|
||||||
memcpy(m_alSockets, c_al, sizeof(m_alSockets));
|
memcpy(m_alSockets, c_al, sizeof(m_alSockets));
|
||||||
Save();
|
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);
|
assert(i < ITEM_SOCKET_MAX_NUM);
|
||||||
m_alSockets[i] = v;
|
m_alSockets[i] = v;
|
||||||
|
@ -1367,17 +1367,10 @@ EVENTFUNC(real_time_expire_event)
|
||||||
|
|
||||||
const time_t current = get_global_time();
|
const time_t current = get_global_time();
|
||||||
|
|
||||||
if (current > item->GetSocket(0))
|
if (current > item->GetSocket(0)) {
|
||||||
{
|
|
||||||
switch (item->GetVnum())
|
|
||||||
{
|
|
||||||
if(item->IsNewMountItem())
|
if(item->IsNewMountItem())
|
||||||
{
|
|
||||||
if (item->GetSocket(2) != 0)
|
if (item->GetSocket(2) != 0)
|
||||||
item->ClearMountAttributeAndAffect();
|
item->ClearMountAttributeAndAffect();
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ITEM_MANAGER::instance().RemoveItem(item, "REAL_TIME_EXPIRE");
|
ITEM_MANAGER::instance().RemoveItem(item, "REAL_TIME_EXPIRE");
|
||||||
|
|
||||||
|
@ -1864,7 +1857,7 @@ bool CItem::CheckItemUseLevel(int nLevel)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
long CItem::FindApplyValue(BYTE bApplyType)
|
int CItem::FindApplyValue(BYTE bApplyType)
|
||||||
{
|
{
|
||||||
if (m_pProto == NULL)
|
if (m_pProto == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -20,7 +20,7 @@ class CItem : public CEntity
|
||||||
|
|
||||||
bool IsPCBangItem();
|
bool IsPCBangItem();
|
||||||
|
|
||||||
long FindApplyValue(BYTE bApplyType);
|
int FindApplyValue(BYTE bApplyType);
|
||||||
|
|
||||||
bool IsStackable() { return (GetFlag() & ITEM_FLAG_STACKABLE)?true:false; }
|
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; }
|
const char * GetBaseName() { return m_pProto ? m_pProto->szName : NULL; }
|
||||||
BYTE GetSize() { return m_pProto ? m_pProto->bSize : 0; }
|
BYTE GetSize() { return m_pProto ? m_pProto->bSize : 0; }
|
||||||
|
|
||||||
void SetFlag(long flag) { m_lFlag = flag; }
|
void SetFlag(int flag) { m_lFlag = flag; }
|
||||||
long GetFlag() { return m_lFlag; }
|
int GetFlag() { return m_lFlag; }
|
||||||
|
|
||||||
void AddFlag(long bit);
|
void AddFlag(int bit);
|
||||||
void RemoveFlag(long bit);
|
void RemoveFlag(int bit);
|
||||||
|
|
||||||
DWORD GetWearFlag() { return m_pProto ? m_pProto->dwWearFlags : 0; }
|
DWORD GetWearFlag() { return m_pProto ? m_pProto->dwWearFlags : 0; }
|
||||||
DWORD GetAntiFlag() { return m_pProto ? m_pProto->dwAntiFlags : 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 GetType() const { return m_pProto ? m_pProto->bType : 0; }
|
||||||
BYTE GetSubType() const { return m_pProto ? m_pProto->bSubType : 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; }
|
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; }
|
void SetCell(LPCHARACTER ch, WORD pos) { m_pOwner = ch, m_wCell = pos; }
|
||||||
WORD GetCell() { return m_wCell; }
|
WORD GetCell() { return m_wCell; }
|
||||||
|
@ -82,7 +82,7 @@ class CItem : public CEntity
|
||||||
LPCHARACTER GetOwner() { return m_pOwner; }
|
LPCHARACTER GetOwner() { return m_pOwner; }
|
||||||
|
|
||||||
LPITEM RemoveFromGround();
|
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);
|
int FindEquipCell(LPCHARACTER ch, int bCandidateCell = -1);
|
||||||
bool IsEquipped() const { return m_bEquipped; }
|
bool IsEquipped() const { return m_bEquipped; }
|
||||||
|
@ -106,11 +106,11 @@ class CItem : public CEntity
|
||||||
void ModifyPoints(bool bAdd); // 아이템의 효과를 캐릭터에 부여 한다. bAdd가 false이면 제거함
|
void ModifyPoints(bool bAdd); // 아이템의 효과를 캐릭터에 부여 한다. bAdd가 false이면 제거함
|
||||||
|
|
||||||
bool CreateSocket(BYTE bSlot, BYTE bGold);
|
bool CreateSocket(BYTE bSlot, BYTE bGold);
|
||||||
const long * GetSockets() { return &m_alSockets[0]; }
|
const int * GetSockets() { return &m_alSockets[0]; }
|
||||||
long GetSocket(int i) { return m_alSockets[i]; }
|
int GetSocket(int i) { return m_alSockets[i]; }
|
||||||
|
|
||||||
void SetSockets(const long * al);
|
void SetSockets(const LONG * al);
|
||||||
void SetSocket(int i, long v, bool bLog = true);
|
void SetSocket(int i, int v, bool bLog = true);
|
||||||
|
|
||||||
int GetSocketCount();
|
int GetSocketCount();
|
||||||
bool AddSocket();
|
bool AddSocket();
|
||||||
|
@ -271,12 +271,12 @@ class CItem : public CEntity
|
||||||
DWORD m_dwVID; // VID
|
DWORD m_dwVID; // VID
|
||||||
WORD m_wCell; // 위치
|
WORD m_wCell; // 위치
|
||||||
DWORD m_dwCount; // 개수
|
DWORD m_dwCount; // 개수
|
||||||
long m_lFlag; // Ãß°¡ flag
|
int m_lFlag; // Ãß°¡ flag
|
||||||
DWORD m_dwLastOwnerPID; // 마지막 가지고 있었던 사람의 PID
|
DWORD m_dwLastOwnerPID; // 마지막 가지고 있었던 사람의 PID
|
||||||
|
|
||||||
bool m_bExchanging; ///< 현재 교환중 상태
|
bool m_bExchanging; ///< 현재 교환중 상태
|
||||||
|
|
||||||
long m_alSockets[ITEM_SOCKET_MAX_NUM]; // ¾ÆÀÌÅÛ ¼ÒĹ
|
int m_alSockets[ITEM_SOCKET_MAX_NUM]; // ¾ÆÀÌÅÛ ¼ÒĹ
|
||||||
TPlayerItemAttribute m_aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
TPlayerItemAttribute m_aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
||||||
|
|
||||||
LPEVENT m_pkDestroyEvent;
|
LPEVENT m_pkDestroyEvent;
|
||||||
|
|
|
@ -104,7 +104,7 @@ void CItem::AddAttr(BYTE bApply, BYTE bLevel)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const TItemAttrTable & r = g_map_itemAttr[bApply];
|
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)
|
if (lVal)
|
||||||
SetAttribute(i, bApply, lVal);
|
SetAttribute(i, bApply, lVal);
|
||||||
|
|
|
@ -315,7 +315,7 @@ LPITEM ITEM_MANAGER::CreateItem(DWORD vnum, DWORD count, DWORD id, bool bTryMagi
|
||||||
}
|
}
|
||||||
else if(0 == id)
|
else if(0 == id)
|
||||||
{
|
{
|
||||||
long duration = item->GetSocket(0);
|
int duration = item->GetSocket(0);
|
||||||
if (0 == duration)
|
if (0 == duration)
|
||||||
duration = item->GetLimitValue(i);
|
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)
|
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군데나 있냐... 하나로 해놓지ㅠㅠㅠ 나는 패스 홍이 할꺼임
|
const int ITEM_BROKEN_METIN_VNUM = 28960; // 이건 뭐 똑같은 상수가 3군데나 있냐... 하나로 해놓지ㅠㅠㅠ 나는 패스 홍이 할꺼임
|
||||||
if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM)
|
if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM)
|
||||||
pkNewItem->SetSocket(slot++, socket);
|
pkNewItem->SetSocket(slot++, socket);
|
||||||
|
|
|
@ -314,14 +314,14 @@ void LogManager::DragonSlayLog(DWORD dwGuildID, DWORD dwDragonVnum, DWORD dwStar
|
||||||
dwGuildID, dwDragonVnum, dwStartTime, dwEndTime);
|
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;
|
struct in_addr st_addr;
|
||||||
|
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
if (0 == inet_aton(ch->GetDesc()->GetHostName(), &st_addr))
|
if (0 == inet_aton(ch->GetDesc()->GetHostName(), &st_addr))
|
||||||
#else
|
#else
|
||||||
unsigned long in_address;
|
unsigned int in_address;
|
||||||
in_address = inet_addr(ch->GetDesc()->GetHostName());
|
in_address = inet_addr(ch->GetDesc()->GetHostName());
|
||||||
st_addr.s_addr = in_address;
|
st_addr.s_addr = in_address;
|
||||||
if (INADDR_NONE == in_address)
|
if (INADDR_NONE == in_address)
|
||||||
|
|
|
@ -52,7 +52,7 @@ class LogManager : public singleton<LogManager>
|
||||||
void QuestRewardLog(const char * c_pszQuestName, DWORD dwPID, DWORD dwLevel, int iValue1, int iValue2);
|
void QuestRewardLog(const char * c_pszQuestName, DWORD dwPID, DWORD dwLevel, int iValue1, int iValue2);
|
||||||
void DetailLoginLog(bool isLogin, LPCHARACTER ch);
|
void DetailLoginLog(bool isLogin, LPCHARACTER ch);
|
||||||
void DragonSlayLog(DWORD dwGuildID, DWORD dwDragonVnum, DWORD dwStartTime, DWORD dwEndTime);
|
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:
|
private:
|
||||||
void Query(const char * c_pszFormat, ...);
|
void Query(const char * c_pszFormat, ...);
|
||||||
|
|
|
@ -89,13 +89,13 @@ const char * CLoginData::GetIP()
|
||||||
return m_szIP;
|
return m_szIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLoginData::SetRemainSecs(long l)
|
void CLoginData::SetRemainSecs(int l)
|
||||||
{
|
{
|
||||||
m_lRemainSecs = l;
|
m_lRemainSecs = l;
|
||||||
sys_log(0, "SetRemainSecs %s %d type %u", m_stLogin.c_str(), m_lRemainSecs, m_bBillType);
|
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;
|
return m_lRemainSecs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ class CLoginData
|
||||||
void SetIP(const char * c_pszIP);
|
void SetIP(const char * c_pszIP);
|
||||||
const char * GetIP();
|
const char * GetIP();
|
||||||
|
|
||||||
void SetRemainSecs(long l);
|
void SetRemainSecs(int l);
|
||||||
long GetRemainSecs();
|
int GetRemainSecs();
|
||||||
|
|
||||||
void SetBilling(bool bOn);
|
void SetBilling(bool bOn);
|
||||||
bool IsBilling();
|
bool IsBilling();
|
||||||
|
@ -51,7 +51,7 @@ class CLoginData
|
||||||
DWORD m_dwBillID;
|
DWORD m_dwBillID;
|
||||||
DWORD m_dwConnectedPeerHandle;
|
DWORD m_dwConnectedPeerHandle;
|
||||||
DWORD m_dwLogonTime;
|
DWORD m_dwLogonTime;
|
||||||
long m_lRemainSecs;
|
int m_lRemainSecs;
|
||||||
char m_szIP[MAX_HOST_LENGTH+1];
|
char m_szIP[MAX_HOST_LENGTH+1];
|
||||||
bool m_bBilling;
|
bool m_bBilling;
|
||||||
bool m_bDeleted;
|
bool m_bDeleted;
|
||||||
|
|
|
@ -45,7 +45,6 @@
|
||||||
#include "polymorph.h"
|
#include "polymorph.h"
|
||||||
#include "blend_item.h"
|
#include "blend_item.h"
|
||||||
#include "castle.h"
|
#include "castle.h"
|
||||||
#include "passpod.h"
|
|
||||||
#include "ani.h"
|
#include "ani.h"
|
||||||
#include "BattleArena.h"
|
#include "BattleArena.h"
|
||||||
#include "over9refine.h"
|
#include "over9refine.h"
|
||||||
|
@ -59,7 +58,9 @@
|
||||||
#include "skill_power.h"
|
#include "skill_power.h"
|
||||||
#include "SpeedServer.h"
|
#include "SpeedServer.h"
|
||||||
#include "DragonSoul.h"
|
#include "DragonSoul.h"
|
||||||
#include <boost/bind.hpp>
|
#include <event2/event.h>
|
||||||
|
#include <event2/listener.h>
|
||||||
|
#include <event2/dns.h>
|
||||||
|
|
||||||
#ifdef __AUCTION__
|
#ifdef __AUCTION__
|
||||||
#include "auction_manager.h"
|
#include "auction_manager.h"
|
||||||
|
@ -95,12 +96,17 @@ int current_bytes_written = 0;
|
||||||
int total_bytes_written = 0;
|
int total_bytes_written = 0;
|
||||||
BYTE g_bLogLevel = 0;
|
BYTE g_bLogLevel = 0;
|
||||||
|
|
||||||
socket_t tcp_socket = 0;
|
evconnlistener * tcp_listener = nullptr;
|
||||||
socket_t p2p_socket = 0;
|
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 start(int argc, char **argv);
|
||||||
int idle();
|
int idle();
|
||||||
|
@ -367,7 +373,6 @@ int main(int argc, char **argv)
|
||||||
CTableBySkill SkillPowerByLevel;
|
CTableBySkill SkillPowerByLevel;
|
||||||
CPolymorphUtils polymorph_utils;
|
CPolymorphUtils polymorph_utils;
|
||||||
CProfiler profiler;
|
CProfiler profiler;
|
||||||
CPasspod passpod;
|
|
||||||
CBattleArena ba;
|
CBattleArena ba;
|
||||||
COver9RefineManager o9r;
|
COver9RefineManager o9r;
|
||||||
SpamManager spam_mgr;
|
SpamManager spam_mgr;
|
||||||
|
@ -541,7 +546,7 @@ int start(int argc, char **argv)
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
{
|
{
|
||||||
long l = strtol(argv[optind], &ep, 10);
|
int l = strtol(argv[optind], &ep, 10);
|
||||||
|
|
||||||
log_set_level(l);
|
log_set_level(l);
|
||||||
|
|
||||||
|
@ -608,26 +613,58 @@ int start(int argc, char **argv)
|
||||||
|
|
||||||
signal_timer_disable();
|
signal_timer_disable();
|
||||||
|
|
||||||
main_fdw = fdwatch_new(4096);
|
// Initialize the network stack
|
||||||
|
// Create a new libevent base and listen for new connections
|
||||||
if ((tcp_socket = socket_tcp_bind(g_szPublicIP, mother_port)) == INVALID_SOCKET)
|
ev_base = event_base_new();
|
||||||
{
|
if (!ev_base) {
|
||||||
perror("socket_tcp_bind: tcp_socket");
|
sys_err("Libevent base initialization FAILED!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if internal ip exists, p2p socket uses internal ip, if not use public ip
|
dns_base = evdns_base_new(ev_base, 1);
|
||||||
//if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET)
|
if (!dns_base) {
|
||||||
if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)
|
sys_err("Libevent DNS base initialization FAILED!");
|
||||||
{
|
|
||||||
perror("socket_tcp_bind: p2p_socket");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fdwatch_add_fd(main_fdw, tcp_socket, NULL, FDW_READ, false);
|
sockaddr_in sin = {};
|
||||||
fdwatch_add_fd(main_fdw, p2p_socket, NULL, FDW_READ, false);
|
|
||||||
|
|
||||||
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) {
|
if (!g_bAuthServer) {
|
||||||
db_clientdesc->UpdateChannelStatus(0, true);
|
db_clientdesc->UpdateChannelStatus(0, true);
|
||||||
}
|
}
|
||||||
|
@ -637,9 +674,9 @@ int start(int argc, char **argv)
|
||||||
if (g_stAuthMasterIP.length() != 0)
|
if (g_stAuthMasterIP.length() != 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "SlaveAuth");
|
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);
|
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
|
else
|
||||||
|
@ -651,7 +688,7 @@ int start(int argc, char **argv)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (teen_addr[0] && teen_port)
|
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_uiSpamBlockDuration;
|
||||||
extern unsigned int g_uiSpamBlockScore;
|
extern unsigned int g_uiSpamBlockScore;
|
||||||
|
@ -676,12 +713,26 @@ void destroy()
|
||||||
sys_log(0, "<shutdown> regen_free()...");
|
sys_log(0, "<shutdown> regen_free()...");
|
||||||
regen_free();
|
regen_free();
|
||||||
|
|
||||||
sys_log(0, "<shutdown> Closing sockets...");
|
sys_log(0, "<shutdown> Closing network stack...");
|
||||||
socket_close(tcp_socket);
|
if (tcp_listener) {
|
||||||
socket_close(p2p_socket);
|
evconnlistener_free(tcp_listener);
|
||||||
|
tcp_listener = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
sys_log(0, "<shutdown> fdwatch_delete()...");
|
if (p2p_listener) {
|
||||||
fdwatch_delete(main_fdw);
|
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, "<shutdown> event_destroy()...");
|
sys_log(0, "<shutdown> event_destroy()...");
|
||||||
event_destroy();
|
event_destroy();
|
||||||
|
@ -724,7 +775,7 @@ int idle()
|
||||||
s_dwProfiler[PROF_CHR_UPDATE] += (get_dword_time() - t);
|
s_dwProfiler[PROF_CHR_UPDATE] += (get_dword_time() - t);
|
||||||
|
|
||||||
t = get_dword_time();
|
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);
|
s_dwProfiler[PROF_IO] += (get_dword_time() - t);
|
||||||
|
|
||||||
log_rotate();
|
log_rotate();
|
||||||
|
@ -772,7 +823,29 @@ int idle()
|
||||||
return 1;
|
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;
|
LPDESC d;
|
||||||
int num_events, event_idx;
|
int num_events, event_idx;
|
||||||
|
@ -780,100 +853,8 @@ int io_loop(LPFDWATCH fdw)
|
||||||
DESC_MANAGER::instance().DestroyClosed(); // PHASE_CLOSEÀÎ Á¢¼ÓµéÀ» ²÷¾îÁØ´Ù.
|
DESC_MANAGER::instance().DestroyClosed(); // PHASE_CLOSEÀÎ Á¢¼ÓµéÀ» ²÷¾îÁØ´Ù.
|
||||||
DESC_MANAGER::instance().TryConnect();
|
DESC_MANAGER::instance().TryConnect();
|
||||||
|
|
||||||
if ((num_events = fdwatch(fdw, 0)) < 0)
|
// Process network events
|
||||||
return 0;
|
event_base_loop(base, EVLOOP_NONBLOCK);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
|
|
||||||
CMapLocation g_mapLocations;
|
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);
|
lIndex = SECTREE_MANAGER::instance().GetMapIndex(x, y);
|
||||||
|
|
||||||
return Get(lIndex, lAddr, wPort);
|
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)
|
if (iIndex == 0)
|
||||||
{
|
{
|
||||||
|
@ -22,12 +22,12 @@ bool CMapLocation::Get(int iIndex, long & lAddr, WORD & wPort)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<long, TLocation>::iterator it = m_map_address.find(iIndex);
|
std::map<int, TLocation>::iterator it = m_map_address.find(iIndex);
|
||||||
|
|
||||||
if (m_map_address.end() == it)
|
if (m_map_address.end() == it)
|
||||||
{
|
{
|
||||||
sys_log(0, "CMapLocation::Get - Error MapIndex[%d]", iIndex);
|
sys_log(0, "CMapLocation::Get - Error MapIndex[%d]", iIndex);
|
||||||
std::map<long, TLocation>::iterator i;
|
std::map<int, TLocation>::iterator i;
|
||||||
for ( i = m_map_address.begin(); i != m_map_address.end(); ++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);
|
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;
|
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;
|
TLocation loc;
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,15 @@ class CMapLocation : public singleton<CMapLocation>
|
||||||
public:
|
public:
|
||||||
typedef struct SLocation
|
typedef struct SLocation
|
||||||
{
|
{
|
||||||
long addr;
|
int addr;
|
||||||
WORD port;
|
WORD port;
|
||||||
} TLocation;
|
} TLocation;
|
||||||
|
|
||||||
bool Get(long x, long y, long & lMapIndex, long & lAddr, WORD & wPort);
|
bool Get(int x, int y, int& lMapIndex, LONG & lAddr, WORD & wPort);
|
||||||
bool Get(int iIndex, long & lAddr, WORD & wPort);
|
bool Get(int iIndex, LONG & lAddr, WORD & wPort);
|
||||||
void Insert(long lIndex, const char * c_pszHost, WORD wPort);
|
void Insert(int lIndex, const char * c_pszHost, WORD wPort);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::map<long, TLocation> m_map_address;
|
std::map<int, TLocation> m_map_address;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue