반응형

Explains how to make a game(Prince of Persia) save file editor with C++.

C++를 이용한 간단한 게임 세이브 파일 에디터 소스.

 

#include <iostream>
#include <fstream>

using namespace std;

int main(int argc, char* argv[])
{
    if (argc != 3)
    {
        cout << "Usage : " << argv[0] << " [save file name] [energy]" << endl;
        cout << "Example: " << argv[0] << " prince.sav 8" << endl;
        return -1;
    }

    short value = atoi(argv[2]); // 2 byte value (for 16 bit old dos game)

    ofstream fout(argv[1], ios_base::binary | ios_base::out | ios_base::in);
    if (!fout.is_open())
    {
        cout << "Can't find " << argv[1] << endl;
        return -1;
    }

    fout.seekp(0x06, ios_base::beg); // Prince's energy saved at 0x06~0x07 (2 byte)
    fout.write((char*)& value, sizeof(short)); // 2 byte

    fout.close();

    cout << "Success!" << endl;

    return 0;
}

 

 

 

 

반응형
Posted by J-sean
: