diff options
Diffstat (limited to 'Stars45/SystemDesign.cpp')
-rw-r--r-- | Stars45/SystemDesign.cpp | 232 |
1 files changed, 116 insertions, 116 deletions
diff --git a/Stars45/SystemDesign.cpp b/Stars45/SystemDesign.cpp index 8b33524..ced589d 100644 --- a/Stars45/SystemDesign.cpp +++ b/Stars45/SystemDesign.cpp @@ -1,15 +1,15 @@ /* Project Starshatter 4.5
- Destroyer Studios LLC
- Copyright © 1997-2004. All Rights Reserved.
+ Destroyer Studios LLC
+ Copyright © 1997-2004. All Rights Reserved.
- SUBSYSTEM: Stars.exe
- FILE: SystemDesign.cpp
- AUTHOR: John DiCamillo
+ SUBSYSTEM: Stars.exe
+ FILE: SystemDesign.cpp
+ AUTHOR: John DiCamillo
- OVERVIEW
- ========
- Weapon Design parameters class
+ OVERVIEW
+ ========
+ Weapon Design parameters class
*/
#include "MemDebug.h"
@@ -35,7 +35,7 @@ SystemDesign::SystemDesign() SystemDesign::~SystemDesign()
{
- components.destroy();
+ components.destroy();
}
// +--------------------------------------------------------------------+
@@ -43,109 +43,109 @@ SystemDesign::~SystemDesign() void
SystemDesign::Initialize(const char* filename)
{
- Print("Loading System Designs '%s'\n", filename);
-
- // Load Design File:
- DataLoader* loader = DataLoader::GetLoader();
- BYTE* block;
-
- int blocklen = loader->LoadBuffer(filename, block, true);
- Parser parser(new(__FILE__,__LINE__) BlockReader((const char*) block, blocklen));
- Term* term = parser.ParseTerm();
-
- if (!term) {
- Print("ERROR: could not parse '%s'\n", filename);
- exit(-3);
- }
- else {
- TermText* file_type = term->isText();
- if (!file_type || file_type->value() != "SYSTEM") {
- Print("ERROR: invalid system design file '%s'\n", filename);
- exit(-4);
- }
- }
-
- int type = 1;
-
- do {
- delete term;
-
- term = parser.ParseTerm();
-
- if (term) {
- TermDef* def = term->isDef();
- if (def) {
- if (def->name()->value() == "system") {
-
- if (!def->term() || !def->term()->isStruct()) {
- Print("WARNING: system structure missing in '%s'\n", filename);
- }
- else {
- TermStruct* val = def->term()->isStruct();
- SystemDesign* design = new(__FILE__,__LINE__) SystemDesign;
-
- for (int i = 0; i < val->elements()->size(); i++) {
- TermDef* pdef = val->elements()->at(i)->isDef();
- if (pdef) {
- GET_DEF_TEXT(pdef, design, name);
-
- else if (pdef->name()->value()==("component")) {
- if (!pdef->term() || !pdef->term()->isStruct()) {
- Print("WARNING: component structure missing in system '%s' in '%s'\n", (const char*) design->name, filename);
- }
- else {
- TermStruct* val2 = pdef->term()->isStruct();
- ComponentDesign* comp_design = new(__FILE__,__LINE__) ComponentDesign;
-
- for (int i = 0; i < val2->elements()->size(); i++) {
- TermDef* pdef2 = val2->elements()->at(i)->isDef();
- if (pdef2) {
- GET_DEF_TEXT(pdef2, comp_design, name);
- else GET_DEF_TEXT(pdef2, comp_design, abrv);
- else GET_DEF_NUM (pdef2, comp_design, repair_time);
- else GET_DEF_NUM (pdef2, comp_design, replace_time);
- else GET_DEF_NUM (pdef2, comp_design, spares);
- else GET_DEF_NUM (pdef2, comp_design, affects);
-
- else {
- Print("WARNING: parameter '%s' ignored in '%s'\n",
- pdef2->name()->value().data(), filename);
- }
- }
- }
-
- design->components.append(comp_design);
- }
- }
-
- else {
- Print("WARNING: parameter '%s' ignored in '%s'\n",
- pdef->name()->value().data(), filename);
- }
- }
- else {
- Print("WARNING: term ignored in '%s'\n", filename);
- val->elements()->at(i)->print();
- }
- }
-
- catalog.append(design);
- }
- }
-
- else
- Print("WARNING: unknown definition '%s' in '%s'\n",
- def->name()->value().data(), filename);
- }
- else {
- Print("WARNING: term ignored in '%s'\n", filename);
- term->print();
- }
- }
- }
- while (term);
-
- loader->ReleaseBuffer(block);
+ Print("Loading System Designs '%s'\n", filename);
+
+ // Load Design File:
+ DataLoader* loader = DataLoader::GetLoader();
+ BYTE* block;
+
+ int blocklen = loader->LoadBuffer(filename, block, true);
+ Parser parser(new(__FILE__,__LINE__) BlockReader((const char*) block, blocklen));
+ Term* term = parser.ParseTerm();
+
+ if (!term) {
+ Print("ERROR: could not parse '%s'\n", filename);
+ exit(-3);
+ }
+ else {
+ TermText* file_type = term->isText();
+ if (!file_type || file_type->value() != "SYSTEM") {
+ Print("ERROR: invalid system design file '%s'\n", filename);
+ exit(-4);
+ }
+ }
+
+ int type = 1;
+
+ do {
+ delete term;
+
+ term = parser.ParseTerm();
+
+ if (term) {
+ TermDef* def = term->isDef();
+ if (def) {
+ if (def->name()->value() == "system") {
+
+ if (!def->term() || !def->term()->isStruct()) {
+ Print("WARNING: system structure missing in '%s'\n", filename);
+ }
+ else {
+ TermStruct* val = def->term()->isStruct();
+ SystemDesign* design = new(__FILE__,__LINE__) SystemDesign;
+
+ for (int i = 0; i < val->elements()->size(); i++) {
+ TermDef* pdef = val->elements()->at(i)->isDef();
+ if (pdef) {
+ GET_DEF_TEXT(pdef, design, name);
+
+ else if (pdef->name()->value()==("component")) {
+ if (!pdef->term() || !pdef->term()->isStruct()) {
+ Print("WARNING: component structure missing in system '%s' in '%s'\n", (const char*) design->name, filename);
+ }
+ else {
+ TermStruct* val2 = pdef->term()->isStruct();
+ ComponentDesign* comp_design = new(__FILE__,__LINE__) ComponentDesign;
+
+ for (int i = 0; i < val2->elements()->size(); i++) {
+ TermDef* pdef2 = val2->elements()->at(i)->isDef();
+ if (pdef2) {
+ GET_DEF_TEXT(pdef2, comp_design, name);
+ else GET_DEF_TEXT(pdef2, comp_design, abrv);
+ else GET_DEF_NUM (pdef2, comp_design, repair_time);
+ else GET_DEF_NUM (pdef2, comp_design, replace_time);
+ else GET_DEF_NUM (pdef2, comp_design, spares);
+ else GET_DEF_NUM (pdef2, comp_design, affects);
+
+ else {
+ Print("WARNING: parameter '%s' ignored in '%s'\n",
+ pdef2->name()->value().data(), filename);
+ }
+ }
+ }
+
+ design->components.append(comp_design);
+ }
+ }
+
+ else {
+ Print("WARNING: parameter '%s' ignored in '%s'\n",
+ pdef->name()->value().data(), filename);
+ }
+ }
+ else {
+ Print("WARNING: term ignored in '%s'\n", filename);
+ val->elements()->at(i)->print();
+ }
+ }
+
+ catalog.append(design);
+ }
+ }
+
+ else
+ Print("WARNING: unknown definition '%s' in '%s'\n",
+ def->name()->value().data(), filename);
+ }
+ else {
+ Print("WARNING: term ignored in '%s'\n", filename);
+ term->print();
+ }
+ }
+ }
+ while (term);
+
+ loader->ReleaseBuffer(block);
}
// +--------------------------------------------------------------------+
@@ -153,7 +153,7 @@ SystemDesign::Initialize(const char* filename) void
SystemDesign::Close()
{
- catalog.destroy();
+ catalog.destroy();
}
// +--------------------------------------------------------------------+
@@ -161,8 +161,8 @@ SystemDesign::Close() SystemDesign*
SystemDesign::Find(const char* name)
{
- SystemDesign test;
- test.name = name;
- return catalog.find(&test);
+ SystemDesign test;
+ test.name = name;
+ return catalog.find(&test);
}
|