Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version memes #68

Merged
merged 4 commits into from
Nov 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 98 additions & 59 deletions src/SoulMemory/EldenRing/EldenRing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using SoulMemory.Memory;
using SoulMemory.Native;
using Pointer = SoulMemory.Memory.Pointer;
Expand Down Expand Up @@ -80,47 +81,62 @@
var version = GetVersion(v);
switch (version)
{
case EldenRingVersion.V102:
case EldenRingVersion.V1_02_0:
case EldenRingVersion.V1_02_1:
case EldenRingVersion.V1_02_2:
case EldenRingVersion.V1_02_3:
_screenStateOffset = 0x718;
_positionOffset = 0x6b8;
_mapIdOffset = 0x6c8;
_playerInsOffset = 0x18468;
break;

case EldenRingVersion.V103:
case EldenRingVersion.V1_03_0:
case EldenRingVersion.V1_03_1:
case EldenRingVersion.V1_03_2:
_screenStateOffset = 0x728;
_positionOffset = 0x6b8;
_mapIdOffset = 0x6c8;
_playerInsOffset = 0x18468;
break;

case EldenRingVersion.V104:
case EldenRingVersion.V105:
case EldenRingVersion.V106:

case EldenRingVersion.V1_04_0:
case EldenRingVersion.V1_04_1:
case EldenRingVersion.V1_05_0:
case EldenRingVersion.V1_06_0:
_screenStateOffset = 0x728;
_positionOffset = 0x6B0;
_mapIdOffset = 0x6c0;
_playerInsOffset = 0x18468;
break;

case EldenRingVersion.V107:
case EldenRingVersion.V1_07_0:
_screenStateOffset = 0x728;
_positionOffset = 0x6B0;
_mapIdOffset = 0x6c0;
_playerInsOffset = 0x1e508;
break;

case EldenRingVersion.V108:
case EldenRingVersion.V109:
case EldenRingVersion.V110:
case EldenRingVersion.V1_08_0:
case EldenRingVersion.V1_08_1:
case EldenRingVersion.V1_09_0:
case EldenRingVersion.V1_09_1:
case EldenRingVersion.V1_10_0:
case EldenRingVersion.V1_10_1:
_screenStateOffset = 0x728;
_positionOffset = 0x6d4;
_mapIdOffset = 0x6d0;
_playerInsOffset = 0x1e508;
break;

default:
case EldenRingVersion.V112:
case EldenRingVersion.V1_12_0:

Check warning on line 134 in src/SoulMemory/EldenRing/EldenRing.cs

View workflow job for this annotation

GitHub Actions / build

Remove this empty 'case' clause. (https://rules.sonarsource.com/csharp/RSPEC-3458)

Check warning on line 134 in src/SoulMemory/EldenRing/EldenRing.cs

View workflow job for this annotation

GitHub Actions / build

Remove this empty 'case' clause. (https://rules.sonarsource.com/csharp/RSPEC-3458)
case EldenRingVersion.V1_12_3:

Check warning on line 135 in src/SoulMemory/EldenRing/EldenRing.cs

View workflow job for this annotation

GitHub Actions / build

Remove this empty 'case' clause. (https://rules.sonarsource.com/csharp/RSPEC-3458)

Check warning on line 135 in src/SoulMemory/EldenRing/EldenRing.cs

View workflow job for this annotation

GitHub Actions / build

Remove this empty 'case' clause. (https://rules.sonarsource.com/csharp/RSPEC-3458)
case EldenRingVersion.V1_13_0:

Check warning on line 136 in src/SoulMemory/EldenRing/EldenRing.cs

View workflow job for this annotation

GitHub Actions / build

Remove this empty 'case' clause. (https://rules.sonarsource.com/csharp/RSPEC-3458)

Check warning on line 136 in src/SoulMemory/EldenRing/EldenRing.cs

View workflow job for this annotation

GitHub Actions / build

Remove this empty 'case' clause. (https://rules.sonarsource.com/csharp/RSPEC-3458)
case EldenRingVersion.V1_14_0:

Check warning on line 137 in src/SoulMemory/EldenRing/EldenRing.cs

View workflow job for this annotation

GitHub Actions / build

Remove this empty 'case' clause. (https://rules.sonarsource.com/csharp/RSPEC-3458)
case EldenRingVersion.V1_15_0:

Check warning on line 138 in src/SoulMemory/EldenRing/EldenRing.cs

View workflow job for this annotation

GitHub Actions / build

Remove this empty 'case' clause. (https://rules.sonarsource.com/csharp/RSPEC-3458)
case EldenRingVersion.V1_16_0:

Check warning on line 139 in src/SoulMemory/EldenRing/EldenRing.cs

View workflow job for this annotation

GitHub Actions / build

Remove this empty 'case' clause. (https://rules.sonarsource.com/csharp/RSPEC-3458)
_screenStateOffset = 0x730;
_positionOffset = 0x6d4;
_mapIdOffset = 0x6d0;
Expand Down Expand Up @@ -186,67 +202,90 @@

#endregion

#region version ================================================================================================

private readonly Dictionary<EldenRingVersion, Version> _versions = new Dictionary<EldenRingVersion, Version>()
{

{ EldenRingVersion.V1_02_0, new Version(1,2,0,0) },
{ EldenRingVersion.V1_02_1, new Version(1,2,1,0) },
{ EldenRingVersion.V1_02_2, new Version(1,2,2,0) },
{ EldenRingVersion.V1_02_3, new Version(1,2,3,0) },
{ EldenRingVersion.V1_03_0, new Version(1,3,0,0) },
{ EldenRingVersion.V1_03_1, new Version(1,3,1,0) },
{ EldenRingVersion.V1_03_2, new Version(1,3,2,0) },
{ EldenRingVersion.V1_04_0, new Version(1,4,0,0) },
{ EldenRingVersion.V1_04_1, new Version(1,4,1,0) },
{ EldenRingVersion.V1_05_0, new Version(1,5,0,0) },
{ EldenRingVersion.V1_06_0, new Version(1,6,0,0) },
{ EldenRingVersion.V1_07_0, new Version(1,7,0,0) },
{ EldenRingVersion.V1_08_0, new Version(1,8,0,0) },
{ EldenRingVersion.V1_08_1, new Version(1,8,1,0) },
{ EldenRingVersion.V1_09_0, new Version(1,9,0,0) },
{ EldenRingVersion.V1_09_1, new Version(1,9,1,0) },
//1.10 turned into 2.0.0.0 for some reason
{ EldenRingVersion.V1_10_0, new Version(2,0,0,0) },
{ EldenRingVersion.V1_10_1, new Version(2,0,1,0) },
{ EldenRingVersion.V1_12_0, new Version(2,2,0,0) },
{ EldenRingVersion.V1_12_3, new Version(2,2,3,0) },
{ EldenRingVersion.V1_13_0, new Version(2,3,0,0) },
{ EldenRingVersion.V1_14_0, new Version(2,4,0,0) },
{ EldenRingVersion.V1_15_0, new Version(2,5,0,0) },
{ EldenRingVersion.V1_16_0, new Version(2,6,0,0) },
};

public enum EldenRingVersion
{
V102,
V103,
V104,
V105,
V106,
V107,
V108,
V109,
V110,
V112,

V1_02_0,
V1_02_1,
V1_02_2,
V1_02_3,

V1_03_0,
V1_03_1,
V1_03_2,

V1_04_0,
V1_04_1,

V1_05_0,
V1_06_0,
V1_07_0,

V1_08_0,
V1_08_1,

V1_09_0,
V1_09_1,

V1_10_0,
V1_10_1,

V1_12_0,
V1_12_3,

V1_13_0,
V1_14_0,
V1_15_0,
V1_16_0,

Unknown,
};

public EldenRingVersion GetVersion(Version v)
{
switch (v.Major)
var version = _versions.FirstOrDefault(i => i.Value.CompareTo(v) == 0);
if (version.Value == null)
{
default:
return EldenRingVersion.Unknown;

case 1:
switch (v.Minor)
{
default:
return EldenRingVersion.Unknown;
case 2:
return EldenRingVersion.V102;
case 3:
return EldenRingVersion.V103;
case 4:
return EldenRingVersion.V104;
case 5:
return EldenRingVersion.V105;
case 6:
return EldenRingVersion.V106;
case 7:
return EldenRingVersion.V107;
case 8:
return EldenRingVersion.V108;
case 9:
return EldenRingVersion.V109;
case 10:
return EldenRingVersion.V110;
}

case 2:
switch (v.Minor)
{
default:
return EldenRingVersion.Unknown;
case 0:
return EldenRingVersion.V110;
case 2:
return EldenRingVersion.V112;
}
return EldenRingVersion.Unknown;
}

return version.Key;
}

#endregion

public void EnableHud()
{
if (_hud != null)
Expand Down Expand Up @@ -386,7 +425,7 @@

#region Read event flag

public bool ReadEventFlag(uint eventFlagId)

Check warning on line 428 in src/SoulMemory/EldenRing/EldenRing.cs

View workflow job for this annotation

GitHub Actions / build

Refactor this method to reduce its Cognitive Complexity from 20 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)
{
var divisor = _virtualMemoryFlag.ReadInt32(0x1c);
//This check does not exist in the games code; reading 0 here means something isn't initialized yet and we should check this flag again later.
Expand Down
Loading