loadBitmapFromDir parameter question


#1

SDL_Surface * BitmapHandler::loadBitmapFromDir(std::string path, std::string fname, bool setKey)

what is setKey used for?

[code]
SDL_Surface * BitmapHandler::loadBitmapFromDir(std::string path, std::string fname, bool setKey)
{
if(!fname.size())
{
logGlobal->warnStream() << “Call to loadBitmap with void fname!”;
return nullptr;
}
if (!CResourceHandler::get()->existsResource(ResourceID(path + fname, EResType::IMAGE)))
{
return nullptr;
}

SDL_Surface * ret=nullptr;

auto readFile = CResourceHandler::get()->load(ResourceID(path + fname, EResType::IMAGE))->readAll();

if (isPCX(readFile.first.get()))
{//H3-style PCX
	ret = loadH3PCX(readFile.first.get(), readFile.second);
	if (ret)
	{
		if(ret->format->BytesPerPixel == 1  &&  setKey)
		{
			CSDL_Ext::setColorKey(ret,ret->format->palette->colors[0]);
		}
	}
	else
	{
		logGlobal->errorStream()<<"Failed to open "<<fname<<" as H3 PCX!";
		return nullptr;
	}
}
else
{ //loading via SDL_Image
	ret = IMG_Load_RW(
	          //create SDL_RW with our data (will be deleted by SDL)
	          SDL_RWFromConstMem((void*)readFile.first.get(), readFile.second),
	          1); // mark it for auto-deleting
	if (ret)
	{
		if (ret->format->palette)
		{
			//set correct value for alpha\unused channel
			for (int i=0; i < ret->format->palette->ncolors; i++)
				ret->format->palette->colors*.a = SDL_ALPHA_OPAQUE;
		}
	}
	else
	{
		logGlobal->errorStream() << "Failed to open " << fname << " via SDL_Image";
		logGlobal->errorStream() << "Reason: " << IMG_GetError();
		return nullptr;
	}
}

// When modifying anything here please check two use cases:
// 1) Vampire mansion in Necropolis (not 1st color is transparent)
// 2) Battle background when fighting on grass/dirt, topmost sky part (NO transparent color)
// 3) New objects that may use 24-bit images for icons (e.g. witchking arts)
if (ret->format->palette)
{
	CSDL_Ext::setDefaultColorKeyPresize(ret);
}
else if (ret->format->Amask)
{
	SDL_SetSurfaceBlendMode(ret, SDL_BLENDMODE_BLEND);
}
else // always set
{
	CSDL_Ext::setDefaultColorKey(ret);
}
return ret;

}
[/code]*


#2

I think this parameter is useless now.