complements LuaStackToBinaryConverter
| 1050 | |
| 1051 | // complements LuaStackToBinaryConverter |
| 1052 | void BinaryToLuaStackConverter(lua_State* L, const unsigned char*& data, unsigned int& remaining) |
| 1053 | { |
| 1054 | // assert(s_dbg_dataSize - (data - s_dbg_dataStart) == remaining); |
| 1055 | |
| 1056 | unsigned char type = AdvanceByteStream<unsigned char>(data, remaining); |
| 1057 | |
| 1058 | switch(type) |
| 1059 | { |
| 1060 | default: |
| 1061 | { |
| 1062 | char errmsg [1024]; |
| 1063 | if(type <= 10 && type != LUA_TTABLE) |
| 1064 | sprintf(errmsg, "values of type \"%s\" are not allowed to be loaded into registered load functions. The save state's Lua save data file might be corrupted.\r\n", lua_typename(L,type)); |
| 1065 | else |
| 1066 | sprintf(errmsg, "The save state's Lua save data file seems to be corrupted.\r\n"); |
| 1067 | if(info_print) |
| 1068 | info_print(info_uid, errmsg); |
| 1069 | else |
| 1070 | puts(errmsg); |
| 1071 | } |
| 1072 | break; |
| 1073 | case LUA_TNIL: |
| 1074 | lua_pushnil(L); |
| 1075 | break; |
| 1076 | case LUA_TBOOLEAN: |
| 1077 | lua_pushboolean(L, AdvanceByteStream<uint8>(data, remaining)); |
| 1078 | break; |
| 1079 | case LUA_TSTRING: |
| 1080 | lua_pushstring(L, (const char*)data); |
| 1081 | AdvanceByteStream(data, remaining, strlen((const char*)data) + 1); |
| 1082 | break; |
| 1083 | case LUA_TNUMBER: |
| 1084 | lua_pushnumber(L, AdvanceByteStream<double>(data, remaining)); |
| 1085 | break; |
| 1086 | case LUAEXT_TLONG: |
| 1087 | lua_pushinteger(L, AdvanceByteStream<int32>(data, remaining)); |
| 1088 | break; |
| 1089 | case LUAEXT_TUSHORT: |
| 1090 | lua_pushinteger(L, AdvanceByteStream<uint16>(data, remaining)); |
| 1091 | break; |
| 1092 | case LUAEXT_TSHORT: |
| 1093 | lua_pushinteger(L, AdvanceByteStream<int16>(data, remaining)); |
| 1094 | break; |
| 1095 | case LUAEXT_TBYTE: |
| 1096 | lua_pushinteger(L, AdvanceByteStream<uint8>(data, remaining)); |
| 1097 | break; |
| 1098 | case LUAEXT_TTABLE: |
| 1099 | case LUAEXT_TTABLE | LUAEXT_BITS_1A: |
| 1100 | case LUAEXT_TTABLE | LUAEXT_BITS_2A: |
| 1101 | case LUAEXT_TTABLE | LUAEXT_BITS_4A: |
| 1102 | case LUAEXT_TTABLE | LUAEXT_BITS_1H: |
| 1103 | case LUAEXT_TTABLE | LUAEXT_BITS_2H: |
| 1104 | case LUAEXT_TTABLE | LUAEXT_BITS_4H: |
| 1105 | case LUAEXT_TTABLE | LUAEXT_BITS_1A | LUAEXT_BITS_1H: |
| 1106 | case LUAEXT_TTABLE | LUAEXT_BITS_2A | LUAEXT_BITS_1H: |
| 1107 | case LUAEXT_TTABLE | LUAEXT_BITS_4A | LUAEXT_BITS_1H: |
| 1108 | case LUAEXT_TTABLE | LUAEXT_BITS_1A | LUAEXT_BITS_2H: |
| 1109 | case LUAEXT_TTABLE | LUAEXT_BITS_2A | LUAEXT_BITS_2H: |
no test coverage detected