Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

image.c File Reference

Image related communication. More...

#include <global.h>
#include <sproto.h>
#include <newclient.h>
#include <newserver.h>
#include <loader.h>

Go to the source code of this file.

Data Structures

struct  FaceInfo
 Information about one image. More...

struct  FaceSets
 Information about one face set. More...


Defines

#define MAX_FACE_SETS   20
 Maximum number of image sets the program will handle.

#define MAX_IMAGE_SIZE   10000

Typedefs

typedef FaceInfo FaceInfo
 Information about one image.


Functions

int is_valid_faceset (int fsn)
 Checks specified faceset is valid.

void free_socket_images ()
 Frees all faceset information.

int get_face_fallback (int faceset, int imageno)
 This returns the set we will actually use when sending a face.

void check_faceset_fallback (int faceset, int togo)
 Checks fallback are correctly defined.

void read_client_images ()
 Loads all the image types into memory.

void SetFaceMode (char *buf, int len, NewSocket *ns)
 Client tells us what type of faces it wants.

void SendFaceCmd (char *buff, int len, NewSocket *ns)
 Client has requested pixmap that it somehow missed getting.

void esrv_send_face (NewSocket *ns, short face_num, int nocache)
 Sends a face to the client.

void send_image_info (NewSocket *ns, char *params)
 Sends the number of images, checksum of the face file, and the image_info file information.

void send_image_sums (NewSocket *ns, char *params)
 Sends requested face information.


Variables

FaceSets facesets [MAX_FACE_SETS]
 All facesets.


Detailed Description

Image related communication.

Date:
2003-11-30
This file deals with the image related communication to the client. I've located all the functions in this file - this localizes it more, and means that we don't need to declare things like all the structures as globals.

Definition in file socket/image.c.


Define Documentation

#define MAX_FACE_SETS   20
 

Maximum number of image sets the program will handle.

Definition at line 47 of file socket/image.c.

Referenced by free_socket_images(), is_valid_faceset(), read_client_images(), and send_image_info().

#define MAX_IMAGE_SIZE   10000
 

Definition at line 157 of file socket/image.c.

Referenced by read_client_images().


Typedef Documentation

typedef struct FaceInfo FaceInfo
 

Information about one image.


Function Documentation

void check_faceset_fallback int  faceset,
int  togo
[static]
 

Checks fallback are correctly defined.

This is a simple recursive function that makes sure the fallbacks are all proper (eg, the fall back to defined sets, and also eventually fall back to 0). At the top level, togo is set to MAX_FACE_SETS, if togo gets to zero, it means we have a loop. This is only run when we first load the facesets.

Definition at line 138 of file socket/image.c.

References facesets, FaceSets::fallback, llevError, LOG(), and FaceSets::prefix.

Referenced by read_client_images().

void esrv_send_face NewSocket ns,
short  face_num,
int  nocache
 

Sends a face to the client.

Sends a face to a client if they are in pixmap mode nothing gets sent in bitmap mode. If nocache is true (nonzero), ignore the cache setting from the client - this is needed for the askface, in which we really do want to send the face (and askface is the only place that should be setting it). Otherwise, we look at the facecache, and if set, send the image name.

Definition at line 326 of file socket/image.c.

References SockList::buf, FaceInfo::data, FaceInfo::datalen, NewSocket::facecache, FaceSets::faces, NewSocket::faces_sent, NewSocket::faceset, facesets, get_face_fallback(), NewSocket::image2, SockList::len, llevError, LOG(), MAXSOCKBUF, new_face_struct::name, new_faces, nrofpixmaps, NewSocket::sc_version, Send_With_Handling(), SockList_AddChar(), SockList_AddInt(), and SockList_AddShort().

Referenced by AskSmooth(), check_head(), draw_client_map1(), esrv_draw_look(), esrv_map_setbelow(), esrv_send_animation(), esrv_send_inventory(), esrv_send_item(), esrv_update_item(), SendFaceCmd(), and update_space().

void free_socket_images void   ) 
 

Frees all faceset information.

Definition at line 82 of file socket/image.c.

References FaceInfo::data, FaceSets::faces, facesets, MAX_FACE_SETS, nrofpixmaps, FaceSets::prefix, and size.

