[Freeciv-Dev] Re: to wrap or not to wrap?
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Raimar Falke wrote:
>
> On Wed, Oct 10, 2001 at 11:39:19AM -0400, Jason Dorje Short wrote:
> > Raimar Falke wrote:
> > >
> > > On Wed, Oct 10, 2001 at 10:34:13AM -0400, Jason Dorje Short wrote:
> > > > That is, if we limit our topologies to only those that wrap in simple
> > > > ways, we can write a wrap_map_pos(&vx, &vy) function that will wrap the
> > > > given coordinate pair [1] independent of it's being a actual tile. This
> > > > can be used practically as-is in the current client implementation,
> > > > although I strongly feel that this implementation is flawed and should
> > > > be fixed anyway.
> > Like I said, it is confusing and will probably lead to misuse.
>
> Usual question: who/what needs this? Note that the only wrapping
> occurs at the GUI and even this case will be no longer if the client
> draw each tile only one time.
AFAIK just the client.
Right now the client does only draw each tile one time. However, it
uses a "trick" to accomplish this:
/* x0, y0 is corner of canvas */
/* width, height are dimensions of canvas */
for (x=0; x<width; x++)
for (y=0; y<width; y++) {
x1 = x, y1 = y;
wrap_map_pos(&x1, &y1);
draw_tile(x0+x1, y0+y1);
}
See, (x1, y1) isn't an actual map position! It's a vector representing
the position of the tile on the map canvas. If the canvas is wider than
the map, then the tile *will* be drawn twice - but it'll be drawn in the
same position so nobody notices (this could easily be avoided by
restricting the size of the mapcanvas). The important point, though, is
that because (x1, y1) isn't an actual map position normalize_map_pos
can't be used on it.
The "correct" way to do the drawing is like this, IMO:
for (x=0; x<width; x++)
for (y=0; y<height; y++) {
x1 = x0+x, y1 = y0+y;
if (normalize_map_pos(&x1, &y1))
draw_tile(x1, y1);
else
draw_black_tile(x1, y1);
}
This uses only mathematically correct operations on the map position.
In the case of the overhead view it is still easy to avoid drawing tiles
multiple times [1] - you just restrict the size of the map canvas [2].
In the case of the isometric view the math would be harder but it would
still be possible.
Gaute pointed out before that it doesn't matter which set of coordinates
you choose to be proper/normal - it's just a convenience to make
everything happen within map.xsize/map.ysize. Mathematically this is
correct, but wrap_map_pos is not mathematically clean - the client MUST
have each vector returned by wrap_map_pos be exactly correct.
[1] Personally, I would prefer to have tiles drawn multiple times. But
that's just me...
[2] This really seems like the obvious solution. Does anyone know why
it wasn't used before?
jason
- [Freeciv-Dev] to wrap or not to wrap?, Jason Dorje Short, 2001/10/10
- [Freeciv-Dev] Re: to wrap or not to wrap?, Ross W. Wetmore, 2001/10/12
- [Freeciv-Dev] Re: to wrap or not to wrap?, Jason Dorje Short, 2001/10/13
- [Freeciv-Dev] Re: to wrap or not to wrap?, Ross W. Wetmore, 2001/10/15
- [Freeciv-Dev] Re: to wrap or not to wrap?, Jason Dorje Short, 2001/10/15
- [Freeciv-Dev] Re: to wrap or not to wrap?, Jason Dorje Short, 2001/10/15
- [Freeciv-Dev] Re: to wrap or not to wrap?, Raimar Falke, 2001/10/15
- [Freeciv-Dev] Re: to wrap or not to wrap?, Jason Dorje Short, 2001/10/15
|
|