mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
Item Deletion and extra fixes (#17)
* Deleting Items * fixes * fixes 2 * Basic GM login * Update ItemManager.cpp Co-authored-by: Raymonf <raymonf@outlook.com>
This commit is contained in:
parent
3fe1a02200
commit
caaffcbe3d
@ -91,6 +91,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||
loginSessions[sock].characters[UID].z = charInfo->iZ;
|
||||
loginSessions[sock].characters[UID].PCStyle = charInfo->sPC_Style;
|
||||
loginSessions[sock].characters[UID].PCStyle2 = charInfo->sPC_Style2;
|
||||
loginSessions[sock].characters[UID].IsGM = false;
|
||||
|
||||
for (int i = 0; i < AEQUIP_COUNT; i++) {
|
||||
// setup equips
|
||||
@ -189,6 +190,17 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||
std::cout << "\tiEquipFootID: " << (int)character->sOn_Item.iEquipFootID << std::endl;
|
||||
)
|
||||
|
||||
int64_t UID = character->PCStyle.iPC_UID;
|
||||
|
||||
bool BecomeGM;
|
||||
|
||||
if (U16toU8(character->PCStyle.szFirstName) == settings::GMPASS) {
|
||||
BecomeGM = true;
|
||||
U8toU16("GM",character->PCStyle.szFirstName);
|
||||
} else {
|
||||
BecomeGM = false;
|
||||
}
|
||||
|
||||
character->PCStyle.iNameCheck = 1;
|
||||
response->sPC_Style = character->PCStyle;
|
||||
response->sPC_Style2.iAppearanceFlag = 1;
|
||||
@ -197,7 +209,6 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||
response->iLevel = 1;
|
||||
response->sOn_Item = character->sOn_Item;
|
||||
|
||||
int64_t UID = character->PCStyle.iPC_UID;
|
||||
loginSessions[sock].characters[UID] = Player();
|
||||
loginSessions[sock].characters[UID].level = 1;
|
||||
loginSessions[sock].characters[UID].FEKey = sock->getFEKey();
|
||||
@ -214,6 +225,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||
loginSessions[sock].characters[UID].Equip[2].iType = 2;
|
||||
loginSessions[sock].characters[UID].Equip[3].iID = character->sOn_Item.iEquipFootID; // foot!
|
||||
loginSessions[sock].characters[UID].Equip[3].iType = 3;
|
||||
loginSessions[sock].characters[UID].IsGM = BecomeGM;
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)response, P_LS2CL_REP_CHAR_CREATE_SUCC, sizeof(sP_LS2CL_REP_CHAR_CREATE_SUCC), sock->getEKey()));
|
||||
break;
|
||||
|
@ -24,6 +24,8 @@ enum SHARDPACKETID {
|
||||
P_CL2FE_REQ_SEND_FREECHAT_MESSAGE = 318767111,
|
||||
P_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT = 318767184,
|
||||
P_CL2FE_REQ_ITEM_MOVE = 318767114,
|
||||
P_CL2FE_REQ_PC_ITEM_DELETE = 318767129,
|
||||
P_CL2FE_REQ_PC_GIVE_ITEM = 318767130,
|
||||
P_CL2FE_REQ_PC_EXIT = 318767106,
|
||||
|
||||
// shard 2 client
|
||||
@ -50,7 +52,10 @@ enum SHARDPACKETID {
|
||||
P_FE2CL_REP_PC_AVATAR_EMOTES_CHAT = 822083730,
|
||||
P_FE2CL_PC_ITEM_MOVE_SUCC = 822083610,
|
||||
P_FE2CL_PC_EQUIP_CHANGE = 822083611,
|
||||
P_FE2CL_REP_PC_ITEM_DELETE_SUCC = 822083641,
|
||||
P_FE2CL_REP_PC_GIVE_ITEM_SUCC = 822083681,
|
||||
P_FE2CL_REP_PC_EXIT_SUCC = 822083589,
|
||||
P_FE2CL_REP_PC_CHANGE_LEVEL = 822083786,
|
||||
P_FE2CL_PC_MOTD_LOGIN = 822083793
|
||||
};
|
||||
|
||||
|
@ -6,7 +6,8 @@
|
||||
|
||||
void ItemManager::init() {
|
||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_ITEM_MOVE, itemMoveHandler);
|
||||
REGISTER_SHARD_PACKET(P_FE2CL_PC_EQUIP_CHANGE, itemMoveHandler);
|
||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_ITEM_DELETE, itemDeleteHandler);
|
||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GIVE_ITEM, itemGMGiveHandler);
|
||||
}
|
||||
|
||||
void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
@ -23,7 +24,6 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
// eFrom 0 means from equip
|
||||
if (itemmove->eFrom == 0) {
|
||||
// unequiping an item
|
||||
std::cout << "unequipting item" << std::endl;
|
||||
fromItem = plr.plr.Equip[itemmove->iFromSlotNum];
|
||||
} else {
|
||||
fromItem = plr.plr.Inven[itemmove->iFromSlotNum];
|
||||
@ -31,7 +31,6 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
// eTo 0 means to equip
|
||||
if (itemmove->eTo == 0) {
|
||||
std::cout << "equipting item" << std::endl;
|
||||
// equiping an item
|
||||
toItem = plr.plr.Equip[itemmove->iToSlotNum];
|
||||
plr.plr.Equip[itemmove->iToSlotNum] = fromItem;
|
||||
@ -54,8 +53,7 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
if (itemmove->eFrom == 0) {
|
||||
resp2->iEquipSlotNum = itemmove->iFromSlotNum;
|
||||
resp2->EquipSlotItem = toItem;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
resp2->iEquipSlotNum = itemmove->iToSlotNum;
|
||||
resp2->EquipSlotItem = fromItem;
|
||||
}
|
||||
@ -72,3 +70,59 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_PC_ITEM_MOVE_SUCC, sizeof(sP_FE2CL_PC_ITEM_MOVE_SUCC), sock->getFEKey()));
|
||||
}
|
||||
|
||||
void ItemManager::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;
|
||||
sP_FE2CL_REP_PC_ITEM_DELETE_SUCC* resp = (sP_FE2CL_REP_PC_ITEM_DELETE_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_PC_ITEM_DELETE_SUCC));
|
||||
|
||||
PlayerView& plr = PlayerManager::players[sock];
|
||||
|
||||
resp->eIL = itemdel->eIL;
|
||||
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;
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_PC_ITEM_DELETE_SUCC, sizeof(sP_FE2CL_REP_PC_ITEM_DELETE_SUCC), sock->getFEKey()));
|
||||
}
|
||||
|
||||
void ItemManager::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;
|
||||
PlayerView& plr = PlayerManager::players[sock];
|
||||
|
||||
if (!plr.plr.IsGM) {
|
||||
// TODO: send fail packet
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemreq->eIL == 2) {
|
||||
// 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()));
|
||||
} else if (itemreq->eIL == 1) {
|
||||
sP_FE2CL_REP_PC_GIVE_ITEM_SUCC* resp = (sP_FE2CL_REP_PC_GIVE_ITEM_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_PC_GIVE_ITEM_SUCC));
|
||||
|
||||
resp->eIL = itemreq->eIL;
|
||||
resp->iSlotNum = itemreq->iSlotNum;
|
||||
resp->Item = itemreq->Item;
|
||||
|
||||
plr.plr.Inven[itemreq->iSlotNum] = itemreq->Item;
|
||||
plr.plr.level = 36;
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_PC_GIVE_ITEM_SUCC, sizeof(sP_FE2CL_REP_PC_GIVE_ITEM_SUCC), sock->getFEKey()));
|
||||
|
||||
sP_FE2CL_REP_PC_CHANGE_LEVEL* resp2 = (sP_FE2CL_REP_PC_CHANGE_LEVEL*)xmalloc(sizeof(sP_FE2CL_REP_PC_CHANGE_LEVEL));
|
||||
|
||||
resp2->iPC_ID = plr.plr.iID;
|
||||
resp2->iPC_Level = 36;
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)resp2, P_FE2CL_REP_PC_CHANGE_LEVEL, sizeof(sP_FE2CL_REP_PC_CHANGE_LEVEL), sock->getFEKey()));
|
||||
}
|
||||
}
|
@ -6,6 +6,8 @@
|
||||
namespace ItemManager {
|
||||
void init();
|
||||
void itemMoveHandler(CNSocket* sock, CNPacketData* data);
|
||||
void itemDeleteHandler(CNSocket* sock, CNPacketData* data);
|
||||
void itemGMGiveHandler(CNSocket* sock, CNPacketData* data);
|
||||
}
|
||||
|
||||
#endif
|
@ -21,6 +21,7 @@ struct Player {
|
||||
int x, y, z, angle;
|
||||
sItemBase Equip[AEQUIP_COUNT];
|
||||
sItemBase Inven[AINVEN_COUNT];
|
||||
bool IsGM;
|
||||
};
|
||||
|
||||
#endif
|
@ -14,6 +14,7 @@ int settings::VIEWDISTANCE = 20000;
|
||||
int settings::SPAWN_X = 179213;
|
||||
int settings::SPAWN_Y = 268451;
|
||||
int settings::SPAWN_Z = -4210;
|
||||
std::string settings::GMPASS = "pass";
|
||||
|
||||
std::string settings::MOTDSTRING = "Welcome to OpenFusion!";
|
||||
|
||||
@ -38,5 +39,6 @@ void settings::init() {
|
||||
SPAWN_Y = reader.GetInteger("shard", "spawny", SPAWN_Y);
|
||||
SPAWN_Z = reader.GetInteger("shard", "spawnz", SPAWN_Z);
|
||||
MOTDSTRING = reader.Get("shard", "motd", "Welcome to OpenFusion!");
|
||||
GMPASS = reader.Get("login", "pass", "pass");
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ namespace settings {
|
||||
extern int SPAWN_Y;
|
||||
extern int SPAWN_Z;
|
||||
extern std::string MOTDSTRING;
|
||||
extern std::string GMPASS;
|
||||
|
||||
void init();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user