#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/file.h>
#include "mech.h"
#include "weapons.h"
#include "p.mech.partnames.h"
#include "p.mech.utils.h"
Include dependency graph for mech.build.c:
Go to the source code of this file.
Functions | |
int | CheckData (dbref player, void *data) |
void | FillDefaultCriticals (MECH *mech, int index) |
char * | ShortArmorSectionString (char type, char mtype, int loc) |
int | ArmorSectionFromString (char type, char mtype, char *string) |
int | WeaponIndexFromString (char *string) |
int | FindSpecialItemCodeFromString (char *buffer) |
Variables | |
const int | num_def_weapons = NUM_DEF_WEAPONS |
int ArmorSectionFromString | ( | char | type, | |
char | mtype, | |||
char * | string | |||
) |
Definition at line 120 of file mech.build.c.
References c, and ProperSectionStringFromType().
Referenced by armorstatus_func(), critslot_func(), critstatus_func(), mech_critstatus(), mech_dump(), mech_target(), mech_usebin(), mechrep_Raddspecial(), mechrep_Raddweap(), mechrep_Rdisplaysection(), mechrep_Rreload(), mechrep_Rrepair(), mechrep_Rsetarmor(), remove_inarc_pods_mech(), setarmorstatus_func(), tech_parsegun(), tech_parsepart_advanced(), and weaponstatus_func().
00121 { 00122 char **locs; 00123 int i, j; 00124 char *c, *d; 00125 00126 if(!string[0]) 00127 return -1; 00128 locs = ProperSectionStringFromType(type, mtype); 00129 if(!locs) 00130 return -1; 00131 /* Then, methodically compare against each other until a suitable 00132 match is found */ 00133 for(i = 0; locs[i]; i++) 00134 if(!strcasecmp(string, locs[i])) 00135 return i; 00136 for(i = 0; locs[i]; i++) { 00137 if(toupper(string[0]) != locs[i][0]) 00138 continue; 00139 for(j = (i + 1); locs[j]; j++) 00140 if(toupper(string[0]) == locs[j][0]) 00141 break; 00142 if(!locs[j]) 00143 return i; 00144 /* Ok, comparison between these two, then */ 00145 c = strstr(locs[i], " "); 00146 d = strstr(locs[j], " "); 00147 if(!c && !string[1] && d) 00148 return i; 00149 if(!c && !d) 00150 return -1; 00151 if(!string[1]) 00152 continue; 00153 if(c && toupper(string[1]) == *(++c)) 00154 return i; 00155 if(d && toupper(string[1]) == *(++d)) 00156 return j; 00157 } 00158 return -1; 00159 }
int CheckData | ( | dbref | player, | |
void * | data | |||
) |
Definition at line 26 of file mech.build.c.
References notify.
Referenced by common_checks(), map_addhex(), map_clearmechs(), map_listmechs(), map_loadmap(), map_mapemit(), map_savemap(), map_setmapsize(), mech_critstatus(), mech_Rsetmapindex(), mech_Rsetteam(), mech_Rsetxy(), mech_shutdown(), mech_weaponspecs(), and PrintEnemyStatus().
00027 { 00028 int returnValue = 1; 00029 00030 if(data == NULL) { 00031 notify(player, "There is a problem with that item."); 00032 notify(player, "The data is not properly allocated."); 00033 notify(player, "Please notify a director of this."); 00034 returnValue = 0; 00035 } 00036 return (returnValue); 00037 }
void FillDefaultCriticals | ( | MECH * | mech, | |
int | index | |||
) |
Definition at line 39 of file mech.build.c.
References AERO_AFT, CLASS_AERO, CLASS_MECH, COCKPIT, CTORSO, EMPTY, ENGINE, GYRO, HAND_OR_FOOT_ACTUATOR, HEAD, HEAT_SINK, I2Special, LARM, LIFE_SUPPORT, LLEG, LOWER_ACTUATOR, LTORSO, MechSections, MechType, NUM_CRITICALS, RARM, RLEG, RTORSO, SENSORS, SHOULDER_OR_HIP, and UPPER_ACTUATOR.
Referenced by mechrep_Rresetcrits(), and newfreemech().
00040 { 00041 int loop; 00042 00043 for(loop = 0; loop < NUM_CRITICALS; loop++) { 00044 MechSections(mech)[index].criticals[loop].type = EMPTY; 00045 MechSections(mech)[index].criticals[loop].data = 0; 00046 MechSections(mech)[index].criticals[loop].firemode = 0; 00047 MechSections(mech)[index].criticals[loop].ammomode = 0; 00048 } 00049 00050 if(MechType(mech) == CLASS_AERO) 00051 switch (index) { 00052 case AERO_AFT: 00053 for(loop = 0; loop < 12; loop++) 00054 MechSections(mech)[index].criticals[loop].type = 00055 I2Special(HEAT_SINK); 00056 MechSections(mech)[index].criticals[2].type = I2Special(ENGINE); 00057 MechSections(mech)[index].criticals[10].type = I2Special(ENGINE); 00058 break; 00059 } 00060 if(MechType(mech) == CLASS_MECH) 00061 switch (index) { 00062 case HEAD: 00063 MechSections(mech)[index].criticals[0].type = 00064 I2Special(LIFE_SUPPORT); 00065 MechSections(mech)[index].criticals[1].type = I2Special(SENSORS); 00066 MechSections(mech)[index].criticals[2].type = I2Special(COCKPIT); 00067 MechSections(mech)[index].criticals[4].type = I2Special(SENSORS); 00068 MechSections(mech)[index].criticals[5].type = 00069 I2Special(LIFE_SUPPORT); 00070 break; 00071 00072 case CTORSO: 00073 MechSections(mech)[index].criticals[0].type = I2Special(ENGINE); 00074 MechSections(mech)[index].criticals[1].type = I2Special(ENGINE); 00075 MechSections(mech)[index].criticals[2].type = I2Special(ENGINE); 00076 MechSections(mech)[index].criticals[3].type = I2Special(GYRO); 00077 MechSections(mech)[index].criticals[4].type = I2Special(GYRO); 00078 MechSections(mech)[index].criticals[5].type = I2Special(GYRO); 00079 MechSections(mech)[index].criticals[6].type = I2Special(GYRO); 00080 MechSections(mech)[index].criticals[7].type = I2Special(ENGINE); 00081 MechSections(mech)[index].criticals[8].type = I2Special(ENGINE); 00082 MechSections(mech)[index].criticals[9].type = I2Special(ENGINE); 00083 break; 00084 00085 case RTORSO: 00086 case LTORSO: 00087 break; 00088 00089 case LARM: 00090 case RARM: 00091 case LLEG: 00092 case RLEG: 00093 MechSections(mech)[index].criticals[0].type = 00094 I2Special(SHOULDER_OR_HIP); 00095 MechSections(mech)[index].criticals[1].type = 00096 I2Special(UPPER_ACTUATOR); 00097 MechSections(mech)[index].criticals[2].type = 00098 I2Special(LOWER_ACTUATOR); 00099 MechSections(mech)[index].criticals[3].type = 00100 I2Special(HAND_OR_FOOT_ACTUATOR); 00101 break; 00102 } 00103 }
int FindSpecialItemCodeFromString | ( | char * | buffer | ) |
Definition at line 171 of file mech.build.c.
References find_matching_vlong_part(), IsSpecial, and Special2I.
Referenced by mechrep_Raddspecial().
00172 { 00173 int id, brand; 00174 00175 if(find_matching_vlong_part(buffer, NULL, &id, &brand)) 00176 if(IsSpecial(id)) 00177 return Special2I(id); 00178 return -1; 00179 }
char* ShortArmorSectionString | ( | char | type, | |
char | mtype, | |||
int | loc | |||
) |
Definition at line 105 of file mech.build.c.
References c, and ProperSectionStringFromType().
Referenced by cause_armordamage(), damages_func(), describe_repairs(), fix_entry(), listtic_fun(), and show_mechs_damage().
00106 { 00107 char **locs; 00108 static char buf[4]; 00109 char *c = buf; 00110 int i; 00111 00112 locs = ProperSectionStringFromType(type, mtype); 00113 for(i = 0; locs[loc][i]; i++) 00114 if(isupper(locs[loc][i]) || isdigit(locs[loc][i])) 00115 *(c++) = locs[loc][i]; 00116 *c = 0; 00117 return buf; 00118 }
int WeaponIndexFromString | ( | char * | string | ) |
Definition at line 161 of file mech.build.c.
References find_matching_vlong_part(), IsWeapon, and Weapon2I.
Referenced by mechrep_Raddweap(), and mechrep_Rreload().
00162 { 00163 int id, brand; 00164 00165 if(find_matching_vlong_part(string, NULL, &id, &brand)) 00166 if(IsWeapon(id)) 00167 return Weapon2I(id); 00168 return -1; 00169 }
const int num_def_weapons = NUM_DEF_WEAPONS |
Definition at line 24 of file mech.build.c.