Skip to content

Commit

Permalink
1/18/2009 - giwo (0.98-4.0a)
Browse files Browse the repository at this point in the history
	Fixed a crash caused by clicking on the Virtue Gump icon in the paperdoll
	Added some checking before sending a status window to ensure the character is visible and in range
	Added some checks to prevent one from inviting themselves to a party
  • Loading branch information
giwo committed Jan 19, 2009
1 parent 29eb8d9 commit 56b7782
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 88 deletions.
108 changes: 54 additions & 54 deletions js/npc/speech/speech_001.js
@@ -1,5 +1,5 @@
// UOX3 Speech File (JavaScript)
// Converted by Dark-Storm
// UOX3 Speech File (JavaScript)
// Converted by Dark-Storm
// Date: 29.12.2001 2:07 am
// Tools used: PERL :)
//
Expand All @@ -10,7 +10,7 @@
// The regular expression is placed within two forward slashes, for instance /hello/. To make sure that the script only searches for the whole
// word "hello" and leaves off any preceeding or trailing letters/numbers/symbols, enclose the trigger-word in \b \b. Example: /\bhello\b/
// By adding an additional "i" behind the last forward slash, you specify that the search is case-insensitive, example: /\bhello\b/i


function onSpeech( myString, myPlayer, myNPC )
{
if( !myNPC.InRange( myPlayer, 2 ) )
Expand All @@ -32,140 +32,140 @@ function onSpeech( myString, myPlayer, myNPC )
return;
}
if( Speech_Array[currObj].match( /\bHail\b/i ) || Speech_Array[currObj].match( /\bHi\b/i ) || Speech_Array[currObj].match( /\bHello\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "Hello there!" );
return;
return;
}
else if( Speech_Array[currObj].match( /\bBritish\b/i ) || Speech_Array[currObj].match( /\bKing\b/i ) || Speech_Array[currObj].match( /\bRuler\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "Lord British is a leader who believes in order." );
return;
}
return;
}
else if( Speech_Array[currObj].match( /\bBlackthorn\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "Blackthorn is Lord British's closest friend." );
return;
return;
}
else if( Speech_Array[currObj].match( /\bBritannia\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "Britannia is the world in which thou art standing in." );
return;
}
return;
}
else if( Speech_Array[currObj].match( /\bShrine\b/i ) || Speech_Array[currObj].match( /\bVirtue\b/i ) || Speech_Array[currObj].match( /\bTemple\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "There are many shrines in Britannia. Some say they have mystical powers!" );
return;
}
return;
}
else if( Speech_Array[currObj].match( /\bAnkh\b/i ) || Speech_Array[currObj].match( /\bHealer\b/i ) || Speech_Array[currObj].match( /\bResurrect\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "Ankh's represent eternal life. Some healers say that they have special powers." );
return;
return;
}
else if( Speech_Array[currObj].match( /\bBard\b/i ) || Speech_Array[currObj].match( /\bGleeman\b/i ) || Speech_Array[currObj].match( /\bMusician\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "Bards sing of adventures of great heroes! But I think they can be really annoying sometimes." );
return;
return;
}
else if( Speech_Array[currObj].match( /\bBoat\b/i ) || Speech_Array[currObj].match( /\bShip\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "A boat is great tool for thee to get around and visit the lands of Britannia with. Get one at the shipwright's!" );
return;
return;
}
else if( Speech_Array[currObj].match( /\bCemetery\b/i ) || Speech_Array[currObj].match( /\bCrypt\b/i ) || Speech_Array[currObj].match( /\bGraves\b/i ) || Speech_Array[currObj].match( /\bGraveyard\b/i ) || Speech_Array[currObj].match( /\bUndead\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "Some people just won't let the dead rest in peace." );
return;
return;
}
else if( Speech_Array[currObj].match( /\bLost\b/i ) || Speech_Array[currObj].match( /\bMap\b/i ) || Speech_Array[currObj].match( /\bAdvice\b/i ) || Speech_Array[currObj].match( /\bWhere\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "Just remember, where ever thou goest - There thou art!" );
return;
return;
}
else if( Speech_Array[currObj].match( /\bOrc\b/i ) || Speech_Array[currObj].match( /\bLizardman\b/i ) || Speech_Array[currObj].match( /\bMonster\b/i ) || Speech_Array[currObj].match( /\bSkeleton\b/i ) || Speech_Array[currObj].match( /\bZombie\b/i ) || Speech_Array[currObj].match( /\bDungeon\b/i ) || Speech_Array[currObj].match( /\bGraveyard\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "Monsters are everywhere... Especially in dungeons and graveyards." );
return;
return;
}
else if( Speech_Array[currObj].match( /\bStable\b/i ) || Speech_Array[currObj].match( /\bHorse\b/i ) || Speech_Array[currObj].match( /\bRide\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "If thou hast some gold to spare, thou canst seek out the stables to buy thyself a horse." );
return;
return;
}
else if( Speech_Array[currObj].match( /\bSteal\b/i ) || Speech_Array[currObj].match( /\bThief\b/i ) || Speech_Array[currObj].match( /\bThiev/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "A thief is annoying, but perhaps they need things more then we do." );
return;
return;
}
else if( Speech_Array[currObj].match( /\bArmor\b/i ) || Speech_Array[currObj].match( /\bArmour\b/i ) || Speech_Array[currObj].match( /\bShield\b/i ) || Speech_Array[currObj].match( /\bPlate\b/i ) || Speech_Array[currObj].match( /\bChain/i ) || Speech_Array[currObj].match( /\bLeather\b/i ) || Speech_Array[currObj].match( /\bStudded\b/i ) || Speech_Array[currObj].match( /\bHelm\b/i ) || Speech_Array[currObj].match( /\bGloves\b/i ) || Speech_Array[currObj].match( /\bLeggings\b/i ) || Speech_Array[currObj].match( /\bGorget\b/i ) || Speech_Array[currObj].match( /\bBone\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "Sounds like thou needst to find thyself an Armorer." );
return;
return;
}
else if( Speech_Array[currObj].match( /\bWeapon\b/i ) || Speech_Array[currObj].match( /\bScimitar\b/i ) || Speech_Array[currObj].match( /\bKatana\b/i ) || Speech_Array[currObj].match( /\bLongsword\b/i ) || Speech_Array[currObj].match( /\bSword/i ) || Speech_Array[currObj].match( /\bViking\b/i ) || Speech_Array[currObj].match( /\bKryss\b/i ) || Speech_Array[currObj].match( /\bDagger\b/i ) || Speech_Array[currObj].match( /\bKnife\b/i ) || Speech_Array[currObj].match( /\bCleaver\b/i ) || Speech_Array[currObj].match( /\bHalberd\b/i ) || Speech_Array[currObj].match( /\bBardiche\b/i ) || Speech_Array[currObj].match( /\bHatchet\b/i ) || Speech_Array[currObj].match( /\bAxe\b/i ) || Speech_Array[currObj].match( /\bSpear\b/i ) || Speech_Array[currObj].match( /\bStaff\b/i ) || Speech_Array[currObj].match( /\bPitchfork\b/i ) || Speech_Array[currObj].match( /\bFork\b/i ) || Speech_Array[currObj].match( /\bCrook\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "Those things may be bought from a Weaponsmith." );
return;
return;
}
else if( Speech_Array[currObj].match( /\bEgg\b/i ) || Speech_Array[currObj].match( /\bFlour\b/i ) || Speech_Array[currObj].match( /\bHoney\b/i ) || Speech_Array[currObj].match( /\bLoaf\b/i ) || Speech_Array[currObj].match( /\bLoaves/i ) || Speech_Array[currObj].match( /\bCake\b/i ) || Speech_Array[currObj].match( /\bCookie\b/i ) || Speech_Array[currObj].match( /\bPizza\b/i ) || Speech_Array[currObj].match( /\bDough\b/i ) || Speech_Array[currObj].match( /\bPie\b/i ) || Speech_Array[currObj].match( /\bMuffin\b/i ) || Speech_Array[currObj].match( /\bDonout\b/i ) || Speech_Array[currObj].match( /\bBake\b/i ) || Speech_Array[currObj].match( /\bOven\b/i ) || Speech_Array[currObj].match( /\bCook\b/i ) || Speech_Array[currObj].match( /\bChicken\b/i ) || Speech_Array[currObj].match( /\bHungry\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "You want food? Try the baker's. Or find a tavern and get a drink to go with thy food." );
return;
return;
}
else if( Speech_Array[currObj].match( /\bLiquor\b/i ) || Speech_Array[currObj].match( /\bBeer\b/i ) || Speech_Array[currObj].match( /\bWine\b/i ) || Speech_Array[currObj].match( /\bAle\b/i ) || Speech_Array[currObj].match( /\bAlcohol/i ) || Speech_Array[currObj].match( /\bSpirit\b/i ) || Speech_Array[currObj].match( /\bBeverage\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "Try a tavern - they have both drinks and food and games aplenty!" );
return;
return;
}
else if( Speech_Array[currObj].match( /\bReagents\b/i ) || Speech_Array[currObj].match( /\bRegs\b/i ) || Speech_Array[currObj].match( /\bReags\b/i ) || Speech_Array[currObj].match( /\bAsh\b/i ) || Speech_Array[currObj].match( /\bBlood/i ) || Speech_Array[currObj].match( /\bGarlic\b/i ) || Speech_Array[currObj].match( /\bMoss\b/i ) || Speech_Array[currObj].match( /\bMandrake\b/i ) || Speech_Array[currObj].match( /\bRoot\b/i ) || Speech_Array[currObj].match( /\bBlack\b/i ) || Speech_Array[currObj].match( /\bPearl\b/i ) || Speech_Array[currObj].match( /\bNightshade\b/i ) || Speech_Array[currObj].match( /\bGinseng\b/i ) || Speech_Array[currObj].match( /\bSulfurous\b/i ) || Speech_Array[currObj].match( /\bSilk\b/i ) || Speech_Array[currObj].match( /\bSceptre\b/i ) || Speech_Array[currObj].match( /\bSpellbook\b/i ) || Speech_Array[currObj].match( /\bPotionk\b/i ) || Speech_Array[currObj].match( /\bMortar\b/i ) || Speech_Array[currObj].match( /\bMagic\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "A Mage or an Alchemist may sell thee such mystical artifacts." );
return;
return;
}
else if( Speech_Array[currObj].match( /\bCloth\b/i ) || Speech_Array[currObj].match( /\bShirt\b/i ) || Speech_Array[currObj].match( /\bClothing\b/i ) || Speech_Array[currObj].match( /\bKilt\b/i ) || Speech_Array[currObj].match( /\bCape/i ) || Speech_Array[currObj].match( /\bRobe\b/i ) || Speech_Array[currObj].match( /\bSash\b/i ) || Speech_Array[currObj].match( /\bTunic\b/i ) || Speech_Array[currObj].match( /\bDress\b/i ) || Speech_Array[currObj].match( /\bLoom\b/i ) || Speech_Array[currObj].match( /\bWeave\b/i ) || Speech_Array[currObj].match( /\bCotton\b/i ) || Speech_Array[currObj].match( /\bWool\b/i ) || Speech_Array[currObj].match( /\bDye\b/i ) || Speech_Array[currObj].match( /\bGarment\b/i ) || Speech_Array[currObj].match( /\bPants\b/i ) || Speech_Array[currObj].match( /\bSew\b/i ) || Speech_Array[currObj].match( /\bTailork\b/i ) || Speech_Array[currObj].match( /\bThread\b/i ) || Speech_Array[currObj].match( /\bScissors\b/i ) || Speech_Array[currObj].match( /\bTunic\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "For some fine clothing, I suggest thou seekest a tailor." );
return;
return;
}
else if( Speech_Array[currObj].match( /\bArchitect\b/i ) || Speech_Array[currObj].match( /\bBuilding\b/i ) || Speech_Array[currObj].match( /\bHome\b/i ) || Speech_Array[currObj].match( /\bHouse\b/i ) || Speech_Array[currObj].match( /\bEstate/i ) || Speech_Array[currObj].match( /\bTower\b/i ) || Speech_Array[currObj].match( /\bCastle\b/i ) || Speech_Array[currObj].match( /\bKeep\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "An architect might be able to grant thee a house deed." );
return;
return;
}
else if( Speech_Array[currObj].match( /\bBye\b/i ) || Speech_Array[currObj].match( /\bGoodbye\b/i ) || Speech_Array[currObj].match( /\bFarewell\b/i ) || Speech_Array[currObj].match( /\bLater\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "Goodbye to thee!" );
return;
return;
}
else if( Speech_Array[currObj].match( /\bStupid\b/i ) || Speech_Array[currObj].match( /\bDumb\b/i ) || Speech_Array[currObj].match( /\bIdiot\b/i ) || Speech_Array[currObj].match( /\bFool\b/i ))
{
{
myNPC.TurnToward( myPlayer );
myNPC.TextMessage( "Ack! It pains my heart to hear such words!" );
return;
return;
}
currObj++;
}
}

