add framedata
This commit is contained in:
parent
6e0ec1c6d3
commit
1e4cfa3363
106
server/gameserver/framedata.cc
Normal file
106
server/gameserver/framedata.cc
Normal file
@ -0,0 +1,106 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include "framedata.h"
|
||||
#include "human.h"
|
||||
#include "room.h"
|
||||
|
||||
void FrameData::ClearFrameData(Human* hum)
|
||||
{
|
||||
if (!new_objects.empty()) {
|
||||
new_objects.clear();
|
||||
}
|
||||
if (!del_objects.empty()) {
|
||||
if (!a8::HasBitFlag(hum->status, CS_Disable)) {
|
||||
for (auto& itr : del_objects) {
|
||||
Entity* entity = hum->room->GetEntityByUniId(itr);
|
||||
if (entity) {
|
||||
hum->RemovePartObjects(entity);
|
||||
if (entity->IsEntityType(ET_Player)) {
|
||||
((Human*)entity)->RemovePartObjects(hum);
|
||||
}
|
||||
#ifdef DEBUG1
|
||||
room->CheckPartObjects();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
del_objects.clear();
|
||||
}
|
||||
if (!out_objects.empty()) {
|
||||
if (!a8::HasBitFlag(hum->status, CS_Disable)) {
|
||||
for (auto& itr : out_objects) {
|
||||
Entity* entity = hum->room->GetEntityByUniId(itr);
|
||||
if (entity) {
|
||||
hum->RemovePartObjects(entity);
|
||||
if (entity->IsEntityType(ET_Player)) {
|
||||
((Human*)entity)->RemovePartObjects(hum);
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG1
|
||||
room->CheckPartObjects();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
out_objects.clear();
|
||||
}
|
||||
if (!shots_.empty()) {
|
||||
shots_.clear();
|
||||
}
|
||||
if (!bullets_.empty()) {
|
||||
bullets_.clear();
|
||||
}
|
||||
if (!explosions_.empty()) {
|
||||
explosions_.clear();
|
||||
}
|
||||
if (!smokes_.empty()) {
|
||||
smokes_.clear();
|
||||
}
|
||||
if (!play_skills_.empty()) {
|
||||
play_skills_.clear();
|
||||
}
|
||||
if (!emotes_.empty()) {
|
||||
emotes_.clear();
|
||||
}
|
||||
if (!chged_bullet_nums_.empty()) {
|
||||
chged_bullet_nums_.clear();
|
||||
}
|
||||
if (!chged_hps_.empty()) {
|
||||
chged_hps_.clear();
|
||||
}
|
||||
if (!chged_buffs_.empty()) {
|
||||
chged_buffs_.clear();
|
||||
}
|
||||
if (!chged_skillcds_.empty()) {
|
||||
chged_skillcds_.clear();
|
||||
}
|
||||
if (!chged_skill_curr_times_.empty()) {
|
||||
chged_skill_curr_times_.clear();
|
||||
}
|
||||
if (!chged_items_.empty()) {
|
||||
chged_items_.clear();
|
||||
}
|
||||
if (!chged_weapon_ammo_.empty()) {
|
||||
chged_weapon_ammo_.clear();
|
||||
}
|
||||
if (!chged_level_.empty()) {
|
||||
chged_level_.clear();
|
||||
}
|
||||
if (!chged_exp_.empty()) {
|
||||
chged_exp_.clear();
|
||||
}
|
||||
if (!chged_race_.empty()) {
|
||||
chged_race_.clear();
|
||||
}
|
||||
if (!dead_alive_objs_.empty()) {
|
||||
dead_alive_objs_.clear();
|
||||
}
|
||||
if (!chged_cars_.empty()) {
|
||||
chged_cars_.clear();
|
||||
}
|
||||
if (!chged_props_.empty()) {
|
||||
chged_props_.clear();
|
||||
}
|
||||
if (!del_bullets_.empty()) {
|
||||
del_bullets_.clear();
|
||||
}
|
||||
}
|
49
server/gameserver/framedata.h
Normal file
49
server/gameserver/framedata.h
Normal file
@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include "weakptr.h"
|
||||
|
||||
struct PartObject
|
||||
{
|
||||
int entity_uniid = 0;
|
||||
int entity_type = 0;
|
||||
int entity_subtype = 0;
|
||||
long long add_frameno = 0;
|
||||
EntityWeakPtr object;
|
||||
};
|
||||
|
||||
class Human;
|
||||
class FrameData
|
||||
{
|
||||
private:
|
||||
void ClearFrameData(Human* hum);
|
||||
|
||||
private:
|
||||
std::map<int, EntityWeakPtr> new_objects;
|
||||
std::map<int, PartObject> part_objects;
|
||||
std::set<int> del_objects;
|
||||
std::set<int> out_objects;
|
||||
std::vector<int> shots_;
|
||||
std::vector<int> emotes_;
|
||||
std::vector<int> bullets_;
|
||||
std::vector<int> smokes_;
|
||||
std::vector<int> play_skills_;
|
||||
std::vector<int> explosions_;
|
||||
std::vector<int> chged_buffs_;
|
||||
std::vector<int> chged_bullet_nums_;
|
||||
std::vector<int> chged_hps_;
|
||||
std::vector<int> chged_skillcds_;
|
||||
std::vector<int> chged_skill_curr_times_;
|
||||
std::vector<int> chged_items_;
|
||||
std::vector<int> chged_weapon_ammo_;
|
||||
std::vector<int> chged_level_;
|
||||
std::vector<int> chged_exp_;
|
||||
std::vector<int> chged_race_;
|
||||
std::vector<int> dead_alive_objs_;
|
||||
std::vector<int> chged_cars_;
|
||||
std::vector<int> chged_props_;
|
||||
std::vector<int> del_bullets_;
|
||||
|
||||
friend class Human;
|
||||
friend class FrameMaker;
|
||||
friend class FrameEvent;
|
||||
};
|
@ -42,7 +42,7 @@ void FrameEvent::AddEmote(CreatureWeakPtr& sender, int emote_id)
|
||||
(
|
||||
[emote_idx] (Human* hum, bool& stop)
|
||||
{
|
||||
hum->emotes_.push_back(emote_idx);
|
||||
hum->framedata_.emotes_.push_back(emote_idx);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -70,7 +70,7 @@ void FrameEvent::AddShot(CreatureWeakPtr& sender)
|
||||
(
|
||||
[shot_idx] (Human* hum, bool& stop)
|
||||
{
|
||||
hum->shots_.push_back(shot_idx);
|
||||
hum->framedata_.shots_.push_back(shot_idx);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -111,7 +111,7 @@ void FrameEvent::AddBullet(int bullet_uniid,
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
hum->bullets_.push_back(bullet_idx);
|
||||
hum->framedata_.bullets_.push_back(bullet_idx);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -136,7 +136,7 @@ void FrameEvent::RemoveBullet(a8::Vec2 pos, int bullet_uniid)
|
||||
grid_list,
|
||||
[bullet_idx] (Human* hum, bool& stop)
|
||||
{
|
||||
hum->del_bullets_.push_back(bullet_idx);
|
||||
hum->framedata_.del_bullets_.push_back(bullet_idx);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -184,7 +184,7 @@ void FrameEvent::AddExplosionEx(CreatureWeakPtr& sender, int item_id, a8::Vec2 b
|
||||
grid_list,
|
||||
[explosion_idx] (Human* hum, bool& stop)
|
||||
{
|
||||
hum->explosions_.push_back(explosion_idx);
|
||||
hum->framedata_.explosions_.push_back(explosion_idx);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -194,13 +194,13 @@ void FrameEvent::AddBulletNumChg(CreatureWeakPtr& sender)
|
||||
chged_bullet_nums_.push_back(sender);
|
||||
int idx = chged_bullet_nums_.size() - 1;
|
||||
if (sender.Get()->IsHuman()) {
|
||||
sender.Get()->AsHuman()->chged_bullet_nums_.push_back(idx);
|
||||
sender.Get()->AsHuman()->framedata_.chged_bullet_nums_.push_back(idx);
|
||||
} else {
|
||||
sender.Get()->TraverseAllLayerHumanList
|
||||
(
|
||||
[idx] (Human* hum, bool& stop)
|
||||
{
|
||||
hum->chged_bullet_nums_.push_back(idx);
|
||||
hum->framedata_.chged_bullet_nums_.push_back(idx);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -226,7 +226,7 @@ void FrameEvent::AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos, float time_
|
||||
(
|
||||
[idx] (Human* hum, bool& stop)
|
||||
{
|
||||
hum->smokes_.push_back(idx);
|
||||
hum->framedata_.smokes_.push_back(idx);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -249,7 +249,7 @@ void FrameEvent::AddPlaySkill(CreatureWeakPtr& sender, int skill_id)
|
||||
(
|
||||
[idx] (Human* hum, bool& stop)
|
||||
{
|
||||
hum->play_skills_.push_back(idx);
|
||||
hum->framedata_.play_skills_.push_back(idx);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -262,7 +262,7 @@ void FrameEvent::AddHpChg(CreatureWeakPtr& sender)
|
||||
(
|
||||
[idx] (Human* hum, bool& stop)
|
||||
{
|
||||
hum->chged_hps_.push_back(idx);
|
||||
hum->framedata_.chged_hps_.push_back(idx);
|
||||
});
|
||||
}
|
||||
|
||||
@ -278,13 +278,13 @@ void FrameEvent::AddWeaponAmmoChg(CreatureWeakPtr& sender)
|
||||
);
|
||||
int idx = chged_weapon_ammo_.size() - 1;
|
||||
if (sender.Get()->IsHuman()) {
|
||||
sender.Get()->AsHuman()->chged_weapon_ammo_.push_back(idx);
|
||||
sender.Get()->AsHuman()->framedata_.chged_weapon_ammo_.push_back(idx);
|
||||
} else {
|
||||
sender.Get()->TraverseAllLayerHumanList
|
||||
(
|
||||
[idx] (Human* hum, bool& stop)
|
||||
{
|
||||
hum->chged_weapon_ammo_.push_back(idx);
|
||||
hum->framedata_.chged_weapon_ammo_.push_back(idx);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -305,7 +305,7 @@ void FrameEvent::AddBuff(CreatureWeakPtr& sender, Buff* buff)
|
||||
(
|
||||
[idx] (Human* hum, bool& stop)
|
||||
{
|
||||
hum->chged_buffs_.push_back(idx);
|
||||
hum->framedata_.chged_buffs_.push_back(idx);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -325,7 +325,7 @@ void FrameEvent::RemoveBuff(CreatureWeakPtr& sender, int buff_id)
|
||||
(
|
||||
[idx] (Human* hum, bool& stop)
|
||||
{
|
||||
hum->chged_buffs_.push_back(idx);
|
||||
hum->framedata_.chged_buffs_.push_back(idx);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -335,7 +335,7 @@ void FrameEvent::AddSkillCdChg(CreatureWeakPtr sender, int skill_id, int left_ti
|
||||
if (sender.Get() && sender.Get()->IsHuman()) {
|
||||
chged_skillcds_.push_back(std::make_tuple(sender, skill_id, left_time));
|
||||
int idx = chged_skillcds_.size() - 1;
|
||||
((Human*)sender.Get())->chged_skillcds_.push_back(idx);
|
||||
((Human*)sender.Get())->framedata_.chged_skillcds_.push_back(idx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -344,7 +344,7 @@ void FrameEvent::AddSkillCurrTimesChg(CreatureWeakPtr sender, int skill_id, int
|
||||
if (sender.Get() && sender.Get()->IsHuman()) {
|
||||
chged_skill_curr_times_.push_back(std::make_tuple(sender, skill_id, curr_times));
|
||||
int idx = chged_skill_curr_times_.size() - 1;
|
||||
((Human*)sender.Get())->chged_skill_curr_times_.push_back(idx);
|
||||
((Human*)sender.Get())->framedata_.chged_skill_curr_times_.push_back(idx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,7 +353,7 @@ void FrameEvent::AddItemChg(CreatureWeakPtr& sender, int item_id, int item_num)
|
||||
if (sender.Get()->IsHuman()) {
|
||||
chged_items_.push_back(std::make_tuple(sender, item_id, item_num));
|
||||
int idx = chged_items_.size() - 1;
|
||||
((Human*)sender.Get())->chged_items_.push_back(idx);
|
||||
((Human*)sender.Get())->framedata_.chged_items_.push_back(idx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -375,7 +375,7 @@ void FrameEvent::AddDead(CreatureWeakPtr& sender, int revive_time)
|
||||
(
|
||||
[dead_idx] (Human* hum, bool& stop)
|
||||
{
|
||||
hum->dead_alive_objs_.push_back(dead_idx);
|
||||
hum->framedata_.dead_alive_objs_.push_back(dead_idx);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -399,7 +399,7 @@ void FrameEvent::AddRevive(CreatureWeakPtr& sender)
|
||||
(
|
||||
[revive_idx] (Human* hum, bool& stop)
|
||||
{
|
||||
hum->dead_alive_objs_.push_back(revive_idx);
|
||||
hum->framedata_.dead_alive_objs_.push_back(revive_idx);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -413,7 +413,7 @@ void FrameEvent::AddCarChg(CreatureWeakPtr& sender)
|
||||
(
|
||||
[idx] (Human* hum, bool& stop)
|
||||
{
|
||||
hum->chged_cars_.push_back(idx);
|
||||
hum->framedata_.chged_cars_.push_back(idx);
|
||||
});
|
||||
}
|
||||
|
||||
@ -431,14 +431,14 @@ void FrameEvent::AddPropChg(CreatureWeakPtr& sender, int type, int subtype, floa
|
||||
int idx = chged_props_.size() - 1;
|
||||
if (only_self) {
|
||||
if (sender.Get()->IsHuman()) {
|
||||
sender.Get()->AsHuman()->chged_props_.push_back(idx);
|
||||
sender.Get()->AsHuman()->framedata_.chged_props_.push_back(idx);
|
||||
}
|
||||
} else {
|
||||
sender.Get()->TraverseAllLayerHumanList
|
||||
(
|
||||
[idx] (Human* hum, bool& stop)
|
||||
{
|
||||
hum->chged_props_.push_back(idx);
|
||||
hum->framedata_.chged_props_.push_back(idx);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,9 @@
|
||||
|
||||
void FrameMaker::Debug_FullObject(Human* hum)
|
||||
{
|
||||
if (!hum->new_objects.empty()) {
|
||||
if (!hum->framedata_.new_objects.empty()) {
|
||||
a8::MutableXObject* out_data = a8::MutableXObject::NewArray();
|
||||
for (auto& pair : hum->new_objects) {
|
||||
for (auto& pair : hum->framedata_.new_objects) {
|
||||
a8::MutableXObject* xobj = a8::MutableXObject::NewObject();
|
||||
xobj->SetVal("uniid", pair.first);
|
||||
if (pair.second.Get()) {
|
||||
@ -42,9 +42,9 @@ void FrameMaker::Debug_FullObject(Human* hum)
|
||||
|
||||
void FrameMaker::Debug_OutObject(Human* hum)
|
||||
{
|
||||
if (!hum->out_objects.empty()) {
|
||||
if (!hum->framedata_.out_objects.empty()) {
|
||||
a8::MutableXObject* out_data = a8::MutableXObject::NewArray();
|
||||
for (auto& itr : hum->out_objects) {
|
||||
for (auto& itr : hum->framedata_.out_objects) {
|
||||
int uniid = itr;
|
||||
a8::MutableXObject* xobj = a8::MutableXObject::NewObject();
|
||||
xobj->SetVal("uniid", uniid);
|
||||
@ -68,6 +68,7 @@ void FrameMaker::Debug_OutObject(Human* hum)
|
||||
|
||||
cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
{
|
||||
FrameData* framedata = &hum->framedata_;
|
||||
cs::SMUpdate* msg = new cs::SMUpdate;
|
||||
{
|
||||
Room* room = hum->room;
|
||||
@ -81,13 +82,13 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
#ifdef DEBUG
|
||||
Debug_FullObject(hum);
|
||||
#endif
|
||||
for (auto& pair : hum->new_objects) {
|
||||
for (auto& pair : framedata->new_objects) {
|
||||
Entity* e = pair.second.Get();
|
||||
if (!e) {
|
||||
continue;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (hum->del_objects.find(e->GetUniId()) != hum->del_objects.end()) {
|
||||
if (framedata->del_objects.find(e->GetUniId()) != framedata->del_objects.end()) {
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
@ -117,7 +118,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
{
|
||||
int deleted_uniid = 0;
|
||||
for (auto& pair : hum->part_objects) {
|
||||
for (auto& pair : framedata->part_objects) {
|
||||
Entity* entity = pair.second.object.Get();
|
||||
if (!entity) {
|
||||
#ifdef DEBUG
|
||||
@ -145,10 +146,10 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
entity->FillMFObjectPart(room, (Human*)hum, msg->add_part_objects());
|
||||
}
|
||||
if (deleted_uniid > 0) {
|
||||
hum->part_objects.erase(deleted_uniid);
|
||||
framedata->part_objects.erase(deleted_uniid);
|
||||
}
|
||||
}
|
||||
for (auto& itr : hum->del_objects) {
|
||||
for (auto& itr : framedata->del_objects) {
|
||||
msg->add_del_objids(itr);
|
||||
#ifdef DEBUG
|
||||
if (App::Instance()->HasFlag(2)) {
|
||||
@ -162,7 +163,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
#ifdef DEBUG
|
||||
Debug_OutObject(hum);
|
||||
#endif
|
||||
for (auto& itr : hum->out_objects) {
|
||||
for (auto& itr : framedata->out_objects) {
|
||||
msg->add_out_objids(itr);
|
||||
#ifdef DEBUG
|
||||
if (App::Instance()->HasFlag(2)) {
|
||||
@ -173,7 +174,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
for (size_t idx : hum->shots_) {
|
||||
for (size_t idx : framedata->shots_) {
|
||||
if (idx < room->frame_event.shots_.size()) {
|
||||
auto& tuple = room->frame_event.shots_[idx];
|
||||
if (std::get<0>(tuple).Get() && hum->CanSee(std::get<0>(tuple).Get())) {
|
||||
@ -189,7 +190,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->bullets_) {
|
||||
for (size_t idx : framedata->bullets_) {
|
||||
if (idx < room->frame_event.bullets_.size()) {
|
||||
auto& tuple = room->frame_event.bullets_[idx];
|
||||
if (std::get<0>(tuple).Get() && hum->CanSee(std::get<0>(tuple).Get())) {
|
||||
@ -197,13 +198,13 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->del_bullets_) {
|
||||
for (size_t idx : framedata->del_bullets_) {
|
||||
if (idx < room->frame_event.del_bullets_.size()) {
|
||||
int bullet_uniid = room->frame_event.del_bullets_[idx];
|
||||
msg->add_del_bullets(bullet_uniid);
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->explosions_) {
|
||||
for (size_t idx : framedata->explosions_) {
|
||||
if (idx < room->frame_event.explosions_.size()) {
|
||||
auto& tuple = room->frame_event.explosions_[idx];
|
||||
*msg->add_explosions() = std::get<1>(tuple);
|
||||
@ -219,7 +220,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->smokes_) {
|
||||
for (size_t idx : framedata->smokes_) {
|
||||
if (idx < room->frame_event.smokes_.size()) {
|
||||
auto& tuple = room->frame_event.smokes_[idx];
|
||||
if (std::get<0>(tuple).Get() && hum->CanSee(std::get<0>(tuple).Get())) {
|
||||
@ -227,7 +228,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->play_skills_) {
|
||||
for (size_t idx : framedata->play_skills_) {
|
||||
if (idx < room->frame_event.play_skills_.size()) {
|
||||
auto& tuple = room->frame_event.play_skills_[idx];
|
||||
if (std::get<0>(tuple).Get() && hum->CanSee(std::get<0>(tuple).Get())) {
|
||||
@ -235,7 +236,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->emotes_) {
|
||||
for (size_t idx : framedata->emotes_) {
|
||||
if (idx < room->frame_event.emotes_.size()) {
|
||||
auto& tuple = room->frame_event.emotes_[idx];
|
||||
if (std::get<0>(tuple).Get() && hum->CanSee(std::get<0>(tuple).Get())) {
|
||||
@ -243,7 +244,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->chged_bullet_nums_) {
|
||||
for (size_t idx : framedata->chged_bullet_nums_) {
|
||||
if (idx < room->frame_event.chged_bullet_nums_.size()) {
|
||||
CreatureWeakPtr& target = room->frame_event.chged_bullet_nums_[idx];
|
||||
if (target.Get()->GetCurrWeapon()) {
|
||||
@ -287,13 +288,13 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (size_t idx : hum->chged_buffs_) {
|
||||
for (size_t idx : framedata->chged_buffs_) {
|
||||
if (idx < room->frame_event.chged_buffs_.size()) {
|
||||
auto p = msg->add_chged_buff_list();
|
||||
*p = std::get<1>(room->frame_event.chged_buffs_[idx]);
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->chged_skillcds_) {
|
||||
for (size_t idx : framedata->chged_skillcds_) {
|
||||
if (idx < room->frame_event.chged_skillcds_.size()) {
|
||||
auto tuple = room->frame_event.chged_skillcds_[idx];
|
||||
CreatureWeakPtr target = std::get<0>(tuple);
|
||||
@ -308,7 +309,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->chged_skill_curr_times_) {
|
||||
for (size_t idx : framedata->chged_skill_curr_times_) {
|
||||
if (idx < room->frame_event.chged_skill_curr_times_.size()) {
|
||||
auto tuple = room->frame_event.chged_skill_curr_times_[idx];
|
||||
CreatureWeakPtr& target = std::get<0>(tuple);
|
||||
@ -323,7 +324,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->chged_hps_) {
|
||||
for (size_t idx : framedata->chged_hps_) {
|
||||
if (idx < room->frame_event.chged_hps_.size()) {
|
||||
CreatureWeakPtr& target = room->frame_event.chged_hps_[idx];
|
||||
if (target.Get() && hum->CanSee(target.Get())) {
|
||||
@ -342,7 +343,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->chged_items_) {
|
||||
for (size_t idx : framedata->chged_items_) {
|
||||
if (idx < room->frame_event.chged_items_.size()) {
|
||||
auto& tuple = room->frame_event.chged_items_[idx];
|
||||
{
|
||||
@ -354,7 +355,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->chged_weapon_ammo_) {
|
||||
for (size_t idx : framedata->chged_weapon_ammo_) {
|
||||
if (idx < room->frame_event.chged_weapon_ammo_.size()) {
|
||||
auto& tuple = room->frame_event.chged_weapon_ammo_[idx];
|
||||
{
|
||||
@ -366,7 +367,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->dead_alive_objs_) {
|
||||
for (size_t idx : framedata->dead_alive_objs_) {
|
||||
if (idx < room->frame_event.dead_alive_objs_.size()) {
|
||||
auto p = msg->add_dead_alive_objs();
|
||||
p->add_values(std::get<0>(room->frame_event.dead_alive_objs_[idx]));
|
||||
@ -374,7 +375,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
p->add_values(std::get<2>(room->frame_event.dead_alive_objs_[idx]));
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->chged_cars_) {
|
||||
for (size_t idx : framedata->chged_cars_) {
|
||||
if (idx < room->frame_event.chged_cars_.size()) {
|
||||
CreatureWeakPtr& target = room->frame_event.chged_cars_[idx];
|
||||
if (target.Get() && target.Get()->IsHuman() && hum->CanSee(target.Get())) {
|
||||
@ -391,7 +392,7 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t idx : hum->chged_props_) {
|
||||
for (size_t idx : framedata->chged_props_) {
|
||||
if (idx < room->frame_event.chged_props_.size()) {
|
||||
auto& p = room->frame_event.chged_props_[idx];
|
||||
auto& target = std::get<0>(p);
|
||||
|
@ -816,7 +816,7 @@ void Human::DecHP(float dec_hp, int killer_id, const std::string& killer_name, i
|
||||
|
||||
void Human::AddToNewObjects(Entity* entity)
|
||||
{
|
||||
new_objects[entity->GetUniId()] = entity->GetEntityWeakPtrRef();
|
||||
framedata_.new_objects[entity->GetUniId()] = entity->GetEntityWeakPtrRef();
|
||||
}
|
||||
|
||||
void Human::AddToPartObjects(Entity* entity)
|
||||
@ -827,7 +827,7 @@ void Human::AddToPartObjects(Entity* entity)
|
||||
part_obj.entity_subtype = entity->GetEntitySubType();
|
||||
part_obj.add_frameno = room->GetFrameNo();
|
||||
part_obj.object = entity->GetEntityWeakPtrRef();
|
||||
part_objects[entity->GetUniId()] = part_obj;
|
||||
framedata_.part_objects[entity->GetUniId()] = part_obj;
|
||||
entity->OnAddToTargetPartObject(this);
|
||||
}
|
||||
|
||||
@ -840,44 +840,44 @@ void Human::RemovePartObjects(Entity* entity)
|
||||
entity->GetUniId()
|
||||
}));
|
||||
#endif
|
||||
part_objects.erase(entity->GetUniId());
|
||||
framedata_.part_objects.erase(entity->GetUniId());
|
||||
entity->OnRemoveFromTargetPartObject(this);
|
||||
}
|
||||
|
||||
void Human::ClearPartObjects()
|
||||
{
|
||||
part_objects.clear();
|
||||
framedata_.part_objects.clear();
|
||||
}
|
||||
|
||||
int Human::GetPartObjectsCount()
|
||||
{
|
||||
return part_objects.size();
|
||||
return framedata_.part_objects.size();
|
||||
}
|
||||
|
||||
bool Human::InNewObjects(Entity* target)
|
||||
{
|
||||
return new_objects.find(target->GetUniId()) != new_objects.end();
|
||||
return framedata_.new_objects.find(target->GetUniId()) != framedata_.new_objects.end();
|
||||
}
|
||||
|
||||
bool Human::InPartObjects(Entity* target)
|
||||
{
|
||||
return part_objects.find(target->GetUniId()) != part_objects.end();
|
||||
return framedata_.part_objects.find(target->GetUniId()) != framedata_.part_objects.end();
|
||||
}
|
||||
|
||||
void Human::RemoveObjects(Entity* entity)
|
||||
{
|
||||
del_objects.insert(entity->GetUniId());
|
||||
new_objects.erase(entity->GetUniId());
|
||||
framedata_.del_objects.insert(entity->GetUniId());
|
||||
framedata_.new_objects.erase(entity->GetUniId());
|
||||
}
|
||||
|
||||
void Human::AddOutObjects(Entity* entity)
|
||||
{
|
||||
out_objects.insert(entity->GetUniId());
|
||||
framedata_.out_objects.insert(entity->GetUniId());
|
||||
}
|
||||
|
||||
void Human::RemoveOutObjects(Entity* entity)
|
||||
{
|
||||
out_objects.erase(entity->GetUniId());
|
||||
framedata_.out_objects.erase(entity->GetUniId());
|
||||
}
|
||||
|
||||
bool Human::HasLiveTeammate()
|
||||
@ -1319,7 +1319,7 @@ void Human::SendUpdateMsg()
|
||||
} else {
|
||||
need_sync_active_player = false;
|
||||
}
|
||||
ClearFrameData();
|
||||
framedata_.ClearFrameData(this);
|
||||
}
|
||||
|
||||
void Human::SendGameOver()
|
||||
@ -1592,109 +1592,6 @@ void Human::_InternalUpdateMove(float speed)
|
||||
room->grid_service->MoveCreature(this);
|
||||
}
|
||||
|
||||
void Human::ClearFrameData()
|
||||
{
|
||||
if (!new_objects.empty()) {
|
||||
new_objects.clear();
|
||||
}
|
||||
if (!del_objects.empty()) {
|
||||
if (!a8::HasBitFlag(status, CS_Disable)) {
|
||||
for (auto& itr : del_objects) {
|
||||
Entity* entity = room->GetEntityByUniId(itr);
|
||||
if (entity) {
|
||||
RemovePartObjects(entity);
|
||||
if (entity->IsEntityType(ET_Player)) {
|
||||
Human* hum = (Human*)entity;
|
||||
hum->RemovePartObjects(this);
|
||||
}
|
||||
#ifdef DEBUG1
|
||||
room->CheckPartObjects();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
del_objects.clear();
|
||||
}
|
||||
if (!out_objects.empty()) {
|
||||
if (!a8::HasBitFlag(status, CS_Disable)) {
|
||||
for (auto& itr : out_objects) {
|
||||
Entity* entity = room->GetEntityByUniId(itr);
|
||||
if (entity) {
|
||||
RemovePartObjects(entity);
|
||||
if (entity->IsEntityType(ET_Player)) {
|
||||
Human* hum = (Human*)entity;
|
||||
hum->RemovePartObjects(this);
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG1
|
||||
room->CheckPartObjects();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
out_objects.clear();
|
||||
}
|
||||
if (!shots_.empty()) {
|
||||
shots_.clear();
|
||||
}
|
||||
if (!bullets_.empty()) {
|
||||
bullets_.clear();
|
||||
}
|
||||
if (!explosions_.empty()) {
|
||||
explosions_.clear();
|
||||
}
|
||||
if (!smokes_.empty()) {
|
||||
smokes_.clear();
|
||||
}
|
||||
if (!play_skills_.empty()) {
|
||||
play_skills_.clear();
|
||||
}
|
||||
if (!emotes_.empty()) {
|
||||
emotes_.clear();
|
||||
}
|
||||
if (!chged_bullet_nums_.empty()) {
|
||||
chged_bullet_nums_.clear();
|
||||
}
|
||||
if (!chged_hps_.empty()) {
|
||||
chged_hps_.clear();
|
||||
}
|
||||
if (!chged_buffs_.empty()) {
|
||||
chged_buffs_.clear();
|
||||
}
|
||||
if (!chged_skillcds_.empty()) {
|
||||
chged_skillcds_.clear();
|
||||
}
|
||||
if (!chged_skill_curr_times_.empty()) {
|
||||
chged_skill_curr_times_.clear();
|
||||
}
|
||||
if (!chged_items_.empty()) {
|
||||
chged_items_.clear();
|
||||
}
|
||||
if (!chged_weapon_ammo_.empty()) {
|
||||
chged_weapon_ammo_.clear();
|
||||
}
|
||||
if (!chged_level_.empty()) {
|
||||
chged_level_.clear();
|
||||
}
|
||||
if (!chged_exp_.empty()) {
|
||||
chged_exp_.clear();
|
||||
}
|
||||
if (!chged_race_.empty()) {
|
||||
chged_race_.clear();
|
||||
}
|
||||
if (!dead_alive_objs_.empty()) {
|
||||
dead_alive_objs_.clear();
|
||||
}
|
||||
if (!chged_cars_.empty()) {
|
||||
chged_cars_.clear();
|
||||
}
|
||||
if (!chged_props_.empty()) {
|
||||
chged_props_.clear();
|
||||
}
|
||||
if (!del_bullets_.empty()) {
|
||||
del_bullets_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void Human::GenBattleReportData(a8::MutableXObject* params)
|
||||
{
|
||||
params->SetVal("room_mode", room->GetRoomMode());
|
||||
@ -2417,7 +2314,7 @@ void Human::OnDisable()
|
||||
{
|
||||
a8::SetBitFlag(status, CS_Disable);
|
||||
RemoveFromScene();
|
||||
ClearFrameData();
|
||||
framedata_.ClearFrameData(this);
|
||||
ClearPartObjects();
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "creature.h"
|
||||
#include "GGListener.h"
|
||||
#include "skin.h"
|
||||
#include "framedata.h"
|
||||
|
||||
namespace MetaData
|
||||
{
|
||||
@ -14,15 +15,6 @@ namespace MetaData
|
||||
struct SkillPhase;
|
||||
}
|
||||
|
||||
struct PartObject
|
||||
{
|
||||
int entity_uniid = 0;
|
||||
int entity_type = 0;
|
||||
int entity_subtype = 0;
|
||||
long long add_frameno = 0;
|
||||
EntityWeakPtr object;
|
||||
};
|
||||
|
||||
struct HumanBehavior
|
||||
{
|
||||
long long curr_start_destory_box_frameno = 0;
|
||||
@ -288,7 +280,6 @@ protected:
|
||||
void DropWeapon(int weapon_idx);
|
||||
|
||||
private:
|
||||
void ClearFrameData();
|
||||
void GenBattleReportData(a8::MutableXObject* params);
|
||||
void FillSMGameOver(cs::SMGameOver& msg);
|
||||
void SendBattleReport();
|
||||
@ -332,31 +323,6 @@ protected:
|
||||
long long leave_frameno_ = 0;
|
||||
|
||||
std::array<int, IS_END> volume_ = {};
|
||||
std::map<int, EntityWeakPtr> new_objects;
|
||||
std::map<int, PartObject> part_objects;
|
||||
std::set<int> del_objects;
|
||||
std::set<int> out_objects;
|
||||
std::vector<int> shots_;
|
||||
std::vector<int> emotes_;
|
||||
std::vector<int> bullets_;
|
||||
std::vector<int> smokes_;
|
||||
std::vector<int> play_skills_;
|
||||
std::vector<int> explosions_;
|
||||
std::vector<int> chged_buffs_;
|
||||
std::set<Human*> observers_;
|
||||
std::vector<int> chged_bullet_nums_;
|
||||
std::vector<int> chged_hps_;
|
||||
std::vector<int> chged_skillcds_;
|
||||
std::vector<int> chged_skill_curr_times_;
|
||||
std::vector<int> chged_items_;
|
||||
std::vector<int> chged_weapon_ammo_;
|
||||
std::vector<int> chged_level_;
|
||||
std::vector<int> chged_exp_;
|
||||
std::vector<int> chged_race_;
|
||||
std::vector<int> dead_alive_objs_;
|
||||
std::vector<int> chged_cars_;
|
||||
std::vector<int> chged_props_;
|
||||
std::vector<int> del_bullets_;
|
||||
Human* follow_target_ = nullptr;
|
||||
bool follow_synced_active_player = false;
|
||||
Car* car_ = nullptr;
|
||||
@ -366,6 +332,8 @@ protected:
|
||||
std::vector<Skin> skins;
|
||||
|
||||
private:
|
||||
FrameData framedata_;
|
||||
std::set<Human*> observers_;
|
||||
long long last_sync_gas_frameno = 0;
|
||||
std::map<int, int> items_;
|
||||
std::set<int> battling_items_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user