ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


multiple_return_values

This is an old revision of the document!


Multiple return values

ACSUtils uses a simple convention for functions returning multiple values, like RotateVector:

There are global variables r1 through r8. The functions write their return values to them.

  RotateVector(x, y, angle); // Call the function
  int newX = r1; // Get the first returned value
  int newY = r2; // And the second one
You should retrieve the return values as soon as possible, or else they may get overwritten by other functions that return multiple values.

Don't do this:

SomeFunctionWithMultipleReturns(...);
SomeOtherFunction(r1);
int x = r2;

Because SomeOtherFunction can call functions that overwrite r2!!!

Instead do this:

SomeFunctionWithMultipleReturns(...);
int a = r1;
int b = r2;

SomeOtherFunction(a);

multiple_return_values.1489765949.txt.gz · Last modified: 2017/03/17 17:52 by korshun