[refactor] Remove redundant packet size checks

Done with a vim macro, since I didn't want to bother hacking up a
multi-line deletion script in sed or awk (or Python).
This commit is contained in:
dongresource 2021-03-19 23:04:22 +01:00
parent 55b140f673
commit 0f687cc6b3
14 changed files with 0 additions and 246 deletions

View File

@ -87,9 +87,6 @@ void Buddies::refreshBuddyList(CNSocket* sock) {
// Buddy request
static void requestBuddy(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_REQUEST_MAKE_BUDDY))
return; // malformed packet
sP_CL2FE_REQ_REQUEST_MAKE_BUDDY* req = (sP_CL2FE_REQ_REQUEST_MAKE_BUDDY*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -128,10 +125,6 @@ static void requestBuddy(CNSocket* sock, CNPacketData* data) {
// Sending buddy request by player name
static void reqBuddyByName(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY)) {
return; // malformed packet
}
sP_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY* pkt = (sP_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY*)data->buf;
Player* plrReq = PlayerManager::getPlayer(sock);
@ -155,9 +148,6 @@ static void reqBuddyByName(CNSocket* sock, CNPacketData* data) {
// Accepting buddy request
static void reqAcceptBuddy(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_ACCEPT_MAKE_BUDDY))
return; // malformed packet
sP_CL2FE_REQ_ACCEPT_MAKE_BUDDY* req = (sP_CL2FE_REQ_ACCEPT_MAKE_BUDDY*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
Player* otherPlr = PlayerManager::getPlayerFromID(req->iBuddyID);
@ -224,10 +214,6 @@ static void reqAcceptBuddy(CNSocket* sock, CNPacketData* data) {
// Accepting buddy request from the find name request
static void reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY)) {
return; // malformed packet
}
sP_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY* pkt = (sP_CL2FE_REQ_PC_FIND_NAME_ACCEPT_BUDDY*)data->buf;
Player* plrReq = PlayerManager::getPlayer(sock);
@ -318,9 +304,6 @@ static void reqPktGetBuddyState(CNSocket* sock, CNPacketData* data) {
// Blocking the buddy
static void reqBuddyBlock(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_SET_BUDDY_BLOCK))
return; // malformed packet
sP_CL2FE_REQ_SET_BUDDY_BLOCK* pkt = (sP_CL2FE_REQ_SET_BUDDY_BLOCK*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -364,9 +347,6 @@ static void reqBuddyBlock(CNSocket* sock, CNPacketData* data) {
// block non-buddy
static void reqPlayerBlock(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_SET_PC_BLOCK))
return;
sP_CL2FE_REQ_SET_PC_BLOCK* pkt = (sP_CL2FE_REQ_SET_PC_BLOCK*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -392,9 +372,6 @@ static void reqPlayerBlock(CNSocket* sock, CNPacketData* data) {
// Deleting the buddy
static void reqBuddyDelete(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_REMOVE_BUDDY))
return; // malformed packet
// note! this packet is used both for removing buddies and blocks
sP_CL2FE_REQ_REMOVE_BUDDY* pkt = (sP_CL2FE_REQ_REMOVE_BUDDY*)data->buf;
@ -442,8 +419,6 @@ static void reqBuddyDelete(CNSocket* sock, CNPacketData* data) {
// Warping to buddy
static void reqBuddyWarp(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_BUDDY_WARP))
return; // malformed packet
Player *plr = PlayerManager::getPlayer(sock);
sP_CL2FE_REQ_PC_BUDDY_WARP* pkt = (sP_CL2FE_REQ_PC_BUDDY_WARP*)data->buf;

View File

@ -6,9 +6,6 @@
// helper function, not a packet handler
void BuiltinCommands::setSpecialState(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_GM_REQ_PC_SPECIAL_STATE_SWITCH))
return; // ignore the malformed packet
sP_CL2FE_GM_REQ_PC_SPECIAL_STATE_SWITCH* setData = (sP_CL2FE_GM_REQ_PC_SPECIAL_STATE_SWITCH*)data->buf;
Player *plr = PlayerManager::getPlayer(sock);
@ -36,9 +33,6 @@ static void setGMSpecialSwitchPlayer(CNSocket* sock, CNPacketData* data) {
}
static void gotoPlayer(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_GOTO))
return; // ignore the malformed packet
Player *plr = PlayerManager::getPlayer(sock);
if (plr->accountLevel > 50)
return;
@ -57,9 +51,6 @@ static void gotoPlayer(CNSocket* sock, CNPacketData* data) {
}
static void setValuePlayer(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_GM_REQ_PC_SET_VALUE))
return; // ignore the malformed packet
Player *plr = PlayerManager::getPlayer(sock);
if (plr->accountLevel > 50)
return;
@ -119,9 +110,6 @@ static void setValuePlayer(CNSocket* sock, CNPacketData* data) {
}
static void setGMSpecialOnOff(CNSocket *sock, CNPacketData *data) {
if (data->size != sizeof(sP_CL2FE_GM_REQ_TARGET_PC_SPECIAL_STATE_ONOFF))
return; // sanity check
Player *plr = PlayerManager::getPlayer(sock);
// access check
@ -147,9 +135,6 @@ static void setGMSpecialOnOff(CNSocket *sock, CNPacketData *data) {
}
static void locatePlayer(CNSocket *sock, CNPacketData *data) {
if (data->size != sizeof(sP_CL2FE_GM_REQ_PC_LOCATION))
return; // sanity check
Player *plr = PlayerManager::getPlayer(sock);
// access check
@ -185,9 +170,6 @@ static void locatePlayer(CNSocket *sock, CNPacketData *data) {
}
static void kickPlayer(CNSocket *sock, CNPacketData *data) {
if (data->size != sizeof(sP_CL2FE_GM_REQ_KICK_PLAYER))
return; // sanity check
Player *plr = PlayerManager::getPlayer(sock);
// access check
@ -223,9 +205,6 @@ static void kickPlayer(CNSocket *sock, CNPacketData *data) {
}
static void warpToPlayer(CNSocket *sock, CNPacketData *data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_WARP_TO_PC))
return; // sanity check
Player *plr = PlayerManager::getPlayer(sock);
// access check
@ -245,9 +224,6 @@ static void warpToPlayer(CNSocket *sock, CNPacketData *data) {
// GM teleport command
static void teleportPlayer(CNSocket *sock, CNPacketData *data) {
if (data->size != sizeof(sP_CL2FE_GM_REQ_TARGET_PC_TELEPORT))
return; // sanity check
Player *plr = PlayerManager::getPlayer(sock);
// access check
@ -302,9 +278,6 @@ static void teleportPlayer(CNSocket *sock, CNPacketData *data) {
}
static void itemGMGiveHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_GIVE_ITEM))
return; // ignore the malformed packet
sP_CL2FE_REQ_PC_GIVE_ITEM* itemreq = (sP_CL2FE_REQ_PC_GIVE_ITEM*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);

View File

@ -10,9 +10,6 @@ std::vector<std::string> Chat::dump;
using namespace Chat;
static void chatHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE))
return; // malformed packet
sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE* chat = (sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -44,9 +41,6 @@ static void chatHandler(CNSocket* sock, CNPacketData* data) {
}
static void menuChatHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_SEND_MENUCHAT_MESSAGE))
return; // malformed packet
sP_CL2FE_REQ_SEND_MENUCHAT_MESSAGE* chat = (sP_CL2FE_REQ_SEND_MENUCHAT_MESSAGE*)data->buf;
Player *plr = PlayerManager::getPlayer(sock);
@ -70,11 +64,6 @@ static void menuChatHandler(CNSocket* sock, CNPacketData* data) {
}
static void emoteHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT))
return; // ignore the malformed packet
// you can dance with friends!!!!!!!!
sP_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT* emote = (sP_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -100,9 +89,6 @@ void Chat::sendServerMessage(CNSocket* sock, std::string msg) {
}
static void announcementHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_GM_REQ_PC_ANNOUNCE))
return; // ignore malformed packet
Player* plr = PlayerManager::getPlayer(sock);
if (plr->accountLevel > 30)
return; // only players with account level less than 30 (GM) are allowed to use this command
@ -138,9 +124,6 @@ static void announcementHandler(CNSocket* sock, CNPacketData* data) {
// Buddy freechatting
static void buddyChatHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE))
return; // malformed packet
sP_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE* pkt = (sP_CL2FE_REQ_SEND_BUDDY_FREECHAT_MESSAGE*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -179,9 +162,6 @@ static void buddyChatHandler(CNSocket* sock, CNPacketData* data) {
// Buddy menuchat
static void buddyMenuChatHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE))
return; // malformed packet
sP_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE* pkt = (sP_CL2FE_REQ_SEND_BUDDY_MENUCHAT_MESSAGE*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -211,8 +191,6 @@ static void buddyMenuChatHandler(CNSocket* sock, CNPacketData* data) {
}
static void tradeChatHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TRADE_EMOTES_CHAT))
return; // malformed packet
sP_CL2FE_REQ_PC_TRADE_EMOTES_CHAT* pacdat = (sP_CL2FE_REQ_PC_TRADE_EMOTES_CHAT*)data->buf;
CNSocket* otherSock; // weird flip flop because we need to know who the other player is
@ -245,9 +223,6 @@ static void tradeChatHandler(CNSocket* sock, CNPacketData* data) {
}
static void groupChatHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_SEND_ALL_GROUP_FREECHAT_MESSAGE))
return; // malformed packet
sP_CL2FE_REQ_SEND_ALL_GROUP_FREECHAT_MESSAGE* chat = (sP_CL2FE_REQ_SEND_ALL_GROUP_FREECHAT_MESSAGE*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
@ -280,9 +255,6 @@ static void groupChatHandler(CNSocket* sock, CNPacketData* data) {
}
static void groupMenuChatHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_SEND_ALL_GROUP_MENUCHAT_MESSAGE))
return; // malformed packet
sP_CL2FE_REQ_SEND_ALL_GROUP_MENUCHAT_MESSAGE* chat = (sP_CL2FE_REQ_SEND_ALL_GROUP_MENUCHAT_MESSAGE*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);

