avatar_Mr.Kernighan

Decompiled Gens System Class. S6.2 TAI~~

Автор Mr.Kernighan, 2013 Фев. 18, 23:07

« назад - далее »

0 Пользователи и 4 гостей просматривают эту тему.

Mr.Kernighan

Может кому понадобиться, 70-75% готово.

GensSystemProtocol.h
#ifndef GENSSYSTEMPROTOCOL_H
#define GENSSYSTEMPROTOCOL_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

enum INFLUENCE_TYPE
{
//-----
LEAVED_INFLUENCE  = -1,
//-----
NONE_INFLUENCE =  0,
//-----
VANERT_INFLUENCE  =  1,
//-----
DUPRIAN_INFLUENCE =  2
//-----
};

enum USER_BATTLE_ZONE
{
//-----
BATTLE_ZONE_BLOCK   = 0,
//-----
BATTLE_ZONE_UNBLOCK = 1
//-----
};

//--------------------------------------------------

struct _tagPMSG_REQ_REG_GENS_MEMBER
{
PBMSG_HEAD2 h; //0
BYTE bResult;  //4
};

struct _tagPMSG_REQ_SEGEDE_GENS_MEMBER
{
PBMSG_HEAD h; //0
BYTE bResult; //3
};

struct _tagPMSG_GENS_REWARD_CODE
{
PBMSG_HEAD2 h; //0
BYTE bReward;  //4
};

struct _tagPMSG_REQ_GENS_INFO
{
};

//--------------------------------------------------

struct _tagPMSG_ANS_GENS_INFO_EXDB
{
PBMSG_HEAD2 h;
BYTE bInfluence;
WORD wIndexH;
WORD wIndexL;
int iContributePoint;
int iGensClass;
int iGensRanking;
};

struct _tagPMSG_ANS_REG_GENS_MEBMER
{
PBMSG_HEAD2 h;   //0
BYTE bResult; //4
BYTE iInfluence; //5
};

struct _tagPMSG_ANS_SECEDE_GENS_MEMBER_EXDB
{
PBMSG_HEAD2 h; //0
BYTE bResult;  //4
BYTE bIndexH;  //5
BYTE bIndexL;  //6
};

struct _tagPMSG_ANS_ABUSING_INFO //9A (154)
{
PBMSG_HEAD h; //2
BYTE bResult; //3
char Name[0x0A]; //13
char szCharNames[100]; //113
int iKillUserCount; //114
BYTE bIndexH; //154
BYTE bIndexL; //155
int KillCount[10]; //166
//i150
//i154
//b154
//b155
};

struct _tagPMSG_ANS_GENS_REWARD_EXDB
{
PBMSG_HEAD h;
BYTE b3;
BYTE bResult; //4
BYTE b5;
BYTE b6;
BYTE b7;
int iGensClass; //8
BYTE bIndexH; //12
BYTE bIndexL; //13
};

struct _tagPMSG_ANS_GENS_MEMBER_COUNT_EXDB //0xA (10)
{
PBMSG_HEAD2 h;
int iVanertMemberCount;
int iDuprianMemberCount;
};

struct _tagPMSG_ANS_GENS_REWARD_DAY_CHECK_EXDB
{
PBMSG_HEAD h;
BYTE bResult;
BYTE bIndexH;
BYTE bIndexL;
int iRewardDay;
};

//--------------------------------------------------

struct _tagPMSG_REQ_REG_GENS_MEMBER_EXDB //0x20 (32)
{
PBMSG_HEAD2 h;
BYTE bResult;
char Name[0x0A];
BYTE bMessage;
BYTE bInfluence;
WORD wNumberH;
WORD wNumberL;
BYTE bIndexH;
BYTE bIndexL;
};

struct _tagPMSG_ANS_REG_GENS_MEMBER_EXDB
{
PBMSG_HEAD2 h;   //0
BYTE bResult; //4
BYTE bInfluence; //5
BYTE bIndexH; //6
BYTE bIndexL; //7
};

struct _tagPMSG_REQ_SECEDE_GENS_MEMBER_EXDB //0x16 (22)
{
PBMSG_HEAD2 h;
char Name[10];
BYTE bResult;
WORD wNumberH;
WORD wNumberL;
BYTE bIndexH;
BYTE bIndexL;
};

struct _tagPMSG_REQ_ABUSING_INFO //0x10 (16)
{
PBMSG_HEAD2 h;
char Name[0x0A];
BYTE bResult;
BYTE bIndexH;
BYTE bIndexL;
};

struct _tagPMSG_REQ_SAVE_CONTRIBUTE_POINT_EXDB //0x1A (24)
{
PBMSG_HEAD h;
char Name[0x0D];
BYTE bResult;
int iContributePoint;
int iGensClass;
};

struct _tagPMSG_REQ_SAVE_ABUSING_KILLUSER_EXDB //0xB0 (176)
{
PBMSG_HEAD h; //
char AccountID[0x0D];
BYTE bResult;
char Name[0x0A];
char KillName[100];
int KillCount[10];
//i150
//i154
//b154
//b155
};

struct _tagGENS_RANKING
{
PBMSG_HEAD h;
BYTE bRanking;
};

struct _tagPMSG_GENS_MEMBER_VIEWPORT_INFO // 0x10
{
BYTE btInfluence; // +0x0(0x1)
BYTE NumberH; // +0x1(0x1)
BYTE NumberL; // +0x2(0x1)
int iGensRanking; // +0x4(0x4)
int iGensClass;   // +0x8(0x4)
int iContributePoint; // +0xc(0x4)
};
extern _tagPMSG_GENS_MEMBER_VIEWPORT_INFO pGensMsg;

struct _tagPMSG_SEND_GENS_MEMBER_VIEWPORT // 0x6
{
struct PWMSG_HEAD2 h; // +0x0(0x5)
BYTE Count;   // +0x5(0x1)
};
extern _tagPMSG_SEND_GENS_MEMBER_VIEWPORT pGensCount;

//--------------------------------------------------

struct _tagPMSG_SEND_GENS_INFO //0x16 (20)
{
PBMSG_HEAD2 h;
BYTE bInfluence;
int iGensRanking;
int iGensClass;
int iContributePoint;
int iNextContributePoint;
};

struct _tagPMSG_REQ_GENS_REWARD_CHECK_EXDB //0x18 (24)
{
PBMSG_HEAD h;
char Name[0x0D];
BYTE bResult;
WORD wIndexH;
WORD wIndexL;
int iInfluence;
};

struct _tagPMSG_REQ_GENS_REWARD_COMPLETE_EXDB //0x14 (20)
{
PBMSG_HEAD h;
BYTE bResult;
char Name[0x0B];
WORD wIndexH;
WORD wIndexL;
};

struct _tagPMSG_SEND_GENS_REWARD //0x8 (8)
{
PBMSG_HEAD h;
BYTE bResult;
BYTE bItemType;
};

struct _tagPMSG_REQ_GENS_MEMBER_COUNT //0x14 (20)
{
PBMSG_HEAD h;
BYTE bResult;
char Name[0x0D];
WORD wIndexH;
WORD wIndexL;
};

struct _tagPMSG_SET_GENS_REWARD_DAY_EXDB
{
PBMSG_HEAD h;
BYTE bRewardDay;
};

struct _tagPMSG_REQ_GENS_REWARD_DAY
{
PBMSG_HEAD h;
WORD bRewardDay;
BYTE bIndexH, bIndexL;
};


#endif

GensSystem.h
#ifndef GENSSYSTEM_H
#define GENSSYSTEM_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "GensSystemProtocol.h"



const int MAX_VIEWPORT_INFO = 0x7FC + 1;



extern BOOL g_GensSystemIsEnabled;
extern int g_GensAbusingResetTime;
extern int g_GensInitialContributePoint;
extern int g_BattleZoneAddExp;
extern int g_GensMasterLevelBattleZoneAddExp;
extern int g_PkPenaltyAddNeedZenMapMove;



//--------------------------------------------------

void CGReqRegGensMember(_tagPMSG_REQ_REG_GENS_MEMBER *lpMsg, int iIndex);
void CGReqSecedeGensMember(_tagPMSG_REQ_SEGEDE_GENS_MEMBER *lpMsg, int iIndex);
void CGReqGensReward(_tagPMSG_GENS_REWARD_CODE *lpMsg, int iIndex);
void CGReqGensMemberInfo(_tagPMSG_REQ_GENS_INFO *lpMsg, int iIndex);

//--------------------------------------------------



//--------------------------------------------------

