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.117 by root, Fri Aug 24 00:26:09 2007 UTC vs.
Revision 1.121 by root, Sat Aug 25 22:19:26 2007 UTC

383 if (!spaces) 383 if (!spaces)
384 return false; 384 return false;
385 385
386 for (int i = 0; i < size (); ++i) 386 for (int i = 0; i < size (); ++i)
387 { 387 {
388 int unique = 0; 388 bool unique = 0;
389
389 for (object *op = spaces [i].bot; op; op = op->above) 390 for (object *op = spaces [i].bot; op; op = op->above)
390 { 391 {
391 if (op->flag [FLAG_UNIQUE] && op->flag [FLAG_IS_FLOOR]) 392 unique |= op->flag [FLAG_UNIQUE] && op->flag [FLAG_IS_FLOOR];
392 unique = 1;
393 393
394 if (!op->can_map_save ()) 394 if (expect_false (!op->can_map_save ()))
395 continue; 395 continue;
396 396
397 if (unique || op->flag [FLAG_UNIQUE]) 397 if (expect_false (unique || op->flag [FLAG_UNIQUE]))
398 { 398 {
399 if (flags & IO_UNIQUES) 399 if (flags & IO_UNIQUES)
400 op->write (f); 400 op->write (f);
401 } 401 }
402 else if (flags & IO_OBJECTS) 402 else if (expect_true (flags & IO_OBJECTS))
403 op->write (f); 403 op->write (f);
404 } 404 }
405 } 405 }
406 406
407 coroapi::cede_to_tick (); 407 coroapi::cede_to_tick ();
1227} 1227}
1228 1228
1229bool 1229bool
1230maptile::tile_available (int dir, bool load) 1230maptile::tile_available (int dir, bool load)
1231{ 1231{
1232 if (!tile_path[dir])
1233 return 0;
1234
1232 if (tile_map[dir] && (!load || tile_map[dir]->in_memory == MAP_IN_MEMORY)) 1235 if (tile_map[dir] && (!load || tile_map[dir]->in_memory == MAP_IN_MEMORY))
1233 return 1; 1236 return 1;
1234
1235 if (!tile_path[dir])
1236 return 0;
1237 1237
1238 if ((tile_map[dir] = find_async (tile_path[dir], this, load))) 1238 if ((tile_map[dir] = find_async (tile_path[dir], this, load)))
1239 return 1; 1239 return 1;
1240 1240
1241 return 0; 1241 return 0;
1259 if (!m) 1259 if (!m)
1260 return 0; 1260 return 0;
1261 1261
1262 if (x < 0) 1262 if (x < 0)
1263 { 1263 {
1264 if (!m->tile_available (3, 0)) 1264 if (!m->tile_available (3))
1265 return 1; 1265 return 1;
1266 1266
1267 return out_of_map (m->tile_map[3], x + m->tile_map[3]->width, y); 1267 return out_of_map (m->tile_map[3], x + m->tile_map[3]->width, y);
1268 } 1268 }
1269 1269
1270 if (x >= m->width) 1270 if (x >= m->width)
1271 { 1271 {
1272 if (!m->tile_available (1, 0)) 1272 if (!m->tile_available (1))
1273 return 1; 1273 return 1;
1274 1274
1275 return out_of_map (m->tile_map[1], x - m->width, y); 1275 return out_of_map (m->tile_map[1], x - m->width, y);
1276 } 1276 }
1277 1277
1278 if (y < 0) 1278 if (y < 0)
1279 { 1279 {
1280 if (!m->tile_available (0, 0)) 1280 if (!m->tile_available (0))
1281 return 1; 1281 return 1;
1282 1282
1283 return out_of_map (m->tile_map[0], x, y + m->tile_map[0]->height); 1283 return out_of_map (m->tile_map[0], x, y + m->tile_map[0]->height);
1284 } 1284 }
1285 1285
1286 if (y >= m->height) 1286 if (y >= m->height)
1287 { 1287 {
1288 if (!m->tile_available (2, 0)) 1288 if (!m->tile_available (2))
1289 return 1; 1289 return 1;
1290 1290
1291 return out_of_map (m->tile_map[2], x, y - m->height); 1291 return out_of_map (m->tile_map[2], x, y - m->height);
1292 } 1292 }
1293 1293
1308maptile * 1308maptile *
1309maptile::xy_find (sint16 &x, sint16 &y) 1309maptile::xy_find (sint16 &x, sint16 &y)
1310{ 1310{
1311 if (x < 0) 1311 if (x < 0)
1312 { 1312 {
1313 if (!tile_available (3, 1)) 1313 if (!tile_available (3))
1314 return 0; 1314 return 0;
1315 1315
1316 x += tile_map[3]->width; 1316 x += tile_map[3]->width;
1317 return tile_map[3]->xy_find (x, y); 1317 return tile_map[3]->xy_find (x, y);
1318 } 1318 }
1319 1319
1320 if (x >= width) 1320 if (x >= width)
1321 { 1321 {
1322 if (!tile_available (1, 1)) 1322 if (!tile_available (1))
1323 return 0; 1323 return 0;
1324 1324
1325 x -= width; 1325 x -= width;
1326 return tile_map[1]->xy_find (x, y); 1326 return tile_map[1]->xy_find (x, y);
1327 } 1327 }
1328 1328
1329 if (y < 0) 1329 if (y < 0)
1330 { 1330 {
1331 if (!tile_available (0, 1)) 1331 if (!tile_available (0))
1332 return 0; 1332 return 0;
1333 1333
1334 y += tile_map[0]->height; 1334 y += tile_map[0]->height;
1335 return tile_map[0]->xy_find (x, y); 1335 return tile_map[0]->xy_find (x, y);
1336 } 1336 }
1337 1337
1338 if (y >= height) 1338 if (y >= height)
1339 { 1339 {
1340 if (!tile_available (2, 1)) 1340 if (!tile_available (2))
1341 return 0; 1341 return 0;
1342 1342
1343 y -= height; 1343 y -= height;
1344 return tile_map[2]->xy_find (x, y); 1344 return tile_map[2]->xy_find (x, y);
1345 } 1345 }
1358adjacent_map (const maptile *map1, const maptile *map2, int *dx, int *dy) 1358adjacent_map (const maptile *map1, const maptile *map2, int *dx, int *dy)
1359{ 1359{
1360 if (!map1 || !map2) 1360 if (!map1 || !map2)
1361 return 0; 1361 return 0;
1362 1362
1363 //TODO: this doesn't actually check corretcly when intermediate maps are not loaded 1363 //TODO: this doesn't actually check correctly when intermediate maps are not loaded
1364 //fix: compare paths instead (this is likely faster, too!) 1364 //fix: compare paths instead (this is likely faster, too!)
1365 if (map1 == map2) 1365 if (map1 == map2)
1366 { 1366 {
1367 *dx = 0; 1367 *dx = 0;
1368 *dy = 0; 1368 *dy = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines