Skip to content

Commit

Permalink
[9869] Extend SCRIPT_COMMAND_QUEST_EXPLORED to allow player<->player …
Browse files Browse the repository at this point in the history
…as source/target

Additional code cleanup and output script id in error messages.

Signed-off-by: NoFantasy <nofantasy@nf.no>
  • Loading branch information
NoFantasy committed May 11, 2010
1 parent cdc849e commit cf5b81d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
27 changes: 13 additions & 14 deletions src/game/Map.cpp
Expand Up @@ -3210,27 +3210,27 @@ void Map::ScriptsProcess()
}
case SCRIPT_COMMAND_QUEST_EXPLORED:
{
if(!source)
if (!source)
{
sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for NULL source.");
sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED (script id %u) call for NULL source.", step.script->id);
break;
}

if(!target)
if (!target)
{
sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for NULL target.");
sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED (script id %u) call for NULL target.", step.script->id);
break;
}

// when script called for item spell casting then target == (unit or GO) and source is player
WorldObject* worldObject;
Player* player;

if(target->GetTypeId()==TYPEID_PLAYER)
if (target->GetTypeId() == TYPEID_PLAYER)
{
if(source->GetTypeId()!=TYPEID_UNIT && source->GetTypeId()!=TYPEID_GAMEOBJECT)
if (source->GetTypeId() != TYPEID_UNIT && source->GetTypeId() != TYPEID_GAMEOBJECT && source->GetTypeId() != TYPEID_PLAYER)
{
sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for non-creature and non-gameobject (TypeId: %u), skipping.",source->GetTypeId());
sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED (script id %u) call for non-creature, non-gameobject or non-player (TypeId: %u), skipping.", step.script->id, source->GetTypeId());
break;
}

Expand All @@ -3239,15 +3239,15 @@ void Map::ScriptsProcess()
}
else
{
if(target->GetTypeId()!=TYPEID_UNIT && target->GetTypeId()!=TYPEID_GAMEOBJECT)
if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER)
{
sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for non-creature and non-gameobject (TypeId: %u), skipping.",target->GetTypeId());
sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED (script id %u) call for non-creature, non-gameobject or non-player (TypeId: %u), skipping.", step.script->id, target->GetTypeId());
break;
}

if(source->GetTypeId()!=TYPEID_PLAYER)
if (source->GetTypeId() != TYPEID_PLAYER)
{
sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for non-player(TypeId: %u), skipping.",source->GetTypeId());
sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED (script id %u) call for non-player (TypeId: %u), skipping.", step.script->id, source->GetTypeId());
break;
}

Expand All @@ -3256,15 +3256,14 @@ void Map::ScriptsProcess()
}

// quest id and flags checked at script loading
if( (worldObject->GetTypeId()!=TYPEID_UNIT || ((Unit*)worldObject)->isAlive()) &&
(step.script->datalong2==0 || worldObject->IsWithinDistInMap(player,float(step.script->datalong2))) )
if ((worldObject->GetTypeId() != TYPEID_UNIT || ((Unit*)worldObject)->isAlive()) &&
(step.script->datalong2 == 0 || worldObject->IsWithinDistInMap(player, float(step.script->datalong2))))
player->AreaExploredOrEventHappens(step.script->datalong);
else
player->FailQuest(step.script->datalong);

break;
}

case SCRIPT_COMMAND_ACTIVATE_OBJECT:
{
if(!source)
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9868"
#define REVISION_NR "9869"
#endif // __REVISION_NR_H__

0 comments on commit cf5b81d

Please sign in to comment.