Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Crash addresses vary (sometimes 0000000, sometimes a random hex address), the stack is always the same, always wants to return to last version's line 126... UnInit would crash? O_O
- Only happen at unit death.
- Index: Ext/Techno/Body.cpp
- ===================================================================
- --- Ext/Techno/Body.cpp (revision 1164)
- +++ Ext/Techno/Body.cpp (working copy)
- @@ -435,6 +435,23 @@
- }
- }
- +void TechnoExt::TransferAttachedEffects(TechnoClass *From, TechnoClass *To) {
- + auto FromExt = TechnoExt::ExtMap.Find(From);
- + auto ToExt = TechnoExt::ExtMap.Find(To);
- + if (FromExt->AttachedEffects.Count != 0) {
- + ToExt->AttachedEffects.Clear();
- +
- + for (int i=0; i<FromExt->AttachedEffects.Count; i++){
- + ToExt->AttachedEffects.AddItem(FromExt->AttachedEffects.GetItem(i));
- + if (ToExt->AttachedEffects.GetItem(i)->Animation) {
- + ToExt->AttachedEffects.GetItem(i)->Animation->SetOwnerObject(To);
- + }
- + }
- + FromExt->AttachedEffects.Clear();
- + }
- +
- +}
- +
- bool TechnoExt::ExtData::IsDeactivated() const {
- return this->AttachedToObject->Deactivated;
- }
- Index: Ext/Techno/Body.h
- ===================================================================
- --- Ext/Techno/Body.h (revision 1164)
- +++ Ext/Techno/Body.h (working copy)
- @@ -20,6 +20,8 @@
- #include "../WeaponType/Body.h"
- #include "../TechnoType/Body.h"
- +#include "../../Misc/AttachEffect.h"
- +
- #include "../_Container.hpp"
- //#include "../../Misc/JammerClass.h"
- @@ -58,6 +60,8 @@
- // issue #617 powered units
- PoweredUnitClass* PoweredUnit;
- + DynamicVectorClass <AttachEffectClass *> AttachedEffects;
- +
- ExtData(const DWORD Canary, TT* const OwnerObject) : Extension<TT>(Canary, OwnerObject),
- idxSlot_Wave (0),
- idxSlot_Beam (0),
- @@ -125,6 +129,7 @@
- static void TransferMindControl(TechnoClass *From, TechnoClass *To);
- static void TransferIvanBomb(TechnoClass *From, TechnoClass *To);
- + static void TransferAttachedEffects(TechnoClass *From, TechnoClass *To);
- static void Destroy(TechnoClass* pTechno, TechnoClass* pKiller = NULL, HouseClass* pKillerHouse = NULL, WarheadTypeClass* pWarhead = NULL);
- /*
- Index: Ext/Techno/Hooks.cpp
- ===================================================================
- --- Ext/Techno/Hooks.cpp (revision 1164)
- +++ Ext/Techno/Hooks.cpp (working copy)
- @@ -64,6 +64,21 @@
- pData->PoweredUnit->Update();
- }
- + //updating attached effects
- + if (pData->AttachedEffects.Count) {
- + for (int i=pData->AttachedEffects.Count; i>0; --i) {
- + auto Effect = pData->AttachedEffects.GetItem(i-1);
- + --Effect->ActualDuration;
- + if(!Effect->ActualDuration) {
- + Debug::Log("[AttachEffect] Removing %d. item from %s", i-1, Source->GetTechnoType()->ID);
- + Effect->Destroy();
- + delete Effect;
- + pData->AttachedEffects.RemoveItem(i-1);
- + }
- +
- + }
- + }
- +
- return 0;
- }
- @@ -135,6 +150,7 @@
- }
- }
- +
- /* using 0x6F9E7C instead makes this function override the original game one's entirely -
- don't activate that unless you handle _everything_ originally handled by the game */
- return 0;
- @@ -737,5 +753,17 @@
- TechnoExt->PoweredUnit = NULL;
- }
- + //attached effects
- + if (TechnoExt->AttachedEffects.Count){
- + for (int i=TechnoExt->AttachedEffects.Count; i>0; --i) {
- + Debug::Log("[AttachEffect] Removing %d. item from %s\n", i-1, pThis->GetTechnoType()->ID);
- + TechnoExt->AttachedEffects.GetItem(i-1)->Destroy();
- + delete TechnoExt->AttachedEffects.GetItem(i-1);
- + }
- + Debug::Log("[AttachEffect] Deleting array of %s\n", pThis->GetTechnoType()->ID);
- + TechnoExt->AttachedEffects.Clear();
- +
- + }
- +
- return 0;
- }
- Index: Ext/WarheadType/Body.cpp
- ===================================================================
- --- Ext/WarheadType/Body.cpp (revision 1164)
- +++ Ext/WarheadType/Body.cpp (working copy)
- @@ -93,6 +93,8 @@
- this->KillDriver = pINI->ReadBool(section, "KillDriver", this->KillDriver);
- this->Malicious.Read(&exINI, section, "Malicious");
- +
- + this->AttachedEffect.Read(&exINI, section);
- };
- void Container<WarheadTypeExt>::InvalidatePointer(void *ptr) {
- Index: Ext/WarheadType/Body.h
- ===================================================================
- --- Ext/WarheadType/Body.h (revision 1164)
- +++ Ext/WarheadType/Body.h (working copy)
- @@ -19,6 +19,8 @@
- #include <Conversions.h>
- +#include "../../Misc/AttachEffect.h"
- +
- #include "../_Container.hpp"
- #include "../../Utilities/Template.h"
- @@ -75,6 +77,8 @@
- Valueable<bool> Malicious;
- + AttachEffectTypeClass AttachedEffect;
- +
- ExtData(const DWORD Canary, TT* const OwnerObject) : Extension<TT>(Canary, OwnerObject),
- MindControl_Permanent (false),
- Ripple_Radius (0),
- @@ -88,7 +92,8 @@
- InfDeathAnim (NULL),
- PreImpactAnim (-1),
- KillDriver (false),
- - Malicious (true)
- + Malicious (true),
- + AttachedEffect()
- {
- for(int i = 0; i < 11; ++i) {
- VersesData vs;
- Index: Ext/WarheadType/Hooks.cpp
- ===================================================================
- --- Ext/WarheadType/Hooks.cpp (revision 1164)
- +++ Ext/WarheadType/Hooks.cpp (working copy)
- @@ -56,6 +56,12 @@
- pWHExt->applyEMP(&coords, Bullet->Owner);
- WarheadTypeExt::applyOccupantDamage(Bullet);
- pWHExt->applyKillDriver(Bullet);
- +
- + if (!!pWHExt->AttachedEffect.Duration && Bullet->Target){
- + TechnoClass *Target = generic_cast<TechnoClass *>(Bullet->Target);
- + pWHExt->AttachedEffect.Attach(Target);
- + }
- +
- }
- /*
- Index: Misc/AttachEffect.cpp
- ===================================================================
- --- Misc/AttachEffect.cpp (revision 0)
- +++ Misc/AttachEffect.cpp (revision 0)
- @@ -0,0 +1,49 @@
- +#include "AttachEffect.h"
- +#include "../Ext/Techno/Body.h"
- +#include "../Ext/TechnoType/Body.h"
- +#include "../Ext/WarheadType/Body.h"
- +
- +/*
- +Attached Effects system
- +Graion Dilach, 2011-09-24+
- +Proper documentation gets done if proper code there is.
- +*/
- +
- +void AttachEffectTypeClass::Attach(TechnoClass* Target) {
- + if (!Target) {return;}
- +
- + TechnoExt::ExtData *TargetExt = TechnoExt::ExtMap.Find(Target);
- +
- +
- + if (!this->Cumulative && TargetExt->AttachedEffects.Count > 0) {
- + for (int i=0; i < TargetExt->AttachedEffects.Count; i++) {
- + if (this->ID == TargetExt->AttachedEffects.GetItem(i)->Type->ID){
- + TargetExt->AttachedEffects.GetItem(i)->ActualDuration = TargetExt->AttachedEffects.GetItem(i)->Type->Duration;
- + return;
- + }
- + }
- + }
- +
- + //there goes the actual attaching
- + auto Attaching = new AttachEffectClass(this, this->Duration);
- + TargetExt->AttachedEffects.AddItem(Attaching);
- + Debug::Log("[AttachEffect] Creating new item on %s, slot %d...\n", Target->GetTechnoType()->ID, TargetExt->AttachedEffects.GetItemIndex(&Attaching));
- + //meh, instead of index, turns out pointer adress, whatever
- +
- +
- + // animation
- + GAME_ALLOC(AnimClass, Attaching->Animation, this->AnimType, &Target->Location);
- + Attaching->Animation->SetOwnerObject(Target);
- + // inb4 void pointers, hardcode the iteration to infinitely looped
- + Attaching->Animation->RemainingIterations=-1;
- +
- +}
- +
- +void AttachEffectClass::Destroy(){
- + if (this->Animation){
- + this->Animation->SetOwnerObject(NULL);
- + this->Animation->TimeToDie = true;
- + this->Animation->UnInit();
- + this->Animation = NULL;
- + }
- +}
- \ No newline at end of file
- Index: Misc/AttachEffect.h
- ===================================================================
- --- Misc/AttachEffect.h (revision 0)
- +++ Misc/AttachEffect.h (revision 0)
- @@ -0,0 +1,51 @@
- +#ifndef ATTACHEFFECT_H_
- +#define ATTACHEFFECT_H_
- +
- +#include <vector>
- +#include <TechnoClass.h>
- +
- +#include "../Utilities/Template.h"
- +
- +
- +class AttachEffectTypeClass {
- +public:
- +
- + const char* ID;
- + Valueable<int> Duration;
- + Valueable<bool> Cumulative;
- +
- + Valueable<AnimTypeClass *> AnimType;
- +
- + virtual void Attach(TechnoClass* Target);
- +
- + AttachEffectTypeClass(){
- + this->Cumulative = false;
- + this->Duration = 0;
- + };
- +
- + void Read(INI_EX *exINI, const char * section) {
- +
- + this->ID = section;
- + this->Duration.Read(exINI, section, "AttachEffect.Duration");
- + this->Cumulative.Read(exINI, section, "AttachEffect.Cumulative");
- + this->AnimType.Parse(exINI, section, "AttachEffect.Animation");
- +
- + }
- +};
- +
- +class AttachEffectClass {
- +public:
- + AttachEffectClass(AttachEffectTypeClass* AEType, int Timer){
- + this->Type = AEType;
- + this->ActualDuration = Timer;
- + }
- +
- + AttachEffectTypeClass * Type;
- + AnimClass * Animation;
- + int ActualDuration;
- +
- + void Destroy();
- +};
- +
- +
- +#endif
- \ No newline at end of file
- Index: Misc/Bugfixes.cpp
- ===================================================================
- --- Misc/Bugfixes.cpp (revision 1164)
- +++ Misc/Bugfixes.cpp (working copy)
- @@ -905,6 +905,7 @@
- TechnoExt::TransferMindControl(pUnit, pStructure);
- TechnoExt::TransferIvanBomb(pUnit, pStructure);
- + TechnoExt::TransferAttachedEffects(pUnit, pStructure);
- pStructure->QueueMission(mission_Construction, 0);
- @@ -925,6 +926,7 @@
- TechnoExt::TransferMindControl(pStructure, pUnit);
- TechnoExt::TransferIvanBomb(pStructure, pUnit);
- + TechnoExt::TransferAttachedEffects(pStructure, pUnit);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement