Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions Arrowgene.Ddon.GameServer/Characters/CharacterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,7 @@ public Character SelectCharacter(uint characterId, bool fetchPawns = true, DbCon

character.FavoritedPawnIds = Server.Database.GetPawnFavorites(character.CharacterId, connectionIn);

character.ExtendedParams = Server.Database.SelectOrbGainExtendParam(character.CommonId, connectionIn);
if (character.ExtendedParams == null)
{
// Old DB is in use and new table not populated with required data for character
Logger.Error($"Character: AccountId={character.AccountId}, CharacterId={character.CharacterId}, CommonId={character.CommonId} is missing table entry in 'ddon_orb_gain_extend_param'.");
return null;
}

character.ExtendedParams = Server.OrbUnlockManager.GetBaseExtendParam(character);
character.ReleasedExtendedJobParams = Server.JobOrbUnlockManager.GetReleasedElements(character, connectionIn);
Server.JobOrbUnlockManager.EvaluateJobOrbTreeUnlocks(character);

Expand Down Expand Up @@ -324,13 +317,8 @@ private void SelectPawns(Character character, DbConnection? connectionIn = null)
Pawn pawn = character.Pawns[i];
pawn.Server = character.Server;
pawn.Equipment = character.Storage.GetPawnEquipment(i);
pawn.ExtendedParams = Server.Database.SelectOrbGainExtendParam(pawn.CommonId, connectionIn);
pawn.ExtendedParams = Server.OrbUnlockManager.GetBaseExtendParam(pawn);
pawn.EmblemStatList = Server.JobEmblemManager.GetEmblemStatsForCurrentJob(character, pawn.Job);
if (pawn.ExtendedParams == null)
{
// Old DB is in use and new table not populated with required data for character
Logger.Error($"Character: AccountId={character.AccountId}, CharacterId={character.ContentCharacterId}, CommonId={character.CommonId}, PawnCommonId={pawn.CommonId} is missing table entry in 'ddon_orb_gain_extend_param'.");
}
if (pawn.PawnType != PawnType.Main)
{
Logger.Error($"Character: AccountId={character.AccountId}, CharacterId={character.ContentCharacterId}, CommonId={character.CommonId}, PawnCommonId={pawn.CommonId} has invalid pawn type; locally setting pawn type back to Main.");
Expand Down
241 changes: 151 additions & 90 deletions Arrowgene.Ddon.GameServer/Characters/OrbUnlockManager.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Arrowgene.Ddon.GameServer/Characters/QuestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private QuestManager()
/// </summary>
private static readonly HashSet<uint> KnownBadQuestScheduleIds = new HashSet<uint>()
{
25077, 43645, 43646, 47734, 47735, 47736, 47737, 47738, 47739, 49692, 77644, 151381, 208640, 233576, 259411, 259412, 287378, 315624
0, 25077, 43645, 43646, 47734, 47735, 47736, 47737, 47738, 47739, 49692, 77644, 151381, 208640, 233576, 259411, 259412, 287378, 315624
};

private static void AddQuestToCategory(Quest quest)
Expand Down
2 changes: 1 addition & 1 deletion Arrowgene.Ddon.GameServer/DdonGameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ private void LoadPacketHandler()
AddHandler(new QuestGetEndContentsGroupHandler(this));
AddHandler(new QuestGetEndContentsRecruitListHandler(this));
AddHandler(new QuestGetLevelBonusListHandler(this));
AddHandler(new QuestGetLightQuestList(this));
AddHandler(new QuestGetLightQuestListHandler(this));
AddHandler(new QuestGetLotQuestListHandler(this));
AddHandler(new QuestGetMainQuestListHandler(this));
AddHandler(new QuestGetMobHuntQuestListHandler(this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,13 @@ public override S2CCharacterSwitchGameModeRes Handle(GameClient client, C2SChara
VisualEquipItemList = client.Character.Equipment.AsCDataEquipItemInfo(EquipType.Visual),
});

List<StorageType> swappedStorages = [.. ItemManager.ItemBagStorageTypes, StorageType.StorageBoxNormal, StorageType.StorageBoxExpansion];
client.Send(new S2CItemSortGetItemSortdataBinNtc()
{
SortData = [.. ItemManager.ItemBagStorageTypes.Select(x => new CDataItemSort()
SortData = [.. swappedStorages.Select(x => new CDataItemSort()
{
StorageType = x,
Bin = client.Character.Storage.GetStorage(x).SortData
Bin = client.Character.Storage.GetStorage(x).SortData,
})]
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public override S2CConnectionLoginRes Handle(GameClient client, C2SConnectionLog
#if DEBUG
if (client.Identity.Contains("127.0.0.1"))
{
client.Account.State = AccountStateType.GameMaster;
client.Account.State = AccountStateType.Admin;
Comment thread
pacampbell marked this conversation as resolved.
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public override S2CConnectionMoveInServerRes Handle(GameClient client, C2SConnec
#if DEBUG
if (client.Identity.Contains("127.0.0.1"))
{
client.Account.State = AccountStateType.GameMaster;
client.Account.State = AccountStateType.Admin;
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override S2CCraftRecipeGetCraftRecipeDesignateRes Handle(GameClient clien
var allRecipes = Server.AssetRepository.CraftingRecipesAsset
.Where(x => x.Category == request.Category)
.SelectMany(x => x.RecipeList)
.Where(x => x.UnlockID > 0);
.Where(x => x.UnlockID > 0 && !x.IsHide);

foreach ( var item in request.ItemList)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ public override S2CInstanceGetGatheringItemListRes Handle(GameClient client, C2S
client.Enqueue(ntc, queue);
}
}

uint stageNo = StageManager.ConvertIdToStageNo(request.LayoutId.AsStageLayoutId());
if (Server.AssetRepository.GatheringSpotInfoAsset.GatheringInfoMap.TryGetValue(stageNo, out var spots)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there not a better way to do this? This looks awful.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could adjust the GatheringInfoAsset to make it less awful, but I don't think it's too bad. It's a nested dictionary, it's gonna be messy to check safely. If you change it too much you're gonna break scripts because it's exposed to default_gathering.csx.

&& spots.TryGetValue((request.LayoutId.AsStageLayoutId().GroupId, request.PosId), out var spotInfo))
{
if (spotInfo.GatheringType is GatheringType.OM_GATHER_GRASS
or GatheringType.OM_GATHER_FLOWER
or GatheringType.OM_GATHER_MUSHROOM)
{
queue.AddRange(Server.AchievementManager.HandleCollect(client, AchievementCollectParam.Herb, connection));
}
}
});

queue.Send();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Arrowgene.Ddon.Database.Model;
using Arrowgene.Ddon.GameServer.Characters;
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Server.Network;
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
using Arrowgene.Ddon.Shared.Entity.Structure;
using Arrowgene.Ddon.Shared.Model;
using Arrowgene.Logging;
using System;
using System.Collections.Generic;
using System.Xml.Linq;

Expand All @@ -24,8 +26,14 @@ public override PacketQueue Handle(GameClient client, C2SPartnerPawnPresentForPa
var packets = new PacketQueue();

List<CDataItemUpdateResult> itemUpdateResults = new List<CDataItemUpdateResult>();

Server.Database.ExecuteInTransaction(connection =>
{
if (Server.Database.HasPartnerPawnLastAffectionIncreaseRecord(client.Character.CharacterId, client.Character.PartnerPawnId, PartnerPawnAffectionAction.Gift, connection))
{
throw new ResponseErrorException(ErrorCode.ERROR_CODE_PAWN_ALREADY_GIFTED);
}

foreach (var item in request.ItemUIDList)
{
uint itemId = client.Character.Storage.FindItemByUIdInStorage(ItemManager.AllItemStorages, item.ItemUID)?.Item2.Item2.ItemId
Expand Down
9 changes: 6 additions & 3 deletions Arrowgene.Ddon.GameServer/Handler/PawnPawnLostHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
using Arrowgene.Ddon.Shared.Model;
using Arrowgene.Logging;
using System;

namespace Arrowgene.Ddon.GameServer.Handler
{
Expand All @@ -20,18 +21,20 @@ public override PacketQueue Handle(GameClient client, C2SPawnPawnLostReq request

Pawn pawn = client.Character.PawnById(request.PawnId, PawnType.Main);

bool isLost = Random.Shared.NextDouble() > (client.Character.ExtendedParams.MainPawnLostRate / 100.0);

client.Enqueue(new S2CPawnPawnLostRes()
{
PawnId = pawn.PawnId,
PawnName = pawn.Name,
IsLost = true
IsLost = isLost
}, queue);

S2CPawnPawnLostNtc ntc = new S2CPawnPawnLostNtc()
{
PawnId = pawn.PawnId,
PawnName = pawn.Name,
IsLost = true
IsLost = isLost
};
client.Party.EnqueueToAllExcept(ntc, queue, client);

Expand All @@ -48,7 +51,7 @@ public override PacketQueue Handle(GameClient client, C2SPawnPawnLostReq request
}, queue);
}

pawn.PawnState = PawnState.Lost;
pawn.PawnState = isLost ? PawnState.Lost : PawnState.None;
Server.Database.UpdatePawnBaseInfo(pawn);

return queue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Arrowgene.Ddon.GameServer.Chat.Command;
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
using Arrowgene.Ddon.Shared.Entity.Structure;
Expand Down Expand Up @@ -39,7 +40,9 @@ public override S2CProfileSetMessageSetRes Handle(GameClient client, C2SProfileS
var newMsg = newSet.CharacterMessageList[j];

// Restore the weird chat bubble thing that you can't normally type.
if (newMsg.Message.Length > 0 && StringInfo.GetNextTextElement(newMsg.Message) != ChatBubblePrefix)
if (newMsg.Message.Length > 0
&& !newMsg.Message.StartsWith(ChatCommandHandler.ChatCommandStart)
&& StringInfo.GetNextTextElement(newMsg.Message) != ChatBubblePrefix)
{
newMsg.Message = $"{ChatBubblePrefix}{newMsg.Message}";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Arrowgene.Ddon.GameServer.Characters;
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
using Arrowgene.Ddon.Shared.Entity.Structure;
using Arrowgene.Ddon.Shared.Model;
using Arrowgene.Ddon.Shared.Model.Quest;
using Arrowgene.Logging;
Expand All @@ -11,11 +10,11 @@

namespace Arrowgene.Ddon.GameServer.Handler
{
public class QuestGetLightQuestList : GameRequestPacketHandler<C2SQuestGetLightQuestListReq, S2CQuestGetLightQuestListRes>
public class QuestGetLightQuestListHandler : GameRequestPacketHandler<C2SQuestGetLightQuestListReq, S2CQuestGetLightQuestListRes>
{
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(QuestGetLightQuestList));
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(QuestGetLightQuestListHandler));

public QuestGetLightQuestList(DdonGameServer server) : base(server)
public QuestGetLightQuestListHandler(DdonGameServer server) : base(server)
{
}

Expand Down Expand Up @@ -43,7 +42,7 @@ public override S2CQuestGetLightQuestListRes Handle(GameClient client, C2SQuestG

if (QuestManager.IsBoardQuest(questScheduleId)
&& client.Character.CompletedQuests.GetValueOrDefault(lightQuest.QuestId)?.ClearCount
>= Server.GameSettings.GameServerSettings.LightQuestGenerationAttemptsPerQuest)
>= Server.GameSettings.GameServerSettings.LightQuestRepeatsPerDay)
{
continue;
}
Expand Down
5 changes: 5 additions & 0 deletions Arrowgene.Ddon.GameServer/Tasks/SchedulerTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,10 @@ public virtual bool IsEnabled(DdonGameServer server)
/// </summary>
/// <returns></returns>
public abstract string TaskTypeName();

public virtual string TaskName()
{
return Type.ToString();
}
}
}
27 changes: 27 additions & 0 deletions Arrowgene.Ddon.Scripts/scripts/chat_commands/affection.csx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Arrowgene.Ddon.GameServer.Handler;
using System.Collections.Generic;

public class ChatCommand : IChatCommand
{
public override AccountStateType AccountState => AccountStateType.User;
public override string CommandName => "affection";
public override string HelpText => "usage: `/affection` - Check pawn affection.";

public override void Execute(DdonGameServer server, string[] command, GameClient client, ChatMessage message, List<ChatResponse> responses)
{
List<string> strings = [];
foreach (var pawn in client.Character.Pawns)
{
int level = (int)pawn.PartnerPawnData.CalculateLikability();

strings.Add($"{pawn.Name}{(client.Character.PartnerPawnId == pawn.PawnId ? " *" : " ")}");
strings.Add($" Affection: {level} / {PartnerPawnData.MaxLevel}");
strings.Add($" Progress: {pawn.PartnerPawnData.CalculateLikabilityXP()} / {PartnerPawnData.LikabilityCurve.ElementAtOrDefault(level+1)}");
strings.Add($" ");
}

client.Send(new S2CConnectionInformationNtc(strings));
}
}

return new ChatCommand();
2 changes: 1 addition & 1 deletion Arrowgene.Ddon.Scripts/scripts/chat_commands/schedule.csx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ChatCommand : IChatCommand

TimeSpan ts = TimeSpan.FromSeconds(server.ScheduleManager.TimeToNextTaskUpdate(task.Type));
var formattedTime = string.Format("{0:D1}d:{1:D2}h:{2:D2}m:{3:D2}s", ts.Days, ts.Hours, ts.Minutes, ts.Seconds);
var line = $"{task.TaskTypeName()}: {task.Type} ({(uint)task.Type})\n {formattedTime}";
var line = $"{task.TaskTypeName()}: {task.TaskName()} ({(uint)task.Type})\n {formattedTime}";
lines.Add(line);
}

Expand Down
18 changes: 18 additions & 0 deletions Arrowgene.Ddon.Scripts/scripts/chat_commands/wallet.csx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Arrowgene.Ddon.GameServer.Handler;
using System.Collections.Generic;
using System.Globalization;

public class ChatCommand : IChatCommand
{
public override AccountStateType AccountState => AccountStateType.User;
public override string CommandName => "wallet";
public override string HelpText => "usage: `/wallet` - Check hidden wallet amounts.";

public override void Execute(DdonGameServer server, string[] command, GameClient client, ChatMessage message, List<ChatResponse> responses)
{
S2CConnectionInformationNtc ntc = new(client.Character.WalletPointList.Select(x => $"{x.Type} : {x.Value.ToString("N0", CultureInfo.InvariantCulture)} / {server.GameSettings.GameServerSettings.WalletLimits.GetValueOrDefault(x.Type).ToString("N0", CultureInfo.InvariantCulture)}"));
client.Send(ntc);
}
}

return new ChatCommand();
Loading
Loading