mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
minor cleanup
This commit is contained in:
parent
73c67a814d
commit
4f6c77be4f
@ -26,26 +26,22 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
int errorCode = 0;
|
int errorCode = 0;
|
||||||
std::string userLogin = U16toU8(login->szID);
|
std::string userLogin = U16toU8(login->szID);
|
||||||
std::string userPassword = U16toU8(login->szPassword);
|
std::string userPassword = U16toU8(login->szPassword);
|
||||||
//checking regex
|
|
||||||
if (!Database::isLoginDataGood(userLogin, userPassword)) {
|
|
||||||
errorCode = (int)LOGINERRORID::login_error;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!Database::isLoginDataGood(userLogin, userPassword)) {
|
||||||
|
// failed regex
|
||||||
|
errorCode = (int)LOGINERRORID::login_error;
|
||||||
|
} else if (!Database::doesUserExist(U16toU8(login->szID))) {
|
||||||
// if user does not exist in db, add him to and send succ
|
// if user does not exist in db, add him to and send succ
|
||||||
else if (!Database::doesUserExist(U16toU8(login->szID))) {
|
|
||||||
Database::addAccount(U16toU8(login->szID), U16toU8(login->szPassword));
|
Database::addAccount(U16toU8(login->szID), U16toU8(login->szPassword));
|
||||||
success = true;
|
success = true;
|
||||||
}
|
} else if (Database::isPasswordCorrect((U16toU8(login->szID)), U16toU8(login->szPassword))) {
|
||||||
// if user exists, check if password is correct
|
// if user exists, check if password is correct
|
||||||
else if (Database::isPasswordCorrect((U16toU8(login->szID)), U16toU8(login->szPassword))) {
|
|
||||||
success = true;
|
success = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
errorCode = (int)LOGINERRORID::id_and_password_do_not_match;
|
errorCode = (int)LOGINERRORID::id_and_password_do_not_match;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success)
|
if (success) {
|
||||||
{
|
|
||||||
int userID = Database::getUserID(userLogin);
|
int userID = Database::getUserID(userLogin);
|
||||||
int charCount = Database::getUserSlotsNum(userID);
|
int charCount = Database::getUserSlotsNum(userID);
|
||||||
|
|
||||||
@ -75,8 +71,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
std::list<Player> characters = Database::getCharacters(loginSessions[sock].userID);
|
std::list<Player> characters = Database::getCharacters(loginSessions[sock].userID);
|
||||||
std::list<Player>::iterator it;
|
std::list<Player>::iterator it;
|
||||||
for (it = characters.begin(); it != characters.end(); it++)
|
for (it = characters.begin(); it != characters.end(); it++) {
|
||||||
{
|
|
||||||
sP_LS2CL_REP_CHAR_INFO charInfo = sP_LS2CL_REP_CHAR_INFO();
|
sP_LS2CL_REP_CHAR_INFO charInfo = sP_LS2CL_REP_CHAR_INFO();
|
||||||
|
|
||||||
charInfo.iSlot = (int8_t)it->slot;
|
charInfo.iSlot = (int8_t)it->slot;
|
||||||
@ -103,10 +98,6 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
loginSessions[sock].characters[UID].IsGM = false;
|
loginSessions[sock].characters[UID].IsGM = false;
|
||||||
loginSessions[sock].characters[UID].money = 9001;
|
loginSessions[sock].characters[UID].money = 9001;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Player test = loginSessions[sock].characters[UID];
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
//equip char creation clothes and lightning rifle
|
//equip char creation clothes and lightning rifle
|
||||||
charInfo.aEquip[i] = it->Equip[i];
|
charInfo.aEquip[i] = it->Equip[i];
|
||||||
@ -134,71 +125,10 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
loginSessions[sock].selectedChar = UID;
|
loginSessions[sock].selectedChar = UID;
|
||||||
|
|
||||||
sock->sendPacket((void*)&charInfo, P_LS2CL_REP_CHAR_INFO, sizeof(sP_LS2CL_REP_CHAR_INFO));
|
sock->sendPacket((void*)&charInfo, P_LS2CL_REP_CHAR_INFO, sizeof(sP_LS2CL_REP_CHAR_INFO));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//for (int i = 0; i < charCount; i++) {
|
} else {
|
||||||
// sP_LS2CL_REP_CHAR_INFO charInfo = sP_LS2CL_REP_CHAR_INFO();
|
// failed
|
||||||
// charInfo.iSlot = (int8_t)i + 1;
|
|
||||||
// charInfo.iLevel = (int16_t)36;
|
|
||||||
// charInfo.sPC_Style.iPC_UID = rand(); // unique identifier for the character
|
|
||||||
// charInfo.sPC_Style.iNameCheck = 1;
|
|
||||||
// charInfo.sPC_Style.iGender = (i%2)+1; // can be 1(boy) or 2(girl)
|
|
||||||
// charInfo.sPC_Style.iFaceStyle = 1;
|
|
||||||
// charInfo.sPC_Style.iHairStyle = 1;
|
|
||||||
// charInfo.sPC_Style.iHairColor = (rand()%19) + 1; // 1 - 19
|
|
||||||
// charInfo.sPC_Style.iSkinColor = (rand()%13) + 1; // 1 - 13
|
|
||||||
// charInfo.sPC_Style.iEyeColor = (rand()%6) + 1; // 1 - 6
|
|
||||||
// charInfo.sPC_Style.iHeight = (rand()%6); // 0 -5
|
|
||||||
// charInfo.sPC_Style.iBody = (rand()%4); // 0 - 3
|
|
||||||
// charInfo.sPC_Style.iClass = 0;
|
|
||||||
// charInfo.sPC_Style2.iAppearanceFlag = 1;
|
|
||||||
// charInfo.sPC_Style2.iPayzoneFlag = 1;
|
|
||||||
// charInfo.sPC_Style2.iTutorialFlag = 1;
|
|
||||||
|
|
||||||
// // past's town hall
|
|
||||||
// charInfo.iX = settings::SPAWN_X;
|
|
||||||
// charInfo.iY = settings::SPAWN_Y;
|
|
||||||
// charInfo.iZ = settings::SPAWN_Z;
|
|
||||||
|
|
||||||
// U8toU16(std::string("Player"), charInfo.sPC_Style.szFirstName);
|
|
||||||
// U8toU16(std::to_string(i + 1), charInfo.sPC_Style.szLastName);
|
|
||||||
|
|
||||||
// int64_t UID = charInfo.sPC_Style.iPC_UID;
|
|
||||||
// loginSessions[sock].characters[UID] = Player();
|
|
||||||
// loginSessions[sock].characters[UID].level = charInfo.iLevel;
|
|
||||||
// loginSessions[sock].characters[UID].money = 9001;
|
|
||||||
// loginSessions[sock].characters[UID].slot = charInfo.iSlot;
|
|
||||||
// loginSessions[sock].characters[UID].FEKey = sock->getFEKey();
|
|
||||||
// loginSessions[sock].characters[UID].x = charInfo.iX;
|
|
||||||
// loginSessions[sock].characters[UID].y = charInfo.iY;
|
|
||||||
// loginSessions[sock].characters[UID].z = charInfo.iZ;
|
|
||||||
// loginSessions[sock].characters[UID].PCStyle = charInfo.sPC_Style;
|
|
||||||
// loginSessions[sock].characters[UID].PCStyle2 = charInfo.sPC_Style2;
|
|
||||||
// loginSessions[sock].characters[UID].isTrading = false;
|
|
||||||
// loginSessions[sock].characters[UID].isTradeConfirm = false;
|
|
||||||
// loginSessions[sock].characters[UID].IsGM = settings::GM;
|
|
||||||
|
|
||||||
// for (int i = 0; i < AEQUIP_COUNT; i++) {
|
|
||||||
// // setup equips
|
|
||||||
// charInfo.aEquip[i].iID = 0;
|
|
||||||
// charInfo.aEquip[i].iType = i;
|
|
||||||
// charInfo.aEquip[i].iOpt = 0;
|
|
||||||
// loginSessions[sock].characters[UID].Equip[i] = charInfo.aEquip[i];
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for (int i = 0; i < AINVEN_COUNT; i++) {
|
|
||||||
// // setup inventories
|
|
||||||
// loginSessions[sock].characters[UID].Inven[i].iID = 0;
|
|
||||||
// loginSessions[sock].characters[UID].Inven[i].iType = 0;
|
|
||||||
// loginSessions[sock].characters[UID].Inven[i].iOpt = 0;
|
|
||||||
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
//Failure
|
|
||||||
else {
|
|
||||||
|
|
||||||
INITSTRUCT(sP_LS2CL_REP_LOGIN_FAIL, resp);
|
INITSTRUCT(sP_LS2CL_REP_LOGIN_FAIL, resp);
|
||||||
|
|
||||||
memcpy(resp.szID, login->szID, sizeof(char16_t) * 33);
|
memcpy(resp.szID, login->szID, sizeof(char16_t) * 33);
|
||||||
@ -206,7 +136,6 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_LS2CL_REP_LOGIN_FAIL, sizeof(sP_LS2CL_REP_LOGIN_FAIL));
|
sock->sendPacket((void*)&resp, P_LS2CL_REP_LOGIN_FAIL, sizeof(sP_LS2CL_REP_LOGIN_FAIL));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case P_CL2LS_REP_LIVE_CHECK: {
|
case P_CL2LS_REP_LIVE_CHECK: {
|
||||||
@ -300,16 +229,6 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
int64_t UID = character->PCStyle.iPC_UID;
|
int64_t UID = character->PCStyle.iPC_UID;
|
||||||
|
|
||||||
// commented and disabled for now
|
|
||||||
//bool BecomeGM;
|
|
||||||
|
|
||||||
//if (U16toU8(character->PCStyle.szFirstName) == settings::GMPASS) {
|
|
||||||
// BecomeGM = true;
|
|
||||||
// U8toU16("GM",character->PCStyle.szFirstName);
|
|
||||||
//} else {
|
|
||||||
// BecomeGM = false;
|
|
||||||
//}
|
|
||||||
|
|
||||||
character->PCStyle.iNameCheck = 1;
|
character->PCStyle.iNameCheck = 1;
|
||||||
resp.sPC_Style = character->PCStyle;
|
resp.sPC_Style = character->PCStyle;
|
||||||
resp.sPC_Style2.iAppearanceFlag = 1;
|
resp.sPC_Style2.iAppearanceFlag = 1;
|
||||||
@ -356,8 +275,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
INITSTRUCT(sP_LS2CL_REP_CHAR_DELETE_SUCC, resp);
|
INITSTRUCT(sP_LS2CL_REP_CHAR_DELETE_SUCC, resp);
|
||||||
resp.iSlotNum = operationResult;
|
resp.iSlotNum = operationResult;
|
||||||
sock->sendPacket((void*)&resp, P_LS2CL_REP_CHAR_DELETE_SUCC, sizeof(sP_LS2CL_REP_CHAR_DELETE_SUCC));
|
sock->sendPacket((void*)&resp, P_LS2CL_REP_CHAR_DELETE_SUCC, sizeof(sP_LS2CL_REP_CHAR_DELETE_SUCC));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// failure
|
// failure
|
||||||
// client doesnt't care about this packet and softlocks
|
// client doesnt't care about this packet and softlocks
|
||||||
INITSTRUCT(sP_LS2CL_REP_CHAR_DELETE_FAIL, resp);
|
INITSTRUCT(sP_LS2CL_REP_CHAR_DELETE_FAIL, resp);
|
||||||
@ -415,6 +333,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
case P_CL2LS_REQ_SAVE_CHAR_TUTOR: {
|
case P_CL2LS_REQ_SAVE_CHAR_TUTOR: {
|
||||||
if (data->size != sizeof(sP_CL2LS_REQ_SAVE_CHAR_TUTOR))
|
if (data->size != sizeof(sP_CL2LS_REQ_SAVE_CHAR_TUTOR))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sP_CL2LS_REQ_SAVE_CHAR_TUTOR* save = (sP_CL2LS_REQ_SAVE_CHAR_TUTOR*)data->buf;
|
sP_CL2LS_REQ_SAVE_CHAR_TUTOR* save = (sP_CL2LS_REQ_SAVE_CHAR_TUTOR*)data->buf;
|
||||||
Database::finishTutorial(save->iPC_UID);
|
Database::finishTutorial(save->iPC_UID);
|
||||||
loginSessions[sock].characters[save->iPC_UID].PCStyle2.iTutorialFlag = 1;
|
loginSessions[sock].characters[save->iPC_UID].PCStyle2.iTutorialFlag = 1;
|
||||||
@ -425,7 +344,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if (settings::VERBOSITY)
|
if (settings::VERBOSITY > 0)
|
||||||
std::cerr << "OpenFusion: LOGIN UNIMPLM ERR. PacketType: " << Defines::p2str(CL2LS, data->type) << " (" << data->type << ")" << std::endl;
|
std::cerr << "OpenFusion: LOGIN UNIMPLM ERR. PacketType: " << Defines::p2str(CL2LS, data->type) << " (" << data->type << ")" << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ void CNShardServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
if (ShardPackets.find(data->type) != ShardPackets.end())
|
if (ShardPackets.find(data->type) != ShardPackets.end())
|
||||||
ShardPackets[data->type](sock, data);
|
ShardPackets[data->type](sock, data);
|
||||||
else if (settings::VERBOSITY)
|
else if (settings::VERBOSITY > 0)
|
||||||
std::cerr << "OpenFusion: SHARD UNIMPLM ERR. PacketType: " << Defines::p2str(CL2FE, data->type) << " (" << data->type << ")" << std::endl;
|
std::cerr << "OpenFusion: SHARD UNIMPLM ERR. PacketType: " << Defines::p2str(CL2FE, data->type) << " (" << data->type << ")" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user