remove unattached docs and plugins
parent
19a4905933
commit
65b3ce6e96
@ -1,11 +0,0 @@
|
||||
alltraffic
|
||||
==========
|
||||
Set traffic designations for every single tile of the map - useful for resetting
|
||||
traffic designations. See also `filltraffic`, `restrictice`, and `restrictliquids`.
|
||||
|
||||
Options:
|
||||
|
||||
:H: High Traffic
|
||||
:N: Normal Traffic
|
||||
:L: Low Traffic
|
||||
:R: Restricted Traffic
|
@ -1,91 +0,0 @@
|
||||
autobutcher
|
||||
===========
|
||||
Assigns lifestock for slaughter once it reaches a specific count. Requires that
|
||||
you add the target race(s) to a watch list. Only tame units will be processed.
|
||||
|
||||
Units will be ignored if they are:
|
||||
|
||||
* Nicknamed (for custom protection; you can use the `rename` ``unit`` tool
|
||||
individually, or `zone` ``nick`` for groups)
|
||||
* Caged, if and only if the cage is defined as a room (to protect zoos)
|
||||
* Trained for war or hunting
|
||||
|
||||
Creatures who will not reproduce (because they're not interested in the
|
||||
opposite sex or have been gelded) will be butchered before those who will.
|
||||
Older adults and younger children will be butchered first if the population
|
||||
is above the target (default 1 male, 5 female kids and adults). Note that
|
||||
you may need to set a target above 1 to have a reliable breeding population
|
||||
due to asexuality etc. See `fix-ster` if this is a problem.
|
||||
|
||||
Options:
|
||||
|
||||
:example: Print some usage examples.
|
||||
:start: Start running every X frames (df simulation ticks).
|
||||
Default: X=6000, which would be every 60 seconds at 100fps.
|
||||
:stop: Stop running automatically.
|
||||
:sleep <x>: Changes the timer to sleep X frames between runs.
|
||||
:watch R: Start watching a race. R can be a valid race RAW id (ALPACA,
|
||||
BIRD_TURKEY, etc) or a list of ids seperated by spaces or
|
||||
the keyword 'all' which affects all races on your current
|
||||
watchlist.
|
||||
:unwatch R: Stop watching race(s). The current target settings will be
|
||||
remembered. R can be a list of ids or the keyword 'all'.
|
||||
:forget R: Stop watching race(s) and forget it's/their target settings.
|
||||
R can be a list of ids or the keyword 'all'.
|
||||
:autowatch: Automatically adds all new races (animals you buy from merchants,
|
||||
tame yourself or get from migrants) to the watch list using
|
||||
default target count.
|
||||
:noautowatch: Stop auto-adding new races to the watchlist.
|
||||
:list: Print the current status and watchlist.
|
||||
:list_export: Print the commands needed to set up status and watchlist,
|
||||
which can be used to import them to another save (see notes).
|
||||
:target <fk> <mk> <fa> <ma> <R>:
|
||||
Set target count for specified race(s). The first four arguments
|
||||
are the number of female and male kids, and female and male adults.
|
||||
R can be a list of spceies ids, or the keyword ``all`` or ``new``.
|
||||
``R = 'all'``: change target count for all races on watchlist
|
||||
and set the new default for the future. ``R = 'new'``: don't touch
|
||||
current settings on the watchlist, only set the new default
|
||||
for future entries.
|
||||
:list_export: Print the commands required to rebuild your current settings.
|
||||
|
||||
.. note::
|
||||
|
||||
Settings and watchlist are stored in the savegame, so that you can have
|
||||
different settings for each save. If you want to copy your watchlist to
|
||||
another savegame you must export the commands required to recreate your settings.
|
||||
|
||||
To export, open an external terminal in the DF directory, and run
|
||||
``dfhack-run autobutcher list_export > filename.txt``. To import, load your
|
||||
new save and run ``script filename.txt`` in the DFHack terminal.
|
||||
|
||||
|
||||
Examples:
|
||||
|
||||
You want to keep max 7 kids (4 female, 3 male) and max 3 adults (2 female,
|
||||
1 male) of the race alpaca. Once the kids grow up the oldest adults will get
|
||||
slaughtered. Excess kids will get slaughtered starting with the youngest
|
||||
to allow that the older ones grow into adults. Any unnamed cats will
|
||||
be slaughtered as soon as possible. ::
|
||||
|
||||
autobutcher target 4 3 2 1 ALPACA BIRD_TURKEY
|
||||
autobutcher target 0 0 0 0 CAT
|
||||
autobutcher watch ALPACA BIRD_TURKEY CAT
|
||||
autobutcher start
|
||||
|
||||
Automatically put all new races onto the watchlist and mark unnamed tame units
|
||||
for slaughter as soon as they arrive in your fort. Settings already made
|
||||
for specific races will be left untouched. ::
|
||||
|
||||
autobutcher target 0 0 0 0 new
|
||||
autobutcher autowatch
|
||||
autobutcher start
|
||||
|
||||
Stop watching the races alpaca and cat, but remember the target count
|
||||
settings so that you can use 'unwatch' without the need to enter the
|
||||
values again. Note: 'autobutcher unwatch all' works, but only makes sense
|
||||
if you want to keep the plugin running with the 'autowatch' feature or manually
|
||||
add some new races with 'watch'. If you simply want to stop it completely use
|
||||
'autobutcher stop' instead. ::
|
||||
|
||||
autobutcher unwatch ALPACA CAT
|
@ -1,19 +0,0 @@
|
||||
autonestbox
|
||||
===========
|
||||
Assigns unpastured female egg-layers to nestbox zones. Requires that you create
|
||||
pen/pasture zones above nestboxes. If the pen is bigger than 1x1 the nestbox
|
||||
must be in the top left corner. Only 1 unit will be assigned per pen, regardless
|
||||
of the size. The age of the units is currently not checked, most birds grow up
|
||||
quite fast. Egglayers who are also grazers will be ignored, since confining them
|
||||
to a 1x1 pasture is not a good idea. Only tame and domesticated own units are
|
||||
processed since pasturing half-trained wild egglayers could destroy your neat
|
||||
nestbox zones when they revert to wild. When called without options autonestbox
|
||||
will instantly run once.
|
||||
|
||||
Options:
|
||||
|
||||
:start: Start running every X frames (df simulation ticks).
|
||||
Default: X=6000, which would be every 60 seconds at 100fps.
|
||||
:stop: Stop running automatically.
|
||||
:sleep: Must be followed by number X. Changes the timer to sleep X
|
||||
frames between runs.
|
@ -1,35 +0,0 @@
|
||||
digcircle
|
||||
=========
|
||||
A command for easy designation of filled and hollow circles.
|
||||
It has several types of options.
|
||||
|
||||
Shape:
|
||||
|
||||
:hollow: Set the circle to hollow (default)
|
||||
:filled: Set the circle to filled
|
||||
:#: Diameter in tiles (default = 0, does nothing)
|
||||
|
||||
Action:
|
||||
|
||||
:set: Set designation (default)
|
||||
:unset: Unset current designation
|
||||
:invert: Invert designations already present
|
||||
|
||||
Designation types:
|
||||
|
||||
:dig: Normal digging designation (default)
|
||||
:ramp: Ramp digging
|
||||
:ustair: Staircase up
|
||||
:dstair: Staircase down
|
||||
:xstair: Staircase up/down
|
||||
:chan: Dig channel
|
||||
|
||||
After you have set the options, the command called with no options
|
||||
repeats with the last selected parameters.
|
||||
|
||||
Examples:
|
||||
|
||||
``digcircle filled 3``
|
||||
Dig a filled circle with diameter = 3.
|
||||
``digcircle``
|
||||
Do it again.
|
@ -1,31 +0,0 @@
|
||||
digexp
|
||||
======
|
||||
This command is for :wiki:`exploratory mining <Exploratory_mining>`.
|
||||
|
||||
There are two variables that can be set: pattern and filter.
|
||||
|
||||
Patterns:
|
||||
|
||||
:diag5: diagonals separated by 5 tiles
|
||||
:diag5r: diag5 rotated 90 degrees
|
||||
:ladder: A 'ladder' pattern
|
||||
:ladderr: ladder rotated 90 degrees
|
||||
:clear: Just remove all dig designations
|
||||
:cross: A cross, exactly in the middle of the map.
|
||||
|
||||
Filters:
|
||||
|
||||
:all: designate whole z-level
|
||||
:hidden: designate only hidden tiles of z-level (default)
|
||||
:designated: Take current designation and apply pattern to it.
|
||||
|
||||
After you have a pattern set, you can use ``expdig`` to apply it again.
|
||||
|
||||
Examples:
|
||||
|
||||
``expdig diag5 hidden``
|
||||
Designate the diagonal 5 patter over all hidden tiles
|
||||
``expdig``
|
||||
Apply last used pattern and filter
|
||||
``expdig ladder designated``
|
||||
Take current designations and replace them with the ladder pattern
|
@ -1,19 +0,0 @@
|
||||
digtype
|
||||
=======
|
||||
For every tile on the map of the same vein type as the selected tile,
|
||||
this command designates it to have the same designation as the
|
||||
selected tile. If the selected tile has no designation, they will be
|
||||
dig designated.
|
||||
If an argument is given, the designation of the selected tile is
|
||||
ignored, and all appropriate tiles are set to the specified
|
||||
designation.
|
||||
|
||||
Options:
|
||||
|
||||
:dig:
|
||||
:channel:
|
||||
:ramp:
|
||||
:updown: up/down stairs
|
||||
:up: up stairs
|
||||
:down: down stairs
|
||||
:clear: clear designation
|
@ -1,316 +0,0 @@
|
||||
#include "Core.h"
|
||||
#include "Console.h"
|
||||
#include "Export.h"
|
||||
#include "PluginManager.h"
|
||||
|
||||
#include "DataDefs.h"
|
||||
#include "df/graphic.h"
|
||||
#include "df/enabler.h"
|
||||
#include "df/renderer.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "PassiveSocket.h"
|
||||
#include "tinythread.h"
|
||||
|
||||
using namespace DFHack;
|
||||
using namespace df::enums;
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
DFHACK_PLUGIN("dfstream");
|
||||
REQUIRE_GLOBAL(gps);
|
||||
REQUIRE_GLOBAL(enabler);
|
||||
|
||||
// Owns the thread that accepts TCP connections and forwards messages to clients;
|
||||
// has a mutex
|
||||
class client_pool {
|
||||
typedef tthread::mutex mutex;
|
||||
|
||||
mutex clients_lock;
|
||||
std::vector<CActiveSocket *> clients;
|
||||
|
||||
// TODO - delete this at some point
|
||||
tthread::thread * accepter;
|
||||
|
||||
static void accept_clients(void * client_pool_pointer) {
|
||||
client_pool * p = reinterpret_cast<client_pool *>(client_pool_pointer);
|
||||
CPassiveSocket socket;
|
||||
socket.Initialize();
|
||||
if (socket.Listen((const uint8_t *)"0.0.0.0", 8008)) {
|
||||
std::cout << "Listening on a socket" << std::endl;
|
||||
} else {
|
||||
std::cout << "Not listening: " << socket.GetSocketError() << std::endl;
|
||||
std::cout << socket.DescribeError() << std::endl;
|
||||
}
|
||||
while (true) {
|
||||
CActiveSocket * client = socket.Accept();
|
||||
if (client != 0) {
|
||||
lock l(*p);
|
||||
p->clients.push_back(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
class lock {
|
||||
tthread::lock_guard<mutex> l;
|
||||
public:
|
||||
lock(client_pool & p)
|
||||
: l(p.clients_lock)
|
||||
{
|
||||
}
|
||||
};
|
||||
friend class client_pool::lock;
|
||||
|
||||
client_pool() {
|
||||
accepter = new tthread::thread(accept_clients, this);
|
||||
}
|
||||
|
||||
// MUST have lock
|
||||
bool has_clients() {
|
||||
return !clients.empty();
|
||||
}
|
||||
|
||||
// MUST have lock
|
||||
void add_client(CActiveSocket * sock) {
|
||||
clients.push_back(sock);
|
||||
}
|
||||
|
||||
// MUST have lock
|
||||
void broadcast(const std::string & message) {
|
||||
unsigned int sz = htonl(message.size());
|
||||
for (size_t i = 0; i < clients.size(); ++i) {
|
||||
clients[i]->Send(reinterpret_cast<const uint8_t *>(&sz), sizeof(sz));
|
||||
clients[i]->Send((const uint8_t *) message.c_str(), message.size());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// A decorator (in the design pattern sense) of the DF renderer class.
|
||||
// Sends the screen contents to a client_pool.
|
||||
class renderer_decorator : public df::renderer {
|
||||
// the renderer we're decorating
|
||||
df::renderer * inner;
|
||||
|
||||
// how many frames have passed since we last sent a frame
|
||||
int framesNotPrinted;
|
||||
|
||||
// set to false in the destructor
|
||||
bool * alive;
|
||||
|
||||
// clients to which we send the frame
|
||||
client_pool clients;
|
||||
|
||||
// The following three methods facilitate copying of state to the inner object
|
||||
void set_to_null() {
|
||||
screen = NULL;
|
||||
screentexpos = NULL;
|
||||
screentexpos_addcolor = NULL;
|
||||
screentexpos_grayscale = NULL;
|
||||
screentexpos_cf = NULL;
|
||||
screentexpos_cbr = NULL;
|
||||
screen_old = NULL;
|
||||
screentexpos_old = NULL;
|
||||
screentexpos_addcolor_old = NULL;
|
||||
screentexpos_grayscale_old = NULL;
|
||||
screentexpos_cf_old = NULL;
|
||||
screentexpos_cbr_old = NULL;
|
||||
}
|
||||
|
||||
void copy_from_inner() {
|
||||
screen = inner->screen;
|
||||
screentexpos = inner->screentexpos;
|
||||
screentexpos_addcolor = inner->screentexpos_addcolor;
|
||||
screentexpos_grayscale = inner->screentexpos_grayscale;
|
||||
screentexpos_cf = inner->screentexpos_cf;
|
||||
screentexpos_cbr = inner->screentexpos_cbr;
|
||||
screen_old = inner->screen_old;
|
||||
screentexpos_old = inner->screentexpos_old;
|
||||
screentexpos_addcolor_old = inner->screentexpos_addcolor_old;
|
||||
screentexpos_grayscale_old = inner->screentexpos_grayscale_old;
|
||||
screentexpos_cf_old = inner->screentexpos_cf_old;
|
||||
screentexpos_cbr_old = inner->screentexpos_cbr_old;
|
||||
}
|
||||
|
||||
void copy_to_inner() {
|
||||
inner->screen = screen;
|
||||
inner->screentexpos = screentexpos;
|
||||
inner->screentexpos_addcolor = screentexpos_addcolor;
|
||||
inner->screentexpos_grayscale = screentexpos_grayscale;
|
||||
inner->screentexpos_cf = screentexpos_cf;
|
||||
inner->screentexpos_cbr = screentexpos_cbr;
|
||||
inner->screen_old = screen_old;
|
||||
inner->screentexpos_old = screentexpos_old;
|
||||
inner->screentexpos_addcolor_old = screentexpos_addcolor_old;
|
||||
inner->screentexpos_grayscale_old = screentexpos_grayscale_old;
|
||||
inner->screentexpos_cf_old = screentexpos_cf_old;
|
||||
inner->screentexpos_cbr_old = screentexpos_cbr_old;
|
||||
}
|
||||
|
||||
public:
|
||||
renderer_decorator(df::renderer * inner, bool * alive)
|
||||
: inner(inner)
|
||||
, framesNotPrinted(0)
|
||||
, alive(alive)
|
||||
{
|
||||
copy_from_inner();
|
||||
}
|
||||
virtual void update_tile(int x, int y) {
|
||||
copy_to_inner();
|
||||
inner->update_tile(x, y);
|
||||
}
|
||||
virtual void update_all() {
|
||||
copy_to_inner();
|
||||
inner->update_all();
|
||||
}
|
||||
virtual void render() {
|
||||
copy_to_inner();
|
||||
inner->render();
|
||||
|
||||
++framesNotPrinted;
|
||||
int gfps = enabler->calculated_gfps;
|
||||
if (gfps == 0) gfps = 1;
|
||||
// send a frame roughly every 128 mibiseconds (1 second = 1024 mibiseconds)
|
||||
if ((framesNotPrinted * 1024) / gfps <= 128) return;
|
||||
|
||||
client_pool::lock lock(clients);
|
||||
if (!clients.has_clients()) return;
|
||||
framesNotPrinted = 0;
|
||||
std::stringstream frame;
|
||||
frame << gps->dimx << ' ' << gps->dimy << " 0 0 " << gps->dimx << ' ' << gps->dimy << '\n';
|
||||
unsigned char * sc_ = gps->screen;
|
||||
for (int y = 0; y < gps->dimy; ++y) {
|
||||
unsigned char * sc = sc_;
|
||||
for (int x = 0; x < gps->dimx; ++x) {
|
||||
unsigned char ch = sc[0];
|
||||
unsigned char bold = (sc[3] != 0) * 8;
|
||||
unsigned char translate[] =
|
||||
{ 0, 4, 2, 6, 1, 5, 3, 7, 8, 12, 10, 14, 9, 13, 11, 15 };
|
||||
unsigned char fg = translate[(sc[1] + bold) % 16];
|
||||
unsigned char bg = translate[sc[2] % 16]*16;
|
||||
frame.put(ch);
|
||||
frame.put(fg+bg);
|
||||
sc += 4*gps->dimy;
|
||||
}
|
||||
sc_ += 4;
|
||||
}
|
||||
clients.broadcast(frame.str());
|
||||
}
|
||||
virtual void set_fullscreen() { inner->set_fullscreen(); }
|
||||
virtual void zoom(df::zoom_commands cmd) {
|
||||
copy_to_inner();
|
||||
inner->zoom(cmd);
|
||||
}
|
||||
virtual void resize(int w, int h) {
|
||||
copy_to_inner();
|
||||
inner->resize(w, h);
|
||||
copy_from_inner();
|
||||
}
|
||||
virtual void grid_resize(int w, int h) {
|
||||
copy_to_inner();
|
||||
inner->grid_resize(w, h);
|
||||
copy_from_inner();
|
||||
}
|
||||
virtual ~renderer_decorator() {
|
||||
*alive = false;
|
||||
if (inner) {
|
||||
copy_to_inner();
|
||||
delete inner;
|
||||
inner = 0;
|
||||
}
|
||||
set_to_null();
|
||||
}
|
||||
virtual bool get_mouse_coords(int *x, int *y) { return inner->get_mouse_coords(x, y); }
|
||||
virtual bool uses_opengl() { return inner->uses_opengl(); }
|
||||
|
||||
static renderer_decorator * hook(df::renderer *& ptr, bool * alive) {
|
||||
renderer_decorator * r = new renderer_decorator(ptr, alive);
|
||||
ptr = r;
|
||||
return r;
|
||||
}
|
||||
|
||||
static void unhook(df::renderer *& ptr, renderer_decorator * dec, color_ostream & out) {
|
||||
dec->copy_to_inner();
|
||||
ptr = dec->inner;
|
||||
dec->inner = 0;
|
||||
delete dec;
|
||||
}
|
||||
};
|
||||
|
||||
inline df::renderer *& active_renderer() {
|
||||
return enabler->renderer;
|
||||
}
|
||||
|
||||
// This class is a smart pointer around a renderer_decorator.
|
||||
// It should only be assigned r_d pointers that use the alive-pointer of this
|
||||
// instance.
|
||||
// If the r_d has been deleted by an external force, this smart pointer doesn't
|
||||
// redelete it.
|
||||
class auto_renderer_decorator {
|
||||
renderer_decorator * p;
|
||||
public:
|
||||
// pass this member to the ctor of renderer_decorator
|
||||
bool alive;
|
||||
|
||||
auto_renderer_decorator()
|
||||
: p(0)
|
||||
{
|
||||
}
|
||||
|
||||
~auto_renderer_decorator() {
|
||||
reset();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
if (*this) {
|
||||
delete p;
|
||||
p = 0;
|
||||
}
|
||||
}
|
||||
|
||||
operator bool() {
|
||||
return (p != 0) && alive;
|
||||
}
|
||||
|
||||
auto_renderer_decorator & operator=(renderer_decorator *p) {
|
||||
reset();
|
||||
this->p = p;
|
||||
return *this;
|
||||
}
|
||||
|
||||
renderer_decorator * get() {
|
||||
return p;
|
||||
}
|
||||
|
||||
renderer_decorator * operator->() {
|
||||
return get();
|
||||
}
|
||||
};
|
||||
|
||||
auto_renderer_decorator decorator;
|
||||
|
||||
DFhackCExport command_result plugin_init ( color_ostream &out, vector <PluginCommand> &commands)
|
||||
{
|
||||
if (!df::renderer::_identity.can_instantiate())
|
||||
{
|
||||
out.printerr("Cannot allocate a renderer\n");
|
||||
return CR_OK;
|
||||
}
|
||||
if (!decorator) {
|
||||
decorator = renderer_decorator::hook(active_renderer(), &decorator.alive);
|
||||
}
|
||||
return CR_OK;
|
||||
}
|
||||
|
||||
DFhackCExport command_result plugin_shutdown ( color_ostream &out )
|
||||
{
|
||||
if (decorator && active_renderer() == decorator.get())
|
||||
{
|
||||
renderer_decorator::unhook(active_renderer(), decorator.get(), out);
|
||||
}
|
||||
decorator.reset();
|
||||
return CR_OK;
|
||||
}
|
||||
// vim:set sw=4 sts=4 et:
|
Loading…
Reference in New Issue