mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 05:20:05 +00:00
Shard crash fixes
This commit is contained in:
parent
b765821552
commit
21d280147c
@ -16,8 +16,9 @@ EntityRef::EntityRef(CNSocket *s) {
|
|||||||
EntityRef::EntityRef(int32_t i) {
|
EntityRef::EntityRef(int32_t i) {
|
||||||
id = i;
|
id = i;
|
||||||
|
|
||||||
assert(NPCManager::NPCs.find(id) != NPCManager::NPCs.end());
|
kind = EntityKind::INVALID;
|
||||||
kind = NPCManager::NPCs[id]->kind;
|
if (NPCManager::NPCs.find(id) != NPCManager::NPCs.end())
|
||||||
|
kind = NPCManager::NPCs[id]->kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityRef::isValid() const {
|
bool EntityRef::isValid() const {
|
||||||
|
@ -64,6 +64,9 @@ static void attachGroupData(std::vector<EntityRef>& pcs, std::vector<EntityRef>&
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Groups::addToGroup(Group* group, EntityRef member) {
|
void Groups::addToGroup(Group* group, EntityRef member) {
|
||||||
|
if (group == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
if (member.kind == EntityKind::PLAYER) {
|
if (member.kind == EntityKind::PLAYER) {
|
||||||
Player* plr = PlayerManager::getPlayer(member.sock);
|
Player* plr = PlayerManager::getPlayer(member.sock);
|
||||||
plr->group = group;
|
plr->group = group;
|
||||||
@ -109,6 +112,9 @@ void Groups::addToGroup(Group* group, EntityRef member) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Groups::removeFromGroup(Group* group, EntityRef member) {
|
bool Groups::removeFromGroup(Group* group, EntityRef member) {
|
||||||
|
if (group == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (member.kind == EntityKind::PLAYER) {
|
if (member.kind == EntityKind::PLAYER) {
|
||||||
Player* plr = PlayerManager::getPlayer(member.sock);
|
Player* plr = PlayerManager::getPlayer(member.sock);
|
||||||
plr->group = nullptr; // no dangling pointers here muahaahahah
|
plr->group = nullptr; // no dangling pointers here muahaahahah
|
||||||
@ -168,6 +174,9 @@ bool Groups::removeFromGroup(Group* group, EntityRef member) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Groups::disbandGroup(Group* group) {
|
void Groups::disbandGroup(Group* group) {
|
||||||
|
if (group == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
// remove everyone from the group!!
|
// remove everyone from the group!!
|
||||||
bool done = false;
|
bool done = false;
|
||||||
while(!done) {
|
while(!done) {
|
||||||
@ -252,6 +261,9 @@ static void leaveGroup(CNSocket* sock, CNPacketData* data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Groups::sendToGroup(Group* group, void* buf, uint32_t type, size_t size) {
|
void Groups::sendToGroup(Group* group, void* buf, uint32_t type, size_t size) {
|
||||||
|
if (group == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
auto players = group->filter(EntityKind::PLAYER);
|
auto players = group->filter(EntityKind::PLAYER);
|
||||||
for (EntityRef ref : players) {
|
for (EntityRef ref : players) {
|
||||||
ref.sock->sendPacket(buf, type, size);
|
ref.sock->sendPacket(buf, type, size);
|
||||||
@ -259,6 +271,9 @@ void Groups::sendToGroup(Group* group, void* buf, uint32_t type, size_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Groups::sendToGroup(Group* group, EntityRef excluded, void* buf, uint32_t type, size_t size) {
|
void Groups::sendToGroup(Group* group, EntityRef excluded, void* buf, uint32_t type, size_t size) {
|
||||||
|
if (group == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
auto players = group->filter(EntityKind::PLAYER);
|
auto players = group->filter(EntityKind::PLAYER);
|
||||||
for (EntityRef ref : players) {
|
for (EntityRef ref : players) {
|
||||||
if(ref != excluded) ref.sock->sendPacket(buf, type, size);
|
if(ref != excluded) ref.sock->sendPacket(buf, type, size);
|
||||||
@ -294,6 +309,9 @@ void Groups::groupTickInfo(CNSocket* sock) {
|
|||||||
|
|
||||||
void Groups::groupKick(Group* group, EntityRef ref) {
|
void Groups::groupKick(Group* group, EntityRef ref) {
|
||||||
|
|
||||||
|
if (group == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
// if you are the group leader, destroy your own group and kick everybody
|
// if you are the group leader, destroy your own group and kick everybody
|
||||||
if (group->members[0] == ref) {
|
if (group->members[0] == ref) {
|
||||||
disbandGroup(group);
|
disbandGroup(group);
|
||||||
|
@ -386,6 +386,9 @@ static void taskStart(CNSocket* sock, CNPacketData* data) {
|
|||||||
static void taskEnd(CNSocket* sock, CNPacketData* data) {
|
static void taskEnd(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_PC_TASK_END* missionData = (sP_CL2FE_REQ_PC_TASK_END*)data->buf;
|
sP_CL2FE_REQ_PC_TASK_END* missionData = (sP_CL2FE_REQ_PC_TASK_END*)data->buf;
|
||||||
|
|
||||||
|
if (Missions::Tasks.find(missionData->iTaskNum) == Missions::Tasks.end())
|
||||||
|
return;
|
||||||
|
|
||||||
TaskData* task = Missions::Tasks[missionData->iTaskNum];
|
TaskData* task = Missions::Tasks[missionData->iTaskNum];
|
||||||
|
|
||||||
// handle timed mission failure
|
// handle timed mission failure
|
||||||
|
@ -110,7 +110,7 @@ void Nanos::summonNano(CNSocket *sock, int slot, bool silent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void setNanoSkill(CNSocket* sock, sP_CL2FE_REQ_NANO_TUNE* skill) {
|
static void setNanoSkill(CNSocket* sock, sP_CL2FE_REQ_NANO_TUNE* skill) {
|
||||||
if (skill->iNanoID >= NANO_COUNT)
|
if (skill == nullptr || skill->iNanoID >= NANO_COUNT || skill->iNanoID < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
Loading…
Reference in New Issue
Block a user