naev 0.10.4
Macros | Functions | Variables
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 "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)   (land_visited |= (f))
 
#define has_visited(f)   (land_visited & (f))
 
#define should_open(s, w)    (spob_hasService(land_spob, s) && (!land_tabGenerated(w)))
 

Functions

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

Variables

static unsigned int land_visited = 0
 
unsigned int land_generated = 0
 
int landed = 0
 
int land_loaded = 0
 
int land_takeoff = 0
 
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 int land_taboverride = 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)    (land_visited & (f))

Check if player has visited.

Definition at line 65 of file land.c.

◆ visited

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

Mark place is visited.

Definition at line 64 of file land.c.

◆ VISITED_BAR

#define VISITED_BAR   (1<<2)

Player already visited bar.

Definition at line 59 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 62 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 63 of file land.c.

◆ VISITED_OUTFITS

#define VISITED_OUTFITS   (1<<3)

Player already visited outfits.

Definition at line 60 of file land.c.

◆ VISITED_SHIPYARD

#define VISITED_SHIPYARD   (1<<4)

Player already visited shipyard.

Definition at line 61 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 555 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 538 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 379 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 310 of file land.c.

◆ bar_open()

static void bar_open ( unsigned int  wid)
static

Opens the spaceport bar window.

Definition at line 327 of file land.c.

◆ bar_regen()

void bar_regen ( void  )

Regenerates the bar list.

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

◆ can_swapEquipment()

int can_swapEquipment ( const char *  shipname)

Makes sure it's valid to change ships in the equipment view.

Parameters
shipnameShip being changed to.

Definition at line 200 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 1201 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 925 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 1372 of file land.c.

◆ land_cleanup()

void land_cleanup ( void  )

Cleans up some land-related variables.

Definition at line 1672 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 939 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 1285 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_errDialogue()

int land_errDialogue ( const char *  name,
const char *  type 
)

Generates error dialogues used by several landing tabs.

Todo:
don't use strings here and use some switch case with an enum.
Parameters
nameName of the ship, outfit or commodity being acted upon.
typeType of action.

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

◆ land_exit()

void land_exit ( void  )

Exits all the landing stuff.

Definition at line 1718 of file land.c.

◆ land_gc()

static int land_gc ( void *  unused)
static

Runs Lua garbage collection.

Definition at line 1273 of file land.c.

◆ land_genWindows()

void land_genWindows ( int  load,
int  changetab 
)

Recreates the land windows.

Parameters
loadIs loading game?
changetabShould it change to the last open tab?

Definition at line 1032 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 963 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 807 of file land.c.

◆ land_setupTabs()

static void land_setupTabs ( void  )
static

Sets up the tabs for the window.

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

◆ land_stranded()

static void land_stranded ( void  )
static

Runs the rescue script if players are stuck.

Definition at line 1631 of file land.c.

◆ land_updateMainTab()

void land_updateMainTab ( void  )

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

Definition at line 864 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 677 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 653 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 724 of file land.c.

◆ misn_open()

static void misn_open ( unsigned int  wid)
static

Opens the mission computer window.

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

◆ news_load()

static int news_load ( void  )
static

Loads the news.

Returns
0 on success.

Definition at line 592 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 829 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 1461 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 83 of file land.c.

◆ land_generated

unsigned int land_generated = 0

Definition at line 69 of file land.c.

◆ land_loaded

int land_loaded = 0

Finished loading?

Definition at line 75 of file land.c.

◆ land_regen

int land_regen = 0
static

Whether or not regenning.

Definition at line 79 of file land.c.

◆ land_spob

Spob* land_spob = NULL

Spob player landed at.

Definition at line 82 of file land.c.

◆ land_taboverride

int land_taboverride = 0
static

Whether or not tab got overwritten.

Definition at line 100 of file land.c.

◆ land_takeoff

int land_takeoff = 0

Takeoff.

Definition at line 76 of file land.c.

◆ land_takeoff_nosave

int land_takeoff_nosave = 0

Whether or not to disable saving when taking off.

Definition at line 77 of file land.c.

◆ land_visited

unsigned int land_visited = 0
static

Contains what the player visited.

Definition at line 66 of file land.c.

◆ land_wid

unsigned int land_wid = 0

Land window ID, also used in gui.c

Definition at line 78 of file land.c.

◆ land_windows

unsigned int* land_windows = NULL
static

Landed window ids.

Definition at line 81 of file land.c.

◆ land_windowsMap

int land_windowsMap[LAND_NUMWINDOWS]
static

Mapping of windows.

Definition at line 80 of file land.c.

◆ landed

int landed = 0

Is player landed.

Definition at line 74 of file land.c.

◆ last_window

int last_window = 0
static

Default window.

Definition at line 99 of file land.c.

◆ mission_computer

Mission* mission_computer = NULL
static

Missions at the computer.

Definition at line 88 of file land.c.

◆ mission_ncomputer

int mission_ncomputer = 0
static

Number of missions at the computer.

Definition at line 89 of file land.c.

◆ mission_portrait

glTexture* mission_portrait = NULL
static

Mission portrait.

Definition at line 94 of file land.c.

◆ rescue_env

nlua_env rescue_env = LUA_NOREF
static

Rescue Lua env.

Definition at line 113 of file land.c.