C, C++
How to make a game save file editor 간단한 게임 에디터 만들기
J-sean
2019. 6. 30. 12:11
반응형
Explains how to make a game(Prince of Persia) save file editor with C++.
C++를 이용한 간단한 게임 세이브 파일 에디터 소스 입니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #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; } | cs |
반응형