UE1 - UT Stack for coders

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Zur

surrealistic mad cow
Jul 8, 2002
11,708
8
38
48
Just a quick post to let you all know about theses classes made for coders.

Stack for Unreal Tournament 4.36
================================

Version: 1.0 (20090205)

[ About ]

Stack is container structure for programmers that allows you to store information in a sort of pile and retrieve information, unit by unit. Unlike a classical stack, there is no limit to how many objects can be added besides the physical memory a computer has. It can be used to store large amounts of incoming data or as a sort of buffer.

Feel free to adapt this to other Unreal Engine games.

[ Instructions ]

The package contains two test mutators. Stack.TestMutator simply tests the different methods of a Stack while Stack.LogFloodSimulator shows how a Stack could be used to buffer output to a log file.

To run the tests, simply drop Stack.u and Stack.int in your System folder. The first test will finish running as soon as you enter the game while the second test can be interrupted at any time. The results can be seen in UnrealTournament.log.

There are actually a few structures available. Stack is the abstract class from which others are derived from. FILOStack and FIFOStack function as their name suggests (First-In Last-Out and First-In Last-Out respectively).

As for RecyclingFILOStack and RecyclingFIFOStack, they use SEInstanceRecycler internally to recycle StackElements and avoid using memory up unnecessarily. This is useful because UT's garbage collector only runs at the end of a game. It is recommended that you use these two classes in your projects.

The methods/functions available for stack are :

isEmpty(), returns boolean Indicates whether the Stack is empty or not
push( Object anObject ) Add an object to the Stack
pop() Retrieve an object from the Stack
reset() Resets the Stack
getSize(), returns int Gets the Stack size
getNumInstances(), returns int Get the number of StackElement instances used

To use this in your script, simply copy the UC files provided in the source folder. You can use Stack directly in any of your classes. To instantiate a Stack, proceed as follows :

local RecyclingFIFOStack rc;

rc = new class'RecyclingFIFOStack';

If you wish to store primitive data types (int, string, float, etc), create a class containing the variables which you want to work with. LogMsg.uc shows how this can be done.

Refer to the test mutator on how to instantiate a custom class and to store it in Stack. Note that typecasting can be necessary when you retrive an object from a Stack to access it's functions.

[ Important note ]

It is highly advise to clear any references to stored objects at the end of a game (in Mutator HandleEndGame() for example) so UT's garbage collection can do it's work. Otherwise, these objects will continue to exist during a servertravel and quite possibly causing a crash.

[ Thanks ]

Wormbo for suggesting recycling instances. I finally got round to figuring out how this could be done.

[ Contact ]

If you have any suggestions or comments, send an e-mail to iamfearlessATgmailDOTcom. I can also be found at unrealadmin.org or beyondunreal.com.

James P.
aka 'Azura'
January 2009.
 

Attachments

  • Stack.zip
    18.1 KB · Views: 4