mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2025-12-16 18:10:05 +00:00
Dynamically allocate the Player struct in PlayerView.
This way we're not always passing it around by value. Note that the Player structs in CNSharedData are still pass-by-reference. Will probably change this later.
This commit is contained in:
@@ -23,10 +23,10 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
// 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.ToSlotItem = plr.plr->Equip[itemmove->iToSlotNum];
|
||||
resp.eFrom = itemmove->eTo;
|
||||
resp.iFromSlotNum = itemmove->iToSlotNum;
|
||||
resp.FromSlotItem = plr.plr.Equip[itemmove->iFromSlotNum];
|
||||
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;
|
||||
@@ -41,31 +41,31 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
// eFrom 0 means from equip
|
||||
if (itemmove->eFrom == 0) {
|
||||
// unequiping an item
|
||||
fromItem = plr.plr.Equip[itemmove->iFromSlotNum];
|
||||
fromItem = plr.plr->Equip[itemmove->iFromSlotNum];
|
||||
} else {
|
||||
fromItem = plr.plr.Inven[itemmove->iFromSlotNum];
|
||||
fromItem = plr.plr->Inven[itemmove->iFromSlotNum];
|
||||
}
|
||||
|
||||
// eTo 0 means to equip
|
||||
if (itemmove->eTo == 0) {
|
||||
// equiping an item
|
||||
toItem = plr.plr.Equip[itemmove->iToSlotNum];
|
||||
plr.plr.Equip[itemmove->iToSlotNum] = fromItem;
|
||||
toItem = plr.plr->Equip[itemmove->iToSlotNum];
|
||||
plr.plr->Equip[itemmove->iToSlotNum] = fromItem;
|
||||
} else {
|
||||
toItem = plr.plr.Inven[itemmove->iToSlotNum];
|
||||
plr.plr.Inven[itemmove->iToSlotNum] = fromItem;
|
||||
toItem = plr.plr->Inven[itemmove->iToSlotNum];
|
||||
plr.plr->Inven[itemmove->iToSlotNum] = fromItem;
|
||||
}
|
||||
|
||||
if (itemmove->eFrom == 0) {
|
||||
plr.plr.Equip[itemmove->iFromSlotNum] = toItem;
|
||||
plr.plr->Equip[itemmove->iFromSlotNum] = toItem;
|
||||
} else {
|
||||
plr.plr.Inven[itemmove->iFromSlotNum] = toItem;
|
||||
plr.plr->Inven[itemmove->iFromSlotNum] = toItem;
|
||||
}
|
||||
|
||||
if (itemmove->eFrom == 0 || itemmove->eTo == 0) {
|
||||
INITSTRUCT(sP_FE2CL_PC_EQUIP_CHANGE, equipChange);
|
||||
|
||||
equipChange.iPC_ID = plr.plr.iID;
|
||||
equipChange.iPC_ID = plr.plr->iID;
|
||||
if (itemmove->eFrom == 0) {
|
||||
equipChange.iEquipSlotNum = itemmove->iFromSlotNum;
|
||||
equipChange.EquipSlotItem = toItem;
|
||||
@@ -103,9 +103,9 @@ void ItemManager::itemDeleteHandler(CNSocket* sock, CNPacketData* data) {
|
||||
resp.iSlotNum = itemdel->iSlotNum;
|
||||
|
||||
// so, im not sure what this eIL thing does since you always delete items in inventory and not equips
|
||||
plr.plr.Inven[itemdel->iSlotNum].iID = 0;
|
||||
plr.plr.Inven[itemdel->iSlotNum].iType = 0;
|
||||
plr.plr.Inven[itemdel->iSlotNum].iOpt = 0;
|
||||
plr.plr->Inven[itemdel->iSlotNum].iID = 0;
|
||||
plr.plr->Inven[itemdel->iSlotNum].iType = 0;
|
||||
plr.plr->Inven[itemdel->iSlotNum].iOpt = 0;
|
||||
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_ITEM_DELETE_SUCC, sizeof(sP_FE2CL_REP_PC_ITEM_DELETE_SUCC));
|
||||
}
|
||||
@@ -118,7 +118,7 @@ void ItemManager::itemGMGiveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
PlayerView& plr = PlayerManager::players[sock];
|
||||
|
||||
// Commented and disabled for future use
|
||||
//if (!plr.plr.IsGM) {
|
||||
//if (!plr.plr->IsGM) {
|
||||
// TODO: send fail packet
|
||||
// return;
|
||||
//}
|
||||
@@ -134,19 +134,19 @@ void ItemManager::itemGMGiveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
resp.iSlotNum = itemreq->iSlotNum;
|
||||
resp.Item = itemreq->Item;
|
||||
|
||||
plr.plr.Inven[itemreq->iSlotNum] = itemreq->Item;
|
||||
plr.plr->Inven[itemreq->iSlotNum] = itemreq->Item;
|
||||
|
||||
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
|
||||
//plr.plr.level = 36;
|
||||
//plr.plr->level = 36;
|
||||
|
||||
//sP_FE2CL_REP_PC_CHANGE_LEVEL resp2;
|
||||
|
||||
//resp2.iPC_ID = plr.plr.iID;
|
||||
//resp2.iPC_ID = plr.plr->iID;
|
||||
//resp2.iPC_Level = 36;
|
||||
|
||||
//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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user