Sonic Adventure 2: Battle Network

Discussion in 'Engineering & Reverse Engineering' started by SF94, Aug 18, 2013.

  1. SF94

    SF94

    AKA SonicFreak94. Tech Member
    773
    0
    16
    Utah
    SA1/2 hax
    [​IMG]

    Sonic Adventure 2: Battle Network is a netplay mod for Sonic Adventure 2 PC which is still very much in early development, and not a Sonic/Mega Man Battle Network crossover, unfortunately.
    Originally a stand-alone program, SA2:BN now utilizes the SA2 Mod Loader to check for changed player and input values and synchronizes them with another instance of SA2 over the internet. It also now uses an oh so very slightly modified version of the SFML networking library (to allow seeking in sf::Packet).

    Media:
    http://www.youtube.com/watch?v=iynFt0lkXiw
    These are old screenshots.
    Local testing
    Splitscreen toggle

    Requirements:

    Download:

    See known issues and report bugs here

    Installation:
    • Extract the SA2 Mod Loader to your SA2 folder, launch the Mod Manager, and click "Install loader"
    • Extract the SA2 Battle Network archive to the "mods" folder.
    • Re-open the Mod Manager if you closed it, or just click refresh if it was still open.
    • Find "SA2 Battle Network" and enable it (by ticking the checkbox to the left)
    • If you have MainMemory's Character Select mod, disable it if you want spawn points in multiplayer to function correctly.

    Usage:

    • If you know how to run a program with command-line arguments, just scroll down to see them.
    • In Steam, right click on Sonic Adventure 2, and click "Properties", click the "Local Files" tab, and click "Browse Local Files..."
    • Create a shortcut to sonic2app.exe and place it wherever you like
    • Right click the shortcut and click Properties.
    • In the "Target" box, at the end of the text, add a space followed by the arguments you want (e.g: "sonic2app.exe" -h 27015). Details below.

    You must use that shortcut to launch the game in order for it to work. But I know what you're thinking. "Steam has launch options! Can't I just use that?" - but the answer is no. SA2 on Steam will always start the launcher first, so the command line arguments will go to the launcher and not the game.

    Note: If you're trying to host and you don't use something like Evolve or Hamachi, you must forward ports on your router for both UDP and TCP protocols (for now). I won't go into detail on how to do this as there are many online resources that give detailed instructions already.

    Command line arguments:
    • --host (or -h) [port] - Hosts a server on the specified port. When in doubt, use 27015
    • --connect (or -c) [address:port] - Connects to the specified address on the specified port. NOTE: As of version 3.2, the format has changed from the original [address] [port] to [address:port]. Be sure to update your shortcuts and stuff.
    • --timeout (or -t) [timeout] - The connection timeout in milliseconds. Default is 15000, minimum is 1000. Currently non-functional.
    • --no-specials - Disables special abilities in 2P mode entirely. It doesn't synchronize yet, so both players must use it.
    • --keep-active - Keeps the game window active. In other words, it doesn't pause when you click on another program while in window mode. Also available in mod form.
    • --cheats - Enables teleportation.
    • --netstat - Enables network statistic logging. Saves as netstat.recv.csv and netstat.sent.csv

    Example: --connect 127.0.0.1:27015 --no-specials

    Features:
    • Toggle-able splitscreen ingame (Press L+R) (DO NOT use if splitscreen was not already on or the game may crash.)
    • Input handler (this makes all the difference in the world)
    • Synced upgrades if you want to cheat yourself a bounce bracelet and the like =P

    Planned:
    • Configurable 2player specials (ring count requirements, blacklist, etc; e.g speed up only, 50 ring requirement)
    • Something everyone has wanted forever
      :ssh:

    Thanks:
    I owe a huge thanks to MainMemory for helping me out with a lot of things (such as enabling me to run multiple instances of SA2).

    On the same token, let me be clear here. MainMemory did all of the reverse engineering. Without his work, this would not have been possible simply because I wouldn't even know where to start with a disassembly and the like. Not to mention the executable had encrypted data which would make it crash if you tried to attach Cheat Engine's debugger... which MainMemory also cracked. The closest thing I got to reverse engineering was finding the input structure of which MainMemory has already documented for SADX (it's pretty much the same).

    And with that, I also have to thank everyone who worked on the cheat table, Sonickidnextgen who wrote the (original) socket library and helped me be less derp at programming (It's still a mess. I'LL CLEAN IT UP LATER I SWEAR!), and everyone who helped me test it. Couldn't have done it without you guys!
     
  2. SF94

    SF94

    AKA SonicFreak94. Tech Member
    773
    0
    16
    Utah
    SA1/2 hax
    Alright, I've updated it. Here are the changes:
    • Input handler is a little more accurate and at the same time a little less accurate. This should also help in low-performance circumstances as it ensures one frame has passed which also pretty much ensures the buffer has been read, thus simulating the button press.
    • Fixed character action bug. One line of code needed to be moved up one line. Wish I noticed before the contest deadline :v:
    • "Fixed" the animation bug (e.g covered it up. If it works it works!)
    • Probably some other stuff I forgot about.

    Specials don't work very well anymore (doesn't notice you pressed the button) due to the input changes, but I'll be working on this.
    This update should make it a little nicer to play if you ignore the specials (which you can disable by running the program with -nospecials, or by using sa2 pro =P).
     
  3. Aquaslash

    Aquaslash

    Emerald Dragoon Moderator
    2,818
    0
    16
    Hampton, VA
    The S Factor: Sonia and Silver
    If this is what I think it is, I might be tempted to marry you XD

    This is an awesome thing though, might give ti a try this weekend when my nephews come over
     
  4. Retroman

    Retroman

    Member
    718
    1
    18
    What is what you think it is, because I'm curious
     
  5. Fred

    Fred

    Formerly known as 'Neo' Oldbie
    1,474
    23
    18
    Portugal
    Sonic 3 Unlocked
    It's more that people just don't seem to care much about this game, and even less people actually own the Steam version.

    But no, this is an amazing thing you've done here and you should very much be proud of yourself! I haven't tried it myself (again, lack of people to test it with) but if it's playable at least 50% of the time (which it very much seems to be) then that's 50% better than what SEGA (or anyone else) has done.

    I know it's not much feedback if I haven't even been able to try it, but I think you at least deserve the acknowledgement. Good job!
     
  6. Caverns 4

    Caverns 4

    Member
    339
    0
    16
    Sanik Quest: Journey To The Right
    I haven't had the chance yet to try this myself, but believe me when I say I'm really looking forward to it. This is going to be awesome to play SA2 online, even if it's a little buggy.
     
  7. ICEknight

    ICEknight

    Researcher Researcher
    I saw this and thought it was a Megaman hack with Sonic Advance sprites, now with netplay (or whatever that would mean in the GBA game).


    Online support for Sonic Adventure 2 PC. That would do.
     
  8. SF94

    SF94

    AKA SonicFreak94. Tech Member
    773
    0
    16
    Utah
    SA1/2 hax
    I totally get that. I feel like I won the contest without anyone even testing it out though. I've been hard pressed to find anyone who has so much as run the program even if they voted on it. I definitely appreciate the support, though!

    Edit: Oh, on that note, I do plan to back-port this to SADX PC, not that there's much to do in the way of multiplayer. Maybe a certain hack of MainMemory's that he should totally finish would go well with it though. WINK WINK NUDGE NUDGE

    ... Heheh, good point. I'll change that. :v:
     
  9. Dude

    Dude

    Tech Member
    3,137
    0
    0
    Southbridge, MA
    Random VR/AR trash
    Well if you really want to test it more you can play with me. I'd love to play against people in sa2. I'm just too busy to go out looking for somebody to play with.
     
  10. Blivsey

    Blivsey

    Charismatic Sonicaholic Member
    704
    0
    0
    Ioway
    Throwing my support behind others' projects (aka none)
    I'd be down to try this with someone! Granted, my connection has a bandwidth cap, but I'd still like to try.
     
  11. sonicblur

    sonicblur

    Oldbie
    1,316
    8
    18
    :-(

    The Gamecube hack was playable more than 50% of the time. (Unless you're counting the BBA and Homebrew launcher requirement)
     
  12. SF94

    SF94

    AKA SonicFreak94. Tech Member
    773
    0
    16
    Utah
    SA1/2 hax
    That Gamecube hack was honestly what got me to start working on this already. Well, that and the SADX PC netplay that showed up on YouTube, but that never really got anywhere. I had the idea for the longest time but never really had the motivation (nor the skill) to make something of it (and plus, SA2 wasn't on PC yet =P). When I saw that, I thought to myself that I have no more excuses if it's already been done to an extent on a Gamecube.
     
  13. Shade Vortex

    Shade Vortex

    The Black Vortex Member
    474
    0
    16
    USA, WA.
    Twitch Streams
    So I was trying this with a friend earlier. Worked pretty well, for the most part. It wasn't perfectly synched up though, my friend was always ahead of me at the start. I used the recommended 16 ms interval. I was using Hamachi to host because even though I forwarded the port from my computer, my network IP wasn't wanting to work for my friend, for some reason.

    Also, the game seemed to crash, or severely desync at times, like we'd end up in different stages. We mostly did Action, but we also tried Shooting. The Time Stop seemed to sometimes not work, but other times it would.

    If it's of much importance, my friend is from the UK and I'm in the US, so that might have something to do with things a bit.
     
  14. SF94

    SF94

    AKA SonicFreak94. Tech Member
    773
    0
    16
    Utah
    SA1/2 hax
    The level desync is probably due to the menu in addition to missed button presses. On that note, I don't recommend doing more than one battle at a time, as that could do it too (make sure battle number isn't 3 in the battle options). Same with selecting an entire set of levels (to the very left of each level tier). Continuing the same level after completion works fine though.

    The time stop thing not working also applies to all other special attacks at the moment, and that's also an input issue. My button press code is more precise but not accurate enough for it to work all the time, although I've been working to fix that. Unfortunately this also breaks the pause menu a bit, but you should still be able to restart and/or exit the level even if the pause menu doesn't sync, as the game state is synced. I recommend restarting if there's a noticeable head start for one of the players... unless it's due to latency. In which case, don't be surprised if you both "win" :specialed:

    Also, it should work OK with latency up to, oh I dunno, 300-500ms? Past that point will be stretching it quite a bit though. Prepare for lots of "resending reliable message" console messages =P
     
  15. Lanzer

    Lanzer

    The saber calls for its master... Member
    6,842
    0
    16
    Glendale, AZ
    Doing Stuff.
    So I got a friend with a problem with this mod:

    So, have any idea what the problem is Morph?
     
  16. Fred

    Fred

    Formerly known as 'Neo' Oldbie
    1,474
    23
    18
    Portugal
    Sonic 3 Unlocked
    Problem might be that the program is asking for a update interval in milliseconds and your braindead friend is typing in "client"!
     
  17. SF94

    SF94

    AKA SonicFreak94. Tech Member
    773
    0
    16
    Utah
    SA1/2 hax
    Yeah uh, it says what it's asking for, and "client" and "server" are not what it's asking for in those screenshots as it clearly says in the console. Of course that's no excuse for it to spam the console window with nonsense and I should totally fix that, but still!
     
  18. Hitlersaurus Christ

    Hitlersaurus Christ

    Not a nazi, maybe Jesus, definitely a dinosaur Member
    512
    0
    16
    glorious nippon
    SNOIC GENERATONS PLUS
    I saw this thread and got super excited to make fun of someone's Megaman fan character texture hack of SA2, only to be disappointed that it's actually something really neat.
     
  19. Shade Vortex

    Shade Vortex

    The Black Vortex Member
    474
    0
    16
    USA, WA.
    Twitch Streams
    [​IMG]
    Help. I don't know how to computer.

    (This happened when I went against your advice and did multiple stage selections. I chose City Escape after we finished with Pyramid Race and on my screen, Sonic disappeared and only his board was there, left unmoving. For my friend though, the game crashed with the above happening... He was suddenly in the Chao World lobby, with my chosen character right beside him. He was Sonic and I was Shadow. For what it's worth, we originally did the Downtown Race and switched to Pyramid Race and that worked fine.)
     
  20. SF94

    SF94

    AKA SonicFreak94. Tech Member
    773
    0
    16
    Utah
    SA1/2 hax
    That's a known issue. Sometimes when returning to the menu form a stage, the stage number stays stuck at whatever stage you were playing, so my program tries to correct this. I use the stage number and check if it's changed to determine when the right time is to check the player objects again. If I don't try to correct it and you go to the same level, it won't re-evaluate the player objects and will probably crash the game because it's writing to the wrong area in memory.

    If anyone has any suggestions for alternative methods to re-evaluate the player objects, let me know; otherwise I'll have to try fixing the current system :v: