src/hcode/btech/p.map.obj.h File Reference

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

Go to the source code of this file.

Functions

mapobjnext_mapobj (mapobj *m)
mapobjfirst_mapobj (MAP *map, int type)
void save_mapobjs (FILE *f, MAP *map)
int find_entrance (MAP *map, char dir, int *x, int *y)
char * structure_name (mapobj *mapo)
mapobjfind_entrance_by_target (MAP *map, dbref target)
mapobjfind_entrance_by_xy (MAP *map, int x, int y)
mapobjfind_mapobj (MAP *map, int x, int y, int type)
char find_decorations (MAP *map, int x, int y)
void del_mapobj (MAP *map, mapobj *mapob, int type, int zap)
void del_mapobjst (MAP *map, int type)
void del_mapobjs (MAP *map)
mapobjadd_mapobj (MAP *map, mapobj **to, mapobj *from, int flag)
int FindXEven (int wind, int x)
int FindYEven (int wind, int y)
int FindXOdd (int wind, int x)
int FindYOdd (int wind, int y)
void CheckForFire (MAP *map, int x[], int y[])
void CheckForSmoke (MAP *map, int x[], int y[])
void add_decoration (MAP *map, int x, int y, int type, char data, int flaggo)
void load_mapobjs (FILE *f, MAP *map)
void list_mapobjs (dbref player, MAP *map)
void map_addfire (dbref player, void *data, char *buffer)
void map_addsmoke (dbref player, void *data, char *buffer)
void map_add_block (dbref player, void *data, char *buffer)
int is_blocked_lz (MECH *mech, MAP *map, int x, int y)
void map_setlinked (dbref player, void *data, char *buffer)
int mapobj_del (MAP *map, int x, int y, int tt)
void map_delobj (dbref player, void *data, char *buffer)
int parse_coord (MAP *map, int dir, char *data, int *x, int *y)
void add_entrances (dbref loc, MAP *map, char *data)
void add_links (dbref loc, MAP *map, char *data)
void recursively_updatelinks (dbref from, dbref loc)
void map_updatelinks (dbref player, void *data, char *buffer)
int map_linked (dbref mapobj)
int get_cf (dbref d)
void possibly_start_building_regen (dbref obj)
void hit_building (MECH *mech, int x, int y, int weapindx, int damage)
void fire_hex (MECH *mech, int x, int y, int meant)
void steppable_base_check (MECH *mech, int x, int y)
void show_building_in_hex (MECH *mech, int x, int y)
int obj_size (MAP *map)
int map_underlying_terrain (MAP *map, int x, int y)
int mech_underlying_terrain (MECH *mech)


Function Documentation

void add_decoration ( MAP map,
int  x,
int  y,
int  type,
char  data,
int  flaggo 
)

Definition at line 516 of file map.obj.c.

References add_mapobj(), mapobj_struct::datac, mapobj_struct::datas, del_mapobj(), EVENT_DECORATION, fire_spreading_event(), FIRESPEED, first_mapobj(), GetRTerrain, MAPEVENT, MAP::mapobj, MAX, next_mapobj(), SetTerrain, smoke_dissipation_event(), TYPE_FIRE, TYPE_LAST_DEC, TYPE_SMOKE, mapobj_struct::x, and mapobj_struct::y.

Referenced by artillery_hit_hex(), blast_hit_hexesf(), CheckForFire(), CheckForSmoke(), DestroyMech(), DS_BlastNearbyMechsAndTrees(), fire_hex(), map_addfire(), map_addsmoke(), meltSnowAndIce(), and water_extinguish_inferno().

00517 {
00518         mapobj foo;
00519         mapobj *tmpo;
00520 
00521         bzero(&foo, sizeof(mapobj));
00522         foo.x = x;
00523         foo.y = y;
00524         foo.datac = GetRTerrain(map, x, y);
00525         /* if (foo.datac) */
00526         {
00527                 mapobj *m, *m2;
00528                 int i;
00529 
00530                 for(i = 0; i <= TYPE_LAST_DEC; i++) {
00531                         for(m = first_mapobj(map, i); m; m = m2) {
00532                                 m2 = next_mapobj(m);
00533                                 if(m->x == x && m->y == y)
00534                                         del_mapobj(map, m, i, 1);
00535                         }
00536                 }
00537         }
00538         SetTerrain(map, x, y, data);
00539         foo.datas = (short) flaggo;
00540         tmpo = add_mapobj(map, &map->mapobj[type], &foo, 1);
00541         if(flaggo) {
00542                 if(type == TYPE_SMOKE)
00543                         MAPEVENT(map, EVENT_DECORATION, smoke_dissipation_event,
00544                                          flaggo, tmpo);
00545                 if(type == TYPE_FIRE) {
00546                         foo.datas = foo.datas * FIRESPEED(map) * 4 / 3 / 60;
00547                         foo.datas = MAX(foo.datas, FIRESPEED(map) * 2);
00548                         MAPEVENT(map, EVENT_DECORATION, fire_spreading_event,
00549                                          FIRESPEED(map), tmpo);
00550                 }
00551         }
00552 }

void add_entrances ( dbref  loc,
MAP map,
char *  data 
)

Definition at line 839 of file map.obj.c.

References add_mapobj(), addstat, alloc_mbuf, args, mapobj_struct::datac, dirtable, free_mbuf, mech_parseattributes(), parse_coord(), TYPE_ENTRANCE, mapobj_struct::x, x, mapobj_struct::y, and y.

Referenced by recursively_updatelinks().

00840 {
00841         char *buf;
00842         char *args[4];
00843         int x, y, i;
00844         mapobj foo;
00845 
00846         bzero(&foo, sizeof(mapobj));
00847 
00848         buf = alloc_mbuf("add_entrances");
00849 
00850         strcpy(buf, data);
00851         if(mech_parseattributes(buf, args, 4) == 4) {
00852                 for(i = 0; i < 4; i++)
00853                         if((parse_coord(map, i, args[i], &x, &y))) {
00854                                 foo.datac = dirtable[i].dir;
00855                                 foo.x = x;
00856                                 foo.y = y;
00857                                 add_mapobj(map, &map->mapobj[TYPE_ENTRANCE], &foo, 1);
00858                                 addstat(2);
00859                         }
00860         }
00861         free_mbuf(buf);
00862 }

