src/hcode/glue.c File Reference

#include "config.h"
#include <stdio.h>
#include <sys/file.h>
#include <string.h>
#include <math.h>
#include "create.h"
#include "mech.h"
#include "mech.events.h"
#include "debug.h"
#include "mechrep.h"
#include "mech.tech.h"
#include "autopilot.h"
#include "turret.h"
#include "p.ds.turret.h"
#include "coolmenu.h"
#include "p.bsuit.h"
#include "glue.h"
#include "mux_tree.h"
#include "powers.h"
#include "ansi.h"
#include "mycool.h"
#include "p.mux_tree.h"
#include "p.mechfile.h"
#include "p.mech.stat.h"
#include "p.mech.partnames.h"

Include dependency graph for glue.c:

Go to the source code of this file.

Data Structures

struct  color_entry

Defines

#define FAST_WHICHSPECIAL
#define _GLUE_C
#define WhichType(node)   NodeType(node)
#define TYPE2FLAG(a)
#define SKIPSTUFF(a)   while (*a && *a != ' ') a++;while (*a == ' ') a++
#define OkayHcode(a)   (a >= 0 && Hardcode(a) && !Zombie(a))
#define ONE_LINE_TEXTS
#define MLen   CM_ONE
#define Len(s)   ((!s || !*s) ? 0 : strlen(s))
#define TAB   3
#define HELPMSG(a)   &SpecialObjects[id].commands[a].helpmsg[SpecialObjects[id].commands[a].helpmsg[0]=='@']
#define DEFAULT   0
#define ANSI_START   "\033["
#define ANSI_START_LEN   2
#define ANSI_END   "m"
#define ANSI_END_LEN   1
#define CHARS   256

Functions

int HandledCommand (dbref player, dbref loc, char *command)
void CreateNewSpecialObject (dbref player, dbref key)
void DisposeSpecialObject (dbref player, dbref key)
void list_hashstat (dbref player, const char *tab_name, HASHTAB *htab)
void raw_notify (dbref player, const char *msg)
void AddEntry (Tree *tree, muxkey_t key, dtype_t type, dsize_t size, void *data)
void DeleteEntry (Tree *tree, muxkey_t key)
int SaveTree (FILE *f, Tree tree)
void UpdateTree (FILE *f, Tree *tree, int(*sizefunc)(int))
void GoThruTree (Tree tree, int(*func)(Node *))
void * NewSpecialObject (int id, int type)
void * FindObjectsData (dbref key)
static NodeFindObjectsNode (dbref key)
static void DoSpecialObjectHelp (dbref player, char *type, int id, int loc, int powerneeded, int objid, char *arg)
void initialize_colorize ()
int WhichSpecial (dbref key)
static int WhichSpecialS (dbref key)
int map_sizefun ()
static int Can_Use_Command (MECH *mech, int cmdflag)
int HandledCommand_sub (dbref player, dbref location, char *command)
void InitSpecialHash (int which)
void initialize_partname_tables ()
static int remove_from_all_maps_func (Node *tmp)
void mech_remove_from_all_maps (MECH *mech)
static int remove_from_all_maps_except_func (Node *tmp)
void mech_remove_from_all_maps_except (MECH *mech, int num)
static int load_update2 (Node *tmp)
static int load_update4 (Node *tmp)
static int load_update3 (Node *tmp)
static int load_update1 (Node *tmp)
static int load_autopilot_data (Node *tmp)
static int get_specialobjectsize (int type)
void heartbeat_init ()
static void load_xcode ()
static int zap_check (Node *n)
void zap_unneccessary_hcode ()
void LoadSpecialObjects (void)
static int save_maps_func (Node *tmp)
static int save_autopilot_data (Node *tmp)
void ChangeSpecialObjects (int i)
void SaveSpecialObjects (int i)
static int UpdateSpecialObject_func (Node *tmp)
void UpdateSpecialObjects (void)
void Dump_Mech (dbref player, int type, char *typestr)
void DumpMechs (dbref player)
void DumpMaps (dbref player)
int IsMech (dbref num)
int IsAuto (dbref num)
int IsMap (dbref num)
char * center_string (char *c, int len)
static void help_color_initialize (char *from, char *to)
static char * do_ugly_things (coolmenu **d, char *msg, int len, int initial)
static void cut_apart_helpmsgs (coolmenu **d, char *msg1, char *msg2, int len, int initial)
void handle_xcode (dbref player, dbref obj, int from, int to)
char * colorize (dbref player, char *from)
void mecha_notify (dbref player, char *msg)
void mecha_notify_except (dbref loc, dbref player, dbref exception, char *msg)
void ResetSpecialObjects ()
MAPgetMap (dbref d)
MECHgetMech (dbref d)

Variables

HASHTAB SpecialCommandHash [NUM_SPECIAL_OBJECTS]
Tree xcode_tree = NULL
static MECHglobal_kludge_mech
int global_specials = NUM_SPECIAL_OBJECTS
static dbref except_map = -1
static FILE * global_file_kludge
static int zappable_node
static FILE * global_file_kludge
static time_t lastrun = 0
color_entry color_table []
char colorc_reverse [CHARS]


Define Documentation

#define _GLUE_C

Definition at line 29 of file glue.c.

#define ANSI_END   "m"

Definition at line 1361 of file glue.c.

Referenced by colorize().

#define ANSI_END_LEN   1

Definition at line 1362 of file glue.c.

Referenced by colorize(), and initialize_colorize().

#define ANSI_START   "\033["

Definition at line 1359 of file glue.c.

Referenced by colorize().

#define ANSI_START_LEN   2

Definition at line 1360 of file glue.c.

Referenced by colorize(), and initialize_colorize().

#define CHARS   256

Definition at line 1388 of file glue.c.

Referenced by initialize_colorize().

#define DEFAULT   0

Definition at line 1358 of file glue.c.

Referenced by colorize(), and initialize_colorize().

#define FAST_WHICHSPECIAL

Definition at line 25 of file glue.c.

#define HELPMSG (  )     &SpecialObjects[id].commands[a].helpmsg[SpecialObjects[id].commands[a].helpmsg[0]=='@']

Referenced by DoSpecialObjectHelp().

#define Len (  )     ((!s || !*s) ? 0 : strlen(s))

Definition at line 1158 of file glue.c.

Referenced by cut_apart_helpmsgs().

#define MLen   CM_ONE

Definition at line 1102 of file glue.c.

Referenced by do_ugly_things().

#define OkayHcode (  )     (a >= 0 && Hardcode(a) && !Zombie(a))

Definition at line 180 of file glue.c.

Referenced by HandledCommand().

#define ONE_LINE_TEXTS

Definition at line 1099 of file glue.c.

#define SKIPSTUFF (  )     while (*a && *a != ' ') a++;while (*a == ' ') a++

Referenced by HandledCommand_sub().

#define TAB   3

Definition at line 1160 of file glue.c.

Referenced by cut_apart_helpmsgs().

#define TYPE2FLAG (  ) 

Value:

Referenced by Can_Use_Command().

#define WhichType ( node   )     NodeType(node)

Definition at line 89 of file glue.c.

Referenced by load_autopilot_data(), load_update1(), load_update2(), load_update3(), load_update4(), remove_from_all_maps_except_func(), remove_from_all_maps_func(), save_autopilot_data(), save_maps_func(), and UpdateSpecialObject_func().


Function Documentation

void AddEntry ( Tree tree,
muxkey_t  key,
dtype_t  type,
dsize_t  size,
void *  data 
)

Definition at line 55 of file mux_tree.c.

References Create, rbtc_node_type::data, rbtc_node_type::key, NodeCompare(), NodeDelete(), rbtc_node_type::size, tree_add(), and rbtc_node_type::type.

Referenced by MyLoadTree(), and NewSpecialObject().

00057 {
00058     Node *foo;
00059 
00060     if (!tree)
00061         return;
00062     Create(foo, Node, 1);
00063     foo->key = key;
00064     foo->data = data;
00065     foo->type = type;
00066     foo->size = size;
00067     tree_add(tree, NodeCompare, foo, NodeDelete);
00068 }

static int Can_Use_Command ( MECH mech,
int  cmdflag 
) [static]

Definition at line 101 of file glue.c.

References MechType, and TYPE2FLAG.

Referenced by DoSpecialObjectHelp(), and HandledCommand_sub().

00102 {
00103 #define TYPE2FLAG(a) \
00104     ((a)==CLASS_MECH?GFLAG_MECH:(a)==CLASS_VEH_GROUND?GFLAG_GROUNDVEH:\
00105      (a)==CLASS_AERO?GFLAG_AERO:DropShip(a)?GFLAG_DS:(a)==CLASS_VTOL?GFLAG_VTOL:\
00106      (a)==CLASS_VEH_NAVAL?GFLAG_NAVAL:\
00107      (a)==CLASS_BSUIT?GFLAG_BSUIT:\
00108      (a)==CLASS_MW?GFLAG_MW:0)
00109         int i;
00110 
00111         if(!cmdflag)
00112                 return 1;
00113         if(!mech || !(i = TYPE2FLAG(MechType(mech))))
00114                 return 0;
00115         if(cmdflag > 0) {
00116                 if(cmdflag & i)
00117                         return 1;
00118         } else if(!((0 - cmdflag) & i))
00119                 return 1;
00120         return 0;
00121 }

char* center_string ( char *  c,
int  len 
)

Definition at line 1067 of file glue.c.

References LBUF_SIZE, and MAX.

Referenced by DoSpecialObjectHelp().

01068 {
01069         static char buf[LBUF_SIZE];
01070         int l = strlen(c);
01071         int p, i;
01072 
01073         p = MAX(0, (len - l) / 2);
01074         for(i = 0; i < p; i++)
01075                 buf[i] = ' ';
01076         strcpy(buf + p, c);
01077         return buf;
01078 }

void ChangeSpecialObjects ( int  i  ) 

Definition at line 651 of file glue.c.

00652 {
00653         /* XXX Unneccessary for now ; 'latest' db
00654            (db.new) is equivalent to 'db' because we don't
00655            _have_ new-db concept ; this is to-be-done project, however */
00656 }

char* colorize ( dbref  player,
char *  from 
)

Definition at line 1411 of file glue.c.

References alloc_lbuf, Ansi, ANSI_END, ANSI_END_LEN, ANSI_START, ANSI_START_LEN, color_entry::bit, color_table, DEFAULT, color_entry::negbit, and color_entry::string.

01412 {
01413         char *to;
01414         char *p, *q;
01415         int color_wanted = 0;
01416         int i;
01417         int cnt;
01418 
01419         q = to = alloc_lbuf("colorize");
01420 #if 1
01421         for(p = from; *p; p++) {
01422                 if(*p == '%' && *(p + 1) == 'c') {
01423                         p += 2;
01424                         if(*p <= 0)
01425                                 i = DEFAULT;
01426                         else
01427                                 i = colorc_reverse[(short) *p];
01428                         if(i == DEFAULT && *p != 'n')
01429                                 p--;
01430                         color_wanted &= ~color_table[i].negbit;
01431                         color_wanted |= color_table[i].bit;
01432                 } else {
01433                         if(color_wanted && Ansi(player)) {
01434                                 *q = 0;
01435                                 /* Generate efficient color string */
01436                                 strcpy(q, ANSI_START);
01437                                 q += ANSI_START_LEN;
01438                                 cnt = 0;
01439                                 for(i = 0; color_table[i].string; i++)
01440                                         if(color_wanted & color_table[i].bit &&
01441                                            color_table[i].bit != color_table[i].negbit) {
01442                                                 if(cnt)
01443                                                         *q++ = ';';
01444                                                 strcpy(q, color_table[i].sstring);
01445                                                 q += strlen(color_table[i].sstring);
01446                                                 cnt++;
01447                                         }
01448                                 strcpy(q, ANSI_END);
01449                                 q += ANSI_END_LEN;
01450                                 color_wanted = 0;
01451                         }
01452                         *q++ = *p;
01453                 }
01454         }
01455         *q = 0;
01456         if(color_wanted && Ansi(player)) {
01457                 /* Generate efficient color string */
01458                 strcpy(q, ANSI_START);
01459                 q += ANSI_START_LEN;
01460                 cnt = 0;
01461                 for(i = 0; color_table[i].string; i++)
01462                         if(color_wanted & color_table[i].bit &&
01463                            color_table[i].bit != color_table[i].negbit) {
01464                                 if(cnt)
01465                                         *q++ = ';';
01466                                 strcpy(q, color_table[i].sstring);
01467                                 q += strlen(color_table[i].sstring);
01468                                 cnt++;
01469                         }
01470                 strcpy(q, ANSI_END);
01471                 q += ANSI_END_LEN;
01472                 color_wanted = 0;
01473         }
01474 #else
01475         strcpy(to, p);
01476 #endif
01477         return to;
01478 }

void CreateNewSpecialObject ( dbref  player,
dbref  key 
)

Definition at line 858 of file glue.c.

References A_XTYPE, c_Hardcode, SpecialObjectStruct::datasize, NewSpecialObject(), notify, silly_atr_get(), SpecialObjects, SpecialObjectStruct::type, and WhichSpecialS().

Referenced by handle_xcode().

00859 {
00860         void *new;
00861         struct SpecialObjectStruct *typeOfObject;
00862         int type;
00863         char *str;
00864 
00865         str = silly_atr_get(key, A_XTYPE);
00866         if(!(str && *str)) {
00867                 notify(player,
00868                            "You must first set the XTYPE using @xtype <object>=<type>");
00869                 notify(player, "Valid XTYPEs include: MECH, MECHREP, MAP, DEBUG, "
00870                            "AUTOPILOT, TURRET.");
00871                 notify(player, "Resetting hardcode flag.");
00872                 c_Hardcode(key);                /* Reset the flag */
00873                 return;
00874         }
00875 
00876         /* Find the special objects */
00877         type = WhichSpecialS(key);
00878         if(type > -1) {
00879                 /* We found the proper special object */
00880                 typeOfObject = &SpecialObjects[type];
00881                 if(typeOfObject->datasize) {
00882                         new = NewSpecialObject(key, type);
00883                         if(!new)
00884                                 notify(player, "Memory allocation failure!");
00885                 }
00886         } else {
00887                 notify(player, "That is not a valid XTYPE!");
00888                 notify(player, "Valid XTYPEs include: MECH, MECHREP, MAP, DEBUG, "
00889                            "AUTOPILOT, TURRET.");
00890                 notify(player, "Resetting HARDCODE flag.");
00891                 c_Hardcode(key);
00892         }
00893 }

static void cut_apart_helpmsgs ( coolmenu **  d,
char *  msg1,
char *  msg2,
int  len,
int  initial 
) [static]

Definition at line 1162 of file glue.c.

References do_ugly_things(), Len, and TAB.

Referenced by DoSpecialObjectHelp().

01164 {
01165         int l1 = Len(msg1);
01166         int l2 = Len(msg2);
01167         int nl1, nl2;
01168 
01169 #ifndef ONE_LINE_TEXTS
01170 
01171         msg1 = do_ugly_things(d, msg1, len, initial);
01172         msg2 =
01173                 do_ugly_things(d, msg2, initial ? len : len - TAB,
01174                                            initial ? 0 : 0 - TAB);
01175         if(!msg1 && !msg2)
01176                 return;
01177         nl1 = Len(msg1);
01178         nl2 = Len(msg2);
01179         if(nl1 != l1 || nl2 != l2)      /* To prevent infinite loops */
01180                 cut_apart_helpmsgs(d, msg1, msg2, len, 0);
01181 #else
01182         int first = 1;
01183 
01184         while (msg1 && *msg1) {
01185                 msg1 = do_ugly_things(d, msg1, len * 2 - 1, first);
01186                 nl1 = Len(msg1);
01187                 if(nl1 == l1)
01188                         break;
01189                 l1 = nl1;
01190                 first = 0;
01191         }
01192         while (msg2 && *msg2) {
01193                 msg2 = do_ugly_things(d, msg2, len * 2 - TAB, 0 - TAB);
01194                 nl2 = Len(msg2);
01195                 if(nl2 == l2)
01196                         break;
01197                 l2 = nl2;
01198         }
01199 
01200 #endif
01201 }

void DeleteEntry ( Tree tree,
muxkey_t  key 
)

Definition at line 78 of file mux_tree.c.

References FindNode(), rbtc_node_type::key, NodeCompare(), NodeDelete(), and tree_delete().

Referenced by DisposeSpecialObject(), and zap_unneccessary_hcode().

00079 {
00080     Node foo;
00081 
00082     if (FindNode(*tree, key)) {
00083         foo.key = key;
00084         tree_delete(tree, NodeCompare, &foo, NodeDelete);
00085     }
00086 }

void DisposeSpecialObject ( dbref  player,
dbref  key 
)

static char* do_ugly_things ( coolmenu **  d,
char *  msg,
int  len,
int  initial 
) [static]

Definition at line 1107 of file glue.c.

References c, help_color_initialize(), LBUF_SIZE, MLen, and sim.

Referenced by cut_apart_helpmsgs().

01108 {
01109         coolmenu *c = *d;
01110         char *e;
01111         int i;
01112         char buf[LBUF_SIZE];
01113         char msg2[LBUF_SIZE];
01114 
01115         strcpy(msg2, msg);
01116 #ifndef ONE_LINE_TEXTS
01117         if(!msg) {
01118                 sim(" ", MLen);
01119                 *d = c;
01120                 return NULL;
01121         }
01122 #endif
01123         if(strlen(msg) < len) {
01124                 if(initial) {
01125                         if(initial > 0)
01126                                 help_color_initialize(msg, buf);
01127                         else {
01128                                 for(i = 0; i < -initial; i++)
01129                                         buf[i] = ' ';
01130                                 strcpy(&buf[i], msg);
01131                         }
01132                         sim(buf, MLen);
01133                 } else
01134                         sim(msg, MLen);
01135                 *d = c;
01136                 return NULL;
01137         }
01138         for(e = msg2 + len - 1; *e != ' '; e--);
01139         *e = 0;
01140         if(initial) {
01141                 if(initial > 0)
01142                         help_color_initialize(msg2, buf);
01143                 else {
01144                         for(i = 0; i < -initial; i++)
01145                                 buf[i] = ' ';
01146                         strcpy(&buf[i], msg2);
01147                 }
01148                 sim(buf, MLen);
01149         } else
01150                 sim(msg2, MLen);
01151         *e = ' ';
01152         *d = c;
01153         if((*e + 1))
01154                 return e + 1;
01155         return NULL;
01156 }