View File

@ -149,9 +149,6 @@ void Eggs::npcDataToEggData(sNPCAppearanceData* npc, sShinyAppearanceData* egg)
}
static void eggPickup(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_SHINY_PICKUP))
return; // malformed packet
sP_CL2FE_REQ_SHINY_PICKUP* pickup = (sP_CL2FE_REQ_SHINY_PICKUP*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);

View File

@ -12,9 +12,6 @@ using namespace Email;
// New email notification
static void emailUpdateCheck(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_EMAIL_UPDATE_CHECK))
return; // malformed packet
INITSTRUCT(sP_FE2CL_REP_PC_NEW_EMAIL, resp);
resp.iNewEmailCnt = Database::getUnreadEmailCount(PlayerManager::getPlayer(sock)->iID);
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_NEW_EMAIL, sizeof(sP_FE2CL_REP_PC_NEW_EMAIL));
@ -22,9 +19,6 @@ static void emailUpdateCheck(CNSocket* sock, CNPacketData* data) {
// Retrieve page of emails
static void emailReceivePageList(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_RECV_EMAIL_PAGE_LIST))
return; // malformed packet
sP_CL2FE_REQ_PC_RECV_EMAIL_PAGE_LIST* pkt = (sP_CL2FE_REQ_PC_RECV_EMAIL_PAGE_LIST*)data->buf;
INITSTRUCT(sP_FE2CL_REP_PC_RECV_EMAIL_PAGE_LIST_SUCC, resp);
@ -52,9 +46,6 @@ static void emailReceivePageList(CNSocket* sock, CNPacketData* data) {
// Read individual email
static void emailRead(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_READ_EMAIL))
return; // malformed packet
sP_CL2FE_REQ_PC_READ_EMAIL* pkt = (sP_CL2FE_REQ_PC_READ_EMAIL*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -77,9 +68,6 @@ static void emailRead(CNSocket* sock, CNPacketData* data) {
// Retrieve attached taros from email
static void emailReceiveTaros(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_RECV_EMAIL_CANDY))
return; // malformed packet
sP_CL2FE_REQ_PC_RECV_EMAIL_CANDY* pkt = (sP_CL2FE_REQ_PC_RECV_EMAIL_CANDY*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -100,9 +88,6 @@ static void emailReceiveTaros(CNSocket* sock, CNPacketData* data) {
// Retrieve individual attached item from email
static void emailReceiveItemSingle(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_RECV_EMAIL_ITEM))
return; // malformed packet
sP_CL2FE_REQ_PC_RECV_EMAIL_ITEM* pkt = (sP_CL2FE_REQ_PC_RECV_EMAIL_ITEM*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -139,9 +124,6 @@ static void emailReceiveItemSingle(CNSocket* sock, CNPacketData* data) {
// Retrieve all attached items from email
static void emailReceiveItemAll(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_RECV_EMAIL_ITEM_ALL))
return; // malformed packet
sP_CL2FE_REQ_PC_RECV_EMAIL_ITEM_ALL* pkt = (sP_CL2FE_REQ_PC_RECV_EMAIL_ITEM_ALL*)data->buf;
// move items to player inventory
@ -184,9 +166,6 @@ static void emailReceiveItemAll(CNSocket* sock, CNPacketData* data) {
// Delete an email
static void emailDelete(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_DELETE_EMAIL))
return; // malformed packet
sP_CL2FE_REQ_PC_DELETE_EMAIL* pkt = (sP_CL2FE_REQ_PC_DELETE_EMAIL*)data->buf;
Database::deleteEmails(PlayerManager::getPlayer(sock)->iID, pkt->iEmailIndexArray);
@ -201,9 +180,6 @@ static void emailDelete(CNSocket* sock, CNPacketData* data) {
// Send an email
static void emailSend(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_SEND_EMAIL))
return; // malformed packet
sP_CL2FE_REQ_PC_SEND_EMAIL* pkt = (sP_CL2FE_REQ_PC_SEND_EMAIL*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);

View File

@ -20,9 +20,6 @@
using namespace Groups;
static void requestGroup(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_GROUP_INVITE))
return; // malformed packet
sP_CL2FE_REQ_PC_GROUP_INVITE* recv = (sP_CL2FE_REQ_PC_GROUP_INVITE*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -56,9 +53,6 @@ static void requestGroup(CNSocket* sock, CNPacketData* data) {
}
static void refuseGroup(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_GROUP_INVITE_REFUSE))
return; // malformed packet
sP_CL2FE_REQ_PC_GROUP_INVITE_REFUSE* recv = (sP_CL2FE_REQ_PC_GROUP_INVITE_REFUSE*)data->buf;
CNSocket* otherSock = PlayerManager::getSockFromID(recv->iID_From);
@ -76,9 +70,6 @@ static void refuseGroup(CNSocket* sock, CNPacketData* data) {
}
static void joinGroup(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_GROUP_JOIN))
return; // malformed packet
sP_CL2FE_REQ_PC_GROUP_JOIN* recv = (sP_CL2FE_REQ_PC_GROUP_JOIN*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
Player* otherPlr = PlayerManager::getPlayerFromID(recv->iID_From);

View File

@ -168,9 +168,6 @@ static int getItemSetId(Crate& crate, int crateId) {
}
static void itemMoveHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_ITEM_MOVE))
return; // ignore the malformed packet
sP_CL2FE_REQ_ITEM_MOVE* itemmove = (sP_CL2FE_REQ_ITEM_MOVE*)data->buf;
INITSTRUCT(sP_FE2CL_PC_ITEM_MOVE_SUCC, resp);
@ -319,9 +316,6 @@ static void itemMoveHandler(CNSocket* sock, CNPacketData* data) {
}
static void itemDeleteHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_ITEM_DELETE))
return; // ignore the malformed packet
sP_CL2FE_REQ_PC_ITEM_DELETE* itemdel = (sP_CL2FE_REQ_PC_ITEM_DELETE*)data->buf;
INITSTRUCT(sP_FE2CL_REP_PC_ITEM_DELETE_SUCC, resp);
@ -339,8 +333,6 @@ static void itemDeleteHandler(CNSocket* sock, CNPacketData* data) {
}
static void itemUseHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_ITEM_USE))
return; // ignore the malformed packet
sP_CL2FE_REQ_ITEM_USE* request = (sP_CL2FE_REQ_ITEM_USE*)data->buf;
Player* player = PlayerManager::getPlayer(sock);
@ -422,9 +414,6 @@ static void itemUseHandler(CNSocket* sock, CNPacketData* data) {
}
static void itemBankOpenHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_BANK_OPEN))
return; // ignore the malformed packet
Player* plr = PlayerManager::getPlayer(sock);
// just send bank inventory
@ -437,9 +426,6 @@ static void itemBankOpenHandler(CNSocket* sock, CNPacketData* data) {
}
static void chestOpenHandler(CNSocket *sock, CNPacketData *data) {
if (data->size != sizeof(sP_CL2FE_REQ_ITEM_CHEST_OPEN))
return; // ignore the malformed packet
sP_CL2FE_REQ_ITEM_CHEST_OPEN *pkt = (sP_CL2FE_REQ_ITEM_CHEST_OPEN *)data->buf;
// sanity check

View File

@ -311,9 +311,6 @@ bool Missions::startTask(Player* plr, int TaskID) {
}
static void taskStart(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TASK_START))
return; // malformed packet
sP_CL2FE_REQ_PC_TASK_START* missionData = (sP_CL2FE_REQ_PC_TASK_START*)data->buf;
INITSTRUCT(sP_FE2CL_REP_PC_TASK_START_SUCC, response);
Player *plr = PlayerManager::getPlayer(sock);
@ -349,9 +346,6 @@ static void taskStart(CNSocket* sock, CNPacketData* data) {
}
static void taskEnd(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TASK_END))
return; // malformed packet
sP_CL2FE_REQ_PC_TASK_END* missionData = (sP_CL2FE_REQ_PC_TASK_END*)data->buf;
// failed timed missions give an iNPC_ID of 0
@ -406,9 +400,6 @@ static void taskEnd(CNSocket* sock, CNPacketData* data) {
}
static void setMission(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_SET_CURRENT_MISSION_ID))
return; // malformed packet
Player* plr = PlayerManager::getPlayer(sock);
sP_CL2FE_REQ_PC_SET_CURRENT_MISSION_ID* missionData = (sP_CL2FE_REQ_PC_SET_CURRENT_MISSION_ID*)data->buf;
@ -420,9 +411,6 @@ static void setMission(CNSocket* sock, CNPacketData* data) {
}
static void quitMission(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TASK_STOP))
return; // malformed packet
sP_CL2FE_REQ_PC_TASK_STOP* missionData = (sP_CL2FE_REQ_PC_TASK_STOP*)data->buf;
quitTask(sock, missionData->iTaskNum, true);
}

