Crossfire Server, Trunk  R20513
toolkit_common.c
Go to the documentation of this file.
1 /*
2  * static char *rcsid_check_object_c =
3  * "$Id: toolkit_common.c 19823 2015-03-01 13:38:30Z ryo_saeba $";
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  settings.datadir = datadir;
71 }
72 
73 void cctk_setconfdir(const char *confdir) {
74  settings.confdir = confdir;
76 }
77 
85  settings.archetypes = "archetypes";
86  settings.treasures = "treasures.bld";
87  init_globals();
90  init_objects();
91  init_block();
93  read_smooth();
94  init_anim();
97 }
98 
106 object *cctk_create_game_object(const char *archname) {
107  archetype *arch;
108  object *obj;
109 
111  if (archname == NULL)
112  archname = "empty_archetype";
113  arch = find_archetype(archname);
114  if (arch == NULL)
115  return NULL;
116  obj = object_create_arch(arch);
117  if (obj == NULL)
118  return NULL;
119  CLEAR_FLAG(obj, FLAG_FREED);
120  return obj;
121 }
128 void cctk_set_object_strings(object *op, const char *string) {
129  op->name = add_string(string);
130  op->name_pl = add_string(string);
131  op->title = add_string(string);
132  op->race = add_string(string);
133  op->slaying = add_string(string);
134  op->skill = add_string(string);
135  op->msg = add_string(string);
136  op->lore = add_string(string);
137  op->materialname = add_string(string);
138 }
EXTERN FILE * logfile
Used by server/daemon.c.
Definition: global.h:144
Main Crossfire structure, one ingame object.
Definition: object.h:274
void cctk_set_object_strings(object *op, const char *string)
Set all strings in given object to given parameter string, used for checking cleaning of objects...
archetype * find_archetype(const char *name)
Finds, using the hashtable, which archetype matches the given name.
Definition: arch.c:695
void init_anim(void)
Loads the lib/animations file.
Definition: anim.c:44
const char * race
Human, goblin, dragon, etc.
Definition: object.h:318
void init_block(void)
initialises the array used by the LOS routines.
Definition: los.c:88
#define CCTK_ASSERT(__flag)
#define STATUS_DATADIR
const char * slaying
Which race to do double damage to.
Definition: object.h:319
void init_archetypes(void)
Initialises the internal linked list of archetypes (read from file).
Definition: arch.c:182
#define STATUS_ARCH
void init_globals(void)
Initialises all global variables.
Definition: init.c:272
void cctk_setdatadir(const char *datadir)
#define STATUS_GLOBALS
#define FALSE
Definition: compat.h:11
Global type definitions and header inclusions.
const char * treasures
Location of the treasures file.
Definition: global.h:250
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:465
const char * logfilename
Logfile to use.
Definition: global.h:238
#define STATUS_BMAP
const char * lore
Obscure information about this object, to get put into books and the like.
Definition: object.h:323
const char * title
Of foo, etc.
Definition: object.h:317
void init_hash_table(void)
Initialises the hash-table used by the shared string library.
Definition: shstr.c:55
int read_smooth(void)
Reads the smooth file to know how to smooth datas.
Definition: image.c:323
const char * name_pl
The plural name of the object.
Definition: object.h:315
#define SET_TKFLAG(__flag)
const char * materialname
Specific material name.
Definition: object.h:346
#define STATUS_BLOCK
const char * name
The name of the object, obviously...
Definition: object.h:311
static int status_flag
void cctk_setconfdir(const char *confdir)
const char * archetypes
Name of the archetypes file - libdir is prepended.
Definition: global.h:248
#define CLEAR_FLAG(xyz, p)
Definition: define.h:224
#define STATUS_HASHTABLE
object * object_create_arch(archetype *at)
Create a full object using the given archetype.
Definition: arch.c:736
const char * skill
Name of the skill this object uses/grants.
Definition: object.h:321
const char * confdir
Configuration files.
Definition: global.h:243
void read_bmap_names(void)
This reads the bmaps file to get all the bitmap names and stuff.
Definition: image.c:180
#define STATUS_ANIM
const char * datadir
Read only data files.
Definition: global.h:244
void init_objects(void)
Sets up and initialises the linked list of free and used objects.
Definition: init.c:366
object * cctk_create_game_object(const char *archname)
Initialize a simple object.
#define STATUS_LOGDIR
#define STATUS_OBJECTS
void init_stats(int reload)
This loads statistic bonus/penalties from the stat_bonus file.
Definition: living.c:2487
struct Settings settings
Server settings.
Definition: init.c:40
#define STATUS_CONFDIR
void cctk_setlog(const char *logfile)
set the logdir to use
#define STATUS_VARS
const char * msg
If this is a book/sign/magic mouth/etc.
Definition: object.h:322
sstring add_string(const char *str)
This will add &#39;str&#39; to the hash table.
Definition: shstr.c:124
#define FLAG_FREED
Object is in the list of free objects.
Definition: define.h:233
void cctk_init_std_archetypes(void)
Loads up to archetype initialisation using standard crossfire files in source tree.