From 4961951a89cefe5b4ce5c657f628c758e685cef8 Mon Sep 17 00:00:00 2001 From: toxieainc Date: Mon, 11 Jul 2022 18:10:41 +0200 Subject: [PATCH] fix a real error (m68kdasm) and some harmless performance warnings and use modern headers --- Src/CPU/68K/Musashi/m68kdasm.c | 4 +- Src/GameLoader.cpp | 12 ++--- Src/Graphics/New3D/GLSLShader.cpp | 5 +- Src/Graphics/New3D/Model.h | 22 ++++----- Src/Graphics/New3D/PolyHeader.cpp | 8 ++-- Src/Graphics/New3D/R3DScrollFog.cpp | 4 +- Src/Graphics/New3D/R3DShader.cpp | 1 + Src/Graphics/New3D/R3DShader.h | 6 +-- Src/Graphics/New3D/TextureSheet.cpp | 2 +- Src/Graphics/New3D/Vec.cpp | 67 ++++++++------------------- Src/Inputs/InputSystem.cpp | 16 +++---- Src/Inputs/InputSystem.h | 6 +-- Src/Inputs/MultiInputSource.cpp | 2 +- Src/Model3/53C810Disasm.cpp | 6 +-- Src/Model3/93C46.cpp | 2 +- Src/Model3/DSB.cpp | 2 +- Src/Model3/Model3.cpp | 2 +- Src/Model3/Real3D.cpp | 3 +- Src/Model3/Real3D.h | 4 +- Src/Network/NetBoard.h | 2 +- Src/Network/SimNetBoard.h | 2 +- Src/Network/TCPSend.cpp | 2 +- Src/OSD/Logger.cpp | 2 +- Src/OSD/Windows/DirectInputSystem.cpp | 12 ++--- Src/Util/BitRegister.cpp | 6 +-- 25 files changed, 81 insertions(+), 119 deletions(-) diff --git a/Src/CPU/68K/Musashi/m68kdasm.c b/Src/CPU/68K/Musashi/m68kdasm.c index c396726..295057a 100644 --- a/Src/CPU/68K/Musashi/m68kdasm.c +++ b/Src/CPU/68K/Musashi/m68kdasm.c @@ -251,8 +251,8 @@ static const char* g_cpcc[64] = {/* 000 001 010 011 100 101 110 111 */ "f", "eq", "ogt", "oge", "olt", "ole", "ogl", "or", /* 000 */ "un", "ueq", "ugt", "uge", "ult", "ule", "ne", "t", /* 001 */ - "sf", "seq", "gt", "ge", "lt", "le", "gl" "gle", /* 010 */ - "ngle", "ngl", "nle", "nlt", "nge", "ngt", "sne", "st", /* 011 */ + "sf", "seq", "gt", "ge", "lt", "le", "gl", "gle", /* 010 */ + "ngle", "ngl", "nle", "nlt", "nge", "ngt", "sne","st", /* 011 */ "?", "?", "?", "?", "?", "?", "?", "?", /* 100 */ "?", "?", "?", "?", "?", "?", "?", "?", /* 101 */ "?", "?", "?", "?", "?", "?", "?", "?", /* 110 */ diff --git a/Src/GameLoader.cpp b/Src/GameLoader.cpp index 969047f..d1175ef 100644 --- a/Src/GameLoader.cpp +++ b/Src/GameLoader.cpp @@ -20,7 +20,7 @@ bool GameLoader::LoadZipArchive(ZipArchive *zip, const std::string &zipfilename) zip->zfs.push_back(zf); // Identify all files in zip archive - int err = UNZ_OK; + int err; for (err = unzGoToFirstFile(zf); err == UNZ_OK; err = unzGoToNextFile(zf)) { unz_file_info file_info; @@ -193,11 +193,11 @@ static void PopulateGameInfo(Game *game, const Util::Config::Node &game_node) game->name = game_node["name"].ValueAs(); game->parent = game_node["parent"].ValueAsDefault(std::string()); game->title = game_node["identity/title"].ValueAsDefault("Unknown"); - game->version = game_node["identity/version"].ValueAsDefault(""); + game->version = game_node["identity/version"].ValueAsDefault(std::string()); game->manufacturer = game_node["identity/manufacturer"].ValueAsDefault("Unknown"); game->year = game_node["identity/year"].ValueAsDefault(0); - game->stepping = game_node["hardware/stepping"].ValueAsDefault(""); - game->mpeg_board = game_node["hardware/mpeg_board"].ValueAsDefault(""); + game->stepping = game_node["hardware/stepping"].ValueAsDefault(std::string()); + game->mpeg_board = game_node["hardware/mpeg_board"].ValueAsDefault(std::string()); std::map audio_types { { "", Game::STEREO_LR }, // default to stereo @@ -212,7 +212,7 @@ static void PopulateGameInfo(Game *game, const Util::Config::Node &game_node) }; std::string audio_type = game_node["hardware/audio"].ValueAsDefault(std::string()); game->audio = audio_types[audio_type]; - game->pci_bridge = game_node["hardware/pci_bridge"].ValueAsDefault(""); + game->pci_bridge = game_node["hardware/pci_bridge"].ValueAsDefault(std::string()); game->real3d_pci_id = game_node["hardware/real3d_pci_id"].ValueAsDefault(0); game->real3d_status_bit_set_percent_of_frame = game_node["hardware/real3d_status_bit_set_percent_of_frame"].ValueAsDefault(0); game->encryption_key = game_node["hardware/encryption_key"].ValueAsDefault(0); @@ -849,7 +849,7 @@ std::string StripFilename(const std::string &filepath) // If none found, there is directory component here if (last_slash == std::string::npos) - return ""; + return std::string(); // Otherwise, strip everything after the slash return std::string(filepath, 0, last_slash + 1); diff --git a/Src/Graphics/New3D/GLSLShader.cpp b/Src/Graphics/New3D/GLSLShader.cpp index 0f2a358..4b27e1f 100644 --- a/Src/Graphics/New3D/GLSLShader.cpp +++ b/Src/Graphics/New3D/GLSLShader.cpp @@ -1,5 +1,5 @@ #include "GLSLShader.h" -#include +#include GLSLShader::GLSLShader() { @@ -107,6 +107,3 @@ int GLSLShader::GetAttributeLocation(const char *str) { return glGetAttribLocation(m_program, str); } - - - diff --git a/Src/Graphics/New3D/Model.h b/Src/Graphics/New3D/Model.h index 5c0e0b5..a081d29 100644 --- a/Src/Graphics/New3D/Model.h +++ b/Src/Graphics/New3D/Model.h @@ -3,9 +3,8 @@ #include #include -#include #include -#include +#include #include "Texture.h" #include "Mat4.h" @@ -32,24 +31,19 @@ struct Vertex // half vertex static bool Equal(const Vertex& p1, const Vertex& p2) { - if (p1.pos[0] == p2.pos[0] && + return (p1.pos[0] == p2.pos[0] && p1.pos[1] == p2.pos[1] && - p1.pos[2] == p2.pos[2]) - { - return true; - } - - return false; + p1.pos[2] == p2.pos[2]); } static void Average(const Vertex& p1, const Vertex& p2, Vertex& p3) { p3.pos[3] = 1.0f; //always 1 - p3.fixedShade = (p1.fixedShade + p2.fixedShade) / 2.0f; + p3.fixedShade = (p1.fixedShade + p2.fixedShade) * 0.5f; - for (int i = 0; i < 3; i++) { p3.pos[i] = (p1.pos[i] + p2.pos[i]) / 2.0f; } - for (int i = 0; i < 3; i++) { p3.normal[i] = (p1.normal[i] + p2.normal[i]) / 2.0f; } - for (int i = 0; i < 2; i++) { p3.texcoords[i] = (p1.texcoords[i] + p2.texcoords[i]) / 2.0f; } + for (int i = 0; i < 3; i++) { p3.pos[i] = (p1.pos[i] + p2.pos[i]) * 0.5f; } + for (int i = 0; i < 3; i++) { p3.normal[i] = (p1.normal[i] + p2.normal[i]) * 0.5f; } + for (int i = 0; i < 2; i++) { p3.texcoords[i] = (p1.texcoords[i] + p2.texcoords[i]) * 0.5f; } } }; @@ -265,4 +259,4 @@ struct Node } // New3D -#endif \ No newline at end of file +#endif diff --git a/Src/Graphics/New3D/PolyHeader.cpp b/Src/Graphics/New3D/PolyHeader.cpp index f8322d7..eb6f230 100644 --- a/Src/Graphics/New3D/PolyHeader.cpp +++ b/Src/Graphics/New3D/PolyHeader.cpp @@ -117,7 +117,7 @@ int PolyHeader::NumVerts() int PolyHeader::NumSharedVerts() { - int sharedVerts[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; + static const int sharedVerts[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; return sharedVerts[header[0] & 0xf]; } @@ -135,9 +135,9 @@ bool PolyHeader::SharedVertex(int vertex) void PolyHeader::FaceNormal(float n[3]) { - n[0] = (float)(((INT32)header[1]) >> 8) * (1.0f / 4194304.0f); - n[1] = (float)(((INT32)header[2]) >> 8) * (1.0f / 4194304.0f); - n[2] = (float)(((INT32)header[3]) >> 8) * (1.0f / 4194304.0f); + n[0] = (float)(((INT32)header[1]) >> 8) * (float)(1.0 / 4194304.0); + n[1] = (float)(((INT32)header[2]) >> 8) * (float)(1.0 / 4194304.0); + n[2] = (float)(((INT32)header[3]) >> 8) * (float)(1.0 / 4194304.0); } float PolyHeader::UVScale() diff --git a/Src/Graphics/New3D/R3DScrollFog.cpp b/Src/Graphics/New3D/R3DScrollFog.cpp index 262ebda..aa57f4a 100644 --- a/Src/Graphics/New3D/R3DScrollFog.cpp +++ b/Src/Graphics/New3D/R3DScrollFog.cpp @@ -43,7 +43,7 @@ void main() position = spotEllipse.xy; size = spotEllipse.zw; ellipse = length((gl_FragCoord.xy - position) / size); - ellipse = pow(ellipse, 2.0); // decay rate = square of distance from center + ellipse = ellipse * ellipse; // decay rate = square of distance from center ellipse = 1.0 - ellipse; // invert ellipse = max(0.0, ellipse); // clamp @@ -149,4 +149,4 @@ void R3DScrollFog::DeallocResources() m_vbo.Destroy(); } -} \ No newline at end of file +} diff --git a/Src/Graphics/New3D/R3DShader.cpp b/Src/Graphics/New3D/R3DShader.cpp index 6797650..1356be8 100644 --- a/Src/Graphics/New3D/R3DShader.cpp +++ b/Src/Graphics/New3D/R3DShader.cpp @@ -134,6 +134,7 @@ GLint R3DShader::GetVertexAttribPos(const std::string& attrib) if (m_vertexLocCache.count(attrib)==0) { auto pos = glGetAttribLocation(m_shaderProgram, attrib.c_str()); m_vertexLocCache[attrib] = pos; + return pos; } return m_vertexLocCache[attrib]; diff --git a/Src/Graphics/New3D/R3DShader.h b/Src/Graphics/New3D/R3DShader.h index e152722..226dddf 100644 --- a/Src/Graphics/New3D/R3DShader.h +++ b/Src/Graphics/New3D/R3DShader.h @@ -4,7 +4,7 @@ #include #include "Util/NewConfig.h" #include "Model.h" -#include +#include #include namespace New3D { @@ -109,11 +109,11 @@ private: GLint m_locDiscardAlpha; // vertex attribute position cache - std::map m_vertexLocCache; + std::unordered_map m_vertexLocCache; }; } // New3D -#endif \ No newline at end of file +#endif diff --git a/Src/Graphics/New3D/TextureSheet.cpp b/Src/Graphics/New3D/TextureSheet.cpp index 979147d..1bb206c 100644 --- a/Src/Graphics/New3D/TextureSheet.cpp +++ b/Src/Graphics/New3D/TextureSheet.cpp @@ -4,7 +4,7 @@ namespace New3D { TextureSheet::TextureSheet() { - m_temp.resize(1024 * 1024 * 4); // temporay buffer for textures + m_temp.resize(1024 * 1024 * 4); // temporary buffer for textures } int TextureSheet::ToIndex(int x, int y) diff --git a/Src/Graphics/New3D/Vec.cpp b/Src/Graphics/New3D/Vec.cpp index ee63676..b7803f1 100644 --- a/Src/Graphics/New3D/Vec.cpp +++ b/Src/Graphics/New3D/Vec.cpp @@ -1,33 +1,9 @@ #include "Vec.h" #include +#include namespace New3D { -static float fastSqrt(float number) { - long i; - float x, y; - const float f = 1.5F; - - x = number * 0.5F; - y = number; - i = * ( long * ) &y; - i = 0x5f375a86 - ( i >> 1 ); - y = * ( float * ) &i; - y = y * ( f - ( x * y * y ) ); - y = y * ( f - ( x * y * y ) ); - return number * y; -} - -static float fastInvSqrt(float x) -{ - float xhalf = 0.5f*x; - int i = *(int*)&x; // get bits for floating value - i = 0x5f375a86- (i>>1); // gives initial guess y0 - x = *(float*)&i; // convert bits back to float - x = x*(1.5f-xhalf*x*x); // Newton step, repeating increases accuracy - return x; -} - void V3::subtract(const Vec3 a, const Vec3 b, Vec3 out) { out[0] = a[0] - b[0]; @@ -58,7 +34,7 @@ void V3::add(Vec3 a, const Vec3 b) { void V3::divide(Vec3 a, float number) { - multiply(a,1/number); + multiply(a,1.f/number); } void V3::multiply(Vec3 a, float number) { @@ -123,13 +99,13 @@ float V3::length(const Vec3 v) { void V3::normalise(Vec3 v) { //======== - float len; + float inv_len; //======== - len = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; - len = fastInvSqrt(len); + inv_len = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; + inv_len = 1.f/std::sqrt(inv_len); - multiply(v,len); + multiply(v,inv_len); } void V3::multiplyAdd(const Vec3 a, float scale, const Vec3 b, Vec3 out) { @@ -141,9 +117,9 @@ void V3::multiplyAdd(const Vec3 a, float scale, const Vec3 b, Vec3 out) { void V3::reset(Vec3 v) { - v[0] = 0; - v[1] = 0; - v[2] = 0; + v[0] = 0.f; + v[1] = 0.f; + v[2] = 0.f; } void V3::set(Vec3 v, float value) { @@ -171,7 +147,7 @@ void V3::reflect(const Vec3 a, const Vec3 b, Vec3 out) { V3::copy(a,v); - temp = V3::dotProduct(a,b) * 2; + temp = V3::dotProduct(a,b) * 2.f; V3::multiply(v,temp); V3::subtract(b,v,out); @@ -191,16 +167,16 @@ void V3::createNormal(const Vec3 a, const Vec3 b, const Vec3 c, Vec3 outNormal) void V3::_max(Vec3 a, const Vec3 compare) { - if(a[0] < compare[0]) a[0] = compare[0]; - if(a[1] < compare[1]) a[1] = compare[1]; - if(a[2] < compare[2]) a[2] = compare[2]; + a[0] = std::max(compare[0], a[0]); + a[1] = std::max(compare[1], a[1]); + a[2] = std::max(compare[2], a[2]); } void V3::_min(Vec3 a, const Vec3 compare) { - if(a[0] > compare[0]) a[0] = compare[0]; - if(a[1] > compare[1]) a[1] = compare[1]; - if(a[2] > compare[2]) a[2] = compare[2]; + a[0] = std::min(compare[0], a[0]); + a[1] = std::min(compare[1], a[1]); + a[2] = std::min(compare[2], a[2]); } bool V3::cmp(const Vec3 a, float b) { @@ -223,14 +199,9 @@ bool V3::cmp(const Vec3 a, const Vec3 b) { void V3::clamp(Vec3 a, float _min, float _max) { - if(a[0] < _min) a[0] = _min; - if(a[0] > _max) a[0] = _max; - - if(a[1] < _min) a[1] = _min; - if(a[1] > _max) a[1] = _max; - - if(a[2] < _min) a[2] = _min; - if(a[2] > _max) a[2] = _max; + a[0] = std::min(std::max(_min, a[0]), _max); + a[1] = std::min(std::max(_min, a[1]), _max); + a[2] = std::min(std::max(_min, a[2]), _max); } } // New3D diff --git a/Src/Inputs/InputSystem.cpp b/Src/Inputs/InputSystem.cpp index baa2fa2..2eb6910 100644 --- a/Src/Inputs/InputSystem.cpp +++ b/Src/Inputs/InputSystem.cpp @@ -724,7 +724,7 @@ void CInputSystem::CheckKeySources(int kbdNum, bool fullAxisOnly, vector> num).fail(); @@ -813,7 +813,7 @@ string CInputSystem::IntToString(int num) return ss.str(); } -bool CInputSystem::EqualsIgnoreCase(string str1, const char *str2) +bool CInputSystem::EqualsIgnoreCase(const string& str1, const char *str2) { for (string::const_iterator ci = str1.begin(); ci < str1.end(); ++ci) { @@ -824,7 +824,7 @@ bool CInputSystem::EqualsIgnoreCase(string str1, const char *str2) return *str2 == '\0'; } -bool CInputSystem::StartsWithIgnoreCase(string str1, const char *str2) +bool CInputSystem::StartsWithIgnoreCase(const string& str1, const char *str2) { for (string::const_iterator ci = str1.begin(); ci < str1.end(); ++ci) { @@ -1023,7 +1023,7 @@ CInputSource *CInputSystem::ParseSingleSource(string str) if (rightSource != NULL) sources.push_back(rightSource); } - if (sources.size() > 0) + if (!sources.empty()) return new CMultiInputSource(true, sources); } return m_emptySource; @@ -1772,7 +1772,7 @@ bool CInputSystem::ReadMapping(char *buffer, unsigned bufSize, bool fullAxisOnly CheckAllSources(readFlags, fullAxisOnly, mseCentered, sources, mapping, badSources); // When some inputs have been activated, keep looping until they have all been released again. - if (sources.size() > 0) + if (!sources.empty()) { // Check each source is no longer active bool active = false; diff --git a/Src/Inputs/InputSystem.h b/Src/Inputs/InputSystem.h index e92abb9..6cc47fd 100644 --- a/Src/Inputs/InputSystem.h +++ b/Src/Inputs/InputSystem.h @@ -420,13 +420,13 @@ private: */ void CheckJoySources(int joyNum, bool fullAxisOnly, std::vector &sources, std::string &mapping, std::vector &badSources); - bool ParseInt(std::string str, int &num); + bool ParseInt(const std::string& str, int &num); std::string IntToString(int num); - bool EqualsIgnoreCase(std::string str1, const char *str2); + bool EqualsIgnoreCase(const std::string& str1, const char *str2); - bool StartsWithIgnoreCase(std::string str1, const char *str2); + bool StartsWithIgnoreCase(const std::string& str1, const char *str2); /* * Returns true if the given string represents a valid key name. diff --git a/Src/Inputs/MultiInputSource.cpp b/Src/Inputs/MultiInputSource.cpp index fc22df0..a2f4d34 100644 --- a/Src/Inputs/MultiInputSource.cpp +++ b/Src/Inputs/MultiInputSource.cpp @@ -36,7 +36,7 @@ using namespace std; ESourceType CMultiInputSource::GetCombinedType(vector &sources) { // Check if vector is empty - if (sources.size() == 0) + if (sources.empty()) return SourceEmpty; // Otherwise, see whether all sources are switches, or if have a full- or half-axis present bool allSwitches = true; diff --git a/Src/Model3/53C810Disasm.cpp b/Src/Model3/53C810Disasm.cpp index b52a6a4..056280e 100644 --- a/Src/Model3/53C810Disasm.cpp +++ b/Src/Model3/53C810Disasm.cpp @@ -29,10 +29,10 @@ * be decoded incorrectly. */ -#include -#include +#include +#include #ifdef STANDALONE -#include +#include #endif #include "Types.h" diff --git a/Src/Model3/93C46.cpp b/Src/Model3/93C46.cpp index 160af3c..004fbf4 100644 --- a/Src/Model3/93C46.cpp +++ b/Src/Model3/93C46.cpp @@ -33,7 +33,7 @@ #include "93C46.h" -#include +#include #include "Supermodel.h" diff --git a/Src/Model3/DSB.cpp b/Src/Model3/DSB.cpp index ff64da0..07ba077 100644 --- a/Src/Model3/DSB.cpp +++ b/Src/Model3/DSB.cpp @@ -143,7 +143,7 @@ int CDSBResampler::UpSampleAndMix(INT16 *outL, INT16 *outR, INT16 *inL, INT16 *i int outIdx = 0; int inIdx = 0; INT32 leftSample, rightSample, leftSoundSample, rightSoundSample; - INT32 v[2], musicVol, soundVol; + INT32 v[2], musicVol; // Obtain program volume settings and convert to 24.8 fixed point (0-200 -> 0x00-0x200) musicVol = m_config["MusicVolume"].ValueAs(); diff --git a/Src/Model3/Model3.cpp b/Src/Model3/Model3.cpp index 72d4a3f..ca2e7ce 100644 --- a/Src/Model3/Model3.cpp +++ b/Src/Model3/Model3.cpp @@ -1144,7 +1144,7 @@ UINT16 CModel3::Read16(UINT32 addr) #ifdef NET_BOARD case 0xc0: // spikeout call this - // interresting : poking @4 master to same value as slave (0x100) or simply !=0 -> connected and go in game, but freeze (prints comm error) as soon as players appear after the gate + // interesting : poking @4 master to same value as slave (0x100) or simply !=0 -> connected and go in game, but freeze (prints comm error) as soon as players appear after the gate // sort of sync ack ? who writes this 16b value ? { UINT16 result; diff --git a/Src/Model3/Real3D.cpp b/Src/Model3/Real3D.cpp index f35d70e..492f8c5 100644 --- a/Src/Model3/Real3D.cpp +++ b/Src/Model3/Real3D.cpp @@ -809,7 +809,7 @@ uint32_t CReal3D::ReadRegister(unsigned reg) int index = (reg - 20) / 4; float val = Render3D->GetLosValue(index); - if (val) { + if (val != 0.f) { //val = 1.0f / val; // test program indicate z values are 1 over return 0xffffffff; // infinity } @@ -922,7 +922,6 @@ uint32_t CReal3D::GetASICIDCode(ASIC asic) const } void CReal3D::SetStepping(int stepping, uint32_t pciIDValue) - { step = stepping; if ((step!=0x10) && (step!=0x15) && (step!=0x20) && (step!=0x21)) diff --git a/Src/Model3/Real3D.h b/Src/Model3/Real3D.h index 598345c..3013924 100644 --- a/Src/Model3/Real3D.h +++ b/Src/Model3/Real3D.h @@ -36,7 +36,7 @@ #include "Util/NewConfig.h" #include -#include +#include /* * QueuedUploadTextures: @@ -505,7 +505,7 @@ private: bool m_evenFrame = false; // Internal ASIC state - std::map m_asicID; + std::unordered_map m_asicID; uint64_t m_internalRenderConfig[2]; }; diff --git a/Src/Network/NetBoard.h b/Src/Network/NetBoard.h index 54594d6..0768986 100644 --- a/Src/Network/NetBoard.h +++ b/Src/Network/NetBoard.h @@ -104,7 +104,7 @@ private: // netsock UINT16 port_in = 0; UINT16 port_out = 0; - std::string addr_out = ""; + std::string addr_out; std::unique_ptr nets; std::unique_ptr netr; diff --git a/Src/Network/SimNetBoard.h b/Src/Network/SimNetBoard.h index b6d74ee..ff2513f 100644 --- a/Src/Network/SimNetBoard.h +++ b/Src/Network/SimNetBoard.h @@ -85,7 +85,7 @@ private: // netsock uint16_t port_in = 0; uint16_t port_out = 0; - std::string addr_out = ""; + std::string addr_out; std::thread m_connectThread; std::atomic_bool m_quit = false; std::atomic_bool m_connected = false; diff --git a/Src/Network/TCPSend.cpp b/Src/Network/TCPSend.cpp index d67486b..bb29722 100644 --- a/Src/Network/TCPSend.cpp +++ b/Src/Network/TCPSend.cpp @@ -60,7 +60,7 @@ bool TCPSend::Send(const void * data, int length) DPRINTF("Sending %i bytes\n", length); - int sent = 0; + int sent; sent = SDLNet_TCP_Send(m_socket, &length, sizeof(int)); // pack the length at the start of transmission. diff --git a/Src/OSD/Logger.cpp b/Src/OSD/Logger.cpp index 26e8ace..ad7aa48 100644 --- a/Src/OSD/Logger.cpp +++ b/Src/OSD/Logger.cpp @@ -112,7 +112,7 @@ std::shared_ptr CreateLogger(const Util::Config::Node &config) loggers.push_back(std::make_shared()); // Parse other log outputs - std::string logOutputs = config["LogOutput"].ValueAsDefault(""); + std::string logOutputs = config["LogOutput"].ValueAsDefault(std::string()); std::vector outputs = Util::Format(logOutputs).Split(','); std::set supportedDestinations { "stdout", "stderr", "syslog" }; diff --git a/Src/OSD/Windows/DirectInputSystem.cpp b/Src/OSD/Windows/DirectInputSystem.cpp index 54106bf..473edec 100644 --- a/Src/OSD/Windows/DirectInputSystem.cpp +++ b/Src/OSD/Windows/DirectInputSystem.cpp @@ -1444,7 +1444,7 @@ HRESULT CDirectInputSystem::CreateJoystickEffect(LPDIRECTINPUTDEVICE8 joystick, DICONSTANTFORCE dicf; DICONDITION dic; DIPERIODIC dip; - DIENVELOPE die; + //DIENVELOPE die; GUID guid; // Set common effects parameters @@ -1865,7 +1865,7 @@ bool CDirectInputSystem::ProcessForceFeedbackCmd(int joyNum, int axisNum, ForceF else { LPDIRECTINPUTDEVICE8 joystick = m_di8Joysticks[pInfo->dInputNum]; - + // See if command is to stop all force feedback, if so send appropriate command if (ffCmd.id == FFStop) return SUCCEEDED(hr = joystick->SendForceFeedbackCommand(DISFFC_STOPALL)); @@ -1878,13 +1878,13 @@ bool CDirectInputSystem::ProcessForceFeedbackCmd(int joyNum, int axisNum, ForceF if (FAILED(hr = CreateJoystickEffect(joystick, axisNum, ffCmd, pEffect))) return false; } - + LONG lDirection = 0; DICONSTANTFORCE dicf; DICONDITION dic; DIPERIODIC dip; - DIENVELOPE die; - + //DIENVELOPE die; + // Set common parameters DIEFFECT eff; memset(&eff, 0, sizeof(eff)); @@ -1894,7 +1894,7 @@ bool CDirectInputSystem::ProcessForceFeedbackCmd(int joyNum, int axisNum, ForceF eff.rglDirection = &lDirection; eff.dwStartDelay = 0; eff.lpEnvelope = NULL; - + // Set command specific parameters LONG lFFMag; DWORD dFFMag; diff --git a/Src/Util/BitRegister.cpp b/Src/Util/BitRegister.cpp index f108035..4e758a4 100644 --- a/Src/Util/BitRegister.cpp +++ b/Src/Util/BitRegister.cpp @@ -276,7 +276,7 @@ namespace Util std::string BitRegister::ToBinaryString() const { if (Empty()) - return std::string(""); + return std::string(); std::string out(Size(), '0'); for (size_t i = 0; i < Size(); i++) { @@ -287,9 +287,9 @@ namespace Util std::string BitRegister::ToHexString() const { - const char digits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + static const char digits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; if (Empty()) - return std::string(""); + return std::string(); size_t partial = Size() & 3; size_t num_digits = Size() / 4 + (partial != 0 ? 1 : 0); std::string out(num_digits + 2, '0');