void DGAnsGensInfo(_tagPMSG_ANS_GENS_INFO_EXDB *lpMsg);
void DGAnsRegGensMember(_tagPMSG_ANS_REG_GENS_MEMBER_EXDB *lpMsg);
void DGAnsSecedeGensMember(_tagPMSG_ANS_SECEDE_GENS_MEMBER_EXDB *lpMsg);
void DGAnsAbusingInfo(_tagPMSG_ANS_ABUSING_INFO *lpMsg);
void DGAnsGensReward(_tagPMSG_ANS_GENS_REWARD_EXDB *lpMsg);
void DGAnsGensMemberCount(_tagPMSG_ANS_GENS_MEMBER_COUNT_EXDB *lpMsg);
void DGAnsGensRewardDayCheck(_tagPMSG_ANS_GENS_REWARD_DAY_CHECK_EXDB *lpMsg);

//--------------------------------------------------



//--------------------------------------------------

class GensSystem
{
public:
GensSystem(void);
virtual ~GensSystem(void);

int GDReqAbusingInfo(LPOBJ lpObj);
int ReqExDBGensInfo(LPOBJ lpObj);
void ReqRegGensMember(LPOBJ lpObj, unsigned char btInfluence);
int AnsRegGensMember(int iObjIndex, unsigned char btResult);
bool IsInfluenceNPC(LPOBJ lpObj);
int ReqSecedeGensMember(LPOBJ lpObj);
int SendGensInfo(LPOBJ lpObj);
int AnsSecedeGensMember(int iObjIndex, BYTE btResult);
int SendPkPenaltyMapMove(LPOBJ lpObj);
int GDReqSaveContributePoint(LPOBJ lpObj);
int DBSaveAbusingKillUserName(LPOBJ lpObj);
int BattleZoneChatMsgSend(LPOBJ lpObj, LPBYTE Msg, int size);
signed int IsMoveMapBattleZone(int iMapIndex);
void GensViewportListProtocol(LPOBJ lpObj);
signed int IsMapBattleZone(int iMapIndex);
void SetGensInfluence(LPOBJ lpObj, int iInfluence);
signed int IsPkEnable(LPOBJ lpObj, LPOBJ lpTargetObj);
signed int GetGensInfluence(LPOBJ lpObj);
char *GetGensInfluenceName(LPOBJ lpObj);
bool IsRegGensInfluence(LPOBJ lpObj);
int SetUserBattleZoneEnable(LPOBJ lpObj, int bBattleZoneEnable);
int IsUserBattleZoneEnable(LPOBJ lpObj);
int SetContributePoint(LPOBJ lpObj, int iContributePoint);
int AddContributePoint(LPOBJ lpObj, int iContributePoint);
int SubContributePoint(LPOBJ lpObj, int iContributePoint);
int GetContributePoint(LPOBJ lpObj);
signed int PkPenaltyAddNeedZenMapMove(LPOBJ lpObj);
void PkPenaltyDropInvenItem(LPOBJ lpObj);
void PkPenaltyDropZen(LPOBJ lpObj);
int SendPKPenaltyDebuff(LPOBJ lpObj);
void CalcContributePoint(LPOBJ lpObj, LPOBJ lpTargetObj);
signed int ChkKillUserName(LPOBJ lpObj, char *szCharName);
signed int AbusingPenalty(LPOBJ lpObj, int iKillUserIndex);
int InsertKillUserName(LPOBJ lpObj, char *szCharName);
void MoveInBattleZonePartySplit(LPOBJ lpObj);
void AbusingInfoReset(LPOBJ lpObj);
signed int CalGensClass(LPOBJ lpObj);
int SetGensRanking(LPOBJ lpObj, int iGensRanking);
int SetGensClass(LPOBJ lpObj, int iGensClass);
int GetGensClass(LPOBJ lpObj);
int GetNextContributePoint(LPOBJ lpObj);
int SetGensMemberCount(int iInfluence, int iMemberCount);
signed int GetGensMemberCount(int iInfluence);
int ReqExDBGensRewardCheck(LPOBJ lpObj, int iInfluence);
int ReqExDBGensRewardComplete(LPOBJ lpObj);
int SendGensReward(LPOBJ lpObj, unsigned char btResult);
signed int SendGensRewardItem(LPOBJ lpObj, int iGensClass);
bool GensRewardInventoryCheck(LPOBJ lpObj, int iItemCount);
int ReqExDBGensMemberCount(LPOBJ lpObj);
int ReqExDBSetGensRewardDay(void);
int ReqExDBSetGensRanking(void);
int LoadData(char *lpszFileName);
int ReqGensRewardDay(LPOBJ lpObj);

//_tagGENS_RANKING::_tagGENS_RANKING(void)   //0050B9F0
//_tagPMSG_REQ_REG_GENS_MEMBER_EXDB::_tagPMSG_REQ_REG_GENS_MEMBER_EXDB(void) //0050BA60
//_tagPMSG_REQ_SECEDE_GENS_MEMBER_EXDB::_tagPMSG_REQ_SECEDE_GENS_MEMBER_EXDB(void)   //0050BAE0
//_tagPMSG_REQ_SAVE_CONTRIBUTE_POINT_EXDB::_tagPMSG_REQ_SAVE_CONTRIBUTE_POINT_EXDB(void) //0050BB40
//_tagPMSG_REQ_SAVE_ABUSING_KILLUSER_EXDB::_tagPMSG_REQ_SAVE_ABUSING_KILLUSER_EXDB(void) //0050BBA0
//_tagPMSG_REQ_ABUSING_INFO::_tagPMSG_REQ_ABUSING_INFO(void) //0050BC20

private:
BOOL b_PkPenaltyDropZen;
BOOL b_PkPenaltyDropInvenItem;

int iVanertMemberCount;
int iDuprianMemberCount;

int iIndex;

protected:
};
extern GensSystem g_GensSystem;

//--------------------------------------------------

#endif //GENSSYSTEM_H

GensSystem.cpp
#include "StdAfx.h"

#include "SQLConnect.h"
#include "DBSockMng.h"
#include "GameMain.h"
#include "GuildClass.h"
#include "logproc.h"
#include "DSProtocol.h"
#include "user.h"
#include "BuffManager.h"

#include "..commonwinutil.h"
#include "..commonReadScript.h"

#include "GensSystem.h"
#include "GensSystemProtocol.h"

//--------------------------------------------------

_tagPMSG_GENS_MEMBER_VIEWPORT_INFO pGensMsg;
_tagPMSG_SEND_GENS_MEMBER_VIEWPORT pGensCount;

BOOL g_GensSystemIsEnabled = GetPrivateProfileIntA("GensSystem", "GensSystemIsEnabled", 1, "..\Data\Events\GensSystem\GensSystem.ini");
int g_GensAbusingResetTime = GetPrivateProfileIntA("GensSystem", "GensSystemAbusingResetTime", 60, "..\Data\Events\GensSystem\GensSystem.ini");
int g_GensInitialContributePoint = GetPrivateProfileIntA("GensSystem", "GensSystemInitialContributePoint", 10, "..\Data\Event\GensSystem\GensSystem.ini");
int g_BattleZoneAddExp = GetPrivateProfileIntA("GensSystem", "GensSystemBattleZoneAddExp", 25, "..\Data\Event\GensSystem\GensSystem.ini");
int g_GensMasterLevelBattleZoneAddExp = GetPrivateProfileIntA("GensSystem", "GensSystemMasterLevelBattleZoneAddExp", 50, "..\Data\Event\GensSystem\GensSystem.ini");
int g_PkPenaltyAddNeedZenMapMove = GetPrivateProfileIntA("GensSystem", "GensSystemPkPenaltyAddNeedZenMapMove", 50, "..\Data\Event\GensSystem\GensSystem.ini");

char *szInfluence[] = { "NONE_INFLUENCE", "Vanert", "Duprian" };

GensSystem g_GensSystem;

GensSystem::GensSystem() {};

GensSystem::~GensSystem() {};

//-> Completed
int GensSystem::GDReqAbusingInfo(LPOBJ lpObj)
{
if (!OBJMAX_RANGE(lpObj->m_Index))
return 0;

if (gObjIsConnected(lpObj))
{
_tagPMSG_REQ_ABUSING_INFO pMsg;

PHeadSetB((LPBYTE)&pMsg, 0xF8, sizeof(pMsg));
memcpy(pMsg.Name, lpObj->Name, 0x0A);
pMsg.bIndexH = SET_NUMBERH(lpObj->m_Index);
pMsg.bIndexL = SET_NUMBERL(lpObj->m_Index);

pMsg.bResult = 9;

if (wsJServerCli.DataSend((char*)&pMsg, pMsg.h.size))
return true;
}
return false;
};

