Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2005:
[Freeciv-Dev] (PR#13003) tile_activity patch
Home

[Freeciv-Dev] (PR#13003) tile_activity patch

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13003) tile_activity patch
From: "Brian Dunstan" <bdunstan149@xxxxxxxxx>
Date: Sat, 7 May 2005 11:20:58 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13003 >

This patch adds a function

tile_activity(tile, activity)

The idea is that you can create the effect of a
particular activity on a tile, by using the
Activity_type_id explicitly.

This will be very useful in modifying autosettler
code, but it may also help simplify other areas of
freeciv.

The patch I've made is one implementation; I'm sure
others can think of some way it might be done better :)


                
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html

diff -Nur -Xfreeciv/diff_ignore freeciv/common/tile.c 
freeciv-altered/common/tile.c
--- freeciv/common/tile.c       2005-05-07 07:22:25.000000000 -0400
+++ freeciv-altered/common/tile.c       2005-05-07 11:15:52.400583576 -0400
@@ -294,6 +294,66 @@
 }
 
 /****************************************************************************
+  Apply an activity (Activity_type_id, e.g. ACTIVITY_TRANSFORM) to a tile.
+  Return false if there was a error or if the activity is not implemented
+  by this function.
+****************************************************************************/
+bool tile_activity(struct tile *ptile, Activity_type_id act) 
+{
+  switch(act) {
+    
+  case ACTIVITY_POLLUTION:
+  case ACTIVITY_FALLOUT: 
+    tile_clear_dirtiness(ptile);
+    return TRUE;
+    
+  case ACTIVITY_MINE:
+    tile_mine(ptile);
+    return TRUE;
+
+  case ACTIVITY_IRRIGATE: 
+    tile_irrigate(ptile);
+    return TRUE;
+
+  case ACTIVITY_ROAD: 
+    if (!is_ocean(ptile->terrain)
+       && !tile_has_special(ptile, S_ROAD)) {
+      /* HACK: calling tile_set_special here will have side effects, so we
+       * have to set it manually. */
+      assert((ptile->special & S_ROAD) == 0);
+      ptile->special |= S_ROAD;
+      return TRUE;
+    }
+    return FALSE;
+
+  case ACTIVITY_RAILROAD:
+    if (!is_ocean(ptile->terrain)
+       && !tile_has_special(ptile, S_RAILROAD)) {
+      /* HACK: calling tile_set_special here will have side effects, so we
+       * have to set it manually. */
+      ptile->special |= (S_ROAD | S_RAILROAD);
+      return TRUE;
+    }
+    return FALSE;
+
+  case ACTIVITY_TRANSFORM:
+    tile_transform(ptile);
+    return TRUE;
+    
+  case ACTIVITY_FORTRESS:
+  case ACTIVITY_PILLAGE: 
+  case ACTIVITY_AIRBASE:   
+  default:
+    return FALSE;
+    /* do nothing  - not implemented */
+
+  }
+  return FALSE;
+}
+
+
+
+/****************************************************************************
   Return a (static) string with tile name describing terrain and specials.
 
   Examples:
diff -Nur -Xfreeciv/diff_ignore freeciv/common/tile.h 
freeciv-altered/common/tile.h
--- freeciv/common/tile.h       2005-05-07 07:22:25.000000000 -0400
+++ freeciv-altered/common/tile.h       2005-05-07 10:50:22.652140688 -0400
@@ -73,6 +73,7 @@
 int tile_activity_time(enum unit_activity activity,
                       const struct tile *ptile);
 
+bool tile_activity(struct tile *ptile, Activity_type_id act);
 void tile_change_terrain(struct tile *ptile, Terrain_type_id type);
 void tile_irrigate(struct tile *ptile);
 void tile_mine(struct tile *ptile);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13003) tile_activity patch, Brian Dunstan <=