00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <stdio.h>
00016 #include <stdlib.h>
00017 #include <math.h>
00018 #include <sys/file.h>
00019 #include <time.h>
00020
00021 #include "mech.h"
00022 #include "mech.events.h"
00023 #include "create.h"
00024 #include "glue.h"
00025 #include "spath.h"
00026 #include "autopilot.h"
00027 #include "p.mech.maps.h"
00028 #include "p.mechfile.h"
00029 #include "p.mech.utils.h"
00030 #include "p.mech.build.h"
00031 #include "p.map.obj.h"
00032 #include "p.mech.sensor.h"
00033 #include "p.spath.h"
00034 #include "p.debug.h"
00035
00036 void debug_fixmap(dbref player, void *data, char *buffer)
00037 {
00038 MAP *m = (MAP *) data;
00039 int i, k;
00040 MECH *mek;
00041
00042 if(!m)
00043 return;
00044 notify_printf(player, "Checking %d entries..", m->first_free);
00045 DOLIST(k, Contents(m->mynum)) {
00046 if(Hardcode(k)) {
00047 if(WhichSpecial(k) == GTYPE_MECH) {
00048 MECH *mek;
00049
00050
00051 for(i = 0; i < m->first_free; i++)
00052 if(m->mechsOnMap[i] == k)
00053 break;
00054 if(i != m->first_free)
00055 continue;
00056 mek = getMech(k);
00057 mek->mapindex = -1;
00058 mek->mapnumber = 0;
00059 }
00060 }
00061 }
00062 for(i = 0; i < m->first_free; i++)
00063 if((k = m->mechsOnMap[i]) >= 0) {
00064 if(!IsMech(k)) {
00065 notify_printf(player,
00066 "Error: #%d isn't mech yet is in mapindex. Fixing..",
00067 k);
00068 m->mechsOnMap[i] = -1;
00069 } else if(!(mek = getMech(k))) {
00070 notify_printf(player,
00071 "Error: #%d has no mech data. Removing..", k);
00072 m->mechsOnMap[i] = -1;
00073 } else if(mek->mapindex != m->mynum) {
00074 notify_printf(player,
00075 "Error: #%d isn't really here! Removing..", k);
00076 m->mechsOnMap[i] = -1;
00077 } else if(mek->mapnumber != i) {
00078 notify_printf(player,
00079 "Error: #%d has invalid mapnumber (mn:%d <-> real:%d)..",
00080 k, mek->mapnumber, i);
00081 }
00082 }
00083 notify(player, "Done.");
00084 }
00085
00086
00087 #define SPECIAL_FREE 0
00088 #define SPECIAL_ALLOC 1
00089
00090
00091
00092 void map_view(dbref player, void *data, char *buffer)
00093 {
00094 MAP *mech_map = (MAP *) data;
00095 int argc, i;
00096 int x, y;
00097 char *args[2];
00098 int displayHeight = MAP_DISPLAY_HEIGHT, displayWidth = MAP_DISPLAY_WIDTH;
00099 char *str;
00100 char **maptext;
00101
00102
00103 if(!mech_map)
00104 return;
00105
00106
00107 argc = mech_parseattributes(buffer, args, 2);
00108 switch (argc) {
00109 case 2:
00110 x = BOUNDED(0, atoi(args[0]), mech_map->map_width - 1);
00111 y = BOUNDED(0, atoi(args[1]), mech_map->map_height - 1);
00112 break;
00113 default:
00114 notify(player, "Invalid number of parameters!");
00115 return;
00116 }
00117
00118
00119
00120
00121
00122 str = silly_atr_get(player, A_TACSIZE);
00123 if(!*str) {
00124 displayHeight = MAP_DISPLAY_HEIGHT;
00125 displayWidth = MAP_DISPLAY_WIDTH;
00126 } else if(sscanf(str, "%d %d", &displayHeight, &displayWidth) != 2 ||
00127 displayHeight > 24 || displayHeight < 5 || displayWidth < 5 ||
00128 displayWidth > 40) {
00129
00130 notify(player,
00131 "Illegal Tacsize attribute. Must be in format "
00132 "'Height Width' . Height : 5-24 Width : 5-40");
00133 displayHeight = MAP_DISPLAY_HEIGHT;
00134 displayWidth = MAP_DISPLAY_WIDTH;
00135
00136 }
00137
00138
00139 displayHeight = (displayHeight <= mech_map->map_height)
00140 ? displayHeight : mech_map->map_height;
00141 displayWidth = (displayWidth <= mech_map->map_width)
00142 ? displayWidth : mech_map->map_width;
00143
00144
00145 maptext = MakeMapText(player, NULL, mech_map, x, y, displayWidth,
00146 displayHeight, 3, 0);
00147
00148
00149 for(i = 0; maptext[i]; i++)
00150 notify(player, maptext[i]);
00151 }
00152
00153 void map_addhex(dbref player, void *data, char *buffer)
00154 {
00155 MAP *map;
00156 int x, y, argc;
00157 char *args[4], elev;
00158
00159 map = (MAP *) data;
00160 if(!CheckData(player, map))
00161 return;
00162 argc = mech_parseattributes(buffer, args, 4);
00163 DOCHECK(argc != 4, "Invalid number of arguments!");
00164 x = atoi(args[0]);
00165 y = atoi(args[1]);
00166 elev = abs(atoi(args[3]));
00167 DOCHECK(!((x >= 0) && (x < map->map_width) && (y >= 0) &&
00168 (y < map->map_height)), "X,Y out of range!");
00169 if(args[2][0] == '.')
00170 SetTerrain(map, x, y, ' ');
00171 else
00172 SetTerrain(map, x, y, args[2][0]);
00173 SetElevation(map, x, y, (elev <= MAX_ELEV) ? elev : MAX_ELEV);
00174 notify(player, "Hex set!");
00175 }
00176
00177 void map_mapemit(dbref player, void *data, char *buffer)
00178 {
00179 MAP *map;
00180
00181 map = (MAP *) data;
00182 if(!CheckData(player, map))
00183 return;
00184 while (*buffer == ' ')
00185 buffer++;
00186 DOCHECK(!buffer || !*buffer, "What do you want to @mapemit?");
00187 MapBroadcast(map, buffer);
00188 notify(player, "Message sent!");
00189 }
00190
00191
00192
00193 extern int dirs[6][2];
00194
00195 int water_distance(MAP * map, int x, int y, int dir, int max)
00196 {
00197 int i;
00198 int x2, y2;
00199
00200 for(i = 1; i < max; i++) {
00201 x = x + dirs[dir][0];
00202 y = y + dirs[dir][1];
00203 if(!x && dirs[dir][0])
00204 y--;
00205 x2 = BOUNDED(0, x, map->map_width - 1);
00206 y2 = BOUNDED(0, y, map->map_height - 1);
00207 if(x != x2 || y != y2)
00208 return max;
00209 if(GetTerrain(map, x, y) == WATER || GetTerrain(map, x, y) == ICE)
00210 return i;
00211 if(GetTerrain(map, x, y) != BRIDGE && GetTerrain(map, x, y) != ROAD)
00212 return max;
00213 }
00214 return max;
00215 }
00216
00217 static int eligible_bridge_hex(MAP * map, int x, int y)
00218 {
00219 int i, j, k;
00220
00221 for(k = 0; k < 3; k++)
00222 if((i = water_distance(map, x, y, k, 4)) < 4)
00223 if((j = water_distance(map, x, y, k + 3, 4)) < 4) {
00224 if((i - j) > 3)
00225 continue;
00226 return 1;
00227 }
00228 return 0;
00229 }
00230
00231
00232
00233 static void make_bridges(MAP * map)
00234 {
00235 int x, y;
00236
00237 for(x = 0; x < map->map_width; x++)
00238 for(y = 0; y < map->map_height; y++)
00239 if(GetTerrain(map, x, y) == ROAD)
00240 if(eligible_bridge_hex(map, x, y))
00241 SetTerrainBase(map, x, y, BRIDGE);
00242 }
00243
00244 int map_load(MAP * map, char *mapname)
00245 {
00246 char openfile[50];
00247 char terr, elev;
00248 int i1, i2, i3;
00249 FILE *fp;
00250 char row[MAPX * 2 + 3];
00251 int i, j = 0, height, width, filemode;
00252
00253 if(strlen(mapname) >= MAP_NAME_SIZE)
00254 mapname[MAP_NAME_SIZE] = 0;
00255 sprintf(openfile, "%s/%s", MAP_PATH, mapname);
00256 fp = my_open_file(openfile, "r", &filemode);
00257 if(!fp) {
00258 return -1;
00259 }
00260 del_mapobjs(map);
00261 if(map->map) {
00262 for(i = 0; i < map->map_height; i++)
00263 free((char *) (map->map[i]));
00264 free((char *) (map->map));
00265 }
00266 if(fscanf(fp, "%d %d\n", &height, &width) != 2 || height < 1 ||
00267 height > MAPY || width < 1 || width > MAPX) {
00268 SendError(tprintf("Map #%d: Invalid height and/or width",
00269 map->mynum));
00270 width = DEFAULT_MAP_WIDTH;
00271 height = DEFAULT_MAP_HEIGHT;
00272 }
00273 Create(map->map, unsigned char *, height);
00274
00275 for(i = 0; i < height; i++)
00276 Create(map->map[i], unsigned char, width);
00277
00278 for(i = 0; i < height; i++) {
00279 if(feof(fp)
00280 || fgets(row, 2 * MAPX + 2, fp) == NULL ||
00281 strlen(row) < (2 * width)) {
00282 break;
00283 }
00284 for(j = 0; j < width; j++) {
00285 terr = row[2 * j];
00286 elev = row[2 * j + 1] - '0';
00287 switch (terr) {
00288 case FIRE:
00289 map->flags |= MAPFLAG_FIRES;
00290 break;
00291 case TFIRE:
00292 case SMOKE:
00293 case '.':
00294 terr = GRASSLAND;
00295 break;
00296 case '\'':
00297 terr = LIGHT_FOREST;
00298 break;
00299 }
00300 if(!strcmp(GetTerrainName_base(terr), "Unknown")) {
00301 SendError(tprintf
00302 ("Map #%d: Invalid terrain at %d,%d: '%c'",
00303 map->mynum, j, i, terr));
00304 terr = GRASSLAND;
00305 }
00306 SetMap(map, j, i, terr, elev);
00307 }
00308 }
00309 if(i != height) {
00310 SendError(tprintf("Error: EOF reached prematurely. "
00311 "(x%d != %d || y%d != %d)", j, width, i, height));
00312 my_close_file(fp, &filemode);
00313 return -2;
00314 }
00315 map->grav = 100;
00316 map->temp = 20;
00317 if(!feof(fp)) {
00318 if(fscanf(fp, "%d: %d %d\n", &i1, &i2, &i3) == 3) {
00319 map->flags = i1;
00320 map->grav = i2;
00321 map->temp = i3;
00322 }
00323 }
00324 map->map_height = height;
00325 map->map_width = width;
00326 if(!MapNoBridgify(map))
00327 make_bridges(map);
00328 sprintf(map->mapname, mapname);
00329 my_close_file(fp, &filemode);
00330 return 0;
00331 }
00332
00333 void map_loadmap(dbref player, void *data, char *buffer)
00334 {
00335 MAP *map;
00336 char *args[1];
00337
00338 map = (MAP *) data;
00339
00340 if(!CheckData(player, map))
00341 return;
00342
00343 DOCHECK(mech_parseattributes(buffer, args, 1) != 1,
00344 "Invalid number of arguments!");
00345 notify_printf(player, "Loading %s", args[0]);
00346 switch (map_load(map, args[0])) {
00347 case -1:
00348 notify(player, "Map not found.");
00349 return;
00350 case -2:
00351 notify(player, "Map invalid.");
00352 return;
00353 case 0:
00354 notify(player, "Map loaded.");
00355 break;
00356 default:
00357 notify(player, "Unknown error while loading map!");
00358 return;
00359 }
00360
00361 if(player != 1) {
00362 notify(player, "Clearing Mechs off Newly Loaded Map");
00363 map_clearmechs(player, data, "");
00364 }
00365 }
00366
00367 mapobj *find_mapobj(MAP * map, int x, int y, int type);
00368
00369 void map_savemap(dbref player, void *data, char *buffer)
00370 {
00371 MAP *map;
00372 char *args[1];
00373 FILE *fp;
00374 char openfile[50];
00375 int i, j;
00376 char row[MAPX * 2 + 1];
00377 char terrain;
00378 int filemode;
00379
00380 map = (MAP *) data;
00381
00382 if(!CheckData(player, map))
00383 return;
00384
00385 DOCHECK(mech_parseattributes(buffer, args, 1) != 1,
00386 "Invalid number of arguments!");
00387 if(strlen(args[0]) >= MAP_NAME_SIZE)
00388 args[MAP_NAME_SIZE] = 0;
00389 notify_printf(player, "Saving %s", args[0]);
00390 sprintf(openfile, "%s/", MAP_PATH);
00391 strcat(openfile, args[0]);
00392 DOCHECK(!(fp =
00393 my_open_file(openfile, "w", &filemode)),
00394 "Unable to open the map file!");
00395 fprintf(fp, "%d %d\n", map->map_height, map->map_width);
00396 for(i = 0; i < map->map_height; i++) {
00397 mapobj *mo;
00398
00399 row[0] = 0;
00400 for(j = 0; j < map->map_width; j++) {
00401 terrain = GetTerrain(map, j, i);
00402 switch (terrain) {
00403 case ' ':
00404 terrain = '.';
00405 break;
00406 case FIRE:
00407
00408 if((mo = find_mapobj(map, j, i, TYPE_FIRE)))
00409 terrain = TFIRE;
00410 else if(!(map->flags & MAPFLAG_FIRES)) {
00411 SetTerrain(map, j, i, ' ');
00412 SendEvent(tprintf
00413 ("[lost?] fire event noticed on map #%d (%s) at %d,%d",
00414 map->mynum, map->mapname, j, i));
00415 terrain = '.';
00416 }
00417 break;
00418 case SMOKE:
00419 terrain = GetRTerrain(map, j, i);
00420 if(terrain == ' ')
00421 terrain = '.';
00422 if(terrain == SMOKE) {
00423 SetTerrain(map, j, i, ' ');
00424 SendEvent(tprintf
00425 ("[lost?] smoke event noticed on map #%d (%s) at %d,%d",
00426 map->mynum, map->mapname, j, i));
00427 terrain = '.';
00428 }
00429 break;
00430 }
00431 row[j * 2] = terrain;
00432 row[j * 2 + 1] = GetElevation(map, j, i) + '0';
00433 }
00434 row[j * 2] = 0;
00435 fprintf(fp, "%s\n", row);
00436 }
00437 if((i = (map->flags & ~(MAPFLAG_MAPO))))
00438 fprintf(fp, "%d: %d %d\n", i, map->grav, map->temp);
00439 notify(player, "Saving complete!");
00440 my_close_file(fp, &filemode);
00441 }
00442
00443 void map_setmapsize(dbref player, void *data, char *buffer)
00444 {
00445 MAP *oldmap;
00446 unsigned char **map;
00447 int x, y, i, j, failed = 0, argc, x1, y1;
00448 char *args[4];
00449
00450 oldmap = (MAP *) data;
00451 if(!CheckData(player, oldmap))
00452 return;
00453 DOCHECK(oldmap->mapobj[TYPE_BITS], "Invalid map for size change, sorry.");
00454 DOCHECK((argc =
00455 mech_parseattributes(buffer, args, 4)) != 2,
00456 "Invalid number of arguments (X/Y expected)");
00457 x = atoi(args[0]);
00458 y = atoi(args[1]);
00459 DOCHECK(!((x >= 0) && (x <= MAPX) && (y >= 0) &&
00460 (y <= MAPY)), "X,Y out of range!");
00461
00462 Create(map, unsigned char *, y);
00463 for(i = 0; i < y; i++)
00464 Create(map[i], unsigned char, x);
00465
00466 if(failed)
00467 SendError("Memory allocation failed in setmapsize!");
00468 else {
00469
00470 for(i = 0; i < y; i++)
00471 for(j = 0; j < x; j++)
00472 SetMapB(map, j, i, ' ', 0);
00473
00474 x1 = (oldmap->map_width < x) ? oldmap->map_width : x;
00475 y1 = (oldmap->map_height < y) ? oldmap->map_height : y;
00476 for(i = 0; i < y1; i++)
00477 for(j = 0; j < x1; j++)
00478 SetMapB(map, j, i, GetTerrain(oldmap, j, i),
00479 GetElevation(oldmap, j, i));
00480
00481 for(i = oldmap->map_height - 1; i >= 0; i--)
00482 free((char *) (oldmap->map[i]));
00483 del_mapobjs(oldmap);
00484
00485 oldmap->map_height = y;
00486 oldmap->map_width = x;
00487 oldmap->map = map;
00488 notify(player, "Size set.");
00489 }
00490 }
00491
00492 void map_clearmechs(dbref player, void *data, char *buffer)
00493 {
00494 MAP *map;
00495
00496 map = (MAP *) data;
00497 if(CheckData(player, map))
00498 ShutDownMap(player, map->mynum);
00499 }
00500
00501 extern void update_LOSinfo(dbref, MAP *);
00502
00503 void map_update(dbref obj, void *data)
00504 {
00505 MAP *map = ((MAP *) data);
00506 MECH *mech;
00507 char *tmps, changemsg[LBUF_SIZE] = "";
00508 int ma, ml, wind, wspeed, cloudbase = 200;
00509 int oldl, oldv, i, j;
00510 AUTO *au;
00511
00512
00513
00514
00515 if(!(muxevent_tick % 25)) {
00516 oldl = map->maplight;
00517 oldv = map->mapvis;
00518 if(!(tmps = silly_atr_get(obj, A_MAPVIS)) ||
00519 sscanf(tmps, "%d %d %d %d %d %[^\n]", &ma, &ml, &wind,
00520 &wspeed, &cloudbase, changemsg) < 4) {
00521 ma = 30;
00522 ml = 2;
00523 wind = 0;
00524 wspeed = 0;
00525 cloudbase = 200;
00526 }
00527 map->winddir = wind;
00528 map->windspeed = wspeed;
00529 map->mapvis = BOUNDED(0, ma, 60);
00530 map->maxvis = BOUNDED(24, ma * 3, 60);
00531 map->maplight = BOUNDED(0, ml, 2);
00532 map->cloudbase = cloudbase;
00533 if(ml != oldl || ma != oldv)
00534 for(i = 0; i < map->first_free; i++) {
00535 if((j = map->mechsOnMap[i]) < 0)
00536 continue;
00537 if(!(mech = getMech(j)))
00538 continue;
00539 if(ml != oldl)
00540 sensor_light_availability_check(mech);
00541 if(strlen(changemsg) > 5)
00542 mech_notify(mech, MECHALL, changemsg);
00543 }
00544 }
00545 update_LOSinfo(obj, map);
00546
00547 }
00548
00549 void initialize_map_empty(MAP * new, dbref key)
00550 {
00551 int i, j;
00552
00553 new->mynum = key;
00554 new->map_width = DEFAULT_MAP_WIDTH;
00555 new->map_height = DEFAULT_MAP_HEIGHT;
00556 Create(new->map, unsigned char *, new->map_height);
00557
00558 for(i = 0; i < new->map_height; i++)
00559 Create(new->map[i], unsigned char, new->map_width);
00560
00561 for(i = 0; i < new->map_height; i++)
00562 for(j = 0; j < new->map_width; j++)
00563 SetMap(new, j, i, ' ', 0);
00564 }
00565
00566
00567 void newfreemap(dbref key, void **data, int selector)
00568 {
00569 MAP *new = *data;
00570 int i;
00571
00572 switch (selector) {
00573 case SPECIAL_ALLOC:
00574 initialize_map_empty(new, key);
00575
00576 for(i = 0; i < NUM_MAPOBJTYPES; i++)
00577 new->mapobj[i] = NULL;
00578 sprintf(new->mapname, "%s", "Default Map");
00579 break;
00580 case SPECIAL_FREE:
00581 del_mapobjs(new);
00582 if(new->map) {
00583 for(i = new->map_height - 1; i >= 0; i--)
00584 if(new->map[i])
00585 free((char *) (new->map[i]));
00586 free((char *) (new->map));
00587 }
00588 break;
00589 }
00590 }
00591
00592 int map_sizefun(void *data, int flag)
00593 {
00594 MAP *map = (MAP *) data;
00595 int size = 0;
00596
00597 if(!map)
00598 return 0;
00599 size = sizeof(*map);
00600 if(map->map)
00601 size += sizeof(*map->map);
00602 return size;
00603 }
00604
00605 void map_listmechs(dbref player, void *data, char *buffer)
00606 {
00607 MAP *map;
00608 MECH *tempMech;
00609 int i;
00610 int count = 0;
00611 char valid[50];
00612 char *ID;
00613 char *args[2];
00614 char *cmds[] = { "MECHS", "OBJS", NULL };
00615 enum {
00616 MECHS, OBJS
00617 };
00618
00619 map = (MAP *) data;
00620
00621 if(!CheckData(player, map))
00622 return;
00623 DOCHECK(mech_parseattributes(buffer, args, 1) == 0,
00624 "Supply target type too!");
00625 switch (listmatch(cmds, args[0])) {
00626 case MECHS:
00627 notify(player, "--- Mechs on Map ---");
00628 for(i = 0; i < map->first_free; i++) {
00629 if(map->mechsOnMap[i] != -1) {
00630 tempMech = getMech(map->mechsOnMap[i]);
00631 ID = MechIDS(tempMech, 0);
00632 if(tempMech)
00633 strcpy(valid, "Valid Data");
00634 else
00635 strcpy(valid, "Invalid Object Data! Remove this Mech!");
00636 notify_printf(player, "Mech DB Number: %d : [%s]\t%s",
00637 map->mechsOnMap[i], ID, valid);
00638 count++;
00639 }
00640 }
00641 notify_printf(player, "%d Mechs On Map", count);
00642 notify_printf(player, "%d positions open", MAX_MECHS_PER_MAP - count);
00643 if(count != map->first_free)
00644 notify_printf(player,
00645 "%d is first free slot, according to db.",
00646 map->first_free);
00647 return;
00648 break;
00649 case OBJS:
00650 list_mapobjs(player, map);
00651 return;
00652 break;
00653 }
00654 notify_printf(player, "Invalid argument (%s)!", args[0]);
00655 return;
00656 }
00657
00658 void clear_hex(MECH * mech, int x, int y, int meant)
00659 {
00660 MAP *map;
00661
00662 if(!(map = getMap(mech->mapindex)))
00663 return;
00664 switch (GetTerrain(map, x, y)) {
00665 case HEAVY_FOREST:
00666 SetTerrain(map, x, y, LIGHT_FOREST);
00667 break;
00668 case LIGHT_FOREST:
00669 if(Number(1, 2) == 1)
00670 SetTerrain(map, x, y, ROUGH);
00671 else
00672 SetTerrain(map, x, y, GRASSLAND);
00673 break;
00674 default:
00675 return;
00676 }
00677 if(meant) {
00678 MechLOSBroadcast(mech, tprintf("'s shot clears %d,%d!", x, y));
00679 mech_printf(mech, MECHALL, "You clear %d,%d.", x, y);
00680 } else {
00681 MechLOSBroadcast(mech, tprintf("'s stray shot clears %d,%d!", x, y));
00682 mech_printf(mech, MECHALL, "You accidentally clear the %d,%d!", x, y);
00683 }
00684 }
00685
00686 MAP *spath_map;
00687
00688 #define readval(f,t) DOCHECK(readint(f, t), "Invalid argument!")
00689
00690 void map_pathfind(dbref player, void *data, char *buffer)
00691 {
00692 MAP *map = (MAP *) data;
00693 char *args[6];
00694 int argc;
00695 int x1, y1, x2, y2;
00696 time_t start_t;
00697 int errper = -1;
00698
00699 if(!map)
00700 return;
00701 argc = mech_parseattributes(buffer, args, 6);
00702 DOCHECK((argc < 4 || argc > 5), "Invalid arguments!");
00703 readval(x1, args[0]);
00704 readval(y1, args[1]);
00705 readval(x2, args[2]);
00706 readval(y2, args[3]);
00707 if(argc > 4) {
00708 readval(errper, args[4]);
00709 errper = BOUNDED(0, errper, 1000);
00710 }
00711 spath_map = map;
00712 start_t = time(NULL);
00713 }
00714
00715 #undef readval
00716
00717 void UpdateMechsTerrain(MAP * map, int x, int y, int t)
00718 {
00719 MECH *mech;
00720 int i;
00721
00722 for(i = 0; i < map->first_free; i++) {
00723 if(!(mech = FindObjectsData(map->mechsOnMap[i])))
00724 continue;
00725 if(MechX(mech) != x || MechY(mech) != y)
00726 continue;
00727 if(MechTerrain(mech) != t) {
00728 MechTerrain(mech) = t;
00729 MarkForLOSUpdate(mech);
00730 }
00731 }
00732 }