* Execute all commands on the local command queue that ought to be executed this frame. */
| 254 | * Execute all commands on the local command queue that ought to be executed this frame. |
| 255 | */ |
| 256 | void NetworkExecuteLocalCommandQueue() |
| 257 | { |
| 258 | assert(IsLocalCompany()); |
| 259 | |
| 260 | CommandQueue &queue = (_network_server ? _local_execution_queue : ClientNetworkGameSocketHandler::my_client->incoming_queue); |
| 261 | |
| 262 | auto cp = queue.begin(); |
| 263 | for (; cp != queue.end(); cp++) { |
| 264 | /* The queue is always in order, which means |
| 265 | * that the first element will be executed first. */ |
| 266 | if (_frame_counter < cp->frame) break; |
| 267 | |
| 268 | if (_frame_counter > cp->frame) { |
| 269 | /* If we reach here, it means for whatever reason, we've already executed |
| 270 | * past the command we need to execute. */ |
| 271 | FatalError("[net] Trying to execute a packet in the past!"); |
| 272 | } |
| 273 | |
| 274 | /* We can execute this command */ |
| 275 | _current_company = cp->company; |
| 276 | size_t cb_index = FindCallbackIndex(cp->callback); |
| 277 | assert(cb_index < _callback_tuple_size); |
| 278 | assert(_cmd_dispatch[cp->cmd].Unpack[cb_index] != nullptr); |
| 279 | _cmd_dispatch[cp->cmd].Unpack[cb_index](*cp); |
| 280 | } |
| 281 | queue.erase(queue.begin(), cp); |
| 282 | |
| 283 | /* Local company may have changed, so we should not restore the old value */ |
| 284 | _current_company = _local_company; |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Free the local command queues. |
no test coverage detected