Sonic and Sega Retro Message Board: Sonic Adventure 2: Battle Network - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
  • 4 Pages +
  • 1
  • 2
  • 3
  • 4
    Locked
    Locked Forum

Sonic Adventure 2: Battle Network Online Multiplayer for Sonic Adventure 2 PC! (v3.2, 04/30/2016)

#31 User is offline Morph 

Posted 17 March 2014 - 02:51 PM

  • AKA SonicFreak94.
  • Posts: 726
  • Joined: 01-August 08
  • Gender:Male
  • Location:Utah
  • Project:SA1/2 hax
  • Wiki edits:11
Quick bugfix. I fixed the argument count oversight, and now it ACTUALLY WORKS on Windows XP... which was also an oversight. I also did some minor cleanup here and there, but it doesn't really affect anything.

Download here. The version number is now 2.6.

#32 User is offline Lanzer 

Posted 18 March 2014 - 02:56 PM

  • The saber calls for its master...
  • Posts: 6649
  • Joined: 27-February 09
  • Gender:Male
  • Location:Glendale, AZ
  • Project:Doing Stuff.
  • Wiki edits:1

View PostMorph, on 17 March 2014 - 02:51 PM, said:

Quick bugfix. I fixed the argument count oversight, and now it ACTUALLY WORKS on Windows XP... which was also an oversight. I also did some minor cleanup here and there, but it doesn't really affect anything.

Download here. The version number is now 2.6.


Awesome, thanks for the update Morph. I'll go ahead and crosspost your posts in the SSMB topic too.

#33 User is offline Morph 

Posted 03 May 2014 - 03:24 PM

  • AKA SonicFreak94.
  • Posts: 726
  • Joined: 01-August 08
  • Gender:Male
  • Location:Utah
  • Project:SA1/2 hax
  • Wiki edits:11
Here's another small polish update:

  • Fixed the random Chao Garden bug. Details below.
  • Fixed an issue with spindashing. The spindash timer is now synchronized. Details on this also below.
  • Attempt to revert changes made to the game's code when disconnecting. The functionality has been there for a while, just not put to use.


To fix the Chao Garden bug, I changed the way I check for player changes. Before, I was relying on the level number to change so that I could re-initialize the (internal) players only exactly when necessary. The problem here is that it doesn't always change to 0 when exiting a stage to the menu, so I'd have to do a bunch of trickery to change it to 0 so that the player objects would realize they shouldn't be "alive" right now. Every so often, things would get mixed up. And as you may know, stage 0 being the Chao Garden was to fix a bug in the actual game which would allow you to go to the test stage, hence Chao Garden.

Instead of doing that which was kinda dumb in retrospect, I'm just checking the pointer to each player every loop to see whether or not they're initialized, or if they've been re-initialized (pointer change). No more mixups and no more Chao Garden bug!

As for the spindash bug: It seems the game would get confused, and sometimes after releasing the spindash button, the receiving end wouldn't always change the timer to 0 like it should (More 0!). So that means next time you pressed B, it would try to spindash, since it always happened to be 24. This would cause desyncs when spinning to gain speed, and then cancelling it, because instead of cancelling on the receiving end, it would just roll up and continue rolling on its merry way. It would also cause the spindash trail left behind to be halfway in the ground. The solution was rather simple, that being to send the spindash timer when you're playing as Sonic/Shadow (and Metalsonic/Amy just in case you use the spindash hack for them =P). I figured it'd be a little more tricky to fix than that, but evidently not.

This brings the version number to 2.7.

Edit: typo :v:
This post has been edited by Morph: 03 May 2014 - 03:26 PM

#34 User is offline Lanzer 

Posted 03 May 2014 - 04:09 PM

  • The saber calls for its master...
  • Posts: 6649
  • Joined: 27-February 09
  • Gender:Male
  • Location:Glendale, AZ
  • Project:Doing Stuff.
  • Wiki edits:1
Thank you for updating the Chao Garden bug and the spindashing <- that right their was alittle annoying to deal with but I wasn't sure if was a legit bug or an after effect of modding the game.

#35 User is offline Morph 

Posted 15 August 2014 - 12:44 AM

  • AKA SonicFreak94.
  • Posts: 726
  • Joined: 01-August 08
  • Gender:Male
  • Location:Utah
  • Project:SA1/2 hax
  • Wiki edits:11
Man, I say I'll work on one thing, but then I do something totally different...



EDIT: To be clear, this is the mod loader version. This is why I'm able to do this kind of thing with ease.

This has pretty been pretty much entirely rewritten for many reasons... although mostly due to everything just falling apart, one bug after another. The networking is now a lot more efficient (by ensuring no duplicate data is sent), and uses both TCP and UDP. Eventually, there will likely be UDP only and TCP only modes. I also send certain bits of player information more efficiently. Before, it effectively sent data every frame (in other words, every 16ms, assuming your game runs at full speed).

As a result of rewriting it, it made it easier for me to track down the cause of that one game-crashing bug which involves picking up objects, and I've nearly fixed it. It still does crash, but now it's a lot safer. Assuming the player picks up the object carefully (no run-by object-grabbing!), everything works out. Of course, no promises that it'll EVER be fixed, but it's something I'd really like to.

