diff --git a/Substrate/SubstrateCS/Examples/Examples.sln b/Substrate/SubstrateCS/Examples/Examples.sln
index 45c749a..64a7d8c 100644
--- a/Substrate/SubstrateCS/Examples/Examples.sln
+++ b/Substrate/SubstrateCS/Examples/Examples.sln
@@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GiveItem", "GiveItem\GiveIt
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoveSpawn", "MoveSpawn\MoveSpawn.csproj", "{15C04C0C-FD50-47E9-B62C-AA0A814189ED}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Skyscraper", "Skyscraper\Skyscraper.csproj", "{83F55F54-7253-4B4D-BC37-E9D1CB63E0B8}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Relight", "Relight\Relight.csproj", "{EBDD447B-01FA-4A29-B4AB-380EC4379B5F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Maze", "Maze\Maze.csproj", "{62D70576-FE3A-4530-B283-889C14B52E9E}"
@@ -81,16 +79,6 @@ Global
{15C04C0C-FD50-47E9-B62C-AA0A814189ED}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{15C04C0C-FD50-47E9-B62C-AA0A814189ED}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{15C04C0C-FD50-47E9-B62C-AA0A814189ED}.Release|x86.ActiveCfg = Release|Any CPU
- {83F55F54-7253-4B4D-BC37-E9D1CB63E0B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {83F55F54-7253-4B4D-BC37-E9D1CB63E0B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {83F55F54-7253-4B4D-BC37-E9D1CB63E0B8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {83F55F54-7253-4B4D-BC37-E9D1CB63E0B8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {83F55F54-7253-4B4D-BC37-E9D1CB63E0B8}.Debug|x86.ActiveCfg = Debug|Any CPU
- {83F55F54-7253-4B4D-BC37-E9D1CB63E0B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {83F55F54-7253-4B4D-BC37-E9D1CB63E0B8}.Release|Any CPU.Build.0 = Release|Any CPU
- {83F55F54-7253-4B4D-BC37-E9D1CB63E0B8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {83F55F54-7253-4B4D-BC37-E9D1CB63E0B8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {83F55F54-7253-4B4D-BC37-E9D1CB63E0B8}.Release|x86.ActiveCfg = Release|Any CPU
{EBDD447B-01FA-4A29-B4AB-380EC4379B5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EBDD447B-01FA-4A29-B4AB-380EC4379B5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EBDD447B-01FA-4A29-B4AB-380EC4379B5F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
diff --git a/Substrate/SubstrateCS/Examples/GiveItem/GiveItem.csproj b/Substrate/SubstrateCS/Examples/GiveItem/GiveItem.csproj
new file mode 100644
index 0000000..a976990
--- /dev/null
+++ b/Substrate/SubstrateCS/Examples/GiveItem/GiveItem.csproj
@@ -0,0 +1,56 @@
+
+
+
+ Debug
+ AnyCPU
+ 9.0.30729
+ 2.0
+ {426B01F4-B0C0-488E-8A5A-5531C8DFA98C}
+ Exe
+ Properties
+ GiveItem
+ GiveItem
+ v4.0
+ 512
+
+
+
+
+ 3.5
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\..\bin\Release\Substrate.dll
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Substrate/SubstrateCS/Examples/GiveItem/Program.cs b/Substrate/SubstrateCS/Examples/GiveItem/Program.cs
new file mode 100644
index 0000000..1f58170
--- /dev/null
+++ b/Substrate/SubstrateCS/Examples/GiveItem/Program.cs
@@ -0,0 +1,53 @@
+using System;
+using Substrate;
+
+// This example will insert x amount of an item into a player's
+// inventory in an SMP server (where there is a player directory)
+
+namespace GiveItem
+{
+ class Program
+ {
+ static void Main (string[] args)
+ {
+ if (args.Length != 4) {
+ Console.WriteLine("Usage: GiveItem ");
+ return;
+ }
+
+ string dest = args[0];
+ string player = args[1];
+ int itemid = Convert.ToInt32(args[2]);
+ int count = Convert.ToInt32(args[3]);
+
+ // Open the world and grab its player manager
+ BetaWorld world = BetaWorld.Open(dest);
+ PlayerManager pm = world.GetPlayerManager();
+
+ // Check that the named player exists
+ if (!pm.PlayerExists(player)) {
+ Console.WriteLine("No such player {0}!", player);
+ return;
+ }
+
+ // Get player (returned object is independent of the playermanager)
+ Player p = pm.GetPlayer(player);
+
+ // Find first slot to place item
+ for (int i = 0; i < p.Items.Capacity; i++) {
+ if (!p.Items.ItemExists(i)) {
+ // Create the item and set its stack count
+ Item item = new Item(itemid);
+ item.Count = count;
+ p.Items[i] = item;
+
+ // Don't keep adding items
+ break;
+ }
+ }
+
+ // Save the player
+ pm.SetPlayer(player, p);
+ }
+ }
+}
diff --git a/Substrate/SubstrateCS/Examples/GiveItem/Properties/AssemblyInfo.cs b/Substrate/SubstrateCS/Examples/GiveItem/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..a9c771c
--- /dev/null
+++ b/Substrate/SubstrateCS/Examples/GiveItem/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("GiveItem")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("GiveItem")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("f1f9e364-dc96-4cce-b23d-42bc1234322d")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Substrate/SubstrateCS/Source/PlayerFile.cs b/Substrate/SubstrateCS/Source/PlayerFile.cs
index ae86c91..59b5ac0 100644
--- a/Substrate/SubstrateCS/Source/PlayerFile.cs
+++ b/Substrate/SubstrateCS/Source/PlayerFile.cs
@@ -16,6 +16,10 @@ namespace Substrate
public PlayerFile (string path, string name)
: base("")
{
+ if (!Directory.Exists(path)) {
+ Directory.CreateDirectory(path);
+ }
+
string file = name + ".dat";
_filename = Path.Combine(path, file);
}
diff --git a/Substrate/SubstrateCS/Source/TileEntities/TileEntitySign.cs b/Substrate/SubstrateCS/Source/TileEntities/TileEntitySign.cs
index cf49df8..6a622ff 100644
--- a/Substrate/SubstrateCS/Source/TileEntities/TileEntitySign.cs
+++ b/Substrate/SubstrateCS/Source/TileEntities/TileEntitySign.cs
@@ -25,25 +25,25 @@ namespace Substrate.TileEntities
public string Text1
{
get { return _text1; }
- set { _text1 = value.Substring(0, 12); }
+ set { _text1 = value.Substring(0, 14); }
}
public string Text2
{
get { return _text2; }
- set { _text2 = value.Substring(0, 12); }
+ set { _text2 = value.Substring(0, 14); }
}
public string Text3
{
get { return _text3; }
- set { _text3 = value.Substring(0, 12); }
+ set { _text3 = value.Substring(0, 14); }
}
public string Text4
{
get { return _text4; }
- set { _text4 = value.Substring(0, 12); }
+ set { _text4 = value.Substring(0, 14); }
}
public TileEntitySign ()
diff --git a/Substrate/SubstrateCS/Source/World.cs b/Substrate/SubstrateCS/Source/World.cs
index 79aebd7..a253a77 100644
--- a/Substrate/SubstrateCS/Source/World.cs
+++ b/Substrate/SubstrateCS/Source/World.cs
@@ -26,10 +26,13 @@ namespace Substrate
IChunkManager GetChunkManager ();
IChunkManager GetChunkManager (int dim);
+
+ PlayerManager GetPlayerManager ();
}
public class AlphaWorld : INBTWorld
{
+ private const string _PLAYER_DIR = "players";
protected string _path;
protected string _levelFile = "level.dat";
@@ -38,6 +41,8 @@ namespace Substrate
private Dictionary _chunkMgrs;
private Dictionary _blockMgrs;
+ private PlayerManager _playerMan;
+
private AlphaWorld ()
{
_chunkMgrs = new Dictionary();
@@ -76,6 +81,18 @@ namespace Substrate
return _chunkMgrs[dim];
}
+ public PlayerManager GetPlayerManager ()
+ {
+ if (_playerMan != null) {
+ return _playerMan;
+ }
+
+ string path = Path.Combine(_path, _PLAYER_DIR);
+
+ _playerMan = new PlayerManager(path);
+ return _playerMan;
+ }
+
public static AlphaWorld Open (string path)
{
return new AlphaWorld().OpenWorld(path) as AlphaWorld;
@@ -205,6 +222,7 @@ namespace Substrate
public class BetaWorld : INBTWorld {
private const string _REGION_DIR = "region";
+ private const string _PLAYER_DIR = "players";
protected string _path;
protected string _levelFile = "level.dat";
@@ -214,6 +232,8 @@ namespace Substrate
private Dictionary _chunkMgrs;
private Dictionary _blockMgrs;
+ private PlayerManager _playerMan;
+
private BetaWorld ()
{
_regionMgrs = new Dictionary();
@@ -269,6 +289,18 @@ namespace Substrate
return _regionMgrs[dim];
}
+ public PlayerManager GetPlayerManager ()
+ {
+ if (_playerMan != null) {
+ return _playerMan;
+ }
+
+ string path = Path.Combine(_path, _PLAYER_DIR);
+
+ _playerMan = new PlayerManager(path);
+ return _playerMan;
+ }
+
public static BetaWorld Open (string path)
{
return new BetaWorld().OpenWorld(path) as BetaWorld;