| 1193 | } |
| 1194 | |
| 1195 | static void U6_AsyncReadManagerThreaded_Request(AsyncReadManagerThreaded *t, AsyncReadCommand *c) |
| 1196 | { |
| 1197 | char* filepath = *(char**)c; |
| 1198 | LOG(LL_TRACE, LCF_HACKS | LCF_FILEIO, "U6_AsyncReadManagerThreaded_Request called with file %s", filepath); |
| 1199 | |
| 1200 | if (!(Global::shared_config.game_specific_sync & SharedConfig::GC_SYNC_UNITY_READS)) |
| 1201 | return orig::U6_AsyncReadManagerThreaded_Request(t, c); |
| 1202 | |
| 1203 | void* complete_callback = *((void**)(c + 0x38)); |
| 1204 | // void* complete_callback_arg = *((void**)(c + 0x40)); |
| 1205 | |
| 1206 | /* If possible, we can use this nice helper function that performs a sync |
| 1207 | * read from a command. I didn't experienced any softlock for now. */ |
| 1208 | if (orig::U6_SyncReadRequest) { |
| 1209 | return orig::U6_SyncReadRequest(c); |
| 1210 | } |
| 1211 | |
| 1212 | if (orig::U2K_AsyncReadManagerThreaded_SyncRequest) { |
| 1213 | return orig::U2K_AsyncReadManagerThreaded_SyncRequest(t, c); |
| 1214 | } |
| 1215 | |
| 1216 | /* This function is less preferable, because it still performs the read in |
| 1217 | * another thread. */ |
| 1218 | if (orig::U5_AsyncReadManagerThreaded_WaitDone) { |
| 1219 | orig::U6_AsyncReadManagerThreaded_Request(t, c); |
| 1220 | orig::U5_AsyncReadManagerThreaded_WaitDone(t, c); |
| 1221 | return; |
| 1222 | } |
| 1223 | |
| 1224 | if (complete_callback != 0) { |
| 1225 | /* We wait until the complete callback is called. */ |
| 1226 | std::unique_lock<std::mutex> lock(async_read_mutex); |
| 1227 | async_read_complete = false; |
| 1228 | |
| 1229 | orig::U6_AsyncReadManagerThreaded_Request(t, c); |
| 1230 | |
| 1231 | async_read_condition.wait(lock, [] { return async_read_complete; }); |
| 1232 | } |
| 1233 | else { |
| 1234 | orig::U6_AsyncReadManagerThreaded_Request(t, c); |
| 1235 | } |
| 1236 | } |
| 1237 | |
| 1238 | static void U2K_AsyncReadManagerThreaded_SyncRequest(AsyncReadManagerThreaded *t, AsyncReadCommand *c) |
| 1239 | { |
nothing calls this directly
no test coverage detected