//-> Completed
int GensSystem::ReqExDBGensInfo(LPOBJ lpObj)
{
if (!OBJMAX_RANGE(lpObj->m_Index)) return 0;

if (gObjIsConnected(lpObj))
{
_tagPMSG_REQ_ABUSING_INFO pMsg;

PHeadSubSetB((LPBYTE)&pMsg, 0xF8, 0x1, sizeof(pMsg));
pMsg.bResult = 0;
memcpy(pMsg.Name, lpObj->Name, 0x0A);
pMsg.bIndexH = SET_NUMBERH(lpObj->m_Index);
pMsg.bIndexL = SET_NUMBERL(lpObj->m_Index);

if (cDBSMng.Send((char*)&pMsg, pMsg.h.size)) return true;
}
return false;
};

//-> Completed
void GensSystem::ReqRegGensMember(LPOBJ lpObj, unsigned char btInfluence)
{
//-----
_GUILD_INFO_STRUCT *lpGuildInfo = lpObj->lpGuild;
//-----

if (!OBJMAX_RANGE(lpObj->m_Index)) return;

if (gObjIsConnected(lpObj->m_Index))
{
if (btInfluence == VANERT_INFLUENCE || btInfluence == DUPRIAN_INFLUENCE)
{
//-----
_tagPMSG_REQ_REG_GENS_MEMBER_EXDB pMsg;
//-----

if (btInfluence == VANERT_INFLUENCE || btInfluence == DUPRIAN_INFLUENCE)
{
//-----
PHeadSubSetB((LPBYTE)&pMsg, 0xF8, 0x03, sizeof(pMsg));
//-----
//memcpy(pMsg.AccountID, lpObj->AccountID, sizeof(lpObj->AccountID));
//-----
//pMsg.bResult = 0;
//-----
memcpy(pMsg.Name, lpObj->Name, sizeof(lpObj->Name));
//-----
pMsg.bMessage = 0;
//-----
pMsg.bInfluence = btInfluence;
//-----

if (lpGuildInfo)
{
pMsg.wNumberH = SET_NUMBERHW(lpGuildInfo->Number);
pMsg.wNumberL = SET_NUMBERLW(lpGuildInfo->Number);
}

//-----
pMsg.bIndexH = SET_NUMBERH(lpObj->m_Index);
//-----
pMsg.bIndexL = SET_NUMBERL(lpObj->m_Index);
//-----

if (cDBSMng.Send((char*)&pMsg, pMsg.h.size)) return;
}
}
else
{
LogAddTD("[GensSystem] - Error - %s %s Line: %d", "btInfluence", __FILE__, __LINE__);
}
}
};

//-> Completed
int GensSystem::AnsRegGensMember(int iObjIndex, unsigned char btResult)
{
return 0;
};

//-> Completed
bool GensSystem::IsInfluenceNPC(LPOBJ lpObj)
{
return (lpObj->TargetNumber == 543 && this->GetGensInfluence(lpObj) == VANERT_INFLUENCE
|| lpObj->TargetNumber == 544 && this->GetGensInfluence(lpObj) == DUPRIAN_INFLUENCE);
};

//-> Completed
int GensSystem::ReqSecedeGensMember(LPOBJ lpObj)
{
if (gObjIsConnected(lpObj->m_Index))
{
//-----
_tagPMSG_REQ_SECEDE_GENS_MEMBER_EXDB pMsg;
//-----
PHeadSubSetBE((LPBYTE)&pMsg, 0xF8, 0x4, sizeof(pMsg));
//-----
pMsg.bResult = 0; //[GensSystem] [%s][%s] Gens Request - Leave [%s]
//-----
pMsg.bIndexH = SET_NUMBERH(lpObj->m_Index);
//-----
pMsg.bIndexL = SET_NUMBERL(lpObj->m_Index);
//-----
memcpy(pMsg.Name, lpObj->Name, sizeof(lpObj->Name));
//-----

if (cDBSMng.Send((char*)&pMsg, sizeof(pMsg))) return true;
}
return false;
};

//-> Completed
int GensSystem::SendGensInfo(LPOBJ lpObj)
{
if (!OBJMAX_RANGE(lpObj->m_Index))
return 0;

if (gObjIsConnected(lpObj))
{
_tagPMSG_SEND_GENS_INFO pMsg;

PHeadSubSetB((LPBYTE)&pMsg, 0xF8, 0x7, sizeof(pMsg));

pMsg.bInfluence = this->GetGensInfluence(lpObj);
pMsg.iGensRanking = lpObj->m_GensRanking;
pMsg.iGensClass = lpObj->m_GensClass;
pMsg.iContributePoint = lpObj->m_ContributePoint;
pMsg.iNextContributePoint = this->GetNextContributePoint(lpObj);

if (DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size))
return true;
}
return false;
};

//-> Completed
int GensSystem::AnsSecedeGensMember(int iObjIndex, BYTE btResult)
{
//int iRet;
return 0;
};

//-> Completed
int GensSystem::SendPkPenaltyMapMove(LPOBJ lpObj)
{
if (!OBJMAX_RANGE(lpObj->m_Index))
return 0;

if (gObjIsConnected(lpObj))
{
BYTE pMsg[4] = { 0xC1, 0x04, 0xF8, 0x08 };
DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg[1]);
return true;
}
return false;
};

//-> Completed
int GensSystem::GDReqSaveContributePoint(LPOBJ lpObj)
{
if (!OBJMAX_RANGE(lpObj->m_Index))
return false;

if (gObjIsConnected(lpObj))
{
if (this->IsRegGensInfluence(lpObj))
{
_tagPMSG_REQ_SAVE_CONTRIBUTE_POINT_EXDB pMsg;

PHeadSetB((LPBYTE)&pMsg, 0xF8, sizeof(pMsg));
memcpy(pMsg.Name, lpObj->Name, 0x0A);
pMsg.iContributePoint = this->GetContributePoint(lpObj);
pMsg.bResult = 7;
pMsg.iGensClass = this->GetGensClass(lpObj);

if (wsJServerCli.DataSend((char*)&pMsg, pMsg.h.size))
return true;
}
}
return false;
};

//-> Completed
int GensSystem::DBSaveAbusingKillUserName(LPOBJ lpObj)
{
if (!OBJMAX_RANGE(lpObj->m_Index))
return false;

if (gObjIsConnected(lpObj))
{
if (this->IsRegGensInfluence(lpObj))
{
EnterCriticalSection(&criti);

_tagPMSG_REQ_SAVE_ABUSING_KILLUSER_EXDB pMsg;

pMsg.bResult = 0;

for (int i = 0; i < 10; ++i)
{
pMsg.KillName[i * 11] = 0;

pMsg.KillCount[i] = lpObj->m_KillUserCnt;

memcpy(&pMsg.KillName[i * 11], lpObj->Name, 0x0A);
}

memcpy(pMsg.AccountID, lpObj->AccountID, 0x0A);

memcpy(pMsg.Name, lpObj->Name, 0x0A);

PHeadSetB((LPBYTE)&pMsg, 0xF8, sizeof(pMsg));

pMsg.bResult = 8;

LeaveCriticalSection(&criti);

if (wsJServerCli.DataSend((char*)&pMsg, pMsg.h.size))
return true;
}
}
return false;
};

//-> Completed
int GensSystem::BattleZoneChatMsgSend(LPOBJ lpObj, LPBYTE Msg, int size)
{
int iTarInfluence = 0;

if (this->IsMapBattleZone(lpObj->MapNumber))
{
iTarInfluence = this->GetGensInfluence(lpObj);

for (int n = 0; n < MAX_VIEWPORT; ++n)
{
if (lpObj->VpPlayer[n].type == OBJ_USER && lpObj->VpPlayer[n].state == PLAYER_CONNECTED && (this->GetGensInfluence((LPOBJ)lpObj->VpPlayer[n].number) == iTarInfluence || CheckAuthorityCondition(98, lpObj) || CheckAuthorityCondition(98, (LPOBJ)lpObj->VpPlayer2[n].number)))
{
DataSend(lpObj->VpPlayer[n].number, (LPBYTE)&Msg, size);
}
iTarInfluence = n + 1;
}
}
return iTarInfluence;
};

//-> Completed
signed int GensSystem::IsMoveMapBattleZone(int iMapIndex)
{
if (gPkLimitFree)
{
switch (iMapIndex)
{
case 11:
case 12:
case 13:
case 25:
case 27:
case 28:
case 29:
case 33:
case 42:
case 45:
return 1;
default:
break;
}
}
return !gPkLimitFree && iMapIndex == 42;
};

