add type.cc
This commit is contained in:
parent
e8320d9c5e
commit
f1c2776777
@ -5,23 +5,63 @@
|
||||
#include "cs_proto.pb.h"
|
||||
#include "room.h"
|
||||
|
||||
const int F_del_objids = 2;
|
||||
const int F_full_objects = 3;
|
||||
const int F_part_objects = 4;
|
||||
const int F_active_player_id = 5;
|
||||
const int F_active_player_data = 6;
|
||||
const int F_alive_count = 15;
|
||||
const int F_gasT = 16;
|
||||
const int F_gas_data = 17;
|
||||
const int F_team_data = 18;
|
||||
const int F_teams = 19;
|
||||
const int F_bullets = 20;
|
||||
const int F_shots = 21;
|
||||
const int F_explosions = 22;
|
||||
const int F_emotes = 23;
|
||||
const int F_ack = 24;
|
||||
|
||||
void Player::Update(int delta_time)
|
||||
{
|
||||
if (updated_times % 2 == 0) {
|
||||
cs::SMUpdate msg;
|
||||
if (updated_times == 0) {
|
||||
msg.set_active_player_id(entity_uniid);
|
||||
{
|
||||
for (auto& itr : new_players) {
|
||||
itr->FillMFObjectFull(msg.add_full_objects());
|
||||
}
|
||||
for (auto& itr : part_players) {
|
||||
itr->FillMFObjectPart(msg.add_part_objects());
|
||||
}
|
||||
if (updated_times == 0) {
|
||||
msg.set_active_player_id(entity_uniid);
|
||||
FillMFPlayerData(msg.mutable_active_player_data());
|
||||
}
|
||||
msg.set_alive_count(room->AliveCount());
|
||||
|
||||
{
|
||||
int data_flags32 = 0;
|
||||
a8::SetBitFlag(data_flags32, 5);
|
||||
a8::SetBitFlag(data_flags32, 15);
|
||||
if (!new_players.empty()) {
|
||||
a8::SetBitFlag(data_flags32, F_full_objects);
|
||||
}
|
||||
if (!part_players.empty()) {
|
||||
a8::SetBitFlag(data_flags32, F_part_objects);
|
||||
}
|
||||
|
||||
if (updated_times == 0) {
|
||||
a8::SetBitFlag(data_flags32, F_active_player_id);
|
||||
a8::SetBitFlag(data_flags32, F_active_player_data);
|
||||
}
|
||||
a8::SetBitFlag(data_flags32, F_alive_count);
|
||||
|
||||
msg.set_data_flags32(data_flags32);
|
||||
}
|
||||
}
|
||||
SendNotifyMsg(msg);
|
||||
{
|
||||
if (!new_players.empty()) {
|
||||
new_players.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,3 +89,42 @@ void Player::_CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Player::FillMFPlayerData(cs::MFPlayerData* player_data)
|
||||
{
|
||||
player_data->set_has_action(false);
|
||||
}
|
||||
|
||||
void Player::FillMFObjectPart(cs::MFObjectPart* part_data)
|
||||
{
|
||||
part_data->set_object_type(ET_Player);
|
||||
cs::MFPlayerPart* p = part_data->mutable_union_obj_1();
|
||||
p->set_obj_uniid(entity_uniid);
|
||||
pos.ToPB(p->mutable_pos());
|
||||
dir.ToPB(p->mutable_dir());
|
||||
}
|
||||
|
||||
void Player::FillMFObjectFull(cs::MFObjectFull* full_data)
|
||||
{
|
||||
full_data->set_object_type(ET_Player);
|
||||
cs::MFPlayerFull* p = full_data->mutable_union_obj_1();
|
||||
p->set_obj_uniid(entity_uniid);
|
||||
pos.ToPB(p->mutable_pos());
|
||||
dir.ToPB(p->mutable_dir());
|
||||
|
||||
p->set_health(health);
|
||||
p->set_dead(dead);
|
||||
p->set_downed(downed);
|
||||
p->set_disconnected(disconnected);
|
||||
p->set_anim_type(anim_type);
|
||||
p->set_anim_seq(anim_seq);
|
||||
p->set_action_type(action_type);
|
||||
p->set_skin(skin);
|
||||
|
||||
p->set_helmet(helmet);
|
||||
p->set_chest(chest);
|
||||
p->set_weapon(weapon);
|
||||
p->set_energy_shield(energy_shield);
|
||||
p->set_vip(vip);
|
||||
p->set_sdmg(sdmg);
|
||||
}
|
||||
|
@ -10,6 +10,9 @@ namespace cs
|
||||
class CMEmote;
|
||||
class CMSpectate;
|
||||
class CMVoice;
|
||||
class MFPlayerData;
|
||||
class MFObjectPart;
|
||||
class MFObjectFull;
|
||||
}
|
||||
|
||||
class Room;
|
||||
@ -43,6 +46,10 @@ class Player : public Entity
|
||||
int energy_shield = 0;
|
||||
int vip = 0;
|
||||
int sdmg = 0;
|
||||
std::set<Player*> my_seen_players;
|
||||
std::set<Player*> seen_me_players;
|
||||
std::set<Player*> new_players;
|
||||
std::set<Player*> part_players;
|
||||
|
||||
template <typename T>
|
||||
void SendNotifyMsg(T& msg)
|
||||
@ -57,4 +64,8 @@ class Player : public Entity
|
||||
void _CMEmote(f8::MsgHdr& hdr, const cs::CMEmote& msg);
|
||||
void _CMSpectate(f8::MsgHdr& hdr, const cs::CMSpectate& msg);
|
||||
void _CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg);
|
||||
|
||||
void FillMFPlayerData(cs::MFPlayerData* player_data);
|
||||
void FillMFObjectPart(cs::MFObjectPart* part_data);
|
||||
void FillMFObjectFull(cs::MFObjectFull* full_data);
|
||||
};
|
||||
|
9
server/gameserver/types.cc
Normal file
9
server/gameserver/types.cc
Normal file
@ -0,0 +1,9 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include "cs_proto.pb.h"
|
||||
|
||||
void Vector2D::ToPB(cs::MFVector2D* pb_obj)
|
||||
{
|
||||
pb_obj->set_x(x);
|
||||
pb_obj->set_y(y);
|
||||
}
|
@ -9,8 +9,15 @@ struct PerfMonitor
|
||||
long long read_count = 0;
|
||||
};
|
||||
|
||||
namespace cs
|
||||
{
|
||||
class MFVector2D;
|
||||
}
|
||||
|
||||
struct Vector2D
|
||||
{
|
||||
float x = 0.0;
|
||||
float y = 0.0;
|
||||
|
||||
void ToPB(cs::MFVector2D* pb_obj);
|
||||
};
|
||||
|
@ -307,7 +307,7 @@ message MFSmokeFull
|
||||
message MFObjectPart
|
||||
{
|
||||
//1:player 2:obstacle 3:building 4:lootspawner 5:loot 6:deadbody 7:decal 8:projectile 9:smoke
|
||||
optional int32 type = 1;
|
||||
optional int32 object_type = 1;
|
||||
|
||||
optional MFPlayerPart union_obj_1 = 2;
|
||||
optional MFObstaclePart union_obj_2 = 3;
|
||||
@ -606,7 +606,7 @@ message SMUpdate
|
||||
repeated MFObjectPart part_objects = 4;
|
||||
optional int32 active_player_id = 5; //当前活跃玩家id
|
||||
optional MFPlayerData active_player_data = 6; //活跃玩家数据
|
||||
optional int32 alive_count = 15; //存活数量
|
||||
optional int32 alive_count = 15; //存活数量
|
||||
optional int32 gasT = 16;
|
||||
optional MFGasData gas_data = 17;
|
||||
repeated MFTeamData team_data = 18;
|
||||
|
Loading…
x
Reference in New Issue
Block a user