Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

ContentDir can now be set correctly in both the realmserver and the t…

…ools

Renamed a bunch of fields and properties
WCELL-11#close fixed #comment ContentDir can now be set correctly
  • Loading branch information...
commit 884969aa0977254344928ab4a9380486f79f80ee 1 parent e871c53
David Thompson authored December 14, 2011
2  Services/WCell.RealmServer/Achievements/AchievementProgressRecord.cs
@@ -41,7 +41,7 @@ public static AchievementProgressRecord CreateAchievementProgressRecord(Characte
41 41
 			}
42 42
 			catch (Exception ex)
43 43
 			{
44  
-				s_log.Error("AchievementProgressRecord creation error (DBS: " + RealmServerConfiguration.DBType + "): ", ex);
  44
+				s_log.Error("AchievementProgressRecord creation error (DBS: " + RealmServerConfiguration.DatabaseType + "): ", ex);
45 45
 				record = null;
46 46
 			}
47 47
 
2  Services/WCell.RealmServer/Achievements/AchievementRecord.cs
@@ -37,7 +37,7 @@ public static AchievementRecord CreateNewAchievementRecord(Character chr, uint a
37 37
 			}
38 38
 			catch (Exception ex)
39 39
 			{
40  
-				s_log.ErrorException("AchievementRecord creation error (DBS: " + RealmServerConfiguration.DBType + "): ", ex);
  40
+				s_log.ErrorException("AchievementRecord creation error (DBS: " + RealmServerConfiguration.DatabaseType + "): ", ex);
41 41
 				record = null;
42 42
 			}
43 43
 
2  Services/WCell.RealmServer/Database/CharacterRecord.cs
@@ -82,7 +82,7 @@ public static CharacterRecord CreateNewCharacterRecord(RealmAccount account, str
82 82
 			}
83 83
 			catch (Exception ex)
84 84
 			{
85  
-				s_log.Error("Character creation error (DBS: " + RealmServerConfiguration.DBType + "): ", ex);
  85
+				s_log.Error("Character creation error (DBS: " + RealmServerConfiguration.DatabaseType + "): ", ex);
86 86
 				record = null;
87 87
 			}
88 88
 
2  Services/WCell.RealmServer/Database/RealmDBMgr.cs
@@ -33,7 +33,7 @@ public static bool Initialize()
33 33
 				Initialized = true;
34 34
 				DatabaseUtil.DBErrorHook = exception => CharacterRecord.GetCount() < 100;
35 35
 
36  
-				DatabaseUtil.DBType = RealmServerConfiguration.DBType;
  36
+				DatabaseUtil.DBType = RealmServerConfiguration.DatabaseType;
37 37
 				DatabaseUtil.ConnectionString = RealmServerConfiguration.DBConnectionString;
38 38
 				DatabaseUtil.DefaultCharset = DefaultCharset;
39 39
 
123  Services/WCell.RealmServer/RealmServerConfiguration.cs
@@ -43,17 +43,13 @@ namespace WCell.RealmServer
43 43
 	[XmlRoot("WCellConfig")]
44 44
 	public class RealmServerConfiguration : WCellConfig<RealmServerConfiguration>
45 45
 	{
46  
-		private static readonly Logger log = LogManager.GetCurrentClassLogger();
  46
+		private static readonly Logger Log = LogManager.GetCurrentClassLogger();
47 47
 
48 48
 		private const string ConfigFilename = "RealmServerConfig.xml";
49 49
 
50  
-		private static RealmServerConfiguration s_instance;
51  
-		public static RealmServerConfiguration Instance
52  
-		{
53  
-			get { return s_instance; }
54  
-		}
  50
+	    public static RealmServerConfiguration Instance { get; private set; }
55 51
 
56  
-		public override string FilePath
  52
+	    public override string FilePath
57 53
 		{
58 54
 			get { return GetFullPath(ConfigFilename); }
59 55
 			set
@@ -64,7 +60,7 @@ public override string FilePath
64 60
 
65 61
 		public static readonly string BinaryRoot = "../";
66 62
 
67  
-		private static string contentDirName = BinaryRoot + "Content/";
  63
+		private static string _contentDirName = BinaryRoot + "Content/";
68 64
 
69 65
 		public readonly static HashSet<string> BadWords = new HashSet<string>();
70 66
 
@@ -75,14 +71,14 @@ public override bool AutoSave
75 71
 			set;
76 72
 		}
77 73
 
78  
-		private static bool m_Loaded;
  74
+		private static bool _loaded;
79 75
 
80 76
 		public static bool Loaded
81 77
 		{
82  
-			get { return m_Loaded; }
  78
+			get { return _loaded; }
83 79
 			protected set
84 80
 			{
85  
-				m_Loaded = value;
  81
+				_loaded = value;
86 82
 				RealmServ.Instance.SetTitle("{0} - {1} ...", RealmServ.Instance, RealmLocalizer.Instance.Translate(DefaultLocale, RealmLangKey.Initializing));
87 83
 			}
88 84
 		}
@@ -94,14 +90,14 @@ public static string LangDir
94 90
 			get { return GetContentPath(LangDirName) + "/"; }
95 91
 		}
