Crossfire Server, Branches 1.12  R18729
toolkit_common.c
Go to the documentation of this file.
1 /*
2  * static char *rcsid_check_object_c =
3  * "$Id: toolkit_common.c 11578 2009-02-23 22:02:27Z lalo $";
4  */
5 
6 /*
7  * CrossFire, A Multiplayer game for X-windows
8  *
9  * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
10  * Copyright (C) 1992 Frank Tore Johansen
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25  *
26  * The authors can be reached via e-mail at crossfire-devel@real-time.com
27  */
28 
29 /*
30  * This is the toolkit for common only operations
31  * All methods should start with cctk (common check toolkit)
32  */
33 
34 #include <global.h>
35 #include <stdlib.h>
36 #include <check.h>
37 
38 #define STATUS_LOGDIR 0x0001
39 #define STATUS_DATADIR 0x0002
40 
41 #define STATUS_GLOBALS 0x0100
42 #define STATUS_HASHTABLE 0x0200
43 #define STATUS_OBJECTS 0x0400
44 #define STATUS_VARS 0x0800
45 #define STATUS_BLOCK 0x1000
46 #define STATUS_BMAP 0x2000
47 #define STATUS_ANIM 0x4000
48 #define STATUS_ARCH 0x8000
49 #define SET_TKFLAG(__flag) (status_flag |= __flag)
50 #define CHECK_TKFLAG(__flag) (status_flag&__flag)
51 #define CCTK_ASSERT(__flag) { \
52  if (!CHECK_TKFLAG(__flag)) \
53  fail("Improper initialisation, flag 0x%H", __flag);\
54  }
55 
56 static int status_flag = 0;
57 
61 void cctk_setlog(char *logfile) {
64 }
65 
66 void cctk_setdatadir(char *datadir) {
67  settings.datadir = datadir;
69 }
77  settings.archetypes = "archetypes";
78  settings.treasures = "treasures.bld";
79  init_globals();
81  init_objects();
82  init_vars();
83  init_block();
85  read_smooth();
86  init_anim();
89 }
90 
98 object *cctk_create_game_object(const char *archname) {
99  archetype *arch;
100  object *obj;
101 
103  if (archname == NULL)
104  archname = "empty_archetype";
105  arch = find_archetype(archname);
106  if (arch == NULL)
107  return NULL;
108  obj = object_create_arch(arch);
109  if (obj == NULL)
110  return NULL;
111  CLEAR_FLAG(obj, FLAG_FREED);
112  return obj;
113 }
120 void cctk_set_object_strings(object *op, char *string) {
121  op->name = add_string(string);
122  op->name_pl = add_string(string);
123  op->title = add_string(string);
124  op->race = add_string(string);
125  op->slaying = add_string(string);
126  op->skill = add_string(string);
127  op->msg = add_string(string);
128  op->lore = add_string(string);
129  op->materialname = add_string(string);
130 }
EXTERN FILE * logfile
Definition: global.h:220
void cctk_setdatadir(char *datadir)
Definition: object.h:132
archetype * find_archetype(const char *name)
Definition: arch.c:700
void init_anim(void)
Definition: anim.c:55
const char * race
Definition: object.h:171
void init_block(void)
Definition: los.c:102
#define CCTK_ASSERT(__flag)
#define STATUS_DATADIR
void init_vars(void)
const char * slaying
Definition: object.h:172
void init_archetypes(void)
Definition: arch.c:195
#define STATUS_ARCH
void init_globals(void)
Definition: init.c:263
#define STATUS_GLOBALS
const char * treasures
Definition: global.h:340
Definition: object.h:321
const char * logfilename
Definition: global.h:325
#define STATUS_BMAP
const char * lore
Definition: object.h:176
const char * title
Definition: object.h:170
void init_hash_table(void)
Definition: shstr.c:47
int read_smooth(void)
Definition: image.c:348
const char * name_pl
Definition: object.h:168
#define SET_TKFLAG(__flag)
const char * materialname
Definition: object.h:197
void cctk_set_object_strings(object *op, char *string)
#define STATUS_BLOCK
const char * name
Definition: object.h:167
static int status_flag
const char * archetypes
Definition: global.h:338
#define CLEAR_FLAG(xyz, p)
Definition: define.h:512
void cctk_setlog(char *logfile)
#define STATUS_HASHTABLE
object * object_create_arch(archetype *at)
Definition: arch.c:741
const char * skill
Definition: object.h:174
void read_bmap_names(void)
Definition: image.c:198
#define STATUS_ANIM
const char * datadir
Definition: global.h:334
void init_objects(void)
Definition: init.c:347
object * cctk_create_game_object(const char *archname)
#define STATUS_LOGDIR
#define STATUS_OBJECTS
struct Settings settings
Definition: init.c:48
#define STATUS_VARS
const char * msg
Definition: object.h:175
sstring add_string(const char *str)
Definition: shstr.c:116
#define FLAG_FREED
Definition: define.h:529
void cctk_init_std_archetypes(void)