Fixed a problem with direct scenery access in C-API

This commit is contained in:
Michaël Lemaire 2013-10-29 21:38:27 +01:00
parent ce56f0a985
commit 00cbc7f424
2 changed files with 13 additions and 3 deletions

View file

@ -233,7 +233,14 @@ void sceneryGetTerrain(TerrainDefinition* terrain)
TerrainDefinition* sceneryGetTerrainDirect()
{
return _main_scenery->getTerrain();
if (_main_scenery)
{
return _main_scenery->getTerrain();
}
else
{
return NULL;
}
}
void scenerySetTextures(TexturesDefinition* textures)

View file

@ -71,8 +71,11 @@ static void _layerValidateDefinition(TexturesLayerDefinition* definition)
/* Update zone height range */
TerrainDefinition* terrain = sceneryGetTerrainDirect();
HeightInfo height_info = terrainGetHeightInfo(terrain);
zoneSetRelativeHeight(definition->terrain_zone, height_info.min_height, height_info.base_height, height_info.max_height);
if (terrain)
{
HeightInfo height_info = terrainGetHeightInfo(terrain);
zoneSetRelativeHeight(definition->terrain_zone, height_info.min_height, height_info.base_height, height_info.max_height);
}
}
static TexturesLayerDefinition* _layerCreateDefinition()