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 23:04:04 -0700
Reply-to: rt@xxxxxxxxxxx

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

Marko Lindqvist wrote:
>>  - 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
>   - Added comment about players_iterate()
>   - Somewhat unrelated comment fixes
>   - Initialize diplstate.contact_turns_left = 0
>   - Initialize diplomatic states as DS_NO_CONTACT instead of DS_NEUTRAL.
  - ai_data_init() was called twice for barbarian creation as well
  - Created player is at war with barbarians
  - Make 'game.nplayers++' earlier so we are not using illegal player_no


  Some later date I'll look into making common parts from barbarian 
creation and rebel nation creation into separate function ( 
create_player_midgame()? ). But that won't happen before next release 
(if it's going to be within months, not years) unless someone else does it.


  - Caz

diff -Nurd -X.diff_ignore freeciv/server/plrhand.c freeciv/server/plrhand.c
--- freeciv/server/plrhand.c    2004-09-11 18:08:18.828125000 +0300
+++ freeciv/server/plrhand.c    2004-09-11 23:45:58.984375000 +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,21 +1824,22 @@
   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.
-   */
+  /* cplayer is not yet part of players_iterate which goes only
+     to game.nplayers. */
   players_iterate(other_player) {
-    cplayer->diplstates[other_player->player_no].type = DS_NEUTRAL;
+    cplayer->diplstates[other_player->player_no].type = DS_NO_CONTACT;
     cplayer->diplstates[other_player->player_no].has_reason_to_cancel = 0;
     cplayer->diplstates[other_player->player_no].turns_left = 0;
-    other_player->diplstates[cplayer->player_no].type = DS_NEUTRAL;
+    cplayer->diplstates[other_player->player_no].contact_turns_left = 0;
+    other_player->diplstates[cplayer->player_no].type = DS_NO_CONTACT;
     other_player->diplstates[cplayer->player_no].has_reason_to_cancel = 0;
     other_player->diplstates[cplayer->player_no].turns_left = 0;
+    other_player->diplstates[cplayer->player_no].contact_turns_left = 0;
     
     /* Send so that other_player sees updated diplomatic info;
-     * cplayer and pplayer will be sent later anyway
+     * pplayer will be sent later anyway
      */
-    if (other_player != cplayer && other_player != pplayer) {
+    if (other_player != pplayer) {
       send_player_info(other_player, other_player);
     }
   }
@@ -1844,7 +1847,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 +1882,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 */
 
@@ -1917,16 +1921,13 @@
  * The capture of a capital is not a sure fire way to throw
 and empire into civil war.  Some governments are more susceptible 
 than others, here are the base probabilities:
- *      Anarchy        90%   
+Anarchy        90%
 Despotism      80%
 Monarchy       70%
-Fundamentalism  60% (In case it gets implemented one day)
+Fundamentalism  60% (Only in civ2 ruleset)
 Communism      50%
-       Republic        40%
-Democracy      30%     
- * Note:  In the event that Fundamentalism is added, you need to
-update the array government_civil_war[G_LAST] in player.c
- * [ SKi: That would now be data/default/governments.ruleset. ]
+Republic       40%
+Democracy      30%
  * In addition each city in revolt adds 5%, each city in rapture 
 subtracts 5% from the probability of a civil war.  
  * If you have at least 1 turns notice of the impending loss of 

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