mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-14 17:33:25 +00:00
Update buffer.
This commit is contained in:
parent
8933e1203e
commit
4515228ca6
7 changed files with 24 additions and 19 deletions
|
|
@ -100,14 +100,14 @@ buffer::buffer(const buffer &rhs, uint32_t size, uint32_t offset)
|
|||
std::string buffer::read_string(uint32_t blocksize) const
|
||||
{
|
||||
std::vector<uint8_t> data(blocksize);
|
||||
read(data.data(), data.size());
|
||||
_read(data.data(), data.size());
|
||||
return (const char *)data.data();
|
||||
}
|
||||
|
||||
std::wstring buffer::read_wstring(uint32_t blocksize) const
|
||||
{
|
||||
std::vector<uint16_t> data(blocksize);
|
||||
read(data.data(), data.size());
|
||||
_read(data.data(), data.size());
|
||||
return (const wchar_t *)data.data();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#define READ(b, var) b.read(&var)
|
||||
#define READ_N(b, var, sz) b.read(&var, sz)
|
||||
#define READ(b, var) b.read(var)
|
||||
#define READ_N(b, var, sz) b.read(var, sz)
|
||||
|
||||
#define READ_STRING(b, var) var = b.read_string()
|
||||
#define READ_STRING_N(b, var, sz) var = b.read_string(sz)
|
||||
|
|
@ -50,9 +50,9 @@ public:
|
|||
buffer(const buffer &rhs, uint32_t size, uint32_t offset);
|
||||
|
||||
template <typename T>
|
||||
uint32_t read(T *dst, uint32_t size = 1) const
|
||||
uint32_t read(T &dst, uint32_t size = 1) const
|
||||
{
|
||||
return _read((void *)dst, size * sizeof(T), 0);
|
||||
return _read((void *)&dst, size * sizeof(T), 0);
|
||||
}
|
||||
std::string read_string(uint32_t blocksize = 0x20) const;
|
||||
std::wstring read_wstring(uint32_t blocksize = 0x20) const;
|
||||
|
|
@ -102,16 +102,16 @@ public:
|
|||
void read_vector(std::vector<T> &v) const
|
||||
{
|
||||
SizeType n = 0;
|
||||
read(&n);
|
||||
read(n);
|
||||
read_vector<T, SizeType>(v, n);
|
||||
}
|
||||
|
||||
std::string read_pascal_string() const
|
||||
{
|
||||
uint32_t n = 0;
|
||||
read(&n);
|
||||
read(n);
|
||||
std::string s(n, 0);
|
||||
read(s.data(), n);
|
||||
_read(s.data(), n);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
@ -128,6 +128,9 @@ public:
|
|||
|
||||
const uint8_t *getPtr() const { return ptr; }
|
||||
|
||||
uint32_t _read(void *dst, uint32_t size, uint32_t offset = 0) const;
|
||||
uint32_t _write(const void *src, uint32_t size);
|
||||
|
||||
private:
|
||||
std::shared_ptr<std::vector<uint8_t>> buf_;
|
||||
mutable uint32_t index_ = 0;
|
||||
|
|
@ -135,7 +138,4 @@ private:
|
|||
mutable uint32_t data_offset = 0;
|
||||
mutable uint32_t size_ = 0;
|
||||
uint32_t end_;
|
||||
|
||||
uint32_t _read(void *dst, uint32_t size, uint32_t offset = 0) const;
|
||||
uint32_t _write(const void *src, uint32_t size);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include <primitives/executor.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <math.h>
|
||||
|
|
@ -299,7 +300,7 @@ try
|
|||
// to check correctness
|
||||
process_lang(*storage.get(), d / "ru", &polygon4::LocalizedString::ru);
|
||||
|
||||
for (auto &f : boost::make_iterator_range(fs::directory_iterator(d), {}))
|
||||
for (auto &f : fs::directory_iterator(d))
|
||||
{
|
||||
if (!fs::is_directory(f))
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -80,14 +80,14 @@ std::string translate(const std::string &s)
|
|||
template <typename T>
|
||||
void aim_vector3<T>::load(const buffer &b)
|
||||
{
|
||||
READ(b, x);
|
||||
READ(b, z);
|
||||
READ(b, y);
|
||||
READ(b, base::x);
|
||||
READ(b, base::z);
|
||||
READ(b, base::y);
|
||||
}
|
||||
|
||||
void aim_vector4::load(const buffer &b, uint32_t flags)
|
||||
{
|
||||
aim_vector3::load(b);
|
||||
base::load(b);
|
||||
if (flags & F_USE_W_COORDINATE)
|
||||
READ(b, w);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,11 +80,15 @@ enum class MaterialType : uint32_t
|
|||
template <typename T>
|
||||
struct aim_vector3 : vector3<T>
|
||||
{
|
||||
using base = vector3<T>;
|
||||
|
||||
void load(const buffer &b);
|
||||
};
|
||||
|
||||
struct aim_vector4 : aim_vector3<float>
|
||||
{
|
||||
using base = aim_vector3<float>;
|
||||
|
||||
float w = 1.0f;
|
||||
|
||||
std::string print() const;
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ struct screen_segment : public segment
|
|||
|
||||
void load(const buffer &b)
|
||||
{
|
||||
b.read((uint8_t*)screenshot.getData().data(), screenshot.getBytesLength());
|
||||
b._read((uint8_t*)screenshot.getData().data(), screenshot.getBytesLength());
|
||||
// rows should be swapped now: bottom is the first row etc.
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ void convert(const path &fn)
|
|||
READ(src, width);
|
||||
READ(src, height);
|
||||
src.seek(0x10);
|
||||
src.read(&dxt5_flag, 1);
|
||||
src._read(&dxt5_flag, 1);
|
||||
src.seek(0x4C);
|
||||
|
||||
auto s = fn.string() + ".bmp";
|
||||
|
|
|
|||
Loading…
Reference in a new issue