Changeset 6142 in orxonox.OLD for trunk/src/story_entities
- Timestamp:
- Dec 16, 2005, 7:13:57 PM (19 years ago)
- Location:
- trunk/src/story_entities
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/story_entities/network_world.cc
r6139 r6142 38 38 #include "shell.h" 39 39 40 #include "garbage_collector.h"41 40 #include "fast_factory.h" 42 41 #include "animation_player.h" … … 123 122 PRINTF(3)("NetworkWorld::~NetworkWorld() - deleting current world\n"); 124 123 125 126 // here everything that is alocated by the NetworkWorld is deleted127 delete this->entities;128 State::setWorldEntityList(NULL);129 130 124 delete this->localPlayer; 131 125 … … 141 135 SoundEngine::getInstance()->flushAllSources(); 142 136 143 137 if (State::getObjectManager() == &this->objectManager) 138 State::setObjectManager(NULL); 144 139 // erease everything that is left. 145 140 delete PNode::getNullParent(); … … 180 175 this->music = NULL; 181 176 this->shell = NULL; 182 this->entities = NULL;183 177 this->localPlayer = NULL; 184 178 this->localCamera = NULL; … … 214 208 ErrorMessage NetworkWorld::preLoad() 215 209 { 216 State::set WorldEntityList(this->entities = new tList<WorldEntity>());210 State::setObjectManager(&this->objectManager); 217 211 this->cycle = 0; 218 212 … … 233 227 234 228 GraphicsEngine::getInstance()->displayFPS(true); 235 236 CDEngine::getInstance()->setEntityList( this->entities);237 229 } 238 230 … … 630 622 631 623 /** 632 * gets the list of entities from the world633 * @returns entity list634 */635 tList<WorldEntity>* NetworkWorld::getEntities()636 {637 return this->entities;638 }639 640 641 /**642 624 * this returns the current game time 643 625 * @returns elapsed game time … … 648 630 } 649 631 650 651 632 /** 652 633 * function to put your own debug stuff into it. it can display informations about 653 634 the current class/procedure 654 635 */ 655 void NetworkWorld::debug()656 {657 PRINTF(0)("Printing out the List of alive NetworkWorldEntities:\n");658 tIterator<WorldEntity>* iterator = this->entities->getIterator();659 WorldEntity* entity = iterator->firstElement();660 while( entity != NULL)661 {662 PRINTF(0)("%s::%s\n", entity->getClassName(), entity->getName());663 entity = iterator->nextElement();664 }665 delete iterator;666 }636 // void NetworkWorld::debug() 637 // { 638 // PRINTF(0)("Printing out the List of alive NetworkWorldEntities:\n"); 639 // tIterator<WorldEntity>* iterator = this->entities->getIterator(); 640 // WorldEntity* entity = iterator->firstElement(); 641 // while( entity != NULL) 642 // { 643 // PRINTF(0)("%s::%s\n", entity->getClassName(), entity->getName()); 644 // entity = iterator->nextElement(); 645 // } 646 // delete iterator; 647 // } 667 648 668 649 … … 682 663 { 683 664 ++this->cycle; 684 PRINTF(4)("NetworkWorld::mainloop() - number of entities: %i\n", this->entities->getSize());665 // PRINTF(4)("NetworkWorld::mainloop() - number of entities: %i\n", this->entities->getSize()); 685 666 // Network 686 667 this->synchronize (); … … 727 708 } 728 709 710 void NetworkWorld::tick(std::list<WorldEntity*> entityList, float dt) 711 { 712 std::list<WorldEntity*>::iterator entity; 713 for (entity = entityList.begin(); entity != entityList.end(); entity++) 714 (*entity)->tick(dt); 715 716 } 729 717 730 718 /** … … 763 751 this->gameTime += this->dtS; 764 752 765 tIterator<WorldEntity>* iterator = this->entities->getIterator(); 766 WorldEntity* entity = iterator->firstElement(); 767 while( entity != NULL) 768 { 769 entity->tick (this->dtS); 770 entity = iterator->nextElement(); 771 } 772 delete iterator; 753 /* this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS); 754 this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS); 755 this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);*/ 756 this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS); 757 this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS); 773 758 774 759 /* update tick the rest */ … … 780 765 781 766 ParticleEngine::getInstance()->tick(this->dtS); 782 GarbageCollector::getInstance()->tick(this->dtS);783 767 784 768 … … 805 789 void NetworkWorld::update() 806 790 { 807 GarbageCollector::getInstance()->update();808 791 GraphicsEngine::getInstance()->update(this->dtS); 809 792 PNode::getNullParent()->updateNode (this->dtS); … … 816 799 void NetworkWorld::collide() 817 800 { 818 CDEngine::getInstance()->checkCollisions(); 801 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00), 802 this->objectManager.getObjectList(OM_GROUP_01_PROJ)); 803 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_01), 804 this->objectManager.getObjectList(OM_COMMON)); 819 805 } 820 806 … … 846 832 void NetworkWorld::draw () 847 833 { 848 /* draw entities */ 849 WorldEntity* entity; 850 glLoadIdentity(); 851 tIterator<WorldEntity>* iterator = this->entities->getIterator(); 852 entity = iterator->firstElement(); 853 while( entity != NULL ) 854 { 855 if( entity->isVisible() ) entity->draw(); 856 if( unlikely( this->showBV)) entity->drawBVTree(3, 226); // to draw the bounding boxes of the objects at level 2 for debug purp 857 entity = iterator->nextElement(); 858 } 859 delete iterator; 834 GraphicsEngine* engine = GraphicsEngine::getInstance(); 835 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK)); 836 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON)); 837 engine->draw(State::getObjectManager()->getObjectList(OM_COMMON)); 838 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_00)); 839 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01)); 840 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ)); 841 842 // { 843 // if( entity->isVisible() ) entity->draw(); 844 //FIXME 845 // if( unlikely( this->showBV)) entity->drawBVTree(3, 226); // to draw the bounding boxes of the objects at level 2 for debug purp 846 // entity = iterator->nextElement(); 847 // } 860 848 861 849 glCallList (objectList); … … 866 854 PNode::getNullParent()->debugDraw(0); 867 855 868 GraphicsEngine::getInstance()->draw();856 engine->draw(); 869 857 //TextEngine::getInstance()->draw(); 870 858 } … … 876 864 void NetworkWorld::spawn(WorldEntity* entity) 877 865 { 878 this->entities->add (entity);866 // this->entities->add (entity); 879 867 entity->postSpawn (); 880 868 } … … 889 877 void NetworkWorld::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir) 890 878 { 891 this->entities->add (entity);879 // this->entities->add (entity); 892 880 893 881 entity->setAbsCoor (*absCoor); … … 915 903 entity->setRelDir (*relDir); 916 904 917 this->entities->add (entity);905 // this->entities->add (entity); 918 906 919 907 entity->postSpawn (); -
trunk/src/story_entities/network_world.h
r6139 r6142 11 11 #include "story_entity.h" 12 12 #include "p_node.h" 13 #include "object_manager.h" 13 14 14 15 class NetworkWorld; 16 15 17 class WorldEntity; 16 18 class Camera; … … 18 20 class GLMenuImageScreen; 19 21 class Terrain; 20 class GarbageCollector;21 class Text;22 22 class TiXmlElement; 23 23 24 24 class Shell; 25 25 class OggPlayer; 26 template<class T> class tList;27 26 28 27 //! The game world … … 61 60 bool command (Command* cmd); 62 61 63 tList<WorldEntity>* getEntities();64 65 62 /* interface to world */ 66 63 void spawn (WorldEntity* entity); … … 84 81 void synchronize (); 85 82 void handleInput (); 83 void tick (std::list<WorldEntity*> worldEntity, float dt); 86 84 void tick (); 87 85 void update (); … … 104 102 bool bPause; //!< pause mode 105 103 104 ObjectManager objectManager; //!< The ObjectManager of this World. 105 106 106 GLMenuImageScreen* glmis; //!< The Level-Loader Display 107 107 … … 118 118 119 119 GLuint objectList; //!< temporary: @todo this will be ereased soon 120 tList<WorldEntity>* entities; //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them. 120 121 121 Player* localPlayer; //!< The Player, you fly through the level. 122 122 }; -
trunk/src/story_entities/world.cc
r6074 r6142 38 38 #include "shell.h" 39 39 40 #include "garbage_collector.h"41 40 #include "fast_factory.h" 42 41 #include "animation_player.h" … … 123 122 PRINTF(3)("World::~World() - deleting current world\n"); 124 123 125 126 // here everything that is alocated by the World is deleted127 delete this->entities;128 State::setWorldEntityList(NULL);129 130 124 delete this->localPlayer; 131 125 … … 141 135 SoundEngine::getInstance()->flushAllSources(); 142 136 143 137 if (State::getObjectManager() == &this->objectManager) 138 State::setObjectManager(NULL); 144 139 // erease everything that is left. 145 140 delete PNode::getNullParent(); … … 180 175 this->music = NULL; 181 176 this->shell = NULL; 182 this->entities = NULL;183 177 this->localPlayer = NULL; 184 178 this->localCamera = NULL; … … 214 208 ErrorMessage World::preLoad() 215 209 { 216 State::set WorldEntityList(this->entities = new tList<WorldEntity>());210 State::setObjectManager(&this->objectManager); 217 211 this->cycle = 0; 218 212 … … 233 227 234 228 GraphicsEngine::getInstance()->displayFPS(true); 235 236 CDEngine::getInstance()->setEntityList( this->entities);237 229 } 238 230 … … 588 580 589 581 /** 590 * gets the list of entities from the world591 * @returns entity list592 */593 tList<WorldEntity>* World::getEntities()594 {595 return this->entities;596 }597 598 599 /**600 582 * this returns the current game time 601 583 * @returns elapsed game time … … 605 587 return this->gameTime; 606 588 } 607 608 609 /**610 * function to put your own debug stuff into it. it can display informations about611 the current class/procedure612 */613 void World::debug()614 {615 PRINTF(0)("Printing out the List of alive WorldEntities:\n");616 tIterator<WorldEntity>* iterator = this->entities->getIterator();617 WorldEntity* entity = iterator->firstElement();618 while( entity != NULL)619 {620 PRINTF(0)("%s::%s\n", entity->getClassName(), entity->getName());621 entity = iterator->nextElement();622 }623 delete iterator;624 }625 626 589 627 590 /** … … 640 603 { 641 604 ++this->cycle; 642 PRINTF(4)("World::mainloop() - number of entities: %i\n", this->entities->getSize());643 605 // Network 644 606 this->synchronize (); … … 685 647 } 686 648 649 void World::tick(std::list<WorldEntity*> entityList, float dt) 650 { 651 std::list<WorldEntity*>::iterator entity; 652 for (entity = entityList.begin(); entity != entityList.end(); entity++) 653 (*entity)->tick(dt); 654 655 } 687 656 688 657 /** … … 721 690 this->gameTime += this->dtS; 722 691 723 tIterator<WorldEntity>* iterator = this->entities->getIterator(); 724 WorldEntity* entity = iterator->firstElement(); 725 while( entity != NULL) 726 { 727 entity->tick (this->dtS); 728 entity = iterator->nextElement(); 729 } 730 delete iterator; 692 /* this->tick(this->objectManager.getObjectList(OM_DEAD_TICK), this->dtS); 693 this->tick(this->objectManager.getObjectList(OM_COMMON), this->dtS); 694 this->tick(this->objectManager.getObjectList(OM_GROUP_00), this->dtS);*/ 695 this->tick(this->objectManager.getObjectList(OM_GROUP_01), this->dtS); 696 this->tick(this->objectManager.getObjectList(OM_GROUP_01_PROJ), this->dtS); 731 697 732 698 /* update tick the rest */ … … 738 704 739 705 ParticleEngine::getInstance()->tick(this->dtS); 740 GarbageCollector::getInstance()->tick(this->dtS);741 706 742 707 … … 763 728 void World::update() 764 729 { 765 GarbageCollector::getInstance()->update();766 730 GraphicsEngine::getInstance()->update(this->dtS); 767 731 PNode::getNullParent()->updateNode (this->dtS); … … 774 738 void World::collide() 775 739 { 776 CDEngine::getInstance()->checkCollisions(); 740 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_00), 741 this->objectManager.getObjectList(OM_GROUP_01_PROJ)); 742 CDEngine::getInstance()->checkCollisions(this->objectManager.getObjectList(OM_GROUP_01), 743 this->objectManager.getObjectList(OM_COMMON)); 777 744 } 778 745 … … 804 771 void World::draw () 805 772 { 806 /* draw entities */ 807 WorldEntity* entity; 808 glLoadIdentity(); 809 tIterator<WorldEntity>* iterator = this->entities->getIterator(); 810 entity = iterator->firstElement(); 811 while( entity != NULL ) 812 { 813 if( entity->isVisible() ) entity->draw(); 814 if( unlikely( this->showBV)) entity->drawBVTree(3, 226); // to draw the bounding boxes of the objects at level 2 for debug purp 815 entity = iterator->nextElement(); 816 } 817 delete iterator; 773 GraphicsEngine* engine = GraphicsEngine::getInstance(); 774 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON_NOTICK)); 775 engine->draw(State::getObjectManager()->getObjectList(OM_ENVIRON)); 776 engine->draw(State::getObjectManager()->getObjectList(OM_COMMON)); 777 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_00)); 778 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01)); 779 engine->draw(State::getObjectManager()->getObjectList(OM_GROUP_01_PROJ)); 780 781 // { 782 // if( entity->isVisible() ) entity->draw(); 783 //FIXME 784 // if( unlikely( this->showBV)) entity->drawBVTree(3, 226); // to draw the bounding boxes of the objects at level 2 for debug purp 785 // entity = iterator->nextElement(); 786 // } 818 787 819 788 glCallList (objectList); … … 824 793 PNode::getNullParent()->debugDraw(0); 825 794 826 GraphicsEngine::getInstance()->draw();795 engine->draw(); 827 796 //TextEngine::getInstance()->draw(); 828 797 } … … 834 803 void World::spawn(WorldEntity* entity) 835 804 { 836 this->entities->add (entity);805 // this->entities->add (entity); 837 806 entity->postSpawn (); 838 807 } … … 847 816 void World::spawn(WorldEntity* entity, Vector* absCoor, Quaternion* absDir) 848 817 { 849 this->entities->add (entity);818 // this->entities->add (entity); 850 819 851 820 entity->setAbsCoor (*absCoor); … … 873 842 entity->setRelDir (*relDir); 874 843 875 this->entities->add (entity);844 // this->entities->add (entity); 876 845 877 846 entity->postSpawn (); -
trunk/src/story_entities/world.h
r6048 r6142 11 11 #include "story_entity.h" 12 12 #include "p_node.h" 13 #include "object_manager.h" 13 14 14 class World; 15 15 16 class WorldEntity; 16 17 class Camera; … … 18 19 class GLMenuImageScreen; 19 20 class Terrain; 20 class GarbageCollector;21 class Text;22 21 class TiXmlElement; 23 22 24 23 class Shell; 25 24 class OggPlayer; 26 template<class T> class tList;27 25 28 26 //! The game world … … 61 59 bool command (Command* cmd); 62 60 63 tList<WorldEntity>* getEntities();64 65 61 /* interface to world */ 66 62 void spawn (WorldEntity* entity); … … 84 80 void synchronize (); 85 81 void handleInput (); 82 void tick (std::list<WorldEntity*> worldEntity, float dt); 86 83 void tick (); 87 84 void update (); … … 104 101 bool bPause; //!< pause mode 105 102 103 ObjectManager objectManager; //!< The ObjectManager of this World. 104 106 105 GLMenuImageScreen* glmis; //!< The Level-Loader Display 107 106 … … 118 117 119 118 GLuint objectList; //!< temporary: @todo this will be ereased soon 120 tList<WorldEntity>* entities; //!< A template List of all entities. Every moving thing should be included here, and world automatically updates them. 119 121 120 Player* localPlayer; //!< The Player, you fly through the level. 122 121 };
Note: See TracChangeset
for help on using the changeset viewer.