| 769 | } |
| 770 | |
| 771 | static bool lua_save_data_push_sjson_object(lua_State *L, const char *value, bool &error, bool force_regular) |
| 772 | { |
| 773 | const int top = lua_gettop(L); |
| 774 | LuaStack stack(L, INT_MAX); |
| 775 | TempAllocator4096 ta; |
| 776 | JsonObject obj(ta); |
| 777 | sjson::parse(obj, value); |
| 778 | if (error) { |
| 779 | lua_settop(L, top); |
| 780 | return false; |
| 781 | } |
| 782 | |
| 783 | if (!force_regular) { |
| 784 | DynamicString type(ta); |
| 785 | if (lua_save_data_parse_typed_object(type, obj, error)) { |
| 786 | if (type == "table") { |
| 787 | if (!lua_save_data_push_sjson_object(L, obj["data"], error, true)) { |
| 788 | lua_settop(L, top); |
| 789 | return false; |
| 790 | } |
| 791 | return true; |
| 792 | } |
| 793 | |
| 794 | JsonArray arr(ta); |
| 795 | sjson::parse_array(arr, obj["data"]); |
| 796 | if (error) { |
| 797 | lua_settop(L, top); |
| 798 | return false; |
| 799 | } |
| 800 | |
| 801 | if (type == "vector3" || type == "vector3box") { |
| 802 | if (array::size(arr) != 3) { |
| 803 | error = true; |
| 804 | lua_settop(L, top); |
| 805 | return false; |
| 806 | } |
| 807 | |
| 808 | Vector3 v = sjson::parse_vector3(obj["data"]); |
| 809 | if (error) { |
| 810 | lua_settop(L, top); |
| 811 | return false; |
| 812 | } |
| 813 | |
| 814 | if (type == "vector3") |
| 815 | stack.push_vector3(v); |
| 816 | else |
| 817 | stack.push_vector3box(v); |
| 818 | return true; |
| 819 | } else if (type == "matrix4x4" || type == "matrix4x4box") { |
| 820 | if (array::size(arr) != 16) { |
| 821 | error = true; |
| 822 | lua_settop(L, top); |
| 823 | return false; |
| 824 | } |
| 825 | |
| 826 | Matrix4x4 m = sjson::parse_matrix4x4(obj["data"]); |
| 827 | if (error) { |
| 828 | lua_settop(L, top); |
no test coverage detected