1
This commit is contained in:
parent
8ade050841
commit
936a2fdd41
@ -50,6 +50,13 @@ enum DoorState_e
|
||||
DoorStateOpen = 1
|
||||
};
|
||||
|
||||
enum GasMode_e
|
||||
{
|
||||
GasInactive = 0,
|
||||
GasWaiting = 1,
|
||||
GasMoving = 2
|
||||
};
|
||||
|
||||
const char* const PROJ_NAME_FMT = "game%d_gameserver";
|
||||
const char* const PROJ_ROOT_FMT = "/data/logs/%s";
|
||||
|
||||
@ -60,3 +67,5 @@ const int SYS_RESET_TIME = 2*60; //每日两点重置
|
||||
const int DEF_HELMET_ID = 12404;
|
||||
const int DEF_CHEST_ID = 12401;
|
||||
const int DEF_WEAPON_ID = 12103;
|
||||
|
||||
const int GAS_INACTIVE_TIME = 30;
|
||||
|
@ -192,3 +192,9 @@ MetaData::Drop* MetaMgr::GetDrop(int drop_id)
|
||||
auto itr = loader_->drop_hash.find(drop_id);
|
||||
return itr != loader_->drop_hash.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
||||
MetaData::SafeArea* MetaMgr::GetSafeArea(int area_id)
|
||||
{
|
||||
auto itr = loader_->safearea_hash.find(area_id);
|
||||
return itr != loader_->safearea_hash.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
||||
MetaData::Equip* GetEquip(int id);
|
||||
MetaData::Building* GetBuilding(int building_id);
|
||||
MetaData::Drop* GetDrop(int drop_id);
|
||||
MetaData::SafeArea* GetSafeArea(int area_id);
|
||||
|
||||
private:
|
||||
MetaDataLoader* loader_ = nullptr;
|
||||
|
@ -291,6 +291,27 @@ void Player::FillMFPlayerData(cs::MFActivePlayerData* player_data)
|
||||
player_data->set_has_action(false);
|
||||
}
|
||||
|
||||
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 = GAS_INACTIVE_TIME * 20 - (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.area_meta->i->wait_time() <= 0) {
|
||||
gas_data->set_duration(0);
|
||||
} else {
|
||||
long long duration = room->gas_data.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);
|
||||
}
|
||||
|
||||
void Player::MakeUpdateMsg()
|
||||
{
|
||||
update_msg->Clear();
|
||||
@ -327,6 +348,13 @@ void Player::MakeUpdateMsg()
|
||||
update_msg->set_active_player_id(entity_uniid);
|
||||
FillMFPlayerData(update_msg->mutable_active_player_data());
|
||||
}
|
||||
if (updated_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);
|
||||
}
|
||||
update_msg->set_alive_count(room->AliveCount());
|
||||
|
||||
{
|
||||
|
@ -11,6 +11,7 @@ namespace cs
|
||||
class CMSpectate;
|
||||
class CMVoice;
|
||||
class MFActivePlayerData;
|
||||
class MFGasData;
|
||||
}
|
||||
|
||||
class Room;
|
||||
@ -63,9 +64,11 @@ class Player : public Human
|
||||
void _CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg);
|
||||
|
||||
void FillMFPlayerData(cs::MFActivePlayerData* player_data);
|
||||
void FillMFGasData(cs::MFGasData* gas_data);
|
||||
|
||||
private:
|
||||
cs::SMUpdate* update_msg = nullptr;
|
||||
long long last_sync_gas_frameno = 0;
|
||||
|
||||
void MakeUpdateMsg();
|
||||
};
|
||||
|
@ -12,6 +12,7 @@ enum RoomState_e
|
||||
namespace MetaData
|
||||
{
|
||||
struct Map;
|
||||
struct SafeArea;
|
||||
}
|
||||
|
||||
struct RoomFrameData
|
||||
@ -34,6 +35,7 @@ public:
|
||||
MetaData::Map* map_meta = nullptr;
|
||||
RoomFrameData frame_data;
|
||||
long long frame_no = 0;
|
||||
GasData gas_data;
|
||||
|
||||
void Update(int delta_time);
|
||||
bool IsFull();
|
||||
|
@ -40,3 +40,20 @@ struct Vector2D
|
||||
static const Vector2D LEFT;
|
||||
static const Vector2D RIGHT;
|
||||
};
|
||||
|
||||
namespace MetaData
|
||||
{
|
||||
struct SafeArea;
|
||||
}
|
||||
|
||||
struct GasData
|
||||
{
|
||||
GasMode_e gas_mode = GasInactive;
|
||||
Vector2D pos_old;
|
||||
Vector2D pos_new;
|
||||
float rad_old = 0.0f;
|
||||
float rad_new = 0.0f;
|
||||
float gas_progress = 0.0f;
|
||||
long long gas_start_frameno = 0;
|
||||
MetaData::SafeArea* area_meta = nullptr;
|
||||
};
|
||||
|
@ -88,6 +88,7 @@ message MFVector2D
|
||||
optional float y = 2; //y轴
|
||||
}
|
||||
|
||||
//地图物件
|
||||
message MFMapObject
|
||||
{
|
||||
//type
|
||||
@ -96,6 +97,7 @@ message MFMapObject
|
||||
optional int32 scale = 3; //缩放比
|
||||
}
|
||||
|
||||
//玩家信息
|
||||
message MFPlayerInfo
|
||||
{
|
||||
optional int32 player_id = 1;
|
||||
@ -344,42 +346,66 @@ message MFActivePlayerData
|
||||
optional int32 action_item_id = 5;
|
||||
optional int32 action_target_id = 6;
|
||||
|
||||
optional int32 cur_scope = 10;
|
||||
repeated int32 inventory = 11;
|
||||
optional int32 cur_scope = 10; //当前视野倍数 1 2 4 8 15
|
||||
/*
|
||||
0: 9mm
|
||||
1: 762mm
|
||||
2: 556mm
|
||||
3: 12gauge
|
||||
4: frag 手雷
|
||||
5: smoke 烟雾弹
|
||||
6: bandage 绷带
|
||||
7: healthkit 医疗包
|
||||
8: soda 苏打
|
||||
9: painkiller 止痛药
|
||||
|
||||
optional int32 cur_weap_idx = 15;
|
||||
// repeated int32 weapons = 16;
|
||||
10: 1xscope
|
||||
11: 2xscope
|
||||
12: 4xscope
|
||||
13: 8xscope
|
||||
14: 15xscope
|
||||
*/
|
||||
repeated int32 inventory = 11; //库存
|
||||
|
||||
optional int32 cur_weap_idx = 15; //当前武器索引 0-3
|
||||
repeated int32 weapons = 16; //武器列表
|
||||
|
||||
optional int32 spectator_count = 20;
|
||||
}
|
||||
|
||||
//毒气数据
|
||||
//毒圈数据
|
||||
message MFGasData
|
||||
{
|
||||
optional int32 mode = 1; //0:inactive 1:waiting 2:moveing
|
||||
optional float duration = 2;
|
||||
optional MFVector2D pos_old = 3;
|
||||
optional MFVector2D pos_new = 4;
|
||||
optional float rad_old = 5;
|
||||
optional float rad_new = 6;
|
||||
/*
|
||||
0: 进入战前准备
|
||||
1: 辐射区将在多少时间后扩大
|
||||
2: 辐射区正在扩大
|
||||
*/
|
||||
optional int32 mode = 1; //0:inactive 1:waiting 2:moving
|
||||
optional float duration = 2; //持续时间(秒)
|
||||
optional MFVector2D pos_old = 3; //前一个圆心
|
||||
optional MFVector2D pos_new = 4; //新圆心
|
||||
optional float rad_old = 5; //前一个圆半径
|
||||
optional float rad_new = 6; //新圆半径
|
||||
}
|
||||
|
||||
//队伍数据
|
||||
message MFTeamData
|
||||
{
|
||||
optional int32 player_id = 1;
|
||||
optional MFVector2D pos = 2;
|
||||
optional MFVector2D dir = 3;
|
||||
optional float health = 4;
|
||||
optional bool disconnected = 5;
|
||||
optional bool dead = 6;
|
||||
optional bool downed = 7;
|
||||
optional int32 player_id = 1; //玩家id
|
||||
optional MFVector2D pos = 2; //位置
|
||||
optional MFVector2D dir = 3; //方向
|
||||
optional float health = 4; //血量
|
||||
optional bool disconnected = 5; //是否短线
|
||||
optional bool dead = 6; //是否死亡
|
||||
optional bool downed = 7; //是否倒下
|
||||
}
|
||||
|
||||
//同队队友数据
|
||||
message MFTeammateInfo
|
||||
{
|
||||
optional int32 team_id = 1;
|
||||
repeated int32 player_ids = 2;
|
||||
optional int32 team_id = 1; //队伍id
|
||||
repeated int32 player_ids = 2; //成员id列表
|
||||
}
|
||||
|
||||
//子弹
|
||||
@ -397,44 +423,47 @@ message MFBullet
|
||||
optional int32 gun_id = 10; //抢id
|
||||
}
|
||||
|
||||
//射击
|
||||
message MFShot
|
||||
{
|
||||
optional int32 player_id = 1;
|
||||
optional int32 weapon_id = 2;
|
||||
optional int32 player_id = 1; //玩家id
|
||||
optional int32 weapon_id = 2; //武器id
|
||||
optional bool offhand = 3;
|
||||
optional int32 bullskin = 4;
|
||||
}
|
||||
|
||||
//爆炸
|
||||
message MFExplosion
|
||||
{
|
||||
optional MFVector2D pos = 1;
|
||||
optional MFVector2D pos = 1; //位置
|
||||
optional int32 type = 2;
|
||||
}
|
||||
|
||||
//表情
|
||||
message MFEmote
|
||||
{
|
||||
optional int32 type = 1;
|
||||
optional int32 is_ping = 2;
|
||||
optional int32 player_id = 3;
|
||||
optional MFVector2D pos = 4;
|
||||
optional int32 player_id = 3; //玩家id
|
||||
optional MFVector2D pos = 4; //位置
|
||||
optional string msg = 5;
|
||||
}
|
||||
|
||||
//xx
|
||||
//游戏结束时玩家统计信息
|
||||
message MFPlayerStats
|
||||
{
|
||||
optional int32 player_id = 1;
|
||||
optional string player_avatar_url = 2;
|
||||
optional int32 time_alive = 3;
|
||||
optional int32 kills = 4;
|
||||
optional int32 dead = 5;
|
||||
optional int32 player_id = 1; //玩家id
|
||||
optional string player_avatar_url = 2; //玩家头像
|
||||
optional int32 time_alive = 3; //存活时间
|
||||
optional int32 kills = 4; //击杀敌人数
|
||||
optional int32 dead = 5; //是否已死亡
|
||||
optional int32 damage_type = 6;
|
||||
optional int32 source_type = 30;
|
||||
optional int32 killer_id = 7;
|
||||
optional int32 killer_id = 7; //杀手id(自杀时为自己)
|
||||
optional int32 damage_given = 8;
|
||||
optional int32 damage_taken = 9;
|
||||
optional int32 gold = 10;
|
||||
optional int32 all_score = 11;
|
||||
optional int32 gold = 10; //金币
|
||||
optional int32 all_score = 11; //所有积分
|
||||
optional int32 score_rank = 12;
|
||||
optional int32 score_kill = 13;
|
||||
optional int32 score_dmg_given = 14;
|
||||
@ -446,7 +475,7 @@ message MFPlayerStats
|
||||
optional int32 chg_elo = 19;
|
||||
|
||||
optional int32 heal_heath = 20;
|
||||
optional string account_id = 21;
|
||||
optional string account_id = 21; //账号id
|
||||
|
||||
repeated MFGoods annual_goods = 22;
|
||||
}
|
||||
@ -519,9 +548,7 @@ message CMEmote
|
||||
{
|
||||
optional int32 type = 1;
|
||||
optional MFVector2D pos = 2;
|
||||
//optional bool use_loadout = 3;
|
||||
optional bool team_only = 4;
|
||||
//optional bool is_ping = 5;
|
||||
}
|
||||
|
||||
//自杀
|
||||
@ -578,8 +605,8 @@ message SMUpdate
|
||||
optional int32 active_player_id = 5; //当前活跃玩家id(如果玩家死亡后是观战对象的id)
|
||||
optional MFActivePlayerData active_player_data = 6; //活跃玩家数据(如果玩家死亡后是观战对象的数据)
|
||||
optional int32 alive_count = 15; //存活数量
|
||||
optional int32 gasT = 16; //毒气
|
||||
optional MFGasData gas_data = 17; //毒气数据
|
||||
optional int32 gas_progress = 16; //毒圈进度
|
||||
optional MFGasData gas_data = 17; //毒圈数据
|
||||
repeated MFTeamData team_data = 18;
|
||||
repeated MFTeammateInfo teams = 19; //同队队友数据
|
||||
repeated MFBullet bullets = 20; //子弹
|
||||
@ -591,7 +618,7 @@ message SMUpdate
|
||||
optional uint32 data_flags32 = 256;
|
||||
}
|
||||
|
||||
//xx
|
||||
//击杀
|
||||
message SMKillMsg
|
||||
{
|
||||
optional int32 damage_type = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user