mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
Players can now see eachother's nanos. (#28)
This commit is contained in:
parent
c9bf3d1896
commit
6129c0b4e2
@ -18,10 +18,15 @@ void NanoManager::nanoEquipHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
sP_CL2FE_REQ_NANO_EQUIP* nano = (sP_CL2FE_REQ_NANO_EQUIP*)data->buf;
|
sP_CL2FE_REQ_NANO_EQUIP* nano = (sP_CL2FE_REQ_NANO_EQUIP*)data->buf;
|
||||||
INITSTRUCT(sP_FE2CL_REP_NANO_EQUIP_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_NANO_EQUIP_SUCC, resp);
|
||||||
|
Player plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
resp.iNanoID = nano->iNanoID;
|
resp.iNanoID = nano->iNanoID;
|
||||||
resp.iNanoSlotNum = nano->iNanoSlotNum;
|
resp.iNanoSlotNum = nano->iNanoSlotNum;
|
||||||
|
|
||||||
|
// Update player
|
||||||
|
plr.equippedNanos[nano->iNanoSlotNum] = nano->iNanoID;
|
||||||
|
PlayerManager::updatePlayer(sock, plr);
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_NANO_EQUIP_SUCC, sizeof(sP_FE2CL_REP_NANO_EQUIP_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_NANO_EQUIP_SUCC, sizeof(sP_FE2CL_REP_NANO_EQUIP_SUCC));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,9 +36,14 @@ void NanoManager::nanoUnEquipHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
sP_CL2FE_REQ_NANO_UNEQUIP* nano = (sP_CL2FE_REQ_NANO_UNEQUIP*)data->buf;
|
sP_CL2FE_REQ_NANO_UNEQUIP* nano = (sP_CL2FE_REQ_NANO_UNEQUIP*)data->buf;
|
||||||
INITSTRUCT(sP_FE2CL_REP_NANO_UNEQUIP_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_NANO_UNEQUIP_SUCC, resp);
|
||||||
|
Player plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
resp.iNanoSlotNum = nano->iNanoSlotNum;
|
resp.iNanoSlotNum = nano->iNanoSlotNum;
|
||||||
|
|
||||||
|
// update player
|
||||||
|
plr.equippedNanos[nano->iNanoSlotNum] = 0;
|
||||||
|
PlayerManager::updatePlayer(sock, plr);
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_NANO_UNEQUIP_SUCC, sizeof(sP_FE2CL_REP_NANO_UNEQUIP_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_NANO_UNEQUIP_SUCC, sizeof(sP_FE2CL_REP_NANO_UNEQUIP_SUCC));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,16 +67,33 @@ void NanoManager::nanoSummonHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (data->size != sizeof(sP_CL2FE_REQ_NANO_ACTIVE))
|
if (data->size != sizeof(sP_CL2FE_REQ_NANO_ACTIVE))
|
||||||
return; // malformed packet
|
return; // malformed packet
|
||||||
|
|
||||||
sP_CL2FE_REQ_NANO_ACTIVE* nano = (sP_CL2FE_REQ_NANO_ACTIVE*)data->buf;
|
sP_CL2FE_REQ_NANO_ACTIVE* pkt = (sP_CL2FE_REQ_NANO_ACTIVE*)data->buf;
|
||||||
PlayerView plr = PlayerManager::players[sock];
|
PlayerView plr = PlayerManager::players[sock];
|
||||||
|
|
||||||
// Send to client
|
// Send to client
|
||||||
INITSTRUCT(sP_FE2CL_REP_NANO_ACTIVE_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_NANO_ACTIVE_SUCC, resp);
|
||||||
resp.iActiveNanoSlotNum = nano->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));
|
||||||
|
|
||||||
|
int nanoId = plr.plr.equippedNanos[pkt->iNanoSlotNum];
|
||||||
|
sNano nano = plr.plr.Nanos[nanoId];
|
||||||
|
|
||||||
|
// Send to other players
|
||||||
|
for (CNSocket *s : PlayerManager::players[sock].viewable) {
|
||||||
|
INITSTRUCT(sP_FE2CL_NANO_ACTIVE, pkt);
|
||||||
|
|
||||||
|
pkt.iPC_ID = plr.plr.iID;
|
||||||
|
pkt.Nano = nano;
|
||||||
|
|
||||||
|
s->sendPacket((void*)&pkt, P_FE2CL_NANO_ACTIVE, sizeof(sP_FE2CL_NANO_ACTIVE));
|
||||||
|
}
|
||||||
|
|
||||||
|
// update player
|
||||||
|
plr.plr.nano = nanoId;
|
||||||
|
PlayerManager::updatePlayer(sock, plr.plr);
|
||||||
|
|
||||||
DEBUGLOG(
|
DEBUGLOG(
|
||||||
std::cout << U16toU8(plr.plr.PCStyle.szFirstName) << U16toU8(plr.plr.PCStyle.szLastName) << " requested to summon nano slot: " << nano->iNanoSlotNum << std::endl;
|
std::cout << U16toU8(plr.plr.PCStyle.szFirstName) << U16toU8(plr.plr.PCStyle.szLastName) << " requested to summon nano slot: " << pkt->iNanoSlotNum << std::endl;
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,4 +178,4 @@ void NanoManager::resetNanoSkill(CNSocket* sock, int16_t nanoId) {
|
|||||||
// Update the player
|
// Update the player
|
||||||
PlayerManager::updatePlayer(sock, plr);
|
PlayerManager::updatePlayer(sock, plr);
|
||||||
}
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
@ -14,10 +14,12 @@ struct Player {
|
|||||||
|
|
||||||
int level;
|
int level;
|
||||||
int HP;
|
int HP;
|
||||||
int slot;
|
int slot; // player slot, not nano slot
|
||||||
sPCStyle PCStyle;
|
sPCStyle PCStyle;
|
||||||
sPCStyle2 PCStyle2;
|
sPCStyle2 PCStyle2;
|
||||||
sNano Nanos[37];
|
sNano Nanos[37];
|
||||||
|
int equippedNanos[3];
|
||||||
|
int nano; // active nano (index into Nanos)
|
||||||
|
|
||||||
int x, y, z, angle;
|
int x, y, z, angle;
|
||||||
sItemBase Equip[AEQUIP_COUNT];
|
sItemBase Equip[AEQUIP_COUNT];
|
||||||
@ -25,4 +27,4 @@ struct Player {
|
|||||||
bool IsGM;
|
bool IsGM;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -125,6 +125,7 @@ void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) {
|
|||||||
newPlayer.PCAppearanceData.iZ = plr.z;
|
newPlayer.PCAppearanceData.iZ = plr.z;
|
||||||
newPlayer.PCAppearanceData.iAngle = plr.angle;
|
newPlayer.PCAppearanceData.iAngle = plr.angle;
|
||||||
newPlayer.PCAppearanceData.PCStyle = plr.PCStyle;
|
newPlayer.PCAppearanceData.PCStyle = plr.PCStyle;
|
||||||
|
newPlayer.PCAppearanceData.Nano = plr.Nanos[plr.nano];
|
||||||
memcpy(newPlayer.PCAppearanceData.ItemEquip, plr.Equip, sizeof(sItemBase) * AEQUIP_COUNT);
|
memcpy(newPlayer.PCAppearanceData.ItemEquip, plr.Equip, sizeof(sItemBase) * AEQUIP_COUNT);
|
||||||
|
|
||||||
otherSock->sendPacket((void*)&newPlayer, P_FE2CL_PC_NEW, sizeof(sP_FE2CL_PC_NEW));
|
otherSock->sendPacket((void*)&newPlayer, P_FE2CL_PC_NEW, sizeof(sP_FE2CL_PC_NEW));
|
||||||
@ -137,6 +138,7 @@ void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) {
|
|||||||
newPlayer.PCAppearanceData.iZ = otherPlr.z;
|
newPlayer.PCAppearanceData.iZ = otherPlr.z;
|
||||||
newPlayer.PCAppearanceData.iAngle = otherPlr.angle;
|
newPlayer.PCAppearanceData.iAngle = otherPlr.angle;
|
||||||
newPlayer.PCAppearanceData.PCStyle = otherPlr.PCStyle;
|
newPlayer.PCAppearanceData.PCStyle = otherPlr.PCStyle;
|
||||||
|
newPlayer.PCAppearanceData.Nano = otherPlr.Nanos[otherPlr.nano];
|
||||||
memcpy(newPlayer.PCAppearanceData.ItemEquip, otherPlr.Equip, sizeof(sItemBase) * AEQUIP_COUNT);
|
memcpy(newPlayer.PCAppearanceData.ItemEquip, otherPlr.Equip, sizeof(sItemBase) * AEQUIP_COUNT);
|
||||||
|
|
||||||
sock->sendPacket((void*)&newPlayer, P_FE2CL_PC_NEW, sizeof(sP_FE2CL_PC_NEW));
|
sock->sendPacket((void*)&newPlayer, P_FE2CL_PC_NEW, sizeof(sP_FE2CL_PC_NEW));
|
||||||
@ -552,4 +554,4 @@ void PlayerManager::updatePlayer(CNSocket* key, Player plr) {
|
|||||||
plrv.plr = plr;
|
plrv.plr = plr;
|
||||||
|
|
||||||
players[key] = plrv;
|
players[key] = plrv;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user