96 92
 
97  
-		private static ClientLocale defaultLocale = ClientLocale.English;
  93
+		private static ClientLocale _defaultLocale = ClientLocale.English;
98 94
 
99 95
 		public static ClientLocale DefaultLocale
100 96
 		{
101  
-			get { return defaultLocale; }
  97
+			get { return _defaultLocale; }
102 98
 			set
103 99
 			{
104  
-				defaultLocale = value;
  100
+				_defaultLocale = value;
105 101
 				WCellConstants.DefaultLocale = value;
106 102
 			}
107 103
 		}
@@ -114,23 +110,23 @@ public static bool Initialize()
114 110
 				Loaded = true;
115 111
 				BadWordString = "";
116 112
 
117  
-				s_instance.AddVariablesOfAsm<VariableAttribute>(typeof(RealmServerConfiguration).Assembly);
  113
+				Instance.AddVariablesOfAsm<VariableAttribute>(typeof(RealmServerConfiguration).Assembly);
118 114
 				//s_instance = Load(RealmServerConfiguration.ConfigPath);
119 115
 				try
120 116
 				{
121  
-					if (!s_instance.Load())
  117
+					if (!Instance.Load())
122 118
 					{
123  
-						s_instance.Save(true, false);
124  
-						log.Warn("Config-file \"{0}\" not found - Created new file.", Instance.FilePath);
125  
-						log.Warn("Please take a little time to configure your server and then restart the Application.");
126  
-						log.Warn("See http://wiki.wcell.org/index.php/Configuration for more information.");
  119
+						Instance.Save(true, false);
  120
+						Log.Warn("Config-file \"{0}\" not found - Created new file.", Instance.FilePath);
  121
+						Log.Warn("Please take a little time to configure your server and then restart the Application.");
  122
+						Log.Warn("See http://wiki.wcell.org/index.php/Configuration for more information.");
127 123
 						return false;
128 124
 					}
129 125
 				}
130 126
 				catch (Exception e)
131 127
 				{
132 128
 					LogUtil.ErrorException(e, "Unable to load Configuration.");
133  
-					log.Error("Please correct the invalid values in your configuration file and restart the Applicaton.");
  129
+					Log.Error("Please correct the invalid values in your configuration file and restart the Applicaton.");
134 130
 					return false;
135 131
 				}
136 132
 			}
@@ -142,38 +138,34 @@ public static bool Initialize()
142 138
 		[Initialization(InitializationPass.Fifth)]
143 139
 		public static void InitializeRoles()
144 140
 		{
145  
-			foreach (var def in s_instance.Definitions.Values)
146  
-			{
147  
-				//def.Initialize();
148  
-			}
149 141
 		}
150 142
 
151 143
 		[Initialization(InitializationPass.Last)]
152 144
 		public static void PerformAutoSave()
153 145
 		{
154  
-			if (s_instance.AutoSave)
  146
+			if (Instance.AutoSave)
155 147
 			{
156  
-				s_instance.Save(true, true);
  148
+				Instance.Save(true, true);
157 149
 			}
158 150
 		}
159 151
 
160 152
 		internal static void OnError(string msg)
161 153
 		{
162  
-			log.Warn("<Config>" + msg);
  154
+			Log.Warn("<Config>" + msg);
163 155
 		}
164 156
 
165 157
 		internal static void OnError(string msg, params object[] args)
166 158
 		{
167  
-			log.Warn("<Config>" + String.Format(msg, args));
  159
+			Log.Warn("<Config>" + String.Format(msg, args));
168 160
 		}
169 161
 
170  
-		private readonly AppConfig m_cfg;
  162
+		private readonly AppConfig _cfg;
171 163
 
172 164
 		protected RealmServerConfiguration()
173 165
 			: base(OnError)
174 166
 		{
175 167
 			RootNodeName = "WCellConfig";
176  
-			s_instance = this;
  168
+			Instance = this;
177 169
 		}
178 170
 
179 171
 		/// <summary>
@@ -183,7 +175,7 @@ protected RealmServerConfiguration()
183 175
 		public RealmServerConfiguration(string executablePath)
