Skip to content

Commit 6e1a45d

Browse files
BurnZeZBurnZeZ
BurnZeZ
authored and
BurnZeZ
committed
Merge pull request #1 from BurnZeZ/catacurses_fixup
Catacurses fixup
2 parents ca1187f + ba34a04 commit 6e1a45d

21 files changed

+61
-122
lines changed

catacurse.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ typedef struct {
6060
int cursorx;//x location of the cursor
6161
int cursory;//y location of the cursor
6262
curseline *line;
63+
6364
} WINDOW;
6465

6566
#define A_NORMAL __NORMAL

color.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
#ifndef _COLOR_H_
22
#define _COLOR_H
33

4-
#if (defined _WIN32 || defined WINDOWS)
5-
#include "catacurse.h"
6-
7-
#elif (defined __CYGWIN__)
8-
#include "ncurses/curses.h"
9-
#else
10-
#include <curses.h>
11-
#endif
12-
134
#ifndef _COLOR_LIST_
145
#define _COLOR_LIST_
156

7+
#include "cursesdef.h"
8+
169
void init_colors();
1710

1811
enum col_attribute {

cursesdef.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef _CURSES_DEF_H_
2+
#define _CURSES_DEF_H_
3+
4+
#if (defined _WIN32 || defined WINDOWS)
5+
#include "catacurse.h"
6+
#elif (defined __CYGWIN__)
7+
#include "ncurses/curses.h"
8+
#else
9+
#include <curses.h>
10+
#endif
11+
12+
#endif // CURSES_DEF_H

game.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,14 @@ game::game() :
6969
init_autosave(); // Set up autosave
7070
load_keyboard_settings();
7171

72-
VIEWX = OPTIONS[OPT_VIEWPORT_X] + 1;
73-
VIEWY = OPTIONS[OPT_VIEWPORT_Y] + 1;
72+
VIEWX = OPTIONS[OPT_VIEWPORT_X];
73+
VIEWY = OPTIONS[OPT_VIEWPORT_Y];
74+
if (VIEWX <= 0) {
75+
VIEWX = 1;
76+
}
77+
if (VIEWY <= 0) {
78+
VIEWY = 1;
79+
}
7480
TERRAIN_WINDOW_WIDTH = (VIEWX * 2) + 1;
7581
TERRAIN_WINDOW_HEIGHT = (VIEWY * 2) + 1;
7682
// Set up the main UI windows.

item.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,7 @@
44
#include "skill.h"
55
#include "game.h"
66
#include <sstream>
7-
8-
#if (defined _WIN32 || defined WINDOWS)
9-
#include "catacurse.h"
10-
#elif (defined __CYGWIN__)
11-
#include "ncurses/curses.h"
12-
#else
13-
#include <curses.h>
14-
#endif
7+
#include "cursesdef.h"
158

169
bool is_flammable(material m);
1710

keypress.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
#ifndef _KEYPRESS_H_
22
#define _KEYPRESS_H_
3-
#if (defined _WIN32 || defined WINDOWS)
4-
#include "catacurse.h"
5-
#elif (defined __CYGWIN__)
6-
#include "ncurses/curses.h"
7-
#else
8-
#include <curses.h>
9-
#endif
103

114
#include <string>
5+
#include "cursesdef.h"
126

137
class game;
148

main.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,7 @@
44
* Who knows
55
*/
66

7-
#if (defined _WIN32 || defined WINDOWS)
8-
#include "catacurse.h"
9-
#elif (defined __CYGWIN__)
10-
#include "ncurses/curses.h"
11-
#else
12-
#include <curses.h>
13-
#endif
14-
7+
#include "cursesdef.h"
158
#include <ctime>
169
#include "game.h"
1710
#include "color.h"

map.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,8 +2364,8 @@ void map::draw(game *g, WINDOW* w, const point center)
23642364

23652365
char trans_buf[my_MAPSIZE*SEEX][my_MAPSIZE*SEEY];
23662366
memset(trans_buf, -1, sizeof(trans_buf));
2367-
for (int realx = center.x - w->_maxx/2; realx <= center.x + g->VIEWX; realx++) {
2368-
for (int realy = center.y - w->_maxy/2; realy <= center.y + w->_maxy/2; realy++) {
2367+
for (int realx = center.x - getmaxx(w)/2; realx <= center.x + getmaxx(w)/2; realx++) {
2368+
for (int realy = center.y - getmaxy(w)/2; realy <= center.y + getmaxy(w)/2; realy++) {
23692369
const int dist = rl_dist(g->u.posx, g->u.posy, realx, realy);
23702370
int sight_range = light_sight_range;
23712371

@@ -2417,25 +2417,25 @@ void map::draw(game *g, WINDOW* w, const point center)
24172417
(lit == LL_DARK ||
24182418
(u_sight_impaired && lit != LL_BRIGHT)))) {
24192419
if (u_is_boomered)
2420-
mvwputch(w, realy+w->_maxy/2 - center.y, realx+w->_maxx/2 - center.x, c_magenta, '#');
2420+
mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_magenta, '#');
24212421
else
2422-
mvwputch(w, realy+w->_maxy/2 - center.y, realx+w->_maxx/2 - center.x, c_dkgray, '#');
2422+
mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_dkgray, '#');
24232423
} else if (dist > light_sight_range && u_sight_impaired && lit == LL_BRIGHT) {
24242424
if (u_is_boomered)
2425-
mvwputch(w, realy+w->_maxy/2 - center.y, realx+w->_maxx/2 - center.x, c_pink, '#');
2425+
mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_pink, '#');
24262426
else
2427-
mvwputch(w, realy+w->_maxy/2 - center.y, realx+w->_maxx/2 - center.x, c_ltgray, '#');
2427+
mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_ltgray, '#');
24282428
} else if (dist <= u_clairvoyance || can_see) {
24292429
drawsq(w, g->u, realx, realy, false, true, center.x, center.y,
24302430
(dist > lowlight_sight_range && LL_LIT > lit) ||
24312431
(dist > sight_range && LL_LOW == lit),
24322432
LL_BRIGHT == lit);
24332433
} else {
2434-
mvwputch(w, realy+w->_maxy/2 - center.y, realx+w->_maxx/2 - center.x, c_black,'#');
2434+
mvwputch(w, realy+getmaxy(w)/2 - center.y, realx+getmaxx(w)/2 - center.x, c_black,'#');
24352435
}
24362436
}
24372437
}
2438-
int atx = w->_maxx/2 + g->u.posx - center.x, aty = w->_maxy/2 + g->u.posy - center.y;
2438+
int atx = getmaxx(w)/2 + g->u.posx - center.x, aty = getmaxy(w)/2 + g->u.posy - center.y;
24392439
if (atx >= 0 && atx < g->TERRAIN_WINDOW_WIDTH && aty >= 0 && aty < g->TERRAIN_WINDOW_HEIGHT)
24402440
mvwputch(w, aty, atx, g->u.color(), '@');
24412441
}
@@ -2454,8 +2454,8 @@ void map::drawsq(WINDOW* w, player &u, const int x, const int y, const bool inve
24542454
cx = u.posx;
24552455
if (cy == -1)
24562456
cy = u.posy;
2457-
const int k = x + w->_maxx/2 - cx;
2458-
const int j = y + w->_maxy/2 - cy;
2457+
const int k = x + getmaxx(w)/2 - cx;
2458+
const int j = y + getmaxy(w)/2 - cy;
24592459
nc_color tercol;
24602460
long sym = terlist[ter(x, y)].sym;
24612461
bool hi = false;

map.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
#ifndef _MAP_H_
22
#define _MAP_H_
33

4-
#if (defined _WIN32 || defined WINDOWS)
5-
#include "catacurse.h"
6-
#elif (defined __CYGWIN__)
7-
#include "ncurses/curses.h"
8-
#else
9-
#include <curses.h>
10-
#endif
4+
#include "cursesdef.h"
115

126
#include <stdlib.h>
137
#include <vector>

melee.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@
55
#include <sstream>
66
#include <stdlib.h>
77

8-
#if (defined _WIN32 || defined WINDOWS)
9-
#include "catacurse.h"
10-
#elif (defined __CYGWIN__)
11-
#include "ncurses/curses.h"
12-
#else
13-
#include <curses.h>
14-
#endif
8+
#include "cursesdef.h"
159

1610
void hit_message(game *g, std::string subject, std::string verb,
1711
std::string target, int dam, bool crit);

monmove.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,7 @@
77
#include "rng.h"
88
#include "pldata.h"
99
#include <stdlib.h>
10-
11-
#if (defined _WIN32 || defined WINDOWS)
12-
#include "catacurse.h"
13-
#elif (defined __CYGWIN__)
14-
#include "ncurses/curses.h"
15-
#else
16-
#include <curses.h>
17-
#endif
10+
#include "cursesdef.h"
1811

1912
#ifndef SGN
2013
#define SGN(a) (((a)<0) ? -1 : 1)

monster.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@
88
#include <sstream>
99
#include <fstream>
1010
#include <stdlib.h>
11-
12-
#if (defined _WIN32 || defined WINDOWS)
13-
#include "catacurse.h"
14-
#elif (defined __CYGWIN__)
15-
#include "ncurses/curses.h"
16-
#else
17-
#include <curses.h>
18-
#endif
11+
#include "cursesdef.h"
1912

2013
#define SGN(a) (((a)<0) ? -1 : 1)
2114
#define SQR(a) ((a)*(a))
@@ -221,8 +214,8 @@ char monster::symbol()
221214

222215
void monster::draw(WINDOW *w, int plx, int ply, bool inv)
223216
{
224-
int x = w->_maxx/2 + posx - plx;
225-
int y = w->_maxy/2 + posy - ply;
217+
int x = getmaxx(w)/2 + posx - plx;
218+
int y = getmaxy(w)/2 + posy - ply;
226219
nc_color color = type->color;
227220
if (friendly != 0 && !inv)
228221
mvwputch_hi(w, y, x, color, type->sym);

npc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,8 +1795,8 @@ int npc::speed_estimate(int speed)
17951795

17961796
void npc::draw(WINDOW* w, int ux, int uy, bool inv)
17971797
{
1798-
int x = w->_maxx/2 + posx - ux;
1799-
int y = w->_maxy/2 + posy - uy;
1798+
int x = getmaxx(w)/2 + posx - ux;
1799+
int y = getmaxy(w)/2 + posy - uy;
18001800
nc_color col = c_pink;
18011801
if (attitude == NPCATT_KILL)
18021802
col = c_red;

options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ char option_max_options(option_key id)
205205
break;
206206
case OPT_VIEWPORT_X:
207207
case OPT_VIEWPORT_Y:
208-
ret = 60;
208+
ret = 61; // TODO Set up min/max values so weird numbers don't have to be used.
209209
break;
210210
default:
211211
ret = 2;

options.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@ struct option_table
2929
{
3030
double options[NUM_OPTION_KEYS];
3131

32-
option_table() { for (int i = 0; i < NUM_OPTION_KEYS; i++) options[i] = 0; };
32+
option_table() {
33+
for (int i = 0; i < NUM_OPTION_KEYS; i++) {
34+
if(i == OPT_VIEWPORT_X || i == OPT_VIEWPORT_Y) {
35+
options[i] = 11;
36+
}
37+
else {
38+
options[i] = 0;
39+
}
40+
}
41+
};
3342

3443
double& operator[] (option_key i) { return options[i]; };
3544
double& operator[] (int i) { return options[i]; };

output.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
2-
#if (defined _WIN32 || defined WINDOWS)
3-
#include "catacurse.h"
4-
#elif (defined __CYGWIN__)
5-
#include "ncurses/curses.h"
6-
#else
7-
#include <curses.h>
8-
#endif
9-
101
#include <string>
112
#include <vector>
123
#include <cstdarg>
@@ -21,6 +12,7 @@
2112
#include "rng.h"
2213
#include "keypress.h"
2314
#include "options.h"
15+
#include "cursesdef.h"
2416

2517
#define LINE_XOXO 4194424
2618
#define LINE_OXOX 4194417

overmap.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#if (defined _WIN32 || defined WINDOWS)
2-
#include "catacurse.h"
3-
#elif (defined __CYGWIN__)
4-
#include "ncurses/curses.h"
5-
#else
6-
#include <curses.h>
7-
#endif
8-
91
#include <stdlib.h>
102
#include <time.h>
113
#include <math.h>
@@ -22,6 +14,7 @@
2214
#include <cstring>
2315
#include <ostream>
2416
#include "debug.h"
17+
#include "cursesdef.h"
2518

2619
#define STREETCHANCE 2
2720
#define NUM_FOREST 250

overmap.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,7 @@
88
#include "output.h"
99
#include <vector>
1010
#include <iosfwd>
11-
12-
#if (defined _WIN32 || defined WINDOWS)
13-
#include "catacurse.h"
14-
#elif (defined __CYGWIN__)
15-
#include "ncurses/curses.h"
16-
#else
17-
#include <curses.h>
18-
#endif
19-
11+
#include "cursesdef.h"
2012

2113
class npc;
2214
struct settlement;

player.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,7 @@
1313
#include <stdlib.h>
1414

1515
#include "name.h"
16-
17-
#if (defined _WIN32 || defined WINDOWS)
18-
#include "catacurse.h"
19-
#elif (defined __CYGWIN__)
20-
#include "ncurses/curses.h"
21-
#else
22-
#include <curses.h>
23-
#endif
16+
#include "cursesdef.h"
2417

2518
nc_color encumb_color(int level);
2619
bool activity_is_suspendable(activity_type type);

tutorial.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ another attack. Your dexterity and melee skills are used to determine\n\
116116
whether an attack hits, while strength affects damage.",
117117
"\
118118
Taking damage often causes pain. Small amounts of pain are tolerable, but as\n\
119-
it gets worse youre stats will drop and you will move much slower. To reduce\n\
119+
it gets worse you're stats will drop and you will move much slower. To reduce\n\
120120
pain, take painkillers like codeine, or simply wait it out.",
121121
"\
122122
When you kill a monster it will often leave behind a corpse. Corpses can be\n\

vehicle.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@
55
#include "item.h"
66
#include <sstream>
77
#include <stdlib.h>
8-
#if (defined _WIN32 || defined WINDOWS)
9-
#include "catacurse.h"
10-
#elif (defined __CYGWIN__)
11-
#include "ncurses/curses.h"
12-
#else
13-
#include <curses.h>
14-
#endif
8+
#include "cursesdef.h"
159

1610
enum vehicle_controls {
1711
toggle_cruise_control,

0 commit comments

Comments
 (0)