Aside from that, the highlight here is the smooth-ish gameplay, and the connectivity notification noises. If anyone's interested, the audio used is in SA2 by default (as far as I'm aware) as chao_k_net_*.adx
This post has been edited by Morph: 15 August 2014 - 08:52 PM

#36 User is offline Turbohog 

Posted 15 August 2014 - 01:15 AM

  • Posts: 447
  • Joined: 25-June 08
  • Gender:Male
  • Wiki edits:22
I'm super late to this party, but I just want to thank you for your work on this. You're fulfilling one of my childhood dreams with this project. New video looks great. I can't wait to test this out myself.

#37 User is offline Morph 

Posted 15 August 2014 - 01:34 AM

  • AKA SonicFreak94.
  • Posts: 726
  • Joined: 01-August 08
  • Gender:Male
  • Location:Utah
  • Project:SA1/2 hax
  • Wiki edits:11
My pleasure. It's a lot of fun, and I'm fulfilling my own childhood dreams as well, of course =P

#38 User is offline Morph 

Posted 29 November 2014 - 06:28 AM

  • AKA SonicFreak94.
  • Posts: 726
  • Joined: 01-August 08
  • Gender:Male
  • Location:Utah
  • Project:SA1/2 hax
  • Wiki edits:11
The mod loader version is here!

Before I get to explaining what changed, let me preface this by saying: I need performance feedback. Does it run better or even worse on your system and connection? Are there any bugs present during gameplay that weren't present in the last release build? Please let me know so I can look into it. Also, expect the console to spam a lot of messages. I have this enabled so that in the event of a crash, you can screenshot the console, and I can narrow it down to which packet caused it. Additionally, the connection timeout functionality is gone again. I never took the time to re-implement it after practically re-writing this whole thing.

This version is generally more stable and uses a totally different networking library (slightly modified SFML - details in OP). As a result, it now uses both TCP and UDP protocols. My friend Sonickidnextgen (ImmutableOctet) plans to eventually implement a UDP-exclusive mode, and on top of that, I'll likely implement TCP-exclusive mode (although likely only for LAN play... but why play via LAN anyway? Whatever... :v: ).

As for changes, the most major change can be seen in the last progress video a few posts up. Connects and disconnects now occur when entering and exiting the 2P Battle menu, and it plays the Chao Kindergarten networking jingles while waiting for a connection, when a connection has been established, or when a connection has been lost. The networking is also generally more efficient.

It now also reverts all code changes made after establishing a connection once you disconnect. Although maybe not desirable, I believe this may affect the --keep-active argument. After disconnecting, it will restore the code to its normal behavior. I recommend using the mod version if you want to permanently keep the window active.

Another nice thing is that you can always have the mod enabled if you please. You just have to enable the console when you want to play online, and then run the game with the command line arguments described in the first post. As for more technical stuff, it now sends less, larger packets as opposed to many small packets. In theory this should speed things up on the receiving end.

There's also a fun little thing I added. Scale is now synchronized, so you can become giant Shadow if you like. =P

The new usage and installation instructions are all in the first post.

Download: Version 3.0 (11/29/2014)

There's your stinkin' download. Now here's a bit (more) of a monologue =P

As it stands now, the overall functionality is the same as the last release version, ignoring the general polish. From this point onward, I plan to utilize the mod loader more heavily. I can use it to hijack functions to do specific networking actions. For example, I could hijack the "load level" function (wherever that is!), and tell it to send a "load level pls" request to all the other clients, at which point they would all simply call the function.

I also plan to rewrite the input handler again. As it stands now, the input handler imposes a 1 to 2 frame delay on every call to the receive function in which a button press was received (which can cause some minor desyncs). The reason for this is that I have to:
  • Synchronize with the framerate if the program doesn't already happen to be in the right place at the right time
  • Take the newly received held buttons, compare to the last received, and write the difference to the "just pressed" buffer.
  • Then I absolutely must wait one whole frame, and immediately after, clear that buffer. Otherwise, the game will think I'm spamming button presses.


I could get around this by doing a bunch of threading trickery, but I'd honestly rather not. That would be such a hassle. Instead, I plan to hijack the controller update routine to do my bidding. The idea is to just trick it into handling those buffers on its own without constantly wiping them unnecessarily (which it does, by the way--rather annoying!).

And in the long run, whoever is the client (not hosting) will be handled as a real player 2, even on their instance of SA2. This'll help make way for porting to SADX later.

#39 User is offline Lanzer 

Posted 29 November 2014 - 06:50 AM

  • The saber calls for its master...
  • Posts: 6649
  • Joined: 27-February 09
  • Gender:Male
  • Location:Glendale, AZ
  • Project:Doing Stuff.
  • Wiki edits:1
Thanks for your continued work on this Morph, I'll crosspost your post over to SSMB as well to see if I can get any feedback there.

#40 User is offline Dark Sonic 

Posted 29 November 2014 - 04:24 PM

  • Posts: 10668
  • Joined: 21-April 06
  • Gender:Male
  • Project:Posting a lot (I have a lot of time at work)
  • Wiki edits:10

