Skip to content

Instantly share code, notes, and snippets.

@Xymanek
Created November 22, 2020 07:41
Show Gist options
  • Save Xymanek/81dc79232121e4c1b4f6f1e4372960c9 to your computer and use it in GitHub Desktop.
Save Xymanek/81dc79232121e4c1b4f6f1e4372960c9 to your computer and use it in GitHub Desktop.
TestPendingStateLeak
exec function TestPendingStateLeak ()
{
local XComGameState_HeadquartersAlien AlienHQ;
local XComGameStateHistory History;
local XComGameState NewGameState;
History = `XCOMHISTORY;
AlienHQ = XComGameState_HeadquartersAlien(History.GetSingleGameStateObjectForClass(class'XComGameState_HeadquartersAlien'));
`CI_Log(`showvar(AlienHQ.bChosenActive) @ "(from history without pending)");
NewGameState = class'XComGameStateContext_ChangeContainer'.static.CreateChangeState("CHEAT: TestPendingStateLeak");
AlienHQ = XComGameState_HeadquartersAlien(NewGameState.ModifyStateObject(class'XComGameState_HeadquartersAlien', AlienHQ.ObjectID));
AlienHQ.bChosenActive = !AlienHQ.bChosenActive;
`CI_Log(`showvar(AlienHQ.bChosenActive) @ "(modified)");
AlienHQ = XComGameState_HeadquartersAlien(History.GetSingleGameStateObjectForClass(class'XComGameState_HeadquartersAlien'));
`CI_Log(`showvar(AlienHQ.bChosenActive) @ "(from history with pending)");
History.CleanupPendingGameState(NewGameState);
}
// [0069.93] CI: AlienHQ.bChosenActive:'False' (from history without pending)
// [0069.93] CI: AlienHQ.bChosenActive:'True' (modified)
// [0069.93] CI: AlienHQ.bChosenActive:'True' (from history with pending)
exec function TestPendingStateLeak2 ()
{
local XComGameState_HeadquartersAlien AlienHQ;
local XComGameStateHistory History;
local XComGameState NewGameState;
History = `XCOMHISTORY;
AlienHQ = XComGameState_HeadquartersAlien(History.GetSingleGameStateObjectForClass(class'XComGameState_HeadquartersAlien'));
`CI_Log(`showvar(AlienHQ.bChosenActive) @ "(from history without pending)");
NewGameState = class'XComGameStateContext_ChangeContainer'.static.CreateChangeState("CHEAT: TestPendingStateLeak");
AlienHQ = XComGameState_HeadquartersAlien(NewGameState.ModifyStateObject(class'XComGameState_HeadquartersAlien', AlienHQ.ObjectID));
AlienHQ.bChosenActive = !AlienHQ.bChosenActive;
`CI_Log(`showvar(AlienHQ.bChosenActive) @ "(modified)");
AlienHQ = XComGameState_HeadquartersAlien(History.GetGameStateForObjectID(AlienHQ.ObjectID));
`CI_Log(`showvar(AlienHQ.bChosenActive) @ "(from history with pending)");
History.CleanupPendingGameState(NewGameState);
}
// [0067.26] CI: AlienHQ.bChosenActive:'False' (from history without pending)
// [0067.26] CI: AlienHQ.bChosenActive:'True' (modified)
// [0067.27] CI: AlienHQ.bChosenActive:'False' (from history with pending)
exec function TestPendingStateLeak3 ()
{
local XComGameState_WorldRegion RegionState;
local XComGameStateHistory History;
local XComGameState NewGameState;
History = `XCOMHISTORY;
foreach History.IterateByClassType(class'XComGameState_WorldRegion', RegionState)
{
break;
}
`CI_Log(`showvar(RegionState.bBuildingDoomFactory) @ "(from history without pending)");
NewGameState = class'XComGameStateContext_ChangeContainer'.static.CreateChangeState("CHEAT: TestPendingStateLeak");
RegionState = XComGameState_WorldRegion(NewGameState.ModifyStateObject(class'XComGameState_WorldRegion', RegionState.ObjectID));
RegionState.bBuildingDoomFactory = !RegionState.bBuildingDoomFactory;
`CI_Log(`showvar(RegionState.bBuildingDoomFactory) @ "(modified)");
RegionState = XComGameState_WorldRegion(History.GetGameStateForObjectID(RegionState.ObjectID));
`CI_Log(`showvar(RegionState.bBuildingDoomFactory) @ "(from history with pending)");
History.CleanupPendingGameState(NewGameState);
}
// [0074.47] CI: RegionState.bBuildingDoomFactory:'False' (from history without pending)
// [0074.47] CI: RegionState.bBuildingDoomFactory:'True' (modified)
// [0074.47] CI: RegionState.bBuildingDoomFactory:'False' (from history with pending)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment