Processes all pending events, removing the ones that are expired
| 139 | |
| 140 | // Processes all pending events, removing the ones that are expired |
| 141 | void ProcessNormalEvents() { |
| 142 | int i, count = 0; |
| 143 | bool skip_event; |
| 144 | |
| 145 | for (i = 0; i < MAX_EVENTS && count < Num_events; i++) { |
| 146 | if (GameEvent[i].used) { |
| 147 | count++; |
| 148 | skip_event = false; |
| 149 | |
| 150 | if (GameEvent[i].objhandle_detonator != OBJECT_HANDLE_NONE) { |
| 151 | // this object has a detonator, see if the object is still alive |
| 152 | object *obj = ObjGet(GameEvent[i].objhandle_detonator); |
| 153 | if (!obj || (obj->type == OBJ_GHOST) || |
| 154 | (obj->type == OBJ_PLAYER && Players[obj->id].flags & (PLAYER_FLAGS_DYING | PLAYER_FLAGS_DEAD))) { |
| 155 | // the object has died, kill the event |
| 156 | FreeEvent(i); |
| 157 | skip_event = true; |
| 158 | mprintf(0, "Game Event %d cancelled\n", i); |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | if (GameEvent[i].type != RENDER_EVENT && GameEvent[i].end_time <= Gametime && !skip_event) { |
| 163 | HandleEvent(&GameEvent[i]); |
| 164 | FreeEvent(i); |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | SpewEmitAll(); |
| 170 | } |
| 171 | |
| 172 | // Goes through all events and returns the first index of the id matching the argument passed. |
| 173 | // If not match found, returns -1 |
no test coverage detected