Skip to content

Commit

Permalink
Typified editmap (CleverRaven#73713)
Browse files Browse the repository at this point in the history
* typified editmap

* removed generated junk file

* this doesn't work

* Update src/line.cpp

Co-authored-by: Jianxiang Wang (王健翔) <[email protected]>

* sorted out line_to

* unnaming dummy parameter

* Update src/coordinates.h

Co-authored-by: Jianxiang Wang (王健翔) <[email protected]>

* Update src/coordinates.h

Co-authored-by: Jianxiang Wang (王健翔) <[email protected]>

* Update src/line.cpp

Co-authored-by: Jianxiang Wang (王健翔) <[email protected]>

* Update src/line.h

Co-authored-by: Jianxiang Wang (王健翔) <[email protected]>

* Update src/coordinates.h

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Nicer parameter name

---------

Co-authored-by: Jianxiang Wang (王健翔) <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored May 14, 2024
1 parent 24f989c commit 7467c42
Show file tree
Hide file tree
Showing 18 changed files with 301 additions and 184 deletions.
4 changes: 2 additions & 2 deletions src/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ void draw_bullet_curses( map &m, const tripoint_bub_ms &t, const char bullet,

shared_ptr_fast<game::draw_callback_t> bullet_cb = make_shared_fast<game::draw_callback_t>( [&]() {
if( p != nullptr && p->z() == vp.z() ) {
m.drawsq( g->w_terrain, *p, drawsq_params().center( vp.raw() ) );
m.drawsq( g->w_terrain, *p, drawsq_params().center( vp ) );
}
mvwputch( g->w_terrain, t.xy().raw() - vp.xy().raw() + point( POSX, POSY ), c_red, bullet );
} );
Expand Down Expand Up @@ -693,7 +693,7 @@ void draw_line_curses( game &g, const tripoint_bub_ms &center,

avatar &player_character = get_avatar();
map &here = get_map();
drawsq_params params = drawsq_params().highlight( true ).center( center.raw() );
drawsq_params params = drawsq_params().highlight( true ).center( center );
creature_tracker &creatures = get_creature_tracker();
for( const tripoint_bub_ms &p : ret ) {
const Creature *critter = creatures.creature_at( p, true );
Expand Down
13 changes: 0 additions & 13 deletions src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4414,15 +4414,6 @@ void cata_tiles::init_explosion( const tripoint_bub_ms &p, int radius )
exp_pos = p;
exp_rad = radius;
}
void cata_tiles::init_custom_explosion_layer( const std::map<tripoint, explosion_tile> &layer )
{
do_draw_custom_explosion = true;
std::map<tripoint_bub_ms, explosion_tile> temp;
for( const auto &it : layer ) {
temp.insert( std::pair<tripoint_bub_ms, explosion_tile>( tripoint_bub_ms( it.first ), it.second ) );
}
custom_explosion_layer = temp;
}
void cata_tiles::init_custom_explosion_layer( const std::map<tripoint_bub_ms, explosion_tile>
&layer )
{
Expand Down Expand Up @@ -4455,10 +4446,6 @@ void cata_tiles::init_draw_cursor( const tripoint_bub_ms &p )
do_draw_cursor = true;
cursors.emplace_back( p );
}
void cata_tiles::init_draw_highlight( const tripoint &p )
{
cata_tiles::init_draw_highlight( tripoint_bub_ms( p ) );
}
void cata_tiles::init_draw_highlight( const tripoint_bub_ms &p )
{
do_draw_highlight = true;
Expand Down
4 changes: 0 additions & 4 deletions src/cata_tiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,6 @@ class cata_tiles
void draw_explosion_frame();
void void_explosion();

// TODO: Get rid of untyped overload
void init_custom_explosion_layer( const std::map<tripoint, explosion_tile> &layer );
void init_custom_explosion_layer( const std::map<tripoint_bub_ms, explosion_tile> &layer );
void draw_custom_explosion_frame();
void void_custom_explosion();
Expand All @@ -613,8 +611,6 @@ class cata_tiles
void draw_cursor();
void void_cursor();

// TODO: Get rid of untyped overload
void init_draw_highlight( const tripoint &p );
void init_draw_highlight( const tripoint_bub_ms &p );
void draw_highlight();
void void_highlight();
Expand Down
27 changes: 23 additions & 4 deletions src/coordinates.h
Original file line number Diff line number Diff line change
Expand Up @@ -793,12 +793,14 @@ direction direction_from( const coords::coord_point<Point, Origin, Scale, LhsInB
return direction_from( loc1.raw(), loc2.raw() );
}

template<typename Point, coords::origin Origin, coords::scale Scale, bool LhsInBounds, bool RhsInBounds>
std::vector < coords::coord_point < Point, Origin, Scale, LhsInBounds &&RhsInBounds >>
template<typename Point, coords::origin Origin, coords::scale Scale, bool LhsInBounds, bool RhsInBounds,
std::enable_if_t<std::is_same_v<Point, point>, int> = 0>
std::vector < coords::coord_point < Point, Origin, Scale, LhsInBounds && RhsInBounds >>
line_to( const coords::coord_point<Point, Origin, Scale, LhsInBounds> &loc1,
const coords::coord_point<Point, Origin, Scale, RhsInBounds> &loc2 )
const coords::coord_point<Point, Origin, Scale, RhsInBounds> &loc2,
const int t = 0 )
{
std::vector<Point> raw_result = line_to( loc1.raw(), loc2.raw() );
std::vector<Point> raw_result = line_to( loc1.raw(), loc2.raw(), t );
std::vector < coords::coord_point < Point, Origin, Scale, LhsInBounds &&RhsInBounds >> result;
std::transform( raw_result.begin(), raw_result.end(), std::back_inserter( result ),
[]( const Point & p ) {
Expand All @@ -808,6 +810,23 @@ std::vector < coords::coord_point < Point, Origin, Scale, LhsInBounds &&RhsInBou
return result;
}

template<typename Tripoint, coords::origin Origin, coords::scale Scale, bool LhsInBounds, bool RhsInBounds,
std::enable_if_t<std::is_same_v<Tripoint, tripoint>, int> = 0>
std::vector < coords::coord_point < Tripoint, Origin, Scale, LhsInBounds && RhsInBounds >>
line_to( const coords::coord_point<Tripoint, Origin, Scale, LhsInBounds> &loc1,
const coords::coord_point<Tripoint, Origin, Scale, RhsInBounds> &loc2,
const int t = 0, const int t2 = 0 )
{
std::vector<Tripoint> raw_result = line_to( loc1.raw(), loc2.raw(), t, t2 );
std::vector < coords::coord_point < Tripoint, Origin, Scale, LhsInBounds &&RhsInBounds >> result;
std::transform( raw_result.begin(), raw_result.end(), std::back_inserter( result ),
[]( const Tripoint & p ) {
return coords::coord_point < Tripoint, Origin, Scale, LhsInBounds &&
RhsInBounds >::make_unchecked( p );
} );
return result;
}

template<typename Point, coords::origin Origin, coords::scale Scale, bool LhsInBounds, bool RhsInBounds>
coords::coord_point < Point, Origin, Scale, LhsInBounds &&RhsInBounds >
midpoint( const coords::coord_point<Point, Origin, Scale, LhsInBounds> &loc1,
Expand Down
4 changes: 2 additions & 2 deletions src/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2983,9 +2983,9 @@ units::mass Creature::weight_capacity() const
/*
* Drawing-related functions
*/
void Creature::draw( const catacurses::window &w, const point &origin, bool inverted ) const
void Creature::draw( const catacurses::window &w, const point_bub_ms &origin, bool inverted ) const
{
draw( w, tripoint( origin, posz() ), inverted );
draw( w, tripoint_bub_ms( origin, posz() ), inverted );
}

void Creature::draw( const catacurses::window &w, const tripoint &origin, bool inverted ) const
Expand Down
2 changes: 1 addition & 1 deletion src/creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ class Creature : public viewer
virtual std::unordered_set<tripoint> get_path_avoid() const = 0;

bool underwater;
void draw( const catacurses::window &w, const point &origin, bool inverted ) const;
void draw( const catacurses::window &w, const point_bub_ms &origin, bool inverted ) const;
// TODO: Get rid of the untyped overload
void draw( const catacurses::window &w, const tripoint &origin, bool inverted ) const;
void draw( const catacurses::window &w, const tripoint_bub_ms &origin, bool inverted ) const;
Expand Down
5 changes: 5 additions & 0 deletions src/debug_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
#include <string>
#include <string_view>

#include "coordinates.h"

class Character;
class Creature;
struct tripoint;

template <typename E> struct enum_traits;

namespace debug_menu
Expand Down Expand Up @@ -113,7 +116,9 @@ enum class debug_menu_index : int {

void wisheffect( Creature &p );
void wishitem( Character *you = nullptr );
// TODO: Get rid of untyped overload
void wishitem( Character *you, const tripoint & );
void wishitem( Character *you, const tripoint_bub_ms & );
void wishmonster( const std::optional<tripoint> &p );
void wishmutate( Character *you );
void wishbionics( Character *you );
Expand Down
Loading

0 comments on commit 7467c42

Please sign in to comment.