Generates a program from a script
| 259 | |
| 260 | // Generates a program from a script |
| 261 | bool CompileScript(tD3XProgram *program, char *script) { |
| 262 | #if 0 // LGT: D3XReallocProgram undefined. Legacy scripting system? |
| 263 | int nscr, nstr, d3xlen; |
| 264 | char *strbuf; // string buffer grabbed from compile |
| 265 | tD3XInstruction *ins; // temporary holder for code |
| 266 | tD3XPMap *map; // temporary holder for map |
| 267 | |
| 268 | if (!script) { |
| 269 | mprintf(1, "Unable to compile null script!\n"); |
| 270 | return false; |
| 271 | } |
| 272 | |
| 273 | if (program == NULL) { |
| 274 | mprintf(1, "You can't compile an uninitialized script!\n"); |
| 275 | return false; |
| 276 | } |
| 277 | |
| 278 | if(!osi_Compile(script, &d3xlen, &ins, &nscr, &map, &nstr, &strbuf)) { |
| 279 | mprintf(1, "Script failed to compile.\n"); |
| 280 | return false; |
| 281 | } |
| 282 | |
| 283 | D3XReallocProgram(program, d3xlen, nscr, nstr); |
| 284 | D3XLoadProgramFromComponents(program, ins, map, strbuf); |
| 285 | |
| 286 | return true; |
| 287 | #else |
| 288 | return false; |
| 289 | #endif |
| 290 | } |
| 291 | |
| 292 | void SaveScriptCode(const char *filename, tD3XProgram *program) { |
| 293 | CFILE *file; |