Closed GoogleCodeExporter closed 9 years ago
try
for each (BWAPI::Unit* i in Broodwar->self()->getUnits())
{ }
The null check should not be necessary, and the iterator seems to be the cause
of the
crash??
Original comment by AHeinerm
on 15 Nov 2009 at 4:36
Try this too:
std::set<Unit*> myunits = Broodwar->self()->getUnits();
for(std::set<Unit*>::iterator i = myunits.begin(); i != myunits.end(); i++)
{ }
Original comment by AHeinerm
on 15 Nov 2009 at 4:52
Right now Broodwar->self()->getUnits() returns a new set of units, so checking
for
the end of the loop with "i!=Broodwar->self()->getUnits().end()" will generate
and
return a new set of units every time since you're calling self()->getUnits().
Original comment by lowerlo...@gmail.com
on 15 Nov 2009 at 7:29
Using the code in comment2 fixed the issue.
I added some debug statements to PlayerImpl::getUnits() and it was not
regenerating
the cache each time which, if it had, would have explained the problem.
Original comment by iulia...@gmail.com
on 15 Nov 2009 at 7:57
In r1427 I changed Player::getUnits() and similar functions in Game so they
return
references to sets, rather than actual sets of units. I also updated the user
documentation to reflect these changes.
Original comment by lowerlo...@gmail.com
on 15 Nov 2009 at 8:41
Original issue reported on code.google.com by
iulia...@gmail.com
on 15 Nov 2009 at 11:07