This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Data Structures | |
struct | hexlosmap_info |
Defines | |
#define | MAX_SENSORS 2 |
#define | NUMSENSORS(mech) 2 |
#define | MAPLOS_MAXX 70 |
#define | MAPLOS_MAXY 45 |
#define | MAPLOS_FLAG_SLITE 1 |
#define | MAPLOSHEX_NOLOS 0 |
#define | MAPLOSHEX_SEEN 1 |
#define | MAPLOSHEX_SEETERRAIN 2 |
#define | MAPLOSHEX_SEEELEV 4 |
#define | MAPLOSHEX_LIT 8 |
#define | MAPLOSHEX_SEE (MAPLOSHEX_SEETERRAIN | MAPLOSHEX_SEEELEV) |
#define | LOSMap_GetFlag(losmap, x, y) ((losmap)->map[LOSMap_Hex2Index(losmap, x, y)]) |
Functions | |
hexlosmap_info * | CalculateLOSMap (MAP *, MECH *, int, int, int, int) |
int | LOSMap_Hex2Index (hexlosmap_info *, int, int) |
#define MAPLOS_FLAG_SLITE 1 |
#define MAPLOS_MAXX 70 |
#define MAPLOS_MAXY 45 |
#define MAPLOSHEX_LIT 8 |
Definition at line 27 of file map.los.h.
Referenced by hexlit(), litemark_callback(), litemark_map(), and trace_slitelos().
#define MAPLOSHEX_NOLOS 0 |
#define MAPLOSHEX_SEE (MAPLOSHEX_SEETERRAIN | MAPLOSHEX_SEEELEV) |
Definition at line 28 of file map.los.h.
Referenced by CalculateLOSMap(), get_lrshexstr(), sketch_tac_map(), and trace_maphexlos().
#define MAPLOSHEX_SEEELEV 4 |
#define MAPLOSHEX_SEEN 1 |
Definition at line 24 of file map.los.h.
Referenced by CalculateLOSMap(), get_lrshexstr(), set_hexlosall(), set_hexlosinfo(), and sketch_tac_map().
#define MAPLOSHEX_SEETERRAIN 2 |
Definition at line 25 of file map.los.h.
Referenced by get_lrshexstr(), sketch_tac_map(), and trace_maphexlos().
#define MAX_SENSORS 2 |
#define NUMSENSORS | ( | mech | ) | 2 |
hexlosmap_info* CalculateLOSMap | ( | MAP * | , | |
MECH * | , | |||
int | , | |||
int | , | |||
int | , | |||
int | ||||
) |
Definition at line 433 of file map.los.c.
References CLAIRVOYANT, CLASS_MECH, hexlosmap_info::flags, IsWater, litemark_map(), losmap, hexlosmap_info::map, MAPLOS_MAXX, MAPLOS_MAXY, MAPLOSHEX_NOLOS, MAPLOSHEX_SEE, MAPLOSHEX_SEEN, MechCritStatus, MechHeight(), MechMove, MechRTerrain, MechSeesTerrain(), MechType, MechZ, MOVE_HOVER, MECH::mynum, SendError, set_hexlosall(), hexlosmap_info::startx, hexlosmap_info::starty, tprintf(), trace_maphexlos(), WaterBeast, hexlosmap_info::xsize, and hexlosmap_info::ysize.
Referenced by sketch_tac_map().
00435 { 00436 int index, underterrain, bothworlds; 00437 float start_height; 00438 00439 /* Some safeguarding on size */ 00440 00441 if(xsz > MAPLOS_MAXX || ysz > MAPLOS_MAXY) { 00442 SendError(tprintf("xsize (%d vs %d) or ysize (%d vs %d) " 00443 "to CalculateLOSMap too large, for mech #%d", 00444 xsz, MAPLOS_MAXX, ysz, MAPLOS_MAXY, mech->mynum)); 00445 return NULL; 00446 } 00447 00448 losmap.startx = sx; 00449 losmap.starty = sy; 00450 losmap.xsize = xsz; 00451 losmap.ysize = ysz; 00452 losmap.flags = 0; 00453 memset(losmap.map, 0, xsz * ysz); 00454 00455 underterrain = MechZ(mech) <= -1; 00456 if(IsWater(MechRTerrain(mech)) 00457 && ((MechType(mech) == CLASS_MECH && MechZ(mech) == -1) 00458 || ((WaterBeast(mech) || MechMove(mech) == MOVE_HOVER) 00459 && MechZ(mech) == 0))) { 00460 bothworlds = 1; 00461 } else 00462 bothworlds = 0; 00463 00464 start_height = MechZ(mech) + MechHeight(mech); 00465 00466 if(MechCritStatus(mech) & CLAIRVOYANT) { 00467 set_hexlosall(MAPLOSHEX_SEE); 00468 return &losmap; 00469 } 00470 00471 if(!MechSeesTerrain(mech, 0) && !MechSeesTerrain(mech, 1)) { 00472 set_hexlosall(MAPLOSHEX_NOLOS); 00473 return &losmap; 00474 } 00475 00476 /* In order for slites to properly light terrain, we have to mark the 00477 * losmap with all lit hexes first. Which means going over all 'mechs on 00478 * the map and tag all hexes that they light. 00479 */ 00480 00481 litemark_map(map); 00482 00483 /* In order to do the most efficient lostracing, we make losmaps by 00484 * first tracing from the 'mech hex to the upper Y-row, the lower Y-row, 00485 * the leftmost X-row, the rightmost X-row, and then all hexes starting 00486 * at the upper left corner to make sure we have seen all hexes. (It is 00487 * entirely possible for a hex not to be visited yet, even if we traced 00488 * to every other hex.) 00489 */ 00490 00491 for(index = 0; index < xsz; index++) { 00492 if(losmap.map[index] & MAPLOSHEX_SEEN) 00493 continue; 00494 trace_maphexlos(map, mech, index, underterrain || bothworlds, 00495 start_height); 00496 } 00497 for(index = (ysz - 1) * xsz; index < ysz * xsz; index++) { 00498 if(losmap.map[index] & MAPLOSHEX_SEEN) 00499 continue; 00500 trace_maphexlos(map, mech, index, underterrain || bothworlds, 00501 start_height); 00502 } 00503 for(index = xsz; index < ysz * xsz; index += xsz) { 00504 if(losmap.map[index] & MAPLOSHEX_SEEN) 00505 continue; 00506 trace_maphexlos(map, mech, index, underterrain || bothworlds, 00507 start_height); 00508 } 00509 for(index = 2 * xsz - 1; index < ysz * xsz; index += xsz) { 00510 if(losmap.map[index] & MAPLOSHEX_SEEN) 00511 continue; 00512 trace_maphexlos(map, mech, index, underterrain || bothworlds, 00513 start_height); 00514 } 00515 for(index = 0; index < xsz * ysz; index++) { 00516 if(losmap.map[index] & MAPLOSHEX_SEEN) 00517 continue; 00518 trace_maphexlos(map, mech, index, underterrain || bothworlds, 00519 start_height); 00520 } 00521 00522 return &losmap; 00523 }
int LOSMap_Hex2Index | ( | hexlosmap_info * | , | |
int | , | |||
int | ||||
) |
Definition at line 26 of file map.los.c.
References losmap, SendError, hexlosmap_info::startx, hexlosmap_info::starty, tprintf(), hexlosmap_info::xsize, and hexlosmap_info::ysize.
Referenced by hexlit(), set_hexlosinfo(), and set_sliteinfo().
00027 { 00028 if(x < losmap->startx || x > losmap->startx + losmap->xsize || 00029 y < losmap->starty || y > losmap->starty + losmap->ysize) { 00030 SendError(tprintf("LOSMap request from out of bounds hex: %d,%d", 00031 x, y)); 00032 return 0; 00033 } 00034 return ((y - losmap->starty) * losmap->xsize) + (x - losmap->startx); 00035 }