mirror of
https://github.com/SWG-Source/src.git
synced 2026-07-29 23:15:56 -04:00
more null checks in places where we're calling createAppearance; some cleanup
This commit is contained in:
@@ -835,12 +835,16 @@ void GameServer::loadTerrain ()
|
||||
|
||||
TerrainObject * const terrainObject = new TerrainObject(ServerWorld::getTerrainObjectNotification());
|
||||
terrainObject->setDebugName("terrain");
|
||||
|
||||
Appearance * const appearance = AppearanceTemplateList::createAppearance(terrainFileName);
|
||||
terrainObject->setAppearance(appearance);
|
||||
if (appearance != NULL) {
|
||||
terrainObject->setAppearance(appearance);
|
||||
}
|
||||
|
||||
ProceduralTerrainAppearance * const proceduralTerrainAppearance = dynamic_cast<ProceduralTerrainAppearance *>(appearance);
|
||||
if (proceduralTerrainAppearance)
|
||||
if (proceduralTerrainAppearance) {
|
||||
ServerObjectTerrainModificationNotification::setTerrainAppearance(proceduralTerrainAppearance);
|
||||
}
|
||||
|
||||
terrainObject->addToWorld();
|
||||
}
|
||||
|
||||
@@ -208,7 +208,11 @@ void DoorObject::createAppearance ( DoorInfo const & info )
|
||||
{
|
||||
if (info.m_frameAppearance && info.m_frameAppearance[0])
|
||||
{
|
||||
setAppearance(AppearanceTemplateList::createAppearance(info.m_frameAppearance));
|
||||
Appearance * const appearance = AppearanceTemplateList::createAppearance(info.m_frameAppearance);
|
||||
|
||||
if (appearance != NULL) {
|
||||
setAppearance(appearance);
|
||||
}
|
||||
}
|
||||
|
||||
m_drawnDoor[0] = new Object();
|
||||
@@ -239,14 +243,24 @@ void DoorObject::createAppearance ( DoorInfo const & info )
|
||||
{
|
||||
if (info.m_doorAppearance && info.m_doorAppearance[0])
|
||||
{
|
||||
m_drawnDoor[0]->setAppearance(AppearanceTemplateList::createAppearance(info.m_doorAppearance));
|
||||
Appearance * const appearance = AppearanceTemplateList::createAppearance(info.m_doorAppearance);
|
||||
|
||||
if (appearance != NULL) {
|
||||
m_drawnDoor[0]->setAppearance(appearance);
|
||||
}
|
||||
}
|
||||
|
||||
if (info.m_doorAppearance2 && info.m_doorAppearance2[0])
|
||||
{
|
||||
m_drawnDoor[1] = new Object();
|
||||
m_drawnDoor[1]->attachToObject_p(this,true);
|
||||
m_drawnDoor[1]->setAppearance(AppearanceTemplateList::createAppearance(info.m_doorAppearance2));
|
||||
|
||||
Appearance * const appearance = AppearanceTemplateList::createAppearance(info.m_doorAppearance2);
|
||||
|
||||
if (appearance != NULL) {
|
||||
m_drawnDoor[1]->setAppearance(appearance);
|
||||
}
|
||||
|
||||
if (info.m_doorFlip2)
|
||||
m_drawnDoor[1]->yaw_o(PI);
|
||||
}
|
||||
|
||||
+19
-11
@@ -232,14 +232,21 @@ const AppearanceTemplate *AppearanceTemplateList::fetch(const char *const fileNa
|
||||
DEBUG_WARNING(true, ("AppearanceTemplateList::fetch could not open '%s', using default", fileName));
|
||||
actualFileName = getDefaultAppearanceTemplateName();
|
||||
}
|
||||
else
|
||||
|
||||
if (actualFileName)
|
||||
{
|
||||
found = true;
|
||||
|
||||
//-- search for the appearance
|
||||
AppearanceTemplate *const appearanceTemplate = create(actualFileName);
|
||||
//-- search for the appearance
|
||||
AppearanceTemplate *const appearanceTemplate = create(actualFileName);
|
||||
|
||||
//-- up the reference count
|
||||
return fetch(appearanceTemplate);
|
||||
//-- up the reference count
|
||||
return fetch(appearanceTemplate);
|
||||
}
|
||||
|
||||
DEBUG_WARNING(true, ("AppearanceTemplateList::fetch actualFileName fetch for %s failed.", actualFileName));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -389,18 +396,18 @@ Appearance *AppearanceTemplateList::createAppearance(const char *const fileName)
|
||||
{
|
||||
DEBUG_FATAL(!ms_installed, ("not installed"));
|
||||
|
||||
#ifdef _DEBUG
|
||||
DataLint::pushAsset(fileName);
|
||||
#endif
|
||||
|
||||
//-- get the appearance template
|
||||
const AppearanceTemplate *const appearanceTemplate = fetch(fileName);
|
||||
|
||||
if(!appearanceTemplate){
|
||||
if (appearanceTemplate == NULL){
|
||||
DEBUG_WARNING(true, ("FIX ME: Appearance template for %s could not be fetched - is it missing?", fileName));
|
||||
return NULL; // Cekis: TODO: Figure out why the template can't be fetched.
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
DataLint::pushAsset(fileName);
|
||||
#endif
|
||||
|
||||
//-- creating the appearance will increment the reference count
|
||||
Appearance *const appearance = appearanceTemplate->createAppearance();
|
||||
|
||||
@@ -585,8 +592,9 @@ AppearanceTemplate *AppearanceTemplateListNamespace::create(const char *const fi
|
||||
|
||||
const Tag tag = iff.getCurrentName();
|
||||
TagBindingMap::iterator iter = ms_tagBindingMap.find(tag);
|
||||
if (iter != ms_tagBindingMap.end())
|
||||
if (iter != ms_tagBindingMap.end()) {
|
||||
appearanceTemplate = iter->second(actualFileName.getString(), &iff);
|
||||
}
|
||||
else
|
||||
{
|
||||
char tagString[5];
|
||||
|
||||
@@ -2460,8 +2460,11 @@ void Object::setAppearanceByName(char const *path)
|
||||
// Create the object's new appearance
|
||||
|
||||
Appearance *appearance = AppearanceTemplateList::createAppearance(path);
|
||||
|
||||
setAppearance(appearance);
|
||||
|
||||
if (appearance != NULL)
|
||||
{
|
||||
setAppearance(appearance);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3270,6 +3273,10 @@ void Object::setAlternateAppearance(const char * path)
|
||||
if (TreeFile::exists(path))
|
||||
{
|
||||
alternateAppearance = AppearanceTemplateList::createAppearance(path);
|
||||
|
||||
if (alternateAppearance == NULL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -431,11 +431,14 @@ void CellProperty::initialize(const PortalProperty &portalProperty, int cellInde
|
||||
m_appearanceObject->setDebugName("Cell appearance object");
|
||||
m_appearanceObject->attachToObject_p(&getOwner(), true);
|
||||
Appearance * const appearance = AppearanceTemplateList::createAppearance(cellTemplate.getAppearanceName());
|
||||
appearance->setShadowBlobAllowed();
|
||||
m_appearanceObject->setAppearance(appearance);
|
||||
|
||||
if (ms_addToRenderWorldHook)
|
||||
ms_addToRenderWorldHook(*m_appearanceObject);
|
||||
if (appearance != NULL) {
|
||||
appearance->setShadowBlobAllowed();
|
||||
m_appearanceObject->setAppearance(appearance);
|
||||
|
||||
if (ms_addToRenderWorldHook)
|
||||
ms_addToRenderWorldHook(*m_appearanceObject);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------
|
||||
|
||||
@@ -460,8 +460,10 @@ void PortalProperty::debugPrint(std::string &buffer) const
|
||||
void PortalProperty::createAppearance()
|
||||
{
|
||||
Appearance * const appearance = AppearanceTemplateList::createAppearance(m_template->getExteriorAppearanceName());
|
||||
appearance->setShadowBlobAllowed();
|
||||
getOwner().setAppearance(appearance);
|
||||
if (appearance != NULL) {
|
||||
appearance->setShadowBlobAllowed();
|
||||
getOwner().setAppearance(appearance);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
+33
-27
@@ -1182,22 +1182,25 @@ void ProceduralTerrainAppearance::_legacyCreateFlora(const Chunk* const chunk)
|
||||
Object* const object = new Object ();
|
||||
object->yaw_o (yaw);
|
||||
Appearance * const appearance = AppearanceTemplateList::createAppearance (FileName (FileName::P_appearance, data.familyChildData->appearanceTemplateName));
|
||||
appearance->setKeepAlive (true);
|
||||
object->setAppearance (appearance);
|
||||
object->setScale (Vector::xyz111 * scale);
|
||||
|
||||
if (ms_createFloraHookFunction)
|
||||
if (appearance != NULL) {
|
||||
appearance->setKeepAlive (true);
|
||||
object->setAppearance (appearance);
|
||||
object->setScale (Vector::xyz111 * scale);
|
||||
|
||||
if (ms_createFloraHookFunction)
|
||||
ms_createFloraHookFunction (*object);
|
||||
|
||||
object->setPosition_p (floraPosition);
|
||||
|
||||
object->setPosition_p (floraPosition);
|
||||
CollisionProperty* const collisionProperty = new CollisionProperty (*object);
|
||||
collisionProperty->setFlora (true);
|
||||
object->addProperty (*collisionProperty);
|
||||
|
||||
CollisionProperty* const collisionProperty = new CollisionProperty (*object);
|
||||
collisionProperty->setFlora (true);
|
||||
object->addProperty (*collisionProperty);
|
||||
object->addToWorld ();
|
||||
|
||||
object->addToWorld ();
|
||||
|
||||
IGNORE_RETURN (m_floraMap->insert (std::make_pair (key, object)));
|
||||
IGNORE_RETURN (m_floraMap->insert (std::make_pair (key, object)));
|
||||
}
|
||||
} //lint !e429 //-- collisionProperty has not been freed or returned
|
||||
}
|
||||
}
|
||||
@@ -1334,24 +1337,27 @@ void ProceduralTerrainAppearance::createFlora (const Chunk* const chunk)
|
||||
Object* const object = new Object ();
|
||||
object->yaw_o (yaw);
|
||||
Appearance * const appearance = AppearanceTemplateList::createAppearance (FileName (FileName::P_appearance, data.familyChildData->appearanceTemplateName));
|
||||
appearance->setKeepAlive (true);
|
||||
object->setAppearance (appearance);
|
||||
object->setScale (Vector::xyz111 * scale);
|
||||
|
||||
if (ms_createFloraHookFunction)
|
||||
{
|
||||
ms_createFloraHookFunction(*object);
|
||||
if (appearance != NULL) {
|
||||
appearance->setKeepAlive (true);
|
||||
object->setAppearance (appearance);
|
||||
object->setScale (Vector::xyz111 * scale);
|
||||
|
||||
if (ms_createFloraHookFunction)
|
||||
{
|
||||
ms_createFloraHookFunction(*object);
|
||||
}
|
||||
|
||||
object->setPosition_p (floraPosition);
|
||||
|
||||
CollisionProperty* const collisionProperty = new CollisionProperty (*object);
|
||||
collisionProperty->setFlora (true);
|
||||
object->addProperty (*collisionProperty);
|
||||
|
||||
object->addToWorld ();
|
||||
|
||||
IGNORE_RETURN (m_floraMap->insert (std::make_pair (key, object)));
|
||||
}
|
||||
|
||||
object->setPosition_p (floraPosition);
|
||||
|
||||
CollisionProperty* const collisionProperty = new CollisionProperty (*object);
|
||||
collisionProperty->setFlora (true);
|
||||
object->addProperty (*collisionProperty);
|
||||
|
||||
object->addToWorld ();
|
||||
|
||||
IGNORE_RETURN (m_floraMap->insert (std::make_pair (key, object)));
|
||||
} //lint !e429 //-- collisionProperty has not been freed or returned
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user