80 lines
2.8 KiB
C++
80 lines
2.8 KiB
C++
#include "precompile.h"
|
|
|
|
#include "framemaker.h"
|
|
#include "human.h"
|
|
#include "room.h"
|
|
|
|
cs::SMUpdate* FrameMaker::MakeUpdateMsg(const Human* hum)
|
|
{
|
|
cs::SMUpdate* msg = new cs::SMUpdate;
|
|
{
|
|
Room* room = hum->room;
|
|
if (room->gas_data.gas_mode == GasJump) {
|
|
cs::MFPlane* p = msg->mutable_plane();
|
|
room->plane.start_point.ToPB(p->mutable_start_point());
|
|
room->plane.end_point.ToPB(p->mutable_end_point());
|
|
}
|
|
for (auto& itr : hum->new_objects) {
|
|
itr->FillMFObjectFull(msg->add_full_objects());
|
|
}
|
|
for (auto& itr : hum->part_objects) {
|
|
itr->FillMFObjectPart(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 (int 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);
|
|
}
|
|
}
|
|
}
|
|
for (int 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 (int 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 (int 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 (int 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);
|
|
}
|
|
}
|
|
}
|
|
if (room->frame_event.airdrops_.size() > 0) {
|
|
*msg->mutable_airdrop() = room->frame_event.airdrops_.Get(0);
|
|
}
|
|
if (room->gas_data.gas_mode == GasMoving) {
|
|
msg->set_gas_progress(room->gas_data.gas_progress);
|
|
room->gas_data.pos_old.ToPB(msg->mutable_gas_pos_old());
|
|
}
|
|
msg->set_alive_count(room->AliveCount());
|
|
}
|
|
return msg;
|
|
}
|