Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2003:
[Freeciv-Dev] (PR#3730) New Irrigation/Farmland System
Home

[Freeciv-Dev] (PR#3730) New Irrigation/Farmland System

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#3730) New Irrigation/Farmland System
From: "Rafa³ Bursig" <bursig@xxxxxxxxx>
Date: Fri, 14 Mar 2003 01:06:37 -0800
Reply-to: rt@xxxxxxxxxxxxxx

Hi
        This is my old code that I forget send to RT. It add support 
for Civ3 irrigation/farmland multi tile system and is compatible with 
current system.

Rafal

----------------------------------------------------------------------
GRA o WYSOKA stawke: Wolne etaty dla nowych trenerow! Nie zwlekaj!
>>> http://link.interia.pl/f16ec

diff -u -r ../store/freeciv/client/tilespec.c fc/client/tilespec.c
--- ../store/freeciv/client/tilespec.c  Thu Mar  6 00:59:03 2003
+++ fc/client/tilespec.c        Wed Mar 12 16:41:50 2003
@@ -832,8 +833,6 @@
   SET_SPRITE(user.attention, "user.attention");
 
   SET_SPRITE(tx.fallout,    "tx.fallout");
-  SET_SPRITE(tx.farmland,   "tx.farmland");
-  SET_SPRITE(tx.irrigation, "tx.irrigation");
   SET_SPRITE(tx.mine,       "tx.mine");
   SET_SPRITE_ALT(tx.oil_mine, "tx.oil_mine", "tx.mine");
   SET_SPRITE(tx.pollution,  "tx.pollution");
@@ -847,7 +846,29 @@
     my_snprintf(buffer, sizeof(buffer), "tx.s_river_%s", nsew_str(i));
     SET_SPRITE(tx.spec_river[i], buffer);
   }
+  
+  my_snprintf(buffer, sizeof(buffer), "tx.s_irrigation_%s", nsew_str(0));
+  if (hash_key_exists(sprite_hash, buffer)) {
+    for(i=0; i<NUM_DIRECTION_NSEW; i++) {
+      my_snprintf(buffer, sizeof(buffer), "tx.s_irrigation_%s", nsew_str(i));
+      SET_SPRITE(tx.spec_irrigation[i], buffer);
+    }
+  } else {
+    sprites.tx.spec_irrigation[0] = NULL;
+    SET_SPRITE(tx.irrigation, "tx.irrigation");
+  }
 
+  my_snprintf(buffer, sizeof(buffer), "tx.s_farmland_%s", nsew_str(0));
+  if (hash_key_exists(sprite_hash, buffer)) {
+    for(i=0; i<NUM_DIRECTION_NSEW; i++) {
+      my_snprintf(buffer, sizeof(buffer), "tx.s_farmland_%s", nsew_str(i));
+      SET_SPRITE(tx.spec_farmland[i], buffer);
+    }
+  } else {
+    sprites.tx.spec_farmland[0] = NULL;
+    SET_SPRITE(tx.farmland,   "tx.farmland");
+  }
+  
   if (is_isometric) {
     for(i=0; i<NUM_DIRECTION_NSEW; i++) {
       my_snprintf(buffer, sizeof(buffer), "tx.s_forest_%s", nsew_str(i));
@@ -1699,6 +1720,49 @@
 }
 
 /**********************************************************************
+...
+**********************************************************************/
+static struct Sprite * get_farmland_tile(enum tile_special_type *tspecial_near)
+{
+  
+  if (sprites.tx.spec_farmland[0])
+  {
+    return sprites.tx.spec_farmland[INDEX_NSEW(((tspecial_near[DIR8_NORTH] &
+                                             (S_FARMLAND | S_IRRIGATION)) > 0 
),
+                                            ((tspecial_near[DIR8_SOUTH] &
+                                              (S_FARMLAND | S_IRRIGATION)) > 
0),
+                                            ((tspecial_near[DIR8_EAST] &
+                                             (S_FARMLAND | S_IRRIGATION)) > 0),
+                                            ((tspecial_near[DIR8_WEST] &
+                                           (S_FARMLAND | S_IRRIGATION)) > 0 
))];         
+  }
+  
+  return sprites.tx.farmland;
+}
+
+/**********************************************************************
+...
+**********************************************************************/
+static struct Sprite * get_irrigation_tile(enum tile_special_type 
*tspecial_near)
+{
+  
+  if (sprites.tx.spec_irrigation[0])
+  {
+    return sprites.tx.spec_irrigation[INDEX_NSEW(((tspecial_near[DIR8_NORTH] &
+                                             (S_FARMLAND | S_IRRIGATION)) > 0 
),
+                                            ((tspecial_near[DIR8_SOUTH] &
+                                              (S_FARMLAND | S_IRRIGATION)) > 
0),
+                                            ((tspecial_near[DIR8_EAST] &
+                                             (S_FARMLAND | S_IRRIGATION)) > 0),
+                                            ((tspecial_near[DIR8_WEST] &
+                                           (S_FARMLAND | S_IRRIGATION)) > 0 
))];
+  }
+  
+  return sprites.tx.irrigation;
+}
+
+
+/**********************************************************************
 Fill in the sprite array for the tile at position (abs_x0,abs_y0).
 Does not fill in the city or unit; that have to be done seperatly in
 isometric view. Also, no fog here.
@@ -1782,9 +1846,9 @@
      
       if (contains_special(tspecial, S_IRRIGATION) && !pcity && 
draw_irrigation) {
        if (contains_special(tspecial, S_FARMLAND))
-         *sprs++ = sprites.tx.farmland;
+         *sprs++ = get_farmland_tile(tspecial_near);
        else
-         *sprs++ = sprites.tx.irrigation;
+         *sprs++ = get_irrigation_tile(tspecial_near);
       }
  
       if (contains_special(tspecial, S_RIVER)) {
@@ -1804,9 +1868,9 @@
 
     if (contains_special(tspecial, S_IRRIGATION) && !pcity && draw_irrigation) 
{
       if (contains_special(tspecial, S_FARMLAND))
-       *sprs++ = sprites.tx.farmland;
+       *sprs++ = get_farmland_tile(tspecial_near);
       else
-        *sprs++ = sprites.tx.irrigation;
+        *sprs++ = get_irrigation_tile(tspecial_near);
     }
   }
   
diff -u -r ../store/freeciv/client/tilespec.h fc/client/tilespec.h
--- ../store/freeciv/client/tilespec.h  Sun Feb  2 21:13:39 2003
+++ fc/client/tilespec.h        Wed Mar 12 16:39:50 2003
@@ -196,6 +196,8 @@
       *spec_forest[NUM_DIRECTION_NSEW],
       *spec_mountain[NUM_DIRECTION_NSEW],
       *spec_hill[NUM_DIRECTION_NSEW],
+      *spec_irrigation[NUM_DIRECTION_NSEW],
+      *spec_farmland[NUM_DIRECTION_NSEW],
       *coast_cape_iso[8][4], /* 4 = up down left right */
       /* for non-isometric */
       *coast_cape[NUM_DIRECTION_NSEW],       /* first unused */

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