mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-15 01:43:25 +00:00
Format pak.h. Update to the latest data manager.
This commit is contained in:
parent
26588ebbfd
commit
540af823f4
4 changed files with 271 additions and 275 deletions
|
|
@ -154,7 +154,7 @@ void write_mmo(std::string db, const storage &s)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bld_ids[o] = iter->getId();
|
bld_ids[o] = iter->second->getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto &object : segment->objects)
|
for (auto &object : segment->objects)
|
||||||
|
|
@ -178,11 +178,11 @@ void write_mmo(std::string db, const storage &s)
|
||||||
mb.scale = ASSIGN(object->m_rotate_z[2].z, 1);
|
mb.scale = ASSIGN(object->m_rotate_z[2].z, 1);
|
||||||
auto i = find_if(storage->mapBuildings.begin(), storage->mapBuildings.end(), [&](const auto &p)
|
auto i = find_if(storage->mapBuildings.begin(), storage->mapBuildings.end(), [&](const auto &p)
|
||||||
{
|
{
|
||||||
return *p.second.get() == mb;
|
return *p.second == mb;
|
||||||
});
|
});
|
||||||
if (i == storage->mapBuildings.end())
|
if (i == storage->mapBuildings.end())
|
||||||
{
|
{
|
||||||
auto mb2 = storage->addMapBuilding(storage->maps[map_id].get());
|
auto mb2 = storage->addMapBuilding(storage->maps[map_id]);
|
||||||
mb.setId(mb2->getId());
|
mb.setId(mb2->getId());
|
||||||
*mb2 = mb;
|
*mb2 = mb;
|
||||||
inserted++;
|
inserted++;
|
||||||
|
|
@ -216,7 +216,7 @@ void write_mmo(std::string db, const storage &s)
|
||||||
bld_ids[o] = bld->getId();
|
bld_ids[o] = bld->getId();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
bld_ids[o] = iter->getId();
|
bld_ids[o] = iter->second->getId();
|
||||||
}
|
}
|
||||||
for (auto &object : segment->objects)
|
for (auto &object : segment->objects)
|
||||||
{
|
{
|
||||||
|
|
@ -239,11 +239,11 @@ void write_mmo(std::string db, const storage &s)
|
||||||
mb.scale = ASSIGN(object->m_rotate_z[2].z, 1);
|
mb.scale = ASSIGN(object->m_rotate_z[2].z, 1);
|
||||||
auto i = find_if(storage->mapObjects.begin(), storage->mapObjects.end(), [&](const auto &p)
|
auto i = find_if(storage->mapObjects.begin(), storage->mapObjects.end(), [&](const auto &p)
|
||||||
{
|
{
|
||||||
return *p.second.get() == mb;
|
return *p.second == mb;
|
||||||
});
|
});
|
||||||
if (i == storage->mapObjects.end())
|
if (i == storage->mapObjects.end())
|
||||||
{
|
{
|
||||||
auto mb2 = storage->addMapObject(storage->maps[map_id].get());
|
auto mb2 = storage->addMapObject(storage->maps[map_id]);
|
||||||
mb.setId(mb2->getId());
|
mb.setId(mb2->getId());
|
||||||
*mb2 = mb;
|
*mb2 = mb;
|
||||||
inserted++;
|
inserted++;
|
||||||
|
|
|
||||||
|
|
@ -4,37 +4,39 @@
|
||||||
#define _WORD uint16_t
|
#define _WORD uint16_t
|
||||||
#define _DWORD uint32_t
|
#define _DWORD uint32_t
|
||||||
|
|
||||||
#define LOBYTE(x) (*((_BYTE*)&(x)))
|
#define LOBYTE(x) (*((_BYTE *)&(x)))
|
||||||
#define LOWORD(x) (*((_WORD*)&(x)))
|
#define LOWORD(x) (*((_WORD *)&(x)))
|
||||||
#define HIBYTE(x) (*((_BYTE*)&(x)+1))
|
#define HIBYTE(x) (*((_BYTE *)&(x) + 1))
|
||||||
|
|
||||||
#define BYTEn(x, n) (*((_BYTE*)&(x)+n))
|
#define BYTEn(x, n) (*((_BYTE *)&(x) + n))
|
||||||
#define BYTE1(x) BYTEn(x, 1)
|
#define BYTE1(x) BYTEn(x, 1)
|
||||||
|
|
||||||
template<class T> int8_t __SETS__(T x)
|
template <class T>
|
||||||
|
int8_t __SETS__(T x)
|
||||||
{
|
{
|
||||||
if ( sizeof(T) == 1 )
|
if (sizeof(T) == 1)
|
||||||
return int8_t(x) < 0;
|
return int8_t(x) < 0;
|
||||||
if ( sizeof(T) == 2 )
|
if (sizeof(T) == 2)
|
||||||
return int16_t(x) < 0;
|
return int16_t(x) < 0;
|
||||||
if ( sizeof(T) == 4 )
|
if (sizeof(T) == 4)
|
||||||
return int32_t(x) < 0;
|
return int32_t(x) < 0;
|
||||||
return int64_t(x) < 0;
|
return int64_t(x) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class U> int8_t __OFSUB__(T x, U y)
|
template <class T, class U>
|
||||||
|
int8_t __OFSUB__(T x, U y)
|
||||||
{
|
{
|
||||||
if ( sizeof(T) < sizeof(U) )
|
if (sizeof(T) < sizeof(U))
|
||||||
{
|
{
|
||||||
U x2 = x;
|
U x2 = x;
|
||||||
int8_t sx = __SETS__(x2);
|
int8_t sx = __SETS__(x2);
|
||||||
return (sx ^ __SETS__(y)) & (sx ^ __SETS__(x2-y));
|
return (sx ^ __SETS__(y)) & (sx ^ __SETS__(x2 - y));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
T y2 = y;
|
T y2 = y;
|
||||||
int8_t sx = __SETS__(x);
|
int8_t sx = __SETS__(x);
|
||||||
return (sx ^ __SETS__(y2)) & (sx ^ __SETS__(x-y2));
|
return (sx ^ __SETS__(y2)) & (sx ^ __SETS__(x - y2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,27 +64,27 @@ char *decode_f1(char *input, int size, char *output)
|
||||||
result = input;
|
result = input;
|
||||||
v4 = &input[size];
|
v4 = &input[size];
|
||||||
v5 = 8;
|
v5 = 8;
|
||||||
if ( input < &input[size] )
|
if (input < &input[size])
|
||||||
{
|
{
|
||||||
v6 = output;
|
v6 = output;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if ( v5 == 8 )
|
if (v5 == 8)
|
||||||
{
|
{
|
||||||
v7 = (char *)(uint8_t)*result++;
|
v7 = (char *)(uint8_t)*result++;
|
||||||
v5 = 0;
|
v5 = 0;
|
||||||
input = v7;
|
input = v7;
|
||||||
if ( result == v4 )
|
if (result == v4)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( (uint8_t)input & 1 )
|
if ((uint8_t)input & 1)
|
||||||
{
|
{
|
||||||
v8 = (uint8_t)*result;
|
v8 = (uint8_t)*result;
|
||||||
v9 = (uint8_t)result[1];
|
v9 = (uint8_t)result[1];
|
||||||
result += 2;
|
result += 2;
|
||||||
v10 = ((v8 & 0xF) << 8) + v9;
|
v10 = ((v8 & 0xF) << 8) + v9;
|
||||||
v11 = (v8 >> 4) + 4;
|
v11 = (v8 >> 4) + 4;
|
||||||
if ( v11 )
|
if (v11)
|
||||||
{
|
{
|
||||||
v12 = &v6[-v10];
|
v12 = &v6[-v10];
|
||||||
v13 = v11;
|
v13 = v11;
|
||||||
|
|
@ -90,8 +92,7 @@ char *decode_f1(char *input, int size, char *output)
|
||||||
{
|
{
|
||||||
*v6++ = *v12++;
|
*v6++ = *v12++;
|
||||||
--v13;
|
--v13;
|
||||||
}
|
} while (v13);
|
||||||
while ( v13 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -100,8 +101,7 @@ char *decode_f1(char *input, int size, char *output)
|
||||||
}
|
}
|
||||||
++v5;
|
++v5;
|
||||||
input = (char *)((signed int)input >> 1);
|
input = (char *)((signed int)input >> 1);
|
||||||
}
|
} while (result < v4);
|
||||||
while ( result < v4 );
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -121,23 +121,23 @@ char decode_f2(char *input, int size, char *output)
|
||||||
LOBYTE(c) = size;
|
LOBYTE(c) = size;
|
||||||
v4 = *input;
|
v4 = *input;
|
||||||
v5 = input + 1;
|
v5 = input + 1;
|
||||||
if ( input + 1 < &input[size] )
|
if (input + 1 < &input[size])
|
||||||
{
|
{
|
||||||
v6 = output;
|
v6 = output;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
LOBYTE(c) = *v5;
|
LOBYTE(c) = *v5;
|
||||||
if ( *v5 == v4 )
|
if (*v5 == v4)
|
||||||
{
|
{
|
||||||
c = (uint8_t)v5[1];
|
c = (uint8_t)v5[1];
|
||||||
v7 = v5 + 1;
|
v7 = v5 + 1;
|
||||||
c_1 = (uint8_t)v7[1];
|
c_1 = (uint8_t)v7[1];
|
||||||
v5 = v7 + 2;
|
v5 = v7 + 2;
|
||||||
if ( c != 255 || c_1 != 255 )
|
if (c != 255 || c_1 != 255)
|
||||||
{
|
{
|
||||||
c_2 = ((c & 0xF) << 8) + c_1;
|
c_2 = ((c & 0xF) << 8) + c_1;
|
||||||
c = (c >> 4) + 4;
|
c = (c >> 4) + 4;
|
||||||
if ( c )
|
if (c)
|
||||||
{
|
{
|
||||||
v10 = &v6[-c_2];
|
v10 = &v6[-c_2];
|
||||||
c_3 = c;
|
c_3 = c;
|
||||||
|
|
@ -146,8 +146,7 @@ char decode_f2(char *input, int size, char *output)
|
||||||
LOBYTE(c) = *v10;
|
LOBYTE(c) = *v10;
|
||||||
*v6++ = *v10++;
|
*v6++ = *v10++;
|
||||||
--c_3;
|
--c_3;
|
||||||
}
|
} while (c_3);
|
||||||
while ( c_3 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -160,8 +159,7 @@ char decode_f2(char *input, int size, char *output)
|
||||||
*v6++ = c;
|
*v6++ = c;
|
||||||
++v5;
|
++v5;
|
||||||
}
|
}
|
||||||
}
|
} while (v5 < &input[size]);
|
||||||
while ( v5 < &input[size] );
|
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
@ -200,20 +198,20 @@ int decode_f3(char *input, int size, char *output)
|
||||||
v22 = size >> 1;
|
v22 = size >> 1;
|
||||||
v10 = s;
|
v10 = s;
|
||||||
v21 = s;
|
v21 = s;
|
||||||
if ( !((uint8_t)(v8 ^ v9) | v7) )
|
if (!((uint8_t)(v8 ^ v9) | v7))
|
||||||
{
|
{
|
||||||
v11 = output;
|
v11 = output;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
v12 = *(_WORD *)&v4[2 * idx];
|
v12 = *(_WORD *)&v4[2 * idx];
|
||||||
if ( (*(_WORD *)&v4[2 * idx] & 0xFF00) == (_WORD)v10 )
|
if ((*(_WORD *)&v4[2 * idx] & 0xFF00) == (_WORD)v10)
|
||||||
{
|
{
|
||||||
v13 = *(_WORD *)&v4[2 * idx++];
|
v13 = *(_WORD *)&v4[2 * idx++];
|
||||||
if ( v12 != (uint16_t)v10 + 255 )
|
if (v12 != (uint16_t)v10 + 255)
|
||||||
{
|
{
|
||||||
v14 = *(_WORD *)&v4[2 * idx];
|
v14 = *(_WORD *)&v4[2 * idx];
|
||||||
v15 = v13 + 3;
|
v15 = v13 + 3;
|
||||||
if ( (signed int)v15 > 0 )
|
if ((signed int)v15 > 0)
|
||||||
{
|
{
|
||||||
LOWORD(v10) = *(_WORD *)&v4[2 * idx];
|
LOWORD(v10) = *(_WORD *)&v4[2 * idx];
|
||||||
v16 = v11;
|
v16 = v11;
|
||||||
|
|
@ -224,7 +222,7 @@ int decode_f3(char *input, int size, char *output)
|
||||||
v10 = v21;
|
v10 = v21;
|
||||||
memset32(v16, v18, v15 >> 1);
|
memset32(v16, v18, v15 >> 1);
|
||||||
v19 = (int)((char *)v16 + 4 * (v15 >> 1));
|
v19 = (int)((char *)v16 + 4 * (v15 >> 1));
|
||||||
for ( i = (v13 + 3) & 1; i; --i )
|
for (i = (v13 + 3) & 1; i; --i)
|
||||||
{
|
{
|
||||||
*(_WORD *)v19 = v18;
|
*(_WORD *)v19 = v18;
|
||||||
v19 += 2;
|
v19 += 2;
|
||||||
|
|
@ -240,11 +238,10 @@ int decode_f3(char *input, int size, char *output)
|
||||||
*(_WORD *)v11 = v12;
|
*(_WORD *)v11 = v12;
|
||||||
}
|
}
|
||||||
v11 += 2;
|
v11 += 2;
|
||||||
LABEL_13:
|
LABEL_13:
|
||||||
result = v22;
|
result = v22;
|
||||||
++idx;
|
++idx;
|
||||||
}
|
} while (idx < v22);
|
||||||
while ( idx < v22 );
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -268,25 +265,25 @@ int decode_f4(char *input, int size, char *output, int segment_offset)
|
||||||
in1 = *input;
|
in1 = *input;
|
||||||
ptr = 1;
|
ptr = 1;
|
||||||
in2 = *input;
|
in2 = *input;
|
||||||
if ( size > 1 )
|
if (size > 1)
|
||||||
{
|
{
|
||||||
out1 = output;
|
out1 = output;
|
||||||
while ( 1 )
|
while (1)
|
||||||
{
|
{
|
||||||
c = in3[ptr];
|
c = in3[ptr];
|
||||||
if ( c != in1 )
|
if (c != in1)
|
||||||
break;
|
break;
|
||||||
c_next = in3[ptr++ + 1];
|
c_next = in3[ptr++ + 1];
|
||||||
if ( c_next == -1 )
|
if (c_next == -1)
|
||||||
{
|
{
|
||||||
*out1 = in1;
|
*out1 = in1;
|
||||||
LABEL_9:
|
LABEL_9:
|
||||||
++out1;
|
++out1;
|
||||||
goto LABEL_10;
|
goto LABEL_10;
|
||||||
}
|
}
|
||||||
v11 = in3[ptr++ + 1];
|
v11 = in3[ptr++ + 1];
|
||||||
c_prev = (uint8_t)c_next + 3;
|
c_prev = (uint8_t)c_next + 3;
|
||||||
if ( (signed int)c_prev > 0 )
|
if ((signed int)c_prev > 0)
|
||||||
{
|
{
|
||||||
LOBYTE(segment_offset) = v11;
|
LOBYTE(segment_offset) = v11;
|
||||||
BYTE1(segment_offset) = v11;
|
BYTE1(segment_offset) = v11;
|
||||||
|
|
@ -297,12 +294,12 @@ LABEL_9:
|
||||||
in3 = input;
|
in3 = input;
|
||||||
memset(&out1[4 * (c_prev >> 2)], v13, c_prev & 3);
|
memset(&out1[4 * (c_prev >> 2)], v13, c_prev & 3);
|
||||||
out1 = &output[c_prev];
|
out1 = &output[c_prev];
|
||||||
LABEL_10:
|
LABEL_10:
|
||||||
output = out1;
|
output = out1;
|
||||||
}
|
}
|
||||||
result = size;
|
result = size;
|
||||||
++ptr;
|
++ptr;
|
||||||
if ( ptr >= size )
|
if (ptr >= size)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
*out1 = c;
|
*out1 = c;
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,14 @@ void unpak(string fn)
|
||||||
return;
|
return;
|
||||||
pak p;
|
pak p;
|
||||||
p.load(f);
|
p.load(f);
|
||||||
auto read_write_any_file = [&](record &file)
|
for (auto &f : p.files)
|
||||||
{
|
{
|
||||||
|
record &file = f.second;
|
||||||
cout << "Unpacking " << file.name << "\n";
|
cout << "Unpacking " << file.name << "\n";
|
||||||
vector<char> buf(file.len);
|
vector<char> buf(file.len);
|
||||||
file.read(&p, &buf[0], file.len);
|
file.read(&p, &buf[0], file.len);
|
||||||
file.write(fn + ".dir", buf);
|
file.write(fn + ".dir", buf);
|
||||||
};
|
};
|
||||||
for (auto &f : p.files)
|
|
||||||
read_write_any_file(f.second);
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue