| 1767 | } |
| 1768 | |
| 1769 | static void reportPacketProgress(NetworkBase& network, Connection& connection) |
| 1770 | { |
| 1771 | if (network.GetMode() != Mode::client) |
| 1772 | { |
| 1773 | return; |
| 1774 | } |
| 1775 | |
| 1776 | const auto nextPacketCommand = connection.getPendingPacketCommand(); |
| 1777 | const auto bytesReceived = connection.getPendingPacketAvailable(); |
| 1778 | const auto bytesTotal = connection.getPendingPacketSize(); |
| 1779 | |
| 1780 | switch (nextPacketCommand) |
| 1781 | { |
| 1782 | case Command::objectsList: |
| 1783 | displayNetworkProgress(STR_MULTIPLAYER_RECEIVING_OBJECTS_LIST); |
| 1784 | break; |
| 1785 | case Command::map: |
| 1786 | displayNetworkProgress(STR_MULTIPLAYER_DOWNLOADING_MAP); |
| 1787 | break; |
| 1788 | case Command::scriptsData: |
| 1789 | displayNetworkProgress(STR_MULTIPLAYER_RECEIVING_SCRIPTS); |
| 1790 | break; |
| 1791 | default: |
| 1792 | // Nothing to report. |
| 1793 | return; |
| 1794 | } |
| 1795 | |
| 1796 | network.GetContext().SetProgress( |
| 1797 | static_cast<uint32_t>(bytesReceived / 1024), static_cast<uint32_t>(bytesTotal / 1024), STR_STRING_M_OF_N_KIB); |
| 1798 | } |
| 1799 | |
| 1800 | bool NetworkBase::ProcessConnection(Connection& connection) |
| 1801 | { |
no test coverage detected