Require level 3 both for water & magma, and indicate level 5 by brightness.

develop
Alexander Gavrilov 2012-09-02 18:57:10 +04:00
parent 3b08ee44d1
commit 2249cb14fa
1 changed files with 23 additions and 16 deletions

@ -234,7 +234,7 @@ struct workshop_hook : df::building_workshopst {
// Find liquids to consume below the engine. // Find liquids to consume below the engine.
bool find_liquids(df::coord *pwater, df::coord *pmagma, bool is_magma, bool any_level) bool find_liquids(df::coord *pwater, df::coord *pmagma, bool is_magma, int min_level)
{ {
if (!is_magma) if (!is_magma)
pmagma = NULL; pmagma = NULL;
@ -252,23 +252,18 @@ struct workshop_hook : df::building_workshopst {
continue; continue;
auto pldes = Maps::getTileDesignation(x,y,z-1); auto pldes = Maps::getTileDesignation(x,y,z-1);
if (!pldes || pldes->bits.flow_size == 0) if (!pldes || pldes->bits.flow_size < min_level)
continue; continue;
if (pldes->bits.liquid_type == tile_liquid::Magma) if (pldes->bits.liquid_type == tile_liquid::Magma)
{ {
if (!pmagma || (!any_level && pldes->bits.flow_size < 4)) if (pmagma)
continue;
*pmagma = df::coord(x,y,z-1); *pmagma = df::coord(x,y,z-1);
if (pwater->isValid()) if (pwater->isValid())
return true; return true;
} }
else else
{ {
if (!any_level && pldes->bits.flow_size < 3)
continue;
*pwater = df::coord(x,y,z-1); *pwater = df::coord(x,y,z-1);
if (!pmagma || pmagma->isValid()) if (!pmagma || pmagma->isValid())
return true; return true;
@ -286,7 +281,7 @@ struct workshop_hook : df::building_workshopst {
// Consume liquid inputs // Consume liquid inputs
df::coord water, magma; df::coord water, magma;
if (!find_liquids(&water, &magma, engine->is_magma, true)) if (!find_liquids(&water, &magma, engine->is_magma, 1))
{ {
// Destroy the item with enormous wear amount. // Destroy the item with enormous wear amount.
liquid->addWear(WEAR_TICKS*5, true, false); liquid->addWear(WEAR_TICKS*5, true, false);
@ -626,7 +621,7 @@ struct workshop_hook : df::building_workshopst {
if (auto engine = get_steam_engine()) if (auto engine = get_steam_engine())
{ {
df::coord water, magma; df::coord water, magma;
return !find_liquids(&water, &magma, engine->is_magma, false); return !find_liquids(&water, &magma, engine->is_magma, 3);
} }
return INTERPOSE_NEXT(isUnpowered)(); return INTERPOSE_NEXT(isUnpowered)();
@ -681,12 +676,24 @@ struct workshop_hook : df::building_workshopst {
if (engine->water_tile.isValid() || engine->magma_tile.isValid()) if (engine->water_tile.isValid() || engine->magma_tile.isValid())
{ {
df::coord water, magma; df::coord water, magma;
find_liquids(&water, &magma, engine->is_magma, false); find_liquids(&water, &magma, engine->is_magma, 3);
df::coord dwater, dmagma;
find_liquids(&dwater, &dmagma, engine->is_magma, 5);
if (engine->water_tile.isValid() && !water.isValid()) if (engine->water_tile.isValid())
{
if (!water.isValid())
db->fore[engine->water_tile.x][engine->water_tile.y] = 0; db->fore[engine->water_tile.x][engine->water_tile.y] = 0;
if (engine->magma_tile.isValid() && engine->is_magma && !magma.isValid()) else if (!dwater.isValid())
db->bright[engine->water_tile.x][engine->water_tile.y] = 0;
}
if (engine->magma_tile.isValid() && engine->is_magma)
{
if (!magma.isValid())
db->fore[engine->magma_tile.x][engine->magma_tile.y] = 0; db->fore[engine->magma_tile.x][engine->magma_tile.y] = 0;
else if (!dmagma.isValid())
db->bright[engine->magma_tile.x][engine->magma_tile.y] = 0;
}
} }
} }
} }