diff libmlk-adventure/adventure/molko.c @ 261:bfde372bf152

core: prefix utilities with util_
author David Demelier <markand@malikania.fr>
date Sun, 06 Dec 2020 23:06:34 +0100
parents 16be1ad3ddba
children cd5bdb995052
line wrap: on
line diff
--- a/libmlk-adventure/adventure/molko.c	Sun Dec 06 22:50:48 2020 +0100
+++ b/libmlk-adventure/adventure/molko.c	Sun Dec 06 23:06:34 2020 +0100
@@ -56,34 +56,6 @@
 	longjmp(panic_buf, 1);
 }
 
-static void
-loop(void)
-{
-	struct clock clock = {0};
-
-	while (game.state) {
-		unsigned int elapsed = clock_elapsed(&clock);
-
-		clock_start(&clock);
-
-		for (union event ev; event_poll(&ev); ) {
-			switch (ev.type) {
-			case EVENT_QUIT:
-				return;
-			default:
-				game_handle(&ev);
-				break;
-			}
-		}
-
-		game_update(elapsed);
-		game_draw();
-
-		if ((elapsed = clock_elapsed(&clock)) < 20)
-			delay(20 - elapsed);
-	}
-}
-
 void
 molko_init(void)
 {
@@ -115,14 +87,14 @@
 {
 	if (setjmp(panic_buf) == 0) {
 		/* Initial game run. */
-		loop();
+		game_loop();
 	} else {
 		/* Clear event queue to avoid accidental key presses. */
 		for (union event ev; event_poll(&ev); )
 			continue;
 
 		game_switch(molko.panic, true);
-		loop();
+		game_loop();
 	}
 }
 
@@ -139,7 +111,7 @@
 	assert(file);
 
 	/* TODO: libmlk-adventure must be renamed. */
-	return pprintf("%s/libmlk-adventure/%s", sys_dir(SYS_DIR_DATA), file);
+	return util_pathf("%s/libmlk-adventure/%s", sys_dir(SYS_DIR_DATA), file);
 }
 
 void