mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 06:50:04 +00:00
Sanity checks + Starting level changes (#31)
* Sanity checks + Starting level changes - Item movement handler checks to make sure items aren't moved from equipment slot to equipment slot. - Item give command checks to make sure an out of bounds item is not spawned (Below iType 0 or above iType 8) - Players now begin at level 36, consequently the item give command does not level you up now. * Sanity Check - Prevents out of bounds item movement by comparing it to AINVEN_COUNT.
This commit is contained in:
parent
55add82843
commit
ff5f3966e3
@ -208,11 +208,11 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.sPC_Style2.iAppearanceFlag = 1;
|
resp.sPC_Style2.iAppearanceFlag = 1;
|
||||||
resp.sPC_Style2.iTutorialFlag = 1;
|
resp.sPC_Style2.iTutorialFlag = 1;
|
||||||
resp.sPC_Style2.iPayzoneFlag = 1;
|
resp.sPC_Style2.iPayzoneFlag = 1;
|
||||||
resp.iLevel = 1;
|
resp.iLevel = 36;
|
||||||
resp.sOn_Item = character->sOn_Item;
|
resp.sOn_Item = character->sOn_Item;
|
||||||
|
|
||||||
loginSessions[sock].characters[UID] = Player();
|
loginSessions[sock].characters[UID] = Player();
|
||||||
loginSessions[sock].characters[UID].level = 1;
|
loginSessions[sock].characters[UID].level = 36;
|
||||||
loginSessions[sock].characters[UID].FEKey = sock->getFEKey();
|
loginSessions[sock].characters[UID].FEKey = sock->getFEKey();
|
||||||
loginSessions[sock].characters[UID].PCStyle = character->PCStyle;
|
loginSessions[sock].characters[UID].PCStyle = character->PCStyle;
|
||||||
loginSessions[sock].characters[UID].PCStyle2.iAppearanceFlag = 1;
|
loginSessions[sock].characters[UID].PCStyle2.iAppearanceFlag = 1;
|
||||||
|
@ -18,6 +18,23 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
INITSTRUCT(sP_FE2CL_PC_ITEM_MOVE_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_PC_ITEM_MOVE_SUCC, resp);
|
||||||
|
|
||||||
PlayerView& plr = PlayerManager::players[sock];
|
PlayerView& plr = PlayerManager::players[sock];
|
||||||
|
|
||||||
|
if (itemmove->eFrom == 0 && itemmove->eTo == 0) {
|
||||||
|
// this packet should never happen, tell the client to do nothing and do nothing ourself
|
||||||
|
resp.eTo = itemmove->eFrom;
|
||||||
|
resp.iToSlotNum = itemmove->iFromSlotNum;
|
||||||
|
resp.ToSlotItem = plr.plr.Equip[itemmove->iToSlotNum];
|
||||||
|
resp.eFrom = itemmove->eTo;
|
||||||
|
resp.iFromSlotNum = itemmove->iToSlotNum;
|
||||||
|
resp.FromSlotItem = plr.plr.Equip[itemmove->iFromSlotNum];
|
||||||
|
|
||||||
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_ITEM_DELETE_SUCC, sizeof(sP_FE2CL_REP_PC_ITEM_DELETE_SUCC));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemmove->iToSlotNum > AINVEN_COUNT)
|
||||||
|
return; // sanity checks
|
||||||
|
|
||||||
sItemBase fromItem;
|
sItemBase fromItem;
|
||||||
sItemBase toItem;
|
sItemBase toItem;
|
||||||
|
|
||||||
@ -109,7 +126,8 @@ void ItemManager::itemGMGiveHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (itemreq->eIL == 2) {
|
if (itemreq->eIL == 2) {
|
||||||
// Quest item, not a real item, handle this later, stubbed for now
|
// Quest item, not a real item, handle this later, stubbed for now
|
||||||
// sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_PC_GIVE_ITEM_FAIL, sizeof(sP_FE2CL_REP_PC_GIVE_ITEM_FAIL), sock->getFEKey()));
|
// sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_PC_GIVE_ITEM_FAIL, sizeof(sP_FE2CL_REP_PC_GIVE_ITEM_FAIL), sock->getFEKey()));
|
||||||
} else if (itemreq->eIL == 1) {
|
} else if (itemreq->eIL == 1 && itemreq->Item.iType >= 0 && itemreq->Item.iType <= 8) {
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_GIVE_ITEM_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_PC_GIVE_ITEM_SUCC, resp);
|
||||||
|
|
||||||
resp.eIL = itemreq->eIL;
|
resp.eIL = itemreq->eIL;
|
||||||
@ -117,17 +135,18 @@ void ItemManager::itemGMGiveHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.Item = itemreq->Item;
|
resp.Item = itemreq->Item;
|
||||||
|
|
||||||
plr.plr.Inven[itemreq->iSlotNum] = itemreq->Item;
|
plr.plr.Inven[itemreq->iSlotNum] = itemreq->Item;
|
||||||
plr.plr.level = 36;
|
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_GIVE_ITEM_SUCC, sizeof(sP_FE2CL_REP_PC_GIVE_ITEM_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_GIVE_ITEM_SUCC, sizeof(sP_FE2CL_REP_PC_GIVE_ITEM_SUCC));
|
||||||
|
|
||||||
// some items require a level, for now we're just going to bypass this by setting your level to 36
|
// some items require a level, for now we're just going to bypass this by setting your level to 36
|
||||||
|
//plr.plr.level = 36;
|
||||||
|
|
||||||
sP_FE2CL_REP_PC_CHANGE_LEVEL resp2;
|
//sP_FE2CL_REP_PC_CHANGE_LEVEL resp2;
|
||||||
|
|
||||||
resp2.iPC_ID = plr.plr.iID;
|
//resp2.iPC_ID = plr.plr.iID;
|
||||||
resp2.iPC_Level = 36;
|
//resp2.iPC_Level = 36;
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp2, P_FE2CL_REP_PC_CHANGE_LEVEL, sizeof(sP_FE2CL_REP_PC_CHANGE_LEVEL));
|
//sock->sendPacket((void*)&resp2, P_FE2CL_REP_PC_CHANGE_LEVEL, sizeof(sP_FE2CL_REP_PC_CHANGE_LEVEL));
|
||||||
|
// saving this for later use on a /level command
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -187,7 +187,7 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
response.iID = rand();
|
response.iID = rand();
|
||||||
response.uiSvrTime = getTime();
|
response.uiSvrTime = getTime();
|
||||||
response.PCLoadData2CL.iUserLevel = 1;
|
response.PCLoadData2CL.iUserLevel = 1;
|
||||||
response.PCLoadData2CL.iHP = 1000 * plr.level;
|
response.PCLoadData2CL.iHP = 3625; //TODO: Check player levelupdata and get this right
|
||||||
response.PCLoadData2CL.iLevel = plr.level;
|
response.PCLoadData2CL.iLevel = plr.level;
|
||||||
response.PCLoadData2CL.iMentor = 1;
|
response.PCLoadData2CL.iMentor = 1;
|
||||||
response.PCLoadData2CL.iMentorCount = 4;
|
response.PCLoadData2CL.iMentorCount = 4;
|
||||||
|
Loading…
Reference in New Issue
Block a user