优化代码格式

This commit is contained in:
huangxiaolei
2022-12-08 18:23:41 +08:00
parent b836c0f8db
commit 3615ad194a
16 changed files with 720 additions and 727 deletions

View File

@@ -24,10 +24,6 @@ type GameManager struct {
netMsgInput chan *cmd.NetMsg netMsgInput chan *cmd.NetMsg
netMsgOutput chan *cmd.NetMsg netMsgOutput chan *cmd.NetMsg
snowflake *alg.SnowflakeWorker snowflake *alg.SnowflakeWorker
// 用户管理器
userManager *UserManager
// 世界管理器
worldManager *WorldManager
} }
func NewGameManager(dao *dao.Dao, netMsgInput chan *cmd.NetMsg, netMsgOutput chan *cmd.NetMsg) (r *GameManager) { func NewGameManager(dao *dao.Dao, netMsgInput chan *cmd.NetMsg, netMsgOutput chan *cmd.NetMsg) (r *GameManager) {
@@ -39,10 +35,8 @@ func NewGameManager(dao *dao.Dao, netMsgInput chan *cmd.NetMsg, netMsgOutput cha
GAME_MANAGER = r GAME_MANAGER = r
LOCAL_EVENT_MANAGER = NewLocalEventManager() LOCAL_EVENT_MANAGER = NewLocalEventManager()
ROUTE_MANAGER = NewRouteManager() ROUTE_MANAGER = NewRouteManager()
r.userManager = NewUserManager(dao, LOCAL_EVENT_MANAGER.localEventChan) USER_MANAGER = NewUserManager(dao, LOCAL_EVENT_MANAGER.localEventChan)
USER_MANAGER = r.userManager WORLD_MANAGER = NewWorldManager(r.snowflake)
r.worldManager = NewWorldManager(r.snowflake)
WORLD_MANAGER = r.worldManager
TICK_MANAGER = NewTickManager() TICK_MANAGER = NewTickManager()
COMMAND_MANAGER = NewCommandManager() COMMAND_MANAGER = NewCommandManager()
return r return r

View File

@@ -81,7 +81,7 @@ func (t *TickManager) onTick10Minute(now int64) {
} }
func (t *TickManager) onTickMinute(now int64) { func (t *TickManager) onTickMinute(now int64) {
//t.gameManager.ServerAnnounceNotify(100, "test123") //GAME_MANAGER.ServerAnnounceNotify(100, "test123")
for _, world := range WORLD_MANAGER.worldMap { for _, world := range WORLD_MANAGER.worldMap {
for _, player := range world.playerMap { for _, player := range world.playerMap {
// 随机物品 // 随机物品
@@ -117,17 +117,19 @@ func (t *TickManager) onTick10Second(now int64) {
for _, world := range WORLD_MANAGER.worldMap { for _, world := range WORLD_MANAGER.worldMap {
for _, scene := range world.sceneMap { for _, scene := range world.sceneMap {
for _, player := range scene.playerMap { for _, player := range scene.playerMap {
// PacketSceneTimeNotify
sceneTimeNotify := new(proto.SceneTimeNotify) sceneTimeNotify := &proto.SceneTimeNotify{
sceneTimeNotify.SceneId = player.SceneId SceneId: player.SceneId,
sceneTimeNotify.SceneTime = uint64(scene.GetSceneTime()) SceneTime: uint64(scene.GetSceneTime()),
GAME_MANAGER.SendMsg(cmd.SceneTimeNotify, player.PlayerID, player.ClientSeq, sceneTimeNotify) }
// PacketPlayerTimeNotify GAME_MANAGER.SendMsg(cmd.SceneTimeNotify, player.PlayerID, 0, sceneTimeNotify)
playerTimeNotify := new(proto.PlayerTimeNotify)
playerTimeNotify.IsPaused = player.Pause playerTimeNotify := &proto.PlayerTimeNotify{
playerTimeNotify.PlayerTime = uint64(player.TotalOnlineTime) IsPaused: player.Pause,
playerTimeNotify.ServerTime = uint64(time.Now().UnixMilli()) PlayerTime: uint64(player.TotalOnlineTime),
GAME_MANAGER.SendMsg(cmd.PlayerTimeNotify, player.PlayerID, player.ClientSeq, playerTimeNotify) ServerTime: uint64(time.Now().UnixMilli()),
}
GAME_MANAGER.SendMsg(cmd.PlayerTimeNotify, player.PlayerID, 0, playerTimeNotify)
} }
} }
if !world.IsBigWorld() && (world.multiplayer || !world.owner.Pause) { if !world.IsBigWorld() && (world.multiplayer || !world.owner.Pause) {
@@ -172,9 +174,12 @@ func (t *TickManager) onTick5Second(now int64) {
} }
for _, player := range world.playerMap { for _, player := range world.playerMap {
if world.multiplayer { if world.multiplayer {
scene := world.GetSceneById(player.SceneId)
// 多人世界其他玩家的坐标位置广播 // 多人世界其他玩家的坐标位置广播
// PacketWorldPlayerLocationNotify worldPlayerLocationNotify := &proto.WorldPlayerLocationNotify{
worldPlayerLocationNotify := new(proto.WorldPlayerLocationNotify) PlayerWorldLocList: make([]*proto.PlayerWorldLocationInfo, 0),
}
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.playerMap {
playerWorldLocationInfo := &proto.PlayerWorldLocationInfo{ playerWorldLocationInfo := &proto.PlayerWorldLocationInfo{
SceneId: worldPlayer.SceneId, SceneId: worldPlayer.SceneId,
@@ -196,10 +201,10 @@ func (t *TickManager) onTick5Second(now int64) {
} }
GAME_MANAGER.SendMsg(cmd.WorldPlayerLocationNotify, player.PlayerID, 0, worldPlayerLocationNotify) GAME_MANAGER.SendMsg(cmd.WorldPlayerLocationNotify, player.PlayerID, 0, worldPlayerLocationNotify)
// PacketScenePlayerLocationNotify scenePlayerLocationNotify := &proto.ScenePlayerLocationNotify{
scene := world.GetSceneById(player.SceneId) SceneId: player.SceneId,
scenePlayerLocationNotify := new(proto.ScenePlayerLocationNotify) PlayerLocList: make([]*proto.PlayerLocationInfo, 0),
scenePlayerLocationNotify.SceneId = player.SceneId }
for _, scenePlayer := range scene.playerMap { for _, scenePlayer := range scene.playerMap {
playerLocationInfo := &proto.PlayerLocationInfo{ playerLocationInfo := &proto.PlayerLocationInfo{
Uid: scenePlayer.PlayerID, Uid: scenePlayer.PlayerID,
@@ -226,9 +231,9 @@ func (t *TickManager) onTickSecond(now int64) {
for _, world := range WORLD_MANAGER.worldMap { for _, world := range WORLD_MANAGER.worldMap {
for _, player := range world.playerMap { for _, player := range world.playerMap {
// 世界里所有玩家的网络延迟广播 // 世界里所有玩家的网络延迟广播
// PacketWorldPlayerRTTNotify worldPlayerRTTNotify := &proto.WorldPlayerRTTNotify{
worldPlayerRTTNotify := new(proto.WorldPlayerRTTNotify) PlayerRttList: make([]*proto.PlayerRTTInfo, 0),
worldPlayerRTTNotify.PlayerRttList = make([]*proto.PlayerRTTInfo, 0) }
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.playerMap {
playerRTTInfo := &proto.PlayerRTTInfo{Uid: worldPlayer.PlayerID, Rtt: worldPlayer.ClientRTT} playerRTTInfo := &proto.PlayerRTTInfo{Uid: worldPlayer.PlayerID, Rtt: worldPlayer.ClientRTT}
worldPlayerRTTNotify.PlayerRttList = append(worldPlayerRTTNotify.PlayerRttList, playerRTTInfo) worldPlayerRTTNotify.PlayerRttList = append(worldPlayerRTTNotify.PlayerRttList, playerRTTInfo)

View File

@@ -29,7 +29,7 @@ func (g *GameManager) GetAllAvatarDataConfig() map[int32]*gdc.AvatarData {
} }
func (g *GameManager) AddUserAvatar(userId uint32, avatarId uint32) { func (g *GameManager) AddUserAvatar(userId uint32, avatarId uint32) {
player := g.userManager.GetOnlineUser(userId) player := USER_MANAGER.GetOnlineUser(userId)
if player == nil { if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId) logger.LOG.Error("player is nil, uid: %v", userId)
return return
@@ -52,13 +52,12 @@ func (g *GameManager) AddUserAvatar(userId uint32, avatarId uint32) {
// 角色装上初始武器 // 角色装上初始武器
g.WearUserAvatarEquip(player.PlayerID, avatarId, weaponId) g.WearUserAvatarEquip(player.PlayerID, avatarId, weaponId)
// TODO 真的有必要存在吗
g.UpdateUserAvatarFightProp(player.PlayerID, avatarId) g.UpdateUserAvatarFightProp(player.PlayerID, avatarId)
// PacketAvatarAddNotify avatarAddNotify := &proto.AvatarAddNotify{
avatarAddNotify := new(proto.AvatarAddNotify) Avatar: g.PacketAvatarInfo(avatar),
avatarAddNotify.Avatar = g.PacketAvatarInfo(avatar) IsInTeam: false,
avatarAddNotify.IsInTeam = false }
g.SendMsg(cmd.AvatarAddNotify, userId, player.ClientSeq, avatarAddNotify) g.SendMsg(cmd.AvatarAddNotify, userId, player.ClientSeq, avatarAddNotify)
} }
@@ -71,15 +70,15 @@ func (g *GameManager) WearEquipReq(player *model.Player, payloadMsg pb.Message)
weapon := player.GameObjectGuidMap[equipGuid].(*model.Weapon) weapon := player.GameObjectGuidMap[equipGuid].(*model.Weapon)
g.WearUserAvatarEquip(player.PlayerID, avatar.AvatarId, weapon.WeaponId) g.WearUserAvatarEquip(player.PlayerID, avatar.AvatarId, weapon.WeaponId)
// PacketWearEquipRsp wearEquipRsp := &proto.WearEquipRsp{
wearEquipRsp := new(proto.WearEquipRsp) AvatarGuid: avatarGuid,
wearEquipRsp.AvatarGuid = avatarGuid EquipGuid: equipGuid,
wearEquipRsp.EquipGuid = equipGuid }
g.SendMsg(cmd.WearEquipRsp, player.PlayerID, player.ClientSeq, wearEquipRsp) g.SendMsg(cmd.WearEquipRsp, player.PlayerID, player.ClientSeq, wearEquipRsp)
} }
func (g *GameManager) WearUserAvatarEquip(userId uint32, avatarId uint32, weaponId uint64) { func (g *GameManager) WearUserAvatarEquip(userId uint32, avatarId uint32, weaponId uint64) {
player := g.userManager.GetOnlineUser(userId) player := USER_MANAGER.GetOnlineUser(userId)
if player == nil { if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId) logger.LOG.Error("player is nil, uid: %v", userId)
return return
@@ -87,7 +86,7 @@ func (g *GameManager) WearUserAvatarEquip(userId uint32, avatarId uint32, weapon
avatar := player.AvatarMap[avatarId] avatar := player.AvatarMap[avatarId]
weapon := player.WeaponMap[weaponId] weapon := player.WeaponMap[weaponId]
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
playerTeamEntity := scene.GetPlayerTeamEntity(player.PlayerID) playerTeamEntity := scene.GetPlayerTeamEntity(player.PlayerID)
team := player.TeamConfig.GetActiveTeam() team := player.TeamConfig.GetActiveTeam()
@@ -115,7 +114,6 @@ func (g *GameManager) WearUserAvatarEquip(userId uint32, avatarId uint32, weapon
} }
} }
// PacketAvatarEquipChangeNotify
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(weakAvatar, weakWeapon, playerTeamEntity.weaponEntityMap[weakWeapon.WeaponId]) avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(weakAvatar, weakWeapon, playerTeamEntity.weaponEntityMap[weakWeapon.WeaponId])
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify) g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
} else if avatar.EquipWeapon != nil { } else if avatar.EquipWeapon != nil {
@@ -136,7 +134,6 @@ func (g *GameManager) WearUserAvatarEquip(userId uint32, avatarId uint32, weapon
} }
} }
// PacketAvatarEquipChangeNotify
avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(avatar, weapon, playerTeamEntity.weaponEntityMap[weaponId]) avatarEquipChangeNotify := g.PacketAvatarEquipChangeNotify(avatar, weapon, playerTeamEntity.weaponEntityMap[weaponId])
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify) g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
} }
@@ -163,20 +160,19 @@ func (g *GameManager) AvatarChangeCostumeReq(player *model.Player, payloadMsg pb
avatar := player.GameObjectGuidMap[avatarGuid].(*model.Avatar) avatar := player.GameObjectGuidMap[avatarGuid].(*model.Avatar)
avatar.Costume = req.CostumeId avatar.Costume = req.CostumeId
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
// PacketAvatarChangeCostumeNotify
avatarChangeCostumeNotify := new(proto.AvatarChangeCostumeNotify) avatarChangeCostumeNotify := new(proto.AvatarChangeCostumeNotify)
avatarChangeCostumeNotify.EntityInfo = g.PacketSceneEntityInfoAvatar(scene, player, avatar.AvatarId) avatarChangeCostumeNotify.EntityInfo = g.PacketSceneEntityInfoAvatar(scene, player, avatar.AvatarId)
for _, scenePlayer := range scene.playerMap { for _, scenePlayer := range scene.playerMap {
g.SendMsg(cmd.AvatarChangeCostumeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, avatarChangeCostumeNotify) g.SendMsg(cmd.AvatarChangeCostumeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, avatarChangeCostumeNotify)
} }
// PacketAvatarChangeCostumeRsp avatarChangeCostumeRsp := &proto.AvatarChangeCostumeRsp{
avatarChangeCostumeRsp := new(proto.AvatarChangeCostumeRsp) AvatarGuid: req.AvatarGuid,
avatarChangeCostumeRsp.AvatarGuid = req.AvatarGuid CostumeId: req.CostumeId,
avatarChangeCostumeRsp.CostumeId = req.CostumeId }
g.SendMsg(cmd.AvatarChangeCostumeRsp, player.PlayerID, player.ClientSeq, avatarChangeCostumeRsp) g.SendMsg(cmd.AvatarChangeCostumeRsp, player.PlayerID, player.ClientSeq, avatarChangeCostumeRsp)
} }
@@ -199,33 +195,30 @@ func (g *GameManager) AvatarWearFlycloakReq(player *model.Player, payloadMsg pb.
avatar := player.GameObjectGuidMap[avatarGuid].(*model.Avatar) avatar := player.GameObjectGuidMap[avatarGuid].(*model.Avatar)
avatar.FlyCloak = req.FlycloakId avatar.FlyCloak = req.FlycloakId
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
// PacketAvatarFlycloakChangeNotify avatarFlycloakChangeNotify := &proto.AvatarFlycloakChangeNotify{
avatarFlycloakChangeNotify := new(proto.AvatarFlycloakChangeNotify) AvatarGuid: avatarGuid,
avatarFlycloakChangeNotify.AvatarGuid = avatarGuid FlycloakId: flycloakId,
avatarFlycloakChangeNotify.FlycloakId = flycloakId }
for _, scenePlayer := range scene.playerMap { for _, scenePlayer := range scene.playerMap {
g.SendMsg(cmd.AvatarFlycloakChangeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, avatarFlycloakChangeNotify) g.SendMsg(cmd.AvatarFlycloakChangeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, avatarFlycloakChangeNotify)
} }
// PacketAvatarWearFlycloakRsp avatarWearFlycloakRsp := &proto.AvatarWearFlycloakRsp{
avatarWearFlycloakRsp := new(proto.AvatarWearFlycloakRsp) AvatarGuid: req.AvatarGuid,
avatarWearFlycloakRsp.AvatarGuid = req.AvatarGuid FlycloakId: req.FlycloakId,
avatarWearFlycloakRsp.FlycloakId = req.FlycloakId }
g.SendMsg(cmd.AvatarWearFlycloakRsp, player.PlayerID, player.ClientSeq, avatarWearFlycloakRsp) g.SendMsg(cmd.AvatarWearFlycloakRsp, player.PlayerID, player.ClientSeq, avatarWearFlycloakRsp)
} }
func (g *GameManager) PacketAvatarEquipChangeNotify(avatar *model.Avatar, weapon *model.Weapon, entityId uint32) *proto.AvatarEquipChangeNotify { func (g *GameManager) PacketAvatarEquipChangeNotify(avatar *model.Avatar, weapon *model.Weapon, entityId uint32) *proto.AvatarEquipChangeNotify {
itemDataConfig, ok := gdc.CONF.ItemDataMap[int32(weapon.ItemId)] avatarEquipChangeNotify := &proto.AvatarEquipChangeNotify{
avatarEquipChangeNotify := new(proto.AvatarEquipChangeNotify) AvatarGuid: avatar.Guid,
avatarEquipChangeNotify.AvatarGuid = avatar.Guid ItemId: weapon.ItemId,
if ok { EquipGuid: weapon.Guid,
avatarEquipChangeNotify.EquipType = uint32(itemDataConfig.EquipEnumType)
} }
avatarEquipChangeNotify.ItemId = weapon.ItemId
avatarEquipChangeNotify.EquipGuid = weapon.Guid
avatarEquipChangeNotify.Weapon = &proto.SceneWeaponInfo{ avatarEquipChangeNotify.Weapon = &proto.SceneWeaponInfo{
EntityId: entityId, EntityId: entityId,
GadgetId: uint32(gdc.CONF.ItemDataMap[int32(weapon.ItemId)].GadgetId), GadgetId: uint32(gdc.CONF.ItemDataMap[int32(weapon.ItemId)].GadgetId),
@@ -234,12 +227,17 @@ func (g *GameManager) PacketAvatarEquipChangeNotify(avatar *model.Avatar, weapon
Level: uint32(weapon.Level), Level: uint32(weapon.Level),
AbilityInfo: new(proto.AbilitySyncStateInfo), AbilityInfo: new(proto.AbilitySyncStateInfo),
} }
itemDataConfig, ok := gdc.CONF.ItemDataMap[int32(weapon.ItemId)]
if ok {
avatarEquipChangeNotify.EquipType = uint32(itemDataConfig.EquipEnumType)
}
return avatarEquipChangeNotify return avatarEquipChangeNotify
} }
func (g *GameManager) PacketAvatarEquipTakeOffNotify(avatar *model.Avatar, weapon *model.Weapon) *proto.AvatarEquipChangeNotify { func (g *GameManager) PacketAvatarEquipTakeOffNotify(avatar *model.Avatar, weapon *model.Weapon) *proto.AvatarEquipChangeNotify {
avatarEquipChangeNotify := new(proto.AvatarEquipChangeNotify) avatarEquipChangeNotify := &proto.AvatarEquipChangeNotify{
avatarEquipChangeNotify.AvatarGuid = avatar.Guid AvatarGuid: avatar.Guid,
}
itemDataConfig, ok := gdc.CONF.ItemDataMap[int32(weapon.ItemId)] itemDataConfig, ok := gdc.CONF.ItemDataMap[int32(weapon.ItemId)]
if ok { if ok {
avatarEquipChangeNotify.EquipType = uint32(itemDataConfig.EquipEnumType) avatarEquipChangeNotify.EquipType = uint32(itemDataConfig.EquipEnumType)
@@ -248,15 +246,16 @@ func (g *GameManager) PacketAvatarEquipTakeOffNotify(avatar *model.Avatar, weapo
} }
func (g *GameManager) UpdateUserAvatarFightProp(userId uint32, avatarId uint32) { func (g *GameManager) UpdateUserAvatarFightProp(userId uint32, avatarId uint32) {
player := g.userManager.GetOnlineUser(userId) player := USER_MANAGER.GetOnlineUser(userId)
if player == nil { if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId) logger.LOG.Error("player is nil, uid: %v", userId)
return return
} }
avatarFightPropNotify := new(proto.AvatarFightPropNotify)
avatar := player.AvatarMap[avatarId] avatar := player.AvatarMap[avatarId]
avatarFightPropNotify.AvatarGuid = avatar.Guid avatarFightPropNotify := &proto.AvatarFightPropNotify{
avatarFightPropNotify.FightPropMap = avatar.FightPropMap AvatarGuid: avatar.Guid,
FightPropMap: avatar.FightPropMap,
}
g.SendMsg(cmd.AvatarFightPropNotify, userId, player.ClientSeq, avatarFightPropNotify) g.SendMsg(cmd.AvatarFightPropNotify, userId, player.ClientSeq, avatarFightPropNotify)
} }
@@ -303,7 +302,6 @@ func (g *GameManager) PacketAvatarInfo(avatar *model.Avatar) *proto.AvatarInfo {
FetterInfo: &proto.AvatarFetterInfo{ FetterInfo: &proto.AvatarFetterInfo{
ExpLevel: uint32(avatar.FetterLevel), ExpLevel: uint32(avatar.FetterLevel),
ExpNumber: avatar.FetterExp, ExpNumber: avatar.FetterExp,
// FetterList 不知道是啥 该角色在配置表里的所有FetterId
// TODO 资料解锁条目 // TODO 资料解锁条目
FetterList: nil, FetterList: nil,
RewardedFetterLevelList: []uint32{10}, RewardedFetterLevelList: []uint32{10},

View File

@@ -29,7 +29,7 @@ func (g *GameManager) PullRecentChatReq(player *model.Player, payloadMsg pb.Mess
} }
} }
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world.multiplayer { if world.multiplayer {
chatList := world.GetChatList() chatList := world.GetChatList()
count := len(chatList) count := len(chatList)
@@ -37,18 +37,18 @@ func (g *GameManager) PullRecentChatReq(player *model.Player, payloadMsg pb.Mess
count = 10 count = 10
} }
for i := len(chatList) - count; i < len(chatList); i++ { for i := len(chatList) - count; i < len(chatList); i++ {
// PacketPlayerChatNotify playerChatNotify := &proto.PlayerChatNotify{
playerChatNotify := new(proto.PlayerChatNotify) ChannelId: 0,
playerChatNotify.ChannelId = 0 ChatInfo: chatList[i],
playerChatNotify.ChatInfo = chatList[i] }
g.SendMsg(cmd.PlayerChatNotify, player.PlayerID, 0, playerChatNotify) g.SendMsg(cmd.PlayerChatNotify, player.PlayerID, player.ClientSeq, playerChatNotify)
} }
} }
// PacketPullRecentChatRsp pullRecentChatRsp := &proto.PullRecentChatRsp{
pullRecentChatRsp := new(proto.PullRecentChatRsp) ChatInfo: retMsgList,
pullRecentChatRsp.ChatInfo = retMsgList }
g.SendMsg(cmd.PullRecentChatRsp, player.PlayerID, 0, pullRecentChatRsp) g.SendMsg(cmd.PullRecentChatRsp, player.PlayerID, player.ClientSeq, pullRecentChatRsp)
} }
func (g *GameManager) PullPrivateChatReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) PullPrivateChatReq(player *model.Player, payloadMsg pb.Message) {
@@ -71,10 +71,10 @@ func (g *GameManager) PullPrivateChatReq(player *model.Player, payloadMsg pb.Mes
retMsgList = append(retMsgList, g.ConvChatMsgToChatInfo(chatMsg)) retMsgList = append(retMsgList, g.ConvChatMsgToChatInfo(chatMsg))
} }
// PacketPullPrivateChatRsp pullPrivateChatRsp := &proto.PullPrivateChatRsp{
pullPrivateChatRsp := new(proto.PullPrivateChatRsp) ChatInfo: retMsgList,
pullPrivateChatRsp.ChatInfo = retMsgList }
g.SendMsg(cmd.PullPrivateChatRsp, player.PlayerID, 0, pullPrivateChatRsp) g.SendMsg(cmd.PullPrivateChatRsp, player.PlayerID, player.ClientSeq, pullPrivateChatRsp)
} }
// SendPrivateChat 发送私聊文本消息给玩家 // SendPrivateChat 发送私聊文本消息给玩家
@@ -119,16 +119,16 @@ func (g *GameManager) SendPrivateChat(player, targetPlayer *model.Player, conten
// 如果目标玩家在线发送消息 // 如果目标玩家在线发送消息
if targetPlayer.Online { if targetPlayer.Online {
// PacketPrivateChatNotify privateChatNotify := &proto.PrivateChatNotify{
privateChatNotify := new(proto.PrivateChatNotify) ChatInfo: chatInfo,
privateChatNotify.ChatInfo = chatInfo }
g.SendMsg(cmd.PrivateChatNotify, targetPlayer.PlayerID, 0, privateChatNotify) g.SendMsg(cmd.PrivateChatNotify, targetPlayer.PlayerID, player.ClientSeq, privateChatNotify)
} }
// PacketPrivateChatNotify privateChatNotify := &proto.PrivateChatNotify{
privateChatNotify := new(proto.PrivateChatNotify) ChatInfo: chatInfo,
privateChatNotify.ChatInfo = chatInfo }
g.SendMsg(cmd.PrivateChatNotify, player.PlayerID, 0, privateChatNotify) g.SendMsg(cmd.PrivateChatNotify, player.PlayerID, player.ClientSeq, privateChatNotify)
} }
func (g *GameManager) PrivateChatReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) PrivateChatReq(player *model.Player, payloadMsg pb.Message) {
@@ -138,7 +138,7 @@ func (g *GameManager) PrivateChatReq(player *model.Player, payloadMsg pb.Message
content := req.Content content := req.Content
// TODO 同步阻塞待优化 // TODO 同步阻塞待优化
targetPlayer := g.userManager.LoadTempOfflineUserSync(targetUid) targetPlayer := USER_MANAGER.LoadTempOfflineUserSync(targetUid)
if targetPlayer == nil { if targetPlayer == nil {
return return
} }
@@ -167,9 +167,7 @@ func (g *GameManager) PrivateChatReq(player *model.Player, payloadMsg pb.Message
return return
} }
// PacketPrivateChatRsp g.SendMsg(cmd.PrivateChatRsp, player.PlayerID, player.ClientSeq, new(proto.PrivateChatRsp))
privateChatRsp := new(proto.PrivateChatRsp)
g.SendMsg(cmd.PrivateChatRsp, player.PlayerID, 0, privateChatRsp)
} }
func (g *GameManager) ReadPrivateChatReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) ReadPrivateChatReq(player *model.Player, payloadMsg pb.Message) {
@@ -187,9 +185,7 @@ func (g *GameManager) ReadPrivateChatReq(player *model.Player, payloadMsg pb.Mes
} }
player.ChatMsgMap[targetUid] = msgList player.ChatMsgMap[targetUid] = msgList
// PacketReadPrivateChatRsp g.SendMsg(cmd.ReadPrivateChatRsp, player.PlayerID, player.ClientSeq, new(proto.ReadPrivateChatRsp))
readPrivateChatRsp := new(proto.ReadPrivateChatRsp)
g.SendMsg(cmd.ReadPrivateChatRsp, player.PlayerID, 0, readPrivateChatRsp)
} }
func (g *GameManager) PlayerChatReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) PlayerChatReq(player *model.Player, payloadMsg pb.Message) {
@@ -221,20 +217,18 @@ func (g *GameManager) PlayerChatReq(player *model.Player, payloadMsg pb.Message)
return return
} }
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
world.AddChat(sendChatInfo) world.AddChat(sendChatInfo)
// PacketPlayerChatNotify playerChatNotify := &proto.PlayerChatNotify{
playerChatNotify := new(proto.PlayerChatNotify) ChannelId: channelId,
playerChatNotify.ChannelId = channelId ChatInfo: sendChatInfo,
playerChatNotify.ChatInfo = sendChatInfo }
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.playerMap {
g.SendMsg(cmd.PlayerChatNotify, worldPlayer.PlayerID, 0, playerChatNotify) g.SendMsg(cmd.PlayerChatNotify, worldPlayer.PlayerID, player.ClientSeq, playerChatNotify)
} }
// PacketPlayerChatRsp g.SendMsg(cmd.PlayerChatRsp, player.PlayerID, player.ClientSeq, new(proto.PlayerChatRsp))
playerChatRsp := new(proto.PlayerChatRsp)
g.SendMsg(cmd.PlayerChatRsp, player.PlayerID, 0, playerChatRsp)
} }
func (g *GameManager) ConvChatInfoToChatMsg(chatInfo *proto.ChatInfo) (chatMsg *model.ChatMsg) { func (g *GameManager) ConvChatInfoToChatMsg(chatInfo *proto.ChatInfo) (chatMsg *model.ChatMsg) {

View File

@@ -13,7 +13,7 @@ func (g *GameManager) UnionCmdNotify(player *model.Player, payloadMsg pb.Message
//logger.LOG.Debug("user send union cmd, uid: %v", player.PlayerID) //logger.LOG.Debug("user send union cmd, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.UnionCmdNotify) req := payloadMsg.(*proto.UnionCmdNotify)
_ = req _ = req
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world == nil { if world == nil {
return return
} }
@@ -29,13 +29,12 @@ func (g *GameManager) UnionCmdNotify(player *model.Player, payloadMsg pb.Message
continue continue
} }
if entity.avatarEntity != nil { if entity.avatarEntity != nil {
otherPlayer := g.userManager.GetOnlineUser(entity.avatarEntity.uid) otherPlayer := USER_MANAGER.GetOnlineUser(entity.avatarEntity.uid)
surrPlayerList = append(surrPlayerList, otherPlayer) surrPlayerList = append(surrPlayerList, otherPlayer)
} }
} }
// CombatInvocationsNotify转发 // CombatInvocationsNotify转发
// PacketCombatInvocationsNotify
if player.CombatInvokeHandler.AllLen() > 0 { if player.CombatInvokeHandler.AllLen() > 0 {
combatInvocationsNotify := new(proto.CombatInvocationsNotify) combatInvocationsNotify := new(proto.CombatInvocationsNotify)
combatInvocationsNotify.InvokeList = player.CombatInvokeHandler.EntryListForwardAll combatInvocationsNotify.InvokeList = player.CombatInvokeHandler.EntryListForwardAll
@@ -60,7 +59,6 @@ func (g *GameManager) UnionCmdNotify(player *model.Player, payloadMsg pb.Message
} }
// AbilityInvocationsNotify转发 // AbilityInvocationsNotify转发
// PacketAbilityInvocationsNotify
if player.AbilityInvokeHandler.AllLen() > 0 { if player.AbilityInvokeHandler.AllLen() > 0 {
abilityInvocationsNotify := new(proto.AbilityInvocationsNotify) abilityInvocationsNotify := new(proto.AbilityInvocationsNotify)
abilityInvocationsNotify.Invokes = player.AbilityInvokeHandler.EntryListForwardAll abilityInvocationsNotify.Invokes = player.AbilityInvokeHandler.EntryListForwardAll
@@ -92,7 +90,7 @@ func (g *GameManager) MassiveEntityElementOpBatchNotify(player *model.Player, pa
//logger.LOG.Debug("user meeo sync, uid: %v", player.PlayerID) //logger.LOG.Debug("user meeo sync, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.MassiveEntityElementOpBatchNotify) req := payloadMsg.(*proto.MassiveEntityElementOpBatchNotify)
ntf := req ntf := req
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world == nil { if world == nil {
return return
} }
@@ -110,7 +108,7 @@ func (g *GameManager) MassiveEntityElementOpBatchNotify(player *model.Player, pa
continue continue
} }
if entity.avatarEntity != nil { if entity.avatarEntity != nil {
otherPlayer := g.userManager.GetOnlineUser(entity.avatarEntity.uid) otherPlayer := USER_MANAGER.GetOnlineUser(entity.avatarEntity.uid)
surrPlayerList = append(surrPlayerList, otherPlayer) surrPlayerList = append(surrPlayerList, otherPlayer)
} }
} }
@@ -123,7 +121,7 @@ func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg p
//logger.LOG.Debug("user combat invocations, uid: %v", player.PlayerID) //logger.LOG.Debug("user combat invocations, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.CombatInvocationsNotify) req := payloadMsg.(*proto.CombatInvocationsNotify)
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world == nil { if world == nil {
return return
} }
@@ -225,11 +223,11 @@ func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg p
world.aoiManager.AddEntityIdToGrid(playerActiveAvatarEntityId, newGid) world.aoiManager.AddEntityIdToGrid(playerActiveAvatarEntityId, newGid)
// 其他玩家 // 其他玩家
for _, uid := range delUidList { for _, uid := range delUidList {
otherPlayer := g.userManager.GetOnlineUser(uid) otherPlayer := USER_MANAGER.GetOnlineUser(uid)
g.RemoveSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_TYPE_REMOVE, []uint32{playerActiveAvatarEntityId}) g.RemoveSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_TYPE_REMOVE, []uint32{playerActiveAvatarEntityId})
} }
for _, uid := range addUidList { for _, uid := range addUidList {
otherPlayer := g.userManager.GetOnlineUser(uid) otherPlayer := USER_MANAGER.GetOnlineUser(uid)
g.AddSceneEntityNotify(otherPlayer, proto.VisionType_VISION_TYPE_BORN, []uint32{playerActiveAvatarEntityId}, false) g.AddSceneEntityNotify(otherPlayer, proto.VisionType_VISION_TYPE_BORN, []uint32{playerActiveAvatarEntityId}, false)
} }
} }
@@ -351,7 +349,7 @@ func (g *GameManager) ClientAbilityInitFinishNotify(player *model.Player, payloa
invokeHandler.AddEntry(entry.ForwardType, entry) invokeHandler.AddEntry(entry.ForwardType, entry)
} }
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world == nil { if world == nil {
return return
} }
@@ -367,13 +365,12 @@ func (g *GameManager) ClientAbilityInitFinishNotify(player *model.Player, payloa
continue continue
} }
if entity.avatarEntity != nil { if entity.avatarEntity != nil {
otherPlayer := g.userManager.GetOnlineUser(entity.avatarEntity.uid) otherPlayer := USER_MANAGER.GetOnlineUser(entity.avatarEntity.uid)
surrPlayerList = append(surrPlayerList, otherPlayer) surrPlayerList = append(surrPlayerList, otherPlayer)
} }
} }
// ClientAbilityInitFinishNotify转发 // ClientAbilityInitFinishNotify转发
// PacketClientAbilityInitFinishNotify
if invokeHandler.AllLen() == 0 && invokeHandler.AllExceptCurLen() == 0 && invokeHandler.HostLen() == 0 { if invokeHandler.AllLen() == 0 && invokeHandler.AllExceptCurLen() == 0 && invokeHandler.HostLen() == 0 {
for _, v := range surrPlayerList { for _, v := range surrPlayerList {
if player.PlayerID == v.PlayerID { if player.PlayerID == v.PlayerID {
@@ -418,7 +415,7 @@ func (g *GameManager) ClientAbilityChangeNotify(player *model.Player, payloadMsg
for _, entry := range req.Invokes { for _, entry := range req.Invokes {
invokeHandler.AddEntry(entry.ForwardType, entry) invokeHandler.AddEntry(entry.ForwardType, entry)
} }
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world == nil { if world == nil {
return return
} }
@@ -434,13 +431,12 @@ func (g *GameManager) ClientAbilityChangeNotify(player *model.Player, payloadMsg
continue continue
} }
if entity.avatarEntity != nil { if entity.avatarEntity != nil {
otherPlayer := g.userManager.GetOnlineUser(entity.avatarEntity.uid) otherPlayer := USER_MANAGER.GetOnlineUser(entity.avatarEntity.uid)
surrPlayerList = append(surrPlayerList, otherPlayer) surrPlayerList = append(surrPlayerList, otherPlayer)
} }
} }
// ClientAbilityChangeNotify转发 // ClientAbilityChangeNotify转发
// PacketClientAbilityChangeNotify
if invokeHandler.AllLen() == 0 && invokeHandler.AllExceptCurLen() == 0 && invokeHandler.HostLen() == 0 { if invokeHandler.AllLen() == 0 && invokeHandler.AllExceptCurLen() == 0 && invokeHandler.HostLen() == 0 {
clientAbilityChangeNotify := new(proto.ClientAbilityChangeNotify) clientAbilityChangeNotify := new(proto.ClientAbilityChangeNotify)
clientAbilityChangeNotify.EntityId = req.EntityId clientAbilityChangeNotify.EntityId = req.EntityId

View File

@@ -15,29 +15,27 @@ func (g *GameManager) PlayerSetPauseReq(player *model.Player, payloadMsg pb.Mess
logger.LOG.Debug("user pause, uid: %v", player.PlayerID) logger.LOG.Debug("user pause, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.PlayerSetPauseReq) req := payloadMsg.(*proto.PlayerSetPauseReq)
isPaused := req.IsPaused isPaused := req.IsPaused
player.Pause = isPaused player.Pause = isPaused
// PacketPlayerSetPauseRsp g.SendMsg(cmd.PlayerSetPauseRsp, player.PlayerID, player.ClientSeq, new(proto.PlayerSetPauseRsp))
playerSetPauseRsp := new(proto.PlayerSetPauseRsp)
g.SendMsg(cmd.PlayerSetPauseRsp, player.PlayerID, player.ClientSeq, playerSetPauseRsp)
} }
func (g *GameManager) TowerAllDataReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) TowerAllDataReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user get tower all data, uid: %v", player.PlayerID) logger.LOG.Debug("user get tower all data, uid: %v", player.PlayerID)
// PacketTowerAllDataRsp towerAllDataRsp := &proto.TowerAllDataRsp{
towerAllDataRsp := new(proto.TowerAllDataRsp) TowerScheduleId: 29,
towerAllDataRsp.TowerScheduleId = 29 TowerFloorRecordList: []*proto.TowerFloorRecord{{FloorId: 1001}},
towerAllDataRsp.TowerFloorRecordList = []*proto.TowerFloorRecord{{FloorId: 1001}} CurLevelRecord: &proto.TowerCurLevelRecord{IsEmpty: true},
towerAllDataRsp.CurLevelRecord = &proto.TowerCurLevelRecord{IsEmpty: true} NextScheduleChangeTime: 4294967295,
towerAllDataRsp.NextScheduleChangeTime = 4294967295 FloorOpenTimeMap: map[uint32]uint32{
towerAllDataRsp.FloorOpenTimeMap = make(map[uint32]uint32) 1024: 1630486800,
towerAllDataRsp.FloorOpenTimeMap[1024] = 1630486800 1025: 1630486800,
towerAllDataRsp.FloorOpenTimeMap[1025] = 1630486800 1026: 1630486800,
towerAllDataRsp.FloorOpenTimeMap[1026] = 1630486800 1027: 1630486800,
towerAllDataRsp.FloorOpenTimeMap[1027] = 1630486800 },
towerAllDataRsp.ScheduleStartTime = 1630486800 ScheduleStartTime: 1630486800,
}
g.SendMsg(cmd.TowerAllDataRsp, player.PlayerID, player.ClientSeq, towerAllDataRsp) g.SendMsg(cmd.TowerAllDataRsp, player.PlayerID, player.ClientSeq, towerAllDataRsp)
} }
@@ -45,9 +43,9 @@ func (g *GameManager) EntityAiSyncNotify(player *model.Player, payloadMsg pb.Mes
logger.LOG.Debug("user entity ai sync, uid: %v", player.PlayerID) logger.LOG.Debug("user entity ai sync, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.EntityAiSyncNotify) req := payloadMsg.(*proto.EntityAiSyncNotify)
// PacketEntityAiSyncNotify entityAiSyncNotify := &proto.EntityAiSyncNotify{
entityAiSyncNotify := new(proto.EntityAiSyncNotify) InfoList: make([]*proto.AiSyncInfo, 0),
entityAiSyncNotify.InfoList = make([]*proto.AiSyncInfo, 0) }
for _, monsterId := range req.LocalAvatarAlertedMonsterList { for _, monsterId := range req.LocalAvatarAlertedMonsterList {
entityAiSyncNotify.InfoList = append(entityAiSyncNotify.InfoList, &proto.AiSyncInfo{ entityAiSyncNotify.InfoList = append(entityAiSyncNotify.InfoList, &proto.AiSyncInfo{
EntityId: monsterId, EntityId: monsterId,
@@ -59,7 +57,7 @@ func (g *GameManager) EntityAiSyncNotify(player *model.Player, payloadMsg pb.Mes
} }
func (g *GameManager) ClientTimeNotify(userId uint32, clientTime uint32) { func (g *GameManager) ClientTimeNotify(userId uint32, clientTime uint32) {
player := g.userManager.GetOnlineUser(userId) player := USER_MANAGER.GetOnlineUser(userId)
if player == nil { if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId) logger.LOG.Error("player is nil, uid: %v", userId)
return return
@@ -69,7 +67,7 @@ func (g *GameManager) ClientTimeNotify(userId uint32, clientTime uint32) {
} }
func (g *GameManager) ClientRttNotify(userId uint32, clientRtt uint32) { func (g *GameManager) ClientRttNotify(userId uint32, clientRtt uint32) {
player := g.userManager.GetOnlineUser(userId) player := USER_MANAGER.GetOnlineUser(userId)
if player == nil { if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId) logger.LOG.Error("player is nil, uid: %v", userId)
return return
@@ -79,24 +77,26 @@ func (g *GameManager) ClientRttNotify(userId uint32, clientRtt uint32) {
} }
func (g *GameManager) ServerAnnounceNotify(announceId uint32, announceMsg string) { func (g *GameManager) ServerAnnounceNotify(announceId uint32, announceMsg string) {
for _, onlinePlayer := range g.userManager.GetAllOnlineUserList() { for _, onlinePlayer := range USER_MANAGER.GetAllOnlineUserList() {
serverAnnounceNotify := new(proto.ServerAnnounceNotify)
now := uint32(time.Now().Unix()) now := uint32(time.Now().Unix())
serverAnnounceNotify.AnnounceDataList = []*proto.AnnounceData{{ serverAnnounceNotify := &proto.ServerAnnounceNotify{
ConfigId: announceId, AnnounceDataList: []*proto.AnnounceData{{
BeginTime: now + 1, ConfigId: announceId,
EndTime: now + 2, BeginTime: now + 1,
CenterSystemText: announceMsg, EndTime: now + 2,
CenterSystemFrequency: 1, CenterSystemText: announceMsg,
}} CenterSystemFrequency: 1,
}},
}
g.SendMsg(cmd.ServerAnnounceNotify, onlinePlayer.PlayerID, 0, serverAnnounceNotify) g.SendMsg(cmd.ServerAnnounceNotify, onlinePlayer.PlayerID, 0, serverAnnounceNotify)
} }
} }
func (g *GameManager) ServerAnnounceRevokeNotify(announceId uint32) { func (g *GameManager) ServerAnnounceRevokeNotify(announceId uint32) {
for _, onlinePlayer := range g.userManager.GetAllOnlineUserList() { for _, onlinePlayer := range USER_MANAGER.GetAllOnlineUserList() {
serverAnnounceRevokeNotify := new(proto.ServerAnnounceRevokeNotify) serverAnnounceRevokeNotify := &proto.ServerAnnounceRevokeNotify{
serverAnnounceRevokeNotify.ConfigIdList = []uint32{announceId} ConfigIdList: []uint32{announceId},
}
g.SendMsg(cmd.ServerAnnounceRevokeNotify, onlinePlayer.PlayerID, 0, serverAnnounceRevokeNotify) g.SendMsg(cmd.ServerAnnounceRevokeNotify, onlinePlayer.PlayerID, 0, serverAnnounceRevokeNotify)
} }
} }
@@ -105,7 +105,7 @@ func (g *GameManager) ToTheMoonEnterSceneReq(player *model.Player, payloadMsg pb
logger.LOG.Debug("user ttm enter scene, uid: %v", player.PlayerID) logger.LOG.Debug("user ttm enter scene, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.ToTheMoonEnterSceneReq) req := payloadMsg.(*proto.ToTheMoonEnterSceneReq)
_ = req _ = req
g.SendMsg(cmd.ServerAnnounceRevokeNotify, player.PlayerID, player.ClientSeq, new(proto.ToTheMoonEnterSceneRsp)) g.SendMsg(cmd.ToTheMoonEnterSceneRsp, player.PlayerID, player.ClientSeq, new(proto.ToTheMoonEnterSceneRsp))
} }
func (g *GameManager) SetEntityClientDataNotify(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) SetEntityClientDataNotify(player *model.Player, payloadMsg pb.Message) {

View File

@@ -24,8 +24,6 @@ type UserInfo struct {
func (g *GameManager) GetGachaInfoReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) GetGachaInfoReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user get gacha info, uid: %v", player.PlayerID) logger.LOG.Debug("user get gacha info, uid: %v", player.PlayerID)
serverAddr := config.CONF.Hk4e.GachaHistoryServer serverAddr := config.CONF.Hk4e.GachaHistoryServer
getGachaInfoRsp := new(proto.GetGachaInfoRsp)
getGachaInfoRsp.GachaRandom = 12345
userInfo := &UserInfo{ userInfo := &UserInfo{
UserId: player.PlayerID, UserId: player.PlayerID,
RegisteredClaims: jwt.RegisteredClaims{ RegisteredClaims: jwt.RegisteredClaims{
@@ -40,6 +38,9 @@ func (g *GameManager) GetGachaInfoReq(player *model.Player, payloadMsg pb.Messag
logger.LOG.Error("generate jwt error: %v", err) logger.LOG.Error("generate jwt error: %v", err)
jwtStr = "default.jwt.token" jwtStr = "default.jwt.token"
} }
getGachaInfoRsp := new(proto.GetGachaInfoRsp)
getGachaInfoRsp.GachaRandom = 12345
getGachaInfoRsp.GachaInfoList = []*proto.GachaInfo{ getGachaInfoRsp.GachaInfoList = []*proto.GachaInfo{
// 温迪 // 温迪
{ {
@@ -190,7 +191,6 @@ func (g *GameManager) GetGachaInfoReq(player *model.Player, payloadMsg pb.Messag
IsNewWish: false, IsNewWish: false,
}, },
} }
g.SendMsg(cmd.GetGachaInfoRsp, player.PlayerID, player.ClientSeq, getGachaInfoRsp) g.SendMsg(cmd.GetGachaInfoRsp, player.PlayerID, player.ClientSeq, getGachaInfoRsp)
} }
@@ -221,19 +221,6 @@ func (g *GameManager) DoGachaReq(player *model.Player, payloadMsg pb.Message) {
costItemId = 224 costItemId = 224
} }
// PacketDoGachaRsp
doGachaRsp := new(proto.DoGachaRsp)
doGachaRsp.GachaType = gachaType
doGachaRsp.GachaScheduleId = gachaScheduleId
doGachaRsp.GachaTimes = gachaTimes
doGachaRsp.NewGachaRandom = 12345
doGachaRsp.LeftGachaTimes = 2147483647
doGachaRsp.GachaTimesLimit = 2147483647
doGachaRsp.CostItemId = costItemId
doGachaRsp.CostItemNum = 1
doGachaRsp.TenCostItemId = costItemId
doGachaRsp.TenCostItemNum = 10
// 先扣掉粉球或蓝球再进行抽卡 // 先扣掉粉球或蓝球再进行抽卡
g.CostUserItem(player.PlayerID, []*UserItem{ g.CostUserItem(player.PlayerID, []*UserItem{
{ {
@@ -242,7 +229,20 @@ func (g *GameManager) DoGachaReq(player *model.Player, payloadMsg pb.Message) {
}, },
}) })
doGachaRsp.GachaItemList = make([]*proto.GachaItem, 0) doGachaRsp := &proto.DoGachaRsp{
GachaType: gachaType,
GachaScheduleId: gachaScheduleId,
GachaTimes: gachaTimes,
NewGachaRandom: 12345,
LeftGachaTimes: 2147483647,
GachaTimesLimit: 2147483647,
CostItemId: costItemId,
CostItemNum: 1,
TenCostItemId: costItemId,
TenCostItemNum: 10,
GachaItemList: make([]*proto.GachaItem, 0),
}
for i := uint32(0); i < gachaTimes; i++ { for i := uint32(0); i < gachaTimes; i++ {
var ok bool var ok bool
var itemId uint32 var itemId uint32
@@ -378,7 +378,7 @@ const (
// 单抽一次 // 单抽一次
func (g *GameManager) doGachaOnce(userId uint32, gachaType uint32, mustGetUpEnable bool, weaponFix bool) (bool, uint32) { func (g *GameManager) doGachaOnce(userId uint32, gachaType uint32, mustGetUpEnable bool, weaponFix bool) (bool, uint32) {
player := g.userManager.GetOnlineUser(userId) player := USER_MANAGER.GetOnlineUser(userId)
if player == nil { if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId) logger.LOG.Error("player is nil, uid: %v", userId)
return false, 0 return false, 0

View File

@@ -49,7 +49,7 @@ func (g *GameManager) GetAllItemDataConfig() map[int32]*gdc.ItemData {
} }
func (g *GameManager) AddUserItem(userId uint32, itemList []*UserItem, isHint bool, hintReason uint16) { func (g *GameManager) AddUserItem(userId uint32, itemList []*UserItem, isHint bool, hintReason uint16) {
player := g.userManager.GetOnlineUser(userId) player := USER_MANAGER.GetOnlineUser(userId)
if player == nil { if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId) logger.LOG.Error("player is nil, uid: %v", userId)
return return
@@ -58,9 +58,10 @@ func (g *GameManager) AddUserItem(userId uint32, itemList []*UserItem, isHint bo
player.AddItem(userItem.ItemId, userItem.ChangeCount) player.AddItem(userItem.ItemId, userItem.ChangeCount)
} }
// PacketStoreItemChangeNotify storeItemChangeNotify := &proto.StoreItemChangeNotify{
storeItemChangeNotify := new(proto.StoreItemChangeNotify) StoreType: proto.StoreType_STORE_TYPE_PACK,
storeItemChangeNotify.StoreType = proto.StoreType_STORE_TYPE_PACK ItemList: make([]*proto.Item, 0),
}
for _, userItem := range itemList { for _, userItem := range itemList {
pbItem := &proto.Item{ pbItem := &proto.Item{
ItemId: userItem.ItemId, ItemId: userItem.ItemId,
@@ -79,9 +80,10 @@ func (g *GameManager) AddUserItem(userId uint32, itemList []*UserItem, isHint bo
if hintReason == 0 { if hintReason == 0 {
hintReason = constant.ActionReasonConst.SubfieldDrop hintReason = constant.ActionReasonConst.SubfieldDrop
} }
// PacketItemAddHintNotify itemAddHintNotify := &proto.ItemAddHintNotify{
itemAddHintNotify := new(proto.ItemAddHintNotify) Reason: uint32(hintReason),
itemAddHintNotify.Reason = uint32(hintReason) ItemList: make([]*proto.ItemHint, 0),
}
for _, userItem := range itemList { for _, userItem := range itemList {
itemAddHintNotify.ItemList = append(itemAddHintNotify.ItemList, &proto.ItemHint{ itemAddHintNotify.ItemList = append(itemAddHintNotify.ItemList, &proto.ItemHint{
ItemId: userItem.ItemId, ItemId: userItem.ItemId,
@@ -92,9 +94,9 @@ func (g *GameManager) AddUserItem(userId uint32, itemList []*UserItem, isHint bo
g.SendMsg(cmd.ItemAddHintNotify, userId, player.ClientSeq, itemAddHintNotify) g.SendMsg(cmd.ItemAddHintNotify, userId, player.ClientSeq, itemAddHintNotify)
} }
// PacketPlayerPropNotify playerPropNotify := &proto.PlayerPropNotify{
playerPropNotify := new(proto.PlayerPropNotify) PropMap: make(map[uint32]*proto.PropValue),
playerPropNotify.PropMap = make(map[uint32]*proto.PropValue) }
for _, userItem := range itemList { for _, userItem := range itemList {
isVirtualItem, prop := player.GetVirtualItemProp(userItem.ItemId) isVirtualItem, prop := player.GetVirtualItemProp(userItem.ItemId)
if !isVirtualItem { if !isVirtualItem {
@@ -114,7 +116,7 @@ func (g *GameManager) AddUserItem(userId uint32, itemList []*UserItem, isHint bo
} }
func (g *GameManager) CostUserItem(userId uint32, itemList []*UserItem) { func (g *GameManager) CostUserItem(userId uint32, itemList []*UserItem) {
player := g.userManager.GetOnlineUser(userId) player := USER_MANAGER.GetOnlineUser(userId)
if player == nil { if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId) logger.LOG.Error("player is nil, uid: %v", userId)
return return
@@ -123,9 +125,10 @@ func (g *GameManager) CostUserItem(userId uint32, itemList []*UserItem) {
player.CostItem(userItem.ItemId, userItem.ChangeCount) player.CostItem(userItem.ItemId, userItem.ChangeCount)
} }
// PacketStoreItemChangeNotify storeItemChangeNotify := &proto.StoreItemChangeNotify{
storeItemChangeNotify := new(proto.StoreItemChangeNotify) StoreType: proto.StoreType_STORE_TYPE_PACK,
storeItemChangeNotify.StoreType = proto.StoreType_STORE_TYPE_PACK ItemList: make([]*proto.Item, 0),
}
for _, userItem := range itemList { for _, userItem := range itemList {
count := player.GetItemCount(userItem.ItemId) count := player.GetItemCount(userItem.ItemId)
if count == 0 { if count == 0 {
@@ -146,9 +149,10 @@ func (g *GameManager) CostUserItem(userId uint32, itemList []*UserItem) {
g.SendMsg(cmd.StoreItemChangeNotify, userId, player.ClientSeq, storeItemChangeNotify) g.SendMsg(cmd.StoreItemChangeNotify, userId, player.ClientSeq, storeItemChangeNotify)
} }
// PacketStoreItemDelNotify storeItemDelNotify := &proto.StoreItemDelNotify{
storeItemDelNotify := new(proto.StoreItemDelNotify) StoreType: proto.StoreType_STORE_TYPE_PACK,
storeItemDelNotify.StoreType = proto.StoreType_STORE_TYPE_PACK GuidList: make([]uint64, 0),
}
for _, userItem := range itemList { for _, userItem := range itemList {
count := player.GetItemCount(userItem.ItemId) count := player.GetItemCount(userItem.ItemId)
if count > 0 { if count > 0 {
@@ -160,9 +164,9 @@ func (g *GameManager) CostUserItem(userId uint32, itemList []*UserItem) {
g.SendMsg(cmd.StoreItemDelNotify, userId, player.ClientSeq, storeItemDelNotify) g.SendMsg(cmd.StoreItemDelNotify, userId, player.ClientSeq, storeItemDelNotify)
} }
// PacketPlayerPropNotify playerPropNotify := &proto.PlayerPropNotify{
playerPropNotify := new(proto.PlayerPropNotify) PropMap: make(map[uint32]*proto.PropValue),
playerPropNotify.PropMap = make(map[uint32]*proto.PropValue) }
for _, userItem := range itemList { for _, userItem := range itemList {
isVirtualItem, prop := player.GetVirtualItemProp(userItem.ItemId) isVirtualItem, prop := player.GetVirtualItemProp(userItem.ItemId)
if !isVirtualItem { if !isVirtualItem {

View File

@@ -15,7 +15,7 @@ import (
func (g *GameManager) OnLogin(userId uint32, clientSeq uint32) { func (g *GameManager) OnLogin(userId uint32, clientSeq uint32) {
logger.LOG.Info("user login, uid: %v", userId) logger.LOG.Info("user login, uid: %v", userId)
player, asyncWait := g.userManager.OnlineUser(userId, clientSeq) player, asyncWait := USER_MANAGER.OnlineUser(userId, clientSeq)
if !asyncWait { if !asyncWait {
g.OnLoginOk(userId, player, clientSeq) g.OnLoginOk(userId, player, clientSeq)
} }
@@ -33,7 +33,7 @@ func (g *GameManager) OnLoginOk(userId uint32, player *model.Player, clientSeq u
player.InitAll() player.InitAll()
player.TeamConfig.UpdateTeam() player.TeamConfig.UpdateTeam()
// 创建世界 // 创建世界
world := g.worldManager.CreateWorld(player, false) world := WORLD_MANAGER.CreateWorld(player, false)
world.AddPlayer(player, player.SceneId) world.AddPlayer(player, player.SceneId)
player.WorldId = world.id player.WorldId = world.id
@@ -63,7 +63,7 @@ func (g *GameManager) OnReg(userId uint32, clientSeq uint32, payloadMsg pb.Messa
req := payloadMsg.(*proto.SetPlayerBornDataReq) req := payloadMsg.(*proto.SetPlayerBornDataReq)
logger.LOG.Debug("avatar id: %v, nickname: %v", req.AvatarId, req.NickName) logger.LOG.Debug("avatar id: %v, nickname: %v", req.AvatarId, req.NickName)
exist, asyncWait := g.userManager.CheckUserExistOnReg(userId, req, clientSeq) exist, asyncWait := USER_MANAGER.CheckUserExistOnReg(userId, req, clientSeq)
if !asyncWait { if !asyncWait {
g.OnRegOk(exist, req, userId, clientSeq) g.OnRegOk(exist, req, userId, clientSeq)
} }
@@ -87,7 +87,7 @@ func (g *GameManager) OnRegOk(exist bool, req *proto.SetPlayerBornDataReq, userI
logger.LOG.Error("player is nil, uid: %v", userId) logger.LOG.Error("player is nil, uid: %v", userId)
return return
} }
g.userManager.AddUser(player) USER_MANAGER.AddUser(player)
g.SendMsg(cmd.SetPlayerBornDataRsp, userId, clientSeq, new(proto.SetPlayerBornDataRsp)) g.SendMsg(cmd.SetPlayerBornDataRsp, userId, clientSeq, new(proto.SetPlayerBornDataRsp))
g.OnLogin(userId, clientSeq) g.OnLogin(userId, clientSeq)
@@ -95,19 +95,19 @@ func (g *GameManager) OnRegOk(exist bool, req *proto.SetPlayerBornDataReq, userI
func (g *GameManager) OnUserOffline(userId uint32) { func (g *GameManager) OnUserOffline(userId uint32) {
logger.LOG.Info("user offline, uid: %v", userId) logger.LOG.Info("user offline, uid: %v", userId)
player := g.userManager.GetOnlineUser(userId) player := USER_MANAGER.GetOnlineUser(userId)
if player == nil { if player == nil {
logger.LOG.Error("player is nil, userId: %v", userId) logger.LOG.Error("player is nil, userId: %v", userId)
return return
} }
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world != nil { if world != nil {
g.UserWorldRemovePlayer(world, player) g.UserWorldRemovePlayer(world, player)
} }
player.OfflineTime = uint32(time.Now().Unix()) player.OfflineTime = uint32(time.Now().Unix())
player.Online = false player.Online = false
player.TotalOnlineTime += uint32(time.Now().UnixMilli()) - player.OnlineTime player.TotalOnlineTime += uint32(time.Now().UnixMilli()) - player.OnlineTime
g.userManager.OfflineUser(player) USER_MANAGER.OfflineUser(player)
} }
func (g *GameManager) LoginNotify(userId uint32, player *model.Player, clientSeq uint32) { func (g *GameManager) LoginNotify(userId uint32, player *model.Player, clientSeq uint32) {
@@ -119,41 +119,42 @@ func (g *GameManager) LoginNotify(userId uint32, player *model.Player, clientSeq
} }
func (g *GameManager) PacketPlayerDataNotify(player *model.Player) *proto.PlayerDataNotify { func (g *GameManager) PacketPlayerDataNotify(player *model.Player) *proto.PlayerDataNotify {
// PacketPlayerDataNotify playerDataNotify := &proto.PlayerDataNotify{
playerDataNotify := new(proto.PlayerDataNotify) NickName: player.NickName,
playerDataNotify.NickName = player.NickName ServerTime: uint64(time.Now().UnixMilli()),
playerDataNotify.ServerTime = uint64(time.Now().UnixMilli()) IsFirstLoginToday: true,
playerDataNotify.IsFirstLoginToday = true RegionId: player.RegionId,
playerDataNotify.RegionId = player.RegionId PropMap: make(map[uint32]*proto.PropValue),
playerDataNotify.PropMap = make(map[uint32]*proto.PropValue) }
for k, v := range player.PropertiesMap { for k, v := range player.PropertiesMap {
propValue := new(proto.PropValue) propValue := &proto.PropValue{
propValue.Type = uint32(k) Type: uint32(k),
propValue.Value = &proto.PropValue_Ival{Ival: int64(v)} Value: &proto.PropValue_Ival{Ival: int64(v)},
propValue.Val = int64(v) Val: int64(v),
}
playerDataNotify.PropMap[uint32(k)] = propValue playerDataNotify.PropMap[uint32(k)] = propValue
} }
return playerDataNotify return playerDataNotify
} }
func (g *GameManager) PacketStoreWeightLimitNotify() *proto.StoreWeightLimitNotify { func (g *GameManager) PacketStoreWeightLimitNotify() *proto.StoreWeightLimitNotify {
// PacketStoreWeightLimitNotify storeWeightLimitNotify := &proto.StoreWeightLimitNotify{
storeWeightLimitNotify := new(proto.StoreWeightLimitNotify) StoreType: proto.StoreType_STORE_TYPE_PACK,
storeWeightLimitNotify.StoreType = proto.StoreType_STORE_TYPE_PACK // 背包容量限制
// 背包容量限制 WeightLimit: 30000,
storeWeightLimitNotify.WeightLimit = 30000 WeaponCountLimit: 2000,
storeWeightLimitNotify.WeaponCountLimit = 2000 ReliquaryCountLimit: 1500,
storeWeightLimitNotify.ReliquaryCountLimit = 1500 MaterialCountLimit: 2000,
storeWeightLimitNotify.MaterialCountLimit = 2000 FurnitureCountLimit: 2000,
storeWeightLimitNotify.FurnitureCountLimit = 2000 }
return storeWeightLimitNotify return storeWeightLimitNotify
} }
func (g *GameManager) PacketPlayerStoreNotify(player *model.Player) *proto.PlayerStoreNotify { func (g *GameManager) PacketPlayerStoreNotify(player *model.Player) *proto.PlayerStoreNotify {
// PacketPlayerStoreNotify playerStoreNotify := &proto.PlayerStoreNotify{
playerStoreNotify := new(proto.PlayerStoreNotify) StoreType: proto.StoreType_STORE_TYPE_PACK,
playerStoreNotify.StoreType = proto.StoreType_STORE_TYPE_PACK WeightLimit: 30000,
playerStoreNotify.WeightLimit = 30000 }
itemDataMapConfig := gdc.CONF.ItemDataMap itemDataMapConfig := gdc.CONF.ItemDataMap
for _, weapon := range player.WeaponMap { for _, weapon := range player.WeaponMap {
pbItem := &proto.Item{ pbItem := &proto.Item{
@@ -241,19 +242,20 @@ func (g *GameManager) PacketPlayerStoreNotify(player *model.Player) *proto.Playe
} }
func (g *GameManager) PacketAvatarDataNotify(player *model.Player) *proto.AvatarDataNotify { func (g *GameManager) PacketAvatarDataNotify(player *model.Player) *proto.AvatarDataNotify {
// PacketAvatarDataNotify
avatarDataNotify := new(proto.AvatarDataNotify)
chooseAvatarId := player.MainCharAvatarId chooseAvatarId := player.MainCharAvatarId
avatarDataNotify.CurAvatarTeamId = uint32(player.TeamConfig.GetActiveTeamId()) avatarDataNotify := &proto.AvatarDataNotify{
avatarDataNotify.ChooseAvatarGuid = player.AvatarMap[chooseAvatarId].Guid CurAvatarTeamId: uint32(player.TeamConfig.GetActiveTeamId()),
avatarDataNotify.OwnedFlycloakList = player.FlyCloakList ChooseAvatarGuid: player.AvatarMap[chooseAvatarId].Guid,
// 角色衣装 OwnedFlycloakList: player.FlyCloakList,
avatarDataNotify.OwnedCostumeList = player.CostumeList // 角色衣装
OwnedCostumeList: player.CostumeList,
AvatarList: make([]*proto.AvatarInfo, 0),
AvatarTeamMap: make(map[uint32]*proto.AvatarTeam),
}
for _, avatar := range player.AvatarMap { for _, avatar := range player.AvatarMap {
pbAvatar := g.PacketAvatarInfo(avatar) pbAvatar := g.PacketAvatarInfo(avatar)
avatarDataNotify.AvatarList = append(avatarDataNotify.AvatarList, pbAvatar) avatarDataNotify.AvatarList = append(avatarDataNotify.AvatarList, pbAvatar)
} }
avatarDataNotify.AvatarTeamMap = make(map[uint32]*proto.AvatarTeam)
for teamIndex, team := range player.TeamConfig.TeamList { for teamIndex, team := range player.TeamConfig.TeamList {
var teamAvatarGuidList []uint64 = nil var teamAvatarGuidList []uint64 = nil
for _, avatarId := range team.AvatarIdList { for _, avatarId := range team.AvatarIdList {
@@ -271,10 +273,10 @@ func (g *GameManager) PacketAvatarDataNotify(player *model.Player) *proto.Avatar
} }
func (g *GameManager) PacketOpenStateUpdateNotify() *proto.OpenStateUpdateNotify { func (g *GameManager) PacketOpenStateUpdateNotify() *proto.OpenStateUpdateNotify {
// PacketOpenStateUpdateNotify openStateUpdateNotify := &proto.OpenStateUpdateNotify{
openStateUpdateNotify := new(proto.OpenStateUpdateNotify) OpenStateMap: make(map[uint32]uint32),
}
openStateConstMap := reflection.ConvStructToMap(constant.OpenStateConst) openStateConstMap := reflection.ConvStructToMap(constant.OpenStateConst)
openStateUpdateNotify.OpenStateMap = make(map[uint32]uint32)
for _, v := range openStateConstMap { for _, v := range openStateConstMap {
openStateUpdateNotify.OpenStateMap[uint32(v.(uint16))] = 1 openStateUpdateNotify.OpenStateMap[uint32(v.(uint16))] = 1
} }

View File

@@ -20,9 +20,9 @@ func (g *GameManager) SceneTransToPointReq(player *model.Player, payloadMsg pb.M
transPointId := strconv.Itoa(int(req.SceneId)) + "_" + strconv.Itoa(int(req.PointId)) transPointId := strconv.Itoa(int(req.SceneId)) + "_" + strconv.Itoa(int(req.PointId))
transPointConfig, exist := gdc.CONF.ScenePointEntries[transPointId] transPointConfig, exist := gdc.CONF.ScenePointEntries[transPointId]
if !exist { if !exist {
// PacketSceneTransToPointRsp sceneTransToPointRsp := &proto.SceneTransToPointRsp{
sceneTransToPointRsp := new(proto.SceneTransToPointRsp) Retcode: int32(proto.Retcode_RETCODE_RET_SVR_ERROR),
sceneTransToPointRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SVR_ERROR) }
g.SendMsg(cmd.SceneTransToPointRsp, player.PlayerID, player.ClientSeq, sceneTransToPointRsp) g.SendMsg(cmd.SceneTransToPointRsp, player.PlayerID, player.ClientSeq, sceneTransToPointRsp)
return return
} }
@@ -37,11 +37,11 @@ func (g *GameManager) SceneTransToPointReq(player *model.Player, payloadMsg pb.M
} }
g.TeleportPlayer(player, sceneId, pos) g.TeleportPlayer(player, sceneId, pos)
// PacketSceneTransToPointRsp sceneTransToPointRsp := &proto.SceneTransToPointRsp{
sceneTransToPointRsp := new(proto.SceneTransToPointRsp) Retcode: 0,
sceneTransToPointRsp.Retcode = 0 PointId: req.PointId,
sceneTransToPointRsp.PointId = req.PointId SceneId: req.SceneId,
sceneTransToPointRsp.SceneId = req.SceneId }
g.SendMsg(cmd.SceneTransToPointRsp, player.PlayerID, player.ClientSeq, sceneTransToPointRsp) g.SendMsg(cmd.SceneTransToPointRsp, player.PlayerID, player.ClientSeq, sceneTransToPointRsp)
} }
@@ -82,13 +82,12 @@ func (g *GameManager) TeleportPlayer(player *model.Player, sceneId uint32, pos *
if newSceneId != oldSceneId { if newSceneId != oldSceneId {
jumpScene = true jumpScene = true
} }
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
oldScene := world.GetSceneById(oldSceneId) oldScene := world.GetSceneById(oldSceneId)
activeAvatarId := player.TeamConfig.GetActiveAvatarId() activeAvatarId := player.TeamConfig.GetActiveAvatarId()
playerTeamEntity := oldScene.GetPlayerTeamEntity(player.PlayerID) playerTeamEntity := oldScene.GetPlayerTeamEntity(player.PlayerID)
g.RemoveSceneEntityNotifyBroadcast(oldScene, proto.VisionType_VISION_TYPE_REMOVE, []uint32{playerTeamEntity.avatarEntityMap[activeAvatarId]}) g.RemoveSceneEntityNotifyBroadcast(oldScene, proto.VisionType_VISION_TYPE_REMOVE, []uint32{playerTeamEntity.avatarEntityMap[activeAvatarId]})
if jumpScene { if jumpScene {
// PacketDelTeamEntityNotify
delTeamEntityNotify := g.PacketDelTeamEntityNotify(oldScene, player) delTeamEntityNotify := g.PacketDelTeamEntityNotify(oldScene, player)
g.SendMsg(cmd.DelTeamEntityNotify, player.PlayerID, player.ClientSeq, delTeamEntityNotify) g.SendMsg(cmd.DelTeamEntityNotify, player.PlayerID, player.ClientSeq, delTeamEntityNotify)
@@ -104,7 +103,6 @@ func (g *GameManager) TeleportPlayer(player *model.Player, sceneId uint32, pos *
player.SceneId = newSceneId player.SceneId = newSceneId
player.SceneLoadState = model.SceneNone player.SceneLoadState = model.SceneNone
// PacketPlayerEnterSceneNotify
var enterType proto.EnterType var enterType proto.EnterType
if jumpScene { if jumpScene {
logger.LOG.Debug("player jump scene, scene: %v, pos: %v", player.SceneId, player.Pos) logger.LOG.Debug("player jump scene, scene: %v, pos: %v", player.SceneId, player.Pos)
@@ -126,11 +124,11 @@ func (g *GameManager) QueryPathReq(player *model.Player, payloadMsg pb.Message)
logger.LOG.Debug("user query path, uid: %v", player.PlayerID) logger.LOG.Debug("user query path, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.QueryPathReq) req := payloadMsg.(*proto.QueryPathReq)
// PacketQueryPathRsp queryPathRsp := &proto.QueryPathRsp{
queryPathRsp := new(proto.QueryPathRsp) Corners: []*proto.Vector{req.DestinationPos[0]},
queryPathRsp.Corners = []*proto.Vector{req.DestinationPos[0]} QueryId: req.QueryId,
queryPathRsp.QueryId = req.QueryId QueryStatus: proto.QueryPathRsp_PATH_STATUS_TYPE_SUCC,
queryPathRsp.QueryStatus = proto.QueryPathRsp_PATH_STATUS_TYPE_SUCC }
g.SendMsg(cmd.QueryPathRsp, player.PlayerID, player.ClientSeq, queryPathRsp) g.SendMsg(cmd.QueryPathRsp, player.PlayerID, player.ClientSeq, queryPathRsp)
} }
@@ -139,20 +137,21 @@ func (g *GameManager) GetScenePointReq(player *model.Player, payloadMsg pb.Messa
req := payloadMsg.(*proto.GetScenePointReq) req := payloadMsg.(*proto.GetScenePointReq)
if req.SceneId != 3 { if req.SceneId != 3 {
getScenePointRsp := new(proto.GetScenePointRsp) getScenePointRsp := &proto.GetScenePointRsp{
getScenePointRsp.SceneId = req.SceneId SceneId: req.SceneId,
}
g.SendMsg(cmd.GetScenePointRsp, player.PlayerID, player.ClientSeq, getScenePointRsp) g.SendMsg(cmd.GetScenePointRsp, player.PlayerID, player.ClientSeq, getScenePointRsp)
return return
} }
// PacketGetScenePointRsp getScenePointRsp := &proto.GetScenePointRsp{
getScenePointRsp := new(proto.GetScenePointRsp) SceneId: 3,
getScenePointRsp.SceneId = 3 UnlockAreaList: []uint32{12, 11, 19, 28, 5, 1, 24, 10, 21, 2, 7, 18, 3, 26, 6, 17, 22, 20, 9, 14, 16, 8, 13, 4, 27, 23},
getScenePointRsp.UnlockAreaList = []uint32{12, 11, 19, 28, 5, 1, 24, 10, 21, 2, 7, 18, 3, 26, 6, 17, 22, 20, 9, 14, 16, 8, 13, 4, 27, 23} UnlockedPointList: []uint32{553, 155, 58, 257, 38, 135, 528, 329, 13, 212, 401, 3, 600, 545, 589, 180, 416, 7, 615, 206, 400, 599, 114, 12, 211, 104, 502, 93, 325, 540, 131, 320, 519, 121, 616, 218, 606, 197, 208, 703, 305, 499, 254, 652, 60, 458, 282, 691, 167, 366, 323, 32, 319, 222, 181, 380, 612, 234, 433, 391, 488, 79, 338, 139, 241, 42, 57, 256, 154, 353, 588, 491, 82, 209, 10, 500, 91, 301, 489, 4, 392, 536, 127, 337, 605, 8, 487, 78, 228, 626, 598, 1, 200, 137, 336, 535, 382, 310, 509, 100, 498, 14, 213, 625, 361, 471, 674, 475, 603, 6, 205, 485, 76, 77, 486, 359, 165, 364, 317, 271, 384, 72, 481, 253, 156, 350, 45, 244, 516, 107, 306, 296, 97, 162, 571, 495, 86, 44, 248, 646, 539, 221, 22, 318, 706, 308, 507, 103, 302, 258, 442, 33, 324, 393, 61, 255, 655, 246, 385, 73, 482, 551, 153, 363, 35, 444, 245, 439, 251, 445, 36, 235, 15, 424, 225, 214, 623, 327, 537, 128, 542, 133, 332, 322, 31, 20, 429, 432, 443, 34, 59, 468, 604, 405, 515, 316, 117, 321, 122, 249, 459, 50, 29, 438, 40, 330, 116, 326, 503, 304, 514, 105, 550, 351, 152, 586, 387, 250, 541, 328, 236, 435, 247, 48, 37, 446, 538, 339, 11, 210, 476, 379, 671, 477, 676, 242, 168, 577, 378, 383, 81, 490, 501, 92, 331, 543, 252, 87, 496, 463, 307, 484, 75, 505, 96, 534, 555, 146, 462, 365, 381, 182, 166, 575, 69, 478, 494, 85, 74, 483, 368, 465, 386, 95, 84, 493, 396, 587, 5, 602, 204, 99, 497, 298, 492, 702, 293},
getScenePointRsp.UnlockedPointList = []uint32{553, 155, 58, 257, 38, 135, 528, 329, 13, 212, 401, 3, 600, 545, 589, 180, 416, 7, 615, 206, 400, 599, 114, 12, 211, 104, 502, 93, 325, 540, 131, 320, 519, 121, 616, 218, 606, 197, 208, 703, 305, 499, 254, 652, 60, 458, 282, 691, 167, 366, 323, 32, 319, 222, 181, 380, 612, 234, 433, 391, 488, 79, 338, 139, 241, 42, 57, 256, 154, 353, 588, 491, 82, 209, 10, 500, 91, 301, 489, 4, 392, 536, 127, 337, 605, 8, 487, 78, 228, 626, 598, 1, 200, 137, 336, 535, 382, 310, 509, 100, 498, 14, 213, 625, 361, 471, 674, 475, 603, 6, 205, 485, 76, 77, 486, 359, 165, 364, 317, 271, 384, 72, 481, 253, 156, 350, 45, 244, 516, 107, 306, 296, 97, 162, 571, 495, 86, 44, 248, 646, 539, 221, 22, 318, 706, 308, 507, 103, 302, 258, 442, 33, 324, 393, 61, 255, 655, 246, 385, 73, 482, 551, 153, 363, 35, 444, 245, 439, 251, 445, 36, 235, 15, 424, 225, 214, 623, 327, 537, 128, 542, 133, 332, 322, 31, 20, 429, 432, 443, 34, 59, 468, 604, 405, 515, 316, 117, 321, 122, 249, 459, 50, 29, 438, 40, 330, 116, 326, 503, 304, 514, 105, 550, 351, 152, 586, 387, 250, 541, 328, 236, 435, 247, 48, 37, 446, 538, 339, 11, 210, 476, 379, 671, 477, 676, 242, 168, 577, 378, 383, 81, 490, 501, 92, 331, 543, 252, 87, 496, 463, 307, 484, 75, 505, 96, 534, 555, 146, 462, 365, 381, 182, 166, 575, 69, 478, 494, 85, 74, 483, 368, 465, 386, 95, 84, 493, 396, 587, 5, 602, 204, 99, 497, 298, 492, 702, 293} LockedPointList: []uint32{173, 398, 627, 223, 417, 419, 231, 278, 699, 408, 276, 229, 520, 512, 415, 113, 274, 565, 344, 436, 394, 403, 262, 430, 195, 412, 315, 233, 440, 52, 409, 334, 193, 240, 566, 469, 187, 704, 413, 346, 259, 447, 286, 102, 345, 580, 411, 129, 578, 202, 682, 294, 570, 414, 511, 622, 428, 449, 426, 238, 265, 273, 564, 467, 563, 175, 269, 457, 574, 89, 388, 291, 707, 125, 559, 268, 656, 183, 280, 267, 357, 260, 354, 451, 410, 119, 216},
getScenePointRsp.LockedPointList = []uint32{173, 398, 627, 223, 417, 419, 231, 278, 699, 408, 276, 229, 520, 512, 415, 113, 274, 565, 344, 436, 394, 403, 262, 430, 195, 412, 315, 233, 440, 52, 409, 334, 193, 240, 566, 469, 187, 704, 413, 346, 259, 447, 286, 102, 345, 580, 411, 129, 578, 202, 682, 294, 570, 414, 511, 622, 428, 449, 426, 238, 265, 273, 564, 467, 563, 175, 269, 457, 574, 89, 388, 291, 707, 125, 559, 268, 656, 183, 280, 267, 357, 260, 354, 451, 410, 119, 216} HidePointList: []uint32{458, 515, 459, 514},
getScenePointRsp.HidePointList = []uint32{458, 515, 459, 514} GroupUnlimitPointList: []uint32{221, 131, 107, 350, 50, 424, 359},
getScenePointRsp.GroupUnlimitPointList = []uint32{221, 131, 107, 350, 50, 424, 359} }
g.SendMsg(cmd.GetScenePointRsp, player.PlayerID, player.ClientSeq, getScenePointRsp) g.SendMsg(cmd.GetScenePointRsp, player.PlayerID, player.ClientSeq, getScenePointRsp)
} }
@@ -161,24 +160,26 @@ func (g *GameManager) GetSceneAreaReq(player *model.Player, payloadMsg pb.Messag
req := payloadMsg.(*proto.GetSceneAreaReq) req := payloadMsg.(*proto.GetSceneAreaReq)
if req.SceneId != 3 { if req.SceneId != 3 {
getSceneAreaRsp := new(proto.GetSceneAreaRsp) getSceneAreaRsp := &proto.GetSceneAreaRsp{
getSceneAreaRsp.SceneId = req.SceneId SceneId: req.SceneId,
}
g.SendMsg(cmd.GetSceneAreaRsp, player.PlayerID, player.ClientSeq, getSceneAreaRsp) g.SendMsg(cmd.GetSceneAreaRsp, player.PlayerID, player.ClientSeq, getSceneAreaRsp)
return return
} }
// PacketGetSceneAreaRsp getSceneAreaRsp := &proto.GetSceneAreaRsp{
getSceneAreaRsp := new(proto.GetSceneAreaRsp) SceneId: 3,
getSceneAreaRsp.SceneId = 3 AreaIdList: []uint32{12, 11, 19, 28, 5, 1, 24, 10, 21, 2, 7, 18, 3, 26, 6, 17, 22, 20, 9, 14, 16, 8, 13, 4, 27, 23},
getSceneAreaRsp.AreaIdList = []uint32{12, 11, 19, 28, 5, 1, 24, 10, 21, 2, 7, 18, 3, 26, 6, 17, 22, 20, 9, 14, 16, 8, 13, 4, 27, 23} CityInfoList: []*proto.CityInfo{
getSceneAreaRsp.CityInfoList = make([]*proto.CityInfo, 0) {CityId: 1, Level: 10},
getSceneAreaRsp.CityInfoList = append(getSceneAreaRsp.CityInfoList, &proto.CityInfo{CityId: 1, Level: 10}) {CityId: 2, Level: 10},
getSceneAreaRsp.CityInfoList = append(getSceneAreaRsp.CityInfoList, &proto.CityInfo{CityId: 2, Level: 10}) {CityId: 3, Level: 10},
getSceneAreaRsp.CityInfoList = append(getSceneAreaRsp.CityInfoList, &proto.CityInfo{CityId: 3, Level: 10}) {CityId: 4, Level: 10},
getSceneAreaRsp.CityInfoList = append(getSceneAreaRsp.CityInfoList, &proto.CityInfo{CityId: 4, Level: 10}) {CityId: 99, Level: 1},
getSceneAreaRsp.CityInfoList = append(getSceneAreaRsp.CityInfoList, &proto.CityInfo{CityId: 99, Level: 1}) {CityId: 100, Level: 1},
getSceneAreaRsp.CityInfoList = append(getSceneAreaRsp.CityInfoList, &proto.CityInfo{CityId: 100, Level: 1}) {CityId: 101, Level: 1},
getSceneAreaRsp.CityInfoList = append(getSceneAreaRsp.CityInfoList, &proto.CityInfo{CityId: 101, Level: 1}) {CityId: 102, Level: 1},
getSceneAreaRsp.CityInfoList = append(getSceneAreaRsp.CityInfoList, &proto.CityInfo{CityId: 102, Level: 1}) },
}
g.SendMsg(cmd.GetSceneAreaRsp, player.PlayerID, player.ClientSeq, getSceneAreaRsp) g.SendMsg(cmd.GetSceneAreaRsp, player.PlayerID, player.ClientSeq, getSceneAreaRsp)
} }

View File

@@ -18,19 +18,19 @@ func (g *GameManager) PlayerApplyEnterMpReq(player *model.Player, payloadMsg pb.
req := payloadMsg.(*proto.PlayerApplyEnterMpReq) req := payloadMsg.(*proto.PlayerApplyEnterMpReq)
targetUid := req.TargetUid targetUid := req.TargetUid
// PacketPlayerApplyEnterMpRsp playerApplyEnterMpRsp := &proto.PlayerApplyEnterMpRsp{
playerApplyEnterMpRsp := new(proto.PlayerApplyEnterMpRsp) TargetUid: targetUid,
playerApplyEnterMpRsp.TargetUid = targetUid }
g.SendMsg(cmd.PlayerApplyEnterMpRsp, player.PlayerID, player.ClientSeq, playerApplyEnterMpRsp) g.SendMsg(cmd.PlayerApplyEnterMpRsp, player.PlayerID, player.ClientSeq, playerApplyEnterMpRsp)
ok := g.UserApplyEnterWorld(player, targetUid) ok := g.UserApplyEnterWorld(player, targetUid)
if !ok { if !ok {
// PacketPlayerApplyEnterMpResultNotify playerApplyEnterMpResultNotify := &proto.PlayerApplyEnterMpResultNotify{
playerApplyEnterMpResultNotify := new(proto.PlayerApplyEnterMpResultNotify) TargetUid: targetUid,
playerApplyEnterMpResultNotify.TargetUid = targetUid TargetNickname: "",
playerApplyEnterMpResultNotify.TargetNickname = "" IsAgreed: false,
playerApplyEnterMpResultNotify.IsAgreed = false Reason: proto.PlayerApplyEnterMpResultNotify_REASON_PLAYER_CANNOT_ENTER_MP,
playerApplyEnterMpResultNotify.Reason = proto.PlayerApplyEnterMpResultNotify_REASON_PLAYER_CANNOT_ENTER_MP }
g.SendMsg(cmd.PlayerApplyEnterMpResultNotify, player.PlayerID, player.ClientSeq, playerApplyEnterMpResultNotify) g.SendMsg(cmd.PlayerApplyEnterMpResultNotify, player.PlayerID, player.ClientSeq, playerApplyEnterMpResultNotify)
} }
} }
@@ -41,10 +41,10 @@ func (g *GameManager) PlayerApplyEnterMpResultReq(player *model.Player, payloadM
applyUid := req.ApplyUid applyUid := req.ApplyUid
isAgreed := req.IsAgreed isAgreed := req.IsAgreed
// PacketPlayerApplyEnterMpResultRsp playerApplyEnterMpResultRsp := &proto.PlayerApplyEnterMpResultRsp{
playerApplyEnterMpResultRsp := new(proto.PlayerApplyEnterMpResultRsp) ApplyUid: applyUid,
playerApplyEnterMpResultRsp.ApplyUid = applyUid IsAgreed: isAgreed,
playerApplyEnterMpResultRsp.IsAgreed = isAgreed }
g.SendMsg(cmd.PlayerApplyEnterMpResultRsp, player.PlayerID, player.ClientSeq, playerApplyEnterMpResultRsp) g.SendMsg(cmd.PlayerApplyEnterMpResultRsp, player.PlayerID, player.ClientSeq, playerApplyEnterMpResultRsp)
g.UserDealEnterWorld(player, applyUid, isAgreed) g.UserDealEnterWorld(player, applyUid, isAgreed)
@@ -54,14 +54,13 @@ func (g *GameManager) PlayerGetForceQuitBanInfoReq(player *model.Player, payload
logger.LOG.Debug("user get world exit ban info, uid: %v", player.PlayerID) logger.LOG.Debug("user get world exit ban info, uid: %v", player.PlayerID)
result := true result := true
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.playerMap {
if worldPlayer.SceneLoadState != model.SceneEnterDone { if worldPlayer.SceneLoadState != model.SceneEnterDone {
result = false result = false
} }
} }
// PacketPlayerGetForceQuitBanInfoRsp
playerGetForceQuitBanInfoRsp := new(proto.PlayerGetForceQuitBanInfoRsp) playerGetForceQuitBanInfoRsp := new(proto.PlayerGetForceQuitBanInfoRsp)
if result { if result {
playerGetForceQuitBanInfoRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SUCC) playerGetForceQuitBanInfoRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SUCC)
@@ -77,7 +76,6 @@ func (g *GameManager) BackMyWorldReq(player *model.Player, payloadMsg pb.Message
// 其他玩家 // 其他玩家
ok := g.UserLeaveWorld(player) ok := g.UserLeaveWorld(player)
// PacketBackMyWorldRsp
backMyWorldRsp := new(proto.BackMyWorldRsp) backMyWorldRsp := new(proto.BackMyWorldRsp)
if ok { if ok {
backMyWorldRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SUCC) backMyWorldRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SUCC)
@@ -93,7 +91,6 @@ func (g *GameManager) ChangeWorldToSingleModeReq(player *model.Player, payloadMs
// 房主 // 房主
ok := g.UserLeaveWorld(player) ok := g.UserLeaveWorld(player)
// PacketChangeWorldToSingleModeRsp
changeWorldToSingleModeRsp := new(proto.ChangeWorldToSingleModeRsp) changeWorldToSingleModeRsp := new(proto.ChangeWorldToSingleModeRsp)
if ok { if ok {
changeWorldToSingleModeRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SUCC) changeWorldToSingleModeRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SUCC)
@@ -108,20 +105,19 @@ func (g *GameManager) SceneKickPlayerReq(player *model.Player, payloadMsg pb.Mes
req := payloadMsg.(*proto.SceneKickPlayerReq) req := payloadMsg.(*proto.SceneKickPlayerReq)
targetUid := req.TargetUid targetUid := req.TargetUid
targetPlayer := g.userManager.GetOnlineUser(targetUid) targetPlayer := USER_MANAGER.GetOnlineUser(targetUid)
ok := g.UserLeaveWorld(targetPlayer) ok := g.UserLeaveWorld(targetPlayer)
if ok { if ok {
// PacketSceneKickPlayerNotify sceneKickPlayerNotify := &proto.SceneKickPlayerNotify{
sceneKickPlayerNotify := new(proto.SceneKickPlayerNotify) TargetUid: targetUid,
sceneKickPlayerNotify.TargetUid = targetUid KickerUid: player.PlayerID,
sceneKickPlayerNotify.KickerUid = player.PlayerID }
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.playerMap {
g.SendMsg(cmd.SceneKickPlayerNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, sceneKickPlayerNotify) g.SendMsg(cmd.SceneKickPlayerNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, sceneKickPlayerNotify)
} }
} }
// PacketSceneKickPlayerRsp
sceneKickPlayerRsp := new(proto.SceneKickPlayerRsp) sceneKickPlayerRsp := new(proto.SceneKickPlayerRsp)
if ok { if ok {
sceneKickPlayerRsp.TargetUid = targetUid sceneKickPlayerRsp.TargetUid = targetUid
@@ -135,8 +131,8 @@ func (g *GameManager) JoinPlayerSceneReq(player *model.Player, payloadMsg pb.Mes
logger.LOG.Debug("user join player scene, uid: %v", player.PlayerID) logger.LOG.Debug("user join player scene, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.JoinPlayerSceneReq) req := payloadMsg.(*proto.JoinPlayerSceneReq)
hostPlayer := g.userManager.GetOnlineUser(req.TargetUid) hostPlayer := USER_MANAGER.GetOnlineUser(req.TargetUid)
hostWorld := g.worldManager.GetWorldByID(hostPlayer.WorldId) hostWorld := WORLD_MANAGER.GetWorldByID(hostPlayer.WorldId)
_, exist := hostWorld.waitEnterPlayerMap[player.PlayerID] _, exist := hostWorld.waitEnterPlayerMap[player.PlayerID]
if !exist { if !exist {
@@ -147,10 +143,10 @@ func (g *GameManager) JoinPlayerSceneReq(player *model.Player, payloadMsg pb.Mes
joinPlayerSceneRsp.Retcode = int32(proto.Retcode_RETCODE_RET_JOIN_OTHER_WAIT) joinPlayerSceneRsp.Retcode = int32(proto.Retcode_RETCODE_RET_JOIN_OTHER_WAIT)
g.SendMsg(cmd.JoinPlayerSceneRsp, player.PlayerID, player.ClientSeq, joinPlayerSceneRsp) g.SendMsg(cmd.JoinPlayerSceneRsp, player.PlayerID, player.ClientSeq, joinPlayerSceneRsp)
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
g.UserWorldRemovePlayer(world, player) g.UserWorldRemovePlayer(world, player)
g.SendMsg(cmd.LeaveWorldNotify, player.PlayerID, 0, new(proto.LeaveWorldNotify)) g.SendMsg(cmd.LeaveWorldNotify, player.PlayerID, player.ClientSeq, new(proto.LeaveWorldNotify))
//g.LoginNotify(player.PlayerID, player, 0) //g.LoginNotify(player.PlayerID, player, 0)
@@ -171,16 +167,16 @@ func (g *GameManager) JoinPlayerSceneReq(player *model.Player, payloadMsg pb.Mes
g.UserWorldAddPlayer(hostWorld, player) g.UserWorldAddPlayer(hostWorld, player)
player.SceneLoadState = model.SceneNone player.SceneLoadState = model.SceneNone
g.SendMsg(cmd.PlayerEnterSceneNotify, player.PlayerID, 0, g.PacketPlayerEnterSceneNotifyLogin(player, proto.EnterType_ENTER_TYPE_OTHER)) g.SendMsg(cmd.PlayerEnterSceneNotify, player.PlayerID, player.ClientSeq, g.PacketPlayerEnterSceneNotifyLogin(player, proto.EnterType_ENTER_TYPE_OTHER))
} }
} }
func (g *GameManager) UserApplyEnterWorld(player *model.Player, targetUid uint32) bool { func (g *GameManager) UserApplyEnterWorld(player *model.Player, targetUid uint32) bool {
targetPlayer := g.userManager.GetOnlineUser(targetUid) targetPlayer := USER_MANAGER.GetOnlineUser(targetUid)
if targetPlayer == nil { if targetPlayer == nil {
return false return false
} }
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world.multiplayer { if world.multiplayer {
return false return false
} }
@@ -189,12 +185,11 @@ func (g *GameManager) UserApplyEnterWorld(player *model.Player, targetUid uint32
return false return false
} }
targetPlayer.CoopApplyMap[player.PlayerID] = time.Now().UnixNano() targetPlayer.CoopApplyMap[player.PlayerID] = time.Now().UnixNano()
targetWorld := g.worldManager.GetWorldByID(targetPlayer.WorldId) targetWorld := WORLD_MANAGER.GetWorldByID(targetPlayer.WorldId)
if targetWorld.multiplayer && targetWorld.owner.PlayerID != targetPlayer.PlayerID { if targetWorld.multiplayer && targetWorld.owner.PlayerID != targetPlayer.PlayerID {
return false return false
} }
// PacketPlayerApplyEnterMpNotify
playerApplyEnterMpNotify := new(proto.PlayerApplyEnterMpNotify) playerApplyEnterMpNotify := new(proto.PlayerApplyEnterMpNotify)
playerApplyEnterMpNotify.SrcPlayerInfo = g.PacketOnlinePlayerInfo(player) playerApplyEnterMpNotify.SrcPlayerInfo = g.PacketOnlinePlayerInfo(player)
g.SendMsg(cmd.PlayerApplyEnterMpNotify, targetPlayer.PlayerID, targetPlayer.ClientSeq, playerApplyEnterMpNotify) g.SendMsg(cmd.PlayerApplyEnterMpNotify, targetPlayer.PlayerID, targetPlayer.ClientSeq, playerApplyEnterMpNotify)
@@ -202,7 +197,7 @@ func (g *GameManager) UserApplyEnterWorld(player *model.Player, targetUid uint32
} }
func (g *GameManager) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint32, agree bool) { func (g *GameManager) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint32, agree bool) {
otherPlayer := g.userManager.GetOnlineUser(otherUid) otherPlayer := USER_MANAGER.GetOnlineUser(otherUid)
if otherPlayer == nil { if otherPlayer == nil {
return return
} }
@@ -211,30 +206,30 @@ func (g *GameManager) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint
return return
} }
delete(hostPlayer.CoopApplyMap, otherUid) delete(hostPlayer.CoopApplyMap, otherUid)
otherPlayerWorld := g.worldManager.GetWorldByID(otherPlayer.WorldId) otherPlayerWorld := WORLD_MANAGER.GetWorldByID(otherPlayer.WorldId)
if otherPlayerWorld.multiplayer { if otherPlayerWorld.multiplayer {
// PacketPlayerApplyEnterMpResultNotify playerApplyEnterMpResultNotify := &proto.PlayerApplyEnterMpResultNotify{
playerApplyEnterMpResultNotify := new(proto.PlayerApplyEnterMpResultNotify) TargetUid: hostPlayer.PlayerID,
playerApplyEnterMpResultNotify.TargetUid = hostPlayer.PlayerID TargetNickname: hostPlayer.NickName,
playerApplyEnterMpResultNotify.TargetNickname = hostPlayer.NickName IsAgreed: false,
playerApplyEnterMpResultNotify.IsAgreed = false Reason: proto.PlayerApplyEnterMpResultNotify_REASON_PLAYER_CANNOT_ENTER_MP,
playerApplyEnterMpResultNotify.Reason = proto.PlayerApplyEnterMpResultNotify_REASON_PLAYER_CANNOT_ENTER_MP }
g.SendMsg(cmd.PlayerApplyEnterMpResultNotify, otherPlayer.PlayerID, otherPlayer.ClientSeq, playerApplyEnterMpResultNotify) g.SendMsg(cmd.PlayerApplyEnterMpResultNotify, otherPlayer.PlayerID, otherPlayer.ClientSeq, playerApplyEnterMpResultNotify)
return return
} }
// PacketPlayerApplyEnterMpResultNotify playerApplyEnterMpResultNotify := &proto.PlayerApplyEnterMpResultNotify{
playerApplyEnterMpResultNotify := new(proto.PlayerApplyEnterMpResultNotify) TargetUid: hostPlayer.PlayerID,
playerApplyEnterMpResultNotify.TargetUid = hostPlayer.PlayerID TargetNickname: hostPlayer.NickName,
playerApplyEnterMpResultNotify.TargetNickname = hostPlayer.NickName IsAgreed: agree,
playerApplyEnterMpResultNotify.IsAgreed = agree Reason: proto.PlayerApplyEnterMpResultNotify_REASON_PLAYER_JUDGE,
playerApplyEnterMpResultNotify.Reason = proto.PlayerApplyEnterMpResultNotify_REASON_PLAYER_JUDGE }
g.SendMsg(cmd.PlayerApplyEnterMpResultNotify, otherPlayer.PlayerID, otherPlayer.ClientSeq, playerApplyEnterMpResultNotify) g.SendMsg(cmd.PlayerApplyEnterMpResultNotify, otherPlayer.PlayerID, otherPlayer.ClientSeq, playerApplyEnterMpResultNotify)
if !agree { if !agree {
return return
} }
world := g.worldManager.GetWorldByID(hostPlayer.WorldId) world := WORLD_MANAGER.GetWorldByID(hostPlayer.WorldId)
world.waitEnterPlayerMap[otherPlayer.PlayerID] = time.Now().UnixMilli() world.waitEnterPlayerMap[otherPlayer.PlayerID] = time.Now().UnixMilli()
if world.multiplayer { if world.multiplayer {
return return
@@ -242,9 +237,9 @@ func (g *GameManager) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint
world.ChangeToMP() world.ChangeToMP()
// PacketWorldDataNotify worldDataNotify := &proto.WorldDataNotify{
worldDataNotify := new(proto.WorldDataNotify) WorldPropMap: make(map[uint32]*proto.PropValue),
worldDataNotify.WorldPropMap = make(map[uint32]*proto.PropValue) }
// 是否多人游戏 // 是否多人游戏
worldDataNotify.WorldPropMap[2] = &proto.PropValue{ worldDataNotify.WorldPropMap[2] = &proto.PropValue{
Type: 2, Type: 2,
@@ -255,7 +250,6 @@ func (g *GameManager) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint
hostPlayer.SceneLoadState = model.SceneNone hostPlayer.SceneLoadState = model.SceneNone
// PacketPlayerEnterSceneNotify
hostPlayerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyMp( hostPlayerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyMp(
hostPlayer, hostPlayer,
hostPlayer, hostPlayer,
@@ -266,10 +260,10 @@ func (g *GameManager) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint
) )
g.SendMsg(cmd.PlayerEnterSceneNotify, hostPlayer.PlayerID, hostPlayer.ClientSeq, hostPlayerEnterSceneNotify) g.SendMsg(cmd.PlayerEnterSceneNotify, hostPlayer.PlayerID, hostPlayer.ClientSeq, hostPlayerEnterSceneNotify)
// PacketGuestBeginEnterSceneNotify guestBeginEnterSceneNotify := &proto.GuestBeginEnterSceneNotify{
guestBeginEnterSceneNotify := new(proto.GuestBeginEnterSceneNotify) SceneId: hostPlayer.SceneId,
guestBeginEnterSceneNotify.SceneId = hostPlayer.SceneId Uid: otherPlayer.PlayerID,
guestBeginEnterSceneNotify.Uid = otherPlayer.PlayerID }
g.SendMsg(cmd.GuestBeginEnterSceneNotify, hostPlayer.PlayerID, hostPlayer.ClientSeq, guestBeginEnterSceneNotify) g.SendMsg(cmd.GuestBeginEnterSceneNotify, hostPlayer.PlayerID, hostPlayer.ClientSeq, guestBeginEnterSceneNotify)
// 仅仅把当前的场上角色的实体消失掉 // 仅仅把当前的场上角色的实体消失掉
@@ -280,7 +274,7 @@ func (g *GameManager) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint
} }
func (g *GameManager) UserLeaveWorld(player *model.Player) bool { func (g *GameManager) UserLeaveWorld(player *model.Player) bool {
oldWorld := g.worldManager.GetWorldByID(player.WorldId) oldWorld := WORLD_MANAGER.GetWorldByID(player.WorldId)
if !oldWorld.multiplayer { if !oldWorld.multiplayer {
return false return false
} }
@@ -290,8 +284,7 @@ func (g *GameManager) UserLeaveWorld(player *model.Player) bool {
} }
} }
g.UserWorldRemovePlayer(oldWorld, player) g.UserWorldRemovePlayer(oldWorld, player)
// PacketClientReconnectNotify g.ReconnectPlayer(player.PlayerID)
g.SendMsg(cmd.ClientReconnectNotify, player.PlayerID, 0, new(proto.ClientReconnectNotify))
return true return true
} }
@@ -327,14 +320,13 @@ func (g *GameManager) UserWorldRemovePlayer(world *World, player *model.Player)
activeAvatarId := player.TeamConfig.GetActiveAvatarId() activeAvatarId := player.TeamConfig.GetActiveAvatarId()
g.RemoveSceneEntityNotifyToPlayer(player, proto.VisionType_VISION_TYPE_MISS, []uint32{playerTeamEntity.avatarEntityMap[activeAvatarId]}) g.RemoveSceneEntityNotifyToPlayer(player, proto.VisionType_VISION_TYPE_MISS, []uint32{playerTeamEntity.avatarEntityMap[activeAvatarId]})
// PacketDelTeamEntityNotify
delTeamEntityNotify := g.PacketDelTeamEntityNotify(scene, player) delTeamEntityNotify := g.PacketDelTeamEntityNotify(scene, player)
g.SendMsg(cmd.DelTeamEntityNotify, player.PlayerID, player.ClientSeq, delTeamEntityNotify) g.SendMsg(cmd.DelTeamEntityNotify, player.PlayerID, player.ClientSeq, delTeamEntityNotify)
if world.multiplayer { if world.multiplayer {
// PlayerQuitFromMpNotify playerQuitFromMpNotify := &proto.PlayerQuitFromMpNotify{
playerQuitFromMpNotify := new(proto.PlayerQuitFromMpNotify) Reason: proto.PlayerQuitFromMpNotify_QUIT_REASON_BACK_TO_MY_WORLD,
playerQuitFromMpNotify.Reason = proto.PlayerQuitFromMpNotify_QUIT_REASON_BACK_TO_MY_WORLD }
g.SendMsg(cmd.PlayerQuitFromMpNotify, player.PlayerID, player.ClientSeq, playerQuitFromMpNotify) g.SendMsg(cmd.PlayerQuitFromMpNotify, player.PlayerID, player.ClientSeq, playerQuitFromMpNotify)
activeAvatarId := player.TeamConfig.GetActiveAvatarId() activeAvatarId := player.TeamConfig.GetActiveAvatarId()
@@ -351,7 +343,7 @@ func (g *GameManager) UserWorldRemovePlayer(world *World, player *model.Player)
if world.owner.PlayerID == player.PlayerID { if world.owner.PlayerID == player.PlayerID {
// 房主离开销毁世界 // 房主离开销毁世界
g.worldManager.DestroyWorld(world.id) WORLD_MANAGER.DestroyWorld(world.id)
} }
} }
@@ -360,78 +352,81 @@ func (g *GameManager) UpdateWorldPlayerInfo(hostWorld *World, excludePlayer *mod
if worldPlayer.PlayerID == excludePlayer.PlayerID { if worldPlayer.PlayerID == excludePlayer.PlayerID {
continue continue
} }
scene := hostWorld.GetSceneById(worldPlayer.SceneId)
// PacketPlayerPreEnterMpNotify playerPreEnterMpNotify := &proto.PlayerPreEnterMpNotify{
playerPreEnterMpNotify := new(proto.PlayerPreEnterMpNotify) State: proto.PlayerPreEnterMpNotify_STATE_START,
playerPreEnterMpNotify.State = proto.PlayerPreEnterMpNotify_STATE_START Uid: excludePlayer.PlayerID,
playerPreEnterMpNotify.Uid = excludePlayer.PlayerID Nickname: excludePlayer.NickName,
playerPreEnterMpNotify.Nickname = excludePlayer.NickName }
g.SendMsg(cmd.PlayerPreEnterMpNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, playerPreEnterMpNotify) g.SendMsg(cmd.PlayerPreEnterMpNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, playerPreEnterMpNotify)
// PacketWorldPlayerInfoNotify worldPlayerInfoNotify := &proto.WorldPlayerInfoNotify{
worldPlayerInfoNotify := new(proto.WorldPlayerInfoNotify) PlayerInfoList: make([]*proto.OnlinePlayerInfo, 0),
PlayerUidList: make([]uint32, 0),
}
for _, subWorldPlayer := range hostWorld.playerMap { for _, subWorldPlayer := range hostWorld.playerMap {
onlinePlayerInfo := new(proto.OnlinePlayerInfo) onlinePlayerInfo := &proto.OnlinePlayerInfo{
onlinePlayerInfo.Uid = subWorldPlayer.PlayerID Uid: subWorldPlayer.PlayerID,
onlinePlayerInfo.Nickname = subWorldPlayer.NickName Nickname: subWorldPlayer.NickName,
onlinePlayerInfo.PlayerLevel = subWorldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL] PlayerLevel: subWorldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
onlinePlayerInfo.MpSettingType = proto.MpSettingType(subWorldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]) MpSettingType: proto.MpSettingType(subWorldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]),
onlinePlayerInfo.NameCardId = subWorldPlayer.NameCard NameCardId: subWorldPlayer.NameCard,
onlinePlayerInfo.Signature = subWorldPlayer.Signature Signature: subWorldPlayer.Signature,
onlinePlayerInfo.ProfilePicture = &proto.ProfilePicture{AvatarId: subWorldPlayer.HeadImage} ProfilePicture: &proto.ProfilePicture{AvatarId: subWorldPlayer.HeadImage},
onlinePlayerInfo.CurPlayerNumInWorld = uint32(len(hostWorld.playerMap)) CurPlayerNumInWorld: uint32(len(hostWorld.playerMap)),
}
worldPlayerInfoNotify.PlayerInfoList = append(worldPlayerInfoNotify.PlayerInfoList, onlinePlayerInfo) worldPlayerInfoNotify.PlayerInfoList = append(worldPlayerInfoNotify.PlayerInfoList, onlinePlayerInfo)
worldPlayerInfoNotify.PlayerUidList = append(worldPlayerInfoNotify.PlayerUidList, subWorldPlayer.PlayerID) worldPlayerInfoNotify.PlayerUidList = append(worldPlayerInfoNotify.PlayerUidList, subWorldPlayer.PlayerID)
} }
g.SendMsg(cmd.WorldPlayerInfoNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, worldPlayerInfoNotify) g.SendMsg(cmd.WorldPlayerInfoNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, worldPlayerInfoNotify)
// PacketSceneTimeNotify serverTimeNotify := &proto.ServerTimeNotify{
sceneTimeNotify := new(proto.SceneTimeNotify) ServerTime: uint64(time.Now().UnixMilli()),
sceneTimeNotify.SceneId = worldPlayer.SceneId }
sceneTimeNotify.SceneTime = uint64(scene.GetSceneTime()) g.SendMsg(cmd.ServerTimeNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, serverTimeNotify)
g.SendMsg(cmd.SceneTimeNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, sceneTimeNotify)
// PacketScenePlayerInfoNotify scenePlayerInfoNotify := &proto.ScenePlayerInfoNotify{
scenePlayerInfoNotify := new(proto.ScenePlayerInfoNotify) PlayerInfoList: make([]*proto.ScenePlayerInfo, 0),
for _, subWorldPlayer := range hostWorld.playerMap { }
onlinePlayerInfo := new(proto.OnlinePlayerInfo) for _, worldPlayer := range hostWorld.playerMap {
onlinePlayerInfo.Uid = subWorldPlayer.PlayerID onlinePlayerInfo := &proto.OnlinePlayerInfo{
onlinePlayerInfo.Nickname = subWorldPlayer.NickName Uid: worldPlayer.PlayerID,
onlinePlayerInfo.PlayerLevel = subWorldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL] Nickname: worldPlayer.NickName,
onlinePlayerInfo.MpSettingType = proto.MpSettingType(subWorldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]) PlayerLevel: worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
onlinePlayerInfo.NameCardId = subWorldPlayer.NameCard MpSettingType: proto.MpSettingType(worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]),
onlinePlayerInfo.Signature = subWorldPlayer.Signature NameCardId: worldPlayer.NameCard,
onlinePlayerInfo.ProfilePicture = &proto.ProfilePicture{AvatarId: subWorldPlayer.HeadImage} Signature: worldPlayer.Signature,
onlinePlayerInfo.CurPlayerNumInWorld = uint32(len(hostWorld.playerMap)) ProfilePicture: &proto.ProfilePicture{AvatarId: worldPlayer.HeadImage},
CurPlayerNumInWorld: uint32(len(hostWorld.playerMap)),
}
scenePlayerInfoNotify.PlayerInfoList = append(scenePlayerInfoNotify.PlayerInfoList, &proto.ScenePlayerInfo{ scenePlayerInfoNotify.PlayerInfoList = append(scenePlayerInfoNotify.PlayerInfoList, &proto.ScenePlayerInfo{
Uid: subWorldPlayer.PlayerID, Uid: worldPlayer.PlayerID,
PeerId: subWorldPlayer.PeerId, PeerId: worldPlayer.PeerId,
Name: subWorldPlayer.NickName, Name: worldPlayer.NickName,
SceneId: subWorldPlayer.SceneId, SceneId: worldPlayer.SceneId,
OnlinePlayerInfo: onlinePlayerInfo, OnlinePlayerInfo: onlinePlayerInfo,
}) })
} }
g.SendMsg(cmd.ScenePlayerInfoNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, scenePlayerInfoNotify) g.SendMsg(cmd.ScenePlayerInfoNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, scenePlayerInfoNotify)
// PacketSceneTeamUpdateNotify
sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(hostWorld) sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(hostWorld)
g.SendMsg(cmd.SceneTeamUpdateNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, sceneTeamUpdateNotify) g.SendMsg(cmd.SceneTeamUpdateNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, sceneTeamUpdateNotify)
// PacketSyncTeamEntityNotify syncTeamEntityNotify := &proto.SyncTeamEntityNotify{
syncTeamEntityNotify := new(proto.SyncTeamEntityNotify) SceneId: worldPlayer.SceneId,
syncTeamEntityNotify.SceneId = worldPlayer.SceneId TeamEntityInfoList: make([]*proto.TeamEntityInfo, 0),
syncTeamEntityNotify.TeamEntityInfoList = make([]*proto.TeamEntityInfo, 0) }
if hostWorld.multiplayer { if hostWorld.multiplayer {
for _, subWorldPlayer := range hostWorld.playerMap { for _, worldPlayer := range hostWorld.playerMap {
if subWorldPlayer.PlayerID == worldPlayer.PlayerID { if worldPlayer.PlayerID == worldPlayer.PlayerID {
continue continue
} }
subWorldPlayerScene := hostWorld.GetSceneById(subWorldPlayer.SceneId) worldPlayerScene := hostWorld.GetSceneById(worldPlayer.SceneId)
subWorldPlayerTeamEntity := subWorldPlayerScene.GetPlayerTeamEntity(subWorldPlayer.PlayerID) worldPlayerTeamEntity := worldPlayerScene.GetPlayerTeamEntity(worldPlayer.PlayerID)
teamEntityInfo := &proto.TeamEntityInfo{ teamEntityInfo := &proto.TeamEntityInfo{
TeamEntityId: subWorldPlayerTeamEntity.teamEntityId, TeamEntityId: worldPlayerTeamEntity.teamEntityId,
AuthorityPeerId: subWorldPlayer.PeerId, AuthorityPeerId: worldPlayer.PeerId,
TeamAbilityInfo: new(proto.AbilitySyncStateInfo), TeamAbilityInfo: new(proto.AbilitySyncStateInfo),
} }
syncTeamEntityNotify.TeamEntityInfoList = append(syncTeamEntityNotify.TeamEntityInfoList, teamEntityInfo) syncTeamEntityNotify.TeamEntityInfoList = append(syncTeamEntityNotify.TeamEntityInfoList, teamEntityInfo)
@@ -439,9 +434,9 @@ func (g *GameManager) UpdateWorldPlayerInfo(hostWorld *World, excludePlayer *mod
} }
g.SendMsg(cmd.SyncTeamEntityNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, syncTeamEntityNotify) g.SendMsg(cmd.SyncTeamEntityNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, syncTeamEntityNotify)
// PacketSyncScenePlayTeamEntityNotify syncScenePlayTeamEntityNotify := &proto.SyncScenePlayTeamEntityNotify{
syncScenePlayTeamEntityNotify := new(proto.SyncScenePlayTeamEntityNotify) SceneId: worldPlayer.SceneId,
syncScenePlayTeamEntityNotify.SceneId = worldPlayer.SceneId }
g.SendMsg(cmd.SyncScenePlayTeamEntityNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, syncScenePlayTeamEntityNotify) g.SendMsg(cmd.SyncScenePlayTeamEntityNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, syncScenePlayTeamEntityNotify)
} }
} }

View File

@@ -18,55 +18,56 @@ import (
func (g *GameManager) EnterSceneReadyReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) EnterSceneReadyReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user enter scene ready, uid: %v", player.PlayerID) logger.LOG.Debug("user enter scene ready, uid: %v", player.PlayerID)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
world := g.worldManager.GetWorldByID(player.WorldId) enterScenePeerNotify := &proto.EnterScenePeerNotify{
DestSceneId: player.SceneId,
// PacketEnterScenePeerNotify PeerId: player.PeerId,
enterScenePeerNotify := new(proto.EnterScenePeerNotify) HostPeerId: world.owner.PeerId,
enterScenePeerNotify.DestSceneId = player.SceneId EnterSceneToken: player.EnterSceneToken,
enterScenePeerNotify.PeerId = player.PeerId }
enterScenePeerNotify.HostPeerId = world.owner.PeerId
enterScenePeerNotify.EnterSceneToken = player.EnterSceneToken
g.SendMsg(cmd.EnterScenePeerNotify, player.PlayerID, player.ClientSeq, enterScenePeerNotify) g.SendMsg(cmd.EnterScenePeerNotify, player.PlayerID, player.ClientSeq, enterScenePeerNotify)
// PacketEnterSceneReadyRsp enterSceneReadyRsp := &proto.EnterSceneReadyRsp{
enterSceneReadyRsp := new(proto.EnterSceneReadyRsp) EnterSceneToken: player.EnterSceneToken,
enterSceneReadyRsp.EnterSceneToken = player.EnterSceneToken }
g.SendMsg(cmd.EnterSceneReadyRsp, player.PlayerID, player.ClientSeq, enterSceneReadyRsp) g.SendMsg(cmd.EnterSceneReadyRsp, player.PlayerID, player.ClientSeq, enterSceneReadyRsp)
} }
func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user scene init finish, uid: %v", player.PlayerID) logger.LOG.Debug("user scene init finish, uid: %v", player.PlayerID)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
world := g.worldManager.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
// PacketServerTimeNotify serverTimeNotify := &proto.ServerTimeNotify{
serverTimeNotify := new(proto.ServerTimeNotify) ServerTime: uint64(time.Now().UnixMilli()),
serverTimeNotify.ServerTime = uint64(time.Now().UnixMilli()) }
g.SendMsg(cmd.ServerTimeNotify, player.PlayerID, player.ClientSeq, serverTimeNotify) g.SendMsg(cmd.ServerTimeNotify, player.PlayerID, player.ClientSeq, serverTimeNotify)
if world.IsPlayerFirstEnter(player) { if world.IsPlayerFirstEnter(player) {
// PacketWorldPlayerInfoNotify worldPlayerInfoNotify := &proto.WorldPlayerInfoNotify{
worldPlayerInfoNotify := new(proto.WorldPlayerInfoNotify) PlayerInfoList: make([]*proto.OnlinePlayerInfo, 0),
PlayerUidList: make([]uint32, 0),
}
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.playerMap {
onlinePlayerInfo := new(proto.OnlinePlayerInfo) onlinePlayerInfo := &proto.OnlinePlayerInfo{
onlinePlayerInfo.Uid = worldPlayer.PlayerID Uid: worldPlayer.PlayerID,
onlinePlayerInfo.Nickname = worldPlayer.NickName Nickname: worldPlayer.NickName,
onlinePlayerInfo.PlayerLevel = worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL] PlayerLevel: worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
onlinePlayerInfo.MpSettingType = proto.MpSettingType(worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]) MpSettingType: proto.MpSettingType(worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]),
onlinePlayerInfo.NameCardId = worldPlayer.NameCard NameCardId: worldPlayer.NameCard,
onlinePlayerInfo.Signature = worldPlayer.Signature Signature: worldPlayer.Signature,
onlinePlayerInfo.ProfilePicture = &proto.ProfilePicture{AvatarId: worldPlayer.HeadImage} ProfilePicture: &proto.ProfilePicture{AvatarId: worldPlayer.HeadImage},
onlinePlayerInfo.CurPlayerNumInWorld = uint32(len(world.playerMap)) CurPlayerNumInWorld: uint32(len(world.playerMap)),
}
worldPlayerInfoNotify.PlayerInfoList = append(worldPlayerInfoNotify.PlayerInfoList, onlinePlayerInfo) worldPlayerInfoNotify.PlayerInfoList = append(worldPlayerInfoNotify.PlayerInfoList, onlinePlayerInfo)
worldPlayerInfoNotify.PlayerUidList = append(worldPlayerInfoNotify.PlayerUidList, worldPlayer.PlayerID) worldPlayerInfoNotify.PlayerUidList = append(worldPlayerInfoNotify.PlayerUidList, worldPlayer.PlayerID)
} }
g.SendMsg(cmd.WorldPlayerInfoNotify, player.PlayerID, player.ClientSeq, worldPlayerInfoNotify) g.SendMsg(cmd.WorldPlayerInfoNotify, player.PlayerID, player.ClientSeq, worldPlayerInfoNotify)
// PacketWorldDataNotify worldDataNotify := &proto.WorldDataNotify{
worldDataNotify := new(proto.WorldDataNotify) WorldPropMap: make(map[uint32]*proto.PropValue),
worldDataNotify.WorldPropMap = make(map[uint32]*proto.PropValue) }
// 世界等级 // 世界等级
worldDataNotify.WorldPropMap[1] = &proto.PropValue{ worldDataNotify.WorldPropMap[1] = &proto.PropValue{
Type: 1, Type: 1,
@@ -81,56 +82,56 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
} }
g.SendMsg(cmd.WorldDataNotify, player.PlayerID, player.ClientSeq, worldDataNotify) g.SendMsg(cmd.WorldDataNotify, player.PlayerID, player.ClientSeq, worldDataNotify)
// PacketPlayerWorldSceneInfoListNotify playerWorldSceneInfoListNotify := &proto.PlayerWorldSceneInfoListNotify{
playerWorldSceneInfoListNotify := new(proto.PlayerWorldSceneInfoListNotify) InfoList: []*proto.PlayerWorldSceneInfo{
playerWorldSceneInfoListNotify.InfoList = []*proto.PlayerWorldSceneInfo{ {SceneId: 1, IsLocked: true, SceneTagIdList: []uint32{}},
{SceneId: 1, IsLocked: true, SceneTagIdList: []uint32{}}, {SceneId: 3, IsLocked: false, SceneTagIdList: []uint32{102, 111, 112, 116, 118, 126, 135, 140, 142, 149, 1091, 1094, 1095, 1099, 1101, 1103, 1105, 1110, 1120, 1122, 1125, 1127, 1129, 1131, 1133, 1135, 1137, 1138, 1140, 1143, 1146, 1165, 1168}},
{SceneId: 3, IsLocked: false, SceneTagIdList: []uint32{102, 111, 112, 116, 118, 126, 135, 140, 142, 149, 1091, 1094, 1095, 1099, 1101, 1103, 1105, 1110, 1120, 1122, 1125, 1127, 1129, 1131, 1133, 1135, 1137, 1138, 1140, 1143, 1146, 1165, 1168}}, {SceneId: 4, IsLocked: true, SceneTagIdList: []uint32{}},
{SceneId: 4, IsLocked: true, SceneTagIdList: []uint32{}}, {SceneId: 5, IsLocked: false, SceneTagIdList: []uint32{121, 1031}},
{SceneId: 5, IsLocked: false, SceneTagIdList: []uint32{121, 1031}}, {SceneId: 6, IsLocked: false, SceneTagIdList: []uint32{144, 146, 1062, 1063}},
{SceneId: 6, IsLocked: false, SceneTagIdList: []uint32{144, 146, 1062, 1063}}, {SceneId: 7, IsLocked: true, SceneTagIdList: []uint32{136, 137, 138, 148, 1034}},
{SceneId: 7, IsLocked: true, SceneTagIdList: []uint32{136, 137, 138, 148, 1034}}, {SceneId: 9, IsLocked: true, SceneTagIdList: []uint32{1012, 1016, 1021, 1022, 1060, 1077}},
{SceneId: 9, IsLocked: true, SceneTagIdList: []uint32{1012, 1016, 1021, 1022, 1060, 1077}}, },
} }
g.SendMsg(cmd.PlayerWorldSceneInfoListNotify, player.PlayerID, player.ClientSeq, playerWorldSceneInfoListNotify) g.SendMsg(cmd.PlayerWorldSceneInfoListNotify, player.PlayerID, player.ClientSeq, playerWorldSceneInfoListNotify)
// SceneForceUnlockNotify
g.SendMsg(cmd.SceneForceUnlockNotify, player.PlayerID, player.ClientSeq, new(proto.SceneForceUnlockNotify)) g.SendMsg(cmd.SceneForceUnlockNotify, player.PlayerID, player.ClientSeq, new(proto.SceneForceUnlockNotify))
// PacketHostPlayerNotify hostPlayerNotify := &proto.HostPlayerNotify{
hostPlayerNotify := new(proto.HostPlayerNotify) HostUid: world.owner.PlayerID,
hostPlayerNotify.HostUid = world.owner.PlayerID HostPeerId: world.owner.PeerId,
hostPlayerNotify.HostPeerId = world.owner.PeerId }
g.SendMsg(cmd.HostPlayerNotify, player.PlayerID, player.ClientSeq, hostPlayerNotify) g.SendMsg(cmd.HostPlayerNotify, player.PlayerID, player.ClientSeq, hostPlayerNotify)
// PacketSceneTimeNotify sceneTimeNotify := &proto.SceneTimeNotify{
sceneTimeNotify := new(proto.SceneTimeNotify) SceneId: player.SceneId,
sceneTimeNotify.SceneId = player.SceneId SceneTime: uint64(scene.GetSceneTime()),
sceneTimeNotify.SceneTime = uint64(scene.GetSceneTime()) }
g.SendMsg(cmd.SceneTimeNotify, player.PlayerID, player.ClientSeq, sceneTimeNotify) g.SendMsg(cmd.SceneTimeNotify, player.PlayerID, player.ClientSeq, sceneTimeNotify)
// PacketPlayerGameTimeNotify playerGameTimeNotify := &proto.PlayerGameTimeNotify{
playerGameTimeNotify := new(proto.PlayerGameTimeNotify) GameTime: scene.gameTime,
playerGameTimeNotify.GameTime = scene.gameTime Uid: player.PlayerID,
playerGameTimeNotify.Uid = player.PlayerID }
g.SendMsg(cmd.PlayerGameTimeNotify, player.PlayerID, player.ClientSeq, playerGameTimeNotify) g.SendMsg(cmd.PlayerGameTimeNotify, player.PlayerID, player.ClientSeq, playerGameTimeNotify)
// PacketPlayerEnterSceneInfoNotify
empty := new(proto.AbilitySyncStateInfo) empty := new(proto.AbilitySyncStateInfo)
playerEnterSceneInfoNotify := new(proto.PlayerEnterSceneInfoNotify)
activeAvatarId := player.TeamConfig.GetActiveAvatarId() activeAvatarId := player.TeamConfig.GetActiveAvatarId()
playerTeamEntity := scene.GetPlayerTeamEntity(player.PlayerID) playerTeamEntity := scene.GetPlayerTeamEntity(player.PlayerID)
playerEnterSceneInfoNotify.CurAvatarEntityId = playerTeamEntity.avatarEntityMap[activeAvatarId] playerEnterSceneInfoNotify := &proto.PlayerEnterSceneInfoNotify{
playerEnterSceneInfoNotify.EnterSceneToken = player.EnterSceneToken CurAvatarEntityId: playerTeamEntity.avatarEntityMap[activeAvatarId],
playerEnterSceneInfoNotify.TeamEnterInfo = &proto.TeamEnterSceneInfo{ EnterSceneToken: player.EnterSceneToken,
TeamEntityId: playerTeamEntity.teamEntityId, TeamEnterInfo: &proto.TeamEnterSceneInfo{
TeamAbilityInfo: empty, TeamEntityId: playerTeamEntity.teamEntityId,
AbilityControlBlock: new(proto.AbilityControlBlock), TeamAbilityInfo: empty,
} AbilityControlBlock: new(proto.AbilityControlBlock),
playerEnterSceneInfoNotify.MpLevelEntityInfo = &proto.MPLevelEntityInfo{ },
EntityId: g.worldManager.GetWorldByID(player.WorldId).mpLevelEntityId, MpLevelEntityInfo: &proto.MPLevelEntityInfo{
AuthorityPeerId: 1, EntityId: WORLD_MANAGER.GetWorldByID(player.WorldId).mpLevelEntityId,
AbilityInfo: empty, AuthorityPeerId: 1,
AbilityInfo: empty,
},
AvatarEnterInfo: make([]*proto.AvatarEnterSceneInfo, 0),
} }
activeTeam := player.TeamConfig.GetActiveTeam() activeTeam := player.TeamConfig.GetActiveTeam()
for _, avatarId := range activeTeam.AvatarIdList { for _, avatarId := range activeTeam.AvatarIdList {
@@ -138,36 +139,39 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
break break
} }
avatar := player.AvatarMap[avatarId] avatar := player.AvatarMap[avatarId]
avatarEnterSceneInfo := new(proto.AvatarEnterSceneInfo) avatarEnterSceneInfo := &proto.AvatarEnterSceneInfo{
avatarEnterSceneInfo.AvatarGuid = avatar.Guid AvatarGuid: avatar.Guid,
avatarEnterSceneInfo.AvatarEntityId = playerTeamEntity.avatarEntityMap[avatarId] AvatarEntityId: playerTeamEntity.avatarEntityMap[avatarId],
avatarEnterSceneInfo.WeaponGuid = avatar.EquipWeapon.Guid WeaponGuid: avatar.EquipWeapon.Guid,
avatarEnterSceneInfo.WeaponEntityId = playerTeamEntity.weaponEntityMap[avatar.EquipWeapon.WeaponId] WeaponEntityId: playerTeamEntity.weaponEntityMap[avatar.EquipWeapon.WeaponId],
avatarEnterSceneInfo.AvatarAbilityInfo = empty AvatarAbilityInfo: empty,
avatarEnterSceneInfo.WeaponAbilityInfo = empty WeaponAbilityInfo: empty,
}
playerEnterSceneInfoNotify.AvatarEnterInfo = append(playerEnterSceneInfoNotify.AvatarEnterInfo, avatarEnterSceneInfo) playerEnterSceneInfoNotify.AvatarEnterInfo = append(playerEnterSceneInfoNotify.AvatarEnterInfo, avatarEnterSceneInfo)
} }
g.SendMsg(cmd.PlayerEnterSceneInfoNotify, player.PlayerID, player.ClientSeq, playerEnterSceneInfoNotify) g.SendMsg(cmd.PlayerEnterSceneInfoNotify, player.PlayerID, player.ClientSeq, playerEnterSceneInfoNotify)
// PacketSceneAreaWeatherNotify sceneAreaWeatherNotify := &proto.SceneAreaWeatherNotify{
sceneAreaWeatherNotify := new(proto.SceneAreaWeatherNotify) WeatherAreaId: 0,
sceneAreaWeatherNotify.WeatherAreaId = 0 ClimateType: uint32(constant.ClimateTypeConst.CLIMATE_SUNNY),
sceneAreaWeatherNotify.ClimateType = uint32(constant.ClimateTypeConst.CLIMATE_SUNNY) }
g.SendMsg(cmd.SceneAreaWeatherNotify, player.PlayerID, player.ClientSeq, sceneAreaWeatherNotify) g.SendMsg(cmd.SceneAreaWeatherNotify, player.PlayerID, player.ClientSeq, sceneAreaWeatherNotify)
} }
// PacketScenePlayerInfoNotify scenePlayerInfoNotify := &proto.ScenePlayerInfoNotify{
scenePlayerInfoNotify := new(proto.ScenePlayerInfoNotify) PlayerInfoList: make([]*proto.ScenePlayerInfo, 0),
}
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.playerMap {
onlinePlayerInfo := new(proto.OnlinePlayerInfo) onlinePlayerInfo := &proto.OnlinePlayerInfo{
onlinePlayerInfo.Uid = worldPlayer.PlayerID Uid: worldPlayer.PlayerID,
onlinePlayerInfo.Nickname = worldPlayer.NickName Nickname: worldPlayer.NickName,
onlinePlayerInfo.PlayerLevel = worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL] PlayerLevel: worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
onlinePlayerInfo.MpSettingType = proto.MpSettingType(worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]) MpSettingType: proto.MpSettingType(worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]),
onlinePlayerInfo.NameCardId = worldPlayer.NameCard NameCardId: worldPlayer.NameCard,
onlinePlayerInfo.Signature = worldPlayer.Signature Signature: worldPlayer.Signature,
onlinePlayerInfo.ProfilePicture = &proto.ProfilePicture{AvatarId: worldPlayer.HeadImage} ProfilePicture: &proto.ProfilePicture{AvatarId: worldPlayer.HeadImage},
onlinePlayerInfo.CurPlayerNumInWorld = uint32(len(world.playerMap)) CurPlayerNumInWorld: uint32(len(world.playerMap)),
}
scenePlayerInfoNotify.PlayerInfoList = append(scenePlayerInfoNotify.PlayerInfoList, &proto.ScenePlayerInfo{ scenePlayerInfoNotify.PlayerInfoList = append(scenePlayerInfoNotify.PlayerInfoList, &proto.ScenePlayerInfo{
Uid: worldPlayer.PlayerID, Uid: worldPlayer.PlayerID,
PeerId: worldPlayer.PeerId, PeerId: worldPlayer.PeerId,
@@ -178,14 +182,13 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
} }
g.SendMsg(cmd.ScenePlayerInfoNotify, player.PlayerID, player.ClientSeq, scenePlayerInfoNotify) g.SendMsg(cmd.ScenePlayerInfoNotify, player.PlayerID, player.ClientSeq, scenePlayerInfoNotify)
// PacketSceneTeamUpdateNotify
sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world) sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world)
g.SendMsg(cmd.SceneTeamUpdateNotify, player.PlayerID, player.ClientSeq, sceneTeamUpdateNotify) g.SendMsg(cmd.SceneTeamUpdateNotify, player.PlayerID, player.ClientSeq, sceneTeamUpdateNotify)
// PacketSyncTeamEntityNotify syncTeamEntityNotify := &proto.SyncTeamEntityNotify{
syncTeamEntityNotify := new(proto.SyncTeamEntityNotify) SceneId: player.SceneId,
syncTeamEntityNotify.SceneId = player.SceneId TeamEntityInfoList: make([]*proto.TeamEntityInfo, 0),
syncTeamEntityNotify.TeamEntityInfoList = make([]*proto.TeamEntityInfo, 0) }
if world.multiplayer { if world.multiplayer {
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.playerMap {
if worldPlayer.PlayerID == player.PlayerID { if worldPlayer.PlayerID == player.PlayerID {
@@ -203,14 +206,14 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
} }
g.SendMsg(cmd.SyncTeamEntityNotify, player.PlayerID, player.ClientSeq, syncTeamEntityNotify) g.SendMsg(cmd.SyncTeamEntityNotify, player.PlayerID, player.ClientSeq, syncTeamEntityNotify)
// PacketSyncScenePlayTeamEntityNotify syncScenePlayTeamEntityNotify := &proto.SyncScenePlayTeamEntityNotify{
syncScenePlayTeamEntityNotify := new(proto.SyncScenePlayTeamEntityNotify) SceneId: player.SceneId,
syncScenePlayTeamEntityNotify.SceneId = player.SceneId }
g.SendMsg(cmd.SyncScenePlayTeamEntityNotify, player.PlayerID, player.ClientSeq, syncScenePlayTeamEntityNotify) g.SendMsg(cmd.SyncScenePlayTeamEntityNotify, player.PlayerID, player.ClientSeq, syncScenePlayTeamEntityNotify)
// PacketSceneInitFinishRsp SceneInitFinishRsp := &proto.SceneInitFinishRsp{
SceneInitFinishRsp := new(proto.SceneInitFinishRsp) EnterSceneToken: player.EnterSceneToken,
SceneInitFinishRsp.EnterSceneToken = player.EnterSceneToken }
g.SendMsg(cmd.SceneInitFinishRsp, player.PlayerID, player.ClientSeq, SceneInitFinishRsp) g.SendMsg(cmd.SceneInitFinishRsp, player.PlayerID, player.ClientSeq, SceneInitFinishRsp)
player.SceneLoadState = model.SceneInitFinish player.SceneLoadState = model.SceneInitFinish
@@ -218,14 +221,14 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user enter scene done, uid: %v", player.PlayerID) logger.LOG.Debug("user enter scene done, uid: %v", player.PlayerID)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
world := g.worldManager.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
if world.multiplayer && world.IsPlayerFirstEnter(player) { if world.multiplayer && world.IsPlayerFirstEnter(player) {
guestPostEnterSceneNotify := new(proto.GuestPostEnterSceneNotify) guestPostEnterSceneNotify := &proto.GuestPostEnterSceneNotify{
guestPostEnterSceneNotify.SceneId = player.SceneId SceneId: player.SceneId,
guestPostEnterSceneNotify.Uid = player.PlayerID Uid: player.PlayerID,
}
g.SendMsg(cmd.GuestPostEnterSceneNotify, world.owner.PlayerID, world.owner.ClientSeq, guestPostEnterSceneNotify) g.SendMsg(cmd.GuestPostEnterSceneNotify, world.owner.PlayerID, world.owner.ClientSeq, guestPostEnterSceneNotify)
} }
@@ -246,15 +249,15 @@ func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Mess
} }
g.AddSceneEntityNotify(player, visionType, entityIdList, false) g.AddSceneEntityNotify(player, visionType, entityIdList, false)
// PacketSceneAreaWeatherNotify sceneAreaWeatherNotify := &proto.SceneAreaWeatherNotify{
sceneAreaWeatherNotify := new(proto.SceneAreaWeatherNotify) WeatherAreaId: 0,
sceneAreaWeatherNotify.WeatherAreaId = 0 ClimateType: uint32(constant.ClimateTypeConst.CLIMATE_SUNNY),
sceneAreaWeatherNotify.ClimateType = uint32(constant.ClimateTypeConst.CLIMATE_SUNNY) }
g.SendMsg(cmd.SceneAreaWeatherNotify, player.PlayerID, player.ClientSeq, sceneAreaWeatherNotify) g.SendMsg(cmd.SceneAreaWeatherNotify, player.PlayerID, player.ClientSeq, sceneAreaWeatherNotify)
// PacketEnterSceneDoneRsp enterSceneDoneRsp := &proto.EnterSceneDoneRsp{
enterSceneDoneRsp := new(proto.EnterSceneDoneRsp) EnterSceneToken: player.EnterSceneToken,
enterSceneDoneRsp.EnterSceneToken = player.EnterSceneToken }
g.SendMsg(cmd.EnterSceneDoneRsp, player.PlayerID, player.ClientSeq, enterSceneDoneRsp) g.SendMsg(cmd.EnterSceneDoneRsp, player.PlayerID, player.ClientSeq, enterSceneDoneRsp)
player.SceneLoadState = model.SceneEnterDone player.SceneLoadState = model.SceneEnterDone
@@ -262,7 +265,7 @@ func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Mess
for otherPlayerId := range world.waitEnterPlayerMap { for otherPlayerId := range world.waitEnterPlayerMap {
delete(world.waitEnterPlayerMap, otherPlayerId) delete(world.waitEnterPlayerMap, otherPlayerId)
otherPlayer := g.userManager.GetOnlineUser(otherPlayerId) otherPlayer := USER_MANAGER.GetOnlineUser(otherPlayerId)
otherPlayer.Pos = &model.Vector{ otherPlayer.Pos = &model.Vector{
X: player.Pos.X, X: player.Pos.X,
Y: player.Pos.Y, Y: player.Pos.Y,
@@ -278,16 +281,17 @@ func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Mess
g.UserWorldAddPlayer(world, otherPlayer) g.UserWorldAddPlayer(world, otherPlayer)
otherPlayer.SceneLoadState = model.SceneNone otherPlayer.SceneLoadState = model.SceneNone
g.SendMsg(cmd.PlayerEnterSceneNotify, otherPlayer.PlayerID, 0, g.PacketPlayerEnterSceneNotifyLogin(otherPlayer, proto.EnterType_ENTER_TYPE_OTHER)) playerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyLogin(otherPlayer, proto.EnterType_ENTER_TYPE_OTHER)
g.SendMsg(cmd.PlayerEnterSceneNotify, otherPlayer.PlayerID, otherPlayer.ClientSeq, playerEnterSceneNotify)
} }
} }
func (g *GameManager) PostEnterSceneReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) PostEnterSceneReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user post enter scene, uid: %v", player.PlayerID) logger.LOG.Debug("user post enter scene, uid: %v", player.PlayerID)
// PacketPostEnterSceneRsp postEnterSceneRsp := &proto.PostEnterSceneRsp{
postEnterSceneRsp := new(proto.PostEnterSceneRsp) EnterSceneToken: player.EnterSceneToken,
postEnterSceneRsp.EnterSceneToken = player.EnterSceneToken }
g.SendMsg(cmd.PostEnterSceneRsp, player.PlayerID, player.ClientSeq, postEnterSceneRsp) g.SendMsg(cmd.PostEnterSceneRsp, player.PlayerID, player.ClientSeq, postEnterSceneRsp)
} }
@@ -295,10 +299,10 @@ func (g *GameManager) EnterWorldAreaReq(player *model.Player, payloadMsg pb.Mess
logger.LOG.Debug("user enter world area, uid: %v", player.PlayerID) logger.LOG.Debug("user enter world area, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.EnterWorldAreaReq) req := payloadMsg.(*proto.EnterWorldAreaReq)
// PacketEnterWorldAreaRsp enterWorldAreaRsp := &proto.EnterWorldAreaRsp{
enterWorldAreaRsp := new(proto.EnterWorldAreaRsp) AreaType: req.AreaType,
enterWorldAreaRsp.AreaType = req.AreaType AreaId: req.AreaId,
enterWorldAreaRsp.AreaId = req.AreaId }
g.SendMsg(cmd.EnterWorldAreaRsp, player.PlayerID, player.ClientSeq, enterWorldAreaRsp) g.SendMsg(cmd.EnterWorldAreaRsp, player.PlayerID, player.ClientSeq, enterWorldAreaRsp)
} }
@@ -306,39 +310,40 @@ func (g *GameManager) ChangeGameTimeReq(player *model.Player, payloadMsg pb.Mess
logger.LOG.Debug("user change game time, uid: %v", player.PlayerID) logger.LOG.Debug("user change game time, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.ChangeGameTimeReq) req := payloadMsg.(*proto.ChangeGameTimeReq)
gameTime := req.GameTime gameTime := req.GameTime
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
scene.ChangeGameTime(gameTime) scene.ChangeGameTime(gameTime)
for _, scenePlayer := range scene.playerMap { for _, scenePlayer := range scene.playerMap {
// PacketPlayerGameTimeNotify playerGameTimeNotify := &proto.PlayerGameTimeNotify{
playerGameTimeNotify := new(proto.PlayerGameTimeNotify) GameTime: scene.gameTime,
playerGameTimeNotify.GameTime = scene.gameTime Uid: scenePlayer.PlayerID,
playerGameTimeNotify.Uid = scenePlayer.PlayerID }
g.SendMsg(cmd.PlayerGameTimeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, playerGameTimeNotify) g.SendMsg(cmd.PlayerGameTimeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, playerGameTimeNotify)
} }
// PacketChangeGameTimeRsp changeGameTimeRsp := &proto.ChangeGameTimeRsp{
changeGameTimeRsp := new(proto.ChangeGameTimeRsp) CurGameTime: scene.gameTime,
changeGameTimeRsp.CurGameTime = scene.gameTime }
g.SendMsg(cmd.ChangeGameTimeRsp, player.PlayerID, player.ClientSeq, changeGameTimeRsp) g.SendMsg(cmd.ChangeGameTimeRsp, player.PlayerID, player.ClientSeq, changeGameTimeRsp)
} }
func (g *GameManager) PacketPlayerEnterSceneNotifyLogin(player *model.Player, enterType proto.EnterType) *proto.PlayerEnterSceneNotify { func (g *GameManager) PacketPlayerEnterSceneNotifyLogin(player *model.Player, enterType proto.EnterType) *proto.PlayerEnterSceneNotify {
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
player.EnterSceneToken = uint32(random.GetRandomInt32(5000, 50000)) player.EnterSceneToken = uint32(random.GetRandomInt32(5000, 50000))
playerEnterSceneNotify := new(proto.PlayerEnterSceneNotify) playerEnterSceneNotify := &proto.PlayerEnterSceneNotify{
playerEnterSceneNotify.SceneId = player.SceneId SceneId: player.SceneId,
playerEnterSceneNotify.Pos = &proto.Vector{X: float32(player.Pos.X), Y: float32(player.Pos.Y), Z: float32(player.Pos.Z)} Pos: &proto.Vector{X: float32(player.Pos.X), Y: float32(player.Pos.Y), Z: float32(player.Pos.Z)},
playerEnterSceneNotify.SceneBeginTime = uint64(scene.GetSceneCreateTime()) SceneBeginTime: uint64(scene.GetSceneCreateTime()),
playerEnterSceneNotify.Type = enterType Type: enterType,
playerEnterSceneNotify.TargetUid = player.PlayerID TargetUid: player.PlayerID,
playerEnterSceneNotify.EnterSceneToken = player.EnterSceneToken EnterSceneToken: player.EnterSceneToken,
playerEnterSceneNotify.WorldLevel = player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL] WorldLevel: player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL],
playerEnterSceneNotify.EnterReason = uint32(constant.EnterReasonConst.Login) EnterReason: uint32(constant.EnterReasonConst.Login),
playerEnterSceneNotify.IsFirstLoginEnterScene = true IsFirstLoginEnterScene: true,
playerEnterSceneNotify.WorldType = 1 WorldType: 1,
}
playerEnterSceneNotify.SceneTransaction = strconv.Itoa(int(player.SceneId)) + "-" + playerEnterSceneNotify.SceneTransaction = strconv.Itoa(int(player.SceneId)) + "-" +
strconv.Itoa(int(player.PlayerID)) + "-" + strconv.Itoa(int(player.PlayerID)) + "-" +
strconv.Itoa(int(time.Now().Unix())) + "-" + strconv.Itoa(int(time.Now().Unix())) + "-" +
@@ -365,21 +370,22 @@ func (g *GameManager) PacketPlayerEnterSceneNotifyMp(
prevSceneId uint32, prevSceneId uint32,
prevPos *model.Vector, prevPos *model.Vector,
) *proto.PlayerEnterSceneNotify { ) *proto.PlayerEnterSceneNotify {
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
player.EnterSceneToken = uint32(random.GetRandomInt32(5000, 50000)) player.EnterSceneToken = uint32(random.GetRandomInt32(5000, 50000))
playerEnterSceneNotify := new(proto.PlayerEnterSceneNotify) playerEnterSceneNotify := &proto.PlayerEnterSceneNotify{
playerEnterSceneNotify.PrevSceneId = prevSceneId PrevSceneId: prevSceneId,
playerEnterSceneNotify.PrevPos = &proto.Vector{X: float32(prevPos.X), Y: float32(prevPos.Y), Z: float32(prevPos.Z)} PrevPos: &proto.Vector{X: float32(prevPos.X), Y: float32(prevPos.Y), Z: float32(prevPos.Z)},
playerEnterSceneNotify.SceneId = player.SceneId SceneId: player.SceneId,
playerEnterSceneNotify.Pos = &proto.Vector{X: float32(player.Pos.X), Y: float32(player.Pos.Y), Z: float32(player.Pos.Z)} Pos: &proto.Vector{X: float32(player.Pos.X), Y: float32(player.Pos.Y), Z: float32(player.Pos.Z)},
playerEnterSceneNotify.SceneBeginTime = uint64(scene.GetSceneCreateTime()) SceneBeginTime: uint64(scene.GetSceneCreateTime()),
playerEnterSceneNotify.Type = enterType Type: enterType,
playerEnterSceneNotify.TargetUid = targetPlayer.PlayerID TargetUid: targetPlayer.PlayerID,
playerEnterSceneNotify.EnterSceneToken = player.EnterSceneToken EnterSceneToken: player.EnterSceneToken,
playerEnterSceneNotify.WorldLevel = targetPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL] WorldLevel: targetPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL],
playerEnterSceneNotify.EnterReason = enterReason EnterReason: enterReason,
playerEnterSceneNotify.WorldType = 1 WorldType: 1,
}
playerEnterSceneNotify.SceneTransaction = strconv.Itoa(int(player.SceneId)) + "-" + playerEnterSceneNotify.SceneTransaction = strconv.Itoa(int(player.SceneId)) + "-" +
strconv.Itoa(int(targetPlayer.PlayerID)) + "-" + strconv.Itoa(int(targetPlayer.PlayerID)) + "-" +
strconv.Itoa(int(time.Now().Unix())) + "-" + strconv.Itoa(int(time.Now().Unix())) + "-" +
@@ -389,20 +395,20 @@ func (g *GameManager) PacketPlayerEnterSceneNotifyMp(
} }
func (g *GameManager) AddSceneEntityNotifyToPlayer(player *model.Player, visionType proto.VisionType, entityList []*proto.SceneEntityInfo) { func (g *GameManager) AddSceneEntityNotifyToPlayer(player *model.Player, visionType proto.VisionType, entityList []*proto.SceneEntityInfo) {
// PacketSceneEntityAppearNotify sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
sceneEntityAppearNotify := new(proto.SceneEntityAppearNotify) AppearType: visionType,
sceneEntityAppearNotify.AppearType = visionType EntityList: entityList,
sceneEntityAppearNotify.EntityList = entityList }
g.SendMsg(cmd.SceneEntityAppearNotify, player.PlayerID, player.ClientSeq, sceneEntityAppearNotify) g.SendMsg(cmd.SceneEntityAppearNotify, player.PlayerID, player.ClientSeq, sceneEntityAppearNotify)
logger.LOG.Debug("SceneEntityAppearNotify, uid: %v, type: %v, len: %v", logger.LOG.Debug("SceneEntityAppearNotify, uid: %v, type: %v, len: %v",
player.PlayerID, sceneEntityAppearNotify.AppearType, len(sceneEntityAppearNotify.EntityList)) player.PlayerID, sceneEntityAppearNotify.AppearType, len(sceneEntityAppearNotify.EntityList))
} }
func (g *GameManager) AddSceneEntityNotifyBroadcast(scene *Scene, visionType proto.VisionType, entityList []*proto.SceneEntityInfo) { func (g *GameManager) AddSceneEntityNotifyBroadcast(scene *Scene, visionType proto.VisionType, entityList []*proto.SceneEntityInfo) {
// PacketSceneEntityAppearNotify sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
sceneEntityAppearNotify := new(proto.SceneEntityAppearNotify) AppearType: visionType,
sceneEntityAppearNotify.AppearType = visionType EntityList: entityList,
sceneEntityAppearNotify.EntityList = entityList }
for _, scenePlayer := range scene.playerMap { for _, scenePlayer := range scene.playerMap {
g.SendMsg(cmd.SceneEntityAppearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityAppearNotify) g.SendMsg(cmd.SceneEntityAppearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityAppearNotify)
logger.LOG.Debug("SceneEntityAppearNotify, uid: %v, type: %v, len: %v", logger.LOG.Debug("SceneEntityAppearNotify, uid: %v, type: %v, len: %v",
@@ -411,20 +417,20 @@ func (g *GameManager) AddSceneEntityNotifyBroadcast(scene *Scene, visionType pro
} }
func (g *GameManager) RemoveSceneEntityNotifyToPlayer(player *model.Player, visionType proto.VisionType, entityIdList []uint32) { func (g *GameManager) RemoveSceneEntityNotifyToPlayer(player *model.Player, visionType proto.VisionType, entityIdList []uint32) {
// PacketSceneEntityDisappearNotify sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{
sceneEntityDisappearNotify := new(proto.SceneEntityDisappearNotify) EntityList: entityIdList,
sceneEntityDisappearNotify.EntityList = entityIdList DisappearType: visionType,
sceneEntityDisappearNotify.DisappearType = visionType }
g.SendMsg(cmd.SceneEntityDisappearNotify, player.PlayerID, player.ClientSeq, sceneEntityDisappearNotify) g.SendMsg(cmd.SceneEntityDisappearNotify, player.PlayerID, player.ClientSeq, sceneEntityDisappearNotify)
logger.LOG.Debug("SceneEntityDisappearNotify, uid: %v, type: %v, len: %v", logger.LOG.Debug("SceneEntityDisappearNotify, uid: %v, type: %v, len: %v",
player.PlayerID, sceneEntityDisappearNotify.DisappearType, len(sceneEntityDisappearNotify.EntityList)) player.PlayerID, sceneEntityDisappearNotify.DisappearType, len(sceneEntityDisappearNotify.EntityList))
} }
func (g *GameManager) RemoveSceneEntityNotifyBroadcast(scene *Scene, visionType proto.VisionType, entityIdList []uint32) { func (g *GameManager) RemoveSceneEntityNotifyBroadcast(scene *Scene, visionType proto.VisionType, entityIdList []uint32) {
// PacketSceneEntityDisappearNotify sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{
sceneEntityDisappearNotify := new(proto.SceneEntityDisappearNotify) EntityList: entityIdList,
sceneEntityDisappearNotify.EntityList = entityIdList DisappearType: visionType,
sceneEntityDisappearNotify.DisappearType = visionType }
for _, scenePlayer := range scene.playerMap { for _, scenePlayer := range scene.playerMap {
g.SendMsg(cmd.SceneEntityDisappearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityDisappearNotify) g.SendMsg(cmd.SceneEntityDisappearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityDisappearNotify)
logger.LOG.Debug("SceneEntityDisappearNotify, uid: %v, type: %v, len: %v", logger.LOG.Debug("SceneEntityDisappearNotify, uid: %v, type: %v, len: %v",
@@ -433,7 +439,7 @@ func (g *GameManager) RemoveSceneEntityNotifyBroadcast(scene *Scene, visionType
} }
func (g *GameManager) AddSceneEntityNotify(player *model.Player, visionType proto.VisionType, entityIdList []uint32, broadcast bool) { func (g *GameManager) AddSceneEntityNotify(player *model.Player, visionType proto.VisionType, entityIdList []uint32, broadcast bool) {
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
entityList := make([]*proto.SceneEntityInfo, 0) entityList := make([]*proto.SceneEntityInfo, 0)
for _, entityId := range entityIdList { for _, entityId := range entityIdList {
@@ -447,14 +453,11 @@ func (g *GameManager) AddSceneEntityNotify(player *model.Player, visionType prot
if visionType == proto.VisionType_VISION_TYPE_MEET && entity.avatarEntity.uid == player.PlayerID { if visionType == proto.VisionType_VISION_TYPE_MEET && entity.avatarEntity.uid == player.PlayerID {
continue continue
} }
scenePlayer := g.userManager.GetOnlineUser(entity.avatarEntity.uid) scenePlayer := USER_MANAGER.GetOnlineUser(entity.avatarEntity.uid)
if scenePlayer == nil { if scenePlayer == nil {
logger.LOG.Error("get scene player is nil, world id: %v, scene id: %v", world.id, scene.id) logger.LOG.Error("get scene player is nil, world id: %v, scene id: %v", world.id, scene.id)
continue continue
} }
//if scenePlayer.SceneLoadState != model.SceneEnterDone {
// continue
//}
if entity.avatarEntity.avatarId != scenePlayer.TeamConfig.GetActiveAvatarId() { if entity.avatarEntity.avatarId != scenePlayer.TeamConfig.GetActiveAvatarId() {
continue continue
} }
@@ -736,9 +739,10 @@ func (g *GameManager) PacketSceneGadgetInfo(gatherId uint32) *proto.SceneGadgetI
} }
func (g *GameManager) PacketDelTeamEntityNotify(scene *Scene, player *model.Player) *proto.DelTeamEntityNotify { func (g *GameManager) PacketDelTeamEntityNotify(scene *Scene, player *model.Player) *proto.DelTeamEntityNotify {
delTeamEntityNotify := new(proto.DelTeamEntityNotify)
delTeamEntityNotify.SceneId = player.SceneId
playerTeamEntity := scene.GetPlayerTeamEntity(player.PlayerID) playerTeamEntity := scene.GetPlayerTeamEntity(player.PlayerID)
delTeamEntityNotify.DelEntityIdList = []uint32{playerTeamEntity.teamEntityId} delTeamEntityNotify := &proto.DelTeamEntityNotify{
SceneId: player.SceneId,
DelEntityIdList: []uint32{playerTeamEntity.teamEntityId},
}
return delTeamEntityNotify return delTeamEntityNotify
} }

View File

@@ -15,9 +15,9 @@ import (
func (g *GameManager) GetShopmallDataReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) GetShopmallDataReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user get shop mall, uid: %v", player.PlayerID) logger.LOG.Debug("user get shop mall, uid: %v", player.PlayerID)
// PacketGetShopmallDataRsp getShopmallDataRsp := &proto.GetShopmallDataRsp{
getShopmallDataRsp := new(proto.GetShopmallDataRsp) ShopTypeList: []uint32{900, 1052, 902, 1001, 903},
getShopmallDataRsp.ShopTypeList = []uint32{900, 1052, 902, 1001, 903} }
g.SendMsg(cmd.GetShopmallDataRsp, player.PlayerID, player.ClientSeq, getShopmallDataRsp) g.SendMsg(cmd.GetShopmallDataRsp, player.PlayerID, player.ClientSeq, getShopmallDataRsp)
} }
@@ -32,39 +32,39 @@ func (g *GameManager) GetShopReq(player *model.Player, payloadMsg pb.Message) {
nextRefreshTime := uint32(time.Now().Add(time.Hour * 24 * 30).Unix()) nextRefreshTime := uint32(time.Now().Add(time.Hour * 24 * 30).Unix())
// PacketGetShopRsp getShopRsp := &proto.GetShopRsp{
getShopRsp := new(proto.GetShopRsp) Shop: &proto.Shop{
getShopRsp.Shop = &proto.Shop{ GoodsList: []*proto.ShopGoods{
GoodsList: []*proto.ShopGoods{ {
{ MinLevel: 1,
MinLevel: 1, EndTime: 2051193600,
EndTime: 2051193600, Hcoin: 160,
Hcoin: 160, GoodsId: 102001,
GoodsId: 102001, NextRefreshTime: nextRefreshTime,
NextRefreshTime: nextRefreshTime, MaxLevel: 99,
MaxLevel: 99, BeginTime: 1575129600,
BeginTime: 1575129600, GoodsItem: &proto.ItemParam{
GoodsItem: &proto.ItemParam{ ItemId: 223,
ItemId: 223, Count: 1,
Count: 1, },
}, },
}, {
{ MinLevel: 1,
MinLevel: 1, EndTime: 2051193600,
EndTime: 2051193600, Hcoin: 160,
Hcoin: 160, GoodsId: 102002,
GoodsId: 102002, NextRefreshTime: nextRefreshTime,
NextRefreshTime: nextRefreshTime, MaxLevel: 99,
MaxLevel: 99, BeginTime: 1575129600,
BeginTime: 1575129600, GoodsItem: &proto.ItemParam{
GoodsItem: &proto.ItemParam{ ItemId: 224,
ItemId: 224, Count: 1,
Count: 1, },
}, },
}, },
NextRefreshTime: nextRefreshTime,
ShopType: 1001,
}, },
NextRefreshTime: nextRefreshTime,
ShopType: 1001,
} }
g.SendMsg(cmd.GetShopRsp, player.PlayerID, player.ClientSeq, getShopRsp) g.SendMsg(cmd.GetShopRsp, player.PlayerID, player.ClientSeq, getShopRsp)
} }
@@ -94,11 +94,11 @@ func (g *GameManager) BuyGoodsReq(player *model.Player, payloadMsg pb.Message) {
}}, true, constant.ActionReasonConst.Shop) }}, true, constant.ActionReasonConst.Shop)
req.Goods.BoughtNum = player.GetItemCount(buyItemId) req.Goods.BoughtNum = player.GetItemCount(buyItemId)
// PacketBuyGoodsRsp buyGoodsRsp := &proto.BuyGoodsRsp{
buyGoodsRsp := new(proto.BuyGoodsRsp) ShopType: req.ShopType,
buyGoodsRsp.ShopType = req.ShopType BuyCount: req.BuyCount,
buyGoodsRsp.BuyCount = req.BuyCount GoodsList: []*proto.ShopGoods{req.Goods},
buyGoodsRsp.GoodsList = []*proto.ShopGoods{req.Goods} }
g.SendMsg(cmd.BuyGoodsRsp, player.PlayerID, player.ClientSeq, buyGoodsRsp) g.SendMsg(cmd.BuyGoodsRsp, player.PlayerID, player.ClientSeq, buyGoodsRsp)
} }
@@ -123,9 +123,9 @@ func (g *GameManager) McoinExchangeHcoinReq(player *model.Player, payloadMsg pb.
ChangeCount: count, ChangeCount: count,
}}, false, 0) }}, false, 0)
// PacketMcoinExchangeHcoinRsp mcoinExchangeHcoinRsp := &proto.McoinExchangeHcoinRsp{
mcoinExchangeHcoinRsp := new(proto.McoinExchangeHcoinRsp) Hcoin: req.Hcoin,
mcoinExchangeHcoinRsp.Hcoin = req.Hcoin McoinCost: req.McoinCost,
mcoinExchangeHcoinRsp.McoinCost = req.McoinCost }
g.SendMsg(cmd.McoinExchangeHcoinRsp, player.PlayerID, player.ClientSeq, mcoinExchangeHcoinRsp) g.SendMsg(cmd.McoinExchangeHcoinRsp, player.PlayerID, player.ClientSeq, mcoinExchangeHcoinRsp)
} }

