Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 3 additions & 5 deletions Arrowgene.Ddon.Database/IDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,9 @@ Ability ability
bool DeleteCommunicationShortcut(uint characterId, uint pageNo, uint buttonNo);

// GameToken
bool SetToken(GameToken token);
GameToken SelectTokenByAccountId(int accountId);
GameToken SelectToken(string tokenStr);
bool DeleteTokenByAccountId(int accountId);
bool DeleteToken(string token);
bool ReplaceToken(GameToken token, DbConnection? connectionIn = null);
GameToken SelectToken(string tokenStr, DbConnection? connectionIn = null);
bool DeleteTokenByAccountId(int accountId, DbConnection? connectionIn = null);

// Connections
bool InsertConnection(Connection connection);
Expand Down
90 changes: 31 additions & 59 deletions Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbGameToken.cs
Original file line number Diff line number Diff line change
@@ -1,85 +1,57 @@
using Arrowgene.Ddon.Shared.Model;
using System.Data.Common;
using System.Linq;
using Arrowgene.Ddon.Shared.Model;

namespace Arrowgene.Ddon.Database.Sql.Core;

public partial class DdonSqlDb : SqlDb
{
private const string SqlInsertToken =
"INSERT INTO \"ddon_game_token\" (\"account_id\", \"character_id\", \"token\", \"created\") VALUES (@account_id, @character_id, @token, @created);";

private const string SqlUpdateToken =
"UPDATE \"ddon_game_token\" SET \"character_id\"=@character_id, \"token\"=@token, \"created\"=@created WHERE \"account_id\" = @account_id;";

private const string SqlSelectTokenByAccountId =
"SELECT \"token\", \"account_id\", \"character_id\", \"token\", \"created\" FROM \"ddon_game_token\" WHERE \"account_id\" = @account_id;";

private static readonly string[] GameTokenFields = ["account_id", "character_id", "token", "created"];
private static readonly string[] GameTokenKeyFields = ["account_id"];
private static readonly string[] GameTokenNonKeyFields = GameTokenFields.Except(GameTokenKeyFields).ToArray();
private static readonly string SqlSelectToken = $"SELECT {BuildQueryField(GameTokenFields)} FROM \"ddon_game_token\" WHERE \"token\" = @token;";
private static readonly string SqlInsertToken = $"INSERT INTO \"ddon_game_token\" ({BuildQueryField(GameTokenFields)}) VALUES ({BuildQueryInsert(GameTokenFields)});";
private static readonly string SqlUpdateToken = $"UPDATE \"ddon_game_token\" SET {BuildQueryUpdate(GameTokenFields)} WHERE \"account_id\" = @account_id;";
private const string SqlDeleteTokenByAccountId = "DELETE FROM \"ddon_game_token\" WHERE \"account_id\"=@account_id;";
private const string SqlSelectToken = "SELECT \"token\", \"account_id\", \"character_id\", \"token\", \"created\" FROM \"ddon_game_token\" WHERE \"token\" = @token;";
private const string SqlDeleteToken = "DELETE FROM \"ddon_game_token\" WHERE \"token\"=@token;";
private readonly string SqlUpsertToken =
$"""
INSERT INTO "ddon_game_token" ({BuildQueryField(GameTokenFields)}) VALUES ({BuildQueryInsert(GameTokenFields)})
ON CONFLICT ("account_id") DO UPDATE SET {BuildQueryUpdateWithPrefix("EXCLUDED.", GameTokenNonKeyFields)};
""";

public override bool SetToken(GameToken token)
public override bool ReplaceToken(GameToken token, DbConnection? connectionIn = null)
{
int rowsAffected = ExecuteNonQuery(SqlUpdateToken, command =>
{
AddParameter(command, "@account_id", token.AccountId);
AddParameter(command, "@character_id", token.CharacterId);
AddParameter(command, "@token", token.Token);
AddParameter(command, "@created", token.Created);
});
if (rowsAffected > NoRowsAffected) return true;

rowsAffected = ExecuteNonQuery(SqlInsertToken, command =>
{
AddParameter(command, "@account_id", token.AccountId);
AddParameter(command, "@character_id", token.CharacterId);
AddParameter(command, "@token", token.Token);
AddParameter(command, "@created", token.Created);
});

return rowsAffected > NoRowsAffected;
}

public override GameToken SelectTokenByAccountId(int accountId)
{
GameToken token = null;
ExecuteReader(SqlSelectTokenByAccountId, command => { AddParameter(command, "@account_id", accountId); }, reader =>
{
if (reader.Read())
return ExecuteQuerySafe(connectionIn,
connection => { return ExecuteNonQuery(connection, SqlUpsertToken, command =>
{
token = new GameToken();
token.AccountId = GetInt32(reader, "account_id");
token.CharacterId = GetUInt32(reader, "character_id");
token.Token = GetString(reader, "token");
token.Created = GetDateTime(reader, "created");
}
});
return token;
AddParameter(command, "@account_id", token.AccountId);
AddParameter(command, "@character_id", token.CharacterId);
AddParameter(command, "@token", token.Token);
AddParameter(command, "@created", token.Created);
}) == 1; });
}

