Пример #1
0
/* <ed99c> ../engine/sv_steam3.cpp:827 */
void CSteam3Client::InitClient()
{
    if (m_bLoggedOn)
        return;

    m_bLoggedOn = true;
    _unlink("steam_appid.txt");
    if (!getenv("SteamAppId"))
    {
        int nAppID = GetGameAppID();
        if (nAppID > 0)
        {
            FILE* f = fopen("steam_appid.txt", "w+");
            if (f)
            {
                fprintf(f, "%d\n", nAppID);
                fclose(f);
            }
        }
    }

    if (!SteamAPI_Init())
        Sys_Error("Failed to initalize authentication interface. Exiting...\n");

    m_bLogOnResult = false;
}
Пример #2
0
int FileSystem_SetGameDirectory(const char *pDefaultDir, const char *pGameDir)
{
	char temp[512];
	char language[256];
	const char *pchLang;

	g_pFileSystem->RemoveAllSearchPaths();
	language[0] = 0;

	if (!bLowViolenceBuild)
	{
		if (CRehldsPlatformHolder::get()->SteamApps() && GetGameAppID() == 70)
		{
			bLowViolenceBuild = CRehldsPlatformHolder::get()->SteamApps()->BIsLowViolence();
		}
	}

	pchLang = CRehldsPlatformHolder::get()->SteamApps() ? CRehldsPlatformHolder::get()->SteamApps()->GetCurrentGameLanguage() : NULL;
	Q_strncpy(language, pchLang ? pchLang : "english", ARRAYSIZE(language));
#ifdef REHLDS_CHECKS
	language[ARRAYSIZE(language) - 1] = 0;
#endif

	if (!g_bIsDedicatedServer && !IsGameSubscribed(pGameDir))
		return 0;

	CRehldsPlatformHolder::get()->SteamAPI_SetBreakpadAppID(GetGameAppID());

	bool bEnableHDPack = BEnabledHDAddon();
	bool bLanguage = (Q_strlen(language) != 0 && Q_stricmp(language, "english")) ? true : false;

	if (!pGameDir)
		pGameDir = pDefaultDir;

	if (pGameDir)
	{
		if (bLowViolenceBuild)
		{
			Q_snprintf(temp, sizeof(temp) - 1, "%s/%s_lv", GetBaseDirectory(), pGameDir);
			temp[sizeof(temp) - 1] = 0;
			COM_FixSlashes(temp);
			g_pFileSystem->AddSearchPathNoWrite(temp, "GAME");
		}
		if (BEnableAddonsFolder())
		{
			Q_snprintf(temp, sizeof(temp) - 1, "%s/%s_addon", GetBaseDirectory(), pGameDir);
			temp[sizeof(temp) - 1] = 0;
			COM_FixSlashes(temp);
			g_pFileSystem->AddSearchPathNoWrite(temp, "GAME");
		}
		if (bLanguage)
		{
			Q_snprintf(temp, sizeof(temp) - 1, "%s/%s_%s", GetBaseDirectory(), pGameDir, language);
			temp[sizeof(temp) - 1] = 0;
			COM_FixSlashes(temp);
			g_pFileSystem->AddSearchPathNoWrite(temp, "GAME");

			if (!COM_CheckParm("-steam"))
			{
				char baseDir[MAX_PATH];
				Q_strncpy(baseDir, GetBaseDirectory(), sizeof(baseDir) - 1);
				baseDir[sizeof(baseDir) - 1] = 0;
				char* tempPtr = Q_strstr(baseDir, "\\game");
				if (tempPtr)
				{
					*tempPtr = 0;
					Q_snprintf(temp, 511, "%s\\localization\\%s_%s", baseDir, pGameDir, language);
					temp[511] = 0;
					COM_FixSlashes(temp);
					g_pFileSystem->AddSearchPathNoWrite(temp, "GAME");
				}
			}
		}
		if (bEnableHDPack)
		{
			Q_snprintf(temp, sizeof(temp) - 1, "%s/%s_hd", GetBaseDirectory(), pGameDir);
			temp[sizeof(temp) - 1] = 0;
			COM_FixSlashes(temp);
			g_pFileSystem->AddSearchPathNoWrite(temp, "GAME");
		}

		Q_snprintf(temp, 511, "%s/%s", GetBaseDirectory(), pGameDir);
		temp[sizeof(temp) - 1] = 0;
		COM_FixSlashes(temp);
		g_pFileSystem->AddSearchPath(temp, "GAME");
		g_pFileSystem->AddSearchPath(temp, "GAMECONFIG");

		Q_snprintf(temp, sizeof(temp) - 1, "%s/%s_downloads", GetBaseDirectory(), pGameDir);
		temp[sizeof(temp) - 1] = 0;
		COM_FixSlashes(temp);
		g_pFileSystem->AddSearchPath(temp, "GAMEDOWNLOAD");

		CheckLiblistForFallbackDir(pGameDir, bLanguage, language, bLowViolenceBuild);
	}
	if (bLanguage)
	{
		if (bLowViolenceBuild)
		{
			Q_snprintf(temp, sizeof(temp) - 1, "%s/%s_lv", GetBaseDirectory(), pDefaultDir);
			temp[sizeof(temp) - 1] = 0;
			COM_FixSlashes(temp);
			g_pFileSystem->AddSearchPathNoWrite(temp, "DEFAULTGAME");
		}

		if (BEnableAddonsFolder())
		{
			Q_snprintf(temp, sizeof(temp) - 1, "%s/%s_addon", GetBaseDirectory(), pDefaultDir);
			temp[sizeof(temp) - 1] = 0;
			COM_FixSlashes(temp);
			g_pFileSystem->AddSearchPathNoWrite(temp, "DEFAULTGAME");
		}

		Q_snprintf(temp, sizeof(temp) - 1, "%s/%s_%s", GetBaseDirectory(), pDefaultDir, language);
		temp[sizeof(temp) - 1] = 0;
		COM_FixSlashes(temp);
		g_pFileSystem->AddSearchPathNoWrite(temp, "DEFAULTGAME");
		if (!COM_CheckParm("-steam"))
		{
			char baseDir[MAX_PATH];

			Q_strncpy(baseDir, GetBaseDirectory(), sizeof(baseDir) - 1);
			baseDir[sizeof(baseDir) - 1] = 0;
			char* tempPtr = Q_strstr(baseDir, "\\game");
			if (tempPtr)
			{
				*tempPtr = 0;
				Q_snprintf(temp, sizeof(temp) - 1, "%s\\localization\\%s_%s", baseDir, pDefaultDir, language);
				temp[sizeof(temp) - 1] = 0;
				COM_FixSlashes(temp);
				g_pFileSystem->AddSearchPathNoWrite(temp, "DEFAULTGAME");
			}
		}
	}
	if (bEnableHDPack)
	{
		Q_snprintf(temp, sizeof(temp) - 1, "%s/%s_hd", GetBaseDirectory(), pDefaultDir);
		temp[sizeof(temp) - 1] = 0;
		COM_FixSlashes(temp);
		g_pFileSystem->AddSearchPathNoWrite(temp, "DEFAULTGAME");
	}

	Q_snprintf(temp, sizeof(temp) - 1, "%s", GetBaseDirectory());
	temp[sizeof(temp) - 1] = 0;
	COM_FixSlashes(temp);
	g_pFileSystem->AddSearchPath(temp, "BASE");

	Q_snprintf(temp, sizeof(temp) - 1, "%s/%s", GetBaseDirectory(), pDefaultDir);
	temp[sizeof(temp) - 1] = 0;
	COM_FixSlashes(temp);
	g_pFileSystem->AddSearchPathNoWrite(temp, "DEFAULTGAME");

	Q_snprintf(temp, sizeof(temp) - 1, "%s/platform", GetBaseDirectory());
	temp[sizeof(temp) - 1] = 0;
	COM_FixSlashes(temp);
	g_pFileSystem->AddSearchPath(temp, "PLATFORM");

	return 1;

}
Пример #3
0
/* <ee234> ../engine/sv_steam3.cpp:375 */
void CSteam3Server::Activate()
{
    bool bLanOnly;
    int argSteamPort;
    EServerMode eSMode;
    int gamePort;
    char gamedir[MAX_PATH];
    int usSteamPort;
    uint32 unIP;

    if (m_bLoggedOn)
    {
        bLanOnly = sv_lan.value != 0.0;
        if (this->m_bLanOnly != bLanOnly)
        {
            m_bLanOnly = bLanOnly;
            m_bWantToBeSecure = !COM_CheckParm("-insecure") && !bLanOnly;
        }
    }
    else
    {
        m_bLoggedOn = 1;
        unIP = 0;
        usSteamPort = 26900;
        argSteamPort = COM_CheckParm("-sport");
        if (argSteamPort > 0)
            usSteamPort = atoi(com_argv[argSteamPort + 1]);
        eSMode = eServerModeAuthenticationAndSecure;
        if (net_local_adr.type == NA_IP)
            unIP = ntohl(*(u_long *)&net_local_adr.ip[0]);

        m_bLanOnly = sv_lan.value > 0.0;
        m_bWantToBeSecure = !COM_CheckParm("-insecure") && !m_bLanOnly;
        COM_FileBase(com_gamedir, gamedir);

        if (!m_bWantToBeSecure)
            eSMode = eServerModeAuthentication;

        if (m_bLanOnly)
            eSMode = eServerModeNoAuthentication;

        gamePort = (int)iphostport.value;
        if (gamePort == 0)
            gamePort = (int)hostport.value;

        int nAppId = GetGameAppID();
        if (nAppId > 0 && g_pcls.state == ca_dedicated)
        {
            FILE* f = fopen("steam_appid.txt", "w+");
            if (f)
            {
                fprintf(f, "%d\n", nAppId);
                fclose(f);
            }
        }

        if (!CRehldsPlatformHolder::get()->SteamGameServer_Init(unIP, usSteamPort, gamePort, 0xFFFFu, eSMode, gpszVersionString))
            Sys_Error("Unable to initialize Steam.");

        CRehldsPlatformHolder::get()->SteamGameServer()->SetProduct(gpszProductString);
        CRehldsPlatformHolder::get()->SteamGameServer()->SetModDir(gamedir);
        CRehldsPlatformHolder::get()->SteamGameServer()->SetDedicatedServer(g_pcls.state == ca_dedicated);
        CRehldsPlatformHolder::get()->SteamGameServer()->SetGameDescription(gEntityInterface.pfnGetGameDescription());
        CRehldsPlatformHolder::get()->SteamGameServer()->LogOnAnonymous();
        m_bLogOnResult = false;

        if (COM_CheckParm("-nomaster"))
        {
            Con_Printf("Master server communication disabled.\n");
            gfNoMasterServer = TRUE;
        }
        else
        {
            if (!gfNoMasterServer && g_psvs.maxclients > 1)
            {
                CRehldsPlatformHolder::get()->SteamGameServer()->EnableHeartbeats(true);
                double fMasterHeartbeatTimeout = 200.0;
                if (!Q_strcmp(gamedir, "dmc"))
                    fMasterHeartbeatTimeout = 150.0;
                if (!Q_strcmp(gamedir, "tfc"))
                    fMasterHeartbeatTimeout = 400.0;
                if (!Q_strcmp(gamedir, "cstrike"))
                    fMasterHeartbeatTimeout = 400.0;

                CRehldsPlatformHolder::get()->SteamGameServer()->SetHeartbeatInterval((int)fMasterHeartbeatTimeout);
                CSteam3Server::NotifyOfLevelChange(true);
            }
        }
    }
}