From dac4a0eb11a70ad7fd04480fbdb5b86cf16213ea Mon Sep 17 00:00:00 2001 From: BurnZeZ Date: Sat, 23 Feb 2013 12:31:11 -0500 Subject: [PATCH 1/6] Hotfix: Compiling on windows failing due to mismatched variable names in the windows curses header. --- catacurse.cpp | 2 ++ catacurse.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/catacurse.cpp b/catacurse.cpp index e9e6158e986e7..99af33701b91d 100644 --- a/catacurse.cpp +++ b/catacurse.cpp @@ -336,6 +336,8 @@ WINDOW *newwin(int nlines, int ncols, int begin_y, int begin_x) newwindow->y=begin_y; newwindow->width=ncols; newwindow->height=nlines; + newwindow->_maxx=width; + newwindow->_maxy=height; newwindow->inuse=true; newwindow->draw=false; newwindow->BG=0; diff --git a/catacurse.h b/catacurse.h index b35268c09ce7c..a48004c89e33e 100644 --- a/catacurse.h +++ b/catacurse.h @@ -60,6 +60,10 @@ typedef struct { int cursorx;//x location of the cursor int cursory;//y location of the cursor curseline *line; + + //Threw these in here to fix a problem with ncurses compatibility + int _maxx; + int _maxy; } WINDOW; #define A_NORMAL __NORMAL From dca4aeae2f66a872fe1a05df3c13caa0f30dd339 Mon Sep 17 00:00:00 2001 From: BurnZeZ Date: Sat, 23 Feb 2013 12:58:20 -0500 Subject: [PATCH 2/6] Fix retarded assignment to non-existent variables from last commit. --- catacurse.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/catacurse.cpp b/catacurse.cpp index 99af33701b91d..24dd0d74e3678 100644 --- a/catacurse.cpp +++ b/catacurse.cpp @@ -336,8 +336,8 @@ WINDOW *newwin(int nlines, int ncols, int begin_y, int begin_x) newwindow->y=begin_y; newwindow->width=ncols; newwindow->height=nlines; - newwindow->_maxx=width; - newwindow->_maxy=height; + newwindow->_maxx=ncols; + newwindow->_maxy=nlines; newwindow->inuse=true; newwindow->draw=false; newwindow->BG=0; From ba795cd153892991000dc7b3e184eef4ce540a60 Mon Sep 17 00:00:00 2001 From: BurnZeZ Date: Sat, 23 Feb 2013 15:39:35 -0500 Subject: [PATCH 3/6] Cleaned up redundant #defines. --- color.h | 11 ++--------- cursesdef.h | 12 ++++++++++++ item.cpp | 9 +-------- keypress.h | 8 +------- main.cpp | 9 +-------- map.h | 8 +------- melee.cpp | 8 +------- monmove.cpp | 9 +-------- monster.cpp | 9 +-------- output.cpp | 10 +--------- overmap.cpp | 9 +-------- overmap.h | 10 +--------- player.cpp | 9 +-------- vehicle.cpp | 8 +------- 14 files changed, 26 insertions(+), 103 deletions(-) create mode 100644 cursesdef.h diff --git a/color.h b/color.h index cf53b7c8ea8c2..7a92a8c1917f7 100644 --- a/color.h +++ b/color.h @@ -1,18 +1,11 @@ #ifndef _COLOR_H_ #define _COLOR_H -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" - -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif - #ifndef _COLOR_LIST_ #define _COLOR_LIST_ +#include "cursesdef.h" + void init_colors(); enum col_attribute { diff --git a/cursesdef.h b/cursesdef.h new file mode 100644 index 0000000000000..928cc6a6bcf9b --- /dev/null +++ b/cursesdef.h @@ -0,0 +1,12 @@ +#ifndef _CURSES_DEF_H_ +#define _CURSES_DEF_H_ + +#if (defined _WIN32 || defined WINDOWS) + #include "catacurse.h" +#elif (defined __CYGWIN__) + #include "ncurses/curses.h" +#else + #include +#endif + +#endif // CURSES_DEF_H diff --git a/item.cpp b/item.cpp index 0566142f33078..9a5c8935f63ce 100644 --- a/item.cpp +++ b/item.cpp @@ -4,14 +4,7 @@ #include "skill.h" #include "game.h" #include - -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif +#include "cursesdef.h" bool is_flammable(material m); diff --git a/keypress.h b/keypress.h index 4c2519a072e02..c54777d155928 100644 --- a/keypress.h +++ b/keypress.h @@ -1,14 +1,8 @@ #ifndef _KEYPRESS_H_ #define _KEYPRESS_H_ -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif #include +#include "cursesdef.h" class game; diff --git a/main.cpp b/main.cpp index e2e9369ff9978..c6c9801630a54 100644 --- a/main.cpp +++ b/main.cpp @@ -4,14 +4,7 @@ * Who knows */ -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif - +#include "cursesdef.h" #include #include "game.h" #include "color.h" diff --git a/map.h b/map.h index ef1042379a19e..96e1dc32e6193 100644 --- a/map.h +++ b/map.h @@ -1,13 +1,7 @@ #ifndef _MAP_H_ #define _MAP_H_ -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif +#include "cursesdef.h" #include #include diff --git a/melee.cpp b/melee.cpp index c1b0b2ce14627..ad0dc2e88cced 100644 --- a/melee.cpp +++ b/melee.cpp @@ -5,13 +5,7 @@ #include #include -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif +#include "cursesdef.h" void hit_message(game *g, std::string subject, std::string verb, std::string target, int dam, bool crit); diff --git a/monmove.cpp b/monmove.cpp index 7a7d24cdccf79..85c51adacd008 100644 --- a/monmove.cpp +++ b/monmove.cpp @@ -7,14 +7,7 @@ #include "rng.h" #include "pldata.h" #include - -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif +#include "cursesdef.h" #ifndef SGN #define SGN(a) (((a)<0) ? -1 : 1) diff --git a/monster.cpp b/monster.cpp index 3a72caf79e86f..7cb0bee51e0b2 100644 --- a/monster.cpp +++ b/monster.cpp @@ -8,14 +8,7 @@ #include #include #include - -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif +#include "cursesdef.h" #define SGN(a) (((a)<0) ? -1 : 1) #define SQR(a) ((a)*(a)) diff --git a/output.cpp b/output.cpp index 797896e2eadd2..4fdd4e9152b04 100644 --- a/output.cpp +++ b/output.cpp @@ -1,12 +1,3 @@ - -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif - #include #include #include @@ -21,6 +12,7 @@ #include "rng.h" #include "keypress.h" #include "options.h" +#include "cursesdef.h" #define LINE_XOXO 4194424 #define LINE_OXOX 4194417 diff --git a/overmap.cpp b/overmap.cpp index 10bb558013dda..20ce5096857ad 100644 --- a/overmap.cpp +++ b/overmap.cpp @@ -1,11 +1,3 @@ -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif - #include #include #include @@ -22,6 +14,7 @@ #include #include #include "debug.h" +#include "cursesdef.h" #define STREETCHANCE 2 #define NUM_FOREST 250 diff --git a/overmap.h b/overmap.h index aa8fc7b14043a..222cec282e744 100644 --- a/overmap.h +++ b/overmap.h @@ -8,15 +8,7 @@ #include "output.h" #include #include - -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif - +#include "cursesdef.h" class npc; struct settlement; diff --git a/player.cpp b/player.cpp index b71160a218a0c..b3a0f913ce9a3 100644 --- a/player.cpp +++ b/player.cpp @@ -13,14 +13,7 @@ #include #include "name.h" - -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif +#include "cursesdef.h" nc_color encumb_color(int level); bool activity_is_suspendable(activity_type type); diff --git a/vehicle.cpp b/vehicle.cpp index c4f0b29e0f160..1d33b4a06dcaa 100644 --- a/vehicle.cpp +++ b/vehicle.cpp @@ -5,13 +5,7 @@ #include "item.h" #include #include -#if (defined _WIN32 || defined WINDOWS) - #include "catacurse.h" -#elif (defined __CYGWIN__) - #include "ncurses/curses.h" -#else - #include -#endif +#include "cursesdef.h" enum vehicle_controls { toggle_cruise_control, From 97c273ab81fe1acd481aaf05758a86daf5ce09eb Mon Sep 17 00:00:00 2001 From: BurnZeZ Date: Sat, 23 Feb 2013 17:41:19 -0500 Subject: [PATCH 4/6] Hackish fix for undefined viewport size when it's not in options.txt --- options.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/options.h b/options.h index 315f865089efd..e268dba8e7347 100644 --- a/options.h +++ b/options.h @@ -29,7 +29,16 @@ struct option_table { double options[NUM_OPTION_KEYS]; - option_table() { for (int i = 0; i < NUM_OPTION_KEYS; i++) options[i] = 0; }; + option_table() { + for (int i = 0; i < NUM_OPTION_KEYS; i++) { + if(i == OPT_VIEWPORT_X || i == OPT_VIEWPORT_Y) { + options[i] = 11; + } + else { + options[i] = 0; + } + } + }; double& operator[] (option_key i) { return options[i]; }; double& operator[] (int i) { return options[i]; }; From 5801dfee6fefa7758cd00a3562e0fb97d4a77f7a Mon Sep 17 00:00:00 2001 From: BurnZeZ Date: Sat, 23 Feb 2013 18:14:02 -0500 Subject: [PATCH 5/6] Removed _maxx/_maxy from catacurse.h WINDOW, as generic curses functions to access them are already defined. Fixed areas that relied on this. --- catacurse.cpp | 2 -- catacurse.h | 3 --- map.cpp | 20 ++++++++++---------- monster.cpp | 4 ++-- npc.cpp | 4 ++-- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/catacurse.cpp b/catacurse.cpp index 24dd0d74e3678..e9e6158e986e7 100644 --- a/catacurse.cpp +++ b/catacurse.cpp @@ -336,8 +336,6 @@ WINDOW *newwin(int nlines, int ncols, int begin_y, int begin_x) newwindow->y=begin_y; newwindow->width=ncols; newwindow->height=nlines; - newwindow->_maxx=ncols; - newwindow->_maxy=nlines; newwindow->inuse=true; newwindow->draw=false; newwindow->BG=0; diff --git a/catacurse.h b/catacurse.h index a48004c89e33e..96a8d79d5eb10 100644 --- a/catacurse.h +++ b/catacurse.h @@ -61,9 +61,6 @@ typedef struct { int cursory;//y location of the cursor curseline *line; - //Threw these in here to fix a problem with ncurses compatibility - int _maxx; - int _maxy; } WINDOW; #define A_NORMAL __NORMAL diff --git a/map.cpp b/map.cpp index 0bf4205a32710..11ee0d6493325 100644 --- a/map.cpp +++ b/map.cpp @@ -2364,8 +2364,8 @@ void map::draw(game *g, WINDOW* w, const point center) char trans_buf[my_MAPSIZE*SEEX][my_MAPSIZE*SEEY]; memset(trans_buf, -1, sizeof(trans_buf)); - for (int realx = center.x - w->_maxx/2; realx <= center.x + g->VIEWX; realx++) { - for (int realy = center.y - w->_maxy/2; realy <= center.y + w->_maxy/2; realy++) { + for (int realx = center.x - getmaxx(w)/2; realx <= center.x + getmaxx(w)/2; realx++) { + for (int realy = center.y - getmaxy(w)/2; realy <= center.y + getmaxy(w)/2; realy++) { const int dist = rl_dist(g->u.posx, g->u.posy, realx, realy); int sight_range = light_sight_range; @@ -2417,25 +2417,25 @@ void map::draw(game *g, WINDOW* w, const point center) (lit == LL_DARK || (u_sight_impaired && lit != LL_BRIGHT)))) { if (u_is_boomered) - mvwputch(w, realy+w->_maxy/2 - center.y, realx+w->_maxx/2 - center.x, c_magenta, '#'); + mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_magenta, '#'); else - mvwputch(w, realy+w->_maxy/2 - center.y, realx+w->_maxx/2 - center.x, c_dkgray, '#'); + mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_dkgray, '#'); } else if (dist > light_sight_range && u_sight_impaired && lit == LL_BRIGHT) { if (u_is_boomered) - mvwputch(w, realy+w->_maxy/2 - center.y, realx+w->_maxx/2 - center.x, c_pink, '#'); + mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_pink, '#'); else - mvwputch(w, realy+w->_maxy/2 - center.y, realx+w->_maxx/2 - center.x, c_ltgray, '#'); + mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_ltgray, '#'); } else if (dist <= u_clairvoyance || can_see) { drawsq(w, g->u, realx, realy, false, true, center.x, center.y, (dist > lowlight_sight_range && LL_LIT > lit) || (dist > sight_range && LL_LOW == lit), LL_BRIGHT == lit); } else { - mvwputch(w, realy+w->_maxy/2 - center.y, realx+w->_maxx/2 - center.x, c_black,'#'); + mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_black,'#'); } } } - int atx = w->_maxx/2 + g->u.posx - center.x, aty = w->_maxy/2 + g->u.posy - center.y; + int atx = getmaxx(w)/2 + g->u.posx - center.x, aty = getmaxy(w)/2 + g->u.posy - center.y; if (atx >= 0 && atx < g->TERRAIN_WINDOW_WIDTH && aty >= 0 && aty < g->TERRAIN_WINDOW_HEIGHT) mvwputch(w, aty, atx, g->u.color(), '@'); } @@ -2454,8 +2454,8 @@ void map::drawsq(WINDOW* w, player &u, const int x, const int y, const bool inve cx = u.posx; if (cy == -1) cy = u.posy; - const int k = x + w->_maxx/2 - cx; - const int j = y + w->_maxy/2 - cy; + const int k = x + getmaxx(w)/2 - cx; + const int j = y + getmaxy(w)/2 - cy; nc_color tercol; long sym = terlist[ter(x, y)].sym; bool hi = false; diff --git a/monster.cpp b/monster.cpp index 7cb0bee51e0b2..31e9f41b79564 100644 --- a/monster.cpp +++ b/monster.cpp @@ -214,8 +214,8 @@ char monster::symbol() void monster::draw(WINDOW *w, int plx, int ply, bool inv) { - int x = w->_maxx/2 + posx - plx; - int y = w->_maxy/2 + posy - ply; + int x = getmaxx(w)/2 + posx - plx; + int y = getmaxy(w)/2 + posy - ply; nc_color color = type->color; if (friendly != 0 && !inv) mvwputch_hi(w, y, x, color, type->sym); diff --git a/npc.cpp b/npc.cpp index c3e15e8933e29..4c10e89c4182b 100644 --- a/npc.cpp +++ b/npc.cpp @@ -1795,8 +1795,8 @@ int npc::speed_estimate(int speed) void npc::draw(WINDOW* w, int ux, int uy, bool inv) { - int x = w->_maxx/2 + posx - ux; - int y = w->_maxy/2 + posy - uy; + int x = getmaxx(w)/2 + posx - ux; + int y = getmaxy(w)/2 + posy - uy; nc_color col = c_pink; if (attitude == NPCATT_KILL) col = c_red; From ba34a04979471350153220d6a13337ba7c0e6992 Mon Sep 17 00:00:00 2001 From: BurnZeZ Date: Sat, 23 Feb 2013 19:23:30 -0500 Subject: [PATCH 6/6] Fixed the window size options to more accurately represent the actual numbers. Fixed a typo in the tutorial text. --- game.cpp | 10 ++++++++-- options.cpp | 2 +- tutorial.h | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/game.cpp b/game.cpp index fd1280dd2f9a3..eb1bfc982cc15 100644 --- a/game.cpp +++ b/game.cpp @@ -69,8 +69,14 @@ game::game() : init_autosave(); // Set up autosave load_keyboard_settings(); - VIEWX = OPTIONS[OPT_VIEWPORT_X] + 1; - VIEWY = OPTIONS[OPT_VIEWPORT_Y] + 1; + VIEWX = OPTIONS[OPT_VIEWPORT_X]; + VIEWY = OPTIONS[OPT_VIEWPORT_Y]; + if (VIEWX <= 0) { + VIEWX = 1; + } + if (VIEWY <= 0) { + VIEWY = 1; + } TERRAIN_WINDOW_WIDTH = (VIEWX * 2) + 1; TERRAIN_WINDOW_HEIGHT = (VIEWY * 2) + 1; // Set up the main UI windows. diff --git a/options.cpp b/options.cpp index 0c08d860c9002..e428964557e46 100644 --- a/options.cpp +++ b/options.cpp @@ -205,7 +205,7 @@ char option_max_options(option_key id) break; case OPT_VIEWPORT_X: case OPT_VIEWPORT_Y: - ret = 60; + ret = 61; // TODO Set up min/max values so weird numbers don't have to be used. break; default: ret = 2; diff --git a/tutorial.h b/tutorial.h index 9c4300ed76963..b105c1f83e7fd 100644 --- a/tutorial.h +++ b/tutorial.h @@ -116,7 +116,7 @@ another attack. Your dexterity and melee skills are used to determine\n\ whether an attack hits, while strength affects damage.", "\ Taking damage often causes pain. Small amounts of pain are tolerable, but as\n\ -it gets worse youre stats will drop and you will move much slower. To reduce\n\ +it gets worse you're stats will drop and you will move much slower. To reduce\n\ pain, take painkillers like codeine, or simply wait it out.", "\ When you kill a monster it will often leave behind a corpse. Corpses can be\n\