naev 0.12.6
naev.c File Reference

Controls the overall game flow: data loading/unloading and game loop. More...

#include "ai.h"
#include "background.h"
#include "camera.h"
#include "cond.h"
#include "conf.h"
#include "console.h"
#include "damagetype.h"
#include "debug.h"
#include "dialogue.h"
#include "difficulty.h"
#include "economy.h"
#include "env.h"
#include "event.h"
#include "faction.h"
#include "font.h"
#include "gui.h"
#include "hook.h"
#include "input.h"
#include "joystick.h"
#include "land.h"
#include "load.h"
#include "log.h"
#include "map.h"
#include "map_overlay.h"
#include "map_system.h"
#include "menu.h"
#include "mission.h"
#include "music.h"
#include "ndata.h"
#include "nebula.h"
#include "news.h"
#include "nfile.h"
#include "nlua_colour.h"
#include "nlua_data.h"
#include "nlua_file.h"
#include "nlua_gfx.h"
#include "nlua_naev.h"
#include "nlua_rnd.h"
#include "nlua_tex.h"
#include "nlua_var.h"
#include "nlua_vec2.h"
#include "npc.h"
#include "ntracing.h"
#include "opengl.h"
#include "options.h"
#include "outfit.h"
#include "pause.h"
#include "pilot.h"
#include "player.h"
#include "player_autonav.h"
#include "plugin.h"
#include "render.h"
#include "rng.h"
#include "safelanes.h"
#include "semver.h"
#include "ship.h"
#include "slots.h"
#include "sound.h"
#include "space.h"
#include "spfx.h"
#include "start.h"
#include "tech.h"
#include "threadpool.h"
#include "toolkit.h"
#include "unidiff.h"
#include "weapon.h"
Include dependency graph for naev.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define VERSION_FILE   "VERSION"
#define LOADING_STAGES   17.
 Loads all the data, makes main() simpler.

Functions

static void print_SDLversion (void)
 Prints the SDL version to console.
static void loadscreen_load (void)
 Loads a loading screen.
static void loadscreen_unload (void)
 Frees the loading screen.
static void load_all (void)
static void unload_all (void)
 Unloads all data, simplifies main().
static void window_caption (void)
 Sets the window caption.
static void fps_init (void)
 Initializes the fps engine.
static void update_all (int dohooks)
 Updates the game itself (player flying around and friends).
static void loadscreen_update (double done, const char *msg)
 Renders the load screen with message.
void main_loop (int nested)
 Split main loop from main() for secondary loop hack in toolkit.c.
void naev_quit (void)
 Flags naev to quit.
int naev_isQuit (void)
 Get if Naev is trying to quit.
int naev_shouldRenderLoadscreen (void)
 Whether or not we want to render the loadscreen.
void naev_doRenderLoadscreen (void)
void naev_renderLoadscreen (void)
 Renders the loadscreen if necessary.
void naev_resize (void)
 Wrapper for gl_resize that handles non-GL reinitialization.
void naev_toggleFullscreen (void)
void fps_setPos (double x, double y)
 Sets the position to display the FPS.
void fps_display (double dt)
 Displays FPS on the screen.
double fps_current (void)
 Gets the current FPS.
void update_routine (double dt, int dohooks)
 Actually runs the updates.
static int binary_comparison (int x, int y)
int naev_versionCompare (const char *version)
 Compares the version against the current naev version.
int naev_versionCompareTarget (const char *version, const char *target)
 Does a comparison with a specific target.
double naev_getrealdt (void)
 Gets the last delta-tick.

Variables

static int quit = 0
Uint32 SDL_LOOPDONE = 0
static Uint64 last_t = 0
static SDL_Surface * naev_icon = NULL
static int fps_skipped = 0
static semver_t version_binary
static double fps_dt = 1.
static double game_dt = 0.
static double real_dt = 0.
static double fps = 0.
static double fps_cur = 0.
static double fps_x = 15.
static double fps_y = -15.
const double fps_min = 1. / 10.
double elapsed_time_mod = 0.
static nlua_env load_env
static int load_force_render = 0
static unsigned int load_last_render = 0
static SDL_mutex * load_mutex

Detailed Description

Controls the overall game flow: data loading/unloading and game loop.

Definition in file naev.c.

Macro Definition Documentation

◆ LOADING_STAGES

#define LOADING_STAGES   17.

Loads all the data, makes main() simpler.

Amount of loading stages.

Definition at line 680 of file naev.c.

◆ VERSION_FILE

#define VERSION_FILE   "VERSION"

Version file by default.

Definition at line 96 of file naev.c.

Function Documentation

◆ binary_comparison()

int binary_comparison ( int x,
int y )
static

Definition at line 1138 of file naev.c.

◆ fps_current()

double fps_current ( void )

Gets the current FPS.

Returns
Current FPS as displayed to the player.

Definition at line 995 of file naev.c.

◆ fps_display()

void fps_display ( double dt)

Displays FPS on the screen.

Parameters
[in]dtCurrent delta tick.

Definition at line 955 of file naev.c.

◆ fps_init()

void fps_init ( void )
static

Initializes the fps engine.

Definition at line 936 of file naev.c.

◆ fps_setPos()

void fps_setPos ( double x,
double y )

Sets the position to display the FPS.

Definition at line 944 of file naev.c.

◆ load_all()

void load_all ( void )
static

