Merge pull request #3260 from ab9rf/3dveins

reenable 3dveins
develop
Myk 2023-07-07 15:54:05 -07:00 committed by GitHub
commit 6c845f5751
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 34 deletions

@ -34,6 +34,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
# Future
## New Plugins
- ``3dveins``: reinstated for v50, this plugin replaces vanilla DF's blobby vein generation with veins that flow smoothly and naturally between z-levels
## Fixes
- Fix extra keys appearing in DFHack text boxes when shift (or any other modifier) is released before the other key you were pressing

@ -7,15 +7,16 @@
#include "Core.h"
#include "Console.h"
#include "DataDefs.h"
#include "Debug.h"
#include "Export.h"
#include "MiscUtils.h"
#include "PluginManager.h"
#include "modules/MapCache.h"
#include "modules/Random.h"
#include "modules/World.h"
#include "MiscUtils.h"
#include "DataDefs.h"
#include "df/world.h"
#include "df/world_data.h"
#include "df/world_region_details.h"
@ -47,6 +48,10 @@ DFHACK_PLUGIN("3dveins");
REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(gametype);
namespace DFHack {
DBG_DECLARE(_3dveins, process, DebugCategory::LINFO);
}
command_result cmd_3dveins(color_ostream &out, std::vector <std::string> & parameters);
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
@ -431,11 +436,13 @@ struct GeoLayer
void print_mineral_stats(color_ostream &out)
{
for (auto it = mineral_count.begin(); it != mineral_count.end(); ++it)
out << " " << MaterialInfo(0,it->first.first).getToken()
<< " " << ENUM_KEY_STR(inclusion_type,it->first.second)
<< ": \t\t" << it->second << " (" << (float(it->second)/unmined_tiles) << ")" << std::endl;
INFO(process, out).print("3dveins: %s %s: %d (%f)\n",
MaterialInfo(0, it->first.first).getToken().c_str(),
ENUM_KEY_STR(inclusion_type, it->first.second).c_str(),
it->second,
(float(it->second) / unmined_tiles));
out.print(" Total tiles: %d (%d unmined)\n", tiles, unmined_tiles);
INFO(process, out).print ("3dveins: Total tiles: %d (%d unmined)\n", tiles, unmined_tiles);
}
bool form_veins(color_ostream &out);
@ -467,12 +474,12 @@ struct GeoBiome
void print_mineral_stats(color_ostream &out)
{
out.print("Geological biome %d:\n", info.geo_index);
INFO(process,out).print("3dveins: Geological biome %d:\n", info.geo_index);
for (size_t i = 0; i < layers.size(); i++)
if (layers[i])
{
out << " Layer " << i << std::endl;
INFO(process, out).print("3dveins: Layer %ld\n", i);
layers[i]->print_mineral_stats(out);
}
}
@ -586,7 +593,7 @@ bool VeinGenerator::init_biomes()
if (info.geo_index < 0 || !info.geobiome)
{
out.printerr("Biome %zd is not defined.\n", i);
WARN(process, out).print("Biome %zd is not defined.\n", i);
return false;
}
@ -797,8 +804,7 @@ bool VeinGenerator::scan_layer_depth(Block *b, df::coord2d column, int z)
{
if (z != min_level[idx]-1 && min_level[idx] <= top_solid)
{
out.printerr(
"Discontinuous layer %d at (%d,%d,%d).\n",
WARN(process, out).print("Discontinuous layer %d at (%d,%d,%d).\n",
layer->index, x+column.x*16, y+column.y*16, z
);
return false;
@ -848,7 +854,7 @@ bool VeinGenerator::adjust_layer_depth(df::coord2d column)
if (max_level[i+1] != min_level[i]-1)
{
out.printerr(
WARN(process, out).print(
"Gap or overlap with next layer %d at (%d,%d,%d-%d).\n",
i+1, x+column.x*16, y+column.y*16, max_level[i+1], min_level[i]
);
@ -891,7 +897,7 @@ bool VeinGenerator::adjust_layer_depth(df::coord2d column)
}
}
out.printerr(
WARN(process, out).print(
"Layer height change in layer %d at (%d,%d,%d): %d instead of %d.\n",
i, x+column.x*16, y+column.y*16, max_level[i],
size, biome->layers[i]->thickness
@ -914,6 +920,7 @@ bool VeinGenerator::scan_block_tiles(Block *b, df::coord2d column, int z)
for (int y = 0; y < 16; y++)
{
df::coord2d tile(x,y);
GeoLayer *layer = mapLayer(b, tile);
if (!layer)
continue;
@ -932,7 +939,7 @@ bool VeinGenerator::scan_block_tiles(Block *b, df::coord2d column, int z)
if (unsigned(key.first) >= materials.size() ||
unsigned(key.second) >= NUM_INCLUSIONS)
{
out.printerr("Invalid vein code: %d %d - aborting.\n",key.first,key.second);
WARN(process, out).print("Invalid vein code: %d %d - aborting.\n",key.first,key.second);
return false;
}
@ -941,7 +948,7 @@ bool VeinGenerator::scan_block_tiles(Block *b, df::coord2d column, int z)
if (status == -1)
{
// Report first occurence of unreasonable vein spec
out.printerr(
WARN(process, out).print(
"Unexpected vein %s %s - ",
MaterialInfo(0,key.first).getToken().c_str(),
ENUM_KEY_STR(inclusion_type, key.second).c_str()
@ -949,9 +956,9 @@ bool VeinGenerator::scan_block_tiles(Block *b, df::coord2d column, int z)
status = materials[key.first].default_type;
if (status < 0)
out.printerr("will be left in place.\n");
WARN(process, out).print("will be left in place.\n");
else
out.printerr(
WARN(process, out).print(
"correcting to %s.\n",
ENUM_KEY_STR(inclusion_type, df::inclusion_type(status)).c_str()
);
@ -1090,7 +1097,7 @@ void VeinGenerator::write_block_tiles(Block *b, df::coord2d column, int z)
if (!ok)
{
out.printerr(
WARN(process, out).print(
"Couldn't write %d vein at (%d,%d,%d)\n",
mat, x+column.x*16, y+column.y*16, z
);
@ -1281,7 +1288,7 @@ bool GeoLayer::form_veins(color_ostream &out)
if (parent_id >= (int)refs.size())
{
out.printerr("Forward vein reference in biome %d.\n", biome->info.geo_index);
WARN(process, out).print("Forward vein reference in biome %d.\n", biome->info.geo_index);
return false;
}
@ -1301,7 +1308,7 @@ bool GeoLayer::form_veins(color_ostream &out)
if (vptr->parent)
ctx = "only be in "+MaterialInfo(0,vptr->parent_mat()).getToken();
out.printerr(
WARN(process, out).print(
"Duplicate vein %s %s in biome %d layer %d - will %s.\n",
MaterialInfo(0,key.first).getToken().c_str(),
ENUM_KEY_STR(inclusion_type, key.second).c_str(),
@ -1357,13 +1364,13 @@ bool VeinGenerator::place_orphan(t_veinkey key, int size, GeoLayer *from)
if (best.empty())
{
out.printerr(
WARN(process,out).print(
"Could not place orphaned vein %s %s anywhere.\n",
MaterialInfo(0,key.first).getToken().c_str(),
ENUM_KEY_STR(inclusion_type, key.second).c_str()
);
return false;
return true;
}
for (auto it = best.begin(); size > 0 && it != best.end(); ++it)
@ -1391,7 +1398,7 @@ bool VeinGenerator::place_orphan(t_veinkey key, int size, GeoLayer *from)
if (size > 0)
{
out.printerr(
WARN(process, out).print(
"Could not place all of orphaned vein %s %s: %d left.\n",
MaterialInfo(0,key.first).getToken().c_str(),
ENUM_KEY_STR(inclusion_type, key.second).c_str(),
@ -1541,7 +1548,7 @@ bool VeinGenerator::place_veins(bool verbose)
if (!isStoneInorganic(key.first))
{
out.printerr(
WARN(process, out).print(
"Invalid vein material: %s\n",
MaterialInfo(0, key.first).getToken().c_str()
);
@ -1551,7 +1558,7 @@ bool VeinGenerator::place_veins(bool verbose)
if (!is_valid_enum_item(key.second))
{
out.printerr("Invalid vein type: %d\n", key.second);
WARN(process, out).print("Invalid vein type: %d\n", key.second);
return false;
}
@ -1564,13 +1571,13 @@ bool VeinGenerator::place_veins(bool verbose)
sort(queue.begin(), queue.end(), vein_cmp);
// Place tiles
out.print("Processing... (%zu)", queue.size());
TRACE(process,out).print("Processing... (%zu)", queue.size());
for (size_t j = 0; j < queue.size(); j++)
{
if (queue[j]->parent && !queue[j]->parent->placed)
{
out.printerr(
WARN(process, out).print(
"\nParent vein not placed for %s %s.\n",
MaterialInfo(0,queue[j]->vein.first).getToken().c_str(),
ENUM_KEY_STR(inclusion_type, queue[j]->vein.second).c_str()
@ -1582,9 +1589,11 @@ bool VeinGenerator::place_veins(bool verbose)
if (verbose)
{
if (j > 0)
out.print("done.");
{
TRACE(process, out).print("done.");
}
out.print(
TRACE(process, out).print(
"\nVein layer %zu of %zu: %s %s (%.2f%%)... ",
j+1, queue.size(),
MaterialInfo(0,queue[j]->vein.first).getToken().c_str(),
@ -1594,14 +1603,13 @@ bool VeinGenerator::place_veins(bool verbose)
}
else
{
out.print("\rVein layer %zu of %zu... ", j+1, queue.size());
out.flush();
TRACE(process, out).print("\rVein layer %zu of %zu... ", j+1, queue.size());
}
queue[j]->place_tiles();
}
out.print("done.\n");
TRACE(process, out).print("done.\n");
return true;
}

@ -73,7 +73,7 @@ set_source_files_properties( Brushes.h PROPERTIES HEADER_FILE_ONLY TRUE )
# If you are adding a plugin that you do not intend to commit to the DFHack repo,
# see instructions for adding "external" plugins at the end of this file.
#dfhack_plugin(3dveins 3dveins.cpp)
dfhack_plugin(3dveins 3dveins.cpp)
dfhack_plugin(add-spatter add-spatter.cpp)
dfhack_plugin(autobutcher autobutcher.cpp LINK_LIBRARIES lua)
dfhack_plugin(autochop autochop.cpp LINK_LIBRARIES lua)