Error E1515: Invalid arguments

Posted By: Reconnoiter

Error E1515: Invalid arguments - 04/13/14 12:09

Hey all,

I sometimes get the invalid arguments error in my mp game when I test it with several clients and let a client fire. The error refers to my 'missile' code (code is below). It probably has got something to do with ent_remove (at the end of the code) that makes a pointer unusable. If I remove the ent_remove(me) line, the code gives no errors. So that is probably the cause of the error, but I have no idea how to solve since the manual does not give e.g. examples of ent_remove in multiplayer (yes blame the manual grin ). Anyway, below is the code of missile (where the error refers too):

Code:
action gun_laser_missile()
{	 	
if (connection & CONNECT_SERVER) my.smask |= NOSEND_FRAME | NOSEND_ALPHA | NOSEND_COLOR | NOSEND_FLAGS | NOSEND_SCALE;
while(connection != 0 && my.client_id < 0) wait(1);
...

	/////////////////////////////
	my.STATE = 1;
	
	....
	
	wait(1);
	c_setminmax(me);

	while(1)
	{	
	// state 1: flying ///////////////////////////////////////////  
		if (my.STATE == 1) 
		{
			if (connection == 2 && my.LIFETIME != 0) {
			ent_createlocal("MDL_MissileLaser.mdl",vector(my.x,my.y,my.z),gun_client_missile);
			my.LIFETIME = 0;
			set(my,INVISIBLE); }  

			//on server	
 			if (connection & CONNECT_SERVER || connection == 0) {
 			if (blabla == blabla) my.smask |= NOSEND_ORIGIN;	
 			my.LIFETIME -= time_step *4;
 			if (my.LIFETIME <= 0) my.STATE = 2; //go to STATE 2		
			//move projectile 	
			c_ignore(1,2,4,0);
			c_move(me,vector(my.MOVEMENTSPEED*time_step,0,0),vector(0,0,my.GRAVITY_SUM),IGNORE_PASSABLE);
			 //go to STATE 2
			 if (HIT_TARGET && my.STATE == 1) my.STATE = 2;
			}
		}

	// state 2: exploding ////////////////////////////////////////  
		if (my.STATE == 2) 
		{
			my.smask |= NOSEND;
                        break;
		} 
	wait(1);	
	}
	ent_remove(me);
}



Thanks in advance!
Posted By: Uhrwerk

Re: Error E1515: Invalid arguments - 04/13/14 13:34

The "ent_remove(me);" is dead code anyways. So this call is not your problem for sure.
Posted By: Reconnoiter

Re: Error E1515: Invalid arguments - 04/13/14 15:04

Thank you for commenting. But besides ent_remove, what could it be than?

I have in the action gun_client_missile (called by the line: ent_createlocal("MDL_MissileLaser.mdl",vector(my.x,my.y,my.z),gun_client_missile);), a few 'you's'. Could that be it, even though the error is refering to the action gun_laser_missile?
Posted By: Uhrwerk

Re: Error E1515: Invalid arguments - 04/13/14 15:07

What does the error message exactly say?
Posted By: Reconnoiter

Re: Error E1515: Invalid arguments - 04/13/14 15:38

"Error E1515:

Invalid function arguments in gun_laser_missile."

I get the error on the clients, but not on the server.
Posted By: Reconnoiter

Re: Error E1515: Invalid arguments - 04/15/14 10:57

Also have the same error (but than 'invalid function arguments in enemy_missile') in my code for the enemy projectiles. Maybe it is the same thing that causes it?
Here's the code for the enemy projectile:

Code:
action enemy_missile()
{
if (connection & CONNECT_SERVER) my.smask |= NOSEND_FRAME | NOSEND_ALPHA | NOSEND_COLOR | NOSEND_FLAGS | NOSEND_SCALE;	
while(connection != 0 && my.client_id < 0) wait(1);	

my.group = 1; //projectiles		
...

my.STATE = 1;
	
my.LIFETIME = 200;
...
 	
	wait(1);
	c_setminmax(me);

	while(1)
	{	
	// state 1: flying ///////////////////////////////////////////  
		if (my.STATE == 1) 
		{  
			//on server	
 			if ((connection & CONNECT_SERVER) || connection == 0) {	
 			my.LIFETIME -= time_step *4;
			my.GRAVITY_SUM -= my.GRAVITY * time_step;	
 			if (my.LIFETIME <= 0) my.STATE = 2; //go to STATE 2		
			 //go to STATE 2
		 	 if (global_timer_cscan == 1 || global_timer_cscan == 3) {
			 c_ignore(1,3,4,0); 
			 if (c_scan(my.x, my.pan, vector(360, 360, my.AREAOFEFFECT), SCAN_ENTS | SCAN_FLAG2 | IGNORE_ME) > 0) 
			  { my.STATE = 2; send_skill(my.STATE,SEND_ALL); }
			 }
			//move projectile 	
			c_ignore(1,2,3,4,0);
			c_move(me,vector(my.MOVEMENTSPEED*time_step,0,0),vector(0,0,my.GRAVITY_SUM),IGNORE_PASSABLE);
			 //go to STATE 2
			 if (HIT_TARGET && my.STATE == 1) { my.STATE = 2; send_skill(my.STATE,SEND_ALL); }
			}

                        //on client
			else {  
			//move projectile 	
			c_ignore(1,2,3,4,0);
			c_move(me,vector(my.MOVEMENTSPEED*time_step,0,0),vector(0,0,my.GRAVITY_SUM),IGNORE_PASSABLE);
			if (global_timer_cscan == 1 || global_timer_cscan == 3) {
			c_ignore(1,3,4,0); c_scan(my.x, my.pan, vector(360, 360, my.AREAOFEFFECT), SCAN_ENTS | SCAN_FLAG2 | IGNORE_ME); }
			}
		}

	// state 2: exploding ////////////////////////////////////////  
		if (my.STATE == 2) 
		{
			my.smask |= NOSEND;
			break;
		} 

		wait(1);	
	}
	ent_remove(me);
}