static void DoSpecialObjectHelp ( dbref  player,
char *  type,
int  id,
int  loc,
int  powerneeded,
int  objid,
char *  arg 
) [static]

Definition at line 1203 of file glue.c.

References c, Can_Use_Command(), center_string(), CM_CENTER, CM_FOUR, CM_LINE, CM_ONE, SpecialObjectStruct::commands, cut_apart_helpmsgs(), flag, getMech(), GTYPE_MECH, Have_MechPower, HELPMSG, KillCoolMenu(), LBUF_SIZE, name, CommandsStruct::name, Owner, ShowCoolMenu(), sim, SpecialObjects, tprintf(), and vsi.

01205 {
01206         int i, j;
01207         MECH *mech = NULL;
01208         int pos[100][2];
01209         int count = 0, csho = 0;
01210         coolmenu *c = NULL;
01211         char buf[LBUF_SIZE];
01212         char *d;
01213         int dc;
01214 
01215         if(id == GTYPE_MECH)
01216                 mech = getMech(loc);
01217         bzero(pos, sizeof(pos));
01218         for(i = 0; SpecialObjects[id].commands[i].name; i++) {
01219                 if(!SpecialObjects[id].commands[i].func &&
01220                    (SpecialObjects[id].commands[i].helpmsg[0] != '@' ||
01221                         Have_MechPower(Owner(player), powerneeded)))
01222                         if(id != GTYPE_MECH ||
01223                            Can_Use_Command(mech, SpecialObjects[id].commands[i].flag)) {
01224                                 if(count)
01225                                         pos[count - 1][1] = i - pos[count - 1][0];
01226                                 pos[count][0] = i;
01227                                 count++;
01228                         }
01229         }
01230         if(count)
01231                 pos[count - 1][1] = i - pos[count - 1][0];
01232         else {
01233                 pos[0][0] = 0;
01234                 pos[0][1] = i;
01235                 count = 1;
01236         }
01237         sim(NULL, CM_ONE | CM_LINE);
01238         if(!arg || !*arg) {
01239 #define HELPMSG(a) \
01240         &SpecialObjects[id].commands[a].helpmsg[SpecialObjects[id].commands[a].helpmsg[0]=='@']
01241                 for(i = 0; i < count; i++) {
01242                         if(count > 1) {
01243                                 d = center_string(HELPMSG(pos[i][0]), 70);
01244                                 sim(tprintf("%s%s%s", "%cg", d, "%c"), CM_ONE);
01245                         } else
01246                                 sim(tprintf("%s command listing: ", type),
01247                                         CM_ONE | CM_CENTER);
01248                         for(j = pos[i][0] + (count == 1 ? 0 : 1);
01249                                 j < pos[i][0] + pos[i][1]; j++)
01250                                 if(SpecialObjects[id].commands[j].helpmsg[0] != '@' ||
01251                                    Have_MechPower(Owner(player), powerneeded))
01252                                         if(id != GTYPE_MECH ||
01253                                            Can_Use_Command(mech,
01254                                                                            SpecialObjects[id].commands[j].flag)) {
01255                                                 strcpy(buf, SpecialObjects[id].commands[j].name);
01256                                                 d = buf;
01257                                                 while (*d && *d != ' ')
01258                                                         d++;
01259                                                 if(*d == ' ')
01260                                                         *d = 0;
01261                                                 sim(buf, CM_FOUR);
01262                                                 csho++;
01263                                         }
01264                 }
01265                 if(!csho)
01266                         vsi(tprintf
01267                                 ("There are no commands you are authorized to use here."));
01268                 else {
01269                         sim(NULL, CM_ONE | CM_LINE);
01270                         if(count > 1)
01271                                 vsi("Additional info available with 'HELP SUBTOPIC'");
01272                         else
01273                                 vsi("Additional info available with 'HELP ALL'");
01274                 }
01275         } else {
01276                 /* Try to find matching subtopic, or ALL */
01277                 if(!strcasecmp(arg, "all")) {
01278                         if(count > 1) {
01279                                 vsi("ALL not available for objects with subcategories.");
01280                                 dc = -2;
01281                         } else
01282                                 dc = -1;
01283                 } else {
01284                         if(count == 1) {
01285                                 vsi("This object doesn't have any other detailed help than 'HELP ALL'");
01286                                 dc = -2;
01287                         } else {
01288                                 for(i = 0; i < count; i++)
01289                                         if(!strcasecmp(arg, HELPMSG(pos[i][0])))
01290                                                 break;
01291                                 if(i == count) {
01292                                         vsi("Subcategory not found.");
01293                                         dc = -2;
01294                                 } else
01295                                         dc = i;
01296                         }
01297                 }
01298                 if(dc > -2) {
01299                         for(i = 0; i < count; i++)
01300                                 if(dc == -1 || i == dc) {
01301                                         if(count > 1)
01302                                                 vsi(tprintf("%s%s%s", "%cg",
01303                                                                         center_string(HELPMSG(pos[i][0]), 70),
01304                                                                         "%c"));
01305                                         for(j = pos[i][0] + (count == 1 ? 0 : 1);
01306                                                 j < pos[i][0] + pos[i][1]; j++)
01307                                                 if(SpecialObjects[id].commands[j].helpmsg[0] !=
01308                                                    '@' || Have_MechPower(Owner(player), powerneeded))
01309                                                         if(id != GTYPE_MECH ||
01310                                                            Can_Use_Command(mech,
01311                                                                                            SpecialObjects[id].commands[j].
01312                                                                                            flag))
01313                                                                 cut_apart_helpmsgs(&c,
01314                                                                                                    SpecialObjects[id].
01315                                                                                                    commands[j].name,
01316                                                                                                    HELPMSG(j), 37, 1);
01317                                 }
01318                 }
01319         }
01320         sim(NULL, CM_ONE | CM_LINE);
01321         ShowCoolMenu(player, c);
01322         KillCoolMenu(c);
01323 }

void Dump_Mech ( dbref  player,
int  type,
char *  typestr 
)

Definition at line 932 of file glue.c.

References MECH::mapindex, MechPilot, MechStatus, MECH::mynum, NodeData, NodeKey, notify, running, Started, STARTED, WhichSpecial(), and xcode_tree.

Referenced by DumpMechs().

00933 {
00934         notify(player, "Support discontinued. Bother a wiz if this bothers you.");
00935 #if 0
00936         MECH *mech;
00937         char buff[100];
00938         int i, running = 0, count = 0;
00939         Node *temp;
00940 
00941         notify(player, "ID    # STATUS      MAP #      PILOT #");
00942         notify(player, "----------------------------------------");
00943         for(temp = TreeTop(xcode_tree); temp; temp = TreeNext(temp))
00944                 if(WhichSpecial((i = NodeKey(temp))) == type) {
00945                         mech = (MECH *) NodeData(temp);
00946                         sprintf(buff, "#%5d %-8s    #%5d    #%5d", mech->mynum,
00947                                         !Started(mech) ? "SHUTDOWN" : "RUNNING", mech->mapindex,
00948                                         MechPilot(mech));
00949                         notify(player, buff);
00950                         if(MechStatus(mech) & STARTED)
00951                                 running++;
00952                         count++;
00953                 }
00954         sprintf(buff, "%d %ss running out of %d %ss allocated.", running,
00955                         typestr, count, typestr);
00956         notify(player, buff);
00957         notify(player, "Done listing");
00958 #endif
00959 }

void DumpMaps ( dbref  player  ) 

Definition at line 966 of file glue.c.

References MAP::first_free, GTYPE_MAP, MAP::map_height, MAP::map_width, MAP::mapname, MAP::mechsOnMap, MAP::mynum, NodeData, NodeKey, notify, WhichSpecial(), and xcode_tree.

Referenced by debug_list().

00967 {
00968         notify(player, "Support discontinued. Bother a wiz if this bothers you.");
00969 #if 0
00970         MAP *map;
00971         char buff[100];
00972         int j, count;
00973         Node *temp;
00974 
00975         notify(player, "MAP #       NAME              X x Y   MECHS");
00976         notify(player, "-------------------------------------------");
00977         for(temp = TreeTop(xcode_tree); temp; temp = TreeNext(temp))
00978                 if(WhichSpecial(NodeKey(temp)) == GTYPE_MAP) {
00979                         count = 0;
00980                         map = (MAP *) NodeData(temp);
00981                         for(j = 0; j < map->first_free; j++)
00982                                 if(map->mechsOnMap[j] != -1)
00983                                         count++;
00984                         sprintf(buff, "#%5d    %-17.17s %3d x%3d       %d", map->mynum,
00985                                         map->mapname, map->map_width, map->map_height, count);
00986                         notify(player, buff);
00987                 }
00988         notify(player, "Done listing");
00989 #endif
00990 }

void DumpMechs ( dbref  player  ) 

Definition at line 961 of file glue.c.

References Dump_Mech(), and GTYPE_MECH.

Referenced by debug_list().

00962 {
00963         Dump_Mech(player, GTYPE_MECH, "mech");
00964 }

void* FindObjectsData ( dbref  key  ) 

static Node * FindObjectsNode ( dbref  key  )  [static]

Definition at line 1049 of file glue.c.

References FindNode(), and xcode_tree.

Referenced by FindObjectsData(), getMap(), getMech(), and WhichSpecial().

01050 {
01051         Node *tmp;
01052 
01053         if((tmp = FindNode(xcode_tree, (int) key)))
01054                 return tmp;
01055         return NULL;
01056 }

