This commit is contained in:
flswld committed 2024-04-24 18:09:46 +08:00
1 parent 0df3016e6e
commit 721a871890
10 files changed
+64 -32

No files matched your search

+6 -6
View File
@@ -21,17 +21,17 @@ const (
PLAYER_PROP_CUR_TEMPORARY_STAMINA = 10012 // 当前临时耐力 暂不确定
PLAYER_PROP_PLAYER_LEVEL = 10013 // 冒险等级
PLAYER_PROP_PLAYER_EXP = 10014 // 冒险经验
PLAYER_PROP_PLAYER_HCOIN = 10015 // 原石 可以为负数
PLAYER_PROP_PLAYER_HCOIN = 10015 // 原石
PLAYER_PROP_PLAYER_SCOIN = 10016 // 摩拉
PLAYER_PROP_PLAYER_MP_SETTING_TYPE = 10017 // 多人游戏世界权限 0禁止加入 1直接加入 2需要申请
PLAYER_PROP_IS_MP_MODE_AVAILABLE = 10018 // 玩家当前的世界是否可加入 0 1 例如任务中就不可加入
PLAYER_PROP_PLAYER_WORLD_LEVEL = 10019 // 世界等级 0-8
PLAYER_PROP_PLAYER_RESIN = 10020 // 树脂 0-2000
PLAYER_PROP_PLAYER_WAIT_SUB_HCOIN = 10022 // 暂存的原石 暂不确定
PLAYER_PROP_PLAYER_WAIT_SUB_SCOIN = 10023 // 暂存的摩拉 暂不确定
PLAYER_PROP_PLAYER_WAIT_SUB_HCOIN = 10022 // 扣到负数的原石
PLAYER_PROP_PLAYER_WAIT_SUB_SCOIN = 10023 // 扣到负数的摩拉
PLAYER_PROP_IS_ONLY_MP_WITH_PS_PLAYER = 10024 // 当前玩家多人世界里是否有PS主机玩家 0 1
PLAYER_PROP_PLAYER_MCOIN = 10025 // 创世结晶 可以为负数
PLAYER_PROP_PLAYER_WAIT_SUB_MCOIN = 10026 // 暂存的创世结晶 暂不确定
PLAYER_PROP_PLAYER_MCOIN = 10025 // 创世结晶
PLAYER_PROP_PLAYER_WAIT_SUB_MCOIN = 10026 // 扣到负数的创世结晶
PLAYER_PROP_PLAYER_LEGENDARY_KEY = 10027 // 传说任务钥匙
PLAYER_PROP_IS_HAS_FIRST_SHARE = 10028 // 是否拥有抽卡结果首次分享奖励 暂不确定
PLAYER_PROP_PLAYER_FORGE_POINT = 10029 // 锻造相关
@@ -43,7 +43,7 @@ const (
PLAYER_PROP_PLAYER_WORLD_LEVEL_ADJUST_CD = 10040 // 降低世界等级的CD
PLAYER_PROP_PLAYER_LEGENDARY_DAILY_TASK_NUM = 10041 // 传说每日任务数量 暂不确定
PLAYER_PROP_PLAYER_HOME_COIN = 10042 // 洞天宝钱
PLAYER_PROP_PLAYER_WAIT_SUB_HOME_COIN = 10043 // 暂存的洞天宝钱 暂不确定
PLAYER_PROP_PLAYER_WAIT_SUB_HOME_COIN = 10043 // 扣到负数的洞天宝钱
PLAYER_PROP_IS_AUTO_UNLOCK_SPECIFIC_EQUIP = 10044 // 是否自动解锁特殊装备 暂不确定
PLAYER_PROP_PLAYER_GCG_COIN = 10045 // 七圣召唤相关
PLAYER_PROP_PLAYER_WAIT_SUB_GCG_COIN = 10046 // 七圣召唤相关
+1 -1
View File
@@ -62,7 +62,7 @@ func (l *LocalEventManager) LocalEventHandle(localEvent *LocalEvent) {
}
}()
gdconf.ReloadGameDataConfig(reloadSceneLua)
LOCAL_EVENT_MANAGER.localEventChan <- &LocalEvent{
l.localEventChan <- &LocalEvent{
EventId: ReloadGameDataConfigFinish,
}
}()
+6 -6
View File
@@ -171,7 +171,7 @@ func (u *UserManager) UserLoginLoad(userId uint32, clientSeq uint32, gateAppId s
func (u *UserManager) OnlineUser(player *model.Player) {
player.Online = true
player.OnlineTime = uint32(time.Now().Unix())
USER_MANAGER.AddUser(player)
u.AddUser(player)
GAME.messageQueue.SendToAll(&mq.NetMsg{
MsgType: mq.MsgTypeServer,
EventId: mq.ServerUserOnlineStateChangeNotify,
@@ -269,7 +269,7 @@ func (u *UserManager) UserOfflineSave(player *model.Player, changeGsInfo *Change
// OfflineUser 玩家离线
func (u *UserManager) OfflineUser(player *model.Player, changeGsInfo *ChangeGsInfo) {
USER_MANAGER.DeleteUser(player.PlayerId)
u.DeleteUser(player.PlayerId)
GAME.messageQueue.SendToAll(&mq.NetMsg{
MsgType: mq.MsgTypeServer,
EventId: mq.ServerUserOnlineStateChangeNotify,
@@ -280,7 +280,7 @@ func (u *UserManager) OfflineUser(player *model.Player, changeGsInfo *ChangeGsIn
})
atomic.AddInt32(&ONLINE_PLAYER_NUM, -1)
if changeGsInfo.IsChangeGs {
gsAppId := USER_MANAGER.GetRemoteUserGsAppId(changeGsInfo.JoinHostUserId)
gsAppId := u.GetRemoteUserGsAppId(changeGsInfo.JoinHostUserId)
GAME.messageQueue.SendToGate(player.GateAppId, &mq.NetMsg{
MsgType: mq.MsgTypeServer,
EventId: mq.ServerUserGsChangeNotify,
@@ -621,7 +621,7 @@ func (p PlayerLastSaveTimeSortList) Swap(i, j int) {
func (u *UserManager) UserCopyAndSave(exitSave bool) {
startTime := time.Now().UnixNano()
playerList := make(PlayerLastSaveTimeSortList, 0)
for _, player := range USER_MANAGER.GetAllOnlineUserList() {
for _, player := range u.GetAllOnlineUserList() {
if player.PlayerId < PlayerBaseUid {
continue
}
@@ -688,7 +688,7 @@ func (u *UserManager) UserCopyAndSave(exitSave bool) {
player.LastSaveTime = uint32(time.Now().UnixMilli())
saveCount++
case model.DbDelete:
USER_MANAGER.DeleteUser(player.PlayerId)
u.DeleteUser(player.PlayerId)
case model.DbNormal:
updatePlayerList = append(updatePlayerList, playerData)
player.LastSaveTime = uint32(time.Now().UnixMilli())
@@ -701,7 +701,7 @@ func (u *UserManager) UserCopyAndSave(exitSave bool) {
updatePlayerList: updatePlayerList,
exitSave: exitSave,
}
USER_MANAGER.GetSaveUserChan() <- saveUserData
u.GetSaveUserChan() <- saveUserData
endTime := time.Now().UnixNano()
costTime := endTime - startTime
logger.Info("run save user copy cost time: %v ns, save user count: %v", costTime, saveCount)
+11 -8
View File
@@ -51,6 +51,7 @@ func (w *WorldManager) CreateWorld(owner *model.Player) *World {
worldId := uint64(w.snowflake.GenId())
world := &World{
id: worldId,
worldManager: w,
owner: owner,
playerMap: make(map[uint32]*model.Player),
sceneMap: make(map[uint32]*Scene),
@@ -193,7 +194,7 @@ func (w *WorldManager) LoadSceneAoi() {
}
func (w *World) IsValidScenePos(sceneId uint32, x, y, z float32) bool {
aoiManager, exist := WORLD_MANAGER.sceneBlockAoiMap[sceneId]
aoiManager, exist := w.worldManager.sceneBlockAoiMap[sceneId]
if !exist {
return false
}
@@ -222,6 +223,7 @@ type EnterSceneContext struct {
// World 世界数据结构
type World struct {
id uint64
worldManager *WorldManager
owner *model.Player
playerMap map[uint32]*model.Player
sceneMap map[uint32]*Scene
@@ -248,6 +250,10 @@ func (w *World) GetId() uint64 {
return w.id
}
func (w *World) GetWorldManager() *WorldManager {
return w.worldManager
}
func (w *World) GetOwner() *model.Player {
return w.owner
}
@@ -369,13 +375,13 @@ func (w *World) AddPlayer(player *model.Player) {
// 将玩家自身当前的队伍角色信息复制到世界的玩家本地队伍
dbTeam := player.GetDbTeam()
team := dbTeam.GetActiveTeam()
if WORLD_MANAGER.IsAiWorld(w) {
if w.worldManager.IsAiWorld(w) {
w.SetPlayerLocalTeam(player, []uint32{dbTeam.GetActiveAvatarId()})
} else {
w.SetPlayerLocalTeam(player, team.GetAvatarIdList())
}
w.SetPlayerActiveAvatarId(player, dbTeam.GetActiveAvatarId())
if WORLD_MANAGER.IsAiWorld(w) {
if w.worldManager.IsAiWorld(w) {
w.AddMultiplayerTeam(player)
} else {
w.UpdateMultiplayerTeam()
@@ -397,7 +403,7 @@ func (w *World) RemovePlayer(player *model.Player) {
delete(w.multiplayerTeam.localTeamMap, player.PlayerId)
delete(w.multiplayerTeam.localTeamEntityMap, player.PlayerId)
delete(w.multiplayerTeam.localActiveAvatarMap, player.PlayerId)
if WORLD_MANAGER.IsAiWorld(w) {
if w.worldManager.IsAiWorld(w) {
w.RemoveMultiplayerTeam(player)
} else {
if player.PlayerId != w.owner.PlayerId {
@@ -810,9 +816,6 @@ func (w *World) AddChat(chatInfo *proto.ChatInfo) {
w.chatMsgList = w.chatMsgList[1:]
}
w.chatMsgList = append(w.chatMsgList, chatInfo)
chatMsg := GAME.ConvChatInfoToChatMsg(chatInfo)
chatMsg.IsDelete = true
go USER_MANAGER.SaveUserChatMsgToDbSync(chatMsg)
}
func (w *World) GetChatList() []*proto.ChatInfo {
@@ -821,7 +824,7 @@ func (w *World) GetChatList() []*proto.ChatInfo {
// ChangeToMultiplayer 转换为多人世界
func (w *World) ChangeToMultiplayer() {
WORLD_MANAGER.multiplayerWorldNum++
w.worldManager.multiplayerWorldNum++
w.multiplayer = true
w.owner.IsInMp = true
}
+27
View File
@@ -88,15 +88,42 @@ func (g *Game) HandlePlayerExpAdd(userId uint32) {
player.PropMap[constant.PLAYER_PROP_PLAYER_LEVEL]++
player.PropMap[constant.PLAYER_PROP_PLAYER_EXP] -= uint32(playerLevelConfig.Exp)
}
// TODO 完善的世界等级机制
player.PropMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL] = g.GetWorldLevelByPlayerLevel(player.PropMap[constant.PLAYER_PROP_PLAYER_LEVEL])
// 更新玩家属性
g.SendMsg(cmd.PlayerPropNotify, player.PlayerId, player.ClientSeq, g.PacketPlayerPropNotify(
player,
constant.PLAYER_PROP_PLAYER_LEVEL,
constant.PLAYER_PROP_PLAYER_EXP,
constant.PLAYER_PROP_PLAYER_WORLD_LEVEL,
))
g.TriggerOpenState(userId)
}
func (g *Game) GetWorldLevelByPlayerLevel(playerLevel uint32) uint32 {
if playerLevel < 20 {
return 0
} else if playerLevel < 25 {
return 1
} else if playerLevel < 30 {
return 2
} else if playerLevel < 35 {
return 3
} else if playerLevel < 40 {
return 4
} else if playerLevel < 45 {
return 5
} else if playerLevel < 50 {
return 6
} else if playerLevel < 55 {
return 7
} else if playerLevel < 60 {
return 8
} else {
return 8
}
}
// TriggerOpenState 触发检测功能开放状态更新
func (g *Game) TriggerOpenState(userId uint32) {
player := USER_MANAGER.GetOnlineUser(userId)
+3
View File
@@ -168,6 +168,9 @@ func (g *Game) PlayerChatReq(player *model.Player, payloadMsg pb.Message) {
return
}
world.AddChat(sendChatInfo)
chatMsg := g.ConvChatInfoToChatMsg(chatInfo)
chatMsg.IsDelete = true
go USER_MANAGER.SaveUserChatMsgToDbSync(chatMsg)
ntf := &proto.PlayerChatNotify{
ChannelId: channelId,
+1 -3
View File
@@ -21,9 +21,7 @@ func (g *Game) PingReq(player *model.Player, payloadMsg pb.Message) {
player.ClientTime = req.ClientTime
now := uint32(time.Now().Unix())
// 客户端与服务器时间相差太过严重
max := math.Max(float64(now), float64(player.ClientTime))
min := math.Min(float64(now), float64(player.ClientTime))
if math.Abs(max-min) > 600.0 {
if math.Abs(math.Max(float64(now), float64(player.ClientTime))-math.Min(float64(now), float64(player.ClientTime))) > 600.0 {
logger.Error("abs of client time and server time above 600s, clientTime: %v, uid: %v", player.ClientTime, player.PlayerId)
}
player.LastKeepaliveTime = now
+4
View File
@@ -53,8 +53,12 @@ func (g *Game) SetPlayerBornDataReq(player *model.Player, payloadMsg pb.Message)
dbWeapon.AddWeapon(player, uint32(avatarDataConfig.InitialWeapon), weaponId)
weapon := dbWeapon.GetWeaponById(weaponId)
dbAvatar.WearWeapon(dbAvatar.MainCharAvatarId, weapon)
// 主角添加进队伍
dbTeam := player.GetDbTeam()
dbTeam.GetActiveTeam().SetAvatarIdList([]uint32{dbAvatar.MainCharAvatarId})
// 主角面板
avatar := dbAvatar.GetAvatarById(dbAvatar.MainCharAvatarId)
dbAvatar.UpdateAvatarFightProp(avatar)
g.AcceptQuest(player, false)
+4 -1
View File
@@ -1271,10 +1271,13 @@ func (g *Game) CreateConfigEntity(scene *Scene, groupId uint32, entityConfig any
switch entityConfig.(type) {
case *gdconf.Monster:
monster := entityConfig.(*gdconf.Monster)
// TODO 怪物等级与世界等级的关联
worldLevel := owner.PropMap[constant.PLAYER_PROP_PLAYER_WORLD_LEVEL]
monsterLevel := uint8(float32(monster.Level) * float32(worldLevel+1) * 0.25)
return scene.CreateEntityMonster(
&model.Vector{X: float64(monster.Pos.X), Y: float64(monster.Pos.Y), Z: float64(monster.Pos.Z)},
&model.Vector{X: float64(monster.Rot.X), Y: float64(monster.Rot.Y), Z: float64(monster.Rot.Z)},
uint32(monster.MonsterId), uint8(monster.Level), uint32(monster.ConfigId), groupId, int(monster.VisionLevel),
uint32(monster.MonsterId), monsterLevel, uint32(monster.ConfigId), groupId, int(monster.VisionLevel),
)
case *gdconf.Npc:
npc := entityConfig.(*gdconf.Npc)
+1 -7
View File
@@ -562,13 +562,7 @@ func (g *Game) UnlockPlayerSceneArea(player *model.Player, sceneId uint32, areaI
// ChangeGameTime 修改游戏时间
func (g *Game) ChangeGameTime(world *World, gameTime uint32) {
world.ChangeGameTime(gameTime)
for _, player := range world.GetAllPlayer() {
playerGameTimeNotify := &proto.PlayerGameTimeNotify{
GameTime: world.GetGameTime(),
Uid: player.PlayerId,
}
g.SendMsg(cmd.PlayerGameTimeNotify, player.PlayerId, player.ClientSeq, playerGameTimeNotify)
}
g.PlayerGameTimeNotify(world)
}
const (