From 69209c38968c6f4066a772e0a51a2928749217de Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Fri, 9 Dec 2011 19:00:23 +0000 Subject: Re-indenting the code to use standard tabs. Yes, I know this is pretty pointless, but who cares? --- Stars45/SystemDesign.cpp | 232 +++++++++++++++++++++++------------------------ 1 file changed, 116 insertions(+), 116 deletions(-) (limited to 'Stars45/SystemDesign.cpp') 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); } -- cgit v1.1