Well... I have narrowed down to the function where the problem lies, The code does not look incorrect to me.
About 10-11 seconds after I press the start debugging button and the initial Dark GDK window appears my program is 100% unresponsive.
Here is the function that is causing the issue:
//int ri is being set at 0 in another header.
//npcs[ri][8] is for a variable to tell weather it is alive or dead which is set in another function. 0 means dead this function also hides the object
//npcs[ri][7] is the time in seconds when the npc was 'killed' + 30 seconds.
//npcs[ri][1] is for the npcs 'health'
void NPC_Respawner()
{
if ( npcs[ri][8] == 0 && npcs[ri][7] <= seconds )
{
npcs[ri][8] = 1;
npcs[ri][1] = 111;
dbShowObject ( npcs[ri][0] );
}
ri++;
}
The program only goes unresponsive only while this function has been uncommented from Main.cpp
Here is main.cpp:
#include <DarkGDK.h>
#include <MikeNet.h>
#include <time.h>
#include <SC_Collision.h>
#include "Declarations.h"
#include "Functions.h"
void DarkGDK ( void )
{
dbInk( 2, 2 );
SC_Start ( );
Setup_Game ( );
Setup_Player ( );
//Net_Connect ( );
while ( LoopGDK ( ) )
{
seconds = time ( 0 );
Player_Update ( );
//Net_Messages ( );
//Net_Send ( );
Camera_Control ( );
Player_Control ( );
Screen_Print ( );
moveObject ( 3, 0 );
Sprite_GUI ( );
//NPC_Respawner ( ); //This is that function
dbSync ( );
}
for ( int i = 1; i < 1000; i++ )
{
dbDeleteObject ( i );
}
mnFinish ( -1 );
mnDeletePacket ( RecvPacket );
mnDeletePacket ( SendPacket );
return;
}
The actual function used contain a for loop to carry out this task and I got an exception probably from the for loop executing a check 500 times against an array every frame
. So I thought I would try to execute it once every frame which meant just to remove the for loop, and now it just goes unresponsive.
Any help?
I <3 C++ & Dark GDK 4 2 maek mai gamezorz! =D