Skip to content

Commit

Permalink
GameSvr数据源测试
Browse files Browse the repository at this point in the history
  • Loading branch information
mirbeta committed Feb 14, 2024
1 parent 488533b commit 1847483
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 13 deletions.
5 changes: 2 additions & 3 deletions src/GameSrv/DB/MySqlDB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace GameSrv.DB
{
public class MySqlDB : IDataSource
{

private IDbConnection _dbConnection;

public int LoadItemsDB()
Expand Down Expand Up @@ -337,13 +336,13 @@ public void SaveSellOffItemList()
}
}

public static int LoadUpgradeWeaponRecord(string sNPCName, IList<WeaponUpgradeInfo> DataList)
public int LoadUpgradeWeaponRecord(string sNPCName, IList<WeaponUpgradeInfo> DataList)
{
//todo 加载武器升级数据
return -1;
}

public static int SaveUpgradeWeaponRecord(string sNPCName, IList<WeaponUpgradeInfo> DataList)
public int SaveUpgradeWeaponRecord(string sNPCName, IList<WeaponUpgradeInfo> DataList)
{
//todo 保存武器升级数据
return -1;
Expand Down
8 changes: 4 additions & 4 deletions src/GameSrv/GameApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void Initialize(CancellationToken stoppingToken)
M2Share.LoadDenyChrNameList();
M2Share.LoadNoClearMonList();
LogService.Info("正在加载物品数据库...");
int nCode = GameShare.CommonDb.LoadItemsDB();
int nCode = GameShare.DataSource.LoadItemsDB();
if (nCode < 0)
{
LogService.Info($"物品数据库加载失败!!! Code: {nCode}");
Expand All @@ -128,15 +128,15 @@ public void Initialize(CancellationToken stoppingToken)
return;
}
LogService.Info("正在加载怪物数据库...");
nCode = GameShare.CommonDb.LoadMonsterDB();
nCode = GameShare.DataSource.LoadMonsterDB();
if (nCode < 0)
{
LogService.Info($"加载怪物数据库失败!!! Code: {nCode}");
return;
}
LogService.Info($"加载怪物数据库成功...[{SystemShare.WorldEngine.MonsterCount}]");
LogService.Info("正在加载技能数据库...");
nCode = GameShare.CommonDb.LoadMagicDB();
nCode = GameShare.DataSource.LoadMagicDB();
if (nCode < 0)
{
LogService.Info($"加载技能数据库失败!!! Code: {nCode}");
Expand Down Expand Up @@ -179,7 +179,7 @@ public void Initialize(CancellationToken stoppingToken)
}
LogService.Info("加载捆装物品信息成功...");
LogService.Info("加载物品寄售系统...");
GameShare.CommonDb.LoadSellOffItemList();
GameShare.DataSource.LoadSellOffItemList();
LogService.Info("正在加载任务地图信息...");
nCode = GameShare.LocalDb.LoadMapQuest();
if (nCode < 0)
Expand Down
4 changes: 2 additions & 2 deletions src/GameSrv/GameShare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class GameShare
public static readonly long StartTime;
public static readonly WordStatistics Statistics;
public static readonly LocalDb LocalDb;
public static readonly MySqlDB CommonDb;
public static readonly IDataSource DataSource;
public static readonly IPlanesService PlanesService;
public static readonly NetworkMonitor NetworkMonitor;
public static readonly SystemProcessor SystemProcess;
Expand All @@ -34,7 +34,7 @@ static GameShare()
{
Statistics = new WordStatistics();
LocalDb = new LocalDb();
CommonDb = new MySqlDB();
DataSource = new MySqlDB();
NetworkMonitor = new NetworkMonitor();
SystemProcess = new SystemProcessor();
UserProcessor = new UserProcessor();
Expand Down
2 changes: 1 addition & 1 deletion src/GameSrv/Maps/MapQuestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace GameSrv.Maps
public class MapQuestManager
{
public Dictionary<string, Merchant> questDict = new Dictionary<string, Merchant>();
public IList<MapQuestInfo> QuestList = new List<MapQuestInfo>();
private IList<MapQuestInfo> QuestList = new List<MapQuestInfo>();

public bool CreateQuest(int nFlag, int nValue, string sMonName, string sItem, string sQuest, bool boGrouped)
{
Expand Down
4 changes: 2 additions & 2 deletions src/GameSrv/Npc/Merchant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@ private void LoadUpgradeList()
UpgradeWeaponList.Clear();
try
{
MySqlDB.LoadUpgradeWeaponRecord(ScriptName + '-' + MapName, UpgradeWeaponList);
GameShare.DataSource.LoadUpgradeWeaponRecord(ScriptName + '-' + MapName, UpgradeWeaponList);
}
catch
{
Expand All @@ -1706,7 +1706,7 @@ private void SaveUpgradingList()
{
try
{
MySqlDB.SaveUpgradeWeaponRecord(ScriptName + '-' + MapName, UpgradeWeaponList);
GameShare.DataSource.SaveUpgradeWeaponRecord(ScriptName + '-' + MapName, UpgradeWeaponList);
}
catch
{
Expand Down
34 changes: 33 additions & 1 deletion src/M2Server/IDataSource.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
namespace M2Server
using SystemModule.Data;

namespace M2Server
{
public interface IDataSource
{
/// <summary>
/// 读取物品数据
/// </summary>
/// <returns></returns>
public int LoadItemsDB();

/// <summary>
/// 读取技能数据
/// </summary>
/// <returns></returns>
public int LoadMagicDB();

/// <summary>
/// 读取怪物数据
/// </summary>
/// <returns></returns>
int LoadMonsterDB();

/// <summary>
/// 加载寄售系统数据
/// </summary>
void LoadSellOffItemList();

/// <summary>
/// 保存寄售系统数据
/// </summary>
void SaveSellOffItemList();

int LoadUpgradeWeaponRecord(string sNPCName, IList<WeaponUpgradeInfo> DataList);

int SaveUpgradeWeaponRecord(string sNPCName, IList<WeaponUpgradeInfo> DataList);
}
}

0 comments on commit 1847483

Please sign in to comment.