regrass: pick random grass event if tile is soil instead of always using the first one found

develop
Robert Heinrich 2012-04-16 07:03:27 +02:00
parent e58a46b42b
commit 9c67250729
1 changed files with 16 additions and 2 deletions

@ -127,9 +127,23 @@ command_result df_regrass (color_ostream &out, vector <string> & parameters)
}
}
// if original could not be found (meaning it was already depleted):
// refresh the first grass event in the map block
// refresh random grass event in the map block
if(!regrew)
grev->amount[x][y]=100;
{
vector <df::block_square_event_grassst *> gr_evs;
for(size_t e=0; e<cur->block_events.size(); e++)
{
df::block_square_event * blev = cur->block_events[e];
df::block_square_event_type blevtype = blev->getType();
if(blevtype == df::block_square_event_type::grass)
{
df::block_square_event_grassst * gr_ev = (df::block_square_event_grassst *)blev;
gr_evs.push_back(gr_ev);
}
}
int r = rand() % gr_evs.size();
gr_evs[r]->amount[x][y]=100;
}
}
cur->tiletype[x][y] = findRandomVariant((rand() & 1) ? tiletype::GrassLightFloor1 : tiletype::GrassDarkFloor1);
count++;