commit 2e23c8c
uint
·
2026-08-04 14:50:35 +0000 UTC
parent 105bef5
rename MG_ERR_... -> MG_EC_...
7 files changed,
+38,
-38
+2,
-2
1@@ -308,7 +308,7 @@ void test_scene_create(Player* player, i8 server)
2 i32 z;
3
4 if (!block_textures_create("assets/resourcepacks/default"))
5- mg_die(MG_ERR_TEXTURE_LOAD, "Failed to load block textures");
6+ mg_die(MG_EC_TEXTURE_LOAD, "Failed to load block textures");
7
8 camera_init(&cam, MG_V3(8.0f, 38.0f, 24.0f));
9 cam.yaw = MG_AngleDeg(-180.0f);
10@@ -332,7 +332,7 @@ void test_scene_create(Player* player, i8 server)
11 chunk_create(&chunks[x][z]);
12
13 if (!chunk_mesh_create(&chunks[x][z]))
14- mg_die(MG_ERR_MESH_CREATE, "Failed to create chunk mesh");
15+ mg_die(MG_EC_MESH_CREATE, "Failed to create chunk mesh");
16 }
17 }
18 }
+18,
-18
1@@ -5,35 +5,35 @@
2
3 /* TODO: rename to MG_EC_... */
4 typedef enum {
5- MG_ERR_EXIT_SUCCESS,
6- MG_ERR_EXIT_FAILURE,
7+ MG_EC_EXIT_SUCCESS,
8+ MG_EC_EXIT_FAILURE,
9
10- MG_ERR_INVALID_ARGS,
11+ MG_EC_INVALID_ARGS,
12
13- MG_ERR_MCCLIENT_LOGIN,
14+ MG_EC_MCCLIENT_LOGIN,
15
16- MG_ERR_SDL_INIT,
17- MG_ERR_SDL_CREATE_WIN,
18+ MG_EC_SDL_INIT,
19+ MG_EC_SDL_CREATE_WIN,
20
21- MG_ERR_MAUS_CREATE_WIN,
22+ MG_EC_MAUS_CREATE_WIN,
23
24- MG_ERR_GL_CTX_CREATE,
25- MG_ERR_GL_CTX_ACTIVATE,
26+ MG_EC_GL_CTX_CREATE,
27+ MG_EC_GL_CTX_ACTIVATE,
28
29- MG_ERR_SHADER_CREATE,
30+ MG_EC_SHADER_CREATE,
31
32- MG_ERR_PIPELINE_CREATE,
33+ MG_EC_PIPELINE_CREATE,
34
35- MG_ERR_MESH_CREATE,
36+ MG_EC_MESH_CREATE,
37
38- MG_ERR_TEXTURE_LOAD,
39- MG_ERR_TEXTURE_CREATE,
40- MG_ERR_SAMPLER_CREATE,
41- MG_ERR_VIEW_CREATE,
42+ MG_EC_TEXTURE_LOAD,
43+ MG_EC_TEXTURE_CREATE,
44+ MG_EC_SAMPLER_CREATE,
45+ MG_EC_VIEW_CREATE,
46
47- MG_ERR_REN_CREATE,
48+ MG_EC_REN_CREATE,
49
50- MG_ERR_LAST
51+ MG_EC_LAST
52 } MGErrorCodes;
53
54 typedef enum {
+3,
-3
1@@ -69,14 +69,14 @@ int main(int argc, char** argv)
2 Player player;
3
4 if (argc != 1 && argc != 3)
5- mg_die(MG_ERR_INVALID_ARGS, "usage: %s [server[:port] username]\n", argv[0]);
6+ mg_die(MG_EC_INVALID_ARGS, "usage: %s [server[:port] username]\n", argv[0]);
7 if (argc == 3) {
8 account.username = argv[2];
9 account.profile_uuid = getenv("MANGOLIA_PROFILE_UUID");
10 account.access_token = getenv("MANGOLIA_ACCESS_TOKEN");
11
12 if (!mc_client_login(&client, argv[1], &account, error, sizeof(error)))
13- mg_die(MG_ERR_MCCLIENT_LOGIN, "%s\n", error);
14+ mg_die(MG_EC_MCCLIENT_LOGIN, "%s\n", error);
15 }
16
17 config_default();
18@@ -143,5 +143,5 @@ int main(int argc, char** argv)
19 test_scene_destroy();
20 renderer_destroy();
21 platform_shutdown(&ctx);
22- return MG_ERR_EXIT_SUCCESS;
23+ return MG_EC_EXIT_SUCCESS;
24 }
+3,
-3
1@@ -67,7 +67,7 @@ i32 platform_poll(MGContext* ctx)
2 ctx->width = (i32)ev.resize.width;
3 ctx->height = (i32)ev.resize.height;
4 if (!maus_resize(ctx->win, ev.resize.width, ev.resize.height))
5- mg_die(MG_ERR_REN_CREATE, "Failed to resize maus framebuffer");
6+ mg_die(MG_EC_REN_CREATE, "Failed to resize maus framebuffer");
7 break;
8 default:
9 break;
10@@ -113,10 +113,10 @@ void platform_window_create(MGContext* ctx)
11 platform_ctx = ctx;
12 ctx->win = maus_init(ctx->title, ctx->x, ctx->y, ctx->width, ctx->height);
13 if (!ctx->win)
14- mg_die(MG_ERR_MAUS_CREATE_WIN, "Failed to initialise maus");
15+ mg_die(MG_EC_MAUS_CREATE_WIN, "Failed to initialise maus");
16
17 if (!maus_create_window(ctx->win))
18- mg_die(MG_ERR_MAUS_CREATE_WIN, "Failed to create maus window");
19+ mg_die(MG_EC_MAUS_CREATE_WIN, "Failed to create maus window");
20 }
21
22 void platform_wait(u32 ms)
+5,
-5
1@@ -59,7 +59,7 @@ void platform_init(MGContext* ctx)
2 ctx->keys[i] = MGK_UNKNOWN;
3
4 if (SDL_Init(SDL_INIT_VIDEO) != 0)
5- mg_die(MG_ERR_SDL_INIT, "SDL_Init failed: %s", SDL_GetError());
6+ mg_die(MG_EC_SDL_INIT, "SDL_Init failed: %s", SDL_GetError());
7
8 #ifdef MG_RENDERER_SOKOL
9 /* TODO: OpenGL specifics */
10@@ -162,23 +162,23 @@ void platform_window_create(MGContext* ctx)
11 ctx->win = SDL_CreateWindow(ctx->title, ctx->x, ctx->y, ctx->width, ctx->height, flags);
12
13 if (!ctx->win)
14- mg_die(MG_ERR_SDL_CREATE_WIN, "Failed to create window: %s", SDL_GetError());
15+ mg_die(MG_EC_SDL_CREATE_WIN, "Failed to create window: %s", SDL_GetError());
16
17 #ifdef MG_RENDERER_SMALL3DLIB
18 ctx->vbe.renderer = SDL_CreateRenderer(ctx->win, -1, SDL_RENDERER_ACCELERATED);
19 if (!ctx->vbe.renderer)
20 ctx->vbe.renderer = SDL_CreateRenderer(ctx->win, -1, SDL_RENDERER_SOFTWARE);
21 if (!ctx->vbe.renderer)
22- mg_die(MG_ERR_REN_CREATE, "Failed to create SDL renderer: %s", SDL_GetError());
23+ mg_die(MG_EC_REN_CREATE, "Failed to create SDL renderer: %s", SDL_GetError());
24 #endif
25
26 #ifdef MG_RENDERER_SOKOL
27 ctx->vbe.gl = SDL_GL_CreateContext(ctx->win);
28 if (!ctx->vbe.gl)
29- mg_die(MG_ERR_GL_CTX_CREATE, "Failed to initialise GL Context");
30+ mg_die(MG_EC_GL_CTX_CREATE, "Failed to initialise GL Context");
31
32 if (SDL_GL_MakeCurrent(ctx->win, ctx->vbe.gl) != 0)
33- mg_die(MG_ERR_GL_CTX_ACTIVATE, "Failed to activate GL Context: %s", SDL_GetError());
34+ mg_die(MG_EC_GL_CTX_ACTIVATE, "Failed to activate GL Context: %s", SDL_GetError());
35
36 SDL_GL_SetSwapInterval(1);
37 #endif
1@@ -137,12 +137,12 @@ static void create_screen_texture(i32 width, i32 height)
2 return;
3
4 if (width > S3L_MAX_WIDTH || height > S3L_MAX_HEIGHT)
5- mg_die(MG_ERR_REN_CREATE, "small3dlib framebuffer exceeds %dx%d", S3L_MAX_WIDTH, S3L_MAX_HEIGHT);
6+ mg_die(MG_EC_REN_CREATE, "small3dlib framebuffer exceeds %dx%d", S3L_MAX_WIDTH, S3L_MAX_HEIGHT);
7
8 pixel_count = (u64)width * (u64)height;
9 framebuffer = malloc(pixel_count * sizeof(*framebuffer));
10 if (!framebuffer)
11- mg_die(MG_ERR_REN_CREATE, "Failed to allocate small3dlib framebuffer");
12+ mg_die(MG_EC_REN_CREATE, "Failed to allocate small3dlib framebuffer");
13
14 #ifdef MG_PLATFORM_SDL
15 if (ren.screen_texture)
16@@ -152,7 +152,7 @@ static void create_screen_texture(i32 width, i32 height)
17 SDL_TEXTUREACCESS_STREAMING, width, height);
18
19 if (!ren.screen_texture)
20- mg_die(MG_ERR_REN_CREATE, "Failed to create small3dlib texture: %s", SDL_GetError());
21+ mg_die(MG_EC_REN_CREATE, "Failed to create small3dlib texture: %s", SDL_GetError());
22 #endif
23
24 free(ren.framebuffer);
+4,
-4
1@@ -108,7 +108,7 @@ static void create_pipelines(void)
2
3 ren.shader = sg_make_shader(&shader_desc);
4 if (sg_query_shader_state(ren.shader) != SG_RESOURCESTATE_VALID)
5- mg_die(MG_ERR_SHADER_CREATE, "Failed to create shader");
6+ mg_die(MG_EC_SHADER_CREATE, "Failed to create shader");
7
8 /* pipeline descriptor */
9 pipeline_desc.shader = ren.shader;
10@@ -124,7 +124,7 @@ static void create_pipelines(void)
11
12 ren.pipeline = sg_make_pipeline(&pipeline_desc);
13 if (sg_query_pipeline_state(ren.pipeline) != SG_RESOURCESTATE_VALID)
14- mg_die(MG_ERR_PIPELINE_CREATE, "Failed to create pipeline");
15+ mg_die(MG_EC_PIPELINE_CREATE, "Failed to create pipeline");
16 }
17
18 static void create_sampler(void)
19@@ -139,7 +139,7 @@ static void create_sampler(void)
20 ren.sampler = sg_make_sampler(&desc);
21
22 if (sg_query_sampler_state(ren.sampler) != SG_RESOURCESTATE_VALID)
23- mg_die(MG_ERR_SAMPLER_CREATE, "Failed to create sampler");
24+ mg_die(MG_EC_SAMPLER_CREATE, "Failed to create sampler");
25 }
26
27 static void sokol_log(const char* tag, u32 level, u32 item, const char* msg, u32 ln, const char* file, void* user)
28@@ -169,7 +169,7 @@ void renderer_backend_create(MGContext* ctx)
29 sg_setup(&desc);
30
31 if (!sg_isvalid())
32- mg_die(MG_ERR_REN_CREATE, "Failed to initialise renderer");
33+ mg_die(MG_EC_REN_CREATE, "Failed to initialise renderer");
34
35 create_pipelines();
36 create_sampler();