| 1814 | //------------------------------------------------------------------------- |
| 1815 | |
| 1816 | BZF_API bool bz_sendJoinServer(int playerID, |
| 1817 | const char* address, int port, int teamID, |
| 1818 | const char* referrer, const char* message) { |
| 1819 | GameKeeper::Player* player = NULL; |
| 1820 | if (playerID != BZ_ALLUSERS) { |
| 1821 | player = GameKeeper::Player::getPlayerByIndex(playerID); |
| 1822 | if (player == NULL) { |
| 1823 | return false; |
| 1824 | } |
| 1825 | } |
| 1826 | if (address == NULL) { |
| 1827 | return false; |
| 1828 | } |
| 1829 | if ((port < 0) || (port >= 65536)) { |
| 1830 | return false; |
| 1831 | } |
| 1832 | if (referrer == NULL) { |
| 1833 | referrer = ""; |
| 1834 | } |
| 1835 | if (message == NULL) { |
| 1836 | message = ""; |
| 1837 | } |
| 1838 | |
| 1839 | const std::string addr = address; |
| 1840 | const std::string refr = referrer; |
| 1841 | const std::string mesg = message; |
| 1842 | |
| 1843 | NetMessage netMsg; |
| 1844 | |
| 1845 | netMsg.packStdString(addr); |
| 1846 | netMsg.packInt32(port); |
| 1847 | netMsg.packInt16(int16_t(teamID)); |
| 1848 | netMsg.packStdString(refr); |
| 1849 | netMsg.packStdString(mesg); |
| 1850 | |
| 1851 | if (player != NULL) { |
| 1852 | netMsg.send(player->netHandler, MsgJoinServer); |
| 1853 | } |
| 1854 | else { |
| 1855 | netMsg.broadcast(MsgJoinServer); |
| 1856 | } |
| 1857 | |
| 1858 | return true; |
| 1859 | } |
| 1860 | |
| 1861 | //------------------------------------------------------------------------- |
| 1862 |
no test coverage detected