mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2025-12-19 11:10:34 +00:00
Make name checking case insensitive.
Co-authored-by: kamilprzyb <kamilprzybspam@wp.pl>
This commit is contained in:
@@ -131,7 +131,6 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
//Equip info
|
||||
for (int i = 0; i < AEQUIP_COUNT; i++) {
|
||||
//equip char creation clothes and lightning rifle
|
||||
charInfo.aEquip[i] = it->Equip[i];
|
||||
}
|
||||
|
||||
@@ -162,13 +161,22 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2LS_REQ_CHECK_CHAR_NAME))
|
||||
return;
|
||||
|
||||
// naughty words allowed!!!!!!!! (also for some reason, the client will always show 'Player 0' if you manually type a name. It will show up for other connected players though)
|
||||
sP_CL2LS_REQ_CHECK_CHAR_NAME* nameCheck = (sP_CL2LS_REQ_CHECK_CHAR_NAME*)data->buf;
|
||||
//check if name is occupied
|
||||
if (Database::isNameFree(nameCheck))
|
||||
{
|
||||
// naughty words allowed!!!!!!!! (also for some reason, the client will always show 'Player + ID' if you manually type a name. It will show up for other connected players though)
|
||||
bool success = true;
|
||||
int errorcode = 0;
|
||||
|
||||
//check regex
|
||||
if (!CNLoginServer::isCharacterNameGood(U16toU8(nameCheck->szFirstName), U16toU8(nameCheck->szLastName))) {
|
||||
success = false;
|
||||
errorcode = 4;
|
||||
}
|
||||
//check if name isn't already occupied
|
||||
else if (!Database::isNameFree(nameCheck)){
|
||||
success = false;
|
||||
errorcode = 1;
|
||||
}
|
||||
|
||||
if (success){
|
||||
INITSTRUCT(sP_LS2CL_REP_CHECK_CHAR_NAME_SUCC, resp);
|
||||
|
||||
DEBUGLOG(
|
||||
@@ -178,17 +186,15 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
memcpy(resp.szFirstName, nameCheck->szFirstName, sizeof(char16_t) * 9);
|
||||
memcpy(resp.szLastName, nameCheck->szLastName, sizeof(char16_t) * 17);
|
||||
|
||||
// fr*ck allowed!!!
|
||||
|
||||
sock->sendPacket((void*)&resp, P_LS2CL_REP_CHECK_CHAR_NAME_SUCC, sizeof(sP_LS2CL_REP_CHECK_CHAR_NAME_SUCC));
|
||||
}
|
||||
else {
|
||||
INITSTRUCT(sP_LS2CL_REP_CHECK_CHAR_NAME_FAIL, resp);
|
||||
resp.iErrorCode = 1;
|
||||
resp.iErrorCode = errorcode;
|
||||
sock->sendPacket((void*)&resp, P_LS2CL_REP_CHECK_CHAR_NAME_FAIL, sizeof(sP_LS2CL_REP_CHECK_CHAR_NAME_FAIL));
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
case P_CL2LS_REQ_SAVE_CHAR_NAME: {
|
||||
if (data->size != sizeof(sP_CL2LS_REQ_SAVE_CHAR_NAME))
|
||||
@@ -411,4 +417,10 @@ bool CNLoginServer::isPasswordCorrect(std::string actualPassword, std::string tr
|
||||
{
|
||||
return BCrypt::validatePassword(tryPassword, actualPassword);
|
||||
}
|
||||
bool CNLoginServer::isCharacterNameGood(std::string Firstname, std::string Lastname)
|
||||
{
|
||||
std::regex firstnamecheck("[a-zA-Z0-9]+(?: [a-zA-Z0-9]+)*$");
|
||||
std::regex lastnamecheck("[a-zA-Z0-9]+(?: [a-zA-Z0-9]+)*$");
|
||||
return (std::regex_match(Firstname, firstnamecheck) && std::regex_match(Lastname, lastnamecheck));
|
||||
}
|
||||
#pragma endregion helperMethods
|
||||
|
||||
Reference in New Issue
Block a user