| 2163 | |
| 2164 | #define MT_DATA_UPDATE_INTERVAL 10 // 30 seconds |
| 2165 | void DoMTFrame() { |
| 2166 | int i; |
| 2167 | int rcode; |
| 2168 | IdleGameTracker(); |
| 2169 | PollPTrackNet(); |
| 2170 | // Periodically update the master tracker's info. |
| 2171 | if ((DLLtimer_GetTime() - LastTrackerDataUpdate) > MT_DATA_UPDATE_INTERVAL) { |
| 2172 | UpdateGameData(&DLLD3_tracker_info); |
| 2173 | LastTrackerDataUpdate = DLLtimer_GetTime(); |
| 2174 | } |
| 2175 | |
| 2176 | if (DLLNetgame->flags & NF_TRACK_RANK) { |
| 2177 | // Loop through all DLLMNetPlayers looking to see if we need to send or receive |
| 2178 | if (MTWritingPilot != -1) { |
| 2179 | // We are already sending a pilot |
| 2180 | rcode = SendD3PilotData(nullptr); |
| 2181 | if (rcode != 0) { |
| 2182 | if (rcode == 1) { |
| 2183 | // Copy data from the DLLMTPilotinfo[MTReadingPilot] struct here |
| 2184 | DLLMNetPlayers[MTWritingPilot].flags &= ~NPF_MT_WRITING_PILOT; |
| 2185 | DLLmprintf(0, "Pilot data wrote to the Mastertracker for Player[%d] %s (tid=%s).\n", MTWritingPilot, |
| 2186 | DLLMTPilotinfo[MTWritingPilot].pilot_name, DLLMTPilotinfo[MTWritingPilot].tracker_id); |
| 2187 | MTWritingPilot = -1; |
| 2188 | |
| 2189 | } else { |
| 2190 | DLLMNetPlayers[MTWritingPilot].flags &= ~NPF_MT_WRITING_PILOT; |
| 2191 | DLLmprintf(0, "Pilot write to the mastertracker failed. Error code %d.\n", rcode); |
| 2192 | MTWritingPilot = -1; |
| 2193 | } |
| 2194 | } |
| 2195 | } else { |
| 2196 | // See if se need to look for another |
| 2197 | for (i = 0; i < MAX_NET_PLAYERS; i++) { |
| 2198 | |
| 2199 | if (DLLMNetPlayers[i].flags & NPF_MT_WRITING_PILOT) { |
| 2200 | if ((!(DLLMNetPlayers[i].flags & NPF_MT_READING_PILOT)) && |
| 2201 | (DLLMNetPlayers[i].flags & NPF_MT_HAS_PILOT_DATA)) { |
| 2202 | strcpy(DLLMTPilotinfo[i].tracker_id, DLLMPlayers[i].tracker_id); |
| 2203 | strcpy(DLLMTPilotinfo[i].pilot_name, DLLMPlayers[i].callsign); |
| 2204 | DLLMTPilotinfo[i].kills = DLLMPlayers[i].kills; |
| 2205 | DLLMTPilotinfo[i].deaths = DLLMPlayers[i].deaths; |
| 2206 | DLLMTPilotinfo[i].suicides = DLLMPlayers[i].suicides; |
| 2207 | DLLMTPilotinfo[i].rank = (DLLMPlayers[i].rank * 65536.0); |
| 2208 | DLLmprintf(0, "Sending pilot %d rank of %f\n", i, DLLMTPilotinfo[i].rank / 65536.0); |
| 2209 | |
| 2210 | DLLMTPilotinfo[i].lateral_thrust = DLLMPlayers[i].lateral_thrust; |
| 2211 | DLLMTPilotinfo[i].rotational_thrust = DLLMPlayers[i].rotational_thrust; |
| 2212 | DLLMTPilotinfo[i].online_time += DLLtimer_GetTime() - DLLMPlayers[i].time_in_game; |
| 2213 | DLLMTPilotinfo[i].sliding_pct = 0; // FIXME |
| 2214 | DLLMPlayers[i].time_in_game = DLLtimer_GetTime(); // when we write this data multiple times we need this |
| 2215 | |
| 2216 | DLLmprintf(0, "Sending User info to the Mastertracker for Player[%d] %s (tid=%s).\n", i, |
| 2217 | DLLMTPilotinfo[i].pilot_name, DLLMTPilotinfo[i].tracker_id); |
| 2218 | SendD3PilotData(&DLLMTPilotinfo[i]); |
| 2219 | |
| 2220 | MTWritingPilot = i; |
| 2221 | i = MAX_NET_PLAYERS + 1; |
| 2222 | break; |
no test coverage detected