Definition at line 681 of file naev.c.

◆ loadscreen_load()

void loadscreen_load ( void )
static

Loads a loading screen.

Definition at line 560 of file naev.c.

◆ loadscreen_unload()

void loadscreen_unload ( void )
static

Frees the loading screen.

Definition at line 671 of file naev.c.

◆ loadscreen_update()

void loadscreen_update ( double done,
const char * msg )
static

Renders the load screen with message.

Parameters
doneAmount done (1. == completed).
msgLoading screen message.

Definition at line 652 of file naev.c.

◆ main_loop()

void main_loop ( int nested)

Split main loop from main() for secondary loop hack in toolkit.c.

Definition at line 795 of file naev.c.

◆ naev_doRenderLoadscreen()

void naev_doRenderLoadscreen ( void )

Definition at line 610 of file naev.c.

◆ naev_getrealdt()

double naev_getrealdt ( void )

Gets the last delta-tick.

Definition at line 1230 of file naev.c.

◆ naev_isQuit()

int naev_isQuit ( void )

Get if Naev is trying to quit.

Definition at line 153 of file naev.c.

◆ naev_quit()

void naev_quit ( void )

Flags naev to quit.

Definition at line 145 of file naev.c.

◆ naev_renderLoadscreen()

void naev_renderLoadscreen ( void )

Renders the loadscreen if necessary.

Definition at line 640 of file naev.c.

◆ naev_resize()

void naev_resize ( void )

Wrapper for gl_resize that handles non-GL reinitialization.

Definition at line 874 of file naev.c.

◆ naev_shouldRenderLoadscreen()

int naev_shouldRenderLoadscreen ( void )

Whether or not we want to render the loadscreen.

Definition at line 596 of file naev.c.

◆ naev_toggleFullscreen()

void naev_toggleFullscreen ( void )

Definition at line 928 of file naev.c.

◆ naev_versionCompare()

int naev_versionCompare ( const char * version)

Compares the version against the current naev version.

Returns
positive if version is newer or negative if version is older.

Definition at line 1151 of file naev.c.

◆ naev_versionCompareTarget()

int naev_versionCompareTarget ( const char * version,
const char * target )

Does a comparison with a specific target.

Definition at line 1175 of file naev.c.

◆ print_SDLversion()

void print_SDLversion ( void )
static

Prints the SDL version to console.

Definition at line 1198 of file naev.c.

◆ unload_all()

void unload_all ( void )
static

Unloads all data, simplifies main().

Definition at line 762 of file naev.c.

◆ update_all()

void update_all ( int dohooks)
static

Updates the game itself (player flying around and friends).

Mainly uses game dt.

Definition at line 1005 of file naev.c.

◆ update_routine()

void update_routine ( double dt,
int dohooks )

Actually runs the updates.

Parameters
[in]dtCurrent delta tick.
[in]dohooksWhether or not we want to do hooks, such as the initial update upon entering a system.

Definition at line 1056 of file naev.c.

◆ window_caption()

void window_caption ( void )
static

Sets the window caption.

Definition at line 1114 of file naev.c.

Variable Documentation

◆ elapsed_time_mod

double elapsed_time_mod = 0.

Elapsed modified time.

Definition at line 117 of file naev.c.

◆ fps

double fps = 0.
static

FPS to finally display.

Definition at line 112 of file naev.c.

◆ fps_cur

double fps_cur = 0.
static

FPS accumulator to trigger change.

Definition at line 113 of file naev.c.

◆ fps_dt

double fps_dt = 1.
static

Display fps accumulator.

Definition at line 109 of file naev.c.

◆ fps_min

const double fps_min = 1. / 10.

New collisions allow larger fps_min.

Definition at line 116 of file naev.c.

◆ fps_skipped

int fps_skipped = 0
static

Skipped last frame?

Definition at line 102 of file naev.c.

◆ fps_x

double fps_x = 15.
static

FPS X position.

Definition at line 114 of file naev.c.

◆ fps_y

double fps_y = -15.
static

FPS Y position.

Definition at line 115 of file naev.c.

◆ game_dt

double game_dt = 0.
static

Current game deltatick (uses dt_mod).

Definition at line 110 of file naev.c.

◆ last_t

Uint64 last_t = 0
static

used to calculate FPS and movement.

Definition at line 100 of file naev.c.

◆ load_env

nlua_env load_env
static
Initial value:
=
LUA_NOREF

Environment for displaying load messages and stuff.

Definition at line 119 of file naev.c.

◆ load_force_render

int load_force_render = 0
static

Definition at line 121 of file naev.c.

◆ load_last_render

unsigned int load_last_render = 0
static

Definition at line 122 of file naev.c.

◆ load_mutex

SDL_mutex* load_mutex
static

Definition at line 123 of file naev.c.

◆ naev_icon

SDL_Surface* naev_icon = NULL
static

Icon.

Definition at line 101 of file naev.c.

◆ quit

int quit = 0
static

For primary loop

Definition at line 98 of file naev.c.

◆ real_dt

double real_dt = 0.
static

Real deltatick.

Definition at line 111 of file naev.c.

◆ SDL_LOOPDONE

Uint32 SDL_LOOPDONE = 0

For custom event to exit loops.

Definition at line 99 of file naev.c.

◆ version_binary

semver_t version_binary
static

Naev binary version.

Definition at line 104 of file naev.c.