示例#1
0
/* Load a team colour mask texturepage into memory */
static bool dataTexPageTCMaskLoad(const char *fileName, void **ppData)
{
	char texpage[PATH_MAX] = {'\0'};

	// This hackery is needed, because fileName will include the directory name, whilst the LastResourceFilename will not, and we need a short name to identify the texpage
	sstrcpy(texpage, GetLastResourceFilename());

	// Check if a corresponding texpage exists, exit if no
	pie_MakeTexPageName(texpage);
	ASSERT_OR_RETURN(false, resPresent(DT_TEXPAGE, texpage), "Corresponding texpage %s doesn't exists!", texpage);

	pie_MakeTexPageTCMaskName(texpage);
		
	if (!dataImageLoad(fileName, ppData))
	{
		return false;
	}

	// see if this texture page has already been loaded
	if (resPresent(DT_TCMASK, texpage))
	{
		// replace the old texture page with the new one
		debug(LOG_TEXTURE, "replacing %s with new tcmask %s", texpage, fileName);
		pie_ReplaceTexPage((iV_Image *)*ppData, texpage, getTextureSize(), false);
	}
	else
	{
		debug(LOG_TEXTURE, "adding page %s with tcmask %s", texpage, fileName);
		SetLastResourceFilename(texpage);
		pie_AddTexPage((iV_Image *)*ppData, texpage, 0, getTextureSize(), false);
	}

	return true;
}
示例#2
0
文件: data.c 项目: blezek/warzone2100
/* Load a texturepage into memory */
static bool dataTexPageLoad(const char *fileName, void **ppData)
{
	char texpage[PATH_MAX] = {'\0'};

	// This hackery is needed, because fileName will include the directory name, whilst the LastResourceFilename will not, and we need a short name to identify the texpage
	sstrcpy(texpage, GetLastResourceFilename());

	pie_MakeTexPageName(texpage);
	if (!dataImageLoad(fileName, ppData))
	{
		return false;
	}

	// see if this texture page has already been loaded
	if (resPresent(DT_TEXPAGE, texpage))
	{
		// replace the old texture page with the new one
		debug(LOG_TEXTURE, "replacing %s with new texture %s", texpage, fileName);
		(void) pie_ReplaceTexPage(*ppData, texpage, getTextureSize(), true);
	}
	else
	{
		debug(LOG_TEXTURE, "adding page %s with texture %s", texpage, fileName);
		SetLastResourceFilename(texpage);
		(void) pie_AddTexPage(*ppData, texpage, 0, getTextureSize(), true);
	}

	return true;
}