30#include "land_outfits.h"
31#include "land_shipyard.h"
32#include "land_trade.h"
47#include "player_autonav.h"
48#include "player_fleet.h"
57#define VISITED_LAND ( 1 << 0 )
58#define VISITED_COMMODITY \
61#define VISITED_BAR ( 1 << 2 )
62#define VISITED_OUTFITS ( 1 << 3 )
63#define VISITED_SHIPYARD ( 1 << 4 )
64#define VISITED_EQUIPMENT ( 1 << 5 )
65#define VISITED_MISSION \
67#define visited( f ) ( land_visited |= ( f ) )
68#define has_visited( f ) \
69 ( land_visited & ( f ) )
73unsigned int land_generated = 0;
112static char errorlist[STRMAX_SHORT];
113static char errorreason[STRMAX_SHORT];
114static int errorappend;
115static char *errorlist_ptr;
126static int land_gc(
void *unused );
127static int land_hasLocalMap(
void );
131static void land_changeTab(
unsigned int wid,
const char *wgt,
int old,
134static void bar_getDim(
int wid,
int *w,
int *h,
int *iw,
int *ih,
int *bw,
136static void bar_open(
unsigned int wid );
138static void bar_update(
unsigned int wid,
const char *str );
139static void bar_close(
unsigned int wid,
const char *str );
140static void bar_approach(
unsigned int wid,
const char *str );
143static void misn_popdown(
unsigned int wid,
const char *str );
144static void misn_popdownActivate(
unsigned int wid,
const char *str );
145static void misn_popdownSelect(
unsigned int wid,
const char *str );
147static void misn_computerOptionsRegen(
unsigned int wid,
const char *str );
149static void misn_open(
unsigned int wid );
150static void misn_autonav(
unsigned int wid,
const char *str );
151static void misn_accept(
unsigned int wid,
const char *str );
153static void misn_update(
unsigned int wid,
const char *str );
154static void misn_popdown(
unsigned int wid,
const char *str );
165void land_needsTakeoff(
int delay )
172static int land_hasLocalMap(
void )
174 if ( !spob_hasService(
land_spob, SPOB_SERVICE_REFUEL ) )
185 if ( player_isFlag( PLAYER_NOSAVE ) )
191 spob_hasService(
land_spob, SPOB_SERVICE_REFUEL ) )
198 if ( spob_hasService( p, SPOB_SERVICE_REFUEL ) && p->can_land )
219 errorlist_ptr = NULL;
233 vsnprintf( errorreason,
sizeof( errorreason ), fmt, ap );
236 if ( errorlist_ptr == NULL )
238 scnprintf( errorlist,
sizeof( errorlist ),
"%s", errorreason );
240 scnprintf( &errorlist[errorappend],
sizeof( errorlist ) - errorappend,
241 "\n%s", errorreason );
242 errorlist_ptr = errorlist;
250 if ( errorlist_ptr != NULL ) {
260static void bar_getDim(
int wid,
int *w,
int *h,
int *iw,
int *ih,
int *bw,
267 *iw = 704 + ( *w - LAND_WIDTH );
271 *bw =
MIN( LAND_BUTTON_WIDTH, ( *w - *iw - 80 ) / 2 );
272 *bh = LAND_BUTTON_HEIGHT;
279 int w, h, iw, ih, bw, bh, dh, th;
283 land_tabGenerate( LAND_WINDOW_BAR );
289 desc = (
land_spob->bar_description != NULL )
292 bar_getDim( wid, &w, &h, &iw, &ih, &bw, &bh );
299 window_addButtonKey( wid, -20, 20, bw, bh,
"btnCloseBar", _(
"Take Off" ),
301 window_addButtonKey( wid, -20 - bw - 20, 20, bw, bh,
"btnApproach",
305 window_addText( wid, iw + 40, -40, w - iw - 60, dh, 0,
"txtDescription",
310 window_addText( wid, iw + 40, th, w - iw - 60,
gl_defFont.h, 1,
314 th -= 20 + PORTRAIT_HEIGHT + 20 + 20;
315 window_addText( wid, iw + 60, th, w - iw - 100, h + th - ( 2 * bh + 60 ), 0,
329 ImageArrayCell *portraits;
330 int w, h, iw, ih, bw, bh;
338 bar_getDim( wid, &w, &h, &iw, &ih, &bw, &bh );
344 pos = toolkit_getImageArrayPos( wid,
"iarMissions" );
358 portraits = calloc( 1,
sizeof( ImageArrayCell ) );
360 portraits[0].caption = strdup( _(
"News" ) );
363 portraits = calloc( n,
sizeof( ImageArrayCell ) );
365 portraits[0].caption = strdup( _(
"News" ) );
367 ImageArrayCell *p = &portraits[i + 1];
379 gl_newImage( OVERLAY_GFX_PATH
"portrait_exclamation.webp", 0 ) );
384 window_addImageArray( wid, 20, -40, iw, ih,
"iarMissions", 128, 96,
388 toolkit_setImageArrayPos( wid,
"iarMissions", pos );
398 window_tabWinSetTabName(
land_wid,
"tabLand",
400 _(
"Spaceport Bar #r!!#0" ) );
402 window_tabWinSetTabName(
land_wid,
"tabLand",
404 _(
"Spaceport Bar" ) );
440 NTracingZone( _ctx, 1 );
442 NTracingZoneEnd( _ctx );
453 int w, h, iw, ih, bw, bh, dh;
456 bar_getDim( wid, &w, &h, &iw, &ih, &bw, &bh );
461 pos = toolkit_getImageArrayPos( wid,
"iarMissions" );
476 window_disableButton( wid,
"btnApproach" );
479 window_modifyText( wid,
"txtPortrait", NULL );
480 window_modifyText( wid,
"txtMission", NULL );
483 news_widget( wid, iw + 60, -40 - ( 40 + dh ), w - iw - 100,
484 h - 40 - ( dh + 20 ) - 40 - bh - 20 );
497 window_addImage( wid, iw + 40 + ( w - iw - 60 - PORTRAIT_WIDTH ) / 2,
498 -( 40 + dh + 40 +
gl_defFont.h + 20 + PORTRAIT_HEIGHT ),
499 0, 0,
"imgPortraitBG", NULL, 1 );
501 window_addImage( wid, iw + 40 + ( w - iw - 60 - PORTRAIT_WIDTH ) / 2,
502 -( 40 + dh + 40 +
gl_defFont.h + 20 + PORTRAIT_HEIGHT ),
503 0, 0,
"imgPortrait", NULL, 1 );
506 window_enableButton( wid,
"btnApproach" );
509 window_modifyText( wid,
"txtPortrait",
npc_getName( pos ) );
511 PORTRAIT_WIDTH, PORTRAIT_HEIGHT );
513 PORTRAIT_WIDTH, PORTRAIT_HEIGHT );
516 window_modifyText( wid,
"txtMission",
npc_getDesc( pos ) );
523static void bar_close(
unsigned int wid,
const char *name )
546 pos = toolkit_getImageArrayPos( wid,
"iarMissions" );
565 toolkit_setImageArrayPos( wid,
"iarMissions", 0 );
571 land_needsTakeoff( 0 );
592 land_tabGenerate( LAND_WINDOW_MISSION );
598 int bw =
MIN( LAND_BUTTON_WIDTH, ( w / 2 - 80 ) / 3 );
599 window_addButtonKey( wid, -20, 20, bw, LAND_BUTTON_HEIGHT,
"btnCloseMission",
601 window_addButtonKey( wid, -20 - bw - 20, 20, bw, LAND_BUTTON_HEIGHT,
602 "btnAcceptMission", _(
"Accept Mission" ),
misn_accept,
604 window_addButtonKey( wid, -20 - 2 * ( bw + 20 ), 20, bw, LAND_BUTTON_HEIGHT,
610 window_addText( wid, w / 2 + 10, y, w / 2 - 30, 40, 0,
"txtSDate", NULL,
614 window_addText( wid, w / 2 + 110, y, w / 2 - 130, 40, 0,
"txtDate", NULL,
617 window_addText( wid, w / 2 + 10, y, w / 2 - 30, 50, 0,
"txtHeader",
620 window_addText( wid, w / 2 + 10, y, w / 2 - 30,
621 y - 40 + h - 2 * LAND_BUTTON_HEIGHT, 0,
"txtDesc",
625 map_show( wid, 20, 20, w / 2 - 30, h / 2 - 35, 0.75, 0., 0. );
638 const StarSystem *sys;
650 map_select( sys, 0 );
664 const char *misn_name = toolkit_getList( wid,
"lstMission" );
667 if ( strcmp( misn_name, _(
"No Missions" ) ) == 0 )
671 _(
"Accept Mission" ),
672 _(
"Are you sure you want to accept this mission?" ) ) ) {
674 int pos = toolkit_getListPos( wid,
"lstMission" );
682 if ( ( ret == 2 ) || ( ret == 3 ) )
704 for (
int i = 0; i <
array_size( misn ); i++ ) {
705 if ( misn_opts.hideillegal && misn[i].
illegal )
715static int misn_cmp(
const void *p1,
const void *p2 )
717 int r1 = *(
const int *)p1;
718 int r2 = *(
const int *)p2;
723 switch ( misn_opts.sortby ) {
724 case MISNCOMPUTER_SORT_PRIORITY:
730 case MISNCOMPUTER_SORT_REWARD:
736 case MISNCOMPUTER_SORT_DISTANCE:
757 const char *name =
"lstMissionPopdown";
758 const char *sort[] = {
759 [MISNCOMPUTER_SORT_PRIORITY] = _(
"Sort by Priority" ),
760 [MISNCOMPUTER_SORT_REWARD] = _(
"Sort by Reward" ),
761 [MISNCOMPUTER_SORT_DISTANCE] = _(
"Sort by Distance" ),
762 [MISNCOMPUTER_SORT_SETTINGS] = _(
"Settings" ),
764 size_t n =
sizeof( sort ) /
sizeof( sort[0] );
773 sortlist = malloc(
sizeof( sort ) );
774 for (
size_t i = 0; i < n; i++ )
775 sortlist[i] = strdup( _( sort[i] ) );
779 window_addList( wid, x + w, y - 120 + h, 350, 120, name, sortlist, n,
780 misn_opts.sortby, misn_popdownSelect, misn_popdownActivate );
784static void misn_popdownSelect(
unsigned int wid,
const char *str )
786 MissionComputerSort p = toolkit_getListPos( wid, str );
787 if ( p == MISNCOMPUTER_SORT_SETTINGS ) {
794 if ( misn_opts.sortby != p ) {
795 misn_opts.sortby = p;
800static void misn_popdownActivate(
unsigned int wid,
const char *str )
802 misn_popdownSelect( wid, str );
806static void misn_computerOptionsRegen(
unsigned int wid,
const char *str )
810 misn_opts.
sortby = toolkit_getListPos( wid,
"lstSort" );
812 misn_opts.hideillegal = window_checkboxState( wid,
"chkHideIllegal" );
825 misn_computerOptionsRegen( wid, name );
838 const char *sort[] = {
839 [MISNCOMPUTER_SORT_PRIORITY] = _(
"Priority (Default)" ),
840 [MISNCOMPUTER_SORT_REWARD] = _(
"Reward" ),
841 [MISNCOMPUTER_SORT_DISTANCE] = _(
"Distance" ),
843 size_t l =
sizeof( sort ) /
sizeof( sort[0] );
849 mwid =
window_create(
"wdwMisnPopdown", _(
"Mission Computer Settings" ), -1,
856 window_addText( mwid, 20, y, 100, h - LAND_BUTTON_HEIGHT, 0,
"txtSSort",
859 sortD = malloc(
sizeof(
char * ) * l );
860 for (
size_t i = 0; i < l; i++ )
861 sortD[i] = strdup( sort[i] );
862 window_addList( mwid, 20, y, 200, 100,
"lstSort", sortD, l, 0,
863 misn_computerOptionsRegen, NULL );
867 window_addCheckbox( mwid, 20, y, w - 40, 30,
"chkHideIllegal",
868 _(
"Hide Illegal Missions" ), misn_computerOptionsRegen,
869 misn_opts.hideillegal );
872 window_addButton( mwid, -20, 20, LAND_BUTTON_WIDTH, LAND_BUTTON_HEIGHT,
890 pos = toolkit_getListPos( wid,
"lstMission" );
915 if ( misn->
title != NULL )
916 misn_names[j++] = strdup( misn->
title );
919 if ( ( misn_names == NULL ) ||
924 misn_names = malloc(
sizeof(
char *) );
925 misn_names[0] = strdup( _(
"No Missions" ) );
928 window_addList( wid, 20, -40, w / 2 - 30, h / 2 - 35,
"lstMission",
936 toolkit_setListPos( wid,
"lstMission", pos );
939 window_addButton( wid, 20 + w / 2 - 30 - 25, -35, 30, 30,
"btnMissionFilter",
941 window_buttonCustomRender( wid,
"btnMissionFilter",
942 window_buttonCustomRenderGear );
952 const char *active_misn;
955 const StarSystem *sys;
956 char txt[STRMAX_SHORT], *buf;
964 snprintf( txt,
sizeof( txt ),
965 n_(
"%s\n%d Tonne",
"%s\n%d Tonnes", cargofree ), buf, cargofree );
967 window_modifyText( wid,
"txtDate", txt );
969 active_misn = toolkit_getList( wid,
"lstMission" );
970 if ( strcmp( active_misn, _(
"No Missions" ) ) == 0 ) {
971 window_modifyText( wid,
"txtHeader", NULL );
972 window_modifyText( wid,
"txtDesc",
973 _(
"There are no missions available here." ) );
974 window_disableButton( wid,
"btnAcceptMission" );
975 window_disableButton( wid,
"btnAutonavMission" );
983 map_center( wid, sys->name );
984 snprintf( txt,
sizeof( txt ), _(
"%s\n#nReward:#0 %s" ), misn->
title,
986 window_modifyText( wid,
"txtHeader", txt );
987 window_modifyText( wid,
"txtDesc", misn->
desc );
988 window_enableButton( wid,
"btnAcceptMission" );
989 window_enableButton( wid,
"btnAutonavMission" );
1005 !spob_hasService(
land_spob, SPOB_SERVICE_REFUEL ) )
1026 WARN( _(
"Outfit '%s' does not exist!" ), LOCAL_MAP_NAME );
1056 char buf[STRMAX], cred[ECON_CRED_STRLEN], tons[STRMAX_SHORT];
1063 l +=
scnprintf( &buf[l],
sizeof( buf ) - l, _(
"%s (%s system)" ),
1065 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
1067 scnprintf( &buf[l],
sizeof( buf ) - l, _(
"%s (%s-class)" ),
1069 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s",
1073 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s",
1075 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n\n%s", tons );
1076 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", cred );
1078 if ( conf.devmode ) {
1079 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
1081 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"%s%s",
1082 ( ( i > 0 ) ?
", " :
"" ),
land_spob->tags[i] );
1088 if ( !land_hasLocalMap() )
1091 if ( LOCAL_MAP_NAME != NULL ) {
1094 WARN( _(
"Outfit '%s' does not exist!" ), LOCAL_MAP_NAME );
1107 snprintf( buf,
sizeof( buf ), _(
"Buy Local Map (%s)" ), cred );
1108 window_addButtonKey(
land_windows[0], -20 - LAND_BUTTON_WIDTH - 20, 20,
1109 LAND_BUTTON_WIDTH, LAND_BUTTON_HEIGHT,
"btnMap", buf,
1129 takeoff( 1, player_isFlag( PLAYER_NOSAVE ) );
1175 const char *names[LAND_NUMWINDOWS];
1182 for (
int i = 0; i < LAND_NUMWINDOWS; i++ )
1189 names[j++] = _(
"Landing Main" );
1191 if ( spob_hasService(
land_spob, SPOB_SERVICE_BAR ) ) {
1193 names[j++] = _(
"Spaceport Bar" );
1196 if ( spob_hasService(
land_spob, SPOB_SERVICE_MISSIONS ) ) {
1198 names[j++] = _(
"Missions" );
1201 if ( spob_hasService(
land_spob, SPOB_SERVICE_OUTFITS ) ) {
1203 names[j++] = _(
"Outfits" );
1206 if ( spob_hasService(
land_spob, SPOB_SERVICE_SHIPYARD ) ) {
1208 names[j++] = _(
"Shipyard" );
1211 if ( spob_hasService(
land_spob, SPOB_SERVICE_REFUEL ) ||
1212 spob_hasService(
land_spob, SPOB_SERVICE_OUTFITS ) ||
1213 spob_hasService(
land_spob, SPOB_SERVICE_SHIPYARD ) ) {
1215 names[j++] = p_(
"service",
"Equipment" );
1218 if ( spob_hasService(
land_spob, SPOB_SERVICE_COMMODITY ) ) {
1220 names[j++] = _(
"Commodity" );
1237 unsigned int pntservices;
1239 NTracingZone( _ctx, 1 );
1254 pntservices = p->services;
1257 if ( SCREEN_W < LAND_WIDTH || SCREEN_H < LAND_HEIGHT ) {
1261 w = LAND_WIDTH + 0.5 * ( SCREEN_W - LAND_WIDTH );
1262 h = LAND_HEIGHT + 0.5 * ( SCREEN_H - LAND_HEIGHT );
1290 NTracingZoneName( _ctx_landhooks,
"hooks_run(\"land\")", 1 );
1300 NTracingZoneEnd( _ctx_landhooks );
1305 NTracingZoneEnd( _ctx );
1310 if (
land_spob->services != pntservices ) {
1318 if ( spob_hasService(
land_spob, SPOB_SERVICE_BAR ) )
1320 if ( spob_hasService(
land_spob, SPOB_SERVICE_MISSIONS ) )
1327#define should_open( s, w ) \
1328 ( spob_hasService( land_spob, s ) && ( !land_tabGenerated( w ) ) )
1336 if ( should_open( SPOB_SERVICE_BAR, LAND_WINDOW_BAR ) )
1338 if ( should_open( SPOB_SERVICE_MISSIONS, LAND_WINDOW_MISSION ) )
1341 if ( should_open( SPOB_SERVICE_OUTFITS, LAND_WINDOW_OUTFITS ) )
1343 spob_hasService(
land_spob, SPOB_SERVICE_BLACKMARKET ) );
1345 if ( should_open( SPOB_SERVICE_SHIPYARD, LAND_WINDOW_SHIPYARD ) )
1348 if ( ( spob_hasService(
land_spob, SPOB_SERVICE_REFUEL ) ||
1349 spob_hasService(
land_spob, SPOB_SERVICE_OUTFITS ) ||
1350 spob_hasService(
land_spob, SPOB_SERVICE_SHIPYARD ) ) &&
1351 !land_tabGenerated( LAND_WINDOW_EQUIPMENT ) )
1354 if ( should_open( SPOB_SERVICE_COMMODITY, LAND_WINDOW_COMMODITY ) )
1373 window_tabWinSetActive(
land_wid,
"tabLand",
1390 NTracingZoneEnd( _ctx );
1420 char buf[STRMAX_SHORT];
1421 size_t l = snprintf( buf,
sizeof( buf ),
"Player landed on '%s'", p->name );
1422 NTracingMessage( buf, l );
1424 NTracingFrameMarkStart(
"land" );
1429 player.ps.landed_times++;
1432 pilot_rmFlag(
player.p, PILOT_LANDING );
1435 pilot_rmFlag(
player.p, PILOT_COOLDOWN_BRAKE );
1436 pilot_rmFlag(
player.p, PILOT_COOLDOWN );
1451 free(
player.p->comm_msg );
1452 player.p->comm_msg = NULL;
1467 if ( spob_hasService(
land_spob, SPOB_SERVICE_BAR ) )
1471 economy_averageSeenPrices( p );
1487 land_needsTakeoff( 0 );
1489 NTracingFrameMarkEnd(
"land" );
1498 lua_gc(
naevL, LUA_GCCOLLECT, 0 );
1511 char buf[STRMAX_SHORT];
1521 if (
land_spob->presence.faction != -1 ) {
1523 if ( logo != NULL ) {
1525 logo->
w * (double)FACTION_LOGO_SM /
MAX( logo->
w, logo->
h );
1527 logo->
h * (double)FACTION_LOGO_SM /
MAX( logo->
w, logo->
h );
1528 window_addImage( wid, 440 + ( w - 460 - logow ) / 2, -20, logow, logoh,
1529 "imgFaction", logo, 0 );
1530 offset += FACTION_LOGO_SM;
1537 window_addImage( wid, 20, -40, 400, 400,
"imgSpob",
gfx_exterior, 1 );
1539 window_addText( wid, 440, -20 - offset, w - 460,
1540 h - 20 - offset - 60 - LAND_BUTTON_HEIGHT * 2, 0,
1545 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"#n%s", _(
"Stationed at:" ) );
1546 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Class:" ) );
1547 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Faction:" ) );
1548 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Population:" ) );
1549 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n\n%s", _(
"Free Space:" ) );
1550 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Money:" ) );
1552 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n%s", _(
"Tags:" ) );
1554 window_addText( wid, 20, 20, 200, th, 0,
"txtSInfo", &
gl_defFont, NULL,
1556 window_addText( wid, 20 + 120, 20, w - 20 - ( 20 + 200 ) - LAND_BUTTON_WIDTH,
1557 th, 0,
"txtDInfo", &
gl_defFont, NULL, NULL );
1563 window_addButtonKey( wid, -20, 20, LAND_BUTTON_WIDTH, LAND_BUTTON_HEIGHT,
1570 y = 20 + ( LAND_BUTTON_HEIGHT + 20 ) + 20;
1571 if ( land_hasLocalMap() )
1572 y += LAND_BUTTON_HEIGHT + 20;
1574 if ( !spob_hasService(
land_spob, SPOB_SERVICE_REFUEL ) )
1576 scnprintf( &buf[l],
sizeof( buf ) - l, _(
"No refueling services." ) );
1579 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"\n" );
1580 l +=
scnprintf( &buf[l],
sizeof( buf ) - l,
"#r%s#0",
1581 _(
"Game will not be saved." ) );
1585 window_addText(
land_windows[0], -20, y, 200, th, 0,
"txtPlayer",
1606 const char *torun_hook = NULL;
1607 unsigned int to_visit = 0;
1614 for (
int i = 0; i < LAND_NUMWINDOWS; i++ ) {
1622 case LAND_WINDOW_MAIN:
1625 case LAND_WINDOW_OUTFITS:
1628 torun_hook =
"outfits";
1630 case LAND_WINDOW_SHIPYARD:
1633 torun_hook =
"shipyard";
1635 case LAND_WINDOW_BAR:
1640 case LAND_WINDOW_MISSION:
1643 torun_hook =
"mission";
1645 case LAND_WINDOW_COMMODITY:
1648 torun_hook =
"commodity";
1650 case LAND_WINDOW_EQUIPMENT:
1654 torun_hook =
"equipment";
1662 if ( i != LAND_WINDOW_MISSION )
1672 if ( torun_hook != NULL )
1679 land_needsTakeoff( 1 );
1703 if (
player.fleet_capacity > 0 ) {
1704 char badfleet_ships[STRMAX_SHORT];
1705 char overfleet_ships[STRMAX_SHORT];
1710 int capused =
player.p->ship->points;
1715 badfleet_ships[0] =
'\0';
1716 for (
int i = 0; i <
array_size( pships ); i++ ) {
1721 if ( capused >
player.fleet_capacity ) {
1723 l +=
scnprintf( &overfleet_ships[l],
sizeof( overfleet_ships ) - l,
1729 l +=
scnprintf( &badfleet_ships[l],
sizeof( badfleet_ships ) - l,
1739 snprintf( buf,
sizeof( buf ),
"%s\n%s",
1740 _(
"You lack the fleet capacity to take off with all "
1741 "the selected ships. Do you wish to undeploy the "
1742 "following ships to be able to take off?" ),
1748 capused =
player.p->ship->points;
1749 for (
int i = 0; i <
array_size( pships ); i++ ) {
1763 _(
"The following ships in your fleet are "
1764 "not space worthy, are you sure you want "
1765 "to take off without them?" ),
1774 char message[STRMAX_SHORT];
1798 a = RNGF() * 2. * M_PI;
1802 player_rmFlag( PLAYER_LANDACK );
1803 pilot_rmFlag(
player.p, PILOT_LANDING );
1808 vec2_pset( &
player.p->solid.vel, 0., 0. );
1809 player.p->solid.dir = RNGF() * 2. * M_PI;
1822 h =
player.p->nav_hyperspace;
1824 player.p->nav_hyperspace = h;
1830 _(
"Failed to save game! You should exit and check the log to see "
1831 "what happened and then file a bug report!" ) );
1836 int stu = (int)( NT_PERIOD_SECONDS *
player.p->stats.land_delay );
1867 for (
int i = 0; i <
array_size( plts ); i++ ) {
1869 if ( pilot_isFlag( p, PILOT_DELETE ) )
1879 if ( !pilot_isWithPlayer( p ) )
1886 p->ptimer = p->landing_delay;
1887 pilot_setFlag( p, PILOT_TAKEOFF );
1901 char buf[STRMAX_SHORT];
1903 snprintf( buf,
sizeof( buf ),
"Player took off from '%s'", spb->
name );
1904 NTracingMessage( buf, l );
1914 if ( !PHYSFS_exists( RESCUE_PATH ) )
1926 if ( buf == NULL ) {
1927 WARN( _(
"File '%s' not found!" ), RESCUE_PATH );
1930 if ( nlua_dobufenv(
rescue_env, buf, bufsize, RESCUE_PATH ) != 0 ) {
1931 WARN( _(
"Error loading file: %s\n"
1933 "Most likely Lua file has improper syntax, please check" ),
1934 RESCUE_PATH, lua_tostring(
naevL, -1 ) );
1944 WARN( _(
"Rescue: 'Ys' : '%s'" ),
"rescue", lua_tostring(
naevL, -1 ) );
1945 lua_pop(
naevL, 1 );
2004 commodity_exchange_cleanup();
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
#define array_create_size(basic_type, capacity)
Creates a new dynamic array of ‘basic_type’ with an initial capacity.
#define array_erase(ptr_array, first, last)
Erases elements in interval [first, last).
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
#define array_push_back(ptr_array, element)
Adds a new element at the end of the array.
void cam_setTargetPilot(unsigned int follow, int soft_over)
Sets the target to follow.
void cam_vel(double vx, double vy)
Sets the camera velocity.
void credits2str(char *str, credits_t credits, int decimals)
Converts credits to a usable string for displaying.
void tonnes2str(char *str, int tonnes)
Converts tonnes to a usable string for displaying.
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.
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_setSystem(void)
Player just changed their system.
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_takeoff_nosave
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.
void misn_patchMission(const Mission *misn)
Patches a mission into the mission computer.
#define VISITED_EQUIPMENT
static unsigned int * land_windows
static void bar_update(unsigned int wid, const char *str)
Updates the missions in the spaceport bar.
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.
static int misn_cmp(const void *p1, const void *p2)
Used to sort available mission computer missions.
#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.
static int * mission_computer_filter
void land_errDialogueBuild(const char *fmt,...)
Generates error dialogues used by several landing tabs.
static void misn_computerOptionsClose(unsigned int wid, const char *name)
Closes the mission computer window.
static int news_load(void)
Loads the news.
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_genWindows(int load)
Recreates the land windows.
void land_updateMainTab(void)
Adds the "Buy Local Map" button if needed and updates info.
static unsigned int land_visited
static int * misn_filter(const Mission *misn)
Hides missions we don't want to look at.
static void bar_open(unsigned int wid)
Opens the spaceport bar window.
static void misn_genList(unsigned int wid)
Generates the mission list.
static void misn_computerOptions(unsigned int wid, const char *str)
Do the popdown options.
void land_errClear(void)
Clear error dialogues.
int land_canSave(void)
Whether or not the player can save.
static glTexture * mission_portrait
static void misn_popdown(unsigned int wid, const char *str)
Opens the small pop-down menu.
static void land_setupTabs(void)
Sets up the tabs for the window.
void misn_regen(void)
Regenerates the mission list.
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.
int land_errDisplay(void)
Displays an error if applicable.
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 nlua_env rescue_env
void outfits_regenList(unsigned int wid, const char *str)
Regenerates the outfit list.
int outfit_canBuy(const Outfit *outfit, int wid)
Checks to see if the player can buy the outfit.
void outfits_cleanup(void)
Cleans up outfit globals.
void outfits_open(unsigned int wid, const Outfit **outfits, int blackmarket)
Opens the outfit exchange center window.
void outfits_update(unsigned int wid, const char *str)
Updates the outfits in the outfit window.
void shipyard_open(unsigned int wid)
Opens the shipyard window.
void shipyard_cleanup(void)
Cleans up shipyard data.
void shipyard_update(unsigned int wid, const char *str)
Updates the ships in the shipyard window.
void commodity_exchange_open(unsigned int wid)
Opens the local market window.
void commodity_update(unsigned int wid, const char *str)
Updates the commodity window.
int mission_accept(Mission *mission)
Small wrapper for misn_run.
void mission_cleanup(Mission *misn)
Cleans up a mission.
Mission * missions_genList(int faction, const Spob *pnt, const StarSystem *sys, MissionAvailability loc)
Generates a mission list. This runs create() so won't work with all missions.
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.
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, 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 pilots_clean(int persist)
Cleans up the pilot stack - leaves the player.
void pilot_setAccel(Pilot *p, double accel)
Sets the pilot's accel.
void pilot_setTurn(Pilot *p, double turn)
Sets the pilot's turn.
Pilot *const * pilot_getAll(void)
Gets the pilot stack.
void pilot_heatReset(Pilot *p)
Resets a pilot's heat.
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.
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_toggleDeploy(PlayerShip_t *ps, int deploy)
Toggles a player ship as deployed.
int pfleet_cargoMissionFree(void)
Gets the free mission 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 * 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.
const char * space_populationStr(const Spob *spb)
Gets the population in an approximated string. Note this function changes the string value each call,...
void space_clearComputerMarkers(void)
Clears all the system computer markers.
MissionComputerSort sortby
Represents an active mission.
A ship outfit, depends radically on the type.
The representation of an in-game pilot.
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
Abstraction for rendering sprite sheets.