src/hcode/btech/p.template.h File Reference

#include "config.h"

Include dependency graph for p.template.h:

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

Go to the source code of this file.

Functions

int count_special_items (void)
int compare_array (char *list[], char *command)
char * one_arg (char *argument, char *first_arg)
char * one_arg_delim (char *argument, char *first_arg)
char * BuildBitString (char *bitdescs[], int data)
char * BuildBitString2 (char *bitdescs[], char *bitdescs2[], int data, int data2)
char * BuildBitStringwdelim2 (char *bitdescs[], char *bitdescs2[], int data, int data2)
char * BuildBitString3 (char *bitdescs[], char *bitdescs2[], char *bitdescs3[], int data, int data2, int data3)
char * my_shortform (char *buf)
char * part_figure_out_shname (int i)
char * part_figure_out_name (int i)
char * part_figure_out_sname (int i)
void dump_locations (FILE *fp, MECH *mech, const char *locdesc[])
float generic_computer_multiplier (MECH *mech)
int generic_radio_type (int i, int isClan)
float generic_radio_multiplier (MECH *mech)
void computer_conversion (MECH *mech)
void try_to_find_name (char *mechref, MECH *mech)
int DefaultFuelByType (MECH *mech)
int save_template (dbref player, MECH *mech, char *reference, char *filename)
char * read_desc (FILE *fp, char *data)
int find_section (char *cmd, int type, int mtype)
long BuildBitVector (char **list, char *line)
long BuildBitVectorWithDelim (char **list, char *line)
long BuildBitVectorNoErr (char **list, char *line)
int CheckSpecialsList (char **specials, char **specials2, char *line)
int WeaponIFromString (char *data)
int AmmoIFromString (char *data)
void update_specials (MECH *mech)
int update_oweight (MECH *mech, int value)
int get_weight (MECH *mech)
int load_template (dbref player, MECH *mech, char *filename)
void DumpMechSpecialObjects (dbref player)
void DumpWeapons (dbref player)
char * techlist_func (MECH *mech)
char * payloadlist_func (MECH *mech)


Function Documentation

int AmmoIFromString ( char *  data  ) 

Definition at line 1964 of file template.c.

References MechWeapons, name, and x.

01965 {
01966         int x = 0;
01967         char *ptr;
01968 
01969         ptr = data;
01970         while (*ptr != '_')
01971                 ptr++;
01972         ptr++;
01973         while (MechWeapons[x].name) {
01974                 if(!strcasecmp(MechWeapons[x].name, ptr))
01975                         return x + 101;
01976                 x++;
01977         }
01978         return -1;
01979 }

char* BuildBitString ( char *  bitdescs[],
int  data 
)

Definition at line 1231 of file template.c.

References MAX_STRING_LENGTH, and x.

Referenced by dump_locations(), mechrep_Raddinftech(), mechrep_Raddtech(), save_template(), and techlist_func().

01232 {
01233         static char crit[MAX_STRING_LENGTH];
01234         int bv;
01235         int x;
01236 
01237         crit[0] = 0;
01238         for(x = 0; bitdescs[x]; x++) {
01239                 bv = 1U << x;
01240                 if(data & bv) {
01241                         strcat(crit, bitdescs[x]);
01242                         strcat(crit, " ");
01243                 }
01244         }
01245         if((x = strlen(crit)) > 0 && crit[x - 1] == ' ')
01246                 crit[x - 1] = '\0';
01247         return crit;
01248 }

char* BuildBitString2 ( char *  bitdescs[],
char *  bitdescs2[],
int  data,
int  data2 
)

Definition at line 1250 of file template.c.

References MAX_STRING_LENGTH, and x.

Referenced by save_template().

01252 {
01253         static char crit[MAX_STRING_LENGTH];
01254         int bv;
01255         int x;
01256 
01257         crit[0] = 0;
01258 
01259         for(x = 0; bitdescs[x]; x++) {
01260                 bv = 1U << x;
01261                 if(data & bv) {
01262                         strcat(crit, bitdescs[x]);
01263                         strcat(crit, " ");
01264                 }
01265         }
01266 
01267         for(x = 0; bitdescs2[x]; x++) {
01268                 bv = 1U << x;
01269                 if(data2 & bv) {
01270                         strcat(crit, bitdescs2[x]);
01271                         strcat(crit, " ");
01272                 }
01273         }
01274 
01275         if((x = strlen(crit)) > 0 && crit[x - 1] == ' ') {
01276                 crit[x - 1] = '\0';
01277 
01278         }
01279 
01280         return crit;
01281 }

char* BuildBitString3 ( char *  bitdescs[],
char *  bitdescs2[],
char *  bitdescs3[],
int  data,
int  data2,
int  data3 
)

Definition at line 1316 of file template.c.

References MAX_STRING_LENGTH, and x.

Referenced by mechrep_gettechstring().

01318 {
01319         static char crit[MAX_STRING_LENGTH];
01320         int bv;
01321         int x;
01322 
01323         crit[0] = 0;
01324 
01325         for(x = 0; bitdescs[x]; x++) {
01326                 bv = 1U << x;
01327                 if(data & bv) {
01328                         strcat(crit, bitdescs[x]);
01329                         strcat(crit, " ");
01330                 }
01331         }
01332 
01333         for(x = 0; bitdescs2[x]; x++) {
01334                 bv = 1U << x;
01335                 if(data2 & bv) {
01336                         strcat(crit, bitdescs2[x]);
01337                         strcat(crit, " ");
01338                 }
01339         }
01340 
01341         for(x = 0; bitdescs3[x]; x++) {
01342                 bv = 1U << x;
01343                 if(data3 & bv) {
01344                         strcat(crit, bitdescs3[x]);
01345                         strcat(crit, " ");
01346                 }
01347         }
01348 
01349         if((x = strlen(crit)) > 0 && crit[x - 1] == ' ')
01350                 crit[x - 1] = '\0';
01351 
01352         return crit;
01353 }

char* BuildBitStringwdelim2 ( char *  bitdescs[],
char *  bitdescs2[],
int  data,
int  data2 
)

Definition at line 1283 of file template.c.

References MAX_STRING_LENGTH, and x.

Referenced by dump_item(), and techstatus_func().

01285 {
01286         static char crit[MAX_STRING_LENGTH];
01287         int bv;
01288         int x;
01289 
01290         crit[0] = 0;
01291 
01292         for(x = 0; bitdescs[x]; x++) {
01293                 bv = 1U << x;
01294                 if(data & bv) {
01295                         strcat(crit, bitdescs[x]);
01296                         strcat(crit, "|");
01297                 }
01298         }
01299 
01300         for(x = 0; bitdescs2[x]; x++) {
01301                 bv = 1U << x;
01302                 if(data2 & bv) {
01303                         strcat(crit, bitdescs2[x]);
01304                         strcat(crit, "|");
01305                 }
01306         }
01307 
01308         if((x = strlen(crit)) > 0 && crit[x - 1] == '|') {
01309                 crit[x - 1] = '\0';
01310 
01311         }
01312 
01313         return crit;
01314 }

long BuildBitVector ( char **  list,
char *  line 
)

Definition at line 1870 of file template.c.

References compare_array(), and one_arg().

Referenced by load_template(), mechrep_Raddinftech(), mechrep_Raddtech(), and mechrep_Rdeltech().

01871 {
01872         long bv = 0;
01873         int temp;
01874         char buf[30];
01875 
01876         if(!strcasecmp(line, "-"))
01877                 return 0;
01878 
01879         while (*line) {
01880                 line = one_arg(line, buf);
01881                 if((temp = compare_array(list, buf)) == -1)
01882                         return -1;
01883                 bv |= 1U << temp;
01884         }
01885         return bv;
01886 }

long BuildBitVectorNoErr ( char **  list,
char *  line 
)

Definition at line 1909 of file template.c.

References compare_array(), and one_arg().

Referenced by load_template().

01910 {
01911         long bv = 0;
01912         int temp;
01913         char buf[30];
01914 
01915         if(!strcasecmp(line, "-"))
01916                 return 0;
01917 
01918         while (*line) {
01919                 line = one_arg(line, buf);
01920 
01921                 if((temp = compare_array(list, buf)) != -1)
01922                         bv |= 1U << temp;
01923         }
01924 
01925         return bv;
01926 }

long BuildBitVectorWithDelim ( char **  list,
char *  line 
)

Definition at line 1888 of file template.c.

References compare_array(), and one_arg_delim().

Referenced by load_template().

01889 {
01890         long bv = 0;
01891         int temp;
01892         char buf[30];
01893 
01894         if(!strcasecmp(line, "-"))
01895                 return 0;
01896 
01897         while (*line) {
01898                 line = one_arg_delim(line, buf);
01899 
01900                 if((temp = compare_array(list, buf)) == -1)
01901                         return -1;
01902 
01903                 bv |= 1U << temp;
01904         }
01905 
01906         return bv;
01907 }

int CheckSpecialsList ( char **  specials,
char **  specials2,
char *  line 
)

Definition at line 1928 of file template.c.

References compare_array(), and one_arg().

Referenced by load_template().

01929 {
01930         int wSpecCheck = -1, wSpec2Check = -1;
01931         char buf[30];
01932 
01933         if(!strcasecmp(line, "-"))
01934                 return 0;
01935 
01936         while (*line) {
01937                 line = one_arg(line, buf);
01938 
01939                 if(specials)
01940                         wSpecCheck = compare_array(specials, buf);
01941 
01942                 if(specials2)
01943                         wSpec2Check = compare_array(specials2, buf);
01944 
01945                 if((wSpecCheck == -1) && (wSpec2Check == -1))
01946                         return 0;
01947         }
01948 
01949         return 1;
01950 }

int compare_array ( char *  list[],
char *  command 
)

Definition at line 1194 of file template.c.

References x.

01195 {
01196         int x;
01197 
01198         if(!list)
01199                 return -1;
01200         for(x = 0; list[x]; x++)
01201                 if(!strcasecmp(list[x], command))
01202                         return x;
01203 
01204         return -1;
01205 }

