JCL, I've also found another bug regarding structs and send_var_to. It appears that if you have more then one variable in the struct and you try to send more then 1 the game crashes. If need be I will provide a working example, but it's easy to replicate
[edit]
Below shows an example of what I mean. It's a complete copy of my testing.c file which you can copy and run it as is.
Code:
#include <acknex.h> // Pure Mode
#include <default.c>
typedef struct MYDATA
{
//int x;
var x;
char c[20];
} MYDATA;
MYDATA mydata;
typedef struct sZone
{
var zPosX;
var zPosY;
var zPosZ;
var zPan;
} sZone;
sZone z1s0;
sZone* pZoneStruct;
PANEL* pnlTesting =
{
flags = VISIBLE;
digits(300,300,"z1s0.zPosX: %015.5f",*,1,z1s0.zPosX);
digits(300,310,"z1s0.zPosY: %015.5f",*,1,z1s0.zPosY);
}
//receiving data
function on_client_event(void* buffer)
{
if(event_type == EVENT_DATA)
memcpy(mydata,buffer,sizeof(MYDATA));
}
function fTest()
{
my.skill50 = 12345;
while(1)
{
wait(1);
if(key_w == 1 && connection == 3)
{
while(key_w == 1){wait(1);}
z1s0.zPosX = 999;
z1s0.zPosY = 999;
send_var_to(my,z1s0.zPosX);
send_var_to(my,z1s0.zPosY);
}
}
/*
while(1)
{
wait(1);
if(key_w && connection == 3)
{
while(key_w == 1){wait(1);}
beep();
mydata.x = my.skill50;
send_var_to(NULL,mydata.x);
}
}
*/
}
function main()
{
if (0 == connection) {
video_window(NULL,NULL,16,"Looking for session...");
if (!session_connect("","")) // if no other server found,
{
session_open(""); // become the server
video_window(NULL,NULL,16,"SERVER");
}
else
{
video_window(NULL,NULL,16,"CLIENT");
}
}
level_load("testing.wmb");
wait(-1);
screen_color.blue = 255;
#ifdef server //if we defined this game as a server
while(connection & 0) {wait(1);} // wait until we have a connection
#endif
#ifdef client //if we defined this game as a client
while(connection & 0) {wait(1);} // wait until we have a connection
#endif
// on_server = server_event;
on_client = on_client_event;
if(connection == 2)
{
player = ent_create("testing.mdl",vector(200,0,0),fTest);
}
wait(-1);
while(1)
{
wait(1);
if(key_q == 1 && connection == 3)
{
while(key_q == 1){wait(1);}
beep();
// sending data
mydata.x = 1234;
strcpy(mydata.c,"Test!");
send_data_to(NULL,mydata,sizeof(MYDATA));
}
}
}
Wow JCL, I can't wait until the next update if send_skill_to / send_data_to and if this is another bug also send_var_to are fixed! I honestly think A7 multiplayer will be 10X better then everyone thinks after those small fixes. Everyone's biggest complaint has always been: "A# multiplayer sucks because it's all or nothing when it comes to sending information". I'm honestly looking foward to it, and I'm almost certain tons of other people are also. send_skill_to should make multiplayer coding a joke (meaning super easy).