Some changes to make cppcheck happy.

This commit is contained in:
lotodore
2011-09-29 20:54:24 +00:00
parent d6ab25d816
commit f8c89304d1
7 changed files with 2 additions and 178 deletions
+2 -1
View File
@@ -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();
-1
View File
@@ -29,7 +29,6 @@
class ClientThread;
class ClientCallback;
class ResolverThread;
class Game;
class NetPacket;
class DownloadHelper;
-1
View File
@@ -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);
-1
View File
@@ -21,7 +21,6 @@
#include <net/clientcontext.h>
#include <net/senderhelper.h>
#include <net/netpacket.h>
#include <net/resolverthread.h>
#include <net/clientexception.h>
#include <net/socket_helper.h>
#include <net/socket_msg.h>
-18
View File
@@ -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)
{
-96
View File
@@ -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 <http://www.gnu.org/licenses/>. *
*****************************************************************************/
#include <net/socket_helper.h>
#include <net/resolverthread.h>
#include <net/clientcontext.h>
#include <net/clientexception.h>
#include <sstream>
#include <cassert>
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;
}
-60
View File
@@ -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 <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/* Name resolution thread. */
#ifndef _RESOLVERTHREAD_H_
#define _RESOLVERTHREAD_H_
#include <string>
#include <core/thread.h>
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<ClientContext> m_context;
bool m_retVal;
};
#endif