void computer_conversion ( MECH mech  ) 

Definition at line 1663 of file template.c.

References MechComputer, MechComputersLRSRange, MechComputersRadioRange, MechComputersScanRange, MechComputersTacRange, MechLRSRange, MechRadioRange, MechScanRange, and MechTacRange.

Referenced by save_template().

01664 {
01665         int l = 0;
01666 
01667         switch (MechScanRange(mech)) {
01668         case 20:
01669                 l = 2;
01670                 break;
01671         case 25:
01672                 l = 3;
01673                 break;
01674         case 30:
01675                 l = 4;
01676                 break;
01677         }
01678         if(l) {
01679                 MechComputer(mech) = l;
01680                 MechScanRange(mech) = MechComputersScanRange(mech);
01681                 MechTacRange(mech) = MechComputersTacRange(mech);
01682                 MechLRSRange(mech) = MechComputersLRSRange(mech);
01683                 MechRadioRange(mech) = MechComputersRadioRange(mech);
01684         }
01685 }

int count_special_items ( void   ) 

Definition at line 1022 of file template.c.

References internals.

Referenced by unable_to_find_proper_type().

01023 {
01024         int i = 0;
01025 
01026         while (internals[i])
01027                 i++;
01028         return i;
01029 }

int DefaultFuelByType ( MECH mech  ) 

Definition at line 1695 of file template.c.

References CLASS_AERO, CLASS_DS, CLASS_SPHEROID_DS, CLASS_VTOL, and MechType.

Referenced by load_template(), and save_template().

01696 {
01697         int mod = 2;
01698 
01699         switch (MechType(mech)) {
01700         case CLASS_VTOL:
01701                 return 2000 * mod;
01702         case CLASS_AERO:
01703                 return 1200 * mod;
01704         case CLASS_DS:
01705         case CLASS_SPHEROID_DS:
01706                 return 3600 * mod;
01707         }
01708         return 0;
01709 }

void dump_locations ( FILE *  fp,
MECH mech,
const char *  locdesc[] 
)

Definition at line 1567 of file template.c.

References BuildBitString(), CASE_TECH, CritsInLoc(), dump_item(), GetSectOArmor, GetSectOInt, GetSectORArmor, MechSections, section_configs, x, and y.

Referenced by save_template().

01568 {
01569         int x, y, l;
01570         char buf[512];
01571         char *ch;
01572 
01573         for(x = 0; locdesc[x]; x++) {
01574                 if(!GetSectOInt(mech, x))
01575                         continue;
01576                 strcpy(buf, locdesc[x]);
01577                 for(ch = buf; *ch; ch++)
01578                         if(*ch == ' ')
01579                                 *ch = '_';
01580                 fprintf(fp, "%s\n", buf);
01581                 if(GetSectOArmor(mech, x))
01582                         fprintf(fp, "  Armor            { %d }\n", GetSectOArmor(mech,
01583                                                                                                                                          x));
01584                 if(GetSectOInt(mech, x))
01585                         fprintf(fp, "  Internals        { %d }\n", GetSectOInt(mech, x));
01586                 if(GetSectORArmor(mech, x))
01587                         fprintf(fp, "  Rear             { %d }\n", GetSectORArmor(mech,
01588                                                                                                                                           x));
01589 #if 0                                                   /* Shouldn't be neccessary to save at all */
01590                 fprintf(fp, "  Recycle          { %d }\n",
01591                                 MechSections(mech)[x].recycle);
01592 #endif
01593                 y = MechSections(mech)[x].config;
01594                 y &= ~CASE_TECH;
01595                 if(y)
01596                         fprintf(fp, "  Config           { %s }\n",
01597                                         BuildBitString(section_configs, y));
01598                 l = CritsInLoc(mech, x);
01599                 for(y = 0; y < l;)
01600                         y += dump_item(fp, mech, x, y);
01601         }
01602 }

void DumpMechSpecialObjects ( dbref  player  ) 

Definition at line 2654 of file template.c.

References AutoCol_StringMenu, c, internals, KillCoolMenu(), and ShowCoolMenu().

Referenced by mechrep_Raddspecial().

02655 {
02656         coolmenu *c;
02657 
02658         c = AutoCol_StringMenu("MechSpecials available", internals);
02659         ShowCoolMenu(player, c);
02660         KillCoolMenu(c);
02661 }

void DumpWeapons ( dbref  player  ) 

Definition at line 2681 of file template.c.

References c, dumpweapon_fun(), KillCoolMenu(), num_def_weapons, SelCol_FunStringMenuK(), and ShowCoolMenu().

Referenced by mechrep_Raddweap(), and mechrep_Rreload().

02682 {
02683         coolmenu *c;
02684 
02685         c = SelCol_FunStringMenuK(1, "MechWeapons available", dumpweapon_fun,
02686                                                           num_def_weapons + 1);
02687         ShowCoolMenu(player, c);
02688         KillCoolMenu(c);
02689 }

int find_section ( char *  cmd,
int  type,
int  mtype 
)

Definition at line 1855 of file template.c.

References compare_array(), and ProperSectionStringFromType().

Referenced by load_template().

01856 {
01857     char section[20];
01858     char *ch;
01859     char **locs;
01860 
01861     strcpy(section, cmd);
01862     for(ch = section; *ch; ch++)
01863         if(*ch == '_')
01864             *ch = ' ';
01865     locs = (char **)ProperSectionStringFromType(type, mtype);
01866     return compare_array((char **) locs, section);
01867     return -1; // Who's retarded? not me!
01868 }

float generic_computer_multiplier ( MECH mech  ) 

Definition at line 1604 of file template.c.

References MechComputer.

01605 {
01606         switch (MechComputer(mech)) {
01607         case 1:
01608                 return 0.8;
01609         case 2:
01610                 return 1;
01611         case 3:
01612                 return 1.25;
01613         case 4:
01614                 return 1.5;
01615         case 5:
01616                 return 1.75;
01617         }
01618         return 0;
01619 }

float generic_radio_multiplier ( MECH mech  ) 

Definition at line 1634 of file template.c.

References MechRadio.

01635 {
01636         switch (MechRadio(mech)) {
01637         case 1:
01638                 return 0.8;
01639         case 2:
01640                 return 1;
01641         case 3:
01642                 return 1.25;
01643         case 4:
01644                 return 1.5;
01645         case 5:
01646                 return 1.75;
01647         }
01648         return 0.0;
01649 }

int generic_radio_type ( int  i,
int  isClan 
)

Definition at line 1621 of file template.c.

References DEFAULT_FREQS, FREQS, and RADIO_RELAY.

Referenced by load_template(), mechrep_Rsetradio(), and save_template().

01622 {
01623         int f = DEFAULT_FREQS;
01624 
01625         if(isClan || i >= 4)
01626                 f += FREQS * RADIO_RELAY;
01627         if(i < 3)
01628                 f -= (3 - i) * 2 - 1;   /* 2 or 4 */
01629         else
01630                 f += (i - 3) * 3;               /* 5 / 8 / 11 */
01631         return f;
01632 }

int get_weight ( MECH mech  ) 

Definition at line 2238 of file template.c.

References GOD, mech_weight_sub(), MechCritStatus, MechRTonsV, OWEIGHT_OK, and update_oweight().

Referenced by MechCargoMaxSpeed().

02239 {
02240         if(MechCritStatus(mech) & OWEIGHT_OK)
02241                 return MechRTonsV(mech);
02242         return update_oweight(mech, mech_weight_sub(GOD, mech, -1));
02243 }

int load_template ( dbref  player,
MECH mech,
char *  filename 
)

Definition at line 2245 of file template.c.

References A_MECHREF, AeroFuel, AeroFuelOrig, AeroSI, AeroSIOrig, Ammo2I, confdata::btech_parts, BuildBitVector(), BuildBitVectorNoErr(), BuildBitVectorWithDelim(), CargoSpace, CarMaxTon, CASE_TECH, CheckSpecialsList(), CL_ANTI_MISSILE_TECH, CLASS_BSUIT, CLASS_MECH, CLASS_MW, CLAT, compare_array(), crit_ammo_modes, crit_fire_modes, CritsInLoc(), DEFAULT_CLCOMPUTER, DEFAULT_CLPART_LEVEL, DEFAULT_CLRADIO, DEFAULT_COMPUTER, DEFAULT_HEATSINKS, DEFAULT_LRSRANGE, DEFAULT_PART_LEVEL, DEFAULT_RADIO, DEFAULT_RADIORANGE, DEFAULT_SCANRANGE, DEFAULT_TACRANGE, DefaultFuelByType(), do_sub_magic(), find_matching_vlong_part(), find_section(), FindObjectsData(), FLIPABLE_ARMS, FullAmmo(), generic_radio_type(), GetPartAmmoMode, GetPartBrand, GetPartData, GetPartFireMode, GetPartType, GetSectOArmor, GetSectOInt, GetSectORArmor, GOD, HALFTON_MODE, HAND_OR_FOOT_ACTUATOR, ICE_TECH, infantry_specials, IS_ANTI_MISSILE_TECH, IsAmmo, IsAMS, IsBomb, IsWeapon, LARM, line, load_cmds, LOWER_ACTUATOR, MAX_STRING_LENGTH, mech_int_check(), mech_types, mech_weight_sub(), MechBV, MechComputer, MechComputersLRSRange, MechComputersRadioRange, MechComputersScanRange, MechComputersTacRange, MechEngineSizeC, MechEngineSizeV, MechInfantrySpecials, MechJumpSpeed, MechLRSRange, MechMaxSpeed, MechMaxSuits, MechMove, MechRadio, MechRadioRange, MechRadioType, MechRealNumsinks, MechScanRange, MechSections, MechSpecials, MechSpecials2, MechTacRange, MechTons, MechType, MechType_Name, MechType_Ref, MechWeapons, MechXPMod, move_types, mudconf, MECH::mynum, name, NUM_SECTIONS, one_arg(), RARM, read_desc(), section_configs, SECTION_DESTROYED, SendError, Set, SetMaxSpeed, SetPartAmmoMode, SetPartBrand, SetPartData, SetPartDesiredAmmoLoc, SetPartFireMode, SetPartType, SetSectArmor, SetSectDestroyed, SetSectInt, SetSectOArmor, SetSectOInt, SetSectORArmor, SetSectRArmor, silly_atr_set(), Special, specials, specials2, Startup, TEMPLATE_ERR, TEMPLATE_GERR, TemplateMaxSpeed, tprintf(), update_oweight(), update_specials(), UpdateConditions(), Weapon2I, x, and y.

