Exemple #1
0
void COM_AddGameDirectory(const char *Directory)
{
    char Buffer[128];
    pack_t *PakPointer;
    

    for (int i = 0; ; i++)
    {
        sprintf_s(Buffer, 128, "%s\\pak%d.pak", Directory, i);
        PakPointer = COM_LoadPackFile(Buffer);
        if (!PakPointer)
            break;
        searchpath_t *NewPath = (searchpath_t *)malloc(sizeof(searchpath_t));
        NewPath->Pack = PakPointer;
        NewPath->Next = COM_Searchpaths;
        COM_Searchpaths = NewPath;
    }
}
Exemple #2
0
/*
==================
Host_Game_f
==================
*/
void Host_Game_f (void)
{
	int i;
	unsigned int path_id;
	searchpath_t *search = com_searchpaths;
	pack_t *pak;
	char   pakfile[MAX_OSPATH]; //FIXME: it's confusing to use this string for two different things

	if (Cmd_Argc() > 1)
	{
		if (!registered.value) //disable command for shareware quake
		{
			Con_Printf("You must have the registered version to use modified games\n");
			return;
		}

		if (strstr(Cmd_Argv(1), ".."))
		{
			Con_Printf ("Relative pathnames are not allowed.\n");
			return;
		}

		q_strlcpy (pakfile, va("%s/%s", host_parms->basedir, Cmd_Argv(1)), sizeof(pakfile));
		if (!Q_strcasecmp(pakfile, com_gamedir)) //no change
		{
			Con_Printf("\"game\" is already \"%s\"\n", COM_SkipPath(com_gamedir));
			return;
		}

		com_modified = true;

		//Kill the server
		CL_Disconnect ();
		Host_ShutdownServer(true);

		//Write config file
		Host_WriteConfiguration ();

		//Kill the extra game if it is loaded
		if (NumGames(com_searchpaths) > 1 + com_nummissionpacks)
			KillGameDir(com_searchpaths);

		q_strlcpy (com_gamedir, pakfile, sizeof(com_gamedir));

		if (Q_strcasecmp(Cmd_Argv(1), GAMENAME)) //game is not id1
		{
			// assign a path_id to this game directory
			if (com_searchpaths)
				path_id = com_searchpaths->path_id << 1;
			else	path_id = 1U;
			search = (searchpath_t *) Z_Malloc(sizeof(searchpath_t));
			search->path_id = path_id;
			q_strlcpy (search->filename, pakfile, sizeof(search->filename));
			search->next = com_searchpaths;
			com_searchpaths = search;

			//Load the paks if any are found:
			for (i = 0; ; i++)
			{
				q_snprintf (pakfile, sizeof(pakfile), "%s/pak%i.pak", com_gamedir, i);
				pak = COM_LoadPackFile (pakfile);
				if (!pak)
					break;
				search = (searchpath_t *) Z_Malloc(sizeof(searchpath_t));
				search->path_id = path_id;
				search->pack = pak;
				search->next = com_searchpaths;
				com_searchpaths = search;
			}
		}

		//clear out and reload appropriate data
		Cache_Flush ();
		if (!isDedicated)
		{
			TexMgr_NewGame ();
			Draw_NewGame ();
			R_NewGame ();
		}
		ExtraMaps_NewGame ();
		//Cbuf_InsertText ("exec quake.rc\n");

		Con_Printf("\"game\" changed to \"%s\"\n", COM_SkipPath(com_gamedir));
	}
	else //Diplay the current gamedir
		Con_Printf("\"game\" is \"%s\"\n", COM_SkipPath(com_gamedir));
}