static int get_specialobjectsize ( int  type  )  [static]

Definition at line 428 of file glue.c.

References SpecialObjectStruct::datasize, and SpecialObjects.

Referenced by load_xcode().

00429 {
00430         if(type < 0 || type >= NUM_SPECIAL_OBJECTS)
00431                 return -1;
00432         return SpecialObjects[type].datasize;
00433 }

MAP* getMap ( dbref  d  ) 

Definition at line 1522 of file glue.c.

References FindObjectsNode(), GTYPE_MAP, NodeData, and NodeType.

Referenced by aero_land(), aero_takeoff(), aero_takeoff_event(), ai_check_path(), artillery_hit(), auto_astar_follow_event(), auto_astar_generate_path(), auto_astar_goto_event(), auto_astar_roam_event(), auto_command_roam(), auto_dumbfollow_event(), auto_dumbgoto_event(), auto_enter_event(), auto_gun_event(), auto_leave_event(), auto_radio_command_goto(), auto_reply_event(), auto_sensor_event(), bomb_drop(), CanChangeTo(), char_disembark(), CheckEdgeOfMap(), checkTAG(), clear_hex(), collision_check(), common_checks(), DamageMech(), DeathFromAbove(), DestroyMech(), DestroyParts(), determineDamageFromHit(), DS_BlastNearbyMechsAndTrees(), DS_Place(), end_lite_check(), explode_mines(), findC3RangeWithNetwork(), FindTargetDBREFFromMapNumber(), fire_hex(), firetic_sub(), fun_btgetrange(), fun_bthexemit(), fun_bthexinblz(), fun_bthexlos(), fun_btid2db(), fun_btlistblz(), fun_btloadmap(), fun_btmapemit(), fun_btmapunits(), fun_btsetxy(), get_building_cf(), HandleOverheat(), hit_building(), ImproperLZ(), InLineOfSight(), LandMech(), Leave_Hangar(), load_update4(), map_linked(), MarkForLOSUpdate(), mech_axe(), mech_bearing(), mech_c3_join_leave(), mech_c3i_join_leave(), mech_charge(), mech_club(), mech_contacts(), mech_detachcables(), mech_dropoff(), mech_embark(), mech_enter_event(), mech_enterbase(), mech_enterbay(), mech_enterbay_event(), mech_eta(), mech_fireweapon(), mech_hide_event(), mech_jump(), mech_kickortrip(), mech_lites_target(), mech_lock_event(), mech_lrsmap(), mech_mace(), mech_map_consistency_check(), mech_navigate(), mech_pickup(), mech_plos_event(), mech_punch(), mech_range(), mech_report(), mech_Rsetxy(), mech_saw(), mech_scan(), mech_set_channelfreq(), mech_settarget(), mech_sight(), mech_snipe_func(), mech_spot(), mech_startup_event(), mech_sword(), mech_tacmap(), mech_tag(), mech_thrash(), mech_udisembark(), mech_vector(), mech_view(), MechLOSBroadcast(), MechLOSBroadcasti(), Missile_Hit(), move_mech(), newfreemech(), parse_tacargs(), possible_mine_poof(), possibly_see_mech(), reactor_explosion(), recursively_updatelinks(), remove_from_all_maps_except_func(), remove_from_all_maps_func(), ScrambleInfraAndLiteAmp(), sendchannelstuff(), Sensor_CanSee(), Sensor_Sees(), Sensor_ToHitBonus(), set_building_cf(), show_building_in_hex(), show_mines_in_hex(), showNetworkTargets(), steppable_base_check(), ValidMap(), and water_extinguish_inferno().

01523 {
01524         Node *tmp;
01525 
01526         if(!(tmp = FindObjectsNode(d)))
01527                 return NULL;
01528         if(NodeType(tmp) != GTYPE_MAP)
01529                 return NULL;
01530         return (MAP *) NodeData(tmp);
01531 }

MECH* getMech ( dbref  d  ) 

Definition at line 1533 of file glue.c.

References FindObjectsNode(), Good_obj, GTYPE_MECH, Hardcode, NodeData, and NodeType.

Referenced by artillery_FriendlyAdjustment(), auto_astar_follow_event(), auto_com_event(), auto_command_autogun(), auto_command_embark(), auto_command_pickup(), auto_dumbfollow_event(), auto_engage(), auto_gun_event(), auto_newautopilot(), auto_radio_command_report(), auto_sensor_event(), autoeject(), char_disembark(), char_eject(), checkTAG(), clear_mech_from_LOS(), ClearFireAdjustments(), countMaxC3Units(), DamageMech(), debug_fixmap(), DestroyMech(), DestroySection(), DisplayTarget(), DoSpecialObjectHelp(), explode_unit(), Find_Single_DS_In_MechHex(), FindArtilleryBTH(), FindBSuitTarget(), FindMechOnMap(), FindNormalBTH(), FindTargetXY(), FireSpot(), FireWeapon(), FireWeaponNumber(), fun_btengrate(), fun_btgetrange(), fun_bthexlos(), fun_btid2db(), fun_btloadmech(), fun_btlosm2m(), fun_btmapunits(), fun_btmechfreqs(), fun_btsetxy(), fun_btunitfixable(), getMechInTempNetwork(), getOtherMechInNetwork(), HexLOSBroadcast(), LandMech(), Leave_DS(), Leave_DS_Bay(), Leave_Hangar(), load_autopilot_data(), map_listmechs(), map_update(), MapBroadcast(), MapLimitedBroadcast2d(), MapLimitedBroadcast3d(), mech_attachcables(), mech_bearing(), mech_c3_join_leave(), mech_c3i_join_leave(), mech_charge(), mech_detachcables(), mech_dropoff(), mech_embark(), mech_enter_event(), mech_enterbay(), mech_enterbay_event(), mech_hide_event(), mech_jump(), mech_pickup(), mech_radio(), mech_range(), mech_report(), mech_scan(), mech_settarget(), Mech_ShowFlags(), mech_snipe(), mech_spot(), mech_tag(), mech_udisembark(), mech_vector(), mech_view(), MechCargoMaxSpeed(), MechLOSBroadcast(), MechLOSBroadcasti(), move_mech(), parse_tacargs(), PhysicalAttack(), possibly_see_mech(), PrintEnemyStatus(), PrintGenericStatus(), PrintInfoStatus(), PrintWeaponStatus(), remove_mech_from_map(), ScrambleInfraAndLiteAmp(), set_xcodestuff(), show_lrs_map(), ShutDownMap(), sketch_tac_mechs(), StopSwarming(), stopTAG(), swim_except(), tag_recycle_event(), TargetMovementMods(), trimC3Network(), update_LOSinfo(), updateAutoturnTurret(), and UpdateSpeed().

01534 {
01535         Node *tmp;
01536 
01537         if(!(Good_obj(d)))
01538                 return NULL;
01539         if(!(Hardcode(d)))
01540                 return NULL;
01541         if(!(tmp = FindObjectsNode(d)))
01542                 return NULL;
01543         if(NodeType(tmp) != GTYPE_MECH)
01544                 return NULL;
01545         return (MECH *) NodeData(tmp);
01546 }

void GoThruTree ( Tree  tree,
int(*)(Node *)  func 
)

Definition at line 171 of file mux_tree.c.

00172 {
00173     tree_trav(&tree, func);
00174 }

void handle_xcode ( dbref  player,
dbref  obj,
int  from,
int  to 
)

Definition at line 1346 of file glue.c.

References c_Hardcode, CreateNewSpecialObject(), DisposeSpecialObject(), and s_Hardcode.

01347 {
01348         if(from == to)
01349                 return;
01350         if(!to) {
01351                 s_Hardcode(obj);
01352                 DisposeSpecialObject(player, obj);
01353                 c_Hardcode(obj);
01354         } else
01355                 CreateNewSpecialObject(player, obj);
01356 }

int HandledCommand ( dbref  player,
dbref  loc,
char *  command 
)

int HandledCommand_sub ( dbref  player,
dbref  location,
char *  command 
)

Definition at line 123 of file glue.c.

References Can_Use_Command(), SpecialObjectStruct::datasize, FindNode(), CommandsStruct::flag, CommandsStruct::func, GTYPE_MECH, Hardcode, hashfind(), Have_MechPower, CommandsStruct::helpmsg, NodeData, Owner, SpecialObjectStruct::power_needed, SKIPSTUFF, SpecialCommandHash, SpecialObjects, ToLower, SpecialObjectStruct::type, WhichSpecial(), WhichSpecialS(), xcode_tree, and Zombie.

Referenced by HandledCommand().