Referenced by load_mechdata2().

02246 {
02247         char line[MAX_STRING_LENGTH], buf[MAX_STRING_LENGTH];
02248         int x, y, value, i;
02249         char cmd[MAX_STRING_LENGTH];
02250         char *ptr, *j, *k, *line2;
02251         int section = 0, critical, selection, type, brand;
02252         FILE *fp = fopen(filename, "r");
02253         char *tmpc;
02254         int lpos, hpos;
02255         int ok_count = 0;
02256         int isClan = 0;
02257         int t;
02258         int wFireModes, wAmmoModes;
02259         MAP *map;
02260 
02261         if(!fp)
02262                 return -1;
02263 
02264         ptr = strrchr(filename, '/');
02265         if(ptr == NULL) {
02266                 ptr = filename;
02267         } else {
02268                 ptr++;
02269         }
02270         strncpy(MechType_Ref(mech), ptr, 15);
02271         MechType_Ref(mech)[14] = '\0';
02272 
02273         silly_atr_set(mech->mynum, A_MECHREF, MechType_Ref(mech));
02274         MechRadioType(mech) = 0;
02275         while (fgets(line, 512, fp)) {
02276                 line[strlen(line) - 1] = '\0';
02277                 j = line;
02278                 while (isspace(*j))
02279                         j++;
02280                 if(j != line)
02281                         memmove(line, j, strlen(j) + 1);
02282                 if((ptr = strchr(line, ' '))) {
02283                         if((tmpc = strchr(line, '\t')) < ptr)
02284                                 if(tmpc)
02285                                         ptr = tmpc;
02286                         j = line;
02287                         k = cmd;
02288                         while (j != ptr)
02289                                 *(k++) = *(j++);
02290                         *k = 0;
02291                         for(ptr++; isspace(*ptr); ptr++);
02292                 } else {
02293                         strcpy(cmd, line);
02294                         strcpy(line, "");
02295                         ptr = NULL;
02296                 }
02297                 if(!strncasecmp(cmd, "CRIT_", 5))
02298                         selection = 9999;
02299                 else if((selection = compare_array(load_cmds, cmd)) == -1) {
02300                         /* Initial premise: we will have a mech type before we get to this */
02301                         section = find_section(cmd, MechType(mech), MechMove(mech));
02302                         TEMPLATE_ERR(section == -1 &&
02303                                                  !ok_count,
02304                                                  "New template loading system: %s is invalid template file.",
02305                                                  filename);
02306                         TEMPLATE_GERR(section == -1,
02307                                                   "Error while loading: Section %s not found.", cmd);
02308                         MechSections(mech)[section].recycle = 0;
02309                         ok_count++;
02310                         continue;
02311                 }
02312                 ok_count++;
02313                 switch (selection) {
02314                 case 0:                         /* Reference */
02315                         tmpc = read_desc(fp, ptr);
02316                         if(strcmp(tmpc, MechType_Ref(mech))) {
02317                                 SendError(tprintf
02318                                                   ("Template %s has Reference <-> Filename mismatch : %s <-> %s - It is automatically fixed by saving again.",
02319                                                    filename, tmpc, MechType_Ref(mech)));
02320                                 tmpc = MechType_Ref(mech);
02321                         }
02322                         silly_atr_set(mech->mynum, A_MECHREF, tmpc);
02323                         strcpy(MechType_Ref(mech), tmpc);
02324                         break;
02325                 case 1:                         /* Type */
02326                         tmpc = read_desc(fp, ptr);
02327                         MechType(mech) = compare_array(mech_types, tmpc);
02328                         TEMPLATE_GERR(MechType(mech) == -1,
02329                                                   "Error while loading: Type %s not found.", tmpc);
02330                         AeroFuel(mech) = AeroFuelOrig(mech) = DefaultFuelByType(mech);
02331                         break;
02332                 case 2:                         /* Movement Type */
02333                         tmpc = read_desc(fp, ptr);
02334                         MechMove(mech) = compare_array(move_types, tmpc);
02335                         TEMPLATE_GERR(MechMove(mech) == -1,
02336                                                   "Error while loading: Type %s not found.", tmpc);
02337                         break;
02338                 case 3:                         /* Tons */
02339                         MechTons(mech) = atoi(read_desc(fp, ptr));
02340                         break;
02341                 case 4:                         /* Tac_Range */
02342                         MechTacRange(mech) = atoi(read_desc(fp, ptr));
02343                         break;
02344                 case 5:                         /* LRS_Range */
02345                         MechLRSRange(mech) = atoi(read_desc(fp, ptr));
02346                         break;
02347                 case 6:                         /* Radio Range */
02348                         MechRadioRange(mech) = atoi(read_desc(fp, ptr));
02349                         break;
02350                 case 7:                         /* Scan Range */
02351                         MechScanRange(mech) = atoi(read_desc(fp, ptr));
02352                         break;
02353                 case 8:                         /* Heat Sinks */
02354                         MechRealNumsinks(mech) = atoi(read_desc(fp, ptr));
02355                         break;
02356                 case 9:                         /* Max Speed */
02357                         SetMaxSpeed(mech, atof(read_desc(fp, ptr)));
02358                         TemplateMaxSpeed(mech) = MechMaxSpeed(mech);
02359                         break;
02360                 case 10:                                /* Specials */
02361                         tmpc = read_desc(fp, ptr);
02362 
02363                         if(CheckSpecialsList(specials, specials2, tmpc)) {
02364                                 MechSpecials(mech) |= BuildBitVectorNoErr(specials, tmpc);
02365                                 MechSpecials2(mech) |= BuildBitVectorNoErr(specials2, tmpc);
02366                         } else
02367                                 TEMPLATE_GERR(MechSpecials(mech) == -1,
02368                                                           "Error while loading: Invalid specials - %s.",
02369                                                           tmpc);
02370                         break;
02371                 case 11:                                /* Armor */
02372                         SetSectOArmor(mech, section, atoi(read_desc(fp, ptr)));
02373                         SetSectArmor(mech, section, GetSectOArmor(mech, section));
02374                         break;
02375                 case 12:                                /* Internals */
02376                         SetSectOInt(mech, section, atoi(read_desc(fp, ptr)));
02377                         SetSectInt(mech, section, GetSectOInt(mech, section));
02378                         break;
02379                 case 13:                                /* Rear */
02380                         SetSectORArmor(mech, section, atoi(read_desc(fp, ptr)));
02381                         SetSectRArmor(mech, section, GetSectORArmor(mech, section));
02382                         break;
02383                 case 14:                                /* Config */
02384                         tmpc = read_desc(fp, ptr);
02385                         MechSections(mech)[section].config =
02386                                 BuildBitVector(section_configs,
02387                                                            tmpc) & ~(CASE_TECH | SECTION_DESTROYED);
02388                         TEMPLATE_GERR(MechSections(mech)[section].config == -1,
02389                                                   "Error while loading: Invalid location config: %s.",
02390                                                   tmpc);
02391                         break;
02392                 case 9999:
02393                         if((sscanf(cmd, "CRIT_%d-%d", &x, &y)) == 2) {
02394                                 lpos = x - 1;
02395                                 hpos = y - 1;
02396                         } else if((sscanf(cmd, "CRIT_%d", &x)) == 1) {
02397                                 lpos = x - 1;
02398                                 hpos = x - 1;
02399                         } else
02400                                 break;
02401                         critical = lpos;
02402                         line2 = read_desc(fp, ptr);
02403                         line2 = one_arg(line2, buf);
02404                         if(!strncasecmp(buf, "CL.", 3))
02405                                 isClan = 1;
02406                         TEMPLATE_GERR(!(find_matching_vlong_part(buf, NULL, &type,
02407                                                                                                          &brand)),
02408                                                   "Unable to find %s", buf);
02409                         SetPartType(mech, section, critical, type);
02410                         if(!mudconf.btech_parts)
02411                                 brand = 0;
02412                         SetPartBrand(mech, section, critical, brand);
02413                         SetPartDesiredAmmoLoc(mech, section, critical, -1);
02414 
02415                         if(IsWeapon(type)) {
02416                                 /* Thanks to legacy of past, we _do_ have to do this.. sniff */
02417                                 if(IsAMS(Weapon2I(type))) {
02418                                         if(MechWeapons[Weapon2I(type)].special & CLAT)
02419                                                 MechSpecials(mech) |= CL_ANTI_MISSILE_TECH;
02420                                         else
02421                                                 MechSpecials(mech) |= IS_ANTI_MISSILE_TECH;
02422                                 }
02423                                 SetPartData(mech, section, critical, 0);
02424                                 line2 = one_arg(line2, buf);    /* Don't need the '-' */
02425                                 line2 = one_arg(line2, buf);
02426 
02427 /*              wFireModes = BuildBitVector(crit_fire_modes, buf); */
02428 
02429 /*              wAmmoModes = BuildBitVector(crit_ammo_modes, buf); */
02430 
02431                                 wFireModes = BuildBitVectorWithDelim(crit_fire_modes, buf);
02432                                 wAmmoModes = BuildBitVectorWithDelim(crit_ammo_modes, buf);
02433 
02434                                 TEMPLATE_GERR(((wFireModes < 0) && (wAmmoModes < 0)),
02435                                                           "Error while loading: Invalid crit modes for weapon: %s.",
02436                                                           buf);
02437 
02438                                 if(wFireModes < 0)
02439                                         wFireModes = 0;
02440 
02441                                 if(wAmmoModes < 0)
02442                                         wAmmoModes = 0;
02443 
02444                                 GetPartFireMode(mech, section, critical) = wFireModes;
02445                                 GetPartAmmoMode(mech, section, critical) = wAmmoModes;
02446 
02447                                 line2 = one_arg(line2, buf);
02448                                 if(mudconf.btech_parts)
02449                                         if(atoi(buf)) {
02450                                                 SetPartBrand(mech, section, critical, atoi(buf));
02451                                         }
02452                         } else if(IsAmmo(type)) {
02453                                 line2 = one_arg(line2, buf);
02454                                 GetPartData(mech, section, critical) = atoi(buf);
02455                                 line2 = one_arg(line2, buf);
02456 
02457 /*              wFireModes = BuildBitVector(crit_fire_modes, buf); */
02458 
02459 /*              wAmmoModes = BuildBitVector(crit_ammo_modes, buf); */
02460 
02461                                 wFireModes = BuildBitVectorWithDelim(crit_fire_modes, buf);
02462                                 wAmmoModes = BuildBitVectorWithDelim(crit_ammo_modes, buf);
02463 
02464                                 TEMPLATE_GERR(((wFireModes < 0) && (wAmmoModes < 0)),
02465                                                           "Error while loading: Invalid crit modes for ammo: %s.",
02466                                                           buf);
02467 
02468                                 if(wFireModes < 0)
02469                                         wFireModes = 0;
02470 
02471                                 if(wAmmoModes < 0)
02472                                         wAmmoModes = 0;
02473 
02474                                 GetPartFireMode(mech, section, critical) = wFireModes;
02475                                 GetPartAmmoMode(mech, section, critical) = wAmmoModes;
02476 
02477                                 if(GetPartData(mech, section, critical) < FullAmmo(mech,
02478                                                                                                                                    section,
02479                                                                                                                                    critical))
02480                                 {
02481                                         GetPartFireMode(mech, section, critical) |= HALFTON_MODE;
02482                                         if(GetPartData(mech, section,
02483                                                                    critical) > FullAmmo(mech, section,
02484                                                                                                                 critical))
02485                                                 GetPartFireMode(mech, section, critical) &=
02486                                                         ~HALFTON_MODE;
02487                                 }
02488 
02489                                 if(GetPartData(mech, section, critical) != FullAmmo(mech,
02490                                                                                                                                         section,
02491                                                                                                                                         critical)
02492                                    && MechType(mech) != CLASS_MW
02493                                    && MechType(mech) != CLASS_BSUIT) {
02494                                         SendError(tprintf
02495                                                           ("Invalid ammo crit for %s in #%d %s (%d/%d)",
02496                                                            MechWeapons[Ammo2I(type)].name, mech->mynum,
02497                                                            filename, GetPartData(mech, section, critical),
02498                                                            FullAmmo(mech, section, critical))
02499                                                 );
02500                                         SetPartData(mech, section, critical, FullAmmo(mech,
02501                                                                                                                                   section,
02502                                                                                                                                   critical));
02503                                 }
02504                         } else {
02505                                 GetPartData(mech, section, critical) = 0;
02506                                 GetPartFireMode(mech, section, critical) = 0;
02507                                 GetPartAmmoMode(mech, section, critical) = 0;
02508                                 if((line2 = one_arg(line2, buf)))
02509                                         if((line2 = one_arg(line2, buf))) {
02510                                                 line2 = one_arg(line2, buf);
02511                                                 if(mudconf.btech_parts)
02512                                                         if(atoi(buf)) {
02513                                                                 SetPartBrand(mech, section, critical,
02514                                                                                          atoi(buf));
02515                                                         }
02516                                         }
02517                         }
02518                         for(x = (lpos + 1); x <= hpos; x++) {
02519                                 SetPartType(mech, section, x, GetPartType(mech, section,
02520                                                                                                                   lpos));
02521                                 SetPartData(mech, section, x, GetPartData(mech, section,
02522                                                                                                                   lpos));
02523                                 SetPartFireMode(mech, section, x, GetPartFireMode(mech,
02524                                                                                                                                   section,
02525                                                                                                                                   lpos));
02526                                 SetPartAmmoMode(mech, section, x,
02527                                                                 GetPartAmmoMode(mech, section, lpos));
02528                                 SetPartBrand(mech, section, x,
02529                                                          GetPartBrand(mech, section, lpos));
02530                         }
02531                         break;
02532                 case 15:                                /* Mech's Computer level */
02533                         MechComputer(mech) = atoi(read_desc(fp, ptr));
02534                         break;
02535                 case 16:                                /* Name of the mech */
02536                         strcpy(MechType_Name(mech), read_desc(fp, ptr));
02537                         break;
02538                 case 17:                                /* Jj's */
02539                         MechJumpSpeed(mech) = atof(read_desc(fp, ptr));
02540                         break;
02541                 case 18:                                /* Radio */
02542                         MechRadio(mech) = atoi(read_desc(fp, ptr));
02543                         break;
02544                 case 19:                                /* SI */
02545                         AeroSI(mech) = AeroSIOrig(mech) = atoi(read_desc(fp, ptr));
02546                         break;
02547                 case 20:                                /* Fuel */
02548                         AeroFuel(mech) = AeroFuelOrig(mech) = atoi(read_desc(fp, ptr));
02549                         break;
02550                 case 21:                                /* Comment */
02551                         break;
02552                 case 22:                                /* Radio_freqs */
02553                         MechRadioType(mech) = atoi(read_desc(fp, ptr));
02554                         break;
02555                 case 23:                                /* Mech battle value */
02556                         MechBV(mech) = atoi(read_desc(fp, ptr));
02557                         break;
02558                 case 24:                                /* Cargospace */
02559                         CargoSpace(mech) = atoi(read_desc(fp, ptr));
02560                         break;
02561                 case 25:                                /* Maxsuits */
02562                         MechMaxSuits(mech) = atoi(read_desc(fp, ptr));
02563                         break;
02564                 case 26:                                /* Specials */
02565                         tmpc = read_desc(fp, ptr);
02566 
02567                         if(CheckSpecialsList(infantry_specials, 0, tmpc))
02568                                 MechInfantrySpecials(mech) |=
02569                                         BuildBitVectorNoErr(infantry_specials, tmpc);
02570 
02571                         break;
02572                 case 27:                                /* Carmaxton */
02573                         CarMaxTon(mech) = atoi(read_desc(fp, ptr));
02574                         break;
02575                 }
02576         }
02577         fclose(fp);
02578         MechEngineSizeV(mech) = MechEngineSizeC(mech);
02579 #define Set(a,b) \
02580                 if (!(a)) a = b
02581         if(!(MechSpecials(mech) & ICE_TECH))
02582                 Set(MechRealNumsinks(mech), DEFAULT_HEATSINKS);
02583         if(MechType(mech) == CLASS_MECH)
02584                 do_sub_magic(mech, 1);
02585         if(MechType(mech) == CLASS_MW)
02586                 Startup(mech);
02587 
02588         if(MechType(mech) == CLASS_MECH)
02589                 value = 8;
02590         else
02591                 value = 6;
02592 
02593         if(mudconf.btech_parts)
02594                 for(x = 0; x < value; x++)
02595                         for(y = 0; y < CritsInLoc(mech, x); y++)
02596                                 if((t = GetPartType(mech, x, y))) {
02597                                         if(GetPartBrand(mech, x, y))
02598                                                 continue;
02599                                         if(IsAmmo(t))
02600                                                 continue;
02601                                         if(IsBomb(t))
02602                                                 continue;
02603                                         SetPartBrand(mech, x, y,
02604                                                                  isClan ? DEFAULT_CLPART_LEVEL :
02605                                                                  DEFAULT_PART_LEVEL);
02606                                 }
02607         if(isClan) {
02608                 Set(MechComputer(mech), DEFAULT_CLCOMPUTER);
02609                 Set(MechRadio(mech), DEFAULT_CLRADIO);
02610         } else {
02611                 Set(MechComputer(mech), DEFAULT_COMPUTER);
02612                 Set(MechRadio(mech), DEFAULT_RADIO);
02613         }
02614         if(!MechRadioType(mech))
02615                 MechRadioType(mech) = generic_radio_type(MechRadio(mech), isClan);
02616         if(!MechComputer(mech)) {
02617                 Set(MechScanRange(mech), DEFAULT_SCANRANGE);
02618                 Set(MechLRSRange(mech), DEFAULT_LRSRANGE);
02619                 Set(MechRadioRange(mech), DEFAULT_RADIORANGE);
02620                 Set(MechTacRange(mech), DEFAULT_TACRANGE);
02621         } else {
02622                 Set(MechScanRange(mech), MechComputersScanRange(mech));
02623                 Set(MechLRSRange(mech), MechComputersLRSRange(mech));
02624                 Set(MechRadioRange(mech), MechComputersRadioRange(mech));
02625                 Set(MechTacRange(mech), MechComputersTacRange(mech));
02626         }
02627 #if 1                                                   /* Don't know if we're ready for this yet - aw, what the hell :) */
02628         if(MechType(mech) == CLASS_MECH)
02629                 if((GetPartType(mech, LARM, 2) != Special(LOWER_ACTUATOR)) &&
02630                    (GetPartType(mech, RARM, 2) != Special(LOWER_ACTUATOR)) &&
02631                    (GetPartType(mech, LARM, 3) != Special(HAND_OR_FOOT_ACTUATOR))
02632                    && (GetPartType(mech, RARM, 3) != Special(HAND_OR_FOOT_ACTUATOR)))
02633                         MechSpecials(mech) |= FLIPABLE_ARMS;
02634 #endif
02635         update_specials(mech);
02636         MechXPMod(mech) = 1.0; /* Default it to 1 (no mod effect at all) */
02637         mech_int_check(mech, 1);
02638         x = mech_weight_sub(GOD, mech, 0);
02639         y = MechTons(mech) * 1024;
02640         if(abs(x - y) > 40)
02641                 SendError(tprintf
02642                                   ("Error in %s template: %.1f tons of 'stuff', yet %d ton frame.",
02643                                    MechType_Ref(mech), x / 1024.0, y / 1024));
02644         update_oweight(mech, x);
02645         if((map = FindObjectsData(mech->mapindex)))
02646                 UpdateConditions(mech, map);
02647         /* To prevent certain funny occurences.. */
02648         for(i = 0; i < NUM_SECTIONS; i++)
02649                 if(!(GetSectOInt(mech, i)))
02650                         SetSectDestroyed(mech, i);
02651         return 0;
02652 }