Posted By: Denn15

Re: Error E1515: Invalid arguments - 04/30/15 21:12

Im sorry for reviving an old topic but i just want to know if you found a solution to this, cause I am experiencing this excact error myself too.

If I spamshoot alot of missiles, then eventually the client will crash with "invalid function arguments in shot_action", which is the action for the missiles and it is always the clients that get the error. I tried to do the same on the server however it does not crash.
Posted By: Reconnoiter

Re: Error E1515: Invalid arguments - 05/01/15 17:35

I haven't touched gs3d multiplayer the last couple months, but I think it has something to do with invalid pointers.

I think EpsiloN's idea in this thread ( http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=450296&page=2 ) of doing only local bullets is a way to completely solve it.

What at that time somewhat helped for me was to wait a bit before doing ent_remove (I made the bullet invisible, break the while loop and removing it from groups etc.) which seemed to help quite a bit, but not solving it completely.
It is playable though when warn level is set to a low number, though this is ofcourse not recommended if your going to make a commercial game of it since sooner or later some clients will get weirds bugs grin .
But for short/quick games its fine.
Posted By: Ch40zzC0d3r

Re: Error E1515: Invalid arguments - 05/01/15 18:58

Use ANet or another third party plugin. More power over the process is sometimes more better wink
Posted By: EpsiloN

Re: Error E1515: Invalid arguments - 05/01/15 19:29

Some tips about these errors...

Never try to send a handle over the network.

Always check if you're spawning entities every frame (even
local ones, as in the first code posted here...) it will eventually crash laugh

You should try to use local bullets/missiles instead of global 'shared'. It will save you a lot of traffic, the error margin is the same...

Always wait one frame before an ent_remove statement. Another function might be running something on the current entity that's being deleted...So, wait until it finish and then remove!
(A wait call before an ent_remove will cause the ent_remove to be one of the first calls that will happen in the next frame, before any other function tries to access this entity...)

I cant say a correct reason for this error, but it might be caused by wrong number of parameters passed, I think, to a function, or the wrong type of parameter passed (eg, passing a string that contains a bitmap's name to a function that expects a bitmap pointer...)

I hope at least some of this helps laugh

Originally Posted By: Ch40zzC0d3r
Use ANet or another third party plugin. More power over the process is sometimes more better wink

I tried using ANet once...and some others...but eventually, I found out the native is best. Its just not used right or explained right laugh
I'll post my tutorial soon, and you'll understand my pov.
Posted By: Reconnoiter

Re: Error E1515: Invalid arguments - 05/01/15 21:04

I wonder if the invalid argument error occures cause of the following (quote from jcl from another topic about why ent_next gives an error when combined with ent_remove even when if (...pointer... != NULL) is done):

Quote:
No, it is not related just to the list, but can also happen in other circumstances. When you have two different actions running on the same entity, and the first action removes the entity at some point, the second action must test the used entity properties - name, position and so on - in order to detect if the entity is still there. Removed entities have no name, no flags, position is zero, and also all other entity properties are nonexistent or zero.
, global functions in a multiplayer games basically have 2 or more actions running the same entity (though they are the same), namely 1 for each server/client right? So perhaps Denn15 try checking if your pointers are valid by not only doing if (...pointer... != NULL) but also if(you->type != NULL). Just an idea, could be total rubbish.
Posted By: EpsiloN

Re: Error E1515: Invalid arguments - 05/01/15 21:12

If that's the case, and you're using dplay_localfunction = 2, I'd suggest remove it. Its complicated for debugging and you can easily confuse whats running where, after your code gets more than 10kb in size.

If you're using the regular MP, its fine if you remove an entity from one machine...It doesn't affect the other machines...or at least I remember being that way. Cant test right now laugh

PS.: I just posted my MP tutorial. If you need some info, here's the link:
Multiplayer - Extensive Tutorial
Posted By: Denn15

Re: Error E1515: Invalid arguments - 05/01/15 22:01

@Reconnoiter: That seems like a good idea actually in theory. I am gonna try that out tomorrow and see if it works.

@Epsilon: I am indeed using dplay_localfunction = 2 and I can easily see it getting out of hand, like it kinda is right now, and I have thought about changing method to not using it, though I think it would be easier to try and make it from scratch since the code i have currently is very much based on having dplay_localfunction = 2.
Posted By: Denn15

Re: Error E1515: Invalid arguments - 05/02/15 07:49

@reconnoiter:

Checking the pointer and type before removing the projectile seemed to have solved the problem. I also added a if(your.type != NULL) in the for loop I use for checking if I hit anything just to rule that out too. Now I can fire away without any crashes so your idea was not rubbish at alll it seems grin
Posted By: Reconnoiter

Re: Error E1515: Invalid arguments - 05/02/15 09:46

Originally Posted By: Denn15
@reconnoiter:

Checking the pointer and type before removing the projectile seemed to have solved the problem. I also added a if(your.type != NULL) in the for loop I use for checking if I hit anything just to rule that out too. Now I can fire away without any crashes so your idea was not rubbish at alll it seems grin
, wow did not expect that, that's good news. Tnx for testing. I will make this thread solves if I can so others can see the solution too.

- can't edit this thread anymore, can a moderator change this thread to solved? Ty
© 2024 lite-C Forums