Skip to content

Commit

Permalink
resolved merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
mschweiger committed Aug 30, 2021
2 parents e96d45f + 8a43708 commit d660393
Show file tree
Hide file tree
Showing 15 changed files with 171 additions and 127 deletions.
22 changes: 10 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ jobs:
name: Build with CMake
env:
CMAKE_BUILD_PARALLEL_LEVEL: 2
VCToolsInstallDir: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.29.30133\\"
strategy:
fail-fast: false
matrix:
architecture: [x64, Win32]
architecture: [x64, x86]

runs-on: windows-latest

Expand All @@ -40,20 +41,17 @@ jobs:
path: ${{ github.workspace }}/out/build/Extern/irrKlang/${{ matrix.architecture }}
key: irrKlang-${{ matrix.architecture }}

- name: Configure
run: 'cmake -A ${{ matrix.architecture }} -G "Visual Studio 16 2019" -S ../.. -DORBITER_MAKE_DOC=OFF -DIRRKLANG_DIR:STRING="irrKlang_DOWNLOAD" -DHTML_HELP_LIBRARY="C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x86\Htmlhelp.Lib"'
working-directory: ${{ github.workspace }}/out/build

- name: Build
run: 'cmake --build . --config Release -- "-maxCpuCount:2" /p:CL_MPcount=2'
working-directory: ${{ github.workspace }}/out/build

- name: Test
run: 'ctest --build-config Release'
- name: Build & Test
shell: cmd
working-directory: ${{ github.workspace }}/out/build
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.architecture }}
cmake -G Ninja ../.. -DORBITER_MAKE_DOC=OFF -DIRRKLANG_DIR:STRING="irrKlang_DOWNLOAD"
cmake --build . --config RelWithDebInfo
ctest --config RelWithDebInfo .
- name: Install
run: 'cmake --install . --prefix "${{ github.workspace }}\out\install"'
run: cmake --install . --prefix ${{ github.workspace }}/out/install
working-directory: ${{ github.workspace }}/out/build

- name: Pack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ END_HYPERDESC
BEGIN_ENVIRONMENT
System Sol
Date MJD 51982.5292925579
Script Tests/unit_test
Script Tests/VesselApiTest
END_ENVIRONMENT

BEGIN_FOCUS
Expand Down
77 changes: 23 additions & 54 deletions Script/Tests/unit_test.lua → Script/Tests/VesselApiTest.lua
Original file line number Diff line number Diff line change
@@ -1,57 +1,26 @@
note = oapi.create_annotation()
note:set_pos (0.2,0.1,0.8,0.9);
note:set_size(0.5)
note:set_colour ({r=0.7,g=0.8,b=1})

maxline = 20
nline = 0
first_line = 0
linebuf = {}

function disp_output()
buf = ""
for i=0,nline-1 do
idx = first_line + i
if idx >= maxline then
idx = idx - maxline
end
buf = buf .. linebuf[idx] .. "\n"
end
note:set_text(buf)
end

function add_line(line)
idx = first_line + nline
if idx >= maxline then
idx = idx - maxline
end
linebuf[idx] = line
if nline < maxline then
nline = nline + 1
else
first_line = first_line + 1
if first_line >= maxline then
first_line = first_line - maxline
end
end
disp_output()
oapi.dbg_out(line)
oapi.write_log(line)
end

function assert(cond)
if cond == false then
add_line("Test failed!")
error("Test failed!")
add_line(" - FAILED!")
error("Assertion failed\n"..debug.traceback())
oapi.exit(1)
end
end

function pass()
idx = first_line + nline - 1
if idx >= maxline then
idx = idx - maxline
end
linebuf[idx] = linebuf[idx] .. " - passed!"
disp_output()
proc.wait_sysdt(0.5)
add_line(" - passed")
end

add_line("=== Lua script unit tests ===")
Expand Down Expand Up @@ -266,21 +235,21 @@ cs = v:get_crosssections()
assert(cs.x == 53 and cs.y == 186.9 and cs.z == 25.9)
pass()

add_line("Test: vessel:get_gravitygradientdamping()")
v = vessel.get_interface("GL-01")
assert(v:get_gravitygradientdamping() == 20)
v = vessel.get_interface("ISS")
assert(v:get_gravitygradientdamping() == 0)
pass()

