Download here. The version number is now 2.6.
Sonic Adventure 2: Battle Network Online Multiplayer for Sonic Adventure 2 PC! (v3.2, 04/30/2016)
Posted 17 March 2014 - 02:51 PM
Download here. The version number is now 2.6.
Posted 18 March 2014 - 02:56 PM
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.
Posted 03 May 2014 - 03:24 PM
- 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.
Posted 15 August 2014 - 12:44 AM
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
Posted 29 November 2014 - 06:28 AM
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... ).
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.
Posted 29 November 2014 - 04:24 PM
Lol wut. How's that going to work.
Big vs Knuckles in Hot Shelter because fuck everything
Posted 29 November 2014 - 07:58 PM
Posted 22 January 2016 - 01:17 PM
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.