Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2004:
[Freeciv-Dev] Re: (PR#10034) no contact with adjacent player
Home

[Freeciv-Dev] Re: (PR#10034) no contact with adjacent player

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#10034) no contact with adjacent player
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Sat, 11 Sep 2004 06:08:53 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=10034 >


  Attached untested patch might help. It fixes several split_players 
related problems I came across.

  - AFAICT player_no for new player was not set ( -> others actually 
gained contact with undefined player) This affects barbarian creation as 
well.
  - Added assert() to make_contact()
  - ai_data_init() was called twice; in server_init_player() and 
split_player()
  - If original player had odd gold amount, one piece was lost during 
civil war. Now original player gets one gold more than created one in 
case of civil war.
  - Removed comment which no longer made sense


  - Caz


diff -Nurd -X.diff_ignore freeciv/server/plrhand.c freeciv/server/plrhand.c
--- freeciv/server/plrhand.c    2004-09-07 22:03:56.296875000 +0300
+++ freeciv/server/plrhand.c    2004-09-11 15:51:28.906250000 +0300
@@ -1548,6 +1548,7 @@
   if (initmap) {
     player_map_allocate(pplayer);
   }
+  pplayer->player_no = pplayer-game.players;
   ai_data_init(pplayer);
 }
 
@@ -1625,6 +1626,8 @@
     check_city_workers(pplayer1);
     check_city_workers(pplayer2);
     return;
+  } else {
+    assert(pplayer_get_diplstate(pplayer2, pplayer1)->type != DS_NO_CONTACT);
   }
   if (player_has_embassy(pplayer1, pplayer2)
       || player_has_embassy(pplayer2, pplayer1)) {
@@ -1809,7 +1812,6 @@
 
   /* make a new player */
   server_player_init(cplayer, TRUE);
-  ai_data_init(cplayer);
 
   /* select a new name and nation for the copied player. */
   /* Rebel will always be an AI player */
@@ -1822,9 +1824,6 @@
   cplayer->revolution_finishes = game.turn + 1;
   cplayer->capital = TRUE;
 
-  /* This should probably be DS_NEUTRAL when AI knows about diplomacy,
-   * but for now AI players are always at war.
-   */
   players_iterate(other_player) {
     cplayer->diplstates[other_player->player_no].type = DS_NEUTRAL;
     cplayer->diplstates[other_player->player_no].has_reason_to_cancel = 0;
@@ -1844,7 +1843,9 @@
 
   /* Split the resources */
   
-  cplayer->economic.gold = pplayer->economic.gold/2;
+  cplayer->economic.gold = pplayer->economic.gold;
+  cplayer->economic.gold /= 2;
+  pplayer->economic.gold -= cplayer->economic.gold;
 
   /* Copy the research */
 
@@ -1877,7 +1878,6 @@
     pplayer->government = game.government_when_anarchy;
     pplayer->revolution_finishes = game.turn + 1;
   }
-  pplayer->economic.gold = cplayer->economic.gold;
   pplayer->research.bulbs_researched = 0;
   pplayer->embassy = 0; /* all embassies destroyed */
 

[Prev in Thread] Current Thread [Next in Thread]