[Freeciv-Dev] (PR#8608) tall terrain
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=8608 >
http://freeciv.org/~jdorje/mountains.png
The above screenshot uses mountains and hills similar to those in civ3.
(Of course they don't match the rest of the terrain; that's beside the
point for now.)
In current freeciv all terrain can only be NORMAL_TILE_HEIGHT tall. By
comarison units (and a few other sprites) can be UNIT_TILE_HEIGHT pixels
high. But the mountains in the above screenshot are "tall" just like
units. This requires a few code changes to make work.
The attached patch adds some new options to the terrain layer data in
the tilespec file:
[terrain_mountains]
is_blended = 1
num_layers = 2
layer1_match_type = 2
layer1_is_tall = 1
layer1_offset_y = 8
mine_sprite = "tx.mine"
The new options are
- is_tall: specifies that the terrain is "tall" and covers the
UNIT_TILE_HEIGHT.
- offset_x/offset_y: specifies an offset for the drawing of the terrain.
In the above example mountains are tall and are drawn 8 pixels off of
the top of the "unit" box.
jason
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.164
diff -u -r1.164 tilespec.c
--- client/tilespec.c 26 Apr 2004 21:26:58 -0000 1.164
+++ client/tilespec.c 27 Apr 2004 21:17:32 -0000
@@ -762,6 +762,15 @@
terr->num_layers = MAX(1, terr->num_layers);
for (l = 0; l < terr->num_layers; l++) {
+ terr->layer[l].is_tall
+ = secfile_lookup_bool_default(file, FALSE, "%s.layer%d_is_tall",
+ terrains[i], l);
+ terr->layer[l].offset_x
+ = secfile_lookup_int_default(file, 0, "%s.layer%d_offset_x",
+ terrains[i], l);
+ terr->layer[l].offset_y
+ = secfile_lookup_int_default(file, 0, "%s.layer%d_offset_y",
+ terrains[i], l);
terr->layer[l].match_type
= secfile_lookup_int_default(file, 0, "%s.layer%d_match_type",
terrains[i], l);
@@ -772,6 +781,16 @@
terr->layer[l].cell_type = CELL_SINGLE;
} else if (mystrcasecmp(cell_type, "rect") == 0) {
terr->layer[l].cell_type = CELL_RECT;
+ if (terr->layer[l].is_tall
+ || terr->layer[l].offset_x > 0
+ || terr->layer[l].offset_y > 0) {
+ freelog(LOG_ERROR,
+ _("Error in %s layer %d: you cannot have tall terrain or\n"
+ "a sprite offset with a cell-based drawing method."),
+ terrains[i], l);
+ terr->layer[l].is_tall = FALSE;
+ terr->layer[l].offset_x = terr->layer[l].offset_y = 0;
+ }
} else {
freelog(LOG_ERROR, "Unknown cell type %s for %s.",
cell_type, terrains[i]);
@@ -1981,7 +2000,9 @@
tileno = INDEX_NSEW(MATCH(DIR8_NORTH), MATCH(DIR8_SOUTH),
MATCH(DIR8_EAST), MATCH(DIR8_WEST));
- ADD_SPRITE_SIMPLE(draw->layer[l].match[tileno]);
+ ADD_SPRITE(draw->layer[l].match[tileno],
+ draw->layer[l].is_tall ? DRAW_FULL : DRAW_NORMAL,
+ TRUE, draw->layer[l].offset_x, draw->layer[l].offset_y);
} else if (draw->layer[l].cell_type == CELL_RECT) {
/* Divide the tile up into four rectangular cells. Now each of these
* cells covers one corner, and each is adjacent to 3 different
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.65
diff -u -r1.65 tilespec.h
--- client/tilespec.h 26 Apr 2004 21:26:58 -0000 1.65
+++ client/tilespec.h 27 Apr 2004 21:17:32 -0000
@@ -114,6 +114,8 @@
int num_layers; /* Can only be 1 or 2. */
struct {
+ bool is_tall;
+ int offset_x, offset_y;
int match_type;
enum cell_type cell_type;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#8608) tall terrain,
Jason Short <=
|
|