code_header.globals = (prog_section){code_header.functions.offset + sizeof(prog_section_function) *code_functions_elements, code_globals_elements };
code_header.strings = (prog_section){code_header.globals.offset + sizeof(int) *code_globals_elements, code_chars_elements };
code_header.entfield = 0; /* TODO: */
-
+
+ if (opts_darkplaces_stringtablebug) {
+ util_debug("GEN", "Patching stringtable for -fdarkplaces-stringtablebug\n");
+
+ /* >= + padd */
+ code_chars_add('\0'); /* > */
+ code_chars_add('\0'); /* = */
+ code_chars_add('\0'); /* P */
+ }
+
/* ensure all data is in LE format */
- util_endianswap(&code_header, sizeof(prog_header), 1);
- util_endianswap(code_statements_data, sizeof(prog_section_statement), code_statements_elements);
- util_endianswap(code_defs_data, sizeof(prog_section_def), code_defs_elements);
- util_endianswap(code_fields_data, sizeof(prog_section_field), code_fields_elements);
- util_endianswap(code_functions_data, sizeof(prog_section_function), code_functions_elements);
- util_endianswap(code_globals_data, sizeof(int), code_globals_elements);
+ util_endianswap(&code_header, 1, sizeof(prog_header));
+ util_endianswap(code_statements_data, code_statements_elements, sizeof(prog_section_statement));
+ util_endianswap(code_defs_data, code_defs_elements, sizeof(prog_section_def));
+ util_endianswap(code_fields_data, code_fields_elements, sizeof(prog_section_field));
+ util_endianswap(code_functions_data, code_functions_elements, sizeof(prog_section_function));
+ util_endianswap(code_globals_data, code_globals_elements, sizeof(int));
FILE *fp = fopen("program.dat", "wb");
fwrite(&code_header, 1, sizeof(prog_header), fp);
VECTOR_MAKE(argitem, items);
/* global options */
-int opts_debug = 0;
-int opts_memchk = 0;
-int opts_compiler = COMPILER_GMQCC;
+int opts_debug = 0;
+int opts_memchk = 0;
+int opts_compiler = COMPILER_GMQCC;
+int opts_darkplaces_stringtablebug = 0;
static const int usage(const char *const app) {
printf("usage:\n");
printf(" -std=ftqecc -- fteqcc QuakeC\n");
printf(" -std=qccx -- qccx QuakeC\n");
printf(" -std=gmqcc -- this compiler QuakeC (default selection)\n");
+ printf(" code flags -f*\n");
+ printf(" -fdarkplaces-stringtablebug -- patches the string table to work with bugged versions of darkplaces\n");
return -1;
}
printf(" -std=gmqcc -- this compiler QuakeC (default selection)\n");
return 0;
}
+
+ /* code specific switches */
+ if (!strncmp(&argv[1][1], "fdarkplaces-stringtablebug", 26)) {
+ opts_darkplaces_stringtablebug = 1;
+ break;
+ }
return usage(app);
}