[ANet] Disconnect message

Posted By: Razoron

[ANet] Disconnect message - 10/01/10 13:43

Hi,
the message recieved by the disconnect event is always wrong.
I disoconnect with:
Code:
enet_disconnect_client(i, "restart");


and recieve with
Code:
STRING* savemsg = str_create(msg); // Save the message



But I always get something like this:
Originally Posted By: Log

restartcr<j

The right string and some random charachters depending on the string length.

Any suggestions?

Posted By: Germanunkol

Re: [ANet] Disconnect message - 10/01/10 14:04

try:
STRING* savemsg = str_create("");
str_cpy(savemsg, msg);

it works for me.
Posted By: Rasch

Re: [ANet] Disconnect message - 10/01/10 14:06

str_create isnt really necessary i think.

STRING* savemsg = "";
str_cpy(savemsg, msg);

that should do it laugh
Posted By: Razoron

Re: [ANet] Disconnect message - 10/01/10 14:28

Tried both, nothing worked, still some mysterious charachters.
Thanks anyway.
Posted By: Rasch

Re: [ANet] Disconnect message - 10/01/10 15:29

Maybe show your functions.

Otherwise check Gamestudio and ANet Version. There were some problems when unicode was implented. Update to the newest one.
Posted By: Dark_samurai

Re: [ANet] Disconnect message - 10/02/10 11:21

Update to the latest ANet version 1.3.2.0. This was a Bug that occured with the old ANet version(s) if you used Gamestudio A7.84 or higher.
Posted By: Razoron

Re: [ANet] Disconnect message - 10/02/10 11:40

Updated, it still doesn't work.
I have A 7.85.4. Maybe I should update to 7.86.
Posted By: Dark_samurai

Re: [ANet] Disconnect message - 10/03/10 17:29

Make sure you also updated the anet.h. Otherwise, the bug will still occure.
Posted By: Razoron

Re: [ANet] Disconnect message - 10/03/10 18:24

Latest A7 Engine.
Latest ANet.

You have forgotten to update the ANet in the current ANet version you can download.

The header says:
Originally Posted By: anet.h

////////////////////////////////////////////////////////////////////////////////
//filename: anet.h
//copyright: Peter Soxberger
//autor: Peter Soxberger
//last change: 18.09.2010
//version: 1.3.0.3
//Describtion: lite-c header for ANet.dll (by Peter Soxberger)
//Notes: For a detailed describtion of each function look into the
// manual, please!
// Visit: www.anet-plugin.com
////////////////////////////////////////////////////////////////////////////////


The date seems valid, but the version is still old.

Posted By: Dark_samurai

Re: [ANet] Disconnect message - 10/04/10 15:02

No, I only forgot to update the version field.

I will do some tests, sounds like a bug to me.
Posted By: Dark_samurai

Re: [ANet] Disconnect message - 10/04/10 15:37

Code:
#include <acknex.h>
#include <anet.h>

void main()
{
	level_load("");
	wait(3);
	enet_init();
	enet_clset_event(EVENT_DISCONNECTED, "ev_cl_disconnected");
	while(1)
	{
		if(key_1)
		{
			enet_init_server(2300, 4, "");
			while(key_1) wait(1);
		}
		if(key_2)
		{
			enet_init_client("localhost", 2300, "");
			while(key_2) wait(1);
		}
		if(key_d)
		{
			enet_disconnect_client(0, "Disconnected");
			while(key_d) wait(1);
		}
		wait(1);
	}
}

void ev_cl_disconnected(var sender, STRING* msg)
{
	STRING* test_str = str_create("#100");
	str_cpy(test_str, msg);
	error(test_str);
}



The code above works just fine for me.
If I do it this way:

Code:
void ev_cl_disconnected(var sender, STRING* msg)
{
	STRING* test_str = str_create(msg);
	error(test_str);
}



Then there is no zero termination at the end of the string => random characters after the original text.
Posted By: Razoron

Re: [ANet] Disconnect message - 10/04/10 16:11

Okay, I tried it your way, it still doesn't work.
The disconnect function:
Code:
function server_restart()
{
	enet_disconnect_client(MY_CLIENTID, "restart");
}


The client event:
Code:
void client_disconnected(var sender, STRING* msg)
{
	STRING* savemsg = str_create("#100"); // Save the message
	str_cpy(savemsg, msg);
	error(savemsg);
}


The only thing that is different is that I use a server - client.
Posted By: Dark_samurai

Re: [ANet] Disconnect message - 10/07/10 19:51

Ah ok. I will take a look at this.

Thanks for the report.
Posted By: Dark_samurai

Re: [ANet] Disconnect message - 10/09/10 16:00

I think I solved the problem. I've sent you the new ANet version that should fix the problem (check your PM's). Please try it and tell me if it's working now.
Posted By: Razoron

Re: [ANet] Disconnect message - 10/20/10 12:12

Sorry, I've been in holidays.
It's working now! Big thanks, motivating me. laugh
© 2024 lite-C Forums