void LoginResultHandler::handle(InPacket& recv) const { // Remove login information. UI::get().remove(UIElement::LOGINNOTICE); UI::get().remove(UIElement::LOGINWAIT); // The packet should contain a 'reason' integer which can signify various things. int32_t reason = recv.readint(); if (reason != 0) { // Login unsuccessfull. The LoginNotice displayed will contain the specific information. switch (reason) { case 2: UI::get().add(ElementLoginNotice(16)); break; case 7: UI::get().add(ElementLoginNotice(17)); break; case 23: // The server sends a request to accept the terms of service. For convenience, just auto-accept. TOSPacket().dispatch(); break; default: // Other reasons. if (reason > 0) { auto reasonbyte = static_cast<int8_t>(reason - 1); UI::get().add(ElementLoginNotice(reasonbyte)); } } UI::get().enable(); } else { // Login successfull. The packet contains information on the account, so we initialise the account with it. Session::get().getlogin().parseaccount(recv); // Save the Login ID if the box for it on the login panel is checked. bool savelogin = Setting<SaveLogin>::get().load(); if (savelogin) { string name = Session::get().getlogin().getaccount().name; Setting<DefaultAccount>::get().save(name); } // Request the list of worlds and channels online. ServerRequestPacket().dispatch(); } }
void DeleteCharResponseHandler::handle(InPacket& recv) const { // Read the character id and if deletion was successfull (pic was correct). recv.readint(); // charid bool success = recv.readbool(); // Show the result to the user. if (success) { UI::get().add(ElementLoginNotice(UILoginNotice::CASH_ITEMS_CONFIRM_DELETION)); } else { UI::get().add(ElementLoginNotice(UILoginNotice::BIRTHDAY_INCORRECT)); } }
void CharnameResponseHandler::handle(InPacket& recv) const { // Read the name and if it is already in use. string name = recv.read<string>(); bool used = recv.readbool(); if (used) { UI::get().add(ElementLoginNotice(UILoginNotice::NAME_IN_USE)); } // Notify character creation screen. UI::get().withelement(UIElement::CHARCREATION, &UICharcreation::nameresult, used); UI::get().enable(); }