Skip to content

Commit

Permalink
Make setWindowFlashing errors more informative
Browse files Browse the repository at this point in the history
Also fixes an issue where giving it "-1" as a count would cause the uint
to wrap around to a huge integer.
  • Loading branch information
qaisjp committed Dec 4, 2015
1 parent 30772de commit f7d8522
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 0 additions & 4 deletions MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,6 @@ bool CStaticFunctionDefinitions::SetWindowFlashing ( bool flash, uint count )
if ( g_pCore->IsFocused () || !g_pCore->GetCVars ()->GetValue < bool > ( "server-can-flash-window", true ) )
return false;

// 0 is infinite flashing
if ( count == 0 )
return false;

FLASHWINFO flashInfo;
flashInfo.cbSize = sizeof(FLASHWINFO);
flashInfo.hwnd = g_pCore->GetHookedWindow ();
Expand Down
2 changes: 1 addition & 1 deletion MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CStaticFunctionDefinitions
static bool ShowChat ( bool bShow );
static bool SetClipboard ( SString& strText );
static bool GetClipboard ( SString& strText );
static bool SetWindowFlashing ( bool flash, uint count = 10 );
static bool SetWindowFlashing ( bool flash, uint count );

// Element get funcs
static CClientEntity* GetRootElement ( void );
Expand Down
12 changes: 7 additions & 5 deletions MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,20 +200,22 @@ int CLuaFunctionDefs::OutputClientDebugString ( lua_State* luaVM )
int CLuaFunctionDefs::SetWindowFlashing ( lua_State* luaVM )
{
// bool setWindowFlashing ( bool flash [, int count = 10 ] )
bool flash; uint count;
bool flash; int count;

CScriptArgReader argStream ( luaVM );
argStream.ReadBool ( flash );
argStream.ReadNumber ( count, 10 );

if ( !argStream.HasErrors () )
{
lua_pushboolean ( luaVM, CStaticFunctionDefinitions::SetWindowFlashing ( flash, count ) );
return 1;
if (count > 0) {
lua_pushboolean ( luaVM, CStaticFunctionDefinitions::SetWindowFlashing ( flash, count ) );
return 1;
} else
argStream.SetCustomError ( "'count' should be greater than 0" );
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
lua_pushboolean ( luaVM, false );
return 1;
}

0 comments on commit f7d8522

Please sign in to comment.