Crossfire Server, Trunk  R21524
toolkit_common.c
Go to the documentation of this file.
1 /*
2  * static char *rcsid_check_object_c =
3  * "$Id: toolkit_common.c 21405 2020-09-12 01:02:52Z toxicfrog $";
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 #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 
63 void cctk_setlog(const char *logfile) {
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;
75 }
76 
84  settings.archetypes = "archetypes";
85  settings.treasures = "treasures";
86  init_globals();
89  init_objects();
90  init_block();
92  read_smooth();
93  init_anim();
96 }
97 
105 object *cctk_create_game_object(const char *archname) {
106  archetype *arch;
107  object *obj;
108 
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 }
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 }
EXTERN FILE * logfile
Definition: global.h:140
Definition: object.h:274
void cctk_set_object_strings(object *op, const char *string)
archetype * find_archetype(const char *name)
Definition: arch.c:696
void init_anim(void)
Definition: anim.c:46
const char * race
Definition: object.h:318
void init_block(void)
Definition: los.c:88
#define CCTK_ASSERT(__flag)
void init_objects(void)
Definition: object.c:93
#define STATUS_DATADIR
const char * slaying
Definition: object.h:319
void init_archetypes(void)
Definition: arch.c:183
#define STATUS_ARCH
void init_globals(void)
Definition: init.c:257
void cctk_setdatadir(const char *datadir)
#define STATUS_GLOBALS
#define FALSE
Definition: compat.h:11
const char * treasures
Definition: global.h:253
Definition: object.h:467
const char * logfilename
Definition: global.h:241
#define STATUS_BMAP
const char * lore
Definition: object.h:323
const char * title
Definition: object.h:317
void init_hash_table(void)
Definition: shstr.c:55
int read_smooth(void)
Definition: image.c:332
const char * name_pl
Definition: object.h:315
#define SET_TKFLAG(__flag)
const char * materialname
Definition: object.h:347
#define snprintf
Definition: win32.h:46
#define STATUS_BLOCK
const char * name
Definition: object.h:311
static int status_flag
const char * archetypes
Definition: global.h:251
#define CLEAR_FLAG(xyz, p)
Definition: define.h:224
#define STATUS_HASHTABLE
object * object_create_arch(archetype *at)
Definition: arch.c:737
const char * skill
Definition: object.h:321
const char * confdir
Definition: global.h:246
void read_bmap_names(void)
Definition: image.c:196
#define STATUS_ANIM
const char * datadir
Definition: global.h:247
object * cctk_create_game_object(const char *archname)
#define STATUS_LOGDIR
#define STATUS_OBJECTS
void init_stats(int reload)
Definition: living.c:2588
struct Settings settings
Definition: init.c:39
#define STATUS_CONFDIR
void cctk_setlog(const char *logfile)
#define STATUS_VARS
const char * msg
Definition: object.h:322
sstring add_string(const char *str)
Definition: shstr.c:124
#define FLAG_FREED
Definition: define.h:233
void cctk_init_std_archetypes(void)