Author: cazfi
Date: Sun Oct 25 08:20:19 2015
New Revision: 30205

URL: http://svn.gna.org/viewcvs/freeciv?rev=30205&view=rev
Log:
Moved space advisors from default ai to advisors.

See patch #5217

Added:
    branches/S2_5/server/advisors/advspace.c
      - copied, changed from r30204, branches/S2_5/ai/default/advspace.c
    branches/S2_5/server/advisors/advspace.h
      - copied, changed from r30204, branches/S2_5/ai/default/advspace.h
Removed:
    branches/S2_5/ai/default/advspace.c
    branches/S2_5/ai/default/advspace.h
Modified:
    branches/S2_5/ai/default/Makefile.am
    branches/S2_5/ai/default/aihand.c
    branches/S2_5/server/advisors/Makefile.am

Modified: branches/S2_5/ai/default/Makefile.am
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/ai/default/Makefile.am?rev=30205&r1=30204&r2=30205&view=diff
==============================================================================
--- branches/S2_5/ai/default/Makefile.am        (original)
+++ branches/S2_5/ai/default/Makefile.am        Sun Oct 25 08:20:19 2015
@@ -11,8 +11,6 @@
                advmilitary.h   \
                advdiplomacy.c  \
                advdiplomacy.h  \
-               advspace.c      \
-               advspace.h      \
                aiair.c         \
                aiair.h         \
                aicity.c        \

Removed: branches/S2_5/ai/default/advspace.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/ai/default/advspace.c?rev=30204&view=auto
==============================================================================
--- branches/S2_5/ai/default/advspace.c (original)
+++ branches/S2_5/ai/default/advspace.c (removed)
@@ -1,154 +0,0 @@
-/********************************************************************** 
- Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-***********************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include <fc_config.h>
-#endif
-
-/* common */
-#include "government.h"
-#include "packets.h"
-#include "spaceship.h"
-
-/* server */
-#include "spacerace.h"
-
-#include "advspace.h"
-
-/****************************************************************************
-  This borrows heavily from autoplace code already in the client source.
-  AJS, 19990610
-****************************************************************************/
-bool dai_spaceship_autoplace(struct player *pplayer,
-                             struct player_spaceship *ship)
-{
-  enum spaceship_place_type type;
-  int num, i;
-  bool retval = FALSE;
-  
-  while (ship->modules > (ship->habitation + ship->life_support
-                      + ship->solar_panels)) {
-    
-    type =
-      (ship->habitation==0)   ? SSHIP_PLACE_HABITATION :
-      (ship->life_support==0) ? SSHIP_PLACE_LIFE_SUPPORT :
-      (ship->solar_panels==0) ? SSHIP_PLACE_SOLAR_PANELS :
-      ((ship->habitation < ship->life_support)
-       && (ship->solar_panels*2 >= ship->habitation + ship->life_support + 1))
-                              ? SSHIP_PLACE_HABITATION :
-      (ship->solar_panels*2 < ship->habitation + ship->life_support)
-                              ? SSHIP_PLACE_SOLAR_PANELS :
-      (ship->life_support<ship->habitation)
-                              ? SSHIP_PLACE_LIFE_SUPPORT :
-      ((ship->life_support <= ship->habitation)
-       && (ship->solar_panels*2 >= ship->habitation + ship->life_support + 1))
-                              ? SSHIP_PLACE_LIFE_SUPPORT :
-                                SSHIP_PLACE_SOLAR_PANELS;
-
-    if (type == SSHIP_PLACE_HABITATION) {
-      num = ship->habitation + 1;
-    } else if(type == SSHIP_PLACE_LIFE_SUPPORT) {
-      num = ship->life_support + 1;
-    } else {
-      num = ship->solar_panels + 1;
-    }
-    fc_assert_ret_val(num <= NUM_SS_MODULES / 3, FALSE);
-
-    handle_spaceship_place(pplayer, type, num);
-    retval = TRUE;
-  }
-  while (ship->components > ship->fuel + ship->propulsion) {
-    if (ship->fuel <= ship->propulsion) {
-      type = SSHIP_PLACE_FUEL;
-      num = ship->fuel + 1;
-    } else {
-      type = SSHIP_PLACE_PROPULSION;
-      num = ship->propulsion + 1;
-    }
-    handle_spaceship_place(pplayer, type, num);
-    retval = TRUE;
-  }
-  while (ship->structurals > num_spaceship_structurals_placed(ship)) {
-    /* Want to choose which structurals are most important.
-       Else we first want to connect one of each type of module,
-       then all placed components, pairwise, then any remaining
-       modules, or else finally in numerical order.
-    */
-    int req = -1;
-    
-    if (!BV_ISSET(ship->structure, 0)) {
-      /* if we don't have the first structural, place that! */
-      type = SSHIP_PLACE_STRUCTURAL;
-      num = 0;
-      handle_spaceship_place(pplayer, type, num);
-    }
-    
-    if (ship->habitation >= 1
-        && !BV_ISSET(ship->structure, modules_info[0].required)) {
-      req = modules_info[0].required;
-    } else if (ship->life_support >= 1
-               && !BV_ISSET(ship->structure, modules_info[1].required)) {
-      req = modules_info[1].required;
-    } else if (ship->solar_panels >= 1
-               && !BV_ISSET(ship->structure, modules_info[2].required)) {
-      req = modules_info[2].required;
-    } else {
-      int i;
-      for(i=0; i<NUM_SS_COMPONENTS; i++) {
-       if ((i%2==0 && ship->fuel > (i/2))
-           || (i%2==1 && ship->propulsion > (i/2))) {
-         if (!BV_ISSET(ship->structure, components_info[i].required)) {
-           req = components_info[i].required;
-           break;
-         }
-       }
-      }
-    }
-    if (req == -1) {
-      for(i=0; i<NUM_SS_MODULES; i++) {
-       if ((i%3==0 && ship->habitation > (i/3))
-           || (i%3==1 && ship->life_support > (i/3))
-           || (i%3==2 && ship->solar_panels > (i/3))) {
-         if (!BV_ISSET(ship->structure, modules_info[i].required)) {
-           req = modules_info[i].required;
-           break;
-         }
-       }
-      }
-    }
-    if (req == -1) {
-      for(i=0; i<NUM_SS_STRUCTURALS; i++) {
-        if (!BV_ISSET(ship->structure, i)) {
-         req = i;
-         break;
-       }
-      }
-    }
-    /* sanity: */
-    fc_assert_ret_val(-1 != req, FALSE);
-    fc_assert_ret_val(!BV_ISSET(ship->structure, req), FALSE);
-    
-    /* Now we want to find a structural we can build which leads to req.
-       This loop should bottom out, because everything leads back to s0,
-       and we made sure above that we do s0 first.
-     */
-    while(!BV_ISSET(ship->structure, structurals_info[req].required)) {
-      req = structurals_info[req].required;
-    }
-    type = SSHIP_PLACE_STRUCTURAL;
-    num = req;
-    handle_spaceship_place(pplayer, type, num);
-    retval = TRUE;
-  }
-  return retval;
-}

