Skip to content

Commit

Permalink
Fixed linux compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
philippeop committed Mar 23, 2013
1 parent 7fb40f8 commit 8e9c0bb
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 57 deletions.
45 changes: 22 additions & 23 deletions map.cpp
Expand Up @@ -2702,7 +2702,7 @@ void map::drawsq(WINDOW* w, player &u, const int x, const int y, const bool inve
graf = true;

//suprise, we're not done, if it's a wall adjacent to an other, put the right glyph
if(sym == LINE_V || sym == LINE_H)//vertical or horizontal
if(sym == LINE_XOXO || sym == LINE_OXOX)//vertical or horizontal
sym = determine_wall_corner(x, y, sym);

if (invert)
Expand Down Expand Up @@ -3291,72 +3291,71 @@ graffiti map::graffiti_at(int x, int y)
return grid[nonant]->graf[x][y];
}

unsigned char map::determine_wall_corner(int x, int y, unsigned char sym)
long map::determine_wall_corner(int x, int y, long sym)
{
//196 = -
//179 = |
//LINE_NESW
long above = terlist[ter(x, y-1)].sym;
long below = terlist[ter(x, y+1)].sym;
long left = terlist[ter(x-1, y)].sym;
long right = terlist[ter(x+1, y)].sym;

bool above_connects = above == sym || (above == '"' || above == '+' || above == '\'');
bool below_connects = below == sym || (below == '"' || below == '+' || below == '\'');
bool left_connects = left == sym || (left == '"' || left == '+' || left == '\'');
bool left_connects = left == sym || (left == '"' || left == '+' || left == '\'');
bool right_connects = right == sym || (right == '"' || right == '+' || right == '\'');

// -
// | this = - and above = | or a connectable
if(sym == LINE_H && (above == LINE_V || above_connects))
if(sym == LINE_OXOX && (above == LINE_XOXO || above_connects))
{
//connects to upper
if(left_connects)
sym = CORNER_SE; // ┘ left coming wall
sym = LINE_XOOX; // ┘ left coming wall
else if(right_connects)
sym = CORNER_SW;//└ right coming wall
sym = LINE_XXOO;//└ right coming wall
if(left_connects && right_connects)
sym = T_TOP; // ┴ passing by
sym = LINE_XXOX; // ┴ passing by
}

// |
// - this = - and below = | or a connectable
else if(sym == LINE_H && (below == LINE_V || below_connects))
else if(sym == LINE_OXOX && (below == LINE_XOXO || below_connects))
{
//connects to lower
if(left_connects)
sym = CORNER_NE; // ┐ left coming wall
sym = LINE_OOXX; // ┐ left coming wall
else if(right_connects)
sym = CORNER_NW;//┌ right coming wall
sym = LINE_OXXO;//┌ right coming wall
if(left_connects && right_connects)
sym = T_BOTTOM; // ┬ passing by
sym = LINE_OXXX; // ┬ passing by
}

// -| this = | and left = - or a connectable
else if(sym == LINE_V && (left == LINE_H || left_connects))
else if(sym == LINE_XOXO && (left == LINE_OXOX || left_connects))
{
//connexts to left
if(above_connects)
sym = CORNER_SE; // ┘ north coming wall
sym = LINE_XOOX; // ┘ north coming wall
else if(below_connects )
sym = CORNER_NE;//┐ south coming wall
sym = LINE_OOXX;//┐ south coming wall
if(above_connects && below_connects)
sym = T_LEFT; // ┤ passing by
sym = LINE_XOXX; // ┤ passing by
}

// |- this = | and right = - or a connectable
else if(sym == LINE_V && (right == LINE_H || right_connects))
else if(sym == LINE_XOXO && (right == LINE_OXOX || right_connects))
{
//connects to right
if(above_connects)
sym = CORNER_SW; // └ north coming wall
sym = LINE_XXOO; // └ north coming wall
else if(below_connects)
sym = CORNER_NW;// ┌ south coming wall
sym = LINE_OXXO;// ┌ south coming wall
if(above_connects && below_connects)
sym = T_RIGHT; // ├ passing by
sym = LINE_XXXO; // ├ passing by
}

if(above == LINE_V && left == LINE_H && above == below && left == right)
sym = 197; // ┼ crossway
if(above == LINE_XOXO && left == LINE_OXOX && above == below && left == right)
sym = LINE_XXXX; // ┼ crossway

return sym;
}
Expand Down
2 changes: 1 addition & 1 deletion map.h
Expand Up @@ -53,7 +53,7 @@ class map
void drawsq(WINDOW* w, player &u, const int x, const int y, const bool invert, const bool show_items,
const int cx = -1, const int cy = -1,
const bool low_light = false, const bool bright_level = false);
unsigned char determine_wall_corner(int x, int y, unsigned char);
long determine_wall_corner(int x, int y, long);

