641 lines
16 KiB
Protocol Buffer
Executable File
641 lines
16 KiB
Protocol Buffer
Executable File
package cs;
|
||
|
||
/*
|
||
约定:
|
||
CM前缀:客户端发给服务器的消息(client message)
|
||
SM前缀:服务器发给客户的的消息(server message)
|
||
MF前缀:消息的内嵌字段,只能作为其他消息的内嵌字段不能send(message field)
|
||
_e后缀:枚举类型
|
||
_uniid后缀:唯一id
|
||
union_前缀:联合体
|
||
_前缀:该字段仅服务器使用客户端无需处理
|
||
|
||
网络包格式:msghead + msgbody
|
||
msghead: packagelen + msgid + seqid + magiccode + reserved = 2 + 2 + 4 + 2 + 2 = 12字节
|
||
msgbody: protobuf数据
|
||
msghead说明
|
||
packagelen(unsigned short): 双字节网络包长度,
|
||
msgid(unsigned short): 双字节消息id
|
||
seqid(unsigned int): 4字节序号id
|
||
magiccode(unsigned short): 2字节魔数,并且为固定常数KS,占位符客户端不需什么处理
|
||
reserved(unsigned short): 保留
|
||
|
||
十六进制位运算数据表示法
|
||
0x01 == 1<<0
|
||
0x02 == 1<<1
|
||
0x04 == 1<<2
|
||
|
||
data_flags字段的意义
|
||
由于protobuf的二义性无法描述repeated字段是否有值(非repeated的字段可以通过msg.xxx == null来a判断)
|
||
所以给协议添加了data_flags这样的字段用来描述字段是否有值
|
||
data_flags32:描述id 1-31的字段哪些是赋值
|
||
data_flags64: 描述id 31-63直接的字段是否赋值
|
||
data_flags128...... 以此类推
|
||
message MFRoleInfo
|
||
{
|
||
optional int32 role_id = 1;
|
||
optional int32 role_name = 2;
|
||
|
||
optional int32 role_level = 34;
|
||
|
||
optional uint32 data_flags32 = 256;
|
||
optional uint32 data_flags64 = 257;
|
||
}
|
||
role_id是否赋值 (data_flags32 & (1<<(1 - 1))) != 0
|
||
role_name是否赋值 (data_flags32 & (1<<(2 - 1))) != 0
|
||
role_level是否赋值 (data_flags64 & (1<<(34 - 33)) != 0
|
||
客户端可以根据protobuf反射得到字段名和字段id的对应关系做到自动化判断
|
||
*/
|
||
|
||
//心跳
|
||
message CMPing
|
||
{
|
||
}
|
||
message SMPing
|
||
{
|
||
optional int32 param1 = 1;
|
||
}
|
||
|
||
//rpc调用错误
|
||
message SMRpcError
|
||
{
|
||
optional int32 error_code = 1;
|
||
optional string error_msg = 2;
|
||
optional string debug_msg = 3;
|
||
optional string file = 4;
|
||
optional int32 lineno = 5;
|
||
optional int32 error_param = 6;
|
||
}
|
||
|
||
//int32键值对
|
||
message MFPair
|
||
{
|
||
optional int32 key = 1; //key
|
||
optional int32 value = 2; //val
|
||
}
|
||
|
||
//int64键值对
|
||
message MFPair64
|
||
{
|
||
optional int64 key = 1; //key
|
||
optional int64 value = 2; //val
|
||
}
|
||
|
||
//向量
|
||
message MFVector2D
|
||
{
|
||
optional float x = 1; //x轴
|
||
optional float y = 2; //y轴
|
||
}
|
||
|
||
message MFMapObject
|
||
{
|
||
//type
|
||
optional MFVector2D pos = 1; //位置
|
||
optional int32 ori = 2; //zzzzz
|
||
optional int32 scale = 3; //缩放比
|
||
}
|
||
|
||
message MFPlayerInfo
|
||
{
|
||
optional int32 player_id = 1;
|
||
optional int32 team_id = 2;
|
||
optional string name = 3;
|
||
}
|
||
|
||
message MFGoods
|
||
{
|
||
optional string name = 1;
|
||
optional int32 num = 2;
|
||
}
|
||
|
||
//视野 x1 x4 x8
|
||
message MFPlug
|
||
{
|
||
optional string name = 1;
|
||
optional int32 id = 2;
|
||
optional int32 param = 3;
|
||
}
|
||
|
||
//玩家信息-部分
|
||
message MFPlayerPart
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
optional MFVector2D dir = 3; //朝向
|
||
}
|
||
|
||
//玩家信息-全量
|
||
message MFPlayerFull
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
optional MFVector2D dir = 3; //朝向
|
||
|
||
optional float health = 6; //血量
|
||
optional bool dead = 7; //是否已死亡
|
||
optional bool downed = 8; //是否跌倒
|
||
optional bool disconnected = 9; //是否断网
|
||
optional int32 anim_type = 10; //
|
||
optional int32 anim_seq = 11; //
|
||
optional int32 action_type = 12; //0: none 1:reload 2:useitem 3:relive
|
||
optional int32 skin = 13; //皮肤id
|
||
//backpack
|
||
optional int32 helmet = 16; //头盔
|
||
optional int32 chest = 17; //防弹衣
|
||
optional int32 weapon = 18; //武器
|
||
optional int32 energy_shield = 19; //能量护盾
|
||
optional int32 vip = 20; //vip
|
||
optional int32 sdmg = 21;
|
||
}
|
||
|
||
//阻挡物-部分
|
||
message MFObstaclePart
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
optional float scale = 3; //缩放比
|
||
}
|
||
|
||
//阻挡物-全量
|
||
message MFObstacleFull
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
optional float scale = 3; //缩放比
|
||
|
||
optional int32 obstacle_id = 6; //阻挡物id
|
||
optional float health = 7; //血量
|
||
optional bool dead = 8; //是否已死亡
|
||
|
||
optional bool is_door = 9; //是否门
|
||
optional int32 door_relative_ori = 10; //
|
||
optional bool door_can_use = 11; //
|
||
optional int32 door_seq = 12;
|
||
|
||
optional bool is_button = 15;
|
||
optional bool button_onoff = 16;
|
||
optional bool button_can_use = 17;
|
||
optional int32 button_seq = 18;
|
||
}
|
||
|
||
//建筑物-部分
|
||
message MFBuildingPart
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
optional int32 building_id = 3; //建筑物id
|
||
optional int32 ori = 4; //
|
||
}
|
||
|
||
//建筑物-全量
|
||
message MFBuildingFull
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
optional int32 building_id = 3; //建筑物id
|
||
optional int32 ori = 4; //
|
||
|
||
optional bool ceiling_dead = 6;
|
||
}
|
||
|
||
//loot出生点-部分 补给箱
|
||
message MFLootSpawnerPart
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
optional int32 loot_id = 3; //id
|
||
}
|
||
|
||
//loot出生点-全量
|
||
message MFLootSpawnerFull
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
optional int32 loot_id = 3; //id
|
||
}
|
||
|
||
//loot-部分
|
||
message MFLootPart
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
}
|
||
|
||
//loot-全量
|
||
message MFLootFull
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
|
||
optional string name = 6;
|
||
optional int32 count = 7;
|
||
optional int32 age_ms = 8;
|
||
}
|
||
|
||
//尸体-部分
|
||
message MFDeadBodyPart
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
}
|
||
|
||
//尸体-全量
|
||
message MFDeadBodyFull
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
|
||
optional int32 inkjet = 6;
|
||
}
|
||
|
||
//decal-部分
|
||
message MFDecalPart
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
optional int32 decal_id = 3; //id
|
||
}
|
||
|
||
//decal-全量
|
||
message MFDecalFull
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
optional int32 decal_id = 3; //id
|
||
}
|
||
|
||
//发射体-部分
|
||
message MFProjectilePart
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
optional float pos_z = 3; //没用到
|
||
}
|
||
|
||
//发射体-全量
|
||
message MFProjectileFull
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
optional float pos_z = 3; //没用到
|
||
}
|
||
|
||
//烟雾-部分
|
||
message MFSmokePart
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
optional float rad = 3; //半径
|
||
}
|
||
|
||
//烟雾-全量
|
||
message MFSmokeFull
|
||
{
|
||
optional int32 obj_uniid = 1; //唯一id
|
||
optional MFVector2D pos = 2; //位置
|
||
optional float rad = 3; //半径
|
||
}
|
||
|
||
//对象信息-部分
|
||
message MFObjectPart
|
||
{
|
||
//1:player 2:obstacle 3:building 4:lootspawner 5:loot 6:deadbody 7:decal 8:projectile 9:smoke
|
||
optional int32 object_type = 1;
|
||
|
||
optional MFPlayerPart union_obj_1 = 2;
|
||
optional MFObstaclePart union_obj_2 = 3;
|
||
optional MFBuildingPart union_obj_3 = 4;
|
||
optional MFLootSpawnerPart union_obj_4 = 5;
|
||
optional MFLootPart union_obj_5 = 6;
|
||
optional MFDeadBodyPart union_obj_6 = 7;
|
||
optional MFDecalPart union_obj_7 = 8;
|
||
optional MFProjectilePart union_obj_8 = 9;
|
||
optional MFSmokePart union_obj_9 = 10;
|
||
}
|
||
|
||
//对象信息-部分
|
||
message MFObjectFull
|
||
{
|
||
//1:player 2:obstacle 3:building 4:lootspawner 5:loot 6:deadbody 7:decal 8:projectile 9:smoke
|
||
optional int32 object_type = 1;
|
||
|
||
optional MFPlayerFull union_obj_1 = 2;
|
||
optional MFObstacleFull union_obj_2 = 3;
|
||
optional MFBuildingFull union_obj_3 = 4;
|
||
optional MFLootSpawnerFull union_obj_4 = 5;
|
||
optional MFLootFull union_obj_5 = 6;
|
||
optional MFDeadBodyFull union_obj_6 = 7;
|
||
optional MFDecalFull union_obj_7 = 8;
|
||
optional MFProjectileFull union_obj_8 = 9;
|
||
optional MFSmokeFull union_obj_9 = 10;
|
||
}
|
||
|
||
//玩家数据
|
||
message MFPlayerData
|
||
{
|
||
optional float boost = 1;
|
||
|
||
//
|
||
optional bool has_action = 2;
|
||
optional float actoin_time = 3;
|
||
optional float action_duration = 4;
|
||
optional int32 action_item_id = 5;
|
||
optional int32 action_target_id = 6;
|
||
|
||
optional int32 cur_scope = 10;
|
||
repeated int32 inventory = 11;
|
||
|
||
optional int32 cur_weap_idx = 15;
|
||
// 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;
|
||
}
|
||
|
||
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;
|
||
}
|
||
|
||
message MFTeamInfo
|
||
{
|
||
optional int32 team_id = 1;
|
||
repeated int32 player_ids = 2;
|
||
}
|
||
|
||
message MFBullet
|
||
{
|
||
optional int32 player_id = 1; //玩家id
|
||
optional int32 bullet_id = 2; //子弹id
|
||
optional MFVector2D pos = 3; //位置
|
||
optional MFVector2D dir = 4; //方向
|
||
optional float variance_t = 5;
|
||
optional int32 bulletskin = 6; //子弹皮肤
|
||
optional bool crit = 7;
|
||
optional int32 reflect_count = 8;
|
||
optional int32 reflect_objid = 9;
|
||
}
|
||
|
||
message MFShot
|
||
{
|
||
optional int32 player_id = 1;
|
||
optional int32 weapon_id = 2;
|
||
optional bool offhand = 3;
|
||
optional int32 bullskin = 4;
|
||
}
|
||
|
||
message MFExplosion
|
||
{
|
||
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 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 damage_type = 6;
|
||
optional int32 source_type = 30;
|
||
optional int32 killer_id = 7;
|
||
optional int32 damage_given = 8;
|
||
optional int32 damage_taken = 9;
|
||
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;
|
||
optional int32 heal_cnt = 15;
|
||
optional int32 score_alivetm = 16;
|
||
|
||
optional int32 old_elo = 17;
|
||
optional int32 new_elo = 18;
|
||
optional int32 chg_elo = 19;
|
||
|
||
optional int32 heal_heath = 20;
|
||
optional string account_id = 21;
|
||
|
||
repeated MFGoods annual_goods = 22;
|
||
}
|
||
|
||
//end mfmsg
|
||
|
||
//加入
|
||
message CMJoin
|
||
{
|
||
optional int32 server_id = 1; //serverid
|
||
optional string team_uuid = 2; //队伍唯一id (没组队时为空字符串)
|
||
optional int32 team_mode = 3; //队伍模式 0:单人 1:多人
|
||
optional int32 player_count = 4; //玩家数(单人时为1)
|
||
optional bool auto_fill = 5; //是否自动填充玩家
|
||
optional int32 bot = 6; //是否机器人
|
||
optional string name = 7; //角色名
|
||
optional bool use_touch = 8; //zzz
|
||
optional string account_id = 9; //账号id account_id
|
||
repeated int32 emotes = 10; //表情列表
|
||
optional string avatar_url = 11; //头像
|
||
optional int32 energy_shield = 12; //能量护盾
|
||
optional int32 baseskin = 13; //皮肤id
|
||
optional int32 basemelee = 14; //xx
|
||
optional int32 elo_score = 15;
|
||
repeated MFPlug plugs = 16;
|
||
|
||
optional string gmode = 21;
|
||
}
|
||
|
||
//移动
|
||
message CMMove
|
||
{
|
||
optional int32 seq = 1; //序号
|
||
|
||
optional MFVector2D move_dir = 24; //移动-方向
|
||
optional MFVector2D attack_dir = 20; //攻击方向(朝向)
|
||
|
||
optional bool shot_start = 6; //射击-开始
|
||
optional bool shot_hold = 7; //射击-一直按着
|
||
optional bool reload = 8; //装弹
|
||
|
||
optional bool equip_primary = 10; //装备1
|
||
optional bool equip_secondary = 11; //装备2
|
||
optional bool equip_throwable = 12; //装备3
|
||
optional bool equip_melee = 13; //装备
|
||
optional bool equip_last = 14; //最后使用的装备
|
||
|
||
optional bool cancel_action = 15; //zz
|
||
//optional bool edit_mode = 16; //没用到
|
||
optional bool scroll_down = 17; //zzz
|
||
optional bool scroll_up = 18; //zz
|
||
optional bool portrait = 19; //zz
|
||
|
||
//use_item使用道具
|
||
//use_scope视野
|
||
|
||
optional bool interaction = 9; //是否有交互
|
||
optional int32 interaction_objid = 23; //交互的对象id
|
||
}
|
||
|
||
//丢弃道具
|
||
message CMDropItem
|
||
{
|
||
optional int32 item_id = 1;
|
||
optional int32 weapon_idx = 2;
|
||
}
|
||
|
||
//发送表情
|
||
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;
|
||
}
|
||
|
||
//自杀
|
||
message CMSpectate
|
||
{
|
||
optional int32 spec_next = 1;
|
||
optional int32 spec_prev = 2;
|
||
}
|
||
|
||
//语音
|
||
message CMVoice
|
||
{
|
||
optional int32 mode = 1; //模式
|
||
optional bytes msg = 2; //语音内容
|
||
}
|
||
|
||
//endcmmsg
|
||
|
||
//加入成功
|
||
message SMJoinedNotify
|
||
{
|
||
optional int32 team_mode = 1; //队伍模式 0:单人 1:多人
|
||
optional int32 player_id = 2; //玩家id(自己)
|
||
optional bool started = 3; //游戏是否已开始
|
||
repeated MFPlayerInfo player_infos = 4; //玩家信息
|
||
|
||
optional int32 map_type = 5; //目前没用到
|
||
optional bool elo_start = 6; //目前没用到
|
||
|
||
optional int32 error_code = 7; //错误
|
||
}
|
||
|
||
//地图信息
|
||
message SMMapInfo
|
||
{
|
||
optional int32 map_id = 1; //地图id
|
||
optional int32 width = 2; //地图宽度
|
||
optional int32 height = 3; //地图高度
|
||
repeated MFMapObject objects = 6; //地图对象
|
||
}
|
||
|
||
//玩家信息
|
||
message SMPlayerInfo
|
||
{
|
||
optional MFPlayerInfo info = 1; //玩家信息
|
||
}
|
||
|
||
//帧事件
|
||
message SMUpdate
|
||
{
|
||
repeated int32 del_objids = 2; //对象-待删除(移出视野)
|
||
repeated MFObjectFull full_objects = 3; //对象-全量(出现在视野)
|
||
repeated MFObjectPart part_objects = 4; //对象-部分(用于插值更新)
|
||
optional int32 active_player_id = 5; //当前活跃玩家id(如果玩家死亡后是观战对象的id)
|
||
optional MFPlayerData active_player_data = 6; //活跃玩家数据(如果玩家死亡后是观战对象的数据)
|
||
optional int32 alive_count = 15; //存活数量
|
||
optional int32 gasT = 16;
|
||
optional MFGasData gas_data = 17;
|
||
repeated MFTeamData team_data = 18;
|
||
repeated MFTeamInfo teams = 19;
|
||
repeated MFBullet bullets = 20; //子弹
|
||
repeated MFShot shots = 21; //射击
|
||
repeated MFExplosion explosions = 22; //爆炸
|
||
repeated MFEmote emotes = 23; //表情
|
||
optional int32 ack = 24;
|
||
|
||
optional uint32 data_flags32 = 256;
|
||
}
|
||
|
||
//xx
|
||
message SMKillMsg
|
||
{
|
||
optional int32 damage_type = 1;
|
||
//source_type
|
||
optional int32 target_id = 2;
|
||
optional int32 killer_id =3;
|
||
optional int32 kill_credit_id = 4;
|
||
optional int32 killer_kills = 5;
|
||
optional int32 downed = 6;
|
||
optional int32 killed =7;
|
||
}
|
||
|
||
//个人信息统计
|
||
message SMPlayerStats
|
||
{
|
||
optional MFPlayerStats player_stats = 1;
|
||
}
|
||
|
||
//游戏结束
|
||
message SMGameOver
|
||
{
|
||
optional int32 team_id = 1;
|
||
optional int32 team_rank = 2;
|
||
optional int32 team_allcnt = 3;
|
||
optional int32 game_over = 4;
|
||
optional int32 victory = 5;
|
||
|
||
repeated MFPlayerStats player_stats = 6;
|
||
}
|
||
|
||
//拾取
|
||
message SMPickup
|
||
{
|
||
optional int32 type = 1;
|
||
optional int32 item_id = 2;
|
||
optional int32 count = 3;
|
||
}
|
||
|
||
//断线通知
|
||
message SMDisconnectNotify
|
||
{
|
||
optional string reason = 1; //断线原因
|
||
}
|
||
|
||
//语音通知
|
||
message SMVoiceNotify
|
||
{
|
||
optional int32 mode = 1; //模式
|
||
optional string account_id = 2; //唯一id
|
||
optional bytes msg = 3; //语音内容
|
||
}
|