99*  Multi Theft Auto is available from http://www.multitheftauto.com/ 
1010* 
1111*****************************************************************************/  
12+ #pragma  once
1213#include  < limits> 
1314
15+ #ifdef  MTA_CLIENT
16+     #include  " CScriptDebugging.h" 
17+ #endif 
18+ 
1419// ///////////////////////////////////////////////////////////////////////
1520// 
1621//  CScriptArgReader
@@ -58,7 +63,7 @@ class CScriptArgReader
5863
5964            if  ( std::is_unsigned < T > () && number < -FLT_EPSILON )
6065            {
61-                 SetCustomError  ( " Expected positive value, got negative" ,  " Bad argument "   );
66+                 SetCustomWarning  ( " Expected positive value, got negative. This warning may be an error in future versions. "   );
6267                return ;
6368            }
6469
@@ -90,7 +95,7 @@ class CScriptArgReader
9095
9196            if  ( std::is_unsigned < T > () && number < -FLT_EPSILON )
9297            {
93-                 SetCustomError  ( " Expected positive value, got negative" ,  " Bad argument "   );
98+                 SetCustomWarning  ( " Expected positive value, got negative. This warning may be an error in future versions. "   );
9499                return ;
95100            }
96101
@@ -1121,11 +1126,24 @@ class CScriptArgReader
11211126    // 
11221127    //  HasErrors - Optional check if there are any unread arguments
11231128    // 
1124-     bool  HasErrors  ( bool  bCheckUnusedArgs = false  )  const 
1129+     bool  HasErrors  ( bool  bCheckUnusedArgs = false  )
11251130    {
11261131        assert  ( !IsReadFunctionPending  () );
11271132        if  ( bCheckUnusedArgs && lua_type  ( m_luaVM, m_iIndex ) != LUA_TNONE )
11281133            return  true ;
1134+ 
1135+         //  Output warning here (there's no better way to integrate it without huge code changes
1136+         if  ( !m_bError && !m_strCustomWarning.empty  () )
1137+         {
1138+             #ifdef  MTA_CLIENT
1139+                 CLuaFunctionDefs::m_pScriptDebugging->LogWarning  ( m_luaVM, m_strCustomWarning );
1140+             #else 
1141+                 g_pGame->GetScriptDebugging  ()->LogWarning  ( m_luaVM, m_strCustomWarning );
1142+             #endif 
1143+             
1144+             m_strCustomWarning.clear  ();
1145+         }
1146+ 
11291147        return  m_bError;
11301148    }
11311149
@@ -1216,6 +1234,14 @@ class CScriptArgReader
12161234        return  SString  ( " %s @ '%s' [%s]"  , *m_strErrorCategory, lua_tostring  ( m_luaVM, lua_upvalueindex  ( 1  ) ), *GetErrorMessage  () );
12171235    }
12181236
1237+     // 
1238+     //  Set custom warning message
1239+     // 
1240+     void  SetCustomWarning  ( const  SString& message )
1241+     {
1242+         m_strCustomWarning = message;
1243+     }
1244+ 
12191245    // 
12201246    //  Skip n arguments
12211247    // 
@@ -1237,5 +1263,6 @@ class CScriptArgReader
12371263    SString                 m_strErrorCategory;
12381264    bool                     m_bHasCustomMessage;
12391265    SString                 m_strCustomMessage;
1266+     SString                 m_strCustomWarning;
12401267
12411268};
0 commit comments