public override GameToken SelectToken(string tokenStr)
public override GameToken SelectToken(string tokenStr, DbConnection? connectionIn = null)
{
GameToken token = null;
ExecuteReader(SqlSelectToken, command => { AddParameter(command, "@token", tokenStr); }, reader =>
{
if (reader.Read())
{
token = new GameToken();
token.AccountId = GetInt32(reader, "account_id");
token.CharacterId = GetUInt32(reader, "character_id");
token.Token = GetString(reader, "token");
token.Created = GetDateTime(reader, "created");
token = new GameToken
{
AccountId = GetInt32(reader, "account_id"),
CharacterId = GetUInt32(reader, "character_id"),
Token = GetString(reader, "token"),
Created = GetDateTime(reader, "created")
};
}
});
return token;
}

public override bool DeleteToken(string token)
{
int rowsAffected = ExecuteNonQuery(SqlDeleteToken, command => { AddParameter(command, "@token", token); });
return rowsAffected > NoRowsAffected;
}

public override bool DeleteTokenByAccountId(int accountId)
public override bool DeleteTokenByAccountId(int accountId, DbConnection? connectionIn = null)
{
int rowsAffected = ExecuteNonQuery(SqlDeleteTokenByAccountId, command => { AddParameter(command, "@account_id", accountId); });
return rowsAffected > NoRowsAffected;
Expand Down
8 changes: 3 additions & 5 deletions Arrowgene.Ddon.Database/Sql/SqlDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,9 @@ public bool MigrateDatabase(DatabaseMigrator migrator, uint toVersion)
public abstract bool ReplaceCommunicationShortcut(uint characterId, CDataCommunicationShortCut communicationShortcut, DbConnection? connectionIn = null);
public abstract bool UpdateCommunicationShortcut(uint characterId, uint oldPageNo, uint oldButtonNo, CDataCommunicationShortCut updatedCommunicationShortcut, DbConnection? connectionIn = null);
public abstract bool DeleteCommunicationShortcut(uint characterId, uint pageNo, uint buttonNo);
public abstract bool SetToken(GameToken token);
public abstract GameToken SelectTokenByAccountId(int accountId);
public abstract GameToken SelectToken(string tokenStr);
public abstract bool DeleteTokenByAccountId(int accountId);
public abstract bool DeleteToken(string token);
public abstract bool ReplaceToken(GameToken token, DbConnection? connectionIn = null);
public abstract GameToken SelectToken(string tokenStr, DbConnection? connectionIn = null);
public abstract bool DeleteTokenByAccountId(int accountId, DbConnection? connectionIn = null);
public abstract bool InsertConnection(Connection connection);
public abstract List<Connection> SelectConnections();
public abstract List<Connection> SelectConnectionsByAccountId(int accountId);
Expand Down
2 changes: 1 addition & 1 deletion Arrowgene.Ddon.GameServer/Characters/CharacterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ private Dictionary<JobId, List<CDataSkillParam>> CalculateAcquirableSkills(Chara
return acquirableSkills;
}

private void SelectPawns(Character character, DbConnection? connectionIn = null)
public void SelectPawns(Character character, DbConnection? connectionIn = null)
{
character.Pawns = Server.Database.SelectPawnsByCharacterId(character.ContentCharacterId, connectionIn);

Expand Down
3 changes: 3 additions & 0 deletions Arrowgene.Ddon.GameServer/DdonGameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ private void LoadPacketHandler()

AddHandler(new BattleContentInfoListHandler(this));
AddHandler(new BattleContentGetContentStatusFromOmHandler(this));
AddHandler(new BattleContentGetPhaseToChangeFromOmHandler(this));
AddHandler(new BattleContentPhaseEntryBeginRecruitmentHandler(this));
AddHandler(new BattleContentPhaseEntryReadyCancelHandler(this));
AddHandler(new BattleContentContentEntryHandler(this));
AddHandler(new BattleContentInstantClearInfoHandler(this));
AddHandler(new BattleContentPartyMemberInfoHandler(this));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using Arrowgene.Ddon.GameServer.Dump;
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Shared.Entity;
Expand All @@ -19,22 +20,61 @@ public BattleContentCharacterInfoHandler(DdonGameServer server) : base(server)

public override S2CBattleContentCharacterInfoRes Handle(GameClient client, C2SBattleContentCharacterInfoReq request)
{
S2CBattleContentInfoListRes pcap = EntitySerializer.Get<S2CBattleContentInfoListRes>().Read(InGameDump.Dump_93.AsBuffer());
pcap.BattleContentStatusList[0].BattleContentSituationData.StartTime = 4875391515;
pcap.BattleContentStatusList[0].BattleContentSituationData.ContentId = 2;
pcap.BattleContentStatusList[0].BattleContentSituationData.Unk8 = 0;
pcap.BattleContentStatusList[0].BattleContentSituationData.Unk11 = 0;
pcap.BattleContentStatusList[0].BattleContentSituationData.RewardReceived = true;
pcap.BattleContentStatusList[0].BattleContentSituationData.RewardBonus = BattleContentRewardBonus.Normal;

pcap.BattleContentStatusList[0].BattleContentSituationData.Unk3 = true;
pcap.BattleContentStatusList[0].BattleContentSituationData.ReportReset = 1;
pcap.BattleContentStatusList[0].BattleContentSituationData.ReportSearchResults = 0;

var result = new S2CBattleContentCharacterInfoRes()
{
SituationData = pcap.BattleContentStatusList[0].BattleContentSituationData,
Unk2List = pcap.BattleContentStatusList[0].BattleContentAvailableRewardsList
SituationData = new CDataBattleContentSituationData
{
GameMode = GameMode.BitterblackMaze,
StartTime = 1,
RewardReceived = false,
Unk3 = false,
RewardBonus = BattleContentRewardBonus.Normal,
ReportReset = 0,
ReportSearchResults = 0,
Unk7 = 2,
Unk8 = 2,
Unktime = 0,
ContentId = 2,
Unk11 = 2
},
AvailableRewardsList = [
new CDataBattleContentAvailableRewards
{
Id = 10,
Amount = 1
},
new CDataBattleContentAvailableRewards
{
Id = 2,
Amount = 1
},
new CDataBattleContentAvailableRewards
{
Id = 11,
Amount = 1
},
new CDataBattleContentAvailableRewards
{
Id = 3,
Amount = 1
},
new CDataBattleContentAvailableRewards
{
Id = 12,
Amount = 1
},
new CDataBattleContentAvailableRewards
{
Id = 4,
Amount = 1
},
new CDataBattleContentAvailableRewards
{
Id = 13,
Amount = 1
}
]
};

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,24 @@ public override S2CBattleContentContentEntryRes Handle(GameClient client, C2SBat
Server.Database.UpdateBBMProgress(client.Character.CharacterId, progress);
}

var contentStatus = BitterblackMazeManager.GetUpdatedContentStatus(Server, client.Character);
S2CBattleContentContentEntryNtc ntc = new S2CBattleContentContentEntryNtc()
// var contentStatus = BitterblackMazeManager.GetUpdatedContentStatus(Server, client.Character);
// S2CBattleContentContentEntryNtc ntc = new S2CBattleContentContentEntryNtc()
// {
// GameMode = GameMode.BitterblackMaze,
// };
// ntc.BattleContentStatusList.Add(contentStatus);
// client.Send(ntc);
//
// S2CBattleContentProgressNtc ntc2 = new S2CBattleContentProgressNtc();
// ntc2.BattleContentStatusList.Add(contentStatus);
// client.Send(ntc2);

S2CBattleContentPhaseEntryReadyNtc phaseEntryReadyNtc = new()
{
GameMode = GameMode.BitterblackMaze,
Unk0 = 2,
Unk1 = 0
};
ntc.BattleContentStatusList.Add(contentStatus);
client.Send(ntc);

S2CBattleContentProgressNtc ntc2 = new S2CBattleContentProgressNtc();
ntc2.BattleContentStatusList.Add(contentStatus);
client.Send(ntc2);
client.Send(phaseEntryReadyNtc);

return new S2CBattleContentContentEntryRes();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
using System;
using System.Linq;
using Arrowgene.Ddon.GameServer.Characters;
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
using Arrowgene.Ddon.Shared.Model;
using Arrowgene.Ddon.Shared.Model.BattleContent;
using Arrowgene.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mime;
using YamlDotNet.Core.Tokens;

namespace Arrowgene.Ddon.GameServer.Handler
{
Expand Down Expand Up @@ -60,10 +56,10 @@ public override S2CBattleContentGetContentStatusFromOmRes Handle(GameClient clie
return new S2CBattleContentGetContentStatusFromOmRes()
{
GameMode = GameMode.BitterblackMaze,
NotifyJobLock = contentInProgress ? 1U : 0U,
Unk2 = 2,
Unk3 = 3,
Unk4 = 4,
NotifyJobLock = 0, //contentInProgress ? 1U : 0U,
Unk2 = 0,
RouteIsNotInProgress = 1, // "Cannot enter because another route is in progress": 0 = display, 1 = skip for regular,
Unk4 = 0
};

// 0, 0, 0, 0 says can't do content
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
using Arrowgene.Ddon.Shared.Entity.Structure;
using Arrowgene.Ddon.Shared.Model;
using Arrowgene.Logging;

namespace Arrowgene.Ddon.GameServer.Handler
{
public class BattleContentGetPhaseToChangeFromOmHandler : GameRequestPacketHandler<C2SBattleContentGetPhaseToChangeFromOmReq, S2CBattleContentGetPhaseToChangeFromOmRes>
{
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(BattleContentGetPhaseToChangeFromOmHandler));

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

public override S2CBattleContentGetPhaseToChangeFromOmRes Handle(GameClient client, C2SBattleContentGetPhaseToChangeFromOmReq request)
{
S2CBattleContentGetPhaseToChangeFromOmRes res = new()
{
BattleContentStage = new CDataBattleContentStage
{
Id = 2,
StageName = "Bitterblack Maze Rotunda: Netherworld 1",
Mode = BattleContentMode.Rotunda
}
};

return res;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
using Arrowgene.Logging;
using Arrowgene.Ddon.Shared.Entity.Structure;
using System.Collections.Generic;
using Arrowgene.Ddon.GameServer.Dump;
using Arrowgene.Ddon.Shared.Entity;
using Arrowgene.Ddon.Shared.Model;
using Arrowgene.Logging;

namespace Arrowgene.Ddon.GameServer.Handler
{
Expand All @@ -19,10 +16,36 @@ public BattleContentInstantClearInfoHandler(DdonGameServer server) : base(server

public override S2CBattleContentInstantClearInfoRes Handle(GameClient client, C2SBattleContentInstantClearInfoReq request)
{
// Not sure what this does, can't seem to make anything show up
// I think it must be related to the ready up select menu, but not sure
var result = new S2CBattleContentInstantClearInfoRes();
return result;
S2CBattleContentInstantClearInfoRes res = new S2CBattleContentInstantClearInfoRes
{
Unk0 =
[
new CDataBattleContentUnk4
{
Unk0 = 2,
Unk1 = 0,
UnknownString = "Bitterblack Maze Rotunda: Netherworld 1",
WalletPoints =
[
new CDataWalletPoint
{
Type = WalletType.Gold,
Value = 123
}
],
Unk3 =
[
new CDataBattleContentUnk5
{
Unk0 = 2,
Unk1 = 2
}
]
}
]
};

return res;
}
}
}
Loading