From 5a3114d279ca7eaee089385b372f6fc063e459b1 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 21 Apr 2018 12:17:22 +0200 Subject: [PATCH] rogueviz:: made it compile with the changes elsewhere --- hyper.h | 1 + kohonen.cpp | 38 +++++++++++++++++++------------------- rogueviz.cpp | 38 +++++++++++++++++++------------------- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/hyper.h b/hyper.h index 3af524be..c4d23f2f 100644 --- a/hyper.h +++ b/hyper.h @@ -1683,6 +1683,7 @@ namespace arg { void shift(); const string& args(); + const char* argcs(); int argi(); ld argf(); bool argis(const string& s); diff --git a/kohonen.cpp b/kohonen.cpp index 90a6774a..c1ee480f 100644 --- a/kohonen.cpp +++ b/kohonen.cpp @@ -69,8 +69,8 @@ double vnorm(kohvec& a, kohvec& b) { void sominit(int); void uninit(int); -void loadsamples(const char *fname) { - FILE *f = fopen(fname, "rt"); +void loadsamples(const string& fname) { + FILE *f = fopen(fname.c_str(), "rt"); if(!f) { fprintf(stderr, "Could not load samples\n"); return; @@ -747,9 +747,9 @@ namespace levelline { } -void ksave(const char *fname) { +void ksave(const string& fname) { sominit(1); - FILE *f = fopen(fname, "wt"); + FILE *f = fopen(fname.c_str(), "wt"); if(!f) { fprintf(stderr, "Could not save the network\n"); return; @@ -763,10 +763,10 @@ void ksave(const char *fname) { fclose(f); } -void kload(const char *fname) { +void kload(const string& fname) { sominit(1); int xcells; - FILE *f = fopen(fname, "rt"); + FILE *f = fopen(fname.c_str(), "rt"); if(!f) { fprintf(stderr, "Could not load the network\n"); return; @@ -783,9 +783,9 @@ void kload(const char *fname) { analyze(); } -void ksavew(const char *fname) { +void ksavew(const string& fname) { sominit(1); - FILE *f = fopen(fname, "wt"); + FILE *f = fopen(fname.c_str(), "wt"); if(!f) { fprintf(stderr, "Could not save the weights\n"); return; @@ -795,9 +795,9 @@ void ksavew(const char *fname) { fclose(f); } -void kloadw(const char *fname) { +void kloadw(const string& fname) { sominit(1); - FILE *f = fopen(fname, "rt"); + FILE *f = fopen(fname.c_str(), "rt"); if(!f) { fprintf(stderr, "Could not load the weights\n"); return; @@ -840,7 +840,7 @@ void progress(string s) { } } -void kclassify(const char *fname_classify) { +void kclassify(const string& fname_classify) { sominit(1); vector bdiffs(samples, 1e20); @@ -871,9 +871,9 @@ void kclassify(const char *fname_classify) { for(int s=0; s& tab, const hyperpoint& h) { - for(int i=0; i<3; i++) tab.push_back(h[i]); +void storevertex(vector& tab, const hyperpoint& h) { + tab.push_back(glhr::pointtogl(h)); } double linequality = .1; -void storelineto(vector& tab, const hyperpoint& h1, const hyperpoint& h2) { +void storelineto(vector& tab, const hyperpoint& h1, const hyperpoint& h2) { if(intval(h1, h2) < linequality) storevertex(tab, h2); else { @@ -983,7 +983,7 @@ void storelineto(vector& tab, const hyperpoint& h1, const hyperpoint& h } } -void storeline(vector& tab, const hyperpoint& h1, const hyperpoint& h2) { +void storeline(vector& tab, const hyperpoint& h1, const hyperpoint& h2) { storevertex(tab, h1); storelineto(tab, h1, h2); } @@ -1111,7 +1111,7 @@ void drawVertex(const transmatrix &V, cell *c, shmup::monster *m) { else storeline(ei->prec, T*h1, T*h2); } - queuetable(shmup::ggmatrix(ei->orig), &ei->prec[0], size(ei->prec)/3, col, 0, + queuetable(shmup::ggmatrix(ei->orig), ei->prec, size(ei->prec), col, 0, PPR_STRUCT0); } } @@ -1257,8 +1257,8 @@ void drawExtra() { } } -void readcolor(const char *cfname) { - FILE *f = fopen(cfname, "rt"); +void readcolor(const string& cfname) { + FILE *f = fopen(cfname.c_str(), "rt"); if(!f) { printf("color file missing\n"); exit(1); } while(true) { string lab = ""; @@ -1382,7 +1382,7 @@ void fixparam() { } #if CAP_SDL -void rvvideo(const char *fname) { +void rvvideo(const string &fname) { if(kind == kCollatz) { pngformat = 2; sightrange_bonus = 3; @@ -1513,7 +1513,7 @@ struct storydata { int s; int e; const char *text; } story[] = { conformal::movetophase(); char buf[500]; - snprintf(buf, 500, fname, i); + snprintf(buf, 500, fname.c_str(), i); if(i == 0) drawthemap(); shmup::turn(100); @@ -1526,7 +1526,7 @@ struct storydata { int s; int e; const char *text; } story[] = { } for(int i=0; i<1800; i++) { char buf[500]; - snprintf(buf, 500, fname, i); + snprintf(buf, 500, fname.c_str(), i); shmup::pc[0]->base = currentmap->gamestart(); shmup::pc[0]->at = spin(i * 2 * M_PI / (58*30.)) * xpush(1.7); if(i == 0) drawthemap(); @@ -1546,7 +1546,7 @@ int readArgs() { // options before reading if(0) ; else if(argis("-dftcolor")) { - shift(); dftcolor = strtol(args(), NULL, 16); + shift(); dftcolor = strtol(args().c_str(), NULL, 16); } // tree visualizer (e.g. Tree of Life) @@ -1615,7 +1615,7 @@ int readArgs() { else if(argis("-collatz")) { PHASE(3); using namespace collatz; - shift(); sscanf(args(), "%lf,%lf,%lf,%lf", &s2, &p2, &s3, &p3); + shift(); sscanf(argcs(), "%lf,%lf,%lf,%lf", &s2, &p2, &s3, &p3); start(); } @@ -1623,7 +1623,7 @@ int readArgs() { PHASE(3); ld mul = 2; int N = 1000; - shift(); sscanf(args(), LDF ",%d", &mul, &N); + shift(); sscanf(argcs(), LDF ",%d", &mul, &N); spiral::place(N, mul); } @@ -1638,7 +1638,7 @@ int readArgs() { PHASE(3); ld shft = 1; ld mul = 1; - shift(); sscanf(args(), LDF "," LDF, &shft, &mul); + shift(); sscanf(argcs(), LDF "," LDF, &shft, &mul); spiral::edge(shft, mul); } @@ -1646,7 +1646,7 @@ int readArgs() { PHASE(3); ld period = 1; ld start = 1; - shift(); sscanf(args(), LDF "," LDF, &period, &start); + shift(); sscanf(argcs(), LDF "," LDF, &period, &start); start--; shift(); spiral::color(start, period, parse(args()));