Comment 7 for bug 1203629

Revision history for this message
GunChleoc (gunchleoc) wrote :

I need help with the pointer thing. In worker.cc, I have a working implementation, looks like this:

  for (const ImmovableFound& tmp_flag : flags)
  {
   Flag & flag = ref_cast<Flag, BaseImmovable>(*tmp_flag.object);

   if (game.logic_rand() % 2 == 0)
    continue;

   int32_t const dist =
    map.calc_distance(get_position(), tmp_flag.coords);

"flags" is of the sollowing type:

std::vector<ImmovableFound> flags;

And ImmovableFound is:

struct ImmovableFound {
 BaseImmovable * object;
 Coords coords;
};

Now, I'm rtying to do the same thing in flag.cc. My attempts compile, but I get an error when I start a game and place a flag.

Attempt1:
 for (const FlagJob& tmp_flagjobs: m_flag_jobs)
  *tmp_flagjobs.request->set_economy(e);

Attempt2:

 for (const FlagJob tmp_flagjobs: m_flag_jobs)
  tmp_flagjobs.request->set_economy(e);

and the types are:

typedef std::list<FlagJob> FlagJobs;
 FlagJobs m_flag_jobs;

 struct FlagJob {
  Request * request;
  std::string program;
 };