// File I/O
virtual void save(overmap *om, unsigned const int turn, const int x, const int y, const int z);
Expand Down
38 changes: 13 additions & 25 deletions mapdata.h
Expand Up @@ -65,7 +65,7 @@ enum t_flag {

struct ter_t {
std::string name;
char sym;
long sym;
nc_color color;
unsigned char movecost;
trap_id trap;
Expand Down Expand Up @@ -160,18 +160,6 @@ t_rock_red, t_rock_green, t_rock_blue, t_floor_red, t_floor_green, t_floor_blue,
num_terrain_types
};

// Extended ASCII aliases
#define LINE_H 196 //
#define LINE_V 179 //
#define CORNER_NW 218 //
#define CORNER_NE 191 //
#define CORNER_SW 192 //
#define CORNER_SE 217 //
#define T_TOP 193 //
#define T_BOTTOM 194 //
#define T_LEFT 180 //
#define T_RIGHT 195 //

const ter_t terlist[num_terrain_types] = { // MUST match enum ter_id above!
{"nothing", ' ', c_white, 2, tr_null,
mfb(transparent)|mfb(diggable)},
Expand Down Expand Up @@ -273,31 +261,31 @@ const ter_t terlist[num_terrain_types] = { // MUST match enum ter_id above!
{"broken wood wall", '&', c_ltred, 0, tr_null,
mfb(transparent)|mfb(bashable)|mfb(flammable2)|mfb(noitem)|
mfb(supports_roof)},
{"wall", LINE_H, c_ltgray, 0, tr_null,
{"wall", LINE_XOXO, c_ltgray, 0, tr_null,
mfb(flammable)|mfb(noitem)|mfb(supports_roof)},
{"wall", LINE_V, c_ltgray, 0, tr_null,
{"wall", LINE_OXOX, c_ltgray, 0, tr_null,
mfb(flammable)|mfb(noitem)|mfb(supports_roof)},
{"concrete wall", LINE_H, c_dkgray, 0, tr_null,
{"concrete wall", LINE_XOXO, c_dkgray, 0, tr_null,
mfb(noitem)|mfb(supports_roof)},
{"concrete wall", LINE_V, c_dkgray, 0, tr_null,
{"concrete wall", LINE_OXOX, c_dkgray, 0, tr_null,
mfb(noitem)|mfb(supports_roof)},
{"metal wall", LINE_H, c_cyan, 0, tr_null,
{"metal wall", LINE_XOXO, c_cyan, 0, tr_null,
mfb(noitem)|mfb(noitem)|mfb(supports_roof)},
{"metal wall", LINE_V, c_cyan, 0, tr_null,
{"metal wall", LINE_OXOX, c_cyan, 0, tr_null,
mfb(noitem)|mfb(noitem)|mfb(supports_roof)},
{"glass wall", LINE_H, c_ltcyan, 0, tr_null,
{"glass wall", LINE_XOXO, c_ltcyan, 0, tr_null,
mfb(transparent)|mfb(bashable)|mfb(noitem)|mfb(supports_roof)},
{"glass wall", LINE_V, c_ltcyan, 0, tr_null,
{"glass wall", LINE_OXOX, c_ltcyan, 0, tr_null,
mfb(transparent)|mfb(bashable)|mfb(noitem)|mfb(supports_roof)},
{"glass wall", LINE_H, c_ltcyan, 0, tr_null, // Alarmed
{"glass wall", LINE_XOXO, c_ltcyan, 0, tr_null, // Alarmed
mfb(transparent)|mfb(bashable)|mfb(alarmed)|mfb(noitem)|
mfb(supports_roof)},
{"glass wall", LINE_V, c_ltcyan, 0, tr_null, // Alarmed
{"glass wall", LINE_OXOX, c_ltcyan, 0, tr_null, // Alarmed
mfb(transparent)|mfb(bashable)|mfb(alarmed)|mfb(noitem)|
mfb(supports_roof)},
{"reinforced glass", LINE_H, c_ltcyan, 0, tr_null,
{"reinforced glass", LINE_XOXO, c_ltcyan, 0, tr_null,
mfb(transparent)|mfb(bashable)|mfb(noitem)|mfb(supports_roof)},
{"reinforced glass", LINE_V, c_ltcyan, 0, tr_null,
{"reinforced glass", LINE_OXOX, c_ltcyan, 0, tr_null,
mfb(transparent)|mfb(bashable)|mfb(noitem)|mfb(supports_roof)},
{"metal bars", '"', c_ltgray, 0, tr_null,
mfb(transparent)|mfb(noitem)},
Expand Down
2 changes: 1 addition & 1 deletion mtype.h
Expand Up @@ -181,7 +181,7 @@ struct mtype {
std::string name;
std::string description;
monster_species species;
unsigned char sym; // Symbol on the map
long sym; // Symbol on the map
nc_color color;// Color of symbol (see color.h)

m_size size;
Expand Down
2 changes: 1 addition & 1 deletion output.cpp
Expand Up @@ -848,7 +848,7 @@ char rand_char()

// this translates symbol y, u, n, b to NW, NE, SE, SW lines correspondingly
// h, j, c to horizontal, vertical, cross correspondingly
long special_symbol (unsigned char sym)
long special_symbol (long sym)
{
switch (sym)
{
Expand Down
2 changes: 1 addition & 1 deletion output.h
Expand Up @@ -68,7 +68,7 @@ nc_color invert_color(nc_color c);
nc_color red_background(nc_color c);
nc_color rand_color();
char rand_char();
long special_symbol (unsigned char sym);
long special_symbol (long sym);

// utility: moves \n's around to fit string breaks within a certain width.
std::string word_rewrap (const std::string &in, int width);
Expand Down
2 changes: 1 addition & 1 deletion tileray.cpp
Expand Up @@ -83,7 +83,7 @@ int tileray::dir4 ()
return 0;
}

unsigned char tileray::dir_symbol (unsigned char sym)
long tileray::dir_symbol (long sym)
{
switch (sym)
{
Expand Down
2 changes: 1 addition & 1 deletion tileray.h
Expand Up @@ -37,7 +37,7 @@ class tileray
int dy (); // return dy of last advance (-1 to 1)
int dir (); // return direction of ray (degrees)
int dir4 (); // return 4-sided direction (0 = east, 1 = south, 2 = west, 3 = north)
unsigned char dir_symbol (unsigned char sym); // convert certain symbols from north-facing variant into current dir facing
long dir_symbol (long sym); // convert certain symbols from north-facing variant into current dir facing
int ortho_dx (int od); // return dx for point at "od" distance in orthogonal direction
int ortho_dy (int od); // return dy for point at "od" distance in orthogonal direction
bool mostly_vertical (); // return if ray is mostly vertical
Expand Down
2 changes: 1 addition & 1 deletion trap.h
Expand Up @@ -112,7 +112,7 @@ struct trapfuncm {

struct trap {
int id;
unsigned char sym;
long sym;
nc_color color;
std::string name;

Expand Down
2 changes: 1 addition & 1 deletion veh_interact.cpp
Expand Up @@ -511,7 +511,7 @@ void veh_interact::display_veh ()
for (int ep = 0; ep < veh->external_parts.size(); ep++)
{
int p = veh->external_parts[ep];
unsigned char sym = veh->part_sym (p);
long sym = veh->part_sym (p);
nc_color col = veh->part_color (p);
int y = -(veh->parts[p].mount_dx + ddx);
int x = veh->parts[p].mount_dy + ddy;
Expand Down
2 changes: 1 addition & 1 deletion veh_type.h
Expand Up @@ -125,7 +125,7 @@ enum vpart_flags
struct vpart_info
{
const char *name; // part name
unsigned char sym; // symbol of part as if it's looking north
long sym; // symbol of part as if it's looking north
nc_color color; // color
char sym_broken; // symbol of broken part as if it's looking north
nc_color color_broken; // color of broken part
Expand Down

0 comments on commit 8e9c0bb

Please sign in to comment.