31#include "land_outfits.h"
32#include "land_shipyard.h"
33#include "land_trade.h"
48#include "player_fleet.h"
57#define VISITED_LAND (1<<0)
58#define VISITED_COMMODITY (1<<1)
59#define VISITED_BAR (1<<2)
60#define VISITED_OUTFITS (1<<3)
61#define VISITED_SHIPYARD (1<<4)
62#define VISITED_EQUIPMENT (1<<5)
63#define VISITED_MISSION (1<<6)
64#define visited(f) (land_visited |= (f))
65#define has_visited(f) (land_visited & (f))
69unsigned int land_generated = 0;
105static char errorlist[STRMAX_SHORT];
106static char errorreason[STRMAX_SHORT];
107static int errorappend;
108static char *errorlist_ptr;
119static int land_gc(
void *unused );
120static int land_hasLocalMap (
void);
124static void land_changeTab(
unsigned int wid,
const char *wgt,
int old,
int tab );
126static void bar_getDim(
int wid,
int *w,
int *h,
int *iw,
int *ih,
int *bw,
int *bh );
127static void bar_open(
unsigned int wid );
129static void bar_update(
unsigned int wid,
const char *str );
130static void bar_close(
unsigned int wid,
const char *str );
131static void bar_approach(
unsigned int wid,
const char *str );
134static void misn_open(
unsigned int wid );
135static void misn_autonav(
unsigned int wid,
const char *str );
136static void misn_accept(
unsigned int wid,
const char *str );
138static void misn_update(
unsigned int wid,
const char *str );
149void land_needsTakeoff(
int delay )
156static int land_hasLocalMap (
void)
158 if (!spob_hasService(
land_spob, SPOB_SERVICE_REFUEL ))
169 if (player_isFlag( PLAYER_NOSAVE ))
180 if (spob_hasService(p,SPOB_SERVICE_REFUEL) && p->can_land)
212 if (ship_isFlag( ps->
p->
ship, SHIP_NOPLAYER )) {
213 land_errDialogueBuild( _(
"You can not pilot the %s! The ship can only be used as an escort."), shipname );
218 if (ship_isFlag(
player.
p->
ship, SHIP_NOESCORT )) {
231 "You have %d tonne more cargo than the new ship can hold.",
232 "You have %d tonnes more cargo than the new ship can hold.",
238 if (!
dialogue_YesNo(_(
"Recall Fighters"), _(
"This action will recall your deployed fighters. Is that OK?"))) {
258 errorlist_ptr = NULL;
259 if (strcmp(type,
"tradeShip")==0)
261 else if (strcmp(type,
"buyShip")==0)
263 else if (strcmp(type,
"swapEquipment")==0)
265 else if (strcmp(type,
"swap")==0)
267 else if (strcmp(type,
"sellShip")==0)
269 else if (strcmp(type,
"buyOutfit")==0)
271 else if (strcmp(type,
"sellOutfit")==0)
273 else if (strcmp(type,
"buyCommodity")==0)
275 else if (strcmp(type,
"sellCommodity")==0)
277 if (errorlist_ptr != NULL) {
296 vsnprintf(errorreason,
sizeof(errorreason), fmt, ap);
300 if (errorlist_ptr == NULL)
301 errorappend =
scnprintf( errorlist,
sizeof(errorlist),
"%s", errorreason );
303 scnprintf( &errorlist[errorappend],
sizeof(errorlist)-errorappend,
"\n%s", errorreason );
304 errorlist_ptr = errorlist;
311 int *w,
int *h,
int *iw,
int *ih,
int *bw,
int *bh )
317 *iw = 704 + (*w - LAND_WIDTH);
321 *bw = (*w - *iw - 80)/2;
322 *bh = LAND_BUTTON_HEIGHT;
329 int w, h, iw, ih, bw, bh, dh, th;
333 land_tabGenerate(LAND_WINDOW_BAR);
340 bar_getDim( wid, &w, &h, &iw, &ih, &bw, &bh );
347 window_addButtonKey( wid, -20, 20,
348 bw, bh,
"btnCloseBar",
350 window_addButtonKey( wid, -20 - bw - 20, 20,
351 bw, bh,
"btnApproach",
355 window_addText( wid, iw + 40, -40, w - iw - 60, dh, 0,
360 window_addText( wid, iw + 40, th,
365 th -= 20 + PORTRAIT_HEIGHT + 20 + 20;
366 window_addText( wid, iw + 60, th,
367 w - iw - 100, h + th - (2*bh+60), 0,
381 ImageArrayCell *portraits;
382 int w, h, iw, ih, bw, bh;
390 bar_getDim( wid, &w, &h, &iw, &ih, &bw, &bh );
395 pos = toolkit_getImageArrayPos( wid,
"iarMissions" );
411 portraits = calloc(1,
sizeof(ImageArrayCell));
413 portraits[0].caption = strdup(_(
"News"));
417 portraits = calloc(n,
sizeof(ImageArrayCell));
419 portraits[0].caption = strdup(_(
"News"));
421 ImageArrayCell *p = &portraits[i+1];
434 window_addImageArray( wid, 20, -40,
435 iw, ih,
"iarMissions", 128, 96,
439 toolkit_setImageArrayPos( wid,
"iarMissions", pos );
469 int w, h, iw, ih, bw, bh, dh;
472 bar_getDim( wid, &w, &h, &iw, &ih, &bw, &bh );
476 pos = toolkit_getImageArrayPos( wid,
"iarMissions" );
491 window_disableButton( wid,
"btnApproach" );
494 window_modifyText( wid,
"txtPortrait", NULL );
495 window_modifyText( wid,
"txtMission", NULL );
499 w - iw - 100, h - 40 - (dh+20) - 40 - bh - 20 );
512 window_addImage( wid, iw + 40 + (w-iw-60-PORTRAIT_WIDTH)/2,
513 -(40 + dh + 40 +
gl_defFont.
h + 20 + PORTRAIT_HEIGHT),
514 0, 0,
"imgPortraitBG", NULL, 1 );
516 window_addImage( wid, iw + 40 + (w-iw-60-PORTRAIT_WIDTH)/2,
517 -(40 + dh + 40 +
gl_defFont.
h + 20 + PORTRAIT_HEIGHT),
518 0, 0,
"imgPortrait", NULL, 1 );
521 window_enableButton( wid,
"btnApproach" );
524 window_modifyText( wid,
"txtPortrait",
npc_getName( pos ) );
526 PORTRAIT_WIDTH, PORTRAIT_HEIGHT );
528 PORTRAIT_WIDTH, PORTRAIT_HEIGHT );
531 window_modifyText( wid,
"txtMission",
npc_getDesc( pos ));
538static void bar_close(
unsigned int wid,
const char *name )
561 pos = toolkit_getImageArrayPos( wid,
"iarMissions" );
579 toolkit_setImageArrayPos( wid,
"iarMissions", 0 );
585 land_needsTakeoff( 0 );
607 land_tabGenerate(LAND_WINDOW_MISSION);
613 window_addButtonKey( wid, -20, 20,
614 LAND_BUTTON_WIDTH,LAND_BUTTON_HEIGHT,
"btnCloseMission",
616 window_addButtonKey( wid, -20, 40+LAND_BUTTON_HEIGHT,
617 LAND_BUTTON_WIDTH,LAND_BUTTON_HEIGHT,
"btnAcceptMission",
619 window_addButtonKey( wid, -20, 60+2*LAND_BUTTON_HEIGHT,
620 LAND_BUTTON_WIDTH,LAND_BUTTON_HEIGHT,
"btnAutonavMission",
625 window_addText( wid, w/2 + 10, y,
627 "txtSDate", NULL, &cFontGrey,
630 window_addText( wid, w/2 + 110, y,
632 "txtDate", NULL, NULL, NULL );
634 window_addText( wid, w/2 + 10, y,
638 window_addText( wid, w/2 + 10, y,
639 w/2 - 30, y - 40 + h - 2*LAND_BUTTON_HEIGHT, 0,
643 map_show( wid, 20, 20, w/2 - 30, h/2 - 35, 0.75, 0., 0. );
656 const StarSystem *sys;
680 const char* misn_name;
684 misn_name = toolkit_getList( wid,
"lstMission" );
687 if (strcmp(misn_name,_(
"No Missions"))==0)
691 _(
"Are you sure you want to accept this mission?"))) {
693 pos = toolkit_getListPos( wid,
"lstMission" );
700 if ((ret==2) || (ret==3))
712 toolkit_setListPos( wid,
"lstMission", pos-1 );
748 misn_names = malloc(
sizeof(
char*));
749 misn_names[0] = strdup(_(
"No Missions"));
752 window_addList( wid, 20, -40,
767 const char *active_misn;
769 const StarSystem *sys;
770 char txt[STRMAX_SHORT], *
buf;
777 snprintf( txt,
sizeof(txt), n_(
781 window_modifyText( wid,
"txtDate", txt );
783 active_misn = toolkit_getList( wid,
"lstMission" );
784 if (strcmp(active_misn,_(
"No Missions"))==0) {
785 window_modifyText( wid,
"txtHeader", NULL );
786 window_modifyText( wid,
"txtDesc",
787 _(
"There are no missions available here.") );
788 window_disableButton( wid,
"btnAcceptMission" );
789 window_disableButton( wid,
"btnAutonavMission" );
796 map_center( wid, sys->name );
797 snprintf( txt,
sizeof(txt), _(
"%s\n#nReward:#0 %s"), misn->
title, misn->
reward );
798 window_modifyText( wid,
"txtHeader", txt );
799 window_modifyText( wid,
"txtDesc", misn->
desc );
800 window_enableButton( wid,
"btnAcceptMission" );
801 window_enableButton( wid,
"btnAutonavMission" );
816 if (!spob_hasService(
land_spob, SPOB_SERVICE_REFUEL))
842 WARN( _(
"Outfit '%s' does not exist!"), LOCAL_MAP_NAME);
866 char buf[STRMAX], cred[ECON_CRED_STRLEN], tons[STRMAX_SHORT];
874 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n%s",
"" );
876 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n%s",
878 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n%s",
"" );
880 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n\n%s", tons );
881 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n%s", cred );
884 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n%s",
"" );
892 if (!land_hasLocalMap())
897 WARN( _(
"Outfit '%s' does not exist!"), LOCAL_MAP_NAME);
907 credits2str( cred, o->
price, 0 );
908 snprintf( buf,
sizeof(buf), _(
"Buy Local Map (%s)"), cred );
909 window_addButtonKey(
land_windows[0], -20, 20 + (LAND_BUTTON_HEIGHT + 20),
910 LAND_BUTTON_WIDTH, LAND_BUTTON_HEIGHT,
"btnMap",
930 takeoff( 1, player_isFlag(PLAYER_NOSAVE) );
976 const char *names[LAND_NUMWINDOWS];
983 for (
int i=0; i<LAND_NUMWINDOWS; i++)
990 names[j++] = _(
"Landing Main");
992 if (spob_hasService(
land_spob, SPOB_SERVICE_BAR)) {
994 names[j++] = _(
"Spaceport Bar");
997 if (spob_hasService(
land_spob, SPOB_SERVICE_MISSIONS)) {
999 names[j++] = _(
"Missions");
1002 if (spob_hasService(
land_spob, SPOB_SERVICE_OUTFITS)) {
1004 names[j++] = _(
"Outfits");
1007 if (spob_hasService(
land_spob, SPOB_SERVICE_SHIPYARD)) {
1009 names[j++] = _(
"Shipyard");
1012 if (spob_hasService(
land_spob, SPOB_SERVICE_OUTFITS) ||
1013 spob_hasService(
land_spob, SPOB_SERVICE_SHIPYARD)) {
1015 names[j++] = p_(
"service",
"Equipment");
1018 if (spob_hasService(
land_spob, SPOB_SERVICE_COMMODITY)) {
1020 names[j++] = _(
"Commodity");
1037 unsigned int pntservices;
1053 pntservices = p->services;
1056 if (SCREEN_W < LAND_WIDTH || SCREEN_H < LAND_HEIGHT) {
1061 w = LAND_WIDTH + 0.5 * (SCREEN_W - LAND_WIDTH);
1062 h = LAND_HEIGHT + 0.5 * (SCREEN_H - LAND_HEIGHT);
1110 if (spob_hasService(
land_spob, SPOB_SERVICE_BAR))
1112 if (spob_hasService(
land_spob, SPOB_SERVICE_MISSIONS))
1115 MIS_AVAIL_COMPUTER );
1119#define should_open(s, w) \
1120 (spob_hasService(land_spob, s) && (!land_tabGenerated(w)))
1128 if (should_open( SPOB_SERVICE_BAR, LAND_WINDOW_BAR ))
1130 if (should_open( SPOB_SERVICE_MISSIONS, LAND_WINDOW_MISSION ))
1133 if (should_open( SPOB_SERVICE_OUTFITS, LAND_WINDOW_OUTFITS ))
1136 if (should_open( SPOB_SERVICE_SHIPYARD, LAND_WINDOW_SHIPYARD ))
1139 if ((spob_hasService(
land_spob, SPOB_SERVICE_OUTFITS) ||
1140 spob_hasService(
land_spob, SPOB_SERVICE_SHIPYARD)) &&
1141 !land_tabGenerated( LAND_WINDOW_EQUIPMENT ))
1144 if (should_open( SPOB_SERVICE_COMMODITY, LAND_WINDOW_COMMODITY ))
1214 pilot_rmFlag(
player.
p, PILOT_COOLDOWN_BRAKE);
1215 pilot_rmFlag(
player.
p, PILOT_COOLDOWN );
1244 if (spob_hasService(
land_spob, SPOB_SERVICE_BAR))
1248 economy_averageSeenPrices( p );
1267 land_needsTakeoff( 0 );
1276 lua_gc( naevL, LUA_GCCOLLECT, 0 );
1289 int w, h, y, logow, logoh, th;
1290 char buf[STRMAX_SHORT];
1303 logow = logo->
w * (double)FACTION_LOGO_SM /
MAX( logo->
w, logo->
h );
1304 logoh = logo->
h * (double)FACTION_LOGO_SM /
MAX( logo->
w, logo->
h );
1305 window_addImage( wid, 440 + (w-460-logow)/2, -20,
1306 logow, logoh,
"imgFaction", logo, 0 );
1307 offset += FACTION_LOGO_SM;
1314 window_addImage( wid, 20, -40, 400, 400,
"imgSpob",
gfx_exterior, 1 );
1316 window_addText( wid, 440, -20-offset,
1317 w-460, h-20-offset-60-LAND_BUTTON_HEIGHT*2, 0,
1321 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"#n%s", _(
"Stationed at:") );
1322 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n%s", _(
"Class:") );
1323 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n%s", _(
"Faction:") );
1324 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n%s", _(
"Population:") );
1325 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n\n%s", _(
"Free Space:") );
1326 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n%s", _(
"Money:") );
1328 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n%s", _(
"Tags:") );
1330 window_addText( wid, 20, 20, 200, th,
1332 window_addText( wid, 20+120, 20, w - 20 - (20+200) - LAND_BUTTON_WIDTH,
1333 th, 0,
"txtDInfo", &
gl_defFont, NULL, NULL );
1339 window_addButtonKey( wid, -20, 20,
1340 LAND_BUTTON_WIDTH, LAND_BUTTON_HEIGHT,
"btnTakeoff",
1346 y = 20 + (LAND_BUTTON_HEIGHT + 20) + 20;
1347 if (land_hasLocalMap())
1348 y += LAND_BUTTON_HEIGHT + 20;
1350 if (!spob_hasService(
land_spob, SPOB_SERVICE_REFUEL))
1351 l +=
scnprintf( &buf[l],
sizeof(buf)-l, _(
"No refueling services.") );
1354 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"\n" );
1355 l +=
scnprintf( &buf[l],
sizeof(buf)-l,
"#r%s#0", _(
"Game will not be saved.") );
1379 const char *torun_hook = NULL;
1380 unsigned int to_visit = 0;
1387 for (
int i=0; i<LAND_NUMWINDOWS; i++) {
1395 case LAND_WINDOW_MAIN:
1398 case LAND_WINDOW_OUTFITS:
1401 torun_hook =
"outfits";
1403 case LAND_WINDOW_SHIPYARD:
1406 torun_hook =
"shipyard";
1408 case LAND_WINDOW_BAR:
1413 case LAND_WINDOW_MISSION:
1416 torun_hook =
"mission";
1418 case LAND_WINDOW_COMMODITY:
1421 torun_hook =
"commodity";
1423 case LAND_WINDOW_EQUIPMENT:
1427 torun_hook =
"equipment";
1435 if (i != LAND_WINDOW_MISSION)
1445 if (torun_hook != NULL)
1451 land_needsTakeoff( 1 );
1472 char badfleet_ships[STRMAX_SHORT];
1480 badfleet_ships[0] =
'\0';
1487 l +=
scnprintf( &badfleet_ships[l],
sizeof(badfleet_ships)-l,
"\n%s", pe->
p->
name );
1494 if (!spob_hasService(
land_spob, SPOB_SERVICE_SHIPYARD)) {
1499 dialogue_msgRaw( _(
"Fleet not fit for flight"), _(
"You lack the fleet capacity to take off with all selected ships.") );
1504 if (!
dialogue_YesNo( _(
"Fleet not fit for flight"),
"%s\n%s", _(
"The following ships in your fleet are not space worthy, are you sure you want to take off without them?"), badfleet_ships ))
1512 char message[STRMAX_SHORT];
1536 a = RNGF() * 2. * M_PI;
1540 player_rmFlag(PLAYER_LANDACK);
1541 pilot_rmFlag(
player.
p,PILOT_LANDING);
1565 dialogue_alert( _(
"Failed to save game! You should exit and check the log to see what happened and then file a bug report!") );
1601 if (pilot_isFlag(p,PILOT_DELETE))
1611 if (!pilot_isWithPlayer( p ))
1618 p->ptimer = p->landing_delay;
1619 pilot_setFlag( p, PILOT_TAKEOFF );
1634 if (!PHYSFS_exists(RESCUE_PATH))
1647 WARN( _(
"File '%s' not found!"), RESCUE_PATH );
1650 if (nlua_dobufenv(
rescue_env, buf, bufsize, RESCUE_PATH) != 0) {
1651 WARN( _(
"Error loading file: %s\n"
1653 "Most likely Lua file has improper syntax, please check"),
1654 RESCUE_PATH, lua_tostring(naevL,-1));
1664 WARN( _(
"Rescue: 'rescue' : '%s'"), lua_tostring(naevL,-1));
1723 commodity_exchange_cleanup();
Provides macros to work with dynamic arrays.
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
void cam_setTargetPilot(unsigned int follow, int soft_over)
Sets the target to follow.
void dialogue_alert(const char *fmt,...)
Displays an alert popup with only an ok button and a message.
void dialogue_msgRaw(const char *caption, const char *msg)
Opens a dialogue window with an ok button and a fixed message.
int dialogue_YesNo(const char *caption, const char *fmt,...)
Runs a dialogue with both yes and no options.
void effect_clear(Effect **efxlist)
Clears an effect list, removing all active effects.
void equipment_slotDeselect(CstSlotWidget *wgt)
Deselects equipment stuff.
void equipment_cleanup(void)
Cleans up after the equipment stuff.
void equipment_updateOutfits(unsigned int wid, const char *str)
Updates the player's outfit list.
void equipment_updateShips(unsigned int wid, const char *str)
Updates the player's ship window.
void equipment_open(unsigned int wid)
Opens the player's equipment window.
int escort_clearDeployed(Pilot *p)
Clears deployed escorts of a pilot.
void events_trigger(EventTrigger_t trigger)
Runs all the events matching a trigger.
const glTexture * faction_logo(int f)
Gets the faction's logo (ideally 256x256).
const char * faction_name(int f)
Gets a factions "real" (internal) name.
int gl_printHeightRaw(const glFont *ft_font, const int width, const char *text)
Gets the height of a non-formatted string.
void gui_setNav(void)
Player just changed their nav computer target.
void player_message(const char *fmt,...)
Adds a mesg to the queue to be displayed on screen.
int hooks_run(const char *stack)
Runs all the hooks of stack.
unsigned int hook_addFunc(int(*func)(void *), void *data, const char *stack)
Adds a function hook to be run.
void bar_regen(void)
Regenerates the bar list.
static void land_changeTab(unsigned int wid, const char *wgt, int old, int tab)
Saves the last place the player was.
void land_queueTakeoff(void)
Queue a takeoff.
static int land_windowsMap[LAND_NUMWINDOWS]
void takeoff(int delay, int nosave)
Makes the player take off if landed.
static void misn_autonav(unsigned int wid, const char *str)
Autonav to selected mission.
static void land_cleanupWindow(unsigned int wid, const char *name)
Cleans up the land window.
static void bar_close(unsigned int wid, const char *str)
Closes the mission computer window.
int can_swapEquipment(const char *shipname)
Makes sure it's valid to change ships in the equipment view.
#define VISITED_EQUIPMENT
void land_genWindows(int load, int changetab)
Recreates the land windows.
static unsigned int * land_windows
static void bar_update(unsigned int wid, const char *str)
Updates the missions in the spaceport bar.
static int mission_ncomputer
int land_setWindow(int window)
Sets the land window tab.
static void bar_approach(unsigned int wid, const char *str)
Approaches guy in mission computer.
unsigned int land_getWid(int window)
Gets the WID of a window by type.
static void land_stranded(void)
Runs the rescue script if players are stuck.
static void spaceport_buyMap(unsigned int wid, const char *str)
Buys a local system map.
#define VISITED_COMMODITY
static void misn_open(unsigned int wid)
Opens the mission computer window.
void land_cleanup(void)
Cleans up some land-related variables.
static Mission * mission_computer
int land_doneLoading(void)
Check to see if finished loading.
void land(Spob *p, int load)
Opens up all the land dialogue stuff.
static int bar_genList(unsigned int wid)
Generates the mission list for the bar.
void land_errDialogueBuild(const char *fmt,...)
Generates error dialogues used by several landing tabs.
int land_errDialogue(const char *name, const char *type)
Generates error dialogues used by several landing tabs.
static int news_load(void)
Loads the news.
static int land_taboverride
void land_exit(void)
Exits all the landing stuff.
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.
void land_updateMainTab(void)
Adds the "Buy Local Map" button if needed and updates info.
static unsigned int land_visited
static void bar_open(unsigned int wid)
Opens the spaceport bar window.
int land_canSave(void)
Whether or not the player can save.
static glTexture * mission_portrait
static void land_setupTabs(void)
Sets up the tabs for the window.
void land_buttonTakeoff(unsigned int wid, const char *unused)
Wrapper for takeoff mission button.
void land_refuel(void)
Refuels the player's current ship, if possible.
static glTexture * gfx_exterior
static void misn_update(unsigned int wid, const char *str)
Updates the mission list.
static int land_gc(void *unused)
Runs Lua garbage collection.
static void misn_accept(unsigned int wid, const char *str)
Accepts the selected mission.
static void land_createMainTab(unsigned int wid)
Creates the main tab.
static void misn_genList(unsigned int wid, int first)
Generates the mission list.
static nlua_env rescue_env
void outfits_regenList(unsigned int wid, const char *str)
Regenerates the outfit list.
void outfits_cleanup(void)
Cleans up outfit globals.
void outfits_open(unsigned int wid, const Outfit **outfits)
Opens the outfit exchange center window.
void outfits_update(unsigned int wid, const char *str)
Updates the outfits in the outfit window.
int outfit_canSell(const char *name)
Checks to see if the player can sell the selected outfit.
int outfit_canBuy(const char *name, const Spob *spob)
Checks to see if the player can buy the outfit.
void shipyard_open(unsigned int wid)
Opens the shipyard window.
int can_sell(const char *shipname)
Makes sure it's valid to sell a ship.
int shipyard_canBuy(const char *shipname, const Spob *spob)
Makes sure it's valid to buy a ship.
int can_swap(const char *shipname)
Makes sure it's valid to change ships.
void shipyard_cleanup(void)
Cleans up shipyard data.
int shipyard_canTrade(const char *shipname, const Spob *spob)
Makes sure it's valid to buy a ship, trading the old one in simultaneously.
void shipyard_update(unsigned int wid, const char *str)
Updates the ships in the shipyard window.
int commodity_canBuy(const Commodity *com)
Checks to see if the player can buy a commodity.
void commodity_exchange_open(unsigned int wid)
Opens the local market window.
int commodity_canSell(const Commodity *com)
Checks to see if a player can sell a commodity.
void commodity_update(unsigned int wid, const char *str)
Updates the commodity window.
int mission_accept(Mission *mission)
Small wrapper for misn_run.
Mission * missions_genList(int *n, int faction, const Spob *pnt, const StarSystem *sys, MissionAvailability loc)
Generates a mission list. This runs create() so won't work with all missions.
void mission_cleanup(Mission *misn)
Cleans up a mission.
const StarSystem * mission_sysComputerMark(const Mission *misn)
Marks the system of the computer mission to reflect where it will head to.
void mission_sysMark(void)
Marks all active systems that need marking.
void missions_run(MissionAvailability loc, int faction, const Spob *pnt, const StarSystem *sys)
Runs missions matching location, all Lua side and one-shot.
int music_choose(const char *situation)
Actually runs the music stuff, based on situation.
int naev_isQuit(void)
Get if Naev is trying to quit.
Header file with generic functions and naev-specifics.
void * ndata_read(const char *path, size_t *filesize)
Reads a file from the ndata (will be NUL terminated).
int * generate_news(int faction)
Generates news from newslist from specific faction AND Generic news.
void news_widget(unsigned int wid, int x, int y, int w, int h)
Creates a news widget.
static char buf[NEWS_MAX_LENGTH]
int nlua_loadStandard(nlua_env env)
Loads the standard Naev Lua API.
int nlua_loadTk(nlua_env env)
Loads the Toolkit Lua library.
const char * npc_getDesc(int i)
Gets the NPC description.
void npc_generateMissions(void)
Generates the bar missions.
glTexture * npc_getTexture(int i)
Get the texture of an NPC.
int npc_approach(int i)
Approaches the NPC.
void npc_clear(void)
Cleans up the spaceport bar NPC.
int npc_getArraySize(void)
Get the size of the npc array.
glTexture * npc_getBackground(int i)
Get the background of an NPC.
int npc_isImportant(int i)
Checks to see if the NPC is important or not.
const char * npc_getName(int i)
Get the name of an NPC.
void npc_sort(void)
Sorts the NPCs.
int scnprintf(char *text, size_t maxlen, const char *fmt,...)
Like snprintf(), but returns the number of characters ACTUALLY "printed" into the buffer....
ntime_t ntime_create(int scu, int stp, int stu)
Creates a time structure.
char * ntime_pretty(ntime_t t, int d)
Gets the time in a pretty human readable format.
void ntime_inc(ntime_t t)
Sets the time relatively.
glTexture * gl_dupTexture(const glTexture *texture)
Duplicates a texture.
glTexture ** gl_addTexArray(glTexture **tex, int *n, glTexture *t)
Adds an element to a texture array.
glTexture * gl_newImage(const char *path, const unsigned int flags)
Loads an image as a texture.
void gl_freeTexture(glTexture *texture)
Frees a texture.
const Outfit * outfit_get(const char *name)
Gets an outfit by name.
void pilot_setThrust(Pilot *p, double thrust)
Sets the pilot's thrust.
void pilots_clean(int persist)
Cleans up the pilot stack - leaves the player.
void pilot_setTurn(Pilot *p, double turn)
Sets the pilot's turn.
Pilot *const * pilot_getAll(void)
Gets the pilot stack.
int pilot_cargoFree(const Pilot *p)
Gets the pilot's free cargo space.
int pilot_cargoUsedMission(const Pilot *p)
Gets how much mission cargo ship has on board.
int pilot_cargoUsed(const Pilot *p)
Gets how much cargo ship has on board.
void pilot_heatReset(Pilot *p)
Resets a pilot's heat.
int pilot_hasDeployed(Pilot *p)
Checks to see if the pilot has deployed ships.
void pilot_healLanded(Pilot *pilot)
Cures the pilot as if he was landed.
void pilot_outfitLOntakeoff(Pilot *pilot)
Runs Lua outfits when pilot takes off from a spob.
void pilot_calcStats(Pilot *pilot)
Recalculates the pilot's stats based on his outfits.
int pilot_reportSpaceworthy(const Pilot *p, char *buf, int bufSize)
Pilot safety report - makes sure stats are safe.
void pilot_outfitLOnland(Pilot *pilot)
Runs Lua outfits when pilot lands on a spob.
int pilot_isSpaceworthy(const Pilot *p)
Pilot safety check - makes sure stats are safe.
void pilot_outfitLInitAll(Pilot *pilot)
Runs the pilot's Lua outfits init script.
int player_addOutfit(const Outfit *o, int quantity)
Adds an outfit to the player outfit stack.
void player_warp(double x, double y)
Warps the player to the new position.
const PlayerShip_t * player_getShipStack(void)
Gets the array (array.h) of the player's ships.
void player_hyperspacePreempt(int preempt)
Enables or disables jump points preempting spobs in autoface and target clearing.
PlayerShip_t * player_getPlayerShip(const char *shipname)
Gets a specific ship.
double player_dt_default(void)
Returns the player's total default time delta based on time dilation stuff.
int player_addEscorts(void)
Adds the player's escorts.
void player_soundStop(void)
Stops playing player sounds.
credits_t player_modCredits(credits_t amount)
Modifies the amount of credits the player has.
void player_targetSpobSet(int id)
Sets the player's target spob.
void player_autonavResetSpeed(void)
Resets the game speed.
void player_autonavStart(void)
Starts autonav.
int pfleet_cargoFree(void)
Gets the total amount of free cargo space in the player's fleet.
void pfleet_update(void)
Updates the used fleet capacity of the player.
int save_all(void)
Saves the current game.
void sound_stopAll(void)
Stops all the playing voices.
void space_init(const char *sysname, int do_simulate)
Initializes the system.
void spob_updateLand(Spob *p)
Updates the land possibilities of a spob.
const char * space_populationStr(uint64_t population)
Gets the population in an approximated string. Note this function changes the string value each call,...
const char * spob_name(const Spob *p)
Gets the translated name of a spob.
const char * spob_getClassName(const char *class)
Gets the long class name for a spob.
void space_clearComputerMarkers(void)
Clears all the system computer markers.
Represents an active mission.
A ship outfit, depends radically on the type.
The representation of an in-game pilot.
unsigned int landed_times
unsigned int landed_times
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
Abstraction for rendering sprite sheets.