Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sebastian-heinz/Arrowgene.DragonsDogmaOnline
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e3732ee53c623cb55a2cfba2a3b1899cfa6e22cd
Choose a base ref
..
head repository: sebastian-heinz/Arrowgene.DragonsDogmaOnline
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a4c098098ad856f4ee565a624b61c13af9321f7a
Choose a head ref
6 changes: 4 additions & 2 deletions Arrowgene.Ddon.Database/IDatabase.cs
Original file line number Diff line number Diff line change
@@ -410,11 +410,13 @@ uint commonId
List<BazaarExhibition> FetchCharacterBazaarExhibitions(uint characterId);
List<BazaarExhibition> SelectActiveBazaarExhibitionsByItemIdExcludingOwn(
uint itemId,
uint excludedCharacterId
uint excludedCharacterId,
DbConnection? connectionIn = null
);
List<BazaarExhibition> SelectActiveBazaarExhibitionsByItemIdsExcludingOwn(
List<uint> itemIds,
uint excludedCharacterId
uint excludedCharacterId,
DbConnection? connectionIn = null
);

// Rewards
35 changes: 14 additions & 21 deletions Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbBazaarExhibition.cs
Original file line number Diff line number Diff line change
@@ -155,18 +155,13 @@ public List<BazaarExhibition> SelectBazaarExhibitionsByCharacterId(TCon conn, ui

return entities;
}


public List<BazaarExhibition> SelectActiveBazaarExhibitionsByItemIdExcludingOwn(uint itemId, uint excludedCharacterId)
{
using TCon conn = OpenNewConnection();
return SelectActiveBazaarExhibitionsByItemIdExcludingOwn(conn, itemId, excludedCharacterId);
}

public List<BazaarExhibition> SelectActiveBazaarExhibitionsByItemIdExcludingOwn(TCon conn, uint itemId, uint excludedCharacterId)

public List<BazaarExhibition> SelectActiveBazaarExhibitionsByItemIdExcludingOwn(uint itemId, uint excludedCharacterId, DbConnection? connectionIn = null)
{
List<BazaarExhibition> entities = new List<BazaarExhibition>();
ExecuteReader(conn, SqlSelectActiveBazaarExhibitionsByItemIdExcludingOwn,
ExecuteQuerySafe(connectionIn, conn =>
{
ExecuteReader(conn, SqlSelectActiveBazaarExhibitionsByItemIdExcludingOwn,
command =>
{
AddParameter(command, "@item_id", itemId);
@@ -180,24 +175,22 @@ public List<BazaarExhibition> SelectActiveBazaarExhibitionsByItemIdExcludingOwn(
entities.Add(e);
}
});
});

return entities;
}

public List<BazaarExhibition> SelectActiveBazaarExhibitionsByItemIdsExcludingOwn(List<uint> itemIds, uint excludedCharacterId)
{
using TCon conn = OpenNewConnection();
return SelectActiveBazaarExhibitionsByItemIdsExcludingOwn(conn, itemIds, excludedCharacterId);
}

public List<BazaarExhibition> SelectActiveBazaarExhibitionsByItemIdsExcludingOwn(TCon conn, List<uint> itemIds, uint excludedCharacterId)
public List<BazaarExhibition> SelectActiveBazaarExhibitionsByItemIdsExcludingOwn(List<uint> itemIds, uint excludedCharacterId, DbConnection? connectionIn = null)
{
List<BazaarExhibition> entities = new List<BazaarExhibition>();
foreach (uint itemId in itemIds)
ExecuteQuerySafe(connectionIn, conn =>
{
List<BazaarExhibition> exhibitionsForItemId = SelectActiveBazaarExhibitionsByItemIdExcludingOwn(conn, itemId, excludedCharacterId);
entities.AddRange(exhibitionsForItemId);
}
foreach (uint itemId in itemIds)
{
List<BazaarExhibition> exhibitionsForItemId = SelectActiveBazaarExhibitionsByItemIdExcludingOwn(itemId, excludedCharacterId, conn);
entities.AddRange(exhibitionsForItemId);
}
});
return entities;
}

5 changes: 3 additions & 2 deletions Arrowgene.Ddon.GameServer/BazaarManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
using Arrowgene.Ddon.Shared.Entity.Structure;
@@ -194,9 +195,9 @@ public List<BazaarExhibition> GetExhibitionsByCharacter(Character character)
return Server.Database.FetchCharacterBazaarExhibitions(character.CharacterId);
}