add_line("Test: vessel:set_gravitygradientdamping(number)")
v = vessel.get_interface("GL-01")
pggd = v:get_gravitygradientdamping()
v:set_gravitygradientdamping(100)
assert(v:get_gravitygradientdamping() == 100)
v:set_gravitygradientdamping(pggd)
assert(v:get_gravitygradientdamping() == 20)
pass()
-- add_line("Test: vessel:get_gravitygradientdamping()")
-- v = vessel.get_interface("GL-01")
-- assert(v:get_gravitygradientdamping() == 20)
-- v = vessel.get_interface("ISS")
-- assert(v:get_gravitygradientdamping() == 0)
-- pass()
--
-- add_line("Test: vessel:set_gravitygradientdamping(number)")
-- v = vessel.get_interface("GL-01")
-- pggd = v:get_gravitygradientdamping()
-- v:set_gravitygradientdamping(100)
-- assert(v:get_gravitygradientdamping() == 100)
-- v:set_gravitygradientdamping(pggd)
-- assert(v:get_gravitygradientdamping() == 20)
-- pass()

add_line("Test: vessel:get_touchdownpoints()")
v = vessel.get_interface("GL-01")
Expand Down Expand Up @@ -388,5 +357,5 @@ arr[6] = v:get_touchdownpoints(5) -- NEW, " " "
v:set_touchdownpoints(arr)
pass()

note:set_colour ({r=0,g=0.9,b=0})
add_line("=== All tests passed ===")
add_line("=== All tests passed ===")
oapi.exit(0)
30 changes: 26 additions & 4 deletions Src/Module/LuaScript/LuaInterpreter/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,17 @@ int Interpreter::RunChunk (const char *chunk, int n)
luaL_loadbuffer (L, chunk, n, "line");
res = lua_pcall (L, 0, 0, 0);
if (res) {
if (is_term) {
// term_strout ("Execution error.");
term_strout(lua_tostring(L, -1), true);
auto error = lua_tostring(L, -1);
if (error) { // can be nullptr
if (is_term) {
// term_strout ("Execution error.");
term_strout(error, true);
}
else {
oapiWriteLogError(error);
}
return res;
}
return res;
}
// check for leftover background jobs
lua_getfield (L, LUA_GLOBALSINDEX, "_nbranch");
Expand Down Expand Up @@ -680,7 +686,9 @@ void Interpreter::LoadAPI ()
{"del_annotation", oapiDelAnnotation},
{"get_annotations", oapiGetAnnotations},
{"dbg_out", oapiDbgOut},
{"write_log", oapiWriteLog},
{"open_help", oapiOpenHelp},
{"exit", oapiExit},
{"open_inputbox", oapiOpenInputBox},
{"receive_input", oapiReceiveInput},
{"del_vessel", oapi_del_vessel},
Expand Down Expand Up @@ -1919,6 +1927,20 @@ int Interpreter::oapiDbgOut (lua_State *L)
return 0;
}

int Interpreter::oapiWriteLog(lua_State* L)
{
const char* str = lua_tostringex(L, 1);
::oapiWriteLog(const_cast<char*>(str));
return 0;
}

int Interpreter::oapiExit(lua_State* L)
{
auto code = lua_tointeger(L, 1);
exit(code);
return 0; // compiler warnings
}

static bool bInputClosed;
static char cInput[1024];

