I search for solutions in this order: Past Code, Unreal Source, Wiki, BUF, groups.yahoo, google, screaming at monitor. – RegularX

Legacy talk:TriggeredTexture

From Unreal Wiki, The Unreal Engine Documentation Site
Revision as of 04:39, 2 December 2021 by SeriousBarbie (Talk | contribs) (+Reported on [https://github.com/OldUnreal/UnrealTournamentPatches/issues/612 GitHub] ~~~~)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

ScriptWarning if 10 textures used[edit]

Recently I noticed a ScriptWarning:

ScriptWarning: TriggeredTexture MH-TwinTower(SB)-Rev2.TriggeredTexture1
(Function Botpack.TriggeredTexture.Trigger:0046)
Accessed array out of bounds (10/10)

I had a look at the code and found the problem:

var() Texture	Textures[10];
...
event Trigger( Actor Other, Pawn EventInstigator )
{
	if( bTriggerOnceOnly && (Textures[CurrentTexture + 1] == None || CurrentTexture == 9) )
		return;
 
	CurrentTexture++;
	if( Textures[CurrentTexture] == None || CurrentTexture == 10 )
		CurrentTexture = 0;
}

If 10 textures are used and the last texture has been choosen, CurrentTexture has the value of 9. With the next function call CurrentTexture will be increased to 10 ("CurrentTexture++") and then the condition

Textures[CurrentTexture] == None

is evaluated. At this moment, the array is accessed at index 10, which does not exist.

--SeriousBarbie 05:01, 5 April 2015 (UTC)

Reported on GitHub. --SeriousBarbie 12:38, 2 December 2021 (MET)