From e0053b3a4619f0dbe931139b2cdcf4d98b86f222 Mon Sep 17 00:00:00 2001 From: toxieainc Date: Mon, 11 Jul 2022 17:43:59 +0200 Subject: [PATCH] fix some real errors (Model3,InputSystem), minor errors (SCSP,SDL/Main) and some performance warnings --- Src/BlockFile.cpp | 2 +- Src/GameLoader.cpp | 4 +-- Src/Graphics/Shader.cpp | 2 +- Src/Inputs/InputSystem.cpp | 36 +++++++++++++-------------- Src/Inputs/InputSystem.h | 10 ++++---- Src/Inputs/Inputs.cpp | 27 ++++++++++---------- Src/Inputs/MultiInputSource.cpp | 2 +- Src/Model3/Model3.cpp | 4 +-- Src/Model3/Real3D.cpp | 2 +- Src/Network/NetBoard.cpp | 2 +- Src/Network/NetBoard.h | 2 +- Src/Network/SimNetBoard.cpp | 2 +- Src/Network/SimNetBoard.h | 2 +- Src/OSD/SDL/Main.cpp | 11 ++++---- Src/OSD/Windows/DirectInputSystem.cpp | 20 +++++++-------- Src/OSD/Windows/WinOutputs.cpp | 6 ++--- Src/Sound/SCSP.cpp | 6 +++-- Src/Util/NewConfig.cpp | 2 +- 18 files changed, 73 insertions(+), 69 deletions(-) diff --git a/Src/BlockFile.cpp b/Src/BlockFile.cpp index 44c01a4..3ccc0dd 100644 --- a/Src/BlockFile.cpp +++ b/Src/BlockFile.cpp @@ -45,7 +45,7 @@ void CBlockFile::ReadString(std::string *str, uint32_t length) str->clear(); //TODO: use fstream to get rid of this ugly hack bool keep_loading = true; - for (size_t i = 0; i < length; i++) + for (uint32_t i = 0; i < length; i++) { char c; fread(&c, sizeof(char), 1, fp); diff --git a/Src/GameLoader.cpp b/Src/GameLoader.cpp index 5db434e..969047f 100644 --- a/Src/GameLoader.cpp +++ b/Src/GameLoader.cpp @@ -135,7 +135,7 @@ bool GameLoader::MissingAttrib(const GameLoader &loader, const Util::Config::Nod GameLoader::File::ptr_t GameLoader::File::Create(const GameLoader &loader, const Util::Config::Node &file_node) { - if (GameLoader::MissingAttrib(loader, file_node, "name") | GameLoader::MissingAttrib(loader, file_node, "offset")) + if (GameLoader::MissingAttrib(loader, file_node, "name") || GameLoader::MissingAttrib(loader, file_node, "offset")) return ptr_t(); ptr_t file = std::make_shared(); file->offset = file_node["offset"].ValueAs(); @@ -159,7 +159,7 @@ bool GameLoader::File::operator==(const File &rhs) const GameLoader::Region::ptr_t GameLoader::Region::Create(const GameLoader &loader, const Util::Config::Node ®ion_node) { - if (GameLoader::MissingAttrib(loader, region_node, "name") | MissingAttrib(loader, region_node, "stride") | GameLoader::MissingAttrib(loader, region_node, "chunk_size")) + if (GameLoader::MissingAttrib(loader, region_node, "name") || MissingAttrib(loader, region_node, "stride") | GameLoader::MissingAttrib(loader, region_node, "chunk_size")) return ptr_t(); ptr_t region = std::make_shared(); region->region_name = region_node["name"].Value(); diff --git a/Src/Graphics/Shader.cpp b/Src/Graphics/Shader.cpp index 3379498..aec7114 100644 --- a/Src/Graphics/Shader.cpp +++ b/Src/Graphics/Shader.cpp @@ -82,7 +82,7 @@ static char *LoadShaderSource(const char *file) return buf; } -bool LoadShaderProgram(GLuint *shaderProgramPtr, GLuint *vertexShaderPtr, GLuint *fragmentShaderPtr, std::string vsFile, std::string fsFile, const char *vsString, const char *fsString) +bool LoadShaderProgram(GLuint *shaderProgramPtr, GLuint *vertexShaderPtr, GLuint *fragmentShaderPtr, const std::string& vsFile, const std::string& fsFile, const char *vsString, const char *fsString) { char infoLog[2048]; const char *vsSource, *fsSource; // source code diff --git a/Src/Inputs/InputSystem.cpp b/Src/Inputs/InputSystem.cpp index c740ff2..baa2fa2 100644 --- a/Src/Inputs/InputSystem.cpp +++ b/Src/Inputs/InputSystem.cpp @@ -815,7 +815,7 @@ string CInputSystem::IntToString(int num) bool CInputSystem::EqualsIgnoreCase(string str1, const char *str2) { - for (string::const_iterator ci = str1.begin(); ci < str1.end(); ci++) + for (string::const_iterator ci = str1.begin(); ci < str1.end(); ++ci) { if (*str2 == '\0' || tolower(*ci) != tolower(*str2)) return false; @@ -826,7 +826,7 @@ bool CInputSystem::EqualsIgnoreCase(string str1, const char *str2) bool CInputSystem::StartsWithIgnoreCase(string str1, const char *str2) { - for (string::const_iterator ci = str1.begin(); ci < str1.end(); ci++) + for (string::const_iterator ci = str1.begin(); ci < str1.end(); ++ci) { if (*str2 == '\0') return true; @@ -837,7 +837,7 @@ bool CInputSystem::StartsWithIgnoreCase(string str1, const char *str2) return *str2 == '\0'; } -bool CInputSystem::IsValidKeyName(string str) +bool CInputSystem::IsValidKeyName(const string& str) { for (size_t i = 0; i < NUM_VALID_KEYS; i++) { @@ -847,7 +847,7 @@ bool CInputSystem::IsValidKeyName(string str) return false; } -EMousePart CInputSystem::LookupMousePart(string str) +EMousePart CInputSystem::LookupMousePart(const string& str) { for (int i = 0; s_mseParts[i].id != NULL; i++) { @@ -867,7 +867,7 @@ const char *CInputSystem::LookupName(EMousePart msePart) return NULL; } -EJoyPart CInputSystem::LookupJoyPart(string str) +EJoyPart CInputSystem::LookupJoyPart(const string& str) { for (int i = 0; s_joyParts[i].id != NULL; i++) { @@ -887,7 +887,7 @@ const char *CInputSystem::LookupName(EJoyPart joyPart) return NULL; } -size_t CInputSystem::ParseDevMapping(string str, const char *devType, int &devNum) +size_t CInputSystem::ParseDevMapping(const string& str, const char *devType, int &devNum) { if (!StartsWithIgnoreCase(str, devType)) return -1; @@ -913,7 +913,7 @@ size_t CInputSystem::ParseDevMapping(string str, const char *devType, int &devNu return -1; } -CInputSource* CInputSystem::ParseMultiSource(string str, bool fullAxisOnly, bool isOr) +CInputSource* CInputSystem::ParseMultiSource(const string& str, bool fullAxisOnly, bool isOr) { // Check for empty or NONE mapping size_t size = str.size(); @@ -1265,7 +1265,7 @@ void CInputSystem::StoreJoySettings(Util::Config::Node *config, JoySettings *set KeySettings *CInputSystem::GetKeySettings(int kbdNum, bool useDefault) { KeySettings *common = NULL; - for (vector::iterator it = m_keySettings.begin(); it != m_keySettings.end(); it++) + for (vector::iterator it = m_keySettings.begin(); it != m_keySettings.end(); ++it) { if ((*it)->kbdNum == kbdNum) return *it; @@ -1280,7 +1280,7 @@ KeySettings *CInputSystem::GetKeySettings(int kbdNum, bool useDefault) MouseSettings *CInputSystem::GetMouseSettings(int mseNum, bool useDefault) { MouseSettings *common = NULL; - for (vector::iterator it = m_mseSettings.begin(); it != m_mseSettings.end(); it++) + for (vector::iterator it = m_mseSettings.begin(); it != m_mseSettings.end(); ++it) { if ((*it)->mseNum == mseNum) return *it; @@ -1295,7 +1295,7 @@ MouseSettings *CInputSystem::GetMouseSettings(int mseNum, bool useDefault) JoySettings *CInputSystem::GetJoySettings(int joyNum, bool useDefault) { JoySettings *common = NULL; - for (vector::iterator it = m_joySettings.begin(); it != m_joySettings.end(); it++) + for (vector::iterator it = m_joySettings.begin(); it != m_joySettings.end(); ++it) { if ((*it)->joyNum == joyNum) return *it; @@ -1340,7 +1340,7 @@ int CInputSystem::GetButtonNumber(EMousePart msePart) EMousePart CInputSystem::GetMouseAxis(int axisNum, int axisDir) { - if (axisNum > 0 || axisNum >= NUM_MOUSE_AXES || axisDir < 0 || axisDir > 3) + if (axisNum < 0 || axisNum >= NUM_MOUSE_AXES || axisDir < 0 || axisDir > 3) return MouseUnknown; return (EMousePart)(MouseXAxis + 4 * axisNum + axisDir); } @@ -1587,17 +1587,17 @@ CInputSource* CInputSystem::ParseSource(const char *mapping, bool fullAxisOnly) void CInputSystem::ClearSettings() { // Delete all key settings - for (vector::iterator it = m_keySettings.begin(); it != m_keySettings.end(); it++) + for (vector::iterator it = m_keySettings.begin(); it != m_keySettings.end(); ++it) delete *it; m_keySettings.clear(); // Delete all mouse settings - for (vector::iterator it = m_mseSettings.begin(); it != m_mseSettings.end(); it++) + for (vector::iterator it = m_mseSettings.begin(); it != m_mseSettings.end(); ++it) delete *it; m_mseSettings.clear(); // Delete all joystick settings - for (vector::iterator it = m_joySettings.begin(); it != m_joySettings.end(); it++) + for (vector::iterator it = m_joySettings.begin(); it != m_joySettings.end(); ++it) delete *it; m_joySettings.clear(); } @@ -1715,15 +1715,15 @@ void CInputSystem::LoadFromConfig(const Util::Config::Node &config) void CInputSystem::StoreToConfig(Util::Config::Node *config) { // Write all key settings - for (vector::iterator it = m_keySettings.begin(); it != m_keySettings.end(); it++) + for (vector::iterator it = m_keySettings.begin(); it != m_keySettings.end(); ++it) StoreKeySettings(config, *it); // Write all mouse settings - for (vector::iterator it = m_mseSettings.begin(); it != m_mseSettings.end(); it++) + for (vector::iterator it = m_mseSettings.begin(); it != m_mseSettings.end(); ++it) StoreMouseSettings(config, *it); // Write all joystick settings - for (vector::iterator it = m_joySettings.begin(); it != m_joySettings.end(); it++) + for (vector::iterator it = m_joySettings.begin(); it != m_joySettings.end(); ++it) StoreJoySettings(config, *it); } @@ -1776,7 +1776,7 @@ bool CInputSystem::ReadMapping(char *buffer, unsigned bufSize, bool fullAxisOnly { // Check each source is no longer active bool active = false; - for (vector::iterator it = sources.begin(); it != sources.end(); it++) + for (vector::iterator it = sources.begin(); it != sources.end(); ++it) { if ((*it)->IsActive()) { diff --git a/Src/Inputs/InputSystem.h b/Src/Inputs/InputSystem.h index b71b12d..e92abb9 100644 --- a/Src/Inputs/InputSystem.h +++ b/Src/Inputs/InputSystem.h @@ -431,12 +431,12 @@ private: /* * Returns true if the given string represents a valid key name. */ - bool IsValidKeyName(std::string str); + bool IsValidKeyName(const std::string& str); /* * Returns the EMousePart with the given mapping name or MouseUnknown if not found. */ - EMousePart LookupMousePart(std::string str); + EMousePart LookupMousePart(const std::string& str); /* * Returns the mapping name for the given EMousePart. @@ -446,21 +446,21 @@ private: /* * Returns the EJoyPart with the given mapping name or JoyUnknown if not found. */ - EJoyPart LookupJoyPart(std::string str); + EJoyPart LookupJoyPart(const std::string& str); /* * Returns the mapping name for the given EJoyPart. */ const char *LookupName(EJoyPart joyPart); - size_t ParseDevMapping(std::string str, const char *devType, int &devNum); + size_t ParseDevMapping(const std::string& str, const char *devType, int &devNum); /* * Parses the given mapping string, possibly representing more than one mapping, and returns an input source for it or NULL if the * mapping is invalid. * If fullAxisOnly is true, then only mappings that represent a full axis range (eg MouseXAxis) are parsed. */ - CInputSource* ParseMultiSource(std::string str, bool fullAxisOnly, bool isOr); + CInputSource* ParseMultiSource(const std::string& str, bool fullAxisOnly, bool isOr); /* * Parses the given single mapping string and returns an input source for it, or NULL if non exists. diff --git a/Src/Inputs/Inputs.cpp b/Src/Inputs/Inputs.cpp index e944891..a300eea 100644 --- a/Src/Inputs/Inputs.cpp +++ b/Src/Inputs/Inputs.cpp @@ -278,7 +278,7 @@ CInputs::CInputs(CInputSystem *system) CInputs::~CInputs() { - for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); it++) + for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it) delete *it; m_inputs.clear(); } @@ -332,7 +332,8 @@ void CInputs::PrintHeader(const char *fmt, ...) va_end(vl); puts(header); - for (size_t i = 0; i < strlen(header); i++) + const size_t hs = strlen(header); + for (size_t i = 0; i < hs; i++) putchar('-'); printf("\n\n"); } @@ -383,7 +384,7 @@ CInput *CInputs::operator[](const unsigned index) CInput *CInputs::operator[](const char *idOrLabel) { - for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); it++) + for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it) { if (stricmp((*it)->id, idOrLabel) == 0 || stricmp((*it)->label, idOrLabel) == 0) return *it; @@ -403,7 +404,7 @@ bool CInputs::Initialize() return false; // Initialize all the inputs - for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); it++) + for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it) (*it)->Initialize(m_system); return true; @@ -413,7 +414,7 @@ void CInputs::LoadFromConfig(const Util::Config::Node &config) { m_system->LoadFromConfig(config); - for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); it++) + for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it) (*it)->LoadFromConfig(config); } @@ -421,7 +422,7 @@ void CInputs::StoreToConfig(Util::Config::Node *config) { m_system->StoreToConfig(config); - for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); it++) + for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it) (*it)->StoreToConfig(config); } @@ -446,7 +447,7 @@ bool CInputs::ConfigureInputs(const Game &game) // Get all inputs to be configured vector toConfigure; vector::iterator it; - for (it = m_inputs.begin(); it != m_inputs.end(); it++) + for (it = m_inputs.begin(); it != m_inputs.end(); ++it) { if ((*it)->IsConfigurable() && ((*it)->gameFlags & gameFlags)) toConfigure.push_back(*it); @@ -455,7 +456,7 @@ bool CInputs::ConfigureInputs(const Game &game) // Remember current mappings for each input in case changes need to be undone later vector oldMappings(toConfigure.size()); size_t index = 0; - for (it = toConfigure.begin(); it != toConfigure.end(); it++) + for (it = toConfigure.begin(); it != toConfigure.end(); ++it) oldMappings[index++] = (*it)->GetMapping(); const char *groupLabel = NULL; @@ -495,7 +496,7 @@ Redisplay: { // If user pressed aborted input, then undo all changes and finish configuration index = 0; - for (it = toConfigure.begin(); it != toConfigure.end(); it++) + for (it = toConfigure.begin(); it != toConfigure.end(); ++it) { (*it)->SetMapping(oldMappings[index].c_str()); index++; @@ -697,7 +698,7 @@ void CInputs::CalibrateJoystick(int joyNum) puts(""); if (m_system->CalibrateJoystickAxis(joyNum, axisNum)) { - for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); it++) + for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it) (*it)->InputSystemChanged(); } return; @@ -720,7 +721,7 @@ void CInputs::PrintInputs(const Game *game) } const char *groupLabel = NULL; - for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); it++) + for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it) { if (!(*it)->IsConfigurable() || !((*it)->gameFlags & gameFlags)) continue; @@ -749,7 +750,7 @@ bool CInputs::Poll(const Game *game, unsigned dispX, unsigned dispY, unsigned di // Poll all UI inputs and all the inputs used by the current game, or all inputs if game is NULL uint32_t gameFlags = game ? game->inputs : Game::INPUT_ALL; - for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); it++) + for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it) { if ((*it)->IsUIInput() || ((*it)->gameFlags & gameFlags)) (*it)->Poll(); @@ -773,7 +774,7 @@ void CInputs::DumpState(const Game *game) } // Loop through the inputs used by the current game, or all inputs if game is NULL, and dump their values to stdout - for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); it++) + for (vector::iterator it = m_inputs.begin(); it != m_inputs.end(); ++it) { if (!(*it)->IsUIInput() && !((*it)->gameFlags & gameFlags)) continue; diff --git a/Src/Inputs/MultiInputSource.cpp b/Src/Inputs/MultiInputSource.cpp index e456a3d..fc22df0 100644 --- a/Src/Inputs/MultiInputSource.cpp +++ b/Src/Inputs/MultiInputSource.cpp @@ -42,7 +42,7 @@ ESourceType CMultiInputSource::GetCombinedType(vector &sources) bool allSwitches = true; bool hasFullAxis = false; bool hasHalfAxis = false; - for (vector::iterator it = sources.begin(); it != sources.end(); it++) + for (vector::iterator it = sources.begin(); it != sources.end(); ++it) { if ((*it)->type == SourceInvalid) return SourceInvalid; // An invalid source makes the whole lot invalid diff --git a/Src/Model3/Model3.cpp b/Src/Model3/Model3.cpp index 5250c32..72d4a3f 100644 --- a/Src/Model3/Model3.cpp +++ b/Src/Model3/Model3.cpp @@ -686,7 +686,7 @@ void CModel3::WriteInputs(unsigned reg, UINT8 data) case 0x87: // Read light gun register serialFIFO1 = 0; // clear serial FIFO 1 serialFIFO2 = 0; - if ((m_game.inputs & Game::INPUT_GUN1||m_game.inputs & Game::INPUT_GUN2)) + if ((m_game.inputs & Game::INPUT_GUN1)||(m_game.inputs & Game::INPUT_GUN2)) { switch (gunReg) { @@ -1906,7 +1906,7 @@ void CModel3::LoadState(CBlockFile *SaveState) SaveState->Read(securityRAM, 0x20000); SaveState->Read(&midiCtrlPort, sizeof(midiCtrlPort)); int32_t securityFirstRead; - SaveState->Write(&securityFirstRead, sizeof(securityFirstRead)); + SaveState->Read(&securityFirstRead, sizeof(securityFirstRead)); m_securityFirstRead = securityFirstRead != 0; // All devices... diff --git a/Src/Model3/Real3D.cpp b/Src/Model3/Real3D.cpp index 30bdb37..f35d70e 100644 --- a/Src/Model3/Real3D.cpp +++ b/Src/Model3/Real3D.cpp @@ -979,7 +979,7 @@ void CReal3D::SetStepping(int stepping, uint32_t pciIDValue) bool CReal3D::Init(const uint8_t *vromPtr, IBus *BusObjectPtr, CIRQ *IRQObjectPtr, unsigned dmaIRQBit) { - uint32_t memSize = (m_config["GPUMultiThreaded"].ValueAs() ? MEMORY_POOL_SIZE : MEM_POOL_SIZE_RW); + uint32_t memSize = (m_gpuMultiThreaded ? MEMORY_POOL_SIZE : MEM_POOL_SIZE_RW); float memSizeMB = (float)memSize/(float)0x100000; // IRQ and bus objects diff --git a/Src/Network/NetBoard.cpp b/Src/Network/NetBoard.cpp index df3cd58..0e7e4b0 100644 --- a/Src/Network/NetBoard.cpp +++ b/Src/Network/NetBoard.cpp @@ -1309,7 +1309,7 @@ bool CNetBoard::IsRunning(void) return m_attached && (ioreg[0xc0] != 0); } -void CNetBoard::GetGame(Game gameinfo) +void CNetBoard::GetGame(const Game& gameinfo) { Gameinfo = gameinfo; } diff --git a/Src/Network/NetBoard.h b/Src/Network/NetBoard.h index 1b573f2..54594d6 100644 --- a/Src/Network/NetBoard.h +++ b/Src/Network/NetBoard.h @@ -60,7 +60,7 @@ public: bool Init(UINT8 *netRAMPtr, UINT8 *netBufferPtr); - void GetGame(Game); + void GetGame(const Game&); UINT8 ReadCommRAM8(unsigned addr); UINT16 ReadCommRAM16(unsigned addr); diff --git a/Src/Network/SimNetBoard.cpp b/Src/Network/SimNetBoard.cpp index 88c471a..1ef9da3 100644 --- a/Src/Network/SimNetBoard.cpp +++ b/Src/Network/SimNetBoard.cpp @@ -520,7 +520,7 @@ bool CSimNetBoard::IsRunning(void) return m_attached && m_running; } -void CSimNetBoard::GetGame(Game gameInfo) +void CSimNetBoard::GetGame(const Game& gameInfo) { m_gameInfo = gameInfo; } diff --git a/Src/Network/SimNetBoard.h b/Src/Network/SimNetBoard.h index 2e466e1..b6d74ee 100644 --- a/Src/Network/SimNetBoard.h +++ b/Src/Network/SimNetBoard.h @@ -60,7 +60,7 @@ public: bool IsAttached(void); bool IsRunning(void); - void GetGame(Game gameInfo); + void GetGame(const Game& gameInfo); uint8_t ReadCommRAM8(unsigned addr); uint16_t ReadCommRAM16(unsigned addr); diff --git a/Src/OSD/SDL/Main.cpp b/Src/OSD/SDL/Main.cpp index 948e81b..def1ff0 100644 --- a/Src/OSD/SDL/Main.cpp +++ b/Src/OSD/SDL/Main.cpp @@ -326,13 +326,14 @@ static void PrintGLInfo(bool createScreen, bool infoLog, bool printExtensions) strcpy(strLocal, (char *) str); if (infoLog) InfoLog(" Supported Extensions : %s", (strLocal = strtok(strLocal, " \t\n"))); else printf(" Supported Extensions : %s\n", (strLocal = strtok(strLocal, " \t\n"))); - while ((strLocal = strtok(NULL, " \t\n")) != NULL) + char* strLocalTmp = strLocal; + while ((strLocalTmp = strtok(NULL, " \t\n")) != NULL) { - if (infoLog) InfoLog(" %s", strLocal); - else printf(" %s\n", strLocal); + if (infoLog) InfoLog(" %s", strLocalTmp); + else printf(" %s\n", strLocalTmp); } } - free(strLocal); + free(strLocal); } if (infoLog) InfoLog(""); else printf("\n"); @@ -1735,7 +1736,7 @@ static ParsedCommandLine ParseCommandLine(int argc, char **argv) else { unsigned x, y; - if (2 == sscanf(&argv[i][4],"=%d,%d", &x, &y)) + if (2 == sscanf(&argv[i][4],"=%u,%u", &x, &y)) { std::string xres = Util::Format() << x; std::string yres = Util::Format() << y; diff --git a/Src/OSD/Windows/DirectInputSystem.cpp b/Src/OSD/Windows/DirectInputSystem.cpp index 208cb79..54106bf 100644 --- a/Src/OSD/Windows/DirectInputSystem.cpp +++ b/Src/OSD/Windows/DirectInputSystem.cpp @@ -781,7 +781,7 @@ void CDirectInputSystem::PollKeyboardsAndMice() if (m_useRawInput) { // For RawInput, only thing to do is update wheelDir from wheelData for each mouse state. Everything else is updated via WM events. - for (std::vector::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); it++) + for (std::vector::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); ++it) { if (it->wheelDelta != 0) { @@ -875,7 +875,7 @@ void CDirectInputSystem::CloseKeyboardsAndMice() } // Delete storage for keyboards - for (std::vector::iterator it = m_rawKeyStates.begin(); it != m_rawKeyStates.end(); it++) + for (std::vector::iterator it = m_rawKeyStates.begin(); it != m_rawKeyStates.end(); ++it) delete[] *it; m_keyDetails.clear(); m_rawKeyboards.clear(); @@ -915,7 +915,7 @@ void CDirectInputSystem::ResetMice() m_combRawMseState.x = p.x; m_combRawMseState.y = p.y; m_combRawMseState.z = 0; - for (std::vector::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); it++) + for (std::vector::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); ++it) { it->x = p.x; it->y = p.y; @@ -1057,7 +1057,7 @@ void CDirectInputSystem::ProcessRawInput(HRAWINPUT hInput) } m_combRawMseState.buttons = 0; - for (std::vector::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); it++) + for (std::vector::iterator it = m_rawMseStates.begin(); it != m_rawMseStates.end(); ++it) m_combRawMseState.buttons |= it->buttons; } } @@ -1080,7 +1080,7 @@ void CDirectInputSystem::OpenJoysticks() // Loop through those found int joyNum = 0; int xNum = 0; - for (std::vector::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); it++) + for (std::vector::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); ++it) { joyNum++; @@ -1145,7 +1145,7 @@ void CDirectInputSystem::OpenJoysticks() } // Gather joystick details (name, num POVs & buttons, which axes are available and whether force feedback is available) - DIPROPSTRING didps; + DIPROPSTRING didps{}; didps.diph.dwSize = sizeof(DIPROPSTRING); didps.diph.dwHeaderSize = sizeof(DIPROPHEADER); didps.diph.dwHow = DIPH_DEVICE; @@ -1293,7 +1293,7 @@ void CDirectInputSystem::ActivateJoysticks() { // Set DirectInput cooperative level of joysticks unsigned joyNum = 0; - for (std::vector::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); it++) + for (std::vector::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); ++it) { if (!it->isXInput) { @@ -1313,7 +1313,7 @@ void CDirectInputSystem::PollJoysticks() { // Get current joystick states from XInput and DirectInput int i = 0; - for (std::vector::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); it++) + for (std::vector::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); ++it) { LPDIJOYSTATE2 pJoyState = &m_diJoyStates[i++]; @@ -1394,7 +1394,7 @@ void CDirectInputSystem::PollJoysticks() void CDirectInputSystem::CloseJoysticks() { // Release any DirectInput force feedback effects that were created - for (std::vector::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); it++) + for (std::vector::iterator it = m_diJoyInfos.begin(); it != m_diJoyInfos.end(); ++it) { for (unsigned axisNum = 0; axisNum < NUM_JOY_AXES; axisNum++) { @@ -1410,7 +1410,7 @@ void CDirectInputSystem::CloseJoysticks() } // Release each DirectInput joystick - for (std::vector::iterator it = m_di8Joysticks.begin(); it != m_di8Joysticks.end(); it++) + for (std::vector::iterator it = m_di8Joysticks.begin(); it != m_di8Joysticks.end(); ++it) { (*it)->Unacquire(); (*it)->Release(); diff --git a/Src/OSD/Windows/WinOutputs.cpp b/Src/OSD/Windows/WinOutputs.cpp index 63a619a..e7e2adf 100755 --- a/Src/OSD/Windows/WinOutputs.cpp +++ b/Src/OSD/Windows/WinOutputs.cpp @@ -111,7 +111,7 @@ void CWinOutputs::SendOutput(EOutputs output, UINT8 prevValue, UINT8 value) // Loop through all registered clients and send them new output value LPARAM param = (LPARAM)output + 1; - for (vector::iterator it = m_clients.begin(), end = m_clients.end(); it != end; it++) + for (vector::iterator it = m_clients.begin(), end = m_clients.end(); it != end; ++it) PostMessage(it->hwnd, m_updateState, param, value); } @@ -178,7 +178,7 @@ LRESULT CWinOutputs::OutputWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM LRESULT CWinOutputs::RegisterClient(HWND hwnd, LPARAM id) { // Check that given client is not already registered - for (vector::iterator it = m_clients.begin(), end = m_clients.end(); it != end; it++) + for (vector::iterator it = m_clients.begin(), end = m_clients.end(); it != end; ++it) { if (it->id == id) { @@ -224,7 +224,7 @@ LRESULT CWinOutputs::UnregisterClient(HWND hwnd, LPARAM id) found = true; } else - it++; + ++it; } // Return error if no matches found diff --git a/Src/Sound/SCSP.cpp b/Src/Sound/SCSP.cpp index eb0ee29..54b5968 100644 --- a/Src/Sound/SCSP.cpp +++ b/Src/Sound/SCSP.cpp @@ -772,7 +772,7 @@ bool SCSP_Init(const Util::Config::Node &config, int n) buffertmpfr=(signed int*) malloc(44100*sizeof(signed int)); if (NULL == buffertmpfr) { - free(buffertmpfr); + free(buffertmpfl); return ErrorLog("Insufficient memory for internal SCSP buffers."); } @@ -781,8 +781,10 @@ bool SCSP_Init(const Util::Config::Node &config, int n) return ErrorLog("Insufficient memory for internal SCSP buffers."); buffertmprr=(signed int*)malloc(44100*sizeof(signed int)); if (NULL == buffertmprr) + { + free(buffertmprl); return ErrorLog("Insufficient memory for internal SCSP buffers."); - + } memset(buffertmpfl, 0, 44100*sizeof(signed int)); memset(buffertmpfr, 0, 44100*sizeof(signed int)); diff --git a/Src/Util/NewConfig.cpp b/Src/Util/NewConfig.cpp index aff5aa4..015414a 100644 --- a/Src/Util/NewConfig.cpp +++ b/Src/Util/NewConfig.cpp @@ -156,7 +156,7 @@ namespace Util { if (m_missing) throw std::range_error(Util::Format() << "Node \"" << m_key << "\" does not exist"); - if (Empty() && !m_missing) + if (Empty()) throw std::logic_error(Util::Format() << "Node \"" << m_key << "\" has no value" ); }