Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 11-30-2010, 06:38 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Well, the reason it works as I explained is because if it finds a false in the first check, there is no need to go past that unless there was an || (OR) statement after the first check.

If your check resulted in the following:

Code:
elsif (false && true) {
Then, perl already knew it wasn't going to pass the check by the time it reached the &&, so there wasn't a reason to even bother checking the second one. This logic is good in multiple ways. One bonus is that it saves processing time, as it doesn't need to even bother checking after it reaches a false. Another nice thing about it working like that is that you can check for things that require other things without risking a null pointer zone crash. Here is an example:

Code:
if ($npc->GetTarget() && $npc->GetTarget()->IsClient())
So, this will only check if the NPC's target is a client IF the NPC actually has a target in the first place. If you tried to do this:

Code:
if ($npc->GetTarget()->IsClient())
without first making sure the NPC has a target, you would be opening up a possible zone crash.

Since the example I gave checks for a target first, and then checks if that target is a client, it is safe from crashes. If Perl worked like you thought it did, that example would still be open to crash issues, as it would check both no matter what.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 12:32 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3