static void NET_SV_ParseSYN(net_packet_t *packet, net_client_t *client, net_addr_t *addr) { unsigned int magic; net_connect_data_t data; char *player_name; char *client_version; int i; // read the magic number if (!NET_ReadInt32(packet, &magic)) { return; } if (magic != NET_MAGIC_NUMBER) { // invalid magic number return; } // Check the client version is the same as the server client_version = NET_ReadString(packet); if (client_version == NULL) { return; } if (strcmp(client_version, PACKAGE_STRING) != 0) { //! // @category net // // When running a netgame server, ignore version mismatches between // the server and the client. Using this option may cause game // desyncs to occur, or differences in protocol may mean the netgame // will simply not function at all. // if (M_CheckParm("-ignoreversion") == 0) { NET_SV_SendReject(addr, "Different " PACKAGE_NAME " versions cannot play a net game!\n" "Version mismatch: server version is: " PACKAGE_STRING); return; } } // read the game mode and mission if (!NET_ReadConnectData(packet, &data)) { return; } if (!D_ValidGameMode(data.gamemission, data.gamemode)) { return; } // Check max_players value. This must be in a sensible range. if (data.max_players > NET_MAXPLAYERS) { return; } // read the player's name player_name = NET_ReadString(packet); if (player_name == NULL) { return; } // received a valid SYN // not accepting new connections? if (server_state != SERVER_WAITING_LAUNCH) { NET_SV_SendReject(addr, "Server is not currently accepting connections"); return; } // allocate a client slot if there isn't one already if (client == NULL) { // find a slot, or return if none found for (i=0; i<MAXNETNODES; ++i) { if (!clients[i].active) { client = &clients[i]; break; } } if (client == NULL) { return; } } else { // If this is a recently-disconnected client, deactivate // to allow immediate reconnection if (client->connection.state == NET_CONN_STATE_DISCONNECTED) { client->active = false; } } // New client? if (!client->active) { int num_players; // Before accepting a new client, check that there is a slot // free NET_SV_AssignPlayers(); num_players = NET_SV_NumPlayers(); if ((!data.drone && num_players >= NET_SV_MaxPlayers()) || NET_SV_NumClients() >= MAXNETNODES) { NET_SV_SendReject(addr, "Server is full!"); return; } // TODO: Add server option to allow rejecting clients which // set lowres_turn. This is potentially desirable as the // presence of such clients affects turning resolution. // Adopt the game mode and mission of the first connecting client if (num_players == 0 && !data.drone) { sv_gamemode = data.gamemode; sv_gamemission = data.gamemission; } // Save the SHA1 checksums memcpy(client->wad_sha1sum, data.wad_sha1sum, sizeof(sha1_digest_t)); memcpy(client->deh_sha1sum, data.deh_sha1sum, sizeof(sha1_digest_t)); client->is_freedoom = data.is_freedoom; client->max_players = data.max_players; // Check the connecting client is playing the same game as all // the other clients if (data.gamemode != sv_gamemode || data.gamemission != sv_gamemission) { NET_SV_SendReject(addr, "You are playing the wrong game!"); return; } // Activate, initialize connection NET_SV_InitNewClient(client, addr, player_name); client->recording_lowres = data.lowres_turn; client->drone = data.drone; client->player_class = data.player_class; } if (client->connection.state == NET_CONN_STATE_WAITING_ACK) { // force an acknowledgement client->connection.last_send_time = -1; } }
// // E_EDFResetWarnings // // Resets the count of warnings to zero. // void E_EDFResetWarnings() { edf_warning_count = 0; edf_warning_out = !!M_CheckParm("-edf-show-warnings"); }
void I_GraphicsCheckCommandLine(void) { int i; //! // @category video // @vanilla // // Disable blitting the screen. // noblit = M_CheckParm ("-noblit"); //! // @category video // // Don't grab the mouse when running in windowed mode. // nograbmouse_override = M_ParmExists("-nograbmouse"); // default to fullscreen mode, allow override with command line // nofullscreen because we love prboom //! // @category video // // Run in a window. // if (M_CheckParm("-window") || M_CheckParm("-nofullscreen")) { fullscreen = false; } //! // @category video // // Run in fullscreen mode. // if (M_CheckParm("-fullscreen")) { fullscreen = true; } //! // @category video // // Disable the mouse. // nomouse = M_CheckParm("-nomouse") > 0; //! // @category video // @arg <x> // // Specify the screen width, in pixels. Implies -window. // i = M_CheckParmWithArgs("-width", 1); if (i > 0) { window_width = atoi(myargv[i + 1]); window_height = window_width * 2; AdjustWindowSize(); fullscreen = false; } //! // @category video // @arg <y> // // Specify the screen height, in pixels. Implies -window. // i = M_CheckParmWithArgs("-height", 1); if (i > 0) { window_height = atoi(myargv[i + 1]); window_width = window_height * 2; AdjustWindowSize(); fullscreen = false; } //! // @category video // @arg <WxY> // // Specify the dimensions of the window. Implies -window. // i = M_CheckParmWithArgs("-geometry", 1); if (i > 0) { int w, h, s; s = sscanf(myargv[i + 1], "%ix%i", &w, &h); if (s == 2) { window_width = w; window_height = h; fullscreen = false; } } //! // @category video // // Don't scale up the screen. Implies -window. // if (M_CheckParm("-1")) { SetScaleFactor(1); } //! // @category video // // Double up the screen to 2x its normal size. Implies -window. // if (M_CheckParm("-2")) { SetScaleFactor(2); } //! // @category video // // Double up the screen to 3x its normal size. Implies -window. // if (M_CheckParm("-3")) { SetScaleFactor(3); } }
void M_LoadDefaults (void) { int i; int len; FILE* f; char def[80]; char strparm[100]; char* newstring = NULL; // killough int parm; boolean isstring; // set everything to base values numdefaults = sizeof(defaults) / sizeof(defaults[0]); for (i = 0 ; i < numdefaults ; i++) { if (defaults[i].location.ppsz) *defaults[i].location.ppsz = strdup(defaults[i].defaultvalue.psz); if (defaults[i].location.pi) *defaults[i].location.pi = defaults[i].defaultvalue.i; } // check for a custom default file #if ((defined GL_DOOM) && (defined _MSC_VER)) #define BOOM_CFG "glboom.cfg" #else #define BOOM_CFG "prboom.cfg" #endif i = M_CheckParm ("-config"); if (i && i < myargc-1) defaultfile = strdup(myargv[i+1]); else { const char* exedir = I_DoomExeDir(); /* get config file from same directory as executable */ #if 1 int len = doom_snprintf(NULL, 0, BOOM_CFG); defaultfile = malloc(len+1); doom_snprintf(defaultfile, len+1, BOOM_CFG); #else int len = doom_snprintf(NULL, 0, "%s/" BOOM_CFG, exedir); defaultfile = malloc(len+1); doom_snprintf(defaultfile, len+1, "%s/" BOOM_CFG, exedir); #endif } lprintf (LO_CONFIRM, " default file: %s\n",defaultfile); // read the file in, overriding any set defaults f = fopen (defaultfile, "r"); if (f) { while (!feof(f)) { isstring = false; if (fscanf (f, "%79s %[^\n]\n", def, strparm) == 2) { //jff 3/3/98 skip lines not starting with an alphanum if (!isalnum(def[0])) continue; if (strparm[0] == '"') { // get a string default isstring = true; len = strlen(strparm); newstring = (char *) malloc(len); strparm[len-1] = 0; // clears trailing double-quote mark strcpy(newstring, strparm+1); // clears leading double-quote mark } else if ((strparm[0] == '0') && (strparm[1] == 'x')) { // CPhipps - allow ints to be specified in hex sscanf(strparm+2, "%x", &parm); } else { sscanf(strparm, "%i", &parm); // Keycode hack removed } for (i = 0 ; i < numdefaults ; i++) if ((defaults[i].type != def_none) && !strcmp(def, defaults[i].name)) { // CPhipps - safety check if (isstring != IS_STRING(defaults[i])) { lprintf(LO_WARN, "M_LoadDefaults: Type mismatch reading %s\n", defaults[i].name); continue; } if (!isstring) { //jff 3/4/98 range check numeric parameters if ((defaults[i].minvalue==UL || defaults[i].minvalue<=parm) && (defaults[i].maxvalue==UL || defaults[i].maxvalue>=parm)) *(defaults[i].location.pi) = parm; } else { union { const char **c; char **s; } u; // type punning via unions u.c = defaults[i].location.ppsz; free(*(u.s)); *(u.s) = newstring; } break; } } } fclose (f); } //jff 3/4/98 redundant range checks for hud deleted here }