00124 {
00125         struct SpecialObjectStruct *typeOfObject;
00126         Node *n = NULL;
00127         int type;
00128         CommandsStruct *cmd;
00129         HASHTAB *damnedhash;
00130         char *tmpc, *tmpchar;
00131         int ishelp;
00132 
00133         type = WhichSpecial(location);
00134         if(type < 0 || (SpecialObjects[type].datasize > 0 &&
00135                                         !(n = FindNode(xcode_tree, location)))) {
00136                 if(type >= 0 || !Hardcode(location) || Zombie(location))
00137                         return 0;
00138                 if((type = WhichSpecialS(location)) >= 0) {
00139                         if(SpecialObjects[type].datasize > 0)
00140                                 return 0;
00141                 } else
00142                         return 0;
00143         }
00144 #ifdef FAST_WHICHSPECIAL
00145         if(type > NUM_SPECIAL_OBJECTS)
00146                 return 0;
00147 #endif
00148         typeOfObject = &SpecialObjects[type];
00149         damnedhash = &SpecialCommandHash[type];
00150         tmpc = strstr(command, " ");
00151         if(tmpc)
00152                 *tmpc = 0;
00153         ishelp = !strcmp(command, "HELP");
00154         for(tmpchar = command; *tmpchar; tmpchar++)
00155                 *tmpchar = ToLower(*tmpchar);
00156         cmd = (CommandsStruct *) hashfind(command, &SpecialCommandHash[type]);
00157         if(tmpc)
00158                 *tmpc = ' ';
00159         if(cmd && (type != GTYPE_MECH || (type == GTYPE_MECH &&
00160                                                                           Can_Use_Command(((MECH *)
00161                                                                                                            (NodeData(n))),
00162                                                                                                           cmd->flag)))) {
00163 #define SKIPSTUFF(a) while (*a && *a != ' ') a++;while (*a == ' ') a++
00164                 if(cmd->helpmsg[0] != '@' ||
00165                    Have_MechPower(Owner(player), typeOfObject->power_needed)) {
00166                         SKIPSTUFF(command);
00167                         cmd->func(player, !n ? NULL : NodeData(n), command);
00168                 } else
00169                         notify(player, "Sorry, that command is restricted!");
00170                 return 1;
00171         } else if(ishelp) {
00172                 SKIPSTUFF(command);
00173                 DoSpecialObjectHelp(player, typeOfObject->type, type, location,
00174                                                         typeOfObject->power_needed, location, command);
00175                 return 1;
00176         }
00177         return 0;
00178 }

void heartbeat_init (  ) 

Definition at line 33 of file tick.c.

References dprintk, heartbeat_ev, heartbeat_run(), heartbeat_running, and heartbeat_tv.

Referenced by load_xcode().

00033                       {
00034     if(heartbeat_running) return;
00035     dprintk("hearbeat initialized, %ds timeout.", (int)heartbeat_tv.tv_sec);
00036     evtimer_set(&heartbeat_ev, heartbeat_run, NULL);
00037     evtimer_add(&heartbeat_ev, &heartbeat_tv);
00038     heartbeat_running = 1;
00039 }

static void help_color_initialize ( char *  from,
char *  to 
) [static]

Definition at line 1080 of file glue.c.

References LBUF_SIZE.

Referenced by do_ugly_things().

01081 {
01082         int i;
01083         char buf[LBUF_SIZE];
01084 
01085         for(i = 0; from[i] && from[i] != ' '; i++);
01086         if(from[i]) {
01087 
01088                 /*      from[i]=0; */
01089                 strncpy(buf, from, i);
01090                 buf[i] = 0;
01091                 sprintf(to, "%s%s%s %s", "%ch%cb", buf, "%cn", &from[i + 1]);
01092 
01093                 /*      from[i]=' '; */
01094         } else
01095                 sprintf(to, "%s%s%s", "%cc", from, "%cn");
01096 
01097 }

void initialize_colorize (  ) 

Definition at line 1392 of file glue.c.

References ANSI_END_LEN, ANSI_START_LEN, c, CHARS, color_table, DEFAULT, color_entry::sstring, and color_entry::string.

Referenced by load_xcode().

01393 {
01394         int i;
01395         char buf[20];
01396         char *c;
01397 
01398         c = buf + ANSI_START_LEN;
01399         for(i = 0; i < CHARS; i++)
01400                 colorc_reverse[i] = DEFAULT;
01401         for(i = 0; color_table[i].string; i++) {
01402                 colorc_reverse[(short) color_table[i].ltr] = i;
01403                 strcpy(buf, color_table[i].string);
01404                 buf[strlen(buf) - ANSI_END_LEN] = 0;
01405                 color_table[i].sstring = strdup(c);
01406         }
01407 
01408 }

void initialize_partname_tables (  ) 

Definition at line 94 of file mech.partnames.c.

References BRANDCOUNT, c, Create, create_brandname(), DASH, HASH_FACTOR, hashinit(), index_sorted, insert_sorted_brandname(), long_sorted, MBUF_SIZE, NUM_ITEMS, object_count, short_hash, short_sorted, vlong_hash, and vlong_sorted.

Referenced by LoadSpecialObjects().

00095 {
00096         int i, j, c = 0, m, n;
00097         char tmpbuf[MBUF_SIZE];
00098         char *tmpc1, *tmpc2;
00099 
00100         bzero(index_sorted, sizeof(index_sorted));
00101         for(j = 0; j <= BRANDCOUNT; j++)
00102                 for(i = 0; i < NUM_ITEMS; i++)
00103                         c += create_brandname(i, j);
00104         Create(short_sorted, PN *, c);
00105         Create(long_sorted, PN *, c);
00106         Create(vlong_sorted, PN *, c);
00107         /* bubble-sort 'em and insert to array */
00108         i = 0;
00109         for(m = 0; m <= BRANDCOUNT; m++)
00110                 for(n = 0; n < NUM_ITEMS; n++)
00111                         if(index_sorted[m][n])
00112                                 insert_sorted_brandname(i++, index_sorted[m][n]);
00113         hashinit(&short_hash, 20 * HASH_FACTOR);
00114         hashinit(&vlong_hash, 20 * HASH_FACTOR);
00115 #define DASH(fromval,tohash) \
00116   for (tmpc1 = short_sorted[i]->fromval, tmpc2 = tmpbuf ; *tmpc1 ; tmpc1++, tmpc2++) \
00117     *tmpc2 = ToLower(*tmpc1); \
00118   *tmpc2 = 0; \
00119   hashadd(tmpbuf, (int *) (i+1), &tohash);
00120 
00121         for(i = 0; i < c; i++) {
00122                 DASH(shorty, short_hash);
00123 
00124 /*       DASH(longy, long_hash); */
00125                 DASH(vlongy, vlong_hash);
00126         }
00127         object_count = c;
00128 }

void InitSpecialHash ( int  which  ) 

Definition at line 1325 of file glue.c.

References SpecialObjectStruct::commands, HASH_FACTOR, hashadd(), hashinit(), MBUF_SIZE, CommandsStruct::name, SpecialCommandHash, SpecialObjects, and ToLower.

Referenced by LoadSpecialObjects().

01326 {
01327         char *tmp, *tmpc;
01328         int i;
01329         char buf[MBUF_SIZE];
01330 
01331         hashinit(&SpecialCommandHash[which], 20 * HASH_FACTOR);
01332         for(i = 0; (tmp = SpecialObjects[which].commands[i].name); i++) {
01333                 if(!SpecialObjects[which].commands[i].func)
01334                         continue;
01335                 tmpc = buf;
01336                 for(; *tmp && *tmp != ' '; tmp++)
01337                         *(tmpc++) = ToLower(*tmp);
01338                 *tmpc = 0;
01339                 if((tmpc = strstr(buf, " ")))
01340                         *tmpc = 0;
01341                 hashadd(buf, (int *) &SpecialObjects[which].commands[i],
01342                                 &SpecialCommandHash[which]);
01343         }
01344 }

int IsAuto ( dbref  num  ) 

Definition at line 1038 of file glue.c.

References GTYPE_AUTO, and WhichSpecial().

Referenced by auto_astar_follow_event(), auto_astar_goto_event(), auto_astar_roam_event(), auto_com_event(), auto_dumbfollow_event(), auto_dumbgoto_event(), auto_enter_event(), auto_goto_event(), auto_gun_event(), auto_leave_event(), auto_sensor_event(), and auto_update_profile_event().

01039 {
01040         return WhichSpecial(num) == GTYPE_AUTO;
01041 }

int IsMap ( dbref  num  ) 

Definition at line 1043 of file glue.c.

References GTYPE_MAP, and WhichSpecial().

Referenced by fun_btgetrange(), fun_btid2db(), fun_btsetxy(), and mech_createbays().

01044 {
01045         return WhichSpecial(num) == GTYPE_MAP;
01046 }

int IsMech ( dbref  num  ) 

Definition at line 1033 of file glue.c.

References GTYPE_MECH, and WhichSpecial().

01034 {
01035         return WhichSpecial(num) == GTYPE_MECH;
01036 }

void list_hashstat ( dbref  player,
const char *  tab_name,
HASHTAB htab 
)

static int load_autopilot_data ( Node tmp  )  [static]

Definition at line 384 of file glue.c.

References AUTO::astar_path, AUTO_PROFILE_MAX_SIZE, AUTO::commands, dllist_create_list(), DoStartGun, DoStopGun, getMech(), GTYPE_AUTO, Gunning, AUTO::mymech, AUTO::mymechnum, NodeData, AUTO::profile, AUTO::weaplist, and WhichType.

Referenced by load_xcode().

