mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-07-20 09:52:50 +00:00
more fixes to Emscripten CLI
This commit is contained in:
parent
15dcbc188a
commit
bb5ac04875
@ -86,7 +86,7 @@ int arg::readCommon() {
|
|||||||
else if(argis("-pattern")) {
|
else if(argis("-pattern")) {
|
||||||
PHASE(3);
|
PHASE(3);
|
||||||
shift();
|
shift();
|
||||||
char *c = args();
|
const char *c = args();
|
||||||
using namespace patterns;
|
using namespace patterns;
|
||||||
subpattern_flags = 0;
|
subpattern_flags = 0;
|
||||||
whichPattern = 0;
|
whichPattern = 0;
|
||||||
@ -523,7 +523,7 @@ purehookset hooks_config;
|
|||||||
hookset<int()> *hooks_args;
|
hookset<int()> *hooks_args;
|
||||||
|
|
||||||
namespace arg {
|
namespace arg {
|
||||||
int argc; char **argv;
|
int argc; const char **argv;
|
||||||
int curphase;
|
int curphase;
|
||||||
|
|
||||||
auto ah = addHook(hooks_args, 0, readCommon);
|
auto ah = addHook(hooks_args, 0, readCommon);
|
||||||
|
@ -40,10 +40,10 @@ void moreStack() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hookset<bool(int argc, char** argv)> *hooks_main;
|
hookset<bool(int argc, const char** argv)> *hooks_main;
|
||||||
|
|
||||||
#ifndef NOMAIN
|
#ifndef NOMAIN
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, const char **argv) {
|
||||||
#if ISWEB
|
#if ISWEB
|
||||||
emscripten_get_commandline(argc, argv);
|
emscripten_get_commandline(argc, argv);
|
||||||
#endif
|
#endif
|
||||||
|
8
hyper.h
8
hyper.h
@ -1506,7 +1506,7 @@ extern int cshpos;
|
|||||||
|
|
||||||
namespace arg {
|
namespace arg {
|
||||||
#if CAP_COMMANDLINE
|
#if CAP_COMMANDLINE
|
||||||
extern int argc; extern char **argv;
|
extern int argc; extern const char **argv;
|
||||||
|
|
||||||
inline void lshift() {
|
inline void lshift() {
|
||||||
argc--; argv++;
|
argc--; argv++;
|
||||||
@ -1516,12 +1516,12 @@ namespace arg {
|
|||||||
lshift(); if(!argc) { printf("Missing parameter\n"); exit(1); }
|
lshift(); if(!argc) { printf("Missing parameter\n"); exit(1); }
|
||||||
}
|
}
|
||||||
|
|
||||||
inline char* args() { return *argv; }
|
inline const char* args() { return *argv; }
|
||||||
inline int argi() { return atoi(*argv); }
|
inline int argi() { return atoi(*argv); }
|
||||||
inline ld argf() { return atof(*argv); }
|
inline ld argf() { return atof(*argv); }
|
||||||
inline bool argis(const char *s) { return strcmp(*argv, s) == 0; }
|
inline bool argis(const char *s) { return strcmp(*argv, s) == 0; }
|
||||||
|
|
||||||
inline void init(int _argc, char **_argv) { argc=_argc-1; argv=_argv+1; }
|
inline void init(int _argc, const char **_argv) { argc=_argc-1; argv=_argv+1; }
|
||||||
|
|
||||||
extern int curphase;
|
extern int curphase;
|
||||||
|
|
||||||
@ -1761,7 +1761,7 @@ template<class T, class V, class... U> V callhandlers(V zero, hookset<T> *h, U&.
|
|||||||
|
|
||||||
extern hookset<bool(int sym, int uni)> *hooks_handleKey;
|
extern hookset<bool(int sym, int uni)> *hooks_handleKey;
|
||||||
extern hookset<void(cell *c, const transmatrix& V)> *hooks_drawcell;
|
extern hookset<void(cell *c, const transmatrix& V)> *hooks_drawcell;
|
||||||
extern hookset<bool(int argc, char** argv)> *hooks_main;
|
extern hookset<bool(int argc, const char** argv)> *hooks_main;
|
||||||
extern hookset<int()> *hooks_args;
|
extern hookset<int()> *hooks_args;
|
||||||
extern hookset<eLand(eLand)> *hooks_nextland;
|
extern hookset<eLand(eLand)> *hooks_nextland;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ template<class A, class B, class C> void emscripten_set_main_loop(A a, B b, C c)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void initweb();
|
void initweb();
|
||||||
void emscripten_get_commandline(int argc, char ** argv);
|
void emscripten_get_commandline(int& argc, const char **& argv);
|
||||||
|
|
||||||
void loadCompressedChar(int &otwidth, int &otheight, int *tpix);
|
void loadCompressedChar(int &otwidth, int &otheight, int *tpix);
|
||||||
|
|
||||||
@ -153,10 +153,9 @@ transmatrix getOrientation() {
|
|||||||
vector<string> emscripten_args;
|
vector<string> emscripten_args;
|
||||||
vector<const char*> emscripten_args_c;
|
vector<const char*> emscripten_args_c;
|
||||||
|
|
||||||
void emscripten_get_commandline(int argc, const char ** argv) {
|
void emscripten_get_commandline(int& argc, const char **& argv) {
|
||||||
char *str = (char*)EM_ASM_INT({
|
char *str = (char*)EM_ASM_INT({
|
||||||
var jsString = document.location.href;
|
var jsString = document.location.href;
|
||||||
alert(jsString);
|
|
||||||
var lengthBytes = lengthBytesUTF8(jsString)+1;
|
var lengthBytes = lengthBytesUTF8(jsString)+1;
|
||||||
var stringOnWasmHeap = _malloc(lengthBytes);
|
var stringOnWasmHeap = _malloc(lengthBytes);
|
||||||
stringToUTF8(jsString, stringOnWasmHeap, lengthBytes+1);
|
stringToUTF8(jsString, stringOnWasmHeap, lengthBytes+1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user