naev 0.11.5
naev.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
15#include "linebreak.h"
16#include "physfsrwops.h"
17#include "SDL.h"
18#include "SDL_error.h"
19#include "SDL_image.h"
20
21#include "naev.h"
22
23#if HAS_POSIX
24#include <time.h>
25#include <unistd.h>
26#endif /* HAS_POSIX */
29#include "ai.h"
30#include "background.h"
31#include "camera.h"
32#include "cond.h"
33#include "conf.h"
34#include "console.h"
35#include "damagetype.h"
36#include "debug.h"
37#include "dialogue.h"
38#include "difficulty.h"
39#include "economy.h"
40#include "env.h"
41#include "event.h"
42#include "faction.h"
43#include "font.h"
44#include "gui.h"
45#include "hook.h"
46#include "input.h"
47#include "joystick.h"
48#include "land.h"
49#include "load.h"
50#include "log.h"
51#include "map.h"
52#include "map_overlay.h"
53#include "map_system.h"
54#include "menu.h"
55#include "mission.h"
56#include "music.h"
57#include "ndata.h"
58#include "nebula.h"
59#include "news.h"
60#include "nfile.h"
61#include "nlua_misn.h"
62#include "nlua_var.h"
63#include "nlua_tex.h"
64#include "nlua_colour.h"
65#include "nlua_gfx.h"
66#include "nlua_naev.h"
67#include "nlua_rnd.h"
68#include "nlua_vec2.h"
69#include "nlua_file.h"
70#include "nlua_data.h"
71#include "npc.h"
72#include "nstring.h"
73#include "nxml.h"
74#include "opengl.h"
75#include "options.h"
76#include "outfit.h"
77#include "pause.h"
78#include "physics.h"
79#include "pilot.h"
80#include "player.h"
81#include "plugin.h"
82#include "render.h"
83#include "rng.h"
84#include "safelanes.h"
85#include "semver.h"
86#include "ship.h"
87#include "slots.h"
88#include "sound.h"
89#include "space.h"
90#include "spfx.h"
91#include "start.h"
92#include "tech.h"
93#include "threadpool.h"
94#include "toolkit.h"
95#include "unidiff.h"
96#include "weapon.h"
97
98#define VERSION_FILE "VERSION"
100static int quit = 0;
101Uint32 SDL_LOOPDONE = 0;
102static Uint64 time_ms = 0;
103static SDL_Surface *naev_icon = NULL;
104static int fps_skipped = 0;
105/* Version stuff. */
108/*
109 * FPS stuff.
110 */
111static double fps_dt = 1.;
112static double game_dt = 0.;
113static double real_dt = 0.;
114static double fps = 0.;
115static double fps_cur = 0.;
116static double fps_x = 15.;
117static double fps_y = -15.;
118const double fps_min = 1./25.;
121double elapsed_time_mod = 0.;
123static nlua_env load_env = LUA_NOREF;
124static int load_force_render = 0;
125static unsigned int load_last_render = 0;
126static SDL_mutex *load_mutex;
127
128/*
129 * prototypes
130 */
131/* Loading. */
132static void print_SDLversion (void);
133static void loadscreen_load (void);
134static void loadscreen_unload (void);
135static void load_all (void);
136static void unload_all (void);
137static void window_caption (void);
138/* update */
139static void fps_init (void);
140static double fps_elapsed (void);
141static void fps_control (void);
142static void update_all( int dohooks );
143/* Misc. */
144static void loadscreen_update( double done, const char *msg );
145void main_loop( int nested ); /* externed in dialogue.c */
146
150void naev_quit (void)
151{
152 quit = 1;
153}
154
158int naev_isQuit (void)
159{
160 return quit;
161}
162
170int main( int argc, char** argv )
171{
172 char conf_file_path[PATH_MAX], **search_path;
173 Uint32 starttime;
174
175#ifdef DEBUGGING
176 /* Set Debugging flags. */
177 memset( debug_flags , 0, DEBUG_FLAGS_MAX );
178#endif /* DEBUGGING */
179
180 env_detect( argc, argv );
181
182 log_init();
183
184 /* Set up PhysicsFS. */
185 if (PHYSFS_init( env.argv0 ) == 0) {
186 ERR( "PhysicsFS initialization failed: %s",
187 _( PHYSFS_getErrorByCode( PHYSFS_getLastErrorCode() ) ) );
188 return -1;
189 }
190 PHYSFS_permitSymbolicLinks( 1 );
191
192 /* Set up locales. */
193 gettext_init();
194 init_linebreak();
195
196 /* Parse version. */
197 if (semver_parse( naev_version( 0 ), &version_binary ))
198 WARN( _("Failed to parse version string '%s'!"), naev_version( 0 ) );
199
200 /* Print the version */
201 LOG( " %s v%s (%s)", APPNAME, naev_version(0), HOST );
202
203 if (env.isAppImage)
204 LOG( "AppImage detected. Running from: %s", env.appdir );
205 else
206 DEBUG( "AppImage not detected." );
207
208 /* Initializes SDL for possible warnings. */
209 if (SDL_Init( 0 )) {
210 ERR( _( "Unable to initialize SDL: %s" ), SDL_GetError() );
211 return -1;
212 }
213 starttime = SDL_GetTicks();
214 SDL_LOOPDONE = SDL_RegisterEvents(1);
215
216 /* Initialize the threadpool */
217 threadpool_init();
218
219 /* Set up debug signal handlers. */
221
222#if HAS_UNIX
223 /* Set window class and name. */
224 SDL_setenv("SDL_VIDEO_X11_WMCLASS", APPNAME, 0);
225#endif /* HAS_UNIX */
226
227 /* Must be initialized before input_init is called. */
228 if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
229 WARN( _("Unable to initialize SDL Video: %s"), SDL_GetError());
230 return -1;
231 }
232
233 /* We'll be parsing XML. */
234 LIBXML_TEST_VERSION
235 xmlInitParser();
236
237 /* Input must be initialized for config to work. */
238 input_init();
239
240 lua_init(); /* initializes lua */
241
242 conf_setDefaults(); /* set the default config values */
243
244 /*
245 * Attempts to load the data path from datapath.lua
246 * At this early point in the load process, the binary path
247 * is the only place likely to be checked.
248 */
249 conf_loadConfigPath();
250
251 /* Create the home directory if needed. */
253 WARN( _("Unable to create config directory '%s'"), nfile_configPath());
254
255 /* Set the configuration. */
256 snprintf(conf_file_path, sizeof(conf_file_path), "%s"CONF_FILE, nfile_configPath());
257
258 conf_loadConfig(conf_file_path); /* Lua to parse the configuration file */
259 conf_parseCLI( argc, argv ); /* parse CLI arguments */
260
261 /* Set up I/O. */
263 log_redirect();
265 gettext_setLanguage( conf.language ); /* now that we can find translations */
266 LOG( _("Loaded configuration: %s"), conf_file_path );
267 search_path = PHYSFS_getSearchPath();
268 LOG( "%s", _("Read locations, searched in order:") );
269 for (char **p = search_path; *p != NULL; p++)
270 LOG( " %s", *p );
271 PHYSFS_freeList( search_path );
272 /* Logging the cache path is noisy, noisy is good at the DEBUG level. */
273 DEBUG( _("Cache location: %s"), nfile_cachePath() );
274 LOG( _("Write location: %s\n"), PHYSFS_getWriteDir() );
275
276 /* Enable FPU exceptions. */
277 if (conf.fpu_except)
278 debug_enableFPUExcept();
279
280 /* Load the start info. */
281 if (start_load())
282 ERR( _("Failed to load module start data.") );
283 LOG(" %s", start_name());
284 DEBUG_BLANK();
285
286 /* Display the SDL Version. */
288 DEBUG_BLANK();
289
290 /* random numbers */
291 rng_init();
292
293 /*
294 * OpenGL
295 */
296 if (gl_init()) { /* initializes video output */
297 ERR( _("Initializing video output failed, exiting…") );
298 SDL_Quit();
299 exit(EXIT_FAILURE);
300 }
302
303 /* Have to set up fonts before rendering anything. */
304 //DEBUG("Using '%s' as main font and '%s' as monospace font.", _(FONT_DEFAULT_PATH), _(FONT_MONOSPACE_PATH));
305 gl_fontInit( &gl_defFont, _(FONT_DEFAULT_PATH), conf.font_size_def, FONT_PATH_PREFIX, 0 ); /* initializes default font to size */
306 gl_fontInit( &gl_smallFont, _(FONT_DEFAULT_PATH), conf.font_size_small, FONT_PATH_PREFIX, 0 ); /* small font */
307 gl_fontInit( &gl_defFontMono, _(FONT_MONOSPACE_PATH), conf.font_size_def, FONT_PATH_PREFIX, 0 );
308
309 /* Detect size changes that occurred after window creation. */
310 naev_resize();
311
312 /* Display the load screen. */
314 loadscreen_update( 0., _("Initializing subsystems…") );
315 time_ms = SDL_GetTicks64();
316
317 /*
318 * Input
319 */
320 if ((conf.joystick_ind >= 0) || (conf.joystick_nam != NULL)) {
321 if (joystick_init())
322 WARN( _("Error initializing joystick input") );
323 if (conf.joystick_nam != NULL) { /* use the joystick name to find a joystick */
325 WARN( _("Failure to open any joystick, falling back to default keybinds") );
327 }
328 free(conf.joystick_nam);
329 }
330 else if (conf.joystick_ind >= 0) /* use a joystick id instead */
331 if (joystick_use(conf.joystick_ind)) {
332 WARN( _("Failure to open any joystick, falling back to default keybinds") );
334 }
335 }
336
337 /*
338 * OpenAL - Sound
339 */
340 if (conf.nosound) {
341 LOG( _("Sound is disabled!") );
342 sound_disabled = 1;
343 music_disabled = 1;
344 }
345 if (sound_init())
346 WARN( _("Problem setting up sound!") );
347 music_choose("load");
348
349 /* FPS stuff. */
350 fps_setPos( 15., (double)(gl_screen.h-15-gl_defFontMono.h) );
351
352 /* Misc graphics init */
353 render_init();
354 if (nebu_init() != 0) { /* Initializes the nebula */
355 /* An error has happened */
356 ERR( _("Unable to initialize the Nebula subsystem!") );
357 /* Weirdness will occur... */
358 }
359 gui_init(); /* initializes the GUI graphics */
360 toolkit_init(); /* initializes the toolkit */
361 map_init(); /* initializes the map. */
362 map_system_init(); /* Initialise the solar system map */
363 cond_init(); /* Initialize conditional subsystem. */
364 cli_init(); /* Initialize console. */
365
366 /* Data loading */
367 load_all();
368
369 /* Detect size changes that occurred during load. */
370 naev_resize();
371
372 /* Unload load screen. */
374
375 /* Start menu. */
376 menu_main();
377
378 if (conf.devmode)
379 LOG( _( "Reached main menu in %.3f s" ), (SDL_GetTicks()-starttime)/1000. );
380 else
381 LOG( _( "Reached main menu" ) );
382
383 fps_init(); /* initializes the time_ms */
384
385 /*
386 * main loop
387 */
388 SDL_Event event;
389 /* flushes the event loop since I noticed that when the joystick is loaded it
390 * creates button events that results in the player starting out acceling */
391 while (SDL_PollEvent(&event));
392
393 /* Show plugin compatibility. */
394 plugin_check();
395
396 /* Incomplete translation note (shows once if we pick an incomplete translation based on user's locale). */
397 if ( !conf.translation_warning_seen && conf.language == NULL ) {
398 const char* language = gettext_getLanguage();
399 double coverage = gettext_languageCoverage(language);
400
401 if (coverage < 0.8) {
404 _("Incomplete Translation"),
405 _("%s is partially translated (%.0f%%) into your language (%s),"
406 " but the remaining text will be English. Language settings"
407 " are available in the \"%s\" screen."),
408 APPNAME, 100.*coverage, language, _("Options") );
409 }
410 }
411
412 /* Incomplete game note (shows every time version number changes). */
413 if (conf.lastversion == NULL || naev_versionCompare(conf.lastversion) != 0) {
414 free( conf.lastversion );
415 conf.lastversion = strdup( naev_version(0) );
417 _("Welcome to Naev"),
418 _("Welcome to Naev version %s, and thank you for playing! We hope you"
419 " enjoy this game and all it has to offer. This is a passion"
420 " project developed exclusively by volunteers and it gives us all"
421 " great joy to know that there are others who love this game as"
422 " much as we do!\n"
423 " Of course, please note that this is an incomplete game. You"
424 " will encounter dead ends to storylines, missing storylines, and"
425 " possibly even some bugs, although we try to keep those to a"
426 " minimum of course. So be prepared for some rough edges for the"
427 " time being. That said, we are working on this game every day and"
428 " hope to one day finish this massive project on our hands."
429 " Perhaps you could become one of us, who knows?\n"
430 " For more information about the game and its development"
431 " state, take a look at naev.org; it has all the relevant links."
432 " And again, thank you for playing!"), conf.lastversion );
433 }
434
435 /* primary loop */
436 while (!quit) {
437 while (!quit && SDL_PollEvent(&event)) { /* event loop */
438 if (event.type == SDL_QUIT) {
439 SDL_FlushEvent( SDL_QUIT ); /* flush event to prevent it from quitting when lagging a bit. */
440 if (quit || menu_askQuit()) {
441 quit = 1; /* quit is handled here */
442 break;
443 }
444 }
445 else if (event.type == SDL_WINDOWEVENT &&
446 event.window.event == SDL_WINDOWEVENT_RESIZED) {
447 naev_resize();
448 continue;
449 }
450 input_handle(&event); /* handles all the events and player keybinds */
451 }
452
453 main_loop( 0 );
454 }
455
456 /* Save configuration. */
457 conf_saveConfig(conf_file_path);
458
459 /* data unloading */
460 unload_all();
461
462 /* cleanup opengl fonts */
463 gl_freeFont(NULL);
466
467 start_cleanup(); /* Cleanup from start.c, not the first cleanup step. :) */
468
469 /* exit subsystems */
470 plugin_exit();
471 cli_exit(); /* Clean up the console. */
472 map_system_exit(); /* Destroys the solar system map. */
473 map_exit(); /* Destroys the map. */
474 ovr_mrkFree(); /* Clear markers. */
475 toolkit_exit(); /* Kills the toolkit */
476 ai_exit(); /* Stops the Lua AI magic */
477 joystick_exit(); /* Releases joystick */
478 input_exit(); /* Cleans up keybindings */
479 nebu_exit(); /* Destroys the nebula */
480 render_exit(); /* Cleans up post-processing. */
481 news_exit(); /* Destroys the news. */
482 difficulty_free(); /* Clean up difficulties. */
483 music_exit(); /* Kills Lua state. */
484 lua_exit(); /* Closes Lua state, and invalidates all Lua. */
485 sound_exit(); /* Kills the sound */
486 gl_exit(); /* Kills video output */
487
488 /* Has to be run last or it will mess up sound settings. */
489 conf_cleanup(); /* Free some memory the configuration allocated. */
490
491 /* Free the icon. */
492 if (naev_icon)
493 SDL_FreeSurface(naev_icon);
494
495 IMG_Quit(); /* quits SDL_image */
496 SDL_Quit(); /* quits SDL */
497
498 /* Clean up parser. */
499 xmlCleanupParser();
500 xmlMemoryDump();
501
502 /* Clean up signal handler. */
504
505 /* Delete logs if empty. */
506 log_clean();
507
508 /* Really turn the lights off. */
509 PHYSFS_deinit();
510 gl_fontExit();
511 gettext_exit();
512
513 /* all is well */
515 return 0;
516}
517
522{
523 int r;
524
525 load_mutex = SDL_CreateMutex();
526
527 load_env = nlua_newEnv();
529 r |= nlua_loadNaev( load_env );
530 r |= nlua_loadRnd( load_env );
532 r |= nlua_loadFile( load_env );
533 r |= nlua_loadData( load_env );
534 r |= nlua_loadTex( load_env );
535 r |= nlua_loadCol( load_env );
536 r |= nlua_loadGFX( load_env );
537 if (r)
538 WARN(_("Something went wrong when loading Lua libraries for '%s'!"), LOADSCREEN_DATA_PATH);
539
540 size_t bufsize;
541 char *buf = ndata_read( LOADSCREEN_DATA_PATH, &bufsize );
542 if (nlua_dobufenv(load_env, buf, bufsize, LOADSCREEN_DATA_PATH) != 0) {
543 WARN( _("Error loading file: %s\n"
544 "%s\n"
545 "Most likely Lua file has improper syntax, please check"),
546 LOADSCREEN_DATA_PATH, lua_tostring(naevL,-1));
547 free(buf);
548 return;
549 }
550 free(buf);
551}
552
557{
558 unsigned int t = SDL_GetTicks();
559 int ret;
560 SDL_mutexP( load_mutex );
561 /* Only render if forced or try for low 10 FPS. */
562 if (!load_force_render && (t-load_last_render) < 100 )
563 ret = 0;
564 else
565 ret = 1;
566 SDL_mutexV( load_mutex );
567 return ret;
568}
569
570void naev_doRenderLoadscreen (void)
571{
572 SDL_mutexP( load_mutex );
573 load_last_render = SDL_GetTicks();
574
575 /* Clear background. */
576 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
577
578 /* Run Lua. */
579 nlua_getenv( naevL, load_env, "render" );
580 if (nlua_pcall(load_env, 0, 0)) { /* error has occurred */
581 WARN( _("Loadscreen '%s': '%s'"), "render", lua_tostring(naevL,-1));
582 lua_pop(naevL,1);
583 }
584
585 /* Flip buffers. HACK: Also try to catch a late-breaking resize from the WM (...or a crazy user?). */
586 SDL_GL_SwapWindow( gl_screen.window );
587 naev_resize();
588
589 /* Clear forcing. */
590 load_force_render = 0;
591 SDL_mutexV( load_mutex );
592}
593
598{
600 naev_doRenderLoadscreen();
601}
602
609void loadscreen_update( double done, const char *msg )
610{
611 /* Run Lua. */
612 nlua_getenv( naevL, load_env, "update" );
613 lua_pushnumber( naevL, done );
614 lua_pushstring( naevL, msg );
615 if (nlua_pcall(load_env, 2, 0)) { /* error has occurred */
616 WARN( _("Loadscreen '%s': '%s'"), "update", lua_tostring(naevL,-1));
617 lua_pop(naevL,1);
618 }
619
620 /* Force rerender. */
621 load_force_render = 1;
623}
624
628static void loadscreen_unload (void)
629{
630 nlua_freeEnv( load_env );
631 SDL_DestroyMutex( load_mutex );
632}
633
637#define LOADING_STAGES 17.
638void load_all (void)
639{
640 int stage = 0;
641 /* We can do fast stuff here. */
642 sp_load();
643
644 /* order is very important as they're interdependent */
645 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Commodities…") );
646 commodity_load(); /* dep for space */
647
648 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Special Effects…") );
649 spfx_load(); /* no dep */
650
651 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Effects…") );
652 effect_load(); /* no dep */
653
654 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Damage Types…") );
655 dtype_load(); /* dep for outfits */
656
657 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Outfits…") );
658 outfit_load(); /* dep for ships, factions */
659
660 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Ships…") );
661 ships_load(); /* dep for fleet */
662
663 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Factions…") );
664 factions_load(); /* dep for fleet, space, missions, AI */
665
666 /* Handle outfit loading part that may use ships and factions. */
668
669 loadscreen_update( ++stage/LOADING_STAGES, _("Loading AI…") );
670 ai_load(); /* dep for fleets */
671
672 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Techs…") );
673 tech_load(); /* dep for space */
674
675 loadscreen_update( ++stage/LOADING_STAGES, _("Loading the Universe…") );
676 space_load(); /* dep for events/missions */
677
678 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Events…") );
679 events_load();
680
681 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Missions…") );
683
684 loadscreen_update( ++stage/LOADING_STAGES, _("Loading the UniDiffs…") );
686
687 loadscreen_update( ++stage/LOADING_STAGES, _("Populating Maps…") );
689
690 loadscreen_update( ++stage/LOADING_STAGES, _("Calculating Patrols…") );
692
693 loadscreen_update( ++stage/LOADING_STAGES, _("Initializing Details…") );
694#if DEBUGGING
695 if (stage > LOADING_STAGES)
696 WARN(_("Too many loading stages, please increase LOADING_STAGES"));
697#endif /* DEBUGGING */
698 difficulty_load();
700 map_load();
701 map_system_load();
703 pilots_init();
704 weapon_init();
705 player_init(); /* Initialize player stuff. */
706 loadscreen_update( 1., _("Loading Completed!") );
707}
711void unload_all (void)
712{
713 /* cleanup some stuff */
714 player_cleanup(); /* cleans up the player stuff */
715 gui_free(); /* cleans up the player's GUI */
716 weapon_exit(); /* destroys all active weapons */
717 pilots_free(); /* frees the pilots, they were locked up :( */
718 cond_exit(); /* destroy conditional subsystem. */
719 land_exit(); /* Destroys landing vbo and friends. */
720 npc_clear(); /* In case exiting while landed. */
721 background_free(); /* Destroy backgrounds. */
722 load_free(); /* Clean up loading game stuff stuff. */
724 diff_free();
725 economy_destroy(); /* must be called before space_exit */
726 space_exit(); /* cleans up the universe itself */
727 tech_free(); /* Frees tech stuff. */
728 ships_free();
729 outfit_free();
730 spfx_free(); /* gets rid of the special effect */
731 effect_exit();
732 dtype_free(); /* gets rid of the damage types */
734 events_exit(); /* Clean up events. */
737 var_cleanup(); /* cleans up mission variables */
738 sp_cleanup();
739}
740
744void main_loop( int nested )
745{
746 /*
747 * Control FPS.
748 */
749 fps_control(); /* everyone loves fps control */
750
751 /*
752 * Handle update.
753 */
754 input_update( real_dt ); /* handle key repeats. */
755 sound_update( real_dt ); /* Update sounds. */
756 toolkit_update(); /* to simulate key repetition and get rid of windows */
757 if (!paused) {
758 /* Important that we pass real_dt here otherwise we get a dt feedback loop which isn't pretty. */
760 update_all( !nested ); /* update game */
761 }
762 else if (!nested) {
763 /* We run the exclusion end here to handle any hooks that are potentially manually triggered by hook.trigger. */
764 hook_exclusionEnd( 0. );
765 }
766
767 /* Safe hook should be run every frame regardless of whether game is paused or not. */
768 if (!nested)
769 hooks_run( "safe" );
770
771 /* Checks to see if we want to land. */
773
774 /*
775 * Handle render.
776 */
777 if (!quit) { /* So if update sets up a nested main loop, we can end up in a
778 state where things are corrupted when trying to exit the game.
779 Avoid rendering when quitting just in case. */
780 /* Clear buffer. */
781 render_all( game_dt, real_dt );
782 /* Draw buffer. */
783 SDL_GL_SwapWindow( gl_screen.window );
784 }
785}
786
790void naev_resize (void)
791{
792 /* Auto-detect window size. */
793 int w, h;
794 SDL_GL_GetDrawableSize( gl_screen.window, &w, &h );
795
796 /* Update options menu, if open. (Never skip, in case the fullscreen mode alone changed.) */
797 opt_resize();
798
799 /* Nothing to do. */
800 if ((w == gl_screen.rw) && (h == gl_screen.rh))
801 return;
802
803 /* Resize the GL context, etc. */
804 gl_resize();
805
806 /* Regenerate the background space dust. */
807 if (cur_system != NULL) {
808 background_initDust( cur_system->spacedust );
809 background_load( cur_system->background );
810 }
811 else
812 background_initDust( 1000. ); /* from loadscreen_load */
813
814 /* Must be before gui_reload */
815 fps_setPos( 15., (double)(SCREEN_H-15-gl_defFontMono.h) );
816
817 /* Reload the GUI (may regenerate land window) */
818 gui_reload();
819
820 /* Resets dimensions in other components which care. */
821 ovr_refresh();
823 menu_main_resize();
824 nebu_resize();
825
826 /* Lua stuff. */
827 nlua_resize();
828
829 /* Have to rerender the toolkit too. */
831
832 /* Finally do a render pass to avoid half-rendered stuff. */
833 render_all( 0., 0. );
834 SDL_GL_SwapWindow( gl_screen.window );
835
836 /* Force render. */
837 load_force_render = 1;
838}
839
840/*
841 * @brief Toggles between windowed and fullscreen mode.
842 */
843void naev_toggleFullscreen (void)
844{
845 opt_setVideoMode( conf.width, conf.height, !conf.fullscreen, 0 );
846}
847
848#if HAS_POSIX && defined(CLOCK_MONOTONIC)
849static struct timespec global_time;
850static int use_posix_time;
851#endif /* HAS_POSIX && defined(CLOCK_MONOTONIC) */
855static void fps_init (void)
856{
857#if HAS_POSIX && defined(CLOCK_MONOTONIC)
858 use_posix_time = 1;
859 /* We must use clock_gettime here instead of gettimeofday mainly because this
860 * way we are not influenced by changes to the time source like say ntp which
861 * could skew up the dt calculations. */
862 if (clock_gettime(CLOCK_MONOTONIC, &global_time)==0)
863 return;
864 WARN( _("clock_gettime failed, disabling POSIX time.") );
865 use_posix_time = 0;
866#endif /* HAS_POSIX && defined(CLOCK_MONOTONIC) */
867 time_ms = SDL_GetTicks64();
868}
874static double fps_elapsed (void)
875{
876 double dt;
877 Uint64 t;
878
879#if HAS_POSIX && defined(CLOCK_MONOTONIC)
880 struct timespec ts;
881
882 if (use_posix_time) {
883 if (clock_gettime(CLOCK_MONOTONIC, &ts)==0) {
884 dt = ts.tv_sec - global_time.tv_sec;
885 dt += (ts.tv_nsec - global_time.tv_nsec) / 1e9;
886 global_time = ts;
887 return dt;
888 }
889 WARN( _("clock_gettime failed!") );
890 }
891#endif /* HAS_POSIX && defined(CLOCK_MONOTONIC) */
892
893 t = SDL_GetTicks64();
894 dt = (double)(t - time_ms); /* Get the elapsed ms. */
895 dt /= 1000.; /* Convert to seconds. */
896 time_ms = t;
897
898 return dt;
899}
900
904static void fps_control (void)
905{
906#if HAS_POSIX
907 struct timespec ts;
908#endif /* HAS_POSIX */
909
910 /* dt in s */
912 game_dt = real_dt * dt_mod; /* Apply the modifier. */
913
914 /* if fps is limited */
915 if (!conf.vsync && conf.fps_max != 0) {
916 const double fps_max = 1./(double)conf.fps_max;
917 if (real_dt < fps_max) {
918 double delay = fps_max - real_dt;
919#if HAS_POSIX
920 ts.tv_sec = floor( delay );
921 ts.tv_nsec = fmod( delay, 1. ) * 1e9;
922 nanosleep( &ts, NULL );
923#else /* HAS_POSIX */
924 SDL_Delay( (unsigned int)(delay * 1000) );
925#endif /* HAS_POSIX */
926 fps_dt += delay; /* makes sure it displays the proper fps */
927 }
928 }
929}
930
934void fps_setPos( double x, double y )
935{
936 fps_x = x;
937 fps_y = y;
938}
939
945void fps_display( double dt )
946{
947 double x,y;
948 double dt_mod_base = 1.;
949
950 fps_dt += dt;
951 fps_cur += 1.;
952 if (fps_dt > 1.) { /* recalculate every second */
953 fps = fps_cur / fps_dt;
954 fps_dt = fps_cur = 0.;
955 }
956
957 x = fps_x;
958 y = fps_y;
959 if (conf.fps_show) {
960 gl_print( &gl_defFontMono, x, y, &cFontWhite, "%3.2f", fps );
961 y -= gl_defFontMono.h + 5.;
962 }
963
964 if ((player.p != NULL) && !player_isFlag(PLAYER_DESTROYED) &&
965 !player_isFlag(PLAYER_CREATING)) {
966 dt_mod_base = player_dt_default();
967 }
968 if (dt_mod != dt_mod_base)
969 gl_print( &gl_defFontMono, x, y, &cFontWhite, "%3.1fx", dt_mod / dt_mod_base);
970
971 if (!paused || !player_paused || !conf.pause_show)
972 return;
973
974 y = SCREEN_H / 3. - gl_defFontMono.h / 2.;
975 gl_printMidRaw( &gl_defFontMono, SCREEN_W, 0., y,
976 &cFontWhite, -1., _("PAUSED") );
977}
978
984double fps_current (void)
985{
986 return fps;
987}
988
994static void update_all( int dohooks )
995{
996 if ((real_dt > 0.25) && (fps_skipped==0)) { /* slow timers down and rerun calculations */
997 fps_skipped = 1;
998 return;
999 }
1000 else if (game_dt > fps_min) { /* We'll force a minimum FPS for physics to work alright. */
1001 int n;
1002 double nf, microdt, accumdt;
1003
1004 /* Number of frames. */
1005 nf = ceil( game_dt / fps_min );
1006 microdt = game_dt / nf;
1007 n = (int) nf;
1008
1009 /* Update as much as needed, evenly. */
1010 accumdt = 0.;
1011 for (int i=0; i<n; i++) {
1012 update_routine( microdt, dohooks );
1013 /* OK, so we need a bit of hackish logic here in case we are chopping up a
1014 * very large dt and it turns out time compression changes so we're now
1015 * updating in "normal time compression" zone. This amounts to many updates
1016 * being run when time compression has changed and thus can cause, say, the
1017 * player to exceed their target position or get mauled by an enemy ship.
1018 */
1019 accumdt += microdt;
1020 if (accumdt > dt_mod*real_dt)
1021 break;
1022 }
1023
1024 /* Note we don't touch game_dt so that fps_display works well */
1025 }
1026 else /* Standard, just update with the last dt */
1027 update_routine( game_dt, dohooks );
1028
1029 fps_skipped = 0;
1030}
1031
1038void update_routine( double dt, int dohooks )
1039{
1040 if (dohooks) {
1042
1043 /* Update time. */
1044 ntime_update( dt );
1045 }
1046
1047 /* Clean up dead elements and build quadtrees. */
1050
1051 /* Core stuff independent of collisions. */
1052 space_update( dt, real_dt );
1053 spfx_update( dt, real_dt );
1054
1055 if (dt > 0.) {
1056 /* First compute weapon collisions. */
1058 pilots_update( dt );
1059 weapons_update( dt ); /* Has weapons think and update positions. */
1060
1061 /* Update camera. */
1062 cam_update( dt );
1063 }
1064
1065 /* Update the elapsed time, should be with all the modifications and such. */
1066 elapsed_time_mod += dt;
1067
1068 if (dohooks) {
1069 HookParam h[3];
1070 hook_exclusionEnd( dt );
1071 /* Hook set up. */
1072 h[0].type = HOOK_PARAM_NUMBER;
1073 h[0].u.num = dt;
1074 h[1].type = HOOK_PARAM_NUMBER;
1075 h[1].u.num = real_dt;
1076 h[2].type = HOOK_PARAM_SENTINEL;
1077 /* Run the update hook. */
1078 hooks_runParam( "update", h );
1079 }
1080}
1081
1085static void window_caption (void)
1086{
1087 char *buf;
1088 SDL_RWops *rw;
1089
1090 /* Load icon. */
1091 rw = PHYSFSRWOPS_openRead( GFX_PATH"icon.webp" );
1092 if (rw == NULL) {
1093 WARN( _("Icon (icon.webp) not found!") );
1094 return;
1095 }
1096 naev_icon = IMG_Load_RW( rw, 1 );
1097 if (naev_icon == NULL) {
1098 WARN( _("Unable to load icon.webp!") );
1099 return;
1100 }
1101
1102 /* Set caption. */
1103 SDL_asprintf( &buf, APPNAME" - %s", _(start_name()) );
1104 SDL_SetWindowTitle( gl_screen.window, buf );
1105 SDL_SetWindowIcon( gl_screen.window, naev_icon );
1106 free( buf );
1107}
1108
1109static int binary_comparison( int x, int y )
1110{
1111 if (x == y) return 0;
1112 if (x > y) return 1;
1113 return -1;
1114}
1120int naev_versionCompare( const char *version )
1121{
1122 int res;
1123 semver_t sv;
1124
1125 if (semver_parse( version, &sv )) {
1126 WARN( _("Failed to parse version string '%s'!"), version );
1127 return -1;
1128 }
1129
1130 if ((res = 3*binary_comparison(version_binary.major, sv.major)) == 0) {
1131 if ((res = 2*binary_comparison(version_binary.minor, sv.minor)) == 0) {
1132 res = semver_compare( version_binary, sv );
1133 }
1134 }
1135 semver_free( &sv );
1136 return res;
1137}
1138
1142static void print_SDLversion (void)
1143{
1144 const SDL_version *linked;
1145 SDL_version compiled;
1146 unsigned int version_linked, version_compiled;
1147
1148 /* Extract information. */
1149 SDL_VERSION(&compiled);
1150 SDL_version ll;
1151 SDL_GetVersion( &ll );
1152 linked = &ll;
1153 DEBUG( _("SDL: %d.%d.%d [compiled: %d.%d.%d]"),
1154 linked->major, linked->minor, linked->patch,
1155 compiled.major, compiled.minor, compiled.patch);
1156#ifndef DEBUGGING /* Shuts up cppcheck. */
1157 (void) compiled.patch;
1158#endif /* DEBUGGING */
1159
1160 /* Get version as number. */
1161 version_linked = linked->major*100 + linked->minor;
1162 version_compiled = compiled.major*100 + compiled.minor;
1163
1164 /* Check if major/minor version differ. */
1165 if (version_linked > version_compiled)
1166 WARN( _("SDL is newer than compiled version") );
1167 if (version_linked < version_compiled)
1168 WARN( _("SDL is older than compiled version.") );
1169}
1170
1174double naev_getrealdt (void)
1175{
1176 return real_dt;
1177}
void ai_exit(void)
Cleans up global AI.
Definition ai.c:773
int ai_load(void)
Initializes the AI stuff which is basically Lua.
Definition ai.c:590
int background_init(void)
Initializes the background system.
Definition background.c:417
void background_initDust(int n)
Initializes background dust.
Definition background.c:90
void background_free(void)
Cleans up and frees memory after the backgrounds.
Definition background.c:518
int background_load(const char *name)
Loads a background script by name.
Definition background.c:427
void cam_update(double dt)
Updates the camera.
Definition camera.c:221
void commodity_free(void)
Frees all the loaded commodities.
Definition commodity.c:504
int commodity_load(void)
Loads all the commodity data.
Definition commodity.c:462
void cond_exit(void)
Destroys the conditional subsystem.
Definition cond.c:41
int cond_init(void)
Initializes the conditional subsystem.
Definition cond.c:24
void cli_exit(void)
Destroys the CLI environment.
Definition console.c:516
int cli_init(void)
Initializes the CLI environment.
Definition console.c:499
int dtype_load(void)
Loads the dtype stack.
Definition damagetype.c:198
void dtype_free(void)
Frees the dtype stack.
Definition damagetype.c:234
void debug_sigInit(void)
Sets up the back-tracing signal handler.
Definition debug.c:211
void debug_enableLeakSanitizer(void)
Does nothing. Calling this tells our debug scripts to stop tracing.
Definition debug.c:262
void debug_sigClose(void)
Closes the back-tracing signal handler.
Definition debug.c:250
void dialogue_msg(const char *caption, const char *fmt,...)
Opens a dialogue window with an ok button and a message.
Definition dialogue.c:230
void economy_destroy(void)
Destroys the economy.
Definition economy.c:593
int effect_load(void)
Loads all the effects.
Definition effect.c:181
void effect_exit(void)
Gets rid of all the effects.
Definition effect.c:224
void events_exit(void)
Exits the event subsystem.
Definition event.c:728
int events_load(void)
Loads all the events.
Definition event.c:553
int factions_load(void)
Loads up all the factions from the data file.
Definition faction.c:1610
void factions_free(void)
Frees the factions.
Definition faction.c:1740
glFont gl_smallFont
Definition font.c:154
glFont gl_defFont
Definition font.c:153
int gl_printMidRaw(const glFont *ft_font, int width, double x, double y, const glColour *c, double outlineR, const char *text)
Displays text centered in position and width.
Definition font.c:788
void gl_print(const glFont *ft_font, const double x, const double y, const glColour *c, const char *fmt,...)
Prints text on screen like printf.
Definition font.c:691
void gl_freeFont(glFont *font)
Frees a loaded font. Caution: its glFontStash still has a slot in avail_fonts. At the time of writing...
Definition font.c:1723
int gl_fontInit(glFont *font, const char *fname, const unsigned int h, const char *prefix, unsigned int flags)
Initializes a font.
Definition font.c:1517
void gl_fontExit(void)
Frees all resources associated with the font system. This also resets font ID tracking,...
Definition font.c:1771
glFont gl_defFontMono
Definition font.c:155
void gettext_exit(void)
Free resources associated with the translation system. This invalidates previously returned pointers ...
Definition gettext.c:81
double gettext_languageCoverage(const char *lang)
Return the fraction of strings which have a translation into the given language.
Definition gettext.c:285
void gettext_setLanguage(const char *lang)
Set the translation language.
Definition gettext.c:125
const char * gettext_getLanguage(void)
Gets the active (primary) translation language. Even in case of a complex locale, this will be the na...
Definition gettext.c:112
void gettext_init(void)
Initialize the translation system. There's no presumption that PhysicsFS is available,...
Definition gettext.c:46
int gui_init(void)
Initializes the GUI system.
Definition gui.c:1623
void gui_free(void)
Frees the gui stuff.
Definition gui.c:2008
void gui_reload(void)
Reloads the GUI.
Definition gui.c:1756
int hooks_runParam(const char *stack, const HookParam *param)
Runs all the hooks of stack.
Definition hook.c:979
void hook_exclusionEnd(double dt)
Ends exclusion zone and runs all the queued hooks.
Definition hook.c:198
int hooks_run(const char *stack)
Runs all the hooks of stack.
Definition hook.c:999
void hook_exclusionStart(void)
Starts the hook exclusion zone, this makes hooks queue until exclusion is done.
Definition hook.c:190
void input_init(void)
Initializes the input subsystem (does not set keys).
Definition input.c:278
void input_handle(SDL_Event *event)
Handles global input.
Definition input.c:1485
void input_setDefault(int wasd)
Sets the default input keys.
Definition input.c:172
void input_update(double dt)
Handles key repeating.
Definition input.c:614
void input_exit(void)
exits the input subsystem.
Definition input.c:329
int joystick_get(const char *namjoystick)
Gets the joystick index by name.
Definition joystick.c:38
int joystick_init(void)
Initializes the joystick subsystem.
Definition joystick.c:148
int joystick_use(int indjoystick)
Makes the game use a joystick by index.
Definition joystick.c:57
void joystick_exit(void)
Exits the joystick subsystem.
Definition joystick.c:172
void land_exit(void)
Exits all the landing stuff.
Definition land.c:1642
void load_free(void)
Frees loaded save stuff.
Definition load.c:447
void log_clean(void)
Deletes useless (empty) log files from the current session.
Definition log.c:205
void log_init(void)
Sets up the logging subsystem. (Calling this ensures logging output is preserved until we have a plac...
Definition log.c:142
void log_redirect(void)
Sets up redirection of stdout and stderr to files. PhysicsFS must be initialized for this to work.
Definition log.c:108
Handles the important game menus.
void missions_free(void)
Frees all the mission data.
Definition mission.c:1245
int missions_load(void)
Loads all the mission data.
Definition mission.c:1120
int music_disabled
Definition music.c:32
int music_choose(const char *situation)
Actually runs the music stuff, based on situation.
Definition music.c:412
void music_exit(void)
Exits the music subsystem.
Definition music.c:138
void naev_renderLoadscreen(void)
Renders the loadscreen if necessary.
Definition naev.c:597
static double fps_dt
Definition naev.c:111
int naev_versionCompare(const char *version)
Compares the version against the current naev version.
Definition naev.c:1120
static int quit
Definition naev.c:100
static SDL_Surface * naev_icon
Definition naev.c:103
int main(int argc, char **argv)
The entry point of Naev.
Definition naev.c:170
double elapsed_time_mod
Definition naev.c:121
static void fps_init(void)
Initializes the fps engine.
Definition naev.c:855
void update_routine(double dt, int dohooks)
Actually runs the updates.
Definition naev.c:1038
static int fps_skipped
Definition naev.c:104
int naev_shouldRenderLoadscreen(void)
Whether or not we want to render the loadscreen.
Definition naev.c:556
static void loadscreen_unload(void)
Frees the loading screen.
Definition naev.c:628
static void print_SDLversion(void)
Prints the SDL version to console.
Definition naev.c:1142
static void unload_all(void)
Unloads all data, simplifies main().
Definition naev.c:711
static double fps
Definition naev.c:114
void fps_display(double dt)
Displays FPS on the screen.
Definition naev.c:945
void naev_quit(void)
Flags naev to quit.
Definition naev.c:150
double fps_current(void)
Gets the current FPS.
Definition naev.c:984
static double fps_elapsed(void)
Gets the elapsed time.
Definition naev.c:874
#define LOADING_STAGES
Loads all the data, makes main() simpler.
Definition naev.c:637
void naev_resize(void)
Wrapper for gl_resize that handles non-GL reinitialization.
Definition naev.c:790
int naev_isQuit(void)
Get if Naev is trying to quit.
Definition naev.c:158
static void window_caption(void)
Sets the window caption.
Definition naev.c:1085
static void loadscreen_update(double done, const char *msg)
Renders the load screen with message.
Definition naev.c:609
static void loadscreen_load(void)
Loads a loading screen.
Definition naev.c:521
static semver_t version_binary
Definition naev.c:106
const double fps_min
Definition naev.c:118
void main_loop(int nested)
Split main loop from main() for secondary loop hack in toolkit.c.
Definition naev.c:744
static double fps_x
Definition naev.c:116
double naev_getrealdt(void)
Gets the last delta-tick.
Definition naev.c:1174
static nlua_env load_env
Definition naev.c:123
static void update_all(int dohooks)
Updates the game itself (player flying around and friends).
Definition naev.c:994
static double game_dt
Definition naev.c:112
static double fps_y
Definition naev.c:117
Uint32 SDL_LOOPDONE
Definition naev.c:101
static Uint64 time_ms
Definition naev.c:102
static double fps_cur
Definition naev.c:115
static double real_dt
Definition naev.c:113
static void fps_control(void)
Controls the FPS.
Definition naev.c:904
void fps_setPos(double x, double y)
Sets the position to display the FPS.
Definition naev.c:934
Header file with generic functions and naev-specifics.
#define APPNAME
Definition naev.h:34
const char * naev_version(int long_version)
Returns the version in a human readable string.
#define PATH_MAX
Definition naev.h:50
void ndata_setupReadDirs(void)
Sets up the PhysicsFS search path.
Definition ndata.c:110
void ndata_setupWriteDir(void)
Gets Naev's data path (for user data such as saves and screenshots)
Definition ndata.c:88
void * ndata_read(const char *path, size_t *filesize)
Reads a file from the ndata (will be NUL terminated).
Definition ndata.c:154
void nebu_exit(void)
Cleans up the nebu subsystem.
Definition nebula.c:134
int nebu_resize(void)
Handles a screen s.
Definition nebula.c:87
int nebu_init(void)
Initializes the nebula.
Definition nebula.c:76
void news_exit(void)
Kills the old news thread.
Definition news.c:146
const char * nfile_configPath(void)
Gets Naev's config path (for user preferences such as conf.lua)
Definition nfile.c:116
int nfile_dirMakeExist(const char *path)
Creates a directory if it doesn't exist.
Definition nfile.c:267
const char * nfile_cachePath(void)
Gets Naev's cache path (for cached data such as generated textures)
Definition nfile.c:159
int nlua_loadStandard(nlua_env env)
Loads the standard Naev Lua API.
Definition nlua.c:798
void nlua_resize(void)
Propagates a resize event to all the environments forcibly.
Definition nlua.c:970
int nlua_loadCol(nlua_env env)
Loads the colour library.
Definition nlua_colour.c:54
int nlua_loadData(nlua_env env)
Loads the data library.
Definition nlua_data.c:54
int nlua_loadFile(nlua_env env)
Loads the file library.
Definition nlua_file.c:66
int nlua_loadGFX(nlua_env env)
Loads the graphics library.
Definition nlua_gfx.c:98
int nlua_loadNaev(nlua_env env)
Loads the Naev Lua library.
Definition nlua_naev.c:124
int nlua_loadRnd(nlua_env env)
Loads the Random Number Lua library.
Definition nlua_rnd.c:48
int nlua_loadTex(nlua_env env)
Loads the texture library.
Definition nlua_tex.c:62
void var_cleanup(void)
Cleans up all the mission variables.
Definition nlua_var.c:199
int nlua_loadVector(nlua_env env)
Loads the vector metatable.
Definition nlua_vec2.c:86
void npc_clear(void)
Cleans up the spaceport bar NPC.
Definition npc.c:470
void ntime_update(double dt)
Updatse the time based on realtime.
Definition ntime.c:69
void gl_resize(void)
Handles a window resize and resets gl_screen parameters.
Definition opengl.c:547
void gl_exit(void)
Cleans up OpenGL, the works.
Definition opengl.c:696
int gl_init(void)
Initializes SDL/OpenGL and the works.
Definition opengl.c:475
glInfo gl_screen
Definition opengl.c:51
int opt_setVideoMode(int w, int h, int fullscreen, int confirm)
Applies new video-mode options.
Definition options.c:1478
void opt_resize(void)
Handles resize events for the options menu.
Definition options.c:213
int outfit_load(void)
Loads all the outfits.
Definition outfit.c:2773
int outfit_mapParse(void)
Parses all the maps.
Definition outfit.c:2994
void outfit_free(void)
Frees the outfit stack.
Definition outfit.c:3068
int outfit_loadPost(void)
Loads all the outfits legality.
Definition outfit.c:2943
int player_paused
Definition pause.c:22
int paused
Definition pause.c:21
double dt_mod
Definition pause.c:23
void pilots_updatePurge(void)
Purges pilots set for deletion.
Definition pilot.c:3797
void pilots_init(void)
Initializes pilot stuff.
Definition pilot.c:3654
void pilots_update(double dt)
Updates all the pilots.
Definition pilot.c:3840
void pilots_free(void)
Frees the pilot stack.
Definition pilot.c:3663
void player_cleanup(void)
Cleans up player stuff like player_stack.
Definition player.c:730
double player_dt_default(void)
Returns the player's total default time delta based on time dilation stuff.
Definition player.c:1913
Player_t player
Definition player.c:74
int player_init(void)
Initializes player stuff.
Definition player.c:185
void player_updateAutonav(double dt)
Updates the player's autonav.
int plugin_check(void)
Checks to see if the plugins are self-declared compatible with Naev.
Definition plugin.c:230
void plugin_exit(void)
Exits the plugin stuff.
Definition plugin.c:195
void rng_init(void)
Initializes the random subsystem.
Definition rng.c:56
void safelanes_destroy(void)
Shuts down the safelanes system.
Definition safelanes.c:176
void safelanes_init(void)
Initializes the safelanes system.
Definition safelanes.c:164
int ships_load(void)
Loads all the ships in the data files.
Definition ship.c:1087
void ships_free(void)
Frees all the ships.
Definition ship.c:1205
void sp_cleanup(void)
Cleans up after the slot properties.
Definition slots.c:114
int sp_load(void)
Initializes the slot properties.
Definition slots.c:45
int sound_disabled
Definition sound.c:133
void sound_exit(void)
Cleans up after the sound subsytem.
Definition sound.c:665
int sound_update(double dt)
Updates the sounds removing obsolete ones and such.
Definition sound.c:908
int sound_init(void)
Initializes the sound subsystem.
Definition sound.c:602
void space_update(double dt, double real_dt)
Controls fleet spawning.
Definition space.c:1414
StarSystem * cur_system
Definition space.c:106
void space_exit(void)
Cleans up the system.
Definition space.c:3564
void space_checkLand(void)
Handles landing if necessary.
Definition space.c:1400
int space_load(void)
Loads the entire universe into ram - pretty big feat eh?
Definition space.c:3313
int space_loadLua(void)
initializes the Lua for all the spobs.
Definition space.c:3349
void spfx_free(void)
Frees the spfx stack.
Definition spfx.c:424
int spfx_load(void)
Loads the spfx stack.
Definition spfx.c:360
void spfx_update(const double dt, const double real_dt)
Updates all the spfx.
Definition spfx.c:550
void start_cleanup(void)
Cleans up after the module start data.
Definition start.c:156
int start_load(void)
Loads the module start data.
Definition start.c:52
const char * start_name(void)
Gets the module name.
Definition start.c:177
The actual hook parameter.
Definition hook.h:38
HookParamType type
Definition hook.h:39
union HookParam::@25 u
double num
Definition hook.h:41
int nosound
Definition conf.h:106
int font_size_def
Definition conf.h:141
int fullscreen
Definition conf.h:91
int vsync
Definition conf.h:83
int fps_max
Definition conf.h:113
int width
Definition conf.h:86
int font_size_small
Definition conf.h:142
char * language
Definition conf.h:79
int devmode
Definition conf.h:157
int pause_show
Definition conf.h:116
int height
Definition conf.h:87
int fps_show
Definition conf.h:112
char * lastversion
Definition conf.h:162
int translation_warning_seen
Definition conf.h:163
int fpu_except
Definition conf.h:167
int joystick_ind
Definition conf.h:119
char * joystick_nam
Definition conf.h:120
Pilot * p
Definition player.h:101
int h
Definition font.h:18
int rh
Definition opengl.h:51
SDL_Window * window
Definition opengl.h:68
int rw
Definition opengl.h:50
int h
Definition opengl.h:45
void tech_free(void)
Cleans up after the tech stuff.
Definition tech.c:141
int tech_load(void)
Loads the tech information.
Definition tech.c:91
void toolkit_resize(void)
Repositions windows and their children if resolution changes.
Definition toolkit.c:2595
void toolkit_update(void)
Updates the toolkit input for repeating keys.
Definition toolkit.c:2224
void toolkit_exit(void)
Exits the toolkit.
Definition toolkit.c:2665
int toolkit_init(void)
Initializes the toolkit.
Definition toolkit.c:2647
void toolkit_rerender(void)
Marks the toolkit for needing a full rerender.
Definition toolkit.c:1661
int diff_loadAvailable(void)
Loads available universe diffs.
Definition unidiff.c:199
void diff_free(void)
Clean up after diff_loadAvailable().
Definition unidiff.c:1535
void weapons_update(double dt)
Updates all the weapons.
Definition weapon.c:696
void weapons_updatePurge(void)
Purges unnecessary weapons.
Definition weapon.c:585
void weapons_updateCollide(double dt)
Handles weapon collisions.
Definition weapon.c:629
void weapon_exit(void)
Destroys all the weapons and frees it all.
Definition weapon.c:2696
void weapon_init(void)
Initializes the weapon stuff.
Definition weapon.c:128