public List<BazaarExhibition> GetActiveExhibitionsForItemId(uint itemId, Character filterOutCharacter)
public List<BazaarExhibition> GetActiveExhibitionsForItemId(uint itemId, Character filterOutCharacter, DbConnection? connectionIn = null)
{
return Server.Database.SelectActiveBazaarExhibitionsByItemIdExcludingOwn(itemId, filterOutCharacter.CharacterId);
return Server.Database.SelectActiveBazaarExhibitionsByItemIdExcludingOwn(itemId, filterOutCharacter.CharacterId, connectionIn);
}

public List<BazaarExhibition> GetActiveExhibitionsForItemIds(List<uint> itemIds, Character filterOutCharacter)
30 changes: 15 additions & 15 deletions Arrowgene.Ddon.GameServer/Handler/BazaarGetItemListHandler.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System.Collections.Generic;
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.Network;
using Arrowgene.Logging;
using System.Collections.Generic;

namespace Arrowgene.Ddon.GameServer.Handler
{
@@ -18,24 +17,25 @@ public BazaarGetItemListHandler(DdonGameServer server) : base(server)

public override S2CBazaarGetItemListRes Handle(GameClient client, C2SBazaarGetItemListReq request)
{
// TODO: Optimize to run in one DB connection
S2CBazaarGetItemListRes response = new S2CBazaarGetItemListRes();
foreach (CDataCommonU32 itemId in request.ItemIdList)
{
List<BazaarExhibition> exhibitionsForItemId = Server.BazaarManager.GetActiveExhibitionsForItemId(itemId.Value, client.Character);
if(exhibitionsForItemId.Count > 0)
Server.Database.ExecuteInTransaction(connection => {
foreach (CDataCommonU32 itemId in request.ItemIdList)
{
CDataBazaarItemNumOfExhibitionInfo exhibitionInfo = new CDataBazaarItemNumOfExhibitionInfo();
exhibitionInfo.ItemId = itemId.Value;
foreach (BazaarExhibition exhibition in exhibitionsForItemId)
List<BazaarExhibition> exhibitionsForItemId = Server.BazaarManager.GetActiveExhibitionsForItemId(itemId.Value, client.Character, connection);
if (exhibitionsForItemId.Count > 0)
{
exhibitionInfo.Num += exhibition.Info.ItemInfo.ItemBaseInfo.Num;
CDataBazaarItemNumOfExhibitionInfo exhibitionInfo = new CDataBazaarItemNumOfExhibitionInfo();
exhibitionInfo.ItemId = itemId.Value;
foreach (BazaarExhibition exhibition in exhibitionsForItemId)
{
exhibitionInfo.Num += exhibition.Info.ItemInfo.ItemBaseInfo.Num;
}
response.ItemList.Add(exhibitionInfo);
}
response.ItemList.Add(exhibitionInfo);
}
}
// TODO: response.Unk0
});

return response;
}
}
}
}
13 changes: 6 additions & 7 deletions Arrowgene.Ddon.GameServer/Handler/ShopGetShopGoodsListHandler.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
using Arrowgene.Ddon.Shared.Network;
using Arrowgene.Logging;

namespace Arrowgene.Ddon.GameServer.Handler
{
public class ShopGetShopGoodsListHandler : GameStructurePacketHandler<C2SShopGetShopGoodsListReq>
public class ShopGetShopGoodsListHandler : GameRequestPacketHandler<C2SShopGetShopGoodsListReq, S2CShopGetShopGoodsListRes>
{
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(ShopGetShopGoodsListHandler));

public ShopGetShopGoodsListHandler(DdonGameServer server) : base(server)
{
}

public override void Handle(GameClient client, StructurePacket<C2SShopGetShopGoodsListReq> packet)
public override S2CShopGetShopGoodsListRes Handle(GameClient client, C2SShopGetShopGoodsListReq request)
{
client.Character.LastEnteredShopId = packet.Structure.ShopId;
client.Character.LastEnteredShopId = request.ShopId;

S2CShopGetShopGoodsListRes res = client.InstanceShopManager.GetAssets(packet.Structure.ShopId);
client.Send(res);
return client.InstanceShopManager.GetAssets(request.ShopId);
}

}
}
}
2 changes: 1 addition & 1 deletion Arrowgene.Ddon.Shared/Entity/EntitySerializer.cs
Original file line number Diff line number Diff line change
@@ -204,7 +204,7 @@ static EntitySerializer()
Create(new CDataGetDispelItem.Serializer());
Create(new CDataGetRewardBoxItem.Serializer());
Create(new CDataGoodsParam.Serializer());
Create(new CDataGoodsParamUnk7.Serializer());
Create(new CDataGoodsParamRequirement.Serializer());

