src/hcode/include/p.glue.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int HandledCommand_sub (dbref player, dbref location, char *command)
int HandledCommand (dbref player, dbref loc, char *command)
void mech_remove_from_all_maps (MECH *mech)
void mech_remove_from_all_maps_except (MECH *mech, int num)
void zap_unneccessary_hcode (void)
void LoadSpecialObjects (void)
void ChangeSpecialObjects (int i)
void SaveSpecialObjects (int i)
void UpdateSpecialObjects (void)
void * NewSpecialObject (int id, int type)
void CreateNewSpecialObject (dbref player, dbref key)
void DisposeSpecialObject (dbref player, dbref key)
void Dump_Mech (dbref player, int type, char *typestr)
void DumpMechs (dbref player)
void DumpMaps (dbref player)
int WhichSpecial (dbref key)
int IsMech (dbref num)
int IsAuto (dbref num)
int IsMap (dbref num)
void * FindObjectsData (dbref key)
char * center_string (char *c, int len)
void InitSpecialHash (int which)
void handle_xcode (dbref player, dbref obj, int from, int to)
void initialize_colorize (void)
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 list_chashstats (dbref player)
void ResetSpecialObjects (void)
MAPgetMap (dbref d)
MECHgetMech (dbref d)


Function Documentation

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 
)

void DisposeSpecialObject ( dbref  player,
dbref  key 
)

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  ) 

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 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 initialize_colorize ( void   ) 

void InitSpecialHash ( int  which  ) 

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_chashstats ( dbref  player  ) 

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 }

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 
)

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 }

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 }

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 }

int WhichSpecial ( dbref  key  ) 

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 }


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