View File

@ -95,9 +95,6 @@ void NPCManager::sendToViewable(BaseNPC *npc, void *buf, uint32_t type, size_t s
}
static void npcBarkHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_BARKER))
return; // malformed packet
sP_CL2FE_REQ_BARKER* req = (sP_CL2FE_REQ_BARKER*)data->buf;
// get bark IDs from task data
@ -118,9 +115,6 @@ static void npcBarkHandler(CNSocket* sock, CNPacketData* data) {
}
static void npcUnsummonHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_NPC_UNSUMMON))
return; // malformed packet
Player* plr = PlayerManager::getPlayer(sock);
if (plr->accountLevel > 30)
@ -155,9 +149,6 @@ BaseNPC *NPCManager::summonNPC(int x, int y, int z, uint64_t instance, int type,
}
static void npcSummonHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_NPC_SUMMON))
return; // malformed packet
sP_CL2FE_REQ_NPC_SUMMON* req = (sP_CL2FE_REQ_NPC_SUMMON*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -274,16 +265,11 @@ static void handleWarp(CNSocket* sock, int32_t warpId) {
}
static void npcWarpHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_WARP_USE_NPC))
return; // malformed packet
sP_CL2FE_REQ_PC_WARP_USE_NPC* warpNpc = (sP_CL2FE_REQ_PC_WARP_USE_NPC*)data->buf;
handleWarp(sock, warpNpc->iWarpID);
}
static void npcWarpTimeMachine(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TIME_TO_GO_WARP))
return; // malformed packet
// this is just a warp request
handleWarp(sock, 28);
}

