Thread: [Gcblue-commits] gcb_wx/src/network tcAuthenticationMessageHandler.cpp,NONE,1.1 tcMultiplayerInterfa
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-05-06 23:58:02
|
Update of /cvsroot/gcblue/gcb_wx/src/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11225/src/network Modified Files: tcMultiplayerInterface.cpp tcNetworkInterface.cpp tcTextMessageHandler.cpp Added Files: tcAuthenticationMessageHandler.cpp Log Message: added player name to connection status, update rates are slower for non-controlled objects, non-controlled objects now display as green, added chat text popup Index: tcNetworkInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcNetworkInterface.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** tcNetworkInterface.cpp 29 Apr 2005 18:52:54 -0000 1.18 --- tcNetworkInterface.cpp 6 May 2005 23:57:50 -0000 1.19 *************** *** 220,225 **** ! std::string tcNetworkInterface::GetConnectionStatus(int id) { unsigned timeCount = tcTime::Get()->Get30HzCount(); --- 220,227 ---- ! const std::string& tcNetworkInterface::GetConnectionStatus(int id) { + static std::string s; + unsigned timeCount = tcTime::Get()->Get30HzCount(); *************** *** 251,257 **** float ping_ms = 1000.0f * connData->GetPingTime(); ! wxString status = wxString::Format("%s (%.0f) %04d %04d %03d %.0f", ! connData->idString.c_str(), dt_sec, bytesIn, bytesOut, resentCount, ping_ms); ! return std::string(status.c_str()); } --- 253,260 ---- float ping_ms = 1000.0f * connData->GetPingTime(); ! wxString status = wxString::Format("(%.0f) %04d %04d %03d %.0f", ! dt_sec, bytesIn, bytesOut, resentCount, ping_ms); ! s = status.c_str(); ! return s; } Index: tcTextMessageHandler.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcTextMessageHandler.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcTextMessageHandler.cpp 29 Apr 2005 18:52:54 -0000 1.5 --- tcTextMessageHandler.cpp 6 May 2005 23:57:50 -0000 1.6 *************** *** 21,24 **** --- 21,25 ---- #include "network/tcTextMessageHandler.h" #include "network/tcMultiplayerInterface.h" + #include "tcMessageInterface.h" BEGIN_NAMESPACE(network) *************** *** 62,65 **** --- 63,72 ---- text = namedText; } + else + { + // send to tcMessageInterface in client mode (mode based popups of chat text) + tcMessageInterface::Get()->PostChatText(text); + } + chatText.push(text); } Index: tcMultiplayerInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcMultiplayerInterface.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** tcMultiplayerInterface.cpp 5 May 2005 02:14:52 -0000 1.25 --- tcMultiplayerInterface.cpp 6 May 2005 23:57:50 -0000 1.26 *************** *** 464,470 **** } ! std::string tcMultiplayerInterface::GetConnectionStatus(int connectionId) { ! return networkInterface->GetConnectionStatus(connectionId); } --- 464,476 ---- } ! const std::string& tcMultiplayerInterface::GetConnectionStatus(int connectionId) { ! static std::string s; ! ! s = GetPlayerName(connectionId).c_str(); ! s += " "; ! s += networkInterface->GetConnectionStatus(connectionId).c_str(); ! ! return s; } *************** *** 1540,1543 **** --- 1546,1550 ---- tcPlayerStatus& pstatus = GetPlayerStatus(connId); + const std::string& playerName = pstatus.GetName(); // create stream for new entities *************** *** 1562,1570 **** if (pstatus.GetLastUpdate(obj->mnID, lastUpdate)) { ! // add check based on object time, etc for variable update rates ! tcUpdateMessageHandler::AddUpdate(obj, updateStream); - pstatus.SetUpdate(obj->mnID, t); - updateCount++; // create new message if updateCount gets too large --- 1569,1583 ---- if (pstatus.GetLastUpdate(obj->mnID, lastUpdate)) { ! unsigned int dt = t - lastUpdate; ! bool doUpdate = (dt >= 90) || ! ((dt >= 25) && (obj->IsControlledBy(playerName))); ! if (doUpdate) ! { ! tcUpdateMessageHandler::AddUpdate(obj, updateStream); ! ! pstatus.SetUpdate(obj->mnID, t); ! updateCount++; ! } // create new message if updateCount gets too large *************** *** 1725,1735 **** stat.entityUpdateTime = 0; stat.sensorUpdateTime = 0; ! stat.name = "anonymous"; stat.isAuthenticated = false; ! playerInfo[connId] = stat; tcSound::Get()->PlayEffect("intercom"); - - if (IsServer()) SendAuthRequest(connId); } else --- 1738,1755 ---- stat.entityUpdateTime = 0; stat.sensorUpdateTime = 0; ! stat.name = "Anonymous"; stat.isAuthenticated = false; ! if (IsServer()) ! { ! SendAuthRequest(connId); ! } ! else ! { ! stat.name = "Server"; ! } ! ! playerInfo[connId] = stat; tcSound::Get()->PlayEffect("intercom"); } else --- NEW FILE: tcAuthenticationMessageHandler.cpp --- /** * @file tcAuthenticationMessageHandler.cpp * * Copyright (C) 2005 Dewitt Colclough (de...@tw...) * All rights reserved. * * This file is part of the Global Conflict Blue (GCB) program. * GCB is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * GCB 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GCB; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "stdwx.h" // precompiled header file #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "wx/string.h" #include "wx/event.h" #include "network/tcAuthenticationMessageHandler.h" #include "network/tcMultiplayerInterface.h" #include "common/tcStream.h" #ifdef _DEBUG #define new DEBUG_NEW #endif BEGIN_NAMESPACE(network) /** * A request for authentication from server to client */ void tcAuthenticationMessageHandler::CreateAuthenticationRequest(unsigned& messageSize, unsigned char *data) { int messageCode = AM_REQUEST; messageSize = sizeof(messageCode); memcpy(data, &messageCode, messageSize); } /** * A username, password hash response from client to server. The plain text password is hashed once (MD5) * before sending to server. The server hashes it again before comparing to database value. * Plaintext passwords are not known at the server and are not stored in the database. * Obtaining the account database does not allow access to the account. */ void tcAuthenticationMessageHandler::CreateAuthenticationResponse(const std::string& username, const std::string& hash, unsigned& messageSize, unsigned char *data) { int messageCode = AM_RESPONSE; tcStream stream; stream << messageCode; stream << username; stream << hash; messageSize = stream.size(); stream.read((char*)data, messageSize); } void tcAuthenticationMessageHandler::Handle(int connectionId, unsigned messageSize, const unsigned char *data) { if (messageSize < sizeof(int)) { fprintf(stderr, "Warning - Empty or short control message received by server\n"); return; } /* This constructor makes a copy of the data **/ tcStream stream((const char*)data, messageSize); int messageCode; stream >> messageCode; // if server, check to ensure control message is valid if (isServer) { if (messageCode != AM_RESPONSE) { fprintf(stderr, "Warning - illegal auth message received by server (%d)\n", messageCode); return; } } else { if (messageCode != AM_REQUEST) { fprintf(stderr, "Warning - illegal auth message received by client (%d)\n", messageCode); return; } } switch (messageCode) { case AM_REQUEST: { tcMultiplayerInterface::Get()->SendAuthResponse(connectionId); } break; case AM_RESPONSE: { std::string username; stream >> username; std::string passwordHash; stream >> passwordHash; tcMultiplayerInterface::Get()->AuthenticatePlayer(connectionId, username, passwordHash); } break; default: { fprintf(stderr, "Warning - Unrecognized auth message " "received (src:%d, id:%d)\n", connectionId, messageCode); return; } } } tcAuthenticationMessageHandler::tcAuthenticationMessageHandler() { } tcAuthenticationMessageHandler::~tcAuthenticationMessageHandler() { } END_NAMESPACE |