void add_links ( dbref  loc,
MAP map,
char *  data 
)

Definition at line 864 of file map.obj.c.

References A_BUILDCOORD, add_mapobj(), addstat, alloc_lbuf, args, FindObjectsData(), free_lbuf, MAP::map_height, MAP::map_width, MAP::mapobj, mech_parseattributes(), mapobj_struct::obj, recursively_updatelinks(), set_hex_enterable(), silly_atr_get(), TYPE_BUILD, mapobj_struct::x, x, mapobj_struct::y, and y.

Referenced by recursively_updatelinks().

00865 {
00866         char *buf;
00867         char *args[500];
00868         int i, found, targ;
00869         char *tmps;
00870         int x, y;
00871         mapobj foo;
00872 
00873         bzero(&foo, sizeof(mapobj));
00874 
00875         buf = alloc_lbuf("add_links");
00876 
00877         strcpy(buf, data);
00878         if((found = mech_parseattributes(buf, args, 500)) > 0)
00879                 for(i = 0; i < found; i++) {
00880                         targ = atoi(args[i]);
00881                         if(targ < 0 || !(FindObjectsData(targ)) || targ == loc)
00882                                 continue;
00883                         tmps = silly_atr_get(targ, A_BUILDCOORD);
00884                         if(!tmps)
00885                                 continue;
00886                         if(sscanf(tmps, "%d,%d", &x, &y) != 2)
00887                                 continue;
00888                         if(x < 0 || x >= map->map_width || y < 0 || y >= map->map_height)
00889                                 continue;
00890                         set_hex_enterable(map, x, y);
00891                         foo.x = x;
00892                         foo.y = y;
00893                         foo.obj = targ;
00894                         add_mapobj(map, &map->mapobj[TYPE_BUILD], &foo, 1);
00895                         addstat(0);
00896                         recursively_updatelinks(loc, targ);
00897                 }
00898         free_lbuf(buf);
00899 }

mapobj* add_mapobj ( MAP map,
mapobj **  to,
mapobj from,
int  flag 
)

Definition at line 185 of file map.obj.c.

References Create, MAP::flags, free_mapobjs, MAPFLAG_MAPO, and mapobj_struct::next.

Referenced by add_decoration(), add_entrances(), add_links(), add_mine(), grab_us_an_array(), load_mapobjs(), map_add_block(), map_add_mine(), map_setlinked(), and recursively_updatelinks().

00186 {
00187         mapobj *realto;
00188 
00189         map->flags |= MAPFLAG_MAPO;
00190         from->next = *to;
00191         if(!free_mapobjs) {
00192                 Create(realto, mapobj, 1);
00193         } else {
00194                 realto = free_mapobjs;
00195                 free_mapobjs = realto->next;
00196         }
00197         bcopy(from, realto, sizeof(mapobj));
00198         *to = realto;
00199         return realto;
00200 }

void CheckForFire ( MAP map,
int  x[],
int  y[] 
)

Definition at line 401 of file map.obj.c.

References add_decoration(), FIRE, FIRE_DURATION, IsForestHex, NUM_SPREAD_HEX, and TYPE_FIRE.

Referenced by fire_spreading_event().

00402 {
00403         int i;
00404 
00405         for(i = 0; i < NUM_SPREAD_HEX; i++) {
00406                 if(x[i] < 0 || y[i] < 0)
00407                         continue;
00408                 /* Cackle */
00409                 if(IsForestHex(map, x[i], y[i]))
00410                         add_decoration(map, x[i], y[i], TYPE_FIRE, FIRE, FIRE_DURATION);
00411         }
00412 }

void CheckForSmoke ( MAP map,
int  x[],
int  y[] 
)

Definition at line 414 of file map.obj.c.

References add_decoration(), BUILDING, find_decorations(), GetTerrain, NUM_SPREAD_HEX, SMOKE, SMOKE_DURATION, TYPE_SMOKE, and WALL.

Referenced by fire_spreading_event().

00415 {
00416         int i;
00417 
00418         for(i = 0; i < NUM_SPREAD_HEX; i++) {
00419                 if(x[i] < 0 || y[i] < 0)
00420                         continue;
00421                 if(find_decorations(map, x[i], y[i]))
00422                         continue;
00423                 /* Cackle */
00424                 switch (GetTerrain(map, x[i], y[i])) {
00425                 case BUILDING:
00426                 case WALL:
00427                         continue;
00428                 default:
00429                         break;
00430                 }
00431                 add_decoration(map, x[i], y[i], TYPE_SMOKE, SMOKE, SMOKE_DURATION);
00432         }
00433 }

void del_mapobj ( MAP map,
mapobj mapob,
int  type,
int  zap 
)

Definition at line 140 of file map.obj.c.

References mapobj_struct::datac, MAP::flags, free_mapobjs, MAPFLAG_MAPO, MAP::mapobj, mapobj_struct::next, SetTerrain, StopDec, TYPE_LAST_DEC, mapobj_struct::x, and mapobj_struct::y.

Referenced by add_decoration(), del_mapobjst(), fire_dissipation_event(), map_delobj(), mapobj_del(), and smoke_dissipation_event().

