diff --git a/examples/04.Movement/main.cpp b/examples/04.Movement/main.cpp index dcbcc30e..443056cb 100644 --- a/examples/04.Movement/main.cpp +++ b/examples/04.Movement/main.cpp @@ -215,21 +215,24 @@ int main() const f32 frameDeltaTime = (f32)(now - then) / 1000.f; // Time in seconds then = now; - /* Check if keys W, S, A or D are being held down, and move the - sphere node around respectively. */ - core::vector3df nodePosition = sphereNode->getPosition(); + if ( sphereNode ) + { + /* Check if keys W, S, A or D are being held down, and move the + sphere node around respectively. */ + core::vector3df nodePosition = sphereNode->getPosition(); - if(receiver.IsKeyDown(irr::KEY_KEY_W)) - nodePosition.Y += MOVEMENT_SPEED * frameDeltaTime; - else if(receiver.IsKeyDown(irr::KEY_KEY_S)) - nodePosition.Y -= MOVEMENT_SPEED * frameDeltaTime; + if(receiver.IsKeyDown(irr::KEY_KEY_W)) + nodePosition.Y += MOVEMENT_SPEED * frameDeltaTime; + else if(receiver.IsKeyDown(irr::KEY_KEY_S)) + nodePosition.Y -= MOVEMENT_SPEED * frameDeltaTime; - if(receiver.IsKeyDown(irr::KEY_KEY_A)) - nodePosition.X -= MOVEMENT_SPEED * frameDeltaTime; - else if(receiver.IsKeyDown(irr::KEY_KEY_D)) - nodePosition.X += MOVEMENT_SPEED * frameDeltaTime; + if(receiver.IsKeyDown(irr::KEY_KEY_A)) + nodePosition.X -= MOVEMENT_SPEED * frameDeltaTime; + else if(receiver.IsKeyDown(irr::KEY_KEY_D)) + nodePosition.X += MOVEMENT_SPEED * frameDeltaTime; - sphereNode->setPosition(nodePosition); + sphereNode->setPosition(nodePosition); + } driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,113,113,133)); diff --git a/examples/16.Quake3MapShader/main.cpp b/examples/16.Quake3MapShader/main.cpp index 38062c5a..e288e6f7 100644 --- a/examples/16.Quake3MapShader/main.cpp +++ b/examples/16.Quake3MapShader/main.cpp @@ -76,7 +76,7 @@ public: if (image) { c8 buf[256]; - snprintf_irr(buf, 256, "%s_shot%04d.jpg", + snprintf_irr(buf, 256, "%s_shot%04u.jpg", FilenameTemplate.c_str(), ++Number); Device->getVideoDriver()->writeImageToFile(image, buf, 85 ); diff --git a/include/irrArray.h b/include/irrArray.h index 3572e626..db5c3e07 100644 --- a/include/irrArray.h +++ b/include/irrArray.h @@ -299,22 +299,27 @@ public: return *this; strategy = other.strategy; + // (TODO: we could probably avoid re-allocations of data when (allocated < other.allocated) + if (data) clear(); - //if (allocated < other.allocated) - if (other.allocated == 0) - data = 0; - else - data = allocator.allocate(other.allocated); // new T[other.allocated]; - used = other.used; free_when_destroyed = true; is_sorted = other.is_sorted; allocated = other.allocated; - for (u32 i=0; i