This commit is contained in:
aozhiwei 2023-09-12 13:10:43 +08:00
parent 97a0ede5c1
commit 6227d7e41d
8 changed files with 275 additions and 4 deletions

View File

@ -38,6 +38,15 @@ type MsgHandler interface {
CMPing(*f5.MsgHdr, *CMPing)
CMLogin(*f5.MsgHdr, *CMLogin)
CMReconnect(*f5.MsgHdr, *CMReconnect)
CMCreateRoom(*f5.MsgHdr, *CMCreateRoom)
CMSearchRoom(*f5.MsgHdr, *CMSearchRoom)
CMJoinRoom(*f5.MsgHdr, *CMJoinRoom)
CMDisbandRoom(*f5.MsgHdr, *CMDisbandRoom)
CMLeaveRoom(*f5.MsgHdr, *CMLeaveRoom)
CMModifyRoom(*f5.MsgHdr, *CMModifyRoom)
CMStartGame(*f5.MsgHdr, *CMStartGame)
CMSetPrepare(*f5.MsgHdr, *CMSetPrepare)
CMKickout(*f5.MsgHdr, *CMKickout)
}
func (this *MsgHandlerImpl) CMPing(hdr *f5.MsgHdr, msg *CMPing) {
@ -49,6 +58,33 @@ func (this *MsgHandlerImpl) CMLogin(hdr *f5.MsgHdr, msg *CMLogin) {
func (this *MsgHandlerImpl) CMReconnect(hdr *f5.MsgHdr, msg *CMReconnect) {
}
func (this *MsgHandlerImpl) CMCreateRoom(hdr *f5.MsgHdr, msg *CMCreateRoom) {
}
func (this *MsgHandlerImpl) CMSearchRoom(hdr *f5.MsgHdr, msg *CMSearchRoom) {
}
func (this *MsgHandlerImpl) CMJoinRoom(hdr *f5.MsgHdr, msg *CMJoinRoom) {
}
func (this *MsgHandlerImpl) CMDisbandRoom(hdr *f5.MsgHdr, msg *CMDisbandRoom) {
}
func (this *MsgHandlerImpl) CMLeaveRoom(hdr *f5.MsgHdr, msg *CMLeaveRoom) {
}
func (this *MsgHandlerImpl) CMModifyRoom(hdr *f5.MsgHdr, msg *CMModifyRoom) {
}
func (this *MsgHandlerImpl) CMStartGame(hdr *f5.MsgHdr, msg *CMStartGame) {
}
func (this *MsgHandlerImpl) CMSetPrepare(hdr *f5.MsgHdr, msg *CMSetPrepare) {
}
func (this *MsgHandlerImpl) CMKickout(hdr *f5.MsgHdr, msg *CMKickout) {
}
func (this *CMPing) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMPing)
}
@ -77,6 +113,90 @@ func (this *SMReconnect) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMReconnect)
}
func (this *CMCreateRoom) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMCreateRoom)
}
func (this *SMCreateRoom) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMCreateRoom)
}
func (this *CMSearchRoom) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMSearchRoom)
}
func (this *SMSearchRoom) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMSearchRoom)
}
func (this *CMJoinRoom) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMJoinRoom)
}
func (this *SMJoinRoom) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMJoinRoom)
}
func (this *CMDisbandRoom) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMDisbandRoom)
}
func (this *SMDisbandRoom) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMDisbandRoom)
}
func (this *CMLeaveRoom) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMLeaveRoom)
}
func (this *SMLeaveRoom) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMLeaveRoom)
}
func (this *CMModifyRoom) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMModifyRoom)
}
func (this *SMModifyRoom) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMModifyRoom)
}
func (this *CMStartGame) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMStartGame)
}
func (this *SMStartGame) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMStartGame)
}
func (this *CMSetPrepare) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMSetPrepare)
}
func (this *CMKickout) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMKickout)
}
func (this *SMRoomMemberChangeNotify) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMRoomMemberChangeNotify)
}
func (this *SMRoomKickoutNotify) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMRoomKickoutNotify)
}
func (this *SMRoomLeaveNotify) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMRoomLeaveNotify)
}
func (this *SMRoomDisbandNotify) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMRoomDisbandNotify)
}
func (this *SMRoomChangeNotify) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMRoomChangeNotify)
}
func init() {
handlers[int(CMMessageIdE__CMPing)] = &CsNetMsgHandler{
@ -115,4 +235,112 @@ func init() {
},
}
handlers[int(CMMessageIdE__CMCreateRoom)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMCreateRoom),
ParseCb: func (data []byte) interface{} {
msg := &CMCreateRoom{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMCreateRoom(hdr, hdr.Msg.(*CMCreateRoom))
},
}
handlers[int(CMMessageIdE__CMSearchRoom)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMSearchRoom),
ParseCb: func (data []byte) interface{} {
msg := &CMSearchRoom{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMSearchRoom(hdr, hdr.Msg.(*CMSearchRoom))
},
}
handlers[int(CMMessageIdE__CMJoinRoom)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMJoinRoom),
ParseCb: func (data []byte) interface{} {
msg := &CMJoinRoom{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMJoinRoom(hdr, hdr.Msg.(*CMJoinRoom))
},
}
handlers[int(CMMessageIdE__CMDisbandRoom)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMDisbandRoom),
ParseCb: func (data []byte) interface{} {
msg := &CMDisbandRoom{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMDisbandRoom(hdr, hdr.Msg.(*CMDisbandRoom))
},
}
handlers[int(CMMessageIdE__CMLeaveRoom)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMLeaveRoom),
ParseCb: func (data []byte) interface{} {
msg := &CMLeaveRoom{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMLeaveRoom(hdr, hdr.Msg.(*CMLeaveRoom))
},
}
handlers[int(CMMessageIdE__CMModifyRoom)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMModifyRoom),
ParseCb: func (data []byte) interface{} {
msg := &CMModifyRoom{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMModifyRoom(hdr, hdr.Msg.(*CMModifyRoom))
},
}
handlers[int(CMMessageIdE__CMStartGame)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMStartGame),
ParseCb: func (data []byte) interface{} {
msg := &CMStartGame{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMStartGame(hdr, hdr.Msg.(*CMStartGame))
},
}
handlers[int(CMMessageIdE__CMSetPrepare)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMSetPrepare),
ParseCb: func (data []byte) interface{} {
msg := &CMSetPrepare{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMSetPrepare(hdr, hdr.Msg.(*CMSetPrepare))
},
}
handlers[int(CMMessageIdE__CMKickout)] = &CsNetMsgHandler{
MsgId: int(CMMessageIdE__CMKickout),
ParseCb: func (data []byte) interface{} {
msg := &CMKickout{}
proto.Unmarshal(data, msg)
return msg
},
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
handler.CMKickout(hdr, hdr.Msg.(*CMKickout))
},
}
}

