浏览代码

- game won't crash on missing dwellings (instead random one will generated)
- added disabled code that can be used to fix buildings blit order
- minor fixes

Ivan Savenko 13 年之前
父节点
当前提交
db10f512d5
共有 4 个文件被更改,包括 38 次插入3 次删除
  1. 29 0
      client/CCastleInterface.cpp
  2. 1 0
      client/GUIClasses.cpp
  3. 5 0
      lib/CGameState.cpp
  4. 3 3
      server/CGameHandler.cpp

+ 29 - 0
client/CCastleInterface.cpp

@@ -1141,6 +1141,35 @@ void CCastleInterface::keyPressed( const SDL_KeyboardEvent & key )
 
 	switch(key.keysym.sym)
 	{
+#if 0 // code that can be used to fix blit order in towns using +/- keys. Quite ugly but works
+	case SDLK_KP_PLUS :
+		if (builds->selectedBuilding)
+		{
+			OBJ_CONSTRUCTION_CAPTURING_ALL;
+			CStructure * str = const_cast<CStructure *>(builds->selectedBuilding->str);
+			str->pos.z++;
+			delete builds;
+			builds = new CCastleBuildings(town);
+
+			BOOST_FOREACH(const CStructure * str, town->town->clientInfo.structures)
+				tlog1 << int(str->building->bid) << " -> " << int(str->pos.z) << "\n";
+		}
+		break;
+	case SDLK_KP_MINUS:
+		if (builds->selectedBuilding)
+		{
+			OBJ_CONSTRUCTION_CAPTURING_ALL;
+			CStructure * str = const_cast<CStructure *>(builds->selectedBuilding->str);
+			str->pos.z--;
+			delete builds;
+			builds = new CCastleBuildings(town);
+
+			BOOST_FOREACH(const CStructure * str, town->town->clientInfo.structures)
+				tlog1 << int(str->building->bid) << " -> " << int(str->pos.z) << "\n";
+
+		}
+		break;
+#endif
 	case SDLK_UP:
 		townlist->selectPrev();
 		break;

+ 1 - 0
client/GUIClasses.cpp

@@ -1386,6 +1386,7 @@ void CRecruitmentWindow::select(CCreatureCard *card)
 		totalCostValue->createItems(card->creature->cost);
 
 		costPerTroopValue->set(card->creature->cost);
+		totalCostValue->set(card->creature->cost * maxAmount);
 
 		//Recruit %s
 		title->setTxt(boost::str(boost::format(CGI->generaltexth->tcommands[21]) % card->creature->namePl));

+ 5 - 0
lib/CGameState.cpp

@@ -636,7 +636,12 @@ std::pair<int,int> CGameState::pickObject (CGObjectInstance *obj)
 					result = std::pair<int,int>(17, iter.first);
 
 			if (result.first == -1)
+			{
 				tlog0 << "Error: failed to find creature for dwelling of "<< int(faction) << " of level " << int(level) << "\n";
+				auto iter = VLC->objh->cregens.begin();
+				std::advance(iter, ran() % VLC->objh->cregens.size() );
+				result = std::pair<int, int>(17, iter->first);
+			}
 
 			return result;
 		}

+ 3 - 3
server/CGameHandler.cpp

@@ -2506,7 +2506,7 @@ bool CGameHandler::buildStructure( si32 tid, si32 bid, bool force /*=false*/ )
 	FoWChange fw;
 	fw.player = t->tempOwner;
 	fw.mode = 1;
-	getTilesInRange(fw.tiles,t->pos,t->getSightRadious(),t->tempOwner,1);
+	t->getSightTiles(fw.tiles);
 	sendAndApply(&fw);
 
 	if (!force)
@@ -3815,9 +3815,9 @@ void CGameHandler::playerMessage( ui8 player, const std::string &message )
 		SetResources sr;
 		sr.player = player;
 		sr.res = gs->getPlayer(player)->resources;
-		for(int i=0;i<7;i++)
+		for(int i=0;i<Res::GOLD;i++)
 			sr.res[i] += 100;
-		sr.res[6] += 19900;
+		sr.res[Res::GOLD] += 100000; //100k
 		sendAndApply(&sr);
 	}
 	else if(message == "vcmieagles") //reveal FoW