Przeglądaj źródła

* fixed bug #20
* minor changes

mateuszb 15 lat temu
rodzic
commit
23a32ebf7a

+ 1 - 1
client/CAdvmapInterface.cpp

@@ -569,7 +569,7 @@ void CTerrainRect::clickRight(tribool down, bool previousState)
 		const TerrainTile * tile = LOCPLINT->cb->getTileInfo(mp);
 		if (tile) 
 		{
-			CSimpleWindow * temp = CMessage::genWindow(VLC->generaltexth->terrainNames[tile->tertype],LOCPLINT->playerID,true);
+			CSimpleWindow * temp = CMessage::genWindow(VLC->generaltexth->terrainNames[tile->tertype], LOCPLINT->playerID, true);
 			CRClickPopupInt *rcpi = new CRClickPopupInt(temp,true);
 			GH.pushInt(rcpi);
 		}

+ 1 - 1
client/CMT.cpp

@@ -501,7 +501,7 @@ static void listenForEvents()
 			delete ev;
 			continue;
 		}
-		else if (ev->type == SDL_USEREVENT && ev->user.code == 2) 
+		else if (ev->type == SDL_USEREVENT && ev->user.code == 2) //something want to quit to main menu
 		{
 			client->stop();
 			delete ev;

+ 13 - 1
client/CSpellWindow.cpp

@@ -666,13 +666,25 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
 {
 	if(!down && mySpell!=-1)
 	{
+		int spellCost = LOCPLINT->cb->getSpellCost(&CGI->spellh->spells[mySpell], owner->myHero);
 		//we will cast a spell
-		if(LOCPLINT->battleInt && LOCPLINT->cb->battleCanCastSpell() && LOCPLINT->cb->getSpellCost(&CGI->spellh->spells[mySpell], owner->myHero) <= owner->myHero->mana) //if battle window is open
+		if(LOCPLINT->battleInt && LOCPLINT->cb->battleCanCastSpell() && spellCost <= owner->myHero->mana) //if battle window is open
 		{
 			int spell = mySpell;
 			owner->fexitb();
 			LOCPLINT->battleInt->castThisSpell(spell);
 		}
+		else
+		{
+			//insufficient mana
+			if(spellCost > owner->myHero->mana)
+			{
+				std::vector<SComponent*> comps;
+				char msgBuf[500];
+				sprintf(msgBuf, CGI->generaltexth->allTexts[206].c_str(), spellCost, owner->myHero->mana);
+				LOCPLINT->showInfoDialog(std::string(msgBuf), comps);
+			}
+		}
 	}
 }
 

+ 1 - 1
hch/CObjectHandler.h

@@ -427,7 +427,7 @@ public:
 	std::vector<CGTownBuilding*> bonusingBuildings;
 	std::vector<ui32> possibleSpells, obligatorySpells;
 	std::vector<std::vector<ui32> > spells; //spells[level] -> vector of spells, first will be available in guild
-	std::set<CCastleEvent> events;
+	std::set<CCastleEvent> events;
 	std::pair<si32, si32> bonusValue;//var to store town bonuses (rampart = resources from mystic pond);
 
 	//////////////////////////////////////////////////////////////////////////

+ 4 - 3
lib/map.cpp

@@ -222,8 +222,8 @@ void CMapHeader::initFromMemory( const unsigned char *bufor, int &i )
 {
 	version = (Eformat)(readNormalNr(bufor,i)); i+=4; //map version
 	areAnyPLayers = readChar(bufor,i); //invalid on some maps
-	height = width = (readNormalNr(bufor,i)); i+=4; // wymiary mapy
-	twoLevel = readChar(bufor,i); //czy sa lochy
+	height = width = (readNormalNr(bufor,i)); i+=4; // dimensions of map
+	twoLevel = readChar(bufor,i); //if there is underground
 	int pom;
 	name = readString(bufor,i);
 	description= readString(bufor,i);
@@ -271,7 +271,7 @@ void CMapHeader::loadPlayerInfo( int &pom, const unsigned char * bufor, int &i )
 	{
 		players[pom].canHumanPlay = bufor[i++];
 		players[pom].canComputerPlay = bufor[i++];
-		if ((!(players[pom].canHumanPlay || players[pom].canComputerPlay)))
+		if ((!(players[pom].canHumanPlay || players[pom].canComputerPlay))) //if nobody can play with this player
 		{
 			switch(version)
 			{
@@ -295,6 +295,7 @@ void CMapHeader::loadPlayerInfo( int &pom, const unsigned char * bufor, int &i )
 		else
 			players[pom].p7= -1;
 
+		//factions this player can choose
 		players[pom].allowedFactions = 0;
 		players[pom].allowedFactions += bufor[i++];
 		if(version != RoE)

+ 7 - 1
mapHandler.cpp

@@ -1341,7 +1341,13 @@ CMapHandler::~CMapHandler()
 	for(int i=0; i < staticRiverDefs.size(); i++)
 		delete staticRiverDefs[i];
 
-	//TODO: delete border graphics
+	//TODO: why this code makes VCMI crash?
+	/*for(int i=0; i < terrainGraphics.size(); ++i)
+	{
+		for(int j=0; j < terrainGraphics[i].size(); ++j)
+			SDL_FreeSurface(terrainGraphics[i][j]);
+	}
+	terrainGraphics.clear();*/
 }
 
 CMapHandler::CMapHandler()

+ 0 - 1
mapHandler.h

@@ -106,7 +106,6 @@ public:
 	std::vector<std::vector<SDL_Surface *> > terrainGraphics; // [terrain id] [view type] [rotation type]
 	std::vector<CDefEssential *> roadDefs;
 	std::vector<CDefEssential *> staticRiverDefs;
-	std::vector<CDefEssential*> defs;
 
 	std::map<std::string, CDefEssential*> loadedDefs; //pointers to loaded defs (key is filename, uppercase)
 

+ 1 - 0
server/CGameHandler.cpp

@@ -750,6 +750,7 @@ CGameHandler::~CGameHandler(void)
 	applier = NULL;
 	delete gs;
 }
+
 void CGameHandler::init(StartInfo *si, int Seed)
 {
 	Mapa *map = new Mapa(si->mapname);