Crossfire Server, Branch 1.12
R12190
|
00001 /* 00002 * static char *rcsid_check_object_c = 00003 * "$Id: toolkit_common.c 11578 2009-02-23 22:02:27Z lalo $"; 00004 */ 00005 00006 /* 00007 * CrossFire, A Multiplayer game for X-windows 00008 * 00009 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 00010 * Copyright (C) 1992 Frank Tore Johansen 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU General Public License as published by 00014 * the Free Software Foundation; either version 2 of the License, or 00015 * (at your option) any later version. 00016 * 00017 * This program is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * You should have received a copy of the GNU General Public License 00023 * along with this program; if not, write to the Free Software 00024 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00025 * 00026 * The authors can be reached via e-mail at crossfire-devel@real-time.com 00027 */ 00028 00029 /* 00030 * This is the toolkit for common only operations 00031 * All methods should start with cctk (common check toolkit) 00032 */ 00033 00034 #include <global.h> 00035 #include <stdlib.h> 00036 #include <check.h> 00037 00038 #define STATUS_LOGDIR 0x0001 00039 #define STATUS_DATADIR 0x0002 00040 00041 #define STATUS_GLOBALS 0x0100 00042 #define STATUS_HASHTABLE 0x0200 00043 #define STATUS_OBJECTS 0x0400 00044 #define STATUS_VARS 0x0800 00045 #define STATUS_BLOCK 0x1000 00046 #define STATUS_BMAP 0x2000 00047 #define STATUS_ANIM 0x4000 00048 #define STATUS_ARCH 0x8000 00049 #define SET_TKFLAG(__flag) (status_flag |= __flag) 00050 #define CHECK_TKFLAG(__flag) (status_flag&__flag) 00051 #define CCTK_ASSERT(__flag) { \ 00052 if (!CHECK_TKFLAG(__flag)) \ 00053 fail("Improper initialisation, flag 0x%H", __flag);\ 00054 } 00055 00056 static int status_flag = 0; 00057 00061 void cctk_setlog(char *logfile) { 00062 settings.logfilename = logfile; 00063 SET_TKFLAG(STATUS_LOGDIR); 00064 } 00065 00066 void cctk_setdatadir(char *datadir) { 00067 settings.datadir = datadir; 00068 SET_TKFLAG(STATUS_DATADIR); 00069 } 00075 void cctk_init_std_archetypes(void) { 00076 CCTK_ASSERT((STATUS_LOGDIR|STATUS_DATADIR)); 00077 settings.archetypes = "archetypes"; 00078 settings.treasures = "treasures.bld"; 00079 init_globals(); 00080 init_hash_table(); 00081 init_objects(); 00082 init_vars(); 00083 init_block(); 00084 read_bmap_names(); 00085 read_smooth(); 00086 init_anim(); 00087 init_archetypes(); 00088 SET_TKFLAG(STATUS_GLOBALS|STATUS_HASHTABLE|STATUS_OBJECTS|STATUS_VARS|STATUS_BLOCK|STATUS_BMAP|STATUS_ANIM|STATUS_ARCH); 00089 } 00090 00098 object *cctk_create_game_object(const char *archname) { 00099 archetype *arch; 00100 object *obj; 00101 00102 CCTK_ASSERT((STATUS_OBJECTS|STATUS_ARCH)); 00103 if (archname == NULL) 00104 archname = "empty_archetype"; 00105 arch = find_archetype(archname); 00106 if (arch == NULL) 00107 return NULL; 00108 obj = object_create_arch(arch); 00109 if (obj == NULL) 00110 return NULL; 00111 CLEAR_FLAG(obj, FLAG_FREED); 00112 return obj; 00113 } 00120 void cctk_set_object_strings(object *op, char *string) { 00121 op->name = add_string(string); 00122 op->name_pl = add_string(string); 00123 op->title = add_string(string); 00124 op->race = add_string(string); 00125 op->slaying = add_string(string); 00126 op->skill = add_string(string); 00127 op->msg = add_string(string); 00128 op->lore = add_string(string); 00129 op->materialname = add_string(string); 00130 }