graffiti.c File Reference


Detailed Description

Wall graffiti support for levels.

Purpose:
Module for handling wall graffities in levels.
Comment:
None.
Author:
Jon Skeet, Tomasz Lis
Date:
14 Oct 1997 - 22 Jul 2008
Copying and copyrights:
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Definition in file graffiti.c.

#include "graffiti.h"
#include "globals.h"
#include "lev_data.h"
#include "obj_column_def.h"
#include "obj_things.h"
#include "obj_slabs.h"
#include "obj_column.h"

Go to the source code of this file.

Functions

short level_free_graffiti (struct LEVEL *lvl)
 Frees the whole graffiti structure.
int graffiti_idx (struct LEVEL *lvl, int tx, int ty)
 Searches for graffiti at given tile and returns its index.
int graffiti_idx_next (struct LEVEL *lvl, int tx, int ty, int prev_idx)
 Searches for next graffiti at given tile and returns its index.
char * get_graffiti_text (struct LEVEL *lvl, unsigned int num)
 Gets text message of graffiti with given index.
void graffiti_del (struct LEVEL *lvl, unsigned int num)
 Deletes graffiti with given index.
struct DK_GRAFFITIcreate_graffiti (int tx, int ty, char *text, const struct LEVEL *lvl, int orient)
 Creates a new graffiti and fills its all properties.
int graffiti_add_obj (struct LEVEL *lvl, struct DK_GRAFFITI *graf)
 Adds graffiti object to level data, without filling the graffiti nor updating slabs.
short set_graffiti_orientation (struct DK_GRAFFITI *graf, const struct LEVEL *lvl, unsigned short orient)
 Sets orientation of given graffiti, updating its dimensions and height.
int set_graffiti_height (struct DK_GRAFFITI *graf, int height)
 Sets new height to the graffiti.
int graffiti_add (struct LEVEL *lvl, int tx, int ty, int height, char *text, int font, unsigned short orient, unsigned short cube)
 Creates and adds graffiti to the level.
void graffiti_update_columns (struct LEVEL *lvl, int graf_idx)
 Updates CLM entries to make the graffiti visible.
void graffiti_clear_from_columns (struct LEVEL *lvl, int graf_idx)
 Updates CLM entries, removing graffiti from them.
unsigned int get_graffiti_count (struct LEVEL *lvl)
 Gets amount of graffitties in the level.
struct DK_GRAFFITIget_graffiti (struct LEVEL *lvl, int graf_idx)
 Gets the graffiti structure for given graffiti index.
int compute_graffiti_subtl_length (unsigned short font, char *text)
 Computes graffiti text length in subtiles, for given font.
int get_graffiti_cube_height (unsigned short font, char *text)
 Returns graffiti text height in subtiles, for given font.
const unsigned char * get_font_char (unsigned short font, char chr)
 Returns graffiti character for given font.
int place_graffiti_on_slab (struct COLUMN_REC *clm_recs[9], struct LEVEL *lvl, int tx, int ty)
 Draws graffiti on given columns array.
short place_graffiti_on_clm_top (struct COLUMN_REC *clm_rec, unsigned short font, unsigned short height, char *text, int graf_subtl, int graf_subtl_h, unsigned short cube)
 Places graffiti on top of given column.
short place_graffiti_on_column (struct COLUMN_REC *clm_rec, unsigned short font, unsigned short height, char *text, int graf_subtl, unsigned short cube)
 Places graffiti on side of given column.


Function Documentation

int compute_graffiti_subtl_length ( unsigned short  font,
char *  text 
)

Computes graffiti text length in subtiles, for given font.

Parameters:
font Graffiti font, from GRAFFITI_FONT enumeration.
text The graffiti message text.
Returns:
Returns length of the graffiti, in subtiles.

Definition at line 434 of file graffiti.c.

Referenced by place_graffiti_on_slab().

struct DK_GRAFFITI* create_graffiti ( int  tx,
int  ty,
char *  text,
const struct LEVEL lvl,
int  orient 
) [read]

Creates a new graffiti and fills its all properties.

The graffiti is not added to LEVEL structure.

Parameters:
tx Map tile coordinate, in range 0-MAP_MAXINDEX_X.
ty Map tile coordinate, in range 0-MAP_MAXINDEX_Y.
text The message text which is duplicated into graffiti.
lvl Pointer to the LEVEL structure.
orient Graffiti orientation, from GRAFFITI_ORIENT enumeration.
Returns:
Returns the new graffiti, or NULL on error.

Definition at line 138 of file graffiti.c.

Referenced by graffiti_add().

const unsigned char* get_font_char ( unsigned short  font,
char  chr 
)

Returns graffiti character for given font.

Parameters:
font Graffiti font, from GRAFFITI_FONT enumeration.
chr The text character.
Returns:
Returns font character to use for making graffiti visible.

Definition at line 490 of file graffiti.c.

Referenced by compute_graffiti_subtl_length(), place_graffiti_on_clm_top(), place_graffiti_on_column(), and set_graffiti_orientation().

struct DK_GRAFFITI* get_graffiti ( struct LEVEL lvl,
int  graf_idx 
) [read]

Gets the graffiti structure for given graffiti index.

Parameters:
lvl Pointer to the LEVEL structure.
graf_idx Graffiti index.
Returns:
Returns DK_GRAFFITI structure pointer, NULL on error.

Definition at line 422 of file graffiti.c.

Referenced by graffiti_clear_from_columns(), graffiti_update_columns(), and place_graffiti_on_slab().

unsigned int get_graffiti_count ( struct LEVEL lvl  ) 

Gets amount of graffitties in the level.

Parameters:
lvl Pointer to the LEVEL structure.
Returns:
Returns graffities count for the level.

Definition at line 410 of file graffiti.c.

Referenced by get_level_objstats_textln().

int get_graffiti_cube_height ( unsigned short  font,
char *  text 
)

Returns graffiti text height in subtiles, for given font.

Parameters:
font Graffiti font, from GRAFFITI_FONT enumeration.
text The graffiti message text.
Returns:
Returns graffiti height, in cubes (or subtiles).

Definition at line 469 of file graffiti.c.

Referenced by place_graffiti_on_slab(), set_graffiti_height(), and set_graffiti_orientation().

char* get_graffiti_text ( struct LEVEL lvl,
unsigned int  num 
)

Gets text message of graffiti with given index.

Parameters:
lvl Pointer to the LEVEL structure.
num Graffiti index.
Returns:
Returns graffiti message string, or empty string ("") on error.

Definition at line 90 of file graffiti.c.

int graffiti_add ( struct LEVEL lvl,
int  tx,
int  ty,
int  height,
char *  text,
int  font,
unsigned short  orient,
unsigned short  cube 
)

Creates and adds graffiti to the level.

Parameters:
lvl Pointer to the LEVEL structure.
tx Map tile coordinate, in range 0-MAP_MAXINDEX_X.
ty Map tile coordinate, in range 0-MAP_MAXINDEX_Y.
height Graffiti height.
text The graffiti message text.
font Graffiti font, from GRAFFITI_FONT enumeration.
orient Graffiti orientation, from GRAFFITI_ORIENT enumeration.
cube Index of the cube used to draw graffiti text.
Returns:
Returns the index at which graffiti is added, or -1 on error.

Definition at line 346 of file graffiti.c.

Referenced by execute_adikted_command().

int graffiti_add_obj ( struct LEVEL lvl,
struct DK_GRAFFITI graf 
)

Adds graffiti object to level data, without filling the graffiti nor updating slabs.

Parameters:
lvl Pointer to the LEVEL structure.
graf Pointer to the DK_GRAFFITI structure to add.
Returns:
Returns the index at which graffiti is added, or -1 on error.

Definition at line 167 of file graffiti.c.

Referenced by graffiti_add().

void graffiti_clear_from_columns ( struct LEVEL lvl,
int  graf_idx 
)

Updates CLM entries, removing graffiti from them.

This makes the graffiti invisuble and ready to be deleted.

Parameters:
lvl Pointer to the LEVEL structure.
graf_idx Graffiti index.

Definition at line 384 of file graffiti.c.

void graffiti_del ( struct LEVEL lvl,
unsigned int  num 
)

Deletes graffiti with given index.

The graffiti is removed from structure, and its memory is freed. Level graphics is not updated by this function.

Parameters:
lvl Pointer to the LEVEL structure.
num Graffiti index.

Definition at line 104 of file graffiti.c.

int graffiti_idx ( struct LEVEL lvl,
int  tx,
int  ty 
)

Searches for graffiti at given tile and returns its index.

Parameters:
lvl Pointer to the LEVEL structure.
tx,ty Map tile coordinates.
Returns:
Returns index of first graffiti at given tile, or -1 if not found.

