Fixing loads of msvc warnings (mainly size_t vs int issues).

This commit is contained in:
lotodore
2011-04-10 10:04:42 +00:00
parent 3cb3a5c3a8
commit 8bac902580
31 changed files with 304 additions and 304 deletions
+4 -4
View File
@@ -97,10 +97,10 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
cacheDir += "cache\\";
//create directories on first start of app
mkdir(configFileName.c_str());
mkdir(logDir.c_str());
mkdir(dataDir.c_str());
mkdir(cacheDir.c_str());
_mkdir(configFileName.c_str());
_mkdir(logDir.c_str());
_mkdir(dataDir.c_str());
_mkdir(cacheDir.c_str());
#else
//define app-dir
+2 -2
View File
@@ -59,9 +59,9 @@ public:
bool GetHashForAvatar(const std::string &fileName, MD5Buf &md5buf) const;
bool GetAvatarFileName(const MD5Buf &md5buf, std::string &fileName) const;
bool HasAvatar(const MD5Buf &md5buf) const;
bool StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFileType, const unsigned char *data, unsigned size, bool upload);
bool StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFileType, const unsigned char *data, size_t size, bool upload);
static bool IsValidAvatarFileType(AvatarFileType avatarFileType, const unsigned char *fileHeader, unsigned fileHeaderSize);
static bool IsValidAvatarFileType(AvatarFileType avatarFileType, const unsigned char *fileHeader, size_t fileHeaderSize);
void RemoveOldAvatarCacheEntries();
+2 -2
View File
@@ -341,7 +341,7 @@ AvatarManager::HasAvatar(const MD5Buf &md5buf) const
}
bool
AvatarManager::StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFileType, const unsigned char *data, unsigned size, bool upload)
AvatarManager::StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFileType, const unsigned char *data, size_t size, bool upload)
{
bool retVal = false;
string cacheDir;
@@ -380,7 +380,7 @@ AvatarManager::StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFil
}
bool
AvatarManager::IsValidAvatarFileType(AvatarFileType avatarFileType, const unsigned char *fileHeader, unsigned fileHeaderSize)
AvatarManager::IsValidAvatarFileType(AvatarFileType avatarFileType, const unsigned char *fileHeader, size_t fileHeaderSize)
{
bool validType = false;
+1 -1
View File
@@ -166,7 +166,7 @@ CryptHelper::MD5Sum(const std::string &fileName, MD5Buf &buf)
if (file) {
// Calculate MD5 sum of file.
unsigned char *readBuf = new unsigned char[8192];
int numBytes;
size_t numBytes;
#ifdef HAVE_OPENSSL
MD5_CTX context;
+1 -1
View File
@@ -87,7 +87,7 @@ ServerDBGeneric::EndGame(unsigned /*requestId*/)
}
void
ServerDBGeneric::AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id */*byPlayerId*/)
ServerDBGeneric::AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id * /*byPlayerId*/)
{
m_ioService->post(boost::bind(&ServerDBCallback::ReportAvatarFailed, &m_callback, requestId, replyId));
}
+1 -1
View File
@@ -45,7 +45,7 @@ public:
virtual void SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/, unsigned /*place*/) {}
virtual void EndGame(unsigned /*requestId*/) {}
virtual void AsyncReportAvatar(unsigned /*requestId*/, unsigned /*replyId*/, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id */*byPlayerId*/) {}
virtual void AsyncReportAvatar(unsigned /*requestId*/, unsigned /*replyId*/, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id * /*byPlayerId*/) {}
};
#endif // _SERVERDBNOACTION_H_
+1 -1
View File
@@ -67,7 +67,7 @@ private:
std::string m_clientSecret;
std::string m_serverSecret;
unsigned char m_recvBuf[2*MAX_CLEANER_PACKET_SIZE];
unsigned m_recvBufUsed;
size_t m_recvBufUsed;
};
#endif
+3 -3
View File
@@ -99,10 +99,10 @@ ChatCleanerManager::HandleGameChatText(unsigned gameId, unsigned playerId, const
netRequest->playerId = playerId;
OCTET_STRING_fromBuf(&netRequest->playerName,
name.c_str(),
name.length());
(int)name.length());
OCTET_STRING_fromBuf(&netRequest->chatMessage,
text.c_str(),
text.length());
(int)text.length());
SendMessageToServer(tmpChat);
}
}
@@ -135,7 +135,7 @@ ChatCleanerManager::HandleConnect(const boost::system::error_code& ec,
netInit->requestedVersion = CLEANER_PROTOCOL_VERSION;
OCTET_STRING_fromBuf(&netInit->clientSecret,
m_clientSecret.c_str(),
m_clientSecret.length());
(int)m_clientSecret.length());
SendMessageToServer(tmpInit);
m_socket->async_read_some(
boost::asio::buffer(m_recvBuf, sizeof(m_recvBuf)),
+4 -4
View File
@@ -920,7 +920,7 @@ ClientStateStartSession::InternalHandlePacket(boost::shared_ptr<ClientThread> cl
UnauthenticatedLogin_t *noauthLogin = &netInit->login.choice.unauthenticatedLogin;
OCTET_STRING_fromBuf(&noauthLogin->nickName,
context.GetPlayerName().c_str(),
context.GetPlayerName().length());
(int)context.GetPlayerName().length());
string avatarFile = client->GetQtToolsInterface().stringFromUtf8(context.GetAvatarFile());
if (!avatarFile.empty()) {
MD5Buf tmpMD5;
@@ -995,7 +995,7 @@ ClientStateWaitEnterLogin::TimerLoop(const boost::system::error_code& ec, boost:
GuestLogin_t *guestLogin = &netInit->login.choice.guestLogin;
OCTET_STRING_fromBuf(&guestLogin->nickName,
context.GetPlayerName().c_str(),
context.GetPlayerName().length());
(int)context.GetPlayerName().length());
client->GetSender().Send(context.GetSessionData(), init);
client->SetState(ClientStateWaitSession::Instance());
@@ -1013,7 +1013,7 @@ ClientStateWaitEnterLogin::TimerLoop(const boost::system::error_code& ec, boost:
string outUserData(tmpSession->AuthGetNextOutMsg());
OCTET_STRING_fromBuf(&authLogin->clientUserData,
outUserData.c_str(),
outUserData.length());
(int)outUserData.length());
string avatarFile = client->GetQtToolsInterface().stringFromUtf8(context.GetAvatarFile());
if (!avatarFile.empty()) {
MD5Buf tmpMD5;
@@ -1089,7 +1089,7 @@ ClientStateWaitAuthChallenge::InternalHandlePacket(boost::shared_ptr<ClientThrea
OCTET_STRING_fromBuf(&outResponse->clientResponse,
outUserData.c_str(),
outUserData.length());
(int)outUserData.length());
client->GetSender().Send(tmpSession, packet);
client->SetState(ClientStateWaitAuthVerify::Instance());
} else
+7 -7
View File
@@ -162,7 +162,7 @@ ClientThread::SendGameChatMessage(const std::string &msg)
ChatRequestMessage_t *netChat = &packet->GetMsg()->choice.chatRequestMessage;
OCTET_STRING_fromBuf(&netChat->chatText,
msg.c_str(),
msg.length());
(int)msg.length());
netChat->chatRequestType.present = chatRequestType_PR_chatRequestTypeGame;
netChat->chatRequestType.choice.chatRequestTypeGame.gameId = GetGameId();
@@ -181,7 +181,7 @@ ClientThread::SendLobbyChatMessage(const std::string &msg)
ChatRequestMessage_t *netChat = &packet->GetMsg()->choice.chatRequestMessage;
OCTET_STRING_fromBuf(&netChat->chatText,
msg.c_str(),
msg.length());
(int)msg.length());
netChat->chatRequestType.present = chatRequestType_PR_chatRequestTypeLobby;
@@ -199,7 +199,7 @@ ClientThread::SendPrivateChatMessage(unsigned targetPlayerId, const std::string
ChatRequestMessage_t *netChat = &packet->GetMsg()->choice.chatRequestMessage;
OCTET_STRING_fromBuf(&netChat->chatText,
msg.c_str(),
msg.length());
(int)msg.length());
netChat->chatRequestType.present = chatRequestType_PR_chatRequestTypePrivate;
netChat->chatRequestType.choice.chatRequestTypePrivate.targetPlayerId = targetPlayerId;
@@ -221,7 +221,7 @@ ClientThread::SendJoinFirstGame(const std::string &password, bool autoLeave)
netJoinGame->password = OCTET_STRING_new_fromBuf(
&asn_DEF_UTF8String,
password.c_str(),
password.length());
(int)password.length());
}
netJoinGame->joinGameAction.present = joinGameAction_PR_joinExistingGame;
@@ -243,7 +243,7 @@ ClientThread::SendJoinGame(unsigned gameId, const std::string &password, bool au
netJoinGame->password = OCTET_STRING_new_fromBuf(
&asn_DEF_UTF8String,
password.c_str(),
password.length());
(int)password.length());
}
netJoinGame->joinGameAction.present = joinGameAction_PR_joinExistingGame;
@@ -265,7 +265,7 @@ ClientThread::SendCreateGame(const GameData &gameData, const std::string &name,
netJoinGame->password = OCTET_STRING_new_fromBuf(
&asn_DEF_UTF8String,
password.c_str(),
password.length());
(int)password.length());
}
netJoinGame->joinGameAction.present = joinGameAction_PR_joinNewGame;
@@ -273,7 +273,7 @@ ClientThread::SendCreateGame(const GameData &gameData, const std::string &name,
NetPacket::SetGameData(gameData, &joinNew->gameInfo);
OCTET_STRING_fromBuf(&joinNew->gameInfo.gameName,
name.c_str(),
name.length());
(int)name.length());
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
}
+1 -1
View File
@@ -37,7 +37,7 @@ DownloadHelper::~DownloadHelper()
}
void
DownloadHelper::InternalInit(const string &/*url*/, const string &targetFileName, const string &/*user*/, const string &/*password*/, int /*filesize*/)
DownloadHelper::InternalInit(const string &/*url*/, const string &targetFileName, const string &/*user*/, const string &/*password*/, size_t /*filesize*/)
{
// Open target file for writing.
GetData()->targetFile = fopen(targetFileName.c_str(), "wb");
+1 -1
View File
@@ -51,7 +51,7 @@ struct IrcContext {
string channelPassword;
unsigned renameTries;
bool sendingBlocked;
unsigned sendCounter;
size_t sendCounter;
queue<string> sendQueue;
};
+1 -1
View File
@@ -35,7 +35,7 @@ NetPacket::~NetPacket()
}
boost::shared_ptr<NetPacket>
NetPacket::Create(char *data, unsigned &dataSize)
NetPacket::Create(char *data, size_t &dataSize)
{
boost::shared_ptr<NetPacket> tmpPacket;
+3 -3
View File
@@ -238,7 +238,7 @@ ServerGame::InternalStartGame()
// Set start data.
StartData startData;
startData.numberOfPlayers = playerData.size();
startData.numberOfPlayers = (int)playerData.size();
int tmpDealerPos = 0;
Tools::getRandNumber(0, startData.numberOfPlayers-1, 1, &tmpDealerPos, 0);
@@ -793,10 +793,10 @@ ServerGame::RemoveDisconnectedPlayers()
}
}
size_t
int
ServerGame::GetCurNumberOfPlayers() const
{
return GetFullPlayerDataList().size();
return (int)GetFullPlayerDataList().size();
}
void
+4 -4
View File
@@ -408,7 +408,7 @@ ServerGameStateInit::HandleNewSession(boost::shared_ptr<ServerGame> server, boos
if (session && session->GetPlayerData()) {
const GameData &tmpGameData = server->GetGameData();
// Check the number of players.
if (server->GetCurNumberOfPlayers() >= (size_t)tmpGameData.maxNumberOfPlayers) {
if (server->GetCurNumberOfPlayers() >= tmpGameData.maxNumberOfPlayers) {
server->MoveSessionToLobby(session, NTF_NET_REMOVED_GAME_FULL);
} else {
session->GetPlayerData()->SetGameAdmin(session->GetPlayerData()->GetUniqueId() == server->GetAdminPlayerId());
@@ -426,7 +426,7 @@ ServerGameStateInit::HandleNewSession(boost::shared_ptr<ServerGame> server, boos
OCTET_STRING_fromBuf(
&joinAck->gameInfo.gameName,
server->GetName().c_str(),
server->GetName().length());
(int)server->GetName().length());
server->GetLobbyThread().GetSender().Send(session, packet);
// Send notifications for connected players to client.
@@ -447,7 +447,7 @@ ServerGameStateInit::HandleNewSession(boost::shared_ptr<ServerGame> server, boos
// Notify lobby.
server->GetLobbyThread().NotifyPlayerJoinedGame(server->GetId(), session->GetPlayerData()->GetUniqueId());
if (server->GetCurNumberOfPlayers() == (size_t)tmpGameData.maxNumberOfPlayers) {
if (server->GetCurNumberOfPlayers() == tmpGameData.maxNumberOfPlayers) {
// Automatically start the game if it is full.
RegisterAutoStartTimer(server);
}
@@ -582,7 +582,7 @@ ServerGameStateInit::InternalProcessPacket(boost::shared_ptr<ServerGame> server,
if (session->GetPlayerData()->IsGameAdmin()
&& netStartEvent->gameId == server->GetId()
&& (server->GetGameData().gameType != GAME_TYPE_RANKING // ranking games need to be full
|| server->GetGameData().maxNumberOfPlayers == (int)server->GetCurNumberOfPlayers())) {
|| server->GetGameData().maxNumberOfPlayers == server->GetCurNumberOfPlayers())) {
SendStartEvent(*server, netStartEvent->fillWithComputerPlayers);
} else { // kick players who try to start but are not allowed to
server->MoveSessionToLobby(session, NTF_NET_REMOVED_START_FAILED);
+9 -9
View File
@@ -561,7 +561,7 @@ ServerLobbyThread::SendGlobalChat(const string &message)
OCTET_STRING_fromBuf(
&netChat->chatText,
message.c_str(),
message.length());
(int)message.length());
m_sessionManager.SendToAllSessions(GetSender(), packet, SessionData::Established);
m_gameSessionManager.SendToAllSessions(GetSender(), packet, SessionData::Game);
@@ -577,7 +577,7 @@ ServerLobbyThread::SendGlobalMsgBox(const string &message)
OCTET_STRING_fromBuf(
&netDialog->notificationText,
message.c_str(),
message.length());
(int)message.length());
m_sessionManager.SendToAllSessions(GetSender(), packet, SessionData::Established);
m_gameSessionManager.SendToAllSessions(GetSender(), packet, SessionData::Game);
}
@@ -592,7 +592,7 @@ ServerLobbyThread::SendChatBotMsg(const std::string &message)
OCTET_STRING_fromBuf(
&netChat->chatText,
message.c_str(),
message.length());
(int)message.length());
m_sessionManager.SendLobbyMsgToAllSessions(GetSender(), packet, SessionData::Established);
m_gameSessionManager.SendLobbyMsgToAllSessions(GetSender(), packet, SessionData::Game);
@@ -613,7 +613,7 @@ ServerLobbyThread::SendChatBotMsg(unsigned gameId, const std::string &message)
OCTET_STRING_fromBuf(
&netChat->chatText,
message.c_str(),
message.length());
(int)message.length());
GameMap::const_iterator pos = m_gameMap.find(gameId);
if (pos != m_gameMap.end()) {
@@ -1075,7 +1075,7 @@ ServerLobbyThread::HandleNetPacketAuthClientResponse(boost::shared_ptr<SessionDa
OCTET_STRING_fromBuf(
&verification->serverVerification,
(char *)outVerification.c_str(),
outVerification.size());
(int)outVerification.size());
GetSender().Send(session, packet);
// The last message is only for server verification.
// We are done now, the user has logged in.
@@ -1193,12 +1193,12 @@ ServerLobbyThread::HandleNetPacketRetrievePlayerInfo(boost::shared_ptr<SessionDa
OCTET_STRING_fromBuf(
&data->playerName,
tmpPlayer->GetName().c_str(),
tmpPlayer->GetName().length());
(int)tmpPlayer->GetName().length());
if (!tmpPlayer->GetCountry().empty()) {
data->countryCode = OCTET_STRING_new_fromBuf(
&asn_DEF_UTF8String,
tmpPlayer->GetCountry().c_str(),
tmpPlayer->GetCountry().length());
(int)tmpPlayer->GetCountry().length());
}
if (!tmpPlayer->GetAvatarMD5().IsZero()) {
data->avatarData = (struct PlayerInfoData::avatarData *)calloc(1, sizeof(struct PlayerInfoData::avatarData));
@@ -1503,7 +1503,7 @@ ServerLobbyThread::EstablishSession(boost::shared_ptr<SessionData> session)
OCTET_STRING_fromBuf(
&netInitAck->yourSessionId,
(char *)&sessionId,
boost::uuids::uuid::static_size());
(int)boost::uuids::uuid::static_size());
netInitAck->yourPlayerId = session->GetPlayerData()->GetUniqueId();
GetSender().Send(session, ack);
@@ -2124,7 +2124,7 @@ ServerLobbyThread::CreateNetPacketGameListNew(const ServerGame &game)
OCTET_STRING_fromBuf(
&gameNew->gameInfo.gameName,
game.GetName().c_str(),
game.GetName().length());
(int)game.GetName().length());
gameNew->isPrivate = game.IsPasswordProtected();
PlayerIdList tmpList = game.GetPlayerIdList();
+1 -1
View File
@@ -286,7 +286,7 @@ unsigned
SessionManager::GetRawSessionCount()
{
boost::recursive_mutex::scoped_lock lock(m_sessionMapMutex);
return m_sessionMap.size();
return (unsigned)m_sessionMap.size();
}
unsigned
+1 -1
View File
@@ -43,7 +43,7 @@ TransferHelper::~TransferHelper()
}
void
TransferHelper::Init(const string &url, const string &targetFileName, const string &user, const string &password, int filesize)
TransferHelper::Init(const string &url, const string &targetFileName, const string &user, const string &password, size_t filesize)
{
// Initialise curl.
m_data->curlHandle = curl_easy_init();
+1 -1
View File
@@ -40,7 +40,7 @@ UploaderThread::~UploaderThread()
}
void
UploaderThread::QueueUpload(const string &url, const string &user, const string &pwd, const string &filename, int filesize)
UploaderThread::QueueUpload(const string &url, const string &user, const string &pwd, const string &filename, size_t filesize)
{
boost::mutex::scoped_lock lock(m_uploadQueueMutex);
m_uploadQueue.push(UploadData(url, user, pwd, filename, filesize));
+1 -1
View File
@@ -44,7 +44,7 @@ UploadHelper::~UploadHelper()
}
void
UploadHelper::InternalInit(const string &/*url*/, const string &targetFileName, const string &user, const string &password, int filesize)
UploadHelper::InternalInit(const string &/*url*/, const string &targetFileName, const string &user, const string &password, size_t filesize)
{
// Open target file for reading.
GetData()->targetFile = fopen(targetFileName.c_str(), "rb");
+1 -1
View File
@@ -32,7 +32,7 @@ public:
protected:
virtual void InternalInit(const std::string &url, const std::string &targetFileName,
const std::string &user, const std::string &password, int filesize);
const std::string &user, const std::string &password, size_t filesize);
};
#endif
+1 -1
View File
@@ -51,7 +51,7 @@ public:
NetPacket(MemAllocType alloc = NoAlloc);
~NetPacket();
static boost::shared_ptr<NetPacket> Create(char *data, unsigned &dataSize);
static boost::shared_ptr<NetPacket> Create(char *data, size_t &dataSize);
const PokerTHMessage_t *GetMsg() const {
return m_msg;
+1 -1
View File
@@ -46,7 +46,7 @@ protected:
private:
NetPacketList receivedPackets;
char recvBuf[RECV_BUF_SIZE];
unsigned recvBufUsed;
size_t recvBufUsed;
};
#endif
+1 -1
View File
@@ -38,7 +38,7 @@ public:
~SendBuffer();
inline size_t GetSendBufLeft() const {
int bytesLeft = sendBufAllocated - sendBufUsed;
int bytesLeft = (int)(sendBufAllocated - sendBufUsed);
return bytesLeft < 0 ? (size_t)0 : (size_t)bytesLeft;
}
+1 -1
View File
@@ -133,7 +133,7 @@ protected:
void MoveSessionToLobby(boost::shared_ptr<SessionData> session, int reason);
void RemoveDisconnectedPlayers();
size_t GetCurNumberOfPlayers() const;
int GetCurNumberOfPlayers() const;
void AssignPlayerNumbers(PlayerDataList &playerList);
bool IsValidPlayer(unsigned playerId) const;
+2 -2
View File
@@ -36,7 +36,7 @@ public:
// Set the parameters. Does not do any error checking.
// Throws an exception on failure.
void Init(const std::string &url, const std::string &targetFileName,
const std::string &user = "", const std::string &password = "", int filesize = 0);
const std::string &user = "", const std::string &password = "", size_t filesize = 0);
// Returns true when done, false should call again.
// Throws an exception on error.
@@ -49,7 +49,7 @@ protected:
boost::shared_ptr<TransferData> GetData();
virtual void InternalInit(const std::string &url, const std::string &targetFileName,
const std::string &user, const std::string &password, int filesize) = 0;
const std::string &user, const std::string &password, size_t filesize) = 0;
private:
+3 -3
View File
@@ -36,19 +36,19 @@ public:
UploaderThread();
virtual ~UploaderThread();
void QueueUpload(const std::string &url, const std::string &user, const std::string &pwd, const std::string &filename, int filesize);
void QueueUpload(const std::string &url, const std::string &user, const std::string &pwd, const std::string &filename, size_t filesize);
protected:
struct UploadData {
UploadData() : filesize(0) {}
UploadData(const std::string &a, const std::string &u, const std::string &p, const std::string &f, int s)
UploadData(const std::string &a, const std::string &u, const std::string &p, const std::string &f, size_t s)
: address(a), user(u), pwd(p), filename(f), filesize(s) {}
std::string address;
std::string user;
std::string pwd;
std::string filename;
int filesize;
size_t filesize;
};
typedef std::queue<UploadData> UploadDataQueue;
+1 -1
View File
@@ -32,7 +32,7 @@ public:
protected:
virtual void InternalInit(const std::string &url, const std::string &targetFileName,
const std::string &user, const std::string &password, int filesize);
const std::string &user, const std::string &password, size_t filesize);
};
#endif
+1 -1
View File
@@ -54,7 +54,7 @@ struct AvatarFile {
AvatarFile() : fileType(AVATAR_FILE_TYPE_UNKNOWN), reportedSize(0) {}
std::vector<unsigned char> fileData;
AvatarFileType fileType;
unsigned reportedSize;
size_t reportedSize;
};
struct PlayerInfo {
+1 -1
View File
@@ -149,7 +149,7 @@ main(int argc, char *argv[])
{
ofstream pidStream(pidFile.c_str(), ios_base::out | ios_base::trunc);
if (!pidStream.fail())
pidStream << getpid();
pidStream << _getpid();
else
LOG_ERROR("Could not create process id file \"" << pidFile << "\"!");
}