191 lines
7.5 KiB
C++
191 lines
7.5 KiB
C++
#include "precompile.h"
|
|
|
|
#include "framemaker.h"
|
|
#include "human.h"
|
|
#include "room.h"
|
|
#include "typeconvert.h"
|
|
|
|
cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum)
|
|
{
|
|
cs::SMUpdate* msg = new cs::SMUpdate;
|
|
{
|
|
Room* room = hum->room;
|
|
for (auto& itr : hum->new_objects) {
|
|
#ifdef DEBUG
|
|
if (hum->del_objects.find(itr->GetEntityUniId()) != hum->del_objects.end()) {
|
|
abort();
|
|
}
|
|
#endif
|
|
itr->FillMFObjectFull(room, msg->add_full_objects());
|
|
}
|
|
for (auto& itr : hum->part_objects) {
|
|
Entity* entity = itr;
|
|
if (entity->IsDead(room) &&
|
|
hum->room->GetFrameNo() - entity->GetDeadFrameNo(room) > 10) {
|
|
continue;
|
|
} else {
|
|
}
|
|
entity->FillMFObjectPart(room, msg->add_part_objects());
|
|
}
|
|
for (auto& itr : hum->del_objects) {
|
|
msg->add_del_objids(itr);
|
|
}
|
|
for (auto& itr : hum->out_objects) {
|
|
msg->add_out_objids(itr);
|
|
}
|
|
for (size_t idx : hum->shots_) {
|
|
if (idx < room->frame_event.shots_.size()) {
|
|
auto& tuple = room->frame_event.shots_[idx];
|
|
if (hum->CanSee(std::get<0>(tuple))) {
|
|
*msg->add_shots() = std::get<1>(tuple);
|
|
} else {
|
|
#ifdef DEBUG1
|
|
abort();
|
|
#endif
|
|
}
|
|
} else {
|
|
#ifdef DEBUG
|
|
abort();
|
|
#endif
|
|
}
|
|
}
|
|
for (size_t idx : hum->bullets_) {
|
|
if (idx < room->frame_event.bullets_.size()) {
|
|
auto& tuple = room->frame_event.bullets_[idx];
|
|
if (hum->CanSee(std::get<0>(tuple))) {
|
|
*msg->add_bullets() = std::get<1>(tuple);
|
|
}
|
|
}
|
|
}
|
|
for (size_t idx : hum->explosions_) {
|
|
if (idx < room->frame_event.explosions_.size()) {
|
|
auto& tuple = room->frame_event.explosions_[idx];
|
|
if (hum->CanSee(std::get<0>(tuple))) {
|
|
*msg->add_explosions() = std::get<1>(tuple);
|
|
}
|
|
}
|
|
}
|
|
for (size_t idx : hum->smokes_) {
|
|
if (idx < room->frame_event.smokes_.size()) {
|
|
auto& tuple = room->frame_event.smokes_[idx];
|
|
if (hum->CanSee(std::get<0>(tuple))) {
|
|
*msg->add_smokes() = std::get<1>(tuple);
|
|
}
|
|
}
|
|
}
|
|
for (size_t idx : hum->emotes_) {
|
|
if (idx < room->frame_event.emotes_.size()) {
|
|
auto& tuple = room->frame_event.emotes_[idx];
|
|
if (hum->CanSee(std::get<0>(tuple))) {
|
|
*msg->add_emotes() = std::get<1>(tuple);
|
|
}
|
|
}
|
|
}
|
|
for (size_t idx : hum->chged_bullet_nums_) {
|
|
if (idx < room->frame_event.chged_bullet_nums_.size()) {
|
|
Human* target = room->frame_event.chged_bullet_nums_[idx];
|
|
if (target->curr_weapon) {
|
|
auto p = msg->add_chged_property_list();
|
|
p->set_obj_id(target->GetEntityUniId());
|
|
p->set_property_type(kPropBulletNum);
|
|
p->set_value(target->curr_weapon->ammo);
|
|
}
|
|
}
|
|
}
|
|
for (size_t idx : hum->chged_tank_bullet_nums_) {
|
|
if (idx < room->frame_event.chged_tank_bullet_nums_.size()) {
|
|
Human* target = room->frame_event.chged_tank_bullet_nums_[idx];
|
|
if (target->curr_weapon) {
|
|
auto p = msg->add_chged_property_list();
|
|
p->set_obj_id(target->GetEntityUniId());
|
|
p->set_property_type(kPropTankBulletNum);
|
|
p->set_value(target->tank_weapon.ammo);
|
|
}
|
|
}
|
|
}
|
|
for (size_t idx : hum->chged_tank_oil_max_) {
|
|
if (idx < room->frame_event.chged_tank_oil_max_.size()) {
|
|
Human* target = room->frame_event.chged_tank_oil_max_[idx];
|
|
auto p = msg->add_chged_property_list();
|
|
p->set_obj_id(target->GetEntityUniId());
|
|
p->set_property_type(kPropTankOil);
|
|
p->set_property_subtype(1);
|
|
p->set_value(target->tank_oil_max);
|
|
}
|
|
}
|
|
for (size_t idx : hum->chged_tank_oil_value_) {
|
|
if (idx < room->frame_event.chged_tank_oil_value_.size()) {
|
|
Human* target = room->frame_event.chged_tank_oil_value_[idx];
|
|
auto p = msg->add_chged_property_list();
|
|
p->set_obj_id(target->GetEntityUniId());
|
|
p->set_property_type(kPropTankOil);
|
|
p->set_property_subtype(0);
|
|
p->set_value(target->tank_oil_value);
|
|
}
|
|
}
|
|
for (size_t idx : hum->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_) {
|
|
if (idx < room->frame_event.chged_skillcds_.size()) {
|
|
Human* target = room->frame_event.chged_skillcds_[idx];
|
|
{
|
|
auto p = msg->add_chged_property_list();
|
|
p->set_obj_id(target->GetEntityUniId());
|
|
p->set_property_type(kPropSkillLeftTime);
|
|
p->set_value(target->GetSkillLeftTime());
|
|
}
|
|
{
|
|
auto p = msg->add_chged_property_list();
|
|
p->set_obj_id(target->GetEntityUniId());
|
|
p->set_property_type(kPropSkillCd);
|
|
p->set_value(target->GetSkillCd());
|
|
}
|
|
}
|
|
}
|
|
for (size_t idx : hum->chged_hps_) {
|
|
if (idx < room->frame_event.chged_hps_.size()) {
|
|
Human* target = room->frame_event.chged_hps_[idx];
|
|
if (hum->CanSee(target)) {
|
|
{
|
|
auto p = msg->add_chged_property_list();
|
|
p->set_obj_id(target->GetEntityUniId());
|
|
p->set_property_type(kPropHp);
|
|
p->set_value(target->GetHP());
|
|
}
|
|
{
|
|
auto p = msg->add_chged_property_list();
|
|
p->set_obj_id(target->GetEntityUniId());
|
|
p->set_property_type(kPropMaxHp);
|
|
p->set_value(target->GetMaxHP());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for (size_t idx : hum->chged_items_) {
|
|
if (idx < room->frame_event.chged_items_.size()) {
|
|
auto& tuple = room->frame_event.chged_items_[idx];
|
|
{
|
|
auto p = msg->add_chged_property_list();
|
|
p->set_obj_id((std::get<0>(tuple))->GetEntityUniId());
|
|
p->set_property_type(kPropItem);
|
|
p->set_property_subtype(std::get<1>(tuple));
|
|
p->set_value(std::get<2>(tuple));
|
|
}
|
|
}
|
|
}
|
|
if (room->frame_event.airdrops_.size() > 0) {
|
|
*msg->mutable_airdrop() = room->frame_event.airdrops_.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());
|
|
}
|
|
msg->set_alive_count(room->AliveCount());
|
|
}
|
|
return msg;
|
|
}
|