| 299 | } |
| 300 | |
| 301 | static void MPConnection_BeginConnect(void) { |
| 302 | static const cc_string invalid_reason = String_FromConst("Invalid IP address"); |
| 303 | cc_string title; char titleBuffer[STRING_SIZE]; |
| 304 | cc_sockaddr addrs[SOCKET_MAX_ADDRS]; |
| 305 | int numValidAddrs; |
| 306 | cc_result res; |
| 307 | String_InitArray(title, titleBuffer); |
| 308 | |
| 309 | /* Default block permissions (in case server supports SetBlockPermissions but doesn't send) */ |
| 310 | Blocks.CanPlace[BLOCK_AIR] = false; |
| 311 | Blocks.CanPlace[BLOCK_LAVA] = false; Blocks.CanDelete[BLOCK_LAVA] = false; |
| 312 | Blocks.CanPlace[BLOCK_WATER] = false; Blocks.CanDelete[BLOCK_WATER] = false; |
| 313 | Blocks.CanPlace[BLOCK_STILL_LAVA] = false; Blocks.CanDelete[BLOCK_STILL_LAVA] = false; |
| 314 | Blocks.CanPlace[BLOCK_STILL_WATER] = false; Blocks.CanDelete[BLOCK_STILL_WATER] = false; |
| 315 | Blocks.CanPlace[BLOCK_BEDROCK] = false; Blocks.CanDelete[BLOCK_BEDROCK] = false; |
| 316 | |
| 317 | res = Socket_ParseAddress(&Server.Address, Server.Port, addrs, &numValidAddrs); |
| 318 | if (res == ERR_INVALID_ARGUMENT) { |
| 319 | MPConnection_Fail(&invalid_reason); return; |
| 320 | } else if (res) { |
| 321 | MPConnection_FailConnect(res); return; |
| 322 | } |
| 323 | |
| 324 | res = Socket_Create(&net_socket, &addrs[0], true); |
| 325 | if (res) { MPConnection_FailConnect(res); return; } |
| 326 | res = Socket_Connect(net_socket, &addrs[0]); |
| 327 | |
| 328 | if (res && res != ReturnCode_SocketInProgess && res != ReturnCode_SocketWouldBlock) { |
| 329 | MPConnection_FailConnect(res); |
| 330 | } else { |
| 331 | Server.Disconnected = false; |
| 332 | net_connecting = true; |
| 333 | net_connectElapsed = 0; |
| 334 | |
| 335 | String_Format2(&title, "Connecting to %s:%i..", &Server.Address, &Server.Port); |
| 336 | LoadingScreen_Show(&title, &String_Empty); |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | static void MPConnection_SendBlock(int x, int y, int z, BlockID old, BlockID now) { |
| 341 | if (now == BLOCK_AIR) { |
nothing calls this directly
no test coverage detected