9
9
* Multi Theft Auto is available from http://www.multitheftauto.com/
10
10
*
11
11
*****************************************************************************/
12
+ #pragma once
12
13
#include < limits>
13
14
15
+ #ifdef MTA_CLIENT
16
+ #include " CScriptDebugging.h"
17
+ #endif
18
+
14
19
// ///////////////////////////////////////////////////////////////////////
15
20
//
16
21
// CScriptArgReader
@@ -58,7 +63,7 @@ class CScriptArgReader
58
63
59
64
if ( std::is_unsigned < T > () && number < -FLT_EPSILON )
60
65
{
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. " );
62
67
return ;
63
68
}
64
69
@@ -90,7 +95,7 @@ class CScriptArgReader
90
95
91
96
if ( std::is_unsigned < T > () && number < -FLT_EPSILON )
92
97
{
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. " );
94
99
return ;
95
100
}
96
101
@@ -1121,11 +1126,24 @@ class CScriptArgReader
1121
1126
//
1122
1127
// HasErrors - Optional check if there are any unread arguments
1123
1128
//
1124
- bool HasErrors ( bool bCheckUnusedArgs = false ) const
1129
+ bool HasErrors ( bool bCheckUnusedArgs = false )
1125
1130
{
1126
1131
assert ( !IsReadFunctionPending () );
1127
1132
if ( bCheckUnusedArgs && lua_type ( m_luaVM, m_iIndex ) != LUA_TNONE )
1128
1133
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
+
1129
1147
return m_bError;
1130
1148
}
1131
1149
@@ -1216,6 +1234,14 @@ class CScriptArgReader
1216
1234
return SString ( " %s @ '%s' [%s]" , *m_strErrorCategory, lua_tostring ( m_luaVM, lua_upvalueindex ( 1 ) ), *GetErrorMessage () );
1217
1235
}
1218
1236
1237
+ //
1238
+ // Set custom warning message
1239
+ //
1240
+ void SetCustomWarning ( const SString& message )
1241
+ {
1242
+ m_strCustomWarning = message;
1243
+ }
1244
+
1219
1245
//
1220
1246
// Skip n arguments
1221
1247
//
@@ -1237,5 +1263,6 @@ class CScriptArgReader
1237
1263
SString m_strErrorCategory;
1238
1264
bool m_bHasCustomMessage;
1239
1265
SString m_strCustomMessage;
1266
+ SString m_strCustomWarning;
1240
1267
1241
1268
};
0 commit comments