void TryRunTics (void) { int runtics; int entertime = I_GetTime(); // Wait for tics to run while (1) { #ifdef HAVE_NET NetUpdate(); #else D_BuildNewTiccmds(); #endif runtics = (server ? remotetic : maketic) - gametic; if (!runtics) { if (server) I_WaitForPacket(ms_to_next_tick); else I_uSleep(ms_to_next_tick*1000); if (I_GetTime() - entertime > 10) { remotesend--; if (server) { char buf[sizeof(packet_header_t) + 1]; packet_set((packet_header_t *)buf, PKT_RETRANS, remotetic); buf[sizeof(buf) - 1] = consoleplayer; I_SendPacket((packet_header_t *)buf, sizeof buf); } M_Ticker(); return; } } else break; } while (runtics--) { #ifdef HAVE_NET if (server) CheckQueuedPackets(); #endif if (advancedemo) D_DoAdvanceDemo (); M_Ticker (); G_Ticker (); gametic++; #ifdef HAVE_NET NetUpdate(); // Keep sending our tics to avoid stalling remote nodes #endif } }
void TryRunTics (void) { int runtics; int entertime = I_GetTime(); // Wait for tics to run while (1) { NetUpdate(); runtics = (server ? remotetic : maketic) - gametic; if (!runtics) { if (!movement_smooth) { if (server) I_WaitForPacket(ms_to_next_tick); else I_uSleep(ms_to_next_tick*1000); } if (I_GetTime() - entertime > 10) { if (server) { char buf[sizeof(packet_header_t)+1]; remotesend--; packet_set((packet_header_t *)buf, PKT_RETRANS, remotetic); buf[sizeof(buf)-1] = consoleplayer; I_SendPacket((packet_header_t *)buf, sizeof buf); } M_Ticker(); return; } { WasRenderedInTryRunTics = TRUE; if (movement_smooth && gamestate==wipegamestate) { isExtraDDisplay = TRUE; D_Display(); isExtraDDisplay = FALSE; } } } else break; } while (runtics--) { if (server) CheckQueuedPackets(); if (advancedemo) D_DoAdvanceDemo (); M_Ticker (); I_GetTime_SaveMS(); G_Ticker (); P_Checksum(gametic); gametic++; NetUpdate(); // Keep sending our tics to avoid stalling remote nodes } }
void D_InitNetGame (void) { int i; int numplayers = 1; i = M_CheckParm("-net"); if (i && i < myargc-1) i++; if (!(netgame = server = !!i)) { playeringame[consoleplayer = 0] = TRUE; // e6y // for play, recording or playback using "single-player coop" mode. // Equivalent to using prboom_server with -N 1 netgame = M_CheckParm("-solo-net") || M_CheckParm("-net1"); } else { // Get game info from server packet_header_t *packet = Z_Malloc(1000, PU_STATIC, NULL); struct setup_packet_s *sinfo = (void*)(packet+1); struct { packet_header_t head; short pn; } PACKEDATTR initpacket; I_InitNetwork(); udp_socket = I_Socket(0); I_ConnectToServer(myargv[i]); do { do { // Send init packet initpacket.pn = doom_htons(wanted_player_number); packet_set(&initpacket.head, PKT_INIT, 0); I_SendPacket(&initpacket.head, sizeof(initpacket)); I_WaitForPacket(5000); } while (!I_GetPacket(packet, 1000)); if (packet->type == PKT_DOWN) I_Error("Server aborted the game"); } while (packet->type != PKT_SETUP); // Get info from the setup packet consoleplayer = sinfo->yourplayer; compatibility_level = sinfo->complevel; G_Compatibility(); startskill = sinfo->skill; deathmatch = sinfo->deathmatch; startmap = sinfo->level; startepisode = sinfo->episode; ticdup = sinfo->ticdup; xtratics = sinfo->extratic; G_ReadOptions(sinfo->game_options); lprintf(LO_INFO, "\tjoined game as player %d/%d; %d WADs specified\n", consoleplayer+1, numplayers = sinfo->players, sinfo->numwads); { char *p = sinfo->wadnames; int i = sinfo->numwads; while (i--) { D_AddFile(p, source_net); p += strlen(p) + 1; } } Z_Free(packet); } localcmds = netcmds[displayplayer = consoleplayer]; for (i=0; i<numplayers; i++) playeringame[i] = TRUE; for (; i<MAXPLAYERS; i++) playeringame[i] = FALSE; if (!playeringame[consoleplayer]) I_Error("D_InitNetGame: consoleplayer not in game"); }
void D_InitNetGame (void) { int i; int numplayers = 1; i = M_CheckParm("-net"); if (i && i < myargc-1) i++; server = netgame; if (!netgame) { playeringame[consoleplayer = 0] = true; } else { StartWifi(); // Get game info from server packet_header_t *packet = Z_Malloc(1000, PU_STATIC, NULL); struct setup_packet_s *sinfo = (void*)(packet+1); struct { packet_header_t head; short pn; } PACKEDATTR initpacket; iprintf("I_InitNetwork()\n"); I_InitNetwork(); udp_socket = I_Socket(0); //I_ConnectToServer(myargv[i]); iprintf("I_ConnectToServer()\n"); if (I_ConnectToServer(server_address[0]) != 0) iprintf("FAILURE!\n"); iprintf("Connected?\n"); do { iprintf("Send Init Packet\n"); do { // Send init packet initpacket.pn = doom_htons(wanted_player_number); packet_set(&initpacket.head, PKT_INIT, 0); I_SendPacket(&initpacket.head, sizeof(initpacket)); iprintf("Wait for packet\n"); I_WaitForPacket(5000); iprintf("Done\n"); } while (!I_GetPacket(packet, 1000)); iprintf("Got it!\n"); if (packet->type == PKT_DOWN) I_Error("Server aborted the game"); } while (packet->type != PKT_SETUP); iprintf("Out of loop!\n"); // Once we have been accepted by the server, we should tell it when we leave atexit(D_QuitNetGame); // Get info from the setup packet consoleplayer = sinfo->yourplayer; compatibility_level = sinfo->complevel; G_Compatibility(); startskill = sinfo->skill; deathmatch = sinfo->deathmatch; startmap = sinfo->level; startepisode = sinfo->episode; ticdup = sinfo->ticdup; xtratics = sinfo->extratic; G_ReadOptions(sinfo->game_options); lprintf(LO_INFO, "\tjoined game as player %d/%d; %d WADs specified\n", consoleplayer+1, numplayers = sinfo->players, sinfo->numwads); { char *p = sinfo->wadnames; int i = sinfo->numwads; while (i--) { D_AddFile(p, source_net); p += strlen(p) + 1; } } Z_Free(packet); } localcmds = netcmds[displayplayer = consoleplayer]; for (i=0; i<numplayers; i++) playeringame[i] = true; for (; i<MAXPLAYERS; i++) playeringame[i] = false; if (!playeringame[consoleplayer]) I_Error("D_InitNetGame: consoleplayer not in game"); }
void TryRunTics () { int runtics; int entertime = I_GetTime(); // Wait for tics to run while (1) { #ifdef HAVE_NET NetUpdate(); #else D_BuildNewTiccmds(); #endif runtics = (server ? remotetic : maketic) - gametic; if (!runtics) { if (!movement_smooth) { #ifdef HAVE_NET if (server) I_WaitForPacket(ms_to_next_tick); else #endif I_uSleep(ms_to_next_tick*1000); } if (I_GetTime() - entertime > 10) { #ifdef HAVE_NET if (server) { char buf[sizeof(packet_header_t)+1]; remotesend--; packet_set((packet_header_t *)buf, PKT_RETRANS, remotetic); buf[sizeof(buf)-1] = consoleplayer; I_SendPacket((packet_header_t *)buf, sizeof buf); } #endif M_Ticker(); return; } //if ((displaytime) < (tic_vars.next-SDL_GetTicks())) { WasRenderedInTryRunTics = true; if (V_GetMode() == VID_MODEGL ? movement_smooth : movement_smooth && gamestate==wipegamestate) { isExtraDDisplay = true; D_Display(0); D_Display(1); isExtraDDisplay = false; } } } else break; } while (runtics--) { #ifdef HAVE_NET if (server) CheckQueuedPackets(); #endif if (advancedemo) D_DoAdvanceDemo (); M_Ticker (); I_GetTime_SaveMS(); G_Ticker (); P_Checksum(gametic); gametic++; #ifdef HAVE_NET NetUpdate(); // Keep sending our tics to avoid stalling remote nodes #endif } }