1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Minor fix for creature Component.

Some missing code also.
This commit is contained in:
DjWarmonger
2010-08-22 07:54:24 +00:00
parent f6b97704c7
commit 6f94fcd083
2 changed files with 32 additions and 5 deletions

View File

@@ -874,8 +874,7 @@ void SComponent::init(Etype Type, int Subtype, int Val)
subtitle = CGI->spellh->spells[Subtype].name; subtitle = CGI->spellh->spells[Subtype].name;
break; break;
case creature: case creature:
if (Val) //no need to display 0 value subtitle = (Val? boost::lexical_cast<std::string>(Val) + " " : "") + CGI->creh->creatures[Subtype]->*(Val != 1 ? &CCreature::namePl : &CCreature::nameSing);
subtitle = boost::lexical_cast<std::string>(Val) + " " + CGI->creh->creatures[Subtype]->*(Val != 1 ? &CCreature::namePl : &CCreature::nameSing);
break; break;
case experience: case experience:
description = CGI->generaltexth->allTexts[241]; description = CGI->generaltexth->allTexts[241];

View File

@@ -22,6 +22,7 @@
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <boost/thread/shared_mutex.hpp> #include <boost/thread/shared_mutex.hpp>
#include <boost/assign/list_of.hpp> #include <boost/assign/list_of.hpp>
#include <boost/random/linear_congruential.hpp>
#include <fstream> #include <fstream>
#include <boost/system/system_error.hpp> #include <boost/system/system_error.hpp>
@@ -56,7 +57,9 @@ extern bool end2;
CondSh<bool> battleMadeAction; CondSh<bool> battleMadeAction;
CondSh<BattleResult *> battleResult(NULL); CondSh<BattleResult *> battleResult(NULL);
boost::rand48 ran; //TODO: Use common (external?) function for it
std::ptrdiff_t randomizer (ptrdiff_t i) {return ran();}
std::ptrdiff_t (*p_myrandom)(std::ptrdiff_t) = randomizer;
class CBaseForGHApply class CBaseForGHApply
{ {
@@ -1139,9 +1142,9 @@ void CGameHandler::newTurn()
//unhiding what shouldn't be hidden? //that's handled in netpacks client //unhiding what shouldn't be hidden? //that's handled in netpacks client
} }
if(getDate(2) == 1) if(getDate(2) == 1) //first week
{ {
SetAvailableArtifacts saa; SetAvailableArtifacts saa;
saa.id = -1; saa.id = -1;
pickAllowedArtsSet(saa.arts); pickAllowedArtsSet(saa.arts);
sendAndApply(&saa); sendAndApply(&saa);
@@ -1152,8 +1155,33 @@ void CGameHandler::newTurn()
handleTimeEvents(); handleTimeEvents();
//call objects //call objects
for(size_t i = 0; i<gs->map->objects.size(); i++) for(size_t i = 0; i<gs->map->objects.size(); i++)
{
if(gs->map->objects[i]) if(gs->map->objects[i])
gs->map->objects[i]->newTurn(); gs->map->objects[i]->newTurn();
}
if(getDate(4) == 1 && getDate(0)>1) //new month
{
//spawn wandering monsters
std::vector<int3>::iterator tile;
std::vector<int3> tiles;
getFreeTiles(tiles);
ui32 amount = (tiles.size()) >> 6;
std::random_shuffle(tiles.begin(), tiles.end(), p_myrandom);
std::pair<int,int> newMonster(54, VLC->creh->pickRandomMonster(boost::ref(ran)));
for (int i = 0; i < amount; ++i)
{
tile = tiles.begin();
TerrainTile *tinfo = &gs->map->terrain[tile->x][tile->y][tile->z];
NewObject no;
no.ID = newMonster.first;
no.subID = newMonster.second;
no.pos = *tile;
sendAndApply(&no);
tiles.erase(tile); //not use it again
}
}
winLoseHandle(0xff); winLoseHandle(0xff);