Removed: branches/S2_5/ai/default/advspace.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/ai/default/advspace.h?rev=30204&view=auto
==============================================================================
--- branches/S2_5/ai/default/advspace.h (original)
+++ branches/S2_5/ai/default/advspace.h (removed)
@@ -1,25 +0,0 @@
-/********************************************************************** 
- Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-***********************************************************************/
-#ifndef FC__ADVSPACE_H
-#define FC__ADVSPACE_H
-
-#include "shared.h"
-
-#include "fc_types.h"
-
-struct player_spaceship;
-
-bool dai_spaceship_autoplace(struct player *pplayer,
-                             struct player_spaceship *ship);
-
-#endif  /* FC__ADVSPACE_H */

Modified: branches/S2_5/ai/default/aihand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/ai/default/aihand.c?rev=30205&r1=30204&r2=30205&view=diff
==============================================================================
--- branches/S2_5/ai/default/aihand.c   (original)
+++ branches/S2_5/ai/default/aihand.c   Sun Oct 25 08:20:19 2015
@@ -95,11 +95,12 @@
 {
   if (game.info.spacerace) {
     if (pplayer->spaceship.state == SSHIP_STARTED) {
-      dai_spaceship_autoplace(pplayer, &pplayer->spaceship);
+      adv_spaceship_autoplace(pplayer, &pplayer->spaceship);
+
       /* if we have built the best possible spaceship  -- AJS 19990610 */
-      if ((pplayer->spaceship.structurals == NUM_SS_STRUCTURALS) &&
-        (pplayer->spaceship.components == NUM_SS_COMPONENTS) &&
-        (pplayer->spaceship.modules == NUM_SS_MODULES))
+      if ((pplayer->spaceship.structurals == NUM_SS_STRUCTURALS)
+          && (pplayer->spaceship.components == NUM_SS_COMPONENTS)
+          && (pplayer->spaceship.modules == NUM_SS_MODULES))
         handle_spaceship_launch(pplayer);
     }
   }

Modified: branches/S2_5/server/advisors/Makefile.am
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/advisors/Makefile.am?rev=30205&r1=30204&r2=30205&view=diff
==============================================================================
--- branches/S2_5/server/advisors/Makefile.am   (original)
+++ branches/S2_5/server/advisors/Makefile.am   Sun Oct 25 08:20:19 2015
@@ -18,6 +18,8 @@
        advgoto.h       \
        advruleset.c    \
        advruleset.h    \
+       advspace.c      \
+       advspace.h      \
        advtools.c      \
        advtools.h      \
        autoexplorer.c  \

Copied: branches/S2_5/server/advisors/advspace.c (from r30204, 
branches/S2_5/ai/default/advspace.c)
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/advisors/advspace.c?p2=branches/S2_5/server/advisors/advspace.c&p1=branches/S2_5/ai/default/advspace.c&r1=30204&r2=30205&rev=30205&view=diff
==============================================================================
--- branches/S2_5/ai/default/advspace.c (original)
+++ branches/S2_5/server/advisors/advspace.c    Sun Oct 25 08:20:19 2015
@@ -29,7 +29,7 @@
   This borrows heavily from autoplace code already in the client source.
   AJS, 19990610
 ****************************************************************************/
-bool dai_spaceship_autoplace(struct player *pplayer,
+bool adv_spaceship_autoplace(struct player *pplayer,
                              struct player_spaceship *ship)
 {
   enum spaceship_place_type type;

Copied: branches/S2_5/server/advisors/advspace.h (from r30204, 
branches/S2_5/ai/default/advspace.h)
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/advisors/advspace.h?p2=branches/S2_5/server/advisors/advspace.h&p1=branches/S2_5/ai/default/advspace.h&r1=30204&r2=30205&rev=30205&view=diff
==============================================================================
--- branches/S2_5/ai/default/advspace.h (original)
+++ branches/S2_5/server/advisors/advspace.h    Sun Oct 25 08:20:19 2015
@@ -13,13 +13,15 @@
 #ifndef FC__ADVSPACE_H
 #define FC__ADVSPACE_H
 
+/* utility */
 #include "shared.h"
 
+/* common */
 #include "fc_types.h"
 
 struct player_spaceship;
 
-bool dai_spaceship_autoplace(struct player *pplayer,
+bool adv_spaceship_autoplace(struct player *pplayer,
                              struct player_spaceship *ship);
 
 #endif  /* FC__ADVSPACE_H */


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to