1,413 bionics.cpp

Large diffs are not rendered by default.

@@ -231,8 +231,6 @@ DebugLog() << "Buffer Surface-- Width: " << buffer->w << " Height: " << buffer->
}

(*tile_values)[tilecount++] = this_tile;


}
}
DebugLog() << "Tiles Created: " << tilecount << "\n";
@@ -598,6 +596,12 @@ bool cata_tiles::draw_from_id_string(std::string id, int x, int y, int subtile,
*/
}

// make sure we aren't going to rotate the tile if it shouldn't be rotated
if (!display_tile->rotates)
{
rota = 0;
}

// translate from player-relative to screen relative tile position
int screen_x;// = (x - o_x) * tile_width;
int screen_y;// = (y - o_y) * tile_height;
@@ -806,12 +810,23 @@ bool cata_tiles::draw_terrain(int x, int y)

char alteration = 0;
int subtile = 0, rotation = 0;
// removed any special case things for making stuff rotate for now

// check walls
if (s == LINE_XOXO /*vertical*/ || s == LINE_OXOX /*horizontal*/)
{
get_wall_values(x, y, LINE_XOXO, LINE_OXOX, subtile, rotation);
wallchange = true;
}
// check windows and doors for wall connections, may or may not have a subtile available, but should be able to rotate to some extent
else if (s == '"' || s == '+' || s == '\'')
{
get_wall_values(x, y, LINE_XOXO, LINE_OXOX, subtile, rotation);
}
else
{
get_terrain_orientation(x, y, rotation, subtile);
// do something to get other terrain orientation values
}

std::string tname;

@@ -827,20 +842,23 @@ bool cata_tiles::draw_furniture(int x, int y)
if (!has_furn) return false;

int f_id = g->m.furn(x,y);
// get the name of this furniture piece
std::string f_name = furn_names[f_id]; // replace with furniture names array access

return draw_from_id_string(f_name, x, y, 0, 0); // for now just draw it normally, add in rotations later
/*
// get the tile that exists here
tile_id_iterator it = tile_ids->find(f_name);
// for rotation inforomation
const int neighborhood[4] =
{
g->m.furn(x, y+1), // south
g->m.furn(x+1, y), // east
g->m.furn(x-1, y), // west
g->m.furn(x, y-1) // north
};

if (it == tile_ids->end()) return false;
int subtile = 0, rotation = 0;
get_tile_values(f_id, neighborhood, subtile, rotation);

tile_type *furn_tile = it->second;
// make sure tile exists
if (!furn_tile) return false;
*/
// get the name of this furniture piece
std::string f_name = furn_names[f_id]; // replace with furniture names array access

return draw_from_id_string(f_name, x, y, subtile, rotation); // for now just draw it normally, add in rotations later
}

bool cata_tiles::draw_trap(int x, int y)
@@ -850,7 +868,18 @@ bool cata_tiles::draw_trap(int x, int y)

std::string tr_name = trap_names[tr_id];

return draw_from_id_string(tr_name, x, y, 0, 0);
const int neighborhood[4] =
{
g->m.tr_at(x, y+1), // south
g->m.tr_at(x+1, y), // east
g->m.tr_at(x-1, y), // west
g->m.tr_at(x, y-1) // north
};

int subtile = 0, rotation = 0;
get_tile_values(tr_id, neighborhood, subtile, rotation);

return draw_from_id_string(tr_name, x, y, subtile, rotation);
}

bool cata_tiles::draw_field_or_item(int x, int y)
@@ -864,7 +893,20 @@ bool cata_tiles::draw_field_or_item(int x, int y)
if (!do_item)
{
std::string fd_name = field_names[f.fieldSymbol()];
return draw_from_id_string(fd_name, x, y, 0, 0);

// for rotation inforomation
const int neighborhood[4] =
{
g->m.field_at(x, y+1).fieldSymbol(), // south
g->m.field_at(x+1, y).fieldSymbol(), // east
g->m.field_at(x-1, y).fieldSymbol(), // west
g->m.field_at(x, y-1).fieldSymbol() // north
};

int subtile = 0, rotation = 0;
get_tile_values(f.fieldSymbol(), neighborhood, subtile, rotation);

return draw_from_id_string(fd_name, x, y, subtile, rotation);
}
else
{
@@ -1207,7 +1249,7 @@ LIGHTING cata_tiles::light_at(int x, int y)
return HIDDEN;
}

