mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-14 17:33: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
|
||||
{
|
||||
bld_ids[o] = iter->getId();
|
||||
bld_ids[o] = iter->second->getId();
|
||||
}
|
||||
}
|
||||
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);
|
||||
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())
|
||||
{
|
||||
auto mb2 = storage->addMapBuilding(storage->maps[map_id].get());
|
||||
auto mb2 = storage->addMapBuilding(storage->maps[map_id]);
|
||||
mb.setId(mb2->getId());
|
||||
*mb2 = mb;
|
||||
inserted++;
|
||||
|
|
@ -216,7 +216,7 @@ void write_mmo(std::string db, const storage &s)
|
|||
bld_ids[o] = bld->getId();
|
||||
}
|
||||
else
|
||||
bld_ids[o] = iter->getId();
|
||||
bld_ids[o] = iter->second->getId();
|
||||
}
|
||||
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);
|
||||
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())
|
||||
{
|
||||
auto mb2 = storage->addMapObject(storage->maps[map_id].get());
|
||||
auto mb2 = storage->addMapObject(storage->maps[map_id]);
|
||||
mb.setId(mb2->getId());
|
||||
*mb2 = mb;
|
||||
inserted++;
|
||||
|
|
|
|||
|
|
@ -4,37 +4,39 @@
|
|||
#define _WORD uint16_t
|
||||
#define _DWORD uint32_t
|
||||
|
||||
#define LOBYTE(x) (*((_BYTE*)&(x)))
|
||||
#define LOWORD(x) (*((_WORD*)&(x)))
|
||||
#define HIBYTE(x) (*((_BYTE*)&(x)+1))
|
||||
#define LOBYTE(x) (*((_BYTE *)&(x)))
|
||||
#define LOWORD(x) (*((_WORD *)&(x)))
|
||||
#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)
|
||||
|
||||
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;
|
||||
if ( sizeof(T) == 2 )
|
||||
if (sizeof(T) == 2)
|
||||
return int16_t(x) < 0;
|
||||
if ( sizeof(T) == 4 )
|
||||
if (sizeof(T) == 4)
|
||||
return int32_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;
|
||||
int8_t sx = __SETS__(x2);
|
||||
return (sx ^ __SETS__(y)) & (sx ^ __SETS__(x2-y));
|
||||
return (sx ^ __SETS__(y)) & (sx ^ __SETS__(x2 - y));
|
||||
}
|
||||
else
|
||||
{
|
||||
T y2 = y;
|
||||
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;
|
||||
v4 = &input[size];
|
||||
v5 = 8;
|
||||
if ( input < &input[size] )
|
||||
if (input < &input[size])
|
||||
{
|
||||
v6 = output;
|
||||
do
|
||||
{
|
||||
if ( v5 == 8 )
|
||||
if (v5 == 8)
|
||||
{
|
||||
v7 = (char *)(uint8_t)*result++;
|
||||
v5 = 0;
|
||||
input = v7;
|
||||
if ( result == v4 )
|
||||
if (result == v4)
|
||||
break;
|
||||
}
|
||||
if ( (uint8_t)input & 1 )
|
||||
if ((uint8_t)input & 1)
|
||||
{
|
||||
v8 = (uint8_t)*result;
|
||||
v9 = (uint8_t)result[1];
|
||||
result += 2;
|
||||
v10 = ((v8 & 0xF) << 8) + v9;
|
||||
v11 = (v8 >> 4) + 4;
|
||||
if ( v11 )
|
||||
if (v11)
|
||||
{
|
||||
v12 = &v6[-v10];
|
||||
v13 = v11;
|
||||
|
|
@ -90,8 +92,7 @@ char *decode_f1(char *input, int size, char *output)
|
|||
{
|
||||
*v6++ = *v12++;
|
||||
--v13;
|
||||
}
|
||||
while ( v13 );
|
||||
} while (v13);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -100,8 +101,7 @@ char *decode_f1(char *input, int size, char *output)
|
|||
}
|
||||
++v5;
|
||||
input = (char *)((signed int)input >> 1);
|
||||
}
|
||||
while ( result < v4 );
|
||||
} while (result < v4);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -121,23 +121,23 @@ char decode_f2(char *input, int size, char *output)
|
|||
LOBYTE(c) = size;
|
||||
v4 = *input;
|
||||
v5 = input + 1;
|
||||
if ( input + 1 < &input[size] )
|
||||
if (input + 1 < &input[size])
|
||||
{
|
||||
v6 = output;
|
||||
do
|
||||
{
|
||||
LOBYTE(c) = *v5;
|
||||
if ( *v5 == v4 )
|
||||
if (*v5 == v4)
|
||||
{
|
||||
c = (uint8_t)v5[1];
|
||||
v7 = v5 + 1;
|
||||
c_1 = (uint8_t)v7[1];
|
||||
v5 = v7 + 2;
|
||||
if ( c != 255 || c_1 != 255 )
|
||||
if (c != 255 || c_1 != 255)
|
||||
{
|
||||
c_2 = ((c & 0xF) << 8) + c_1;
|
||||
c = (c >> 4) + 4;
|
||||
if ( c )
|
||||
if (c)
|
||||
{
|
||||
v10 = &v6[-c_2];
|
||||
c_3 = c;
|
||||
|
|
@ -146,8 +146,7 @@ char decode_f2(char *input, int size, char *output)
|
|||
LOBYTE(c) = *v10;
|
||||
*v6++ = *v10++;
|
||||
--c_3;
|
||||
}
|
||||
while ( c_3 );
|
||||
} while (c_3);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -160,8 +159,7 @@ char decode_f2(char *input, int size, char *output)
|
|||
*v6++ = c;
|
||||
++v5;
|
||||
}
|
||||
}
|
||||
while ( v5 < &input[size] );
|
||||
} while (v5 < &input[size]);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
|
@ -200,20 +198,20 @@ int decode_f3(char *input, int size, char *output)
|
|||
v22 = size >> 1;
|
||||
v10 = s;
|
||||
v21 = s;
|
||||
if ( !((uint8_t)(v8 ^ v9) | v7) )
|
||||
if (!((uint8_t)(v8 ^ v9) | v7))
|
||||
{
|
||||
v11 = output;
|
||||
do
|
||||
{
|
||||
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++];
|
||||
if ( v12 != (uint16_t)v10 + 255 )
|
||||
if (v12 != (uint16_t)v10 + 255)
|
||||
{
|
||||
v14 = *(_WORD *)&v4[2 * idx];
|
||||
v15 = v13 + 3;
|
||||
if ( (signed int)v15 > 0 )
|
||||
if ((signed int)v15 > 0)
|
||||
{
|
||||
LOWORD(v10) = *(_WORD *)&v4[2 * idx];
|
||||
v16 = v11;
|
||||
|
|
@ -224,7 +222,7 @@ int decode_f3(char *input, int size, char *output)
|
|||
v10 = v21;
|
||||
memset32(v16, v18, 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;
|
||||
v19 += 2;
|
||||
|
|
@ -240,11 +238,10 @@ int decode_f3(char *input, int size, char *output)
|
|||
*(_WORD *)v11 = v12;
|
||||
}
|
||||
v11 += 2;
|
||||
LABEL_13:
|
||||
LABEL_13:
|
||||
result = v22;
|
||||
++idx;
|
||||
}
|
||||
while ( idx < v22 );
|
||||
} while (idx < v22);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -268,25 +265,25 @@ int decode_f4(char *input, int size, char *output, int segment_offset)
|
|||
in1 = *input;
|
||||
ptr = 1;
|
||||
in2 = *input;
|
||||
if ( size > 1 )
|
||||
if (size > 1)
|
||||
{
|
||||
out1 = output;
|
||||
while ( 1 )
|
||||
while (1)
|
||||
{
|
||||
c = in3[ptr];
|
||||
if ( c != in1 )
|
||||
if (c != in1)
|
||||
break;
|
||||
c_next = in3[ptr++ + 1];
|
||||
if ( c_next == -1 )
|
||||
if (c_next == -1)
|
||||
{
|
||||
*out1 = in1;
|
||||
LABEL_9:
|
||||
LABEL_9:
|
||||
++out1;
|
||||
goto LABEL_10;
|
||||
}
|
||||
v11 = in3[ptr++ + 1];
|
||||
c_prev = (uint8_t)c_next + 3;
|
||||
if ( (signed int)c_prev > 0 )
|
||||
if ((signed int)c_prev > 0)
|
||||
{
|
||||
LOBYTE(segment_offset) = v11;
|
||||
BYTE1(segment_offset) = v11;
|
||||
|
|
@ -297,12 +294,12 @@ LABEL_9:
|
|||
in3 = input;
|
||||
memset(&out1[4 * (c_prev >> 2)], v13, c_prev & 3);
|
||||
out1 = &output[c_prev];
|
||||
LABEL_10:
|
||||
LABEL_10:
|
||||
output = out1;
|
||||
}
|
||||
result = size;
|
||||
++ptr;
|
||||
if ( ptr >= size )
|
||||
if (ptr >= size)
|
||||
return result;
|
||||
}
|
||||
*out1 = c;
|
||||
|
|
|
|||
|
|
@ -27,15 +27,14 @@ void unpak(string fn)
|
|||
return;
|
||||
pak p;
|
||||
p.load(f);
|
||||
auto read_write_any_file = [&](record &file)
|
||||
for (auto &f : p.files)
|
||||
{
|
||||
record &file = f.second;
|
||||
cout << "Unpacking " << file.name << "\n";
|
||||
vector<char> buf(file.len);
|
||||
file.read(&p, &buf[0], file.len);
|
||||
file.write(fn + ".dir", buf);
|
||||
};
|
||||
for (auto &f : p.files)
|
||||
read_write_any_file(f.second);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue