Content packages & MD5 hash comparison between client and server
@@ -400,6 +400,27 @@ namespace Subsurface
|
||||
CharacterList.Add(this);
|
||||
}
|
||||
|
||||
private static string humanConfigFile;
|
||||
public static string HumanConfigFile
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(humanConfigFile))
|
||||
{
|
||||
var characterFiles = Game1.SelectedPackage.GetFilesOfType(ContentType.Character);
|
||||
|
||||
humanConfigFile = characterFiles.Find(c => c.EndsWith("human.xml"));
|
||||
if (humanConfigFile == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Couldn't find a config file for humans from the selected content package!");
|
||||
DebugConsole.ThrowError("(The config file must end with ''human.xml'')");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return humanConfigFile;
|
||||
}
|
||||
}
|
||||
|
||||
public void GiveJobItems(WayPoint spawnPoint)
|
||||
{
|
||||
if (Info == null || Info.Job == null) return;
|
||||
|
||||
@@ -104,17 +104,20 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
|
||||
public static void LoadAll(string filePath)
|
||||
public static void LoadAll(List<string> filePaths)
|
||||
{
|
||||
List = new List<JobPrefab>();
|
||||
|
||||
XDocument doc = ToolBox.TryLoadXml(filePath);
|
||||
if (doc == null) return;
|
||||
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
foreach (string filePath in filePaths)
|
||||
{
|
||||
JobPrefab job = new JobPrefab(element);
|
||||
List.Add(job);
|
||||
XDocument doc = ToolBox.TryLoadXml(filePath);
|
||||
if (doc == null) return;
|
||||
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
{
|
||||
JobPrefab job = new JobPrefab(element);
|
||||
List.Add(job);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 204 KiB |
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<character name ="shrimp" humanoid="false" waveamplitude="0.5" wavelength="80">
|
||||
|
||||
<ragdoll texture ="Content/Characters/panzershrimp.png">
|
||||
|
||||
|
||||
|
||||
<!-- head -->
|
||||
<limb id = "0" radius="50" length = "300" mass = "6" type="Head">
|
||||
<sprite sourcex="6" sourcey="30" sourcewidth="251" sourceheight="242" depth="0.1"/>
|
||||
</limb>
|
||||
<!-- body -->
|
||||
<limb id = "1" radius="50" mass = "40" type="Torso">
|
||||
<sprite sourcex="373" sourcey="6" sourcewidth="122" sourceheight="208" depth="0.05"/>
|
||||
</limb>
|
||||
<!-- left arm -->
|
||||
<limb id = "2" radius="45" height="153" mass="2">
|
||||
<sprite sourcex="252" sourcey="22" sourcewidth="115" sourceheight="227" depth="0.06"/>
|
||||
</limb>
|
||||
<limb id = "3" radius="45" height="205" mass="3">
|
||||
<sprite sourcex="359" sourcey="265" sourcewidth="109" sourceheight="216" depth="0.07"/>
|
||||
</limb>
|
||||
|
||||
<!-- right arm -->
|
||||
<limb id = "4" radius="40" height="175" mass="3" type="Torso">
|
||||
<sprite sourcex="237" sourcey="302" sourcewidth="92" sourceheight="175" depth="0.1"/>
|
||||
</limb>
|
||||
|
||||
<!-- head to body -->
|
||||
<joint limb1="0" limb1y="80" limb2="1" limb2x="-30" limb2y="-20" lowerlimit="0" upperlimit="40"/>
|
||||
<joint limb1="1" limb1y="16" limb2="2" limb2y="-50" lowerlimit="5" upperlimit="60"/>
|
||||
<joint limb1="2" limb1y="20" limb2="3" limb2y="-70" lowerlimit="10" upperlimit="60"/>
|
||||
<joint limb1="3" limb1y="60" limb2="4" limb2y="-50" lowerlimit="20" upperlimit="60"/>
|
||||
|
||||
</ragdoll>
|
||||
|
||||
<ai attackhumans="100" attackrooms="50.0" attackweaker="50" attackstronger="-30" sight="0.5" hearing="1.0"/>
|
||||
</character>
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Items>
|
||||
<Item
|
||||
name="Oxygen Tank"
|
||||
Tags="smallitem"
|
||||
pickdistance="150">
|
||||
|
||||
<Sprite texture ="oxygentank.png" depth="0.05"/>
|
||||
|
||||
<Body radius="6" height="22" density="5"/>
|
||||
|
||||
<Holdable holdpos="30,-15" handle1="0,5" handle2="0,-5"/>
|
||||
<Pickable slots="RightHand,Any"/>
|
||||
</Item>
|
||||
|
||||
<Item
|
||||
name="Diving Mask"
|
||||
Tags="smallitem"
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Item
|
||||
name="Oxygen Tank"
|
||||
Tags="smallitem"
|
||||
pickdistance="150">
|
||||
|
||||
<Sprite texture ="oxygentank.png" depth="0.05"/>
|
||||
|
||||
<Body radius="6" height="22" density="5"/>
|
||||
|
||||
<Holdable holdpos="30,-15" handle1="0,5" handle2="0,-5"/>
|
||||
<Pickable slots="RightHand,Any"/>
|
||||
</Item>
|
||||
|
Before Width: | Height: | Size: 177 B After Width: | Height: | Size: 177 B |
|
Before Width: | Height: | Size: 520 B After Width: | Height: | Size: 520 B |
|
Before Width: | Height: | Size: 498 B After Width: | Height: | Size: 498 B |
|
Before Width: | Height: | Size: 237 B After Width: | Height: | Size: 237 B |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
|
Before Width: | Height: | Size: 187 B After Width: | Height: | Size: 187 B |
@@ -108,7 +108,7 @@
|
||||
<Sprite texture ="light.png" depth="0.8"/>
|
||||
|
||||
<LightComponent canbeselected = "true" color="1.0,0.0,0.0,1.0">
|
||||
<sprite texture="Content/Items/Signal/lightsprite.png" origin="0.5,0.5"/>
|
||||
<sprite texture="Content/Items/Electricity/lightsprite.png" origin="0.5,0.5"/>
|
||||
</LightComponent>
|
||||
|
||||
<Body width="16" height="16"/>
|
||||
|
Before Width: | Height: | Size: 934 B After Width: | Height: | Size: 934 B |
@@ -7,26 +7,36 @@
|
||||
|
||||
<Sprite texture ="weldingtool.png" depth="0.04"/>
|
||||
|
||||
<!-- physics body -->
|
||||
<Body width="39" height="18" density="5"/>
|
||||
|
||||
<!-- the character will hold the item 50 pixels in front of him, with his hands at the handle1 and handle2 positions -->
|
||||
<Holdable aimpos="50,0" handle1="-17,0" handle2="8,0"/>
|
||||
|
||||
<RepairTool structurefixamount="50.0" range="80" barrelpos="19,8">
|
||||
<!-- the item must contain a welding fuel tank for it to work -->
|
||||
<RequiredItems name="Welding Fuel Tank" type="Contained" msg="Welding fuel required"/>
|
||||
|
||||
<!-- when using, the contained welding fuel tank will detoriate (= lose fuel) -->
|
||||
<StatusEffect type="OnUse" target="Contained" targetnames="Welding Fuel Tank" Condition="-0.7"/>
|
||||
|
||||
<!-- welding a door, it will get stuck after a while -->
|
||||
<StatusEffect type="OnUse" target="UseTarget" targetnames="Door,Windowed Door" Stuck="10.0"/>
|
||||
|
||||
<Fixable name="structure"/>
|
||||
|
||||
<!-- construction skill 20 required to use the item -->
|
||||
<RequiredSkill name="Construction" level="20"/>
|
||||
|
||||
<!-- if using the item fails (due to a insufficient skill level for example), the contained tank will break and an explosion will occurr -->
|
||||
<StatusEffect type="OnFailure" target="Contained" targetnames="Welding Fuel Tank,Oxygen Tank" Condition="-100.0" sound="Content/Items/Weapons/stunGrenade.ogg">
|
||||
<Explosion range="5" damage="20" stun="10" force="5.0"/>
|
||||
</StatusEffect>
|
||||
</RepairTool>
|
||||
|
||||
<Pickable slots="Any,BothHands"/>
|
||||
|
||||
|
||||
<!-- one welding fuel or oxygen tank can be contained inside the welding tool -->
|
||||
<ItemContainer capacity="1" hideitems="false" itempos="-17,-21">
|
||||
<Containable name="Welding Fuel Tank"/>
|
||||
<Containable name="Oxygen Tank"/>
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Subsurface
|
||||
{
|
||||
public enum ContentType
|
||||
{
|
||||
None, Jobs, Item, Character, Structure
|
||||
}
|
||||
|
||||
public class ContentPackage
|
||||
{
|
||||
public static List<ContentPackage> list = new List<ContentPackage>();
|
||||
|
||||
|
||||
string name;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
private Md5Hash md5Hash;
|
||||
|
||||
public Md5Hash MD5hash
|
||||
{
|
||||
get
|
||||
{
|
||||
if (md5Hash == null) CalculateHash();
|
||||
return md5Hash;
|
||||
}
|
||||
}
|
||||
|
||||
public List<ContentFile> files;
|
||||
|
||||
private ContentPackage()
|
||||
{
|
||||
files = new List<ContentFile>();
|
||||
}
|
||||
|
||||
public ContentPackage(string filePath)
|
||||
: this()
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(filePath);
|
||||
|
||||
Path = filePath;
|
||||
|
||||
name = ToolBox.GetAttributeString(doc.Root, "name", "");
|
||||
|
||||
foreach (XElement subElement in doc.Root.Elements())
|
||||
{
|
||||
ContentType type = (ContentType)Enum.Parse(typeof(ContentType), subElement.Name.ToString(), true);
|
||||
files.Add(new ContentFile(ToolBox.GetAttributeString(subElement, "file", ""), type));
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public static ContentPackage CreatePackage(string name)
|
||||
{
|
||||
ContentPackage newPackage = new ContentPackage();
|
||||
newPackage.name = name;
|
||||
list.Add(newPackage);
|
||||
|
||||
return newPackage;
|
||||
}
|
||||
|
||||
public ContentFile AddFile(string path, ContentType type)
|
||||
{
|
||||
if (files.Find(file => file.path == path && file.type == type) != null) return null;
|
||||
|
||||
ContentFile cf = new ContentFile(path, type);
|
||||
files.Add(cf);
|
||||
|
||||
return cf;
|
||||
}
|
||||
|
||||
public void Save(string filePath)
|
||||
{
|
||||
XDocument doc = new XDocument();
|
||||
doc.Add(new XElement("contentpackage",
|
||||
new XAttribute("name", name),
|
||||
new XAttribute("path", Path)));
|
||||
|
||||
//doc.Root.Add(
|
||||
// new XElement("jobs", new XAttribute("file", JobFile)),
|
||||
// new XElement("structures", new XAttribute("file", StructureFile)));
|
||||
|
||||
foreach (ContentFile file in files)
|
||||
{
|
||||
doc.Root.Add(new XElement(file.type.ToString(), new XAttribute("file", file.path)));
|
||||
}
|
||||
|
||||
//foreach (string itemFile in itemFiles)
|
||||
//{
|
||||
// doc.Root.Add(new XElement("item", new XAttribute("file", itemFile)));
|
||||
//}
|
||||
doc.Save(filePath+"//"+name+".xml");
|
||||
}
|
||||
|
||||
private void CalculateHash()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
foreach (ContentFile file in files)
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(file.path);
|
||||
|
||||
sb.Append(doc.ToString());
|
||||
}
|
||||
string str = sb.ToString();
|
||||
byte[] bytes = new byte[str.Length * sizeof(char)];
|
||||
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
|
||||
|
||||
md5Hash = new Md5Hash(bytes);
|
||||
}
|
||||
|
||||
public List<string> GetFilesOfType(ContentType type)
|
||||
{
|
||||
List<ContentFile> contentFiles = files.FindAll(f => f.type == type);
|
||||
|
||||
List<string> filePaths = new List<string>();
|
||||
foreach (ContentFile contentFile in contentFiles)
|
||||
{
|
||||
filePaths.Add(contentFile.path);
|
||||
}
|
||||
return filePaths;
|
||||
}
|
||||
public static void LoadAll(string folder)
|
||||
{
|
||||
if (!Directory.Exists(folder))
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(folder);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
string[] files = Directory.GetFiles(folder, "*.xml");
|
||||
|
||||
foreach (string filePath in files)
|
||||
{
|
||||
ContentPackage package = new ContentPackage(filePath);
|
||||
list.Add(package);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ContentFile
|
||||
{
|
||||
public string path;
|
||||
public ContentType type;
|
||||
|
||||
public ContentFile(string path, ContentType type)
|
||||
{
|
||||
Directory.GetCurrentDirectory();
|
||||
//Path.get
|
||||
this.path = path;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -147,7 +147,7 @@ namespace Subsurface
|
||||
if (commands[1].ToLower()=="human")
|
||||
{
|
||||
WayPoint spawnPoint = WayPoint.GetRandom(SpawnType.Human);
|
||||
Character.Controlled = new Character("Content/Characters/Human/human.xml", (spawnPoint == null) ? Vector2.Zero : spawnPoint.SimPosition);
|
||||
Character.Controlled = new Character(Character.HumanConfigFile, (spawnPoint == null) ? Vector2.Zero : spawnPoint.SimPosition);
|
||||
if (Game1.GameSession != null)
|
||||
{
|
||||
SinglePlayerMode mode = Game1.GameSession.gameMode as SinglePlayerMode;
|
||||
|
||||
@@ -33,6 +33,11 @@ namespace Subsurface
|
||||
public static EditMapScreen EditMapScreen;
|
||||
public static EditCharacterScreen EditCharacterScreen;
|
||||
|
||||
public static ContentPackage SelectedPackage
|
||||
{
|
||||
get { return Config.SelectedContentPackage; }
|
||||
}
|
||||
|
||||
public static Level Level;
|
||||
|
||||
public static GameSession GameSession;
|
||||
@@ -167,15 +172,15 @@ namespace Subsurface
|
||||
loadState = 10.0f;
|
||||
yield return Status.Running;
|
||||
|
||||
JobPrefab.LoadAll("Content/Characters/Jobs.xml");
|
||||
JobPrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Jobs));
|
||||
loadState = 15.0f;
|
||||
yield return Status.Running;
|
||||
|
||||
StructurePrefab.LoadAll("Content/Map/StructurePrefabs.xml");
|
||||
StructurePrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Structure));
|
||||
loadState = 25.0f;
|
||||
yield return Status.Running;
|
||||
|
||||
ItemPrefab.LoadAll();
|
||||
ItemPrefab.LoadAll(SelectedPackage.GetFilesOfType(ContentType.Item));
|
||||
loadState = 40.0f;
|
||||
yield return Status.Running;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Subsurface
|
||||
endShiftButton = new GUIButton(new Rectangle(Game1.GraphicsWidth - 220, 20, 200, 25), "End shift", Alignment.TopLeft, GUI.style);
|
||||
endShiftButton.OnClicked = EndShift;
|
||||
|
||||
hireManager.GenerateCharacters("Content/Characters/Human/human.xml", 10);
|
||||
hireManager.GenerateCharacters(Character.HumanConfigFile, 10);
|
||||
|
||||
|
||||
//day = 1;
|
||||
|
||||
@@ -108,11 +108,11 @@ namespace Subsurface
|
||||
|
||||
}
|
||||
|
||||
public static void LoadAll()
|
||||
public static void LoadAll(List<string> filePaths)
|
||||
{
|
||||
string[] files = Directory.GetFiles(contentFolder, "*.xml", SearchOption.AllDirectories);
|
||||
//string[] files = Directory.GetFiles(contentFolder, "*.xml", SearchOption.AllDirectories);
|
||||
|
||||
foreach (string filePath in files)
|
||||
foreach (string filePath in filePaths)
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(filePath);
|
||||
if (doc == null) return;
|
||||
|
||||
@@ -5,16 +5,16 @@ using System.Xml.Linq;
|
||||
|
||||
namespace Subsurface
|
||||
{
|
||||
class Md5Hash
|
||||
public class Md5Hash
|
||||
{
|
||||
private string md5Hash;
|
||||
private string hash;
|
||||
private string shortHash;
|
||||
|
||||
public string MD5Hash
|
||||
public string Hash
|
||||
{
|
||||
get
|
||||
{
|
||||
return md5Hash;
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,30 +28,41 @@ namespace Subsurface
|
||||
|
||||
public Md5Hash(string md5Hash)
|
||||
{
|
||||
this.md5Hash = md5Hash;
|
||||
this.hash = md5Hash;
|
||||
|
||||
shortHash = GetShortHash(md5Hash);
|
||||
}
|
||||
|
||||
public Md5Hash(byte[] bytes)
|
||||
{
|
||||
hash = CalculateHash(bytes);
|
||||
|
||||
shortHash = GetShortHash(hash);
|
||||
}
|
||||
|
||||
public Md5Hash(XDocument doc)
|
||||
{
|
||||
string docString = Regex.Replace(doc.ToString(), @"\s+", "");
|
||||
// step 1, calculate MD5 hash from input
|
||||
|
||||
MD5 md5 = MD5.Create();
|
||||
byte[] inputBytes = Encoding.ASCII.GetBytes(docString);
|
||||
byte[] hash = md5.ComputeHash(inputBytes);
|
||||
|
||||
hash = CalculateHash(inputBytes);
|
||||
|
||||
shortHash = GetShortHash(hash);
|
||||
}
|
||||
|
||||
private string CalculateHash(byte[] bytes)
|
||||
{
|
||||
MD5 md5 = MD5.Create();
|
||||
byte[] byteHash = md5.ComputeHash(bytes);
|
||||
// step 2, convert byte array to hex string
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < hash.Length; i++)
|
||||
for (int i = 0; i < byteHash.Length; i++)
|
||||
{
|
||||
sb.Append(hash[i].ToString("X2"));
|
||||
sb.Append(byteHash[i].ToString("X2"));
|
||||
}
|
||||
|
||||
md5Hash = sb.ToString();
|
||||
|
||||
shortHash = GetShortHash(md5Hash);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private string GetShortHash(string fullHash)
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Xml.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Subsurface
|
||||
{
|
||||
@@ -49,18 +50,21 @@ namespace Subsurface
|
||||
get { return stairDirection; }
|
||||
}
|
||||
|
||||
public static void LoadAll(string filePath)
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(filePath);
|
||||
if (doc == null) return;
|
||||
public static void LoadAll(List<string> filePaths)
|
||||
{
|
||||
foreach (string filePath in filePaths)
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(filePath);
|
||||
if (doc == null) return;
|
||||
|
||||
foreach (XElement el in doc.Root.Elements())
|
||||
{
|
||||
StructurePrefab sp = Load(el);
|
||||
foreach (XElement el in doc.Root.Elements())
|
||||
{
|
||||
StructurePrefab sp = Load(el);
|
||||
|
||||
Debug.WriteLine(sp.name);
|
||||
Debug.WriteLine(sp.name);
|
||||
|
||||
list.Add(sp);
|
||||
list.Add(sp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -616,7 +616,7 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
hash = new Md5Hash(doc);
|
||||
doc.Root.Add(new XAttribute("md5hash", hash.MD5Hash));
|
||||
doc.Root.Add(new XAttribute("md5hash", hash.Hash));
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Subsurface.Networking
|
||||
{
|
||||
name = newName;
|
||||
|
||||
characterInfo = new CharacterInfo("Content/Characters/Human/human.xml", name);
|
||||
characterInfo = new CharacterInfo(Character.HumanConfigFile, name);
|
||||
|
||||
otherClients = new List<Client>();
|
||||
|
||||
@@ -85,6 +85,8 @@ namespace Subsurface.Networking
|
||||
|
||||
outmsg.Write((byte)PacketTypes.Login);
|
||||
outmsg.Write(Game1.Version.ToString());
|
||||
outmsg.Write(Game1.SelectedPackage.Name);
|
||||
outmsg.Write(Game1.SelectedPackage.MD5hash.Hash);
|
||||
outmsg.Write(name);
|
||||
|
||||
// Connect client, to ip previously requested from user
|
||||
@@ -468,7 +470,7 @@ namespace Subsurface.Networking
|
||||
return null;
|
||||
}
|
||||
|
||||
CharacterInfo ch = new CharacterInfo("Content/Characters/Human/human.xml", newName, isFemale ? Gender.Female : Gender.Male, jobPrefab);
|
||||
CharacterInfo ch = new CharacterInfo(Character.HumanConfigFile, newName, isFemale ? Gender.Female : Gender.Male, jobPrefab);
|
||||
ch.HeadSpriteId = headSpriteID;
|
||||
|
||||
WayPoint closestWaypoint = null;
|
||||
|
||||
@@ -124,11 +124,13 @@ namespace Subsurface.Networking
|
||||
Client existingClient = connectedClients.Find(c=> c.Connection == inc.SenderConnection);
|
||||
if (existingClient==null)
|
||||
{
|
||||
string version = "", name = "";
|
||||
string version = "", packageName="", packageHash="", name = "";
|
||||
try
|
||||
{
|
||||
version = inc.ReadString();
|
||||
name = inc.ReadString();
|
||||
version = inc.ReadString();
|
||||
packageName = inc.ReadString();
|
||||
packageHash = inc.ReadString();
|
||||
name = inc.ReadString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -141,6 +143,16 @@ namespace Subsurface.Networking
|
||||
inc.SenderConnection.Deny("Subsurface version " + Game1.Version + " required to connect to the server (Your version: " + version + ")");
|
||||
break;
|
||||
}
|
||||
else if (packageName != Game1.SelectedPackage.Name)
|
||||
{
|
||||
inc.SenderConnection.Deny("Your content package ("+packageName+") doesn't match the server's version (" + Game1.SelectedPackage.Name + ")");
|
||||
break;
|
||||
}
|
||||
else if (packageHash != Game1.SelectedPackage.MD5hash.Hash)
|
||||
{
|
||||
inc.SenderConnection.Deny("Your content package (MD5: " + packageHash + ") doesn't match the server's version (MD5: " + Game1.SelectedPackage.MD5hash.Hash + ")");
|
||||
break;
|
||||
}
|
||||
else if (connectedClients.Find(c => c.name.ToLower() == name.ToLower())!=null)
|
||||
{
|
||||
inc.SenderConnection.Deny("The name ''" + name + "'' is already in use. Please choose another name.");
|
||||
@@ -342,7 +354,7 @@ namespace Subsurface.Networking
|
||||
|
||||
if (client.characterInfo==null)
|
||||
{
|
||||
client.characterInfo = new CharacterInfo("Content/Characters/Human/human.xml", client.name);
|
||||
client.characterInfo = new CharacterInfo(Character.HumanConfigFile, client.name);
|
||||
}
|
||||
characterInfos.Add(client.characterInfo);
|
||||
|
||||
@@ -362,7 +374,7 @@ namespace Subsurface.Networking
|
||||
if (myClient != null)
|
||||
{
|
||||
WayPoint spawnPoint = WayPoint.GetRandom(SpawnType.Human);
|
||||
CharacterInfo ch = new CharacterInfo("Content/Characters/Human/human.xml", myClient.name);
|
||||
CharacterInfo ch = new CharacterInfo(Character.HumanConfigFile, myClient.name);
|
||||
myClient.character = new Character(ch, (spawnPoint == null) ? Vector2.Zero : spawnPoint.SimPosition);
|
||||
}
|
||||
|
||||
@@ -376,7 +388,7 @@ namespace Subsurface.Networking
|
||||
msg.Write(Game1.NetLobbyScreen.LevelSeed);
|
||||
|
||||
msg.Write(Game1.NetLobbyScreen.SelectedMap.Name);
|
||||
msg.Write(Game1.NetLobbyScreen.SelectedMap.Hash.MD5Hash);
|
||||
msg.Write(Game1.NetLobbyScreen.SelectedMap.Hash.Hash);
|
||||
|
||||
msg.Write(Game1.NetLobbyScreen.GameDuration.TotalMinutes);
|
||||
|
||||
@@ -587,7 +599,7 @@ namespace Subsurface.Networking
|
||||
{
|
||||
if (c.Connection != message.SenderConnection) continue;
|
||||
|
||||
c.characterInfo = new CharacterInfo("Content/Characters/Human/human.xml", name, gender);
|
||||
c.characterInfo = new CharacterInfo(Character.HumanConfigFile, name, gender);
|
||||
c.characterInfo.HeadSpriteId = headSpriteId;
|
||||
c.jobPreferences = jobPreferences;
|
||||
break;
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Subsurface
|
||||
{
|
||||
if (dummyCharacter != null) dummyCharacter.Remove();
|
||||
|
||||
dummyCharacter = new Character("Content/Characters/Human/human.xml", Vector2.Zero);
|
||||
dummyCharacter = new Character(Character.HumanConfigFile, Vector2.Zero);
|
||||
Character.Controlled = dummyCharacter;
|
||||
Game1.World.ProcessChanges();
|
||||
}
|
||||
|
||||
@@ -486,10 +486,10 @@ namespace Subsurface
|
||||
}
|
||||
else
|
||||
{
|
||||
if (map.Hash.MD5Hash != md5Hash)
|
||||
if (map.Hash.Hash != md5Hash)
|
||||
{
|
||||
DebugConsole.ThrowError("Your version of the map file ''" + map.Name + "'' doesn't match the server's version!");
|
||||
DebugConsole.ThrowError("Your file: " + map.Name + "(MD5 hash : " + map.Hash.MD5Hash + ")");
|
||||
DebugConsole.ThrowError("Your file: " + map.Name + "(MD5 hash : " + map.Hash.Hash + ")");
|
||||
DebugConsole.ThrowError("Server's file: " + mapName + "(MD5 hash : " + md5Hash + ")");
|
||||
return false;
|
||||
}
|
||||
@@ -514,7 +514,7 @@ namespace Subsurface
|
||||
else
|
||||
{
|
||||
msg.Write(Path.GetFileName(selectedMap.Name));
|
||||
msg.Write(selectedMap.Hash.MD5Hash);
|
||||
msg.Write(selectedMap.Hash.Hash);
|
||||
}
|
||||
|
||||
msg.Write(modeList.SelectedIndex-1);
|
||||
|
||||
@@ -25,6 +25,12 @@ namespace Subsurface
|
||||
set;
|
||||
}
|
||||
|
||||
public ContentPackage SelectedContentPackage
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public GameSettings(string filePath)
|
||||
{
|
||||
Load(filePath);
|
||||
@@ -45,7 +51,19 @@ namespace Subsurface
|
||||
{
|
||||
GraphicsWidth = 1024;
|
||||
GraphicsHeight = 768;
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (XElement subElement in doc.Root.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLower())
|
||||
{
|
||||
case "contentpackage":
|
||||
string path = ToolBox.GetAttributeString(subElement, "path", "");
|
||||
SelectedContentPackage = ContentPackage.list.Find(cp => cp.Path == path);
|
||||
|
||||
if (SelectedContentPackage == null) SelectedContentPackage = new ContentPackage(path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -79,6 +97,13 @@ namespace Subsurface
|
||||
new XAttribute("height", GraphicsHeight),
|
||||
new XAttribute("fullscreen", FullScreenEnabled ? "true" : "false"));
|
||||
|
||||
if (SelectedContentPackage != null)
|
||||
{
|
||||
doc.Root.Add(new XElement("contentpackage",
|
||||
new XAttribute("path", SelectedContentPackage.Path)));
|
||||
}
|
||||
|
||||
|
||||
doc.Save(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,11 +64,12 @@
|
||||
<Compile Include="Characters\Jobs\JobPrefab.cs" />
|
||||
<Compile Include="Characters\AI\SteeringManager.cs" />
|
||||
<Compile Include="Characters\AI\SteeringPath.cs" />
|
||||
<Compile Include="ContentPackage.cs" />
|
||||
<Compile Include="CoroutineManager.cs" />
|
||||
<Compile Include="GUI\TitleScreen.cs" />
|
||||
<Compile Include="Items\FixRequirement.cs" />
|
||||
<Compile Include="Map\LocationType.cs" />
|
||||
<Compile Include="Rand.cs" />
|
||||
<Compile Include="Utils\Rand.cs" />
|
||||
<Compile Include="Events\PropertyTask.cs" />
|
||||
<Compile Include="Events\RepairTask.cs" />
|
||||
<Compile Include="GameSession\CrewManager.cs" />
|
||||
@@ -142,7 +143,7 @@
|
||||
<Compile Include="Map\Md5Hash.cs" />
|
||||
<Compile Include="Map\Levels\Voronoi.cs" />
|
||||
<Compile Include="Map\Levels\VoronoiElements.cs" />
|
||||
<Compile Include="MathUtils.cs" />
|
||||
<Compile Include="Utils\MathUtils.cs" />
|
||||
<Compile Include="Physics\PhysicsBody.cs" />
|
||||
<Compile Include="Networking\NetworkEvent.cs" />
|
||||
<Compile Include="Networking\NetworkMember.cs" />
|
||||
@@ -151,7 +152,7 @@
|
||||
<Compile Include="Particles\ParticlePrefab.cs" />
|
||||
<Compile Include="Physics\Physics.cs" />
|
||||
<Compile Include="Properties.cs" />
|
||||
<Compile Include="SaveUtil.cs" />
|
||||
<Compile Include="Utils\SaveUtil.cs" />
|
||||
<Compile Include="Screens\EditCharacterScreen.cs" />
|
||||
<Compile Include="EventInput\EventInput.cs" />
|
||||
<Compile Include="EventInput\KeyboardDispatcher.cs" />
|
||||
@@ -199,8 +200,8 @@
|
||||
<Compile Include="Sounds\Sound.cs" />
|
||||
<Compile Include="Sounds\AmbientSoundManager.cs" />
|
||||
<Compile Include="Sprite.cs" />
|
||||
<Compile Include="TextureLoader.cs" />
|
||||
<Compile Include="ToolBox.cs" />
|
||||
<Compile Include="Utils\TextureLoader.cs" />
|
||||
<Compile Include="Utils\ToolBox.cs" />
|
||||
<Compile Include="Map\Hull.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -271,7 +272,7 @@
|
||||
<Content Include="Content\Characters\Human\torso.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Characters\Jobs.xml">
|
||||
<Content Include="Content\Jobs.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
@@ -289,13 +290,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Characters\shrimp.xml">
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Characters\panzershrimp.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Characters\Scorpion\scorpion.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
@@ -357,26 +351,26 @@
|
||||
<Content Include="Content\Items\Lockers\lockers.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Signal\and.png">
|
||||
<Content Include="Content\Items\Electricity\and.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Signal\light.png">
|
||||
<Content Include="Content\Items\Electricity\light.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Signal\lightsprite.png">
|
||||
<Content Include="Content\Items\Electricity\lightsprite.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Signal\not.png">
|
||||
<Content Include="Content\Items\Electricity\not.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Signal\or.png">
|
||||
<Content Include="Content\Items\Electricity\or.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Signal\signalitems.xml">
|
||||
<Content Include="Content\Items\Electricity\signalitems.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Signal\wire.png">
|
||||
<Content Include="Content\Items\Electricity\wire.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Pump\pump.xml">
|
||||
@@ -417,7 +411,7 @@
|
||||
<Content Include="Content\UI\textboxTexture.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\battery.png">
|
||||
<Content Include="Content\Items\Electricity\battery.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Button\button.png">
|
||||
@@ -471,7 +465,7 @@
|
||||
<Content Include="Content\Items\idcard.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\junctionbox.png">
|
||||
<Content Include="Content\Items\Electricity\junctionbox.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Ladder\item.xml">
|
||||
@@ -492,13 +486,10 @@
|
||||
<Content Include="Content\Items\OxygenGenerator\item.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Diving\item.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Diving\oxygentank.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\poweritems.xml">
|
||||
<Content Include="Content\Items\Electricity\poweritems.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Weapons\railgun.xml">
|
||||
|
||||