// [EOF]
}

// [EOF]

4 changes: 2 additions & 2 deletions js/server/light/torch02_on.js
@@ -1,5 +1,5 @@
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org
// simple lightsource switching script
// 17/06/2001 Yeshe; yeshe@manofmystery.org

function onUseChecked( pUser, iUsed )
{
Expand Down
17 changes: 10 additions & 7 deletions source/CPacketReceive.cpp
Expand Up @@ -1285,14 +1285,17 @@ std::string CPIGumpMenuSelect::GetTextUString( UI08 number ) const
}
void CPIGumpMenuSelect::BuildTextLocations( void )
{
size_t i = textOffset + 4; // first is textOffset + 4, to walk past the number of text strings
textLocationOffsets.resize( textCount );
for( size_t j = 0; j < textCount; ++j )
if( textCount > 0 )
{
textLocationOffsets[j] = static_cast<wchar_t>(i);
i += 2; // skip the text ID
UI16 textLen = tSock->GetWord( i );
i += ( 2 * textLen + 2 ); // we need to add the + 2 for the text len field
size_t i = textOffset + 4; // first is textOffset + 4, to walk past the number of text strings
textLocationOffsets.resize( textCount );
for( size_t j = 0; j < textCount; ++j )
{
textLocationOffsets[j] = static_cast<wchar_t>(i);
i += 2; // skip the text ID
UI16 textLen = tSock->GetWord( i );
i += ( 2 * textLen + 2 ); // we need to add the + 2 for the text len field
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions source/Changelog.txt
@@ -1,3 +1,8 @@
1/18/2009 - giwo (0.98-4.0a)
Fixed a crash caused by clicking on the Virtue Gump icon in the paperdoll
Added some checking before sending a status window to ensure the character is visible and in range
Added some checks to prevent one from inviting themselves to a party

1/17/2009 - giwo
Fixed the handling for the UOX ini tags OVERLOADPACKETS and DARKLEVEL

Expand Down
12 changes: 9 additions & 3 deletions source/PartySystem.cpp
Expand Up @@ -250,16 +250,22 @@ namespace UOX
inviter->sysmessage( "You cannot invite an npc or unknown player" );
return;
}
Party *ourParty = Get( inviter->CurrcharObj() );
CChar *inviterChar = inviter->CurrcharObj();
if( ValidateObject( inviterChar ) && inviterChar == toInvite )
{
inviter->sysmessage( "You cannot invite yourself to a party" );
return;
}
Party *ourParty = Get( inviterChar );
if( ourParty == NULL )
{
Party *tParty = Create( inviter->CurrcharObj() );
Party *tParty = Create( inviterChar );
}
CSocket *targSock = toInvite->GetSocket();
if( targSock != NULL )
{
CPPartyInvitation toSend;
toSend.Leader( inviter->CurrcharObj() );
toSend.Leader( inviterChar );
targSock->Send( &toSend );
targSock->sysmessage( "You have been invited to join a party, type /accept or /decline to deal with the invitation" );
}
Expand Down
26 changes: 17 additions & 9 deletions source/cSocket.cpp
Expand Up @@ -582,6 +582,9 @@ void CSocket::LoginComplete( bool newVal )
//| Programmer - Abaddon
//o---------------------------------------------------------------------------o
//| Purpose - Returns the current spell type of the socket
//| 0 - Normal spellcast
//| 1 - Scroll
//| 2 - Wand
//o---------------------------------------------------------------------------o
UI08 CSocket::CurrentSpellType( void ) const
{
Expand Down Expand Up @@ -1664,25 +1667,30 @@ UI32 CSocket::BytesReceived( void ) const
//o---------------------------------------------------------------------------o
//| Purpose - Opens the status window
//o---------------------------------------------------------------------------o
void CSocket::statwindow( CChar *i )
void CSocket::statwindow( CChar *targChar )
{
if( !ValidateObject( i ) )
if( !ValidateObject( targChar ) )
return;

if( !LoginComplete() )
return;

CPStatWindow toSend( (*i), (*this) );

CChar *mChar = CurrcharObj();

if( mChar != targChar && mChar->GetCommandLevel() < CL_CNS &&
(targChar->GetVisible() != VT_VISIBLE || ( !targChar->IsNpc() && !isOnline( (*targChar) ) ) || !charInRange(mChar, targChar) ) )
return;

CPStatWindow toSend( (*targChar), (*this) );

//Zippy 9/17/01 : fixed bug of your name on your own stat window
toSend.NameChange( mChar != i && ( mChar->IsGM() || i->GetOwnerObj() == mChar ) );
toSend.Gold( GetItemAmount( i, 0x0EED ) );
toSend.AC( Combat->calcDef( i, 0, false ) );
toSend.Weight( static_cast<UI16>(i->GetWeight() / 100) );
toSend.NameChange( mChar != targChar && ( mChar->GetCommandLevel() >= CL_GM || targChar->GetOwnerObj() == mChar ) );
toSend.Gold( GetItemAmount( targChar, 0x0EED ) );
toSend.AC( Combat->calcDef( targChar, 0, false ) );
toSend.Weight( static_cast<UI16>(targChar->GetWeight() / 100) );
Send( &toSend );

CPExtendedStats exStats( (*i) );
CPExtendedStats exStats( (*targChar) );
Send( &exStats );
}

Expand Down
2 changes: 1 addition & 1 deletion source/cVersionClass.cpp
Expand Up @@ -21,7 +21,7 @@ namespace UOX
// product info
//o---------------------------------------------------------------------------o
const std::string VER = "0.98-4";
const std::string BUILD = "0";
const std::string BUILD = "0a";
const std::string REALBUILD = "0";
const std::string SVER = "2.0";
const std::string CVER = "2.0";
Expand Down
30 changes: 18 additions & 12 deletions source/gumps.cpp
Expand Up @@ -1387,23 +1387,36 @@ bool CPIGumpMenuSelect::Handle( void )
gumpID = tSock->GetDWord( 7 );
buttonID = tSock->GetDWord( 11 );
switchCount = tSock->GetDWord( 15 );
textOffset = 19 + (4 * switchCount);
textCount = tSock->GetDWord( textOffset );

#if defined( UOX_DEBUG_MODE )
Console << "CPIGumpMenuSelect::Handle(void)" << myendl;
Console << " GumpID : " << gumpID << myendl;
Console << " ButtonID : " << buttonID << myendl;
Console << " SwitchCount : " << switchCount << myendl;
#endif

if( gumpID == 461 ) // Virtue gump
{
if( buttonID == 1 && switchCount > 0 ) // Clicked on a players Virtue Gump icon
{
SERIAL targSer = tSock->GetDWord( 19 );
}
else // Clicked an item on the virtue gump
{
}
return true;
}

textOffset = 19 + (4 * switchCount);
textCount = tSock->GetDWord( textOffset );

#if defined( UOX_DEBUG_MODE )
Console << " TextOffset : " << textOffset << myendl;
Console << " TextCount : " << textCount << myendl;
#endif

BuildTextLocations();

if( tSock == NULL )
return true;

if( buttonID > 10000 )
{
BuildGumpFromScripts( tSock, (UI16)(buttonID - 10000) );
Expand All @@ -1426,13 +1439,6 @@ bool CPIGumpMenuSelect::Handle( void )
MultiGumpCallback( tSock, id, buttonID );
return true;
}
else if( gumpID == 0x01CD )
{
#if defined( _MSC_VER )
#pragma note( "Newly passed button press due to the pentagram in the 2D and 3D clients" )
#pragma note( "The question is... what does it DO?" )
#endif
}
else if( gumpID > 13 )
return true; //increase this value with each new gump added.
if( buttonID == 1 )
Expand Down

0 comments on commit 56b7782

Please sign in to comment.