Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] [Patch] Reorder change homecity
Home

[Freeciv-Dev] [Patch] Reorder change homecity

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] [Patch] Reorder change homecity
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 16 Oct 2001 11:47:10 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

This patch reorders change homecity. This change is necessary for the
CMA. Old code:

    if ((pcity=player_find_city_by_id(pplayer, req->city_id))
        && pcity->owner == punit->owner) {
      unit_list_insert(&pcity->units_supported, punit);
      city_refresh(pcity);
1>>>  send_city_info(pplayer, pcity);

      if((pcity=player_find_city_by_id(pplayer, punit->homecity))) {
        unit_list_unlink(&pcity->units_supported, punit);
        city_refresh(pcity);
        send_city_info(pplayer, pcity);
      }

2>>>> punit->homecity=req->city_id;
      send_unit_info(pplayer, punit);
    }

At 1 the client gets a new city info. The CMA re-calculates the city
but doesn't have all information (2 is missing). So the CMA calulcates
a wrong result.

The new code:
    if (new_pcity && new_pcity->owner == punit->owner) {
      unit_list_insert(&new_pcity->units_supported, punit);
      if (old_pcity) {
        unit_list_unlink(&old_pcity->units_supported, punit);
      }

      punit->homecity = req->city_id;
      send_unit_info(pplayer, punit);

      city_refresh(new_pcity);
      send_city_info(pplayer, new_pcity);

      if (old_pcity) {
        city_refresh(old_pcity);
        send_city_info(pplayer, old_pcity);
      }
    }

First sends the new unit_info and then the updated city_infos.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  Microsoft does have a year 2000 problem. I'm part of it. I'm running Linux.

Attachment: change_homecity_reorder1.diff
Description: Text document


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] [Patch] Reorder change homecity, Raimar Falke <=