Crossfire Server, Branches 1.12  R18729
image.c File Reference
#include <global.h>
#include <stdio.h>
#include "image.h"
+ Include dependency graph for image.c:

Go to the source code of this file.

Data Structures

struct  bmappair
 

Functions

static void check_faceset_fallback (int faceset, int togo)
 
static int compar (const struct bmappair *a, const struct bmappair *b)
 
static uint8 find_color (const char *name)
 
unsigned find_face (const char *name, unsigned error)
 
int find_smooth (uint16 face, uint16 *smoothed)
 
void free_all_images (void)
 
void free_socket_images (void)
 
int get_face_fallback (int faceset, int imageno)
 
int is_valid_faceset (int fsn)
 
void read_bmap_names (void)
 
void read_client_images (void)
 
static void read_face_data (void)
 
int read_smooth (void)
 

Variables

New_Faceblank_face
 
static const char *const colorname []
 
New_Faceempty_face
 
face_sets facesets [MAX_FACE_SETS]
 
New_Facenew_faces
 
static int nroffiles = 0
 
int nrofpixmaps = 0
 
New_Facesmooth_face
 
static struct bmappairxbm = NULL
 

Detailed Description

Handles face-related stuff, including the actual face data.

Definition in file image.c.

Function Documentation

static 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 435 of file image.c.

References face_sets::fallback, llevError, and LOG().

Referenced by read_client_images().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int compar ( const struct bmappair a,
const struct bmappair b 
)
static

Used for bsearch searching.

Definition at line 106 of file image.c.

References bmappair::name.

Referenced by find_face(), and read_bmap_names().

+ Here is the caller graph for this function:

static uint8 find_color ( const char *  name)
static

Finds a color by name.

Parameters
namecolor name, case-sensitive.
Returns
the matching color in the coloralias if found, 0 otherwise.
Note
0 will actually be black, so there is no way the calling function can tell if an error occurred or not

Definition at line 123 of file image.c.

References colorname, llevError, and LOG().

Referenced by read_bmap_names(), and read_face_data().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned find_face ( const char *  name,
unsigned  error 
)

