@@ -571,8 +571,14 @@ komodod_LDADD += \
|
||||
$(LIBBITCOIN_CRYPTO) \
|
||||
$(LIBVERUS_CRYPTO) \
|
||||
$(LIBVERUS_PORTABLE_CRYPTO) \
|
||||
$(LIBZCASH_LIBS) \
|
||||
libcc.so -lncurses
|
||||
$(LIBZCASH_LIBS)
|
||||
|
||||
if TARGET_DARWIN
|
||||
komodod_LDADD += libcc.dylib -lncurses
|
||||
else
|
||||
komodod_LDADD += libcc.so -lncurses
|
||||
endif
|
||||
|
||||
|
||||
if ENABLE_PROTON
|
||||
komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS)
|
||||
|
||||
@@ -64,6 +64,7 @@ CClib_methods[] =
|
||||
{ (char *)"rogue", (char *)"players", (char *)"<no args>", 0, 0, 'D', EVAL_ROGUE },
|
||||
{ (char *)"rogue", (char *)"games", (char *)"<no args>", 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 },
|
||||
#else
|
||||
{ (char *)"sudoku", (char *)"gen", (char *)"<no args>", 0, 0, 'G', EVAL_SUDOKU },
|
||||
{ (char *)"sudoku", (char *)"txidinfo", (char *)"txid", 1, 1, 'T', EVAL_SUDOKU },
|
||||
@@ -89,6 +90,7 @@ UniValue rogue_playerinfo(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
|
||||
UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
|
||||
#else
|
||||
bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx);
|
||||
@@ -118,6 +120,8 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,cJSON *params)
|
||||
return(rogue_bailout(txfee,cp,params));
|
||||
else if ( strcmp(method,"highlander") == 0 )
|
||||
return(rogue_highlander(txfee,cp,params));
|
||||
else if ( strcmp(method,"extract") == 0 )
|
||||
return(rogue_extract(txfee,cp,params));
|
||||
else if ( strcmp(method,"playerinfo") == 0 )
|
||||
return(rogue_playerinfo(txfee,cp,params));
|
||||
else if ( strcmp(method,"players") == 0 )
|
||||
@@ -492,6 +496,7 @@ cJSON *cclib_reparse(int32_t *nump,cJSON *origparams) // assumes origparams will
|
||||
|
||||
#ifdef BUILD_ROGUE
|
||||
#include "rogue_rpc.cpp"
|
||||
#include "rogue/cursesd.c"
|
||||
#include "rogue/vers.c"
|
||||
#include "rogue/extern.c"
|
||||
#include "rogue/armor.c"
|
||||
|
||||
@@ -106,12 +106,12 @@ CScript EncodeChannelsOpRet(uint8_t funcid,uint256 tokenid,uint256 opentxid,CPub
|
||||
|
||||
uint8_t DecodeChannelsOpRet(const CScript &scriptPubKey, uint256 &tokenid, uint256 &opentxid, CPubKey &srcpub,CPubKey &destpub,int32_t &numpayments,int64_t &payment,uint256 &hashchain)
|
||||
{
|
||||
std::vector<uint8_t> vopret; uint8_t *script,e,f,tokenevalcode;
|
||||
std::vector<CPubKey> pubkeys; std::vector<uint8_t> vOpretExtra;
|
||||
std::vector<uint8_t> vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode;
|
||||
std::vector<CPubKey> pubkeys;
|
||||
|
||||
if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0)
|
||||
{
|
||||
if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0);
|
||||
vopret=vOpretExtra;
|
||||
}
|
||||
else GetOpReturnData(scriptPubKey, vopret);
|
||||
if ( vopret.size() > 2 )
|
||||
|
||||
@@ -167,12 +167,11 @@ CScript EncodeGatewaysBindOpRet(uint8_t funcid,uint256 tokenid,std::string coin,
|
||||
|
||||
uint8_t DecodeGatewaysBindOpRet(char *depositaddr,const CScript &scriptPubKey,uint256 &tokenid,std::string &coin,int64_t &totalsupply,uint256 &oracletxid,uint8_t &M,uint8_t &N,std::vector<CPubKey> &gatewaypubkeys,uint8_t &taddr,uint8_t &prefix,uint8_t &prefix2,uint8_t wiftype)
|
||||
{
|
||||
std::vector<uint8_t> vopret; uint8_t *script,e,f,tokenevalcode;
|
||||
std::vector<uint8_t> vOpretExtra; std::vector<CPubKey> pubkeys;
|
||||
std::vector<uint8_t> vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; std::vector<CPubKey> pubkeys;
|
||||
|
||||
if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0)
|
||||
{
|
||||
if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0);
|
||||
vopret=vOpretExtra;
|
||||
}
|
||||
else GetOpReturnData(scriptPubKey, vopret);
|
||||
script = (uint8_t *)vopret.data();
|
||||
@@ -230,12 +229,11 @@ CScript EncodeGatewaysClaimOpRet(uint8_t funcid,uint256 tokenid,uint256 bindtxid
|
||||
|
||||
uint8_t DecodeGatewaysClaimOpRet(const CScript &scriptPubKey,uint256 &tokenid,uint256 &bindtxid,std::string &refcoin,uint256 &deposittxid,CPubKey &destpub,int64_t &amount)
|
||||
{
|
||||
std::vector<uint8_t> vopret; uint8_t *script,e,f,tokenevalcode;
|
||||
std::vector<CPubKey> pubkeys; std::vector<uint8_t> vOpretExtra;
|
||||
std::vector<uint8_t> vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; std::vector<CPubKey> pubkeys;
|
||||
|
||||
if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0)
|
||||
{
|
||||
if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0);
|
||||
vopret=vOpretExtra;
|
||||
}
|
||||
else GetOpReturnData(scriptPubKey, vopret);
|
||||
script = (uint8_t *)vopret.data();
|
||||
@@ -260,12 +258,11 @@ CScript EncodeGatewaysWithdrawOpRet(uint8_t funcid,uint256 tokenid,uint256 bindt
|
||||
|
||||
uint8_t DecodeGatewaysWithdrawOpRet(const CScript &scriptPubKey, uint256& tokenid, uint256 &bindtxid, std::string &refcoin, CPubKey &withdrawpub, int64_t &amount)
|
||||
{
|
||||
std::vector<uint8_t> vopret; uint8_t *script,e,f,tokenevalcode;
|
||||
std::vector<CPubKey> pubkeys; std::vector<uint8_t> vOpretExtra;
|
||||
std::vector<uint8_t> vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; std::vector<CPubKey> pubkeys;
|
||||
|
||||
if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0)
|
||||
{
|
||||
if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0);
|
||||
vopret=vOpretExtra;
|
||||
}
|
||||
else GetOpReturnData(scriptPubKey, vopret);
|
||||
script = (uint8_t *)vopret.data();
|
||||
@@ -339,12 +336,11 @@ uint8_t DecodeGatewaysMarkDoneOpRet(const CScript &scriptPubKey, uint256 &withdr
|
||||
|
||||
uint8_t DecodeGatewaysOpRet(const CScript &scriptPubKey)
|
||||
{
|
||||
std::vector<uint8_t> vopret; uint8_t *script,e,f,tokenevalcode;
|
||||
std::vector<CPubKey> pubkeys; std::vector<uint8_t> vOpretExtra; uint256 tokenid;
|
||||
std::vector<uint8_t> vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode; std::vector<CPubKey> pubkeys; uint256 tokenid;
|
||||
|
||||
if (DecodeTokenOpRet(scriptPubKey,tokenevalcode,tokenid,pubkeys,vOpretExtra)!=0 && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0)
|
||||
{
|
||||
if (!E_UNMARSHAL(vOpretExtra, { ss >> vopret; })) return (0);
|
||||
vopret=vOpretExtra;
|
||||
}
|
||||
else GetOpReturnData(scriptPubKey, vopret);
|
||||
script = (uint8_t *)vopret.data();
|
||||
|
||||
@@ -327,27 +327,28 @@ uint8_t _DecodeHeirEitherOpRet(CScript scriptPubKey, uint256 &tokenid, CPubKey&
|
||||
{
|
||||
uint8_t evalCodeTokens = 0;
|
||||
std::vector<CPubKey> voutPubkeysDummy;
|
||||
std::vector<uint8_t> vopretExtra, vopretStripped;
|
||||
std::vector<uint8_t> vopretExtra /*, vopretStripped*/;
|
||||
|
||||
if (DecodeTokenOpRet(scriptPubKey, evalCodeTokens, tokenid, voutPubkeysDummy, vopretExtra) != 0) {
|
||||
if (vopretExtra.size() > 1) {
|
||||
// restore the second opret:
|
||||
/* if (vopretExtra.size() > 1) {
|
||||
// restore the second opret:
|
||||
|
||||
if (!E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; })) { //strip string size
|
||||
if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() could not unmarshal vopretStripped" << std::endl;
|
||||
return (uint8_t)0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* unmarshalled in DecodeTokenOpRet:
|
||||
if (!E_UNMARSHAL(vopretExtra, { ss >> vopretStripped; })) { //strip string size
|
||||
if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() could not unmarshal vopretStripped" << std::endl;
|
||||
return (uint8_t)0;
|
||||
}
|
||||
} */
|
||||
if (vopretExtra.size() < 1) {
|
||||
if (!noLogging) std::cerr << "_DecodeHeirEitherOpret() empty vopretExtra" << std::endl;
|
||||
return (uint8_t)0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
GetOpReturnData(scriptPubKey, vopretStripped);
|
||||
GetOpReturnData(scriptPubKey, vopretExtra);
|
||||
}
|
||||
|
||||
return _DecodeHeirOpRet(vopretStripped, ownerPubkey, heirPubkey, inactivityTime, heirName, memo, fundingTxidInOpret, hasHeirSpendingBegun, noLogging);
|
||||
return _DecodeHeirOpRet(vopretExtra, ownerPubkey, heirPubkey, inactivityTime, heirName, memo, fundingTxidInOpret, hasHeirSpendingBegun, noLogging);
|
||||
}
|
||||
|
||||
// overload to decode opret in fundingtxid:
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#!/bin/sh
|
||||
gcc -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o ../libcc.so cclib.cpp
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/bin/sh
|
||||
cd rogue;
|
||||
./configure # only need this first time
|
||||
make; cd ..
|
||||
gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp -lncurses
|
||||
gcc -Wno-write-strings -DBUILD_ROGUE -std=c++11 -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -o librogue.so -c cclib.cpp
|
||||
#gcc -std=c++11 -fPIC -shared -o librogue.so cclib.o rogue/rogue.so
|
||||
cp librogue.so ../libcc.so
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ HDRS = rogue.h extern.h score.h
|
||||
OBJS1 = vers.$(O) extern.$(O) armor.$(O) chase.$(O) command.$(O) \
|
||||
daemon.$(O) daemons.$(O) fight.$(O) init.$(O) io.$(O) list.$(O) \
|
||||
mach_dep.$(O) rogue.$(O) mdport.$(O) misc.$(O) monsters.$(O) \
|
||||
move.$(O) new_level.$(O)
|
||||
move.$(O) new_level.$(O)
|
||||
OBJS2 = options.$(O) pack.$(O) passages.$(O) potions.$(O) rings.$(O) \
|
||||
rip.$(O) rooms.$(O) save.$(O) scrolls.$(O) state.$(O) sticks.$(O) \
|
||||
things.$(O) weapons.$(O) wizard.$(O) xcrypt.$(O)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <curses.h>
|
||||
//#include <curses.h>
|
||||
#include "rogue.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <curses.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <curses.h>
|
||||
#include "rogue.h"
|
||||
|
||||
#define DRAGONSHOT 5 /* one chance in DRAGONSHOT that a dragon will flame */
|
||||
|
||||
@@ -10,10 +10,7 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <curses.h>
|
||||
#include <ctype.h>
|
||||
//#include <curses.h>
|
||||
#include "rogue.h"
|
||||
|
||||
/*
|
||||
@@ -272,6 +269,7 @@ over:
|
||||
q_comm = FALSE;
|
||||
if ( rs->guiflag != 0 )
|
||||
rogue_bailout(rs);
|
||||
else rs->replaydone = (uint32_t)time(NULL);
|
||||
return;
|
||||
when 'i': after = FALSE; inventory(rs,pack, 0);
|
||||
when 'I': after = FALSE; picky_inven(rs);
|
||||
@@ -312,9 +310,12 @@ over:
|
||||
after = FALSE;
|
||||
msg(rs,"version %s. (mctesq was here)", release);
|
||||
when 'S':
|
||||
msg(rs,"Saving is disabled, use bailout rpc");
|
||||
after = FALSE;
|
||||
//save_game(rs);
|
||||
#ifdef STANDALONE
|
||||
save_game(rs);
|
||||
#else
|
||||
msg(rs,"Saving is disabled, use bailout rpc");
|
||||
#endif
|
||||
when '.': ; /* Rest command */
|
||||
when ' ': after = FALSE; /* "Legal" illegal command */
|
||||
when '^':
|
||||
|
||||
423
src/cc/rogue/cursesd.c
Normal file
423
src/cc/rogue/cursesd.c
Normal file
@@ -0,0 +1,423 @@
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
* *
|
||||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
|
||||
* the top-level directory of this distribution for the individual copyright *
|
||||
* holder information and the developer policies on copyright and licensing. *
|
||||
* *
|
||||
* Unless otherwise agreed in a custom licensing agreement, no part of the *
|
||||
* SuperNET software, including this file may be copied, modified, propagated *
|
||||
* or distributed except according to the terms contained in the LICENSE file *
|
||||
* *
|
||||
* Removal or modification of this copyright notice is prohibited. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "cursesd.h"
|
||||
|
||||
static int32_t endwinflag;
|
||||
WINDOW *stdscr;
|
||||
int32_t ESCDELAY;
|
||||
|
||||
WINDOW *newwin(int32_t nlines,int32_t ncols,int32_t begin_y,int32_t begin_x)
|
||||
{
|
||||
WINDOW *scr = 0;
|
||||
if ( nlines == LINES && ncols == COLS && begin_y == 0 && begin_x == 0 )
|
||||
scr = (WINDOW *)calloc(1,sizeof(*stdscr));
|
||||
curscr = scr;
|
||||
return(scr);
|
||||
}
|
||||
|
||||
WINDOW *initscr()
|
||||
{
|
||||
if ( stdscr == 0 )
|
||||
stdscr = newwin(LINES,COLS,0,0);
|
||||
return(stdscr);
|
||||
}
|
||||
|
||||
int32_t delwin(WINDOW *win)
|
||||
{
|
||||
free(win);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t wmove(WINDOW *win, int32_t y, int32_t x)
|
||||
{
|
||||
win->y = y;
|
||||
win->x = x;
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t move(int32_t y, int32_t x)
|
||||
{
|
||||
return(wmove(stdscr,y,x));
|
||||
}
|
||||
|
||||
int32_t werase(WINDOW *win)
|
||||
{
|
||||
memset(win->screen,' ',sizeof(win->screen));
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t wclear(WINDOW *win)
|
||||
{
|
||||
werase(win);
|
||||
clearok(win,TRUE);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t wclrtoeol(WINDOW *win)
|
||||
{
|
||||
if ( win->x < COLS-1 )
|
||||
memset(&win->screen[win->y][win->x],' ',COLS - win->x);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t wclrtobot(WINDOW *win)
|
||||
{
|
||||
wclrtoeol(win);
|
||||
if ( win->y < LINES-1 )
|
||||
memset(&win->screen[win->y+1][0],' ',COLS);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t erase(void)
|
||||
{
|
||||
return(werase(stdscr));
|
||||
}
|
||||
|
||||
int32_t clear(void)
|
||||
{
|
||||
return(wclear(stdscr));
|
||||
}
|
||||
|
||||
int32_t clrtobot(void)
|
||||
{
|
||||
return(wclrtobot(stdscr));
|
||||
}
|
||||
|
||||
int32_t clrtoeol(void)
|
||||
{
|
||||
return(wclrtoeol(stdscr));
|
||||
}
|
||||
|
||||
int32_t waddch(WINDOW *win, chtype ch)
|
||||
{
|
||||
int32_t i;
|
||||
if ( ch == '\t' )
|
||||
{
|
||||
for (i=0; i<8; i++)
|
||||
{
|
||||
if ( win->x >= COLS-1 )
|
||||
break;
|
||||
win->x++;
|
||||
if ( (win->x & 7) == 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( ch == '\n' )
|
||||
{
|
||||
wclrtoeol(win);
|
||||
win->x = 0;
|
||||
win->y++;
|
||||
if ( win->y >= LINES )
|
||||
win->y = 0;
|
||||
}
|
||||
else if ( ch == '\b' )
|
||||
{
|
||||
if ( win->x > 0 )
|
||||
win->x--;
|
||||
}
|
||||
else
|
||||
{
|
||||
win->screen[win->y][win->x++] = ch;
|
||||
if ( win->x >= COLS )
|
||||
{
|
||||
win->x = 0;
|
||||
win->y++;
|
||||
if ( win->y >= LINES )
|
||||
win->y = 0;
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t mvwaddch(WINDOW *win, int32_t y, int32_t x, chtype ch)
|
||||
{
|
||||
win->y = y;
|
||||
win->x = x;
|
||||
return(waddch(win,ch));
|
||||
}
|
||||
|
||||
int32_t addch(chtype ch)
|
||||
{
|
||||
return(waddch(stdscr,ch));
|
||||
}
|
||||
|
||||
int32_t mvaddch(int32_t y, int32_t x, chtype ch)
|
||||
{
|
||||
return(mvwaddch(stdscr,y,x,ch));
|
||||
}
|
||||
|
||||
int32_t waddstr(WINDOW *win, const char *str)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=0; str[i]!=0; i++)
|
||||
waddch(win,str[i]);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t waddnstr(WINDOW *win, const char *str, int32_t n)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=0; str[i]!=0 && i<n; i++)
|
||||
waddch(win,str[i]);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t mvwaddstr(WINDOW *win, int32_t y, int32_t x, const char *str)
|
||||
{
|
||||
win->y = y;
|
||||
win->x = x;
|
||||
return(waddstr(win,str));
|
||||
}
|
||||
|
||||
int32_t mvwaddnstr(WINDOW *win, int32_t y, int32_t x, const char *str, int32_t n)
|
||||
{
|
||||
win->y = y;
|
||||
win->x = x;
|
||||
return(waddnstr(win,str,n));
|
||||
}
|
||||
|
||||
int32_t addstr(const char *str)
|
||||
{
|
||||
return(waddstr(stdscr,str));
|
||||
}
|
||||
|
||||
int32_t addnstr(const char *str, int32_t n)
|
||||
{
|
||||
return(waddnstr(stdscr,str,n));
|
||||
}
|
||||
|
||||
int32_t mvaddstr(int32_t y, int32_t x, const char *str)
|
||||
{
|
||||
stdscr->y = y;
|
||||
stdscr->x = x;
|
||||
return(waddstr(stdscr,str));
|
||||
}
|
||||
|
||||
int32_t mvaddnstr(int32_t y, int32_t x, const char *str, int32_t n)
|
||||
{
|
||||
stdscr->y = y;
|
||||
stdscr->x = x;
|
||||
return(waddnstr(stdscr,str,n));
|
||||
}
|
||||
|
||||
int32_t printw(char *fmt,...)
|
||||
{
|
||||
char str[512]; int32_t ret; va_list myargs; // Declare a va_list type variable
|
||||
va_start(myargs,fmt); // Initialise the va_list variable with the ... after fmt
|
||||
ret = vsprintf(str,fmt,myargs); // Forward the '...' to vsprintf
|
||||
va_end(myargs); // Clean up the va_list
|
||||
return(addstr(str));
|
||||
}
|
||||
|
||||
int32_t wprintw(WINDOW *win,char *fmt,...)
|
||||
{
|
||||
char str[512]; int32_t ret; va_list myargs; // Declare a va_list type variable
|
||||
va_start(myargs,fmt); // Initialise the va_list variable with the ... after fmt
|
||||
ret = vsprintf(str,fmt,myargs); // Forward the '...' to vsprintf
|
||||
va_end(myargs); // Clean up the va_list
|
||||
return(waddstr(win,str));
|
||||
}
|
||||
|
||||
int32_t mvprintw(int32_t y,int32_t x,char *fmt,...)
|
||||
{
|
||||
char str[512]; int32_t ret; va_list myargs; // Declare a va_list type variable
|
||||
va_start(myargs,fmt); // Initialise the va_list variable with the ... after fmt
|
||||
ret = vsprintf(str,fmt,myargs); // Forward the '...' to vsprintf
|
||||
va_end(myargs); // Clean up the va_list
|
||||
stdscr->y = y;
|
||||
stdscr->x = x;
|
||||
return(addstr(str));
|
||||
}
|
||||
|
||||
int32_t mvwprintw(WINDOW *win,int32_t y,int32_t x,char *fmt,...)
|
||||
{
|
||||
char str[512]; int32_t ret; va_list myargs; // Declare a va_list type variable
|
||||
va_start(myargs,fmt); // Initialise the va_list variable with the ... after fmt
|
||||
ret = vsprintf(str,fmt,myargs); // Forward the '...' to vsprintf
|
||||
va_end(myargs); // Clean up the va_list
|
||||
win->y = y;
|
||||
win->x = x;
|
||||
return(waddstr(win,str));
|
||||
}
|
||||
|
||||
chtype winch(WINDOW *win)
|
||||
{
|
||||
return(win->screen[win->y][win->x]);
|
||||
}
|
||||
|
||||
chtype inch(void)
|
||||
{
|
||||
return(winch(stdscr));
|
||||
}
|
||||
|
||||
chtype mvwinch(WINDOW *win, int32_t y, int32_t x)
|
||||
{
|
||||
win->y = y;
|
||||
win->x = x;
|
||||
return(win->screen[win->y][win->x]);
|
||||
}
|
||||
|
||||
chtype mvinch(int32_t y, int32_t x)
|
||||
{
|
||||
return(mvwinch(stdscr,y,x));
|
||||
}
|
||||
|
||||
int32_t mvcur(int32_t oldrow, int32_t oldcol, int32_t newrow, int32_t newcol)
|
||||
{
|
||||
stdscr->y = newrow;
|
||||
stdscr->x = newcol;
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t endwin(void)
|
||||
{
|
||||
if ( stdscr != 0 )
|
||||
free(stdscr), stdscr = 0;
|
||||
endwinflag = 1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t isendwin(void)
|
||||
{
|
||||
return(endwinflag);
|
||||
}
|
||||
|
||||
int32_t refresh(void)
|
||||
{
|
||||
endwinflag = 0;
|
||||
return(wrefresh(stdscr));
|
||||
}
|
||||
|
||||
int32_t redrawwin(WINDOW *win)
|
||||
{
|
||||
return(wrefresh(win));
|
||||
}
|
||||
|
||||
int32_t wredrawln(WINDOW *win, int32_t beg_line, int32_t num_lines)
|
||||
{
|
||||
return(wrefresh(win));
|
||||
}
|
||||
|
||||
// functions with no data side effect
|
||||
#ifdef they_are_macros
|
||||
int32_t wrefresh(WINDOW *win)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t wnoutrefresh(WINDOW *win)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t doupdate(void)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t touchwin(WINDOW *win)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t standout(void)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t standend(void)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t raw(void)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t keypad(WINDOW *win, bool bf)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t noecho(void)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t flushinp(void)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t clearok(WINDOW *win, bool bf)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t idlok(WINDOW *win, bool bf)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t leaveok(WINDOW *win, bool bf)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t mvwin(WINDOW *win, int32_t y, int32_t x) // stub
|
||||
{
|
||||
fprintf(stderr,"unexpected call to mvwin\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
WINDOW *subwin(WINDOW *orig, int32_t nlines, int32_t ncols, int32_t begin_y, int32_t begin_x)
|
||||
{
|
||||
fprintf(stderr,"unexpected and unsupported call to subwin\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
char erasechar(void)
|
||||
{
|
||||
fprintf(stderr,"unexpected and unsupported call to erasechar\n");
|
||||
return(8);
|
||||
}
|
||||
|
||||
char killchar(void)
|
||||
{
|
||||
fprintf(stderr,"unexpected and unsupported call to erasechar\n");
|
||||
return(3);
|
||||
}
|
||||
|
||||
int32_t wgetnstr(WINDOW *win, char *str, int32_t n) // stub
|
||||
{
|
||||
fprintf(stderr,"unexpected and unsupported call to mvgetnstr\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t getch(void)
|
||||
{
|
||||
fprintf(stderr,"unexpected and unsupported call to getch\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t md_readchar(void)
|
||||
{
|
||||
fprintf(stderr,"unexpected and unsupported call to md_readchar\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
158
src/cc/rogue/cursesd.h
Normal file
158
src/cc/rogue/cursesd.h
Normal file
@@ -0,0 +1,158 @@
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
* *
|
||||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
|
||||
* the top-level directory of this distribution for the individual copyright *
|
||||
* holder information and the developer policies on copyright and licensing. *
|
||||
* *
|
||||
* Unless otherwise agreed in a custom licensing agreement, no part of the *
|
||||
* SuperNET software, including this file may be copied, modified, propagated *
|
||||
* or distributed except according to the terms contained in the LICENSE file *
|
||||
* *
|
||||
* Removal or modification of this copyright notice is prohibited. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef H_CURSESD_H
|
||||
#define H_CURSESD_H
|
||||
|
||||
#define LINES 24
|
||||
#define COLS 80
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h> /* we need va_list */
|
||||
#include <stddef.h> /* we want wchar_t */
|
||||
#include <stdbool.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define ERR (-1)
|
||||
|
||||
struct cursesd_info
|
||||
{
|
||||
uint8_t screen[LINES][COLS];
|
||||
int32_t x,y;
|
||||
};
|
||||
typedef struct cursesd_info WINDOW;
|
||||
extern WINDOW *stdscr,*curscr;
|
||||
extern int32_t ESCDELAY;
|
||||
typedef char chtype;
|
||||
|
||||
int32_t getch(void); // stub
|
||||
int32_t md_readchar(void); // stub
|
||||
|
||||
WINDOW *initscr(void);
|
||||
int32_t endwin(void);
|
||||
int32_t isendwin(void);
|
||||
//SCREEN *newterm(const char *type, FILE *outfd, FILE *infd);
|
||||
//SCREEN *set_term(SCREEN *new);
|
||||
//void delscreen(SCREEN* sp);
|
||||
|
||||
int32_t refresh(void);
|
||||
int32_t wrefresh(WINDOW *win);
|
||||
//int32_t wnoutrefresh(WINDOW *win);
|
||||
//int32_t doupdate(void);
|
||||
int32_t redrawwin(WINDOW *win);
|
||||
int32_t wredrawln(WINDOW *win, int32_t beg_line, int32_t num_lines);
|
||||
|
||||
int32_t erase(void);
|
||||
int32_t werase(WINDOW *win);
|
||||
int32_t clear(void);
|
||||
int32_t wclear(WINDOW *win);
|
||||
int32_t clrtobot(void);
|
||||
int32_t wclrtobot(WINDOW *win);
|
||||
int32_t clrtoeol(void);
|
||||
int32_t wclrtoeol(WINDOW *win);
|
||||
|
||||
int32_t standout(void);
|
||||
int32_t standend(void);
|
||||
int32_t raw(void);
|
||||
int32_t noecho(void);
|
||||
int32_t flushinp(void);
|
||||
int32_t keypad(WINDOW *win, bool bf);
|
||||
|
||||
int32_t clearok(WINDOW *win, bool bf);
|
||||
int32_t idlok(WINDOW *win, bool bf);
|
||||
int32_t leaveok(WINDOW *win, bool bf);
|
||||
|
||||
WINDOW *newwin(int32_t nlines,int32_t ncols,int32_t begin_y,int32_t begin_x); // only LINES,COLS,0,0
|
||||
int32_t delwin(WINDOW *win);
|
||||
int32_t touchwin(WINDOW *win); // stub
|
||||
WINDOW *subwin(WINDOW *orig, int32_t nlines, int32_t ncols, int32_t begin_y, int32_t begin_x); // stub
|
||||
int32_t mvwin(WINDOW *win, int32_t y, int32_t x); // stub
|
||||
int32_t mvcur(int32_t oldrow, int32_t oldcol, int32_t newrow, int32_t newcol);
|
||||
|
||||
char erasechar(void); // stub
|
||||
char killchar(void); // stub
|
||||
|
||||
int32_t move(int32_t y, int32_t x);
|
||||
int32_t wmove(WINDOW *win, int32_t y, int32_t x);
|
||||
|
||||
chtype inch(void);
|
||||
chtype winch(WINDOW *win);
|
||||
chtype mvinch(int32_t y, int32_t x);
|
||||
chtype mvwinch(WINDOW *win, int32_t y, int32_t x);
|
||||
|
||||
int32_t addch(chtype ch);
|
||||
int32_t waddch(WINDOW *win, chtype ch);
|
||||
int32_t mvaddch(int32_t y, int32_t x, chtype ch);
|
||||
int32_t mvwaddch(WINDOW *win, int32_t y, int32_t x, chtype ch);
|
||||
|
||||
int32_t addstr(const char *str);
|
||||
int32_t addnstr(const char *str, int32_t n);
|
||||
int32_t waddstr(WINDOW *win, const char *str);
|
||||
int32_t waddnstr(WINDOW *win, const char *str, int32_t n);
|
||||
int32_t mvaddstr(int32_t y, int32_t x, const char *str);
|
||||
int32_t mvaddnstr(int32_t y, int32_t x, const char *str, int32_t n);
|
||||
int32_t mvwaddstr(WINDOW *win, int32_t y, int32_t x, const char *str);
|
||||
int32_t mvwaddnstr(WINDOW *win, int32_t y, int32_t x, const char *str, int32_t n);
|
||||
|
||||
int32_t wgetnstr(WINDOW *win, char *str, int32_t n); // stub
|
||||
int32_t printw(char *fmt,...);
|
||||
int32_t wprintw(WINDOW *win,char *fmt,...);
|
||||
int32_t mvprintw(int32_t y,int32_t x,char *fmt,...);
|
||||
int32_t mvwprintw(WINDOW *win,int32_t y,int32_t x,char *fmt,...);
|
||||
|
||||
#define A_CHARTEXT 0xff
|
||||
#define baudrate() 9600
|
||||
#define unctrl(a) "^x"
|
||||
#define getmaxx(a) COLS
|
||||
#define getmaxy(a) LINES
|
||||
#define getyx(win,_argfory,_argforx) _argfory = win->y, _argforx = win->x
|
||||
|
||||
// functions with only visible effects
|
||||
#define wrefresh(win) 0
|
||||
#define wnoutrefresh(win) 0
|
||||
#define doupdate() 0
|
||||
#define touchwin(win) 0
|
||||
#define standout() 0
|
||||
#define standend() 0
|
||||
#define raw() 0
|
||||
#define keypad(win,bf) 0
|
||||
#define noecho() 0
|
||||
#define flushinp() 0
|
||||
#define clearok(win,bf) 0
|
||||
#define idlok(win,bf) 0
|
||||
#define leaveok(win,bf) 0
|
||||
#define halfdelay(x) 0
|
||||
#define nocbreak() 0
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <curses.h>
|
||||
//#include <curses.h>
|
||||
#include "rogue.h"
|
||||
|
||||
#define EMPTY 0
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <curses.h>
|
||||
//#include <curses.h>
|
||||
#include "rogue.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <curses.h>
|
||||
//#include <curses.h>
|
||||
#include "rogue.h"
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
#ifndef H_EXTERN_ROGUE_H
|
||||
#define H_EXTERN_ROGUE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#ifdef PDCURSES
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <curses.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <curses.h>
|
||||
//#include <string.h>
|
||||
//#include <ctype.h>
|
||||
#include "rogue.h"
|
||||
|
||||
//#define EQSTR(a, b) (strcmp(a, b) == 0)
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <curses.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <curses.h>
|
||||
//#include <ctype.h>
|
||||
//#include <string.h>
|
||||
#include "rogue.h"
|
||||
|
||||
/*
|
||||
@@ -27,7 +27,7 @@ void restore_player(struct rogue_state *rs)
|
||||
int32_t i; THING *obj;
|
||||
//rs->P.gold = purse;
|
||||
max_hp = rs->P.hitpoints;
|
||||
max_stats.s_str = rs->P.strength;
|
||||
pstats.s_str = max_stats.s_str = rs->P.strength;
|
||||
pstats.s_lvl = rs->P.level;
|
||||
pstats.s_exp = rs->P.experience;
|
||||
for (i=0; i<rs->P.packsize; i++)
|
||||
@@ -49,7 +49,11 @@ void init_player(struct rogue_state *rs)
|
||||
// duplicate rng usage of normal case
|
||||
obj = new_item();
|
||||
init_weapon(obj, MACE);
|
||||
free(obj);
|
||||
obj = new_item();
|
||||
init_weapon(obj, BOW);
|
||||
free(obj);
|
||||
obj = new_item();
|
||||
init_weapon(obj, ARROW);
|
||||
obj->o_count = rnd(15) + 25;
|
||||
free(obj);
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
* @(#)io.c 4.32 (Berkeley) 02/05/99
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <curses.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
//#include <stdarg.h>
|
||||
//#include <curses.h>
|
||||
//#include <ctype.h>
|
||||
//#include <string.h>
|
||||
|
||||
#include "rogue.h"
|
||||
|
||||
/*
|
||||
@@ -155,6 +156,7 @@ readchar(struct rogue_state *rs)
|
||||
char ch = -1;
|
||||
if ( rs != 0 && rs->guiflag == 0 )
|
||||
{
|
||||
static uint32_t counter;
|
||||
if ( rs->ind < rs->numkeys )
|
||||
{
|
||||
//if ( rs->ind == rs->numkeys-1 )
|
||||
@@ -162,12 +164,15 @@ readchar(struct rogue_state *rs)
|
||||
//fprintf(stderr,"(%c) ",rs->keystrokes[rs->ind]);
|
||||
return(rs->keystrokes[rs->ind++]);
|
||||
}
|
||||
fprintf(stderr,"replay finished but readchar called\n");
|
||||
if ( rs->replaydone != 0 && counter++ < 3 )
|
||||
fprintf(stderr,"replay finished but readchar called\n");
|
||||
rs->replaydone = (uint32_t)time(NULL);
|
||||
//if ( (rand() & 1) == 0 )
|
||||
// return(ESCAPE);
|
||||
//else
|
||||
return('y');
|
||||
if ( counter < 3 || (counter & 1) == 0 )
|
||||
return('y');
|
||||
else return(ESCAPE);
|
||||
}
|
||||
if ( rs == 0 || rs->guiflag != 0 )
|
||||
{
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <curses.h>
|
||||
#include <memory.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <curses.h>
|
||||
//#include <memory.h>
|
||||
#include "rogue.h"
|
||||
|
||||
#ifdef MASTER
|
||||
|
||||
@@ -46,7 +46,8 @@
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <curses.h>
|
||||
//#include <curses.h>
|
||||
#include "rogue.h"
|
||||
#include "extern.h"
|
||||
|
||||
#define NOOP(x) (x += 0)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define SMALLVAL 0.000000000000001
|
||||
#define SATOSHIDEN ((uint64_t)100000000L)
|
||||
@@ -251,7 +252,7 @@ int main(int argc, char **argv, char **envp)
|
||||
if ( argc == 2 && (fp=fopen(argv[1],"rb")) == 0 )
|
||||
{
|
||||
seed = atol(argv[1]);
|
||||
fprintf(stderr,"replay %llu\n",(long long)seed);
|
||||
//fprintf(stderr,"replay %llu\n",(long long)seed);
|
||||
return(rogue_replay(seed,50000));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#undef MOUSE_MOVED
|
||||
#endif
|
||||
|
||||
#include <curses.h>
|
||||
//#include <curses.h>
|
||||
#include "extern.h"
|
||||
|
||||
#if defined(HAVE_SYS_TYPES)
|
||||
@@ -81,7 +81,12 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef BUILD_ROGUE
|
||||
#include <curses.h> /* AIX requires curses.h be included before term.h */
|
||||
#else
|
||||
#include "cursesd.h"
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(HAVE_TERM_H)
|
||||
#include <term.h>
|
||||
@@ -1076,6 +1081,7 @@ md_setsuspchar(int c)
|
||||
#define M_KEYPAD 2
|
||||
#define M_TRAIL 3
|
||||
|
||||
#ifndef BUILD_ROGUE
|
||||
int
|
||||
md_readchar()
|
||||
{
|
||||
@@ -1315,7 +1321,8 @@ md_readchar()
|
||||
|
||||
return(ch & 0x7F);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(LOADAV) && defined(HAVE_NLIST_H) && defined(HAVE_NLIST)
|
||||
/*
|
||||
* loadav:
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <curses.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <curses.h>
|
||||
//#include <string.h>
|
||||
//#include <ctype.h>
|
||||
#include "rogue.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <curses.h>
|
||||
#include <string.h>
|
||||
//#include <curses.h>
|
||||
//#include <string.h>
|
||||
#include "rogue.h"
|
||||
#include <ctype.h>
|
||||
//#include <ctype.h>
|
||||
|
||||
/*
|
||||
* List of monsters in rough order of vorpalness
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <curses.h>
|
||||
#include <ctype.h>
|
||||
//#include <curses.h>
|
||||
//#include <ctype.h>
|
||||
#include "rogue.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <curses.h>
|
||||
#include <string.h>
|
||||
//#include <curses.h>
|
||||
//#include <string.h>
|
||||
#include "rogue.h"
|
||||
|
||||
#define TREAS_ROOM 20 /* one chance in TREAS_ROOM for a treasure room */
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <curses.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <curses.h>
|
||||
//#include <ctype.h>
|
||||
//#include <string.h>
|
||||
#include "rogue.h"
|
||||
|
||||
#define EQSTR(a, b, c) (strncmp(a, b, c) == 0)
|
||||
@@ -266,7 +266,7 @@ get_str(struct rogue_state *rs,void *vopt, WINDOW *win)
|
||||
{
|
||||
if (c == -1)
|
||||
continue;
|
||||
else if (c == erasechar()) /* process erase character */
|
||||
/*else if (c == erasechar()) // process erase character
|
||||
{
|
||||
if (sp > buf)
|
||||
{
|
||||
@@ -276,12 +276,12 @@ get_str(struct rogue_state *rs,void *vopt, WINDOW *win)
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if (c == killchar()) /* process kill character */
|
||||
else if (c == killchar()) // process kill character
|
||||
{
|
||||
sp = buf;
|
||||
wmove(win, oy, ox);
|
||||
continue;
|
||||
}
|
||||
}*/
|
||||
else if (sp == buf)
|
||||
{
|
||||
if (c == '-' && win != stdscr)
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <curses.h>
|
||||
#include <ctype.h>
|
||||
//#include <string.h>
|
||||
//#include <curses.h>
|
||||
//#include <ctype.h>
|
||||
#include "rogue.h"
|
||||
|
||||
/*
|
||||
@@ -165,6 +165,7 @@ out:
|
||||
bool
|
||||
pack_room(struct rogue_state *rs,bool from_floor, THING *obj)
|
||||
{
|
||||
inpack = num_packitems();
|
||||
if (++inpack > MAXPACK)
|
||||
{
|
||||
if (!terse)
|
||||
@@ -178,7 +179,8 @@ pack_room(struct rogue_state *rs,bool from_floor, THING *obj)
|
||||
inpack = MAXPACK;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//fprintf(stderr,"inpack.%d vs MAX.%d\n",inpack,MAXPACK), sleep(2);
|
||||
|
||||
if (from_floor)
|
||||
{
|
||||
detach(lvl_obj, obj);
|
||||
@@ -244,6 +246,16 @@ pack_char()
|
||||
* List what is in the pack. Return TRUE if there is something of
|
||||
* the given type.
|
||||
*/
|
||||
|
||||
int32_t num_packitems()
|
||||
{
|
||||
THING *list = pack;
|
||||
int32_t type = 0,n = 0;
|
||||
for (; list != NULL; list = next(list))
|
||||
n++;
|
||||
return(n);
|
||||
}
|
||||
|
||||
bool
|
||||
inventory(struct rogue_state *rs,THING *list, int type)
|
||||
{
|
||||
@@ -272,6 +284,8 @@ inventory(struct rogue_state *rs,THING *list, int type)
|
||||
}
|
||||
msg_esc = FALSE;
|
||||
}
|
||||
//if ( n_objs != inpack )
|
||||
// fprintf(stderr,"n_objs.%d vs inpack.%d\n",n_objs,inpack), sleep(2);
|
||||
if (n_objs == 0)
|
||||
{
|
||||
if (terse)
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <curses.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <curses.h>
|
||||
#include "rogue.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <curses.h>
|
||||
#include <ctype.h>
|
||||
//#include <curses.h>
|
||||
//#include <ctype.h>
|
||||
#include "rogue.h"
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <curses.h>
|
||||
//#include <curses.h>
|
||||
#include "rogue.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <string.h>
|
||||
//#include <time.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <curses.h>
|
||||
//#include <sys/types.h>
|
||||
//#include <ctype.h>
|
||||
//#include <fcntl.h>
|
||||
//#include <curses.h>
|
||||
#include "rogue.h"
|
||||
#include "score.h"
|
||||
|
||||
@@ -87,6 +87,7 @@ score(struct rogue_state *rs,int amount, int flags, char monst)
|
||||
delwin(curscr);
|
||||
if (hw != NULL)
|
||||
delwin(hw);
|
||||
hw = NULL;
|
||||
}
|
||||
|
||||
top_ten = (SCORE *) malloc(numscores * sizeof (SCORE));
|
||||
|
||||
@@ -8,12 +8,11 @@
|
||||
* @(#)main.c 4.22 (Berkeley) 02/05/99
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <curses.h>
|
||||
//#include <unistd.h>
|
||||
//#include <curses.h>
|
||||
#include "rogue.h"
|
||||
#ifdef STANDALONE
|
||||
#include "../komodo/src/komodo_cJSON.h"
|
||||
@@ -88,9 +87,13 @@ void rogueiterate(struct rogue_state *rs)
|
||||
endwin();
|
||||
my_exit(1);
|
||||
}
|
||||
//fprintf(stderr,"LINES %d, COLS %d\n",LINES,COLS);
|
||||
|
||||
// Set up windows
|
||||
if ( hw == NULL )
|
||||
{
|
||||
hw = newwin(LINES, COLS, 0, 0);
|
||||
}
|
||||
idlok(stdscr, TRUE);
|
||||
idlok(hw, TRUE);
|
||||
#ifdef MASTER
|
||||
@@ -103,7 +106,9 @@ void rogueiterate(struct rogue_state *rs)
|
||||
fuse(swander, 0, WANDERTIME, AFTER);
|
||||
start_daemon(stomach, 0, AFTER);
|
||||
if ( rs->restoring != 0 )
|
||||
{
|
||||
restore_player(rs);
|
||||
}
|
||||
playit(rs);
|
||||
}
|
||||
|
||||
@@ -231,37 +236,40 @@ void rogue_bailout(struct rogue_state *rs)
|
||||
fprintf(stderr,"error issuing (%s)\n",cmd);
|
||||
}
|
||||
|
||||
int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player)
|
||||
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;
|
||||
rs = (struct rogue_state *)calloc(1,sizeof(*rs));
|
||||
rs->seed = seed;
|
||||
rs->keystrokes = keystrokes;
|
||||
rs->numkeys = num;
|
||||
rs->sleeptime = 0*50000;
|
||||
rs->sleeptime = sleepmillis * 1000;
|
||||
if ( player != 0 )
|
||||
{
|
||||
rs->P = *player;
|
||||
rs->restoring = 1;
|
||||
fprintf(stderr,"restore player packsize.%d\n",rs->P.packsize);
|
||||
//fprintf(stderr,"restore player packsize.%d HP.%d\n",rs->P.packsize,rs->P.hitpoints);
|
||||
}
|
||||
uint32_t starttime = (uint32_t)time(NULL);
|
||||
rogueiterate(rs);
|
||||
/*fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime);
|
||||
sleep(2);
|
||||
|
||||
starttime = (uint32_t)time(NULL);
|
||||
for (i=0; i<100; i++)
|
||||
if ( 0 )
|
||||
{
|
||||
memset(rs,0,sizeof(*rs));
|
||||
rs->seed = seed;
|
||||
rs->keystrokes = keystrokes;
|
||||
rs->numkeys = num;
|
||||
rs->sleeptime = 0;
|
||||
rogueiterate(rs);
|
||||
fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL) - starttime);
|
||||
sleep(2);
|
||||
|
||||
starttime = (uint32_t)time(NULL);
|
||||
for (i=0; i<10000; i++)
|
||||
{
|
||||
memset(rs,0,sizeof(*rs));
|
||||
rs->seed = seed;
|
||||
rs->keystrokes = keystrokes;
|
||||
rs->numkeys = num;
|
||||
rs->sleeptime = 0;
|
||||
rogueiterate(rs);
|
||||
}
|
||||
fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime);
|
||||
sleep(3);
|
||||
}
|
||||
fprintf(stderr,"elapsed %d seconds\n",(uint32_t)time(NULL)-starttime);
|
||||
sleep(1);*/
|
||||
if ( (fp= fopen("checkfile","wb")) != 0 )
|
||||
{
|
||||
save_file(rs,fp,0);
|
||||
@@ -284,17 +292,19 @@ long get_filesize(FILE *fp)
|
||||
|
||||
int32_t rogue_replay(uint64_t seed,int32_t sleeptime)
|
||||
{
|
||||
FILE *fp; char fname[1024]; char *keystrokes = 0; long num=0,fsize; int32_t i,counter = 0; struct rogue_state *rs;
|
||||
FILE *fp; char fname[1024]; char *keystrokes = 0; long num=0,fsize; int32_t i,counter = 0; struct rogue_state *rs; struct rogue_player P,*player = 0;
|
||||
if ( seed == 0 )
|
||||
seed = 777;
|
||||
while ( 1 )
|
||||
{
|
||||
roguefname(fname,seed,counter);
|
||||
//printf("check (%s)\n",fname);
|
||||
if ( (fp= fopen(fname,"rb")) == 0 )
|
||||
break;
|
||||
if ( (fsize= get_filesize(fp)) <= 0 )
|
||||
{
|
||||
fclose(fp);
|
||||
printf("fsize.%ld\n",fsize);
|
||||
break;
|
||||
}
|
||||
if ( (keystrokes= (char *)realloc(keystrokes,num+fsize)) == 0 )
|
||||
@@ -316,8 +326,19 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime)
|
||||
}
|
||||
if ( num > 0 )
|
||||
{
|
||||
rogue_replay2(0,seed,keystrokes,num,0);
|
||||
mvaddstr(LINES - 2, 0, (char *)"replay completed");
|
||||
sprintf(fname,"rogue.%llu.player",(long long)seed);
|
||||
if ( (fp=fopen(fname,"rb")) != 0 )
|
||||
{
|
||||
if ( fread(&P,1,sizeof(P),fp) > 0 )
|
||||
{
|
||||
//printf("max size player\n");
|
||||
player = &P;
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
rogue_replay2(0,seed,keystrokes,num,player,150);
|
||||
|
||||
//mvaddstr(LINES - 2, 0, (char *)"replay completed");
|
||||
endwin();
|
||||
}
|
||||
if ( keystrokes != 0 )
|
||||
@@ -523,9 +544,11 @@ tstp(int ignored)
|
||||
fflush(stdout);
|
||||
//wmove(curscr,oy,ox);
|
||||
#ifndef __APPLE__
|
||||
#ifndef BUILD_ROGUE
|
||||
curscr->_cury = oy;
|
||||
curscr->_curx = ox;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -569,7 +592,8 @@ playit(struct rogue_state *rs)
|
||||
{
|
||||
if ( rs->replaydone != 0 )
|
||||
{
|
||||
//fprintf(stderr,"replaydone\n"); sleep(3);
|
||||
if ( rs->sleeptime != 0 )
|
||||
sleep(3);
|
||||
return;
|
||||
}
|
||||
if ( rs->sleeptime != 0 )
|
||||
@@ -626,8 +650,8 @@ quit(int sig)
|
||||
}
|
||||
else
|
||||
{
|
||||
score(rs,purse, 1, 0);
|
||||
fprintf(stderr,"done!\n");
|
||||
//score(rs,purse, 1, 0);
|
||||
//fprintf(stderr,"done!\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -12,9 +12,42 @@
|
||||
|
||||
#ifndef H_ROGUE_H
|
||||
#define H_ROGUE_H
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h> /* we need va_list */
|
||||
#include <stddef.h> /* we want wchar_t */
|
||||
#include <stdbool.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef BUILD_ROGUE
|
||||
#include <curses.h>
|
||||
#else
|
||||
#include "cursesd.h"
|
||||
#endif
|
||||
|
||||
#ifdef LINES
|
||||
#undef LINES
|
||||
#endif
|
||||
#ifdef COLS
|
||||
#undef COLS
|
||||
#endif
|
||||
|
||||
#define LINES 24
|
||||
#define COLS 80
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
|
||||
#undef lines
|
||||
|
||||
#define NOOP(x) (x += 0)
|
||||
@@ -358,7 +391,7 @@ int32_t roguefname(char *fname,uint64_t seed,int32_t counter);
|
||||
int32_t flushkeystrokes(struct rogue_state *rs);
|
||||
int32_t rogue_restorepack(struct rogue_state *rs);
|
||||
void restore_player(struct rogue_state *rs);
|
||||
int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player);
|
||||
int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis);
|
||||
void rogue_bailout(struct rogue_state *rs);
|
||||
|
||||
/*
|
||||
@@ -782,6 +815,7 @@ THING *leave_pack(struct rogue_state *rs,THING *obj, bool newobj, bool all);
|
||||
THING *new_item(void);
|
||||
THING *new_thing(struct rogue_state *rs);
|
||||
void end_line(struct rogue_state *rs);
|
||||
int32_t num_packitems();
|
||||
|
||||
void runners(struct rogue_state *rs,int);
|
||||
void land(struct rogue_state *rs,int);
|
||||
@@ -826,5 +860,8 @@ extern const char *wood[];
|
||||
extern int cNWOOD;
|
||||
extern const char *metal[];
|
||||
extern int cNMETAL;
|
||||
|
||||
//extern WINDOW *stdscr,*curscr;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <curses.h>
|
||||
//#include <ctype.h>
|
||||
//#include <curses.h>
|
||||
#include "rogue.h"
|
||||
|
||||
typedef struct spot { /* position matrix for maze positions */
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <curses.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <sys/types.h>
|
||||
//#include <sys/stat.h>
|
||||
//#include <errno.h>
|
||||
//#include <signal.h>
|
||||
//#include <string.h>
|
||||
//#include <curses.h>
|
||||
#include "rogue.h"
|
||||
#include "score.h"
|
||||
|
||||
@@ -165,21 +165,24 @@ save_file(struct rogue_state *rs,FILE *savef,int32_t guiflag)
|
||||
memset(histo,0,sizeof(histo));
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
fprintf(stderr,"%02x",((uint8_t *)&rs->P)[i]);
|
||||
//fprintf(stderr,"%02x",((uint8_t *)&rs->P)[i]);
|
||||
histo[((uint8_t *)&rs->P)[i]]++;
|
||||
rs->playerdata[i] = ((uint8_t *)&rs->P)[i];
|
||||
}
|
||||
rs->playersize = n;
|
||||
fprintf(stderr," packsize.%d n.%d\n",rs->P.packsize,n);
|
||||
//fprintf(stderr," packsize.%d n.%d\n",rs->P.packsize,n);
|
||||
if ( (fp= fopen(rogue_packfname(rs,fname),"wb")) != 0 )
|
||||
{
|
||||
fwrite(&rs->P,1,n,fp);
|
||||
fclose(fp);
|
||||
}
|
||||
for (i=nonz=0; i<0x100; i++)
|
||||
if ( histo[i] != 0 )
|
||||
fprintf(stderr,"(%d %d) ",i,histo[i]), nonz++;
|
||||
fprintf(stderr,"nonz.%d\n",nonz);
|
||||
if ( 0 )
|
||||
{
|
||||
for (i=nonz=0; i<0x100; i++)
|
||||
if ( histo[i] != 0 )
|
||||
fprintf(stderr,"(%d %d) ",i,histo[i]), nonz++;
|
||||
fprintf(stderr,"nonz.%d\n",nonz);
|
||||
}
|
||||
fflush(savef);
|
||||
fclose(savef);
|
||||
if ( guiflag != 0 )
|
||||
@@ -224,7 +227,9 @@ restore(struct rogue_state *rs,char *file, char **envp)
|
||||
char buf[MAXSTR];
|
||||
//auto
|
||||
STAT sbuf2;
|
||||
|
||||
if ( rs->guiflag == 0 )
|
||||
return(0);
|
||||
|
||||
if (strcmp(file, "-r") == 0)
|
||||
file = file_name;
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <curses.h>
|
||||
#include <ctype.h>
|
||||
//#include <curses.h>
|
||||
//#include <ctype.h>
|
||||
#include "rogue.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <curses.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <string.h>
|
||||
//#include <curses.h>
|
||||
#include "rogue.h"
|
||||
|
||||
/************************************************************************/
|
||||
@@ -1434,7 +1434,7 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o)
|
||||
item = &rs->P.roguepack[rs->P.packsize];
|
||||
if ( pstats.s_hpt <= 0 )
|
||||
{
|
||||
fprintf(stderr,"KILLED\n");
|
||||
//fprintf(stderr,"KILLED\n");
|
||||
rs->P.gold = -1;
|
||||
rs->P.hitpoints = -1;
|
||||
rs->P.strength = -1;
|
||||
@@ -1448,13 +1448,13 @@ rs_write_object(struct rogue_state *rs,FILE *savef, THING *o)
|
||||
{
|
||||
rs->P.gold = purse;
|
||||
rs->P.hitpoints = max_hp;
|
||||
rs->P.strength = max_stats.s_str;
|
||||
rs->P.strength = pstats.s_str; //max_stats.s_str;
|
||||
rs->P.level = pstats.s_lvl;
|
||||
rs->P.experience = pstats.s_exp;
|
||||
rs->P.dungeonlevel = level;
|
||||
fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level);
|
||||
//fprintf(stderr,"%ld gold.%d hp.%d strength.%d level.%d exp.%d %d\n",ftell(savef),purse,max_hp,max_stats.s_str,pstats.s_lvl,pstats.s_exp,level);
|
||||
}
|
||||
fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch);
|
||||
//fprintf(stderr,"object (%s) x.%d y.%d type.%d pack.(%c:%d)\n",inv_name(o,FALSE),o->_o._o_pos.x,o->_o._o_pos.y,o->_o._o_type,o->_o._o_packch,o->_o._o_packch);
|
||||
if ( rs->P.packsize < MAXPACK && o->o_type != AMULET )
|
||||
{
|
||||
packsave(item,o->_o._o_type,o->_o._o_launch,o->_o._o_damage,sizeof(o->_o._o_damage),o->_o._o_hurldmg,sizeof(o->_o._o_hurldmg),o->_o._o_count,o->_o._o_which,o->_o._o_hplus,o->_o._o_dplus,o->_o._o_arm,o->_o._o_flags,o->_o._o_group);
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <curses.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
//#include <curses.h>
|
||||
//#include <string.h>
|
||||
//#include <ctype.h>
|
||||
#include "rogue.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <curses.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
//#include <curses.h>
|
||||
//#include <string.h>
|
||||
//#include <ctype.h>
|
||||
#include "rogue.h"
|
||||
|
||||
/*
|
||||
@@ -498,55 +498,62 @@ add_line(struct rogue_state *rs,char *fmt, char *arg)
|
||||
if (line_cnt >= LINES - 1 || fmt == NULL)
|
||||
{
|
||||
if (inv_type == INV_OVER && fmt == NULL && !newpage)
|
||||
{
|
||||
msg(rs,"");
|
||||
{
|
||||
msg(rs,"");
|
||||
if ( rs->sleeptime != 0 )
|
||||
refresh();
|
||||
tw = newwin(line_cnt + 1, maxlen + 2, 0, COLS - maxlen - 3);
|
||||
sw = subwin(tw, line_cnt + 1, maxlen + 1, 0, COLS - maxlen - 2);
|
||||
for (y = 0; y <= line_cnt; y++)
|
||||
{
|
||||
wmove(sw, y, 0);
|
||||
for (x = 0; x <= maxlen; x++)
|
||||
waddch(sw, mvwinch(hw, y, x));
|
||||
}
|
||||
wmove(tw, line_cnt, 1);
|
||||
waddstr(tw, prompt);
|
||||
/*
|
||||
* if there are lines below, use 'em
|
||||
*/
|
||||
if (LINES > NUMLINES)
|
||||
{
|
||||
if (NUMLINES + line_cnt > LINES)
|
||||
mvwin(tw, LINES - (line_cnt + 1), COLS - maxlen - 3);
|
||||
else
|
||||
mvwin(tw, NUMLINES, 0);
|
||||
}
|
||||
touchwin(tw);
|
||||
wrefresh(tw);
|
||||
wait_for(rs,' ');
|
||||
if ( rs->guiflag != 0 )
|
||||
{
|
||||
tw = newwin(line_cnt + 1, maxlen + 2, 0, COLS - maxlen - 3);
|
||||
sw = subwin(tw, line_cnt + 1, maxlen + 1, 0, COLS - maxlen - 2);
|
||||
for (y = 0; y <= line_cnt; y++)
|
||||
{
|
||||
wmove(sw, y, 0);
|
||||
for (x = 0; x <= maxlen; x++)
|
||||
waddch(sw, mvwinch(hw, y, x));
|
||||
}
|
||||
wmove(tw, line_cnt, 1);
|
||||
waddstr(tw, prompt);
|
||||
/*
|
||||
* if there are lines below, use 'em
|
||||
*/
|
||||
if (LINES > NUMLINES)
|
||||
{
|
||||
if (NUMLINES + line_cnt > LINES)
|
||||
mvwin(tw, LINES - (line_cnt + 1), COLS - maxlen - 3);
|
||||
else
|
||||
mvwin(tw, NUMLINES, 0);
|
||||
}
|
||||
touchwin(tw);
|
||||
wrefresh(tw);
|
||||
wait_for(rs,' ');
|
||||
if (md_hasclreol())
|
||||
{
|
||||
werase(tw);
|
||||
leaveok(tw, TRUE);
|
||||
wrefresh(tw);
|
||||
}
|
||||
delwin(tw);
|
||||
touchwin(stdscr);
|
||||
{
|
||||
werase(tw);
|
||||
leaveok(tw, TRUE);
|
||||
wrefresh(tw);
|
||||
}
|
||||
delwin(tw);
|
||||
touchwin(stdscr);
|
||||
}
|
||||
else
|
||||
{
|
||||
wait_for(rs,' ');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wmove(hw, LINES - 1, 0);
|
||||
waddstr(hw, prompt);
|
||||
wrefresh(hw);
|
||||
wait_for(rs,' ');
|
||||
clearok(curscr, TRUE);
|
||||
wclear(hw);
|
||||
touchwin(stdscr);
|
||||
}
|
||||
newpage = TRUE;
|
||||
line_cnt = 0;
|
||||
maxlen = (int) strlen(prompt);
|
||||
wmove(hw, LINES - 1, 0);
|
||||
waddstr(hw, prompt);
|
||||
wrefresh(hw);
|
||||
wait_for(rs,' ');
|
||||
clearok(curscr, TRUE);
|
||||
wclear(hw);
|
||||
touchwin(stdscr);
|
||||
}
|
||||
newpage = TRUE;
|
||||
line_cnt = 0;
|
||||
maxlen = (int) strlen(prompt);
|
||||
}
|
||||
if (fmt != NULL && !(line_cnt == 0 && *fmt == '\0'))
|
||||
{
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <curses.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
//#include <curses.h>
|
||||
//#include <string.h>
|
||||
//#include <ctype.h>
|
||||
#include "rogue.h"
|
||||
|
||||
#define NO_WEAPON -1
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
* See the file LICENSE.TXT for full copyright and licensing information.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <curses.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <curses.h>
|
||||
//#include <string.h>
|
||||
//#include <ctype.h>
|
||||
#include "rogue.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -22,7 +22,24 @@
|
||||
#define ROGUE_MAXPLAYERS 64 // need to send unused fees back to globalCC address to prevent leeching
|
||||
#define ROGUE_MAXKEYSTROKESGAP 60
|
||||
#define ROGUE_MAXITERATIONS 777
|
||||
std::string Rogue_pname = "fred";
|
||||
|
||||
#define MAXPACK 23
|
||||
struct rogue_packitem
|
||||
{
|
||||
int32_t type,launch,count,which,hplus,dplus,arm,flags,group;
|
||||
char damage[8],hurldmg[8];
|
||||
};
|
||||
struct rogue_player
|
||||
{
|
||||
int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad;
|
||||
struct rogue_packitem roguepack[MAXPACK];
|
||||
};
|
||||
int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player,int32_t sleepmillis);
|
||||
#define ROGUE_DECLARED_PACK
|
||||
void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item);
|
||||
|
||||
|
||||
std::string Rogue_pname = "";
|
||||
|
||||
/*
|
||||
Roguelander - using highlander competition between rogue players
|
||||
@@ -133,20 +150,6 @@ std::string Rogue_pname = "fred";
|
||||
// ./c cclib bailout 17 \"[%226d3243c6e5ab383898b28a87e01f6c00b5bdd9687020f17f5caacc8a61febd19%22]\"
|
||||
// ./komodo-cli -ac_name=ROGUE cclib register 17 \"[%22a898f4ceef7647ba113b9f3c24ef045f5d134935a3b09bdd1a997b9d474f4c1b%22,%22f11d0cb4e2e4c21f029a1146f8e5926f11456885b7ab7d665096f5efedec8ea0%22]\"
|
||||
|
||||
#define MAXPACK 23
|
||||
struct rogue_packitem
|
||||
{
|
||||
int32_t type,launch,count,which,hplus,dplus,arm,flags,group;
|
||||
char damage[8],hurldmg[8];
|
||||
};
|
||||
struct rogue_player
|
||||
{
|
||||
int32_t gold,hitpoints,strength,level,experience,packsize,dungeonlevel,pad;
|
||||
struct rogue_packitem roguepack[MAXPACK];
|
||||
};
|
||||
int32_t rogue_replay2(uint8_t *newdata,uint64_t seed,char *keystrokes,int32_t num,struct rogue_player *player);
|
||||
#define ROGUE_DECLARED_PACK
|
||||
void rogue_packitemstr(char *packitemstr,struct rogue_packitem *item);
|
||||
|
||||
CScript rogue_newgameopret(int64_t buyin,int32_t maxplayers)
|
||||
{
|
||||
@@ -400,7 +403,7 @@ UniValue rogue_playerobj(std::vector<uint8_t> playerdata,uint256 playertxid,uint
|
||||
obj.push_back(Pair("experience",(int64_t)P.experience));
|
||||
obj.push_back(Pair("dungeonlevel",(int64_t)P.dungeonlevel));
|
||||
obj.push_back(Pair("chain",symbol));
|
||||
obj.push_back(Pair("name",pname));
|
||||
obj.push_back(Pair("pname",pname));
|
||||
return(obj);
|
||||
}
|
||||
|
||||
@@ -823,6 +826,83 @@ UniValue rogue_keystrokes(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
|
||||
} else return(cclib_error(result,"couldnt reparse params"));
|
||||
}
|
||||
|
||||
UniValue rogue_extract(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
||||
{
|
||||
UniValue result; CPubKey pk,roguepk; int32_t i,n,num,maxplayers,gameheight,batonht,batonvout,numplayers,regslot,numkeys,err; std::string symbol,pname; CTransaction gametx; uint64_t seed,mult; int64_t buyin,batonvalue; char rogueaddr[64],fname[64],*pubstr,*keystrokes = 0; std::vector<uint8_t> playerdata,newdata; uint256 batontxid,playertxid,gametxid; FILE *fp; uint8_t player[10000],pub33[33];
|
||||
pk = pubkey2pk(Mypubkey());
|
||||
roguepk = GetUnspendable(cp,0);
|
||||
result.push_back(Pair("status","success"));
|
||||
result.push_back(Pair("name","rogue"));
|
||||
result.push_back(Pair("method","extract"));
|
||||
if ( (params= cclib_reparse(&n,params)) != 0 )
|
||||
{
|
||||
if ( n > 0 )
|
||||
{
|
||||
gametxid = juint256(jitem(params,0));
|
||||
result.push_back(Pair("gametxid",gametxid.GetHex()));
|
||||
if ( n == 2 )
|
||||
{
|
||||
if ( (pubstr= jstr(jitem(params,1),0)) != 0 && strlen(pubstr) == 66 )
|
||||
{
|
||||
decode_hex(pub33,33,pubstr);
|
||||
pk = buf2pk(pub33);
|
||||
}
|
||||
fprintf(stderr,"gametxid.%s %s\n",gametxid.GetHex().c_str(),pubstr);
|
||||
}
|
||||
GetCCaddress1of2(cp,rogueaddr,roguepk,pk);
|
||||
result.push_back(Pair("rogueaddr",rogueaddr));
|
||||
if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 )
|
||||
{
|
||||
if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,rogueaddr,numplayers,symbol,pname) == 0 )
|
||||
{
|
||||
UniValue obj; struct rogue_player P;
|
||||
seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,rogueaddr);
|
||||
fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size());
|
||||
memset(&P,0,sizeof(P));
|
||||
if ( playerdata.size() > 0 )
|
||||
{
|
||||
for (i=0; i<playerdata.size(); i++)
|
||||
((uint8_t *)&P)[i] = playerdata[i];
|
||||
}
|
||||
if ( keystrokes != 0 )
|
||||
{
|
||||
sprintf(fname,"rogue.%llu.0",(long long)seed);
|
||||
if ( (fp= fopen(fname,"wb")) != 0 )
|
||||
{
|
||||
if ( fwrite(keystrokes,1,numkeys,fp) != numkeys )
|
||||
fprintf(stderr,"error writing %s\n",fname);
|
||||
fclose(fp);
|
||||
}
|
||||
sprintf(fname,"rogue.%llu.player",(long long)seed);
|
||||
if ( (fp= fopen(fname,"wb")) != 0 )
|
||||
{
|
||||
if ( fwrite(&playerdata[0],1,(int32_t)playerdata.size(),fp) != playerdata.size() )
|
||||
fprintf(stderr,"error writing %s\n",fname);
|
||||
fclose(fp);
|
||||
}
|
||||
num = rogue_replay2(player,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,50);
|
||||
newdata.resize(num);
|
||||
for (i=0; i<num; i++)
|
||||
{
|
||||
newdata[i] = player[i];
|
||||
((uint8_t *)&P)[i] = player[i];
|
||||
}
|
||||
if ( P.gold <= 0 || P.hitpoints <= 0 || P.strength <= 0 || P.level <= 0 || P.experience <= 0 || P.dungeonlevel <= 0 )
|
||||
{
|
||||
fprintf(stderr,"zero value character was killed -> no playerdata\n");
|
||||
newdata.resize(0);
|
||||
}
|
||||
fprintf(stderr,"\nextracted $$$gold.%d hp.%d strength.%d level.%d exp.%d dl.%d n.%d size.%d\n",P.gold,P.hitpoints,P.strength,P.level,P.experience,P.dungeonlevel,n,(int32_t)sizeof(P));
|
||||
if ( keystrokes != 0 )
|
||||
free(keystrokes);
|
||||
} else num = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params,char *method)
|
||||
{
|
||||
//vin0 -> highlander vout from creategame TCBOO
|
||||
@@ -866,15 +946,11 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
|
||||
result.push_back(Pair("gametxid",gametxid.GetHex()));
|
||||
if ( (err= rogue_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid)) == 0 )
|
||||
{
|
||||
if ( maxplayers == 1 )
|
||||
mult /= 2;
|
||||
if ( rogue_findbaton(cp,playertxid,&keystrokes,numkeys,regslot,playerdata,batontxid,batonvout,batonvalue,batonht,gametxid,gametx,maxplayers,myrogueaddr,numplayers,symbol,pname) == 0 )
|
||||
{
|
||||
UniValue obj; struct rogue_player P;
|
||||
if ( pname.size() == 0 )
|
||||
pname = Rogue_pname;
|
||||
seed = rogue_gamefields(obj,maxplayers,buyin,gametxid,myrogueaddr);
|
||||
fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size());
|
||||
fprintf(stderr,"(%s) found baton %s numkeys.%d seed.%llu playerdata.%d\n",pname.size()!=0?pname.c_str():Rogue_pname.c_str(),batontxid.ToString().c_str(),numkeys,(long long)seed,(int32_t)playerdata.size());
|
||||
memset(&P,0,sizeof(P));
|
||||
if ( playerdata.size() > 0 )
|
||||
{
|
||||
@@ -883,7 +959,7 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
|
||||
}
|
||||
if ( keystrokes != 0 )
|
||||
{
|
||||
num = rogue_replay2(player,seed,keystrokes,numkeys,playerdata.size()==0?0:&P);
|
||||
num = rogue_replay2(player,seed,keystrokes,numkeys,playerdata.size()==0?0:&P,0);
|
||||
if ( keystrokes != 0 )
|
||||
free(keystrokes);
|
||||
} else num = 0;
|
||||
@@ -906,6 +982,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( maxplayers == 1 )
|
||||
mult /= 2;
|
||||
cpTokens = CCinit(&tokensC, EVAL_TOKENS);
|
||||
mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS, txfee, GetUnspendable(cpTokens,NULL))); // marker to token cc addr, burnable and validated
|
||||
mtx.vout.push_back(MakeTokensCC1vout(cp->evalcode,1,mypk));
|
||||
@@ -930,6 +1008,8 @@ UniValue rogue_finishgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
|
||||
Myprivkey(mypriv);
|
||||
CCaddr1of2set(cp,roguepk,mypk,mypriv,myrogueaddr);
|
||||
CScript opret;
|
||||
if ( pname.size() == 0 )
|
||||
pname = Rogue_pname;
|
||||
if ( newdata.size() == 0 )
|
||||
{
|
||||
opret = rogue_highlanderopret(funcid, gametxid, regslot, mypk, nodata,pname);
|
||||
@@ -1025,7 +1105,7 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
||||
result.push_back(Pair("result","success"));
|
||||
rogue_univalue(result,"pending",-1,-1);
|
||||
result.push_back(Pair("pending",a));
|
||||
result.push_back(Pair("numpending",a.size()));
|
||||
result.push_back(Pair("numpending",(int64_t)a.size()));
|
||||
return(result);
|
||||
}
|
||||
|
||||
@@ -1052,7 +1132,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
||||
}
|
||||
}
|
||||
result.push_back(Pair("playerdata",a));
|
||||
result.push_back(Pair("numplayerdata",a.size()));
|
||||
result.push_back(Pair("numplayerdata",(int64_t)a.size()));
|
||||
return(result);
|
||||
}
|
||||
|
||||
@@ -1091,7 +1171,7 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
||||
}
|
||||
result.push_back(Pair("pastgames",b));
|
||||
result.push_back(Pair("games",a));
|
||||
result.push_back(Pair("numgames",a.size()+b.size()));
|
||||
result.push_back(Pair("numgames",(int64_t)(a.size()+b.size())));
|
||||
return(result);
|
||||
}
|
||||
|
||||
@@ -1106,7 +1186,7 @@ UniValue rogue_setname(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
||||
if ( (namestr= jstri(params,0)) != 0 )
|
||||
{
|
||||
result.push_back(Pair("result","success"));
|
||||
result.push_back(Pair("name",namestr));
|
||||
result.push_back(Pair("pname",namestr));
|
||||
Rogue_pname = namestr;
|
||||
return(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user