Moved the game loop into a new thread (yet this is the only one)
Signed-off-by: Polonkai Gergely <polesz@w00d5t0ck.info>
This commit is contained in:
parent
c054543641
commit
a8c7a04cfe
20
src/main.c
20
src/main.c
@ -157,6 +157,15 @@ wmud_config_init(GError **err)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpointer
|
||||||
|
game_thread_func(GMainLoop *game_loop)
|
||||||
|
{
|
||||||
|
/* Run the game loop */
|
||||||
|
g_main_loop_run(game_loop);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -164,6 +173,7 @@ main(int argc, char **argv)
|
|||||||
GSource *timeout_source;
|
GSource *timeout_source;
|
||||||
guint timeout_id;
|
guint timeout_id;
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
|
GThread *game_thread;
|
||||||
|
|
||||||
/* Initialize the thread and type system */
|
/* Initialize the thread and type system */
|
||||||
g_thread_init(NULL);
|
g_thread_init(NULL);
|
||||||
@ -237,8 +247,14 @@ main(int argc, char **argv)
|
|||||||
g_clear_error(&err);
|
g_clear_error(&err);
|
||||||
wmud_db_players_load(&err);
|
wmud_db_players_load(&err);
|
||||||
|
|
||||||
/* Run the game loop */
|
/* Initialization ends here */
|
||||||
g_main_loop_run(game_loop);
|
|
||||||
|
g_clear_error(&err);
|
||||||
|
game_thread = g_thread_create((GThreadFunc)game_thread_func, game_loop, TRUE, &err);
|
||||||
|
|
||||||
|
/* Initialize other threads here */
|
||||||
|
|
||||||
|
g_thread_join(game_thread);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user