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/skeleton | |
| 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/skeleton')
| -rw-r--r-- | plugins/skeleton/skeleton.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/plugins/skeleton/skeleton.cpp b/plugins/skeleton/skeleton.cpp index b2db81ff..3f5c6cd0 100644 --- a/plugins/skeleton/skeleton.cpp +++ b/plugins/skeleton/skeleton.cpp @@ -19,14 +19,14 @@ using namespace df::enums; // Here go all the command declarations... // mostly to allow having the mandatory stuff on top of the file and commands on the bottom -command_result skeleton (Core * c, std::vector <std::string> & parameters); +command_result skeleton (color_ostream &out, std::vector <std::string> & parameters); // A plugin must be able to return its name and version. // The name string provided must correspond to the filename - skeleton.plug.so or skeleton.plug.dll in this case DFHACK_PLUGIN("skeleton"); // Mandatory init function. If you have some global state, create it here. -DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands) +DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) { // Fill the command list with your commands. commands.clear(); @@ -43,7 +43,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> } // This is called right before the plugin library is removed from memory. -DFhackCExport command_result plugin_shutdown ( Core * c ) +DFhackCExport command_result plugin_shutdown ( color_ostream &out ) { // You *MUST* kill all threads you created before this returns. // If everything fails, just return CR_FAILURE. Your plugin will be @@ -55,7 +55,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c ) // Invoked with DF suspended, and always before the matching plugin_onupdate. // More event codes may be added in the future. /* -DFhackCExport command_result plugin_onstatechange(Core* c, state_change_event event) +DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) { switch (event) { case SC_GAME_LOADED: @@ -74,7 +74,7 @@ DFhackCExport command_result plugin_onstatechange(Core* c, state_change_event ev // Whatever you put here will be done in each game step. Don't abuse it. // It's optional, so you can just comment it out like this if you don't need it. /* -DFhackCExport command_result plugin_onupdate ( Core * c ) +DFhackCExport command_result plugin_onupdate ( color_ostream &out ) { // whetever. You don't need to suspend DF execution here. return CR_OK; @@ -82,7 +82,7 @@ DFhackCExport command_result plugin_onupdate ( Core * c ) */ // A command! It sits around and looks pretty. And it's nice and friendly. -command_result skeleton (Core * c, std::vector <std::string> & parameters) +command_result skeleton (color_ostream &out, std::vector <std::string> & parameters) { // It's nice to print a help message you get invalid options // from the user instead of just acting strange. @@ -96,9 +96,9 @@ command_result skeleton (Core * c, std::vector <std::string> & parameters) // Suspend this thread until DF has time for us. If you // use CoreSuspender, it'll automatically resume DF when // execution leaves the current scope. - CoreSuspender suspend(c); + CoreSuspender suspend; // Actually do something here. Yay. - c->con.print("Hello! I do nothing, remember?\n"); + out.print("Hello! I do nothing, remember?\n"); // Give control back to DF. return CR_OK; } |
