| 692 | } |
| 693 | |
| 694 | bool HostGame (int i) |
| 695 | { |
| 696 | PreGamePacket packet; |
| 697 | int numplayers; |
| 698 | int node; |
| 699 | int gotack[MAXNETNODES+1]; |
| 700 | |
| 701 | if ((i == Args->NumArgs() - 1) || !(numplayers = atoi (Args->GetArg(i+1)))) |
| 702 | { // No player count specified, assume 2 |
| 703 | numplayers = 2; |
| 704 | } |
| 705 | |
| 706 | if (numplayers > MAXNETNODES) |
| 707 | { |
| 708 | I_FatalError("You cannot host a game with %d players. The limit is currently %d.", numplayers, MAXNETNODES); |
| 709 | } |
| 710 | |
| 711 | if (numplayers == 1) |
| 712 | { // Special case: Only 1 player, so don't bother starting the network |
| 713 | netgame = false; |
| 714 | multiplayer = true; |
| 715 | doomcom.id = DOOMCOM_ID; |
| 716 | doomcom.numplayers = doomcom.numnodes = 1; |
| 717 | doomcom.consoleplayer = 0; |
| 718 | return true; |
| 719 | } |
| 720 | |
| 721 | StartNetwork (false); |
| 722 | |
| 723 | // [JC] - this computer is starting the game, therefore it should |
| 724 | // be the Net Arbitrator. |
| 725 | doomcom.consoleplayer = 0; |
| 726 | Printf ("Console player number: %d\n", doomcom.consoleplayer); |
| 727 | |
| 728 | doomcom.numnodes = 1; |
| 729 | |
| 730 | I_NetInit ("Hosting game", numplayers); |
| 731 | |
| 732 | // Wait for numplayers-1 different connections |
| 733 | if (!I_NetLoop (Host_CheckForConnects, (void *)(intptr_t)numplayers)) |
| 734 | { |
| 735 | SendAbort(); |
| 736 | return false; |
| 737 | } |
| 738 | |
| 739 | // Now inform everyone of all machines involved in the game |
| 740 | memset (gotack, 0, sizeof(gotack)); |
| 741 | I_NetMessage ("Sending all here."); |
| 742 | I_NetInit ("Done waiting", 1); |
| 743 | |
| 744 | if (!I_NetLoop (Host_SendAllHere, (void *)gotack)) |
| 745 | { |
| 746 | SendAbort(); |
| 747 | return false; |
| 748 | } |
| 749 | |
| 750 | // Now go |
| 751 | I_NetMessage ("Go"); |
no test coverage detected