naev 0.11.5
land.c File Reference

Handles all the landing menus and actions. More...

#include "land.h"
#include "array.h"
#include "camera.h"
#include "conf.h"
#include "dialogue.h"
#include "economy.h"
#include "equipment.h"
#include "escort.h"
#include "event.h"
#include "gui.h"
#include "gui_omsg.h"
#include "hook.h"
#include "land_outfits.h"
#include "land_shipyard.h"
#include "land_trade.h"
#include "log.h"
#include "map.h"
#include "menu.h"
#include "mission.h"
#include "music.h"
#include "ndata.h"
#include "news.h"
#include "nlua.h"
#include "nlua_tk.h"
#include "nluadef.h"
#include "npc.h"
#include "nstring.h"
#include "ntime.h"
#include "player.h"
#include "player_fleet.h"
#include "rng.h"
#include "render.h"
#include "save.h"
#include "shiplog.h"
#include "toolkit.h"

Go to the source code of this file.

Macros

#define VISITED_LAND   (1<<0)
 
#define VISITED_COMMODITY   (1<<1)
 
#define VISITED_BAR   (1<<2)
 
#define VISITED_OUTFITS   (1<<3)
 
#define VISITED_SHIPYARD   (1<<4)
 
#define VISITED_EQUIPMENT   (1<<5)
 
#define VISITED_MISSION   (1<<6)
 
#define visited(f)
 
#define has_visited(f)
 
#define should_open(s, w)
 

Functions

static void land_stranded (void)
 Runs the rescue script if players are stuck.
 
static int land_gc (void *unused)
 Runs Lua garbage collection.
 
static int land_hasLocalMap (void)
 
static void land_createMainTab (unsigned int wid)
 Creates the main tab.
 
static void land_setupTabs (void)
 Sets up the tabs for the window.
 
static void land_cleanupWindow (unsigned int wid, const char *name)
 Cleans up the land window.
 
static void land_changeTab (unsigned int wid, const char *wgt, int old, int tab)
 Saves the last place the player was.
 
static void bar_getDim (int wid, int *w, int *h, int *iw, int *ih, int *bw, int *bh)
 Gets the dimensions of the spaceport bar window.
 
static void bar_open (unsigned int wid)
 Opens the spaceport bar window.
 
static int bar_genList (unsigned int wid)
 Generates the mission list for the bar.
 
static void bar_update (unsigned int wid, const char *str)
 Updates the missions in the spaceport bar.
 
static void bar_close (unsigned int wid, const char *name)
 Closes the mission computer window.
 
static void bar_approach (unsigned int wid, const char *str)
 Approaches guy in mission computer.
 
static int news_load (void)
 Loads the news.
 
static void misn_open (unsigned int wid)
 Opens the mission computer window.
 
static void misn_autonav (unsigned int wid, const char *str)
 Autonav to selected mission.
 
static void misn_accept (unsigned int wid, const char *str)
 Accepts the selected mission.
 
static void misn_genList (unsigned int wid, int first)
 Generates the mission list.
 
static void misn_update (unsigned int wid, const char *str)
 Updates the mission list.
 
void land_queueTakeoff (void)
 Queue a takeoff.
 
void land_needsTakeoff (int delay)
 
int land_canSave (void)
 Whether or not the player can save.
 
int land_doneLoading (void)
 Check to see if finished loading.
 
void land_errClear (void)
 Clear error dialogues.
 
void land_errDialogueBuild (const char *fmt,...)
 Generates error dialogues used by several landing tabs.
 
int land_errDisplay (void)
 Displays an error if applicable.
 
void bar_regen (void)
 Regenerates the bar list.
 
void land_refuel (void)
 Refuels the player's current ship, if possible.
 
static void spaceport_buyMap (unsigned int wid, const char *str)
 Buys a local system map.
 
void land_updateMainTab (void)
 Adds the "Buy Local Map" button if needed and updates info.
 
void land_buttonTakeoff (unsigned int wid, const char *unused)
 Wrapper for takeoff mission button.
 
unsigned int land_getWid (int window)
 Gets the WID of a window by type.
 
void land_genWindows (int load)
 Recreates the land windows.
 
int land_setWindow (int window)
 Sets the land window tab.
 
void land (Spob *p, int load)
 Opens up all the land dialogue stuff.
 
void takeoff (int delay, int nosave)
 Makes the player take off if landed.
 
void land_cleanup (void)
 Cleans up some land-related variables.
 
void land_exit (void)
 Exits all the landing stuff.
 

Variables

static unsigned int land_visited = 0
 
unsigned int land_generated = 0
 
int landed = 0
 
int land_loaded = 0
 
static int land_takeoff = 0
 
static int land_takeoff_nosave = 0
 
unsigned int land_wid = 0
 
static int land_regen = 0
 
static int land_windowsMap [LAND_NUMWINDOWS]
 
static unsigned int * land_windows = NULL
 
Spobland_spob = NULL
 
static glTexturegfx_exterior = NULL
 
static Missionmission_computer = NULL
 
static int mission_ncomputer = 0
 
static glTexturemission_portrait = NULL
 
static int last_window = 0
 
static char errorlist [STRMAX_SHORT]
 
static char errorreason [STRMAX_SHORT]
 
static int errorappend
 
static char * errorlist_ptr
 
static nlua_env rescue_env = LUA_NOREF
 

Detailed Description

Handles all the landing menus and actions.

Definition in file land.c.

Macro Definition Documentation

◆ has_visited

#define has_visited ( f)
Value:
(land_visited & (f))
static unsigned int land_visited
Definition land.c:67

Check if player has visited.

Definition at line 66 of file land.c.

◆ should_open

#define should_open ( s,
w )
Value:
(spob_hasService(land_spob, s) && (!land_tabGenerated(w)))
Spob * land_spob
Definition land.c:83

◆ visited

#define visited ( f)
Value:
(land_visited |= (f))

Mark place is visited.

Definition at line 65 of file land.c.

◆ VISITED_BAR

#define VISITED_BAR   (1<<2)

Player already visited bar.

Definition at line 60 of file land.c.

◆ VISITED_COMMODITY

#define VISITED_COMMODITY   (1<<1)

Player already visited commodities.

Definition at line 59 of file land.c.

◆ VISITED_EQUIPMENT

#define VISITED_EQUIPMENT   (1<<5)

Player already visited equipment.

Definition at line 63 of file land.c.

◆ VISITED_LAND

#define VISITED_LAND   (1<<0)

Player already landed.

Definition at line 58 of file land.c.

◆ VISITED_MISSION

#define VISITED_MISSION   (1<<6)

Player already visited mission computer.

Definition at line 64 of file land.c.

◆ VISITED_OUTFITS

#define VISITED_OUTFITS   (1<<3)

Player already visited outfits.

Definition at line 61 of file land.c.

◆ VISITED_SHIPYARD

#define VISITED_SHIPYARD   (1<<4)

Player already visited shipyard.

Definition at line 62 of file land.c.

Function Documentation

◆ bar_approach()

static void bar_approach ( unsigned int wid,
const char * str )
static

Approaches guy in mission computer.

Definition at line 485 of file land.c.

◆ bar_close()

static void bar_close ( unsigned int wid,
const char * name )
static

Closes the mission computer window.

Parameters
widWindow to close.
nameUnused.

Definition at line 468 of file land.c.

◆ bar_genList()

static int bar_genList ( unsigned int wid)
static

Generates the mission list for the bar.

Parameters
widWindow to create mission list for.

Definition at line 309 of file land.c.

◆ bar_getDim()

static void bar_getDim ( int wid,
int * w,
int * h,
int * iw,
int * ih,
int * bw,
int * bh )
static

Gets the dimensions of the spaceport bar window.

Definition at line 240 of file land.c.

◆ bar_open()

static void bar_open ( unsigned int wid)
static

Opens the spaceport bar window.

Definition at line 257 of file land.c.

◆ bar_regen()

void bar_regen ( void )

Regenerates the bar list.

Definition at line 382 of file land.c.

◆ bar_update()

static void bar_update ( unsigned int wid,
const char * str )
static

Updates the missions in the spaceport bar.

Parameters
widWindow to update the outfits in.
strUnused.

Definition at line 395 of file land.c.

◆ land()

void land ( Spob * p,
int load )

Opens up all the land dialogue stuff.

Parameters
pSpob to open stuff for.
loadWhether or not loading the game.

Definition at line 1124 of file land.c.

◆ land_buttonTakeoff()

void land_buttonTakeoff ( unsigned int wid,
const char * unused )

Wrapper for takeoff mission button.

Parameters
widWindow causing takeoff.
unusedUnused.

Definition at line 851 of file land.c.

◆ land_canSave()

int land_canSave ( void )

Whether or not the player can save.

Definition at line 166 of file land.c.

◆ land_changeTab()

static void land_changeTab ( unsigned int wid,
const char * wgt,
int old,
int tab )
static

Saves the last place the player was.

Parameters
widUnused.
wgtUnused.
oldPreviously-active tab. (Unused)
tabTab changed to.

Definition at line 1290 of file land.c.

◆ land_cleanup()

void land_cleanup ( void )

Cleans up some land-related variables.

Definition at line 1596 of file land.c.

◆ land_cleanupWindow()

static void land_cleanupWindow ( unsigned int wid,
const char * name )
static

Cleans up the land window.

Parameters
widWindow closing.
nameUnused.

Definition at line 865 of file land.c.

◆ land_createMainTab()

static void land_createMainTab ( unsigned int wid)
static

Creates the main tab.

Parameters
widWindow to create main tab.

Definition at line 1204 of file land.c.

◆ land_doneLoading()

int land_doneLoading ( void )

Check to see if finished loading.

Definition at line 189 of file land.c.

◆ land_errClear()

void land_errClear ( void )

Clear error dialogues.

Definition at line 199 of file land.c.

◆ land_errDialogueBuild()

void land_errDialogueBuild ( const char * fmt,
... )

Generates error dialogues used by several landing tabs.

Parameters
fmtString with printf-like formatting

Definition at line 208 of file land.c.

◆ land_errDisplay()

int land_errDisplay ( void )

Displays an error if applicable.

Definition at line 228 of file land.c.

◆ land_exit()

void land_exit ( void )

Exits all the landing stuff.

Definition at line 1642 of file land.c.

◆ land_gc()

static int land_gc ( void * unused)
static

Runs Lua garbage collection.

Definition at line 1192 of file land.c.

◆ land_genWindows()

void land_genWindows ( int load)

Recreates the land windows.

Parameters
loadIs loading game?

Definition at line 957 of file land.c.

◆ land_getWid()

unsigned int land_getWid ( int window)

Gets the WID of a window by type.

Parameters
windowType of window to get wid (LAND_WINDOW_MAIN, ...).
Returns
0 on error, otherwise the wid of the window.

Definition at line 889 of file land.c.

◆ land_hasLocalMap()

static int land_hasLocalMap ( void )
static

Definition at line 156 of file land.c.

◆ land_needsTakeoff()

void land_needsTakeoff ( int delay)

Definition at line 149 of file land.c.

◆ land_queueTakeoff()

void land_queueTakeoff ( void )

Queue a takeoff.

Definition at line 143 of file land.c.

◆ land_refuel()

void land_refuel ( void )

Refuels the player's current ship, if possible.

Definition at line 733 of file land.c.

◆ land_setupTabs()

static void land_setupTabs ( void )
static

Sets up the tabs for the window.

Definition at line 899 of file land.c.

◆ land_setWindow()

int land_setWindow ( int window)

Sets the land window tab.

Parameters
windowTab to set like LAND_WINDOW_COMMODITY.
Returns
0 on success.

Definition at line 1110 of file land.c.

◆ land_stranded()

static void land_stranded ( void )
static

Runs the rescue script if players are stuck.

Definition at line 1555 of file land.c.

◆ land_updateMainTab()

void land_updateMainTab ( void )

Adds the "Buy Local Map" button if needed and updates info.

Definition at line 791 of file land.c.

◆ misn_accept()

static void misn_accept ( unsigned int wid,
const char * str )
static

Accepts the selected mission.

Parameters
widWindow of the mission computer.
strUnused.

Definition at line 607 of file land.c.

◆ misn_autonav()

static void misn_autonav ( unsigned int wid,
const char * str )
static

Autonav to selected mission.

Parameters
widWindow of the mission computer.
strUnused.

Definition at line 583 of file land.c.

◆ misn_genList()

static void misn_genList ( unsigned int wid,
int first )
static

Generates the mission list.

Parameters
widWindow to generate the mission list for.
firstIs it the first time generated?

Definition at line 650 of file land.c.

◆ misn_open()

static void misn_open ( unsigned int wid)
static

Opens the mission computer window.

Definition at line 532 of file land.c.

◆ misn_update()

static void misn_update ( unsigned int wid,
const char * str )
static

Updates the mission list.

Parameters
widWindow of the mission computer.
strUnused.

Definition at line 690 of file land.c.

◆ news_load()

static int news_load ( void )
static

Loads the news.

Returns
0 on success.

Definition at line 522 of file land.c.

◆ spaceport_buyMap()

static void spaceport_buyMap ( unsigned int wid,
const char * str )
static

Buys a local system map.

Definition at line 755 of file land.c.

◆ takeoff()

void takeoff ( int delay,
int nosave )

Makes the player take off if landed.

Parameters
delayWhether or not to have time pass as if the player landed normally.
nosaveWhether or not to avoid saving the game.

Definition at line 1380 of file land.c.

Variable Documentation

◆ errorappend

int errorappend
static

Definition at line 107 of file land.c.

◆ errorlist

char errorlist[STRMAX_SHORT]
static

Definition at line 105 of file land.c.

◆ errorlist_ptr

char* errorlist_ptr
static

Definition at line 108 of file land.c.

◆ errorreason

char errorreason[STRMAX_SHORT]
static

Definition at line 106 of file land.c.

◆ gfx_exterior

glTexture* gfx_exterior = NULL
static

Exterior graphic of the landed spob.

Definition at line 84 of file land.c.

◆ land_generated

unsigned int land_generated = 0

Definition at line 70 of file land.c.

◆ land_loaded

int land_loaded = 0

Finished loading?

Definition at line 76 of file land.c.

◆ land_regen

int land_regen = 0
static

Whether or not regenning.

Definition at line 80 of file land.c.

◆ land_spob

Spob* land_spob = NULL

Spob player landed at.

Definition at line 83 of file land.c.

◆ land_takeoff

int land_takeoff = 0
static

Takeoff.

Definition at line 77 of file land.c.

◆ land_takeoff_nosave

int land_takeoff_nosave = 0
static

Whether or not to disable saving when taking off.

Definition at line 78 of file land.c.

◆ land_visited

unsigned int land_visited = 0
static

Contains what the player visited.

Definition at line 67 of file land.c.

◆ land_wid

unsigned int land_wid = 0

Land window ID, also used in gui.c

Definition at line 79 of file land.c.

◆ land_windows

unsigned int* land_windows = NULL
static

Landed window ids.

Definition at line 82 of file land.c.

◆ land_windowsMap

int land_windowsMap[LAND_NUMWINDOWS]
static

Mapping of windows.

Definition at line 81 of file land.c.

◆ landed

int landed = 0

Is player landed.

Definition at line 75 of file land.c.

◆ last_window

int last_window = 0
static

Default window.

Definition at line 100 of file land.c.

◆ mission_computer

Mission* mission_computer = NULL
static

Missions at the computer.

Definition at line 89 of file land.c.

◆ mission_ncomputer

int mission_ncomputer = 0
static

Number of missions at the computer.

Definition at line 90 of file land.c.

◆ mission_portrait

glTexture* mission_portrait = NULL
static

Mission portrait.

Definition at line 95 of file land.c.

◆ rescue_env

nlua_env rescue_env = LUA_NOREF
static

Rescue Lua env.

Definition at line 113 of file land.c.