浏览代码

Reenabled campaigns. Workaround for crash when button graphic is not available.

Michał W. Urbańczyk 15 年之前
父节点
当前提交
e301f8e048
共有 3 个文件被更改,包括 16 次插入5 次删除
  1. 12 2
      client/AdventureMapButton.cpp
  2. 2 1
      hch/CCampaignHandler.cpp
  3. 2 2
      hch/CLodHandler.cpp

+ 12 - 2
client/AdventureMapButton.cpp

@@ -51,9 +51,19 @@ void CButtonBase::show(SDL_Surface * to)
 	int img = std::min(state+bitmapOffset,int(imgs[curimg]->size()-1));
 	img = std::max(0, img);
 
+	SDL_Surface *toBlit = imgs[curimg]->image(img);
+
 	if (abs)
 	{
-		blitAt(imgs[curimg]->image(img),pos.x,pos.y,to);
+		if(toBlit)
+		{
+			blitAt(toBlit,pos.x,pos.y,to);
+		}
+		else
+		{
+			SDL_Rect r = pos;
+			SDL_FillRect(to, &r, 0x505000);
+		}
 		if(text)
 		{//using "state" instead of "state == 1" screwed up hoverable buttons with text
 			CSDL_Ext::printAt(text->text, text->x + pos.x + (state == 1), text->y + pos.y + (state == 1), text->font, text->color, to);
@@ -61,7 +71,7 @@ void CButtonBase::show(SDL_Surface * to)
 	}
 	else
 	{
-		blitAt(imgs[curimg]->image(img),pos.x+ourObj->pos.x,pos.y+ourObj->pos.y,to);
+		blitAt(toBlit,pos.x+ourObj->pos.x,pos.y+ourObj->pos.y,to);
 	}
 }
 

+ 2 - 1
hch/CCampaignHandler.cpp

@@ -53,10 +53,11 @@ std::vector<CCampaignHeader> CCampaignHandler::getCampaignHeaders(GetMode mode)
 	}
 	if (mode == ALL) //add all lod campaigns
 	{
+		ext = "#H3C";
 		for(int g=0; g<bitmaph->entries.size(); ++g)
 		{
 			const std::string & nameS = bitmaph->entries[g].nameStr;
-			if( boost::ends_with(nameS, ext) && nameS != "TOSBLK1.H3C" )
+			if( boost::ends_with(nameS, ext) && nameS != "TOSBLK1#H3C" )
 			{
 				ret.push_back( getHeader(bitmaph->entries[g].nameStr, true) );
 			}

+ 2 - 2
hch/CLodHandler.cpp

@@ -247,7 +247,7 @@ void CLodHandler::init(std::string lodFile, std::string dirName)
 		if ( dotPos < entry.nameStr.size() )
 		{
 			std::string ext = entry.nameStr.substr(dotPos);
-			if (ext == ".MSK" || ext == ".MSG")
+			if (ext == ".MSK" || ext == ".MSG" || ext == ".H3C")
 				entry.nameStr[dotPos] = '#';//this files have same name as def - rename to defName#msk
 			else
 				entry.nameStr.erase(dotPos);//filename.ext becomes filename
@@ -277,7 +277,7 @@ void CLodHandler::init(std::string lodFile, std::string dirName)
 				if ( dotPos < name.size() )
 				{
 					std::string ext = name.substr(dotPos);
-					if (ext == ".MSK" || ext == ".MSG")
+					if (ext == ".MSK" || ext == ".MSG" || ext == ".H3C")
 						name[dotPos] = '#';//this files have same name as def - rename to defName#msk
 					else
 						name.erase(dotPos);//filename.ext becomes filename