Merge branch 'develop' of https://github.com/dfhack/dfhack into develop

develop
lethosor 2016-01-31 14:22:57 -05:00
commit 80fd2270db
5 changed files with 133 additions and 3 deletions

@ -73,6 +73,7 @@ using namespace DFHack;
#include "df/building_water_wheelst.h"
#include "df/building_wellst.h"
#include "df/building_rollersst.h"
#include "df/building_floodgatest.h"
using namespace df::enums;
using df::global::ui;
@ -369,6 +370,12 @@ df::building *Buildings::allocInstance(df::coord pos, df::building_type type, in
obj->ready_timeout = 500;
break;
}
case building_type::Floodgate:
{
auto obj = (df::building_floodgatest*)bld;
obj->gate_flags.bits.closed = true;
break;
}
default:
break;
}
@ -887,6 +894,21 @@ static int getMaxStockpileId()
return max_id;
}
static int getMaxCivzoneId()
{
auto &vec = world->buildings.other[buildings_other_id::ANY_ZONE];
int max_id = 0;
for (size_t i = 0; i < vec.size(); i++)
{
auto bld = strict_virtual_cast<df::building_civzonest>(vec[i]);
if (bld)
max_id = std::max(max_id, bld->zone_num);
}
return max_id;
}
bool Buildings::constructAbstract(df::building *bld)
{
CHECK_NULL_POINTER(bld);
@ -903,6 +925,11 @@ bool Buildings::constructAbstract(df::building *bld)
stock->stockpile_number = getMaxStockpileId() + 1;
break;
case building_type::Civzone:
if (auto zone = strict_virtual_cast<df::building_civzonest>(bld))
zone->zone_num = getMaxCivzoneId() + 1;
break;
default:
break;
}

@ -418,6 +418,7 @@ message GrowthPrint
optional int32 color = 2;
optional int32 timing_start = 3;
optional int32 timing_end = 4;
optional int32 tile = 5;
}
message TreeGrowth
@ -444,6 +445,12 @@ message PlantRaw
{
optional int32 index = 1;
optional string id = 2;
repeated string name = 3;
optional string name = 3;
repeated TreeGrowth growths = 4;
optional int32 tile = 5;
}
message PlantRawList
{
repeated PlantRaw plant_raws = 1;
}

@ -24,6 +24,7 @@
#include "df/builtin_mats.h"
#include "df/map_block_column.h"
#include "df/plant.h"
#include "df/plant_raw_flags.h"
#if DF_VERSION > 40001
#include "df/plant_tree_info.h"
#include "df/plant_tree_tile.h"
@ -112,6 +113,7 @@ static command_result GetWorldMap(color_ostream &stream, const EmptyMessage *in,
static command_result GetWorldMapCenter(color_ostream &stream, const EmptyMessage *in, WorldMap *out);
static command_result GetRegionMaps(color_ostream &stream, const EmptyMessage *in, RegionMaps *out);
static command_result GetCreatureRaws(color_ostream &stream, const EmptyMessage *in, CreatureRawList *out);
static command_result GetPlantRaws(color_ostream &stream, const EmptyMessage *in, PlantRawList *out);
void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC, DFCoord pos);
@ -164,6 +166,7 @@ DFhackCExport RPCService *plugin_rpcconnect(color_ostream &)
svc->addFunction("GetRegionMaps", GetRegionMaps);
svc->addFunction("GetCreatureRaws", GetCreatureRaws);
svc->addFunction("GetWorldMapCenter", GetWorldMapCenter);
svc->addFunction("GetPlantRaws", GetPlantRaws);
return svc;
}
@ -1943,3 +1946,60 @@ static command_result GetCreatureRaws(color_ostream &stream, const EmptyMessage
return CR_OK;
}
static command_result GetPlantRaws(color_ostream &stream, const EmptyMessage *in, PlantRawList *out)
{
if (!df::global::world)
return CR_FAILURE;
df::world * world = df::global::world;
for (int i = 0; i < world->raws.plants.all.size(); i++)
{
df::plant_raw* plant_local = world->raws.plants.all[i];
PlantRaw* plant_remote = out->add_plant_raws();
plant_remote->set_index(i);
plant_remote->set_id(plant_local->id);
plant_remote->set_name(plant_local->name);
if (!plant_local->flags.is_set(df::plant_raw_flags::TREE))
plant_remote->set_tile(plant_local->tiles.shrub_tile);
else
plant_remote->set_tile(plant_local->tiles.tree_tile);
for (int j = 0; j < plant_local->growths.size(); j++)
{
df::plant_growth* growth_local = plant_local->growths[j];
TreeGrowth * growth_remote = plant_remote->add_growths();
growth_remote->set_index(j);
growth_remote->set_id(growth_local->id);
growth_remote->set_name(growth_local->name);
for (int k = 0; k < growth_local->prints.size(); k++)
{
df::plant_growth_print* print_local = growth_local->prints[k];
GrowthPrint* print_remote = growth_remote->add_prints();
print_remote->set_priority(print_local->priority);
print_remote->set_color(print_local->color[0] + (print_local->color[1] * 8));
print_remote->set_timing_start(print_local->timing_start);
print_remote->set_timing_end(print_local->timing_end);
print_remote->set_tile(print_local->tile_growth);
}
growth_remote->set_timing_start(growth_local->timing_1);
growth_remote->set_timing_end(growth_local->timing_2);
growth_remote->set_twigs(growth_local->locations.bits.twigs);
growth_remote->set_light_branches(growth_local->locations.bits.light_branches);
growth_remote->set_heavy_branches(growth_local->locations.bits.heavy_branches);
growth_remote->set_trunk(growth_local->locations.bits.trunk);
growth_remote->set_roots(growth_local->locations.bits.roots);
growth_remote->set_cap(growth_local->locations.bits.cap);
growth_remote->set_sapling(growth_local->locations.bits.sapling);
growth_remote->set_timing_start(growth_local->timing_1);
growth_remote->set_timing_end(growth_local->timing_2);
growth_remote->set_trunk_height_start(growth_local->trunk_height_perc_1);
growth_remote->set_trunk_height_end(growth_local->trunk_height_perc_2);
auto growthMat = growth_remote->mutable_mat();
growthMat->set_mat_index(growth_local->mat_index);
growthMat->set_mat_type(growth_local->mat_type);
}
}
return CR_OK;
}

