← Back to team overview

widelands-dev team mailing list archive

blocking fields in area

 

Hi,

I am not able to figure this problem:

When a space_consumer (farm, vineyard) is built I want to block fields in
some radius. AI has list blocked_fields, so basically I need to iterate
over area around given field and each field will be changed to
 BlockedField that is defined as:

struct BlockedField {

Widelands::FCoords coords;

int32_t blocked_until_;


 BlockedField(Widelands::FCoords c, int32_t until) : coords(c),
blocked_until_(until) {

}

};


My code so far I have is:


MapRegion<Area<FCoords> > mr

(map,

 Area<FCoords>(game().map().get_fcoords(proposed_coords), 2));

do {


BlockedField blocked2(

    game().map().get_fcoords(mr.location().field), game().get_gametime() +
20 * 60 * 1000);

blocked_fields.push_back(blocked2);


 } while (mr.advance(map));


I am struggling with: game().map().get_fcoords(mr.location().field)


when compiling I get


/var/widelands/tibor-ai3/src/ai/defaultai.cc:1671:54: error: no matching
function for call to 'Widelands::Map::get_fcoords(Widelands::Field* const&)'

/var/widelands/tibor-ai3/src/ai/defaultai.cc:1671:54: note: candidates are:

In file included from
/var/widelands/tibor-ai3/src/logic/editor_game_base.h:33:0,

                 from /var/widelands/tibor-ai3/src/logic/game.h:26,

                 from /var/widelands/tibor-ai3/src/ai/ai_help_structs.h:29,

                 from /var/widelands/tibor-ai3/src/ai/defaultai.h:25,

                 from /var/widelands/tibor-ai3/src/ai/defaultai.cc:29:

/var/widelands/tibor-ai3/src/logic/map.h:460:16: note: Widelands::FCoords
Widelands::Map::get_fcoords(const Widelands::Coords&) const

/var/widelands/tibor-ai3/src/logic/map.h:460:16: note:   no known
conversion for argument 1 from 'Widelands::Field* const' to 'const
Widelands::Coords&'

/var/widelands/tibor-ai3/src/logic/map.h:477:16: note: Widelands::FCoords
Widelands::Map::get_fcoords(Widelands::Field&) const

/var/widelands/tibor-ai3/src/logic/map.h:477:16: note:   no known
conversion for argument 1 from 'Widelands::Field* const' to
'Widelands::Field&'


Please advice, this must trivial I believe


Thanks


Tibor

Follow ups