diff --git a/server/imserver_new/common/types.go b/server/imserver_new/common/types.go index 887d24a7..2aea7674 100644 --- a/server/imserver_new/common/types.go +++ b/server/imserver_new/common/types.go @@ -14,6 +14,11 @@ type HistorySeasons struct { WinTimes int `json:"win_times"` } +type HeadRsp struct { + Errcode int `json:"errcode"` + Errmsg string `json:"errmsg"` +} + type LoginRsp struct { Errcode int `json:"errcode"` Errmsg string `json:"errmsg"` @@ -79,6 +84,7 @@ type GuildMember interface { type GuildMgr interface { GetGuildByAccountId(string) Guild + GetGuildByGuildName(string) Guild GetRecommendGuilds(string) []Guild GetGuildRank() []Guild AsyncCreateGuild(string, int32, string, func(int32, string, int64)) diff --git a/server/imserver_new/player/player.go b/server/imserver_new/player/player.go index 0dc01ccf..cedc554f 100644 --- a/server/imserver_new/player/player.go +++ b/server/imserver_new/player/player.go @@ -4,6 +4,8 @@ import ( "cs" "q5" "f5" + "fmt" + "mt" "github.com/golang/protobuf/proto" "main/common" "main/constant" @@ -35,6 +37,10 @@ func (this *player) IsOnline() bool { return this.socket.IsValid() } +func (this *player) guildIsTooLong(guildName string) bool { + return len(guildName) > 15 +} + func (this *player) SendMsg(rspMsg proto.Message) { GetWspListener().SendProxyMsg(this.socket.Conn, this.socket.SocketHandle, rspMsg) } @@ -380,6 +386,38 @@ func (this *player) CMGetTopGuildsByTotalStars(hdr *f5.MsgHdr, msg *cs.CMGetTopG } func (this *player) CMCreateGuild(hdr *f5.MsgHdr, msg *cs.CMCreateGuild) { + rspMsg := new(cs.SMCreateGuild) + if len(msg.GetName()) <= 0 { + this.SendMsg(rspMsg.Err(1, "Name cantnot be empty")) + return + } + if this.guildIsTooLong(msg.GetName()) { + this.SendMsg(rspMsg.Err(2, "Name is to long")) + return + } + if GetGuildMgr().GetGuildByAccountId(this.GetAccountId()) != nil { + this.SendMsg(rspMsg.Err(3, "You already have a cube")) + return + } + if GetGuildMgr().GetGuildByGuildName(msg.GetName()) != nil { + this.SendMsg(rspMsg.Err(4, "Cube name already exists")) + return + } + params := map[string]string{ + "c": "Bag", + "a": "createGuildConsume", + "account_id": this.GetAccountId(), + "session_id": this.GetSessionId(), + } + url := fmt.Sprintf("%s/webapp/index.php", mt.Table.Config.GetById(0).GetGameapiUrl()) + rspObj := new(common.HeadRsp) + f5.GetHttpCliMgr().SendJsStyleJsonRspRequest( + url, + params, + &rspObj, + func(rsp f5.HttpCliResponse) { + + }) } func (this *player) CMApplyToGuild(hdr *f5.MsgHdr, msg *cs.CMApplyToGuild) { diff --git a/server/imserver_new/player/playermgr.go b/server/imserver_new/player/playermgr.go index 14f46c24..ff686131 100644 --- a/server/imserver_new/player/playermgr.go +++ b/server/imserver_new/player/playermgr.go @@ -126,7 +126,7 @@ func (this *playerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) { "target_id": msg.GetAccountId(), } url := fmt.Sprintf("%s/webapp/index.php", mt.Table.Config.GetById(0).GetGameapiUrl()) - rspObj := &common.LoginRsp{} + rspObj := new(common.LoginRsp) var evHandle **SocketCloseEventHandle = new(*SocketCloseEventHandle) handle := f5.GetHttpCliMgr().SendJsStyleJsonRspRequest( url,