Skip to content

Commit

Permalink
Quick patches to fix overlap ids.
Browse files Browse the repository at this point in the history
The code is dirty and I'm not proud.
  • Loading branch information
ThePhar committed Sep 5, 2024
1 parent f69b500 commit 7034340
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 25 deletions.
12 changes: 6 additions & 6 deletions Randomizer/ArchipelagoManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class ArchipelagoManager
public DeathLink DeathLinkData { get; private set; }
public bool IsDeathLinkSafe { get; set; }
public bool Ready { get; private set; }
public Queue<Tuple<int, NetworkItem>> ItemQueue { get; private set; } = new();
public Dictionary<long, NetworkItem> LocationDictionary { get; private set; } = new();
public Queue<Tuple<int, ItemInfo>> ItemQueue { get; private set; } = new();
public Dictionary<long, ItemInfo> LocationDictionary { get; private set; } = new();
public List<Tuple<JsonMessageType, JsonMessagePart[]>> ChatLog { get; } = new();

public bool CanCollect => _session.RoomState.CollectPermissions is Permissions.Goal or Permissions.Enabled;
Expand Down Expand Up @@ -270,11 +270,11 @@ public string GetItemName(long item)
/// <param name="item">The network item to get name from.</param>
/// <returns>A string representation of the item (or a trap).</returns>
[SuppressMessage("ReSharper", "StringLiteralTypo")]
public string GetItemOrTrapName(NetworkItem item)
public string GetItemOrTrapName(ItemInfo item)
{
if (!item.Flags.HasFlag(ItemFlags.Trap))
{
return GetItemName(item.Item);
return GetItemName(item.ItemId);
}

// I'm hilarious, obviously.
Expand Down Expand Up @@ -366,9 +366,9 @@ private async Task BuildLocationDictionary()
{
var locations = await _session.Locations.ScoutLocationsAsync(false, _session.Locations.AllLocations.ToArray());

foreach (var item in locations.Locations)
foreach (var item in locations.Values)
{
LocationDictionary[item.Location] = item;
LocationDictionary[item.LocationId] = item;
}
}

Expand Down
18 changes: 12 additions & 6 deletions Randomizer/ItemHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,16 @@ public void CheckReceivedItemQueue()
return;
}

var (index, item) = Manager.ItemQueue.Dequeue();
var (index, itemInfo) = Manager.ItemQueue.Dequeue();
if (!HasReceivedItem(index))
{
GainItem(item);
GainItem(itemInfo);
var item = new NetworkItem
{
Item = itemInfo.ItemId,
Location = itemInfo.LocationId,
Player = itemInfo.Player,
};
ReceivedItems.Add(index, item);
Program.Game.SaveManager.SaveFiles(SaveType.PlayerData, SaveType.Lineage, SaveType.UpgradeData);
}
Expand All @@ -45,10 +51,10 @@ private bool HasReceivedItem(int index)
return ReceivedItems.ContainsKey(index);
}

private static void GainItem(NetworkItem item)
private static void GainItem(ItemInfo item)
{
var stats = new float[] { -1, -1, -1 };
switch (item.Item)
switch (item.ItemId)
{
#region Vendors

Expand Down Expand Up @@ -479,8 +485,8 @@ private static void GainItem(NetworkItem item)
// Add item to received items HUD.
var tupleStats = new Tuple<float, float, float, float>(stats[0], stats[1], stats[2], 0);
Game.ScreenManager.GetLevelScreen().AddReceivedItem(
item.Item.GetItemType(),
item.Item,
item.ItemId.GetItemType(),
item.ItemId,
Manager.GetPlayerName(item.Player),
tupleStats
);
Expand Down
6 changes: 3 additions & 3 deletions Rogue Legacy Randomizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="Archipelago.MultiClient.Net, Version=5.0.6.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Archipelago.MultiClient.Net.5.0.6\lib\net45\Archipelago.MultiClient.Net.dll</HintPath>
<Reference Include="Archipelago.MultiClient.Net, Version=6.3.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Archipelago.MultiClient.Net.6.3.1\lib\net45\Archipelago.MultiClient.Net.dll</HintPath>
</Reference>
<Reference Include="DS2DEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>lib\DS2DEngine.dll</HintPath>
Expand All @@ -57,7 +57,7 @@
</Reference>
<Reference Include="mscorlib" />
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Archipelago.MultiClient.Net.5.0.6\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>packages\Archipelago.MultiClient.Net.6.3.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="SpriteSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>lib\SpriteSystem.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion RogueLegacy/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ public void CollectItemFromLocation(long location)
new Vector2(stats.Item1, stats.Item4),
new Vector2(stats.Item2, stats.Item3),
ArchipelagoManager.GetPlayerName(item.Player),
item.Item
item.ItemId,
};

ScreenManager.DisplayScreen((int) ScreenType.GetItem, true, data);
Expand Down
8 changes: 4 additions & 4 deletions RogueLegacy/LevelENV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public static class LevelENV
public const int LevelDungeonBottomDoor = 100;

public static string GameName => "Rogue Legacy Randomizer";
public static Version TargetVersion => Version.Parse("1.0.0");
public static int PreRelease => 6;
public static string FullVersion => $"v{TargetVersion}" + (PreRelease > 0 ? $" Alpha {PreRelease}" : "");
public static string VersionSubtitle => "Development Build 2023-10-26";
public static Version TargetVersion => Version.Parse("1.0.1");
public static int PreRelease => 1;
public static string FullVersion => $"v{TargetVersion}" + (PreRelease > 0 ? $" Alpha Hotfix {PreRelease}" : "");
public static string VersionSubtitle => "Development Build 2024-09-05";

static LevelENV()
{
Expand Down
6 changes: 3 additions & 3 deletions RogueLegacy/Screens/SkillScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ public override void OnEnter()
var item = Program.Game.ArchipelagoManager.LocationDictionary[ManorContainer.ArchipelagoLocationTable[(ManorPiece) SkillSystem.GetManorPiece(s)]];

// Toggle correct plate.
s.IconName = GetSkillPlateIcon(item.Item);
s.Name = Program.Game.ArchipelagoManager.GetLocationName(item.Location).Replace("Manor - ", "");
s.IconName = GetSkillPlateIcon(item.ItemId);
s.Name = Program.Game.ArchipelagoManager.GetLocationName(item.LocationId).Replace("Manor - ", "");
var itemName = Program.Game.ArchipelagoManager.GetItemOrTrapName(item);

// Check if we grabbed this location, and change our skillArray current level.
if (Program.Game.ArchipelagoManager.IsLocationChecked(item.Location))
if (Program.Game.ArchipelagoManager.IsLocationChecked(item.LocationId))
{
s.CurrentLevel = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion inno/installer.iss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define MyAppId "{6741975E-782A-438F-8C05-502EDB37E7DB}"
#define MyAppName "Rogue Legacy Randomizer"
#define MyAppVersion "1.0.0 Alpha 6"
#define MyAppVersion "1.0.1 Alpha Hotfix 1"
#define MyAppPublisher "Zach Parks & Cellar Door Games"
#define MyAppURL "https://github.com/ThePhar/RogueLegacyRandomizer"
#define MyAppExeName "Rogue Legacy Randomizer.exe"
Expand Down
2 changes: 1 addition & 1 deletion packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Archipelago.MultiClient.Net" version="5.0.6" targetFramework="net481" />
<package id="Archipelago.MultiClient.Net" version="6.3.1" targetFramework="net481" />
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net48" />
</packages>

0 comments on commit 7034340

Please sign in to comment.