LAN multiplayer(UDP)..

Blitz3D Forums/Blitz3D Userlibs/LAN multiplayer(UDP)..

Rick Nasher(Posted 2015) [#1]
Hi All,

I am trying to create a LAN/Internet multiplayer game, but I'm having trouble to make it answer to my needs(switching hosts on the fly).

Sofar I've tried these 2 UDP libraries:

1) LlamaNet 1.06


From this I really love example "LAmaNet_Example09_3D-Environment.bb"
Which is great but apparently a bit buggy, working less good than SimpleUDP, so I abandonedd it, just added it for anyone interested, for it really is a nice example of a 3d multiplayer over network:






2) SimpleUDP 3.1 Which I'm wrestling with now.


From analyzing the examples I know how to set it up so that the 1st player also becomes the host and every other player who joins will be a client, so that they can join and leave at will.

* However I want to make it so that in let's a say a LAN group of 5 players of which Player1 is the host, that when he decides to leave, the other 4 players can continue playing unnoticed by making Player2 the new host. Does any body know if this is possible at all?


I like to think this should be fairly easy, but due to lack of documentation, experience and knowledge I'm struggling to make it work.

Under the mainloop I've added the bit below ";End Session"
...
	WaitTimer(timer)
	
Until(KeyHit(1))

;End Session
; If player that is leaving is also HOST Then make next client host..

If clientCount > 0 Then 
	If UDP_SessionHostID = UDP_ClientID Then
		UDP_SessionChangeHost%( UDP_ClientID+1 )
		Text 0, 0, "changing host.. " 
		Delay 2000
		
	EndIf		
EndIf 

UDP_SessionDisconnect()
End 


Full code and adaption of "Sample #11 - Verbinden.bb" below:


If anybody knows the answer to this, I'dd be happy to hear it. Thanks.