@ -57,9 +57,10 @@ module DFHack
bld.setSubtype(subtype)
bld.setCustomType(custom)
case type
when :Well; bld.bucket_z = bld.z
when :Furnace; bld.melt_remainder[world.raws.inorganics.length] = 0
when :Coffin; bld.initBurialFlags
when :Trap; bld.unk_cc = 500 if bld.trap_type == :PressurePlate
when :Trap; bld.ready_timeout = 500 if bld.trap_type == :PressurePlate
when :Floodgate; bld.gate_flags.closed = true
end
bld

@ -5,7 +5,8 @@ ban-cooking
===========
A more convenient way to ban cooking various categories of foods than the
kitchen interface. Usage: ``ban-cooking <type>``. Valid types are ``booze``,
``honey``, ``tallow``, ``oil``, and ``seeds`` (non-tree plants with seeds).
``honey``, ``tallow``, ``oil``, ``seeds`` (non-tree plants with seeds),
``brew``, ``mill``, ``thread``, and ``milk``.
=end
@ -87,11 +88,45 @@ $script_args.each do |arg|
end
end
when 'brew'
df.world.raws.plants.all.each do |p|
m = df.decode_mat(p.material_defs.type_basic_mat, p.material_defs.idx_basic_mat).material
ban_cooking[p.material_defs.type_basic_mat, p.material_defs.idx_basic_mat, :PLANT] if m.reaction_product and m.reaction_product.id and m.reaction_product.id.include?('DRINK_MAT')
p.growths.each do |g|
m = df.decode_mat(g).material
ban_cooking[g.mat_type, g.mat_index, :PLANT_GROWTH] if m.reaction_product and m.reaction_product.id and m.reaction_product.id.include?('DRINK_MAT')
end
end
when 'mill'
df.world.raws.plants.all.each do |p|
ban_cooking[p.material_defs.type_basic_mat, p.material_defs.idx_basic_mat, :PLANT] if m.flags[:MILL]
end
when 'thread'
df.world.raws.plants.all.each do |p|
ban_cooking[p.material_defs.type_basic_mat, p.material_defs.idx_basic_mat, :PLANT] if m.flags[:THREAD]
end
when 'milk'
df.world.raws.creatures.all.each_with_index do |c, i|
c.material.each_with_index do |m, j|
if m.reaction_product and m.reaction_product.id and m.reaction_product.id.include?('CHEESE_MAT')
ban_cooking[j + DFHack::MaterialInfo::CREATURE_BASE, i, :LIQUID_MISC]
end
end
end
else
puts "ban-cooking booze - bans cooking of drinks"
puts "ban-cooking honey - bans cooking of honey bee honey"
puts "ban-cooking tallow - bans cooking of tallow"
puts "ban-cooking oil - bans cooking of oil"
puts "ban-cooking seeds - bans cooking of plants that have seeds (tree seeds don't count)"
puts "ban-cooking brew - bans cooking of plants that can be brewed into alcohol"
puts "ban-cooking mill - bans cooking of plants that can be milled into powder"
puts "ban-cooking thread - bans cooking of plants that can be turned into thread"
puts "ban-cooking milk - bans cooking of creature liquids that can be turned into cheese"
end
end