mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-03-01 00:35:36 +08:00
优化
This commit is contained in:
+60
-7
@@ -87,7 +87,9 @@ func NewGameManager(dao *dao.Dao, messageQueue *mq.MessageQueue, gsId uint32, gs
|
|||||||
r.ai = r.CreateRobot(uid, name, sign)
|
r.ai = r.CreateRobot(uid, name, sign)
|
||||||
WORLD_MANAGER.InitAiWorld(r.ai)
|
WORLD_MANAGER.InitAiWorld(r.ai)
|
||||||
COMMAND_MANAGER.SetSystem(r.ai)
|
COMMAND_MANAGER.SetSystem(r.ai)
|
||||||
|
COMMAND_MANAGER.gmCmd.GMUnlockAllPoint(r.ai.PlayerID, 3)
|
||||||
USER_MANAGER.SetRemoteUserOnlineState(BigWorldAiUid, true, mainGsAppid)
|
USER_MANAGER.SetRemoteUserOnlineState(BigWorldAiUid, true, mainGsAppid)
|
||||||
|
aiWorld := WORLD_MANAGER.GetAiWorld()
|
||||||
if r.IsMainGs() {
|
if r.IsMainGs() {
|
||||||
// TODO 测试
|
// TODO 测试
|
||||||
for i := 1; i < 100; i++ {
|
for i := 1; i < 100; i++ {
|
||||||
@@ -105,13 +107,52 @@ func NewGameManager(dao *dao.Dao, messageQueue *mq.MessageQueue, gsId uint32, gs
|
|||||||
AvatarTeamGuidList: []uint64{dbAvatar.AvatarMap[avatarId].Guid},
|
AvatarTeamGuidList: []uint64{dbAvatar.AvatarMap[avatarId].Guid},
|
||||||
CurAvatarGuid: dbAvatar.AvatarMap[avatarId].Guid,
|
CurAvatarGuid: dbAvatar.AvatarMap[avatarId].Guid,
|
||||||
})
|
})
|
||||||
pos := &model.Vector{
|
r.JoinPlayerSceneReq(robot, &proto.JoinPlayerSceneReq{
|
||||||
X: 1800.0 + random.GetRandomFloat64(-100.0, 100.0),
|
TargetUid: r.ai.PlayerID,
|
||||||
Y: 195.0 + random.GetRandomFloat64(0.0, 5.0),
|
})
|
||||||
Z: -1500.0 + random.GetRandomFloat64(-100.0, 100.0),
|
r.EnterSceneReadyReq(robot, &proto.EnterSceneReadyReq{
|
||||||
|
EnterSceneToken: aiWorld.GetEnterSceneToken(),
|
||||||
|
})
|
||||||
|
r.SceneInitFinishReq(robot, &proto.SceneInitFinishReq{
|
||||||
|
EnterSceneToken: aiWorld.GetEnterSceneToken(),
|
||||||
|
})
|
||||||
|
r.EnterSceneDoneReq(robot, &proto.EnterSceneDoneReq{
|
||||||
|
EnterSceneToken: aiWorld.GetEnterSceneToken(),
|
||||||
|
})
|
||||||
|
r.PostEnterSceneReq(robot, &proto.PostEnterSceneReq{
|
||||||
|
EnterSceneToken: aiWorld.GetEnterSceneToken(),
|
||||||
|
})
|
||||||
|
activeAvatarId := aiWorld.GetPlayerActiveAvatarId(robot)
|
||||||
|
entityMoveInfo := &proto.EntityMoveInfo{
|
||||||
|
EntityId: aiWorld.GetPlayerWorldAvatarEntityId(robot, activeAvatarId),
|
||||||
|
MotionInfo: &proto.MotionInfo{
|
||||||
|
Pos: &proto.Vector{
|
||||||
|
X: float32(1800.0 + random.GetRandomFloat64(-100.0, 100.0)),
|
||||||
|
Y: float32(195.0 + random.GetRandomFloat64(0.0, 5.0)),
|
||||||
|
Z: float32(-1500.0 + random.GetRandomFloat64(-100.0, 100.0)),
|
||||||
|
},
|
||||||
|
Rot: &proto.Vector{
|
||||||
|
X: 0,
|
||||||
|
Y: float32(random.GetRandomFloat64(0.0, 360.0)),
|
||||||
|
Z: 0,
|
||||||
|
},
|
||||||
|
State: proto.MotionState_MOTION_STANDBY,
|
||||||
|
},
|
||||||
|
SceneTime: 0,
|
||||||
|
ReliableSeq: 0,
|
||||||
}
|
}
|
||||||
robot.Pos = pos
|
combatData, err := pb.Marshal(entityMoveInfo)
|
||||||
r.UserWorldAddPlayer(WORLD_MANAGER.GetAiWorld(), robot)
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
r.CombatInvocationsNotify(robot, &proto.CombatInvocationsNotify{
|
||||||
|
InvokeList: []*proto.CombatInvokeEntry{{
|
||||||
|
CombatData: combatData,
|
||||||
|
ForwardType: proto.ForwardType_FORWARD_TO_ALL_EXCEPT_CUR,
|
||||||
|
ArgumentType: proto.CombatTypeArgument_ENTITY_MOVE,
|
||||||
|
}},
|
||||||
|
})
|
||||||
|
r.UnionCmdNotify(robot, &proto.UnionCmdNotify{})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r.run()
|
r.run()
|
||||||
@@ -145,8 +186,20 @@ func (g *Game) CreateRobot(uid uint32, name string, sign string) *model.Player {
|
|||||||
robot := USER_MANAGER.GetOnlineUser(uid)
|
robot := USER_MANAGER.GetOnlineUser(uid)
|
||||||
robot.DbState = model.DbNormal
|
robot.DbState = model.DbNormal
|
||||||
g.SetPlayerBornDataReq(robot, &proto.SetPlayerBornDataReq{AvatarId: 10000007, NickName: name})
|
g.SetPlayerBornDataReq(robot, &proto.SetPlayerBornDataReq{AvatarId: 10000007, NickName: name})
|
||||||
robot.SceneLoadState = model.SceneEnterDone
|
|
||||||
robot.Signature = sign
|
robot.Signature = sign
|
||||||
|
world := WORLD_MANAGER.GetWorldByID(robot.WorldId)
|
||||||
|
g.EnterSceneReadyReq(robot, &proto.EnterSceneReadyReq{
|
||||||
|
EnterSceneToken: world.GetEnterSceneToken(),
|
||||||
|
})
|
||||||
|
g.SceneInitFinishReq(robot, &proto.SceneInitFinishReq{
|
||||||
|
EnterSceneToken: world.GetEnterSceneToken(),
|
||||||
|
})
|
||||||
|
g.EnterSceneDoneReq(robot, &proto.EnterSceneDoneReq{
|
||||||
|
EnterSceneToken: world.GetEnterSceneToken(),
|
||||||
|
})
|
||||||
|
g.PostEnterSceneReq(robot, &proto.PostEnterSceneReq{
|
||||||
|
EnterSceneToken: world.GetEnterSceneToken(),
|
||||||
|
})
|
||||||
return robot
|
return robot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -252,15 +252,12 @@ func (w *World) AddEnterSceneContext(ctx *EnterSceneContext) uint32 {
|
|||||||
return w.enterSceneToken
|
return w.enterSceneToken
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *World) GetLastEnterSceneContextBySceneIdAndUid(sceneId uint32, uid uint32) *EnterSceneContext {
|
func (w *World) GetLastEnterSceneContextByUid(uid uint32) *EnterSceneContext {
|
||||||
for token := w.enterSceneToken; token >= 5000; token -= 100 {
|
for token := w.enterSceneToken; token >= 5000; token -= 100 {
|
||||||
ctx, exist := w.enterSceneContextMap[token]
|
ctx, exist := w.enterSceneContextMap[token]
|
||||||
if !exist {
|
if !exist {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if ctx.OldSceneId != sceneId {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if ctx.Uid != uid {
|
if ctx.Uid != uid {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -269,6 +266,19 @@ func (w *World) GetLastEnterSceneContextBySceneIdAndUid(sceneId uint32, uid uint
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *World) RemoveAllEnterSceneContextByUid(uid uint32) {
|
||||||
|
for token := w.enterSceneToken; token >= 5000; token -= 100 {
|
||||||
|
ctx, exist := w.enterSceneContextMap[token]
|
||||||
|
if !exist {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if ctx.Uid != uid {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
delete(w.enterSceneContextMap, token)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (w *World) GetWorldLevel() uint8 {
|
func (w *World) GetWorldLevel() uint8 {
|
||||||
return w.worldLevel
|
return w.worldLevel
|
||||||
}
|
}
|
||||||
@@ -309,7 +319,6 @@ func (w *World) GetPlayerPeerId(player *model.Player) uint32 {
|
|||||||
peerId = uint32(peerIdIndex) + 1
|
peerId = uint32(peerIdIndex) + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// logger.Debug("get player peer id is: %v, uid: %v", peerId, player.PlayerID)
|
|
||||||
return peerId
|
return peerId
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,12 +371,6 @@ func (w *World) AddPlayer(player *model.Player, sceneId uint32) {
|
|||||||
scene := w.GetSceneById(sceneId)
|
scene := w.GetSceneById(sceneId)
|
||||||
scene.AddPlayer(player)
|
scene.AddPlayer(player)
|
||||||
w.InitPlayerTeamEntityId(player)
|
w.InitPlayerTeamEntityId(player)
|
||||||
if WORLD_MANAGER.IsBigWorld(w) {
|
|
||||||
activeAvatarId := w.GetPlayerActiveAvatarId(player)
|
|
||||||
worldAvatar := w.GetPlayerWorldAvatar(player, activeAvatarId)
|
|
||||||
w.bigWorldAoi.AddObjectToGridByPos(int64(player.PlayerID), worldAvatar,
|
|
||||||
float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *World) RemovePlayer(player *model.Player) {
|
func (w *World) RemovePlayer(player *model.Player) {
|
||||||
@@ -375,6 +378,7 @@ func (w *World) RemovePlayer(player *model.Player) {
|
|||||||
w.peerList = append(w.peerList[:peerId-1], w.peerList[peerId:]...)
|
w.peerList = append(w.peerList[:peerId-1], w.peerList[peerId:]...)
|
||||||
scene := w.sceneMap[player.SceneId]
|
scene := w.sceneMap[player.SceneId]
|
||||||
scene.RemovePlayer(player)
|
scene.RemovePlayer(player)
|
||||||
|
w.RemoveAllEnterSceneContextByUid(player.PlayerID)
|
||||||
delete(w.playerMap, player.PlayerID)
|
delete(w.playerMap, player.PlayerID)
|
||||||
delete(w.playerFirstEnterMap, player.PlayerID)
|
delete(w.playerFirstEnterMap, player.PlayerID)
|
||||||
delete(w.multiplayerTeam.localTeamMap, player.PlayerID)
|
delete(w.multiplayerTeam.localTeamMap, player.PlayerID)
|
||||||
@@ -382,8 +386,6 @@ func (w *World) RemovePlayer(player *model.Player) {
|
|||||||
delete(w.multiplayerTeam.localTeamEntityMap, player.PlayerID)
|
delete(w.multiplayerTeam.localTeamEntityMap, player.PlayerID)
|
||||||
if WORLD_MANAGER.IsBigWorld(w) {
|
if WORLD_MANAGER.IsBigWorld(w) {
|
||||||
w.RemoveMultiplayerTeam(player)
|
w.RemoveMultiplayerTeam(player)
|
||||||
w.bigWorldAoi.RemoveObjectFromGridByPos(int64(player.PlayerID),
|
|
||||||
float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z))
|
|
||||||
} else {
|
} else {
|
||||||
if player.PlayerID != w.owner.PlayerID {
|
if player.PlayerID != w.owner.PlayerID {
|
||||||
w.UpdateMultiplayerTeam()
|
w.UpdateMultiplayerTeam()
|
||||||
@@ -658,7 +660,7 @@ func (w *World) copyLocalTeamToWorld(start int, end int, peerId uint32) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 为了实现大世界无限人数写的
|
// 为了实现大世界无限人数写的
|
||||||
// 现在看来把世界里所有人放进队伍里发给客户端超过8个客户端会崩溃
|
// 现在看来把世界里所有人放进队伍里发给客户端超过8个客户端会崩溃
|
||||||
// 看来还是不能简单的走通用逻辑 需要对大世界场景队伍做特殊处理 欺骗客户端其他玩家仅仅以场景角色实体的形式出现
|
// 看来还是不能简单的走通用逻辑 需要对大世界场景队伍做特殊处理 欺骗客户端其他玩家仅仅以场景角色实体的形式出现
|
||||||
|
|
||||||
|
|||||||
+42
-18
@@ -101,6 +101,18 @@ func GetContextGroup(player *model.Player, ctx *lua.LTable, luaState *lua.LState
|
|||||||
return group
|
return group
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetContextDbSceneGroup(player *model.Player, groupId uint32) *model.DbSceneGroup {
|
||||||
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
|
if world == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
owner := world.GetOwner()
|
||||||
|
dbWorld := owner.GetDbWorld()
|
||||||
|
dbScene := dbWorld.GetSceneById(player.SceneId)
|
||||||
|
dbSceneGroup := dbScene.GetSceneGroupById(groupId)
|
||||||
|
return dbSceneGroup
|
||||||
|
}
|
||||||
|
|
||||||
// RegLuaScriptLibFunc 注册LUA侧ScriptLib调用的Golang方法
|
// RegLuaScriptLibFunc 注册LUA侧ScriptLib调用的Golang方法
|
||||||
func RegLuaScriptLibFunc() {
|
func RegLuaScriptLibFunc() {
|
||||||
gdconf.RegScriptLibFunc("GetEntityType", GetEntityType)
|
gdconf.RegScriptLibFunc("GetEntityType", GetEntityType)
|
||||||
@@ -497,9 +509,11 @@ func GetGroupVariableValue(luaState *lua.LState) int {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
name := luaState.ToString(2)
|
name := luaState.ToString(2)
|
||||||
dbWorld := player.GetDbWorld()
|
dbSceneGroup := GetContextDbSceneGroup(player, uint32(groupId))
|
||||||
dbScene := dbWorld.GetSceneById(player.SceneId)
|
if dbSceneGroup == nil {
|
||||||
dbSceneGroup := dbScene.GetSceneGroupById(uint32(groupId))
|
luaState.Push(lua.LNumber(-1))
|
||||||
|
return 1
|
||||||
|
}
|
||||||
value := dbSceneGroup.GetVariableByName(name)
|
value := dbSceneGroup.GetVariableByName(name)
|
||||||
luaState.Push(lua.LNumber(value))
|
luaState.Push(lua.LNumber(value))
|
||||||
return 1
|
return 1
|
||||||
@@ -518,9 +532,11 @@ func GetGroupVariableValueByGroup(luaState *lua.LState) int {
|
|||||||
}
|
}
|
||||||
name := luaState.ToString(2)
|
name := luaState.ToString(2)
|
||||||
groupId := luaState.ToInt(3)
|
groupId := luaState.ToInt(3)
|
||||||
dbWorld := player.GetDbWorld()
|
dbSceneGroup := GetContextDbSceneGroup(player, uint32(groupId))
|
||||||
dbScene := dbWorld.GetSceneById(player.SceneId)
|
if dbSceneGroup == nil {
|
||||||
dbSceneGroup := dbScene.GetSceneGroupById(uint32(groupId))
|
luaState.Push(lua.LNumber(-1))
|
||||||
|
return 1
|
||||||
|
}
|
||||||
value := dbSceneGroup.GetVariableByName(name)
|
value := dbSceneGroup.GetVariableByName(name)
|
||||||
luaState.Push(lua.LNumber(value))
|
luaState.Push(lua.LNumber(value))
|
||||||
return 1
|
return 1
|
||||||
@@ -544,9 +560,11 @@ func SetGroupVariableValue(luaState *lua.LState) int {
|
|||||||
}
|
}
|
||||||
name := luaState.ToString(2)
|
name := luaState.ToString(2)
|
||||||
value := luaState.ToInt(3)
|
value := luaState.ToInt(3)
|
||||||
dbWorld := player.GetDbWorld()
|
dbSceneGroup := GetContextDbSceneGroup(player, uint32(groupId))
|
||||||
dbScene := dbWorld.GetSceneById(player.SceneId)
|
if dbSceneGroup == nil {
|
||||||
dbSceneGroup := dbScene.GetSceneGroupById(uint32(groupId))
|
luaState.Push(lua.LNumber(-1))
|
||||||
|
return 1
|
||||||
|
}
|
||||||
dbSceneGroup.SetVariable(name, int32(value))
|
dbSceneGroup.SetVariable(name, int32(value))
|
||||||
luaState.Push(lua.LNumber(0))
|
luaState.Push(lua.LNumber(0))
|
||||||
return 1
|
return 1
|
||||||
@@ -566,9 +584,11 @@ func SetGroupVariableValueByGroup(luaState *lua.LState) int {
|
|||||||
name := luaState.ToString(2)
|
name := luaState.ToString(2)
|
||||||
value := luaState.ToInt(3)
|
value := luaState.ToInt(3)
|
||||||
groupId := luaState.ToInt(4)
|
groupId := luaState.ToInt(4)
|
||||||
dbWorld := player.GetDbWorld()
|
dbSceneGroup := GetContextDbSceneGroup(player, uint32(groupId))
|
||||||
dbScene := dbWorld.GetSceneById(player.SceneId)
|
if dbSceneGroup == nil {
|
||||||
dbSceneGroup := dbScene.GetSceneGroupById(uint32(groupId))
|
luaState.Push(lua.LNumber(-1))
|
||||||
|
return 1
|
||||||
|
}
|
||||||
dbSceneGroup.SetVariable(name, int32(value))
|
dbSceneGroup.SetVariable(name, int32(value))
|
||||||
luaState.Push(lua.LNumber(0))
|
luaState.Push(lua.LNumber(0))
|
||||||
return 1
|
return 1
|
||||||
@@ -592,9 +612,11 @@ func ChangeGroupVariableValue(luaState *lua.LState) int {
|
|||||||
}
|
}
|
||||||
name := luaState.ToString(2)
|
name := luaState.ToString(2)
|
||||||
change := luaState.ToInt(3)
|
change := luaState.ToInt(3)
|
||||||
dbWorld := player.GetDbWorld()
|
dbSceneGroup := GetContextDbSceneGroup(player, uint32(groupId))
|
||||||
dbScene := dbWorld.GetSceneById(player.SceneId)
|
if dbSceneGroup == nil {
|
||||||
dbSceneGroup := dbScene.GetSceneGroupById(uint32(groupId))
|
luaState.Push(lua.LNumber(-1))
|
||||||
|
return 1
|
||||||
|
}
|
||||||
value := dbSceneGroup.GetVariableByName(name)
|
value := dbSceneGroup.GetVariableByName(name)
|
||||||
dbSceneGroup.SetVariable(name, value+int32(change))
|
dbSceneGroup.SetVariable(name, value+int32(change))
|
||||||
luaState.Push(lua.LNumber(0))
|
luaState.Push(lua.LNumber(0))
|
||||||
@@ -615,9 +637,11 @@ func ChangeGroupVariableValueByGroup(luaState *lua.LState) int {
|
|||||||
name := luaState.ToString(2)
|
name := luaState.ToString(2)
|
||||||
change := luaState.ToInt(3)
|
change := luaState.ToInt(3)
|
||||||
groupId := luaState.ToInt(4)
|
groupId := luaState.ToInt(4)
|
||||||
dbWorld := player.GetDbWorld()
|
dbSceneGroup := GetContextDbSceneGroup(player, uint32(groupId))
|
||||||
dbScene := dbWorld.GetSceneById(player.SceneId)
|
if dbSceneGroup == nil {
|
||||||
dbSceneGroup := dbScene.GetSceneGroupById(uint32(groupId))
|
luaState.Push(lua.LNumber(-1))
|
||||||
|
return 1
|
||||||
|
}
|
||||||
value := dbSceneGroup.GetVariableByName(name)
|
value := dbSceneGroup.GetVariableByName(name)
|
||||||
dbSceneGroup.SetVariable(name, value+int32(change))
|
dbSceneGroup.SetVariable(name, value+int32(change))
|
||||||
luaState.Push(lua.LNumber(0))
|
luaState.Push(lua.LNumber(0))
|
||||||
|
|||||||
@@ -363,6 +363,10 @@ func (g *Game) BigWorldAoiPlayerMove(player *model.Player, world *World, scene *
|
|||||||
// 通知老格子里的其它玩家 自己消失
|
// 通知老格子里的其它玩家 自己消失
|
||||||
for otherPlayerId := range oldOtherWorldAvatarMap {
|
for otherPlayerId := range oldOtherWorldAvatarMap {
|
||||||
otherPlayer := USER_MANAGER.GetOnlineUser(uint32(otherPlayerId))
|
otherPlayer := USER_MANAGER.GetOnlineUser(uint32(otherPlayerId))
|
||||||
|
if otherPlayer == nil {
|
||||||
|
logger.Error("get player is nil, target uid: %v, uid: %v", otherPlayerId, player.PlayerID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
g.RemoveSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_MISS, []uint32{activeWorldAvatar.GetAvatarEntityId()})
|
g.RemoveSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_MISS, []uint32{activeWorldAvatar.GetAvatarEntityId()})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -381,6 +385,10 @@ func (g *Game) BigWorldAoiPlayerMove(player *model.Player, world *World, scene *
|
|||||||
// 通知新格子里的其他玩家 自己出现
|
// 通知新格子里的其他玩家 自己出现
|
||||||
for otherPlayerId := range newOtherWorldAvatarMap {
|
for otherPlayerId := range newOtherWorldAvatarMap {
|
||||||
otherPlayer := USER_MANAGER.GetOnlineUser(uint32(otherPlayerId))
|
otherPlayer := USER_MANAGER.GetOnlineUser(uint32(otherPlayerId))
|
||||||
|
if otherPlayer == nil {
|
||||||
|
logger.Error("get player is nil, target uid: %v, uid: %v", otherPlayerId, player.PlayerID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
sceneEntityInfoAvatar := g.PacketSceneEntityInfoAvatar(scene, player, world.GetPlayerActiveAvatarId(player))
|
sceneEntityInfoAvatar := g.PacketSceneEntityInfoAvatar(scene, player, world.GetPlayerActiveAvatarId(player))
|
||||||
g.AddSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_MEET, []*proto.SceneEntityInfo{sceneEntityInfoAvatar})
|
g.AddSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_MEET, []*proto.SceneEntityInfo{sceneEntityInfoAvatar})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -415,6 +415,10 @@ func (g *Game) UserWorldRemovePlayer(world *World, player *model.Player) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
world.RemovePlayer(player)
|
world.RemovePlayer(player)
|
||||||
|
if WORLD_MANAGER.IsBigWorld(world) {
|
||||||
|
bigWorldAoi := world.GetBigWorldAoi()
|
||||||
|
bigWorldAoi.RemoveObjectFromGridByPos(int64(player.PlayerID), float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z))
|
||||||
|
}
|
||||||
player.WorldId = 0
|
player.WorldId = 0
|
||||||
if world.GetOwner().PlayerID == player.PlayerID {
|
if world.GetOwner().PlayerID == player.PlayerID {
|
||||||
// 房主离开销毁世界
|
// 房主离开销毁世界
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ func (g *Game) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
activeAvatarId := world.GetPlayerActiveAvatarId(player)
|
activeAvatarId := world.GetPlayerActiveAvatarId(player)
|
||||||
activeWorldAvatar := world.GetPlayerWorldAvatar(player, activeAvatarId)
|
activeWorldAvatar := world.GetPlayerWorldAvatar(player, activeAvatarId)
|
||||||
|
|
||||||
if WORLD_MANAGER.IsBigWorld(world) && !world.IsPlayerFirstEnter(player) {
|
if WORLD_MANAGER.IsBigWorld(world) {
|
||||||
bigWorldAoi := world.GetBigWorldAoi()
|
bigWorldAoi := world.GetBigWorldAoi()
|
||||||
bigWorldAoi.AddObjectToGridByPos(int64(player.PlayerID), activeWorldAvatar, float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z))
|
bigWorldAoi.AddObjectToGridByPos(int64(player.PlayerID), activeWorldAvatar, float32(player.Pos.X), float32(player.Pos.Y), float32(player.Pos.Z))
|
||||||
}
|
}
|
||||||
@@ -679,7 +679,6 @@ func (g *Game) GetNeighborGroup(sceneId uint32, pos *model.Vector) map[uint32]*g
|
|||||||
func (g *Game) AddSceneGroup(player *model.Player, scene *Scene, groupConfig *gdconf.Group) {
|
func (g *Game) AddSceneGroup(player *model.Player, scene *Scene, groupConfig *gdconf.Group) {
|
||||||
group := scene.GetGroupById(uint32(groupConfig.Id))
|
group := scene.GetGroupById(uint32(groupConfig.Id))
|
||||||
if group != nil {
|
if group != nil {
|
||||||
logger.Error("group already exist, groupId: %v, uid: %v", groupConfig.Id, player.PlayerID)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
initSuiteId := groupConfig.GroupInitConfig.Suite
|
initSuiteId := groupConfig.GroupInitConfig.Suite
|
||||||
|
|||||||
+24
-6
@@ -22,7 +22,13 @@ func (g *Game) SceneTransToPointReq(player *model.Player, payloadMsg pb.Message)
|
|||||||
g.SendError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{}, proto.Retcode_RET_IN_TRANSFER)
|
g.SendError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{}, proto.Retcode_RET_IN_TRANSFER)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dbWorld := player.GetDbWorld()
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
|
if world == nil {
|
||||||
|
g.SendError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
owner := world.GetOwner()
|
||||||
|
dbWorld := owner.GetDbWorld()
|
||||||
dbScene := dbWorld.GetSceneById(req.SceneId)
|
dbScene := dbWorld.GetSceneById(req.SceneId)
|
||||||
if dbScene == nil {
|
if dbScene == nil {
|
||||||
g.SendError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{}, proto.Retcode_RET_POINT_NOT_UNLOCKED)
|
g.SendError(cmd.SceneTransToPointRsp, player, &proto.SceneTransToPointRsp{}, proto.Retcode_RET_POINT_NOT_UNLOCKED)
|
||||||
@@ -60,7 +66,13 @@ func (g *Game) SceneTransToPointReq(player *model.Player, payloadMsg pb.Message)
|
|||||||
func (g *Game) UnlockTransPointReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) UnlockTransPointReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.UnlockTransPointReq)
|
req := payloadMsg.(*proto.UnlockTransPointReq)
|
||||||
|
|
||||||
dbWorld := player.GetDbWorld()
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
|
if world == nil {
|
||||||
|
g.SendError(cmd.UnlockTransPointRsp, player, &proto.UnlockTransPointRsp{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
owner := world.GetOwner()
|
||||||
|
dbWorld := owner.GetDbWorld()
|
||||||
dbScene := dbWorld.GetSceneById(req.SceneId)
|
dbScene := dbWorld.GetSceneById(req.SceneId)
|
||||||
if dbScene == nil {
|
if dbScene == nil {
|
||||||
g.SendError(cmd.UnlockTransPointRsp, player, &proto.UnlockTransPointRsp{}, proto.Retcode_RET_POINT_NOT_UNLOCKED)
|
g.SendError(cmd.UnlockTransPointRsp, player, &proto.UnlockTransPointRsp{}, proto.Retcode_RET_POINT_NOT_UNLOCKED)
|
||||||
@@ -86,7 +98,13 @@ func (g *Game) UnlockTransPointReq(player *model.Player, payloadMsg pb.Message)
|
|||||||
func (g *Game) GetScenePointReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) GetScenePointReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.GetScenePointReq)
|
req := payloadMsg.(*proto.GetScenePointReq)
|
||||||
|
|
||||||
dbWorld := player.GetDbWorld()
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
|
if world == nil {
|
||||||
|
g.SendError(cmd.GetScenePointRsp, player, &proto.GetScenePointRsp{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
owner := world.GetOwner()
|
||||||
|
dbWorld := owner.GetDbWorld()
|
||||||
dbScene := dbWorld.GetSceneById(req.SceneId)
|
dbScene := dbWorld.GetSceneById(req.SceneId)
|
||||||
if dbScene == nil {
|
if dbScene == nil {
|
||||||
g.SendError(cmd.GetScenePointRsp, player, &proto.GetScenePointRsp{})
|
g.SendError(cmd.GetScenePointRsp, player, &proto.GetScenePointRsp{})
|
||||||
@@ -280,18 +298,18 @@ func (g *Game) PlayerQuitDungeonReq(player *model.Player, payloadMsg pb.Message)
|
|||||||
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerID)
|
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx := world.GetLastEnterSceneContextBySceneIdAndUid(3, player.PlayerID)
|
ctx := world.GetLastEnterSceneContextByUid(player.PlayerID)
|
||||||
if ctx == nil {
|
if ctx == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pointDataConfig := gdconf.GetScenePointBySceneIdAndPointId(3, int32(ctx.OldDungeonPointId))
|
pointDataConfig := gdconf.GetScenePointBySceneIdAndPointId(int32(ctx.OldSceneId), int32(ctx.OldDungeonPointId))
|
||||||
if pointDataConfig == nil {
|
if pointDataConfig == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
g.TeleportPlayer(
|
g.TeleportPlayer(
|
||||||
player,
|
player,
|
||||||
proto.EnterReason_ENTER_REASON_DUNGEON_QUIT,
|
proto.EnterReason_ENTER_REASON_DUNGEON_QUIT,
|
||||||
3,
|
ctx.OldSceneId,
|
||||||
&model.Vector{X: pointDataConfig.TranPos.X, Y: pointDataConfig.TranPos.Y, Z: pointDataConfig.TranPos.Z},
|
&model.Vector{X: pointDataConfig.TranPos.X, Y: pointDataConfig.TranPos.Y, Z: pointDataConfig.TranPos.Z},
|
||||||
&model.Vector{X: pointDataConfig.TranRot.X, Y: pointDataConfig.TranRot.Y, Z: pointDataConfig.TranRot.Z},
|
&model.Vector{X: pointDataConfig.TranRot.X, Y: pointDataConfig.TranRot.Y, Z: pointDataConfig.TranRot.Z},
|
||||||
0,
|
0,
|
||||||
|
|||||||
Reference in New Issue
Block a user