Referenced by free_all_newserver().

int get_face_fallback int  faceset,
int  imageno
[static]
 

This returns the set we will actually use when sending a face.

This is used because the image files may be sparse. This function is recursive. imageno is the face number we are trying to send

If face is not found in specified faceset, tries with 'fallback' faceset.

Parameters:
faceset faceset to check
imageno image number

Definition at line 112 of file socket/image.c.

References FaceInfo::data, FaceSets::faces, facesets, llevError, LOG(), and FaceSets::prefix.

Referenced by esrv_send_face(), and send_image_sums().

int is_valid_faceset int  fsn  ) 
 

Checks specified faceset is valid.

Parameters:
fsn faceset number

Definition at line 73 of file socket/image.c.

References facesets, FALSE, MAX_FACE_SETS, FaceSets::prefix, and TRUE.

Referenced by SetUp().

void read_client_images void   ) 
 

Loads all the image types into memory.

This way, we can easily send them to the client. We should really do something better than abort on any errors - on the other hand, these are all fatal to the server (can't work around them), but the abort just seems a bit messy (exit would probably be better.)

Couple of notes: We assume that the faces are in a continous block. This works fine for now, but this could perhaps change in the future

Function largely rewritten May 2000 to be more general purpose. The server itself does not care what the image data is - to the server, it is just data it needs to allocate. As such, the code is written to do such.

Definition at line 176 of file socket/image.c.

References check_faceset_fallback(), FaceInfo::checksum, close_and_delete(), FaceInfo::data, Settings::datadir, FaceInfo::datalen, FaceSets::faces, facesets, HUGE_BUF, len, llevDebug, llevError, LOG(), MAX_FACE_SETS, MAX_IMAGE_SIZE, nrofpixmaps, open_and_uncompress(), FaceSets::prefix, ROTATE_RIGHT, settings, and strdup_local().

Referenced by init_ericserver().

void send_image_info NewSocket ns,
char *  params
 

Sends the number of images, checksum of the face file, and the image_info file information.

See the doc/Developers/protocol if you want further detail.

Definition at line 387 of file socket/image.c.

References bmaps_checksum, SockList::buf, FaceSets::comment, FaceSets::extension, facesets, FaceSets::fallback, FaceSets::fullname, SockList::len, MAX_FACE_SETS, MAXSOCKBUF, nrofpixmaps, FaceSets::prefix, Send_With_Handling(), and FaceSets::size.

Referenced by RequestInfo().

void send_image_sums NewSocket ns,
char *  params
 

Sends requested face information.

Parameters:
ns socket to send to
params contains first and last index of face
For each image in [start..stop] sends
  • checksum
  • name

Definition at line 416 of file socket/image.c.

References SockList::buf, cs_write_string(), NewSocket::faces_sent, NewSocket::faceset, facesets, get_face_fallback(), SockList::len, llevError, LOG(), MAX_BUF, MAXSOCKBUF, new_face_struct::name, new_faces, nrofpixmaps, Send_With_Handling(), SockList_AddChar(), SockList_AddInt(), and SockList_AddShort().

Referenced by RequestInfo().

void SendFaceCmd char *  buff,
int  len,
NewSocket ns
 

Client has requested pixmap that it somehow missed getting.

This will be called often if the client is caching images.

Definition at line 307 of file socket/image.c.

References esrv_send_face().

void SetFaceMode char *  buf,
int  len,
NewSocket ns
 

Client tells us what type of faces it wants.

Also sets the caching attribute.

Definition at line 281 of file socket/image.c.

References CF_FACE_CACHE, CF_FACE_NONE, CF_FACE_PNG, NewSocket::facecache, llevDebug, LOG(), NDI_RED, and Write_String_To_Socket().


Variable Documentation

FaceSets facesets[MAX_FACE_SETS] [static]
 

All facesets.

Definition at line 67 of file socket/image.c.

Referenced by check_faceset_fallback(), esrv_send_face(), free_socket_images(), get_face_fallback(), is_valid_faceset(), read_client_images(), send_image_info(), and send_image_sums().


Generated on Tue Dec 2 19:42:46 2003 for Crossfire by doxygen 1.3.4