Troubleshooting While loop

OrionVeteran

Deity
Joined
Dec 25, 2003
Messages
2,443
Location
Newport News VA
I have two lines of code I am using to find failure points in my latest SDK development.

Code:
CvWString szBufferA = "Test Message A";
gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), true, GC.getEVENT_MESSAGE_TIME(), szBufferA, "AS2D_COMBAT", MESSAGE_TYPE_DISPLAY_ONLY, getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_RED"), pPlot->getX_INLINE(), pPlot->getY_INLINE(), true);

This code works except when I attempt to place it within a While loop. The failure of this test message code to display within the while loop, is preventing me from isolating the line of failure, within the loop. Is there something else I can do to help locate the failure point within the loop?
 
Show us what the non-working code looks like.

I think I have found the problem. I am running 3 while loops in one function. I did a bool test to see if (pUnitNode == NULL) and it came back true! Therefore, the 3rd loop never ran. Do I have to specify 3 different names for pUnitNode to make all 3 loops work correctly?


Code:
while (pUnitNode != NULL)
{
	pLoopUnitX = ::getUnit(pUnitNode->m_data);
	pUnitNode = pPlot->nextUnitNode(pUnitNode);

	Code...


while (pUnitNode != NULL)
{
	pLoopUnitY = ::getUnit(pUnitNode->m_data);
	pUnitNode = pPlot->nextUnitNode(pUnitNode);

	Code...


while (pUnitNode != NULL)
{
	pLoopUnitZ = ::getUnit(pUnitNode->m_data);
	pUnitNode = pPlot->nextUnitNode(pUnitNode);

	code...

Update: The answer is yes and now all 3 while loops work! The conversion of Mine Warfare to SDK just had a major break through. :)
 
Top Bottom