| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
#include <global.h> |
| 35 |
#include <stdlib.h> |
| 36 |
#include <check.h> |
| 37 |
#include "../include/toolkit_common.h" |
| 38 |
|
| 39 |
#define STATUS_LOGDIR 0x0001 |
| 40 |
#define STATUS_DATADIR 0x0002 |
| 41 |
#define STATUS_CONFDIR 0x0004 |
| 42 |
|
| 43 |
#define STATUS_GLOBALS 0x0100 |
| 44 |
#define STATUS_HASHTABLE 0x0200 |
| 45 |
#define STATUS_OBJECTS 0x0400 |
| 46 |
#define STATUS_VARS 0x0800 |
| 47 |
#define STATUS_BLOCK 0x1000 |
| 48 |
#define STATUS_BMAP 0x2000 |
| 49 |
#define STATUS_ANIM 0x4000 |
| 50 |
#define STATUS_ARCH 0x8000 |
| 51 |
#define SET_TKFLAG(__flag) (status_flag |= __flag) |
| 52 |
#define CHECK_TKFLAG(__flag) (status_flag&__flag) |
| 53 |
#define CCTK_ASSERT(__flag) { \ |
| 54 |
if (!CHECK_TKFLAG(__flag)) \ |
| 55 |
fail("Improper initialisation, flag 0x%H", __flag);\ |
| 56 |
} |
| 57 |
|
| 58 |
static int status_flag = 0; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
void cctk_setlog(const char *logfile) { |
| 64 |
settings.logfilename = logfile; |
| 65 |
SET_TKFLAG(STATUS_LOGDIR); |
| 66 |
} |
| 67 |
|
| 68 |
void cctk_setdatadir(const char *datadir) { |
| 69 |
static char confdir[1024]; |
| 70 |
snprintf(confdir, sizeof(confdir), "%s/config", datadir); |
| 71 |
settings.datadir = datadir; |
| 72 |
settings.confdir = confdir; |
| 73 |
SET_TKFLAG(STATUS_DATADIR); |
| 74 |
SET_TKFLAG(STATUS_CONFDIR); |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
void cctk_init_std_archetypes(void) { |
| 83 |
CCTK_ASSERT((STATUS_LOGDIR|STATUS_DATADIR)); |
| 84 |
settings.archetypes = "archetypes"; |
| 85 |
settings.treasures = "treasures"; |
| 86 |
init_globals(); |
| 87 |
init_hash_table(); |
| 88 |
init_stats(FALSE); |
| 89 |
init_objects(); |
| 90 |
init_block(); |
| 91 |
read_bmap_names(); |
| 92 |
read_smooth(); |
| 93 |
init_anim(); |
| 94 |
init_archetypes(); |
| 95 |
SET_TKFLAG(STATUS_GLOBALS|STATUS_HASHTABLE|STATUS_OBJECTS|STATUS_VARS|STATUS_BLOCK|STATUS_BMAP|STATUS_ANIM|STATUS_ARCH); |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
object *cctk_create_game_object(const char *archname) { |
| 106 |
archetype *arch; |
| 107 |
object *obj; |
| 108 |
|
| 109 |
CCTK_ASSERT((STATUS_OBJECTS|STATUS_ARCH)); |
| 110 |
if (archname == NULL) |
| 111 |
archname = "empty_archetype"; |
| 112 |
arch = find_archetype(archname); |
| 113 |
if (arch == NULL) |
| 114 |
return NULL; |
| 115 |
obj = object_create_arch(arch); |
| 116 |
if (obj == NULL) |
| 117 |
return NULL; |
| 118 |
CLEAR_FLAG(obj, FLAG_FREED); |
| 119 |
return obj; |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
void cctk_set_object_strings(object *op, const char *string) { |
| 128 |
op->name = add_string(string); |
| 129 |
op->name_pl = add_string(string); |
| 130 |
op->title = add_string(string); |
| 131 |
op->race = add_string(string); |
| 132 |
op->slaying = add_string(string); |
| 133 |
op->skill = add_string(string); |
| 134 |
op->msg = add_string(string); |
| 135 |
op->lore = add_string(string); |
| 136 |
op->materialname = add_string(string); |
| 137 |
} |