Avoid some warnings from static code analysis.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6296 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien 2022-01-22 15:54:43 +00:00
parent 62cf8296b1
commit 0fb6891267
3 changed files with 29 additions and 21 deletions

@ -215,21 +215,24 @@ int main()
const f32 frameDeltaTime = (f32)(now - then) / 1000.f; // Time in seconds const f32 frameDeltaTime = (f32)(now - then) / 1000.f; // Time in seconds
then = now; then = now;
/* Check if keys W, S, A or D are being held down, and move the if ( sphereNode )
sphere node around respectively. */ {
core::vector3df nodePosition = sphereNode->getPosition(); /* 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)) if(receiver.IsKeyDown(irr::KEY_KEY_W))
nodePosition.Y += MOVEMENT_SPEED * frameDeltaTime; nodePosition.Y += MOVEMENT_SPEED * frameDeltaTime;
else if(receiver.IsKeyDown(irr::KEY_KEY_S)) else if(receiver.IsKeyDown(irr::KEY_KEY_S))
nodePosition.Y -= MOVEMENT_SPEED * frameDeltaTime; nodePosition.Y -= MOVEMENT_SPEED * frameDeltaTime;
if(receiver.IsKeyDown(irr::KEY_KEY_A)) if(receiver.IsKeyDown(irr::KEY_KEY_A))
nodePosition.X -= MOVEMENT_SPEED * frameDeltaTime; nodePosition.X -= MOVEMENT_SPEED * frameDeltaTime;
else if(receiver.IsKeyDown(irr::KEY_KEY_D)) else if(receiver.IsKeyDown(irr::KEY_KEY_D))
nodePosition.X += MOVEMENT_SPEED * frameDeltaTime; 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)); driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,113,113,133));

@ -76,7 +76,7 @@ public:
if (image) if (image)
{ {
c8 buf[256]; c8 buf[256];
snprintf_irr(buf, 256, "%s_shot%04d.jpg", snprintf_irr(buf, 256, "%s_shot%04u.jpg",
FilenameTemplate.c_str(), FilenameTemplate.c_str(),
++Number); ++Number);
Device->getVideoDriver()->writeImageToFile(image, buf, 85 ); Device->getVideoDriver()->writeImageToFile(image, buf, 85 );

@ -299,22 +299,27 @@ public:
return *this; return *this;
strategy = other.strategy; strategy = other.strategy;
// (TODO: we could probably avoid re-allocations of data when (allocated < other.allocated)
if (data) if (data)
clear(); clear();
//if (allocated < other.allocated)
if (other.allocated == 0)
data = 0;
else
data = allocator.allocate(other.allocated); // new T[other.allocated];
used = other.used; used = other.used;
free_when_destroyed = true; free_when_destroyed = true;
is_sorted = other.is_sorted; is_sorted = other.is_sorted;
allocated = other.allocated; allocated = other.allocated;
for (u32 i=0; i<other.used; ++i) if (other.allocated == 0)
allocator.construct(&data[i], other.data[i]); // data[i] = other.data[i]; {
data = 0;
}
else
{
data = allocator.allocate(other.allocated); // new T[other.allocated];
for (u32 i=0; i<other.used; ++i)
allocator.construct(&data[i], other.data[i]); // data[i] = other.data[i];
}
return *this; return *this;
} }