Skip to content

Commit 203f001

Browse files
committed
Use an unsigned type for IEmuClientApi.ShowFuture
fixes 6223c9d
1 parent fd5573c commit 203f001

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/BizHawk.Client.Common/Api/Classes/EmuClientApi.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,11 @@ public void SetWindowSize(int size)
219219
}
220220
}
221221

222-
public void ShowFuture(ShowFutureCallback/*?*/ preFrameCallback, short maxFrames)
222+
public void ShowFuture(ShowFutureCallback/*?*/ preFrameCallback, ushort maxFrames)
223223
{
224224
if (preFrameCallback is not null)
225225
{
226-
if (maxFrames <= 0) throw new ArgumentOutOfRangeException(paramName: nameof(maxFrames), maxFrames, message: "Invalid number of future frames, number must be positive.");
226+
if (maxFrames is 0) throw new ArgumentOutOfRangeException(paramName: nameof(maxFrames), maxFrames, message: "0 frames is not in the future. Did you mean to disable this by passing (null, 0)?");
227227
_mainForm.MaxFutureFrames = maxFrames;
228228
}
229229
else

src/BizHawk.Client.Common/Api/Interfaces/IEmuClientApi.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ public interface IEmuClientApi : IDisposable, IExternalApi
146146
/// <br/>Pass null to disable future frame display.</param>
147147
/// <param name="maxFrames">The maximum number of future frames to emulate. Useful to avoid freezing the client UI in case of accidentally never returning true from the callback.</param>
148148
/// <exception cref="ArgumentOutOfRangeException">
149-
/// <paramref name="maxFrames"/> <c>0</c>
149+
/// <paramref name="maxFrames"/> is <c>0</c>
150150
/// (and <paramref name="preFrameCallback"/> is a delegate, since <paramref name="maxFrames"/> is ignored when it's <see langword="null"/>)
151151
/// </exception>
152-
void ShowFuture(ShowFutureCallback/*?*/ preFrameCallback, short maxFrames);
152+
void ShowFuture(ShowFutureCallback/*?*/ preFrameCallback, ushort maxFrames);
153153

154154
void SpeedMode(int percent);
155155

src/BizHawk.Client.Common/lua/CommonLibs/ClientLuaLibrary.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,15 +288,15 @@ public void SetWindowSize(int size)
288288
"the client UI in case of accidentally never returning true from the callback.")]
289289
public string ShowFuture(LuaFunction luaf, long maxFrames, string name = null)
290290
{
291-
if (maxFrames < 1 || maxFrames > short.MaxValue)
291+
if (maxFrames is < 1 or > ushort.MaxValue)
292292
{
293293
Log($"Invalid number of future frames ({maxFrames}); number must be positive and less than 2^15.");
294294
return EventsLuaLibrary.EMPTY_UUID_STR;
295295
}
296296

297297
INamedLuaFunction nlf = CreateAndRegisterNamedFunction(luaf, NamedLuaFunction.EVENT_TYPE_FUTURE, prohibitedApis: ApiGroup.PROHIBITED_MID_FRAME, name: name);
298298
ShowFutureCallback FutureCallback = (f) => nlf.Call(f) is [ bool r ] ? r : false;
299-
APIs.EmuClient.ShowFuture(FutureCallback, (short)maxFrames);
299+
APIs.EmuClient.ShowFuture(FutureCallback, (ushort) maxFrames);
300300
nlf.OnRemove += () => APIs.EmuClient.ShowFuture(null, 0);
301301
return nlf.GuidStr;
302302
}

0 commit comments

Comments
 (0)