View File

@ -218,9 +218,6 @@ bool Nanos::getNanoBoost(Player* plr) {
#pragma endregion
static void nanoEquipHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_NANO_EQUIP))
return; // malformed packet
sP_CL2FE_REQ_NANO_EQUIP* nano = (sP_CL2FE_REQ_NANO_EQUIP*)data->buf;
INITSTRUCT(sP_FE2CL_REP_NANO_EQUIP_SUCC, resp);
Player *plr = PlayerManager::getPlayer(sock);
@ -255,9 +252,6 @@ static void nanoEquipHandler(CNSocket* sock, CNPacketData* data) {
}
static void nanoUnEquipHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_NANO_UNEQUIP))
return; // malformed packet
sP_CL2FE_REQ_NANO_UNEQUIP* nano = (sP_CL2FE_REQ_NANO_UNEQUIP*)data->buf;
INITSTRUCT(sP_FE2CL_REP_NANO_UNEQUIP_SUCC, resp);
Player *plr = PlayerManager::getPlayer(sock);
@ -279,9 +273,6 @@ static void nanoUnEquipHandler(CNSocket* sock, CNPacketData* data) {
}
static void nanoGMGiveHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_GIVE_NANO))
return; // ignore the malformed packet
// Cmd: /nano <nanoID>
sP_CL2FE_REQ_PC_GIVE_NANO* nano = (sP_CL2FE_REQ_PC_GIVE_NANO*)data->buf;
Player *plr = PlayerManager::getPlayer(sock);
@ -295,9 +286,6 @@ static void nanoGMGiveHandler(CNSocket* sock, CNPacketData* data) {
}
static void nanoSummonHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_NANO_ACTIVE))
return; // malformed packet
sP_CL2FE_REQ_NANO_ACTIVE* pkt = (sP_CL2FE_REQ_NANO_ACTIVE*)data->buf;
Player *plr = PlayerManager::getPlayer(sock);
@ -337,25 +325,16 @@ static void nanoSkillUseHandler(CNSocket* sock, CNPacketData* data) {
}
static void nanoSkillSetHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_NANO_TUNE))
return; // malformed packet
sP_CL2FE_REQ_NANO_TUNE* skill = (sP_CL2FE_REQ_NANO_TUNE*)data->buf;
setNanoSkill(sock, skill);
}
static void nanoSkillSetGMHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_GIVE_NANO_SKILL))
return; // malformed packet
sP_CL2FE_REQ_NANO_TUNE* skillGM = (sP_CL2FE_REQ_NANO_TUNE*)data->buf;
setNanoSkill(sock, skillGM);
}
static void nanoRecallRegisterHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_REGIST_RXCOM))
return;
sP_CL2FE_REQ_REGIST_RXCOM* recallData = (sP_CL2FE_REQ_REGIST_RXCOM*)data->buf;
if (NPCManager::NPCs.find(recallData->iNPCID) == NPCManager::NPCs.end())
@ -374,9 +353,6 @@ static void nanoRecallRegisterHandler(CNSocket* sock, CNPacketData* data) {
}
static void nanoRecallHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_WARP_USE_RECALL))
return;
sP_CL2FE_REQ_WARP_USE_RECALL* recallData = (sP_CL2FE_REQ_WARP_USE_RECALL*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -401,9 +377,6 @@ static void nanoRecallHandler(CNSocket* sock, CNPacketData* data) {
}
static void nanoPotionHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_CHARGE_NANO_STAMINA))
return;
Player* player = PlayerManager::getPlayer(sock);
// sanity checks