char* my_shortform ( char *  buf  ) 

Definition at line 1420 of file template.c.

References c, MBUF_SIZE, and tprintf().

01421 {
01422         static char buf2[MBUF_SIZE];
01423         char *c, *d;
01424 
01425         if(!buf)
01426                 return NULL;
01427         if(strlen(buf) <= 4 && !strchr(buf, '/'))
01428                 strcpy(buf2, buf);
01429         else {
01430                 for(c = buf, d = buf2; *c; c++)
01431                         if(isdigit(*c) || isupper(*c) || *c == '_')
01432                                 *d++ = *c;
01433                 *d = 0;
01434                 if(strlen(buf2) == 1)
01435                         strcat(d, tprintf("%c", buf[1]));
01436         }
01437         return buf2;
01438 }

char* one_arg ( char *  argument,
char *  first_arg 
)

Definition at line 1207 of file template.c.

Referenced by BuildBitVector(), BuildBitVectorNoErr(), CheckSpecialsList(), and load_template().

01208 {
01209         if(isspace(*argument))
01210                 for(argument++; isspace(*argument); argument++);
01211 
01212         while (*argument && !isspace(*argument))
01213                 *(first_arg++) = *(argument++);
01214         *first_arg = '\0';
01215         return argument;
01216 }

char* one_arg_delim ( char *  argument,
char *  first_arg 
)

