Sign in to follow this  
Followers 0
mouseboyx

Game Replay

Tiddy-bits:

Quote

I was trying to think of a way to save the float data as binary rather than plaintext which would probably reduce the file size significantly, but so far haven't come up with a solution.

If you were able to get it hooked up with a database of some sort it would probably handle some of this for you, not sure how that would be done since I've had issues getting the SAPP lua to do this in the past. 

 

For the future, it would be cool to hook this up to a web server in real time and be able to watch a game in near real-time. Performance might be an issue, but then again I have ran full servers on the same box that I run other services and it went fine.

Edited by Enclusion
mouseboyx likes this

Share this post


Link to post
Share on other sites
1 hour ago, Enclusion said:

If you were able to get it hooked up with a database of some sort it would probably handle some of this for you, not sure how that would be done since I've had issues getting the SAPP lua to do this in the past. 

 

For the future, it would be cool to hook this up to a web server in real time and be able to watch a game in near real-time. Performance might be an issue, but then again I have ran full servers on the same box that I run other services and it went fine.

It would take me a while and some motivation to figure out how to make it work, but mysql has a C/C++ api that could be used to create an ffi dll for sapp so that you could call a mysql_query() function directly from an lua script. 

https://dev.mysql.com/doc/c-api/8.0/en/

 

I thought about the real time option, if it was a public service I was worried about players using it to cheat, but if it was a private setup, that wouldn't be as much of an issue, the renderer code is built around a fixed recording file size but with a bit of tinkering it could work in near real time, there's currently a sync issue where the js animation runs slightly faster than halo's ticks.  The issue is probably due to using the js setInterval() function for animation frame increments which technically isn't supposed to be used for timing precise events.  Switching to using a timer like performance.now() might solve the issue.

 

I've had bad experiences with vps hosts in the past where I feel like I can't trust their connection enough not to lag a halo game in progress, I should probably do some testing beforehand to see what happens in different circumstances.

Enclusion likes this

Share this post


Link to post
Share on other sites
12 minutes ago, mouseboyx said:

It would take me a while and some motivation to figure out how to make it work, but mysql has a C/C++ api that could be used to create an ffi dll for sapp so that you could call a mysql_query() function directly from an lua script. 

https://dev.mysql.com/doc/c-api/8.0/en/

 

I thought about the real time option, if it was a public service I was worried about players using it to cheat, but if it was a private setup, that wouldn't be as much of an issue, the renderer code is built around a fixed recording file size but with a bit of tinkering it could work in near real time, there's currently a sync issue where the js animation runs slightly faster than halo's ticks.  The issue is probably due to using the js setInterval() function for animation frame increments which technically isn't supposed to be used for timing precise events.  Switching to using a timer like performance.now() might solve the issue.

 

I've had bad experiences with vps hosts in the past where I feel like I can't trust their connection enough not to lag a halo game in progress, I should probably do some testing beforehand to see what happens in different circumstances.

In terms of cheating, you could have a 30 second to a minute buffer. Also even if it was just private it would be extremely useful to be able to check for cheaters, assuming the rendering is accurate enough, without even joining a server.

mouseboyx likes this

Share this post


Link to post
Share on other sites
3 hours ago, Enclusion said:

In terms of cheating, you could have a 30 second to a minute buffer. Also even if it was just private it would be extremely useful to be able to check for cheaters, assuming the rendering is accurate enough, without even joining a server.

I think the data collection is going to influenced by latency, here's a video of an aimbot that does horizontal aiming only, on the aimbot client the horizontal aim is always spot on, but the data collected is late, and this is through the localhost so it might be an even greater difference over the internet.  Not sure if there's a way to account for this in the code, or if the person viewing the render will have to assume and compensate for latency. 

 

It's definitely possible to do a realtime render, but would take some extra work to make it possible.

 

Edit: It might be possible using get_var(PlayerIndex,"$ping") and using that data to account for latency.

 

Edit2:

