| 145 | extern bool isdedicated; |
| 146 | |
| 147 | bool resolverwait(const char *name, ENetAddress *address) |
| 148 | { |
| 149 | if(isdedicated) return enet_address_set_host(address, name) >= 0; |
| 150 | |
| 151 | if(resolverthreads.empty()) resolverinit(); |
| 152 | |
| 153 | defformatstring(text)("resolving %s... (esc to abort)", name); |
| 154 | show_out_of_renderloop_progress(0, text); |
| 155 | |
| 156 | SDL_LockMutex(resolvermutex); |
| 157 | resolverqueries.add(name); |
| 158 | SDL_CondSignal(querycond); |
| 159 | int starttime = SDL_GetTicks(), timeout = 0; |
| 160 | bool resolved = false; |
| 161 | for(;;) |
| 162 | { |
| 163 | SDL_CondWaitTimeout(resultcond, resolvermutex, 250); |
| 164 | loopv(resolverresults) if(resolverresults[i].query == name) |
| 165 | { |
| 166 | address->host = resolverresults[i].address.host; |
| 167 | resolverresults.remove(i); |
| 168 | resolved = true; |
| 169 | break; |
| 170 | } |
| 171 | if(resolved) break; |
| 172 | |
| 173 | timeout = SDL_GetTicks() - starttime; |
| 174 | show_out_of_renderloop_progress(min(float(timeout)/RESOLVERLIMIT, 1.0f), text); |
| 175 | SDL_Event event; |
| 176 | while(SDL_PollEvent(&event)) |
| 177 | { |
| 178 | if(event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE) timeout = RESOLVERLIMIT + 1; |
| 179 | } |
| 180 | |
| 181 | if(timeout > RESOLVERLIMIT) break; |
| 182 | } |
| 183 | if(!resolved && timeout > RESOLVERLIMIT) |
| 184 | { |
| 185 | loopv(resolverthreads) |
| 186 | { |
| 187 | resolverthread &rt = resolverthreads[i]; |
| 188 | if(rt.query == name) { resolverstop(rt); break; } |
| 189 | } |
| 190 | } |
| 191 | SDL_UnlockMutex(resolvermutex); |
| 192 | return resolved; |
| 193 | } |
| 194 | |
| 195 | SDL_Thread *connthread = NULL; |
| 196 | SDL_mutex *connmutex = NULL; |
nothing calls this directly
no test coverage detected