00141 {
00142         /* Delete the specified mapobj */
00143         struct mapobj_struct *tmp;
00144 
00145         if(!(map->flags & MAPFLAG_MAPO))
00146                 return;
00147         if(map->mapobj[type] != mapob) {
00148                 for(tmp = map->mapobj[type]; tmp->next && tmp->next != mapob;
00149                         tmp = tmp->next);
00150                 if(!tmp->next)
00151                         return;
00152                 tmp->next = mapob->next;
00153         } else
00154                 map->mapobj[type] = mapob->next;
00155         /* Then, the silly thing. Decorations, they suck */
00156         if(type <= TYPE_LAST_DEC) {
00157                 /* Need to alter terrain back to 'usual' */
00158                 if(!(zap & 2))
00159                         SetTerrain(map, mapob->x, mapob->y, mapob->datac);
00160                 if(zap)
00161                         StopDec(mapob);
00162         }
00163         mapob->next = free_mapobjs;
00164         free_mapobjs = mapob;
00165 }

void del_mapobjs ( MAP map  ) 

Definition at line 175 of file map.obj.c.

References del_mapobjst(), MAP::flags, MAPFLAG_MAPO, and NUM_MAPOBJTYPES.

Referenced by map_load(), map_setmapsize(), and newfreemap().

00176 {
00177         int i;
00178 
00179         for(i = 0; i < NUM_MAPOBJTYPES; i++)
00180                 del_mapobjst(map, i);
00181         if(map->flags & MAPFLAG_MAPO)
00182                 map->flags &= ~MAPFLAG_MAPO;
00183 }

void del_mapobjst ( MAP map,
int  type 
)

Definition at line 167 of file map.obj.c.

References del_mapobj(), MAP::flags, MAPFLAG_MAPO, and MAP::mapobj.

Referenced by del_mapobjs(), and recursively_updatelinks().

00168 {
00169         if(!(map->flags & MAPFLAG_MAPO))
00170                 return;
00171         while (map->mapobj[type])
00172                 del_mapobj(map, map->mapobj[type], type, 3);
00173 }

char find_decorations ( MAP map,
int  x,
int  y 
)

Definition at line 127 of file map.obj.c.

References mapobj_struct::datac, first_mapobj(), next_mapobj(), TYPE_LAST_DEC, mapobj_struct::x, and mapobj_struct::y.

Referenced by blast_hit_hexesf(), CheckForSmoke(), DS_BlastNearbyMechsAndTrees(), map_underlying_terrain(), and mech_underlying_terrain().

00128 {
00129         int i;
00130         mapobj *m;
00131 
00132         for(i = 0; i <= TYPE_LAST_DEC; i++) {
00133                 for(m = first_mapobj(map, i); m; m = next_mapobj(m))
00134                         if(m->x == x && m->y == y)
00135                                 return m->datac;
00136         }
00137         return 0;
00138 }

int find_entrance ( MAP map,
char  dir,
int *  x,
int *  y 
)

Definition at line 68 of file map.obj.c.

References mapobj_struct::datac, first_mapobj(), next_mapobj(), TYPE_ENTRANCE, mapobj_struct::x, and mapobj_struct::y.

Referenced by mech_enter_event(), and mech_enterbase().

00069 {
00070         mapobj *tmp;
00071 
00072         for(tmp = first_mapobj(map, TYPE_ENTRANCE); tmp; tmp = next_mapobj(tmp))
00073                 if(!dir || tmp->datac == dir) {
00074                         *x = tmp->x;
00075                         *y = tmp->y;
00076                         return 1;
00077                 }
00078         return 0;
00079 }

mapobj* find_entrance_by_target ( MAP map,
dbref  target 
)

Definition at line 89 of file map.obj.c.

References first_mapobj(), next_mapobj(), mapobj_struct::obj, and TYPE_BUILD.

Referenced by Leave_Hangar().

00090 {
00091         mapobj *tmp;
00092 
00093         for(tmp = first_mapobj(map, TYPE_BUILD); tmp; tmp = next_mapobj(tmp))
00094                 if(tmp->obj == target)
00095                         return tmp;
00096         return NULL;
00097 }

mapobj* find_entrance_by_xy ( MAP map,
int  x,
int  y 
)

Definition at line 99 of file map.obj.c.

References first_mapobj(), next_mapobj(), TYPE_BUILD, mapobj_struct::x, and mapobj_struct::y.

Referenced by auto_enter_event(), hit_building(), mech_enter_event(), mech_enterbase(), show_building_in_hex(), and steppable_base_check().

00100 {
00101         mapobj *tmp;
00102 
00103         for(tmp = first_mapobj(map, TYPE_BUILD); tmp; tmp = next_mapobj(tmp))
00104                 if(tmp->x == x && tmp->y == y)
00105                         return tmp;
00106         return NULL;
00107 }

mapobj* find_mapobj ( MAP map,
int  x,
int  y,
int  type 
)

Definition at line 109 of file map.obj.c.

References first_mapobj(), next_mapobj(), NUM_MAPOBJTYPES, mapobj_struct::x, and mapobj_struct::y.

00110 {
00111         mapobj *tmp;
00112         int i;
00113 
00114         if(type >= 0) {
00115                 for(tmp = first_mapobj(map, type); tmp; tmp = next_mapobj(tmp))
00116                         if(tmp->x == x && tmp->y == y)
00117                                 return tmp;
00118         } else {
00119                 for(i = 0; i < NUM_MAPOBJTYPES; i++)
00120                         for(tmp = first_mapobj(map, i); tmp; tmp = next_mapobj(tmp))
00121                                 if(tmp->x == x && tmp->y == y)
00122                                         return tmp;
00123         }
00124         return NULL;
00125 }

int FindXEven ( int  wind,
int  x 
)

Definition at line 227 of file map.obj.c.

Referenced by FindMyCoord().

00231 {
00232         switch (wind) {
00233         case 0:
00234                 if(x == 0)
00235                         return 0;
00236                 if(x == 1)
00237                         return -1;
00238                 return 1;
00239         case 60:
00240                 if(x == 0)
00241                         return 1;
00242                 if(x == 1)
00243                         return 0;
00244                 return 1;
00245         case 120:
00246                 if(x == 0)
00247                         return 1;
00248                 if(x == 1)
00249                         return 1;
00250                 return 0;
00251         case 180:
00252                 if(x == 0)
00253                         return 0;
00254                 if(x == 1)
00255                         return 1;
00256                 return -1;
00257         case 240:
00258                 return x - 1;
00259         case 300:
00260                 if(x == 0)
00261                         return -1;
00262                 if(x == 1)
00263                         return 0;
00264                 return -1;
00265         }
00266         return 0;
00267 }

