summary refs log tree commit diff
diff options
context:
space:
mode:
m---------lib/gfz0
-rw-r--r--src/Game.h10
-rw-r--r--src/GameDraw.cpp13
-rw-r--r--src/GameInitDispose.cpp5
-rw-r--r--src/GameLoop.cpp28
-rw-r--r--src/GameTick.cpp2
-rw-r--r--src/main.zig1
7 files changed, 10 insertions, 49 deletions
diff --git a/lib/gfz b/lib/gfz
-Subproject c4d5e7dccfdfa102f1aeb39074789ce3d51dac9
+Subproject 63f402e1bc8b9bf790a890d6b3ab86c7a9e61a4
diff --git a/src/Game.h b/src/Game.h
index 7e27345..363cfcc 100644
--- a/src/Game.h
+++ b/src/Game.h
@@ -63,13 +63,6 @@ class Game {
 	XYZ aimBot(int);
 	void setListener(XYZ&);
 public:
-	// Event loop
-	float gamespeed;
-	float multiplier2, multiplier3, multiplier4, multiplier5;
-	float framespersecond;
-	float sps;
-	int maxfps;
-
 	// Graphics
 	int screenwidth, screenheight;
 	float viewdistance;
@@ -124,7 +117,6 @@ public:
 
 	bool lasersight;
 	bool debug;
-	bool vblsync;
 
 	bool blur;
 	bool blurness;
@@ -179,7 +171,7 @@ public:
 
 	// GL functions
 	GLvoid ReSizeGLScene(float fov, float near);
-	int DrawGLScene();
+	void DrawGLScene();
 	void LoadingScreen(float percent);
 
 	// Game functions
diff --git a/src/GameDraw.cpp b/src/GameDraw.cpp
index 9848232..a3d9fe7 100644
--- a/src/GameDraw.cpp
+++ b/src/GameDraw.cpp
@@ -39,7 +39,7 @@ extern float sinefluctprog;
 extern int environment;
 extern Decals decals;
 
-int Game::DrawGLScene(void)
+void Game::DrawGLScene(void)
 {
 	//Main menu
 	if (mainmenu == 1) {
@@ -1505,7 +1505,7 @@ int Game::DrawGLScene(void)
 
 		if(debug){
 
-		sprintf (string, "The framespersecond is %d out of maximum %d.",(int)framespersecond+1,maxfps);
+		sprintf (string, "FPS: %.0f", 1.0f / multiplier);
 
 		text.glPrint(10,30,string,0,.8,screenwidth,screenheight);
 
@@ -1530,14 +1530,5 @@ int Game::DrawGLScene(void)
 		text.glPrint(10,80,string,0,.8,screenwidth,screenheight);
 
 		}
-
-		/*
-		sprintf (string, "");
-
-		text.glPrint(10,80,string,0,.8,screenwidth,screenheight);
-		*/
-
 	}
-
-	return 1;
 }
diff --git a/src/GameInitDispose.cpp b/src/GameInitDispose.cpp
index c5c803e..40b6c58 100644
--- a/src/GameInitDispose.cpp
+++ b/src/GameInitDispose.cpp
@@ -70,7 +70,6 @@ Game* makeGame(Config config)
 	auto game = new Game();
 	game->screenwidth = config.width;
 	game->screenheight = config.height;
-	game->vblsync = config.vsync;
 	game->blurness = config.blur;
 	blood = config.blood;
 
@@ -105,8 +104,6 @@ Game* makeGame(Config config)
 			ipstream2.close();
 		}
 
-		game->sps = 40;
-		game->maxfps = 90;
 		game->disttest = true;
 		game->cubetest = true;
 	}
@@ -716,7 +713,6 @@ void initGame(Game* game)
 
 	// Setup random seed
 	srand(time(NULL));
-	game->gamespeed = 1;
 
 	// Setup block models
 	if (!game->initialized) {
@@ -1797,7 +1793,6 @@ void initGame(Game* game)
 	decals.howmanydecals=0;
 	sprites.howmanysprites=0;
 	game->losedelay = 1;
-	game->framespersecond = 60.0f;
 }
 
 void initGl(Game* game)
diff --git a/src/GameLoop.cpp b/src/GameLoop.cpp
index 7b7c617..1691157 100644
--- a/src/GameLoop.cpp
+++ b/src/GameLoop.cpp
@@ -201,29 +201,11 @@ void handleKey(Game* game, int key, int action, int mods)
 void eventLoop(Game* game)
 {
 	auto start = glfwGetTime();
-	GLfloat oldmult = multiplier;
-	int colaccuracy = min(game->sps,
-		game->sps / game->framespersecond + 1.0f);
-	multiplier /= colaccuracy;
-	for (int i = 0; i < (int) (colaccuracy + 0.5f); i++)
-		game->Tick();
-	auto window = glfwGetCurrentContext();
-	if (game->DrawGLScene())
-		glfwSwapBuffers(window);
-	else
-		glfwSetWindowShouldClose(window, GLFW_TRUE);
-	multiplier = oldmult;
-
-	do game->framespersecond = 1.0 / (glfwGetTime() - start);
-	while (game->framespersecond > game->maxfps);
-
-	game->multiplier5 = game->multiplier4;
-	game->multiplier4 = game->multiplier3;
-	game->multiplier3 = game->multiplier2;
-	game->multiplier2 = 1 / game->framespersecond;
-	multiplier = (game->multiplier2 + game->multiplier3
-		+ game->multiplier4 + game->multiplier5) / 4.0f;
-	multiplier = min(max(multiplier, 0.00001f), 1.0f);
+	game->Tick();
+	game->DrawGLScene();
+
+	do multiplier = glfwGetTime() - start;
+	while (multiplier < 1.0f / 69);
 	if (visions == 1 && !game->mainmenu)
 		multiplier /= 3;
 	if (slomo)
diff --git a/src/GameTick.cpp b/src/GameTick.cpp
index 2e9c71a..af77e40 100644
--- a/src/GameTick.cpp
+++ b/src/GameTick.cpp
@@ -328,7 +328,7 @@ void Game::Tick()
 	if (person[1].health <= 0 || person[0].health <= 0 || killedinnocent)
 		losedelay -= multiplier / 6;
 	else
-		timeremaining -= multiplier * 25 / 40;
+		timeremaining -= multiplier;
 
 	if (timeremaining <= 0) {
 		score += ++mission * 50 + 100;
diff --git a/src/main.zig b/src/main.zig
index 2364b8e..3add1ac 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -48,6 +48,7 @@ pub fn main() !void {
                                         "Black Shades", .{}, .{});
     try window.makeCurrent();
     try window.setSizeCallback(resizeWindow);
+    try gf.swapInterval(@boolToInt(config.vsync));
     legacy.initGl(game);
 
     try window.setCursorMode(.disabled);