void cata_tiles::get_terrain_orientation(int x, int y, int& rota, int* subtile)
void cata_tiles::get_terrain_orientation(int x, int y, int& rota, int& subtile)
{
// get terrain at x,y
ter_id tid = g->m.ter(x, y);
@@ -1221,35 +1263,34 @@ void cata_tiles::get_terrain_orientation(int x, int y, int& rota, int* subtile)


// get terrain neighborhood
ter_id *t_neighbors = new ter_id[4];

}
void cata_tiles::get_wall_values(const int x, const int y, const long vertical_wall_symbol, const long horizontal_wall_symbol, int& subtile, int& rotation)
{
// makes the assumption that x,y is a wall of some sort
const long neighborhood[4] = {
terlist[g->m.ter(x, y+1)].sym, // south
terlist[g->m.ter(x+1, y)].sym, // east
terlist[g->m.ter(x-1, y)].sym, // west
terlist[g->m.ter(x, y-1)].sym // north
};

bool connects[4];
const ter_id neighborhood[4] =
{
g->m.ter(x, y+1), // south
g->m.ter(x+1, y), // east
g->m.ter(x-1, y), // west
g->m.ter(x, y-1) // north
};

char val = 0;
int num_connects = 0;
bool connects[4];
char val = 0;
int num_connects = 0;

// populate connection information
// populate connection information
for (int i = 0; i < 4; ++i)
{
connects[i] = (neighborhood[i] == vertical_wall_symbol || neighborhood[i] == horizontal_wall_symbol) || (neighborhood[i] == '"' || neighborhood[i] == '+' || neighborhood[i] == '\'');
connects[i] = (neighborhood[i] == tid);

if (connects[i])
{
++num_connects;
val += 1 << i;
}
}

get_rotation_and_subtile(val, num_connects, rota, subtile);
}
void cata_tiles::get_rotation_and_subtile(const char val, const int num_connects, int &rotation, int &subtile)
{
switch(num_connects)
{
case 0: rotation = 0; subtile = unconnected; break;
@@ -1287,6 +1328,34 @@ void cata_tiles::get_wall_values(const int x, const int y, const long vertical_w
}
break;
}
}
void cata_tiles::get_wall_values(const int x, const int y, const long vertical_wall_symbol, const long horizontal_wall_symbol, int& subtile, int& rotation)
{
// makes the assumption that x,y is a wall | window | door of some sort
const long neighborhood[4] = {
terlist[g->m.ter(x, y+1)].sym, // south
terlist[g->m.ter(x+1, y)].sym, // east
terlist[g->m.ter(x-1, y)].sym, // west
terlist[g->m.ter(x, y-1)].sym // north
};

bool connects[4];

char val = 0;
int num_connects = 0;

// populate connection information
for (int i = 0; i < 4; ++i)
{
connects[i] = (neighborhood[i] == vertical_wall_symbol || neighborhood[i] == horizontal_wall_symbol) || (neighborhood[i] == '"' || neighborhood[i] == '+' || neighborhood[i] == '\'');

if (connects[i])
{
++num_connects;
val += 1 << i;
}
}
get_rotation_and_subtile(val, num_connects, rotation, subtile);
//DebugLog() << "Expected Wall Tile: <" << multitile_keys[subtile] << "-" << rotation << "> at <" << x << ", " << y << ">\n";
}