int FindXOdd ( int  wind,
int  x 
)

Definition at line 311 of file map.obj.c.

Referenced by FindMyCoord().

00315 {
00316         switch (wind) {
00317         case 0:
00318                 if(x == 0)
00319                         return 0;
00320                 if(x == 1)
00321                         return 1;
00322                 return -1;
00323         case 60:
00324                 if(x == 0)
00325                         return 1;
00326                 if(x == 1)
00327                         return 0;
00328                 return 1;
00329         case 120:
00330                 if(x == 0)
00331                         return 1;
00332                 if(x == 1)
00333                         return 1;
00334                 return 0;
00335         case 180:
00336                 if(x == 0)
00337                         return 0;
00338                 if(x == 1)
00339                         return 1;
00340                 return -1;
00341         case 240:
00342                 return x - 1;
00343         case 300:
00344                 if(x == 0)
00345                         return -1;
00346                 if(x == 1)
00347                         return -1;
00348                 return 0;
00349         }
00350         return 0;
00351 }

int FindYEven ( int  wind,
int  y 
)

Definition at line 269 of file map.obj.c.

Referenced by FindMyCoord().

00273 {
00274         switch (wind) {
00275         case 0:
00276                 if(y == 0)
00277                         return -1;
00278                 if(y == 1)
00279                         return 0;
00280                 return 0;
00281         case 60:
00282                 if(y == 0)
00283                         return 0;
00284                 if(y == 1)
00285                         return -1;
00286                 return 1;
00287         case 120:
00288                 if(y == 0)
00289                         return 1;
00290                 if(y == 1)
00291                         return 0;
00292                 return 1;
00293         case 180:
00294                 return 1;
00295         case 240:
00296                 if(y == 0)
00297                         return 1;
00298                 if(y == 1)
00299                         return 1;
00300                 return 0;
00301         case 300:
00302                 if(y == 0)
00303                         return 0;
00304                 if(y == 1)
00305                         return -1;
00306                 return 1;
00307         }
00308         return 0;
00309 }

int FindYOdd ( int  wind,
int  y 
)

Definition at line 353 of file map.obj.c.

Referenced by FindMyCoord().

00357 {
00358         switch (wind) {
00359         case 0:
00360                 if(y == 0)
00361                         return -1;
00362                 if(y == 1)
00363                         return -1;
00364                 return -1;
00365         case 60:
00366                 if(y == 0)
00367                         return -1;
00368                 if(y == 1)
00369                         return -1;
00370                 return 0;
00371         case 120:
00372                 if(y == 0)
00373                         return 0;
00374                 if(y == 1)
00375                         return -1;
00376                 return 1;
00377         case 180:
00378                 if(y == 0)
00379                         return 1;
00380                 if(y == 1)
00381                         return 0;
00382                 return 0;
00383         case 240:
00384                 if(y == 0)
00385                         return 0;
00386                 if(y == 1)
00387                         return 1;
00388                 return -1;
00389         case 300:
00390                 if(y == 0)
00391                         return -1;
00392                 if(y == 1)
00393                         return 0;
00394                 return -1;
00395         }
00396         return 0;
00397 }

void fire_hex ( MECH mech,
int  x,
int  y,
int  meant 
)

Definition at line 1115 of file map.obj.c.

References add_decoration(), FIRE, FIRE_DURATION, getMap(), GetTerrain, HEAVY_FOREST, LIGHT_FOREST, MECH::mapindex, mech_printf(), MECHALL, MechLOSBroadcast(), tprintf(), and TYPE_FIRE.

Referenced by possibly_ignite().

01116 {
01117         MAP *map;
01118 
01119         if(!(map = getMap(mech->mapindex)))
01120                 return;
01121         switch (GetTerrain(map, x, y)) {
01122         case HEAVY_FOREST:
01123                 break;
01124         case LIGHT_FOREST:
01125                 break;
01126         default:
01127                 return;
01128         }
01129         if(meant) {
01130                 MechLOSBroadcast(mech, tprintf("'s shot ignites %d,%d!", x, y));
01131                 mech_printf(mech, MECHALL, "You ignite %d,%d.", x, y);
01132         } else {
01133                 MechLOSBroadcast(mech, tprintf("'s stray shot ignites %d,%d!", x, y));
01134                 mech_printf(mech, MECHALL, "You accidentally ignite %d,%d!", x, y);
01135         }
01136         add_decoration(map, x, y, TYPE_FIRE, FIRE, FIRE_DURATION);
01137 }

mapobj* first_mapobj ( MAP map,
int  type 
)

Definition at line 40 of file map.obj.c.

References MAP::mapobj.

Referenced by add_decoration(), find_decorations(), find_entrance(), find_entrance_by_target(), find_entrance_by_xy(), find_mapobj(), fun_bthexinblz(), fun_btlistblz(), is_blocked_lz(), list_mapobjs(), litemark_map(), map_delobj(), map_linked(), mapobj_del(), and obj_size().

00041 {
00042         return map->mapobj[type];
00043 }

int get_cf ( dbref  d  ) 

Definition at line 968 of file map.obj.c.

References get_building_cf().

00969 {
00970         int cf, max = 0;
00971 
00972         if(!(get_building_cf(d, &cf, &max)))
00973                 if(max <= 0)
00974                         return -1;
00975         return cf;
00976 }

void hit_building ( MECH mech,
int  x,
int  y,
int  weapindx,
int  damage 
)

Definition at line 1069 of file map.obj.c.

