login crash bug

This commit is contained in:
2024-03-09 21:08:58 -06:00
parent 64e6e035c1
commit 0759c56b14
2 changed files with 30 additions and 31 deletions
@@ -30,6 +30,7 @@ import engine.server.MBServerStatics;
import engine.session.CSSession;
import engine.session.Session;
import engine.util.ByteUtils;
import engine.util.MiscUtils;
import engine.util.StringUtils;
import org.pmw.tinylog.Logger;
@@ -343,12 +344,40 @@ public class LoginServerMsgHandler implements NetMsgHandler {
this.sendCharacterSelectScreen(session);
return;
}
String firstName = commitNewCharacterMessage.getFirstName().trim();
String lastName = commitNewCharacterMessage.getLastName().trim();
if (firstName.length() < 3) {
LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_FIRSTNAME_MUST_BE_LONGER,
clientConnection);
return;
}
// Ensure names are below required length
if (firstName.length() > 15 || lastName.length() > 15) {
LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_FIRSTANDLAST_MUST_BE_SHORTER,
clientConnection);
return;
}
// Check if firstname is valid
if (MiscUtils.checkIfFirstNameInvalid(firstName)) {
LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_PLEASE_CHOOSE_ANOTHER_FIRSTNAME,
clientConnection);
return;
}
// Check if last name is valid
if (MiscUtils.checkIfLastNameInvalid(lastName)) {
LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_LASTNAME_UNAVAILABLE,
clientConnection);
return;
}
PlayerCharacter pc = PlayerCharacter.generatePCFromCommitNewCharacterMsg(session.getAccount(), commitNewCharacterMessage, clientConnection);
if (pc == null) {
Logger.info("Player returned null while creating character.");
//this.sendCharacterSelectScreen(session, true);
this.sendCharacterSelectScreen(session, true);
return;
}
PlayerCharacter.initializePlayer(pc);