[英]Colossal Cave Adventure File: Decode From Binary (?) to readable format (Python)
我相信你們很多人都知道 1976 年的游戲 Colossal Cave Adventure。 我在 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
是一個很好的起點。
我們在游戲suspend()
的代碼中找到了對struct game_t
的引用。 該結構在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 代碼並使用掛起/恢復功能加載您保存的文件並破解它,以便您喝龍血!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.