This returns an the face number of face 'name'. Number is constant during an invocation, but not necessarily between versions (this is because the faces are arranged in alphabetical order, so if a face is removed or added, all faces after that will now have a different number.

Parameters
nameface to search for
errorvalue to return if face was not found.
Note
If a face is not found, then error is returned. This can be useful if you want some default face used, or can be set to negative so that it will be known that the face could not be found (needed in client, so that it will know to request that image from the server)

Definition at line 324 of file image.c.

References compar(), bmappair::name, nroffiles, and bmappair::number.

Referenced by cfapi_system_find_face(), init_anim(), read_bmap_names(), read_face_data(), read_smooth(), set_object_face_main(), set_object_face_other(), and transport_type_apply().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int find_smooth ( uint16  face,
uint16 smoothed 
)

Find the smooth face for a given face.

Parameters
facethe face to find the smoothing face for
smoothedreturn value: set to smooth face
Returns
1=smooth face found, 0=no smooth face found

Definition at line 401 of file image.c.

References nrofpixmaps, and new_face_struct::smoothface.

Referenced by send_smooth().

+ Here is the caller graph for this function:

void free_all_images ( void  )

Deallocates memory allocated by read_bmap_names() and read_smooth().

Definition at line 418 of file image.c.

References bmappair::name, and nroffiles.

Referenced by cleanup().

+ Here is the caller graph for this function:

void free_socket_images ( void  )

Frees all faceset information

Definition at line 584 of file image.c.

References MAX_FACE_SETS, and nrofpixmaps.

Referenced by free_all_newserver().

+ Here is the caller graph for this function:

int get_face_fallback ( int  faceset,
int  imageno 
)

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
facesetfaceset to check
imagenoimage number

Definition at line 614 of file image.c.

References get_face_fallback(), llevError, and LOG().

Referenced by esrv_send_face(), get_face_fallback(), process_map(), and send_image_sums().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int is_valid_faceset ( int  fsn)

Checks specified faceset is valid

Parameters
fsnfaceset number

Definition at line 575 of file image.c.

References FALSE, MAX_FACE_SETS, and TRUE.

Referenced by main(), and set_up_cmd().

+ Here is the caller graph for this function:

void read_bmap_names ( void  )

This reads the bmaps file to get all the bitmap names and stuff. It only needs to be done once, because it is player independent (ie, what display the person is on will not make a difference.)

Note
will call exit() if file doesn't exist, and abort() in case of memory error.

Definition at line 198 of file image.c.

References BLANK_FACE_NAME, bmaps_checksum, compar(), Settings::datadir, EMPTY_FACE_NAME, FACE_FLOOR, find_color(), find_face(), llevDebug, llevError, LOG(), new_face_struct::magicmap, MAX_BUF, new_face_struct::name, bmappair::name, nroffiles, nrofpixmaps, new_face_struct::number, bmappair::number, read_face_data(), ROTATE_RIGHT, settings, SMOOTH_FACE_NAME, new_face_struct::smoothface, snprintf(), strdup_local(), strerror_local(), and new_face_struct::visibility.

Referenced by cctk_init_std_archetypes(), and init_library().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 471 of file image.c.

References check_faceset_fallback(), face_info::checksum, close_and_delete(), face_sets::comment, face_info::data, Settings::datadir, face_info::datalen, face_sets::extension, face_sets::faces, face_sets::fallback, face_sets::fullname, HUGE_BUF, llevDebug, llevError, LOG(), MAX_FACE_SETS, MAX_IMAGE_SIZE, nrofpixmaps, open_and_uncompress(), face_sets::prefix, ROTATE_RIGHT, settings, face_sets::size, snprintf(), and strdup_local().

Referenced by init_server(), and main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void read_face_data ( void  )
static

This reads the lib/faces file, getting color and visibility information. it is called by read_bmap_names().

Note
will call exit() if file doesn't exist.

Definition at line 141 of file image.c.

References Settings::datadir, FACE_FLOOR, find_color(), find_face(), llevDebug, llevError, LOG(), new_face_struct::magicmap, MAX_BUF, settings, snprintf(), strerror_local(), and new_face_struct::visibility.

Referenced by read_bmap_names().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int read_smooth ( void  )

Reads the smooth file to know how to smooth datas. the smooth file if made of 2 elements lines. lines starting with # are comment the first element of line is face to smooth the next element is the 16x2 faces picture used for smoothing

Note
will call exit() if file can't be opened.

Definition at line 348 of file image.c.

References Settings::datadir, find_face(), llevDebug, llevError, LOG(), MAX_BUF, settings, new_face_struct::smoothface, snprintf(), and strerror_local().

Referenced by cctk_init_std_archetypes(), and init_library().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

New_Face* blank_face

Following can just as easily be pointers, but it is easier to keep them like this.

Definition at line 66 of file image.c.

Referenced by add_abilities(), animate_object(), CREUtils::artifactNode(), clear_object(), magic_mapping_mark(), magic_mapping_mark_recursive(), tear_down_wall(), update_position(), and write_rune().

const char* const colorname[]
static
Initial value:
= {
"black",
"white",
"blue",
"red",
"orange",
"light_blue",
"dark_orange",
"green",
"light_green",
"grey",
"brown",
"yellow",
"khaki"
}

The only thing this table is used for now is to translate the colorname in the magicmap field of the face into a numeric index that is then sent to the client for magic map commands. The order of this table must match that of the NDI colors in include/newclient.h.

Definition at line 87 of file image.c.

Referenced by find_color().

New_Face * empty_face

Definition at line 66 of file image.c.

Referenced by esrv_draw_look().

All facesets

Definition at line 78 of file image.c.

Referenced by esrv_send_face(), CREPixmap::getIcon(), main(), process_map(), send_image_info(), and send_image_sums().

int nroffiles = 0
static

nroffiles is the actual number of bitmaps defined.

Definition at line 70 of file image.c.

Referenced by find_face(), free_all_images(), and read_bmap_names().

int nrofpixmaps = 0

nrofpixmaps is the number of bitmaps loaded. With the automatic generation of the bmaps file, this is now equal to nroffiles.

Definition at line 76 of file image.c.

Referenced by do_server(), esrv_send_face(), CREResourcesWindow::fillFaces(), find_smooth(), free_socket_images(), init_connection(), main(), read_bmap_names(), read_client_images(), send_image_info(), and send_image_sums().

New_Face * smooth_face

Definition at line 66 of file image.c.

Referenced by send_smooth().

struct bmappair* xbm = NULL
static

The xbm array (which contains name and number information, and is then sorted) contains nroffiles entries.

Definition at line 60 of file image.c.