I'm working on making a Mac client based on the common code. I've got it working with the console, as you can see:
Anyhow, I need some help with the graphics. Questions follow.
What does create_and_rescale_image_from_data() actually do?
Can someone walk me through (in pseudocode or plain English or whatever) what I should be doing in it? The GTK and X clients do things with their respective graphic toolkits that I don't understand. If I knew what the point of the function was, I'd have a better chance at porting it to Mac.
What're the main image data structures?
Just in case I've missed some - what should I be watching for displaying and storing images?
I find this an interesting topic.
I would like to do something with the client or possibly the server myself,
with due credit to the creators of the original.
I cannot answer these questions too well, but I have been sifting through the code
for the X11 and GTK clients.
I am going to make some smart guesses but I might be wrong.
I am also going to risk telling you things that you are aware of.
Input from developers of the actual Crossfire game would be helpful.
this is a function that is part of the X11 libraries I think.
It takes an array of characters, and uses them to assign colors to a bitmap.
This bitmap has the chosen height and width, but the length of the input char array
must then be width * height.
Images are stored on the server, as is map data.
Maps are stored in the data structure "struct Map the_map" or similar name.
The map is the level that each player / client is active on.
The server dynamically opens maps as players enter them, allow alteration of monsters and items and walls, and if it is empty of clients for a certain time it becomes closed
and freed of changes.
The server handles multiple maps at a time.
"the_map" on the server side has coordinates "x" and "y",
and "the_map" on the client side has coordinates "mx" and "my".
As explained above, the server keeps track of the entire open map(s)
including what is out of the client's sight. Each instance of server-side "the_map"
is an entire map containing the static walls and the moving objects.
The client-side "the_map" is the same size as the server-side "the_map";
the size of the floor and static wall layout are downloaded as the client first enters the map: in x11.c "allocate_map( &the_map, MIN_ALLOCATED_MAP_SIZE, MIN_ALLOCATED_MAP_SIZE);" in client.h " #define MAP_MAX_SIZE 31
#define MIN_ALLOCATED_MAP_SIZE MAP_MAX_SIZE * 2 ".
This map must be updated by the server as the player moves
and the state of objects inside change.
(Confusion) from what I have read, display_map_doneupdate( ), display_mapcell_pixmap( ), and gen_draw_face( ) in the x11 client are just for refreshing the game window. They do involve the 11 x 11 visible screen, but do not send packets to the server.
The reason why I am confused is the lack of notification on the client side that anything needs update from the server, except if it is missing bitmaps or sounds, and when it sends commands.
The server keeps track of the client's "x" and "y" on its edition "the_map".
When the client moves, the server checks for collisions with creatures and walls,
updates these objects and other items, and after the effects of all clients and monsters / moving objects are calculated, updates its edition of "the_map".
The server sends its edition of "the_map" to the client, passing it through some masks
that I am not certain about.
The client applies the information from the server to its copy of "the_map" data structure.
** I can find the client main layer, but not find the code that uses packet data to update objects in the client-side "the_map" **
Display: in "xutil.c" allocate_map( ), print_map( ), reset_map_data( ) are used for the processing. For moving, on tiles where there is no server update, display_mapscroll( )
is used. ** this is where my understanding of "cleared" and "need update" is uncertain**
Now we wait for the client to announce another move.
Please post corrections to my errors, and answer my ** questions ** if you can.