Definition at line 1218 of file template.c.

Referenced by BuildBitVectorWithDelim().

01219 {
01220         if(isspace(*argument) || (*argument == '|'))
01221                 for(argument++; (isspace(*argument) || (*argument == '|'));
01222                         argument++);
01223 
01224         while (*argument && (!(*argument == '|')))
01225                 *(first_arg++) = *(argument++);
01226 
01227         *first_arg = '\0';
01228         return argument;
01229 }

char* part_figure_out_name ( int  i  ) 

Definition at line 1470 of file template.c.

References part_figure_out_name_sub().

01471 {
01472         return part_figure_out_name_sub(i, 0);
01473 }

char* part_figure_out_shname ( int  i  ) 

Definition at line 1447 of file template.c.

References Ammo2WeaponI, Bomb2I, bomb_name(), cargo, Cargo2I, CLCH, I2Ammo, I2Cargo, I2Special, I2Weapon, internal_count, internals, IsAmmo, IsBomb, IsCargo, IsSpecial, IsWeapon, MBUF_SIZE, MechWeapons, my_shortform(), name, num_def_weapons, Special2I, and Weapon2I.

01448 {
01449         char buf[MBUF_SIZE];
01450 
01451         if(!i)
01452                 return NULL;
01453         buf[0] = 0;
01454         if(IsWeapon(i) && i < I2Weapon(num_def_weapons)) {
01455                 strcpy(buf, &MechWeapons[Weapon2I(i)].name[CLCH(Weapon2I(i))]);
01456         } else if(IsAmmo(i) && i < I2Ammo(num_def_weapons)) {
01457                 sprintf(buf, "Ammo_%s",
01458                                 &MechWeapons[Ammo2WeaponI(i)].name[CLCH(Ammo2WeaponI(i))]);
01459         } else if(IsBomb(i))
01460                 sprintf(buf, "Bomb_%s", bomb_name(Bomb2I(i)));
01461         else if(IsSpecial(i) && i < I2Special(internal_count))
01462                 strcpy(buf, internals[Special2I(i)]);
01463         if(IsCargo(i) && i < I2Cargo(cargo_count))
01464                 strcpy(buf, cargo[Cargo2I(i)]);
01465         if(!buf[0])
01466                 return NULL;
01467         return my_shortform(buf);
01468 }

char* part_figure_out_sname ( int  i  ) 

Definition at line 1475 of file template.c.

References part_figure_out_name_sub().

01476 {
01477         return part_figure_out_name_sub(i, 1);
01478 }

char* payloadlist_func ( MECH mech  ) 

Definition at line 2757 of file template.c.

References FindWeapons, GetPartType, IsAmmo, MAX_WEAPS_SECTION, MBUF_SIZE, MechWeapons, name, NUM_SECTIONS, and partname_func().

Referenced by fun_btpayload_ref().

02758 {
02759         static char buffer[MBUF_SIZE];
02760 
02761         unsigned char weaparray[MAX_WEAPS_SECTION];
02762         unsigned char weapdata[MAX_WEAPS_SECTION];
02763         int critical[MAX_WEAPS_SECTION];
02764         short ammomode;
02765         int temp_crit;
02766 
02767         int count, weap_count, ammo_count, section_loop, weap_loop, put_loop;
02768         char payloadbuff[120];
02769 
02770         unsigned short payload_items[8 * MAX_WEAPS_SECTION];
02771         unsigned short payload_items_count[8 * MAX_WEAPS_SECTION];
02772 
02773         /* Clear the buffer */
02774         snprintf(buffer, MBUF_SIZE, "%s", "");
02775 
02776         /* Count each 'unique' item */
02777         weap_count = 0;
02778         ammo_count = 0;
02779 
02780         /* Initialize array */
02781         for(put_loop = 0; put_loop < 8 * MAX_WEAPS_SECTION; put_loop++) {
02782                 payload_items[put_loop] = 0;
02783                 payload_items_count[put_loop] = 0;
02784         }
02785 
02786         /* Get the weapons for each sections */
02787         for(section_loop = 0; section_loop < NUM_SECTIONS; section_loop++) {
02788 
02789                 /* Get all the weapons for that section */
02790                 count =
02791                         FindWeapons(mech, section_loop, weaparray, weapdata, critical);
02792                 /* Check if any weapons in that section */
02793                 if(count <= 0)
02794                         continue;
02795 
02796                 /* Loop through all the weapons found and store their values */
02797                 for(weap_loop = 0; weap_loop < count; weap_loop++) {
02798 
02799                         /* Loop to put weapons in the temp array and keep count */
02800                         for(put_loop = 0; put_loop < 8 * MAX_WEAPS_SECTION; put_loop++) {
02801 
02802                                 /* Check to see if there is already an entry */
02803                                 if(payload_items[put_loop] == weaparray[weap_loop]) {
02804                                         payload_items_count[put_loop]++;
02805                                         break;
02806                                         /* Ok, see if there is no entry */
02807                                 } else if(payload_items[put_loop] == 0) {
02808                                         payload_items[put_loop] = weaparray[weap_loop];
02809                                         payload_items_count[put_loop]++;
02810                                         weap_count++;
02811                                         break;
02812                                 }
02813 
02814                         }                                       /* End of put loop */
02815 
02816                 }                                               /* End of weap count loop */
02817 
02818         }                                                       /* End of section loop */
02819 
02820         /* Loop through all the sections */
02821         for(section_loop = 0; section_loop < NUM_SECTIONS; section_loop++) {
02822 
02823                 /* Loop through all the crits in a section */
02824                 for(count = 0; count < MAX_WEAPS_SECTION; count++) {
02825 
02826                         /* Get the Part at that spot */
02827                         temp_crit = GetPartType(mech, section_loop, count);
02828 
02829                         /* Is it Ammo? */
02830                         if(IsAmmo(temp_crit)) {
02831 
02832                                 /* Loop to put weapons in the temp array and keep count */
02833                                 for(put_loop = weap_count; put_loop < 8 * MAX_WEAPS_SECTION;
02834                                         put_loop++) {
02835 
02836                                         /* Check to see if there is already an entry */
02837                                         if(payload_items[put_loop] == temp_crit) {
02838                                                 payload_items_count[put_loop]++;
02839                                                 break;
02840                                                 /* Ok, see if there is no entry */
02841                                         } else if(payload_items[put_loop] == 0) {
02842                                                 payload_items[put_loop] = temp_crit;
02843                                                 payload_items_count[put_loop]++;
02844                                                 ammo_count++;
02845                                                 break;
02846                                         }
02847 
02848                                 }                               /* End of put loop */
02849 
02850                         }
02851                         /* End of is it Ammo if Statement */
02852                 }                                               /* End of Crit Slot Loop */
02853 
02854         }                                                       /* End of Section Loop */
02855 
02856         /* Final loop to print out the full payload to the buffer and return it */
02857         for(put_loop = 0; put_loop < (weap_count + ammo_count); put_loop++) {
02858 
02859                 /* If its a weapon use this method of printing it out
02860                  * Else use the part method */
02861                 if(put_loop < weap_count) {
02862                         sprintf(payloadbuff, "%s:%d",
02863                                         &MechWeapons[payload_items[put_loop]].name[0],
02864                                         payload_items_count[put_loop]);
02865                 } else {
02866                         sprintf(payloadbuff, "%s:%d",
02867                                         partname_func(payload_items[put_loop], 'V'),
02868                                         payload_items_count[put_loop]);
02869                 }
02870 
02871                 /* If we are not at the end, then put a | as a spacer */
02872                 if(put_loop < (weap_count + ammo_count - 1)) {
02873                         strncat(payloadbuff, "|", sizeof(buffer) - strlen(buffer) - 1);
02874                 }
02875 
02876                 /* Adding it to the main buffer */
02877                 strncat(buffer, payloadbuff, sizeof(buffer) - strlen(buffer) - 1);
02878 
02879         }                                                       /* End of printing loop */
02880 
02881         return buffer;
02882 }

