Skip to content

Commit 463bb8d

Browse files
committed
Update plugins to use CR_WRONG_USAGE where appropriate
1 parent ff939e3 commit 463bb8d

12 files changed

Lines changed: 68 additions & 74 deletions

plugins/autotrade.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <Plug
626626
commands.push_back(
627627
PluginCommand(
628628
"autotrade", "Automatically send items in marked stockpiles to trade depot, when trading is possible.",
629-
autotrade_cmd, false, ""));
629+
autotrade_cmd, false, "Run 'autotrade version' to query the plugin version."));
630630

631631
return CR_OK;
632632
}

plugins/buildingplan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <Plug
11831183
commands.push_back(
11841184
PluginCommand(
11851185
"buildingplan", "Place furniture before it's built",
1186-
buildingplan_cmd, false, ""));
1186+
buildingplan_cmd, false, "Run 'buildingplan debug [on|off]' to toggle debugging, or 'buildingplan version' to query the plugin version."));
11871187
planner.initialize();
11881188

11891189
return CR_OK;

plugins/createitem.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ command_result df_createitem (color_ostream &out, vector <string> & parameters);
3737

3838
DFhackCExport command_result plugin_init (color_ostream &out, std::vector<PluginCommand> &commands)
3939
{
40-
commands.push_back(PluginCommand("createitem", "Create arbitrary item at the selected unit's feet.", df_createitem));
40+
commands.push_back(PluginCommand("createitem", "Create arbitrary item at the selected unit's feet.", df_createitem, false,
41+
"Syntax: createitem <item> <material> [count]\n"
42+
" <item> - Item token for what you wish to create, as specified in custom\n"
43+
" reactions. If the item has no subtype, omit the :NONE.\n"
44+
" <material> - The material you want the item to be made of, as specified\n"
45+
" in custom reactions. For REMAINS, FISH, FISH_RAW, VERMIN,\n"
46+
" PET, and EGG, replace this with a creature ID and caste.\n"
47+
" [count] - How many of the item you wish to create.\n"));
4148
return CR_OK;
4249
}
4350

@@ -91,17 +98,7 @@ command_result df_createitem (color_ostream &out, vector <string> & parameters)
9198
int count = 1;
9299

93100
if ((parameters.size() < 2) || (parameters.size() > 3))
94-
{
95-
out.print("Syntax: createitem <item> <material> [count]\n"
96-
" <item> - Item token for what you wish to create, as specified in custom\n"
97-
" reactions. If the item has no subtype, omit the :NONE.\n"
98-
" <material> - The material you want the item to be made of, as specified\n"
99-
" in custom reactions. For REMAINS, FISH, FISH_RAW, VERMIN,\n"
100-
" PET, and EGG, replace this with a creature ID and caste.\n"
101-
" [count] - How many of the item you wish to create.\n"
102-
);
103101
return CR_WRONG_USAGE;
104-
}
105102
item_str = parameters[0];
106103
material_str = parameters[1];
107104

plugins/lair.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ command_result lair(color_ostream &out, std::vector<std::string> & params)
5858

5959
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
6060
{
61-
commands.push_back(PluginCommand("lair","Mark the map as a monster lair, preventing item scatter ('lair reset' reverts that).",lair));
61+
commands.push_back(PluginCommand("lair","Mark the map as a monster lair, preventing item scatter.",lair, false,
62+
"Usage: 'lair' to mark entire map as monster lair, 'lair reset' to undo the operation.\n"));
6263
return CR_OK;
6364
}

plugins/liquids.cpp

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,16 @@ DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <Plug
5959
liquids_hist.load("liquids.history");
6060
commands.push_back(PluginCommand(
6161
"liquids", "Place magma, water or obsidian.",
62-
df_liquids, true)); // interactive, needs console for prompt
62+
df_liquids, true,
63+
"This tool allows placing magma, water and other similar things.\n"
64+
"It is interactive and further help is available when you run it.\n"
65+
"The settings will be remembered until dfhack is closed and you can call\n"
66+
"'liquids-here' (mapped to a hotkey) to paint liquids at the cursor position\n"
67+
"without the need to go back to the dfhack console.\n")); // interactive, needs console for prompt
6368
commands.push_back(PluginCommand(
6469
"liquids-here", "Use settings from liquids at cursor position.",
6570
df_liquids_here, Gui::cursor_hotkey, // non-interactive, needs ingame cursor
66-
" Identical to pressing enter in liquids, intended for use as keybinding.\n"
67-
" Can (but doesn't need to) be called while liquids is running in the console."));
71+
" This command is intended to be mapped to a hotkey and is identical to pressing Enter in liquids with the current parameters.\n"));
6872
return CR_OK;
6973
}
7074

@@ -157,14 +161,7 @@ command_result df_liquids (color_ostream &out_, vector <string> & parameters)
157161
for(size_t i = 0; i < parameters.size();i++)
158162
{
159163
if(parameters[i] == "help" || parameters[i] == "?")
160-
{
161-
out.print( "This tool allows placing magma, water and other similar things.\n"
162-
"It is interactive and further help is available when you run it.\n"
163-
"The settings will be remembered until dfhack is closed and you can call\n"
164-
"'liquids-here' (mapped to a hotkey) to paint liquids at the cursor position\n"
165-
"without the need to go back to the dfhack console.\n");
166-
return CR_OK;
167-
}
164+
return CR_WRONG_USAGE;
168165
}
169166

170167
if (!Maps::IsValid())
@@ -375,11 +372,7 @@ command_result df_liquids_here (color_ostream &out, vector <string> & parameters
375372
for(size_t i = 0; i < parameters.size();i++)
376373
{
377374
if(parameters[i] == "help" || parameters[i] == "?")
378-
{
379-
out << "This command is supposed to be mapped to a hotkey." << endl;
380-
out << "It will use the current/last parameters set in liquids." << endl;
381-
return CR_OK;
382-
}
375+
return CR_WRONG_USAGE;
383376
}
384377

385378
out.print("Run liquids-here with these parameters: ");

plugins/probe.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,19 @@ DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <Plug
4646
{
4747
commands.push_back(PluginCommand("probe",
4848
"A tile probe",
49-
df_probe));
49+
df_probe,
50+
false,
51+
"Hover the cursor over a tile to view its properties.\n"));
5052
commands.push_back(PluginCommand("cprobe",
5153
"A creature probe",
52-
df_cprobe));
54+
df_cprobe,
55+
false,
56+
"Select a creature to view its properties.\n"));
5357
commands.push_back(PluginCommand("bprobe",
5458
"A simple building probe",
55-
df_bprobe));
59+
df_bprobe,
60+
false,
61+
"Select a building to view its properties.\n"));
5662
return CR_OK;
5763
}
5864

plugins/regrass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ command_result df_regrass (color_ostream &out, vector <string> & parameters);
3030

3131
DFhackCExport command_result plugin_init (color_ostream &out, std::vector<PluginCommand> &commands)
3232
{
33-
commands.push_back(PluginCommand("regrass", "Regrows surface grass.", df_regrass));
33+
commands.push_back(PluginCommand("regrass", "Regrows surface grass.", df_regrass, false,
34+
"Specify parameter 'max' to set all grass types to full density, otherwise only one type of grass will be restored per tile.\n"));
3435
return CR_OK;
3536
}
3637

plugins/reveal.cpp

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,23 @@ DFHACK_PLUGIN("reveal");
7676

7777
DFhackCExport command_result plugin_init ( color_ostream &out, vector <PluginCommand> &commands)
7878
{
79-
commands.push_back(PluginCommand("reveal","Reveal the map. 'reveal hell' will also reveal hell. 'reveal demon' won't pause.",reveal));
80-
commands.push_back(PluginCommand("unreveal","Revert the map to its previous state.",unreveal));
81-
commands.push_back(PluginCommand("revtoggle","Reveal/unreveal depending on state.",revtoggle));
82-
commands.push_back(PluginCommand("revflood","Hide all, reveal all tiles reachable from cursor position.",revflood));
83-
commands.push_back(PluginCommand("revforget", "Forget the current reveal data, allowing to use reveal again.",revforget));
84-
commands.push_back(PluginCommand("nopause","Disable pausing (doesn't affect pause forced by reveal).",nopause));
79+
commands.push_back(PluginCommand("reveal","Reveal the map. 'reveal hell' will also reveal hell. 'reveal demon' won't pause.",reveal,false,
80+
"Reveals the map, by default ignoring hell.\n"
81+
"Options:\n"
82+
"hell - also reveal hell, while forcing the game to pause.\n"
83+
"demon - reveal hell, do not pause.\n"));
84+
commands.push_back(PluginCommand("unreveal","Revert the map to its previous state.",unreveal,false,
85+
"Reverts the previous reveal operation, hiding the map again.\n"));
86+
commands.push_back(PluginCommand("revtoggle","Reveal/unreveal depending on state.",revtoggle,false,
87+
"Toggles between reveal and unreveal.\n"));
88+
commands.push_back(PluginCommand("revflood","Hide all, reveal all tiles reachable from cursor position.",revflood,false,
89+
"This command hides the whole map. Then, starting from the cursor,\n"
90+
"reveals all accessible tiles. Allows repairing parma-revealed maps.\n"));
91+
commands.push_back(PluginCommand("revforget", "Forget the current reveal data, allowing to use reveal again.",revforget,false,
92+
"Forget the current reveal data, allowing to use reveal again.\n"));
93+
commands.push_back(PluginCommand("nopause","Disable pausing (doesn't affect pause forced by reveal).",nopause,false,
94+
"Disable pausing (doesn't affect pause forced by reveal).\n"
95+
"Activate with 'nopause 1', deactivate with 'nopause 0'.\n"));
8596
return CR_OK;
8697
}
8798

