naev 0.10.4
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 unsigned int 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./30.;
119double elapsed_time_mod = 0.;
121static nlua_env load_env = LUA_NOREF;
122static int load_force_render = 0;
123static unsigned int load_last_render = 0;
124
125/*
126 * prototypes
127 */
128/* Loading. */
129static void print_SDLversion (void);
130static void loadscreen_load (void);
131static void loadscreen_unload (void);
132static void load_all (void);
133static void unload_all (void);
134static void window_caption (void);
135/* update */
136static void fps_init (void);
137static double fps_elapsed (void);
138static void fps_control (void);
139static void update_all (void);
140/* Misc. */
141static void loadscreen_update( double done, const char *msg );
142void main_loop( int update ); /* dialogue.c */
143
147void naev_quit (void)
148{
149 quit = 1;
150}
151
155int naev_isQuit (void)
156{
157 return quit;
158}
159
167int main( int argc, char** argv )
168{
169 char conf_file_path[PATH_MAX], **search_path;
170 Uint32 starttime;
171
172#ifdef DEBUGGING
173 /* Set Debugging flags. */
174 memset( debug_flags , 0, DEBUG_FLAGS_MAX );
175#endif /* DEBUGGING */
176
177 env_detect( argc, argv );
178
179 log_init();
180
181 /* Set up PhysicsFS. */
182 if (PHYSFS_init( env.argv0 ) == 0) {
183 ERR( "PhysicsFS initialization failed: %s",
184 _( PHYSFS_getErrorByCode( PHYSFS_getLastErrorCode() ) ) );
185 return -1;
186 }
187 PHYSFS_permitSymbolicLinks( 1 );
188
189 /* Set up locales. */
190 gettext_init();
191 init_linebreak();
192
193 /* Parse version. */
194 if (semver_parse( naev_version( 0 ), &version_binary ))
195 WARN( _("Failed to parse version string '%s'!"), naev_version( 0 ) );
196
197 /* Print the version */
198 LOG( " %s v%s (%s)", APPNAME, naev_version(0), HOST );
199
200 if (env.isAppImage)
201 LOG( "AppImage detected. Running from: %s", env.appdir );
202 else
203 DEBUG( "AppImage not detected." );
204
205 /* Initializes SDL for possible warnings. */
206 if (SDL_Init( 0 )) {
207 ERR( _( "Unable to initialize SDL: %s" ), SDL_GetError() );
208 return -1;
209 }
210 starttime = SDL_GetTicks();
211 SDL_LOOPDONE = SDL_RegisterEvents(1);
212
213 /* Initialize the threadpool */
214 threadpool_init();
215
216 /* Set up debug signal handlers. */
218
219#if HAS_UNIX
220 /* Set window class and name. */
221 nsetenv("SDL_VIDEO_X11_WMCLASS", APPNAME, 0);
222#endif /* HAS_UNIX */
223
224 /* Must be initialized before input_init is called. */
225 if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
226 WARN( _("Unable to initialize SDL Video: %s"), SDL_GetError());
227 return -1;
228 }
229
230 /* We'll be parsing XML. */
231 LIBXML_TEST_VERSION
232 xmlInitParser();
233
234 /* Input must be initialized for config to work. */
235 input_init();
236
237 lua_init(); /* initializes lua */
238
239 conf_setDefaults(); /* set the default config values */
240
241 /*
242 * Attempts to load the data path from datapath.lua
243 * At this early point in the load process, the binary path
244 * is the only place likely to be checked.
245 */
246 conf_loadConfigPath();
247
248 /* Create the home directory if needed. */
250 WARN( _("Unable to create config directory '%s'"), nfile_configPath());
251
252 /* Set the configuration. */
253 snprintf(conf_file_path, sizeof(conf_file_path), "%s"CONF_FILE, nfile_configPath());
254
255 conf_loadConfig(conf_file_path); /* Lua to parse the configuration file */
256 conf_parseCLI( argc, argv ); /* parse CLI arguments */
257
258 /* Set up I/O. */
260 log_redirect();
262 gettext_setLanguage( conf.language ); /* now that we can find translations */
263 LOG( _("Loaded configuration: %s"), conf_file_path );
264 search_path = PHYSFS_getSearchPath();
265 LOG( "%s", _("Read locations, searched in order:") );
266 for (char **p = search_path; *p != NULL; p++)
267 LOG( " %s", *p );
268 PHYSFS_freeList( search_path );
269 /* Logging the cache path is noisy, noisy is good at the DEBUG level. */
270 DEBUG( _("Cache location: %s"), nfile_cachePath() );
271 LOG( _("Write location: %s\n"), PHYSFS_getWriteDir() );
272
273 /* Enable FPU exceptions. */
274 if (conf.fpu_except)
276
277 /* Load the start info. */
278 if (start_load())
279 ERR( _("Failed to load module start data.") );
280 LOG(" %s", start_name());
281 DEBUG_BLANK();
282
283 /* Display the SDL Version. */
285 DEBUG_BLANK();
286
287 /* random numbers */
288 rng_init();
289
290 /*
291 * OpenGL
292 */
293 if (gl_init()) { /* initializes video output */
294 ERR( _("Initializing video output failed, exiting…") );
295 SDL_Quit();
296 exit(EXIT_FAILURE);
297 }
299
300 /* Have to set up fonts before rendering anything. */
301 //DEBUG("Using '%s' as main font and '%s' as monospace font.", _(FONT_DEFAULT_PATH), _(FONT_MONOSPACE_PATH));
302 gl_fontInit( &gl_defFont, _(FONT_DEFAULT_PATH), conf.font_size_def, FONT_PATH_PREFIX, 0 ); /* initializes default font to size */
303 gl_fontInit( &gl_smallFont, _(FONT_DEFAULT_PATH), conf.font_size_small, FONT_PATH_PREFIX, 0 ); /* small font */
304 gl_fontInit( &gl_defFontMono, _(FONT_MONOSPACE_PATH), conf.font_size_def, FONT_PATH_PREFIX, 0 );
305
306 /* Detect size changes that occurred after window creation. */
307 naev_resize();
308
309 /* Display the load screen. */
311 loadscreen_update( 0., _("Initializing subsystems…") );
312 time_ms = SDL_GetTicks();
313
314 /*
315 * Input
316 */
317 if ((conf.joystick_ind >= 0) || (conf.joystick_nam != NULL)) {
318 if (joystick_init())
319 WARN( _("Error initializing joystick input") );
320 if (conf.joystick_nam != NULL) { /* use the joystick name to find a joystick */
322 WARN( _("Failure to open any joystick, falling back to default keybinds") );
324 }
325 free(conf.joystick_nam);
326 }
327 else if (conf.joystick_ind >= 0) /* use a joystick id instead */
328 if (joystick_use(conf.joystick_ind)) {
329 WARN( _("Failure to open any joystick, falling back to default keybinds") );
331 }
332 }
333
334 /*
335 * OpenAL - Sound
336 */
337 if (conf.nosound) {
338 LOG( _("Sound is disabled!") );
339 sound_disabled = 1;
340 music_disabled = 1;
341 }
342 if (sound_init())
343 WARN( _("Problem setting up sound!") );
344 music_choose("load");
345
346 /* FPS stuff. */
347 fps_setPos( 15., (double)(gl_screen.h-15-gl_defFontMono.h) );
348
349 /* Misc graphics init */
350 render_init();
351 if (nebu_init() != 0) { /* Initializes the nebula */
352 /* An error has happened */
353 ERR( _("Unable to initialize the Nebula subsystem!") );
354 /* Weirdness will occur... */
355 }
356 gui_init(); /* initializes the GUI graphics */
357 toolkit_init(); /* initializes the toolkit */
358 map_init(); /* initializes the map. */
359 map_system_init(); /* Initialise the solar system map */
360 cond_init(); /* Initialize conditional subsystem. */
361 cli_init(); /* Initialize console. */
362
363 /* Data loading */
364 load_all();
365
366 /* Detect size changes that occurred during load. */
367 naev_resize();
368
369 /* Unload load screen. */
371
372 /* Start menu. */
373 menu_main();
374
375 if (conf.devmode)
376 LOG( _( "Reached main menu in %.3f s" ), (SDL_GetTicks()-starttime)/1000. );
377 else
378 LOG( _( "Reached main menu" ) );
379
380 fps_init(); /* initializes the time_ms */
381
382 /*
383 * main loop
384 */
385 SDL_Event event;
386 /* flushes the event loop since I noticed that when the joystick is loaded it
387 * creates button events that results in the player starting out acceling */
388 while (SDL_PollEvent(&event));
389
390 /* Show plugin compatibility. */
391 plugin_check();
392
393 /* Incomplete translation note (shows once if we pick an incomplete translation based on user's locale). */
394 if ( !conf.translation_warning_seen && conf.language == NULL ) {
395 const char* language = gettext_getLanguage();
396 double coverage = gettext_languageCoverage(language);
397
398 if (coverage < 0.8) {
401 _("Incomplete Translation"),
402 _("%s is partially translated (%.0f%%) into your language (%s),"
403 " but the remaining text will be English. Language settings"
404 " are available in the \"%s\" screen."),
405 APPNAME, 100.*coverage, language, _("Options") );
406 }
407 }
408
409 /* Incomplete game note (shows every time version number changes). */
410 if ( conf.lastversion == NULL || naev_versionCompare(conf.lastversion) != 0 ) {
411 free( conf.lastversion );
412 conf.lastversion = strdup( naev_version(0) );
414 _("Welcome to Naev"),
415 _("Welcome to Naev version %s, and thank you for playing! We hope you"
416 " enjoy this game and all it has to offer. This is a passion"
417 " project developed exclusively by volunteers and it gives us all"
418 " great joy to know that there are others who love this game as"
419 " much as we do!\n"
420 " Of course, please note that this is an incomplete game. You"
421 " will encounter dead ends to storylines, missing storylines, and"
422 " possibly even some bugs, although we try to keep those to a"
423 " minimum of course. So be prepared for some rough edges for the"
424 " time being. That said, we are working on this game every day and"
425 " hope to one day finish this massive project on our hands."
426 " Perhaps you could become one of us, who knows?\n"
427 " For more information about the game and its development"
428 " state, take a look at naev.org; it has all the relevant links."
429 " And again, thank you for playing!"), conf.lastversion );
430 }
431
432 /* primary loop */
433 while (!quit) {
434 while (!quit && SDL_PollEvent(&event)) { /* event loop */
435 if (event.type == SDL_QUIT) {
436 if (quit || menu_askQuit()) {
437 quit = 1; /* quit is handled here */
438 break;
439 }
440 }
441 else if (event.type == SDL_WINDOWEVENT &&
442 event.window.event == SDL_WINDOWEVENT_RESIZED) {
443 naev_resize();
444 continue;
445 }
446 input_handle(&event); /* handles all the events and player keybinds */
447 }
448
449 main_loop( 1 );
450 }
451
452 /* Save configuration. */
453 conf_saveConfig(conf_file_path);
454
455 /* data unloading */
456 unload_all();
457
458 /* cleanup opengl fonts */
459 gl_freeFont(NULL);
462
463 start_cleanup(); /* Cleanup from start.c, not the first cleanup step. :) */
464
465 /* exit subsystems */
466 plugin_exit();
467 cli_exit(); /* Clean up the console. */
468 map_system_exit(); /* Destroys the solar system map. */
469 map_exit(); /* Destroys the map. */
470 ovr_mrkFree(); /* Clear markers. */
471 toolkit_exit(); /* Kills the toolkit */
472 ai_exit(); /* Stops the Lua AI magic */
473 joystick_exit(); /* Releases joystick */
474 input_exit(); /* Cleans up keybindings */
475 nebu_exit(); /* Destroys the nebula */
476 render_exit(); /* Cleans up post-processing. */
477 news_exit(); /* Destroys the news. */
478 difficulty_free(); /* Clean up difficulties. */
479 music_exit(); /* Kills Lua state. */
480 lua_exit(); /* Closes Lua state, and invalidates all Lua. */
481 sound_exit(); /* Kills the sound */
482 gl_exit(); /* Kills video output */
483
484 /* Has to be run last or it will mess up sound settings. */
485 conf_cleanup(); /* Free some memory the configuration allocated. */
486
487 /* Free the icon. */
488 if (naev_icon)
489 SDL_FreeSurface(naev_icon);
490
491 IMG_Quit(); /* quits SDL_image */
492 SDL_Quit(); /* quits SDL */
493
494 /* Clean up parser. */
495 xmlCleanupParser();
496
497 /* Clean up signal handler. */
499
500 /* Delete logs if empty. */
501 log_clean();
502
503 /* Really turn the lights off. */
504 PHYSFS_deinit();
505 gl_fontExit();
506 gettext_exit();
507
508 /* all is well */
510 return 0;
511}
512
517{
518 int r;
519
520 load_env = nlua_newEnv();
522 r |= nlua_loadNaev( load_env );
523 r |= nlua_loadRnd( load_env );
525 r |= nlua_loadFile( load_env );
526 r |= nlua_loadData( load_env );
527 r |= nlua_loadTex( load_env );
528 r |= nlua_loadCol( load_env );
529 r |= nlua_loadGFX( load_env );
530 if (r)
531 WARN(_("Something went wrong when loading Lua libraries for '%s'!"), LOADSCREEN_DATA_PATH);
532
533 size_t bufsize;
534 char *buf = ndata_read( LOADSCREEN_DATA_PATH, &bufsize );
535 if (nlua_dobufenv(load_env, buf, bufsize, LOADSCREEN_DATA_PATH) != 0) {
536 WARN( _("Error loading file: %s\n"
537 "%s\n"
538 "Most likely Lua file has improper syntax, please check"),
539 LOADSCREEN_DATA_PATH, lua_tostring(naevL,-1));
540 free(buf);
541 return;
542 }
543 free(buf);
544}
545
550{
551 SDL_Event event;
552 unsigned int t = SDL_GetTicks();
553
554 /* Only render if forced or try for low 10 FPS. */
555 if (!load_force_render && (t-load_last_render) < 100 )
556 return;
557 load_last_render = t;
558
559 /* Clear background. */
560 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
561
562 /* Run Lua. */
563 nlua_getenv( naevL, load_env, "render" );
564 if (nlua_pcall(load_env, 0, 0)) { /* error has occurred */
565 WARN( _("Loadscreen '%s': '%s'"), "render", lua_tostring(naevL,-1));
566 lua_pop(naevL,1);
567 }
568
569 /* Get rid of events again. */
570 while (SDL_PollEvent(&event));
571
572 /* Flip buffers. HACK: Also try to catch a late-breaking resize from the WM (...or a crazy user?). */
573 SDL_GL_SwapWindow( gl_screen.window );
574 naev_resize();
575
576 /* Clear forcing. */
577 load_force_render = 0;
578}
579
586void loadscreen_update( double done, const char *msg )
587{
588 /* Run Lua. */
589 nlua_getenv( naevL, load_env, "update" );
590 lua_pushnumber( naevL, done );
591 lua_pushstring( naevL, msg );
592 if (nlua_pcall(load_env, 2, 0)) { /* error has occurred */
593 WARN( _("Loadscreen '%s': '%s'"), "update", lua_tostring(naevL,-1));
594 lua_pop(naevL,1);
595 }
596
597 /* Force rerender. */
598 load_force_render = 1;
600}
601
605static void loadscreen_unload (void)
606{
607 nlua_freeEnv( load_env );
608}
609
613#define LOADING_STAGES 17.
614void load_all (void)
615{
616 int stage = 0;
617 /* We can do fast stuff here. */
618 sp_load();
619
620 /* order is very important as they're interdependent */
621 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Commodities…") );
622 commodity_load(); /* dep for space */
623
624 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Special Effects…") );
625 spfx_load(); /* no dep */
626
627 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Effects…") );
628 effect_load(); /* no dep */
629
630 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Damage Types…") );
631 dtype_load(); /* dep for outfits */
632
633 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Outfits…") );
634 outfit_load(); /* dep for ships, factions */
635
636 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Ships…") );
637 ships_load(); /* dep for fleet */
638
639 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Factions…") );
640 factions_load(); /* dep for fleet, space, missions, AI */
641
642 /* Handle outfit loading part that may use ships and factions. */
644
645 loadscreen_update( ++stage/LOADING_STAGES, _("Loading AI…") );
646 ai_load(); /* dep for fleets */
647
648 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Techs…") );
649 tech_load(); /* dep for space */
650
651 loadscreen_update( ++stage/LOADING_STAGES, _("Loading the Universe…") );
652 space_load(); /* dep for events/missions */
653
654 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Events…") );
655 events_load();
656
657 loadscreen_update( ++stage/LOADING_STAGES, _("Loading Missions…") );
659
660 loadscreen_update( ++stage/LOADING_STAGES, _("Loading the UniDiffs…") );
662
663 loadscreen_update( ++stage/LOADING_STAGES, _("Populating Maps…") );
665
666 loadscreen_update( ++stage/LOADING_STAGES, _("Calculating Patrols…") );
668
669 loadscreen_update( ++stage/LOADING_STAGES, _("Initializing Details…") );
670#if DEBUGGING
671 if (stage > LOADING_STAGES)
672 WARN(_("Too many loading stages, please increase LOADING_STAGES"));
673#endif /* DEBUGGING */
674 difficulty_load();
676 map_load();
677 map_system_load();
679 pilots_init();
680 weapon_init();
681 player_init(); /* Initialize player stuff. */
682 loadscreen_update( 1., _("Loading Completed!") );
683}
687void unload_all (void)
688{
689 /* cleanup some stuff */
690 player_cleanup(); /* cleans up the player stuff */
691 gui_free(); /* cleans up the player's GUI */
692 weapon_exit(); /* destroys all active weapons */
693 pilots_free(); /* frees the pilots, they were locked up :( */
694 cond_exit(); /* destroy conditional subsystem. */
695 land_exit(); /* Destroys landing vbo and friends. */
696 npc_clear(); /* In case exiting while landed. */
697 background_free(); /* Destroy backgrounds. */
698 load_free(); /* Clean up loading game stuff stuff. */
700 diff_free();
701 economy_destroy(); /* must be called before space_exit */
702 space_exit(); /* cleans up the universe itself */
703 tech_free(); /* Frees tech stuff. */
704 ships_free();
705 outfit_free();
706 spfx_free(); /* gets rid of the special effect */
707 effect_exit();
708 dtype_free(); /* gets rid of the damage types */
710 events_exit(); /* Clean up events. */
712 commodity_free();
713 var_cleanup(); /* cleans up mission variables */
714 sp_cleanup();
715}
716
720void main_loop( int update )
721{
722 /*
723 * Control FPS.
724 */
725 fps_control(); /* everyone loves fps control */
726
727 /*
728 * Handle update.
729 */
730 input_update( real_dt ); /* handle key repeats. */
731 sound_update( real_dt ); /* Update sounds. */
732 toolkit_update(); /* to simulate key repetition and get rid of windows */
733 if (!paused && update) {
734 /* Important that we pass real_dt here otherwise we get a dt feedback loop which isn't pretty. */
736 update_all(); /* update game */
737 }
738 else if (!dialogue_isOpen()) {
739 /* We run the exclusion end here to handle any hooks that are potentially manually triggered by hook.trigger. */
740 hook_exclusionEnd( 0. );
741 }
742
743 /* Safe hook should be run every frame regardless of whether game is paused or not. */
744 hooks_run( "safe" );
745
746 /* Checks to see if we want to land. */
748
749 /*
750 * Handle render.
751 */
752 if (!quit) { /* So if update sets up a nested main loop, we can end up in a
753 state where things are corrupted when trying to exit the game.
754 Avoid rendering when quitting just in case. */
755 /* Clear buffer. */
756 render_all( game_dt, real_dt );
757 /* Draw buffer. */
758 SDL_GL_SwapWindow( gl_screen.window );
759 }
760}
761
765void naev_resize (void)
766{
767 /* Auto-detect window size. */
768 int w, h;
769 SDL_GL_GetDrawableSize( gl_screen.window, &w, &h );
770
771 /* Update options menu, if open. (Never skip, in case the fullscreen mode alone changed.) */
772 opt_resize();
773
774 /* Nothing to do. */
775 if ((w == gl_screen.rw) && (h == gl_screen.rh))
776 return;
777
778 /* Resize the GL context, etc. */
779 gl_resize();
780
781 /* Regenerate the background stars. */
782 if (cur_system != NULL)
784 else
785 background_initDust( 1000. ); /* from loadscreen_load */
786
787 /* Must be before gui_reload */
788 fps_setPos( 15., (double)(SCREEN_H-15-gl_defFontMono.h) );
789
790 /* Reload the GUI (may regenerate land window) */
791 gui_reload();
792
793 /* Resets dimensions in other components which care. */
794 ovr_refresh();
797 nebu_resize();
798
799 /* Lua stuff. */
800 nlua_resize();
801
802 /* Finally do a render pass to avoid half-rendered stuff. */
803 render_all( 0., 0. );
804 SDL_GL_SwapWindow( gl_screen.window );
805
806 /* Force render. */
807 load_force_render = 1;
808}
809
810/*
811 * @brief Toggles between windowed and fullscreen mode.
812 */
813void naev_toggleFullscreen (void)
814{
815 opt_setVideoMode( conf.width, conf.height, !conf.fullscreen, 0 );
816}
817
818#if HAS_POSIX && defined(CLOCK_MONOTONIC)
819static struct timespec global_time;
820static int use_posix_time;
821#endif /* HAS_POSIX && defined(CLOCK_MONOTONIC) */
825static void fps_init (void)
826{
827#if HAS_POSIX && defined(CLOCK_MONOTONIC)
828 use_posix_time = 1;
829 /* We must use clock_gettime here instead of gettimeofday mainly because this
830 * way we are not influenced by changes to the time source like say ntp which
831 * could skew up the dt calculations. */
832 if (clock_gettime(CLOCK_MONOTONIC, &global_time)==0)
833 return;
834 WARN( _("clock_gettime failed, disabling POSIX time.") );
835 use_posix_time = 0;
836#endif /* HAS_POSIX && defined(CLOCK_MONOTONIC) */
837 time_ms = SDL_GetTicks();
838}
844static double fps_elapsed (void)
845{
846 double dt;
847 unsigned int t;
848
849#if HAS_POSIX && defined(CLOCK_MONOTONIC)
850 struct timespec ts;
851
852 if (use_posix_time) {
853 if (clock_gettime(CLOCK_MONOTONIC, &ts)==0) {
854 dt = ts.tv_sec - global_time.tv_sec;
855 dt += (ts.tv_nsec - global_time.tv_nsec) / 1e9;
856 global_time = ts;
857 return dt;
858 }
859 WARN( _("clock_gettime failed!") );
860 }
861#endif /* HAS_POSIX && defined(CLOCK_MONOTONIC) */
862
863 t = SDL_GetTicks();
864 dt = (double)(t - time_ms); /* Get the elapsed ms. */
865 dt /= 1000.; /* Convert to seconds. */
866 time_ms = t;
867
868 return dt;
869}
870
874static void fps_control (void)
875{
876#if HAS_POSIX
877 struct timespec ts;
878#endif /* HAS_POSIX */
879
880 /* dt in s */
882 game_dt = real_dt * dt_mod; /* Apply the modifier. */
883
884 /* if fps is limited */
885 if (!conf.vsync && conf.fps_max != 0) {
886 const double fps_max = 1./(double)conf.fps_max;
887 if (real_dt < fps_max) {
888 double delay = fps_max - real_dt;
889#if HAS_POSIX
890 ts.tv_sec = floor( delay );
891 ts.tv_nsec = fmod( delay, 1. ) * 1e9;
892 nanosleep( &ts, NULL );
893#else /* HAS_POSIX */
894 SDL_Delay( (unsigned int)(delay * 1000) );
895#endif /* HAS_POSIX */
896 fps_dt += delay; /* makes sure it displays the proper fps */
897 }
898 }
899}
900
904void fps_setPos( double x, double y )
905{
906 fps_x = x;
907 fps_y = y;
908}
909
915void display_fps( const double dt )
916{
917 double x,y;
918 double dt_mod_base = 1.;
919
920 fps_dt += dt;
921 fps_cur += 1.;
922 if (fps_dt > 1.) { /* recalculate every second */
923 fps = fps_cur / fps_dt;
924 fps_dt = fps_cur = 0.;
925 }
926
927 x = fps_x;
928 y = fps_y;
929 if (conf.fps_show) {
930 gl_print( &gl_defFontMono, x, y, &cFontWhite, "%3.2f", fps );
931 y -= gl_defFontMono.h + 5.;
932 }
933
934 if ((player.p != NULL) && !player_isFlag(PLAYER_DESTROYED) &&
935 !player_isFlag(PLAYER_CREATING)) {
936 dt_mod_base = player_dt_default();
937 }
938 if (dt_mod != dt_mod_base)
939 gl_print( &gl_defFontMono, x, y, &cFontWhite, "%3.1fx", dt_mod / dt_mod_base);
940
941 if (!paused || !player_paused || !conf.pause_show)
942 return;
943
944 y = SCREEN_H / 3. - gl_defFontMono.h / 2.;
945 gl_printMidRaw( &gl_defFontMono, SCREEN_W, 0., y,
946 &cFontWhite, -1., _("PAUSED") );
947}
948
954static void update_all (void)
955{
956 if ((real_dt > 0.25) && (fps_skipped==0)) { /* slow timers down and rerun calculations */
957 fps_skipped = 1;
958 return;
959 }
960 else if (game_dt > fps_min) { /* we'll force a minimum FPS for physics to work alright. */
961 int n;
962 double nf, microdt, accumdt;
963
964 /* Number of frames. */
965 nf = ceil( game_dt / fps_min );
966 microdt = game_dt / nf;
967 n = (int) nf;
968
969 /* Update as much as needed, evenly. */
970 accumdt = 0.;
971 for (int i=0; i<n; i++) {
972 update_routine( microdt, 0 );
973 /* OK, so we need a bit of hackish logic here in case we are chopping up a
974 * very large dt and it turns out time compression changes so we're now
975 * updating in "normal time compression" zone. This amounts to many updates
976 * being run when time compression has changed and thus can cause, say, the
977 * player to exceed their target position or get mauled by an enemy ship.
978 */
979 accumdt += microdt;
980 if (accumdt > dt_mod*real_dt)
981 break;
982 }
983
984 /* Note we don't touch game_dt so that fps_display works well */
985 }
986 else /* Standard, just update with the last dt */
988
989 fps_skipped = 0;
990}
991
998void update_routine( double dt, int enter_sys )
999{
1000 if (!enter_sys) {
1002
1003 /* Update time. */
1004 ntime_update( dt );
1005 }
1006
1007 /* Update engine stuff. */
1008 space_update(dt, real_dt);
1009 weapons_update(dt);
1010 spfx_update(dt, real_dt);
1011 pilots_update(dt);
1012
1013 /* Update camera. */
1014 cam_update( dt );
1015
1016 /* Update the elapsed time, should be with all the modifications and such. */
1017 elapsed_time_mod += dt;
1018
1019 if (!enter_sys) {
1020 HookParam h[3];
1021 hook_exclusionEnd( dt );
1022 /* Hook set up. */
1023 h[0].type = HOOK_PARAM_NUMBER;
1024 h[0].u.num = dt;
1025 h[1].type = HOOK_PARAM_NUMBER;
1026 h[1].u.num = real_dt;
1027 h[2].type = HOOK_PARAM_SENTINEL;
1028 /* Run the update hook. */
1029 hooks_runParam( "update", h );
1030 }
1031}
1032
1036static void window_caption (void)
1037{
1038 char *buf;
1039 SDL_RWops *rw;
1040
1041 /* Load icon. */
1042 rw = PHYSFSRWOPS_openRead( GFX_PATH"icon.webp" );
1043 if (rw == NULL) {
1044 WARN( _("Icon (icon.webp) not found!") );
1045 return;
1046 }
1047 naev_icon = IMG_Load_RW( rw, 1 );
1048 if (naev_icon == NULL) {
1049 WARN( _("Unable to load icon.webp!") );
1050 return;
1051 }
1052
1053 /* Set caption. */
1054 asprintf( &buf, APPNAME" - %s", _(start_name()) );
1055 SDL_SetWindowTitle( gl_screen.window, buf );
1056 SDL_SetWindowIcon( gl_screen.window, naev_icon );
1057 free( buf );
1058}
1059
1060static int binary_comparison( int x, int y )
1061{
1062 if (x == y) return 0;
1063 if (x > y) return 1;
1064 return -1;
1065}
1071int naev_versionCompare( const char *version )
1072{
1073 int res;
1074 semver_t sv;
1075
1076 if (semver_parse( version, &sv )) {
1077 WARN( _("Failed to parse version string '%s'!"), version );
1078 return -1;
1079 }
1080
1081 if ((res = 3*binary_comparison(version_binary.major, sv.major)) == 0) {
1082 if ((res = 2*binary_comparison(version_binary.minor, sv.minor)) == 0) {
1083 res = semver_compare( version_binary, sv );
1084 }
1085 }
1086 semver_free( &sv );
1087 return res;
1088}
1089
1093static void print_SDLversion (void)
1094{
1095 const SDL_version *linked;
1096 SDL_version compiled;
1097 unsigned int version_linked, version_compiled;
1098
1099 /* Extract information. */
1100 SDL_VERSION(&compiled);
1101 SDL_version ll;
1102 SDL_GetVersion( &ll );
1103 linked = &ll;
1104 DEBUG( _("SDL: %d.%d.%d [compiled: %d.%d.%d]"),
1105 linked->major, linked->minor, linked->patch,
1106 compiled.major, compiled.minor, compiled.patch);
1107
1108 /* Get version as number. */
1109 version_linked = linked->major*100 + linked->minor;
1110 version_compiled = compiled.major*100 + compiled.minor;
1111
1112 /* Check if major/minor version differ. */
1113 if (version_linked > version_compiled)
1114 WARN( _("SDL is newer than compiled version") );
1115 if (version_linked < version_compiled)
1116 WARN( _("SDL is older than compiled version.") );
1117}
1118
1122double naev_getrealdt (void)
1123{
1124 return real_dt;
1125}
void ai_exit(void)
Cleans up global AI.
Definition: ai.c:695
int ai_load(void)
Initializes the AI stuff which is basically Lua.
Definition: ai.c:525
int background_init(void)
Initializes the background system.
Definition: background.c:437
void background_initDust(int n)
Initializes background stars.
Definition: background.c:90
void background_free(void)
Cleans up and frees memory after the backgrounds.
Definition: background.c:538
void cam_update(double dt)
Updates the camera.
Definition: camera.c:221
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:515
int cli_init(void)
Initializes the CLI environment.
Definition: console.c:498
int dtype_load(void)
Loads the dtype stack.
Definition: damagetype.c:181
void dtype_free(void)
Frees the dtype stack.
Definition: damagetype.c:215
void debug_sigInit(void)
Sets up the back-tracing signal handler.
Definition: debug.c:192
void debug_enableLeakSanitizer(void)
Does nothing. Calling this tells our debug scripts to stop tracing.
Definition: debug.c:243
void debug_sigClose(void)
Closes the back-tracing signal handler.
Definition: debug.c:230
void debug_enableFPUExcept(void)
Enables FPU exceptions. Artificially limited to Linux until link issues are figured out.
Definition: debug_fpu.c:27
void dialogue_msg(const char *caption, const char *fmt,...)
Opens a dialogue window with an ok button and a message.
Definition: dialogue.c:218
int dialogue_isOpen(void)
Checks to see if a dialogue is open.
Definition: dialogue.c:98
void economy_destroy(void)
Destroys the economy.
Definition: economy.c:593
int effect_load(void)
Loads all the effects.
Definition: effect.c:168
void effect_exit(void)
Gets rid of all the effects.
Definition: effect.c:202
void events_exit(void)
Exits the event subsystem.
Definition: event.c:678
int events_load(void)
Loads all the events.
Definition: event.c:519
int factions_load(void)
Loads up all the factions from the data file.
Definition: faction.c:1583
void factions_free(void)
Frees the factions.
Definition: faction.c:1705
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:787
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:690
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:1722
int gl_fontInit(glFont *font, const char *fname, const unsigned int h, const char *prefix, unsigned int flags)
Initializes a font.
Definition: font.c:1516
void gl_fontExit(void)
Frees all resources associated with the font system. This also resets font ID tracking,...
Definition: font.c:1770
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:70
double gettext_languageCoverage(const char *lang)
Return the fraction of strings which have a translation into the given language.
Definition: gettext.c:269
void gettext_setLanguage(const char *lang)
Set the translation language.
Definition: gettext.c:106
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:93
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:1592
void gui_free(void)
Frees the gui stuff.
Definition: gui.c:1969
void gui_reload(void)
Reloads the GUI.
Definition: gui.c:1730
int hooks_runParam(const char *stack, const HookParam *param)
Runs all the hooks of stack.
Definition: hook.c:967
void hook_exclusionEnd(double dt)
Ends exclusion zone and runs all the queued hooks.
Definition: hook.c:195
int hooks_run(const char *stack)
Runs all the hooks of stack.
Definition: hook.c:987
void hook_exclusionStart(void)
Starts the hook exclusion zone, this makes hooks queue until exclusion is done.
Definition: hook.c:187
void input_init(void)
Initializes the input subsystem (does not set keys).
Definition: input.c:283
void input_handle(SDL_Event *event)
Handles global input.
Definition: input.c:1489
void input_setDefault(int wasd)
Sets the default input keys.
Definition: input.c:176
void input_update(double dt)
Handles key repeating.
Definition: input.c:619
void input_exit(void)
exits the input subsystem.
Definition: input.c:334
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:1718
void load_free(void)
Frees loaded save stuff.
Definition: load.c:453
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 menu_main(void)
Opens the main menu (titlescreen).
Definition: menu.c:165
int menu_askQuit(void)
Menu to ask if player really wants to quit.
Definition: menu.c:685
void menu_main_resize(void)
Resizes the main menu and its background.
Definition: menu.c:273
void missions_free(void)
Frees all the mission data.
Definition: mission.c:1160
int missions_load(void)
Loads all the mission data.
Definition: mission.c:1041
int music_disabled
Definition: music.c:32
int music_choose(const char *situation)
Actually runs the music stuff, based on situation.
Definition: music.c:413
void music_exit(void)
Exits the music subsystem.
Definition: music.c:139
void naev_renderLoadscreen(void)
Renders the loadscreen if necessary.
Definition: naev.c:549
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:1071
static int quit
Definition: naev.c:100
static SDL_Surface * naev_icon
Definition: naev.c:103
static void update_all(void)
Updates the game itself (player flying around and friends).
Definition: naev.c:954
static unsigned int time_ms
Definition: naev.c:102
int main(int argc, char **argv)
The entry point of Naev.
Definition: naev.c:167
double elapsed_time_mod
Definition: naev.c:119
static void fps_init(void)
Initializes the fps engine.
Definition: naev.c:825
static int fps_skipped
Definition: naev.c:104
static void loadscreen_unload(void)
Frees the loading screen.
Definition: naev.c:605
void display_fps(const double dt)
Displays FPS on the screen.
Definition: naev.c:915
void main_loop(int update)
Split main loop from main() for secondary loop hack in toolkit.c.
Definition: naev.c:720
static void print_SDLversion(void)
Prints the SDL version to console.
Definition: naev.c:1093
static void unload_all(void)
Unloads all data, simplifies main().
Definition: naev.c:687
static double fps
Definition: naev.c:114
void update_routine(double dt, int enter_sys)
Actually runs the updates.
Definition: naev.c:998
void naev_quit(void)
Flags naev to quit.
Definition: naev.c:147
static double fps_elapsed(void)
Gets the elapsed time.
Definition: naev.c:844
#define LOADING_STAGES
Loads all the data, makes main() simpler.
Definition: naev.c:613
void naev_resize(void)
Wrapper for gl_resize that handles non-GL reinitialization.
Definition: naev.c:765
int naev_isQuit(void)
Get if Naev is trying to quit.
Definition: naev.c:155
static void window_caption(void)
Sets the window caption.
Definition: naev.c:1036
static void loadscreen_update(double done, const char *msg)
Renders the load screen with message.
Definition: naev.c:586
static void loadscreen_load(void)
Loads a loading screen.
Definition: naev.c:516
static semver_t version_binary
Definition: naev.c:106
const double fps_min
Definition: naev.c:118
static double fps_x
Definition: naev.c:116
double naev_getrealdt(void)
Gets the last delta-tick.
Definition: naev.c:1122
static nlua_env load_env
Definition: naev.c:121
static double game_dt
Definition: naev.c:112
static double fps_y
Definition: naev.c:117
Uint32 SDL_LOOPDONE
Definition: naev.c:101
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:874
void fps_setPos(double x, double y)
Sets the position to display the FPS.
Definition: naev.c:904
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.
Definition: naev_version.c:25
#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
static char buf[NEWS_MAX_LENGTH]
Definition: news.c:45
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:760
void nlua_resize(void)
Propagates a resize event to all the environments forcibly.
Definition: nlua.c:923
int nlua_loadCol(nlua_env env)
Loads the colour library.
Definition: nlua_colour.c:52
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:64
int nlua_loadGFX(nlua_env env)
Loads the graphics library.
Definition: nlua_gfx.c:97
int nlua_loadNaev(nlua_env env)
Loads the Naev Lua library.
Definition: nlua_naev.c:114
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:80
void npc_clear(void)
Cleans up the spaceport bar NPC.
Definition: npc.c:469
int asprintf(char **strp, const char *fmt,...)
Like sprintf(), but it allocates a large-enough string and returns the pointer in the first argument....
Definition: nstring.c:161
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:1556
void opt_resize(void)
Handles resize events for the options menu.
Definition: options.c:214
int outfit_load(void)
Loads all the outfits.
Definition: outfit.c:2511
int outfit_mapParse(void)
Parses all the maps.
Definition: outfit.c:2685
void outfit_free(void)
Frees the outfit stack.
Definition: outfit.c:2759
int outfit_loadPost(void)
Loads all the outfits legality.
Definition: outfit.c:2634
int player_paused
Definition: pause.c:22
int paused
Definition: pause.c:21
double dt_mod
Definition: pause.c:23
void pilots_init(void)
Initializes pilot stuff.
Definition: pilot.c:3520
void pilots_update(double dt)
Updates all the pilots.
Definition: pilot.c:3653
void pilots_free(void)
Frees the pilot stack.
Definition: pilot.c:3528
void player_cleanup(void)
Cleans up player stuff like player_stack.
Definition: player.c:697
double player_dt_default(void)
Returns the player's total default time delta based on time dilation stuff.
Definition: player.c:1871
Player_t player
Definition: player.c:73
int player_init(void)
Initializes player stuff.
Definition: player.c:184
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:173
void safelanes_init(void)
Initializes the safelanes system.
Definition: safelanes.c:161
int ships_load(void)
Loads all the ships in the data files.
Definition: ship.c:1021
void ships_free(void)
Frees all the ships.
Definition: ship.c:1072
void sp_cleanup(void)
Cleans up after the slot properties.
Definition: slots.c:106
int sp_load(void)
Initializes the slot properties.
Definition: slots.c:44
int sound_disabled
Definition: sound.c:133
void sound_exit(void)
Cleans up after the sound subsytem.
Definition: sound.c:673
int sound_update(double dt)
Updates the sounds removing obsolete ones and such.
Definition: sound.c:916
int sound_init(void)
Initializes the sound subsystem.
Definition: sound.c:610
void space_update(double dt, double real_dt)
Controls fleet spawning.
Definition: space.c:1366
StarSystem * cur_system
Definition: space.c:105
void space_exit(void)
Cleans up the system.
Definition: space.c:3518
void space_checkLand(void)
Handles landing if necessary.
Definition: space.c:1352
int space_load(void)
Loads the entire universe into ram - pretty big feat eh?
Definition: space.c:3237
int space_loadLua(void)
initializes the Lua for all the spobs.
Definition: space.c:3306
void spfx_free(void)
Frees the spfx stack.
Definition: spfx.c:411
int spfx_load(void)
Loads the spfx stack.
Definition: spfx.c:348
void spfx_update(const double dt, const double real_dt)
Updates all the spfx.
Definition: spfx.c:537
void start_cleanup(void)
Cleans up after the module start data.
Definition: start.c:147
int start_load(void)
Loads the module start data.
Definition: start.c:48
const char * start_name(void)
Gets the module name.
Definition: start.c:165
The actual hook parameter.
Definition: hook.h:35
union HookParam::@4 u
HookParamType type
Definition: hook.h:36
double num
Definition: hook.h:38
int nosound
Definition: conf.h:107
int font_size_def
Definition: conf.h:143
int fullscreen
Definition: conf.h:92
int vsync
Definition: conf.h:84
int fps_max
Definition: conf.h:114
int width
Definition: conf.h:87
int font_size_small
Definition: conf.h:144
char * language
Definition: conf.h:80
int devmode
Definition: conf.h:158
int pause_show
Definition: conf.h:117
int height
Definition: conf.h:88
int fps_show
Definition: conf.h:113
char * lastversion
Definition: conf.h:163
int translation_warning_seen
Definition: conf.h:164
int fpu_except
Definition: conf.h:168
int joystick_ind
Definition: conf.h:120
char * joystick_nam
Definition: conf.h:121
Pilot * p
Definition: player.h:101
int h
Definition: font.h:18
int rh
Definition: opengl.h:47
SDL_Window * window
Definition: opengl.h:64
int rw
Definition: opengl.h:46
int h
Definition: opengl.h:41
void tech_free(void)
Cleans up after the tech stuff.
Definition: tech.c:138
int tech_load(void)
Loads the tech information.
Definition: tech.c:91
void toolkit_update(void)
Updates the toolkit input for repeating keys.
Definition: toolkit.c:2218
void toolkit_exit(void)
Exits the toolkit.
Definition: toolkit.c:2651
int toolkit_init(void)
Initializes the toolkit.
Definition: toolkit.c:2633
void toolkit_reposition(void)
Repositions windows and their children if resolution changes.
Definition: toolkit.c:2582
int diff_loadAvailable(void)
Loads available universe diffs.
Definition: unidiff.c:197
void diff_free(void)
Clean up after diff_loadAvailable().
Definition: unidiff.c:1485
void weapons_update(const double dt)
Updates all the weapon layers.
Definition: weapon.c:548
void weapon_exit(void)
Destroys all the weapons and frees it all.
Definition: weapon.c:2179
void weapon_init(void)
Initializes the weapon stuff.
Definition: weapon.c:157