Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I look into a Starcraft 2 replay?

I am interested in building a parser for my own enjoyment using PHP. What do I need to know? What suggestions would you have for me? How do I even open a Starcraft 2 replay using PHP?

like image 878
Strawberry Avatar asked Oct 04 '10 08:10

Strawberry


People also ask

How do I access my Starcraft 2 replays?

Replays are saved and stored in a special folder called "StarCraft II" in the user's Documents folder. If you disconnect from Battle.net while watching a replay you will be able to continue watching the replay until you exit the replay, where you will have to reconnect.

Where are my StarCraft replays?

Replays are usually stored in the “\Maps\Replays” folder of StarCraft. Manually saved replays can be seen in this folder. The last played game is automatically saved as LastReplay.

How do I resume a replay in Starcraft 2?

In the Replay screen, right-click on the replay and select “Recover Game” in the context menu to take you to a Battle.net lobby. From this lobby you can invite the original players of the game.

Where are Starcraft 2 saved games stored?

Your savegames for the game can be found under [My Documents]\Starcraft II\Accounts....


1 Answers

The SC replay file is actually an MPQ archive file. This MPQ archive contains a few different files (like a .zip file).

Inside this archive are separate files for each of the types of data in the MPQ archive. (For example there is one file for game events and another for UI events).

There is a fair amount of documentation online about how to deal with MPQ files. Now, the individual files within the MPQ is a bit trickier.

If you want to get the information from the replay (who the players were and what map they played on) you can use these tools. (I'm assuming a Unix like web server).

1) Download and build libmpq and mpq-tools (https://libmpq.org/ )

2) Run the following scripts

You can run these from a system() call and then run a few split commands to get the players and the race.

Save this as info.sh. Run it like a command shell and pass in the replay file as an argument.

#!/bin/bash

# Save this file as info.sh

# This extracts the individual files from the MPQ archive (the replay
# file)


mpq-extract -e $1 > /dev/null
cat file000000.xxx | strings | ruby info.rb

Here is a ruby script. Save this as info.rb

# This *kinda* extracts the file info from a header file.  I don't
# really know how it works yet, so I'm just extracting strings.
#
# Save this file as info.rb

lines = STDIN.readlines
puts "%s:%s|%s:%s" % [(lines[0].strip), (lines[1].strip), (lines[2].strip), (lines[3].strip)]

Hope this helps!

like image 70
pknodle Avatar answered Nov 04 '22 12:11

pknodle