ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/map.C
(Generate patch)

Comparing deliantra/server/common/map.C (file contents):
Revision 1.211 by root, Sat May 7 14:13:48 2011 UTC vs.
Revision 1.213 by root, Sat May 7 20:03:27 2011 UTC

671 case KW_value: case KW_swap_time: thawer.get (timeout); break; 671 case KW_value: case KW_swap_time: thawer.get (timeout); break;
672 case KW_level: case KW_difficulty: thawer.get (difficulty); difficulty = clamp (difficulty, 1, settings.max_level); break; 672 case KW_level: case KW_difficulty: thawer.get (difficulty); difficulty = clamp (difficulty, 1, settings.max_level); break;
673 case KW_invisible: case KW_darkness: thawer.get (darkness); break; 673 case KW_invisible: case KW_darkness: thawer.get (darkness); break;
674 case KW_stand_still: case KW_fixed_resettime: thawer.get (fixed_resettime); break; 674 case KW_stand_still: case KW_fixed_resettime: thawer.get (fixed_resettime); break;
675 675
676 case KW_tile_path_1: thawer.get (tile_path [0]); break; 676 case KW_tile_path_1: thawer.get (tile_path [TILE_NORTH]); break;
677 case KW_tile_path_2: thawer.get (tile_path [1]); break; 677 case KW_tile_path_2: thawer.get (tile_path [TILE_EAST ]); break;
678 case KW_tile_path_3: thawer.get (tile_path [2]); break; 678 case KW_tile_path_3: thawer.get (tile_path [TILE_SOUTH]); break;
679 case KW_tile_path_4: thawer.get (tile_path [3]); break; 679 case KW_tile_path_4: thawer.get (tile_path [TILE_WEST ]); break;
680 case KW_tile_path_5: thawer.get (tile_path [4]); break; 680 case KW_tile_path_5: thawer.get (tile_path [TILE_UP ]); break;
681 case KW_tile_path_6: thawer.get (tile_path [5]); break; 681 case KW_tile_path_6: thawer.get (tile_path [TILE_DOWN ]); break;
682 682
683 case KW_ERROR: 683 case KW_ERROR:
684 set_key_text (thawer.kw_str, thawer.value); 684 set_key_text (thawer.kw_str, thawer.value);
685 break; 685 break;
686 686
765 if (maplore) freezer.put (KW(maplore), KW(endmaplore), maplore); 765 if (maplore) freezer.put (KW(maplore), KW(endmaplore), maplore);
766 766
767 MAP_OUT (per_player); 767 MAP_OUT (per_player);
768 MAP_OUT (per_party); 768 MAP_OUT (per_party);
769 769
770 if (tile_path [0]) MAP_OUT2 (tile_path_1, tile_path [0]); 770 if (tile_path [TILE_NORTH]) MAP_OUT2 (tile_path_1, tile_path [TILE_NORTH]);
771 if (tile_path [1]) MAP_OUT2 (tile_path_2, tile_path [1]); 771 if (tile_path [TILE_EAST ]) MAP_OUT2 (tile_path_2, tile_path [TILE_EAST ]);
772 if (tile_path [2]) MAP_OUT2 (tile_path_3, tile_path [2]); 772 if (tile_path [TILE_SOUTH]) MAP_OUT2 (tile_path_3, tile_path [TILE_SOUTH]);
773 if (tile_path [3]) MAP_OUT2 (tile_path_4, tile_path [3]); 773 if (tile_path [TILE_WEST ]) MAP_OUT2 (tile_path_4, tile_path [TILE_WEST ]);
774 if (tile_path [4]) MAP_OUT2 (tile_path_5, tile_path [4]); 774 if (tile_path [TILE_UP ]) MAP_OUT2 (tile_path_5, tile_path [TILE_UP ]);
775 if (tile_path [5]) MAP_OUT2 (tile_path_6, tile_path [5]); 775 if (tile_path [TILE_DOWN ]) MAP_OUT2 (tile_path_6, tile_path [TILE_DOWN ]);
776 776
777 freezer.put (this); 777 freezer.put (this);
778 freezer.put (KW(end)); 778 freezer.put (KW(end));
779 779
780 return true; 780 return true;
1195 middle = 0; 1195 middle = 0;
1196 1196
1197 if (top == middle) 1197 if (top == middle)
1198 middle = 0; 1198 middle = 0;
1199 1199
1200 // dire hack to handle "transparent" floors - currently only open_space 1200 // set lower map transparent floor flag if applicable
1201 if (floor && floor->arch->archname == shstr_quad_open_space) 1201 if (floor && floor->flag [FLAG_IS_TRANSPARENT_FLOOR] && !middle && !top)
1202 { 1202 {
1203 floor->set_anim_frame (0); 1203 floor->set_anim_frame (0);
1204 1204
1205 if (maptile *m = floor->map->tile_map [TILE_DOWN]) 1205 if (maptile *m = floor->map->tile_map [TILE_DOWN])
1206 { 1206 {
1207 // mirror the floor - very unreliable because usually outdated,
1208 // but somewhta works because floors do not change often :/
1209 mapspace &ms = m->at (floor->x, floor->y); 1207 mapspace &ms = m->at (floor->x, floor->y);
1210 ms.update (); 1208 ms.update ();
1211 1209
1212 if (object *floor2 = ms.faces_obj [2]) 1210 if (object *floor2 = ms.faces_obj [2])
1213 if (floor2->arch->archname != shstr_quad_open_space && !middle) 1211 if (!floor2->flag [FLAG_IS_TRANSPARENT_FLOOR])
1214 { 1212 {
1215 floor->set_anim_frame (1); 1213 floor->set_anim_frame (1);
1216 middle = floor; 1214 top = floor;
1215 middle = ms.faces_obj [0];
1217 floor = floor2; 1216 floor = floor2;
1218 } 1217 }
1218
1219 ms.pflags |= PF_VIS_UP;
1219 } 1220 }
1220 } 1221 }
1221 1222
1222#if 0 1223#if 0
1223 faces_obj [0] = top; 1224 faces_obj [0] = top;
1224 faces_obj [1] = middle; 1225 faces_obj [1] = middle;
1225 faces_obj [2] = floor; 1226 faces_obj [2] = floor;
1226#endif 1227#endif
1227} 1228}
1228 1229
1230void
1231mapspace::update_up ()
1232{
1233 // invalidate up
1234 if (!(pflags & PF_VIS_UP))
1235 return;
1236
1237 pflags &= ~PF_VIS_UP;
1238
1239 if (bot)
1240 if (maptile *m = bot->map->tile_map [TILE_UP])
1241 m->at (bot->x, bot->y).invalidate ();
1242}
1243
1229maptile * 1244maptile *
1230maptile::tile_available (int dir, bool load) 1245maptile::tile_available (int dir, bool load)
1231{ 1246{
1232 if (tile_path[dir])
1233 {
1234 // map is there and we don't need to load it OR it's loaded => return what we have 1247 // map is there and we don't need to load it OR it's loaded => return what we have
1235 if (tile_map[dir] && (!load || tile_map[dir]->linkable ())) 1248 if (tile_map [dir] && (!load || tile_map [dir]->linkable ()))
1236 return tile_map[dir]; 1249 return tile_map [dir];
1237 1250
1251 if (tile_path [dir])
1252 {
1238 // well, try to locate it then, if possible - maybe it's there already 1253 // well, try to locate it then, if possible - maybe it's there already
1239 if ((tile_map[dir] = find_async (tile_path[dir], this, load))) 1254 if (maptile *m = find_async (tile_path [dir], this, load))
1255 {
1256 bool match = true;
1257
1258 if (dir == TILE_NORTH || dir == TILE_SOUTH || dir == TILE_UP || dir == TILE_DOWN)
1259 if (width != m->width)
1260 match = false;
1261
1262 if (dir == TILE_EAST || dir == TILE_WEST || dir == TILE_UP || dir == TILE_DOWN)
1263 if (height != m->height)
1264 match = false;
1265
1266 if (!match)
1267 {
1268 LOG (llevError, "tile dimension mismatch for direction %d from %s to %s\n",
1269 dir, &path, &m->path);
1270 m = 0;
1271 }
1272
1273 // this could be optimised endlessly
1274 //m->activate_physics ();
1275
1240 return tile_map[dir]; 1276 return tile_map [dir] = m;
1277 }
1241 } 1278 }
1242 1279
1243 return 0; 1280 return 0;
1244} 1281}
1245 1282
1261 if (!m) 1298 if (!m)
1262 return 0; 1299 return 0;
1263 1300
1264 if (x < 0) 1301 if (x < 0)
1265 { 1302 {
1266 if (!m->tile_available (3)) 1303 if (!m->tile_available (TILE_WEST))
1267 return 1; 1304 return 1;
1268 1305
1269 return out_of_map (m->tile_map[3], x + m->tile_map[3]->width, y); 1306 return out_of_map (m->tile_map [TILE_WEST], x + m->tile_map [TILE_WEST]->width, y);
1270 } 1307 }
1271 1308
1272 if (x >= m->width) 1309 if (x >= m->width)
1273 { 1310 {
1274 if (!m->tile_available (1)) 1311 if (!m->tile_available (TILE_EAST))
1275 return 1; 1312 return 1;
1276 1313
1277 return out_of_map (m->tile_map[1], x - m->width, y); 1314 return out_of_map (m->tile_map [TILE_EAST], x - m->width, y);
1278 } 1315 }
1279 1316
1280 if (y < 0) 1317 if (y < 0)
1281 { 1318 {
1282 if (!m->tile_available (0)) 1319 if (!m->tile_available (TILE_NORTH))
1283 return 1; 1320 return 1;
1284 1321
1285 return out_of_map (m->tile_map[0], x, y + m->tile_map[0]->height); 1322 return out_of_map (m->tile_map [TILE_NORTH], x, y + m->tile_map [TILE_NORTH]->height);
1286 } 1323 }
1287 1324
1288 if (y >= m->height) 1325 if (y >= m->height)
1289 { 1326 {
1290 if (!m->tile_available (2)) 1327 if (!m->tile_available (TILE_SOUTH))
1291 return 1; 1328 return 1;
1292 1329
1293 return out_of_map (m->tile_map[2], x, y - m->height); 1330 return out_of_map (m->tile_map [TILE_SOUTH], x, y - m->height);
1294 } 1331 }
1295 1332
1296 /* Simple case - coordinates are within this local 1333 /* Simple case - coordinates are within this local
1297 * map. 1334 * map.
1298 */ 1335 */
1310maptile * 1347maptile *
1311maptile::xy_find (sint16 &x, sint16 &y) 1348maptile::xy_find (sint16 &x, sint16 &y)
1312{ 1349{
1313 if (x < 0) 1350 if (x < 0)
1314 { 1351 {
1315 if (!tile_available (3)) 1352 if (!tile_available (TILE_WEST))
1316 return 0; 1353 return 0;
1317 1354
1318 x += tile_map[3]->width; 1355 x += tile_map [TILE_WEST]->width;
1319 return tile_map[3]->xy_find (x, y); 1356 return tile_map [TILE_WEST]->xy_find (x, y);
1320 } 1357 }
1321 1358
1322 if (x >= width) 1359 if (x >= width)
1323 { 1360 {
1324 if (!tile_available (1)) 1361 if (!tile_available (TILE_EAST))
1325 return 0; 1362 return 0;
1326 1363
1327 x -= width; 1364 x -= width;
1328 return tile_map[1]->xy_find (x, y); 1365 return tile_map [TILE_EAST]->xy_find (x, y);
1329 } 1366 }
1330 1367
1331 if (y < 0) 1368 if (y < 0)
1332 { 1369 {
1333 if (!tile_available (0)) 1370 if (!tile_available (TILE_NORTH))
1334 return 0; 1371 return 0;
1335 1372
1336 y += tile_map[0]->height; 1373 y += tile_map [TILE_NORTH]->height;
1337 return tile_map[0]->xy_find (x, y); 1374 return tile_map [TILE_NORTH]->xy_find (x, y);
1338 } 1375 }
1339 1376
1340 if (y >= height) 1377 if (y >= height)
1341 { 1378 {
1342 if (!tile_available (2)) 1379 if (!tile_available (TILE_SOUTH))
1343 return 0; 1380 return 0;
1344 1381
1345 y -= height; 1382 y -= height;
1346 return tile_map[2]->xy_find (x, y); 1383 return tile_map [TILE_SOUTH]->xy_find (x, y);
1347 } 1384 }
1348 1385
1349 /* Simple case - coordinates are within this local 1386 /* Simple case - coordinates are within this local
1350 * map. 1387 * map.
1351 */ 1388 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines