| 1 | /*************************************************************************** |
| 2 | rcistructure.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: rcistructure.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 "rcistructure.h" |
| 26 | |
| 27 | // Global settings |
| 28 | #include "globalvar.h" |
| 29 | extern GlobalVar gVars; |
| 30 | |
| 31 | |
| 32 | /*=====================================================================*/ |
| 33 | RCIStructure::RCIStructure(): |
| 34 | Structure() |
| 35 | { |
| 36 | OPENCITY_DEBUG( "ctor" ); |
| 37 | } |
| 38 | |
| 39 | |
| 40 | /*=====================================================================*/ |
| 41 | RCIStructure::RCIStructure( |
| 42 | const OPENCITY_STRUCTURE_CODE & enumStructCode): |
| 43 | Structure( enumStructCode ) |
| 44 | { |
| 45 | OPENCITY_DEBUG( "ctor param" ); |
| 46 | |
| 47 | _eGC = gVars.gpPropertyMgr->GetGC( enumStructCode ); |
| 48 | _eType = gVars.gpPropertyMgr->GetST( enumStructCode ); |
| 49 | } |
| 50 | |
| 51 | |
| 52 | /*=====================================================================*/ |
| 53 | RCIStructure::RCIStructure( |
| 54 | const OPENCITY_STRUCTURE_CODE & enumStructCode, |
| 55 | Structure * pMain ): |
| 56 | Structure( enumStructCode, pMain ) |
| 57 | { |
| 58 | assert( pMain != NULL ); |
| 59 | |
| 60 | _eGC = gVars.gpPropertyMgr->GetGC( enumStructCode ); |
| 61 | _eType = gVars.gpPropertyMgr->GetST( enumStructCode ); |
| 62 | } |
| 63 | |
| 64 | |
| 65 | /*=====================================================================*/ |
| 66 | RCIStructure::~RCIStructure(){ |
| 67 | OPENCITY_DEBUG( "dtor" ); |
| 68 | } |
| 69 | |
| 70 | |
| 71 | /*=====================================================================*/ |
| 72 | const OPENCITY_GRAPHIC_CODE |
| 73 | RCIStructure::GetNextLevelGraphicCode() const |
| 74 | { |
| 75 | // OPENCITY_DEBUG( "WARNING: Inside RCI - Level/Next - " << _uiLevel << "/" << (_uiLevel+1) / 10 ); |
| 76 | if (_uiLevel < OC_STRUCTURE_LEVEL_MAX) |
| 77 | return (OPENCITY_GRAPHIC_CODE)(this->GetBaseGraphicCode() + ((_uiLevel+1) / OC_STRUCTURE_LEVEL_RATIO)); |
| 78 | else |
| 79 | return _eGC; |
| 80 | } |
| 81 | |
| 82 | |
| 83 | /*=====================================================================*/ |
| 84 | const OPENCITY_GRAPHIC_CODE |
| 85 | RCIStructure::GetPreviousLevelGraphicCode() const |
| 86 | { |
| 87 | if (_uiLevel > OC_STRUCTURE_LEVEL_MIN) |
| 88 | return (OPENCITY_GRAPHIC_CODE)(this->GetBaseGraphicCode() + ((_uiLevel-1) / OC_STRUCTURE_LEVEL_RATIO)); |
| 89 | else |
| 90 | return _eGC; |
| 91 | } |
| 92 | |
| 93 | |
| 94 | /*=====================================================================*/ |
| 95 | const bool |
| 96 | RCIStructure::LevelUp() |
| 97 | { |
| 98 | OPENCITY_GRAPHIC_CODE newGC; |
| 99 | |
| 100 | newGC = this->GetNextLevelGraphicCode(); |
| 101 | |
| 102 | if (this->Structure::LevelUp() == true) { |
| 103 | _eGC = newGC; |
| 104 | return true; |
| 105 | } |
| 106 | else { |
| 107 | return false; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | |
| 112 | /*=====================================================================*/ |
| 113 | const bool |
| 114 | RCIStructure::LevelDown() |
| 115 | { |
| 116 | OPENCITY_GRAPHIC_CODE newGC; |
| 117 | |
| 118 | newGC = this->GetPreviousLevelGraphicCode(); |
| 119 | |
| 120 | if (this->Structure::LevelDown() == true) { |
| 121 | _eGC = newGC; |
| 122 | return true; |
| 123 | } |
| 124 | else { |
| 125 | return false; |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | |
| 130 | /*=====================================================================*/ |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 |