Definition at line 51 of file graffiti.c.

Referenced by slab_has_custom_columns(), and update_custom_columns_for_slab().

int graffiti_idx_next ( struct LEVEL lvl,
int  tx,
int  ty,
int  prev_idx 
)

Searches for next graffiti at given tile and returns its index.

Parameters:
lvl Pointer to the LEVEL structure.
tx Map tile coordinate, in range 0-MAP_MAXINDEX_X.
ty Map tile coordinate, in range 0-MAP_MAXINDEX_Y.
prev_idx index if the graffiti previously found. To get first graffiti, prev_idx must be -1.
Returns:
Returns index of next graffiti at given tile, the one after prev_idx; or -1 if not found.

Definition at line 66 of file graffiti.c.

Referenced by graffiti_idx(), and place_graffiti_on_slab().

void graffiti_update_columns ( struct LEVEL lvl,
int  graf_idx 
)

Updates CLM entries to make the graffiti visible.

Parameters:
lvl Pointer to the LEVEL structure.
graf_idx Graffiti index.

Definition at line 369 of file graffiti.c.

short level_free_graffiti ( struct LEVEL lvl  ) 

Frees the whole graffiti structure.

Parameters:
lvl Pointer to the LEVEL structure.
Returns:
Returns ERR_NONE on success, error code on failure.

Definition at line 32 of file graffiti.c.

Referenced by level_free().

short place_graffiti_on_clm_top ( struct COLUMN_REC clm_rec,
unsigned short  font,
unsigned short  height,
char *  text,
int  graf_subtl,
int  graf_subtl_h,
unsigned short  cube 
)

Places graffiti on top of given column.

Parameters:
clm_rec Comumn entry struct pointer.
font Graffiti font, from GRAFFITI_FONT enumeration.
height Graffiti height.
text The graffiti message text.
graf_subtl The subtile at which we're placing.
graf_subtl_h The subtile at which we're placing, on height.
cube Index of the cube to place as graffiti.
Returns:
Returns true on success.

Definition at line 605 of file graffiti.c.

Referenced by place_graffiti_on_slab().

short place_graffiti_on_column ( struct COLUMN_REC clm_rec,
unsigned short  font,
unsigned short  height,
char *  text,
int  graf_subtl,
unsigned short  cube 
)

Places graffiti on side of given column.

Parameters:
clm_rec Comumn entry struct pointer.
font Graffiti font, from GRAFFITI_FONT enumeration.
height Graffiti height.
text The graffiti message text.
graf_subtl The subtile at which we're placing.
cube Index of the cube to place as graffiti.
Returns:
Returns true on success.

Definition at line 654 of file graffiti.c.

Referenced by place_graffiti_on_slab().

int place_graffiti_on_slab ( struct COLUMN_REC clm_recs[9],
struct LEVEL lvl,
int  tx,
int  ty 
)

Draws graffiti on given columns array.

Parameters:
clm_recs Comumn entries array.
lvl Pointer to the LEVEL structure.
tx Map tile coordinate, in range 0-MAP_MAXINDEX_X.
ty Map tile coordinate, in range 0-MAP_MAXINDEX_Y.
Returns:
Returns num of changed entries.

Definition at line 511 of file graffiti.c.

Referenced by update_custom_columns_for_slab().

int set_graffiti_height ( struct DK_GRAFFITI graf,
int  height 
)

Sets new height to the graffiti.

Makes sure the parameter will be in appropiate range.

Parameters:
graf Pointer to the DK_GRAFFITI structure to update.
height New graffiti height.
Returns:
Returns the new height set for graffiti.

Definition at line 308 of file graffiti.c.

short set_graffiti_orientation ( struct DK_GRAFFITI graf,
const struct LEVEL lvl,
unsigned short  orient 
)

Sets orientation of given graffiti, updating its dimensions and height.

Graffiti don't have to be in the LEVEL structure, but must have tx,ty,font and text properties set.

Parameters:
graf Pointer to the DK_GRAFFITI structure to update.
lvl Pointer to the LEVEL structure.
orient New graffiti orientation, from GRAFFITI_ORIENT enumeration.
Returns:
Returns ERR_NONE on success, error code on failure.

Definition at line 193 of file graffiti.c.

Referenced by create_graffiti().


Generated on Tue Sep 2 18:51:48 2008 for libAdikted by  doxygen 1.5.6