add framemaker.*
This commit is contained in:
parent
f4b39596ae
commit
e8b97dafee
103
server/gameserver/framemaker.cc
Normal file
103
server/gameserver/framemaker.cc
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
#include "precompile.h"
|
||||||
|
|
||||||
|
#include "framemaker.h"
|
||||||
|
|
||||||
|
cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
update_msg->Clear();
|
||||||
|
{
|
||||||
|
update_msg->set_ack(last_seq_id);
|
||||||
|
#if 0
|
||||||
|
{
|
||||||
|
for (auto& pair : room->frame_data.deleted_objects_hash) {
|
||||||
|
if (pair.first <= room->frame_no) {
|
||||||
|
for (auto& itr : pair.second) {
|
||||||
|
update_msg->add_del_objids(itr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto& pair : room->frame_data.shots_hash) {
|
||||||
|
if (pair.first <= room->frame_no) {
|
||||||
|
for (auto& itr : pair.second) {
|
||||||
|
*update_msg->add_shots() = itr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto& pair : room->frame_data.bullets_hash) {
|
||||||
|
if (pair.first <= room->frame_no) {
|
||||||
|
for (auto& itr : pair.second) {
|
||||||
|
*update_msg->add_bullets() = itr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto& pair : room->frame_data.explosions_hash) {
|
||||||
|
if (pair.first <= room->frame_no) {
|
||||||
|
for (auto& itr : pair.second) {
|
||||||
|
*update_msg->add_explosions() = itr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto& pair : room->frame_data.smokes_hash) {
|
||||||
|
if (pair.first <= room->frame_no) {
|
||||||
|
for (auto& itr : pair.second) {
|
||||||
|
*update_msg->add_smokes() = itr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto& pair : room->frame_data.emotes_hash) {
|
||||||
|
if (pair.first <= room->frame_no) {
|
||||||
|
for (auto& itr : pair.second) {
|
||||||
|
*update_msg->add_emotes() = itr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto& pair : room->frame_data.airdrops_hash) {
|
||||||
|
if (pair.first <= room->frame_no) {
|
||||||
|
for (auto& itr : pair.second) {
|
||||||
|
*update_msg->mutable_airdrop() = itr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (team_members) {
|
||||||
|
for (auto& itr : *team_members) {
|
||||||
|
if (itr != this) {
|
||||||
|
itr->FillMFTeamData(update_msg->add_team_data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (room->gas_data.gas_mode == GasJump) {
|
||||||
|
cs::MFPlane* p = update_msg->mutable_plane();
|
||||||
|
room->plane.start_point.ToPB(p->mutable_start_point());
|
||||||
|
room->plane.end_point.ToPB(p->mutable_end_point());
|
||||||
|
}
|
||||||
|
if (send_update_msg_times == 0) {
|
||||||
|
room->FetchBuilding(this);
|
||||||
|
}
|
||||||
|
for (auto& itr : new_objects) {
|
||||||
|
itr->FillMFObjectFull(update_msg->add_full_objects());
|
||||||
|
}
|
||||||
|
for (auto& itr : part_objects) {
|
||||||
|
itr->FillMFObjectPart(update_msg->add_part_objects());
|
||||||
|
}
|
||||||
|
if (send_update_msg_times == 0 || need_sync_active_player) {
|
||||||
|
update_msg->set_active_player_id(entity_uniid);
|
||||||
|
FillMFActivePlayerData(update_msg->mutable_active_player_data());
|
||||||
|
need_sync_active_player = false;
|
||||||
|
}
|
||||||
|
if (send_update_msg_times == 0 || last_sync_gas_frameno < room->gas_data.gas_start_frameno) {
|
||||||
|
last_sync_gas_frameno = room->gas_data.gas_start_frameno;
|
||||||
|
FillMFGasData(update_msg->mutable_gas_data());
|
||||||
|
}
|
||||||
|
if (room->gas_data.gas_mode == GasMoving) {
|
||||||
|
update_msg->set_gas_progress(room->gas_data.gas_progress);
|
||||||
|
room->gas_data.pos_old.ToPB(update_msg->mutable_gas_pos_old());
|
||||||
|
}
|
||||||
|
update_msg->set_alive_count(room->AliveCount());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return nullptr;
|
||||||
|
}
|
13
server/gameserver/framemaker.h
Normal file
13
server/gameserver/framemaker.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "cs_proto.pb.h"
|
||||||
|
|
||||||
|
class Human;
|
||||||
|
class Room;
|
||||||
|
class FrameMaker
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Room* room = nullptr;
|
||||||
|
|
||||||
|
cs::SMUpdate* MakeUpdateMsg(Human* hum);
|
||||||
|
};
|
@ -16,13 +16,10 @@ Player::Player()
|
|||||||
{
|
{
|
||||||
entity_type = ET_Player;
|
entity_type = ET_Player;
|
||||||
entity_subtype = EST_Player;
|
entity_subtype = EST_Player;
|
||||||
update_msg = new cs::SMUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player()
|
Player::~Player()
|
||||||
{
|
{
|
||||||
delete update_msg;
|
|
||||||
update_msg = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Initialize()
|
void Player::Initialize()
|
||||||
@ -719,8 +716,10 @@ void Player::HumanInteraction(Human* hum)
|
|||||||
|
|
||||||
void Player::SendUpdateMsg()
|
void Player::SendUpdateMsg()
|
||||||
{
|
{
|
||||||
MakeUpdateMsg();
|
cs::SMUpdate* msg = room->frame_maker.MakeUpdateMsg(this);
|
||||||
SendNotifyMsg(*update_msg);
|
if (msg) {
|
||||||
|
SendNotifyMsg(*msg);
|
||||||
|
}
|
||||||
if (send_gameover) {
|
if (send_gameover) {
|
||||||
UpdateGameOver();
|
UpdateGameOver();
|
||||||
}
|
}
|
||||||
@ -989,99 +988,3 @@ void Player::FillMFGasData(cs::MFGasData* gas_data)
|
|||||||
gas_data->set_rad_new(room->gas_data.rad_new);
|
gas_data->set_rad_new(room->gas_data.rad_new);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::MakeUpdateMsg()
|
|
||||||
{
|
|
||||||
update_msg->Clear();
|
|
||||||
{
|
|
||||||
update_msg->set_ack(last_seq_id);
|
|
||||||
#if 0
|
|
||||||
{
|
|
||||||
for (auto& pair : room->frame_data.deleted_objects_hash) {
|
|
||||||
if (pair.first <= room->frame_no) {
|
|
||||||
for (auto& itr : pair.second) {
|
|
||||||
update_msg->add_del_objids(itr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto& pair : room->frame_data.shots_hash) {
|
|
||||||
if (pair.first <= room->frame_no) {
|
|
||||||
for (auto& itr : pair.second) {
|
|
||||||
*update_msg->add_shots() = itr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto& pair : room->frame_data.bullets_hash) {
|
|
||||||
if (pair.first <= room->frame_no) {
|
|
||||||
for (auto& itr : pair.second) {
|
|
||||||
*update_msg->add_bullets() = itr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto& pair : room->frame_data.explosions_hash) {
|
|
||||||
if (pair.first <= room->frame_no) {
|
|
||||||
for (auto& itr : pair.second) {
|
|
||||||
*update_msg->add_explosions() = itr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto& pair : room->frame_data.smokes_hash) {
|
|
||||||
if (pair.first <= room->frame_no) {
|
|
||||||
for (auto& itr : pair.second) {
|
|
||||||
*update_msg->add_smokes() = itr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto& pair : room->frame_data.emotes_hash) {
|
|
||||||
if (pair.first <= room->frame_no) {
|
|
||||||
for (auto& itr : pair.second) {
|
|
||||||
*update_msg->add_emotes() = itr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto& pair : room->frame_data.airdrops_hash) {
|
|
||||||
if (pair.first <= room->frame_no) {
|
|
||||||
for (auto& itr : pair.second) {
|
|
||||||
*update_msg->mutable_airdrop() = itr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (team_members) {
|
|
||||||
for (auto& itr : *team_members) {
|
|
||||||
if (itr != this) {
|
|
||||||
itr->FillMFTeamData(update_msg->add_team_data());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (room->gas_data.gas_mode == GasJump) {
|
|
||||||
cs::MFPlane* p = update_msg->mutable_plane();
|
|
||||||
room->plane.start_point.ToPB(p->mutable_start_point());
|
|
||||||
room->plane.end_point.ToPB(p->mutable_end_point());
|
|
||||||
}
|
|
||||||
if (send_update_msg_times == 0) {
|
|
||||||
room->FetchBuilding(this);
|
|
||||||
}
|
|
||||||
for (auto& itr : new_objects) {
|
|
||||||
itr->FillMFObjectFull(update_msg->add_full_objects());
|
|
||||||
}
|
|
||||||
for (auto& itr : part_objects) {
|
|
||||||
itr->FillMFObjectPart(update_msg->add_part_objects());
|
|
||||||
}
|
|
||||||
if (send_update_msg_times == 0 || need_sync_active_player) {
|
|
||||||
update_msg->set_active_player_id(entity_uniid);
|
|
||||||
FillMFActivePlayerData(update_msg->mutable_active_player_data());
|
|
||||||
need_sync_active_player = false;
|
|
||||||
}
|
|
||||||
if (send_update_msg_times == 0 || last_sync_gas_frameno < room->gas_data.gas_start_frameno) {
|
|
||||||
last_sync_gas_frameno = room->gas_data.gas_start_frameno;
|
|
||||||
FillMFGasData(update_msg->mutable_gas_data());
|
|
||||||
}
|
|
||||||
if (room->gas_data.gas_mode == GasMoving) {
|
|
||||||
update_msg->set_gas_progress(room->gas_data.gas_progress);
|
|
||||||
room->gas_data.pos_old.ToPB(update_msg->mutable_gas_pos_old());
|
|
||||||
}
|
|
||||||
update_msg->set_alive_count(room->AliveCount());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -101,7 +101,5 @@ class Player : public Human
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int send_update_msg_times = 0;
|
int send_update_msg_times = 0;
|
||||||
cs::SMUpdate* update_msg = nullptr;
|
|
||||||
long long last_sync_gas_frameno = 0;
|
long long last_sync_gas_frameno = 0;
|
||||||
void MakeUpdateMsg();
|
|
||||||
};
|
};
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <a8/timer_attacher.h>
|
#include <a8/timer_attacher.h>
|
||||||
|
|
||||||
#include "frameevent.h"
|
#include "frameevent.h"
|
||||||
|
#include "framemaker.h"
|
||||||
|
|
||||||
namespace MetaData
|
namespace MetaData
|
||||||
{
|
{
|
||||||
@ -30,6 +31,7 @@ public:
|
|||||||
long long room_uuid = 0;
|
long long room_uuid = 0;
|
||||||
MetaData::Map* map_meta = nullptr;
|
MetaData::Map* map_meta = nullptr;
|
||||||
FrameEvent frame_event;
|
FrameEvent frame_event;
|
||||||
|
FrameMaker frame_maker;
|
||||||
long long frame_no = 0;
|
long long frame_no = 0;
|
||||||
GasData gas_data;
|
GasData gas_data;
|
||||||
bool game_over = false;
|
bool game_over = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user