mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 02:12:45 +01:00
Initial commit
This commit is contained in:
commit
477e9ff3d5
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
build/
|
||||||
|
gtfw.kdev4
|
||||||
|
*~
|
||||||
|
|
5
CMakeLists.txt
Normal file
5
CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
project(gtfw)
|
||||||
|
|
||||||
|
SET(CMAKE_CXX_FLAGS "-std=c++11")
|
||||||
|
|
||||||
|
add_subdirectory(datadump)
|
3
datadump/CMakeLists.txt
Normal file
3
datadump/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
add_executable(datadump main.cpp)
|
||||||
|
|
||||||
|
install(TARGETS datadump RUNTIME DESTINATION bin)
|
50
datadump/main.cpp
Normal file
50
datadump/main.cpp
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include "../framework/rwbinarystream.h"
|
||||||
|
|
||||||
|
using RW::BSSectionHeader;
|
||||||
|
using RW::BSClump;
|
||||||
|
|
||||||
|
template<class T> T readStructure(char* data, size_t& dataI)
|
||||||
|
{
|
||||||
|
size_t orgoff = dataI; dataI += sizeof(T);
|
||||||
|
return *reinterpret_cast<T*>(data+orgoff);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
for(int i = 1; i < argc; ++i)
|
||||||
|
{
|
||||||
|
std::ifstream dfile(argv[i]);
|
||||||
|
if(!dfile.is_open()) {
|
||||||
|
std::cerr << "Error opening file " << argv[i] << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
dfile.seekg(0, std::ios_base::end);
|
||||||
|
size_t length = dfile.tellg();
|
||||||
|
dfile.seekg(0);
|
||||||
|
char* data = new char[length];
|
||||||
|
dfile.read(data, length);
|
||||||
|
size_t dataI = 0;
|
||||||
|
|
||||||
|
BSSectionHeader first = readStructure<BSSectionHeader>(data, dataI);
|
||||||
|
|
||||||
|
std::cout << "ID = " << std::hex << (unsigned long)first.id << " (IsClump = " << (first.id == RW::SID_Clump) << ")" << std::endl;
|
||||||
|
std::cout << "Size = " << std::dec << (unsigned long)first.size << " bytes" << std::endl;
|
||||||
|
std::cout << "Version ID = " << std::hex << (unsigned long)first.versionid << std::endl;
|
||||||
|
|
||||||
|
if(first.id == RW::SID_Clump)
|
||||||
|
{
|
||||||
|
BSClump clump = readStructure<BSClump>(data, dataI);
|
||||||
|
std::cout << " Clump Data" << std::endl;
|
||||||
|
std::cout << " Atomics = " << std::dec << (unsigned long)clump.numatomics << std::endl;
|
||||||
|
std::cout << " Lights = " << std::dec << (unsigned long)clump.numlights << std::endl;
|
||||||
|
std::cout << " Cameras = " << std::dec << (unsigned long)clump.numcameras << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
17
framework/gtfwpre.h
Normal file
17
framework/gtfwpre.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef _GTFWPRE_H_
|
||||||
|
#define _GTFWPRE_H_
|
||||||
|
|
||||||
|
// Useful includes
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
// Useful global imports
|
||||||
|
using std::int8_t;
|
||||||
|
using std::int16_t;
|
||||||
|
using std::int32_t;
|
||||||
|
using std::int64_t;
|
||||||
|
using std::uint8_t;
|
||||||
|
using std::uint16_t;
|
||||||
|
using std::uint32_t;
|
||||||
|
using std::uint64_t;
|
||||||
|
|
||||||
|
#endif
|
36
framework/rwbinarystream.h
Normal file
36
framework/rwbinarystream.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifndef _RWBINARYSTREAM_H_
|
||||||
|
#define _RWBINARYSTREAM_H_
|
||||||
|
#include "gtfwpre.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file rwbinarystream.h
|
||||||
|
* Contains the structs for the shared Render Ware binary stream data.
|
||||||
|
* Many thanks to http://www.gtamodding.com/index.php?title=RenderWare_binary_stream_file
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace RW
|
||||||
|
{
|
||||||
|
enum {
|
||||||
|
SID_Struct = 0x0001,
|
||||||
|
SID_String = 0x0002,
|
||||||
|
SID_Extension = 0x0003,
|
||||||
|
|
||||||
|
SID_Clump = 0x0010
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BSSectionHeader
|
||||||
|
{
|
||||||
|
uint32_t id;
|
||||||
|
uint32_t size;
|
||||||
|
uint32_t versionid;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BSClump
|
||||||
|
{
|
||||||
|
uint32_t numatomics;
|
||||||
|
uint32_t numlights;
|
||||||
|
uint32_t numcameras;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user