00385 {
00386 
00387         AUTO *autopilot;
00388         int i;
00389 
00390         if(WhichType(tmp) == GTYPE_AUTO) {
00391 
00392                 autopilot = (AUTO *) NodeData(tmp);
00393 
00394                 /* Save the AI Command List */
00395                 /* auto_load_commands(global_file_kludge, autopilot); */
00396         autopilot->commands = dllist_create_list();
00397 
00398                 /* Reset the Astar Path */
00399                 autopilot->astar_path = NULL;
00400 
00401                 /* Reset the weaplist */
00402                 autopilot->weaplist = NULL;
00403 
00404                 /* Reset the profile */
00405                 for(i = 0; i < AUTO_PROFILE_MAX_SIZE; i++) {
00406                         autopilot->profile[i] = NULL;
00407                 }
00408 
00409                 /* Check to see if the AI is in a mech */
00410             /* Need to make this better, check if its got a target whatnot */
00411 
00412 
00413                 if(!autopilot->mymechnum ||
00414                    !(autopilot->mymech = getMech(autopilot->mymechnum))) {
00415                         DoStopGun(autopilot);
00416                 } else {
00417                         if(Gunning(autopilot))
00418                                 DoStartGun(autopilot);
00419                 }
00420 
00421 
00422         }
00423 
00424         return 1;
00425 
00426 }

static int load_update1 ( Node tmp  )  [static]

Definition at line 308 of file glue.c.

References ANGEL_ECCM_ENABLED, ANGEL_ECM_DISTURBED, ANGEL_ECM_ENABLED, ANGEL_ECM_PROTECTED, BLINDED, debug_fixmap(), ECCM_ENABLED, ECM_DISTURBANCE, ECM_ENABLED, ECM_PROTECTED, MAP::first_free, MAP::flags, FlyingT, FREQS, GOD, GTYPE_MAP, GTYPE_MECH, initialize_map_empty(), initiate_ood(), JELLIED, JUMPING, Jumping, Landed, load_mapdynamic(), load_mapobjs(), LOAD_OK, MAP::LOSinfo, MAP::map, map_loadmap(), MAPFLAG_MAPO, MAP::mapname, MAP::mapobj, MBUF_SIZE, mech_Rsetxy(), MechBoomStart, MechC3iNetworkSize, MechCarrying, MechCocoon, MechCommLast, MechCritStatus, MechDesiredSpeed, MAP::mechflags, MechHeatLast, MAP::mechsOnMap, MechSpecials2, MechSpeed, MechStatus, MechVerticalSpeed, MechWalkXPFactor, MechX, MechXPMod, MechY, MechZ, NodeData, NodeKey, OWEIGHT_OK, SPEED_OK, Started, TOWED, tprintf(), UNCONSCIOUS, and WhichType.

Referenced by load_xcode().

00309 {
00310         MAP *map;
00311         int doh;
00312         char mapbuffer[MBUF_SIZE];
00313         MECH *mech;
00314         int i;
00315         int ctemp;
00316 
00317         switch ((i = WhichType(tmp))) {
00318         case GTYPE_MAP:
00319                 map = (MAP *) NodeData(tmp);
00320                 bzero(map->mapobj, sizeof(map->mapobj));
00321                 map->map = NULL;
00322                 strcpy(mapbuffer, map->mapname);
00323                 doh = (map->flags & MAPFLAG_MAPO);
00324                 if(strcmp(map->mapname, "Default Map"))
00325                         map_loadmap(1, map, mapbuffer);
00326                 if(!strcmp(map->mapname, "Default Map") || !map->map)
00327                         initialize_map_empty(map, NodeKey(tmp));
00328                 if(!feof(global_file_kludge)) {
00329                         load_mapdynamic(global_file_kludge, map);
00330                         if(!feof(global_file_kludge))
00331                                 if(doh)
00332                                         load_mapobjs(global_file_kludge, map);
00333                 }
00334                 if(feof(global_file_kludge)) {
00335                         map->first_free = 0;
00336                         map->mechflags = NULL;
00337                         map->mechsOnMap = NULL;
00338                         map->LOSinfo = NULL;
00339                 }
00340                 debug_fixmap(GOD, map, NULL);
00341                 break;
00342         case GTYPE_MECH:
00343                 mech = (MECH *) NodeData(tmp);
00344                 if(!(FlyingT(mech) && !Landed(mech))) {
00345                         MechDesiredSpeed(mech) = 0;
00346                         MechSpeed(mech) = 0;
00347                         MechVerticalSpeed(mech) = 0;
00348                 }
00349                 ctemp = MechCocoon(mech);
00350                 if(MechCocoon(mech)) {
00351                         MechCocoon(mech) = 0;
00352                         initiate_ood((dbref) GOD, mech, tprintf("%d %d %d", MechX(mech), MechY(mech), MechZ(mech)));
00353                         MechCocoon(mech) = ctemp;
00354                 }
00355 
00356                 if(!FlyingT(mech) && Started(mech) && Jumping(mech))
00357                         mech_Rsetxy(GOD, (void *) mech, tprintf("%d %d", MechX(mech),MechY(mech)));
00358         
00359                 MechStatus(mech) &= ~(BLINDED | UNCONSCIOUS | JUMPING | TOWED);
00360                 MechSpecials2(mech) &=
00361                         ~(ECM_ENABLED | ECM_DISTURBANCE | ECM_PROTECTED |
00362                           ECCM_ENABLED | ANGEL_ECM_ENABLED | ANGEL_ECCM_ENABLED |
00363                           ANGEL_ECM_PROTECTED | ANGEL_ECM_DISTURBED);
00364                 MechCritStatus(mech) &= ~(JELLIED | LOAD_OK | OWEIGHT_OK | SPEED_OK);
00365                 MechWalkXPFactor(mech) = 999;
00366                 MechCarrying(mech) = -1;
00367                 MechBoomStart(mech) = 0;
00368                 MechC3iNetworkSize(mech) = -1;
00369                 MechHeatLast(mech) = 0;
00370                 MechCommLast(mech) = 0;
00371                 if(!(MechXPMod(mech)))
00372                         MechXPMod(mech) = 1;            
00373                 for(i = 0; i < FREQS; i++)
00374                         if(mech->freq[i] < 0)
00375                                 mech->freq[i] = 0;
00376                 break;
00377         }
00378         return 1;
00379 }

static int load_update2 ( Node tmp  )  [static]

Definition at line 261 of file glue.c.

References GTYPE_MECH, mech_map_consistency_check(), NodeData, and WhichType.

Referenced by load_xcode().

00262 {
00263         int i = WhichType(tmp);;
00264 
00265         if(i == GTYPE_MECH)
00266                 mech_map_consistency_check(NodeData(tmp));
00267         return 1;
00268 }

static int load_update3 ( Node tmp  )  [static]

Definition at line 295 of file glue.c.

References eliminate_empties(), GTYPE_MAP, NodeData, recalculate_minefields(), and WhichType.

Referenced by load_xcode().

00296 {
00297         int i = WhichType(tmp);
00298 
00299         if(i == GTYPE_MAP) {
00300                 eliminate_empties((MAP *) NodeData(tmp));
00301                 recalculate_minefields((MAP *) NodeData(tmp));
00302         }
00303         return 1;
00304 }

static int load_update4 ( Node tmp  )  [static]

Definition at line 270 of file glue.c.

References getMap(), GOD, GTYPE_MECH, Location, MECH::mapindex, MaybeMove, mech_Rsetmapindex(), MECH::mynum, NodeData, Started, StartSeeing, tprintf(), UpdateRecycling, and WhichType.

Referenced by load_xcode().

00271 {
00272         MECH *mech;
00273         MAP *map;
00274 
00275         if(WhichType(tmp) == GTYPE_MECH) {
00276                 mech = NodeData(tmp);
00277                 if(!(map = getMap(mech->mapindex))) {
00278                         /* Ugly kludge */
00279                         if((map = getMap(Location(mech->mynum))))
00280                                 mech_Rsetmapindex(GOD, mech, tprintf("%d",
00281                                                                                                          Location(mech->mynum)));
00282                         if(!(map = getMap(mech->mapindex)))
00283                                 return 1;
00284                 }
00285                 if(!Started(mech))
00286                         return 1;
00287                 StartSeeing(mech);
00288                 UpdateRecycling(mech);
00289                 MaybeMove(mech);
00290 
00291         }
00292         return 1;
00293 }

static void load_xcode (  )  [static]

Definition at line 501 of file glue.c.

References get_specialobjectsize(), global_file_kludge, GoThruTree(), confdata::hcode_db, heartbeat_init(), initialize_colorize(), load_autopilot_data(), load_update1(), load_update2(), load_update3(), load_update4(), loadrepairs(), mudconf, my_close_file(), my_open_file(), UpdateTree(), xcode_tree, and XCODE_VERSION.

Referenced by LoadSpecialObjects().

00502 {
00503         FILE *f;
00504         byte xcode_version;
00505         int filemode;
00506 
00507         initialize_colorize();
00508         fprintf(stderr, "LOADING: %s\n", mudconf.hcode_db);
00509         f = my_open_file(mudconf.hcode_db, "r", &filemode);
00510         if(!f) {
00511                 fprintf(stderr, "ERROR: %s not found.\n", mudconf.hcode_db);
00512                 return;
00513         }
00514         fread(&xcode_version, 1, 1, f);
00515         if(xcode_version != XCODE_VERSION) {
00516                 fprintf(stderr,
00517                                 "LOADING: %s (skipped xcodetree - version difference: %d vs %d)\n",
00518                                 mudconf.hcode_db, (int) xcode_version, (int) XCODE_VERSION);
00519                 return;
00520         }
00521         UpdateTree(f, &xcode_tree, get_specialobjectsize);
00522         global_file_kludge = f;
00523         GoThruTree(xcode_tree, load_update1);
00524         GoThruTree(xcode_tree, load_update2);
00525         GoThruTree(xcode_tree, load_update3);
00526         GoThruTree(xcode_tree, load_update4);
00527 
00528         /* Read in autopilot data */
00529         GoThruTree(xcode_tree, load_autopilot_data);
00530 
00531         if(!feof(f))
00532                 loadrepairs(f);
00533 
00534         my_close_file(f, &filemode);
00535         fprintf(stderr, "LOADING: %s (done)\n", mudconf.hcode_db);
00536 #ifdef BT_ADVANCED_ECON
00537         load_econdb();
00538 #endif
00539     heartbeat_init();
00540 }