View File

@ -13,9 +13,6 @@ std::map<CNSocket*, EPRace> Racing::EPRaces;
std::map<int32_t, std::pair<std::vector<int>, std::vector<int>>> Racing::EPRewards;
static void racingStart(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_EP_RACE_START))
return; // malformed packet
sP_CL2FE_REQ_EP_RACE_START* req = (sP_CL2FE_REQ_EP_RACE_START*)data->buf;
if (NPCManager::NPCs.find(req->iStartEcomID) == NPCManager::NPCs.end())
@ -37,9 +34,6 @@ static void racingStart(CNSocket* sock, CNPacketData* data) {
}
static void racingGetPod(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_EP_GET_RING))
return; // malformed packet
if (EPRaces.find(sock) == EPRaces.end())
return; // race not found
@ -57,9 +51,6 @@ static void racingGetPod(CNSocket* sock, CNPacketData* data) {
}
static void racingCancel(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_EP_RACE_CANCEL))
return; // malformed packet
if (EPRaces.find(sock) == EPRaces.end())
return; // race not found
@ -70,9 +61,6 @@ static void racingCancel(CNSocket* sock, CNPacketData* data) {
}
static void racingEnd(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_EP_RACE_END))
return; // malformed packet
if (EPRaces.find(sock) == EPRaces.end())
return; // race not found

