mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 06:50:04 +00:00
Fix case where resplen wasn't being initialized
This commit is contained in:
parent
166eb5125f
commit
c2ab5c9d02
@ -364,9 +364,6 @@ void GroupManager::groupUnbuff(Player* plr) {
|
|||||||
Player* otherPlr = PlayerManager::getPlayerFromID(plr->groupIDs[i]);
|
Player* otherPlr = PlayerManager::getPlayerFromID(plr->groupIDs[i]);
|
||||||
CNSocket* sock = PlayerManager::getSockFromID(plr->groupIDs[n]);
|
CNSocket* sock = PlayerManager::getSockFromID(plr->groupIDs[n]);
|
||||||
|
|
||||||
if (otherPlr == nullptr || sock == nullptr)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
NanoManager::applyBuff(sock, otherPlr->Nanos[otherPlr->activeNano].iSkillID, 2, 1, 0);
|
NanoManager::applyBuff(sock, otherPlr->Nanos[otherPlr->activeNano].iSkillID, 2, 1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -575,13 +575,8 @@ int NPCManager::eggBuffPlayer(CNSocket* sock, int skillId, int eggId) {
|
|||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
|
|
||||||
if (otherPlr == nullptr)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
int CBFlag = 0;
|
|
||||||
int bitFlag = GroupManager::getGroupFlags(otherPlr);
|
int bitFlag = GroupManager::getGroupFlags(otherPlr);
|
||||||
|
int CBFlag = NanoManager::applyBuff(sock, skillId, 1, 3, bitFlag);
|
||||||
CBFlag = NanoManager::applyBuff(sock, skillId, 1, 3, bitFlag);
|
|
||||||
|
|
||||||
size_t resplen;
|
size_t resplen;
|
||||||
|
|
||||||
@ -589,9 +584,9 @@ int NPCManager::eggBuffPlayer(CNSocket* sock, int skillId, int eggId) {
|
|||||||
resplen = sizeof(sP_FE2CL_NPC_SKILL_HIT) + sizeof(sSkillResult_Damage);
|
resplen = sizeof(sP_FE2CL_NPC_SKILL_HIT) + sizeof(sSkillResult_Damage);
|
||||||
} else if (skillId == 147) {
|
} else if (skillId == 147) {
|
||||||
resplen = sizeof(sP_FE2CL_NPC_SKILL_HIT) + sizeof(sSkillResult_Heal_HP);
|
resplen = sizeof(sP_FE2CL_NPC_SKILL_HIT) + sizeof(sSkillResult_Heal_HP);
|
||||||
} else
|
} else {
|
||||||
sizeof(sP_FE2CL_NPC_SKILL_HIT) + sizeof(sSkillResult_Buff);
|
resplen = sizeof(sP_FE2CL_NPC_SKILL_HIT) + sizeof(sSkillResult_Buff);
|
||||||
|
}
|
||||||
assert(resplen < CN_PACKET_BUFFER_SIZE - 8);
|
assert(resplen < CN_PACKET_BUFFER_SIZE - 8);
|
||||||
// we know it's only one trailing struct, so we can skip full validation
|
// we know it's only one trailing struct, so we can skip full validation
|
||||||
|
|
||||||
@ -605,6 +600,8 @@ int NPCManager::eggBuffPlayer(CNSocket* sock, int skillId, int eggId) {
|
|||||||
skill->iID = plr->iID;
|
skill->iID = plr->iID;
|
||||||
skill->iDamage = PC_MAXHEALTH(plr->level) * NanoManager::SkillTable[skillId].powerIntensity[0] / 1000;
|
skill->iDamage = PC_MAXHEALTH(plr->level) * NanoManager::SkillTable[skillId].powerIntensity[0] / 1000;
|
||||||
plr->HP -= skill->iDamage;
|
plr->HP -= skill->iDamage;
|
||||||
|
if (plr->HP < 0)
|
||||||
|
plr->HP = 0;
|
||||||
skill->iHP = plr->HP;
|
skill->iHP = plr->HP;
|
||||||
} else if (skillId == 147) { // heal egg
|
} else if (skillId == 147) { // heal egg
|
||||||
sSkillResult_Heal_HP* skill = (sSkillResult_Heal_HP*)(respbuf + sizeof(sP_FE2CL_NPC_SKILL_HIT));
|
sSkillResult_Heal_HP* skill = (sSkillResult_Heal_HP*)(respbuf + sizeof(sP_FE2CL_NPC_SKILL_HIT));
|
||||||
@ -653,17 +650,12 @@ void NPCManager::eggStep(CNServer* serv, time_t currTime) {
|
|||||||
// check remaining time
|
// check remaining time
|
||||||
if (it->second > timeStamp)
|
if (it->second > timeStamp)
|
||||||
it++;
|
it++;
|
||||||
|
else { // if time reached 0
|
||||||
// if time reached 0
|
|
||||||
else {
|
|
||||||
CNSocket* sock = it->first.first;
|
CNSocket* sock = it->first.first;
|
||||||
int32_t CBFlag = it->first.second;
|
int32_t CBFlag = it->first.second;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
|
|
||||||
if (otherPlr == nullptr)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
int groupFlags = GroupManager::getGroupFlags(otherPlr);
|
int groupFlags = GroupManager::getGroupFlags(otherPlr);
|
||||||
for (auto& pwr : NanoManager::NanoPowers) {
|
for (auto& pwr : NanoManager::NanoPowers) {
|
||||||
if (pwr.bitFlag == CBFlag) { // pick the power with the right flag and unbuff
|
if (pwr.bitFlag == CBFlag) { // pick the power with the right flag and unbuff
|
||||||
@ -691,8 +683,7 @@ void NPCManager::eggStep(CNServer* serv, time_t currTime) {
|
|||||||
egg.second->deadUntil = 0;
|
egg.second->deadUntil = 0;
|
||||||
egg.second->appearanceData.iHP = 400;
|
egg.second->appearanceData.iHP = 400;
|
||||||
|
|
||||||
ChunkManager::addNPCToChunks(ChunkManager::getViewableChunks(egg.second->chunkPos),
|
ChunkManager::addNPCToChunks(ChunkManager::getViewableChunks(egg.second->chunkPos), egg.first);
|
||||||
egg.first);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user