Skip to content

Commit

Permalink
家具使用数上限调整为65535
Browse files Browse the repository at this point in the history
  • Loading branch information
1144822034 committed Nov 8, 2020
1 parent bff75a7 commit 994a382
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 63 deletions.
10 changes: 5 additions & 5 deletions Engine/Engine/Storage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static Stream OpenFile(string path, OpenFileMode openFileMode)

public static void DeleteFile(string path)
{
File.Delete(ProcessPath(path, writeAccess: true, failIfApp: true));
File.Delete(ProcessPath(path, writeAccess: true, failIfApp: false));
}

public static void CopyFile(string sourcePath, string destinationPath)
Expand All @@ -94,8 +94,8 @@ public static void CopyFile(string sourcePath, string destinationPath)

public static void MoveFile(string sourcePath, string destinationPath)
{
string sourceFileName = ProcessPath(sourcePath, writeAccess: true, failIfApp: true);
string text = ProcessPath(destinationPath, writeAccess: true, failIfApp: true);
string sourceFileName = ProcessPath(sourcePath, writeAccess: true, failIfApp: false);
string text = ProcessPath(destinationPath, writeAccess: true, failIfApp: false);
File.Delete(text);
File.Move(sourceFileName, text);
}
Expand All @@ -107,7 +107,7 @@ public static void CreateDirectory(string path)

public static void DeleteDirectory(string path)
{
Directory.Delete(ProcessPath(path, writeAccess: true, failIfApp: true));
Directory.Delete(ProcessPath(path, writeAccess: true, failIfApp: false));
}

public static IEnumerable<string> ListFileNames(string path)
Expand Down Expand Up @@ -166,7 +166,7 @@ public static void WriteAllBytes(string path, byte[] bytes)

public static string GetSystemPath(string path)
{
return ProcessPath(path, writeAccess: false, failIfApp: true);
return ProcessPath(path, writeAccess: false, failIfApp: false);
}

public static string GetExtension(string path)
Expand Down
4 changes: 2 additions & 2 deletions Survivalcraft/Component/ComponentFurnitureInventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ComponentFurnitureInventory : Component, IInventory
public List<int> m_slots = new List<int>();

public const int m_largeNumber = 9999;

public const int maxDesign = 65535;
public int PageIndex
{
get;
Expand Down Expand Up @@ -56,7 +56,7 @@ public void FillSlots()
{
m_subsystemFurnitureBlockBehavior.GarbageCollectDesigns();
m_slots.Clear();
for (int i = 0; i < 1024; i++)
for (int i = 0; i < maxDesign; i++)
{
FurnitureDesign design = m_subsystemFurnitureBlockBehavior.GetDesign(i);
if (design != null)
Expand Down
4 changes: 2 additions & 2 deletions Survivalcraft/Game/GameMenuDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ public GameMenuDialog(ComponentPlayer componentPlayer)
AddStat(stackPanelWidget, LanguageControl.Get(fName, 12), WorldOptionsScreen.FormatOffset(subsystemGameInfo.WorldSettings.HumidityOffset));
AddStat(stackPanelWidget, LanguageControl.Get(fName, 13), subsystemGameInfo.WorldSettings.BiomeSize.ToString() + "x");
int num = 0;
for (int i = 0; i < 1024; i++)
for (int i = 0; i < ComponentFurnitureInventory.maxDesign; i++)
{
if (subsystemFurnitureBlockBehavior.GetDesign(i) != null)
{
num++;
}
}
AddStat(stackPanelWidget, LanguageControl.Get(fName, 14), $"{num}/{1024}");
AddStat(stackPanelWidget, LanguageControl.Get(fName, 14), $"{num}/{ComponentFurnitureInventory.maxDesign}");
AddStat(stackPanelWidget, LanguageControl.Get(fName, 15), string.IsNullOrEmpty(subsystemGameInfo.WorldSettings.OriginalSerializationVersion) ? LanguageControl.Get(fName, 16) : subsystemGameInfo.WorldSettings.OriginalSerializationVersion);
stackPanelWidget.Children.Add(new LabelWidget
{
Expand Down
102 changes: 50 additions & 52 deletions Survivalcraft/Subsystem/SubsystemFurnitureBlockBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ namespace Game
{
public class SubsystemFurnitureBlockBehavior : SubsystemBlockBehavior
{
public const int MaxDesigns = 1024;

public const int MaxFurnitureSetNameLength = 20;
public const int MaxFurnitureSetNameLength = 64;

public SubsystemAudio m_subsystemAudio;

Expand All @@ -28,7 +26,7 @@ public class SubsystemFurnitureBlockBehavior : SubsystemBlockBehavior

public List<FurnitureSet> m_furnitureSets = new List<FurnitureSet>();

public FurnitureDesign[] m_furnitureDesigns = new FurnitureDesign[1024];
public FurnitureDesign[] m_furnitureDesigns = new FurnitureDesign[ComponentFurnitureInventory.maxDesign];

public Dictionary<Point3, List<FireParticleSystem>> m_particleSystemsByCell = new Dictionary<Point3, List<FireParticleSystem>>();

Expand Down Expand Up @@ -234,7 +232,7 @@ public void ScanDesign(CellFace start, Vector3 direction, ComponentMiner compone
Point3 delta = new Point3((point5.X - location.X) / 2, -location.Y, (point5.Z - location.Z) / 2);
design.Shift(delta);
}
BuildFurnitureDialog dialog = new BuildFurnitureDialog(design, furnitureDesign, delegate(bool result)
BuildFurnitureDialog dialog = new BuildFurnitureDialog(design, furnitureDesign, delegate (bool result)
{
if (result)
{
Expand Down Expand Up @@ -329,9 +327,9 @@ public void GarbageCollectDesigns()

public FurnitureSet NewFurnitureSet(string name, string importedFrom)
{
if (name.Length > 20)
if (name.Length > MaxFurnitureSetNameLength)
{
name = name.Substring(0, 20);
name = name.Substring(0, MaxFurnitureSetNameLength);
}
int num = 0;
while (FurnitureSets.FirstOrDefault((FurnitureSet fs) => fs.Name == name) != null)
Expand Down Expand Up @@ -527,7 +525,7 @@ public override void Save(ValuesDictionary valuesDictionary)
valuesDictionary4.SetValue("ImportedFrom", furnitureSet.ImportedFrom);
}
string value = HumanReadableConverter.ValuesListToString(';', (from d in GetFurnitureSetDesigns(furnitureSet)
select d.Index).ToArray());
select d.Index).ToArray());
valuesDictionary4.SetValue("Indices", value);
num++;
}
Expand Down Expand Up @@ -611,50 +609,50 @@ public static bool IsValueAllowed(int value)
{
switch (Terrain.ExtractContents(value))
{
case 21:
return true;
case 3:
return true;
case 67:
return true;
case 7:
return true;
case 72:
return true;
case 5:
return true;
case 26:
return true;
case 4:
return true;
case 68:
return true;
case 73:
return true;
case 150:
return true;
case 71:
return true;
case 126:
return true;
case 47:
return true;
case 46:
return true;
case 15:
return true;
case 208:
return true;
case 31:
return true;
case 17:
return true;
case 18:
return true;
case 92:
return true;
default:
return false;
case 21:
return true;
case 3:
return true;
case 67:
return true;
case 7:
return true;
case 72:
return true;
case 5:
return true;
case 26:
return true;
case 4:
return true;
case 68:
return true;
case 73:
return true;
case 150:
return true;
case 71:
return true;
case 126:
return true;
case 47:
return true;
case 46:
return true;
case 15:
return true;
case 208:
return true;
case 31:
return true;
case 17:
return true;
case 18:
return true;
case 92:
return true;
default:
return false;
}
}

Expand Down
4 changes: 2 additions & 2 deletions Survivalcraft/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@

},
"FurnitureInventoryPanel": {
"1": "{0}个设计被添加. ",
"2": "{0}个设计已存在在这个世界中,并被忽略",
"1": "{0}个家具被添加. ",
"2": "{0}个家具已存在在这个世界中,并被忽略",
"3": "{0}个家具被忽略,因为已经达到{1}个家具限制数",
"4": "导入成功",
"5": "导入失败",
Expand Down

0 comments on commit 994a382

Please sign in to comment.