References AngelECMDisturbed, BuildIsCS, weapon_struct::damage, damage_cf(), find_entrance_by_xy(), get_building_cf(), getMap(), IsMissile, missile_hit_table_struct::key, MECH::mapindex, MapIsCS, mech_notify(), MECHALL, MechWeapons, MissileHitTable, missile_hit_table_struct::num_missiles, mapobj_struct::obj, Roll(), and STREAK.

Referenced by hex_hit().

01070 {
01071         mapobj *o;
01072         MAP *map;
01073         MAP *nmap;
01074         int loop, num_missiles_hit, hit_roll;
01075         int i1, i2;
01076 
01077         if(!(map = getMap(mech->mapindex)))
01078                 return;
01079         if(!(o = find_entrance_by_xy(map, x, y)))
01080                 return;
01081         if(!(nmap = getMap(o->obj)))
01082                 return;
01083         if(!damage) {
01084                 if(!IsMissile(weapindx))
01085                         damage = MechWeapons[weapindx].damage;
01086                 else {
01087                         /* Missile weapon.  Multiple Hit locations... */
01088                         for(loop = 0; MissileHitTable[loop].key != -1; loop++)
01089                                 if(MissileHitTable[loop].key == weapindx)
01090                                         break;
01091                         if(!(MissileHitTable[loop].key == weapindx))
01092                                 return;
01093                         if((MechWeapons[weapindx].type == STREAK) &&
01094                            (!AngelECMDisturbed(mech)))
01095                                 num_missiles_hit = MissileHitTable[loop].num_missiles[10];
01096                         else {
01097                                 hit_roll = Roll() - 2;
01098                                 num_missiles_hit =
01099                                         MissileHitTable[loop].num_missiles[hit_roll];
01100                         }
01101                         damage = num_missiles_hit * MechWeapons[weapindx].damage;
01102                 }
01103         }
01104         if(!damage)
01105                 return;
01106         if(MapIsCS(map) || BuildIsCS(nmap)) {
01107                 mech_notify(mech, MECHALL, "Your shot only scratches the paint!");
01108                 return;
01109         }
01110         if(!get_building_cf(o->obj, &i1, &i2))
01111                 return;
01112         damage_cf(mech, o, i1, i2, damage);
01113 }

int is_blocked_lz ( MECH mech,
MAP map,
int  x,
int  y 
)

Definition at line 676 of file map.obj.c.

References mapobj_struct::datac, mapobj_struct::datai, FindHexRange(), first_mapobj(), MapCoordToRealCoord(), MechTeam, next_mapobj(), TYPE_B_LZ, mapobj_struct::x, and mapobj_struct::y.

Referenced by ImproperLZ().

00677 {
00678         mapobj *o;
00679         float fx, fy;
00680         float tx, ty;
00681 
00682         MapCoordToRealCoord(x, y, &fx, &fy);
00683         for(o = first_mapobj(map, TYPE_B_LZ); o; o = next_mapobj(o)) {
00684                 if(abs(x - o->x) > o->datai || abs(y - o->y) > o->datai)
00685                         continue;
00686                 if(o->datac && o->datac == MechTeam(mech))
00687                         continue;
00688                 MapCoordToRealCoord(o->x, o->y, &tx, &ty);
00689                 if(FindHexRange(fx, fy, tx, ty) <= o->datai)
00690                         return 1;
00691         }
00692         return 0;
00693 }

void list_mapobjs ( dbref  player,
MAP map 
)

Definition at line 585 of file map.obj.c.

References mapobj_struct::datac, mapobj_struct::datai, mapobj_struct::datas, first_mapobj(), map_types, next_mapobj(), notify, notify_printf(), NUM_MAPOBJTYPES, mapobj_struct::obj, TYPE_BITS, mapobj_struct::x, and mapobj_struct::y.

Referenced by map_listmechs().

00586 {
00587         mapobj *tmp;
00588         int i;
00589 
00590         notify(player, "X   Y   Type  obj   dc   ds     di");
00591         notify(player, "--------------------------------------------");
00592         for(i = 0; i < NUM_MAPOBJTYPES; i++)
00593                 for(tmp = first_mapobj(map, i); tmp; tmp = next_mapobj(tmp)) {
00594                         if(i == TYPE_BITS)
00595                                 notify(player, "--- MAP/HANGAR INFORMATION OBJECT ---");
00596                         else
00597                                 notify_printf(player, "%-3d %-3d %-5s %-5d %-4d %-6d %d",
00598                                                           tmp->x, tmp->y, map_types[i], (int) tmp->obj,
00599                                                           tmp->datac, tmp->datas, tmp->datai);
00600                 }
00601         notify(player, "--------------------------------------------");
00602 }

void load_mapobjs ( FILE *  f,
MAP map 
)

Definition at line 554 of file map.obj.c.

References add_mapobj(), map_load_bits(), MAP::mapobj, MAPOBJEND_MAGICNUM, MAPOBJSTART_MAGICNUM, NUM_MAPOBJTYPES, possibly_start_building_regen(), TYPE_BITS, and TYPE_BUILD.

Referenced by load_update1().

00555 {
00556         unsigned char tmpb;
00557         int i;
00558         mapobj tmp;
00559 
00560         fread(&tmpb, 1, 1, f);
00561         if(tmpb != MAPOBJSTART_MAGICNUM) {
00562                 fprintf(stderr, "Error: No mapobjstart found!");
00563                 return;
00564         }
00565         /* Clean out */
00566         for(i = 0; i < NUM_MAPOBJTYPES; i++)
00567                 map->mapobj[i] = NULL;
00568         fread(&tmpb, 1, 1, f);
00569         while (tmpb && !feof(f)) {
00570                 if((tmpb - 1) == TYPE_BITS)
00571                         map_load_bits(f, map);
00572                 else {
00573                         fread(&tmp, sizeof(mapobj), 1, f);
00574                         add_mapobj(map, &map->mapobj[tmpb - 1], &tmp, 0);
00575                         if((tmpb - 1) == TYPE_BUILD)
00576                                 possibly_start_building_regen(tmp.obj);
00577                 }
00578                 fread(&tmpb, 1, 1, f);
00579         }
00580         fread(&tmpb, 1, 1, f);
00581         if(tmpb != MAPOBJEND_MAGICNUM)
00582                 fprintf(stderr, "Error: No mapobjend found!");
00583 }

