From 3958c0d156e7ef41bb462943c29c4d60627b3c7e Mon Sep 17 00:00:00 2001 From: David Carlier Date: Tue, 9 Aug 2022 22:15:46 +0100 Subject: [PATCH 1/2] few cosmetic changes and with C++17 no need to explictly define copy constructors. --- lib/xgraph/xgraph.cpp | 6 +++--- lib/xgraph/xgraph.h | 6 +++--- src/3d/3d_math.h | 16 +--------------- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/lib/xgraph/xgraph.cpp b/lib/xgraph/xgraph.cpp index 39008208..9c473505 100644 --- a/lib/xgraph/xgraph.cpp +++ b/lib/xgraph/xgraph.cpp @@ -297,11 +297,11 @@ void XGR_Screen::set_resolution(int width, int height){ create_surfaces(width, height); } -const float XGR_Screen::get_screen_scale_x() { +float XGR_Screen::get_screen_scale_x() const { return screen_scale_x; } -const float XGR_Screen::get_screen_scale_y() { +float XGR_Screen::get_screen_scale_y() const { return screen_scale_y; } @@ -343,7 +343,7 @@ void XGR_Screen::set_is_scaled_renderer(bool is_scaled_renderer) this->is_scaled_renderer = is_scaled_renderer; } -const bool XGR_Screen::get_is_scaled_renderer() +bool XGR_Screen::get_is_scaled_renderer() const { return this->is_scaled_renderer; } diff --git a/lib/xgraph/xgraph.h b/lib/xgraph/xgraph.h index 03ae28c9..df83f87a 100644 --- a/lib/xgraph/xgraph.h +++ b/lib/xgraph/xgraph.h @@ -129,9 +129,9 @@ struct XGR_Screen void set_fullscreen(bool fullscreen); void set_resolution(int width, int height); void set_is_scaled_renderer(bool is_scaled_renderer); - const bool get_is_scaled_renderer(); - const float get_screen_scale_x(); - const float get_screen_scale_y(); + bool get_is_scaled_renderer() const; + float get_screen_scale_x() const; + float get_screen_scale_y() const; void setpixel(int x,int y,int col); int getpixel(int x,int y); diff --git a/src/3d/3d_math.h b/src/3d/3d_math.h index aca91ed3..3360513a 100644 --- a/src/3d/3d_math.h +++ b/src/3d/3d_math.h @@ -316,7 +316,6 @@ struct DBV { DBV(); DBV(double u,double v,double t); - DBV(const DBV& v); DBV(const Vector& v); double operator [](unsigned int i) const { return ((double*)this)[i % 3]; } @@ -408,7 +407,6 @@ struct DBM { // Creates I DBM(); - DBM(const DBM& m); DBM(double a0,double a1,double a2, double a3,double a4,double a5, double a6,double a7,double a8); @@ -867,12 +865,6 @@ inline DBV::DBV(double u,double v,double t) y = v; z = t; } -inline DBV::DBV(const DBV& v) -{ - x = v.x; - y = v.y; - z = v.z; -} inline DBV::DBV(const Vector& v) { x = v.x; @@ -1159,12 +1151,6 @@ inline DBM::DBM() a[3] = 0; a[4] = 1; a[5] = 0; a[6] = 0; a[7] = 0; a[8] = 1; } -inline DBM::DBM(const DBM& m) -{ - a[0] = m[0]; a[1] = m[1]; a[2] = m[2]; - a[3] = m[3]; a[4] = m[4]; a[5] = m[5]; - a[6] = m[6]; a[7] = m[7]; a[8] = m[8]; -} inline DBM::DBM(double a0,double a1,double a2, double a3,double a4,double a5, double a6,double a7,double a8) @@ -1346,4 +1332,4 @@ inline DBM DBM::operator- (double w) const return m; } -#endif \ No newline at end of file +#endif From b23519ca39540c14c31e73b056101042811b409c Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 10 Aug 2022 22:31:40 +0100 Subject: [PATCH 2/2] using more C++17 facilities. --- lib/xsound/ogg_stream.cpp | 4 ++-- lib/xsound/ogg_stream.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/xsound/ogg_stream.cpp b/lib/xsound/ogg_stream.cpp index 1abb1f0e..5c14a612 100644 --- a/lib/xsound/ogg_stream.cpp +++ b/lib/xsound/ogg_stream.cpp @@ -37,8 +37,8 @@ static long stream_tell_func (void *datasource) { return ftell(file); } -OggStream::OggStream(const std::string &fname) { - _file = fopen(fname.c_str(), "rb"); +OggStream::OggStream(const std::string_view fname) { + _file = fopen(fname.data(), "rb"); if (_file == NULL) { perror("fopen"); throw std::runtime_error("cannot open file"); diff --git a/lib/xsound/ogg_stream.h b/lib/xsound/ogg_stream.h index dbe0d351..98bfc815 100644 --- a/lib/xsound/ogg_stream.h +++ b/lib/xsound/ogg_stream.h @@ -1,7 +1,7 @@ #ifndef __SAMPLE_CLUNK_OGG_STREAM_H__ #define __SAMPLE_CLUNK_OGG_STREAM_H__ -#include +#include #include #include #include @@ -18,7 +18,7 @@ namespace clunk { class OggStream : public clunk::Stream { public: - OggStream(const std::string &fname); + OggStream(const std::string_view fname); void rewind(); bool read(clunk::Buffer &data, unsigned hint); ~OggStream();