Expand Down
2 changes: 2 additions & 0 deletions Src/Module/LuaScript/LuaInterpreter/Interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ class INTERPRETERLIB Interpreter {
static int oapiDelAnnotation (lua_State *L);
static int oapiGetAnnotations (lua_State *L);
static int oapiDbgOut (lua_State *L);
static int oapiWriteLog(lua_State* L);
static int oapiExit(lua_State *L);
static int oapiOpenHelp (lua_State *L);
static int oapiOpenInputBox (lua_State *L);
static int oapiReceiveInput (lua_State *L);
Expand Down
2 changes: 1 addition & 1 deletion Src/Orbiter/FlightRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ bool Vessel::FRecorder_Read (const char *scname)

void Vessel::FRecorder_Play ()
{
dASSERT (s1);
dASSERT (s1, "State vector not available");
StateVectors *sv = s1;

if (fstatus == FLIGHTSTATUS_FREEFLIGHT) {
Expand Down
5 changes: 5 additions & 0 deletions Src/Orbiter/OrbiterAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2198,6 +2198,11 @@ DLLEXPORT void oapiWriteLog (char *line)
LOGOUT (line);
}

DLLEXPORT void oapiExitOrbiter(int code)
{
exit(code);
}

DLLEXPORT void oapiWriteLogV (const char *format, ...)
{
#ifdef GENERATE_LOG
Expand Down
10 changes: 8 additions & 2 deletions Src/Orbiter/cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,16 @@ bool CommandLine::ParseNextOption(PSTR& cmdLine, bool& groupKey, Option& option)
{
bool isLongKey;
bool isQuotedVal;
bool isQuotedParam = false; // Is full parameter quoted? "--scenario=my_scenario"

// Parse next key
if (!groupKey) {
while (*cmdLine == ' ' || *cmdLine == '\t') cmdLine++; // skip whitespace
if (*cmdLine == '"')
{
cmdLine++;
isQuotedParam = true;
}
if (*cmdLine == '\0')
return false; // nothing left to parse
if (*cmdLine != '-')
Expand Down Expand Up @@ -96,15 +102,15 @@ bool CommandLine::ParseNextOption(PSTR& cmdLine, bool& groupKey, Option& option)
return false; // for long keys, '=' is mandatory before values
if (isQuotedVal = (*cmdLine == '\"'))
cmdLine++; // skip starting quotes
char* termValChar = (isQuotedVal ? "\"" : " \t"); // for quoted values, only accept quotes as terminator
char* termValChar = (isQuotedParam || isQuotedVal ? "\"" : " \t"); // for quoted values, only accept quotes as terminator
std::set<char> termV(termValChar, termValChar + strlen(termValChar) + 1); // include '\0' in set
PSTR endVal = cmdLine;
while (termV.find(*endVal) == termV.end())
endVal++;
size_t valLen = endVal - cmdLine;
option.strVal = std::string(cmdLine, valLen);
cmdLine = endVal; // advance command line pointer
if (isQuotedVal && *cmdLine == '\"')
if ((isQuotedParam || isQuotedVal) && *cmdLine == '\"')
cmdLine++; // skip trailing quotes

return true;
Expand Down
5 changes: 3 additions & 2 deletions Src/Orbiter/console_ng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,13 @@ DWORD WINAPI InputProc(LPVOID context)
SetConsoleTextAttribute(hStdI, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
hMutex = CreateMutex(NULL, FALSE, NULL);
for (;;) {
ReadConsole(hStdI, cbuf, 1024, &count, NULL);
if (!ReadConsole(hStdI, cbuf, 1024, &count, NULL))
break; // Console not available, exiting
WriteConsole(hStdO, "> ", 2, &c, NULL);

WaitForSingleObject(hMutex, 1000);
cConsoleCmd[0] = 'x';
memcpy(cConsoleCmd + 1, cbuf, count);
strncpy(cConsoleCmd + 1, cbuf, count);
cConsoleCmd[count - 1] = '\0'; // eliminates CR
ReleaseMutex(hMutex);
}
Expand Down
2 changes: 1 addition & 1 deletion Src/Plugin/TransX/transxstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ bool transxstate::doupdate(Sketchpad *sketchpad, int tw, int th,unsigned int cur
cfunction->doupdate(sketchpad,tw,th,currview);
}
char buffer[20];
int length=sprintf(buffer,"Stage %i:%i",curfunction,baselist.size());
int length=sprintf(buffer,"Stage %i:%z",curfunction,baselist.size());
sketchpad->Text(tw/2,0,buffer,length);
length=sprintf(buffer,"Vars Stage %i",curvarfunction);
sketchpad->Text(tw/2,4*linespacing,buffer,length);
Expand Down
10 changes: 6 additions & 4 deletions Src/Vessel/DeltaGlider/Script/aap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ aap.maxdsc = -20
dg_aap = {file='Html/Script/Stockvessels/DG/aap.chm'}

function setvessel (_v)
v = _v
class = _v:get_classname()
if (class ~= 'DeltaGlider') and (class ~= 'DG-S') then
term.out('Warning: Autopilot is designed for use with DeltaGlider.')
if _v then
v = _v
class = _v:get_classname()
if (class ~= 'DeltaGlider') and (class ~= 'DG-S') then
term.out('Warning: Autopilot is designed for use with DeltaGlider.')
end
end
end

Expand Down
Loading

0 comments on commit d660393

Please sign in to comment.