Skip to content

Commit

Permalink
Changelog
Browse files Browse the repository at this point in the history
- Added Map Sync configuration
- Added Info to the valheim_plus.cfg
  • Loading branch information
nxPublic committed Mar 13, 2021
1 parent 4d45c77 commit faee2a7
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 41 deletions.
72 changes: 36 additions & 36 deletions ValheimPlus/GameClasses/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,55 +41,55 @@ public static class Container_Awake_Patch
/// </summary>
static void Postfix(Container __instance, ref Inventory ___m_inventory)
{
if (!Configuration.Current.Inventory.IsEnabled) return;

string containerName = __instance.transform.parent.name;
string inventoryName = ___m_inventory.m_name;
ref int inventoryColumns = ref ___m_inventory.m_width;
ref int inventoryRows = ref ___m_inventory.m_height;

if (Configuration.Current.Inventory.IsEnabled)
// Karve (small boat)
// Use Contains because the actual name is "Karve (Clone)"
if (containerName.Contains("Karve"))
{
// Karve (small boat)
// Use Contains because the actual name is "Karve (Clone)"
if (containerName.Contains("Karve"))
{
inventoryRows = Helper.Clamp(Configuration.Current.Inventory.karveInventoryRows, karveChestInventoryMinRows, karveChestInventoryMaxRows);
inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.karveInventoryColumns, karveChestInventoryMinCol, karveChestInventoryMaxCol);
}
// Longboat (Large boat)
else if (containerName.Contains("VikingShip"))
inventoryRows = Helper.Clamp(Configuration.Current.Inventory.karveInventoryRows, karveChestInventoryMinRows, karveChestInventoryMaxRows);
inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.karveInventoryColumns, karveChestInventoryMinCol, karveChestInventoryMaxCol);
}
// Longboat (Large boat)
else if (containerName.Contains("VikingShip"))
{
inventoryRows = Helper.Clamp(Configuration.Current.Inventory.longboatInventoryRows, longboatChestInventoryMinRows, longboatChestInventoryMaxRows);
inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.longboatInventoryColumns, longboatChestInventoryMinCol, longboatChestInventoryMaxCol);
}
// Cart (Wagon)
else if (containerName.Contains("Cart"))
{
inventoryRows = Helper.Clamp(Configuration.Current.Inventory.cartInventoryRows, cartChestInventoryMinRows, cartChestInventoryMaxRows);
inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.cartInventoryColumns, cartChestInventoryMinCol, cartChestInventoryMaxCol);
}
// Chests (containerName is _NetSceneRoot)
else
{
// Personal chest
if (inventoryName == "$piece_chestprivate")
{
inventoryRows = Helper.Clamp(Configuration.Current.Inventory.longboatInventoryRows, longboatChestInventoryMinRows, longboatChestInventoryMaxRows);
inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.longboatInventoryColumns, longboatChestInventoryMinCol, longboatChestInventoryMaxCol);
inventoryRows = Helper.Clamp(Configuration.Current.Inventory.personalChestRows, personalChestInventoryMinRows, personalChestInventoryMaxRows);
inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.personalChestColumns, personalChestInventoryMinCol, personalChestInventoryMaxCol);
}
// Cart (Wagon)
else if (containerName.Contains("Cart"))
// Wood chest
else if (inventoryName == "$piece_chestwood")
{
inventoryRows = Helper.Clamp(Configuration.Current.Inventory.cartInventoryRows, cartChestInventoryMinRows, cartChestInventoryMaxRows);
inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.cartInventoryColumns, cartChestInventoryMinCol, cartChestInventoryMaxCol);
inventoryRows = Helper.Clamp(Configuration.Current.Inventory.woodChestRows, woodChestInventoryMinRows, woodChestInventoryMaxRows);
inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.woodChestColumns, woodChestInventoryMinCol, woodChestInventoryMaxCol);
}
// Chests (containerName is _NetSceneRoot)
else
// Iron chest
else if (inventoryName == "$piece_chest")
{
// Personal chest
if (inventoryName == "$piece_chestprivate")
{
inventoryRows = Helper.Clamp(Configuration.Current.Inventory.personalChestRows, personalChestInventoryMinRows, personalChestInventoryMaxRows);
inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.personalChestColumns, personalChestInventoryMinCol, personalChestInventoryMaxCol);
}
// Wood chest
else if (inventoryName == "$piece_chestwood")
{
inventoryRows = Helper.Clamp(Configuration.Current.Inventory.woodChestRows, woodChestInventoryMinRows, woodChestInventoryMaxRows);
inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.woodChestColumns, woodChestInventoryMinCol, woodChestInventoryMaxCol);
}
// Iron chest
else if (inventoryName == "$piece_chest")
{
inventoryRows = Helper.Clamp(Configuration.Current.Inventory.ironChestRows, ironChestInventoryMinRows, ironChestInventoryMaxRows);
inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.ironChestColumns, ironChestInventoryMinCol, ironChestInventoryMaxCol);
}
inventoryRows = Helper.Clamp(Configuration.Current.Inventory.ironChestRows, ironChestInventoryMinRows, ironChestInventoryMaxRows);
inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.ironChestColumns, ironChestInventoryMinCol, ironChestInventoryMaxCol);
}
}

}
}
}
2 changes: 1 addition & 1 deletion ValheimPlus/GameClasses/Minimap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static class MinimapAwake
{
private static void Postfix()
{
if (ZNet.m_isServer)
if (ZNet.m_isServer && Configuration.Current.Map.IsEnabled && Configuration.Current.Map.shareMapProgression)
{
//Init map array
VPlusMapSync.ServerMapData = new bool[Minimap.instance.m_textureSize * Minimap.instance.m_textureSize];
Expand Down
2 changes: 1 addition & 1 deletion ValheimPlus/GameClasses/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private static void Prefix()
Player.m_localPlayer.ShowTutorial("vplus");

//Only sync on first spawn
if (VPlusMapSync.ShouldSyncOnSpawn)
if (VPlusMapSync.ShouldSyncOnSpawn && Configuration.Current.Map.IsEnabled && Configuration.Current.Map.shareMapProgression)
{
//Send map data to the server
VPlusMapSync.SendMapToServer();
Expand Down
6 changes: 4 additions & 2 deletions ValheimPlus/GameClasses/ZNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ private static void Prefix(ref ZNet __instance)
ValheimPlusPlugin.harmony.PatchAll();

//We left the server, so reset our map sync check.
VPlusMapSync.ShouldSyncOnSpawn = true;
if (Configuration.Current.Map.IsEnabled && Configuration.Current.Map.shareMapProgression)
VPlusMapSync.ShouldSyncOnSpawn = true;
}
else
{
//Save map data to disk
VPlusMapSync.SaveMapDataToDisk();
if (Configuration.Current.Map.IsEnabled && Configuration.Current.Map.shareMapProgression)
VPlusMapSync.SaveMapDataToDisk();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ValheimPlus/ValheimPlus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void Awake()
VPlusMainMenu.Load();

//Map Sync Save Timer
if (ZNet.m_isServer)
if (ZNet.m_isServer && Configuration.Current.Map.IsEnabled && Configuration.Current.Map.shareMapProgression)
{
mapSyncSaveTimer.AutoReset = true;
mapSyncSaveTimer.Elapsed += (sender, args) => VPlusMapSync.SaveMapDataToDisk();
Expand Down
1 change: 1 addition & 0 deletions valheim_plus.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ autoDepositRange=10
enabled=false

; With this enabled you will receive the same exploration progression as other players on the server
; This will also enable the option for the server to sync everyones exploration progression on connecting to the server.
shareMapProgression=false

; The radius of the map that you explore when moving
Expand Down

0 comments on commit faee2a7

Please sign in to comment.