| 1 | /*************************************************************************** |
| 2 | wegstructure.cpp - description |
| 3 | ------------------- |
| 4 | begin : june 17th, 2003 |
| 5 | copyright : (C) 2003-2007 by Duong Khang NGUYEN |
| 6 | email : neoneurone @ gmail com |
| 7 | |
| 8 | $Id: wegstructure.cpp 375 2008-10-28 14:47:15Z neoneurone $ |
| 9 | ***************************************************************************/ |
| 10 | |
| 11 | /*************************************************************************** |
| 12 | * * |
| 13 | * This program is free software; you can redistribute it and/or modify * |
| 14 | * it under the terms of the GNU General Public License as published by * |
| 15 | * the Free Software Foundation; either version 2 of the License, or * |
| 16 | * any later version. * |
| 17 | * * |
| 18 | ***************************************************************************/ |
| 19 | |
| 20 | // Useful enumerations |
| 21 | #include "opencity_direction.h" |
| 22 | #include "opencity_structure_type.h" |
| 23 | |
| 24 | // OpenCity header |
| 25 | #include "wegstructure.h" |
| 26 | |
| 27 | // Global settings |
| 28 | #include "globalvar.h" |
| 29 | extern GlobalVar gVars; |
| 30 | |
| 31 | |
| 32 | /*=====================================================================*/ |
| 33 | WEGStructure::WEGStructure(): |
| 34 | Structure() |
| 35 | { |
| 36 | OPENCITY_DEBUG( "ctor" ); |
| 37 | } |
| 38 | |
| 39 | |
| 40 | /*=====================================================================*/ |
| 41 | WEGStructure::WEGStructure( |
| 42 | const OPENCITY_STRUCTURE_CODE & enumStructCode ): |
| 43 | Structure( enumStructCode ) |
| 44 | { |
| 45 | _eGC = gVars.gpPropertyMgr->GetGC( enumStructCode ); |
| 46 | _eType = gVars.gpPropertyMgr->GetST( enumStructCode ); |
| 47 | |
| 48 | // IF this is an electric plant THEN turn on the electricity bit |
| 49 | if (enumStructCode == OC_STRUCTURE_EPLANT_COAL) { |
| 50 | Set( OC_STRUCTURE_E ); |
| 51 | } else |
| 52 | if (enumStructCode == OC_STRUCTURE_EPLANT_NUCLEAR) { |
| 53 | Set( OC_STRUCTURE_E ); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | |
| 58 | /*=====================================================================*/ |
| 59 | WEGStructure::WEGStructure( |
| 60 | const OPENCITY_STRUCTURE_CODE & enumStructCode, |
| 61 | Structure * pMain ): |
| 62 | Structure( enumStructCode, pMain ) |
| 63 | { |
| 64 | assert( pMain != NULL ); |
| 65 | |
| 66 | switch (enumStructCode) { |
| 67 | case OC_STRUCTURE_PART: |
| 68 | _eGC = OC_EMPTY; |
| 69 | // If this is part of an electric plant |
| 70 | // Then turn the E bit on |
| 71 | if (pMain!= NULL) { |
| 72 | if (pMain->GetCode() == OC_STRUCTURE_EPLANT_COAL) |
| 73 | this->Set( OC_STRUCTURE_E ); |
| 74 | else if (enumStructCode == OC_STRUCTURE_EPLANT_NUCLEAR) |
| 75 | this->Set( OC_STRUCTURE_E ); |
| 76 | } |
| 77 | break; |
| 78 | |
| 79 | default: |
| 80 | OPENCITY_DEBUG( "Unknown structure" ); |
| 81 | assert(0); |
| 82 | break; |
| 83 | } |
| 84 | |
| 85 | _eType = gVars.gpPropertyMgr->GetST( enumStructCode ); |
| 86 | } |
| 87 | |
| 88 | |
| 89 | /*=====================================================================*/ |
| 90 | WEGStructure::~WEGStructure(){ |
| 91 | OPENCITY_DEBUG( "dtor" ); |
| 92 | } |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 |