diff options
author | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-22 16:22:21 +0200 |
---|---|---|
committer | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-22 16:22:21 +0200 |
commit | 7c84349990f21f783f4b24c113fb372a3c00164b (patch) | |
tree | 41cb29e214b98fc5b9c105bdf722a5c236c2318e /source/cWebAdmin.cpp | |
parent | Fixed cWebPlugin_Lua being not thread safe. And I don't know why, but it still crashes in Lua sometimes o_O (diff) | |
download | cuberite-7c84349990f21f783f4b24c113fb372a3c00164b.tar cuberite-7c84349990f21f783f4b24c113fb372a3c00164b.tar.gz cuberite-7c84349990f21f783f4b24c113fb372a3c00164b.tar.bz2 cuberite-7c84349990f21f783f4b24c113fb372a3c00164b.tar.lz cuberite-7c84349990f21f783f4b24c113fb372a3c00164b.tar.xz cuberite-7c84349990f21f783f4b24c113fb372a3c00164b.tar.zst cuberite-7c84349990f21f783f4b24c113fb372a3c00164b.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cWebAdmin.cpp | 42 |
1 files changed, 8 insertions, 34 deletions
diff --git a/source/cWebAdmin.cpp b/source/cWebAdmin.cpp index 9bb8e8e27..e70d60f7f 100644 --- a/source/cWebAdmin.cpp +++ b/source/cWebAdmin.cpp @@ -80,13 +80,13 @@ cWebAdmin::~cWebAdmin() delete m_Event; } -void cWebAdmin::AddPlugin( cWebPlugin* a_Plugin ) +void cWebAdmin::AddPlugin( cWebPlugin * a_Plugin ) { m_Plugins.remove( a_Plugin ); m_Plugins.push_back( a_Plugin ); } -void cWebAdmin::RemovePlugin( cWebPlugin* a_Plugin ) +void cWebAdmin::RemovePlugin( cWebPlugin * a_Plugin ) { m_Plugins.remove( a_Plugin ); } @@ -161,18 +161,10 @@ void cWebAdmin::Request_Handler(webserver::http_request* r) for (PluginList::iterator itr = WebAdmin->m_Plugins.begin(); itr != WebAdmin->m_Plugins.end(); ++itr) { cWebPlugin* WebPlugin = *itr; - cWebPlugin_Lua* LuaPlugin = dynamic_cast< cWebPlugin_Lua* >( WebPlugin ); - if( LuaPlugin ) + std::list< std::pair<std::string, std::string> > NameList = WebPlugin->GetTabNames(); + for( std::list< std::pair<std::string, std::string> >::iterator Names = NameList.begin(); Names != NameList.end(); ++Names ) { - std::list< std::pair<std::string, std::string> > NameList = LuaPlugin->GetTabNames(); - for( std::list< std::pair<std::string, std::string> >::iterator Names = NameList.begin(); Names != NameList.end(); ++Names ) - { - Menu += "<li><a href='" + BaseURL + WebPlugin->GetName() + "/" + (*Names).second + "'>" + (*Names).first + "</a></li>"; - } - } - else - { - Menu += "<li><a href='" + BaseURL + WebPlugin->GetName() + "'>" + WebPlugin->GetName() + "</a></li>"; + Menu += "<li><a href='" + BaseURL + WebPlugin->GetName().c_str() + "/" + (*Names).second + "'>" + (*Names).first + "</a></li>"; } } @@ -201,7 +193,7 @@ void cWebAdmin::Request_Handler(webserver::http_request* r) { if( (*itr)->GetName() == Split[1] ) { - Content = (*itr)->HandleRequest( &Request ); + Content = (*itr)->HandleWebRequest( &Request ); cWebPlugin* WebPlugin = *itr; FoundPlugin = WebPlugin->GetName(); cWebPlugin_Lua* LuaPlugin = dynamic_cast< cWebPlugin_Lua* >( WebPlugin ); @@ -229,7 +221,7 @@ void cWebAdmin::Request_Handler(webserver::http_request* r) for( cPluginManager::PluginList::const_iterator itr = List.begin(); itr != List.end(); ++itr ) { AString VersionNum; - AppendPrintf(Content, "<li>%s V.%i</li>", (*itr)->GetName(), (*itr)->GetVersion()); + AppendPrintf(Content, "<li>%s V.%i</li>", (*itr)->GetName().c_str(), (*itr)->GetVersion()); } } Content += "</ul>"; @@ -371,22 +363,4 @@ std::string cWebAdmin::GetTemplate() f.ReadRestOfFile(retVal); return retVal; -} - - - - - -void cWebAdmin::RemovePlugin( lua_State* L ) -{ - for( PluginList::iterator itr = m_Plugins.begin(); itr != m_Plugins.end(); ) - { - if( (*itr)->GetLuaState() == L ) - { - PluginList::iterator prev = itr++; - delete *prev; // deleting a dereferenced iterator also takes it out of the list, so no need for erase() - } - else - ++itr; - } -} +}
\ No newline at end of file |