Create(new CDataHasRegionBreakReward.Serializer());
Create(new CDataHistoryElement.Serializer());
Original file line number Diff line number Diff line change
@@ -12,29 +12,32 @@ public class S2CBazaarGetItemListRes : ServerResponse
public S2CBazaarGetItemListRes()
{
ItemList = new List<CDataBazaarItemNumOfExhibitionInfo>();
Unk0 = new List<CDataCommonU32>();
IgnoredItemIdList = new List<CDataCommonU32>();
}

public List<CDataBazaarItemNumOfExhibitionInfo> ItemList { get; set; }
public List<CDataCommonU32> Unk0 { get; set; }
/// <summary>
/// List of ItemIDs that are removed from the search result.
/// </summary>
public List<CDataCommonU32> IgnoredItemIdList { get; set; }

public class Serializer : PacketEntitySerializer<S2CBazaarGetItemListRes>
{
public override void Write(IBuffer buffer, S2CBazaarGetItemListRes obj)
{
WriteServerResponse(buffer, obj);
WriteEntityList<CDataBazaarItemNumOfExhibitionInfo>(buffer, obj.ItemList);
WriteEntityList<CDataCommonU32>(buffer, obj.Unk0);
WriteEntityList<CDataCommonU32>(buffer, obj.IgnoredItemIdList);
}

public override S2CBazaarGetItemListRes Read(IBuffer buffer)
{
S2CBazaarGetItemListRes obj = new S2CBazaarGetItemListRes();
ReadServerResponse(buffer, obj);
obj.ItemList = ReadEntityList<CDataBazaarItemNumOfExhibitionInfo>(buffer);
obj.Unk0 = ReadEntityList<CDataCommonU32>(buffer);
obj.IgnoredItemIdList = ReadEntityList<CDataCommonU32>(buffer);
return obj;
}
}
}
}
}
36 changes: 18 additions & 18 deletions Arrowgene.Ddon.Shared/Entity/Structure/CDataGoodsParam.cs
Original file line number Diff line number Diff line change
@@ -9,18 +9,18 @@ namespace Arrowgene.Ddon.Shared.Entity.Structure
public class CDataGoodsParam : ICloneable
{
public CDataGoodsParam() {
Unk7 = new List<CDataGoodsParamUnk7>();
Requirements = new();
}

// PS4 fields: Index, Price, Stock, MaxStock, RequireFavorite, ItemId (all uint)
public uint Index { get; set; } // 0 based
public uint ItemId { get; set; }
public uint Price { get; set; }
public byte Stock { get; set; } // 255 for unlimited
public bool Unk4{ get; set; }
public ulong Unk5 { get; set; }
public ulong Unk6 { get; set; }
public List<CDataGoodsParamUnk7> Unk7 { get; set; } // Requirements?
public bool HideIfReqsUnmet { get; set; }
public DateTimeOffset SalesPeriodStart { get; set; }
public DateTimeOffset SalesPeriodEnd { get; set; }
public List<CDataGoodsParamRequirement> Requirements { get; set; } // Requirements?

public object Clone()
{
@@ -30,10 +30,10 @@ public object Clone()
ItemId = this.ItemId,
Price = this.Price,
Stock = this.Stock,
Unk4 = this.Unk4,
Unk5 = this.Unk5,
Unk6 = this.Unk6,
Unk7 = this.Unk7.Select(gpu7 => (CDataGoodsParamUnk7) gpu7.Clone()).ToList()
HideIfReqsUnmet = this.HideIfReqsUnmet,
SalesPeriodStart = this.SalesPeriodStart,
SalesPeriodEnd = this.SalesPeriodEnd,
Requirements = this.Requirements.Select(gpu7 => (CDataGoodsParamRequirement) gpu7.Clone()).ToList()
};
}

@@ -45,10 +45,10 @@ public override void Write(IBuffer buffer, CDataGoodsParam obj)
WriteUInt32(buffer, obj.ItemId);
WriteUInt32(buffer, obj.Price);
WriteByte(buffer, obj.Stock);
WriteBool(buffer, obj.Unk4);
WriteUInt64(buffer, obj.Unk5);
WriteUInt64(buffer, obj.Unk6);
WriteEntityList<CDataGoodsParamUnk7>(buffer, obj.Unk7);
WriteBool(buffer, obj.HideIfReqsUnmet);
WriteInt64(buffer, obj.SalesPeriodStart.ToUnixTimeSeconds());
WriteInt64(buffer, obj.SalesPeriodEnd.ToUnixTimeSeconds());
WriteEntityList<CDataGoodsParamRequirement>(buffer, obj.Requirements);
}

