This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RepeatJourney = true | |
local journeys = {} | |
Event.Register('onGameStart', function () | |
journeys = {} | |
end) | |
Event.Register('onShipDocked', function (ship, station) | |
local journey = journeys[ship] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// build with: g++ -std=c++98 -Wall -ocheck test.cpp | |
#include <iostream> | |
#include <string> | |
#include <sstream> | |
int parse_int(const char *x) { | |
std::istringstream ss(x); | |
int y; | |
ss >> y; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Classes, namespaces and methods are LikeThis. | |
Non-public member variables are m_likeThis. | |
Local variables and local constants are likeThis. | |
Public member variables are likeThis, but you should think about making them non-public and providing an accessor instead. | |
Accessors are called GetFooBar() and SetFooBar(), but you should think about whether you really want to provide SetFooBar() or if you want to provide nicer verb methods (e.g., Missile provides Arm() and Disarm(), rather than SetArmed()). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Gets a list of stations in nearby systems that match some criteria. | |
-- | |
-- Example: | |
-- | |
-- local orbital_ports = Game.system:GetNearbyStationPaths( | |
-- 30, nil, function (station) return station.type == 'STARPORT_ORBITAL' end, true) | |
-- | |
-- for i = 1, #orbital_ports do | |
-- local path = orbital_ports[i] | |
-- print(path, ' -- ', path:GetSystemBody().name, ' in system ', path:GetStarSystem().name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if 0 /* example use: */ | |
#define EMIT_FIXUP_DEFINITIONS 1 | |
/* if EMIT_FIXUP_DEFINITIONS is 0 or undefined then | |
* only the struct declaration will be emitted | |
* typically you want to only emit fixup function | |
* definitions in a single translation unit. | |
*/ | |
#define DECLARE_STRUCT_NAME BITMAPFILEHEADER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Written for | |
* | |
* A Quick Coding Contest: Convert String to Integer Without Overflow | |
* | |
* http://blog.regehr.org/archives/909 | |
* | |
* This has not yet been run through clang's integer behaviour sanitizer, | |
* because I don't have a recent enough clang build. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function numbered_keys(step, context, position) | |
local k = position | |
local f = function(s, i) | |
local v | |
k,v = step(s, k) | |
if k ~= nil then | |
return (i+1), v | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function MinMaxCommodity(sys) | |
sys = sys or Game.system | |
if sys:isa('SystemPath') then | |
sys = sys:GetStarSystem() | |
end | |
local alt = sys:GetCommodityBasePriceAlterations() | |
local minPrice = math.huge | |
local maxPrice = -math.huge | |
local minCargo, maxCargo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cmath> | |
#include <type_traits> | |
static_assert(std::is_same<float, decltype(std::sin(3.1f))>::value, | |
"std::sin not overloaded for float"); | |
static_assert(std::is_same<double, decltype(std::sin(3.1))>::value, | |
"std::sin not overloaded for double"); | |
static_assert(std::is_same<long double, decltype(std::sin(3.1l))>::value, | |
"std::sin not overloaded for long double"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Translate:Add({ | |
English = { | |
cheats = 'Cheats!', | |
} | |
}) | |
local ui = Engine.ui | |
local t = Translate:GetTranslator() | |
local cheatMission = function (loaded) |