void CUser::SelNationToAgent(char *pBuf)
{
	int index = 0, send_index = 0, retvalue = 0;
	int nation = 0;
	char send_buff[256];
	memset( send_buff, NULL, 256);

	nation = GetByte( pBuf, index );
	if( nation > 2 )
		goto fail_return;

	SetByte( send_buff, WIZ_SEL_NATION, send_index );
	SetShort( send_buff, m_Sid, send_index );
	SetKOString(send_buff, m_strAccountID, send_index);
	SetByte( send_buff, nation, send_index );

	retvalue = m_pMain->m_LoggerSendQueue.PutData( send_buff, send_index );
	if (retvalue < SMQ_FULL)
		return;

	DEBUG_LOG("Nation Sel Send Fail : %d", retvalue);

fail_return:
	send_index = 0;
	SetByte( send_buff, WIZ_SEL_NATION, send_index );
	SetByte( send_buff, 0x00, send_index );
	Send( send_buff, send_index );
}
void CUser::PartyDelete()
{
	int send_index = 0;
	CUser* pUser = NULL;
	_PARTY_GROUP* pParty = NULL;
	if( m_sPartyIndex == -1 ) return;

	pParty = m_pMain->m_PartyArray.GetData( m_sPartyIndex );
	if( !pParty ) {
		m_sPartyIndex = -1;
		return;
	}
	for( int i=0; i<8; i++ ) {
		pUser = m_pMain->GetUserPtr(pParty->uid[i]);
		if (pUser == NULL) 
			continue;
		pUser->m_sPartyIndex = -1;
	}

	char send_buff[256]; memset( send_buff, 0x00, 256 );
	SetByte( send_buff, WIZ_PARTY, send_index );
	SetByte( send_buff, PARTY_DELETE, send_index );
	m_pMain->Send_PartyMember( pParty->wIndex, send_buff, send_index );	// ????? ???? ??e??????..

	// AI Server
	send_index = 0; memset( send_buff, 0x00, 256 );
	SetByte( send_buff, AG_USER_PARTY, send_index );
	SetByte( send_buff, PARTY_DELETE, send_index );
	SetShort( send_buff, pParty->wIndex, send_index );
	m_pMain->Send_AIServer(m_pUserData->m_bZone, send_buff, send_index);

	m_pMain->DeleteParty(pParty->wIndex);
}
示例#3
0
void User::Refresh()
{
	this->lpPlayer			= &*(ObjectCharacter*)oUserObjectStruct;
	this->lpViewPlayer		= &*(ObjectPreview*)oUserPreviewStruct;
	this->GetTarget();
	// ----
	this->m_CursorX			= pCursorX;
	this->m_CursorY			= pCursorY;
	this->m_MapNumber		= pMapNumber;
	this->m_MasterLevel		= pMasterLevel;
	this->m_MasterPoint		= pMasterPoint;
	this->m_MasterExp		= pMasterExp;
	this->m_MasterNextExp	= pMasterNextExp;
	// ----
	if( (gObjUser.lpPlayer->Class & 7) != 6 )
	{
		SetByte((PVOID)(0x00556C32 + 6), 2);
	}
	else
	{
		SetByte((PVOID)(0x00556C32 + 6), 15);
	}
	// ----
	if( gTrayMode.InTray )
	{
		if( !this->lpViewPlayer->m_Model.Unknown4 && gConnectEx.m_ConnectState == 0 )
		{
			gTrayMode.ShowMessage(NIIF_WARNING, "MU Online", "Your character has been killed");
		}
	}
}
示例#4
0
void CUser::Parsing(int len, char *pData)
{
	int index = 0, send_index = 0, i=0, client_version = 0;
	char buff[2048]; memset( buff, 0x00, 2048 );
	BYTE command = GetByte( pData, index );

	switch( command ) {
	case LS_VERSION_REQ:
		SetByte( buff, LS_VERSION_REQ, send_index );
		SetShort( buff, m_pMain->m_nLastVersion, send_index );
		Send( buff, send_index );
		break;
	case LS_SERVERLIST:
		m_pMain->m_DBProcess.LoadUserCountList();		// 기범이가 ^^;
		SetByte( buff, LS_SERVERLIST, send_index );
		SetByte( buff, m_pMain->m_nServerCount, send_index );
		for(i=0; i<m_pMain->m_ServerList.size(); i++) {		
			SetShort( buff, strlen(m_pMain->m_ServerList[i]->strServerIP), send_index );
			SetString( buff, m_pMain->m_ServerList[i]->strServerIP, strlen(m_pMain->m_ServerList[i]->strServerIP), send_index );
			SetShort( buff, strlen(m_pMain->m_ServerList[i]->strServerName), send_index );
			SetString( buff, m_pMain->m_ServerList[i]->strServerName, strlen( m_pMain->m_ServerList[i]->strServerName ), send_index );			
			SetShort( buff, m_pMain->m_ServerList[i]->sUserCount, send_index);   // 기범이가 ^^;
		}
		Send( buff, send_index );
		break;
	case LS_DOWNLOADINFO_REQ:
		client_version = GetShort( pData, index );
		SendDownloadInfo( client_version );
		break;
	case LS_LOGIN_REQ:
		LogInReq( pData+index );
		break;
	}
}
示例#5
0
void CUdpSocket::RecvJoinKnights( char* pBuf, BYTE command )
{
	int send_index = 0, knightsindex = 0, index = 0;
	char charid[MAX_ID_SIZE+1], send_buff[128], finalstr[128];
	CKnights*	pKnights = NULL;

	knightsindex = GetShort( pBuf, index );
	if (!GetKOString(pBuf, charid, index, MAX_ID_SIZE))
		return;

	pKnights = m_pMain->m_KnightsArray.GetData( knightsindex );

	if( command == KNIGHTS_JOIN ) {
		sprintf( finalstr, "#### %s님이 가입하셨습니다. ####", charid );
		// 클랜정보에 추가
		m_pMain->m_KnightsManager.AddKnightsUser( knightsindex, charid );
		TRACE("UDP - RecvJoinKnights - 가입, name=%s, index=%d\n", charid, knightsindex);
	}
	else {		// 탈퇴..
		// 클랜정보에 추가
		m_pMain->m_KnightsManager.RemoveKnightsUser( knightsindex, charid );
		sprintf( finalstr, "#### %s님이 탈퇴하셨습니다. ####", charid );
		TRACE("UDP - RecvJoinKnights - 탈퇴, name=%s, index=%d\n", charid, knightsindex );
	}

	//TRACE("UDP - RecvJoinKnights - command=%d, name=%s, index=%d\n", command, charid, knightsindex);

	send_index = 0;
	SetByte( send_buff, WIZ_CHAT, send_index );
	SetByte( send_buff, KNIGHTS_CHAT, send_index );
	SetByte( send_buff, 1, send_index );
	SetShort( send_buff, -1, send_index );
	SetKOString( send_buff, finalstr, send_index );
	m_pMain->Send_KnightsMember( knightsindex, send_buff, send_index );
}
void CUser::PartyCancel()
{
	int send_index = 0, leader_id = -1, count = 0;
	CUser* pUser = NULL;
	_PARTY_GROUP* pParty = NULL;
	char send_buff[256]; memset( send_buff, 0x00, 256 );

	if( m_sPartyIndex == -1 ) return;
	pParty = m_pMain->m_PartyArray.GetData( m_sPartyIndex );
	if( !pParty ) {				
		m_sPartyIndex = -1;
		return;
	}

	m_sPartyIndex = -1;
	
	leader_id = pParty->uid[0];
	pUser = m_pMain->GetUserPtr(leader_id);
	if (pUser == NULL)
		return;

	for( int i=0; i<8; i++ ) {		
		if( pParty->uid[i] >= 0 )
			count++;
	}

	if( count == 1 )
		pUser->PartyDelete();			

	SetByte( send_buff, WIZ_PARTY, send_index );
	SetByte( send_buff, PARTY_INSERT, send_index );
	SetShort( send_buff, -1, send_index );
	pUser->Send( send_buff, send_index );
}
bool Transporter::CreateAsTransporter(uint32 EntryID, const char* Name)
{
	// Lookup GameobjectInfo
	if(!CreateFromProto(EntryID,0,0,0,0,0))
		return false;
	
	SetUInt32Value(GAMEOBJECT_FLAGS,40);
	SetByte(GAMEOBJECT_BYTES_1,GAMEOBJECT_BYTES_ANIMPROGRESS, 100);

	//Maybe this would be the perfect way, so there would be no extra checks in Object.cpp:
	SetByte( GAMEOBJECT_BYTES_1, 0, GAMEOBJECT_TYPE_TRANSPORT );
	//but these fields seems to change often and between server flavours (ArcEmu, Aspire, name another one) - by: VLack aka. VLsoft
	if( pInfo )
		pInfo->Type = GAMEOBJECT_TYPE_TRANSPORT;
	else
		sLog.outString("Transporter id[%i] name[%s] - can't set GAMEOBJECT_TYPE - it will behave badly!",EntryID,Name);

	// Generate waypoints
	if(!GenerateWaypoints())
		return false;

	// Set position
	SetMapId(m_WayPoints[0].mapid);
	SetPosition(m_WayPoints[0].x, m_WayPoints[0].y, m_WayPoints[0].z, 0);

	SetUInt32Value(GAMEOBJECT_LEVEL, m_period); // ITS OVER 9000!!!!! No, really, it is.

	// Add to world
	AddToWorld();

	return true;
}
示例#8
0
void CUser::SendMagicAttackResult(int tuid, BYTE result, short sDamage, short sHP)
{
	int send_index = 0;
	int sid = -1, tid = -1;
	BYTE type, bResult;
	char buff[256];
	memset( buff, 0x00, 256 );
	float rx=0.0f, ry=0.0f, rz=0.0f;

	type = 0x01;				
	bResult = result;
	sid = m_iUserId+USER_BAND;
	tid = tuid;

	SetByte( buff, AG_MAGIC_ATTACK_RESULT, send_index );
	SetByte( buff, type, send_index );
	SetByte( buff, bResult, send_index );
	SetShort( buff, sid, send_index );
	SetShort( buff, tid, send_index );
	SetShort( buff, sDamage, send_index );
	SetShort( buff, sHP, send_index );

	//TRACE("User - SendAttackSuccess() : [sid=%d, tid=%d, result=%d], damage=%d, hp = %d\n", sid, tid, bResult, sDamage, sHP);

	SendAll(buff, send_index);   // thread 에서 send
}
示例#9
0
bool GameObject::Load(GOSpawn *spawn)
{
	if(!CreateFromProto(spawn->entry,0,spawn->x,spawn->y,spawn->z,spawn->facing,spawn->orientation1,spawn->orientation2,spawn->orientation3,spawn->orientation4))
		return false;

	m_phaseMode = spawn->phase;
	m_spawn = spawn;
	SetUInt32Value(GAMEOBJECT_FLAGS,spawn->flags);
	SetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_STATE, spawn->state);
	if(spawn->faction)
	{
		SetUInt32Value(GAMEOBJECT_FACTION,spawn->faction);
		m_faction = dbcFactionTemplate.LookupEntry(spawn->faction);
		if(m_faction)
			m_factionDBC = dbcFaction.LookupEntry(m_faction->Faction);
	}
	SetFloatValue(OBJECT_FIELD_SCALE_X,spawn->scale);

	if( spawn->flags & GO_FLAG_IN_USE || spawn->flags & GO_FLAG_LOCKED )
		SetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_ANIMPROGRESS, 100);

	CALL_GO_SCRIPT_EVENT(TO_GAMEOBJECT(this), OnCreate)();

	_LoadQuests();
	return true;
}
void CUser::RecvDeleteChar( char* pBuf )
{
	int nResult = 0, nLen = 0, index = 0, send_index = 0, char_index = 0, nKnights = 0;
	char strCharID[MAX_ID_SIZE+1];	memset( strCharID, 0x00, MAX_ID_SIZE+1 );
	char send_buff[256];			memset( send_buff, 0x00, 256 );

	nResult = GetByte( pBuf, index );
	char_index = GetByte( pBuf, index );
	nKnights = GetShort( pBuf, index );
	nLen = GetShort( pBuf, index );
	GetString( strCharID, pBuf, nLen, index );

	if( nResult == 1 && nKnights != 0 )	{
		m_pMain->m_KnightsManager.RemoveKnightsUser( nKnights, strCharID );
		TRACE("RecvDeleteChar ==> name=%s, knights=%d\n", strCharID, nKnights );

		memset( send_buff, 0x00, 128 );		send_index = 0;
		SetByte( send_buff, UDP_KNIGHTS_PROCESS, send_index );
		SetByte( send_buff, KNIGHTS_WITHDRAW, send_index );
		SetShort( send_buff, nKnights, send_index );
		SetKOString(send_buff, strCharID, send_index);
		if( m_pMain->m_nServerGroup == 0 )
			m_pMain->Send_UDP_All( send_buff, send_index );
		else
			m_pMain->Send_UDP_All( send_buff, send_index, 1 );
	}

	memset( send_buff, 0x00, 128 );		send_index = 0;
	SetByte( send_buff, WIZ_DEL_CHAR, send_index );
	SetByte( send_buff, nResult, send_index );	
	SetByte( send_buff, char_index, send_index );

	Send( send_buff, send_index );
}
示例#11
0
void CAISocket::RecvUserFail(char* pBuf)
{
	short nid = 0, sid=0;
	int index = 0, send_index = 0;
	char pOutBuf[1024];

	nid = GetShort(pBuf,index);
	sid = GetShort(pBuf,index);

	CUser* pUser = m_pMain->GetUserPtr(nid);
	if (pUser == NULL)
		return;

	pUser->HpChange(-10000, 1);

	BYTE type = 0x01;
	BYTE result = 0x02;
	float fDir = 0.0f;

	SetByte(pOutBuf, WIZ_ATTACK, send_index);
	SetByte( pOutBuf, type, send_index );
	SetByte( pOutBuf, result, send_index );
	SetShort( pOutBuf, sid, send_index );
	SetShort( pOutBuf, nid, send_index );

	TRACE("### AISocket - RecvUserFail : sid=%d, tid=%d, id=%s ####\n", sid, nid, pUser->m_pUserData->m_id);

	m_pMain->Send_Region(pOutBuf, send_index, pUser->GetMap(), pUser->m_RegionX, pUser->m_RegionZ);

}
void CUser::PartyBBSDelete(char *pBuf)
{
	int send_index = 0;	// Basic Initializations. 			
	BYTE result = 0; 
	char send_buff[256]; memset( send_buff, NULL, 256);

	if (m_bNeedParty == 1) goto fail_return;	// You don't need anymore 

	m_bNeedParty = 1;	// Success! You no longer need a party !!!
	result = 1;

	SetByte(send_buff, 2, send_index);	// Send new 'Need Party Status' to region!!!
	SetByte(send_buff, m_bNeedParty, send_index);
	StateChange(send_buff);

	send_index = 0; memset(send_buff, NULL, 256);	// Now, let's find out which page the user is on.
	SetShort(send_buff, 0, send_index);
	PartyBBSNeeded(send_buff, PARTY_BBS_DELETE);
	return;

fail_return:
	SetByte(send_buff, WIZ_PARTY_BBS, send_index);
	SetByte(send_buff, PARTY_BBS_DELETE, send_index);
	SetByte(send_buff, result, send_index);
	Send(send_buff, send_index);
	return;	
}
示例#13
0
void CAISocket::RecvSystemMsg(char* pBuf)
{
	int index = 0, send_index = 0;
	char send_buff[256], strSysMsg[256];

	BYTE bType;
	short sWho;

	bType = GetByte(pBuf,index);
	sWho = GetShort(pBuf,index);
	if (!GetKOString(pBuf, strSysMsg, index, sizeof(strSysMsg) - 1))
		return;

	//TRACE("RecvSystemMsg - type=%d, who=%d, len=%d, msg=%s\n", bType, sWho, sLength, strSysMsg);

	switch(sWho)
	{
	case SEND_ME:
		break;
	case SEND_REGION:
		break;
	case SEND_ALL:
		SetByte( send_buff, WIZ_CHAT, send_index );
		SetByte( send_buff, bType, send_index );
		SetByte( send_buff, 0x01, send_index );		// nation
		SetShort( send_buff, -1, send_index );		// sid
		SetKOString( send_buff, strSysMsg, send_index );
		m_pMain->Send_All( send_buff, send_index );
		break;
	case SEND_ZONE:
		break;
	}
	
}
示例#14
0
void CNpc::RemoveRegion(int del_x, int del_z)
{
	int send_index = 0, i=0;
	int region_x = -1, region_z = -1, uid = -1;
	char buff[128];
	memset( buff, NULL, 128 );
	C3DMap* pMap = GetMap();

	SetByte( buff, WIZ_NPC_INOUT, send_index );
	SetByte( buff, NPC_OUT, send_index );
	SetShort( buff, m_sNid, send_index );

	if( del_x != 0 ) {
		m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+del_x*2, m_sRegion_Z+del_z-1 );
		m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+del_x*2, m_sRegion_Z+del_z );
		m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+del_x*2, m_sRegion_Z+del_z+1 );
	}
	if( del_z != 0 ) {	
		m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+del_x, m_sRegion_Z+del_z*2 );
		if( del_x < 0 ) 
			m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+del_x+1, m_sRegion_Z+del_z*2 );
		else if( del_x > 0 )
			m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+del_x-1, m_sRegion_Z+del_z*2 );
		else {
			m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+del_x-1, m_sRegion_Z+del_z*2 );
			m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+del_x+1, m_sRegion_Z+del_z*2 );
		}
	}
}
示例#15
0
void CNpc::NpcInOut(BYTE Type, float fx, float fz, float fy)
{
	int send_index = 0;
	char buff[1024];
	memset( buff, 0x00, 1024 );

	C3DMap *pMap = m_pMain->GetZoneByID(getZoneID());
	if (pMap == NULL)
		return;

	m_pMap = pMap;

	if( Type == NPC_OUT )
	{
		pMap->RegionNpcRemove( m_sRegion_X, m_sRegion_Z, m_sNid );
	}
	else	
	{
		pMap->RegionNpcAdd( m_sRegion_X, m_sRegion_Z, m_sNid );
		m_fCurX = fx;	m_fCurZ = fz;	m_fCurY = fy;
	}

	SetByte( buff, WIZ_NPC_INOUT, send_index );
	SetByte( buff, Type, send_index );
	SetShort( buff, m_sNid, send_index );
	if( Type == NPC_OUT ) {
		m_pMain->Send_Region(buff, send_index, GetMap(), m_sRegion_X, m_sRegion_Z);
		return;
	}

	GetNpcInfo(buff, send_index);
	m_pMain->Send_Region(buff, send_index, GetMap(), m_sRegion_X, m_sRegion_Z);
}
示例#16
0
void CNpc::InsertRegion(int del_x, int del_z)
{
	int send_index = 0, buff_index = 0, i=0;
	int region_x = -1, region_z = -1;
	char buff[128];
	memset( buff, NULL, 128 );
	C3DMap* pMap = GetMap();
	if (pMap == NULL)
		return;

	SetByte( buff, WIZ_NPC_INOUT, send_index );
	SetByte( buff, NPC_IN, send_index );

	GetNpcInfo(buff, send_index);

	if( del_x != 0 ) {
		m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+del_x, m_sRegion_Z-1 );
		m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+del_x, m_sRegion_Z );
		m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+del_x, m_sRegion_Z+1 );
	}
	if( del_z != 0 ) {
		m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X, m_sRegion_Z+del_z );
		
		if( del_x < 0 )	{
			m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+1, m_sRegion_Z+del_z );
		}
		else if( del_x > 0 ) {
			m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X-1, m_sRegion_Z+del_z );
		}
		else {
			m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X-1, m_sRegion_Z+del_z );
			m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+1, m_sRegion_Z+del_z );
		}
	}
}
void CUser::HandleStoreClose()
{
	char send_buff[256];
	int send_index = 0;

	m_bStoreOpen = false;

	// Tell Aujard we're closing the PUS so that we can call LOAD_WEB_ITEMMALL and load the extra items.
	SetByte(send_buff, WIZ_SHOPPING_MALL, send_index);
	SetByte(send_buff, STORE_CLOSE, send_index);
	SetShort(send_buff, GetSocketID(), send_index);
	m_pMain->m_LoggerSendQueue.PutData(send_buff, send_index);
}
示例#18
0
void User::SetBattleMapData(PMSG_BATTLE_LIST * aRecv)
{
	SetByte((PVOID)pMaxBattleZoneCount, MAX_BATTLE_LIST);
	// ----
	for( int i = 0; i < MAX_BATTLE_LIST; i++ )
	{
		SetByte((PVOID)((oBattleMapStart + 7 * i) + 3), aRecv->BattleMapList[i]);
	}
	// ----
	for( int i = 0; i < MAX_BATTLE_LIST; i++ )
	{
		this->m_BattleZoneList[i] = aRecv->BattleZoneList[i];
	}
}
示例#19
0
BOOL CUser::RobItem(int itemid, short count)
{
	int send_index = 0, i = 0;					
	char send_buff[256];
	BYTE type = 1;

	_ITEM_TABLE* pTable = NULL;				// This checks if such an item exists.
	pTable = m_pMain->m_ItemtableArray.GetData( itemid );
	if( !pTable ) return FALSE;

	for ( i = SLOT_MAX ; i < SLOT_MAX + HAVE_MAX * type ; i++ ) {
		if( m_pUserData->m_sItemArray[i].nNum == itemid ) {		
			if (!pTable->m_bCountable) {	// Remove item from inventory (Non-countable items)
				m_pUserData->m_sItemArray[i].nNum = 0;
				m_pUserData->m_sItemArray[i].sCount = 0;
				m_pUserData->m_sItemArray[i].sDuration = 0;
				goto success_return;
			}
			else {	// Remove the number of items from the inventory (Countable Items)
				if (m_pUserData->m_sItemArray[i].sCount >= count) {
					m_pUserData->m_sItemArray[i].sCount -= count ;

					if (m_pUserData->m_sItemArray[i].sCount == 0) {
						m_pUserData->m_sItemArray[i].nNum = 0 ;
						m_pUserData->m_sItemArray[i].sCount = 0;
						m_pUserData->m_sItemArray[i].sDuration = 0;
					}					
					goto success_return;
				}
				else {
					return FALSE;	
				}
			}			
		}		
	}
	
	return FALSE;

success_return:
	SendItemWeight();	// Change weight first :)
	SetByte( send_buff, WIZ_ITEM_COUNT_CHANGE, send_index );	
	SetShort( send_buff, 0x01, send_index );	// The number of for-loops
	SetByte( send_buff, 0x01, send_index );
	SetByte( send_buff, i - SLOT_MAX, send_index );
	SetDWORD( send_buff, itemid, send_index );	// The ID of item.
	SetDWORD( send_buff, m_pUserData->m_sItemArray[i].sCount, send_index );
	Send( send_buff, send_index );
	return TRUE;
}
void CUser::SelCharToAgent(char *pBuf)
{
	int index = 0, send_index = 0, retvalue = 0;
	char userid[MAX_ID_SIZE+1], accountid[MAX_ID_SIZE+1];
	memset( userid, NULL, MAX_ID_SIZE+1 );
	memset( accountid, NULL, MAX_ID_SIZE+1 );
	char send_buff[256];
	memset( send_buff, NULL, 256);
	CUser* pUser = NULL;
	CTime t = CTime::GetCurrentTime();
	BYTE	bInit = 0x01;

	if (!GetKOString(pBuf, accountid, index, MAX_ID_SIZE)
		|| !GetKOString(pBuf, userid, index, MAX_ID_SIZE))
		goto fail_return;

	bInit = GetByte( pBuf, index );
	
	if( _strnicmp( accountid, m_strAccountID, MAX_ID_SIZE ) != 0 ) {
		Close();
		return;
	}

	pUser = m_pMain->GetUserPtr(userid, TYPE_CHARACTER);
	if( pUser && (pUser->GetSocketID() != GetSocketID()) ) {
		pUser->Close();
		goto fail_return;
	}

	SetByte( send_buff, WIZ_SEL_CHAR, send_index );
	SetShort( send_buff, m_Sid, send_index );
	SetKOString(send_buff, m_strAccountID, send_index);
	SetKOString(send_buff, userid, send_index);
	SetByte( send_buff, bInit, send_index );

	m_pMain->WriteLog("[SelCharToAgent : %d:%d:%d] - acname=%s, name=%s, TH: %lu, Rear : %d\r\n", t.GetHour(), t.GetMinute(), t.GetSecond(), m_strAccountID, userid, GetCurrentThreadId(), m_pMain->m_LoggerSendQueue.GetRearPointer());

	retvalue = m_pMain->m_LoggerSendQueue.PutData( send_buff, send_index );
	if (retvalue < SMQ_FULL)
		return;

	DEBUG_LOG("SelChar Send Fail : %d", retvalue);

fail_return:
	send_index = 0;
	SetByte( send_buff, WIZ_SEL_CHAR, send_index );
	SetByte( send_buff, 0x00, send_index );
	Send( send_buff, send_index );
}
void CUser::ItemRepair(char *pBuf)
{
	int index = 0, send_index = 0, money = 0, quantity = 0;
	int itemid = 0, pos = 0, slot = -1, durability = 0;
	char send_buff[128]; memset( send_buff, 0x00, 128 );
	_ITEM_TABLE* pTable = NULL;

	pos = GetByte( pBuf, index );
	slot = GetByte( pBuf, index );
	itemid = GetDWORD( pBuf, index );
	if( pos == 1 ) {	// SLOT
		if( slot >= SLOT_MAX ) goto fail_return;
		if( m_pUserData->m_sItemArray[slot].nNum != itemid ) goto fail_return;
	}
	else if ( pos == 2 ) {	// INVEN
		if( slot >= HAVE_MAX ) goto fail_return;
		if( m_pUserData->m_sItemArray[SLOT_MAX+slot].nNum != itemid ) goto fail_return;
	}
	pTable = m_pMain->m_ItemtableArray.GetData( itemid );
	if( !pTable ) goto fail_return;
	durability = pTable->m_sDuration;
	if( durability == 1 ) goto fail_return;
	if( pos == 1 )
		quantity = pTable->m_sDuration - m_pUserData->m_sItemArray[slot].sDuration;
	else if( pos == 2 ) 
		quantity = pTable->m_sDuration - m_pUserData->m_sItemArray[SLOT_MAX+slot].sDuration;
	
	money = (int)( ((pTable->m_iBuyPrice-10)/10000.0f) + pow(pTable->m_iBuyPrice, 0.75)) * quantity / (double)durability;
	if( money > m_pUserData->m_iGold ) goto fail_return;

	m_pUserData->m_iGold -= money;
	if( pos == 1 )
		m_pUserData->m_sItemArray[slot].sDuration = durability;
	else if( pos == 2 )
		m_pUserData->m_sItemArray[SLOT_MAX+slot].sDuration = durability;

	SetByte( send_buff, WIZ_ITEM_REPAIR, send_index );
	SetByte( send_buff, 0x01, send_index );
	SetDWORD( send_buff, m_pUserData->m_iGold, send_index );
	Send( send_buff, send_index );

	return;
fail_return:
	SetByte( send_buff, WIZ_ITEM_REPAIR, send_index );
	SetByte( send_buff, 0x00, send_index );
	SetDWORD( send_buff, m_pUserData->m_iGold, send_index );
	Send( send_buff, send_index );
}
示例#22
0
void CAISocket::RecvNpcMoveResult(char *pBuf)
{
	// sungyong tw
	char send_buff[256];
	int index = 0, send_index = 0;
	BYTE		flag;			// 01(INFO_MODIFY)	: NPC 정보 변경
								// 02(INFO_DELETE)	: NPC 정보 삭제
	short		nid;			// NPC index
	float		fPosX;			// X Position
	float		fPosZ;			// Z Position
	float		fPosY;			// Y Position
	float		fSecForMetor;	// Sec당 metor
	flag = GetByte(pBuf,index);
	nid = GetShort(pBuf,index);
	fPosX = Getfloat(pBuf, index);
	fPosZ = Getfloat(pBuf, index);
	fPosY = Getfloat(pBuf, index);
	fSecForMetor = Getfloat(pBuf, index);

	CNpc* pNpc = m_pMain->m_arNpcArray.GetData( nid );
	if(!pNpc)
		return;

	if( pNpc->m_NpcState == NPC_DEAD || pNpc->m_iHP <= 0 ) {	// Npc 상태 동기화 불량,, 재요청..
		SetByte( send_buff, AG_NPC_HP_REQ, send_index);
		SetShort( send_buff, nid, send_index );
		SetDWORD( send_buff, pNpc->m_iHP, send_index );
		Send( send_buff, send_index );
	}
	// ~sungyong tw
	
	pNpc->MoveResult(fPosX, fPosY, fPosZ, fSecForMetor);
}
示例#23
0
void CAISocket::RecvUserExp(char* pBuf)
{
	int index = 0;
	int nid = 0;
	short sExp = 0;
	short sLoyalty = 0;

	nid = GetShort(pBuf,index);
	sExp = GetShort(pBuf,index);
	sLoyalty = GetShort(pBuf,index);

	CUser* pUser = m_pMain->GetUserPtr(nid);
	if(pUser == NULL)
		return;
	if(sExp < 0 || sLoyalty < 0)	{
		TRACE("#### AISocket - RecvUserExp : exp=%d, loyalty=%d,, 잘못된 경험치가 온다,, 수정해!!\n", sExp, sLoyalty);
		return;
	}
	pUser->m_pUserData->m_iLoyalty += sLoyalty;
	pUser->ExpChange(sExp);

	if( sLoyalty > 0 )	{
		char send_buff[128]; 
		int send_index = 0;
		SetByte( send_buff, WIZ_LOYALTY_CHANGE, send_index );
		SetDWORD( send_buff, pUser->m_pUserData->m_iLoyalty, send_index );
		pUser->Send( send_buff, send_index );
	}
}
示例#24
0
void GameObject::Despawn(uint32 time)
{
	if(!IsInWorld())
		return;

	//This is for go get deleted while looting
	if( m_spawn != NULL )
	{
		SetByte(GAMEOBJECT_BYTES_1,GAMEOBJECT_BYTES_STATE, m_spawn->state);
		SetUInt32Value(GAMEOBJECT_FLAGS, m_spawn->flags);
	}

	CALL_GO_SCRIPT_EVENT(TO_GAMEOBJECT(this), OnDespawn)();

	if(time)
	{
		/* Get our originiating mapcell */
		MapCell * pCell = m_mapCell;
		ASSERT(pCell);
		pCell->_respawnObjects.insert( TO_OBJECT(this) );
		sEventMgr.RemoveEvents(this);
		sEventMgr.AddEvent(m_mapMgr, &MapMgr::EventRespawnGameObject, TO_GAMEOBJECT(this), pCell, EVENT_GAMEOBJECT_ITEM_SPAWN, time, 1, 0);
		Object::RemoveFromWorld(false);
		m_respawnCell=pCell;
	}
	else
	{
		Object::RemoveFromWorld(false);
		ExpireAndDelete();
	}
}
示例#25
0
void CIOCPSocket2::SendCompressingPacket(const char *pData, int len)
{
    // Data's too short to bother with compression...
    if (len < 500)
    {
        Send((char *)pData, len);
        return;
    }

    if (len <= 0 || len >= 49152)
    {
        TRACE("### SendCompressingPacket Error : len = %d ### \n", len);
        return;
    }

    CCompressMng comp;
    int send_index = 0;
    char send_buff[49152];

    comp.PreCompressWork(pData, len);
    comp.Compress();

    SetByte(send_buff, WIZ_COMPRESS_PACKET, send_index);
    SetDWORD(send_buff, comp.m_nOutputBufferCurPos, send_index);
    SetDWORD(send_buff, comp.m_nOrgDataLength, send_index);
    SetDWORD(send_buff, comp.m_dwCrc, send_index);
    SetString(send_buff, comp.m_pOutputBuffer, comp.m_nOutputBufferCurPos, send_index);
    Send(send_buff, send_index);
}
示例#26
0
void CIOCPSocket2::RegioinPacketClear(char* GetBuf, int& len)
{
    int count = 0;
    do {
        if( m_pRegionBuffer->bFlag == W ) {
            bb();
            count++;
            continue;
        }
        m_pRegionBuffer->bFlag = W;
        m_pRegionBuffer->dwThreadID = ::GetCurrentThreadId();
        bb();
        if( m_pRegionBuffer->dwThreadID != ::GetCurrentThreadId() ) {	// Dual Lock System...
            count++;
            continue;
        }

        int index = 0;
        SetByte( GetBuf, WIZ_CONTINOUS_PACKET, index );
        SetShort( GetBuf, m_pRegionBuffer->iLength, index );
        SetString( GetBuf, m_pRegionBuffer->pDataBuff, m_pRegionBuffer->iLength, index );
        len = index;

        memset( m_pRegionBuffer->pDataBuff, 0x00, REGION_BUFF_SIZE );
        m_pRegionBuffer->iLength = 0;
        m_pRegionBuffer->bFlag = E;
        break;
    } while( count < 30 );
    if( count > 29 )
        TRACE("Region packet Clear Drop\n");
}
示例#27
0
void CUser::SendSystemMsg(TCHAR *pMsg, BYTE type, int nWho)
{
	int send_index = 0;
	char buff[1024];
	memset( buff, 0x00, 1024 );
	short sLength = _tcslen(pMsg);

	SetByte(buff, AG_SYSTEM_MSG, send_index );
	SetByte(buff, type, send_index );				// 채팅형식
	SetShort(buff, nWho, send_index );				// 누구에게
	SetShort(buff, m_iUserId, send_index );
	SetShort(buff, sLength, send_index );
	SetString( buff, pMsg, sLength, send_index );

	SendAll(buff, send_index);   	
}
示例#28
0
void CUser::SendDownloadInfo(int version)
{
	int send_index = 0, filecount = 0;
	_VERSION_INFO *pInfo = NULL;
	std::set <string>	downloadset;
	char buff[2048]; memset( buff, 0x00, 2048 );

	std::map <string, _VERSION_INFO*>::iterator	Iter1, Iter2;
	Iter1 = m_pMain->m_VersionList.m_UserTypeMap.begin();
	Iter2 = m_pMain->m_VersionList.m_UserTypeMap.end();
	for( ; Iter1 != Iter2; Iter1++ ) {
		pInfo = (*Iter1).second;
		if( pInfo->sVersion > version )
			downloadset.insert(pInfo->strCompName);
	}

	SetByte( buff, LS_DOWNLOADINFO_REQ, send_index );
	SetShort( buff, strlen( m_pMain->m_strFtpUrl), send_index );
	SetString( buff, m_pMain->m_strFtpUrl, strlen( m_pMain->m_strFtpUrl), send_index );
	SetShort( buff, strlen( m_pMain->m_strFilePath), send_index );
	SetString( buff, m_pMain->m_strFilePath, strlen( m_pMain->m_strFilePath), send_index );
	SetShort( buff, downloadset.size(), send_index );
	
	std::set <string>::iterator filenameIter1, filenameIter2;
	filenameIter1 = downloadset.begin();
	filenameIter2 = downloadset.end();
	for(; filenameIter1 != filenameIter2; filenameIter1++ ) {
		SetShort( buff, strlen( (*filenameIter1).c_str() ), send_index );
		SetString( buff, (char*)((*filenameIter1).c_str()), strlen( (*filenameIter1).c_str() ), send_index );
	}
	Send( buff, send_index );
}
示例#29
0
void CNpc::GetNpcInfo(char *buff, int & send_index)
{
	SetShort(buff, m_sPid, send_index );
	SetByte(buff, m_tNpcType, send_index );
	SetDWORD(buff, m_iSellingGroup, send_index );
	SetShort(buff, m_sSize, send_index );
	SetDWORD(buff, m_iWeapon_1, send_index );
	SetDWORD(buff, m_iWeapon_2, send_index );
	SetKOString(buff, m_strName, send_index);
	SetByte(buff, m_byGroup, send_index );
	SetByte(buff, m_byLevel, send_index );
	SetShort(buff, (WORD)m_fCurX*10, send_index );
	SetShort(buff, (WORD)m_fCurZ*10, send_index );
	SetShort(buff, (short)m_fCurY*10, send_index );
	SetDWORD(buff, (int)m_byGateOpen, send_index );
	SetByte(buff, m_byObjectType, send_index );
}
void CUser::DelCharToAgent(char *pBuf)
{
	int index = 0, idlen = 0, send_index = 0, retvalue = 0;
	int charindex = 0, soclen = 0;
	char charid[MAX_ID_SIZE+1];
	char socno[15];
	memset( charid, NULL, MAX_ID_SIZE+1 );
	memset( socno, NULL, 15 );
	char send_buff[256];
	memset( send_buff, NULL, 256);

	charindex = GetByte( pBuf, index );
	if( charindex > 4 )	goto fail_return;
	idlen = GetShort( pBuf, index );
	if( idlen > MAX_ID_SIZE || idlen <= 0 )	goto fail_return;
	GetString( charid, pBuf, idlen, index );
	soclen = GetShort( pBuf, index );
	// sungyong tw
	//if( soclen != 14 ) goto fail_return;
	if( soclen > 14 || soclen <= 0 ) goto fail_return;
	// ~sungyong tw
	GetString( socno, pBuf, soclen, index );

	if( m_pUserData->m_bKnights > 0 && m_pUserData->m_bFame == CHIEF)	goto fail_return;	

	SetByte( send_buff, WIZ_DEL_CHAR, send_index );
	SetShort( send_buff, m_Sid, send_index );
	SetKOString( send_buff, m_strAccountID, send_index );
	SetByte( send_buff, charindex, send_index );
	SetKOString(send_buff, charid, send_index);
	SetKOString(send_buff, socno, send_index);

	retvalue = m_pMain->m_LoggerSendQueue.PutData( send_buff, send_index );
	if (retvalue < SMQ_FULL)
		return;

	DEBUG_LOG("DelChar Send Fail : %d", retvalue);

fail_return:
	send_index = 0;
	SetByte( send_buff, WIZ_DEL_CHAR, send_index );
	SetByte( send_buff, 0x00, send_index );
	SetByte( send_buff, 0xFF, send_index );
	Send( send_buff, send_index );
}