bool Socket::HandleNameInput() { Player* mob = nullptr; std::string input; World* world = World::GetPtr(); Server* server = world->GetServer(); input = PopCommand(); //new player: if (input=="new") { Write("Welcome, what name would you like?\n"); AllocatePlayer(); mob = GetPlayer(); SetConnectionType(CON_Newname); return true; } //checks to see if the username is valid if (!IsValidUserName(input)) { Write("Invalid name, try again.\n"); return true; } //check to see if the player exists if (!PlayerExists(input)) { Write("That player doesn't exist.\nWhat is your name? Type new for a new character.\n"); return true; } mob = server->GetLinkdeadUser(input); if (mob) { _mobile = mob; Write(TELNET_ECHO_OFF); Write("\n"); Write("Password?\n"); SetConnectionType(CON_Password); return true; } AllocatePlayer(); mob = GetPlayer(); //set the players name to the one specified and try to load the file. mob->SetName(input); mob->Load(); Write(TELNET_ECHO_OFF); Write("\n"); Write("Password?\n"); SetConnectionType(CON_Password); return true; }
bool Socket::HandleNameInput() { Player* mob = nullptr; std::string input; //we associate a player with the socket object so we can store data and later load. AllocatePlayer(); mob = GetPlayer(); input = PopCommand(); //new player: if (input=="new") { Write("Welcome, what name would you like?\n"); SetConnectionType(ConnectionType::Newname); return true; } //checks to see if the username is valid if (!IsValidUserName(input)) { Write("Invalid name, try again.\n"); return true; } //check to see if the player exists if (!PlayerExists(input)) { Write("That player doesn't exist.\nWhat is your name? Type new for a new character.\n"); return true; } //set the players name to the one specified and try to load the file. mob->SetName(input); mob->Load(); Write(TELNET_ECHO_OFF); Write("\n"); Write("Password?\n"); SetConnectionType(ConnectionType::Password); return true; }