JOIN_REJECTION works, ready for the rest

This commit is contained in:
Kayne Ruse
2014-09-09 08:39:36 +10:00
parent 4c882682ed
commit 2c06232264
4 changed files with 19 additions and 6 deletions
+7 -4
View File
@@ -67,9 +67,14 @@ void ServerApplication::HandleJoinRequest(ClientPacket* const argPacket) {
//load the user account
//TODO: handle passwords
int accountIndex = accountMgr.LoadAccount(argPacket->username, clientIndex);
//Error checking
if (accountIndex < 0) {
//TODO: send rejection packet
std::cerr << "Error: Account already loaded: " << accountIndex << std::endl;
TextPacket newPacket;
newPacket.type = SerialPacketType::JOIN_REJECTION;
std::string msg = std::string() + "Account already loaded: " + argPacket->username;
strncpy(newPacket.text, msg.c_str(), PACKET_STRING_SIZE); //BUG: If the name is too long this would truncate it
network.SendTo(argPacket->srcAddress, static_cast<SerialPacket*>(&newPacket));
return;
}
@@ -223,8 +228,6 @@ void ServerApplication::HandleCharacterUpdate(CharacterPacket* const argPacket)
//make a new character if this one doesn't exist
if (!character) {
//this isn't normal
std::cerr << "Warning: HandleCharacterUpdate() is passing to HandleCharacterNew()" << std::endl;
HandleCharacterNew(argPacket);
return;
}