char* read_desc ( FILE *  fp,
char *  data 
)

Definition at line 1810 of file template.c.

References MAX_STRING_LENGTH.

Referenced by load_template().

01811 {
01812         char keep[MAX_STRING_LENGTH + 500];
01813         char *t, *tmp;
01814         char *point;
01815         int length = 0;
01816         static char buf[MAX_STRING_LENGTH];
01817 
01818         keep[0] = '\0';
01819         if((tmp = strchr(data, '{'))) {
01820                 fscanf(fp, "\n");
01821                 while (isspace(*(++tmp)));
01822                 if((t = strchr(tmp, '}'))) {
01823                         while (isspace(*(t--)));
01824                         *(t++) = '\0';
01825                         length = strlen(tmp);
01826                         strcpy(buf, tmp);
01827                         return buf;
01828                 } else {
01829                         strcpy(keep, tmp);
01830                         strcat(keep, "\r\n");
01831                         t = tmp + strlen(tmp) - 1;
01832                         length = strlen(t);
01833                         while (fgets(data, 512, fp)) {
01834                                 fscanf(fp, "\n");
01835                                 if((tmp = strchr(data, '}')) != NULL) {
01836                                         *tmp = 0;
01837                                         length += strlen(data);
01838                                         strcat(keep, data);
01839                                         break;
01840                                 } else {
01841                                         point = data + strlen(data) - 1;
01842                                         *(point++) = '\r';
01843                                         *(point++) = '\n';
01844                                         *point = '\0';
01845                                         strcat(keep, data);
01846                                         length += strlen(data);
01847                                 }
01848                         }
01849                 }
01850         }
01851         strcpy(buf, keep);
01852         return buf;
01853 }

int save_template ( dbref  player,
MECH mech,
char *  reference,
char *  filename 
)

Definition at line 1711 of file template.c.

References AeroFuelOrig, AeroSIOrig, ANGEL_ECM_TECH, ARTEMIS_IV_TECH, BEAGLE_PROBE_TECH, BLOODHOUND_PROBE_TECH, BuildBitString(), BuildBitString2(), c, C3_MASTER_TECH, C3_SLAVE_TECH, C3I_TECH, CargoSpace, CarMaxTon, CE_TECH, CL_ANTI_MISSILE_TECH, CLAN_TECH, CLASS_MECH, computer_conversion(), DEFAULT_COMPUTER, DEFAULT_HEATSINKS, DEFAULT_LRSRANGE, DEFAULT_RADIO, DEFAULT_RADIORANGE, DEFAULT_SCANRANGE, DEFAULT_TACRANGE, DefaultFuelByType(), dump_locations(), ECM_TECH, ES_TECH, FF_TECH, generic_radio_type(), HVY_FF_ARMOR_TECH, ICE_TECH, infantry_specials, IS_ANTI_MISSILE_TECH, LE_TECH, LT_FF_ARMOR_TECH, MASC_TECH, mech_types, MechBV, MechComputer, MechComputersLRSRange, MechComputersRadioRange, MechComputersScanRange, MechComputersTacRange, MechInfantrySpecials, MechJumpSpeed, MechLRSRange, MechMaxSpeed, MechMaxSuits, MechMove, MechRadio, MechRadioRange, MechRadioType, MechRealNumsinks, MechScanRange, MechSpecials, MechSpecials2, MechTacRange, MechTons, MechType, MechType_Name, move_types, mudstate, Name(), statedata::now, NULLSIGSYS_TECH, ProperSectionStringFromType(), SILLY_OUTPUT, SILLY_UTTERANCE, specials, specials2, SS_ABILITY, STEALTH_ARMOR_TECH, TAG_TECH, TCOMP_TECH, TRIPLE_MYOMER_TECH, try_to_find_name(), x, XL_TECH, and XXL_TECH.

Referenced by mechrep_Rsavetemp2().

01712 {
01713         FILE *fp;
01714         int x, x2, inf_x;
01715         char **locs;
01716         char *d, *c = ctime(&mudstate.now);
01717 
01718         if(!MechComputer(mech))
01719                 computer_conversion(mech);
01720         if(!MechType_Name(mech)[0])
01721                 try_to_find_name(reference, mech);
01722         if(!(fp = fopen(filename, "w")))
01723                 return -1;
01724         if(MechType_Name(mech)[0])
01725                 fprintf(fp, "Name             { %s }\n", MechType_Name(mech));
01726         fprintf(fp, "Reference        { %s }\n", reference);
01727         fprintf(fp, "Type             { %s }\n",
01728                         mech_types[(short) MechType(mech)]);
01729         fprintf(fp, "Move_Type        { %s }\n",
01730                         move_types[(short) MechMove(mech)]);
01731         fprintf(fp, "Tons             { %d }\n", MechTons(mech));
01732         if((d = strrchr(c, '\n')))
01733                 *d = 0;
01734         fprintf(fp, "Comment          { Saved by: %s(#%d) at %s }\n",
01735                         Name(player), player, c);
01736 #define SILLY_UTTERANCE(ran,cran,dran,name) \
01737   if ((!MechComputer(mech) && ran != dran) || \
01738       (MechComputer(mech) && ran != cran)) \
01739       fprintf(fp, "%-16s { %d }\n", name, ran)
01740 
01741         SILLY_UTTERANCE(MechTacRange(mech), MechComputersTacRange(mech),
01742                                         DEFAULT_TACRANGE, "Tac_Range");
01743         SILLY_UTTERANCE(MechLRSRange(mech), MechComputersLRSRange(mech),
01744                                         DEFAULT_LRSRANGE, "LRS_Range");
01745         SILLY_UTTERANCE(MechScanRange(mech), MechComputersScanRange(mech),
01746                                         DEFAULT_SCANRANGE, "Scan_Range");
01747         SILLY_UTTERANCE(MechRadioRange(mech), MechComputersRadioRange(mech),
01748                                         DEFAULT_RADIORANGE, "Radio_Range");
01749 
01750 #define SILLY_OUTPUT(def,now,name) \
01751   if ((def) != (now)) \
01752      fprintf(fp, "%-16s { %d }\n", name, now)
01753 
01754         SILLY_OUTPUT(DEFAULT_COMPUTER, MechComputer(mech), "Computer");
01755         SILLY_OUTPUT(DEFAULT_RADIO, MechRadio(mech), "Radio");
01756         SILLY_OUTPUT((MechSpecials(mech) & ICE_TECH) ? 0 : DEFAULT_HEATSINKS,
01757                                  MechRealNumsinks(mech), "Heat_Sinks");
01758         SILLY_OUTPUT(generic_radio_type(MechRadio(mech),
01759                                                                         MechSpecials(mech) & CLAN_TECH),
01760                                  MechRadioType(mech), "RadioType");
01761         SILLY_OUTPUT(2000, MechBV(mech), "Mech_BV");
01762         SILLY_OUTPUT(2000, CargoSpace(mech), "Cargo_Space");
01763         SILLY_OUTPUT(0, CarMaxTon(mech), "Max_Ton");
01764         SILLY_OUTPUT(2000, MechMaxSuits(mech), "Max_Suits");
01765         SILLY_OUTPUT(0, AeroSIOrig(mech), "SI");
01766 
01767         SILLY_OUTPUT(DefaultFuelByType(mech), AeroFuelOrig(mech), "Fuel");
01768 
01769         fprintf(fp, "Max_Speed        { %.2f }\n", MechMaxSpeed(mech));
01770         if(MechJumpSpeed(mech) > 0.0)
01771                 fprintf(fp, "Jump_Speed       { %.2f }\n", MechJumpSpeed(mech));
01772         x = MechSpecials(mech);
01773         x2 = MechSpecials2(mech);
01774         /* Remove AMS'es, they're re-generated back on loadtime */
01775         x &= ~(CL_ANTI_MISSILE_TECH | IS_ANTI_MISSILE_TECH | SS_ABILITY);
01776         x &=                                            /* Calculated at load-time */
01777                 ~(BEAGLE_PROBE_TECH | TRIPLE_MYOMER_TECH | MASC_TECH | ECM_TECH |
01778                   C3_SLAVE_TECH | C3_MASTER_TECH | ARTEMIS_IV_TECH | ES_TECH |
01779                   FF_TECH);
01780 
01781         if(MechType(mech) == CLASS_MECH)
01782                 x &= ~(XL_TECH | XXL_TECH | CE_TECH | LE_TECH);
01783 
01784         /* Get rid of our specials2 */
01785         x2 &=
01786                 ~(STEALTH_ARMOR_TECH | NULLSIGSYS_TECH | ANGEL_ECM_TECH |
01787                   HVY_FF_ARMOR_TECH | LT_FF_ARMOR_TECH | TAG_TECH | C3I_TECH |
01788                   BLOODHOUND_PROBE_TECH | TCOMP_TECH);
01789 
01790         if(x || x2)
01791                 fprintf(fp, "Specials         { %s }\n", BuildBitString2(specials,
01792                                                                                                                                  specials2, x,
01793                                                                                                                                  x2));
01794 
01795         inf_x = MechInfantrySpecials(mech);
01796 
01797         if(inf_x)
01798                 fprintf(fp, "InfantrySpecials { %s }\n",
01799                                 BuildBitString(infantry_specials, inf_x));
01800 
01801         if((locs = (char **)ProperSectionStringFromType(MechType(mech), MechMove(mech)))) {
01802                 dump_locations(fp, mech, (const char **)locs);
01803                 fclose(fp);
01804                 return 0;
01805         }
01806         fclose(fp);
01807         return -1;
01808 }

char* techlist_func ( MECH mech  ) 

Definition at line 2691 of file template.c.

