巨大的洞穴冒险文件:从二进制(?)解码为可读格式(Python)



我相信你们中的许多人都知道1976年的游戏《巨大的洞穴冒险》。我把它下载到我的Mac上,它允许你保存你的进度,它把它保存在一个.adv文件中,你可以打开它,从你离开的地方继续你的游戏。我在TextEdit中打开了它(将其更改为.txt文件),它看起来像是一大堆天知道什么语言的编码文本。我附上了一张图片

https://i.stack.imgur.com/RkBlb.png

以及谷歌云端硬盘上指向.txt文件的链接

https://drive.google.com/file/d/1Ku4QO4cpx61X8mS9bBgGK3AyViczczNl/view?usp=sharing 出于某种原因,谷歌驱动器预览看起来像中文或其他语言,但如果您下载.txt,您将看到它与 igmur 图片相同。

我使用以下命令通过python运行该文件: import io with io.open(filename, 'rb') as f: text = f.read()

text给了我这个: https://drive.google.com/file/d/1KyjdPxUDkBy5ATZfg1GdIexeP9nK-Km6/view?usp=sharing

只是它的一个示例(单击上面的链接查看完整文件): b'\xc1\xdfd\x00\x84K\xfd\xcb\xff\x93\xcb\xf9\x90\\xa9\xd5\xdb\x10\xaf\xdb\xb5{_\xd1\xf9\xcaw\xd2\xc13\x8e\xd1\xd6\x06\xce\xe3V\xd0\xa8

尝试用Python解码它给了我这个错误:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc1 in position 0: invalid start byte

我尝试了很多种解码方法,但它们都失败了。我需要将其解码为可读的内容。我怎么做,它是什么"文本语言"?

谢谢

没有什么比在经典游戏中进行黑客攻击和闲逛更像了。

哪个版本? 原版是用Fortran编写的,并在PDP-11上运行。 所以,这不是你得到的那个。

也许你有最新的OSS? https://gitlab.com/esr/open-adventure

所以,你需要看看游戏的具体实现,并获取它用来保存游戏状态的数据结构。

这是您要执行的操作:

git clone https://gitlab.com/esr/open-adventure.git open-adventure
make
./advent

这将运行游戏并将您置于其中。

Welcome to Adventure!!  Would you like instructions?
> no
You are standing at the end of a road before a small brick building.
Around you is a forest.  A small stream flows out of the building and
down a gully.
> save
I can suspend your Adventure for you so that you can resume later, but
it will cost you 5 points.
Is this acceptable?
> yes
OK
File name: saved_game
Richs-MBP:open-adventure randrews$ ls -l saved_game 
-rw-r--r--  1 randrews  staff  3192 Mar 18 19:11 saved_game
Richs-MBP:open-adventure randrews$ file saved_game
saved_game: data
Richs-MBP:open-adventure randrews$ strings saved_game
E'HTH

这是二进制的好吧。所以我们追寻游戏来源。

saveresume.c是一个很好的起点。

在代码中找到struct game_t的引用,suspend()游戏。该结构在advent.h中定义

它看起来像:

struct game_t {
int32_t lcg_x;
int abbnum;                  // How often to print int descriptions
score_t bonus;               // What kind of finishing bonus we are getting
loc_t chloc;                 // pirate chest location
loc_t chloc2;                // pirate chest alternate location
turn_t clock1;               // # turns from finding last treasure to close
turn_t clock2;               // # turns from warning till blinding flash
bool clshnt;                 // has player read the clue in the endgame?
bool closed;                 // whether we're all the way closed
bool closng;                 // whether it's closing time yet
bool lmwarn;                 // has player been warned about lamp going dim?
bool novice;                 // asked for instructions at start-up?
bool panic;                  // has player found out he's trapped?
bool wzdark;                 // whether the loc he's leaving was dark
bool blooded;                // has player drunk of dragon's blood?
... it is big! ...
obj_t link[NOBJECTS * 2 + 1];// object-list links
loc_t place[NOBJECTS + 1];   // location of object
int hinted[NHINTS];          // hinted[i] = true iff hint i has been used.
int hintlc[NHINTS];          // hintlc[i] = how int at LOC with cond bit i
int prop[NOBJECTS + 1];      // object state array */
};

这就是您文件中的内容。 玩得开心 游戏 C 代码并使用暂停/恢复功能加载您保存的文件并破解它,让您喝了龙血!

最新更新