diff --git a/source/build/include/build.h b/source/build/include/build.h
index 011ae73d6..9b9898ad1 100644
--- a/source/build/include/build.h
+++ b/source/build/include/build.h
@@ -108,17 +108,6 @@ class F2DDrawer;
 
 struct HitInfoBase;
 
-inline int32_t krand(void)
-{
-    randomseed = (randomseed * 27584621) + 1;
-    return ((uint32_t) randomseed)>>16;
-}
-
-inline double krandf(double span)
-{
-    return (krand() & 0x7fff) * span / 32767;
-}
-
 inline int32_t ksqrt(uint64_t num)
 {
     return int(sqrt(double(num)));
@@ -129,14 +118,6 @@ inline constexpr uint32_t uhypsq(int32_t const dx, int32_t const dy)
     return (uint32_t)dx*dx + (uint32_t)dy*dy;
 }
 
-EXTERN_CVAR(Bool, hw_hightile)
-EXTERN_CVAR(Bool, hw_models)
-EXTERN_CVAR(Float, gl_texture_filter_anisotropic)
-EXTERN_CVAR(Int, gl_texture_filter)
-extern bool hw_int_useindexedcolortextures;
-EXTERN_CVAR(Bool, hw_useindexedcolortextures)
-EXTERN_CVAR(Bool, r_voxels)
-
 static inline int64_t compat_maybe_truncate_to_int32(int64_t val)
 {
     return enginecompatibility_mode != ENGINECOMPATIBILITY_NONE ? (int32_t)val : val;
diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h
index 22d88d87d..3bdec772d 100644
--- a/source/core/gamefuncs.h
+++ b/source/core/gamefuncs.h
@@ -6,9 +6,19 @@
 #include "coreactor.h"
 #include "intrect.h"
 #include "geometry.h"
+#include "c_cvars.h"
 
 extern IntRect viewport3d;
 
+EXTERN_CVAR(Bool, hw_hightile)
+EXTERN_CVAR(Bool, hw_models)
+EXTERN_CVAR(Float, gl_texture_filter_anisotropic)
+EXTERN_CVAR(Int, gl_texture_filter)
+extern bool hw_int_useindexedcolortextures;
+EXTERN_CVAR(Bool, hw_useindexedcolortextures)
+EXTERN_CVAR(Bool, r_voxels)
+
+
 constexpr int SLOPEVAL_FACTOR = 4096;
 
 //==========================================================================
diff --git a/source/core/models/modeldata.cpp b/source/core/models/modeldata.cpp
index 5d46ce1cd..d2dcb3730 100644
--- a/source/core/models/modeldata.cpp
+++ b/source/core/models/modeldata.cpp
@@ -3,6 +3,7 @@
 #include "modeldata.h"
 #include "texturemanager.h"
 #include "hw_voxels.h"
+#include "gamefuncs.h"
 
 #include "build.h"
 
diff --git a/source/core/precache.cpp b/source/core/precache.cpp
index 42a10aef5..ebdb1e87e 100644
--- a/source/core/precache.cpp
+++ b/source/core/precache.cpp
@@ -44,6 +44,7 @@
 #include "hw_voxels.h"
 #include "mapinfo.h"
 #include "models/modeldata.h"
+#include "gamefuncs.h"
 
 BEGIN_BLD_NS
 extern short voxelIndex[MAXTILES];
diff --git a/source/core/rendering/scene/hw_drawinfo.h b/source/core/rendering/scene/hw_drawinfo.h
index e01f0ac17..5eb8c965f 100644
--- a/source/core/rendering/scene/hw_drawinfo.h
+++ b/source/core/rendering/scene/hw_drawinfo.h
@@ -8,7 +8,7 @@
 #include "v_video.h"
 #include "hw_drawlist.h"
 #include "hw_bunchdrawer.h"
-//#include "r_viewpoint.h"
+#include "gamefuncs.h"
 
 EXTERN_CVAR(Int, hw_lightmode)
 
diff --git a/source/core/textures/hightile.cpp b/source/core/textures/hightile.cpp
index 41e5310b9..f4e7d6774 100644
--- a/source/core/textures/hightile.cpp
+++ b/source/core/textures/hightile.cpp
@@ -49,6 +49,7 @@
 #include "gamestruct.h"
 #include "hw_renderstate.h"
 #include "skyboxtexture.h"
+#include "gamefuncs.h"
 
 CVARD(Bool, hw_shadeinterpolate, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable shade interpolation")
 
diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h
index eecb5924c..93122c28b 100644
--- a/source/games/duke/src/funct.h
+++ b/source/games/duke/src/funct.h
@@ -241,6 +241,17 @@ void loadcons();
 void recordoldspritepos();
 void DrawStatusBar();
 
+inline int32_t krand(void)
+{
+	randomseed = (randomseed * 27584621) + 1;
+	return ((uint32_t)randomseed) >> 16;
+}
+
+inline double krandf(double span)
+{
+	return (krand() & 0x7fff) * span / 32767;
+}
+
 [[deprecated]]
 inline double zrand(int spread, int ofs)
 {