It looks like the data is late independent from sapp's custom_sleep command, or at least the data seems to be late relative to tick.

For the player being sightjacked if their ping is anywhere from 1-33ish then their aim needs to be 2 ticks ahead of the current animation, then add 1 tick for every 33ms of ping-ish.

For the rest of the players not being sightjacked their data needs to be 2 ticks behind the current animation from 1-33 then minus 1 extra tick for every 33ms.

It may be challenging to find each "tick slot" a player falls into based on ping, then apply that delay in the render, lots of testing to be done...

Edited by mouseboyx
Enclusion likes this

Share this post


Link to post
Share on other sites

Not sure if you are already doing this but an easy way to trim the size of data files is to only write values that have changed from the previous frame. If you are not already doing that then that is probably the main reason why the file size upon compression is so much smaller. The compression algorithm in the end would do something similar.

Enclusion and mouseboyx like this

Share this post


Link to post
Share on other sites
On 12/6/2022 at 9:26 PM, Sunstriker7 said:

Not sure if you are already doing this but an easy way to trim the size of data files is to only write values that have changed from the previous frame. If you are not already doing that then that is probably the main reason why the file size upon compression is so much smaller. The compression algorithm in the end would do something similar.

I like the idea, it seems difficult to do a seek feature with that though.  For each piece of data that didn't change it's true value could be any arbitrary length from the desired tick that's animating.  It becomes easier if there's an ID associated with each object that didn't change, then seek backward through the file until you find each piece of data that you need.  I can see how it would work, like if some float didn't change from the previous tick then write a single character in place of the float indicating to look to the previous tick, and do that every time it doesn't change.  It seems like a necessary tradeoff, the file size will be smaller, but PHP will have to work harder, rewinding the file, parsing each line, checking if the data is there until it finds everything, then sending it off to js.  js could then see that certain data hasn't changed from the seek position tick and fill that in as necessary.  It gets a little complicated while buffering the animation data too, as well as buffering data while the animation is playing in reverse.

 

Lmao the optimization never ends, in all seriousness though I'm glad I'm getting feedback to improve this.

 

In other news I figured out an ok method of latency compensation while using SJ.  Only have to set the camera's aim to a certain number of ticks in the future based on that player's ping.  Ended up having a toggle to switch to use either average ping or instantaneous ping from each tick (seems like it might be necessary for certain warping conditions)

 

Edit (Progress):

Added a simple yet effective way to save space, vehicles, and flags and oddballs are the main culprit for bloating the file, because they can sit idle for long periods of time.

An example string of how a vehicle was saved previously:

ObjectID,tag_name,obj_x_coord,obj_y_coord,obj_z_coord,obj_front_x,obj_front_y,obj_front_z,obj_up_x,obj_up_y,obj_up_z,player_in_vehicle
3800236052,mp_warthog,46.338062286377,-64.705101013184,1.4689781665802,0.64794391393661,-0.758948802948,-0.064540214836597,-0.04084175080061,-0.11922907084227,0.99202638864517,-1

If none of that data changes in the next tick it's reduced to:

3799056386,p,69

ObjectID, the character 'p' to indicate to look to previous data, and 69 as the line number of it's last known data change.

 

PHP then finds all of the 'p' occurrences and fills in the the first and last line of buffer data with the appropriate true values, then echos out the same 3799056386,p,69 like data for the rest of the stuff that doesn't change, and JavaScript fills in the spaces based on the first and last line.  (I think this should work for reverse buffering because the last line true values are found based on the line numbers from the last line)

 

With the latency compensation I'm going to add another toggle to compensate all player cameras and not only the SJ view.  As long as the positions and rotations of objects remains true to the current tick, then all player cameras can be set into the future by an individual compensation factor to show where any player is currently aiming via a 3D object.

 

 

Edited by mouseboyx
Enclusion and AntiMomentum like this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0
  • Recently Browsing   0 members

    No registered users viewing this page.