Return codes: -3 Still waiting (returned if we were waiting for a tracker response and VersionCheck was called with a non-NULL value -2 Timeout waiting for tracker to respond 0 Still waiting for response from tracker/Idle 1 Version received (URL[0] will not be NULL if we have the URL which means we need a newer version) Call once with the real version, then poll with the version set to 0 URL is a
| 661 | // Call once with the real version, then poll with the version set to 0 URL is a pointer to a char buff(max size == 200) |
| 662 | // that will be filled if/when we get a URL response |
| 663 | int MTAVersionCheck(uint32_t oldver, char *URL) { |
| 664 | |
| 665 | int res = DLLPollUI(); |
| 666 | if (res == 99) { |
| 667 | VersionState = VERSION_STATE_TIMEOUT; |
| 668 | } |
| 669 | VersionIdle(); |
| 670 | if (oldver == 0) { |
| 671 | switch (VersionState) { |
| 672 | case VERSION_STATE_IDLE: |
| 673 | return 0; |
| 674 | break; |
| 675 | case VERSION_STATE_WAITING: |
| 676 | return 0; |
| 677 | break; |
| 678 | case VERSION_STATE_RECEIVED: |
| 679 | VersionState = VERSION_STATE_IDLE; |
| 680 | return 1; |
| 681 | case VERSION_STATE_TIMEOUT: |
| 682 | VersionState = VERSION_STATE_IDLE; |
| 683 | return -2; |
| 684 | } |
| 685 | return 0; |
| 686 | } else { |
| 687 | if (VersionState == VERSION_STATE_IDLE) { |
| 688 | /* |
| 689 | //First, flush the input buffer for the socket |
| 690 | uint32_t bytesin; |
| 691 | udp_packet_header inpacket; |
| 692 | do |
| 693 | { |
| 694 | bytesin = ReceivePilotTracker(&inpacket); |
| 695 | }while(bytesin && (bytesin!=-1)); |
| 696 | */ |
| 697 | VersionURL = URL; |
| 698 | VersionPacketHeader.len = INTEL_SHORT(PACKED_HEADER_ONLY_SIZE); |
| 699 | VersionPacketHeader.type = UNT_TRACKER_VERSION_REQ; |
| 700 | VersionPacketHeader.xcode = INTEL_SHORT(CMD_GAME_DESCENT3); |
| 701 | VersionPacketHeader.code = INTEL_INT(oldver); |
| 702 | |
| 703 | SendPilotTrackerPacket(&VersionPacketHeader); |
| 704 | VersionState = VERSION_STATE_WAITING; |
| 705 | VersionFirstSent = DLLtimer_GetTime(); |
| 706 | VersionLastSent = DLLtimer_GetTime(); |
| 707 | return 0; |
| 708 | } else { |
| 709 | return -3; |
| 710 | } |
| 711 | } |
| 712 | } |
| 713 | |
| 714 | int GetD3MOTD(char *szmotd, int maxlen) { |
| 715 | // First check the network |
no test coverage detected