将迷你世界的蓝图导出成表格
使用方法为编译此代码,然后将游戏存档的vbp文件拖入编译出的exe上即可导出csv文件
#include<iostream>
#include<Windows.h>
#include<direct.h>
#include<io.h>
using namespace std;
#define N_L 4
//这个改为用户的名字长度
string UTF8toANSI(const char* utf8)
{int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0);wchar_t* wstr = new wchar_t[len + 1];memset(wstr, 0, len + 1);MultiByteToWideChar(CP_UTF8, 0, utf8, -1, wstr, len);len = WideCharToMultiByte(CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL);char* str = new char[len + 1];memset(str, 0, len + 1);WideCharToMultiByte(CP_ACP, 0, wstr, -1, str, len, NULL, NULL);if (wstr) delete[] wstr;string ret = str;if (str) delete[] str;return ret;
}
int count_i = 0;
void outfile(const char*filename,FILE*tp)
{char name[1024];memset(name, 0, 1024);strcpy(name, filename);int len = strlen(name);if (name[len - 1] != 'p'){for (int i = len - 1; i >= 0; i--){if (name[i] == '\\'){++i;name[len] = '\\';for (int j = 1; i < len; i++, j++){name[len + j] = name[i];}strcat(name, ".vbp");break;}}}FILE *fp = fopen(name, "rb");char reader[16];fread(reader, 1, 16, fp);unsigned char s = reader[6];int ttt = (int)s & 0xFF;ttt -= 48;fread(reader, 1, 16, fp);fread(reader, 1, 16, fp);fread(reader, 1, 16, fp);fread(reader, 1, 16, fp);fseek(fp, ttt, 1);char *bpname = new char[32];fread(bpname, 1, 32, fp);//开始获取名称for (int i = 0; i <32; i++)if (bpname[i] == 0){for (; i < 32; i++)bpname[i] = 0;break;}string bp_name = bpname;len = ((N_L + 1) * 4);fread(bpname, 1, len, fp);for (int i = 0; i <len; i++)if (bpname[i] == 0){for (; i < len; i++)bpname[i] = 0;break;}std::string h = UTF8toANSI(bpname);h.clear();fread(bpname, 1, 32, fp);for (int i = 0; i <32; i++)if (bpname[i] == 0){for (; i < 32; i++)bpname[i] = 0;break;}h = UTF8toANSI(bpname);string bp_c_name= h;fclose(fp);delete bpname;if (count_i % 3 == 0)fprintf(tp, "\n");fprintf(tp,"%s,\"0,%s\",", bp_c_name.data(), bp_name.data());
}
void main(int argc,char **argv)
{if (argc != 2)return;_finddata_t file;long id;string h = argv[1];id =_findfirst((h+"\\*").data(), &file);if (id == -1)return;FILE*fp = fopen("out.csv", "w");while (_findnext(id, &file)==0){if (file.name[0] == 'b'&&file.name[1] == 'p'){printf("%s\n", file.name);outfile((h + "\\" + file.name).data(), fp);count_i++;}}fclose(fp);getchar();
}
效果就是这样,可以看到蓝图名字对应的ID