Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2000:
[Freeciv-Dev] [patch] unit fog of war
Home

[Freeciv-Dev] [patch] unit fog of war

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] [patch] unit fog of war
From: Thue Janus Kristensen <thue105@xxxxxxxxxxxxxxxxxx>
Date: Thu, 2 Mar 2000 23:30:25 +0100

First shot at fog of war - everything doesn't work yet, but I was hoping for a
little help. The basic client-server communication is ok, thought.

I have replaced 

enum known_type {
 TILE_UNKNOWN, TILE_KNOWN_NODRAW, TILE_KNOWN
};

with

enum known_type {
 TILE_UNKNOWN, TILE_KNOWN_NODRAW, TILE_KNOWN_FOGGED, TILE_KNOWN
};

and added an array of ints seen to the tile struct. As you know, on the server
side the tiles "int known" member is a bitvector indicating of a player knows a
tile, and it is an enum known_type on the client side.
The int array seen is used for remembering which tiles the players see, and
unused on the client side. The index of seen is the number of the player. The
int is an indicator of haw many units/cities that can see the tile, and is
counted up or down when a unit moves/city is founded.
The client only knows if the tile is fogged or not, ie TILE_KNOWN_FOGGED or
TILE_KNOWN. Info is only sendt when this changes.

Unit movements are only sendt to the players that can see the square where the
unit is. When a unit moves out of the unfogged area of a client it is removed
from the clients unitlist. SImilarly if the square where it stand is suddently
fogged. This is the responserbility of the client - it does it itself to all
units on a square when the square is fogged. (client/packhand.c ->
handle_tile_info)

Terrain changes (roads, etc) is send to all players, and so is cities and their
population.

A little unrelated, I have added a field "short unsigned sendt" to the tile
struct. This is a bitvector similar to the known field. It is used to indicate
if info about a TILE_KNOWN_NODRAW tile has been sendt to the client allready.
If so, updates about the terrain on that tile will be sendt to the client, and
the tile info wont be resendt unneccesarily (as it is now).

Thing that doesn't work:
- Savegames don't load properly - I will fix this (note: I havent changed the
savegame-format, and it won't be neccesery)

- Fogged squares isn't marked. Well, Right now I put an airbase on them to
check that fog of war is working properly. Grep for "FIXME" in server/maphand.c
to remove this. _robert_ allready made fogged graphics that can be used to
overlay fogged squares, but I have no idea how to use it :). Should be easy
enought if you know how - somebody help :)

- Edges of unknown territory not shown. I haven't been able to see why this
should stop working. In fact I haven't been able to track down how they are
drawn in the fisr place :). This should again be easy for someone into the
graphics. I must be the addition of the TILE_KNOWN_FOGGED field that did this,
or the fact that known is now never > TILE_KNOWN (it was as a hack before).

- AI and barbarians comfused. Not surpricingly :). We could solve this by
giving both unfogged view, which would be very easy to do. Or perhapse let the
easy AI remain comfused.

- I haven't tested other clients than the gui-gtk one. I have changed a few
TILE_KNOWN to TILE_KNOWN_FOGGED where appropriate, but no garanties.

-Thue

Attachment: fog_of_war.diff.bz2
Description: Binary data

Attachment: tiles-bad-fog.xpm.bz2
Description: Binary data


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