ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


new:port_detection

Differences

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

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
new:port_detection [2018/02/17 14:26] – created korshunnew:port_detection [2018/02/18 19:20] korshun
Line 5: Line 5:
 ''int IdentifySourcePort()'' ''int IdentifySourcePort()''
  
-Returns one of the following:+It returns one of the following:
  
   * ''PORT_ZDOOM''   * ''PORT_ZDOOM''
Line 15: Line 15:
   * ''bool IsGZDoom()'' -- returns true if the mod is running on an engine with GZDoom features (this includes GZDoom and Zandronum).   * ''bool IsGZDoom()'' -- returns true if the mod is running on an engine with GZDoom features (this includes GZDoom and Zandronum).
   * ''bool IsZandronum()'' -- returns true if the mod is running on Zandronum.   * ''bool IsZandronum()'' -- returns true if the mod is running on Zandronum.
 +
 +You can also display the name of the port the mod is running in using ''str GetPortName()'':
 +
 +<code>
 +print(s:"This mod is running in ", s:GetPortName());
 +</code>
 +
 +It returns one of the following: "ZDoom", "GZDoom", "Zandronum".
  
 ===== Renderer detection ===== ===== Renderer detection =====
Line 29: Line 37:
 ===== How port detection works ===== ===== How port detection works =====
  
-First, ''GetPlayerAccountName(0)'' is called. In Zandronum it returns a string (possibly empty string). In other ports it returns 0, because it's an unknown function.+First, ''GetPlayerAccountName(0)'' is called. In Zandronum it returns a string (possibly [[empty string]]). In other ports it returns 0, because it's an unknown function.
  
 Second, existence of ''DynamicLight'' actor is checked by spawning and instantly destroying it. This actor is not present in ZDoom. If it spawns successfully, the port is GZDoom. Second, existence of ''DynamicLight'' actor is checked by spawning and instantly destroying it. This actor is not present in ZDoom. If it spawns successfully, the port is GZDoom.
  
 If both checks fail, the port is ZDoom. If both checks fail, the port is ZDoom.
 +
 +Port detection is performed only once. Subsequent calls to ''IdentifySourcePort()'' just return a cached result.