如何查看《星际争霸 2》重播?

发布于 2024-09-25 23:15:46 字数 71 浏览 5 评论 0原文

我有兴趣使用 PHP 构建一个解析器供我自己享受。我需要知道什么?您对我有什么建议?如何使用 PHP 打开《星际争霸 2》重播?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

酒解孤独 2024-10-02 23:15:47

SC重放文件实际上是MPQ存档文件。此 MPQ 存档包含一些不同的文件(如 .zip 文件)。

该存档中包含 MPQ 存档中每种数据类型的单独文件。
(例如,有一个文件用于游戏事件,另一个文件用于 UI 事件)。

网上有大量关于如何处理 MPQ 文件的文档。现在,MPQ 中的各个文件有点棘手。

如果您想从重播中获取信息(玩家是谁以及他们玩的地图),您可以使用这些工具。 (我假设有一个类似 Unix 的网络服务器)。

1) 下载并构建 libmpq 和 mpq-tools (https://libmpq.org/ )

2) 运行以下脚本

您可以通过 system() 调用运行这些命令,然后运行一些拆分命令来获取玩家和比赛。

将其保存为 info.sh。像命令 shell 一样运行它,并将重播文件作为参数传递。

#!/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

这是一个 ruby​​ 脚本。将其另存为 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)]

希望这有帮助!

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!

天生の放荡 2024-10-02 23:15:47

看看 http://code.google.com/p/phpsc2replay/

我想它可能正是您正在寻找的。我当然希望我一个月前就找到了它。

Take a look at http://code.google.com/p/phpsc2replay/

I think it may be exactly what you are looking for. I certainly wish I had found it a month ago.

白昼 2024-10-02 23:15:47

如何使用 PHP 打开《星际争霸 2》重播?

使用任何 PHP 文件系统函数 http://us.php.net/manual/en /ref.filesystem.php

由于大多数 SC2 重播的大小似乎相当小,您可能可以使用 file_get_contents() 将整个文件作为字符串检索。

How do I even open a Starcraft 2 replay using PHP?

With any of PHP's filesystem functions http://us.php.net/manual/en/ref.filesystem.php

Since most SC2 replays seem to be fairly small in size you could probably get away with file_get_contents() to retrieve the entire file as a string.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文