- Timestamp:
- Sep 7, 2006, 10:33:06 PM (18 years ago)
- Location:
- branches/new_class_id/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/graphics/text_engine/font.cc
r9718 r9723 132 132 133 133 this->registerObject(this, Font::_objectList); 134 if (Font::defaultFontData. get() == NULL)134 if (Font::defaultFontData.isNull()) 135 135 { 136 136 Font::initDefaultFont(); -
branches/new_class_id/src/lib/util/count_pointer.h
r8761 r9723 9 9 { 10 10 public: 11 explicit CountPointer(X* p = 0) // allocate a new counter 12 : itsCounter(0) { if (p) itsCounter = new counter(p); } 13 virtual ~CountPointer() { release(); } 14 CountPointer(const CountPointer& r) { acquire(r.itsCounter); } 15 CountPointer& operator=(const CountPointer& r) 11 explicit CountPointer(X* p = NULL) // allocate a new counter 12 : itsCounter(NULL) { if (p) itsCounter = new counter(p); } 13 virtual ~CountPointer() { release(); } 14 CountPointer(const CountPointer& r) { acquire(r.itsCounter); } 15 CountPointer& operator=(const CountPointer& r) 16 { 17 if (this != &r) 16 18 { 17 if (this != &r) { 18 release(); 19 acquire(r.itsCounter); 20 } 21 return *this; 19 release(); 20 acquire(r.itsCounter); 22 21 } 23 bool operator==(const CountPointer& r) const { return this->itsCounter->ptr == r.itsCounter->ptr; }; 24 X& operator*() const { return *itsCounter->ptr; } 25 X* operator->() const { return itsCounter->ptr; } 26 X* get() const { return itsCounter ? itsCounter->ptr : 0; } 27 bool unique() const { return (itsCounter ? itsCounter->count == 1 : true); } 28 virtual unsigned int count() const { return (this->itsCounter ? itsCounter->count : 0); } 22 return *this; 23 } 24 bool operator==(const CountPointer& r) const { return this->itsCounter->ptr == r.itsCounter->ptr; }; 25 inline X& operator*() const { return *itsCounter->ptr; } 26 inline X* operator->() const { return itsCounter->ptr; } 27 inline bool unique() const { return (itsCounter ? itsCounter->count == 1 : true); } 28 inline bool isNull() const { return (!itsCounter); } 29 30 virtual unsigned int count() const { return (this->itsCounter ? itsCounter->count : 0); } 29 31 private: 30 32 31 struct counter { 32 counter(X* p = 0, unsigned c = 1) : ptr(p), count(c) {} 33 X* ptr; 34 unsigned count; 35 }* itsCounter; 33 struct counter 34 { 35 counter(X* p = NULL, unsigned c = 1) : ptr(p), count(c) {} 36 X* ptr; 37 unsigned count; 38 } 39 * itsCounter; 36 40 37 void acquire(counter* c) 41 void acquire(counter* c) 42 { 43 // increment the count 44 itsCounter = c; 45 if (c) ++c->count; 46 } 47 48 void release() 49 { 50 // decrement the count, delete if it is 0 51 if (itsCounter) 38 52 { 39 // increment the count 40 itsCounter = c; 41 if (c) ++c->count; 53 if (--itsCounter->count == 0) 54 { 55 delete itsCounter->ptr; 56 delete itsCounter; 57 } 58 itsCounter = NULL; 42 59 } 43 44 void release() 45 { 46 // decrement the count, delete if it is 0 47 if (itsCounter) { 48 if (--itsCounter->count == 0) { 49 delete itsCounter->ptr; 50 delete itsCounter; 51 } 52 itsCounter = 0; 53 } 54 } 60 } 55 61 }; 56 62 -
branches/new_class_id/src/story_entities/game_world.cc
r9715 r9723 415 415 if (currentFrame - this->lastFrame < .01) 416 416 { 417 SDL_Delay( 1000.0 * (0.01 - (currentFrame - lastFrame)));417 SDL_Delay((int)1000.0 * (0.01 - (currentFrame - lastFrame))); 418 418 currentFrame = Timer::getNow(); 419 419 } -
branches/new_class_id/src/world_entities/weapons/weapon.cc
r9715 r9723 542 542 { 543 543 PRINTF(4)("Reloading Weapon %s\n", this->getCName()); 544 if ( this->ammoContainer.get() != NULL&&544 if (!this->ammoContainer.isNull() && 545 545 unlikely(this->energy + this->ammoContainer->getStoredEnergy() < this->minCharge)) 546 546 { … … 554 554 this->soundSource->play(this->soundBuffers[WA_RELOAD]); 555 555 556 if ( this->ammoContainer.get() != NULL)556 if (!this->ammoContainer.isNull()) 557 557 this->ammoContainer->fillWeapon(this); 558 558 else
Note: See TracChangeset
for help on using the changeset viewer.