Beispiel #1
0
void I_GetMemory(quakeparms_t *parms)
{
    FILE *f;
    char buffer[256];
	char *procparse;
    int freemem, buffermem, totalmem;
    int rc, suggestion;

	parms->memsize = 8*1024*1024;

    f = fopen("/proc/meminfo", "r");
    if (f)
	{
		fgets(buffer, sizeof buffer, f);
		procparse = "%s %d %d %d %d %d";
		rc = fscanf(f, procparse, buffer, &totalmem, buffer, &freemem,
		  buffer, &buffermem);

		suggestion = (9*buffermem)/10 + freemem;
		if (suggestion > totalmem)
			I_Printf("[%s] did not properly parse /proc/meminfo\n", procparse);
		if (suggestion > parms->memsize && suggestion < totalmem)
			parms->memsize = suggestion;

		fclose(f);
	}
	else
		I_Printf("Did you know /proc breaks up painful gas bubbles?\n");

	parms->membase = malloc (parms->memsize);

}
Beispiel #2
0
// DHM - Nerve
void I_ShutdownNetwork( void ) {
	if ( globalNetworking && gameLocal != NULL ) {
		
		int curPlayer = DoomLib::GetPlayer();

		for (int player = 0; player < gameLocal->Interface.GetNumPlayers(); ++player)
		{
			DoomLib::SetPlayer( player );

			if ( IsValidSocket( ::g->insocket ) ) {
				I_Printf( "[-] Shut down insocket for player %d\n", DoomLib::GetPlayer() );
				shutdown( ::g->insocket, SHUT_RDWR );
				socketclose( ::g->insocket );
			}
			if ( IsValidSocket( ::g->sendsocket ) ) {
				I_Printf( "[-] Shut down sendsocket for player %d\n", DoomLib::GetPlayer() );
				shutdown( ::g->sendsocket, SHUT_RDWR );
				socketclose( ::g->sendsocket );
			}
		}

		DoomLib::SetPlayer(curPlayer);

		globalNetworking = false;
	}
}
//
// I_SetAffinityMask
//
// Due to ongoing problems with the SDL_mixer library and/or the SDL audio
// core, it is necessary to support the restriction of Eternity to a single
// core or CPU. Apparent thread contention issues cause the library to 
// malfunction if multiple threads of the process run simultaneously.
//
// I wish SDL would fix their bullshit already.
//
void I_SetAffinityMask(void)
{
#ifdef HAVE_SCHED_SETAFFINITY
   int p = M_CheckParm("-affinity");

   if(p && p < myargc - 1)
       process_affinity_mask = datoi(myargv[p + 1]);
   else
       process_affinity_mask = 0;

   // Set the process affinity mask so that all threads
   // run on the same processor.  This is a workaround for a bug in
   // SDL_mixer that causes occasional crashes.
   if(process_affinity_mask)
   {
      int i;
      cpu_set_t set;

      CPU_ZERO(&set);
      
      for(i = 0; i < 16; ++i)
         CPU_SET((process_affinity_mask>>i)&1, &set);

      if(sched_setaffinity(getpid(), sizeof(set), &set) == -1)
         I_Printf("I_SetAffinityMask: failed to set process affinity mask.\n");
      else
         I_Printf("I_SetAffinityMask: applied affinity mask.\n");
   }
#endif
}
Beispiel #4
0
//
// R_InitData
// Locates all the lumps
//  that will be used by all views
// Must be called after W_Init.
//
void R_InitData (void)
{
    R_InitTextures ();
    I_Printf ("\nInitTextures");
    R_InitFlats ();
    I_Printf ("\nInitFlats");
    R_InitSpriteLumps ();
    I_Printf ("\nInitSprites");
    R_InitColormaps ();
    I_Printf ("\nInitColormaps");
}
Beispiel #5
0
void G_PrintActions(alist_t *al)
{
    int i;
    
    while(al)
    {
        I_Printf("%s", al->cmd);
        for(i = 0; al->param[i]; i++)
        {
            I_Printf(" %s", al->param[i]);
        }
        al = al->next;
        if(al)
            I_Printf(" ; ");
    }
}
Beispiel #6
0
void D_DoomMain(void)
{
    I_Printf("I_Init\n");
    I_Init();
    I_Printf("Z_Init\n");
    Z_Init();
    I_Printf("W_Init\n");
    W_Init();
    I_Printf("R_Init\n");
    R_Init();
    I_Printf("P_Init\n");
    P_Init();
    I_Printf("ST_Init\n");
    ST_Init();
    I_Printf("S_Init\n");
    S_Init();

    gameaction = ga_nothing;
    gamestate = GS_NONE;
    gametic = 0;
    startskill = sk_medium;
    gameskill = sk_medium;
    startmap = 1;
    ticdup = 1;
    offsetms = 0;
    playeringame[0] = true;

    D_DebugParams();
    D_SplashScreen();
    D_DoomLoop();
}
Beispiel #7
0
void G_ShowAliases(action_t	*action)
{
    if(!action)
        return;
    
    if(action->children[0])
        G_ShowAliases(action->children[0]);

    if((action->proc == G_RunAlias) && action->data)
    {
        I_Printf(" %s = ", action->name);
        G_PrintActions((alist_t *)action->data);
        I_Printf("\n");
    }

    if(action->children[1])
        G_ShowAliases(action->children[1]);
}
Beispiel #8
0
static CMD(Unbind)
{   
    if(!param[0])
    {
        I_Printf(" unbind <key>\n");
        return;
    }
    
    Unbind(param[0]);
}
Beispiel #9
0
void CON_Printf(rcolor clr, const char *s, ...) {
    static char msg[MAX_MESSAGE_SIZE];
    va_list    va;

    va_start(va, s);
    vsprintf(msg, s, va);
    va_end(va);

    I_Printf(msg);
    console_buffer[console_head]->color = clr;
}
Beispiel #10
0
void G_ShowBinding(char *key)
{
    alist_t	**alist;
    
    alist = G_FindKeyByName(key);
    if(!alist)
    {
        CON_Warnf("Unknown key:%s\n", key);
        return;
    }
    if(!*alist)
    {
        CON_Warnf("%s is not bound\n", key);
        return;
    }

    I_Printf("%s = ", key);
    G_PrintActions(*alist);
    I_Printf("\n");
}
Beispiel #11
0
static CMD(Alias)
{
    alist_t *al;
    
    if(!param[0])
    {
        I_Printf("Current Aliases:\n");
        G_ShowAliases(Actions);
        return;
    }
    al = ParseActions(param[1]);
    if(!al)
        G_UnregisterAction(param[0]);
    else
        G_AddCommand(param[0], G_RunAlias, (int64)al);
}
Beispiel #12
0
static void Unbind(char *action)
{
    alist_t **alist;

    alist = G_FindKeyByName(action);
    if(!alist)
    {
        I_Printf("Unknown Key:%s\n", action);
        return;
    }
    if(*alist)
    {
        DerefActionList(*alist);
        *alist=NULL;
    }
}
Beispiel #13
0
void
WI_drawOnLnode
( int		n,
  patch_t*	c[] )
{

    int		i;
    int		left;
    int		top;
    int		right;
    int		bottom;
    qboolean	fits = false;

    i = 0;
    do
    {
	left = lnodes[::g->wbs->epsd][n].x - SHORT(c[i]->leftoffset);
	top = lnodes[::g->wbs->epsd][n].y - SHORT(c[i]->topoffset);
	right = left + SHORT(c[i]->width);
	bottom = top + SHORT(c[i]->height);

	if (left >= 0
	    && right < SCREENWIDTH
	    && top >= 0
	    && bottom < SCREENHEIGHT)
	{
	    fits = true;
	}
	else
	{
	    i++;
	}
    } while (!fits && i!=2);

    if (fits && i<2)
    {
	V_DrawPatch(lnodes[::g->wbs->epsd][n].x, lnodes[::g->wbs->epsd][n].y,
		    FB, c[i]);
    }
    else
    {
	// DEBUG
	I_Printf("Could not place patch on level %d", n+1); 
    }
}
Beispiel #14
0
//
// R_InitSpriteLumps
// Finds the width and hoffset of all ::g->sprites in the wad,
//  so the sprite does not need to be cached completely
//  just for having the header info ready during rendering.
//
void R_InitSpriteLumps (void)
{
    int		i;
    patch_t	*patch;
	
    ::g->firstspritelump = W_GetNumForName ("S_START") + 1;
    ::g->lastspritelump = W_GetNumForName ("S_END") - 1;
    
    ::g->numspritelumps = ::g->lastspritelump - ::g->firstspritelump + 1;
    ::g->spritewidth = (fixed_t*)DoomLib::Z_Malloc (::g->numspritelumps*4, PU_STATIC, 0);
    ::g->spriteoffset = (fixed_t*)DoomLib::Z_Malloc (::g->numspritelumps*4, PU_STATIC, 0);
    ::g->spritetopoffset = (fixed_t*)DoomLib::Z_Malloc (::g->numspritelumps*4, PU_STATIC, 0);
	
    for (i=0 ; i< ::g->numspritelumps ; i++)
    {
	if (!(i&63))
	    I_Printf (".");

	patch = (patch_t*)W_CacheLumpNum (::g->firstspritelump+i, PU_CACHE_SHARED);
	::g->spritewidth[i] = SHORT(patch->width)<<FRACBITS;
	::g->spriteoffset[i] = SHORT(patch->leftoffset)<<FRACBITS;
	::g->spritetopoffset[i] = SHORT(patch->topoffset)<<FRACBITS;
    }
}
Beispiel #15
0
//
// R_InitTextures
// Initializes the texture list
//  with the s_textures from the world map.
//
void R_InitTextures (void)
{
    maptexture_t*	mtexture;
    texture_t*		texture;
    mappatch_t*		mpatch;
    texpatch_t*		patch;

    int			i;
    int			j;

    int*		maptex;
    int*		maptex2;
    int*		maptex1;
    
    char		name[9];
    char*		names;
    char*		name_p;
    
    int			totalwidth;
    int			nummappatches;
    int			offset;
    int			maxoff;
    int			maxoff2;
    int			numtextures1;
    int			numtextures2;

    int*		directory;
    
    int			temp1;
    int			temp2;
    int			temp3;

    
    // Load the patch names from pnames.lmp.
    name[8] = 0;	
    names = (char*)W_CacheLumpName ("PNAMES", PU_CACHE_SHARED);
    nummappatches = LONG ( *((int *)names) );
    name_p = names+4;
    
	std::vector<int> patchlookup(nummappatches);

    for (i=0 ; i<nummappatches ; i++)
    {
		strncpy (name,name_p+i*8, 8);
		patchlookup[i] = W_CheckNumForName (name);
    }
    Z_Free(names);
    
	if (::g->s_numtextures == 0)
	{

		// Load the map texture definitions from textures.lmp.
		// The data is contained in one or two lumps,
		//  TEXTURE1 for shareware, plus TEXTURE2 for commercial.
		maptex = maptex1 = (int*)W_CacheLumpName ("TEXTURE1", PU_CACHE_SHARED); // ALAN:  LOADTIME
		numtextures1 = LONG(*maptex);
		maxoff = W_LumpLength (W_GetNumForName ("TEXTURE1"));
		directory = maptex+1;

		if (W_CheckNumForName ("TEXTURE2") != -1)
		{
			maptex2 = (int*)W_CacheLumpName ("TEXTURE2", PU_CACHE_SHARED); // ALAN:  LOADTIME
			numtextures2 = LONG(*maptex2);
			maxoff2 = W_LumpLength (W_GetNumForName ("TEXTURE2"));
		}
		else
		{
			maptex2 = NULL;
			numtextures2 = 0;
			maxoff2 = 0;
		}


		::g->s_numtextures = numtextures1 + numtextures2;

		::g->s_textures = (texture_t**)DoomLib::Z_Malloc (::g->s_numtextures*sizeof(texture_t*), PU_STATIC_SHARED, 0);
		::g->s_texturecolumnlump = (short**)DoomLib::Z_Malloc (::g->s_numtextures*sizeof(short*), PU_STATIC_SHARED, 0);
		::g->s_texturecolumnofs = (unsigned short**)DoomLib::Z_Malloc (::g->s_numtextures*sizeof(unsigned short*), PU_STATIC_SHARED, 0);
		::g->s_texturewidthmask = (int*)DoomLib::Z_Malloc (::g->s_numtextures*4, PU_STATIC_SHARED, 0);
		::g->s_textureheight = (fixed_t*)DoomLib::Z_Malloc (::g->s_numtextures*4, PU_STATIC_SHARED, 0);
		::g->s_texturecomposite = (byte**)DoomLib::Z_Malloc (::g->s_numtextures*sizeof(byte*), PU_STATIC_SHARED, 0);
		::g->s_texturecompositesize = (int*)DoomLib::Z_Malloc (::g->s_numtextures*4, PU_STATIC_SHARED, 0);

		totalwidth = 0;

		//	Really complex printing shit...
		temp1 = W_GetNumForName ("S_START");  // P_???????
		temp2 = W_GetNumForName ("S_END") - 1;
		temp3 = ((temp2-temp1+63)/64) + ((::g->s_numtextures+63)/64);
		I_Printf("[");
		for (i = 0; i < temp3; i++)
			I_Printf(" ");
		I_Printf("         ]");
		for (i = 0; i < temp3; i++)
			I_Printf("\x8");
		I_Printf("\x8\x8\x8\x8\x8\x8\x8\x8\x8\x8");	

		for (i=0 ; i < ::g->s_numtextures ; i++, directory++)
		{
			if (!(i&63))
				I_Printf (".");

			if (i == numtextures1)
			{
				// Start looking in second texture file.
				maptex = maptex2;
				maxoff = maxoff2;
				directory = maptex+1;
			}
		
			offset = LONG(*directory);

			if (offset > maxoff)
				I_Error ("R_InitTextures: bad texture directory");
		
			mtexture = (maptexture_t *) ( (byte *)maptex + offset);

			texture = ::g->s_textures[i] = (texture_t*)DoomLib::Z_Malloc (sizeof(texture_t)
				+ sizeof(texpatch_t)*(SHORT(mtexture->patchcount)-1), PU_STATIC_SHARED, 0);

			texture->width = SHORT(mtexture->width);
			texture->height = SHORT(mtexture->height);
			texture->patchcount = SHORT(mtexture->patchcount);

			memcpy (texture->name, mtexture->name, sizeof(texture->name));
			mpatch = &mtexture->patches[0];
			patch = &texture->patches[0];

			for (j=0 ; j<texture->patchcount ; j++, mpatch++, patch++)
			{
				patch->originx = SHORT(mpatch->originx);
				patch->originy = SHORT(mpatch->originy);
				patch->patch = patchlookup[SHORT(mpatch->patch)];
				if (patch->patch == -1)
				{
					I_Error ("R_InitTextures: Missing patch in texture %s",
					texture->name);
				}
			}		
			::g->s_texturecolumnlump[i] = (short*)DoomLib::Z_Malloc (texture->width*2, PU_STATIC_SHARED,0);
			::g->s_texturecolumnofs[i] = (unsigned short*)DoomLib::Z_Malloc (texture->width*2, PU_STATIC_SHARED,0);

			j = 1;
			while (j*2 <= texture->width)
				j<<=1;

			::g->s_texturewidthmask[i] = j-1;
			::g->s_textureheight[i] = texture->height<<FRACBITS;

			totalwidth += texture->width;
		}

		Z_Free(maptex1);
		if (maptex2)
			Z_Free(maptex2);


		// Precalculate whatever possible.	
		for (i=0 ; i < ::g->s_numtextures ; i++)
			R_GenerateLookup (i);
	}

	// ALAN:  These animations are done globally -- can it be shared?
	// Create translation table for global animation.
	::g->texturetranslation = (int*)DoomLib::Z_Malloc ((::g->s_numtextures+1)*4, PU_STATIC, 0);

	for (i=0 ; i < ::g->s_numtextures ; i++)
		::g->texturetranslation[i] = i;	
}
Beispiel #16
0
//
// R_GenerateLookup
//
void R_GenerateLookup (int texnum)
{
    texture_t*		texture;
    texpatch_t*		patch;	
    patch_t*		realpatch;
    int			x;
    int			x1;
    int			x2;
    int			i;
    short*		collump;
    unsigned short*	colofs;
	
    texture = ::g->s_textures[texnum];

    // Composited texture not created yet.
    ::g->s_texturecomposite[texnum] = 0;
    
    ::g->s_texturecompositesize[texnum] = 0;
    collump = ::g->s_texturecolumnlump[texnum];
    colofs = ::g->s_texturecolumnofs[texnum];
    
    // Now count the number of columns
    //  that are covered by more than one patch.
    // Fill in the lump / offset, so columns
    //  with only a single patch are all done.
    std::vector<byte> patchcount(texture->width, 0);
    patch = texture->patches;
		
    for (i=0 , patch = texture->patches;
	 i<texture->patchcount;
	 i++, patch++)
    {
	realpatch = (patch_t*)W_CacheLumpNum (patch->patch, PU_CACHE_SHARED);
	x1 = patch->originx;
	x2 = x1 + SHORT(realpatch->width);
	
	if (x1 < 0)
	    x = 0;
	else
	    x = x1;

	if (x2 > texture->width)
	    x2 = texture->width;
	for ( ; x<x2 ; x++)
	{
	    patchcount[x]++;
	    collump[x] = patch->patch;
	    colofs[x] = LONG(realpatch->columnofs[x-x1])+3;
	}
    }
	
    for (x=0 ; x<texture->width ; x++)
    {
	if (!patchcount[x])
	{
	    I_Printf ("R_GenerateLookup: column without a patch (%s)\n",
		    texture->name);
	    return;
	}
	// I_Error ("R_GenerateLookup: column without a patch");
	
	if (patchcount[x] > 1)
	{
	    // Use the cached block.
	    collump[x] = -1;	
	    colofs[x] = ::g->s_texturecompositesize[texnum];
	    
	    if (::g->s_texturecompositesize[texnum] > 0x10000-texture->height)
	    {
		I_Error ("R_GenerateLookup: texture %i is >64k",
			 texnum);
	    }
	    
	    ::g->s_texturecompositesize[texnum] += texture->height;
	}
    }	
}
Beispiel #17
0
static void D_DebugParams(void)
{
    int keys = 0;

    scanKeys();
    keys = keysHeld();

    if(!(keys & (KEY_Y | KEY_B)))
        return;

    I_Printf("Debug startup enabled\n\n");

    while(!(keys & KEY_START))
    {
        scanKeys();
        keys = keysDown();

        if(keys & KEY_UP)
        {
            keys &= ~KEY_UP;
            startmap++;
            if(startmap > 33)
                startmap = 33;

            I_Printf("startmap: %i\n", startmap);
        }
        if(keys & KEY_DOWN)
        {
            keys &= ~KEY_DOWN;
            startmap--;
            if(startmap < 1)
                startmap = 1;

            I_Printf("startmap: %i\n", startmap);
        }
        if(keys & KEY_A)
        {
            nomonsters ^= 1;
            I_Printf("nomonsters ");
            if(nomonsters)
                I_Printf("on\n");
            else
                I_Printf("off\n");
        }
        if(keys & KEY_B)
        {
            lockmonsters ^= 1;
            I_Printf("lockmonsters ");
            if(lockmonsters)
                I_Printf("on\n");
            else
                I_Printf("off\n");
        }
        if(keys & KEY_X)
        {
            devparm ^= 1;
            I_Printf("development mode ");
            if(devparm)
                I_Printf("on\n");
            else
                I_Printf("off\n");
        }
        if(keys & KEY_Y)
        {
            nosound ^= 1;
            I_Printf("sound ");
            if(nosound)
                I_Printf("disabled\n");
            else
                I_Printf("enabled\n");
        }

        swiWaitForVBlank();
    }

    I_Printf("Exiting...\n");
}
Beispiel #18
0
void W_AddFile ( const char *filename)
{
    wadinfo_t		header;
    lumpinfo_t*		lump_p;
    int		i;
    idFile *		handle;
    int			length;
    int			startlump;
    std::vector<filelump_t>	fileinfo( 1 );
    
    // open the file and add to directory
    if ( (handle = fileSystem->OpenFileRead(filename)) == 0)
    {
		I_Printf (" couldn't open %s\n",filename);
		return;
    }

    I_Printf (" adding %s\n",filename);
    startlump = numlumps;
	
    if ( idStr::Icmp( filename+strlen(filename)-3 , "wad" ) )
    {
		// single lump file
		fileinfo[0].filepos = 0;
		fileinfo[0].size = 0;
		ExtractFileBase (filename, fileinfo[0].name);
		numlumps++;
    }
    else 
    {
		// WAD file
		handle->Read( &header, sizeof( header ) );
		if ( idStr::Cmpn( header.identification,"IWAD",4 ) )
		{
			// Homebrew levels?
			if ( idStr::Cmpn( header.identification, "PWAD", 4 ) )
			{
				I_Error ("Wad file %s doesn't have IWAD "
					"or PWAD id\n", filename);
			}
		    
			// ???modifiedgame = true;		
		}
		header.numlumps = LONG(header.numlumps);
		header.infotableofs = LONG(header.infotableofs);
		length = header.numlumps*sizeof(filelump_t);
		fileinfo.resize(header.numlumps);
		handle->Seek(  header.infotableofs, FS_SEEK_SET );
		handle->Read( &fileinfo[0], length );
		numlumps += header.numlumps;
    }

    
	// Fill in lumpinfo
	if (lumpinfo == NULL) {
		lumpinfo = (lumpinfo_t*)malloc( numlumps*sizeof(lumpinfo_t) );
	} else {
		lumpinfo = (lumpinfo_t*)realloc( lumpinfo, numlumps*sizeof(lumpinfo_t) );
	}

	if (!lumpinfo)
		I_Error ("Couldn't realloc lumpinfo");

	lump_p = &lumpinfo[startlump];

	::g->wadFileHandles[ ::g->numWadFiles++ ] = handle;

	filelump_t * filelumpPointer = &fileinfo[0];
	for (i=startlump ; i<numlumps ; i++,lump_p++, filelumpPointer++)
	{
		lump_p->handle = handle;
		lump_p->position = LONG(filelumpPointer->filepos);
		lump_p->size = LONG(filelumpPointer->size);
		strncpy (lump_p->name, filelumpPointer->name, 8);
	}
}
Beispiel #19
0
//
// I_InitNetwork
//
void I_InitNetwork (void)
{

	//qboolean		trueval = true;
	int			i;
	int			p;
	//int a = 0;
	//    struct hostent*	hostentry;	// host information entry

	memset (&::g->doomcom, 0, sizeof(::g->doomcom) );

	// set up for network
	i = M_CheckParm ("-dup");
	if (i && i< ::g->myargc-1)
	{
		::g->doomcom.ticdup = ::g->myargv[i+1][0]-'0';
		if (::g->doomcom.ticdup < 1)
			::g->doomcom.ticdup = 1;
		if (::g->doomcom.ticdup > 9)
			::g->doomcom.ticdup = 9;
	}
	else
		::g->doomcom.ticdup = 1;

	if (M_CheckParm ("-extratic"))
		::g->doomcom.extratics = 1;
	else
		::g->doomcom.extratics = 0;

	p = M_CheckParm ("-port");
	if (p && p < ::g->myargc-1)
	{
		DOOMPORT = atoi (::g->myargv[p+1]);
		I_Printf ("using alternate port %i\n",DOOMPORT);
	}

	// parse network game options,
	//  -net <::g->consoleplayer> <host> <host> ...
	i = M_CheckParm ("-net");
	if (!i || !I_TrySetupNetwork())
	{
		// single player game
		::g->netgame = false;
		::g->doomcom.id = DOOMCOM_ID;
		::g->doomcom.numplayers = ::g->doomcom.numnodes = 1;
		::g->doomcom.deathmatch = false;
		::g->doomcom.consoleplayer = 0;
		return;
	}

	netsend = PacketSend;
	netget = PacketGet;

	::g->netgame = true;

	{
		++i; // skip the '-net'
		::g->doomcom.numnodes = 0;
		::g->doomcom.consoleplayer = atoi( ::g->myargv[i] );
		// skip the console number
		++i;
		::g->doomcom.numnodes = 0;
		for (; i < ::g->myargc; ++i)
		{
			::g->sendaddress[::g->doomcom.numnodes].sin_family = AF_INET;
			::g->sendaddress[::g->doomcom.numnodes].sin_port = htons(DOOMPORT);
			
			// Pull out the port number.
			const std::string ipAddressWithPort( ::g->myargv[i] );
			const std::size_t colonPosition = ipAddressWithPort.find_last_of(':');
			std::string ipOnly;

			if( colonPosition != std::string::npos && colonPosition + 1 < ipAddressWithPort.size() ) {
				const std::string portOnly( ipAddressWithPort.substr( colonPosition + 1 ) );

				::g->sendaddress[::g->doomcom.numnodes].sin_port = htons( atoi( portOnly.c_str() ) );

				ipOnly = ipAddressWithPort.substr( 0, colonPosition );
			} else {
				// Assume the address doesn't include a port.
				ipOnly = ipAddressWithPort;
			}

			in_addr_t ipAddress = inet_addr( ipOnly.c_str() );

			if ( ipAddress == INADDR_NONE ) {
				I_Error( "Invalid IP Address: %s\n", ipOnly.c_str() );
				session->QuitMatch();
				common->AddDialog( GDM_OPPONENT_CONNECTION_LOST, DIALOG_ACCEPT, NULL, NULL, false );
			}
			::g->sendaddress[::g->doomcom.numnodes].sin_addr.s_addr = ipAddress;
			::g->doomcom.numnodes++;
		}
		
		::g->doomcom.id = DOOMCOM_ID;
		::g->doomcom.numplayers = ::g->doomcom.numnodes;
	}

	if ( globalNetworking ) {
		// Setup sockets
		::g->insocket = UDPsocket ();
		BindToLocalPort (::g->insocket,htons(DOOMPORT));
		
		// PS3 call to enable non-blocking mode
		int nonblocking = 1; // Non-zero is nonblocking mode.
		setsockopt( ::g->insocket, SOL_SOCKET, SO_NBIO, &nonblocking, sizeof(nonblocking));

		::g->sendsocket = UDPsocket ();

		I_Printf( "[+] Setting up sockets for player %d\n", DoomLib::GetPlayer() );
	}
}