Merge branch 'master' of git.kingsome.cn:server/game2006go
This commit is contained in:
commit
e32452b60b
@ -47,6 +47,7 @@ type MsgHandler interface {
|
|||||||
CMStartGame(*f5.MsgHdr, *CMStartGame)
|
CMStartGame(*f5.MsgHdr, *CMStartGame)
|
||||||
CMSetPrepare(*f5.MsgHdr, *CMSetPrepare)
|
CMSetPrepare(*f5.MsgHdr, *CMSetPrepare)
|
||||||
CMKickout(*f5.MsgHdr, *CMKickout)
|
CMKickout(*f5.MsgHdr, *CMKickout)
|
||||||
|
CMCloseNotify(*f5.MsgHdr, *CMCloseNotify)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *MsgHandlerImpl) CMPing(hdr *f5.MsgHdr, msg *CMPing) {
|
func (this *MsgHandlerImpl) CMPing(hdr *f5.MsgHdr, msg *CMPing) {
|
||||||
@ -85,6 +86,9 @@ func (this *MsgHandlerImpl) CMSetPrepare(hdr *f5.MsgHdr, msg *CMSetPrepare) {
|
|||||||
func (this *MsgHandlerImpl) CMKickout(hdr *f5.MsgHdr, msg *CMKickout) {
|
func (this *MsgHandlerImpl) CMKickout(hdr *f5.MsgHdr, msg *CMKickout) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *MsgHandlerImpl) CMCloseNotify(hdr *f5.MsgHdr, msg *CMCloseNotify) {
|
||||||
|
}
|
||||||
|
|
||||||
func (this *CMPing) GetNetMsgId() uint16 {
|
func (this *CMPing) GetNetMsgId() uint16 {
|
||||||
return uint16(CMMessageIdE__CMPing)
|
return uint16(CMMessageIdE__CMPing)
|
||||||
}
|
}
|
||||||
@ -177,6 +181,10 @@ func (this *CMKickout) GetNetMsgId() uint16 {
|
|||||||
return uint16(CMMessageIdE__CMKickout)
|
return uint16(CMMessageIdE__CMKickout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *CMCloseNotify) GetNetMsgId() uint16 {
|
||||||
|
return uint16(CMMessageIdE__CMCloseNotify)
|
||||||
|
}
|
||||||
|
|
||||||
func (this *SMRoomMemberChangeNotify) GetNetMsgId() uint16 {
|
func (this *SMRoomMemberChangeNotify) GetNetMsgId() uint16 {
|
||||||
return uint16(SMMessageIdE__SMRoomMemberChangeNotify)
|
return uint16(SMMessageIdE__SMRoomMemberChangeNotify)
|
||||||
}
|
}
|
||||||
@ -197,6 +205,10 @@ func (this *SMRoomChangeNotify) GetNetMsgId() uint16 {
|
|||||||
return uint16(SMMessageIdE__SMRoomChangeNotify)
|
return uint16(SMMessageIdE__SMRoomChangeNotify)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *SMRoomGameStartNotify) GetNetMsgId() uint16 {
|
||||||
|
return uint16(SMMessageIdE__SMRoomGameStartNotify)
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
||||||
handlers[int(CMMessageIdE__CMPing)] = &CsNetMsgHandler{
|
handlers[int(CMMessageIdE__CMPing)] = &CsNetMsgHandler{
|
||||||
@ -343,4 +355,16 @@ func init() {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlers[int(CMMessageIdE__CMCloseNotify)] = &CsNetMsgHandler{
|
||||||
|
MsgId: int(CMMessageIdE__CMCloseNotify),
|
||||||
|
ParseCb: func (data []byte) interface{} {
|
||||||
|
msg := &CMCloseNotify{}
|
||||||
|
proto.Unmarshal(data, msg)
|
||||||
|
return msg
|
||||||
|
},
|
||||||
|
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
|
||||||
|
handler.CMCloseNotify(hdr, hdr.Msg.(*CMCloseNotify))
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -28,6 +28,7 @@ func (this *HandlerMgr) Init() {
|
|||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMStartGame), constant.ROOM_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMStartGame), constant.ROOM_HANDLER_ID)
|
||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetPrepare), constant.ROOM_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMSetPrepare), constant.ROOM_HANDLER_ID)
|
||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMKickout), constant.ROOM_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMKickout), constant.ROOM_HANDLER_ID)
|
||||||
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMCloseNotify), constant.ROOM_HANDLER_ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *HandlerMgr) UnInit() {
|
func (this *HandlerMgr) UnInit() {
|
||||||
|
@ -18,6 +18,9 @@ func (this *Config) Init1() {
|
|||||||
if this.GetAutoStartTime() < 30 {
|
if this.GetAutoStartTime() < 30 {
|
||||||
panic("config.auto_start_time config error")
|
panic("config.auto_start_time config error")
|
||||||
}
|
}
|
||||||
|
if this.GetGameStartNotifyTime() < 3 || this.GetGameStartNotifyTime() > 35 {
|
||||||
|
panic("config.game_start_notify_time config error")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ConfigTable) PostInit1() {
|
func (this *ConfigTable) PostInit1() {
|
||||||
|
@ -47,6 +47,7 @@ type FriendDb struct {
|
|||||||
type Config struct {
|
type Config struct {
|
||||||
gameapi_url string
|
gameapi_url string
|
||||||
auto_start_time int32
|
auto_start_time int32
|
||||||
|
game_start_notify_time int32
|
||||||
|
|
||||||
_flags1_ uint64
|
_flags1_ uint64
|
||||||
_flags2_ uint64
|
_flags2_ uint64
|
||||||
@ -196,6 +197,14 @@ func (this *Config) HasAutoStartTime() bool {
|
|||||||
return (this._flags1_ & (uint64(1) << 2)) > 0
|
return (this._flags1_ & (uint64(1) << 2)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *Config) GetGameStartNotifyTime() int32 {
|
||||||
|
return this.game_start_notify_time
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Config) HasGameStartNotifyTime() bool {
|
||||||
|
return (this._flags1_ & (uint64(1) << 3)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func (this *HallCluster) LoadFromKv(kv map[string]interface{}) {
|
func (this *HallCluster) LoadFromKv(kv map[string]interface{}) {
|
||||||
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
|
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
|
||||||
@ -228,4 +237,5 @@ func (this *FriendDb) LoadFromKv(kv map[string]interface{}) {
|
|||||||
func (this *Config) LoadFromKv(kv map[string]interface{}) {
|
func (this *Config) LoadFromKv(kv map[string]interface{}) {
|
||||||
f5.ReadMetaTableField(&this.gameapi_url, "gameapi_url", &this._flags1_, 1, kv)
|
f5.ReadMetaTableField(&this.gameapi_url, "gameapi_url", &this._flags1_, 1, kv)
|
||||||
f5.ReadMetaTableField(&this.auto_start_time, "auto_start_time", &this._flags1_, 2, kv)
|
f5.ReadMetaTableField(&this.auto_start_time, "auto_start_time", &this._flags1_, 2, kv)
|
||||||
|
f5.ReadMetaTableField(&this.game_start_notify_time, "game_start_notify_time", &this._flags1_, 3, kv)
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,9 @@ func (this *player) GetAccountId() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *player) SendMsg(rspMsg proto.Message) {
|
func (this *player) SendMsg(rspMsg proto.Message) {
|
||||||
GetWspListener().SendProxyMsg(this.socket.Conn, this.socket.SocketHandle, rspMsg)
|
if this.socket.IsValid() {
|
||||||
|
GetWspListener().SendProxyMsg(this.socket.Conn, this.socket.SocketHandle, rspMsg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *player) GetRoom() common.Room {
|
func (this *player) GetRoom() common.Room {
|
||||||
@ -50,7 +52,6 @@ func (this *player) GetName() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (this *player) GetAvatarUrl() string {
|
func (this *player) GetAvatarUrl() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ syntax = "proto2";
|
|||||||
package cs;
|
package cs;
|
||||||
option go_package = ".;cs";
|
option go_package = ".;cs";
|
||||||
|
|
||||||
//消息id定义
|
|
||||||
enum CMMessageId_e
|
enum CMMessageId_e
|
||||||
{
|
{
|
||||||
_CMPing = 101;
|
_CMPing = 101;
|
||||||
@ -18,6 +17,7 @@ enum CMMessageId_e
|
|||||||
_CMStartGame = 111;
|
_CMStartGame = 111;
|
||||||
_CMSetPrepare = 112;
|
_CMSetPrepare = 112;
|
||||||
_CMKickout = 113;
|
_CMKickout = 113;
|
||||||
|
_CMCloseNotify = 114;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum SMMessageId_e
|
enum SMMessageId_e
|
||||||
@ -42,4 +42,5 @@ enum SMMessageId_e
|
|||||||
_SMRoomLeaveNotify = 1003;
|
_SMRoomLeaveNotify = 1003;
|
||||||
_SMRoomDisbandNotify = 1004;
|
_SMRoomDisbandNotify = 1004;
|
||||||
_SMRoomChangeNotify = 1005;
|
_SMRoomChangeNotify = 1005;
|
||||||
|
_SMRoomGameStartNotify = 1006;
|
||||||
}
|
}
|
||||||
|
@ -271,6 +271,12 @@ message CMKickout
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//关闭通知
|
||||||
|
message CMCloseNotify
|
||||||
|
{
|
||||||
|
optional int32 param = 1; //1:关闭SMRoomGameStartNotify
|
||||||
|
}
|
||||||
|
|
||||||
//房间成员信息变更通知
|
//房间成员信息变更通知
|
||||||
message SMRoomMemberChangeNotify
|
message SMRoomMemberChangeNotify
|
||||||
{
|
{
|
||||||
@ -281,6 +287,7 @@ message SMRoomMemberChangeNotify
|
|||||||
message SMRoomKickoutNotify
|
message SMRoomKickoutNotify
|
||||||
{
|
{
|
||||||
repeated string account_ids = 1; //成员account_id列表
|
repeated string account_ids = 1; //成员account_id列表
|
||||||
|
optional int32 reason = 2; //解散原因 1:房主解散 2:系统解散(倒计时超时后队伍数<2)
|
||||||
}
|
}
|
||||||
|
|
||||||
//房间玩家离开通知
|
//房间玩家离开通知
|
||||||
@ -301,3 +308,12 @@ message SMRoomChangeNotify
|
|||||||
{
|
{
|
||||||
optional MFRoom room = 1; //房间信息
|
optional MFRoom room = 1; //房间信息
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//房间游戏开始通知,这个消息游戏开始后10秒内每秒通知,客户端需要做重复消息处理
|
||||||
|
message SMRoomGameStartNotify
|
||||||
|
{
|
||||||
|
optional int32 zone_id = 1; //区id
|
||||||
|
optional int32 node_id = 2; //节点id
|
||||||
|
optional string team_uuid = 3; //CMJoin战斗服时用
|
||||||
|
optional string custom_room_payload = 4; //自定义房间透传数据
|
||||||
|
}
|
||||||
|
@ -38,4 +38,5 @@ message Config
|
|||||||
{
|
{
|
||||||
optional string gameapi_url = 1;
|
optional string gameapi_url = 1;
|
||||||
optional int32 auto_start_time = 2;
|
optional int32 auto_start_time = 2;
|
||||||
|
optional int32 game_start_notify_time = 3;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
type member struct {
|
type member struct {
|
||||||
joinTime int64
|
joinTime int64
|
||||||
state int32
|
state int32
|
||||||
|
closeGameStartNotify bool
|
||||||
entry q5.ListHead
|
entry q5.ListHead
|
||||||
teamEntry q5.ListHead
|
teamEntry q5.ListHead
|
||||||
hum common.Player
|
hum common.Player
|
||||||
|
@ -26,10 +26,14 @@ type room struct {
|
|||||||
owner *member
|
owner *member
|
||||||
roomState int32
|
roomState int32
|
||||||
startTime int64
|
startTime int64
|
||||||
startType int32
|
startReason int32
|
||||||
|
disbandTime int64
|
||||||
|
disbandReason int32
|
||||||
teams map[string]*team
|
teams map[string]*team
|
||||||
members map[string]*member
|
members map[string]*member
|
||||||
startTimer *f5.TimerWp
|
startTimer *f5.TimerWp
|
||||||
|
attacher *f5.TimerAttacher
|
||||||
|
gameStartNotifyMsg *cs.SMRoomGameStartNotify
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *room) init(roomId string, roomIdx int64, mapId int32, owner common.Player, passwd string) {
|
func (this *room) init(roomId string, roomIdx int64, mapId int32, owner common.Player, passwd string) {
|
||||||
@ -48,13 +52,15 @@ func (this *room) init(roomId string, roomIdx int64, mapId int32, owner common.P
|
|||||||
owner.GetTeamUuid(): newTeam(this.owner),
|
owner.GetTeamUuid(): newTeam(this.owner),
|
||||||
}
|
}
|
||||||
this.owner.hum.SetRoom(this)
|
this.owner.hum.SetRoom(this)
|
||||||
this.startTimer = f5.GetTimer().SetTimeoutWp(
|
this.attacher = f5.GetTimer().NewTimerAttacher()
|
||||||
mt.Table.Config.Get().GetAutoStartTime(),
|
this.startTimer = f5.GetTimer().SetTimeoutExWp(
|
||||||
|
1000 * mt.Table.Config.Get().GetAutoStartTime(),
|
||||||
func (e int32, args *q5.Args) {
|
func (e int32, args *q5.Args) {
|
||||||
if e == q5.TIMER_EXEC_EVENT {
|
if e == q5.TIMER_EXEC_EVENT {
|
||||||
this.autoStart()
|
this.autoStart()
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
|
this.attacher)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *room) getMember(accountId string) *member {
|
func (this *room) getMember(accountId string) *member {
|
||||||
@ -189,6 +195,14 @@ func (this *room) CMKickout(hdr *f5.MsgHdr, msg *cs.CMKickout) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *room) CMCloseNotify(hdr *f5.MsgHdr, msg *cs.CMCloseNotify) {
|
||||||
|
hum := hdr.Context.(common.Player)
|
||||||
|
m := this.getMember(hum.GetAccountId())
|
||||||
|
if m != nil {
|
||||||
|
m.closeGameStartNotify = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (this *room) broadcastMsg(msg proto.Message) {
|
func (this *room) broadcastMsg(msg proto.Message) {
|
||||||
for _, m := range(this.members) {
|
for _, m := range(this.members) {
|
||||||
m.hum.SendMsg(msg)
|
m.hum.SendMsg(msg)
|
||||||
@ -211,14 +225,43 @@ func (this *room) started() bool {
|
|||||||
|
|
||||||
func (this *room) doDisband(reason int32) {
|
func (this *room) doDisband(reason int32) {
|
||||||
this.roomState = ROOM_DISBAND_STATE
|
this.roomState = ROOM_DISBAND_STATE
|
||||||
|
this.disbandTime = q5.GetTickCount()
|
||||||
|
this.disbandReason = reason
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *room) doStart(reason int32) {
|
func (this *room) doStart(reason int32) {
|
||||||
this.roomState = ROOM_STARTED_STATE
|
this.roomState = ROOM_STARTED_STATE
|
||||||
this.startTime = q5.GetTickCount()
|
this.startTime = q5.GetTickCount()
|
||||||
this.startType = ROOM_AUTO_START_TYPE
|
this.startReason = ROOM_AUTO_START_TYPE
|
||||||
|
f5.GetTimer().SetIntervalExWp(
|
||||||
|
1000,
|
||||||
|
func (e int32, args *q5.Args) {
|
||||||
|
if e == q5.TIMER_EXEC_EVENT {
|
||||||
|
if q5.GetTickCount() - this.startTime <
|
||||||
|
int64(1000 * mt.Table.Config.Get().GetGameStartNotifyTime()) {
|
||||||
|
this.notifyGameStart()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
this.attacher)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *room) view() bool {
|
func (this *room) view() bool {
|
||||||
return this.roomState == ROOM_INIT_STATE
|
return this.roomState == ROOM_INIT_STATE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *room) notifyGameStart() {
|
||||||
|
if this.gameStartNotifyMsg == nil {
|
||||||
|
this.gameStartNotifyMsg = &cs.SMRoomGameStartNotify{}
|
||||||
|
this.gameStartNotifyMsg.ZoneId = proto.Int32(this.config.zoneId)
|
||||||
|
this.gameStartNotifyMsg.NodeId = proto.Int32(this.config.nodeId)
|
||||||
|
this.gameStartNotifyMsg.TeamUuid = proto.String(q5.ToString(this.roomIdx))
|
||||||
|
}
|
||||||
|
for _, m := range(this.members) {
|
||||||
|
if m.state == MEMBER_READY_STATE &&
|
||||||
|
m.hum.GetRoom() == this &&
|
||||||
|
!m.closeGameStartNotify {
|
||||||
|
m.hum.SendMsg(this.gameStartNotifyMsg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user