ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


source_port_detection
no way to compare when less than two revisions

Differences

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


source_port_detection [2019/08/26 03:54] (current) – created korshun
Line 1: Line 1:
 +====== Source port detection ======
 +
 +===== Introduction =====
 +
 +You can identify what engine your mod is running in using ACSUtils. This may be useful to avoid using features if they're not present in the engine your mod is running in.
 +
 +<note important>Don't use these functions to check for renderer. Use [[renderer_identification|IsOpenGL]]!</note>
 +
 +===== Functions =====
 +
 +==== Is<Port> ====
 +
 +  * ''bool IsZDoom()'' -- returns true if the mod is running in ZDoom, but not GZDoom or Zandronum.
 +  * ''bool IsGZDoom()'' -- returns true if the mod is running in GZDoom or a GZDoom-based engine like Zandronum.
 +  * ''bool IsZandronum()'' -- returns true if the mod is running in Zandronum.
 +
 +==== IdentifySourcePort ====
 +
 +''int IdentifySourcePort()'' -- returns the exact source port the mod is running in. It can be one of the following constants:
 +  * ''PORT_ZDOOM'' -- ZDoom
 +  * ''PORT_GZDOOM'' - GZDoom
 +  * ''PORT_ZANDRONUM'' -- Zandronum
 +
 +
 +
 +===== How it works =====
 +
 +First, [[zan>GetPlayerAccountName]] is called. It's a Zandronum-exclusive function. It always returns a string (usually an empty string) if it's implemented, while unimplemented ACS functions return 0. Thus, if the function returned something other than zero, it is supported by the engine, and the port is assumed to be Zandronum.
 +
 +If the port is not Zandronum, an attempt to spawn an actor of type [[zdoom>Classes:DynamicLight|DynamicLight]] is performed. This actor is only present in GZDoom-based engines, but not in ZDoom. If the actor spawns successfully, it's immediately removed and the port is assumed to be GZDoom.
 +
 +If both these checks fail, the port is assumed to be ZDoom.
 +
 +To avoid rerunning these checks every time you call one of the source port identification functions, they are only run the first time any of the functions is called and the result is stored into a map variable. Subsequent function calls simply read the map variable.
 +
  
source_port_detection.txt · Last modified: 2019/08/26 03:54 by korshun