Files
CHOMPStation2/code/WorkInProgress/Aryn/Lighting/_Defs.dm
Aryn 9007aedf15 Fixed an annoying bug with giving another player a flashlight,
opened up at least 100 individual bugs where people kept setting
loc and expecting light updates to catch it.
2014-03-18 22:12:23 -06:00

15 lines
751 B
Plaintext

#define SQ(X) ((X)*(X))
#define DISTSQ3(A,B,C) (SQ(A)+SQ(B)+SQ(C))
#define FSQRT(X) (X >= fastroot.len ? new_fsqrt(X) : fastroot[(X)+1])
#define MAX_VALUE(X) (X.cached_value < 0 ? X.max_value() : X.cached_value)
#define VALUE_OF(X) ( !X ? 0 : ( X.is_outside ? LIGHTCLAMP(lighting_controller.starlight) : X.lit_value ) )
#define LIGHTCLAMP(x) ( max(0,min(3,round(x,1))) )
var/list/fastroot = list(0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7)
proc/new_fsqrt(n)
//world << "Adding [n-fastroot.len] entries to root table."
for(var/i = fastroot.len, i <= n, i++)
fastroot += round(sqrt(i))