File tree Expand file tree Collapse file tree 2 files changed +42
-29
lines changed
MTA10_Server/mods/deathmatch/logic/lua
MTA10/mods/shared_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 )
119119 // Got a string argument?
120120 CScriptArgReader argStream ( luaVM );
121121
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 () );
139144 }
140145 else
141146 m_pScriptDebugging->LogBadType ( luaVM );
Original file line number Diff line number Diff line change @@ -370,10 +370,11 @@ int CLuaFunctionDefs::GetTok ( lua_State* luaVM )
370370 return 1 ;
371371}
372372
373- int CLuaFunctionDefs::toJSON ( lua_State* luaVM )
374- {
373+ int CLuaFunctionDefs::toJSON ( lua_State* luaVM )
374+ {
375375 // Got a string argument?
376376 CScriptArgReader argStream ( luaVM );
377+
377378 if ( !argStream.NextIsNil () )
378379 {
379380 bool bCompact = false ;
@@ -383,19 +384,26 @@ int CLuaFunctionDefs::toJSON ( lua_State* luaVM )
383384 argStream.Skip ( 1 );
384385 argStream.ReadBool ( bCompact, false );
385386
386- // Convert it to a JSON string
387- std::string strJSON;
388- if ( JSON.WriteToJSONString ( strJSON, false , bCompact ) )
387+ if ( !argStream.HasErrors () )
389388 {
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+ }
393397 }
398+ else
399+ m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
394400 }
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 ;
399407}
400408
401409
You can’t perform that action at this time.
0 commit comments