24 #if defined (_WIN32) && !defined (__CYGWIN__) && !defined (__MINGW32__)
59 #if defined (_WIN32) && !defined (__CYGWIN__)
65 #endif //tells VCC not to generate min/max macros
75 #include <sys/types.h>
99 weapfiltervec.push_back(
"upgrades/Weapon" );
100 weapfiltervec.push_back(
"SubUnits" );
101 weapfiltervec.push_back(
"upgrades/Ammunition" );
117 std::string::size_type where = cargo.
GetDescription().find(
"<" );
118 if (where != string::npos) {
120 where = category.find(
">" );
121 return category.substr( 0, where );
260 "Hire starship mechanics to examine and assess any wear and tear on your craft. They will replace any damaged components on your vessel with the standard components of the vessel you initially purchased. Further upgrades above and beyond the original will not be replaced free of charge. The total assessment and repair cost applies if any components are damaged or need servicing (fuel, wear and tear on jump drive, etc...). If such components are damaged you may save money by repairing them on your own. Your vessel will also be refuelled.";
270 ModeInfo(
string t =
"",
string b =
"",
string c =
"",
string g =
"" ) :
278 ModeInfo(
"Cargo Dealer ",
"Cargo",
"CargoMode",
"CargoGroup" ),
279 ModeInfo(
"Ship Upgrades ",
"Upgrades",
"UpgradeMode",
"UpgradeGroup" ),
280 ModeInfo(
"New Ships ",
"Ships",
"ShipDealerMode",
"ShipDealerGroup" ),
281 ModeInfo(
"Missions BBS ",
"Missions",
"MissionsMode",
"MissionsGroup" ),
282 ModeInfo(
"GNN News ",
"News",
"NewsMode",
"NewsGroup" ),
283 ModeInfo(
"Info/Stats ",
"Info",
"InfoMode",
"InfoGroup" ),
284 ModeInfo(
"Load / Save ",
"LoadSave",
"LoadSaveMode",
"LoadSaveGroup" ),
285 ModeInfo(
"Network ",
"Network",
"NetworkMode",
"NetworkGroup" )
352 return (a<b) ? a :
b;
357 return (a>b) ? a :
b;
365 bool wordStart =
true;
366 for (std::string::const_iterator
i = input.begin();
i != input.end();
i++) {
371 }
else if (wordStart) {
373 result += toupper( *
i );
386 return .5*originalValue;
389 extern float RepairPrice(
float operational,
float price );
397 static float SellPrice(
float operational,
float price )
407 extern bool isWeapon( std::string name );
411 #define PRETTY_ADD( str, val, digits ) \
416 prettyPrintFloat( conversionBuffer, val, 0, digits ); \
417 text += conversionBuffer; \
421 #define PRETTY_ADDN( str, val, digits ) \
424 prettyPrintFloat( conversionBuffer, val, 0, digits ); \
425 text += conversionBuffer; \
429 #define PRETTY_ADDU( str, val, digits, unit ) \
434 prettyPrintFloat( conversionBuffer, val, 0, digits ); \
435 text += conversionBuffer; \
444 m_displayModes( modes )
447 , m_currentDisplay( NULL_DISPLAY )
448 , m_selectedList( NULL )
449 , m_playingMuzak( false )
473 static bool use_faction_background =
475 static float faction_color_darkness =
477 if (use_faction_background) {
483 return GFXColor( stuff[0]*faction_color_darkness, stuff[1]*faction_color_darkness, stuff[2]*faction_color_darkness );
485 if (
id ==
"CargoGroup")
486 return GFXColor( 0, 0, faction_color_darkness );
487 else if (
id ==
"NewsGroup")
488 return GFXColor( faction_color_darkness, 0, faction_color_darkness );
489 else if (
id ==
"UpgradeGroup")
490 return GFXColor( 0, faction_color_darkness, 0 );
491 else if (
id ==
"InfoGroup")
492 return GFXColor( 0, faction_color_darkness, faction_color_darkness );
493 else if (
id ==
"MissionsGroup")
494 return GFXColor( faction_color_darkness, 0, 0 );
495 else if (
id ==
"ShipDealerGroup")
496 return GFXColor( faction_color_darkness, faction_color_darkness, 0 );
497 else if (
id ==
"LoadSaveGroup")
498 return GFXColor( 0, faction_color_darkness, faction_color_darkness );
499 else if (
id ==
"NetworkGroup")
500 return GFXColor( 0, faction_color_darkness, faction_color_darkness );
518 baseTitle->
setId(
"BaseInfoTitle" );
525 playerTitle->
setRect(
Rect( -.96, .69, 1.9, .07 ) );
529 playerTitle->
setId(
"PlayerInfoTitle" );
578 mode->
setId(
"ModeButton" );
584 cargoGroup->
setId(
"CargoGroup" );
591 sellLabel->
setText(
"Seller" );
612 totalPrice->
setId(
"TotalPrice" );
617 maxForPlayer->
setRect(
Rect( -.14, .49, .28, .07 ) );
622 maxForPlayer->
setId(
"MaxQuantity" );
623 cargoGroup->
addChild( maxForPlayer );
627 sellerScroller->
setRect(
Rect( -.20, -.4, .05, .95 ) );
645 sellpick->
setId(
"BaseCargo" );
649 cargoGroup->
addChild( sellerScroller );
653 invScroller->
setRect(
Rect( .91, -.4, .05, .95 ) );
671 ipick->
setId(
"PlayerCargo" );
675 cargoGroup->
addChild( invScroller );
689 buy->
setId(
"CommitAll" );
704 buy10->
setId(
"Commit10" );
719 buy1->
setId(
"Commit" );
724 descScroller->
setRect(
Rect( .91, -.95, .05, .5 ) );
734 picture->
setRect(
Rect( -.96, -.45, .46*.75, -.47 ) );
736 picture->
setId(
"DescriptionImage" );
744 ms->
setId(
"Description" );
748 cargoGroup->
addChild( descScroller );
754 upgradeGroup->
setId(
"UpgradeGroup" );
761 sellLabel->
setText(
"Available Upgrades" );
766 upgradeGroup->
addChild( sellLabel );
772 inv->
setText(
"Improvements To Sell" );
777 sellerScroller->
setRect(
Rect( -.20, -.4, .05, .95 ) );
795 sellpick->
setId(
"BaseUpgrades" );
799 upgradeGroup->
addChild( sellerScroller );
803 invScroller->
setRect(
Rect( .91, -.4, .05, .95 ) );
821 ipick->
setId(
"PlayerUpgrades" );
825 upgradeGroup->
addChild( invScroller );
839 buy->
setId(
"Commit" );
854 fix->
setId(
"CommitFix" );
859 descScroller->
setRect(
Rect( .91, -.95, .05, .5 ) );
869 picture->
setRect(
Rect( -.96, -.45, .46*.75, -.47 ) );
871 picture->
setId(
"DescriptionImage" );
880 ms->
setId(
"Description" );
884 upgradeGroup->
addChild( descScroller );
890 newsGroup->
setId(
"NewsGroup" );
914 pick->
setId(
"NewsPicker" );
918 newsGroup->
addChild( pickScroller );
922 descScroller->
setRect(
Rect( .91, -.95, .05, .90 ) );
938 ms->
setId(
"Description" );
942 newsGroup->
addChild( descScroller );
946 loadSaveGroup->
setId(
"LoadSaveGroup" );
951 pickScroller->
setRect(
Rect( -.20, -.7, .05, 1.4 ) );
969 pick->
setId(
"LoadSavePicker" );
973 loadSaveGroup->
addChild( pickScroller );
977 descScroller->
setRect(
Rect( .91, -.7, .05, 1.4 ) );
993 ms->
setId(
"Description" );
997 loadSaveGroup->
addChild( descScroller );
1001 inputTextScroller->
setRect(
Rect( .61, -0.95, .05, .2 ) );
1010 inputText->
setRect(
Rect( -.6, -.95, 1.21, .2 ) );
1017 inputText->
setId(
"InputText" );
1019 loadSaveGroup->
addChild( inputText );
1021 loadSaveGroup->
addChild( inputTextScroller );
1036 buy10->
setId(
"Commit10" );
1052 accept->
setId(
"Commit" );
1068 quit->
setId(
"CommitAll" );
1084 net->
setId(
"CommitAll" );
1100 newgame->
setId(
"NewGame" );
1103 loadSaveGroup->
addChild( newgame );
1107 networkGroup->
setId(
"NetworkGroup" );
1110 netJoinGroup->
setId(
"NetworkJoinGroup" );
1111 networkGroup->
addChild( netJoinGroup );
1113 netStatGroup->
setId(
"NetworkStatGroup" );
1115 networkGroup->
addChild( netStatGroup );
1125 std::string serverip;
1126 unsigned short serverport;
1131 mplayTitle->
setText(
"Independent Server IP Address:" );
1135 netStatGroup->
addChild( mplayTitle );
1139 serverInputText->
setRect(
Rect( -.6, .5, 1.2, .1 ) );
1143 if (serverip ==
"localhost" || serverip ==
"127.0.0.1") {
1144 serverInputText->
setText(
"Locally Hosted Game" );
1146 }
else if (serverip.substr( 0, 3 ) ==
"10." || serverip.substr( 0, 8 ) ==
"192.168."
1147 || serverip.substr( 0, 8 ) ==
"169.254." || serverip.find(
'.' ) == std::string::npos) {
1148 serverInputText->
setText(
"LAN: "+serverip );
1151 serverInputText->
setText( serverip );
1154 netStatGroup->
addChild( serverInputText );
1158 mplayTitle->
setText(
"Server Port: (default 6777)" );
1162 netStatGroup->
addChild( mplayTitle );
1165 portInputText->
setRect(
Rect( -.6, .3, .4, .1 ) );
1172 sprintf( portstr,
"%d", (
int) (serverport) );
1173 portInputText->
setText( portstr );
1175 netStatGroup->
addChild( portInputText );
1179 mplayTitle->
setText(
"Account Server:" );
1183 netStatGroup->
addChild( mplayTitle );
1186 acctserverInput->
setRect(
Rect( -.6, .1, 1.2, .1 ) );
1192 std::string acctserver;
1194 if (useacctserver) {
1195 acctserver =
vs_config->
getVariable(
"network",
"account_server_url",
"http://vegastrike.sourceforge.net/" );
1196 std::string::size_type s1, s3,
q;
1197 s1 = acctserver.find(
'/' );
1198 if (s1 != std::string::npos) {
1199 if (s1+1 < acctserver.length() && acctserver[s1+1] ==
'/') {
1200 s3 = acctserver.find(
'/', s1+3 );
1201 if (s3 != std::string::npos) {
1203 q = acctserver.find(
'?', s3 );
1204 if (q != std::string::npos)
1205 mod =
"; "+acctserver.substr( q+1 );
1206 acctserver = acctserver.substr( s1+2, s3-s1-2 )+mod;
1212 acctserver =
"(Private Game)";
1214 acctserverInput->
setText( acctserver );
1215 netStatGroup->
addChild( acctserverInput );
1219 mplayTitle->
setText(
"Callsign:" );
1223 netStatGroup->
addChild( mplayTitle );
1226 usernameInput->
setRect(
Rect( -.6, -.1, .6, .1 ) );
1232 netStatGroup->
addChild( usernameInput );
1236 mplayTitle->
setText(
"Serial Number:" );
1240 netStatGroup->
addChild( mplayTitle );
1243 currentSerial->
setRect(
Rect( .1, -.1, .6, .1 ) );
1250 sprintf( serial,
"%d", (
int) nc.
serial );
1251 currentSerial->
setText( serial );
1253 netStatGroup->
addChild( currentSerial );
1257 mplayTitle->
setText(
"Current Ship:" );
1261 netStatGroup->
addChild( mplayTitle );
1264 currentFighter->
setRect(
Rect( -.6, -.3, .6, .1 ) );
1274 currentFighter->
setText(
"(Currently Destroyed)" );
1276 netStatGroup->
addChild( currentFighter );
1280 mplayTitle->
setText(
"Faction:" );
1284 netStatGroup->
addChild( mplayTitle );
1287 currentFaction->
setRect(
Rect( .1, -.3, .6, .1 ) );
1298 currentFaction->
setText(
"(Currently Destroyed)" );
1300 netStatGroup->
addChild( currentFaction );
1303 saveNetGame->
setRect(
Rect( -.7, -.65, .4, .13 ) );
1309 saveNetGame->
setCommand(
"NetworkSaveGame" );
1310 saveNetGame->
setLabel(
"Save Progress" );
1311 netStatGroup->
addChild( saveNetGame );
1321 reloadNet->
setLabel(
"Die and Reload" );
1322 netStatGroup->
addChild( reloadNet );
1325 hideNetStatus->
setRect(
Rect( -.2, -.65, .4, .13 ) );
1331 hideNetStatus->
setCommand(
"HideNetworkStatus" );
1332 hideNetStatus->
setLabel(
"Join Another Server" );
1333 netStatGroup->
addChild( hideNetStatus );
1347 loadsave->
setId(
"CommitAll" );
1349 loadsave->
setLabel(
"Single Player" );
1353 networkGroup->
addChild( loadsave );
1367 quit->
setId(
"CommitAll" );
1376 missionsGroup->
setId(
"MissionsGroup" );
1382 pickScroller->
setRect(
Rect( -.20, -.8, .05, 1.45 ) );
1400 pick->
setId(
"Missions" );
1404 missionsGroup->
addChild( pickScroller );
1408 descScroller->
setRect(
Rect( .91, -.8, .05, 1.45 ) );
1424 ms->
setId(
"Description" );
1428 missionsGroup->
addChild( descScroller );
1442 accept->
setId(
"Commit" );
1448 shipDealerGroup->
setId(
"ShipDealerGroup" );
1454 pickScroller->
setRect(
Rect( -.20, -.8, .05, 1.45 ) );
1472 pick->
setId(
"Ships" );
1476 shipDealerGroup->
addChild( pickScroller );
1480 descScroller->
setRect(
Rect( .91, -.5, .05, 1.15 ) );
1490 picture->
setRect(
Rect( -.10, -.51, .48*.75, -.48 ) );
1492 picture->
setId(
"DescriptionImage" );
1500 ms->
setId(
"Description" );
1504 shipDealerGroup->
addChild( descScroller );
1505 shipDealerGroup->
addChild( picture );
1518 buy->
setId(
"Commit" );
1531 sell->
setId(
"Commit10" );
1537 infoGroup->
setId(
"InfoGroup" );
1543 playerInfo->
setRect(
Rect( -.40, .52, .27, .09 ) );
1544 playerInfo->
setLabel(
"Player Info" );
1558 shipStats->
setRect(
Rect( -.05, .52, .27, .09 ) );
1559 shipStats->
setLabel(
"Ship Stats" );
1571 descScroller->
setRect(
Rect( .91, -.95, .05, 1.4 ) );
1587 ms->
setId(
"Description" );
1591 infoGroup->
addChild( descScroller );
1620 assert( originalButton != NULL );
1623 Rect rect = originalButton->
rect();
1628 newButton->
setLabel( modeInfo[mode].button );
1629 newButton->
setCommand( modeInfo[mode].command );
1763 string temp = ( (
Planet*) baseUnit )->getHumanReadablePlanetType()+
" Planet";
1766 baseName = baseUnit->
name;
1770 static bool includebasename =
1772 if (includebasename) {
1773 baseTitle += baseName;
1777 if ( !baseFaction.empty() )
1778 baseTitle +=
" ["+baseFaction+
']';
1782 assert( baseTitleDisplay != NULL );
1783 baseTitleDisplay->
setText( baseTitle );
1786 char playerTitle[256];
1787 playerTitle[0] =
'\0';
1789 static bool showStardate =
1799 sprintf( playerTitle,
"Stardate: %s Credits: %.2f", stardate, playerCredits );
1801 sprintf( playerTitle,
"Credits: %.2f", playerCredits );
1808 sprintf( playerTitle,
"Stardate: %s Credits: %.2f Active missions: %d", stardate, playerCredits, count );
1810 sprintf( playerTitle,
"Credits: %.2f Active missions: %d", playerCredits, count );
1822 const float volumeLeft = emptyVolume
1826 sprintf( playerTitle,
"Stardate: %s Credits: %.2f Space left: %.6g of %.6g cubic meters", stardate, playerCredits, volumeLeft, emptyVolume );
1828 sprintf( playerTitle,
"Credits: %.2f Space left: %.6g of %.6g cubic meters", playerCredits, volumeLeft, emptyVolume );
1836 assert( playerTitleDisplay != NULL );
1837 playerTitleDisplay->
setText( playerTitle );
1845 if (!cells)
return false;
1850 if (category.size() > 0) {
1852 string::size_type categoryStart = 0;
1853 if (skipFirstCategory) {
1858 if (categoryStart != string::npos) categoryStart++;
1862 const string::size_type categoryEnd = category.find(
CATEGORY_SEP, categoryStart );
1863 const string currentCategory = category.substr( categoryStart, categoryEnd-categoryStart );
1866 if ( !cell || !cell->
children() ) {
1873 categoryCell = cell;
1878 if (categoryEnd == string::npos)
1880 categoryStart = categoryEnd+1;
1884 assert( cells != NULL );
1889 int count = cells->
count();
1899 for (; i < count; i++)
1902 if (i == count) i--;
1903 cell = cells->
cellAt( i );
1904 assert( cell != NULL );
1930 if (commit10Button != NULL) commit10Button->
setHidden(
true );
1932 if (commitAllButton != NULL) commitAllButton->
setHidden(
true );
1934 if (commitFixButton != NULL) commitFixButton->
setHidden(
true );
1937 if (totalPrice != NULL) totalPrice->
setText(
"" );
1939 if (maxForPlayer != NULL) maxForPlayer->
setText(
"" );
1948 assert( commitButton != NULL );
1955 assert( commit10Button != NULL );
1957 commit10Button->
setLabel(
"Buy 10" );
1962 assert( commitAllButton != NULL );
1964 commitAllButton->
setLabel(
"Buy" );
1965 commitAllButton->
setCommand(
"BuyAllCargo" );
1970 const double totalPrice = item.
price*maxQuantity;
1971 char tempString[2048];
1972 sprintf( tempString,
"Total: #b#%.2f#-b", totalPrice );
1974 assert( totalDisplay != NULL );
1975 totalDisplay->
setText( tempString );
1979 assert( maxForPlayer != NULL );
1980 if (maxQuantity >= item.
quantity) {
1984 char maxString[2048];
1985 sprintf( maxString,
"Max: #b#%d#-b", maxQuantity );
1986 maxForPlayer->
setText( maxString );
1993 assert( commitButton != NULL );
2000 assert( commit10Button != NULL );
2007 assert( commitAllButton != NULL );
2010 commitAllButton->
setCommand(
"SellAllCargo" );
2014 char tempString[2048];
2015 sprintf( tempString,
"Total: #b#%.2f#-b", totalPrice );
2017 assert( totalDisplay != NULL );
2018 totalDisplay->
setText( tempString );
2022 assert( maxForPlayer != NULL );
2030 bool damaged_mode =
false;
2034 assert( commitButton != NULL );
2040 assert( commitButton != NULL );
2042 commitFixButton->
setLabel(
"Fix" );
2047 assert( commitButton != NULL );
2049 bool CanDoSell =
true;
2051 unsigned int numc = player->
numCargo();
2054 for (
unsigned int i = 0;
i < numc; ++
i) {
2058 if (po > .02 && po < .98) {
2059 static bool must_fix_first =
2072 damaged_mode =
true;
2074 commitButton->
setLabel(
"Fix1st" );
2079 bool unhidden =
true;
2086 assert( commitFixButton != NULL );
2087 if (commitFixButton) {
2089 commitFixButton->
setLabel(
"Fix" );
2096 if (unhidden && commitFixButton)
2099 return damaged_mode;
2109 assert( commitButton != NULL );
2111 std::string descriptiontexture;
2112 assert( desc != NULL );
2134 assert( cell != NULL );
2136 bool damaged_mode =
false;
2155 if (item.
GetCategory().find(
"My_Fleet" ) != string::npos) {
2158 assert( commit10Button != NULL );
2160 commit10Button->
setLabel(
"Sell" );
2171 if (item.
GetCategory().find(
"Active_Missions" ) != string::npos) {
2173 static bool allow_abort_mission =
2175 if (allow_abort_mission ==
false)
2178 commitButton->
setLabel(
"Accept" );
2188 char conversionBuffer[128];
2192 char tempString[2048];
2202 if ( ( string::npos != temp.find(
'@' ) ) && (
"" != descriptiontexture) )
2203 temp =
"@"+descriptiontexture+
"@"+temp;
2206 if (item.
GetCategory().find(
"My_Fleet" ) != string::npos) {
2209 sprintf( tempString,
"#b#Transport cost: %.2f#-b#n1.5#", item.
price );
2211 sprintf( tempString,
"Price: #b#%.2f#-b#n#", baseUnit->
PriceCargo( item.
content ) );
2212 descString += tempString;
2213 sprintf( tempString,
"Cargo volume: %.2f cubic meters; Mass: %.2f metric tons#n1.5#", item.
volume, item.
mass );
2215 descString += tempString;
2226 sprintf( tempString,
"Price: #b#%.2f#-b#n1.5#",
basicRepairPrice()*multiplier );
2228 sprintf( tempString,
"Price: #b#%.2f#-b#n1.5#", baseUnit->
PriceCargo( item.
content ) );
2230 descString += tempString;
2235 if (item.
GetCategory().find(
"My_Fleet" ) == string::npos) {
2246 if (item.
GetCategory().find(
"My_Fleet" ) != string::npos) {
2249 sprintf( tempString,
"#b#Transport cost: %.2f#-b#n1.5#", item.
price );
2252 sprintf( tempString,
"Price: #b#%s#-b#n#", text.c_str() );
2253 static bool printvolume =
2256 descString += tempString;
2257 sprintf( tempString,
"Vessel volume: %.2f cubic meters; Mass: %.2f metric tons#n1.5#", item.
volume, item.
mass );
2260 descString += tempString;
2266 if ( ( string::npos != temp.find(
'@' ) ) && (
"" != descriptiontexture) )
2267 temp =
"@"+descriptiontexture+
"@"+item.
description;
2271 sprintf( tempString,
"Destroy evidence of mission cargo. Credit received: 0.00." );
2273 sprintf( tempString,
"Value: #b#%.2f#-b, purchased for %.2f#n#",
2275 descString += tempString;
2276 sprintf( tempString,
"Cargo volume: %.2f cubic meters; Mass: %.2f metric tons#n1.5#", item.
volume, item.
mass );
2277 descString += tempString;
2287 if (percent_working < 1) {
2289 sprintf( tempString,
"Damaged and Used value: #b#%.2f#-b, purchased for %.2f#n1.5#",
2291 descString += tempString;
2293 sprintf( tempString,
"Percent Working: #b#%.2f#-b, Repair Cost: %.2f#n1.5#",
2295 descString += tempString;
2297 sprintf( tempString,
"Used value: #b#%.2f#-b, purchased for %.2f#n1.5#",
2299 descString += tempString;
2303 "#c1:0:0#Warning: #b#Because pieces of your ship are damaged, you will not be able to sell this item until you fix those damaged items in this column in order to allow the mechanics to remove this item.#-c#-b#n1.5#";
2316 descString += tailString;
2319 string::size_type pic;
2321 if ( ( pic = descString.find(
"@" ) ) != string::npos ) {
2322 std::string texture = descString.substr( pic+1 );
2323 descString = descString.substr( 0, pic );
2324 string::size_type picend = texture.find(
"@" );
2325 if (picend != string::npos) {
2326 descString += texture.substr( picend+1 );
2327 texture = texture.substr( 0, picend );
2332 if (descimage && descriptiontexture ==
"")
2338 pic = descString.find(
"<" );
2339 if (pic != string::npos) {
2340 std::string tmp = descString.substr( pic+1 );
2341 descString = descString.substr( 0, pic );
2342 if ( ( pic = tmp.find(
">" ) ) != string::npos )
2343 descString += tmp.substr( pic+1 );
2352 assert( control != NULL );
2382 std::string prohibited_upgrades =
2384 playerUnit->
faction ),
"Prohibited_Upgrades" );
2385 while ( prohibited_upgrades.length() ) {
2386 std::string::size_type where = prohibited_upgrades.find(
" " );
2387 if (where == string::npos) where = prohibited_upgrades.find(
";" );
2388 std::string prohibited_upgrade = prohibited_upgrades;
2389 if (where != string::npos) {
2390 prohibited_upgrade = prohibited_upgrades.substr( 0, where );
2391 prohibited_upgrades = prohibited_upgrades.substr( where+1 );
2392 }
else {prohibited_upgrades =
""; } where = prohibited_upgrade.find(
":" );
2393 std::string content = prohibited_upgrade.substr( 0, where );
2395 if (where != string::npos) {
2396 std::string tmp = prohibited_upgrade.substr( where+1 );
2397 quantity = atoi( tmp.c_str() );
2399 if ( item.
content == content || ( 0 ==
string( item.
category ).find( content ) ) ) {
2400 if (quantity == 0) {
2407 if (numUpgrades->
quantity >= quantity) {
2412 unsigned int limit = playerUnit->
numCargo();
2414 for (i = 0; i < limit; ++i) {
2415 numUpgrades = &( playerUnit->
GetCargo( i ) );
2416 if ( numUpgrades && ( 0 ==
string( numUpgrades->
category ).find( content ) ) )
2417 totalquant += numUpgrades->
quantity;
2419 if (totalquant >= quantity) {
2437 if (!playerUnit)
return false;
2439 if (!cockpit)
return false;
2441 Cargo item = originalItem;
2444 bool havemoney =
true;
2445 bool havespace =
true;
2452 if (havemoney && havespace) {
2479 if (item.
price*quantity <= cockpit->credits)
2521 const string &origCategory,
2522 bool skipFirstCategory )
2524 string category = origCategory;
2525 if (skipFirstCategory) {
2527 const string::size_type sepLoc = category.find(
CATEGORY_SEP );
2528 if (sepLoc == string::npos)
2530 category.erase( 0, category.size() );
2533 category = origCategory.substr( sepLoc+1 );
2535 if (category.size() == 0)
2539 const string::size_type loc = category.find(
CATEGORY_SEP );
2540 const string currentCategory = category.substr( 0, loc );
2541 if (cells.
count() > 0 && cells.
cellAt( cells.
count()-1 )->
id() == currentCategory) {
2550 if (loc == string::npos) {
2556 if (!childCellList) {
2561 const string newCategory = category.substr( loc+1 );
2572 bool skipFirstCategory )
2582 string currentCategory =
"--ILLEGAL CATEGORY--";
2587 if (icategory != currentCategory) {
2590 *static_cast< SimplePickerCells* > ( picker.
cells() ), icategory, skipFirstCategory );
2591 currentCategory = icategory;
2598 string originalName = itemName;
2629 (1.0*percent_working)+( 1.0*(1.0-percent_working) ),
2630 (1.0*percent_working)+( 0.0*(1.0-percent_working) ),
2631 (0.0*percent_working)+( 0.0*(1.0-percent_working) ),
2632 (1.0*percent_working)+( 1.0*(1.0-percent_working) )
2634 if (percent_working == 1.0) final_color = base_color;
2637 final_color = base_color;
2658 static bool requireportforlaunch =
2660 static bool portallowsupgrades =
2663 vector< string >donttakethis;
2664 donttakethis.push_back(
"missions" );
2667 donttakethis.push_back(
"upgrades" );
2670 donttakethis.push_back(
"starships" );
2672 if (!starship_purchase) {
2673 donttakethis.push_back(
"starships" );
2674 donttakethis.push_back(
"starship" );
2678 assert( basePicker != NULL );
2684 assert( inventoryPicker != NULL );
2703 if (aless != string::npos && agreater != string::npos)
2705 if (bless != string::npos && bgreater != string::npos)
2707 if (acategory == bcategory)
2709 return acategory < bcategory;
2715 const vector< string > &filtervec,
2716 const vector< string > &invfiltervec,
2720 vector< CargoColor > *items = &tlist.
masterList;
2722 bool filter = filtervec.empty();
2723 bool invfilter =
true;
2725 for (vecindex = 0; !filter && ( vecindex < filtervec.size() ); vecindex++)
2728 for (vecindex = 0; invfilter && ( vecindex < invfiltervec.size() ); vecindex++)
2731 if (filter && invfilter) {
2737 items->push_back( col );
2747 Cargo *result = NULL;
2809 std::list< std::list< std::string > >list1save, list2save;
2840 if ( !(playerUnit && baseUnit) )
2844 int quantity = (requestedQuantity <= 0 ? item->
quantity : requestedQuantity);
2879 if ( !(playerUnit && baseUnit) )
2883 Cargo itemCopy = *item;
2885 const int quantity = (requestedQuantity <= 0 ? item->
quantity : requestedQuantity);
2887 vector< Cargo >::iterator mycargo = std::find( playerUnit->
pImage->
cargo.begin(),
2933 assert( control != NULL );
2938 assert( desc != NULL );
2959 assert( control != NULL );
2965 assert( desc != NULL );
2971 if (inputbox != NULL)
2981 assert( picker != NULL );
2985 static const bool newsFromCargolist =
2987 if (newsFromCargolist &&
Network == NULL) {
2990 vector< std::string >who;
2991 who.push_back(
"news" );
3000 for (
int i = len-1;
i >= 0;
i--)
3008 assert( desc != NULL );
3015 #if defined (__APPLE__)
3016 static int nodirs(
struct dirent *entry )
3018 static int nodirs(
const struct dirent * entry )
3021 #if defined (_WIN32) || defined(__HAIKU__)
3025 if (
stat( tmp.c_str(), &s ) < 0)
3026 return string( entry->d_name ) !=
"." && string( entry->d_name ) !=
"..";
3027 if ( (s.st_mode&S_IFDIR) == 0 &&
string( entry->d_name ) !=
"." &&
string( entry->d_name ) !=
".." )
3030 if (entry->d_type != DT_DIR &&
string( entry->d_name ) !=
"." &&
string( entry->d_name ) !=
"..")
3038 const struct dirent *d1 = *(
const struct dirent**) v1;
3039 const struct dirent *d2 = *(
const struct dirent**) v2;
3042 if (
stat( tmp.c_str(), &s1 ) )
3045 if (
stat( tmp.c_str(), &s2 ) )
3047 return s1.st_mtime-s2.st_mtime;
3050 #if (defined (__FREEBSD__)) || (defined (_WIN32) && !defined (__CYGWIN__ ) ) || (defined (__GLIBC_MINOR__) && __GLIBC_MINOR__ >= 10) || defined(__HAIKU__)
3051 typedef int (*
scancompare)(
const struct dirent **v1,
const struct dirent **v2 );
3060 assert( picker != NULL );
3066 struct dirent **dirlist;
3074 assert( desc != NULL );
3099 if (playerNum < 0) {
3111 for (
size_t current = 0; current < stringCount; current++) {
3115 for (
unsigned int check = current+1; check < stringCount; ++check) {
3117 if (check == current)
3126 for (
size_t i = 0;
i < stringCount;
i++) {
3131 if (finalScript[0] ==
'#')
3135 const string::size_type lastCategorySep = originalName.rfind(
CATEGORY_SEP );
3136 if (lastCategorySep != string::npos) {
3138 c.
cargo.
content = originalName.substr( lastCategorySep+1 );
3139 c.
cargo.
category = originalName.substr( 0, lastCategorySep );
3182 assert( picker != NULL );
3194 if ( !(playerUnit && baseUnit) )
return true;
3202 if (item->
GetCategory().find(
"Active_Missions" ) != string::npos) {
3203 unsigned int whichmission = atoi( item->
GetContent().c_str() );
3226 string qualifiedName;
3228 qualifiedName = item->
content;
3232 for (
size_t i = 0;
i < stringCount;
i++)
3244 if ( finalScript.empty() ) {
3249 finalScript, false );
3286 std::vector< std::string >filtervec;
3287 filtervec.push_back(
"upgrades" );
3288 loadMasterList( baseUnit, filtervec, std::vector< std::string > (),
true, tlist );
3293 vector< CargoColor >::iterator iter;
3305 assert( basePicker != NULL );
3322 if ( !(playerUnit && baseUnit) )
3333 static const bool clearDowngrades =
3335 if (clearDowngrades) {
3338 if ( downgradeMap.find( tlist.
masterList[
i].cargo.content ) == downgradeMap.end() ) {
3345 vector< CargoColor >::iterator iter;
3348 std::vector< std::string >invplayerfiltervec =
weapfiltervec;
3349 std::vector< string >playerfiltervec;
3350 playerfiltervec.push_back(
"upgrades" );
3351 loadMasterList( playerUnit, playerfiltervec, invplayerfiltervec,
false, tlist );
3358 assert( basePicker != NULL );
3367 if ( !(playerUnit && baseUnit) )
return true;
3381 showAlert(
"You don't have enough credits to repair your ship." );
3385 showAlert(
"Your ship has no damage. No charge." );
3503 if ( m_parent.m_player.GetUnit() ) {
3516 Unit *playerUnit = m_parent.m_player.GetUnit();
3521 vector< string >mounts;
3523 mounts.push_back( (*unitIter)->name );
3524 showListQuestion(
"Select turret mount for your turret:", mounts,
this, GOT_TURRET_ID );
3530 Unit *playerUnit = m_parent.m_player.GetUnit();
3531 if (index < 0 || !playerUnit) {
3536 m_selectedMount =
index;
3537 if ( !( *m_newPart->viewSubUnits() ) ) {
3539 return checkTransaction();
3549 showAlert(
"Your ship does not support turrets." );
3564 m_selectedTurret =
index;
3565 return checkTransaction();
3572 if (
id == GOT_MOUNT_ID) {
3574 gotSelectedMount( result );
3575 }
else if (
id == GOT_TURRET_ID) {
3577 gotSelectedTurret( result );
3578 }
else if (
id == CONFIRM_ID) {
3582 concludeTransaction();
3592 Unit *playerUnit = m_parent.m_player.GetUnit();
3593 Unit *baseUnit = m_parent.m_base.GetUnit();
3594 if ( !( playerUnit && baseUnit && commonInit() ) ) {
3600 m_addMultMode =
GetModeFromName( m_selectedItem.GetContent().c_str() );
3601 unsigned int offset;
3602 Cargo *part = baseUnit->
GetCargo( m_selectedItem.content, offset );
3623 if (command ==
"Picker::NewSelection") {
3624 assert( control != NULL );
3627 if (cell && cell->
tag() == 0)
3639 if (m_newPart->GetNumMounts() <= 0) {
3641 gotSelectedMount( 0 );
3644 Unit *playerUnit = m_parent.m_player.GetUnit();
3651 dialog->
init(
"Select mount for your item:" );
3656 assert( picker != NULL );
3660 const bool selectable = playerUnit->
canUpgrade( m_newPart,
3675 (playerUnit->
mounts[
i].ammo == -1) ?
string(
"" ) : string( (
" ammo: "+
tostring( playerUnit->
mounts[
i].ammo ) ) );
3676 mountName += ammoexp;
3680 mountName =
tostring(
i+1 )+
" (Empty) "+temp.c_str();
3694 Unit *playerUnit = m_parent.m_player.GetUnit();
3700 if ( playerUnit->
canUpgrade( m_newPart, m_selectedMount, m_selectedTurret, m_addMultMode,
false, percent,
3703 concludeTransaction();
3706 showYesNoQuestion(
"The item cannot fit the frame of your starship. Do you want to buy it anyway?",
3715 Unit *playerUnit = m_parent.m_player.GetUnit();
3716 Unit *baseUnit = m_parent.m_base.GetUnit();
3717 if ( !(playerUnit && baseUnit) ) {
3725 && playerUnit->
canUpgrade( m_newPart, m_selectedMount, m_selectedTurret, m_addMultMode,
true, percent,
3727 const float price = m_part.price;
3734 playerUnit->
Upgrade( m_newPart, m_selectedMount, m_selectedTurret, m_addMultMode,
true, percent, m_theTemplate );
3735 static bool allow_special_with_weapons =
3737 if (!allow_special_with_weapons) {
3743 baseUnit->
GetCargo( m_part.content, index );
3748 if (m_newPart->mounts.size() == 0)
3750 else if (m_newPart->mounts[0].ammo <= 0)
3772 Unit *playerUnit = m_parent.m_player.GetUnit();
3773 if ( !( playerUnit && commonInit() ) ) {
3777 const string unitDir =
GetUnitDir( playerUnit->
name.get().c_str() );
3778 const string limiterName = unitDir+
".blank";
3805 std::string convertedCargoName;
3808 int end = cargoName.size();
3809 const string::size_type ammoOffset = cargoName.rfind(
"_ammo" );
3810 if (ammoOffset != std::string::npos)
3812 bool wordStart =
true;
3813 for (
int i = 0;
i < end;
i++) {
3814 const char c = cargoName[
i];
3818 }
else if (wordStart) {
3820 convertedCargoName += toupper( c );
3824 convertedCargoName +=
c;
3833 if (m_newPart->GetNumMounts() <= 0) {
3835 gotSelectedMount( 0 );
3838 Unit *playerUnit = m_parent.m_player.GetUnit();
3845 dialog->
init(
"Select mount for your item:" );
3850 assert( picker != NULL );
3852 int selectableCount = 0;
3855 bool selectable =
false;
3861 const std::string unitName = playerUnit->
mounts[
i].type->weapon_name;
3864 mountName =
tostring(
i+1 )+
" "+unitName.c_str();
3866 (playerUnit->
mounts[
i].ammo == -1) ?
string(
"" ) : string( (
" ammo: "+
tostring( playerUnit->
mounts[
i].ammo ) ) );
3867 mountName += ammoexp;
3870 if (partUnit->
mounts[0].type == playerUnit->
mounts[
i].type) {
3884 mountName =
tostring(
i+1 )+
" (Empty) "+temp.c_str();
3890 assert( selectableCount > 0 );
3891 if (selectableCount > 1) {
3897 gotSelectedMount( mount );
3904 Unit *playerUnit = m_parent.m_player.GetUnit();
3910 if ( playerUnit->
canDowngrade( m_newPart, m_selectedMount, m_selectedTurret, percent, m_downgradeLimiter ) ) {
3912 concludeTransaction();
3924 Unit *playerUnit = m_parent.m_player.GetUnit();
3925 Unit *baseUnit = m_parent.m_base.GetUnit();
3926 if ( !(playerUnit && baseUnit) ) {
3932 playerUnit->
canDowngrade( m_newPart, m_selectedMount, m_selectedTurret, percent, m_downgradeLimiter );
3933 const float price = m_part.price*
usedValue( percent );
3938 if ( playerUnit->
Downgrade( m_newPart, m_selectedMount, m_selectedTurret, percent, m_downgradeLimiter ) ) {
3940 m_part.quantity = 1;
3941 m_part.price = baseUnit->
PriceCargo( m_part.content );
3971 const int quantity = 1;
3994 const int quantity = 1;
3997 if (baseUnit && playerUnit) {
4018 if (baseUnit && playerUnit && item) {
4019 float *credits = NULL;
4054 bool needsJumpTransport = (locationSystemName != destinationSystemName);
4055 bool needsInsysTransport = (locationBaseName != destinationBaseName);
4057 static const float shipping_price_base =
4059 static const float shipping_price_insys =
4061 static const float shipping_price_perjump =
4064 cargo.
price = shipping_price_base;
4066 cargo.
category =
"starships/My_Fleet";
4068 if (needsJumpTransport) {
4069 vector< string >
jumps;
4072 destinationSystemName,
4075 locationBaseName.c_str(),
4076 destinationSystemName.c_str(),
4078 cargo.
price += shipping_price_perjump * (jumps.size() - 1);
4079 }
else if (needsInsysTransport) {
4081 locationBaseName.c_str(),
4082 destinationBaseName.c_str());
4083 cargo.
price += shipping_price_insys;
4106 size_t putpos = (swappingShipsIndex >= 0) ? swappingShipsIndex : cockpit->
GetNumUnits();
4110 if (swappingShipsIndex != -1) {
4117 }
else if (swappingShipsIndex != -1) {
4127 string newModifications;
4128 if (item.
GetCategory().find(
"My_Fleet" ) != string::npos)
4135 flightGroup, fgsNumber );
4142 string::size_type delim = sHudImage.find(
'|' );
4143 if (delim != string::npos) {
4144 sImage = sHudImage.substr( delim+1 );
4145 sHudImage = sHudImage.substr( 0, delim-sImage.length() );
4147 delim = sHudImage.rfind(
'.' );
4148 if (delim != string::npos)
4149 sHudImage = sHudImage.substr( delim+2 );
4150 texturedescription =
"../units/"+sHudImage+
"/"+sImage;
4156 if ( texturedescription !=
"" && ( string::npos == str.find(
'@' ) ) )
4157 str =
"@"+texturedescription+
"@"+str;
4180 const vector<float> &price;
4193 return price[
a] > price[
b];
4195 return price[
a] < price[
b];
4199 void trackPrice(
int whichplayer,
const Cargo &item,
float price,
const string &systemName,
const string &baseName,
4200 vector<string> &highest, vector<string> &lowest)
4202 static size_t toprank = (size_t)
4207 systemName.c_str(), baseName.c_str());
4213 string hilock = itemkey +
"?hi?loc";
4214 string lolock = itemkey +
"?lo?loc";
4215 string hipricek = itemkey +
"?hi?pcs";
4216 string lopricek = itemkey +
"?lo?pcs";
4220 string locname =
"#b#" + baseName +
"#-b# in the #b#" + systemName +
"#-b# system";
4223 bool resort =
false;
4226 const vector<string> &recordedHighestLocs =
getStringList(whichplayer, hilock);
4227 const vector<float> &recordedHighestPrices =
getSaveData(whichplayer, hipricek);
4228 vector<string>::const_iterator prev = std::find(
4229 recordedHighestLocs.begin(), recordedHighestLocs.end(),
4232 if (prev != recordedHighestLocs.end()) {
4233 size_t index = prev - recordedHighestLocs.begin();
4236 }
else if (recordedHighestPrices.size() < toprank || recordedHighestPrices.back() < price) {
4246 const vector<string> &locs =
getStringList(whichplayer, hilock);
4247 const vector<float> &prices =
getSaveData(whichplayer, hipricek);
4248 vector<size_t> indices;
4250 indices.resize(
mymin(prices.size(),locs.size()));
4251 {
for (
size_t i=0;
i<indices.size(); ++
i)
4254 std::sort(indices.begin(), indices.end(),
PriceSort(prices,
true));
4256 vector<string> newlocs;
4257 vector<float> newprices;
4259 newlocs.reserve(indices.size());
4260 newprices.reserve(indices.size());
4261 {
for (
size_t i=0;
i<indices.size() &&
i<toprank; ++
i) {
4262 newlocs.push_back(locs[indices[
i]]);
4263 newprices.push_back(prices[indices[i]]);
4273 bool resort =
false;
4276 const vector<string> &recordedLowestLocs =
getStringList(whichplayer, lolock);
4277 const vector<float> &recordedLowestPrices =
getSaveData(whichplayer, lopricek);
4278 vector<string>::const_iterator prev = std::find(
4279 recordedLowestLocs.begin(), recordedLowestLocs.end(),
4282 if (prev != recordedLowestLocs.end()) {
4283 size_t index = prev - recordedLowestLocs.begin();
4286 }
else if (recordedLowestPrices.size() < toprank || recordedLowestPrices.back() > price) {
4296 const vector<string> &locs =
getStringList(whichplayer, lolock);
4297 const vector<float> &prices =
getSaveData(whichplayer, lopricek);
4298 vector<size_t> indices;
4300 indices.resize(
mymin(prices.size(),locs.size()));
4301 {
for (
size_t i=0;
i<indices.size(); ++
i)
4304 std::sort(indices.begin(), indices.end(),
PriceSort(prices,
false));
4306 vector<string> newlocs;
4307 vector<float> newprices;
4309 newlocs.reserve(indices.size());
4310 newprices.reserve(indices.size());
4311 {
for (
size_t i=0;
i<indices.size() &&
i<toprank; ++
i) {
4312 newlocs.push_back(locs[indices[
i]]);
4313 newprices.push_back(prices[indices[i]]);
4325 const vector<string> &recordedHighestLocs =
getStringList(whichplayer, hilock);
4326 const vector<string> &recordedLowestLocs =
getStringList(whichplayer, lolock);
4327 const vector<float> &recordedHighestPrices =
getSaveData(whichplayer, hipricek);
4328 const vector<float> &recordedLowestPrices =
getSaveData(whichplayer, lopricek);
4330 string prefix =
" ";
4331 char conversionBuffer[128];
4335 {
for (
size_t i=0;
i < recordedHighestLocs.size(); ++
i) {
4340 {
for (
size_t i=0;
i < recordedHighestPrices.size(); ++
i) {
4345 {
for (
size_t i=0;
i < recordedLowestLocs.size(); ++
i) {
4350 {
for (
size_t i=0;
i < recordedLowestPrices.size(); ++
i) {
4358 highest.resize(recordedHighestPrices.size());
4359 {
for (
size_t i=0;
i < recordedHighestPrices.size(); ++
i) {
4360 string &text = highest[
i];
4362 text +=
" (at " + recordedHighestLocs[i] +
")";
4368 lowest.resize(recordedLowestPrices.size());
4369 {
for (
size_t i=0;
i < recordedLowestPrices.size(); ++
i) {
4370 string &text = lowest[
i];
4372 text +=
" (at " + recordedLowestLocs[i] +
")";
4381 static bool trackBestPrices =
4388 vector<string> highest, lowest;
4396 if (highest.size()) {
4397 desc +=
"#n##n##b#Highest prices seen#-b#:";
4398 for (vector<string>::const_iterator
i=highest.begin();
i!=highest.end(); ++
i)
4402 if (lowest.size()) {
4403 desc +=
"#n##n##b#Lowest prices seen#-b#:";
4404 for (vector<string>::const_iterator
i=lowest.begin();
i!=lowest.end(); ++
i)
4419 std::vector< std::string >filtervec;
4420 filtervec.push_back(
"starships" );
4432 for (vector< CargoColor >::iterator it = items->begin(); it != items->end(); it++)
4433 (*it).cargo.description =
"";
4436 assert( basePicker != NULL );
4446 unsigned int tempInt = 1;
4448 if (shipCargo == NULL)
4460 static const float shipping_price =
4462 xtra += shipping_price;
4465 static float shipSellback =
4486 if ( !(playerUnit && baseUnit && item && cockpit) )
4493 std::string content,
4495 bool force_base_inventory,
4498 unsigned int tempInt;
4500 if (shipCargo == NULL && force_base_inventory)
4502 Cargo myFleetShipCargo;
4503 int swappingShipsIndex = -1;
4506 shipCargo = &myFleetShipCargo;
4511 swappingShipsIndex = -1;
4528 if (flightGroup != NULL) {
4533 string newModifications;
4535 if (swappingShipsIndex != -1) {
4554 newPart->SetFaction( playerUnit->
faction );
4556 if (newPart->nummesh() > 0) {
4563 for (
int j = 0;
j < 2; ++
j) {
4564 for (
int i = playerUnit->
numCargo()-1;
i >= 0; --
i) {
4570 if ( newPart->CanAddCargo( c ) ) {
4571 newPart->AddCargo( c );
4587 playerUnit->
UnDock( baseUnit );
4592 newPart->ForceDock( baseUnit, 0 );
4596 static bool persistent_missions_across_ship_switch =
4599 if (persistent_missions_across_ship_switch)
4621 if ( !(playerUnit && baseUnit && item) )
4670 std::string result =
colorsToCommandString( spark[0]/1.5+1.0/3, spark[1]/1.5+1.0/3, spark[2]/1.5+1.0/3 );
4679 string text =
"#b#Factions:#-b#n1.7#";
4690 static string disallowedFactions =
vs_config->
getVariable(
"graphics",
"unprintable_factions",
"" );
4692 size_t fac_loc_before = 0, fac_loc = 0, fac_loc_after = 0;
4693 for (; i < numFactions; i++) {
4700 if (i < killList->
size() && i != upgrades && i != planets && i != neutral && i != privateer)
4701 totkills += (
int) (*killList)[i];
4704 fac_loc = disallowedFactions.find( factionname, fac_loc_after );
4705 while (fac_loc != string::npos) {
4706 fac_loc_before = fac_loc-1;
4707 if (fac_loc_before < 0)
4709 fac_loc_after = fac_loc+factionname.size();
4710 if ( (fac_loc == 0 || disallowedFactions[fac_loc_before] ==
' '
4711 || disallowedFactions[fac_loc_before] ==
'\t')
4712 && (disallowedFactions[fac_loc_after] ==
' ' || disallowedFactions[fac_loc_after] ==
'\t'
4713 || disallowedFactions[fac_loc_after] ==
'\0') )
4715 fac_loc = disallowedFactions.find( factionname, fac_loc_after );
4717 if (fac_loc != string::npos)
4721 if (relation < -1) relation = -1;
4722 if (relation > 1) relation = 1;
4723 const int percent = (
int) (relation*100.0);
4729 float normRelation = (relation+1)/2;
4735 if ( i < killList->
size() )
4743 assert( desc != NULL );
4767 while (temp >= 1.0f) {
4771 while (bufferPos < (bufferLen-4-digitsAfter) && before < digitsBefore) {
4772 buffer[bufferPos++] =
'0';
4776 for (
int p = before; bufferPos < (bufferLen-4-digitsAfter) && p > 0; p--) {
4778 float substractor = 1;
4779 for (
int i = 0;
i < p-1;
i++) {
4781 substractor *= 10.0;
4783 int digit = ( (
int) temp )%10;
4784 buffer[bufferPos++] =
'0'+digit;
4786 f = f-( (
float) digit*substractor );
4787 if ( (p != 1) && (p%3 == 1) ) buffer[bufferPos++] =
' ';
4790 buffer[bufferPos++] =
'0';
4792 if (digitsAfter == 0) {
4793 buffer[bufferPos] = 0;
4797 if (bufferPos < bufferLen)
4798 buffer[bufferPos++] =
'.';
4801 for (
int i = 0; bufferPos < (bufferLen-1) &&
i < digitsAfter;
i++) {
4803 buffer[bufferPos++] =
'0'+( ( (
int) temp )%10 );
4805 if (bufferPos < bufferLen)
4806 buffer[bufferPos] = 0;
4823 static float shield_maintenance_cost =
4825 static bool shields_require_power =
4827 static float shieldenergycap =
4830 float Wconv = warpenratio == 0.0 ? 0.0 : (1.0/warpenratio);
4831 char conversionBuffer[128];
4833 for (
int i = 0;
i < subunitlevel;
i++)
4836 static float kj_per_unit_damage =
4838 float VSDM = kj_per_unit_damage/1000.0;
4839 float RSconverter = 100;
4840 float totalWeaponEnergyUsage = 0;
4841 float totalWeaponDamage = 0;
4842 string MPLdesc =
"";
4843 string statcolor =
"#c.75:.9:1#";
4844 string substatcolor =
"#c.675:.925:.825#";
4845 string expstatcolor =
"#c.6:.7:.8#";
4846 string nametemp =
"";
4848 size_t nameindex = 0;
4849 int replacement_mode = -1;
4854 string nametemp =
"";
4861 if (nametemp ==
"") {
4862 const std::string &name = playerUnit->
name.get();
4863 for (nameindex = 0; ( nameindex < name.size() ) && name[nameindex] !=
'.'; ++nameindex)
4864 nametemp += name[nameindex];
4866 if ( nametemp.length() )
4867 nametemp[0] = toupper( nametemp[0] );
4869 text += statcolor+
"Selected Part: #-c"+nametemp;
4876 text +=
" cubic meter.#n##n##c0:1:.5#"+prefix+
"[DESCRIPTION]#n##-c";
4879 text +=
" cubic meters.#n##n##c0:1:.5#"+prefix+
"[DESCRIPTION]#n##-c";
4883 text +=
"#n##c0:1:.5#[STATS]#n##-c";
4886 const std::string &name = playerUnit->
name;
4887 for (nameindex = 0; ( nameindex < name.size() ) && name[nameindex] !=
'.'; nameindex++) {
4890 if ( nametemp.length() )
4891 nametemp[0] = toupper( nametemp[0] );
4892 for (nameindex = nameindex+1; nameindex < name.size(); nameindex++)
4893 model += name[nameindex];
4894 if (model ==
"blank")
4895 model =
"TEMPLATE--WARNING--BUG";
4896 else if (model ==
"")
4897 model =
"Military Issue (equipped)";
4898 else if (model ==
"rg")
4899 model =
"Regional Guard Issue (equipped)";
4900 else if (model ==
"milspec")
4901 model =
"Military Spec.";
4902 else if (model ==
"rgspec")
4903 model =
"Regional Guard Spec.";
4904 else if (model ==
"stock")
4906 else if (model ==
"begin")
4907 model =
"Stock(Refurbished)";
4909 model =
"Military Spec. Variant ("+model+
")";
4913 if ( !subunitlevel && (fullname || milname || blankname) ) {
4914 text +=
"#c0:1:.5#"+prefix+
"[NOTES]#n##n##-c";
4918 text += blankname->GetDescription();
4920 text += milname->GetDescription();
4923 text +=
"#n##c0:1:.5#"+prefix+
"[GENERAL INFORMATION]#n##-c";
4925 text +=
"#n#"+prefix+statcolor+
"Class: #-c"+nametemp+statcolor+
" Model: #-c"+
model;
4930 if ( mode && replacement_mode == 2 && playerUnit->
GetMass() != blankUnit->
GetMass() )
4931 PRETTY_ADDU( statcolor+
"Effective Mass reduced by: #-c", 100.0*( 1.0-playerUnit->
GetMass() ), 0,
"%" );
4932 if (!subunitlevel) {
4935 const char *dvol[2] = {
"Hold",
"Upgrade"};
4944 switch (replacement_mode)
4947 PRETTY_ADDU( statcolor+
"Changes "+dvol[index]+
" Volume to: #-c", vol[index], 0,
"cubic meters" );
4950 PRETTY_ADDU( statcolor+
"Adds #-c", vol[index], 0,
"cubic meters "+statcolor+
"to "+dvol[index]+
" Volume #-c" );
4953 PRETTY_ADDU( statcolor+
"Increases "+dvol[index]+
" Volume by #-c", 100.0*(vol[index]-1), 0,
"%" );
4956 text +=
"Oh dear, this wasn't an upgrade. Please debug code.";
4965 PRETTY_ADDU( statcolor+
"Fuel capacity: #-c", playerUnit->
FuelData(), 2,
"metric tons of Lithium-6" );
4967 switch (replacement_mode)
4972 PRETTY_ADDU( statcolor+
"Adds #-c", playerUnit->
FuelData(), 2,
"metric tons of Lithium-6 " );
4977 text +=
"Oh dear, this wasn't an upgrade. Please debug code.";
4984 text +=
"#n##n#"+prefix+
"#c0:1:.5#[FLIGHT CHARACTERISTICS]#n##-c";
4985 text +=
"#n#"+prefix+statcolor+
"Turning response: #-c";
4991 text += conversionBuffer;
4992 text +=
" radians/second^2#n#"+expstatcolor+
" (yaw, pitch, roll)#-c";
4994 switch (replacement_mode)
4997 PRETTY_ADDU( statcolor+
"#n#Installs maneuvering jets with turning response #-c",
5000 " radians/second^2#n#"+statcolor+
" (yaw, pitch, roll)#-c" );
5005 PRETTY_ADDU( statcolor+
"#n#Increases turning response by #-c",
5008 "%#n#"+statcolor+
" (yaw, pitch, roll)#-c" );
5011 text +=
"Oh dear, this wasn't an upgrade. Please debug code.";
5021 text +=
" radians/second^2";
5024 switch (replacement_mode)
5027 text +=
"#n#Replaces existing maneuvering system with one rated at: #-c#n#";
5031 text +=
" metric-ton*radians/second^2";
5034 text +=
"#n#Upgrades existing maneuvering system by the following amounts: #-c#n#";
5038 text +=
" metric-ton*radians/second^2";
5041 text +=
"#n#Increases performance of existing maneuvering system by the following percentages: #-c#n#";
5047 text +=
"Oh dear, this wasn't an upgrade. Please debug code.";
5052 if (!subunitlevel) {
5053 if ( !mode && (playerUnit->
GetMass() != 0) ) {
5059 PRETTY_ADDU( statcolor+
"Orthogonal acceleration: #-c",
5061 text += expstatcolor+
"#n# (vertical and lateral axes)#-c";
5064 PRETTY_ADDN( statcolor+
" Vertical acceleration #-c",
5066 text +=
" gravities";
5069 /( 9.8*playerUnit->
GetMass() ), 2,
"gravities" );
5070 text.append(
"#n##n##c0:1:.5#"+prefix+
"[GOVERNOR SETTINGS]#n##-c" );
5072 switch (replacement_mode)
5076 PRETTY_ADDU( statcolor+
"Provides forward thrust rated at: #-c",
5082 PRETTY_ADDU( statcolor+
"Provides aftward thrust rated at: #-c",
5088 PRETTY_ADDU( statcolor+
"Provides vertical thrust rated at: #-c",
5094 PRETTY_ADDU( statcolor+
"Provides lateral thrust rated at: #-c",
5100 PRETTY_ADDU( statcolor+
"Overdrive thrust rated at: #-c",
5108 PRETTY_ADDU( statcolor+
"Increases forward thrust rating by: #-c",
5114 PRETTY_ADDU( statcolor+
"Increases aftward thrust rating by: #-c",
5120 PRETTY_ADDU( statcolor+
"Increases vertical thrust rating by: #-c",
5126 PRETTY_ADDU( statcolor+
"Increases lateral thrust rating by: #-c",
5132 PRETTY_ADDU( statcolor+
"Increases overdrive thrust rating by: #-c",
5140 PRETTY_ADDU( statcolor+
"Increases forward thrust rating by: #-c",
5146 PRETTY_ADDU( statcolor+
"Increases aftward thrust rating by: #-c",
5152 PRETTY_ADDU( statcolor+
"Increases vertical thrust rating by: #-c",
5158 PRETTY_ADDU( statcolor+
"Increases lateral thrust rating by: #-c",
5167 text +=
"Oh dear, this wasn't an upgrade. Please debug code.";
5171 static float non_combat_mode_mult =
5176 PRETTY_ADDU( statcolor+
"Max non-combat speed: #-c", uc.
max_speed()*non_combat_mode_mult, 0,
"m/s" );
5178 switch (replacement_mode)
5183 PRETTY_ADDU( statcolor+
"Sets max non-combat speed governor to: #-c",
5184 uc.
max_speed()*non_combat_mode_mult, 0,
"m/s" );
5191 PRETTY_ADDU( statcolor+
"Increases max combat speed governor setting by: #-c", uc.
max_speed(), 0,
"m/s" );
5192 PRETTY_ADDU( statcolor+
"Increases max non-combat speed governor setting by: #-c",
5193 uc.
max_speed()*non_combat_mode_mult, 0,
"m/s" );
5196 PRETTY_ADDU( statcolor+
"Increases max overdrive combat speed governor setting by: #-c",
5201 PRETTY_ADDU( statcolor+
"Increases max combat speed governor settings by: #-c",
5203 PRETTY_ADDU( statcolor+
"Increases max non-combat speed governor settings by: #-c",
5207 PRETTY_ADDU( statcolor+
"Increases max overdrive combat speed governor settings by: #-c",
5211 text +=
"Oh dear, this wasn't an upgrade. Please debug code.";
5219 text +=
" radians/second "+expstatcolor+
"(yaw, pitch, roll)#-c";
5221 text += (
"#n#"+prefix+statcolor+
"Max turn rates:#-c");
5226 text +=
"#n##n##c0:1:.5#"+prefix+
"[TARGETTING SUBSYSTEM]#n##-c";
5229 switch (replacement_mode)
5232 text += (
"#n#"+prefix+
"Governor settings for maximum turn rates set to: ");
5236 text +=
" radians/second";
5239 text += (
"#n#"+prefix+
"Governor settings for maximum turn rates increased by: ");
5243 text +=
" radians/second";
5246 text += (
"#n#"+substatcolor+
"Increases governor settings for maximum turn rates by: #-c");
5253 text +=
"Oh dear, this wasn't an upgrade. Please debug code.";
5261 text += expstatcolor+
"#n# (planar angle: 2 pi means full space)#-c";
5263 text +=
"#n#"+prefix+statcolor+
"Tracking cone: #-cOMNIDIRECTIONAL";
5267 if (!subunitlevel) {
5269 text +=
"#n#"+prefix+statcolor+
"ITTS (Intelligent Target Tracking System) support: #-c";
5270 if (uc.
itts) text +=
"yes";
5273 text +=
"#n#"+prefix+statcolor+
"AFHH (Advanced Flag & Hostility Heuristics) support: #-c";
5276 afhh +=
"friendly/hostile ";
5283 text.append(
"#n##n##c0:1:.5#"+prefix+
"[ENERGY SUBSYSTEM]#n##-c" );
5285 switch (replacement_mode)
5292 text += statcolor+
" (planar angle: 2 pi means full space)#-c";
5294 text +=
"#n#"+prefix+statcolor+
"Tracking cone: #-cOMNIDIRECTIONAL";
5298 text +=
"#n#"+prefix+statcolor+
"ITTS (Intelligent Target Tracking System) support: #-c";
5299 if (uc.
itts) text +=
"yes";
5302 text +=
"#n#"+prefix+statcolor+
"AFHH (Advanced Flag & Hostility Heuristics) support: #-c";
5305 afhh +=
"friendly/hostile ";
5318 text +=
"Oh dear, this wasn't an upgrade. Please debug code.";
5326 if (shields_require_power)
5329 PRETTY_ADDU( statcolor+
"Weapon capacitor bank storage: #-c",
5330 ( (playerUnit->
MaxEnergyData()-maxshield)*RSconverter ), 0,
"MJ" );
5332 if (!subunitlevel) {
5333 PRETTY_ADDU( statcolor+
"Warp capacitor bank storage: #-c", playerUnit->
WarpCapData()*RSconverter*Wconv, 0,
"MJ" );
5335 text +=
"#n##n##c0:1:.5#"+prefix+
"[SPEC SUBSYSTEM]#n##-c";
5337 PRETTY_ADDU( statcolor+
"Active SPEC Energy Requirements: #-c",
5342 text +=
"#n##n##c0:1:.5#"+prefix+
"[JUMP SUBSYSTEM]#n##-c";
5343 if (uj.
drive == -2) {
5344 text +=
"#n##c1:.3:.3#No outsystem jump drive present#-c";
5346 PRETTY_ADDU( statcolor+
"Energy cost for jumpnode travel: #-c", uj.
energy*RSconverter*Wconv, 0,
"MJ" );
5350 PRETTY_ADDU( statcolor+
"Damage to outsystem jump drive: #-c", uj.
damage*VSDM, 0,
"MJ" );
5352 text +=
"#n##c1:.3:.3#"+prefix
5354 "WARNING: Warp capacitor banks under capacity for jump: upgrade warp capacitance#-c";
5359 switch (replacement_mode)
5363 PRETTY_ADDU( statcolor+
"Installs reactor with recharge rate: #-c",
5366 PRETTY_ADDU( statcolor+
"Installs main capacitor bank with storage capacity: #-c",
5369 PRETTY_ADDU( statcolor+
"Installs warp capacitor bank with storage capacity: #-c",
5374 "#n#Allows travel via Jump Points.#n#Consult your personal info screen for ship specific energy requirements. #-c";
5379 PRETTY_ADDU( statcolor+
"Increases recharge rate by #-c",
5383 (playerUnit->
MaxEnergyData()*RSconverter), 0,
"MJ of storage to main capacitor banks" );
5386 playerUnit->
GetWarpEnergy()*RSconverter*Wconv, 0,
"MJ of storage to warp capacitor bank" );
5390 PRETTY_ADDU( statcolor+
"Increases reactor recharge rate by #-c",
5393 PRETTY_ADDU( statcolor+
"Increases main capacitor bank storage by #-c",
5396 PRETTY_ADDU( statcolor+
"Increases warp capacitor bank storage by #-c",
5400 text +=
"Oh dear, this wasn't an upgrade. Please debug code.";
5405 text +=
"#n##n##c0:1:.5#"+prefix+
"[DURABILITY STATISTICS]#n##-c";
5406 text +=
"#n#"+prefix+statcolor+
"Armor damage resistance:#-c";
5409 switch (replacement_mode)
5412 text +=
"#n#"+prefix+statcolor+
"Replaces existing armor, if any.#n#Armor damage resistance:#-c";
5415 text +=
"#n#"+prefix+statcolor+
"Adds the following to armor damage resistance ratings:#-c";
5418 text +=
"#n#"+prefix+statcolor+
"Armor damage resistance increased by following percentages:#-c";
5421 text +=
"Oh dear, this wasn't an upgrade. Please debug code.";
5427 substatcolor+
" - Fore-starboard-high: #-c",
5428 (mode && replacement_mode
5431 (2 == replacement_mode) ?
"%" :
"MJ" );
5433 substatcolor+
" - Aft-starboard-high: #-c",
5434 (mode && replacement_mode
5437 (2 == replacement_mode) ?
"%" :
"MJ" );
5439 substatcolor+
" - Fore-port-high: #-c",
5440 (mode && replacement_mode
5443 (2 == replacement_mode) ?
"%" :
"MJ" );
5445 substatcolor+
" - Aft-port-high: #-c",
5446 (mode && replacement_mode
5449 (2 == replacement_mode) ?
"%" :
"MJ" );
5451 substatcolor+
" - Fore-starboard-low: #-c",
5452 (mode && replacement_mode
5455 (2 == replacement_mode) ?
"%" :
"MJ" );
5457 substatcolor+
" - Aft-starboard-low: #-c",
5458 (mode && replacement_mode
5461 (2 == replacement_mode) ?
"%" :
"MJ" );
5463 substatcolor+
" - Fore-port-low: #-c",
5464 (mode && replacement_mode
5467 (2 == replacement_mode) ?
"%" :
"MJ" );
5469 substatcolor+
" - Aft-port-low: #-c",
5470 (mode && replacement_mode
5473 (2 == replacement_mode) ?
"%" :
"MJ" );
5476 PRETTY_ADDU( statcolor+
"Sustainable Hull Damage: #-c",
5480 text +=
"% of normal";
5483 switch (replacement_mode)
5486 PRETTY_ADDU( statcolor+
"New Sustained Hull Damage Rating: #-c",
5490 PRETTY_ADDU( statcolor+
"Increases sustainable hull damage by #-c", playerUnit->
GetHull()
5494 PRETTY_ADDU( statcolor+
"Hull Strength increased by #-c", 100.0*(playerUnit->
GetHull()-1), 0,
"%" );
5497 text +=
"Oh dear, this wasn't an upgrade. Please debug code.";
5504 text +=
"#n#"+prefix+statcolor+
"Shield protection rating:#-c";
5506 text +=
"#n#"+prefix+statcolor+
"No shielding. #-c";
5512 switch (replacement_mode)
5515 text +=
"#n#"+prefix+statcolor+
"Installs shield with following protection ratings:#-c";
5518 text +=
"#n#"+prefix+statcolor+
"Adds following amounts to shield protection ratings:#-c";
5521 text +=
"#n#"+prefix+statcolor+
"Shield protection rating for each emitter increased by listed percentage:#-c";
5524 text +=
"Oh dear, this wasn't an upgrade. Please debug code.";
5535 substatcolor+
" - fore: #-c",
5536 (mode && replacement_mode == 2) ? ( 100.0
5540 (2 == replacement_mode) ?
"%" :
"MJ" );
5542 substatcolor+
" - aft: #-c",
5543 (mode && replacement_mode == 2) ? ( 100.0
5547 (2 == replacement_mode) ?
"%" :
"MJ" );
5553 substatcolor+
" - fore: #-c",
5554 (mode && replacement_mode == 2) ? ( 100.0
5558 (2 == replacement_mode) ?
"%" :
"MJ" );
5560 substatcolor+
" - aft: #-c",
5561 (mode && replacement_mode == 2) ? ( 100.0
5565 (2 == replacement_mode) ?
"%" :
"MJ" );
5567 substatcolor+
" - port: #-c",
5568 (mode && replacement_mode == 2) ? ( 100.0
5572 (2 == replacement_mode) ?
"%" :
"MJ" );
5574 substatcolor+
" - starboard: #-c",
5575 (mode && replacement_mode == 2) ? ( 100.0
5579 (2 == replacement_mode) ?
"%" :
"MJ" );
5585 statcolor+
" - Fore-starboard-high: #-c",
5586 (mode && replacement_mode
5590 (2 == replacement_mode) ?
"%" :
"MJ" );
5592 substatcolor+
" - Aft-starboard-high: #-c",
5593 (mode && replacement_mode
5597 (2 == replacement_mode) ?
"%" :
"MJ" );
5599 substatcolor+
" - Fore-port-high: #-c",
5600 (mode && replacement_mode
5604 (2 == replacement_mode) ?
"%" :
"MJ" );
5606 substatcolor+
" - Aft-port-high: #-c",
5607 (mode && replacement_mode
5611 (2 == replacement_mode) ?
"%" :
"MJ" );
5613 substatcolor+
" - Fore-starboard-low: #-c",
5614 (mode && replacement_mode
5618 (2 == replacement_mode) ?
"%" :
"MJ" );
5620 substatcolor+
" - Aft-starboard-low: #-c",
5621 (mode && replacement_mode
5625 (2 == replacement_mode) ?
"%" :
"MJ" );
5627 substatcolor+
" - Fore-port-low: #-c",
5628 (mode && replacement_mode
5632 (2 == replacement_mode) ?
"%" :
"MJ" );
5634 substatcolor+
" - Aft-port-low: #-c",
5635 (mode && replacement_mode
5639 (2 == replacement_mode) ?
"%" :
"MJ" );
5643 text +=
"#c1:.3:.3#Shield model unrecognized#-c";
5649 switch (replacement_mode)
5655 PRETTY_ADDU( statcolor+
"Increases shield protection recharge speed by #-c",
5661 PRETTY_ADDU( statcolor+
"Shield protection recharge speed increased by #-c",
5667 text +=
"Oh dear, this wasn't an upgrade. Please debug code.";
5674 PRETTY_ADDU( statcolor+
"Cloaking device available, energy usage: #-c",
5679 switch (replacement_mode)
5682 PRETTY_ADDU( statcolor+
"Installs a cloaking device.#n# Activated energy usage: #-c",
5688 text +=
"#n#Additive Cloaking...Seems like a bug to me.#n#";
5691 text +=
"#n#Multiplicative Cloaking...Seems like a bug to me.#n#";
5694 text +=
"Oh dear, this wasn't an upgrade. Please debug code.";
5699 bool anyweapons =
false;
5701 text +=
"#n##n##c0:1:.5#"+prefix+
"[ARMAMENT]#n##-c";
5702 text += prefix+
"MOUNTPOINT RATINGS:";
5717 text +=
"#n#"+prefix+
"MOUNTED:";
5727 text +=
"#c0:1:.3#]#-c ";
5730 +WeaponTypeStrings[wi->
type]+
" #-c";
5731 if (wi->
Damage < 0) {text +=
"#n#"+prefix+statcolor+
" Damage:#-c special"; }
else {
5753 PRETTY_ADDU( statcolor+
" Exit velocity: #-c", wi->
Speed, 0,
"meters/second" );
5755 PRETTY_ADD( statcolor+
" Range attenuation factor: #-c",
5761 PRETTY_ADD( statcolor+
" Rounds remaining: #-c", playerUnit->
mounts[
i].ammo, 0 );
5763 PRETTY_ADD( statcolor+
" Rockets remaining: #-c", playerUnit->
mounts[
i].ammo, 0 );
5772 text += statcolor+
" Missile Lock Type: #-c#c1:.3:.3#None.#-c Inertial Guidance Only";
5774 PRETTY_ADD( statcolor+
" Missiles remaining: #-c", playerUnit->
mounts[
i].ammo, 0 );
5779 totalWeaponDamage += wi->
Damage;
5782 PRETTY_ADD( statcolor+
" Range attenuation factor: #-c",
5796 text +=
"#n##c1:.3:.3#"+prefix+
" NO MOUNTED WEAPONS#n##-c";
5801 if (subunitlevel == 0 && mode == 0) {
5802 text +=
"#n##n##c0:1:.5#"+prefix+
"[KEY FIGURES]#n##-c";
5804 if (shields_require_power)
5806 PRETTY_ADDU( statcolor+
"Minimum time to reach full overthrust speed: #-c",
5809 float avail = (playerUnit->
MaxEnergyData()*RSconverter-maxshield*VSDM);
5811 (shields_require_power) ? (playerUnit->
shield.
recharge/shieldenergycap*shield_maintenance_cost
5814 PRETTY_ADDU( statcolor+
"Reactor nominal replenish time: #-c", nrt, 2,
"seconds" );
5818 if (playerUnit->
MaxEnergyData()-maxshield < low_power_mode) {
5819 text +=
"#n##c1:.3:.3#"+prefix
5821 "WARNING: Capacitor banks are overdrawn: downgrade shield, upgrade reactor or purchase reactor capacitance!#-c";
5824 text +=
"#n##c1:.3:.3#"+prefix
5826 "WARNING: Warp capacitor banks under capacity for jump: upgrade warp capacitance#-c";
5831 text +=
"#n##c1:1:.1#"+prefix+
"WARNING: reactor recharge rate is less than combined shield recharge rate.#n#";
5832 text +=
"Your shields won't be able to regenerate at their optimal speed!#-c";
5834 if (shields_require_power) {
5835 text +=
"#n#"+prefix+statcolor+
"Reactor recharge slowdown caused by shield maintenance: #-c";
5836 float maint_draw_percent = playerUnit->
shield.
recharge*VSDM*100.0/shieldenergycap*shield_maintenance_cost
5838 sprintf( conversionBuffer,
"%.2f", maint_draw_percent );
5839 text += conversionBuffer;
5841 if (maint_draw_percent > 60) {
5842 text +=
"#n##c1:1:.1#"+prefix
5844 "WARNING: Reactor power is heavily consumed by passive shield maintenance: consider downgrading shield or upgrading reactor.#-c";
5845 }
else if (maint_draw_percent > 95) {
5846 text +=
"#n##c1:.3:.3#"+prefix
5848 "SEVERE WARNING: Reactor power is overdrawn! Unsustainable power is being consumed by passive shield maintenance: downgrade shield or upgrade reactor immediately!#-c";
5852 totalWeaponEnergyUsage = totalWeaponEnergyUsage*RSconverter;
5853 PRETTY_ADDU( statcolor+
"Combined weapon energy usage: #-c", totalWeaponEnergyUsage, 0,
"MJ/s" );
5856 *shield_maintenance_cost*playerUnit->
shield.
number) : 0;
5857 if ( totalWeaponEnergyUsage < (playerUnit->
EnergyRechargeData()*RSconverter-maint_draw) ) {
5859 text +=
"#n##c0:1:.2#"+prefix+
"Your reactor produces more energy than your weapons can use!#-c";
5861 PRETTY_ADDU( statcolor+
"Reactor energy depletion time if weapons in continuous use: #-c",
5863 *RSconverter)/( totalWeaponEnergyUsage-( (playerUnit->
EnergyRechargeData()*RSconverter-maint_draw) ) ),
5867 PRETTY_ADDU( statcolor+
"Combined (non-missile) weapon damage: #-c", totalWeaponDamage*VSDM, 0,
"MJ/s" );
5874 if (i == 1) text +=
"#n##n##c0:1:.5#"+prefix+
"[SUB UNITS]#-c";
5875 PRETTY_ADD(
"#n#"+prefix+
"#c0:1:.2#[#-csub unit ", i, 0 );
5876 text +=
"#c0:1:.2#]#-c#n#";
5896 string::size_type pic;
5897 if ( ( pic = text.find(
"@" ) ) != string::npos ) {
5898 std::string texture = text.substr( pic+1 );
5899 text = text.substr( 0, pic );
5900 string::size_type picend = texture.find(
"@" );
5901 if (picend != string::npos)
5902 text += texture.substr( picend+1 );
5904 text.append(
"#n##n##c0:1:.5#[RAW DIAGNOSTIC OUTPUT]#n##-c" );
5905 bool inQuote =
false;
5906 bool newLine =
false;
5909 for (string::const_iterator
i = rawText.begin();
i != rawText.end();
i++) {
5913 text.append(
"#n#" );
5915 text.append(
"#c0:1:.5#" );
5921 text.append(
"#c1:.3:.3#" );
5924 text.append(
"#-c" );
5932 text.append(
"#-c" );
5942 text.append(
"#n# #c1:.1:.1#SUPPRESSED #n##-c" );
5946 assert( desc != NULL );
5952 namespace CockpitKeys
5978 text->
setId(
"Information" );
6016 if (command ==
"Save") {
6017 m_parent->actionConfirmedSaveGame();
6019 }
else if (command ==
"Load") {
6020 m_parent->actionConfirmedLoadGame();
6021 }
else if (command ==
"Quit") {
6022 m_parent->actionConfirmedQuitGame();
6049 if (player && player->
name ==
"return_to_cockpit") {
6050 showAlert(
"Return to a base to save." );
6055 std::string tmp = desc->
text();
6060 "Could not create the saved game because it contains invalid characters or you do not have permissions or free space." );
6063 if (tmp.length() > 0) {
6065 if (player && cockpit) {
6069 showAlert(
"Game saved successfully." );
6071 showAlert(
"Oops - unexpected error (player or cockpit is null)" );
6074 showAlert(
"You Must Type In a Name To Save." );
6078 showAlert(
"Oops - unexpected error (desc control not found!)" );
6091 if (tmp.length() <= 0)
6103 if (
string(
"New_Game" ) != tmp) {
6106 "Do you want to overwrite your old saved game?" );
6110 showAlert(
"You may not save to the name New_Game." );
6116 showAlert(
"You Must Type In a Name To Save." );
6125 std::string tmp = desc->
text();
6126 if (tmp.length() > 0) {
6128 if (player && cockpit) {
6138 showAlert(
"Oops - unexpected error (player or cockpit is null)" );
6141 showAlert(
"You Must Type In a Name To Load...." );
6144 showAlert(
"Oops - unexpected error (desc control not found!)" );
6161 std::string tmp = desc->
text();
6162 if (tmp.length() > 0) {
6168 "Are you sure that you want to load this game?" );
6176 showAlert(
"You Must Type In a Name To Load...." );