| 122 | } |
| 123 | |
| 124 | static Error read_reals(real_t *dst, Ref<FileAccess> &f, size_t count) { |
| 125 | if (f->real_is_double) { |
| 126 | if constexpr (sizeof(real_t) == 8) { |
| 127 | // Ideal case with double-precision |
| 128 | f->get_buffer((uint8_t *)dst, count * sizeof(double)); |
| 129 | #ifdef BIG_ENDIAN_ENABLED |
| 130 | { |
| 131 | uint64_t *dst = (uint64_t *)dst; |
| 132 | for (size_t i = 0; i < count; i++) { |
| 133 | dst[i] = BSWAP64(dst[i]); |
| 134 | } |
| 135 | } |
| 136 | #endif |
| 137 | } else if constexpr (sizeof(real_t) == 4) { |
| 138 | // May be slower, but this is for compatibility. Eventually the data should be converted. |
| 139 | for (size_t i = 0; i < count; ++i) { |
| 140 | dst[i] = f->get_double(); |
| 141 | } |
| 142 | } else { |
| 143 | ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "real_t size is neither 4 nor 8!"); |
| 144 | } |
| 145 | } else { |
| 146 | if constexpr (sizeof(real_t) == 4) { |
| 147 | // Ideal case with float-precision |
| 148 | f->get_buffer((uint8_t *)dst, count * sizeof(float)); |
| 149 | #ifdef BIG_ENDIAN_ENABLED |
| 150 | { |
| 151 | uint32_t *dst = (uint32_t *)dst; |
| 152 | for (size_t i = 0; i < count; i++) { |
| 153 | dst[i] = BSWAP32(dst[i]); |
| 154 | } |
| 155 | } |
| 156 | #endif |
| 157 | } else if constexpr (sizeof(real_t) == 8) { |
| 158 | for (size_t i = 0; i < count; ++i) { |
| 159 | dst[i] = f->get_float(); |
| 160 | } |
| 161 | } else { |
| 162 | ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "real_t size is neither 4 nor 8!"); |
| 163 | } |
| 164 | } |
| 165 | return OK; |
| 166 | } |
| 167 | |
| 168 | StringName ResourceLoaderCompatBinary::_get_string() { |
| 169 | uint32_t id = f->get_32(); |
no test coverage detected