27 #include "../shared/parse.h"
28 #include "../shared/keyvaluepair.h"
29 #include "../game/inventory.h"
30 #include "../client/cl_screen.h"
32 #define CONSTNAMEINT_HASH_SIZE 32
34 #define MAX_CONSTNAMEINT_NAME 32
59 const char* space = strstr(name,
"::");
81 if (
Q_streq(variable, a->name)) {
82 if (!a->fullname || variable == name ||
Q_streq(a->fullname, name)) {
124 const size_t namespaceLength = strlen(space);
129 if (!strncmp(a->
fullname, space, namespaceLength))
162 com_constNameInt = a->
next;
171 if (!
Q_streq(name, b->fullname))
205 for (a = com_constNameInt_hash[hash]; a; a = a->
hash_next) {
209 }
else if (!strncmp(variable, a->
name,
sizeof(a->
name))) {
215 Com_Printf(
"Com_RegisterConstInt: Const string already defined. '%s = %d' is not set.\n", name, value);
226 com_constNameInt_hash[
hash] = a;
227 com_constNameInt = a;
241 for (
int i = 0; constList[
i].
name !=
nullptr;
i++)
255 for (
int i = 0; constList[
i].
name !=
nullptr;
i++)
277 const char*
Com_EParse (
const char** text,
const char* errhead,
const char* errinfo,
char* target,
size_t size)
279 const char* token =
Com_Parse(text, target, size);
298 Sys_Error(
"You are mixing versions of the binary (" UFO_VERSION ") and the script (%s) files.", version);
300 Sys_Error(
"More than one version string found in the script files.");
321 "translation_string",
342 "ul",
"uc",
"ur",
"cl",
"cc",
"cr",
"ll",
"lc",
"lr",
"ul_rsl",
"uc_rsl",
"ur_rsl",
"cl_rsl",
"cc_rsl",
"cr_rsl",
"ll_rsl",
"lc_rsl",
"lr_rsl"
347 "replace",
"one",
"blend",
"add",
"filter",
"invfilter"
352 "facing",
"rotated",
"beam",
"line",
"axis",
"circle"
357 "none",
"in",
"out",
"sin",
"saw"
442 const size_t align = vt_aligns[
type];
443 assert(memory !=
nullptr);
445 Sys_Error(
"Com_AlignPtr: can't align V_NULL");
447 Sys_Error(
"Com_AlignPtr: type hit V_NUM_TYPES");
448 return ALIGN_PTR(memory, align);
484 if (idNum >= 0 && idNum < aircraftIdsNum[type]) {
485 return aircraftIdsTable[
type][idNum];
492 const char*
const id =
Q_strstart(idString,
va(
"craft_%s_", craftTypeIds[type]));
494 for (
int i = 0;
i < aircraftIdsNum[
type];
i++)
495 if (
Q_streq(
id, aircraftIdsTable[type][
i]))
506 Com_sprintf(outStr, size,
"craft_%s_%s", craftTypeIds[type], uDef);
515 for (
int i = 0;
i < aircraftIdsNum[
type];
i++)
516 if (
Q_streq(
id, aircraftIdsTable[type][
i]))
596 if (
Q_streq(name,
va(
"%sids", craftTypeIds[
i]))) {
601 if (craftType == CRAFT_MAX) {
602 Com_Printf(
"Com_ParseAircraftNames: Unknown aircraft name type '%s' ignored\n", name);
607 if (!*text || *token !=
'{') {
608 Com_Printf(
"Com_ParseAircraftNames: names def \"%s\" without body ignored\n", name);
624 Com_Printf(
"Com_ParseAircraftNames: Unknown aircraft type '%s' without max ids ignored\n", name);
627 const char*
const errhead =
"Com_ParseAircraftNames: Unexpected end of file (name type ";
635 if (aircraftIdsNum[craftType] >= maxIds) {
636 Com_Printf(
"Com_ParseAircraftNames: Too many aircraft ids for type '%s', '%s' ignored!\n", name, token);
640 Com_Printf(
"Com_ParseAircraftNames: Aircraft with same name found '%s', second ignored\n", token);
643 aircraftIdsTable[craftType][aircraftIdsNum[craftType]++] =
Mem_StrDup(token);
676 if (size > vt_sizes[type]) {
677 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Size mismatch: given size: " UFO_SIZE_T ", should be: " UFO_SIZE_T " (type: %i). ", size, vt_sizes[type], type);
681 if (size < vt_sizes[type]) {
682 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Size mismatch: given size: " UFO_SIZE_T ", should be: " UFO_SIZE_T ". (type: %i)", size, vt_sizes[type], type);
689 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"V_HUNK_STRING is not parsed here");
697 if (
Q_streq(token,
"true") || *token ==
'1')
699 else if (
Q_streq(token,
"false") || *token ==
'0')
702 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Illegal bool statement '%s'", token);
705 *writtenBytes =
sizeof(bool);
709 if (token[0] ==
'\0') {
710 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Char expected, but end of string found");
713 if (token[1] !=
'\0') {
714 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Illegal end of string. '\\0' explected but 0x%x found", token[1]);
717 *(
char*) b = token[0];
718 *writtenBytes =
sizeof(char);
722 if (
Q_streq(token,
"civilian"))
724 else if (
Q_streq(token,
"phalanx"))
726 else if (
Q_streq(token,
"alien"))
729 Sys_Error(
"Unknown team string: '%s' found in script files", token);
730 *writtenBytes =
sizeof(
int);
738 Sys_Error(
"Unknown aircraft type: '%s'", token);
747 Sys_Error(
"Unknown ufo type: '%s'", token);
756 Sys_Error(
"Unknown ufo type: '%s'", token);
761 if (sscanf(token,
"%i", &((
int*) b)[0]) != 1) {
763 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Illegal int statement '%s'", token);
767 *writtenBytes =
sizeof(
int);
771 if (sscanf(token,
"%i %i", &((
int*) b)[0], &((
int*) b)[1]) != 2) {
772 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Illegal int2 statement '%s'", token);
775 *writtenBytes = 2 *
sizeof(
int);
779 if (sscanf(token,
"%f", &((
float*) b)[0]) != 1) {
780 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Illegal float statement '%s'", token);
783 *writtenBytes =
sizeof(float);
787 if (sscanf(token,
"%f %f", &((
float*) b)[0], &((
float*) b)[1]) != 2) {
788 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Illegal pos statement '%s'", token);
791 *writtenBytes = 2 *
sizeof(float);
795 if (sscanf(token,
"%f %f %f", &((
float*) b)[0], &((
float*) b)[1], &((
float*) b)[2]) != 3) {
796 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Illegal vector statement '%s'", token);
799 *writtenBytes = 3 *
sizeof(float);
804 float*
f = (
float*) b;
805 if (sscanf(token,
"%f %f %f %f", &f[0], &f[1], &f[2], &f[3]) != 4) {
806 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Illegal color statement '%s'", token);
809 *writtenBytes = 4 *
sizeof(float);
815 w = (
int)strlen(token) + 1;
825 w = (
int)strlen((
char*) b) + 1;
830 strcpy((
char*) b, token);
831 w = (
int)strlen(token) + 1;
837 if (
Q_streq(token, align_names[num]))
839 if (num == ALIGN_LAST) {
840 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Illegal align token '%s'", token);
844 *writtenBytes =
sizeof(
align_t);
849 if (
Q_streq(token, blend_names[num]))
851 if (num == BLEND_LAST) {
852 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Illegal blend token '%s'", token);
856 *writtenBytes =
sizeof(
blend_t);
861 if (
Q_streq(token, style_names[num]))
863 if (num == STYLE_LAST) {
864 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Illegal style token '%s'", token);
868 *writtenBytes =
sizeof(
style_t);
873 if (
Q_streq(token, fade_names[num]))
875 if (num == FADE_LAST) {
876 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Illegal fade token '%s'", token);
880 *writtenBytes =
sizeof(
fade_t);
884 if (sscanf(token,
"%i %i %i %i", &x, &y, &w, &h) != 4) {
885 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Illegal shape small statement '%s'", token);
890 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"illegal shape small statement - max h value is %i (y: %i, h: %i)",
SHAPE_SMALL_MAX_HEIGHT, y, h);
894 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"illegal shape small statement - max x and w values are %i",
SHAPE_SMALL_MAX_WIDTH);
897 for (h += y; y < h; y++)
903 if (sscanf(token,
"%i %i %i %i", &x, &y, &w, &h) != 4) {
904 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Illegal shape big statement '%s'", token);
908 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Illegal shape big statement, max height is %i",
SHAPE_BIG_MAX_HEIGHT);
912 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"illegal shape big statement - max x and w values are %i ('%s')",
SHAPE_BIG_MAX_WIDTH, token);
915 w = ((1 << w) - 1) << x;
916 for (h += y; y < h; y++)
917 ((uint32_t*) b)[y] |= w;
929 *writtenBytes =
sizeof(
byte);
933 if (sscanf(token,
"%i %i %i", &x, &y, &w) != 3) {
934 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"Illegal if statement '%s'", token);
940 *writtenBytes =
sizeof(
date_t);
944 if (token[0] ==
'-' || token[0] ==
'+') {
945 if (fabs(atof(token + 1)) <= 2.0
f) {
946 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"a V_RELABS (absolute) value should always be bigger than +/-2.0");
950 *(
float*) b = atof(token + 1) * (-1);
952 *(
float*) b = atof(token + 1);
954 if (fabs(atof(token)) > 2.0
f) {
955 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"a V_RELABS (relative) value should only be between 0.00..1 and 2.0");
958 *(
float*) b = atof(token);
960 *writtenBytes =
sizeof(float);
964 snprintf(parseErrorMessage,
sizeof(parseErrorMessage),
"unknown value type '%s'", token);
984 Sys_Error(
"Com_EParseValue: %s\n", parseErrorMessage);
987 Com_Printf(
"Com_EParseValue: %s\n", parseErrorMessage);
1003 size_t writtenBytes;
1005 assert(writtenBytes ==
sizeof(b));
1021 int Com_SetValueDebug (
void* base,
const void* set,
valueTypes_t type,
int ofs,
size_t size,
const char* file,
int line)
1034 if (size > vt_sizes[type])
1035 Com_Printf(
"Warning: Size mismatch: given size: " UFO_SIZE_T ", should be: " UFO_SIZE_T ". File: '%s', line: %i (type: %i)\n", size, vt_sizes[type], file, line, type);
1037 if (size < vt_sizes[type])
1038 Sys_Error(
"Size mismatch: given size: " UFO_SIZE_T
", should be: " UFO_SIZE_T
". File: '%s', line: %i (type: %i)", size, vt_sizes[type], file, line, type);
1040 if (size < vt_sizes[type])
1041 Sys_Error(
"Size mismatch: given size: " UFO_SIZE_T
", should be: " UFO_SIZE_T
". (type: %i)", size, vt_sizes[type], type);
1057 if (*(
const bool*) set)
1061 return sizeof(bool);
1064 *(
char*) b = *(
const char*) set;
1065 return sizeof(char);
1068 if (
Q_streq((
const char*)set,
"civilian"))
1070 else if (
Q_streq((
const char*)set,
"phalanx"))
1072 else if (
Q_streq((
const char*)set,
"alien"))
1075 Sys_Error(
"Unknown team given: '%s'", (
const char*)set);
1083 Sys_Error(
"Unknown aircraft type: '%s'", (
const char*)set);
1091 Sys_Error(
"Unknown ufo type: '%s'", (
const char*)set);
1099 Sys_Error(
"Unknown ufo type: '%s'", (
const char*)set);
1103 *(
int*) b = *(
const int*) set;
1107 ((
int*) b)[0] = ((
const int*) set)[0];
1108 ((
int*) b)[1] = ((
const int*) set)[1];
1109 return 2 *
sizeof(
int);
1112 *(
float*) b = *(
const float*) set;
1113 return sizeof(float);
1116 ((
float*) b)[0] = ((
const float*) set)[0];
1117 ((
float*) b)[1] = ((
const float*) set)[1];
1118 return 2 *
sizeof(float);
1121 ((
float*) b)[0] = ((
const float*) set)[0];
1122 ((
float*) b)[1] = ((
const float*) set)[1];
1123 ((
float*) b)[2] = ((
const float*) set)[2];
1124 return 3 *
sizeof(float);
1127 ((
float*) b)[0] = ((
const float*) set)[0];
1128 ((
float*) b)[1] = ((
const float*) set)[1];
1129 ((
float*) b)[2] = ((
const float*) set)[2];
1130 ((
float*) b)[3] = ((
const float*) set)[3];
1131 return 4 *
sizeof(float);
1135 len = (
int)strlen((
const char*) set) + 1;
1141 strcpy((
char*) b, (
const char*) set);
1142 len = (
int)strlen((
const char*) set) + 1;
1162 *(
int*) b = *(
const int*) set;
1170 *b = *(
const byte*) set;
1174 memcpy(b, set,
sizeof(
date_t));
1178 Sys_Error(
"Com_SetValue: unknown value type\n");
1191 static char valuestr[
MAX_VAR];
1192 const byte* b = (
const byte*) base + ofs;
1209 return (
const char*)b;
1212 if (*(
const bool*)b)
1218 return (
const char*) b;
1222 switch (*(
const int*) b) {
1230 Sys_Error(
"Unknown team id '%i'", *(
const int*) b);
1255 Com_sprintf(valuestr,
sizeof(valuestr),
"%i", *(
const int*) b);
1259 Com_sprintf(valuestr,
sizeof(valuestr),
"%i %i", ((
const int*) b)[0], ((
const int*) b)[1]);
1263 Com_sprintf(valuestr,
sizeof(valuestr),
"%.2f", *(
const float*) b);
1267 Com_sprintf(valuestr,
sizeof(valuestr),
"%.2f %.2f", ((
const float*) b)[0], ((
const float*) b)[1]);
1271 Com_sprintf(valuestr,
sizeof(valuestr),
"%.2f %.2f %.2f", ((
const float*) b)[0], ((
const float*) b)[1], ((
const float*) b)[2]);
1275 Com_sprintf(valuestr,
sizeof(valuestr),
"%.2f %.2f %.2f %.2f", ((
const float*) b)[0], ((
const float*) b)[1], ((
const float*) b)[2], ((
const float*) b)[3]);
1282 return (
const char*) b;
1318 if (*(
const float*) b > 2.0)
1319 Com_sprintf(valuestr,
sizeof(valuestr),
"+%.2f", *(
const float*) b);
1321 else if (*(
const float*) b < 2.0)
1322 Com_sprintf(valuestr,
sizeof(valuestr),
"-%.2f", *(
const float*) b);
1325 Com_sprintf(valuestr,
sizeof(valuestr),
"%.2f", *(
const float*) b);
1329 Sys_Error(
"Com_ValueToStr: unknown value type %i\n", type);
1336 const char* errhead =
"Com_ParseBlockToken: unexpected end of file (";
1338 for (v = values; v->
string; v++)
1347 if (mempool ==
nullptr) {
1375 return v->
string !=
nullptr;
1399 Com_Printf(
"Com_ParseList: expected list content but end of file found\n");
1417 const char* errhead =
"Com_ParseBlock: unexpected end of file (";
1422 if (!*text || *token !=
'{') {
1423 Com_Printf(
"Com_ParseBlock: block \"%s\" without body ignored\n", name);
1435 Com_Printf(
"Com_ParseBlock: unknown token '%s' ignored (%s)\n", token, name);
1591 Com_Printf(
"Com_ParseItemEffect: syntax error for item '%s'\n", name);
1595 if (
Q_streq(token,
"active")) {
1597 }
else if (
Q_streq(token,
"inactive")) {
1599 }
else if (
Q_streq(token,
"overdose")) {
1601 }
else if (
Q_streq(token,
"strengthen")) {
1605 if (!*text || *token !=
'{') {
1606 Com_Printf(
"Com_ParseItemEffect: syntax error for item '%s'\n", name);
1610 Com_Printf(
"Com_ParseItemEffect: item effect of \"%s\" has invalid effect stage: '%s'\n", name, token);
1615 if (token[0] !=
'{') {
1616 Com_Printf(
"Com_ParseItemEffect: syntax error for item '%s'\n", name);
1628 Com_Printf(
"Com_ParseItemEffect: item effect of \"%s\" contains invalid values\n", name);
1669 if (stagePtr ==
nullptr) {
1671 Com_Printf(
"Com_ParseFireEffect: invalid effect stage for '%s'\n", name);
1675 if (*stagePtr !=
nullptr) {
1677 Com_Printf(
"Com_ParseFireEffect: item effect of \"%s\" already has an effect assigned\n", name);
1692 const char* errhead =
"Com_ParseFire: unexpected end of file";
1697 if (!*text || *token !=
'{') {
1698 Com_Printf(
"Com_ParseFire: fire definition \"%s\" without body ignored\n", name);
1710 if (
Q_streq(token,
"skill")) {
1718 if (
Q_streq(skillNames[skill], token)) {
1722 if (skill >= SKILL_NUM_TYPES)
1723 Com_Printf(
"Com_ParseFire: unknown weapon skill \"%s\" ignored (weapon %s)\n", token, name);
1724 }
else if (
Q_streq(token,
"effect")) {
1726 }
else if (
Q_streq(token,
"range")) {
1731 }
else if (
Q_streq(token,
"splrad")) {
1737 Com_Printf(
"Com_ParseFire: unknown token \"%s\" ignored (weapon %s)\n", token, name);
1742 Com_Printf(
"Com_ParseFire: firedef for weapon \"%s\" has an invalid impact sound attenuation value set\n", name);
1745 Com_Printf(
"Com_ParseFire: firedef for weapon \"%s\" has an invalid fire sound attenuation value set\n", name);
1748 Com_Printf(
"Com_ParseFire: firedef for weapon \"%s\" doesn't have a skill set\n", name);
1751 Com_Printf(
"Com_ParseFire: firedef for weapon \"%s\" has delayBetweenShots set but is only a one-shot-firedef\n", name);
1755 if (fd->
name ==
nullptr) {
1771 const char* errhead =
"Com_ParseArmourOrResistance: unexpected end of file";
1776 if (!*text || *token !=
'{') {
1777 Com_Printf(
"Com_ParseArmourOrResistance: armour definition \"%s\" without body ignored\n", name);
1796 Sys_Error(
"Com_ParseArmourOrResistance: You try to set a rating value for a none menu displayed damage type '%s'",
1799 ad[
i] = atoi(token);
1805 Com_Printf(
"Com_ParseArmourOrResistance: unknown damage type \"%s\" ignored (in %s)\n", token, name);
1831 Sys_Error(
"max weapons per objdef exceeded");
1835 if (!*text || *token !=
'{') {
1836 Com_Printf(
"Com_ParseFireDefinition: weapon_mod \"%s\" without body ignored\n", name);
1842 if (!*text || !
Q_streq(token,
"weapon")) {
1843 Com_Printf(
"Com_ParseFireDefinition: weapon_mod \"%s\" weapon as first element expected.\n", name);
1854 LIST_Add(&parseItemWeapons, parse);
1858 const char* errhead =
"Com_ParseFireDefinition: unexpected end of file (weapon_mod ";
1865 if (
Q_streq(token,
"firedef")) {
1883 Com_Printf(
"Unknown token '%s' - expected firedef\n", token);
1894 Com_Printf(
"Com_ParseObjDefEffect: ignore invalid item effect stage for item: '%s'\n", name);
1899 Com_Printf(
"Com_ParseObjDefEffect: there is already a strengthen effect assigned to: '%s'\n", name);
1914 Com_Printf(
"Com_ParseItem: weapon def \"%s\" with same name found, second ignored\n", name);
1919 Sys_Error(
"Com_ParseItem: MAX_OBJDEFS exceeded\n");
1935 Sys_Error(
"Com_ParseItem: no id given\n");
1942 if (!*text || *token !=
'{') {
1943 Com_Printf(
"Com_ParseItem: weapon def \"%s\" without body ignored\n", name);
1948 const char* errhead =
"Com_ParseItem: unexpected end of file (weapon ";
1959 if (
Q_streq(token,
"craftweapon")) {
1968 LIST_Add(&parseItemWeapons, parse);
1973 }
else if (
Q_streq(token,
"effect")) {
1975 }
else if (
Q_streq(token,
"crafttype")) {
1983 if (
Q_streq(token, air_slot_type_strings[i])) {
1988 if (i == MAX_ACITEMS)
1989 Com_Printf(
"AII_ParseAircraftItem: \"%s\" unknown craftitem type: \"%s\" - ignored.\n", name, token);
1990 }
else if (
Q_streq(token,
"protection")) {
1992 }
else if (
Q_streq(token,
"rating")) {
1994 }
else if (
Q_streq(token,
"weapon_mod")) {
1997 Com_Printf(
"Com_ParseItem: unknown token \"%s\" ignored (weapon %s)\n", token, name);
2006 if (od->
shape & (0x01010101 << i))
2020 Sys_Error(
"Item %s has invalid parameters\n", od->
id);
2024 Com_Printf(
"Com_ParseItem: weapon \"%s\" has an invalid reload sound attenuation value set\n", od->
id);
2044 Com_Printf(
"Com_ParseImplant: implant def \"%s\" with same name found, second ignored\n", name);
2049 Sys_Error(
"Com_ParseImplant: MAX_IMPLANTS exceeded\n");
2058 Sys_Error(
"Com_ParseImplant: no id given\n");
2065 if (!*text || *token !=
'{') {
2066 Com_Printf(
"Com_ParseImplant: implant def \"%s\" without body ignored\n", name);
2071 const char* errhead =
"Com_ParseImplant: unexpected end of file (implant ";
2083 Com_Printf(
"Com_ParseImplant: syntax error (implant %s)\n", name);
2088 Com_Printf(
"Com_ParseImplant: unknown token \"%s\" ignored (implant %s)\n", token, name);
2093 if (implant->
item ==
nullptr) {
2094 Sys_Error(
"implant %s without item found", name);
2136 }
else if (
Q_streq(name,
"left")) {
2138 }
else if (
Q_streq(name,
"implant")) {
2140 }
else if (
Q_streq(name,
"belt")) {
2142 }
else if (
Q_streq(name,
"holster")) {
2144 }
else if (
Q_streq(name,
"backpack")) {
2146 }
else if (
Q_streq(name,
"armour")) {
2148 }
else if (
Q_streq(name,
"floor")) {
2150 }
else if (
Q_streq(name,
"equip")) {
2152 }
else if (
Q_streq(name,
"headgear")) {
2155 Sys_Error(
"Unknown inventory definition \"%s\". Aborting.\n", name);
2161 Com_Printf(
"Com_ParseInventory: inventory def \"%s\" with same name found, second ignored\n", name);
2204 const char* errhead =
"Com_ParseEquipment: unexpected end of file (equipment ";
2213 Com_Printf(
"Com_ParseEquipment: equipment def \"%s\" with same name found, second ignored\n", name);
2218 Sys_Error(
"Com_ParseEquipment: MAX_EQUIPDEFS exceeded\n");
2230 if (!*text || *token !=
'{') {
2231 Com_Printf(
"Com_ParseEquipment: equipment def \"%s\" without body ignored\n", name);
2238 if (!*text || *token ==
'}')
2245 Com_Error(
ERR_DROP,
"Com_ParseEquipment: error while reading equipment item tuple");
2248 Com_Error(
ERR_DROP,
"Com_ParseEquipment: equipment item tuple must contains 2 elements (id amount)");
2250 const char* itemToken = (
char*)list->
data;
2251 const char* amountToken = (
char*)list->
next->
data;
2256 const int n = atoi(amountToken);
2258 Com_Printf(
"Com_ParseEquipment: item '%s' is used several times in def '%s'. Only last entry will be taken into account.\n",
2263 Com_Printf(
"Com_ParseEquipment: unknown token \"%s\" ignored (equipment %s)\n", itemToken, name);
2266 }
else if (
Q_streq(token,
"aircraft")) {
2269 Com_Error(
ERR_DROP,
"Com_ParseEquipment: error while reading equipment aircraft tuple");
2272 Com_Error(
ERR_DROP,
"Com_ParseEquipment: equipment aircraft tuple must contains 2 elements (id amount)");
2274 const char* aircraftToken = (
char*)list->
data;
2275 const char* amountToken = (
char*)list->
next->
data;
2279 const int n = atoi(amountToken);
2281 Com_Printf(
"Com_ParseEquipment: aircraft type '%i' is used several times in def '%s'. Only last entry will be taken into account.\n",
2287 Sys_Error(
"unknown token in equipment in definition %s: '%s'", ed->
id, token);
2313 Sys_Error(
"Could not find any valid name definitions for category '%s'\n", td->
id);
2322 name = rand() % td->
numNames[gender];
2326 for (
int j = 0; j <
name; j++) {
2332 return (
const char*)list->
data;
2344 Com_Printf(
"Com_GiveModel: no models defined for gender %i and category '%s'\n", gender, td->
id);
2349 size_t n = rand() % td->
numModels[gender];
2376 Com_Printf(
"Com_GetTeamDefinitionByID: could not find team definition for '%s' in team definitions\n", team);
2408 for (gender = 0; gender <
NAME_LAST; ++gender)
2409 if (teamDef->
numNames[gender] > 0 && teamDef->
numNames[gender + NAME_LAST] > 0)
2410 numModels += teamDef->
numModels[gender];
2413 int roll = rand() % numModels;
2414 for (gender = 0; gender <
NAME_LAST; ++gender)
2415 if (teamDef->
numNames[gender] > 0 && teamDef->
numNames[gender + NAME_LAST] > 0) {
2416 if (roll < teamDef->numModels[gender])
2438 Com_Error(
ERR_DROP,
"Com_GetCharacterValues: could not find team '%s' in team definitions", teamDefition);
2466 Com_Error(
ERR_DROP,
"Could not set character values for team '%s'\n", teamDefition);
2476 const char* errhead =
"Com_ParseNames: unexpected end of file (names ";
2480 if (
Q_streq(name, names->id)) {
2481 Com_Printf(
"Com_ParseActorNames: Name list with same name found, second ignored '%s'\n", name);
2491 if (!*text || *token !=
'{') {
2492 Com_Printf(
"Com_ParseActorNames: names def \"%s\" without body ignored\n", name);
2505 if (nameType == -1) {
2511 Com_Error(
ERR_DROP,
"Com_ParseActorNames: error while reading names (%s)", name);
2514 for (
linkedList_t* element = list; element !=
nullptr; element = element->
next) {
2516 const char* n = (
char*)element->data;
2536 Sys_Error(
"Com_ParseNames: '%s' has no female lastname category\n", nameList.
id);
2538 Sys_Error(
"Com_ParseNames: '%s' has no male lastname category\n", nameList.
id);
2540 Sys_Error(
"Com_ParseNames: '%s' has no neutral lastname category\n", nameList.
id);
2552 const char* errhead =
"Com_ParseActorModels: unexpected end of file (actors ";
2557 if (!*text || *token !=
'{') {
2558 Com_Printf(
"Com_ParseActorModels: actor def \"%s\" without body ignored\n", td->
id);
2571 if (nameType == -1) {
2577 Com_Error(
ERR_DROP,
"Com_ParseActorModels: error while reading model tuple (%s)", name);
2581 Com_Error(
ERR_DROP,
"Com_ParseActorModels: model tuple must contains 5 elements");
2585 const char* pathToken = (
const char*)element->
data;
2586 element = element->
next;
2587 const char* bodyToken = (
const char*)element->
data;
2588 element = element->
next;
2589 const char* headToken = (
const char*)element->
data;
2590 element = element->
next;
2591 const char* bodySkinToken = (
const char*)element->
data;
2592 element = element->
next;
2593 const char* headSkinToken = (
const char*)element->
data;
2599 model.bodySkin = atoi(bodySkinToken);
2600 model.headSkin = atoi(headSkinToken);
2616 const char*
const errhead =
"Com_ParseActorSounds: unexpected end of file (actorsounds ";
2622 if (!*text || *token !=
'{') {
2623 Com_Printf(
"Com_ParseActorSounds: actorsounds def \"%s\" without body ignored\n", name);
2636 if (
Q_streq(token, name_strings[i])) {
2650 if (
Q_streq(token,
"hurtsound")) {
2656 }
else if (
Q_streq(token,
"deathsound")) {
2663 Com_Printf(
"Com_ParseActorSounds: unknown token \"%s\" ignored (actorsounds %s)\n", token, name);
2670 Com_Printf(
"Com_ParseActorSounds: unknown token \"%s\" ignored (actorsounds %s)\n", token, name);
2680 Com_Printf(
"Com_GetBodyTemplateByID: could not find template: '%s'\n",
id);
2689 Com_Printf(
"Com_GetNameListByID: could not find name list: '%s'\n",
id);
2712 const char* errhead =
"Com_ParseTeam: unexpected end of file (team ";
2728 Com_Printf(
"CL_ParseTeam: Too many team definitions, '%s' ignored.\n", name);
2732 Com_Printf(
"CL_ParseTeam: Team with same name found, second ignored '%s'\n", name);
2744 if (!*text || *token !=
'{') {
2745 Com_Printf(
"Com_ParseTeam: team def \"%s\" without body ignored\n", name);
2760 if (
Q_streq(token,
"onlyWeapon")) {
2769 Sys_Error(
"Com_ParseTeam: Could not get item definition for '%s'", token);
2770 }
else if (
Q_streq(token,
"templates")) {
2773 Com_Error(
ERR_DROP,
"Com_ParseTeam: error while reading templates (team \"%s\")", name);
2776 for (
linkedList_t* element = list; element !=
nullptr; element = element->
next) {
2779 Com_Printf(
"Com_ParseTeam: template %s used more than once in team def %s second ignored", (
char*)element->data, name);
2788 Sys_Error(
"Com_ParseTeam: Could not get character template for '%s' in %s", (
char*)element->data, name);
2793 }
else if (
Q_streq(token,
"bodytype")) {
2797 Sys_Error(
"Com_ParseTeam: Could not find body type %s in team def %s\n", token, name);
2799 }
else if (
Q_streq(token,
"names")) {
2802 if (nameList ==
nullptr)
2803 Sys_Error(
"Com_ParseTeam: Could not find name list %s in team def %s\n", token, name);
2806 }
else if (
Q_streq(token,
"models"))
2808 else if (
Q_streq(token,
"actorsounds"))
2810 else if (
Q_streq(token,
"resistance"))
2813 Com_Printf(
"Com_ParseTeam: unknown token \"%s\" ignored (team %s)\n", token, name);
2823 Sys_Error(
"Teamdef without body data: %s\n", td->
id);
2841 Com_Printf(
"Com_GetCharacterTemplateByID: could not find character template: '%s'\n", chrTemplate);
2863 Com_Printf(
"Com_ParseUGVs: ugv \"%s\" with same name already loaded\n", name);
2869 Com_Printf(
"Com_ParseUGVs: Too many UGV descriptions, '%s' ignored.\n", name);
2889 const char* errhead =
"Com_ParseCharacterTemplate: unexpected end of file";
2894 Com_Printf(
"Com_ParseCharacterTemplate: Template with same name found, second ignored '%s'\n", name);
2899 Sys_Error(
"Com_ParseCharacterTemplate: too many character templates");
2909 if (!*text || *token !=
'{') {
2910 Com_Printf(
"Com_ParseCharacterTemplate: character template \"%s\" without body ignored\n", name);
2917 if (!*text || *token ==
'}')
2921 if (
Q_streq(token, skillNames[i])) {
2930 if (i >= SKILL_NUM_TYPES + 1) {
2935 ct->
rate = atof(token);
2937 Com_Printf(
"Com_ParseCharacterTemplate: unknown token \"%s\" ignored (template %s)\n", token, name);
2952 "accuracy",
"shooting_tu",
"movement_tu",
"detection",
"reaction_time",
"max_tu"
2957 const char* errhead =
"Com_ParseBodyPart: unexpected end of file";
2962 Com_Printf(
"Com_ParseBodyPart: BodyPart with same name found, second ignored '%s'\n", name);
2968 Com_Printf(
"Com_ParseBodyPart: too many BodyParts '%s' ignored ('%s')\n", name, bd->
id());
2977 if (!*text || *token !=
'{') {
2978 Com_Printf(
"Com_ParseBodyPart: BodyPart '%s' without body ignored\n", name);
2984 if (!*text || *token ==
'}')
2988 if (
Q_streq(token,
"penalty")) {
2991 Com_Error(
ERR_DROP,
"Com_ParseBodyPart: error while reading penalties ('%s')", name);
2996 Com_Error(
ERR_DROP,
"Com_ParseBodyPart: penalty tuple must contain 2 elements ('%s')", name);
3001 if (
Q_streq(static_cast<const char*>(element->
data), penaltyNames[i])) {
3003 element = element->
next;
3008 if (i >= MODIFIER_MAX)
3009 Com_Printf(
"Com_ParseBodyPart: Unknown penalty '%s' ignored ('%s')\n", static_cast<const char*>(element->
data), name);
3013 Com_Printf(
"Com_ParseBodyPart: Unknown token '%s' ignored ('%s')\n", token, name);
3023 const char* errhead =
"Com_ParseBodyTemplate: unexpected end of file";
3027 if (
Q_streq(name, bt->id())) {
3028 Com_Printf(
"Com_ParseBodyTemplate: BodyTemplate with same name found, second ignored '%s'\n", name);
3035 if (!*text || *token !=
'{') {
3036 Com_Printf(
"Com_ParseBodyTemplate: body template '%s' without body ignored\n", name);
3044 if (!*text || *token ==
'}')
3047 if (
Q_streq(token,
"bodypart")) {
3054 Com_Printf(
"Com_ParseBodyTemplate: unknown token '%s' ignored ('%s')\n", token, name);
3059 Com_Printf(
"Body template without bodyparts %s ignored!\n", name);
3072 #define TERRAIN_HASH_SIZE 64
3091 assert(textureName);
3094 if (
Q_streq(textureName, t->texture))
3110 Com_Printf(
"Terrain definition with same name already parsed: '%s'\n", name);
3123 terrainTypesHash[
hash] = t;
3143 const char* errhead =
"Com_ParseGameTypes: unexpected end of file (gametype ";
3148 if (!*text || *token !=
'{') {
3149 Com_Printf(
"Com_ParseGameTypes: gametype \"%s\" without body ignored\n", name);
3160 Sys_Error(
"Com_ParseGameTypes: MAX_GAMETYPES exceeded");
3165 Sys_Error(
"Com_ParseGameTypes: Too many gametypes.");
3175 if (!
Q_streq(token,
"cvarlist"))
3176 Sys_Error(
"Com_ParseGameTypes: gametype \"%s\" without cvarlist", name);
3182 Sys_Error(
"Com_ParseGameTypes: gametype \"%s\" without cvarlist", name);
3186 if (!*text || *token ==
'}') {
3188 Sys_Error(
"Com_ParseGameTypes: gametype \"%s\" with empty cvarlist", name);
3195 Sys_Error(
"Com_ParseGameTypes: gametype \"%s\" max cvarlist hit", name);
3198 if (!*text || *token ==
'}')
3199 Sys_Error(
"Com_ParseGameTypes: gametype \"%s\" cvar \"%s\" with no value", name, cvarlist->
name);
3201 }
while (*text && *token !=
'}');
3205 Com_Printf(
"Com_ParseGameTypes: gametype \"%s\" with same already exists - ignore the second one\n", name);
3218 const char* errhead =
"Com_ParseDamageTypes: unexpected end of file (damagetype ";
3224 if (!*text || *token !=
'{') {
3225 Com_Printf(
"Com_ParseDamageTypes: damage type list \"%s\" without body ignored\n", name);
3237 if (*token ==
'_') {
3254 else if (
Q_streq(token,
"blast"))
3256 else if (
Q_streq(token,
"fire"))
3258 else if (
Q_streq(token,
"shock"))
3260 else if (
Q_streq(token,
"laser"))
3262 else if (
Q_streq(token,
"plasma"))
3264 else if (
Q_streq(token,
"particlebeam"))
3266 else if (
Q_streq(token,
"stun_electro"))
3268 else if (
Q_streq(token,
"stun_gas"))
3270 else if (
Q_streq(token,
"smoke"))
3272 else if (
Q_streq(token,
"incendiary"))
3277 Sys_Error(
"Com_ParseDamageTypes: Too many damage types.");
3279 Com_Printf(
"Com_ParseDamageTypes: damage type \"%s\" in list \"%s\" with same already exists - ignore the second one (#%i)\n", token, name,
csi.
numDTs);
3301 return va(
"+%s", craftID);
3309 if (
Q_streq(craftID,
"craft_drop_firebird"))
3310 return "+craft_crash_drop_firebird";
3311 else if (
Q_streq(craftID,
"craft_drop_raptor"))
3312 return "+craft_crash_drop_raptor";
3313 else if (
Q_streq(craftID,
"craft_inter_dragon"))
3314 return "+craft_crash_inter_dragon";
3315 else if (
Q_streq(craftID,
"craft_inter_saracen"))
3316 return "+craft_crash_inter_saracen";
3317 else if (
Q_streq(craftID,
"craft_inter_starchaser"))
3318 return "+craft_crash_inter_starchaser";
3334 return aircraftType;
3408 Com_Printf(
"Com_GetUGVByID Called with nullptr ugvID!\n");
3410 Com_Printf(
"Com_GetUGVByID: No ugv_t entry found for id '%s' in %i entries.\n", ugvID,
csi.
numUGV);
3421 const int weaponsIdx = parse->numWeapons;
3422 const char*
id = parse->token;
3426 if (!parse->od->weapons[weaponsIdx]) {
3427 Sys_Error(
"Com_AddObjectLinks: Could not get item '%s' for linking into item '%s'\n",
3428 id , parse->od->id);
3432 for (
int k = 0; k < parse->od->numFiredefs[weaponsIdx]; k++) {
3433 parse->od->fd[weaponsIdx][k].obj = parse->od;
3497 const char* errhead =
"Com_ParseMapDefinition: unexpected end of file (mapdef ";
3502 if (!*text || *token !=
'{') {
3503 Com_Printf(
"Com_ParseMapDefinition: mapdef \"%s\" without body ignored\n", name);
3510 Sys_Error(
"Com_ParseMapDefinition: Max mapdef hit");
3526 if (
Q_streq(token,
"params")) {
3529 Com_Printf(
"Com_ParseMapDefinition: unknown token \"%s\" ignored (mapdef %s)\n", token, name);
3536 Com_Printf(
"Com_ParseMapDefinition: mapdef \"%s\" with no map\n", name);
3541 Com_Printf(
"Com_ParseMapDefinition: mapdef \"%s\" with no description\n", name);
3546 Com_Printf(
"Com_ParseMapDefinition: mapdef \"%s\" with invalid maxAlien value\n", name);
3552 Com_DPrintf(
DEBUG_SHARED,
"Com_ParseMapDefinition: mapdef \"%s\" is skipped because hwclass doesn't match\n", name);
3559 const char* errhead =
"Com_ParseTerrainDefinition: unexpected end of file (terraindef ";
3567 if (!*text || *token !=
'{') {
3568 Com_Printf(
"Com_ParseTerrainDefinition: mapdef \"%s\" without body ignored\n", name);
3585 if (kvp.
isKey(
"rgbred"))
3587 else if (kvp.
isKey(
"rgbgreen"))
3589 else if (kvp.
isKey(
"rgbblue"))
3591 else if (kvp.
isKey(
"survivalchance"))
3593 else if (kvp.
isKey(
"rainchance"))
3595 else if (kvp.
isKey(
"snowchance"))
3598 Com_Printf(
"Com_ParseTerrainDefinition: unknown token \"%s\" ignored (terraindef %s)\n", token, name);
3603 Com_Printf(
"Com_ParseTerrainDefinition: terraindef \"%s\" with no name\n", name);
3607 Com_Printf(
"Com_ParseTerrainDefinition: could not add terraindef \"%s\". Duplicate colors or name.\n", name);
3645 Com_Printf(
"\n----------- parse scripts ----------\n");
3660 const char* text =
nullptr;
3665 if (
Q_streq(type,
"damagetypes"))
3667 else if (
Q_streq(type,
"gametype"))
3669 else if (
Q_streq(type,
"version"))
3680 else if (
Q_streq(type,
"inventory"))
3682 else if (
Q_streq(type,
"terrain"))
3684 else if (
Q_streq(type,
"ugv"))
3686 else if (
Q_streq(type,
"chrtemplate"))
3688 else if (
Q_streq(type,
"terraindef"))
3690 else if (
Q_streq(type,
"mapdef"))
3692 else if (
Q_streq(type,
"bodydef"))
3694 else if (
Q_streq(type,
"names"))
3696 else if (
Q_streq(type,
"aircraftnames"))
3698 else if (!onlyServer)
3703 Sys_Error(
"Could not find version string for script files");
3711 if (
Q_streq(type,
"equipment"))
3713 else if (
Q_streq(type,
"team"))
3715 else if (
Q_streq(type,
"implant"))
3731 Com_Printf(
"Shared Client/Server Info loaded\n");
3741 static int checksum = 0;
3757 OBJZERO(com_constNameInt_hash);
3758 com_constNameInt =
nullptr;
list of script aliases to register
static void Com_ParseActorModels(const char *name, const char **text, teamDef_t *td)
Parses "actors" definition from team_* ufo script files.
bool Q_strnull(const char *string)
const objDef_t * onlyWeapon
bool CL_ParseClientData(const char *type, const char *name, const char **text)
Called at client startup.
bool Com_ParseBlock(const char *name, const char **text, void *base, const value_t *values, memPool_t *mempool)
#define SHAPE_BIG_MAX_HEIGHT
defines the max height of an inventory container
static void Com_ParseObjDefEffect(objDef_t *od, const char *name, const char **text)
const objDef_t * INVSH_GetItemByIDSilent(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
const char * Com_GetLastParseError(void)
static void Com_GetCrashedUfoIdStr(ufoType_t idNum, char *outStr, const size_t size)
#define MAX_CHARACTER_TEMPLATES
bool Com_UnregisterConstVariable(const char *name)
Removes a registered constant from the script mapping hash table.
void Sys_Error(const char *error,...)
Structure to map (script) strings and integer (enum) values.
static const char * dropIdsTable[DROPSHIP_MAX]
static const char * interIdsTable[INTERCEPTOR_MAX]
#define MAX_CVARLISTINGAMETYPE
short Com_GetDropShipIdsNum(void)
struct date_s date_t
Engine-side time information in the game.
static void Com_ParseBodyPart(const char *name, const char **text, BodyData *bd)
bool Com_GetConstIntFromNamespace(const char *space, const char *variable, int *value)
Searches whether a given value was registered as a string to int mapping.
const char * Com_GetRandomMapAssemblyNameForCrashedCraft(const char *craftID)
const objDef_t * INVSH_GetItemByID(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
QGL_EXTERN GLint GLenum type
mapDef_t mds[MAX_MAPDEFS]
static void Com_ParseArmourOrResistance(const char *name, const char **text, short *ad, bool rating)
Parses the armour definitions or the team resistance values from script files. The protection and rat...
A pair of strings representing a key and a value The value string can be trimmed and rendered in the ...
valueTypes_t
possible values for parsing functions
const chrTemplate_t * Com_GetCharacterTemplateByID(const char *chrTemplate)
Returns the chrTemplate pointer for the given id - or nullptr if not found in the chrTemplates array...
this is a fire definition for our weapons/ammo
static void Com_ParseItem(const char *name, const char **text)
Parses weapon, equipment, craft items and armour.
static short aircraftIdsNum[CRAFT_MAX]
static const char *const craftTypeIds[CRAFT_MAX *2]
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
int Com_GetMapDefNumber(void)
short humanAircraftType_t
const teamDef_t * teamDef
const terrainType_t * Com_GetTerrainType(const char *textureName)
Searches the terrain definition if given.
static const vec3_t scale
int numNames[NAME_NUM_TYPES]
#define MAX_CONSTNAMEINT_NAME
weaponFireDefIndex_t weapFdsIdx
Terrain property table entry Terrain is defined by the file map_earth_terrain.png in pics/geoscape...
static const value_t ugvValues[]
#define CONSTNAMEINT_HASH_SIZE
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
Defines a type of UGV/Robot.
static linkedList_t * parseItemWeapons
Temporary list of weapon ids as parsed from the ufo file "weapon_mod \" in Com_ParseItem and use...
static int Com_GetGender(const teamDef_t *teamDef)
Return a random (weighted by number of models) gender for this teamDef.
static void Com_ParseTerrainDefinition(const char *name, const char **text)
memPool_t * com_aliasSysPool
static void Com_ParseEquipment(const char *name, const char **text)
static int Com_FindNameType(const char *nameType)
const char *const fade_names[]
static const char * ufoIdsTable[UFO_MAX]
Ufoai uses two types of ids for aircraft: the string is used for references in the scripts...
static short Com_GetCrashedAircraftIdNum(aircraftType_t type, const char *idString)
linkedList_t * actorNames
linkedList_t * names[NAME_NUM_TYPES]
CASSERT(lengthof(vt_names)==V_NUM_TYPES)
void Com_ParseScripts(bool onlyServer)
unsigned Com_BlockChecksum(const void *buffer, int length)
invDef_t ids[MAX_INVDEFS]
equipDef_t eds[MAX_EQUIPDEFS]
fireDef_t fd[MAX_WEAPONS_PER_OBJDEF][MAX_FIREDEFS_PER_WEAPON]
linkedList_t * models[NAME_LAST]
bool Com_GetCharacterModel(character_t *chr)
static void Com_GetHumanCraftIdStr(short idNum, char *outStr, const size_t size)
linkedList_t *const * names
char deathTextureName[MAX_VAR]
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
static const char **const aircraftIdsTable[CRAFT_MAX]
#define ABILITY_NUM_TYPES
void Com_Printf(const char *const fmt,...)
chrTemplate_t chrTemplates[MAX_CHARACTER_TEMPLATES]
const char * Com_DropShipTypeToShortName(humanAircraftType_t type)
Translate DropShip type to short name.
static const char *const penaltyNames[MODIFIER_MAX]
const struct objDef_s * ammos[MAX_AMMOS_PER_OBJDEF]
char name[MAX_CONSTNAMEINT_NAME]
static void Com_ParseMapDefinition(const char *name, const char **text)
int FS_BuildFileList(const char *fileList)
Build a filelist.
static short Com_GetHumanCraftIdNum(const char *idString)
void LIST_Delete(linkedList_t **list)
Defines all attributes of objects used in the inventory.
static const BodyData * Com_GetBodyTemplateByID(const char *id)
void Com_RegisterConstList(const constListEntry_t constList[])
Registers a list of string aliases.
linkedList_t * bodyTemplates
implantDef_t implants[MAX_IMPLANTS]
static void Com_ParseBodyTemplate(const char *name, const char **text)
cvarlist_t cvars[MAX_CVARLISTINGAMETYPE]
const char * Com_GetRandomMapAssemblyNameForCraft(const char *craftID)
Returns the name of an aircraft or an ufo that is used in the ump files for the random map assembly...
static const value_t fdps[]
const teamDef_t * Com_GetTeamDefinitionByID(const char *team)
Returns the teamDef pointer for the searched team id - or nullptr if not found in the teamDef array...
const chrTemplate_t * characterTemplates[MAX_TEMPLATES_PER_TEAM]
const ugv_t * Com_GetUGVByIDSilent(const char *ugvID)
Searches an UGV definition by a given script id and returns the pointer to the global data...
int LIST_Count(const linkedList_t *list)
#define Mem_PoolStrDupTo(in, out, pool, tagNum)
const char *const align_names[]
static const char * Com_ConstIntGetVariable(const char *name)
Will extract the variable from a string<=>int mapping string which contain a namespace.
void Sys_Backtrace(void)
On platforms supporting it, print a backtrace.
short protection[MAX_DAMAGETYPES]
void Com_GetCharacterValues(const char *teamDefition, character_t *chr)
Assign character values, 3D models and names to a character.
int Com_GetScriptChecksum(void)
void Com_Error(int code, const char *fmt,...)
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
Header for script parsing functions.
int penalties[MODIFIER_MAX]
static const value_t equipment_definition_vals[]
Valid equipment definition values from script files.
struct com_constNameInt_s * next
align_t
We need this here for checking the boundaries from script values.
static com_constNameInt_t * com_constNameInt_hash[CONSTNAMEINT_HASH_SIZE]
Hash of all the registeres mappings.
int numSounds[SND_MAX][NAME_LAST]
static const value_t terrainTypeValues[]
#define SND_VOLUME_FOOTSTEPS
bool add(const TerrainDef *tdef)
Translate color value to terrain type to random weather code.
int skills[SKILL_NUM_TYPES+1][2]
fireDefIndex_t numFiredefs[MAX_WEAPONS_PER_OBJDEF]
void LIST_AddString(linkedList_t **listDest, const char *data)
Adds an string to a new or to an already existing linked list. The string is copied here...
#define SHAPE_BIG_MAX_WIDTH
32 bit mask
static terrainType_t * terrainTypesHash[TERRAIN_HASH_SIZE]
const char *const vt_names[]
possible values for parsing functions
static const value_t od_vals[]
itemEffect_t * activeEffect
static wrapCache_t * hash[MAX_WRAP_HASH]
gametype_t gts[MAX_GAMETYPES]
short Com_GetUfoIdsNum(void)
int Com_SetValue(void *base, const void *set, valueTypes_t type, int ofs, size_t size)
static const char *const skillNames[SKILL_NUM_TYPES+1]
#define MAX_WEAPONS_PER_OBJDEF
static const value_t effect_vals[]
#define MAX_FIREDEFS_PER_WEAPON
memPool_t * com_genericPool
damageType_t dts[MAX_DAMAGETYPES]
const char * Com_ValueToStr(const void *base, const valueTypes_t type, const int ofs)
short resistance[MAX_DAMAGETYPES]
short ratings[MAX_DAMAGETYPES]
const char * Com_EParse(const char **text, const char *errhead, const char *errinfo, char *target, size_t size)
Parsing function that prints an error message when there is no text in the buffer.
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
#define SHAPE_SMALL_MAX_WIDTH
The max width and height of an item-shape.
struct com_constNameInt_s * hash_next
itemEffect_t * overdoseEffect
Engine-side time information in the game.
const char * Com_UFOTypeToShortName(ufoType_t type)
Translate UFO type to short name.
static const value_t bodyPartValues[]
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
teamDef_t teamDef[MAX_TEAMDEFS]
int numAircraft[AIRCRAFTTYPE_MAX]
ufoType_t Com_UFOShortNameToID(const char *token)
Translate short name to UFO type.
static void Com_GetAircraftIdStr(aircraftType_t type, short idNum, char *outStr, const size_t size)
void addBodyPart(const BodyPartData &bodyPart)
#define TERRAIN_HASH_SIZE
static bool Com_ParseFire(const char *name, const char **text, fireDef_t *fd)
Parses the firemode.
static const size_t vt_aligns[]
natural align for each targets
mapDef_t * Com_GetMapDefByIDX(int index)
struct terrainType_s * hash_next
void Com_RegisterConstInt(const char *name, int value)
Register mappings between script strings and enum values for values of the type V_INT.
resultStatus_t Com_ParseValue(void *base, const char *token, valueTypes_t type, int ofs, size_t size, size_t *writtenBytes)
Parse a value from a string.
static const size_t vt_sizes[]
target sizes for buffer
static ufoType_t Com_GetCrashedUfoIdNum(const char *idString)
int32_t weaponFireDefIndex_t
static const teamNames_t * Com_GetNameListByID(const char *id)
static bool versionParsed
static void Com_ParseUGVs(const char *name, const char **text)
Parse 2x2 units (e.g. UGVs)
CGAME_HARD_LINKED_FUNCTIONS linkedList_t * LIST_Add(linkedList_t **listDest, void const *data, size_t length)
const char *const air_slot_type_strings[]
List of valid strings for slot types.
const char * Com_GetConstVariable(const char *space, int value)
Searches the mapping variable for a given integer value and a namespace.
linkedList_t * sounds[SND_MAX][NAME_LAST]
int Com_EParseValue(void *base, const char *token, valueTypes_t type, int ofs, size_t size)
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
static void Com_ParseCharacterTemplate(const char *name, const char **text)
Parses character templates from scripts.
static void Com_GetCrashedAircraftIdStr(aircraftType_t type, short idNum, char *outStr, const size_t size)
const char *const blend_names[]
static void Com_ParseTeam(const char *name, const char **text)
struct com_constNameInt_s com_constNameInt_t
Structure to map (script) strings and integer (enum) values.
short numBodyParts(void) const
#define AIR_SLOT_TYPE_STRINGS
bool Com_ParseList(const char **text, linkedList_t **list)
static const value_t teamDefValues[]
possible teamdesc values (ufo-scriptfiles)
QGL_EXTERN GLuint GLchar GLuint * len
mapDef_t * Com_GetMapDefinitionByID(const char *mapDefID)
itemEffect_t * strengthenEffect
#define MAX_AMMOS_PER_OBJDEF
int numItems[MAX_OBJDEFS]
static teamDef_t::model_t const * Com_GiveModel(int gender, const teamDef_t *td)
static short Com_GetAircraftIdNum(aircraftType_t type, const char *idString)
const char * FS_GetFileData(const char *files)
Returns the buffer of a file.
char * FS_NextScriptHeader(const char *files, const char **name, const char **text)
aircraftItemType_t
All different types of craft items.
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
static void Com_AddObjectLinks(void)
Creates links to other items (i.e. ammo<->weapons)
const BodyData * bodyTemplate
static const char * Com_GetAircraftDef(aircraftType_t type, short idNum)
static const value_t idps[]
unsigned int Com_HashKey(const char *name, int hashsize)
returns hash key for a string
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
static void Com_ParseTerrain(const char *name, const char **text)
Parses "terrain" definition from script files.
static void Com_ParseVersion(const char *version)
bool isKey(const char *name) const
static char parseErrorMessage[256]
#define MEMBER_SIZEOF(TYPE, MEMBER)
static void Com_ParseGameTypes(const char *name, const char **text)
#define LIST_Foreach(list, type, var)
Iterates over a linked list, it's safe to delete the returned entry from the list while looping over ...
inventory definition for our menus
static effectStages_t Com_ParseItemEffect(itemEffect_t *e, const char *name, const char **text)
Parses the item effect.
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
static const value_t implant_vals[]
void * Com_AlignPtr(const void *memory, valueTypes_t type)
Align a memory to use a natural address for the data type we will write.
#define Mem_AllocType(type)
#define MapDef_Foreach(var)
objDef_t ods[MAX_OBJDEFS]
const char *const style_names[]
void Com_UnParseLastToken(void)
Put back the last token into the parser The next call of Com_Parse will return the same token again...
static const char * Com_GiveName(int gender, const teamDef_t *td)
const char * id(void) const
Different terrain definitions for footsteps and particles.
#define Mem_PoolStrDup(in, pool, tagNum)
void INVSH_InitCSI(const csi_t *import)
Initializes client server shared data pointer. This works because the client and the server are both ...
Com_TokenType_t Com_NextToken(const char **data_p)
Compute the next token.
itemEffect_t * deactiveEffect
void setId(const char *id)
#define Mem_PoolAllocType(type, pool)
const char *const name_strings[NAME_NUM_TYPES]
#define ACTOR_SIZE_NORMAL
static const value_t mapdef_vals[]
valid mapdef descriptors
const char * Com_GetToken(const char **data_p)
Get the current token value.
const struct objDef_s * item
humanAircraftType_t Com_DropShipShortNameToID(const char *token)
Translate DropShip type to short name.
QGL_EXTERN int GLboolean GLfloat * v
#define SHAPE_SMALL_MAX_HEIGHT
static const value_t gameTypeValues[]
possible gametype values for the gameserver (ufo-scriptfiles)
#define ACTOR_SIZE_INVALID
actorSizeEnum_t fieldSize
static ufoType_t Com_GetUfoIdNum(const char *idString)
static void Com_ParseInventory(const char *name, const char **text)
static void Com_ParseFireEffect(fireDef_t *fd, const char *name, const char **text)
Parses the effect that is bound to a fire definitions.
static void Com_ParseFireDefinition(objDef_t *od, const char *name, const char **text)
const char * Com_UFOCrashedTypeToShortName(ufoType_t type)
Translate UFO type to short name when UFO is crashed.
static void Com_ParseAircraftNames(const char *const name, const char **text)
Parse the aircraft names from the scripts.
bool Com_ParseBlockToken(const char *name, const char **text, void *base, const value_t *values, memPool_t *mempool, const char *token)
const struct objDef_s * weapons[MAX_WEAPONS_PER_OBJDEF]
bool Com_GetConstInt(const char *name, int *value)
Searches whether a given value was registered as a string to int mapping.
bool Com_UnregisterConstList(const constListEntry_t constList[])
Unregisters a list of string aliases.
static void Com_ParseActorSounds(const char *name, const char **text, teamDef_t *td)
Parses "actorsounds" definition from team_* ufo script files.
static com_constNameInt_t * com_constNameInt
Linked list of all the registeres mappings.
static void Com_ParseActorNames(const char *name, const char **text)
Parses "name" definition from team_* ufo script files.
const ugv_t * Com_GetUGVByID(const char *ugvID)
Searches an UGV definition by a given script id and returns the pointer to the global data...
void Com_SkipBlock(const char **text)
Skips a block of {} in our script files.
short Com_GetHumanAircraftIdsNum(void)
static void Com_ParseImplant(const char *name, const char **text)
static void Com_ParseDamageTypes(const char *name, const char **text)
bool Com_ParseBoolean(const char *token)
Parses a boolean from a string.
static void Com_GetUfoIdStr(ufoType_t idNum, char *outStr, const size_t size)
Describes a character with all its attributes.