Ejemplo n.º 1
0
boolean W_RemoveFile(char *filename)
{
	int     idx = W_RecordGetIdx(filename);
	filerecord_t *rec;

	if(idx == -1)
		return false;			// No such file loaded.
	rec = records + idx;

	// We must remove all the data of this file from the lump storage
	// (lumpinfo + lumpcache).
	W_RemoveLumpsWithHandle(rec->handle);

	// Resize the lump storage to match numlumps.
	W_ResizeLumpStorage(numlumps);

	// Close the file, we don't need it any more.
	F_Close(rec->handle);

	// Destroy the file record.
	W_RecordDestroy(idx);

	PrimaryLumpInfo = lumpinfo;
	PrimaryLumpCache = lumpcache;
	PrimaryNumLumps = numlumps;

	// Success!
	return true;
}
Ejemplo n.º 2
0
void AboutOk(void)
/*
	Procedure called when the OK button of About me is clicked.
*/
{
  OBJECT	*Arbre;
  
  rsrc_gaddr(R_TREE,FINFO,&Arbre);				/* Tree address */
  Arbre[FUNSHIP].ob_flags |= HIDETREE;				/* Hide photo */
  F_Close(FINFO);
}
Ejemplo n.º 3
0
/*
 * Shuts down the zip file database and frees all resources.
 */
void Zip_Shutdown(void)
{
	package_t *pack, *next;
	int     i;

	// Close package files and free the nodes.
	for(pack = zipRoot; pack; pack = next)
	{
		next = pack->next;
		if(pack->file)
			F_Close(pack->file);
		free(pack);
	}

	// Free the file directory.
	for(i = 0; i < zipNumFiles; i++)
		free(zipFiles[i].name);
	free(zipFiles);

	zipRoot = NULL;
	zipFiles = NULL;
	zipNumFiles = 0;
	zipAllocatedFiles = 0;
}
Ejemplo n.º 4
0
boolean W_AddFile(const char *filename, boolean allowDuplicate)
{
	char    alterFileName[256];
	wadinfo_t header;
	DFILE  *handle;
	unsigned int length;
	filelump_t *fileinfo, singleinfo;
	filelump_t *freeFileInfo;
	filerecord_t *rec;
	const char *extension;

	// Filename given?
	if(!filename || !filename[0])
		return true;

	if((handle = F_Open(filename, "rb")) == NULL)
	{
		// Didn't find file. Try reading from the data path.
		R_PrependDataPath(filename, alterFileName);
		if((handle = F_Open(alterFileName, "rb")) == NULL)
		{
			Con_Message("W_AddFile: ERROR: %s not found!\n", filename);
			return false;
		}
		// We'll use this instead.
		filename = alterFileName;
	}

	// Do not read files twice.
	if(!allowDuplicate && !M_CheckFileID(filename))
	{
		F_Close(handle);		// The file is not used.
		return false;
	}

	Con_Message("W_AddFile: %s\n", M_Pretty(filename));

	// Determine the file name extension.
	extension = strrchr(filename, '.');
	if(!extension)
		extension = "";
	else
		extension++;			// Move to point after the dot.

	// Is it a zip/pk3 package?
	if(!stricmp(extension, "zip") || !stricmp(extension, "pk3"))
	{
		return Zip_Open(filename, handle);
	}

	// Get a new file record.
	rec = W_RecordNew();
	strcpy(rec->filename, filename);
	convertSlashes(rec->filename);
	rec->handle = handle;

	// If we're not loading for startup, flag the record to be a Runtime one.
	if(!loadingForStartup)
		rec->flags = FRF_RUNTIME;

	if(stricmp(extension, "wad") && stricmp(extension, "gwa"))
	{
		// Single lump file.
		fileinfo = &singleinfo;
		freeFileInfo = NULL;
		singleinfo.filepos = 0;
		singleinfo.size = F_Length(handle);
		M_ExtractFileBase(filename, singleinfo.name);
		rec->numlumps = 1;
	}
	else
	{
		// WAD file.
		F_Read(&header, sizeof(header), handle);
		if(!strncmp(header.identification, "JWAD", 4))
		{
			// This is treated like an IWAD, but we won't set the
			// iwadLoaded flag.
			rec->iwad = true;
		}
		else if(strncmp(header.identification, "IWAD", 4))
		{
			if(strncmp(header.identification, "PWAD", 4))
			{					// Bad file id
				Con_Error("Wad file %s doesn't have IWAD or PWAD id\n",
						  filename);
			}
		}
		else
		{
			// Found an IWAD.
			iwadLoaded = true;
			if(!stricmp(extension, "wad"))
				rec->iwad = true;
		}
		header.numlumps = LONG(header.numlumps);
		header.infotableofs = LONG(header.infotableofs);
		length = header.numlumps * sizeof(filelump_t);
		if(!(fileinfo = malloc(length)))
		{
			Con_Error("W_AddFile: fileinfo malloc failed\n");
		}
		freeFileInfo = fileinfo;
		F_Seek(handle, header.infotableofs, SEEK_SET);
		F_Read(fileinfo, length, handle);
		rec->numlumps = header.numlumps;
	}

	// Insert the lumps to lumpinfo, into their rightful places.
	W_InsertLumps(fileinfo, rec);

	if(freeFileInfo)
		free(freeFileInfo);

	PrimaryLumpInfo = lumpinfo;
	PrimaryLumpCache = lumpcache;
	PrimaryNumLumps = numlumps;

	// Print the 'CRC' number of the IWAD, so it can be identified.
	if(rec->iwad)
		Con_Message("  IWAD identification: %08x\n",
					W_CRCNumberForRecord(rec - records));

	// glBSP: Also load a possible GWA.
	if(!stricmp(extension, "wad"))
	{
		char    buff[256];

		strcpy(buff, filename);
		strcpy(buff + strlen(buff) - 3, "gwa");

		// If GL data exists, load it.
		if(F_Access(buff))
		{
			W_AddFile(buff, allowDuplicate);
		}
	}

	return true;
}