References AXE, BuildBitString(), CargoSpace, CASE_TECH, CLASS_MECH, CLASS_VTOL, DUAL_SAW, GetPartType, HAND_OR_FOOT_ACTUATOR, I2Special, LARM, MACE, MBUF_SIZE, MechMove, MechSections, MechSpecials, MechSpecials2, MechType, MOVE_QUAD, NUM_CRITICALS, NUM_SECTIONS, OkayCritSectS, RARM, SALVAGE_TECH, SBUF_SIZE, SHOULDER_OR_HIP, specialsabrev, specialsabrev2, and SWORD.

Referenced by fun_bttechlist(), and fun_bttechlist_ref().

02692 {
02693         static char buffer[MBUF_SIZE];
02694         char bufa[SBUF_SIZE], bufb[SBUF_SIZE];
02695         int i, ii, part = 0, axe = 0, mace = 0, sword = 0, saw = 0, hascase = 0;
02696 
02697         snprintf(bufa, SBUF_SIZE, "%s",
02698                          BuildBitString(specialsabrev, MechSpecials(mech)));
02699         snprintf(bufb, SBUF_SIZE, "%s",
02700                          BuildBitString(specialsabrev2, MechSpecials2(mech)));
02701         snprintf(buffer, MBUF_SIZE, "%s %s", bufa, bufb);
02702 
02703         if(!
02704            (strstr(buffer, "XL") || strstr(buffer, "XXL")
02705                 || strstr(buffer, "LENG") || strstr(buffer, "ICE")
02706                 || strstr(buffer, "CENG")))
02707                 strcat(buffer, " FUS ");
02708         for(i = 0; i < NUM_SECTIONS; i++)
02709                 for(ii = 0; ii < NUM_CRITICALS; ii++) {
02710                         part = GetPartType(mech, i, ii);
02711                         if(part == I2Special(AXE) && !axe) {
02712                                 axe = 1;
02713                                 strcat(buffer, " AXE");
02714                         }
02715                         if(part == I2Special(MACE) && !mace) {
02716                                 mace = 1;
02717                                 strcat(buffer, " MACE");
02718                         }
02719                         if(part == I2Special(DUAL_SAW) && !saw) {
02720                                 saw = 1;
02721                                 strcat(buffer, " DUAL_SAW");
02722                         }
02723                         if(part == I2Special(SWORD) && !sword) {
02724                                 sword = 1;
02725                                 strcat(buffer, " SWORD");
02726                         }
02727                         if((MechSections(mech)[i].config & CASE_TECH) && !hascase) {
02728                                 hascase = 1;
02729                                 strcat(buffer, " CASE");
02730                         }
02731                 }
02732 
02733         if(CargoSpace(mech))
02734                 strcat(buffer, " INFC");
02735 
02736         if(MechType(mech) == CLASS_VTOL)
02737                 strcat(buffer, " VTOL");
02738 
02739         if(MechType(mech) == CLASS_MECH && MechMove(mech) != MOVE_QUAD) {
02740                 if((OkayCritSectS(RARM, 3, HAND_OR_FOOT_ACTUATOR)
02741                         && OkayCritSectS(RARM, 0, SHOULDER_OR_HIP))
02742                    || (OkayCritSectS(LARM, 3, HAND_OR_FOOT_ACTUATOR)
02743                            && OkayCritSectS(LARM, 0, SHOULDER_OR_HIP))
02744                    || MechSpecials(mech) & SALVAGE_TECH)
02745                         strcat(buffer, " MTOW");
02746         } else {
02747                 if(MechSpecials(mech) & SALVAGE_TECH)
02748                         strcat(buffer, " MTOW");
02749         }
02750 
02751         return buffer;
02752 }

void try_to_find_name ( char *  mechref,
MECH mech 
)

Definition at line 1687 of file template.c.

References c, find_mechname_by_mechref(), and MechType_Name.

Referenced by save_template().

01688 {
01689         const char *c;
01690 
01691         if((c = find_mechname_by_mechref(mechref)))
01692                 strcpy(MechType_Name(mech), c);
01693 }

int update_oweight ( MECH mech,
int  value 
)

Definition at line 2227 of file template.c.

References confdata::btech_dynspeed, Destroyed, MechCritStatus, MechRTonsV, MechTons, mudconf, and OWEIGHT_OK.

Referenced by get_weight(), and load_template().

02228 {
02229         MechCritStatus(mech) |= OWEIGHT_OK;
02230 
02231         /* Check to prevent silliness */
02232         if(!mudconf.btech_dynspeed || (value == 1 && !Destroyed(mech)))
02233                 value = MechTons(mech) * 1024;
02234         MechRTonsV(mech) = value;
02235         return value;
02236 }

void update_specials ( MECH mech  ) 

Definition at line 1981 of file template.c.

References ACHILEUS_STEALTH_UNIT, ANGEL_ECM_TECH, ANGELECM, ARTEMIS_IV, ARTEMIS_IV_TECH, BEAGLE_PROBE, BEAGLE_PROBE_TECH, BLOODHOUND_PROBE, BLOODHOUND_PROBE_TECH, BSIDE, C3_DESTROYED, C3_MASTER, C3_MASTER_TECH, C3_SLAVE, C3_SLAVE_TECH, C3I, C3I_TECH, CASE, CASE_TECH, CE_TECH, CL_ANTI_MISSILE_TECH, CLAN_TECH, CLASS_BSUIT, CLASS_MECH, CLASS_VEH_GROUND, CLAT, CountBSuitMembers(), countTotalC3MastersOnMech(), countWorkingC3MastersOnMech(), CritsInLoc(), CS_PURIFIER_STEALTH_TECH, CTORSO, DC_KAGE_STEALTH_TECH, ECM, ECM_TECH, ENDO_STEEL, ENGINE, ES_TECH, FC_INFILTRATOR_STEALTH_TECH, FC_INFILTRATORII_STEALTH_TECH, FERRO_FIBROUS, FF_TECH, FWL_ACHILEUS_STEALTH_TECH, GetPartFireMode, GetPartType, HEAD, HVY_FERRO_FIBROUS, HVY_FF_ARMOR_TECH, INFILTRATOR_STEALTH_UNIT, INFILTRATORII_STEALTH_UNIT, IS_ANTI_MISSILE_TECH, IsAMS, IsWeapon, ITech, ITech2, KAGE_STEALTH_UNIT, LE_TECH, LT_FERRO_FIBROUS, LT_FF_ARMOR_TECH, MASC, MASC_TECH, MAX, MechCritStatus, MechInfantrySpecials, MechSections, MechSpecials, MechSpecials2, MechTons, MechTotalC3Masters, MechType, MechWeapons, MechWorkingC3Masters, NULL_SIGNATURE_SYSTEM, NULLSIGSYS_TECH, NUM_SECTIONS, ON_TC, PURIFIER_ARMOR, SendError, Special2I, STEALTH_ARMOR, STEALTH_ARMOR_TECH, TAG, TAG_TECH, TARGETING_COMPUTER, TCAble, TCOMP_TECH, TECH, TECH2, TECHC, TECHCU, TECHU, tprintf(), TRIPLE_MYOMER_TECH, TRIPLE_STRENGTH_MYOMER, Weapon2I, x, XL_TECH, XXL_TECH, and y.

Referenced by do_magic(), and load_template().

