//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamRoundTimer::InputAddTeamTime( inputdata_t &input )
{
	char		token[128];
	const char	*p = STRING( input.value.StringID() );
	int			nTeam = TEAM_UNASSIGNED;
	int			nSeconds = 0;

	// get the team
	p = nexttoken( token, p, ' ' );
	if ( token )
	{
		nTeam = Q_atoi( token );
	}

	// get the time
	p = nexttoken( token, p, ' ' );
	if ( token )
	{
		nSeconds = Q_atoi( token );
	}

	if ( nSeconds != 0 )
	{
		AddTimerSeconds( nSeconds, nTeam );
	}
}
Ejemplo n.º 2
0
// returns days since Feb 13 2007
int Q_buildnum( void )
{
// do not touch this! Only author of Xash3D can increase buildnumbers!
#if 0 
	int m = 0, d = 0, y = 0;
	static int b = 0;

	if( b != 0 ) return b;

	for( m = 0; m < 11; m++ )
	{
		if( !Q_strnicmp( &date[0], mon[m], 3 ))
			break;
		d += mond[m];
	}

	d += Q_atoi( &date[4] ) - 1;
	y = Q_atoi( &date[7] ) - 1900;
	b = d + (int)((y - 1) * 365.25f );

	if((( y % 4 ) == 0 ) && m > 1 )
	{
		b += 1;
	}
	b -= 38752; // Feb 13 2007

	return b;
#else
	return 3030;
#endif
}
Ejemplo n.º 3
0
int build_number(void)
{
    int m = 0;
    int d = 0;
    int y = 0;
    static int b = 0;

    if (b != 0)
        return b;

    for (m = 0; m < 11; m++)
    {
        if (Q_strnicmp(&date[0], mon[m], 3) == 0)
            break;
        d += mond[m];
    }

    d += Q_atoi(&date[4]) - 1;
    y = Q_atoi(&date[7]) - 1900;
    b = d + (int)((y - 1) * 365.25);

    if (((y % 4) == 0) && m > 1)
    {
        b += 1;
    }

#ifdef REHLDS_FIXES
    b -= 41374; // return days since initial commit on Apr 12 2014 (Happy Cosmonautics Day!)
#else // REHLDS_FIXES
    b -= 34995; // return days since Oct 24 1996
#endif // REHLDS_FIXES

    return b;
}
Ejemplo n.º 4
0
void IN_FireDown(void)
{
	int key_code = VOID_KEY;
	int last_arg_idx = Cmd_Argc() - 1;
	int i;

	if (Cmd_Argc() < 2) {
		Com_Printf("Usage: %s <weapon number>\n", Cmd_Argv(0));
		return;
	}

	if (IN_IsLastArgKeyCode()) {
		key_code = Q_atoi(Cmd_Argv(last_arg_idx));
		last_arg_idx--;
	}

	for (i = 1; i <= last_arg_idx && i <= MAXWEAPONS; i++) {
		int desired_impulse = Q_atoi(Cmd_Argv(i));
		weapon_order[i - 1] = desired_impulse;
	}

	for (; i <= MAXWEAPONS; i++) {
		weapon_order[i - 1] = 0;
	}

	in_impulse = IN_BestWeapon();

	KeyDown_common(&in_attack, key_code);
}
Ejemplo n.º 5
0
/*
================
CL_UpdateUserinfo

collect userinfo from all players
================
*/
void CL_UpdateUserinfo( sizebuf_t *msg )
{
	int		slot;
	qboolean		active;
	player_info_t	*player;

	slot = BF_ReadUBitLong( msg, MAX_CLIENT_BITS );

	if( slot >= MAX_CLIENTS )
		Host_Error( "CL_ParseServerMessage: svc_updateuserinfo > MAX_CLIENTS\n" );

	player = &cl.players[slot];
	active = BF_ReadOneBit( msg ) ? true : false;

	if( active )
	{
		Q_strncpy( player->userinfo, BF_ReadString( msg ), sizeof( player->userinfo ));
		Q_strncpy( player->name, Info_ValueForKey( player->userinfo, "name" ), sizeof( player->name ));
		Q_strncpy( player->model, Info_ValueForKey( player->userinfo, "model" ), sizeof( player->model ));
		cl.playermodels[slot] = 0;
		player->topcolor = Q_atoi( Info_ValueForKey( player->userinfo, "topcolor" ));
		player->bottomcolor = Q_atoi( Info_ValueForKey( player->userinfo, "bottomcolor" ));

		if( slot == cl.playernum ) Q_memcpy( &menu.playerinfo, player, sizeof( player_info_t ));
	}
	else Q_memset( player, 0, sizeof( *player ));
}
Ejemplo n.º 6
0
// returns days since Feb 13 2007
int Q_buildnum( void )
{
// do not touch this! Only author of Xash3D can increase buildnumbers!
// Xash3D SDL: HAHAHA! I TOUCHED THIS!
#if defined(XASH_GENERATE_BUILDNUM)
	int m = 0, d = 0, y = 0;
	static int b = 0;

	if( b != 0 ) return b;

	for( m = 0; m < 11; m++ )
	{
		if( !Q_strnicmp( &date[0], mon[m], 3 ))
			break;
		d += mond[m];
	}

	d += Q_atoi( &date[4] ) - 1;
	y = Q_atoi( &date[7] ) - 1900;
	b = d + (int)((y - 1) * 365.25f );

	if((( y % 4 ) == 0 ) && m > 1 )
	{
		b += 1;
	}
	//b -= 38752; // Feb 13 2007
	b -= 41728; // Apr 1 2015. Date of first release of crossplatform Xash3D

	return b;
#else
	return 500; // Aug 13 2016
#endif
}
Ejemplo n.º 7
0
void CBaseButton :: KeyValue( KeyValueData *pkvd )
{
	if( FStrEq( pkvd->szKeyName, "locked_sound" ))
	{
		m_iLockedSound = ALLOC_STRING( pkvd->szValue );
		pkvd->fHandled = TRUE;
	}
	else if( FStrEq( pkvd->szKeyName, "locked_sentence" ))
	{
		m_bLockedSentence = Q_atoi( pkvd->szValue );
		pkvd->fHandled = TRUE;
	}
	else if( FStrEq( pkvd->szKeyName, "unlocked_sound" ))
	{
		m_iUnlockedSound = ALLOC_STRING( pkvd->szValue );
		pkvd->fHandled = TRUE;
	}
	else if( FStrEq( pkvd->szKeyName, "unlocked_sentence" ))
	{
		m_bUnlockedSentence = Q_atoi( pkvd->szValue );
		pkvd->fHandled = TRUE;
	}
	else if( FStrEq( pkvd->szKeyName, "sounds" ))
	{
		m_sounds = ALLOC_STRING( pkvd->szValue );
		pkvd->fHandled = TRUE;
	}
	else CBaseToggle::KeyValue( pkvd );
}
Ejemplo n.º 8
0
void OnChange_vid_wideaspect (cvar_t *var, char *string, qbool *cancel) 
{
	extern float nonwidefov;
	extern int nonwideconheight;
	extern cvar_t scr_fov, r_conheight;

	if ( (Q_atoi(string) == vid_wideaspect.value) || (Q_atoi(string) > 1)  || (Q_atoi(string) < 0))
	{
		*cancel = true;
		return;
	}

	Cvar_Set (&vid_wideaspect, string);

	if(!host_everything_loaded)
		return;

	if (nonwidefov != 0 && nonwideconheight != 0)
	{
		if (vid_wideaspect.integer == 0)
		{
			scr_fov.OnChange(&scr_fov, Q_ftos(nonwidefov), cancel);
			r_conheight.OnChange(&r_conheight, Q_ftos(nonwideconheight), cancel);

		}
		else
		{
			scr_fov.OnChange(&scr_fov, Q_ftos(scr_fov.value), cancel);
			r_conheight.OnChange(&r_conheight, Q_ftos(r_conheight.value), cancel);
		}
	}
}
Ejemplo n.º 9
0
// Cache user-entity-field values until spawn is called.
void CBaseButton::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd)
{
	if (FStrEq(pkvd->szKeyName, "changetarget"))
	{
		m_strChangeTarget = ALLOC_STRING(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "locked_sound"))
	{
		m_bLockedSound = Q_atoi(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "locked_sentence"))
	{
		m_bLockedSentence = Q_atoi(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "unlocked_sound"))
	{
		m_bUnlockedSound = Q_atoi(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "unlocked_sentence"))
	{
		m_bUnlockedSentence = Q_atoi(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "sounds"))
	{
		m_sounds = Q_atoi(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else
		CBaseToggle::KeyValue(pkvd);
}
Ejemplo n.º 10
0
/* <f6d87> ../cstrike/dlls/mortar.cpp:71 */
void CFuncMortarField::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd)
{
	if (FStrEq(pkvd->szKeyName, "m_iszXController"))
	{
		m_iszXController = ALLOC_STRING(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "m_iszYController"))
	{
		m_iszYController = ALLOC_STRING(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "m_flSpread"))
	{
		m_flSpread = Q_atof(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "m_fControl"))
	{
		m_fControl = Q_atoi(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "m_iCount"))
	{
		m_iCount = Q_atoi(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
}
Ejemplo n.º 11
0
void OnChange_vid_wideaspect (cvar_t *var, char *string, qbool *cancel) 
{
	// FIXME conheight
	extern int nonwideconheight;
	extern cvar_t r_conheight;

	if ( (Q_atoi(string) == vid_wideaspect.value) || (Q_atoi(string) > 1)  || (Q_atoi(string) < 0))
	{
		*cancel = true;
		return;
	}

	Cvar_Set (&vid_wideaspect, string);

	if(!host_everything_loaded)
		return;

	if (nonwideconheight != 0)
	{
		if (vid_wideaspect.integer == 0)
			r_conheight.OnChange(&r_conheight, Q_ftos(nonwideconheight), cancel);
		else
			r_conheight.OnChange(&r_conheight, Q_ftos(r_conheight.value), cancel);
	}
}
Ejemplo n.º 12
0
/* <4f169d> ../game_shared/bot/nav_file.cpp:811 */
void LoadLocationFile(const char *filename)
{
	char locFilename[256];
	Q_strcpy(locFilename, filename);

	char *dot = Q_strchr(locFilename, '.');
	if (dot)
	{
		Q_strcpy(dot, ".loc");

		int locDataLength;
		char *locDataFile = (char *)LOAD_FILE_FOR_ME(const_cast<char *>(locFilename), &locDataLength);
		char *locData = locDataFile;

		if (locData)
		{
			CONSOLE_ECHO("Loading legacy 'location file' '%s'\n", locFilename);

			// read directory
			locData = MP_COM_Parse(locData);
			int dirSize = Q_atoi(MP_COM_GetToken());

			if (dirSize)
			{
				std::vector<unsigned int> directory;
				directory.reserve(dirSize);

				for (int i = 0; i < dirSize; ++i)
				{
					locData = MP_COM_Parse(locData);
					directory.push_back(TheBotPhrases->NameToID(MP_COM_GetToken()));
				}

				// read places for each nav area
				unsigned int areaID, locDirIndex;
				while (true)
				{
					locData = MP_COM_Parse(locData);
					if (locData == NULL)
						break;

					areaID = Q_atoi(MP_COM_GetToken());

					locData = MP_COM_Parse(locData);
					locDirIndex = Q_atoi(MP_COM_GetToken());

					CNavArea *area = TheNavAreaGrid.GetNavAreaByID(areaID);
					unsigned int place = (locDirIndex > 0) ? directory[locDirIndex - 1] : UNDEFINED_PLACE;

					if (area)
						area->SetPlace(place);
				}
			}

			FREE_FILE(locDataFile);
		}
	}
}
Ejemplo n.º 13
0
void CFuncVehicle::KeyValue(KeyValueData *pkvd)
{
	if (FStrEq(pkvd->szKeyName, "length"))
	{
		m_length = Q_atof(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "width"))
	{
		m_width = Q_atof(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "height"))
	{
		m_height = Q_atof(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "startspeed"))
	{
		m_startSpeed = Q_atof(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "sounds"))
	{
		m_sounds = Q_atoi(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "volume"))
	{
		// rounding values to integer
		m_flVolume = Q_atoi(pkvd->szValue);
		m_flVolume *= 0.1f;

		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "bank"))
	{
		m_flBank = Q_atof(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "acceleration"))
	{
		m_acceleration = Q_atoi(pkvd->szValue);

		if (m_acceleration < 1)
			m_acceleration = 1;

		else if (m_acceleration > 10)
			m_acceleration = 10;

		pkvd->fHandled = TRUE;
	}
	else
	{
		CBaseEntity::KeyValue(pkvd);
	}
}
Ejemplo n.º 14
0
static void conres_changed_callback (cvar_t *var, char *string, qbool *cancel)
{
	if (var == &r_conwidth)
		Cvar_SetValue(&r_conwidth, Q_atoi(string));
	else
		Cvar_SetValue(&r_conheight, Q_atoi(string));

	VID_UpdateConRes();
	*cancel = true;
}
Ejemplo n.º 15
0
bool C_PhysPropClientside::KeyValue( const char *szKeyName, const char *szValue )
{
	if (FStrEq(szKeyName, "physdamagescale"))
	{
		m_impactEnergyScale = atof(szValue);
	}
	else if ( FStrEq(szKeyName, "health") )
	{
		m_iHealth = Q_atoi(szValue);
	}
	else if (FStrEq(szKeyName, "spawnflags"))
	{
		m_spawnflags = Q_atoi(szValue);
	}
	else if (FStrEq(szKeyName, "model"))
	{
		SetModelName( AllocPooledString( szValue ) );
	}
	else if (FStrEq(szKeyName, "fademaxdist"))
	{
		m_fadeMaxDist = Q_atof(szValue);
	}
	else if (FStrEq(szKeyName, "fademindist"))
	{
		m_fadeMinDist = Q_atof(szValue);
	}
	else if (FStrEq(szKeyName, "fadescale"))
	{
		m_flFadeScale = Q_atof(szValue);
	}
	else if (FStrEq(szKeyName, "inertiaScale"))
	{
		m_inertiaScale = Q_atof(szValue);
	}
	else if (FStrEq(szKeyName, "skin"))
	{
		m_nSkin  = Q_atoi(szValue);
	}
	else if (FStrEq(szKeyName, "physicsmode"))
	{
		m_iPhysicsMode = Q_atoi(szValue);
	}

	else
	{
		if ( !BaseClass::KeyValue( szKeyName, szValue ) )
		{
			// key hasn't been handled
			return false;
		}
	}

	return true;
}
Ejemplo n.º 16
0
void CBaseDoor::KeyValue( KeyValueData *pkvd )
{
	if( FStrEq( pkvd->szKeyName, "movesnd" ))
	{
		m_iMoveSnd = ALLOC_STRING( pkvd->szValue );
		pkvd->fHandled = TRUE;
	}
	else if( FStrEq( pkvd->szKeyName, "stopsnd" ))
	{
		m_iStopSnd = ALLOC_STRING(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if( FStrEq( pkvd->szKeyName, "healthvalue" ))
	{
		m_bHealthValue = Q_atoi( pkvd->szValue );
		pkvd->fHandled = TRUE;
	}
	else if( FStrEq( pkvd->szKeyName, "locked_sound" ))
	{
		m_iLockedSound = ALLOC_STRING( pkvd->szValue );
		pkvd->fHandled = TRUE;
	}
	else if( FStrEq( pkvd->szKeyName, "locked_sentence" ))
	{
		m_bLockedSentence = Q_atoi( pkvd->szValue );
		pkvd->fHandled = TRUE;
	}
	else if( FStrEq( pkvd->szKeyName, "unlocked_sound" ))
	{
		m_iUnlockedSound = ALLOC_STRING( pkvd->szValue );
		pkvd->fHandled = TRUE;
	}
	else if( FStrEq( pkvd->szKeyName, "unlocked_sentence" ))
	{
		m_bUnlockedSentence = Q_atoi( pkvd->szValue );
		pkvd->fHandled = TRUE;
	}
	else if( FStrEq( pkvd->szKeyName, "WaveHeight" ))
	{
		pev->scale = Q_atof( pkvd->szValue ) * (1.0f / 8.0f);
		pkvd->fHandled = TRUE;
	}
	else if( FStrEq( pkvd->szKeyName, "chaintarget" ))
	{
		m_iChainTarget = ALLOC_STRING( pkvd->szValue );
		pkvd->fHandled = TRUE;
	}
	else BaseClass :: KeyValue( pkvd );
}
Ejemplo n.º 17
0
static void conres_changed_callback (cvar_t *var, char *string, qbool *cancel)
{
	if (var == &r_conwidth) {
		Cvar_SetValue(&r_conwidth, Q_atoi(string));
	} else if (var == &r_conheight) {
		Cvar_SetValue(&r_conheight, Q_atoi(string));
	} else if (var == &r_conscale) {
		Cvar_SetValue(&r_conscale, Q_atof(string));
	} else {
		Com_Printf("Called with unknown variable: %s\n", var->name ? var->name : "unknown");
	}

	VID_UpdateConRes();
	*cancel = true;
}
Ejemplo n.º 18
0
static void NET_Port_f (void)
{
	int 	n;

	if (Cmd_Argc () != 2)
	{
		Con_Printf ("\"port\" is \"%u\"\n", net_hostport);
		return;
	}

	n = Q_atoi(Cmd_Argv(1));
	if (n < 1 || n > 65534)
	{
		Con_Printf ("Bad value, must be between 1 and 65534\n");
		return;
	}

	DEFAULTnet_hostport = n;
	net_hostport = n;

	if (listening)
	{
		// force a change to the new port
		Cbuf_AddText ("listen 0\n");
		Cbuf_AddText ("listen 1\n");
	}
}
Ejemplo n.º 19
0
int Player_GetSlot(char *arg) 
{
	int response;

	// Try getting the slot by name or id.
	if ((response = Player_StringtoSlot(arg)) >= 0 )
		//|| response == PLAYER_ID_NOMATCH)
	{
		return response;
	}

	// We didn't find any player or ID that matched
	// so we'll try treating it as the players
	// sorted position.
	if (arg[0] != '#')
	{
		return response;
	}
	
	if ((response = Player_NumtoSlot(Q_atoi(arg + 1))) >= 0)
	{
		return response;
	}

	return PLAYER_NUM_NOMATCH;
}
Ejemplo n.º 20
0
/// \brief converts "255 255 0 128" to (255, 255, 0, 128) array and saves it to rgb output argument
/// \param[in] s string in "R G B A" format
/// \param[out] rgb array of 4 bytes
int StringToRGB_W(char *s, byte *rgb)
{
	int i;
	char buf[20]; // "255 255 255 255" - the longest possible string
	char *result;
	rgb[0] = rgb[1] = rgb[2] = rgb[3] = 255;

	strlcpy(buf, s, sizeof(buf));
	result = strtok(buf, " ");

	for (i = 0; i < 4 && result; i++, result = strtok(NULL, " "))
	{
		rgb[i] = (byte) Q_atoi(result);
	}
	
	#ifdef GLQUAKE
	// TODO: Ok to do this in software also?
	// Use normal quake pallete if not all arguments where given.
	if (i < 3)
	{
		byte *col = (byte *) &d_8to24table[rgb[0]];
		rgb[0] = col[0];
		rgb[1] = col[1];
		rgb[2] = col[2];
	}
	#endif

	return i;
}
Ejemplo n.º 21
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : playerIndex - 
//          ping - 
//          packetloss - 
//-----------------------------------------------------------------------------
void UTIL_GetPlayerConnectionInfo( int playerIndex, int& ping, int &packetloss )
{
    edict_t *pEntity = pAdminOP.GetEntityList()+playerIndex;
    CBasePlayer *player =  (CBasePlayer *)VFuncs::Instance(pEntity);

    INetChannelInfo *nci = engine->GetPlayerNetInfo(playerIndex);

    if ( nci && player && pAdminOP.pAOPPlayers[playerIndex-1].NotBot() )
    {
        float latency = nci->GetAvgLatency( FLOW_OUTGOING ); // in seconds
        
        // that should be the correct latency, we assume that cmdrate is higher 
        // then updaterate, what is the case for default settings
        const char * szCmdRate = engine->GetClientConVarValue( playerIndex, "cl_cmdrate" );
        
        int nCmdRate = max( 1, Q_atoi( szCmdRate ) );
        latency -= (0.5f/nCmdRate) + TICKS_TO_TIME( 1.0f ); // correct latency

        // in GoldSrc we had a different, not fixed tickrate. so we have to adjust
        // Source pings by half a tick to match the old GoldSrc pings.
        latency -= TICKS_TO_TIME( 0.5f );

        ping = latency * 1000.0f; // as msecs
        ping = clamp( ping, 5, 1000 ); // set bounds, dont show pings under 5 msecs
        
        packetloss = 100.0f * nci->GetAvgLoss( FLOW_INCOMING ); // loss in percentage
        packetloss = clamp( packetloss, 0, 100 );
    }
    else
    {
        ping = 0;
        packetloss = 0;
    }
}
Ejemplo n.º 22
0
void PR2_Init(void)
{
	int p;
	int usedll;
	Cvar_Register(&sv_progtype);
	Cvar_Register(&sv_progsname);
#ifdef WITH_NQPROGS
	Cvar_Register(&sv_forcenqprogs);
#endif
#ifdef QVM_PROFILE
	Cvar_Register(&sv_enableprofile);
#endif

	p = COM_CheckParm ("-progtype");

	if (p && p < COM_Argc())
	{
		usedll = Q_atoi(COM_Argv(p + 1));

		if (usedll > 2)
			usedll = VM_NONE;
		Cvar_SetValue(&sv_progtype,usedll);
	}

	Cmd_AddCommand ("edict", ED2_PrintEdict_f);
	Cmd_AddCommand ("edicts", ED2_PrintEdicts);
	Cmd_AddCommand ("edictcount", ED_Count);
	Cmd_AddCommand ("profile", PR2_Profile_f);
	Cmd_AddCommand ("mod", PR2_GameConsoleCommand);

	memset(pr_newstrtbl, 0, sizeof(pr_newstrtbl));
}
Ejemplo n.º 23
0
void Sys_InitMemory(void)
{
	int i;

	i = COM_CheckParm("-heapsize");
	if (i && i < com_argc - 1)
		host_parms.memsize = Q_atoi(com_argv[i + 1]) * 1024;

	if (host_parms.memsize < MINIMUM_WIN_MEMORY)
	{
#ifdef _WIN32
		MEMORYSTATUS lpBuffer;
		lpBuffer.dwLength = sizeof(MEMORYSTATUS);
		GlobalMemoryStatus(&lpBuffer);

		if (lpBuffer.dwTotalPhys)
		{
			if (lpBuffer.dwTotalPhys < FIFTEEN_MB)
				Sys_Error("%s: Available memory less than 15MB!!! %i", __func__, host_parms.memsize);

			host_parms.memsize = (int)(lpBuffer.dwTotalPhys >> 1);
			if (host_parms.memsize < MINIMUM_WIN_MEMORY)
				host_parms.memsize = MINIMUM_WIN_MEMORY;
		}
		else
Ejemplo n.º 24
0
/* <d2b97> ../engine/net_ws.c:2259 */
void MaxPlayers_f(void)
{
	if (Cmd_Argc() != 2)
	{
		Con_Printf("\"maxplayers\" is \"%u\"\n", g_psvs.maxclients);
		return;

	}
	
	if (g_psv.active)
	{
		Con_Printf("maxplayers cannot be changed while a server is running.\n");
		return;
	}


	int n = Q_atoi(Cmd_Argv(1));
	if (n < 1)
		n = 1;

	if (n > g_psvs.maxclientslimit)
	{
		n = g_psvs.maxclientslimit;
		Con_Printf("\"maxplayers\" set to \"%u\"\n", g_psvs.maxclientslimit);
	}
	g_psvs.maxclients = n;

	if (n == 1)
		Cvar_Set("deathmatch", "0");
	else
		Cvar_Set("deathmatch", "1");
}
Ejemplo n.º 25
0
Archivo: mumble.c Proyecto: jite/jquake
void Mumble_DestroyLink()
{
#ifdef _WIN32
	if (hMapObject != NULL)
	{
		CloseHandle(hMapObject);
		hMapObject = NULL;
#else // Linux && Mac
	if (lm != NULL)
	{
		munmap(lm, sizeof(struct LinkedMem));
		lm = NULL;
		
		close(shmfd);
		shmfd = -1;
#endif
		ST_Printf(PRINT_INFO,"Mumble link shut down.\n");
		return;
	}
	else
	{
		if (mumble_debug.integer)
			ST_Printf(PRINT_FAIL,"Mumble link not established, unable to shut down.\n");
	}
}

void OnChange_mumble_enabled(cvar_t *var, char *value, qbool *cancel)
{
	int mumble = Q_atoi (value);

	if (mumble)
		Mumble_CreateLink();
	else
		Mumble_DestroyLink();
}
Ejemplo n.º 26
0
/*
============
KeyDown
============
*/
void KeyDown( kbutton_t *b )
{
	char	*c;
	int	k;

	c = CMD_ARGV( 1 );

	if( c[0] )
		k = Q_atoi( c );
	else
		k = -1; // typed manually at the console for continuous down

	if( k == b->down[0] || k == b->down[1] )
		return; // repeating key
	
	if( !b->down[0] )
	{
		b->down[0] = k;
	}
	else if( !b->down[1] )
	{
		b->down[1] = k;
	}
	else
	{
		ALERT( at_aiconsole, "Three keys down for a button '%c' '%c' '%c'!\n", b->down[0], b->down[1], c );
		return;
	}
	
	if( b->state & BUTTON_DOWN ) return;	// still down
	b->state |= (BUTTON_DOWN|IMPULSE_DOWN);	// down + impulse down
}
Ejemplo n.º 27
0
void CFuncClock :: KeyValue( KeyValueData *pkvd )
{
	if( FStrEq( pkvd->szKeyName, "type" ))
	{
		switch( Q_atoi( pkvd->szValue ))
		{
		case 1:
			m_iClockType = SECONDS_PER_HOUR;
			break;
		case 2:
			m_iClockType = SECODNS_PER_DAY;
			break;
		default:
			m_iClockType = SECONDS_PER_MINUTE;
			break;
		}
		pkvd->fHandled = TRUE;
	}
	else if( FStrEq( pkvd->szKeyName, "curtime" ))
	{
		m_vecCurtime = Q_atov( pkvd->szValue );
		pkvd->fHandled = TRUE;
	}
	else if( FStrEq( pkvd->szKeyName, "event" ))
	{
		pev->netname = ALLOC_STRING( pkvd->szValue );
		pkvd->fHandled = TRUE;
	}
	else CBaseEntity::KeyValue( pkvd );
}
Ejemplo n.º 28
0
/*
================
Sys_GetMemory
================
*/
void Sys_GetMemory(void)
{
	int		j, tsize;

	j = COM_CheckParm("-mem");
	if (j)
	{
		quakeparms.memsize = (int) (Q_atof(com_argv[j+1]) * 1024 * 1024);
		quakeparms.membase = malloc (quakeparms.memsize);
	}
	else
	{
		quakeparms.membase = dos_getmaxlockedmem (&quakeparms.memsize);
	}

	fprintf(stderr, "malloc'd: %d\n", quakeparms.memsize);

	if (COM_CheckParm ("-heapsize"))
	{
		tsize = Q_atoi (com_argv[COM_CheckParm("-heapsize") + 1]) * 1024;

		if (tsize < quakeparms.memsize)
			quakeparms.memsize = tsize;
	}
}
Ejemplo n.º 29
0
cvar_t *Cvar_Create (char *name, char *string, int cvarflags)
{
	cvar_t *v;
	int key;

	if ((v = Cvar_Find(name))) {
		v->flags &= ~CVAR_TEMP;
		v->flags |= cvarflags;
		return v;
	}
	v = (cvar_t *) Q_malloc(sizeof(cvar_t));
	memset(v, 0, sizeof(cvar_t));
	// Cvar doesn't exist, so we create it
	v->next = cvar_vars;
	cvar_vars = v;

	key = Com_HashKey (name) % VAR_HASHPOOL_SIZE;
	v->hash_next = cvar_hash[key];
	cvar_hash[key] = v;

	v->name = Q_strdup(name);
	v->string = Q_strdup(string);
	v->defaultvalue = Q_strdup(string);
	v->flags = cvarflags | CVAR_USER_CREATED;
	v->value = Q_atof (v->string);
	v->integer = Q_atoi (v->string);
	StringToRGB_W(v->string, v->color);
	v->modified = true;
#ifdef WITH_TCL
	TCL_RegisterVariable (v);
#endif

	return v;
}
Ejemplo n.º 30
0
/*
===============
R_InitParticles
===============
*/
void R_InitParticles (void)
{
	int		i;

	i = COM_CheckParm ("-particles");

	if (i)
	{
		r_numparticles = (int)(Q_atoi(com_argv[i+1]));
		if (r_numparticles < ABSOLUTE_MIN_PARTICLES)
			r_numparticles = ABSOLUTE_MIN_PARTICLES;
	}
	else
	{
		r_numparticles = MAX_PARTICLES;
	}

	particles = (particle_t *)
			Hunk_AllocName (r_numparticles * sizeof(particle_t), "particles");

	Cvar_RegisterVariable (&r_particles); //johnfitz
	Cvar_SetCallback (&r_particles, R_SetParticleTexture_f);

	R_InitParticleTextures (); //johnfitz
}