优化代码格式

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
netMsgOutput chan *cmd.NetMsg
snowflake *alg.SnowflakeWorker
// 用户管理器
userManager *UserManager
// 世界管理器
worldManager *WorldManager
}
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
LOCAL_EVENT_MANAGER = NewLocalEventManager()
ROUTE_MANAGER = NewRouteManager()
r.userManager = NewUserManager(dao, LOCAL_EVENT_MANAGER.localEventChan)
USER_MANAGER = r.userManager
r.worldManager = NewWorldManager(r.snowflake)
WORLD_MANAGER = r.worldManager
USER_MANAGER = NewUserManager(dao, LOCAL_EVENT_MANAGER.localEventChan)
WORLD_MANAGER = NewWorldManager(r.snowflake)
TICK_MANAGER = NewTickManager()
COMMAND_MANAGER = NewCommandManager()
return r

View File

@@ -81,7 +81,7 @@ func (t *TickManager) onTick10Minute(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 _, player := range world.playerMap {
// 随机物品
@@ -117,17 +117,19 @@ func (t *TickManager) onTick10Second(now int64) {
for _, world := range WORLD_MANAGER.worldMap {
for _, scene := range world.sceneMap {
for _, player := range scene.playerMap {
// PacketSceneTimeNotify
sceneTimeNotify := new(proto.SceneTimeNotify)
sceneTimeNotify.SceneId = player.SceneId
sceneTimeNotify.SceneTime = uint64(scene.GetSceneTime())
GAME_MANAGER.SendMsg(cmd.SceneTimeNotify, player.PlayerID, player.ClientSeq, sceneTimeNotify)
// PacketPlayerTimeNotify
playerTimeNotify := new(proto.PlayerTimeNotify)
playerTimeNotify.IsPaused = player.Pause
playerTimeNotify.PlayerTime = uint64(player.TotalOnlineTime)
playerTimeNotify.ServerTime = uint64(time.Now().UnixMilli())
GAME_MANAGER.SendMsg(cmd.PlayerTimeNotify, player.PlayerID, player.ClientSeq, playerTimeNotify)
sceneTimeNotify := &proto.SceneTimeNotify{
SceneId: player.SceneId,
SceneTime: uint64(scene.GetSceneTime()),
}
GAME_MANAGER.SendMsg(cmd.SceneTimeNotify, player.PlayerID, 0, sceneTimeNotify)
playerTimeNotify := &proto.PlayerTimeNotify{
IsPaused: player.Pause,
PlayerTime: uint64(player.TotalOnlineTime),
ServerTime: uint64(time.Now().UnixMilli()),
}
GAME_MANAGER.SendMsg(cmd.PlayerTimeNotify, player.PlayerID, 0, playerTimeNotify)
}
}
if !world.IsBigWorld() && (world.multiplayer || !world.owner.Pause) {
@@ -172,9 +174,12 @@ func (t *TickManager) onTick5Second(now int64) {
}
for _, player := range world.playerMap {
if world.multiplayer {
scene := world.GetSceneById(player.SceneId)
// 多人世界其他玩家的坐标位置广播
// PacketWorldPlayerLocationNotify
worldPlayerLocationNotify := new(proto.WorldPlayerLocationNotify)
worldPlayerLocationNotify := &proto.WorldPlayerLocationNotify{
PlayerWorldLocList: make([]*proto.PlayerWorldLocationInfo, 0),
}
for _, worldPlayer := range world.playerMap {
playerWorldLocationInfo := &proto.PlayerWorldLocationInfo{
SceneId: worldPlayer.SceneId,
@@ -196,10 +201,10 @@ func (t *TickManager) onTick5Second(now int64) {
}
GAME_MANAGER.SendMsg(cmd.WorldPlayerLocationNotify, player.PlayerID, 0, worldPlayerLocationNotify)
// PacketScenePlayerLocationNotify
scene := world.GetSceneById(player.SceneId)
scenePlayerLocationNotify := new(proto.ScenePlayerLocationNotify)
scenePlayerLocationNotify.SceneId = player.SceneId
scenePlayerLocationNotify := &proto.ScenePlayerLocationNotify{
SceneId: player.SceneId,
PlayerLocList: make([]*proto.PlayerLocationInfo, 0),
}
for _, scenePlayer := range scene.playerMap {
playerLocationInfo := &proto.PlayerLocationInfo{
Uid: scenePlayer.PlayerID,
@@ -226,9 +231,9 @@ func (t *TickManager) onTickSecond(now int64) {
for _, world := range WORLD_MANAGER.worldMap {
for _, player := range world.playerMap {
// 世界里所有玩家的网络延迟广播
// PacketWorldPlayerRTTNotify
worldPlayerRTTNotify := new(proto.WorldPlayerRTTNotify)
worldPlayerRTTNotify.PlayerRttList = make([]*proto.PlayerRTTInfo, 0)
worldPlayerRTTNotify := &proto.WorldPlayerRTTNotify{
PlayerRttList: make([]*proto.PlayerRTTInfo, 0),
}
for _, worldPlayer := range world.playerMap {
playerRTTInfo := &proto.PlayerRTTInfo{Uid: worldPlayer.PlayerID, Rtt: worldPlayer.ClientRTT}
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) {
player := g.userManager.GetOnlineUser(userId)
player := USER_MANAGER.GetOnlineUser(userId)
if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId)
return
@@ -52,13 +52,12 @@ func (g *GameManager) AddUserAvatar(userId uint32, avatarId uint32) {
// 角色装上初始武器
g.WearUserAvatarEquip(player.PlayerID, avatarId, weaponId)
// TODO 真的有必要存在吗
g.UpdateUserAvatarFightProp(player.PlayerID, avatarId)
// PacketAvatarAddNotify
avatarAddNotify := new(proto.AvatarAddNotify)
avatarAddNotify.Avatar = g.PacketAvatarInfo(avatar)
avatarAddNotify.IsInTeam = false
avatarAddNotify := &proto.AvatarAddNotify{
Avatar: g.PacketAvatarInfo(avatar),
IsInTeam: false,
}
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)
g.WearUserAvatarEquip(player.PlayerID, avatar.AvatarId, weapon.WeaponId)
// PacketWearEquipRsp
wearEquipRsp := new(proto.WearEquipRsp)
wearEquipRsp.AvatarGuid = avatarGuid
wearEquipRsp.EquipGuid = equipGuid
wearEquipRsp := &proto.WearEquipRsp{
AvatarGuid: avatarGuid,
EquipGuid: equipGuid,
}
g.SendMsg(cmd.WearEquipRsp, player.PlayerID, player.ClientSeq, wearEquipRsp)
}
func (g *GameManager) WearUserAvatarEquip(userId uint32, avatarId uint32, weaponId uint64) {
player := g.userManager.GetOnlineUser(userId)
player := USER_MANAGER.GetOnlineUser(userId)
if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId)
return
@@ -87,7 +86,7 @@ func (g *GameManager) WearUserAvatarEquip(userId uint32, avatarId uint32, weapon
avatar := player.AvatarMap[avatarId]
weapon := player.WeaponMap[weaponId]
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId)
playerTeamEntity := scene.GetPlayerTeamEntity(player.PlayerID)
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])
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
} 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])
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.Costume = req.CostumeId
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId)
// PacketAvatarChangeCostumeNotify
avatarChangeCostumeNotify := new(proto.AvatarChangeCostumeNotify)
avatarChangeCostumeNotify.EntityInfo = g.PacketSceneEntityInfoAvatar(scene, player, avatar.AvatarId)
for _, scenePlayer := range scene.playerMap {
g.SendMsg(cmd.AvatarChangeCostumeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, avatarChangeCostumeNotify)
}
// PacketAvatarChangeCostumeRsp
avatarChangeCostumeRsp := new(proto.AvatarChangeCostumeRsp)
avatarChangeCostumeRsp.AvatarGuid = req.AvatarGuid
avatarChangeCostumeRsp.CostumeId = req.CostumeId
avatarChangeCostumeRsp := &proto.AvatarChangeCostumeRsp{
AvatarGuid: req.AvatarGuid,
CostumeId: req.CostumeId,
}
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.FlyCloak = req.FlycloakId
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId)
// PacketAvatarFlycloakChangeNotify
avatarFlycloakChangeNotify := new(proto.AvatarFlycloakChangeNotify)
avatarFlycloakChangeNotify.AvatarGuid = avatarGuid
avatarFlycloakChangeNotify.FlycloakId = flycloakId
avatarFlycloakChangeNotify := &proto.AvatarFlycloakChangeNotify{
AvatarGuid: avatarGuid,
FlycloakId: flycloakId,
}
for _, scenePlayer := range scene.playerMap {
g.SendMsg(cmd.AvatarFlycloakChangeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, avatarFlycloakChangeNotify)
}
// PacketAvatarWearFlycloakRsp
avatarWearFlycloakRsp := new(proto.AvatarWearFlycloakRsp)
avatarWearFlycloakRsp.AvatarGuid = req.AvatarGuid
avatarWearFlycloakRsp.FlycloakId = req.FlycloakId
avatarWearFlycloakRsp := &proto.AvatarWearFlycloakRsp{
AvatarGuid: req.AvatarGuid,
FlycloakId: req.FlycloakId,
}
g.SendMsg(cmd.AvatarWearFlycloakRsp, player.PlayerID, player.ClientSeq, avatarWearFlycloakRsp)
}
func (g *GameManager) PacketAvatarEquipChangeNotify(avatar *model.Avatar, weapon *model.Weapon, entityId uint32) *proto.AvatarEquipChangeNotify {
itemDataConfig, ok := gdc.CONF.ItemDataMap[int32(weapon.ItemId)]
avatarEquipChangeNotify := new(proto.AvatarEquipChangeNotify)
avatarEquipChangeNotify.AvatarGuid = avatar.Guid
if ok {
avatarEquipChangeNotify.EquipType = uint32(itemDataConfig.EquipEnumType)
avatarEquipChangeNotify := &proto.AvatarEquipChangeNotify{
AvatarGuid: avatar.Guid,
ItemId: weapon.ItemId,
EquipGuid: weapon.Guid,
}
avatarEquipChangeNotify.ItemId = weapon.ItemId
avatarEquipChangeNotify.EquipGuid = weapon.Guid
avatarEquipChangeNotify.Weapon = &proto.SceneWeaponInfo{
EntityId: entityId,
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),
AbilityInfo: new(proto.AbilitySyncStateInfo),
}
itemDataConfig, ok := gdc.CONF.ItemDataMap[int32(weapon.ItemId)]
if ok {
avatarEquipChangeNotify.EquipType = uint32(itemDataConfig.EquipEnumType)
}
return avatarEquipChangeNotify
}
func (g *GameManager) PacketAvatarEquipTakeOffNotify(avatar *model.Avatar, weapon *model.Weapon) *proto.AvatarEquipChangeNotify {
avatarEquipChangeNotify := new(proto.AvatarEquipChangeNotify)
avatarEquipChangeNotify.AvatarGuid = avatar.Guid
avatarEquipChangeNotify := &proto.AvatarEquipChangeNotify{
AvatarGuid: avatar.Guid,
}
itemDataConfig, ok := gdc.CONF.ItemDataMap[int32(weapon.ItemId)]
if ok {
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) {
player := g.userManager.GetOnlineUser(userId)
player := USER_MANAGER.GetOnlineUser(userId)
if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId)
return
}
avatarFightPropNotify := new(proto.AvatarFightPropNotify)
avatar := player.AvatarMap[avatarId]
avatarFightPropNotify.AvatarGuid = avatar.Guid
avatarFightPropNotify.FightPropMap = avatar.FightPropMap
avatarFightPropNotify := &proto.AvatarFightPropNotify{
AvatarGuid: avatar.Guid,
FightPropMap: avatar.FightPropMap,
}
g.SendMsg(cmd.AvatarFightPropNotify, userId, player.ClientSeq, avatarFightPropNotify)
}
@@ -303,7 +302,6 @@ func (g *GameManager) PacketAvatarInfo(avatar *model.Avatar) *proto.AvatarInfo {
FetterInfo: &proto.AvatarFetterInfo{
ExpLevel: uint32(avatar.FetterLevel),
ExpNumber: avatar.FetterExp,
// FetterList 不知道是啥 该角色在配置表里的所有FetterId
// TODO 资料解锁条目
FetterList: nil,
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 {
chatList := world.GetChatList()
count := len(chatList)
@@ -37,18 +37,18 @@ func (g *GameManager) PullRecentChatReq(player *model.Player, payloadMsg pb.Mess
count = 10
}
for i := len(chatList) - count; i < len(chatList); i++ {
// PacketPlayerChatNotify
playerChatNotify := new(proto.PlayerChatNotify)
playerChatNotify.ChannelId = 0
playerChatNotify.ChatInfo = chatList[i]
g.SendMsg(cmd.PlayerChatNotify, player.PlayerID, 0, playerChatNotify)
playerChatNotify := &proto.PlayerChatNotify{
ChannelId: 0,
ChatInfo: chatList[i],
}
g.SendMsg(cmd.PlayerChatNotify, player.PlayerID, player.ClientSeq, playerChatNotify)
}
}
// PacketPullRecentChatRsp
pullRecentChatRsp := new(proto.PullRecentChatRsp)
pullRecentChatRsp.ChatInfo = retMsgList
g.SendMsg(cmd.PullRecentChatRsp, player.PlayerID, 0, pullRecentChatRsp)
pullRecentChatRsp := &proto.PullRecentChatRsp{
ChatInfo: retMsgList,
}
g.SendMsg(cmd.PullRecentChatRsp, player.PlayerID, player.ClientSeq, pullRecentChatRsp)
}
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))
}
// PacketPullPrivateChatRsp
pullPrivateChatRsp := new(proto.PullPrivateChatRsp)
pullPrivateChatRsp.ChatInfo = retMsgList
g.SendMsg(cmd.PullPrivateChatRsp, player.PlayerID, 0, pullPrivateChatRsp)
pullPrivateChatRsp := &proto.PullPrivateChatRsp{
ChatInfo: retMsgList,
}
g.SendMsg(cmd.PullPrivateChatRsp, player.PlayerID, player.ClientSeq, pullPrivateChatRsp)
}
// SendPrivateChat 发送私聊文本消息给玩家
@@ -119,16 +119,16 @@ func (g *GameManager) SendPrivateChat(player, targetPlayer *model.Player, conten
// 如果目标玩家在线发送消息
if targetPlayer.Online {
// PacketPrivateChatNotify
privateChatNotify := new(proto.PrivateChatNotify)
privateChatNotify.ChatInfo = chatInfo
g.SendMsg(cmd.PrivateChatNotify, targetPlayer.PlayerID, 0, privateChatNotify)
privateChatNotify := &proto.PrivateChatNotify{
ChatInfo: chatInfo,
}
g.SendMsg(cmd.PrivateChatNotify, targetPlayer.PlayerID, player.ClientSeq, privateChatNotify)
}
// PacketPrivateChatNotify
privateChatNotify := new(proto.PrivateChatNotify)
privateChatNotify.ChatInfo = chatInfo
g.SendMsg(cmd.PrivateChatNotify, player.PlayerID, 0, privateChatNotify)
privateChatNotify := &proto.PrivateChatNotify{
ChatInfo: chatInfo,
}
g.SendMsg(cmd.PrivateChatNotify, player.PlayerID, player.ClientSeq, privateChatNotify)
}
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
// TODO 同步阻塞待优化
targetPlayer := g.userManager.LoadTempOfflineUserSync(targetUid)
targetPlayer := USER_MANAGER.LoadTempOfflineUserSync(targetUid)
if targetPlayer == nil {
return
}
@@ -167,9 +167,7 @@ func (g *GameManager) PrivateChatReq(player *model.Player, payloadMsg pb.Message
return
}
// PacketPrivateChatRsp
privateChatRsp := new(proto.PrivateChatRsp)
g.SendMsg(cmd.PrivateChatRsp, player.PlayerID, 0, privateChatRsp)
g.SendMsg(cmd.PrivateChatRsp, player.PlayerID, player.ClientSeq, new(proto.PrivateChatRsp))
}
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
// PacketReadPrivateChatRsp
readPrivateChatRsp := new(proto.ReadPrivateChatRsp)
g.SendMsg(cmd.ReadPrivateChatRsp, player.PlayerID, 0, readPrivateChatRsp)
g.SendMsg(cmd.ReadPrivateChatRsp, player.PlayerID, player.ClientSeq, new(proto.ReadPrivateChatRsp))
}
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
}
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
world.AddChat(sendChatInfo)
// PacketPlayerChatNotify
playerChatNotify := new(proto.PlayerChatNotify)
playerChatNotify.ChannelId = channelId
playerChatNotify.ChatInfo = sendChatInfo
playerChatNotify := &proto.PlayerChatNotify{
ChannelId: channelId,
ChatInfo: sendChatInfo,
}
for _, worldPlayer := range world.playerMap {
g.SendMsg(cmd.PlayerChatNotify, worldPlayer.PlayerID, 0, playerChatNotify)
g.SendMsg(cmd.PlayerChatNotify, worldPlayer.PlayerID, player.ClientSeq, playerChatNotify)
}
// PacketPlayerChatRsp
playerChatRsp := new(proto.PlayerChatRsp)
g.SendMsg(cmd.PlayerChatRsp, player.PlayerID, 0, playerChatRsp)
g.SendMsg(cmd.PlayerChatRsp, player.PlayerID, player.ClientSeq, new(proto.PlayerChatRsp))
}
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)
req := payloadMsg.(*proto.UnionCmdNotify)
_ = req
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world == nil {
return
}
@@ -29,13 +29,12 @@ func (g *GameManager) UnionCmdNotify(player *model.Player, payloadMsg pb.Message
continue
}
if entity.avatarEntity != nil {
otherPlayer := g.userManager.GetOnlineUser(entity.avatarEntity.uid)
otherPlayer := USER_MANAGER.GetOnlineUser(entity.avatarEntity.uid)
surrPlayerList = append(surrPlayerList, otherPlayer)
}
}
// CombatInvocationsNotify转发
// PacketCombatInvocationsNotify
if player.CombatInvokeHandler.AllLen() > 0 {
combatInvocationsNotify := new(proto.CombatInvocationsNotify)
combatInvocationsNotify.InvokeList = player.CombatInvokeHandler.EntryListForwardAll
@@ -60,7 +59,6 @@ func (g *GameManager) UnionCmdNotify(player *model.Player, payloadMsg pb.Message
}
// AbilityInvocationsNotify转发
// PacketAbilityInvocationsNotify
if player.AbilityInvokeHandler.AllLen() > 0 {
abilityInvocationsNotify := new(proto.AbilityInvocationsNotify)
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)
req := payloadMsg.(*proto.MassiveEntityElementOpBatchNotify)
ntf := req
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world == nil {
return
}
@@ -110,7 +108,7 @@ func (g *GameManager) MassiveEntityElementOpBatchNotify(player *model.Player, pa
continue
}
if entity.avatarEntity != nil {
otherPlayer := g.userManager.GetOnlineUser(entity.avatarEntity.uid)
otherPlayer := USER_MANAGER.GetOnlineUser(entity.avatarEntity.uid)
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)
req := payloadMsg.(*proto.CombatInvocationsNotify)
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world == nil {
return
}
@@ -225,11 +223,11 @@ func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg p
world.aoiManager.AddEntityIdToGrid(playerActiveAvatarEntityId, newGid)
// 其他玩家
for _, uid := range delUidList {
otherPlayer := g.userManager.GetOnlineUser(uid)
otherPlayer := USER_MANAGER.GetOnlineUser(uid)
g.RemoveSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_TYPE_REMOVE, []uint32{playerActiveAvatarEntityId})
}
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)
}
}
@@ -351,7 +349,7 @@ func (g *GameManager) ClientAbilityInitFinishNotify(player *model.Player, payloa
invokeHandler.AddEntry(entry.ForwardType, entry)
}
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world == nil {
return
}
@@ -367,13 +365,12 @@ func (g *GameManager) ClientAbilityInitFinishNotify(player *model.Player, payloa
continue
}
if entity.avatarEntity != nil {
otherPlayer := g.userManager.GetOnlineUser(entity.avatarEntity.uid)
otherPlayer := USER_MANAGER.GetOnlineUser(entity.avatarEntity.uid)
surrPlayerList = append(surrPlayerList, otherPlayer)
}
}
// ClientAbilityInitFinishNotify转发
// PacketClientAbilityInitFinishNotify
if invokeHandler.AllLen() == 0 && invokeHandler.AllExceptCurLen() == 0 && invokeHandler.HostLen() == 0 {
for _, v := range surrPlayerList {
if player.PlayerID == v.PlayerID {
@@ -418,7 +415,7 @@ func (g *GameManager) ClientAbilityChangeNotify(player *model.Player, payloadMsg
for _, entry := range req.Invokes {
invokeHandler.AddEntry(entry.ForwardType, entry)
}
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world == nil {
return
}
@@ -434,13 +431,12 @@ func (g *GameManager) ClientAbilityChangeNotify(player *model.Player, payloadMsg
continue
}
if entity.avatarEntity != nil {
otherPlayer := g.userManager.GetOnlineUser(entity.avatarEntity.uid)
otherPlayer := USER_MANAGER.GetOnlineUser(entity.avatarEntity.uid)
surrPlayerList = append(surrPlayerList, otherPlayer)
}
}
// ClientAbilityChangeNotify转发
// PacketClientAbilityChangeNotify
if invokeHandler.AllLen() == 0 && invokeHandler.AllExceptCurLen() == 0 && invokeHandler.HostLen() == 0 {
clientAbilityChangeNotify := new(proto.ClientAbilityChangeNotify)
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)
req := payloadMsg.(*proto.PlayerSetPauseReq)
isPaused := req.IsPaused
player.Pause = isPaused
// PacketPlayerSetPauseRsp
playerSetPauseRsp := new(proto.PlayerSetPauseRsp)
g.SendMsg(cmd.PlayerSetPauseRsp, player.PlayerID, player.ClientSeq, playerSetPauseRsp)
g.SendMsg(cmd.PlayerSetPauseRsp, player.PlayerID, player.ClientSeq, new(proto.PlayerSetPauseRsp))
}
func (g *GameManager) TowerAllDataReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user get tower all data, uid: %v", player.PlayerID)
// PacketTowerAllDataRsp
towerAllDataRsp := new(proto.TowerAllDataRsp)
towerAllDataRsp.TowerScheduleId = 29
towerAllDataRsp.TowerFloorRecordList = []*proto.TowerFloorRecord{{FloorId: 1001}}
towerAllDataRsp.CurLevelRecord = &proto.TowerCurLevelRecord{IsEmpty: true}
towerAllDataRsp.NextScheduleChangeTime = 4294967295
towerAllDataRsp.FloorOpenTimeMap = make(map[uint32]uint32)
towerAllDataRsp.FloorOpenTimeMap[1024] = 1630486800
towerAllDataRsp.FloorOpenTimeMap[1025] = 1630486800
towerAllDataRsp.FloorOpenTimeMap[1026] = 1630486800
towerAllDataRsp.FloorOpenTimeMap[1027] = 1630486800
towerAllDataRsp.ScheduleStartTime = 1630486800
towerAllDataRsp := &proto.TowerAllDataRsp{
TowerScheduleId: 29,
TowerFloorRecordList: []*proto.TowerFloorRecord{{FloorId: 1001}},
CurLevelRecord: &proto.TowerCurLevelRecord{IsEmpty: true},
NextScheduleChangeTime: 4294967295,
FloorOpenTimeMap: map[uint32]uint32{
1024: 1630486800,
1025: 1630486800,
1026: 1630486800,
1027: 1630486800,
},
ScheduleStartTime: 1630486800,
}
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)
req := payloadMsg.(*proto.EntityAiSyncNotify)
// PacketEntityAiSyncNotify
entityAiSyncNotify := new(proto.EntityAiSyncNotify)
entityAiSyncNotify.InfoList = make([]*proto.AiSyncInfo, 0)
entityAiSyncNotify := &proto.EntityAiSyncNotify{
InfoList: make([]*proto.AiSyncInfo, 0),
}
for _, monsterId := range req.LocalAvatarAlertedMonsterList {
entityAiSyncNotify.InfoList = append(entityAiSyncNotify.InfoList, &proto.AiSyncInfo{
EntityId: monsterId,
@@ -59,7 +57,7 @@ func (g *GameManager) EntityAiSyncNotify(player *model.Player, payloadMsg pb.Mes
}
func (g *GameManager) ClientTimeNotify(userId uint32, clientTime uint32) {
player := g.userManager.GetOnlineUser(userId)
player := USER_MANAGER.GetOnlineUser(userId)
if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId)
return
@@ -69,7 +67,7 @@ func (g *GameManager) ClientTimeNotify(userId uint32, clientTime uint32) {
}
func (g *GameManager) ClientRttNotify(userId uint32, clientRtt uint32) {
player := g.userManager.GetOnlineUser(userId)
player := USER_MANAGER.GetOnlineUser(userId)
if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId)
return
@@ -79,24 +77,26 @@ func (g *GameManager) ClientRttNotify(userId uint32, clientRtt uint32) {
}
func (g *GameManager) ServerAnnounceNotify(announceId uint32, announceMsg string) {
for _, onlinePlayer := range g.userManager.GetAllOnlineUserList() {
serverAnnounceNotify := new(proto.ServerAnnounceNotify)
for _, onlinePlayer := range USER_MANAGER.GetAllOnlineUserList() {
now := uint32(time.Now().Unix())
serverAnnounceNotify.AnnounceDataList = []*proto.AnnounceData{{
ConfigId: announceId,
BeginTime: now + 1,
EndTime: now + 2,
CenterSystemText: announceMsg,
CenterSystemFrequency: 1,
}}
serverAnnounceNotify := &proto.ServerAnnounceNotify{
AnnounceDataList: []*proto.AnnounceData{{
ConfigId: announceId,
BeginTime: now + 1,
EndTime: now + 2,
CenterSystemText: announceMsg,
CenterSystemFrequency: 1,
}},
}
g.SendMsg(cmd.ServerAnnounceNotify, onlinePlayer.PlayerID, 0, serverAnnounceNotify)
}
}
func (g *GameManager) ServerAnnounceRevokeNotify(announceId uint32) {
for _, onlinePlayer := range g.userManager.GetAllOnlineUserList() {
serverAnnounceRevokeNotify := new(proto.ServerAnnounceRevokeNotify)
serverAnnounceRevokeNotify.ConfigIdList = []uint32{announceId}
for _, onlinePlayer := range USER_MANAGER.GetAllOnlineUserList() {
serverAnnounceRevokeNotify := &proto.ServerAnnounceRevokeNotify{
ConfigIdList: []uint32{announceId},
}
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)
req := payloadMsg.(*proto.ToTheMoonEnterSceneReq)
_ = 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) {

View File

@@ -24,8 +24,6 @@ type UserInfo struct {
func (g *GameManager) GetGachaInfoReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user get gacha info, uid: %v", player.PlayerID)
serverAddr := config.CONF.Hk4e.GachaHistoryServer
getGachaInfoRsp := new(proto.GetGachaInfoRsp)
getGachaInfoRsp.GachaRandom = 12345
userInfo := &UserInfo{
UserId: player.PlayerID,
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)
jwtStr = "default.jwt.token"
}
getGachaInfoRsp := new(proto.GetGachaInfoRsp)
getGachaInfoRsp.GachaRandom = 12345
getGachaInfoRsp.GachaInfoList = []*proto.GachaInfo{
// 温迪
{
@@ -190,7 +191,6 @@ func (g *GameManager) GetGachaInfoReq(player *model.Player, payloadMsg pb.Messag
IsNewWish: false,
},
}
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
}
// 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{
{
@@ -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++ {
var ok bool
var itemId uint32
@@ -378,7 +378,7 @@ const (
// 单抽一次
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 {
logger.LOG.Error("player is nil, uid: %v", userId)
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) {
player := g.userManager.GetOnlineUser(userId)
player := USER_MANAGER.GetOnlineUser(userId)
if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId)
return
@@ -58,9 +58,10 @@ func (g *GameManager) AddUserItem(userId uint32, itemList []*UserItem, isHint bo
player.AddItem(userItem.ItemId, userItem.ChangeCount)
}
// PacketStoreItemChangeNotify
storeItemChangeNotify := new(proto.StoreItemChangeNotify)
storeItemChangeNotify.StoreType = proto.StoreType_STORE_TYPE_PACK
storeItemChangeNotify := &proto.StoreItemChangeNotify{
StoreType: proto.StoreType_STORE_TYPE_PACK,
ItemList: make([]*proto.Item, 0),
}
for _, userItem := range itemList {
pbItem := &proto.Item{
ItemId: userItem.ItemId,
@@ -79,9 +80,10 @@ func (g *GameManager) AddUserItem(userId uint32, itemList []*UserItem, isHint bo
if hintReason == 0 {
hintReason = constant.ActionReasonConst.SubfieldDrop
}
// PacketItemAddHintNotify
itemAddHintNotify := new(proto.ItemAddHintNotify)
itemAddHintNotify.Reason = uint32(hintReason)
itemAddHintNotify := &proto.ItemAddHintNotify{
Reason: uint32(hintReason),
ItemList: make([]*proto.ItemHint, 0),
}
for _, userItem := range itemList {
itemAddHintNotify.ItemList = append(itemAddHintNotify.ItemList, &proto.ItemHint{
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)
}
// PacketPlayerPropNotify
playerPropNotify := new(proto.PlayerPropNotify)
playerPropNotify.PropMap = make(map[uint32]*proto.PropValue)
playerPropNotify := &proto.PlayerPropNotify{
PropMap: make(map[uint32]*proto.PropValue),
}
for _, userItem := range itemList {
isVirtualItem, prop := player.GetVirtualItemProp(userItem.ItemId)
if !isVirtualItem {
@@ -114,7 +116,7 @@ func (g *GameManager) AddUserItem(userId uint32, itemList []*UserItem, isHint bo
}
func (g *GameManager) CostUserItem(userId uint32, itemList []*UserItem) {
player := g.userManager.GetOnlineUser(userId)
player := USER_MANAGER.GetOnlineUser(userId)
if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId)
return
@@ -123,9 +125,10 @@ func (g *GameManager) CostUserItem(userId uint32, itemList []*UserItem) {
player.CostItem(userItem.ItemId, userItem.ChangeCount)
}
// PacketStoreItemChangeNotify
storeItemChangeNotify := new(proto.StoreItemChangeNotify)
storeItemChangeNotify.StoreType = proto.StoreType_STORE_TYPE_PACK
storeItemChangeNotify := &proto.StoreItemChangeNotify{
StoreType: proto.StoreType_STORE_TYPE_PACK,
ItemList: make([]*proto.Item, 0),
}
for _, userItem := range itemList {
count := player.GetItemCount(userItem.ItemId)
if count == 0 {
@@ -146,9 +149,10 @@ func (g *GameManager) CostUserItem(userId uint32, itemList []*UserItem) {
g.SendMsg(cmd.StoreItemChangeNotify, userId, player.ClientSeq, storeItemChangeNotify)
}
// PacketStoreItemDelNotify
storeItemDelNotify := new(proto.StoreItemDelNotify)
storeItemDelNotify.StoreType = proto.StoreType_STORE_TYPE_PACK
storeItemDelNotify := &proto.StoreItemDelNotify{
StoreType: proto.StoreType_STORE_TYPE_PACK,
GuidList: make([]uint64, 0),
}
for _, userItem := range itemList {
count := player.GetItemCount(userItem.ItemId)
if count > 0 {
@@ -160,9 +164,9 @@ func (g *GameManager) CostUserItem(userId uint32, itemList []*UserItem) {
g.SendMsg(cmd.StoreItemDelNotify, userId, player.ClientSeq, storeItemDelNotify)
}
// PacketPlayerPropNotify
playerPropNotify := new(proto.PlayerPropNotify)
playerPropNotify.PropMap = make(map[uint32]*proto.PropValue)
playerPropNotify := &proto.PlayerPropNotify{
PropMap: make(map[uint32]*proto.PropValue),
}
for _, userItem := range itemList {
isVirtualItem, prop := player.GetVirtualItemProp(userItem.ItemId)
if !isVirtualItem {

View File

@@ -15,7 +15,7 @@ import (
func (g *GameManager) OnLogin(userId uint32, clientSeq uint32) {
logger.LOG.Info("user login, uid: %v", userId)
player, asyncWait := g.userManager.OnlineUser(userId, clientSeq)
player, asyncWait := USER_MANAGER.OnlineUser(userId, clientSeq)
if !asyncWait {
g.OnLoginOk(userId, player, clientSeq)
}
@@ -33,7 +33,7 @@ func (g *GameManager) OnLoginOk(userId uint32, player *model.Player, clientSeq u
player.InitAll()
player.TeamConfig.UpdateTeam()
// 创建世界
world := g.worldManager.CreateWorld(player, false)
world := WORLD_MANAGER.CreateWorld(player, false)
world.AddPlayer(player, player.SceneId)
player.WorldId = world.id
@@ -63,7 +63,7 @@ func (g *GameManager) OnReg(userId uint32, clientSeq uint32, payloadMsg pb.Messa
req := payloadMsg.(*proto.SetPlayerBornDataReq)
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 {
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)
return
}
g.userManager.AddUser(player)
USER_MANAGER.AddUser(player)
g.SendMsg(cmd.SetPlayerBornDataRsp, userId, clientSeq, new(proto.SetPlayerBornDataRsp))
g.OnLogin(userId, clientSeq)
@@ -95,19 +95,19 @@ func (g *GameManager) OnRegOk(exist bool, req *proto.SetPlayerBornDataReq, userI
func (g *GameManager) OnUserOffline(userId uint32) {
logger.LOG.Info("user offline, uid: %v", userId)
player := g.userManager.GetOnlineUser(userId)
player := USER_MANAGER.GetOnlineUser(userId)
if player == nil {
logger.LOG.Error("player is nil, userId: %v", userId)
return
}
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world != nil {
g.UserWorldRemovePlayer(world, player)
}
player.OfflineTime = uint32(time.Now().Unix())
player.Online = false
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) {
@@ -119,41 +119,42 @@ func (g *GameManager) LoginNotify(userId uint32, player *model.Player, clientSeq
}
func (g *GameManager) PacketPlayerDataNotify(player *model.Player) *proto.PlayerDataNotify {
// PacketPlayerDataNotify
playerDataNotify := new(proto.PlayerDataNotify)
playerDataNotify.NickName = player.NickName
playerDataNotify.ServerTime = uint64(time.Now().UnixMilli())
playerDataNotify.IsFirstLoginToday = true
playerDataNotify.RegionId = player.RegionId
playerDataNotify.PropMap = make(map[uint32]*proto.PropValue)
playerDataNotify := &proto.PlayerDataNotify{
NickName: player.NickName,
ServerTime: uint64(time.Now().UnixMilli()),
IsFirstLoginToday: true,
RegionId: player.RegionId,
PropMap: make(map[uint32]*proto.PropValue),
}
for k, v := range player.PropertiesMap {
propValue := new(proto.PropValue)
propValue.Type = uint32(k)
propValue.Value = &proto.PropValue_Ival{Ival: int64(v)}
propValue.Val = int64(v)
propValue := &proto.PropValue{
Type: uint32(k),
Value: &proto.PropValue_Ival{Ival: int64(v)},
Val: int64(v),
}
playerDataNotify.PropMap[uint32(k)] = propValue
}
return playerDataNotify
}
func (g *GameManager) PacketStoreWeightLimitNotify() *proto.StoreWeightLimitNotify {
// PacketStoreWeightLimitNotify
storeWeightLimitNotify := new(proto.StoreWeightLimitNotify)
storeWeightLimitNotify.StoreType = proto.StoreType_STORE_TYPE_PACK
// 背包容量限制
storeWeightLimitNotify.WeightLimit = 30000
storeWeightLimitNotify.WeaponCountLimit = 2000
storeWeightLimitNotify.ReliquaryCountLimit = 1500
storeWeightLimitNotify.MaterialCountLimit = 2000
storeWeightLimitNotify.FurnitureCountLimit = 2000
storeWeightLimitNotify := &proto.StoreWeightLimitNotify{
StoreType: proto.StoreType_STORE_TYPE_PACK,
// 背包容量限制
WeightLimit: 30000,
WeaponCountLimit: 2000,
ReliquaryCountLimit: 1500,
MaterialCountLimit: 2000,
FurnitureCountLimit: 2000,
}
return storeWeightLimitNotify
}
func (g *GameManager) PacketPlayerStoreNotify(player *model.Player) *proto.PlayerStoreNotify {
// PacketPlayerStoreNotify
playerStoreNotify := new(proto.PlayerStoreNotify)
playerStoreNotify.StoreType = proto.StoreType_STORE_TYPE_PACK
playerStoreNotify.WeightLimit = 30000
playerStoreNotify := &proto.PlayerStoreNotify{
StoreType: proto.StoreType_STORE_TYPE_PACK,
WeightLimit: 30000,
}
itemDataMapConfig := gdc.CONF.ItemDataMap
for _, weapon := range player.WeaponMap {
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 {
// PacketAvatarDataNotify
avatarDataNotify := new(proto.AvatarDataNotify)
chooseAvatarId := player.MainCharAvatarId
avatarDataNotify.CurAvatarTeamId = uint32(player.TeamConfig.GetActiveTeamId())
avatarDataNotify.ChooseAvatarGuid = player.AvatarMap[chooseAvatarId].Guid
avatarDataNotify.OwnedFlycloakList = player.FlyCloakList
// 角色衣装
avatarDataNotify.OwnedCostumeList = player.CostumeList
avatarDataNotify := &proto.AvatarDataNotify{
CurAvatarTeamId: uint32(player.TeamConfig.GetActiveTeamId()),
ChooseAvatarGuid: player.AvatarMap[chooseAvatarId].Guid,
OwnedFlycloakList: player.FlyCloakList,
// 角色衣装
OwnedCostumeList: player.CostumeList,
AvatarList: make([]*proto.AvatarInfo, 0),
AvatarTeamMap: make(map[uint32]*proto.AvatarTeam),
}
for _, avatar := range player.AvatarMap {
pbAvatar := g.PacketAvatarInfo(avatar)
avatarDataNotify.AvatarList = append(avatarDataNotify.AvatarList, pbAvatar)
}
avatarDataNotify.AvatarTeamMap = make(map[uint32]*proto.AvatarTeam)
for teamIndex, team := range player.TeamConfig.TeamList {
var teamAvatarGuidList []uint64 = nil
for _, avatarId := range team.AvatarIdList {
@@ -271,10 +273,10 @@ func (g *GameManager) PacketAvatarDataNotify(player *model.Player) *proto.Avatar
}
func (g *GameManager) PacketOpenStateUpdateNotify() *proto.OpenStateUpdateNotify {
// PacketOpenStateUpdateNotify
openStateUpdateNotify := new(proto.OpenStateUpdateNotify)
openStateUpdateNotify := &proto.OpenStateUpdateNotify{
OpenStateMap: make(map[uint32]uint32),
}
openStateConstMap := reflection.ConvStructToMap(constant.OpenStateConst)
openStateUpdateNotify.OpenStateMap = make(map[uint32]uint32)
for _, v := range openStateConstMap {
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))
transPointConfig, exist := gdc.CONF.ScenePointEntries[transPointId]
if !exist {
// PacketSceneTransToPointRsp
sceneTransToPointRsp := new(proto.SceneTransToPointRsp)
sceneTransToPointRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SVR_ERROR)
sceneTransToPointRsp := &proto.SceneTransToPointRsp{
Retcode: int32(proto.Retcode_RETCODE_RET_SVR_ERROR),
}
g.SendMsg(cmd.SceneTransToPointRsp, player.PlayerID, player.ClientSeq, sceneTransToPointRsp)
return
}
@@ -37,11 +37,11 @@ func (g *GameManager) SceneTransToPointReq(player *model.Player, payloadMsg pb.M
}
g.TeleportPlayer(player, sceneId, pos)
// PacketSceneTransToPointRsp
sceneTransToPointRsp := new(proto.SceneTransToPointRsp)
sceneTransToPointRsp.Retcode = 0
sceneTransToPointRsp.PointId = req.PointId
sceneTransToPointRsp.SceneId = req.SceneId
sceneTransToPointRsp := &proto.SceneTransToPointRsp{
Retcode: 0,
PointId: req.PointId,
SceneId: req.SceneId,
}
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 {
jumpScene = true
}
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
oldScene := world.GetSceneById(oldSceneId)
activeAvatarId := player.TeamConfig.GetActiveAvatarId()
playerTeamEntity := oldScene.GetPlayerTeamEntity(player.PlayerID)
g.RemoveSceneEntityNotifyBroadcast(oldScene, proto.VisionType_VISION_TYPE_REMOVE, []uint32{playerTeamEntity.avatarEntityMap[activeAvatarId]})
if jumpScene {
// PacketDelTeamEntityNotify
delTeamEntityNotify := g.PacketDelTeamEntityNotify(oldScene, player)
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.SceneLoadState = model.SceneNone
// PacketPlayerEnterSceneNotify
var enterType proto.EnterType
if jumpScene {
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)
req := payloadMsg.(*proto.QueryPathReq)
// PacketQueryPathRsp
queryPathRsp := new(proto.QueryPathRsp)
queryPathRsp.Corners = []*proto.Vector{req.DestinationPos[0]}
queryPathRsp.QueryId = req.QueryId
queryPathRsp.QueryStatus = proto.QueryPathRsp_PATH_STATUS_TYPE_SUCC
queryPathRsp := &proto.QueryPathRsp{
Corners: []*proto.Vector{req.DestinationPos[0]},
QueryId: req.QueryId,
QueryStatus: proto.QueryPathRsp_PATH_STATUS_TYPE_SUCC,
}
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)
if req.SceneId != 3 {
getScenePointRsp := new(proto.GetScenePointRsp)
getScenePointRsp.SceneId = req.SceneId
getScenePointRsp := &proto.GetScenePointRsp{
SceneId: req.SceneId,
}
g.SendMsg(cmd.GetScenePointRsp, player.PlayerID, player.ClientSeq, getScenePointRsp)
return
}
// PacketGetScenePointRsp
getScenePointRsp := new(proto.GetScenePointRsp)
getScenePointRsp.SceneId = 3
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}
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}
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}
getScenePointRsp.HidePointList = []uint32{458, 515, 459, 514}
getScenePointRsp.GroupUnlimitPointList = []uint32{221, 131, 107, 350, 50, 424, 359}
getScenePointRsp := &proto.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},
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},
HidePointList: []uint32{458, 515, 459, 514},
GroupUnlimitPointList: []uint32{221, 131, 107, 350, 50, 424, 359},
}
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)
if req.SceneId != 3 {
getSceneAreaRsp := new(proto.GetSceneAreaRsp)
getSceneAreaRsp.SceneId = req.SceneId
getSceneAreaRsp := &proto.GetSceneAreaRsp{
SceneId: req.SceneId,
}
g.SendMsg(cmd.GetSceneAreaRsp, player.PlayerID, player.ClientSeq, getSceneAreaRsp)
return
}
// PacketGetSceneAreaRsp
getSceneAreaRsp := new(proto.GetSceneAreaRsp)
getSceneAreaRsp.SceneId = 3
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}
getSceneAreaRsp.CityInfoList = make([]*proto.CityInfo, 0)
getSceneAreaRsp.CityInfoList = append(getSceneAreaRsp.CityInfoList, &proto.CityInfo{CityId: 1, Level: 10})
getSceneAreaRsp.CityInfoList = append(getSceneAreaRsp.CityInfoList, &proto.CityInfo{CityId: 2, Level: 10})
getSceneAreaRsp.CityInfoList = append(getSceneAreaRsp.CityInfoList, &proto.CityInfo{CityId: 3, Level: 10})
getSceneAreaRsp.CityInfoList = append(getSceneAreaRsp.CityInfoList, &proto.CityInfo{CityId: 4, Level: 10})
getSceneAreaRsp.CityInfoList = append(getSceneAreaRsp.CityInfoList, &proto.CityInfo{CityId: 99, Level: 1})
getSceneAreaRsp.CityInfoList = append(getSceneAreaRsp.CityInfoList, &proto.CityInfo{CityId: 100, Level: 1})
getSceneAreaRsp.CityInfoList = append(getSceneAreaRsp.CityInfoList, &proto.CityInfo{CityId: 101, Level: 1})
getSceneAreaRsp.CityInfoList = append(getSceneAreaRsp.CityInfoList, &proto.CityInfo{CityId: 102, Level: 1})
getSceneAreaRsp := &proto.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},
CityInfoList: []*proto.CityInfo{
{CityId: 1, Level: 10},
{CityId: 2, Level: 10},
{CityId: 3, Level: 10},
{CityId: 4, Level: 10},
{CityId: 99, Level: 1},
{CityId: 100, Level: 1},
{CityId: 101, Level: 1},
{CityId: 102, Level: 1},
},
}
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)
targetUid := req.TargetUid
// PacketPlayerApplyEnterMpRsp
playerApplyEnterMpRsp := new(proto.PlayerApplyEnterMpRsp)
playerApplyEnterMpRsp.TargetUid = targetUid
playerApplyEnterMpRsp := &proto.PlayerApplyEnterMpRsp{
TargetUid: targetUid,
}
g.SendMsg(cmd.PlayerApplyEnterMpRsp, player.PlayerID, player.ClientSeq, playerApplyEnterMpRsp)
ok := g.UserApplyEnterWorld(player, targetUid)
if !ok {
// PacketPlayerApplyEnterMpResultNotify
playerApplyEnterMpResultNotify := new(proto.PlayerApplyEnterMpResultNotify)
playerApplyEnterMpResultNotify.TargetUid = targetUid
playerApplyEnterMpResultNotify.TargetNickname = ""
playerApplyEnterMpResultNotify.IsAgreed = false
playerApplyEnterMpResultNotify.Reason = proto.PlayerApplyEnterMpResultNotify_REASON_PLAYER_CANNOT_ENTER_MP
playerApplyEnterMpResultNotify := &proto.PlayerApplyEnterMpResultNotify{
TargetUid: targetUid,
TargetNickname: "",
IsAgreed: false,
Reason: proto.PlayerApplyEnterMpResultNotify_REASON_PLAYER_CANNOT_ENTER_MP,
}
g.SendMsg(cmd.PlayerApplyEnterMpResultNotify, player.PlayerID, player.ClientSeq, playerApplyEnterMpResultNotify)
}
}
@@ -41,10 +41,10 @@ func (g *GameManager) PlayerApplyEnterMpResultReq(player *model.Player, payloadM
applyUid := req.ApplyUid
isAgreed := req.IsAgreed
// PacketPlayerApplyEnterMpResultRsp
playerApplyEnterMpResultRsp := new(proto.PlayerApplyEnterMpResultRsp)
playerApplyEnterMpResultRsp.ApplyUid = applyUid
playerApplyEnterMpResultRsp.IsAgreed = isAgreed
playerApplyEnterMpResultRsp := &proto.PlayerApplyEnterMpResultRsp{
ApplyUid: applyUid,
IsAgreed: isAgreed,
}
g.SendMsg(cmd.PlayerApplyEnterMpResultRsp, player.PlayerID, player.ClientSeq, playerApplyEnterMpResultRsp)
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)
result := true
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
for _, worldPlayer := range world.playerMap {
if worldPlayer.SceneLoadState != model.SceneEnterDone {
result = false
}
}
// PacketPlayerGetForceQuitBanInfoRsp
playerGetForceQuitBanInfoRsp := new(proto.PlayerGetForceQuitBanInfoRsp)
if result {
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)
// PacketBackMyWorldRsp
backMyWorldRsp := new(proto.BackMyWorldRsp)
if ok {
backMyWorldRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SUCC)
@@ -93,7 +91,6 @@ func (g *GameManager) ChangeWorldToSingleModeReq(player *model.Player, payloadMs
// 房主
ok := g.UserLeaveWorld(player)
// PacketChangeWorldToSingleModeRsp
changeWorldToSingleModeRsp := new(proto.ChangeWorldToSingleModeRsp)
if ok {
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)
targetUid := req.TargetUid
targetPlayer := g.userManager.GetOnlineUser(targetUid)
targetPlayer := USER_MANAGER.GetOnlineUser(targetUid)
ok := g.UserLeaveWorld(targetPlayer)
if ok {
// PacketSceneKickPlayerNotify
sceneKickPlayerNotify := new(proto.SceneKickPlayerNotify)
sceneKickPlayerNotify.TargetUid = targetUid
sceneKickPlayerNotify.KickerUid = player.PlayerID
world := g.worldManager.GetWorldByID(player.WorldId)
sceneKickPlayerNotify := &proto.SceneKickPlayerNotify{
TargetUid: targetUid,
KickerUid: player.PlayerID,
}
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
for _, worldPlayer := range world.playerMap {
g.SendMsg(cmd.SceneKickPlayerNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, sceneKickPlayerNotify)
}
}
// PacketSceneKickPlayerRsp
sceneKickPlayerRsp := new(proto.SceneKickPlayerRsp)
if ok {
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)
req := payloadMsg.(*proto.JoinPlayerSceneReq)
hostPlayer := g.userManager.GetOnlineUser(req.TargetUid)
hostWorld := g.worldManager.GetWorldByID(hostPlayer.WorldId)
hostPlayer := USER_MANAGER.GetOnlineUser(req.TargetUid)
hostWorld := WORLD_MANAGER.GetWorldByID(hostPlayer.WorldId)
_, exist := hostWorld.waitEnterPlayerMap[player.PlayerID]
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)
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.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)
@@ -171,16 +167,16 @@ func (g *GameManager) JoinPlayerSceneReq(player *model.Player, payloadMsg pb.Mes
g.UserWorldAddPlayer(hostWorld, player)
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 {
targetPlayer := g.userManager.GetOnlineUser(targetUid)
targetPlayer := USER_MANAGER.GetOnlineUser(targetUid)
if targetPlayer == nil {
return false
}
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world.multiplayer {
return false
}
@@ -189,12 +185,11 @@ func (g *GameManager) UserApplyEnterWorld(player *model.Player, targetUid uint32
return false
}
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 {
return false
}
// PacketPlayerApplyEnterMpNotify
playerApplyEnterMpNotify := new(proto.PlayerApplyEnterMpNotify)
playerApplyEnterMpNotify.SrcPlayerInfo = g.PacketOnlinePlayerInfo(player)
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) {
otherPlayer := g.userManager.GetOnlineUser(otherUid)
otherPlayer := USER_MANAGER.GetOnlineUser(otherUid)
if otherPlayer == nil {
return
}
@@ -211,30 +206,30 @@ func (g *GameManager) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint
return
}
delete(hostPlayer.CoopApplyMap, otherUid)
otherPlayerWorld := g.worldManager.GetWorldByID(otherPlayer.WorldId)
otherPlayerWorld := WORLD_MANAGER.GetWorldByID(otherPlayer.WorldId)
if otherPlayerWorld.multiplayer {
// PacketPlayerApplyEnterMpResultNotify
playerApplyEnterMpResultNotify := new(proto.PlayerApplyEnterMpResultNotify)
playerApplyEnterMpResultNotify.TargetUid = hostPlayer.PlayerID
playerApplyEnterMpResultNotify.TargetNickname = hostPlayer.NickName
playerApplyEnterMpResultNotify.IsAgreed = false
playerApplyEnterMpResultNotify.Reason = proto.PlayerApplyEnterMpResultNotify_REASON_PLAYER_CANNOT_ENTER_MP
playerApplyEnterMpResultNotify := &proto.PlayerApplyEnterMpResultNotify{
TargetUid: hostPlayer.PlayerID,
TargetNickname: hostPlayer.NickName,
IsAgreed: false,
Reason: proto.PlayerApplyEnterMpResultNotify_REASON_PLAYER_CANNOT_ENTER_MP,
}
g.SendMsg(cmd.PlayerApplyEnterMpResultNotify, otherPlayer.PlayerID, otherPlayer.ClientSeq, playerApplyEnterMpResultNotify)
return
}
// PacketPlayerApplyEnterMpResultNotify
playerApplyEnterMpResultNotify := new(proto.PlayerApplyEnterMpResultNotify)
playerApplyEnterMpResultNotify.TargetUid = hostPlayer.PlayerID
playerApplyEnterMpResultNotify.TargetNickname = hostPlayer.NickName
playerApplyEnterMpResultNotify.IsAgreed = agree
playerApplyEnterMpResultNotify.Reason = proto.PlayerApplyEnterMpResultNotify_REASON_PLAYER_JUDGE
playerApplyEnterMpResultNotify := &proto.PlayerApplyEnterMpResultNotify{
TargetUid: hostPlayer.PlayerID,
TargetNickname: hostPlayer.NickName,
IsAgreed: agree,
Reason: proto.PlayerApplyEnterMpResultNotify_REASON_PLAYER_JUDGE,
}
g.SendMsg(cmd.PlayerApplyEnterMpResultNotify, otherPlayer.PlayerID, otherPlayer.ClientSeq, playerApplyEnterMpResultNotify)
if !agree {
return
}
world := g.worldManager.GetWorldByID(hostPlayer.WorldId)
world := WORLD_MANAGER.GetWorldByID(hostPlayer.WorldId)
world.waitEnterPlayerMap[otherPlayer.PlayerID] = time.Now().UnixMilli()
if world.multiplayer {
return
@@ -242,9 +237,9 @@ func (g *GameManager) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint
world.ChangeToMP()
// PacketWorldDataNotify
worldDataNotify := new(proto.WorldDataNotify)
worldDataNotify.WorldPropMap = make(map[uint32]*proto.PropValue)
worldDataNotify := &proto.WorldDataNotify{
WorldPropMap: make(map[uint32]*proto.PropValue),
}
// 是否多人游戏
worldDataNotify.WorldPropMap[2] = &proto.PropValue{
Type: 2,
@@ -255,7 +250,6 @@ func (g *GameManager) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint
hostPlayer.SceneLoadState = model.SceneNone
// PacketPlayerEnterSceneNotify
hostPlayerEnterSceneNotify := g.PacketPlayerEnterSceneNotifyMp(
hostPlayer,
hostPlayer,
@@ -266,10 +260,10 @@ func (g *GameManager) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint
)
g.SendMsg(cmd.PlayerEnterSceneNotify, hostPlayer.PlayerID, hostPlayer.ClientSeq, hostPlayerEnterSceneNotify)
// PacketGuestBeginEnterSceneNotify
guestBeginEnterSceneNotify := new(proto.GuestBeginEnterSceneNotify)
guestBeginEnterSceneNotify.SceneId = hostPlayer.SceneId
guestBeginEnterSceneNotify.Uid = otherPlayer.PlayerID
guestBeginEnterSceneNotify := &proto.GuestBeginEnterSceneNotify{
SceneId: hostPlayer.SceneId,
Uid: otherPlayer.PlayerID,
}
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 {
oldWorld := g.worldManager.GetWorldByID(player.WorldId)
oldWorld := WORLD_MANAGER.GetWorldByID(player.WorldId)
if !oldWorld.multiplayer {
return false
}
@@ -290,8 +284,7 @@ func (g *GameManager) UserLeaveWorld(player *model.Player) bool {
}
}
g.UserWorldRemovePlayer(oldWorld, player)
// PacketClientReconnectNotify
g.SendMsg(cmd.ClientReconnectNotify, player.PlayerID, 0, new(proto.ClientReconnectNotify))
g.ReconnectPlayer(player.PlayerID)
return true
}
@@ -327,14 +320,13 @@ func (g *GameManager) UserWorldRemovePlayer(world *World, player *model.Player)
activeAvatarId := player.TeamConfig.GetActiveAvatarId()
g.RemoveSceneEntityNotifyToPlayer(player, proto.VisionType_VISION_TYPE_MISS, []uint32{playerTeamEntity.avatarEntityMap[activeAvatarId]})
// PacketDelTeamEntityNotify
delTeamEntityNotify := g.PacketDelTeamEntityNotify(scene, player)
g.SendMsg(cmd.DelTeamEntityNotify, player.PlayerID, player.ClientSeq, delTeamEntityNotify)
if world.multiplayer {
// PlayerQuitFromMpNotify
playerQuitFromMpNotify := new(proto.PlayerQuitFromMpNotify)
playerQuitFromMpNotify.Reason = proto.PlayerQuitFromMpNotify_QUIT_REASON_BACK_TO_MY_WORLD
playerQuitFromMpNotify := &proto.PlayerQuitFromMpNotify{
Reason: proto.PlayerQuitFromMpNotify_QUIT_REASON_BACK_TO_MY_WORLD,
}
g.SendMsg(cmd.PlayerQuitFromMpNotify, player.PlayerID, player.ClientSeq, playerQuitFromMpNotify)
activeAvatarId := player.TeamConfig.GetActiveAvatarId()
@@ -351,7 +343,7 @@ func (g *GameManager) UserWorldRemovePlayer(world *World, player *model.Player)
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 {
continue
}
scene := hostWorld.GetSceneById(worldPlayer.SceneId)
// PacketPlayerPreEnterMpNotify
playerPreEnterMpNotify := new(proto.PlayerPreEnterMpNotify)
playerPreEnterMpNotify.State = proto.PlayerPreEnterMpNotify_STATE_START
playerPreEnterMpNotify.Uid = excludePlayer.PlayerID
playerPreEnterMpNotify.Nickname = excludePlayer.NickName
playerPreEnterMpNotify := &proto.PlayerPreEnterMpNotify{
State: proto.PlayerPreEnterMpNotify_STATE_START,
Uid: excludePlayer.PlayerID,
Nickname: excludePlayer.NickName,
}
g.SendMsg(cmd.PlayerPreEnterMpNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, playerPreEnterMpNotify)
// PacketWorldPlayerInfoNotify
worldPlayerInfoNotify := new(proto.WorldPlayerInfoNotify)
worldPlayerInfoNotify := &proto.WorldPlayerInfoNotify{
PlayerInfoList: make([]*proto.OnlinePlayerInfo, 0),
PlayerUidList: make([]uint32, 0),
}
for _, subWorldPlayer := range hostWorld.playerMap {
onlinePlayerInfo := new(proto.OnlinePlayerInfo)
onlinePlayerInfo.Uid = subWorldPlayer.PlayerID
onlinePlayerInfo.Nickname = subWorldPlayer.NickName
onlinePlayerInfo.PlayerLevel = subWorldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL]
onlinePlayerInfo.MpSettingType = proto.MpSettingType(subWorldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE])
onlinePlayerInfo.NameCardId = subWorldPlayer.NameCard
onlinePlayerInfo.Signature = subWorldPlayer.Signature
onlinePlayerInfo.ProfilePicture = &proto.ProfilePicture{AvatarId: subWorldPlayer.HeadImage}
onlinePlayerInfo.CurPlayerNumInWorld = uint32(len(hostWorld.playerMap))
onlinePlayerInfo := &proto.OnlinePlayerInfo{
Uid: subWorldPlayer.PlayerID,
Nickname: subWorldPlayer.NickName,
PlayerLevel: subWorldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
MpSettingType: proto.MpSettingType(subWorldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]),
NameCardId: subWorldPlayer.NameCard,
Signature: subWorldPlayer.Signature,
ProfilePicture: &proto.ProfilePicture{AvatarId: subWorldPlayer.HeadImage},
CurPlayerNumInWorld: uint32(len(hostWorld.playerMap)),
}
worldPlayerInfoNotify.PlayerInfoList = append(worldPlayerInfoNotify.PlayerInfoList, onlinePlayerInfo)
worldPlayerInfoNotify.PlayerUidList = append(worldPlayerInfoNotify.PlayerUidList, subWorldPlayer.PlayerID)
}
g.SendMsg(cmd.WorldPlayerInfoNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, worldPlayerInfoNotify)
// PacketSceneTimeNotify
sceneTimeNotify := new(proto.SceneTimeNotify)
sceneTimeNotify.SceneId = worldPlayer.SceneId
sceneTimeNotify.SceneTime = uint64(scene.GetSceneTime())
g.SendMsg(cmd.SceneTimeNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, sceneTimeNotify)
serverTimeNotify := &proto.ServerTimeNotify{
ServerTime: uint64(time.Now().UnixMilli()),
}
g.SendMsg(cmd.ServerTimeNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, serverTimeNotify)
// PacketScenePlayerInfoNotify
scenePlayerInfoNotify := new(proto.ScenePlayerInfoNotify)
for _, subWorldPlayer := range hostWorld.playerMap {
onlinePlayerInfo := new(proto.OnlinePlayerInfo)
onlinePlayerInfo.Uid = subWorldPlayer.PlayerID
onlinePlayerInfo.Nickname = subWorldPlayer.NickName
onlinePlayerInfo.PlayerLevel = subWorldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL]
onlinePlayerInfo.MpSettingType = proto.MpSettingType(subWorldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE])
onlinePlayerInfo.NameCardId = subWorldPlayer.NameCard
onlinePlayerInfo.Signature = subWorldPlayer.Signature
onlinePlayerInfo.ProfilePicture = &proto.ProfilePicture{AvatarId: subWorldPlayer.HeadImage}
onlinePlayerInfo.CurPlayerNumInWorld = uint32(len(hostWorld.playerMap))
scenePlayerInfoNotify := &proto.ScenePlayerInfoNotify{
PlayerInfoList: make([]*proto.ScenePlayerInfo, 0),
}
for _, worldPlayer := range hostWorld.playerMap {
onlinePlayerInfo := &proto.OnlinePlayerInfo{
Uid: worldPlayer.PlayerID,
Nickname: worldPlayer.NickName,
PlayerLevel: worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
MpSettingType: proto.MpSettingType(worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]),
NameCardId: worldPlayer.NameCard,
Signature: worldPlayer.Signature,
ProfilePicture: &proto.ProfilePicture{AvatarId: worldPlayer.HeadImage},
CurPlayerNumInWorld: uint32(len(hostWorld.playerMap)),
}
scenePlayerInfoNotify.PlayerInfoList = append(scenePlayerInfoNotify.PlayerInfoList, &proto.ScenePlayerInfo{
Uid: subWorldPlayer.PlayerID,
PeerId: subWorldPlayer.PeerId,
Name: subWorldPlayer.NickName,
SceneId: subWorldPlayer.SceneId,
Uid: worldPlayer.PlayerID,
PeerId: worldPlayer.PeerId,
Name: worldPlayer.NickName,
SceneId: worldPlayer.SceneId,
OnlinePlayerInfo: onlinePlayerInfo,
})
}
g.SendMsg(cmd.ScenePlayerInfoNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, scenePlayerInfoNotify)
// PacketSceneTeamUpdateNotify
sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(hostWorld)
g.SendMsg(cmd.SceneTeamUpdateNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, sceneTeamUpdateNotify)
// PacketSyncTeamEntityNotify
syncTeamEntityNotify := new(proto.SyncTeamEntityNotify)
syncTeamEntityNotify.SceneId = worldPlayer.SceneId
syncTeamEntityNotify.TeamEntityInfoList = make([]*proto.TeamEntityInfo, 0)
syncTeamEntityNotify := &proto.SyncTeamEntityNotify{
SceneId: worldPlayer.SceneId,
TeamEntityInfoList: make([]*proto.TeamEntityInfo, 0),
}
if hostWorld.multiplayer {
for _, subWorldPlayer := range hostWorld.playerMap {
if subWorldPlayer.PlayerID == worldPlayer.PlayerID {
for _, worldPlayer := range hostWorld.playerMap {
if worldPlayer.PlayerID == worldPlayer.PlayerID {
continue
}
subWorldPlayerScene := hostWorld.GetSceneById(subWorldPlayer.SceneId)
subWorldPlayerTeamEntity := subWorldPlayerScene.GetPlayerTeamEntity(subWorldPlayer.PlayerID)
worldPlayerScene := hostWorld.GetSceneById(worldPlayer.SceneId)
worldPlayerTeamEntity := worldPlayerScene.GetPlayerTeamEntity(worldPlayer.PlayerID)
teamEntityInfo := &proto.TeamEntityInfo{
TeamEntityId: subWorldPlayerTeamEntity.teamEntityId,
AuthorityPeerId: subWorldPlayer.PeerId,
TeamEntityId: worldPlayerTeamEntity.teamEntityId,
AuthorityPeerId: worldPlayer.PeerId,
TeamAbilityInfo: new(proto.AbilitySyncStateInfo),
}
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)
// PacketSyncScenePlayTeamEntityNotify
syncScenePlayTeamEntityNotify := new(proto.SyncScenePlayTeamEntityNotify)
syncScenePlayTeamEntityNotify.SceneId = worldPlayer.SceneId
syncScenePlayTeamEntityNotify := &proto.SyncScenePlayTeamEntityNotify{
SceneId: worldPlayer.SceneId,
}
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) {
logger.LOG.Debug("user enter scene ready, uid: %v", player.PlayerID)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
world := g.worldManager.GetWorldByID(player.WorldId)
// PacketEnterScenePeerNotify
enterScenePeerNotify := new(proto.EnterScenePeerNotify)
enterScenePeerNotify.DestSceneId = player.SceneId
enterScenePeerNotify.PeerId = player.PeerId
enterScenePeerNotify.HostPeerId = world.owner.PeerId
enterScenePeerNotify.EnterSceneToken = player.EnterSceneToken
enterScenePeerNotify := &proto.EnterScenePeerNotify{
DestSceneId: player.SceneId,
PeerId: player.PeerId,
HostPeerId: world.owner.PeerId,
EnterSceneToken: player.EnterSceneToken,
}
g.SendMsg(cmd.EnterScenePeerNotify, player.PlayerID, player.ClientSeq, enterScenePeerNotify)
// PacketEnterSceneReadyRsp
enterSceneReadyRsp := new(proto.EnterSceneReadyRsp)
enterSceneReadyRsp.EnterSceneToken = player.EnterSceneToken
enterSceneReadyRsp := &proto.EnterSceneReadyRsp{
EnterSceneToken: player.EnterSceneToken,
}
g.SendMsg(cmd.EnterSceneReadyRsp, player.PlayerID, player.ClientSeq, enterSceneReadyRsp)
}
func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user scene init finish, uid: %v", player.PlayerID)
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId)
// PacketServerTimeNotify
serverTimeNotify := new(proto.ServerTimeNotify)
serverTimeNotify.ServerTime = uint64(time.Now().UnixMilli())
serverTimeNotify := &proto.ServerTimeNotify{
ServerTime: uint64(time.Now().UnixMilli()),
}
g.SendMsg(cmd.ServerTimeNotify, player.PlayerID, player.ClientSeq, serverTimeNotify)
if world.IsPlayerFirstEnter(player) {
// PacketWorldPlayerInfoNotify
worldPlayerInfoNotify := new(proto.WorldPlayerInfoNotify)
worldPlayerInfoNotify := &proto.WorldPlayerInfoNotify{
PlayerInfoList: make([]*proto.OnlinePlayerInfo, 0),
PlayerUidList: make([]uint32, 0),
}
for _, worldPlayer := range world.playerMap {
onlinePlayerInfo := new(proto.OnlinePlayerInfo)
onlinePlayerInfo.Uid = worldPlayer.PlayerID
onlinePlayerInfo.Nickname = worldPlayer.NickName
onlinePlayerInfo.PlayerLevel = worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL]
onlinePlayerInfo.MpSettingType = proto.MpSettingType(worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE])
onlinePlayerInfo.NameCardId = worldPlayer.NameCard
onlinePlayerInfo.Signature = worldPlayer.Signature
onlinePlayerInfo.ProfilePicture = &proto.ProfilePicture{AvatarId: worldPlayer.HeadImage}
onlinePlayerInfo.CurPlayerNumInWorld = uint32(len(world.playerMap))
onlinePlayerInfo := &proto.OnlinePlayerInfo{
Uid: worldPlayer.PlayerID,
Nickname: worldPlayer.NickName,
PlayerLevel: worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
MpSettingType: proto.MpSettingType(worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]),
NameCardId: worldPlayer.NameCard,
Signature: worldPlayer.Signature,
ProfilePicture: &proto.ProfilePicture{AvatarId: worldPlayer.HeadImage},
CurPlayerNumInWorld: uint32(len(world.playerMap)),
}
worldPlayerInfoNotify.PlayerInfoList = append(worldPlayerInfoNotify.PlayerInfoList, onlinePlayerInfo)
worldPlayerInfoNotify.PlayerUidList = append(worldPlayerInfoNotify.PlayerUidList, worldPlayer.PlayerID)
}
g.SendMsg(cmd.WorldPlayerInfoNotify, player.PlayerID, player.ClientSeq, worldPlayerInfoNotify)
// PacketWorldDataNotify
worldDataNotify := new(proto.WorldDataNotify)
worldDataNotify.WorldPropMap = make(map[uint32]*proto.PropValue)
worldDataNotify := &proto.WorldDataNotify{
WorldPropMap: make(map[uint32]*proto.PropValue),
}
// 世界等级
worldDataNotify.WorldPropMap[1] = &proto.PropValue{
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)
// PacketPlayerWorldSceneInfoListNotify
playerWorldSceneInfoListNotify := new(proto.PlayerWorldSceneInfoListNotify)
playerWorldSceneInfoListNotify.InfoList = []*proto.PlayerWorldSceneInfo{
{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: 4, IsLocked: true, SceneTagIdList: []uint32{}},
{SceneId: 5, IsLocked: false, SceneTagIdList: []uint32{121, 1031}},
{SceneId: 6, IsLocked: false, SceneTagIdList: []uint32{144, 146, 1062, 1063}},
{SceneId: 7, IsLocked: true, SceneTagIdList: []uint32{136, 137, 138, 148, 1034}},
{SceneId: 9, IsLocked: true, SceneTagIdList: []uint32{1012, 1016, 1021, 1022, 1060, 1077}},
playerWorldSceneInfoListNotify := &proto.PlayerWorldSceneInfoListNotify{
InfoList: []*proto.PlayerWorldSceneInfo{
{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: 4, IsLocked: true, SceneTagIdList: []uint32{}},
{SceneId: 5, IsLocked: false, SceneTagIdList: []uint32{121, 1031}},
{SceneId: 6, IsLocked: false, SceneTagIdList: []uint32{144, 146, 1062, 1063}},
{SceneId: 7, IsLocked: true, SceneTagIdList: []uint32{136, 137, 138, 148, 1034}},
{SceneId: 9, IsLocked: true, SceneTagIdList: []uint32{1012, 1016, 1021, 1022, 1060, 1077}},
},
}
g.SendMsg(cmd.PlayerWorldSceneInfoListNotify, player.PlayerID, player.ClientSeq, playerWorldSceneInfoListNotify)
// SceneForceUnlockNotify
g.SendMsg(cmd.SceneForceUnlockNotify, player.PlayerID, player.ClientSeq, new(proto.SceneForceUnlockNotify))
// PacketHostPlayerNotify
hostPlayerNotify := new(proto.HostPlayerNotify)
hostPlayerNotify.HostUid = world.owner.PlayerID
hostPlayerNotify.HostPeerId = world.owner.PeerId
hostPlayerNotify := &proto.HostPlayerNotify{
HostUid: world.owner.PlayerID,
HostPeerId: world.owner.PeerId,
}
g.SendMsg(cmd.HostPlayerNotify, player.PlayerID, player.ClientSeq, hostPlayerNotify)
// PacketSceneTimeNotify
sceneTimeNotify := new(proto.SceneTimeNotify)
sceneTimeNotify.SceneId = player.SceneId
sceneTimeNotify.SceneTime = uint64(scene.GetSceneTime())
sceneTimeNotify := &proto.SceneTimeNotify{
SceneId: player.SceneId,
SceneTime: uint64(scene.GetSceneTime()),
}
g.SendMsg(cmd.SceneTimeNotify, player.PlayerID, player.ClientSeq, sceneTimeNotify)
// PacketPlayerGameTimeNotify
playerGameTimeNotify := new(proto.PlayerGameTimeNotify)
playerGameTimeNotify.GameTime = scene.gameTime
playerGameTimeNotify.Uid = player.PlayerID
playerGameTimeNotify := &proto.PlayerGameTimeNotify{
GameTime: scene.gameTime,
Uid: player.PlayerID,
}
g.SendMsg(cmd.PlayerGameTimeNotify, player.PlayerID, player.ClientSeq, playerGameTimeNotify)
// PacketPlayerEnterSceneInfoNotify
empty := new(proto.AbilitySyncStateInfo)
playerEnterSceneInfoNotify := new(proto.PlayerEnterSceneInfoNotify)
activeAvatarId := player.TeamConfig.GetActiveAvatarId()
playerTeamEntity := scene.GetPlayerTeamEntity(player.PlayerID)
playerEnterSceneInfoNotify.CurAvatarEntityId = playerTeamEntity.avatarEntityMap[activeAvatarId]
playerEnterSceneInfoNotify.EnterSceneToken = player.EnterSceneToken
playerEnterSceneInfoNotify.TeamEnterInfo = &proto.TeamEnterSceneInfo{
TeamEntityId: playerTeamEntity.teamEntityId,
TeamAbilityInfo: empty,
AbilityControlBlock: new(proto.AbilityControlBlock),
}
playerEnterSceneInfoNotify.MpLevelEntityInfo = &proto.MPLevelEntityInfo{
EntityId: g.worldManager.GetWorldByID(player.WorldId).mpLevelEntityId,
AuthorityPeerId: 1,
AbilityInfo: empty,
playerEnterSceneInfoNotify := &proto.PlayerEnterSceneInfoNotify{
CurAvatarEntityId: playerTeamEntity.avatarEntityMap[activeAvatarId],
EnterSceneToken: player.EnterSceneToken,
TeamEnterInfo: &proto.TeamEnterSceneInfo{
TeamEntityId: playerTeamEntity.teamEntityId,
TeamAbilityInfo: empty,
AbilityControlBlock: new(proto.AbilityControlBlock),
},
MpLevelEntityInfo: &proto.MPLevelEntityInfo{
EntityId: WORLD_MANAGER.GetWorldByID(player.WorldId).mpLevelEntityId,
AuthorityPeerId: 1,
AbilityInfo: empty,
},
AvatarEnterInfo: make([]*proto.AvatarEnterSceneInfo, 0),
}
activeTeam := player.TeamConfig.GetActiveTeam()
for _, avatarId := range activeTeam.AvatarIdList {
@@ -138,36 +139,39 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
break
}
avatar := player.AvatarMap[avatarId]
avatarEnterSceneInfo := new(proto.AvatarEnterSceneInfo)
avatarEnterSceneInfo.AvatarGuid = avatar.Guid
avatarEnterSceneInfo.AvatarEntityId = playerTeamEntity.avatarEntityMap[avatarId]
avatarEnterSceneInfo.WeaponGuid = avatar.EquipWeapon.Guid
avatarEnterSceneInfo.WeaponEntityId = playerTeamEntity.weaponEntityMap[avatar.EquipWeapon.WeaponId]
avatarEnterSceneInfo.AvatarAbilityInfo = empty
avatarEnterSceneInfo.WeaponAbilityInfo = empty
avatarEnterSceneInfo := &proto.AvatarEnterSceneInfo{
AvatarGuid: avatar.Guid,
AvatarEntityId: playerTeamEntity.avatarEntityMap[avatarId],
WeaponGuid: avatar.EquipWeapon.Guid,
WeaponEntityId: playerTeamEntity.weaponEntityMap[avatar.EquipWeapon.WeaponId],
AvatarAbilityInfo: empty,
WeaponAbilityInfo: empty,
}
playerEnterSceneInfoNotify.AvatarEnterInfo = append(playerEnterSceneInfoNotify.AvatarEnterInfo, avatarEnterSceneInfo)
}
g.SendMsg(cmd.PlayerEnterSceneInfoNotify, player.PlayerID, player.ClientSeq, playerEnterSceneInfoNotify)
// PacketSceneAreaWeatherNotify
sceneAreaWeatherNotify := new(proto.SceneAreaWeatherNotify)
sceneAreaWeatherNotify.WeatherAreaId = 0
sceneAreaWeatherNotify.ClimateType = uint32(constant.ClimateTypeConst.CLIMATE_SUNNY)
sceneAreaWeatherNotify := &proto.SceneAreaWeatherNotify{
WeatherAreaId: 0,
ClimateType: uint32(constant.ClimateTypeConst.CLIMATE_SUNNY),
}
g.SendMsg(cmd.SceneAreaWeatherNotify, player.PlayerID, player.ClientSeq, sceneAreaWeatherNotify)
}
// PacketScenePlayerInfoNotify
scenePlayerInfoNotify := new(proto.ScenePlayerInfoNotify)
scenePlayerInfoNotify := &proto.ScenePlayerInfoNotify{
PlayerInfoList: make([]*proto.ScenePlayerInfo, 0),
}
for _, worldPlayer := range world.playerMap {
onlinePlayerInfo := new(proto.OnlinePlayerInfo)
onlinePlayerInfo.Uid = worldPlayer.PlayerID
onlinePlayerInfo.Nickname = worldPlayer.NickName
onlinePlayerInfo.PlayerLevel = worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL]
onlinePlayerInfo.MpSettingType = proto.MpSettingType(worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE])
onlinePlayerInfo.NameCardId = worldPlayer.NameCard
onlinePlayerInfo.Signature = worldPlayer.Signature
onlinePlayerInfo.ProfilePicture = &proto.ProfilePicture{AvatarId: worldPlayer.HeadImage}
onlinePlayerInfo.CurPlayerNumInWorld = uint32(len(world.playerMap))
onlinePlayerInfo := &proto.OnlinePlayerInfo{
Uid: worldPlayer.PlayerID,
Nickname: worldPlayer.NickName,
PlayerLevel: worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_LEVEL],
MpSettingType: proto.MpSettingType(worldPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_MP_SETTING_TYPE]),
NameCardId: worldPlayer.NameCard,
Signature: worldPlayer.Signature,
ProfilePicture: &proto.ProfilePicture{AvatarId: worldPlayer.HeadImage},
CurPlayerNumInWorld: uint32(len(world.playerMap)),
}
scenePlayerInfoNotify.PlayerInfoList = append(scenePlayerInfoNotify.PlayerInfoList, &proto.ScenePlayerInfo{
Uid: worldPlayer.PlayerID,
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)
// PacketSceneTeamUpdateNotify
sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world)
g.SendMsg(cmd.SceneTeamUpdateNotify, player.PlayerID, player.ClientSeq, sceneTeamUpdateNotify)
// PacketSyncTeamEntityNotify
syncTeamEntityNotify := new(proto.SyncTeamEntityNotify)
syncTeamEntityNotify.SceneId = player.SceneId
syncTeamEntityNotify.TeamEntityInfoList = make([]*proto.TeamEntityInfo, 0)
syncTeamEntityNotify := &proto.SyncTeamEntityNotify{
SceneId: player.SceneId,
TeamEntityInfoList: make([]*proto.TeamEntityInfo, 0),
}
if world.multiplayer {
for _, worldPlayer := range world.playerMap {
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)
// PacketSyncScenePlayTeamEntityNotify
syncScenePlayTeamEntityNotify := new(proto.SyncScenePlayTeamEntityNotify)
syncScenePlayTeamEntityNotify.SceneId = player.SceneId
syncScenePlayTeamEntityNotify := &proto.SyncScenePlayTeamEntityNotify{
SceneId: player.SceneId,
}
g.SendMsg(cmd.SyncScenePlayTeamEntityNotify, player.PlayerID, player.ClientSeq, syncScenePlayTeamEntityNotify)
// PacketSceneInitFinishRsp
SceneInitFinishRsp := new(proto.SceneInitFinishRsp)
SceneInitFinishRsp.EnterSceneToken = player.EnterSceneToken
SceneInitFinishRsp := &proto.SceneInitFinishRsp{
EnterSceneToken: player.EnterSceneToken,
}
g.SendMsg(cmd.SceneInitFinishRsp, player.PlayerID, player.ClientSeq, SceneInitFinishRsp)
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) {
logger.LOG.Debug("user enter scene done, uid: %v", player.PlayerID)
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId)
if world.multiplayer && world.IsPlayerFirstEnter(player) {
guestPostEnterSceneNotify := new(proto.GuestPostEnterSceneNotify)
guestPostEnterSceneNotify.SceneId = player.SceneId
guestPostEnterSceneNotify.Uid = player.PlayerID
guestPostEnterSceneNotify := &proto.GuestPostEnterSceneNotify{
SceneId: player.SceneId,
Uid: player.PlayerID,
}
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)
// PacketSceneAreaWeatherNotify
sceneAreaWeatherNotify := new(proto.SceneAreaWeatherNotify)
sceneAreaWeatherNotify.WeatherAreaId = 0
sceneAreaWeatherNotify.ClimateType = uint32(constant.ClimateTypeConst.CLIMATE_SUNNY)
sceneAreaWeatherNotify := &proto.SceneAreaWeatherNotify{
WeatherAreaId: 0,
ClimateType: uint32(constant.ClimateTypeConst.CLIMATE_SUNNY),
}
g.SendMsg(cmd.SceneAreaWeatherNotify, player.PlayerID, player.ClientSeq, sceneAreaWeatherNotify)
// PacketEnterSceneDoneRsp
enterSceneDoneRsp := new(proto.EnterSceneDoneRsp)
enterSceneDoneRsp.EnterSceneToken = player.EnterSceneToken
enterSceneDoneRsp := &proto.EnterSceneDoneRsp{
EnterSceneToken: player.EnterSceneToken,
}
g.SendMsg(cmd.EnterSceneDoneRsp, player.PlayerID, player.ClientSeq, enterSceneDoneRsp)
player.SceneLoadState = model.SceneEnterDone
@@ -262,7 +265,7 @@ func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Mess
for otherPlayerId := range world.waitEnterPlayerMap {
delete(world.waitEnterPlayerMap, otherPlayerId)
otherPlayer := g.userManager.GetOnlineUser(otherPlayerId)
otherPlayer := USER_MANAGER.GetOnlineUser(otherPlayerId)
otherPlayer.Pos = &model.Vector{
X: player.Pos.X,
Y: player.Pos.Y,
@@ -278,16 +281,17 @@ func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Mess
g.UserWorldAddPlayer(world, otherPlayer)
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) {
logger.LOG.Debug("user post enter scene, uid: %v", player.PlayerID)
// PacketPostEnterSceneRsp
postEnterSceneRsp := new(proto.PostEnterSceneRsp)
postEnterSceneRsp.EnterSceneToken = player.EnterSceneToken
postEnterSceneRsp := &proto.PostEnterSceneRsp{
EnterSceneToken: player.EnterSceneToken,
}
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)
req := payloadMsg.(*proto.EnterWorldAreaReq)
// PacketEnterWorldAreaRsp
enterWorldAreaRsp := new(proto.EnterWorldAreaRsp)
enterWorldAreaRsp.AreaType = req.AreaType
enterWorldAreaRsp.AreaId = req.AreaId
enterWorldAreaRsp := &proto.EnterWorldAreaRsp{
AreaType: req.AreaType,
AreaId: req.AreaId,
}
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)
req := payloadMsg.(*proto.ChangeGameTimeReq)
gameTime := req.GameTime
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId)
scene.ChangeGameTime(gameTime)
for _, scenePlayer := range scene.playerMap {
// PacketPlayerGameTimeNotify
playerGameTimeNotify := new(proto.PlayerGameTimeNotify)
playerGameTimeNotify.GameTime = scene.gameTime
playerGameTimeNotify.Uid = scenePlayer.PlayerID
playerGameTimeNotify := &proto.PlayerGameTimeNotify{
GameTime: scene.gameTime,
Uid: scenePlayer.PlayerID,
}
g.SendMsg(cmd.PlayerGameTimeNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, playerGameTimeNotify)
}
// PacketChangeGameTimeRsp
changeGameTimeRsp := new(proto.ChangeGameTimeRsp)
changeGameTimeRsp.CurGameTime = scene.gameTime
changeGameTimeRsp := &proto.ChangeGameTimeRsp{
CurGameTime: scene.gameTime,
}
g.SendMsg(cmd.ChangeGameTimeRsp, player.PlayerID, player.ClientSeq, changeGameTimeRsp)
}
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)
player.EnterSceneToken = uint32(random.GetRandomInt32(5000, 50000))
playerEnterSceneNotify := new(proto.PlayerEnterSceneNotify)
playerEnterSceneNotify.SceneId = player.SceneId
playerEnterSceneNotify.Pos = &proto.Vector{X: float32(player.Pos.X), Y: float32(player.Pos.Y), Z: float32(player.Pos.Z)}
playerEnterSceneNotify.SceneBeginTime = uint64(scene.GetSceneCreateTime())
playerEnterSceneNotify.Type = enterType
playerEnterSceneNotify.TargetUid = player.PlayerID
playerEnterSceneNotify.EnterSceneToken = player.EnterSceneToken
playerEnterSceneNotify.WorldLevel = player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL]
playerEnterSceneNotify.EnterReason = uint32(constant.EnterReasonConst.Login)
playerEnterSceneNotify.IsFirstLoginEnterScene = true
playerEnterSceneNotify.WorldType = 1
playerEnterSceneNotify := &proto.PlayerEnterSceneNotify{
SceneId: player.SceneId,
Pos: &proto.Vector{X: float32(player.Pos.X), Y: float32(player.Pos.Y), Z: float32(player.Pos.Z)},
SceneBeginTime: uint64(scene.GetSceneCreateTime()),
Type: enterType,
TargetUid: player.PlayerID,
EnterSceneToken: player.EnterSceneToken,
WorldLevel: player.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL],
EnterReason: uint32(constant.EnterReasonConst.Login),
IsFirstLoginEnterScene: true,
WorldType: 1,
}
playerEnterSceneNotify.SceneTransaction = strconv.Itoa(int(player.SceneId)) + "-" +
strconv.Itoa(int(player.PlayerID)) + "-" +
strconv.Itoa(int(time.Now().Unix())) + "-" +
@@ -365,21 +370,22 @@ func (g *GameManager) PacketPlayerEnterSceneNotifyMp(
prevSceneId uint32,
prevPos *model.Vector,
) *proto.PlayerEnterSceneNotify {
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId)
player.EnterSceneToken = uint32(random.GetRandomInt32(5000, 50000))
playerEnterSceneNotify := new(proto.PlayerEnterSceneNotify)
playerEnterSceneNotify.PrevSceneId = prevSceneId
playerEnterSceneNotify.PrevPos = &proto.Vector{X: float32(prevPos.X), Y: float32(prevPos.Y), Z: float32(prevPos.Z)}
playerEnterSceneNotify.SceneId = player.SceneId
playerEnterSceneNotify.Pos = &proto.Vector{X: float32(player.Pos.X), Y: float32(player.Pos.Y), Z: float32(player.Pos.Z)}
playerEnterSceneNotify.SceneBeginTime = uint64(scene.GetSceneCreateTime())
playerEnterSceneNotify.Type = enterType
playerEnterSceneNotify.TargetUid = targetPlayer.PlayerID
playerEnterSceneNotify.EnterSceneToken = player.EnterSceneToken
playerEnterSceneNotify.WorldLevel = targetPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL]
playerEnterSceneNotify.EnterReason = enterReason
playerEnterSceneNotify.WorldType = 1
playerEnterSceneNotify := &proto.PlayerEnterSceneNotify{
PrevSceneId: prevSceneId,
PrevPos: &proto.Vector{X: float32(prevPos.X), Y: float32(prevPos.Y), Z: float32(prevPos.Z)},
SceneId: player.SceneId,
Pos: &proto.Vector{X: float32(player.Pos.X), Y: float32(player.Pos.Y), Z: float32(player.Pos.Z)},
SceneBeginTime: uint64(scene.GetSceneCreateTime()),
Type: enterType,
TargetUid: targetPlayer.PlayerID,
EnterSceneToken: player.EnterSceneToken,
WorldLevel: targetPlayer.PropertiesMap[constant.PlayerPropertyConst.PROP_PLAYER_WORLD_LEVEL],
EnterReason: enterReason,
WorldType: 1,
}
playerEnterSceneNotify.SceneTransaction = strconv.Itoa(int(player.SceneId)) + "-" +
strconv.Itoa(int(targetPlayer.PlayerID)) + "-" +
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) {
// PacketSceneEntityAppearNotify
sceneEntityAppearNotify := new(proto.SceneEntityAppearNotify)
sceneEntityAppearNotify.AppearType = visionType
sceneEntityAppearNotify.EntityList = entityList
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
AppearType: visionType,
EntityList: entityList,
}
g.SendMsg(cmd.SceneEntityAppearNotify, player.PlayerID, player.ClientSeq, sceneEntityAppearNotify)
logger.LOG.Debug("SceneEntityAppearNotify, uid: %v, type: %v, len: %v",
player.PlayerID, sceneEntityAppearNotify.AppearType, len(sceneEntityAppearNotify.EntityList))
}
func (g *GameManager) AddSceneEntityNotifyBroadcast(scene *Scene, visionType proto.VisionType, entityList []*proto.SceneEntityInfo) {
// PacketSceneEntityAppearNotify
sceneEntityAppearNotify := new(proto.SceneEntityAppearNotify)
sceneEntityAppearNotify.AppearType = visionType
sceneEntityAppearNotify.EntityList = entityList
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
AppearType: visionType,
EntityList: entityList,
}
for _, scenePlayer := range scene.playerMap {
g.SendMsg(cmd.SceneEntityAppearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityAppearNotify)
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) {
// PacketSceneEntityDisappearNotify
sceneEntityDisappearNotify := new(proto.SceneEntityDisappearNotify)
sceneEntityDisappearNotify.EntityList = entityIdList
sceneEntityDisappearNotify.DisappearType = visionType
sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{
EntityList: entityIdList,
DisappearType: visionType,
}
g.SendMsg(cmd.SceneEntityDisappearNotify, player.PlayerID, player.ClientSeq, sceneEntityDisappearNotify)
logger.LOG.Debug("SceneEntityDisappearNotify, uid: %v, type: %v, len: %v",
player.PlayerID, sceneEntityDisappearNotify.DisappearType, len(sceneEntityDisappearNotify.EntityList))
}
func (g *GameManager) RemoveSceneEntityNotifyBroadcast(scene *Scene, visionType proto.VisionType, entityIdList []uint32) {
// PacketSceneEntityDisappearNotify
sceneEntityDisappearNotify := new(proto.SceneEntityDisappearNotify)
sceneEntityDisappearNotify.EntityList = entityIdList
sceneEntityDisappearNotify.DisappearType = visionType
sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{
EntityList: entityIdList,
DisappearType: visionType,
}
for _, scenePlayer := range scene.playerMap {
g.SendMsg(cmd.SceneEntityDisappearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityDisappearNotify)
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) {
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId)
entityList := make([]*proto.SceneEntityInfo, 0)
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 {
continue
}
scenePlayer := g.userManager.GetOnlineUser(entity.avatarEntity.uid)
scenePlayer := USER_MANAGER.GetOnlineUser(entity.avatarEntity.uid)
if scenePlayer == nil {
logger.LOG.Error("get scene player is nil, world id: %v, scene id: %v", world.id, scene.id)
continue
}
//if scenePlayer.SceneLoadState != model.SceneEnterDone {
// continue
//}
if entity.avatarEntity.avatarId != scenePlayer.TeamConfig.GetActiveAvatarId() {
continue
}
@@ -736,9 +739,10 @@ func (g *GameManager) PacketSceneGadgetInfo(gatherId uint32) *proto.SceneGadgetI
}
func (g *GameManager) PacketDelTeamEntityNotify(scene *Scene, player *model.Player) *proto.DelTeamEntityNotify {
delTeamEntityNotify := new(proto.DelTeamEntityNotify)
delTeamEntityNotify.SceneId = player.SceneId
playerTeamEntity := scene.GetPlayerTeamEntity(player.PlayerID)
delTeamEntityNotify.DelEntityIdList = []uint32{playerTeamEntity.teamEntityId}
delTeamEntityNotify := &proto.DelTeamEntityNotify{
SceneId: player.SceneId,
DelEntityIdList: []uint32{playerTeamEntity.teamEntityId},
}
return delTeamEntityNotify
}

View File

@@ -15,9 +15,9 @@ import (
func (g *GameManager) GetShopmallDataReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user get shop mall, uid: %v", player.PlayerID)
// PacketGetShopmallDataRsp
getShopmallDataRsp := new(proto.GetShopmallDataRsp)
getShopmallDataRsp.ShopTypeList = []uint32{900, 1052, 902, 1001, 903}
getShopmallDataRsp := &proto.GetShopmallDataRsp{
ShopTypeList: []uint32{900, 1052, 902, 1001, 903},
}
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())
// PacketGetShopRsp
getShopRsp := new(proto.GetShopRsp)
getShopRsp.Shop = &proto.Shop{
GoodsList: []*proto.ShopGoods{
{
MinLevel: 1,
EndTime: 2051193600,
Hcoin: 160,
GoodsId: 102001,
NextRefreshTime: nextRefreshTime,
MaxLevel: 99,
BeginTime: 1575129600,
GoodsItem: &proto.ItemParam{
ItemId: 223,
Count: 1,
},
},
{
MinLevel: 1,
EndTime: 2051193600,
Hcoin: 160,
GoodsId: 102002,
NextRefreshTime: nextRefreshTime,
MaxLevel: 99,
BeginTime: 1575129600,
GoodsItem: &proto.ItemParam{
ItemId: 224,
Count: 1,
getShopRsp := &proto.GetShopRsp{
Shop: &proto.Shop{
GoodsList: []*proto.ShopGoods{
{
MinLevel: 1,
EndTime: 2051193600,
Hcoin: 160,
GoodsId: 102001,
NextRefreshTime: nextRefreshTime,
MaxLevel: 99,
BeginTime: 1575129600,
GoodsItem: &proto.ItemParam{
ItemId: 223,
Count: 1,
},
},
{
MinLevel: 1,
EndTime: 2051193600,
Hcoin: 160,
GoodsId: 102002,
NextRefreshTime: nextRefreshTime,
MaxLevel: 99,
BeginTime: 1575129600,
GoodsItem: &proto.ItemParam{
ItemId: 224,
Count: 1,
},
},
},
NextRefreshTime: nextRefreshTime,
ShopType: 1001,
},
NextRefreshTime: nextRefreshTime,
ShopType: 1001,
}
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)
req.Goods.BoughtNum = player.GetItemCount(buyItemId)
// PacketBuyGoodsRsp
buyGoodsRsp := new(proto.BuyGoodsRsp)
buyGoodsRsp.ShopType = req.ShopType
buyGoodsRsp.BuyCount = req.BuyCount
buyGoodsRsp.GoodsList = []*proto.ShopGoods{req.Goods}
buyGoodsRsp := &proto.BuyGoodsRsp{
ShopType: req.ShopType,
BuyCount: req.BuyCount,
GoodsList: []*proto.ShopGoods{req.Goods},
}
g.SendMsg(cmd.BuyGoodsRsp, player.PlayerID, player.ClientSeq, buyGoodsRsp)
}
@@ -123,9 +123,9 @@ func (g *GameManager) McoinExchangeHcoinReq(player *model.Player, payloadMsg pb.
ChangeCount: count,
}}, false, 0)
// PacketMcoinExchangeHcoinRsp
mcoinExchangeHcoinRsp := new(proto.McoinExchangeHcoinRsp)
mcoinExchangeHcoinRsp.Hcoin = req.Hcoin
mcoinExchangeHcoinRsp.McoinCost = req.McoinCost
mcoinExchangeHcoinRsp := &proto.McoinExchangeHcoinRsp{
Hcoin: req.Hcoin,
McoinCost: req.McoinCost,
}
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)
targetUid := req.Uid
// PacketGetPlayerSocialDetailRsp
getPlayerSocialDetailRsp := new(proto.GetPlayerSocialDetailRsp)
// TODO 同步阻塞待优化
targetPlayer := g.userManager.LoadTempOfflineUserSync(targetUid)
targetPlayer := USER_MANAGER.LoadTempOfflineUserSync(targetUid)
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]
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
} else {
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
// PacketSetNameCardRsp
setNameCardRsp := new(proto.SetNameCardRsp)
setNameCardRsp.NameCardId = nameCardId
setNameCardRsp := &proto.SetNameCardRsp{
NameCardId: nameCardId,
}
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)
signature := req.Signature
// PacketSetPlayerSignatureRsp
setPlayerSignatureRsp := new(proto.SetPlayerSignatureRsp)
if !object.IsUtf8String(signature) {
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)
nickName := req.NickName
// PacketSetPlayerNameRsp
setPlayerNameRsp := new(proto.SetPlayerNameRsp)
if len(nickName) == 0 {
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
// PacketSetPlayerHeadImageRsp
setPlayerHeadImageRsp := new(proto.SetPlayerHeadImageRsp)
setPlayerHeadImageRsp.ProfilePicture = &proto.ProfilePicture{AvatarId: player.HeadImage}
setPlayerHeadImageRsp := &proto.SetPlayerHeadImageRsp{
ProfilePicture: &proto.ProfilePicture{AvatarId: player.HeadImage},
}
g.SendMsg(cmd.SetPlayerHeadImageRsp, player.PlayerID, player.ClientSeq, setPlayerHeadImageRsp)
}
func (g *GameManager) GetAllUnlockNameCardReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user get all unlock name card, uid: %v", player.PlayerID)
// PacketGetAllUnlockNameCardRsp
getAllUnlockNameCardRsp := new(proto.GetAllUnlockNameCardRsp)
getAllUnlockNameCardRsp.NameCardList = player.NameCardList
getAllUnlockNameCardRsp := &proto.GetAllUnlockNameCardRsp{
NameCardList: player.NameCardList,
}
g.SendMsg(cmd.GetAllUnlockNameCardRsp, player.PlayerID, player.ClientSeq, getAllUnlockNameCardRsp)
}
func (g *GameManager) GetPlayerFriendListReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user get friend list, uid: %v", player.PlayerID)
// PacketGetPlayerFriendListRsp
getPlayerFriendListRsp := new(proto.GetPlayerFriendListRsp)
getPlayerFriendListRsp.FriendList = make([]*proto.FriendBrief, 0)
getPlayerFriendListRsp := &proto.GetPlayerFriendListRsp{
FriendList: make([]*proto.FriendBrief, 0),
}
// 获取包含系统的临时好友列表
// 用于实现好友列表内的系统且不更改原先的内容
tempFriendList := COMMAND_MANAGER.GetFriendList(player.FriendList)
for uid := range tempFriendList {
// TODO 同步阻塞待优化
var onlineState proto.FriendOnlineState
online := g.userManager.GetUserOnlineState(uid)
online := USER_MANAGER.GetUserOnlineState(uid)
if online {
onlineState = proto.FriendOnlineState_FRIEND_ONLINE_STATE_ONLINE
} else {
onlineState = proto.FriendOnlineState_FRIEND_ONLINE_STATE_FREIEND_DISCONNECT
}
friendPlayer := g.userManager.LoadTempOfflineUserSync(uid)
friendPlayer := USER_MANAGER.LoadTempOfflineUserSync(uid)
if friendPlayer == nil {
logger.LOG.Error("target player is nil, uid: %v", player.PlayerID)
continue
@@ -187,19 +183,19 @@ func (g *GameManager) GetPlayerFriendListReq(player *model.Player, payloadMsg pb
func (g *GameManager) GetPlayerAskFriendListReq(player *model.Player, payloadMsg pb.Message) {
logger.LOG.Debug("user get friend apply list, uid: %v", player.PlayerID)
// PacketGetPlayerAskFriendListRsp
getPlayerAskFriendListRsp := new(proto.GetPlayerAskFriendListRsp)
getPlayerAskFriendListRsp.AskFriendList = make([]*proto.FriendBrief, 0)
getPlayerAskFriendListRsp := &proto.GetPlayerAskFriendListRsp{
AskFriendList: make([]*proto.FriendBrief, 0),
}
for uid := range player.FriendApplyList {
// TODO 同步阻塞待优化
var onlineState proto.FriendOnlineState
online := g.userManager.GetUserOnlineState(uid)
online := USER_MANAGER.GetUserOnlineState(uid)
if online {
onlineState = proto.FriendOnlineState_FRIEND_ONLINE_STATE_ONLINE
} else {
onlineState = proto.FriendOnlineState_FRIEND_ONLINE_STATE_FREIEND_DISCONNECT
}
friendPlayer := g.userManager.LoadTempOfflineUserSync(uid)
friendPlayer := USER_MANAGER.LoadTempOfflineUserSync(uid)
if friendPlayer == nil {
logger.LOG.Error("target player is nil, uid: %v", player.PlayerID)
continue
@@ -230,8 +226,8 @@ func (g *GameManager) AskAddFriendReq(player *model.Player, payloadMsg pb.Messag
targetUid := req.TargetUid
// TODO 同步阻塞待优化
targetPlayerOnline := g.userManager.GetUserOnlineState(targetUid)
targetPlayer := g.userManager.LoadTempOfflineUserSync(targetUid)
targetPlayerOnline := USER_MANAGER.GetUserOnlineState(targetUid)
targetPlayer := USER_MANAGER.LoadTempOfflineUserSync(targetUid)
if targetPlayer == nil {
logger.LOG.Error("apply add friend target player is nil, uid: %v", player.PlayerID)
return
@@ -245,9 +241,9 @@ func (g *GameManager) AskAddFriendReq(player *model.Player, payloadMsg pb.Messag
targetPlayer.FriendApplyList[player.PlayerID] = true
if targetPlayerOnline {
// PacketAskAddFriendNotify
askAddFriendNotify := new(proto.AskAddFriendNotify)
askAddFriendNotify.TargetUid = player.PlayerID
askAddFriendNotify := &proto.AskAddFriendNotify{
TargetUid: player.PlayerID,
}
askAddFriendNotify.TargetFriendBrief = &proto.FriendBrief{
Uid: player.PlayerID,
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)
}
// PacketAskAddFriendRsp
askAddFriendRsp := new(proto.AskAddFriendRsp)
askAddFriendRsp.TargetUid = targetUid
askAddFriendRsp := &proto.AskAddFriendRsp{
TargetUid: targetUid,
}
g.SendMsg(cmd.AskAddFriendRsp, player.PlayerID, player.ClientSeq, askAddFriendRsp)
}
func (g *GameManager) AddFriend(player *model.Player, targetUid uint32) {
player.FriendList[targetUid] = true
// TODO 同步阻塞待优化
targetPlayer := g.userManager.LoadTempOfflineUserSync(targetUid)
targetPlayer := USER_MANAGER.LoadTempOfflineUserSync(targetUid)
if targetPlayer == nil {
logger.LOG.Error("agree friend apply target player is nil, uid: %v", player.PlayerID)
return
@@ -294,10 +290,10 @@ func (g *GameManager) DealAddFriendReq(player *model.Player, payloadMsg pb.Messa
}
delete(player.FriendApplyList, targetUid)
// PacketDealAddFriendRsp
dealAddFriendRsp := new(proto.DealAddFriendRsp)
dealAddFriendRsp.TargetUid = targetUid
dealAddFriendRsp.DealAddFriendResult = result
dealAddFriendRsp := &proto.DealAddFriendRsp{
TargetUid: targetUid,
DealAddFriendResult: result,
}
g.SendMsg(cmd.DealAddFriendRsp, player.PlayerID, player.ClientSeq, dealAddFriendRsp)
}
@@ -306,7 +302,7 @@ func (g *GameManager) GetOnlinePlayerListReq(player *model.Player, payloadMsg pb
count := 0
onlinePlayerList := make([]*model.Player, 0)
for _, onlinePlayer := range g.userManager.GetAllOnlineUserList() {
for _, onlinePlayer := range USER_MANAGER.GetAllOnlineUserList() {
if onlinePlayer.PlayerID == player.PlayerID {
continue
}
@@ -317,9 +313,9 @@ func (g *GameManager) GetOnlinePlayerListReq(player *model.Player, payloadMsg pb
}
}
// PacketGetOnlinePlayerListRsp
getOnlinePlayerListRsp := new(proto.GetOnlinePlayerListRsp)
getOnlinePlayerListRsp.PlayerInfoList = make([]*proto.OnlinePlayerInfo, 0)
getOnlinePlayerListRsp := &proto.GetOnlinePlayerListRsp{
PlayerInfoList: make([]*proto.OnlinePlayerInfo, 0),
}
for _, onlinePlayer := range onlinePlayerList {
onlinePlayerInfo := g.PacketOnlinePlayerInfo(onlinePlayer)
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},
CurPlayerNumInWorld: 1,
}
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world != nil && world.playerMap != nil {
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)
targetAvatarGuid := req.Guid
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
scene := world.GetSceneById(player.SceneId)
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)
// PacketSceneEntityDisappearNotify
sceneEntityDisappearNotify := new(proto.SceneEntityDisappearNotify)
sceneEntityDisappearNotify.DisappearType = proto.VisionType_VISION_TYPE_REPLACE
sceneEntityDisappearNotify.EntityList = []uint32{playerTeamEntity.avatarEntityMap[oldAvatarId]}
sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{
DisappearType: proto.VisionType_VISION_TYPE_REPLACE,
EntityList: []uint32{playerTeamEntity.avatarEntityMap[oldAvatarId]},
}
for _, scenePlayer := range scene.playerMap {
g.SendMsg(cmd.SceneEntityDisappearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityDisappearNotify)
}
// PacketSceneEntityAppearNotify
sceneEntityAppearNotify := new(proto.SceneEntityAppearNotify)
sceneEntityAppearNotify.AppearType = proto.VisionType_VISION_TYPE_REPLACE
sceneEntityAppearNotify.Param = playerTeamEntity.avatarEntityMap[oldAvatarId]
sceneEntityAppearNotify.EntityList = []*proto.SceneEntityInfo{g.PacketSceneEntityInfoAvatar(scene, player, player.TeamConfig.GetActiveAvatarId())}
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
AppearType: proto.VisionType_VISION_TYPE_REPLACE,
Param: playerTeamEntity.avatarEntityMap[oldAvatarId],
EntityList: []*proto.SceneEntityInfo{g.PacketSceneEntityInfoAvatar(scene, player, player.TeamConfig.GetActiveAvatarId())},
}
for _, scenePlayer := range scene.playerMap {
g.SendMsg(cmd.SceneEntityAppearNotify, scenePlayer.PlayerID, scenePlayer.ClientSeq, sceneEntityAppearNotify)
}
// PacketChangeAvatarRsp
changeAvatarRsp := new(proto.ChangeAvatarRsp)
changeAvatarRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SUCC)
changeAvatarRsp.CurGuid = targetAvatarGuid
changeAvatarRsp := &proto.ChangeAvatarRsp{
Retcode: int32(proto.Retcode_RETCODE_RET_SUCC),
CurGuid: targetAvatarGuid,
}
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
if teamId <= 0 || teamId >= 5 {
// PacketSetUpAvatarTeamRsp
setUpAvatarTeamRsp := new(proto.SetUpAvatarTeamRsp)
setUpAvatarTeamRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SVR_ERROR)
setUpAvatarTeamRsp := &proto.SetUpAvatarTeamRsp{
Retcode: int32(proto.Retcode_RETCODE_RET_SVR_ERROR),
}
g.SendMsg(cmd.SetUpAvatarTeamRsp, player.PlayerID, player.ClientSeq, setUpAvatarTeamRsp)
return
}
avatarGuidList := req.AvatarTeamGuidList
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
multiTeam := teamId == 4
selfTeam := teamId == uint32(player.TeamConfig.GetActiveTeamId())
if (multiTeam && len(avatarGuidList) == 0) || (selfTeam && len(avatarGuidList) == 0) || len(avatarGuidList) > 4 || world.multiplayer {
// PacketSetUpAvatarTeamRsp
setUpAvatarTeamRsp := new(proto.SetUpAvatarTeamRsp)
setUpAvatarTeamRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SVR_ERROR)
setUpAvatarTeamRsp := &proto.SetUpAvatarTeamRsp{
Retcode: int32(proto.Retcode_RETCODE_RET_SVR_ERROR),
}
g.SendMsg(cmd.SetUpAvatarTeamRsp, player.PlayerID, player.ClientSeq, setUpAvatarTeamRsp)
return
}
@@ -110,19 +110,21 @@ func (g *GameManager) SetUpAvatarTeamReq(player *model.Player, payloadMsg pb.Mes
}
if world.multiplayer {
// PacketSetUpAvatarTeamRsp
setUpAvatarTeamRsp := new(proto.SetUpAvatarTeamRsp)
setUpAvatarTeamRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SVR_ERROR)
setUpAvatarTeamRsp := &proto.SetUpAvatarTeamRsp{
Retcode: int32(proto.Retcode_RETCODE_RET_SVR_ERROR),
}
g.SendMsg(cmd.SetUpAvatarTeamRsp, player.PlayerID, player.ClientSeq, setUpAvatarTeamRsp)
return
}
// PacketAvatarTeamUpdateNotify
avatarTeamUpdateNotify := new(proto.AvatarTeamUpdateNotify)
avatarTeamUpdateNotify.AvatarTeamMap = make(map[uint32]*proto.AvatarTeam)
avatarTeamUpdateNotify := &proto.AvatarTeamUpdateNotify{
AvatarTeamMap: make(map[uint32]*proto.AvatarTeam),
}
for teamIndex, team := range player.TeamConfig.TeamList {
avatarTeam := new(proto.AvatarTeam)
avatarTeam.TeamName = team.Name
avatarTeam := &proto.AvatarTeam{
TeamName: team.Name,
AvatarGuidList: make([]uint64, 0),
}
for _, avatarId := range team.AvatarIdList {
if avatarId == 0 {
break
@@ -139,14 +141,14 @@ func (g *GameManager) SetUpAvatarTeamReq(player *model.Player, payloadMsg pb.Mes
scene := world.GetSceneById(player.SceneId)
scene.UpdatePlayerTeamEntity(player)
// PacketSceneTeamUpdateNotify
sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world)
g.SendMsg(cmd.SceneTeamUpdateNotify, player.PlayerID, player.ClientSeq, sceneTeamUpdateNotify)
// PacketSetUpAvatarTeamRsp
setUpAvatarTeamRsp := new(proto.SetUpAvatarTeamRsp)
setUpAvatarTeamRsp.TeamId = teamId
setUpAvatarTeamRsp.CurAvatarGuid = player.AvatarMap[player.TeamConfig.GetActiveAvatarId()].Guid
setUpAvatarTeamRsp := &proto.SetUpAvatarTeamRsp{
TeamId: teamId,
CurAvatarGuid: player.AvatarMap[player.TeamConfig.GetActiveAvatarId()].Guid,
AvatarTeamGuidList: make([]uint64, 0),
}
team := player.TeamConfig.GetTeamByIndex(uint8(teamId - 1))
for _, avatarId := range team.AvatarIdList {
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)
} else {
// PacketSetUpAvatarTeamRsp
setUpAvatarTeamRsp := new(proto.SetUpAvatarTeamRsp)
setUpAvatarTeamRsp.TeamId = teamId
setUpAvatarTeamRsp.CurAvatarGuid = player.AvatarMap[player.TeamConfig.GetActiveAvatarId()].Guid
setUpAvatarTeamRsp := &proto.SetUpAvatarTeamRsp{
TeamId: teamId,
CurAvatarGuid: player.AvatarMap[player.TeamConfig.GetActiveAvatarId()].Guid,
AvatarTeamGuidList: make([]uint64, 0),
}
team := player.TeamConfig.GetTeamByIndex(uint8(teamId - 1))
for _, avatarId := range team.AvatarIdList {
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)
req := payloadMsg.(*proto.ChooseCurAvatarTeamReq)
teamId := req.TeamId
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if world.multiplayer {
return
}
@@ -189,13 +192,12 @@ func (g *GameManager) ChooseCurAvatarTeamReq(player *model.Player, payloadMsg pb
scene := world.GetSceneById(player.SceneId)
scene.UpdatePlayerTeamEntity(player)
// PacketSceneTeamUpdateNotify
sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world)
g.SendMsg(cmd.SceneTeamUpdateNotify, player.PlayerID, player.ClientSeq, sceneTeamUpdateNotify)
// PacketChooseCurAvatarTeamRsp
chooseCurAvatarTeamRsp := new(proto.ChooseCurAvatarTeamRsp)
chooseCurAvatarTeamRsp.CurTeamId = teamId
chooseCurAvatarTeamRsp := &proto.ChooseCurAvatarTeamRsp{
CurTeamId: teamId,
}
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)
avatarGuidList := req.AvatarGuidList
world := g.worldManager.GetWorldByID(player.WorldId)
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
if len(avatarGuidList) == 0 || len(avatarGuidList) > 4 || !world.multiplayer {
// PacketChangeMpTeamAvatarRsp
changeMpTeamAvatarRsp := new(proto.ChangeMpTeamAvatarRsp)
changeMpTeamAvatarRsp.Retcode = int32(proto.Retcode_RETCODE_RET_SVR_ERROR)
changeMpTeamAvatarRsp := &proto.ChangeMpTeamAvatarRsp{
Retcode: int32(proto.Retcode_RETCODE_RET_SVR_ERROR),
}
g.SendMsg(cmd.ChangeMpTeamAvatarRsp, player.PlayerID, player.ClientSeq, changeMpTeamAvatarRsp)
return
}
@@ -230,14 +232,14 @@ func (g *GameManager) ChangeMpTeamAvatarReq(player *model.Player, payloadMsg pb.
scene.UpdatePlayerTeamEntity(player)
for _, worldPlayer := range world.playerMap {
// PacketSceneTeamUpdateNotify
sceneTeamUpdateNotify := g.PacketSceneTeamUpdateNotify(world)
g.SendMsg(cmd.SceneTeamUpdateNotify, worldPlayer.PlayerID, worldPlayer.ClientSeq, sceneTeamUpdateNotify)
}
// PacketChangeMpTeamAvatarRsp
changeMpTeamAvatarRsp := new(proto.ChangeMpTeamAvatarRsp)
changeMpTeamAvatarRsp.CurAvatarGuid = player.AvatarMap[player.TeamConfig.GetActiveAvatarId()].Guid
changeMpTeamAvatarRsp := &proto.ChangeMpTeamAvatarRsp{
CurAvatarGuid: player.AvatarMap[player.TeamConfig.GetActiveAvatarId()].Guid,
AvatarGuidList: make([]uint64, 0),
}
team := player.TeamConfig.GetTeamByIndex(3)
for _, avatarId := range team.AvatarIdList {
if avatarId == 0 {
@@ -249,8 +251,9 @@ func (g *GameManager) ChangeMpTeamAvatarReq(player *model.Player, payloadMsg pb.
}
func (g *GameManager) PacketSceneTeamUpdateNotify(world *World) *proto.SceneTeamUpdateNotify {
sceneTeamUpdateNotify := new(proto.SceneTeamUpdateNotify)
sceneTeamUpdateNotify.IsInMp = world.multiplayer
sceneTeamUpdateNotify := &proto.SceneTeamUpdateNotify{
IsInMp: world.multiplayer,
}
empty := new(proto.AbilitySyncStateInfo)
for _, worldPlayer := range world.playerMap {
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 {
player := g.userManager.GetOnlineUser(userId)
player := USER_MANAGER.GetOnlineUser(userId)
if player == nil {
logger.LOG.Error("player is nil, uid: %v", userId)
return 0
@@ -51,9 +51,10 @@ func (g *GameManager) AddUserWeapon(userId uint32, itemId uint32) uint64 {
return 0
}
// PacketStoreItemChangeNotify
storeItemChangeNotify := new(proto.StoreItemChangeNotify)
storeItemChangeNotify.StoreType = proto.StoreType_STORE_TYPE_PACK
storeItemChangeNotify := &proto.StoreItemChangeNotify{
StoreType: proto.StoreType_STORE_TYPE_PACK,
ItemList: make([]*proto.Item, 0),
}
affixMap := make(map[uint32]uint32)
for _, affixId := range weapon.AffixIdList {
affixMap[affixId] = uint32(weapon.Refinement)