Game Development Community

Torque3D 3.0 MIT - ShapeBase Warnings

by JeffH · in Torque 3D Professional · 05/27/2013 (1:49 pm) · 5 replies

In shapeBase.cpp, around line 3161, the inner for loop should be using a new variable as "I" is instantiated and used within the outer for loop.

This code:

for (U32 i=0; i<ShapeBaseImageData::MaxGenericTriggers; ++i)
{
   stream->writeFlag(image.genericTrigger[i]);
}

Should be replaced with this code:

for (U32 j = 0; j < ShapeBaseImageData::MaxGenericTriggers; ++j)
   stream->writeFlag(image.genericTrigger[j]);

Same with around line 3304

replace:

for (U32 i=0; i<ShapeBaseImageData::MaxGenericTriggers; ++i)
  image.genericTrigger[i] = stream->readFlag();

with this:

for (U32 j=0; j<ShapeBaseImageData::MaxGenericTriggers; ++j)
  image.genericTrigger[j] = stream->readFlag();

#1
05/27/2013 (2:05 pm)
Hmm, once upon a time this would have used the inner for loop's variable within that scope and the outer definition for that scope - apparently this was not standards compliant....

However, this works (with warnings):
for (int i = 0; i < 10; i++)
	{
		for (unsigned int i = 50; i > 40; i--)
			printf("inner i = %d\n", i);
		printf("outer i = %d\n", i);
	}
#2
05/27/2013 (2:28 pm)
Something of this nature would better be served if ticketed as an Issue on Github so that it is not lost in the Forums -- especially given it's non-descriptive thread title. Even better would be to see a Pull Request for the fix if it's causing any issues.
#3
05/27/2013 (2:39 pm)
Yes, the code as it is does work, though MSVC gives warnings about it.
#4
05/28/2013 (7:48 am)
If you are using VS 2012 and use their deprecation cop feature ("SDL", can't remember what it stands for) it will actually not compile with this warning.

I think it's interesting that the warning says its ignoring the inner definition but still keeps track of them separately.
#5
08/27/2013 (4:49 am)
someone shoot the spammer #5 :-)