9 #include "network_client.h" |
9 #include "network_client.h" |
10 #include "network_server.h" |
10 #include "network_server.h" |
11 #include "network_udp.h" |
11 #include "network_udp.h" |
12 #include "command.h" |
12 #include "command.h" |
13 #include "settings.h" |
13 #include "settings.h" |
|
14 #include "hal.h" /* for file list */ |
14 |
15 |
15 |
16 |
16 // ** scriptfile handling ** // |
17 // ** scriptfile handling ** // |
17 static FILE * _script_file; |
18 static FILE * _script_file; |
18 static bool _script_running; |
19 static bool _script_running; |
134 TileIndex tile = (TileIndex)GetArgumentInteger(argv[1]); |
135 TileIndex tile = (TileIndex)GetArgumentInteger(argv[1]); |
135 ScrollMainWindowToTile(tile); |
136 ScrollMainWindowToTile(tile); |
136 } |
137 } |
137 |
138 |
138 return 0; |
139 return 0; |
|
140 } |
|
141 |
|
142 extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm); |
|
143 extern void BuildFileList(); |
|
144 extern void SetFiosType(const byte fiostype); |
|
145 |
|
146 /* Load a file-number from current dir */ |
|
147 static void LoadMap(uint no) |
|
148 { |
|
149 /* Build file list */ |
|
150 BuildFileList(); |
|
151 |
|
152 /* Check if in range */ |
|
153 if (no != 0 && no <= _fios_num) { |
|
154 const FiosItem *item = &_fios_list[no - 1]; |
|
155 |
|
156 /* Load the file */ |
|
157 _switch_mode = SM_LOAD; |
|
158 SetFiosType(item->type); |
|
159 strcpy(_file_to_saveload.name, FiosBrowseTo(item)); |
|
160 |
|
161 IConsolePrint(_iconsole_color_default, "Loading map..."); |
|
162 } else { |
|
163 /* Show usages */ |
|
164 IConsolePrint(_iconsole_color_default, "Unknown map. Use 'list_files' and 'goto_dir' to find the numbers of the savegame."); |
|
165 } |
|
166 |
|
167 /* Free the file-list */ |
|
168 FiosFreeSavegameList(); |
|
169 } |
|
170 |
|
171 /* Load a file from a map */ |
|
172 DEF_CONSOLE_CMD(ConLoad) |
|
173 { |
|
174 /* We need 1 argument */ |
|
175 if (argc == 2) { |
|
176 /* Load the map */ |
|
177 LoadMap(atoi(argv[1])); |
|
178 return NULL; |
|
179 } |
|
180 |
|
181 /* Give usage */ |
|
182 IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: load <file-no>"); |
|
183 return NULL; |
|
184 } |
|
185 |
|
186 /* List all the files in the current dir via console */ |
|
187 DEF_CONSOLE_CMD(ConListFiles) |
|
188 { |
|
189 const FiosItem *item; |
|
190 int pos = 0; |
|
191 |
|
192 /* Build the file-list */ |
|
193 BuildFileList(); |
|
194 |
|
195 /* As long as we have files */ |
|
196 while (pos < _fios_num) { |
|
197 item = _fios_list + pos; |
|
198 pos++; |
|
199 /* Show them */ |
|
200 IConsolePrintF(_iconsole_color_default, "%d) %s", pos, item->title[0] ? item->title : item->name); |
|
201 } |
|
202 |
|
203 /* Destroy the file list */ |
|
204 FiosFreeSavegameList(); |
|
205 |
|
206 return NULL; |
|
207 } |
|
208 |
|
209 /* Change the dir via console */ |
|
210 DEF_CONSOLE_CMD(ConGotoDir) |
|
211 { |
|
212 char *file; |
|
213 int no; |
|
214 |
|
215 /* We need 1 argument */ |
|
216 if (argc != 2) { |
|
217 IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: goto_map <dir-no>"); |
|
218 return NULL; |
|
219 } |
|
220 |
|
221 no = atoi(argv[1]); |
|
222 |
|
223 /* Make the file list */ |
|
224 BuildFileList(); |
|
225 |
|
226 /* Check if we are in range */ |
|
227 if (no != 0 && no <= _fios_num) { |
|
228 const FiosItem *item = &_fios_list[no - 1]; |
|
229 /* Only DIR and PARENT we do allow here */ |
|
230 if (item->type == FIOS_TYPE_DIR || item->type == FIOS_TYPE_PARENT) { |
|
231 /* Goto the map */ |
|
232 file = FiosBrowseTo(item); |
|
233 FiosFreeSavegameList(); |
|
234 return NULL; |
|
235 } |
|
236 } |
|
237 |
|
238 /* Report error */ |
|
239 IConsolePrint(_iconsole_color_default, "That number is no directory."); |
|
240 FiosFreeSavegameList(); |
|
241 |
|
242 return NULL; |
139 } |
243 } |
140 |
244 |
141 |
245 |
142 // ********************************* // |
246 // ********************************* // |
143 // * Network Core Console Commands * // |
247 // * Network Core Console Commands * // |
1032 IConsoleCmdRegister("screenshot", ConScreenShot); |
1136 IConsoleCmdRegister("screenshot", ConScreenShot); |
1033 IConsoleCmdRegister("script", ConScript); |
1137 IConsoleCmdRegister("script", ConScript); |
1034 IConsoleCmdRegister("scrollto", ConScrollToTile); |
1138 IConsoleCmdRegister("scrollto", ConScrollToTile); |
1035 IConsoleCmdRegister("set", ConSet); |
1139 IConsoleCmdRegister("set", ConSet); |
1036 IConsoleCmdRegister("alias", ConAlias); |
1140 IConsoleCmdRegister("alias", ConAlias); |
|
1141 IConsoleCmdRegister("load", ConLoad); |
|
1142 IConsoleCmdRegister("list_files", ConListFiles); |
|
1143 IConsoleCmdRegister("goto_dir", ConGotoDir); |
1037 IConsoleAliasRegister("new_game", "newgame"); |
1144 IConsoleAliasRegister("new_game", "newgame"); |
1038 IConsoleAliasRegister("newmap", "newgame"); |
1145 IConsoleAliasRegister("newmap", "newgame"); |
1039 IConsoleAliasRegister("new_map", "newgame"); |
1146 IConsoleAliasRegister("new_map", "newgame"); |
1040 |
1147 |
1041 IConsoleVarRegister("developer", &_stdlib_developer, ICONSOLE_VAR_BYTE); |
1148 IConsoleVarRegister("developer", &_stdlib_developer, ICONSOLE_VAR_BYTE); |