| 1 | /*************************************************************************** |
| 2 | treetructure.cpp - description |
| 3 | ------------------- |
| 4 | begin : july 23th, 2006 |
| 5 | copyright : (C) 2006-2007 by Duong Khang NGUYEN |
| 6 | email : neoneurone @ gmail com |
| 7 | |
| 8 | $Id: treestructure.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 "treestructure.h" |
| 26 | |
| 27 | // Global settings |
| 28 | #include "globalvar.h" |
| 29 | extern GlobalVar gVars; |
| 30 | |
| 31 | |
| 32 | /*=====================================================================*/ |
| 33 | TreeStructure::TreeStructure(): |
| 34 | Structure() |
| 35 | { |
| 36 | OPENCITY_DEBUG( "ctor" ); |
| 37 | } |
| 38 | |
| 39 | |
| 40 | /*=====================================================================*/ |
| 41 | TreeStructure::TreeStructure( |
| 42 | const OPENCITY_STRUCTURE_CODE & enumStructCode): |
| 43 | Structure( enumStructCode ) |
| 44 | { |
| 45 | OPENCITY_DEBUG( "ctor param" ); |
| 46 | |
| 47 | _eGC = OPENCITY_GRAPHIC_CODE(OC_TREE_BEGIN + rand() % (OC_TREE_END - OC_TREE_BEGIN + 1)); |
| 48 | // _eGC = gVars.gpPropertyMgr->GetGC( enumStructCode ); |
| 49 | _eType = gVars.gpPropertyMgr->GetST( enumStructCode ); |
| 50 | } |
| 51 | |
| 52 | |
| 53 | /*=====================================================================*/ |
| 54 | /* not used atm |
| 55 | TreeStructure::TreeStructure( |
| 56 | const OPENCITY_STRUCTURE_CODE & enumStructCode, |
| 57 | Structure * pMain ): |
| 58 | Structure( enumStructCode, pMain ) |
| 59 | { |
| 60 | assert( pMain != NULL ); |
| 61 | |
| 62 | _eGC = gVars.gpPropertyMgr->GetGC( enumStructCode ); |
| 63 | _eType = gVars.gpPropertyMgr->GetST( enumStructCode ); |
| 64 | } |
| 65 | */ |
| 66 | |
| 67 | |
| 68 | /*=====================================================================*/ |
| 69 | TreeStructure::~TreeStructure(){ |
| 70 | OPENCITY_DEBUG( "dtor" ); |
| 71 | } |
| 72 | |
| 73 | |
| 74 | /*=====================================================================*/ |
| 75 | /* not used atm |
| 76 | const OPENCITY_GRAPHIC_CODE |
| 77 | TreeStructure::GetNextLevelGraphicCode() const |
| 78 | { |
| 79 | // OPENCITY_DEBUG("WARNING: Inside Tree"); |
| 80 | if (_uiLevel < OC_STRUCTURE_LEVEL_MAX) |
| 81 | return (OPENCITY_GRAPHIC_CODE)(this->GetBaseGraphicCode() + ((_uiLevel+1) / 10)); |
| 82 | else |
| 83 | return _eGC; |
| 84 | } |
| 85 | */ |
| 86 | |
| 87 | |
| 88 | /*=====================================================================*/ |
| 89 | /* not used atm |
| 90 | const OPENCITY_GRAPHIC_CODE |
| 91 | TreeStructure::GetPreviousLevelGraphicCode() const |
| 92 | { |
| 93 | if (_uiLevel > OC_STRUCTURE_LEVEL_MIN) |
| 94 | return (OPENCITY_GRAPHIC_CODE)(this->GetBaseGraphicCode() + ((_uiLevel-1) / 10)); |
| 95 | else |
| 96 | return _eGC; |
| 97 | } |
| 98 | */ |
| 99 | |
| 100 | |
| 101 | /*=====================================================================*/ |
| 102 | /* not used atm |
| 103 | const bool |
| 104 | TreeStructure::LevelUp() |
| 105 | { |
| 106 | OPENCITY_GRAPHIC_CODE newGC; |
| 107 | |
| 108 | newGC = this->GetNextLevelGraphicCode(); |
| 109 | |
| 110 | if (this->Structure::LevelUp() == true) { |
| 111 | _eGC = newGC; |
| 112 | return true; |
| 113 | } |
| 114 | else { |
| 115 | return false; |
| 116 | } |
| 117 | } |
| 118 | */ |
| 119 | |
| 120 | |
| 121 | /*=====================================================================*/ |
| 122 | /* not used atm |
| 123 | const bool |
| 124 | TreeStructure::LevelDown() |
| 125 | { |
| 126 | OPENCITY_GRAPHIC_CODE newGC; |
| 127 | |
| 128 | newGC = this->GetPreviousLevelGraphicCode(); |
| 129 | |
| 130 | if (this->Structure::LevelDown() == true) { |
| 131 | _eGC = newGC; |
| 132 | return true; |
| 133 | } |
| 134 | else { |
| 135 | return false; |
| 136 | } |
| 137 | } |
| 138 | */ |
| 139 | |
| 140 | |
| 141 | /*=====================================================================*/ |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 |