Skip to content

Commit f7d8522

Browse files
committed
Make setWindowFlashing errors more informative
Also fixes an issue where giving it "-1" as a count would cause the uint to wrap around to a huge integer.
1 parent 30772de commit f7d8522

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,6 @@ bool CStaticFunctionDefinitions::SetWindowFlashing ( bool flash, uint count )
334334
if ( g_pCore->IsFocused () || !g_pCore->GetCVars ()->GetValue < bool > ( "server-can-flash-window", true ) )
335335
return false;
336336

337-
// 0 is infinite flashing
338-
if ( count == 0 )
339-
return false;
340-
341337
FLASHWINFO flashInfo;
342338
flashInfo.cbSize = sizeof(FLASHWINFO);
343339
flashInfo.hwnd = g_pCore->GetHookedWindow ();

MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class CStaticFunctionDefinitions
5555
static bool ShowChat ( bool bShow );
5656
static bool SetClipboard ( SString& strText );
5757
static bool GetClipboard ( SString& strText );
58-
static bool SetWindowFlashing ( bool flash, uint count = 10 );
58+
static bool SetWindowFlashing ( bool flash, uint count );
5959

6060
// Element get funcs
6161
static CClientEntity* GetRootElement ( void );

MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Output.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,20 +200,22 @@ int CLuaFunctionDefs::OutputClientDebugString ( lua_State* luaVM )
200200
int CLuaFunctionDefs::SetWindowFlashing ( lua_State* luaVM )
201201
{
202202
// bool setWindowFlashing ( bool flash [, int count = 10 ] )
203-
bool flash; uint count;
203+
bool flash; int count;
204204

205205
CScriptArgReader argStream ( luaVM );
206206
argStream.ReadBool ( flash );
207207
argStream.ReadNumber ( count, 10 );
208208

209209
if ( !argStream.HasErrors () )
210210
{
211-
lua_pushboolean ( luaVM, CStaticFunctionDefinitions::SetWindowFlashing ( flash, count ) );
212-
return 1;
211+
if (count > 0) {
212+
lua_pushboolean ( luaVM, CStaticFunctionDefinitions::SetWindowFlashing ( flash, count ) );
213+
return 1;
214+
} else
215+
argStream.SetCustomError ( "'count' should be greater than 0" );
213216
}
214-
else
215-
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
216217

218+
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
217219
lua_pushboolean ( luaVM, false );
218220
return 1;
219221
}

0 commit comments

Comments
 (0)