Fixed compiling
Build Dusk / run-tests (push) Failing after 15s
Build Dusk / run-tests (push) Failing after 15s
This commit is contained in:
@@ -33,6 +33,8 @@ void timeUpdate(void) {
|
|||||||
TIME.dynamicTime += TIME.dynamicDelta;
|
TIME.dynamicTime += TIME.dynamicDelta;
|
||||||
TIME.dynamicUpdate = true;
|
TIME.dynamicUpdate = true;
|
||||||
|
|
||||||
|
printf("Time delta: %f\n", TIME.dynamicDelta);
|
||||||
|
|
||||||
assertTrue(TIME.dynamicDelta >= 0.0f, "Time delta is negative");
|
assertTrue(TIME.dynamicDelta >= 0.0f, "Time delta is negative");
|
||||||
|
|
||||||
// Is within 1ms of a full step?
|
// Is within 1ms of a full step?
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "timesdl2.h"
|
#include "timesdl2.h"
|
||||||
|
#include "assert/assert.h"
|
||||||
|
|
||||||
void timeTickSDL2(void) {
|
void timeTickSDL2(void) {
|
||||||
TIME_TICKS_LAST_SDL2 = TIME_TICKS_SDL2;
|
TIME_TICKS_LAST_SDL2 = TIME_TICKS_SDL2;
|
||||||
@@ -13,5 +14,6 @@ void timeTickSDL2(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float_t timeGetDeltaSDL2(void) {
|
float_t timeGetDeltaSDL2(void) {
|
||||||
|
assertTrue(TIME_TICKS_SDL2 >= TIME_TICKS_LAST_SDL2, "Ticks went backwards?");
|
||||||
return (float_t)(TIME_TICKS_SDL2 - TIME_TICKS_LAST_SDL2) / 1000.0f;
|
return (float_t)(TIME_TICKS_SDL2 - TIME_TICKS_LAST_SDL2) / 1000.0f;
|
||||||
}
|
}
|
||||||
+1
-1
@@ -6,6 +6,6 @@
|
|||||||
add_subdirectory(assert)
|
add_subdirectory(assert)
|
||||||
add_subdirectory(display)
|
add_subdirectory(display)
|
||||||
# add_subdirectory(rpg)
|
# add_subdirectory(rpg)
|
||||||
add_subdirectory(item)
|
# add_subdirectory(item)
|
||||||
add_subdirectory(time)
|
add_subdirectory(time)
|
||||||
add_subdirectory(util)
|
add_subdirectory(util)
|
||||||
+24
-22
@@ -32,10 +32,10 @@ static void test_timeInit(void **state) {
|
|||||||
timeInit();
|
timeInit();
|
||||||
|
|
||||||
// Inital struct is set.
|
// Inital struct is set.
|
||||||
assert_float_equal(TIME.time, TIME_STEP, 0.0001f);
|
assert_float_equal(TIME.time, DUSK_TIME_STEP, 0.0001f);
|
||||||
assert_float_equal(TIME.delta, TIME_STEP, 0.0001f);
|
assert_float_equal(TIME.delta, DUSK_TIME_STEP, 0.0001f);
|
||||||
assert_float_equal(TIME.dynamicTime, TIME_STEP, 0.0001f);
|
assert_float_equal(TIME.dynamicTime, DUSK_TIME_STEP, 0.0001f);
|
||||||
assert_float_equal(TIME.dynamicDelta, TIME_STEP, 0.0001f);
|
assert_float_equal(TIME.dynamicDelta, DUSK_TIME_STEP, 0.0001f);
|
||||||
assert_false(TIME.dynamicUpdate);
|
assert_false(TIME.dynamicUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,9 +52,11 @@ static void test_timeUpdate(void **state) {
|
|||||||
assert_true(SDL_GETTICKS_CALLED);
|
assert_true(SDL_GETTICKS_CALLED);
|
||||||
assert_true(TIME.dynamicUpdate);
|
assert_true(TIME.dynamicUpdate);
|
||||||
assert_float_equal(TIME.dynamicDelta, 0.014f, 0.0001f);
|
assert_float_equal(TIME.dynamicDelta, 0.014f, 0.0001f);
|
||||||
assert_float_equal(TIME.dynamicTime, TIME_STEP + TIME.dynamicDelta, 0.0001f);
|
assert_float_equal(
|
||||||
assert_float_equal(TIME.delta, TIME_STEP, 0.0001f); // Not changed
|
TIME.dynamicTime, DUSK_TIME_STEP + TIME.dynamicDelta, 0.0001f
|
||||||
assert_float_equal(TIME.time, TIME_STEP, 0.0001f); // Not changed
|
);
|
||||||
|
assert_float_equal(TIME.delta, DUSK_TIME_STEP, 0.0001f); // Not changed
|
||||||
|
assert_float_equal(TIME.time, DUSK_TIME_STEP, 0.0001f); // Not changed
|
||||||
|
|
||||||
// Simulate total 16ms elapsed (2ms more)
|
// Simulate total 16ms elapsed (2ms more)
|
||||||
SDL_GETTICKS_TICKS = 16;
|
SDL_GETTICKS_TICKS = 16;
|
||||||
@@ -63,9 +65,9 @@ static void test_timeUpdate(void **state) {
|
|||||||
assert_true(SDL_GETTICKS_CALLED);
|
assert_true(SDL_GETTICKS_CALLED);
|
||||||
assert_false(TIME.dynamicUpdate);
|
assert_false(TIME.dynamicUpdate);
|
||||||
assert_float_equal(TIME.dynamicDelta, 0.002f, 0.0001f);
|
assert_float_equal(TIME.dynamicDelta, 0.002f, 0.0001f);
|
||||||
assert_float_equal(TIME.dynamicTime, TIME_STEP * 2, 0.0001f);
|
assert_float_equal(TIME.dynamicTime, DUSK_TIME_STEP * 2, 0.0001f);
|
||||||
assert_float_equal(TIME.delta, TIME_STEP, 0.0001f);
|
assert_float_equal(TIME.delta, DUSK_TIME_STEP, 0.0001f);
|
||||||
assert_float_equal(TIME.time, TIME_STEP * 2, 0.0001f); // Stepped once
|
assert_float_equal(TIME.time, DUSK_TIME_STEP * 2, 0.0001f); // Stepped once
|
||||||
|
|
||||||
// Second test, half step (16 + 8)
|
// Second test, half step (16 + 8)
|
||||||
SDL_GETTICKS_TICKS = 24;
|
SDL_GETTICKS_TICKS = 24;
|
||||||
@@ -74,9 +76,9 @@ static void test_timeUpdate(void **state) {
|
|||||||
assert_true(SDL_GETTICKS_CALLED);
|
assert_true(SDL_GETTICKS_CALLED);
|
||||||
assert_true(TIME.dynamicUpdate);
|
assert_true(TIME.dynamicUpdate);
|
||||||
assert_float_equal(TIME.dynamicDelta, 0.008f, 0.0001f);
|
assert_float_equal(TIME.dynamicDelta, 0.008f, 0.0001f);
|
||||||
assert_float_equal(TIME.dynamicTime, TIME_STEP + 0.024f, 0.0001f);
|
assert_float_equal(TIME.dynamicTime, DUSK_TIME_STEP + 0.024f, 0.0001f);
|
||||||
assert_float_equal(TIME.delta, TIME_STEP, 0.0001f);
|
assert_float_equal(TIME.delta, DUSK_TIME_STEP, 0.0001f);
|
||||||
assert_float_equal(TIME.time, TIME_STEP * 2, 0.0001f);// Unchanged.
|
assert_float_equal(TIME.time, DUSK_TIME_STEP * 2, 0.0001f);// Unchanged.
|
||||||
|
|
||||||
// Third test, another half step, leading to non dynamic update
|
// Third test, another half step, leading to non dynamic update
|
||||||
SDL_GETTICKS_TICKS = 32;
|
SDL_GETTICKS_TICKS = 32;
|
||||||
@@ -85,9 +87,9 @@ static void test_timeUpdate(void **state) {
|
|||||||
assert_true(SDL_GETTICKS_CALLED);
|
assert_true(SDL_GETTICKS_CALLED);
|
||||||
assert_false(TIME.dynamicUpdate);
|
assert_false(TIME.dynamicUpdate);
|
||||||
assert_float_equal(TIME.dynamicDelta, 0.008f, 0.0001f);
|
assert_float_equal(TIME.dynamicDelta, 0.008f, 0.0001f);
|
||||||
assert_float_equal(TIME.dynamicTime, TIME_STEP + 0.032f, 0.0001f);
|
assert_float_equal(TIME.dynamicTime, DUSK_TIME_STEP + 0.032f, 0.0001f);
|
||||||
assert_float_equal(TIME.delta, TIME_STEP, 0.0001f);
|
assert_float_equal(TIME.delta, DUSK_TIME_STEP, 0.0001f);
|
||||||
assert_float_equal(TIME.time, TIME_STEP * 3, 0.0001f);
|
assert_float_equal(TIME.time, DUSK_TIME_STEP * 3, 0.0001f);
|
||||||
|
|
||||||
// Fourth test, large jump, should only step once
|
// Fourth test, large jump, should only step once
|
||||||
SDL_GETTICKS_TICKS = 100; // Simulate 100ms elapsed
|
SDL_GETTICKS_TICKS = 100; // Simulate 100ms elapsed
|
||||||
@@ -96,9 +98,9 @@ static void test_timeUpdate(void **state) {
|
|||||||
assert_true(SDL_GETTICKS_CALLED);
|
assert_true(SDL_GETTICKS_CALLED);
|
||||||
assert_false(TIME.dynamicUpdate);
|
assert_false(TIME.dynamicUpdate);
|
||||||
assert_float_equal(TIME.dynamicDelta, 0.068f, 0.0001f);
|
assert_float_equal(TIME.dynamicDelta, 0.068f, 0.0001f);
|
||||||
assert_float_equal(TIME.dynamicTime, TIME_STEP + 0.100f, 0.0001f);
|
assert_float_equal(TIME.dynamicTime, DUSK_TIME_STEP + 0.100f, 0.0001f);
|
||||||
assert_float_equal(TIME.delta, TIME_STEP, 0.0001f);
|
assert_float_equal(TIME.delta, DUSK_TIME_STEP, 0.0001f);
|
||||||
assert_float_equal(TIME.time, TIME_STEP * 4, 0.0001f);
|
assert_float_equal(TIME.time, DUSK_TIME_STEP * 4, 0.0001f);
|
||||||
|
|
||||||
// Fifth test, despite a small time passing the game should not start
|
// Fifth test, despite a small time passing the game should not start
|
||||||
// trying to run ahead
|
// trying to run ahead
|
||||||
@@ -108,9 +110,9 @@ static void test_timeUpdate(void **state) {
|
|||||||
assert_true(SDL_GETTICKS_CALLED);
|
assert_true(SDL_GETTICKS_CALLED);
|
||||||
assert_true(TIME.dynamicUpdate);
|
assert_true(TIME.dynamicUpdate);
|
||||||
assert_float_equal(TIME.dynamicDelta, 0.004f, 0.0001f);
|
assert_float_equal(TIME.dynamicDelta, 0.004f, 0.0001f);
|
||||||
assert_float_equal(TIME.dynamicTime, TIME_STEP + 0.104f, 0.0001f);
|
assert_float_equal(TIME.dynamicTime, DUSK_TIME_STEP + 0.104f, 0.0001f);
|
||||||
assert_float_equal(TIME.delta, TIME_STEP, 0.0001f);
|
assert_float_equal(TIME.delta, DUSK_TIME_STEP, 0.0001f);
|
||||||
assert_float_equal(TIME.time, TIME_STEP * 4, 0.0001f);
|
assert_float_equal(TIME.time, DUSK_TIME_STEP * 4, 0.0001f);
|
||||||
|
|
||||||
// Time can stand still if needed
|
// Time can stand still if needed
|
||||||
SDL_GETTICKS_CALLED = false;
|
SDL_GETTICKS_CALLED = false;
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ outHeader += "#define color3f(r, g, b) ((color3f_t){ r, g, b })\n"
|
|||||||
outHeader += "#define color4f(r, g, b, a) ((color4f_t){ r, g, b, a })\n"
|
outHeader += "#define color4f(r, g, b, a) ((color4f_t){ r, g, b, a })\n"
|
||||||
outHeader += "#define color3b(r, g, b) ((color3b_t){ r, g, b })\n"
|
outHeader += "#define color3b(r, g, b) ((color3b_t){ r, g, b })\n"
|
||||||
outHeader += "#define color4b(r, g, b, a) ((color4b_t){ r, g, b, a })\n\n"
|
outHeader += "#define color4b(r, g, b, a) ((color4b_t){ r, g, b, a })\n\n"
|
||||||
|
outHeader += "#define color(r, g, b, a) color4b(r, g, b, a)\n\n" # Preferred format.
|
||||||
|
outHeader += "#define colorHex(hex) color4b(((hex >> 24) & 0xFF), ((hex >> 16) & 0xFF), ((hex >> 8) & 0xFF), (hex & 0xFF))\n\n"
|
||||||
|
|
||||||
luaScript = ""
|
luaScript = ""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user