Happy new year everyone!
I'm still hard at work on my game, particularly the server stuff.
To make everything user friendly, I've made it so that the user can insert their own username and preferred ip address into text files in the same directory as the dcb file. This way they can set up their own server if they want to play a friend. The dcb has no problem reading from the text files and loading the ip address or the user names, but passing the user name to the other side seems to be tricky.
Each client loads their own username file and populates the variable "string username" with their own username. What seems to be happening, is that the name of the variable "username" is being passed through the server, and not the contents of that string itself. I've found that if I override the contents of the string by manually assigning a string of text to each client's username variable, that the strings are passed through the server just fine.
In the example below, as is, user one loads its username which is Miss_One, and user two is Mr_Two. In the Miss_One client, it tells us that the opponent is also called Miss_One because it is looking at its own username variable, which means the server is telling the client to look at username, not passing a string value for p2name.
If you uncomment lines 60 and 63, regarding mario and luigi, the clients are given those names respectively. Now when you launch it, the names Mario and Luigi are passed through the server, and everything works properly. Trouble is, it's no longer using the name that the user typed in that handy text file.
So the problem must lie within the way I'm initially assigning the contents of the text file to the string username:
seems to be sending the message to the other client to look at their own variable "username" instead of sending the string value of username to populate the type on the server. Like sending the name of the string, rather than the contents of the string?
I have tried passing username to a different string variable inbetween, but it produced the same results.
I also tried adding the string with another string, but also produced the same results.
I had no luck using pointers to the string variable username.
I must be missing something here. Thank you to anyone who has even read this far! I'll definitely update if I find a solution!
/*Solár Cliénte - Christof Muñoz*/
MaxConnections = 1;
write(0,10,30,3,"BNP_PORT=" + (BNP_PORT));
write(0,10,40,3,"BNP_ID=" + (BNP_ID));
write(0,10,80,3,"p1name=" + (player.p1name));
write(0,10,90,3,"p2name=" + (player.p2name));
write(0,10,100,3,"username=" + (username));
All files needed to test this out are in the zip file.