36 #define GET_DEF_BOOL(x) if(defname==(#x))GetDefBool(design->x,pdef,filename)
37 #define GET_DEF_TEXT(x) if(defname==(#x))GetDefText(design->x,pdef,filename)
38 #define GET_DEF_NUM(x) if(defname==(#x))GetDefNumber(design->x,pdef,filename)
159 Print(
"Loading Weapon Designs '%s'\n", filename);
160 LoadDesign(
"Weapons/", filename);
181 WeaponDesign::LoadDesign(
const char* path,
const char* filename,
bool mod)
188 int blocklen = loader->
LoadBuffer(filename, block,
true);
190 Parser parser(
new(__FILE__,__LINE__)
BlockReader((
const char*) block, blocklen));
191 Term* term = parser.ParseTerm();
194 Print(
"ERROR: could not parse '%s'\n", filename);
199 if (!file_type || file_type->
value() !=
"WEAPON") {
200 Print(
"ERROR: invalid weapon design file '%s'\n", filename);
211 term = parser.ParseTerm();
219 if (defname ==
"primary" ||
220 defname ==
"missile" ||
221 defname ==
"drone" ||
225 Print(
"WARNING: weapon structure missing in '%s'\n", filename);
231 design->
type = type++;
232 if (defname ==
"primary") {
236 else if (defname ==
"beam") {
246 else if (defname ==
"drone") {
247 design->
drone =
true;
255 float sound_min_dist = 1.0f;
256 float sound_max_dist = 100.0e3f;
274 else if (defname==(
"degrees")) {
278 else if (defname==(
"secret")) {
282 else if (defname==(
"aim_az_max")) {
288 else if (defname==(
"aim_el_max")) {
294 else if (defname==(
"aim_az_min")) {
299 else if (defname==(
"aim_el_min")) {
304 else if (defname==(
"aim_az_rest")) {
309 else if (defname==(
"aim_el_rest")) {
314 else if (defname==(
"spread_az")) {
319 else if (defname==(
"spread_el")) {
387 else if (defname ==
"animation") {
392 Print(
"WARNING: too many animation frames for weapon '%s' in '%s'\n",
393 (
const char*) design->
name, filename);
397 else if (defname ==
"light_color")
400 else if (defname ==
"sound_min_dist")
403 else if (defname ==
"sound_max_dist")
406 else if (defname ==
"muzzle") {
413 Print(
"WARNING: too many muzzles for weapon '%s' in '%s'\n",
414 (
const char*) design->
name, filename);
418 else if (defname ==
"attachment") {
425 Print(
"WARNING: too many attachments for weapon '%s' in '%s'\n",
426 (
const char*) design->
name, filename);
430 else if (defname ==
"eject")
433 else if (defname ==
"decoy") {
439 else if (defname ==
"damage_type") {
443 if (!_stricmp(typestr,
"normal"))
446 else if (!_stricmp(typestr,
"emp"))
449 else if (!_stricmp(typestr,
"power"))
453 Print(
"WARNING: unknown weapon damage type '%s' in '%s'\n",
459 Print(
"WARNING: parameter '%s' ignored in '%s'\n",
460 defname.
data(), filename);
464 Print(
"WARNING: term ignored in '%s'\n", filename);
493 const char* s = strrchr(t.
data(),
'/');
500 s = strrchr(t.
data(),
'\\');
516 s = strrchr(t.
data(),
'/');
523 s = strrchr(t.
data(),
'\\');
544 const char* s = strrchr(t.
data(),
'/');
551 s = strrchr(t.
data(),
'\\');
586 if (strstr(path,
"Mods") == 0)
607 design->
flak =
false;
624 mod_catalog.
append(design);
631 Print(
"WARNING: unknown definition '%s' in '%s'\n",
635 Print(
"WARNING: term ignored in '%s'\n", filename);
657 result = mod_catalog.
find(&test);
667 for (
int i = 0; i < catalog.
size(); i++) {
670 if (d->
name == name) {
675 for (
int i = 0; i < mod_catalog.
size(); i++) {
678 if (d->
name == name) {
683 Print(
"WeaponDesign: no catalog entry for design '%s', checking mods...\n", name);
693 LoadDesign(
"Mods/Weapons/", fname,
true);
695 for (
int i = 0; i < mod_catalog.
size(); i++) {
698 if (d->
name == name) {
699 Print(
"WeaponDesign: found mod weapon '%s'\n", d->
name.
data());
704 Print(
"WeaponDesign: no mod found for design '%s'\n", name);
715 for (
int i = 0; i < catalog.
size(); i++) {
720 for (
int i = 0; i < mod_catalog.
size(); i++) {
725 return designs.
size();