Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: Ext/Techno/Hooks.cpp
- ===================================================================
- --- Ext/Techno/Hooks.cpp (revision 989)
- +++ Ext/Techno/Hooks.cpp (working copy)
- @@ -57,9 +57,10 @@
- }
- // #617 powered units
- - if( pTypeData->PoweredBy )
- - {
- - if(!pData->PoweredUnit) pData->PoweredUnit = new PoweredUnitClass(Source, pTypeData);
- + if( pTypeData->PoweredBy.Count ) {
- + if(!pData->PoweredUnit) {
- + pData->PoweredUnit = new PoweredUnitClass(Source, pTypeData);
- + }
- pData->PoweredUnit->Update();
- }
- @@ -90,7 +91,7 @@
- */
- if(!pTheBuildingBelow || ((pTheBuildingBelow == pThis) && (pTheBuildingBelow->IsPowerOnline()))) {
- if(pData->IsOperated()) { // either does have an operator or doesn't need one, so...
- - if(pThis->Deactivated) { // ...if it's currently off, turn it on! (oooh baby)
- + if( pThis->Deactivated && pData->IsPowered() && !pThis->IsUnderEMP() ) { // ...if it's currently off, turn it on! (oooh baby)
- pThis->Reactivate();
- pThis->Owner->ShouldRecheckTechTree = true; // #885
- }
- Index: Ext/TechnoType/Body.cpp
- ===================================================================
- --- Ext/TechnoType/Body.cpp (revision 989)
- +++ Ext/TechnoType/Body.cpp (working copy)
- @@ -290,12 +290,15 @@
- this->PassengerTurret.Read(&exINI, section, "PassengerTurret");
- // #617 powered units
- - if( pINI->ReadString(section, "PoweredBy", "", Ares::readBuffer, Ares::readLength) )
- - {
- - BuildingTypeClass* bld = BuildingTypeClass::Find(Ares::readBuffer);
- -
- - if(bld) this->PoweredBy = bld;
- - else Debug::INIParseFailed(pThis->ImageFile, "PoweredBy", "BuildingType not found");
- + if( pINI->ReadString(section, "PoweredBy", "", Ares::readBuffer, Ares::readLength) ) {
- + for(char *cur = strtok(Ares::readBuffer, ","); cur; cur = strtok(NULL, ",")) {
- + BuildingTypeClass* b = BuildingTypeClass::Find(cur);
- + if(b) {
- + this->PoweredBy.AddItem(b);
- + } else {
- + Debug::INIParseFailed(pThis->ImageFile, "PoweredBy", "BuildingType not found");
- + }
- + }
- }
- // quick fix - remove after the rest of weapon selector code is done
- Index: Ext/TechnoType/Body.h
- ===================================================================
- --- Ext/TechnoType/Body.h (revision 989)
- +++ Ext/TechnoType/Body.h (working copy)
- @@ -111,7 +111,7 @@
- Valueable<bool> PassengerTurret; //!< Whether this unit's turret changes based on the number of people in its passenger hold.
- // issue #617
- - BuildingTypeClass* PoweredBy; //!< The buildingtype this unit is powered by or NULL.
- + DynamicVectorClass<BuildingTypeClass*> PoweredBy; //!< The buildingtype this unit is powered by or NULL.
- ExtData(const DWORD Canary, TT* const OwnerObject) : Extension<TT>(Canary, OwnerObject),
- Survivors_PilotChance (NULL),
- @@ -157,8 +157,7 @@
- WaterImage (NULL),
- CanBeReversed (true),
- RadarJamRadius (0),
- - PassengerTurret (false),
- - PoweredBy(NULL)
- + PassengerTurret (false)
- {
- this->Insignia.SetAll(NULL);
- *this->CameoPCX = *this->AltCameoPCX = 0;
- Index: Misc/EMPulse.cpp
- ===================================================================
- --- Misc/EMPulse.cpp (revision 989)
- +++ Misc/EMPulse.cpp (working copy)
- @@ -677,10 +677,10 @@
- */
- void EMPulse::DisableEMPEffect(TechnoClass * Victim) {
- TechnoExt::ExtData *pData = TechnoExt::ExtMap.Find(Victim);
- - bool HasPower = pData->IsPowered();
- + bool HasPower = pData->IsPowered() && pData->IsOperated();
- if (BuildingClass * Building = specific_cast<BuildingClass *>(Victim)) {
- - HasPower = Building->HasPower && !(Building->Owner->PowerDrain > Building->Owner->PowerOutput) ;
- + HasPower = HasPower && Building->IsPowerOnline(); //Building->HasPower && !(Building->Owner->PowerDrain > Building->Owner->PowerOutput) ;
- if (!Building->Type->InvisibleInGame) {
- if (HasPower) {
- Index: Misc/PoweredUnitClass.cpp
- ===================================================================
- --- Misc/PoweredUnitClass.cpp (revision 989)
- +++ Misc/PoweredUnitClass.cpp (working copy)
- @@ -9,17 +9,18 @@
- bool PoweredUnitClass::IsPoweredBy(HouseClass* Owner) const
- {
- - if(!this->Ext->PoweredBy) return true;
- -
- - for(int i = 0; i < Owner->Buildings.Count; ++i)
- - {
- - BuildingClass* Building = Owner->Buildings.GetItem(i);
- + for(int i = 0; i < Owner->Buildings.Count; ++i) {
- + BuildingClass* Building = Owner->Buildings.GetItem(i);
- + TechnoExt::ExtData* BExt = TechnoExt::ExtMap.Find(Building);
- - if( !( Building->Type != this->Ext->PoweredBy
- - || Building->IsUnderEMP()
- - || Building->BeingWarpedOut
- - || !Building->IsPowerOnline() )
- - ) return true;
- + for(int j = 0; j < this->Ext->PoweredBy.Count; ++j) {
- + if( !( Building->Type != this->Ext->PoweredBy.GetItem(j)
- + || Building->BeingWarpedOut
- + || Building->IsUnderEMP()
- + || !BExt->IsOperated()
- + || !Building->IsPowerOnline() )
- + ) return true;
- + }
- }
- return false;
- @@ -27,24 +28,21 @@
- void PoweredUnitClass::PowerUp()
- {
- - if( this->Techno->IsUnderEMP() ) return;
- - EMPulse::DisableEMPEffect(this->Techno);
- + TechnoExt::ExtData* e = TechnoExt::ExtMap.Find(this->Techno);
- + if( !this->Techno->IsUnderEMP() && e->IsOperated() ) {
- + EMPulse::DisableEMPEffect(this->Techno);
- + }
- }
- void PoweredUnitClass::PowerDown()
- {
- - if( !EMPulse::IsDeactivationAdvisable(this->Techno) || this->Techno->IsUnderEMP() ) return;
- -
- - if( !EMPulse::enableEMPEffect(this->Techno, NULL) )
- - {
- + if( EMPulse::IsDeactivationAdvisable(this->Techno) && !EMPulse::enableEMPEffect(this->Techno, NULL) ) {
- // for EMP.Threshold=inair
- - if( Ext->EMP_Threshold == -1 && this->Techno->IsInAir() )
- - {
- + if( this->Ext->EMP_Threshold == -1 && this->Techno->IsInAir() ) {
- this->Techno->Destroyed(NULL);
- this->Techno->Crash(NULL);
- - if (this->Techno->Owner == HouseClass::Player)
- - {
- + if (this->Techno->Owner == HouseClass::Player) {
- VocClass::PlayAt(this->Techno->GetTechnoType()->VoiceCrashing, &this->Techno->Location, NULL);
- }
- }
- @@ -60,8 +58,11 @@
- this->Powered = HasPower;
- - if ( HasPower && this->Techno->Deactivated ) this->PowerUp();
- - else if( !HasPower && !this->Techno->Deactivated ) this->PowerDown();
- + if(HasPower && this->Techno->Deactivated) {
- + this->PowerUp();
- + } else if(!HasPower && !this->Techno->Deactivated) {
- + this->PowerDown();
- + }
- LastScan = Unsorted::CurrentFrame;
- }
- Index: Misc/PoweredUnitClass.h
- ===================================================================
- --- Misc/PoweredUnitClass.h (revision 989)
- +++ Misc/PoweredUnitClass.h (working copy)
- @@ -19,17 +19,19 @@
- void PowerDown();
- public:
- PoweredUnitClass(TechnoClass* Techno, TechnoTypeExt::ExtData* Ext)
- - : Techno(Techno), Ext(Ext), LastScan(0), Powered(true)
- - {
- + : Techno(Techno), Ext(Ext), LastScan(0), Powered(true) {
- }
- - ~PoweredUnitClass() {}
- + ~PoweredUnitClass() {
- + }
- //!< Updates this Powered Unit's status.
- void Update();
- //!< Whether the unit has a building providing power. NOT the same as being online.
- - inline bool IsPowered() const { return this->Powered; }
- + inline bool IsPowered() const {
- + return this->Powered;
- + }
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement