I faced a really strange thing. When adding entity Arrays to a shadeC Project, ull be hunted by strange randomly appearing bugs.

Its hard to explain, but already confirmed by 3run ( my example i uploaded ).

I made this example. Its basicly the std. example from shadeC with around 50 new lines.
In this example the c_move call makes the script Crash ( but only if its commented out WTF ). This is just one example of bug with Array in shadeC.
Without Arrays all works fine. And if you take the Array stuff out of shadec Project it also works.


https://www.file-upload.net/download-13105427/arrayBUGshadeC.rar.html

Code:
#define MAX_ENEMY   9999
#define MAX_ENEMY2   9999

var ENEMIES_TOTAL    = 0;
var ENEMIES_TOTAL2    = 0;

ENTITY* enemy_list  [MAX_ENEMY];
ENTITY* enemy_list2  [MAX_ENEMY2];


action actEnemy(){
	// ----------------------------------------------------------------------------------------------------------
	if (ENEMIES_TOTAL >= MAX_ENEMY) { ptr_remove(my); return; }
	enemy_list [ENEMIES_TOTAL] = my;
	ENEMIES_TOTAL++;
}
action actEnemy2(){
	// ----------------------------------------------------------------------------------------------------------
	if (ENEMIES_TOTAL2 >= MAX_ENEMY2) { ptr_remove(my); return; }
	enemy_list2 [ENEMIES_TOTAL2] = my;
	ENEMIES_TOTAL2++;
}

void updateNPC_both(){
	ENTITY* tempEnt;                           // instead of my/me were using tempEnt
	ENTITY* tempEnt2;                           // instead of my/me were using tempEnt
	int i = 0;                                 // the "itemindex" in the for cycle
	// ----------------------------------------------------------------------------------------------------------
	while (1){                                 // handle all enemys as long as... 
	   // -------------------------------------------------------------------------------------------------------


		for (i = 0; i < ENEMIES_TOTAL; i++){    // cycle through all enemys in array now
		   // ----------------------------------------------------------------------------------------------------
			// --- [ fill pointers ] ------------------------------------------------------------------------------
			// ----------------------------------------------------------------------------------------------------
			tempEnt   = enemy_list[i]; 
			tempEnt2  = enemy_list2[i]; 
                        if (tempEnt == NULL) continue;
                        if (tempEnt2 == NULL) continue;
                        if (tempEnt2.skill1 == 0) beep; // baam
                 }
                 wait (1);
           }
}

main.c:

updateNPC_both();
ent_create ("modela.mdl", vector (0,0,0), actEnemy);
ent_create ("modela.mdl", vector (0,0,0), actEnemy2);

This tiny contruct will Crash when u continue adding stuff, hard to explain.

edit:
I know the using of two arrays like i did in this example is shitty...anyway it should work.

Last edited by rayp; 04/30/18 00:16.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;