From 184748310d00e611e5a2c7e70f1931b5b805e7e1 Mon Sep 17 00:00:00 2001 From: summer Date: Wed, 14 Feb 2024 22:47:40 +0800 Subject: [PATCH] =?UTF-8?q?GameSvr=E6=95=B0=E6=8D=AE=E6=BA=90=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/GameSrv/DB/MySqlDB.cs | 5 ++--- src/GameSrv/GameApp.cs | 8 +++---- src/GameSrv/GameShare.cs | 4 ++-- src/GameSrv/Maps/MapQuestManager.cs | 2 +- src/GameSrv/Npc/Merchant.cs | 4 ++-- src/M2Server/IDataSource.cs | 34 ++++++++++++++++++++++++++++- 6 files changed, 44 insertions(+), 13 deletions(-) diff --git a/src/GameSrv/DB/MySqlDB.cs b/src/GameSrv/DB/MySqlDB.cs index 1f4f9f92..0649d3bd 100644 --- a/src/GameSrv/DB/MySqlDB.cs +++ b/src/GameSrv/DB/MySqlDB.cs @@ -8,7 +8,6 @@ namespace GameSrv.DB { public class MySqlDB : IDataSource { - private IDbConnection _dbConnection; public int LoadItemsDB() @@ -337,13 +336,13 @@ public void SaveSellOffItemList() } } - public static int LoadUpgradeWeaponRecord(string sNPCName, IList DataList) + public int LoadUpgradeWeaponRecord(string sNPCName, IList DataList) { //todo 加载武器升级数据 return -1; } - public static int SaveUpgradeWeaponRecord(string sNPCName, IList DataList) + public int SaveUpgradeWeaponRecord(string sNPCName, IList DataList) { //todo 保存武器升级数据 return -1; diff --git a/src/GameSrv/GameApp.cs b/src/GameSrv/GameApp.cs index 4f0ff040..8cb09b7c 100644 --- a/src/GameSrv/GameApp.cs +++ b/src/GameSrv/GameApp.cs @@ -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}"); @@ -128,7 +128,7 @@ public void Initialize(CancellationToken stoppingToken) return; } LogService.Info("正在加载怪物数据库..."); - nCode = GameShare.CommonDb.LoadMonsterDB(); + nCode = GameShare.DataSource.LoadMonsterDB(); if (nCode < 0) { LogService.Info($"加载怪物数据库失败!!! Code: {nCode}"); @@ -136,7 +136,7 @@ public void Initialize(CancellationToken stoppingToken) } LogService.Info($"加载怪物数据库成功...[{SystemShare.WorldEngine.MonsterCount}]"); LogService.Info("正在加载技能数据库..."); - nCode = GameShare.CommonDb.LoadMagicDB(); + nCode = GameShare.DataSource.LoadMagicDB(); if (nCode < 0) { LogService.Info($"加载技能数据库失败!!! Code: {nCode}"); @@ -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) diff --git a/src/GameSrv/GameShare.cs b/src/GameSrv/GameShare.cs index b4c7899f..0ec710e1 100644 --- a/src/GameSrv/GameShare.cs +++ b/src/GameSrv/GameShare.cs @@ -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; @@ -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(); diff --git a/src/GameSrv/Maps/MapQuestManager.cs b/src/GameSrv/Maps/MapQuestManager.cs index bf14204b..6b9d05c4 100644 --- a/src/GameSrv/Maps/MapQuestManager.cs +++ b/src/GameSrv/Maps/MapQuestManager.cs @@ -5,7 +5,7 @@ namespace GameSrv.Maps public class MapQuestManager { public Dictionary questDict = new Dictionary(); - public IList QuestList = new List(); + private IList QuestList = new List(); public bool CreateQuest(int nFlag, int nValue, string sMonName, string sItem, string sQuest, bool boGrouped) { diff --git a/src/GameSrv/Npc/Merchant.cs b/src/GameSrv/Npc/Merchant.cs index 4c885289..2231d6aa 100644 --- a/src/GameSrv/Npc/Merchant.cs +++ b/src/GameSrv/Npc/Merchant.cs @@ -1694,7 +1694,7 @@ private void LoadUpgradeList() UpgradeWeaponList.Clear(); try { - MySqlDB.LoadUpgradeWeaponRecord(ScriptName + '-' + MapName, UpgradeWeaponList); + GameShare.DataSource.LoadUpgradeWeaponRecord(ScriptName + '-' + MapName, UpgradeWeaponList); } catch { @@ -1706,7 +1706,7 @@ private void SaveUpgradingList() { try { - MySqlDB.SaveUpgradeWeaponRecord(ScriptName + '-' + MapName, UpgradeWeaponList); + GameShare.DataSource.SaveUpgradeWeaponRecord(ScriptName + '-' + MapName, UpgradeWeaponList); } catch { diff --git a/src/M2Server/IDataSource.cs b/src/M2Server/IDataSource.cs index 316619f4..2a9d535a 100644 --- a/src/M2Server/IDataSource.cs +++ b/src/M2Server/IDataSource.cs @@ -1,7 +1,39 @@ -namespace M2Server +using SystemModule.Data; + +namespace M2Server { public interface IDataSource { + /// + /// 读取物品数据 + /// + /// + public int LoadItemsDB(); + + /// + /// 读取技能数据 + /// + /// + public int LoadMagicDB(); + + /// + /// 读取怪物数据 + /// + /// + int LoadMonsterDB(); + + /// + /// 加载寄售系统数据 + /// + void LoadSellOffItemList(); + + /// + /// 保存寄售系统数据 + /// + void SaveSellOffItemList(); + + int LoadUpgradeWeaponRecord(string sNPCName, IList DataList); + int SaveUpgradeWeaponRecord(string sNPCName, IList DataList); } }