framemaker ok
This commit is contained in:
parent
1e88baf74e
commit
71de446a33
@ -1,23 +1,11 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include "framemaker.h"
|
||||
#include "human.h"
|
||||
#include "room.h"
|
||||
|
||||
cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
{
|
||||
cs::SMUpdate* msg = new cs::SMUpdate;
|
||||
#if 0
|
||||
msg->Clear();
|
||||
{
|
||||
msg->set_ack(last_seq_id);
|
||||
#if 0
|
||||
#if 0
|
||||
{
|
||||
for (auto& pair : room->frame_data.deleted_objects_hash) {
|
||||
if (pair.first <= room->frame_no) {
|
||||
for (auto& itr : pair.second) {
|
||||
msg->add_del_objids(itr);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto& pair : room->frame_data.shots_hash) {
|
||||
if (pair.first <= room->frame_no) {
|
||||
for (auto& itr : pair.second) {
|
||||
@ -62,36 +50,45 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (team_members) {
|
||||
for (auto& itr : *team_members) {
|
||||
if (itr != this) {
|
||||
#endif
|
||||
|
||||
cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
{
|
||||
cs::SMUpdate* msg = new cs::SMUpdate;
|
||||
{
|
||||
if (hum->team_members) {
|
||||
for (auto& itr : *hum->team_members) {
|
||||
if (itr != hum) {
|
||||
itr->FillMFTeamData(msg->add_team_data());
|
||||
}
|
||||
}
|
||||
}
|
||||
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());
|
||||
}
|
||||
if (send_msg_times == 0) {
|
||||
room->FetchBuilding(this);
|
||||
if (hum->send_msg_times == 0) {
|
||||
room->FetchBuilding(hum);
|
||||
}
|
||||
for (auto& itr : new_objects) {
|
||||
for (auto& itr : hum->new_objects) {
|
||||
itr->FillMFObjectFull(msg->add_full_objects());
|
||||
}
|
||||
for (auto& itr : part_objects) {
|
||||
for (auto& itr : hum->part_objects) {
|
||||
itr->FillMFObjectPart(msg->add_part_objects());
|
||||
}
|
||||
if (send_msg_times == 0 || need_sync_active_player) {
|
||||
msg->set_active_player_id(entity_uniid);
|
||||
FillMFActivePlayerData(msg->mutable_active_player_data());
|
||||
need_sync_active_player = false;
|
||||
for (auto& itr : hum->del_objects) {
|
||||
msg->add_del_objids(itr);
|
||||
}
|
||||
if (send_msg_times == 0 || last_sync_gas_frameno < room->gas_data.gas_start_frameno) {
|
||||
last_sync_gas_frameno = room->gas_data.gas_start_frameno;
|
||||
FillMFGasData(msg->mutable_gas_data());
|
||||
if (hum->send_msg_times == 0 || hum->need_sync_active_player) {
|
||||
msg->set_active_player_id(hum->entity_uniid);
|
||||
hum->FillMFActivePlayerData(msg->mutable_active_player_data());
|
||||
hum->need_sync_active_player = false;
|
||||
}
|
||||
if (hum->send_msg_times == 0 || hum->last_sync_gas_frameno < room->gas_data.gas_start_frameno) {
|
||||
hum->last_sync_gas_frameno = room->gas_data.gas_start_frameno;
|
||||
hum->FillMFGasData(msg->mutable_gas_data());
|
||||
}
|
||||
if (room->gas_data.gas_mode == GasMoving) {
|
||||
msg->set_gas_progress(room->gas_data.gas_progress);
|
||||
@ -99,6 +96,6 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||
}
|
||||
msg->set_alive_count(room->AliveCount());
|
||||
}
|
||||
#endif
|
||||
++hum->send_msg_times;
|
||||
return msg;
|
||||
}
|
||||
|
@ -764,3 +764,75 @@ void Human::OnGridListChange(std::set<GridCell*>& old_grid_list,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Human::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
|
||||
{
|
||||
{
|
||||
player_data->set_action_type(action_type);
|
||||
if (action_type != AT_None) {
|
||||
int duration = std::max(0,
|
||||
action_duration -
|
||||
(int)((room->frame_no - action_frameno) * 1.0f / SERVER_FRAME_RATE) * 1000
|
||||
);
|
||||
player_data->set_action_item_id(action_item_id);
|
||||
player_data->set_action_duration(duration);
|
||||
player_data->set_action_target_id(action_target_id);
|
||||
}
|
||||
}
|
||||
player_data->set_skin(skin);
|
||||
player_data->set_backpack(backpack);
|
||||
player_data->set_helmet(helmet);
|
||||
player_data->set_chest(chest);
|
||||
player_data->set_health(health);
|
||||
player_data->set_max_health(GetMaxHP());
|
||||
player_data->set_cur_weapon_idx(curr_weapon->weapon_idx);
|
||||
player_data->set_cur_scope(curr_scope_idx);
|
||||
for (auto& weapon : weapons) {
|
||||
auto p = player_data->add_weapons();
|
||||
weapon.ToPB(p);
|
||||
}
|
||||
for (auto& num : inventory) {
|
||||
player_data->add_inventory(num);
|
||||
}
|
||||
if (pain_killer_timer) {
|
||||
int passed_time = (room->frame_no - pain_killer_frameno) * FRAME_RATE_MS;
|
||||
int left_time = std::max(0, pain_killer_lastingtime * 1000 - passed_time);
|
||||
int anodyne_max_time = MetaMgr::Instance()->GetSysParamAsInt("anodyne_max_time");
|
||||
left_time = std::min(left_time, anodyne_max_time * 1000);
|
||||
|
||||
cs::MFBodyState* p = player_data->add_states();
|
||||
p->set_state_type(1);
|
||||
p->set_left_time(left_time);
|
||||
p->set_lasting_time(anodyne_max_time * 1000);
|
||||
}
|
||||
player_data->set_energy_shield(energy_shield);
|
||||
#if 1
|
||||
{
|
||||
player_data->set_max_energy_shield(max_energy_shield);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Human::FillMFGasData(cs::MFGasData* gas_data)
|
||||
{
|
||||
gas_data->set_mode(room->gas_data.gas_mode);
|
||||
if (room->gas_data.gas_mode == GasInactive) {
|
||||
long long duration = MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE -
|
||||
(room->frame_no - room->gas_data.gas_start_frameno);
|
||||
gas_data->set_duration(std::max(duration * 50, (long long)1000) / 1000);
|
||||
} else if (room->gas_data.gas_mode == GasJump) {
|
||||
gas_data->set_duration(0);
|
||||
} else {
|
||||
if (room->gas_data.old_area_meta->i->wait_time() <= 0) {
|
||||
gas_data->set_duration(0);
|
||||
} else {
|
||||
long long duration = room->gas_data.old_area_meta->i->wait_time() * 20 -
|
||||
(room->frame_no - room->gas_data.gas_start_frameno);
|
||||
gas_data->set_duration(std::max(duration * 50, (long long)1000) / 1000);
|
||||
}
|
||||
}
|
||||
room->gas_data.pos_old.ToPB(gas_data->mutable_pos_old());
|
||||
room->gas_data.pos_new.ToPB(gas_data->mutable_pos_new());
|
||||
gas_data->set_rad_old(room->gas_data.rad_old);
|
||||
gas_data->set_rad_new(room->gas_data.rad_new);
|
||||
}
|
||||
|
@ -85,6 +85,7 @@ class Human : public Entity
|
||||
|
||||
long long jump_frameno = 0;
|
||||
|
||||
long long send_msg_times = 0;
|
||||
Human();
|
||||
virtual ~Human() override;
|
||||
virtual void Initialize() override;
|
||||
@ -125,7 +126,8 @@ class Human : public Entity
|
||||
std::set<GridCell*>& inc_grid_list,
|
||||
std::set<GridCell*>& dec_grid_list
|
||||
);
|
||||
|
||||
void FillMFActivePlayerData(cs::MFActivePlayerData* player_data);
|
||||
void FillMFGasData(cs::MFGasData* gas_data);
|
||||
protected:
|
||||
long long last_shot_frameno_ = 0;
|
||||
std::set<Entity*> new_objects;
|
||||
@ -134,5 +136,6 @@ protected:
|
||||
|
||||
private:
|
||||
CircleCollider* self_collider_ = nullptr;
|
||||
|
||||
long long last_sync_gas_frameno = 0;
|
||||
friend class FrameMaker;
|
||||
};
|
||||
|
@ -921,75 +921,3 @@ void Player::_CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg)
|
||||
.SetSender(¬ifymsg),
|
||||
send_func);
|
||||
}
|
||||
|
||||
void Player::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
|
||||
{
|
||||
{
|
||||
player_data->set_action_type(action_type);
|
||||
if (action_type != AT_None) {
|
||||
int duration = std::max(0,
|
||||
action_duration -
|
||||
(int)((room->frame_no - action_frameno) * 1.0f / SERVER_FRAME_RATE) * 1000
|
||||
);
|
||||
player_data->set_action_item_id(action_item_id);
|
||||
player_data->set_action_duration(duration);
|
||||
player_data->set_action_target_id(action_target_id);
|
||||
}
|
||||
}
|
||||
player_data->set_skin(skin);
|
||||
player_data->set_backpack(backpack);
|
||||
player_data->set_helmet(helmet);
|
||||
player_data->set_chest(chest);
|
||||
player_data->set_health(health);
|
||||
player_data->set_max_health(GetMaxHP());
|
||||
player_data->set_cur_weapon_idx(curr_weapon->weapon_idx);
|
||||
player_data->set_cur_scope(curr_scope_idx);
|
||||
for (auto& weapon : weapons) {
|
||||
auto p = player_data->add_weapons();
|
||||
weapon.ToPB(p);
|
||||
}
|
||||
for (auto& num : inventory) {
|
||||
player_data->add_inventory(num);
|
||||
}
|
||||
if (pain_killer_timer) {
|
||||
int passed_time = (room->frame_no - pain_killer_frameno) * FRAME_RATE_MS;
|
||||
int left_time = std::max(0, pain_killer_lastingtime * 1000 - passed_time);
|
||||
int anodyne_max_time = MetaMgr::Instance()->GetSysParamAsInt("anodyne_max_time");
|
||||
left_time = std::min(left_time, anodyne_max_time * 1000);
|
||||
|
||||
cs::MFBodyState* p = player_data->add_states();
|
||||
p->set_state_type(1);
|
||||
p->set_left_time(left_time);
|
||||
p->set_lasting_time(anodyne_max_time * 1000);
|
||||
}
|
||||
player_data->set_energy_shield(energy_shield);
|
||||
#if 1
|
||||
{
|
||||
player_data->set_max_energy_shield(max_energy_shield);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Player::FillMFGasData(cs::MFGasData* gas_data)
|
||||
{
|
||||
gas_data->set_mode(room->gas_data.gas_mode);
|
||||
if (room->gas_data.gas_mode == GasInactive) {
|
||||
long long duration = MetaMgr::Instance()->gas_inactive_time * SERVER_FRAME_RATE -
|
||||
(room->frame_no - room->gas_data.gas_start_frameno);
|
||||
gas_data->set_duration(std::max(duration * 50, (long long)1000) / 1000);
|
||||
} else if (room->gas_data.gas_mode == GasJump) {
|
||||
gas_data->set_duration(0);
|
||||
} else {
|
||||
if (room->gas_data.old_area_meta->i->wait_time() <= 0) {
|
||||
gas_data->set_duration(0);
|
||||
} else {
|
||||
long long duration = room->gas_data.old_area_meta->i->wait_time() * 20 -
|
||||
(room->frame_no - room->gas_data.gas_start_frameno);
|
||||
gas_data->set_duration(std::max(duration * 50, (long long)1000) / 1000);
|
||||
}
|
||||
}
|
||||
room->gas_data.pos_old.ToPB(gas_data->mutable_pos_old());
|
||||
room->gas_data.pos_new.ToPB(gas_data->mutable_pos_new());
|
||||
gas_data->set_rad_old(room->gas_data.rad_old);
|
||||
gas_data->set_rad_new(room->gas_data.rad_new);
|
||||
}
|
||||
|
@ -95,11 +95,6 @@ class Player : public Human
|
||||
void _CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg);
|
||||
void _CMEmote(f8::MsgHdr& hdr, const cs::CMEmote& msg);
|
||||
void _CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg);
|
||||
|
||||
void FillMFActivePlayerData(cs::MFActivePlayerData* player_data);
|
||||
void FillMFGasData(cs::MFGasData* gas_data);
|
||||
|
||||
private:
|
||||
int send_update_msg_times = 0;
|
||||
long long last_sync_gas_frameno = 0;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user