From 9678341a11caa08a40c3ddb562d893fc0cd2ba73 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Thu, 24 Jul 2014 12:15:48 +0200 Subject: [PATCH] Made the cWorld::SpawnMobFinalize function more readable. --- src/World.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/World.cpp b/src/World.cpp index 4ddd11f59..104805209 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2975,21 +2975,31 @@ int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eTyp int cWorld::SpawnMobFinalize(cMonster * a_Monster) { + // Invalid cMonster object. Bail out. if (!a_Monster) + { return -1; + } + + // Give the mob full health. a_Monster->SetHealth(a_Monster->GetMaxHealth()); + + // A plugin doesn't agree with the spawn. bail out. if (cPluginManager::Get()->CallHookSpawningMonster(*this, *a_Monster)) { delete a_Monster; a_Monster = NULL; return -1; } + + // Initialize the monster into the current world. if (!a_Monster->Initialize(*this)) { delete a_Monster; a_Monster = NULL; return -1; } + BroadcastSpawnEntity(*a_Monster); cPluginManager::Get()->CallHookSpawnedMonster(*this, *a_Monster);