void map_add_block ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 644 of file map.obj.c.

References add_mapobj(), args, mapobj_struct::datac, mapobj_struct::datai, DOCHECK, MAP::mapobj, mech_parseattributes(), notify_printf(), mapobj_struct::obj, READINT, team, TYPE_B_LZ, mapobj_struct::x, x, mapobj_struct::y, and y.

00645 {
00646         char *args[4];
00647         int argc;
00648         int x, y, str;
00649         MAP *map = (MAP *) data;
00650         mapobj foo;
00651         int team = 0;
00652 
00653         if(!map)
00654                 return;
00655 #define READINT(from,to) \
00656     DOCHECK(Readnum(to,from), "Invalid number!")
00657         argc = mech_parseattributes(buffer, args, 4);
00658         DOCHECK(argc < 2 || argc > 4, "Invalid arguments!");
00659         READINT(args[0], x);
00660         READINT(args[1], y);
00661         READINT(args[2], str);
00662         if(argc == 4)
00663                 READINT(args[3], team);
00664         bzero(&foo, sizeof(mapobj));
00665         foo.x = x;
00666         foo.y = y;
00667         foo.datai = str;
00668         foo.obj = player;
00669         foo.datac = team;
00670         add_mapobj(map, &map->mapobj[TYPE_B_LZ], &foo, 1);
00671         notify_printf(player,
00672                                   "Landingzone-block added to %d,%d (distance: %d)", x, y,
00673                                   str);
00674 }

void map_addfire ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 604 of file map.obj.c.

References add_decoration(), args, FIRE, mech_parseattributes(), notify, notify_printf(), TYPE_FIRE, x, and y.

00605 {
00606         /* Entrance-checking code */
00607         MAP *map = (MAP *) data;
00608         char *args[4];
00609         int x, y, d;
00610 
00611         if(mech_parseattributes(buffer, args, 3) != 3) {
00612                 notify(player,
00613                            "Error: Invalid number of attributes to addfire command.");
00614                 return;
00615         }
00616         x = atoi(args[0]);
00617         y = atoi(args[1]);
00618         d = atoi(args[2]);
00619         add_decoration(map, x, y, TYPE_FIRE, FIRE, d);
00620         notify_printf(player, "Added: Fire at (%d,%d) with duration of %ds.",
00621                                   x, y, d);
00622 }

void map_addsmoke ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 624 of file map.obj.c.

References add_decoration(), args, mech_parseattributes(), notify, notify_printf(), SMOKE, TYPE_SMOKE, x, and y.

00625 {
00626         MAP *map = (MAP *) data;
00627         char *args[4];
00628         int x, y, d;
00629 
00630         if(mech_parseattributes(buffer, args, 3) != 3) {
00631                 notify(player,
00632                            "Error: Invalid number of attributes to addsmoke command.");
00633                 return;
00634         }
00635         x = atoi(args[0]);
00636         y = atoi(args[1]);
00637         d = atoi(args[2]);
00638         add_decoration(map, x, y, TYPE_SMOKE, SMOKE, d);
00639         notify_printf(player, "Added: Smoke at (%d,%d) with duration of %ds.",
00640                                   x, y, d);
00641 }

void map_delobj ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 721 of file map.obj.c.

References args, del_mapobj(), DOCHECK, first_mapobj(), listmatch(), map_types, MAP::mapobj, mech_parseattributes(), next_mapobj(), notify, notify_printf(), NUM_MAPOBJTYPES, TYPE_MINE, mapobj_struct::x, x, mapobj_struct::y, and y.

00722 {
00723         MAP *map = (MAP *) data;
00724         char *args[5];
00725         mapobj *foo, *foo2;
00726         int tt, count = 0, mdel = 0;
00727         int x, y;
00728 
00729         switch (mech_parseattributes(buffer, args, 3)) {
00730         case 0:
00731                 notify(player,
00732                            "Error: Invalid number of attributes to delobj command.");   
00733                 return;
00734         case 1:
00735                 DOCHECK((tt = listmatch(map_types, args[0])) < 0, "Invalid type!");
00736                 for(foo = map->mapobj[tt]; foo; foo = foo2) {
00737                         foo2 = next_mapobj(foo);
00738                         del_mapobj(map, foo, tt, 1);
00739                         count++;
00740                 }
00741                 notify_printf(player, "%d objects deleted!", count);
00742                 if(tt == TYPE_MINE)
00743                         mdel = 1;
00744                 break;
00745         case 2:
00746                 x = atoi(args[0]);
00747                 y = atoi(args[1]);
00748                 for(tt = 0; tt < NUM_MAPOBJTYPES; tt++)
00749                         for(foo = first_mapobj(map, tt); foo; foo = foo2) {
00750                                 foo2 = next_mapobj(foo);
00751                                 if(foo->x == x && foo->y == y) {
00752                                         if(tt == TYPE_MINE)
00753                                                 mdel = 1;
00754                                         del_mapobj(map, foo, tt, 1);
00755                                         count++;
00756                                 }
00757                         }
00758                 notify_printf(player, "%d objects at (%d,%d) deleted.", count, x, y);
00759                 break;
00760         case 3:
00761                 DOCHECK((tt = listmatch(map_types, args[0])) < 0, "Invalid type!");
00762                 x = atoi(args[1]);
00763                 y = atoi(args[2]);
00764                 for(foo = first_mapobj(map, tt); foo; foo = foo2) {
00765                         foo2 = next_mapobj(foo);
00766                         if(foo->x == x && foo->y == y) {
00767                                 if(tt == TYPE_MINE)
00768                                         mdel = 1;
00769                                 del_mapobj(map, foo, tt, 1);
00770                                 count++;
00771                         }
00772                 }
00773                 notify_printf(player, "%d %s at (%d,%d) deleted.", count,
00774                                           map_types[tt], x, y);
00775                 break;
00776         default:
00777                 notify(player, "Invalid number of arguments!");
00778                 return;
00779         }
00780         if(mdel)
00781                 recalculate_minefields(map);
00782 }

int map_linked ( dbref  mapobj  ) 

Definition at line 948 of file map.obj.c.

References first_mapobj(), getMap(), and TYPE_LINKED.

Referenced by CheckEdgeOfMap().

00949 {
00950         MAP *map = getMap(mapobj);
00951 
00952         if(!map)
00953                 return 0;
00954         return (first_mapobj(map, TYPE_LINKED)) ? 1 : 0;
00955 }

void map_setlinked ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 695 of file map.obj.c.

References add_mapobj(), mapobj_struct::datac, MAP::mapobj, notify_printf(), and TYPE_LINKED.

00696 {
00697         MAP *map = (MAP *) data;
00698         mapobj foo;
00699 
00700         bzero(&foo, sizeof(mapobj));
00701         foo.datac = 1;
00702         add_mapobj(map, &map->mapobj[TYPE_LINKED], &foo, 1);
00703         notify_printf(player, "Map set to linked.");
00704 }

int map_underlying_terrain ( MAP map,
int  x,
int  y 
)

Definition at line 1213 of file map.obj.c.

References c, find_decorations(), and GetTerrain.

01214 {
01215         char c;
01216 
01217         if(!map)
01218                 return 0;
01219         c = find_decorations(map, x, y);
01220         if(c)
01221                 return c;
01222         return GetTerrain(map, x, y);
01223 }

void map_updatelinks ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 936 of file map.obj.c.

References Location, NOTHING, notify_printf(), recursively_updatelinks(), and update_stats.

00937 {
00938         dbref ourloc;
00939 
00940         ourloc = Location(player);
00941         bzero(update_stats, sizeof(update_stats));
00942         recursively_updatelinks(NOTHING, ourloc);
00943         notify_printf(player,
00944                                   "Updated %d BUILD objs, %d LEAVE objs, %d ENTRANCE objs.",
00945                                   update_stats[0], update_stats[1], update_stats[2]);
00946 }

int mapobj_del ( MAP map,
int  x,
int  y,
int  tt 
)

Definition at line 706 of file map.obj.c.

References del_mapobj(), first_mapobj(), next_mapobj(), mapobj_struct::x, and mapobj_struct::y.

Referenced by make_mine_explode(), and possibly_remove_mines().

00707 {
00708         int count = 0;
00709         mapobj *foo, *foo2;
00710 
00711         for(foo = first_mapobj(map, tt); foo; foo = foo2) {
00712                 foo2 = next_mapobj(foo);
00713                 if(foo->x == x && foo->y == y) {
00714                         del_mapobj(map, foo, tt, 1);
00715                         count++;
00716                 }
00717         }
00718         return count;
00719 }

int mech_underlying_terrain ( MECH mech  ) 

Definition at line 1225 of file map.obj.c.

References c, find_decorations(), FindObjectsData(), MECH::mapindex, MechTerrain, MechX, and MechY.

01226 {
01227         char c;
01228         MAP *map = FindObjectsData(mech->mapindex);
01229 
01230         if(!map)
01231                 return MechTerrain(mech);
01232         c = find_decorations(map, MechX(mech), MechY(mech));
01233         if(c)
01234                 return c;
01235         return MechTerrain(mech);
01236 }

mapobj* next_mapobj ( mapobj m  ) 

Definition at line 35 of file map.obj.c.

References mapobj_struct::next.

Referenced by add_decoration(), find_decorations(), find_entrance(), find_entrance_by_target(), find_entrance_by_xy(), find_mapobj(), fun_bthexinblz(), fun_btlistblz(), is_blocked_lz(), list_mapobjs(), litemark_map(), map_delobj(), mapobj_del(), and obj_size().

00036 {
00037         return m->next;
00038 }

int obj_size ( MAP map  ) 

Definition at line 1200 of file map.obj.c.

References first_mapobj(), MAP::mapobj, next_mapobj(), and NUM_MAPOBJTYPES.

Referenced by debug_check_stuff().

01201 {
01202         int s = 0;
01203         mapobj *m;
01204         int i;
01205 
01206         for(i = 0; i < NUM_MAPOBJTYPES; i++)
01207                 if(map->mapobj[i])
01208                         for(m = first_mapobj(map, i); m; m = next_mapobj(m))
01209                                 s += sizeof(mapobj);
01210         return s;
01211 }

int parse_coord ( MAP map,
int  dir,
char *  data,
int *  x,
int *  y 
)

Definition at line 801 of file map.obj.c.

References dirtable, MAP::map_height, and MAP::map_width.

Referenced by add_entrances().

00802 {
00803         int tx, ty, tox, toy;
00804         int doh;
00805 
00806         if(strchr(data, ',')) {
00807                 if(sscanf(data, "%d,%d", x, y) == 2)
00808                         return 1;
00809                 return 0;
00810         }
00811         doh = atoi(data);
00812         if(doh < 0)
00813                 return 0;
00814         tox = dirtable[dir].x;
00815         toy = dirtable[dir].y;
00816         tx = (map->map_width * tox) / 2;
00817         if(tx >= map->map_width)
00818                 tx = map->map_width - 1;
00819         ty = (map->map_height * toy) / 2;
00820         if(ty >= map->map_height)
00821                 ty = map->map_height - 1;
00822         if(tox == 1)
00823                 ty += (toy > 1) ? (0 - doh) : (doh);
00824         if(toy == 1)
00825                 tx += (tox > 1) ? (0 - doh) : (doh);
00826         if(tx < 0)
00827                 tx = 0;
00828         if(ty < 0)
00829                 ty = 0;
00830         if(tx >= map->map_width)
00831                 tx = (map->map_width - 1);
00832         if(ty >= map->map_height)
00833                 ty = (map->map_height - 1);
00834         *x = tx;
00835         *y = ty;
00836         return 1;
00837 }

