Sfoglia il codice sorgente

Improvements within garrisons/town.

Michał W. Urbańczyk 18 anni fa
parent
commit
70bf415eb6
5 ha cambiato i file con 47 aggiunte e 8 eliminazioni
  1. 3 0
      CCallback.cpp
  2. 2 2
      CCastleInterface.cpp
  3. 10 6
      CPlayerInterface.cpp
  4. 1 0
      config/buildings2.txt
  5. 31 0
      hch/CTownHandler.cpp

+ 3 - 0
CCallback.cpp

@@ -389,6 +389,9 @@ int CCallback::swapCreatures(const CCreatureSet *s1, const CCreatureSet *s2, int
 			CCreature * pom = S2->slots[p2].first;
 			S2->slots[p2].first = S1->slots[p1].first;
 			S1->slots[p1].first = pom;
+			int pom2 = S2->slots[p2].second;
+			S2->slots[p2].second = S1->slots[p1].second;
+			S1->slots[p1].second = pom2;
 		}
 	}
 	return -1;

+ 2 - 2
CCastleInterface.cpp

@@ -173,7 +173,7 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, bool Activate)
 	}
 
 	std::sort(buildings.begin(),buildings.end(),srthlp);
-	garr = new CGarrisonInt(305,387,4,32,townInt,241,13,&town->garrison,(town->garrisonHero)?(&town->garrisonHero->army):(NULL));
+	garr = new CGarrisonInt(305,387,4,32,townInt,243,13,&town->garrison,(town->garrisonHero)?(&town->garrisonHero->army):(NULL));
 
 	if(Activate)
 	{
@@ -197,7 +197,7 @@ CCastleInterface::~CCastleInterface()
 	delete fort;
 	delete bigTownPic;
 	delete flag;
-
+	delete garr;
 	for(int i=0;i<buildings.size();i++)
 	{
 		delete buildings[i];

+ 10 - 6
CPlayerInterface.cpp

@@ -87,11 +87,18 @@ void CGarrisonSlot::show()
 {
 	if(creature)
 	{
-		blitAtWR(CGI->creh->bigImgs[creature->idNumber],pos);
+		char* buf = new char[15];
+		itoa(count,buf,10);
+		blitAt(CGI->creh->bigImgs[creature->idNumber],pos);
+		printTo(buf,pos.x+56,pos.y+62,GEOR13,zwykly);
+		if(owner->highlighted==this)
+			blitAt(CGI->creh->bigImgs[-1],pos);
+		updateRect(&pos,ekran);
+		delete [] buf;
 	}
 	else
 	{
-		SDL_Rect jakis1 = genRect(pos.w,pos.h,owner->offx+ID*(pos.w+owner->interx),owner->offy+upg*(pos.h+owner->intery)), jakis2 = pos;
+		SDL_Rect jakis1 = genRect(pos.h,pos.w,owner->offx+ID*(pos.w+owner->interx),owner->offy+upg*(pos.h+owner->intery)), jakis2 = pos;
 		SDL_BlitSurface(owner->sur,&jakis1,ekran,&jakis2);
 		SDL_UpdateRect(ekran,pos.x,pos.y,pos.w,pos.h);
 	}
@@ -126,10 +133,6 @@ void CGarrisonInt::show()
 			if((*sdown)[i])
 				(*sdown)[i]->show();
 	}
-	if(highlighted)
-	{
-		blitAt(CGI->creh->bigImgs[-1],highlighted->pos);
-	}
 }
 void CGarrisonInt::deactiveteSlots()
 {
@@ -236,6 +239,7 @@ void CGarrisonInt::recreateSlots()
 	deactiveteSlots();
 	deleteSlots();
 	createSlots();
+	ignoreEvent = true;
 	activeteSlots();
 	show();
 }

+ 1 - 0
config/buildings2.txt

@@ -13,6 +13,7 @@ CASTLE 0
 22
 30
 37
+16
 END
 EOD
 

+ 31 - 0
hch/CTownHandler.cpp

@@ -118,6 +118,37 @@ void CTownHandler::loadNames()
 	of.close();
 	of.clear();
 
+	
+	//of.open("config/buildings4.txt");
+	//of >> format;
+	//while(!of.eof())
+	//{
+	//	std::map<int,std::map<int, Structure*> >::iterator i;
+	//	std::map<int, Structure*>::iterator i2;
+	//	int itr=1, buildingID;
+	//	int castleID;
+	//	of >> s;
+	//	if (s != "CASTLE")
+	//		break;
+	//	of >> castleID;
+	//	while(1)
+	//	{
+	//		of >> s;
+	//		if (s == "END")
+	//			break;
+	//		else
+	//			if((i=structures.find(castleID))!=structures.end())
+	//				if((i2=(i->second.find(buildingID=atoi(s.c_str()))))!=(i->second.end()))
+	//					i2->second->pos.z=itr++;
+	//				else
+	//					std::cout << "Warning1: No building "<<buildingID<<" in the castle "<<castleID<<std::endl;
+	//			else
+	//				std::cout << "Warning1: Castle "<<castleID<<" not defined."<<std::endl;
+	//	}
+	//}
+	//of.close();
+	//of.clear();
+
 }
 SDL_Surface * CTownHandler::getPic(int ID, bool fort, bool builded)
 {