- Timestamp:
- Nov 26, 2005, 2:20:58 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/text_engine/text_engine.cc
r5515 r5779 64 64 { 65 65 // first remove all the remaining Texts (if any). 66 tList<BaseObject>* textList = ClassList::getList(CL_TEXT);66 std::list<BaseObject*>* textList = ClassList::getList(CL_TEXT); 67 67 if (textList != NULL) 68 68 { 69 tIterator<BaseObject>* textIterator = textList->getIterator(); 70 Text* text = dynamic_cast<Text*>(textIterator->firstElement()); 71 while( text != NULL) 69 while(textList->size() > 0) 72 70 { 73 delete text; 74 text = dynamic_cast<Text*>(textIterator->nextElement()); 71 delete dynamic_cast<Text*>(textList->front()); 75 72 } 76 delete textIterator;77 73 } 78 74 // delete all remaining fonts (There should not be Anything to do here) 79 tList<BaseObject>* fontList = ClassList::getList(CL_FONT);75 std::list<BaseObject*>* fontList = ClassList::getList(CL_FONT); 80 76 if (fontList != NULL) 81 77 { 82 tIterator<BaseObject>* fontIterator = fontList->getIterator(); 83 Font* font = dynamic_cast<Font*>(fontIterator->firstElement()); 84 while( font != NULL) 78 // while (fontList->size() > 0) 85 79 { 80 Font* font = dynamic_cast<Font*>(fontList->front()); 86 81 if (likely(font != Font::getDefaultFont())) 87 82 ResourceManager::getInstance()->unload(font, RP_GAME); 88 font = dynamic_cast<Font*>(fontIterator->nextElement());89 83 } 90 delete fontIterator;91 84 } 92 93 85 this->disableFonts(); 94 86 … … 133 125 void TextEngine::debug() const 134 126 { 135 tList<BaseObject>* textList = ClassList::getList(CL_TEXT);127 list<BaseObject*>* textList = ClassList::getList(CL_TEXT); 136 128 if (textList != NULL) 137 129 { … … 139 131 PRINT(0)("+ TEXT ENGINE DEBUG INFORMATION +\n"); 140 132 PRINT(0)("+-------------------------------+\n"); 141 PRINT(0)("Reference: %p; Text Counts: %d\n", this, textList-> getSize());133 PRINT(0)("Reference: %p; Text Counts: %d\n", this, textList->size()); 142 134 143 tIterator<BaseObject>* textIterator = textList->getIterator(); 144 Text* text = dynamic_cast<Text*>(textIterator->firstElement()); 145 while( text != NULL) 146 { 147 text->debug(); 148 text = dynamic_cast<Text*>(textIterator->nextElement()); 149 } 150 delete textIterator; 135 list<BaseObject*>::iterator text; 136 for ( text = textList->begin(); text != textList->end(); text++) 137 dynamic_cast<Text*>(*text)->debug(); 151 138 PRINT(0)("+---------------------------TE--+\n"); 152 139 } -
trunk/src/lib/lang/class_list.cc
r5770 r5779 40 40 this->className = className; 41 41 this->classID = classID; 42 this->objectList = new tList<BaseObject>;43 42 44 43 ++ClassList::classCount; … … 50 49 ClassList::~ClassList () 51 50 { 52 delete this->objectList;53 if(ClassList::classList != NULL)54 {55 delete ClassList::classList;56 ClassList::classList = NULL;57 }51 /// FIXME 52 // if(ClassList::classList != NULL) 53 // { 54 // delete ClassList::classList; 55 // ClassList::classList = NULL; 56 // } 58 57 --ClassList::classCount; 59 58 } … … 66 65 67 66 //! a List of all strings of all classes, that have registered so far. 68 tList<const char>* ClassList::classList = NULL;67 std::list<const char*> ClassList::classList; 69 68 70 69 /** … … 100 99 } 101 100 } 102 regClass->objectList ->add(objectPointer);101 regClass->objectList.push_back(objectPointer); 103 102 } 104 103 … … 114 113 if (objectPointer->isA(tmp->classID)) 115 114 { 116 tmp->objectList ->remove(objectPointer);115 tmp->objectList.remove(objectPointer); 117 116 } 118 117 tmp = tmp->next; … … 127 126 * befor it changes anything. 128 127 */ 129 const tList<const char>* ClassList::getClassList() 130 { 131 if (unlikely(ClassList::classList != NULL && ClassList::classList->getSize() != ClassList::classCount)) 132 { 133 delete ClassList::classList; 134 ClassList::classList = NULL; 135 } 136 if (unlikely(ClassList::classList == NULL)) 137 ClassList::classList = new tList<const char>; 128 const std::list<const char*>* ClassList::getClassList() 129 { 130 if (ClassList::classList.size() != ClassList::classCount) 131 ClassList::classList.erase(ClassList::classList.begin(), ClassList::classList.end()); 138 132 139 133 if(likely(ClassList::first != NULL)) … … 142 136 while (likely(tmpCL != NULL)) 143 137 { 144 ClassList::classList ->add(tmpCL->className);145 tmpCL = tmpCL->next; 146 } 147 } 148 return ClassList::classList;138 ClassList::classList.push_back(tmpCL->className); 139 tmpCL = tmpCL->next; 140 } 141 } 142 return &ClassList::classList; 149 143 } 150 144 … … 154 148 * @return the List accessed by classID, or NULL if not found 155 149 */ 156 tList<BaseObject>* ClassList::getList(long classID)150 std::list<BaseObject*>* ClassList::getList(long classID) 157 151 { 158 152 if(unlikely(ClassList::first == NULL)) … … 164 158 { 165 159 if (unlikely(tmpCL->classID == classID)) 166 return tmpCL->objectList;160 return &tmpCL->objectList; 167 161 tmpCL = tmpCL->next; 168 162 } … … 175 169 * @param className the name of the class to get the list from 176 170 * @return the List accessed by classID, or NULL if not found 177 */tList<BaseObject>* ClassList::getList(const char* className) 171 */ 172 std::list<BaseObject*>* ClassList::getList(const char* className) 178 173 { 179 174 if(unlikely(ClassList::first == NULL)) … … 185 180 { 186 181 if (unlikely(!strcmp(tmpCL->className, className))) 187 return tmpCL->objectList;182 return &tmpCL->objectList; 188 183 tmpCL = tmpCL->next; 189 184 } … … 210 205 if (tmp->classID == classID || classID == CL_NULL) 211 206 { 212 tIterator<BaseObject>* iterator = tmp->objectList->getIterator(); 213 BaseObject* enumBO = iterator->firstElement(); 214 const char* tmpName; 215 while (enumBO != NULL) 216 { 217 tmpName = enumBO->getName(); 218 if (tmpName && !strcmp(tmpName, name)) 219 { 220 delete iterator; 221 return enumBO; 222 } 223 enumBO = iterator->nextElement(); 224 } 225 delete iterator; 207 list<BaseObject*>::iterator bo; 208 for (bo = tmp->objectList.begin(); bo != tmp->objectList.end(); bo++) 209 if ((*bo)->getName() && !strcmp((*bo)->getName(), name)) 210 return (*bo); 226 211 break; 227 212 } … … 251 236 if (tmp->classID == classID || classID == CL_NULL) 252 237 { 253 tIterator<BaseObject>* iterator = tmp->objectList->getIterator(); 254 const BaseObject* enumBO = iterator->firstElement(); 255 while (enumBO != NULL) 256 { 257 if (enumBO == object) 258 { 259 delete iterator; 238 list<BaseObject*>::iterator bo; 239 for (bo = tmp->objectList.begin(); bo != tmp->objectList.end(); bo++) 240 if ((*bo) == object) 260 241 return true; 261 }262 enumBO = iterator->nextElement();263 }264 242 if (likely(tmp->classID == classID)) 265 {266 delete iterator;267 243 break; 268 }269 244 } 270 245 tmp = tmp->next; … … 354 329 while (likely(tmp != NULL)) 355 330 { 356 if ((debugLevel >= 1 || tmp->objectList ->getSize() > 0 ) &&331 if ((debugLevel >= 1 || tmp->objectList.size() > 0 ) && 357 332 (classID == CL_NULL || unlikely (classID == tmp->classID))) 358 333 { 359 334 lenCount = 1; 360 while (pow(10, lenCount) <= tmp->objectList->getSize())335 while (pow(10, lenCount) <= tmp->objectList.size()) 361 336 ++lenCount; 362 337 for (int i=0; i < 30-strlen(tmp->className) - lenCount; i++) … … 364 339 niceString[30-strlen(tmp->className) - lenCount] = '\0'; 365 340 366 PRINT(0)("| CLASS %s:%s %d\n", tmp->className, niceString, tmp->objectList ->getSize());367 368 if (debugLevel >=2 && tmp->objectList ->getSize() > 0)341 PRINT(0)("| CLASS %s:%s %d\n", tmp->className, niceString, tmp->objectList.size()); 342 343 if (debugLevel >=2 && tmp->objectList.size() > 0) 369 344 { 370 345 PRINT(0)("| Listing Instances:\n"); 371 tIterator<BaseObject>* iterator = tmp->objectList->getIterator(); 372 BaseObject* enumBO = iterator->firstElement(); 373 while (enumBO) 346 list<BaseObject*>::const_iterator bo; 347 for (bo = tmp->objectList.begin(); bo != tmp->objectList.end(); bo++) 374 348 { 375 PRINT(0)("| (class %s): NAME(%s)->%p ", enumBO->getClassName(), enumBO->getName(), enumBO);349 PRINT(0)("| (class %s): NAME(%s)->%p ", (*bo)->getClassName(), (*bo)->getName(), (*bo)); 376 350 if (debugLevel == 3) 377 ClassList::whatIs( enumBO);351 ClassList::whatIs(*bo); 378 352 PRINT(0)("\n"); 379 enumBO = iterator->nextElement();380 353 } 381 delete iterator;382 354 } 383 355 } -
trunk/src/lib/lang/class_list.h
r5405 r5779 9 9 10 10 #include "class_id.h" 11 #include <list> 11 12 12 13 // FORWARD DECLARATION 13 14 class BaseObject; 14 template<class T> class tList;15 16 15 17 16 //! A class that handles Pointers to Objects of all type. … … 35 34 36 35 // STATIC FUNCTIONS 37 static void addToClassList(BaseObject* objectPointer, const long& classID, const char* className);38 static void removeFromClassList(BaseObject* objectPointer);36 static void addToClassList(BaseObject* objectPointer, const long& classID, const char* className); 37 static void removeFromClassList(BaseObject* objectPointer); 39 38 40 static tList<BaseObject>* getList(long classID = CL_NULL);41 static tList<BaseObject>* getList(const char* className);42 static const tList<const char>* getClassList();43 static BaseObject* getObject(const char* name, long classID = CL_NULL);44 static bool exists(const BaseObject* object, long classID = CL_NULL);39 static std::list<BaseObject*>* getList(long classID = CL_NULL); 40 static std::list<BaseObject*>* getList(const char* className); 41 static const std::list<const char*>* getClassList(); 42 static BaseObject* getObject(const char* name, long classID = CL_NULL); 43 static bool exists(const BaseObject* object, long classID = CL_NULL); 45 44 46 static void whatIs(const BaseObject* object);45 static void whatIs(const BaseObject* object); 47 46 48 static const char* IDToString(long classID = CL_NULL); 49 static long StringToID(const char* className); 50 static void debug(unsigned int debugLevel = 0, long classID = CL_NULL); 51 static void debugS(const char* className = 0x0, unsigned int debugLevel = 0); 47 static const char* IDToString(long classID = CL_NULL); 48 static long StringToID(const char* className); 49 static void debug(unsigned int debugLevel = 0, long classID = CL_NULL); 50 static void debugS(const char* className = 0x0, unsigned int debugLevel = 0); 51 52 52 53 53 54 54 private: 55 tList<BaseObject>*objectList; //!< A list of Objects belonging to this Class55 std::list<BaseObject*> objectList; //!< A list of Objects belonging to this Class 56 56 57 57 long classID; //!< ClassID stored in this ClassList \see ClassID … … 62 62 // STATIC MEMBERS 63 63 static ClassList* first; //!< The first Class in the List 64 static tList<const char>*classList; //!< a List of all Names of all classes, that have registered so far.64 static std::list<const char*> classList; //!< a List of all Names of all classes, that have registered so far. 65 65 static unsigned int classCount; //!< The Count of classes that have been registered (should match the lower description) 66 66 }; -
trunk/src/lib/physics/physics_engine.cc
r5778 r5779 131 131 PhysicsInterface* PhysicsEngine::getPhysicsInterfaceByName(const char* physicsInterfaceName) const 132 132 { 133 tIterator<BaseObject>* tmpIt = ClassList::getList(CL_PHYSICS_INTERFACE)->getIterator(); 134 BaseObject* tmpInt = tmpIt->firstElement(); 135 while(tmpInt) 136 { 137 if (!strcmp(physicsInterfaceName, tmpInt->getName())) 138 { 139 delete tmpIt; 140 return dynamic_cast<PhysicsInterface*>(tmpInt); 141 } 142 tmpInt = tmpIt->nextElement(); 143 } 144 delete tmpIt; 145 return NULL; 133 BaseObject* interface = ClassList::getObject(physicsInterfaceName, CL_PHYSICS_INTERFACE); 134 return (interface != NULL)? dynamic_cast<PhysicsInterface*>(interface) : NULL; 146 135 } 147 136 … … 237 226 if (this->interfaces != NULL || (this->interfaces = ClassList::getList(CL_PHYSICS_INTERFACE)) != NULL) 238 227 { 239 tIterator<BaseObject>* itPI = this->interfaces->getIterator(); 240 PhysicsInterface* enumPI = dynamic_cast<PhysicsInterface*>(itPI->firstElement()); 241 while (enumPI) 242 { 243 enumPI->tickPhys(dt); 244 245 enumPI = dynamic_cast<PhysicsInterface*>(itPI->nextElement()); 246 } 247 delete itPI; 228 list<BaseObject*>::const_iterator tickPhys; 229 for (tickPhys = this->interfaces->begin(); tickPhys != this->interfaces->end(); tickPhys++) 230 dynamic_cast<PhysicsInterface*>(*tickPhys)->tickPhys(dt); 248 231 } 249 232 } … … 261 244 PRINT(0)(" reference: %p\n", this); 262 245 if (this->interfaces != NULL) 263 PRINT(0)(" number of Interfaces: %d\n", this->interfaces-> getSize());246 PRINT(0)(" number of Interfaces: %d\n", this->interfaces->size()); 264 247 PRINT(0)(" number of Fields: %d\n", this->fields.size()); 265 248 PRINT(0)(" number of Connections: %d\n", this->connections.size()); -
trunk/src/lib/physics/physics_engine.h
r5777 r5779 54 54 std::list<Field*> fields; //!< a list of physicsl fields. 55 55 std::list<PhysicsConnection*> connections; //!< a list of physical connections. 56 const tList<BaseObject>*interfaces; //!< The list of physical interfaces.56 const std::list<BaseObject*>* interfaces; //!< The list of physical interfaces. 57 57 }; 58 58 -
trunk/src/lib/shell/shell_command.cc
r5656 r5779 47 47 this->shellClass = ShellCommandClass::getCommandClass(className); //ClassList::IDToString(classID); 48 48 if (this->shellClass != NULL) 49 this->shellClass->commandList ->add(this);49 this->shellClass->commandList.push_back(this); 50 50 } 51 51 … … 82 82 void ShellCommand::unregisterCommand(const char* commandName, const char* className) 83 83 { 84 if (ShellCommandClass::commandClassList == NULL) 84 /// FIXME 85 /* if (ShellCommandClass::commandClassList == NULL) 85 86 ShellCommandClass::initCommandClassList(); 86 87 … … 89 90 if (checkClass != NULL) 90 91 { 91 tIterator<ShellCommand>* iterator = checkClass->commandList->getIterator(); 92 ShellCommand* elem = iterator->firstElement(); 93 while(elem != NULL) 94 { 95 if (!strcmp(commandName, elem->getName())) 96 { 97 checkClass->commandList->remove(elem); 98 delete elem; 92 std::list<ShellCommand*>::iterator elem; 93 for (elem = checkClass->commandList.begin(); elem != checkClass->commandList.end(); elem++) 94 { 95 if (!strcmp(commandName, (*elem)->getName())) 96 { 97 delete (*elem); 98 checkClass->commandList.remove(*elem); 99 99 break; 100 100 } 101 elem = iterator->nextElement(); 102 } 103 delete iterator; 104 105 if (checkClass->commandList->getSize() == 0) 101 } 102 103 if (checkClass->commandList->size() == 0) 106 104 { 107 105 ShellCommandClass::commandClassList->remove(checkClass); 108 106 delete checkClass; 109 107 } 110 } 108 }*/ 111 109 } 112 110 … … 132 130 if (checkClass != NULL) 133 131 { 134 tIterator<ShellCommand>* iterator = checkClass->commandList->getIterator(); 135 ShellCommand* elem = iterator->firstElement(); 136 while(elem != NULL) 137 { 138 if (!strcmp(commandName, elem->getName())) 139 { 140 PRINTF(2)("Command already registered\n"); 141 delete iterator; 142 return true; 143 } 144 elem = iterator->nextElement(); 145 } 146 delete iterator; 132 std::list<ShellCommand*>::const_iterator elem; 133 for (elem = checkClass->commandList.begin(); elem != checkClass->commandList.end(); elem++) 134 { 135 if (!strcmp(commandName, (*elem)->getName())) 136 { 137 PRINTF(2)("Command '%s::%s' already registered\n", className, commandName); 138 return true; 139 } 140 } 147 141 return false; 148 142 } … … 163 157 return false; 164 158 165 long classID = CL_NULL; //< the classID retrieved from the Class.166 ShellCommandClass* commandClass = NULL; //< the command class this command applies to.167 tList<BaseObject>* objectList = NULL; //< the list of Objects stored in classID168 BaseObject* objectPointer = NULL; //< a pointer to th Object to Execute the command on169 bool emptyComplete = false; //< if the completion input is empty string. e.g ""170 unsigned int fktPos = 1; //< the position of the function (needed for finding it)171 // long completeType = SHELLC_NONE; //< the Type we'd like to complete.159 long classID = CL_NULL; //< the classID retrieved from the Class. 160 ShellCommandClass* commandClass = NULL; //< the command class this command applies to. 161 std::list<BaseObject*>* objectList = NULL; //< the list of Objects stored in classID 162 BaseObject* objectPointer = NULL; //< a pointer to th Object to Execute the command on 163 bool emptyComplete = false; //< if the completion input is empty string. e.g "" 164 unsigned int fktPos = 1; //< the position of the function (needed for finding it) 165 // long completeType = SHELLC_NONE; //< the Type we'd like to complete. 172 166 SubString inputSplits(executionString, " \t\n,"); 173 167 … … 179 173 if (ShellCommandClass::aliasList != NULL) 180 174 { 181 tIterator<ShellCommandAlias>* itAL = ShellCommandClass::aliasList->getIterator(); 182 ShellCommandAlias* elemAL = itAL->firstElement(); 183 while(elemAL != NULL) 184 { 185 if (elemAL->getName() != NULL && !strcmp(elemAL->getName(), inputSplits.getString(0)) && elemAL->getCommand() != NULL && 186 elemAL->getCommand()->shellClass != NULL ) 175 list<ShellCommandAlias*>::iterator alias; 176 for (alias = ShellCommandClass::aliasList->begin(); alias != ShellCommandClass::aliasList->end(); alias++ ) 177 { 178 if ((*alias)->getName() != NULL && !strcmp((*alias)->getName(), inputSplits.getString(0)) && (*alias)->getCommand() != NULL && 179 (*alias)->getCommand()->shellClass != NULL ) 187 180 { 188 objectList = ClassList::getList( elemAL->getCommand()->shellClass->getName());181 objectList = ClassList::getList((*alias)->getCommand()->shellClass->getName()); 189 182 if (objectList != NULL) 190 183 { 191 184 if (inputSplits.getCount() > 1) 192 elemAL->getCommand()->executor->execute(objectList->firstElement(), executionString+inputSplits.getOffset(1));185 (*alias)->getCommand()->executor->execute(objectList->front(), executionString+inputSplits.getOffset(1)); 193 186 else 194 elemAL->getCommand()->executor->execute(objectList->firstElement(), ""); 195 delete itAL; 187 (*alias)->getCommand()->executor->execute(objectList->front(), ""); 188 return true; 189 } 190 } 191 } 192 } 193 // looking for a Matching Class 194 if (likely(ShellCommandClass::commandClassList != NULL)) 195 { 196 list<ShellCommandClass*>::iterator commandClassIT; 197 for (commandClassIT = ShellCommandClass::commandClassList->begin(); commandClassIT != ShellCommandClass::commandClassList->end(); commandClassIT++) 198 { 199 if ((*commandClassIT)->getName() && !strcasecmp(inputSplits.getString(0), (*commandClassIT)->getName())) 200 { 201 //elemCL->getName(); 202 classID = ClassList::StringToID((*commandClassIT)->getName()); 203 commandClass = (*commandClassIT); 204 objectList = ClassList::getList(classID); 205 break; 206 } 207 } 208 } 209 210 if (commandClass != NULL && inputSplits.getCount() >= 2) 211 { 212 if (objectList != NULL) 213 { 214 // Checking for a Match in the Objects of classID (else take the first) 215 list<BaseObject*>::const_iterator object; 216 for (object = objectList->begin(); object != objectList->end(); object++) 217 { 218 if ((*object)->getName() != NULL && !strcasecmp((*object)->getName(), inputSplits.getString(1))) 219 { 220 objectPointer = (*object); 221 fktPos = 2; 222 break; 223 } 224 } 225 226 // 227 if (objectPointer == NULL) 228 objectPointer = objectList->front(); 229 } 230 // match a function. 231 if (commandClass != NULL && (fktPos == 1 || (fktPos == 2 && inputSplits.getCount() >= 3))) 232 { 233 list<ShellCommand*>::iterator cmdIT; 234 for (cmdIT = commandClass->commandList.begin(); cmdIT != commandClass->commandList.end(); cmdIT++) 235 { 236 if (!strcmp((*cmdIT)->getName(), inputSplits.getString(fktPos))) 237 { 238 if (objectPointer == NULL && (*cmdIT)->executor->getType() & Executor_Objective) 239 return false; 240 if (inputSplits.getCount() > fktPos+1) 241 (*cmdIT)->executor->execute(objectPointer, executionString+inputSplits.getOffset(fktPos +1)); 242 else 243 (*cmdIT)->executor->execute(objectPointer, ""); 196 244 return true; 197 245 } 198 246 } 199 elemAL = itAL->nextElement();200 }201 delete itAL;202 }203 // looking for a Matching Class204 if (likely(ShellCommandClass::commandClassList != NULL))205 {206 tIterator<ShellCommandClass>* itCL = ShellCommandClass::commandClassList->getIterator();207 ShellCommandClass* elemCL = itCL->firstElement();208 while(elemCL != NULL)209 {210 if (elemCL->getName() && !strcasecmp(inputSplits.getString(0), elemCL->getName()))211 {212 //elemCL->getName();213 classID = ClassList::StringToID(elemCL->getName());214 commandClass = elemCL;215 objectList = ClassList::getList(classID);216 break;217 }218 elemCL = itCL->nextElement();219 }220 delete itCL;221 }222 223 if (commandClass != NULL && inputSplits.getCount() >= 2)224 {225 if (objectList != NULL)226 {227 // Checking for a Match in the Objects of classID (else take the first)228 tIterator<BaseObject>* itBO = objectList->getIterator();229 BaseObject* enumBO = itBO->firstElement();230 while(enumBO)231 {232 if (enumBO->getName() != NULL && !strcasecmp(enumBO->getName(), inputSplits.getString(1)))233 {234 objectPointer = enumBO;235 fktPos = 2;236 break;237 }238 enumBO = itBO->nextElement();239 }240 delete itBO;241 242 //243 if (objectPointer == NULL)244 objectPointer = objectList->firstElement();245 }246 // match a function.247 if (commandClass != NULL && (fktPos == 1 || (fktPos == 2 && inputSplits.getCount() >= 3)))248 {249 tIterator<ShellCommand>* itCMD = commandClass->commandList->getIterator();250 ShellCommand* enumCMD = itCMD->firstElement();251 while (enumCMD != NULL)252 {253 if (!strcmp(enumCMD->getName(), inputSplits.getString(fktPos)))254 {255 if (objectPointer == NULL && enumCMD->executor->getType() & Executor_Objective)256 {257 delete itCMD;258 return false;259 }260 if (inputSplits.getCount() > fktPos+1)261 enumCMD->executor->execute(objectPointer, executionString+inputSplits.getOffset(fktPos +1));262 else263 enumCMD->executor->execute(objectPointer, "");264 delete itCMD;265 return true;266 }267 268 enumCMD = itCMD->nextElement();269 }270 delete itCMD;271 247 } 272 248 } … … 306 282 { 307 283 if (ShellCommandClass::aliasList == NULL) 308 ShellCommandClass::aliasList = new tList<ShellCommandAlias>;284 ShellCommandClass::aliasList = new std::list<ShellCommandAlias*>; 309 285 310 286 ShellCommandAlias* aliasCMD = new ShellCommandAlias(alias, this); 311 ShellCommandClass::aliasList-> add(aliasCMD);287 ShellCommandClass::aliasList->push_back(aliasCMD); 312 288 this->alias = aliasCMD; 313 289 } … … 348 324 } 349 325 350 tIterator<ShellCommandClass>* iteratorCL = ShellCommandClass::commandClassList->getIterator(); 351 ShellCommandClass* elemCL = iteratorCL->firstElement(); 352 while(elemCL != NULL) 353 { 354 PRINT(0)("Class:'%s' registered %d commands: \n", elemCL->className, elemCL->commandList->getSize()); 355 tIterator<ShellCommand>* iterator = elemCL->commandList->getIterator(); 356 const ShellCommand* elem = iterator->firstElement(); 357 while(elem != NULL) 358 { 359 PRINT(0)(" command:'%s' : params:%d: ", elem->getName(), elem->executor->getParamCount()); 326 list<ShellCommandClass*>::iterator classIT; 327 for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++) 328 { 329 PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className, (*classIT)->commandList.size()); 330 331 list<ShellCommand*>::iterator cmdIT; 332 for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++) 333 { 334 PRINT(0)(" command:'%s' : params:%d: ", (*cmdIT)->getName(), (*cmdIT)->executor->getParamCount()); 360 335 /// FIXME 361 336 /* for (unsigned int i = 0; i< elem->paramCount; i++) 362 337 printf("%s ", ShellCommand::paramToString(elem->parameters[i]));*/ 363 if ( elem->description != NULL)364 printf("- %s", elem->description);338 if ((*cmdIT)->description != NULL) 339 printf("- %s", (*cmdIT)->description); 365 340 printf("\n"); 366 341 367 elem = iterator->nextElement(); 368 } 369 delete iterator; 370 elemCL = iteratorCL->nextElement(); 371 } 372 delete iteratorCL; 342 } 343 } 373 344 } 374 345 -
trunk/src/lib/shell/shell_command.h
r5690 r5779 108 108 109 109 private: 110 const char* 110 const char* aliasName; //!< the name of the Alias 111 111 ShellCommand* command; //!< a pointer to the command, this alias executes. 112 112 }; -
trunk/src/lib/shell/shell_command_class.cc
r5644 r5779 29 29 using namespace std; 30 30 31 tList<ShellCommandClass>* ShellCommandClass::commandClassList = NULL;32 tList<ShellCommandAlias>* ShellCommandClass::aliasList = NULL;31 std::list<ShellCommandClass*>* ShellCommandClass::commandClassList = NULL; 32 std::list<ShellCommandAlias*>* ShellCommandClass::aliasList = NULL; 33 33 34 34 /** … … 43 43 this->className = className; 44 44 this->classID = CL_NULL; 45 this->commandList = new tList<ShellCommand>; 46 47 ShellCommandClass::commandClassList->add(this); 45 46 ShellCommandClass::commandClassList->push_back(this); 48 47 } 49 48 … … 53 52 ShellCommandClass::~ShellCommandClass() 54 53 { 55 tIterator<ShellCommand>* iterator = this->commandList->getIterator(); 56 ShellCommand* elem = iterator->firstElement(); 57 while(elem != NULL) 58 { 59 delete elem; 60 elem = iterator->nextElement(); 61 } 62 delete iterator; 63 delete this->commandList; 54 while(this->commandList.size() > 0) 55 { 56 delete this->commandList.front(); 57 this->commandList.pop_front(); 58 } 64 59 } 65 60 … … 70 65 * @returns true on success, false otherwise 71 66 */ 72 bool ShellCommandClass::getCommandListOfClass(const char* className, tList<const char>* stringList)67 bool ShellCommandClass::getCommandListOfClass(const char* className, std::list<const char*>* stringList) 73 68 { 74 69 if (stringList == NULL || className == NULL) 75 70 return false; 76 71 77 tIterator<ShellCommandClass>* iterator = ShellCommandClass::commandClassList->getIterator(); 78 ShellCommandClass* elem = iterator->firstElement(); 79 while(elem != NULL) 80 { 81 if (!strcmp (elem->getName(), className)) 82 { 83 tIterator<ShellCommand>* itFkt = elem->commandList->getIterator(); 84 ShellCommand* command = itFkt->firstElement(); 85 while (command != NULL) 86 { 87 stringList->add(command->getName()); 88 command = itFkt->nextElement(); 89 } 90 delete itFkt; 91 } 92 93 elem = iterator->nextElement(); 94 } 95 delete iterator; 72 list<ShellCommandClass*>::iterator elem; 73 for(elem = ShellCommandClass::commandClassList->begin(); elem != ShellCommandClass::commandClassList->end(); elem++) 74 { 75 if (!strcmp ((*elem)->getName(), className)) 76 { 77 list<ShellCommand*>::iterator command; 78 for(command = (*elem)->commandList.begin(); command != (*elem)->commandList.end(); command++) 79 stringList->push_back((*command)->getName()); 80 } 81 } 96 82 return true; 97 83 } … … 102 88 * @returns true on success, false otherwise 103 89 */ 104 bool ShellCommandClass::getCommandListOfAlias( tList<const char>* stringList)90 bool ShellCommandClass::getCommandListOfAlias(std::list<const char*>* stringList) 105 91 { 106 92 if (stringList == NULL || ShellCommandClass::aliasList == NULL) 107 93 return false; 108 94 109 tIterator<ShellCommandAlias>* iterator = ShellCommandClass::aliasList->getIterator(); 110 ShellCommandAlias* elem = iterator->firstElement(); 111 while(elem != NULL) 112 { 113 stringList->add(elem->getName()); 114 elem = iterator->nextElement(); 115 } 116 delete iterator; 117 return true; 95 list<ShellCommandAlias*>::iterator alias; 96 for (alias = ShellCommandClass::aliasList->begin(); alias != ShellCommandClass::aliasList->end(); alias++) 97 stringList->push_back((*alias)->getName()); 98 return true; 118 99 } 119 100 … … 123 104 void ShellCommandClass::unregisterAllCommands() 124 105 { 125 if (ShellCommandClass::commandClassList != NULL) 106 /// FIXME 107 108 /* if (ShellCommandClass::commandClassList != NULL) 126 109 { 127 110 // unregister all commands … … 153 136 delete ShellCommandClass::aliasList; 154 137 ShellCommandClass::aliasList = NULL; 155 } 138 }*/ 156 139 } 157 140 … … 166 149 initCommandClassList(); 167 150 168 tIterator<ShellCommandClass>* iterator = ShellCommandClass::commandClassList->getIterator(); 169 ShellCommandClass* elem = iterator->firstElement(); 170 while(elem != NULL) 171 { 172 if (!strcmp(className, elem->className)) 173 { 174 if (elem->classID == CL_NULL) 175 elem->classID = ClassList::StringToID(className); 176 177 delete iterator; 178 return elem; 179 } 180 elem = iterator->nextElement(); 181 } 182 delete iterator; 151 list<ShellCommandClass*>::const_iterator classIT; 152 for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++) 153 { 154 if (!strcmp(className, (*classIT)->className)) 155 { 156 if ((*classIT)->classID == CL_NULL) 157 (*classIT)->classID = ClassList::StringToID(className); 158 159 return (*classIT); 160 } 161 } 183 162 return NULL; 184 163 } … … 194 173 initCommandClassList(); 195 174 196 tIterator<ShellCommandClass>* iterator = ShellCommandClass::commandClassList->getIterator(); 197 ShellCommandClass* elem = iterator->firstElement(); 198 while(elem != NULL) 199 { 200 if (!strcmp(className, elem->className)) 201 { 202 delete iterator; 203 return elem; 204 } 205 elem = iterator->nextElement(); 206 } 207 delete iterator; 175 list<ShellCommandClass*>::iterator classIT; 176 for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++) 177 { 178 if (!strcmp(className, (*classIT)->className)) 179 { 180 return (*classIT); 181 } 182 } 208 183 return new ShellCommandClass(className); 209 184 } … … 216 191 if (ShellCommandClass::commandClassList == NULL) 217 192 { 218 ShellCommandClass::commandClassList = new tList<ShellCommandClass>;193 ShellCommandClass::commandClassList = new std::list<ShellCommandClass*>; 219 194 ShellCommand::registerCommand("debug", "ShellCommand", ExecutorStatic<ShellCommand>(ShellCommand::debug)); 220 195 } … … 231 206 if (likely(ShellCommandClass::commandClassList != NULL)) 232 207 { 233 tIterator<ShellCommandClass>* itCL = ShellCommandClass::commandClassList->getIterator(); 234 ShellCommandClass* elemCL = itCL->firstElement(); 235 while(elemCL != NULL) 236 { 237 if (elemCL->className && !strcasecmp(className, elemCL->className)) 208 list<ShellCommandClass*>::iterator classIT; 209 for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++) 210 { 211 if ((*classIT)->className && !strcasecmp(className, (*classIT)->className)) 238 212 { 239 PRINT(0)("Class:'%s' registered %d commands: \n", elemCL->className, elemCL->commandList->getSize()); 240 tIterator<ShellCommand>* iterator = elemCL->commandList->getIterator(); 241 const ShellCommand* elem = iterator->firstElement(); 242 while(elem != NULL) 213 PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className, (*classIT)->commandList.size()); 214 list<ShellCommand*>::const_iterator cmdIT; 215 for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++) 243 216 { 244 PRINT(0)(" command:'%s' : params:%d: ", elem->getName(), elem->executor->getParamCount());217 PRINT(0)(" command:'%s' : params:%d: ", (*cmdIT)->getName(), (*cmdIT)->executor->getParamCount()); 245 218 /// FIXME 246 219 /* for (unsigned int i = 0; i< elem->paramCount; i++) 247 220 PRINT(0)("%s ", ShellCommand::paramToString(elem->parameters[i]));*/ 248 if ( elem->description != NULL)249 PRINT(0)("- %s", elem->description);221 if ((*cmdIT)->description != NULL) 222 PRINT(0)("- %s", (*cmdIT)->description); 250 223 PRINT(0)("\n"); 251 elem = iterator->nextElement();252 224 } 253 delete iterator;254 255 delete itCL;256 225 return; 257 226 } 258 elemCL = itCL->nextElement(); 259 } 260 delete itCL; 227 } 261 228 PRINTF(3)("Class %s not found in Command's classes\n", className); 262 229 } -
trunk/src/lib/shell/shell_command_class.h
r5639 r5779 8 8 9 9 #include "base_object.h" 10 #include <list> 10 11 11 12 … … 26 27 public: 27 28 /** @returns the CommandClassList */ 28 static const tList<ShellCommandClass>* getCommandClassList() { return ShellCommandClass::commandClassList; };29 static bool getCommandListOfClass(const char* className, tList<const char>* stringList);30 static bool getCommandListOfAlias( tList<const char>* aliasList);29 static const std::list<ShellCommandClass*>* getCommandClassList() { return ShellCommandClass::commandClassList; }; 30 static bool getCommandListOfClass(const char* className, std::list<const char*>* stringList); 31 static bool getCommandListOfAlias(std::list<const char*>* aliasList); 31 32 32 33 static ShellCommandClass* getCommandClass(const char* className); … … 43 44 44 45 private: 45 const char* className; //!< The Name of the Class. This should match the ClassName of the Commands Class.46 long classID; //!< The classID of this Class47 tList<ShellCommand>*commandList; //!< A list of Commands from this Class48 static tList<ShellCommandClass>*commandClassList; //!< A list of Classes49 static tList<ShellCommandAlias>*aliasList; //!< An Alias to A Command. (only for classes with one Instance)46 const char* className; //!< The Name of the Class. This should match the ClassName of the Commands Class. 47 long classID; //!< The classID of this Class 48 std::list<ShellCommand*> commandList; //!< A list of Commands from this Class 49 static std::list<ShellCommandClass*>* commandClassList; //!< A list of Classes 50 static std::list<ShellCommandAlias*>* aliasList; //!< An Alias to A Command. (only for classes with one Instance) 50 51 }; 51 52 -
trunk/src/lib/shell/shell_completion.cc
r5656 r5779 63 63 bool ShellCompletion::autoComplete(ShellInput* input) 64 64 { 65 const char* completionLine; //< the inputLine we complete.66 67 long classID; //< the classID retrieved from the Class.68 tList<BaseObject>* objectList; //< the list of Objects stored in classID69 bool emptyComplete = false; //< if the completion input is empty string. e.g ""70 long completeType = SHELLC_NONE; //< the Type we'd like to complete.71 const char* completeString; //< the string to complete.65 const char* completionLine; //< the inputLine we complete. 66 67 long classID; //< the classID retrieved from the Class. 68 std::list<BaseObject*>* objectList; //< the list of Objects stored in classID 69 bool emptyComplete = false; //< if the completion input is empty string. e.g "" 70 long completeType = SHELLC_NONE; //< the Type we'd like to complete. 71 const char* completeString; //< the string to complete. 72 72 73 73 … … 159 159 if (unlikely(classBegin == NULL)) 160 160 return false; 161 const tList<const char>* clList = ClassList::getClassList();161 const std::list<const char*>* clList = ClassList::getClassList(); 162 162 if (clList != NULL) 163 163 { … … 180 180 if (unlikely(objectBegin == NULL)) 181 181 return false; 182 const tList<BaseObject>* boList = ClassList::getList(classID);182 const std::list<BaseObject*>* boList = ClassList::getList(classID); 183 183 if (boList != NULL) 184 184 { … … 203 203 if (unlikely(functionBegin == NULL)) 204 204 return false; 205 tList<const char> fktList;205 std::list<const char*> fktList; 206 206 ShellCommandClass::getCommandListOfClass(className, &fktList); 207 207 //printf("%s\n", boList->firstElement()->getName()); … … 220 220 if (unlikely(aliasBegin == NULL)) 221 221 return false; 222 tList<const char> aliasList;222 std::list<const char*> aliasList; 223 223 ShellCommandClass::getCommandListOfAlias(&aliasList); 224 224 //printf("%s\n", boList->firstElement()->getName()); … … 241 241 if (completionList == NULL || this->input == NULL ) 242 242 return false; 243 if (completionList-> getSize() == 0)244 return false; 245 246 ShellC_Element* addElem = completionList->f irstElement();243 if (completionList->size() == 0) 244 return false; 245 246 ShellC_Element* addElem = completionList->front(); 247 247 const char* addString = addElem->name; 248 248 unsigned int addLength = 0; … … 252 252 if (addString != NULL) 253 253 addLength = strlen(addString); 254 tIterator<ShellC_Element>* charIterator = completionList->getIterator(); 255 ShellC_Element* charElem = charIterator->firstElement(); 254 256 255 SHELLC_TYPE changeType = SHELLC_NONE; 257 while (charElem != NULL) 258 { 259 if (charElem->type != changeType) 256 list<ShellC_Element*>::iterator charIT; 257 for (charIT = completionList->begin(); charIT != completionList->end(); charIT++) 258 { 259 if ((*charIT)->type != changeType) 260 260 { 261 261 if (changeType != SHELLC_NONE) 262 262 PRINT(0)("\n"); 263 PRINT(0)("%s: ", ShellCompletion::typeToString( charElem->type));264 changeType = charElem->type;265 } 266 PRINTF(0)("%s ", charElem->name);263 PRINT(0)("%s: ", ShellCompletion::typeToString((*charIT)->type)); 264 changeType = (*charIT)->type; 265 } 266 PRINTF(0)("%s ", (*charIT)->name); 267 267 for (unsigned int i = inputLenght; i < addLength; i++) 268 if (addString[i] != charElem->name[i])268 if (addString[i] != (*charIT)->name[i]) 269 269 { 270 270 addLength = i; 271 271 // break; 272 272 } 273 charElem = charIterator->nextElement(); 274 } 275 delete charIterator; 273 } 276 274 PRINT(0)("\n"); 277 275 … … 287 285 this->input->addCharacters(adder); 288 286 289 if (completionList-> getSize() == 1)287 if (completionList->size() == 1) 290 288 { 291 289 if ( addBack != NULL ) … … 305 303 * !! The strings MUST NOT be deleted !! 306 304 */ 307 bool ShellCompletion::addToCompleteList(const tList<const char>* inputList, const char* completionBegin, SHELLC_TYPE type)305 bool ShellCompletion::addToCompleteList(const std::list<const char*>* inputList, const char* completionBegin, SHELLC_TYPE type) 308 306 { 309 307 if (inputList == NULL || completionBegin == NULL) … … 311 309 unsigned int searchLength = strlen(completionBegin); 312 310 313 tIterator<const char>* iterator = inputList->getIterator(); 314 const char* enumString = iterator->firstElement(); 315 while (enumString != NULL) 316 { 317 if (strlen(enumString) >= searchLength && 318 !strncasecmp(enumString, completionBegin, searchLength)) 319 { 320 printf("%s\n", enumString); 311 list<const char*>::const_iterator string; 312 for (string = inputList->begin(); string != inputList->end(); string++) 313 { 314 if (strlen(*string) >= searchLength && 315 !strncasecmp(*string, completionBegin, searchLength)) 316 { 317 printf("%s\n", *string); 321 318 ShellC_Element* newElem = new ShellC_Element; 322 newElem->name = enumString;319 newElem->name = *string; 323 320 newElem->type = type; 324 this->completionList->add(newElem); 325 } 326 enumString = iterator->nextElement(); 327 } 328 delete iterator; 329 321 this->completionList->push_back(newElem); 322 } 323 } 330 324 return true; 331 325 } … … 337 331 * !! The strings MUST NOT be deleted !! 338 332 */ 339 bool ShellCompletion::addToCompleteList(const tList<BaseObject>* inputList, const char* completionBegin, SHELLC_TYPE type)333 bool ShellCompletion::addToCompleteList(const std::list<BaseObject*>* inputList, const char* completionBegin, SHELLC_TYPE type) 340 334 { 341 335 if (inputList == NULL || completionBegin == NULL) … … 343 337 unsigned int searchLength = strlen(completionBegin); 344 338 345 tIterator<BaseObject>* iterator = inputList->getIterator(); 346 BaseObject* enumBO = iterator->firstElement(); 347 while (enumBO != NULL) 348 { 349 if (enumBO->getName() != NULL && 350 strlen(enumBO->getName()) >= searchLength && 351 !strncasecmp(enumBO->getName(), completionBegin, searchLength)) 339 list<BaseObject*>::const_iterator bo; 340 for(bo = inputList->begin(); bo != inputList->end(); bo++) 341 { 342 if ((*bo)->getName() != NULL && 343 strlen((*bo)->getName()) >= searchLength && 344 !strncasecmp((*bo)->getName(), completionBegin, searchLength)) 352 345 { 353 346 ShellC_Element* newElem = new ShellC_Element; 354 newElem->name = enumBO->getName();347 newElem->name = (*bo)->getName(); 355 348 newElem->type = type; 356 this->completionList->add(newElem); 357 } 358 enumBO = iterator->nextElement(); 359 } 360 delete iterator; 349 this->completionList->push_back(newElem); 350 } 351 } 361 352 362 353 return true; … … 372 363 if (this->completionList != NULL) 373 364 { 374 tIterator<ShellC_Element>* elemIT = this->completionList->getIterator(); 375 ShellC_Element* elem = elemIT->firstElement(); 376 while (elem != NULL) 377 { 378 delete elem; 379 elem = elemIT->nextElement(); 380 } 381 delete this->completionList; 382 } 383 this->completionList = new tList<ShellC_Element>; 365 while (this->completionList->size() > 0) 366 { 367 delete this->completionList->front(); 368 this->completionList->pop_front(); 369 } 370 } 384 371 } 385 372 -
trunk/src/lib/shell/shell_completion.h
r5371 r5779 9 9 #ifndef _SHELL_COMPLETION_H 10 10 #define _SHELL_COMPLETION_H 11 12 #include <list> 11 13 12 14 // FORWARD DECLARATION … … 51 53 bool generalComplete(const char* begin, const char* displayAs = "%s", const char* addBack = NULL, const char* addFront = NULL); 52 54 53 bool addToCompleteList(const tList<const char>* inputList, const char* completionBegin, SHELLC_TYPE type);54 bool addToCompleteList(const tList<BaseObject>* inputList, const char* completionBegin, SHELLC_TYPE type);55 bool addToCompleteList(const std::list<const char*>* inputList, const char* completionBegin, SHELLC_TYPE type); 56 bool addToCompleteList(const std::list<BaseObject*>* inputList, const char* completionBegin, SHELLC_TYPE type); 55 57 void emptyCompletionList(); 56 58 … … 58 60 59 61 private: 60 tList<ShellC_Element>*completionList; //!< A list of completions, that are io.61 ShellInput* input; //!< the input this completion works on.62 std::list<ShellC_Element*>* completionList; //!< A list of completions, that are io. 63 ShellInput* input; //!< the input this completion works on. 62 64 }; 63 65 -
trunk/src/lib/sound/sound_engine.cc
r5473 r5779 63 63 if(this->sourceList != NULL) 64 64 { 65 tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator(); 66 SoundSource* enumSource = (SoundSource*)sourceIterator->firstElement(); 67 while (enumSource) 68 { 69 delete enumSource; 70 enumSource = (SoundSource*)sourceIterator->nextElement(); 71 } 72 delete sourceIterator; 65 while (this->sourceList->size() > 0) 66 delete dynamic_cast<SoundSource*>(this->sourceList->front()); 73 67 } 74 68 … … 76 70 if (this->bufferList != NULL) 77 71 { 78 tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator(); 79 SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->firstElement(); 80 while (enumBuffer) 81 { 82 ResourceManager::getInstance()->unload(enumBuffer); 83 enumBuffer = (SoundBuffer*)bufferIterator->nextElement(); 84 } 85 delete bufferIterator; 72 while(this->bufferList->size() > 0) 73 ResourceManager::getInstance()->unload(dynamic_cast<SoundBuffer*>(this->bufferList->front())); 86 74 } 87 75 … … 148 136 { 149 137 // look if there are any sources that have the buffer still loaded 150 tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator();151 SoundSource* enumSource = (SoundSource*)sourceIterator->firstElement();152 while (enumSource)153 {154 if (buffer == enumSource->getBuffer())155 delete enumSource;156 enumSource = (SoundSource*)sourceIterator->nextElement();138 if (this->sourceList != NULL) 139 { 140 list<BaseObject*>::iterator source; 141 for (source = this->sourceList->begin(); source != this->sourceList->end(); source++) 142 { 143 if (buffer == static_cast<SoundSource*>(*source)->getBuffer()) 144 delete (*source); 157 145 } 158 delete sourceIterator;146 } 159 147 } 160 148 … … 195 183 if (likely(this->sourceList != NULL)) 196 184 { 197 tIterator<BaseObject>* iterator = this->sourceList->getIterator(); 198 SoundSource* enumSource = (SoundSource*)iterator->firstElement(); 199 while (enumSource) 200 { 201 if (likely(enumSource->getNode() != NULL)) 185 list<BaseObject*>::iterator sourceIT; 186 SoundSource* source; 187 for (sourceIT = this->sourceList->begin(); sourceIT != this->sourceList->end(); sourceIT++) 188 { 189 source = static_cast<SoundSource*>(*sourceIT); 190 if (likely(source->getNode() != NULL)) 202 191 { 203 alSource3f( enumSource->getID(), AL_POSITION,204 enumSource->getNode()->getAbsCoor().x,205 enumSource->getNode()->getAbsCoor().y,206 enumSource->getNode()->getAbsCoor().z);207 alSource3f( enumSource->getID(), AL_VELOCITY,208 enumSource->getNode()->getVelocity().x,209 enumSource->getNode()->getVelocity().y,210 enumSource->getNode()->getVelocity().z);192 alSource3f(source->getID(), AL_POSITION, 193 source->getNode()->getAbsCoor().x, 194 source->getNode()->getAbsCoor().y, 195 source->getNode()->getAbsCoor().z); 196 alSource3f(source->getID(), AL_VELOCITY, 197 source->getNode()->getVelocity().x, 198 source->getNode()->getVelocity().y, 199 source->getNode()->getVelocity().z); 211 200 } 212 enumSource = (SoundSource*)iterator->nextElement();213 201 } 214 delete iterator;215 202 } 216 203 } … … 221 208 void SoundEngine::flushUnusedBuffers() 222 209 { 223 if(this->sourceList && this->bufferList)210 /* if(this->sourceList && this->bufferList) 224 211 { 225 212 tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator(); … … 241 228 } 242 229 delete bufferIterator; 243 } 230 }*/ /// FIXME 244 231 } 245 232 … … 252 239 if (this->bufferList) 253 240 { 254 tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator(); 255 SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->firstElement(); 256 while (enumBuffer) 257 { 258 ResourceManager::getInstance()->unload(enumBuffer, RP_LEVEL); 259 enumBuffer = (SoundBuffer*)bufferIterator->nextElement(); 260 } 261 delete bufferIterator; 241 while (this->bufferList->size() > 0) 242 ResourceManager::getInstance()->unload(static_cast<SoundBuffer*>(this->bufferList->front()), RP_LEVEL); 262 243 } 263 244 } … … 270 251 if (this->sourceList) 271 252 { 272 tIterator<BaseObject>* Iterator = this->sourceList->getIterator(); 273 SoundSource* enumSource = (SoundSource*)Iterator->firstElement(); 274 while (enumSource) 275 { 276 delete enumSource; 277 enumSource = (SoundSource*)Iterator->nextElement(); 278 } 279 delete Iterator; 253 while(this->sourceList->size() > 0) 254 delete this->sourceList->front(); 280 255 } 281 256 } -
trunk/src/lib/sound/sound_engine.h
r5405 r5779 13 13 #include "sound_source.h" 14 14 15 #include <list> 16 15 17 #define SOUND_DOPPLER_FACTOR 0.001 //!< A factor for the audible doppler effect 16 18 #define SOUND_DOPPLER_VELOCITY 5000000 //!< A factor for the TravelSpeed of sound … … 18 20 // FORWARD DECLARATION 19 21 class PNode; 20 template<class T> class tList;21 22 class IniParser; 22 23 … … 70 71 float effectsVolume; //!< the maximum volume of sound-effects in % (0f,1f] 71 72 PNode* listener; //!< The listener of the Scene 72 tList<BaseObject>*bufferList; //!< A list of buffers73 tList<BaseObject>*sourceList; //!< A list for all the sources in the scene.73 std::list<BaseObject*>* bufferList; //!< A list of buffers 74 std::list<BaseObject*>* sourceList; //!< A list for all the sources in the scene. 74 75 75 76 }; -
trunk/src/world_entities/weapons/aim.cc
r5750 r5779 81 81 82 82 this->text = new Text(); 83 this->text->setLayer(this->getLayer()); 83 84 this->text->setParent2D(this); 84 85 this->text->setRelCoor2D(10, -50); -
trunk/src/world_entities/weapons/guided_missile.cc
r5772 r5779 66 66 67 67 /* this is normaly done by World.cc by deleting the ParticleEngine */ 68 if (GuidedMissile::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)-> getSize() <= 1)68 if (GuidedMissile::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->size() <= 1) 69 69 { 70 70 if (ClassList::exists(GuidedMissile::trailParticles, CL_PARTICLE_SYSTEM)) … … 72 72 GuidedMissile::trailParticles = NULL; 73 73 } 74 if (GuidedMissile::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)-> getSize() <= 1)74 if (GuidedMissile::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->size() <= 1) 75 75 { 76 76 if (ClassList::exists(GuidedMissile::explosionParticles, CL_PARTICLE_SYSTEM)) -
trunk/src/world_entities/weapons/laser.cc
r5769 r5779 63 63 64 64 /* this is normaly done by World.cc by deleting the ParticleEngine */ 65 if (Laser::explosionParticles != NULL && ClassList::getList(CL_LASER)-> getSize() <= 1)65 if (Laser::explosionParticles != NULL && ClassList::getList(CL_LASER)->size() <= 1) 66 66 { 67 67 //if (ClassList::exists(Laser::explosionParticles, CL_PARTICLE_SYSTEM)) -
trunk/src/world_entities/weapons/rocket.cc
r5769 r5779 62 62 63 63 /* this is normaly done by World.cc by deleting the ParticleEngine */ 64 if (Rocket::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)-> getSize() <= 1)64 if (Rocket::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->size() <= 1) 65 65 { 66 66 if (ClassList::exists(Rocket::trailParticles, CL_PARTICLE_SYSTEM)) … … 68 68 Rocket::trailParticles = NULL; 69 69 } 70 if (Rocket::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)-> getSize() <= 1)70 if (Rocket::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->size() <= 1) 71 71 { 72 72 if (ClassList::exists(Rocket::explosionParticles, CL_PARTICLE_SYSTEM)) -
trunk/src/world_entities/weapons/test_bullet.cc
r5769 r5779 62 62 63 63 /* this is normaly done by World.cc by deleting the ParticleEngine */ 64 if (TestBullet::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)-> getSize() <= 1)64 if (TestBullet::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->size() <= 1) 65 65 { 66 66 if (ClassList::exists(TestBullet::trailParticles, CL_PARTICLE_SYSTEM)) … … 68 68 TestBullet::trailParticles = NULL; 69 69 } 70 if (TestBullet::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)-> getSize() <= 1)70 if (TestBullet::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->size() <= 1) 71 71 { 72 72 if (ClassList::exists(TestBullet::explosionParticles, CL_PARTICLE_SYSTEM)) -
trunk/src/world_entities/weapons/weapon_manager.cc
r5750 r5779 347 347 if (this->targetIterator == NULL) 348 348 { 349 tList<BaseObject>* npcList = ClassList::getList(CL_NPC);349 std::list<BaseObject*>* npcList = ClassList::getList(CL_NPC); 350 350 if (npcList != NULL) 351 351 { 352 this->targetIterator = npcList->getIterator(); 353 this->targetIterator->firstElement(); 352 this->targetIterator = npcList->begin(); 354 353 } 355 354 else … … 357 356 } 358 357 359 PNode* retNode = dynamic_cast<PNode*>(targetIterator->nextElement()); 360 if (retNode == NULL && this->targetIterator->getList()->getSize() > 0) 361 retNode = dynamic_cast<PNode*>(targetIterator->firstElement()); 358 ///FIXME 359 // this->targetIterator++; 360 PNode* retNode = dynamic_cast<PNode*>((*targetIterator)); 361 // if (retNode == NULL && this->targetIterator->getList()->getSize() > 0) 362 // retNode = dynamic_cast<PNode*>(targetIterator->firstElement()); 362 363 363 364 return retNode; … … 372 373 PNode* WeaponManager::getDistanceTarget(const PNode* carrier, float distance) 373 374 { 374 tList<BaseObject>* npcList = ClassList::getList(CL_NPC);375 std::list<BaseObject*>* npcList = ClassList::getList(CL_NPC); 375 376 if (npcList != NULL) 376 377 { 377 tIterator<BaseObject>* npcIT = npcList->getIterator(); 378 PNode* tmpNPC = dynamic_cast<PNode*>(npcIT->firstElement()); 379 while (tmpNPC != NULL) 380 { 381 if ((carrier->getAbsCoor() - tmpNPC->getAbsCoor()).len() < distance) 382 { 383 delete npcIT; 384 return tmpNPC; 385 } 386 tmpNPC = dynamic_cast<PNode*>(npcIT->nextElement()); 387 } 388 delete npcIT; 378 list<BaseObject*>::iterator node; 379 for (node= npcList->begin(); node != npcList->end(); node++) 380 if ((carrier->getAbsCoor() - dynamic_cast<PNode*>(*node)->getAbsCoor()).len() < distance) 381 return dynamic_cast<PNode*>(*node); 389 382 } 390 383 return this->getFixedTarget(); 391 392 384 } 393 385 -
trunk/src/world_entities/weapons/weapon_manager.h
r5750 r5779 110 110 tAnimation<Crosshair>* crossHairSizeAnim; //!< An animation for the crosshair (scaling) 111 111 112 tIterator<BaseObject>*targetIterator; //!< An iterator for traversion lists of enemies.112 std::list<BaseObject*>::iterator targetIterator; //!< An iterator for traversion lists of enemies. 113 113 };
Note: See TracChangeset
for help on using the changeset viewer.