@@ -160,14 +171,7 @@ command_result reveal(color_ostream &out, vector<string> & params)
160171
if(params[i]=="hell")
161172
no_hell = false;
162173
else if(params[i] == "help" || params[i] == "?")
163-
{
164-
out.print("Reveals the map, by default ignoring hell.\n"
165-
"Options:\n"
166-
"hell - also reveal hell, while forcing the game to pause.\n"
167-
"demon - reveal hell, do not pause.\n"
168-
);
169-
return CR_OK;
170-
}
174+
return CR_WRONG_USAGE;
171175
}
172176
if(params.size() && params[0] == "hell")
173177
{
@@ -254,10 +258,7 @@ command_result unreveal(color_ostream &out, vector<string> & params)
254258
for(size_t i = 0; i < params.size();i++)
255259
{
256260
if(params[i] == "help" || params[i] == "?")
257-
{
258-
out.print("Reverts the previous reveal operation, hiding the map again.\n");
259-
return CR_OK;
260-
}
261+
return CR_WRONG_USAGE;
261262
}
262263
if(!revealed)
263264
{
@@ -330,12 +331,7 @@ command_result revflood(color_ostream &out, vector<string> & params)
330331
for(size_t i = 0; i < params.size();i++)
331332
{
332333
if(params[i] == "help" || params[i] == "?")
333-
{
334-
out.print("This command hides the whole map. Then, starting from the cursor,\n"
335-
"reveals all accessible tiles. Allows repairing parma-revealed maps.\n"
336-
);
337-
return CR_OK;
338-
}
334+
return CR_WRONG_USAGE;
339335
}
340336
CoreSuspender suspend;
341337
uint32_t x_max,y_max,z_max;
@@ -482,10 +478,7 @@ command_result revforget(color_ostream &out, vector<string> & params)
482478
for(size_t i = 0; i < params.size();i++)
483479
{
484480
if(params[i] == "help" || params[i] == "?")
485-
{
486-
out.print("Forget the current reveal data, allowing to use reveal again.\n");
487-
return CR_OK;
488-
}
481+
return CR_WRONG_USAGE;
489482
}
490483
if(!revealed)
491484
{

plugins/seedwatch.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,15 @@ command_result df_seedwatch(color_ostream &out, vector<string>& parameters)
130130
{
131131
case 0:
132132
printHelp(out);
133-
break;
133+
return CR_WRONG_USAGE;
134+
134135
case 1:
135136
par = parameters[0];
136-
if(par == "help") printHelp(out);
137-
else if(par == "?") printHelp(out);
137+
if ((par == "help") || (par == "?"))
138+
{
139+
printHelp(out);
140+
return CR_WRONG_USAGE;
141+
}
138142
else if(par == "start")
139143
{
140144
running = true;
@@ -239,6 +243,7 @@ command_result df_seedwatch(color_ostream &out, vector<string>& parameters)
239243
break;
240244
default:
241245
printHelp(out);
246+
return CR_WRONG_USAGE;
242247
break;
243248
}
244249

plugins/showmood.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ DFHACK_PLUGIN("showmood");
292292

293293
DFhackCExport command_result plugin_init (color_ostream &out, std::vector<PluginCommand> &commands)
294294
{
295-
commands.push_back(PluginCommand("showmood", "Shows items needed for current strange mood.", df_showmood));
295+
commands.push_back(PluginCommand("showmood", "Shows items needed for current strange mood.", df_showmood, false,
296+
"Run this command without any parameters to display information on the currently active Strange Mood."));
296297
return CR_OK;
297298
}
298299

0 commit comments

Comments
 (0)