diff --git a/Arrowgene.Ddon.Database/IDatabase.cs b/Arrowgene.Ddon.Database/IDatabase.cs index a932be218..481f80669 100644 --- a/Arrowgene.Ddon.Database/IDatabase.cs +++ b/Arrowgene.Ddon.Database/IDatabase.cs @@ -27,6 +27,8 @@ void ExecuteReader( Action commandAction, Action readAction ); + void ExecuteQuerySafe(DbConnection? connectionIn, Action work); + T ExecuteQuerySafe(DbConnection? connectionIn, Func work); // Generic functions for getting/setting void AddParameter(DbCommand command, string name, object? value, DbType type); @@ -120,7 +122,7 @@ CDataPawnSearchParameter searchParams ); bool DeletePawn(uint pawnId); bool UpdatePawnBaseInfo(Pawn pawn); - uint GetPawnOwnerCharacterId(uint pawnId); + uint GetPawnOwnerCharacterId(uint pawnId, DbConnection? connectionIn = null); bool ReplacePawnReaction(uint pawnId, CDataPawnReaction pawnReaction, DbConnection? connectionIn = null); // Pawn Training Status diff --git a/Arrowgene.Ddon.Database/Sql/Core/DdonSqlDb.cs b/Arrowgene.Ddon.Database/Sql/Core/DdonSqlDb.cs index dd8268fe6..30476f0f9 100644 --- a/Arrowgene.Ddon.Database/Sql/Core/DdonSqlDb.cs +++ b/Arrowgene.Ddon.Database/Sql/Core/DdonSqlDb.cs @@ -159,6 +159,19 @@ public void ExecuteQuerySafe(DbConnection? connectionIn, Action work) } } + // Wrestling with generics; the interface is not happy to expose a generic, + // but a bunch of DB functions break if you don't allow the generic. + // This is the compromise. + public void ExecuteQuerySafe(DbConnection? connectionIn, Action work) + { + ExecuteQuerySafe(connectionIn, (Action)work); + } + + public T ExecuteQuerySafe(DbConnection? connectionIn, Func work) + { + return ExecuteQuerySafe(connectionIn, (Func)work); + } + public bool MigrateDatabase(DatabaseMigrator migrator, uint toVersion) { uint currentVersion = GetMeta().DatabaseVersion; diff --git a/Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbPawn.cs b/Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbPawn.cs index 0a2af21a5..8327d3e10 100644 --- a/Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbPawn.cs +++ b/Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbPawn.cs @@ -306,31 +306,28 @@ CDataPawnSearchParameter searchParams return registeredPawns; } - public uint GetPawnOwnerCharacterId(uint pawnId) - { - using TCon connection = OpenNewConnection(); - return GetPawnOwnerCharacterId(connection, pawnId); - } - - public uint GetPawnOwnerCharacterId(TCon connection, uint pawnId) + public uint GetPawnOwnerCharacterId(uint pawnId, DbConnection? connectionIn = null) { uint ownerCharacterId = 0; - ExecuteReader( - connection, - SqlSelectPawnOwnerId, - command => - { - AddParameter(command, "@pawn_id", pawnId); - }, - reader => - { - if (reader.Read()) + ExecuteQuerySafe(connectionIn, connection => + { + ExecuteReader( + connection, + SqlSelectPawnOwnerId, + command => + { + AddParameter(command, "@pawn_id", pawnId); + }, + reader => { - ownerCharacterId = GetUInt32(reader, "character_id"); + if (reader.Read()) + { + ownerCharacterId = GetUInt32(reader, "character_id"); + } } - } - ); - + ); + }); + return ownerCharacterId; } diff --git a/Arrowgene.Ddon.GameServer/Characters/CharacterManager.cs b/Arrowgene.Ddon.GameServer/Characters/CharacterManager.cs index 9d984446a..8032f8897 100644 --- a/Arrowgene.Ddon.GameServer/Characters/CharacterManager.cs +++ b/Arrowgene.Ddon.GameServer/Characters/CharacterManager.cs @@ -33,45 +33,51 @@ public CharacterManager(DdonGameServer server) public Character SelectCharacter(GameClient client, uint characterId, DbConnection? connectionIn = null) { - Character character = SelectCharacter(characterId, connectionIn); + Character character = SelectCharacter(characterId, connectionIn:connectionIn); client.Character = character; client.UpdateIdentity(); return character; } - public Character SelectCharacter(uint characterId, DbConnection? connectionIn = null) + public Character SelectCharacter(uint characterId, bool fetchPawns = true, DbConnection? connectionIn = null) { - Character character = _Server.Database.SelectCharacter(characterId, connectionIn); - if (character == null) + return _Server.Database.ExecuteQuerySafe(connectionIn, connectionIn => { - return null; - } + Character character = _Server.Database.SelectCharacter(characterId, connectionIn); + if (character == null) + { + return null; + } - character.Server = _Server.AssetRepository.ServerList.Where(server => server.Id == _Server.Id).Single().ToCDataGameServerListInfo(); - character.Equipment = character.Storage.GetCharacterEquipment(); + character.Server = _Server.AssetRepository.ServerList.Where(server => server.Id == _Server.Id).Single().ToCDataGameServerListInfo(); + character.Equipment = character.Storage.GetCharacterEquipment(); - 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.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.EpitaphRoadState.UnlockedContent = _Server.Database.GetEpitaphRoadUnlocks(character.CharacterId, connectionIn); + character.EpitaphRoadState.UnlockedContent = _Server.Database.GetEpitaphRoadUnlocks(character.CharacterId, connectionIn); - if (_Server.GameLogicSettings.EnableEpitaphWeeklyRewards) - { - character.EpitaphRoadState.WeeklyRewardsClaimed = _Server.Database.GetEpitaphClaimedWeeklyRewards(character.CharacterId, connectionIn); - } - + if (_Server.GameLogicSettings.EnableEpitaphWeeklyRewards) + { + character.EpitaphRoadState.WeeklyRewardsClaimed = _Server.Database.GetEpitaphClaimedWeeklyRewards(character.CharacterId, connectionIn); + } - UpdateCharacterExtendedParams(character); - SelectPawns(character, connectionIn); + UpdateCharacterExtendedParams(character); - return character; + if (fetchPawns) + { + SelectPawns(character, connectionIn); + } + + return character; + }); } private void SelectPawns(Character character, DbConnection? connectionIn = null) diff --git a/Arrowgene.Ddon.GameServer/Handler/ClanClanPartnerPawnDataGetHandler.cs b/Arrowgene.Ddon.GameServer/Handler/ClanClanPartnerPawnDataGetHandler.cs index bb3d9c89a..6461359c3 100644 --- a/Arrowgene.Ddon.GameServer/Handler/ClanClanPartnerPawnDataGetHandler.cs +++ b/Arrowgene.Ddon.GameServer/Handler/ClanClanPartnerPawnDataGetHandler.cs @@ -22,13 +22,13 @@ public override S2CClanClanPartnerPawnDataGetRes Handle(GameClient client, C2SCl Pawn pawn = null; Server.Database.ExecuteInTransaction(connection => { - uint ownerCharacterId = Server.Database.GetPawnOwnerCharacterId((uint)request.PawnId); + uint ownerCharacterId = Server.Database.GetPawnOwnerCharacterId((uint)request.PawnId, connection); if (ownerCharacterId == 0) { throw new ResponseErrorException(ErrorCode.ERROR_CODE_CHARACTER_PAWN_PARAM_NOT_FOUND); } - var ownerCharacter = Server.CharacterManager.SelectCharacter(ownerCharacterId); + var ownerCharacter = Server.CharacterManager.SelectCharacter(ownerCharacterId, connectionIn:connection); pawn = ownerCharacter.Pawns.Find(x => x.PawnId == request.PawnId) ?? throw new ResponseErrorException(ErrorCode.ERROR_CODE_PAWN_INVALID); }); @@ -36,152 +36,5 @@ public override S2CClanClanPartnerPawnDataGetRes Handle(GameClient client, C2SCl return res; } - - private readonly byte[] Dab2f3 = - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDA, 0xB2, 0xF3, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x53, 0x65, 0x65, 0x6C, 0x69, 0x78, 0x02, 0x06, 0x75, 0x30, 0x07, 0x01, 0x01, 0x13, - 0x12, 0x00, 0x00, 0x02, 0x03, 0x05, 0x08, 0x00, 0x45, 0x00, 0x45, 0x37, 0x37, 0x0C, 0x74, 0x9A, - 0x74, 0x7C, 0x76, 0xD4, 0x73, 0x85, 0x73, 0xB7, 0x74, 0x13, 0x71, 0xCF, 0x75, 0xDC, 0x74, 0x82, - 0x77, 0x1C, 0x75, 0x32, 0x74, 0xD1, 0x7C, 0x38, 0x72, 0xD8, 0x75, 0x30, 0x75, 0x30, 0x75, 0xC3, - 0x74, 0xF2, 0x74, 0x4F, 0x75, 0x02, 0x74, 0xE0, 0x74, 0x9A, 0x72, 0x10, 0x72, 0xDC, 0x74, 0x04, - 0x73, 0x20, 0x77, 0xD0, 0x71, 0x48, 0x73, 0x50, 0x77, 0xB5, 0x75, 0xA2, 0x75, 0x30, 0x75, 0x30, - 0x75, 0x30, 0x75, 0x30, 0x75, 0x30, 0xBB, 0xB2, 0x9B, 0x35, 0x71, 0xFC, 0x8A, 0x98, 0x96, 0x96, - 0x99, 0xF2, 0xA9, 0xB3, 0x96, 0xC8, 0x77, 0x88, 0x72, 0x95, 0x70, 0x1C, 0x51, 0xA4, 0x75, 0x30, - 0x61, 0x44, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x62, 0x68, 0x00, - 0x01, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x63, 0x3D, 0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, - 0xA2, 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x42, 0x00, 0x01, 0x00, 0x06, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0xC8, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x63, 0x47, 0x00, 0x01, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x01, 0x01, 0x02, 0x43, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0xA7, 0x00, - 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x63, 0xAC, 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x93, 0x00, 0x01, 0x00, 0x0A, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x56, 0xDA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0x92, 0x00, 0x01, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x01, 0x00, 0x00, 0x34, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x53, 0x7D, 0x00, 0x01, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x4B, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x54, 0x93, 0x00, 0x01, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x56, - 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0xE4, 0x00, - 0x01, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x59, 0xB5, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x4A, 0x00, 0x01, 0x00, 0x0F, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x25, 0x9D, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x10, - 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x03, 0xC8, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0xA2, 0x00, 0x01, 0x00, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0xFA, 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - - private readonly byte[] Db3bcf = - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDB, 0x3B, 0xCF, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x53, 0x65, 0x65, 0x6C, 0x69, 0x78, 0x02, 0x06, 0x75, 0x30, 0x07, 0x01, 0x01, 0x13, - 0x12, 0x00, 0x00, 0x02, 0x03, 0x05, 0x08, 0x00, 0x45, 0x00, 0x45, 0x37, 0x37, 0x0C, 0x74, 0x9A, - 0x74, 0x7C, 0x76, 0xD4, 0x73, 0x85, 0x73, 0xB7, 0x74, 0x13, 0x71, 0xCF, 0x75, 0xDC, 0x74, 0x82, - 0x77, 0x1C, 0x75, 0x32, 0x74, 0xD1, 0x7C, 0x38, 0x72, 0xD8, 0x75, 0x30, 0x75, 0x30, 0x75, 0xC3, - 0x74, 0xF2, 0x74, 0x4F, 0x75, 0x02, 0x74, 0xE0, 0x74, 0x9A, 0x72, 0x10, 0x72, 0xDC, 0x74, 0x04, - 0x73, 0x20, 0x77, 0xD0, 0x71, 0x48, 0x73, 0x50, 0x77, 0xB5, 0x75, 0xA2, 0x75, 0x30, 0x75, 0x30, - 0x75, 0x30, 0x75, 0x30, 0x75, 0x30, 0xBB, 0xB2, 0x9B, 0x35, 0x71, 0xFC, 0x8A, 0x98, 0x96, 0x96, - 0x99, 0xF2, 0xA9, 0xB3, 0x96, 0xC8, 0x77, 0x88, 0x72, 0x95, 0x70, 0x1C, 0x51, 0xA4, 0x75, 0x30, - 0x61, 0x44, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x62, 0x68, 0x00, - 0x01, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x63, 0x3D, 0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, - 0xA2, 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x42, 0x00, 0x01, 0x00, 0x06, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0xC8, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x63, 0x47, 0x00, 0x01, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x01, 0x01, 0x02, 0x43, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0xA7, 0x00, - 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x63, 0xAC, 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x93, 0x00, 0x01, 0x00, 0x0A, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x56, 0xDA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0x92, 0x00, 0x01, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x01, 0x00, 0x00, 0x34, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x53, 0x7D, 0x00, 0x01, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x4B, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x54, 0x93, 0x00, 0x01, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x56, - 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0xE4, 0x00, - 0x01, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x59, 0xB5, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x4A, 0x00, 0x01, 0x00, 0x0F, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x25, 0x9D, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x10, - 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x03, 0xC8, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0xA2, 0x00, 0x01, 0x00, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0xFA, 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - - private readonly byte[] Dc0377 = - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x03, 0x77, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x06, 0x46, 0x61, 0x69, 0x74, 0x61, 0x72, 0x02, 0x05, 0x76, 0xC0, 0x01, 0x01, 0x01, 0x11, - 0x12, 0x00, 0x00, 0x19, 0x10, 0x05, 0x02, 0x1F, 0x28, 0x00, 0x16, 0x11, 0x11, 0x01, 0x75, 0x30, - 0x75, 0x30, 0x76, 0xD4, 0x74, 0x1F, 0x74, 0x19, 0x73, 0xB6, 0x72, 0x3B, 0x74, 0x9A, 0x74, 0x7C, - 0x76, 0x71, 0x74, 0xC4, 0x75, 0xB7, 0x70, 0x80, 0x73, 0xC8, 0x75, 0x30, 0x75, 0x30, 0x75, 0xC3, - 0x74, 0xF2, 0x74, 0x4F, 0x75, 0x02, 0x74, 0xF5, 0x74, 0x7C, 0x73, 0xB0, 0x74, 0x74, 0x74, 0x8E, - 0x74, 0xD0, 0x75, 0xCA, 0x72, 0x92, 0x75, 0x0A, 0x76, 0x50, 0x75, 0x3C, 0x75, 0x30, 0x75, 0x30, - 0x75, 0x30, 0x75, 0x30, 0x75, 0x30, 0xBA, 0x86, 0x99, 0x20, 0x74, 0x18, 0x8C, 0xF0, 0x98, 0x8A, - 0x9B, 0x1C, 0xA5, 0xB7, 0x97, 0x2C, 0x7E, 0xF4, 0x7E, 0x63, 0x71, 0xAF, 0x4E, 0x20, 0x87, 0x5A, - 0x71, 0x48, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x38, 0x3D, 0x00, - 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x38, 0x6A, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3A, 0x64, 0x00, 0x01, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3B, - 0x04, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x16, 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3B, 0xD7, 0x00, 0x01, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x3C, 0x77, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x3E, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x75, 0x00, - 0x01, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x5C, 0x9F, 0x00, 0x01, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x5C, 0x56, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x5C, 0x9F, 0x00, 0x01, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x5C, - 0x59, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x93, 0x00, - 0x01, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x56, 0xDA, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0xF9, 0x00, 0x01, 0x00, 0x0F, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xF5 - }; - - private readonly byte[] Dc7370 = - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x73, 0x70, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x05, 0x52, 0x65, 0x69, 0x6B, 0x6F, 0x02, 0x06, 0x75, 0x30, 0x03, 0x04, 0x01, 0x63, 0x12, - 0x03, 0x00, 0x05, 0x01, 0x05, 0x02, 0x07, 0x32, 0x00, 0x1E, 0x27, 0x27, 0x00, 0x75, 0x30, 0x76, - 0x0C, 0x75, 0x30, 0x74, 0xB2, 0x74, 0x19, 0x74, 0x1B, 0x71, 0xCF, 0x74, 0xA1, 0x74, 0x64, 0x77, - 0x1C, 0x74, 0xCA, 0x75, 0xFD, 0x66, 0x58, 0x72, 0xEA, 0x75, 0x30, 0x75, 0x30, 0x76, 0xBF, 0x76, - 0xB4, 0x74, 0xEF, 0x75, 0xA4, 0x74, 0xFC, 0x74, 0x36, 0x73, 0x88, 0x73, 0x04, 0x74, 0xA7, 0x74, - 0x68, 0x75, 0xB5, 0x73, 0x37, 0x73, 0xEA, 0x74, 0x84, 0x73, 0x8C, 0x75, 0x30, 0x75, 0x30, 0x75, - 0x30, 0x75, 0x30, 0x75, 0x30, 0xB6, 0xD0, 0x9B, 0xDA, 0x71, 0x34, 0x8E, 0x80, 0x95, 0xC4, 0x9D, - 0xFB, 0xAD, 0xAC, 0x97, 0x2C, 0x71, 0xFC, 0x75, 0x44, 0x71, 0xAF, 0x65, 0x90, 0x75, 0x30, 0x75, - 0x30, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x01, 0x37, 0x00, 0x01, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0xB1, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0xA2, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xD1, - 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0xF2, 0x00, 0x01, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x0D, 0x00, 0x01, 0x00, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0xE9, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFD, 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x1F, 0x89, 0x04, 0x53, 0x2F - }; - } } diff --git a/Arrowgene.Ddon.GameServer/Handler/ProfileGetCharacterProfileHandler.cs b/Arrowgene.Ddon.GameServer/Handler/ProfileGetCharacterProfileHandler.cs index faba13468..b4dcdba69 100644 --- a/Arrowgene.Ddon.GameServer/Handler/ProfileGetCharacterProfileHandler.cs +++ b/Arrowgene.Ddon.GameServer/Handler/ProfileGetCharacterProfileHandler.cs @@ -18,7 +18,7 @@ public ProfileGetCharacterProfileHandler(DdonGameServer server) : base(server) public override S2CProfileGetCharacterProfileRes Handle(GameClient client, C2SProfileGetCharacterProfileReq request) { Character targetCharacter = Server.ClientLookup.GetClientByCharacterId(request.CharacterId)?.Character - ?? Server.Database.SelectCharacter(request.CharacterId) + ?? Server.CharacterManager.SelectCharacter(request.CharacterId, fetchPawns:false) ?? throw new ResponseErrorException(ErrorCode.ERROR_CODE_CHARACTER_DATA_INVALID_CHARACTER_ID); S2CCharacterGetCharacterStatusNtc ntc = new S2CCharacterGetCharacterStatusNtc(); diff --git a/Arrowgene.Ddon.Test/Database/DatabaseMigratorTest.cs b/Arrowgene.Ddon.Test/Database/DatabaseMigratorTest.cs index 722d59602..121ba706b 100644 --- a/Arrowgene.Ddon.Test/Database/DatabaseMigratorTest.cs +++ b/Arrowgene.Ddon.Test/Database/DatabaseMigratorTest.cs @@ -185,6 +185,9 @@ public bool ExecuteInTransaction(Action action) { public int ExecuteNonQuery(DbConnection conn, string command, Action action) { return 1; } public void ExecuteReader(string command, Action action) {} public void ExecuteReader(DbConnection conn, string sql, Action commandAction, Action readAction) {} + public void ExecuteQuerySafe(DbConnection? connectionIn, Action work) {} + T IDatabase.ExecuteQuerySafe(DbConnection? connectionIn, Func work) { throw new NotImplementedException(); } + public Account CreateAccount(string name, string mail, string hash) { return new Account(); } public bool CreateCharacter(Character character) { return true; } public bool CreateDatabase() { return true; } @@ -394,7 +397,7 @@ public bool UpdateRentalPawnSlot(uint characterId, uint num) public List SelectClanPawns(uint clanId, uint characterId = 0, uint limit = 100, DbConnection? connectionIn = null) { return new(); } public List SelectRandomPlayerPawns(uint limit = 100) { return new List(); } public List SelectRandomPlayerPawns(DbConnection connection, uint limit = 100) { return new List(); } - public uint GetPawnOwnerCharacterId(uint pawnId) { return 0; } + public uint GetPawnOwnerCharacterId(uint pawnId, DbConnection? connectionIn = null) { return 0; } public CDataCharacterSearchParam SelectCharacterNameById(uint characterId) { return new CDataCharacterSearchParam(); } public CDataCharacterSearchParam SelectCharacterNameById(DbConnection connection, uint characterId) { return new CDataCharacterSearchParam(); } @@ -448,6 +451,8 @@ public void AddParameter(DbCommand command, string name, bool value) { } public List SelectRegisteredPawns(Character searchingCharacter, CDataPawnSearchParameter searchParams) { return new List(); } public List SelectRegisteredPawns(DbConnection conn, Character searchingCharacter, CDataPawnSearchParameter searchParams) { return new List(); } public void DeleteWeeklyEpitaphClaimedRewards(DbConnection? connectionIn = null) { } + + } class MockMigrationStrategy : IMigrationStrategy