save
This commit is contained in:
parent
e4b1bd4038
commit
8a07fcdd8c
@ -3775,7 +3775,7 @@ type MFGuild struct {
|
|||||||
GuildId *int64 `protobuf:"varint,2,opt,name=guild_id,json=guildId" json:"guild_id,omitempty"`
|
GuildId *int64 `protobuf:"varint,2,opt,name=guild_id,json=guildId" json:"guild_id,omitempty"`
|
||||||
Name *string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"`
|
Name *string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"`
|
||||||
LeaderId *string `protobuf:"bytes,4,opt,name=leader_id,json=leaderId" json:"leader_id,omitempty"`
|
LeaderId *string `protobuf:"bytes,4,opt,name=leader_id,json=leaderId" json:"leader_id,omitempty"`
|
||||||
Members *int32 `protobuf:"varint,5,opt,name=members" json:"members,omitempty"`
|
MembersCount *int32 `protobuf:"varint,5,opt,name=membersCount" json:"membersCount,omitempty"`
|
||||||
MaxMembers *int32 `protobuf:"varint,6,opt,name=max_members,json=maxMembers" json:"max_members,omitempty"`
|
MaxMembers *int32 `protobuf:"varint,6,opt,name=max_members,json=maxMembers" json:"max_members,omitempty"`
|
||||||
Notice *string `protobuf:"bytes,7,opt,name=notice" json:"notice,omitempty"`
|
Notice *string `protobuf:"bytes,7,opt,name=notice" json:"notice,omitempty"`
|
||||||
}
|
}
|
||||||
@ -3840,9 +3840,9 @@ func (x *MFGuild) GetLeaderId() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *MFGuild) GetMembers() int32 {
|
func (x *MFGuild) GetMembersCount() int32 {
|
||||||
if x != nil && x.Members != nil {
|
if x != nil && x.MembersCount != nil {
|
||||||
return *x.Members
|
return *x.MembersCount
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -4452,44 +4452,44 @@ var file_cs_proto_proto_rawDesc = []byte{
|
|||||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x72, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x23,
|
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x72, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x23,
|
||||||
0x0a, 0x06, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b,
|
0x0a, 0x06, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b,
|
||||||
0x2e, 0x63, 0x73, 0x2e, 0x4d, 0x46, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x06, 0x67, 0x75, 0x69,
|
0x2e, 0x63, 0x73, 0x2e, 0x4d, 0x46, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x06, 0x67, 0x75, 0x69,
|
||||||
0x6c, 0x64, 0x73, 0x22, 0xc1, 0x01, 0x0a, 0x07, 0x4d, 0x46, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x12,
|
0x6c, 0x64, 0x73, 0x22, 0xcb, 0x01, 0x0a, 0x07, 0x4d, 0x46, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x12,
|
||||||
0x17, 0x0a, 0x07, 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
|
0x17, 0x0a, 0x07, 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
|
||||||
0x52, 0x06, 0x61, 0x75, 0x74, 0x6f, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x75, 0x69, 0x6c,
|
0x52, 0x06, 0x61, 0x75, 0x74, 0x6f, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x75, 0x69, 0x6c,
|
||||||
0x64, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x67, 0x75, 0x69, 0x6c,
|
0x64, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x67, 0x75, 0x69, 0x6c,
|
||||||
0x64, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,
|
0x64, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,
|
||||||
0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6c, 0x65, 0x61, 0x64, 0x65,
|
0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6c, 0x65, 0x61, 0x64, 0x65,
|
||||||
0x72, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x65, 0x61, 0x64,
|
0x72, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x65, 0x61, 0x64,
|
||||||
0x65, 0x72, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18,
|
0x65, 0x72, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x43,
|
||||||
0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x1f,
|
0x6f, 0x75, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x6d, 0x65, 0x6d, 0x62,
|
||||||
0x0a, 0x0b, 0x6d, 0x61, 0x78, 0x5f, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x06, 0x20,
|
0x65, 0x72, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x61, 0x78, 0x5f,
|
||||||
0x01, 0x28, 0x05, 0x52, 0x0a, 0x6d, 0x61, 0x78, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12,
|
0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x6d,
|
||||||
0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52,
|
0x61, 0x78, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x74,
|
||||||
0x06, 0x6e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x22, 0x0d, 0x0a, 0x0b, 0x43, 0x4d, 0x47, 0x75, 0x69,
|
0x69, 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x63,
|
||||||
0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x6f, 0x0a, 0x0b, 0x53, 0x4d, 0x47, 0x75, 0x69, 0x6c,
|
0x65, 0x22, 0x0d, 0x0a, 0x0b, 0x43, 0x4d, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x73,
|
||||||
0x64, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x72, 0x72, 0x5f, 0x63, 0x6f, 0x64,
|
0x22, 0x6f, 0x0a, 0x0b, 0x53, 0x4d, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x73, 0x12,
|
||||||
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x65, 0x72, 0x72, 0x43, 0x6f, 0x64, 0x65,
|
0x19, 0x0a, 0x08, 0x65, 0x72, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
0x12, 0x17, 0x0a, 0x07, 0x65, 0x72, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28,
|
0x05, 0x52, 0x07, 0x65, 0x72, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x65, 0x72,
|
||||||
0x09, 0x52, 0x06, 0x65, 0x72, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x2c, 0x0a, 0x09, 0x67, 0x75, 0x69,
|
0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x72, 0x72,
|
||||||
0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x63,
|
0x4d, 0x73, 0x67, 0x12, 0x2c, 0x0a, 0x09, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x73,
|
||||||
0x73, 0x2e, 0x4d, 0x46, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x52, 0x09, 0x67, 0x75,
|
0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x63, 0x73, 0x2e, 0x4d, 0x46, 0x47, 0x75,
|
||||||
0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x7b, 0x0a, 0x0a, 0x4d, 0x46, 0x47, 0x75, 0x69,
|
0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x52, 0x09, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67,
|
||||||
0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69,
|
0x73, 0x22, 0x7b, 0x0a, 0x0a, 0x4d, 0x46, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x6f, 0x67, 0x12,
|
||||||
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x64,
|
0x19, 0x0a, 0x08, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02,
|
0x03, 0x52, 0x07, 0x67, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x12,
|
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
|
||||||
0x19, 0x0a, 0x08, 0x6c, 0x6f, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,
|
0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x6f, 0x67,
|
||||||
0x05, 0x52, 0x07, 0x6c, 0x6f, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f,
|
0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6c, 0x6f, 0x67,
|
||||||
0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e,
|
0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18,
|
||||||
0x74, 0x65, 0x6e, 0x74, 0x22, 0x24, 0x0a, 0x08, 0x43, 0x4d, 0x4e, 0x6f, 0x74, 0x69, 0x63, 0x65,
|
0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x24,
|
||||||
0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x0a, 0x08, 0x43, 0x4d, 0x4e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f,
|
||||||
0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x3e, 0x0a, 0x08, 0x53, 0x4d,
|
0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e,
|
||||||
0x4e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x72, 0x72, 0x5f, 0x63, 0x6f,
|
0x74, 0x65, 0x6e, 0x74, 0x22, 0x3e, 0x0a, 0x08, 0x53, 0x4d, 0x4e, 0x6f, 0x74, 0x69, 0x63, 0x65,
|
||||||
0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x65, 0x72, 0x72, 0x43, 0x6f, 0x64,
|
0x12, 0x19, 0x0a, 0x08, 0x65, 0x72, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01,
|
||||||
0x65, 0x12, 0x17, 0x0a, 0x07, 0x65, 0x72, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01,
|
0x28, 0x05, 0x52, 0x07, 0x65, 0x72, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x65,
|
||||||
0x28, 0x09, 0x52, 0x06, 0x65, 0x72, 0x72, 0x4d, 0x73, 0x67, 0x2a, 0x22, 0x0a, 0x0a, 0x43, 0x6f,
|
0x72, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x72,
|
||||||
0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x5f, 0x65, 0x12, 0x14, 0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x74,
|
0x72, 0x4d, 0x73, 0x67, 0x2a, 0x22, 0x0a, 0x0a, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74,
|
||||||
0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x10, 0xd1, 0xa2, 0xd5, 0xc4, 0x07, 0x42, 0x06,
|
0x5f, 0x65, 0x12, 0x14, 0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x56, 0x65, 0x72, 0x73, 0x69,
|
||||||
0x5a, 0x04, 0x2e, 0x3b, 0x63, 0x73,
|
0x6f, 0x6e, 0x10, 0xd1, 0xa2, 0xd5, 0xc4, 0x07, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x63, 0x73,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -6,6 +6,8 @@ import "q5"
|
|||||||
type User struct {
|
type User struct {
|
||||||
AccountId string
|
AccountId string
|
||||||
Username string
|
Username string
|
||||||
|
FriendRequest map[string]*FriendRequest // AccountId -> FriendRequest
|
||||||
|
FriendBlackList map[string]*FriendBlackList // AccountId -> FriendBlackList
|
||||||
}
|
}
|
||||||
|
|
||||||
// Friendship user1, user2 构成一个好友关系
|
// Friendship user1, user2 构成一个好友关系
|
||||||
@ -15,18 +17,92 @@ type Friendship struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FriendRequest struct {
|
type FriendRequest struct {
|
||||||
RequestID int
|
AccountId string
|
||||||
SenderID int
|
IsFriendship int32 // 0 pending, 1 ok, 2 reject, 3 disband
|
||||||
ReceiverID int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BlockedUser 直接存列表, 黑名单上限就50个
|
// FriendBlackList 直接存列表, 黑名单上限就50个
|
||||||
type BlockedUser struct {
|
type FriendBlackList struct {
|
||||||
AccountId string
|
AccountId string
|
||||||
BlockedAccountId string
|
isRemoved int32 // default: 0, isRemoved
|
||||||
}
|
}
|
||||||
|
|
||||||
// RandomUsername generates a random username
|
// RandomUsername generates a random username
|
||||||
func RandomUsername() string {
|
func RandomUsername() string {
|
||||||
return q5.RandomString(6)
|
return q5.RandomString(6)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *User) AddFriendRequest(account2Id string) {
|
||||||
|
if u.FriendRequest == nil {
|
||||||
|
u.FriendRequest = make(map[string]*FriendRequest, MaxPendingFriendReqs)
|
||||||
|
}
|
||||||
|
friendRequest := &FriendRequest{
|
||||||
|
AccountId: account2Id,
|
||||||
|
IsFriendship: 0,
|
||||||
|
}
|
||||||
|
u.FriendRequest[account2Id] = friendRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) GetFriendRequest(account2Id string) *FriendRequest {
|
||||||
|
if friendRequest, exists := u.FriendRequest[account2Id]; exists {
|
||||||
|
if exists {
|
||||||
|
return friendRequest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) GetAllFriendRequestAccountIds() []string {
|
||||||
|
var accountIds []string
|
||||||
|
for accountId, _ := range u.FriendRequest {
|
||||||
|
accountIds = append(accountIds, accountId)
|
||||||
|
}
|
||||||
|
return accountIds
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) RemoveFriendRequest(account2Id string) {
|
||||||
|
delete(u.FriendRequest, account2Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) IsInReq(targetAccountId string) bool {
|
||||||
|
if u.FriendRequest == nil {
|
||||||
|
u.FriendRequest = make(map[string]*FriendRequest, MaxPendingFriendReqs)
|
||||||
|
}
|
||||||
|
friendRequest, exists := u.FriendRequest[targetAccountId]
|
||||||
|
return exists && friendRequest.IsFriendship != 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddBlacklist 加入黑名单
|
||||||
|
func (u *User) AddBlacklist(b *FriendBlackList) {
|
||||||
|
if u.FriendBlackList == nil {
|
||||||
|
u.FriendBlackList = make(map[string]*FriendBlackList, MaxBlockedMembers)
|
||||||
|
}
|
||||||
|
u.FriendBlackList[b.AccountId] = b
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBlacklist 获取黑名单
|
||||||
|
func (u *User) GetBlacklist(account2Id string) *FriendBlackList {
|
||||||
|
if friendBlackList, exists := u.FriendBlackList[account2Id]; exists {
|
||||||
|
if exists {
|
||||||
|
return friendBlackList
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsInBlacklist 在黑名单中
|
||||||
|
func (u *User) IsInBlacklist(account2Id string) bool {
|
||||||
|
if friendBlackList, exists := u.FriendBlackList[account2Id]; exists {
|
||||||
|
return exists && friendBlackList.isRemoved == 0
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *User) RemoveBlacklist(account2Id string) {
|
||||||
|
delete(u.FriendBlackList, account2Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBlacklistCount 获取黑名单
|
||||||
|
func (u *User) GetBlacklistCount() int {
|
||||||
|
return len(u.FriendBlackList)
|
||||||
|
}
|
||||||
|
@ -129,7 +129,6 @@ func (fm *FriendsMgr) loadUsersResult(err error, rows *f5.DataSet) {
|
|||||||
fmt.Printf("loadUsersResult err:%v \n", err)
|
fmt.Printf("loadUsersResult err:%v \n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fm.users = make(map[string]*User, 100)
|
fm.users = make(map[string]*User, 100)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
user := &User{
|
user := &User{
|
||||||
@ -192,12 +191,20 @@ func (fm *FriendsMgr) loadPendingRequestsResult(err error, rows *f5.DataSet) {
|
|||||||
fmt.Printf("loadPendingRequestsResult err:%v \n", err)
|
fmt.Printf("loadPendingRequestsResult err:%v \n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fm.pendingReqs = make(map[string]map[string]bool)
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
senderAccountId := q5.ToString(*rows.GetByIndex(0))
|
senderAccountId := q5.ToString(*rows.GetByIndex(0))
|
||||||
receiverAccountId := q5.ToString(*rows.GetByIndex(1))
|
receiverAccountId := q5.ToString(*rows.GetByIndex(1))
|
||||||
fm.pendingReqs[receiverAccountId] = make(map[string]bool)
|
user := fm.users[receiverAccountId]
|
||||||
fm.pendingReqs[receiverAccountId][senderAccountId] = false
|
if user != nil {
|
||||||
|
if user.FriendRequest == nil {
|
||||||
|
user.FriendRequest = make(map[string]*FriendRequest, MaxPendingFriendReqs)
|
||||||
|
}
|
||||||
|
friendRequest := &FriendRequest{
|
||||||
|
AccountId: senderAccountId,
|
||||||
|
IsFriendship: 0,
|
||||||
|
}
|
||||||
|
user.FriendRequest[receiverAccountId] = friendRequest
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,11 +227,20 @@ func (fm *FriendsMgr) loadBlacklistResult(err error, rows *f5.DataSet) {
|
|||||||
fmt.Printf("loadBlacklistResult err:%v \n", err)
|
fmt.Printf("loadBlacklistResult err:%v \n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fm.blackList = make(map[string]map[string]bool, 100)
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
account1Id := q5.ToString(*rows.GetByIndex(0))
|
account1Id := q5.ToString(*rows.GetByIndex(0))
|
||||||
account2Id := q5.ToString(*rows.GetByIndex(1))
|
account2Id := q5.ToString(*rows.GetByIndex(1))
|
||||||
fm.blackList[account1Id] = make(map[string]bool, MaxBlockedMembers)
|
|
||||||
fm.blackList[account1Id][account2Id] = false
|
friendBlackList := &FriendBlackList{
|
||||||
|
AccountId: account2Id,
|
||||||
|
isRemoved: 0,
|
||||||
|
}
|
||||||
|
user := fm.users[account1Id]
|
||||||
|
if user != nil {
|
||||||
|
if user.FriendBlackList == nil {
|
||||||
|
user.FriendBlackList = make(map[string]*FriendBlackList, MaxBlockedMembers)
|
||||||
|
}
|
||||||
|
user.FriendBlackList[account1Id] = friendBlackList
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,6 @@ type FriendsMgr struct {
|
|||||||
users map[string]*User // AccountId -> 用户
|
users map[string]*User // AccountId -> 用户
|
||||||
searchCaches map[string]SearchCache // SearchKeyword -> 好友搜索结果 []*User
|
searchCaches map[string]SearchCache // SearchKeyword -> 好友搜索结果 []*User
|
||||||
friendships map[string][]*Friendship // AccountId -> 好友关系列表 []*Friendship
|
friendships map[string][]*Friendship // AccountId -> 好友关系列表 []*Friendship
|
||||||
pendingReqs map[string]map[string]bool // AccountId -> 等待请求列表 map[account2Id]false default false, isFriendShip
|
|
||||||
blackList map[string]map[string]bool // AccountId -> 黑名单列表 map[account2Id]false default: false, isRemoved
|
|
||||||
userCount int // 用户总数
|
userCount int // 用户总数
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +91,7 @@ func (fm *FriendsMgr) searchUsers(keyword string) []*User {
|
|||||||
return listFriend
|
return listFriend
|
||||||
}
|
}
|
||||||
|
|
||||||
// addFriendRequest 添加好友请求
|
// addFriendRequest 添加好友请求 By default, account1Id is me, account2Id is them
|
||||||
func (fm *FriendsMgr) addFriendRequest(account1Id string, account2Id string) error {
|
func (fm *FriendsMgr) addFriendRequest(account1Id string, account2Id string) error {
|
||||||
user1 := fm.getUser(account1Id)
|
user1 := fm.getUser(account1Id)
|
||||||
if user1 == nil {
|
if user1 == nil {
|
||||||
@ -104,15 +102,17 @@ func (fm *FriendsMgr) addFriendRequest(account1Id string, account2Id string) err
|
|||||||
return fmt.Errorf("user not found, accountId:%s", account2Id)
|
return fmt.Errorf("user not found, accountId:%s", account2Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := fm.checkInBlackList(account1Id, account2Id)
|
found1 := user1.IsInBlacklist(account2Id)
|
||||||
if err != nil {
|
found2 := user2.IsInBlacklist(account1Id)
|
||||||
return err
|
if found1 == true || found2 == true {
|
||||||
|
return fmt.Errorf("user:%s in user:%s blocked", account1Id, account2Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 已发送请求
|
// 已发送请求
|
||||||
if _, ok := fm.pendingReqs[account1Id][account2Id]; ok {
|
if _, ok := user1.FriendRequest[account2Id]; ok {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自己好友已满
|
// 自己好友已满
|
||||||
if fm.getFriendCount(account1Id) >= MaxFriendMembers {
|
if fm.getFriendCount(account1Id) >= MaxFriendMembers {
|
||||||
return fmt.Errorf("player:%s, friends are full", account1Id)
|
return fmt.Errorf("player:%s, friends are full", account1Id)
|
||||||
@ -126,18 +126,8 @@ func (fm *FriendsMgr) addFriendRequest(account1Id string, account2Id string) err
|
|||||||
return fmt.Errorf("player:%s, friends are full", account2Id)
|
return fmt.Errorf("player:%s, friends are full", account2Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
if fm.pendingReqs == nil {
|
user1.AddFriendRequest(account2Id)
|
||||||
fm.pendingReqs = make(map[string]map[string]bool, MaxPendingFriendReqs*10)
|
user2.AddFriendRequest(account1Id)
|
||||||
}
|
|
||||||
if fm.pendingReqs[account1Id] == nil {
|
|
||||||
fm.pendingReqs[account1Id] = make(map[string]bool, MaxPendingFriendReqs)
|
|
||||||
}
|
|
||||||
fm.pendingReqs[account1Id][account2Id] = false
|
|
||||||
|
|
||||||
if fm.pendingReqs[account2Id] == nil {
|
|
||||||
fm.pendingReqs[account2Id] = make(map[string]bool, MaxPendingFriendReqs)
|
|
||||||
}
|
|
||||||
fm.pendingReqs[account2Id][account1Id] = false
|
|
||||||
|
|
||||||
// persist to db
|
// persist to db
|
||||||
fm.upsertFriendRequest(account1Id, account2Id, q5.ToString(FriendReqsStatusDefault))
|
fm.upsertFriendRequest(account1Id, account2Id, q5.ToString(FriendReqsStatusDefault))
|
||||||
@ -147,7 +137,8 @@ func (fm *FriendsMgr) addFriendRequest(account1Id string, account2Id string) err
|
|||||||
|
|
||||||
// acceptFriendRequest 接受好友请求
|
// acceptFriendRequest 接受好友请求
|
||||||
func (fm *FriendsMgr) acceptFriendRequest(account1Id string, account2Id string) error {
|
func (fm *FriendsMgr) acceptFriendRequest(account1Id string, account2Id string) error {
|
||||||
if _, ok := fm.pendingReqs[account1Id][account2Id]; !ok {
|
user := fm.getUser(account1Id)
|
||||||
|
if !user.IsInReq(account2Id) {
|
||||||
return fmt.Errorf("no pending friend request from account1Id to account2Id")
|
return fmt.Errorf("no pending friend request from account1Id to account2Id")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,26 +161,28 @@ func (fm *FriendsMgr) acceptFriendRequest(account1Id string, account2Id string)
|
|||||||
}
|
}
|
||||||
fm.friendships[account1Id] = append(fm.friendships[account1Id], friendship)
|
fm.friendships[account1Id] = append(fm.friendships[account1Id], friendship)
|
||||||
fm.friendships[account2Id] = append(fm.friendships[account2Id], friendship)
|
fm.friendships[account2Id] = append(fm.friendships[account2Id], friendship)
|
||||||
delete(fm.pendingReqs[account1Id], account2Id)
|
|
||||||
delete(fm.pendingReqs[account2Id], account1Id)
|
user.RemoveFriendRequest(account2Id)
|
||||||
|
|
||||||
|
// remove
|
||||||
|
user2 := fm.getUser(account2Id)
|
||||||
|
user2.RemoveFriendRequest(account1Id)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// rejectFriendRequest 拒绝好友请求
|
// rejectFriendRequest 拒绝好友请求
|
||||||
func (fm *FriendsMgr) rejectFriendRequest(account1Id string, account2Id string) error {
|
func (fm *FriendsMgr) rejectFriendRequest(account1Id string, account2Id string) error {
|
||||||
if fm.pendingReqs[account1Id] == nil {
|
user := fm.getUser(account1Id)
|
||||||
return fmt.Errorf("no pending friend request to reject")
|
//friendRequest := user.GetFriendRequest(account2Id)
|
||||||
}
|
|
||||||
if _, ok := fm.pendingReqs[account1Id][account2Id]; !ok {
|
|
||||||
return fmt.Errorf("no pending friend request from user1 to user2")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 申请表,申请者,目标者,
|
// 申请表,申请者,目标者,
|
||||||
fm.upsertFriendRequest(account2Id, account1Id, q5.ToString(FriendReqsStatusReject))
|
fm.upsertFriendRequest(account2Id, account1Id, q5.ToString(FriendReqsStatusReject))
|
||||||
|
user.RemoveFriendRequest(account2Id)
|
||||||
|
|
||||||
delete(fm.pendingReqs[account1Id], account2Id)
|
// remove
|
||||||
delete(fm.pendingReqs[account2Id], account1Id)
|
user2 := fm.getUser(account2Id)
|
||||||
|
user2.RemoveFriendRequest(account1Id)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -249,8 +242,9 @@ func (fm *FriendsMgr) getFriendCount(accountId string) int {
|
|||||||
|
|
||||||
// getFriendRequestCount 等待请求数量
|
// getFriendRequestCount 等待请求数量
|
||||||
func (fm *FriendsMgr) getFriendRequestCount(accountId string) int {
|
func (fm *FriendsMgr) getFriendRequestCount(accountId string) int {
|
||||||
if _, ok := fm.pendingReqs[accountId]; ok {
|
user := fm.getUser(accountId)
|
||||||
return len(fm.pendingReqs[accountId])
|
if user != nil {
|
||||||
|
return len(user.FriendRequest)
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -279,25 +273,26 @@ func (fm *FriendsMgr) listFriends(accountId string) []*User {
|
|||||||
|
|
||||||
// addBlacklist 加入黑名单
|
// addBlacklist 加入黑名单
|
||||||
func (fm *FriendsMgr) addBlacklist(account1Id string, account2Id string) error {
|
func (fm *FriendsMgr) addBlacklist(account1Id string, account2Id string) error {
|
||||||
|
user1 := fm.getUser(account1Id)
|
||||||
|
|
||||||
user2 := fm.getUser(account2Id)
|
user2 := fm.getUser(account2Id)
|
||||||
if user2 == nil {
|
if user2 == nil {
|
||||||
return fmt.Errorf("user not found, accountId:%s", account2Id)
|
return fmt.Errorf("user not found, accountId:%s", account2Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
if fm.blackList[account1Id] == nil {
|
user1FriendBlackList := user1.GetBlacklist(account2Id)
|
||||||
fm.blackList[account1Id] = make(map[string]bool, MaxBlockedMembers)
|
if user1FriendBlackList != nil && user1FriendBlackList.isRemoved != 0 {
|
||||||
}
|
|
||||||
|
|
||||||
isRemoved, exists := fm.blackList[account1Id][account2Id]
|
|
||||||
if exists && !isRemoved {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(fm.blackList[account1Id]) >= MaxBlockedMembers {
|
if user1.GetBlacklistCount() >= MaxBlockedMembers {
|
||||||
return fmt.Errorf("your blacklist has reached the limit")
|
return fmt.Errorf("your blacklist has reached the limit")
|
||||||
}
|
}
|
||||||
|
|
||||||
fm.blackList[account1Id][account2Id] = false
|
user1.AddBlacklist(&FriendBlackList{
|
||||||
|
AccountId: account2Id,
|
||||||
|
isRemoved: 0,
|
||||||
|
})
|
||||||
fm.upsertBlacklist(account1Id, account2Id, BlacklistStatusDefault)
|
fm.upsertBlacklist(account1Id, account2Id, BlacklistStatusDefault)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -305,20 +300,14 @@ func (fm *FriendsMgr) addBlacklist(account1Id string, account2Id string) error {
|
|||||||
|
|
||||||
// removeBlacklist 移除黑名单
|
// removeBlacklist 移除黑名单
|
||||||
func (fm *FriendsMgr) removeBlacklist(account1Id string, account2Id string) error {
|
func (fm *FriendsMgr) removeBlacklist(account1Id string, account2Id string) error {
|
||||||
|
user1 := fm.getUser(account1Id)
|
||||||
|
|
||||||
user2 := fm.getUser(account2Id)
|
user2 := fm.getUser(account2Id)
|
||||||
if user2 == nil {
|
if user2 == nil {
|
||||||
return fmt.Errorf("user not found, accountId:%s", account2Id)
|
return fmt.Errorf("user not found, accountId:%s", account2Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
if fm.blackList[account1Id] == nil {
|
user1.RemoveBlacklist(account2Id)
|
||||||
return fmt.Errorf("your blacklist is emtpy")
|
|
||||||
}
|
|
||||||
|
|
||||||
if isRemoved, exists := fm.blackList[account1Id][account2Id]; !exists || isRemoved {
|
|
||||||
return fmt.Errorf("your blacklist not exists target account id")
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(fm.blackList[account1Id], account2Id)
|
|
||||||
fm.upsertBlacklist(account1Id, account2Id, BlacklistStatusIsRemoved)
|
fm.upsertBlacklist(account1Id, account2Id, BlacklistStatusIsRemoved)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -391,24 +380,6 @@ func (fm *FriendsMgr) findFriendShipIndex(Account1Id, Account2Id string) int {
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fm *FriendsMgr) checkInBlackList(account1Id, account2Id string) error {
|
|
||||||
if fm.blackList[account1Id] == nil {
|
|
||||||
fm.blackList[account1Id] = make(map[string]bool, MaxBlockedMembers)
|
|
||||||
}
|
|
||||||
if isRemoved, exists := fm.blackList[account1Id][account2Id]; isRemoved && exists {
|
|
||||||
return fmt.Errorf("user:%s in user:%s blocked", account2Id, account1Id)
|
|
||||||
}
|
|
||||||
|
|
||||||
if fm.blackList[account2Id] == nil {
|
|
||||||
fm.blackList[account2Id] = make(map[string]bool, MaxBlockedMembers)
|
|
||||||
}
|
|
||||||
if isRemoved, exists := fm.blackList[account2Id][account1Id]; isRemoved && exists {
|
|
||||||
return fmt.Errorf("user:%s in user:%s blocked", account1Id, account2Id)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func swapAccountIds(account1Id, account2Id string) (string, string) {
|
func swapAccountIds(account1Id, account2Id string) (string, string) {
|
||||||
if strings.Compare(account1Id, account2Id) > 0 {
|
if strings.Compare(account1Id, account2Id) > 0 {
|
||||||
account1Id, account2Id = account2Id, account1Id
|
account1Id, account2Id = account2Id, account1Id
|
||||||
@ -429,17 +400,3 @@ func (fm *FriendsMgr) getFriendships(accountId string) []*Friendship {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fm *FriendsMgr) getPendingReqs(accountId string) map[string]bool {
|
|
||||||
if reqs, ok := fm.pendingReqs[accountId]; ok {
|
|
||||||
return reqs
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fm *FriendsMgr) getBlacklist(accountId string) map[string]bool {
|
|
||||||
if b, ok := fm.blackList[accountId]; ok {
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -118,12 +118,8 @@ func (p *Player) CMRejectFriendRequest(hdr *f5.MsgHdr, msg *cs.CMRejectFriendReq
|
|||||||
func (p *Player) CMListPendingFriendRequest(hdr *f5.MsgHdr, msg *cs.CMListPendingFriendRequest) {
|
func (p *Player) CMListPendingFriendRequest(hdr *f5.MsgHdr, msg *cs.CMListPendingFriendRequest) {
|
||||||
rspMsg := &cs.SMListPendingFriendRequest{}
|
rspMsg := &cs.SMListPendingFriendRequest{}
|
||||||
accountId := p.accountId
|
accountId := p.accountId
|
||||||
|
user := friendMgr.getUser(accountId)
|
||||||
resAccountIds := make([]string, MaxPendingFriendReqs)
|
rspMsg.AccountIds = user.GetAllFriendRequestAccountIds()
|
||||||
for accountId, _ := range friendMgr.pendingReqs[accountId] {
|
|
||||||
resAccountIds = append(resAccountIds, accountId)
|
|
||||||
}
|
|
||||||
rspMsg.AccountIds = resAccountIds
|
|
||||||
|
|
||||||
f5.GetSysLog().Info("CMListPendingFriendRequest requests count:%d\n", len(rspMsg.GetAccountIds()))
|
f5.GetSysLog().Info("CMListPendingFriendRequest requests count:%d\n", len(rspMsg.GetAccountIds()))
|
||||||
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||||
@ -211,26 +207,23 @@ func (p *Player) CMRemoveBlacklist(hdr *f5.MsgHdr, msg *cs.CMRemoveBlacklist) {
|
|||||||
func (p *Player) CMFriendInfo(hdr *f5.MsgHdr, msg *cs.CMFriendInfo) {
|
func (p *Player) CMFriendInfo(hdr *f5.MsgHdr, msg *cs.CMFriendInfo) {
|
||||||
rspMsg := new(cs.SMFriendInfo)
|
rspMsg := new(cs.SMFriendInfo)
|
||||||
accountId := p.accountId
|
accountId := p.accountId
|
||||||
|
user := friendMgr.getUser(accountId)
|
||||||
|
|
||||||
// friendships
|
// friendships
|
||||||
users := friendMgr.listFriends(accountId)
|
friends := friendMgr.listFriends(accountId)
|
||||||
for _, user := range users {
|
for _, friend := range friends {
|
||||||
rspMsg.FriendshipsAccountIds = append(rspMsg.FriendshipsAccountIds, user.AccountId)
|
rspMsg.FriendshipsAccountIds = append(rspMsg.FriendshipsAccountIds, friend.AccountId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// pending reqs
|
accountIds := user.GetAllFriendRequestAccountIds()
|
||||||
reqs := friendMgr.getPendingReqs(accountId)
|
rspMsg.PendingReqsAccountIds = accountIds
|
||||||
for reqAccountId, _ := range reqs {
|
|
||||||
rspMsg.PendingReqsAccountIds = append(rspMsg.PendingReqsAccountIds, reqAccountId)
|
|
||||||
}
|
|
||||||
|
|
||||||
// blacklist
|
// blacklist
|
||||||
blacklist := friendMgr.getBlacklist(accountId)
|
var blacklistAccountIds []string
|
||||||
for blockedAccountId, isRemoved := range blacklist {
|
for bAccountId := range user.FriendBlackList {
|
||||||
if isRemoved == false {
|
blacklistAccountIds = append(blacklistAccountIds, bAccountId)
|
||||||
rspMsg.BlacklistAccountIds = append(rspMsg.BlacklistAccountIds, blockedAccountId)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
rspMsg.BlacklistAccountIds = blacklistAccountIds
|
||||||
|
|
||||||
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||||
}
|
}
|
||||||
@ -293,26 +286,27 @@ func IsValidChatChannel(chatChannel int32) bool {
|
|||||||
// CMGuildInfo 我的公会信息
|
// CMGuildInfo 我的公会信息
|
||||||
func (p *Player) CMGuildInfo(hdr *f5.MsgHdr, msg *cs.CMGuildInfo) {
|
func (p *Player) CMGuildInfo(hdr *f5.MsgHdr, msg *cs.CMGuildInfo) {
|
||||||
rspMsg := new(cs.SMGuildInfo)
|
rspMsg := new(cs.SMGuildInfo)
|
||||||
g := guildMgr.GetGuildByAccountId(p.accountId)
|
guild := guildMgr.GetGuildByAccountId(p.accountId)
|
||||||
if g == nil {
|
if guild == nil {
|
||||||
rspMsg.Guild = nil
|
rspMsg.Guild = nil
|
||||||
rspMsg.RandomGuilds = p.FillGuild(guildMgr.RandomGuilds())
|
rspMsg.RandomGuilds = p.FillGuild(guildMgr.RandomGuilds())
|
||||||
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
members := q5.ToInt32(len(g.Members))
|
membersCount := q5.ToInt32(len(guild.Members))
|
||||||
maxMembers := q5.ToInt32(g.MaxMembers)
|
maxMembers := q5.ToInt32(guild.MaxMembers)
|
||||||
currGuild := &cs.MFGuild{
|
|
||||||
AutoId: &g.AutoId,
|
rspGuild := &cs.MFGuild{
|
||||||
GuildId: &g.GuildId,
|
AutoId: &guild.AutoId,
|
||||||
Name: &g.Name,
|
GuildId: &guild.GuildId,
|
||||||
LeaderId: &g.LeaderId,
|
Name: &guild.Name,
|
||||||
Members: &members,
|
LeaderId: &guild.LeaderId,
|
||||||
|
MembersCount: &membersCount,
|
||||||
MaxMembers: &maxMembers,
|
MaxMembers: &maxMembers,
|
||||||
Notice: &g.Notice,
|
Notice: &guild.Notice,
|
||||||
}
|
}
|
||||||
rspMsg.Guild = currGuild
|
rspMsg.Guild = rspGuild
|
||||||
rspMsg.RandomGuilds = nil
|
rspMsg.RandomGuilds = nil
|
||||||
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||||
}
|
}
|
||||||
@ -516,14 +510,14 @@ func (p *Player) CMGuildLogs(hdr *f5.MsgHdr, msg *cs.CMGuildLogs) {
|
|||||||
func (p *Player) FillGuild(guilds []*Guild) []*cs.MFGuild {
|
func (p *Player) FillGuild(guilds []*Guild) []*cs.MFGuild {
|
||||||
var resGuilds []*cs.MFGuild
|
var resGuilds []*cs.MFGuild
|
||||||
for _, g := range guilds {
|
for _, g := range guilds {
|
||||||
members := q5.ToInt32(len(g.Members))
|
membersCount := q5.ToInt32(len(g.Members))
|
||||||
maxMembers := q5.ToInt32(g.MaxMembers)
|
maxMembers := q5.ToInt32(g.MaxMembers)
|
||||||
guild := &cs.MFGuild{
|
guild := &cs.MFGuild{
|
||||||
AutoId: &g.AutoId,
|
AutoId: &g.AutoId,
|
||||||
GuildId: &g.GuildId,
|
GuildId: &g.GuildId,
|
||||||
Name: &g.Name,
|
Name: &g.Name,
|
||||||
LeaderId: &g.LeaderId,
|
LeaderId: &g.LeaderId,
|
||||||
Members: &members,
|
MembersCount: &membersCount,
|
||||||
MaxMembers: &maxMembers,
|
MaxMembers: &maxMembers,
|
||||||
Notice: &g.Notice,
|
Notice: &g.Notice,
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,6 @@ message SMGuildInfo
|
|||||||
message CMCreateGuild
|
message CMCreateGuild
|
||||||
{
|
{
|
||||||
optional string name = 1;
|
optional string name = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 回复创建公会
|
// 回复创建公会
|
||||||
@ -501,7 +500,7 @@ message MFGuild {
|
|||||||
optional int64 guild_id = 2;
|
optional int64 guild_id = 2;
|
||||||
optional string name = 3;
|
optional string name = 3;
|
||||||
optional string leader_id = 4;
|
optional string leader_id = 4;
|
||||||
optional int32 members = 5;
|
optional int32 members_count = 5;
|
||||||
optional int32 max_members = 6;
|
optional int32 max_members = 6;
|
||||||
optional string notice = 7;
|
optional string notice = 7;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user