//-> Completed

unsigned char lpViewportAdd[MAX_VIEWPORT_INFO];

void GensSystem::GensViewportListProtocol(LPOBJ lpObj)
{
unsigned char btInfluence;

int iGensCount = 0;

int iViewportSize = 0x06;

memset(&lpViewportAdd, 0, MAX_VIEWPORT_INFO);

if ((lpObj->Authority & 32) != 32 || gObjSearchActiveEffect(lpObj, AT_INVISIBILITY) != AT_MONSTER_GENERAL)
{
pGensMsg.btInfluence = this->GetGensInfluence(lpObj);
btInfluence = pGensMsg.btInfluence;
pGensMsg.NumberH = HIBYTE(lpObj->m_Index);
pGensMsg.NumberL = LOBYTE(lpObj->m_Index);
pGensMsg.iGensRanking = 1; //lpObj->m_GensRanking;
pGensMsg.iGensClass = 1; //this->GetGensClass(lpObj);
pGensMsg.iContributePoint = 1; // this->GetContributePoint(lpObj);
memcpy((BYTE*)lpViewportAdd + iViewportSize, &pGensMsg, 16);

iViewportSize += 16; ++iGensCount;

PHeadSubSetW((LPBYTE)&pGensCount, 0xF8, 0x05, iViewportSize);
pGensCount.Count = iGensCount;
memcpy((BYTE*)lpViewportAdd, &pGensCount, 6);

for (int n = 0; n < MAX_VIEWPORT; ++n)
{
if (lpObj->VpPlayer[n].type == OBJ_USER)
{
switch (lpObj->VpPlayer[n].state)
{
case 1:
case 2:
case 3:
{
int tObjNum = lpObj->VpPlayer[n].number;

if (tObjNum > 0)
{
DataSend(tObjNum, (LPBYTE)&lpViewportAdd, iViewportSize);
}
}
break;
}
}
}
}
};

//-> Completed
signed int GensSystem::IsMapBattleZone(int iMapIndex)
{
if (gNonPK)
{
return FALSE;
}

if (gPkLimitFree)
{
switch (iMapIndex)
{
case 7:

case 33:

case 37:

case 56:

case 63:
return TRUE;
break;

default:
break;
}
}

return (!gPkLimitFree && iMapIndex == 63);
};

//-> Completed
void GensSystem::SetGensInfluence(LPOBJ lpObj, int iInfluence)
{
if (iInfluence != VANERT_INFLUENCE && iInfluence != DUPRIAN_INFLUENCE && iInfluence != LEAVED_INFLUENCE)
{
LogAddTD("[GensSystem] - Error - [%s][%s] Influence[%d] %s %d",
lpObj->AccountID, lpObj->Name, iInfluence, __FILE__, __LINE__);
}
else
{
if (iInfluence == LEAVED_INFLUENCE) iInfluence = NONE_INFLUENCE;

lpObj->m_GensInfluence = iInfluence;
}
};

//-> Completed
signed int GensSystem::IsPkEnable(LPOBJ lpObj, LPOBJ lpTargetObj)
{
if (this->IsMapBattleZone(lpObj->MapNumber))
{
if (lpObj->Type != 1 || lpTargetObj->Type != 1)
{
return this->GetGensInfluence(lpObj) != this->GetGensInfluence(lpTargetObj);
}
else
{
return 1;
}
}
return 1;
};

//-> Completed
signed int GensSystem::GetGensInfluence(LPOBJ lpObj)
{
if (lpObj->m_GensInfluence == LEAVED_INFLUENCE || lpObj->m_GensInfluence < NONE_INFLUENCE || lpObj->m_GensInfluence > DUPRIAN_INFLUENCE)
{
LogAddTD("[GensSystem] Error [%s][%s] GensInfluence [%d]", lpObj->AccountID, lpObj->Name, lpObj->m_GensInfluence); return 0;
}
return lpObj->m_GensInfluence;
};

//-> Completed
char *GensSystem::GetGensInfluenceName(LPOBJ lpObj)
{
if (lpObj->m_GensInfluence == LEAVED_INFLUENCE || lpObj->m_GensInfluence < NONE_INFLUENCE || lpObj->m_GensInfluence > DUPRIAN_INFLUENCE)
{
LogAddTD("[GensSystem] Error [%s][%s] GensInfluence [%d]", lpObj->AccountID, lpObj->Name, lpObj->m_GensInfluence);
return NULL;
}
return szInfluence[lpObj->m_GensInfluence];
};

//-> Completed
bool GensSystem::IsRegGensInfluence(LPOBJ lpObj)
{
if (this->GetGensInfluence(lpObj) == VANERT_INFLUENCE || this->GetGensInfluence(lpObj) == DUPRIAN_INFLUENCE)
{
return true;
}
return false;
};

//-> Completed
int GensSystem::SetUserBattleZoneEnable(LPOBJ lpObj, int bBattleZoneEnable)
{
return lpObj->m_UserBattleZoneEnable = bBattleZoneEnable;
};

//-> Completed
int GensSystem::IsUserBattleZoneEnable(LPOBJ lpObj)
{
return lpObj->m_UserBattleZoneEnable;
};

//-> Completed
int GensSystem::SetContributePoint(LPOBJ lpObj, int iContributePoint)
{
return lpObj->m_ContributePoint = iContributePoint;
};

//-> Completed
int GensSystem::AddContributePoint(LPOBJ lpObj, int iContributePoint)
{
lpObj->m_ContributePoint += iContributePoint;
return this->GDReqSaveContributePoint(lpObj);
};

//-> Completed
int GensSystem::SubContributePoint(LPOBJ lpObj, int iContributePoint)
{
lpObj->m_ContributePoint -= iContributePoint;

if (lpObj->m_ContributePoint < 0)
{
lpObj->m_ContributePoint = 0;
}

return this->GDReqSaveContributePoint(lpObj);
};

//-> Completed
int GensSystem::GetContributePoint(LPOBJ lpObj)
{
return lpObj->m_ContributePoint;
};

//-> Completed
signed int GensSystem::PkPenaltyAddNeedZenMapMove(LPOBJ lpObj)
{
if (gPkLimitFree)
{
if (this->IsMapBattleZone(lpObj->MapNumber))
{
return 1;
}
return 1;
}
return 0;
};

//-> Completed
void GensSystem::PkPenaltyDropInvenItem(LPOBJ lpObj)
{
if (gPkLimitFree)
{
if (this->IsMapBattleZone(lpObj->MapNumber))
{
this->b_PkPenaltyDropInvenItem = TRUE;
}
}
this->b_PkPenaltyDropInvenItem = FALSE;
};

//-> Completed
void GensSystem::PkPenaltyDropZen(LPOBJ lpObj)
{
if (gPkLimitFree)
{
if (this->IsMapBattleZone(lpObj->MapNumber))
{
this->b_PkPenaltyDropZen = TRUE;
}
}
this->b_PkPenaltyDropZen = FALSE;
};

//-> Completed
int GensSystem::SendPKPenaltyDebuff(LPOBJ lpObj)
{
if (lpObj->Type)
{
if (gPkLimitFree)
{
return this->IsMapBattleZone(lpObj->MapNumber);
}
}
return 0;
};