void LoadSpecialObjects ( void   ) 

Definition at line 567 of file glue.c.

References c_Hardcode, SpecialObjectStruct::datasize, statedata::db_top, find_matching_vlong_part(), Going, Halted, Hardcode, init_btechstats(), init_stat(), initialize_partname_tables(), InitSpecialHash(), missile_hit_table_struct::key, load_xcode(), MissileHitTable, mudstate, muxevent_count_initialize(), muxevent_initialize(), name, NewSpecialObject(), SpecialObjects, SpecialObjectStruct::type, SpecialObjectStruct::updatefunc, SpecialObjectStruct::updateTime, Weapon2I, WhichSpecialS(), and zap_unneccessary_hcode().

00568 {
00569         dbref i;
00570         int id, brand;
00571         int type;
00572         void *tmpdat;
00573 
00574         muxevent_initialize();
00575         muxevent_count_initialize();
00576         init_stat();
00577         initialize_partname_tables();
00578         for(i = 0; MissileHitTable[i].key != -1; i++) {
00579                 if(find_matching_vlong_part(MissileHitTable[i].name, NULL, &id,
00580                                                                         &brand))
00581                         MissileHitTable[i].key = Weapon2I(id);
00582                 else
00583                         MissileHitTable[i].key = -2;
00584         }
00585         /* Loop through the entire database, and if it has the special */
00586         /* object flag, add it to our linked list. */
00587         for(i = 0; i < mudstate.db_top; i++)
00588                 if(Hardcode(i) && !Going(i) && !Halted(i)) {
00589                         type = WhichSpecialS(i);
00590                         if(type >= 0) {
00591                                 if(SpecialObjects[type].datasize > 0)
00592                                         tmpdat = NewSpecialObject(i, type);
00593                                 else
00594                                         tmpdat = NULL;
00595                         } else
00596                                 c_Hardcode(i);  /* Reset the flag */
00597                 }
00598         for(i = 0; i < NUM_SPECIAL_OBJECTS; i++) {
00599                 InitSpecialHash(i);
00600                 if(!SpecialObjects[i].updatefunc)
00601                         SpecialObjects[i].updateTime = 0;
00602         }
00603         init_btechstats();
00604         load_xcode();
00605         zap_unneccessary_hcode();
00606 }

int map_sizefun (  ) 

void mech_remove_from_all_maps ( MECH mech  ) 

Definition at line 229 of file glue.c.

References global_kludge_mech, GoThruTree(), remove_from_all_maps_func(), and xcode_tree.

Referenced by mech_map_consistency_check().

00230 {
00231         global_kludge_mech = mech;
00232         GoThruTree(xcode_tree, remove_from_all_maps_func);
00233 }

void mech_remove_from_all_maps_except ( MECH mech,
int  num 
)

Definition at line 253 of file glue.c.

References global_kludge_mech, GoThruTree(), remove_from_all_maps_except_func(), and xcode_tree.

Referenced by mech_map_consistency_check().

00254 {
00255         global_kludge_mech = mech;
00256         except_map = num;
00257         GoThruTree(xcode_tree, remove_from_all_maps_except_func);
00258         except_map = -1;
00259 }

void mecha_notify ( dbref  player,
char *  msg 
)

Definition at line 1480 of file glue.c.

References colorize(), free_lbuf, and raw_notify().

01481 {
01482         char *tmp;
01483 
01484         tmp = colorize(player, msg);
01485         raw_notify(player, tmp);
01486         free_lbuf(tmp);
01487 }

void mecha_notify_except ( dbref  loc,
dbref  player,
dbref  exception,
char *  msg 
)

Definition at line 1489 of file glue.c.

References Contents, DOLIST, MSG_COLORIZE, MSG_F_DOWN, MSG_F_UP, MSG_ME, MSG_ME_ALL, MSG_NBR_EXITS_A, MSG_S_INSIDE, MSG_S_OUTSIDE, and notify_checked().

01490 {
01491         dbref first;
01492 
01493         if(loc != exception)
01494                 notify_checked(loc, player, msg,
01495                                            (MSG_ME_ALL | MSG_F_UP | MSG_S_INSIDE | MSG_NBR_EXITS_A
01496                                                 | MSG_COLORIZE));
01497         DOLIST(first, Contents(loc)) {
01498                 if(first != exception) {
01499                         notify_checked(first, player, msg,
01500                                                    (MSG_ME | MSG_F_DOWN | MSG_S_OUTSIDE |
01501                                                         MSG_COLORIZE));
01502                 }
01503         }
01504 }

void * NewSpecialObject ( int  id,
int  type 
)

Definition at line 840 of file glue.c.

References AddEntry(), SpecialObjectStruct::allocfreefunc, Create, SpecialObjectStruct::datasize, SPECIAL_ALLOC, SpecialObjects, and xcode_tree.

Referenced by CreateNewSpecialObject(), and LoadSpecialObjects().

00841 {
00842         void *foo;
00843         int i;
00844         dbref *t;
00845 
00846         if(SpecialObjects[type].datasize) {
00847                 Create(foo, char, (i = SpecialObjects[type].datasize));
00848 
00849                 t = (dbref *) foo;
00850                 *t = id;
00851                 if(SpecialObjects[type].allocfreefunc)
00852                         SpecialObjects[type].allocfreefunc(id, &(foo), SPECIAL_ALLOC);
00853                 AddEntry(&xcode_tree, id, type, i, foo);
00854         }
00855         return foo;
00856 }

void raw_notify ( dbref  player,
const char *  msg 
)

Definition at line 243 of file netcommon.c.

00244 {
00245         raw_notify_raw(player, msg, "\r\n");
00246 }

static int remove_from_all_maps_except_func ( Node tmp  )  [static]

Definition at line 237 of file glue.c.

References MAP::first_free, getMap(), global_kludge_mech, GTYPE_MAP, MAP::mechsOnMap, MECH::mynum, NodeKey, and WhichType.

Referenced by mech_remove_from_all_maps_except().

00238 {
00239         if(WhichType(tmp) == GTYPE_MAP) {
00240                 int i;
00241                 MAP *map;
00242 
00243                 if(NodeKey(tmp) == except_map)
00244                         return 1;
00245                 if(!(map = getMap(NodeKey(tmp))))
00246                         return 1;
00247                 for(i = 0; i < map->first_free; i++)
00248                         if(map->mechsOnMap[i] == global_kludge_mech->mynum)
00249                                 map->mechsOnMap[i] = -1;
00250         }
00251         return 1;
00252 }

static int remove_from_all_maps_func ( Node tmp  )  [static]

Definition at line 214 of file glue.c.

References MAP::first_free, getMap(), global_kludge_mech, GTYPE_MAP, MAP::mechsOnMap, MECH::mynum, NodeKey, and WhichType.

Referenced by mech_remove_from_all_maps().

00215 {
00216         if(WhichType(tmp) == GTYPE_MAP) {
00217                 MAP *map;
00218                 int i;
00219 
00220                 if(!(map = getMap(NodeKey(tmp))))
00221                         return 1;
00222                 for(i = 0; i < map->first_free; i++)
00223                         if(map->mechsOnMap[i] == global_kludge_mech->mynum)
00224                                 map->mechsOnMap[i] = -1;
00225         }
00226         return 1;
00227 }

void ResetSpecialObjects ( void   ) 

Definition at line 1510 of file glue.c.

References EVENT_BLINDREC, EVENT_HIDE, FIRST_TECH_EVENT, LAST_TECH_EVENT, and muxevent_run_by_type().

01511 {
01512 #if 0                                                   /* Nowadays no longer neccessary, see mech.tech.saverepair.c */
01513         int i;
01514 
01515         for(i = FIRST_TECH_EVENT; i <= LAST_TECH_EVENT; i++)
01516                 while (muxevent_run_by_type(i));
01517 #endif
01518         muxevent_run_by_type(EVENT_HIDE);
01519         muxevent_run_by_type(EVENT_BLINDREC);
01520 }

static int save_autopilot_data ( Node tmp  )  [static]

Definition at line 631 of file glue.c.

References auto_save_commands(), GTYPE_AUTO, NodeData, and WhichType.

00632 {
00633 
00634         AUTO *a;
00635 
00636         if(WhichType(tmp) == GTYPE_AUTO) {
00637 
00638                 a = (AUTO *) NodeData(tmp);
00639 
00640                 /* Save the AI Command List */
00641                 auto_save_commands(global_file_kludge, a);
00642 
00643                 /* Save the AI Astar Path */
00644 
00645         }
00646 
00647         return 1;
00648 
00649 }

static int save_maps_func ( Node tmp  )  [static]

Definition at line 610 of file glue.c.

References MAP::flags, GTYPE_MAP, MAPFLAG_MAPO, NodeData, save_mapdynamic(), save_mapobjs(), and WhichType.

Referenced by SaveSpecialObjects().

