[wpdev-commits] wolfpack/network uosocket.cpp,1.281,1.282 uosocket.h,1.92,1.93
Brought to you by:
rip,
thiagocorrea
|
From: <dar...@us...> - 2003-09-05 00:05:39
|
Update of /cvsroot/wpdev/wolfpack/network
In directory sc8-pr-cvs1:/tmp/cvs-serv3552/network
Modified Files:
uosocket.cpp uosocket.h
Log Message:
Moved logging to cLog.cpp (further cleanup of wolfpack.cpp).
Index: uosocket.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/network/uosocket.cpp,v
retrieving revision 1.281
retrieving revision 1.282
diff -C2 -d -r1.281 -r1.282
*** uosocket.cpp 3 Sep 2003 20:58:17 -0000 1.281
--- uosocket.cpp 5 Sep 2003 00:03:46 -0000 1.282
***************
*** 64,67 ****
--- 64,68 ----
#include "../chars.h"
#include "../npc.h"
+ #include "../log.h"
#include "../ai.h"
***************
*** 101,104 ****
--- 102,106 ----
_socket->resetStatus();
_ip = _socket->peerAddress().toString();
+ _uniqueId = sDevice->socket();
tooltipscache_ = new QBitArray;
}
***************
*** 193,197 ****
if( lastPacket == 0x73 && packetId == 0x73 )
{
! clConsole.send( tr( "[%1] Idle Disconnected" ).arg( _socket->peerAddress().toString() ) );
disconnect();
return;
--- 195,199 ----
if( lastPacket == 0x73 && packetId == 0x73 )
{
! log( "Disconnected idling socket.\n" );
disconnect();
return;
***************
*** 201,209 ****
if( ( _account < 0 ) && ( packetId != 0x80 ) && ( packetId != 0x91 ) )
{
! clConsole.send( tr( "Communication Error [%1 instead of 0x80|0x91] [%2]\n" ).arg( packetId, 2, 16 ).arg( _socket->peerAddress().toString() ) );
cUOTxDenyLogin denyLogin;
denyLogin.setReason( DL_BADCOMMUNICATION );
send( &denyLogin );
disconnect();
return;
}
--- 203,214 ----
if( ( _account < 0 ) && ( packetId != 0x80 ) && ( packetId != 0x91 ) )
{
! log( QString( "Communication error: %1 instead of 0x80 or 0x91\n" ).arg( packetId, 2, 16 ) );
!
cUOTxDenyLogin denyLogin;
denyLogin.setReason( DL_BADCOMMUNICATION );
send( &denyLogin );
+
disconnect();
+
return;
}
***************
*** 627,631 ****
_account = authRet;
! clConsole.send( tr( "[%2] Account autocreated: '%1'\n" ).arg( username ).arg( _socket->peerAddress().toString() ) );
return true;
}
--- 632,636 ----
_account = authRet;
! log( QString( "Automatically created account '%1'.\n" ).arg( username ) );
return true;
}
***************
*** 642,651 ****
};
! clConsole.send( tr( "[%2] Failed to log in as '%1'\n" ).arg( username ).arg( _socket->peerAddress().toString() ) );
send( &denyPacket );
}
else if( error == cAccounts::NoError )
{
! clConsole.send( tr( "[%2] Identified as '%1'\n" ).arg( username ).arg( _socket->peerAddress().toString() ) );
}
--- 647,656 ----
};
! log( QString( "Failed to log in as '%1'.\n" ).arg( username ) );
send( &denyPacket );
}
else if( error == cAccounts::NoError )
{
! log( QString( "Logged in as '%1'.\n" ).arg( username ) );
}
***************
*** 668,672 ****
if ( !_account )
{
- clConsole.send( tr("%1 sent cUORxCreateChar without being authenticated, disconnecting. Probably a crypt client").arg(this->_socket->peerAddress().toString()) );
this->_socket->close();
return;
--- 673,676 ----
***************
*** 677,681 ****
if( characters.size() >= 5 )
{
- clConsole.send( tr( "%1 is trying to create char but has more than 5 characters" ).arg( _account->login() ) );
cancelCreate( tr("You already have more than 5 characters") )
}
--- 681,684 ----
***************
*** 683,696 ****
// Check the stats
Q_UINT16 statSum = ( packet->strength() + packet->dexterity() + packet->intelligence() );
- if( statSum > 80 )
- {
- clConsole.send( tr( "%1 is trying to create character with wrong stats: %2\n" ).arg( _account->login() ).arg( statSum ) );
- cancelCreate( tr( "Invalid Character stat sum: %1" ).arg( statSum ) )
- }
! // Every stat needs to be below 60
! if( ( packet->strength() > 60 ) || ( packet->dexterity() > 60 ) || ( packet->intelligence() > 60 ) )
{
! clConsole.send( tr( "%1 is trying to create char with wrong stats: %2 [str] %3 [dex] %4 [int]" ).arg( _account->login() ).arg( packet->strength() ).arg( packet->dexterity() ).arg( packet->intelligence() ) );
cancelCreate( tr("Invalid Character stats") )
}
--- 686,694 ----
// Check the stats
Q_UINT16 statSum = ( packet->strength() + packet->dexterity() + packet->intelligence() );
! // Every stat needs to be below 60 && the sum lower/equal than 80
! if( statSum > 80 || ( packet->strength() > 60 ) || ( packet->dexterity() > 60 ) || ( packet->intelligence() > 60 ) )
{
! log( QString( "Submitted invalid stats during char creation (%1,%2,%3).\n" ).arg( packet->strength() ).arg( packet->dexterity() ).arg( packet->intelligence() ) );
cancelCreate( tr("Invalid Character stats") )
}
***************
*** 702,707 ****
( packet->skillValue1() + packet->skillValue2() + packet->skillValue3() > 100 ) )
{
! clConsole.send( tr( "%1 is trying to create char with wrong skills: %1 [%2%] %3 [%4%] %5 [%6%]" ).arg( _account->login() ).arg( packet->skillId1() ).arg( packet->skillValue1() ).arg( packet->skillId2() ).arg( packet->skillValue2() ).arg( packet->skillId3() ).arg( packet->skillValue3() ) );
! cancelCreate( tr("Invalid Character skills") )
}
--- 700,705 ----
( packet->skillValue1() + packet->skillValue2() + packet->skillValue3() > 100 ) )
{
! log( QString( "Submitted invalid skills during char creation (%1=%2,%3=%4,%5=%6).\n" ).arg( packet->skillId1() ).arg( packet->skillValue1() ).arg( packet->skillId2() ).arg( packet->skillValue2() ).arg( packet->skillId3() ).arg( packet->skillValue3() ) );
! cancelCreate( tr( "Invalid Character skills" ) )
}
***************
*** 709,713 ****
if( packet->hairStyle() && ( !isHair( packet->hairStyle() ) || !isHairColor( packet->hairColor() ) ) )
{
! clConsole.send( tr( "%1 is trying to create a char with wrong hair %2 [Color: %3]" ).arg( _account->login() ).arg( packet->hairStyle() ).arg( packet->hairColor() ) );
cancelCreate( tr("Invalid hair") )
}
--- 707,711 ----
if( packet->hairStyle() && ( !isHair( packet->hairStyle() ) || !isHairColor( packet->hairColor() ) ) )
{
! log( QString( "Submitted wrong hair style (%1) or wrong hair color (%2) during char creation.\n" ).arg( packet->hairStyle() ).arg( packet->hairColor() ) );
cancelCreate( tr("Invalid hair") )
}
***************
*** 716,720 ****
if( packet->beardStyle() && ( !isBeard( packet->beardStyle() ) || !isHairColor( packet->beardColor() ) ) )
{
! clConsole.send( tr( "%1 is trying to create a char with wrong beard %2 [Color: %3]" ).arg( _account->login() ).arg( packet->beardStyle() ).arg( packet->beardColor() ) );
cancelCreate( tr("Invalid beard") )
}
--- 714,718 ----
if( packet->beardStyle() && ( !isBeard( packet->beardStyle() ) || !isHairColor( packet->beardColor() ) ) )
{
! log( QString( "Submitted wrong beard style (%1) or wrong beard color (%2) during char creation.\n" ).arg( packet->beardStyle() ).arg( packet->beardColor() ) );
cancelCreate( tr("Invalid beard") )
}
***************
*** 723,727 ****
if( !isNormalColor( packet->shirtColor() ) || !isNormalColor( packet->pantsColor() ) )
{
! clConsole.send( tr( "%1 is trying to create a char with wrong shirt [%2] or pant [%3] color" ).arg( _account->login() ).arg( packet->shirtColor() ).arg( packet->pantsColor() ) );
cancelCreate( tr("Invalid shirt or pant color") )
}
--- 721,725 ----
if( !isNormalColor( packet->shirtColor() ) || !isNormalColor( packet->pantsColor() ) )
{
! log( QString( "Submitted wrong shirt (%1) or pant (%2) color during char creation.\n" ).arg( packet->shirtColor() ).arg( packet->pantsColor() ) );
cancelCreate( tr("Invalid shirt or pant color") )
}
***************
*** 729,735 ****
// Check the start location
vector< StartLocation_st > startLocations = SrvParams->startLocation();
! if( packet->startTown() > startLocations.size() )
{
! clConsole.send( tr( "%1 is trying to create a char with wrong start location: %2" ).arg( _account->login() ).arg( packet->startTown() ) );
cancelCreate( tr("Invalid start location") )
}
--- 727,734 ----
// Check the start location
vector< StartLocation_st > startLocations = SrvParams->startLocation();
!
! if( packet->startTown() >= startLocations.size() )
{
! log( QString( "Submitted wrong starting location (%1) during char creation.\n" ).arg( packet->startTown() ) );
cancelCreate( tr("Invalid start location") )
}
***************
*** 738,742 ****
if( !isSkinColor( packet->skinColor() ) )
{
! clConsole.send( tr( "%1 is trying to create a char with wrong skin color: %2" ).arg( _account->login() ).arg( packet->skinColor() ) );
cancelCreate( tr("Invalid skin color") )
}
--- 737,741 ----
if( !isSkinColor( packet->skinColor() ) )
{
! log( QString( "Submitted a wrong skin color (%1) during char creation.\n" ).arg( packet->skinColor() ) );
cancelCreate( tr("Invalid skin color") )
}
***************
*** 2188,2201 ****
void cUOSocket::handleGumpResponse( cUORxGumpResponse* packet )
{
- if( gumps.find( packet->serial() ) == gumps.end() )
- {
- sysMessage( tr( "Unexpected button input" ) );
- return;
- }
-
QMap< SERIAL, cGump* >::iterator it( gumps.find( packet->serial() ) );
! if ( it == gumps.end() )
{
! clConsole.send( tr("Invalid gump response packet received from %1").arg(_account->login()) );
return;
}
--- 2187,2195 ----
void cUOSocket::handleGumpResponse( cUORxGumpResponse* packet )
{
QMap< SERIAL, cGump* >::iterator it( gumps.find( packet->serial() ) );
!
! if( it == gumps.end() )
{
! sysMessage( tr( "Unexpected button input" ) );
return;
}
***************
*** 2549,2551 ****
--- 2543,2555 ----
tooltipscache_->setBit( data );
+ }
+
+ void cUOSocket::log( const QString &message )
+ {
+ Log::instance()->print( LOG_MESSAGE, this, message );
+ }
+
+ void cUOSocket::log( eLogLevel loglevel, const QString &message )
+ {
+ Log::instance()->print( loglevel, this, message );
}
Index: uosocket.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/network/uosocket.h,v
retrieving revision 1.92
retrieving revision 1.93
diff -C2 -d -r1.92 -r1.93
*** uosocket.h 30 Aug 2003 17:00:13 -0000 1.92
--- uosocket.h 5 Sep 2003 00:03:46 -0000 1.93
***************
*** 55,58 ****
--- 55,59 ----
#include "../customtags.h"
+ enum eLogLevel;
struct stTargetItem
***************
*** 207,210 ****
--- 208,213 ----
void sendQuestArrow( bool show, UINT16 x, UINT16 y );
void closeGump( UINT32 type, UINT32 returnCode );
+ void log( eLogLevel loglevel, const QString &message );
+ void log( const QString &message );
void allowMove( Q_UINT8 sequence );
|