View PostMorph, on 29 November 2014 - 06:28 AM, said:

And in the long run, whoever is the client (not hosting) will be handled as a real player 2, even on their instance of SA2. This'll help make way for porting to SADX later.

Lol wut. How's that going to work.

Big vs Knuckles in Hot Shelter because fuck everything
This post has been edited by Dark Sonic: 29 November 2014 - 04:24 PM

#41 User is offline E-122-Psi 

Posted 29 November 2014 - 07:58 PM

  • Posts: 1728
  • Joined: 29-December 09
  • Gender:Male
  • Wiki edits:41

View PostMorph, on 29 November 2014 - 06:28 AM, said:

And in the long run, whoever is the client (not hosting) will be handled as a real player 2, even on their instance of SA2. This'll help make way for porting to SADX later.


Two player mode in SADX??? Make it happen! :D

#42 User is offline Vertrex 

Posted 05 December 2014 - 01:36 PM

  • Layin' the wax and spinnin' the sound
  • Posts: 30
  • Joined: 16-July 14
  • Gender:Male
  • Location:Yuma, Arizona
Tested chao world with nethax, although it's indefinitely unstable.


This post has been edited by Vertrex: 14 February 2017 - 04:07 AM

#43 User is offline Morph 

Posted 22 January 2016 - 01:17 PM

  • AKA SonicFreak94.
  • Posts: 726
  • Joined: 01-August 08
  • Gender:Male
  • Location:Utah
  • Project:SA1/2 hax
  • Wiki edits:11
It's been a loooong time. How have you been?

Version 3.1 has been released, and it's open source! Latest release and code here. From now on you'll be able to find archived releases on the GitHub repo. The latest version will always be hosted on my website here.

Note: This version requires a newer C++ redist than before. It's linked in the main post. And make sure you update your mod loader! It's using new events that have just recently been implemented.

Changes from 3.0:
  • Camera independent input.
  • Input rewrite now in place using OnInput and OnControl events. No frame latency!
  • Partial Emerald Hunting support (see #12 and #10).
  • Shooting is now much more playable, but not perfect. See #11.
  • Synchronized player damage, HP and ring counts via function call hooks; never desync again!
  • Teleportation only allowed with new flag from host, --cheats.
  • Network statistic logging now available with --netstat (logs to CSV in game directory).
  • Stage load lag compensation. The player who loaded first will wait for the player who is behind.
  • Stage change synchronization. Even if the menu desyncs, you'll still go to the same stage.
  • Random seed synchronization (although it's 0xDEAD0CAB 99% of the time anyway).
  • Console window now optional, but still recommended.
  • Overall accuracy and stability improvements (as well as some newly introduced instabilities! Fun!).
  • And of course, open source =P

can't be bothered to make those issue numbers clickable; just go to the github release page for that

You can report bugs and see known issues here!

I'm probably forgetting some things given that it's been over a year since the last release. I can't believe I've been sitting on so many improvements for so long (which isn't to say all of the improvements listed above are old, it's just that some of them are, like the new input handler).

For this version I wrote my own trampoline implementation which allows me to override functions but still call the originals, and that has been immensely useful for things like synchronizing HP, ring count, damage, etc etc. My implementation can also be found in the SADX Mod Loader right now, and I plan to expose it to mod developers in both mod loaders sometime soon. If anybody needs it in the meantime, just copy the source files =P

And emerald hunting now works!... with a catch. It will only work the first time you enter a specific stage. If you try to replay that stage without first exiting to the main menu, they will no longer be synchronized. If you play best 2 of 3 however, the stage will usually change after a round, so it works out. I got this working entirely accidentally though. As it turns out, upon first stage load, the emerald manager will run through a for loop calling rand() because... reasons? It's relative to the frame count, though. Specifically, FrameCount & 0x3FF, which is anything < 1024. I decided to synchronize the frame count there for kicks, and to my surprise, it just worked. There's another catch though. There appears to be a crashing issue upon stage load in emerald hunting, but I can't consistently reproduce the issue. I highly recommend looking through the known issues linked above.

For the next version, I hope to start working on a master server to make it easier to find people to play with.

Have fun!
This post has been edited by Morph: 22 January 2016 - 01:20 PM

#44 User is offline Overlord 

Posted 22 January 2016 - 02:00 PM

  • Substitute Meerkovo IT Chief
  • Posts: 16438
  • Joined: 12-January 03
  • Gender:Male
  • Location:Berkshire, England
  • Project:VGDB
  • Wiki edits:3,204
Thanks for your efforts, and for making it open source too! Won't be downloading personally as I don't have the PC version of SA2:B but I'm sure lots will put this to use.

#45 User is offline Lanzer 

Posted 27 January 2016 - 10:54 PM

  • The saber calls for its master...
  • Posts: 6649
  • Joined: 27-February 09
  • Gender:Male
  • Location:Glendale, AZ
  • Project:Doing Stuff.
  • Wiki edits:1
This got updated?! whoa awesome!! :D

Thanks for your efforts Morph.

  • 4 Pages +
  • 1
  • 2
  • 3
  • 4
    Locked
    Locked Forum

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users