ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


functions:newtid

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
functions:newtid [2017/03/19 18:20] korshunfunctions:newtid [2017/03/20 09:49] korshun
Line 9: Line 9:
 [[zdoom>UniqueTid]] is error-prone when mixed with statically allocated tid ranges. You always need to pass the correct boundaries to UniqueTid, like ''UniqueTid(2000, INT_MAX)'', making sure that no actors with tid over 2000 are spawned manually after a call to UniqueTid. Otherwise the newly spawned actor may conflict with the randomly allocated tid. [[zdoom>UniqueTid]] is error-prone when mixed with statically allocated tid ranges. You always need to pass the correct boundaries to UniqueTid, like ''UniqueTid(2000, INT_MAX)'', making sure that no actors with tid over 2000 are spawned manually after a call to UniqueTid. Otherwise the newly spawned actor may conflict with the randomly allocated tid.
  
-For example, if you have decided that player tids will range from 1000 to 1063, an incorrect call to UniqueTid like ''UniqueTid(500, 15000)'' may return tid 1008, which does not yet conflict with any of the player tids, but will do so when player 9 joins the game.+For example, if you have decided that player tids will range from 1000 to 1063, an incorrect call to UniqueTid like ''UniqueTid(500, 15000)'' or ''UniqueTid()'' may return tid 1008, which does not yet conflict with any of the player tids, but will do so when player 9 joins the game.
  
 **To correctly use UniqueTid, you need to use the same start value in the whole project.** **To correctly use UniqueTid, you need to use the same start value in the whole project.**
Line 19: Line 19:
 ==== The solution ==== ==== The solution ====
  
-NewTid is a function designed to solve both these problems. To use NewTid, you first specify the first tid it may allocate using a global #define in your project:+NewTid is a function designed to solve both these problems. To use NewTid, you first specify the first tid it may allocate using a global #define in your project, for example:
  
 <code> <code>
Line 33: Line 33:
 int tid = NewTid(); int tid = NewTid();
 Spawn("SomeActor", x, y, z, tid, angle); Spawn("SomeActor", x, y, z, tid, angle);
-<code>+</code>
  
  
  
functions/newtid.txt · Last modified: 2017/04/15 17:29 by korshun