mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-15 01:43:25 +00:00
Add script2txt.
This commit is contained in:
parent
5875885b0b
commit
829d12f4bd
3 changed files with 78 additions and 11 deletions
|
|
@ -6,3 +6,6 @@ add_executable(db_extractor ${db_extractor_src})
|
||||||
|
|
||||||
file(GLOB obj_extractor_src "obj_extractor/*")
|
file(GLOB obj_extractor_src "obj_extractor/*")
|
||||||
add_executable(obj_extractor ${obj_extractor_src})
|
add_executable(obj_extractor ${obj_extractor_src})
|
||||||
|
|
||||||
|
file(GLOB script2txt_src "script2txt/*")
|
||||||
|
add_executable(script2txt ${script2txt_src})
|
||||||
|
|
|
||||||
|
|
@ -91,21 +91,23 @@ struct SegmentObjects : public Segment
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Vector4
|
||||||
|
{
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
float w;
|
||||||
|
};
|
||||||
|
|
||||||
struct Common
|
struct Common
|
||||||
{
|
{
|
||||||
float unk2[2];
|
Vector4 m_rotate_z[3];
|
||||||
uint32_t unk3[2];
|
Vector4 position;
|
||||||
float unk4[2];
|
|
||||||
uint32_t unk5[2];
|
|
||||||
float unk6[8];
|
|
||||||
|
|
||||||
void load(FILE *f)
|
void load(FILE *f)
|
||||||
{
|
{
|
||||||
FREAD(unk2);
|
FREAD(m_rotate_z);
|
||||||
FREAD(unk3);
|
FREAD(position);
|
||||||
FREAD(unk4);
|
|
||||||
FREAD(unk5);
|
|
||||||
FREAD(unk6);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
62
src/script2txt/script2txt.cpp
Normal file
62
src/script2txt/script2txt.cpp
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* AIM script2txt
|
||||||
|
* Copyright (C) 2015 lzwdgc
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if (argc != 2)
|
||||||
|
{
|
||||||
|
cout << "Usage:\n" << argv[0] << " script.scr";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
string path = argv[1];
|
||||||
|
FILE *f = fopen(path.c_str(), "rb");
|
||||||
|
if (!f)
|
||||||
|
{
|
||||||
|
cout << "Cannot open the file: " << argv[1];
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
uint32_t size = 0;
|
||||||
|
uint32_t dummy = 0;
|
||||||
|
fread(&size, sizeof(uint32_t), 1, f);
|
||||||
|
fread(&size, sizeof(uint32_t), 1, f);
|
||||||
|
fread(&size, sizeof(uint32_t), 1, f);
|
||||||
|
fread(&dummy, sizeof(uint32_t), 1, f);
|
||||||
|
string buf(size, 0);
|
||||||
|
fread(&buf[0], size, 1, f);
|
||||||
|
fclose(f);
|
||||||
|
path += ".txt";
|
||||||
|
f = fopen(path.c_str(), "w");
|
||||||
|
if (!f)
|
||||||
|
{
|
||||||
|
cout << "Cannot open the file: " << argv[1];
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
const char *ptr = &buf[0];
|
||||||
|
while (ptr < &buf[0] + size)
|
||||||
|
{
|
||||||
|
fprintf(f, "%s\n", ptr);
|
||||||
|
ptr += strlen(ptr) + 1;
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue