naev 0.12.6
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 "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 "npc.h"
#include "nstring.h"
#include "ntime.h"
#include "ntracing.h"
#include "player.h"
#include "player_autonav.h"
#include "player_fleet.h"
#include "rng.h"
#include "save.h"
#include "sound.h"
#include "toolkit.h"
Include dependency graph for land.c:

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_popdown (unsigned int wid, const char *str)
 Opens the small pop-down menu.
static void misn_popdownActivate (unsigned int wid, const char *str)
static void misn_popdownSelect (unsigned int wid, const char *str)
static void misn_computerOptions (unsigned int wid, const char *str)
 Do the popdown options.
static void misn_computerOptionsRegen (unsigned int wid, const char *str)
static void misn_computerOptionsClose (unsigned int wid, const char *name)
 Closes the mission computer window.
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)
 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 misn_patchMission (const Mission *misn)
 Patches a mission into the mission computer.
void misn_regen (void)
 Regenerates the mission list.
void bar_regen (void)
 Regenerates the bar list.
static int * misn_filter (const Mission *misn)
 Hides missions we don't want to look at.
static int misn_cmp (const void *p1, const void *p2)
 Used to sort available mission computer missions.
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
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
static Missionmission_computer = NULL
static int * mission_computer_filter
MissionComputerOptions misn_opts
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:70

Check if player has visited.

Definition at line 68 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:87

◆ visited

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

Mark place is visited.

Definition at line 67 of file land.c.

◆ VISITED_BAR

#define VISITED_BAR   ( 1 << 2 )

Player already visited bar.

Definition at line 61 of file land.c.

◆ VISITED_COMMODITY

#define VISITED_COMMODITY    ( 1 << 1 )

Player already visited commodities. \

Definition at line 58 of file land.c.

◆ VISITED_EQUIPMENT

#define VISITED_EQUIPMENT   ( 1 << 5 )

Player already visited equipment.

Definition at line 64 of file land.c.

◆ VISITED_LAND

#define VISITED_LAND   ( 1 << 0 )

Player already landed.

Definition at line 57 of file land.c.

◆ VISITED_MISSION

#define VISITED_MISSION    ( 1 << 6 )

Player already visited mission computer.

Definition at line 65 of file land.c.

◆ VISITED_OUTFITS

#define VISITED_OUTFITS   ( 1 << 3 )

Player already visited outfits.

Definition at line 62 of file land.c.

◆ VISITED_SHIPYARD

#define VISITED_SHIPYARD   ( 1 << 4 )

Player already visited shipyard.

Definition at line 63 of file land.c.

Function Documentation

◆ bar_approach()

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

Approaches guy in mission computer.

Definition at line 540 of file land.c.

◆ bar_close()

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

Closes the mission computer window.

Parameters
widWindow to close.
nameUnused.

Definition at line 523 of file land.c.

◆ bar_genList()

int bar_genList ( unsigned int wid)
static

Generates the mission list for the bar.

Parameters
widWindow to create mission list for.

Definition at line 327 of file land.c.

◆ bar_getDim()

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 260 of file land.c.

◆ bar_open()

void bar_open ( unsigned int wid)
static

Opens the spaceport bar window.

Definition at line 277 of file land.c.

◆ bar_regen()

void bar_regen ( void )

Regenerates the bar list.

Definition at line 432 of file land.c.

◆ bar_update()

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 449 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 1413 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 1124 of file land.c.

◆ land_canSave()

int land_canSave ( void )

Whether or not the player can save.

Definition at line 182 of file land.c.

◆ land_changeTab()

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 1598 of file land.c.

◆ land_cleanup()

void land_cleanup ( void )

Cleans up some land-related variables.

Definition at line 1952 of file land.c.

◆ land_cleanupWindow()

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

Cleans up the land window.

Parameters
widWindow closing.
nameUnused.

Definition at line 1138 of file land.c.

◆ land_createMainTab()

void land_createMainTab ( unsigned int wid)
static

Creates the main tab.

Parameters
widWindow to create main tab.

Definition at line 1507 of file land.c.

◆ land_doneLoading()

int land_doneLoading ( void )

Check to see if finished loading.

Definition at line 207 of file land.c.

◆ land_errClear()

void land_errClear ( void )

Clear error dialogues.

Definition at line 217 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 226 of file land.c.

◆ land_errDisplay()

int land_errDisplay ( void )

Displays an error if applicable.

Definition at line 248 of file land.c.

◆ land_exit()

void land_exit ( void )

Exits all the landing stuff.

Definition at line 1999 of file land.c.

◆ land_gc()

int land_gc ( void * unused)
static

Runs Lua garbage collection.

Definition at line 1495 of file land.c.

◆ land_genWindows()

void land_genWindows ( int load)

Recreates the land windows.

Parameters
loadIs loading game?

Definition at line 1232 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 1162 of file land.c.

◆ land_hasLocalMap()

int land_hasLocalMap ( void )
static

Definition at line 172 of file land.c.

◆ land_needsTakeoff()

void land_needsTakeoff ( int delay)

Definition at line 165 of file land.c.

◆ land_queueTakeoff()

void land_queueTakeoff ( void )

Queue a takeoff.

Definition at line 159 of file land.c.

◆ land_refuel()

void land_refuel ( void )

Refuels the player's current ship, if possible.

Definition at line 995 of file land.c.

◆ land_setupTabs()

void land_setupTabs ( void )
static

Sets up the tabs for the window.

Definition at line 1172 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 1399 of file land.c.

◆ land_stranded()

void land_stranded ( void )
static

Runs the rescue script if players are stuck.

Definition at line 1911 of file land.c.

◆ land_updateMainTab()

void land_updateMainTab ( void )

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

Definition at line 1054 of file land.c.

◆ misn_accept()

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

Accepts the selected mission.

Parameters
widWindow of the mission computer.
strUnused.

Definition at line 661 of file land.c.

◆ misn_autonav()

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

Autonav to selected mission.

Parameters
widWindow of the mission computer.
strUnused.

Definition at line 635 of file land.c.

◆ misn_cmp()

int misn_cmp ( const void * p1,
const void * p2 )
static

Used to sort available mission computer missions.

Definition at line 715 of file land.c.

◆ misn_computerOptions()

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

Do the popdown options.

Definition at line 832 of file land.c.

◆ misn_computerOptionsClose()

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

Closes the mission computer window.

Parameters
widWindow to close.
nameUnused.

Definition at line 823 of file land.c.

◆ misn_computerOptionsRegen()

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

Definition at line 806 of file land.c.

◆ misn_filter()

int * misn_filter ( const Mission * misn)
static

Hides missions we don't want to look at.

Definition at line 701 of file land.c.

◆ misn_genList()

void misn_genList ( unsigned int wid)
static

Generates the mission list.

Parameters
widWindow to generate the mission list for.

Definition at line 880 of file land.c.

◆ misn_open()

void misn_open ( unsigned int wid)
static

Opens the mission computer window.

Definition at line 587 of file land.c.

◆ misn_patchMission()

void misn_patchMission ( const Mission * misn)

Patches a mission into the mission computer.

Definition at line 411 of file land.c.

◆ misn_popdown()

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

Opens the small pop-down menu.

Definition at line 755 of file land.c.

◆ misn_popdownActivate()

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

Definition at line 800 of file land.c.

◆ misn_popdownSelect()

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

Definition at line 784 of file land.c.

◆ misn_regen()

void misn_regen ( void )

Regenerates the mission list.

Definition at line 419 of file land.c.

◆ misn_update()

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

Updates the mission list.

Parameters
widWindow of the mission computer.
strUnused.

Definition at line 949 of file land.c.

◆ news_load()

int news_load ( void )
static

Loads the news.

Returns
0 on success.

Definition at line 578 of file land.c.

◆ spaceport_buyMap()

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

Buys a local system map.

Definition at line 1018 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 1690 of file land.c.

Variable Documentation

◆ errorappend

int errorappend
static

Definition at line 114 of file land.c.

◆ errorlist

char errorlist[STRMAX_SHORT]
static

Definition at line 112 of file land.c.

◆ errorlist_ptr

char* errorlist_ptr
static

Definition at line 115 of file land.c.

◆ errorreason

char errorreason[STRMAX_SHORT]
static

Definition at line 113 of file land.c.

◆ gfx_exterior

glTexture* gfx_exterior
static
Initial value:
=
NULL

Exterior graphic of the landed spob.

Definition at line 88 of file land.c.

◆ land_generated

unsigned int land_generated = 0

Definition at line 73 of file land.c.

◆ land_loaded

int land_loaded = 0

Finished loading?

Definition at line 79 of file land.c.

◆ land_regen

int land_regen = 0
static

Whether or not regenning.

Definition at line 84 of file land.c.

◆ land_spob

Spob* land_spob = NULL

Spob player landed at.

Definition at line 87 of file land.c.

◆ land_takeoff

int land_takeoff = 0
static

Takeoff.

Definition at line 80 of file land.c.

◆ land_takeoff_nosave

int land_takeoff_nosave
static
Initial value:
=
0

Whether or not to disable saving when taking off.

Definition at line 81 of file land.c.

◆ land_visited

unsigned int land_visited = 0
static

Contains what the player visited.

Definition at line 70 of file land.c.

◆ land_wid

unsigned int land_wid = 0

Land window ID, also used in gui.c

Definition at line 83 of file land.c.

◆ land_windows

unsigned int* land_windows = NULL
static

Landed window ids.

Definition at line 86 of file land.c.

◆ land_windowsMap

int land_windowsMap[LAND_NUMWINDOWS]
static

Mapping of windows.

Definition at line 85 of file land.c.

◆ landed

int landed = 0

Is player landed.

Definition at line 78 of file land.c.

◆ last_window

int last_window = 0
static

Default window.

Definition at line 107 of file land.c.

◆ misn_opts

Definition at line 97 of file land.c.

◆ mission_computer

Mission* mission_computer = NULL
static

Missions at the computer.

Definition at line 94 of file land.c.

◆ mission_computer_filter

int* mission_computer_filter
static
Initial value:
=
NULL

IDs of the filtered missions.

Definition at line 95 of file land.c.

◆ mission_portrait

glTexture* mission_portrait = NULL
static

Mission portrait.

Definition at line 102 of file land.c.

◆ rescue_env

nlua_env rescue_env = LUA_NOREF
static

Rescue Lua env.

Definition at line 120 of file land.c.