性能优化
This commit is contained in:
parent
d9568fda0c
commit
28f2816ede
@ -19,6 +19,8 @@ public:
|
||||
void Init();
|
||||
void UnInit();
|
||||
|
||||
int max_packet_size = 0;
|
||||
|
||||
template <typename T>
|
||||
void SendProxyMsg(int sockhandle, T& msg)
|
||||
{
|
||||
@ -30,7 +32,10 @@ public:
|
||||
void SendToClient(int sockhandle, unsigned int seqid, T& msg)
|
||||
{
|
||||
static int msgid = f8::Net_GetMessageId(msg);
|
||||
f8::Net_SendProxyMsg(tcp_listener_, sockhandle, seqid, 0, msgid, msg);
|
||||
int packet_size = f8::Net_SendProxyMsg(tcp_listener_, sockhandle, seqid, 0, msgid, msg);
|
||||
if (packet_size > max_packet_size) {
|
||||
max_packet_size = packet_size;
|
||||
}
|
||||
}
|
||||
void SendText(int sockhandle, const std::string& text);
|
||||
|
||||
|
@ -63,7 +63,8 @@ static void SavePerfLog()
|
||||
a8::UdpLog::Instance()->Info
|
||||
("max_rundelay:%d room_num:%d player_num:%d online_num:%d alive_count:%d "
|
||||
"sys_request_delay:%d user_request_delay:%d http_pending_num:%d real_alive_count:%d "
|
||||
"account_num:%d level0_num:%d level1_num:%d",
|
||||
"account_num:%d level0_num:%d level1_num:%d max_full_obj:%d max_part_obj:%d max_bullet:%d "
|
||||
"max_packet:%d",
|
||||
{
|
||||
PerfMonitor::Instance()->max_run_delay_time,
|
||||
RoomMgr::Instance()->RoomNum(),
|
||||
@ -76,20 +77,28 @@ static void SavePerfLog()
|
||||
PerfMonitor::Instance()->real_alive_count,
|
||||
PlayerMgr::Instance()->GetAccountNum(),
|
||||
PerfMonitor::Instance()->room_num[RT_NewBrid],
|
||||
PerfMonitor::Instance()->room_num[RT_MidBrid]
|
||||
PerfMonitor::Instance()->room_num[RT_MidBrid],
|
||||
PerfMonitor::Instance()->max_full_objects_num,
|
||||
PerfMonitor::Instance()->max_part_objects_num,
|
||||
PerfMonitor::Instance()->max_bullet_num,
|
||||
GGListener::Instance()->max_packet_size
|
||||
});
|
||||
PerfMonitor::Instance()->max_run_delay_time = 0;
|
||||
PerfMonitor::Instance()->max_dispatchmsg_time = 0;
|
||||
PerfMonitor::Instance()->max_timer_idle = 0;
|
||||
PerfMonitor::Instance()->grid_chg_times = 0;
|
||||
PerfMonitor::Instance()->test_times = 0;
|
||||
PerfMonitor::Instance()->params[0] = 0,
|
||||
PerfMonitor::Instance()->params[1] = 0,
|
||||
PerfMonitor::Instance()->params[2] = 0,
|
||||
PerfMonitor::Instance()->params[3] = 0,
|
||||
PerfMonitor::Instance()->params[4] = 0,
|
||||
PerfMonitor::Instance()->params[5] = 0,
|
||||
PerfMonitor::Instance()->params[6] = 0,
|
||||
PerfMonitor::Instance()->params[0] = 0;
|
||||
PerfMonitor::Instance()->params[1] = 0;
|
||||
PerfMonitor::Instance()->params[2] = 0;
|
||||
PerfMonitor::Instance()->params[3] = 0;
|
||||
PerfMonitor::Instance()->params[4] = 0;
|
||||
PerfMonitor::Instance()->params[5] = 0;
|
||||
PerfMonitor::Instance()->params[6] = 0;
|
||||
PerfMonitor::Instance()->max_full_objects_num = 0;
|
||||
PerfMonitor::Instance()->max_part_objects_num = 0;
|
||||
PerfMonitor::Instance()->max_bullet_num = 0;
|
||||
GGListener::Instance()->max_packet_size = 0;
|
||||
f8::HttpClientPool::Instance()->max_sys_request_delay = 0;
|
||||
f8::HttpClientPool::Instance()->max_user_request_delay = 0;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "metamgr.h"
|
||||
#include "car.h"
|
||||
#include "app.h"
|
||||
#include "perfmonitor.h"
|
||||
|
||||
void FrameMaker::Debug_FullObject(Human* hum)
|
||||
{
|
||||
@ -45,6 +46,7 @@ void FrameMaker::Debug_FullObject(Human* hum)
|
||||
}));
|
||||
}
|
||||
});
|
||||
delete out_data;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -80,6 +82,7 @@ void FrameMaker::Debug_OutObject(Human* hum)
|
||||
}));
|
||||
}
|
||||
});
|
||||
delete out_data;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -89,15 +92,8 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
FrameData* framedata = &hum->GetFrameData();
|
||||
cs::SMUpdate* msg = new cs::SMUpdate;
|
||||
Room* room = hum->room;
|
||||
{
|
||||
msg->set_frameno(hum->room->GetFrameNo() / 2);
|
||||
if (hum->room->GetGasData().gas_mode == GasJump) {
|
||||
cs::MFPlane* p = msg->mutable_plane();
|
||||
TypeConvert::ToPb(hum->room->plane.start_point, p->mutable_start_point());
|
||||
TypeConvert::ToPb(hum->room->plane.end_point, p->mutable_end_point());
|
||||
TypeConvert::ToPb(hum->room->plane.curr_pos, p->mutable_pos());
|
||||
}
|
||||
}
|
||||
|
||||
PreProcess(msg, room, hum, framedata);
|
||||
SerializeNewObjects(msg, room, hum, framedata);
|
||||
SerializePartObjects(msg, room, hum, framedata);
|
||||
SerializeDelObjects(msg, room, hum, framedata);
|
||||
@ -119,150 +115,187 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
SerializeChgedCars(msg, room, hum, framedata);
|
||||
SerializeChgedProps(msg, room, hum, framedata);
|
||||
SerializeDelBullets(msg, room, hum, framedata);
|
||||
PostProcess(msg, room, hum, framedata);
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
void FrameMaker::PreProcess(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
{
|
||||
if (room->frame_event.airdrops_.size() > 0) {
|
||||
*msg->mutable_airdrop() = room->frame_event.airdrops_.Get(0);
|
||||
}
|
||||
if (room->frame_event.airraids_.size() > 0) {
|
||||
*msg->mutable_airraid() = room->frame_event.airraids_.Get(0);
|
||||
}
|
||||
if (room->GetGasData().gas_mode == GasMoving) {
|
||||
msg->set_gas_progress(room->GetGasData().gas_progress);
|
||||
TypeConvert::ToPb(room->GetGasData().pos_old, msg->mutable_gas_pos_old());
|
||||
}
|
||||
if (room->GetFrameNo() - room->AliveCountChgFrameNo() <= 4 ||
|
||||
room->GetFrameNo() - hum->join_frameno <= 2) {
|
||||
msg->set_alive_count(room->AliveCount());
|
||||
msg->set_frameno(hum->room->GetFrameNo() / 2);
|
||||
if (hum->room->GetGasData().gas_mode == GasJump) {
|
||||
cs::MFPlane* p = msg->mutable_plane();
|
||||
TypeConvert::ToPb(hum->room->plane.start_point, p->mutable_start_point());
|
||||
TypeConvert::ToPb(hum->room->plane.end_point, p->mutable_end_point());
|
||||
TypeConvert::ToPb(hum->room->plane.curr_pos, p->mutable_pos());
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
{
|
||||
size_t chg_prop_size = framedata->chged_bullet_nums_.size() +
|
||||
framedata->chged_hps_.size() * 2 +
|
||||
framedata->chged_skillcds_.size() +
|
||||
framedata->chged_skill_curr_times_.size() +
|
||||
framedata->chged_items_.size() +
|
||||
framedata->chged_weapon_ammo_.size() +
|
||||
framedata->chged_cars_.size() +
|
||||
framedata->chged_props_.size();
|
||||
if (chg_prop_size > 0) {
|
||||
msg->mutable_chged_property_list()->Reserve(chg_prop_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FrameMaker::PostProcess(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
if (room->frame_event.airdrops_.size() > 0) {
|
||||
*msg->mutable_airdrop() = room->frame_event.airdrops_.Get(0);
|
||||
}
|
||||
if (room->frame_event.airraids_.size() > 0) {
|
||||
*msg->mutable_airraid() = room->frame_event.airraids_.Get(0);
|
||||
}
|
||||
if (room->GetGasData().gas_mode == GasMoving) {
|
||||
msg->set_gas_progress(room->GetGasData().gas_progress);
|
||||
TypeConvert::ToPb(room->GetGasData().pos_old, msg->mutable_gas_pos_old());
|
||||
}
|
||||
if (room->GetFrameNo() - room->AliveCountChgFrameNo() <= 4 ||
|
||||
room->GetFrameNo() - hum->join_frameno <= 2) {
|
||||
msg->set_alive_count(room->AliveCount());
|
||||
}
|
||||
}
|
||||
|
||||
void FrameMaker::SerializeNewObjects(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
if (!framedata->new_objects.empty()) {
|
||||
#ifdef DEBUG
|
||||
Debug_FullObject(hum);
|
||||
Debug_FullObject(hum);
|
||||
#endif
|
||||
for (auto& pair : framedata->new_objects) {
|
||||
Entity* e = pair.second.Get();
|
||||
if (!e) {
|
||||
continue;
|
||||
msg->mutable_full_objects()->Reserve(framedata->new_objects.size());
|
||||
if (framedata->new_objects.size() > PerfMonitor::Instance()->max_full_objects_num) {
|
||||
PerfMonitor::Instance()->max_full_objects_num = framedata->new_objects.size();
|
||||
}
|
||||
for (auto& pair : framedata->new_objects) {
|
||||
Entity* e = pair.second.Get();
|
||||
if (!e) {
|
||||
continue;
|
||||
}
|
||||
if (e != hum &&
|
||||
e->GetEntityType() == ET_Player &&
|
||||
((Human*)e)->HasBuffEffect(kBET_Fly)){
|
||||
continue;
|
||||
}
|
||||
if ((hum->IsPlayer() || hum->HasObserver()) && e->CanSeeMe(hum)) {
|
||||
e->FillMFObjectFull(room, (Human*)hum, msg->add_full_objects());
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (framedata->del_objects.find(e->GetUniId()) != framedata->del_objects.end()) {
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
if (e != hum &&
|
||||
e->GetEntityType() == ET_Player &&
|
||||
((Human*)e)->HasBuffEffect(kBET_Fly)){
|
||||
continue;
|
||||
}
|
||||
if ((hum->IsPlayer() || hum->HasObserver()) && e->CanSeeMe(hum)) {
|
||||
e->FillMFObjectFull(room, (Human*)hum, msg->add_full_objects());
|
||||
#ifdef DEBUG
|
||||
if (e->GetEntityType() == ET_Car) {
|
||||
hum->SendDebugMsg(a8::Format("载具出现", {}));
|
||||
if (App::Instance()->HasFlag(2) && e->GetEntityType() == ET_Player) {
|
||||
hum->room->BroadcastDebugMsg(a8::Format("投放 %d pos:%d,%d 出现",
|
||||
{
|
||||
e->GetUniId(),
|
||||
e->GetPos().x,
|
||||
e->GetPos().y,
|
||||
}));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (App::Instance()->HasFlag(2) && e->GetEntityType() == ET_Player) {
|
||||
hum->room->BroadcastDebugMsg(a8::Format("投放 %d pos:%d,%d 出现",
|
||||
{
|
||||
e->GetUniId(),
|
||||
e->GetPos().x,
|
||||
e->GetPos().y,
|
||||
}));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void FrameMaker::SerializePartObjects(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
int deleted_uniid = 0;
|
||||
for (auto& pair : framedata->part_objects) {
|
||||
Entity* entity = pair.second.object.Get();
|
||||
if (!entity) {
|
||||
#ifdef DEBUG
|
||||
abort();
|
||||
#endif
|
||||
deleted_uniid = pair.first;
|
||||
continue;
|
||||
if (!framedata->part_objects.empty()) {
|
||||
msg->mutable_part_objects()->Reserve(framedata->part_objects.size());
|
||||
if (framedata->part_objects.size() > PerfMonitor::Instance()->max_part_objects_num) {
|
||||
PerfMonitor::Instance()->max_part_objects_num = framedata->part_objects.size();
|
||||
}
|
||||
if (entity->IsDead(room) &&
|
||||
hum->room->GetFrameNo() - entity->GetDeadFrameNo(room) > 10) {
|
||||
continue;
|
||||
} else {
|
||||
if (room->GetGasData().gas_mode == GasJump &&
|
||||
entity != hum &&
|
||||
entity->GetEntityType() == ET_Player &&
|
||||
((Human*)entity)->HasBuffEffect(kBET_Fly)) {
|
||||
int deleted_uniid = 0;
|
||||
for (auto& pair : framedata->part_objects) {
|
||||
Entity* entity = pair.second.object.Get();
|
||||
if (!entity) {
|
||||
#ifdef DEBUG
|
||||
abort();
|
||||
#endif
|
||||
deleted_uniid = pair.first;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (entity->IsDead(room) &&
|
||||
hum->room->GetFrameNo() - entity->GetDeadFrameNo(room) > 10) {
|
||||
continue;
|
||||
} else {
|
||||
if (room->GetGasData().gas_mode == GasJump &&
|
||||
entity != hum &&
|
||||
entity->GetEntityType() == ET_Player &&
|
||||
((Human*)entity)->HasBuffEffect(kBET_Fly)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
if (((Human*)hum)->GetPos().ManhattanDistance(entity->GetPos()) > VIEW_RANGE + 300) {
|
||||
continue;
|
||||
}
|
||||
if (((Human*)hum)->GetPos().ManhattanDistance(entity->GetPos()) > VIEW_RANGE + 300) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
entity->FillMFObjectPart(room, (Human*)hum, msg->add_part_objects());
|
||||
}
|
||||
if (deleted_uniid > 0) {
|
||||
framedata->part_objects.erase(deleted_uniid);
|
||||
entity->FillMFObjectPart(room, (Human*)hum, msg->add_part_objects());
|
||||
}
|
||||
if (deleted_uniid > 0) {
|
||||
framedata->part_objects.erase(deleted_uniid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FrameMaker::SerializeDelObjects(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
for (auto& itr : framedata->del_objects) {
|
||||
msg->add_del_objids(itr);
|
||||
if (!framedata->del_objects.empty()) {
|
||||
msg->mutable_del_objids()->Reserve(framedata->del_objects.size());
|
||||
for (auto& itr : framedata->del_objects) {
|
||||
msg->add_del_objids(itr);
|
||||
#ifdef DEBUG
|
||||
if (App::Instance()->HasFlag(2)) {
|
||||
room->BroadcastDebugMsg(a8::Format("投放 删除对象%d",
|
||||
{
|
||||
itr
|
||||
}));
|
||||
}
|
||||
if (App::Instance()->HasFlag(2)) {
|
||||
room->BroadcastDebugMsg(a8::Format("投放 删除对象%d",
|
||||
{
|
||||
itr
|
||||
}));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FrameMaker::SerializeOutObjects(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
if (!framedata->out_objects.empty()) {
|
||||
msg->mutable_out_objids()->Reserve(framedata->out_objects.size());
|
||||
#ifdef DEBUG
|
||||
Debug_OutObject(hum);
|
||||
#endif
|
||||
for (auto& itr : framedata->out_objects) {
|
||||
msg->add_out_objids(itr);
|
||||
#ifdef DEBUG
|
||||
#ifdef DEBUG
|
||||
if (App::Instance()->HasFlag(2)) {
|
||||
room->BroadcastDebugMsg(a8::Format("投放 移除视野对象%d",
|
||||
{
|
||||
itr
|
||||
itr
|
||||
}));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FrameMaker::SerializeShots(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
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())) {
|
||||
*msg->add_shots() = std::get<1>(tuple);
|
||||
} else {
|
||||
if (!framedata->shots_.empty()) {
|
||||
msg->mutable_shots()->Reserve(framedata->shots_.size());
|
||||
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())) {
|
||||
*msg->add_shots() = std::get<1>(tuple);
|
||||
} else {
|
||||
#ifdef DEBUG1
|
||||
abort();
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -270,6 +303,7 @@ void FrameMaker::SerializeShots(cs::SMUpdate* msg, Room* room, Human* hum, Frame
|
||||
void FrameMaker::SerializeEmotes(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
for (size_t idx : framedata->emotes_) {
|
||||
msg->mutable_emotes()->Reserve(framedata->emotes_.size());
|
||||
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())) {
|
||||
@ -281,11 +315,17 @@ void FrameMaker::SerializeEmotes(cs::SMUpdate* msg, Room* room, Human* hum, Fram
|
||||
|
||||
void FrameMaker::SerializeBullets(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
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())) {
|
||||
*msg->add_bullets() = std::get<1>(tuple);
|
||||
if (!framedata->bullets_.empty()) {
|
||||
msg->mutable_bullets()->Reserve(framedata->bullets_.size());
|
||||
if (framedata->bullets_.size() > PerfMonitor::Instance()->max_bullet_num) {
|
||||
PerfMonitor::Instance()->max_bullet_num = framedata->bullets_.size();
|
||||
}
|
||||
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())) {
|
||||
*msg->add_bullets() = std::get<1>(tuple);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -294,6 +334,7 @@ void FrameMaker::SerializeBullets(cs::SMUpdate* msg, Room* room, Human* hum, Fra
|
||||
void FrameMaker::SerializeSmokes(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
for (size_t idx : framedata->smokes_) {
|
||||
msg->mutable_smokes()->Reserve(framedata->smokes_.size());
|
||||
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())) {
|
||||
@ -306,6 +347,7 @@ void FrameMaker::SerializeSmokes(cs::SMUpdate* msg, Room* room, Human* hum, Fram
|
||||
void FrameMaker::SerializePlaySkills(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
for (size_t idx : framedata->play_skills_) {
|
||||
msg->mutable_play_skill_list(framedata->play_skills_.size());
|
||||
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())) {
|
||||
@ -318,10 +360,11 @@ void FrameMaker::SerializePlaySkills(cs::SMUpdate* msg, Room* room, Human* hum,
|
||||
void FrameMaker::SerializeExplosions(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
for (size_t idx : framedata->explosions_) {
|
||||
msg->mutable_explosions()->Reserve(framedata->explosions_.size());
|
||||
if (idx < room->frame_event.explosions_.size()) {
|
||||
auto& tuple = room->frame_event.explosions_[idx];
|
||||
*msg->add_explosions() = std::get<1>(tuple);
|
||||
#ifdef DEBUG
|
||||
#ifdef DEBUG1
|
||||
a8::XPrintf("AddExplosion %d, %s pos=%d,%d effect:%d\n",
|
||||
{
|
||||
hum->GetUniId(),
|
||||
@ -337,24 +380,29 @@ void FrameMaker::SerializeExplosions(cs::SMUpdate* msg, Room* room, Human* hum,
|
||||
|
||||
void FrameMaker::SerializeChgedBuffs(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
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]);
|
||||
if (!framedata->chged_buffs_.empty()) {
|
||||
msg->mutable_chged_buff_list()->Reserve(framedata->chged_buffs_.size());
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FrameMaker::SerializeChgedBulletNums(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
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()) {
|
||||
auto p = msg->add_chged_property_list();
|
||||
p->set_obj_id(target.Get()->GetUniId());
|
||||
p->set_property_type(kPropBulletNum);
|
||||
p->set_value(target.Get()->GetCurrWeapon()->ammo);
|
||||
if (!framedata->chged_bullet_nums_.empty()) {
|
||||
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()) {
|
||||
auto p = msg->add_chged_property_list();
|
||||
p->set_obj_id(target.Get()->GetUniId());
|
||||
p->set_property_type(kPropBulletNum);
|
||||
p->set_value(target.Get()->GetCurrWeapon()->ammo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -385,18 +433,20 @@ void FrameMaker::SerializeChgedHps(cs::SMUpdate* msg, Room* room, Human* hum, Fr
|
||||
|
||||
void FrameMaker::SerializeChgedSkillCds(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
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);
|
||||
int skill_id = std::get<1>(tuple);
|
||||
int left_time = std::get<2>(tuple);
|
||||
if (target.Get()) {
|
||||
auto p = msg->add_chged_property_list();
|
||||
p->set_obj_id(target.Get()->GetUniId());
|
||||
p->set_property_type(kPropSkillLeftTime);
|
||||
p->set_property_subtype(skill_id);
|
||||
p->set_value(left_time);
|
||||
if (!framedata->chged_skillcds_.empty()) {
|
||||
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);
|
||||
int skill_id = std::get<1>(tuple);
|
||||
int left_time = std::get<2>(tuple);
|
||||
if (target.Get()) {
|
||||
auto p = msg->add_chged_property_list();
|
||||
p->set_obj_id(target.Get()->GetUniId());
|
||||
p->set_property_type(kPropSkillLeftTime);
|
||||
p->set_property_subtype(skill_id);
|
||||
p->set_value(left_time);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -455,12 +505,15 @@ void FrameMaker::SerializeChgedWeaponAmmo(cs::SMUpdate* msg, Room* room, Human*
|
||||
|
||||
void FrameMaker::SerializeDeadAliveObjs(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
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]));
|
||||
p->add_values(std::get<1>(room->frame_event.dead_alive_objs_[idx]));
|
||||
p->add_values(std::get<2>(room->frame_event.dead_alive_objs_[idx]));
|
||||
if (!framedata->dead_alive_objs_.empty()) {
|
||||
msg->mutable_dead_alive_objs()->Reserve(framedata->dead_alive_objs_.size());
|
||||
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]));
|
||||
p->add_values(std::get<1>(room->frame_event.dead_alive_objs_[idx]));
|
||||
p->add_values(std::get<2>(room->frame_event.dead_alive_objs_[idx]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -488,12 +541,15 @@ void FrameMaker::SerializeChgedCars(cs::SMUpdate* msg, Room* room, Human* hum, F
|
||||
|
||||
void FrameMaker::SerializeChgedProps(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
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);
|
||||
if (target.Get()) {
|
||||
*msg->add_chged_property_list() = std::get<1>(p);
|
||||
if (!framedata->chged_props_.empty()) {
|
||||
msg->mutable_chged_property_list()->Reserve(framedata->chged_props_.size());
|
||||
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);
|
||||
if (target.Get()) {
|
||||
*msg->add_chged_property_list() = std::get<1>(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -501,10 +557,13 @@ void FrameMaker::SerializeChgedProps(cs::SMUpdate* msg, Room* room, Human* hum,
|
||||
|
||||
void FrameMaker::SerializeDelBullets(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata)
|
||||
{
|
||||
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);
|
||||
if (!framedata->del_bullets_.empty()) {
|
||||
msg->mutable_del_bullets()->Reserve(framedata->del_bullets_.size());
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ private:
|
||||
void Debug_FullObject(Human* hum);
|
||||
void Debug_OutObject(Human* hum);
|
||||
|
||||
void PreProcess(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata);
|
||||
void PostProcess(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata);
|
||||
void SerializeNewObjects(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata);
|
||||
void SerializePartObjects(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata);
|
||||
void SerializeDelObjects(cs::SMUpdate* msg, Room* room, Human* hum, FrameData* framedata);
|
||||
|
@ -1278,6 +1278,10 @@ bool Human::HasObserver()
|
||||
|
||||
void Human::SendUpdateMsg()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
long long begin_tick1 = a8::XGetTickCount();
|
||||
long long end_tick1 = a8::XGetTickCount();
|
||||
#endif
|
||||
if (!follow_target_ && !a8::HasBitFlag(status, CS_Disable)) {
|
||||
#ifdef DEBUG
|
||||
long long begin_tick = a8::XGetTickCount();
|
||||
@ -1319,6 +1323,12 @@ void Human::SendUpdateMsg()
|
||||
} else {
|
||||
need_sync_active_player = false;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
end_tick1 = a8::XGetTickCount();
|
||||
if (end_tick1 - begin_tick1 > 100) {
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
framedata_.ClearFrameData(this);
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,9 @@ class Human : public Creature
|
||||
template <typename T>
|
||||
void SendNotifyMsg(T& msg)
|
||||
{
|
||||
GGListener::Instance()->SendToClient(socket_handle, 0, msg);
|
||||
if (socket_handle != 0) {
|
||||
GGListener::Instance()->SendToClient(socket_handle, 0, msg);
|
||||
}
|
||||
}
|
||||
void SendGameOver();
|
||||
void FollowTarget(Human* target);
|
||||
|
@ -20,6 +20,9 @@ class PerfMonitor : public a8::Singleton<PerfMonitor>
|
||||
std::array<long long, 30> params = {};
|
||||
std::array<int, 30> entity_num = {};
|
||||
std::array<int, RT_Max + 1> room_num = {};
|
||||
int max_full_objects_num = 0;
|
||||
int max_part_objects_num = 0;
|
||||
int max_bullet_num = 0;
|
||||
|
||||
void Init();
|
||||
void UnInit();
|
||||
|
@ -2323,12 +2323,14 @@ void Room::EnableHuman(Human* target)
|
||||
}
|
||||
#ifdef DEBUG
|
||||
CheckPartObjects();
|
||||
#if 0
|
||||
a8::UdpLog::Instance()->Debug("enablehuman %d %d",
|
||||
{
|
||||
(long long)target,
|
||||
target->GetUniId()
|
||||
});
|
||||
#endif
|
||||
#endif
|
||||
#if 0
|
||||
target->OnEnable();
|
||||
AddToMoveableHash(target);
|
||||
@ -2360,12 +2362,14 @@ void Room::DisableHuman(Human* target)
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
CheckPartObjects();
|
||||
#if 0
|
||||
a8::UdpLog::Instance()->Debug("disablehuman %d %d",
|
||||
{
|
||||
(long long)target,
|
||||
target->GetUniId()
|
||||
});
|
||||
#endif
|
||||
#endif
|
||||
if (!a8::HasBitFlag(target->status, CS_Disable)) {
|
||||
target->OnDisable();
|
||||
RemoveFromMoveableHash(target);
|
||||
@ -2796,6 +2800,7 @@ void Room::ShuaGridRound(Human* target)
|
||||
|
||||
void Room::CheckPartObjects(Human* testa, Human* testb)
|
||||
{
|
||||
#if 0
|
||||
for (auto& pair1 : human_hash_) {
|
||||
Human* a = pair1.second;
|
||||
for (auto& pair2 : human_hash_) {
|
||||
@ -2835,6 +2840,7 @@ void Room::CheckPartObjects(Human* testa, Human* testb)
|
||||
}
|
||||
});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Room::GetAliveHumans(std::vector<Human*>& alive_humans, size_t num, Human* exclude_hum)
|
||||
|
Loading…
x
Reference in New Issue
Block a user