diff --git a/10x.10x b/10x.10x
index f7935a8..797c393 100644
--- a/10x.10x
+++ b/10x.10x
@@ -18,7 +18,7 @@
remedybg.exe start-debugging
-
+ main.sln
true
Debug
diff --git a/assets/grunt_0.wav b/assets/grunt_0.wav
index fdb89a6..ccc9abf 100644
Binary files a/assets/grunt_0.wav and b/assets/grunt_0.wav differ
diff --git a/assets/grunt_1.wav b/assets/grunt_1.wav
index 5009823..47fc5fd 100644
Binary files a/assets/grunt_1.wav and b/assets/grunt_1.wav differ
diff --git a/assets/grunt_2.wav b/assets/grunt_2.wav
index ba48193..8e93474 100644
Binary files a/assets/grunt_2.wav and b/assets/grunt_2.wav differ
diff --git a/assets/grunt_3.wav b/assets/grunt_3.wav
index 0bdaebd..c1372bc 100644
Binary files a/assets/grunt_3.wav and b/assets/grunt_3.wav differ
diff --git a/build_web_debug.bat b/build_web_debug.bat
index 67cb81a..0de78bf 100644
--- a/build_web_debug.bat
+++ b/build_web_debug.bat
@@ -1,5 +1,7 @@
@echo off
+pushd %~dp0%
+
rmdir /S /q build_web
mkdir build_web
@@ -23,8 +25,10 @@ if "%1" == "NO_VALIDATION" (
echo If you want to turn graphics validation off to make web debug build faster, provide a command line argument called "NO_VALIDATION" to this build script
)
-goto :EOF
+goto :success
:error
echo Failed to build
+:success
+popd
exit /B %ERRORLEVEL%
diff --git a/build_web_release.bat b/build_web_release.bat
index edfc435..301ac74 100644
--- a/build_web_release.bat
+++ b/build_web_release.bat
@@ -1,5 +1,7 @@
@echo off
+pushd %~dp0%
+
rmdir /S /q build_web_release
mkdir build_web_release
@@ -10,8 +12,10 @@ set OUTPUT_FOLDER=build_web_release
call build_web_common.bat || goto :error
-goto :EOF
+goto :success
:error
echo Failed to build
+:success
+popd
exit /B %ERRORLEVEL%
diff --git a/main.c b/main.c
index 7d3740c..34706c4 100644
--- a/main.c
+++ b/main.c
@@ -28,6 +28,12 @@
#define SOKOL_GLES2
#endif
+#define DRWAV_ASSERT game_assert
+#define SOKOL_ASSERT game_assert
+#define STBDS_ASSERT game_assert
+#define STBI_ASSERT game_assert
+#define STBTT_assert game_assert
+
#include "utility.h"
#ifdef WINDOWS
@@ -67,11 +73,14 @@ __declspec(dllexport) uint32_t AmdPowerXpressRequestHighPerformance = 0x00000001
#pragma warning(pop)
#define STB_TRUETYPE_IMPLEMENTATION
#include "stb_truetype.h"
-#define STB_DS_IMPLEMENTATION
-#include "stb_ds.h"
#include "HandmadeMath.h"
#define DR_WAV_IMPLEMENTATION
#include "dr_wav.h"
+#define STB_DS_IMPLEMENTATION
+#include "stb_ds.h" // placed last because it includes
+
+#undef assert
+#define assert game_assert
#pragma warning(pop)
@@ -179,6 +188,8 @@ void web_arena_set_auto_align(WebArena *arena, size_t align)
#define STBSP_ADD_TO_FUNCTIONS no_ubsan
#define MD_FUNCTION no_ubsan
#include "md.h"
+#undef MD_Assert
+#define MD_Assert assert
#include "md.c"
#pragma warning(pop)
@@ -278,6 +289,12 @@ typedef struct AABB
Vec2 lower_right;
} AABB;
+typedef struct Circle
+{
+ Vec2 center;
+ float radius;
+} Circle;
+
typedef struct Quad
{
union
@@ -312,6 +329,7 @@ typedef struct AudioSample
{
float *pcm_data; // allocated by loader, must be freed
uint64_t pcm_data_length;
+ unsigned int num_channels;
} AudioSample;
typedef struct AudioPlayer
@@ -328,18 +346,19 @@ AudioPlayer playing_audio[128] = { 0 };
AudioSample load_wav_audio(const char *path)
{
- unsigned int channels;
unsigned int sampleRate;
AudioSample to_return = { 0 };
- to_return.pcm_data = drwav_open_file_and_read_pcm_frames_f32(path, &channels, &sampleRate, &to_return.pcm_data_length, 0);
- assert(channels == 1);
+ to_return.pcm_data = drwav_open_file_and_read_pcm_frames_f32(path, &to_return.num_channels, &sampleRate, &to_return.pcm_data_length, 0);
+ assert(to_return.num_channels == 1 || to_return.num_channels == 2);
assert(sampleRate == SAMPLE_RATE);
return to_return;
}
-uint64_t cursor_pcm(AudioPlayer *p)
+void cursor_pcm(AudioPlayer *p, uint64_t *integer, float *fractional)
{
- return (uint64_t)(p->cursor_time * SAMPLE_RATE);
+ double sample_time = p->cursor_time * SAMPLE_RATE;
+ *integer = (uint64_t)sample_time;
+ *fractional = (float)(sample_time - *integer);
}
float float_rand(float min, float max)
{
@@ -512,6 +531,8 @@ void generation_thread(void* my_request_voidptr)
WinAssertWithErrorCode(WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, WINHTTP_HEADER_NAME_BY_INDEX, &status_code, &status_code_size, WINHTTP_NO_HEADER_INDEX));
Log("Status code: %lu\n", status_code);
+ WinAssertWithErrorCode(status_code != 500);
+
DWORD dwSize = 0;
MD_String8List received_data_list = {0};
do
@@ -698,6 +719,23 @@ Vec2 entity_aabb_size(Entity *e)
}
}
+float entity_radius(Entity *e)
+{
+ if (e->is_character)
+ {
+ return 0.35f;
+ }
+ else if (e->is_npc)
+ {
+ return 0.5f;
+ }
+ else
+ {
+ assert(false);
+ return 0;
+ }
+}
+
Vec2 rotate_counter_clockwise(Vec2 v)
{
return V2(-v.Y, v.X);
@@ -1222,17 +1260,17 @@ Armature load_armature(MD_Arena *arena, MD_String8 binary_file, MD_String8 armat
return to_return;
}
-typedef struct CollisionCube
+typedef struct CollisionCylinder
{
- struct CollisionCube *next;
- AABB bounds;
-} CollisionCube;
+ struct CollisionCylinder *next;
+ Circle bounds;
+} CollisionCylinder;
typedef struct
{
Mesh *mesh_list;
PlacedMesh *placed_mesh_list;
- CollisionCube *collision_list;
+ CollisionCylinder *collision_list;
PlacedEntity *placed_entity_list;
} ThreeDeeLevel;
@@ -1335,13 +1373,14 @@ ThreeDeeLevel load_level(MD_Arena *arena, MD_String8 binary_file)
ser_MD_u64(&ser, &num_collision_cubes);
for(MD_u64 i = 0; i < num_collision_cubes; i++)
{
- CollisionCube *new_cube = MD_PushArray(arena, CollisionCube, 1);
+ CollisionCylinder *new_cylinder = MD_PushArray(arena, CollisionCylinder, 1);
Vec2 twodee_pos;
Vec2 size;
ser_Vec2(&ser, &twodee_pos);
ser_Vec2(&ser, &size);
- new_cube->bounds = aabb_centered(twodee_pos, size);
- MD_StackPush(out.collision_list, new_cube);
+ new_cylinder->bounds.center = twodee_pos;
+ new_cylinder->bounds.radius = (size.x + size.y) * 0.5f; // @TODO(Phillip): @Temporary
+ MD_StackPush(out.collision_list, new_cylinder);
}
// placed entities
@@ -2878,29 +2917,51 @@ float decode_normalized_float32(PixelData encoded)
void audio_stream_callback(float *buffer, int num_frames, int num_channels)
{
- assert(num_channels == 1);
+ assert(num_channels == 2);
const int num_samples = num_frames * num_channels;
double time_per_sample = 1.0 / (double)SAMPLE_RATE;
- for (int i = 0; i < num_samples; i++)
+ for (int i = 0; i < num_samples; i += num_channels)
{
- float output_frame = 0.0f;
+ float output_frames[2] = {0};
for (int audio_i = 0; audio_i < ARRLEN(playing_audio); audio_i++)
{
AudioPlayer *it = &playing_audio[audio_i];
if (it->sample != 0)
{
- if (cursor_pcm(it) >= it->sample->pcm_data_length)
+ uint64_t pcm_position_int;
+ float pcm_position_frac;
+ cursor_pcm(it, &pcm_position_int, &pcm_position_frac);
+ if (pcm_position_int + 1 >= it->sample->pcm_data_length)
{
it->sample = 0;
}
else
{
- output_frame += it->sample->pcm_data[cursor_pcm(it)]*(float)(it->volume + 1.0);
+ const int source_num_channels = it->sample->num_channels;
+ float volume = (float)(it->volume + 1.0);
+ if (source_num_channels == 1) {
+ float src = Lerp(it->sample->pcm_data[pcm_position_int], pcm_position_frac, it->sample->pcm_data[pcm_position_int + 1]) * volume;
+ output_frames[0] += src;
+ output_frames[1] += src;
+ } else if (source_num_channels == 2) {
+ float src[2];
+ src[0] = Lerp(it->sample->pcm_data[pcm_position_int * 2 + 0], pcm_position_frac, it->sample->pcm_data[(pcm_position_int + 1) * 2 + 0]) * volume;
+ src[1] = Lerp(it->sample->pcm_data[pcm_position_int * 2 + 1], pcm_position_frac, it->sample->pcm_data[(pcm_position_int + 1) * 2 + 1]) * volume;
+ output_frames[0] += src[0];
+ output_frames[1] += src[1];
+ } else {
+ assert(false);
+ }
it->cursor_time += time_per_sample*(it->pitch + 1.0);
}
}
}
- buffer[i] = output_frame;
+ if (num_channels == 1) {
+ buffer[i] = (output_frames[0] + output_frames[1]) * 0.5f;
+ } else if (num_channels == 2) {
+ buffer[i + 0] = output_frames[0];
+ buffer[i + 1] = output_frames[1];
+ }
}
}
@@ -3149,6 +3210,7 @@ void init(void)
saudio_setup(&(saudio_desc) {
.stream_cb = audio_stream_callback,
.logger.func = slog_func,
+ .num_channels = 2,
});
load_assets();
@@ -3613,6 +3675,13 @@ bool overlapping(AABB a, AABB b)
return true; // both segments overlapping
}
+bool overlapping_circle(Circle a, Circle b)
+{
+ Vec2 disp = SubV2(b.center, a.center);
+ float dist = LenV2(disp);
+ return (dist < a.radius + b.radius);
+}
+
bool has_point(AABB aabb, Vec2 point)
{
return
@@ -3863,7 +3932,7 @@ void colorquad(Quad q, Color col)
}
-Vec2 NormV2_or_zero(Vec2 v)
+Vec2 NozV2(Vec2 v)
{
if(v.x == 0.0f && v.y == 0.0f)
{
@@ -3877,7 +3946,7 @@ Vec2 NormV2_or_zero(Vec2 v)
Quad line_quad(Vec2 from, Vec2 to, float line_width)
{
- Vec2 normal = rotate_counter_clockwise(NormV2_or_zero(SubV2(to, from)));
+ Vec2 normal = rotate_counter_clockwise(NozV2(SubV2(to, from)));
return (Quad){
.points = {
@@ -3926,7 +3995,7 @@ void dbgbigsquare(Vec2 at)
{
#ifdef DEVTOOLS
if (!show_devtools) return;
- colorquad(quad_centered(at, V2(20.0, 20.0)), BLUE);
+ colorquad(quad_centered(at, V2(20.0, 20.0)), debug_color);
#else
(void)at;
#endif
@@ -4332,21 +4401,20 @@ Vec2 get_penetration_vector(AABB stable, AABB dynamic)
// returns new pos after moving and sliding against collidable things
Vec2 move_and_slide(MoveSlideParams p)
{
- Vec2 collision_aabb_size = entity_aabb_size(p.from);
+ float collision_radius = entity_radius(p.from);
Vec2 new_pos = AddV2(p.position, p.movement_this_frame);
- assert(collision_aabb_size.x > 0.0f);
- assert(collision_aabb_size.y > 0.0f);
- AABB at_new = aabb_centered(new_pos, collision_aabb_size);
+ assert(collision_radius > 0.0f);
+ Circle at_new = {new_pos, collision_radius};
typedef struct
{
- AABB aabb;
+ Circle circle;
Entity *e; // required
} CollisionObj;
BUFF(CollisionObj, 256) to_check = { 0 };
// add world boxes
- for(CollisionCube *cur = level_threedee.collision_list; cur; cur = cur->next)
+ for(CollisionCylinder *cur = level_threedee.collision_list; cur; cur = cur->next)
{
BUFF_APPEND(&to_check, ((CollisionObj){cur->bounds, gs.world_entity}));
}
@@ -4358,7 +4426,7 @@ Vec2 move_and_slide(MoveSlideParams p)
{
if (it != p.from && !(it->is_npc && it->dead) && !it->is_world)
{
- BUFF_APPEND(&to_check, ((CollisionObj){aabb_centered(it->pos, entity_aabb_size(it)), it}));
+ BUFF_APPEND(&to_check, ((CollisionObj){.circle.center = it->pos, .circle.radius = entity_radius(it), it}));
}
}
}
@@ -4372,7 +4440,7 @@ Vec2 move_and_slide(MoveSlideParams p)
BUFF_ITER(CollisionObj, &to_check)
{
- if (overlapping(at_new, it->aabb))
+ if (overlapping_circle(at_new, it->circle))
{
BUFF_APPEND(&actually_overlapping, *it);
}
@@ -4380,14 +4448,14 @@ Vec2 move_and_slide(MoveSlideParams p)
float smallest_distance = FLT_MAX;
- int smallest_aabb_index = 0;
+ int smallest_circle_index = 0;
int i = 0;
BUFF_ITER(CollisionObj, &actually_overlapping)
{
- float cur_dist = LenV2(SubV2(aabb_center(at_new), aabb_center(it->aabb)));
+ float cur_dist = LenV2(SubV2(at_new.center, it->circle.center));
if (cur_dist < smallest_distance) {
smallest_distance = cur_dist;
- smallest_aabb_index = i;
+ smallest_circle_index = i;
}
i++;
}
@@ -4396,11 +4464,11 @@ Vec2 move_and_slide(MoveSlideParams p)
OverlapBuff overlapping_smallest_first = { 0 };
if (actually_overlapping.cur_index > 0)
{
- BUFF_APPEND(&overlapping_smallest_first, actually_overlapping.data[smallest_aabb_index]);
+ BUFF_APPEND(&overlapping_smallest_first, actually_overlapping.data[smallest_circle_index]);
}
BUFF_ITER_I(CollisionObj, &actually_overlapping, i)
{
- if (i == smallest_aabb_index)
+ if (i == smallest_circle_index)
{
}
else
@@ -4414,7 +4482,7 @@ Vec2 move_and_slide(MoveSlideParams p)
{
dbgcol(GREEN)
{
- dbgplanerect(it->aabb);
+ dbgplanerect(aabb_centered(it->circle.center, (Vec2){it->circle.radius, it->circle.radius}));
}
}
@@ -4423,21 +4491,20 @@ Vec2 move_and_slide(MoveSlideParams p)
BUFF_ITER(CollisionObj, &actually_overlapping)
dbgcol(WHITE)
- dbgplanerect(it->aabb);
+ dbgplanerect(aabb_centered(it->circle.center, (Vec2){it->circle.radius, it->circle.radius}));
BUFF_ITER(CollisionObj, &overlapping_smallest_first)
dbgcol(WHITE)
- dbgplanesquare(aabb_center(it->aabb));
+ dbgplanesquare(it->circle.center);
CollisionInfo info = { 0 };
for (int col_iter_i = 0; col_iter_i < 1; col_iter_i++)
BUFF_ITER(CollisionObj, &overlapping_smallest_first)
{
- AABB to_depenetrate_from = it->aabb;
+ Circle to_depenetrate_from = it->circle;
- Vec2 resolution_vector = get_penetration_vector(to_depenetrate_from, at_new);
- at_new.upper_left = AddV2(at_new.upper_left , resolution_vector);
- at_new.lower_right = AddV2(at_new.lower_right, resolution_vector);
+ Vec2 resolution_vector = NozV2(SubV2(at_new.center, to_depenetrate_from.center));
+ at_new.center = AddV2(to_depenetrate_from.center, MulV2F(resolution_vector, to_depenetrate_from.radius + at_new.radius));
bool happened_with_this_one = true;
if(happened_with_this_one)
@@ -4470,7 +4537,7 @@ Vec2 move_and_slide(MoveSlideParams p)
if (p.col_info_out) *p.col_info_out = info;
- Vec2 result_pos = aabb_center(at_new);
+ Vec2 result_pos = at_new.center;
return result_pos;
}
@@ -5875,7 +5942,7 @@ void frame(void)
if (it->is_npc || it->is_character)
{
if(LenV2(it->last_moved) > 0.0f && !it->killed)
- it->rotation = lerp_angle(it->rotation, dt * 8.0f, AngleOfV2(it->last_moved));
+ it->rotation = lerp_angle(it->rotation, dt * (it->quick_turning_timer > 0 ? 12.0f : 8.0f), AngleOfV2(it->last_moved));
}
if (it->is_npc)
@@ -6637,7 +6704,22 @@ ISANERROR("Don't know how to do this stuff on this platform.")
{
gs.player->last_moved = NormV2(movement);
Vec2 target_vel = MulV2F(movement, pixels_per_meter * speed);
- gs.player->vel = LerpV2(gs.player->vel, dt * 15.0f, target_vel);
+ float player_speed = LenV2(gs.player->vel);
+ float target_speed = LenV2(target_vel);
+ bool quick_turn = (player_speed < target_speed / 2) || DotV2(gs.player->vel, target_vel) < -0.707f;
+ gs.player->quick_turning_timer -= dt;
+ if (quick_turn) {
+ gs.player->quick_turning_timer = 0.125f;
+ }
+ if (quick_turn) {
+ gs.player->vel = target_vel;
+ } else { // framerate-independent smoothly transition towards target (functions as friction when target is 0)
+ gs.player->vel = SubV2(gs.player->vel, target_vel);
+ gs.player->vel = MulV2F(gs.player->vel, powf(1e-8f, dt));
+ gs.player->vel = AddV2(gs.player->vel, target_vel);
+ }
+ // printf("%f%s\n", LenV2(gs.player->vel), gs.player->quick_turning_timer > 0 ? " QUICK TURN" : "");
+
gs.player->pos = move_and_slide((MoveSlideParams) { gs.player, gs.player->pos, MulV2F(gs.player->vel, dt) });
bool should_append = false;
@@ -6908,7 +6990,27 @@ ISANERROR("Don't know how to do this stuff on this platform.")
Vec2 pos = V2(0.0, screen_size().Y);
int num_entities = 0;
ENTITIES_ITER(gs.entities) num_entities++;
- MD_String8 stats = tprint("Frametime: %.1f ms\nProcessing: %.1f ms\nGameplay processing: %.1f ms\nEntities: %d\nDraw calls: %d\nDrawn Vertices: %d\nProfiling: %s\nNumber gameplay processing loops: %d\nFlyecam: %s\nPlayer position: %f %f\n", dt*1000.0, last_frame_processing_time*1000.0, last_frame_gameplay_processing_time*1000.0, num_entities, num_draw_calls, num_vertices, profiling ? "yes" : "no", num_timestep_loops, flycam ? "yes" : "no", v2varg(gs.player->pos));
+ MD_String8 stats =
+ tprint("Frametime: %.1f ms\n"
+ "Processing: %.1f ms\n"
+ "Gameplay processing: %.1f ms\n"
+ "Entities: %d\n"
+ "Draw calls: %d\n"
+ "Drawn Vertices: %d\n"
+ "Profiling: %s\n"
+ "Number gameplay processing loops: %d\n"
+ "Flycam: %s\n"
+ "Player position: %f %f\n",
+ dt*1000.0,
+ last_frame_processing_time*1000.0,
+ last_frame_gameplay_processing_time*1000.0,
+ num_entities,
+ num_draw_calls,
+ num_vertices,
+ profiling ? "yes" : "no",
+ num_timestep_loops,
+ flycam ? "yes" : "no",
+ v2varg(gs.player->pos));
AABB bounds = draw_text((TextParams) { true, stats, pos, BLACK, 1.0f });
pos.Y -= bounds.upper_left.Y - screen_size().Y;
bounds = draw_text((TextParams) { true, stats, pos, BLACK, 1.0f });
diff --git a/main.sln b/main.sln
new file mode 100644
index 0000000..a810336
--- /dev/null
+++ b/main.sln
@@ -0,0 +1,32 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.6.33723.286
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{911E67C6-3D85-4FCE-B560-20A9C3E3FF48}") = "main", "main.exe", "{AA54BC1E-3360-4F83-9947-C1A78675D72C}"
+ ProjectSection(DebuggerProjectSystem) = preProject
+ PortSupplier = 00000000-0000-0000-0000-000000000000
+ Executable = .\main.exe
+ StartingDirectory = .\
+ Environment = Default
+ LaunchingEngine = 00000000-0000-0000-0000-000000000000
+ UseLegacyDebugEngines = No
+ LaunchSQLEngine = No
+ AttachLaunchAction = No
+ IORedirection = Auto
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {AA54BC1E-3360-4F83-9947-C1A78675D72C}.Release|x64.ActiveCfg = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {8FA0C944-81FC-4BE6-A866-162F58D74D4F}
+ EndGlobalSection
+EndGlobal
diff --git a/makeprompt.h b/makeprompt.h
index 41857f0..dac5a6e 100644
--- a/makeprompt.h
+++ b/makeprompt.h
@@ -219,6 +219,7 @@ typedef struct Entity
// fields for all gs.entities
Vec2 pos;
Vec2 last_moved;
+ float quick_turning_timer;
float rotation;
Vec2 vel; // only used sometimes, like in old man and bullet
float damage; // at 1.0, dead! zero initialized
diff --git a/server/go.mod b/server/go.mod
index 07d4bcf..691ce3c 100644
--- a/server/go.mod
+++ b/server/go.mod
@@ -3,13 +3,24 @@ module github.com/creikey/rpgpt/server
go 1.19
require (
+ github.com/dustin/go-humanize v1.0.1 // indirect
+ github.com/glebarez/go-sqlite v1.21.2 // indirect
+ github.com/glebarez/sqlite v1.9.0 // indirect
+ github.com/google/uuid v1.3.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
+ github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-sqlite3 v1.14.16 // indirect
+ github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/sashabaranov/go-gpt3 v1.2.1 // indirect
github.com/sashabaranov/go-openai v1.5.8 // indirect
github.com/stripe/stripe-go/v72 v72.122.0 // indirect
github.com/stripe/stripe-go/v74 v74.13.0 // indirect
+ golang.org/x/sys v0.7.0 // indirect
gorm.io/driver/sqlite v1.4.4 // indirect
- gorm.io/gorm v1.24.6 // indirect
+ gorm.io/gorm v1.25.2 // indirect
+ modernc.org/libc v1.22.5 // indirect
+ modernc.org/mathutil v1.5.0 // indirect
+ modernc.org/memory v1.5.0 // indirect
+ modernc.org/sqlite v1.23.1 // indirect
)
diff --git a/server/go.sum b/server/go.sum
index 2489ef7..e342be8 100644
--- a/server/go.sum
+++ b/server/go.sum
@@ -1,14 +1,27 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
+github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
+github.com/glebarez/go-sqlite v1.21.2 h1:3a6LFC4sKahUunAmynQKLZceZCOzUthkRkEAl9gAXWo=
+github.com/glebarez/go-sqlite v1.21.2/go.mod h1:sfxdZyhQjTM2Wry3gVYWaW072Ri1WMdWJi0k6+3382k=
+github.com/glebarez/sqlite v1.9.0 h1:Aj6bPA12ZEx5GbSF6XADmCkYXlljPNUY+Zf1EQxynXs=
+github.com/glebarez/sqlite v1.9.0/go.mod h1:YBYCoyupOao60lzp1MVBLEjZfgkq0tdB1voAQ09K9zw=
+github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
+github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
+github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
+github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
+github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
+github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/sashabaranov/go-gpt3 v1.2.1 h1:kfU+vQ1ThI7p+xfwwJC8olEEEWjK3smgKZ3FcYbaLRQ=
github.com/sashabaranov/go-gpt3 v1.2.1/go.mod h1:BIZdbwdzxZbCrcKGMGH6u2eyGe1xFuX9Anmh3tCP8lQ=
github.com/sashabaranov/go-openai v1.5.8 h1:EfNEmc+Ue+CuRy7iSpNdxfHyiOv2vQsQ2Y0kZRA/z5w=
@@ -27,6 +40,9 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
+golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@@ -39,3 +55,13 @@ gorm.io/driver/sqlite v1.4.4/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2e
gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/gorm v1.24.6 h1:wy98aq9oFEetsc4CAbKD2SoBCdMzsbSIvSUUFJuHi5s=
gorm.io/gorm v1.24.6/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
+gorm.io/gorm v1.25.2 h1:gs1o6Vsa+oVKG/a9ElL3XgyGfghFfkKA2SInQaCyMho=
+gorm.io/gorm v1.25.2/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
+modernc.org/libc v1.22.5 h1:91BNch/e5B0uPbJFgqbxXuOnxBQjlS//icfQEGmvyjE=
+modernc.org/libc v1.22.5/go.mod h1:jj+Z7dTNX8fBScMVNRAYZ/jF91K8fdT2hYMThc3YjBY=
+modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ=
+modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
+modernc.org/memory v1.5.0 h1:N+/8c5rE6EqugZwHii4IFsaJ7MUhoWX07J5tC/iI5Ds=
+modernc.org/memory v1.5.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
+modernc.org/sqlite v1.23.1 h1:nrSBg4aRQQwq59JpvGEQ15tNxoO5pX/kUjcRNwSAGQM=
+modernc.org/sqlite v1.23.1/go.mod h1:OrDj17Mggn6MhE+iPbBNf7RGKODDE9NFT0f3EwDzJqk=
diff --git a/server/main.go b/server/main.go
index 8e0a0e7..2d6d7b3 100644
--- a/server/main.go
+++ b/server/main.go
@@ -19,7 +19,7 @@ import (
"github.com/stripe/stripe-go/v74/checkout/session"
"gorm.io/gorm"
- "gorm.io/driver/sqlite"
+ "github.com/glebarez/sqlite"
"github.com/creikey/rpgpt/server/codes"
)
diff --git a/utility.h b/utility.h
index 6e59483..dc00fab 100644
--- a/utility.h
+++ b/utility.h
@@ -4,29 +4,43 @@
#include
#ifdef WEB
-//#include
#include
-#endif
+#define game_debugbreak() raise(SIGTRAP)
+
+#define game_assert_4127_push
+#define game_assert_4127_pop
-static void assert_impl(bool cond, const char *expression)
-{
- if(!cond)
- {
- fprintf(stderr, "Assertion failed: %s\n", expression);
-#ifdef WEB
- raise(SIGTRAP);
- //assert(false);
#elif defined(DESKTOP)
- __debugbreak();
+#define game_debugbreak() __debugbreak()
+
+#define game_assert_4127_push __pragma(warning(push)) __pragma(warning(disable:4127))
+#define game_assert_4127_pop __pragma(warning(pop))
+
#else
#error "Don't know how to assert for current platform configuration"
+#define game_debugbreak() (void)(0)
#endif
- }
+
+static void assert_impl(const char *func, const char *file, long line, const char *expression)
+{
+ fprintf(stderr, "Assert fail in %s(%s:%ld):\n \"%s\"\n", func, file, line, expression);
}
+
+#ifdef NDEBUG
+#define game_assert(cond) game_assert_4127_push do { (void)0; } while (0) game_assert_4127_pop
+#else
+#define game_assert(cond) game_assert_4127_push do { \
+ if (!(cond)) { \
+ assert_impl(__func__, __FILE__, __LINE__, #cond); \
+ game_debugbreak(); \
+ } \
+} while (0) game_assert_4127_pop
+#endif
+
+
#ifdef assert
#undef assert
#endif
+#define assert game_assert
-#define assert(cond) assert_impl(cond, #cond)
-
-#define Log(...) { printf("%s Log %d | ", __FILE__, __LINE__); printf(__VA_ARGS__); }
\ No newline at end of file
+#define Log(...) { printf("%s Log %d | ", __FILE__, __LINE__); printf(__VA_ARGS__); }