mirror of
https://github.com/EggLinks/DanhengServer-OpenSource.git
synced 2026-01-03 04:36:03 +08:00
Fix A Bug
- fix when entering a story line and re login, player will get 1001_1
This commit is contained in:
@@ -13,6 +13,7 @@ namespace EggLink.DanhengServer.Data.Excel
|
||||
public class StoryLineExcel : ExcelResource
|
||||
{
|
||||
public int StoryLineID { get; set; }
|
||||
public StoryLineCondition BeginCondition { get; set; } = new();
|
||||
public StoryLineCondition EndCondition { get; set; } = new();
|
||||
public int InitEntranceID { get; set; }
|
||||
public int InitGroupID { get; set; }
|
||||
|
||||
@@ -55,19 +55,19 @@ namespace EggLink.DanhengServer.Game.Lineup
|
||||
var avatarList = new List<AvatarSceneInfo>();
|
||||
foreach (var avatar in lineup.BaseAvatars!)
|
||||
{
|
||||
Proto.AvatarType avatarType = Proto.AvatarType.AvatarFormalType;
|
||||
AvatarType avatarType = AvatarType.AvatarFormalType;
|
||||
Database.Avatar.AvatarInfo? avatarInfo = null;
|
||||
if (avatar.SpecialAvatarId > 0)
|
||||
{
|
||||
GameData.SpecialAvatarData.TryGetValue(avatar.SpecialAvatarId, out var specialAvatar);
|
||||
if (specialAvatar == null) continue;
|
||||
avatarType = Proto.AvatarType.AvatarTrialType;
|
||||
avatarType = AvatarType.AvatarTrialType;
|
||||
avatarInfo = specialAvatar.ToAvatarData(Player.Uid);
|
||||
}
|
||||
else if (avatar.AssistUid > 0)
|
||||
{
|
||||
var avatarStorage = DatabaseHelper.Instance?.GetInstance<Database.Avatar.AvatarData>(avatar.AssistUid);
|
||||
avatarType = Proto.AvatarType.AvatarAssistType;
|
||||
avatarType = AvatarType.AvatarAssistType;
|
||||
if (avatarStorage == null) continue;
|
||||
foreach (var avatarData in avatarStorage.Avatars!)
|
||||
{
|
||||
@@ -191,13 +191,30 @@ namespace EggLink.DanhengServer.Game.Lineup
|
||||
return;
|
||||
}
|
||||
LineupData.Lineups.TryGetValue(lineupIndex, out LineupInfo? lineup);
|
||||
|
||||
if (lineup == null)
|
||||
{
|
||||
var baseAvatarId = avatarId;
|
||||
var specialAvatarId = avatarId * 10 + Player.Data.WorldLevel;
|
||||
GameData.SpecialAvatarData.TryGetValue(specialAvatarId, out var specialAvatar);
|
||||
if (specialAvatar != null)
|
||||
{
|
||||
baseAvatarId = specialAvatar.AvatarID;
|
||||
}
|
||||
else
|
||||
{
|
||||
specialAvatarId = 0;
|
||||
if (baseAvatarId > 8000)
|
||||
{
|
||||
baseAvatarId = 8001;
|
||||
}
|
||||
}
|
||||
|
||||
lineup = new()
|
||||
{
|
||||
Name = "",
|
||||
LineupType = 0,
|
||||
BaseAvatars = [new() { BaseAvatarId = avatarId }],
|
||||
BaseAvatars = [new() { BaseAvatarId = baseAvatarId, SpecialAvatarId = specialAvatarId }],
|
||||
LineupData = LineupData,
|
||||
AvatarData = Player.AvatarManager!.AvatarData,
|
||||
};
|
||||
@@ -208,10 +225,27 @@ namespace EggLink.DanhengServer.Game.Lineup
|
||||
{
|
||||
return;
|
||||
}
|
||||
lineup.BaseAvatars?.Add(new() { BaseAvatarId = avatarId });
|
||||
|
||||
var baseAvatarId = avatarId;
|
||||
var specialAvatarId = avatarId * 10 + Player.Data.WorldLevel;
|
||||
GameData.SpecialAvatarData.TryGetValue(specialAvatarId, out var specialAvatar);
|
||||
if (specialAvatar != null)
|
||||
{
|
||||
baseAvatarId = specialAvatar.AvatarID;
|
||||
}
|
||||
else
|
||||
{
|
||||
specialAvatarId = 0;
|
||||
if (baseAvatarId > 8000)
|
||||
{
|
||||
baseAvatarId = 8001;
|
||||
}
|
||||
}
|
||||
|
||||
lineup.BaseAvatars?.Add(new() { BaseAvatarId = baseAvatarId, SpecialAvatarId = specialAvatarId });
|
||||
LineupData.Lineups[lineupIndex] = lineup;
|
||||
}
|
||||
DatabaseHelper.Instance?.UpdateInstance(LineupData);
|
||||
|
||||
if (sendPacket)
|
||||
{
|
||||
if (lineupIndex == LineupData.GetCurLineupIndex())
|
||||
@@ -333,7 +367,7 @@ namespace EggLink.DanhengServer.Game.Lineup
|
||||
{
|
||||
AddAvatar(index, avatar, false);
|
||||
}
|
||||
DatabaseHelper.Instance?.UpdateInstance(LineupData);
|
||||
|
||||
if (index == LineupData.GetCurLineupIndex())
|
||||
{
|
||||
Player.SceneInstance?.SyncLineup();
|
||||
@@ -369,7 +403,7 @@ namespace EggLink.DanhengServer.Game.Lineup
|
||||
{
|
||||
AddAvatar(index, (int)avatar.Id, false);
|
||||
}
|
||||
DatabaseHelper.Instance?.UpdateInstance(LineupData);
|
||||
|
||||
if (index == LineupData.GetCurLineupIndex())
|
||||
{
|
||||
Player.SceneInstance?.SyncLineup();
|
||||
|
||||
@@ -361,6 +361,7 @@ namespace EggLink.DanhengServer.Game.Mission
|
||||
|
||||
// handle reward
|
||||
HandleSubMissionReward(missionId);
|
||||
Player.StoryLineManager!.CheckIfEnterStoryLine();
|
||||
//Player.StoryLineManager!.CheckIfFinishStoryLine();
|
||||
|
||||
PluginEvent.InvokeOnPlayerFinishSubMission(Player, missionId);
|
||||
|
||||
@@ -20,11 +20,28 @@ namespace EggLink.DanhengServer.GameServer.Game.Mission
|
||||
public StoryLineManager(PlayerInstance player) : base(player)
|
||||
{
|
||||
StoryLineData = DatabaseHelper.Instance!.GetInstanceOrCreateNew<StoryLineData>(player.Uid);
|
||||
OnLogin();
|
||||
}
|
||||
|
||||
public void CheckIfEnterStoryLine()
|
||||
{
|
||||
if (StoryLineData.CurStoryLineId != 0) return;
|
||||
|
||||
foreach (var storyLine in GameData.StoryLineData.Values)
|
||||
{
|
||||
if (Player.MissionManager!.GetSubMissionStatus(storyLine.BeginCondition.Param) == Enums.MissionPhaseEnum.Finish)
|
||||
{
|
||||
InitStoryLine(storyLine.StoryLineID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void InitStoryLine(int storyLineId, int entryId = 0, int anchorGroupId = 0, int anchorId = 0)
|
||||
{
|
||||
if (StoryLineData.CurStoryLineId != 0)
|
||||
{
|
||||
FinishStoryLine(entryId, anchorGroupId, anchorId, false);
|
||||
}
|
||||
GameData.StoryLineData.TryGetValue(storyLineId, out var storyExcel);
|
||||
GameData.StroyLineTrialAvatarDataData.TryGetValue(storyLineId, out var storyAvatarExcel);
|
||||
if (storyExcel == null || storyAvatarExcel == null) return;
|
||||
@@ -58,6 +75,7 @@ namespace EggLink.DanhengServer.GameServer.Game.Mission
|
||||
StoryLineData.RunningStoryLines[storyExcel.StoryLineID] = record;
|
||||
StoryLineData.CurStoryLineId = storyExcel.StoryLineID;
|
||||
Player.SendPacket(new PacketStoryLineInfoScNotify(Player));
|
||||
Player.SendPacket(new PacketChangeStoryLineFinishScNotify(storyExcel.StoryLineID));
|
||||
}
|
||||
|
||||
public void EnterStoryLine(int storyLineId)
|
||||
@@ -78,6 +96,7 @@ namespace EggLink.DanhengServer.GameServer.Game.Mission
|
||||
|
||||
StoryLineData.CurStoryLineId = lineInfo.StoryLineId;
|
||||
Player.SendPacket(new PacketStoryLineInfoScNotify(Player));
|
||||
Player.SendPacket(new PacketChangeStoryLineFinishScNotify(StoryLineData.CurStoryLineId));
|
||||
}
|
||||
|
||||
public void LeaveStoryLine()
|
||||
@@ -113,6 +132,7 @@ namespace EggLink.DanhengServer.GameServer.Game.Mission
|
||||
StoryLineData.OldRot = new();
|
||||
|
||||
Player.SendPacket(new PacketStoryLineInfoScNotify(Player));
|
||||
Player.SendPacket(new PacketChangeStoryLineFinishScNotify(0));
|
||||
}
|
||||
|
||||
public void CheckIfFinishStoryLine() // seems like a story line end with another ChangeStoryLine finish action that Params[0] = 0
|
||||
@@ -127,16 +147,19 @@ namespace EggLink.DanhengServer.GameServer.Game.Mission
|
||||
}
|
||||
}
|
||||
|
||||
public void FinishStoryLine(int entryId = 0, int anchorGroupId = 0, int anchorId = 0)
|
||||
public void FinishStoryLine(int entryId = 0, int anchorGroupId = 0, int anchorId = 0, bool tp = true)
|
||||
{
|
||||
if (StoryLineData.CurStoryLineId == 0) return;
|
||||
if (entryId > 0)
|
||||
if (tp)
|
||||
{
|
||||
Player.EnterMissionScene(entryId, anchorGroupId, anchorId, true, EnterSceneReasonStatus.EnterSceneReasonChangeStoryline);
|
||||
}
|
||||
else
|
||||
{
|
||||
Player.LoadScene(StoryLineData.OldPlaneId, StoryLineData.OldFloorId, StoryLineData.OldEntryId, StoryLineData.OldPos, StoryLineData.OldRot, true, EnterSceneReasonStatus.EnterSceneReasonChangeStoryline);
|
||||
if (entryId > 0)
|
||||
{
|
||||
Player.EnterMissionScene(entryId, anchorGroupId, anchorId, true, EnterSceneReasonStatus.EnterSceneReasonChangeStoryline);
|
||||
}
|
||||
else
|
||||
{
|
||||
Player.LoadScene(StoryLineData.OldPlaneId, StoryLineData.OldFloorId, StoryLineData.OldEntryId, StoryLineData.OldPos, StoryLineData.OldRot, true, EnterSceneReasonStatus.EnterSceneReasonChangeStoryline);
|
||||
}
|
||||
}
|
||||
|
||||
// delete old & reset
|
||||
@@ -150,6 +173,7 @@ namespace EggLink.DanhengServer.GameServer.Game.Mission
|
||||
StoryLineData.OldRot = new();
|
||||
|
||||
Player.SendPacket(new PacketStoryLineInfoScNotify(Player));
|
||||
Player.SendPacket(new PacketChangeStoryLineFinishScNotify(0));
|
||||
}
|
||||
|
||||
public void OnLogin()
|
||||
@@ -157,6 +181,7 @@ namespace EggLink.DanhengServer.GameServer.Game.Mission
|
||||
if (StoryLineData.CurStoryLineId == 0) return;
|
||||
|
||||
Player.SendPacket(new PacketStoryLineInfoScNotify(Player));
|
||||
Player.SendPacket(new PacketChangeStoryLineFinishScNotify(StoryLineData.CurStoryLineId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +148,7 @@ namespace EggLink.DanhengServer.Game.Player
|
||||
DatabaseHelper.Instance?.UpdateInstance(Data);
|
||||
|
||||
ChallengeManager.ResurrectInstance();
|
||||
StoryLineManager.OnLogin();
|
||||
LoadScene(Data.PlaneId, Data.FloorId, Data.EntryId, Data.Pos!, Data.Rot!, false);
|
||||
if (SceneInstance == null)
|
||||
{
|
||||
@@ -183,6 +184,15 @@ namespace EggLink.DanhengServer.Game.Player
|
||||
{
|
||||
avatar.SpecialAvatarId = special.GetId();
|
||||
avatar.BaseAvatarId = special.AvatarID;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameData.SpecialAvatarData.TryGetValue(avatar.BaseAvatarId * 10 + Data.WorldLevel, out special);
|
||||
if (special != null)
|
||||
{
|
||||
avatar.SpecialAvatarId = special.GetId();
|
||||
avatar.BaseAvatarId = special.AvatarID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -535,6 +545,7 @@ namespace EggLink.DanhengServer.Game.Player
|
||||
// TODO: Sanify check
|
||||
Data.Pos = pos;
|
||||
Data.Rot = rot;
|
||||
var sendMove = true;
|
||||
SceneInstance instance = new(this, plane, floorId, entryId);
|
||||
if (planeId != Data.PlaneId || floorId != Data.FloorId || entryId != Data.EntryId)
|
||||
{
|
||||
@@ -542,15 +553,23 @@ namespace EggLink.DanhengServer.Game.Player
|
||||
Data.FloorId = floorId;
|
||||
Data.EntryId = entryId;
|
||||
}
|
||||
else
|
||||
{
|
||||
sendMove = false;
|
||||
}
|
||||
SceneInstance = instance;
|
||||
|
||||
MissionManager?.OnPlayerChangeScene();
|
||||
|
||||
Connection?.SendPacket(CmdIds.SyncServerSceneChangeNotify);
|
||||
if (sendPacket)
|
||||
if (sendPacket && sendMove)
|
||||
{
|
||||
SendPacket(new PacketEnterSceneByServerScNotify(instance, reason));
|
||||
}
|
||||
else if (!sendMove)
|
||||
{
|
||||
SendPacket(new PacketSceneEntityMoveScNotify(this));
|
||||
}
|
||||
|
||||
MissionManager?.HandleFinishType(MissionFinishTypeEnum.EnterFloor);
|
||||
MissionManager?.HandleFinishType(MissionFinishTypeEnum.NotInFloor);
|
||||
|
||||
Reference in New Issue
Block a user