#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/file.h>
#include "mech.h"
#include "mech.events.h"
#include "create.h"
#include "autopilot.h"
#include "p.mech.build.h"
#include "p.mech.utils.h"
#include "p.mechrep.h"
#include "p.mech.c3.h"
#include "p.mech.c3i.h"
Include dependency graph for mech.restrict.c:
Go to the source code of this file.
Defines | |
#define | SPECIAL_FREE 0 |
#define | SPECIAL_ALLOC 1 |
#define | SPECIAL_FREE 0 |
#define | SPECIAL_ALLOC 1 |
Functions | |
void | clear_mech_from_LOS (MECH *mech) |
void | mech_Rsetxy (dbref player, void *data, char *buffer) |
void | mech_Rsetmapindex (dbref player, void *data, char *buffer) |
void | mech_Rsetteam (dbref player, void *data, char *buffer) |
void | auto_stop_pilot (AUTO *autopilot) |
void | newfreemech (dbref key, void **data, int selector) |
#define SPECIAL_ALLOC 1 |
Definition at line 236 of file mech.restrict.c.
#define SPECIAL_ALLOC 1 |
Definition at line 236 of file mech.restrict.c.
#define SPECIAL_FREE 0 |
Definition at line 235 of file mech.restrict.c.
#define SPECIAL_FREE 0 |
Definition at line 235 of file mech.restrict.c.
void auto_stop_pilot | ( | AUTO * | autopilot | ) |
Definition at line 629 of file autopilot_core.c.
References AUTOPILOT_AUTOGUN, AUTOPILOT_GUNZOMBIE, AUTOPILOT_PILZOMBIE, FIRST_AUTO_EVENT, AUTO::flags, LAST_AUTO_EVENT, and muxevent_remove_type_data().
Referenced by auto_disengage(), auto_newautopilot(), and newfreemech().
00630 { 00631 00632 int i; 00633 00634 autopilot->flags &= ~(AUTOPILOT_AUTOGUN | AUTOPILOT_GUNZOMBIE 00635 | AUTOPILOT_PILZOMBIE); 00636 00637 for(i = FIRST_AUTO_EVENT; i <= LAST_AUTO_EVENT; i++) 00638 muxevent_remove_type_data(i, (void *) autopilot); 00639 00640 }
void clear_mech_from_LOS | ( | MECH * | mech | ) |
Definition at line 29 of file mech.restrict.c.
References FindObjectsData(), MAP::first_free, getMech(), LOCK_TARGET, LoseLock, MAP::LOSinfo, MECH::mapindex, MECH::mapnumber, MAX, mech_notify(), MECHALL, MECHLOSFLAG_SEEN, MechNumSeen, MAP::mechsOnMap, MechStatus, MechTarget, MechTeam, MECH::mynum, SendSensor, and tprintf().
Referenced by fun_btloadmech(), mech_Rsetxy(), mechrep_Rloadnew(), and remove_mech_from_map().
00030 { 00031 MAP *map; 00032 int i; 00033 MECH *mek; 00034 00035 /* if (mech->mapindex < 0) 00036 return; 00037 */ 00038 if(!(map = FindObjectsData(mech->mapindex))) 00039 return; 00040 #ifdef SENSOR_DEBUG 00041 SendSensor(tprintf("LOS info for #%d cleared.", mech->mynum)); 00042 #endif 00043 for(i = 0; i < map->first_free; i++) { 00044 map->LOSinfo[mech->mapnumber][i] = 0; 00045 map->LOSinfo[i][mech->mapnumber] = 0; 00046 00047 if(map->mechsOnMap[i] >= 0 && i != mech->mapnumber) { 00048 if(!(mek = getMech(map->mechsOnMap[i]))) 00049 continue; 00050 if((MechStatus(mek) & LOCK_TARGET) && 00051 MechTarget(mek) == mech->mynum) { 00052 mech_notify(mek, MECHALL, 00053 "Weapon system reports the lock has been lost."); 00054 LoseLock(mek); 00055 } 00056 if((map->LOSinfo[i][mech->mapnumber] & MECHLOSFLAG_SEEN) && 00057 MechTeam(mek) != MechTeam(mech)) 00058 MechNumSeen(mek) = MAX(0, MechNumSeen(mek) - 1); 00059 } 00060 } 00061 if(MechStatus(mech) & LOCK_MODES) { 00062 mech_notify(mech, MECHALL, 00063 "Weapon system reports the lock has been lost."); 00064 LoseLock(mech); 00065 } 00066 }
void mech_Rsetmapindex | ( | dbref | player, | |
void * | data, | |||
char * | buffer | |||
) |
Definition at line 113 of file mech.restrict.c.
References A_MECHPREFID, add_mech_to_map(), args, BOUNDED(), CheckData(), clearC3iNetwork(), clearC3Network(), DOCHECK, FindObjectsData(), MAP::first_free, GetElev, GetTerrain, MAP::map_height, MAP::map_width, MapCoordToRealCoord(), MECH::mapindex, MAX_MECHS_PER_MAP, mech_parseattributes(), MechElev, MechFX, MechFY, MechID, MechLastX, MechLastY, MAP::mechsOnMap, MechTerrain, MechX, MechY, MECH::mynum, MAP::mynum, notify, notify_printf(), Number, remove_mech_from_map(), SendLoc, silly_atr_get(), TAGTarget, tprintf(), UnZombifyMech, and ValidMap().
Referenced by autoeject(), char_disembark(), char_eject(), fun_btsetxy(), Leave_DS_Bay(), Leave_Hangar(), load_update4(), mech_embark(), mech_enter_event(), mech_enterbay_event(), and mech_udisembark().
00114 { 00115 MECH *mech = (MECH *) data; 00116 char *args[2], *tempstr; 00117 int newindex, nargs, notdone = 0; 00118 int loop; 00119 MAP *newmap = NULL; 00120 MAP *oldmap; 00121 MECH *tempMech; 00122 char targ[2]; 00123 00124 if(!CheckData(player, mech)) 00125 return; 00126 nargs = mech_parseattributes(buffer, args, 2); 00127 DOCHECK(nargs < 1, "Invalid number of arguments to SETMAPINDX!"); 00128 newindex = atoi(args[0]); 00129 DOCHECK(newindex < -1, "Invalid map index!"); 00130 if(newindex != -1) { 00131 if(!(newmap = ValidMap(player, newindex))) 00132 return; 00133 } 00134 /* Remove the mech from it's old map */ 00135 if(mech->mapindex != -1) { 00136 if(!(oldmap = ValidMap(player, mech->mapindex))) 00137 return; 00138 TAGTarget(mech) = -1; 00139 clearC3iNetwork(mech, 1); 00140 clearC3Network(mech, 1); 00141 remove_mech_from_map(oldmap, mech); 00142 } 00143 00144 if(newindex == -1) { 00145 notify(player, "Mech removed from map."); 00146 SendLoc(tprintf("#%d removed #%d from map #%d.", player, 00147 mech->mynum, oldmap->mynum)); 00148 return; 00149 } 00150 00151 /* Just make it random */ 00152 /* Find a clear spot for this mech */ 00153 if(nargs > 1 && strlen(args[1]) > 1) { 00154 targ[0] = args[1][0]; 00155 targ[1] = args[1][1]; 00156 } else if((tempstr = silly_atr_get(mech->mynum, A_MECHPREFID)) 00157 && strlen(tempstr) > 1) { 00158 targ[0] = tempstr[0]; 00159 targ[1] = tempstr[1]; 00160 } else { 00161 targ[0] = 65 + Number(0, 25); 00162 targ[1] = 65 + Number(0, 25); 00163 } 00164 targ[0] = BOUNDED('A', toupper(targ[0]), 'Z'); 00165 targ[1] = BOUNDED('A', toupper(targ[1]), 'Z'); 00166 for(loop = 0; (loop < newmap->first_free && !notdone); loop++) { 00167 if((tempMech = (MECH *) 00168 FindObjectsData(newmap->mechsOnMap[loop]))) 00169 if(MechID(tempMech)[0] == targ[0] && 00170 MechID(tempMech)[1] == targ[1]) 00171 notdone = 1; 00172 } 00173 while (notdone) { 00174 targ[0] = 65 + Number(0, 25); 00175 targ[1] = 65 + Number(0, 25); 00176 notdone = 0; 00177 for(loop = 0; (loop < newmap->first_free && !notdone); loop++) { 00178 if((tempMech = (MECH *) 00179 FindObjectsData(newmap->mechsOnMap[loop]))) 00180 if(MechID(tempMech)[0] == targ[0] && 00181 MechID(tempMech)[1] == targ[1]) 00182 notdone = 1; 00183 } 00184 } 00185 DOCHECK(loop == MAX_MECHS_PER_MAP, 00186 "There are too many mechs on that map!"); 00187 add_mech_to_map(newmap, mech); 00188 MechID(mech)[0] = targ[0]; 00189 MechID(mech)[1] = targ[1]; 00190 if(MechX(mech) > (newmap->map_width - 1) || 00191 MechY(mech) > (newmap->map_height - 1)) { 00192 MechX(mech) = 0; 00193 MechLastX(mech) = 0; 00194 MechY(mech) = 0; 00195 MechLastY(mech) = 0; 00196 MapCoordToRealCoord(MechX(mech), MechY(mech), &MechFX(mech), 00197 &MechFY(mech)); 00198 MechTerrain(mech) = GetTerrain(newmap, MechX(mech), MechY(mech)); 00199 MechElev(mech) = GetElev(newmap, MechX(mech), MechY(mech)); 00200 notify(player, 00201 "You're current position is out of bounds, Pos changed to 0,0"); 00202 } 00203 notify_printf(player, "MapIndex changed to %d", newindex); 00204 notify_printf(player, "Your ID: %c%c", MechID(mech)[0], MechID(mech)[1]); 00205 SendLoc(tprintf("#%d set #%d's mapindex to #%d.", player, mech->mynum, 00206 newindex)); 00207 UnZombifyMech(mech); 00208 }
void mech_Rsetteam | ( | dbref | player, | |
void * | data, | |||
char * | buffer | |||
) |
Definition at line 210 of file mech.restrict.c.
References args, CheckData(), DOCHECK, MECH::mapindex, mech_parseattributes(), MechTeam, notify, notify_printf(), team, and ValidMap().
Referenced by autoeject(), char_disembark(), and char_eject().
00211 { 00212 MECH *mech = (MECH *) data; 00213 char *args[1]; 00214 int team; 00215 MAP *newmap; 00216 00217 if(!CheckData(player, mech)) 00218 return; 00219 DOCHECK(mech->mapindex == -1, "Mech is not on a map: Can't set team"); 00220 newmap = ValidMap(player, mech->mapindex); 00221 if(!newmap) { 00222 notify(player, "Map index reset!"); 00223 mech->mapindex = -1; 00224 return; 00225 } 00226 DOCHECK(mech_parseattributes(buffer, args, 1) != 1, 00227 "Invalid number of arguments!"); 00228 team = atoi(args[0]); 00229 if(team < 0) 00230 team = 0; 00231 MechTeam(mech) = team; 00232 notify_printf(player, "Team set to %d", team); 00233 }
void mech_Rsetxy | ( | dbref | player, | |
void * | data, | |||
char * | buffer | |||
) |
Definition at line 68 of file mech.restrict.c.
References args, cch, CheckData(), clear_mech_from_LOS(), DOCHECK, DropSetElevation(), FlyingT, GetElev, getMap(), GetTerrain, Landed, LANDED, MAP::map_height, MAP::map_width, MapCoordToRealCoord(), MECH::mapindex, MarkForLOSUpdate(), MECH_MAP, mech_parseattributes(), MechElev, MechFX, MechFY, MechFZ, MechLastX, MechLastY, MechStatus, MechTerrain, MechX, MechY, MechZ, MECH::mynum, notify_printf(), SendLoc, tprintf(), x, y, and ZSCALE.
Referenced by autoeject(), char_disembark(), char_eject(), fun_btsetxy(), initiate_ood(), Leave_Hangar(), load_update1(), mech_embark(), mech_enter_event(), mech_enterbay_event(), and mech_udisembark().
00069 { 00070 MECH *mech = (MECH *) data; 00071 MAP *mech_map = getMap(mech->mapindex); 00072 char *args[3]; 00073 int x, y, z, argc; 00074 00075 if(!CheckData(player, mech)) 00076 return; 00077 cch(MECH_MAP); 00078 argc = mech_parseattributes(buffer, args, 3); 00079 DOCHECK(argc != 2 && argc != 3, "Invalid number of arguments to SETXY!"); 00080 x = atoi(args[0]); 00081 y = atoi(args[1]); 00082 DOCHECK(x >= mech_map->map_width || y >= mech_map->map_height || x < 0 00083 || y < 0, "Invalid coordinates!"); 00084 MechX(mech) = x; 00085 MechLastX(mech) = x; 00086 MechY(mech) = y; 00087 MechLastY(mech) = y; 00088 MapCoordToRealCoord(MechX(mech), MechY(mech), &MechFX(mech), 00089 &MechFY(mech)); 00090 MechTerrain(mech) = GetTerrain(mech_map, MechX(mech), MechY(mech)); 00091 MarkForLOSUpdate(mech); 00092 if(argc == 2) { 00093 MechElev(mech) = GetElev(mech_map, MechX(mech), MechY(mech)); 00094 MechZ(mech) = MechElev(mech) - 1; 00095 MechFZ(mech) = ZSCALE * MechZ(mech); 00096 DropSetElevation(mech, 0); 00097 z = MechZ(mech); 00098 if(!Landed(mech) && FlyingT(mech)) 00099 MechStatus(mech) |= LANDED; 00100 } else { 00101 z = atoi(args[2]); 00102 MechZ(mech) = z; 00103 MechFZ(mech) = ZSCALE * MechZ(mech); 00104 MechElev(mech) = GetElev(mech_map, MechX(mech), MechY(mech)); 00105 } 00106 clear_mech_from_LOS(mech); 00107 notify_printf(player, "Pos changed to %d,%d,%d", x, y, z); 00108 SendLoc(tprintf("#%d set #%d's pos to %d,%d,%d.", player, mech->mynum, 00109 x, y, z)); 00110 }
void newfreemech | ( | dbref | key, | |
void ** | data, | |||
int | selector | |||
) |
Definition at line 240 of file mech.restrict.c.
References auto_destroy_astar_path(), auto_destroy_command_node(), auto_destroy_weaplist(), AUTO_PROFILE_MAX_SIZE, auto_stop_pilot(), clear_mech(), dllist_destroy_list(), dllist_head(), dllist_remove(), dllist_size(), FillDefaultCriticals(), FindObjectsData(), getMap(), MechAuto, MechID, AUTO::mymechnum, NUM_SECTIONS, rb_destroy(), remove_mech_from_map(), SPECIAL_ALLOC, and SPECIAL_FREE.
00241 { 00242 MECH *new = *data; 00243 MAP *map; 00244 AUTO *a; 00245 int i; 00246 command_node *temp; 00247 00248 switch (selector) { 00249 case SPECIAL_ALLOC: 00250 new->mynum = key; 00251 new->mapnumber = 1; 00252 new->mapindex = -1; 00253 MechID(new)[0] = ' '; 00254 MechID(new)[1] = ' '; 00255 clear_mech(new, 1); 00256 for(i = 0; i < NUM_SECTIONS; i++) 00257 FillDefaultCriticals(new, i); 00258 break; 00259 case SPECIAL_FREE: 00260 if(new->mapindex != -1 && (map = getMap(new->mapindex))) 00261 remove_mech_from_map(map, new); 00262 if(MechAuto(new) > 0 ) { 00263 AUTO *a = (AUTO *) FindObjectsData(MechAuto(new)); 00264 if (a) { 00265 auto_stop_pilot(a); 00266 /* Go through the list and remove any leftover nodes */ 00267 while (dllist_size(a->commands)) { 00268 00269 /* Remove the first node on the list and get the data 00270 * from it */ 00271 temp = (command_node *) dllist_remove(a->commands, 00272 dllist_head(a-> 00273 commands)); 00274 00275 /* Destroy the command node */ 00276 auto_destroy_command_node(temp); 00277 00278 } 00279 00280 /* Destroy the list */ 00281 dllist_destroy_list(a->commands); 00282 a->commands = NULL; 00283 00284 /* Destroy any astar path list thats on the AI */ 00285 auto_destroy_astar_path(a); 00286 00287 /* Destroy profile array */ 00288 for(i = 0; i < AUTO_PROFILE_MAX_SIZE; i++) { 00289 if(a->profile[i]) { 00290 rb_destroy(a->profile[i]); 00291 } 00292 a->profile[i] = NULL; 00293 } 00294 00295 /* Destroy weaponlist */ 00296 auto_destroy_weaplist(a); 00297 00298 a->mymechnum = -1; 00299 } 00300 MechAuto(new) = -1; 00301 } 00302 00303 00304 } 00305 }