📄 dragonloginserver.cpp
字号:
#include "StdAfx.h"
#include "packed.h"
#include "servertable.h"
#include "MAIN.H"
#include "Scrp_exe.H"
#include "ID.h"
#include "SealStone.h"
#include "Debug.h"
#include "mainheader.h"
#include "monitor.h"
#include "Citem.h"
#include "Pay.h"
#include "ChrLog.h"
#include "dragonloginserver2.h" // 010406 YGI
#include "network.h"
#include "LottoDBMgr.h"
#include "ShopDemon.h"
t_connection connections[LOGIN_MAX_CONNECTIONS] = {0,};
extern bool CheckRookieServerAble(const int iLv);
extern int CheckIDAutherizing(t_packet &packet, const int cn);
extern HWND g_hWnd;
extern int CheckHandleByKein( t_packet *p, t_connection c[], int cn ); // 0308 YGI
extern int CheckHandleByNationWar(t_packet *p, t_connection c[], int cn ); // 010915 LTS
extern void SendThrowDice( char type, short int cn ); // op_chr_status.cpp
extern void SendCreateAbility( short int cn );
extern void CheckStartMap( t_connection c[], short int cn, int &StartPosition ); // 1004 YGI
extern int CheckGameMakeTool(char *id, char ip[40]); // 020830 YGI
extern int GetUserAge(const char* szID); // 030929 kyo
extern bool IsLimitedTime(); // 030929 kyo
/////////////////////////////////////////////////////////////////////////////////
//
// User Functions..
//
char g_LogFName[255];
char Queue_Out_Buffer[MAX_SERVER_QUEUE_OUT_BUFFER];
char MapName[ MAX_PATH];
/////////////////////////////////////////////////////////////////////////////////
//
// User Functions....
//
//-----------------------------------------------------------------------------
#define MAX_MSG_COUNT 25
static int Msg[ MAX_MSG_COUNT][ MAX_PATH];
int MsgCount;
//---------------------------------------------------------------------------------
int QueuePacket( t_connection c[], int cn, t_packet *packet, int type )
{
char temp[MM_MAX_PACKET_SIZE+6] = {0,};
DWORD dwUserID = c[cn].dwUserID;
DWORD dwLength = HEADER_SIZE + packet->h.header.size;
temp[0] = (BYTE)PTCL_DB_ANSWER;
memcpy(temp+1,&dwUserID,4);
memcpy(temp+1+4,packet,dwLength);
if( 1+4+dwLength >= MM_MAX_PACKET_SIZE )
{
// it's a big bug..
// _asm int 3;
}
else
{
temp[ 1+4+dwLength ]=0;
}
g_pServerTable->Send( c[cn].dwConIndex, temp, dwLength+5);
return true;
}
//---------------------------------------------------------------------------------
int DequeuePacket(t_connection c[], int cn, t_packet *packet, int type)
{
return 1;
}
//---------------------------------------------------------------------------------
void closeconnection(t_connection c[], int cn, const eCloseConnectionType errnum)
{
char temp[5] = {0,};
DWORD dwUserID = c[cn].dwUserID;
temp[0] = (BYTE)PTCL_DB_TO_AGENT_REQUEST_DISCONNECT_USER_BY_ID;
memcpy(temp+1,&dwUserID,4);
switch( errnum )
{
case CCT_ID_NOT_EXIST:
case CCT_WRONG_PASSWORD:
case CCT_ID_USING_NOW:
case CCT_PAYMENT_NEED:
break;
case CCT_INVALID_CLIENT :
{
::MyLog( LOG_NORMAL, "Invalid Client Version[ %d ]", dwUserID );
}break;
case CCT_NORMAL :
{
::MyLog( LOG_NORMAL, "Normal Disconnection[ %d ]", dwUserID );
}break;
case CCT_AGENT_ORDER :
{
::MyLog( LOG_NORMAL, "Agent order : Disconnection[ %d ]", dwUserID );
}break;
}
if( !g_pServerTable->Send( c[cn].dwConIndex, temp, 5) )
{
MyLog( LOG_NORMAL,"SEND: Failed(to %d)", c[cn].dwConIndex);
}
}
//---------------------------------------------------------------------------------
int HandleAccepting(t_connection c[], SOCKET lsock)
{
return(1);
}
//---------------------------------------------------------------------------------
int HandleReading(t_connection c[], int cn)
{
return(1);
}
//---------------------------------------------------------------------------------
int HandleCommand(t_connection c[], DWORD dwIndex, t_packet *packet, DWORD dwUserID, int cn)
{
const int ttype = packet->h.header.type;
switch(ttype)
{
case CMD_NONE :
break;
case CMD_PING :
break;
case CMD_LOST_CONNECTION :
closeconnection(c, cn, CCT_NORMAL);
break;
case CMD_IM_GAME_SERVER :
break;
case CMD_ACCESS_CHAR_DB : // 010613 YGI
{
const int server_id = packet->u.server_access_char_db.server_id;
memcpy(c[cn].id, packet->u.server_access_char_db.id, ID_LENGTH);
memcpy(c[cn].name, packet->u.server_access_char_db.name, NM_LENGTH);
if(GetCharDB_SQL(c, cn) != 1) break;
if(GetCharGameDB_SQL(c, cn) != 1 ) break;
LPCHARLIST ch = &c[cn].chrlst;
if(!CheckRookieServerAble(ch->Level))//021230 lsw
{
break;
}
ch->server_id = cn;
// 030923 HK YGI
int ret = get_BinaryData_from_Chr_Info( (UCHAR *)ch->Ws,
(UCHAR *)ch->Ps,
(UCHAR *)ch->Skill,
(UCHAR *)ch->skillexp,
(UCHAR *)ch->tac_skillEXP,
(UCHAR *)var[cn],
(UCHAR *)ch->inv,
(UCHAR *)ch->equip,
(UCHAR *)ch->quick,
(UCHAR *)ch->party,
(UCHAR *)ch->relation,
(UCHAR *)ch->employment,
(UCHAR *)ch->Item,
c[cn].id, c[cn].name ) ;
if( ret != 1 ) break;
ret = get_BinaryData_from_Chr_Info2 ( (UCHAR *)c[cn].chrlst.bank, c[cn].id, c[cn].name ) ;
if( ret != 1 ) break;
/////////////////////////////
ResetCharInfo(var[cn], ch);
// PutEventItem( 2, &c[cn] ); // 捞亥飘侩 酒捞袍 持绢 林扁 // BBD 040308 Map辑滚啊 林扁肺 沁澜
int refresh_inventory = CheckEventITem( ch );
CheckEventJoin(&c[cn].chrlst); // 020115 LTS
/////////////////////////////////////////////////////////////////////////////////////
memset(packet, 0, sizeof(t_packet));
packet->h.header.type = CMD_ACCEPT_CHAR_DB;
packet->h.header.size = sizeof(t_server_accept_char_db);
t_server_accept_char_db *tp = &(packet->u.server_accept_char_db);
strcpy( tp->name, c[cn].name );// 030923 HK YGI
tp->server_id = server_id;
tp->Level = ch->Level;
tp->Exp = ch->Exp;
tp->Gender = ch->Gender;
tp->Face = ch->Face;
tp->nGuildCode = ch->nGuildCode; // CSD-030324
tp->Class = ch->Class;
tp->Spell = ch->Spell;
tp->Job = ch->Job; // 0212 YGI
tp->Str = ch->Str;
tp->Con = ch->Con;
tp->Dex = ch->Dex;
tp->Wis = ch->Wis;
tp->Int = ch->Int;
tp->MoveP = ch->MoveP;
tp->Char = ch->Char;
tp->Endu = ch->Endu;
tp->Moral = ch->Moral;
tp->Money = ch->Money;
tp->nLife = ch->Hp;
tp->nMaxHp = ch->HpMax;
tp->nMana = ch->Mana;
tp->nMaxMp = ch->ManaMax;
tp->nHungry = ch->Hungry;
tp->nMaxHungry = ch->HungryMax;
tp->Condition = ch->Condition;
tp->SprNo = ch->SprNo;
tp->X = ch->X;
tp->Y = ch->Y;
memcpy( tp->MapName, ch->MapName, 20);
tp->Peacests = ch->Peacests;
tp->Sight = ch->Sight;
tp->BodyR = ch->BodyR;
tp->BodyG = ch->BodyG;
tp->BodyB = ch->BodyB;
tp->ClothR = ch->ClothR;
tp->ClothG = ch->ClothG;
tp->ClothB = ch->ClothB;
tp->Age = ch->Age;
tp->Luck = ch->Luck;
tp->wsps = ch->wsps;
memcpy( &tp->nation, &ch->name_status, sizeof( DWORD ) ); // 1004 YGI
tp->accessory[0] = ch->accessory[0];
tp->accessory[1] = ch->accessory[1];
tp->accessory[2] = ch->accessory[2];
tp->accessory[3] = ch->accessory[3];
ch->mantle = ch->equip[ WT_NECK].item_no;
tp->mantle = ch->mantle;
tp->bAlive = ch->bAlive;
tp->openhouse = ch->openhouse;
tp->disease[0] = ch->disease[0];
tp->disease[1] = ch->disease[1];
tp->disease[2] = ch->disease[2];
tp->disease[3] = ch->disease[3];
tp->disease[4] = ch->disease[4];
tp->disease[5] = ch->disease[5];
tp->total_id = ch->total_id;
tp->nPoison = ch->nPoison;
tp->nCurse = ch->nCurse;
tp->nFire = ch->nFire;
tp->nIce = ch->nIce;
tp->nElect = ch->nElect;
tp->nHoly = ch->nHoly;
tp->viewtype = ch->viewtype; // 0212 YGI
tp->social_status = ch->social_status;
tp->fame = ch->fame;
tp->fame_pk = ch->fame_pk; // 010915 LTS //Fame_PK -> NWCharacter肺 背眉 DB俊绰 角力肺 NWCharacter狼 蔼捞 甸绢癌聪促.
tp->NWCharacter = ch->NWCharacter; // 010915 LTS
tp->EventJoin = ch->EventJoin; // 020115 LTS
tp->nUserAge = GetUserAge(c[cn].id); // 030929 kyo
memcpy(tp->aStepInfo, ch->aStepInfo, sizeof(ch->aStepInfo));
if(!QueuePacket(c, cn, packet, 1)){break;}
/////////////////////////////////////////////////////////////////////////
memset(packet, 0, sizeof(t_packet));
t_server_accept_char_game_db *tsac = &(packet->u.server_accept_char_game_db);
packet->h.header.type = CMD_ACCEPT_CHAR_GAME_DB;
packet->h.header.size = sizeof(t_server_accept_char_game_db);
strcpy( tsac->name, c[cn].name );// 030923 HK YGI
tsac->server_id = server_id;
tsac->BankMoney = ch->BankMoney;
memcpy( &tsac->win_defeat, &ch->WinLoseScore, sizeof( DWORD ) );
tsac->LadderScore = ch->LadderScore;
tsac->LastLoan = ch->LastLoan;
tsac->nk3 = ch->nk[N_VYSEUS];
tsac->nk4 = ch->nk[N_ZYPERN];
tsac->nk6 = ch->nk[N_YILSE];
tsac->killmon = ch->killmon;
tsac->killanimal = ch->killanimal;
tsac->killpc = ch->killpc;
tsac->reserved_point= ch->reserved_point;
tsac->Tactics = ch->Tactics;
if(!QueuePacket(c, cn, packet, 1)) break;
///////////////////////////////////////////////////////////////////////
memset(packet, 0, sizeof(t_packet));
packet->h.header.type = CMD_ACCEPT_BINARY_DATA;
packet->h.header.size = sizeof(t_server_accept_binary_data);
packet->u.server_accept_binary_data.server_id = server_id;
strcpy( packet->u.server_accept_binary_data.name, c[cn].name );// 030923 HK YGI
memcpy((UCHAR *)packet->u.server_accept_binary_data.Ws, (UCHAR *)ch->Ws, SIZE_OF_WS);
memcpy((UCHAR *)packet->u.server_accept_binary_data.Ps, (UCHAR *)ch->Ps, SIZE_OF_PS);
memcpy((UCHAR *)packet->u.server_accept_binary_data.Skill, (UCHAR *)ch->Skill, SIZE_OF_SKILL);
memcpy((UCHAR *)packet->u.server_accept_binary_data.skillexp, (UCHAR *)ch->skillexp, SIZE_OF_SKILL_EXP);
memcpy((UCHAR *)packet->u.server_accept_binary_data.tac_skillEXP, (UCHAR *)ch->tac_skillEXP, SIZE_OF_TAC_SKILL_EXP);
memcpy((UCHAR *)packet->u.server_accept_binary_data.equip, (UCHAR *)ch->equip, SIZE_OF_EQUIP);
memcpy((UCHAR *)packet->u.server_accept_binary_data.quick, (UCHAR *)ch->quick, SIZE_OF_QUICK);
memcpy((UCHAR *)packet->u.server_accept_binary_data.party, (UCHAR *)ch->party, SIZE_OF_PARTY);
memcpy((UCHAR *)packet->u.server_accept_binary_data.relation, (UCHAR *)ch->relation, SIZE_OF_RELATION);
memcpy((UCHAR *)packet->u.server_accept_binary_data.employment, (UCHAR *)ch->employment, SIZE_OF_EMPLOYMENT);
if(!QueuePacket(c, cn, packet, 1)) break;
///////////////////////////////////////////////////////////////////////
memset(packet, 0, sizeof(t_packet));
packet->h.header.type = CMD_ACCEPT_SCRIPT_DATA;
packet->h.header.size = sizeof(t_server_accept_script_data);
packet->u.server_accept_script_data.server_id = server_id;
strcpy( packet->u.server_accept_script_data.name, c[cn].name );// 030923 HK YGI
memcpy((UCHAR *)packet->u.server_accept_script_data.script_var, (UCHAR *)var[cn], SIZE_OF_SCRIPT_VAR);
if(!QueuePacket(c, cn, packet, 1)) break;
///////////////////////////////////////////////////////////////////////
memset(packet, 0, sizeof(t_packet));
packet->h.header.type = CMD_ACCEPT_INV_DATA;
packet->h.header.size = sizeof(t_server_accept_inv_data);
packet->u.server_accept_inv_data.server_id = server_id;
strcpy( packet->u.server_accept_inv_data.name, c[cn].name );// 030923 HK YGI
memcpy((UCHAR *)packet->u.server_accept_inv_data.inv, (UCHAR *)ch->inv, SIZE_OF_INV);
//021030 YGI
packet->u.server_accept_inv_data.refresh_inventory = refresh_inventory;
if(!QueuePacket(c, cn, packet, 1)) break;
///////////////////////////////////////////////////////////////////////
memset(packet, 0, sizeof(t_packet));
packet->h.header.type = CMD_ACCEPT_ITEM_DATA;
packet->h.header.size = sizeof(t_server_accept_item_data);
packet->u.server_accept_item_data.server_id = server_id;
strcpy( packet->u.server_accept_item_data.name, c[cn].name );// 030923 HK YGI
memcpy((UCHAR *)packet->u.server_accept_item_data.Item, (UCHAR *)c[cn].chrlst.Item, SIZE_OF_ITEMINDEX);
if(!QueuePacket(c, cn, packet, 1)) break;
///////////////////////////////////////////////////////////////////////
memset(packet, 0, sizeof(t_packet));
packet->h.header.type = CMD_ACCEPT_BANKITEM_DATA;
packet->h.header.size = sizeof(t_server_accept_bankitem_data);
packet->u.server_accept_bankitem_data.server_id = server_id;
strcpy( packet->u.server_accept_bankitem_data.name, c[cn].name );// 030923 HK YGI
memcpy((UCHAR *)packet->u.server_accept_bankitem_data.bankitem, (UCHAR *)c[cn].chrlst.bank, SIZE_OF_BANKITEM);
if(!QueuePacket(c, cn, packet, 1)) break;
}break;
case CMD_ACCESS_LOGIN :
{
::CheckIDAutherizing(*packet,cn);
}break;
case CMD_PARTY_ACCESS :
{
::SendPartyInforForGameserver( packet->u.kein.server_req_party_db.server_id, packet->u.kein.server_req_party_db.ct, packet->u.kein.server_req_party_db.name, c, cn );
}break;
case CMD_REQ_PARTY_TOGETHER :
{
::SendPartyInfoOfOtherCharToGameserver( packet->u.kein.server_req_party_together.party_name, packet->u.kein.server_req_party_together.my_name, packet->u.kein.server_req_party_together.server_id, c, cn );
}break;
case CMD_CONNECT_INFO : // 4俺吝狼 窍唱狼 某腐磐甫 急琶沁促
{
// 某腐磐檬扁拳捞饶角青 0405 KHS
// 0405 YGI new char
int is_new_char = 0;
if( ::GetCharNew(is_new_char, packet->u.client_connect_info.name ) ) // 4岿 1老 货酚霸 父电 某腐磐 牢啊?
{
if( is_new_char )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -