File tree Expand file tree Collapse file tree 2 files changed +42
-29
lines changed
MTA10/mods/shared_logic/lua
MTA10_Server/mods/deathmatch/logic/lua Expand file tree Collapse file tree 2 files changed +42
-29
lines changed Original file line number Diff line number Diff line change @@ -119,23 +119,28 @@ int CLuaFunctionDefs::toJSON ( lua_State* luaVM )
119
119
// Got a string argument?
120
120
CScriptArgReader argStream ( luaVM );
121
121
122
- if ( !argStream.NextIsNil ( ) )
123
- {
124
- bool bCompact = false ;
125
- // Read the argument
126
- CLuaArguments JSON;
127
- JSON.ReadArgument ( luaVM, 1 );
128
- argStream.Skip ( 1 );
129
- argStream.ReadBool ( bCompact, false );
130
-
131
- // Convert it to a JSON string
132
- std::string strJSON;
133
- if ( JSON.WriteToJSONString ( strJSON, false , bCompact ) )
134
- {
135
- // Return the JSON string
136
- lua_pushstring ( luaVM, strJSON.c_str () );
137
- return 1 ;
138
- }
122
+ if ( !argStream.NextIsNil () )
123
+ {
124
+ bool bCompact = false ;
125
+ // Read the argument
126
+ CLuaArguments JSON;
127
+ JSON.ReadArgument ( luaVM, 1 );
128
+ argStream.Skip ( 1 );
129
+ argStream.ReadBool ( bCompact, false );
130
+
131
+ if ( !argStream.HasErrors () )
132
+ {
133
+ // Convert it to a JSON string
134
+ std::string strJSON;
135
+ if ( JSON.WriteToJSONString ( strJSON, false , bCompact ) )
136
+ {
137
+ // Return the JSON string
138
+ lua_pushstring ( luaVM, strJSON.c_str () );
139
+ return 1 ;
140
+ }
141
+ }
142
+ else
143
+ m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
139
144
}
140
145
else
141
146
m_pScriptDebugging->LogBadType ( luaVM );
Original file line number Diff line number Diff line change @@ -370,10 +370,11 @@ int CLuaFunctionDefs::GetTok ( lua_State* luaVM )
370
370
return 1 ;
371
371
}
372
372
373
- int CLuaFunctionDefs::toJSON ( lua_State* luaVM )
374
- {
373
+ int CLuaFunctionDefs::toJSON ( lua_State* luaVM )
374
+ {
375
375
// Got a string argument?
376
376
CScriptArgReader argStream ( luaVM );
377
+
377
378
if ( !argStream.NextIsNil () )
378
379
{
379
380
bool bCompact = false ;
@@ -383,19 +384,26 @@ int CLuaFunctionDefs::toJSON ( lua_State* luaVM )
383
384
argStream.Skip ( 1 );
384
385
argStream.ReadBool ( bCompact, false );
385
386
386
- // Convert it to a JSON string
387
- std::string strJSON;
388
- if ( JSON.WriteToJSONString ( strJSON, false , bCompact ) )
387
+ if ( !argStream.HasErrors () )
389
388
{
390
- // Return the JSON string
391
- lua_pushstring ( luaVM, strJSON.c_str () );
392
- return 1 ;
389
+ // Convert it to a JSON string
390
+ std::string strJSON;
391
+ if ( JSON.WriteToJSONString ( strJSON, false , bCompact ) )
392
+ {
393
+ // Return the JSON string
394
+ lua_pushstring ( luaVM, strJSON.c_str () );
395
+ return 1 ;
396
+ }
393
397
}
398
+ else
399
+ m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
394
400
}
395
-
396
- // Failed
397
- lua_pushnil ( luaVM );
398
- return 1 ;
401
+ else
402
+ m_pScriptDebugging->LogBadType ( luaVM );
403
+
404
+ // Failed
405
+ lua_pushnil ( luaVM );
406
+ return 1 ;
399
407
}
400
408
401
409
You can’t perform that action at this time.
0 commit comments