View File

@ -98,9 +98,6 @@ static bool doTrade(Player* plr, Player* plr2) {
}
static void tradeOffer(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TRADE_OFFER))
return; // ignore the malformed packet
sP_CL2FE_REQ_PC_TRADE_OFFER* pacdat = (sP_CL2FE_REQ_PC_TRADE_OFFER*)data->buf;
CNSocket* otherSock = PlayerManager::getSockFromID(pacdat->iID_To);
@ -127,9 +124,6 @@ static void tradeOffer(CNSocket* sock, CNPacketData* data) {
}
static void tradeOfferAccept(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TRADE_OFFER_ACCEPT))
return; // ignore the malformed packet
sP_CL2FE_REQ_PC_TRADE_OFFER_ACCEPT* pacdat = (sP_CL2FE_REQ_PC_TRADE_OFFER_ACCEPT*)data->buf;
CNSocket* otherSock = PlayerManager::getSockFromID(pacdat->iID_From);
@ -174,9 +168,6 @@ static void tradeOfferAccept(CNSocket* sock, CNPacketData* data) {
}
static void tradeOfferRefusal(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TRADE_OFFER_REFUSAL))
return; // ignore the malformed packet
sP_CL2FE_REQ_PC_TRADE_OFFER_REFUSAL* pacdat = (sP_CL2FE_REQ_PC_TRADE_OFFER_REFUSAL*)data->buf;
CNSocket* otherSock = PlayerManager::getSockFromID(pacdat->iID_From);
@ -192,9 +183,6 @@ static void tradeOfferRefusal(CNSocket* sock, CNPacketData* data) {
}
static void tradeConfirm(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TRADE_CONFIRM))
return; // ignore the malformed packet
sP_CL2FE_REQ_PC_TRADE_CONFIRM* pacdat = (sP_CL2FE_REQ_PC_TRADE_CONFIRM*)data->buf;
CNSocket* otherSock; // weird flip flop because we need to know who the other player is
@ -270,9 +258,6 @@ static void tradeConfirm(CNSocket* sock, CNPacketData* data) {
}
static void tradeConfirmCancel(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TRADE_CONFIRM_CANCEL))
return; // ignore the malformed packet
sP_CL2FE_REQ_PC_TRADE_CONFIRM_CANCEL* pacdat = (sP_CL2FE_REQ_PC_TRADE_CONFIRM_CANCEL*)data->buf;
CNSocket* otherSock; // weird flip flop because we need to know who the other player is
@ -301,9 +286,6 @@ static void tradeConfirmCancel(CNSocket* sock, CNPacketData* data) {
}
static void tradeRegisterItem(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TRADE_ITEM_REGISTER))
return; // ignore the malformed packet
sP_CL2FE_REQ_PC_TRADE_ITEM_REGISTER* pacdat = (sP_CL2FE_REQ_PC_TRADE_ITEM_REGISTER*)data->buf;
if (pacdat->Item.iSlotNum < 0 || pacdat->Item.iSlotNum > 4)
@ -346,9 +328,6 @@ static void tradeRegisterItem(CNSocket* sock, CNPacketData* data) {
}
static void tradeUnregisterItem(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TRADE_ITEM_UNREGISTER))
return; // ignore the malformed packet
sP_CL2FE_REQ_PC_TRADE_ITEM_UNREGISTER* pacdat = (sP_CL2FE_REQ_PC_TRADE_ITEM_UNREGISTER*)data->buf;
if (pacdat->Item.iSlotNum < 0 || pacdat->Item.iSlotNum > 4)
@ -390,9 +369,6 @@ static void tradeUnregisterItem(CNSocket* sock, CNPacketData* data) {
}
static void tradeRegisterCash(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TRADE_CASH_REGISTER))
return; // ignore the malformed packet
sP_CL2FE_REQ_PC_TRADE_CASH_REGISTER* pacdat = (sP_CL2FE_REQ_PC_TRADE_CASH_REGISTER*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);

