From 0ed77a852c33ab9056ef0625665fa8b34d5b5f27 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Mar 2019 21:46:19 -1100 Subject: [PATCH 01/64] Slow down clock --- src/cc/tetris.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 254c9b135..40278d493 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -867,7 +867,7 @@ int main(int argc, char **argv) display_piece(hold, tg->stored); display_score(score, tg); doupdate(); - sleep_milli(10); + sleep_milli(50); switch (getch()) { case KEY_LEFT: From 5e44e6d33ec4ef262f360ce9bcd883640e2ab5f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Mar 2019 21:47:51 -1100 Subject: [PATCH 02/64] Faster and slower --- src/cc/tetris.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 40278d493..41e8c1a78 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -858,7 +858,7 @@ int main(int argc, char **argv) next = newwin(6, 10, 0, 2 * (tg->cols + 1) + 1); hold = newwin(6, 10, 7, 2 * (tg->cols + 1) + 1); score = newwin(6, 10, 14, 2 * (tg->cols + 1 ) + 1); - + int32_t counter = 0; // Game loop while (running) { running = tg_tick(tg, move); @@ -866,8 +866,9 @@ int main(int argc, char **argv) display_piece(next, tg->next); display_piece(hold, tg->stored); display_score(score, tg); - doupdate(); - sleep_milli(50); + if ( (counter++ & 1) == 0 ) + doupdate(); + sleep_milli(25); switch (getch()) { case KEY_LEFT: From 6ef61a1aa9de6902245f8a030e6fc5d09c15de3c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Mar 2019 21:50:30 -1100 Subject: [PATCH 03/64] A0/50 --- src/cc/tetris.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/tetris.cpp b/src/cc/tetris.cpp index 41e8c1a78..d6ae473fe 100644 --- a/src/cc/tetris.cpp +++ b/src/cc/tetris.cpp @@ -866,9 +866,9 @@ int main(int argc, char **argv) display_piece(next, tg->next); display_piece(hold, tg->stored); display_score(score, tg); - if ( (counter++ & 1) == 0 ) + if ( (counter++ % 5) == 0 ) doupdate(); - sleep_milli(25); + sleep_milli(10); switch (getch()) { case KEY_LEFT: From 21c8a023e70703c4d31be9ca0279f28a43c3f4de Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 8 Mar 2019 22:54:02 -1100 Subject: [PATCH 04/64] Fix dilithium inputs scan to compare for the voutpubtxids[vout] --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index d4b75bf38..7ab6b4c37 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3352,7 +3352,7 @@ int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu { if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > DILITHIUM_TXFEE && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { - if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' || dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x') && destpubtxid == checktxid ) + if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' && vout < voutpubtxids.size() && checktxid == voutpubtxids[vout]) || (dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' && destpubtxid == checktxid) ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); From 5c66b810d3cbad6ad7b1cd7da30695490cfdef3b Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 9 Mar 2019 07:50:53 -0800 Subject: [PATCH 05/64] Prevent use of uninitialized ignoredAddresses --- src/txdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index b798599b7..f00f2adf8 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -441,7 +441,7 @@ uint32_t komodo_segid32(char *coinaddr); UniValue CBlockTreeDB::Snapshot(int top) { int64_t total = 0; int64_t totalAddresses = 0; std::string address; - int64_t utxos = 0; int64_t ignoredAddresses; + int64_t utxos = 0; int64_t ignoredAddresses = 0; boost::scoped_ptr iter(NewIterator()); std::map addressAmounts; std::vector > vaddr; From 6398d6f0547436681e01f46e44a97c1430240a04 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 9 Mar 2019 14:52:49 -0800 Subject: [PATCH 06/64] Filter out amount=0 UTXOs from getsnapshot results --- src/txdb.cpp | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index f00f2adf8..0588d52de 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -491,27 +491,31 @@ UniValue CBlockTreeDB::Snapshot(int top) getAddressFromIndex(indexKey.type, indexKey.hashBytes, address); - std::map ::iterator ignored = ignoredMap.find(address); - if (ignored != ignoredMap.end()) { - fprintf(stderr,"ignoring %s\n", address.c_str()); - ignoredAddresses++; - continue; - } + if (nValue > 0) { + std::map ::iterator ignored = ignoredMap.find(address); + if (ignored != ignoredMap.end()) { + fprintf(stderr,"ignoring %s\n", address.c_str()); + ignoredAddresses++; + continue; + } - std::map ::iterator pos = addressAmounts.find(address); - if (pos == addressAmounts.end()) { - // insert new address + utxo amount - //fprintf(stderr, "inserting new address %s with amount %li\n", address.c_str(), nValue); - addressAmounts[address] = nValue; - totalAddresses++; + std::map ::iterator pos = addressAmounts.find(address); + if (pos == addressAmounts.end()) { + // insert new address + utxo amount + //fprintf(stderr, "inserting new address %s with amount %li\n", address.c_str(), nValue); + addressAmounts[address] = nValue; + totalAddresses++; + } else { + // update unspent tally for this address + //fprintf(stderr, "updating address %s with new utxo amount %li\n", address.c_str(), nValue); + addressAmounts[address] += nValue; + } + //fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN); + // total += nValue; + utxos++; } else { - // update unspent tally for this address - //fprintf(stderr, "updating address %s with new utxo amount %li\n", address.c_str(), nValue); - addressAmounts[address] += nValue; + fprintf(stderr,"ignoring amount=0 UTXO for %s\n", address.c_str()); } - //fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN); - // total += nValue; - utxos++; } catch (const std::exception& e) { fprintf(stderr, "DONE %s: LevelDB addressindex exception! - %s\n", __func__, e.what()); break; From bc0073b27dc826fae3bf5cc3896fa2bd86b34e4c Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Mon, 11 Mar 2019 08:33:40 +0200 Subject: [PATCH 07/64] rogue msvc build (#1327) * + msvc 2015 deps headers * + msvc deps build script this script builds only deps, to build rogue binary, open *.sln file in MSVC 2015 and build x64 Release version. * + msvc solution (*.sln) update * + msvc build fix * fix libcurl deps install (msvc) --- .gitignore | 1 + src/cc/rogue/extern.h | 9 +- src/cc/rogue/main.c | 45 +- src/cc/rogue/rogue.c | 27 + src/cc/rogue/rogue54.sln | 14 +- src/cc/rogue/rogue54.vcxproj | 257 +++ src/cc/rogue/rogue_build_msvc.cmd | 64 + .../deps/install/include/acs_defs.h | 265 +++ .../deps/install/include/curses.h | 1846 +++++++++++++++++ .../deps/install/include/curspriv.h | 134 ++ .../deps/install/include/getopt.h | 93 + .../deps/install/include/panel.h | 56 + .../deps/install/include/term.h | 48 + .../deps/install/include/unistd.h | 56 + 14 files changed, 2910 insertions(+), 5 deletions(-) create mode 100644 src/cc/rogue/rogue54.vcxproj create mode 100644 src/cc/rogue/rogue_build_msvc.cmd create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/acs_defs.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/curses.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/curspriv.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/getopt.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/panel.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/term.h create mode 100644 src/cc/rogue/x86_64-w64-msvc/deps/install/include/unistd.h diff --git a/.gitignore b/.gitignore index 2ab07ee0f..9f05e147c 100644 --- a/.gitignore +++ b/.gitignore @@ -154,3 +154,4 @@ src/ROGUE.conf src/rogue.scr src/cc/rogue/confdefs.h +src/cc/rogue/x64 diff --git a/src/cc/rogue/extern.h b/src/cc/rogue/extern.h index 7fba842f3..c62646b67 100644 --- a/src/cc/rogue/extern.h +++ b/src/cc/rogue/extern.h @@ -107,6 +107,12 @@ #include #include +#ifdef _WIN32 +#ifdef _MSC_VER +#include +#endif +#endif + #undef SIGTSTP #define MAXSTR 1024 /* maximum length of strings */ @@ -142,7 +148,8 @@ void leave(int); void my_exit(int st); void playltchars(void); void quit(int); -int32_t _quit(); +int32_t _quit(); + void resetltchars(void); void set_order(int *order, int numthings); void tstp(int ignored); diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index c2155a085..da46898f8 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -38,6 +38,31 @@ union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uin typedef union _bits256 bits256; #endif +#ifdef _WIN32 +#ifdef _MSC_VER +int gettimeofday(struct timeval * tp, struct timezone * tzp) +{ + // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's + static const uint64_t EPOCH = ((uint64_t)116444736000000000ULL); + + SYSTEMTIME system_time; + FILETIME file_time; + uint64_t time; + + GetSystemTime(&system_time); + SystemTimeToFileTime(&system_time, &file_time); + time = ((uint64_t)file_time.dwLowDateTime); + time += ((uint64_t)file_time.dwHighDateTime) << 32; + + tp->tv_sec = (long)((time - EPOCH) / 10000000L); + tp->tv_usec = (long)(system_time.wMilliseconds * 1000); + return 0; +} +#endif // _MSC_VER +#endif + + + double OS_milliseconds() { struct timeval tv; double millis; @@ -392,6 +417,12 @@ char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char * } #endif +#ifdef _WIN32 +#ifdef _MSC_VER +#define sleep(x) Sleep(1000*(x)) +#endif +#endif + /************************************************************************ * * perform the query @@ -919,7 +950,19 @@ int main(int argc, char **argv, char **envp) printf("ASSETCHAINS_SYMBOL.(%s) port.%u (%s) IPADDRESS.%s \n",ASSETCHAINS_SYMBOL,ROGUE_PORT,USERPASS,IPADDRESS); sleep(1); if ( argc == 2 && (fp=fopen(argv[1],"rb")) == 0 ) { - seed = atol(argv[1]); + + #ifdef _WIN32 + #ifdef _MSC_VER + seed = _strtoui64(argv[1], NULL, 10); + fprintf(stderr, "replay seed.str(%s) seed.uint64_t(%I64u)", argv[1], seed); + #else + fprintf(stderr, "replay seed.str(%s) seed.uint64_t(%llu)", argv[1], (long long)seed); + seed = atol(argv[1]); // windows, but not MSVC + #endif // _MSC_VER + #else + seed = atol(argv[1]); // non-windows + #endif // _WIN32 + //fprintf(stderr,"replay %llu\n",(long long)seed); return(rogue_replay(seed,10)); } diff --git a/src/cc/rogue/rogue.c b/src/cc/rogue/rogue.c index 352e950ec..36616b340 100644 --- a/src/cc/rogue/rogue.c +++ b/src/cc/rogue/rogue.c @@ -13,6 +13,7 @@ #include //#include //#include + #include "rogue.h" #ifdef STANDALONE #include "../komodo/src/komodo_cJSON.h" @@ -196,6 +197,12 @@ void rogue_bailout(struct rogue_state *rs) fprintf(stderr,"error issuing (%s)\n",cmd);*/ } +#ifdef _WIN32 +#ifdef _MSC_VER +#define sleep(x) Sleep(1000*(x)) +#endif +#endif + int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis) { struct rogue_state *rs; FILE *fp; int32_t i,n; @@ -215,6 +222,14 @@ int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t nu globalR = *rs; uint32_t starttime = (uint32_t)time(NULL); rogueiterate(rs); + + /* + // keypress after replay + printf("[Press return to continue]"); + fflush(stdout); + if (fgets(prbuf, 10, stdin) != 0); + */ + if ( 0 ) { fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime); @@ -526,6 +541,18 @@ tstp(int ignored) #endif*/ } + +#ifdef _WIN32 +#ifdef _MSC_VER +void usleep(int32_t micros) +{ + if (micros < 1000) + Sleep(1); + else Sleep(micros / 1000); +} +#endif +#endif + /* * playit: * The main loop of the program. Loop until the game is over, diff --git a/src/cc/rogue/rogue54.sln b/src/cc/rogue/rogue54.sln index da1c58f07..751959465 100644 --- a/src/cc/rogue/rogue54.sln +++ b/src/cc/rogue/rogue54.sln @@ -1,17 +1,25 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rogue54", "rogue54.vcproj", "{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}" +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rogue54", "rogue54.vcxproj", "{9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|Win32.ActiveCfg = Debug|Win32 {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|Win32.Build.0 = Debug|Win32 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|x64.ActiveCfg = Debug|x64 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Debug|x64.Build.0 = Debug|x64 {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|Win32.ActiveCfg = Release|Win32 {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|Win32.Build.0 = Release|Win32 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|x64.ActiveCfg = Release|x64 + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/cc/rogue/rogue54.vcxproj b/src/cc/rogue/rogue54.vcxproj new file mode 100644 index 000000000..344598dd8 --- /dev/null +++ b/src/cc/rogue/rogue54.vcxproj @@ -0,0 +1,257 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {9EA0D326-8097-4ADA-82EA-4DB1F5CAA8F6} + Win32Proj + 8.1 + + + + Application + v140 + MultiByte + + + Application + v140 + MultiByte + false + + + Application + v140 + MultiByte + + + Application + v140 + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>14.0.25431.1 + + + Debug\ + Debug\ + true + + + true + + + Release\ + Release\ + false + + + false + + + + Disabled + Default + ../pdcurses;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;ALLSCORES;MASTER;SCOREFILE="rogue54.scr";LOCKFILE="rogue54.lck";%(PreprocessorDefinitions) + true + false + + EnableFastChecks + MultiThreaded + true + true + false + true + + + Level4 + EditAndContinue + CompileAsC + + + Ws2_32.lib;pdcurses.lib;advapi32.lib;shfolder.lib;user32.lib;%(AdditionalDependencies) + $(OutDir)rogue54.exe + ..\pdcurses;%(AdditionalLibraryDirectories) + false + true + $(OutDir)rogue54.pdb + Console + MachineX86 + + + + + Disabled + Default + $(ProjectDir)x86_64-w64-msvc\deps\install\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;PDC_DLL_BUILD;PDC_WIDE;PDCDEBUG;_CRT_SECURE_NO_DEPRECATE;ALLSCORES;SCOREFILE="rogue54.scr";LOCKFILE="rogue54.lck";%(PreprocessorDefinitions) + true + false + + + EnableFastChecks + MultiThreaded + true + true + false + true + + + + + Level4 + ProgramDatabase + CompileAsC + + + Ws2_32.lib;wincon\pdcurses.lib;libcurl_imp.lib;advapi32.lib;shfolder.lib;user32.lib;%(AdditionalDependencies) + $(OutDir)rogue54.exe + $(ProjectDir)x86_64-w64-msvc\deps\install\lib;$(ProjectDir)x86_64-w64-msvc\deps\install\Release\lib;%(AdditionalLibraryDirectories) + false + true + $(OutDir)rogue54.pdb + Console + + + + + MaxSpeed + OnlyExplicitInline + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + MultiThreaded + true + NotUsing + Level3 + ProgramDatabase + $(ProjectDir)\x86_64-w64-msvc\include\ncursesw;$(ProjectDir)\x86_64-w64-msvc\include;%(AdditionalIncludeDirectories) + + + $(OutDir)rogue54.exe + true + Windows + true + true + MachineX86 + %(AdditionalLibraryDirectories) + %(AdditionalDependencies) + + + + + MaxSpeed + OnlyExplicitInline + true + WIN32;_WINDOWS;NDEBUG;PDC_DLL_BUILD;PDC_WIDE;PDCDEBUG;_CRT_SECURE_NO_DEPRECATE;ALLSCORES;SCOREFILE="rogue54.scr";LOCKFILE="rogue54.lck";%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + ProgramDatabase + $(ProjectDir)x86_64-w64-msvc\deps\install\include;%(AdditionalIncludeDirectories) + stdafx.h + CompileAsC + + + + + $(OutDir)rogue54.exe + true + Console + true + true + $(ProjectDir)x86_64-w64-msvc\deps\install\lib;$(ProjectDir)x86_64-w64-msvc\deps\install\Release\lib;%(AdditionalLibraryDirectories) + Ws2_32.lib;wincon\pdcurses.lib;libcurl_imp.lib;advapi32.lib;shfolder.lib;user32.lib;%(AdditionalDependencies) + %(IgnoreSpecificDefaultLibraries) + false + %(ForceSymbolReferences) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/cc/rogue/rogue_build_msvc.cmd b/src/cc/rogue/rogue_build_msvc.cmd new file mode 100644 index 000000000..77e7cd852 --- /dev/null +++ b/src/cc/rogue/rogue_build_msvc.cmd @@ -0,0 +1,64 @@ +@echo off +echo Rogue Build Script by Decker (c) 2019 + +@REM Check for Visual Studio +call set "VSPATH=" +if defined VS140COMNTOOLS ( if not defined VSPATH ( + call set "VSPATH=%%VS140COMNTOOLS%%" +) ) + +@REM check if we already have the tools in the environment +if exist "%VCINSTALLDIR%" ( + goto compile +) + +if not defined VSPATH ( + echo You need Microsoft Visual Studio 15 installed + pause + exit +) + +@REM set up the environment +if exist "%VSPATH%..\..\vc\vcvarsall.bat" ( + call "%%VSPATH%%..\..\vc\vcvarsall.bat" amd64 + goto compile +) + +echo Unable to set up the environment +pause +exit + +:compile + +mkdir x86_64-w64-msvc\deps +mkdir x86_64-w64-msvc\deps\install + +pushd x86_64-w64-msvc\deps + +:compile_pdcurses +rem git clone https://github.com/wmcbrine/PDCurses PDCurses.org +git clone https://github.com/Bill-Gray/PDCurses + +set PREFIX_DIR=%CD%\install + +pushd PDCurses +mkdir build64 & pushd build64 +rem cmake -G"Visual Studio 14 2015 Win64" -DPDC_WIDE=ON -DCMAKE_INSTALL_PREFIX=%PREFIX_DIR% -DCMAKE_BUILD_TYPE=Debug -DPDCDEBUG=ON .. +cmake -G"Visual Studio 14 2015 Win64" -DPDC_WIDE=ON -DCMAKE_INSTALL_PREFIX=%PREFIX_DIR% -DCMAKE_BUILD_TYPE=Release .. +popd +rem cmake --build build64 --config Debug --target install +cmake --build build64 --config Release --target install +popd + +:compile_curl + +git clone https://github.com/curl/curl +pushd curl + +mkdir build64 & pushd build64 +cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=%PREFIX_DIR% -DCMAKE_USE_WINSSL:BOOL=ON .. +cmake --build . --config Release --target libcurl +cmake --build . --config Release --target install +popd +popd + diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/acs_defs.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/acs_defs.h new file mode 100644 index 000000000..c8c02a737 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/acs_defs.h @@ -0,0 +1,265 @@ +/* Many of the following #defines are completely unused for the +nonce. For each character, its code point in code page 437, +Unicode, and page 8859-1 are given. The first is used for +non-wide builds in Win32 console, DOS, SDL, and OS/2. +Unicode is used for all wide builds, and for the non-wide +build of WinGUI. Code page 8859-1 is used for non-wide X11. + + All of these characters exist in CP437 and Unicode. Some +don't exist in 8859-1, in which case the last column is 'TBD'. +Only 32 are used in ncurses. So caution is advised. */ + +#ifdef USE_ISO8859_CHARSET + #define CHOOSE( A, B, C) (C) + #define TBD '!' +#else + #define CHOOSE( A, B, C) (USE_UNICODE_ACS_CHARS ? B : A) +#endif + +/* Codes found from https://en.wikipedia.org/wiki/Code_page_437 */ + +#define SMILE CHOOSE( 0x01, 0x263a, 'O') +#define REV_SMILE CHOOSE( 0x02, 0x263b, 'O') +#define HEART CHOOSE( 0x03, 0x2665, 'H') +#define DIAMOND CHOOSE( 0x04, 0x2666, 0x01) +#define CLUB CHOOSE( 0x05, 0x2663, 'C') +#define SPADE CHOOSE( 0x06, 0x2660, 'S') +#define MEDIUM_BULLET CHOOSE( 0x07, 0x2022, 0xb7) +#define REV_BULLET CHOOSE( 0x08, 0x2508, 0xb7) +#define WHITE_BULLET CHOOSE( 0x09, 0x25cb, 7) +#define REV_WHITE_BULLET CHOOSE( 0x0a, 0x25D9, 7) +#define MALE_SYM CHOOSE( 0x0b, 0x2642, 'm') +#define FEMALE_SYM CHOOSE( 0x0c, 0x2640, 'f') +#define QTR_NOTE CHOOSE( 0x0d, 0x266a, 0xbc) +#define EIGHTH_NOTE CHOOSE( 0x0e, 0x266b, 0xbd) +#define SPLAT CHOOSE( 0x0f, 0xa4 , 0xa4) +#define RIGHT_TRIANGLE CHOOSE( 0x10, 0x25b6, '>') +#define LEFT_TRIANGLE CHOOSE( 0x11, 0x25c0, '<') +#define UP_DOWN_ARROW CHOOSE( 0x12, 0x2195, 0x19) +#define DBL_BANG CHOOSE( 0x13, 0x203c, '!') +#define PILCROW CHOOSE( 0x14, 0xb6 , 0xb6) +#define SECTION_SIGN CHOOSE( 0x15, 0xa7 , 0xa7) +#define LOW_QTR_BLOCK CHOOSE( 0x16, 0x25b2, '_') +#define UP_DOWN_ARROW_UNDERSCORED CHOOSE( 0x17, 0x21ab, 0x19) +#define UP_ARROW CHOOSE( 0x18, 0x2191, '^') +#define DOWN_ARROW CHOOSE( 0x19, 0x2193, 'v') +#define RIGHT_ARROW CHOOSE( 0x1a, 0x2192, '>') +#define LEFT_ARROW CHOOSE( 0x1b, 0x2190, '<') +#define RIGHT_ANGLE CHOOSE( 0x1c, 0x221f, 0xe) +#define LEFT_RIGHT_ARROW CHOOSE( 0x1d, 0x2194, '-') +#define UP_TRIANGLE CHOOSE( 0x1e, 0x25b2, '^') +#define DOWN_TRIANGLE CHOOSE( 0x1f, 0x25bc, 'v') + +#define UPPERCASE_C_CEDILLA CHOOSE( 0x80, 0xc7 , 0xc7) +#define LOWERCASE_U_UMLAUT CHOOSE( 0x81, 0xfc , 0xfc) +#define LOWERCASE_E_ACUTE CHOOSE( 0x82, 0xe9 , 0xe9) +#define LOWERCASE_A_CIRCUMFLEX CHOOSE( 0x83, 0xe2 , 0xe2) +#define LOWERCASE_A_UMLAUT CHOOSE( 0x84, 0xe4 , 0xe4) +#define LOWERCASE_A_GRAVE CHOOSE( 0x85, 0xe0 , 0xea) +#define LOWERCASE_A_RING CHOOSE( 0x86, 0xe5 , 0xe5) +#define LOWERCASE_C_CEDILLA CHOOSE( 0x87, 0xe7 , 0xe7) +#define LOWERCASE_E_CIRCUMFLEX CHOOSE( 0x88, 0xea , 0xea) +#define LOWERCASE_E_UMLAUT CHOOSE( 0x89, 0xeb , 0xeb) +#define LOWERCASE_E_GRAVE CHOOSE( 0x8a, 0xe8 , 0xe8) +#define LOWERCASE_I_UMLAUT CHOOSE( 0x8b, 0xef , 0xef) +#define LOWERCASE_I_CIRCUMFLEX CHOOSE( 0x8c, 0xee , 0xee) +#define LOWERCASE_I_GRAVE CHOOSE( 0x8d, 0xec , 0xce) +#define UPPERCASE_A_UMLAUT CHOOSE( 0x8e, 0xc4 , 0xc4) +#define UPPERCASE_A_RING CHOOSE( 0x8f, 0xc5 , 0xc5) + +#define UPPERCASE_E_ACUTE CHOOSE( 0x90, 0xc9 , 0xc9) +#define LOWERCASE_AE_LIGATURE CHOOSE( 0x91, 0xe6 , 0xe6) +#define UPPERCASE_AE_LIGATURE CHOOSE( 0x92, 0xc6 , 0xc6) +#define LOWERCASE_O_CIRCUMFLEX CHOOSE( 0x93, 0xf4 , 0xf4) +#define LOWERCASE_O_UMLAUT CHOOSE( 0x94, 0xf6 , 0xf6) +#define LOWERCASE_O_GRAVE CHOOSE( 0x95, 0xf2 , 0xf2) +#define LOWERCASE_U_CIRCUMFLEX CHOOSE( 0x96, 0xfb , 0xfb) +#define LOWERCASE_U_GRAVE CHOOSE( 0x97, 0xf9 , 0xf9) +#define LOWERCASE_Y_UMLAUT CHOOSE( 0x98, 0xff , 0xff) +#define UPPERCASE_O_UMLAUT CHOOSE( 0x99, 0xd6 , 0xd6) +#define UPPERCASE_U_UMLAUT CHOOSE( 0x9a, 0xdc , 0xdc) +#define CENT_SIGN CHOOSE( 0x9b, 0xa2 , 0xa2) +#define STERLING_SIGN CHOOSE( 0x9c, 0xa3 , 30) +#define YEN_SIGN CHOOSE( 0x9d, 0xa5 , 0xa5) +#define PESETA_SIGN CHOOSE( 0x9e, 0x20a7, TBD) +#define F_WITH_HOOK CHOOSE( 0x9f, 0x0192, TBD) + +#define LOWERCASE_A_ACUTE CHOOSE( 0xa0, 0xe1 , 0xe1) +#define LOWERCASE_I_ACUTE CHOOSE( 0xa1, 0xed , 0xed) +#define LOWERCASE_O_ACUTE CHOOSE( 0xa2, 0xf3 , 0xf3) +#define LOWERCASE_U_ACUTE CHOOSE( 0xa3, 0xfa , 0xfa) +#define LOWERCASE_N_TILDE CHOOSE( 0xa4, 0xf1 , 0xf1) +#define UPPERCASE_N_TILDE CHOOSE( 0xa5, 0xd1 , 0xd1) +#define A_ORDINAL CHOOSE( 0xa6, 0xaa , 0xaa) +#define O_ORDINAL CHOOSE( 0xa7, 0xba , 0xba) +#define INVERTED_QUESTION_MARK CHOOSE( 0xa8, 0xbf , 0xbf) +#define REVERSED_NOT_SIGN CHOOSE( 0xa9, 0x2310, TBD) +#define NOT_SIGN CHOOSE( 0xaa, 0xac , 0xac) +#define VULGAR_HALF CHOOSE( 0xab, 0xbd , 0xbd) +#define VULGAR_QUARTER CHOOSE( 0xac, 0xbc , 0xbc) +#define INVERTED_EXCLAMATION_MARK CHOOSE( 0xad, 0xa1 , 0xa1) +#define LEFT_ANGLE_QUOTE_MARK CHOOSE( 0xae, 0xab , 0xab) +#define RIGHT_ANGLE_QUOTE_MARK CHOOSE( 0xaf, 0xbb , 0xbb) + +#define LIGHT_SHADE CHOOSE( 0xb0, 0x2591, '#' ) +#define MEDIUM_SHADE CHOOSE( 0xb1, 0x2592, 2) +#define DARK_SHADE CHOOSE( 0xb2, 0x2593, TBD) +#define BOX_VLINE CHOOSE( 0xb3, 0x2502, 25) +#define BOX_RTEE CHOOSE( 0xb4, 0x2524, 22) +#define BOX_SD_RTEE CHOOSE( 0xb5, 0x2561, 22) +#define BOX_DS_RTEE CHOOSE( 0xb6, 0x2562, 22) +#define BOX_DS_URCORNER CHOOSE( 0xb7, 0x2556, 12) +#define BOX_SD_URCORNER CHOOSE( 0xb8, 0x2555, 12) +#define BOX_D_RTEE CHOOSE( 0xb9, 0x2563, 22) +#define BOX_D_VLINE CHOOSE( 0xba, 0x2551, 25) +#define BOX_D_URCORNER CHOOSE( 0xbb, 0x2557, 12) +#define BOX_D_LRCORNER CHOOSE( 0xbc, 0x255D, 11) +#define BOX_DS_LRCORNER CHOOSE( 0xbd, 0x255c, 11) +#define BOX_SD_LRCORNER CHOOSE( 0xbe, 0x255b, 11) +#define BOX_URCORNER CHOOSE( 0xbf, 0x2510, 12) + +#define BOX_LLCORNER CHOOSE( 0xc0, 0x2514, 14) +#define BOX_BTEE CHOOSE( 0xc1, 0x2534, 23) +#define BOX_TTEE CHOOSE( 0xc2, 0x252c, 24) +#define BOX_LTEE CHOOSE( 0xc3, 0x251c, 21) +#define BOX_HLINE CHOOSE( 0xc4, 0x2500, 18) +#define BOX_PLUS CHOOSE( 0xc5, 0x253c, 15) +#define BOX_SD_LTEE CHOOSE( 0xc6, 0x255e, 21) +#define BOX_DS_LTEE CHOOSE( 0xc7, 0x255f, 21) +#define BOX_D_LLCORNER CHOOSE( 0xc8, 0x255A, 14) +#define BOX_D_ULCORNER CHOOSE( 0xc9, 0x2554, 13) +#define BOX_D_BTEE CHOOSE( 0xca, 0x2569, 23) +#define BOX_D_TTEE CHOOSE( 0xcb, 0x2566, 24) +#define BOX_D_LTEE CHOOSE( 0xcc, 0x2560, 21) +#define BOX_D_HLINE CHOOSE( 0xcd, 0x2550, 18) +#define BOX_D_PLUS CHOOSE( 0xce, 0x256C, 15) +#define BOX_SD_BTEE CHOOSE( 0xcf, 0x2567, 23) + +#define BOX_DS_BTEE CHOOSE( 0xd0, 0x2568, 23) +#define BOX_SD_TTEE CHOOSE( 0xd1, 0x2564, 24) +#define BOX_DS_TTEE CHOOSE( 0xd2, 0x2565, 24) +#define BOX_DS_LLCORNER CHOOSE( 0xd3, 0x2559, 14) +#define BOX_SD_LLCORNER CHOOSE( 0xd4, 0x2558, 14) +#define BOX_SD_ULCORNER CHOOSE( 0xd5, 0x2552, 13) +#define BOX_DS_ULCORNER CHOOSE( 0xd6, 0x2553, 13) +#define BOX_DS_PLUS CHOOSE( 0xd7, 0x256b, 15) +#define BOX_SD_PLUS CHOOSE( 0xd8, 0x256a, 15) +#define BOX_LRCORNER CHOOSE( 0xd9, 0x2518, 11) +#define BOX_ULCORNER CHOOSE( 0xda, 0x250c, 13) +#define FULL_BLOCK CHOOSE( 0xdb, 0x2588, 0) +#define LOWER_HALF_BLOCK CHOOSE( 0xdc, 0x2584, TBD) +#define LEFT_HALF_BLOCK CHOOSE( 0xdd, 0x258c, TBD) +#define RIGHT_HALF_BLOCK CHOOSE( 0xde, 0x2590, TBD) +#define UPPER_HALF_BLOCK CHOOSE( 0xdf, 0x2580, TBD) + +#define ALPHA CHOOSE( 0xe0, 0x03b1, TBD) +#define BETA CHOOSE( 0xe1, 0x00df, TBD) +#define GAMMA CHOOSE( 0xe2, 0x0393, TBD) +#define PI CHOOSE( 0xe3, 0x03c0, 28) +#define UPPERCASE_SIGMA CHOOSE( 0xe4, 0x03a3, TBD) +#define LOWERCASE_SIGMA CHOOSE( 0xe5, 0x03c3, TBD) +#define MU CHOOSE( 0xe6, 0x00b5, 0xb5) +#define TAU CHOOSE( 0xe7, 0x03c4, TBD) +#define UPPERCASE_PHI CHOOSE( 0xe8, 0x03a6, TBD) +#define THETA CHOOSE( 0xe9, 0x0398, TBD) +#define OMEGA CHOOSE( 0xea, 0x03a9, TBD) +#define DELTA CHOOSE( 0xeb, 0x03b4, TBD) +#define INFINITY_SIGN CHOOSE( 0xec, 0x221e, TBD) +#define LOWERCASE_PHI CHOOSE( 0xed, 0x03c6, TBD) +#define EPSILON CHOOSE( 0xee, 0x03b5, TBD) +#define INTERSECTION CHOOSE( 0xef, 0x2229, TBD) + +#define TRIPLE_BAR CHOOSE( 0xf0, 0x2261, TBD) +#define PLUS_OR_MINUS CHOOSE( 0xf1, 0x00b1, 8) +#define GREATER_THAN_OR_EQUAL_TO CHOOSE( 0xf2, 0x2265, 27) +#define LESSER_THAN_OR_EQUAL_TO CHOOSE( 0xf3, 0x2264, 26) +#define UPPER_HALF_INTEGRAL_SIGN CHOOSE( 0xf4, 0x2320, TBD) +#define LOWER_HALF_INTEGRAL_SIGN CHOOSE( 0xf5, 0x2321, TBD) +#define DIVISION_SIGN CHOOSE( 0xf6, 0x00f7, 0xf7) +#define APPROXIMATELY_EQUALS_SIGN CHOOSE( 0xf7, 0x2248, TBD) +#define DEGREE_SIGN CHOOSE( 0xf8, 0x00b0, 0xb0) +#define LARGE_BULLET CHOOSE( 0xf9, 0x2219, 7) +#define SMALL_BULLET CHOOSE( 0xfa, 0x00b7, 0xb7) +#define SQUARE_ROOT CHOOSE( 0xfb, 0x221a, TBD) +#define SUPERSCRIPT_N CHOOSE( 0xfc, 0x207f, TBD) +#define SUPERSCRIPT_2 CHOOSE( 0xfd, 0x00b2, 0xb2) +#define CENTERED_SQUARE CHOOSE( 0xfe, 0x25a0, TBD) +#define NON_BREAKING_SPACE CHOOSE( 0xff, 0x00a0, TBD) + + + + /* It says at http://unicode.org/charts/PDF/U2300.pdf */ + /* that '...the scan line numbers here refer to old, */ + /* low-resolution technology for terminals, with only */ + /* nine scan lines per fixed-size character glyph. */ + /* Even-numbered scan lines are unified with box */ + /* drawing graphics." */ + /* The utility of these is questionable; they'd */ + /* work Just Fine in wingdi (_if_ the appropriate */ + /* glyphs are available), but not elsewhere. */ +#define HORIZ_SCAN_LINE_1 CHOOSE( 0x2d, 0x23ba, 16) +#define HORIZ_SCAN_LINE_3 CHOOSE( 0x2d, 0x23bb, 17) +#define HORIZ_SCAN_LINE_7 CHOOSE( 0x2d, 0x23bc, 19) +#define HORIZ_SCAN_LINE_9 CHOOSE( '_', 0x23bd, 20) + + /* Code page 437 lacks a 'for real' not-equals, so for that, */ + /* we use the double-horizontal single-vertical box drawing : */ +#define NOT_EQUALS_SIGN CHOOSE( 0xd8, 0x2260, 29) + +# define A(x) ((chtype)x | A_ALTCHARSET) + +chtype acs_map[128] = +{ + A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), + A(9), A(10), + CLUB, HEART, SPADE, SMILE, REV_SMILE, /* 11 12 13 14 15 */ + MEDIUM_BULLET, WHITE_BULLET, PILCROW, SECTION_SIGN, /* 16 17 18 19 */ + A_ORDINAL, O_ORDINAL, LOWERCASE_PHI, /* 20 21 22 */ + INVERTED_EXCLAMATION_MARK, INVERTED_QUESTION_MARK, /* 23 24 */ + REVERSED_NOT_SIGN, NOT_SIGN, /* 25 26 */ + UPPER_HALF_INTEGRAL_SIGN, LOWER_HALF_INTEGRAL_SIGN, /* 27 28 */ + SUPERSCRIPT_N, CENTERED_SQUARE, F_WITH_HOOK, /* 29 30 31 */ + + RIGHT_ARROW, LEFT_ARROW, UP_ARROW, DOWN_ARROW, /* 32 !"# */ + + PI, NOT_EQUALS_SIGN, VULGAR_HALF, VULGAR_QUARTER, /* $%&' */ + '(', + LEFT_ANGLE_QUOTE_MARK, RIGHT_ANGLE_QUOTE_MARK, /* )* */ + DARK_SHADE, SUPERSCRIPT_2, INFINITY_SIGN, /* +,- */ + ALPHA, BETA, GAMMA, UPPERCASE_SIGMA, LOWERCASE_SIGMA, /* ./012 */ + '3', + MU, TAU, UPPERCASE_PHI, THETA, OMEGA, DELTA, EPSILON, /* 456789: */ + + BOX_SD_LRCORNER, BOX_SD_URCORNER, BOX_SD_ULCORNER, /* ;<= */ + BOX_SD_LLCORNER, BOX_SD_PLUS, /* >? */ + BOX_SD_LTEE, BOX_SD_RTEE, BOX_SD_BTEE, BOX_SD_TTEE, /* @ABC */ + + BOX_D_LRCORNER, BOX_D_URCORNER, BOX_D_ULCORNER, /* DEF */ + BOX_D_LLCORNER, BOX_D_PLUS, /* GH */ + BOX_D_LTEE, BOX_D_RTEE, BOX_D_BTEE, BOX_D_TTEE, /* IJKL */ + + BOX_DS_LRCORNER, BOX_DS_URCORNER, BOX_DS_ULCORNER, /* MNO */ + BOX_DS_LLCORNER, BOX_DS_PLUS, /* PQ */ + BOX_DS_LTEE, BOX_DS_RTEE, BOX_DS_BTEE, BOX_DS_TTEE, /* RSTU */ + + BOX_LRCORNER, BOX_URCORNER, BOX_ULCORNER, /* VWX */ + BOX_LLCORNER, BOX_PLUS, /* YZ */ + BOX_LTEE, BOX_RTEE, BOX_BTEE, BOX_TTEE, /* [\]^ */ + + BOX_HLINE, BOX_VLINE, BOX_D_HLINE, BOX_D_VLINE, /* _`ab */ + + DIVISION_SIGN, APPROXIMATELY_EQUALS_SIGN, /* cd */ + INTERSECTION, TRIPLE_BAR, /* ef */ + SMALL_BULLET, LARGE_BULLET, SQUARE_ROOT, /* ghi */ + DIAMOND, MEDIUM_SHADE, /* jk */ + HORIZ_SCAN_LINE_1, HORIZ_SCAN_LINE_3, /* lm */ + HORIZ_SCAN_LINE_7, HORIZ_SCAN_LINE_9, /* no */ + UPPER_HALF_BLOCK, LOWER_HALF_BLOCK, /* pq */ + LEFT_HALF_BLOCK, RIGHT_HALF_BLOCK, FULL_BLOCK, /* rst */ + LESSER_THAN_OR_EQUAL_TO, GREATER_THAN_OR_EQUAL_TO, /* uv */ + DEGREE_SIGN, PLUS_OR_MINUS, LIGHT_SHADE, SPLAT, /* wxyz */ + CENT_SIGN, YEN_SIGN, PESETA_SIGN, STERLING_SIGN, /* {|}~ */ + A(127) +}; + +# undef A diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curses.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curses.h new file mode 100644 index 000000000..9ee3f08a6 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curses.h @@ -0,0 +1,1846 @@ +/* Public Domain Curses */ + +/*----------------------------------------------------------------------* + * PDCurses * + *----------------------------------------------------------------------*/ + +#ifndef __PDCURSES__ +#define __PDCURSES__ 1 + +/*man-start************************************************************** + +PDCurses definitions list: (Only define those needed) + + XCURSES True if compiling for X11. + PDC_RGB True if you want to use RGB color definitions + (Red = 1, Green = 2, Blue = 4) instead of BGR. + PDC_WIDE True if building wide-character support. + PDC_DLL_BUILD True if building a Windows DLL. + PDC_NCMOUSE Use the ncurses mouse API instead + of PDCurses' traditional mouse API. + +PDCurses portable platform definitions list: + + PDC_BUILD Defines API build version. + PDCURSES Enables access to PDCurses-only routines. + XOPEN Always true. + SYSVcurses True if you are compiling for SYSV portability. + BSDcurses True if you are compiling for BSD portability. + +**man-end****************************************************************/ + +#define PDCURSES 1 /* PDCurses-only routines */ +#define XOPEN 1 /* X/Open Curses routines */ +#define SYSVcurses 1 /* System V Curses routines */ +#define BSDcurses 1 /* BSD Curses routines */ +#if defined( CHTYPE_32) + #define CHTYPE_LONG 1 /* chtypes will be 32 bits */ +#elif !defined( CHTYPE_16) + #define CHTYPE_LONG 2 /* chtypes will be (default) 64 bits */ +#endif + +/*----------------------------------------------------------------------*/ + +#ifdef NO_STDINT_H + #define uint64_t unsigned long long + #define uint32_t unsigned long + #define uint16_t unsigned short +#else + #include +#endif +#include +#include +#include /* Required by X/Open usage below */ + +#ifdef PDC_WIDE +# include +#endif + +#if defined(__STDC_VERSION__) && __STDC_VERSION >= 199901L && \ + !defined(__bool_true_false_are_defined) +# include +#endif + +#ifdef __cplusplus +extern "C" +{ +# define bool _bool +#endif + +/*---------------------------------------------------------------------- + * + * Constants and Types + * + */ + +#undef FALSE +#undef TRUE + +#ifdef __bool_true_false_are_defined + +# define FALSE false +# define TRUE true + +#else + +typedef unsigned char bool; + +# define FALSE 0 +# define TRUE 1 + +#endif + +#undef ERR +#define ERR (-1) + +#undef OK +#define OK 0 + +#ifdef CHTYPE_LONG + #if(CHTYPE_LONG >= 2) /* "non-standard" 64-bit chtypes */ + typedef uint64_t chtype; + #else /* "Standard" CHTYPE_LONG case, 32-bit: */ + typedef uint32_t chtype; + # endif +#else +typedef uint16_t chtype; /* 8-bit attr + 8-bit char */ +#endif + +#ifdef PDC_WIDE +typedef chtype cchar_t; +#endif + +typedef chtype attr_t; + +/* Version constants, available as of version 4.0 : */ +/* Don't forget to update 'version.mif' if MAJOR/MINOR changes! */ + +#define PDC_VER_MAJOR 4 +#define PDC_VER_MINOR 0 +#define PDC_VER_CHANGE 4 +#define PDC_VER_YEAR 2019 +#define PDC_VER_MONTH 1 +#define PDC_VER_DAY 20 + +#define PDC_BUILD (PDC_VER_MAJOR*1000 + PDC_VER_MINOR *100 + PDC_VER_CHANGE) + +/* When using PDCurses as a DLL (Windows) or shared library (BSD or *nix), +it's possible to switch the DLL or shared library. One may therefore want +to inquire of the DLL/shared library the port, version numbers, and +chtype_size used, and make sure they're what one was expecting. The +'PDC_version' structure lets you do just that. */ + +enum PDC_port +{ + PDC_PORT_X11 = 0, + PDC_PORT_WIN32 = 1, + PDC_PORT_WINGUI = 2, + PDC_PORT_DOS = 3, + PDC_PORT_OS2 = 4, + PDC_PORT_SDL1 = 5, + PDC_PORT_SDL2 = 6, + PDC_PORT_VT = 7 +}; + +/* Detailed PDC version information */ +#define PDC_HAS_VERSION_INFO 1 +typedef struct +{ + const enum PDC_port port; + const int ver_major; + const int ver_minor; + const int ver_change; + const size_t chtype_size; + const bool is_wide; + const bool is_forced_utf8; +} PDC_version_info; + +/*---------------------------------------------------------------------- + * + * Mouse Interface -- SYSVR4, with extensions + * + */ + +/* Most flavors of PDCurses support three buttons. WinGUI supports */ +/* these plus two "extended" buttons. But we'll set this macro to */ +/* six, allowing future versions to support up to nine total buttons. */ +/* (The button states are broken up into two arrays to allow for the */ +/* possibility of backward compatibility to DLLs compiled with only */ +/* three mouse buttons.) */ + +#define PDC_MAX_MOUSE_BUTTONS 9 +#define PDC_N_EXTENDED_MOUSE_BUTTONS 6 + +typedef struct +{ + int x; /* absolute column, 0 based, measured in characters */ + int y; /* absolute row, 0 based, measured in characters */ + short button[3]; /* state of three "normal" buttons */ + int changes; /* flags indicating what has changed with the mouse */ + short xbutton[PDC_N_EXTENDED_MOUSE_BUTTONS]; /* state of ext buttons */ +} MOUSE_STATUS; + +#define BUTTON_RELEASED 0x0000 +#define BUTTON_PRESSED 0x0001 +#define BUTTON_CLICKED 0x0002 +#define BUTTON_DOUBLE_CLICKED 0x0003 +#define BUTTON_TRIPLE_CLICKED 0x0004 +#define BUTTON_MOVED 0x0005 /* PDCurses */ +#define WHEEL_SCROLLED 0x0006 /* PDCurses */ +#define BUTTON_ACTION_MASK 0x0007 /* PDCurses */ + +#define PDC_BUTTON_SHIFT 0x0008 /* PDCurses */ +#define PDC_BUTTON_CONTROL 0x0010 /* PDCurses */ +#define PDC_BUTTON_ALT 0x0020 /* PDCurses */ +#define BUTTON_MODIFIER_MASK 0x0038 /* PDCurses */ + +#define MOUSE_X_POS (Mouse_status.x) +#define MOUSE_Y_POS (Mouse_status.y) + +/* + * Bits associated with the .changes field: + * 3 2 1 0 + * 210987654321098765432109876543210 + * 1 <- button 1 has changed 0 + * 10 <- button 2 has changed 1 + * 100 <- button 3 has changed 2 + * 1000 <- mouse has moved 3 + * 10000 <- mouse position report 4 + * 100000 <- mouse wheel up 5 + * 1000000 <- mouse wheel down 6 + * 10000000 <- mouse wheel left 7 + * 100000000 <- mouse wheel right 8 + * 1000000000 <- button 4 has changed 9 + * (NOTE: buttons 6 to 10000000000 <- button 5 has changed 10 + * 9 aren't implemented 100000000000 <- button 6 has changed 11 + * in any flavor of 1000000000000 <- button 7 has changed 12 + * PDCurses yet!) 10000000000000 <- button 8 has changed 13 + * 100000000000000 <- button 9 has changed 14 + */ + +#define PDC_MOUSE_MOVED 0x0008 +#define PDC_MOUSE_POSITION 0x0010 +#define PDC_MOUSE_WHEEL_UP 0x0020 +#define PDC_MOUSE_WHEEL_DOWN 0x0040 +#define PDC_MOUSE_WHEEL_LEFT 0x0080 +#define PDC_MOUSE_WHEEL_RIGHT 0x0100 + +#define A_BUTTON_CHANGED (Mouse_status.changes & 7) +#define MOUSE_MOVED (Mouse_status.changes & PDC_MOUSE_MOVED) +#define MOUSE_POS_REPORT (Mouse_status.changes & PDC_MOUSE_POSITION) +#define BUTTON_CHANGED(x) (Mouse_status.changes & (1 << ((x) - ((x)<4 ? 1 : -5)))) +#define BUTTON_STATUS(x) (Mouse_status.button[(x) - 1]) +#define MOUSE_WHEEL_UP (Mouse_status.changes & PDC_MOUSE_WHEEL_UP) +#define MOUSE_WHEEL_DOWN (Mouse_status.changes & PDC_MOUSE_WHEEL_DOWN) +#define MOUSE_WHEEL_LEFT (Mouse_status.changes & PDC_MOUSE_WHEEL_LEFT) +#define MOUSE_WHEEL_RIGHT (Mouse_status.changes & PDC_MOUSE_WHEEL_RIGHT) + +/* mouse bit-masks */ + +#define BUTTON1_RELEASED 0x00000001L +#define BUTTON1_PRESSED 0x00000002L +#define BUTTON1_CLICKED 0x00000004L +#define BUTTON1_DOUBLE_CLICKED 0x00000008L +#define BUTTON1_TRIPLE_CLICKED 0x00000010L +#define BUTTON1_MOVED 0x00000010L /* PDCurses */ + +#define BUTTON2_RELEASED 0x00000020L +#define BUTTON2_PRESSED 0x00000040L +#define BUTTON2_CLICKED 0x00000080L +#define BUTTON2_DOUBLE_CLICKED 0x00000100L +#define BUTTON2_TRIPLE_CLICKED 0x00000200L +#define BUTTON2_MOVED 0x00000200L /* PDCurses */ + +#define BUTTON3_RELEASED 0x00000400L +#define BUTTON3_PRESSED 0x00000800L +#define BUTTON3_CLICKED 0x00001000L +#define BUTTON3_DOUBLE_CLICKED 0x00002000L +#define BUTTON3_TRIPLE_CLICKED 0x00004000L +#define BUTTON3_MOVED 0x00004000L /* PDCurses */ + +/* For the ncurses-compatible functions only, BUTTON4_PRESSED and + BUTTON5_PRESSED are returned for mouse scroll wheel up and down; + otherwise PDCurses doesn't support buttons 4 and 5... except + as described above for WinGUI, and perhaps to be extended to + other PDCurses flavors */ + +#define BUTTON4_RELEASED 0x00008000L +#define BUTTON4_PRESSED 0x00010000L +#define BUTTON4_CLICKED 0x00020000L +#define BUTTON4_DOUBLE_CLICKED 0x00040000L +#define BUTTON4_TRIPLE_CLICKED 0x00080000L + +#define BUTTON5_RELEASED 0x00100000L +#define BUTTON5_PRESSED 0x00200000L +#define BUTTON5_CLICKED 0x00400000L +#define BUTTON5_DOUBLE_CLICKED 0x00800000L +#define BUTTON5_TRIPLE_CLICKED 0x01000000L + +#define MOUSE_WHEEL_SCROLL 0x02000000L /* PDCurses */ +#define BUTTON_MODIFIER_SHIFT 0x04000000L /* PDCurses */ +#define BUTTON_MODIFIER_CONTROL 0x08000000L /* PDCurses */ +#define BUTTON_MODIFIER_ALT 0x10000000L /* PDCurses */ + +#define ALL_MOUSE_EVENTS 0x1fffffffL +#define REPORT_MOUSE_POSITION 0x20000000L + +/* ncurses mouse interface */ + +typedef unsigned long mmask_t; + +typedef struct +{ + short id; /* unused, always 0 */ + int x, y, z; /* x, y same as MOUSE_STATUS; z unused */ + mmask_t bstate; /* equivalent to changes + button[], but + in the same format as used for mousemask() */ +} MEVENT; + +#if defined(PDC_NCMOUSE) && !defined(NCURSES_MOUSE_VERSION) +# define NCURSES_MOUSE_VERSION 2 +#endif + +#ifdef NCURSES_MOUSE_VERSION +# define BUTTON_SHIFT BUTTON_MODIFIER_SHIFT +# define BUTTON_CONTROL BUTTON_MODIFIER_CONTROL +# define BUTTON_CTRL BUTTON_MODIFIER_CONTROL +# define BUTTON_ALT BUTTON_MODIFIER_ALT +#else +# define BUTTON_SHIFT PDC_BUTTON_SHIFT +# define BUTTON_CONTROL PDC_BUTTON_CONTROL +# define BUTTON_ALT PDC_BUTTON_ALT +#endif + +/*---------------------------------------------------------------------- + * + * Window and Screen Structures + * + */ + +typedef struct _win /* definition of a window */ +{ + int _cury; /* current pseudo-cursor */ + int _curx; + int _maxy; /* max window coordinates */ + int _maxx; + int _begy; /* origin on screen */ + int _begx; + int _flags; /* window properties */ + chtype _attrs; /* standard attributes and colors */ + chtype _bkgd; /* background, normally blank */ + bool _clear; /* causes clear at next refresh */ + bool _leaveit; /* leaves cursor where it is */ + bool _scroll; /* allows window scrolling */ + bool _nodelay; /* input character wait flag */ + bool _immed; /* immediate update flag */ + bool _sync; /* synchronise window ancestors */ + bool _use_keypad; /* flags keypad key mode active */ + chtype **_y; /* pointer to line pointer array */ + int *_firstch; /* first changed character in line */ + int *_lastch; /* last changed character in line */ + int _tmarg; /* top of scrolling region */ + int _bmarg; /* bottom of scrolling region */ + int _delayms; /* milliseconds of delay for getch() */ + int _parx, _pary; /* coords relative to parent (0,0) */ + struct _win *_parent; /* subwin's pointer to parent win */ +} WINDOW; + +/* Avoid using the SCREEN struct directly -- use the corresponding + functions if possible. This struct may eventually be made private. */ + +typedef struct +{ + bool alive; /* if initscr() called, and not endwin() */ + bool autocr; /* if cr -> lf */ + bool cbreak; /* if terminal unbuffered */ + bool echo; /* if terminal echo */ + bool raw_inp; /* raw input mode (v. cooked input) */ + bool raw_out; /* raw output mode (7 v. 8 bits) */ + bool audible; /* FALSE if the bell is visual */ + bool mono; /* TRUE if current screen is mono */ + bool resized; /* TRUE if TERM has been resized */ + bool orig_attr; /* TRUE if we have the original colors */ + short orig_fore; /* original screen foreground color */ + short orig_back; /* original screen foreground color */ + int cursrow; /* position of physical cursor */ + int curscol; /* position of physical cursor */ + int visibility; /* visibility of cursor */ + int orig_cursor; /* original cursor size */ + int lines; /* new value for LINES */ + int cols; /* new value for COLS */ + unsigned long _trap_mbe; /* trap these mouse button events */ + unsigned long _map_mbe_to_key; /* map mouse buttons to slk */ + int mouse_wait; /* time to wait (in ms) for a + button release after a press, in + order to count it as a click */ + int slklines; /* lines in use by slk_init() */ + WINDOW *slk_winptr; /* window for slk */ + int linesrippedoff; /* lines ripped off via ripoffline() */ + int linesrippedoffontop; /* lines ripped off on + top via ripoffline() */ + int delaytenths; /* 1/10ths second to wait block + getch() for */ + bool _preserve; /* TRUE if screen background + to be preserved */ + int _restore; /* specifies if screen background + to be restored, and how */ + bool save_key_modifiers; /* TRUE if each key modifiers saved + with each key press */ + bool return_key_modifiers; /* TRUE if modifier keys are + returned as "real" keys */ + bool key_code; /* TRUE if last key is a special key; + used internally by get_wch() */ +#ifdef XCURSES + int XcurscrSize; /* size of Xcurscr shared memory block */ + bool sb_on; + int sb_viewport_y; + int sb_viewport_x; + int sb_total_y; + int sb_total_x; + int sb_cur_y; + int sb_cur_x; + int exit_key; +#endif + short line_color; /* color of line attributes - default -1 */ +} SCREEN; + +/*---------------------------------------------------------------------- + * + * External Variables + * + */ + +#ifdef PDC_DLL_BUILD +# ifdef CURSES_LIBRARY +# define PDCEX __declspec(dllexport) extern +# else +# define PDCEX __declspec(dllimport) +# endif +#else +# define PDCEX extern +#endif + +PDCEX int LINES; /* terminal height */ +PDCEX int COLS; /* terminal width */ +PDCEX WINDOW *stdscr; /* the default screen window */ +PDCEX WINDOW *curscr; /* the current screen image */ +PDCEX SCREEN *SP; /* curses variables */ +PDCEX MOUSE_STATUS Mouse_status; +PDCEX int COLORS; +PDCEX int COLOR_PAIRS; +PDCEX int TABSIZE; +PDCEX chtype acs_map[]; /* alternate character set map */ +PDCEX char ttytype[]; /* terminal name/description */ +PDCEX PDC_version_info PDC_version; + +/*man-start************************************************************** + +Text Attributes +=============== + +Originally, PDCurses used a short (16 bits) for its chtype. To include +color, a number of things had to be sacrificed from the strict Unix and +System V support. The main problem was fitting all character attributes +and color into an unsigned char (all 8 bits!). + +Today, PDCurses by default uses a long (32 bits) for its chtype, as in +System V. The short chtype is still available, by undefining CHTYPE_LONG +and rebuilding the library. + +The following is the structure of a win->_attrs chtype: + +short form: + + +-----------------------------------------------+ + |15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0| + +-----------------------------------------------+ + color number | attrs | character eg 'a' + +The available non-color attributes are bold, reverse and blink. Others +have no effect. The high order char is an index into an array of +physical colors (defined in color.c) -- 32 foreground/background color +pairs (5 bits) plus 3 bits for other attributes. + +long form: + + +--------------------------------------------------------------------+ + |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|..| 2| 1| 0| + +--------------------------------------------------------------------+ + color number | modifiers | character eg 'a' + +The available non-color attributes are bold, underline, invisible, +right-line, left-line, protect, reverse and blink. 256 color pairs (8 +bits), 8 bits for other attributes, and 16 bits for character data. + + Note that there is now a "super-long" 64-bit form, available by +defining CHTYPE_LONG to be 2: + +------------------------------------------------------------------------------- +|63|62|61|60|59|..|34|33|32|31|30|29|28|..|22|21|20|19|18|17|16|..| 3| 2| 1| 0| +------------------------------------------------------------------------------- + color number | modifiers | character eg 'a' + + + We take five more bits for the character (thus allowing Unicode values +past 64K; UTF-16 can go up to 0x10ffff, requiring 21 bits total), and +four more bits for attributes. Three are currently used as A_OVERLINE, A_DIM, +and A_STRIKEOUT; one more is reserved for future use. 31 bits are then used +for color. These are usually just treated as the usual palette +indices, and range from 0 to 255. However, if bit 63 is +set, the remaining 30 bits are interpreted as foreground RGB (first +fifteen bits, five bits for each of the three channels) and background RGB +(same scheme using the remaining 15 bits.) + +**man-end****************************************************************/ + +/*** Video attribute macros ***/ + +#define A_NORMAL (chtype)0 + +#ifdef CHTYPE_LONG + +# if(CHTYPE_LONG >= 2) /* 64-bit chtypes */ + # define PDC_CHARTEXT_BITS 21 + # define A_CHARTEXT (chtype)( ((chtype)0x1 << PDC_CHARTEXT_BITS) - 1) + # define A_ALTCHARSET ((chtype)0x001 << PDC_CHARTEXT_BITS) + # define A_RIGHTLINE ((chtype)0x002 << PDC_CHARTEXT_BITS) + # define A_LEFTLINE ((chtype)0x004 << PDC_CHARTEXT_BITS) + # define A_INVIS ((chtype)0x008 << PDC_CHARTEXT_BITS) + # define A_UNDERLINE ((chtype)0x010 << PDC_CHARTEXT_BITS) + # define A_REVERSE ((chtype)0x020 << PDC_CHARTEXT_BITS) + # define A_BLINK ((chtype)0x040 << PDC_CHARTEXT_BITS) + # define A_BOLD ((chtype)0x080 << PDC_CHARTEXT_BITS) + # define A_OVERLINE ((chtype)0x100 << PDC_CHARTEXT_BITS) + # define A_STRIKEOUT ((chtype)0x200 << PDC_CHARTEXT_BITS) + # define A_DIM ((chtype)0x400 << PDC_CHARTEXT_BITS) +#if 0 + /* May come up with a use for this bit */ + /* someday; reserved for the future: */ + # define A_FUTURE_2 ((chtype)0x800 << PDC_CHARTEXT_BITS) +#endif + # define PDC_COLOR_SHIFT (PDC_CHARTEXT_BITS + 12) + # define A_COLOR ((chtype)0x7fffffff << PDC_COLOR_SHIFT) + # define A_RGB_COLOR ((chtype)0x40000000 << PDC_COLOR_SHIFT) + # define A_ATTRIBUTES (((chtype)0xfff << PDC_CHARTEXT_BITS) | A_COLOR) + # define A_RGB( rfore, gfore, bfore, rback, gback, bback) \ + (( (((chtype)(bfore) << 25) \ + | ((chtype)(gfore) << 20) \ + | ((chtype)(rfore) << 15) \ + | ((chtype)(bback) << 10) \ + | ((chtype)(gback) << 5) \ + | ((chtype)(rback) )) << PDC_COLOR_SHIFT) | A_RGB_COLOR) +# else /* plain ol' 32-bit chtypes */ + # define A_ALTCHARSET (chtype)0x00010000 + # define A_RIGHTLINE (chtype)0x00020000 + # define A_LEFTLINE (chtype)0x00040000 + # define A_INVIS (chtype)0x00080000 + # define A_UNDERLINE (chtype)0x00100000 + # define A_REVERSE (chtype)0x00200000 + # define A_BLINK (chtype)0x00400000 + # define A_BOLD (chtype)0x00800000 + # define A_COLOR (chtype)0xff000000 + # define A_RGB_COLOR A_NORMAL +#ifdef PDC_WIDE + # define A_CHARTEXT (chtype)0x0000ffff + # define A_ATTRIBUTES (chtype)0xffff0000 + # define A_DIM A_NORMAL + # define A_OVERLINE A_NORMAL + # define A_STRIKEOUT A_NORMAL +#else /* with 8-bit chars, we have bits for these attribs : */ + # define A_CHARTEXT (chtype)0x000000ff + # define A_ATTRIBUTES (chtype)0xffffe000 + # define A_DIM (chtype)0x00008000 + # define A_OVERLINE (chtype)0x00004000 + # define A_STRIKEOUT (chtype)0x00002000 +#endif + # define PDC_COLOR_SHIFT 24 +#endif + + +# define A_ITALIC A_INVIS +# define A_PROTECT (A_UNDERLINE | A_LEFTLINE | A_RIGHTLINE) + +#else /* 16-bit chtypes */ +# define A_BOLD (chtype)0x0100 /* X/Open */ +# define A_REVERSE (chtype)0x0200 /* X/Open */ +# define A_BLINK (chtype)0x0400 /* X/Open */ + +# define A_ATTRIBUTES (chtype)0xff00 /* X/Open */ +# define A_CHARTEXT (chtype)0x00ff /* X/Open */ +# define A_COLOR (chtype)0xf800 /* System V */ + +# define A_ALTCHARSET A_NORMAL /* X/Open */ +# define A_PROTECT A_NORMAL /* X/Open */ +# define A_UNDERLINE A_NORMAL /* X/Open */ +# define A_OVERLINE A_NORMAL /* X/Open */ +# define A_STRIKEOUT A_NORMAL /* X/Open */ + +# define A_LEFTLINE A_NORMAL +# define A_RIGHTLINE A_NORMAL +# define A_ITALIC A_NORMAL +# define A_INVIS A_NORMAL +# define A_RGB_COLOR A_NORMAL +# define A_DIM A_NORMAL + +# define PDC_COLOR_SHIFT 11 +#endif + +#define A_STANDOUT (A_REVERSE | A_BOLD) /* X/Open */ + +#define CHR_MSK A_CHARTEXT /* Obsolete */ +#define ATR_MSK A_ATTRIBUTES /* Obsolete */ +#define ATR_NRM A_NORMAL /* Obsolete */ + +/* For use with attr_t -- X/Open says, "these shall be distinct", so + this is a non-conforming implementation. */ + +#define WA_NORMAL A_NORMAL + +#define WA_ALTCHARSET A_ALTCHARSET +#define WA_BLINK A_BLINK +#define WA_BOLD A_BOLD +#define WA_DIM A_DIM +#define WA_INVIS A_INVIS +#define WA_LEFT A_LEFTLINE +#define WA_PROTECT A_PROTECT +#define WA_REVERSE A_REVERSE +#define WA_RIGHT A_RIGHTLINE +#define WA_STANDOUT A_STANDOUT +#define WA_UNDERLINE A_UNDERLINE + +#define WA_HORIZONTAL A_NORMAL +#define WA_LOW A_NORMAL +#define WA_TOP A_NORMAL +#define WA_VERTICAL A_NORMAL + +#define WA_ATTRIBUTES A_ATTRIBUTES + +/*** Alternate character set macros ***/ + +/* 'w' = 32-bit chtype; acs_map[] index | A_ALTCHARSET + 'n' = 16-bit chtype; it gets the fallback set because no bit is + available for A_ALTCHARSET */ + +#ifdef CHTYPE_LONG +# define PDC_ACS(w, n) ((chtype)w | A_ALTCHARSET) +#else +# define PDC_ACS(w, n) ((chtype)n) +#endif + +/* VT100-compatible symbols -- box chars */ + +#define ACS_LRCORNER PDC_ACS('V', '+') +#define ACS_URCORNER PDC_ACS('W', '+') +#define ACS_ULCORNER PDC_ACS('X', '+') +#define ACS_LLCORNER PDC_ACS('Y', '+') +#define ACS_PLUS PDC_ACS('Z', '+') +#define ACS_LTEE PDC_ACS('[', '+') +#define ACS_RTEE PDC_ACS('\\', '+') +#define ACS_BTEE PDC_ACS(']', '+') +#define ACS_TTEE PDC_ACS('^', '+') +#define ACS_HLINE PDC_ACS('_', '-') +#define ACS_VLINE PDC_ACS('`', '|') + +/* PDCurses-only ACS chars. Don't use if ncurses compatibility matters. +Some won't work in non-wide X11 builds (see 'acs_defs.h' for details). */ + +#define ACS_CENT PDC_ACS('{', 'c') +#define ACS_YEN PDC_ACS('|', 'y') +#define ACS_PESETA PDC_ACS('}', 'p') +#define ACS_HALF PDC_ACS('&', '/') +#define ACS_QUARTER PDC_ACS('\'', '/') +#define ACS_LEFT_ANG_QU PDC_ACS(')', '<') +#define ACS_RIGHT_ANG_QU PDC_ACS('*', '>') +#define ACS_D_HLINE PDC_ACS('a', '-') +#define ACS_D_VLINE PDC_ACS('b', '|') +#define ACS_CLUB PDC_ACS( 11, 'C') +#define ACS_HEART PDC_ACS( 12, 'H') +#define ACS_SPADE PDC_ACS( 13, 'S') +#define ACS_SMILE PDC_ACS( 14, 'O') +#define ACS_REV_SMILE PDC_ACS( 15, 'O') +#define ACS_MED_BULLET PDC_ACS( 16, '.') +#define ACS_WHITE_BULLET PDC_ACS( 17, 'O') +#define ACS_PILCROW PDC_ACS( 18, 'O') +#define ACS_SECTION PDC_ACS( 19, 'O') + +#define ACS_SUP2 PDC_ACS(',', '2') +#define ACS_ALPHA PDC_ACS('.', 'a') +#define ACS_BETA PDC_ACS('/', 'b') +#define ACS_GAMMA PDC_ACS('0', 'y') +#define ACS_UP_SIGMA PDC_ACS('1', 'S') +#define ACS_LO_SIGMA PDC_ACS('2', 's') +#define ACS_MU PDC_ACS('4', 'u') +#define ACS_TAU PDC_ACS('5', 't') +#define ACS_UP_PHI PDC_ACS('6', 'F') +#define ACS_THETA PDC_ACS('7', 't') +#define ACS_OMEGA PDC_ACS('8', 'w') +#define ACS_DELTA PDC_ACS('9', 'd') +#define ACS_INFINITY PDC_ACS('-', 'i') +#define ACS_LO_PHI PDC_ACS( 22, 'f') +#define ACS_EPSILON PDC_ACS(':', 'e') +#define ACS_INTERSECT PDC_ACS('e', 'u') +#define ACS_TRIPLE_BAR PDC_ACS('f', '=') +#define ACS_DIVISION PDC_ACS('c', '/') +#define ACS_APPROX_EQ PDC_ACS('d', '~') +#define ACS_SM_BULLET PDC_ACS('g', '.') +#define ACS_SQUARE_ROOT PDC_ACS('i', '!') +#define ACS_UBLOCK PDC_ACS('p', '^') +#define ACS_BBLOCK PDC_ACS('q', '_') +#define ACS_LBLOCK PDC_ACS('r', '<') +#define ACS_RBLOCK PDC_ACS('s', '>') + +#define ACS_A_ORDINAL PDC_ACS(20, 'a') +#define ACS_O_ORDINAL PDC_ACS(21, 'o') +#define ACS_INV_QUERY PDC_ACS(24, '?') +#define ACS_REV_NOT PDC_ACS(25, '!') +#define ACS_NOT PDC_ACS(26, '!') +#define ACS_INV_BANG PDC_ACS(23, '!') +#define ACS_UP_INTEGRAL PDC_ACS(27, '|') +#define ACS_LO_INTEGRAL PDC_ACS(28, '|') +#define ACS_SUP_N PDC_ACS(29, 'n') +#define ACS_CENTER_SQU PDC_ACS(30, 'x') +#define ACS_F_WITH_HOOK PDC_ACS(31, 'f') + +#define ACS_SD_LRCORNER PDC_ACS(';', '+') +#define ACS_SD_URCORNER PDC_ACS('<', '+') +#define ACS_SD_ULCORNER PDC_ACS('=', '+') +#define ACS_SD_LLCORNER PDC_ACS('>', '+') +#define ACS_SD_PLUS PDC_ACS('?', '+') +#define ACS_SD_LTEE PDC_ACS('@', '+') +#define ACS_SD_RTEE PDC_ACS('A', '+') +#define ACS_SD_BTEE PDC_ACS('B', '+') +#define ACS_SD_TTEE PDC_ACS('C', '+') + +#define ACS_D_LRCORNER PDC_ACS('D', '+') +#define ACS_D_URCORNER PDC_ACS('E', '+') +#define ACS_D_ULCORNER PDC_ACS('F', '+') +#define ACS_D_LLCORNER PDC_ACS('G', '+') +#define ACS_D_PLUS PDC_ACS('H', '+') +#define ACS_D_LTEE PDC_ACS('I', '+') +#define ACS_D_RTEE PDC_ACS('J', '+') +#define ACS_D_BTEE PDC_ACS('K', '+') +#define ACS_D_TTEE PDC_ACS('L', '+') + +#define ACS_DS_LRCORNER PDC_ACS('M', '+') +#define ACS_DS_URCORNER PDC_ACS('N', '+') +#define ACS_DS_ULCORNER PDC_ACS('O', '+') +#define ACS_DS_LLCORNER PDC_ACS('P', '+') +#define ACS_DS_PLUS PDC_ACS('Q', '+') +#define ACS_DS_LTEE PDC_ACS('R', '+') +#define ACS_DS_RTEE PDC_ACS('S', '+') +#define ACS_DS_BTEE PDC_ACS('T', '+') +#define ACS_DS_TTEE PDC_ACS('U', '+') + +/* VT100-compatible symbols -- other */ + +#define ACS_S1 PDC_ACS('l', '-') +#define ACS_S9 PDC_ACS('o', '_') +#define ACS_DIAMOND PDC_ACS('j', '+') +#define ACS_CKBOARD PDC_ACS('k', ':') +#define ACS_DEGREE PDC_ACS('w', '\'') +#define ACS_PLMINUS PDC_ACS('x', '#') +#define ACS_BULLET PDC_ACS('h', 'o') + +/* Teletype 5410v1 symbols -- these are defined in SysV curses, but + are not well-supported by most terminals. Stick to VT100 characters + for optimum portability. */ + +#define ACS_LARROW PDC_ACS('!', '<') +#define ACS_RARROW PDC_ACS(' ', '>') +#define ACS_DARROW PDC_ACS('#', 'v') +#define ACS_UARROW PDC_ACS('"', '^') +#define ACS_BOARD PDC_ACS('+', '#') +#define ACS_LTBOARD PDC_ACS('y', '#') +#define ACS_LANTERN PDC_ACS('z', '*') +#define ACS_BLOCK PDC_ACS('t', '#') + +/* That goes double for these -- undocumented SysV symbols. Don't use + them. */ + +#define ACS_S3 PDC_ACS('m', '-') +#define ACS_S7 PDC_ACS('n', '-') +#define ACS_LEQUAL PDC_ACS('u', '<') +#define ACS_GEQUAL PDC_ACS('v', '>') +#define ACS_PI PDC_ACS('$', 'n') +#define ACS_NEQUAL PDC_ACS('%', '+') +#define ACS_STERLING PDC_ACS('~', 'L') + +/* Box char aliases */ + +#define ACS_BSSB ACS_ULCORNER +#define ACS_SSBB ACS_LLCORNER +#define ACS_BBSS ACS_URCORNER +#define ACS_SBBS ACS_LRCORNER +#define ACS_SBSS ACS_RTEE +#define ACS_SSSB ACS_LTEE +#define ACS_SSBS ACS_BTEE +#define ACS_BSSS ACS_TTEE +#define ACS_BSBS ACS_HLINE +#define ACS_SBSB ACS_VLINE +#define ACS_SSSS ACS_PLUS + +/* cchar_t aliases */ + +#ifdef PDC_WIDE +# define WACS_LRCORNER (&(acs_map['V'])) +# define WACS_URCORNER (&(acs_map['W'])) +# define WACS_ULCORNER (&(acs_map['X'])) +# define WACS_LLCORNER (&(acs_map['Y'])) +# define WACS_PLUS (&(acs_map['Z'])) +# define WACS_LTEE (&(acs_map['['])) +# define WACS_RTEE (&(acs_map['\\'])) +# define WACS_BTEE (&(acs_map[']'])) +# define WACS_TTEE (&(acs_map['^'])) +# define WACS_HLINE (&(acs_map['_'])) +# define WACS_VLINE (&(acs_map['`'])) + +# define WACS_CENT (&(acs_map['{'])) +# define WACS_YEN (&(acs_map['|'])) +# define WACS_PESETA (&(acs_map['}'])) +# define WACS_HALF (&(acs_map['&'])) +# define WACS_QUARTER (&(acs_map['\''])) +# define WACS_LEFT_ANG_QU (&(acs_map[')'])) +# define WACS_RIGHT_ANG_QU (&(acs_map['*'])) +# define WACS_D_HLINE (&(acs_map['a'])) +# define WACS_D_VLINE (&(acs_map['b'])) +# define WACS_CLUB (&(acs_map[ 11])) +# define WACS_HEART (&(acs_map[ 12])) +# define WACS_SPADE (&(acs_map[ 13])) +# define WACS_SMILE (&(acs_map[ 14])) +# define WACS_REV_SMILE (&(acs_map[ 15])) +# define WACS_MED_BULLET (&(acs_map[ 16])) +# define WACS_WHITE_BULLET (&(acs_map[ 17])) +# define WACS_PILCROW (&(acs_map[ 18])) +# define WACS_SECTION (&(acs_map[ 19])) + +# define WACS_SUP2 (&(acs_map[','])) +# define WACS_ALPHA (&(acs_map['.'])) +# define WACS_BETA (&(acs_map['/'])) +# define WACS_GAMMA (&(acs_map['0'])) +# define WACS_UP_SIGMA (&(acs_map['1'])) +# define WACS_LO_SIGMA (&(acs_map['2'])) +# define WACS_MU (&(acs_map['4'])) +# define WACS_TAU (&(acs_map['5'])) +# define WACS_UP_PHI (&(acs_map['6'])) +# define WACS_THETA (&(acs_map['7'])) +# define WACS_OMEGA (&(acs_map['8'])) +# define WACS_DELTA (&(acs_map['9'])) +# define WACS_INFINITY (&(acs_map['-'])) +# define WACS_LO_PHI (&(acs_map[ 22])) +# define WACS_EPSILON (&(acs_map[':'])) +# define WACS_INTERSECT (&(acs_map['e'])) +# define WACS_TRIPLE_BAR (&(acs_map['f'])) +# define WACS_DIVISION (&(acs_map['c'])) +# define WACS_APPROX_EQ (&(acs_map['d'])) +# define WACS_SM_BULLET (&(acs_map['g'])) +# define WACS_SQUARE_ROOT (&(acs_map['i'])) +# define WACS_UBLOCK (&(acs_map['p'])) +# define WACS_BBLOCK (&(acs_map['q'])) +# define WACS_LBLOCK (&(acs_map['r'])) +# define WACS_RBLOCK (&(acs_map['s'])) + +# define WACS_A_ORDINAL (&(acs_map[20])) +# define WACS_O_ORDINAL (&(acs_map[21])) +# define WACS_INV_QUERY (&(acs_map[24])) +# define WACS_REV_NOT (&(acs_map[25])) +# define WACS_NOT (&(acs_map[26])) +# define WACS_INV_BANG (&(acs_map[23])) +# define WACS_UP_INTEGRAL (&(acs_map[27])) +# define WACS_LO_INTEGRAL (&(acs_map[28])) +# define WACS_SUP_N (&(acs_map[29])) +# define WACS_CENTER_SQU (&(acs_map[30])) +# define WACS_F_WITH_HOOK (&(acs_map[31])) + +# define WACS_SD_LRCORNER (&(acs_map[';'])) +# define WACS_SD_URCORNER (&(acs_map['<'])) +# define WACS_SD_ULCORNER (&(acs_map['='])) +# define WACS_SD_LLCORNER (&(acs_map['>'])) +# define WACS_SD_PLUS (&(acs_map['?'])) +# define WACS_SD_LTEE (&(acs_map['@'])) +# define WACS_SD_RTEE (&(acs_map['A'])) +# define WACS_SD_BTEE (&(acs_map['B'])) +# define WACS_SD_TTEE (&(acs_map['C'])) + +# define WACS_D_LRCORNER (&(acs_map['D'])) +# define WACS_D_URCORNER (&(acs_map['E'])) +# define WACS_D_ULCORNER (&(acs_map['F'])) +# define WACS_D_LLCORNER (&(acs_map['G'])) +# define WACS_D_PLUS (&(acs_map['H'])) +# define WACS_D_LTEE (&(acs_map['I'])) +# define WACS_D_RTEE (&(acs_map['J'])) +# define WACS_D_BTEE (&(acs_map['K'])) +# define WACS_D_TTEE (&(acs_map['L'])) + +# define WACS_DS_LRCORNER (&(acs_map['M'])) +# define WACS_DS_URCORNER (&(acs_map['N'])) +# define WACS_DS_ULCORNER (&(acs_map['O'])) +# define WACS_DS_LLCORNER (&(acs_map['P'])) +# define WACS_DS_PLUS (&(acs_map['Q'])) +# define WACS_DS_LTEE (&(acs_map['R'])) +# define WACS_DS_RTEE (&(acs_map['S'])) +# define WACS_DS_BTEE (&(acs_map['T'])) +# define WACS_DS_TTEE (&(acs_map['U'])) + +# define WACS_S1 (&(acs_map['l'])) +# define WACS_S9 (&(acs_map['o'])) +# define WACS_DIAMOND (&(acs_map['j'])) +# define WACS_CKBOARD (&(acs_map['k'])) +# define WACS_DEGREE (&(acs_map['w'])) +# define WACS_PLMINUS (&(acs_map['x'])) +# define WACS_BULLET (&(acs_map['h'])) + + +# define WACS_LARROW (&(acs_map['!'])) +# define WACS_RARROW (&(acs_map[' '])) +# define WACS_DARROW (&(acs_map['#'])) +# define WACS_UARROW (&(acs_map['"'])) +# define WACS_BOARD (&(acs_map['+'])) +# define WACS_LTBOARD (&(acs_map['y'])) +# define WACS_LANTERN (&(acs_map['z'])) +# define WACS_BLOCK (&(acs_map['t'])) + +# define WACS_S3 (&(acs_map['m'])) +# define WACS_S7 (&(acs_map['n'])) +# define WACS_LEQUAL (&(acs_map['u'])) +# define WACS_GEQUAL (&(acs_map['v'])) +# define WACS_PI (&(acs_map['$'])) +# define WACS_NEQUAL (&(acs_map['%'])) +# define WACS_STERLING (&(acs_map['~'])) + +# define WACS_BSSB WACS_ULCORNER +# define WACS_SSBB WACS_LLCORNER +# define WACS_BBSS WACS_URCORNER +# define WACS_SBBS WACS_LRCORNER +# define WACS_SBSS WACS_RTEE +# define WACS_SSSB WACS_LTEE +# define WACS_SSBS WACS_BTEE +# define WACS_BSSS WACS_TTEE +# define WACS_BSBS WACS_HLINE +# define WACS_SBSB WACS_VLINE +# define WACS_SSSS WACS_PLUS +#endif + +/*** Color macros ***/ + +#define COLOR_BLACK 0 + +#ifdef PDC_RGB /* RGB */ +# define COLOR_RED 1 +# define COLOR_GREEN 2 +# define COLOR_BLUE 4 +#else /* BGR */ +# define COLOR_BLUE 1 +# define COLOR_GREEN 2 +# define COLOR_RED 4 +#endif + +#define COLOR_CYAN (COLOR_BLUE | COLOR_GREEN) +#define COLOR_MAGENTA (COLOR_RED | COLOR_BLUE) +#define COLOR_YELLOW (COLOR_RED | COLOR_GREEN) + +#define COLOR_WHITE 7 + +/*---------------------------------------------------------------------- + * + * Function and Keypad Key Definitions + * Many are just for compatibility + * + */ + +#ifdef PDC_WIDE + #define KEY_OFFSET 0xec00 +#else + #define KEY_OFFSET 0x100 +#endif + +#define KEY_CODE_YES (KEY_OFFSET + 0x00) /* If get_wch() gives a key code */ + +#define KEY_BREAK (KEY_OFFSET + 0x01) /* Not on PC KBD */ +#define KEY_DOWN (KEY_OFFSET + 0x02) /* Down arrow key */ +#define KEY_UP (KEY_OFFSET + 0x03) /* Up arrow key */ +#define KEY_LEFT (KEY_OFFSET + 0x04) /* Left arrow key */ +#define KEY_RIGHT (KEY_OFFSET + 0x05) /* Right arrow key */ +#define KEY_HOME (KEY_OFFSET + 0x06) /* home key */ +#define KEY_BACKSPACE (KEY_OFFSET + 0x07) /* not on pc */ +#define KEY_F0 (KEY_OFFSET + 0x08) /* function keys; 64 reserved */ + +#define KEY_DL (KEY_OFFSET + 0x48) /* delete line */ +#define KEY_IL (KEY_OFFSET + 0x49) /* insert line */ +#define KEY_DC (KEY_OFFSET + 0x4a) /* delete character */ +#define KEY_IC (KEY_OFFSET + 0x4b) /* insert char or enter ins mode */ +#define KEY_EIC (KEY_OFFSET + 0x4c) /* exit insert char mode */ +#define KEY_CLEAR (KEY_OFFSET + 0x4d) /* clear screen */ +#define KEY_EOS (KEY_OFFSET + 0x4e) /* clear to end of screen */ +#define KEY_EOL (KEY_OFFSET + 0x4f) /* clear to end of line */ +#define KEY_SF (KEY_OFFSET + 0x50) /* scroll 1 line forward */ +#define KEY_SR (KEY_OFFSET + 0x51) /* scroll 1 line back (reverse) */ +#define KEY_NPAGE (KEY_OFFSET + 0x52) /* next page */ +#define KEY_PPAGE (KEY_OFFSET + 0x53) /* previous page */ +#define KEY_STAB (KEY_OFFSET + 0x54) /* set tab */ +#define KEY_CTAB (KEY_OFFSET + 0x55) /* clear tab */ +#define KEY_CATAB (KEY_OFFSET + 0x56) /* clear all tabs */ +#define KEY_ENTER (KEY_OFFSET + 0x57) /* enter or send (unreliable) */ +#define KEY_SRESET (KEY_OFFSET + 0x58) /* soft/reset (partial/unreliable) */ +#define KEY_RESET (KEY_OFFSET + 0x59) /* reset/hard reset (unreliable) */ +#define KEY_PRINT (KEY_OFFSET + 0x5a) /* print/copy */ +#define KEY_LL (KEY_OFFSET + 0x5b) /* home down/bottom (lower left) */ +#define KEY_ABORT (KEY_OFFSET + 0x5c) /* abort/terminate key (any) */ +#define KEY_SHELP (KEY_OFFSET + 0x5d) /* short help */ +#define KEY_LHELP (KEY_OFFSET + 0x5e) /* long help */ +#define KEY_BTAB (KEY_OFFSET + 0x5f) /* Back tab key */ +#define KEY_BEG (KEY_OFFSET + 0x60) /* beg(inning) key */ +#define KEY_CANCEL (KEY_OFFSET + 0x61) /* cancel key */ +#define KEY_CLOSE (KEY_OFFSET + 0x62) /* close key */ +#define KEY_COMMAND (KEY_OFFSET + 0x63) /* cmd (command) key */ +#define KEY_COPY (KEY_OFFSET + 0x64) /* copy key */ +#define KEY_CREATE (KEY_OFFSET + 0x65) /* create key */ +#define KEY_END (KEY_OFFSET + 0x66) /* end key */ +#define KEY_EXIT (KEY_OFFSET + 0x67) /* exit key */ +#define KEY_FIND (KEY_OFFSET + 0x68) /* find key */ +#define KEY_HELP (KEY_OFFSET + 0x69) /* help key */ +#define KEY_MARK (KEY_OFFSET + 0x6a) /* mark key */ +#define KEY_MESSAGE (KEY_OFFSET + 0x6b) /* message key */ +#define KEY_MOVE (KEY_OFFSET + 0x6c) /* move key */ +#define KEY_NEXT (KEY_OFFSET + 0x6d) /* next object key */ +#define KEY_OPEN (KEY_OFFSET + 0x6e) /* open key */ +#define KEY_OPTIONS (KEY_OFFSET + 0x6f) /* options key */ +#define KEY_PREVIOUS (KEY_OFFSET + 0x70) /* previous object key */ +#define KEY_REDO (KEY_OFFSET + 0x71) /* redo key */ +#define KEY_REFERENCE (KEY_OFFSET + 0x72) /* ref(erence) key */ +#define KEY_REFRESH (KEY_OFFSET + 0x73) /* refresh key */ +#define KEY_REPLACE (KEY_OFFSET + 0x74) /* replace key */ +#define KEY_RESTART (KEY_OFFSET + 0x75) /* restart key */ +#define KEY_RESUME (KEY_OFFSET + 0x76) /* resume key */ +#define KEY_SAVE (KEY_OFFSET + 0x77) /* save key */ +#define KEY_SBEG (KEY_OFFSET + 0x78) /* shifted beginning key */ +#define KEY_SCANCEL (KEY_OFFSET + 0x79) /* shifted cancel key */ +#define KEY_SCOMMAND (KEY_OFFSET + 0x7a) /* shifted command key */ +#define KEY_SCOPY (KEY_OFFSET + 0x7b) /* shifted copy key */ +#define KEY_SCREATE (KEY_OFFSET + 0x7c) /* shifted create key */ +#define KEY_SDC (KEY_OFFSET + 0x7d) /* shifted delete char key */ +#define KEY_SDL (KEY_OFFSET + 0x7e) /* shifted delete line key */ +#define KEY_SELECT (KEY_OFFSET + 0x7f) /* select key */ +#define KEY_SEND (KEY_OFFSET + 0x80) /* shifted end key */ +#define KEY_SEOL (KEY_OFFSET + 0x81) /* shifted clear line key */ +#define KEY_SEXIT (KEY_OFFSET + 0x82) /* shifted exit key */ +#define KEY_SFIND (KEY_OFFSET + 0x83) /* shifted find key */ +#define KEY_SHOME (KEY_OFFSET + 0x84) /* shifted home key */ +#define KEY_SIC (KEY_OFFSET + 0x85) /* shifted input key */ + +#define KEY_SLEFT (KEY_OFFSET + 0x87) /* shifted left arrow key */ +#define KEY_SMESSAGE (KEY_OFFSET + 0x88) /* shifted message key */ +#define KEY_SMOVE (KEY_OFFSET + 0x89) /* shifted move key */ +#define KEY_SNEXT (KEY_OFFSET + 0x8a) /* shifted next key */ +#define KEY_SOPTIONS (KEY_OFFSET + 0x8b) /* shifted options key */ +#define KEY_SPREVIOUS (KEY_OFFSET + 0x8c) /* shifted prev key */ +#define KEY_SPRINT (KEY_OFFSET + 0x8d) /* shifted print key */ +#define KEY_SREDO (KEY_OFFSET + 0x8e) /* shifted redo key */ +#define KEY_SREPLACE (KEY_OFFSET + 0x8f) /* shifted replace key */ +#define KEY_SRIGHT (KEY_OFFSET + 0x90) /* shifted right arrow */ +#define KEY_SRSUME (KEY_OFFSET + 0x91) /* shifted resume key */ +#define KEY_SSAVE (KEY_OFFSET + 0x92) /* shifted save key */ +#define KEY_SSUSPEND (KEY_OFFSET + 0x93) /* shifted suspend key */ +#define KEY_SUNDO (KEY_OFFSET + 0x94) /* shifted undo key */ +#define KEY_SUSPEND (KEY_OFFSET + 0x95) /* suspend key */ +#define KEY_UNDO (KEY_OFFSET + 0x96) /* undo key */ + +/* PDCurses-specific key definitions -- PC only */ + +#define ALT_0 (KEY_OFFSET + 0x97) +#define ALT_1 (KEY_OFFSET + 0x98) +#define ALT_2 (KEY_OFFSET + 0x99) +#define ALT_3 (KEY_OFFSET + 0x9a) +#define ALT_4 (KEY_OFFSET + 0x9b) +#define ALT_5 (KEY_OFFSET + 0x9c) +#define ALT_6 (KEY_OFFSET + 0x9d) +#define ALT_7 (KEY_OFFSET + 0x9e) +#define ALT_8 (KEY_OFFSET + 0x9f) +#define ALT_9 (KEY_OFFSET + 0xa0) +#define ALT_A (KEY_OFFSET + 0xa1) +#define ALT_B (KEY_OFFSET + 0xa2) +#define ALT_C (KEY_OFFSET + 0xa3) +#define ALT_D (KEY_OFFSET + 0xa4) +#define ALT_E (KEY_OFFSET + 0xa5) +#define ALT_F (KEY_OFFSET + 0xa6) +#define ALT_G (KEY_OFFSET + 0xa7) +#define ALT_H (KEY_OFFSET + 0xa8) +#define ALT_I (KEY_OFFSET + 0xa9) +#define ALT_J (KEY_OFFSET + 0xaa) +#define ALT_K (KEY_OFFSET + 0xab) +#define ALT_L (KEY_OFFSET + 0xac) +#define ALT_M (KEY_OFFSET + 0xad) +#define ALT_N (KEY_OFFSET + 0xae) +#define ALT_O (KEY_OFFSET + 0xaf) +#define ALT_P (KEY_OFFSET + 0xb0) +#define ALT_Q (KEY_OFFSET + 0xb1) +#define ALT_R (KEY_OFFSET + 0xb2) +#define ALT_S (KEY_OFFSET + 0xb3) +#define ALT_T (KEY_OFFSET + 0xb4) +#define ALT_U (KEY_OFFSET + 0xb5) +#define ALT_V (KEY_OFFSET + 0xb6) +#define ALT_W (KEY_OFFSET + 0xb7) +#define ALT_X (KEY_OFFSET + 0xb8) +#define ALT_Y (KEY_OFFSET + 0xb9) +#define ALT_Z (KEY_OFFSET + 0xba) + +#define CTL_LEFT (KEY_OFFSET + 0xbb) /* Control-Left-Arrow */ +#define CTL_RIGHT (KEY_OFFSET + 0xbc) +#define CTL_PGUP (KEY_OFFSET + 0xbd) +#define CTL_PGDN (KEY_OFFSET + 0xbe) +#define CTL_HOME (KEY_OFFSET + 0xbf) +#define CTL_END (KEY_OFFSET + 0xc0) + +#define KEY_A1 (KEY_OFFSET + 0xc1) /* upper left on Virtual keypad */ +#define KEY_A2 (KEY_OFFSET + 0xc2) /* upper middle on Virt. keypad */ +#define KEY_A3 (KEY_OFFSET + 0xc3) /* upper right on Vir. keypad */ +#define KEY_B1 (KEY_OFFSET + 0xc4) /* middle left on Virt. keypad */ +#define KEY_B2 (KEY_OFFSET + 0xc5) /* center on Virt. keypad */ +#define KEY_B3 (KEY_OFFSET + 0xc6) /* middle right on Vir. keypad */ +#define KEY_C1 (KEY_OFFSET + 0xc7) /* lower left on Virt. keypad */ +#define KEY_C2 (KEY_OFFSET + 0xc8) /* lower middle on Virt. keypad */ +#define KEY_C3 (KEY_OFFSET + 0xc9) /* lower right on Vir. keypad */ + +#define PADSLASH (KEY_OFFSET + 0xca) /* slash on keypad */ +#define PADENTER (KEY_OFFSET + 0xcb) /* enter on keypad */ +#define CTL_PADENTER (KEY_OFFSET + 0xcc) /* ctl-enter on keypad */ +#define ALT_PADENTER (KEY_OFFSET + 0xcd) /* alt-enter on keypad */ +#define PADSTOP (KEY_OFFSET + 0xce) /* stop on keypad */ +#define PADSTAR (KEY_OFFSET + 0xcf) /* star on keypad */ +#define PADMINUS (KEY_OFFSET + 0xd0) /* minus on keypad */ +#define PADPLUS (KEY_OFFSET + 0xd1) /* plus on keypad */ +#define CTL_PADSTOP (KEY_OFFSET + 0xd2) /* ctl-stop on keypad */ +#define CTL_PADCENTER (KEY_OFFSET + 0xd3) /* ctl-enter on keypad */ +#define CTL_PADPLUS (KEY_OFFSET + 0xd4) /* ctl-plus on keypad */ +#define CTL_PADMINUS (KEY_OFFSET + 0xd5) /* ctl-minus on keypad */ +#define CTL_PADSLASH (KEY_OFFSET + 0xd6) /* ctl-slash on keypad */ +#define CTL_PADSTAR (KEY_OFFSET + 0xd7) /* ctl-star on keypad */ +#define ALT_PADPLUS (KEY_OFFSET + 0xd8) /* alt-plus on keypad */ +#define ALT_PADMINUS (KEY_OFFSET + 0xd9) /* alt-minus on keypad */ +#define ALT_PADSLASH (KEY_OFFSET + 0xda) /* alt-slash on keypad */ +#define ALT_PADSTAR (KEY_OFFSET + 0xdb) /* alt-star on keypad */ +#define ALT_PADSTOP (KEY_OFFSET + 0xdc) /* alt-stop on keypad */ +#define CTL_INS (KEY_OFFSET + 0xdd) /* ctl-insert */ +#define ALT_DEL (KEY_OFFSET + 0xde) /* alt-delete */ +#define ALT_INS (KEY_OFFSET + 0xdf) /* alt-insert */ +#define CTL_UP (KEY_OFFSET + 0xe0) /* ctl-up arrow */ +#define CTL_DOWN (KEY_OFFSET + 0xe1) /* ctl-down arrow */ +#define CTL_TAB (KEY_OFFSET + 0xe2) /* ctl-tab */ +#define ALT_TAB (KEY_OFFSET + 0xe3) +#define ALT_MINUS (KEY_OFFSET + 0xe4) +#define ALT_EQUAL (KEY_OFFSET + 0xe5) +#define ALT_HOME (KEY_OFFSET + 0xe6) +#define ALT_PGUP (KEY_OFFSET + 0xe7) +#define ALT_PGDN (KEY_OFFSET + 0xe8) +#define ALT_END (KEY_OFFSET + 0xe9) +#define ALT_UP (KEY_OFFSET + 0xea) /* alt-up arrow */ +#define ALT_DOWN (KEY_OFFSET + 0xeb) /* alt-down arrow */ +#define ALT_RIGHT (KEY_OFFSET + 0xec) /* alt-right arrow */ +#define ALT_LEFT (KEY_OFFSET + 0xed) /* alt-left arrow */ +#define ALT_ENTER (KEY_OFFSET + 0xee) /* alt-enter */ +#define ALT_ESC (KEY_OFFSET + 0xef) /* alt-escape */ +#define ALT_BQUOTE (KEY_OFFSET + 0xf0) /* alt-back quote */ +#define ALT_LBRACKET (KEY_OFFSET + 0xf1) /* alt-left bracket */ +#define ALT_RBRACKET (KEY_OFFSET + 0xf2) /* alt-right bracket */ +#define ALT_SEMICOLON (KEY_OFFSET + 0xf3) /* alt-semi-colon */ +#define ALT_FQUOTE (KEY_OFFSET + 0xf4) /* alt-forward quote */ +#define ALT_COMMA (KEY_OFFSET + 0xf5) /* alt-comma */ +#define ALT_STOP (KEY_OFFSET + 0xf6) /* alt-stop */ +#define ALT_FSLASH (KEY_OFFSET + 0xf7) /* alt-forward slash */ +#define ALT_BKSP (KEY_OFFSET + 0xf8) /* alt-backspace */ +#define CTL_BKSP (KEY_OFFSET + 0xf9) /* ctl-backspace */ +#define PAD0 (KEY_OFFSET + 0xfa) /* keypad 0 */ + +#define CTL_PAD0 (KEY_OFFSET + 0xfb) /* ctl-keypad 0 */ +#define CTL_PAD1 (KEY_OFFSET + 0xfc) +#define CTL_PAD2 (KEY_OFFSET + 0xfd) +#define CTL_PAD3 (KEY_OFFSET + 0xfe) +#define CTL_PAD4 (KEY_OFFSET + 0xff) +#define CTL_PAD5 (KEY_OFFSET + 0x100) +#define CTL_PAD6 (KEY_OFFSET + 0x101) +#define CTL_PAD7 (KEY_OFFSET + 0x102) +#define CTL_PAD8 (KEY_OFFSET + 0x103) +#define CTL_PAD9 (KEY_OFFSET + 0x104) + +#define ALT_PAD0 (KEY_OFFSET + 0x105) /* alt-keypad 0 */ +#define ALT_PAD1 (KEY_OFFSET + 0x106) +#define ALT_PAD2 (KEY_OFFSET + 0x107) +#define ALT_PAD3 (KEY_OFFSET + 0x108) +#define ALT_PAD4 (KEY_OFFSET + 0x109) +#define ALT_PAD5 (KEY_OFFSET + 0x10a) +#define ALT_PAD6 (KEY_OFFSET + 0x10b) +#define ALT_PAD7 (KEY_OFFSET + 0x10c) +#define ALT_PAD8 (KEY_OFFSET + 0x10d) +#define ALT_PAD9 (KEY_OFFSET + 0x10e) + +#define CTL_DEL (KEY_OFFSET + 0x10f) /* clt-delete */ +#define ALT_BSLASH (KEY_OFFSET + 0x110) /* alt-back slash */ +#define CTL_ENTER (KEY_OFFSET + 0x111) /* ctl-enter */ + +#define SHF_PADENTER (KEY_OFFSET + 0x112) /* shift-enter on keypad */ +#define SHF_PADSLASH (KEY_OFFSET + 0x113) /* shift-slash on keypad */ +#define SHF_PADSTAR (KEY_OFFSET + 0x114) /* shift-star on keypad */ +#define SHF_PADPLUS (KEY_OFFSET + 0x115) /* shift-plus on keypad */ +#define SHF_PADMINUS (KEY_OFFSET + 0x116) /* shift-minus on keypad */ +#define SHF_UP (KEY_OFFSET + 0x117) /* shift-up on keypad */ +#define SHF_DOWN (KEY_OFFSET + 0x118) /* shift-down on keypad */ +#define SHF_IC (KEY_OFFSET + 0x119) /* shift-insert on keypad */ +#define SHF_DC (KEY_OFFSET + 0x11a) /* shift-delete on keypad */ + +#define KEY_MOUSE (KEY_OFFSET + 0x11b) /* "mouse" key */ +#define KEY_SHIFT_L (KEY_OFFSET + 0x11c) /* Left-shift */ +#define KEY_SHIFT_R (KEY_OFFSET + 0x11d) /* Right-shift */ +#define KEY_CONTROL_L (KEY_OFFSET + 0x11e) /* Left-control */ +#define KEY_CONTROL_R (KEY_OFFSET + 0x11f) /* Right-control */ +#define KEY_ALT_L (KEY_OFFSET + 0x120) /* Left-alt */ +#define KEY_ALT_R (KEY_OFFSET + 0x121) /* Right-alt */ +#define KEY_RESIZE (KEY_OFFSET + 0x122) /* Window resize */ +#define KEY_SUP (KEY_OFFSET + 0x123) /* Shifted up arrow */ +#define KEY_SDOWN (KEY_OFFSET + 0x124) /* Shifted down arrow */ + + /* The following were added 2011 Sep 14, and are */ + /* not returned by most flavors of PDCurses: */ + +#define CTL_SEMICOLON (KEY_OFFSET + 0x125) +#define CTL_EQUAL (KEY_OFFSET + 0x126) +#define CTL_COMMA (KEY_OFFSET + 0x127) +#define CTL_MINUS (KEY_OFFSET + 0x128) +#define CTL_STOP (KEY_OFFSET + 0x129) +#define CTL_FSLASH (KEY_OFFSET + 0x12a) +#define CTL_BQUOTE (KEY_OFFSET + 0x12b) + +#define KEY_APPS (KEY_OFFSET + 0x12c) +#define KEY_SAPPS (KEY_OFFSET + 0x12d) +#define CTL_APPS (KEY_OFFSET + 0x12e) +#define ALT_APPS (KEY_OFFSET + 0x12f) + +#define KEY_PAUSE (KEY_OFFSET + 0x130) +#define KEY_SPAUSE (KEY_OFFSET + 0x131) +#define CTL_PAUSE (KEY_OFFSET + 0x132) + +#define KEY_PRINTSCREEN (KEY_OFFSET + 0x133) +#define ALT_PRINTSCREEN (KEY_OFFSET + 0x134) +#define KEY_SCROLLLOCK (KEY_OFFSET + 0x135) +#define ALT_SCROLLLOCK (KEY_OFFSET + 0x136) + +#define CTL_0 (KEY_OFFSET + 0x137) +#define CTL_1 (KEY_OFFSET + 0x138) +#define CTL_2 (KEY_OFFSET + 0x139) +#define CTL_3 (KEY_OFFSET + 0x13a) +#define CTL_4 (KEY_OFFSET + 0x13b) +#define CTL_5 (KEY_OFFSET + 0x13c) +#define CTL_6 (KEY_OFFSET + 0x13d) +#define CTL_7 (KEY_OFFSET + 0x13e) +#define CTL_8 (KEY_OFFSET + 0x13f) +#define CTL_9 (KEY_OFFSET + 0x140) + +#define KEY_BROWSER_BACK (KEY_OFFSET + 0x141) +#define KEY_SBROWSER_BACK (KEY_OFFSET + 0x142) +#define KEY_CBROWSER_BACK (KEY_OFFSET + 0x143) +#define KEY_ABROWSER_BACK (KEY_OFFSET + 0x144) +#define KEY_BROWSER_FWD (KEY_OFFSET + 0x145) +#define KEY_SBROWSER_FWD (KEY_OFFSET + 0x146) +#define KEY_CBROWSER_FWD (KEY_OFFSET + 0x147) +#define KEY_ABROWSER_FWD (KEY_OFFSET + 0x148) +#define KEY_BROWSER_REF (KEY_OFFSET + 0x149) +#define KEY_SBROWSER_REF (KEY_OFFSET + 0x14A) +#define KEY_CBROWSER_REF (KEY_OFFSET + 0x14B) +#define KEY_ABROWSER_REF (KEY_OFFSET + 0x14C) +#define KEY_BROWSER_STOP (KEY_OFFSET + 0x14D) +#define KEY_SBROWSER_STOP (KEY_OFFSET + 0x14E) +#define KEY_CBROWSER_STOP (KEY_OFFSET + 0x14F) +#define KEY_ABROWSER_STOP (KEY_OFFSET + 0x150) +#define KEY_SEARCH (KEY_OFFSET + 0x151) +#define KEY_SSEARCH (KEY_OFFSET + 0x152) +#define KEY_CSEARCH (KEY_OFFSET + 0x153) +#define KEY_ASEARCH (KEY_OFFSET + 0x154) +#define KEY_FAVORITES (KEY_OFFSET + 0x155) +#define KEY_SFAVORITES (KEY_OFFSET + 0x156) +#define KEY_CFAVORITES (KEY_OFFSET + 0x157) +#define KEY_AFAVORITES (KEY_OFFSET + 0x158) +#define KEY_BROWSER_HOME (KEY_OFFSET + 0x159) +#define KEY_SBROWSER_HOME (KEY_OFFSET + 0x15A) +#define KEY_CBROWSER_HOME (KEY_OFFSET + 0x15B) +#define KEY_ABROWSER_HOME (KEY_OFFSET + 0x15C) +#define KEY_VOLUME_MUTE (KEY_OFFSET + 0x15D) +#define KEY_SVOLUME_MUTE (KEY_OFFSET + 0x15E) +#define KEY_CVOLUME_MUTE (KEY_OFFSET + 0x15F) +#define KEY_AVOLUME_MUTE (KEY_OFFSET + 0x160) +#define KEY_VOLUME_DOWN (KEY_OFFSET + 0x161) +#define KEY_SVOLUME_DOWN (KEY_OFFSET + 0x162) +#define KEY_CVOLUME_DOWN (KEY_OFFSET + 0x163) +#define KEY_AVOLUME_DOWN (KEY_OFFSET + 0x164) +#define KEY_VOLUME_UP (KEY_OFFSET + 0x165) +#define KEY_SVOLUME_UP (KEY_OFFSET + 0x166) +#define KEY_CVOLUME_UP (KEY_OFFSET + 0x167) +#define KEY_AVOLUME_UP (KEY_OFFSET + 0x168) +#define KEY_NEXT_TRACK (KEY_OFFSET + 0x169) +#define KEY_SNEXT_TRACK (KEY_OFFSET + 0x16A) +#define KEY_CNEXT_TRACK (KEY_OFFSET + 0x16B) +#define KEY_ANEXT_TRACK (KEY_OFFSET + 0x16C) +#define KEY_PREV_TRACK (KEY_OFFSET + 0x16D) +#define KEY_SPREV_TRACK (KEY_OFFSET + 0x16E) +#define KEY_CPREV_TRACK (KEY_OFFSET + 0x16F) +#define KEY_APREV_TRACK (KEY_OFFSET + 0x170) +#define KEY_MEDIA_STOP (KEY_OFFSET + 0x171) +#define KEY_SMEDIA_STOP (KEY_OFFSET + 0x172) +#define KEY_CMEDIA_STOP (KEY_OFFSET + 0x173) +#define KEY_AMEDIA_STOP (KEY_OFFSET + 0x174) +#define KEY_PLAY_PAUSE (KEY_OFFSET + 0x175) +#define KEY_SPLAY_PAUSE (KEY_OFFSET + 0x176) +#define KEY_CPLAY_PAUSE (KEY_OFFSET + 0x177) +#define KEY_APLAY_PAUSE (KEY_OFFSET + 0x178) +#define KEY_LAUNCH_MAIL (KEY_OFFSET + 0x179) +#define KEY_SLAUNCH_MAIL (KEY_OFFSET + 0x17A) +#define KEY_CLAUNCH_MAIL (KEY_OFFSET + 0x17B) +#define KEY_ALAUNCH_MAIL (KEY_OFFSET + 0x17C) +#define KEY_MEDIA_SELECT (KEY_OFFSET + 0x17D) +#define KEY_SMEDIA_SELECT (KEY_OFFSET + 0x17E) +#define KEY_CMEDIA_SELECT (KEY_OFFSET + 0x17F) +#define KEY_AMEDIA_SELECT (KEY_OFFSET + 0x180) +#define KEY_LAUNCH_APP1 (KEY_OFFSET + 0x181) +#define KEY_SLAUNCH_APP1 (KEY_OFFSET + 0x182) +#define KEY_CLAUNCH_APP1 (KEY_OFFSET + 0x183) +#define KEY_ALAUNCH_APP1 (KEY_OFFSET + 0x184) +#define KEY_LAUNCH_APP2 (KEY_OFFSET + 0x185) +#define KEY_SLAUNCH_APP2 (KEY_OFFSET + 0x186) +#define KEY_CLAUNCH_APP2 (KEY_OFFSET + 0x187) +#define KEY_ALAUNCH_APP2 (KEY_OFFSET + 0x188) + +#define KEY_MIN KEY_BREAK /* Minimum curses key value */ +#define KEY_MAX KEY_ALAUNCH_APP2 /* Maximum curses key */ + +#define KEY_F(n) (KEY_F0 + (n)) + +/*---------------------------------------------------------------------- + * + * PDCurses Function Declarations + * + */ + +/* Standard */ + +PDCEX int addch(const chtype); +PDCEX int addchnstr(const chtype *, int); +PDCEX int addchstr(const chtype *); +PDCEX int addnstr(const char *, int); +PDCEX int addstr(const char *); +PDCEX int attroff(chtype); +PDCEX int attron(chtype); +PDCEX int attrset(chtype); +PDCEX int attr_get(attr_t *, short *, void *); +PDCEX int attr_off(attr_t, void *); +PDCEX int attr_on(attr_t, void *); +PDCEX int attr_set(attr_t, short, void *); +PDCEX int baudrate(void); +PDCEX int beep(void); +PDCEX int bkgd(chtype); +PDCEX void bkgdset(chtype); +PDCEX int border(chtype, chtype, chtype, chtype, + chtype, chtype, chtype, chtype); +PDCEX int box(WINDOW *, chtype, chtype); +PDCEX bool can_change_color(void); +PDCEX int cbreak(void); +PDCEX int chgat(int, attr_t, short, const void *); +PDCEX int clearok(WINDOW *, bool); +PDCEX int clear(void); +PDCEX int clrtobot(void); +PDCEX int clrtoeol(void); +PDCEX int color_content(short, short *, short *, short *); +PDCEX int color_set(short, void *); +PDCEX int copywin(const WINDOW *, WINDOW *, int, int, int, + int, int, int, int); +PDCEX int curs_set(int); +PDCEX int def_prog_mode(void); +PDCEX int def_shell_mode(void); +PDCEX int delay_output(int); +PDCEX int delch(void); +PDCEX int deleteln(void); +PDCEX void delscreen(SCREEN *); +PDCEX int delwin(WINDOW *); +PDCEX WINDOW *derwin(WINDOW *, int, int, int, int); +PDCEX int doupdate(void); +PDCEX WINDOW *dupwin(WINDOW *); +PDCEX int echochar(const chtype); +PDCEX int echo(void); +PDCEX int endwin(void); +PDCEX char erasechar(void); +PDCEX int erase(void); +PDCEX void filter(void); +PDCEX int flash(void); +PDCEX int flushinp(void); +PDCEX chtype getbkgd(WINDOW *); +PDCEX int getnstr(char *, int); +PDCEX int getstr(char *); +PDCEX WINDOW *getwin(FILE *); +PDCEX int halfdelay(int); +PDCEX bool has_colors(void); +PDCEX bool has_ic(void); +PDCEX bool has_il(void); +PDCEX int hline(chtype, int); +PDCEX void idcok(WINDOW *, bool); +PDCEX int idlok(WINDOW *, bool); +PDCEX void immedok(WINDOW *, bool); +PDCEX int inchnstr(chtype *, int); +PDCEX int inchstr(chtype *); +PDCEX chtype inch(void); +PDCEX int init_color(short, short, short, short); +PDCEX int init_pair(short, short, short); +PDCEX WINDOW *initscr(void); +PDCEX int innstr(char *, int); +PDCEX int insch(chtype); +PDCEX int insdelln(int); +PDCEX int insertln(void); +PDCEX int insnstr(const char *, int); +PDCEX int insstr(const char *); +PDCEX int instr(char *); +PDCEX int intrflush(WINDOW *, bool); +PDCEX bool isendwin(void); +PDCEX bool is_linetouched(WINDOW *, int); +PDCEX bool is_wintouched(WINDOW *); +PDCEX char *keyname(int); +PDCEX int keypad(WINDOW *, bool); +PDCEX char killchar(void); +PDCEX int leaveok(WINDOW *, bool); +PDCEX char *longname(void); +PDCEX int meta(WINDOW *, bool); +PDCEX int move(int, int); +PDCEX int mvaddch(int, int, const chtype); +PDCEX int mvaddchnstr(int, int, const chtype *, int); +PDCEX int mvaddchstr(int, int, const chtype *); +PDCEX int mvaddnstr(int, int, const char *, int); +PDCEX int mvaddstr(int, int, const char *); +PDCEX int mvchgat(int, int, int, attr_t, short, const void *); +PDCEX int mvcur(int, int, int, int); +PDCEX int mvdelch(int, int); +PDCEX int mvderwin(WINDOW *, int, int); +PDCEX int mvgetch(int, int); +PDCEX int mvgetnstr(int, int, char *, int); +PDCEX int mvgetstr(int, int, char *); +PDCEX int mvhline(int, int, chtype, int); +PDCEX chtype mvinch(int, int); +PDCEX int mvinchnstr(int, int, chtype *, int); +PDCEX int mvinchstr(int, int, chtype *); +PDCEX int mvinnstr(int, int, char *, int); +PDCEX int mvinsch(int, int, chtype); +PDCEX int mvinsnstr(int, int, const char *, int); +PDCEX int mvinsstr(int, int, const char *); +PDCEX int mvinstr(int, int, char *); +PDCEX int mvprintw(int, int, const char *, ...); +PDCEX int mvscanw(int, int, const char *, ...); +PDCEX int mvvline(int, int, chtype, int); +PDCEX int mvwaddchnstr(WINDOW *, int, int, const chtype *, int); +PDCEX int mvwaddchstr(WINDOW *, int, int, const chtype *); +PDCEX int mvwaddch(WINDOW *, int, int, const chtype); +PDCEX int mvwaddnstr(WINDOW *, int, int, const char *, int); +PDCEX int mvwaddstr(WINDOW *, int, int, const char *); +PDCEX int mvwchgat(WINDOW *, int, int, int, attr_t, short, const void *); +PDCEX int mvwdelch(WINDOW *, int, int); +PDCEX int mvwgetch(WINDOW *, int, int); +PDCEX int mvwgetnstr(WINDOW *, int, int, char *, int); +PDCEX int mvwgetstr(WINDOW *, int, int, char *); +PDCEX int mvwhline(WINDOW *, int, int, chtype, int); +PDCEX int mvwinchnstr(WINDOW *, int, int, chtype *, int); +PDCEX int mvwinchstr(WINDOW *, int, int, chtype *); +PDCEX chtype mvwinch(WINDOW *, int, int); +PDCEX int mvwinnstr(WINDOW *, int, int, char *, int); +PDCEX int mvwinsch(WINDOW *, int, int, chtype); +PDCEX int mvwinsnstr(WINDOW *, int, int, const char *, int); +PDCEX int mvwinsstr(WINDOW *, int, int, const char *); +PDCEX int mvwinstr(WINDOW *, int, int, char *); +PDCEX int mvwin(WINDOW *, int, int); +PDCEX int mvwprintw(WINDOW *, int, int, const char *, ...); +PDCEX int mvwscanw(WINDOW *, int, int, const char *, ...); +PDCEX int mvwvline(WINDOW *, int, int, chtype, int); +PDCEX int napms(int); +PDCEX WINDOW *newpad(int, int); +PDCEX SCREEN *newterm(const char *, FILE *, FILE *); +PDCEX WINDOW *newwin(int, int, int, int); +PDCEX int nl(void); +PDCEX int nocbreak(void); +PDCEX int nodelay(WINDOW *, bool); +PDCEX int noecho(void); +PDCEX int nonl(void); +PDCEX void noqiflush(void); +PDCEX int noraw(void); +PDCEX int notimeout(WINDOW *, bool); +PDCEX int overlay(const WINDOW *, WINDOW *); +PDCEX int overwrite(const WINDOW *, WINDOW *); +PDCEX int pair_content(short, short *, short *); +PDCEX int pechochar(WINDOW *, chtype); +PDCEX int pnoutrefresh(WINDOW *, int, int, int, int, int, int); +PDCEX int prefresh(WINDOW *, int, int, int, int, int, int); +PDCEX int printw(const char *, ...); +PDCEX int putwin(WINDOW *, FILE *); +PDCEX void qiflush(void); +PDCEX int raw(void); +PDCEX int redrawwin(WINDOW *); +PDCEX int refresh(void); +PDCEX int reset_prog_mode(void); +PDCEX int reset_shell_mode(void); +PDCEX int resetty(void); +PDCEX int ripoffline(int, int (*)(WINDOW *, int)); +PDCEX int savetty(void); +PDCEX int scanw(const char *, ...); +PDCEX int scr_dump(const char *); +PDCEX int scr_init(const char *); +PDCEX int scr_restore(const char *); +PDCEX int scr_set(const char *); +PDCEX int scrl(int); +PDCEX int scroll(WINDOW *); +PDCEX int scrollok(WINDOW *, bool); +PDCEX SCREEN *set_term(SCREEN *); +PDCEX int setscrreg(int, int); +PDCEX int slk_attroff(const chtype); +PDCEX int slk_attr_off(const attr_t, void *); +PDCEX int slk_attron(const chtype); +PDCEX int slk_attr_on(const attr_t, void *); +PDCEX int slk_attrset(const chtype); +PDCEX int slk_attr_set(const attr_t, short, void *); +PDCEX int slk_clear(void); +PDCEX int slk_color(short); +PDCEX int slk_init(int); +PDCEX char *slk_label(int); +PDCEX int slk_noutrefresh(void); +PDCEX int slk_refresh(void); +PDCEX int slk_restore(void); +PDCEX int slk_set(int, const char *, int); +PDCEX int slk_touch(void); +PDCEX int standend(void); +PDCEX int standout(void); +PDCEX int start_color(void); +PDCEX WINDOW *subpad(WINDOW *, int, int, int, int); +PDCEX WINDOW *subwin(WINDOW *, int, int, int, int); +PDCEX int syncok(WINDOW *, bool); +PDCEX chtype termattrs(void); +PDCEX attr_t term_attrs(void); +PDCEX char *termname(void); +PDCEX void timeout(int); +PDCEX int touchline(WINDOW *, int, int); +PDCEX int touchwin(WINDOW *); +PDCEX int typeahead(int); +PDCEX int untouchwin(WINDOW *); +PDCEX void use_env(bool); +PDCEX int vidattr(chtype); +PDCEX int vid_attr(attr_t, short, void *); +PDCEX int vidputs(chtype, int (*)(int)); +PDCEX int vid_puts(attr_t, short, void *, int (*)(int)); +PDCEX int vline(chtype, int); +PDCEX int vw_printw(WINDOW *, const char *, va_list); +PDCEX int vwprintw(WINDOW *, const char *, va_list); +PDCEX int vw_scanw(WINDOW *, const char *, va_list); +PDCEX int vwscanw(WINDOW *, const char *, va_list); +PDCEX int waddchnstr(WINDOW *, const chtype *, int); +PDCEX int waddchstr(WINDOW *, const chtype *); +PDCEX int waddch(WINDOW *, const chtype); +PDCEX int waddnstr(WINDOW *, const char *, int); +PDCEX int waddstr(WINDOW *, const char *); +PDCEX int wattroff(WINDOW *, chtype); +PDCEX int wattron(WINDOW *, chtype); +PDCEX int wattrset(WINDOW *, chtype); +PDCEX int wattr_get(WINDOW *, attr_t *, short *, void *); +PDCEX int wattr_off(WINDOW *, attr_t, void *); +PDCEX int wattr_on(WINDOW *, attr_t, void *); +PDCEX int wattr_set(WINDOW *, attr_t, short, void *); +PDCEX void wbkgdset(WINDOW *, chtype); +PDCEX int wbkgd(WINDOW *, chtype); +PDCEX int wborder(WINDOW *, chtype, chtype, chtype, chtype, + chtype, chtype, chtype, chtype); +PDCEX int wchgat(WINDOW *, int, attr_t, short, const void *); +PDCEX int wclear(WINDOW *); +PDCEX int wclrtobot(WINDOW *); +PDCEX int wclrtoeol(WINDOW *); +PDCEX int wcolor_set(WINDOW *, short, void *); +PDCEX void wcursyncup(WINDOW *); +PDCEX int wdelch(WINDOW *); +PDCEX int wdeleteln(WINDOW *); +PDCEX int wechochar(WINDOW *, const chtype); +PDCEX int werase(WINDOW *); +PDCEX int wgetch(WINDOW *); +PDCEX int wgetnstr(WINDOW *, char *, int); +PDCEX int wgetstr(WINDOW *, char *); +PDCEX int whline(WINDOW *, chtype, int); +PDCEX int winchnstr(WINDOW *, chtype *, int); +PDCEX int winchstr(WINDOW *, chtype *); +PDCEX chtype winch(WINDOW *); +PDCEX int winnstr(WINDOW *, char *, int); +PDCEX int winsch(WINDOW *, chtype); +PDCEX int winsdelln(WINDOW *, int); +PDCEX int winsertln(WINDOW *); +PDCEX int winsnstr(WINDOW *, const char *, int); +PDCEX int winsstr(WINDOW *, const char *); +PDCEX int winstr(WINDOW *, char *); +PDCEX int wmove(WINDOW *, int, int); +PDCEX int wnoutrefresh(WINDOW *); +PDCEX int wprintw(WINDOW *, const char *, ...); +PDCEX int wredrawln(WINDOW *, int, int); +PDCEX int wrefresh(WINDOW *); +PDCEX int wscanw(WINDOW *, const char *, ...); +PDCEX int wscrl(WINDOW *, int); +PDCEX int wsetscrreg(WINDOW *, int, int); +PDCEX int wstandend(WINDOW *); +PDCEX int wstandout(WINDOW *); +PDCEX void wsyncdown(WINDOW *); +PDCEX void wsyncup(WINDOW *); +PDCEX void wtimeout(WINDOW *, int); +PDCEX int wtouchln(WINDOW *, int, int, int); +PDCEX int wvline(WINDOW *, chtype, int); + +/* Wide-character functions */ + +#ifdef PDC_WIDE +PDCEX int addnwstr(const wchar_t *, int); +PDCEX int addwstr(const wchar_t *); +PDCEX int add_wch(const cchar_t *); +PDCEX int add_wchnstr(const cchar_t *, int); +PDCEX int add_wchstr(const cchar_t *); +PDCEX int border_set(const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *); +PDCEX int box_set(WINDOW *, const cchar_t *, const cchar_t *); +PDCEX int echo_wchar(const cchar_t *); +PDCEX int erasewchar(wchar_t *); +PDCEX int getbkgrnd(cchar_t *); +PDCEX int getcchar(const cchar_t *, wchar_t *, attr_t *, short *, void *); +PDCEX int getn_wstr(wint_t *, int); +PDCEX int get_wch(wint_t *); +PDCEX int get_wstr(wint_t *); +PDCEX int hline_set(const cchar_t *, int); +PDCEX int innwstr(wchar_t *, int); +PDCEX int ins_nwstr(const wchar_t *, int); +PDCEX int ins_wch(const cchar_t *); +PDCEX int ins_wstr(const wchar_t *); +PDCEX int inwstr(wchar_t *); +PDCEX int in_wch(cchar_t *); +PDCEX int in_wchnstr(cchar_t *, int); +PDCEX int in_wchstr(cchar_t *); +PDCEX char *key_name(wchar_t); +PDCEX int killwchar(wchar_t *); +PDCEX int mvaddnwstr(int, int, const wchar_t *, int); +PDCEX int mvaddwstr(int, int, const wchar_t *); +PDCEX int mvadd_wch(int, int, const cchar_t *); +PDCEX int mvadd_wchnstr(int, int, const cchar_t *, int); +PDCEX int mvadd_wchstr(int, int, const cchar_t *); +PDCEX int mvgetn_wstr(int, int, wint_t *, int); +PDCEX int mvget_wch(int, int, wint_t *); +PDCEX int mvget_wstr(int, int, wint_t *); +PDCEX int mvhline_set(int, int, const cchar_t *, int); +PDCEX int mvinnwstr(int, int, wchar_t *, int); +PDCEX int mvins_nwstr(int, int, const wchar_t *, int); +PDCEX int mvins_wch(int, int, const cchar_t *); +PDCEX int mvins_wstr(int, int, const wchar_t *); +PDCEX int mvinwstr(int, int, wchar_t *); +PDCEX int mvin_wch(int, int, cchar_t *); +PDCEX int mvin_wchnstr(int, int, cchar_t *, int); +PDCEX int mvin_wchstr(int, int, cchar_t *); +PDCEX int mvvline_set(int, int, const cchar_t *, int); +PDCEX int mvwaddnwstr(WINDOW *, int, int, const wchar_t *, int); +PDCEX int mvwaddwstr(WINDOW *, int, int, const wchar_t *); +PDCEX int mvwadd_wch(WINDOW *, int, int, const cchar_t *); +PDCEX int mvwadd_wchnstr(WINDOW *, int, int, const cchar_t *, int); +PDCEX int mvwadd_wchstr(WINDOW *, int, int, const cchar_t *); +PDCEX int mvwgetn_wstr(WINDOW *, int, int, wint_t *, int); +PDCEX int mvwget_wch(WINDOW *, int, int, wint_t *); +PDCEX int mvwget_wstr(WINDOW *, int, int, wint_t *); +PDCEX int mvwhline_set(WINDOW *, int, int, const cchar_t *, int); +PDCEX int mvwinnwstr(WINDOW *, int, int, wchar_t *, int); +PDCEX int mvwins_nwstr(WINDOW *, int, int, const wchar_t *, int); +PDCEX int mvwins_wch(WINDOW *, int, int, const cchar_t *); +PDCEX int mvwins_wstr(WINDOW *, int, int, const wchar_t *); +PDCEX int mvwin_wch(WINDOW *, int, int, cchar_t *); +PDCEX int mvwin_wchnstr(WINDOW *, int, int, cchar_t *, int); +PDCEX int mvwin_wchstr(WINDOW *, int, int, cchar_t *); +PDCEX int mvwinwstr(WINDOW *, int, int, wchar_t *); +PDCEX int mvwvline_set(WINDOW *, int, int, const cchar_t *, int); +PDCEX int pecho_wchar(WINDOW *, const cchar_t*); +PDCEX int setcchar(cchar_t*, const wchar_t*, const attr_t, + short, const void*); +PDCEX int slk_wset(int, const wchar_t *, int); +PDCEX int unget_wch(const wchar_t); +PDCEX int vline_set(const cchar_t *, int); +PDCEX int waddnwstr(WINDOW *, const wchar_t *, int); +PDCEX int waddwstr(WINDOW *, const wchar_t *); +PDCEX int wadd_wch(WINDOW *, const cchar_t *); +PDCEX int wadd_wchnstr(WINDOW *, const cchar_t *, int); +PDCEX int wadd_wchstr(WINDOW *, const cchar_t *); +PDCEX int wbkgrnd(WINDOW *, const cchar_t *); +PDCEX void wbkgrndset(WINDOW *, const cchar_t *); +PDCEX int wborder_set(WINDOW *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *, + const cchar_t *, const cchar_t *, const cchar_t *); +PDCEX int wecho_wchar(WINDOW *, const cchar_t *); +PDCEX int wgetbkgrnd(WINDOW *, cchar_t *); +PDCEX int wgetn_wstr(WINDOW *, wint_t *, int); +PDCEX int wget_wch(WINDOW *, wint_t *); +PDCEX int wget_wstr(WINDOW *, wint_t *); +PDCEX int whline_set(WINDOW *, const cchar_t *, int); +PDCEX int winnwstr(WINDOW *, wchar_t *, int); +PDCEX int wins_nwstr(WINDOW *, const wchar_t *, int); +PDCEX int wins_wch(WINDOW *, const cchar_t *); +PDCEX int wins_wstr(WINDOW *, const wchar_t *); +PDCEX int winwstr(WINDOW *, wchar_t *); +PDCEX int win_wch(WINDOW *, cchar_t *); +PDCEX int win_wchnstr(WINDOW *, cchar_t *, int); +PDCEX int win_wchstr(WINDOW *, cchar_t *); +PDCEX wchar_t *wunctrl(cchar_t *); +PDCEX int wvline_set(WINDOW *, const cchar_t *, int); +#endif + +/* Quasi-standard */ + +PDCEX chtype getattrs(WINDOW *); +PDCEX int getbegx(WINDOW *); +PDCEX int getbegy(WINDOW *); +PDCEX int getmaxx(WINDOW *); +PDCEX int getmaxy(WINDOW *); +PDCEX int getparx(WINDOW *); +PDCEX int getpary(WINDOW *); +PDCEX int getcurx(WINDOW *); +PDCEX int getcury(WINDOW *); +PDCEX void traceoff(void); +PDCEX void traceon(void); +PDCEX char *unctrl(chtype); + +PDCEX int crmode(void); +PDCEX int nocrmode(void); +PDCEX int draino(int); +PDCEX int resetterm(void); +PDCEX int fixterm(void); +PDCEX int saveterm(void); +PDCEX void setsyx(int, int); + +PDCEX int mouse_set(unsigned long); +PDCEX int mouse_on(unsigned long); +PDCEX int mouse_off(unsigned long); +PDCEX int request_mouse_pos(void); +PDCEX int map_button(unsigned long); +PDCEX void wmouse_position(WINDOW *, int *, int *); +PDCEX unsigned long getmouse(void); +PDCEX unsigned long getbmap(void); + +/* ncurses */ + +PDCEX int assume_default_colors(int, int); +PDCEX const char *curses_version(void); +PDCEX bool has_key(int); +PDCEX int use_default_colors(void); +PDCEX int wresize(WINDOW *, int, int); + +PDCEX int mouseinterval(int); +PDCEX mmask_t mousemask(mmask_t, mmask_t *); +PDCEX bool mouse_trafo(int *, int *, bool); +PDCEX int nc_getmouse(MEVENT *); +PDCEX int ungetmouse(MEVENT *); +PDCEX bool wenclose(const WINDOW *, int, int); +PDCEX bool wmouse_trafo(const WINDOW *, int *, int *, bool); + +/* PDCurses */ + +PDCEX int addrawch(chtype); +PDCEX int insrawch(chtype); +PDCEX bool is_termresized(void); +PDCEX int mvaddrawch(int, int, chtype); +PDCEX int mvdeleteln(int, int); +PDCEX int mvinsertln(int, int); +PDCEX int mvinsrawch(int, int, chtype); +PDCEX int mvwaddrawch(WINDOW *, int, int, chtype); +PDCEX int mvwdeleteln(WINDOW *, int, int); +PDCEX int mvwinsertln(WINDOW *, int, int); +PDCEX int mvwinsrawch(WINDOW *, int, int, chtype); +PDCEX int raw_output(bool); +PDCEX int resize_term(int, int); +PDCEX WINDOW *resize_window(WINDOW *, int, int); +PDCEX int waddrawch(WINDOW *, chtype); +PDCEX int winsrawch(WINDOW *, chtype); +PDCEX char wordchar(void); + +#ifdef PDC_WIDE +PDCEX wchar_t *slk_wlabel(int); +#endif + +PDCEX void PDC_debug(const char *, ...); +PDCEX int PDC_ungetch(int); +PDCEX int PDC_set_blink(bool); +PDCEX int PDC_set_line_color(short); +PDCEX void PDC_set_title(const char *); + +PDCEX int PDC_clearclipboard(void); +PDCEX int PDC_freeclipboard(char *); +PDCEX int PDC_getclipboard(char **, long *); +PDCEX int PDC_setclipboard(const char *, long); + +PDCEX unsigned long PDC_get_input_fd(void); +PDCEX unsigned long PDC_get_key_modifiers(void); +PDCEX int PDC_return_key_modifiers(bool); +PDCEX int PDC_save_key_modifiers(bool); +PDCEX void PDC_set_resize_limits( const int new_min_lines, + const int new_max_lines, + const int new_min_cols, + const int new_max_cols); + +#define FUNCTION_KEY_SHUT_DOWN 0 +#define FUNCTION_KEY_PASTE 1 +#define FUNCTION_KEY_ENLARGE_FONT 2 +#define FUNCTION_KEY_SHRINK_FONT 3 +#define FUNCTION_KEY_CHOOSE_FONT 4 +#define FUNCTION_KEY_ABORT 5 +#define PDC_MAX_FUNCTION_KEYS 6 + +PDCEX int PDC_set_function_key( const unsigned function, + const int new_key); + +PDCEX WINDOW *Xinitscr(int, char **); +#ifdef XCURSES +PDCEX void XCursesExit(void); +PDCEX int sb_init(void); +PDCEX int sb_set_horz(int, int, int); +PDCEX int sb_set_vert(int, int, int); +PDCEX int sb_get_horz(int *, int *, int *); +PDCEX int sb_get_vert(int *, int *, int *); +PDCEX int sb_refresh(void); + #endif + +/*** Functions defined as macros ***/ + +/* getch() and ungetch() conflict with some DOS libraries */ + +#define getch() wgetch(stdscr) +#define ungetch(ch) PDC_ungetch(ch) + +#define COLOR_PAIR(n) (((chtype)(n) << PDC_COLOR_SHIFT) & A_COLOR) +#define PAIR_NUMBER(n) ((((n) & A_COLOR) >> PDC_COLOR_SHIFT) & 0xff) + +/* These will _only_ work as macros */ + +#define getbegyx(w, y, x) (y = getbegy(w), x = getbegx(w)) +#define getmaxyx(w, y, x) (y = getmaxy(w), x = getmaxx(w)) +#define getparyx(w, y, x) (y = getpary(w), x = getparx(w)) +#define getyx(w, y, x) (y = getcury(w), x = getcurx(w)) + +#define getsyx(y, x) { if (curscr->_leaveit) (y)=(x)=-1; \ + else getyx(curscr,(y),(x)); } + +#ifdef NCURSES_MOUSE_VERSION +# define getmouse(x) nc_getmouse(x) +#endif + +/* return codes from PDC_getclipboard() and PDC_setclipboard() calls */ + +#define PDC_CLIP_SUCCESS 0 +#define PDC_CLIP_ACCESS_ERROR 1 +#define PDC_CLIP_EMPTY 2 +#define PDC_CLIP_MEMORY_ERROR 3 + +/* PDCurses key modifier masks */ + +#define PDC_KEY_MODIFIER_SHIFT 1 +#define PDC_KEY_MODIFIER_CONTROL 2 +#define PDC_KEY_MODIFIER_ALT 4 +#define PDC_KEY_MODIFIER_NUMLOCK 8 +#define PDC_KEY_MODIFIER_REPEAT 16 + +#ifdef __cplusplus +# undef bool +} +#endif + +#endif /* __PDCURSES__ */ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curspriv.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curspriv.h new file mode 100644 index 000000000..b5edcc173 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/curspriv.h @@ -0,0 +1,134 @@ +/* Public Domain Curses */ + +/* Private definitions and declarations for use within PDCurses. + These should generally not be referenced by applications. */ + +#ifndef __CURSES_INTERNALS__ +#define __CURSES_INTERNALS__ 1 + +#define CURSES_LIBRARY +#include + +#if defined(__TURBOC__) || defined(__EMX__) || defined(__DJGPP__) || \ + defined(__CYGWIN__) || defined(__MINGW32__) || \ + defined(__WATCOMC__) || defined(__PACIFIC__) +# ifndef HAVE_VSSCANF +# define HAVE_VSSCANF /* have vsscanf() */ +# endif +#endif + +#if defined(__CYGWIN__) || defined(__MINGW32__) || \ + defined(__LCC__) || defined(__WATCOMC__) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF /* have vsnprintf() */ +# endif +#endif + +#if defined(_MSC_VER) && defined(_WIN32) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE 1 /* kill nonsense warnings */ +#endif + +/*----------------------------------------------------------------------*/ + +typedef struct /* structure for ripped off lines */ +{ + int line; + int (*init)(WINDOW *, int); +} RIPPEDOFFLINE; + +/* Window properties */ + +#define _SUBWIN 0x01 /* window is a subwindow */ +#define _PAD 0x10 /* X/Open Pad. */ +#define _SUBPAD 0x20 /* X/Open subpad. */ + +/* Miscellaneous */ + +#define _NO_CHANGE -1 /* flags line edge unchanged */ + +#define _ECHAR 0x08 /* Erase char (^H) */ +#define _DWCHAR 0x17 /* Delete Word char (^W) */ +#define _DLCHAR 0x15 /* Delete Line char (^U) */ + +extern WINDOW *pdc_lastscr; +extern FILE *pdc_dbfp; /* tracing file pointer (NULL = off) */ +extern bool pdc_color_started; +extern unsigned long pdc_key_modifiers; +extern MOUSE_STATUS pdc_mouse_status; + +/*----------------------------------------------------------------------*/ + +/* Platform implementation functions */ + +void PDC_beep(void); +bool PDC_can_change_color(void); +int PDC_color_content(short, short *, short *, short *); +bool PDC_check_key(void); +int PDC_curs_set(int); +void PDC_flushinp(void); +int PDC_get_columns(void); +int PDC_get_cursor_mode(void); +int PDC_get_key(void); +int PDC_get_rows(void); +void PDC_gotoyx(int, int); +int PDC_init_color(short, short, short, short); +void PDC_init_pair(short, short, short); +int PDC_modifiers_set(void); +int PDC_mouse_set(void); +void PDC_napms(int); +int PDC_pair_content(short, short *, short *); +void PDC_reset_prog_mode(void); +void PDC_reset_shell_mode(void); +int PDC_resize_screen(int, int); +void PDC_restore_screen_mode(int); +void PDC_save_screen_mode(int); +void PDC_scr_close(void); +void PDC_scr_free(void); +int PDC_scr_open(int, char **); +void PDC_set_keyboard_binary(bool); +void PDC_transform_line(int, int, int, const chtype *); +const char *PDC_sysname(void); + +/* Internal cross-module functions */ + +void PDC_init_atrtab(void); +WINDOW *PDC_makelines(WINDOW *); +WINDOW *PDC_makenew(int, int, int, int); +int PDC_mouse_in_slk(int, int); +void PDC_slk_free(void); +void PDC_slk_initialize(void); +void PDC_sync(WINDOW *); + +#ifdef PDC_WIDE +int PDC_mbtowc(wchar_t *, const char *, size_t); +size_t PDC_mbstowcs(wchar_t *, const char *, size_t); +size_t PDC_wcstombs(char *, const wchar_t *, size_t); +#endif + +#ifdef PDCDEBUG +# define PDC_LOG(x) if (pdc_dbfp) PDC_debug x +#else +# define PDC_LOG(x) +#endif + +/* Internal macros for attributes */ + +#ifdef CHTYPE_LONG +# define PDC_COLOR_PAIRS 256 +#else +# define PDC_COLOR_PAIRS 32 +#endif + +#ifndef max +# define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +# define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +#define DIVROUND(num, divisor) (((num) + ((divisor) >> 1)) / (divisor)) + +#define PDC_CLICK_PERIOD 150 /* time to wait for a click, if + not set by mouseinterval() */ + +#endif /* __CURSES_INTERNALS__*/ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/getopt.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/getopt.h new file mode 100644 index 000000000..4de6e853e --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/getopt.h @@ -0,0 +1,93 @@ +/* $Id: getopt.h,v 1.1 2009/10/16 19:50:28 rodney Exp rodney $ */ +/* $OpenBSD: getopt.h,v 1.1 2002/12/03 20:24:29 millert Exp $ */ +/* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */ + +/*- + * Copyright (c) 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Dieter Baron and Thomas Klausner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _GETOPT_H_ +#define _GETOPT_H_ + +#if 0 +#include +#endif + +/* + * GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions + */ +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +struct option { + /* name of long option */ + const char *name; + /* + * one of no_argument, required_argument, and optional_argument: + * whether option takes an argument + */ + int has_arg; + /* if not NULL, set *flag to val when option found */ + int *flag; + /* if flag not NULL, value to set *flag to; else return value */ + int val; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +int getopt_long(int, char * const *, const char *, + const struct option *, int *); +int getopt_long_only(int, char * const *, const char *, + const struct option *, int *); +#ifndef _GETOPT_DEFINED +#define _GETOPT_DEFINED +int getopt(int, char * const *, const char *); +int getsubopt(char **, char * const *, char **); + +extern char *optarg; /* getopt(3) external variables */ +extern int opterr; +extern int optind; +extern int optopt; +extern int optreset; +extern char *suboptarg; /* getsubopt(3) external variable */ +#endif /* _GETOPT_DEFINED */ + +#ifdef __cplusplus +} +#endif +#endif /* !_GETOPT_H_ */ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/panel.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/panel.h new file mode 100644 index 000000000..7f1fb1f17 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/panel.h @@ -0,0 +1,56 @@ +/* Public Domain Curses */ + +/*----------------------------------------------------------------------* + * Panels for PDCurses * + *----------------------------------------------------------------------*/ + +#ifndef __PDCURSES_PANEL_H__ +#define __PDCURSES_PANEL_H__ 1 + +#include + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +extern "C" +{ +#endif + +typedef struct panelobs +{ + struct panelobs *above; + struct panel *pan; +} PANELOBS; + +typedef struct panel +{ + WINDOW *win; + int wstarty; + int wendy; + int wstartx; + int wendx; + struct panel *below; + struct panel *above; + const void *user; + struct panelobs *obscure; +} PANEL; + +PDCEX int bottom_panel(PANEL *pan); +PDCEX int del_panel(PANEL *pan); +PDCEX int hide_panel(PANEL *pan); +PDCEX int move_panel(PANEL *pan, int starty, int startx); +PDCEX PANEL *new_panel(WINDOW *win); +PDCEX PANEL *panel_above(const PANEL *pan); +PDCEX PANEL *panel_below(const PANEL *pan); +PDCEX int panel_hidden(const PANEL *pan); +PDCEX const void *panel_userptr(const PANEL *pan); +PDCEX WINDOW *panel_window(const PANEL *pan); +PDCEX int replace_panel(PANEL *pan, WINDOW *win); +PDCEX int set_panel_userptr(PANEL *pan, const void *uptr); +PDCEX int show_panel(PANEL *pan); +PDCEX int top_panel(PANEL *pan); +PDCEX void update_panels(void); + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +} +#endif + +#endif /* __PDCURSES_PANEL_H__ */ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/term.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/term.h new file mode 100644 index 000000000..0ba0b7a7f --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/term.h @@ -0,0 +1,48 @@ +/* Public Domain Curses */ + +/* PDCurses doesn't operate with terminfo, but we need these functions for + compatibility, to allow some things (notably, interface libraries for + other languages) to be compiled. Anyone who tries to actually _use_ + them will be disappointed, since they only return ERR. */ + +#ifndef __PDCURSES_TERM_H__ +#define __PDCURSES_TERM_H__ 1 + +#include + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +extern "C" +{ +#endif + +typedef struct +{ + const char *_termname; +} TERMINAL; + +/* PDCEX is defined in curses.h */ +PDCEX TERMINAL *cur_term; + +int del_curterm(TERMINAL *); +int putp(const char *); +int restartterm(const char *, int, int *); +TERMINAL *set_curterm(TERMINAL *); +int setterm(const char *); +int setupterm(const char *, int, int *); +int tgetent(char *, const char *); +int tgetflag(const char *); +int tgetnum(const char *); +char *tgetstr(const char *, char **); +char *tgoto(const char *, int, int); +int tigetflag(const char *); +int tigetnum(const char *); +char *tigetstr(const char *); +char *tparm(const char *, long, long, long, long, long, + long, long, long, long); +int tputs(const char *, int, int (*)(int)); + +#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS) +} +#endif + +#endif /* __PDCURSES_TERM_H__ */ diff --git a/src/cc/rogue/x86_64-w64-msvc/deps/install/include/unistd.h b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/unistd.h new file mode 100644 index 000000000..5d2440309 --- /dev/null +++ b/src/cc/rogue/x86_64-w64-msvc/deps/install/include/unistd.h @@ -0,0 +1,56 @@ +#ifndef _UNISTD_H +#define _UNISTD_H 1 + +/* This is intended as a drop-in replacement for unistd.h on Windows. + * Please add functionality as neeeded. + * https://stackoverflow.com/a/826027/1202830 + */ + +#include +#include +#include /* getopt at: https://gist.github.com/ashelly/7776712 */ +#include /* for getpid() and the exec..() family */ +#include /* for _getcwd() and _chdir() */ + +#define srandom srand +#define random rand + +/* Values for the second argument to access. + These may be OR'd together. */ +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +//#define X_OK 1 /* execute permission - unsupported in windows*/ +#define F_OK 0 /* Test for existence. */ + +#define access _access +#define dup2 _dup2 +#define execve _execve +#define ftruncate _chsize +#define unlink _unlink +#define fileno _fileno +#define getcwd _getcwd +#define chdir _chdir +#define isatty _isatty +#define lseek _lseek +/* read, write, and close are NOT being #defined here, because while there are file handle specific versions for Windows, they probably don't work for sockets. You need to look at your app and consider whether to call e.g. closesocket(). */ + +#ifdef _WIN64 +#define ssize_t __int64 +#else +#define ssize_t long +#endif + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +/* should be in some equivalent to */ +typedef __int8 int8_t; +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; + +#endif /* unistd.h */ \ No newline at end of file From 8ff5220943fb1def080bc8003495d251b66af5ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 10 Mar 2019 20:13:48 -1100 Subject: [PATCH 08/64] Fix wrong dilithium compare --- src/cc/dilithium.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 7ab6b4c37..0854236ec 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3352,7 +3352,7 @@ int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu { if ( (nValue= IsCClibvout(cp,vintx,vout,cmpaddr)) > DILITHIUM_TXFEE && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) { - if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' && vout < voutpubtxids.size() && checktxid == voutpubtxids[vout]) || (dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' && destpubtxid == checktxid) ) + if ( (dilithium_Qsendopretdecode(checktxid,tmpsig,voutpubtxids,vintx.vout[numvouts-1].scriptPubKey) == 'Q' && vout < voutpubtxids.size() && destpubtxid == voutpubtxids[vout]) || (dilithium_sendopretdecode(checktxid,vintx.vout[numvouts-1].scriptPubKey) == 'x' && destpubtxid == checktxid) ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); From 02961a91e48edb9b45d5254a291d2fe821c87667 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 11 Mar 2019 09:46:22 -0400 Subject: [PATCH 09/64] Port getchaintxstats from BTC master (#1328) This will allow explorers to present interesting analytics about transaction volume in various time frames. --- src/rpc/blockchain.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++ src/rpc/client.cpp | 1 + 2 files changed, 83 insertions(+) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 5be94dc94..6dac120e4 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1655,6 +1655,87 @@ UniValue getmempoolinfo(const UniValue& params, bool fHelp) return mempoolInfoToJSON(); } +inline CBlockIndex* LookupBlockIndex(const uint256& hash) +{ + AssertLockHeld(cs_main); + BlockMap::const_iterator it = mapBlockIndex.find(hash); + return it == mapBlockIndex.end() ? nullptr : it->second; +} + +UniValue getchaintxstats(const UniValue& params, bool fHelp) +{ + if (fHelp || params.size() > 2) + throw runtime_error( + "getchaintxstats\n" + "\nCompute statistics about the total number and rate of transactions in the chain.\n" + "\nArguments:\n" + "1. nblocks (numeric, optional) Number of blocks in averaging window.\n" + "2. blockhash (string, optional) The hash of the block which ends the window.\n" + "\nResult:\n" + "{\n" + " \"time\": xxxxx, (numeric) The timestamp for the final block in the window in UNIX format.\n" + " \"txcount\": xxxxx, (numeric) The total number of transactions in the chain up to that point.\n" + " \"window_final_block_hash\": \"...\", (string) The hash of the final block in the window.\n" + " \"window_block_count\": xxxxx, (numeric) Size of the window in number of blocks.\n" + " \"window_tx_count\": xxxxx, (numeric) The number of transactions in the window. Only returned if \"window_block_count\" is > 0.\n" + " \"window_interval\": xxxxx, (numeric) The elapsed time in the window in seconds. Only returned if \"window_block_count\" is > 0.\n" + " \"txrate\": x.xx, (numeric) The average rate of transactions per second in the window. Only returned if \"window_interval\" is > 0.\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getchaintxstats", "") + + HelpExampleRpc("getchaintxstats", "2016") + ); + + const CBlockIndex* pindex; + int blockcount = 30 * 24 * 60 * 60 / Params().GetConsensus().nPowTargetSpacing; // By default: 1 month + + if (params[1].isNull()) { + LOCK(cs_main); + pindex = chainActive.Tip(); + } else { + uint256 hash(ParseHashV(params[1], "blockhash")); + LOCK(cs_main); + pindex = LookupBlockIndex(hash); + if (!pindex) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); + } + if (!chainActive.Contains(pindex)) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Block is not in main chain"); + } + } + + assert(pindex != nullptr); + + if (params[0].isNull()) { + blockcount = std::max(0, std::min(blockcount, pindex->GetHeight() - 1)); + } else { + blockcount = params[0].get_int(); + + if (blockcount < 0 || (blockcount > 0 && blockcount >= pindex->GetHeight())) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block count: should be between 0 and the block's height - 1"); + } + } + + const CBlockIndex* pindexPast = pindex->GetAncestor(pindex->GetHeight() - blockcount); + int nTimeDiff = pindex->GetMedianTimePast() - pindexPast->GetMedianTimePast(); + int nTxDiff = pindex->nChainTx - pindexPast->nChainTx; + + UniValue ret(UniValue::VOBJ); + ret.pushKV("time", (int64_t)pindex->nTime); + ret.pushKV("txcount", (int64_t)pindex->nChainTx); + ret.pushKV("window_final_block_hash", pindex->GetBlockHash().GetHex()); + ret.pushKV("window_block_count", blockcount); + if (blockcount > 0) { + ret.pushKV("window_tx_count", nTxDiff); + ret.pushKV("window_interval", nTimeDiff); + if (nTimeDiff > 0) { + ret.pushKV("txrate", ((double)nTxDiff) / nTimeDiff); + } + } + + return ret; +} + UniValue invalidateblock(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) @@ -1742,6 +1823,7 @@ static const CRPCCommand commands[] = { "blockchain", "getblockhash", &getblockhash, true }, { "blockchain", "getblockheader", &getblockheader, true }, { "blockchain", "getchaintips", &getchaintips, true }, + { "blockchain", "getchaintxstats", &getchaintxstats, true }, { "blockchain", "getdifficulty", &getdifficulty, true }, { "blockchain", "getmempoolinfo", &getmempoolinfo, true }, { "blockchain", "getrawmempool", &getrawmempool, true }, diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 3cbde9f10..19910b25c 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -89,6 +89,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "listunspent", 2 }, { "getblock", 1 }, { "getblockheader", 1 }, + { "getchaintxstats", 0 }, { "getlastsegidstakes", 0 }, { "gettransaction", 1 }, { "getrawtransaction", 1 }, From 24e27eb7eabd923ab45a26bb25e2e4ccee2f1b43 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 00:24:08 -1100 Subject: [PATCH 10/64] customcc --- src/cc/cclib.cpp | 15 ++++++++- src/cc/customcc.cpp | 80 +++++++++++++++++++++++++++++++++++++++++++++ src/cc/customcc.h | 44 +++++++++++++++++++++++++ 3 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 src/cc/customcc.cpp create mode 100644 src/cc/customcc.h diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 651723e44..c783eb4d0 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -33,8 +33,12 @@ #ifdef BUILD_ROGUE #define EVAL_ROGUE 17 std::string MYCCLIBNAME = (char *)"rogue"; -#else + +#elif BUILD_CUSTOMCC +#include "customcc.h" + +#else #define EVAL_SUDOKU 17 #define EVAL_MUSIG 18 #define EVAL_DILITHIUM 19 @@ -67,6 +71,8 @@ CClib_methods[] = { (char *)"rogue", (char *)"games", (char *)"", 0, 0, 'F', EVAL_ROGUE }, { (char *)"rogue", (char *)"setname", (char *)"pname", 1, 1, 'N', EVAL_ROGUE }, { (char *)"rogue", (char *)"extract", (char *)"gametxid [pubkey]", 1, 2, 'X', EVAL_ROGUE }, +#elif BUILD_CUSTOMCC + RPC_FUNCS #else { (char *)"sudoku", (char *)"gen", (char *)"", 0, 0, 'G', EVAL_SUDOKU }, { (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU }, @@ -214,6 +220,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr) return(result); } } +#elif BUILD_CUSTOMCC + CUSTOM_DISPATCH #else if ( cp->evalcode == EVAL_SUDOKU ) { @@ -410,6 +418,8 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C { #ifdef BUILD_ROGUE return(rogue_validate(cp,height,eval,tx)); +#elif BUILD_CUSTOMCC + return(custom_validate(cp,height,eval,tx)); #else if ( cp->evalcode == EVAL_SUDOKU ) return(sudoku_validate(cp,height,eval,tx)); @@ -660,6 +670,9 @@ int32_t cclib_parsehash(uint8_t *hash32,cJSON *item,int32_t len) #include "rogue/weapons.c" #include "rogue/wizard.c" +#elif BUILD_CUSTOMCC +#include "customcc.cpp" + #else #include "sudoku.cpp" #include "musig.cpp" diff --git a/src/cc/customcc.cpp b/src/cc/customcc.cpp new file mode 100644 index 000000000..d79c255f4 --- /dev/null +++ b/src/cc/customcc.cpp @@ -0,0 +1,80 @@ +/* + simple stub custom cc + */ + +CScript custom_opret(uint8_t funcid,CPubKey pk) +{ + CScript opret; uint8_t evalcode = EVAL_CUSTOM; + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << pk); + return(opret); +} + +uint8_t custom_opretdecode(CPubKey &pk,CScript scriptPubKey) +{ + std::vector vopret; uint8_t e,f; + GetOpReturnData(scriptPubKey,vopret); + if ( vopret.size() > 2 && E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> pk) != 0 && e == EVAL_CUSTOM ) + { + return(f); + } + return(0); +} + +UniValue custom_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag) +{ + CTransaction tx; + if ( rawtx.size() > 0 ) + { + result.push_back(Pair("hex",rawtx)); + if ( DecodeHexTx(tx,rawtx) != 0 ) + { + if ( broadcastflag != 0 && myAddtomempool(tx) != 0 ) + RelayTransaction(tx); + result.push_back(Pair("txid",tx.GetHash().ToString())); + result.push_back(Pair("result","success")); + } else result.push_back(Pair("error","decode hex")); + } else result.push_back(Pair("error","couldnt finalize CCtx")); + return(result); +} + +UniValue custom_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + UniValue result(UniValue::VOBJ); + result.push_back(Pair("result","success")); + result.push_back(Pair("message","just an example of an information returning rpc")); + return(result); +} + +// send yourself 1 coin to your CC address using normal utxo from your -pubkey + +UniValue custom_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) +{ + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + UniValue result(UniValue::VOBJ); CPubKey mypk; int64_t amount = COIN; int32_t broadcastflag=0; + if ( txfee == 0 ) + txfee = CUSTOM_TXFEE; + mypk = pubkey2pk(Mypubkey()); + if ( AddNormalinputs(mtx,mypk,COIN+txfee,64) >= COIN+txfee ) // add utxo to mtx + { + mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,mypk)); // make vout0 + // add opreturn, change is automatically added and tx is properly signed + rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,custom_opret('1',mypk)); + return(custom_rawtxresult(result,rawtx,broadcastflag)); + } + return(result); +} + +bool custom_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx) +{ + char expectedaddress[64]; CPubKey pk; + if ( tx.vout.size() != 2 ) // make sure the tx only has 2 outputs + return eval->Invalid("invalid number of vouts"); + else if ( custom_opretdecode(pk,tx.vout[1].scriptPubKey) != '1' ) // verify has opreturn + return eval->Invalid("invalid opreturn"); + GetCCaddress(cp,expectedaddress,pk) + if ( IsCClibvout(cp,tx,0,expectedaddress) == COIN ) // make sure amount and destination matches + return(true); + else return eval->Invalid("invalid vout0 amount"); +} + + diff --git a/src/cc/customcc.h b/src/cc/customcc.h new file mode 100644 index 000000000..87ebb6142 --- /dev/null +++ b/src/cc/customcc.h @@ -0,0 +1,44 @@ +/* + to create a custom libcc.so: + + 1. change "func0" and "func1" to method names that fit your custom cc. Of course, you can create more functions by adding another entry to RPC_FUNCS. there is not any practical limit to the number of methods. + + 2. For each method make sure there is a UniValue function declaration and CUSTOM_DISPATCH has an if statement checking for it that calls the custom_func + + 3. write the actual custom_func0, custom_func1 and custom_validate in customcc.cpp + + 4. build cclib.cpp with -DBUILD_CUSTOMCC and put the libcc.so in ~/komodo/src and rebuild komodod + + 5. launch your chain with -ac_cclib=customcc -ac_cc=2 + + */ + +std::string MYCCLIBNAME = (char *)"customcc"; + +#define EVAL_CUSTOM (EVAL_FAUCET2+1) + +#define MYCCNAME "custom" + +#define RPC_FUNCS \ + { (char *)MYCCNAME, (char *)"func0", (char *)"", 1, 1, '0', EVAL_CUSTOM }, \ + { (char *)MYCCNAME, (char *)"func1", (char *)"", 0, 0, '1', EVAL_CUSTOM }, + +bool custom_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx); +UniValue custom_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); +UniValue custom_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); + +#define CUSTOM_DISPATCH \ +if ( cp->evalcode == EVAL_SUDOKU ) \ +{ \ + if ( strcmp(method,"func0") == 0 ) \ + return(custom_func0(txfee,cp,params)); \ + else if ( strcmp(method,"func1") == 0 ) \ + return(custom_func1(txfee,cp,params)); \ + else \ + { \ + result.push_back(Pair("result","error")); \ + result.push_back(Pair("error","invalid customcc method")); \ + result.push_back(Pair("method",method)); \ + return(result); \ + } \ +} From baabb607e25eed0f7eb3a31b84efcc7bcfd4bb25 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 00:36:02 -1100 Subject: [PATCH 11/64] Make custom --- src/cc/makecustom | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 src/cc/makecustom diff --git a/src/cc/makecustom b/src/cc/makecustom new file mode 100755 index 000000000..61b251e6e --- /dev/null +++ b/src/cc/makecustom @@ -0,0 +1,7 @@ +#!/bin/sh +gcc -O3 -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o customcc.so cclib.cpp +cp customcc.so ../libcc.so +cd .. +make +cd cc + From b0290d6fe67eef9e9dea45954a72e747765746f9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 00:38:09 -1100 Subject: [PATCH 12/64] Syntax --- src/cc/customcc.cpp | 4 ++-- src/cc/customcc.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cc/customcc.cpp b/src/cc/customcc.cpp index d79c255f4..27947b57a 100644 --- a/src/cc/customcc.cpp +++ b/src/cc/customcc.cpp @@ -49,7 +49,7 @@ UniValue custom_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue custom_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { - CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); + CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); std::string rawtx; UniValue result(UniValue::VOBJ); CPubKey mypk; int64_t amount = COIN; int32_t broadcastflag=0; if ( txfee == 0 ) txfee = CUSTOM_TXFEE; @@ -71,7 +71,7 @@ bool custom_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const return eval->Invalid("invalid number of vouts"); else if ( custom_opretdecode(pk,tx.vout[1].scriptPubKey) != '1' ) // verify has opreturn return eval->Invalid("invalid opreturn"); - GetCCaddress(cp,expectedaddress,pk) + GetCCaddress(cp,expectedaddress,pk); if ( IsCClibvout(cp,tx,0,expectedaddress) == COIN ) // make sure amount and destination matches return(true); else return eval->Invalid("invalid vout0 amount"); diff --git a/src/cc/customcc.h b/src/cc/customcc.h index 87ebb6142..436937391 100644 --- a/src/cc/customcc.h +++ b/src/cc/customcc.h @@ -7,7 +7,7 @@ 3. write the actual custom_func0, custom_func1 and custom_validate in customcc.cpp - 4. build cclib.cpp with -DBUILD_CUSTOMCC and put the libcc.so in ~/komodo/src and rebuild komodod + 4. ./makecustom, which builds cclib.cpp with -DBUILD_CUSTOMCC and puts the libcc.so in ~/komodo/src and rebuilds komodod 5. launch your chain with -ac_cclib=customcc -ac_cc=2 @@ -16,6 +16,7 @@ std::string MYCCLIBNAME = (char *)"customcc"; #define EVAL_CUSTOM (EVAL_FAUCET2+1) +#define CUSTOM_TXFEE 10000 #define MYCCNAME "custom" @@ -28,7 +29,7 @@ UniValue custom_func0(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); UniValue custom_func1(uint64_t txfee,struct CCcontract_info *cp,cJSON *params); #define CUSTOM_DISPATCH \ -if ( cp->evalcode == EVAL_SUDOKU ) \ +if ( cp->evalcode == EVAL_CUSTOM ) \ { \ if ( strcmp(method,"func0") == 0 ) \ return(custom_func0(txfee,cp,params)); \ From ac70f723be0f6e34e770e470011f6b9bfa1aeab2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 00:42:03 -1100 Subject: [PATCH 13/64] update --- src/cc/customcc.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cc/customcc.cpp b/src/cc/customcc.cpp index 27947b57a..9f58c5c8b 100644 --- a/src/cc/customcc.cpp +++ b/src/cc/customcc.cpp @@ -1,5 +1,13 @@ /* simple stub custom cc + + Just update the functions in this file, then from ~/komodo/src/cc + + ../komodo-cli -ac_name=CUSTOM stop + ./makecustom + ../komodod -ac_name=CUSTOM -ac_cclib=custom -ac_cc=2 ... + + The above will rebuild komodod and get it running again */ CScript custom_opret(uint8_t funcid,CPubKey pk) From 6579ea6c21c12d2fe20a879f87b00d6aecc91e0a Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Wed, 13 Mar 2019 14:03:43 +0200 Subject: [PATCH 14/64] Patch rogue msvc (#1330) * + msvc 2015 deps headers * + msvc deps build script this script builds only deps, to build rogue binary, open *.sln file in MSVC 2015 and build x64 Release version. * + msvc solution (*.sln) update * + msvc build fix * fix libcurl deps install (msvc) * [msvc] fix seed str -> uint64 conversion * [msvc] fix config file name issue + debug print for send raw tx * + comment debug printouts * [ msvc ] display compiler version and build date on startup --- src/cc/rogue/main.c | 57 ++++++++++++++++++++++++++++++++++++++++++++ src/cc/rogue/rogue.c | 10 +++++++- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index da46898f8..f146cfb4d 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -767,6 +767,17 @@ int32_t rogue_sendrawtransaction(char *rawtx) } free_json(retjson); } + + /* log sendrawtx result in file */ + + /* + FILE *debug_file; + debug_file = fopen("tx_debug.log", "a"); + fprintf(debug_file, "%s\n", retstr); + fflush(debug_file); + fclose(debug_file); + */ + free(retstr); } free(params); @@ -930,9 +941,46 @@ int32_t rogue_setplayerdata(struct rogue_state *rs,char *gametxidstr) return(retval); } +#ifdef _WIN32 +#ifdef _MSC_VER +__inline int msver(void) { + switch (_MSC_VER) { + case 1500: return 2008; + case 1600: return 2010; + case 1700: return 2012; + case 1800: return 2013; + case 1900: return 2015; + //case 1910: return 2017; + default: return (_MSC_VER / 100); + } +} + +static inline bool is_x64(void) { +#if defined(__x86_64__) || defined(_WIN64) || defined(__aarch64__) + return 1; +#elif defined(__amd64__) || defined(__amd64) || defined(_M_X64) || defined(_M_IA64) + return 1; +#else + return 0; +#endif +} + +#define BUILD_DATE __DATE__ " " __TIME__ +#endif // _WIN32 +#endif // _MSC_VER + int main(int argc, char **argv, char **envp) { uint64_t seed; FILE *fp = 0; int32_t i,j,c; char userpass[8192]; + + #ifdef _WIN32 + #ifdef _MSC_VER + printf("*** rogue for Windows [ Build %s ] ***\n", BUILD_DATE); + const char* arch = is_x64() ? "64-bits" : "32-bits"; + printf(" Built with VC++ %d (%ld) %s\n\n", msver(), _MSC_FULL_VER, arch); + #endif + #endif + for (i=j=0; argv[0][i]!=0&&jsleeptime = 1; // non-zero to allow refresh() if ( argc == 3 && strlen(argv[2]) == 64 ) { - rs->seed = atol(argv[1]); + #ifdef _WIN32 + #ifdef _MSC_VER + rs->seed = _strtoui64(argv[1], NULL, 10); + #else + rs->seed = atol(argv[1]); // windows, but not MSVC + #endif // _MSC_VER + #else + rs->seed = atol(argv[1]); // non-windows + #endif // _WIN32 strcpy(Gametxidstr,argv[2]); fprintf(stderr,"setplayerdata\n"); if ( rogue_setplayerdata(rs,Gametxidstr) < 0 ) From 153a63a915c01ddff35ea6ae23e913abb2f7c880 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 01:14:12 -1100 Subject: [PATCH 15/64] +pritns --- src/cc/rogue_rpc.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index f765a17b9..c47b4e7f6 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -487,6 +487,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,active,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; batonvalue = numkeys = numplayers = batonht = 0; playertxid = batontxid = zeroid; + *keystrokesp = 0; for (i=0; i 0 ) { @@ -969,7 +970,9 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto fclose(fp); } } + fprintf(stderr,"call replay2\n"); num = rogue_replay2(newplayer,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); + fprintf(stderr,"back replay2\n"); newdata.resize(num); for (i=0; i Date: Wed, 13 Mar 2019 01:33:50 -1100 Subject: [PATCH 16/64] +prints --- src/cc/rogue_rpc.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c47b4e7f6..e9f9a3f90 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -321,6 +321,23 @@ int32_t rogue_isvalidgame(struct CCcontract_info *cp,int32_t &gameheight,CTransa } else return(-1); } +void disp_playerdata(std::vector playerdata) +{ + struct rogue_player P; int32_t i; char packitemstr[512]; + if ( playerdata.size() > 0 ) + { + for (i=0; i>16,P.level,P.experience,P.dungeonlevel); + for (i=0; i playerdata,uint256 playertxid,uint256 tokenid,std::string symbol,std::string pname,uint256 gametxid) { int32_t i,vout,spentvini,numvouts,n=0; uint256 txid,spenttxid,hashBlock; struct rogue_player P; char packitemstr[512],*datastr=0; UniValue obj(UniValue::VOBJ),a(UniValue::VARR); CTransaction tx; @@ -944,7 +961,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto { UniValue obj; seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr); -fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); +//fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxid.%s\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size(),playertxid.GetHex().c_str()); memset(&P,0,sizeof(P)); if ( playerdata.size() > 0 ) { @@ -970,9 +987,9 @@ fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d playertxi fclose(fp); } } - fprintf(stderr,"call replay2\n"); + //fprintf(stderr,"call replay2\n"); num = rogue_replay2(newplayer,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); - fprintf(stderr,"back replay2\n"); + //fprintf(stderr,"back replay2\n"); newdata.resize(num); for (i=0; i Date: Wed, 13 Mar 2019 01:40:56 -1100 Subject: [PATCH 17/64] I, --- src/cc/rogue_rpc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index e9f9a3f90..67a6f7667 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -332,7 +332,7 @@ void disp_playerdata(std::vector playerdata) for (i=0; i>16,P.level,P.experience,P.dungeonlevel); fprintf(stderr,"newdata[%d] != playerdata[%d], numkeys.%d %s pub.%s playertxid.%s good.%d bad.%d\n",(int32_t)newdata.size(),(int32_t)playerdata.size(),numkeys,rogueaddr,pubkey33_str(str2,(uint8_t *)&pk),playertxid.GetHex().c_str(),good,bad); } From ec0669c374a802ec792cf3ecf02b6359ad187497 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 01:44:36 -1100 Subject: [PATCH 18/64] Print hex --- src/cc/rogue_rpc.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 67a6f7667..12a95766b 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -327,8 +327,11 @@ void disp_playerdata(std::vector playerdata) if ( playerdata.size() > 0 ) { for (i=0; i>16,P.level,P.experience,P.dungeonlevel); + fprintf(stderr,"%02x",playerdata[i]); + } + fprintf(stderr," <- playerdata: gold.%d hp.%d strength.%d/%d level.%d exp.%d dl.%d\n",P.gold,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel); for (i=0; i Date: Wed, 13 Mar 2019 01:49:28 -1100 Subject: [PATCH 19/64] Allow gold mismatch for validate --- src/cc/rogue_rpc.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 12a95766b..3766ba5ee 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1133,6 +1133,17 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C } return(0); } + newdata[0] = newdata[1] = playerdata[0] = playerdata[1] = 0; // vout.2 check will validate gold + if ( newdata == playerdata ) + { + if ( gametxid != prevgame ) + { + prevgame = gametxid; + good++; + fprintf(stderr,"%s matched after clearing lower 16bits of gold good.%d bad.%d\n",gametxid.GetHex().c_str(),good,bad); + } + return(0); + } if ( P.gold <= 0 || P.hitpoints <= 0 || (P.strength&0xffff) <= 0 || P.level <= 0 || P.experience <= 0 || P.dungeonlevel <= 0 ) { //P.gold = (P.gold * 8) / 10; From 526beb964f78628945d729bbb74cf6f5305661ea Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 01:58:40 -1100 Subject: [PATCH 20/64] Stricter player data validation --- src/cc/rogue_rpc.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 3766ba5ee..12ec60f14 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1572,28 +1572,31 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C return eval->Invalid("couldnt decode H/Q opret"); } // verify pk belongs to this tx - if ( tokentx == 'c' && playerdata.size() > 0 ) + if ( tokentx == 'c' ) { - static char laststr[512]; char cashstr[512]; - if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) + if ( playerdata.size() > 0 ) { - sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",tokentx,decoded,height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); + static char laststr[512]; char cashstr[512]; + if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 ) + { + sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",tokentx,decoded,height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size()); + if ( strcmp(laststr,cashstr) != 0 ) + { + strcpy(laststr,cashstr); + fprintf(stderr,"%s\n",cashstr); + } + if ( enabled != 0 ) + return eval->Invalid("mismatched playerdata"); + } + if ( funcid == 'H' ) + cashout *= 2; + sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); if ( strcmp(laststr,cashstr) != 0 ) { strcpy(laststr,cashstr); fprintf(stderr,"%s\n",cashstr); } - if ( enabled != 0 ) - return eval->Invalid("mismatched playerdata"); - } - if ( funcid == 'H' ) - cashout *= 2; - sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN); - if ( strcmp(laststr,cashstr) != 0 ) - { - strcpy(laststr,cashstr); - fprintf(stderr,"%s\n",cashstr); - } + } else cashout = 10000; if ( enabled != 0 && tx.vout[2].nValue != cashout ) return eval->Invalid("mismatched cashout amount"); } From 69848917c8c7436385920a6630c5ccce8772c5ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 02:26:05 -1100 Subject: [PATCH 21/64] Change data source --- src/cc/rogue_rpc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 12ec60f14..aa634e089 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1104,8 +1104,8 @@ int32_t rogue_playerdata_validate(int64_t *cashoutp,uint256 &playertxid,struct C sprintf(fname,"rogue.%llu.pack",(long long)seed); remove(fname); - for (i=0; i Date: Wed, 13 Mar 2019 02:38:19 -1100 Subject: [PATCH 22/64] Allow claiming less than cashout value --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index aa634e089..af96fd2a2 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1597,7 +1597,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C fprintf(stderr,"%s\n",cashstr); } } else cashout = 10000; - if ( enabled != 0 && tx.vout[2].nValue != cashout ) + if ( enabled != 0 && tx.vout[2].nValue > cashout ) return eval->Invalid("mismatched cashout amount"); } if ( funcid == 'Q' ) From cc5aa0b33883a2325597300c38b76fb06b7e70cc Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 02:51:36 -1100 Subject: [PATCH 23/64] 50902 exemption --- src/cc/rogue_rpc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index af96fd2a2..ffa9545d7 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1498,6 +1498,8 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( (numvouts= tx.vout.size()) > 1 ) { txid = tx.GetHash(); + if ( tx == Parseuint256("1ae04dc0c5f2fca2053819a3a1b2efe5d355c34f58d6f16d59e5e2573e7baf7f") ) // osx rogue chain ht.50902 + enabled = 0; scriptPubKey = tx.vout[numvouts-1].scriptPubKey; GetOpReturnData(scriptPubKey,vopret); if ( vopret.size() > 2 ) From 6d4b45dc5e72c1bf32aeab6f1392ec7098ce1d01 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 02:52:13 -1100 Subject: [PATCH 24/64] Taxied --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index ffa9545d7..c10e03757 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1498,7 +1498,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C if ( (numvouts= tx.vout.size()) > 1 ) { txid = tx.GetHash(); - if ( tx == Parseuint256("1ae04dc0c5f2fca2053819a3a1b2efe5d355c34f58d6f16d59e5e2573e7baf7f") ) // osx rogue chain ht.50902 + if ( txid == Parseuint256("1ae04dc0c5f2fca2053819a3a1b2efe5d355c34f58d6f16d59e5e2573e7baf7f") ) // osx rogue chain ht.50902 enabled = 0; scriptPubKey = tx.vout[numvouts-1].scriptPubKey; GetOpReturnData(scriptPubKey,vopret); From d4a4e6e6c6abb242af70869666664005b9e4dad4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 05:29:24 -1100 Subject: [PATCH 25/64] Print --- src/cc/rogue/new_level.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/new_level.c b/src/cc/rogue/new_level.c index c2ec5219d..dbe59ac40 100644 --- a/src/cc/rogue/new_level.c +++ b/src/cc/rogue/new_level.c @@ -26,7 +26,7 @@ new_level(struct rogue_state *rs) PLACE *pp; char *sp; int i; - + fprintf(stderr,"newlevel seed.%llu\n",(long long)seed); player.t_flags &= ~ISHELD; /* unhold when you go down just in case */ if (level > max_level) max_level = level; From b4c7d73c782de9ea349f1826080d7969d6b0bcb6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 05:31:23 -1100 Subject: [PATCH 26/64] Debug file --- src/cc/rogue/new_level.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue/new_level.c b/src/cc/rogue/new_level.c index dbe59ac40..6450a2748 100644 --- a/src/cc/rogue/new_level.c +++ b/src/cc/rogue/new_level.c @@ -26,7 +26,16 @@ new_level(struct rogue_state *rs) PLACE *pp; char *sp; int i; - fprintf(stderr,"newlevel seed.%llu\n",(long long)seed); + { + static FILE *fp; + if ( fp == 0 ) + fp = fopen("debug","wb"); + if ( fp != 0 ) + { + fprintf(fp,"newlevel seed.%llu\n",(long long)seed); + fflush(fp); + } + } player.t_flags &= ~ISHELD; /* unhold when you go down just in case */ if (level > max_level) max_level = level; From 393c9a065eddce6c69a2eb5714e1b8fec690eabf Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 05:35:04 -1100 Subject: [PATCH 27/64] Log seed --- src/cc/rogue/io.c | 4 ++-- src/cc/rogue/new_level.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 4c289ad7d..11321763a 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -160,14 +160,14 @@ readchar(struct rogue_state *rs) if ( rs->ind < rs->numkeys ) { c = rs->keystrokes[rs->ind++]; - if ( 0 ) + if ( 1 ) { static FILE *fp; static int32_t counter; if ( fp == 0 ) fp = fopen("log","wb"); if ( fp != 0 ) { - fprintf(fp,"%d: (%c) hp.%d num.%d\n",counter,c,pstats.s_hpt,num_packitems(rs)); + fprintf(fp,"%d: (%c) hp.%d num.%d gold.%d seed.%llu\n",counter,c,pstats.s_hpt,num_packitems(rs),purse,(long long)seed); fflush(fp); counter++; } diff --git a/src/cc/rogue/new_level.c b/src/cc/rogue/new_level.c index 6450a2748..ca0e5efb3 100644 --- a/src/cc/rogue/new_level.c +++ b/src/cc/rogue/new_level.c @@ -26,6 +26,7 @@ new_level(struct rogue_state *rs) PLACE *pp; char *sp; int i; + if ( 0 ) { static FILE *fp; if ( fp == 0 ) From 31ecac1e220637ba8ade2b90370cdcf8b072fb06 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 05:43:20 -1100 Subject: [PATCH 28/64] Potion file --- src/cc/rogue/potions.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index b10f83bd4..251e425e8 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -78,7 +78,16 @@ quaff(struct rogue_state *rs) } if (obj == cur_weapon) cur_weapon = NULL; - + static FILE *fp; + { + if ( fp == 0 ) + fp = fopen("potions","wb"); + if ( fp != 0 ) + { + fprintf(fp,"potion.%d\n",obj->o_which) + fflush(fp); + } + } /* * Calculate the effect it has on the poor guy. */ @@ -91,7 +100,12 @@ quaff(struct rogue_state *rs) do_pot(rs,P_CONFUSE, !trip); when P_POISON: pot_info[P_POISON].oi_know = TRUE; - if (ISWEARING(R_SUSTSTR)) + if ( fp != 0 ) + { + fprintf(fp,"poison iswearing.%d left.%d right.%d\n",ISWEARING(R_SUSTSTR),ISRING(LEFT, R_SUSTSTR),ISRING(RIGHT, R_SUSTSTR)) + fflush(fp); + } + if (ISWEARING(R_SUSTSTR)) msg(rs,"you feel momentarily sick"); else { From 94eaa600de22520178a0cfd6636d5e0787e76aee Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 05:45:09 -1100 Subject: [PATCH 29/64] ; --- src/cc/rogue/potions.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index 251e425e8..ea5b7fae0 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -84,7 +84,7 @@ quaff(struct rogue_state *rs) fp = fopen("potions","wb"); if ( fp != 0 ) { - fprintf(fp,"potion.%d\n",obj->o_which) + fprintf(fp,"potion.%d\n",obj->o_which); fflush(fp); } } @@ -102,7 +102,7 @@ quaff(struct rogue_state *rs) pot_info[P_POISON].oi_know = TRUE; if ( fp != 0 ) { - fprintf(fp,"poison iswearing.%d left.%d right.%d\n",ISWEARING(R_SUSTSTR),ISRING(LEFT, R_SUSTSTR),ISRING(RIGHT, R_SUSTSTR)) + fprintf(fp,"poison iswearing.%d left.%d right.%d\n",ISWEARING(R_SUSTSTR),ISRING(LEFT, R_SUSTSTR),ISRING(RIGHT, R_SUSTSTR)); fflush(fp); } if (ISWEARING(R_SUSTSTR)) From fc6546f8d9426f983af176de6a2de06e4e4173f9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 05:48:02 -1100 Subject: [PATCH 30/64] Log seed --- src/cc/rogue/potions.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index ea5b7fae0..7168913b8 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -84,7 +84,7 @@ quaff(struct rogue_state *rs) fp = fopen("potions","wb"); if ( fp != 0 ) { - fprintf(fp,"potion.%d\n",obj->o_which); + fprintf(fp,"potion.%d seed.%llu\n",obj->o_which,(long long)seed); fflush(fp); } } @@ -100,11 +100,6 @@ quaff(struct rogue_state *rs) do_pot(rs,P_CONFUSE, !trip); when P_POISON: pot_info[P_POISON].oi_know = TRUE; - if ( fp != 0 ) - { - fprintf(fp,"poison iswearing.%d left.%d right.%d\n",ISWEARING(R_SUSTSTR),ISRING(LEFT, R_SUSTSTR),ISRING(RIGHT, R_SUSTSTR)); - fflush(fp); - } if (ISWEARING(R_SUSTSTR)) msg(rs,"you feel momentarily sick"); else @@ -113,6 +108,11 @@ quaff(struct rogue_state *rs) msg(rs,"you feel very sick now"); come_down(rs,0); } + if ( fp != 0 ) + { + fprintf(fp,"poison iswearing.%d left.%d right.%d seed.%llu\n",ISWEARING(R_SUSTSTR),ISRING(LEFT, R_SUSTSTR),ISRING(RIGHT, R_SUSTSTR),(long long)seed); + fflush(fp); + } when P_HEALING: pot_info[P_HEALING].oi_know = TRUE; if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_hp) From 37392635f74e31fc9404b809dc4276b5b385b806 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:02:27 -1100 Subject: [PATCH 31/64] Commands log --- src/cc/rogue/command.c | 10 ++++++++++ src/cc/rogue/potions.c | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 84281c5a7..022fac8bb 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -475,6 +475,16 @@ over: search(rs); else if (ISRING(RIGHT, R_TELEPORT) && rnd(50) == 0) teleport(rs); + { + static FILE *fp; + if ( fp == 0 ) + fp = fopen("commands","wb"); + if ( fp != 0 ) + { + fprintf(stderr,"after command seed.%llu\n",(long long)seed); + fflush(fp); + } + } } /* diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index 7168913b8..f452bf0e7 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -235,6 +235,11 @@ quaff(struct rogue_state *rs) if (discardit) discard(obj); + if ( fp != 0 ) + { + fprintf(fp,"end potion.%d seed.%llu\n",obj->o_which,(long long)seed); + fflush(fp); + } return; } From 2a3370da6da0419c1419f1aa904bc8e42538a24e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:03:06 -1100 Subject: [PATCH 32/64] Fp --- src/cc/rogue/command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 022fac8bb..5625900dd 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -481,7 +481,7 @@ over: fp = fopen("commands","wb"); if ( fp != 0 ) { - fprintf(stderr,"after command seed.%llu\n",(long long)seed); + fprintf(fp,"after command seed.%llu\n",(long long)seed); fflush(fp); } } From 6e8626bbff79e61d80b4378c591762590b63abf0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:06:48 -1100 Subject: [PATCH 33/64] Test --- src/cc/rogue/command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 5625900dd..3a04d37b3 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -481,7 +481,7 @@ over: fp = fopen("commands","wb"); if ( fp != 0 ) { - fprintf(fp,"after command seed.%llu\n",(long long)seed); + fprintf(fp,"after command (%c).%d seed.%llu\n",ch,ch,(long long)seed); fflush(fp); } } From dece47b479a4d8788acf3e7956842cfec006abe8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:20:20 -1100 Subject: [PATCH 34/64] Prints --- src/cc/rogue/command.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 3a04d37b3..7f03003b2 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -455,7 +455,15 @@ over: if (!running) door_stop = FALSE; } - /* + static FILE *fp; + if ( fp == 0 ) + fp = fopen("commands","wb"); + if ( fp != 0 ) + { + fprintf(fp,"after switch (%c).%d seed.%llu take.%d running.%d after.%d ntimes.%d\n",ch,ch,(long long)seed,take,running,after,ntimes); + fflush(fp); + } +/* * If he ran into something to take, let him pick it up. */ if (take != 0) @@ -465,8 +473,18 @@ over: if (!after) ntimes++; } + if ( fp != 0 ) + { + fprintf(fp,"after if (%c).%d seed.%llu\n",ch,ch,(long long)seed); + fflush(fp); + } do_daemons(rs,AFTER); do_fuses(rs,AFTER); + if ( fp != 0 ) + { + fprintf(fp,"after fuses (%c).%d seed.%llu isring.%d teleport.%d || search.%d teleport.%d\n",ch,ch,(long long)seed,ISRING(LEFT, R_SEARCH),ISRING(LEFT, R_TELEPORT),ISRING(RIGHT, R_SEARCH),ISRING(RIGHT, R_TELEPORT)); + fflush(fp); + } if (ISRING(LEFT, R_SEARCH)) search(rs); else if (ISRING(LEFT, R_TELEPORT) && rnd(50) == 0) @@ -475,15 +493,10 @@ over: search(rs); else if (ISRING(RIGHT, R_TELEPORT) && rnd(50) == 0) teleport(rs); + if ( fp != 0 ) { - static FILE *fp; - if ( fp == 0 ) - fp = fopen("commands","wb"); - if ( fp != 0 ) - { - fprintf(fp,"after command (%c).%d seed.%llu\n",ch,ch,(long long)seed); - fflush(fp); - } + fprintf(fp,"after command (%c).%d seed.%llu\n",ch,ch,(long long)seed); + fflush(fp); } } From f1417140a5ce1e62b13179b3c697e8b508edb33d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:21:06 -1100 Subject: [PATCH 35/64] static FILE *fp; --- src/cc/rogue/command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 7f03003b2..e19c5e138 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -20,6 +20,7 @@ void command(struct rogue_state *rs) { + static FILE *fp; register char ch; register int ntimes = 1; /* Number of player moves */ char *fp; @@ -455,7 +456,6 @@ over: if (!running) door_stop = FALSE; } - static FILE *fp; if ( fp == 0 ) fp = fopen("commands","wb"); if ( fp != 0 ) From 9e79992258d7b3067db0dc7daa8a4e8bdfd94bee Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:22:23 -1100 Subject: [PATCH 36/64] Fp2 --- src/cc/rogue/command.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index e19c5e138..f16ffc8c2 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -20,7 +20,7 @@ void command(struct rogue_state *rs) { - static FILE *fp; + static FILE *fp2; register char ch; register int ntimes = 1; /* Number of player moves */ char *fp; @@ -456,12 +456,12 @@ over: if (!running) door_stop = FALSE; } - if ( fp == 0 ) - fp = fopen("commands","wb"); - if ( fp != 0 ) + if ( fp2 == 0 ) + fp2 = fopen("commands","wb"); + if ( fp2 != 0 ) { - fprintf(fp,"after switch (%c).%d seed.%llu take.%d running.%d after.%d ntimes.%d\n",ch,ch,(long long)seed,take,running,after,ntimes); - fflush(fp); + fprintf(fp2,"after switch (%c).%d seed.%llu take.%d running.%d after.%d ntimes.%d\n",ch,ch,(long long)seed,take,running,after,ntimes); + fflush(fp2); } /* * If he ran into something to take, let him pick it up. @@ -473,17 +473,17 @@ over: if (!after) ntimes++; } - if ( fp != 0 ) + if ( fp2 != 0 ) { - fprintf(fp,"after if (%c).%d seed.%llu\n",ch,ch,(long long)seed); - fflush(fp); + fprintf(fp2,"after if (%c).%d seed.%llu\n",ch,ch,(long long)seed); + fflush(fp2); } do_daemons(rs,AFTER); do_fuses(rs,AFTER); - if ( fp != 0 ) + if ( fp2 != 0 ) { - fprintf(fp,"after fuses (%c).%d seed.%llu isring.%d teleport.%d || search.%d teleport.%d\n",ch,ch,(long long)seed,ISRING(LEFT, R_SEARCH),ISRING(LEFT, R_TELEPORT),ISRING(RIGHT, R_SEARCH),ISRING(RIGHT, R_TELEPORT)); - fflush(fp); + fprintf(fp2,"after fuses (%c).%d seed.%llu isring.%d teleport.%d || search.%d teleport.%d\n",ch,ch,(long long)seed,ISRING(LEFT, R_SEARCH),ISRING(LEFT, R_TELEPORT),ISRING(RIGHT, R_SEARCH),ISRING(RIGHT, R_TELEPORT)); + fflush(fp2); } if (ISRING(LEFT, R_SEARCH)) search(rs); @@ -493,10 +493,10 @@ over: search(rs); else if (ISRING(RIGHT, R_TELEPORT) && rnd(50) == 0) teleport(rs); - if ( fp != 0 ) + if ( fp2 != 0 ) { - fprintf(fp,"after command (%c).%d seed.%llu\n",ch,ch,(long long)seed); - fflush(fp); + fprintf(fp2,"after command (%c).%d seed.%llu\n",ch,ch,(long long)seed); + fflush(fp2); } } From e5d33bab939d0e0f7a0fe8908659a6665a74218f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:29:59 -1100 Subject: [PATCH 37/64] Daemons or fuses --- src/cc/rogue/command.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index f16ffc8c2..dac6ba2b9 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -456,13 +456,6 @@ over: if (!running) door_stop = FALSE; } - if ( fp2 == 0 ) - fp2 = fopen("commands","wb"); - if ( fp2 != 0 ) - { - fprintf(fp2,"after switch (%c).%d seed.%llu take.%d running.%d after.%d ntimes.%d\n",ch,ch,(long long)seed,take,running,after,ntimes); - fflush(fp2); - } /* * If he ran into something to take, let him pick it up. */ @@ -473,12 +466,19 @@ over: if (!after) ntimes++; } + if ( fp2 == 0 ) + fp2 = fopen("commands","wb"); if ( fp2 != 0 ) { fprintf(fp2,"after if (%c).%d seed.%llu\n",ch,ch,(long long)seed); fflush(fp2); } do_daemons(rs,AFTER); + if ( fp2 != 0 ) + { + fprintf(fp2,"after daemons (%c).%d seed.%llu isring.%d teleport.%d || search.%d teleport.%d\n",ch,ch,(long long)seed,ISRING(LEFT, R_SEARCH),ISRING(LEFT, R_TELEPORT),ISRING(RIGHT, R_SEARCH),ISRING(RIGHT, R_TELEPORT)); + fflush(fp2); + } do_fuses(rs,AFTER); if ( fp2 != 0 ) { From 5b32b491b659d313f580fa66522fac16f83ab857 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:39:21 -1100 Subject: [PATCH 38/64] Fuse prints --- src/cc/rogue/armor.c | 4 ++-- src/cc/rogue/command.c | 4 ++-- src/cc/rogue/daemon.c | 20 +++++++++++++++++--- src/cc/rogue/rogue.h | 2 +- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/cc/rogue/armor.c b/src/cc/rogue/armor.c index 20c5704a8..f8c491121 100644 --- a/src/cc/rogue/armor.c +++ b/src/cc/rogue/armor.c @@ -83,7 +83,7 @@ void waste_time(struct rogue_state *rs) { do_daemons(rs,BEFORE); - do_fuses(rs,BEFORE); + do_fuses(rs,BEFORE,0); do_daemons(rs,AFTER); - do_fuses(rs,AFTER); + do_fuses(rs,AFTER,0); } diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index dac6ba2b9..3de5db534 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -32,7 +32,7 @@ command(struct rogue_state *rs) * Let the daemons start up */ do_daemons(rs,BEFORE); - do_fuses(rs,BEFORE); + do_fuses(rs,BEFORE,0); while (ntimes--) { if ( rs->replaydone != 0 ) @@ -479,7 +479,7 @@ over: fprintf(fp2,"after daemons (%c).%d seed.%llu isring.%d teleport.%d || search.%d teleport.%d\n",ch,ch,(long long)seed,ISRING(LEFT, R_SEARCH),ISRING(LEFT, R_TELEPORT),ISRING(RIGHT, R_SEARCH),ISRING(RIGHT, R_TELEPORT)); fflush(fp2); } - do_fuses(rs,AFTER); + do_fuses(rs,AFTER,fp2); if ( fp2 != 0 ) { fprintf(fp2,"after fuses (%c).%d seed.%llu isring.%d teleport.%d || search.%d teleport.%d\n",ch,ch,(long long)seed,ISRING(LEFT, R_SEARCH),ISRING(LEFT, R_TELEPORT),ISRING(RIGHT, R_SEARCH),ISRING(RIGHT, R_TELEPORT)); diff --git a/src/cc/rogue/daemon.c b/src/cc/rogue/daemon.c index 1da06d499..b81e57585 100644 --- a/src/cc/rogue/daemon.c +++ b/src/cc/rogue/daemon.c @@ -160,10 +160,22 @@ extinguish(void (*func)(struct rogue_state *rs,int)) * do_fuses: * Decrement counters and start needed fuses */ -void -do_fuses(struct rogue_state *rs,int flag) + +char *actionfunc_str(char *str,void *ptr) { - register struct delayed_action *wire; + if ( ptr == (void *)runners ) + strcpy(str,"runners"); + else if ( ptr == (void *)doctor ) + strcpy(str,"doctor"); + else if ( ptr == (void *)stomach ) + strcpy(str,"stomach"); + else strcpy(str,"no match"); + return(str); +} +void +do_fuses(struct rogue_state *rs,int flag,FILE *fp) +{ + register struct delayed_action *wire; char str[64]; /* * Step though the list @@ -175,6 +187,8 @@ do_fuses(struct rogue_state *rs,int flag) */ if (flag == wire->d_type && wire->d_time > 0 && --wire->d_time == 0) { + if ( fp != 0 ) + fprintf(fp,"t.%d %d %s, ",wire->d_type,wire->d_time,actionfunc_str(str,wire->d_func)); wire->d_type = EMPTY; (*wire->d_func)(rs,wire->d_arg); } diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index ba57adbe6..b8d162ca3 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -619,7 +619,7 @@ int dist(int y1, int x1, int y2, int x2); int dist_cp(coord *c1, coord *c2); int do_chase(struct rogue_state *rs,THING *th); void do_daemons(struct rogue_state *rs,int flag); -void do_fuses(struct rogue_state *rs,int flag); +void do_fuses(struct rogue_state *rs,int flag,FILE *fp); void do_maze(struct rogue_state *rs,struct room *rp); void do_motion(struct rogue_state *rs,THING *obj, int ydelta, int xdelta); void do_move(struct rogue_state *rs,int dy, int dx); From 01a63eb151c458a340d861f3d6f0b433254c2617 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 06:49:46 -1100 Subject: [PATCH 39/64] All funcs --- src/cc/rogue/daemon.c | 18 ++++++++++++++++++ src/cc/rogue/potions.c | 12 ++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/cc/rogue/daemon.c b/src/cc/rogue/daemon.c index b81e57585..e14213bfe 100644 --- a/src/cc/rogue/daemon.c +++ b/src/cc/rogue/daemon.c @@ -169,6 +169,24 @@ char *actionfunc_str(char *str,void *ptr) strcpy(str,"doctor"); else if ( ptr == (void *)stomach ) strcpy(str,"stomach"); + else if ( ptr == (void *)nohaste ) + strcpy(str,"nohaste"); + else if ( ptr == (void *)unconfuse ) + strcpy(str,"unconfuse"); + else if ( ptr == (void *)swander ) + strcpy(str,"swander"); + else if ( ptr == (void *)come_down ) + strcpy(str,"come_down"); + else if ( ptr == (void *)unsee ) + strcpy(str,"unsee"); + else if ( ptr == (void *)sight ) + strcpy(str,"sight"); + else if ( ptr == (void *)land ) + strcpy(str,"land"); + else if ( ptr == (void *)rollwand ) + strcpy(str,"rollwand"); + else if ( ptr == (void *)visuals ) + strcpy(str,"visuals"); else strcpy(str,"no match"); return(str); } diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index f452bf0e7..4e818f0ec 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -377,18 +377,18 @@ do_pot(struct rogue_state *rs,int type, bool knowit) { PACT *pp; int t; - + pp = &p_actions[type]; if (!pot_info[type].oi_know) - pot_info[type].oi_know = knowit; + pot_info[type].oi_know = knowit; t = spread(pp->pa_time); if (!on(player, pp->pa_flags)) { - player.t_flags |= pp->pa_flags; - fuse(pp->pa_daemon, 0, t, AFTER); - look(rs,FALSE); + player.t_flags |= pp->pa_flags; + fuse(pp->pa_daemon, 0, t, AFTER); + look(rs,FALSE); } else - lengthen(pp->pa_daemon, t); + lengthen(pp->pa_daemon, t); msg(rs,choose_str(pp->pa_high, pp->pa_straight)); } From 8f18bbbed5cb32ec4f87e5f1b0e3617732cf352c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 07:14:29 -1100 Subject: [PATCH 40/64] Logfp --- src/cc/rogue/command.c | 2 +- src/cc/rogue/daemon.c | 1 + src/cc/rogue/daemons.c | 106 +++++++++++++++++++++++++---------------- src/cc/rogue/rogue.h | 1 + 4 files changed, 67 insertions(+), 43 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 3de5db534..d9fc266c2 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -467,7 +467,7 @@ over: ntimes++; } if ( fp2 == 0 ) - fp2 = fopen("commands","wb"); + rs->logfp = fp2 = fopen("commands","wb"); if ( fp2 != 0 ) { fprintf(fp2,"after if (%c).%d seed.%llu\n",ch,ch,(long long)seed); diff --git a/src/cc/rogue/daemon.c b/src/cc/rogue/daemon.c index e14213bfe..118ca3c37 100644 --- a/src/cc/rogue/daemon.c +++ b/src/cc/rogue/daemon.c @@ -190,6 +190,7 @@ char *actionfunc_str(char *str,void *ptr) else strcpy(str,"no match"); return(str); } + void do_fuses(struct rogue_state *rs,int flag,FILE *fp) { diff --git a/src/cc/rogue/daemons.c b/src/cc/rogue/daemons.c index 42e685320..71a3789a9 100644 --- a/src/cc/rogue/daemons.c +++ b/src/cc/rogue/daemons.c @@ -21,6 +21,8 @@ void doctor(struct rogue_state *rs,int arg) { register int lv, ohp; + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"doctor\n"); lv = pstats.s_lvl; ohp = pstats.s_hpt; @@ -52,6 +54,8 @@ doctor(struct rogue_state *rs,int arg) void swander(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"swander\n"); start_daemon(rollwand, 0, BEFORE); } @@ -63,6 +67,8 @@ int between = 0; void rollwand(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"rollwand\n"); if (++between >= 4) { if (roll(1, 6) == 4) @@ -82,6 +88,8 @@ rollwand(struct rogue_state *rs,int arg) void unconfuse(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"unconfuse\n"); player.t_flags &= ~ISHUH; msg(rs,"you feel less %s now", choose_str("trippy", "confused")); } @@ -94,6 +102,8 @@ void unsee(struct rogue_state *rs,int arg) { register THING *th; + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"unsee\n"); for (th = mlist; th != NULL; th = next(th)) if (on(*th, ISINVIS) && see_monst(th)) @@ -108,6 +118,8 @@ unsee(struct rogue_state *rs,int arg) void sight(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"sight\n"); if (on(player, ISBLIND)) { extinguish(sight); @@ -126,6 +138,8 @@ sight(struct rogue_state *rs,int arg) void nohaste(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"nohaste\n"); player.t_flags &= ~ISHASTE; msg(rs,"you feel yourself slowing down"); } @@ -139,6 +153,8 @@ stomach(struct rogue_state *rs,int arg) { register int oldfood; int orig_hungry = hungry_state; + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"stomach\n"); if (food_left <= 0) { @@ -194,41 +210,43 @@ come_down(struct rogue_state *rs,int arg) { register THING *tp; register bool seemonst; - + + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"come_down\n"); if (!on(player, ISHALU)) - return; - + return; + kill_daemon(visuals); player.t_flags &= ~ISHALU; - + if (on(player, ISBLIND)) - return; - + return; + /* * undo the things */ for (tp = lvl_obj; tp != NULL; tp = next(tp)) - if (cansee(rs,tp->o_pos.y, tp->o_pos.x)) - mvaddch(tp->o_pos.y, tp->o_pos.x, tp->o_type); - + if (cansee(rs,tp->o_pos.y, tp->o_pos.x)) + mvaddch(tp->o_pos.y, tp->o_pos.x, tp->o_type); + /* * undo the monsters */ seemonst = on(player, SEEMONST); for (tp = mlist; tp != NULL; tp = next(tp)) { - move(tp->t_pos.y, tp->t_pos.x); - if (cansee(rs,tp->t_pos.y, tp->t_pos.x)) - if (!on(*tp, ISINVIS) || on(player, CANSEE)) - addch(tp->t_disguise); - else - addch(chat(tp->t_pos.y, tp->t_pos.x)); - else if (seemonst) - { - standout(); - addch(tp->t_type); - standend(); - } + move(tp->t_pos.y, tp->t_pos.x); + if (cansee(rs,tp->t_pos.y, tp->t_pos.x)) + if (!on(*tp, ISINVIS) || on(player, CANSEE)) + addch(tp->t_disguise); + else + addch(chat(tp->t_pos.y, tp->t_pos.x)); + else if (seemonst) + { + standout(); + addch(tp->t_type); + standend(); + } } msg(rs,"Everything looks SO boring now."); } @@ -242,42 +260,44 @@ visuals(struct rogue_state *rs,int arg) { register THING *tp; register bool seemonst; - + if (!after || (running && jump)) - return; + return; + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"visuals\n"); /* * change the things */ for (tp = lvl_obj; tp != NULL; tp = next(tp)) - if (cansee(rs,tp->o_pos.y, tp->o_pos.x)) - mvaddch(tp->o_pos.y, tp->o_pos.x, rnd_thing()); - + if (cansee(rs,tp->o_pos.y, tp->o_pos.x)) + mvaddch(tp->o_pos.y, tp->o_pos.x, rnd_thing()); + /* * change the stairs */ if (!seenstairs && cansee(rs,stairs.y, stairs.x)) - mvaddch(stairs.y, stairs.x, rnd_thing()); - + mvaddch(stairs.y, stairs.x, rnd_thing()); + /* * change the monsters */ seemonst = on(player, SEEMONST); for (tp = mlist; tp != NULL; tp = next(tp)) { - move(tp->t_pos.y, tp->t_pos.x); - if (see_monst(tp)) - { - if (tp->t_type == 'X' && tp->t_disguise != 'X') - addch(rnd_thing()); - else - addch(rnd(26) + 'A'); - } - else if (seemonst) - { - standout(); - addch(rnd(26) + 'A'); - standend(); - } + move(tp->t_pos.y, tp->t_pos.x); + if (see_monst(tp)) + { + if (tp->t_type == 'X' && tp->t_disguise != 'X') + addch(rnd_thing()); + else + addch(rnd(26) + 'A'); + } + else if (seemonst) + { + standout(); + addch(rnd(26) + 'A'); + standend(); + } } } @@ -288,6 +308,8 @@ visuals(struct rogue_state *rs,int arg) void land(struct rogue_state *rs,int arg) { + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"land\n"); player.t_flags &= ~ISLEVIT; msg(rs,choose_str("bummer! You've hit the ground", "you float gently to the ground")); diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index b8d162ca3..dac2b63a3 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -365,6 +365,7 @@ struct rogue_state char *keystrokes,*keystrokeshex; uint32_t needflush,replaydone; int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; + FILE *logfp; struct rogue_player P; char buffered[10000]; uint8_t playerdata[10000]; From 827d8f54f8b8c9d7420584efffa90da3fc80d8c0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 07:31:47 -1100 Subject: [PATCH 41/64] turn_see is a daemon! --- src/cc/rogue/command.c | 6 ++--- src/cc/rogue/daemons.c | 45 ++++++++++++++++++++++++++++++++++++++ src/cc/rogue/misc.c | 18 +++++++-------- src/cc/rogue/new_level.c | 2 +- src/cc/rogue/potions.c | 47 +++------------------------------------- src/cc/rogue/rogue.h | 2 +- src/cc/rogue_rpc.cpp | 4 ++-- 7 files changed, 64 insertions(+), 60 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index d9fc266c2..c57c0615f 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -345,7 +345,7 @@ over: if (wizard) { wizard = FALSE; - turn_see(TRUE); + turn_see(rs,TRUE); msg(rs,"not wizard any more"); } else @@ -354,7 +354,7 @@ over: if (wizard) { noscore = TRUE; - turn_see(FALSE); + turn_see(rs,FALSE); msg(rs,"you are suddenly as smart as Ken Arnold in dungeon #%d", dnum); } else @@ -404,7 +404,7 @@ over: when CTRL('T'): teleport(); when CTRL('E'): msg(rs,"food left: %d", food_left); when CTRL('C'): add_pass(); - when CTRL('X'): turn_see(on(player, SEEMONST)); + when CTRL('X'): turn_see(rs,on(player, SEEMONST)); when CTRL('~'): { THING *item; diff --git a/src/cc/rogue/daemons.c b/src/cc/rogue/daemons.c index 71a3789a9..c9c16448d 100644 --- a/src/cc/rogue/daemons.c +++ b/src/cc/rogue/daemons.c @@ -314,3 +314,48 @@ land(struct rogue_state *rs,int arg) msg(rs,choose_str("bummer! You've hit the ground", "you float gently to the ground")); } + +/* + * turn_see: + * Put on or off seeing monsters on this level + */ +bool +turn_see(struct rogue_state *rs,bool turn_off) +{ + THING *mp; + bool can_see, add_new; + if ( rs->logfp != 0 ) + fprintf(rs->logfp,"turn_see\n"); + + add_new = FALSE; + for (mp = mlist; mp != NULL; mp = next(mp)) + { + move(mp->t_pos.y, mp->t_pos.x); + can_see = see_monst(mp); + if (turn_off) + { + if (!can_see) + addch(mp->t_oldch); + } + else + { + if (!can_see) + standout(); + if (!on(player, ISHALU)) + addch(mp->t_type); + else + addch(rnd(26) + 'A'); + if (!can_see) + { + standend(); + add_new ^= 1;//add_new++; + } + } + } + if (turn_off) + player.t_flags &= ~SEEMONST; + else + player.t_flags |= SEEMONST; + return add_new; +} + diff --git a/src/cc/rogue/misc.c b/src/cc/rogue/misc.c index 8a4d1df94..5f9a89dcc 100644 --- a/src/cc/rogue/misc.c +++ b/src/cc/rogue/misc.c @@ -404,18 +404,18 @@ add_haste(struct rogue_state *rs,bool potion) { if (on(player, ISHASTE)) { - no_command += rnd(8); - player.t_flags &= ~(ISRUN|ISHASTE); - extinguish(nohaste); - msg(rs,"you faint from exhaustion"); - return FALSE; + no_command += rnd(8); + player.t_flags &= ~(ISRUN|ISHASTE); + extinguish(nohaste); + msg(rs,"you faint from exhaustion"); + return FALSE; } else { - player.t_flags |= ISHASTE; - if (potion) - fuse(nohaste, 0, rnd(4)+4, AFTER); - return TRUE; + player.t_flags |= ISHASTE; + if (potion) + fuse(nohaste, 0, rnd(4)+4, AFTER); + return TRUE; } } diff --git a/src/cc/rogue/new_level.c b/src/cc/rogue/new_level.c index ca0e5efb3..c7f08ff28 100644 --- a/src/cc/rogue/new_level.c +++ b/src/cc/rogue/new_level.c @@ -105,7 +105,7 @@ new_level(struct rogue_state *rs) enter_room(rs,&hero); mvaddch(hero.y, hero.x, PLAYER); if (on(player, SEEMONST)) - turn_see(FALSE); + turn_see(rs,FALSE); if (on(player, ISHALU)) visuals(rs,0); } diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index 4e818f0ec..56261118b 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -125,8 +125,8 @@ quaff(struct rogue_state *rs) msg(rs,"you feel stronger, now. What bulging muscles!"); when P_MFIND: player.t_flags |= SEEMONST; - fuse((void(*)(struct rogue_state *rs,int))turn_see, TRUE, HUHDURATION, AFTER); - if (!turn_see(FALSE)) + fuse(turn_see, TRUE, HUHDURATION, AFTER); + if (!turn_see(rs,FALSE)) msg(rs,"you have a %s feeling for a moment, then it passes", choose_str("normal", "strange")); when P_TFIND: @@ -172,7 +172,7 @@ quaff(struct rogue_state *rs) if (!trip) { if (on(player, SEEMONST)) - turn_see(FALSE); + turn_see(rs,FALSE); start_daemon(visuals, 0, BEFORE); seenstairs = seen_stairs(); } @@ -282,47 +282,6 @@ invis_on() mvaddch(mp->t_pos.y, mp->t_pos.x, mp->t_disguise); } -/* - * turn_see: - * Put on or off seeing monsters on this level - */ -bool -turn_see(bool turn_off) -{ - THING *mp; - bool can_see, add_new; - - add_new = FALSE; - for (mp = mlist; mp != NULL; mp = next(mp)) - { - move(mp->t_pos.y, mp->t_pos.x); - can_see = see_monst(mp); - if (turn_off) - { - if (!can_see) - addch(mp->t_oldch); - } - else - { - if (!can_see) - standout(); - if (!on(player, ISHALU)) - addch(mp->t_type); - else - addch(rnd(26) + 'A'); - if (!can_see) - { - standend(); - add_new ^= 1;//add_new++; - } - } - } - if (turn_off) - player.t_flags &= ~SEEMONST; - else - player.t_flags |= SEEMONST; - return add_new; -} /* * seen_stairs: diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index dac2b63a3..2a5b39bf9 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -771,7 +771,7 @@ bool roll_em(THING *thatt, THING *thdef, THING *weap, bool hurl); bool see_monst(THING *mp); bool seen_stairs(void); bool turn_ok(int y, int x); -bool turn_see(bool turn_off); +bool turn_see(struct rogue_state *rs,bool turn_off); bool is_current(struct rogue_state *rs,THING *obj); int passwd(void); diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c10e03757..196bc645a 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1263,8 +1263,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param if ( P.amulet != 0 ) mult *= 5; dungeonlevel = P.dungeonlevel; - if ( P.amulet != 0 && dungeonlevel < 21 ) - dungeonlevel = 21; + if ( P.amulet != 0 && dungeonlevel < 26 ) + dungeonlevel = 26; cashout = (uint64_t)P.gold * P.gold * mult * dungeonlevel; fprintf(stderr,"\nextracted $$$gold.%d -> %.8f ROGUE hp.%d strength.%d/%d level.%d exp.%d dl.%d n.%d amulet.%d\n",P.gold,(double)cashout/COIN,P.hitpoints,P.strength&0xffff,P.strength>>16,P.level,P.experience,P.dungeonlevel,n,P.amulet); if ( funcid == 'H' && maxplayers > 1 ) From 680c622eec80cc570d66f6e276c5256b15b5509a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 07:33:10 -1100 Subject: [PATCH 42/64] 'void (*)(struct rogue_state *, int) --- src/cc/rogue/potions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index 56261118b..27e78303f 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -125,7 +125,7 @@ quaff(struct rogue_state *rs) msg(rs,"you feel stronger, now. What bulging muscles!"); when P_MFIND: player.t_flags |= SEEMONST; - fuse(turn_see, TRUE, HUHDURATION, AFTER); + fuse((void(*)(struct rogue_state *rs,int))turn_see, TRUE, HUHDURATION, AFTER); if (!turn_see(rs,FALSE)) msg(rs,"you have a %s feeling for a moment, then it passes", choose_str("normal", "strange")); From 7a04cea145fa51cc7dfe10400ba13eaa141c1333 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 07:37:40 -1100 Subject: [PATCH 43/64] -prints --- src/cc/rogue/command.c | 25 +------------------------ src/cc/rogue/daemon.c | 2 ++ src/cc/rogue/io.c | 2 +- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index c57c0615f..830fa2356 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -20,7 +20,6 @@ void command(struct rogue_state *rs) { - static FILE *fp2; register char ch; register int ntimes = 1; /* Number of player moves */ char *fp; @@ -466,25 +465,8 @@ over: if (!after) ntimes++; } - if ( fp2 == 0 ) - rs->logfp = fp2 = fopen("commands","wb"); - if ( fp2 != 0 ) - { - fprintf(fp2,"after if (%c).%d seed.%llu\n",ch,ch,(long long)seed); - fflush(fp2); - } do_daemons(rs,AFTER); - if ( fp2 != 0 ) - { - fprintf(fp2,"after daemons (%c).%d seed.%llu isring.%d teleport.%d || search.%d teleport.%d\n",ch,ch,(long long)seed,ISRING(LEFT, R_SEARCH),ISRING(LEFT, R_TELEPORT),ISRING(RIGHT, R_SEARCH),ISRING(RIGHT, R_TELEPORT)); - fflush(fp2); - } - do_fuses(rs,AFTER,fp2); - if ( fp2 != 0 ) - { - fprintf(fp2,"after fuses (%c).%d seed.%llu isring.%d teleport.%d || search.%d teleport.%d\n",ch,ch,(long long)seed,ISRING(LEFT, R_SEARCH),ISRING(LEFT, R_TELEPORT),ISRING(RIGHT, R_SEARCH),ISRING(RIGHT, R_TELEPORT)); - fflush(fp2); - } + do_fuses(rs,AFTER,0); if (ISRING(LEFT, R_SEARCH)) search(rs); else if (ISRING(LEFT, R_TELEPORT) && rnd(50) == 0) @@ -493,11 +475,6 @@ over: search(rs); else if (ISRING(RIGHT, R_TELEPORT) && rnd(50) == 0) teleport(rs); - if ( fp2 != 0 ) - { - fprintf(fp2,"after command (%c).%d seed.%llu\n",ch,ch,(long long)seed); - fflush(fp2); - } } /* diff --git a/src/cc/rogue/daemon.c b/src/cc/rogue/daemon.c index 118ca3c37..c98b10f88 100644 --- a/src/cc/rogue/daemon.c +++ b/src/cc/rogue/daemon.c @@ -187,6 +187,8 @@ char *actionfunc_str(char *str,void *ptr) strcpy(str,"rollwand"); else if ( ptr == (void *)visuals ) strcpy(str,"visuals"); + else if ( ptr == (void *)turn_see ) + strcpy(str,"turn_see"); else strcpy(str,"no match"); return(str); } diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 11321763a..ad22407f6 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -160,7 +160,7 @@ readchar(struct rogue_state *rs) if ( rs->ind < rs->numkeys ) { c = rs->keystrokes[rs->ind++]; - if ( 1 ) + if ( 0 ) { static FILE *fp; static int32_t counter; if ( fp == 0 ) From 41d89521a1b2181178dc49233543613b5646ee99 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 07:43:10 -1100 Subject: [PATCH 44/64] -file fp --- src/cc/rogue/armor.c | 4 ++-- src/cc/rogue/command.c | 4 ++-- src/cc/rogue/daemon.c | 10 +++++----- src/cc/rogue/rogue.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cc/rogue/armor.c b/src/cc/rogue/armor.c index f8c491121..20c5704a8 100644 --- a/src/cc/rogue/armor.c +++ b/src/cc/rogue/armor.c @@ -83,7 +83,7 @@ void waste_time(struct rogue_state *rs) { do_daemons(rs,BEFORE); - do_fuses(rs,BEFORE,0); + do_fuses(rs,BEFORE); do_daemons(rs,AFTER); - do_fuses(rs,AFTER,0); + do_fuses(rs,AFTER); } diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 830fa2356..568f4b8f8 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -31,7 +31,7 @@ command(struct rogue_state *rs) * Let the daemons start up */ do_daemons(rs,BEFORE); - do_fuses(rs,BEFORE,0); + do_fuses(rs,BEFORE); while (ntimes--) { if ( rs->replaydone != 0 ) @@ -466,7 +466,7 @@ over: ntimes++; } do_daemons(rs,AFTER); - do_fuses(rs,AFTER,0); + do_fuses(rs,AFTER); if (ISRING(LEFT, R_SEARCH)) search(rs); else if (ISRING(LEFT, R_TELEPORT) && rnd(50) == 0) diff --git a/src/cc/rogue/daemon.c b/src/cc/rogue/daemon.c index c98b10f88..81bdd0a73 100644 --- a/src/cc/rogue/daemon.c +++ b/src/cc/rogue/daemon.c @@ -161,7 +161,7 @@ extinguish(void (*func)(struct rogue_state *rs,int)) * Decrement counters and start needed fuses */ -char *actionfunc_str(char *str,void *ptr) +/*char *actionfunc_str(char *str,void *ptr) { if ( ptr == (void *)runners ) strcpy(str,"runners"); @@ -191,10 +191,10 @@ char *actionfunc_str(char *str,void *ptr) strcpy(str,"turn_see"); else strcpy(str,"no match"); return(str); -} +}*/ void -do_fuses(struct rogue_state *rs,int flag,FILE *fp) +do_fuses(struct rogue_state *rs,int flag) { register struct delayed_action *wire; char str[64]; @@ -208,8 +208,8 @@ do_fuses(struct rogue_state *rs,int flag,FILE *fp) */ if (flag == wire->d_type && wire->d_time > 0 && --wire->d_time == 0) { - if ( fp != 0 ) - fprintf(fp,"t.%d %d %s, ",wire->d_type,wire->d_time,actionfunc_str(str,wire->d_func)); + //if ( fp != 0 ) + // fprintf(fp,"t.%d %d %s, ",wire->d_type,wire->d_time,actionfunc_str(str,wire->d_func)); wire->d_type = EMPTY; (*wire->d_func)(rs,wire->d_arg); } diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 2a5b39bf9..5540da2da 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -620,7 +620,7 @@ int dist(int y1, int x1, int y2, int x2); int dist_cp(coord *c1, coord *c2); int do_chase(struct rogue_state *rs,THING *th); void do_daemons(struct rogue_state *rs,int flag); -void do_fuses(struct rogue_state *rs,int flag,FILE *fp); +void do_fuses(struct rogue_state *rs,int flag); void do_maze(struct rogue_state *rs,struct room *rp); void do_motion(struct rogue_state *rs,THING *obj, int ydelta, int xdelta); void do_move(struct rogue_state *rs,int dy, int dx); From 00955f71b0009831de12fddf9b56f949bfd04115 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 07:46:34 -1100 Subject: [PATCH 45/64] -potions file --- src/cc/rogue/potions.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index 27e78303f..2425b051f 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -78,16 +78,6 @@ quaff(struct rogue_state *rs) } if (obj == cur_weapon) cur_weapon = NULL; - static FILE *fp; - { - if ( fp == 0 ) - fp = fopen("potions","wb"); - if ( fp != 0 ) - { - fprintf(fp,"potion.%d seed.%llu\n",obj->o_which,(long long)seed); - fflush(fp); - } - } /* * Calculate the effect it has on the poor guy. */ @@ -108,11 +98,6 @@ quaff(struct rogue_state *rs) msg(rs,"you feel very sick now"); come_down(rs,0); } - if ( fp != 0 ) - { - fprintf(fp,"poison iswearing.%d left.%d right.%d seed.%llu\n",ISWEARING(R_SUSTSTR),ISRING(LEFT, R_SUSTSTR),ISRING(RIGHT, R_SUSTSTR),(long long)seed); - fflush(fp); - } when P_HEALING: pot_info[P_HEALING].oi_know = TRUE; if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_hp) @@ -235,11 +220,6 @@ quaff(struct rogue_state *rs) if (discardit) discard(obj); - if ( fp != 0 ) - { - fprintf(fp,"end potion.%d seed.%llu\n",obj->o_which,(long long)seed); - fflush(fp); - } return; } From 784e1cb1277198a960b4f779f07465a7ea7814df Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 07:52:57 -1100 Subject: [PATCH 46/64] Test --- src/cc/rogue/io.c | 2 +- src/cc/rogue_rpc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index ad22407f6..11321763a 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -160,7 +160,7 @@ readchar(struct rogue_state *rs) if ( rs->ind < rs->numkeys ) { c = rs->keystrokes[rs->ind++]; - if ( 0 ) + if ( 1 ) { static FILE *fp; static int32_t counter; if ( fp == 0 ) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 196bc645a..7fc88b878 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -992,13 +992,13 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto } //fprintf(stderr,"call replay2\n"); num = rogue_replay2(newplayer,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0); - //fprintf(stderr,"back replay2\n"); newdata.resize(num); for (i=0; i no playerdata\n"); From 2f4fd73ed42430a16cd30672ea4cecdf1d7141ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 08:01:36 -1100 Subject: [PATCH 47/64] -log --- src/cc/rogue/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue/io.c b/src/cc/rogue/io.c index 11321763a..ad22407f6 100644 --- a/src/cc/rogue/io.c +++ b/src/cc/rogue/io.c @@ -160,7 +160,7 @@ readchar(struct rogue_state *rs) if ( rs->ind < rs->numkeys ) { c = rs->keystrokes[rs->ind++]; - if ( 1 ) + if ( 0 ) { static FILE *fp; static int32_t counter; if ( fp == 0 ) From ffd9731880022c1cb2c3c0e8c7c4685a3c5b836b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 09:02:28 -1100 Subject: [PATCH 48/64] -print replay2 gold --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 7fc88b878..c65e0e70c 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -998,7 +998,7 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto newdata[i] = newplayer[i]; ((uint8_t *)&endP)[i] = newplayer[i]; } - fprintf(stderr,"back replay2 gold.%d\n",endP.gold); + //fprintf(stderr,"back replay2 gold.%d\n",endP.gold); if ( endP.gold <= 0 || endP.hitpoints <= 0 || (endP.strength&0xffff) <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 ) { sprintf(str,"zero value character was killed -> no playerdata\n"); From 34fc048c0c04b9ddf55893d4486f3669c4a7b650 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 09:28:07 -1100 Subject: [PATCH 49/64] Test --- src/cc/rogue_rpc.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c65e0e70c..4dc449596 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -510,7 +510,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke *keystrokesp = 0; for (i=0; i= 0 ) { if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) @@ -529,17 +529,17 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke if ( matches == 1 ) { numvouts = matchtx.vout.size(); - //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); + fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); if ( tokenid != zeroid ) active = tokenid; else active = playertxid; if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) { txid = matchtx.GetHash(); - //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); n = 0; while ( CCgettxout(txid,0,1,0) < 0 ) { @@ -556,7 +556,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke } } txid = spenttxid; - //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); if ( spentvini != 0 ) // game is over? { return(0); @@ -581,7 +581,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-5); } } - //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); + fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; batonvout = 0; // not vini // how to detect timeout, bailedout, highlander @@ -594,7 +594,7 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke return(-4); else batonht = pindex->GetHeight(); batonvalue = batontx.vout[0].nValue; - //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); + printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); return(0); } else fprintf(stderr,"couldnt find baton\n"); } else fprintf(stderr,"error with playerdata\n"); From 5ac1415bf98f0bcf9f29ef223fb4a85457a0633e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Mar 2019 09:32:37 -1100 Subject: [PATCH 50/64] D'oh! --- src/cc/rogue_rpc.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 4dc449596..5dc970bc8 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -507,10 +507,11 @@ int32_t rogue_findbaton(struct CCcontract_info *cp,uint256 &playertxid,char **ke int32_t i,numvouts,spentvini,n,matches = 0; CPubKey pk; uint256 tid,active,spenttxid,tokenid,hashBlock,txid,origplayergame; CTransaction spenttx,matchtx,batontx; std::vector checkdata; CBlockIndex *pindex; char ccaddr[64],*keystrokes=0; batonvalue = numkeys = numplayers = batonht = 0; playertxid = batontxid = zeroid; - *keystrokesp = 0; + if ( keystrokesp != 0 ) + *keystrokesp = 0; for (i=0; i= 0 ) { if ( myGetTransaction(spenttxid,spenttx,hashBlock) != 0 && spenttx.vout.size() > 0 ) @@ -529,17 +530,17 @@ fprintf(stderr,"findbaton.%d of %d\n",i,maxplayers); if ( matches == 1 ) { numvouts = matchtx.vout.size(); - fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); + //fprintf(stderr,"matchtxid.%s matches.%d numvouts.%d\n",matchtx.GetHash().GetHex().c_str(),matches,numvouts); if ( rogue_registeropretdecode(txid,tokenid,playertxid,matchtx.vout[numvouts-1].scriptPubKey) == 'R' )//&& txid == gametxid ) { - fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); + //fprintf(stderr,"tokenid.%s txid.%s vs gametxid.%s player.%s\n",tokenid.GetHex().c_str(),txid.GetHex().c_str(),gametxid.GetHex().c_str(),playertxid.GetHex().c_str()); if ( tokenid != zeroid ) active = tokenid; else active = playertxid; if ( active == zeroid || rogue_playerdata(cp,origplayergame,tid,pk,playerdata,symbol,pname,active) == 0 ) { txid = matchtx.GetHash(); - fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); + //fprintf(stderr,"scan forward active.%s spenttxid.%s\n",active.GetHex().c_str(),txid.GetHex().c_str()); n = 0; while ( CCgettxout(txid,0,1,0) < 0 ) { @@ -556,7 +557,7 @@ fprintf(stderr,"findbaton.%d of %d\n",i,maxplayers); } } txid = spenttxid; - fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); + //fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini); if ( spentvini != 0 ) // game is over? { return(0); @@ -581,7 +582,7 @@ fprintf(stderr,"findbaton.%d of %d\n",i,maxplayers); return(-5); } } - fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); + //fprintf(stderr,"set baton %s\n",txid.GetHex().c_str()); batontxid = txid; batonvout = 0; // not vini // how to detect timeout, bailedout, highlander @@ -594,7 +595,7 @@ fprintf(stderr,"findbaton.%d of %d\n",i,maxplayers); return(-4); else batonht = pindex->GetHeight(); batonvalue = batontx.vout[0].nValue; - printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); + //printf("batonht.%d keystrokes[%d]\n",batonht,numkeys); return(0); } else fprintf(stderr,"couldnt find baton\n"); } else fprintf(stderr,"error with playerdata\n"); From fc2ae0cbe858e5802c2c422429733993be5d990f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 14 Mar 2019 21:16:19 -1100 Subject: [PATCH 51/64] Fix < txfee cashout --- src/cc/rogue_rpc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 5dc970bc8..cfe108d36 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1279,6 +1279,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } cashout += numplayers * buyin; } + if ( cashout < txfee ) + cashout = txfee; if ( cashout >= txfee ) { if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*mult ) From 8f90135f348172c2ff1679a238d7c42446b519ca Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 14 Mar 2019 21:25:45 -1100 Subject: [PATCH 52/64] Set cashout to 0 --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index cfe108d36..60707c89d 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1192,7 +1192,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param // vout0 -> 1% ingame gold // get any playerdata, get all keystrokes, replay game and compare final state CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); - UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,dungeonlevel,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; + UniValue result(UniValue::VOBJ); std::string rawtx,symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue,inputsum,cashout=0,CCchange=0; int32_t i,err,gameheight,tmp,numplayers,regslot,n,num,dungeonlevel,numkeys,maxplayers,batonht,batonvout; char myrogueaddr[64],*keystrokes = 0; std::vector playerdata,newdata,nodata; uint256 batontxid,playertxid,gametxid; CPubKey mypk,roguepk; uint8_t player[10000],mypriv[32],funcid; struct CCcontract_info *cpTokens, tokensC; if ( txfee == 0 ) From b07507de2e413cccb21e059f9ea14a5d52bbf0e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 14 Mar 2019 21:35:46 -1100 Subject: [PATCH 53/64] Dont roundup --- src/cc/rogue_rpc.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 60707c89d..507f60c3f 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1279,14 +1279,12 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } cashout += numplayers * buyin; } - if ( cashout < txfee ) - cashout = txfee; - if ( cashout >= txfee ) + if ( cashout > 0 ) { if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*mult ) CCchange = (inputsum - cashout); - mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); } + mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); } } mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-3*txfee),roguepk)); From c9d83ebdb781fedb6169aed98458bfb4350abfbe Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 15 Mar 2019 03:11:05 -1100 Subject: [PATCH 54/64] Dont issue change if not big enough --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 507f60c3f..d08ba61c2 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1287,7 +1287,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); } } - mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-3*txfee),roguepk)); + if ( CCchange + (batonvalue-3*txfee) >= txfee ) + mtx.vout.push_back(MakeCC1vout(cp->evalcode,CCchange + (batonvalue-3*txfee),roguepk)); Myprivkey(mypriv); CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr); CScript opret; From 89604d821dcbbeebdc39e6180f0fce799b468f1a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 15 Mar 2019 03:13:27 -1100 Subject: [PATCH 55/64] Calc change properly --- src/cc/rogue_rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index d08ba61c2..2d1a45d33 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1281,7 +1281,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } if ( cashout > 0 ) { - if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > (uint64_t)P.gold*mult ) + if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > cashout ) CCchange = (inputsum - cashout); } mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); From 2a3d132b554e02ba1d3fc3b6413fb05ac18e5c28 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 15 Mar 2019 14:28:39 -0400 Subject: [PATCH 56/64] Show foundersreward in getblocktemplate if ac_founders enabled (#1334) --- src/rpc/mining.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 975154cdf..2efe8d694 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -49,6 +49,7 @@ using namespace std; #include "komodo_defs.h" +extern int32_t ASSETCHAINS_FOUNDERS; arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc); @@ -785,10 +786,10 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) if (tx.IsCoinBase() && coinbasetxn == true ) { // Show founders' reward if it is required - //if (pblock->vtx[0].vout.size() > 1) { + if (ASSETCHAINS_FOUNDERS && pblock->vtx[0].vout.size() > 1) { // Correct this if GetBlockTemplate changes the order - // entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue)); - //} + entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue)); + } CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->GetHeight()+1, Params().GetConsensus()); entry.push_back(Pair("coinbasevalue", nReward)); entry.push_back(Pair("required", true)); From e49b9075803f408b58ac24cc7aeb728dbd315d5b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Mar 2019 08:37:25 -1100 Subject: [PATCH 57/64] Error print --- src/cc/rogue_rpc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index 2d1a45d33..495fa8774 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1281,8 +1281,9 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param } if ( cashout > 0 ) { - if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,16,cp->unspendableCCaddr)) > cashout ) + if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,60,cp->unspendableCCaddr)) > cashout ) CCchange = (inputsum - cashout); + else fprintf(stderr,"couldnt find enough utxos\n"); } mtx.vout.push_back(CTxOut(cashout,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); } From f58655b1cd2e3c5b8e61138a23d268aa285b6d8a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Mar 2019 08:40:47 -1100 Subject: [PATCH 58/64] Thresholding --- src/cc/cclib.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index c783eb4d0..25cd691c5 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -492,7 +492,9 @@ int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); - threshold = total/(maxinputs+1); + if ( maxinputs != 0 ) + threshold = total/maxinputs; + else threshold = total; for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; From 0322f2d98cbd0dc2ddabd5cd83dc2a4e8f2c2df8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Mar 2019 01:35:15 -1100 Subject: [PATCH 59/64] Morph static variables --- src/cc/rogue/command.c | 18 ++++++++-------- src/cc/rogue/init.c | 2 +- src/cc/rogue/monsters.c | 24 ++++++++++----------- src/cc/rogue/potions.c | 2 +- src/cc/rogue/rogue.h | 1 + src/cc/rogue/rooms.c | 37 +++++++++++++-------------------- src/cc/rogue/scrolls.c | 27 +++++++++--------------- src/cc/rogue/sticks.c | 46 ++++++++++++++++++----------------------- src/cc/rogue/things.c | 17 +++++++-------- src/cc/rogue/weapons.c | 10 ++++----- 10 files changed, 80 insertions(+), 104 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 568f4b8f8..37bcedc74 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -24,7 +24,7 @@ command(struct rogue_state *rs) register int ntimes = 1; /* Number of player moves */ char *fp; THING *mp; - static char countch, direction, newcount = FALSE; + //static char countch, direction, newcount = FALSE; if (on(player, ISHASTE)) ntimes++; /* @@ -74,7 +74,7 @@ command(struct rogue_state *rs) if (running || to_death) ch = runch; else if (count) - ch = countch; + ch = rs->countch; else { ch = readchar(rs); @@ -98,11 +98,11 @@ command(struct rogue_state *rs) /* * check for prefixes */ - newcount = FALSE; + rs->newcount = FALSE; if (isdigit(ch)) { count = 0; - newcount = TRUE; + rs->newcount = TRUE; while (isdigit(ch)) { count = count * 10 + (ch - '0'); @@ -110,7 +110,7 @@ command(struct rogue_state *rs) count = 255; ch = readchar(rs); } - countch = ch; + rs->countch = ch; /* * turn off count for commands which don't make sense * to repeat @@ -205,12 +205,12 @@ over: door_stop = TRUE; firstmove = TRUE; } - if (count && !newcount) - ch = direction; + if (count && !rs->newcount) + ch = rs->direction; else { ch += ('A' - CTRL('A')); - direction = ch; + rs->direction = ch; } goto over; } @@ -372,7 +372,7 @@ over: else { ch = dir_ch; - countch = dir_ch; + rs->countch = dir_ch; goto over; } when ')': current(rs,cur_weapon, "wielding", NULL); diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index b11cfa80c..635e95843 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -369,7 +369,7 @@ init_materials() { register int i, j; register const char *str; - static bool metused[NMETAL]; + bool metused[NMETAL]; memset(metused,0,sizeof(metused)); for (i = 0; i < NWOOD; i++) used[i] = FALSE; diff --git a/src/cc/rogue/monsters.c b/src/cc/rogue/monsters.c index 7e1186e8d..7d6d9a32e 100644 --- a/src/cc/rogue/monsters.c +++ b/src/cc/rogue/monsters.c @@ -18,12 +18,12 @@ /* * List of monsters in rough order of vorpalness */ -static char lvl_mons[] = { +static const char lvl_mons[] = { 'K', 'E', 'B', 'S', 'H', 'I', 'R', 'O', 'Z', 'L', 'C', 'Q', 'A', 'N', 'Y', 'F', 'T', 'W', 'P', 'X', 'U', 'M', 'V', 'G', 'J', 'D' }; -static char wand_mons[] = { +static const char wand_mons[] = { 'K', 'E', 'B', 'S', 'H', 0, 'R', 'O', 'Z', 0, 'C', 'Q', 'A', 0, 'Y', 0, 'T', 'W', 'P', 0, 'U', 'M', 'V', 'G', 'J', 0 }; @@ -119,27 +119,27 @@ void wanderer(struct rogue_state *rs) { THING *tp; - static coord cp; - + coord cp; + memset(&cp,0,sizeof(cp)); tp = new_item(); do { - find_floor(rs,(struct room *) NULL, &cp, FALSE, TRUE); + find_floor(rs,(struct room *) NULL, &cp, FALSE, TRUE); } while (roomin(rs,&cp) == proom); new_monster(rs,tp, randmonster(TRUE), &cp); if (on(player, SEEMONST)) { - standout(); - if (!on(player, ISHALU)) - addch(tp->t_type); - else - addch(rnd(26) + 'A'); - standend(); + standout(); + if (!on(player, ISHALU)) + addch(tp->t_type); + else + addch(rnd(26) + 'A'); + standend(); } runto(rs,&tp->t_pos); #ifdef MASTER if (wizard) - msg(rs,"started a wandering %s", monsters[tp->t_type-'A'].m_name); + msg(rs,"started a wandering %s", monsters[tp->t_type-'A'].m_name); #endif } diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index 2425b051f..e503056d6 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -22,7 +22,7 @@ typedef struct char *pa_high, *pa_straight; } PACT; -static PACT p_actions[] = +static const PACT p_actions[] = { { ISHUH, unconfuse, HUHDURATION, /* P_CONFUSE */ "what a tripy feeling!", diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index 5540da2da..f8117cb91 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -366,6 +366,7 @@ struct rogue_state uint32_t needflush,replaydone; int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; FILE *logfp; + char countch, direction, newcount; struct rogue_player P; char buffered[10000]; uint8_t playerdata[10000]; diff --git a/src/cc/rogue/rooms.c b/src/cc/rogue/rooms.c index 67ca701d9..f5454d501 100644 --- a/src/cc/rogue/rooms.c +++ b/src/cc/rogue/rooms.c @@ -30,14 +30,10 @@ typedef struct spot { /* position matrix for maze positions */ void do_rooms(struct rogue_state *rs) { - int i; - struct room *rp; - THING *tp; - int left_out; - static coord top; - coord bsze; /* maximum room size */ - coord mp; - + int i,left_out; struct room *rp; THING *tp; + //static coord top; + coord mp,bsze,top; /* maximum room size */ + memset(&top,0,sizeof(top)); bsze.x = NUMCOLS / 3; bsze.y = NUMLINES / 3; /* @@ -206,23 +202,18 @@ horiz(struct room *rp, int starty) */ static int Maxy, Maxx, Starty, Startx; - static SPOT maze[NUMLINES/3+1][NUMCOLS/3+1]; - -void -do_maze(struct rogue_state *rs,struct room *rp) +void do_maze(struct rogue_state *rs,struct room *rp) { - SPOT *sp; - int starty, startx; - static coord pos; - + SPOT *sp; int starty, startx; + coord pos; + memset(&pos,0,sizeof(pos)); for (sp = &maze[0][0]; sp <= &maze[NUMLINES / 3][NUMCOLS / 3]; sp++) { - sp->used = FALSE; - sp->nexits = 0; + sp->used = FALSE; + sp->nexits = 0; } - Maxy = rp->r_max.y; Maxx = rp->r_max.x; Starty = rp->r_pos.y; @@ -245,11 +236,11 @@ dig(struct rogue_state *rs,int y, int x) { coord *cp; int cnt, newy, newx, nexty = 0, nextx = 0; - static coord pos; - static coord del[4] = { - {2, 0}, {-2, 0}, {0, 2}, {0, -2} + coord pos; + static const coord del[4] = { + {2, 0}, {-2, 0}, {0, 2}, {0, -2} }; - + memset(&pos,0,sizeof(pos)); for (;;) { if ( rs->replaydone != 0 ) diff --git a/src/cc/rogue/scrolls.c b/src/cc/rogue/scrolls.c index 8ed6d2648..49c427f67 100644 --- a/src/cc/rogue/scrolls.c +++ b/src/cc/rogue/scrolls.c @@ -22,26 +22,19 @@ void read_scroll(struct rogue_state *rs) { - THING *obj; - PLACE *pp; - int y, x; - char ch; - int i; - bool discardit = FALSE; - struct room *cur_room; - THING *orig_obj; - static coord mp; - + THING *obj,*orig_obj; PLACE *pp; int i, y, x; char ch; + bool discardit = FALSE; struct room *cur_room; coord mp; + memset(&mp,0,sizeof(mp)); obj = get_item(rs,"read", SCROLL); if (obj == NULL) - return; + return; if (obj->o_type != SCROLL) { - if (!terse) - msg(rs,"there is nothing on it to read"); - else - msg(rs,"nothing to read"); - return; + if (!terse) + msg(rs,"there is nothing on it to read"); + else + msg(rs,"nothing to read"); + return; } /* * Calculate the effect it has on the poor guy. @@ -149,7 +142,7 @@ read_scroll(struct rogue_state *rs) case S_ID_ARMOR: case S_ID_R_OR_S: { - static char id_type[S_ID_R_OR_S + 1] = + static const char id_type[S_ID_R_OR_S + 1] = { 0, 0, 0, 0, 0, POTION, SCROLL, WEAPON, ARMOR, R_OR_S }; /* * Identify, let him figure something out diff --git a/src/cc/rogue/sticks.c b/src/cc/rogue/sticks.c index cd559daef..7ab33f03c 100644 --- a/src/cc/rogue/sticks.c +++ b/src/cc/rogue/sticks.c @@ -245,35 +245,29 @@ do_zap(struct rogue_state *rs) * Do drain hit points from player shtick */ -void -drain(struct rogue_state *rs) +void drain(struct rogue_state *rs) { - THING *mp; - struct room *corp; - THING **dp; - int cnt; - bool inpass; - static THING *drainee[40]; - + THING *mp,**dp; struct room *corp; int cnt; bool inpass; THING *drainee[40]; + memset(drainee,0,sizeof(drainee)); /* * First cnt how many things we need to spread the hit points among */ cnt = 0; if (chat(hero.y, hero.x) == DOOR) - corp = &passages[flat(hero.y, hero.x) & F_PNUM]; + corp = &passages[flat(hero.y, hero.x) & F_PNUM]; else - corp = NULL; + corp = NULL; inpass = (bool)(proom->r_flags & ISGONE); dp = drainee; for (mp = mlist; mp != NULL; mp = next(mp)) - if (mp->t_room == proom || mp->t_room == corp || - (inpass && chat(mp->t_pos.y, mp->t_pos.x) == DOOR && - &passages[flat(mp->t_pos.y, mp->t_pos.x) & F_PNUM] == proom)) - *dp++ = mp; + if (mp->t_room == proom || mp->t_room == corp || + (inpass && chat(mp->t_pos.y, mp->t_pos.x) == DOOR && + &passages[flat(mp->t_pos.y, mp->t_pos.x) & F_PNUM] == proom)) + *dp++ = mp; if ((cnt = (int)(dp - drainee)) == 0) { - msg(rs,"you have a tingling feeling"); - return; + msg(rs,"you have a tingling feeling"); + return; } *dp = NULL; pstats.s_hpt /= 2; @@ -283,11 +277,11 @@ drain(struct rogue_state *rs) */ for (dp = drainee; *dp; dp++) { - mp = *dp; - if ((mp->t_stats.s_hpt -= cnt) <= 0) - killed(rs,mp, see_monst(mp)); - else - runto(rs,&mp->t_pos); + mp = *dp; + if ((mp->t_stats.s_hpt -= cnt) <= 0) + killed(rs,mp, see_monst(mp)); + else + runto(rs,&mp->t_pos); } } @@ -421,12 +415,12 @@ char * charge_str(THING *obj) { static char buf[20]; - + if (!(obj->o_flags & ISKNOW)) - buf[0] = '\0'; + buf[0] = '\0'; else if (terse) - sprintf(buf, " [%d]", obj->o_charges); + sprintf(buf, " [%d]", obj->o_charges); else - sprintf(buf, " [%d charges]", obj->o_charges); + sprintf(buf, " [%d charges]", obj->o_charges); return buf; } diff --git a/src/cc/rogue/things.c b/src/cc/rogue/things.c index 39c7b94b7..e1ce2a2a8 100644 --- a/src/cc/rogue/things.c +++ b/src/cc/rogue/things.c @@ -334,12 +334,9 @@ pick_one(struct rogue_state *rs,struct obj_info *info, int nitems) * list what the player has discovered in this game of a certain type */ static int line_cnt = 0; - static bool newpage = FALSE; - static char *lastfmt, *lastarg; - void discovered(struct rogue_state *rs) { @@ -480,16 +477,16 @@ add_line(struct rogue_state *rs,char *fmt, char *arg) if (line_cnt == 0) { - wclear(hw); - if (inv_type == INV_SLOW) - mpos = 0; + wclear(hw); + if (inv_type == INV_SLOW) + mpos = 0; } if (inv_type == INV_SLOW) { - if (*fmt != '\0') - if (msg(rs,fmt, arg) == ESCAPE) - return ESCAPE; - line_cnt++; + if (*fmt != '\0') + if (msg(rs,fmt, arg) == ESCAPE) + return ESCAPE; + line_cnt++; } else { diff --git a/src/cc/rogue/weapons.c b/src/cc/rogue/weapons.c index 0a8b6016c..592b405f7 100644 --- a/src/cc/rogue/weapons.c +++ b/src/cc/rogue/weapons.c @@ -19,7 +19,7 @@ int group = 2; -static struct init_weaps { +static const struct init_weaps { char *iw_dam; /* Damage when wielded */ char *iw_hrl; /* Damage when thrown */ char iw_launch; /* Launching weapon */ @@ -125,8 +125,8 @@ void fall(struct rogue_state *rs,THING *obj, bool pr) { PLACE *pp; - static coord fpos; - + coord fpos; + memset(&fpos,0,sizeof(fpos)); if (fallpos(&obj->o_pos, &fpos)) { pp = INDEX(fpos.y, fpos.x); @@ -197,8 +197,8 @@ init_weapon(THING *weap, int which) int hit_monster(struct rogue_state *rs,int y, int x, THING *obj) { - static coord mp; - + coord mp; + memset(&mp,0,sizeof(mp)); mp.y = y; mp.x = x; return fight(rs,&mp, obj, TRUE); From 02613880a18dc4f638f31731dc5a6c0d569d6220 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Mar 2019 01:38:15 -1100 Subject: [PATCH 60/64] Const --- src/cc/rogue/monsters.c | 2 +- src/cc/rogue/potions.c | 2 +- src/cc/rogue/rooms.c | 28 ++++++++++++++-------------- src/cc/rogue/weapons.c | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/cc/rogue/monsters.c b/src/cc/rogue/monsters.c index 7d6d9a32e..465e57c2a 100644 --- a/src/cc/rogue/monsters.c +++ b/src/cc/rogue/monsters.c @@ -39,7 +39,7 @@ randmonster(bool wander) int d; char *mons; - mons = (wander ? wand_mons : lvl_mons); + mons = (char *)(wander ? wand_mons : lvl_mons); do { d = level + (rnd(10) - 6); diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index e503056d6..ce58e5acc 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -317,7 +317,7 @@ do_pot(struct rogue_state *rs,int type, bool knowit) PACT *pp; int t; - pp = &p_actions[type]; + pp = (PACT *)&p_actions[type]; if (!pot_info[type].oi_know) pot_info[type].oi_know = knowit; t = spread(pp->pa_time); diff --git a/src/cc/rogue/rooms.c b/src/cc/rogue/rooms.c index f5454d501..eea847d9d 100644 --- a/src/cc/rogue/rooms.c +++ b/src/cc/rogue/rooms.c @@ -246,20 +246,20 @@ dig(struct rogue_state *rs,int y, int x) if ( rs->replaydone != 0 ) return; cnt = 0; - for (cp = del; cp <= &del[3]; cp++) - { - newy = y + cp->y; - newx = x + cp->x; - if (newy < 0 || newy > Maxy || newx < 0 || newx > Maxx) - continue; - if (flat(newy + Starty, newx + Startx) & F_PASS) - continue; - if (rnd(++cnt) == 0) - { - nexty = newy; - nextx = newx; - } - } + for (cp = (coord *)del; cp <= (coord *)&del[3]; cp++) + { + newy = y + cp->y; + newx = x + cp->x; + if (newy < 0 || newy > Maxy || newx < 0 || newx > Maxx) + continue; + if (flat(newy + Starty, newx + Startx) & F_PASS) + continue; + if (rnd(++cnt) == 0) + { + nexty = newy; + nextx = newx; + } + } if (cnt == 0) return; accnt_maze(y, x, nexty, nextx); diff --git a/src/cc/rogue/weapons.c b/src/cc/rogue/weapons.c index 592b405f7..a8a9556af 100644 --- a/src/cc/rogue/weapons.c +++ b/src/cc/rogue/weapons.c @@ -163,7 +163,7 @@ fall(struct rogue_state *rs,THING *obj, bool pr) void init_weapon(THING *weap, int which) { - struct init_weaps *iwp; + const struct init_weaps *iwp; weap->o_type = WEAPON; weap->o_which = which; iwp = &init_dam[which]; From f8c3d42f9b47b66f4744ca8cb85844df7b977ef7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Mar 2019 06:29:53 -1100 Subject: [PATCH 61/64] Revert "Const" This reverts commit 02613880a18dc4f638f31731dc5a6c0d569d6220. --- src/cc/rogue/monsters.c | 2 +- src/cc/rogue/potions.c | 2 +- src/cc/rogue/rooms.c | 28 ++++++++++++++-------------- src/cc/rogue/weapons.c | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/cc/rogue/monsters.c b/src/cc/rogue/monsters.c index 465e57c2a..7d6d9a32e 100644 --- a/src/cc/rogue/monsters.c +++ b/src/cc/rogue/monsters.c @@ -39,7 +39,7 @@ randmonster(bool wander) int d; char *mons; - mons = (char *)(wander ? wand_mons : lvl_mons); + mons = (wander ? wand_mons : lvl_mons); do { d = level + (rnd(10) - 6); diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index ce58e5acc..e503056d6 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -317,7 +317,7 @@ do_pot(struct rogue_state *rs,int type, bool knowit) PACT *pp; int t; - pp = (PACT *)&p_actions[type]; + pp = &p_actions[type]; if (!pot_info[type].oi_know) pot_info[type].oi_know = knowit; t = spread(pp->pa_time); diff --git a/src/cc/rogue/rooms.c b/src/cc/rogue/rooms.c index eea847d9d..f5454d501 100644 --- a/src/cc/rogue/rooms.c +++ b/src/cc/rogue/rooms.c @@ -246,20 +246,20 @@ dig(struct rogue_state *rs,int y, int x) if ( rs->replaydone != 0 ) return; cnt = 0; - for (cp = (coord *)del; cp <= (coord *)&del[3]; cp++) - { - newy = y + cp->y; - newx = x + cp->x; - if (newy < 0 || newy > Maxy || newx < 0 || newx > Maxx) - continue; - if (flat(newy + Starty, newx + Startx) & F_PASS) - continue; - if (rnd(++cnt) == 0) - { - nexty = newy; - nextx = newx; - } - } + for (cp = del; cp <= &del[3]; cp++) + { + newy = y + cp->y; + newx = x + cp->x; + if (newy < 0 || newy > Maxy || newx < 0 || newx > Maxx) + continue; + if (flat(newy + Starty, newx + Startx) & F_PASS) + continue; + if (rnd(++cnt) == 0) + { + nexty = newy; + nextx = newx; + } + } if (cnt == 0) return; accnt_maze(y, x, nexty, nextx); diff --git a/src/cc/rogue/weapons.c b/src/cc/rogue/weapons.c index a8a9556af..592b405f7 100644 --- a/src/cc/rogue/weapons.c +++ b/src/cc/rogue/weapons.c @@ -163,7 +163,7 @@ fall(struct rogue_state *rs,THING *obj, bool pr) void init_weapon(THING *weap, int which) { - const struct init_weaps *iwp; + struct init_weaps *iwp; weap->o_type = WEAPON; weap->o_which = which; iwp = &init_dam[which]; From 94adc1406656df97e5fab4734ba477405e8c7589 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Mar 2019 06:30:28 -1100 Subject: [PATCH 62/64] Revert "Morph static variables" This reverts commit 0322f2d98cbd0dc2ddabd5cd83dc2a4e8f2c2df8. --- src/cc/rogue/command.c | 18 ++++++++-------- src/cc/rogue/init.c | 2 +- src/cc/rogue/monsters.c | 24 ++++++++++----------- src/cc/rogue/potions.c | 2 +- src/cc/rogue/rogue.h | 1 - src/cc/rogue/rooms.c | 37 ++++++++++++++++++++------------- src/cc/rogue/scrolls.c | 27 +++++++++++++++--------- src/cc/rogue/sticks.c | 46 +++++++++++++++++++++++------------------ src/cc/rogue/things.c | 17 ++++++++------- src/cc/rogue/weapons.c | 10 ++++----- 10 files changed, 104 insertions(+), 80 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 37bcedc74..568f4b8f8 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -24,7 +24,7 @@ command(struct rogue_state *rs) register int ntimes = 1; /* Number of player moves */ char *fp; THING *mp; - //static char countch, direction, newcount = FALSE; + static char countch, direction, newcount = FALSE; if (on(player, ISHASTE)) ntimes++; /* @@ -74,7 +74,7 @@ command(struct rogue_state *rs) if (running || to_death) ch = runch; else if (count) - ch = rs->countch; + ch = countch; else { ch = readchar(rs); @@ -98,11 +98,11 @@ command(struct rogue_state *rs) /* * check for prefixes */ - rs->newcount = FALSE; + newcount = FALSE; if (isdigit(ch)) { count = 0; - rs->newcount = TRUE; + newcount = TRUE; while (isdigit(ch)) { count = count * 10 + (ch - '0'); @@ -110,7 +110,7 @@ command(struct rogue_state *rs) count = 255; ch = readchar(rs); } - rs->countch = ch; + countch = ch; /* * turn off count for commands which don't make sense * to repeat @@ -205,12 +205,12 @@ over: door_stop = TRUE; firstmove = TRUE; } - if (count && !rs->newcount) - ch = rs->direction; + if (count && !newcount) + ch = direction; else { ch += ('A' - CTRL('A')); - rs->direction = ch; + direction = ch; } goto over; } @@ -372,7 +372,7 @@ over: else { ch = dir_ch; - rs->countch = dir_ch; + countch = dir_ch; goto over; } when ')': current(rs,cur_weapon, "wielding", NULL); diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index 635e95843..b11cfa80c 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -369,7 +369,7 @@ init_materials() { register int i, j; register const char *str; - bool metused[NMETAL]; + static bool metused[NMETAL]; memset(metused,0,sizeof(metused)); for (i = 0; i < NWOOD; i++) used[i] = FALSE; diff --git a/src/cc/rogue/monsters.c b/src/cc/rogue/monsters.c index 7d6d9a32e..7e1186e8d 100644 --- a/src/cc/rogue/monsters.c +++ b/src/cc/rogue/monsters.c @@ -18,12 +18,12 @@ /* * List of monsters in rough order of vorpalness */ -static const char lvl_mons[] = { +static char lvl_mons[] = { 'K', 'E', 'B', 'S', 'H', 'I', 'R', 'O', 'Z', 'L', 'C', 'Q', 'A', 'N', 'Y', 'F', 'T', 'W', 'P', 'X', 'U', 'M', 'V', 'G', 'J', 'D' }; -static const char wand_mons[] = { +static char wand_mons[] = { 'K', 'E', 'B', 'S', 'H', 0, 'R', 'O', 'Z', 0, 'C', 'Q', 'A', 0, 'Y', 0, 'T', 'W', 'P', 0, 'U', 'M', 'V', 'G', 'J', 0 }; @@ -119,27 +119,27 @@ void wanderer(struct rogue_state *rs) { THING *tp; - coord cp; - memset(&cp,0,sizeof(cp)); + static coord cp; + tp = new_item(); do { - find_floor(rs,(struct room *) NULL, &cp, FALSE, TRUE); + find_floor(rs,(struct room *) NULL, &cp, FALSE, TRUE); } while (roomin(rs,&cp) == proom); new_monster(rs,tp, randmonster(TRUE), &cp); if (on(player, SEEMONST)) { - standout(); - if (!on(player, ISHALU)) - addch(tp->t_type); - else - addch(rnd(26) + 'A'); - standend(); + standout(); + if (!on(player, ISHALU)) + addch(tp->t_type); + else + addch(rnd(26) + 'A'); + standend(); } runto(rs,&tp->t_pos); #ifdef MASTER if (wizard) - msg(rs,"started a wandering %s", monsters[tp->t_type-'A'].m_name); + msg(rs,"started a wandering %s", monsters[tp->t_type-'A'].m_name); #endif } diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index e503056d6..2425b051f 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -22,7 +22,7 @@ typedef struct char *pa_high, *pa_straight; } PACT; -static const PACT p_actions[] = +static PACT p_actions[] = { { ISHUH, unconfuse, HUHDURATION, /* P_CONFUSE */ "what a tripy feeling!", diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index f8117cb91..5540da2da 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -366,7 +366,6 @@ struct rogue_state uint32_t needflush,replaydone; int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; FILE *logfp; - char countch, direction, newcount; struct rogue_player P; char buffered[10000]; uint8_t playerdata[10000]; diff --git a/src/cc/rogue/rooms.c b/src/cc/rogue/rooms.c index f5454d501..67ca701d9 100644 --- a/src/cc/rogue/rooms.c +++ b/src/cc/rogue/rooms.c @@ -30,10 +30,14 @@ typedef struct spot { /* position matrix for maze positions */ void do_rooms(struct rogue_state *rs) { - int i,left_out; struct room *rp; THING *tp; - //static coord top; - coord mp,bsze,top; /* maximum room size */ - memset(&top,0,sizeof(top)); + int i; + struct room *rp; + THING *tp; + int left_out; + static coord top; + coord bsze; /* maximum room size */ + coord mp; + bsze.x = NUMCOLS / 3; bsze.y = NUMLINES / 3; /* @@ -202,18 +206,23 @@ horiz(struct room *rp, int starty) */ static int Maxy, Maxx, Starty, Startx; + static SPOT maze[NUMLINES/3+1][NUMCOLS/3+1]; -void do_maze(struct rogue_state *rs,struct room *rp) + +void +do_maze(struct rogue_state *rs,struct room *rp) { - SPOT *sp; int starty, startx; - coord pos; - memset(&pos,0,sizeof(pos)); + SPOT *sp; + int starty, startx; + static coord pos; + for (sp = &maze[0][0]; sp <= &maze[NUMLINES / 3][NUMCOLS / 3]; sp++) { - sp->used = FALSE; - sp->nexits = 0; + sp->used = FALSE; + sp->nexits = 0; } + Maxy = rp->r_max.y; Maxx = rp->r_max.x; Starty = rp->r_pos.y; @@ -236,11 +245,11 @@ dig(struct rogue_state *rs,int y, int x) { coord *cp; int cnt, newy, newx, nexty = 0, nextx = 0; - coord pos; - static const coord del[4] = { - {2, 0}, {-2, 0}, {0, 2}, {0, -2} + static coord pos; + static coord del[4] = { + {2, 0}, {-2, 0}, {0, 2}, {0, -2} }; - memset(&pos,0,sizeof(pos)); + for (;;) { if ( rs->replaydone != 0 ) diff --git a/src/cc/rogue/scrolls.c b/src/cc/rogue/scrolls.c index 49c427f67..8ed6d2648 100644 --- a/src/cc/rogue/scrolls.c +++ b/src/cc/rogue/scrolls.c @@ -22,19 +22,26 @@ void read_scroll(struct rogue_state *rs) { - THING *obj,*orig_obj; PLACE *pp; int i, y, x; char ch; - bool discardit = FALSE; struct room *cur_room; coord mp; - memset(&mp,0,sizeof(mp)); + THING *obj; + PLACE *pp; + int y, x; + char ch; + int i; + bool discardit = FALSE; + struct room *cur_room; + THING *orig_obj; + static coord mp; + obj = get_item(rs,"read", SCROLL); if (obj == NULL) - return; + return; if (obj->o_type != SCROLL) { - if (!terse) - msg(rs,"there is nothing on it to read"); - else - msg(rs,"nothing to read"); - return; + if (!terse) + msg(rs,"there is nothing on it to read"); + else + msg(rs,"nothing to read"); + return; } /* * Calculate the effect it has on the poor guy. @@ -142,7 +149,7 @@ read_scroll(struct rogue_state *rs) case S_ID_ARMOR: case S_ID_R_OR_S: { - static const char id_type[S_ID_R_OR_S + 1] = + static char id_type[S_ID_R_OR_S + 1] = { 0, 0, 0, 0, 0, POTION, SCROLL, WEAPON, ARMOR, R_OR_S }; /* * Identify, let him figure something out diff --git a/src/cc/rogue/sticks.c b/src/cc/rogue/sticks.c index 7ab33f03c..cd559daef 100644 --- a/src/cc/rogue/sticks.c +++ b/src/cc/rogue/sticks.c @@ -245,29 +245,35 @@ do_zap(struct rogue_state *rs) * Do drain hit points from player shtick */ -void drain(struct rogue_state *rs) +void +drain(struct rogue_state *rs) { - THING *mp,**dp; struct room *corp; int cnt; bool inpass; THING *drainee[40]; - memset(drainee,0,sizeof(drainee)); + THING *mp; + struct room *corp; + THING **dp; + int cnt; + bool inpass; + static THING *drainee[40]; + /* * First cnt how many things we need to spread the hit points among */ cnt = 0; if (chat(hero.y, hero.x) == DOOR) - corp = &passages[flat(hero.y, hero.x) & F_PNUM]; + corp = &passages[flat(hero.y, hero.x) & F_PNUM]; else - corp = NULL; + corp = NULL; inpass = (bool)(proom->r_flags & ISGONE); dp = drainee; for (mp = mlist; mp != NULL; mp = next(mp)) - if (mp->t_room == proom || mp->t_room == corp || - (inpass && chat(mp->t_pos.y, mp->t_pos.x) == DOOR && - &passages[flat(mp->t_pos.y, mp->t_pos.x) & F_PNUM] == proom)) - *dp++ = mp; + if (mp->t_room == proom || mp->t_room == corp || + (inpass && chat(mp->t_pos.y, mp->t_pos.x) == DOOR && + &passages[flat(mp->t_pos.y, mp->t_pos.x) & F_PNUM] == proom)) + *dp++ = mp; if ((cnt = (int)(dp - drainee)) == 0) { - msg(rs,"you have a tingling feeling"); - return; + msg(rs,"you have a tingling feeling"); + return; } *dp = NULL; pstats.s_hpt /= 2; @@ -277,11 +283,11 @@ void drain(struct rogue_state *rs) */ for (dp = drainee; *dp; dp++) { - mp = *dp; - if ((mp->t_stats.s_hpt -= cnt) <= 0) - killed(rs,mp, see_monst(mp)); - else - runto(rs,&mp->t_pos); + mp = *dp; + if ((mp->t_stats.s_hpt -= cnt) <= 0) + killed(rs,mp, see_monst(mp)); + else + runto(rs,&mp->t_pos); } } @@ -415,12 +421,12 @@ char * charge_str(THING *obj) { static char buf[20]; - + if (!(obj->o_flags & ISKNOW)) - buf[0] = '\0'; + buf[0] = '\0'; else if (terse) - sprintf(buf, " [%d]", obj->o_charges); + sprintf(buf, " [%d]", obj->o_charges); else - sprintf(buf, " [%d charges]", obj->o_charges); + sprintf(buf, " [%d charges]", obj->o_charges); return buf; } diff --git a/src/cc/rogue/things.c b/src/cc/rogue/things.c index e1ce2a2a8..39c7b94b7 100644 --- a/src/cc/rogue/things.c +++ b/src/cc/rogue/things.c @@ -334,9 +334,12 @@ pick_one(struct rogue_state *rs,struct obj_info *info, int nitems) * list what the player has discovered in this game of a certain type */ static int line_cnt = 0; + static bool newpage = FALSE; + static char *lastfmt, *lastarg; + void discovered(struct rogue_state *rs) { @@ -477,16 +480,16 @@ add_line(struct rogue_state *rs,char *fmt, char *arg) if (line_cnt == 0) { - wclear(hw); - if (inv_type == INV_SLOW) - mpos = 0; + wclear(hw); + if (inv_type == INV_SLOW) + mpos = 0; } if (inv_type == INV_SLOW) { - if (*fmt != '\0') - if (msg(rs,fmt, arg) == ESCAPE) - return ESCAPE; - line_cnt++; + if (*fmt != '\0') + if (msg(rs,fmt, arg) == ESCAPE) + return ESCAPE; + line_cnt++; } else { diff --git a/src/cc/rogue/weapons.c b/src/cc/rogue/weapons.c index 592b405f7..0a8b6016c 100644 --- a/src/cc/rogue/weapons.c +++ b/src/cc/rogue/weapons.c @@ -19,7 +19,7 @@ int group = 2; -static const struct init_weaps { +static struct init_weaps { char *iw_dam; /* Damage when wielded */ char *iw_hrl; /* Damage when thrown */ char iw_launch; /* Launching weapon */ @@ -125,8 +125,8 @@ void fall(struct rogue_state *rs,THING *obj, bool pr) { PLACE *pp; - coord fpos; - memset(&fpos,0,sizeof(fpos)); + static coord fpos; + if (fallpos(&obj->o_pos, &fpos)) { pp = INDEX(fpos.y, fpos.x); @@ -197,8 +197,8 @@ init_weapon(THING *weap, int which) int hit_monster(struct rogue_state *rs,int y, int x, THING *obj) { - coord mp; - memset(&mp,0,sizeof(mp)); + static coord mp; + mp.y = y; mp.x = x; return fight(rs,&mp, obj, TRUE); From d61784c949f7f11d65110f862764ad4b4487771e Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 20 Mar 2019 13:03:41 -0700 Subject: [PATCH 63/64] Custom asset chain client names (#1338) * Allow setting client name via cli * Add util.h for GetArg --- src/clientversion.cpp | 3 ++- src/init.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 4f004aac2..663e2e937 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -20,6 +20,7 @@ #include "clientversion.h" #include "tinyformat.h" +#include "util.h" #include @@ -34,7 +35,7 @@ * for both bitcoind and bitcoin-core, to make it harder for attackers to * target servers or GUI users specifically. */ -const std::string CLIENT_NAME("MagicBean"); +const std::string CLIENT_NAME = GetArg("-ac_clientname", "MagicBean"); /** * Client version number diff --git a/src/init.cpp b/src/init.cpp index 2a612634e..d2546347d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -571,6 +571,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-ac_cclib", _("Cryptoconditions dynamicly loadable library")); strUsage += HelpMessageOpt("-ac_ccenable", _("Cryptoconditions to enable")); strUsage += HelpMessageOpt("-ac_ccactivate", _("Block height to enable Cryptoconditions")); + strUsage += HelpMessageOpt("-ac_clientname", _("Full node client name, default 'MagicBean'")); strUsage += HelpMessageOpt("-ac_decay", _("Percentage of block reward decrease at each halving")); strUsage += HelpMessageOpt("-ac_end", _("Block height at which block rewards will end")); strUsage += HelpMessageOpt("-ac_eras", _("Block reward eras")); From 42200a471667dadd6ab32f31f37767fe5a6de426 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 21 Mar 2019 00:00:40 -0700 Subject: [PATCH 64/64] Fix z_listunspent RPC docs, which require different quoting that CLI function arguments (#1339) --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 38c21d2bd..445f145fd 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3031,7 +3031,7 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) "\nExamples\n" + HelpExampleCli("z_listunspent", "") + HelpExampleCli("z_listunspent", "6 9999999 false \"[\\\"zs14d8tc0hl9q0vg5l28uec5vk6sk34fkj2n8s7jalvw5fxpy6v39yn4s2ga082lymrkjk0x2nqg37\\\",\\\"zs14d8tc0hl9q0vg5l28uec5vk6sk34fkj2n8s7jalvw5fxpy6v39yn4s2ga082lymrkjk0x2nqg37\\\"]\"") - + HelpExampleRpc("z_listunspent", "6 9999999 false \"[\\\"zs14d8tc0hl9q0vg5l28uec5vk6sk34fkj2n8s7jalvw5fxpy6v39yn4s2ga082lymrkjk0x2nqg37\\\",\\\"zs14d8tc0hl9q0vg5l28uec5vk6sk34fkj2n8s7jalvw5fxpy6v39yn4s2ga082lymrkjk0x2nqg37\\\"]\"") + + HelpExampleRpc("z_listunspent", "6,9999999,false,[\"zs14d8tc0hl9q0vg5l28uec5vk6sk34fkj2n8s7jalvw5fxpy6v39yn4s2ga082lymrkjk0x2nqg37\",\"zs14d8tc0hl9q0vg5l28uec5vk6sk34fkj2n8s7jalvw5fxpy6v39yn4s2ga082lymrkjk0x2nqg37\"]") ); RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)(UniValue::VNUM)(UniValue::VBOOL)(UniValue::VARR));