@@ -1304,42 +1373,6 @@ void cata_tiles::get_tile_values(const int t, const int *tn, int &subtile, int &
val += 1 << i;
}
}
switch(num_connects)
{
case 0: rotation = 0; subtile = unconnected; break;
case 4: rotation = 0; subtile = center; break;
case 1: // all end pieces
subtile = end_piece;
switch(val)
{
case 8: rotation = 0; break;
case 4: rotation = 3; break;
case 2: rotation = 1; break;
case 1: rotation = 2; break;
}
break;
case 2:
switch(val)
{// edges
case 9: subtile = edge; rotation = 0; break;
case 6: subtile = edge; rotation = 1; break;
// corners
case 12: subtile = corner; rotation = 0; break;
case 10: subtile = corner; rotation = 1; break;
case 3: subtile = corner; rotation = 2; break;
case 5: subtile = corner; rotation = 3; break;
}
break;
case 3: // all t_connections
subtile = t_connection;
switch(val)
{
case 14: rotation = 0; break;
case 11: rotation = 1; break;
case 7: rotation = 2; break;
case 13: rotation = 3; break;
}
break;
}
get_rotation_and_subtile(val, num_connects, rotation, subtile);
}
#endif // SDL_TILES
@@ -6,7 +6,6 @@
//#include <windows.h>
#include "SDL.h"
#include "SDL_ttf.h"
#include "SDL_image.h"
#else
#include <wordexp.h>
#if (defined OSX_SDL_FW)
@@ -127,8 +126,11 @@ class cata_tiles
Uint32 get_pixel(SDL_Surface *surface, int x, int y);
/* Tile Picking */
void get_tile_values(const int t, const int *tn, int &subtile, int &rotation);

void get_wall_values(const int x, const int y, const long vertical_wall_symbol, const long horizontal_wall_symbol, int &subtile, int &rotation);
void get_terrain_orientation(int x, int y, int &rota, int *subtype);
void get_terrain_orientation(int x, int y, int &rota, int &subtype);

void get_rotation_and_subtile(const char val, const int num_connects, int &rota, int &subtype);

/** Drawing Layers */
bool draw_lighting(int x, int y, LIGHTING l);

Large diffs are not rendered by default.

3,348 crafting.cpp

Large diffs are not rendered by default.

@@ -3964,17 +3964,18 @@
"revert_to": "null",
"use_action": "DEJAR"
},

{
"id": "jar_kompot",
"type": "TOOL",
"symbol": ")",
"color": "red",
"name": "sealed 3-litre jar of kompot",
"description": "A sealed glass jar containing kompot. Activate to open and enjoy.",
"rarity": 0,
"price": 80,
"material": ["glass", "water"],
"weight": 3365,
"weight": 3,
"volume": 2,
"bashing": 8,
"cutting": 1,
@@ -5076,36 +5076,7 @@ void game::explosion(int x, int y, int power, int shrapnel, bool has_fire)
}
}
}
/*
void game::draw_explosion(int x, int y, int radius, nc_color col)
{
timespec ts; // Timespec for the animation of the explosion
ts.tv_sec = 0;
ts.tv_nsec = EXPLOSION_SPEED;
for (int i = 1; i <= radius; i++) {
mvwputch(w_terrain, y - i + VIEWY - u.posy - u.view_offset_y,
x - i + VIEWX - u.posx - u.view_offset_x, col, '/');
mvwputch(w_terrain, y - i + VIEWY - u.posy - u.view_offset_y,
x + i + VIEWX - u.posx - u.view_offset_x, col,'\\');
mvwputch(w_terrain, y + i + VIEWY - u.posy - u.view_offset_y,
x - i + VIEWX - u.posx - u.view_offset_x, col,'\\');
mvwputch(w_terrain, y + i + VIEWY - u.posy - u.view_offset_y,
x + i + VIEWX - u.posx - u.view_offset_x, col, '/');
for (int j = 1 - i; j < 0 + i; j++) {
mvwputch(w_terrain, y - i + VIEWY - u.posy - u.view_offset_y,
x + j + VIEWX - u.posx - u.view_offset_x, col,'-');
mvwputch(w_terrain, y + i + VIEWY - u.posy - u.view_offset_y,
x + j + VIEWX - u.posx - u.view_offset_x, col,'-');
mvwputch(w_terrain, y + j + VIEWY - u.posy - u.view_offset_y,
x - i + VIEWX - u.posx - u.view_offset_x, col,'|');
mvwputch(w_terrain, y + j + VIEWY - u.posy - u.view_offset_y,
x + i + VIEWX - u.posx - u.view_offset_x, col,'|');
}
wrefresh(w_terrain);
nanosleep(&ts, NULL);
}
}
*/

