diff --git a/client/GUIClasses.cpp b/client/GUIClasses.cpp index 7f6109274..5b9e9398b 100644 --- a/client/GUIClasses.cpp +++ b/client/GUIClasses.cpp @@ -874,8 +874,7 @@ void SComponent::init(Etype Type, int Subtype, int Val) subtitle = CGI->spellh->spells[Subtype].name; break; case creature: - if (Val) //no need to display 0 value - subtitle = boost::lexical_cast(Val) + " " + CGI->creh->creatures[Subtype]->*(Val != 1 ? &CCreature::namePl : &CCreature::nameSing); + subtitle = (Val? boost::lexical_cast(Val) + " " : "") + CGI->creh->creatures[Subtype]->*(Val != 1 ? &CCreature::namePl : &CCreature::nameSing); break; case experience: description = CGI->generaltexth->allTexts[241]; diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index a7c86bb9f..6c7d1d91d 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -56,7 +57,9 @@ extern bool end2; CondSh battleMadeAction; CondSh 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 { @@ -1139,9 +1142,9 @@ void CGameHandler::newTurn() //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; pickAllowedArtsSet(saa.arts); sendAndApply(&saa); @@ -1152,8 +1155,33 @@ void CGameHandler::newTurn() handleTimeEvents(); //call objects for(size_t i = 0; imap->objects.size(); i++) + { if(gs->map->objects[i]) gs->map->objects[i]->newTurn(); + } + + if(getDate(4) == 1 && getDate(0)>1) //new month + { + //spawn wandering monsters + std::vector::iterator tile; + std::vector tiles; + getFreeTiles(tiles); + ui32 amount = (tiles.size()) >> 6; + std::random_shuffle(tiles.begin(), tiles.end(), p_myrandom); + + std::pair 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);