Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] Re: (PR#7322) Four small features requests
Home

[Freeciv-Dev] Re: (PR#7322) Four small features requests

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#7322) Four small features requests
From: "Josh Cogliati" <jjc@xxxxxxxxxxxxxxxxxx>
Date: Sun, 23 May 2004 08:44:26 -0700
Reply-to: rt@xxxxxxxxxxx

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

On Sat, May 22, 2004 at 12:46:49AM -0700, Raimar Falke wrote:
> 
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=7322 >
> 
> On Thu, May 20, 2004 at 07:49:33PM -0700, Josh Cogliati wrote:
> > 
> > <URL: http://rt.freeciv.org/Ticket/Display.html?id=7322 >
> > 
> > > [jrincayc - Mon Jan 26 15:35:34 2004]:
> > > 
> > > These are a few features that I think will help beginning players:
> > > 
> > > 1. Give an embassay from all human players to all novice (maybe easy?)
> > > ai players.
> > > This will help because it allows the new player to compare their armys,
> > > population, production etc with the computer player.  This gives them
> > > feedback as to how efficiently they are growing their empire.
> > 
> > Attached is a simple implementation of this.  It adds the embassys 
> > in the generate_ai_players code for every player that has the 
> > handicap H_EMBASSY.  novice ai players get this handicap.
> > The patch is against cvs current.

> > +  for (i=0; i<game.nplayers; i++) {
> > +    pplayer = &game.players[i];
> 
> Please use player_iterate.
Fixed in the new version.
 
>> > +  game.players[j].embassy |= (1 << pplayer->player_no);
> 
> Isn't there a function for this.
Not really.  You are probably thinking of establish_embassy in diplhand.c
However, establish_embassy also sends out packets notifying the players of 
the new embassy.  Since generate_ai_players is called before all 
the game starts this triggers an assertion.  

So calling establish_embassy doesn't work, and even if it did, it would 
cause extra packets to be sent.

The new version changes to using players_iterate.  Other than that, it
is the same as the previous version.

-- 
Josh Cogliati



? data/experimental
? data/experimental.tar.gz
? data/graphics/isotrident/units/u.workers.png
? data/graphics/trident/units/u.workers.png
Index: common/player.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.h,v
retrieving revision 1.115
diff -u -r1.115 player.h
--- common/player.h     23 Apr 2004 22:58:06 -0000      1.115
+++ common/player.h     23 May 2004 15:28:59 -0000
@@ -53,7 +53,8 @@
   H_HUTS = 128,       /* Doesn't know which unseen tiles have huts on them */
   H_FOG = 256,        /* Can't see through fog of war */
   H_NOPLANES = 512,   /* Doesn't build air units */
-  H_MAP = 1024        /* Only knows map_is_known tiles */
+  H_MAP = 1024,       /* Only knows map_is_known tiles */
+  H_EMBASSY = 2048    /* Other players get embassy with */
 };
 
 struct player_economic {
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.160
diff -u -r1.160 srv_main.c
--- server/srv_main.c   2 May 2004 14:47:12 -0000       1.160
+++ server/srv_main.c   23 May 2004 15:29:21 -0000
@@ -1231,6 +1231,15 @@
     announce_ai_player(pplayer);
     set_ai_level_direct(pplayer, pplayer->ai.skill_level);
   }
+
+  players_iterate(pplayer) {
+    if(pplayer->ai.handicap & H_EMBASSY) {
+      players_iterate(oplayer) {
+        oplayer->embassy |= (1 << pplayer->player_no);
+      } players_iterate_end
+    }
+  } players_iterate_end
+  
   (void) send_server_info_to_metaserver(TRUE, FALSE);
 }
 
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.317
diff -u -r1.317 stdinhand.c
--- server/stdinhand.c  17 May 2004 05:34:53 -0000      1.317
+++ server/stdinhand.c  23 May 2004 15:29:54 -0000
@@ -1906,7 +1906,8 @@
   int h[11] = { -1,
                H_AWAY,
  /* novice */   H_RATES | H_TARGETS | H_HUTS | H_NOPLANES 
-                        | H_DIPLOMAT | H_LIMITEDHUTS | H_DEFENSIVE,
+                        | H_DIPLOMAT | H_LIMITEDHUTS | H_DEFENSIVE
+                        | H_EMBASSY,
  /* easy */    H_RATES | H_TARGETS | H_HUTS | H_NOPLANES 
                         | H_DIPLOMAT | H_LIMITEDHUTS | H_DEFENSIVE,
                H_NONE,

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