void possibly_start_building_regen ( dbref  obj  ) 

Definition at line 1018 of file map.obj.c.

References BUILDING_DREBUILD_DELAY, building_rebuild_event(), building_regen_event(), BUILDING_REPAIR_DELAY, EVENT_BREBUILD, EVENT_BREGEN, get_building_cf(), and OBJEVENT.

Referenced by damage_cf(), and load_mapobjs().

01019 {
01020         int f, t;
01021 
01022         if(!get_building_cf(obj, &f, &t))
01023                 return;
01024         if(f == t)
01025                 return;
01026         if(!f)
01027                 OBJEVENT(obj, EVENT_BREBUILD, building_rebuild_event,
01028                                  BUILDING_DREBUILD_DELAY, NULL);
01029         else
01030                 OBJEVENT(obj, EVENT_BREGEN, building_regen_event,
01031                                  BUILDING_REPAIR_DELAY, NULL);
01032 }

void recursively_updatelinks ( dbref  from,
dbref  loc 
)

void save_mapobjs ( FILE *  f,
MAP map 
)

Definition at line 45 of file map.obj.c.

References map_save_bits(), MAP::mapobj, MAPOBJSTART_MAGICNUM, NUM_MAPOBJTYPES, outbyte, and TYPE_BITS.

Referenced by save_maps_func().

00046 {
00047 #define outbyte(a) tmpb=(a);fwrite(&tmpb, 1, 1, f);
00048         int i;
00049         unsigned char tmpb;
00050         mapobj *tmp;
00051 
00052         outbyte(MAPOBJSTART_MAGICNUM);
00053         for(i = 0; i < NUM_MAPOBJTYPES; i++)
00054                 if(map->mapobj[i]) {
00055                         if(i == TYPE_BITS) {
00056                                 tmp = map->mapobj[i];
00057                                 map_save_bits(f, map, tmp);
00058                         } else
00059                                 for(tmp = map->mapobj[i]; tmp; tmp = tmp->next) {
00060                                         outbyte(i + 1);
00061                                         fwrite(tmp, sizeof(mapobj), 1, f);
00062                                 }
00063                 }
00064         outbyte(0);
00065         outbyte(MAPOBJEND_MAGICNUM);
00066 }

void show_building_in_hex ( MECH mech,
int  x,
int  y 
)

Definition at line 1164 of file map.obj.c.

References BuildIsHidden, BuildIsInvis, MAP::cf, find_entrance_by_xy(), FindRange(), getMap(), MadePerceptionRoll(), MECH::mapindex, mech_notify(), mech_printf(), MECHALL, MechX, MechY, MechZ, MyToUpper(), mapobj_struct::obj, and structure_name().

Referenced by mech_scan().

01165 {
01166         mapobj *o;
01167         MAP *map;
01168         MAP *nmap;
01169 
01170         if(!(map = getMap(mech->mapindex))) {
01171                 mech_notify(mech, MECHALL,
01172                                         "The sensors detect no building in the hex!");
01173                 return;
01174         }
01175         if(!(o = find_entrance_by_xy(map, x, y))) {
01176                 mech_notify(mech, MECHALL,
01177                                         "The sensors detect no building in the hex!");
01178                 return;
01179         }
01180         if(!(nmap = getMap(o->obj))) {
01181                 mech_notify(mech, MECHALL,
01182                                         "The sensors detect no building in the hex!");
01183                 return;
01184         }
01185         if(BuildIsInvis(nmap) || (BuildIsHidden(nmap) &&
01186                                                           !MadePerceptionRoll(mech,
01187                                                                                                   (int) (FindRange
01188                                                                                                                  (MechX(mech),
01189                                                                                                                   MechY(mech),
01190                                                                                                                   MechZ(mech), x, y,
01191                                                                                                                   0) + 0.95)))) {
01192                 mech_notify(mech, MECHALL,
01193                                         "The sensors detect no building in the hex!");
01194                 return;
01195         }
01196         mech_printf(mech, MECHALL, "%s's CF is %d.",
01197                                 MyToUpper(structure_name(o)), nmap->cf);
01198 }

void steppable_base_check ( MECH mech,
int  x,
int  y 
)

Definition at line 1139 of file map.obj.c.

References BuildIsHidden, BuildIsInvis, MAP::cf, Elevation, find_entrance_by_xy(), getMap(), is_hangar_hex(), MadePerceptionRoll(), MECH::mapindex, mech_printf(), MECHALL, MechZ, MyToUpper(), mapobj_struct::obj, and structure_name().

Referenced by move_mech().

01140 {
01141         mapobj *o;
01142         MAP *map;
01143         MAP *nmap;
01144 
01145         map = getMap(mech->mapindex);
01146         if(!map)
01147                 return;
01148         if(MechZ(mech) != Elevation(map, x, y))
01149                 return;
01150         if(!(is_hangar_hex(map, x, y)))
01151                 return;
01152         if(!(o = find_entrance_by_xy(map, x, y)))
01153                 return;
01154         if(!(nmap = getMap(o->obj)))
01155                 return;
01156         if(BuildIsInvis(nmap))
01157                 return;
01158         if(BuildIsHidden(nmap) && !MadePerceptionRoll(mech, 0))
01159                 return;
01160         mech_printf(mech, MECHALL, "%s has CF of %d.",
01161                                 MyToUpper(structure_name(o)), nmap->cf);
01162 }

char* structure_name ( mapobj mapo  ) 

Definition at line 81 of file map.obj.c.

References MBUF_SIZE, Name(), and mapobj_struct::obj.

Referenced by damage_cf(), Leave_Hangar(), mech_enter_event(), show_building_in_hex(), and steppable_base_check().

00082 {
00083         static char buf[MBUF_SIZE];
00084 
00085         sprintf(buf, "the %s", Name(mapo->obj));
00086         return buf;
00087 }


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