Crossfire Server, Trunk
|
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <global.h>
#include <sys/stat.h>
#include "sproto.h"
Go to the source code of this file.
Data Structures | |
struct | string_array |
Macros | |
#define | LO_NEWFILE 2 |
#define | MAX_SIZE 64 |
#define | NA "n/a" |
Typedefs | |
typedef struct string_array | String_Array |
Functions | |
static char * | cat_template (char *source, char *add) |
static char * | do_template (const char *tpl, const char **vars, const char **values) |
void | free_data (String_Array *array) |
static void | free_if_used (char *p) |
const char * | join_with_comma (String_Array *array) |
int | main (int argc, char *argv[]) |
void | push (String_Array *array, const char *string) |
static int | read_template (const char *name, char **buffer) |
void | set_map_timeout (void) |
static int | sort_archetypes (const void *a, const void *b) |
static int | sortbyname (const void *a, const void *b) |
Variables | |
const char *const | flag_names [NUM_FLAGS+1] |
char * | monster_attack_row |
char * | monster_canuse_row |
char * | monster_entry |
char * | monster_lore_row |
char * | monster_page_foot |
char * | monster_page_head |
char * | monster_protected_row |
char * | monster_special_row |
char * | monster_vulnerable_row |
typedef struct string_array String_Array |
|
static |
|
static |
Processes a template.
Variables in the form #VARIABLE#
will be substituted for specified values.
template | template to process. |
vars | variables to replace. Array must be NULL-terminated. |
values | variables to replace by. Must be the same size as vars, no NULL element allowed. |
Definition at line 190 of file bwp.cpp.
References disinfect::count, and rotate-tower::result.
Referenced by main().
void free_data | ( | String_Array * | array | ) |
|
static |
Frees memory if the pointer was ever given a string.
There's probably a cleaner way to do this, but this frees the memory given to a pointer if the pointer points to a string longer than zero length. It's to get rid of "in free(): warning: junk pointer, too high to make sense" errors.
p | Pointer to free memory from |
const char* join_with_comma | ( | String_Array * | array | ) |
Joins strings with a comma and space.
Takes an array of strings and joins them togther with a comma and a space between each of them.
array | Pointer to struct of type String_Array, containing strings to join |
Definition at line 349 of file bwp.cpp.
References sortbyname().
Referenced by main().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 366 of file bwp.cpp.
References living::ac, object::attacktype, attacktype_desc, buf, archetype::clone, string_array::count, do_template(), living::exp, object::face, FLAG_ALIVE, FLAG_MONSTER, flag_names, free_data(), get_next_archetype(), living::hp, init_globals(), init_gods(), init_library(), init_readable(), string_array::item, join_with_comma(), castle_read::key, llevError, llevInfo, LOG(), object::lore, MAX_BUF, monster_attack_row, monster_canuse_row, monster_entry, monster_lore_row, monster_page_foot, monster_page_head, monster_protected_row, monster_special_row, monster_vulnerable_row, NA, Face::name, object::name, archetype::name, NROFATTACKS, NUM_FLAGS, push(), QUERY_FLAG, object::race, read_template(), altar_valkyrie::res, object::resist, sort_archetypes(), object::stats, and tolower.
void push | ( | String_Array * | array, |
const char * | string | ||
) |
Add a string to a String_Array struct
Adds the new string to the struct's 'item' array, and updates the 'count'value.
array | The array to be appended |
string | The new string to append |
Definition at line 315 of file bwp.cpp.
References strdup_local.
Referenced by check_trigger(), and main().
|
static |
Reads a file in memory.
name | file path to read. |
buffer | where to store. Can be left uninitialized in case of errors. |
Definition at line 136 of file bwp.cpp.
References mad_mage_user::file, and give::name.
Referenced by main().
|
static |
Sort archetypes alphabetically
Used by qsort to sort archetypes alphabetically without regard to case
a | First value |
b | Second value |
Definition at line 293 of file bwp.cpp.
References disinfect::a, Ice::b, archetype::clone, object::name, and strcasecmp().
Referenced by main().
|
static |
Sort values alphabetically
Used by qsort to sort values alphabetically without regard to case
a | First value |
b | Second value |
Definition at line 276 of file bwp.cpp.
References disinfect::a, Ice::b, and strcasecmp().
Referenced by join_with_comma().
const char* const flag_names[NUM_FLAGS+1] |
This is a list of pointers that correspond to the FLAG_.. values. This is a simple 1:1 mapping - if FLAG_FRIENDLY is 15, then the 15'th element of this array should match that name. If an entry is NULL, that is a flag not to loaded/saved.
Copied from common/loader.c; perhaps should be defined elsewhere?
Definition at line 74 of file bwp.cpp.
Referenced by main().