//-> Completed
void GensSystem::CalcContributePoint(LPOBJ lpObj, LPOBJ lpTargetObj)
{
int iInfluence;
int iTarInfluence;
int iContributePoint;
int iKillerContributePoint;
int iCalcLv;
int iAddValue;
int iSubValue;
int iAddBonusValue;
int iGensClassGap;

char szName[0x0B];

if (lpObj->Type && lpTargetObj->Type && this->IsMapBattleZone(lpObj->MapNumber) && this->IsMapBattleZone(lpTargetObj->MapNumber))
{
iInfluence = this->GetGensInfluence(lpObj);
iTarInfluence = this->GetGensInfluence(lpTargetObj);

if (iInfluence && iTarInfluence)
{
if (iInfluence != iTarInfluence)
{
memcpy(szName, lpTargetObj->Name, sizeof(lpTargetObj->Name));

if (this->ChkKillUserName(lpObj, szName) == 0)
{
iKillerContributePoint = this->GetContributePoint(lpTargetObj);

iContributePoint = this->GetContributePoint(lpObj);

if (iKillerContributePoint > 0 || iContributePoint <= 0)
{
iAddValue = 0; iAddBonusValue = 0;

if (lpObj->Level == lpTargetObj->Level)
{
iAddValue = 5; iAddBonusValue = 3;
}
else
{
if (lpObj->Level >= lpTargetObj->Level)
{
if (lpObj->Level > lpTargetObj->Level)
{
iCalcLv = lpObj->Level - lpTargetObj->Level;

if (iCalcLv < 51)
{
if (iCalcLv < 31 || iCalcLv > 50)
{
if (iCalcLv < 11 || iCalcLv > 30)
{
if (iCalcLv > 0 && iCalcLv <= 10)
{
iAddValue = 5; iSubValue = 3;
}
}
else
{
iAddValue = 3; iSubValue = 3;
}
}
else
{
iAddValue = 2; iSubValue = 1;
}
}
else
{
iAddValue = 1; iSubValue = 1;
}
}
}
else
{
iCalcLv = lpTargetObj->Level - lpObj->Level;

if (iCalcLv < 51)
{
if (iCalcLv < 31 || iCalcLv > 50)
{
if (iCalcLv < 11 || iCalcLv > 30)
{
if (iCalcLv > 0 && iCalcLv <= 10)
{
iAddValue = 5; iSubValue = 3;
}
}
else
{
iAddValue = 6; iSubValue = 3;
}
}
else
{
iAddValue = 6; iSubValue = 3;
}
}
else
{
iAddValue = 7; iSubValue = 3;
}
}
}

iAddBonusValue = 0;

iGensClassGap = lpObj->m_GensClass - lpTargetObj->m_GensClass;

if (iGensClassGap == 1)
{
if (lpObj->m_GensClass >= 9)
{
iAddBonusValue = 1;
}
else
{
iAddBonusValue = 3;
}
}
else
{
if (iGensClassGap == 2)
{
if (lpObj->m_GensClass >= 9)
{
iAddBonusValue = 2;
}
else
{
iAddBonusValue = 4;
}
}
else
{
if (iGensClassGap >= 3)
{
if (lpObj->m_GensClass >= 9)
{
iAddBonusValue = 3;
}
else
{
iAddBonusValue = 5;
}
}
}

if (lpObj->m_GensClass > 9 && iAddBonusValue + iAddValue >= this->GetNextContributePoint(lpObj))
{
GCServerMsgStringSend(lMsg.Get(3470), lpObj->m_Index, 1);
}

this->AddContributePoint(lpObj, iAddValue);

LogAddTD("[GensSystem] [%s][%s] Add ContributePoint[%d] - Result : Lv [%d] GensName [%s] / Lv [%d] GensName [%s]",
lpTargetObj->AccountID, lpTargetObj->Name, iAddValue, lpTargetObj->Level, this->GetGensInfluenceName(lpTargetObj), lpObj->Level, this->GetGensInfluenceName(lpObj));

this->SubContributePoint(lpObj, iSubValue);

LogAddTD("[GensSystem] [%s][%s] Sub ContributePoint[%d] - Result : Lv [%d] GensName [%s] / Lv [%d] GensName [%s]",
lpTargetObj->AccountID, lpTargetObj->Name, iSubValue, lpTargetObj->Level, this->GetGensInfluenceName(lpTargetObj), lpObj->Level, this->GetGensInfluenceName(lpObj));

if (iAddBonusValue > 0)
{
this->AddContributePoint(lpObj, iAddBonusValue);

GCServerMsgStringSend(lMsg.Get(3472), lpObj->m_Index, 1);

LogAddTD("[GensSystem] [%s][%s] Add BonusCP[%d] - Result : Lv [%d] GensName [%s] / Lv [%d] GensName [%s]",
lpObj->AccountID, lpObj->Name, iAddBonusValue, lpObj->Level, this->GetGensInfluenceName(lpObj), lpTargetObj->Level, this->GetGensInfluenceName(lpTargetObj));
}
}
}
}
}
else
{
LogAddTD("[GensSystem] - Error NONE_INFLUENCE - %s Line: %d", __FILE__, __LINE__);
}
}
}
};

//-> Completed
signed int GensSystem::ChkKillUserName(LPOBJ lpObj, char *szCharName)
{
int i = 0;

while (true)
{
if (i >= 10)
{
EnterCriticalSection((LPCRITICAL_SECTION)&criti);
this->InsertKillUserName(lpObj, szCharName);
LeaveCriticalSection((LPCRITICAL_SECTION)&criti);
return 0;
}

if (!strcmp(gObj[lpObj->m_Index].m_szCharName, szCharName))
break;

i++;
}

EnterCriticalSection((LPCRITICAL_SECTION)&criti);
++lpObj->m_KillUserCnt;
LeaveCriticalSection((LPCRITICAL_SECTION)&criti);

if (this->AbusingPenalty(lpObj, i))
return true;

return false;
};

//-> Completed
signed int GensSystem::AbusingPenalty(LPOBJ lpObj, int iKillUserIndex)
{
int iKillUserCnt = lpObj->m_KillUserCnt;

int bDBSave = 0;

if (lpObj->m_ContributePoint > 0)
{
bDBSave = 1;
}

// WebZen разработчики... :D
if (iKillUserCnt >= 3)
{
if (iKillUserCnt < 3 || iKillUserCnt > 5)
{
if (iKillUserCnt >= 6)
{
GCServerMsgStringSend(lMsg.Get(3450), lpObj->m_Index, 1);
}

EnterCriticalSection((LPCRITICAL_SECTION)&criti);

if (lpObj->m_KillUserCnt < 0)
{
lpObj->m_KillUserCnt = 0;
}

LeaveCriticalSection((LPCRITICAL_SECTION)&criti);

if (bDBSave)
{
this->GDReqSaveContributePoint(lpObj); return true;
}
return true;
}
else
{
GCServerMsgStringSend(lMsg.Get(3449), lpObj->m_Index, 1);
return false;
}
}
return false;
};

//-> Completed
int GensSystem::InsertKillUserName(LPOBJ lpObj, char *szCharName)
{
int iKillUserToCnt = lpObj->m_KillUserTotCnt;

if (iKillUserToCnt >= 10)
{
lpObj->m_KillUserTotCnt = 0; iKillUserToCnt = 0;
}

memset(lpObj->m_szCharName, 0, 0x0B);
strcpy(lpObj->m_szCharName, szCharName);

++lpObj->m_KillUserCnt;
++lpObj->m_KillUserTotCnt;

for (int i = 0; i < lpObj->m_KillUserTotCnt; ++i)
{
LogAddTD("[GensSystem] Abusing List [%s][%s] KillUserName[%s] Cnt[%d]", lpObj->AccountID, lpObj->Name, lpObj->m_szCharName, lpObj->m_KillUserCnt);
iKillUserToCnt = i + 1;
}
return iKillUserToCnt;
};

//-> Completed
void GensSystem::MoveInBattleZonePartySplit(LPOBJ lpObj)
{
PMSG_PARTYDELUSER pMsg;

if (gPkLimitFree != TRUE && lpObj->PartyNumber >= 0)
{
int pindex = gParty.GetIndex(lpObj->PartyNumber, lpObj->m_Index, lpObj->DBNumber);

if (pindex >= 0)
{
pMsg.Number = pindex;
CGPartyDelUser(&pMsg, lpObj->m_Index); GCResultSend(lpObj->m_Index, 0x41, 0x7);
}
}
};

//-> Completed
void GensSystem::AbusingInfoReset(LPOBJ lpObj)
{
if (!OBJMAX_RANGE(lpObj->m_Index))
return;

if (!gObjIsConnected(lpObj->m_Index))
{
if (this->IsRegGensInfluence(lpObj))
{
if (g_GensAbusingResetTime > 0 && GetTickCount() - lpObj->m_GensAbusingTick >= 60000 * g_GensAbusingResetTime)
{
EnterCriticalSection((LPCRITICAL_SECTION)&criti);

lpObj->m_GensAbusingTick = GetTickCount();

for (int i = 0; i < 10; ++i)
{
lpObj->m_KillUserCnt = 0;
memset(lpObj->m_szCharName, 0, 0x0B);
}

lpObj->m_KillUserTotCnt = 0;

LeaveCriticalSection((LPCRITICAL_SECTION)&criti);
}
}
else
{
lpObj->m_GensAbusingTick = GetTickCount();
}
}
};

