Minor tweaks

This commit is contained in:
Kayne Ruse
2014-08-19 03:35:46 +10:00
parent 61337e29f6
commit dfe8c108de
4 changed files with 10 additions and 6 deletions
+1 -1
View File
@@ -98,7 +98,7 @@ private:
//misc //misc
bool running = true; bool running = true;
int clientUID = 0; int clientIndex = 0;
}; };
#endif #endif
+5 -2
View File
@@ -223,8 +223,11 @@ void ServerApplication::HandlePacket(SerialPacket* const argPacket) {
break; break;
//handle errors //handle errors
default: default: {
throw(std::runtime_error(std::string() + "Unknown SerialPacketType encountered in the server: " + to_string_custom(static_cast<int>(argPacket->type)) )); std::string msg = "Unknown SerialPacketType encountered in the server: ";
msg += to_string_custom(static_cast<int>(argPacket->type));
throw(std::runtime_error(msg));
}
break; break;
} }
} }
+3 -3
View File
@@ -46,7 +46,7 @@ void ServerApplication::HandleJoinRequest(ClientPacket* const argPacket) {
//load the user account //load the user account
//TODO: handle passwords //TODO: handle passwords
int accountIndex = accountMgr.LoadAccount(argPacket->username, clientUID); int accountIndex = accountMgr.LoadAccount(argPacket->username, clientIndex);
if (accountIndex < 0) { if (accountIndex < 0) {
//TODO: send rejection packet //TODO: send rejection packet
std::cerr << "Error: Account already loaded: " << accountIndex << std::endl; std::cerr << "Error: Account already loaded: " << accountIndex << std::endl;
@@ -56,13 +56,13 @@ void ServerApplication::HandleJoinRequest(ClientPacket* const argPacket) {
//send the client their info //send the client their info
ClientPacket newPacket; ClientPacket newPacket;
newPacket.type = SerialPacketType::JOIN_RESPONSE; newPacket.type = SerialPacketType::JOIN_RESPONSE;
newPacket.clientIndex = clientUID; newPacket.clientIndex = clientIndex;
newPacket.accountIndex = accountIndex; newPacket.accountIndex = accountIndex;
network.SendTo(&newClient.address, static_cast<SerialPacket*>(&newPacket)); network.SendTo(&newClient.address, static_cast<SerialPacket*>(&newPacket));
//finished this routine //finished this routine
clientMap[clientUID++] = newClient; clientMap[clientIndex++] = newClient;
std::cout << "New connection, " << clientMap.size() << " clients and " << accountMgr.GetContainer()->size() << " accounts total" << std::endl; std::cout << "New connection, " << clientMap.size() << " clients and " << accountMgr.GetContainer()->size() << " accounts total" << std::endl;
} }
+1
View File
@@ -3,6 +3,7 @@ TODO: A proper logging system
TODO: Ping-pong and keep alive system TODO: Ping-pong and keep alive system
TODO: Move the statistics into their own SQL table, instead of duplicating the structure a dozen times TODO: Move the statistics into their own SQL table, instead of duplicating the structure a dozen times
TODO: Get the rooms working, even if only via hotkeys TODO: Get the rooms working, even if only via hotkeys
TODO: Rejection messages
TODO: Fix shoddy movement TODO: Fix shoddy movement
TODO: make the whole thing more fault tolerant TODO: make the whole thing more fault tolerant