RemiD(Posted 2015) [#2]

the other 4 players can continue playing unnoticed by making Player2 the new host. Does any body know if this is possible at all


I have never used any of these libs, but i suppose that the idea would be to keep a list of the "active' players (those who have sent a packet recently), and to choose which one will host the game.

But personally, i would separate the clients and the server so that the number of active players does not matter, the game is updated the same way on all computers, and the players can't cheat.


Rick Nasher(Posted 2015) [#3]
Indeed not many people came across these libraries/used them in this fashion I guess. Hmm, guess I'll need to dig deeper and experiment some more for documentation is sparse.


Rick Nasher(Posted 2015) [#4]
Hmm, stumbled upon another library: NetBlitz

Download here: http://dawp.tripod.com/netblitz.htm
Seems to work rather well, but appears only 2 player, or at least in the 3d example above. Nevertheless, a nice piece of code.


stayne(Posted 2015) [#5]
Going down the confusing rabbit hole of trying to decipher someone else's network code is a dark one. Gooooooooooood luck.


Rick Nasher(Posted 2015) [#6]
Hehehe, so true man. But.. Networking stuff is a pretty complex beast, I do not intend to re-invent the wheel, plus it's way beyond my current skillset, so I'm kinda depended on a library like this.
Also it gives good indication of what's possible and how by studying the examples.


vektorDex(Posted 2015) [#7]
You could also look into BPLite. I've been working off this for Sirius Online and it works marvellous. Can't find the thread here though. Afair it supports switching hosts on the fly, but I deleted that part as its unneeded ;)
The Demo of it is 2D, but its fairly easy to adapt it to support 3D in all kinds.


Rick Nasher(Posted 2015) [#8]
Thanks for the advice vektorDex, that sounds really promising. I'll look into it.
Do you know of an example of the host-switching-on-the-fly feature that I can study to know which commands to use in order to make it work?
Documentation of BPLite is fairly limited.


Rick Nasher(Posted 2015) [#9]
Or: does anyone have a more extensive documentation?


RustyKristi(Posted 2015) [#10]
Hey Rick,

I'm curious on how did you get the LamaNet example above running?

Using 1.6, I'm getting 'parameter must be positive value' error

When using 2.0, it runs but I don't see any servers on the list while I already started a server before in a new window.


Rick Nasher(Posted 2015) [#11]
Hi Rusty,

I remember at first I had some issues with it too, but can't really recall what exactly. I believe it had something to do with upgrading the 1.6 to 2.0.

For as far as I can remember all I did is:
1)copy the file LamaNet2.decls from the 2.0 into the Blitz decls folder, for me under windows10 x64 in: "C:\Program Files (x86)\Blitz3D\userlibs\"
2)copy LamaNet2.bb from the "LamaNet 2\include\" folder to the 1.6 include folder and reference to it in the code as such(see code below also):
Include "include\LamaNet2.bb" (Otherwise it will just take the old file in the same directory)
BTW: The slight name change "A" to "a" between 1.6's "LAmaNet.bb" and 2.0's "LamaNet2.bb" might be the cause. It's kinda easy to mis.

LAmaNet_Example09_3D-Environment.bb


That all works fine at my system.
(I must point out though that I'm using Blitz3d updated to Version 1.106 to maintain compatibility with Fastlibs FastExt.dll. Above this it kinda breaks compatibility with this great dll, which is fixable using some workaround Yue got from the author MichaelV, but as this is working fine for me sofar I haven't bothered yet).

Firewalls/antivirus packages can be blocking things though, which can be annoying at times. I'm using Comodo Firewall in combo with Avast which can play up at times.

Also there's a little bug in this example: All players start out transparent. Joined players should become opaque instead of transparant and assigned a random color, which sometimes fails. As you can see in the screenshot below(left screen is host/1st player, right player2 and midscreen player3 that both joined, all running on my system at once, but also the same via wifi on 2 other systems):

Right now the Host appears to be the only player who has all the cubes in colored opaque view(as should be to all). Also the colors are chosen randomly by the example program, which data in my opinion should have been transferred to all the players(just a matter of sending them the correct transparant/color values similar as x,y,z positions and playerID's), so that when player1 was assigned the color red it would always appear red to all players also, not another color to every player. But all this can be fixed imho using a different approach in the example code. This is pretty standard across all different network libs.

I have made a slightly modified version of the code below which contains a bit more English comments :-) and other things such as AppTitle so the player window is more easier to identify when running multiple instances on the same machine(which I btw can't do from IDEal, only the bog old standard Blitz3d IDE allows multiple executions apparently)

LAmaNet_Example09_3D-Environment2.bb


Hope this helps.

Also below the results of my Multiplayer Option Investigation sofar tested on home network(LAN/WLAN):

1) DirectPlay ; Tried 2d dots example, russian comments(unreadible).
Pros:
-Build into Blitz.
Cons:
-Undesirable as is using DXplay, which is being phased out by MS(and slow).
Conclussion: Too slow( lagging, more slow than BPLite and obsolete)


2) BPLite ; Mostly talked about on BlitzBasic.com, however more in depth info not avail.
Pros:
-Has some docs, simple commandset and fairly easy to understand.
-With Multiple players continues to work even when host left.
Testresults BPDEMO:
-When host leaves, players can still continue to play, however no new players can join(as there's no host)
-There appears to be a jurk in movement here and there(timing issues?)
-colors where not correctly displayed: random on every new window.
-Entering the computername instead of IP also works.
Cons:
-Appears fast at first, but noticed a lag in the 2d example.(too much).
-Lacks commands, can't switch hosts(well, according to someone it can and appears feasible after some studying).
-Was able to connect to other syst on LAN only by manually entering IP.
-For more than 2 players(host/client) had to manually enter another portnr also when trying the included examples.
Conclusion: Lagging, lacking more advanced commands so would need to build myself, which would probably require delving deep into UDP /networking tech.

3) SimpleUDP V2.0/3.0/3.01 ; German made solution, with lot's of commands.
Pros:
-Has a very extensive commandset.
Cons:
-Requires running a precompiled MasterServer for it to work over internet?(not for older versions I believe).
-Not free for commercial usage.
-No docs, only couple of examples. No 3d example to test performance immediately.
Conclusion: Need to recheck with older version and a 3d converted example.


4) LAmaNet V1.6/2.0 ; 3d car like example is pretty smooth(server is also player). Appears most suitable for LAN party. Have to check transparancy/color bug and Pong example in docs:
on WLAN worked fine, not when ran on another system that was on LAN(can't connect) but this has an additional router in between so could be explained.
Pros:
-Very quick, didn't notice any lag. Nice command set.
Cons:
-Appears to not always being able to find the server automatically, unclear why, possibly firewall issues for at moment no longer failing.
-Lacking more detailed docs and is in German(version 3.0 was never finished by the author due to other work he was doing, so docs are bit limited).
-Not sure how to switch Host/servers when the host leaves(yet).
Conclusion: Appears for now this is the most suitable candidate.

TODO:
1) check if can connect to another system OK over the LAN/internet using an manually provided IP/Port and what's required for that.
2) Try Pong example(from the manual pdf, appears bit outdated when compared to newer 3d example though).
3) See if can switch hosts(should be possible according to creator and a German user I briefly had contact with).

Grtz,

Rick


RustyKristi(Posted 2015) [#12]
Thanks Rick! will try this out and let you know my results asap :-)


RustyKristi(Posted 2015) [#13]
I'm still getting the same results, I already followed your instructions and copied the last code set above with the translation. Here's the client screen without any listed servers.. :/





Server part:




RustyKristi(Posted 2015) [#14]
I'm using a router btw and running both on the same computer, do you think this has something to do with the problem?

Using 1.106 as well for future use with Fastext :-)


RustyKristi(Posted 2015) [#15]
Having read this post that you guys have discussed, I'm assuming that it does not work with Internet (WAN)?

http://www.blitzforum.de/forum/viewtopic.php?t=40330&highlight=lamanet


Hello, I had a lot of contact with chrise. Just now there were many problems with the master and client. In the lan everything still works great but once it went into the WAN (Internet) there were several errors.




Rick Nasher(Posted 2015) [#16]
Ah, missed that reply, was about the time I got my burnout.

Hmm, that gives a lot of stuff to think about. Debugging this would be a pain. However it does work on my WLAN. Perhaps your firewall(s) do not allow it? Did you try creating an executable, run that as admin on your LAN without firewalls((disconnected the internet cable first)?

When I run it I'm getting messages from Avast(deepscan), Comodo(allow access? x3) and oddly enough the Windows 10 firewall too, which should be off as I already have Comodo on(weird behavier).

Also did some little experiments(which do not make a lot of sense) with this one:
LAmaNet_Example09_3D-Environment3.bb

Was also thinking about reworking the 3d-example to SimpleUDP(which apparently is stable) to see how it would perform, but docs were sparse on that one and I just love the Blitz-like simplicity of the LamaNet commands.

Can't believe there's not a complete, stable and perfect library around. That really does suck imho. Multiplayer is a must in this day and age.


RustyKristi(Posted 2015) [#17]
I definitely agree and thanks for the info Rick. In that case, I'm now considering to moving to another library although not sure what else is out there or might check other options above that you have listed.


Rick Nasher(Posted 2015) [#18]
Well guess there's not that much else. Before people were using the in-build DirectPlay routines of Blitz3d, see commands below:
StartNetGame
HostNetGame
JoinNetGame
StopNetGame
CreateNetPlayer
DeleteNetPlayer
NetPlayerName
NetPlayerLocal
RecvNetMsg
NetMsgType
NetMsgFrom
NetMsgTo
NetMsgData
SendNetMsg

This in combination with a Host server on this site and/or using GNET I believe.

DirectPlay however is obsolete as MS is phasing it out as part of the DirectX package. So I've come to understand everyone now is using UDP, but as this is meticulous to handle every one appears to have jumped onto/talking mostly about BlitzPlay Lite/Pro on the forums. This is also no longer supported by the creator. The BPLite version appeared slow & lagging in my tests, has a limited command set(or at least poorly documented) and apparently doesn't have the ability to sync, which makes it rather useless for realtime games?. So nogo for me I guess.

Sofar I haven't seen anything else that was good enough/similar to the inbuilt commands, besides LamaNet and SimpleUDP 3.1(but the latter is not free for commercial applications). We could of course be bold and create our own looking at structures of both libraries and combine these into something new, however this will take ages and requires more in depth knowledge of the inner workings(I probably lack the skill too).

So I'm getting a bit discouraged here and starting to wonder if really possible to build good multiplayer games in Blitz3d(at the moment), which is a requirement for what I have in mind. If not, I'll may have to abandon ship here(which I would really hate for I can basically build round all other restrictions). :-(


If anybody has some better views on this I'd be happy to hear it, but I fear for the worst..


RustyKristi(Posted 2015) [#19]
DirectPlay is nice when it is still being used and happening but yes it seems as much as it is technically possible, but the phasing out thing is really not something you can hope and seriously invest in.

What got me weirded out is the divide and many variations of blitz3d networking method over the years and not one stands out to be a"Go-To" solution unlike other libs out there paid or free. I guess multiplayer was not that demanding during those times?


Rick Nasher(Posted 2015) [#20]
Indeed. However I haven't given up on it just yet.

SimpleUDP of which I have a nice piece of version 2.0 techdemo example code, shows some potential. I was able to have it working flawless on 2 laptops; 1 host, 1 client, both connected via a wifi router(WLAN) that also has a wired router(LAN) connected to it, which in turn connects to a desktop PC that also worked fine as a client when I manually entered the IP of the host laptop that is residing on the WLAN. This should do fine for a Quake3 like experience.

However, it didn't work the other round: making the desktop on the LAN acting as host, for then it wasn't found. Now I must say I'm using some odd IP's on the LAN just for making a break in a little less easy and also have different firewall brands on the LAN/WLAN so that could be a reason for it to be working as a client only.

I'll still have to test this with the improved 3.0 version(has some holepunching ability bug fixes) don't know for sure, but I believe 3.01 by default requires a MasterServer contrary to previous versions, but I'll have to double check(could be misconception).


Rick Nasher(Posted 2015) [#21]
Couldn't resist checking out the LamaNet 4-Player Pong Example in the manual and added a bit to it. It's quite simple, but nevertheless interesting.



So for people who are interested and do not like to type here's the code with English comments.


Media:
Title
Logo
LamaNet media PNG's are opyright by Chrise and derived from the PDF manual that comes with it, but free to use and distribute with it I guess.


RustyKristi(Posted 2015) [#22]
Interesting demo Rick, too bad I've given up on Lama. It should work right out of the box like other demos out there. :/


Rick Nasher(Posted 2015) [#23]
True Rusty. Still was fun to toy with. A little while ago I've seen you checking at the Max threads to see what they're using. Did that give you anything interesting?
I did a quick search and found a few things for BMX:

TNet http://www.truplo.com/TNet/versions.html
ENet wrapper for guaranteed UDP works very well. ENet comes with Blitzmax (at least that's what was mentioned somewhere).
BNET http://www.eiksoft.com/multi/multi.htm


Rick Nasher(Posted 2015) [#24]
Really wondering if there's actually something like this full fledged out there working flawless for Blitz3D.. Please correct me if not.


RustyKristi(Posted 2015) [#25]
ENet looks great and the commandset is almost ready for actual usage, too bad the examples are limited to chat and hi and hello stuff. It looks like it needs some work from data packing and message handling.

I'm curious with TNet as it says it's complete but it looks like it's not completely free to use. I'm not into BMax yet but do you think this can be easily to port to B3D with userlibs, etc?


Rick Nasher(Posted 2015) [#26]
I've been wondering that myself, but I fear it's too easy for it's a bit of another beast. Other way round is probably more do-able, seen people using DLL's and put them to use in BMax, but the format of TNet downloaded isn't a DLL, but in Max's module fashion. Perhaps from BMax it's possible to generate a DLL in turn and then it's 'simply' a matter of creating a decls file. All with big perhapses and maybe's..

Any BMXers with experience in the field probably won't read this thread, so perhaps a question in one of their threads?

Meanwhile, I keep on digging to see if I can get something useable working.
Currently back at checking BPLite, to see if can work around timing/lagging issues I experienced with a 2d example.


Guy Fawkes(Posted 2015) [#27]
yea no. SCREW ALL those suggestions no offense. Use NetBlitz 1.3! :D

http://dawp.tripod.com/netblitz.htm

ENJOY! :)

~GF


Rick Nasher(Posted 2015) [#28]
Hi Guy Fawkes:

Indeed I've considered that one too(see post #4).

However I was under the impression it's only working well with 2 players.
Can you confirm or supply an example showing it works with more than 2? (that would be great actually..)


Rick Nasher(Posted 2015) [#29]
OK GF, I did some new tests on that NetBlitz 1.3 lib. Actually it *does* work with multiple players, which appeared to fail before, but I didn't test well enough. Interesting results:

1. Host(Player1) started on laptop1, over wireless network as 'non local'.
2. Player2 connects/joins over 'non local' network from laptop2, (actually on same wireless network) specifying IP# and port#.
3. Player3 connects/joins same way over 'non local' network from Deskttop PC#1, on LAN connected to my LAN Router1, which in turn is connected to LAN/WLAN Router2 (which is als my connection to internet).

So I guess local for this one means really local 127.0.0.1 loopback address or so, so on same machine? Or perhaps it's because of the firewalls..
All systems are equipped with different firewalls so I guess that's hindering connection, but not making it impossible (have to permit when asked by firewalls of course).


Thanks for pointing me into this direction. I thought it was an ancient, old and superseded lib.

I'll now need see:
1) How can make one of the players act as the new host when the player that is the original host, decides to leave the game, for I've noticed that then not all players get updated anymore. I'll check the online commands list for that to see what can be achieved.

2) Check if it works over internet(WAN) too, so basically if any IP can be used. I suspect it does, just need to test.


Again, thanks.


Guy Fawkes(Posted 2015) [#30]
Any Luck, Rick? If so, I'd like to see your examples.

~GF


Rick Nasher(Posted 2015) [#31]
Not yet, x-mas shopping and unfortunately I have to dose my computer time for I'm suffering from a burnout, on top of my visual issues(eyestrain when watching LED/LCD's for a prolonged period of time).

But I'm hopeful, after the previous tests.


funkmaster5000(Posted 2015) [#32]
Actually, I'd like to point out this thread. It is working great, except the issue I am having with the player ID atm.


Rick Nasher(Posted 2015) [#33]
No clue on that, currently still checking out NetBlitz1.3, but very limited time.


Flanker(Posted 2015) [#34]
If your goal is to switch the host on the fly, I see two solutions :

1) One player is the server and sends informations about players (IP, port, ID) to other players. If the server leaves, all players wait for a timeout, then the lowest ID player starts a server and other try to connect. If it fails, after a timeout, the second lowest ID player tries too and so on. Not easy but not impossible. But it will be noticeable for everyone.

2) All players are server and clients. Any of them can accept an incoming player to gather informations about all other players to "connect" to the network. Then, each player sends and receives informations with all of the other players. This could work for a low players count even if it's not efficient, any deconection would be unoticeable and you wouldn't even have to worry about that.

It could be a great challenge, I'll see if I have some time to try something about this. A while back I wrote a very simple server/client test with Blitz3D, with both UDP and TCP, it worked quite well tested with two friends.


Rick Nasher(Posted 2015) [#35]
@Flanker:
Thanks, yeah indeed above 2 options came to mind. With option 1(switching hosts) being the easiest(but unpretty) solution I think due to the mentioned pause. And option 2(all players are both server and clients) probably being the most preferable, slick, but perhaps more complex option?

I'm thinking about a limited number of players, tops 5 or so if feasible(I'd settle for less if required) LAN/WAN party death match kinda game.
However even though I've got most of the single player game aspects covered and running pretty good, implementing the network side of this in the above mentioned fashion is a bit more of an headache to me so far.

The NetBlitz lib 3D example code was easy enough to incorporate into my code, but it just can't be that when the host player leaves, the game ends for all players, hence the need for a solution to this. Dunno if the 2nd option is even at all possible using NetBlitz or any other existing lib.

Anyway, if you'd have a working example I'd be very grateful(for I'm ready to pull my hair out ;-)


Flanker(Posted 2015) [#36]
The option 2 can be easy for some kind of game. For example a "free for all" FPS where each player would just send his position/rotation/inputs to all other player, and eventually something like "Player 12 killed me". In this example you don't need a main player to act as a server. But another example would be a soccer game. In this case you need a player to act as a server to handle the ball and goals.

The option 1 is preferable I think, even if switching hosts is noticeable. I'll have a look at NetBlitz.


Rick Nasher(Posted 2015) [#37]
That would be great. You might be right that option 1(host switching) is preferable as it's less wasteful and I've got some moving platforms, doors, particle stuff and other events that need to be controlled also. All these things perhaps may generate too much network traffic to make it run smoothly if all players would have to send and synch that info.

A brief pause to switch hosts might be acceptable, if it's done notification style wise. As like: "NOTE: Player A(the host), has left the game. Player B is now the new host. Continue in 3 secs. 3..2..1".


Flanker(Posted 2015) [#38]
I've takeen a look at NetBlitz. In the examples it acts like the "option 2" we discussed earlier, each players sends directly to each other player so when the first player leaves the other can still play, but noone can join. The code is messy and doesn't work well, and it would be simpler to rewrite a library than modifying this...


Rick Nasher(Posted 2015) [#39]
Hmm, thanks for looking into it, but that's a real pity. For I can get round using a library, but further more my UDP coding skills are pretty limited.

Almost can't believe there's no one who wrote a decent lib to replace Blitz's DirectPlay routines. To summarize, so far I've looked at:

1) LlamaNet 1.06 - unfinished, buggy.
2) SimpleUDP 3.1 - not free, requires a masterserver.
3) BlitzPlay Lite - lacking features to synch, causing lag.
4) NetBlitz 1.3 - works on my network, but not as described by the author(only the 3D example works fine, when taking into account certain steps, see post #29).

So I guess it's a nogo then.. :-(


Flanker(Posted 2015) [#40]
The hardest part of a network library I guess is to make it easy to include in any project. If you find that DirectPlay commands are ok I can try to write a blitz DirectPlay-like with blitz UDP commands, and host switching. The only thing I don't guarantee is packet reliability, even if it is possible, it will probably be a pain.

The network routine test I wrote several years ago used both UDP and TCP, UDP for fast but non crucial data and TCP for important data like chat messages, new player connected etc... But today after some tests, TCP works well on the local network but not over internet. Do you have the same thing ?

UDP works well, so I guess it would be 100% UDP, wich is easier for host switching.


Rick Nasher(Posted 2015) [#41]
Hmm, so far haven't tried NetBlitz over the internet, only noticed it passed different firewalls and routers on LAN/WLAN and timing in the 3d example worked fine, this unlike the other libraries I tried(they all failed). It should in theory work fine over the internet. I'll try from a remote machine and let you know. Perhaps some of the routines he used are useable, dunno if he's using hole-punching techniques?

BTW: Got a reply from the author of NetBlitz 1.3(had dropped him a line couple of days ago), quoting part the message below:

Thank you for your regards. As you may have guessed, NetBlitz is not supported anymore. It has been a while since I have worked with the library. However, there are a few solutions to your problem. Essentially, you want your program to have 'Host Migration' in that when the host leaves the program, it finds another host. Some computer programs and games avoid this altogether by booting all the players off the game when the host leaves. Another solution involves having a non-player host that monitors all the connections and players that would be controlled by your systems.

NetBlitz unfortunately does not have host migration as you already noticed, however I looked at the internal code and found a few hacks that would give it this feature that you are requesting.
1) NetBlitz internally uses globals serverip and serverport to identify which ip belongs to the host. Every user when logged on stores this ip and port obtained from the host. The default port is 80 and NetBlitz expects the host person to have port 80 setup as the UDP stream.

2) I suggest that when the host logs off, you should send a message to all of the other players telling them that the host has logged off. You can use your own custom message type. In addition, the current host should find a new host and send the details of the new host to all the remaining players before leaving the game.

3) When the remaining players receive this message (Let's call it host change message), they all change their respective serverip to the new host ip. This new host would also need to close the current udp stream and re-open it at port 80 if it wasn't already at port 80. In addition, make sure to update the nbplayer type field of host to the correct host.

I hope the above information gives you guidance and good luck with your project!

This is sort what I was thinking about already, execution is another matter of course. Not impossible, however after your check on the code I'm a bit weary if worth the try.


Flanker(Posted 2015) [#42]
Yes that would be the solution, when the server quits, it should sends a "switch host" packet with ip and port of the new host to everyone.

IMO it doesn't worth trying to modify NetBlitz. I won't, I prefer to write a fresh library, as stayne said :p
Going down the confusing rabbit hole of trying to decipher someone else's network code is a dark one. Gooooooooooood luck.



Rick Nasher(Posted 2015) [#43]
If you can write such a fresh library, I'd for starters would be very grateful and I'm pretty sure a lot more Blitzers would, for this is now a very missed out, but essential feature. However it's perhaps a bit much to ask.
I personally don't think I'm skilled enough in this area, would probably set me back a year and a half or so to do it right(if ever).


Flanker(Posted 2015) [#44]
Hi, I've a working UDP example of host switching on the fly. It works quite well, barely unnoticeable. Some polishing and I'll post it in the code archives.



The drawback for the moment is I can't get it working over my NAT, it's only local, even NetBlitz don't work anymore through it (with same parameters), it seems random to me...


Guy Fawkes(Posted 2015) [#45]
@Flanker :: Can you do a 3D version?

Ty! :)

~GF


Flanker(Posted 2015) [#46]
It would need some smooth position interpolation but here is a 3d example i'm testing.




Rick Nasher(Posted 2015) [#47]
Wauw-oh-wauw-oh-wauw! (need I say more?) This is looking like it's going to be a very merry X-mas. Thanks so far Santa(Flanker), this is really cool! Merry X-mass and enjoy,


Rick Nasher(Posted 2015) [#48]
[double entry]


Guy Fawkes(Posted 2015) [#49]
I agree! :) Can you release the 3D demo when it's done? (When WILL it be done anyway) ?


Rick Nasher(Posted 2015) [#50]
Not so impatient GF. ;-) It's the holidays, people interacting with other (real life) people, eating, getting boozed up etc. I myself just enjoyed a good glass of wine, which is *not* a good combo for coding and that's probably not at all that different for a whole lot of people round the world, hehehe. I like you am hoping Flanker will be 'the one' (Matrix-ref-style lol) that will free us and allow us to reach Zion, the multiplayer game coding walhala. (see the booze already kicking in?). Now I only have to decide if next I wanna take the red or the blue pill, uh red or white wine.. The red probably takes me out of this world as it contains more alcohol. ;-D


Flanker(Posted 2015) [#51]
I'll post the first version of the library tomorrow. Everything works fine, but there's a lot of latency when running 6 players on the same computer so tonight I'll try to connect from other computers on my network to see what happens.


Guy Fawkes(Posted 2015) [#52]
HA! @Rick Nasher! Are you Rick Smashered? :D XD

Sounds good, Flanker! Thanks alot! :)


Rick Nasher(Posted 2015) [#53]
@ Flanker:
Cool. You are gathering some interest here as you can see. I think that latency is actually quite common when running multiple clients on the same computer. At least it's what I experienced before too.
Apparently it's less on a LAN/WLAN. Perhaps cos everything has to be addressed by the same NIC. Looking forward to try it.

@GF:
Well, no I kinda left the red pill/wine and went for a Coca-Cola, as my girlfriend already fell a sleep on the couch and I'm watching "The Shining" on TV. Amazed by the haunting atmosphere, straight from the start of the movie.


Guy Fawkes(Posted 2015) [#54]
Haha, nice @RickNasher!

AWESOME, @Flanker! Can't wait to try it! :)

~GF


Flanker(Posted 2015) [#55]
Tested with 15 players, 9 on one computer, 6 on another, worked pretty well, the host switching works perfectly and the latency comes from a brute "full update" done by the server every X seconds in the 3D example. It's not directly linked with the library but with a "crappy" example ^^



I'll post it in the code archives now, as I'd like others to test it and tell if it works fine. A lot more things could be added but for the first version it will be fine like that.


Flanker(Posted 2015) [#56]
I've created a worklog for it as it may change : http://www.blitzbasic.com/logs/userlog.php?log=1916&user=15074

Hope it works for you guys, and tell me if you need help with it.


Guy Fawkes(Posted 2015) [#57]
O it's changed alright! I've fixed QUITE a few things in here INCLUDING the terrible collision. You now have MULTIPLE collision types affecting what the players can & cannot hit. Or can slide off of / on & / or NOT slide off of / on.

I DID notice TWO glitches I cannot fix. 1) (The most important) :: The camera thinks that every new player that comes in if the camera is up close & personal on the other player, it automatically assumes that it should be looking through THAT player's eyes which is a real pain in the ass. The 2nd thing I noticed is that players spawn in the exact same area instead of WITHIN the exact same area. Which is a real pain because after so many players, that starts to cause lag for the other players.

Other than that, this is starting to become something BEAUTIFUL! =D

I now share my code with the rest of you as KNOWLEDGE IS FREEDOM! :)

3DFix.bb ::



Enjoy, and I hope you can fix at LEAST the MAIN issue with the camera! :)

Sincerely,

~GF


Flanker(Posted 2015) [#58]
I don't really understand the problems you mentioned.

The example already has 2 collision type, "1" for the scene and "2" for the players. Players to Scene is ellipsoid to polygon with prevent to slide on slopes. Players to players is ellipsoid to ellipsoid with full slide. It didn't work well for you ?

The camera always follow the local player, it can never switch to another one unless you modified it ^^

And for the spawn yes everyone spawn at the same location, it's in the CreatePlayer() function :

	p\x = -20
	p\y = 1
	p\z = -20
	p\yaw = -45


You can change that and the server player will have to send it to everyone.

The example is just an example, the library just handles connections, proper messages routing and host switching. All the rest is up to you.


Rick Nasher(Posted 2015) [#59]
@GF: I haven't run into what you mentioned(or not noticed). And don't forget this is example code only, the main thing is that the UDP multiplayer networking host switching thing should work(for me then).
Cams and all that are things like that should be easily fixable, if needed that is(not yet for me).

@Flanker: Just did a quick first test running the 3dexample.bb, on local machine, 1 server/player, with 2 joined players: Success!!! Runs like a charm. Thank you very much for this so far.


What I did was:
1. start server at 127.0.0.1, port 80. When started moved player around from origin.
2. joined player at port 1 and moved round; no issues with cam found.
3. added another player and mover round; all the same to me, all fine so far.

Next I tested adding a player on the LAN(on different router) to see if caught on: OK, after the required firewall allow messages(time out was bit quick I must say, had to do several start attempts as firewall kicked in/obstructed and before I could allow it through it already said that couldn't start game).
As server port I used 80, as client port 81.

Next to test is:
- The 2d example(went for the greatest pleasure, 3d, first ;-)
- Adding another player on 2nd laptop connected to the WLAN(wifi).
- Adding a player on a remote PC over WAN(internet) and see how goes.
- Try host switching.

Again, thanks very much for your effort so far.


Flanker512(Posted 2015) [#60]
@Guy Fawkes : I guess the problem you mentioned with the camera is when another player comes between the camera and the player, so it can be fixed by removing "EntityPickMode p\mesh,1" in the CreatePlayer() function.

@Rick Nasher : you're welcome, it's nice to hear it works quite well for you two. For the moment, the host switching works only if the server quits properly as I didn't implement a constant ping-pong to check if server didn't crash, this will be in v1.1 probably.

Also, in the examples, It reads only one message per frame, after some testing it's better to read all available messages (for a lot of players connected we would read only X messages), so you can change it with something like "While Net_CheckMessage()... Wend". But don't forget to send a message only when it is necessary.

I've tested an example based on this article : https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
It works quite well, but still have some work on it.


RemiD(Posted 2015) [#61]

I've fixed QUITE a few things in here



and I hope you can fix at LEAST the MAIN issue


Déjà vu...


Rick Nasher(Posted 2015) [#62]
@RemiD: pls no.. not that road again. It's thread pollution and not making things better. :-)

@Flanker:
Test#2.
- Adding another player on 2nd laptop connected to the WLAN(wifi): works same as on LAN, test passed. (But same issues with connecting; times out too quickly, so need to restart the application several times, otherwise not enough time to allow through to firewall. But I found the:
"Global net_timeOut = 5000" so that can be changed easily(will test).
- Host switching appears to go pretty smooth indeed, at least the local network. Some data display is needed for new player to join so can see who's avail as server(will test). And indeed ping is needed for determining who's is the best candidate for being the new server(not implemented yet I believe to have seen, but I glanced only briefly, family weekend, otherwise I get punished :-).


To test still(tomorrow):
- The 2d example.
- Adding a player on a remote PC over WAN(internet) and see how goes.


RemiD(Posted 2015) [#63]

It's thread pollution and not making things better


but GF posts are useful and making things better...

@Flanker>>Good work, sorry for the useless comments


Flanker(Posted 2015) [#64]
@Rick Nasher : yes net_timeOut is the time in milliseconds a client will wait for an answer from the server when connecting. The ping-pong will be there only to check if a player or the server is still up. The best candidate for being the new host must be the most ancient player, or the most recent so everybody will know where to connect if the server crashes, it has to be a rule I think.

@RemiD : thanks, did you try the library ?


RemiD(Posted 2015) [#65]
@Flanker>>
No, i have just taken a look at the code and created a server just to see what you have made. The code seems structured and clear. Not sure if it is reliable. Rick will probably help you to test, he seems to be into multiplayer games on a network these days...


@Rick>>Not sure if you are aware of this or not, but there was a discussion on the forum some time ago where the idea was to use a php page to read/write txt files on a web space in order to know if there are players online, if there are existing game servers online, what are the ip addresses of the game servers online and of the players of each game server so that you don't have to type the ip address and the port number manually. Do a search you will probably find it.


Rick Nasher(Posted 2015) [#66]
@Flanker: Sorry haven't been able to test over the internet last night due to other obligations demanding my attention and became too late to take over the other system as the person is asleep now. Wasn't exactly what I had in mind for tonight, would much rather have tested out this stuff as I'm burning up with curiosity to see if works alright.

Regarding the switching rules: You might be right; I was thinking only in terms of the player with the lowest ping value, should become the new server as it's the fastest connection, but this may not always be the best choice perhaps.

I'll keep you posted on my testing progress. Tomorrow night nothing should come in between. Btw: I agree with RemiD; the code is looking really nice and clean I must say. -No spaghetti whatsoever.

P.S. Tested the 2D example, which of course also works very well and is a little more verbal. Very nice as it shows what can be done, with chat and reporting events onscreen.



@RemiD: certain things are better left as is, can't change what you can't change if you know what I mean.. ;-)

And sure, the PHP approach is way of doing it, but I'm not in a need for that just yet(first things first), but indeed would be nice to have as an option, especially when playing over the internet.

For a LAN-party it's less necessary I think, for should be possible to scan the network for special packages or pressent & exchange a list of all servers/clients available between the players on the LAN. Also if all comes down to it(if all else fails), in a LAN-party people can just manually exchange the IP's & ports, but of course automated is much more player friendly and more neat, so I'd try to establish something like that also.

And indeed multiplayer is what I'm after(shouldn't every modern game??), but is not a new thing, was the end goal all along and I'm trying to incorporate this feature in my existing game. It should have some AI players also of course, but I don't foresee issues with that. Have that working partially already and will extend/build on this.


RemiD(Posted 2015) [#67]
The approach to read/write .txt files on a predefined web space is to facilitate the process to know what are the available game servers and available players. (and also not have to manually type the ip address and port number)

But you could use the same approach in a local network by reading/writing .txt files on a predefined computer (with a fixed ip address) and make each client machine scan these .txt files to know which game servers / players are available in the local network.
Of course this requires one more computer. But the advantage is that it will prevent cheating if all the important calculations are done on this separate computer.


Rick Nasher(Posted 2015) [#68]
@RemiD: Sounds like a good approach indeed. I basically want to offer 4 game modes:

1) Single player with AI bots.
2) Multiplayer LAN party(with bots when no other players are available). No central server required, just host switching to keep it flexible and simple to run. A list of servers/players on the LAN could be presented using broadcasting on the LAN.
3) Multiplayer over the internet(WAN) in the same way.

4) In above multiplayer modes people need to know each other in order to provide IP & ports, but if the game is more successful and more people want to play, I would need to provide a way to get that data across, so that complete strangers can join. Perhaps by what you describe. As in that case I would probably need to run/hire a server, then I could also setup a central server to run(part of) the game world. And in such a scenario a second server as backup to switch to if #1 crashes is not a bad idea too.


Rick Nasher(Posted 2015) [#69]
@Flanker:
Update, tested:
- Adding a player on a remote PC over WAN(internet):

1. Raised IP timeout to 50000 to give more time to connect.
2. Used http://www.whatsmyip.org/ to find out my own and my friends 'real world' IP's.
3. Created server on my system using WAN IP 87.210.xx.xxx on port# 80.
4. Tried to join from my friend's PC to the server on my system, using port 81 for his PC, but couldn't join game.
5. Put Firewalls into gamemode to allow passing through: no change.
6. Tried other way round: server on his system, me trying to join: still no go.

Perhaps I have to manually open ports on the firewalls/routers(port forwarding?) to allow this to go through? However when tried on LAN it did work and firewall nicely asked permission, now nothing showed up. This could be because it has a different, more strict ruleset for connections to outside the LAN, but I doubt this a bit. Or need to raise timeout even more? Other possible cause could be I was using TeamViewer to control his PCand dunno which ports that is using or that causing more delay in making the connecting.

Any other ideas?


Guy Fawkes(Posted 2015) [#70]
Yes. I'm LOVING this network library! I was wondering if we could add a function that will automatically (and safely), allow the server host to AUTOMATICALLY be added to the firewall, as it's a pain in the ass everytime I keep trying to test it on different ports >.< As for the camera thing, I tested it, and I must say... WOW! THANK you for finding the fix! I appreciate it! :)

Sincerely,

~GF


Flanker(Posted 2015) [#71]
@Rick Nasher :
I have quite the same problem here, and the cause is the NAT/router. You will have to set your ports correctly in the router (port forwarding). Port 80 shouldn't be used I think, it's usually reserved for network things, you should use from 1024 to 65535.

The timeout shouldn't be an issue, maybe set it to 10000, but the connection should be instantaneous or so (depending on ping). For me it works one time, then I have to wait several minutes(it seems random...) to make another connection but my NAT is crappy, it's probably a security issue... You can test it on the same computer, entering your public IP for the server, it will go through the router and try to come back on the port of the server. I'll try others things and let you know.

Guy Fawkes : I'm afraid I don't know how to access to the rules of a firewall. But you can probably set the blitz3d application to be ignored by the firewall.


Guy Fawkes(Posted 2015) [#72]
Yea, Flanker's right guys. I tested up to 7+ simultaneous connections using my INTERNAL IP (or my IPV4 IP address) and it worked VERY smoothly. (Minus that damn camera glitch, lol )

~GF


Guy Fawkes(Posted 2015) [#73]
@Rick Nasher :: In your recent test, you mention NOWHERE about FIRST "Port Forwarding" your "server" on your "router" ;)


Guy Fawkes(Posted 2015) [#74]
Hope that helps, @Rick Nasher! :)

~GF


Rick Nasher(Posted 2015) [#75]
@Flanker:
Hmm, new stuff to try & check, nice.. :-)

- Before I used port 80 as was used by NetBlitz and some other libs. Normally 80 I believe is reserved for HTTP traffic, so thought would allow smooth access as it's open anyway, but not sure- ah well checked it: many people say it is, but just in case here's Wikipedia:List of TCP and UDP port numbers.
- I raised the timeout for the antivirus and firewalls I'm using (Avast, Comodo and ZoneAlarm) on different PC's usually take some time to kick in and present the allow/deny access requesters. So before I could answer 'Allow Access', the application would say something like: "Couldn't start game" and exit, resulting in several attempts to get one PC connected to another.

You can test it on the same computer, entering your public IP for the server, it will go through the router and try to come back on the port of the server.
- Will try the other range 1024 to 65535 and entering public IP for the server: Seems like a good idea to see if works. It was actually gonna be my next question, if there's a way to force the router to use a certain IP address over the internet instead it looks for it on the LAN. So I guess you answered my thought(who needs internet if there's ESP). ;-)
Then again.. long time since I dealt with this stuff, but isn't the router smart enough and has an IP look up table that will detect that the public IP is actually local, so it(the packet) never leaves the LAN and never reaches the next internet router that holds the complete table for this IP address, so translates directly into local IP's? See: look up tables and ARP(I need to dive into my books to know for sure).


@GF:
In your recent test, you mention NOWHERE about FIRST "Port Forwarding" your "server" on your "router" ;)
True, for I haven't actually tried that yet, for locally it worked fine over 2 connected local routers; I have two routers and both use a different IP range.
I use router#1 for internet(WAN)access, LAN and WLAN(wifi) and router#2 for I need some ports at my desk too, when checking/repairing systems and downloading stuff from the desktop PC.


Guy Fawkes(Posted 2015) [#76]
Yea, I noticed if "I" don't connect to MY External IP (WAN IP), it won't let ME through, but it lets everyone else through for port forwarding, so it's good. It should work! :)


Rick Nasher(Posted 2016) [#77]
Hmm..
Tested:
1. Created server on port range 1024 to 65535: 10xx
2. Tried to join using my public IP: 87.210.xx.xxx, serverport mentioned above, clientport 10xx+1.

After a minute or so got msg:

Error!
Failed to start game. [OK]

Then it exits.
When I use 127.0.0.1 it instantly connects, so I guess the router isn't able to check that this is actually the IP I'm using and so not replacing it with the local IP 127.0.0.1(as assumed). This could mean it's not that smart or that it can't communicate as the ports are closed.

>> In my next test I will delve into my router and open up some ports.
BTW: From the ports wiki I get that range 49152–65535 is non-registered, does this mean this is the preferred range to pick from with a new application such as our online gaming? Any ideas?


Guy Fawkes(Posted 2016) [#78]
as I said. YOU can't use YOUR WAN IP because YOU own it. Other players can, but you can't. How YOU connect is through YOUR INTERNAL IP (IE: 192.168.0.100).

~GF


Flanker(Posted 2016) [#79]
@Rick Nasher : you could use any port in fact, but it is assumed that from 1024 to 65535, ports won't be in conflict with the most common used ports. Companies can register ports but if you don't use their software you can use their ports, but not for commercial purpose I think.

@Guy Fawkes : you may be right now, but several years ago I was able to do so, using my own public IP with a server-client session in blitz3d through my internet box. Today through my router I can create a server, join it and receive packets from the server, but if I send something to the server the udp stream fails.


Flanker(Posted 2016) [#80]
Guy Fawkes is right about our own public IP. I tried to send a packet to my public IP through the NAT, and I received it, but the command UDPMsgIP() returns my own local IP, so the NAT detects his own IP and converts it to the local IP from where it comes from. So we can't test anymore with our own public IP.

Anyway, some better news, I've been able to test the 3D example over internet with my phone as a 3g modem, so it gives my other computer a unique public IP. It works well, except the high ping and the high packets loss, but I assume it's because of the crappy 3g connection.


Rick Nasher(Posted 2016) [#81]
Cool! Tonight I'll try with a remote PC to see if goes through after opening ports in the NAT.
[EDIT: well, tomorrow that will be then(couldn't reach the remote PC)]


Rick Nasher(Posted 2016) [#82]
Ok here goes.. Connecting to a remote PC over the internet after opening some ports on the router: It works perfectly!
Of course was some lag as I was using TeamViewer to control the remote PC and it's not a super fast internet connection, but still very do-able.

Thanks very much Flanker, you've done a great job! I owe you one big time. (well.. actually the whole Blitz3d/BlitzPlus community!) :-D

Next I'll do some performance/code tests and get back to this.


Guy Fawkes(Posted 2016) [#83]
It'd be beneficial to use interpolation on the packets to maintain a smooth & non-dropping packet stream, free of lag.

Alls I can do is give you guys ideas. :)

~GF

P.S. You're QUITE welcome, mr. Nasher! ^_^

~GF


Rick Nasher(Posted 2016) [#84]
Of course I thank you for your input too GF. ;-) I do value your thinking along and support in this.


Flanker(Posted 2016) [#85]
You're welcome Rick Nasher :)

@Guy Fawkes, the interpolation has to be done by the user, not the library as you can send whatever you want in the packets.

I'm writing an example with interpolation for the version 1.1 of the library.


Rick Nasher(Posted 2016) [#86]
Even more to come. Wauw, I'm very, very curious..


Guy Fawkes(Posted 2016) [#87]
O this is gonna RULE! How long before 1.1?! =D


RemiD(Posted 2016) [#88]

It'd be beneficial to use interpolation on the packets to maintain a smooth & non-dropping packet stream, free of lag


You seem to have no idea what you are talking about, it's funny to read :)


Rick Nasher(Posted 2016) [#89]
With interpolation is meant the difference between the current and the position moved to, or in some cases the guessed/estimated position, based upon previous input and speed, and then tweening the next frame to get smooth movement, right?


Guy Fawkes(Posted 2016) [#90]
Ignoring RemiD because he'd rather be a self-centered jack*** along with a few unnamed others in here which I am also ignoring, what I mean, Rick, is the interpolation between packets.


Flanker(Posted 2016) [#91]
Yes, basically it's a linear interpolation beetween previous position and next position. For the moment I use something like this :
rate# = (MilliSecs()-nextTime) / (nextTime-previousTime)
PositionEntity mesh,previousX+(nextX-previousX)*rate,previousY+(nextY-previousY)*rate,previousZ+(nextZ-previousZ)*rate

previousTime is the time (Millisecs()) when the previousX,Y,Z has arrived, same for nextTime, so it will interpolate on a delay of nextTime-previousTime, this works quite well for now and automatically does extrapolation in the case of packet loss.

This great article describes the techniques of the Source engine about networking : http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking


Guy Fawkes(Posted 2016) [#92]
Sweet!


Guy Fawkes(Posted 2016) [#93]
what would the value of "rate" be?


RemiD(Posted 2016) [#94]
If i were you i would not focus on interpolation for the moment. This is something which is an improvement of an already functional game. If you manage to have a good enough online multiplayers game at 20fps this would already be a great achievement. Then focus on improving the details...

Also if each client sends the orientation and actionstate of the player to the server and the server calculates the turns moves, detects the collisions, reorientes repositions, updates the action states, send back the results to the clients, and if at the same time each client does the same calculations but you give a priority to the datas sent by the server, then you won't need interpolation. The players will simply be reoriented repositionned sometimes but if the connection is good enough (low ping) this will probably not be noticeable...


Flanker(Posted 2016) [#95]
The "rate" is calculated each frame, I should call it "currentTime" instead. It tells you the time beetween previousTime and nextTime where your entity should be, so the interpolation is easy. This also means that you will always have a delay beetween a player true position, and the position where you draw it, but it can't be avoided.


Guy Fawkes(Posted 2016) [#96]
Remi, you've done nothing but try to batter ME AND this project. GTFO. I am NOT gonna let a GOOD project get screwed up or cancelled because you're an ignorant jerk. Now LEAVE. Or so help me I will make so many new threads about this project, you won't be able to stop us.


Flanker(Posted 2016) [#97]
@RemiD, the library is already steady, and the v1.1 update naturally needs an advanced example with interpolation and ticks, to really see if the library is reliable.

The major change in v1.1 is that the server won't automatically route messages to client like it does in v1.0 (it can still be done, just a boolean variable), so the server can receive inputs from players, and send back positions for example. That's why i'm writing an interpolation example with ticks to save bandwidth, and it works pretty well.

The other change will be the possibility to send packets instead of messages string, by writing to a bank, it will probably improve performances and simplicity to send complex packets.


Guy Fawkes(Posted 2016) [#98]
<3 I love you guys! :D


Rick Nasher(Posted 2016) [#99]
Sounds pretty good to me. Can't wait to see it in action.

BTW: did a small(quick & dirty) mod to the Server/Client selection. Saves typing the localhost IP & ports every time when testing out stuff.





funkmaster5000(Posted 2016) [#100]
First of all thanks for pointing out this thread, Rick Nasher.

I ran the 2D example on my webserver, without making ANY adjustments to/examining the code whatsoever and connected three clients. It ran pretty well considering, that the server itself is displaying the game state simultaneously (without having a fitting GPU etc.) so I will try to get a dedicated example (possible?) running over the weekend or so.

Keep up the good work and don't let your motivation get drained by some unthankful people. Thanks for sharing your fruits of labor with us!


Rick Nasher(Posted 2016) [#101]
Thanks and your welcome. True I'm on a 'relentless' ;-) hunt for a good UDP gaming solution for Blitz3d/Plus to replace the original routines for some time now, but you should be thanking Flanker as he the one that does all the hard UDP coding and I must say he's done a marvelous job sofar and he isn't even finished yet, but it's already pretty usable.
If I could, I would do it myself, but I lack the skill, even though I'm learning a lot from this these days. Flanker's code is written in a very clear & clean fashion, so that helps a lot to understand what's going on. I'm currently combining his 2d example code with the 3d example to show some more info on the screen and make use of the chat routines.


Guy Fawkes(Posted 2016) [#102]
OMG! We should totally make like a 3D hangout room! You know! Kinda' like Phantasy Star Online! Where we can talk all we want on Encrypted chat! :D


RemiD(Posted 2016) [#103]
My last post was a suggestion to not have to use interpolation, not a critic... Whatever !



Phantasy Star Online


I use to play this on dreamcast, simple but addicting gameplay. :)


Guy Fawkes(Posted 2016) [#104]
O god yes. I LOVE PSO.


Rick Nasher(Posted 2016) [#105]
Added chat from the 2Dexample to the 3D example(basically Flanker's 2 examples merged into 1). We can now chat and have bit more info on screen.

Also included the little mod to the UDP library mentioned above to make testing easier on the local computer(saves on typing info).

Hope you don't mind Flanker(it's not the prettiest of mods(yet). ;-)

Things on my to do list:
-Show list of available server(s) and port info.
-Set up selection: Local machine/LAN/WAN, so can partially pre-fill input's(same as for local machine mod).
-Create a GUI for above selections and input.
-Add jumping & shooting, etc.
-Add ThirdPerson/FirstPerson switching.
-Incorporate a ping check for checking if next player in line is capable of being the next server.
These I'm not sure of how to implement just yet:
-Interpolation.
-Dedicated server selection option.

"UDPNetwork_lib V1.001.bb"

"3Dexample with chat - V1.001.bb"

[EDIT: slight display correction copy/paste error]


Flanker(Posted 2016) [#106]
Nice one :)
I don't mind at all, it's written in the library : "Oh, and BTW, this library is licensed under the NoLicenseRequired agreement, meaning that you can do whatever you want with it..." ^^

You can't show the list of servers/port, this would need an external server to store each running server infos then each client would connect to that server.

The ping check will maybe be in the v1.1, to check for timeouts. For now if you close a client or server session with the window cross, the other player are not aware of the disconnection. It's an important thing to implement.

If you want to add interpolation you must send positions instead of inputs, and this should be done at a constant interval, for example 50 millisecs.

A dedicated server can be done, but you'll need to rewrite the whole example.

I'll work on the library this week end, maybe v1.1 soon with the interpolation example.


Guy Fawkes(Posted 2016) [#107]
HAHA! AWESOME, @Rick Nasher! <3 ONE STEP CLOSER TO A PSO-LIKE LOBBY! =D

I cannot WAIT!

AWESOME, @Flanker! Can't WAIT!


Guy Fawkes(Posted 2016) [#108]
Slight fix if you don't want to delete your username in the chat ::

Replace :

ElseIf key = 8 And Len(chatMessage) > 0 )


With :

ElseIf key = 8 And Len(chatMessage) > Len ( localName + "> " )



Guy Fawkes(Posted 2016) [#109]
Also found 2 other glitches. 1 ) Pressing enter the FIRST time should OPEN the chat without sending any text. 2 ) Pressing enter the second time should NOT result in sending an empty message, which it does. I don't have a workaround for any of these. Please help. Thank You!

~GF


Rick Nasher(Posted 2016) [#110]
@Flanker:

Thanks. :-)


You can't show the list of servers/port, this would need an external server to store each running server infos then each client would connect to that server.


I was thinking about storing the IP and server port in a type and sending a broadcast msg to show that a server is 'alive' and on which port, but this would probably only be viable on a (W)LAN if I'm correct.
For the internet a central place(site/server) would be needed to store/show which is available. Such as mentioned by RemiD in post#65

@Rick>>Not sure if you are aware of this or not, but there was a discussion on the forum some time ago where the idea was to use a php page to read/write txt files on a web space in order to know if there are players online, if there are existing game servers online, what are the ip addresses of the game servers online and of the players of each game server so that you don't have to type the ip address and the port number manually. Do a search you will probably find it.


And post #67:

The approach to read/write .txt files on a predefined web space is to facilitate the process to know what are the available game servers and available players. (and also not have to manually type the ip address and port number)

But you could use the same approach in a local network by reading/writing .txt files on a predefined computer (with a fixed ip address) and make each client machine scan these .txt files to know which game servers / players are available in the local network.
Of course this requires one more computer. But the advantage is that it will prevent cheating if all the important calculations are done on this separate computer.

Like Guy Fawkes said: Can't wait to see what rabbit you're gonna pull out of the magic hat in v1.1

@Guy Fawkes:
Thanks for the fix. Wasn't aware of the backspace-erasing-the-name issue.
For the Enter without input(if that's what you mean): I thought would be enough to check for 0 or "" input, but that apparently doesn't catch it right away. Strange. I'll check.


Rick Nasher(Posted 2016) [#111]
[Deleted double post]


Guy Fawkes(Posted 2016) [#112]
@Rick Nasher :: It's either returning NULL or an extra space that it shouldn't, because the cursor is way out there in Timbuktu & the text is all the way to the left of it.

Press enter WITHOUT any text should turn on & off the chat. (on meaning totally opaque, off meaning almost translucent ).

Also, PRESSING ANY key as opposed to HOLDING DOWN that key for a few seconds before it starts to add or delete each character of text is VERY slow & inefficient. The text should ALWAYS be on a small, 2-second timer. Without this timer, lag & all other sorts of DDOS tricks can be used. Hold down a key for 2 seconds and stop the cursor from being seen while doing so, then let the text continue to scroll to the right ( or in backspace' case, the "left" ), like any other textbox or input message box for ANY key. Also, use of the space key results in the ability to continuously post invisible "space" messages. Spaces should ONLY be sent inbetween characters IF a space is present BEFORE OR AFTER the character(s).

I do not point out these flaws to be mean, I point out these flaws in hopes of seeing it fixed.

Let me know when you have a fix for most if not all of this. Together, we are going to build the best damn online chatbox this forum has ever SEEN! I am SO excited! :)

~GF


Flanker(Posted 2016) [#113]
I have a working example of positions interpolation + jumping + fireing bullets + chat. It works even with v1.0 because I had some trouble to interpolate a player based on his inputs, so finally all players send their positions instead of inputs, that means that it is not cheat protected, but it shouldn't be an issue lol I don't see someone writing the next worldwide MMORPG with Blitz3D and this library ^^

The chat is "fixed" according to Guy Fawkes ideas, but you can still send multiple spaces as long as you have at least one character in the message.

The mod from Rick Nasher is added in v1.1 so we can save time when testing. Unfortunately it's not yet ready, i've been working on the example instead.

Still a little issue interpolating players yaw angle, because EntityYaw returns a value beetween +180 and -180, so when you go from 179 to -179, it makes a turn backward. I'll see that later. FIXED

Here it is the example "3Dexample_interpolation.bb", I hope it works well for you, it starts to be a huge example, maybe not easy to go in for others :

Fire with left mouse, jump with right mouse.

EDIT : you can change the variable Global updateTick = 50, just before the main loop. It represents the rate at wich a player send his position, so here every 50 milliseconds. You can set it to 1000 (1 second) for example to see the interpolation at work (but jumping is weird with a too high delay).

EDIT2 : it would be nice to test this example together over internet one day, if anyone is interested I could start a test server.


Guy Fawkes(Posted 2016) [#114]
DIBS FLANKER! :D

SETUP T3H SERV0RZ! :3

I will beta test ANYTHING you throw at me! :D

~GF


Flanker(Posted 2016) [#115]
join me at channel #UDPNetwork_lib here if you want : http://webchat.quakenet.org/


Flanker(Posted 2016) [#116]
Thanks for testing guys, I'll try to fix few things and we test that again.


RemiD(Posted 2016) [#117]
Here is another idea to manage an online multiplayer game :

Depending on input and its previousactionstate, each client determines the nowactionstate of the player.
Each client regularly sends a packet with its noworientation nowposition nowlife nowactionstate (before updating the logic) to the server.
Each client and the server use the same logic to update the game (depending on the noworientation nowposition nowlife nowactionstate, turn move the player/bullets, detect collisions/hits, reoriente reposition the player/bullets, update life, update actionstate)
Each client does not need to wait for a packet from the server to continue to update the game, it uses the previousorientation previousposition previouslife previousactionstate of each player (except the player of this computer) to continue to update the game until a new packet from the server is received.
The server does not need to wait for a packet from a client to continue to update the game, it uses the previousorientation previousposition previouslife previousactionstate of each player to continue to update the game.
When the server receives a packet from a client, it checks if the noworientation nowposition nowlife nowactionstate of the player seems possible ((near enough from oldposition, not too much life, alive/dead) with a tolerance), and if yes it continues to update the game with these infos, and if no it sends back an error message and a correction of the orientation position life actionstate to the client. The server also sends regularly the correctedorientation correctedposition correctedlife correctedactionstate of each player to each client.
When a client receives a packet from the server, it corrects the orientation position life actionstate of each player before continuing to update the game.
Since the server is tolerant about small differences, the corrections of orientation position life ationstate should not happen too often.
Since the clients do not need to wait for the server to update the game, the game can update at more than 10fps (around 50ms to send a packet from client to server and around 50ms to send a packet from server to client).
For bullets it would be better to use turningmoving ellipsoid colliders instead of linepicks because of the possibly corrected orientation/position/actionstate done by the server (not instantaneous like a linepick)

What do you think ?


Flanker(Posted 2016) [#118]
Kind of what I've been trying to do.

- each client were sending list of last inputs every 30ms to the server (local player was updated client side)
- the server were moving players according to received inputs, then he sends positions/rotation of each player to every player, every 50ms.
- beetween each update, clients used interpolation, and eventually extrapolation.

It works. The problem is server side. You receive inputs every 30ms. But I can't figure how to interpolate inputs. The players were "laggy" on the server, but client side they were smooth. That's why I did an example where clients send positions, as I think cheat protection is useless for our use. But it can probably be done, it's up to you to make an example ^^ the library (v1.1) will be able to work this way.

Another problem is how do you correct a player's position ? If you send him the position were it should be like in the first 3D example, it's really weird. If you use interpolation on it, the player will be forced to reach that location and won't be able to move until it's done. Weird too.

Packets loss seems quite important in UDP over internet, and correction are continous. For now, sending positions and use interpolation is the simplest way to ensure everyone see the same game.

The bullets already are colliding spheres, it's much faster than linepicks. Collisions are updated both server and client side, but only the server can decide if someone is hit/killed.

Also, Guy Fawkes is officially the first cheater on this library :D He replaced MouseHit fire by MouseDown, so he got a minigun instead of a pistol ^^ This didn't affect the multiplayer much as with Flip screen, a packet can only be sent every 17ms~.

Thanks for the suggestions.


RemiD(Posted 2016) [#119]

But I can't figure how to interpolate inputs.


With what i propose, you don't, if the server has not received a packet from a client, you simply use the previous orientation, position, life, action to update the new game.


how do you correct a player's position


The server knows the previousorientation, previousposition, previouslife, previousaction.
When a packet from a client is received, it can evaluates if the noworientation, nowposition, nowlife, nowaction, of this player is possible (approximately, with some tolerance) or if he is trying to cheat (teleport, move too fast, add too much life when there is no medpack nearby)
If the noworientation, nowposition, nowlife, nowaction, is within what is tolerated/possible, then no correction is done. If the noworientation, nowposition, nowlife, nowaction, is too different from what it is tolerated/possible, the server calculates what it should be and sends back the correctedorientation, correctedposition, correctedlife, correctedaction.
The client updates the game, for the player and for the new created bullets depending on the previousorientation, previousposition, previouslife, previousaction and depending on the player input, and for the others players and bullets depending on the datas which were last received from the server, but a priority is given to what is received from the server, so sometimes there can be some corrections of the players/bullets orientation/position/life/action.
However since there is some tolerance on the server, this should not be too often or too noticeable.
That's the idea.


Collisions are updated both server and client side, but only the server can decide if someone is hit/killed


With what i propose, the client could detects a collision/pick, but the server would evaluate if it is possible depending on what is known and depending on the tolerance.


Guy Fawkes is officially the first cheater on this library :D He replaced MouseHit fire by MouseDown, so he got a minigun instead of a pistol


:D


Guy Fawkes(Posted 2016) [#120]
TROLOLOLOLOL! =D


Rick Nasher(Posted 2016) [#121]
@Flanker:
I think some occasional lag and weird effects are virtually impossible to avoid over the internet. Kinda comes with the territory I guess? But as long as it doesn't interfere with the gameplay too much I think it's acceptable. What was a bit weird was the endless spinning mode I got into when I was accidentally clicking outside the window while moving with the cursors. Only seemed to recover when shot. :-)
I'll see what exactly was triggering it and if able to replicate. Was great fun never the less..

Also what's great about this lib is that this would also work under Ploppy's Harwired/Hybrid(Blitz3d/Plus V2.0) as it has the same foundations as original Blitz and he can then take out the fazed out DirectPlay code under Hybrid, ensuring this multiplayer will work under new Window/DirectX's versions until virtually the end of times.. ;-)


Another little mod to input a player name or just press enter and autoselect a randomized one.



Question:
Given the code below, shouldn't that normally stop the bullets from passing through buildings/scenery?
;; COLLISIONS
Collisions 2,1,2,3 ; player to scene
Collisions 2,2,1,3 ; player to player
	
Collisions 3,1,2,1 ; bullet to scene
Collisions 3,2,1,1 ; bullet to player

EDIT: I guess it does, did you correct anything for yesterday I was under the impression it could shoot through buildings.

P.S.: GF, where is your health upgrade code? I expected to see a PowerPill random distribution by now. ;-)


Flanker(Posted 2016) [#122]
@RemiD I see what you mean. Comparing a new incoming packet with the previous received one and check if it is possible with elapsed time and a tolerance. It's ok for correction/anti cheat.

But you would still need interpolation as the server won't receive a packet at each frame. For example, let's say a player goes forward, he sends "forward" every 50ms to the server. Let's say a packet was just sent at the previous frame. But this frame, the player decides to go backward. He will send "backward" only in 50ms as a packet has just been sent. During these 50ms, the server continued to move the player forward. So there will be a difference of 100ms beetween server and player position. In this case, interpolation will be needed server side or the players will always jump from one position to another, and that's the main problem of delayed packets.

@Rick Nasher yes, the first code I posted for collision was "Collisions 3,1,3,1 ; bullet to scene" and that didn't work well, I corrected it later with "Collisions 3,1,2,1 ; bullet to scene". For the endless spin we should have to known if the game is in focus or not, wich is impossible with native blitz3d, but possible with some libraries probably.


Guy Fawkes(Posted 2016) [#123]
Still working out a few minor bugs. Sorry for the delay, guys.

Just trying to get the item count so that the healthpacks only spin until there are no more healthpacks ><

And NO bullets don't go through walls or objects. I tested that last night.

~GF


Rick Nasher(Posted 2016) [#124]
Haven't been able to replicate on the local machine, will try on the LAN later.


stayne(Posted 2016) [#125]
I think the old BlitzPlay lib dealt with laggy players with spine interpolation.


Rick Nasher(Posted 2016) [#126]
Hehehe.

@ GF:
Perhaps this is suitable to represent a healthpack, or do you have something else in mind?

healthpowerup = CreateCylinder():EntityColor healthpowerup ,255,0,0	
healthpowerup1= CopyEntity (healthpowerup)
ScaleEntity healthpowerup ,.25,.5,.25:PositionEntity healthpowerup ,-30,.5,-20
ScaleEntity healthpowerup1,.25,.5,.25:PositionEntity healthpowerup1,-30,.5,-20
RotateEntity healthpowerup1,90,0,0
EntityParent healthpowerup1, healthpowerup

See I'm the one getting impatient now.. ;-)
BTW I've changed the bullet color to yellow for I think it looks more like fire:
EntityColor b\mesh,255,255,0



Rick Nasher(Posted 2016) [#127]
@stayne:
True, I read about that, but only was available in the BlitPlayPro(non-free) version fafaik.


Guy Fawkes(Posted 2016) [#128]
Mine's better, @Rick Nasher! :P It may use cubes for the items, but it totally detects WITH OR WITHOUT Collision if a player is either A) Within a VERY SHORT vicinity of, or if the Player actually DID detect a collision between the Player & the touched object accordingly, and adds a random value to your health, then deletes the touched Item. So I win! :D

~GF


RemiD(Posted 2016) [#129]

For example, let's say a player goes forward, he sends "forward" every 50ms to the server. Let's say a packet was just sent at the previous frame. But this frame, the player decides to go backward. He will send "backward" only in 50ms as a packet has just been sent. During these 50ms, the server continued to move the player forward. So there will be a difference of 100ms beetween server and player position.


Yes i understand that but there is no way to avoid it totally... A way to reduce this difference would be to lock the fps on the client computer. For example, let's say that a packet can travel at 50ms maximum, the sending from the client to the server + the checks on the server + the sending from the server to the client would be approximately 100ms. So around 10fps, so if you can lock the fps at 20fps or maybe 30fps on the client machine, this would reduce the difference between what is seen on the player machine and what is calculated on the server... And 20fps is more than enough to play an action game (if the movement are not too fast).

(the idea is not to wait for the server response to update the game on the client machine but rather to reduce the difference there can be so that it is not noticeable)


Guy Fawkes(Posted 2016) [#130]
I say screw it and make it 30 FPS so that we CAN make MMORPGs. No matter how small they may be.

Besides. We can easily switch this over to Ploppy's Hardwired Blitz3D and make it SHIT TONS faster, AND 64-bit as well! :D

BUT. I digress. We test it on old Blitz3D FIRST to ENSURE all the BAD bugs are beaten.

~GF


RemiD(Posted 2016) [#131]

I say screw it and make it 30 FPS


30fps would probably be ok for a gameplay where the movement are not too fast...


Flanker512(Posted 2016) [#132]
(the idea is not to wait for the server response to update the game on the client machine but rather to reduce the difference there can be so that it is not noticeable)


The last example already does that with interpolation. A player is updated client side, then he sends his position every 50ms to the server. The server just transmit the packet to other players. Interpolation is done beetween packets for other players. In the next library version the server can decide if the packets are auto transmitted to every clients (fast and simple), or not. So it will be possible to verify a position packet for example, and see if the player tried to cheat.

From the Source engine article above :
But instead of sending a new packet to the server for each user command, the client sends command packets at a certain rate of packets per second (usually 30).
...
By default, the client receives about 20 snapshot per second. If the objects (entities) in the world were only rendered at the positions received by the server, moving objects and animation would look choppy and jittery. Dropped packets would also cause noticeable glitches. The trick to solve this problem is to go back in time for rendering, so positions and animations can be continuously interpolated between two recently received snapshot.

But that's just the way i'm doing it because I trust Valve for multiplayer games ;)
You can make the library work as you want. The only thing I didn't implement in the example is the fixed interpolation time. So the interpolation is done on the elapsed time beetween two packets, but Source engine for example interpolates entities on a fixed 100ms time by default, maybe I should do that too.


Rick Nasher(Posted 2016) [#133]
Hehehe, lot's of activity in this thread all of a sudden.

I thought our spherical nosy players could do with a little more personality :-). How about a little angry bird style gfx?


If enjoyable just add to "Function CreatePlayer(id,name$)" underneath the nose bit.
	eyeLeft = CreateSphere(8,p\mesh):EntityColor eyeLeft,255,255,255
	PositionEntity eyeLeft ,.29,.4,.7;1
	ScaleEntity eyeLeft ,0.2,0.2,0.2
	
	pupilLeft = CreateSphere(8,p\mesh):EntityColor pupilLeft ,0,0,0
	PositionEntity pupilLeft ,.3,.52,.9;1
	ScaleEntity pupilLeft ,0.05,0.05,0.02
	
	eyeRight = CreateSphere(8,p\mesh):EntityColor eyeRight ,255,255,255
	PositionEntity eyeRight ,-.29,.4,.7;1
	ScaleEntity eyeRight ,0.2,0.2,0.2
		
	pupilRight = CreateSphere(8,p\mesh):EntityColor pupilRight ,0,0,0
	PositionEntity pupilRight ,-.3,.52,.9;1
	ScaleEntity pupilRight ,0.05,0.05,0.02

	unaBrow = CreateCone(8,1,p\mesh):EntityColor unaBrow ,0,0,0
	PositionEntity unaBrow ,0,.45,.7
	RotateEntity unaBrow ,-180,0,0
	ScaleEntity unaBrow ,.7,.2,.3


@GF: That's cool but show me the moneymaker as they say in the hood ;-)


Flanker(Posted 2016) [#134]
Just a little picture, the library now performs a constant background ping-pong server side :



The pings are quite weird as both server and clients examples are locked to 60fps with Flip.

I included your code in the example @Rick Nasher, that's funny ^^


stayne(Posted 2016) [#135]
why don't you replace the natives with free animated md2's or b3d's? If you want I will build you a lightmapped level with 3dws. no prob.

or just grab a level from http://lvlworld.com/. make sure you put textures and .bsp in the same folder.


Flanker(Posted 2016) [#136]
So far this is just an example for the library so it can be put in a codebox on the forum. But yes if you can build a more complex level I'll had it for sure, it will be better for testing.


stayne(Posted 2016) [#137]
ok i'll build you a level. you have the 3dws map code for importing entites? if not here it is. it's a coded example, I can explain how to strip out what you need if need be. Easy stuff. Entity placement is good for health, powerups, ammo, etc.




Flanker(Posted 2016) [#138]
Ok I see, it should be easy to implement as a separated file.


Guy Fawkes(Posted 2016) [#139]
Sorry about the late reply, guys. The parser on here is a bit of a pain.

Anyways, without further adieu, here's my medipack code so far ::

EDIT :: UGH... I'm just gonna post it on Pastebin.. SCREW the parser!

http://pastebin.com/vAaQbUDJ

~GF


Flanker(Posted 2016) [#140]
@Guy Fawkes
Your health code won't work in multiplayer. Only the local player will create health when you press spacebar, and only the local player will be able to pick it. Also, when the player picks health, only the local player knows it.

You need to use the network library with the SendMessage() command. You should try to write a very simple example for the library on your own to see how it works. SendMessage() is the only function needed to update the network once it is set, that's quite simple, but you have to use it wisely.

The v1.1 is near to be complete, major changes and new functionalities. I'll update the worklog and add a better documentation when everything is ready.


Guy Fawkes(Posted 2016) [#141]
Fixed! :D The only problem now is with respawning health packs on the fly with Ctrl+Space & being able to grab them. For some reason, the collision has a little bug in THAT part of the code.

Also, shooting has been changed to the "V" key so that Mousedown may be used for an Orbit Camera set of functions! =)

Other than that, we're all clear so far! :)

I also added Fog for a much more difficult challenge! :D

I also added the ability to turn on all Collisions at the same time, or turn separate ones on or off.

And the last thing I added was camera collision with type_scene.

ENJOY!

http://pastebin.com/nQuf6V83

~GF


Flanker(Posted 2016) [#142]
Not fixed yet ;)
When you create health you want to say it to other players. Also, in the UpdateItems() function, "Net_SendMessage(5,p\life,p\id,Net_MsgFrom)" means that you try to send a message to the last received message's player... and you can't use the sender data when you are a client, it's like stealing his identity and the server will just ignore your message.

Trust me, you should write a little network example, a pong with 2 players for example, and everything will be clear after that. I started to update the worklog for documentation.


Flanker(Posted 2016) [#143]
[double post]


Rick Nasher(Posted 2016) [#144]
@GF:
More tricky than you thought at first hey? But perseverance and endurance will get you there. ;-)

Nevertheless want to see what you came up with, but 2 questions..
-What's wrong with putting it in here using the codebox commands? See: http://www.blitzbasic.com/faq/faq_entry.php?id=2
-You are using dependencies:
api_ShowWindow ( SystemProperty$ ( "apphWnd" ), 1 )

What decls go with that again?

Also if you want everyone to be able to enter their own name then replace the top of the example with:



@Flanker:
Nice bit of docs there, but you pulled down the library and example code of v1.0 without putting a new entry. Is this by accident or deliberate?
I found the code pretty enjoyable so far..


Flanker(Posted 2016) [#145]
It is deliberate, I will erase obsolete versions each time to make the worklog clear.

The worklog is near to be fully updated : http://www.blitzbasic.com/logs/userlog.php?user=15074&log=1916

The v1.1 is also uploaded, with a newer 3D example. I'll write simpler examples to explain the library.

New thread for discussion for the library, if you don't mind : http://www.blitzbasic.com/Community/posts.php?topic=105608


Rick Nasher(Posted 2016) [#146]
Yep, I totally agree for this was a general investigation and your lib deserves it's own thread as it really outgrew this thread. :-)


Rick Nasher(Posted 2016) [#147]
Well, I'm certainly not going to be claiming to be the one who coded the lib Flankers making(I'm not worthy :-). We brought in ideas, tested, bug hunted? -Yes, absolutely, but 'making'(coding) is too much credit. The follow up Blitz3D Multiplayer FPS/TPS is something we can do together of course, yes.

Let's call it:
BUMP - (Blitz3D's Ultimate Multi Player) as a working title.

The conversion/extension to Hybrid can then be called:
HUMP - (Hybrid's Ultimate Multi Player)

:-D


Rick Nasher(Posted 2016) [#148]
Chat/testing/playground for Flanker's UDPlib:

Site: http://webchat.quakenet.org/
Channel: #UDPNetwork_lib


Rick Nasher(Posted 2016) [#149]
Added some new audio fx and other fixes. Will provide download link tonight..

[EDIT]


Source+media download <here>
Executable download <here>


Guy Fawkes(Posted 2016) [#150]
SICK, RICK! :)

~GF


Rick Nasher(Posted 2016) [#151]
:-)


Rick Nasher(Posted 2016) [#152]
@GF:

Just a quick idea of how to implement, already partialy functional(host can kick), requires finetuning, but proof of concept.
At the chat variables initialization, in beginning of code add:
; chat
Global maxlinelength% =79




Going to sleep now(yawn), hope you like it so far.


Rick Nasher(Posted 2016) [#153]
Woops, fixed some bugs/logic errors. (It was late..)

Fixes:
-Msg display is little better.
-Host can't kick oneself.
-Bit more fool proof.


Guy Fawkes(Posted 2016) [#154]
Meet me in da chat, @Rick Nasher! =D

~GF


Guy Fawkes(Posted 2016) [#155]
Rick, having a BIT of trouble with the player's type (ie: Player, Server, Administrator, Moderator, etc...). I did manage to at least get it to show under the player's name and have the values of 3 & 4 be recognized by the server as actual Administrator / Moderator statuses.

I just can't grab the player's local Mode. ( the mode in which player x connects to the server ).

For instance, if the admin is already connected & has a localMode of "3", and the player that just connected has a localMode of "1", the player that connected's type should be Player, & the Admin's should be "ADMINISTRATOR", and each player / admin, etc, should be able to see the different status types under their names, but I either see Player for ALL Players in this example INCLUDING the Administrator being Player instead of Administrator as well.

ADVANCED_3D_EXAMPLE_V.1.6.1.bb:

http://pastebin.com/QEE6ybYc

UDPNetwork_lib.bb ( Modified as well ):

http://pastebin.com/RhuD4QdE

Thanks alot, Rick!

~GF


Rick Nasher(Posted 2016) [#156]
Heyy.. you've been busy.
Sorry, no time to check your stuff yet, have to work soon and woke up just now to do a slight improvement on my own code(not there yet). Will check your code as soon as permits.



Guy Fawkes(Posted 2016) [#157]
Hi, Rick! Any luck? Meet me in the chat! :)

~GF


Canana(Posted 2016) [#158]
Could I try this out?
I have never been able to get multiplayer working, it always crashes lol


Guy Fawkes(Posted 2016) [#159]
Sure! :)

Come chat with me, & / or Rick Nasher & / or Flanker. We are the creators of the demo & the library!

http://webchat.quakenet.org

the room is:

UDPNetwork_lib

Type it EXACTLY the way you see it.

I'll see you in the chat! :)

~GF


Guy Fawkes(Posted 2016) [#160]
Anyone wanna come test with me? =)

~GF


Guy Fawkes(Posted 2016) [#161]
Hello? Rick, Flanker? Wanna do some beta testing?

~GF


Guy Fawkes(Posted 2016) [#162]
Anyone wanna have a test run today? =)

~GF


Rick Nasher(Posted 2016) [#163]
Hey-hey. Sorry haven't been able to test/code past few weeks. Anything in particular you've coded and want to test?


Guy Fawkes(Posted 2016) [#164]
No. I just wanna run some beta tests.

Meet me in the chatroom! :D

~GF


Rick Nasher(Posted 2016) [#165]
@RustiKristi
I'm not sure what you mean:
1. If the player falls through the floor in the multiplayer example I'm having a real issue(bug).
2. If meant in general:

Syntax is..
EntityRadius entity, x_radius#[,y_radius#]

Parameters
entity - entity handle
x_radius# - x radius of entity's collision ellipsoid
y_radius# (optional) - y radius of entity's collision ellipsoid. If omitted the x_radius# will be used for the y_radius#.

So you if set x-radius only, you'll have a sphere.
If set y-radius also, you can create an ellipse (sphere with diff height than width).

e.g:
EntityRadius mesh,2.0 ;sphere size 2 in diameter.
EntityRadius mesh, 1.2, 1.0 ;ellipse width 1.2 , height 1.0.



@RemiD
I know it seems easy like that, but nevertheless isn't somehow:
for instance how do you determine the difference between character running down a ramp or falling of a cube of same height?

I've tried 2 approaches(in both examples the actual code is in the 'Else' section(if you're interested at least):

example1:


example2:



RustyKristi(Posted 2016) [#166]
thanks. I forgot about the Y param in EntityRadius and I'll give it another go.


Rick Nasher(Posted 2016) [#167]
Above issue solved Post#203
http://www.blitzbasic.com/Community/posts.php?topic=105608#1306517.
Now I'm trying to add the ability for players with more strength(more healthpower actually) to push players with lesser strength(of a cliff for instance ;-)
I thought I could achieve this by checking if players collided and then use translate entity to push the player:

Which is working, except for that then shooting system fails for the server. Will need to rethink.


Guy Fawkes(Posted 2016) [#168]
WOW, NASHER! You REALLY ARE making some KICK-ASS head way! =D

Keep up the EXCELLENT work!

~GF


Rick Nasher(Posted 2016) [#169]
Well, I try. But right now the good old burnout headache cane back to haunt me and have to go to work, so that kinda sucks.
I really want to have this fixed before I bring in stuff from the moving platform demo and a freecam sort of routine (for the not being able to look round is starting to annoy me :-), so don't lose oversight.

Other than with regular code it's kinda tricky at times to know where and how to introduce new functionality due to the network thinghy. Lots of stuff to keep track on at same time: Server/client/local player and code is rather spaghetti-ish in that sense.


RemiD(Posted 2016) [#170]

for instance how do you determine the difference between character running down a ramp or falling of a cube of same height?


i have already answered before...
consider the human behavior when crossing obstacles, when the obstacle is small (below the knee level) you can consider that the character is not falling but rather automatically crossing the obstacle.
So how does this translate into code :
each loop, check where is the ground related to the x,z position of the character
if the ground is below the character feet but the distance between the character feet and the ground is at a distance at less than 0.475units (corresponds to the distance between the feet and the knee of my humanoids), or if the ground is above the character feet and the ground is at a distance at less than 0.475units, position the character directly at the picked ground position, else the character is falling.
This allows the character to cross small obstacles and to move up or down on not too steep slopes.
After that i turn move the character (at front,back,left,right).


Rick Nasher(Posted 2016) [#171]
@RemiD.

Already solved the falling issue(as can be read above, you haven't read the news? ;o) It's working fine, see code below in the UpdatePlayers() function.
V1.71.1


But I'm now onto adding a new ability for the players in V1.72.0;

- The ability to push another player around by contact(so mainly over the x,z axis)when the player's health value is higher(stronger) than that of the other health value(weaker) player. -

I managed to have it working already, so could push weaker players off a ramp/platform etc, but it somehow influenced an entirely different function of the game: for suddenly when the player launched a bullet, it returned an error from the push collision check function, saying: "Entity does not exists".

So all is working fine(running, pushing, falling) for as long as the player doesn't try to shoot anyone, while this used to work fine, until I introduced the pushing code into the UpdatePlayers() function.


New archive with above mentioned source and executables, library and media included: <download here>


Rick Nasher(Posted 2016) [#172]
Update:
Added stronger player pushing weaker player function. Caution: pushing someone along requires energy. :-)
Slightly changed: made p/life into a float, easier calculating, saves an additional variable.

V1.72.4



Rick Nasher(Posted 2016) [#173]
[Deleted double post]


Guy Fawkes(Posted 2016) [#174]
WOW Nasher! I must say! You are kicking @#$, & taking names! =D

Keep up the INCREDIBLE work!

And hell YEA I'll test it with ya! :D You deserve it!

Regards,

~GF


Rick Nasher(Posted 2016) [#175]
Thanks, but wayyy not there yet. Still in phase 1. :-D


eng_harvey(Posted 2016) [#176]
Great to see LAN multiplayer(UDP).. still being worked on :) I am looking forward to downloading and taking for another test run :) Awesome Rick!!!

How is the shooting function? Did you get it happening without affecting the function you mentioned?

Best wishes Rick!

I will take a look in the next week or two and see how it is functioning!

:)


Rick Nasher(Posted 2016) [#177]
Yep that's working all fine now.
Working on some other functionalities now, as soon as I've got that working I'll upload again.


Rick Nasher(Posted 2016) [#178]
Update:


Media(.wav files), sources and exe(for the lazy people ;-) here:
UDPlibV1.12-BUMPV1.72.5t.rar

-Fixed bugs: health inaccuracies. color at start always displaying ok on players.
-Added push player function. Caution: pushing someone requires energy. :-)
-Death/change color/revive delay working.
-bug: wrong player getting color(mixed up, for not properly net-sent)fixed: Color working ok now.
-Immobility when dead also working.
-Now storing previous color and revives when.. well, revived of course.
-Added another chat cheat '/' command.
-Several bugfixes/optimizations.
-Added teleportation locations.
-Preventing players having same color.


Guy Fawkes(Posted 2016) [#179]
KICK ASS, NASHER! Keep up the GREAT damn work! I can't WAIT to get in & test it with you!

Regards,

~GF


Rick Nasher(Posted 2016) [#180]
Thanks, been tinkering too long today so got a terrible headache but I can give it a quick test spin. I'm in the usual place:
http://webchat.quakenet.org/
channel #UDPNetwork_lib



eng_harvey(Posted 2016) [#181]
@Rick Regarding the shooting thing; I might have a piece of code that does what you want - it works by releasing itself from the parent after a short distance and then it is able to kill anything in its path but does not damage its parent upon the traversal from shoot to the release distance.

Regarding the headache - do you get up often enough and stretch your legs and all that other jive as well as keep enough fluids up - I cant talk; I will sit there for hours anyway :)

I am not sure if that is what you are after but it is slightly different to what you have so it may even be interesting to look at for ideas.

There are three short functions involved - the first releases the bullet as a part of the parent until x distance - the second updates all bullet positions and the last one culls the bullet or takes action including sound upon a hit.

I think that is how it works - I wrote the code 4 months ago so it has been a while since I have seen it myself - However the code is easily accessible so if you want I am more than happy to share. Happy to help out with what I can - time pending!

I like the teleport functionality!

Anyhow great work - we will have to get together when we have some time and have a play!

:)

All the best to you Rick!

:)


Rick Nasher(Posted 2016) [#182]
Thanks. Shooting is working fine now, afaik, also close range. But never hurts to look at other code/ ways.
Ltrz.
>>edit: you'll just need to put a ';' before the line
MoveEntity b\mesh,0,0,2 ; so can't hit own player or little less easy..(no sure fix)
in the Function CreateBullet() to allow close range shooting.


eng_harvey(Posted 2016) [#183]
@Rick - that is great - I will give it a test run then - Thanks :)


Rick Nasher(Posted 2016) [#184]
Update

V1.72.5u
-bugfix: wrong location after push / teleport resolved (most of the time).
-added jump pads.
-fixed negative fall value display.
-added close range/far range mode(only can shoot each other close range with pistol, not machinegun<< diff weapons not implemented yet:-)
-fixed jumping health deduction.

V1.72.5z
-Added bullets through teleports feature..

Currently can't add code into codebox above for getting an error, so download here: http://www.mediafire.com/download/n147k5ovuhvyrng/BUMP_V1.72.5z.bb

As this one's getting a bit lengthy, continuing here: UDP LAN multiplayer(continued) Pt2