//-> Completed
signed int GensSystem::CalGensClass(LPOBJ lpObj)
{
if (lpObj->m_ContributePoint < 200)
{
if (lpObj->m_ContributePoint < 224)
{
if (lpObj->m_ContributePoint < 248)
{
if (lpObj->m_ContributePoint < 272)
{
if (lpObj->m_ContributePoint < 296)
{
if (lpObj->m_ContributePoint < 320)
{
return 0;
}
else
{
return 14;
}
}
else
{
return 13;
}
}
else
{
return 12;
}
}
else
{
return 11;
}
}
else
{
return 10;
}
}
else
{
if (lpObj->m_ContributePoint > 8)
{
if (lpObj->m_ContributePoint > 32)
{
if (lpObj->m_ContributePoint > 56)
{
if (lpObj->m_ContributePoint > 80)
{
if (lpObj->m_ContributePoint > 104)
{
if (lpObj->m_ContributePoint > 128)
{
if (lpObj->m_ContributePoint > 152)
{
if (lpObj->m_ContributePoint > 176)
{
return 9;
}
else
{
return 8;
}
}
else
{
return 7;
}
}
else
{
return 6;
}
}
else
{
return 5;
}
}
else
{
return 4;
}
}
else
{
return 3;
}
}
else
{
return 2;
}
}
else
{
return 1;
}
}
return 0;
};

//-> Completed
int GensSystem::SetGensRanking(LPOBJ lpObj, int iGensRanking)
{
return lpObj->m_GensRanking = iGensRanking;
};

//-> Completed
int GensSystem::SetGensClass(LPOBJ lpObj, int iGensClass)
{
return lpObj->m_GensClass = iGensClass;
};

//-> Completed
int GensSystem::GetGensClass(LPOBJ lpObj)
{
return lpObj->m_GensClass;
};

//-> Completed
int GensSystem::GetNextContributePoint(LPOBJ lpObj)
{
if (this->IsRegGensInfluence(lpObj))
{
if (lpObj->m_NextContributePoint > 499)
{
if (lpObj->m_NextContributePoint > 1499)
{
if (lpObj->m_NextContributePoint > 2999)
{
if (lpObj->m_NextContributePoint > 5999)
{
if (lpObj->m_NextContributePoint > 9999)
{
return -2;
}
else
{
return 10000 - lpObj->m_NextContributePoint;
}
}
else
{
return 6000 - lpObj->m_NextContributePoint;
}
}
else
{
return 3000 - lpObj->m_NextContributePoint;
}
}
else
{
return 1500 - lpObj->m_NextContributePoint;
}
}
else
{
return 500 - lpObj->m_NextContributePoint;
}
}
else
{
return -1;
}

return 0;
};

//-> Completed
int GensSystem::SetGensMemberCount(int iInfluence, int iMemberCount)
{
if (iInfluence == VANERT_INFLUENCE)
{
this->iVanertMemberCount = iMemberCount;
}
else
{
if (iInfluence == DUPRIAN_INFLUENCE)
this->iDuprianMemberCount = iMemberCount;
}

return NONE_INFLUENCE;
};

//-> Completed
signed int GensSystem::GetGensMemberCount(int iInfluence)
{
if (iInfluence == VANERT_INFLUENCE)
{
return this->iVanertMemberCount;
}
else if (iInfluence == DUPRIAN_INFLUENCE)
{
return this->iDuprianMemberCount;
}
else
{
return -1;
}
};

//-> Completed
int GensSystem::ReqExDBGensRewardCheck(LPOBJ lpObj, int iInfluence)
{
if (!OBJMAX_RANGE(lpObj->m_Index))
return false;

if (gObjIsConnected(lpObj))
{
_tagPMSG_REQ_GENS_REWARD_CHECK_EXDB pMsg;

PHeadSetB((LPBYTE)&pMsg, 0xF8, sizeof(pMsg));

pMsg.bResult = 12;
strcpy(pMsg.Name, lpObj->Name);
pMsg.wIndexH = SET_NUMBERH(lpObj->m_Index);
pMsg.wIndexL = SET_NUMBERL(lpObj->m_Index);
pMsg.iInfluence = iInfluence;

if (wsJServerCli.DataSend((char*)&pMsg, pMsg.h.size))
return true;
}
return false;
};

//-> Completed
int GensSystem::ReqExDBGensRewardComplete(LPOBJ lpObj)
{
if (!OBJMAX_RANGE(lpObj->m_Index))
return false;

if (gObjIsConnected(lpObj))
{
_tagPMSG_REQ_GENS_REWARD_COMPLETE_EXDB pMsg;

PHeadSetB((LPBYTE)&pMsg, 0xF8, sizeof(pMsg));

pMsg.bResult = 14;
memcpy(pMsg.Name, lpObj->Name, 0x0A);
pMsg.wIndexH = SET_NUMBERHW(lpObj->m_Index);
pMsg.wIndexL = SET_NUMBERLW(lpObj->m_Index);

if (wsJServerCli.DataSend((char*)&pMsg, pMsg.h.size))
return true;
}
return false;
};

//-> Completed
int GensSystem::SendGensReward(LPOBJ lpObj, unsigned char btResult)
{
if (!OBJMAX_RANGE(lpObj->m_Index))
return false;

if (gObjIsConnected(lpObj))
{
_tagPMSG_SEND_GENS_REWARD pMsg;

PHeadSetB((LPBYTE)&pMsg, 0xF8, sizeof(pMsg));

pMsg.bResult = 10;
pMsg.bItemType = btResult;

if (DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size))
return true;
}
return false;
};

