- Login command now supports Offline games. Skips various things that are server related only. - Added a constructor to SaveDataPaths for quickly being able to assign paths. - Game.Start is now Virtual so that scripts may override it. - Game.Start now supports single player games and initializes players within it. - Log now provides a Verbose mode so that Singleplayer games no longer gets flooded with Game startup messages. - BaseCharacter.Initialize() Initialize no longer crashes when called with IsMultiplayer set to false. - BaseCharacter.ReadInput() now supports IsMultiplayer being false. MudServer: - Now supports singleplayer and multiplayer games within a single application. - MudServer is now ready to be re-named to MudGame and will be used for both Offline and Online games.
54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.IO;
|
|
|
|
using MudEngine.FileSystem;
|
|
|
|
namespace MudEngine.GameManagement
|
|
{
|
|
public static class Log
|
|
{
|
|
static List<string> cachedMessages = new List<string>();
|
|
public static Boolean IsVerbose;
|
|
|
|
public static void Write(string message)
|
|
{
|
|
string filename = Path.Combine(FileManager.GetDataPath(SaveDataTypes.Root), "Log.txt");
|
|
StreamWriter sw;
|
|
|
|
if (File.Exists(filename))
|
|
sw = File.AppendText(filename);
|
|
else
|
|
sw = File.CreateText(filename);
|
|
|
|
sw.WriteLine(message);
|
|
sw.Close();
|
|
|
|
//Add to the cache so consoles can get these messages if they want to.
|
|
cachedMessages.Add(message);
|
|
}
|
|
|
|
public static string GetMessages()
|
|
{
|
|
string messages = "";
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
foreach (string message in cachedMessages)
|
|
{
|
|
sb.AppendLine(message);
|
|
}
|
|
|
|
if ((sb.ToString() == "") || (IsVerbose))
|
|
return "";
|
|
else
|
|
return sb.ToString();
|
|
}
|
|
|
|
public static void FlushMessages()
|
|
{
|
|
cachedMessages = new List<string>();
|
|
}
|
|
}
|
|
}
|