From 00c9238bd6d293ce443bf00836c03521ae365d9b Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 29 Oct 2017 12:46:57 +0100 Subject: [PATCH] more rearrangement --- achievement.cpp | 2 +- cell.cpp | 20 ----------- classes.h | 2 ++ dialogs.cpp | 2 ++ game.cpp | 3 ++ heptagon.cpp | 8 ----- hyper.cpp | 17 +-------- hyper.h | 94 ++++++++++++++++++++++++++++++++++++++++++++----- init.cpp | 58 +++++++++++++++++++++--------- polygons.cpp | 49 -------------------------- shmup.cpp | 2 ++ 11 files changed, 139 insertions(+), 118 deletions(-) diff --git a/achievement.cpp b/achievement.cpp index bae965d3..6ffcab7a 100644 --- a/achievement.cpp +++ b/achievement.cpp @@ -77,7 +77,7 @@ void upload_score(int id, int v); string achievementMessage[3]; int achievementTimer; -// vector achievementsReceived; +vector achievementsReceived; bool wrongMode(char flags) { if(cheater) return true; diff --git a/cell.cpp b/cell.cpp index 590352b5..b169032e 100644 --- a/cell.cpp +++ b/cell.cpp @@ -15,26 +15,6 @@ int dirdiff(int dd, int t) { return dd; } -struct cell : gcell { - char type; // 6 for hexagons, 7 for heptagons - - // wall parameter, used for remaining power of Bonfires and Thumpers - char wparam; - - // 'tmp' is used for: - // pathfinding algorithm used by monsters with atypical movement (which do not use pathdist) - // bugs' pathfinding algorithm - short aitmp; - - uint32_t spintable; - int spin(int d) { return tspin(spintable, d); } - int spn(int d) { return tspin(spintable, d); } - int mirror(int d) { return tmirror(spintable, d); } - - heptagon *master; - cell *mov[MAX_EDGE]; // meaning very similar to heptagon::move - }; - int fixdir(int a, cell *c) { a %= c->type; if(a<0) a += c->type; return a; } int cellcount = 0; diff --git a/classes.h b/classes.h index 44e49c5d..d48255b1 100644 --- a/classes.h +++ b/classes.h @@ -208,3 +208,5 @@ static const int SEE_ALL = 15; static const int FORBIDDEN = -1; extern eGeometry geometry; + +extern geometryinfo ginf[gGUARD]; diff --git a/dialogs.cpp b/dialogs.cpp index a21b6d94..40740853 100644 --- a/dialogs.cpp +++ b/dialogs.cpp @@ -11,6 +11,8 @@ */ +const char* COLORBAR = "###"; + namespace dialog { namespace zoom { diff --git a/game.cpp b/game.cpp index c8887486..a263eae4 100644 --- a/game.cpp +++ b/game.cpp @@ -1072,6 +1072,9 @@ bool outlawNearby(cell *c, int dist) { // int monstersnear(cell *c, cell *nocount = NULL, eMonster who = moPlayer, cell *pushto = NULL) { namespace stalemate { + vector moves; + bool nextturn; + bool anyKilled() { for(int i=0; i> (d<<2)) & 7; - } - -int tmirror(uint32_t& t, int d) { - return (t >> ((d<<2)+3)) & 1; - } - void tsetspin(uint32_t& t, int d, int spin) { t &= ~(15 << (d<<2)); t |= spin << (d<<2); diff --git a/hyper.cpp b/hyper.cpp index fa2962dd..ce6d6864 100644 --- a/hyper.cpp +++ b/hyper.cpp @@ -15,22 +15,6 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -#ifdef MAC -#define ISMAC 1 -#endif - -#ifdef LINUX -#define ISLINUX 1 -#endif - -#ifdef WINDOWS -#define ISWINDOWS 1 -#endif - -#if ISSTEAM -#define NOLICENSE -#endif - #include "init.cpp" #if ISLINUX @@ -473,6 +457,7 @@ hookset *hooks_args; namespace arg { int argc; char **argv; + int curphase; auto ah = addHook(hooks_args, 0, readCommon); diff --git a/hyper.h b/hyper.h index ba588b19..f76b449b 100644 --- a/hyper.h +++ b/hyper.h @@ -94,8 +94,32 @@ struct gcell { #define NOBARRIERS 9 struct heptagon; + struct heptspin; -struct cell; + +inline int tspin(uint32_t& t, int d) { return (t >> (d<<2)) & 7; } +inline int tmirror(uint32_t& t, int d) { return (t >> ((d<<2)+3)) & 1; } + +struct cell : gcell { + char type; // 6 for hexagons, 7 for heptagons + + // wall parameter, used for remaining power of Bonfires and Thumpers + char wparam; + + // 'tmp' is used for: + // pathfinding algorithm used by monsters with atypical movement (which do not use pathdist) + // bugs' pathfinding algorithm + short aitmp; + + uint32_t spintable; + int spin(int d) { return tspin(spintable, d); } + int spn(int d) { return tspin(spintable, d); } + int mirror(int d) { return tmirror(spintable, d); } + + heptagon *master; + cell *mov[MAX_EDGE]; // meaning very similar to heptagon::move + }; + struct cellwalker; // automaton state @@ -129,6 +153,7 @@ enum hstate { hsOrigin, hsA, hsB, hsError, hsA0, hsA1, hsB0, hsB1, hsC }; string XLAT(string x); string cts(char c); +string its(int i); int hrand(int i); template int size(const T& x) {return int(x.size()); } @@ -172,7 +197,7 @@ void achievement_display(); void achievement_pump(); // achievements received this game -vector achievementsReceived; +extern vector achievementsReceived; // game forward declarations typedef unsigned long long flagtype; @@ -314,7 +339,7 @@ namespace multi { void loadConfig(FILE *f); void initConfig(); - charstyle scs[MAXPLAYER]; + extern charstyle scs[MAXPLAYER]; bool playerActive(int p); int activePlayers(); @@ -877,8 +902,8 @@ struct stalemate1 { }; namespace stalemate { - vector moves; - bool nextturn; + extern vector moves; + extern bool nextturn; bool isKilled(cell *c); @@ -1251,7 +1276,7 @@ namespace arg { inline void init(int _argc, char **_argv) { argc=_argc-1; argv=_argv+1; } - int curphase; + extern int curphase; inline void phaseerror(int x) { printf("Command line error: cannot read command '%s' from phase %d in phase %d\n", args(), x, curphase); @@ -1523,7 +1548,8 @@ void setAppropriateOverview(); bool quitsaves(); extern bool sidescreen; -static const char* COLORBAR = "###"; +extern const char* COLORBAR; + int textwidth(int siz, const string &str); #define GLERR(call) glError(call, __FILE__, __LINE__) @@ -1664,7 +1690,7 @@ void selectLanguageScreen(); bool inscreenrange(cell *c); bool allowIncreasedSight(); -static bool orbProtection(eItem it) { return false; } // not implemented +static inline bool orbProtection(eItem it) { return false; } // not implemented namespace windmap { void create(); @@ -1729,3 +1755,55 @@ int ctof(cell *c); void modalDebug(cell *c); int getDistLimit(); + +void drawqueue(); + +#ifndef GL +typedef float GLfloat; +#endif + +struct qpoly { + transmatrix V; + GLfloat *tab; + int curveindex; + int cnt; + int outline; + double minwidth; + }; + +struct qline { + hyperpoint H1, H2; + int prf; + double width; + }; + +#define MAXQCHR 40 + +struct qchr { + char str[MAXQCHR]; + int x, y, shift, size, frame; + int align; + }; + +struct qcir { + int x, y, size; + }; + +enum eKind { pkPoly, pkLine, pkString, pkCircle, pkShape, pkResetModel }; + +struct polytodraw { + eKind kind; + int prio, col; + union { + qpoly poly; + qline line; + qchr chr; + qcir cir; + double dvalue; + } u; +#if CAP_ROGUEVIZ + string* info; + polytodraw() { info = NULL; } +#endif + }; + diff --git a/init.cpp b/init.cpp index d22ad430..a786e892 100644 --- a/init.cpp +++ b/init.cpp @@ -1,3 +1,19 @@ +#ifdef MAC +#define ISMAC 1 +#endif + +#ifdef LINUX +#define ISLINUX 1 +#endif + +#ifdef WINDOWS +#define ISWINDOWS 1 +#endif + +#if ISSTEAM +#define NOLICENSE +#endif + #define VER "10.1h" #define VERNUM 10108 #define VERNUM_HEX 0xA088 @@ -179,7 +195,7 @@ #define CAP_SHMUP_GOOD (!ISMOBWEB) #endif -int fontscale = 100; +extern int fontscale; #if ISMOBILE #define EXTRALICENSE "\n\nHyperRogue soundtrack by Shawn Parrotte (http://www.shawnparrotte.com), under the Creative Commons BY-SA 3.0 license, http://creativecommons.org/licenses/by-sa/3.0/" @@ -306,9 +322,31 @@ inline Uint8 *SDL_GetKeyState(void *v) { static Uint8 tab[1024]; return tab; } using namespace std; -string s0; void addMessage(string s, char spamtype = 0); +#define S7 ginf[geometry].sides +#define S3 ginf[geometry].vertex +#define weirdhyperbolic (S7 > 7 || S3 > 3) +#define S6 (S3*2) +#define S42 (S7*S6) +#define S12 (S6*2) +#define S14 (S7*2) +#define S21 (S7*S3) +#define S28 (S7*4) +#define S36 (S6*6) +#define S84 (S7*S6*2) +#define MAX_EDGE 8 +#define MAX_S3 4 +#define MAX_S84 240 + +#ifdef ONE_CU +#include "classes.h" +#include "hyper.h" + +#else + +int fontscale = 100; + #if ISANDROID FILE *debfile; #endif @@ -325,20 +363,7 @@ const char *musicfile = ""; const char *loadlevel = NULL; #endif -#define S7 ginf[geometry].sides -#define S3 ginf[geometry].vertex -#define weirdhyperbolic (S7 > 7 || S3 > 3) -#define S6 (S3*2) -#define S42 (S7*S6) -#define S12 (S6*2) -#define S14 (S7*2) -#define S21 (S7*S3) -#define S28 (S7*4) -#define S36 (S6*6) -#define S84 (S7*S6*2) -#define MAX_EDGE 8 -#define MAX_S3 4 -#define MAX_S84 240 +string s0; #include "classes.cpp" #include "hyper.h" @@ -788,3 +813,4 @@ void mobile_draw(MOBPAR_FORMAL) { void playSound(cell*, const string &s, int vol) { printf("play sound: %s vol %d\n", s.c_str(), vol); } #endif +#endif diff --git a/polygons.cpp b/polygons.cpp index 48b3925e..4f1aba64 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -28,55 +28,6 @@ struct hpcshape { hpcshape *last = NULL; -#ifndef GL -typedef float GLfloat; -#endif - -struct qpoly { - transmatrix V; - GLfloat *tab; - int curveindex; - int cnt; - int outline; - double minwidth; - }; - -struct qline { - hyperpoint H1, H2; - int prf; - double width; - }; - -#define MAXQCHR 40 - -struct qchr { - char str[MAXQCHR]; - int x, y, shift, size, frame; - int align; - }; - -struct qcir { - int x, y, size; - }; - -enum eKind { pkPoly, pkLine, pkString, pkCircle, pkShape, pkResetModel }; - -struct polytodraw { - eKind kind; - int prio, col; - union { - qpoly poly; - qline line; - qchr chr; - qcir cir; - double dvalue; - } u; -#if CAP_ROGUEVIZ - string* info; - polytodraw() { info = NULL; } -#endif - }; - vector ptds; polytodraw& lastptd() { return ptds[size(ptds)-1]; } diff --git a/shmup.cpp b/shmup.cpp index 7444cb47..ac83b61f 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -21,6 +21,8 @@ namespace shmupballs { namespace multi { + charstyle scs[MAXPLAYER]; + int players = 1; cellwalker player[MAXPLAYER]; vector revive_queue; // queue for revival