game2002/server/tools/protobuild/cs_proto.proto
aozhiwei 8ad57613b6 1
2019-07-30 12:12:30 +08:00

832 lines
23 KiB
Protocol Buffer
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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说明
packagelenunsigned 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的对应关系做到自动化判断
*/
//常量
enum Constant_e
{
ProtoVersion = 2019071501; //系统版本
}
//心跳
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
}
//int32元组
message MFTuple
{
repeated int32 values = 1; //values
}
//向量
message MFVec2
{
optional float x = 1; //x轴
optional float y = 2; //y轴
}
//属性变更
/*
property_type: 1 血量
property_type: 2 最大血量
property_type: 3 库存
property_subtype: 库存数组索引
property_type: 4 技能cd时间剩余时间
property_type: 5 技能cd时间总时间
*/
message MFPropertyChg
{
optional int32 obj_id = 1; //对象id
optional int32 property_type = 2; //属性类型
optional int32 property_subtype = 3; //属性子类型
optional float value = 4; //属性值
}
//地图物件
message MFMapObject
{
optional int32 object_id = 1; //物件id(mapThing表id)
optional MFVec2 pos = 2; //位置
}
//玩家信息
message MFPlayerInfo
{
optional int32 player_id = 1;
optional int32 team_id = 2;
optional string name = 3;
}
//武器
message MFWeapon
{
optional int32 weapon_id = 1; //武器id 当weapon_id == 0时表示无装备装备位置显示空
optional int32 weapon_lv = 2; //武器等级
optional int32 ammo = 4; //弹药数
}
//皮肤
message MFSkin
{
optional int32 skin_id = 1; //皮肤id
optional int32 skin_lv = 2; //皮肤等级
}
//玩家信息-部分
message MFPlayerPart
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
optional MFVec2 dir = 3; //朝向
optional float max_health = 5; //血量上限只有变化时才发没变化时为undefined
optional float health = 6; //血量只有变化时才发没变化时为undefined
}
//玩家信息-全量
message MFPlayerFull
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
optional MFVec2 dir = 3; //朝向
optional float max_health = 5; //血量
optional float health = 6; //血量
optional bool dead = 7; //是否已死亡
optional bool downed = 8; //是否跌倒
optional bool disconnected = 9; //是否断网
optional MFSkin skin = 13; //皮肤id
optional int32 backpack = 14; //背包
optional int32 helmet = 16; //头盔
optional int32 chest = 17; //防弹衣
optional MFWeapon weapon = 18; //武器
optional int32 energy_shield = 19; //能量护盾
optional int32 max_energy_shield = 22; //最大能量护盾
repeated MFBuff buff_list = 24; //buff列表
optional MFSkin tankskin = 25; //坦克皮肤
optional float shot_range = 26; //射程加成(添加到子弹)
}
//阻挡物-部分
message MFObstaclePart
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
optional float scale = 3; //缩放比
}
//阻挡物-全量
message MFObstacleFull
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
optional float scale = 3; //缩放比
optional int32 obstacle_id = 6; //阻挡物id
optional float health = 7; //血量
optional bool dead = 8; //是否已死亡
optional bool dead_at_thisframe = 9; //是否当前帧死亡(播放死亡特效)
optional bool is_door = 20; //是否门
//只有当is_door==ture时以下字段才有意义
//门状态定义: 0:关 1:开 当door_old_state != door_new_state时播动画开/关门)
optional int32 door_id = 22; //门id
optional int32 door_old_state = 23; //门前一个状态
optional int32 door_new_state = 24; //门当前状态
optional int32 door_house_uniid = 25; //门所属房间唯一id
optional int32 door_house_id = 26; //门所属房间id
optional float door_width = 27; //门宽度
optional float door_height = 28; //门高度
optional int32 door_open_times = 29; //门开启次数,每次开/关 ++times 0:客户端自动开
//如果是召唤出来的对象该字段才有意义表示召唤者id
//比如地雷,通过该字段控制地雷的可见性
optional int32 master_id = 30;
}
//建筑物-部分
message MFBuildingPart
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
}
//建筑物-全量
message MFBuildingFull
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
optional int32 building_id = 3; //建筑物id
optional bool ceiling_dead = 6;
}
//loot出生点-部分 补给箱
message MFLootSpawnerPart
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
optional int32 loot_id = 3; //id
}
//loot出生点-全量
message MFLootSpawnerFull
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
optional int32 loot_id = 3; //id
}
//loot-部分
message MFLootPart
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
}
//loot-全量
message MFLootFull
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
optional int32 item_id = 6;
optional int32 count = 7;
optional int32 age_ms = 8;
}
//尸体-部分
message MFDeadBodyPart
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
}
//尸体-全量
message MFDeadBodyFull
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
optional int32 player_id = 3; //玩家id
optional int32 inkjet = 6;
}
//decal-部分
message MFDecalPart
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
optional int32 decal_id = 3; //id
}
//decal-全量
message MFDecalFull
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
optional int32 decal_id = 3; //id
}
//发射体-部分
message MFProjectilePart
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
optional float pos_z = 3; //没用到
}
//发射体-全量
message MFProjectileFull
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
optional float pos_z = 3; //没用到
}
//英雄(分身)-部分
message MFHeroPart
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
optional MFVec2 dir = 3; //朝向
}
//英雄(分身)-全量
message MFHeroFull
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
optional MFVec2 dir = 3; //朝向
optional int32 masert_uniid = 4; //主人id
optional MFSkin skin = 13; //皮肤id
optional int32 backpack = 14; //背包
optional int32 helmet = 16; //头盔
optional int32 chest = 17; //防弹衣
optional MFWeapon weapon = 18; //武器
optional int32 energy_shield = 19; //能量护盾
}
//烟雾-部分
message MFSmokePart
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 pos = 2; //位置
optional float rad = 3; //半径
}
//烟雾-全量
message MFSmokeFull
{
optional int32 obj_uniid = 1; //唯一id
optional MFVec2 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 10:hero
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;
optional MFHeroPart union_obj_10 = 11;
}
//对象信息-全量
message MFObjectFull
{
//1:player 2:obstacle 3:building 4:lootspawner 5:loot 6:deadbody 7:decal 8:projectile 9:smoke 10:hero
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;
optional MFHeroFull union_obj_10 = 11;
}
//活跃玩家数据(当前)
message MFActivePlayerData
{
optional int32 action_type = 3; //0: none 1:reload 2:useitem 3:revive 4: rescue
optional int32 action_duration = 5; //持续时间毫秒
optional int32 action_item_id = 6;
optional int32 action_target_id = 7;
optional MFSkin skin = 30; //皮肤id
optional int32 backpack = 31; //背包
optional int32 helmet = 32; //头盔
optional int32 chest = 33; //防弹衣
optional float max_health = 34; //最大血量
optional float health = 35; //血量
optional int32 cur_scope = 10; //当前视野倍数 1 2 4 8 15
/*
0: 9mm
1: 556mm
2: 762mm
3: 12gauge
4: rpg火药榴弹炮
5: frag 手雷
6: smoke 烟雾弹
7: healthkit 医疗包
8: 止痛药
9:
10:
11:
12: 1xscope
13: 2xscope
14: 4xscope
15: 8xscope
16: 15xscope
*/
repeated int32 inventory = 11; //库存
optional int32 cur_weapon_idx = 15; //当前武器索引 0-4
repeated MFWeapon weapons = 16; //武器列表1-4 0拳头 1枪 2枪 3手雷 4烟雾弹
optional int32 energy_shield = 40; //能量护盾
optional int32 max_energy_shield = 41; //最大能量护盾
optional int32 spectator_count = 20;
optional int32 skill_left_time = 50; //技能cd时间(剩余时间)
optional int32 skill_cd_time = 51; //技能cd时间(总时间)
}
//毒圈数据
message MFGasData
{
/*
0: 进入战前准备
1: 开始战斗
*/
optional int32 mode = 1; //0:inactive 1:started
optional float duration = 2; //持续时间(秒)
optional MFVec2 pos_old = 3; //前一个圆心
optional MFVec2 pos_new = 4; //新圆心
optional float rad_old = 5; //前一个圆半径
optional float rad_new = 6; //新圆半径
}
//队伍数据
message MFTeamData
{
optional int32 player_id = 1; //玩家id
optional MFVec2 pos = 2; //位置
optional MFVec2 dir = 3; //方向
optional float health = 4; //血量
optional bool disconnected = 5; //是否短线
optional bool dead = 6; //是否死亡
optional bool downed = 7; //是否倒下
optional string name = 8; //名字
optional float max_health = 9; //最大血量
}
//子弹
message MFBullet
{
optional int32 player_id = 1; //玩家id
optional int32 bullet_id = 2; //子弹id
optional MFVec2 pos = 3; //位置
optional MFVec2 dir = 4; //方向
optional int32 gun_lv = 5; //枪等级
optional int32 bulletskin = 6; //子弹皮肤
//只有追踪类子弹以下两个字段才有意义
optional int32 bullet_uniid = 7; //子弹唯一id
optional int32 target_id = 8; //目标id
optional int32 hit_time = 9; //命中时间(毫秒)
optional int32 gun_id = 10; //枪id
optional float fly_distance = 11; //只有手雷和烟雾弹时这个字段才有意义
optional int32 skill_id = 12; //如果是技能触发的表示技能id普通射击为undefined or 0
}
//射击
message MFShot
{
optional int32 player_id = 1; //玩家id
optional MFWeapon weapon = 2; //武器id
optional bool offhand = 3;
optional int32 bullskin = 4;
}
//爆炸
message MFExplosion
{
optional int32 item_id = 1; //配置表id
optional MFVec2 pos = 2; //位置
optional int32 effect = 4 [default = 0]; //爆照效果 0普通爆照 1:核爆炸 2:跳跃技能爆炸效果
}
//烟雾
message MFSmoke
{
optional int32 item_id = 1; //配置表id
optional MFVec2 pos = 2; //位置
optional int32 player_id = 4; //玩家id
}
//表情
message MFEmote
{
optional int32 emote_id = 1; //表情id
optional int32 player_id = 3; //玩家id
optional string msg = 5;
}
//游戏结束时玩家统计信息
message MFPlayerStats
{
optional int32 rank = 1; //排名
optional int32 player_id = 2; //玩家id
optional string player_avatar_url = 3; //玩家头像
optional string account_id = 4; //账号id
optional int32 kills = 5; //击杀敌人数
optional int32 dead_times = 6; //死亡次数
optional int32 cup = 7; //奖杯
optional double gold = 9; //金币
repeated MFPair extra_drop = 12; //额外掉落,key:item_id value:数量(看广告)
}
//玩家战斗中统计
message MFPlayerBattlingStats
{
optional int32 player_id = 1; //玩家id
optional string name = 2; //玩家名可能为undefined
optional int32 kills = 3; //击杀数
/*
最后击杀时间序号(用于客户端排序, 击杀数相同时越小的排前面, 如果timeseq也相同则player_id小的排前面
*/
optional int32 last_kill_timeseq = 4;
}
//空投
message MFAirDrop
{
optional int32 appear_time = 1; //箱子出现时间(毫秒)
repeated MFVec2 pos_list = 3; //位置列表
}
//buff
message MFBuff
{
optional int32 buff_id = 1; //buff id
optional float left_time = 2; //剩余时间(单位毫秒)
optional float lasting_time = 3; //持续时间(总时间毫秒)
}
//buff变更
message MFBuffChg
{
optional int32 obj_id = 1; //对象id
optional int32 chg = 2; //0:新增/更新 1:删除
optional MFBuff buff = 3; //buff
}
//驾驶员
message MFDriver
{
optional int32 driver_id = 1; //驾驶员id
optional int32 driver_lv = 2; //驾驶员等级
}
//房间成员
message MFRoomMember
{
optional string account_id = 1; //账号id
optional string name = 3; //名字
optional string avatar_url = 4; //头像
optional MFSkin skin = 5; //皮肤id
optional MFSkin tankskin = 6; //坦克皮肤
}
//end mfmsg
//加入
message CMJoin
{
optional int32 server_id = 1; //serverid
optional string team_uuid = 2; //队伍唯一id (没组队时为空字符串)
optional string account_id = 3; //账号id account_id
optional string session_id = 4; //session_id
optional int32 proto_version = 5; //协议版本号Constant_e.ProtoVersion
optional int32 team_mode = 20; //队伍模式 0:单人 1:多人
optional bool auto_fill = 6; //是否自动填充玩家
optional int32 bot = 7; //是否机器人
optional string name = 8; //角色名
optional bool use_touch = 9; //zzz
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 MFWeapon weapon = 15; //武器
repeated MFWeapon weapons = 17; //武器列表
repeated MFSkin skins = 18; //皮肤列表 key: 皮肤id value:皮肤等级
repeated int32 prepare_items = 19; //战斗前准备道具 战前准备护盾存到energy_shield
optional string from_appid = 21; //from_appid
optional MFDriver driver = 22; //驾驶员
optional MFSkin tankskin = 23; //坦克皮肤
repeated int32 buff_list = 24; //周边系统带进来的战斗数据(护盾,立刻复活等)
repeated int32 test_params = 25; //测试参数 [0]:机器人坦克等级
repeated MFRoomMember room_member = 100; //房间成员(不包括自己)
}
//移动
message CMMove
{
optional int32 seq = 1; //序号
optional MFVec2 move_dir = 2; //移动-方向
optional MFVec2 attack_dir = 3; //攻击方向(朝向)
optional bool shot_start = 4; //射击-单发
optional bool shot_hold = 5; //射击-连发
optional int32 shot_target_id = 6; //射击目标
optional bool reload = 7; //装弹
optional float fly_distance = 8; //子弹飞行距离(只有手雷和烟雾弹时这个字段才有意义)
optional int32 select_weapon = 9; //切换武器(没切换是不用发)
optional int32 drop_weapon = 10; //丢弃武器
optional bool cancel_action = 11; //取消当前操作(比如取消使用道具装弹等)
optional int32 use_item_idx = 12; //使用道具对应库存索引0-16
optional int32 use_scope = 13; //使用倍镜 0-4
optional bool interaction = 14; //是否有交互
repeated int32 interaction_objids = 15; //交互的对象id列表
optional bool use_skill = 20; //使用技能
optional int32 skill_target_id = 21; //技能目标(单体攻击)
optional MFVec2 skill_dir = 22; //技能方向
optional float skill_param1 = 23; //辅助参数
optional bool spectate = 30; //自杀
optional int32 emote = 31; //表情id
}
//丢弃道具
message CMDropItem
{
optional int32 item_id = 1; //道具id
optional int32 weapon_idx = 2; //武器索引 0-4
}
//发送表情
message CMEmote
{
optional int32 type = 1;
optional MFVec2 pos = 2;
optional bool team_only = 4;
}
//语音
message CMVoice
{
optional string download_url = 2; //语音下载地址
}
//请求结算
message CMGameOver
{
}
//请求观战
message CMWatchWar
{
}
//离开 在飞机起飞前视为:逃跑 起飞后视为自杀
message CMLeave
{
}
//endcmmsg
//观战error_code == 0 时关闭结算界面,回到战斗界面
message SMWatchWar
{
optional int32 error_code = 1 [default = 0]; //错误码 0:成功 1:失败
optional string error_msg = 2; //错误信息
}
//加入成功
message SMJoinedNotify
{
optional int32 team_mode = 1; //队伍模式 0:单人 1:多人
optional int32 player_id = 2; //玩家id(自己)
optional bool started = 3; //游戏是否已开始
optional string room_uuid = 4; //房间唯一id
optional int32 map_type = 5; //目前没用到
optional bool elo_start = 6; //目前没用到
optional int32 error_code = 7; //错误 1:服务器维护中 2服务器繁忙请稍后再进入
}
//地图信息
message SMMapInfo
{
optional int32 map_id = 1; //地图id
optional int32 map_width = 2; //地图宽度
optional int32 map_height = 3; //地图高度
repeated MFMapObject objects = 6; //地图对象
}
//玩家信息
message SMPlayerInfo
{
optional MFPlayerInfo info = 1; //玩家信息
}
//帧事件
message SMUpdate
{
repeated int32 out_objids = 1; //对象-移出视野
repeated int32 del_objids = 2; //对象-待删除
repeated MFObjectFull full_objects = 3; //对象-全量(出现在视野)
repeated MFObjectPart part_objects = 4; //对象-部分(用于插值更新)
optional int32 active_player_id = 5; //当前活跃玩家id(如果玩家死亡后是观战对象的id)
optional MFActivePlayerData active_player_data = 6; //活跃玩家数据(如果玩家死亡后是观战对象的数据)
optional int32 game_left_time = 7; //游戏剩余时间(毫秒, 战斗开始后字段才有意义)
optional int32 gas_progress = 8; //毒圈进度,表示缩进的像素数(只有当gas_data.mode == moving时才会发进度)
optional MFVec2 gas_pos_old = 9; //毒圈当前圆心坐标
optional MFGasData gas_data = 10; //毒圈数据
repeated MFTeamData team_data = 11; //队伍数据
repeated MFBullet bullets = 12; //子弹
repeated MFShot shots = 13; //射击
repeated MFExplosion explosions = 14; //爆炸
repeated MFSmoke smokes = 15; //烟雾
repeated MFEmote emotes = 16; //表情
optional MFAirDrop airdrop = 17; //空投
repeated int32 revive_objids = 18; //复活的玩家
repeated MFTuple dead_objs = 19; //死亡的玩家values[0]:objid values[1]:多少毫秒后复活
repeated MFBuffChg chged_buff_list = 20; //buff变更列表
repeated MFPropertyChg chged_property_list = 21; //property变更列表
}
//滚动消息
message SMRollMsg
{
optional string msg = 6; //死者名字
}
//个人信息统计
message SMPlayerStats
{
optional MFPlayerStats player_stats = 1;
}
//游戏结束
message SMGameOver
{
optional int32 team_id = 1; //队伍id
optional int32 team_rank = 2; //队伍排名
optional int32 team_allcnt = 3;
optional bool game_over = 4; //是否结束
optional bool victory = 5; //是否胜利
repeated MFPlayerStats player_stats = 6; //玩家信息统计
optional string room_uuid = 7; //房间唯一id
}
//离开
message SMLeave
{
}
//断线通知
message SMDisconnectNotify
{
optional string reason = 1; //断线原因
}
//语音通知
message SMVoiceNotify
{
optional string account_id = 2; //唯一id
optional string download_url = 3; //语音下载地址
}
//调试信息
message SMDebugMsg
{
optional string debug_msg = 3; //调试信息
}
/*
微信实时语音房间
客户端需要调用loginserver签名后再加入微信实时语音房间
*/
message SMWxVoip
{
optional string group_id = 1; //微信语聊房间id
}
//ui界面更新一些不需要实时更新的数据
message SMUiUpdate
{
repeated MFPlayerBattlingStats player_stats = 1; //玩家战斗中统计信息
}