diff --git a/Source/Project64/Plugins/Plugin List.cpp b/Source/Project64/Plugins/Plugin List.cpp index 244492e76..725ad27a7 100644 --- a/Source/Project64/Plugins/Plugin List.cpp +++ b/Source/Project64/Plugins/Plugin List.cpp @@ -12,12 +12,12 @@ #include CPluginList::CPluginList(bool bAutoFill /* = true */) : - m_PluginDir(g_Settings->LoadStringVal(Directory_Plugin),"") +m_PluginDir(g_Settings->LoadStringVal(Directory_Plugin), "") { - if (bAutoFill) - { - LoadList(); - } + if (bAutoFill) + { + LoadList(); + } } CPluginList::~CPluginList() @@ -26,123 +26,122 @@ CPluginList::~CPluginList() int CPluginList::GetPluginCount() const { - return m_PluginList.size(); + return m_PluginList.size(); } -const CPluginList::PLUGIN * CPluginList::GetPluginInfo ( int indx ) const +const CPluginList::PLUGIN * CPluginList::GetPluginInfo(int indx) const { - if (indx < 0 || indx >= (int)m_PluginList.size()) - { - return NULL; - } - return &m_PluginList[indx]; - + if (indx < 0 || indx >= (int)m_PluginList.size()) + { + return NULL; + } + return &m_PluginList[indx]; } bool CPluginList::LoadList() { - WriteTrace(TraceDebug,__FUNCTION__ ": Start"); - m_PluginList.clear(); - AddPluginFromDir(m_PluginDir); - WriteTrace(TraceDebug,__FUNCTION__ ": Done"); - return true; + WriteTrace(TraceDebug, __FUNCTION__ ": Start"); + m_PluginList.clear(); + AddPluginFromDir(m_PluginDir); + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); + return true; } -void CPluginList::AddPluginFromDir ( CPath Dir) +void CPluginList::AddPluginFromDir(CPath Dir) { - Dir.SetNameExtension("*.*"); - if (Dir.FindFirst(_A_SUBDIR)) - { - do { - AddPluginFromDir(Dir); - } while (Dir.FindNext()); - Dir.UpDirectory(); - } + Dir.SetNameExtension("*.*"); + if (Dir.FindFirst(_A_SUBDIR)) + { + do { + AddPluginFromDir(Dir); + } while (Dir.FindNext()); + Dir.UpDirectory(); + } - Dir.SetNameExtension("*.dll"); - if (Dir.FindFirst()) - { - HMODULE hLib = NULL; - do { - if (hLib) - { - FreeLibrary(hLib); - hLib = NULL; - } + Dir.SetNameExtension("*.dll"); + if (Dir.FindFirst()) + { + HMODULE hLib = NULL; + do { + if (hLib) + { + FreeLibrary(hLib); + hLib = NULL; + } - //UINT LastErrorMode = SetErrorMode( SEM_FAILCRITICALERRORS ); - WriteTraceF(TraceDebug,__FUNCTION__ ": loading %s",(LPCSTR)Dir); - hLib = LoadLibrary(Dir); - //SetErrorMode(LastErrorMode); + //UINT LastErrorMode = SetErrorMode( SEM_FAILCRITICALERRORS ); + WriteTraceF(TraceDebug, __FUNCTION__ ": loading %s", (LPCSTR)Dir); + hLib = LoadLibrary(Dir); + //SetErrorMode(LastErrorMode); - if (hLib == NULL) - { - DWORD LoadError = GetLastError(); - WriteTraceF(TraceDebug, __FUNCTION__ ": failed to loadi %s (error: %d)", (LPCSTR)Dir, LoadError); - continue; - } + if (hLib == NULL) + { + DWORD LoadError = GetLastError(); + WriteTraceF(TraceDebug, __FUNCTION__ ": failed to loadi %s (error: %d)", (LPCSTR)Dir, LoadError); + continue; + } - void (__cdecl *GetDllInfo) ( PLUGIN_INFO * PluginInfo ); - GetDllInfo = (void (__cdecl *)(PLUGIN_INFO *))GetProcAddress( hLib, "GetDllInfo" ); - if (GetDllInfo == NULL) - { - continue; - } - - PLUGIN Plugin = { 0 }; - Plugin.Info.MemoryBswaped = true; - GetDllInfo(&Plugin.Info); - if (!ValidPluginVersion(Plugin.Info)) - { - continue; - } + void(__cdecl *GetDllInfo) (PLUGIN_INFO * PluginInfo); + GetDllInfo = (void(__cdecl *)(PLUGIN_INFO *))GetProcAddress(hLib, "GetDllInfo"); + if (GetDllInfo == NULL) + { + continue; + } - Plugin.FullPath = Dir; - std::string& fullPath = Dir; - std::string& pluginPath = m_PluginDir; - Plugin.FileName = fullPath.substr(pluginPath.length()); + PLUGIN Plugin = { 0 }; + Plugin.Info.MemoryBswaped = true; + GetDllInfo(&Plugin.Info); + if (!ValidPluginVersion(Plugin.Info)) + { + continue; + } - if (GetProcAddress(hLib,"DllAbout") != NULL) - { - Plugin.AboutFunction = true; - } - m_PluginList.push_back(Plugin); - } while (Dir.FindNext()); + Plugin.FullPath = Dir; + std::string& fullPath = Dir; + std::string& pluginPath = m_PluginDir; + Plugin.FileName = fullPath.substr(pluginPath.length()); - if (hLib) - { - FreeLibrary(hLib); - hLib = NULL; - } - } + if (GetProcAddress(hLib, "DllAbout") != NULL) + { + Plugin.AboutFunction = true; + } + m_PluginList.push_back(Plugin); + } while (Dir.FindNext()); + + if (hLib) + { + FreeLibrary(hLib); + hLib = NULL; + } + } } -bool CPluginList::ValidPluginVersion ( PLUGIN_INFO & PluginInfo ) { - switch (PluginInfo.Type) - { - case PLUGIN_TYPE_RSP: - if (!PluginInfo.MemoryBswaped) { return false; } - if (PluginInfo.Version == 0x0001) { return true; } - if (PluginInfo.Version == 0x0100) { return true; } - if (PluginInfo.Version == 0x0101) { return true; } - if (PluginInfo.Version == 0x0102) { return true; } - break; - case PLUGIN_TYPE_GFX: - if (!PluginInfo.MemoryBswaped) { return false; } - if (PluginInfo.Version == 0x0102) { return true; } - if (PluginInfo.Version == 0x0103) { return true; } - if (PluginInfo.Version == 0x0104) { return true; } - break; - case PLUGIN_TYPE_AUDIO: - if (!PluginInfo.MemoryBswaped) { return false; } - if (PluginInfo.Version == 0x0101) { return true; } - if (PluginInfo.Version == 0x0102) { return true; } - break; - case PLUGIN_TYPE_CONTROLLER: - if (PluginInfo.Version == 0x0100) { return true; } - if (PluginInfo.Version == 0x0101) { return true; } - if (PluginInfo.Version == 0x0102) { return true; } - break; - } - return FALSE; -} +bool CPluginList::ValidPluginVersion(PLUGIN_INFO & PluginInfo) { + switch (PluginInfo.Type) + { + case PLUGIN_TYPE_RSP: + if (!PluginInfo.MemoryBswaped) { return false; } + if (PluginInfo.Version == 0x0001) { return true; } + if (PluginInfo.Version == 0x0100) { return true; } + if (PluginInfo.Version == 0x0101) { return true; } + if (PluginInfo.Version == 0x0102) { return true; } + break; + case PLUGIN_TYPE_GFX: + if (!PluginInfo.MemoryBswaped) { return false; } + if (PluginInfo.Version == 0x0102) { return true; } + if (PluginInfo.Version == 0x0103) { return true; } + if (PluginInfo.Version == 0x0104) { return true; } + break; + case PLUGIN_TYPE_AUDIO: + if (!PluginInfo.MemoryBswaped) { return false; } + if (PluginInfo.Version == 0x0101) { return true; } + if (PluginInfo.Version == 0x0102) { return true; } + break; + case PLUGIN_TYPE_CONTROLLER: + if (PluginInfo.Version == 0x0100) { return true; } + if (PluginInfo.Version == 0x0101) { return true; } + if (PluginInfo.Version == 0x0102) { return true; } + break; + } + return FALSE; +} \ No newline at end of file diff --git a/Source/Project64/Plugins/Plugin List.h b/Source/Project64/Plugins/Plugin List.h index 17edd39c3..ae67c6805 100644 --- a/Source/Project64/Plugins/Plugin List.h +++ b/Source/Project64/Plugins/Plugin List.h @@ -1,30 +1,42 @@ -#include "..\\Settings.h" +/**************************************************************************** +* * +* Project64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#pragma once -class CPluginList +#include + +class CPluginList { public: - typedef struct - { - PLUGIN_INFO Info; - bool AboutFunction; - CPath FullPath; - stdstr FileName; - } PLUGIN; + typedef struct + { + PLUGIN_INFO Info; + bool AboutFunction; + CPath FullPath; + stdstr FileName; + } PLUGIN; public: - CPluginList(bool bAutoFill = true); - ~CPluginList(); + CPluginList(bool bAutoFill = true); + ~CPluginList(); - bool LoadList ( void ); - int GetPluginCount ( void ) const; - const PLUGIN * GetPluginInfo ( int indx ) const; - static bool ValidPluginVersion ( PLUGIN_INFO & PluginInfo ); + bool LoadList(void); + int GetPluginCount(void) const; + const PLUGIN * GetPluginInfo(int indx) const; + static bool ValidPluginVersion(PLUGIN_INFO & PluginInfo); private: - typedef std::vector PluginList; + typedef std::vector PluginList; - PluginList m_PluginList; - CPath m_PluginDir; + PluginList m_PluginList; + CPath m_PluginDir; - void AddPluginFromDir(CPath Dir); + void AddPluginFromDir(CPath Dir); };