mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 06:50:04 +00:00
added sanity checks to nanos
This commit is contained in:
parent
6129c0b4e2
commit
d6b96389be
@ -20,9 +20,13 @@ void NanoManager::nanoEquipHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
INITSTRUCT(sP_FE2CL_REP_NANO_EQUIP_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_NANO_EQUIP_SUCC, resp);
|
||||||
Player plr = PlayerManager::getPlayer(sock);
|
Player plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
|
if (nano->iNanoSlotNum > 2)
|
||||||
|
return;
|
||||||
|
|
||||||
resp.iNanoID = nano->iNanoID;
|
resp.iNanoID = nano->iNanoID;
|
||||||
resp.iNanoSlotNum = nano->iNanoSlotNum;
|
resp.iNanoSlotNum = nano->iNanoSlotNum;
|
||||||
|
|
||||||
|
|
||||||
// Update player
|
// Update player
|
||||||
plr.equippedNanos[nano->iNanoSlotNum] = nano->iNanoID;
|
plr.equippedNanos[nano->iNanoSlotNum] = nano->iNanoID;
|
||||||
PlayerManager::updatePlayer(sock, plr);
|
PlayerManager::updatePlayer(sock, plr);
|
||||||
@ -38,6 +42,9 @@ void NanoManager::nanoUnEquipHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
INITSTRUCT(sP_FE2CL_REP_NANO_UNEQUIP_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_NANO_UNEQUIP_SUCC, resp);
|
||||||
Player plr = PlayerManager::getPlayer(sock);
|
Player plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
|
if (nano->iNanoSlotNum > 2)
|
||||||
|
return;
|
||||||
|
|
||||||
resp.iNanoSlotNum = nano->iNanoSlotNum;
|
resp.iNanoSlotNum = nano->iNanoSlotNum;
|
||||||
|
|
||||||
// update player
|
// update player
|
||||||
@ -75,7 +82,14 @@ void NanoManager::nanoSummonHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.iActiveNanoSlotNum = pkt->iNanoSlotNum;
|
resp.iActiveNanoSlotNum = pkt->iNanoSlotNum;
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_NANO_ACTIVE_SUCC, sizeof(sP_FE2CL_REP_NANO_ACTIVE_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_NANO_ACTIVE_SUCC, sizeof(sP_FE2CL_REP_NANO_ACTIVE_SUCC));
|
||||||
|
|
||||||
|
if (pkt->iNanoSlotNum > 2)
|
||||||
|
return;
|
||||||
|
|
||||||
int nanoId = plr.plr.equippedNanos[pkt->iNanoSlotNum];
|
int nanoId = plr.plr.equippedNanos[pkt->iNanoSlotNum];
|
||||||
|
|
||||||
|
if (nanoId > 36)
|
||||||
|
return; // sanity check
|
||||||
|
|
||||||
sNano nano = plr.plr.Nanos[nanoId];
|
sNano nano = plr.plr.Nanos[nanoId];
|
||||||
|
|
||||||
// Send to other players
|
// Send to other players
|
||||||
@ -131,6 +145,9 @@ void NanoManager::nanoSkillSetHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
#pragma region Helper methods
|
#pragma region Helper methods
|
||||||
void NanoManager::addNano(CNSocket* sock, int16_t nanoId, int16_t slot) {
|
void NanoManager::addNano(CNSocket* sock, int16_t nanoId, int16_t slot) {
|
||||||
|
if (nanoId > 36)
|
||||||
|
return;
|
||||||
|
|
||||||
Player plr = PlayerManager::getPlayer(sock);
|
Player plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
// Send to client
|
// Send to client
|
||||||
@ -147,6 +164,9 @@ void NanoManager::addNano(CNSocket* sock, int16_t nanoId, int16_t slot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NanoManager::setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId) {
|
void NanoManager::setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId) {
|
||||||
|
if (nanoId > 36)
|
||||||
|
return;
|
||||||
|
|
||||||
Player plr = PlayerManager::getPlayer(sock);
|
Player plr = PlayerManager::getPlayer(sock);
|
||||||
sNano nano = plr.Nanos[nanoId];
|
sNano nano = plr.Nanos[nanoId];
|
||||||
|
|
||||||
@ -169,6 +189,9 @@ void NanoManager::setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NanoManager::resetNanoSkill(CNSocket* sock, int16_t nanoId) {
|
void NanoManager::resetNanoSkill(CNSocket* sock, int16_t nanoId) {
|
||||||
|
if (nanoId > 36)
|
||||||
|
return;
|
||||||
|
|
||||||
Player plr = PlayerManager::getPlayer(sock);
|
Player plr = PlayerManager::getPlayer(sock);
|
||||||
sNano nano = plr.Nanos[nanoId];
|
sNano nano = plr.Nanos[nanoId];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user