void game::flashbang(int x, int y, bool player_immune)
{
int dist = rl_dist(u.posx, u.posy, x, y), t;
1,271 itypedef.cpp

Large diffs are not rendered by default.

@@ -604,7 +604,7 @@ void game::throw_item(player &p, int tarx, int tary, item &thrown,
m.add_item_or_charges(tx, ty, thrown);
}
}

// TODO: Shunt redundant drawing code elsewhere
std::vector<point> game::target(int &x, int &y, int lowx, int lowy, int hix,
int hiy, std::vector <monster> t, int &target,
item *relevent)
@@ -696,8 +696,9 @@ std::vector<point> game::target(int &x, int &y, int lowx, int lowy, int hix,
for (int j = 1; j < getmaxx(w_target) - 2; j++)
mvwputch(w_target, i, j, c_white, ' ');
}
m.build_map_cache(this);
m.draw(this, w_terrain, center);
/* Start drawing w_terrain things -- possibly move out to centralized draw_terrain_window function as they all should be roughly similar*/
m.build_map_cache(this); // part of the SDLTILES drawing code
m.draw(this, w_terrain, center); // embedded in SDL drawing code
// Draw the Monsters
for (int i = 0; i < num_zombies(); i++) {
if (u_see(&(zombie(i)))) {
@@ -760,6 +761,7 @@ std::vector<point> game::target(int &x, int &y, int lowx, int lowy, int hix,
refresh();
ch = input();
get_direction(this, tarx, tary, ch);
/* More drawing to terrain */
if (tarx != -2 && tary != -2 && ch != '.') { // Direction character pressed
int mondex = mon_at(x, y), npcdex = npc_at(x, y);
if (mondex != -1 && u_see(&(zombie(mondex))))
@@ -29,9 +29,11 @@
#if (defined OSX_SDL_FW)
#include "SDL.h"
#include "SDL_ttf/SDL_ttf.h"
#include "SDL_image/SDL_image.h" // Make sure to add this to the other OS inclusions
#else
#include "SDL/SDL.h"
#include "SDL/SDL_ttf.h"
#include "SDL/SDL_image.h" // Make sure to add this to the other OS inclusions
#endif
#endif

@@ -333,7 +335,7 @@ void curses_drawwindow(WINDOW *win)
update_rect.y = win->y*fontheight;
update_rect.h = win->height*fontheight;
//GfxDraw(thegame, win->x*fontwidth, win->y*fontheight, thegame->terrain_view_x, thegame->terrain_view_y, win->width*fontwidth, win->height*fontheight);
tilecontext->draw(win->x * fontwidth, win->y * fontheight, g->u.posx, g->u.posy, win->width * fontwidth, win->height * fontheight);
tilecontext->draw(win->x * fontwidth, win->y * fontheight, g->ter_view_x, g->ter_view_y, win->width * fontwidth, win->height * fontheight);
}
//*/
if (update_rect.y != 9999)
2 ui.cpp
@@ -578,6 +578,8 @@ void uimenu::query(bool loop) {
} else if ( return_invalid ) {
ret = 0 - entries[ selected ].retval; // disabled
}
} else if ( keypress == 27 ) { //break loop with ESCAPE key
break;
} else {
if ( keycallback ) {
skipkey = callback->key( keypress, selected, this );