Advertisement
Guest User

Untitled

a guest
Feb 21st, 2011
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 7.14 KB | None | 0 0
  1. Index: Ext/Techno/Hooks.cpp
  2. ===================================================================
  3. --- Ext/Techno/Hooks.cpp    (revision 989)
  4. +++ Ext/Techno/Hooks.cpp    (working copy)
  5. @@ -57,9 +57,10 @@
  6.     }
  7.    
  8.     // #617 powered units
  9. -   if( pTypeData->PoweredBy )
  10. -   {
  11. -       if(!pData->PoweredUnit) pData->PoweredUnit = new PoweredUnitClass(Source, pTypeData);
  12. +   if( pTypeData->PoweredBy.Count ) {
  13. +       if(!pData->PoweredUnit) {
  14. +           pData->PoweredUnit = new PoweredUnitClass(Source, pTypeData);
  15. +       }
  16.         pData->PoweredUnit->Update();
  17.     }
  18.  
  19. @@ -90,7 +91,7 @@
  20.     */
  21.     if(!pTheBuildingBelow || ((pTheBuildingBelow == pThis) && (pTheBuildingBelow->IsPowerOnline()))) {
  22.         if(pData->IsOperated()) { // either does have an operator or doesn't need one, so...
  23. -           if(pThis->Deactivated) { // ...if it's currently off, turn it on! (oooh baby)
  24. +           if( pThis->Deactivated && pData->IsPowered() && !pThis->IsUnderEMP() ) { // ...if it's currently off, turn it on! (oooh baby)
  25.                 pThis->Reactivate();
  26.                 pThis->Owner->ShouldRecheckTechTree = true; // #885
  27.             }
  28. Index: Ext/TechnoType/Body.cpp
  29. ===================================================================
  30. --- Ext/TechnoType/Body.cpp (revision 989)
  31. +++ Ext/TechnoType/Body.cpp (working copy)
  32. @@ -290,12 +290,15 @@
  33.     this->PassengerTurret.Read(&exINI, section, "PassengerTurret");
  34.    
  35.     // #617 powered units
  36. -   if( pINI->ReadString(section, "PoweredBy", "", Ares::readBuffer, Ares::readLength) )
  37. -   {
  38. -       BuildingTypeClass* bld = BuildingTypeClass::Find(Ares::readBuffer);
  39. -      
  40. -       if(bld) this->PoweredBy = bld;
  41. -       else    Debug::INIParseFailed(pThis->ImageFile, "PoweredBy", "BuildingType not found");
  42. +   if( pINI->ReadString(section, "PoweredBy", "", Ares::readBuffer, Ares::readLength) ) {
  43. +       for(char *cur = strtok(Ares::readBuffer, ","); cur; cur = strtok(NULL, ",")) {
  44. +           BuildingTypeClass* b = BuildingTypeClass::Find(cur);
  45. +           if(b) {
  46. +               this->PoweredBy.AddItem(b);
  47. +           } else {
  48. +               Debug::INIParseFailed(pThis->ImageFile, "PoweredBy", "BuildingType not found");
  49. +           }
  50. +       }
  51.     }
  52.  
  53.     // quick fix - remove after the rest of weapon selector code is done
  54. Index: Ext/TechnoType/Body.h
  55. ===================================================================
  56. --- Ext/TechnoType/Body.h   (revision 989)
  57. +++ Ext/TechnoType/Body.h   (working copy)
  58. @@ -111,7 +111,7 @@
  59.         Valueable<bool> PassengerTurret; //!< Whether this unit's turret changes based on the number of people in its passenger hold.
  60.  
  61.         // issue #617
  62. -       BuildingTypeClass* PoweredBy;  //!< The buildingtype this unit is powered by or NULL.
  63. +       DynamicVectorClass<BuildingTypeClass*> PoweredBy;  //!< The buildingtype this unit is powered by or NULL.
  64.  
  65.         ExtData(const DWORD Canary, TT* const OwnerObject) : Extension<TT>(Canary, OwnerObject),
  66.             Survivors_PilotChance (NULL),
  67. @@ -157,8 +157,7 @@
  68.             WaterImage (NULL),
  69.             CanBeReversed (true),
  70.             RadarJamRadius (0),
  71. -           PassengerTurret (false),
  72. -           PoweredBy(NULL)
  73. +           PassengerTurret (false)
  74.             {
  75.                 this->Insignia.SetAll(NULL);
  76.                 *this->CameoPCX = *this->AltCameoPCX = 0;
  77. Index: Misc/EMPulse.cpp
  78. ===================================================================
  79. --- Misc/EMPulse.cpp    (revision 989)
  80. +++ Misc/EMPulse.cpp    (working copy)
  81. @@ -677,10 +677,10 @@
  82.  */
  83.  void EMPulse::DisableEMPEffect(TechnoClass * Victim) {
  84.     TechnoExt::ExtData *pData = TechnoExt::ExtMap.Find(Victim);
  85. -   bool HasPower = pData->IsPowered();
  86. +   bool HasPower = pData->IsPowered() && pData->IsOperated();
  87.  
  88.     if (BuildingClass * Building = specific_cast<BuildingClass *>(Victim)) {
  89. -       HasPower = Building->HasPower && !(Building->Owner->PowerDrain > Building->Owner->PowerOutput) ;
  90. +       HasPower = HasPower && Building->IsPowerOnline(); //Building->HasPower && !(Building->Owner->PowerDrain > Building->Owner->PowerOutput) ;
  91.  
  92.         if (!Building->Type->InvisibleInGame) {
  93.             if (HasPower) {
  94. Index: Misc/PoweredUnitClass.cpp
  95. ===================================================================
  96. --- Misc/PoweredUnitClass.cpp   (revision 989)
  97. +++ Misc/PoweredUnitClass.cpp   (working copy)
  98. @@ -9,17 +9,18 @@
  99.  
  100.  bool PoweredUnitClass::IsPoweredBy(HouseClass* Owner) const
  101.  {
  102. -   if(!this->Ext->PoweredBy) return true;
  103. -
  104. -   for(int i = 0; i < Owner->Buildings.Count; ++i)
  105. -   {
  106. -       BuildingClass* Building = Owner->Buildings.GetItem(i)
  107. +   for(int i = 0; i < Owner->Buildings.Count; ++i) {
  108. +       BuildingClass* Building  = Owner->Buildings.GetItem(i);
  109. +       TechnoExt::ExtData* BExt = TechnoExt::ExtMap.Find(Building);
  110.        
  111. -       if( !( Building->Type != this->Ext->PoweredBy
  112. -           || Building->IsUnderEMP()
  113. -           || Building->BeingWarpedOut
  114. -           || !Building->IsPowerOnline() )
  115. -         ) return true;
  116. +       for(int j = 0; j < this->Ext->PoweredBy.Count; ++j) {
  117. +           if( !( Building->Type != this->Ext->PoweredBy.GetItem(j)
  118. +               || Building->BeingWarpedOut
  119. +               || Building->IsUnderEMP()
  120. +               || !BExt->IsOperated()
  121. +               || !Building->IsPowerOnline() )
  122. +           ) return true;
  123. +       }
  124.     }
  125.    
  126.     return false;
  127. @@ -27,24 +28,21 @@
  128.  
  129.  void PoweredUnitClass::PowerUp()
  130.  {
  131. -   if( this->Techno->IsUnderEMP() ) return;
  132. -   EMPulse::DisableEMPEffect(this->Techno);
  133. +   TechnoExt::ExtData* e = TechnoExt::ExtMap.Find(this->Techno);
  134. +   if( !this->Techno->IsUnderEMP() && e->IsOperated() ) {
  135. +       EMPulse::DisableEMPEffect(this->Techno);
  136. +   }
  137.  }
  138.  
  139.  void PoweredUnitClass::PowerDown()
  140.  {
  141. -   if( !EMPulse::IsDeactivationAdvisable(this->Techno) || this->Techno->IsUnderEMP() ) return;
  142. -
  143. -   if( !EMPulse::enableEMPEffect(this->Techno, NULL) )
  144. -   {
  145. +   if( EMPulse::IsDeactivationAdvisable(this->Techno) && !EMPulse::enableEMPEffect(this->Techno, NULL) ) {
  146.         // for EMP.Threshold=inair
  147. -       if( Ext->EMP_Threshold == -1 && this->Techno->IsInAir() )
  148. -       {
  149. +       if( this->Ext->EMP_Threshold == -1 && this->Techno->IsInAir() ) {
  150.             this->Techno->Destroyed(NULL);
  151.             this->Techno->Crash(NULL);
  152.            
  153. -           if (this->Techno->Owner == HouseClass::Player)
  154. -           {
  155. +           if (this->Techno->Owner == HouseClass::Player) {
  156.                 VocClass::PlayAt(this->Techno->GetTechnoType()->VoiceCrashing, &this->Techno->Location, NULL);
  157.             }
  158.         }
  159. @@ -60,8 +58,11 @@
  160.    
  161.     this->Powered = HasPower;
  162.    
  163. -   if     (  HasPower &&  this->Techno->Deactivated ) this->PowerUp();
  164. -   else if( !HasPower && !this->Techno->Deactivated ) this->PowerDown();
  165. +   if(HasPower && this->Techno->Deactivated) {
  166. +       this->PowerUp();
  167. +   } else if(!HasPower && !this->Techno->Deactivated) {
  168. +       this->PowerDown();
  169. +   }
  170.    
  171.     LastScan = Unsorted::CurrentFrame;
  172.  }
  173. Index: Misc/PoweredUnitClass.h
  174. ===================================================================
  175. --- Misc/PoweredUnitClass.h (revision 989)
  176. +++ Misc/PoweredUnitClass.h (working copy)
  177. @@ -19,17 +19,19 @@
  178.     void PowerDown();
  179.  public:
  180.     PoweredUnitClass(TechnoClass* Techno, TechnoTypeExt::ExtData* Ext)
  181. -       : Techno(Techno), Ext(Ext), LastScan(0), Powered(true)
  182. -   {
  183. +       : Techno(Techno), Ext(Ext), LastScan(0), Powered(true) {
  184.     }
  185.    
  186. -   ~PoweredUnitClass() {}
  187. +   ~PoweredUnitClass() {
  188. +   }
  189.  
  190.     //!< Updates this Powered Unit's status.
  191.     void Update();
  192.    
  193.     //!< Whether the unit has a building providing power. NOT the same as being online.
  194. -   inline bool IsPowered() const { return this->Powered; }
  195. +   inline bool IsPowered() const {
  196. +       return this->Powered;
  197. +   }
  198.  };
  199.  
  200.  #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement