Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv955
Modified Files:
basechar.cpp items.cpp player.cpp
Log Message:
More fixes for basescripts event handlers.
Index: player.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/player.cpp,v
retrieving revision 1.123
retrieving revision 1.124
diff -C2 -d -r1.123 -r1.124
*** player.cpp 29 Aug 2004 20:40:50 -0000 1.123
--- player.cpp 31 Aug 2004 14:05:04 -0000 1.124
***************
*** 942,957 ****
bool cPlayer::onTradeStart( P_PLAYER partner, P_ITEM firstitem )
{
- cPythonScript* global = ScriptManager::instance()->getGlobalHook( EVENT_TRADESTART );
bool result = false;
! if ( scriptChain || global )
! {
PyObject* args = Py_BuildValue( "(O&O&O&)", PyGetCharObject, this, PyGetCharObject, partner, PyGetItemObject, firstitem );
!
! result = cPythonScript::callChainedEventHandler( EVENT_TRADESTART, scriptChain, args );
!
! if ( !result && global )
! result = global->callEventHandler( EVENT_TRADESTART, args );
!
Py_DECREF( args );
}
--- 942,950 ----
bool cPlayer::onTradeStart( P_PLAYER partner, P_ITEM firstitem )
{
bool result = false;
! if (canHandleEvent(EVENT_TRADESTART)) {
PyObject* args = Py_BuildValue( "(O&O&O&)", PyGetCharObject, this, PyGetCharObject, partner, PyGetItemObject, firstitem );
! result = callEventHandler( EVENT_TRADESTART, args );
Py_DECREF( args );
}
***************
*** 962,976 ****
bool cPlayer::onTrade( unsigned int type, unsigned int buttonstate, SERIAL itemserial )
{
- cPythonScript* global = ScriptManager::instance()->getGlobalHook( EVENT_TRADE );
bool result = false;
! if ( scriptChain || global )
{
PyObject* args = Py_BuildValue( "(O&iii)", PyGetCharObject, this, type, buttonstate, itemserial );
! result = cPythonScript::callChainedEventHandler( EVENT_TRADE, scriptChain, args );
!
! if ( !result && global )
! result = global->callEventHandler( EVENT_TRADE, args );
Py_DECREF( args );
--- 955,965 ----
bool cPlayer::onTrade( unsigned int type, unsigned int buttonstate, SERIAL itemserial )
{
bool result = false;
! if ( canHandleEvent(EVENT_TRADE) )
{
PyObject* args = Py_BuildValue( "(O&iii)", PyGetCharObject, this, type, buttonstate, itemserial );
! result = callEventHandler(EVENT_TRADE, args );
Py_DECREF( args );
***************
*** 983,991 ****
bool result = false;
! if ( scriptChain )
{
PyObject* args = Py_BuildValue( "O&O&", PyGetCharObject, this, PyGetItemObject, pItem );
! result = cPythonScript::callChainedEventHandler( EVENT_PICKUP, scriptChain, args );
Py_DECREF( args );
--- 972,980 ----
bool result = false;
! if ( canHandleEvent(EVENT_PICKUP) )
{
PyObject* args = Py_BuildValue( "O&O&", PyGetCharObject, this, PyGetItemObject, pItem );
! result = callEventHandler( EVENT_PICKUP, args );
Py_DECREF( args );
***************
*** 997,1012 ****
bool cPlayer::onLogin( void )
{
- cPythonScript* global = ScriptManager::instance()->getGlobalHook( EVENT_LOGIN );
bool result = false;
! if ( scriptChain || global )
{
PyObject* args = Py_BuildValue( "(O&)", PyGetCharObject, this );
!
! result = cPythonScript::callChainedEventHandler( EVENT_LOGIN, scriptChain, args );
!
! if ( !result && global )
! result = global->callEventHandler( EVENT_LOGIN, args );
!
Py_DECREF( args );
}
--- 986,995 ----
bool cPlayer::onLogin( void )
{
bool result = false;
! if ( canHandleEvent( EVENT_LOGIN ) )
{
PyObject* args = Py_BuildValue( "(O&)", PyGetCharObject, this );
! result = callEventHandler( EVENT_LOGIN, args );
Py_DECREF( args );
}
***************
*** 1017,1032 ****
bool cPlayer::onCastSpell( unsigned int spell )
{
- cPythonScript* global = ScriptManager::instance()->getGlobalHook( EVENT_CASTSPELL );
bool result = false;
! if ( scriptChain || global )
{
PyObject* args = Py_BuildValue( "O&i", PyGetCharObject, this, spell );
!
! result = cPythonScript::callChainedEventHandler( EVENT_CASTSPELL, scriptChain, args );
!
! if ( !result && global )
! result = global->callEventHandler( EVENT_CASTSPELL, args );
!
Py_DECREF( args );
}
--- 1000,1009 ----
bool cPlayer::onCastSpell( unsigned int spell )
{
bool result = false;
! if ( canHandleEvent( EVENT_CASTSPELL ) )
{
PyObject* args = Py_BuildValue( "O&i", PyGetCharObject, this, spell );
! result = callEventHandler( EVENT_CASTSPELL, args );
Py_DECREF( args );
}
***************
*** 1037,1052 ****
bool cPlayer::onLogout( void )
{
- cPythonScript* global = ScriptManager::instance()->getGlobalHook( EVENT_LOGOUT );
bool result = false;
! if ( scriptChain || global )
{
PyObject* args = Py_BuildValue( "(O&)", PyGetCharObject, this );
!
! result = cPythonScript::callChainedEventHandler( EVENT_LOGOUT, scriptChain, args );
!
! if ( !result && global )
! result = global->callEventHandler( EVENT_LOGOUT, args );
!
Py_DECREF( args );
}
--- 1014,1023 ----
bool cPlayer::onLogout( void )
{
bool result = false;
! if ( canHandleEvent( EVENT_LOGOUT ) )
{
PyObject* args = Py_BuildValue( "(O&)", PyGetCharObject, this );
! result = callEventHandler( EVENT_LOGOUT, args );
Py_DECREF( args );
}
***************
*** 1058,1072 ****
bool cPlayer::onHelp( void )
{
- cPythonScript* global = ScriptManager::instance()->getGlobalHook( EVENT_HELP );
bool result = false;
! if ( scriptChain || global )
{
PyObject* args = Py_BuildValue( "(O&)", PyGetCharObject, this );
! result = cPythonScript::callChainedEventHandler( EVENT_HELP, scriptChain, args );
!
! if ( !result && global )
! result = global->callEventHandler( EVENT_HELP, args );
Py_DECREF( args );
--- 1029,1039 ----
bool cPlayer::onHelp( void )
{
bool result = false;
! if ( canHandleEvent(EVENT_HELP) )
{
PyObject* args = Py_BuildValue( "(O&)", PyGetCharObject, this );
! result = callEventHandler( EVENT_HELP, args );
Py_DECREF( args );
***************
*** 1079,1094 ****
bool cPlayer::onChat( void )
{
- cPythonScript* global = ScriptManager::instance()->getGlobalHook( EVENT_CHAT );
bool result = false;
! if ( scriptChain || global )
{
PyObject* args = Py_BuildValue( "(O&)", PyGetCharObject, this );
!
! result = cPythonScript::callChainedEventHandler( EVENT_CHAT, scriptChain, args );
!
! if ( !result && global )
! result = global->callEventHandler( EVENT_CHAT, args );
!
Py_DECREF( args );
}
--- 1046,1055 ----
bool cPlayer::onChat( void )
{
bool result = false;
! if ( canHandleEvent( EVENT_CHAT ) )
{
PyObject* args = Py_BuildValue( "(O&)", PyGetCharObject, this );
! result = callEventHandler( EVENT_CHAT, args );
Py_DECREF( args );
}
***************
*** 1101,1108 ****
bool result = false;
! if ( scriptChain )
{
PyObject* args = Py_BuildValue( "O&O&", PyGetCharObject, this, PyGetItemObject, pItem );
! result = cPythonScript::callChainedEventHandler( EVENT_USE, scriptChain, args );
Py_DECREF( args );
}
--- 1062,1069 ----
bool result = false;
! if ( canHandleEvent(EVENT_USE) )
{
PyObject* args = Py_BuildValue( "O&O&", PyGetCharObject, this, PyGetItemObject, pItem );
! result = callEventHandler( EVENT_USE, args );
Py_DECREF( args );
}
Index: items.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/items.cpp,v
retrieving revision 1.444
retrieving revision 1.445
diff -C2 -d -r1.444 -r1.445
*** items.cpp 29 Aug 2004 16:44:39 -0000 1.444
--- items.cpp 31 Aug 2004 14:04:53 -0000 1.445
***************
*** 527,534 ****
}
! if ( cPythonScript::canChainHandleEvent( EVENT_DELETE, scriptChain ) )
{
PyObject* args = Py_BuildValue( "(N)", getPyObject() );
! cPythonScript::callChainedEventHandler( EVENT_DELETE, scriptChain, args );
Py_DECREF( args );
}
--- 527,534 ----
}
! if ( canHandleEvent( EVENT_DELETE ) )
{
PyObject* args = Py_BuildValue( "(N)", getPyObject() );
! callEventHandler( EVENT_DELETE, args );
Py_DECREF( args );
}
Index: basechar.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basechar.cpp,v
retrieving revision 1.137
retrieving revision 1.138
diff -C2 -d -r1.137 -r1.138
*** basechar.cpp 29 Aug 2004 20:40:50 -0000 1.137
--- basechar.cpp 31 Aug 2004 14:04:53 -0000 1.138
***************
*** 3368,3374 ****
// Call the onDelete event.
! PyObject* args = Py_BuildValue( "(N)", getPyObject() );
! cPythonScript::callChainedEventHandler( EVENT_DELETE, scriptChain, args );
! Py_DECREF( args );
removeFromView( false );
--- 3368,3376 ----
// Call the onDelete event.
! if (canHandleEvent(EVENT_DELETE)) {
! PyObject* args = Py_BuildValue( "(N)", getPyObject() );
! callEventHandler( EVENT_DELETE, args );
! Py_DECREF( args );
! }
removeFromView( false );
|