From a76a5dd2653f46b6edef00fb75f67e7b211b6ff6 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 9 Aug 2019 23:39:36 +0200 Subject: [PATCH] further cleanup --- basegraph.cpp | 2 +- control.cpp | 8 +++-- debug.cpp | 3 +- game.cpp | 2 +- graph.cpp | 8 ++--- help.cpp | 2 +- hud.cpp | 2 +- hyper.h | 97 --------------------------------------------------- hypgraph.cpp | 20 ++++++----- init.cpp | 2 +- landlock.cpp | 6 ++-- mapeditor.cpp | 6 ++-- 12 files changed, 33 insertions(+), 125 deletions(-) diff --git a/basegraph.cpp b/basegraph.cpp index 54371e58..d75df159 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -128,7 +128,7 @@ int textwidth(int siz, const string &str) { } #endif -int darkenedby(int c, int lev) { +EX int darkenedby(int c, int lev) { for(int i=0; i> 1); return c; diff --git a/control.cpp b/control.cpp index 8da06489..17ccbed3 100644 --- a/control.cpp +++ b/control.cpp @@ -13,15 +13,19 @@ EX bool leftclick, rightclick, targetclick, hiliteclick, anyshiftclick, wheelcli EX bool forcetarget, lshiftclick, lctrlclick, numlock_on; EX bool gtouched; -bool holdmouse; +EX bool holdmouse; EX int getcstat, lgetcstat; -ld getcshift; +EX ld getcshift; EX bool inslider; EX function keyhandler = [] (int sym, int uni) {}; EX function joyhandler = [] (SDL_Event &ev) {return false;}; +#if HDR +// what part of the compass does 'skip turn' +static const auto SKIPFAC = .4; +#endif // is the player using mouse? (used for auto-cross) EX bool mousing = true; diff --git a/debug.cpp b/debug.cpp index 19ce0547..6e28186f 100644 --- a/debug.cpp +++ b/debug.cpp @@ -86,7 +86,7 @@ eItem randomTreasure2(int cv) { return best; } -eLand cheatdest; +EX eLand cheatdest; void cheatMoveTo(eLand l) { cheatdest = l; @@ -212,7 +212,6 @@ bool applyCheat(char u, cell *c = NULL) { cwt++; mirror::act(1, mirror::SPINSINGLE); - wavephase = (1+wavephase) & 7; if(shmup::on) shmup::pc[0]->at = Id; return true; } diff --git a/game.cpp b/game.cpp index 1375b9a8..1e34bfbc 100644 --- a/game.cpp +++ b/game.cpp @@ -6489,7 +6489,7 @@ EX void placeItems(int qty, eItem it) { } } -cellwalker recallCell; +EX cellwalker recallCell; EX bool activateRecall() { if(!recallCell.at) { diff --git a/graph.cpp b/graph.cpp index ebacba85..ebf18e10 100644 --- a/graph.cpp +++ b/graph.cpp @@ -2365,7 +2365,7 @@ bool chainAnimation(cell *c, transmatrix& V, cell *c2, int i, ld bonus, const tr // based on cell c and transmatrix V // do change the zoom factor? do change the priorities? -int cellcolor(cell *c) { +EX int cellcolor(cell *c) { if(isPlayerOn(c) || isFriendly(c)) return OUTLINE_FRIEND; if(noHighlight(c->monst)) return OUTLINE_NONE; if(c->monst) return OUTLINE_ENEMY; @@ -3886,8 +3886,6 @@ EX bool use_swapped_duals() { return (masterless && !a4) || GOLDBERG; } -int wavephase; - #if CAP_SHAPES void floorShadow(cell *c, const transmatrix& V, color_t col) { if(model_needs_depth() || noshadow) @@ -3993,7 +3991,7 @@ bool openorsafe(cell *c) { #define Dark(x) darkena(x,0,0xFF) -color_t stdgridcolor = 0x202020FF; +EX color_t stdgridcolor = 0x202020FF; int gridcolor(cell *c1, cell *c2) { if(cmode & sm::DRAW) return Dark(forecolor); @@ -7241,8 +7239,6 @@ EX void drawthemap() { noclipped = 0; first_cell_to_draw = true; - wavephase = (-(ticks / 100)) & 7; - if(sightrange_bonus > 0 && !allowIncreasedSight()) sightrange_bonus = 0; diff --git a/help.cpp b/help.cpp index 0a5c2907..9d2a57c5 100644 --- a/help.cpp +++ b/help.cpp @@ -280,7 +280,7 @@ string forbidden_unmarked() { return XLAT("When the 'mark heptagons' option (hotkey '7') is on, moves between unmarked cells are forbidden."); } -string generateHelpForItem(eItem it) { +EX string generateHelpForItem(eItem it) { string help = helptitle(XLATN(iinf[it].name), iinf[it].color); diff --git a/hud.cpp b/hud.cpp index 3080fc1e..755840ca 100644 --- a/hud.cpp +++ b/hud.cpp @@ -185,7 +185,7 @@ int glyphflags(int gid) { return f; } -bool graphglyph() { +EX bool graphglyph() { // if(DIM == 3) return false; return vid.graphglyph == 2 || (vid.graphglyph == 1 && vid.monmode); } diff --git a/hyper.h b/hyper.h index 326ea4e8..78a1f7ba 100644 --- a/hyper.h +++ b/hyper.h @@ -1455,39 +1455,14 @@ namespace mapeditor { inline string pick123() { return cts('1' + rand() % 3); } inline string pick12() { return cts('1' + rand() % 2); } -extern int lowfar; -extern int maxreclevel, reclevel; - extern int detaillevel; extern bool quitmainloop; enum eGravity { gsNormal, gsLevitation, gsAnti }; extern eGravity gravity_state, last_gravity_state; -int gravityLevel(cell *c); -int gravityLevelDiff(cell *c, cell *f); -void fullcenter(); -void movecost(cell* from, cell *to, int phase); // 1 = pre-collect, 2 = post-collect, 3 = both -void checkmove(); - -transmatrix eumove(ld x, ld y); -transmatrix eumove(int vec); -transmatrix eumovedir(int d); - -int reptilemax(); - -extern bool mousing; #define IFM(x) (mousing?"":x) -extern cellwalker recallCell; - -extern eLand cheatdest; -void cheatMoveTo(eLand l); - -void doOvergenerate(); - -void collectMessage(cell *c2, eItem which); - namespace quotientspace { void build(); void clear(); @@ -1717,10 +1692,6 @@ namespace linepatterns { static const int DISTANCE_UNKNOWN = 127; -transmatrix atscreenpos(ld x, ld y, ld size); - -hyperpoint mirrorif(const hyperpoint& V, bool b); - #define SETMOUSEKEY 5000 extern char mousekey; extern char newmousekey; @@ -1728,14 +1699,6 @@ void displaymm(char c, int x, int y, int rad, int size, const string& title, int template T pick(T x, U... u) { std::initializer_list i = {x,u...}; return *(i.begin() + hrand(1+sizeof...(u))); } -int darkenedby(int c, int lev); -extern ld mouseaim_sensitivity; -string generateHelpForItem(eItem it); -bool graphglyph(); -extern bool hiliteclick; -extern int antialiaslines; -extern color_t ringcolor, periodcolor, modelcolor, stdgridcolor; - #include template int addHook(hookset*& m, int prio, const U& hook) { @@ -1840,8 +1803,6 @@ namespace windmap { } #endif -extern int wavephase; - int getgametime(); string getgametime_s(int timespent = getgametime()); extern int stampbase; @@ -2206,68 +2167,10 @@ struct land_validity_t { string msg; }; -extern vector landlist; -template void generateLandList(T t); -land_validity_t& land_validity(eLand l); -bool isLandIngame(eLand l); - -bool inmirrororwall(eLand l); -extern bool holdmouse; - -// what part of the compass does 'skip turn' -static const auto SKIPFAC = .4; - -bool haveMobileCompass(); -bool handleCompass(); - -inline bool sphereflipped() { return sphere && vid.alpha > 1.1 && DIM == 3; } -int cellcolor(cell *c); -extern ld backbrightness; - -void initcells(); extern const hyperpoint C02, C03; #define C0 (DIM == 2 ? C02 : C03) -extern long long circlesize[100], disksize[100]; -extern ld circlesizeD[10000]; -void computeSizes(); - -#if CAP_FILES -extern const char *scorefile; -extern const char *conffile; -extern string levelfile; -extern string picfile; -extern const char *musicfile; -extern const char *loadlevel; -#endif - -extern bool fixseed; -extern eLand firstland0; -extern int startseed; - -// heptspin hsstep(const heptspin &hs, int spin); - -ld hdist0(const hyperpoint& mh); - -extern bool fading; -extern ld fadeout; -int itemclass(eItem i); -int monsterclass(eMonster m); - -extern purehookset hooks_drawmap; -extern hookset *hooks_music; -extern hookset *hooks_prestats; -extern purehookset hooks_fixticks; - -void sdltogl(SDL_Surface *txt, struct glfont_t& f, int ch); - -void showStartMenu(); - -bool polara50(int x); -bool polara50(cell *c); -int fiftyval049(cell *c); - namespace fieldpattern { pair fieldval(cell *c); } diff --git a/hypgraph.cpp b/hypgraph.cpp index c571cf68..aef641a8 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -6,6 +6,10 @@ namespace hr { ld ghx, ghy, ghgx, ghgy; hyperpoint ghpm = C0; +#if HDR +inline bool sphereflipped() { return sphere && vid.alpha > 1.1 && DIM == 3; } +#endif + void ghcheck(hyperpoint &ret, const hyperpoint &H) { if(hypot(ret[0]-ghx, ret[1]-ghy) < hypot(ghgx-ghx, ghgy-ghy)) { ghpm = H; ghgx = ret[0]; ghgy = ret[1]; @@ -780,12 +784,12 @@ EX bool outofmap(hyperpoint h) { return h[2] < .5; } -hyperpoint mirrorif(const hyperpoint& V, bool b) { +EX hyperpoint mirrorif(const hyperpoint& V, bool b) { if(b) return Mirror*V; else return V; } -transmatrix mirrorif(const transmatrix& V, bool b) { +EX transmatrix mirrorif(const transmatrix& V, bool b) { if(b) return V*Mirror; else return V; } @@ -1120,7 +1124,7 @@ void hrmap_standard::draw() { int mindx=-7, mindy=-7, maxdx=7, maxdy=7; -transmatrix eumove(ld x, ld y) { +EX transmatrix eumove(ld x, ld y) { transmatrix Mat = Id; Mat[DIM][DIM] = 1; @@ -1144,13 +1148,13 @@ transmatrix eumove(ld x, ld y) { return Mat; } -transmatrix eumove(int vec) { +EX transmatrix eumove(int vec) { int x, y; tie(x,y) = vec_to_pair(vec); return eumove(x, y); } -transmatrix eumovedir(int d) { +EX transmatrix eumovedir(int d) { if(a4) { d = d & 3; switch(d) { @@ -1474,9 +1478,9 @@ void circle_around_center(ld radius, color_t linecol, color_t fillcol, PPR prio) #endif } -color_t periodcolor = 0x00FF0080; -color_t ringcolor = darkena(0xFF, 0, 0xFF); -color_t modelcolor = 0; +EX color_t periodcolor = 0x00FF0080; +EX color_t ringcolor = darkena(0xFF, 0, 0xFF); +EX color_t modelcolor = 0; #if CAP_QUEUE EX void draw_model_elements() { diff --git a/init.cpp b/init.cpp index e7bae558..091eb831 100644 --- a/init.cpp +++ b/init.cpp @@ -15,7 +15,7 @@ EX string s0; EX bool fixseed = false; EX int startseed = 0; -eLand firstland0; +EX eLand firstland0; EX void initAll() { init_floorcolors(); diff --git a/landlock.cpp b/landlock.cpp index 5fe01999..5f491667 100644 --- a/landlock.cpp +++ b/landlock.cpp @@ -530,7 +530,7 @@ EX eLand getNewLand(eLand old) { return n; } -vector land_over = { +EX vector land_over = { laIce, laCaves, laDesert, laHunting, laMotion, laJungle, laAlchemist, laCrossroads, laMirror, laMirrorOld, laMinefield, laPalace, laPrincessQuest, laZebra, laSwitch, laReptile, @@ -551,12 +551,14 @@ vector land_over = { laWildWest, laHalloween, laDual, laSnakeNest, laMagnetic, laCA, laAsteroids }; -vector landlist; +EX vector landlist; +#if HDR template void generateLandList(T t) { landlist.clear(); for(auto l: land_over) if(t(l)) landlist.push_back(l); } +#endif EX eLand getLandForList(cell *c) { eLand l = c->land; diff --git a/mapeditor.cpp b/mapeditor.cpp index 74e239eb..524124c6 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -2244,9 +2244,9 @@ namespace mapeditor { } #if CAP_EDIT -string levelfile = "hyperrogue.lev"; -const char *loadlevel = NULL; -string picfile = "hyperrogue.pic"; +EX string levelfile = "hyperrogue.lev"; +EX const char *loadlevel = NULL; +EX string picfile = "hyperrogue.pic"; #if CAP_COMMANDLINE