diff options
| author | Alexander Gavrilov | 2012-03-10 15:55:42 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-03-10 15:55:42 +0400 |
| commit | 8cc82d5876c902cbb4f0b3fa6cf15cf268dd942b (patch) | |
| tree | 4be7625f1bbe15b81d00373316047137d3422464 /plugins/colonies.cpp | |
| parent | b2737e2bed5f013a4dfbf6e19650ca60498a9afd (diff) | |
| download | dfhack-8cc82d5876c902cbb4f0b3fa6cf15cf268dd942b.tar.gz dfhack-8cc82d5876c902cbb4f0b3fa6cf15cf268dd942b.tar.bz2 dfhack-8cc82d5876c902cbb4f0b3fa6cf15cf268dd942b.tar.xz | |
Make plugins accept explicit output stream references.
This is an incompatible change to the plugin ABI.
The Console is not thread-safe unless used indirectly
via color_ostream_proxy, so everything should use their
per-thread stream.
Diffstat (limited to 'plugins/colonies.cpp')
| -rw-r--r-- | plugins/colonies.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/plugins/colonies.cpp b/plugins/colonies.cpp index 2ba0e738..3ebfc324 100644 --- a/plugins/colonies.cpp +++ b/plugins/colonies.cpp @@ -11,11 +11,11 @@ using std::vector; using std::string; using namespace DFHack; -command_result colonies (Core * c, vector <string> & parameters); +command_result colonies (color_ostream &out, vector <string> & parameters); DFHACK_PLUGIN("colonies"); -DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) +DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) { commands.push_back(PluginCommand( "colonies", "List or change wild colonies (ants hills and such)", @@ -28,16 +28,16 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> return CR_OK; } -DFhackCExport command_result plugin_shutdown ( Core * c ) +DFhackCExport command_result plugin_shutdown ( color_ostream &out ) { return CR_OK; } void destroyColonies(); void convertColonies(Materials *Materials); -void showColonies(Core *c, Materials *Materials); +void showColonies(color_ostream &out, Materials *Materials); -command_result colonies (Core * c, vector <string> & parameters) +command_result colonies (color_ostream &out, vector <string> & parameters) { bool destroy = false; bool convert = false; @@ -53,12 +53,13 @@ command_result colonies (Core * c, vector <string> & parameters) } if (destroy && convert) { - c->con.printerr("Kill or make bees? DECIDE!\n"); + out.printerr("Kill or make bees? DECIDE!\n"); return CR_FAILURE; } - CoreSuspender suspend(c); - Materials * materials = c->getMaterials(); + CoreSuspender suspend; + + Materials * materials = Core::getInstance().getMaterials(); materials->ReadCreatureTypesEx(); @@ -67,7 +68,7 @@ command_result colonies (Core * c, vector <string> & parameters) else if (convert) convertColonies(materials); else - showColonies(c, materials); + showColonies(out, materials); materials->Finish(); @@ -124,7 +125,7 @@ void convertColonies(Materials *Materials) } } -void showColonies(Core *c, Materials *Materials) +void showColonies(color_ostream &out, Materials *Materials) { uint32_t numSpawnPoints = Vermin::getNumVermin(); int numColonies = 0; @@ -141,11 +142,11 @@ void showColonies(Core *c, Materials *Materials) if(sp.race != -1) race = Materials->raceEx[sp.race].id; - c->con.print("Colony %u: %s at %d:%d:%d\n", i, - race.c_str(), sp.x, sp.y, sp.z); + out.print("Colony %u: %s at %d:%d:%d\n", i, + race.c_str(), sp.x, sp.y, sp.z); } } if (numColonies == 0) - c->con << "No colonies present." << std::endl; + out << "No colonies present." << std::endl; } |