184 176
 			: this()
185 177
 		{
186  
-			m_cfg = new AppConfig(executablePath);
  178
+			_cfg = new AppConfig(executablePath);
187 179
 		}
188 180
 
189 181
 		/// <summary>
@@ -201,17 +193,17 @@ public RealmServerConfiguration(string executablePath)
201 193
 		/// </summary>
202 194
 		public static int Port = 8085;
203 195
 
204  
-		private static string realmName = "Change the RealmName in the Config!";
  196
+		private static string _realmName = "Change the RealmName in the Config!";
205 197
 
206 198
 		/// <summary>
207 199
 		/// The name of this server
208 200
 		/// </summary>
209 201
 		public static string RealmName
210 202
 		{
211  
-			get { return realmName; }
  203
+			get { return _realmName; }
212 204
 			set
213 205
 			{
214  
-				realmName = value;
  206
+				_realmName = value;
215 207
 				if (RealmServ.Instance.IsRunning)
216 208
 				{
217 209
 					RealmServ.Instance.SetTitle(RealmServ.Instance.ToString());
@@ -225,19 +217,19 @@ public static string RealmName
225 217
 		/// </summary>
226 218
 		//public static string ConfigDir = "cfg";
227 219
 
228  
-		private static RealmServerType serverType = RealmServerType.PVP;
  220
+		private static RealmServerType _serverType = RealmServerType.PVP;
229 221
 
230 222
 		/// <summary>
231 223
 		/// Type of server
232 224
 		/// </summary>
233 225
 		public static RealmServerType ServerType
234 226
 		{
235  
-			get { return serverType; }
  227
+			get { return _serverType; }
236 228
 			set
237 229
 			{
238  
-				if (serverType != value)
  230
+				if (_serverType != value)
239 231
 				{
240  
-					serverType = value;
  232
+					_serverType = value;
241 233
 					if (RealmServ.Instance.IsRunning)
242 234
 					{
243 235
 						RealmServ.Instance.UpdateRealm();
@@ -246,20 +238,20 @@ public static RealmServerType ServerType
246 238
 			}
247 239
 		}
248 240
 
249  
-		private static RealmStatus status = RealmStatus.Open;
  241
+		private static RealmStatus _status = RealmStatus.Open;
250 242
 
251 243
 		/// <summary>
252 244
 		/// The status can be Open or Locked (a Locked Realm can only be accessed by Staff members)
253 245
 		/// </summary>
254 246
 		public static RealmStatus Status
255 247
 		{
256  
-			get { return status; }
  248
+			get { return _status; }
257 249
 			set
258 250
 			{
259  
-				if (status != value)
  251
+				if (_status != value)
260 252
 				{
261  
-					var oldStatus = status;
262  
-					status = value;
  253
+					var oldStatus = _status;
  254
+					_status = value;
263 255
 					if (RealmServ.Instance.IsRunning)
264 256
 					{
265 257
 						RealmServ.Instance.OnStatusChange(oldStatus);
@@ -268,17 +260,17 @@ public static RealmStatus Status
268 260
 			}
269 261
 		}
270 262
 
271  
-		private static RealmCategory category = RealmCategory.Development;
  263
+		private static RealmCategory _category = RealmCategory.Development;
272 264
 
273 265
 		/// <summary>
274 266
 		/// The Category of this RealmServer
275 267
 		/// </summary>
276 268
 		public static RealmCategory Category
277 269
 		{
278  
-			get { return category; }
  270
+			get { return _category; }
279 271
 			set
280 272
 			{
281  
-				category = value;
  273
+				_category = value;
282 274
 				if (RealmServ.Instance.IsRunning)
283 275
 				{
284 276
 					RealmServ.Instance.UpdateRealm();
@@ -286,17 +278,17 @@ public static RealmCategory Category
286 278
 			}
287 279
 		}
288 280
 
289  
-		private static RealmFlags flags = RealmFlags.Recommended;
  281
+		private static RealmFlags _flags = RealmFlags.Recommended;
290 282
 
291 283
 		/// <summary>
292 284
 		/// The flags of this RealmServer
293 285
 		/// </summary>
294 286
 		public static RealmFlags Flags
295 287
 		{
296  
-			get { return flags; }
  288
+			get { return _flags; }
297 289
 			set
298 290
 			{
299  
-				flags = value;
  291
+				_flags = value;
300 292
 				if (RealmServ.Instance.IsRunning)
301 293
 				{
302 294
 					RealmServ.Instance.UpdateRealm();
@@ -321,7 +313,7 @@ public static string BadWordString
321 313
 			}
322 314
 		}
323 315
 
324  
-		private static bool registerExternalAddress;
  316
+		private static bool _registerExternalAddress;
325 317
 
326 318
 		/// <summary>
327 319
 		/// Whether or not to try and register the outside-most IP this computer
@@ -329,10 +321,10 @@ public static string BadWordString
329 321
 		/// </summary>
330 322
 		public static bool RegisterExternalAddress
331 323
 		{
332  
-			get { return registerExternalAddress; }
  324
+			get { return _registerExternalAddress; }
333 325
 			set
334 326
 			{
335  
-				registerExternalAddress = value;
  327
+				_registerExternalAddress = value;
336 328
 				if (RealmServ.Instance.IsRunning)
337 329
 				{
338 330
 					RealmServ.Instance.UpdateRealm();
@@ -343,9 +335,9 @@ public static bool RegisterExternalAddress
343 335
 		/// <summary>
344 336
 		/// The type of database we're connecting to. (e.g. MySQL, mssql2005, Oracle, etc)
345 337
 		/// </summary>
346  
-		public static string DBType = "mysql5";
  338
+		public static string DatabaseType = "mysql5";
347 339
 
348  
-		private static string dbConnectionString = @"Server=127.0.0.1;Port=3306;Database=WCellRealmServer;CharSet=utf8;Uid=root;Pwd=;";
  340
+		private static string _dbConnectionString = @"Server=127.0.0.1;Port=3306;Database=WCellRealmServer;CharSet=utf8;Uid=root;Pwd=;";
349 341
 
350 342
 		/// <summary>
351 343
 		/// The connection string for the authentication server database.
@@ -353,8 +345,8 @@ public static bool RegisterExternalAddress
353 345
 		[Variable(IsFileOnly = true)]
354 346
 		public static string DBConnectionString
355 347
 		{
356  
-			get { return dbConnectionString; }
357  
-			set { dbConnectionString = value; }
  348
+			get { return _dbConnectionString; }
  349
+			set { _dbConnectionString = value; }
358 350
 		}
359 351
 
360 352
 		/// <summary>
@@ -392,7 +384,7 @@ public static string DBConnectionString
392 384
 		/// </summary>
393 385
 		public static int CompressionLevel = 7;
394 386
 
395  
-		private static float ingameMinutePerSecond = 0.0166666666666f;
  387
+		private static float _ingameMinutePerSecond = 0.0166666666666f;
396 388
 
397 389
 		/// <summary>
398 390
 		/// The speed of time in ingame minute per real-time second.
@@ -402,7 +394,7 @@ public static string DBConnectionString
402 394
 		[Variable("TimeSpeed")]
403 395
 		public static float IngameMinutesPerSecond
404 396
 		{
405  
-			get { return ingameMinutePerSecond; }
  397
+			get { return _ingameMinutePerSecond; }
406 398
 			set
407 399
 			{
408 400
 				if (value > 60)
@@ -415,7 +407,7 @@ public static float IngameMinutesPerSecond
415 407
 				{
416 408
 					// make sure to reset before changing the speed
417 409
 					RealmServ.ResetTimeStart();
418  
-					ingameMinutePerSecond = value;
  410
+					_ingameMinutePerSecond = value;
419 411
 					foreach (var chr in World.GetAllCharacters())
420 412
 					{
421 413
 						CharacterHandler.SendTimeSpeed(chr);
@@ -423,7 +415,7 @@ public static float IngameMinutesPerSecond
423 415
 				}
424 416
 				else
425 417
 				{
426  
-					ingameMinutePerSecond = value;
  418
+					_ingameMinutePerSecond = value;
427 419
 				}
428 420
 			}
429 421
 		}
@@ -435,13 +427,13 @@ public static float IngameMinutesPerSecond
435 427
 		[Variable("ContentDir")]
436 428
 		public static string ContentDirName
437 429
 		{
438  
-			get { return contentDirName; }
439  
-			set { contentDirName = value; }
  430
+			get { return _contentDirName; }
  431
+			set { _contentDirName = value; }
440 432
 		}
441 433
 
442 434
 		public static string ContentDir
443 435
 		{
444  
-			get { return GetFullPath(contentDirName); }
  436
+			get { return GetFullPath(ContentDirName); }
445 437
 		}
446 438
 
447 439
 		public static string DBCFolderName = "dbc" + WCellInfo.RequiredVersion.BasicString;
@@ -494,7 +486,8 @@ public static string GetFullPath(string file)
494 486
 		{
495 487
 			if (!Path.IsPathRooted(file))
496 488
 			{
497  
-				return Path.Combine(s_instance.m_cfg.ExecutableFile.Directory.FullName, file);
  489
+			    if (Instance._cfg.ExecutableFile.Directory != null)
  490
+			        return Path.Combine(Instance._cfg.ExecutableFile.Directory.FullName, file);
498 491
 			}
499 492
 			return file;
500 493
 		}
13  Utilities/WCell.Tools/ToolConfig.cs
@@ -28,7 +28,18 @@ public class ToolConfig : XmlFile<ToolConfig>
28 28
 		public static string RealmServerRoot { get { return ServicesRoot + "WCell.RealmServer/"; } }
29 29
 		public static string AuthServerRoot { get { return ServicesRoot + "WCell.AuthServer/"; } }
30 30
 		public static string RunDir { get { return WCellRoot + "Run/"; } }
31  
-		public static string ContentDir { get { return RunDir + "Content/"; } }
  31
+        public static string ContentDir
  32
+        { 
  33
+            get 
  34
+            { 
  35
+                return _contentDir;
  36
+            }
  37
+            set
  38
+            {
  39
+                _contentDir = value;
  40
+            }
  41
+        }
  42
+        private static string _contentDir = RunDir + "Content/";
32 43
 		public static string MapDir { get { return ContentDir + "Maps/"; } }
33 44
 		public static string WMODir { get { return ContentDir + "Maps/"; } }
34 45
 		public static string M2Dir { get { return ContentDir + "Maps/"; } }
16  Utilities/WCell.Tools/Tools.cs
@@ -57,7 +57,7 @@ public class Tools
57 57
 	{
58 58
 		public static readonly ToolMgr Mgr = new ToolMgr();
59 59
 
60  
-		private static readonly Logger log = LogManager.GetCurrentClassLogger();
  60
+		private static readonly Logger Log = LogManager.GetCurrentClassLogger();
61 61
 		public static ToolConfig Config;
62 62
 
63 63
 		/// <summary>
@@ -83,7 +83,7 @@ public static bool Init(string toolsRoot, params Assembly[] assemblies)
83 83
 
84 84
 			LogUtil.SetupConsoleLogging();
85 85
 
86  
-			Console.WriteLine("Output Directory: " + new DirectoryInfo(ToolConfig.OutputDir).FullName);
  86
+			Log.Info("Output Directory: {0}", new DirectoryInfo(ToolConfig.OutputDir).FullName);
87 87
 			if (!Directory.Exists(ToolConfig.OutputDir))
88 88
 			{
89 89
 				Directory.CreateDirectory(ToolConfig.OutputDir);
@@ -94,12 +94,12 @@ public static bool Init(string toolsRoot, params Assembly[] assemblies)
94 94
 			RealmServerConfiguration.Initialize();
95 95
 			RealmAddonMgr.AddonDir = ToolConfig.AddonDir;
96 96
 
97  
-			Console.WriteLine("Content Directory: " + new DirectoryInfo(RealmServerConfiguration.ContentDir).FullName);
  97
+            Log.Info("Content Directory: " + new DirectoryInfo(RealmServerConfiguration.ContentDir).FullName);
98 98
 
99 99
 			if (!InitMgr.Initialize(typeof(Tools).Assembly) ||
100 100
 				!InitMgr.Initialize(typeof(PacketAnalyzer).Assembly))
101 101
 			{
102  
-				log.Error("Cancelled - Press any key to exit...");
  102
+				Log.Error("Cancelled - Press any key to exit...");
103 103
 				Console.ReadKey();
104 104
 				return false;
105 105
 			}
@@ -108,7 +108,7 @@ public static bool Init(string toolsRoot, params Assembly[] assemblies)
108 108
 			{
109 109
 				if (!InitMgr.Initialize(asm))
110 110
 				{
111  
-					log.Error("Unable to initialize Assembly: \"{0}\" - Press any key to exit...", asm);
  111
+					Log.Error("Unable to initialize Assembly: \"{0}\" - Press any key to exit...", asm);
112 112
 					return false;
113 113
 				}
114 114
 				ToolCommandHandler.Instance.AddCmdsOfAsm(asm);
@@ -175,10 +175,10 @@ public static void StartCommandLine()
175 175
 			Console.WriteLine(" to quit");
176 176
 
177 177
 			var defaultTrigger = new ToolCommandHandler.ConsoleCmdTrigger(new ToolCmdArgs());
178  
-			string line;
179  
-			do
  178
+		    do
180 179
 			{
181  
-				try
  180
+			    string line;
  181
+			    try
182 182
 				{
183 183
 					line = Console.ReadLine();
184 184
 				}

0 notes on commit 884969a

Please sign in to comment.
Something went wrong with that request. Please try again.