From f8c89304d105ebacd942ae6d9e5242d0d92ff146 Mon Sep 17 00:00:00 2001 From: lotodore Date: Thu, 29 Sep 2011 20:54:24 +0000 Subject: [PATCH] Some changes to make cppcheck happy. --- src/gui/qt/gametable/myavatarlabel.cpp | 3 +- src/net/clientstate.h | 1 - src/net/clientthread.h | 1 - src/net/common/clientstate.cpp | 1 - src/net/common/clientthread.cpp | 18 ----- src/net/common/resolverthread.cpp | 96 -------------------------- src/net/resolverthread.h | 60 ---------------- 7 files changed, 2 insertions(+), 178 deletions(-) delete mode 100644 src/net/common/resolverthread.cpp delete mode 100644 src/net/resolverthread.h diff --git a/src/gui/qt/gametable/myavatarlabel.cpp b/src/gui/qt/gametable/myavatarlabel.cpp index 07b967cd..5aa6b54f 100644 --- a/src/gui/qt/gametable/myavatarlabel.cpp +++ b/src/gui/qt/gametable/myavatarlabel.cpp @@ -253,7 +253,8 @@ QString MyAvatarLabel::getPlayerTip(QString playerName) void MyAvatarLabel::setPlayerTip() { int found=0; - std::string rating="1", separator="(!#$%)"; + //std::string rating="1"; + std::string separator="(!#$%)"; std::string tip = std::string((const char*)myW->textEdit_tipInput->toPlainText().toUtf8()); std::string playerName; if(myW->tabWidget_Left->widget(2) == myW->tab_editTip)playerName = myW->tabWidget_Left->tabText(2).toUtf8().constData(); diff --git a/src/net/clientstate.h b/src/net/clientstate.h index d438b39a..df52daef 100644 --- a/src/net/clientstate.h +++ b/src/net/clientstate.h @@ -29,7 +29,6 @@ class ClientThread; class ClientCallback; -class ResolverThread; class Game; class NetPacket; class DownloadHelper; diff --git a/src/net/clientthread.h b/src/net/clientthread.h index 4f63a3aa..1003b657 100644 --- a/src/net/clientthread.h +++ b/src/net/clientthread.h @@ -187,7 +187,6 @@ protected: bool GetLoginData(LoginData &loginData) const; - unsigned GetGameIdByName(const std::string &name) const; void AddGameInfo(unsigned gameId, const GameInfo &info); void UpdateGameInfoMode(unsigned gameId, GameMode mode); void UpdateGameInfoAdmin(unsigned gameId, unsigned adminPlayerId); diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index 7ff8b379..7e32b730 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/src/net/common/clientthread.cpp b/src/net/common/clientthread.cpp index 00c79fd5..6e859173 100644 --- a/src/net/common/clientthread.cpp +++ b/src/net/common/clientthread.cpp @@ -1225,24 +1225,6 @@ ClientThread::GetLoginData(LoginData &loginData) const return retVal; } -unsigned -ClientThread::GetGameIdByName(const std::string &name) const -{ - // Find the game. - boost::mutex::scoped_lock lock(m_gameInfoMapMutex); - GameInfoMap::const_iterator i = m_gameInfoMap.begin(); - GameInfoMap::const_iterator end = m_gameInfoMap.end(); - while (i != end) { - if (i->second.name == name) - break; - ++i; - } - - if (i == end) - throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_GAME, 0); - return i->first; -} - void ClientThread::AddGameInfo(unsigned gameId, const GameInfo &info) { diff --git a/src/net/common/resolverthread.cpp b/src/net/common/resolverthread.cpp deleted file mode 100644 index 5e83aae4..00000000 --- a/src/net/common/resolverthread.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/***************************************************************************** - * PokerTH - The open source texas holdem engine * - * Copyright (C) 2006-2011 Felix Hammer, Florian Thauer, Lothar May * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Affero General Public License as * - * published by the Free Software Foundation, either version 3 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Affero General Public License for more details. * - * * - * You should have received a copy of the GNU Affero General Public License * - * along with this program. If not, see . * - *****************************************************************************/ - -#include -#include -#include -#include - -#include -#include - -using namespace std; - - -ResolverThread::ResolverThread() - : m_retVal(false) -{ - m_context.reset(new ClientContext); -} - -ResolverThread::~ResolverThread() -{ -} - -void -ResolverThread::Init(const ClientContext &context) -{ - if (IsRunning()) - return; // TODO: throw exception - - GetContext().SetAddrFamily(context.GetAddrFamily()); - GetContext().SetServerAddr(context.GetServerAddr()); - GetContext().SetServerPort(context.GetServerPort()); -} - -bool -ResolverThread::GetResult(ClientContext &context) const -{ - if (IsRunning()) - return false; // TODO: throw exception - - if (m_retVal) - memcpy(context.GetClientSockaddr(), GetContext().GetClientSockaddr(), GetContext().GetClientSockaddrSize()); - - return m_retVal; -} - -void -ResolverThread::Main() -{ - const ClientContext &context = GetContext(); - - // Convert the port to a string. - ostringstream tmpStr; - tmpStr << context.GetServerPort(); - - // Start the name resolution. - m_retVal = socket_resolve( - context.GetServerAddr().c_str(), - tmpStr.str().c_str(), - context.GetAddrFamily(), - SOCK_STREAM, - context.GetProtocol(), - (struct sockaddr *)context.GetClientSockaddr(), - context.GetClientSockaddrSize()); -} - -const ClientContext & -ResolverThread::GetContext() const -{ - assert(m_context.get()); - return *m_context; -} - -ClientContext & -ResolverThread::GetContext() -{ - assert(m_context.get()); - return *m_context; -} - diff --git a/src/net/resolverthread.h b/src/net/resolverthread.h deleted file mode 100644 index d997dc49..00000000 --- a/src/net/resolverthread.h +++ /dev/null @@ -1,60 +0,0 @@ -/***************************************************************************** - * PokerTH - The open source texas holdem engine * - * Copyright (C) 2006-2011 Felix Hammer, Florian Thauer, Lothar May * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Affero General Public License as * - * published by the Free Software Foundation, either version 3 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Affero General Public License for more details. * - * * - * You should have received a copy of the GNU Affero General Public License * - * along with this program. If not, see . * - *****************************************************************************/ -/* Name resolution thread. */ - -#ifndef _RESOLVERTHREAD_H_ -#define _RESOLVERTHREAD_H_ - -#include - -#include - -class ClientContext; - -class ResolverThread : public Thread -{ -public: - ResolverThread(); - virtual ~ResolverThread(); - - // Set the parameters. Does not do any error checking. - // To prevent access faults if this thread cannot be - // terminated, the data is not modified. - void Init(const ClientContext &context); - - // Retrieve the result of the name resolution. - // ONLY CALL THIS FUNCTION AFTER THE THREAD TERMINATED. - // You have been warned... - bool GetResult(ClientContext &context) const; - -protected: - - // Main function of the thread. - virtual void Main(); - - const ClientContext &GetContext() const; - ClientContext &GetContext(); - -private: - - boost::shared_ptr m_context; - bool m_retVal; -}; - -#endif -