---------------------------------------------- PROCESS EVENTS
| 497 | } |
| 498 | //---------------------------------------------- PROCESS EVENTS |
| 499 | void GameImpl::processEvents() |
| 500 | { |
| 501 | //This function translates events into AIModule callbacks |
| 502 | if ( !client || server.isConnected() ) |
| 503 | return; |
| 504 | for (Event e : events) |
| 505 | { |
| 506 | static DWORD dwLastEventTime = 0; |
| 507 | |
| 508 | // Reset event stopwatch |
| 509 | if ( tournamentAI ) |
| 510 | { |
| 511 | this->lastEventTime = 0; |
| 512 | dwLastEventTime = GetTickCount(); |
| 513 | } |
| 514 | |
| 515 | // Send event to the AI Client module |
| 516 | SendClientEvent(client, e); |
| 517 | |
| 518 | // continue if the tournament is not loaded |
| 519 | if ( !tournamentAI ) |
| 520 | continue; |
| 521 | |
| 522 | // Save the last event time |
| 523 | this->lastEventTime = GetTickCount() - dwLastEventTime; |
| 524 | |
| 525 | // Send same event to the Tournament module for post-processing |
| 526 | isTournamentCall = true; |
| 527 | SendClientEvent(tournamentAI, e); |
| 528 | isTournamentCall = false; |
| 529 | } // foreach event |
| 530 | } |
| 531 | } |
| 532 |