Crossfire Server, Trunk
toolkit_common.c
Go to the documentation of this file.
1 /*
2  * static char *rcsid_check_object_c =
3  * "$Id$";
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 #include <assets.h>
39 
40 #define STATUS_LOGDIR 0x0001
41 #define STATUS_DATADIR 0x0002
42 #define STATUS_CONFDIR 0x0004
43 
44 #define STATUS_GLOBALS 0x0100
45 #define STATUS_HASHTABLE 0x0200
46 #define STATUS_OBJECTS 0x0400
47 #define STATUS_VARS 0x0800
48 #define STATUS_BLOCK 0x1000
49 #define STATUS_BMAP 0x2000
50 #define STATUS_ANIM 0x4000
51 #define STATUS_ARCH 0x8000
52 #define SET_TKFLAG(__flag) (status_flag |= __flag)
53 #define CHECK_TKFLAG(__flag) (status_flag&__flag)
54 #define CCTK_ASSERT(__flag) { \
55  if (!CHECK_TKFLAG(__flag)) \
56  fail("Improper initialisation, flag 0x%H", __flag);\
57  }
58 
59 static int status_flag = 0;
60 
64 void cctk_setlog(const char *logfile) {
67 }
68 
69 void cctk_setdatadir(const char *datadir) {
70  static char confdir[1024];
71  snprintf(confdir, sizeof(confdir), "%s/config", datadir);
72  settings.datadir = datadir;
73  settings.confdir = confdir;
76 }
77 
85  init_globals();
88  assets_init();
89 
90  init_objects();
91  init_block();
92 
94 
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;
116  if (obj == NULL)
117  return NULL;
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 }
init_hash_table
void init_hash_table(void)
Definition: shstr.c:55
global.h
add_string
sstring add_string(const char *str)
Definition: shstr.c:124
altar_valkyrie.obj
obj
Definition: altar_valkyrie.py:33
archininventory.arch
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: archininventory.py:16
FALSE
#define FALSE
Definition: compat.h:14
Settings::datadir
const char * datadir
Definition: global.h:244
STATUS_DATADIR
#define STATUS_DATADIR
Definition: toolkit_common.c:41
cctk_create_game_object
object * cctk_create_game_object(const char *archname)
Definition: toolkit_common.c:105
status_flag
static int status_flag
Definition: toolkit_common.c:59
SET_TKFLAG
#define SET_TKFLAG(__flag)
Definition: toolkit_common.c:52
init_objects
void init_objects(void)
Definition: object.c:316
STATUS_CONFDIR
#define STATUS_CONFDIR
Definition: toolkit_common.c:42
cctk_set_object_strings
void cctk_set_object_strings(object *op, const char *string)
Definition: toolkit_common.c:127
STATUS_ANIM
#define STATUS_ANIM
Definition: toolkit_common.c:50
cctk_init_std_archetypes
void cctk_init_std_archetypes(void)
Definition: toolkit_common.c:83
archt
Definition: object.h:468
obj
Definition: object.h:275
settings
struct Settings settings
Definition: init.c:39
STATUS_HASHTABLE
#define STATUS_HASHTABLE
Definition: toolkit_common.c:45
STATUS_GLOBALS
#define STATUS_GLOBALS
Definition: toolkit_common.c:44
cctk_setlog
void cctk_setlog(const char *logfile)
Definition: toolkit_common.c:64
Settings::logfilename
const char * logfilename
Definition: global.h:238
FLAG_FREED
#define FLAG_FREED
Definition: define.h:233
CCTK_ASSERT
#define CCTK_ASSERT(__flag)
Definition: toolkit_common.c:54
init_stats
void init_stats(int reload)
Definition: living.c:2594
object_create_arch
object * object_create_arch(archetype *at)
Definition: arch.cpp:301
Settings::confdir
const char * confdir
Definition: global.h:243
logfile
EXTERN FILE * logfile
Definition: global.h:136
init_globals
void init_globals(void)
Definition: init.c:268
ASSETS_ALL
#define ASSETS_ALL
Definition: assets.h:35
STATUS_BLOCK
#define STATUS_BLOCK
Definition: toolkit_common.c:48
cctk_setdatadir
void cctk_setdatadir(const char *datadir)
Definition: toolkit_common.c:69
STATUS_LOGDIR
#define STATUS_LOGDIR
Definition: toolkit_common.c:40
give.op
op
Definition: give.py:33
find_archetype
archetype * find_archetype(const char *name)
Definition: assets.cpp:278
STATUS_BMAP
#define STATUS_BMAP
Definition: toolkit_common.c:49
assets.h
CLEAR_FLAG
#define CLEAR_FLAG(xyz, p)
Definition: define.h:225
STATUS_ARCH
#define STATUS_ARCH
Definition: toolkit_common.c:51
STATUS_VARS
#define STATUS_VARS
Definition: toolkit_common.c:47
init_block
void init_block(void)
Definition: los.c:88
assets_collect
void assets_collect(const char *datadir, int what)
Definition: assets.cpp:116
STATUS_OBJECTS
#define STATUS_OBJECTS
Definition: toolkit_common.c:46
assets_init
void assets_init()
Definition: assets.cpp:68