Skip to content

Commit 48004e2

Browse files
committed
Fix IsActive flag offset causing dens to not activate
The IsActive flag was being read/written at the wrong memory offset. DeterminePointer points to Seed (0x10), but IsActive is at offset 0x00. The old code added 0x18 (pointing to Flags field) instead of subtracting 0x10. Also fixed data type from byte to uint32.
1 parent 4b907d1 commit 48004e2

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

SysBot.Pokemon/Helpers/RaidMemoryManager.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ private static List<long> DeterminePointer(int index)
153153

154154
/// <summary>
155155
/// Reads the IsActive flag for a raid at the specified index.
156+
/// IsActive (IsEnabled) is at offset 0x00 within the raid structure.
157+
/// DeterminePointer returns a pointer to the Seed (offset 0x10), so we subtract 0x10.
156158
/// </summary>
157159
/// <param name="index">The global raid index</param>
158160
/// <param name="token">Cancellation token</param>
@@ -162,9 +164,11 @@ public async Task<bool> ReadIsActiveFlag(int index, CancellationToken token)
162164
try
163165
{
164166
var ptr = DeterminePointer(index);
165-
ptr[3] += 0x18;
166-
byte[] data = await _connection.PointerPeek(1, ptr, token).ConfigureAwait(false);
167-
return data[0] != 0;
167+
// IsActive is at offset 0x00, Seed is at offset 0x10, so IsActive = Seed - 0x10
168+
ptr[3] -= 0x10;
169+
// IsActive is a uint32 (4 bytes), value of 1 = active
170+
byte[] data = await _connection.PointerPeek(4, ptr, token).ConfigureAwait(false);
171+
return BitConverter.ToUInt32(data, 0) == 1;
168172
}
169173
catch
170174
{
@@ -174,6 +178,8 @@ public async Task<bool> ReadIsActiveFlag(int index, CancellationToken token)
174178

175179
/// <summary>
176180
/// Sets the IsActive flag for a raid at the specified index.
181+
/// IsActive (IsEnabled) is at offset 0x00 within the raid structure.
182+
/// DeterminePointer returns a pointer to the Seed (offset 0x10), so we subtract 0x10.
177183
/// </summary>
178184
/// <param name="index">The global raid index</param>
179185
/// <param name="isActive">True to mark as active, false to mark as inactive</param>
@@ -184,12 +190,14 @@ public async Task<bool> SetIsActiveFlag(int index, bool isActive, CancellationTo
184190
try
185191
{
186192
var ptr = DeterminePointer(index);
187-
ptr[3] += 0x18;
188-
byte[] flagByte = [(byte)(isActive ? 1 : 0)];
189-
await _connection.PointerPoke(flagByte, ptr, token).ConfigureAwait(false);
193+
// IsActive is at offset 0x00, Seed is at offset 0x10, so IsActive = Seed - 0x10
194+
ptr[3] -= 0x10;
195+
// IsActive is a uint32 (4 bytes), value of 1 = active, 0 = inactive
196+
byte[] flagBytes = BitConverter.GetBytes(isActive ? 1u : 0u);
197+
await _connection.PointerPoke(flagBytes, ptr, token).ConfigureAwait(false);
190198

191-
byte[] verification = await _connection.PointerPeek(1, ptr, token).ConfigureAwait(false);
192-
return verification[0] == flagByte[0];
199+
byte[] verification = await _connection.PointerPeek(4, ptr, token).ConfigureAwait(false);
200+
return BitConverter.ToUInt32(verification, 0) == (isActive ? 1u : 0u);
193201
}
194202
catch
195203
{

SysBot.Pokemon/Helpers/SVRaidBot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
public static class SVRaidBot
44
{
5-
public const string Version = "v8.7.6";
5+
public const string Version = "v8.7.7";
66
public const string Repo = "https://github.com/hexbyt3/SVRaidBot";
77
public const string ConfigPath = "config.json";
88
}

0 commit comments

Comments
 (0)