public override CDataGoodsParam Read(IBuffer buffer)
@@ -58,12 +58,12 @@ public override CDataGoodsParam Read(IBuffer buffer)
obj.ItemId = ReadUInt32(buffer);
obj.Price = ReadUInt32(buffer);
obj.Stock = ReadByte(buffer);
obj.Unk4 = ReadBool(buffer);
obj.Unk5 = ReadUInt64(buffer);
obj.Unk6 = ReadUInt64(buffer);
obj.Unk7 = ReadEntityList<CDataGoodsParamUnk7>(buffer);
obj.HideIfReqsUnmet = ReadBool(buffer);
obj.SalesPeriodStart = DateTimeOffset.FromUnixTimeSeconds(ReadInt64(buffer));
obj.SalesPeriodEnd = DateTimeOffset.FromUnixTimeSeconds(ReadInt64(buffer));
obj.Requirements = ReadEntityList<CDataGoodsParamRequirement>(buffer);
return obj;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using System;
using Arrowgene.Buffers;
using Arrowgene.Ddon.Shared.Model;

namespace Arrowgene.Ddon.Shared.Entity.Structure
{
public class CDataGoodsParamRequirement : ICloneable
{
public uint Index { get; set; } // Maybe?
public ShopItemUnlockCondition Condition { get; set; }
public bool IgnoreRequirements { get; set; }
public uint Progress { get; set; }
public bool HideRequirementDetails { get; set; }
public uint Param1 { get; set; }
public uint Param2 { get; set; }
public uint Param3 { get; set; }
public uint Param4 { get; set; }
public uint Param5 { get; set; }
public DateTimeOffset SalesPeriodStart { get; set; }
public DateTimeOffset SalesPeriodEnd { get; set; }

public object Clone()
{
return new CDataGoodsParamRequirement()
{
Index = this.Index,
Condition = this.Condition,
IgnoreRequirements = this.IgnoreRequirements,
Progress = this.Progress,
HideRequirementDetails = this.HideRequirementDetails,
Param1 = this.Param1,
Param2 = this.Param2,
Param3 = this.Param3,
Param4 = this.Param4,
Param5 = this.Param5,
SalesPeriodStart = this.SalesPeriodStart,
SalesPeriodEnd = this.SalesPeriodEnd
};
}

public class Serializer : EntitySerializer<CDataGoodsParamRequirement>
{
public override void Write(IBuffer buffer, CDataGoodsParamRequirement obj)
{
WriteUInt32(buffer, obj.Index);
WriteUInt32(buffer, (uint)obj.Condition);
WriteBool(buffer, obj.IgnoreRequirements);
WriteUInt32(buffer, obj.Progress);
WriteBool(buffer, obj.HideRequirementDetails);
WriteUInt32(buffer, obj.Param1);
WriteUInt32(buffer, obj.Param2);
WriteUInt32(buffer, obj.Param3);
WriteUInt32(buffer, obj.Param4);
WriteUInt32(buffer, obj.Param5);
WriteInt64(buffer, obj.SalesPeriodStart.ToUnixTimeSeconds());
WriteInt64(buffer, obj.SalesPeriodEnd.ToUnixTimeSeconds());
}

public override CDataGoodsParamRequirement Read(IBuffer buffer)
{
CDataGoodsParamRequirement obj = new CDataGoodsParamRequirement();
obj.Index = ReadUInt32(buffer);
obj.Condition = (ShopItemUnlockCondition)ReadUInt32(buffer);
obj.IgnoreRequirements = ReadBool(buffer);
obj.Progress = ReadUInt32(buffer);
obj.HideRequirementDetails = ReadBool(buffer);
obj.Param1 = ReadUInt32(buffer);
obj.Param2 = ReadUInt32(buffer);
obj.Param3 = ReadUInt32(buffer);
obj.Param4 = ReadUInt32(buffer);
obj.Param5 = ReadUInt32(buffer);
obj.SalesPeriodStart = DateTimeOffset.FromUnixTimeSeconds(ReadInt64(buffer));
obj.SalesPeriodEnd = DateTimeOffset.FromUnixTimeSeconds(ReadInt64(buffer));
return obj;
}
}
}
}
Loading