View File

@ -18,9 +18,6 @@ std::unordered_map<CNSocket*, std::queue<WarpLocation>> Transport::SkywayQueues;
std::unordered_map<int32_t, std::queue<WarpLocation>> Transport::NPCQueues;
static void transportRegisterLocationHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_REGIST_TRANSPORTATION_LOCATION))
return; // malformed packet
sP_CL2FE_REQ_REGIST_TRANSPORTATION_LOCATION* transport = (sP_CL2FE_REQ_REGIST_TRANSPORTATION_LOCATION*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -94,9 +91,6 @@ static void transportRegisterLocationHandler(CNSocket* sock, CNPacketData* data)
}
static void transportWarpHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_WARP_USE_TRANSPORTATION))
return; // malformed packet
sP_CL2FE_REQ_PC_WARP_USE_TRANSPORTATION* req = (sP_CL2FE_REQ_PC_WARP_USE_TRANSPORTATION*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);

View File

@ -5,9 +5,6 @@ using namespace Vendor;
std::map<int32_t, std::vector<VendorListing>> Vendor::VendorTables;
static void vendorBuy(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_VENDOR_ITEM_BUY))
return; // malformed packet
sP_CL2FE_REQ_PC_VENDOR_ITEM_BUY* req = (sP_CL2FE_REQ_PC_VENDOR_ITEM_BUY*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -60,9 +57,6 @@ static void vendorBuy(CNSocket* sock, CNPacketData* data) {
}
static void vendorSell(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_VENDOR_ITEM_SELL))
return; // malformed packet
sP_CL2FE_REQ_PC_VENDOR_ITEM_SELL* req = (sP_CL2FE_REQ_PC_VENDOR_ITEM_SELL*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -126,9 +120,6 @@ static void vendorSell(CNSocket* sock, CNPacketData* data) {
}
static void vendorBuyback(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_VENDOR_ITEM_RESTORE_BUY))
return; // malformed packet
sP_CL2FE_REQ_PC_VENDOR_ITEM_RESTORE_BUY* req = (sP_CL2FE_REQ_PC_VENDOR_ITEM_RESTORE_BUY*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -205,9 +196,6 @@ static void vendorBuyback(CNSocket* sock, CNPacketData* data) {
}
static void vendorTable(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_VENDOR_TABLE_UPDATE))
return; // malformed packet
sP_CL2FE_REQ_PC_VENDOR_TABLE_UPDATE* req = (sP_CL2FE_REQ_PC_VENDOR_TABLE_UPDATE*)data->buf;
if (req->iVendorID != req->iNPC_ID || Vendor::VendorTables.find(req->iVendorID) == Vendor::VendorTables.end())
@ -237,9 +225,6 @@ static void vendorTable(CNSocket* sock, CNPacketData* data) {
}
static void vendorStart(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_VENDOR_START))
return; // malformed packet
sP_CL2FE_REQ_PC_VENDOR_START* req = (sP_CL2FE_REQ_PC_VENDOR_START*)data->buf;
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_START_SUCC, resp);
@ -250,9 +235,6 @@ static void vendorStart(CNSocket* sock, CNPacketData* data) {
}
static void vendorBuyBattery(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_VENDOR_BATTERY_BUY))
return; // malformed packet
sP_CL2FE_REQ_PC_VENDOR_BATTERY_BUY* req = (sP_CL2FE_REQ_PC_VENDOR_BATTERY_BUY*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);
@ -287,9 +269,6 @@ static void vendorBuyBattery(CNSocket* sock, CNPacketData* data) {
}
static void vendorCombineItems(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_ITEM_COMBINATION))
return; // malformed packet
sP_CL2FE_REQ_PC_ITEM_COMBINATION* req = (sP_CL2FE_REQ_PC_ITEM_COMBINATION*)data->buf;
Player* plr = PlayerManager::getPlayer(sock);