//-> Completed
signed int GensSystem::SendGensRewardItem(LPOBJ lpObj, int iGensClass)
{
int iIndex = lpObj->m_Index;

int iItemCount = iGensClass - 1;

if (iItemCount - 1 >= 0)
{
iItemCount = this->iIndex * iItemCount + 5;

if (iItemCount > 0)
{
int iItemNumber = ((this->iIndex * iItemCount + 4) + (this->iIndex * iItemCount + 3)) << 9;

if (this->GensRewardInventoryCheck(lpObj, iItemCount))
{
for (int i = 0; i < iItemCount; ++i)
{
ItemSerialCreateSend(iIndex, 240, 0, 0, iItemNumber, 0, 0, 0, 0, 0, 0, 0, 0);
}
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
return false;
};

//-> Completed
bool GensSystem::GensRewardInventoryCheck(LPOBJ lpObj, int iItemCount)
{
unsigned char blank = NULL;

int iCount = 0;

for (int h = 0; h < 8; ++h)
{
for (int w = 0; w < 8; ++w)
{
if (*(BYTE*)(lpObj->pInventoryMap + (h) * 8 + (w)) == 255)
{
if (gObjOnlyInventoryRectCheck(lpObj->m_Index, w, h, 1, 1))
{
++iCount;
}
}
}
}
return iItemCount <= iCount;
};

//-> Completed
int GensSystem::ReqExDBGensMemberCount(LPOBJ lpObj)
{
if (!OBJMAX_RANGE(lpObj->m_Index))
return false;

if (gObjIsConnected(lpObj))
{
_tagPMSG_REQ_GENS_MEMBER_COUNT pMsg;

PHeadSetB((LPBYTE)&pMsg, 0xF8, sizeof(pMsg));

pMsg.bResult = 15;
pMsg.wIndexH = SET_NUMBERHW(lpObj->m_Index);
pMsg.wIndexL = SET_NUMBERLW(lpObj->m_Index);

if (wsJServerCli.DataSend((char*)&pMsg, pMsg.h.size))
return true;
}
return false;
};

//-> Completed
int GensSystem::ReqExDBSetGensRewardDay(void)
{
_tagPMSG_SET_GENS_REWARD_DAY_EXDB pMsg;

PHeadSetB((LPBYTE)&pMsg, 0xF8, sizeof(pMsg));
pMsg.bRewardDay = 17;

return wsJServerCli.DataSend((char*)&pMsg, pMsg.h.size);
};

//-> Completed
int GensSystem::ReqExDBSetGensRanking(void)
{
_tagGENS_RANKING pMsg;

PHeadSetB((LPBYTE)&pMsg, 0xF8, sizeof(pMsg));
pMsg.bRanking = 18;

return wsJServerCli.DataSend((char*)&pMsg, pMsg.h.size);
};

//-> Not Completed
int GensSystem::LoadData(char *lpszFileName)
{
int iType = 0;
SMDToken Token = GetToken();
int i = 0;
unsigned long dwError = 0;
int iGensClass = 0;
int iRewardItemType = 0;
int iRewardItemCount = 0;
unsigned char btRankingKind = NULL;
int iRankingValue = 0;
int iRewardItemNumber = 0;

return 0;
};

//-> Completed
int GensSystem::ReqGensRewardDay(LPOBJ lpObj)
{
_tagPMSG_REQ_GENS_REWARD_DAY pMsg;

PHeadSetB((LPBYTE)&pMsg, 0xF8, sizeof(pMsg));
pMsg.bRewardDay = 19;
pMsg.bIndexH = SET_NUMBERH(lpObj->m_Index);
pMsg.bIndexL = SET_NUMBERL(lpObj->m_Index);

return wsJServerCli.DataSend((char*)&pMsg, pMsg.h.size);
};

//--------------------------------------------------



//--------------------------------------------------

//void ProtocolCore(BYTE protoNum, BYTE * aRecv, int aLen, int aIndex, BOOL Encrypt, int serial)

//-> Completed
void CGReqRegGensMember(_tagPMSG_REQ_REG_GENS_MEMBER *lpMsg, int iIndex)
{
unsigned char bRet;

LPOBJ lpObj = &gObj[iIndex];

_GUILD_INFO_STRUCT *lpGuildInfo = gObj[iIndex].lpGuild;

if (!OBJMAX_RANGE(iIndex)) return;

if (gObjIsConnected(iIndex))
{
_tagPMSG_ANS_REG_GENS_MEMBER_EXDB pMsg;

pMsg.bInfluence = lpMsg->bResult;

//[GensSystem] [%s][%s] Gens Request - Join [%s]
if (!g_GensSystem.GetGensInfluence(lpObj))
{
pMsg.bResult = 0; bRet = 1;
}

//GensSystem] [%s][%s] Gens Joining Failed to Gens be Same : [%s]
if (g_GensSystem.GetGensInfluence(lpObj) > 0)
{
pMsg.bResult = 1; bRet = 0;
}

//[GensSystem] [%s][%s] Gens Joining Failed to Below Gens leaving Time
//if (g_GensAbusingResetTime < 60)
//{
// pMsg.bResult = 2; bRet = 1;
//}

//[GensSystem] [%s][%s] Gens Joining Failed to Below 50Lv
if (lpObj->Level < 50)
{
pMsg.bResult = 3; bRet = 0;
}

//[GensSystem] [%s][%s] Gens Joining Failed to Gens be Different Guild Leader [%s]
if (lpObj->GuildStatus >= 0)
{
pMsg.bResult = 4; bRet = 0;
}

//[GensSystem] [%s][%s] Gens Joining Failed to Not Register Guild Leader GuildName [%s]
if (lpObj->GuildStatus == GUILD_MASTER)
{
pMsg.bResult = 5; bRet = 0;
}

//[GensSystem] [%s][%s] Gens Joining Failed to Already Partymember
if (lpObj->PartyNumber >= 0)
{
pMsg.bResult = 6; bRet = 0;
}

//[GensSystem] [%s][%s] Gens Joining Failed to Union GuildMaster
if (lpGuildInfo != NULL && lpGuildInfo->iGuildUnion)
{
pMsg.bResult = 7; bRet = 0;
}

if (bRet)
{
g_GensSystem.ReqRegGensMember(lpObj, lpMsg->bResult);
}
else
{
pMsg.bIndexH = SET_NUMBERH(iIndex);
pMsg.bIndexL = SET_NUMBERL(iIndex);
DGAnsRegGensMember((_tagPMSG_ANS_REG_GENS_MEMBER_EXDB*)&pMsg);
}
}
}

//-> Completed
void CGReqSecedeGensMember(_tagPMSG_REQ_SEGEDE_GENS_MEMBER *lpMsg, int iIndex)
{
if (!OBJMAX_RANGE(iIndex))
return;

LPOBJ lpObj = &gObj[iIndex];

unsigned char bRet = 1;

if (gObjIsConnected(iIndex))
{
_tagPMSG_ANS_SECEDE_GENS_MEMBER_EXDB pMsg;

if (!g_GensSystem.IsInfluenceNPC(lpObj))
{
pMsg.bResult = 3; bRet = 0;
}

//[GensSystem] [%s][%s] Gens Leaving Failed to Not Register Gens
if (!g_GensSystem.GetGensInfluence(lpObj))
{
pMsg.bResult = 1; bRet = 0;
}
else
{
pMsg.bResult = 0; bRet = 1;
}

if (bRet)
{
g_GensSystem.ReqSecedeGensMember(lpObj);
}
else
{
pMsg.bIndexH = SET_NUMBERH(iIndex);
pMsg.bIndexL = SET_NUMBERL(iIndex);
DGAnsSecedeGensMember((_tagPMSG_ANS_SECEDE_GENS_MEMBER_EXDB*)&pMsg);
}
}
}

//-> Completed
void CGReqGensReward(_tagPMSG_GENS_REWARD_CODE *lpMsg, int iIndex)
{
if (!OBJMAX_RANGE(iIndex))
return;

unsigned char bRet = 0; //Not Used

LPOBJ lpObj = &gObj[iIndex];

if (gObjIsConnected(lpObj))
{
g_GensSystem.ReqExDBGensRewardCheck(lpObj, lpMsg->bReward);
}
}

//-> Completed
void CGReqGensMemberInfo(_tagPMSG_REQ_GENS_INFO *lpMsg, int iIndex)
{
if (!OBJMAX_RANGE(iIndex)) return;

LPOBJ lpObj = &gObj[iIndex];

if (gObjIsConnected(lpObj))
{
if (g_GensSystem.IsRegGensInfluence(lpObj))
{
g_GensSystem.ReqExDBGensInfo(lpObj);
}
}
}

//--------------------------------------------------



//--------------------------------------------------

// void ExDataServerProtocolCore(BYTE protoNum, LPBYTE aRecv, int aLen)

//-> Completed
void DGAnsGensInfo(_tagPMSG_ANS_GENS_INFO_EXDB *lpMsg)
{
int iObjIndex = MAKE_NUMBERW(lpMsg->wIndexH, lpMsg->wIndexL);

LPOBJ lpObj = &gObj[iObjIndex];

if (gObjIsConnectedGP(iObjIndex))
{
if (lpMsg->iGensClass)
{
g_GensSystem.SetUserBattleZoneEnable(lpObj, BATTLE_ZONE_BLOCK);
g_GensSystem.SetGensInfluence(lpObj, NONE_INFLUENCE);
g_GensSystem.SetContributePoint(lpObj, 0);
}
else
{
if (lpMsg->bInfluence != LEAVED_INFLUENCE && lpMsg->bInfluence)
{
g_GensSystem.SetUserBattleZoneEnable(lpObj, BATTLE_ZONE_UNBLOCK);
}

g_GensSystem.SetGensInfluence(lpObj, lpMsg->bInfluence);
g_GensSystem.SetContributePoint(lpObj, lpMsg->iContributePoint);
g_GensSystem.SetGensRanking(lpObj, lpMsg->iGensRanking);
g_GensSystem.SetGensClass(lpObj, lpMsg->iGensClass);
g_GensSystem.GensViewportListProtocol(lpObj);
}

LogAddTD("[GensSystem] Get DB GensInfo [%s][%s] GensName [%s]", lpObj->AccountID, lpObj->Name, g_GensSystem.GetGensInfluenceName(lpObj));

g_GensSystem.SendGensInfo(lpObj);

if (g_GensSystem.IsMapBattleZone(lpObj->MapNumber))
{
if (!g_GensSystem.IsUserBattleZoneEnable(lpObj))
{
gObjTeleport(lpObj->m_Index, 0, 140, 125);
GCServerMsgStringSend(lMsg.Get(3451), lpObj->m_Index, 1);
}
}
}
else
{
LogAddTD("error-L2 : Index %s %d", __FILE__, __LINE__);
}
}

//-> Completed
void DGAnsRegGensMember(_tagPMSG_ANS_REG_GENS_MEMBER_EXDB *lpMsg)
{
int iObjIndex = MAKE_NUMBERW(lpMsg->bIndexH, lpMsg->bIndexL);

LPOBJ lpObj = &gObj[iObjIndex];

if (gObjIsConnectedGP(lpObj->m_Index))
{
_tagPMSG_ANS_REG_GENS_MEBMER pMsg;

if (!lpMsg->bResult)
{
g_GensSystem.SetGensInfluence(lpObj, lpMsg->bInfluence);
g_GensSystem.SetUserBattleZoneEnable(lpObj, BATTLE_ZONE_UNBLOCK);
g_GensSystem.GensViewportListProtocol(lpObj);
g_GensSystem.SetContributePoint(lpObj, g_GensInitialContributePoint);
g_GensSystem.GDReqSaveContributePoint(lpObj);
}

PHeadSubSetBE((LPBYTE)&pMsg, 0xF8, 0x02, sizeof(pMsg));
pMsg.bResult = lpMsg->bResult;
pMsg.iInfluence = lpMsg->bInfluence;
DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);

switch (lpMsg->bResult)
{
case 0:
LogAddTD("[GensSystem] [%s][%s] Gens Request - Join [%s]", lpObj->AccountID, lpObj->Name, g_GensSystem.GetGensInfluenceName(lpObj));
break;

case 1:
LogAddTD("[GensSystem] [%s][%s] Gens Joining Failed to Gens be Same : [%s]", lpObj->AccountID, lpObj->Name);
break;

case 2:
LogAddTD("[GensSystem] [%s][%s] Gens Joining Failed to Below Gens leaving Time", lpObj->AccountID, lpObj->Name);
break;

case 3:
LogAddTD("[GensSystem] [%s][%s] Gens Joining Failed to Below 50Lv", lpObj->AccountID, lpObj->Name);
break;

case 4:
LogAddTD("[GensSystem] [%s][%s] Gens Joining Failed to Gens be Different Guild Leader [%s]", lpObj->AccountID, lpObj->Name, lpObj->lpGuild->Names);
break;

case 5:
LogAddTD("[GensSystem] [%s][%s] Gens Joining Failed to Not Register Guild Leader GuildName [%s]", lpObj->AccountID, lpObj->Name, lpObj->lpGuild->Name);
break;

case 6:
LogAddTD("[GensSystem] [%s][%s] Gens Joining Failed to Already Partymember", lpObj->AccountID, lpObj->Name);
break;

case 7:
LogAddTD("[GensSystem] [%s][%s] Gens Joining Failed to Union GuildMaster", lpObj->AccountID, lpObj->Name);
break;

default:
return;
}
}
else
{
LogAddTD("error-L2 : Index %s %d", __FILE__, __LINE__);
}
}

//-> Completed
void DGAnsSecedeGensMember(_tagPMSG_ANS_SECEDE_GENS_MEMBER_EXDB *lpMsg)
{
int iObjIndex = MAKE_NUMBERW(lpMsg->bIndexH, lpMsg->bIndexL);

LPOBJ lpObj = &gObj[iObjIndex];

if (gObjIsConnectedGP(lpObj->m_Index))
{
switch (lpMsg->bResult)
{
case 0:
LogAddTD("[GensSystem] [%s][%s] Gens Request - Leave [%s]", lpObj->AccountID, lpObj->Name, g_GensSystem.GetGensInfluenceName(lpObj));
break;

case 1:
LogAddTD("[GensSystem] [%s][%s] Gens Leaving Failed to Not Register Gens", lpObj->AccountID, lpObj->Name);
break;

case 2:
LogAddTD("[GensSystem] [%s][%s] Gens Leaving Failed to GuildMaster GensName [%s]", lpObj->AccountID, lpObj->Name, g_GensSystem.GetGensInfluenceName(lpObj));
break;

case 3:
LogAddTD("[GensSystem] [%s][%s] Gens Leaving Failed to Not Influence NPC : [%s]", lpObj->AccountID, lpObj->Name, g_GensSystem.GetGensInfluenceName(lpObj));
break;

default:
break;
}

if (!lpMsg->bResult)
{
g_GensSystem.SetGensInfluence(lpObj, LEAVED_INFLUENCE);
g_GensSystem.SetUserBattleZoneEnable(lpObj, BATTLE_ZONE_BLOCK);
g_GensSystem.SetContributePoint(lpObj, 0);

memset(lpObj->m_szCharName, 0, sizeof(lpObj->m_szCharName));

lpObj->m_KillUserCnt = 0; lpObj->m_KillUserTotCnt = 0;

g_GensSystem.GensViewportListProtocol(lpObj);
g_GensSystem.SetGensClass(lpObj, 0);
g_GensSystem.SetGensRanking(lpObj, 0);
}

_tagPMSG_ANS_SECEDE_GENS_MEMBER_EXDB pMsg;

PHeadSubSetBE((LPBYTE)&pMsg, 0xF8, 0x04, sizeof(pMsg));
pMsg.bResult = lpMsg->bResult;
DataSend(lpObj->m_Index, (LPBYTE)&pMsg, 0x05);
}
else
{
LogAddTD("error-L2 : Index %s %d", __FILE__, __LINE__);
}
}

//-> Completed
void DGAnsAbusingInfo(_tagPMSG_ANS_ABUSING_INFO *lpMsg)
{
//int iObjIndex = MAKE_NUMBERW(lpMsg->bIndexH, lpMsg->bIndexL);

//LPOBJ lpObj = &gObj[iObjIndex];

//if (gObjIsConnectedGP(iObjIndex))
//{
// for (int i = 0; i < 10; ++i)
// {
// if (strlen(lpMsg->Name) > 0)
// {
// //lpObj->m_szTargetCharName[0] = 0;
// //memcpy(lpObj->m_szCharName, &lpMsg->Name[0], 0x0A);
// //lpObj->m_KillUserCnt = lpMsg->iKillUserCount;
// //++lpObj->m_KillUserTotCnt;
// }
// }
//}
//else
//{
// LogAddTD("error-L2 : Index %s %d", __FILE__, __LINE__);
//}
}

//-> Completed
void DGAnsGensReward(_tagPMSG_ANS_GENS_REWARD_EXDB *lpMsg)
{
unsigned char btResult;

int iObjIndex = MAKE_NUMBERW(0, 0);

LPOBJ lpObj = &gObj[iObjIndex];

if (gObjIsConnectedGP(iObjIndex))
{
if (lpMsg->bResult)
{
btResult = lpMsg->bResult;
}
else
{
if (g_GensSystem.SendGensRewardItem(lpObj, lpMsg->iGensClass))
{
btResult = 0;
g_GensSystem.ReqExDBGensRewardComplete(lpObj);
}
else
{
btResult = 3;
}
}

LogAddTD("[GensSystem] Send Gens Ranking Reward [%s][%s] Result [%d]", lpObj->AccountID, lpObj->Name, btResult);

g_GensSystem.SendGensReward(lpObj, btResult);
}
else
{
LogAddTD("error-L2 : Index %s %d", __FILE__, __LINE__);
}
}

//-> Completed
void DGAnsGensMemberCount(_tagPMSG_ANS_GENS_MEMBER_COUNT_EXDB *lpMsg)
{
g_GensSystem.SetGensMemberCount(1, lpMsg->iVanertMemberCount);
g_GensSystem.SetGensMemberCount(2, lpMsg->iDuprianMemberCount);
}

//-> Completed
void DGAnsGensRewardDayCheck(_tagPMSG_ANS_GENS_REWARD_DAY_CHECK_EXDB *lpMsg)
{
int iObjIndex = MAKE_NUMBERW(lpMsg->bIndexH, lpMsg->bIndexL);

LPOBJ lpObj = &gObj[iObjIndex];

if (gObjIsConnectedGP(iObjIndex))
{
if (lpMsg->iRewardDay)
{
GCServerMsgStringSend(lMsg.Get(3459), iObjIndex, 1);
}
}
else
{
LogAddTD("error-L2 : Index %s %d", __FILE__, __LINE__);
}
}

//--------------------------------------------------

Кредиты: Мои
Спасибы: HermeX - Viewport Packet

Simp1e

#1
Отличная работа пригодится     а еще интересно чего нехвотает ток протокола? или же неполностью GensSystem.cpp декомпилировал

Mr.Kernighan

Некоторые моменты из протокола нужно закончить.
Класс вроде закончен... Есть логические ошибки, проверенно.

Crazzy-

Керни . ай молодец какой))  только забывай про hexrays у нее с if&else большие проблемы, лучше ети моменты самому через disasm декомпилить, ато что за хрень
if (this->IsRegGensInfluence(lpObj))
{
if (lpObj->m_NextContributePoint > 499)
{
if (lpObj->m_NextContributePoint > 1499)
{
if (lpObj->m_NextContributePoint > 2999)
{
if (lpObj->m_NextContributePoint > 5999)
{
if (lpObj->m_NextContributePoint > 9999)
{
return -2;
}
else
{
return 10000 - lpObj->m_NextContributePoint;
}
}
else
{
return 6000 - lpObj->m_NextContributePoint;
}
}
else
{
return 3000 - lpObj->m_NextContributePoint;
}
}
else
{
return 1500 - lpObj->m_NextContributePoint;
}
}
else
{
return 500 - lpObj->m_NextContributePoint;
}
}
else
{
return -1;
}

хермекс пакеты имеет , ммм у него есть пятый сезон походу с пдбшником ))))))))

Mr.Kernighan

#4
У него много чего есть интересного, чего он не договаривает ыы

Ну ветвление не красивое конечно, но все логично, такие моменты собственно программист сам уже форматирует как ему больше нравится, а мне заниматься этим некогда, делал как говориться решением в лоб. Надеюсь, может будет еще новое поколение людей которое сможет и будет этим пользоваться.

Похожие темы (5)