From: <vo...@us...> - 2008-12-17 15:19:20
|
Revision: 1034 http://opde.svn.sourceforge.net/opde/?rev=1034&view=rev Author: volca Date: 2008-12-17 15:19:12 +0000 (Wed, 17 Dec 2008) Log Message: ----------- Couple of fixes - opde is now usable without dtype scripts! Modified Paths: -------------- trunk/scripts/shock2/ss2-props.pldef trunk/scripts/thief1/t1-links.pldef trunk/scripts/thief1/t1-props.pldef trunk/scripts/thief2/t2-links.pldef trunk/scripts/thief2/t2-props.pldef trunk/src/base/servicemanager/OpdeService.h trunk/src/base/servicemanager/OpdeServiceManager.cpp trunk/src/main/GameStateManager.cpp trunk/src/main/ProxyArchive.cpp trunk/src/main/ProxyArchive.h trunk/src/services/inherit/InheritService.cpp trunk/src/services/link/LinkService.cpp trunk/src/services/render/RenderService.cpp Modified: trunk/scripts/shock2/ss2-props.pldef =================================================================== --- trunk/scripts/shock2/ss2-props.pldef 2008-12-17 12:24:28 UTC (rev 1033) +++ trunk/scripts/shock2/ss2-props.pldef 2008-12-17 15:19:12 UTC (rev 1034) @@ -1609,10 +1609,10 @@ label "NonPhysicalCreature" } -property ModelName { - label "ModelName" - p_ver 2.16 -} +//property ModelName { +// label "ModelName" +// p_ver 2.16 +//} property TransRate { label "TransluceRate" Modified: trunk/scripts/thief1/t1-links.pldef =================================================================== --- trunk/scripts/thief1/t1-links.pldef 2008-12-17 12:24:28 UTC (rev 1033) +++ trunk/scripts/thief1/t1-links.pldef 2008-12-17 15:19:12 UTC (rev 1034) @@ -82,9 +82,9 @@ } -relation PlayerFactory { - no_data -} +//relation PlayerFactory { +// no_data +//} relation Firer { Modified: trunk/scripts/thief1/t1-props.pldef =================================================================== --- trunk/scripts/thief1/t1-props.pldef 2008-12-17 12:24:28 UTC (rev 1033) +++ trunk/scripts/thief1/t1-props.pldef 2008-12-17 15:19:12 UTC (rev 1034) @@ -1001,10 +1001,10 @@ p_ver 2.66537 } -property ModelName { - label "ModelName" - p_ver 2.16 -} +//property ModelName { +// label "ModelName" +// p_ver 2.16 +//} property StTweq4Em { label "TweqEmitter4State" Modified: trunk/scripts/thief2/t2-links.pldef =================================================================== --- trunk/scripts/thief2/t2-links.pldef 2008-12-17 12:24:28 UTC (rev 1033) +++ trunk/scripts/thief2/t2-links.pldef 2008-12-17 15:19:12 UTC (rev 1034) @@ -80,9 +80,9 @@ } -relation PlayerFactory { - no_data -} +//relation PlayerFactory { +// no_data +//} relation Firer { no_data Modified: trunk/scripts/thief2/t2-props.pldef =================================================================== --- trunk/scripts/thief2/t2-props.pldef 2008-12-17 12:24:28 UTC (rev 1033) +++ trunk/scripts/thief2/t2-props.pldef 2008-12-17 15:19:12 UTC (rev 1034) @@ -1302,10 +1302,10 @@ label "NonPhysicalCreature" } -property ModelName { - label "ModelName" - p_ver 2.16 -} +//property ModelName { +// label "ModelName" +// p_ver 2.16 +//} property StTweq4Em { label "TweqEmitter4State" Modified: trunk/src/base/servicemanager/OpdeService.h =================================================================== --- trunk/src/base/servicemanager/OpdeService.h 2008-12-17 12:24:28 UTC (rev 1033) +++ trunk/src/base/servicemanager/OpdeService.h 2008-12-17 15:19:12 UTC (rev 1034) @@ -41,7 +41,7 @@ class OPDELIB_EXPORT Service : public NonCopyable { protected: friend class ServiceManager; - + ServiceManager* mServiceManager; std::string mName; @@ -53,6 +53,9 @@ */ virtual ~Service(); + /// Service name getter + inline const std::string& getName() const { return mName; }; + protected: /** Intialization of the service. Guaranteed to be called after construction (If constructor was sucessful). * Used to estabilish relations with other services. Only the dependencies that are fixed can be resolved here, otherwise use the bootstrapFinished. Modified: trunk/src/base/servicemanager/OpdeServiceManager.cpp =================================================================== --- trunk/src/base/servicemanager/OpdeServiceManager.cpp 2008-12-17 12:24:28 UTC (rev 1033) +++ trunk/src/base/servicemanager/OpdeServiceManager.cpp 2008-12-17 15:19:12 UTC (rev 1034) @@ -25,6 +25,7 @@ #include "config.h" #include <iostream> +#include <vector> #include "OpdeServiceManager.h" #include "OpdeService.h" @@ -37,11 +38,11 @@ template<> ServiceManager* Singleton<ServiceManager>::ms_Singleton = 0; - ServiceManager::ServiceManager(uint serviceMask) : - mServiceFactories(), - mServiceInstances(), + ServiceManager::ServiceManager(uint serviceMask) : + mServiceFactories(), + mServiceInstances(), mBootstrapFinished(false), - mGlobalServiceMask(serviceMask) { + mGlobalServiceMask(serviceMask) { } ServiceManager::~ServiceManager() { @@ -49,7 +50,7 @@ LOG_DEBUG("ServiceManager: Releasing all services"); ServiceInstanceMap::iterator s_it; - + s_it = mServiceInstances.begin(); LOG_INFO("ServiceManager: Shutting down all services"); @@ -59,16 +60,16 @@ LOG_INFO(" * Shutting down service '%s'", s_it->first.c_str()); s_it->second->shutdown(); } - + s_it = mServiceInstances.begin(); LOG_INFO("ServiceManager: Releasing all services"); for (; s_it != mServiceInstances.end(); ++s_it) { LOG_INFO(" * Releasing service %s (ref. count %d)", s_it->first.c_str(), s_it->second.getRefCount()); - + /*if (s_it->second.getRefCount() > 0) LOG_FATAL(" * Service '%s' has reference count > 1. It won't probably be released immediately!", s_it->first.c_str());*/ - + s_it->second.setNull(); } @@ -132,7 +133,7 @@ if (factory != NULL) { // Found a factory for the Service name if (!(factory->getMask() & mGlobalServiceMask)) OPDE_EXCEPT("Initialization of service " + factory->getName() + " was not permitted by mask. Please consult OPDE log for details", "ServiceManager::createInstance"); - + ServicePtr ns = factory->createInstance(this); mServiceInstances.insert(make_pair(factory->getName(), ns)); @@ -166,7 +167,7 @@ for (; factory_it != mServiceFactories.end(); ++factory_it) { // if the mask fits and the service is permitted by global service mask - if ((factory_it->second->getMask() & mask) && (factory_it->second->getMask() & mGlobalServiceMask)) { + if ((factory_it->second->getMask() & mask) && (factory_it->second->getMask() & mGlobalServiceMask)) { ServicePtr service = getService(factory_it->second->getName()); } } @@ -176,15 +177,28 @@ if (mBootstrapFinished) // just do this once return; - ServiceInstanceMap::iterator it = mServiceInstances.begin(); + // Here's a catch: The services can create other services while bootstrapping + // process is performed. That means the service map can be modified, + // and so it's not guaranteed that the bootstrap will be called on those. + // For a fix, we set the mBootstrapFinished flag in advance, which means + // createInstance will also bootstrap - for (; it != mServiceInstances.end() ; ++it ) { - LOG_DEBUG("ServiceManager: Bootstrap finished: informing %s", it->first.c_str()); + std::vector<ServicePtr> toBootstrap; - it->second->bootstrapFinished(); + ServiceInstanceMap::iterator it = mServiceInstances.begin(); + + for (; it != mServiceInstances.end() ; ++it ) + toBootstrap.push_back(it->second); + + mBootstrapFinished = true; + + std::vector<ServicePtr>::iterator tit = toBootstrap.begin(); + + for (; tit != toBootstrap.end() ; ++tit ) { + LOG_DEBUG("ServiceManager: Bootstrap finished: informing %s", (*tit)->getName().c_str()); + + (*tit)->bootstrapFinished(); }; - - mBootstrapFinished = true; } } Modified: trunk/src/main/GameStateManager.cpp =================================================================== --- trunk/src/main/GameStateManager.cpp 2008-12-17 12:24:28 UTC (rev 1033) +++ trunk/src/main/GameStateManager.cpp 2008-12-17 15:19:12 UTC (rev 1034) @@ -157,10 +157,16 @@ // override the config setting mConfigService->setParam("game_type", mGameType); - RenderServicePtr rends; - rends = GET_SERVICE(RenderService); + // To be sure it exists, and because this is just a testing code + // and to remove the need to parse scripts, + // we create the data-less Relation PlayerFactory here + LinkServicePtr linksvc = GET_SERVICE(LinkService); + linksvc->createRelation("PlayerFactory", NULL, false); + linksvc.setNull(); + RenderServicePtr rends = GET_SERVICE(RenderService); + // Setup resources. setupResources(); @@ -202,7 +208,7 @@ * The parameter is split to path and mission file name * the path goes to the default resource group (if not already in) * the name is then loaded - */ + */ if (mConfigService->hasParam("mission")) { DVariant mis = mConfigService->getParam("mission"); Modified: trunk/src/main/ProxyArchive.cpp =================================================================== --- trunk/src/main/ProxyArchive.cpp 2008-12-17 12:24:28 UTC (rev 1033) +++ trunk/src/main/ProxyArchive.cpp 2008-12-17 15:19:12 UTC (rev 1034) @@ -32,7 +32,7 @@ // ------------------------------------------------------- // ----- Proxy Archive ----------------------------------- // ------------------------------------------------------- - ProxyArchive::ProxyArchive(const String& name, const String& archType) : + ProxyArchive::ProxyArchive(const String& name, const String& archType) : Archive(name, archType), mArchive(NULL) { } @@ -40,24 +40,24 @@ // ------------------------------------------------------- ProxyArchive::~ProxyArchive(void) { } - + // ------------------------------------------------------- void ProxyArchive::load(void) { // load, build map mArchive->load(); - + StringVectorPtr lst = mArchive->list(true, false); - + StringVector::iterator it = lst->begin(); - + while (it != lst->end()) { const std::string& fn = *it++; std::string tn = transformName(fn); StringUtil::toLowerCase(tn); // insert into the map - std::pair<NameTable::iterator, bool> result = + std::pair<NameTable::iterator, bool> result = mExtToIntNames.insert(std::make_pair(tn, fn)); - + // see if the result is ok, except if not if (!result.second) OGRE_EXCEPT(Exception::ERR_DUPLICATE_ITEM, @@ -65,25 +65,25 @@ "ProxyArchive::load"); } } - - + + // ------------------------------------------------------- void ProxyArchive::unload(void) { mArchive->unload(); - + mExtToIntNames.clear(); } - + // ------------------------------------------------------- FileInfoListPtr ProxyArchive::findFileInfo(const String& pattern, bool recursive , bool dirs) { /// have to list all infos, filter those which fit FileInfoListPtr lst = listFileInfo(recursive, dirs); - + FileInfoListPtr res(new FileInfoList()); - + /// now iterate, the list, match using the name, return FileInfoList::iterator it = lst->begin(); - + while (it != lst->end()) { const FileInfo& fi = *it++; // match? @@ -91,30 +91,30 @@ res->push_back(fi); } } - + return res; } // ------------------------------------------------------- bool ProxyArchive::exists(const String& filename) { - try { - String un = untransformName(filename); + String un; + + if (untransformName(filename, un)) return mArchive->exists(un); - } catch (...) { + else return false; - } } // ------------------------------------------------------- StringVectorPtr ProxyArchive::find(const String& pattern, bool recursive , bool dirs) { /// have to list all infos, filter those which fit StringVectorPtr lst = list(recursive, dirs); - + StringVectorPtr res(new StringVector()); - + /// now iterate, the list, match using the name, return StringVector::iterator it = lst->begin(); - + while (it != lst->end()) { const String& fn = *it++; // match? @@ -122,35 +122,35 @@ res->push_back(fn); } } - + return res; } // ------------------------------------------------------- FileInfoListPtr ProxyArchive::listFileInfo(bool recursive , bool dirs) { FileInfoListPtr list = mArchive->listFileInfo(recursive, dirs); - + FileInfoListPtr res(new FileInfoList()); - + /// now iterate, the list, match using the name, return FileInfoList::iterator it = list->begin(); - + while (it != list->end()) { const FileInfo& fi = *it++; - + FileInfo fin; - + fin.archive = this; fin.filename = transformName(fi.filename); fin.path = transformName(fi.path); fin.basename = transformName(fi.basename); - + fin.compressedSize = fi.compressedSize; fin.uncompressedSize = fi.uncompressedSize; - + res->push_back(fin); } - + return res; } @@ -158,49 +158,56 @@ StringVectorPtr ProxyArchive::list(bool recursive , bool dirs) { /// have to list all infos, filter those which fit StringVectorPtr lst = mArchive->list(recursive, dirs); - + StringVectorPtr res(new StringVector()); - + /// now iterate, the list, match using the name, return StringVector::iterator it = lst->begin(); - + while (it != lst->end()) { const String& fn = *it++; - + res->push_back(transformName(fn)); } - + return res; } // ------------------------------------------------------- DataStreamPtr ProxyArchive::open(const String& filename) const { - String utfn = untransformName(filename); - return mArchive->open(utfn); + String un; + + if (untransformName(filename, un)) + return mArchive->open(un); + else + return DataStreamPtr(); } // ------------------------------------------------------- - std::string ProxyArchive::untransformName(const String& name) const { + bool ProxyArchive::untransformName(const String& name, String& unt) const { String s = name; StringUtil::toLowerCase(s); NameTable::const_iterator it = mExtToIntNames.find(s); - + if (it != mExtToIntNames.end()) { - return it->second; + unt = it->second; + return true; } else { - OGRE_EXCEPT(Exception::ERR_FILE_NOT_FOUND, - "Archive '" + mName + "' does not contain file : " + name, - "ProxyArchive::untransformName"); + return false; } } - + // ------------------------------------------------------- bool ProxyArchive::match(const String& pattern, const String& name) const { - String unt = untransformName(name); + String unt; + + if (!untransformName(name, unt)) + return false; + StringUtil::toLowerCase(unt); String lpattern = pattern; StringUtil::toLowerCase(lpattern); - + // inspired by one codeproject article (but a rewrite without using the code) enum State { @@ -239,7 +246,7 @@ } switch (state) { - case PM_Match: + case PM_Match: match = *pi == *si; case PM_Any: ++pi; ++si; @@ -247,7 +254,7 @@ case PM_AnySeq: // matched any character ++si; - + // found the end of pattern? If so, // then the previous comparisons decide if (pnext == lpattern.end()) { @@ -270,17 +277,17 @@ return match; } - - + + // ------------------------------------------------------- // ----- CaseLess Archive -------------------------------- // ------------------------------------------------------- - CaseLessFileSystemArchive::CaseLessFileSystemArchive(const String& name, + CaseLessFileSystemArchive::CaseLessFileSystemArchive(const String& name, const String& archType) : ProxyArchive(name, archType) { - + mArchive = new Ogre::FileSystemArchive(mName, mType); } - + // ------------------------------------------------------- CaseLessFileSystemArchive::~CaseLessFileSystemArchive(void) { delete mArchive; @@ -290,7 +297,7 @@ bool CaseLessFileSystemArchive::isCaseSensitive(void) const { return false; } - + // ------------------------------------------------------- String CaseLessFileSystemArchive::transformName(const std::string& name) { // simple - just lowercase the name @@ -298,24 +305,24 @@ StringUtil::toLowerCase(res); return res; } - + // ------------------------------------------------------- // ----- CRF Archive ------------------------------------- // ------------------------------------------------------- - CRFArchive::CRFArchive(const String& name, + CRFArchive::CRFArchive(const String& name, const String& archType) : ProxyArchive(name, archType) { - + // split, we only want the file name part String ext, path; StringUtil::splitFullFilename(name, mFilePart, ext, path); - + StringUtil::toLowerCase(mFilePart); - + mFilePart += '/'; - + mArchive = new Ogre::ZipArchive(mName, mType); } - + // ------------------------------------------------------- CRFArchive::~CRFArchive(void) { delete mArchive; @@ -325,7 +332,7 @@ bool CRFArchive::isCaseSensitive(void) const { return false; } - + // ------------------------------------------------------- String CRFArchive::transformName(const std::string& name) { String res = name; @@ -333,13 +340,13 @@ // just lowercase the name, and prefix with the mFilePart return mFilePart + res; } - + // ------------------------------------------------------- const String& CaseLessFileSystemArchiveFactory::getType(void) const { static String name = "Dir"; return name; } - + // ------------------------------------------------------- const String& CrfArchiveFactory::getType(void) const { static String name = "Crf"; Modified: trunk/src/main/ProxyArchive.h =================================================================== --- trunk/src/main/ProxyArchive.h 2008-12-17 12:24:28 UTC (rev 1033) +++ trunk/src/main/ProxyArchive.h 2008-12-17 15:19:12 UTC (rev 1034) @@ -20,7 +20,7 @@ * $Id$ * *****************************************************************************/ - + #ifndef __PROXYARCHIVE_H #define __PROXYARCHIVE_H @@ -28,9 +28,9 @@ #include <OgreArchive.h> #include <OgreArchiveFactory.h> - + namespace Ogre { - + /** Proxy archive, which performs name transforms and delegates to underlying archive instance. * There are couple different possible usages for this archive class: * 1. A case insensitive filesystem archive on *nix systems @@ -42,121 +42,121 @@ * make ogre's file system archive case insensitive on *nix systems. * * @todo The final piece of puzzle will be a class that autoloads crf files as resources \ - * for the predefined group, and a resource listener that allows duplicate resource names in some way + * for the predefined group, and a resource listener that allows duplicate resource names in some way */ class OPDELIB_EXPORT ProxyArchive : public Archive { public: /// constructor ProxyArchive(const String& name, const String& archType); - + /// destructor virtual ~ProxyArchive(void); - + /// performs the archive load. Scans the archive for filenames, builds the reverse transform table virtual void load(void); - + /// Unloads the archive, clears the transform map virtual void unload(void); - + /// opens a resource stream, unmapping the name first virtual DataStreamPtr open(const String& filename) const; - + /// lists the contents of the archive. transformed. virtual StringVectorPtr list(bool recursive = true, bool dirs = false); - + /// lists the contents of the archive. transformed, in the FileInfo structures. virtual FileInfoListPtr listFileInfo(bool recursive = true, bool dirs = false); - + /// performs a pattern match find on the archive files virtual StringVectorPtr find(const String& pattern, bool recursive = true, bool dirs = false); - + /// Searches for the given name, untransforming it first virtual bool exists(const String& filename); - + /** Searches for files that match the given pattern * @see find */ - virtual FileInfoListPtr findFileInfo(const String& pattern, + virtual FileInfoListPtr findFileInfo(const String& pattern, bool recursive = true, bool dirs = false); - + /// reports case sensitiveness of this proxy archive virtual bool isCaseSensitive(void) const = 0; - + protected: /// performs the forward transform on a single name virtual String transformName(const String& name) = 0; - + /// performs an inverse transform on a single name, turning internal name from the external one - virtual String untransformName(const String& name) const; - + virtual bool untransformName(const String& name, String& unt) const; + /** compares if the given filename matches the pattern * By default, this does case insensitive filename match on the untransformed name */ virtual bool match(const String& pattern, const String& name) const; - + typedef std::map<std::string, std::string> NameTable; - + NameTable mExtToIntNames; - + Archive* mArchive; }; - + /// Lowercase transforming file system archive class CaseLessFileSystemArchive : public ProxyArchive { public: CaseLessFileSystemArchive(const String& name, const String& archType); ~CaseLessFileSystemArchive(void); - + bool isCaseSensitive(void) const; - + protected: String transformName(const std::string& name); - + }; - + /// Zip archive wrapper that prefixes the file names with the name without extesion (fam.crf -> fam/*) class CRFArchive : public ProxyArchive { public: CRFArchive(const String& name, const String& archType); ~CRFArchive(void); - + bool isCaseSensitive(void) const; - + protected: String transformName(const std::string& name); - + String mFilePart; }; - + // Factories, so we can actually use these - + class OPDELIB_EXPORT CaseLessFileSystemArchiveFactory : public ArchiveFactory { // what a title! public: virtual ~CaseLessFileSystemArchiveFactory() {} - + const String& getType(void) const; - + Archive* createInstance(const String& name) { return new CaseLessFileSystemArchive(name, "Dir"); } - + void destroyInstance( Archive* arch) { delete arch; } }; - - class CrfArchiveFactory : public ArchiveFactory { + + class CrfArchiveFactory : public ArchiveFactory { public: virtual ~CrfArchiveFactory() {} - + const String& getType(void) const; - + Archive* createInstance(const String& name) { return new CRFArchive(name, "Crf"); } - + void destroyInstance( Archive* arch) { delete arch; } }; - + } #endif Modified: trunk/src/services/inherit/InheritService.cpp =================================================================== --- trunk/src/services/inherit/InheritService.cpp 2008-12-17 12:24:28 UTC (rev 1033) +++ trunk/src/services/inherit/InheritService.cpp 2008-12-17 15:19:12 UTC (rev 1034) @@ -156,7 +156,7 @@ return false; } - // create the builtin metaprop relation and it's storage... + // create the built-in meta property relation and it's storage... DataStoragePtr stor = new UIntDataStorage(NULL); mMetaPropRelation = mLinkService->createRelation("MetaProp", stor, true); Modified: trunk/src/services/link/LinkService.cpp =================================================================== --- trunk/src/services/link/LinkService.cpp 2008-12-17 12:24:28 UTC (rev 1033) +++ trunk/src/services/link/LinkService.cpp 2008-12-17 15:19:12 UTC (rev 1034) @@ -120,8 +120,10 @@ // TODO: Look for the relation name. Have to find it. RelationNameMap::iterator rnit = mRelationNameMap.find(text); - if (rnit == mRelationNameMap.end()) - OPDE_EXCEPT(string("Could not find relation ") + text + " predefined. Could not continue", "LinkService::_load"); + if (rnit == mRelationNameMap.end()) { + LOG_ERROR("LinkService::_load: Could not find relation %s predefined. Skipping", text); + continue; + } RelationPtr rel = rnit->second; @@ -241,6 +243,8 @@ if (!res.second) OPDE_EXCEPT("Failed to insert new instance of Relation", "LinkService::createRelation"); + LOG_VERBOSE("LinkService::createRelation: Succesfully created Relation pair '%s'", name.c_str()); + return nr; } Modified: trunk/src/services/render/RenderService.cpp =================================================================== --- trunk/src/services/render/RenderService.cpp 2008-12-17 12:24:28 UTC (rev 1033) +++ trunk/src/services/render/RenderService.cpp 2008-12-17 15:19:12 UTC (rev 1034) @@ -501,8 +501,12 @@ return; } + // upper, to compare without case + std::string iname = name; + StringUtil::toUpperCase(iname); + // if the new name is particle, just set skip and it's done - if (name == FX_PARTICLE_OBJECT_NAME) { + if (iname == FX_PARTICLE_OBJECT_NAME) { LOG_VERBOSE("RenderService: Mesh rendering for %d disabled", id); ei->setSkip(true); return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |