Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1:/tmp/cvs-serv3552
Modified Files:
basechar.cpp basechar.h boats.cpp chars.cpp combat.cpp
encryption.cpp items.cpp network.cpp npc.cpp npc.h
persistentbroker.cpp player.cpp player.h prototypes.h
sectors.cpp skills.cpp spawnregions.cpp srvparams.cpp
srvparams.h wolf.dsp wolfpack.cpp wolfpack.pro world.cpp
wpconsole.cpp wpconsole.h wpdefmanager.cpp
Added Files:
log.cpp log.h
Log Message:
Moved logging to cLog.cpp (further cleanup of wolfpack.cpp).
--- NEW FILE: log.cpp ---
//==================================================================================
//
// Wolfpack Emu (WP)
// UO Server Emulation Program
//
// Copyright 1997, 98 by Marcus Rating (Cironian)
// Copyright 2001-2003 by holders identified in authors.txt
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Palace - Suite 330, Boston, MA 02111-1307, USA.
//
// * In addition to that license, if you are running this program or modified
// * versions of it on a public system you HAVE TO make the complete source of
// * the version used by you available or provide people with a location to
// * download it.
//
//
//
// Wolfpack Homepage: http://wpdev.sf.net/
//==================================================================================
// Wolfpack Includes
#include "log.h"
#include "globals.h"
#include "srvparams.h"
#include "network/uosocket.h"
#include "wpconsole.h"
// QT Includes
#include <qdatetime.h>
#include <qdir.h>
cLog::~cLog()
{
if( logfile.isOpen() )
logfile.close();
}
bool cLog::checkLogFile()
{
QDate today = QDate::currentDate();
/*
Try to open the logfile for today if:
a) Our filedescriptor is invalid
b) We don't have today anymore
*/
if( !logfile.isOpen() || currentday != today.day() )
{
logfile.close(); // Just to be sure
QString path = SrvParams->logPath();
if( !path.endsWith( QChar( QDir::separator() ) ) )
path.append( QDir::separator() );
QString filename;
filename.sprintf( "wolfpack-%04u-%02u-%02u.log", today.year(), today.month(), today.day() );
logfile.setName( path + filename );
if( !logfile.open( IO_WriteOnly | IO_Append | IO_Translate ) )
{
clConsole.send( QString( "Couldn't open logfile '%1'\n" ).arg( path ) );
return false;
}
}
return true;
}
/*
Log to the logfile only.
*/
void cLog::log( eLogLevel loglevel, cUOSocket *sock, const QString &string, bool timestamp )
{
if( loglevel > this->loglevel )
return;
if( !checkLogFile() )
return;
// Timestamp the data
QTime now = QTime::currentTime();
QCString utfdata = string.utf8();
QCString prelude;
if( timestamp )
{
prelude.sprintf( "%02u:%02u:", now.hour(), now.minute() );
if( sock )
prelude.append( QString( "%1:" ).arg( sock->uniqueId(), 0, 16 ) );
}
// LogLevel
switch( loglevel )
{
case LOG_ERROR:
prelude.append( "ERROR: " );
break;
case LOG_WARNING:
prelude.append( "WARNING: " );
break;
default:
prelude.append( " " );
}
utfdata.prepend( prelude );
logfile.writeBlock( utfdata.data(), utfdata.length() );
logfile.flush();
}
// Sends to the console and logs too
void cLog::print( eLogLevel loglevel, const QString &string, bool timestamp )
{
// Send to the Console too
print( loglevel, 0, string, timestamp );
log( loglevel, 0, string, timestamp );
}
void cLog::print( eLogLevel loglevel, cUOSocket *sock, const QString &string, bool timestamp )
{
// send to the logfile
log( loglevel, sock, string, timestamp );
// Timestamp the data
QTime now = QTime::currentTime();
QCString prelude;
if( timestamp )
{
prelude.sprintf( "%02u:%02u:", now.hour(), now.minute() );
clConsole.ChangeColor( WPC_WHITE );
clConsole.send( prelude );
clConsole.ChangeColor( WPC_NORMAL );
if( sock )
clConsole.send( QString( "%1:" ).arg( sock->uniqueId(), 0, 16 ) );
}
// LogLevel
switch( loglevel )
{
case LOG_ERROR:
clConsole.ChangeColor( WPC_RED );
clConsole.send( "ERROR: " );
clConsole.ChangeColor( WPC_NORMAL );
break;
case LOG_WARNING:
clConsole.ChangeColor( WPC_YELLOW );
clConsole.send( "WARNING: " );
clConsole.ChangeColor( WPC_NORMAL );
break;
default:
if( !prelude.isEmpty() )
clConsole.send( " " );
}
clConsole.send( string );
}
--- NEW FILE: log.h ---
//==================================================================================
//
// Wolfpack Emu (WP)
// UO Server Emulation Program
//
// Copyright 1997, 98 by Marcus Rating (Cironian)
// Copyright 2001-2003 by holders identified in authors.txt
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Palace - Suite 330, Boston, MA 02111-1307, USA.
//
// * In addition to that license, if you are running this program or modified
// * versions of it on a public system you HAVE TO make the complete source of
// * the version used by you available or provide people with a location to
// * download it.
//
//
//
// Wolfpack Homepage: http://wpdev.sf.net/
//==================================================================================
#if !defined( __LOG_H__ )
#define __LOG_H__
// QT Includes
#include <qfile.h>
// Wolfpack Includes
#include "singleton.h"
// Log Levels
enum eLogLevel
{
LOG_MESSAGE = 0,
LOG_ERROR,
LOG_WARNING,
LOG_NOTICE,
LOG_TRACE,
LOG_DEBUG
};
class cUOSocket;
class cLog
{
protected:
eLogLevel loglevel;
QFile logfile;
bool checkLogFile();
unsigned char currentday; // Day of the month our current logfile is for
public:
cLog(): loglevel( LOG_DEBUG ) {}
virtual ~cLog();
// Prints to the logfile only
void log( eLogLevel, cUOSocket*, const QString&, bool timestamp = true );
// Sends to the console and logs too
void print( eLogLevel, const QString&, bool timestamp = true );
void print( eLogLevel, cUOSocket*, const QString&, bool timestamp = true );
};
typedef SingletonHolder< cLog > Log;
#define DEBUG_LOG( value ) Log::instance()->log( LOG_DEBUG, QString( "%1 (%2:%3)" ).arg( value ).arg( __FILE__ ).arg( __LINE__ ) );
#endif
Index: basechar.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basechar.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** basechar.cpp 3 Sep 2003 14:44:21 -0000 1.39
--- basechar.cpp 5 Sep 2003 00:03:44 -0000 1.40
***************
*** 50,53 ****
--- 50,54 ----
#include "pythonscript.h"
#include "scriptmanager.h"
+ #include "log.h"
#include "skills.h"
#include "wpdefmanager.h"
***************
*** 1463,1468 ****
// DoubleEquip is *NOT* allowed
if ( atLayer( layer ) != 0 )
! {
! clConsole.log( LOG_WARNING, QString( "Trying to put an item on layer %1 which is already occupied\n" ).arg( layer ) );
pi->setContainer( 0 );
return;
--- 1464,1469 ----
// DoubleEquip is *NOT* allowed
if ( atLayer( layer ) != 0 )
! {
! log( LOG_WARNING, QString( "Trying to put an item on layer %1 which is already occupied\n" ).arg( layer ) );
pi->setContainer( 0 );
return;
Index: basechar.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basechar.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** basechar.h 3 Sep 2003 14:44:21 -0000 1.29
--- basechar.h 5 Sep 2003 00:03:45 -0000 1.30
***************
*** 47,50 ****
--- 47,51 ----
class cUOTxTooltipList;
+ enum eLogLevel;
enum eDamageType
***************
*** 101,104 ****
--- 102,107 ----
virtual void giveGold( Q_UINT32 amount, bool inBank = false ) = 0;
virtual uint takeGold( uint amount, bool useBank = false ) = 0;
+ virtual void log( eLogLevel, const QString &string ) = 0;
+ virtual void log( const QString &string ) = 0;
unsigned int damage( eDamageType type, unsigned int amount, cUObject *source = 0 );
Index: boats.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/boats.cpp,v
retrieving revision 1.111
retrieving revision 1.112
diff -C2 -d -r1.111 -r1.112
*** boats.cpp 28 Aug 2003 20:56:16 -0000 1.111
--- boats.cpp 5 Sep 2003 00:03:45 -0000 1.112
***************
*** 47,50 ****
--- 47,51 ----
#include "globals.h"
#include "wpconsole.h"
+ #include "log.h"
#include "player.h"
#include "inlines.h"
Index: chars.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/chars.cpp,v
retrieving revision 1.329
retrieving revision 1.330
diff -C2 -d -r1.329 -r1.330
*** chars.cpp 27 Aug 2003 20:35:10 -0000 1.329
--- chars.cpp 5 Sep 2003 00:03:45 -0000 1.330
***************
*** 45,48 ****
--- 45,49 ----
#include "wpdefmanager.h"
#include "wpconsole.h"
+ #include "log.h"
// Qt Includes
Index: combat.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/combat.cpp,v
retrieving revision 1.147
retrieving revision 1.148
diff -C2 -d -r1.147 -r1.148
*** combat.cpp 3 Sep 2003 20:58:17 -0000 1.147
--- combat.cpp 5 Sep 2003 00:03:45 -0000 1.148
***************
*** 49,52 ****
--- 49,53 ----
#include "wpdefmanager.h"
#include "basechar.h"
+ #include "log.h"
#include "player.h"
#include "npc.h"
***************
*** 1042,1052 ****
}
}
-
- if( SrvParams->pvpLog() )
- {
- sprintf((char*)temp,"%s was killed by %s!\n",pDefender->name().latin1(), pAttacker->name().latin1());
- savelog((char*)temp,"PvP.log");
- }
}
if( pAttacker->objectType() == enNPC && pAttacker->isAtWar() )
--- 1043,1049 ----
}
}
}
+
+ Log::instance()->print( LOG_NOTICE, QString( "%1 was killed by %2\n" ).arg( pDefender->name() ).arg( pAttacker->name() ) );
if( pAttacker->objectType() == enNPC && pAttacker->isAtWar() )
Index: encryption.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/encryption.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** encryption.cpp 5 Jul 2003 19:02:13 -0000 1.11
--- encryption.cpp 5 Sep 2003 00:03:45 -0000 1.12
***************
*** 42,45 ****
--- 42,46 ----
#include "globals.h"
#include "prototypes.h"
+ #include "log.h"
/*!
***************
*** 221,225 ****
if( elements.size() < 3 )
{
! clConsole.log( LOG_WARNING, QString( "Invalid encryption key line: %1" ).arg( *it ) );
continue;
}
--- 222,226 ----
if( elements.size() < 3 )
{
! Log::instance()->print( LOG_WARNING, QString( "Invalid encryption key: %1" ).arg( *it ) );
continue;
}
***************
*** 233,237 ****
if( !ok )
{
! clConsole.log( LOG_WARNING, QString( "Couldn't parse key value: %1" ).arg( elements[1].stripWhiteSpace() ) );
continue;
}
--- 234,238 ----
if( !ok )
{
! Log::instance()->print( LOG_WARNING, QString( "Couldn't parse key value: %1" ).arg( elements[1].stripWhiteSpace() ) );
continue;
}
***************
*** 241,245 ****
if( !ok )
{
! clConsole.log( LOG_WARNING, QString( "Couldn't parse key value: %1" ).arg( elements[2].stripWhiteSpace() ) );
continue;
}
--- 242,246 ----
if( !ok )
{
! Log::instance()->print( LOG_WARNING, QString( "Couldn't parse key value: %1" ).arg( elements[2].stripWhiteSpace() ) );
continue;
}
Index: items.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/items.cpp,v
retrieving revision 1.345
retrieving revision 1.346
diff -C2 -d -r1.345 -r1.346
*** items.cpp 31 Aug 2003 15:23:45 -0000 1.345
--- items.cpp 5 Sep 2003 00:03:45 -0000 1.346
***************
*** 48,51 ****
--- 48,52 ----
#include "maps.h"
#include "network.h"
+ #include "log.h"
#include "multis.h"
#include "persistentbroker.h"
Index: network.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/network.cpp,v
retrieving revision 1.136
retrieving revision 1.137
diff -C2 -d -r1.136 -r1.137
*** network.cpp 3 Sep 2003 20:58:17 -0000 1.136
--- network.cpp 5 Sep 2003 00:03:45 -0000 1.137
***************
*** 113,120 ****
QSocketDevice *socket = loginServer_->getNewConnection();
netIo_->registerSocket( socket, true );
! loginSockets.append( new cUOSocket(socket) );
// Notify the admin
! clConsole.send( QString( "[%1] Client connected (LoginServer)\n" ).arg( socket->peerAddress().toString() ) );
}
--- 113,121 ----
QSocketDevice *socket = loginServer_->getNewConnection();
netIo_->registerSocket( socket, true );
! cUOSocket *uosocket = new cUOSocket(socket);
! loginSockets.append( uosocket );
// Notify the admin
! uosocket->log( QString( "Client connected to login server (%1).\n" ).arg( socket->peerAddress().toString() ) );
}
***************
*** 124,131 ****
QSocketDevice *socket = gameServer_->getNewConnection();
netIo_->registerSocket( socket, false );
! loginSockets.append( new cUOSocket(socket) );
// Notify the admin
! clConsole.send( QString( "[%1] Client connected (GameServer)\n" ).arg( socket->peerAddress().toString() ) );
}
--- 125,133 ----
QSocketDevice *socket = gameServer_->getNewConnection();
netIo_->registerSocket( socket, false );
! cUOSocket *uosocket = new cUOSocket(socket);
! loginSockets.append( uosocket );
// Notify the admin
! uosocket->log( QString( "Client connected to game server (%1).\n" ).arg( socket->peerAddress().toString() ) );
}
***************
*** 141,145 ****
if ( uoSocket->socket()->error() != QSocketDevice::NoError || !uoSocket->socket()->isValid() || !uoSocket->socket()->isWritable() || uoSocket->socket()->isInactive() || !uoSocket->socket()->isOpen() )
{
! clConsole.send( tr( "[%1] Client disconnected\n" ).arg( uoSocket->ip() ) );
uoSocket->disconnect();
netIo_->unregisterSocket( uoSocket->socket() );
--- 143,147 ----
if ( uoSocket->socket()->error() != QSocketDevice::NoError || !uoSocket->socket()->isValid() || !uoSocket->socket()->isWritable() || uoSocket->socket()->isInactive() || !uoSocket->socket()->isOpen() )
{
! uoSocket->log( "Client disconnected.\n" );
uoSocket->disconnect();
netIo_->unregisterSocket( uoSocket->socket() );
***************
*** 159,163 ****
if( uoSocket->socket()->error() != QSocketDevice::NoError || !uoSocket->socket()->isValid() || !uoSocket->socket()->isOpen() )
{
! clConsole.send( tr( "[%1] Client disconnected\n" ).arg( uoSocket->ip() ) );
netIo_->unregisterSocket( uoSocket->socket() );
loginSockets.remove();
--- 161,165 ----
if( uoSocket->socket()->error() != QSocketDevice::NoError || !uoSocket->socket()->isValid() || !uoSocket->socket()->isOpen() )
{
! uoSocket->log( "Client disconnected.\n" );
netIo_->unregisterSocket( uoSocket->socket() );
loginSockets.remove();
Index: npc.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/npc.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** npc.cpp 3 Sep 2003 14:44:21 -0000 1.38
--- npc.cpp 5 Sep 2003 00:03:45 -0000 1.39
***************
*** 45,48 ****
--- 45,49 ----
#include "sectors.h"
#include "srvparams.h"
+ #include "log.h"
#include "corpse.h"
#include "wpdefmanager.h"
***************
*** 1548,1550 ****
--- 1549,1562 ----
setFame( nCurFame+nChange );
}
+ }
+
+ void cNPC::log( eLogLevel loglevel, const QString &string )
+ {
+ // NPC's usually don't have sockets
+ Log::instance()->print( loglevel, string );
+ }
+
+ void cNPC::log( const QString &string )
+ {
+ log( LOG_NOTICE, string );
}
Index: npc.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/npc.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** npc.h 3 Sep 2003 14:44:21 -0000 1.23
--- npc.h 5 Sep 2003 00:03:45 -0000 1.24
***************
*** 102,105 ****
--- 102,107 ----
virtual void applyDefinition( const cElement* );
virtual void flagUnchanged() { cNPC::changed_ = false; cBaseChar::flagUnchanged(); }
+ void log( eLogLevel, const QString &string );
+ void log( const QString &string );
void awardFame( short amount );
void awardKarma( P_CHAR pKilled, short amount );
Index: persistentbroker.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/persistentbroker.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** persistentbroker.cpp 3 Sep 2003 12:23:17 -0000 1.23
--- persistentbroker.cpp 5 Sep 2003 00:03:45 -0000 1.24
***************
*** 36,39 ****
--- 36,40 ----
#include "wpconsole.h"
#include "globals.h"
+ #include "log.h"
// Qt Includes
***************
*** 70,74 ****
sqlite = false;
#else
! clConsole.log( LOG_FATAL, QString("Sorry, you have to define MYSQL_DRIVER to make wolfpack work with MySQL.") );
exit( -1 );
#endif
--- 71,75 ----
sqlite = false;
#else
! Log::instance()->print( LOG_ERROR, "Sorry, you have to define MYSQL_DRIVER to make wolfpack work with MySQL.\n" );
exit( -1 );
#endif
Index: player.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/player.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** player.cpp 3 Sep 2003 14:44:21 -0000 1.34
--- player.cpp 5 Sep 2003 00:03:45 -0000 1.35
***************
*** 48,51 ****
--- 48,52 ----
#include "skills.h"
#include "pythonscript.h"
+ #include "log.h"
#include "scriptmanager.h"
#include "inlines.h"
***************
*** 474,485 ****
setcharflag( pp_t );
}
-
- if( SrvParams->pvpLog() )
- {
- sprintf((char*)temp,"%s was killed by %s!\n", name().latin1(),pp_t->name().latin1());
- savelog((char*)temp,"PvP.log");
- }
}
if( pc_t->objectType() == enNPC && pc_t->isAtWar() )
--- 475,481 ----
setcharflag( pp_t );
}
}
+ Log::instance()->print( LOG_NOTICE, QString( "%1 was killed by %2\n" ).arg( name() ).arg( pc_t->name() ) );
if( pc_t->objectType() == enNPC && pc_t->isAtWar() )
***************
*** 1772,1774 ****
--- 1768,1780 ----
socket()->clilocMessage( message );
+ }
+
+ void cPlayer::log( eLogLevel loglevel, const QString &string )
+ {
+ Log::instance()->print( loglevel, socket_, string );
+ }
+
+ void cPlayer::log( const QString &string )
+ {
+ log( LOG_NOTICE, string );
}
Index: player.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/player.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** player.h 3 Sep 2003 14:44:21 -0000 1.21
--- player.h 5 Sep 2003 00:03:45 -0000 1.22
***************
*** 80,83 ****
--- 80,85 ----
virtual UINT32 takeGold( UINT32 amount, bool useBank = false );
virtual void flagUnchanged();
+ void log( eLogLevel, const QString &string );
+ void log( const QString &string );
void awardFame( short amount );
void awardKarma( P_CHAR pKilled, short amount );
Index: prototypes.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/prototypes.h,v
retrieving revision 1.108
retrieving revision 1.109
diff -C2 -d -r1.108 -r1.109
*** prototypes.h 3 Sep 2003 15:05:56 -0000 1.108
--- prototypes.h 5 Sep 2003 00:03:45 -0000 1.109
***************
*** 38,42 ****
QString hex2dec( const QString& value );
void showPaperdoll( cUOSocket *socket, P_CHAR pTarget, bool hotkey );
- void savelog(const char *msg, char *logfile);
void goldsfx( cUOSocket *socket, UINT16 amount, bool hearall );
--- 38,41 ----
Index: sectors.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/sectors.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** sectors.cpp 1 Sep 2003 05:03:03 -0000 1.14
--- sectors.cpp 5 Sep 2003 00:03:45 -0000 1.15
***************
*** 12,15 ****
--- 12,16 ----
#include "items.h"
#include "basechar.h"
+ #include "log.h"
#include <math.h>
Index: skills.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/skills.cpp,v
retrieving revision 1.205
retrieving revision 1.206
diff -C2 -d -r1.205 -r1.206
*** skills.cpp 3 Sep 2003 20:58:17 -0000 1.205
--- skills.cpp 5 Sep 2003 00:03:45 -0000 1.206
***************
*** 48,51 ****
--- 48,52 ----
#include "maps.h"
#include "network/uosocket.h"
+ #include "log.h"
#include "targetrequests.h"
#include "territories.h"
Index: spawnregions.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/spawnregions.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** spawnregions.cpp 4 Sep 2003 01:22:54 -0000 1.45
--- spawnregions.cpp 5 Sep 2003 00:03:45 -0000 1.46
***************
*** 44,47 ****
--- 44,48 ----
#include "maps.h"
#include "walking.h"
+ #include "log.h"
#include "utilsys.h"
#include "chars.h"
Index: srvparams.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/srvparams.cpp,v
retrieving revision 1.86
retrieving revision 1.87
diff -C2 -d -r1.86 -r1.87
*** srvparams.cpp 26 Aug 2003 15:05:38 -0000 1.86
--- srvparams.cpp 5 Sep 2003 00:03:45 -0000 1.87
***************
*** 212,216 ****
heartBeat_ = getBool("General", "HeartBeat", false, true);
defaultpriv2_ = getNumber("General", "DefaultPrivileage2", 0, true);
! mulPath_ = QDir::convertSeparators( getString("General", "MulPath", "./", true) );
// Network
--- 212,217 ----
heartBeat_ = getBool("General", "HeartBeat", false, true);
defaultpriv2_ = getNumber("General", "DefaultPrivileage2", 0, true);
! mulPath_ = QDir::convertSeparators( getString("General", "MulPath", "./muls/", true) );
! logPath_ = QDir::convertSeparators( getString("General", "LogPath", "./logs/", true ) );
// Network
***************
*** 382,385 ****
--- 383,393 ----
mulPath_ = data;
setString("General", "MulPath", data);
+ flush();
+ }
+
+ void cSrvParams::setLogPath( const QString &data )
+ {
+ logPath_ = data;
+ setString("General", "LogPath", data );
flush();
}
Index: srvparams.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/srvparams.h,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -d -r1.54 -r1.55
*** srvparams.h 26 Aug 2003 15:01:05 -0000 1.54
--- srvparams.h 5 Sep 2003 00:03:45 -0000 1.55
***************
*** 154,157 ****
--- 154,158 ----
int defaultpriv2_;
QString mulPath_;
+ QString logPath_;
int maxLoginAttempts_;
int resetAttemptCount_;
***************
*** 333,337 ****
--- 334,340 ----
int defaultpriv2() const;
QString mulPath() const;
+ QString logPath() const;
void setMulPath( const QString& data );
+ void setLogPath( const QString& data );
int MaxLoginAttempts() const;
int AccountBlockTime() const;
***************
*** 1149,1152 ****
--- 1152,1160 ----
{
return pathfindFleeRadius_;
+ }
+
+ inline QString cSrvParams::logPath() const
+ {
+ return logPath_;
}
Index: wolf.dsp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wolf.dsp,v
retrieving revision 1.216
retrieving revision 1.217
diff -C2 -d -r1.216 -r1.217
*** wolf.dsp 4 Sep 2003 01:22:54 -0000 1.216
--- wolf.dsp 5 Sep 2003 00:03:45 -0000 1.217
***************
*** 203,206 ****
--- 203,210 ----
# Begin Source File
+ SOURCE=.\log.cpp
+ # End Source File
+ # Begin Source File
+
SOURCE=.\makemenus.cpp
# End Source File
***************
*** 614,617 ****
--- 618,625 ----
SOURCE=.\items.h
# PROP Ignore_Default_Tool 1
+ # End Source File
+ # Begin Source File
+
+ SOURCE=.\log.h
# End Source File
# Begin Source File
Index: wolfpack.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wolfpack.cpp,v
retrieving revision 1.454
retrieving revision 1.455
diff -C2 -d -r1.454 -r1.455
*** wolfpack.cpp 3 Sep 2003 20:58:17 -0000 1.454
--- wolfpack.cpp 5 Sep 2003 00:03:46 -0000 1.455
***************
*** 30,34 ****
//==================================================================================
-
#include "wolfpack.h"
#include "world.h"
--- 30,33 ----
***************
*** 55,58 ****
--- 54,58 ----
#include "maps.h"
#include "wpdefmanager.h"
+ #include "log.h"
#include "scriptmanager.h"
#include "wptargetrequests.h"
***************
*** 520,524 ****
catch( ... )
{
! clConsole.log( LOG_FATAL, "Couldn't start up classes." );
exit( -1 );
}
--- 520,524 ----
catch( ... )
{
! clConsole.log( LOG_ERROR, "Couldn't start up classes.\n" );
exit( -1 );
}
***************
*** 536,540 ****
catch( ... )
{
! clConsole.log( LOG_FATAL, "Couldn't load translator." );
exit( -1 );
}
--- 536,540 ----
catch( ... )
{
! clConsole.log( LOG_ERROR, "Couldn't load translator.\n" );
exit( -1 );
}
***************
*** 547,551 ****
catch( ... )
{
! clConsole.log( LOG_FATAL, "Couldn't start up python." );
exit( -1 );
}
--- 547,551 ----
catch( ... )
{
! clConsole.log( LOG_ERROR, "Couldn't start up python.\n" );
exit( -1 );
}
***************
*** 612,621 ****
catch( wpException &exception )
{
! clConsole.log( LOG_FATAL, exception.error() );
exit( -1 );
}
catch( ... )
{
! clConsole.log( LOG_FATAL, "Unknown error while loading data files." );
exit( -1 );
}
--- 612,621 ----
catch( wpException &exception )
{
! clConsole.log( LOG_ERROR, exception.error() );
exit( -1 );
}
catch( ... )
{
! clConsole.log( LOG_ERROR, "Unknown error while loading data files.\n" );
exit( -1 );
}
***************
*** 632,636 ****
if( !persistentBroker->openDriver( SrvParams->databaseDriver() ) )
{
! clConsole.log( LOG_FATAL, QString("Error trying to open %1 database driver, check your wolfpack.xml").arg(SrvParams->databaseDriver()) );
exit( -1 );
}
--- 632,636 ----
if( !persistentBroker->openDriver( SrvParams->databaseDriver() ) )
{
! clConsole.log( LOG_ERROR, QString("Error trying to open %1 database driver, check your wolfpack.xml").arg(SrvParams->databaseDriver()) );
exit( -1 );
}
***************
*** 667,676 ****
catch( QString &error )
{
! clConsole.log( LOG_FATAL, error );
exit( -1 );
}
catch( ... )
{
! clConsole.log( LOG_FATAL, "An unknown error occured while loading the world." );
exit( -1 );
}
--- 667,676 ----
catch( QString &error )
{
! clConsole.log( LOG_ERROR, error );
exit( -1 );
}
catch( ... )
{
! clConsole.log( LOG_ERROR, "An unknown error occured while loading the world.\n" );
exit( -1 );
}
***************
*** 683,689 ****
endtime = 0;
lclock = 0;
-
- if( SrvParams->serverLog() )
- savelog( "Server startup", "server.log" );
uiCurrentTime = getNormalizedTime();
--- 683,686 ----
***************
*** 852,858 ****
stopPython();
- if( SrvParams->serverLog() )
- savelog( "Server shutdown","server.log" );
-
return 0;
}
--- 849,852 ----
***************
*** 1027,1044 ****
}
}
-
-
- void savelog(const char *msg, char *logfile)
- {
- FILE *file;
- file = fopen( logfile, "a" );
-
- QString logMessage = QString( "[%1] %2\n" ).arg( QDateTime::currentDateTime().toString() ).arg( msg );
-
- // Remove newlines
- logMessage = logMessage.replace( QRegExp( "\n" ), "" );
-
- fprintf( file, "%s", logMessage.ascii() );
-
- fclose( file );
- }
\ No newline at end of file
--- 1021,1022 ----
Index: wolfpack.pro
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wolfpack.pro,v
retrieving revision 1.151
retrieving revision 1.152
diff -C2 -d -r1.151 -r1.152
*** wolfpack.pro 4 Sep 2003 20:10:03 -0000 1.151
--- wolfpack.pro 5 Sep 2003 00:03:46 -0000 1.152
***************
*** 82,85 ****
--- 82,86 ----
itemid.h \
items.h \
+ log.h \
makemenus.h \
multis.h \
***************
*** 150,153 ****
--- 151,155 ----
itemid.cpp \
items.cpp \
+ log.cpp \
makemenus.cpp \
maps.cpp \
Index: world.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/world.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** world.cpp 2 Sep 2003 01:27:57 -0000 1.36
--- world.cpp 5 Sep 2003 00:03:46 -0000 1.37
***************
*** 45,48 ****
--- 45,49 ----
#include "player.h"
#include "npc.h"
+ #include "log.h"
#include <sqlite.h>
***************
*** 267,271 ****
else
{
! clConsole.log( LOG_FATAL, tr( "An unknown temporary Effect class was found: %1" ).arg( objectID ) );
continue; // Skip the class, not a good habit but at the moment the user couldn't really debug the error
}
--- 268,272 ----
else
{
! clConsole.log( LOG_ERROR, tr( "An unknown temporary Effect class was found: %1" ).arg( objectID ) );
continue; // Skip the class, not a good habit but at the moment the user couldn't really debug the error
}
***************
*** 449,453 ****
catch( QString &e )
{
! clConsole.log( LOG_FATAL, QString( "Couldn't open the database: %1\n" ).arg( e ) );
return;
}
--- 450,454 ----
catch( QString &e )
{
! clConsole.log( LOG_ERROR, QString( "Couldn't open the database: %1\n" ).arg( e ) );
return;
}
Index: wpconsole.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wpconsole.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** wpconsole.cpp 2 Sep 2003 01:07:44 -0000 1.24
--- wpconsole.cpp 5 Sep 2003 00:03:46 -0000 1.25
***************
*** 33,36 ****
--- 33,37 ----
#include "wpconsole.h"
#include "pythonscript.h"
+ #include "log.h"
// Library Includes
***************
*** 112,139 ****
void WPConsole_cl::log( UINT8 logLevel, const QString &message )
{
! if( incompleteLine_.length() > 0 )
! send( "\n" ); // End line
!
! switch( logLevel )
! {
! case LOG_ERROR:
! case LOG_FATAL:
! ChangeColor( WPC_RED );
! send( "ERROR" );
! ChangeColor( WPC_NORMAL );
! break;
! case LOG_NOTICE:
! ChangeColor( WPC_WHITE );
! send( "NOTICE" );
! ChangeColor( WPC_NORMAL );
! break;
! case LOG_WARNING:
! ChangeColor( WPC_YELLOW );
! send( "WARNING" );
! ChangeColor( WPC_NORMAL );
! break;
! }
! send( ": " + message + "\n" );
}
--- 113,123 ----
void WPConsole_cl::log( UINT8 logLevel, const QString &message )
{
! // Legacy Code
! QString msg = message;
!
! if( msg.endsWith( "\n" ) )
! msg = msg.left( msg.length() - 1 );
! Log::instance()->print( (eLogLevel)logLevel, msg + "\n" );
}
Index: wpconsole.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wpconsole.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** wpconsole.h 4 Jul 2003 16:30:48 -0000 1.18
--- wpconsole.h 5 Sep 2003 00:03:46 -0000 1.19
***************
*** 64,73 ****
};
- // I'll use defines here
- #define LOG_ERROR 1
- #define LOG_WARNING 2
- #define LOG_NOTICE 3
- #define LOG_FATAL 4
-
class WPConsole_cl
{
--- 64,67 ----
Index: wpdefmanager.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wpdefmanager.cpp,v
retrieving revision 1.60
retrieving revision 1.61
diff -C2 -d -r1.60 -r1.61
*** wpdefmanager.cpp 2 Sep 2003 02:06:34 -0000 1.60
--- wpdefmanager.cpp 5 Sep 2003 00:03:46 -0000 1.61
***************
*** 39,42 ****
--- 39,43 ----
#include "encryption.h"
#include "basedef.h"
+ #include "log.h"
// Library Includes
|