aboutsummaryrefslogtreecommitdiff
path: root/src/server/collision/Models/GameObjectModel.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2012-02-23 15:56:53 +0100
committerShauren <shauren.trinity@gmail.com>2012-02-23 15:56:53 +0100
commitadc115dc41a7af07ab27f35db674568fd88d05db (patch)
treef00d5a5959173fd1697a0c79c0898218faea8503 /src/server/collision/Models/GameObjectModel.cpp
parent40cda6b095a294a94bcd9b3484a57c26feedb13d (diff)
Core/Vmaps: Fixed errors during loading gameobject models and improved error output (will now write to logs)
Diffstat (limited to 'src/server/collision/Models/GameObjectModel.cpp')
-rw-r--r--src/server/collision/Models/GameObjectModel.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/server/collision/Models/GameObjectModel.cpp b/src/server/collision/Models/GameObjectModel.cpp
index 1abbc59a5b0..c0bcdd1e782 100644
--- a/src/server/collision/Models/GameObjectModel.cpp
+++ b/src/server/collision/Models/GameObjectModel.cpp
@@ -33,6 +33,8 @@ using G3D::Vector3;
using G3D::Ray;
using G3D::AABox;
+#ifndef NO_CORE_FUNCS
+
struct GameobjectModelData
{
GameobjectModelData(const std::string& name_, const AABox& box) :
@@ -47,23 +49,30 @@ ModelList model_list;
void LoadGameObjectModelList()
{
+ uint32 oldMSTime = getMSTime();
FILE* model_list_file = fopen((sWorld->GetDataPath() + "vmaps/" + VMAP::GAMEOBJECT_MODELS).c_str(), "rb");
if (!model_list_file)
+ {
+ sLog->outError("Unable to open '%s' file.", VMAP::GAMEOBJECT_MODELS);
return;
+ }
uint32 name_length, displayId;
char buff[500];
- while (!feof(model_list_file))
+ while (true)
{
Vector3 v1, v2;
- if (fread(&displayId, sizeof(uint32), 1, model_list_file) != 1
- || fread(&name_length, sizeof(uint32), 1, model_list_file) != 1
+ if (fread(&displayId, sizeof(uint32), 1, model_list_file) != 1)
+ if (feof(model_list_file)) // EOF flag is only set after failed reading attempt
+ break;
+
+ if (fread(&name_length, sizeof(uint32), 1, model_list_file) != 1
|| name_length >= sizeof(buff)
|| fread(&buff, sizeof(char), name_length, model_list_file) != name_length
|| fread(&v1, sizeof(Vector3), 1, model_list_file) != 1
|| fread(&v2, sizeof(Vector3), 1, model_list_file) != 1)
{
- printf("\nFile '%s' seems to be corrupted", VMAP::GAMEOBJECT_MODELS);
+ sLog->outError("File '%s' seems to be corrupted!", VMAP::GAMEOBJECT_MODELS);
break;
}
@@ -72,7 +81,10 @@ void LoadGameObjectModelList()
ModelList::value_type( displayId, GameobjectModelData(std::string(buff,name_length),AABox(v1,v2)) )
);
}
+
fclose(model_list_file);
+ sLog->outString(">> Loaded %d GameObject models in %u ms", model_list.size(), GetMSTimeDiffToNow(oldMSTime));
+ sLog->outString();
}
GameObjectModel::~GameObjectModel()
@@ -91,7 +103,7 @@ bool GameObjectModel::initialize(const GameObject& go, const GameObjectDisplayIn
// ignore models with no bounds
if (mdl_box == G3D::AABox::zero())
{
- std::cout << "Model " << it->second.name << " has zero bounds, loading skipped" << std::endl;
+ sLog->outError("GameObject model %s has zero bounds, loading skipped", it->second.name);
return false;
}
@@ -171,3 +183,5 @@ bool GameObjectModel::intersectRay(const G3D::Ray& ray, float& MaxDist, bool Sto
}
return hit;
}
+
+#endif