00611 {
00612         MAP *map;
00613 
00614         if(WhichType(tmp) == GTYPE_MAP) {
00615                 /* Write mapobjs, if neccessary */
00616                 map = (MAP *) NodeData(tmp);
00617                 save_mapdynamic(global_file_kludge, map);
00618                 if(map->flags & MAPFLAG_MAPO)
00619                         save_mapobjs(global_file_kludge, map);
00620         }
00621         return 1;
00622 }

void SaveSpecialObjects ( int  i  ) 

Definition at line 747 of file glue.c.

References DUMP_CRASHED, DUMP_KILLED, DUMP_NORMAL, DUMP_RESTART, GoThruTree(), confdata::hcode_db, LBUF_SIZE, log_perror(), mudconf, my_close_file(), my_open_file(), save_maps_func(), saverepairs(), SaveTree(), SendDB, tprintf(), xcode_tree, and XCODE_VERSION.

00748 {
00749         FILE *f;
00750         int filemode, count;
00751         byte xcode_version = XCODE_VERSION;
00752         char target[LBUF_SIZE];
00753 
00754         switch (i) {
00755         case DUMP_KILLED:
00756                 sprintf(target, "%s.KILLED", mudconf.hcode_db);
00757                 break;
00758         case DUMP_CRASHED:
00759                 sprintf(target, "%s.CRASHED", mudconf.hcode_db);
00760                 break;
00761         default:                                        /* RESTART / normal */
00762                 sprintf(target, "%s.tmp", mudconf.hcode_db);
00763                 break;
00764         }
00765         f = my_open_file(target, "w", &filemode);
00766         if(!f) {
00767                 log_perror("SAV", "FAIL", "Opening new hcode-save file", target);
00768                 SendDB("ERROR occured during opening of new hcode-savefile.");
00769                 return;
00770         }
00771         fwrite(&xcode_version, 1, 1, f);
00772         count = SaveTree(f, xcode_tree);
00773         global_file_kludge = f;
00774         /* Then, check each xcode thing for stuff */
00775         GoThruTree(xcode_tree, save_maps_func);
00776 
00777         /* Save autopilot data */
00778         /* GoThruTree(xcode_tree, save_autopilot_data); */
00779 
00780         saverepairs(f);
00781         my_close_file(f, &filemode);
00782         if(i == DUMP_RESTART || i == DUMP_NORMAL) {
00783                 if(rename(mudconf.hcode_db, tprintf("%s.prev", mudconf.hcode_db))
00784                    < 0) {
00785                         log_perror("SAV", "FAIL", "Renaming old hcode-save file ",
00786                                            target);
00787                         SendDB("ERROR occured during renaming of old hcode save-file.");
00788                 }
00789                 if(rename(target, mudconf.hcode_db) < 0) {
00790                         log_perror("SAV", "FAIL", "Renaming new hcode-save file ",
00791                                            target);
00792                         SendDB("ERROR occured during renaming of new hcode save-file.");
00793                 }
00794         }
00795         if(count)
00796                 SendDB(tprintf("Hcode saved. %d xcode entries dumped.", count));
00797 #ifdef BT_ADVANCED_ECON
00798         save_econdb(target, i);
00799 #endif
00800 }

int SaveTree ( FILE *  f,
Tree  tree 
)

Definition at line 103 of file mux_tree.c.

Referenced by SaveSpecialObjects().

00104 {
00105     muxkey_t key;
00106 
00107     nodesave_count = 0;
00108     tree_file = f;
00109     tree_trav(&tree, NodeSave);
00110     key = -1;
00111     fwrite(&key, sizeof(key), 1, tree_file);
00112     return nodesave_count;
00113 }

static int UpdateSpecialObject_func ( Node tmp  )  [static]

Definition at line 802 of file glue.c.

References mudstate, NodeData, NodeKey, statedata::now, SpecialObjects, SpecialObjectStruct::updatefunc, SpecialObjectStruct::updateTime, and WhichType.

Referenced by UpdateSpecialObjects().

00803 {
00804         int i;
00805 
00806         i = WhichType(tmp);
00807         if(!SpecialObjects[i].updateTime)
00808                 return 1;
00809         if((mudstate.now % SpecialObjects[i].updateTime))
00810                 return 1;
00811         SpecialObjects[i].updatefunc(NodeKey(tmp), NodeData(tmp));
00812         return 1;
00813 }

void UpdateSpecialObjects ( void   ) 

Definition at line 821 of file glue.c.

References statedata::debug_cmd, GoThruTree(), mudstate, muxevent_run(), statedata::now, UpdateSpecialObject_func(), and xcode_tree.

00822 {
00823         char *cmdsave;
00824         int i;
00825         int times = lastrun ? (mudstate.now - lastrun) : 1;
00826 
00827         if(times > 20)
00828                 times = 20;                             /* Machine's hopelessly lagged,
00829                                                                    we don't want to make it [much] worse */
00830         cmdsave = mudstate.debug_cmd;
00831         for(i = 0; i < times; i++) {
00832                 muxevent_run();
00833                 mudstate.debug_cmd = (char *) "< Generic hcode update handler>";
00834                 GoThruTree(xcode_tree, UpdateSpecialObject_func);
00835         }
00836         lastrun = mudstate.now;
00837         mudstate.debug_cmd = cmdsave;
00838 }

void UpdateTree ( FILE *  f,
Tree tree,
int(*)(int)  sizefunc 
)

Definition at line 166 of file mux_tree.c.

References MyLoadTree().

Referenced by load_xcode().

00167 {
00168     MyLoadTree(f, tree, sizefunc);
00169 }

int WhichSpecial ( dbref  key  ) 

Definition at line 994 of file glue.c.

References FindObjectsNode(), Good_obj, Hardcode, and NodeType.

Referenced by debug_fixmap(), DisposeSpecialObject(), Dump_Mech(), DumpMaps(), fun_btgetxcodevalue(), fun_btmapelev(), fun_btmapterr(), fun_btremovestores(), fun_btsetxcodevalue(), HandledCommand_sub(), IsAuto(), IsMap(), IsMech(), list_xcodestuff(), and set_xcodestuff().

00995 {
00996         Node *n;
00997 
00998         if(!Good_obj(key))
00999                 return -1;
01000         if(!Hardcode(key))
01001                 return -1;
01002         if(!(n = FindObjectsNode(key)))
01003                 return -1;
01004         return NodeType(n);
01005 }

static int WhichSpecialS ( dbref  key  )  [static]

Definition at line 1010 of file glue.c.

References A_XTYPE, Hardcode, silly_atr_get(), SpecialObjects, and SpecialObjectStruct::type.

Referenced by CreateNewSpecialObject(), DisposeSpecialObject(), HandledCommand_sub(), and LoadSpecialObjects().

01014 {
01015         int i;
01016         int returnValue = -1;
01017         char *str;
01018 
01019         if(!Hardcode(key))
01020                 return -1;
01021         str = silly_atr_get(key, A_XTYPE);
01022         if(str && *str) {
01023                 for(i = 0; i < NUM_SPECIAL_OBJECTS; i++) {
01024                         if(!strcmp(SpecialObjects[i].type, str)) {
01025                                 returnValue = i;
01026                                 break;
01027                         }
01028                 }
01029         }
01030         return (returnValue);
01031 }

static int zap_check ( Node n  )  [static]

Definition at line 544 of file glue.c.

References Hardcode, and NodeKey.

Referenced by zap_unneccessary_hcode().

00545 {
00546         if(zappable_node >= 0)
00547                 return 0;
00548         if(!Hardcode(NodeKey(n))) {
00549                 zappable_node = NodeKey(n);
00550                 return 0;
00551         }
00552         return 1;
00553 }

void zap_unneccessary_hcode ( void   ) 

Definition at line 555 of file glue.c.

References DeleteEntry(), GoThruTree(), xcode_tree, and zap_check().

Referenced by LoadSpecialObjects().

00556 {
00557         while (1) {
00558                 zappable_node = -1;
00559                 GoThruTree(xcode_tree, zap_check);
00560                 if(zappable_node >= 0)
00561                         DeleteEntry(&xcode_tree, zappable_node);
00562                 else
00563                         break;
00564         }
00565 }


Variable Documentation

struct color_entry color_table[]

Referenced by colorize(), and initialize_colorize().

char colorc_reverse[CHARS]

Definition at line 1390 of file glue.c.

dbref except_map = -1 [static]

Definition at line 235 of file glue.c.

FILE* global_file_kludge [static]

Definition at line 608 of file glue.c.

FILE* global_file_kludge [static]

Definition at line 306 of file glue.c.

Referenced by load_xcode().

MECH* global_kludge_mech [static]

Definition at line 211 of file glue.c.

Referenced by mech_remove_from_all_maps(), mech_remove_from_all_maps_except(), remove_from_all_maps_except_func(), and remove_from_all_maps_func().

int global_specials = NUM_SPECIAL_OBJECTS

Definition at line 212 of file glue.c.

time_t lastrun = 0 [static]

Definition at line 820 of file glue.c.

HASHTAB SpecialCommandHash[NUM_SPECIAL_OBJECTS]

Definition at line 97 of file glue.c.

Referenced by HandledCommand_sub(), and InitSpecialHash().

Tree xcode_tree = NULL

Definition at line 98 of file glue.c.

int zappable_node [static]

Definition at line 542 of file glue.c.


Generated on Mon May 28 04:25:44 2007 for BattletechMUX by  doxygen 1.4.7