Flakes Construction Yard

YSFlight addon development, questions, tutorials, & more!
User avatar
Flake
Staff
Staff
Posts: 4121
Joined: Thu Feb 10, 2011 8:47 pm
Favorite Aircraft: Honda CBR600RR. Shit I mean Boeing F/A-18A.
Location: Newcastle, Australia
OS: Windows 10 (x64)
Has thanked: 752 times
Been thanked: 1022 times

Re: Flakes Construction Yard

Post by Flake » Thu Nov 23, 2017 4:19 am

Image

That refactor was more difficult than it looked, but got there in the end.

----

So it turns out you can do some neat stuff with windows command line:

Code: Select all

tasklist | findstr fsmaino
tasklist | findstr fsmaindx
tasklist | findstr ysflight32_gl1
tasklist | findstr ysflight32_gl2
tasklist | findstr ysflight32_d3d9
Pipe each process id into:

Code: Select all

netstat -aon | findstr xxxx
To find remote addresses that each YSFlight program is connected to, if it is connected.

Plug this up to a simple windows service and an installer/uninstaller for that and I link this to an authentication form for YSFHQ.

I can send "automatic logins" packets to any YSFlight server, from any YS version. No need to pipe through a tunnel, slowing your game down, bcause all I really needed in the first place was the external IP you've connected to.

You'd literally just start YSF and connect to your favourite server, set and forget. No funky logins on the server side. Choose any username you want, and any OpenYS enabled server will recognise you when you login by your YSFHQ username.

That's something to get excited about for the future.

