45 #include "common.h" |
45 #include "common.h" |
46 #include "scriptreader.h" |
46 #include "scriptreader.h" |
47 #include "str.h" |
47 #include "str.h" |
48 #include "commands.h" |
48 #include "commands.h" |
49 |
49 |
50 CommandDef* g_CommDef; |
|
51 |
|
52 void ReadCommands () { |
50 void ReadCommands () { |
53 ScriptReader* r = new ScriptReader ("commands.def"); |
51 ScriptReader* r = new ScriptReader ("commands.def"); |
54 g_CommDef = NULL; |
52 g_CommDef = NULL; |
55 CommandDef* curdef = g_CommDef; |
53 CommandDef* curdef = g_CommDef; |
56 unsigned int numCommDefs = 0; |
54 unsigned int numCommDefs = 0; |
190 return comm; |
188 return comm; |
191 } |
189 } |
192 |
190 |
193 return NULL; |
191 return NULL; |
194 } |
192 } |
|
193 |
|
194 str GetCommandPrototype (CommandDef* comm) { |
|
195 str text; |
|
196 text += GetReturnTypeName (comm->returnvalue); |
|
197 text += ' '; |
|
198 text += comm->name; |
|
199 text += '('; |
|
200 |
|
201 bool hasOptionalArguments = false; |
|
202 for (int i = 0; i < comm->maxargs; i++) { |
|
203 if (i == comm->numargs) { |
|
204 hasOptionalArguments = true; |
|
205 text += '['; |
|
206 } |
|
207 |
|
208 if (i) |
|
209 text += ", "; |
|
210 |
|
211 text += GetReturnTypeName (comm->argtypes[i]); |
|
212 text += ' '; |
|
213 text += comm->argnames[i]; |
|
214 |
|
215 if (i >= comm->numargs) { |
|
216 text += '='; |
|
217 |
|
218 bool isString = comm->argtypes[i] == RETURNVAL_STRING; |
|
219 if (isString) text += '"'; |
|
220 |
|
221 char defvalstring[8]; |
|
222 sprintf (defvalstring, "%d", comm->defvals[i]); |
|
223 text += defvalstring; |
|
224 |
|
225 if (isString) text += '"'; |
|
226 } |
|
227 } |
|
228 |
|
229 if (hasOptionalArguments) |
|
230 text += ']'; |
|
231 text += ')'; |
|
232 return text; |
|
233 } |