So I started toying with creating my own mud server modeled after the mud Majormud. Yeah there is greatermud, but it has the same issue as with all mud recreates it uses the old telnet ansi, vt-100 protocols. So I decided I wanted to make the server and the client at the same time BUT the client can be created by anyone as well for custom interfaces.
I created a library file that is imported and shares the class data between the client and the server to allow for easy character information transfer.
Right now I can effectively serialize game data into a byte array that is transmitted to the client and then de-serialized back into the class structure from the server. To me this seems much simpler than encoding all the vt-100 and ansi protocol information since we have really moved away from that technology but still want to play those fun mud games:)
Here is a snippet of the code to show how simplistic it is / can be.
Right now I have the capability to chat with other uses and provide player data such as position, hitpoints, mana and such no real logic yet.
Server side code serializing the player data.
On the client side the data is simply deserialized and displayed, no need for parsing or interpreting.
Now I realize this removes the use of telnet clients, so is this a taboo thing or kinda removes the feel of a mud?
I created a library file that is imported and shares the class data between the client and the server to allow for easy character information transfer.
Right now I can effectively serialize game data into a byte array that is transmitted to the client and then de-serialized back into the class structure from the server. To me this seems much simpler than encoding all the vt-100 and ansi protocol information since we have really moved away from that technology but still want to play those fun mud games:)
Here is a snippet of the code to show how simplistic it is / can be.
Right now I have the capability to chat with other uses and provide player data such as position, hitpoints, mana and such no real logic yet.
Server side code serializing the player data.
private void TransmitServerDataProc()
{
byte[] genericRead = new byte[1024];
GameSharedData.SharedMemory.CommunicationType communication = new GameSharedData.SharedMemory.CommunicationType();
try
{
while (true)
{
if (PlayersConnected.Count > 0)
{
if (CommunicationManager.ChatLog.Count > 0)
{
communication = new GameSharedData.SharedMemory.CommunicationType();
communication = CommunicationManager.ChatLog.Dequeue();
}
foreach (KeyValuePair<int, PlayerConnectionType> players in PlayersConnected)
{
if (communication.Data != null)
{
PlayerManager.PlayerData[players.Key].PlayerChat = communication;
}
byte[] playerData = ServerUtilities.SerializeToStream(PlayerManager.PlayerData[players.Value.PlayerID]).ToArray();
// If the player has a command incoming lets read it.
if (players.Value.playerStream.DataAvailable)
{
int commandBytesRead = players.Value.playerStream.Read(genericRead, 0, genericRead.Length);
ReadCommand(genericRead, commandBytesRead);
}
try
{
players.Value.playerStream.Write(playerData, 0, playerData.Length);
}
catch { RemovePlayerOnline(players.Value); break; }
//Cleanup
PlayerManager.PlayerData[players.Key].PlayerChat = null;
}
communication = new GameSharedData.SharedMemory.CommunicationType();
Thread.Sleep(100);
}
else
{
Thread.Sleep(1000);
}
}
}
catch { }
}
On the client side the data is simply deserialized and displayed, no need for parsing or interpreting.
GameSharedData.SharedMemory.GameDataType gameData = (GameSharedData.SharedMemory.GameDataType)DeserializeFromStream(ms);
App.Current.Dispatcher.BeginInvoke(new Action(delegate
{
_inputGUI.txtPlayerName.Text = gameData.CurrentPlayer.PlayerFirstName;
_inputGUI.manaBar.Maximum = gameData.CurrentPlayer.MaximumManaPoints;
_inputGUI.manaBar.Value = gameData.CurrentPlayer.ManaPoints;
_inputGUI.healthBar.Maximum = gameData.CurrentPlayer.MaximumHitPoints;
_inputGUI.healthBar.Value = gameData.CurrentPlayer.HitPoints;
_inputGUI.experienceBar.Maximum = gameData.CurrentPlayer.ExperienceTilNextLevel;
_inputGUI.experienceBar.Value = gameData.CurrentPlayer.CurrentPlayerExperience;
try
{
if (gameData.PlayerChat.Data != null)
{
if (gameData.PlayerChat != null && gameData.PlayerChat.Data.Length > 0)
{
_inputGUI.txtCurrentStatus.Text += (gameData.PlayerChat.PlayerName + " " + gameData.PlayerChat.PlayerChat.ToString() + " : " + gameData.PlayerChat.Data + "\r\n");
}
}
}
catch { }
}));
Now I realize this removes the use of telnet clients, so is this a taboo thing or kinda removes the feel of a mud?