Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 00:21

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[help][client 5017] character creation packet.

Discussion on [help][client 5017] character creation packet. within the CO2 Private Server forum part of the Conquer Online 2 category.

Closed Thread
 
Old   #1
 
elite*gold: 0
Join Date: Nov 2009
Posts: 19
Received Thanks: 4
[help][client 5017] character creation packet.

i am trying to make the character creation work on a C++ source(Hybrid's one) and i am having some troubles.
i suppose the sequence goes like this(?):
1-> client sends (valid, meaning acc and pass are ok) login request to server
2-> server check for a character being existent on that account
3-> if no character is created on the specified account, server sends sends back a MessagePacket with the message "NEW_ROLE"
4-> client then goes into the class selection screen, chooses name, class, gender and body type and sends the coresponding character creation packet to the server
5-> server creates the character and disconnects the player in order to re-log.

however, it seems that i get a garbage packet on step (4) instead of a valid one which causes the server to disconnect the client and discard the data. for whatever reason i cannot find the problem, hope you guys can help me.

Screenshot:

CODES:
Code:
// this is the function called when a player tries to login
void StartLogin(CGameClient *Client, PACKET_HEAD *pHead)
{
	struct Packet_Data
	{
		PACKET_HEAD Header;
		DWORD Key2;
		DWORD Key1;
	};
	Packet_Data* Packet = (Packet_Data*)pHead;
	Client->ID = Packet->Key1;
	
	CMsgPacket *msg = new CMsgPacket( );
	msg->Color = 0x00FFFFFF;
	msg->ChatType = CHAT_TYPE_DIALOG;
	msg->To = "ALLUSERS";
	msg->From = "SYSTEM";

	try
	{
		// finding the AuthClient coresponding to the GameClient
		bool result = false;
		CDatabaseRoot::Core->AuthClients->ObtainSyncHandle( );
		for(int i = 0; i < CDatabaseRoot::Core->AuthClients->Count; i++)
		{
			if(CDatabaseRoot::Core->AuthClients->Elements[i]->ID == Client->ID)
			{
				memcpy(Client->szUsername, CDatabaseRoot::Core->AuthClients->Elements[i]->szUsername, 16);
				memcpy(Client->szPassword, CDatabaseRoot::Core->AuthClients->Elements[i]->szPassword, 16);
				result = true;
				CDatabaseRoot::Core->AuthClients->RemoveAt(i, false);
				break;
			}
		}
		CDatabaseRoot::Core->AuthClients->FreeSyncHandle( );
	
		if(!result)
		{
			// couldn't find the coresponding AuthClient for the GameClient
			throw "Login failed. Please try again later!";
		}

		// check if the account is already logged on and disconnect him if so
		CGameClient *C = CDatabaseRoot::Core->FindClient(Client->szName);
	
		if(C)
		{
			// account was already logged in, disconnect both clients
			C->Disconnect( );	
			throw "Someone is already logged on this account. Please try again later!";	
			// Client will be disconnected in the catch statement
		}	

		string charname = CDatabaseRoot::Core->GetCharacterFromAccount(Client->szUsername);
		if(charname.empty( ))
		{
			// there is no character created on that account
			msg->Message = "NEW_ROLE";
			Client->Send(msg);
			return;
		}

		CDatabaseRoot::Core->LoadCharacter(Client);

		CharacterInfoPacket* cInfo = (CharacterInfoPacket*)CharacterInfoPacket::Create(Client->szName, Client->szSpouse);
		cInfo->UID = Client->ID;
		cInfo->Model = Client->Data->Model;
		cInfo->HairStyle = Client->Data->HairStyle;
		cInfo->Money = Client->Money;
		cInfo->ConquerPoints = Client->ConquerPoints;
		memcpy(cInfo->Stats, &Client->Stats, sizeof(UserStats));
		cInfo->Hitpoints = Client->Hitpoints;
		cInfo->Mana = Client->Mana;
		cInfo->Level = (BYTE)Client->Data->Level;
		cInfo->Job = Client->Job.GetID( );
		cInfo->Reborn = (BYTE)Client->Data->Reborn;

		CDatabaseRoot::Core->Clients->Add(Client);
		Client->Crypto->SetKeys(&Packet->Key1, &Packet->Key2);

		msg->Message = "ANSWER_OK";
		Client->Send(cInfo, true);
		Client->Send(msg);
	}
	catch(char* exception)
	{
		msg->Message = exception;
		Client->Send(msg);
		Client->Disconnect(false);	
		// do not save the account as the variables haven't been loaded 
		// and this would corrup the account file
	}
}
Code:
// function responsible for received data processing
void GameReceive(CCustomWinsockClient* client, CServerSocket* server, unsigned char* buf, int buflen)
{
	CGameClient* pWrapper = (CGameClient*)client->PublicWrapper;	
	pWrapper->Crypto->Decrypt(buf, buf, buflen);
	
	for(int Counter = 0; Counter < buflen; /*Counter += Size*/)
	{
		PACKET_HEAD* header = (PACKET_HEAD*)(buf + Counter);
		
		WriteLn("buflen: " + ConvertToString(buflen) + " header->Size: " + ConvertToString(header->Size));
		PrintHexStr(buf + Counter, buflen - Counter);

		if(header->Size > buflen)
		{
			pWrapper->Disconnect( ); // INVALID_LEN
		}
		else
		{
			//PrintHexStr(buf + Counter, header->Size);

			PacketProcessor::Process(pWrapper, header);
		}
		Counter += header->Size;
	}
}
dospy is offline  
Old 09/08/2013, 19:46   #2
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,211
Received Thanks: 4,114
Don't forget to generate keys. You should be generating new keys before telling the client to do anything where it could send back a packet. Also, this is in the wrong section. I'll be moving it shortly.
Spirited is offline  
Thanks
1 User
Old 09/08/2013, 20:21   #3
 
elite*gold: 0
Join Date: Nov 2009
Posts: 19
Received Thanks: 4
thx for the reply, really appreciate it, dono how i missed that.
you are a lifesaver
#can be closed
dospy is offline  
Old 09/08/2013, 20:25   #4
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,211
Received Thanks: 4,114
No problem.
Closed as requested.
Spirited is offline  
Closed Thread


Similar Threads Similar Threads
[French Release] Création serveur priver 5017 FringeCO
01/08/2012 - CO2 PServer Guides & Releases - 12 Replies
http://ups.imagup.com/ano1/1283195167.jpg Hi, A lot of French people ask me to help with the creation of Conquer Private Server i decide to put my source online FringeCO 2.1 FringeCO is a server deny conquest 2.0 french created by Benj! and myself in the summer of 2009 It offers: -lvl max 140 -super lotery 50k cps
Character info packet 5017
12/22/2011 - CO2 Private Server - 2 Replies
I'm certain that all the values up till the string packer are correct since I just took them from Hybrid's source but I'm not too sure about the string packer part but it should be correct too yet it appears to be wrong and characters don't have names. using System.Text; using Albetros.Core.Enum; namespace Albetros.Game.Packet { public unsafe struct PlayerInfoPacket { public uint Id;
Character creation bug
01/18/2010 - Archlord - 8 Replies
I made a new character on the new server Deribelle yesterday, to reserve the name for a new account i would make later. Today 24 hours later i deleted the char and already had another client with character creation window open, i tried to create a char with the same name like right after i deleted the original one and it says character name already taken. logged off on both accounts tried again same thing. After i tried this with a completely random name like x48e78 and same problem. Any...
Character Creation
06/18/2009 - Dekaron - 8 Replies
Hello, Everytime I log into 2Moons and try to create a Character, I can't. Because nothing happens when I click on new. I already chose Servers and Channels, but all I can click is Delete and Log Out. My Character Slots aren't full, I didn't make any Characters yet. I just can't click new.
Item packet creation
11/30/2005 - Conquer Online 2 - 19 Replies
Well well, I've played a server sided game b4 and I know that we can make a "item creation" I said creation not dupping...thats impossible on server sided games although every1 knows that, but I know a theory that worked on the other game and it really worked at least for some items, but it was a simple game in flash and well Im not used with this whole source code of conquer but if I have some help, maybe we can make a tool that makes lots of items dropping on the ground :D I will explain it...



All times are GMT +2. The time now is 00:21.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.