修订版 | b3db6aca7e700b6ff7612f8cc1322c065ff9db5f (tree) |
---|---|
时间 | 2017-12-18 22:43:32 |
作者 | Rachael Alexanderson <anonymous@none...> |
Commiter | Rachael Alexanderson |
- added some security for MENUDEF commands in c_dispatch to curb some possible skulldrugery that may be possible.
@@ -137,7 +137,7 @@ | ||
137 | 137 | Button_ShowMedals; // [BC] Added the "show medals" button. |
138 | 138 | |
139 | 139 | |
140 | -bool ParsingKeyConf; | |
140 | +bool ParsingKeyConf, ParsingMenuDef = false; | |
141 | 141 | |
142 | 142 | // To add new actions, go to the console and type "key <action name>". |
143 | 143 | // This will give you the key value to use in the first column. Then |
@@ -199,6 +199,43 @@ | ||
199 | 199 | "clearplayerclasses" |
200 | 200 | }; |
201 | 201 | |
202 | +static const char *MenuDefCommands[] = | |
203 | +{ | |
204 | + "snd_reset", | |
205 | + "reset2defaults", | |
206 | + "reset2saved", | |
207 | + "menuconsole", | |
208 | + "clearnodecache", | |
209 | + "am_restorecolors", | |
210 | + "special", | |
211 | + "puke", | |
212 | + "fpuke", | |
213 | + "pukename", | |
214 | + //"event", // [SP] these won't be useful until zscript | |
215 | + //"netevent", | |
216 | + | |
217 | + // begin zandronum specific commands | |
218 | + "menu_spectate", | |
219 | + "menu_changeteam", | |
220 | + "menu_disconnect", | |
221 | + "menu_startskirmish", | |
222 | + "querymaster", | |
223 | + "menu_join_selected_server", | |
224 | + "menu_callkickvote", | |
225 | + "menu_callmapvote", | |
226 | + "menu_calllimitvote", | |
227 | + "menu_ignore", | |
228 | + "menu_joingame", | |
229 | + "menu_help", | |
230 | + "menu_autoselect", | |
231 | + "menu_joingame", | |
232 | + "menu_joingamewithclass", | |
233 | + "menu_login", | |
234 | + "rcon", | |
235 | + "menu_rconlogin", | |
236 | + "spectate", | |
237 | +}; | |
238 | + | |
202 | 239 | // CODE -------------------------------------------------------------------- |
203 | 240 | |
204 | 241 | IMPLEMENT_CLASS (DWaitingCommand) |
@@ -596,6 +633,25 @@ | ||
596 | 633 | } |
597 | 634 | } |
598 | 635 | |
636 | + if (ParsingMenuDef) | |
637 | + { | |
638 | + int i; | |
639 | + | |
640 | + for (i = countof(MenuDefCommands)-1; i >= 0; --i) | |
641 | + { | |
642 | + if (strnicmp (beg, MenuDefCommands[i], len) == 0 && | |
643 | + MenuDefCommands[i][len] == 0) | |
644 | + { | |
645 | + break; | |
646 | + } | |
647 | + } | |
648 | + if (i < 0) | |
649 | + { | |
650 | + Printf ("Invalid command for MENUDEF: %s\n", beg); | |
651 | + return; | |
652 | + } | |
653 | + } | |
654 | + | |
599 | 655 | // Check if this is an action |
600 | 656 | if (*beg == '+' || *beg == '-') |
601 | 657 | { |
@@ -35,6 +35,7 @@ | ||
35 | 35 | |
36 | 36 | void M_DrawConText (int color, int x, int y, const char *str); |
37 | 37 | void M_SetVideoMode(); |
38 | +extern bool ParsingMenuDef; // needed to stop some skulldruggery | |
38 | 39 | |
39 | 40 | |
40 | 41 |
@@ -86,7 +87,9 @@ | ||
86 | 87 | bool Activate() |
87 | 88 | { |
88 | 89 | S_Sound (CHAN_VOICE | CHAN_UI, "menu/choose", snd_menuvolume, ATTN_NONE); |
90 | + ParsingMenuDef = true; | |
89 | 91 | C_DoCommand(mAction); |
92 | + ParsingMenuDef = false; | |
90 | 93 | return true; |
91 | 94 | } |
92 | 95 |
@@ -111,7 +114,9 @@ | ||
111 | 114 | { |
112 | 115 | if (mkey == MKEY_MBYes) |
113 | 116 | { |
117 | + ParsingMenuDef = true; | |
114 | 118 | C_DoCommand(mAction); |
119 | + ParsingMenuDef = false; | |
115 | 120 | return true; |
116 | 121 | } |
117 | 122 | return FOptionMenuItemCommand::MenuEvent(mkey, fromcontroller); |