View File

@@ -20,24 +20,24 @@ func (g *GameManager) GetPlayerSocialDetailReq(player *model.Player, payloadMsg
req := payloadMsg.(*proto.GetPlayerSocialDetailReq) req := payloadMsg.(*proto.GetPlayerSocialDetailReq)
targetUid := req.Uid targetUid := req.Uid
// PacketGetPlayerSocialDetailRsp
getPlayerSocialDetailRsp := new(proto.GetPlayerSocialDetailRsp) getPlayerSocialDetailRsp := new(proto.GetPlayerSocialDetailRsp)
// TODO 同步阻塞待优化 // TODO 同步阻塞待优化
targetPlayer := g.userManager.LoadTempOfflineUserSync(targetUid) targetPlayer := USER_MANAGER.LoadTempOfflineUserSync(targetUid)
if targetPlayer != nil { if targetPlayer != nil {
socialDetail := new(proto.SocialDetail)
socialDetail.Uid = targetPlayer.PlayerID
socialDetail.ProfilePicture = &proto.ProfilePicture{AvatarId: targetPlayer.HeadImage}
socialDetail.Nickname = targetPlayer.NickName
socialDetail.Signature = targetPlayer.Signature
socialDetail.Level = targetPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL]
socialDetail.Birthday = &proto.Birthday{Month: 2, Day: 13}
socialDetail.WorldLevel = targetPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL]
socialDetail.NameCardId = targetPlayer.NameCard
socialDetail.IsShowAvatar = false
socialDetail.FinishAchievementNum = 0
_, exist := player.FriendList[targetPlayer.PlayerID] _, exist := player.FriendList[targetPlayer.PlayerID]
socialDetail.IsFriend = exist socialDetail := &proto.SocialDetail{
Uid: targetPlayer.PlayerID,
ProfilePicture: &proto.ProfilePicture{AvatarId: targetPlayer.HeadImage},
Nickname: targetPlayer.NickName,
Signature: targetPlayer.Signature,
Level: targetPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
Birthday: &proto.Birthday{Month: 2, Day: 13},
WorldLevel: targetPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL],
NameCardId: targetPlayer.NameCard,
IsShowAvatar: false,
FinishAchievementNum: 0,
IsFriend: exist,
}
getPlayerSocialDetailRsp.DetailData = socialDetail getPlayerSocialDetailRsp.DetailData = socialDetail
} else { } else {
getPlayerSocialDetailRsp.Retcode = int32(proto.Retcode_RETCODE_RET_PLAYER_NOT_EXIST) getPlayerSocialDetailRsp.Retcode = int32(proto.Retcode_RETCODE_RET_PLAYER_NOT_EXIST)
@@ -67,9 +67,9 @@ func (g *GameManager) SetNameCardReq(player *model.Player, payloadMsg pb.Message
} }
player.NameCard = nameCardId player.NameCard = nameCardId
// PacketSetNameCardRsp setNameCardRsp := &proto.SetNameCardRsp{
setNameCardRsp := new(proto.SetNameCardRsp) NameCardId: nameCardId,
setNameCardRsp.NameCardId = nameCardId }
g.SendMsg(cmd.SetNameCardRsp, player.PlayerID, player.ClientSeq, setNameCardRsp) g.SendMsg(cmd.SetNameCardRsp, player.PlayerID, player.ClientSeq, setNameCardRsp)
} }
@@ -78,7 +78,6 @@ func (g *GameManager) SetPlayerSignatureReq(player *model.Player, payloadMsg pb.
req := payloadMsg.(*proto.SetPlayerSignatureReq) req := payloadMsg.(*proto.SetPlayerSignatureReq)
signature := req.Signature signature := req.Signature
// PacketSetPlayerSignatureRsp
setPlayerSignatureRsp := new(proto.SetPlayerSignatureRsp) setPlayerSignatureRsp := new(proto.SetPlayerSignatureRsp)
if !object.IsUtf8String(signature) { if !object.IsUtf8String(signature) {
setPlayerSignatureRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SIGNATURE_ILLEGAL) setPlayerSignatureRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SIGNATURE_ILLEGAL)
@@ -96,7 +95,6 @@ func (g *GameManager) SetPlayerNameReq(player *model.Player, payloadMsg pb.Messa
req := payloadMsg.(*proto.SetPlayerNameReq) req := payloadMsg.(*proto.SetPlayerNameReq)
nickName := req.NickName nickName := req.NickName
// PacketSetPlayerNameRsp
setPlayerNameRsp := new(proto.SetPlayerNameRsp) setPlayerNameRsp := new(proto.SetPlayerNameRsp)
if len(nickName) == 0 { if len(nickName) == 0 {
setPlayerNameRsp.Retcode = int32(proto.Retcode_RETCODE_RET_NICKNAME_IS_EMPTY) setPlayerNameRsp.Retcode = int32(proto.Retcode_RETCODE_RET_NICKNAME_IS_EMPTY)
@@ -124,42 +122,40 @@ func (g *GameManager) SetPlayerHeadImageReq(player *model.Player, payloadMsg pb.
} }
player.HeadImage = avatarId player.HeadImage = avatarId
// PacketSetPlayerHeadImageRsp setPlayerHeadImageRsp := &proto.SetPlayerHeadImageRsp{
setPlayerHeadImageRsp := new(proto.SetPlayerHeadImageRsp) ProfilePicture: &proto.ProfilePicture{AvatarId: player.HeadImage},
setPlayerHeadImageRsp.ProfilePicture = &proto.ProfilePicture{AvatarId: player.HeadImage} }
g.SendMsg(cmd.SetPlayerHeadImageRsp, player.PlayerID, player.ClientSeq, setPlayerHeadImageRsp) g.SendMsg(cmd.SetPlayerHeadImageRsp, player.PlayerID, player.ClientSeq, setPlayerHeadImageRsp)
} }
func (g *GameManager) GetAllUnlockNameCardReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) GetAllUnlockNameCardReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user get all unlock name card, uid: %v", player.PlayerID) logger.LOG.Debug("user get all unlock name card, uid: %v", player.PlayerID)
// PacketGetAllUnlockNameCardRsp getAllUnlockNameCardRsp := &proto.GetAllUnlockNameCardRsp{
getAllUnlockNameCardRsp := new(proto.GetAllUnlockNameCardRsp) NameCardList: player.NameCardList,
getAllUnlockNameCardRsp.NameCardList = player.NameCardList }
g.SendMsg(cmd.GetAllUnlockNameCardRsp, player.PlayerID, player.ClientSeq, getAllUnlockNameCardRsp) g.SendMsg(cmd.GetAllUnlockNameCardRsp, player.PlayerID, player.ClientSeq, getAllUnlockNameCardRsp)
} }
func (g *GameManager) GetPlayerFriendListReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) GetPlayerFriendListReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user get friend list, uid: %v", player.PlayerID) logger.LOG.Debug("user get friend list, uid: %v", player.PlayerID)
getPlayerFriendListRsp := &proto.GetPlayerFriendListRsp{
// PacketGetPlayerFriendListRsp FriendList: make([]*proto.FriendBrief, 0),
getPlayerFriendListRsp := new(proto.GetPlayerFriendListRsp) }
getPlayerFriendListRsp.FriendList = make([]*proto.FriendBrief, 0)
// 获取包含系统的临时好友列表 // 获取包含系统的临时好友列表
// 用于实现好友列表内的系统且不更改原先的内容 // 用于实现好友列表内的系统且不更改原先的内容
tempFriendList := COMMAND_MANAGER.GetFriendList(player.FriendList) tempFriendList := COMMAND_MANAGER.GetFriendList(player.FriendList)
for uid := range tempFriendList { for uid := range tempFriendList {
// TODO 同步阻塞待优化 // TODO 同步阻塞待优化
var onlineState proto.FriendOnlineState var onlineState proto.FriendOnlineState
online := g.userManager.GetUserOnlineState(uid) online := USER_MANAGER.GetUserOnlineState(uid)
if online { if online {
onlineState = proto.FriendOnlineState_FRIEND_ONLINE_STATE_ONLINE onlineState = proto.FriendOnlineState_FRIEND_ONLINE_STATE_ONLINE
} else { } else {
onlineState = proto.FriendOnlineState_FRIEND_ONLINE_STATE_FREIEND_DISCONNECT onlineState = proto.FriendOnlineState_FRIEND_ONLINE_STATE_FREIEND_DISCONNECT
} }
friendPlayer := g.userManager.LoadTempOfflineUserSync(uid) friendPlayer := USER_MANAGER.LoadTempOfflineUserSync(uid)
if friendPlayer == nil { if friendPlayer == nil {
logger.LOG.Error("target player is nil, uid: %v", player.PlayerID) logger.LOG.Error("target player is nil, uid: %v", player.PlayerID)
continue continue
@@ -187,19 +183,19 @@ func (g *GameManager) GetPlayerFriendListReq(player *model.Player, payloadMsg pb
func (g *GameManager) GetPlayerAskFriendListReq(player *model.Player, payloadMsg pb.Message) { func (g *GameManager) GetPlayerAskFriendListReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user get friend apply list, uid: %v", player.PlayerID) logger.LOG.Debug("user get friend apply list, uid: %v", player.PlayerID)
// PacketGetPlayerAskFriendListRsp getPlayerAskFriendListRsp := &proto.GetPlayerAskFriendListRsp{
getPlayerAskFriendListRsp := new(proto.GetPlayerAskFriendListRsp) AskFriendList: make([]*proto.FriendBrief, 0),
getPlayerAskFriendListRsp.AskFriendList = make([]*proto.FriendBrief, 0) }
for uid := range player.FriendApplyList { for uid := range player.FriendApplyList {
// TODO 同步阻塞待优化 // TODO 同步阻塞待优化
var onlineState proto.FriendOnlineState var onlineState proto.FriendOnlineState
online := g.userManager.GetUserOnlineState(uid) online := USER_MANAGER.GetUserOnlineState(uid)
if online { if online {
onlineState = proto.FriendOnlineState_FRIEND_ONLINE_STATE_ONLINE onlineState = proto.FriendOnlineState_FRIEND_ONLINE_STATE_ONLINE
} else { } else {
onlineState = proto.FriendOnlineState_FRIEND_ONLINE_STATE_FREIEND_DISCONNECT onlineState = proto.FriendOnlineState_FRIEND_ONLINE_STATE_FREIEND_DISCONNECT
} }
friendPlayer := g.userManager.LoadTempOfflineUserSync(uid) friendPlayer := USER_MANAGER.LoadTempOfflineUserSync(uid)
if friendPlayer == nil { if friendPlayer == nil {
logger.LOG.Error("target player is nil, uid: %v", player.PlayerID) logger.LOG.Error("target player is nil, uid: %v", player.PlayerID)
continue continue
@@ -230,8 +226,8 @@ func (g *GameManager) AskAddFriendReq(player *model.Player, payloadMsg pb.Messag
targetUid := req.TargetUid targetUid := req.TargetUid
// TODO 同步阻塞待优化 // TODO 同步阻塞待优化
targetPlayerOnline := g.userManager.GetUserOnlineState(targetUid) targetPlayerOnline := USER_MANAGER.GetUserOnlineState(targetUid)
targetPlayer := g.userManager.LoadTempOfflineUserSync(targetUid) targetPlayer := USER_MANAGER.LoadTempOfflineUserSync(targetUid)
if targetPlayer == nil { if targetPlayer == nil {
logger.LOG.Error("apply add friend target player is nil, uid: %v", player.PlayerID) logger.LOG.Error("apply add friend target player is nil, uid: %v", player.PlayerID)
return return
@@ -245,9 +241,9 @@ func (g *GameManager) AskAddFriendReq(player *model.Player, payloadMsg pb.Messag
targetPlayer.FriendApplyList[player.PlayerID] = true targetPlayer.FriendApplyList[player.PlayerID] = true
if targetPlayerOnline { if targetPlayerOnline {
// PacketAskAddFriendNotify askAddFriendNotify := &proto.AskAddFriendNotify{
askAddFriendNotify := new(proto.AskAddFriendNotify) TargetUid: player.PlayerID,
askAddFriendNotify.TargetUid = player.PlayerID }
askAddFriendNotify.TargetFriendBrief = &proto.FriendBrief{ askAddFriendNotify.TargetFriendBrief = &proto.FriendBrief{
Uid: player.PlayerID, Uid: player.PlayerID,
Nickname: player.NickName, Nickname: player.NickName,
@@ -266,16 +262,16 @@ func (g *GameManager) AskAddFriendReq(player *model.Player, payloadMsg pb.Messag
g.SendMsg(cmd.AskAddFriendNotify, targetPlayer.PlayerID, targetPlayer.ClientSeq, askAddFriendNotify) g.SendMsg(cmd.AskAddFriendNotify, targetPlayer.PlayerID, targetPlayer.ClientSeq, askAddFriendNotify)
} }
// PacketAskAddFriendRsp askAddFriendRsp := &proto.AskAddFriendRsp{
askAddFriendRsp := new(proto.AskAddFriendRsp) TargetUid: targetUid,
askAddFriendRsp.TargetUid = targetUid }
g.SendMsg(cmd.AskAddFriendRsp, player.PlayerID, player.ClientSeq, askAddFriendRsp) g.SendMsg(cmd.AskAddFriendRsp, player.PlayerID, player.ClientSeq, askAddFriendRsp)
} }
func (g *GameManager) AddFriend(player *model.Player, targetUid uint32) { func (g *GameManager) AddFriend(player *model.Player, targetUid uint32) {
player.FriendList[targetUid] = true player.FriendList[targetUid] = true
// TODO 同步阻塞待优化 // TODO 同步阻塞待优化
targetPlayer := g.userManager.LoadTempOfflineUserSync(targetUid) targetPlayer := USER_MANAGER.LoadTempOfflineUserSync(targetUid)
if targetPlayer == nil { if targetPlayer == nil {
logger.LOG.Error("agree friend apply target player is nil, uid: %v", player.PlayerID) logger.LOG.Error("agree friend apply target player is nil, uid: %v", player.PlayerID)
return return
@@ -294,10 +290,10 @@ func (g *GameManager) DealAddFriendReq(player *model.Player, payloadMsg pb.Messa
} }
delete(player.FriendApplyList, targetUid) delete(player.FriendApplyList, targetUid)
// PacketDealAddFriendRsp dealAddFriendRsp := &proto.DealAddFriendRsp{
dealAddFriendRsp := new(proto.DealAddFriendRsp) TargetUid: targetUid,
dealAddFriendRsp.TargetUid = targetUid DealAddFriendResult: result,
dealAddFriendRsp.DealAddFriendResult = result }
g.SendMsg(cmd.DealAddFriendRsp, player.PlayerID, player.ClientSeq, dealAddFriendRsp) g.SendMsg(cmd.DealAddFriendRsp, player.PlayerID, player.ClientSeq, dealAddFriendRsp)
} }
@@ -306,7 +302,7 @@ func (g *GameManager) GetOnlinePlayerListReq(player *model.Player, payloadMsg pb
count := 0 count := 0
onlinePlayerList := make([]*model.Player, 0) onlinePlayerList := make([]*model.Player, 0)
for _, onlinePlayer := range g.userManager.GetAllOnlineUserList() { for _, onlinePlayer := range USER_MANAGER.GetAllOnlineUserList() {
if onlinePlayer.PlayerID == player.PlayerID { if onlinePlayer.PlayerID == player.PlayerID {
continue continue
} }
@@ -317,9 +313,9 @@ func (g *GameManager) GetOnlinePlayerListReq(player *model.Player, payloadMsg pb
} }
} }
// PacketGetOnlinePlayerListRsp getOnlinePlayerListRsp := &proto.GetOnlinePlayerListRsp{
getOnlinePlayerListRsp := new(proto.GetOnlinePlayerListRsp) PlayerInfoList: make([]*proto.OnlinePlayerInfo, 0),
getOnlinePlayerListRsp.PlayerInfoList = make([]*proto.OnlinePlayerInfo, 0) }
for _, onlinePlayer := range onlinePlayerList { for _, onlinePlayer := range onlinePlayerList {
onlinePlayerInfo := g.PacketOnlinePlayerInfo(onlinePlayer) onlinePlayerInfo := g.PacketOnlinePlayerInfo(onlinePlayer)
getOnlinePlayerListRsp.PlayerInfoList = append(getOnlinePlayerListRsp.PlayerInfoList, onlinePlayerInfo) getOnlinePlayerListRsp.PlayerInfoList = append(getOnlinePlayerListRsp.PlayerInfoList, onlinePlayerInfo)
@@ -338,7 +334,7 @@ func (g *GameManager) PacketOnlinePlayerInfo(player *model.Player) *proto.Online
ProfilePicture: &proto.ProfilePicture{AvatarId: player.HeadImage}, ProfilePicture: &proto.ProfilePicture{AvatarId: player.HeadImage},
CurPlayerNumInWorld: 1, CurPlayerNumInWorld: 1,
} }
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world != nil && world.playerMap != nil { if world != nil && world.playerMap != nil {
onlinePlayerInfo.CurPlayerNumInWorld = uint32(len(world.playerMap)) onlinePlayerInfo.CurPlayerNumInWorld = uint32(len(world.playerMap))
} }

View File

@@ -17,7 +17,7 @@ func (g *GameManager) ChangeAvatarReq(player *model.Player, payloadMsg pb.Messag
req := payloadMsg.(*proto.ChangeAvatarReq) req := payloadMsg.(*proto.ChangeAvatarReq)
targetAvatarGuid := req.Guid targetAvatarGuid := req.Guid
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
playerTeamEntity := scene.GetPlayerTeamEntity(player.PlayerID) playerTeamEntity := scene.GetPlayerTeamEntity(player.PlayerID)
@@ -49,27 +49,27 @@ func (g *GameManager) ChangeAvatarReq(player *model.Player, payloadMsg pb.Messag
} }
entity.moveState = uint16(proto.MotionState_MOTION_STATE_STANDBY) entity.moveState = uint16(proto.MotionState_MOTION_STATE_STANDBY)
// PacketSceneEntityDisappearNotify sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{
sceneEntityDisappearNotify := new(proto.SceneEntityDisappearNotify) DisappearType: proto.VisionType_VISION_TYPE_REPLACE,
sceneEntityDisappearNotify.DisappearType = proto.VisionType_VISION_TYPE_REPLACE EntityList: []uint32{playerTeamEntity.avatarEntityMap[oldAvatarId]},
sceneEntityDisappearNotify.EntityList = []uint32{playerTeamEntity.avatarEntityMap[oldAvatarId]} }
for _, scenePlayer := range scene.playerMap { for _, scenePlayer := range scene.playerMap {
g.SendMsg(cmd.SceneEntityDisappearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityDisappearNotify) g.SendMsg(cmd.SceneEntityDisappearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityDisappearNotify)
} }
// PacketSceneEntityAppearNotify sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
sceneEntityAppearNotify := new(proto.SceneEntityAppearNotify) AppearType: proto.VisionType_VISION_TYPE_REPLACE,
sceneEntityAppearNotify.AppearType = proto.VisionType_VISION_TYPE_REPLACE Param: playerTeamEntity.avatarEntityMap[oldAvatarId],
sceneEntityAppearNotify.Param = playerTeamEntity.avatarEntityMap[oldAvatarId] EntityList: []*proto.SceneEntityInfo{g.PacketSceneEntityInfoAvatar(scene, player, player.TeamConfig.GetActiveAvatarId())},
sceneEntityAppearNotify.EntityList = []*proto.SceneEntityInfo{g.PacketSceneEntityInfoAvatar(scene, player, player.TeamConfig.GetActiveAvatarId())} }
for _, scenePlayer := range scene.playerMap { for _, scenePlayer := range scene.playerMap {
g.SendMsg(cmd.SceneEntityAppearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityAppearNotify) g.SendMsg(cmd.SceneEntityAppearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityAppearNotify)
} }
// PacketChangeAvatarRsp changeAvatarRsp := &proto.ChangeAvatarRsp{
changeAvatarRsp := new(proto.ChangeAvatarRsp) Retcode: int32(proto.Retcode_RETCODE_RET_SUCC),
changeAvatarRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SUCC) CurGuid: targetAvatarGuid,
changeAvatarRsp.CurGuid = targetAvatarGuid }
g.SendMsg(cmd.ChangeAvatarRsp, player.PlayerID, player.ClientSeq, changeAvatarRsp) g.SendMsg(cmd.ChangeAvatarRsp, player.PlayerID, player.ClientSeq, changeAvatarRsp)
} }
@@ -79,20 +79,20 @@ func (g *GameManager) SetUpAvatarTeamReq(player *model.Player, payloadMsg pb.Mes
teamId := req.TeamId teamId := req.TeamId
if teamId <= 0 || teamId >= 5 { if teamId <= 0 || teamId >= 5 {
// PacketSetUpAvatarTeamRsp setUpAvatarTeamRsp := &proto.SetUpAvatarTeamRsp{
setUpAvatarTeamRsp := new(proto.SetUpAvatarTeamRsp) Retcode: int32(proto.Retcode_RETCODE_RET_SVR_ERROR),
setUpAvatarTeamRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SVR_ERROR) }
g.SendMsg(cmd.SetUpAvatarTeamRsp, player.PlayerID, player.ClientSeq, setUpAvatarTeamRsp) g.SendMsg(cmd.SetUpAvatarTeamRsp, player.PlayerID, player.ClientSeq, setUpAvatarTeamRsp)
return return
} }
avatarGuidList := req.AvatarTeamGuidList avatarGuidList := req.AvatarTeamGuidList
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
multiTeam := teamId == 4 multiTeam := teamId == 4
selfTeam := teamId == uint32(player.TeamConfig.GetActiveTeamId()) selfTeam := teamId == uint32(player.TeamConfig.GetActiveTeamId())
if (multiTeam && len(avatarGuidList) == 0) || (selfTeam && len(avatarGuidList) == 0) || len(avatarGuidList) > 4 || world.multiplayer { if (multiTeam && len(avatarGuidList) == 0) || (selfTeam && len(avatarGuidList) == 0) || len(avatarGuidList) > 4 || world.multiplayer {
// PacketSetUpAvatarTeamRsp setUpAvatarTeamRsp := &proto.SetUpAvatarTeamRsp{
setUpAvatarTeamRsp := new(proto.SetUpAvatarTeamRsp) Retcode: int32(proto.Retcode_RETCODE_RET_SVR_ERROR),
setUpAvatarTeamRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SVR_ERROR) }
g.SendMsg(cmd.SetUpAvatarTeamRsp, player.PlayerID, player.ClientSeq, setUpAvatarTeamRsp) g.SendMsg(cmd.SetUpAvatarTeamRsp, player.PlayerID, player.ClientSeq, setUpAvatarTeamRsp)
return return
} }
@@ -110,19 +110,21 @@ func (g *GameManager) SetUpAvatarTeamReq(player *model.Player, payloadMsg pb.Mes
} }
if world.multiplayer { if world.multiplayer {
// PacketSetUpAvatarTeamRsp setUpAvatarTeamRsp := &proto.SetUpAvatarTeamRsp{
setUpAvatarTeamRsp := new(proto.SetUpAvatarTeamRsp) Retcode: int32(proto.Retcode_RETCODE_RET_SVR_ERROR),
setUpAvatarTeamRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SVR_ERROR) }
g.SendMsg(cmd.SetUpAvatarTeamRsp, player.PlayerID, player.ClientSeq, setUpAvatarTeamRsp) g.SendMsg(cmd.SetUpAvatarTeamRsp, player.PlayerID, player.ClientSeq, setUpAvatarTeamRsp)
return return
} }
// PacketAvatarTeamUpdateNotify avatarTeamUpdateNotify := &proto.AvatarTeamUpdateNotify{
avatarTeamUpdateNotify := new(proto.AvatarTeamUpdateNotify) AvatarTeamMap: make(map[uint32]*proto.AvatarTeam),
avatarTeamUpdateNotify.AvatarTeamMap = make(map[uint32]*proto.AvatarTeam) }
for teamIndex, team := range player.TeamConfig.TeamList { for teamIndex, team := range player.TeamConfig.TeamList {
avatarTeam := new(proto.AvatarTeam) avatarTeam := &proto.AvatarTeam{
avatarTeam.TeamName = team.Name TeamName: team.Name,
AvatarGuidList: make([]uint64, 0),
}
for _, avatarId := range team.AvatarIdList { for _, avatarId := range team.AvatarIdList {
if avatarId == 0 { if avatarId == 0 {
break break
@@ -139,14 +141,14 @@ func (g *GameManager) SetUpAvatarTeamReq(player *model.Player, payloadMsg pb.Mes
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
scene.UpdatePlayerTeamEntity(player) scene.UpdatePlayerTeamEntity(player)
// PacketSceneTeamUpdateNotify
sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world) sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world)
g.SendMsg(cmd.SceneTeamUpdateNotify, player.PlayerID, player.ClientSeq, sceneTeamUpdateNotify) g.SendMsg(cmd.SceneTeamUpdateNotify, player.PlayerID, player.ClientSeq, sceneTeamUpdateNotify)
// PacketSetUpAvatarTeamRsp setUpAvatarTeamRsp := &proto.SetUpAvatarTeamRsp{
setUpAvatarTeamRsp := new(proto.SetUpAvatarTeamRsp) TeamId: teamId,
setUpAvatarTeamRsp.TeamId = teamId CurAvatarGuid: player.AvatarMap[player.TeamConfig.GetActiveAvatarId()].Guid,
setUpAvatarTeamRsp.CurAvatarGuid = player.AvatarMap[player.TeamConfig.GetActiveAvatarId()].Guid AvatarTeamGuidList: make([]uint64, 0),
}
team := player.TeamConfig.GetTeamByIndex(uint8(teamId - 1)) team := player.TeamConfig.GetTeamByIndex(uint8(teamId - 1))
for _, avatarId := range team.AvatarIdList { for _, avatarId := range team.AvatarIdList {
if avatarId == 0 { if avatarId == 0 {
@@ -156,10 +158,11 @@ func (g *GameManager) SetUpAvatarTeamReq(player *model.Player, payloadMsg pb.Mes
} }
g.SendMsg(cmd.SetUpAvatarTeamRsp, player.PlayerID, player.ClientSeq, setUpAvatarTeamRsp) g.SendMsg(cmd.SetUpAvatarTeamRsp, player.PlayerID, player.ClientSeq, setUpAvatarTeamRsp)
} else { } else {
// PacketSetUpAvatarTeamRsp setUpAvatarTeamRsp := &proto.SetUpAvatarTeamRsp{
setUpAvatarTeamRsp := new(proto.SetUpAvatarTeamRsp) TeamId: teamId,
setUpAvatarTeamRsp.TeamId = teamId CurAvatarGuid: player.AvatarMap[player.TeamConfig.GetActiveAvatarId()].Guid,
setUpAvatarTeamRsp.CurAvatarGuid = player.AvatarMap[player.TeamConfig.GetActiveAvatarId()].Guid AvatarTeamGuidList: make([]uint64, 0),
}
team := player.TeamConfig.GetTeamByIndex(uint8(teamId - 1)) team := player.TeamConfig.GetTeamByIndex(uint8(teamId - 1))
for _, avatarId := range team.AvatarIdList { for _, avatarId := range team.AvatarIdList {
if avatarId == 0 { if avatarId == 0 {
@@ -175,7 +178,7 @@ func (g *GameManager) ChooseCurAvatarTeamReq(player *model.Player, payloadMsg pb
logger.LOG.Debug("user switch team, uid: %v", player.PlayerID) logger.LOG.Debug("user switch team, uid: %v", player.PlayerID)
req := payloadMsg.(*proto.ChooseCurAvatarTeamReq) req := payloadMsg.(*proto.ChooseCurAvatarTeamReq)
teamId := req.TeamId teamId := req.TeamId
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world.multiplayer { if world.multiplayer {
return return
} }
@@ -189,13 +192,12 @@ func (g *GameManager) ChooseCurAvatarTeamReq(player *model.Player, payloadMsg pb
scene := world.GetSceneById(player.SceneId) scene := world.GetSceneById(player.SceneId)
scene.UpdatePlayerTeamEntity(player) scene.UpdatePlayerTeamEntity(player)
// PacketSceneTeamUpdateNotify
sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world) sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world)
g.SendMsg(cmd.SceneTeamUpdateNotify, player.PlayerID, player.ClientSeq, sceneTeamUpdateNotify) g.SendMsg(cmd.SceneTeamUpdateNotify, player.PlayerID, player.ClientSeq, sceneTeamUpdateNotify)
// PacketChooseCurAvatarTeamRsp chooseCurAvatarTeamRsp := &proto.ChooseCurAvatarTeamRsp{
chooseCurAvatarTeamRsp := new(proto.ChooseCurAvatarTeamRsp) CurTeamId: teamId,
chooseCurAvatarTeamRsp.CurTeamId = teamId }
g.SendMsg(cmd.ChooseCurAvatarTeamRsp, player.PlayerID, player.ClientSeq, chooseCurAvatarTeamRsp) g.SendMsg(cmd.ChooseCurAvatarTeamRsp, player.PlayerID, player.ClientSeq, chooseCurAvatarTeamRsp)
} }
@@ -204,11 +206,11 @@ func (g *GameManager) ChangeMpTeamAvatarReq(player *model.Player, payloadMsg pb.
req := payloadMsg.(*proto.ChangeMpTeamAvatarReq) req := payloadMsg.(*proto.ChangeMpTeamAvatarReq)
avatarGuidList := req.AvatarGuidList avatarGuidList := req.AvatarGuidList
world := g.worldManager.GetWorldByID(player.WorldId) world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if len(avatarGuidList) == 0 || len(avatarGuidList) > 4 || !world.multiplayer { if len(avatarGuidList) == 0 || len(avatarGuidList) > 4 || !world.multiplayer {
// PacketChangeMpTeamAvatarRsp changeMpTeamAvatarRsp := &proto.ChangeMpTeamAvatarRsp{
changeMpTeamAvatarRsp := new(proto.ChangeMpTeamAvatarRsp) Retcode: int32(proto.Retcode_RETCODE_RET_SVR_ERROR),
changeMpTeamAvatarRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SVR_ERROR) }
g.SendMsg(cmd.ChangeMpTeamAvatarRsp, player.PlayerID, player.ClientSeq, changeMpTeamAvatarRsp) g.SendMsg(cmd.ChangeMpTeamAvatarRsp, player.PlayerID, player.ClientSeq, changeMpTeamAvatarRsp)
return return
} }
@@ -230,14 +232,14 @@ func (g *GameManager) ChangeMpTeamAvatarReq(player *model.Player, payloadMsg pb.
scene.UpdatePlayerTeamEntity(player) scene.UpdatePlayerTeamEntity(player)
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.playerMap {
// PacketSceneTeamUpdateNotify
sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world) sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world)
g.SendMsg(cmd.SceneTeamUpdateNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, sceneTeamUpdateNotify) g.SendMsg(cmd.SceneTeamUpdateNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, sceneTeamUpdateNotify)
} }
// PacketChangeMpTeamAvatarRsp changeMpTeamAvatarRsp := &proto.ChangeMpTeamAvatarRsp{
changeMpTeamAvatarRsp := new(proto.ChangeMpTeamAvatarRsp) CurAvatarGuid: player.AvatarMap[player.TeamConfig.GetActiveAvatarId()].Guid,
changeMpTeamAvatarRsp.CurAvatarGuid = player.AvatarMap[player.TeamConfig.GetActiveAvatarId()].Guid AvatarGuidList: make([]uint64, 0),
}
team := player.TeamConfig.GetTeamByIndex(3) team := player.TeamConfig.GetTeamByIndex(3)
for _, avatarId := range team.AvatarIdList { for _, avatarId := range team.AvatarIdList {
if avatarId == 0 { if avatarId == 0 {
@@ -249,8 +251,9 @@ func (g *GameManager) ChangeMpTeamAvatarReq(player *model.Player, payloadMsg pb.
} }
func (g *GameManager) PacketSceneTeamUpdateNotify(world *World) *proto.SceneTeamUpdateNotify { func (g *GameManager) PacketSceneTeamUpdateNotify(world *World) *proto.SceneTeamUpdateNotify {
sceneTeamUpdateNotify := new(proto.SceneTeamUpdateNotify) sceneTeamUpdateNotify := &proto.SceneTeamUpdateNotify{
sceneTeamUpdateNotify.IsInMp = world.multiplayer IsInMp: world.multiplayer,
}
empty := new(proto.AbilitySyncStateInfo) empty := new(proto.AbilitySyncStateInfo)
for _, worldPlayer := range world.playerMap { for _, worldPlayer := range world.playerMap {
worldPlayerScene := world.GetSceneById(worldPlayer.SceneId) worldPlayerScene := world.GetSceneById(worldPlayer.SceneId)

View File

@@ -38,7 +38,7 @@ func (g *GameManager) GetAllWeaponDataConfig() map[int32]*gdc.ItemData {
} }
func (g *GameManager) AddUserWeapon(userId uint32, itemId uint32) uint64 { func (g *GameManager) AddUserWeapon(userId uint32, itemId uint32) uint64 {
player := g.userManager.GetOnlineUser(userId) player := USER_MANAGER.GetOnlineUser(userId)
if player == nil { if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId) logger.LOG.Error("player is nil, uid: %v", userId)
return 0 return 0
@@ -51,9 +51,10 @@ func (g *GameManager) AddUserWeapon(userId uint32, itemId uint32) uint64 {
return 0 return 0
} }
// PacketStoreItemChangeNotify storeItemChangeNotify := &proto.StoreItemChangeNotify{
storeItemChangeNotify := new(proto.StoreItemChangeNotify) StoreType: proto.StoreType_STORE_TYPE_PACK,
storeItemChangeNotify.StoreType = proto.StoreType_STORE_TYPE_PACK ItemList: make([]*proto.Item, 0),
}
affixMap := make(map[uint32]uint32) affixMap := make(map[uint32]uint32)
for _, affixId := range weapon.AffixIdList { for _, affixId := range weapon.AffixIdList {
affixMap[affixId] = uint32(weapon.Refinement) affixMap[affixId] = uint32(weapon.Refinement)