[Freeciv-Dev] Re: example patch: [xy]_map_iterate
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Thu, Oct 04, 2001 at 07:58:22AM -0400, Jason Dorje Short wrote:
> Raimar Falke wrote:
> >
> > On Thu, Oct 04, 2001 at 07:00:01AM -0400, Jason Dorje Short wrote:
> > > Raimar Falke wrote:
> > > >
> > > > On Thu, Oct 04, 2001 at 05:57:09AM -0400, Jason Dorje Short wrote:
> > > > > There's a lot of code that can't use whole_map_iterate because the
> > > > > iteration has to happen in a certain order.
> > > >
> > > > What code? I don't have a good feeling with code that has such
> > > > dependencies. Printing the map?
> > >
> > > Printing the map (to some random text file, I presume) is part of it.
> > > Also saving the game and sending tiles across the network. These depend
> > > strictly upon the ordering, so are easy to fix using [xy]_map_iterate.
> >
> > So what code would be used (after preprocessor expansion) instead of
> >
> > for(y=0; y<map.ysize; y++) {
> > char *terline=secfile_lookup_str(file, "map.l%03d", y);
> >
> > for(x=0; x<map.xsize; x++) {
> > char ch=terline[x];
> >
> > with an isometric map? Will there be map.xsize and map.ysize in an
> > isometric map?
>
> There may be map.xsize and map.ysize; this depends on the
> implementation. You could also do a single array using map_pos_to_index
> and the inverse. In any case though there will be some single value
> that represents the maximum X and Y width; call them map_[xy]_size().
>
> for(y=0; y<map_y_size(); y++) {
> char *terline=...
>
> for(y=0; y<map_x_size(); x++) {
> char ch=terline[x];
> if(!is_normal_map_pos(x, y)) continue;
> ...
>
> But, some special handling may be necessary in the case of off-the-map
> coordinate positions. Everything will have to be fixed up case-by-case.
>
> > > Other examples don't iterate over the whole map...for instance some
> > > iterate over just the poles while others skip border positions. These
> > > can be done with whole_map_iterate by skipping invalid positions; the
> > > problem here is that the current definition of "valid" is
> > > topology-dependent (it assumes the current wrapping system). These will
> > > take a little time to figure out.
> >
> > For the poles I can imagine a rectangle_iterare.
>
> No...the problem is "polar" may vary from topology to topology. In an
> isometric map polar regions will run diagonally along two sides, so a
> rectangular iteration will not work. In the more general case, it may
> be desirable to have polar regions defined by the ruleset or server
> options - in a taurus topology, what regions are polar? Or, perhaps the
> ruleset should just define "north" and "south" and let the game figure
> it out (this would fail for a topology that was not well-oriented).
>
> static void make_fair(void)
> {
> whole_map_iterate(x, y) {
> if (!IS_POLAR(x, y)) {
> ...
> }
> } whole_map_iterate_end;
>
> Add to this complication: in make_fair() I'm not sure if the correct
> restriction is IS_POLAR (which is true of the northernmost and
> southernmost 2 tiles) or IS_NEAR_BORDER (also true of the northernmost
> and southernmost 2 tiles). Ross's patch has a cleverly incomprehensible
> algorithm for this that wouldn't work under isometric topologies - I
> can't tell from it one way or the other.
Now I have another basic question:
a
bcd
efghi
jkl
m
For which tiles is y==0? a OR e,b and a? Or isn't this an isometric
map? And the following is:?
/ North
n /
o p
q r s
t u
v
The same map rotated (non-isometric now):
n p s
o r u
q t v
The adjacent property is the same.
/
- # \4
| # # \
| # # # \/
6 # # #
| # # \
- # / 3
\
|--6-|
The game has to know somewhere the this map above is 3x4.
The more I think about this the more I think that the easiest way is
to leave the current system in place and introduce a new name/position
space. Normal positions are called map positions and the new ones are
called user positons. If there is a non-isometric map there would a
1:1 mapping of map pos to user pos and back. If there is a isometric
map is used the mapping would be more complicated. Neighbor properties
and distances are only defined on user positions.
Summary: before I don't understand this issue and especially the end
result fully there will be no changes by me. What
coordinates/positions are there? What semantic they represent (where
is north and south)?
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Understanding is a three-edged sword;
your side, their side, and the truth."
-- a well-known Vorlon
- [Freeciv-Dev] example patch: [xy]_map_iterate, Jason Dorje Short, 2001/10/04
- [Freeciv-Dev] Re: example patch: [xy]_map_iterate, Raimar Falke, 2001/10/04
- [Freeciv-Dev] Re: example patch: [xy]_map_iterate, Jason Dorje Short, 2001/10/04
- [Freeciv-Dev] Re: example patch: [xy]_map_iterate, Jason Dorje Short, 2001/10/04
- [Freeciv-Dev] Re: example patch: [xy]_map_iterate, Raimar Falke, 2001/10/04
- [Freeciv-Dev] Re: example patch: [xy]_map_iterate, Jason Dorje Short, 2001/10/04
- [Freeciv-Dev] Re: example patch: [xy]_map_iterate,
Raimar Falke <=
- [Freeciv-Dev] Re: example patch: [xy]_map_iterate, Jason Dorje Short, 2001/10/04
- [Freeciv-Dev] Re: example patch: [xy]_map_iterate, Raimar Falke, 2001/10/04
- [Freeciv-Dev] Re: example patch: [xy]_map_iterate, Jason Dorje Short, 2001/10/04
- [Freeciv-Dev] Re: example patch: [xy]_map_iterate, Raimar Falke, 2001/10/05
- [Freeciv-Dev] Re: example patch: [xy]_map_iterate, Jason Dorje Short, 2001/10/05
- [Freeciv-Dev] Re: example patch: [xy]_map_iterate, Raimar Falke, 2001/10/05
- [Freeciv-Dev] Re: example patch: [xy]_map_iterate, Jason Dorje Short, 2001/10/05
- [Freeciv-Dev] Re: example patch: [xy]_map_iterate, Raimar Falke, 2001/10/05
- [Freeciv-Dev] Re: example patch: [xy]_map_iterate, Jason Dorje Short, 2001/10/05
- [Freeciv-Dev] Re: example patch: [xy]_map_iterate, Raimar Falke, 2001/10/05
|
|