(Extended protocal functions and the like that is client sided will still need to go through a tunnel service though.
Image
(At this stage, I get more enjoyment coding for this game then playing it. Weird right?)

User avatar
Flake
Staff
Staff
Posts: 4121
Joined: Thu Feb 10, 2011 8:47 pm
Favorite Aircraft: Honda CBR600RR. Shit I mean Boeing F/A-18A.
Location: Newcastle, Australia
OS: Windows 10 (x64)
Has thanked: 752 times
Been thanked: 1022 times

Re: Flakes Construction Yard

Post by Flake » Fri Nov 24, 2017 7:47 am

Image

Built an authenticator...

Image

Also built a detector for seeing which servers you are connected to. Works for all YSFlight executable types
(so long as you don't rename the exe)...

Only thing I'd need to do to finish that up is some crash wrappers, a place to store and load the username and password, and then link with a UDP packet to the host with your YSFHQ ID.

If the host happens to be running my new version of OYS, they'll automattically log you in.
Image
(At this stage, I get more enjoyment coding for this game then playing it. Weird right?)

User avatar
Flake
Staff
Staff
Posts: 4121
Joined: Thu Feb 10, 2011 8:47 pm
Favorite Aircraft: Honda CBR600RR. Shit I mean Boeing F/A-18A.
Location: Newcastle, Australia
OS: Windows 10 (x64)
Has thanked: 752 times
Been thanked: 1022 times

Re: Flakes Construction Yard

Post by Flake » Thu Nov 30, 2017 11:31 am

Update: Working on the skeleton and basic functions for Servers today. Those following the OfficerFlake Library on GitHub will be able to grab my source at all times I commit a change, which is each day I work on the code.

Implemented a class for Connections, which can handle TCP/IP and UDP input, will be driven by events. Copied the old, stable code from OYS for the TCP/IP side. UDP, though I'm using static methods, needs to be refactored into its own class. Issue there is many client can reference the UDP receiver and mess the connection up: 1 udp client recieves all the messages to all clients on the server, where as with TCP one client has one socket that recieves the messages just for it.

Implemented basic GenericPacket, before I re-do the packets from OYS. Can safely read data that doesn't exist by fudging zero's. Can set data that doesn't exist in the array by appending data to the array. Returning the correct values for all common data types: Bool (a bit as part of a byte), Byte, SByte, Int16, UInt16, Int32, UInt32, Single (floating point), String. Further specialisation will be done in the packet itself.

Created a simple test packet of type 00 and edited the data a bit to confirm all is working and not broken. Used weird and funky numbers and other ways of manipulating data to confirm that the program won't crash in future based on the possible inputs of each data type.

I'll copy across the packet definitions I have from OYS starting tomorrow and we'll see if I can have the first working server for OYS 2.0 in the next few days.

No settings yet. No database to store data, it'll just be very bare bones. At this stage, I'm near refactoring old-code point so the production should hopefully accelerate from here.

Also to note: String in/out is being handled as UTF8 instead of ASCII, so this should stop future crashes due to weird symbols on places like Discord. In fact, I'm using a StreamReader and getting the encoding detected from that, so if the encoding is different, that I should be able to pick that up correctly too.

With each new version of OYS, I improve as a programmer and make for a cleaner, more bug free program. Here's hoping the new code will be suitable for extended server use! Fingers crossed.

Code: Select all

223107 <OpenYS Console> TESTING BOOLEAN:
223107 <OpenYS Console> ----Current Value: False
223107 <OpenYS Console> ----Current Data: 
223107 <OpenYS Console> CHANING BOOLEAN TO TRUE:
223107 <OpenYS Console> ----Current Value: True
223107 <OpenYS Console> ----Current Data: 10
223107 <OpenYS Console> ----Clearing Data....
223107 <OpenYS Console> TESTING BYTE:
223107 <OpenYS Console> ----Current Value: 0
223107 <OpenYS Console> ----Current Data: 
223107 <OpenYS Console> CHANING BYTE TO 127:
223107 <OpenYS Console> ----Current Value: 127
223107 <OpenYS Console> ----Current Data: 7F
223107 <OpenYS Console> ----Clearing Data....
223107 <OpenYS Console> TESTING SBYTE:
223107 <OpenYS Console> ----Current Value: 0
223107 <OpenYS Console> ----Current Data: 
223107 <OpenYS Console> CHANING SBYTE TO -127:
223107 <OpenYS Console> ----Current Value: -127
223107 <OpenYS Console> ----Current Data: 81
223107 <OpenYS Console> ----Clearing Data....
223107 <OpenYS Console> TESTING INT16:
223107 <OpenYS Console> ----Current Value: 0
223107 <OpenYS Console> ----Current Data: 
223107 <OpenYS Console> CHANING INT16 TO -1024:
223107 <OpenYS Console> ----Current Value: -1024
223107 <OpenYS Console> ----Current Data: 00-FC
223107 <OpenYS Console> ----Clearing Data....
223107 <OpenYS Console> TESTING UINT16:
223107 <OpenYS Console> ----Current Value: 0
223107 <OpenYS Console> ----Current Data: 
223107 <OpenYS Console> CHANING UINT16 TO 32767:
223107 <OpenYS Console> ----Current Value: 32767
223107 <OpenYS Console> ----Current Data: FF-7F
223107 <OpenYS Console> ----Clearing Data....
223107 <OpenYS Console> TESTING INT32:
223107 <OpenYS Console> ----Current Value: 0
223107 <OpenYS Console> ----Current Data: 
223107 <OpenYS Console> CHANING INT32 TO -1024:
223107 <OpenYS Console> ----Current Value: -1024
223107 <OpenYS Console> ----Current Data: 00-FC-FF-FF
223107 <OpenYS Console> ----Clearing Data....
223107 <OpenYS Console> TESTING UINT32:
223107 <OpenYS Console> ----Current Value: 0
223107 <OpenYS Console> ----Current Data: 
223107 <OpenYS Console> CHANING UINT32 TO 32767:
223107 <OpenYS Console> ----Current Value: 32767
223107 <OpenYS Console> ----Current Data: FF-7F-00-00
223107 <OpenYS Console> ----Clearing Data....
223107 <OpenYS Console> TESTING SINGLE:
223107 <OpenYS Console> ----Current Value: 0
223107 <OpenYS Console> ----Current Data: 
223107 <OpenYS Console> CHANING SINGLE TO -1024.50:
223107 <OpenYS Console> ----Current Value: -1024.5
223107 <OpenYS Console> ----Current Data: 00-10-80-C4
223107 <OpenYS Console> ----Clearing Data....
223107 <OpenYS Console> TESTING STRING:
223107 <OpenYS Console> ----Current Value: 
223107 <OpenYS Console> ----Current Data: 
223107 <OpenYS Console> CHANING STRING TO "0123456789ABCDEF$$$$" (Limit 16 Char)
                        :
223107 <OpenYS Console> ----Current Value: 0123456789ABCDEF
223107 <OpenYS Console> ----Current Data: 30-31-32-33-34-35-36-37-38-39-41-42-43
                        -44-45-46
223107 <OpenYS Console> ----Clearing Data....
223107 <OpenYS Console> All Tests Successful
Image
(At this stage, I get more enjoyment coding for this game then playing it. Weird right?)

User avatar
Flake
Staff
Staff
Posts: 4121
Joined: Thu Feb 10, 2011 8:47 pm
Favorite Aircraft: Honda CBR600RR. Shit I mean Boeing F/A-18A.
Location: Newcastle, Australia
OS: Windows 10 (x64)
Has thanked: 752 times
Been thanked: 1022 times

Re: Flakes Construction Yard

Post by Flake » Mon Dec 04, 2017 5:47 am

Much has happened since my last update:

Now loading all Aircraft, Grounds, and Scenerys from default YSFlight Folder.
Now have a basic barebones Server object that can accept TCP/IP clients, and UDP messages and pass them to the correct clients.

The only thing that the server is missing now is a processor to handle incoming packets. That's just a refactor of old OYS code, so shouldn't take more than one day.

One day until OYS 2.0 alpha is ready? Let's hope...
Image
(At this stage, I get more enjoyment coding for this game then playing it. Weird right?)

User avatar
Flake
Staff
Staff
Posts: 4121
Joined: Thu Feb 10, 2011 8:47 pm
Favorite Aircraft: Honda CBR600RR. Shit I mean Boeing F/A-18A.
Location: Newcastle, Australia
OS: Windows 10 (x64)
Has thanked: 752 times
Been thanked: 1022 times

Re: Flakes Construction Yard

Post by Flake » Tue Dec 05, 2017 7:35 am

Image

Ahh yes. I see you know your Netcode well.

I can now send and receive data and messages to connected clients.
I can now wait for specific packets, by defining specific parameters of the target packets I am after.
Packet send and receive is once again async with callbacks and invokations.
The login method is already much cleaner than it used to be.

There's a LOT of processing code to refactor, so I might have been optimistic. I'm also going to be busy for the coming week, so it might be another fortnight or so until this is done but it should be worth the wait.

Tech specs:

Can do cool stuff like:

Code: Select all

thisConnection.SendMessage("Sending you the Version Packet");

Type_29_NetcodeVersion packetNetcodeVersion = new Type_29_NetcodeVersion();
packetNetcodeVersion.Version = 20110207;

thisConnection.Send(packetNetcodeVersion);

////

PacketWaiter thisWaiter = new PacketWaiter(6); //Get an acknowledgement
thisWaiter.Require(0, (Int32)9); //which has an Int32 at data position 0 equal to 9.
thisWaiter.Desire(4,(Int32)10); //Example, optionally require this.
thisWaiter.Desire(4,(Int32)11); //Example, can choose between any desire option, and will match so long as one or more conditions are met.

bool result = thisConnection.GetResponseOrResend(thisWaiter, packetNetcodeVersion); //wait for response, if we don't get it, try to resend until we get a reply. Give up after three tries.
bool result2 = PacketWaiter.WaitUntilRecieved(int timeout). //Blocks until a packet that meets the given criteria is received.

Type_06_Acknowledge thisAcknowledgent = thisWaiter.RecievedPacket;

////
So already the code for waiting for data is quite flexible. By the way, none of this is blocking. So if a packet comes in that I don't want to look at, it's handled normally. No threads, no mess, just Async callbacks.

More to come in the coming days or weeks. Stay tuned!
Image
(At this stage, I get more enjoyment coding for this game then playing it. Weird right?)

User avatar
Flake
Staff
Staff
Posts: 4121
Joined: Thu Feb 10, 2011 8:47 pm
Favorite Aircraft: Honda CBR600RR. Shit I mean Boeing F/A-18A.
Location: Newcastle, Australia
OS: Windows 10 (x64)
Has thanked: 752 times
Been thanked: 1022 times

Re: Flakes Construction Yard

Post by Flake » Tue Dec 05, 2017 9:42 am

Can now login to the server but much further to go before I can join flight. I'm currently trying to add the ground objects to the server and failing miserably.
Image
(At this stage, I get more enjoyment coding for this game then playing it. Weird right?)

User avatar
Flake
Staff
Staff
Posts: 4121
Joined: Thu Feb 10, 2011 8:47 pm
Favorite Aircraft: Honda CBR600RR. Shit I mean Boeing F/A-18A.
Location: Newcastle, Australia
OS: Windows 10 (x64)
Has thanked: 752 times
Been thanked: 1022 times

Re: Flakes Construction Yard

Post by Flake » Wed Dec 06, 2017 5:30 am

Progress:

Image

Data is occasionally not sent, and connections are occasionally not being accepted/processed, so I'll be inspecting that closer over coming days.

Object position isn't being set correctly, though the world loading is reporting no issues. I'll have to get down closer to the code and inspect.

We've got a lot of little things to iron out now before I can build any higher.

EDIT: Apparantly YSF throws a hissy fit if the datasize if the packet is not at least what YSF needs. This is why Fields would load at funny angles sometimes. If there was an exception, the packet size would be less than 60 and YSFlight itself would throw an exception trying to access that data. Of course, I don't get to see there was an error because throwing errors back to the user would just be logical (Thanks Soji). And the errors we do get (which should really just be a warning) block the UI. Why am I coding for this mess of a game again?
Image
(At this stage, I get more enjoyment coding for this game then playing it. Weird right?)

User avatar
Flake
Staff
Staff
Posts: 4121
Joined: Thu Feb 10, 2011 8:47 pm
Favorite Aircraft: Honda CBR600RR. Shit I mean Boeing F/A-18A.
Location: Newcastle, Australia
OS: Windows 10 (x64)
Has thanked: 752 times
Been thanked: 1022 times

Re: Flakes Construction Yard

Post by Flake » Thu Dec 07, 2017 1:49 pm

Quick update: I've now started using Async/Await/Task library built into C# 5.0 and .Net 4.5+. Sorry WindowsXP, You've been deprecated for a few years by Microsoft now and I can't justify supporting you any longer. If you use WindowsXP and don't have computer AIDS, I'm impressed.

The data I/O for sockets and other net data is now very very clean and is not having any errors. All errors are antiticpated and handled with appropriate Try/Catch for the possible errors each method could return.

Clients disconnect gracefully from the server, and their objects are confirmed collected by the .Net Garbage Collector.

It would appear the Connection class is now stable for long term use.

Also decided that there really should be only ONE console, codewise for the program so I made a static-object wrapper for that. Can now use "Console.AddDebugMessage" or "Console.AddWarningMessage" etc anywhere in the code so long as I link the delegate in the executable. I might do a bit more work to have Debug in a seperate, optional console window. This will be quite verbose.

I am also intending on adding a per Connection packet logger, that can be tied with a Form for easy inspection of YSFlight Netcode when operating in proxy mode. This will allow me to confirm packet signatures much faster, and inspect bugs and solve quicker.

At this stage, I can load the world, all aircraft and ground objects from the lists. Some bugs in world/metadata loading but I will refactor that all out, I've been making good progress so far. Grounds are spawning in the wrong location but I've made a simple FLD/STP/YFS set to test just a few objects in various positions. I will use this map to confirm my code is working correctly. This is a much better idea than just going gung-ho on random maps and praying for the best - this way, I can CONFIRM the code is working for certain scenraiors. By the way, The world/metadata loading will have debug information attached as well, I've already linked most of it to a master debug list but I should like to seperate them into individual debug lists before it's all done.

Road map from here: Test and confirm Metadata/World loading is bug free. => Develop a simple Proxy Server to run between YSF Vanilla Server and YSF Client => Make a quick UI to read the data for a specific client and show that in the Packet Sniffer UI. => Fix Bugs in Ground Object Population on YSF Servers (Location???) => Finish mapping more packets to enable players to send messages and join flight.

It's a long path ahead but it's going quite well. Stay tuned!
Image
(At this stage, I get more enjoyment coding for this game then playing it. Weird right?)

User avatar
Flake
Staff
Staff
Posts: 4121
Joined: Thu Feb 10, 2011 8:47 pm
Favorite Aircraft: Honda CBR600RR. Shit I mean Boeing F/A-18A.
Location: Newcastle, Australia
OS: Windows 10 (x64)
Has thanked: 752 times
Been thanked: 1022 times

Re: Flakes Construction Yard

Post by Flake » Fri Dec 08, 2017 2:14 am

Fixed world loading. I wasn't comparing the lines in the file as UpperCaseInvarient, so child scenerys were'nt being processed. Fixed that for everything Loading related.

Image

----

Can now send ChatMessages, Notifications for users joining and leaving the server.
Image
(At this stage, I get more enjoyment coding for this game then playing it. Weird right?)

User avatar
Neocon
First Class Membership
First Class Membership
Posts: 3627
Joined: Wed Oct 19, 2011 5:01 am
Favorite Aircraft: Baron 58
Location: Tennessee
OS: Win Vista
Has thanked: 1451 times
Been thanked: 1582 times
Contact:

Re: Flakes Construction Yard

Post by Neocon » Fri Dec 08, 2017 4:56 am

You're a wizard, Flake!

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests