Browse Source

Fixed bugs 11, 24 & 26

Next part of Shops script, however still no GUI.
DjWarmonger 16 years ago
parent
commit
913c0af6fa
6 changed files with 61 additions and 8 deletions
  1. 9 0
      client/GUIClasses.cpp
  2. 10 1
      client/GUIClasses.h
  3. 17 0
      client/NetPacksClient.cpp
  4. 15 4
      hch/CObjectHandler.cpp
  5. 9 1
      hch/CObjectHandler.h
  6. 1 2
      lib/NetPacks.h

+ 9 - 0
client/GUIClasses.cpp

@@ -4377,3 +4377,12 @@ bool CShopWindow::swapItem (ui16 which, bool choose)
 	}
 	return itemFound;
 }
+
+CArtMerchantWindow::CArtMerchantWindow()
+{
+}
+CArtMerchantWindow::~CArtMerchantWindow(){}
+void CArtMerchantWindow::activate() {}
+void CArtMerchantWindow::deactivate() {}
+void CArtMerchantWindow::show(SDL_Surface * to) {}
+void CArtMerchantWindow::Buy() {}

+ 10 - 1
client/GUIClasses.h

@@ -771,7 +771,16 @@ public:
 	virtual void Buy() {};
 };
 class CArtMerchantWindow : public CShopWindow
-{};
+{
+public:
+	void activate();
+	void deactivate();	
+	void show(SDL_Surface * to);
+	void Buy();
+
+	CArtMerchantWindow();
+	~CArtMerchantWindow();
+};
 class CUniversityWindow : public CShopWindow
 {};
 class CAltarWindow : public CShopWindow

+ 17 - 0
client/NetPacksClient.cpp

@@ -623,3 +623,20 @@ void NewObject::applyCl(CClient *cl)
 		}
 	}
 }
+
+void TradeComponents::applyCl(CClient *cl)
+{///Shop handler
+	switch (CGI->mh->map->objects[objectid]->ID)
+	{
+		case 7: //Black Market
+			break;
+		case 95: //Tavern
+			break;
+		case 97: //Den of Thieves
+			break;
+		case 221: //Trading Post
+			break;
+		default: 
+			tlog2 << "Shop type not supported! \n";
+	}
+}

+ 15 - 4
hch/CObjectHandler.cpp

@@ -1592,7 +1592,8 @@ void CGTownInstance::initObj()
 				bonusingBuildings.push_back (new CTownBonus(17, this));
 			break;
 	}
-	removeCapitols (getOwner(), false); // destroy other capitols
+	if (getOwner() != 255)
+		removeCapitols (getOwner(), false); // destroy other capitols
 }
 
 int3 CGTownInstance::getSightCenter() const
@@ -1819,11 +1820,11 @@ void CGVisitableOPH::onNAHeroVisit(int heroID, bool alreadyVisited) const
 						return;
 					}
 
-					BlockingDialog sd(true,false);
+					BlockingDialog sd (true, false);
 					sd.soundID = sound;
 					sd.player = cb->getOwner(heroID);
 					sd.text << std::pair<ui8,ui32>(11,ot);
-					sd.components.push_back(Component(id,subid,val,0));
+					sd.components.push_back (Component (Component::RESOURCE, res, resval, 0));
 					cb->showBlockingDialog(&sd,boost::bind(&CGVisitableOPH::treeSelected,this,heroID,res,resval,val,_1));
 				}
 				break;
@@ -3898,6 +3899,8 @@ void CGOnceVisitable::searchTomb(const CGHeroInstance *h, ui32 accept) const
 			gb.bdescr.addTxt(MetaString::ARRAY_TXT,104); //Warrior Tomb Visited -3
 			cb->giveHeroBonus(&gb);
 		}
+		cb->showInfoDialog(&iw);
+		cb->setObjProperty(id,10,h->getOwner());
 	}
 }
 
@@ -4676,7 +4679,7 @@ void CShop::newTurn() const
 			}
 			break;
 		case 78: //Refugee Camp
-		case 95: //Tavern
+		case 95: //Tavern -- global hero pool?
 			if (cb->getDate(0)%7 == 1)
 				cb->setObjProperty (id, 14, rand());
 			break;
@@ -4734,3 +4737,11 @@ void CGArtMerchant::reset(ui32 val)
 	}
 
 }
+
+void CGRefugeeCamp::reset(ui32 val)
+{
+	/*int creid = creh->creatures[val%creh->creatures.size()].idNumber;
+	VLC->creh->creatures[creatures[creid].second[0]].growth;
+	available[0] = new Component (Component::CREATURE, creid, 0, 0);
+	*/
+}

+ 9 - 1
hch/CObjectHandler.h

@@ -982,7 +982,7 @@ public:
 	void setPropertyDer (ui8 what, ui32 val);
 	void newTurn() const;
 	virtual void reset (ui32 val) {}; //get new items for Black Market, Tavern, Refugee Camp 
-	void onHeroVisit (const CGHeroInstance * h) const {};
+	virtual void onHeroVisit (const CGHeroInstance * h) const {};
 	virtual void trade (const CGHeroInstance * h) const {};
 	
 	template <typename Handler> void serialize(Handler &h, const int version)
@@ -992,7 +992,15 @@ public:
 };
 class DLL_EXPORT CGArtMerchant : public CShop
 {
+public:
+	void reset (ui32 val);
+	void onHeroVisit (const CGHeroInstance * h) const {};
+};
+class DLL_EXPORT CGRefugeeCamp : public CShop
+{
+public:
 	void reset (ui32 val);
+	void onHeroVisit (const CGHeroInstance * h) const {};
 };
 struct BankConfig
 {

+ 1 - 2
lib/NetPacks.h

@@ -700,8 +700,7 @@ struct TradeComponents : public CPackForClient, public CPackForServer
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
-		//FIXME: Deal with id properly.
-		h /* & id */ & heroid & objectid & available & chosen & bought;
+		h & heroid & objectid & available & chosen & bought;
 	}
 
 };