From c6248a3a0a2c628f33da5989a2f3fad49acb1a9f Mon Sep 17 00:00:00 2001
From: Li
Date: Fri, 10 Mar 2023 16:59:34 +1300
Subject: [PATCH] Add the ability to add xomtypes if there missing
---
LibW4M/Data/Teams/TeamData.cs | 136 +++++++++++++++++-
LibW4M/Data/Teams/TeamsCollective.cs | 3 +-
.../Data/WeaponFactory/WeaponsCollective.cs | 3 +-
LibW4M/W4SaveFile.cs | 133 ++++++++++++++++-
LibXom/Blocks/TypeBlock.cs | 2 +-
LibXom/Data/XomFile.cs | 27 +++-
LibXom/Data/XomFileComponent.cs | 3 +-
LibXom/Data/XomType.cs | 34 +++--
LibXom/XomWriter.cs | 2 +-
W4Gui/Components/SchemePanel.Designer.cs | 64 ++++++---
10 files changed, 366 insertions(+), 41 deletions(-)
diff --git a/LibW4M/Data/Teams/TeamData.cs b/LibW4M/Data/Teams/TeamData.cs
index 6b5cf5f..044c6ec 100644
--- a/LibW4M/Data/Teams/TeamData.cs
+++ b/LibW4M/Data/Teams/TeamData.cs
@@ -71,7 +71,7 @@ namespace LibW4M.Data.Teams
public XomString Tash;
public int[] StoryMissionsCompleted;
public int StoryChapter;
- public TeamData(W4SaveFile fileBelongs, XomContainer mainContainer) : base(fileBelongs, mainContainer)
+ public TeamData(W4SaveFile fileBelongs, XomContainer mainContainer, bool load=true) : base(fileBelongs, mainContainer, load)
{
}
@@ -115,6 +115,136 @@ namespace LibW4M.Data.Teams
base.DeleteEntries();
}
+ private void setDefaultWeapon()
+ {
+ // Search other teams for "FETXT.Factory.Blaster"
+ bool foundDefault = false;
+ foreach (TeamData team in fileBelongs.TeamDataColective)
+ {
+ if (team.CustomWeapon.Value == "FETXT.Factory.Blaster")
+ {
+ this.SecretWeapon = team.SecretWeapon;
+ this.SecretWeaponCluster = team.SecretWeaponCluster;
+ foundDefault = true;
+ break;
+ }
+ }
+
+ // not found? FIIIIIIIIIIINE ILL CREATE IT MYSELF
+ if (!foundDefault)
+ {
+ WeaponData weapon = new WeaponData(fileBelongs, fileBelongs.CreateContainer("WeaponFactoryContainer"), false);
+ WeaponData cluster = new WeaponData(fileBelongs, fileBelongs.CreateContainer("WeaponFactoryContainer"), false);
+
+ // Set weapon data
+ weapon.Name = fileBelongs.LookupString("");
+ weapon.Type = 0;
+ weapon.DetonationType = DetonationType.Fuse;
+ weapon.ProjectileLaunchType = ProjectileLaunchType.Thrown;
+ weapon.RetreatTime = -1;
+ weapon.FuseTime = -1;
+
+ weapon.WormDamageRadius = 0.75f;
+ weapon.WormDamageMagnitude = 0.75f;
+ weapon.LandDamageRadius = 0.600000024f;
+ weapon.Push = 0.600000024f;
+ weapon.ProjectileMaxPower = 1.0f;
+
+ weapon.ProjectileNumClusters = 0;
+ weapon.ClusterMaxSpeed = 0.300000012f;
+ weapon.ClusterMaxSpeed = 0.0f;
+
+ weapon.PayloadResourceId = 16;
+ weapon.ProjectileCollisionRadius = 1.0f;
+ weapon.LaunchFX = fileBelongs.LookupString("");
+ weapon.ArielFX = fileBelongs.LookupString("");
+ weapon.DetonationFX = fileBelongs.LookupString("EffectExplosion");
+ weapon.GraphicalResources = new XomString[4] { fileBelongs.LookupString("Factory.TankGunBody"), fileBelongs.LookupString("Factory.TankGunBarrel"), fileBelongs.LookupString("Factory.TankGunButt"), fileBelongs.LookupString("Factory.TankGunSight") };
+ weapon.GraphicalLocators = new XomString[4] { fileBelongs.LookupString("TANK_body_locator"), fileBelongs.LookupString("TANK_barrel_root_locator"), fileBelongs.LookupString("TANK_butt_root_locator"), fileBelongs.LookupString("TANK_sight_root_locator") };
+
+ weapon.Homing = false;
+ weapon.HomingAvoidLand = false;
+ weapon.Poison = false;
+ weapon.EffectedByWind = false;
+ weapon.ProjectilePowersUp = true;
+ weapon.FireOnGround = false;
+
+ weapon.Save();
+
+ // Set cluster data
+
+ cluster.Name = fileBelongs.LookupString("");
+ cluster.Type = 1;
+ cluster.DetonationType = DetonationType.Fuse;
+ cluster.ProjectileLaunchType = ProjectileLaunchType.Thrown;
+ cluster.RetreatTime = -1;
+ cluster.FuseTime = -1;
+
+ cluster.WormDamageRadius = 0.75f;
+ cluster.WormDamageMagnitude = 0.75f;
+ cluster.LandDamageRadius = 0.600000024f;
+ cluster.Push = 0.600000024f;
+ cluster.ProjectileMaxPower = 1.0f;
+
+ cluster.ProjectileNumClusters = 0;
+ cluster.ClusterMaxSpeed = 0.300000012f;
+ cluster.ClusterMaxSpeed = 0.0f;
+
+ cluster.PayloadResourceId = 16;
+ cluster.ProjectileCollisionRadius = 1.0f;
+ cluster.LaunchFX = fileBelongs.LookupString("");
+ cluster.ArielFX = fileBelongs.LookupString("");
+ cluster.DetonationFX = fileBelongs.LookupString("EffectExplosion");
+ cluster.GraphicalResources = new XomString[1] { fileBelongs.LookupString("Grenade.Weapon") };
+ cluster.GraphicalLocators = new XomString[0];
+
+ cluster.Homing = false;
+ cluster.HomingAvoidLand = false;
+ cluster.Poison = false;
+ cluster.EffectedByWind = false;
+ cluster.ProjectilePowersUp = true;
+ cluster.FireOnGround = false;
+
+ cluster.Save();
+
+ this.SecretWeapon = weapon;
+ this.SecretWeaponCluster = cluster;
+ }
+ }
+ internal override void loadDefaults()
+ {
+ this.Name = fileBelongs.LookupString("Untitled Team");
+ this.Worms = new XomString[6] { fileBelongs.LookupString("Worm 1"), fileBelongs.LookupString("Worm 2"), fileBelongs.LookupString("Worm 3"), fileBelongs.LookupString("Worm 4"), fileBelongs.LookupString("Worm 5"), fileBelongs.LookupString("Worm 6") };
+
+ this.TutorialsDone = 0;
+ this.NewTeam = 0;
+ this.Skill = SkillLevel.PlayerControled;
+
+ this.Grave = 0;
+ this.SWeapon = 0;
+ this.Flag = fileBelongs.LookupString("Flag.UK");
+ this.Speech = fileBelongs.LookupString("voclassi");
+ this.InGame = false;
+ this.AllMissionsDone = false;
+ this.AllMissionsDone = false;
+
+ this.Player = fileBelongs.LookupString("");
+
+ // Deal with team weapon
+ setDefaultWeapon();
+ this.CustomWeapon = fileBelongs.LookupString("FETXT.Factory.Blaster");
+ //
+
+ this.Hat = fileBelongs.LookupString("");
+ this.Gloves = fileBelongs.LookupString("");
+ this.Glasses = fileBelongs.LookupString("");
+ this.Tash = fileBelongs.LookupString("");
+
+ this.StoryMissionsCompleted = new int[5];
+ this.StoryChapter = 0;
+
+ base.loadDefaults();
+ }
public override void Load()
{
using (XomStreamReader reader = new XomStreamReader(new MemoryStream(this.mainContainer.GetData())))
@@ -137,7 +267,6 @@ namespace LibW4M.Data.Teams
this.secretWeapon = new WeaponData(fileBelongs, fileBelongs.LookupContainerById(reader.ReadCompressedInt()));
this.secretWeaponCluster = new WeaponData(fileBelongs, fileBelongs.LookupContainerById(reader.ReadCompressedInt()));
-
this.CustomWeapon = fileBelongs.LookupStringFromId(reader.ReadCompressedInt());
this.Hat = fileBelongs.LookupStringFromId(reader.ReadCompressedInt());
@@ -152,6 +281,9 @@ namespace LibW4M.Data.Teams
public override void Save()
{
+ this.SecretWeapon.Save();
+ this.SecretWeaponCluster.Save();
+
using (MemoryStream ms = new MemoryStream())
{
using (XomStreamWriter writer = new XomStreamWriter(ms))
diff --git a/LibW4M/Data/Teams/TeamsCollective.cs b/LibW4M/Data/Teams/TeamsCollective.cs
index 8e777e3..b8bfaf2 100644
--- a/LibW4M/Data/Teams/TeamsCollective.cs
+++ b/LibW4M/Data/Teams/TeamsCollective.cs
@@ -16,7 +16,8 @@ namespace LibW4M.Data.Teams
public override void Create()
{
- throw new NotImplementedException();
+ TeamData team = new TeamData(this.fileBelongs, this.fileBelongs.CreateContainer("StoredTeamData"), false);
+ this.collectiveEntries.Add(team);
}
public override void Load()
diff --git a/LibW4M/Data/WeaponFactory/WeaponsCollective.cs b/LibW4M/Data/WeaponFactory/WeaponsCollective.cs
index 7821360..2671bd9 100644
--- a/LibW4M/Data/WeaponFactory/WeaponsCollective.cs
+++ b/LibW4M/Data/WeaponFactory/WeaponsCollective.cs
@@ -28,7 +28,8 @@ namespace LibW4M.Data.WeaponFactory
public override void Create()
{
- this.collectiveEntries.Add(new WeaponStore(this.fileBelongs, this.fileBelongs.CreateContainer("StoreWeaponFactory"), false));
+ WeaponStore store = new WeaponStore(this.fileBelongs, this.fileBelongs.CreateContainer("StoreWeaponFactory"), false);
+ this.collectiveEntries.Add(store);
}
public override void Load()
diff --git a/LibW4M/W4SaveFile.cs b/LibW4M/W4SaveFile.cs
index 589717f..fbb07b2 100644
--- a/LibW4M/W4SaveFile.cs
+++ b/LibW4M/W4SaveFile.cs
@@ -16,9 +16,11 @@ using LibXom.Blocks;
using LibXom.Data;
using LibXom.Exceptions;
using LibXom.Streams;
+using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Xml.XPath;
+using static System.Runtime.InteropServices.JavaScript.JSType;
namespace LibW4M
{
@@ -214,10 +216,139 @@ namespace LibW4M
for (int i = 0; i < strings.Length; i++) strings[i] = this.LookupStringFromId(stringIds[i]);
return strings;
}
+ private static byte[] getXomTypeXBytes(string name)
+ {
+ switch (name)
+ {
+ case "WeaponFactoryContainer":
+ return new byte[0x10] { 0xA5, 0x36, 0x42, 0x20, 0xF4, 0x4D, 0x60, 0x4F, 0x90, 0x97, 0x4F, 0xA8, 0x87, 0xD5, 0xC7, 0x4D };
+ case "StoreWeaponFactory":
+ return new byte[0x10] { 0xB5, 0x2C, 0x2F, 0xE3, 0x3A, 0x13, 0x1C, 0x4F, 0xB6, 0x4A, 0x81, 0xB8, 0x97, 0x30, 0x2E, 0x82 };
+ case "WeaponFactoryCollective":
+ return new byte[0x10] { 0xB2, 0x4A, 0x97, 0x29, 0xF8, 0x2E, 0x3D, 0x4E, 0xB7, 0x98, 0xF5, 0x8D, 0x3F, 0x36, 0x07, 0xFF };
+ case "StoredTeamData":
+ return new byte[0x10] { 0x55, 0xB4, 0x6A, 0x78, 0x13, 0x63, 0xC6, 0x4D, 0xA1, 0xA3, 0xA5, 0x4B, 0x67, 0xD5, 0x2C, 0xDE };
+ case "HighScoreData":
+ return new byte[0x10] { 0xED, 0xB1, 0x58, 0x90, 0x67, 0x06, 0x31, 0x44, 0xBC, 0x6B, 0x7E, 0x56, 0x6C, 0x8C, 0xBC, 0xE4 };
+ case "TeamDataColective":
+ return new byte[0x10] { 0x39, 0x11, 0x7C, 0x55, 0xF9, 0xEA, 0xBF, 0x49, 0x99, 0x8D, 0x05, 0xD8, 0x52, 0x59, 0x86, 0x55 };
+ case "WeaponSettingsData":
+ return new byte[0x10] { 0x16, 0x2E, 0xAC, 0x14, 0x90, 0x16, 0x97, 0x43, 0xBA, 0x75, 0x20, 0x4D, 0xAC, 0x1C, 0x56, 0x3F };
+ case "SchemeData":
+ return new byte[0x10] { 0x6B, 0xDD, 0x69, 0x39, 0x1A, 0xAF, 0xBF, 0x40, 0xBF, 0x2C, 0x21, 0xE3, 0x7C, 0x4B, 0xFC, 0xFE };
+ case "SchemeColective":
+ return new byte[0x10] { 0x1E, 0x40, 0x13, 0xDF, 0xC6, 0x8F, 0x50, 0x44, 0x8C, 0x7F, 0x55, 0xC6, 0x72, 0xA7, 0x27, 0x25 };
+ case "WXFE_UnlockableItem":
+ return new byte[0x10] { 0x72, 0x12, 0xCB, 0x5B, 0x48, 0xBF, 0x9F, 0x4A, 0xA2, 0xD3, 0xD1, 0x21, 0xA9, 0x82, 0xD7, 0x3A };
+ case "InputDetailsContainer":
+ return new byte[0x10] { 0x66, 0xE0, 0x60, 0xA5, 0xAB, 0x92, 0xC2, 0x43, 0x8E, 0x71, 0x46, 0xE8, 0x34, 0xF5, 0xDF, 0x80 };
+ case "InputEventMappingContainer":
+ return new byte[0x10] { 0x30, 0x7B, 0x4E, 0x74, 0x00, 0xED, 0x46, 0x4C, 0xA4, 0x5D, 0x87, 0x0C, 0xD3, 0x52, 0x81, 0xD8 };
+ case "InputMappingDetails":
+ return new byte[0x10] { 0x7B, 0x26, 0x21, 0x39, 0xC6, 0x3E, 0x69, 0x4C, 0xB7, 0xDD, 0x19, 0x9A, 0xED, 0xEB, 0x71, 0x5C };
+ case "StatsContainer":
+ return new byte[0x10] { 0x13, 0x54, 0xBC, 0xDF, 0x36, 0x80, 0x71, 0x4F, 0x83, 0x71, 0x6F, 0x3B, 0x5D, 0x87, 0x63, 0xED };
+ case "StoredStatsCollective":
+ return new byte[0x10] { 0x25, 0x1D, 0x56, 0xF7, 0x90, 0xD3, 0xF9, 0x4B, 0xA7, 0xE3, 0xE6, 0x73, 0xD6, 0x75, 0xCE, 0x03 };
+ case "TeamAwardsContainer":
+ return new byte[0x10] { 0xBB, 0x77, 0x14, 0x26, 0x44, 0xC0, 0xAC, 0x4C, 0xA4, 0x18, 0x90, 0x8F, 0xE9, 0x07, 0x5C, 0xF8 };
+ case "XResourceDetails":
+ return new byte[0x10] { 0xF2, 0x56, 0x75, 0xE7, 0x95, 0xA4, 0x1A, 0x49, 0x85, 0x63, 0x00, 0x6C, 0xE2, 0x57, 0x72, 0x44 };
+ case "XIntResourceDetails":
+ return new byte[0x10] { 0x8D, 0x9B, 0x88, 0x7D, 0x14, 0x2C, 0x5E, 0x44, 0x96, 0x1F, 0x5E, 0x0E, 0x55, 0x20, 0x41, 0x6A };
+ case "XUintResourceDetails":
+ return new byte[0x10] { 0x7C, 0x11, 0xE5, 0x93, 0xDA, 0x8A, 0xFB, 0x4A, 0xB1, 0x7A, 0x66, 0x8D, 0x0B, 0xDD, 0x15, 0xE6 };
+ case "XStringResourceDetails":
+ return new byte[0x10] { 0x72, 0x58, 0xDC, 0x7C, 0xA3, 0x2C, 0xCC, 0x4F, 0xAE, 0x66, 0x43, 0x10, 0x71, 0xE5, 0xCE, 0x67 };
+ case "XFloatResourceDetails":
+ return new byte[0x10] { 0x5F, 0x9D, 0x88, 0x08, 0x39, 0x80, 0xEA, 0x4C, 0xBA, 0x5B, 0x9C, 0x05, 0x9A, 0xC0, 0x57, 0x0E };
+ case "XContainerResourceDetails":
+ return new byte[0x10] { 0x20, 0xBF, 0xB6, 0xE0, 0x0B, 0xF8, 0x29, 0x43, 0xB6, 0xEB, 0x19, 0x98, 0xED, 0x8A, 0xEC, 0x1F };
+ case "XDataBank":
+ return new byte[0x10] { 0xAC, 0x61, 0xE6, 0x93, 0x41, 0xD9, 0x2A, 0x44, 0xA1, 0x8E, 0xE9, 0x9B, 0x79, 0x58, 0x79, 0xDC };
+ case "XContainer":
+ return new byte[0x10] { 0x46, 0xD4, 0x1C, 0x5E, 0xA3, 0x48, 0xFE, 0x44, 0xA5, 0x5A, 0xE2, 0x47, 0xB8, 0xF5, 0xE7, 0x13 };
+ default:
+ return new byte[0x10];
+ }
+ }
+
+ private int findInStringArray(string str, string[] arr)
+ {
+ for(int i = 0; i < arr.Length; i++)
+ {
+ if (str.Equals(arr[i], StringComparison.InvariantCulture)) return i;
+ }
+ return -1;
+ }
+ private int getXomTypeInsertPos(string typeName)
+ {
+ XomType[] types = xomFile.XomTypes;
+ string[] typesOrder = new string[] {
+ "WeaponFactoryContainer",
+ "StoreWeaponFactory",
+ "WeaponFactoryCollective",
+ "StoredTeamData",
+ "HighScoreData",
+ "TeamDataColective",
+ "WeaponSettingsData",
+ "SchemeData",
+ "SchemeColective",
+ "WXFE_UnlockableItem",
+ "InputDetailsContainer",
+ "InputEventMappingContainer",
+ "InputMappingDetails",
+ "StatsContainer",
+ "StoredStatsCollective",
+ "TeamAwardsContainer",
+ "XResourceDetails",
+ "XIntResourceDetails",
+ "XUintResourceDetails",
+ "XStringResourceDetails",
+ "XFloatResourceDetails",
+ "XContainerResourceDetails",
+ "XDataBank",
+ "XContainer"
+ };
+
+ int loc = findInStringArray(typeName, typesOrder);
+
+ string[] strs = new string[typesOrder.Length];
+
+ for (int i = 0; i < types.Length; i++)
+ {
+ int f = findInStringArray(types[i].Name, typesOrder);
+ strs[f] = types[i].Name;
+ }
+
+ strs[loc] = typeName;
+
+ int ins = 0;
+ foreach(string str in strs)
+ {
+ if (str == null)
+ continue;
+ if (str == typeName)
+ break;
+ ins++;
+ }
+ return ins - 1;
+ }
+
+ public void CreateXomType(string typeName)
+ {
+ byte[] xbytes = getXomTypeXBytes(typeName);
+ int insertInto = getXomTypeInsertPos(typeName);
+ xomFile.CreateXomType(xbytes, typeName, insertInto);
+ }
public XomContainer CreateContainer(string type)
{
- return xomFile.CreateContainer(type);
+ try
+ {
+ return xomFile.CreateContainer(type);
+ }
+ catch(XomTypeNotFoundException) { this.CreateXomType(type); return this.CreateContainer(type); }
}
public XomContainer LookupContainerById(int id)
{
diff --git a/LibXom/Blocks/TypeBlock.cs b/LibXom/Blocks/TypeBlock.cs
index 6c1c92d..8863c42 100644
--- a/LibXom/Blocks/TypeBlock.cs
+++ b/LibXom/Blocks/TypeBlock.cs
@@ -18,7 +18,7 @@ namespace LibXom.Blocks
return numCtnr;
}
}
- public byte[] Md5
+ public byte[] XBytes
{
get
{
diff --git a/LibXom/Data/XomFile.cs b/LibXom/Data/XomFile.cs
index 3825b80..c13c05a 100644
--- a/LibXom/Data/XomFile.cs
+++ b/LibXom/Data/XomFile.cs
@@ -90,12 +90,19 @@ namespace LibXom.Data
{
return XomContainers[containerId - 1];
}
+ public XomType CreateXomType(byte[] xBytes, string typeName, int insertAt=-1)
+ {
+ if (insertAt == -1) insertAt = xomTypes.Count - 1;
+ XomType newType = new XomType(this, xBytes, typeName, new XomContainer[0]);
+ xomTypes.Insert(insertAt, newType);
+ return newType;
+ }
public XomType GetTypeByName(string typeName)
{
foreach(XomType type in XomTypes)
if (type.Name.Equals(typeName, StringComparison.InvariantCulture)) return type;
- throw new XomTypeNotFoundException("Type \"" + typeName + "\" was not found in XOM.");
+ throw new XomTypeNotFoundException("Could not find xom type: " + typeName);
}
public XomContainer GetContainerByUuid(string uuid)
@@ -111,6 +118,18 @@ namespace LibXom.Data
throw new XomContainerNotFoundException("No container was found with the uuid: " + uuid);
}
+ internal void deleteXomType(XomType type)
+ {
+ for(int i = 0; i < xomTypes.Count; i++)
+ {
+ if (xomTypes[i].Equals(type))
+ {
+ xomTypes.RemoveAt(i);
+ break;
+ }
+ }
+ }
+
internal int calculateIdForXomStrings(XomString searchString)
{
XomString[] stringsList = this.XomStrings;
@@ -140,7 +159,7 @@ namespace LibXom.Data
blocks.Add(new MoikBlock(this.version, containers.Length, types.Length));
// add type blocks
- foreach (XomType type in types) blocks.Add(new TypeBlock(type.Containers.Length, type.Md5, type.Name));
+ foreach (XomType type in types) blocks.Add(new TypeBlock(type.Containers.Length, type.XBytes, type.Name));
// Add guid and schm block
blocks.Add(new GuidBlock(0, 0, 0));
@@ -222,7 +241,7 @@ namespace LibXom.Data
foreach (TypeBlock type in typeBlocks)
{
string typeName = type.TypeName;
- byte[] md5 = type.Md5;
+ byte[] xBytes = type.XBytes;
int numContainers = type.NumCtnr;
// Create a list of containers, inside this type.
List xomContainers = new List();
@@ -240,7 +259,7 @@ namespace LibXom.Data
cnt++; // Increment the global container block count.
}
- this.xomTypes.Add(new XomType(this, md5, typeName, xomContainers.ToArray()));
+ this.xomTypes.Add(new XomType(this, xBytes, typeName, xomContainers.ToArray()));
}
}
diff --git a/LibXom/Data/XomFileComponent.cs b/LibXom/Data/XomFileComponent.cs
index 0d809b1..76e11f3 100644
--- a/LibXom/Data/XomFileComponent.cs
+++ b/LibXom/Data/XomFileComponent.cs
@@ -25,7 +25,8 @@ namespace LibXom.Data
public override bool Equals(object? obj)
{
if (obj is not XomFileComponent) return false;
- return this.Uuid.Equals((obj as XomFileComponent).Uuid, StringComparison.InvariantCultureIgnoreCase);
+ XomFileComponent xComponent = (obj as XomFileComponent);
+ return this.Uuid.Equals(xComponent.Uuid, StringComparison.InvariantCultureIgnoreCase);
}
}
}
diff --git a/LibXom/Data/XomType.cs b/LibXom/Data/XomType.cs
index c3ffc6f..81093e8 100644
--- a/LibXom/Data/XomType.cs
+++ b/LibXom/Data/XomType.cs
@@ -9,7 +9,7 @@ namespace LibXom.Data
{
public class XomType : XomFileComponent
{
- private byte[] md5;
+ private byte[] xBytes;
private string name;
private List xomContainers = new List();
public override int Id
@@ -20,11 +20,11 @@ namespace LibXom.Data
}
}
- public byte[] Md5
+ public byte[] XBytes
{
get
{
- return md5;
+ return xBytes;
}
}
public string Name
@@ -45,15 +45,13 @@ namespace LibXom.Data
{
for (int i = 0; i < xomContainers.Count; i++)
{
- if (xomContainers[i].Uuid.Equals(container.Uuid, StringComparison.InvariantCulture))
+ if (xomContainers[i].Equals(container))
{
return i;
}
}
- // maybe removed this container by mistakes; so lets just add it back
- container.Type.xomContainers.Add(container);
- return getContainerIndex(container);
+ throw new XomContainerNotFoundException("container with uuid " + container.Uuid + " not found in type " + this.Name);
}
public void ReplaceContainerData(XomContainer container, byte[] newData)
{
@@ -68,16 +66,34 @@ namespace LibXom.Data
return xomContainer;
}
+ public override int GetHashCode()
+ {
+ return this.Name.GetHashCode();
+ }
+
+ public override bool Equals(object? obj)
+ {
+ if (obj is not XomType) return false;
+ XomType xCompare = obj as XomType;
+
+ return xCompare.Name.Equals(this.Name, StringComparison.InvariantCultureIgnoreCase);
+ }
+
public void DeleteContainer(XomContainer container)
{
int indx = this.getContainerIndex(container);
this.xomContainers.RemoveAt(indx);
+
+ if(this.xomContainers.Count == 0)
+ this.fileBelongs.deleteXomType(this);
}
- internal XomType(XomFile fileFrom, byte[] md5, string name, XomContainer[] xomContainers)
+
+
+ internal XomType(XomFile fileFrom, byte[] xBytes, string name, XomContainer[] xomContainers)
{
fileBelongs = fileFrom;
- this.md5 = md5;
+ this.xBytes = xBytes;
this.name = name;
this.xomContainers.AddRange(xomContainers);
}
diff --git a/LibXom/XomWriter.cs b/LibXom/XomWriter.cs
index 0987acd..c71acfd 100644
--- a/LibXom/XomWriter.cs
+++ b/LibXom/XomWriter.cs
@@ -26,7 +26,7 @@ namespace LibXom
xomStream.Skip(0x4);
xomStream.WriteInt32(typeBlock.NumCtnr);
xomStream.Skip(0x4);
- xomStream.WriteBytes(typeBlock.Md5);
+ xomStream.WriteBytes(typeBlock.XBytes);
xomStream.WriteStrLen(typeBlock.TypeName, 0x20);
}
diff --git a/W4Gui/Components/SchemePanel.Designer.cs b/W4Gui/Components/SchemePanel.Designer.cs
index 39b6d52..c256f0c 100644
--- a/W4Gui/Components/SchemePanel.Designer.cs
+++ b/W4Gui/Components/SchemePanel.Designer.cs
@@ -451,12 +451,16 @@
// selWormSelectAtGameStart
//
this.selWormSelectAtGameStart.Dock = System.Windows.Forms.DockStyle.Top;
+ this.selWormSelectAtGameStart.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.selWormSelectAtGameStart.FormattingEnabled = true;
+ this.selWormSelectAtGameStart.Items.AddRange(new object[] {
+ "No",
+ "Yes"});
this.selWormSelectAtGameStart.Location = new System.Drawing.Point(121, 160);
this.selWormSelectAtGameStart.Name = "selWormSelectAtGameStart";
this.selWormSelectAtGameStart.Size = new System.Drawing.Size(546, 23);
this.selWormSelectAtGameStart.TabIndex = 32;
- this.selWormSelectAtGameStart.Text = "0";
- this.selWormSelectAtGameStart.Value = 0;
+ this.selWormSelectAtGameStart.Value = LibW4M.Data.YesNo.No;
//
// lblTurnTime
//
@@ -516,12 +520,16 @@
// selTeleportIn
//
this.selTeleportIn.Dock = System.Windows.Forms.DockStyle.Top;
+ this.selTeleportIn.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.selTeleportIn.FormattingEnabled = true;
+ this.selTeleportIn.Items.AddRange(new object[] {
+ "No",
+ "Yes"});
this.selTeleportIn.Location = new System.Drawing.Point(121, 98);
this.selTeleportIn.Name = "selTeleportIn";
this.selTeleportIn.Size = new System.Drawing.Size(546, 23);
this.selTeleportIn.TabIndex = 24;
- this.selTeleportIn.Text = "0";
- this.selTeleportIn.Value = 0;
+ this.selTeleportIn.Value = LibW4M.Data.YesNo.No;
//
// lblTeleportIn
//
@@ -587,12 +595,16 @@
// selArtilaryMode
//
this.selArtilaryMode.Dock = System.Windows.Forms.DockStyle.Top;
+ this.selArtilaryMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.selArtilaryMode.FormattingEnabled = true;
+ this.selArtilaryMode.Items.AddRange(new object[] {
+ "No",
+ "Yes"});
this.selArtilaryMode.Location = new System.Drawing.Point(121, 67);
this.selArtilaryMode.Name = "selArtilaryMode";
this.selArtilaryMode.Size = new System.Drawing.Size(546, 23);
this.selArtilaryMode.TabIndex = 22;
- this.selArtilaryMode.Text = "No";
- this.selArtilaryMode.Value = 0;
+ this.selArtilaryMode.Value = LibW4M.Data.YesNo.No;
//
// selNumRounds
//
@@ -607,12 +619,16 @@
// selDisplayTime
//
this.selDisplayTime.Dock = System.Windows.Forms.DockStyle.Top;
+ this.selDisplayTime.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.selDisplayTime.FormattingEnabled = true;
+ this.selDisplayTime.Items.AddRange(new object[] {
+ "No",
+ "Yes"});
this.selDisplayTime.Location = new System.Drawing.Point(121, 315);
this.selDisplayTime.Name = "selDisplayTime";
this.selDisplayTime.Size = new System.Drawing.Size(546, 23);
this.selDisplayTime.TabIndex = 46;
- this.selDisplayTime.Text = "0";
- this.selDisplayTime.Value = 0;
+ this.selDisplayTime.Value = LibW4M.Data.YesNo.No;
//
// selLandTime
//
@@ -637,12 +653,16 @@
// selFallDamage
//
this.selFallDamage.Dock = System.Windows.Forms.DockStyle.Top;
+ this.selFallDamage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.selFallDamage.FormattingEnabled = true;
+ this.selFallDamage.Items.AddRange(new object[] {
+ "No",
+ "Yes"});
this.selFallDamage.Location = new System.Drawing.Point(121, 408);
this.selFallDamage.Name = "selFallDamage";
this.selFallDamage.Size = new System.Drawing.Size(546, 23);
this.selFallDamage.TabIndex = 49;
- this.selFallDamage.Text = "0";
- this.selFallDamage.Value = 0;
+ this.selFallDamage.Value = LibW4M.Data.YesNo.No;
//
// selHotSeat
//
@@ -657,12 +677,16 @@
// selSpecial
//
this.selSpecial.Dock = System.Windows.Forms.DockStyle.Top;
+ this.selSpecial.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.selSpecial.FormattingEnabled = true;
+ this.selSpecial.Items.AddRange(new object[] {
+ "No",
+ "Yes"});
this.selSpecial.Location = new System.Drawing.Point(121, 470);
this.selSpecial.Name = "selSpecial";
this.selSpecial.Size = new System.Drawing.Size(546, 23);
this.selSpecial.TabIndex = 51;
- this.selSpecial.Text = "0";
- this.selSpecial.Value = 0;
+ this.selSpecial.Value = LibW4M.Data.YesNo.No;
//
// selHelpPanelDisplay
//
@@ -725,7 +749,7 @@
this.crateTab.Location = new System.Drawing.Point(4, 24);
this.crateTab.Name = "crateTab";
this.crateTab.Padding = new System.Windows.Forms.Padding(3);
- this.crateTab.Size = new System.Drawing.Size(699, 387);
+ this.crateTab.Size = new System.Drawing.Size(192, 72);
this.crateTab.TabIndex = 2;
this.crateTab.Text = "Crates";
//
@@ -759,7 +783,7 @@
this.tblCrate.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tblCrate.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tblCrate.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tblCrate.Size = new System.Drawing.Size(689, 188);
+ this.tblCrate.Size = new System.Drawing.Size(165, 188);
this.tblCrate.TabIndex = 1;
//
// selWeapCrateChance
@@ -767,7 +791,7 @@
this.selWeapCrateChance.Dock = System.Windows.Forms.DockStyle.Top;
this.selWeapCrateChance.Location = new System.Drawing.Point(144, 36);
this.selWeapCrateChance.Name = "selWeapCrateChance";
- this.selWeapCrateChance.Size = new System.Drawing.Size(540, 23);
+ this.selWeapCrateChance.Size = new System.Drawing.Size(16, 23);
this.selWeapCrateChance.TabIndex = 36;
this.selWeapCrateChance.Text = "0";
this.selWeapCrateChance.Value = 0;
@@ -788,7 +812,7 @@
this.selHealthCrateAmount.Dock = System.Windows.Forms.DockStyle.Top;
this.selHealthCrateAmount.Location = new System.Drawing.Point(144, 160);
this.selHealthCrateAmount.Name = "selHealthCrateAmount";
- this.selHealthCrateAmount.Size = new System.Drawing.Size(540, 23);
+ this.selHealthCrateAmount.Size = new System.Drawing.Size(16, 23);
this.selHealthCrateAmount.TabIndex = 34;
this.selHealthCrateAmount.Text = "0";
this.selHealthCrateAmount.Value = 0;
@@ -798,7 +822,7 @@
this.selHealthCrateChance.Dock = System.Windows.Forms.DockStyle.Top;
this.selHealthCrateChance.Location = new System.Drawing.Point(144, 129);
this.selHealthCrateChance.Name = "selHealthCrateChance";
- this.selHealthCrateChance.Size = new System.Drawing.Size(540, 23);
+ this.selHealthCrateChance.Size = new System.Drawing.Size(16, 23);
this.selHealthCrateChance.TabIndex = 32;
this.selHealthCrateChance.Text = "0";
this.selHealthCrateChance.Value = 0;
@@ -841,7 +865,7 @@
this.selMysteryCrateChance.Dock = System.Windows.Forms.DockStyle.Top;
this.selMysteryCrateChance.Location = new System.Drawing.Point(144, 67);
this.selMysteryCrateChance.Name = "selMysteryCrateChance";
- this.selMysteryCrateChance.Size = new System.Drawing.Size(540, 23);
+ this.selMysteryCrateChance.Size = new System.Drawing.Size(16, 23);
this.selMysteryCrateChance.TabIndex = 24;
this.selMysteryCrateChance.Text = "0";
this.selMysteryCrateChance.Value = 0;
@@ -873,7 +897,7 @@
this.selCrateChance.Dock = System.Windows.Forms.DockStyle.Top;
this.selCrateChance.Location = new System.Drawing.Point(144, 5);
this.selCrateChance.Name = "selCrateChance";
- this.selCrateChance.Size = new System.Drawing.Size(540, 23);
+ this.selCrateChance.Size = new System.Drawing.Size(16, 23);
this.selCrateChance.TabIndex = 22;
this.selCrateChance.Text = "0";
this.selCrateChance.Value = 0;
@@ -883,7 +907,7 @@
this.selUtilityCrateChance.Dock = System.Windows.Forms.DockStyle.Top;
this.selUtilityCrateChance.Location = new System.Drawing.Point(144, 98);
this.selUtilityCrateChance.Name = "selUtilityCrateChance";
- this.selUtilityCrateChance.Size = new System.Drawing.Size(540, 23);
+ this.selUtilityCrateChance.Size = new System.Drawing.Size(16, 23);
this.selUtilityCrateChance.TabIndex = 26;
this.selUtilityCrateChance.Text = "0";
this.selUtilityCrateChance.Value = 0;