View File

@ -13,3 +13,20 @@ type ConfigTable struct {
f5.IdMetaTable[Config]
selfConf *Config
}
func (this *Config) Init1() {
if this.GetAutoStartTime() < 30 {
panic("config.auto_start_time config error")
}
}
func (this *ConfigTable) PostInit1() {
this.selfConf = this.GetById(int64(0))
if this.selfConf == nil {
panic("无法读取config.json")
}
}
func (this *ConfigTable) Get() *Config {
return this.selfConf
}

View File

@ -46,6 +46,7 @@ type FriendDb struct {
type Config struct {
gameapi_url string
auto_start_time int32
_flags1_ uint64
_flags2_ uint64
@ -187,6 +188,14 @@ func (this *Config) HasGameapiUrl() bool {
return (this._flags1_ & (uint64(1) << 1)) > 0
}
func (this *Config) GetAutoStartTime() int32 {
return this.auto_start_time
}
func (this *Config) HasAutoStartTime() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *HallCluster) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
@ -218,4 +227,5 @@ func (this *FriendDb) 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.auto_start_time, "auto_start_time", &this._flags1_, 2, kv)
}

View File

@ -37,9 +37,9 @@ enum SMMessageId_e
_SMSetPrepare = 112;
_SMKickout = 113;
_SMRoomMemberChagnedNotify = 1001;
_SMRoomMemberChangeNotify = 1001;
_SMRoomKickoutNotify = 1002;
_SMRoomLeaveNotify = 1003;
_SMRoomDisbandNotify = 1004;
_SMRoomChangedNotify = 1005;
_SMRoomChangeNotify = 1005;
}

View File

@ -241,7 +241,8 @@ message SMLeaveRoom
//
message CMModifyRoom
{
optional string room_id = 1; //
optional int32 map_id = 1; //
optional string passwd = 2; //
}
message SMModifyRoom

View File

@ -37,4 +37,5 @@ message FriendDb
message Config
{
optional string gameapi_url = 1;
optional int32 auto_start_time = 2;
}

View File

@ -4,6 +4,7 @@ import (
"cs"
"q5"
"f5"
"mt"
"main/common"
"main/constant"
"github.com/golang/protobuf/proto"
@ -12,6 +13,7 @@ import (
type roomConfg struct {
mapId int32
zoneId int32
nodeId int32
passwd string
}
@ -24,6 +26,7 @@ type room struct {
owner *member
teams map[string]*team
members map[string]*member
startTimer *f5.TimerWp
}
func (this *room) init(roomId string, roomIdx int64, owner common.Player, passwd string) {
@ -39,6 +42,13 @@ func (this *room) init(roomId string, roomIdx int64, owner common.Player, passwd
owner.GetTeamUuid(): newTeam(this.owner),
}
this.owner.hum.SetRoom(this)
this.startTimer = f5.GetTimer().SetTimeoutWp(
mt.Table.Config.Get().GetAutoStartTime(),
func (e int32, args *q5.Args) {
if e == q5.TIMER_EXEC_EVENT {
this.autoStart()
}
})
}
func (this *room) getMember(accountId string) *member {
@ -164,3 +174,7 @@ func (this *room) broadcastMsg(msg proto.Message) {
m.hum.SendMsg(msg)
}
}
func (this *room) autoStart() {
}