TileManager::get(unsigned int id)
{
Tiles::iterator i = tiles.find(id);
-
if(i == tiles.end())
- {
- std::cerr << "Warning: Asked for a non-existing tile id. Ignoring.\n";
- // Never return 0, but return the first tile instead so that
- // user code doesn't have to check for NULL pointers all over
- // the place
- i = tiles.begin();
- return i->second;
- }
+ return 0;
return i->second;
}
int tx, ty;
for(pos.x = start_x, tx = tsx; pos.x < end_x; pos.x += 32, ++tx) {
for(pos.y = start_y, ty = tsy; pos.y < end_y; pos.y += 32, ++ty) {
+ if(tx < 0 || tx > width || ty < 0 || ty > height)
+ continue; // outside tilemap
if (!tiles[ty*width + tx].hidden)
tilemanager->draw_tile(context, tiles[ty*width + tx].id, pos, layer);
}
int tx, ty;
for(pos.x = start_x, tx = tsx; pos.x < end_x; pos.x += 32, ++tx) {
for(pos.y = start_y, ty = tsy; pos.y < end_y; pos.y += 32, ++ty) {
+ if(tx < 0 || tx > width || ty < 0 || ty > height)
+ continue; // outside tilemap
if (!tiles[ty*width + tx].hidden)
tilemanager->draw_tile(context, tiles[ty*width + tx].id, pos, layer);
}