Remove some quits, replace with clean dialog

main
Cameron Murphy Reikes 2 years ago
parent 59b4363b45
commit 6d50ebc50a

@ -19,7 +19,7 @@
// - chipmunk // - chipmunk
#ifdef ASSERT_DO_POPUP_AND_CRASH #ifdef ASSERT_DO_POPUP_AND_CRASH
#ifdef WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
wchar_t * wchar_t *
@ -64,7 +64,7 @@ FILE *log_file = NULL;
void quit_with_popup(const char *message_utf8, const char *title_utf8) void quit_with_popup(const char *message_utf8, const char *title_utf8)
{ {
#ifdef WIN32 #ifdef _WIN32
size_t message_out_len = 0; size_t message_out_len = 0;
size_t title_out_len = 0; size_t title_out_len = 0;
wchar_t *message_wchar = fromUTF8(message_utf8, strlen(message_utf8), &message_out_len); wchar_t *message_wchar = fromUTF8(message_utf8, strlen(message_utf8), &message_out_len);
@ -581,7 +581,7 @@ cpVect box_compass_vector(Entity *box)
#include <time.h> #include <time.h>
void fill_time_string(char *to_fill, size_t max_length) void fill_time_string(char *to_fill, size_t max_length)
{ {
#ifdef WIN32 #ifdef _WIN32
time_t rawtime; time_t rawtime;
struct tm timeinfo = {0}; struct tm timeinfo = {0};

@ -253,7 +253,6 @@ static enum BoxType currently_building()
return toolbar[cur_toolbar_slot]; return toolbar[cur_toolbar_slot];
} }
struct BoxInfo boxinfo(enum BoxType type) struct BoxInfo boxinfo(enum BoxType type)
{ {
for (int i = 0; i < ARRLEN(boxes); i++) for (int i = 0; i < ARRLEN(boxes); i++)
@ -519,29 +518,30 @@ static void init(void)
result = ma_device_init(NULL, &microphone_config, &microphone_device); result = ma_device_init(NULL, &microphone_config, &microphone_device);
if (result != MA_SUCCESS) if (result != MA_SUCCESS)
{ {
Log("Failed to initialize capture device.\n"); quit_with_popup("Failed to initialize microphone\n", "Failed to initialize audio");
exit(-1); Log("Cap device fail\n");
return;
} }
result = ma_device_init(NULL, &speaker_config, &speaker_device); result = ma_device_init(NULL, &speaker_config, &speaker_device);
if (result != MA_SUCCESS) if (result != MA_SUCCESS)
{ {
ma_device_uninit(&microphone_device); ma_device_uninit(&microphone_device);
quit_with_popup("Failed to initialize speaker/headphones\n", "Failed to initialize audio");
Log("Failed to init speaker\n"); Log("Failed to init speaker\n");
exit(-1); return;
} }
if (ma_mutex_init(&send_packets_mutex) != MA_SUCCESS) flight_assert(ma_mutex_init(&send_packets_mutex) == MA_SUCCESS);
Log("Failed to init send mutex\n"); flight_assert(ma_mutex_init(&play_packets_mutex) == MA_SUCCESS);
if (ma_mutex_init(&play_packets_mutex) != MA_SUCCESS)
Log("Failed to init play mutex\n");
result = ma_device_start(&microphone_device); result = ma_device_start(&microphone_device);
if (result != MA_SUCCESS) if (result != MA_SUCCESS)
{ {
ma_device_uninit(&microphone_device); ma_device_uninit(&microphone_device);
Log("Failed to start device.\n"); Log("Failed to start mic.\n");
exit(-1); quit_with_popup("Failed to start microphone device\n", "Failed to start audio");
return;
} }
result = ma_device_start(&speaker_device); result = ma_device_start(&speaker_device);
@ -550,7 +550,8 @@ static void init(void)
ma_device_uninit(&microphone_device); ma_device_uninit(&microphone_device);
ma_device_uninit(&speaker_device); ma_device_uninit(&speaker_device);
Log("Failed to start speaker\n"); Log("Failed to start speaker\n");
exit(-1); quit_with_popup("Failed to start speaker device\n", "Failed to start audio");
return;
} }
Log("Initialized audio\n"); Log("Initialized audio\n");
@ -580,10 +581,7 @@ static void init(void)
exit(-1); exit(-1);
} }
// shaders // initialize shaders
{
// initialize shader
{
{ {
sgp_pipeline_desc pip_desc = { sgp_pipeline_desc pip_desc = {
.shader = *hueshift_program_shader_desc(sg_query_backend()), .shader = *hueshift_program_shader_desc(sg_query_backend()),
@ -595,7 +593,6 @@ static void init(void)
fprintf(stderr, "failed to make hueshift pipeline\n"); fprintf(stderr, "failed to make hueshift pipeline\n");
exit(-1); exit(-1);
} }
}
{ {
sgp_pipeline_desc pip_desc = { sgp_pipeline_desc pip_desc = {
@ -610,6 +607,7 @@ static void init(void)
exit(-1); exit(-1);
} }
} }
}
// images loading // images loading
{ {
@ -688,10 +686,9 @@ static void init(void)
/* received. Reset the peer in the event the 5 seconds */ /* received. Reset the peer in the event the 5 seconds */
/* had run out without any significant event. */ /* had run out without any significant event. */
enet_peer_reset(peer); enet_peer_reset(peer);
fprintf(stderr, "Connection to server failed."); Log("Failed to connecvt to server\n");
exit(-1); quit_with_popup("Failed to connect to server. Is your wifi down? It took too long.", "Connection Failure");
} Log("Connection to server failed.\n");
}
} }
} }
} }

@ -436,6 +436,8 @@ uint64_t tick(struct GameState *gs);
double elapsed_time(GameState *gs); double elapsed_time(GameState *gs);
double sun_dist_no_gravity(Entity *sun); double sun_dist_no_gravity(Entity *sun);
void quit_with_popup(const char *message_utf8, const char *title_utf8);
// all of these return if successful or not // all of these return if successful or not
bool server_to_client_serialize(struct ServerToClient *msg, unsigned char *bytes, size_t *out_len, size_t max_len, Entity *for_this_player, bool to_disk); bool server_to_client_serialize(struct ServerToClient *msg, unsigned char *bytes, size_t *out_len, size_t max_len, Entity *for_this_player, bool to_disk);
bool server_to_client_deserialize(struct ServerToClient *msg, unsigned char *bytes, size_t max_len, bool from_disk); bool server_to_client_deserialize(struct ServerToClient *msg, unsigned char *bytes, size_t max_len, bool from_disk);

Loading…
Cancel
Save