01982 {
01983         int x, y, t;
01984         int masc_count = 0;
01985         int c3_master_count = 0;
01986         int tsm_count = 0;
01987         int ff_count = 0;
01988         int es_count = 0;
01989         int tc_count = 0;
01990         int awcSthArmor[NUM_SECTIONS];
01991         int awcNSS[NUM_SECTIONS];
01992         int wcSthArmor = 0;
01993         int wcNSS = 0;
01994         int wcAngel = 0;
01995         int cl = MechSpecials(mech) & CLAN_TECH;
01996         int e_count = 0;
01997         int tTechOK = 1;
01998         int wcHvyFF = 0;
01999         int wcLtFF = 0;
02000         int wcC3i = 0;
02001         int wcBloodhound = 0;
02002         int awInfSpec[5];
02003         int wcSuits = 0;
02004 
02005         MechSpecials(mech) &=
02006                 ~(BEAGLE_PROBE_TECH | TRIPLE_MYOMER_TECH | MASC_TECH | ECM_TECH |
02007                   C3_SLAVE_TECH | C3_MASTER_TECH | ARTEMIS_IV_TECH | ES_TECH |
02008                   FF_TECH | IS_ANTI_MISSILE_TECH | CL_ANTI_MISSILE_TECH);
02009         if(MechType(mech) == CLASS_MECH)
02010                 MechSpecials(mech) &= ~(XL_TECH | XXL_TECH | CE_TECH | LE_TECH);
02011 
02012         MechSpecials2(mech) &=
02013                 ~(STEALTH_ARMOR_TECH | NULLSIGSYS_TECH | ANGEL_ECM_TECH |
02014                   HVY_FF_ARMOR_TECH | LT_FF_ARMOR_TECH | TAG_TECH | C3I_TECH |
02015                   BLOODHOUND_PROBE_TECH | TCOMP_TECH);
02016 
02017         MechInfantrySpecials(mech) &=
02018                 ~(CS_PURIFIER_STEALTH_TECH | DC_KAGE_STEALTH_TECH |
02019                   FWL_ACHILEUS_STEALTH_TECH | FC_INFILTRATOR_STEALTH_TECH |
02020                   FC_INFILTRATORII_STEALTH_TECH);
02021 
02022         for(x = 0; x < 5; x++)
02023                 awInfSpec[x] = 0;
02024 
02025         for(x = 0; x < NUM_SECTIONS; x++) {
02026                 e_count = 0;
02027                 MechSections(mech)[x].config &= ~CASE_TECH;
02028                 awcSthArmor[x] = 0;
02029                 awcNSS[x] = 0;
02030 
02031                 for(y = 0; y < CritsInLoc(mech, x); y++)
02032                         if((t = GetPartType(mech, x, y))) {
02033                                 switch (Special2I(t)) {
02034 #define TECHC(item,name) case item: name++; break;
02035 #define TECHCU(item,name) \
02036                                 case item: if (!PartIsNonfunctional(mech, x, y)) name++; break;
02037 #define TECH(item,name) case item: MechSpecials(mech) |= name; break
02038 #define TECH2(item,name) case item: MechSpecials2(mech) |= name; break
02039 #define TECHU(item, name) \
02040                                 case item: if (!PartIsNonfunctional(mech, x, y)) MechSpecials(mech) |= name ; break
02041                                         TECH(ARTEMIS_IV, ARTEMIS_IV_TECH);
02042                                         TECHU(BEAGLE_PROBE, BEAGLE_PROBE_TECH);
02043                                         TECH(ECM, ECM_TECH);
02044                                         TECH2(TAG, TAG_TECH);
02045                                         TECHU(C3_SLAVE, C3_SLAVE_TECH);
02046                                         TECHCU(MASC, masc_count);
02047                                         TECHC(C3_MASTER, c3_master_count);
02048                                         TECHCU(C3I, wcC3i);
02049                                         TECHCU(ANGELECM, wcAngel);
02050                                         TECHC(TRIPLE_STRENGTH_MYOMER, tsm_count);
02051                                         TECHC(FERRO_FIBROUS, ff_count);
02052                                         TECHC(HVY_FERRO_FIBROUS, wcHvyFF);
02053                                         TECHC(LT_FERRO_FIBROUS, wcLtFF);
02054                                         TECHC(BLOODHOUND_PROBE, wcBloodhound);
02055                                         TECHCU(TARGETING_COMPUTER, tc_count);
02056                                         TECHC(ENDO_STEEL, es_count);
02057                                         TECHC(PURIFIER_ARMOR, awInfSpec[0]);
02058                                         TECHCU(KAGE_STEALTH_UNIT, awInfSpec[1]);
02059                                         TECHCU(ACHILEUS_STEALTH_UNIT, awInfSpec[2]);
02060                                         TECHCU(INFILTRATOR_STEALTH_UNIT, awInfSpec[3]);
02061                                         TECHCU(INFILTRATORII_STEALTH_UNIT, awInfSpec[4]);
02062                                 case ENGINE:
02063                                         e_count++;
02064                                         break;
02065                                 case CASE:
02066                                         MechSections(mech)[(MechType(mech) == CLASS_VEH_GROUND)
02067                                                                            ? BSIDE : x].config |= CASE_TECH;
02068                                         break;
02069                                 case STEALTH_ARMOR:
02070                                         awcSthArmor[x]++;
02071                                         wcSthArmor++;
02072                                         break;
02073                                 case NULL_SIGNATURE_SYSTEM:
02074                                         awcNSS[x]++;
02075                                         wcNSS++;
02076                                         break;
02077                                 }
02078                                 if(IsWeapon(t) && IsAMS(Weapon2I(t))) {
02079                                         if(MechWeapons[Weapon2I(t)].special & CLAT)
02080                                                 MechSpecials(mech) |= CL_ANTI_MISSILE_TECH;
02081                                         else
02082                                                 MechSpecials(mech) |= IS_ANTI_MISSILE_TECH;
02083                                 }
02084                         }
02085                 if(x != CTORSO && e_count) {
02086                         if(e_count > 3)
02087                                 MechSpecials(mech) |= XXL_TECH;
02088 
02089                         else if(e_count == 2)
02090                                 if(cl)
02091                                         MechSpecials(mech) |= XL_TECH;
02092 
02093                                 else
02094                                         MechSpecials(mech) |= LE_TECH;
02095 
02096                         else
02097                                 MechSpecials(mech) |= XL_TECH;
02098                 } else {
02099                         if(x == CTORSO && e_count < 4 && MechType(mech) == CLASS_MECH)
02100                                 MechSpecials(mech) |= CE_TECH;
02101                 }
02102 
02103         }
02104         if((MechSpecials(mech) & (XXL_TECH | XL_TECH | LE_TECH)) &&
02105            (MechSpecials(mech) & CE_TECH))
02106                 SendError(tprintf
02107                                   ("#%d apparently is very weird: Compact engine AND XL/XXL?",
02108                                    mech->mynum));
02109         if(tc_count) {
02110                 MechSpecials2(mech) |= TCOMP_TECH;
02111                 for(x = 0; x < NUM_SECTIONS; x++)
02112                         for(y = 0; y < CritsInLoc(mech, x); y++)
02113                                 if(IsWeapon((t = GetPartType(mech, x, y))))
02114                                         if(TCAble(t))
02115                                                 GetPartFireMode(mech, x, y) |= ON_TC;
02116         }
02117         if(masc_count >= MAX(1, (MechTons(mech) / (cl ? 25 : 20))))
02118                 MechSpecials(mech) |= MASC_TECH;
02119 #define ITech(var,cnt,spec) \
02120   if (((var)) >= ((cnt)) || (MechType(mech) != CLASS_MECH && ((var)>0))) \
02121                                         MechSpecials(mech) |= spec
02122 
02123 #define ITech2(var,cnt,spec) \
02124   if (((var)) >= ((cnt)) || (MechType(mech) != CLASS_MECH && ((var)>0))) \
02125                                         MechSpecials2(mech) |= spec
02126 
02127         ITech(ff_count, (cl ? 7 : 14), FF_TECH);
02128         ITech(es_count, (cl ? 7 : 14), ES_TECH);
02129         ITech(tsm_count, 6, TRIPLE_MYOMER_TECH);
02130         ITech2(wcAngel, 2, ANGEL_ECM_TECH);
02131         ITech2(wcHvyFF, 21, HVY_FF_ARMOR_TECH);
02132         ITech2(wcLtFF, 7, LT_FF_ARMOR_TECH);
02133         ITech2(wcC3i, 2, C3I_TECH);
02134         ITech2(wcBloodhound, 2, BLOODHOUND_PROBE_TECH);
02135 
02136         /*
02137          * Check our NSS. Need 1 crit in each loc except H
02138          */
02139         tTechOK = 0;
02140 
02141         if(wcNSS > 0) {
02142                 tTechOK = 1;
02143 
02144                 if(MechType(mech) != CLASS_MECH) {
02145                         if(wcNSS < 1)
02146                                 tTechOK = 0;
02147                 } else {
02148                         for(x = 0; x < NUM_SECTIONS; x++) {
02149                                 if(x != HEAD) {
02150                                         if(awcNSS[x] < 1) {
02151                                                 tTechOK = 0;
02152                                                 break;
02153                                         }
02154                                 }
02155                         }
02156                 }
02157 
02158                 if(tTechOK)
02159                         MechSpecials2(mech) |= NULLSIGSYS_TECH;
02160         }
02161 
02162         /*
02163          * Check our Stealth armor. Need 2 crits in each loc except H and CT
02164          */
02165         tTechOK = 0;
02166 
02167         if(wcSthArmor > 0) {
02168                 tTechOK = 1;
02169 
02170                 if(!(MechSpecials(mech) & ECM_TECH)) {
02171                         tTechOK = 0;
02172                 } else {
02173                         if(MechType(mech) != CLASS_MECH) {
02174                                 if(wcSthArmor < 1)
02175                                         tTechOK = 0;
02176                         } else {
02177                                 for(x = 0; x < NUM_SECTIONS; x++) {
02178                                         if((x != HEAD) && (x != CTORSO)) {
02179                                                 if(awcSthArmor[x] < 2) {
02180                                                         tTechOK = 0;
02181                                                         break;
02182                                                 }
02183                                         }
02184                                 }
02185                         }
02186                 }
02187 
02188                 if(tTechOK)
02189                         MechSpecials2(mech) |= STEALTH_ARMOR_TECH;
02190         }
02191 
02192         /* Let's do our suit checks */
02193         if(MechType(mech) == CLASS_BSUIT) {
02194                 wcSuits = CountBSuitMembers(mech);
02195 
02196                 if(awInfSpec[0] >= wcSuits)
02197                         MechInfantrySpecials(mech) |= CS_PURIFIER_STEALTH_TECH;
02198 
02199                 if(awInfSpec[1] >= wcSuits)
02200                         MechInfantrySpecials(mech) |= DC_KAGE_STEALTH_TECH;
02201 
02202                 if(awInfSpec[2] >= wcSuits)
02203                         MechInfantrySpecials(mech) |= FWL_ACHILEUS_STEALTH_TECH;
02204 
02205                 if(awInfSpec[3] >= wcSuits)
02206                         MechInfantrySpecials(mech) |= FC_INFILTRATOR_STEALTH_TECH;
02207 
02208                 if(awInfSpec[4] >= wcSuits)
02209                         MechInfantrySpecials(mech) |= FC_INFILTRATORII_STEALTH_TECH;
02210         }
02211 
02212         /* New C3 Master code */
02213         if(c3_master_count > 0) {
02214                 MechTotalC3Masters(mech) = countTotalC3MastersOnMech(mech);
02215                 MechWorkingC3Masters(mech) = countWorkingC3MastersOnMech(mech);
02216 
02217                 if(MechTotalC3Masters(mech) > 0)
02218                         MechSpecials(mech) |= C3_MASTER_TECH;
02219 
02220                 if(MechWorkingC3Masters(mech) == 0)
02221                         MechCritStatus(mech) |= C3_DESTROYED;
02222                 else
02223                         MechCritStatus(mech) &= ~C3_DESTROYED;
02224         }
02225 }

int WeaponIFromString ( char *  data  ) 

Definition at line 1952 of file template.c.

References MechWeapons, name, and x.

01953 {
01954         int x = 0;;
01955 
01956         while (MechWeapons[x].name) {
01957                 if(!strcasecmp(MechWeapons[x].name, data))
01958                         return x + 1;           /* weapons start at 1 not 0 */
01959                 x++;
01960         }
01961         return -1;
01962 }


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