Added a proper disconnection message by hacking the config

This commit is contained in:
Kayne Ruse
2014-09-10 17:35:12 +10:00
parent ad2c65dc67
commit 411687b41c
4 changed files with 11 additions and 4 deletions
+3 -1
View File
@@ -90,8 +90,10 @@ void CleanUp::Update() {
}
void CleanUp::Render(SDL_Surface* const screen) {
ConfigUtility& config = ConfigUtility::GetSingleton();
backButton.DrawTo(screen);
font.DrawStringTo("You have been disconnected.", screen, 50, 30);
font.DrawStringTo(config["client.disconnectMessage"], screen, 50, 30);
}
//-------------------------
+7 -2
View File
@@ -152,7 +152,9 @@ void InWorld::Update() {
//check the connection
if (Clock::now() - lastBeat > std::chrono::seconds(3)) {
if (attemptedBeats > 2) {
throw(std::runtime_error("Connection lost"));
RequestDisconnect();
SetNextScene(SceneList::CLEANUP);
ConfigUtility::GetSingleton()["client.disconnectMessage"] = "Error: Lost connection to the server";
}
ServerPacket newPacket;
@@ -341,6 +343,7 @@ void InWorld::HandlePong(ServerPacket* const argPacket) {
void InWorld::HandleDisconnect(ClientPacket* const argPacket) {
//TODO: More needed in the disconnection
SetNextScene(SceneList::CLEANUP);
ConfigUtility::GetSingleton()["client.disconnectMessage"] = "You have been disconnected";
}
void InWorld::HandleCharacterNew(CharacterPacket* const argPacket) {
@@ -415,9 +418,11 @@ void InWorld::HandleCharacterUpdate(CharacterPacket* const argPacket) {
}
void InWorld::HandleCharacterRejection(TextPacket* const argPacket) {
std::cerr << "Error: " << argPacket->text << std::endl;
RequestDisconnect();
SetNextScene(SceneList::CLEANUP);
ConfigUtility& config = ConfigUtility::GetSingleton();
config["client.disconnectMessage"] = "Error: ";
config["client.disconnectMessage"] += argPacket->text;
}
void InWorld::HandleRegionContent(RegionPacket* const argPacket) {
+1
View File
@@ -127,6 +127,7 @@ protected:
Character* localCharacter = nullptr;
//connections
//TODO: This needs it's own utility, for both InWorld and InCombat
typedef std::chrono::steady_clock Clock;
Clock::time_point lastBeat = Clock::now();
int attemptedBeats = 0;
-1
View File
@@ -1,4 +1,3 @@
TODO: The error handling is terrible
TODO: Get the rooms working, even if only via hotkeys
TODO: Fix shoddy movement
TODO: Move the statistics into their own SQL table, instead of duplicating the structure a dozen times