53 "Corvette",
"Freighter",
55 "Frigate",
"Destroyer",
56 "Cruiser",
"Battleship",
57 "Carrier",
"Dreadnaught",
59 "Station",
"Farcaster",
64 "Building",
"Factory",
68 "0x04000000",
"0x08000000",
69 "0x10000000",
"0x20000000",
70 "0x40000000",
"0x80000000"
76 static bool degrees =
false;
79 static const char*
TYPENAME() {
return "ShipCatalogEntry"; }
83 ShipCatalogEntry(
const char* n,
const char* t,
const char* p,
const char* f,
bool h=
false) :
102 #define GET_DEF_BOOL(n) if (defname==(#n)) GetDefBool((n), def, filename)
103 #define GET_DEF_TEXT(n) if (defname==(#n)) GetDefText((n), def, filename)
104 #define GET_DEF_NUM(n) if (defname==(#n)) GetDefNumber((n), def, filename)
105 #define GET_DEF_VEC(n) if (defname==(#n)) GetDefVec((n), def, filename)
107 static char cockpit_name[80];
111 static char errmsg[256];
130 static void PrepareModel(
Model& model)
132 bool uses_bumps =
false;
135 while (++iter && !uses_bumps) {
148 : sensor(0), navsys(0), shield(0), type(0), decoy(0),
149 probe(0), gear(0), valid(false), secret(false), auto_roll(1), cockpit_model(0),
150 bolt_hit_sound_resource(0), beam_hit_sound_resource(0), lod_levels(0)
158 for (
int i = 0; i < 4; i++)
165 : sensor(0), navsys(0), shield(0), type(0),
166 quantum_drive(0), farcaster(0), thruster(0), shield_model(0), decoy(0),
167 probe(0), gear(0), valid(false), secret(s), auto_roll(1), cockpit_model(0),
168 bolt_hit_sound_resource(0), beam_hit_sound_resource(0), lod_levels(0)
178 if (!strstr(fname,
".def"))
179 sprintf_s(
filename,
"%s.def", fname);
183 for (
int i = 0; i < 4; i++)
249 Print(
"Loading ShipDesign '%s'\n",
name);
268 Parser parser(
new(__FILE__,__LINE__)
BlockReader((
const char*) block, blocklen));
278 if (!file_type || file_type->
value() !=
"SHIP") {
307 for (
int i = 0; i < 4; i++) {
311 const char* model_name = iter.
value()->
data();
315 Print(
"ERROR: Could not load detail %d, model '%s'\n", i, model_name);
328 PrepareModel(*model);
330 if (offset[i].size()) {
347 if (cockpit_name[0]) {
348 const char* model_name = cockpit_name;
352 Print(
"ERROR: Could not load cockpit model '%s'\n", model_name);
358 Print(
" Loaded cockpit model '%s', preparing tangents\n", model_name);
450 for (
int i = 0; i < 4; i++) {
457 for (
int i = 0; i < 10; i++) {
475 if (!design_name || !*design_name)
480 for (
int i = 0; i < catalog.
size(); i++) {
482 if (e->
name == design_name) {
483 if (design_path && *design_path && e->
path != design_path)
490 for (
int i = 0; i < mod_catalog.
size(); i++) {
492 if (e->
name == design_name) {
493 if (design_path && *design_path) {
494 Text full_path =
"Mods/Ships/";
495 full_path += design_path;
497 if (e->
path != full_path)
507 Text file =
Text(design_name) +
".def";
513 if (design_path && *design_path)
524 int blocklen = loader->
LoadBuffer(file, block,
true);
531 Parser parser(
new(__FILE__,__LINE__)
BlockReader((
const char*) block, blocklen));
535 Print(
"ERROR: could not parse '%s'\n", file.
data());
541 if (!file_type || file_type->
value() !=
"SHIP") {
542 Print(
"ERROR: invalid ship design file '%s'\n", file.
data());
561 if (defname ==
"class") {
563 Print(
"WARNING: invalid or missing ship class in '%s'\n", file.
data());
568 else if (defname ==
"name") {
570 Print(
"WARNING: invalid or missing ship name in '%s'\n", file.
data());
576 Print(
"WARNING: term ignored in '%s'\n", file.
data());
581 while (term && valid && (name.
length() < 1 || type.
length() < 1));
586 Print(
"Add Mod Catalog Entry '%s' Class '%s'\n", name.
data(), type.
data());
589 mod_catalog.
append(entry);
596 if (catalog.
size())
return;
604 loader->
ListFiles(
"*.def", mod_designs,
true);
606 for (
int i = 0; i < mod_designs.
size(); i++) {
607 Text full_name = *mod_designs[i];
612 strcpy_s(path, full_name.
data());
620 char* p = strrchr(name,
'.');
621 if (p && strlen(p) > 3) {
622 if ((p[1] ==
'd' || p[1] ==
'D') &&
623 (p[2] ==
'e' || p[2] ==
'E') &&
624 (p[3] ==
'f' || p[3] ==
'F')) {
663 strncpy(filename, fname,
NAMELEN-1);
665 Print(
"Loading ship design catalog: %s%s\n", path, filename);
668 int blocklen = loader->
LoadBuffer(filename, block,
true);
669 Parser parser(
new(__FILE__,__LINE__)
BlockReader((
const char*) block, blocklen));
673 Print(
"ERROR: could not parse '%s'\n", filename);
680 if (!file_type || file_type->
value() !=
"SHIPCATALOG") {
681 Print(
"ERROR: invalid ship catalog file '%s'\n", filename);
707 if (defname ==
"name") {
709 Print(
"WARNING: invalid or missing ship name in '%s'\n", filename);
711 else if (defname ==
"type") {
713 Print(
"WARNING: invalid or missing ship type in '%s'\n", filename);
715 else if (defname ==
"path") {
717 Print(
"WARNING: invalid or missing ship path in '%s'\n", filename);
719 else if (defname ==
"file") {
721 Print(
"WARNING: invalid or missing ship file in '%s'\n", filename);
723 else if (defname ==
"hide" || defname ==
"secret") {
731 if (mod) mod_catalog.
append(entry);
732 else catalog.
append(entry);
737 Print(
"WARNING: term ignored in '%s'\n", filename);
768 int blocklen = loader->
LoadBuffer(filename, block,
true);
775 Parser parser(
new(__FILE__,__LINE__)
BlockReader((
const char*) block, blocklen));
780 Print(
"ERROR: could not parse '%s'\n", filename.
data());
785 if (!file_type || file_type->
value() !=
"SKIN") {
786 Print(
"ERROR: invalid skin file '%s'\n", filename.
data());
802 if (defname ==
"name") {
808 else if (defname ==
"skin" && design != 0) {
810 Print(
"WARNING: skin struct missing in '%s'\n", filename.
data());
834 return catalog.
size();
840 if (index >= 0 && index < catalog.
size()) {
883 for (
int i = 0; i < catalog.
size(); i++) {
884 if (catalog.
at(i)->
name == design_name) {
885 entry = catalog.
at(i);
891 for (
int i = 0; i < mod_catalog.
size(); i++) {
892 if (mod_catalog.
at(i)->
name == design_name) {
893 entry = mod_catalog.
at(i);
907 if (!design_name || !*design_name)
912 for (
int i = 0; i < catalog.
size(); i++) {
914 if (e->
name == design_name) {
915 if (design_path && *design_path && e->
path != design_path)
923 for (
int i = 0; i < mod_catalog.
size(); i++) {
925 if (e->
name == design_name) {
926 if (design_path && *design_path) {
927 Text full_path =
"Mods/Ships/";
928 full_path += design_path;
930 if (e->
path != full_path)
950 Print(
"ShipDesign: no catalog entry for design '%s', checking mods...\n", design_name);
958 Text file =
Text(design_name) +
".def";
961 if (design_path && *design_path)
972 Print(
"ShipDesign: found mod design '%s'\n", design->
name);
978 mod_catalog.
append(entry);
994 for (
int i = 0; i < catalog.
size(); i++) {
1016 for (
int i = 0; i < catalog.
size(); i++) {
1034 for (
int i = 0; i < mod_catalog.
size(); i++) {
1043 return designs.
size();
1051 if (!name || !name[0])
1054 for (
int i = 0; i < 32; i++) {
1069 while (!(type & 1)) {
1074 if (index >= 0 && index < 32)
1093 if (defname ==
"cockpit_model") {
1095 Print(
"WARNING: invalid or missing cockpit_model in '%s'\n",
filename);
1098 else if (defname ==
"model" || defname ==
"detail_0") {
1100 Print(
"WARNING: invalid or missing model in '%s'\n",
filename);
1102 detail[0].
append(
new(__FILE__,__LINE__)
Text(detail_name));
1105 else if (defname ==
"detail_1") {
1107 Print(
"WARNING: invalid or missing detail_1 in '%s'\n",
filename);
1109 detail[1].
append(
new(__FILE__,__LINE__)
Text(detail_name));
1112 else if (defname ==
"detail_2") {
1114 Print(
"WARNING: invalid or missing detail_2 in '%s'\n",
filename);
1116 detail[2].
append(
new(__FILE__,__LINE__)
Text(detail_name));
1119 else if (defname ==
"detail_3") {
1121 Print(
"WARNING: invalid or missing detail_3 in '%s'\n",
filename);
1123 detail[3].
append(
new(__FILE__,__LINE__)
Text(detail_name));
1126 else if (defname ==
"spin") {
1128 Print(
"WARNING: invalid or missing spin in '%s'\n",
filename);
1133 else if (defname ==
"offset_0") {
1135 Print(
"WARNING: invalid or missing offset_0 in '%s'\n",
filename);
1137 offset[0].
append(
new(__FILE__,__LINE__)
Point(off_loc));
1140 else if (defname ==
"offset_1") {
1142 Print(
"WARNING: invalid or missing offset_1 in '%s'\n",
filename);
1144 offset[1].
append(
new(__FILE__,__LINE__)
Point(off_loc));
1147 else if (defname ==
"offset_2") {
1149 Print(
"WARNING: invalid or missing offset_2 in '%s'\n",
filename);
1151 offset[2].
append(
new(__FILE__,__LINE__)
Point(off_loc));
1154 else if (defname ==
"offset_3") {
1156 Print(
"WARNING: invalid or missing offset_3 in '%s'\n",
filename);
1158 offset[3].
append(
new(__FILE__,__LINE__)
Point(off_loc));
1161 else if (defname ==
"beauty") {
1172 char beauty_name[64];
1174 Print(
"WARNING: invalid or missing beauty in '%s'\n",
filename);
1181 else if (defname ==
"hud_icon") {
1182 char hud_icon_name[64];
1184 Print(
"WARNING: invalid or missing hud_icon in '%s'\n",
filename);
1190 else if (defname ==
"feature_0") {
1192 Print(
"WARNING: invalid or missing feature_0 in '%s'\n",
filename);
1195 else if (defname ==
"feature_1") {
1197 Print(
"WARNING: invalid or missing feature_1 in '%s'\n",
filename);
1200 else if (defname ==
"feature_2") {
1202 Print(
"WARNING: invalid or missing feature_2 in '%s'\n",
filename);
1205 else if (defname ==
"feature_3") {
1207 Print(
"WARNING: invalid or missing feature_3 in '%s'\n",
filename);
1211 else if (defname ==
"class") {
1214 Print(
"WARNING: invalid or missing ship class in '%s'\n",
filename);
1275 else if (defname ==
"emcon_1") {
1279 else if (defname ==
"emcon_2") {
1283 else if (defname ==
"emcon_3") {
1287 else if (defname ==
"chase") {
1289 Print(
"WARNING: invalid or missing chase cam loc in '%s'\n",
filename);
1294 else if (defname ==
"bridge") {
1296 Print(
"WARNING: invalid or missing bridge cam loc in '%s'\n",
filename);
1301 else if (defname ==
"power") {
1303 Print(
"WARNING: power source struct missing in '%s'\n",
filename);
1311 else if (defname ==
"main_drive" || defname ==
"drive") {
1313 Print(
"WARNING: main drive struct missing in '%s'\n",
filename);
1321 else if (defname ==
"quantum" || defname ==
"quantum_drive") {
1323 Print(
"WARNING: quantum_drive struct missing in '%s'\n",
filename);
1331 else if (defname ==
"sender" || defname ==
"farcaster") {
1333 Print(
"WARNING: farcaster struct missing in '%s'\n",
filename);
1341 else if (defname ==
"thruster") {
1343 Print(
"WARNING: thruster struct missing in '%s'\n",
filename);
1351 else if (defname ==
"navlight") {
1353 Print(
"WARNING: navlight struct missing in '%s'\n",
filename);
1361 else if (defname ==
"flightdeck") {
1363 Print(
"WARNING: flightdeck struct missing in '%s'\n",
filename);
1371 else if (defname ==
"gear") {
1381 else if (defname ==
"weapon") {
1383 Print(
"WARNING: weapon struct missing in '%s'\n",
filename);
1391 else if (defname ==
"hardpoint") {
1393 Print(
"WARNING: hardpoint struct missing in '%s'\n",
filename);
1401 else if (defname ==
"loadout") {
1403 Print(
"WARNING: loadout struct missing in '%s'\n",
filename);
1411 else if (defname ==
"decoy") {
1421 else if (defname ==
"probe") {
1431 else if (defname ==
"sensor") {
1433 Print(
"WARNING: sensor struct missing in '%s'\n",
filename);
1441 else if (defname ==
"nav") {
1451 else if (defname ==
"computer") {
1453 Print(
"WARNING: computer struct missing in '%s'\n",
filename);
1461 else if (defname ==
"shield") {
1463 Print(
"WARNING: shield struct missing in '%s'\n",
filename);
1471 else if (defname ==
"death_spiral") {
1473 Print(
"WARNING: death spiral struct missing in '%s'\n",
filename);
1481 else if (defname ==
"map") {
1491 else if (defname ==
"squadron") {
1493 Print(
"WARNING: squadron struct missing in '%s'\n",
filename);
1501 else if (defname ==
"skin") {
1512 Print(
"WARNING: unknown parameter '%s' in '%s'\n",
1526 float output = 1000.0f;
1528 Vec3 loc(0.0f, 0.0f, 0.0f);
1545 if (defname ==
"type") {
1556 else if (defname ==
"name") {
1560 else if (defname ==
"abrv") {
1564 else if (defname ==
"design") {
1568 else if (defname ==
"max_output") {
1571 else if (defname ==
"fuel_range") {
1575 else if (defname ==
"loc") {
1577 loc *= (float)
scale;
1579 else if (defname ==
"size") {
1581 size *= (float)
scale;
1583 else if (defname ==
"hull_factor") {
1587 else if (defname ==
"explosion") {
1591 else if (defname ==
"emcon_1") {
1595 else if (defname ==
"emcon_2") {
1599 else if (defname ==
"emcon_3") {
1609 source->
Mount(loc, size, hull);
1612 if (design_name.
length()) {
1618 if (emcon_1 >= 0 && emcon_1 <= 100)
1621 if (emcon_2 >= 0 && emcon_2 <= 100)
1624 if (emcon_3 >= 0 && emcon_3 <= 100)
1639 float dthrust = 1.0f;
1641 float dscale = 1.0f;
1642 Vec3 loc(0.0f, 0.0f, 0.0f);
1658 if (defname ==
"type") {
1677 else if (defname ==
"name") {
1679 Print(
"WARNING: invalid or missing name for drive in '%s'\n",
filename);
1682 else if (defname ==
"abrv") {
1684 Print(
"WARNING: invalid or missing abrv for drive in '%s'\n",
filename);
1687 else if (defname ==
"design") {
1689 Print(
"WARNING: invalid or missing design for drive in '%s'\n",
filename);
1692 else if (defname ==
"thrust") {
1694 Print(
"WARNING: invalid or missing thrust for drive in '%s'\n",
filename);
1697 else if (defname ==
"augmenter") {
1699 Print(
"WARNING: invalid or missing augmenter for drive in '%s'\n",
filename);
1702 else if (defname ==
"scale") {
1704 Print(
"WARNING: invalid or missing scale for drive in '%s'\n",
filename);
1707 else if (defname ==
"port") {
1709 float flare_scale = 0;
1714 flare_scale = dscale;
1728 else if (pdef2->
name()->
value() ==
"scale") {
1734 if (flare_scale <= 0)
1735 flare_scale = dscale;
1741 drive->
AddPort(port, flare_scale);
1744 else if (defname ==
"loc") {
1746 Print(
"WARNING: invalid or missing loc for drive in '%s'\n",
filename);
1747 loc *= (float)
scale;
1750 else if (defname ==
"size") {
1752 Print(
"WARNING: invalid or missing size for drive in '%s'\n",
filename);
1753 size *= (float)
scale;
1756 else if (defname ==
"hull_factor") {
1758 Print(
"WARNING: invalid or missing hull_factor for drive in '%s'\n",
filename);
1761 else if (defname ==
"explosion") {
1763 Print(
"WARNING: invalid or missing explosion for drive in '%s'\n",
filename);
1766 else if (defname ==
"emcon_1") {
1770 else if (defname ==
"emcon_2") {
1774 else if (defname ==
"emcon_3") {
1778 else if (defname ==
"trail" || defname ==
"show_trail") {
1788 drive->
Mount(loc, size, hull);
1793 if (design_name.
length()) {
1799 if (emcon_1 >= 0 && emcon_1 <= 100)
1802 if (emcon_2 >= 0 && emcon_2 <= 100)
1805 if (emcon_3 >= 0 && emcon_3 <= 100)
1817 double capacity = 250e3;
1818 double consumption = 1e3;
1819 Vec3 loc(0.0f, 0.0f, 0.0f);
1822 float countdown = 5.0f;
1837 if (defname ==
"design") {
1840 else if (defname ==
"abrv") {
1843 else if (defname ==
"type") {
1851 else if (defname ==
"capacity") {
1854 else if (defname ==
"consumption") {
1857 else if (defname ==
"loc") {
1859 loc *= (float)
scale;
1861 else if (defname ==
"size") {
1863 size *= (float)
scale;
1865 else if (defname ==
"hull_factor") {
1868 else if (defname ==
"jump_time") {
1871 else if (defname ==
"countdown") {
1875 else if (defname ==
"emcon_1") {
1879 else if (defname ==
"emcon_2") {
1883 else if (defname ==
"emcon_3") {
1891 drive->
Mount(loc, size, hull);
1894 if (design_name.
length()) {
1903 if (emcon_1 >= 0 && emcon_1 <= 100)
1906 if (emcon_2 >= 0 && emcon_2 <= 100)
1909 if (emcon_3 >= 0 && emcon_3 <= 100)
1921 double capacity = 300e3;
1922 double consumption = 15e3;
1925 Vec3 loc(0.0f, 0.0f, 0.0f);
1926 Vec3 start(0.0f, 0.0f, 0.0f);
1927 Vec3 end(0.0f, 0.0f, 0.0f);
1940 if (defname ==
"design") {
1943 else if (defname ==
"capacity") {
1946 else if (defname ==
"consumption") {
1949 else if (defname ==
"loc") {
1951 loc *= (float)
scale;
1953 else if (defname ==
"size") {
1955 size *= (float)
scale;
1957 else if (defname ==
"hull_factor") {
1961 else if (defname ==
"start") {
1963 start *= (float)
scale;
1965 else if (defname ==
"end") {
1967 end *= (float)
scale;
1969 else if (defname ==
"approach") {
1972 approach[napproach++] *= (float)
scale;
1975 Print(
"WARNING: farcaster approach point ignored in '%s' (max=%d)\n",
1980 else if (defname ==
"emcon_1") {
1984 else if (defname ==
"emcon_2") {
1988 else if (defname ==
"emcon_3") {
1996 caster->
Mount(loc, size, hull);
1998 if (design_name.
length()) {
2007 for (
int i = 0; i < napproach; i++)
2010 if (emcon_1 >= 0 && emcon_1 <= 100)
2013 if (emcon_2 >= 0 && emcon_2 <= 100)
2016 if (emcon_3 >= 0 && emcon_3 <= 100)
2028 Print(
"WARNING: additional thruster ignored in '%s'\n",
filename);
2032 double thrust = 100;
2034 Vec3 loc(0.0f, 0.0f, 0.0f);
2038 float tscale = 1.0f;
2053 if (defname ==
"type") {
2073 else if (defname ==
"thrust") {
2077 else if (defname ==
"design") {
2081 else if (defname ==
"loc") {
2083 loc *= (float)
scale;
2085 else if (defname ==
"size") {
2087 size *= (float)
scale;
2089 else if (defname ==
"hull_factor") {
2092 else if (defname ==
"scale") {
2097 float port_scale = 0;
2103 port_scale = tscale;
2117 else if (pdef2->
name()->
value() ==
"fire") {
2121 else if (pdef2->
name()->
value() ==
"scale") {
2127 if (port_scale <= 0)
2128 port_scale = tscale;
2132 drive =
new(__FILE__,__LINE__)
Thruster(dtype, thrust, tscale);
2134 if (defname ==
"port" || defname ==
"port_bottom")
2137 else if (defname ==
"port_top")
2140 else if (defname ==
"port_left")
2143 else if (defname ==
"port_right")
2146 else if (defname ==
"port_fore")
2149 else if (defname ==
"port_aft")
2153 else if (defname ==
"emcon_1") {
2157 else if (defname ==
"emcon_2") {
2161 else if (defname ==
"emcon_3") {
2168 drive =
new(__FILE__,__LINE__)
Thruster(dtype, thrust, tscale);
2170 drive->
Mount(loc, size, hull);
2172 if (design_name.
length()) {
2178 if (emcon_1 >= 0 && emcon_1 <= 100)
2181 if (emcon_2 >= 0 && emcon_2 <= 100)
2184 if (emcon_3 >= 0 && emcon_3 <= 100)
2199 float dscale = 1.0f;
2200 float period = 10.0f;
2211 if (defname ==
"name")
2213 else if (defname ==
"abrv")
2216 else if (defname ==
"design") {
2220 else if (defname ==
"scale") {
2223 else if (defname ==
"period") {
2226 else if (defname ==
"light") {
2243 if (defname ==
"type") {
2246 else if (defname ==
"loc") {
2249 else if (defname ==
"pattern") {
2259 bloc[nlights] = loc *
scale;
2260 btype[nlights] = t-1;
2261 pattern[nlights] = ptn;
2276 if (design_name.
length()) {
2282 for (
int i = 0; i < nlights; i++)
2283 nav->
AddBeacon(bloc[i], pattern[i], btype[i]);
2296 float dscale = 1.0f;
2300 bool launch =
false;
2301 bool recovery =
false;
2314 float cycle_time = 0.0f;
2326 if (defname ==
"name")
2328 else if (defname ==
"abrv")
2330 else if (defname ==
"design")
2333 else if (defname ==
"start") {
2335 start *= (float)
scale;
2337 else if (defname ==
"end") {
2339 end *= (float)
scale;
2341 else if (defname ==
"cam") {
2343 cam *= (float)
scale;
2345 else if (defname ==
"box" || defname ==
"bounding_box") {
2347 box *= (float)
scale;
2349 else if (defname ==
"approach") {
2352 approach[napproach++] *= (float)
scale;
2355 Print(
"WARNING: flight deck approach point ignored in '%s' (max=%d)\n",
2359 else if (defname ==
"runway") {
2361 runway[nrunway++] *= (float)
scale;
2363 else if (defname ==
"spot") {
2371 spots[nslots] *= (float)
scale;
2373 else if (d->
name()->
value() ==
"filter") {
2384 spots[nslots] *= (float)
scale;
2385 filters[nslots++] = 0xf;
2389 else if (defname ==
"light") {
2393 else if (defname ==
"cycle_time") {
2397 else if (defname ==
"launch") {
2401 else if (defname ==
"recovery") {
2405 else if (defname ==
"azimuth") {
2407 if (degrees) az *= (float)
DEGREES;
2410 else if (defname ==
"loc") {
2412 loc *= (float)
scale;
2414 else if (defname ==
"size") {
2416 size *= (float)
scale;
2418 else if (defname ==
"hull_factor") {
2421 else if (defname ==
"explosion") {
2428 deck->
Mount(loc, size, hull);
2432 if (design_name.
length()) {
2453 for (
int i = 0; i < napproach; i++)
2456 for (
int i = 0; i < nrunway; i++)
2459 for (
int i = 0; i < nslots; i++)
2460 deck->
AddSlot(spots[i], filters[i]);
2487 if (defname ==
"name")
2489 else if (defname ==
"abrv")
2492 else if (defname ==
"design") {
2496 else if (defname ==
"gear") {
2506 ZeroMemory(mod_name,
sizeof(mod_name));
2514 if (defname ==
"model") {
2517 else if (defname ==
"start") {
2520 else if (defname ==
"end") {
2529 Print(
"WARNING: Could not load landing gear model '%s'\n", mod_name);
2535 start[ngear] = v1 *
scale;
2536 end[ngear] = v2 *
scale;
2552 if (design_name.
length()) {
2558 for (
int i = 0; i < ngear; i++)
2574 Vec3 loc(0.0f, 0.0f, 0.0f);
2579 float az_max = 1e6f;
2580 float az_min = 1e6f;
2581 float el_max = 1e6f;
2582 float el_min = 1e6f;
2583 float az_rest = 1e6f;
2584 float el_rest = 1e6f;
2596 if (defname ==
"type")
2598 else if (defname ==
"name")
2600 else if (defname ==
"abrv")
2602 else if (defname ==
"design")
2604 else if (defname ==
"group")
2607 else if (defname ==
"muzzle") {
2616 else if (defname ==
"loc") {
2618 loc *= (float)
scale;
2620 else if (defname ==
"size") {
2622 size *= (float)
scale;
2624 else if (defname ==
"hull_factor") {
2627 else if (defname ==
"azimuth") {
2629 if (degrees) az *= (float)
DEGREES;
2631 else if (defname ==
"elevation") {
2633 if (degrees) el *= (float)
DEGREES;
2636 else if (defname==(
"aim_az_max")) {
2638 if (degrees) az_max *= (float)
DEGREES;
2639 az_min = 0.0f - az_max;
2642 else if (defname==(
"aim_el_max")) {
2644 if (degrees) el_max *= (float)
DEGREES;
2645 el_min = 0.0f - el_max;
2648 else if (defname==(
"aim_az_min")) {
2650 if (degrees) az_min *= (float)
DEGREES;
2653 else if (defname==(
"aim_el_min")) {
2655 if (degrees) el_min *= (float)
DEGREES;
2658 else if (defname==(
"aim_az_rest")) {
2660 if (degrees) az_rest *= (float)
DEGREES;
2663 else if (defname==(
"aim_el_rest")) {
2665 if (degrees) el_rest *= (float)
DEGREES;
2668 else if (defname ==
"rest_azimuth") {
2670 if (degrees) az_rest *= (float)
DEGREES;
2672 else if (defname ==
"rest_elevation") {
2674 if (degrees) el_rest *= (float)
DEGREES;
2676 else if (defname ==
"explosion") {
2680 else if (defname ==
"emcon_1") {
2684 else if (defname ==
"emcon_2") {
2688 else if (defname ==
"emcon_3") {
2692 Print(
"WARNING: unknown weapon parameter '%s' in '%s'\n",
2700 Print(
"WARNING: unusual weapon name '%s' in '%s'\n", (
const char*) wtype,
filename);
2705 for (
int i = 0; i < nmuz; i++)
2706 muzzles[i] *= (
float)
scale;
2711 for (
int i = 0; i < nmuz; i++)
2712 muzzles[i] *= (
float) meta->
scale;
2715 Weapon* gun =
new(__FILE__,__LINE__)
Weapon(meta, nmuz, muzzles, az, el);
2717 gun->
Mount(loc, size, hull);
2727 if (emcon_1 >= 0 && emcon_1 <= 100)
2730 if (emcon_2 >= 0 && emcon_2 <= 100)
2733 if (emcon_3 >= 0 && emcon_3 <= 100)
2739 if (design_name.
length()) {
2745 if (group_name.
length()) {
2773 Vec3 loc(0.0f, 0.0f, 0.0f);
2789 if (defname ==
"type")
2791 else if (defname ==
"name")
2793 else if (defname ==
"abrv")
2795 else if (defname ==
"design")
2798 else if (defname ==
"muzzle") {
2800 muzzle *= (float)
scale;
2802 else if (defname ==
"loc") {
2804 loc *= (float)
scale;
2806 else if (defname ==
"size") {
2808 size *= (float)
scale;
2810 else if (defname ==
"hull_factor") {
2813 else if (defname ==
"azimuth") {
2815 if (degrees) az *= (float)
DEGREES;
2817 else if (defname ==
"elevation") {
2819 if (degrees) el *= (float)
DEGREES;
2822 else if (defname ==
"emcon_1") {
2826 else if (defname ==
"emcon_2") {
2830 else if (defname ==
"emcon_3") {
2834 Print(
"WARNING: unknown weapon parameter '%s' in '%s'\n",
2842 for (
int i = 0; i < ntypes; i++) {
2845 Print(
"WARNING: unusual weapon name '%s' in '%s'\n", (
const char*) wtypes[i],
filename);
2852 hp->
Mount(loc, size, hull);
2879 if (defname ==
"name")
2882 else if (defname ==
"stations")
2886 Print(
"WARNING: unknown loadout parameter '%s' in '%s'\n",
2900 Vec3 loc(0.0f, 0.0f, 0.0f);
2909 ZeroMemory(ranges,
sizeof(ranges));
2917 if (defname ==
"range") {
2920 else if (defname ==
"loc") {
2922 loc *= (float)
scale;
2924 else if (defname ==
"size") {
2925 size *= (float)
scale;
2928 else if (defname ==
"hull_factor") {
2931 else if (defname ==
"design") {
2934 else if (defname ==
"emcon_1") {
2938 else if (defname ==
"emcon_2") {
2942 else if (defname ==
"emcon_3") {
2951 if (design_name.
length()) {
2957 for (
int i = 0; i < nranges; i++)
2960 if (emcon_1 >= 0 && emcon_1 <= 100)
2963 if (emcon_2 >= 0 && emcon_2 <= 100)
2966 if (emcon_3 >= 0 && emcon_3 <= 100)
2973 Print(
"WARNING: additional sensor ignored in '%s'\n",
filename);
2983 Vec3 loc(0.0f, 0.0f, 0.0f);
2993 if (defname ==
"loc") {
2995 loc *= (float)
scale;
2997 else if (defname ==
"size") {
2998 size *= (float)
scale;
3001 else if (defname ==
"hull_factor") {
3004 else if (defname ==
"design")
3012 if (design_name.
length()) {
3022 Print(
"WARNING: additional nav system ignored in '%s'\n",
filename);
3031 Text comp_name(
"Computer");
3032 Text comp_abrv(
"Comp");
3035 Vec3 loc(0.0f, 0.0f, 0.0f);
3045 if (defname ==
"name") {
3048 else if (defname ==
"abrv") {
3051 else if (defname ==
"design") {
3054 else if (defname ==
"type") {
3057 else if (defname ==
"loc") {
3059 loc *= (float)
scale;
3061 else if (defname ==
"size") {
3062 size *= (float)
scale;
3065 else if (defname ==
"hull_factor") {
3072 comp->
Mount(loc, size, hull);
3076 if (design_name.
length()) {
3095 double capacity = 0;
3096 double consumption = 0;
3099 double def_cost = 1;
3100 int shield_type = 0;
3101 Vec3 loc(0.0f, 0.0f, 0.0f);
3105 bool shield_capacitor =
false;
3106 bool shield_bubble =
false;
3117 if (defname ==
"type") {
3120 else if (defname ==
"name")
3122 else if (defname ==
"abrv")
3124 else if (defname ==
"design")
3126 else if (defname ==
"model")
3129 else if (defname ==
"loc") {
3131 loc *= (float)
scale;
3133 else if (defname ==
"size") {
3135 size *= (float)
scale;
3137 else if (defname ==
"hull_factor")
3140 else if (defname.
contains(
"factor"))
3142 else if (defname.
contains(
"cutoff"))
3144 else if (defname.
contains(
"curve"))
3146 else if (defname.
contains(
"capacitor"))
3148 else if (defname.
contains(
"bubble"))
3150 else if (defname ==
"capacity")
3152 else if (defname ==
"consumption")
3154 else if (defname ==
"deflection_cost")
3156 else if (defname ==
"explosion")
3159 else if (defname ==
"emcon_1") {
3163 else if (defname ==
"emcon_2") {
3167 else if (defname ==
"emcon_3") {
3171 else if (defname ==
"bolt_hit_sound") {
3175 else if (defname ==
"beam_hit_sound") {
3189 if (design_name.
length()) {
3206 if (emcon_1 >= 0 && emcon_1 <= 100)
3209 if (emcon_2 >= 0 && emcon_2 <= 100)
3212 if (emcon_3 >= 0 && emcon_3 <= 100)
3215 if (model_name.
length()) {
3218 Print(
"ERROR: Could not load shield model '%s'\n", model_name.
data());
3253 Print(
"WARNING: additional shield ignored in '%s'\n",
filename);
3263 int debris_index = -1;
3264 int fire_index = -1;
3272 if (defname ==
"time") {
3276 else if (defname ==
"explosion") {
3278 Print(
"WARNING: explosion struct missing in '%s'\n",
filename);
3287 else if (defname ==
"explosion_type") {
3291 else if (defname ==
"explosion_time") {
3295 else if (defname ==
"explosion_loc") {
3300 else if (defname ==
"final_type") {
3305 else if (defname ==
"final_loc") {
3311 else if (defname ==
"debris") {
3317 Print(
"Could not load debris model '%s'\n", model_name.
data());
3322 PrepareModel(*model);
3327 Print(
"WARNING: debris struct missing in '%s'\n",
filename);
3335 else if (defname ==
"debris_mass") {
3339 else if (defname ==
"debris_speed") {
3343 else if (defname ==
"debris_drag") {
3347 else if (defname ==
"debris_loc") {
3352 else if (defname ==
"debris_count") {
3356 else if (defname ==
"debris_life") {
3360 else if (defname ==
"debris_fire") {
3361 if (++fire_index < 5) {
3367 else if (defname ==
"debris_fire_type") {
3387 if (defname ==
"time") {
3391 else if (defname ==
"type") {
3395 else if (defname ==
"loc") {
3400 else if (defname ==
"final") {
3421 if (defname ==
"model") {
3425 Print(
"Could not load debris model '%s'\n", model_name);
3430 PrepareModel(*model);
3434 else if (defname ==
"mass") {
3438 else if (defname ==
"speed") {
3442 else if (defname ==
"drag") {
3446 else if (defname ==
"loc") {
3451 else if (defname ==
"count") {
3455 else if (defname ==
"life") {
3459 else if (defname ==
"fire") {
3460 if (fire_index < 5) {
3467 else if (defname ==
"fire_type") {
3487 if (defname ==
"sprite") {
3519 if (defname ==
"name") {
3522 else if (defname ==
"design") {
3525 else if (defname ==
"count") {
3528 else if (defname ==
"avail") {
3535 strcpy_s(s->
name, name);
3560 if (defname ==
"name") {
3563 skin =
new(__FILE__,__LINE__)
Skin(name);
3565 else if (defname ==
"material" || defname ==
"mtl") {
3600 if (defname ==
"name") {
3603 else if (defname ==
"Ka") {
3606 else if (defname ==
"Kd") {
3609 else if (defname ==
"Ks") {
3612 else if (defname ==
"Ke") {
3615 else if (defname ==
"Ns" || defname ==
"power") {
3618 else if (defname ==
"bump") {
3621 else if (defname ==
"luminous") {
3625 else if (defname ==
"blend") {
3634 if (val ==
"alpha" || val ==
"translucent")
3637 else if (val ==
"additive")
3645 else if (defname.
indexOf(
"tex_d") == 0) {
3648 Print(
"WARNING: invalid or missing tex_diffuse in '%s'\n",
filename);
3654 else if (defname.
indexOf(
"tex_s") == 0) {
3657 Print(
"WARNING: invalid or missing tex_specular in '%s'\n",
filename);
3663 else if (defname.
indexOf(
"tex_b") == 0) {
3666 Print(
"WARNING: invalid or missing tex_bumpmap in '%s'\n",
filename);
3672 else if (defname.
indexOf(
"tex_e") == 0) {
3675 Print(
"WARNING: invalid or missing tex_emissive in '%s'\n",
filename);
3692 for (
int i = 0; i < n; i++) {
3695 if (!strcmp(s->
Name(), skin_name))