Added a proper disconnection message by hacking the config
This commit is contained in:
@@ -90,8 +90,10 @@ void CleanUp::Update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CleanUp::Render(SDL_Surface* const screen) {
|
void CleanUp::Render(SDL_Surface* const screen) {
|
||||||
|
ConfigUtility& config = ConfigUtility::GetSingleton();
|
||||||
|
|
||||||
backButton.DrawTo(screen);
|
backButton.DrawTo(screen);
|
||||||
font.DrawStringTo("You have been disconnected.", screen, 50, 30);
|
font.DrawStringTo(config["client.disconnectMessage"], screen, 50, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|||||||
@@ -152,7 +152,9 @@ void InWorld::Update() {
|
|||||||
//check the connection
|
//check the connection
|
||||||
if (Clock::now() - lastBeat > std::chrono::seconds(3)) {
|
if (Clock::now() - lastBeat > std::chrono::seconds(3)) {
|
||||||
if (attemptedBeats > 2) {
|
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;
|
ServerPacket newPacket;
|
||||||
@@ -341,6 +343,7 @@ void InWorld::HandlePong(ServerPacket* const argPacket) {
|
|||||||
void InWorld::HandleDisconnect(ClientPacket* const argPacket) {
|
void InWorld::HandleDisconnect(ClientPacket* const argPacket) {
|
||||||
//TODO: More needed in the disconnection
|
//TODO: More needed in the disconnection
|
||||||
SetNextScene(SceneList::CLEANUP);
|
SetNextScene(SceneList::CLEANUP);
|
||||||
|
ConfigUtility::GetSingleton()["client.disconnectMessage"] = "You have been disconnected";
|
||||||
}
|
}
|
||||||
|
|
||||||
void InWorld::HandleCharacterNew(CharacterPacket* const argPacket) {
|
void InWorld::HandleCharacterNew(CharacterPacket* const argPacket) {
|
||||||
@@ -415,9 +418,11 @@ void InWorld::HandleCharacterUpdate(CharacterPacket* const argPacket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InWorld::HandleCharacterRejection(TextPacket* const argPacket) {
|
void InWorld::HandleCharacterRejection(TextPacket* const argPacket) {
|
||||||
std::cerr << "Error: " << argPacket->text << std::endl;
|
|
||||||
RequestDisconnect();
|
RequestDisconnect();
|
||||||
SetNextScene(SceneList::CLEANUP);
|
SetNextScene(SceneList::CLEANUP);
|
||||||
|
ConfigUtility& config = ConfigUtility::GetSingleton();
|
||||||
|
config["client.disconnectMessage"] = "Error: ";
|
||||||
|
config["client.disconnectMessage"] += argPacket->text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InWorld::HandleRegionContent(RegionPacket* const argPacket) {
|
void InWorld::HandleRegionContent(RegionPacket* const argPacket) {
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ protected:
|
|||||||
Character* localCharacter = nullptr;
|
Character* localCharacter = nullptr;
|
||||||
|
|
||||||
//connections
|
//connections
|
||||||
|
//TODO: This needs it's own utility, for both InWorld and InCombat
|
||||||
typedef std::chrono::steady_clock Clock;
|
typedef std::chrono::steady_clock Clock;
|
||||||
Clock::time_point lastBeat = Clock::now();
|
Clock::time_point lastBeat = Clock::now();
|
||||||
int attemptedBeats = 0;
|
int attemptedBeats = 0;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
TODO: The error handling is terrible
|
|
||||||
TODO: Get the rooms working, even if only via hotkeys
|
TODO: Get the rooms working, even if only via hotkeys
|
||||||
TODO: Fix shoddy movement
|
TODO: Fix shoddy movement
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user