mirror of
https://github.com/electronicarts/CNC_TS_and_RA2_Mission_Editor.git
synced 2025-07-24 16:14:57 -04:00
code reformatted .
This commit is contained in:
parent
76d336504f
commit
1de6ad56c2
265 changed files with 18240 additions and 21591 deletions
24
3rdParty/xcc/Library/StdAfx.cpp
vendored
24
3rdParty/xcc/Library/StdAfx.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
|
24
3rdParty/xcc/Library/StdAfx.h
vendored
24
3rdParty/xcc/Library/StdAfx.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
78
3rdParty/xcc/misc/blowfish.cpp
vendored
78
3rdParty/xcc/misc/blowfish.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include <memory.h>
|
||||
|
||||
const Cblowfish::t_bf_p g_p =
|
||||
const Cblowfish::t_bf_p g_p =
|
||||
{
|
||||
0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
|
||||
0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
|
||||
|
@ -30,7 +30,7 @@ const Cblowfish::t_bf_p g_p =
|
|||
0x9216d5d9, 0x8979fb1b,
|
||||
};
|
||||
|
||||
const Cblowfish::t_bf_s g_s =
|
||||
const Cblowfish::t_bf_s g_s =
|
||||
{
|
||||
0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
|
||||
0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
|
||||
|
@ -296,8 +296,7 @@ void Cblowfish::set_key(data_ref key)
|
|||
memcpy(m_s, g_s, sizeof(t_bf_s));
|
||||
|
||||
int j = 0;
|
||||
for (int i = 0; i < 18; i++)
|
||||
{
|
||||
for (int i = 0; i < 18; i++) {
|
||||
int a = key[j++]; j %= key.size();
|
||||
int b = key[j++]; j %= key.size();
|
||||
int c = key[j++]; j %= key.size();
|
||||
|
@ -308,18 +307,15 @@ void Cblowfish::set_key(data_ref key)
|
|||
uint32_t datal = 0;
|
||||
uint32_t datar = 0;
|
||||
|
||||
for (int i = 0; i < 18; )
|
||||
{
|
||||
for (int i = 0; i < 18; ) {
|
||||
encipher(datal, datar);
|
||||
|
||||
m_p[i++] = datal;
|
||||
m_p[i++] = datar;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 256; )
|
||||
{
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 256; ) {
|
||||
encipher(datal, datar);
|
||||
|
||||
m_s[i][j++] = datal;
|
||||
|
@ -349,14 +345,14 @@ void Cblowfish::encipher(uint32_t& xl, uint32_t& xr) const
|
|||
uint32_t Xr = xr;
|
||||
|
||||
Xl ^= m_p[0];
|
||||
ROUND (Xr, Xl, 1); ROUND (Xl, Xr, 2);
|
||||
ROUND (Xr, Xl, 3); ROUND (Xl, Xr, 4);
|
||||
ROUND (Xr, Xl, 5); ROUND (Xl, Xr, 6);
|
||||
ROUND (Xr, Xl, 7); ROUND (Xl, Xr, 8);
|
||||
ROUND (Xr, Xl, 9); ROUND (Xl, Xr, 10);
|
||||
ROUND (Xr, Xl, 11); ROUND (Xl, Xr, 12);
|
||||
ROUND (Xr, Xl, 13); ROUND (Xl, Xr, 14);
|
||||
ROUND (Xr, Xl, 15); ROUND (Xl, Xr, 16);
|
||||
ROUND(Xr, Xl, 1); ROUND(Xl, Xr, 2);
|
||||
ROUND(Xr, Xl, 3); ROUND(Xl, Xr, 4);
|
||||
ROUND(Xr, Xl, 5); ROUND(Xl, Xr, 6);
|
||||
ROUND(Xr, Xl, 7); ROUND(Xl, Xr, 8);
|
||||
ROUND(Xr, Xl, 9); ROUND(Xl, Xr, 10);
|
||||
ROUND(Xr, Xl, 11); ROUND(Xl, Xr, 12);
|
||||
ROUND(Xr, Xl, 13); ROUND(Xl, Xr, 14);
|
||||
ROUND(Xr, Xl, 15); ROUND(Xl, Xr, 16);
|
||||
Xr ^= m_p[17];
|
||||
|
||||
xr = Xl;
|
||||
|
@ -369,14 +365,14 @@ void Cblowfish::decipher(uint32_t& xl, uint32_t& xr) const
|
|||
uint32_t Xr = xr;
|
||||
|
||||
Xl ^= m_p[17];
|
||||
ROUND (Xr, Xl, 16); ROUND (Xl, Xr, 15);
|
||||
ROUND (Xr, Xl, 14); ROUND (Xl, Xr, 13);
|
||||
ROUND (Xr, Xl, 12); ROUND (Xl, Xr, 11);
|
||||
ROUND (Xr, Xl, 10); ROUND (Xl, Xr, 9);
|
||||
ROUND (Xr, Xl, 8); ROUND (Xl, Xr, 7);
|
||||
ROUND (Xr, Xl, 6); ROUND (Xl, Xr, 5);
|
||||
ROUND (Xr, Xl, 4); ROUND (Xl, Xr, 3);
|
||||
ROUND (Xr, Xl, 2); ROUND (Xl, Xr, 1);
|
||||
ROUND(Xr, Xl, 16); ROUND(Xl, Xr, 15);
|
||||
ROUND(Xr, Xl, 14); ROUND(Xl, Xr, 13);
|
||||
ROUND(Xr, Xl, 12); ROUND(Xl, Xr, 11);
|
||||
ROUND(Xr, Xl, 10); ROUND(Xl, Xr, 9);
|
||||
ROUND(Xr, Xl, 8); ROUND(Xl, Xr, 7);
|
||||
ROUND(Xr, Xl, 6); ROUND(Xl, Xr, 5);
|
||||
ROUND(Xr, Xl, 4); ROUND(Xl, Xr, 3);
|
||||
ROUND(Xr, Xl, 2); ROUND(Xl, Xr, 1);
|
||||
Xr ^= m_p[0];
|
||||
|
||||
xl = Xr;
|
||||
|
@ -395,8 +391,7 @@ void Cblowfish::encipher(const void* s, void* d, int size) const
|
|||
const uint32_t* r = reinterpret_cast<const uint32_t*>(s);
|
||||
uint32_t* w = reinterpret_cast<uint32_t*>(d);
|
||||
size >>= 3;
|
||||
while (size--)
|
||||
{
|
||||
while (size--) {
|
||||
uint32_t a = reverse(*r++);
|
||||
uint32_t b = reverse(*r++);
|
||||
encipher(a, b);
|
||||
|
@ -410,8 +405,7 @@ void Cblowfish::decipher(const void* s, void* d, int size) const
|
|||
const uint32_t* r = reinterpret_cast<const uint32_t*>(s);
|
||||
uint32_t* w = reinterpret_cast<uint32_t*>(d);
|
||||
size >>= 3;
|
||||
while (size--)
|
||||
{
|
||||
while (size--) {
|
||||
uint32_t a = reverse(*r++);
|
||||
uint32_t b = reverse(*r++);
|
||||
decipher(a, b);
|
||||
|
|
24
3rdParty/xcc/misc/blowfish.h
vendored
24
3rdParty/xcc/misc/blowfish.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
695
3rdParty/xcc/misc/cc_file.cpp
vendored
695
3rdParty/xcc/misc/cc_file.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -161,360 +161,347 @@ Ccc_file::Ccc_file(bool read_on_open) :
|
|||
#define test_fail(res) { int v = res; if (v) { close(); return v; }}
|
||||
|
||||
#ifndef NO_MIX_SUPPORT
|
||||
int Ccc_file::open(unsigned int id, Cmix_file& mix_f)
|
||||
{
|
||||
if (mix_f.get_index(id) == -1)
|
||||
return -1;
|
||||
m_f = mix_f.m_f;
|
||||
m_offset = mix_f.m_offset + mix_f.get_offset(id);
|
||||
m_size = mix_f.get_size(id);
|
||||
m_p = 0;
|
||||
m_is_open = true;
|
||||
if (m_read_on_open || mix_f.data())
|
||||
m_data = mix_f.get_vdata(id);
|
||||
test_fail(post_open())
|
||||
return 0;
|
||||
}
|
||||
int Ccc_file::open(unsigned int id, Cmix_file& mix_f)
|
||||
{
|
||||
if (mix_f.get_index(id) == -1)
|
||||
return -1;
|
||||
m_f = mix_f.m_f;
|
||||
m_offset = mix_f.m_offset + mix_f.get_offset(id);
|
||||
m_size = mix_f.get_size(id);
|
||||
m_p = 0;
|
||||
m_is_open = true;
|
||||
if (m_read_on_open || mix_f.data())
|
||||
m_data = mix_f.get_vdata(id);
|
||||
test_fail(post_open())
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Ccc_file::open(const string& name, Cmix_file& mix_f)
|
||||
{
|
||||
return open(Cmix_file::get_id(mix_f.get_game(), name), mix_f);
|
||||
}
|
||||
int Ccc_file::open(const string& name, Cmix_file& mix_f)
|
||||
{
|
||||
return open(Cmix_file::get_id(mix_f.get_game(), name), mix_f);
|
||||
}
|
||||
#endif
|
||||
|
||||
int Ccc_file::open(const string& name)
|
||||
{
|
||||
close();
|
||||
assert(!is_open());
|
||||
int Ccc_file::open(const string& name)
|
||||
{
|
||||
close();
|
||||
assert(!is_open());
|
||||
#ifdef NO_MIX_SUPPORT
|
||||
test_fail(m_f.open_read(name));
|
||||
test_fail(m_f.open_read(name));
|
||||
#else
|
||||
test_fail(m_f.open_read(xcc_dirs::find_file(name)));
|
||||
test_fail(m_f.open_read(xcc_dirs::find_file(name)));
|
||||
#endif
|
||||
m_offset = 0;
|
||||
m_size = m_f.size();
|
||||
m_p = 0;
|
||||
m_is_open = true;
|
||||
m_data = m_f.get_mm();
|
||||
if (m_read_on_open)
|
||||
m_f.close();
|
||||
#ifndef NO_FT_SUPPORT
|
||||
Cfname fname = to_lower_copy(name);
|
||||
if (fname.get_fext() == ".mmx")
|
||||
{
|
||||
fname.set_ext(".map");
|
||||
mix_database::add_name(game_ra2, fname.get_fname(), "-");
|
||||
fname.set_ext(".pkt");
|
||||
mix_database::add_name(game_ra2, fname.get_fname(), "-");
|
||||
}
|
||||
#endif
|
||||
test_fail(post_open())
|
||||
return 0;
|
||||
}
|
||||
|
||||
const Cwin_handle& Ccc_file::h()
|
||||
{
|
||||
assert(is_open());
|
||||
return m_f.h();
|
||||
}
|
||||
|
||||
int Ccc_file::open(const Cwin_handle& h)
|
||||
{
|
||||
assert(!is_open());
|
||||
m_f.open(h);
|
||||
m_offset = 0;
|
||||
m_size = m_f.size();
|
||||
m_p = 0;
|
||||
m_is_open = true;
|
||||
m_data = m_f.get_mm();
|
||||
if (m_read_on_open)
|
||||
m_f.close();
|
||||
test_fail(post_open())
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Ccc_file::load(const Cvirtual_binary& d, int size)
|
||||
{
|
||||
m_data = d;
|
||||
m_offset = 0;
|
||||
m_is_open = true;
|
||||
m_p = 0;
|
||||
m_size = size == -1 ? d.size() : size;
|
||||
post_open();
|
||||
}
|
||||
|
||||
void Ccc_file::load(const Ccc_file& f)
|
||||
{
|
||||
load(f.vdata());
|
||||
}
|
||||
|
||||
int Ccc_file::read()
|
||||
{
|
||||
seek(0);
|
||||
Cvirtual_binary d;
|
||||
if (int error = read(d.write_start(get_size()), get_size()))
|
||||
return error;
|
||||
m_data = d;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Ccc_file::read(void* data, int size)
|
||||
{
|
||||
if (get_p() < 0 || get_p() + size > get_size())
|
||||
return 1;
|
||||
if (get_data())
|
||||
{
|
||||
memcpy(data, m_data.data() + m_p, size);
|
||||
skip(size);
|
||||
return 0;
|
||||
}
|
||||
assert(is_open());
|
||||
m_f.seek(m_offset + m_p);
|
||||
int res = m_f.read(data, size);
|
||||
if (!res)
|
||||
skip(size);
|
||||
return res;
|
||||
}
|
||||
|
||||
int Ccc_file::extract(const string& name)
|
||||
{
|
||||
assert(is_open());
|
||||
if (data())
|
||||
return vdata().save(name);
|
||||
seek(0);
|
||||
Cfile32 f;
|
||||
if (int error = f.open_write(name))
|
||||
return error;
|
||||
Cvirtual_binary data;
|
||||
for (int size = get_size(); size; )
|
||||
{
|
||||
int cb_write = min(size, 1 << 20);
|
||||
if (int error = read(data.write_start(cb_write), cb_write))
|
||||
return error;
|
||||
if (int error = f.write(data.data(), cb_write))
|
||||
return error;
|
||||
size -= cb_write;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Ccc_file::close()
|
||||
{
|
||||
m_data.clear();
|
||||
m_offset = 0;
|
||||
m_size = m_f.size();
|
||||
m_p = 0;
|
||||
m_is_open = true;
|
||||
m_data = m_f.get_mm();
|
||||
if (m_read_on_open)
|
||||
m_f.close();
|
||||
m_is_open = false;
|
||||
#ifndef NO_FT_SUPPORT
|
||||
Cfname fname = to_lower_copy(name);
|
||||
if (fname.get_fext() == ".mmx") {
|
||||
fname.set_ext(".map");
|
||||
mix_database::add_name(game_ra2, fname.get_fname(), "-");
|
||||
fname.set_ext(".pkt");
|
||||
mix_database::add_name(game_ra2, fname.get_fname(), "-");
|
||||
}
|
||||
#endif
|
||||
test_fail(post_open())
|
||||
return 0;
|
||||
}
|
||||
|
||||
const Cwin_handle& Ccc_file::h()
|
||||
{
|
||||
assert(is_open());
|
||||
return m_f.h();
|
||||
}
|
||||
|
||||
int Ccc_file::open(const Cwin_handle& h)
|
||||
{
|
||||
assert(!is_open());
|
||||
m_f.open(h);
|
||||
m_offset = 0;
|
||||
m_size = m_f.size();
|
||||
m_p = 0;
|
||||
m_is_open = true;
|
||||
m_data = m_f.get_mm();
|
||||
if (m_read_on_open)
|
||||
m_f.close();
|
||||
test_fail(post_open())
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Ccc_file::load(const Cvirtual_binary& d, int size)
|
||||
{
|
||||
m_data = d;
|
||||
m_offset = 0;
|
||||
m_is_open = true;
|
||||
m_p = 0;
|
||||
m_size = size == -1 ? d.size() : size;
|
||||
post_open();
|
||||
}
|
||||
|
||||
void Ccc_file::load(const Ccc_file& f)
|
||||
{
|
||||
load(f.vdata());
|
||||
}
|
||||
|
||||
int Ccc_file::read()
|
||||
{
|
||||
seek(0);
|
||||
Cvirtual_binary d;
|
||||
if (int error = read(d.write_start(get_size()), get_size()))
|
||||
return error;
|
||||
m_data = d;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Ccc_file::read(void* data, int size)
|
||||
{
|
||||
if (get_p() < 0 || get_p() + size > get_size())
|
||||
return 1;
|
||||
if (get_data()) {
|
||||
memcpy(data, m_data.data() + m_p, size);
|
||||
skip(size);
|
||||
return 0;
|
||||
}
|
||||
assert(is_open());
|
||||
m_f.seek(m_offset + m_p);
|
||||
int res = m_f.read(data, size);
|
||||
if (!res)
|
||||
skip(size);
|
||||
return res;
|
||||
}
|
||||
|
||||
int Ccc_file::extract(const string& name)
|
||||
{
|
||||
assert(is_open());
|
||||
if (data())
|
||||
return vdata().save(name);
|
||||
seek(0);
|
||||
Cfile32 f;
|
||||
if (int error = f.open_write(name))
|
||||
return error;
|
||||
Cvirtual_binary data;
|
||||
for (int size = get_size(); size; ) {
|
||||
int cb_write = min(size, 1 << 20);
|
||||
if (int error = read(data.write_start(cb_write), cb_write))
|
||||
return error;
|
||||
if (int error = f.write(data.data(), cb_write))
|
||||
return error;
|
||||
size -= cb_write;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Ccc_file::close()
|
||||
{
|
||||
m_data.clear();
|
||||
m_f.close();
|
||||
m_is_open = false;
|
||||
}
|
||||
|
||||
|
||||
#ifndef NO_MIX_SUPPORT
|
||||
#ifndef NO_FT_SUPPORT
|
||||
t_file_type Ccc_file::get_file_type(bool fast)
|
||||
{
|
||||
Cvirtual_binary data;
|
||||
int size;
|
||||
if (m_data.data())
|
||||
{
|
||||
data = m_data;
|
||||
size = m_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
size = min<int>(m_size, 64 << 10);
|
||||
seek(0);
|
||||
if (read(data.write_start(size), size))
|
||||
return ft_unknown;
|
||||
seek(0);
|
||||
}
|
||||
Caud_file aud_f;
|
||||
Cbin_file bin_f;
|
||||
Cbink_file bink_f;
|
||||
Cbig_file big_f;
|
||||
Cbmp_file bmp_f;
|
||||
Ccsf_file csf_f;
|
||||
Ccps_file cps_f;
|
||||
Cdds_file dds_f;
|
||||
Cfnt_file fnt_f;
|
||||
Chva_file hva_f;
|
||||
Cmix_file mix_f;
|
||||
Cmix_rg_file mix_rg_f;
|
||||
Cmp3_file mp3_f;
|
||||
Cjpeg_file jpeg_f;
|
||||
Cogg_file ogg_f;
|
||||
Cpak_file pak_f;
|
||||
Cpal_file pal_f;
|
||||
Cpcx_file pcx_f;
|
||||
Cpng_file png_f;
|
||||
Criff_file riff_f;
|
||||
Cshp_dune2_file shp_dune2_f;
|
||||
Cshp_file shp_f;
|
||||
Cshp_ts_file shp_ts_f;
|
||||
Cst_file st_f;
|
||||
Ctext_file text_f;
|
||||
Ctga_file tga_f;
|
||||
Ctmp_file tmp_f;
|
||||
Ctmp_ra_file tmp_ra_f;
|
||||
Ctmp_ts_file tmp_ts_f;
|
||||
Cvoc_file voc_f;
|
||||
Cvqa_file vqa_f;
|
||||
Cvqp_file vqp_f;
|
||||
Cvxl_file vxl_f;
|
||||
Cw3d_file w3d_f;
|
||||
Cwsa_dune2_file wsa_dune2_f;
|
||||
Cwsa_file wsa_f;
|
||||
Cxcc_file xcc_f;
|
||||
Cxif_file xif_f;
|
||||
if (aud_f.load(data, m_size), aud_f.is_valid())
|
||||
return ft_aud;
|
||||
if (big_f.load(data, m_size), big_f.is_valid())
|
||||
return ft_big;
|
||||
if (bin_f.load(data, m_size), bin_f.is_valid())
|
||||
return ft_bin;
|
||||
if (bink_f.load(data, m_size), bink_f.is_valid())
|
||||
return ft_bink;
|
||||
if (bmp_f.load(data, m_size), bmp_f.is_valid())
|
||||
return ft_bmp;
|
||||
if (csf_f.load(data, m_size), csf_f.is_valid())
|
||||
return ft_csf;
|
||||
if (cps_f.load(data, m_size), cps_f.is_valid())
|
||||
return ft_cps;
|
||||
if (dds_f.load(data, m_size), dds_f.is_valid())
|
||||
return ft_dds;
|
||||
if (fnt_f.load(data, m_size), fnt_f.is_valid())
|
||||
return ft_fnt;
|
||||
if (hva_f.load(data, m_size), hva_f.is_valid())
|
||||
return ft_hva;
|
||||
if (mp3_f.load(data, m_size), mp3_f.is_valid())
|
||||
return ft_mp3;
|
||||
if (jpeg_f.load(data, m_size), jpeg_f.is_valid())
|
||||
return ft_jpeg;
|
||||
if (ogg_f.load(data, m_size), ogg_f.is_valid())
|
||||
return ft_ogg;
|
||||
if (pal_f.load(data, m_size), pal_f.is_valid())
|
||||
return ft_pal;
|
||||
if (pcx_f.load(data, m_size), pcx_f.is_valid())
|
||||
return ft_pcx;
|
||||
if (png_f.load(data, m_size), png_f.is_valid())
|
||||
return ft_png;
|
||||
if (riff_f.load(data, m_size), riff_f.is_valid())
|
||||
{
|
||||
Cavi_file avi_f;
|
||||
Cwav_file wav_f;
|
||||
avi_f.load(data, m_size);
|
||||
wav_f.load(data, m_size);
|
||||
if (avi_f.is_valid())
|
||||
return ft_avi;
|
||||
if (wav_f.is_valid())
|
||||
return ft_wav;
|
||||
return ft_riff;
|
||||
}
|
||||
if (shp_dune2_f.load(data, m_size), shp_dune2_f.is_valid())
|
||||
return ft_shp_dune2;
|
||||
if (shp_f.load(data, m_size), shp_f.is_valid())
|
||||
return ft_shp;
|
||||
if (shp_ts_f.load(data, m_size), shp_ts_f.is_valid())
|
||||
return ft_shp_ts;
|
||||
if (st_f.load(data, m_size), st_f.is_valid())
|
||||
return ft_st;
|
||||
if (tga_f.load(data, m_size), tga_f.is_valid())
|
||||
return ft_tga;
|
||||
if (tmp_f.load(data, m_size), tmp_f.is_valid())
|
||||
return ft_tmp;
|
||||
if (tmp_ra_f.load(data, m_size), tmp_ra_f.is_valid())
|
||||
return ft_tmp_ra;
|
||||
if (tmp_ts_f.load(data, m_size), tmp_ts_f.is_valid())
|
||||
return ft_tmp_ts;
|
||||
if (voc_f.load(data, m_size), voc_f.is_valid())
|
||||
return ft_voc;
|
||||
if (vqa_f.load(data, m_size), vqa_f.is_valid())
|
||||
return ft_vqa;
|
||||
if (vqp_f.load(data, m_size), vqp_f.is_valid())
|
||||
return ft_vqp;
|
||||
if (vxl_f.load(data, m_size), vxl_f.is_valid())
|
||||
return ft_vxl;
|
||||
if (wsa_dune2_f.load(data, m_size), wsa_dune2_f.is_valid())
|
||||
return ft_wsa_dune2;
|
||||
if (wsa_f.load(data, m_size), wsa_f.is_valid())
|
||||
return ft_wsa;
|
||||
if (xcc_f.load(data, m_size), xcc_f.is_valid())
|
||||
{
|
||||
switch (xcc_f.get_ft())
|
||||
{
|
||||
case xcc_ft_lmd:
|
||||
return ft_xcc_lmd;
|
||||
}
|
||||
return ft_xcc_unknown;
|
||||
}
|
||||
if (xif_f.load(data, m_size), xif_f.is_valid())
|
||||
return ft_xif;
|
||||
if (mix_f.load(data, m_size), mix_f.is_valid())
|
||||
return ft_mix;
|
||||
if (mix_rg_f.load(data, m_size), mix_rg_f.is_valid())
|
||||
return ft_mix_rg;
|
||||
if (pak_f.load(data, m_size), pak_f.is_valid())
|
||||
return ft_pak;
|
||||
if (w3d_f.load(data, m_size), w3d_f.is_valid())
|
||||
return ft_w3d;
|
||||
if (text_f.load(data, m_size), text_f.is_valid())
|
||||
{
|
||||
if (fast)
|
||||
return ft_text;
|
||||
Cvirtual_tfile tf;
|
||||
tf.load_data(data);
|
||||
Cnull_ini_reader ir;
|
||||
int error = 0;
|
||||
while (!error && !tf.eof())
|
||||
{
|
||||
error = ir.process_line(tf.read_line());
|
||||
if (tf.eof())
|
||||
error = 0;
|
||||
}
|
||||
if (!error && ir.is_valid())
|
||||
{
|
||||
if (!m_read_on_open && m_size != size)
|
||||
{
|
||||
size = m_size;
|
||||
if (read(data.write_start(size), size))
|
||||
return ft_unknown;
|
||||
seek(0);
|
||||
}
|
||||
{
|
||||
Cmap_td_ini_reader ir;
|
||||
if (!ir.process(data) && ir.is_valid())
|
||||
return ft_map_td;
|
||||
}
|
||||
{
|
||||
Cmap_ra_ini_reader ir;
|
||||
if (!ir.process(data) && ir.is_valid())
|
||||
return ft_map_ra;
|
||||
}
|
||||
{
|
||||
Cmap_ts_ini_reader ir;
|
||||
ir.fast(true);
|
||||
if (!ir.process(data) && ir.is_valid())
|
||||
return ft_map_ts;
|
||||
}
|
||||
{
|
||||
Cpkt_ts_ini_reader ir;
|
||||
ir.fast(true);
|
||||
if (!ir.process(data) && ir.is_valid())
|
||||
return ft_pkt_ts;
|
||||
}
|
||||
{
|
||||
Csound_ts_ini_reader ir;
|
||||
ir.fast(true);
|
||||
if (!ir.process(data) && ir.is_valid())
|
||||
return ft_sound_ini_ts;
|
||||
}
|
||||
{
|
||||
Ctheme_ts_ini_reader ir;
|
||||
if (!ir.process(data) && ir.is_valid())
|
||||
return ft_theme_ini_ts;
|
||||
}
|
||||
return ft_ini;
|
||||
}
|
||||
return ft_text;
|
||||
}
|
||||
return ft_unknown;
|
||||
t_file_type Ccc_file::get_file_type(bool fast)
|
||||
{
|
||||
Cvirtual_binary data;
|
||||
int size;
|
||||
if (m_data.data()) {
|
||||
data = m_data;
|
||||
size = m_size;
|
||||
} else {
|
||||
size = min<int>(m_size, 64 << 10);
|
||||
seek(0);
|
||||
if (read(data.write_start(size), size))
|
||||
return ft_unknown;
|
||||
seek(0);
|
||||
}
|
||||
Caud_file aud_f;
|
||||
Cbin_file bin_f;
|
||||
Cbink_file bink_f;
|
||||
Cbig_file big_f;
|
||||
Cbmp_file bmp_f;
|
||||
Ccsf_file csf_f;
|
||||
Ccps_file cps_f;
|
||||
Cdds_file dds_f;
|
||||
Cfnt_file fnt_f;
|
||||
Chva_file hva_f;
|
||||
Cmix_file mix_f;
|
||||
Cmix_rg_file mix_rg_f;
|
||||
Cmp3_file mp3_f;
|
||||
Cjpeg_file jpeg_f;
|
||||
Cogg_file ogg_f;
|
||||
Cpak_file pak_f;
|
||||
Cpal_file pal_f;
|
||||
Cpcx_file pcx_f;
|
||||
Cpng_file png_f;
|
||||
Criff_file riff_f;
|
||||
Cshp_dune2_file shp_dune2_f;
|
||||
Cshp_file shp_f;
|
||||
Cshp_ts_file shp_ts_f;
|
||||
Cst_file st_f;
|
||||
Ctext_file text_f;
|
||||
Ctga_file tga_f;
|
||||
Ctmp_file tmp_f;
|
||||
Ctmp_ra_file tmp_ra_f;
|
||||
Ctmp_ts_file tmp_ts_f;
|
||||
Cvoc_file voc_f;
|
||||
Cvqa_file vqa_f;
|
||||
Cvqp_file vqp_f;
|
||||
Cvxl_file vxl_f;
|
||||
Cw3d_file w3d_f;
|
||||
Cwsa_dune2_file wsa_dune2_f;
|
||||
Cwsa_file wsa_f;
|
||||
Cxcc_file xcc_f;
|
||||
Cxif_file xif_f;
|
||||
if (aud_f.load(data, m_size), aud_f.is_valid())
|
||||
return ft_aud;
|
||||
if (big_f.load(data, m_size), big_f.is_valid())
|
||||
return ft_big;
|
||||
if (bin_f.load(data, m_size), bin_f.is_valid())
|
||||
return ft_bin;
|
||||
if (bink_f.load(data, m_size), bink_f.is_valid())
|
||||
return ft_bink;
|
||||
if (bmp_f.load(data, m_size), bmp_f.is_valid())
|
||||
return ft_bmp;
|
||||
if (csf_f.load(data, m_size), csf_f.is_valid())
|
||||
return ft_csf;
|
||||
if (cps_f.load(data, m_size), cps_f.is_valid())
|
||||
return ft_cps;
|
||||
if (dds_f.load(data, m_size), dds_f.is_valid())
|
||||
return ft_dds;
|
||||
if (fnt_f.load(data, m_size), fnt_f.is_valid())
|
||||
return ft_fnt;
|
||||
if (hva_f.load(data, m_size), hva_f.is_valid())
|
||||
return ft_hva;
|
||||
if (mp3_f.load(data, m_size), mp3_f.is_valid())
|
||||
return ft_mp3;
|
||||
if (jpeg_f.load(data, m_size), jpeg_f.is_valid())
|
||||
return ft_jpeg;
|
||||
if (ogg_f.load(data, m_size), ogg_f.is_valid())
|
||||
return ft_ogg;
|
||||
if (pal_f.load(data, m_size), pal_f.is_valid())
|
||||
return ft_pal;
|
||||
if (pcx_f.load(data, m_size), pcx_f.is_valid())
|
||||
return ft_pcx;
|
||||
if (png_f.load(data, m_size), png_f.is_valid())
|
||||
return ft_png;
|
||||
if (riff_f.load(data, m_size), riff_f.is_valid()) {
|
||||
Cavi_file avi_f;
|
||||
Cwav_file wav_f;
|
||||
avi_f.load(data, m_size);
|
||||
wav_f.load(data, m_size);
|
||||
if (avi_f.is_valid())
|
||||
return ft_avi;
|
||||
if (wav_f.is_valid())
|
||||
return ft_wav;
|
||||
return ft_riff;
|
||||
}
|
||||
if (shp_dune2_f.load(data, m_size), shp_dune2_f.is_valid())
|
||||
return ft_shp_dune2;
|
||||
if (shp_f.load(data, m_size), shp_f.is_valid())
|
||||
return ft_shp;
|
||||
if (shp_ts_f.load(data, m_size), shp_ts_f.is_valid())
|
||||
return ft_shp_ts;
|
||||
if (st_f.load(data, m_size), st_f.is_valid())
|
||||
return ft_st;
|
||||
if (tga_f.load(data, m_size), tga_f.is_valid())
|
||||
return ft_tga;
|
||||
if (tmp_f.load(data, m_size), tmp_f.is_valid())
|
||||
return ft_tmp;
|
||||
if (tmp_ra_f.load(data, m_size), tmp_ra_f.is_valid())
|
||||
return ft_tmp_ra;
|
||||
if (tmp_ts_f.load(data, m_size), tmp_ts_f.is_valid())
|
||||
return ft_tmp_ts;
|
||||
if (voc_f.load(data, m_size), voc_f.is_valid())
|
||||
return ft_voc;
|
||||
if (vqa_f.load(data, m_size), vqa_f.is_valid())
|
||||
return ft_vqa;
|
||||
if (vqp_f.load(data, m_size), vqp_f.is_valid())
|
||||
return ft_vqp;
|
||||
if (vxl_f.load(data, m_size), vxl_f.is_valid())
|
||||
return ft_vxl;
|
||||
if (wsa_dune2_f.load(data, m_size), wsa_dune2_f.is_valid())
|
||||
return ft_wsa_dune2;
|
||||
if (wsa_f.load(data, m_size), wsa_f.is_valid())
|
||||
return ft_wsa;
|
||||
if (xcc_f.load(data, m_size), xcc_f.is_valid()) {
|
||||
switch (xcc_f.get_ft()) {
|
||||
case xcc_ft_lmd:
|
||||
return ft_xcc_lmd;
|
||||
}
|
||||
return ft_xcc_unknown;
|
||||
}
|
||||
if (xif_f.load(data, m_size), xif_f.is_valid())
|
||||
return ft_xif;
|
||||
if (mix_f.load(data, m_size), mix_f.is_valid())
|
||||
return ft_mix;
|
||||
if (mix_rg_f.load(data, m_size), mix_rg_f.is_valid())
|
||||
return ft_mix_rg;
|
||||
if (pak_f.load(data, m_size), pak_f.is_valid())
|
||||
return ft_pak;
|
||||
if (w3d_f.load(data, m_size), w3d_f.is_valid())
|
||||
return ft_w3d;
|
||||
if (text_f.load(data, m_size), text_f.is_valid()) {
|
||||
if (fast)
|
||||
return ft_text;
|
||||
Cvirtual_tfile tf;
|
||||
tf.load_data(data);
|
||||
Cnull_ini_reader ir;
|
||||
int error = 0;
|
||||
while (!error && !tf.eof()) {
|
||||
error = ir.process_line(tf.read_line());
|
||||
if (tf.eof())
|
||||
error = 0;
|
||||
}
|
||||
if (!error && ir.is_valid()) {
|
||||
if (!m_read_on_open && m_size != size) {
|
||||
size = m_size;
|
||||
if (read(data.write_start(size), size))
|
||||
return ft_unknown;
|
||||
seek(0);
|
||||
}
|
||||
{
|
||||
Cmap_td_ini_reader ir;
|
||||
if (!ir.process(data) && ir.is_valid())
|
||||
return ft_map_td;
|
||||
}
|
||||
{
|
||||
Cmap_ra_ini_reader ir;
|
||||
if (!ir.process(data) && ir.is_valid())
|
||||
return ft_map_ra;
|
||||
}
|
||||
{
|
||||
Cmap_ts_ini_reader ir;
|
||||
ir.fast(true);
|
||||
if (!ir.process(data) && ir.is_valid())
|
||||
return ft_map_ts;
|
||||
}
|
||||
{
|
||||
Cpkt_ts_ini_reader ir;
|
||||
ir.fast(true);
|
||||
if (!ir.process(data) && ir.is_valid())
|
||||
return ft_pkt_ts;
|
||||
}
|
||||
{
|
||||
Csound_ts_ini_reader ir;
|
||||
ir.fast(true);
|
||||
if (!ir.process(data) && ir.is_valid())
|
||||
return ft_sound_ini_ts;
|
||||
}
|
||||
{
|
||||
Ctheme_ts_ini_reader ir;
|
||||
if (!ir.process(data) && ir.is_valid())
|
||||
return ft_theme_ini_ts;
|
||||
}
|
||||
return ft_ini;
|
||||
}
|
||||
return ft_text;
|
||||
}
|
||||
return ft_unknown;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
58
3rdParty/xcc/misc/cc_file.h
vendored
58
3rdParty/xcc/misc/cc_file.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -52,7 +52,7 @@ enum t_file_type
|
|||
ft_mix_rg,
|
||||
ft_mng,
|
||||
ft_mp3,
|
||||
ft_mrf,
|
||||
ft_mrf,
|
||||
ft_ogg,
|
||||
ft_pak,
|
||||
ft_pal,
|
||||
|
@ -67,7 +67,7 @@ enum t_file_type
|
|||
ft_rules_ini_ra2,
|
||||
ft_shp_dune2,
|
||||
ft_shp,
|
||||
ft_shp_ts,
|
||||
ft_shp_ts,
|
||||
ft_sound_ini_ts,
|
||||
ft_sound_ini_ra2,
|
||||
ft_st,
|
||||
|
@ -85,7 +85,7 @@ enum t_file_type
|
|||
ft_vqp,
|
||||
ft_vxl,
|
||||
ft_w3d,
|
||||
ft_wav,
|
||||
ft_wav,
|
||||
ft_wav_ima_adpcm,
|
||||
ft_wav_pcm,
|
||||
ft_wsa_dune2,
|
||||
|
@ -102,7 +102,7 @@ const char* ft_name[];
|
|||
|
||||
class Cmix_file;
|
||||
|
||||
class Ccc_file
|
||||
class Ccc_file
|
||||
{
|
||||
public:
|
||||
const Cwin_handle& h();
|
||||
|
@ -120,24 +120,24 @@ public:
|
|||
Ccc_file(bool read_on_open);
|
||||
|
||||
const byte* begin() const
|
||||
{
|
||||
return m_data.begin();
|
||||
}
|
||||
{
|
||||
return m_data.begin();
|
||||
}
|
||||
|
||||
const byte* end() const
|
||||
{
|
||||
return m_data.end();
|
||||
}
|
||||
{
|
||||
return m_data.end();
|
||||
}
|
||||
|
||||
const byte* data() const
|
||||
{
|
||||
return m_data.data();
|
||||
}
|
||||
{
|
||||
return m_data.data();
|
||||
}
|
||||
|
||||
long long size() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
long long size() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
const byte* get_data() const
|
||||
{
|
||||
|
|
32
3rdParty/xcc/misc/cc_file_sh.h
vendored
32
3rdParty/xcc/misc/cc_file_sh.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -24,8 +24,8 @@ template <class T>
|
|||
class Ccc_file_sh : public Ccc_file_small
|
||||
{
|
||||
public:
|
||||
const T& header() const
|
||||
{
|
||||
return *reinterpret_cast<const T*>(data());
|
||||
}
|
||||
const T& header() const
|
||||
{
|
||||
return *reinterpret_cast<const T*>(data());
|
||||
}
|
||||
};
|
||||
|
|
26
3rdParty/xcc/misc/cc_file_small.h
vendored
26
3rdParty/xcc/misc/cc_file_small.h
vendored
|
@ -1,26 +1,26 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cc_file.h>
|
||||
|
||||
class Ccc_file_small : public Ccc_file
|
||||
class Ccc_file_small : public Ccc_file
|
||||
{
|
||||
public:
|
||||
Ccc_file_small() : Ccc_file(true)
|
||||
|
|
46
3rdParty/xcc/misc/cc_structures.cpp
vendored
46
3rdParty/xcc/misc/cc_structures.cpp
vendored
|
@ -1,40 +1,40 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "cc_structures.h"
|
||||
|
||||
const char* game_name[] =
|
||||
const char* game_name[] =
|
||||
{
|
||||
"Tiberian Dawn",
|
||||
"Red Alert",
|
||||
"Tiberian Sun",
|
||||
"Dune 2",
|
||||
"Dune 2000",
|
||||
"Red Alert 2",
|
||||
"Red Alert 2 Yuri's Revenge",
|
||||
"Renegade",
|
||||
"Generals",
|
||||
"Tiberian Dawn",
|
||||
"Red Alert",
|
||||
"Tiberian Sun",
|
||||
"Dune 2",
|
||||
"Dune 2000",
|
||||
"Red Alert 2",
|
||||
"Red Alert 2 Yuri's Revenge",
|
||||
"Renegade",
|
||||
"Generals",
|
||||
"Generals Zero Hour",
|
||||
"Emperor Battle for Dune",
|
||||
"Nox",
|
||||
"Battle for Middle Earth",
|
||||
"Battle for Middle Earth 2",
|
||||
"Tiberium Wars",
|
||||
"Tiberian Sun Firestorm",
|
||||
"Tiberian Sun Firestorm",
|
||||
};
|
||||
|
|
104
3rdParty/xcc/misc/cc_structures.h
vendored
104
3rdParty/xcc/misc/cc_structures.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -201,9 +201,9 @@ struct t_mix_index_entry
|
|||
size = size_;
|
||||
}
|
||||
|
||||
unsigned __int32 id;
|
||||
__int32 offset;
|
||||
__int32 size;
|
||||
unsigned __int32 id;
|
||||
__int32 offset;
|
||||
__int32 size;
|
||||
};
|
||||
|
||||
struct t_mix_rg_header
|
||||
|
@ -276,14 +276,14 @@ const char png_id[] = "\x89PNG\r\n\x1A\n";
|
|||
|
||||
struct t_shp_dune2_header
|
||||
{
|
||||
__int16 c_images;
|
||||
__int16 c_images;
|
||||
};
|
||||
|
||||
struct t_shp_dune2_image_header
|
||||
{
|
||||
__int16 compression;
|
||||
unsigned __int8 cy;
|
||||
unsigned __int16 cx;
|
||||
unsigned __int8 cy;
|
||||
unsigned __int16 cx;
|
||||
unsigned __int8 cy2;
|
||||
unsigned __int16 size_in;
|
||||
unsigned __int16 size_out;
|
||||
|
@ -291,29 +291,29 @@ struct t_shp_dune2_image_header
|
|||
|
||||
struct t_shp_header
|
||||
{
|
||||
__int16 c_images;
|
||||
__int16 unknown1;
|
||||
__int16 unknown2;
|
||||
__int16 cx;
|
||||
__int16 cy;
|
||||
__int32 unknown3;
|
||||
__int16 c_images;
|
||||
__int16 unknown1;
|
||||
__int16 unknown2;
|
||||
__int16 cx;
|
||||
__int16 cy;
|
||||
__int32 unknown3;
|
||||
};
|
||||
|
||||
struct t_shp_ts_header
|
||||
{
|
||||
__int16 zero;
|
||||
__int16 cx;
|
||||
__int16 cy;
|
||||
__int16 c_images;
|
||||
__int16 zero;
|
||||
__int16 cx;
|
||||
__int16 cy;
|
||||
__int16 c_images;
|
||||
};
|
||||
|
||||
struct t_shp_ts_image_header
|
||||
{
|
||||
__int16 x;
|
||||
__int16 y;
|
||||
__int16 cx;
|
||||
__int16 cy;
|
||||
__int32 compression;
|
||||
__int16 cx;
|
||||
__int16 cy;
|
||||
__int32 compression;
|
||||
__int32 unknown;
|
||||
__int32 zero;
|
||||
__int32 offset;
|
||||
|
@ -321,7 +321,7 @@ struct t_shp_ts_image_header
|
|||
|
||||
struct t_tga_header
|
||||
{
|
||||
byte id_size;
|
||||
byte id_size;
|
||||
byte map_t;
|
||||
byte image_t;
|
||||
unsigned __int16 map_first;
|
||||
|
@ -332,9 +332,9 @@ struct t_tga_header
|
|||
unsigned __int16 cx;
|
||||
unsigned __int16 cy;
|
||||
byte cb_pixel;
|
||||
byte alpha:4;
|
||||
byte horizontal:1;
|
||||
byte vertical:1;
|
||||
byte alpha : 4;
|
||||
byte horizontal : 1;
|
||||
byte vertical : 1;
|
||||
};
|
||||
|
||||
struct t_tmp_header
|
||||
|
@ -387,9 +387,9 @@ struct t_tmp_image_header
|
|||
__int32 y_extra;
|
||||
__int32 cx_extra;
|
||||
__int32 cy_extra;
|
||||
unsigned int has_extra_data: 1;
|
||||
unsigned int has_z_data: 1;
|
||||
unsigned int has_damaged_data: 1;
|
||||
unsigned int has_extra_data : 1;
|
||||
unsigned int has_z_data : 1;
|
||||
unsigned int has_damaged_data : 1;
|
||||
__int8 height;
|
||||
__int8 terrain_type;
|
||||
__int8 ramp_type;
|
||||
|
@ -451,7 +451,7 @@ struct t_vqa_header
|
|||
const __int32 vqa_c_mask = 0xff000000;
|
||||
const __int32 vqa_t_mask = 0x00ffffff;
|
||||
const __int32 vqa_file_id = *(__int32*)"FORM";
|
||||
const __int64 vqa_form_id = {*(__int64*)"WVQAVQHD"};
|
||||
const __int64 vqa_form_id = { *(__int64*)"WVQAVQHD" };
|
||||
const __int32 vqa_cbf_id = *(__int32*)"CBF\0";
|
||||
const __int32 vqa_cbp_id = *(__int32*)"CBP\0";
|
||||
const __int32 vqa_cpl_id = *(__int32*)"CPL\0";
|
||||
|
@ -465,7 +465,7 @@ const __int32 vqa_vqfr_id = *(__int32*)"VQFR";
|
|||
|
||||
struct t_vqp_header
|
||||
{
|
||||
unsigned __int32 c_tables;
|
||||
unsigned __int32 c_tables;
|
||||
};
|
||||
|
||||
struct t_vxl_header
|
||||
|
@ -489,9 +489,9 @@ struct t_vxl_section_header
|
|||
|
||||
struct t_vxl_section_tailer
|
||||
{
|
||||
__int32 span_start_ofs;
|
||||
__int32 span_end_ofs;
|
||||
__int32 span_data_ofs;
|
||||
__int32 span_start_ofs;
|
||||
__int32 span_end_ofs;
|
||||
__int32 span_data_ofs;
|
||||
float scale;
|
||||
float transform[3][4];
|
||||
float x_min_scale;
|
||||
|
@ -526,20 +526,20 @@ struct t_w3d_header
|
|||
|
||||
struct t_wsa_dune2_header
|
||||
{
|
||||
__int16 c_frames;
|
||||
__int16 cx;
|
||||
__int16 cy;
|
||||
__int16 c_frames;
|
||||
__int16 cx;
|
||||
__int16 cy;
|
||||
__int16 delta;
|
||||
};
|
||||
|
||||
struct t_wsa_header
|
||||
{
|
||||
__int16 c_frames;
|
||||
__int16 x;
|
||||
__int16 y;
|
||||
__int16 cx;
|
||||
__int16 cy;
|
||||
__int32 delta;
|
||||
__int16 c_frames;
|
||||
__int16 x;
|
||||
__int16 y;
|
||||
__int16 cx;
|
||||
__int16 cy;
|
||||
__int32 delta;
|
||||
};
|
||||
|
||||
struct t_xcc_header
|
||||
|
|
24
3rdParty/xcc/misc/crc.h
vendored
24
3rdParty/xcc/misc/crc.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
32
3rdParty/xcc/misc/ddpf_conversion.cpp
vendored
32
3rdParty/xcc/misc/ddpf_conversion.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -24,8 +24,7 @@ static int get_shift(unsigned int v)
|
|||
if (!v)
|
||||
return 0;
|
||||
int r = 0;
|
||||
while (~v & 1)
|
||||
{
|
||||
while (~v & 1) {
|
||||
r++;
|
||||
v >>= 1;
|
||||
}
|
||||
|
@ -35,8 +34,7 @@ static int get_shift(unsigned int v)
|
|||
static int get_size(unsigned int v)
|
||||
{
|
||||
int r = 0;
|
||||
while (v)
|
||||
{
|
||||
while (v) {
|
||||
if (v & 1)
|
||||
r++;
|
||||
v >>= 1;
|
||||
|
@ -58,7 +56,7 @@ void Cddpf_conversion::set_pf(const DDPIXELFORMAT& pf)
|
|||
|
||||
int Cddpf_conversion::get_color(int a, int r, int g, int b)
|
||||
{
|
||||
return a >> (8 - a_size) << a_shift | r >> (8 - r_size) << r_shift | g >> (8 - g_size) << g_shift | b >> (8 - b_size) << b_shift;
|
||||
return a >> (8 - a_size) << a_shift | r >> (8 - r_size) << r_shift | g >> (8 - g_size) << g_shift | b >> (8 - b_size) << b_shift;
|
||||
}
|
||||
|
||||
int Cddpf_conversion::get_color(int r, int g, int b)
|
||||
|
|
24
3rdParty/xcc/misc/ddpf_conversion.h
vendored
24
3rdParty/xcc/misc/ddpf_conversion.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
30
3rdParty/xcc/misc/file32.cpp
vendored
30
3rdParty/xcc/misc/file32.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -133,9 +133,9 @@ Cvirtual_binary Cfile32::get_mm()
|
|||
{
|
||||
if (!size())
|
||||
return Cvirtual_binary();
|
||||
Cwin_handle mh(CreateFileMapping(h(), NULL, PAGE_READONLY, 0, 0, NULL));
|
||||
void* d = mh ? MapViewOfFile(mh, FILE_MAP_READ, 0, 0, 0) : NULL;
|
||||
return d ? Cvirtual_binary(d, size(), std::shared_ptr<void>(d, UnmapViewOfFile)) : Cvirtual_binary();
|
||||
Cwin_handle mh(CreateFileMapping(h(), NULL, PAGE_READONLY, 0, 0, NULL));
|
||||
void* d = mh ? MapViewOfFile(mh, FILE_MAP_READ, 0, 0, 0) : NULL;
|
||||
return d ? Cvirtual_binary(d, size(), std::shared_ptr<void>(d, UnmapViewOfFile)) : Cvirtual_binary();
|
||||
}
|
||||
|
||||
Cvirtual_binary file32_read(const string& name)
|
||||
|
|
24
3rdParty/xcc/misc/file32.h
vendored
24
3rdParty/xcc/misc/file32.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
45
3rdParty/xcc/misc/fname.cpp
vendored
45
3rdParty/xcc/misc/fname.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -136,16 +136,14 @@ const Cfname& Cfname::operator=(string_view s)
|
|||
long p1 = s.rfind('\\');
|
||||
long p2 = s.rfind('.');
|
||||
char t[MAX_PATH];
|
||||
if (p1 != string::npos)
|
||||
{
|
||||
if (p1 != string::npos) {
|
||||
//copy last \ also
|
||||
t[s.copy(t, p1 + 1)] = 0;
|
||||
path = t;
|
||||
}
|
||||
t[s.copy(t, p2 - p1 - 1, p1 + 1)] = 0;
|
||||
title = t;
|
||||
if (p2 != s.npos && p1 < p2)
|
||||
{
|
||||
if (p2 != s.npos && p1 < p2) {
|
||||
t[s.copy(t, s.npos, p2)] = 0;
|
||||
ext = t;
|
||||
}
|
||||
|
@ -166,8 +164,7 @@ void create_deep_dir(string dir, const string& name)
|
|||
{
|
||||
int a = 0;
|
||||
int b;
|
||||
while ((b = name.find_first_of("/\\", a)) != string::npos)
|
||||
{
|
||||
while ((b = name.find_first_of("/\\", a)) != string::npos) {
|
||||
dir += '/' + name.substr(a, b - a);
|
||||
create_dir(dir);
|
||||
a = b + 1;
|
||||
|
@ -192,19 +189,15 @@ int move_file(string s, string d)
|
|||
bool fname_filter(const string& fname, const string& filter)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < filter.size(); i++)
|
||||
{
|
||||
for (i = 0; i < filter.size(); i++) {
|
||||
char c = filter[i];
|
||||
if (c == '*')
|
||||
{
|
||||
if (filter.find('*', i + 1) == string::npos)
|
||||
{
|
||||
if (c == '*') {
|
||||
if (filter.find('*', i + 1) == string::npos) {
|
||||
int j = fname.length() - filter.length() + 1;
|
||||
return j < 0 ? false : fname_filter(fname.substr(i + j), filter.substr(i + 1));
|
||||
}
|
||||
// for (int j = 0; j < min(fname.length(), filter.length()) - i; j++)
|
||||
for (size_t j = 0; j < fname.size(); j++)
|
||||
{
|
||||
for (size_t j = 0; j < fname.size(); j++) {
|
||||
if (fname_filter(fname.substr(i + j), filter.substr(i + 1)))
|
||||
return true;
|
||||
}
|
||||
|
|
26
3rdParty/xcc/misc/fname.h
vendored
26
3rdParty/xcc/misc/fname.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
Cfname GetModuleFileName(HMODULE hModule = 0);
|
||||
bool fname_filter(const string& fname, const string& filter);
|
||||
int create_dir(const string& dir);
|
||||
int create_dir(const string& dir);
|
||||
void create_deep_dir(string dir, const string& name);
|
||||
int delete_file(string fname);
|
||||
int copy_file(string s, string d);
|
||||
|
|
59
3rdParty/xcc/misc/hva_file.cpp
vendored
59
3rdParty/xcc/misc/hva_file.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -28,7 +28,7 @@ bool Chva_file::is_valid() const
|
|||
const t_hva_header& h = header();
|
||||
int size = get_size();
|
||||
return !(sizeof(t_hva_header) > size
|
||||
|| !h.c_frames
|
||||
|| !h.c_frames
|
||||
|| !h.c_sections
|
||||
|| sizeof(t_hva_header) + (48 * h.c_frames + 16) * h.c_sections != size);
|
||||
}
|
||||
|
@ -43,15 +43,11 @@ int Chva_file::extract_as_csv(const string& name) const
|
|||
<< endl;
|
||||
for (int i = 0; i < c_sections; i++)
|
||||
f << get_section_id(i) << ";;;;;";
|
||||
for (int j = 0; j < c_frames; j++)
|
||||
{
|
||||
for (int j = 0; j < c_frames; j++) {
|
||||
f << endl;
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
for (int i = 0; i < c_sections; i++)
|
||||
{
|
||||
for (int x = 0; x < 4; x++)
|
||||
{
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int i = 0; i < c_sections; i++) {
|
||||
for (int x = 0; x < 4; x++) {
|
||||
f << get_transform_matrix(i, j)[x + 4 * y] << ';';
|
||||
}
|
||||
f << ';';
|
||||
|
@ -83,25 +79,20 @@ Cvirtual_binary hva_file_write(const byte* s, int cb_s)
|
|||
header.c_sections = c_sections;
|
||||
w += sizeof(t_hva_header);
|
||||
l = f.read_line();
|
||||
for (int i = 0; i < c_sections; i++)
|
||||
{
|
||||
for (int i = 0; i < c_sections; i++) {
|
||||
strcpy(reinterpret_cast<char*>(w), l.get_next_line(sep).c_str());
|
||||
w += 16;
|
||||
l.get_next_line(sep);
|
||||
l.get_next_line(sep);
|
||||
l.get_next_line(sep);
|
||||
l.get_next_line(sep);
|
||||
l.get_next_line(sep);
|
||||
l.get_next_line(sep);
|
||||
l.get_next_line(sep);
|
||||
}
|
||||
float* transform_matrix = reinterpret_cast<float*>(w);
|
||||
for (int j = 0; j < c_frames; j++)
|
||||
{
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
for (int j = 0; j < c_frames; j++) {
|
||||
for (int y = 0; y < 3; y++) {
|
||||
l = f.read_line();
|
||||
for (int i = 0; i < c_sections; i++)
|
||||
{
|
||||
for (int x = 0; x < 4; x++)
|
||||
{
|
||||
for (int i = 0; i < c_sections; i++) {
|
||||
for (int x = 0; x < 4; x++) {
|
||||
transform_matrix[12 * (c_frames * i + j) + x + 4 * y] = atof(l.get_next_line(sep).c_str());
|
||||
}
|
||||
l.get_next_line(sep);
|
||||
|
|
24
3rdParty/xcc/misc/hva_file.h
vendored
24
3rdParty/xcc/misc/hva_file.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
48
3rdParty/xcc/misc/id_log.cpp
vendored
48
3rdParty/xcc/misc/id_log.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -36,8 +36,7 @@ t_id_list td_list, ra_list, ts_list, dune2_list, ra2_list;
|
|||
|
||||
static t_id_list& get_list(t_game game)
|
||||
{
|
||||
switch (game)
|
||||
{
|
||||
switch (game) {
|
||||
case game_ra:
|
||||
return ra_list;
|
||||
case game_ts:
|
||||
|
@ -56,8 +55,7 @@ static void read_list(t_game game, const char*& s)
|
|||
int count = *reinterpret_cast<const int*>(s);
|
||||
s += 4;
|
||||
t_idinfo idinfo;
|
||||
while (count--)
|
||||
{
|
||||
while (count--) {
|
||||
idinfo.name = s;
|
||||
s += idinfo.name.length() + 1;
|
||||
idinfo.description = s;
|
||||
|
@ -78,8 +76,7 @@ int mix_database::load()
|
|||
read_list(game_ra, data);
|
||||
read_list(game_ts, data);
|
||||
read_list(game_ra2, data);
|
||||
if (0)
|
||||
{
|
||||
if (0) {
|
||||
ofstream log_f("c:\\log.txt");
|
||||
for (auto& i : ts_list)
|
||||
log_f << i.second.name << '\t' << i.second.description << endl;
|
||||
|
@ -89,21 +86,16 @@ int mix_database::load()
|
|||
const char char1[] = "bgjm";
|
||||
const char char2[] = "ew";
|
||||
const char char3[] = "abc";
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (i)
|
||||
strcpy(name + 8, "ini");
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++) {
|
||||
name[2] = char1[j];
|
||||
for (int k = 0; k < 100; k++)
|
||||
{
|
||||
for (int k = 0; k < 100; k++) {
|
||||
memcpy(name + 3, nwzl(2, k).c_str(), 2);
|
||||
for (int l = 0; l < 2; l++)
|
||||
{
|
||||
for (int l = 0; l < 2; l++) {
|
||||
name[5] = char2[l];
|
||||
for (int m = 0; m < 3; m++)
|
||||
{
|
||||
for (int m = 0; m < 3; m++) {
|
||||
name[6] = char3[m];
|
||||
mix_database::add_name(game_td, name, "");
|
||||
mix_database::add_name(game_ra, name, "");
|
||||
|
|
24
3rdParty/xcc/misc/id_log.h
vendored
24
3rdParty/xcc/misc/id_log.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
28
3rdParty/xcc/misc/image_file.h
vendored
28
3rdParty/xcc/misc/image_file.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2001 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2001 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -29,7 +29,7 @@ class Cimage_file : public Cvideo_file<T>
|
|||
{
|
||||
public:
|
||||
virtual void decode(void*) const = 0;
|
||||
|
||||
|
||||
#ifndef XCC_MINIMAL_BUILD
|
||||
virtual Cvirtual_image vimage() const
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ public:
|
|||
return Cvirtual_image(image, this->cx(), this->cy(), this->cb_pixel(), this->palet());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int cf() const override
|
||||
{
|
||||
return 1;
|
||||
|
|
189
3rdParty/xcc/misc/mix_decode.cpp
vendored
189
3rdParty/xcc/misc/mix_decode.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -22,7 +22,7 @@
|
|||
|
||||
const static char* pubkey_str = "AihRvNoIbTn85FZRYNZRcT+i6KpU+maCsEqr3Q5q+LDB5tH7Tz2qQ38V";
|
||||
|
||||
const static char char2num[] =
|
||||
const static char char2num[] =
|
||||
{
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
|
@ -45,7 +45,7 @@ const static char char2num[] =
|
|||
using word = unsigned short;
|
||||
using bignum = uint32_t[64];
|
||||
|
||||
static struct
|
||||
static struct
|
||||
{
|
||||
bignum key1;
|
||||
bignum key2;
|
||||
|
@ -73,32 +73,29 @@ static void move_key_to_big(bignum n, const char* key, uint32_t klen, uint32_t b
|
|||
uint32_t sign = key[0] & 0x80 ? 0xff : 0;
|
||||
int i = blen * 4;
|
||||
for (; i > klen; i--)
|
||||
((char *)n)[i - 1] = sign;
|
||||
for (; i > 0; i--)
|
||||
((char *)n)[i - 1] = key[klen - i];
|
||||
((char*)n)[i - 1] = sign;
|
||||
for (; i > 0; i--)
|
||||
((char*)n)[i - 1] = key[klen - i];
|
||||
}
|
||||
|
||||
static void key_to_bignum(bignum n, char *key, uint32_t len)
|
||||
static void key_to_bignum(bignum n, char* key, uint32_t len)
|
||||
{
|
||||
uint32_t keylen;
|
||||
int i;
|
||||
|
||||
if (key[0] != 2)
|
||||
|
||||
if (key[0] != 2)
|
||||
return;
|
||||
key++;
|
||||
|
||||
if (key[0] & 0x80)
|
||||
{
|
||||
|
||||
if (key[0] & 0x80) {
|
||||
keylen = 0;
|
||||
for (i = 0; i < (key[0] & 0x7f); i++) keylen = (keylen << 8) | key[i+1];
|
||||
for (i = 0; i < (key[0] & 0x7f); i++) keylen = (keylen << 8) | key[i + 1];
|
||||
key += (key[0] & 0x7f) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
keylen = key[0];
|
||||
key++;
|
||||
}
|
||||
if (keylen <= len * 4)
|
||||
if (keylen <= len * 4)
|
||||
move_key_to_big(n, key, keylen, len);
|
||||
}
|
||||
|
||||
|
@ -117,8 +114,7 @@ static uint32_t bitlen_bignum(bignum n, uint32_t len)
|
|||
return 0;
|
||||
uint32_t bitlen = ddlen * 32;
|
||||
uint32_t mask = 0x80000000;
|
||||
while ((mask & n[ddlen - 1]) == 0)
|
||||
{
|
||||
while ((mask & n[ddlen - 1]) == 0) {
|
||||
mask >>= 1;
|
||||
bitlen--;
|
||||
}
|
||||
|
@ -130,8 +126,7 @@ static void init_pubkey()
|
|||
init_bignum(pubkey.key2, 0x10001, 64);
|
||||
char keytmp[256];
|
||||
uint32_t i2 = 0;
|
||||
for (uint32_t i = 0; i < strlen(pubkey_str);)
|
||||
{
|
||||
for (uint32_t i = 0; i < strlen(pubkey_str);) {
|
||||
uint32_t tmp = char2num[pubkey_str[i++]];
|
||||
tmp <<= 6; tmp |= char2num[pubkey_str[i++]];
|
||||
tmp <<= 6; tmp |= char2num[pubkey_str[i++]];
|
||||
|
@ -154,8 +149,7 @@ static int cmp_bignum(bignum n1, bignum n2, uint32_t len)
|
|||
{
|
||||
n1 += len - 1;
|
||||
n2 += len - 1;
|
||||
while (len > 0)
|
||||
{
|
||||
while (len > 0) {
|
||||
if (*n1 < *n2) return -1;
|
||||
if (*n1 > *n2) return 1;
|
||||
n1--;
|
||||
|
@ -173,11 +167,10 @@ static void mov_bignum(bignum dest, bignum src, uint32_t len)
|
|||
static void shr_bignum(bignum n, uint32_t bits, long int len)
|
||||
{
|
||||
uint32_t i;
|
||||
if (uint32_t i2 = bits / 32)
|
||||
{
|
||||
for (i = 0; i < len - i2; i++)
|
||||
if (uint32_t i2 = bits / 32) {
|
||||
for (i = 0; i < len - i2; i++)
|
||||
n[i] = n[i + i2];
|
||||
for (; i < len; i++)
|
||||
for (; i < len; i++)
|
||||
n[i] = 0;
|
||||
bits %= 32;
|
||||
}
|
||||
|
@ -191,11 +184,10 @@ static void shr_bignum(bignum n, uint32_t bits, long int len)
|
|||
static void shl_bignum(bignum n, uint32_t bits, uint32_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
if (uint32_t i2 = bits / 32)
|
||||
{
|
||||
for (i = len - 1; i > i2; i--)
|
||||
if (uint32_t i2 = bits / 32) {
|
||||
for (i = len - 1; i > i2; i--)
|
||||
n[i] = n[i - i2];
|
||||
for (; i > 0; i--)
|
||||
for (; i > 0; i--)
|
||||
n[i] = 0;
|
||||
bits %= 32;
|
||||
}
|
||||
|
@ -209,14 +201,13 @@ static void shl_bignum(bignum n, uint32_t bits, uint32_t len)
|
|||
static uint32_t sub_bignum(bignum dest, bignum src1, bignum src2, uint32_t carry, uint32_t len)
|
||||
{
|
||||
len *= 2;
|
||||
while (--len != -1)
|
||||
{
|
||||
uint32_t i1 = *(word *)src1;
|
||||
uint32_t i2 = *(word *)src2;
|
||||
*(word *)dest = i1 - i2 - carry;
|
||||
src1 = (uint32_t *)(((word *)src1) + 1);
|
||||
src2 = (uint32_t *)(((word *)src2) + 1);
|
||||
dest = (uint32_t *)(((word *)dest) + 1);
|
||||
while (--len != -1) {
|
||||
uint32_t i1 = *(word*)src1;
|
||||
uint32_t i2 = *(word*)src2;
|
||||
*(word*)dest = i1 - i2 - carry;
|
||||
src1 = (uint32_t*)(((word*)src1) + 1);
|
||||
src2 = (uint32_t*)(((word*)src2) + 1);
|
||||
dest = (uint32_t*)(((word*)dest) + 1);
|
||||
carry = ((i1 - i2 - carry) & 0x10000) ? 1 : 0;
|
||||
}
|
||||
return carry;
|
||||
|
@ -234,18 +225,15 @@ static void inv_bignum(bignum n1, bignum n2, uint32_t len)
|
|||
uint32_t n2_bytelen = ((n2_bitlen - 1) / 32) * 4;
|
||||
n_tmp[n2_bytelen / 4] |= ((uint32_t)1) << ((n2_bitlen - 1) & 0x1f);
|
||||
|
||||
while (n2_bitlen > 0)
|
||||
{
|
||||
while (n2_bitlen > 0) {
|
||||
n2_bitlen--;
|
||||
shl_bignum(n_tmp, 1, len);
|
||||
if (cmp_bignum(n_tmp, n2, len) != -1)
|
||||
{
|
||||
if (cmp_bignum(n_tmp, n2, len) != -1) {
|
||||
sub_bignum(n_tmp, n_tmp, n2, 0, len);
|
||||
*n1 |= bit;
|
||||
}
|
||||
bit >>= 1;
|
||||
if (bit == 0)
|
||||
{
|
||||
if (bit == 0) {
|
||||
n1--;
|
||||
bit = 0x80000000;
|
||||
}
|
||||
|
@ -255,7 +243,7 @@ static void inv_bignum(bignum n1, bignum n2, uint32_t len)
|
|||
|
||||
static void inc_bignum(bignum n, uint32_t len)
|
||||
{
|
||||
while ((++*n == 0) && (--len > 0))
|
||||
while ((++ * n == 0) && (--len > 0))
|
||||
n++;
|
||||
}
|
||||
|
||||
|
@ -271,37 +259,34 @@ static void init_two_dw(bignum n, uint32_t len)
|
|||
shr_bignum(glob1_hi_inv, 1, 2);
|
||||
glob1_hi_bitlen = (glob1_hi_bitlen + 15) % 16 + 1;
|
||||
inc_bignum(glob1_hi_inv, 2);
|
||||
if (bitlen_bignum(glob1_hi_inv, 2) > 32)
|
||||
{
|
||||
if (bitlen_bignum(glob1_hi_inv, 2) > 32) {
|
||||
shr_bignum(glob1_hi_inv, 1, 2);
|
||||
glob1_hi_bitlen--;
|
||||
}
|
||||
glob1_hi_inv_lo = *(word *)glob1_hi_inv;
|
||||
glob1_hi_inv_hi = *(((word *)glob1_hi_inv) + 1);
|
||||
glob1_hi_inv_lo = *(word*)glob1_hi_inv;
|
||||
glob1_hi_inv_hi = *(((word*)glob1_hi_inv) + 1);
|
||||
}
|
||||
|
||||
static void mul_bignum_word(bignum n1, bignum n2, uint32_t mul, uint32_t len)
|
||||
{
|
||||
uint32_t tmp = 0;
|
||||
for (uint32_t i = 0; i < len; i++)
|
||||
{
|
||||
tmp = mul * (*(word *)n2) + *(word *)n1 + tmp;
|
||||
*(word *)n1 = tmp;
|
||||
n1 = (uint32_t *)(((word *)n1) + 1);
|
||||
n2 = (uint32_t *)(((word *)n2) + 1);
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
tmp = mul * (*(word*)n2) + *(word*)n1 + tmp;
|
||||
*(word*)n1 = tmp;
|
||||
n1 = (uint32_t*)(((word*)n1) + 1);
|
||||
n2 = (uint32_t*)(((word*)n2) + 1);
|
||||
tmp >>= 16;
|
||||
}
|
||||
*(word *)n1 += tmp;
|
||||
*(word*)n1 += tmp;
|
||||
}
|
||||
|
||||
static void mul_bignum(bignum dest, bignum src1, bignum src2, uint32_t len)
|
||||
{
|
||||
init_bignum(dest, 0, len * 2);
|
||||
for (uint32_t i = 0; i < len * 2; i++)
|
||||
{
|
||||
mul_bignum_word(dest, src1, *(word *)src2, len * 2);
|
||||
src2 = (uint32_t *)(((word *)src2) + 1);
|
||||
dest = (uint32_t *)(((word *)dest) + 1);
|
||||
for (uint32_t i = 0; i < len * 2; i++) {
|
||||
mul_bignum_word(dest, src1, *(word*)src2, len * 2);
|
||||
src2 = (uint32_t*)(((word*)src2) + 1);
|
||||
dest = (uint32_t*)(((word*)dest) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,20 +304,20 @@ static void neg_bignum(bignum n, uint32_t len)
|
|||
|
||||
static uint32_t get_mulword(bignum n)
|
||||
{
|
||||
word* wn = (word *)n;
|
||||
word* wn = (word*)n;
|
||||
uint32_t i = (((((((((*(wn - 1) ^ 0xffff) & 0xffff) * glob1_hi_inv_lo + 0x10000) >> 1)
|
||||
+ (((*(wn-2) ^ 0xffff) * glob1_hi_inv_hi + glob1_hi_inv_hi) >> 1) + 1)
|
||||
>> 16) + ((((*(wn-1) ^ 0xffff) & 0xffff) * glob1_hi_inv_hi) >> 1) +
|
||||
(((*wn ^ 0xffff) * glob1_hi_inv_lo) >> 1) + 1) >> 14) + glob1_hi_inv_hi
|
||||
* (*wn ^ 0xffff) * 2) >> glob1_hi_bitlen;
|
||||
if (i > 0xffff)
|
||||
+ (((*(wn - 2) ^ 0xffff) * glob1_hi_inv_hi + glob1_hi_inv_hi) >> 1) + 1)
|
||||
>> 16) + ((((*(wn - 1) ^ 0xffff) & 0xffff) * glob1_hi_inv_hi) >> 1) +
|
||||
(((*wn ^ 0xffff) * glob1_hi_inv_lo) >> 1) + 1) >> 14) + glob1_hi_inv_hi
|
||||
* (*wn ^ 0xffff) * 2) >> glob1_hi_bitlen;
|
||||
if (i > 0xffff)
|
||||
i = 0xffff;
|
||||
return i & 0xffff;
|
||||
}
|
||||
|
||||
static void dec_bignum(bignum n, uint32_t len)
|
||||
{
|
||||
while ((--*n == 0xffffffff) && (--len > 0))
|
||||
while ((-- * n == 0xffffffff) && (--len > 0))
|
||||
n++;
|
||||
}
|
||||
|
||||
|
@ -341,24 +326,20 @@ static void calc_a_bignum(bignum n1, bignum n2, bignum n3, uint32_t len)
|
|||
mul_bignum(glob2, n2, n3, len);
|
||||
glob2[len * 2] = 0;
|
||||
uint32_t g2_len_x2 = len_bignum(glob2, len * 2 + 1) * 2;
|
||||
if (g2_len_x2 >= glob1_len_x2)
|
||||
{
|
||||
if (g2_len_x2 >= glob1_len_x2) {
|
||||
inc_bignum(glob2, len * 2 + 1);
|
||||
neg_bignum(glob2, len * 2 + 1);
|
||||
uint32_t len_diff = g2_len_x2 + 1 - glob1_len_x2;
|
||||
word* esi = ((word *)glob2) + (1 + g2_len_x2 - glob1_len_x2);
|
||||
word* edi = ((word *)glob2) + (g2_len_x2 + 1);
|
||||
for (; len_diff != 0; len_diff--)
|
||||
{
|
||||
word* esi = ((word*)glob2) + (1 + g2_len_x2 - glob1_len_x2);
|
||||
word* edi = ((word*)glob2) + (g2_len_x2 + 1);
|
||||
for (; len_diff != 0; len_diff--) {
|
||||
edi--;
|
||||
word tmp = get_mulword((uint32_t *)edi);
|
||||
word tmp = get_mulword((uint32_t*)edi);
|
||||
esi--;
|
||||
if (tmp > 0)
|
||||
{
|
||||
mul_bignum_word((uint32_t *)esi, glob1, tmp, 2 * len);
|
||||
if ((*edi & 0x8000) == 0)
|
||||
{
|
||||
if (sub_bignum((uint32_t *)esi, (uint32_t *)esi, glob1, 0, len))
|
||||
if (tmp > 0) {
|
||||
mul_bignum_word((uint32_t*)esi, glob1, tmp, 2 * len);
|
||||
if ((*edi & 0x8000) == 0) {
|
||||
if (sub_bignum((uint32_t*)esi, (uint32_t*)esi, glob1, 0, len))
|
||||
(*edi)--;
|
||||
}
|
||||
}
|
||||
|
@ -381,17 +362,15 @@ static void calc_a_key(bignum n1, bignum n2, bignum n3, bignum n4, uint32_t len)
|
|||
n3 += n3_len - 1;
|
||||
n3_bitlen--;
|
||||
mov_bignum(n1, n2, n4_len);
|
||||
while (--n3_bitlen != -1)
|
||||
{
|
||||
if (bit_mask == 0)
|
||||
{
|
||||
while (--n3_bitlen != -1) {
|
||||
if (bit_mask == 0) {
|
||||
bit_mask = 0x80000000;
|
||||
n3--;
|
||||
}
|
||||
calc_a_bignum(n_tmp, n1, n1, n4_len);
|
||||
if (*n3 & bit_mask)
|
||||
if (*n3 & bit_mask)
|
||||
calc_a_bignum(n1, n_tmp, n2, n4_len);
|
||||
else
|
||||
else
|
||||
mov_bignum(n1, n_tmp, n4_len);
|
||||
bit_mask >>= 1;
|
||||
}
|
||||
|
@ -407,18 +386,17 @@ static void calc_a_key(bignum n1, bignum n2, bignum n3, bignum n4, uint32_t len)
|
|||
glob1_hi_inv_hi = 0;
|
||||
}
|
||||
|
||||
static void process_predata(const byte* pre, uint32_t pre_len, byte *buf)
|
||||
static void process_predata(const byte* pre, uint32_t pre_len, byte* buf)
|
||||
{
|
||||
bignum n2, n3;
|
||||
const uint32_t a = (pubkey.len - 1) / 8;
|
||||
while (a + 1 <= pre_len)
|
||||
{
|
||||
while (a + 1 <= pre_len) {
|
||||
init_bignum(n2, 0, 64);
|
||||
memmove(n2, pre, a + 1);
|
||||
calc_a_key(n3, n2, pubkey.key2, pubkey.key1, 64);
|
||||
|
||||
|
||||
memmove(buf, n3, a);
|
||||
|
||||
|
||||
pre_len -= a + 1;
|
||||
pre += a + 1;
|
||||
buf += a;
|
||||
|
@ -428,8 +406,7 @@ static void process_predata(const byte* pre, uint32_t pre_len, byte *buf)
|
|||
void get_blowfish_key(const byte* s, span<byte> d)
|
||||
{
|
||||
static bool public_key_initialized = false;
|
||||
if (!public_key_initialized)
|
||||
{
|
||||
if (!public_key_initialized) {
|
||||
init_pubkey();
|
||||
public_key_initialized = true;
|
||||
}
|
||||
|
|
24
3rdParty/xcc/misc/mix_decode.h
vendored
24
3rdParty/xcc/misc/mix_decode.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
168
3rdParty/xcc/misc/mix_file.cpp
vendored
168
3rdParty/xcc/misc/mix_file.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdafx.h>
|
||||
|
@ -58,8 +58,7 @@ bool Cmix_file::is_valid()
|
|||
return false;
|
||||
m_has_checksum = header.flags & mix_checksum;
|
||||
m_is_encrypted = header.flags & mix_encrypted;
|
||||
if (m_is_encrypted)
|
||||
{
|
||||
if (m_is_encrypted) {
|
||||
Cblowfish bf;
|
||||
std::array<byte, cb_mix_key> key;
|
||||
get_blowfish_key(data + 4, key);
|
||||
|
@ -69,9 +68,7 @@ bool Cmix_file::is_valid()
|
|||
t_mix_header* header = reinterpret_cast<t_mix_header*>(e);
|
||||
if (!header->c_files || 84 + (sizeof(t_mix_header) + header->c_files * sizeof(t_mix_index_entry) + 7 & ~7) + header->size + (m_has_checksum ? 20 : 0) != size)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
const t_mix_header* header = reinterpret_cast<const t_mix_header*>(data + 4);
|
||||
if (!header->c_files || 4 + sizeof(t_mix_header) + header->c_files * sizeof(t_mix_index_entry) + header->size + (m_has_checksum ? 20 : 0) != size)
|
||||
return false;
|
||||
|
@ -85,42 +82,35 @@ int Cmix_file::post_open()
|
|||
{
|
||||
#ifndef NO_FT_SUPPORT
|
||||
bool index_read = false;
|
||||
if (h())
|
||||
{
|
||||
if (h()) {
|
||||
Cmix_rg_file f;
|
||||
if (get_data())
|
||||
f.load(vdata());
|
||||
else
|
||||
f.open(h());
|
||||
if (f.is_open() && f.is_valid())
|
||||
{
|
||||
if (f.is_open() && f.is_valid()) {
|
||||
m_game = game_rg;
|
||||
m_is_encrypted = m_has_checksum = false;
|
||||
int c_files = f.get_c_files();
|
||||
m_index.resize(c_files);
|
||||
for (int i = 0; i < c_files; i++)
|
||||
{
|
||||
for (int i = 0; i < c_files; i++) {
|
||||
string name = f.get_name(i);
|
||||
mix_database::add_name(m_game, name, "-");
|
||||
m_index[i] = t_mix_index_entry(get_id(get_game(), name), f.get_offset(name), f.get_size(name));
|
||||
}
|
||||
index_read = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Cbig_file f;
|
||||
if (get_data())
|
||||
f.load(vdata());
|
||||
else
|
||||
f.open(h());
|
||||
if (f.is_open() && f.is_valid())
|
||||
{
|
||||
if (f.is_open() && f.is_valid()) {
|
||||
m_game = game_gr;
|
||||
m_is_encrypted = m_has_checksum = false;
|
||||
int c_files = f.get_c_files();
|
||||
m_index.resize(c_files);
|
||||
for (int i = 0; i < c_files; i++)
|
||||
{
|
||||
for (int i = 0; i < c_files; i++) {
|
||||
string name = f.get_name(i);
|
||||
mix_database::add_name(m_game, name, "-");
|
||||
m_index[i] = t_mix_index_entry(get_id(get_game(), name), f.get_offset(name), f.get_size(name));
|
||||
|
@ -129,28 +119,24 @@ int Cmix_file::post_open()
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!index_read)
|
||||
{
|
||||
if (!index_read) {
|
||||
Cpak_file f;
|
||||
if (get_data())
|
||||
f.load(vdata());
|
||||
else
|
||||
{
|
||||
else {
|
||||
int size = min<int>(get_size(), 64 << 10);
|
||||
Cvirtual_binary data;
|
||||
test_fail(read(data.write_start(size), size));
|
||||
f.load(data, get_size());
|
||||
}
|
||||
if (f.is_valid())
|
||||
{
|
||||
if (f.is_valid()) {
|
||||
m_game = game_dune2;
|
||||
m_is_encrypted = m_has_checksum = false;
|
||||
int c_files = f.get_c_files();
|
||||
if (c_files >> 12)
|
||||
test_fail(1);
|
||||
m_index.resize(c_files);
|
||||
for (int i = 0; i < c_files; i++)
|
||||
{
|
||||
for (int i = 0; i < c_files; i++) {
|
||||
string name = f.get_name(i);
|
||||
mix_database::add_name(m_game, name, "-");
|
||||
m_index[i] = t_mix_index_entry(get_id(get_game(), name), f.get_offset(name), f.get_size(name));
|
||||
|
@ -164,8 +150,7 @@ int Cmix_file::post_open()
|
|||
t_mix_header header;
|
||||
seek(0);
|
||||
test_fail(read(&header, sizeof(t_mix_header)));
|
||||
if (header.c_files)
|
||||
{
|
||||
if (header.c_files) {
|
||||
m_game = game_td;
|
||||
m_is_encrypted = m_has_checksum = false;
|
||||
int c_files = header.c_files;
|
||||
|
@ -176,16 +161,13 @@ int Cmix_file::post_open()
|
|||
test_fail(read(&m_index[0], cb_index));
|
||||
for (int i = 0; i < c_files; i++)
|
||||
m_index[i].offset += 6 + cb_index;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
m_has_checksum = header.flags & mix_checksum;
|
||||
m_is_encrypted = header.flags & mix_encrypted;
|
||||
bool aligned = true;
|
||||
Cblowfish bf;
|
||||
seek(4);
|
||||
if (m_is_encrypted)
|
||||
{
|
||||
if (m_is_encrypted) {
|
||||
byte key_source[cb_mix_key_source];
|
||||
read(key_source, cb_mix_key_source);
|
||||
std::array<byte, cb_mix_key> key;
|
||||
|
@ -200,43 +182,36 @@ int Cmix_file::post_open()
|
|||
const int cb_f = cb_index + 5 & ~7;
|
||||
if (get_size() != 92 + cb_f + header.size + (m_has_checksum ? 20 : 0))
|
||||
test_fail(1);
|
||||
if (c_files)
|
||||
{
|
||||
if (c_files) {
|
||||
Cvirtual_binary f;
|
||||
read(f.write_start(cb_f), cb_f);
|
||||
bf.decipher(f.data_edit(), f.data_edit(), cb_f);
|
||||
m_index.resize(c_files);
|
||||
memcpy(&m_index[0], e + 6, 2);
|
||||
memcpy(reinterpret_cast<byte*>(&m_index[0]) + 2, f.data(), cb_index - 2);
|
||||
for (int i = 0; i < c_files; i++)
|
||||
{
|
||||
for (int i = 0; i < c_files; i++) {
|
||||
if (m_index[i].offset & 0xf)
|
||||
aligned = false;
|
||||
m_index[i].offset += 92 + cb_f;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
read(&header, sizeof(header));
|
||||
int c_files = header.c_files;
|
||||
const int cb_index = c_files * sizeof(t_mix_index_entry);
|
||||
if (get_size() != 4 + sizeof(t_mix_header) + cb_index + header.size + (m_has_checksum ? 20 : 0))
|
||||
test_fail(1);
|
||||
test_fail(1);
|
||||
m_index.resize(c_files);
|
||||
read(&m_index[0], cb_index);
|
||||
for (int i = 0; i < c_files; i++)
|
||||
{
|
||||
for (int i = 0; i < c_files; i++) {
|
||||
if (m_index[i].offset & 0xf)
|
||||
aligned = false;
|
||||
m_index[i].offset += 4 + sizeof(t_mix_header) + cb_index;
|
||||
}
|
||||
}
|
||||
m_game = is_encrypted() ? game_ra : game_ts;
|
||||
for (int i = 0; i < get_c_files(); i++)
|
||||
{
|
||||
if (get_id(i) == 0x763c81dd)
|
||||
{
|
||||
for (int i = 0; i < get_c_files(); i++) {
|
||||
if (get_id(i) == 0x763c81dd) {
|
||||
m_game = game_ts;
|
||||
break;
|
||||
}
|
||||
|
@ -248,55 +223,46 @@ int Cmix_file::post_open()
|
|||
for (int i = 0; i < get_c_files(); i++)
|
||||
m_id_index[get_id(i)] = i;
|
||||
#ifndef NO_FT_SUPPORT
|
||||
if (m_ft_support)
|
||||
{
|
||||
switch (m_game)
|
||||
{
|
||||
if (m_ft_support) {
|
||||
switch (m_game) {
|
||||
case game_dune2:
|
||||
case game_rg:
|
||||
break;
|
||||
default:
|
||||
int count[game_unknown] = {0};
|
||||
for (int i = 0; i < get_c_files(); i++)
|
||||
{
|
||||
int count[game_unknown] = { 0 };
|
||||
for (int i = 0; i < get_c_files(); i++) {
|
||||
int id = get_id(i);
|
||||
for (int game = game_td; game < game_unknown; game++)
|
||||
count[game] += mix_database::get_name(static_cast<t_game>(game), id).empty();
|
||||
}
|
||||
int min = count[0];
|
||||
for (int game = 0; game < game_unknown; game++)
|
||||
{
|
||||
if (count[game] < min)
|
||||
{
|
||||
for (int game = 0; game < game_unknown; game++) {
|
||||
if (count[game] < min) {
|
||||
m_game = static_cast<t_game>(game);
|
||||
min = count[game];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (vdata().size() == get_size())
|
||||
{
|
||||
if (vdata().size() == get_size()) {
|
||||
int crc = compute_crc(&m_index[0], get_c_files() * sizeof(t_mix_index_entry));
|
||||
Cvirtual_binary s = mix_cache::get_data(crc);
|
||||
m_index_ft.resize(get_c_files());
|
||||
if (s.size() == get_c_files() * sizeof(t_file_type))
|
||||
memcpy(&m_index_ft[0], s.data(), get_c_files() * sizeof(t_file_type));
|
||||
else
|
||||
{
|
||||
else {
|
||||
using t_block_map = multimap<int, int>;
|
||||
|
||||
t_block_map block_map;
|
||||
for (int i = 0; i < get_c_files(); i++)
|
||||
block_map.insert(t_block_map::value_type(get_offset(get_id(i)), i));
|
||||
for (auto& i : block_map)
|
||||
{
|
||||
for (auto& i : block_map) {
|
||||
Ccc_file f(false);
|
||||
f.open(get_id(i.second), *this);
|
||||
m_index_ft[i.second] = f.get_file_type();
|
||||
}
|
||||
mix_cache::set_data(crc, Cvirtual_binary(&m_index_ft[0], get_c_files() * sizeof(t_file_type)));
|
||||
}
|
||||
for (int i = 0; i < get_c_files(); i++)
|
||||
{
|
||||
for (int i = 0; i < get_c_files(); i++) {
|
||||
int id = get_id(i);
|
||||
Cxcc_lmd_file f;
|
||||
if (get_type(id) != ft_xcc_lmd || f.open(id, *this) || !f.is_valid())
|
||||
|
@ -304,8 +270,7 @@ int Cmix_file::post_open()
|
|||
m_game = f.get_game();
|
||||
int count = f.get_c_fnames();
|
||||
const char* r = f.get_fnames();
|
||||
while (count--)
|
||||
{
|
||||
while (count--) {
|
||||
string name = r;
|
||||
r += name.length() + 1;
|
||||
mix_database::add_name(m_game, name, "-");
|
||||
|
@ -314,20 +279,17 @@ int Cmix_file::post_open()
|
|||
}
|
||||
}
|
||||
#endif
|
||||
if (m_mix_expansion)
|
||||
{
|
||||
if (m_mix_expansion) {
|
||||
int c_files = get_c_files();
|
||||
for (int i = 0; i < c_files; i++)
|
||||
{
|
||||
for (int i = 0; i < c_files; i++) {
|
||||
if (get_type(m_index[i].id) != ft_mix)
|
||||
continue;
|
||||
Cmix_file f;
|
||||
f.open(m_index[i].id, *this);
|
||||
f.open(m_index[i].id, *this);
|
||||
int c_files = get_c_files();
|
||||
int new_c_files = f.get_c_files();
|
||||
m_index.resize(c_files + new_c_files);
|
||||
for (int j = 0; j < new_c_files; j++)
|
||||
{
|
||||
for (int j = 0; j < new_c_files; j++) {
|
||||
int id = f.get_id(j);
|
||||
m_index[c_files + j] = t_mix_index_entry(id, f.get_offset(id) + get_offset(m_index[i].id), f.get_size(id));
|
||||
m_id_index[id] = c_files + j;
|
||||
|
@ -336,14 +298,14 @@ int Cmix_file::post_open()
|
|||
memcpy(&m_index_ft[c_files], &f.m_index_ft[0], new_c_files * sizeof(t_file_type));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Cmix_file::close()
|
||||
{
|
||||
m_id_index.clear();
|
||||
m_index_ft.clear();
|
||||
m_index.clear();
|
||||
m_index.clear();
|
||||
Ccc_file::close();
|
||||
}
|
||||
|
||||
|
@ -360,34 +322,30 @@ int Cmix_file::get_id(t_game game, string name)
|
|||
{
|
||||
boost::to_upper(name);
|
||||
std::replace(name.begin(), name.end(), '/', '\\');
|
||||
switch (game)
|
||||
{
|
||||
switch (game) {
|
||||
case game_ts:
|
||||
case game_ra2:
|
||||
case game_ra2_yr:
|
||||
{
|
||||
const int l = name.length();
|
||||
int a = l & ~3;
|
||||
if (l & 3)
|
||||
{
|
||||
name += static_cast<char>(l - a);
|
||||
name.append(3 - (l & 3), name[a]);
|
||||
}
|
||||
return compute_crc(name.c_str(), name.length());
|
||||
{
|
||||
const int l = name.length();
|
||||
int a = l & ~3;
|
||||
if (l & 3) {
|
||||
name += static_cast<char>(l - a);
|
||||
name.append(3 - (l & 3), name[a]);
|
||||
}
|
||||
return compute_crc(name.c_str(), name.length());
|
||||
}
|
||||
case game_rg:
|
||||
case game_gr:
|
||||
case game_gr_zh:
|
||||
return compute_crc(name.c_str(), name.length());
|
||||
return compute_crc(name.c_str(), name.length());
|
||||
default:
|
||||
int i = 0;
|
||||
unsigned int id = 0;
|
||||
int l = name.length();
|
||||
while (i < l)
|
||||
{
|
||||
while (i < l) {
|
||||
unsigned int a = 0;
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++) {
|
||||
a >>= 8;
|
||||
if (i < l)
|
||||
a |= static_cast<unsigned int>(name[i++]) << 24;
|
||||
|
|
30
3rdParty/xcc/misc/mix_file.h
vendored
30
3rdParty/xcc/misc/mix_file.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -21,7 +21,7 @@
|
|||
#include "cc_file.h"
|
||||
#include "cc_structures.h"
|
||||
|
||||
class Cmix_file : public Ccc_file
|
||||
class Cmix_file : public Ccc_file
|
||||
{
|
||||
public:
|
||||
int post_open();
|
||||
|
@ -88,12 +88,12 @@ public:
|
|||
|
||||
bool has_checksum() const
|
||||
{
|
||||
return m_has_checksum;
|
||||
return m_has_checksum;
|
||||
}
|
||||
|
||||
bool is_encrypted() const
|
||||
{
|
||||
return m_is_encrypted;
|
||||
return m_is_encrypted;
|
||||
}
|
||||
|
||||
const t_mix_index_entry* index() const
|
||||
|
|
27
3rdParty/xcc/misc/mix_file_write.cpp
vendored
27
3rdParty/xcc/misc/mix_file_write.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -63,8 +63,7 @@ int Cmix_file_write::write(byte* d) const
|
|||
t_mix_index_entry* index = reinterpret_cast<t_mix_index_entry*>(w);
|
||||
w += m_index.size() * sizeof(t_mix_index_entry);
|
||||
byte* body_start = w;
|
||||
for (auto& i : m_index)
|
||||
{
|
||||
for (auto& i : m_index) {
|
||||
index->id = i.first;
|
||||
index->offset = w - body_start;
|
||||
index->size = i.second.size();
|
||||
|
|
26
3rdParty/xcc/misc/mix_file_write.h
vendored
26
3rdParty/xcc/misc/mix_file_write.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -22,7 +22,7 @@
|
|||
#include <virtual_binary.h>
|
||||
#include "xcc_lmd_file_write.h"
|
||||
|
||||
class Cmix_file_write
|
||||
class Cmix_file_write
|
||||
{
|
||||
public:
|
||||
void add_file(int id, const Cvirtual_binary d);
|
||||
|
|
30
3rdParty/xcc/misc/null_ini_reader.h
vendored
30
3rdParty/xcc/misc/null_ini_reader.h
vendored
|
@ -1,26 +1,26 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ini_reader.h"
|
||||
|
||||
class Cnull_ini_reader : public Cini_reader
|
||||
class Cnull_ini_reader : public Cini_reader
|
||||
{
|
||||
public:
|
||||
int process_section_start(string_view) override
|
||||
|
@ -33,13 +33,13 @@ public:
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int process_key(string_view, string_view) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool is_valid() const
|
||||
bool is_valid() const
|
||||
{
|
||||
return mc_sections;
|
||||
}
|
||||
|
|
27
3rdParty/xcc/misc/pal_file.cpp
vendored
27
3rdParty/xcc/misc/pal_file.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -26,8 +26,7 @@ bool Cpal_file::is_valid() const
|
|||
if (get_size() != sizeof(t_palet))
|
||||
return false;
|
||||
const t_palet_entry* p = get_palet();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
for (int i = 0; i < 256; i++) {
|
||||
if ((p[i].r | p[i].g | p[i].b) & 0xc0)
|
||||
return false;
|
||||
}
|
||||
|
|
24
3rdParty/xcc/misc/pal_file.h
vendored
24
3rdParty/xcc/misc/pal_file.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
76
3rdParty/xcc/misc/palet.cpp
vendored
76
3rdParty/xcc/misc/palet.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -25,8 +25,7 @@ void convert_image_8_to_24(const byte* s, byte* d, int cx, int cy, const t_palet
|
|||
const byte* r = s;
|
||||
byte* w = d;
|
||||
int c = cx * cy;
|
||||
while (c--)
|
||||
{
|
||||
while (c--) {
|
||||
const t_palet_entry* v = palet + *r++;
|
||||
*w++ = v->r;
|
||||
*w++ = v->g;
|
||||
|
@ -37,10 +36,8 @@ void convert_image_8_to_24(const byte* s, byte* d, int cx, int cy, const t_palet
|
|||
void create_downsample_table(const t_palet palet, byte* rp)
|
||||
{
|
||||
byte* rp_w = rp;
|
||||
for (int b = 0; b < 0x40; b++)
|
||||
{
|
||||
for (int g = 0; g < 0x40; g++)
|
||||
{
|
||||
for (int b = 0; b < 0x40; b++) {
|
||||
for (int g = 0; g < 0x40; g++) {
|
||||
for (int r = 0; r < 0x40; r++)
|
||||
*rp_w++ = find_color(r * 255 / 63, g * 255 / 63, b * 255 / 63, palet);
|
||||
}
|
||||
|
@ -52,8 +49,7 @@ void convert_image_24_to_8(const byte* s, byte* d, int cx, int cy, const byte* r
|
|||
const byte* r = s;
|
||||
byte* w = d;
|
||||
int c = cx * cy;
|
||||
while (c--)
|
||||
{
|
||||
while (c--) {
|
||||
int red = *r++ >> 2 & 0x3f;
|
||||
int green = *r++ >> 2 & 0x3f;
|
||||
int blue = *r++ >> 2 & 0x3f;
|
||||
|
@ -66,8 +62,7 @@ void convert_image_24_to_8(const byte* s, byte* d, int cx, int cy, const t_palet
|
|||
const byte* r = s;
|
||||
byte* w = d;
|
||||
int c = cx * cy;
|
||||
while (c--)
|
||||
{
|
||||
while (c--) {
|
||||
int red = *r++;
|
||||
int green = *r++;
|
||||
int blue = *r++;
|
||||
|
@ -80,8 +75,7 @@ void downsample_image(const t_palet32entry* s, byte* d, int cx, int cy, const by
|
|||
const t_palet32entry* r = s;
|
||||
byte* w = d;
|
||||
int c = cx * cy;
|
||||
while (c--)
|
||||
{
|
||||
while (c--) {
|
||||
t_palet32entry e = *r++;
|
||||
*w++ = e.a < 0x80 ? 0 : rp[e.r >> 2 | (e.g & 0xfc) << 4 | (e.b & 0xfc) << 10];
|
||||
}
|
||||
|
@ -92,8 +86,7 @@ void downsample_image(const t_palet32entry* s, byte* d, int cx, int cy, const t_
|
|||
const t_palet32entry* r = s;
|
||||
byte* w = d;
|
||||
int c = cx * cy;
|
||||
while (c--)
|
||||
{
|
||||
while (c--) {
|
||||
t_palet32entry e = *r++;
|
||||
if (e.a < 0x80)
|
||||
*w++ = 0;
|
||||
|
@ -107,20 +100,16 @@ void upsample_image(const byte* s, t_palet32entry* d, int cx, int cy, const t_pa
|
|||
const byte* r = s;
|
||||
t_palet32entry* w = d;
|
||||
int c = cx * cy;
|
||||
while (c--)
|
||||
{
|
||||
while (c--) {
|
||||
t_palet32entry& e = *w++;
|
||||
int z = *r++;
|
||||
if (z)
|
||||
{
|
||||
if (z) {
|
||||
const t_palet_entry* v = palet + z;
|
||||
e.r = v->r;
|
||||
e.g = v->g;
|
||||
e.b = v->b;
|
||||
e.a = 0xff;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
e.r = 0x80;
|
||||
e.g = 0x80;
|
||||
e.b = 0x80;
|
||||
|
@ -131,8 +120,7 @@ void upsample_image(const byte* s, t_palet32entry* d, int cx, int cy, const t_pa
|
|||
|
||||
void convert_palet_18_to_24(const t_palet s, t_palet d)
|
||||
{
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
for (int i = 0; i < 256; i++) {
|
||||
d[i].r = (s[i].r & 63) * 255 / 63;
|
||||
d[i].g = (s[i].g & 63) * 255 / 63;
|
||||
d[i].b = (s[i].b & 63) * 255 / 63;
|
||||
|
@ -141,8 +129,7 @@ void convert_palet_18_to_24(const t_palet s, t_palet d)
|
|||
|
||||
void convert_palet_24_to_18(const t_palet s, t_palet d)
|
||||
{
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
for (int i = 0; i < 256; i++) {
|
||||
d[i].r = s[i].r >> 2;
|
||||
d[i].g = s[i].g >> 2;
|
||||
d[i].b = s[i].b >> 2;
|
||||
|
@ -163,14 +150,12 @@ int find_color(int r, int g, int b, const t_palet p)
|
|||
{
|
||||
int best_i;
|
||||
int min_d = INT_MAX;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
for (int i = 0; i < 256; i++) {
|
||||
int d_r = p[i].r - r;
|
||||
int d_g = p[i].g - g;
|
||||
int d_b = p[i].b - b;
|
||||
int d = d_r * d_r + d_g * d_g + d_b * d_b;
|
||||
if (d < min_d)
|
||||
{
|
||||
if (d < min_d) {
|
||||
min_d = d;
|
||||
best_i = i;
|
||||
}
|
||||
|
@ -182,14 +167,12 @@ int find_color_t(int r, int g, int b, const t_palet p)
|
|||
{
|
||||
int best_i;
|
||||
int min_d = INT_MAX;
|
||||
for (int i = 1; i < 256; i++)
|
||||
{
|
||||
for (int i = 1; i < 256; i++) {
|
||||
int d_r = p[i].r - r;
|
||||
int d_g = p[i].g - g;
|
||||
int d_b = p[i].b - b;
|
||||
int d = d_r * d_r + d_g * d_g + d_b * d_b;
|
||||
if (d < min_d)
|
||||
{
|
||||
if (d < min_d) {
|
||||
min_d = d;
|
||||
best_i = i;
|
||||
}
|
||||
|
@ -206,8 +189,7 @@ void create_rp(const t_palet s1, const t_palet s2, byte* d)
|
|||
|
||||
void apply_rp(byte* d, int cb_d, const byte* rp)
|
||||
{
|
||||
while (cb_d--)
|
||||
{
|
||||
while (cb_d--) {
|
||||
*d = rp[*d];
|
||||
d++;
|
||||
}
|
||||
|
|
24
3rdParty/xcc/misc/palet.h
vendored
24
3rdParty/xcc/misc/palet.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
30
3rdParty/xcc/misc/reg_key.cpp
vendored
30
3rdParty/xcc/misc/reg_key.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2006 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2006 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -74,15 +74,13 @@ LONG Creg_key::query_value(const string& name, string& value)
|
|||
LONG result = RegQueryValueExA(m_h, name.c_str(), NULL, NULL, NULL, &cb_d);
|
||||
if (result != ERROR_SUCCESS)
|
||||
return result;
|
||||
if (!cb_d)
|
||||
{
|
||||
if (!cb_d) {
|
||||
value.erase();
|
||||
return result;
|
||||
}
|
||||
vector<BYTE> d(cb_d);
|
||||
result = RegQueryValueExA(m_h, name.c_str(), NULL, NULL, &d.front(), &cb_d);
|
||||
if (result == ERROR_SUCCESS)
|
||||
{
|
||||
if (result == ERROR_SUCCESS) {
|
||||
if (cb_d)
|
||||
value.assign(reinterpret_cast<char*>(&d.front()), cb_d - 1);
|
||||
else
|
||||
|
|
24
3rdParty/xcc/misc/reg_key.h
vendored
24
3rdParty/xcc/misc/reg_key.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2006 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2006 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
462
3rdParty/xcc/misc/shp_decode.cpp
vendored
462
3rdParty/xcc/misc/shp_decode.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -25,24 +25,24 @@
|
|||
|
||||
static const char* encode64_table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
static const int decode64_table[256] =
|
||||
static const int decode64_table[256] =
|
||||
{
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63,
|
||||
52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1,-1,-1,-1,
|
||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14,
|
||||
15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1,
|
||||
-1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
|
||||
41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63,
|
||||
52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1,-1,-1,-1,
|
||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14,
|
||||
15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1,
|
||||
-1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
|
||||
41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1
|
||||
};
|
||||
|
||||
static int read_w(const byte*& r)
|
||||
|
@ -60,12 +60,9 @@ static void write_w(int v, byte*& w)
|
|||
|
||||
static void write_v40(byte v, int count, byte*& d)
|
||||
{
|
||||
while (count)
|
||||
{
|
||||
if (v)
|
||||
{
|
||||
if (count < 0x100)
|
||||
{
|
||||
while (count) {
|
||||
if (v) {
|
||||
if (count < 0x100) {
|
||||
*d++ = 0x00;
|
||||
*d++ = count;
|
||||
*d++ = v;
|
||||
|
@ -76,19 +73,15 @@ static void write_v40(byte v, int count, byte*& d)
|
|||
write_w(0xc000 | c_write, d);
|
||||
count -= c_write;
|
||||
*d++ = v;
|
||||
}
|
||||
else if (count < 0x80)
|
||||
{
|
||||
} else if (count < 0x80) {
|
||||
*d++ = 0x80 | count;
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int c_write = count < 0x8000 ? count : 0x7fff;
|
||||
} else {
|
||||
int c_write = count < 0x8000 ? count : 0x7fff;
|
||||
*d++ = 0x80;
|
||||
write_w(c_write, d);
|
||||
count -= c_write;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,63 +136,50 @@ static void write40_c5(byte*& w, int count)
|
|||
|
||||
static void write40_copy(byte*& w, int count, const byte* r)
|
||||
{
|
||||
while (count)
|
||||
{
|
||||
if (count < 0x80)
|
||||
{
|
||||
while (count) {
|
||||
if (count < 0x80) {
|
||||
write40_c1(w, count, r);
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
int c_write = count < 0x4000 ? count : 0x3fff;
|
||||
write40_c3(w, c_write, r);
|
||||
r += c_write;
|
||||
count -= c_write;
|
||||
count -= c_write;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write40_fill(byte*& w, int count, int v)
|
||||
{
|
||||
while (count)
|
||||
{
|
||||
if (count < 0x100)
|
||||
{
|
||||
while (count) {
|
||||
if (count < 0x100) {
|
||||
write40_c0(w, count, v);
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
int c_write = count < 0x4000 ? count : 0x3fff;
|
||||
write40_c4(w, c_write, v);
|
||||
count -= c_write;
|
||||
count -= c_write;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write40_skip(byte*& w, int count)
|
||||
{
|
||||
while (count)
|
||||
{
|
||||
if (count < 0x80)
|
||||
{
|
||||
while (count) {
|
||||
if (count < 0x80) {
|
||||
write40_c5(w, count);
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
int c_write = count < 0x8000 ? count : 0x7fff;
|
||||
write40_c2(w, c_write);
|
||||
count -= c_write;
|
||||
count -= c_write;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void flush_copy(byte*& w, const byte* r, const byte*& copy_from)
|
||||
{
|
||||
if (copy_from)
|
||||
{
|
||||
if (copy_from) {
|
||||
write40_copy(w, r - copy_from, copy_from);
|
||||
copy_from = NULL;
|
||||
}
|
||||
|
@ -219,22 +199,16 @@ int encode40(const byte* last_s, const byte* x, byte* d, int cb_s)
|
|||
const byte* r = s;
|
||||
byte* w = d;
|
||||
const byte* copy_from = NULL;
|
||||
while (r < s_end)
|
||||
{
|
||||
while (r < s_end) {
|
||||
int v = *r;
|
||||
int t = get_run_length(r, s_end);
|
||||
if (!v)
|
||||
{
|
||||
flush_copy(w, r, copy_from);
|
||||
if (!v) {
|
||||
flush_copy(w, r, copy_from);
|
||||
write40_skip(w, t);
|
||||
}
|
||||
else if (t > 2)
|
||||
{
|
||||
flush_copy(w, r, copy_from);
|
||||
} else if (t > 2) {
|
||||
flush_copy(w, r, copy_from);
|
||||
write40_fill(w, t, v);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (!copy_from)
|
||||
copy_from = r;
|
||||
}
|
||||
|
@ -253,13 +227,11 @@ int encode40_y(const byte* last_r, const byte* r, byte* d, int cb_s)
|
|||
int count = 0;
|
||||
byte last = ~(*last_r ^ *r);
|
||||
|
||||
while (cb_s--)
|
||||
{
|
||||
while (cb_s--) {
|
||||
byte v = *last_r++ ^ *r++;
|
||||
if (last == v)
|
||||
count++;
|
||||
else
|
||||
{
|
||||
else {
|
||||
write_v40(last, count, w);
|
||||
count = 1;
|
||||
last = v;
|
||||
|
@ -277,8 +249,7 @@ int encode40_z(const byte* last_s, const byte* s, byte* d, int cb_s)
|
|||
const byte* last_r = last_s;
|
||||
const byte* r = s;
|
||||
byte* w = d;
|
||||
while (cb_s)
|
||||
{
|
||||
while (cb_s) {
|
||||
int c_write = cb_s > 0x3fff ? 0x3fff : cb_s;
|
||||
cb_s -= c_write;
|
||||
*w++ = 0x80;
|
||||
|
@ -288,7 +259,7 @@ int encode40_z(const byte* last_s, const byte* s, byte* d, int cb_s)
|
|||
*w++ = *last_r++ ^ *r++;
|
||||
}
|
||||
*w++ = 0x80;
|
||||
*w++ = 0x00;
|
||||
*w++ = 0x00;
|
||||
*w++ = 0x00;
|
||||
return w - d;
|
||||
}
|
||||
|
@ -301,57 +272,42 @@ int decode40(const byte* s, byte* d)
|
|||
2 skip 10000000 c 0ccccccc
|
||||
3 copy 10000000 c 10cccccc
|
||||
4 fill 10000000 c 11cccccc v
|
||||
5 skip 1ccccccc
|
||||
5 skip 1ccccccc
|
||||
*/
|
||||
|
||||
const byte* r = s;
|
||||
byte* w = d;
|
||||
int count;
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
int code = *r++;
|
||||
if (code & 0x80)
|
||||
{
|
||||
if (count = code & 0x7f)
|
||||
{
|
||||
if (code & 0x80) {
|
||||
if (count = code & 0x7f) {
|
||||
w += count;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
count = *(uint16_t*)r;
|
||||
r += 2;
|
||||
code = count >> 8;
|
||||
if (code & 0x80)
|
||||
{
|
||||
if (code & 0x80) {
|
||||
count &= 0x3fff;
|
||||
if (code & 0x40)
|
||||
{
|
||||
if (code & 0x40) {
|
||||
code = *r++;
|
||||
while (count--)
|
||||
*w++ ^= code;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
while (count--)
|
||||
*w++ ^= *r++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (!count)
|
||||
break;
|
||||
w += count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (code)
|
||||
{
|
||||
} else if (code) {
|
||||
count = code;
|
||||
while (count--)
|
||||
*w++ ^= *r++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
count = *r++;
|
||||
code = *r++;
|
||||
while (count--)
|
||||
|
@ -363,14 +319,11 @@ int decode40(const byte* s, byte* d)
|
|||
|
||||
static void write_v80(byte v, int count, byte*& d)
|
||||
{
|
||||
if (count > 3)
|
||||
{
|
||||
if (count > 3) {
|
||||
*d++ = 0xfe;
|
||||
write_w(count, d);
|
||||
*d++ = v;
|
||||
}
|
||||
else if (count)
|
||||
{
|
||||
} else if (count) {
|
||||
*d++ = 0x80 | count;
|
||||
while (count--)
|
||||
*d++ = v;
|
||||
|
@ -415,7 +368,7 @@ end_line:
|
|||
goto next_s;
|
||||
|
||||
end0:
|
||||
edi_ptr = reinterpret_cast<byte*>(& cb_p);
|
||||
edi_ptr = reinterpret_cast<byte*>(&cb_p);
|
||||
*edi_ptr = ecx_value;
|
||||
// Restore registers
|
||||
}
|
||||
|
@ -428,16 +381,14 @@ static void write80_c0(byte*& w, int count, int p)
|
|||
|
||||
static void write80_c1(byte*& w, int count, const byte* r)
|
||||
{
|
||||
do
|
||||
{
|
||||
do {
|
||||
int c_write = count < 0x40 ? count : 0x3f;
|
||||
*w++ = 0x80 | c_write;
|
||||
memcpy(w, r, c_write);
|
||||
r += c_write;
|
||||
w += c_write;
|
||||
count -= c_write;
|
||||
}
|
||||
while (count);
|
||||
} while (count);
|
||||
}
|
||||
|
||||
static void write80_c2(byte*& w, int count, int p)
|
||||
|
@ -462,8 +413,7 @@ static void write80_c4(byte*& w, int count, int p)
|
|||
|
||||
static void flush_c1(byte*& w, const byte* r, const byte*& copy_from)
|
||||
{
|
||||
if (copy_from)
|
||||
{
|
||||
if (copy_from) {
|
||||
write80_c1(w, r - copy_from, copy_from);
|
||||
copy_from = NULL;
|
||||
}
|
||||
|
@ -476,32 +426,25 @@ int encode80(const byte* s, byte* d, int cb_s)
|
|||
const byte* r = s;
|
||||
byte* w = d;
|
||||
const byte* copy_from = NULL;
|
||||
while (r < s_end)
|
||||
{
|
||||
while (r < s_end) {
|
||||
byte* p;
|
||||
int cb_p;
|
||||
int t = get_run_length(r, s_end);
|
||||
get_same(s, r, s_end, p, cb_p);
|
||||
if (t < cb_p && cb_p > 2)
|
||||
{
|
||||
if (t < cb_p && cb_p > 2) {
|
||||
flush_c1(w, r, copy_from);
|
||||
if (cb_p - 3 < 8 && r - p < 0x1000)
|
||||
write80_c0(w, cb_p, r - p);
|
||||
else if (cb_p - 3 < 0x3e)
|
||||
write80_c2(w, cb_p, p - s);
|
||||
else
|
||||
write80_c4(w, cb_p, p - s);
|
||||
else
|
||||
write80_c4(w, cb_p, p - s);
|
||||
r += cb_p;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (t < 3)
|
||||
{
|
||||
} else {
|
||||
if (t < 3) {
|
||||
if (!copy_from)
|
||||
copy_from = r;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
flush_c1(w, r, copy_from);
|
||||
write80_c3(w, t, *r);
|
||||
}
|
||||
|
@ -521,18 +464,16 @@ int encode80_y(const byte* s, byte* d, int cb_s)
|
|||
int count = 0;
|
||||
byte last = ~*r;
|
||||
|
||||
while (cb_s--)
|
||||
{
|
||||
while (cb_s--) {
|
||||
byte v = *r++;
|
||||
if (last == v)
|
||||
count++;
|
||||
else
|
||||
{
|
||||
else {
|
||||
write_v80(last, count, w);
|
||||
count = 1;
|
||||
last = v;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
write_v80(last, count, w);
|
||||
*w++ = 0x80;
|
||||
|
@ -548,30 +489,25 @@ int decode80c(const byte image_in[], byte image_out[], int cb_in)
|
|||
3 fill 11111110 c c v
|
||||
4 copy 11111111 c c p p
|
||||
*/
|
||||
|
||||
|
||||
const byte* copyp;
|
||||
const byte* r = image_in;
|
||||
byte* w = image_out;
|
||||
int code;
|
||||
int count;
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
code = *r++;
|
||||
if (~code & 0x80)
|
||||
{
|
||||
if (~code & 0x80) {
|
||||
//bit 7 = 0
|
||||
//command 0 (0cccpppp p): copy
|
||||
count = (code >> 4) + 3;
|
||||
copyp = w - (((code & 0xf) << 8) + *r++);
|
||||
while (count--)
|
||||
*w++ = *copyp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//bit 7 = 1
|
||||
count = code & 0x3f;
|
||||
if (~code & 0x40)
|
||||
{
|
||||
if (~code & 0x40) {
|
||||
//bit 6 = 0
|
||||
if (!count)
|
||||
//end of image
|
||||
|
@ -579,31 +515,24 @@ int decode80c(const byte image_in[], byte image_out[], int cb_in)
|
|||
//command 1 (10cccccc): copy
|
||||
while (count--)
|
||||
*w++ = *r++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//bit 6 = 1
|
||||
if (count < 0x3e)
|
||||
{
|
||||
if (count < 0x3e) {
|
||||
//command 2 (11cccccc p p): copy
|
||||
count += 3;
|
||||
copyp = &image_out[*(unsigned __int16*)r];
|
||||
r += 2;
|
||||
while (count--)
|
||||
*w++ = *copyp++;
|
||||
}
|
||||
else
|
||||
if (count == 0x3e)
|
||||
{
|
||||
} else
|
||||
if (count == 0x3e) {
|
||||
//command 3 (11111110 c c v): fill
|
||||
count = *(unsigned __int16*)r;
|
||||
r += 2;
|
||||
code = *r++;
|
||||
while (count--)
|
||||
*w++ = byte(code);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//command 4 (copy 11111111 c c p p): copy
|
||||
count = *(unsigned __int16*)r;
|
||||
r += 2;
|
||||
|
@ -634,14 +563,11 @@ int __fastcall decode80(const byte image_in[], byte image_out[])
|
|||
unsigned int v13; // ecx
|
||||
char v14; // al
|
||||
|
||||
for (i = image_out; ; i += v10)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
for (i = image_out; ; i += v10) {
|
||||
while (1) {
|
||||
v4 = (unsigned __int8)*image_in;
|
||||
v5 = image_in + 1;
|
||||
if ((v4 & 0x80) == 0)
|
||||
{
|
||||
if ((v4 & 0x80) == 0) {
|
||||
v6 = (v4 >> 4) + 3;
|
||||
v7 = (v4 & 0xF) << 8;
|
||||
v7 |= static_cast<unsigned char>(*v5);
|
||||
|
@ -654,23 +580,19 @@ int __fastcall decode80(const byte image_in[], byte image_out[])
|
|||
break;
|
||||
v11 = *(unsigned __int16*)v5;
|
||||
v12 = v5 + 2;
|
||||
if (v10 == 62)
|
||||
{
|
||||
if (v10 == 62) {
|
||||
v13 = v11;
|
||||
v14 = *v12;
|
||||
image_in = v12 + 1;
|
||||
memset(i, v14, v13);
|
||||
i += v13;
|
||||
} else
|
||||
{
|
||||
if (v10 > 0x3E)
|
||||
{
|
||||
} else {
|
||||
if (v10 > 0x3E) {
|
||||
v6 = v11;
|
||||
v11 = *reinterpret_cast<const int16_t*>(v12);
|
||||
v8 = v12 + 2;
|
||||
v9 = &image_out[v11];
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
v8 = v12;
|
||||
v9 = &image_out[v11];
|
||||
v6 = v10 + 3;
|
||||
|
@ -704,14 +626,11 @@ int __fastcall decode80r(const byte image_in[], byte image_out[])
|
|||
unsigned int v13; // ecx
|
||||
char v14; // al
|
||||
|
||||
for (i = image_out; ; i += v10)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
for (i = image_out; ; i += v10) {
|
||||
while (1) {
|
||||
v4 = (unsigned __int8)*image_in;
|
||||
v5 = image_in + 1;
|
||||
if ((v4 & 0x80) == 0)
|
||||
{
|
||||
if ((v4 & 0x80) == 0) {
|
||||
v6 = (v4 >> 4) + 3;
|
||||
v7 = (v4 & 0xF) << 8;
|
||||
v7 |= static_cast<unsigned char>(*v5);
|
||||
|
@ -724,23 +643,19 @@ int __fastcall decode80r(const byte image_in[], byte image_out[])
|
|||
break;
|
||||
v11 = *(unsigned __int16*)v5;
|
||||
v12 = v5 + 2;
|
||||
if (v10 == 62)
|
||||
{
|
||||
if (v10 == 62) {
|
||||
v13 = v11;
|
||||
v14 = *v12;
|
||||
image_in = v12 + 1;
|
||||
memset(i, v14, v13);
|
||||
i += v13;
|
||||
} else
|
||||
{
|
||||
if (v10 > 0x3E)
|
||||
{
|
||||
} else {
|
||||
if (v10 > 0x3E) {
|
||||
v6 = v11;
|
||||
v11 = *reinterpret_cast<const int16_t*>(v12);
|
||||
v8 = v12 + 2;
|
||||
v9 = &i[-v11];
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
v8 = v12;
|
||||
v9 = &i[-v11];
|
||||
v6 = v10 + 3;
|
||||
|
@ -764,13 +679,11 @@ int decode2(const byte* s, byte* d, int cb_s, const byte* reference_palet)
|
|||
const byte* r = s;
|
||||
const byte* r_end = s + cb_s;
|
||||
byte* w = d;
|
||||
while (r < r_end)
|
||||
{
|
||||
while (r < r_end) {
|
||||
int v = *r++;
|
||||
if (v)
|
||||
*w++ = v;
|
||||
else
|
||||
{
|
||||
else {
|
||||
v = *r++;
|
||||
memset(w, 0, v);
|
||||
w += v;
|
||||
|
@ -785,21 +698,16 @@ int decode3(const byte* s, byte* d, int cx, int cy)
|
|||
{
|
||||
const byte* r = s;
|
||||
byte* w = d;
|
||||
for (int y = 0; y < cy; y++)
|
||||
{
|
||||
for (int y = 0; y < cy; y++) {
|
||||
int count = *reinterpret_cast<const unsigned __int16*>(r) - 2;
|
||||
r += 2;
|
||||
int x = 0;
|
||||
while (count--)
|
||||
{
|
||||
while (count--) {
|
||||
int v = *r++;
|
||||
if (v)
|
||||
{
|
||||
if (v) {
|
||||
x++;
|
||||
*w++ = v;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
count--;
|
||||
v = *r++;
|
||||
if (x + v > cx)
|
||||
|
@ -817,20 +725,17 @@ int encode3(const byte* s, byte* d, int cx, int cy)
|
|||
{
|
||||
const byte* r = s;
|
||||
byte* w = d;
|
||||
for (int y = 0; y < cy; y++)
|
||||
{
|
||||
for (int y = 0; y < cy; y++) {
|
||||
const byte* r_end = r + cx;
|
||||
byte* w_line = w;
|
||||
w += 2;
|
||||
while (r < r_end)
|
||||
{
|
||||
|
||||
while (r < r_end) {
|
||||
|
||||
int v = *r;
|
||||
*w++ = v;
|
||||
if (v)
|
||||
r++;
|
||||
else
|
||||
{
|
||||
else {
|
||||
int c = get_run_length(r, r_end);
|
||||
if (c > 0xff)
|
||||
c = 0xff;
|
||||
|
@ -848,71 +753,66 @@ Cvirtual_binary encode64(data_ref s)
|
|||
Cvirtual_binary d;
|
||||
const byte* r = s.data();
|
||||
int cb_s = s.size();
|
||||
byte* w = d.write_start(s.size() << 1);
|
||||
while (cb_s)
|
||||
{
|
||||
byte* w = d.write_start(s.size() << 1);
|
||||
while (cb_s) {
|
||||
int c1 = *r++;
|
||||
*w++ = encode64_table[c1>>2];
|
||||
|
||||
*w++ = encode64_table[c1 >> 2];
|
||||
|
||||
int c2 = --cb_s == 0 ? 0 : *r++;
|
||||
*w++ = encode64_table[((c1 & 0x3) << 4) | ((c2 & 0xf0) >> 4)];
|
||||
if (cb_s == 0)
|
||||
{
|
||||
*w++ = encode64_table[((c1 & 0x3) << 4) | ((c2 & 0xf0) >> 4)];
|
||||
if (cb_s == 0) {
|
||||
*w++ = '=';
|
||||
*w++ = '=';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
int c3 = --cb_s == 0 ? 0 : *r++;
|
||||
|
||||
|
||||
*w++ = encode64_table[((c2 & 0xf) << 2) | ((c3 & 0xc0) >> 6)];
|
||||
if (cb_s == 0)
|
||||
{
|
||||
if (cb_s == 0) {
|
||||
*w++ = '=';
|
||||
break;
|
||||
}
|
||||
}
|
||||
--cb_s;
|
||||
*w++ = encode64_table[c3 & 0x3f];
|
||||
}
|
||||
}
|
||||
d.set_size(w - d.data());
|
||||
return d;
|
||||
return d;
|
||||
}
|
||||
|
||||
Cvirtual_binary decode64(data_ref s)
|
||||
{
|
||||
Cvirtual_binary d;
|
||||
const byte* r = s.data();
|
||||
byte* w = d.write_start(s.size() << 1);
|
||||
while (*r)
|
||||
{
|
||||
byte* w = d.write_start(s.size() << 1);
|
||||
while (*r) {
|
||||
int c1 = *r++;
|
||||
if (decode64_table[c1] == -1)
|
||||
if (decode64_table[c1] == -1)
|
||||
return Cvirtual_binary();
|
||||
int c2 = *r++;
|
||||
if (decode64_table[c2] == -1)
|
||||
if (decode64_table[c2] == -1)
|
||||
return Cvirtual_binary();
|
||||
int c3 = *r++;
|
||||
if (c3 != '=' && decode64_table[c3] == -1)
|
||||
if (c3 != '=' && decode64_table[c3] == -1)
|
||||
return Cvirtual_binary();
|
||||
int c4 = *r++;
|
||||
if (c4 != '=' && decode64_table[c4] == -1)
|
||||
if (c4 != '=' && decode64_table[c4] == -1)
|
||||
return Cvirtual_binary();
|
||||
*w++ = (decode64_table[c1] << 2) | (decode64_table[c2] >> 4);
|
||||
if (c3 == '=')
|
||||
if (c3 == '=')
|
||||
break;
|
||||
*w++ = ((decode64_table[c2] << 4) & 0xf0) | (decode64_table[c3] >> 2);
|
||||
if (c4 == '=')
|
||||
if (c4 == '=')
|
||||
break;
|
||||
*w++ = ((decode64_table[c3] << 6) & 0xc0) | decode64_table[c4];
|
||||
}
|
||||
}
|
||||
d.set_size(w - d.data());
|
||||
return d;
|
||||
}
|
||||
|
||||
static void write5_count(byte*& w, int count)
|
||||
{
|
||||
while (count > 255)
|
||||
{
|
||||
while (count > 255) {
|
||||
*w++ = 0;
|
||||
count -= 255;
|
||||
}
|
||||
|
@ -923,8 +823,7 @@ static void write5_c0(byte*& w, int count, const byte* r, byte* small_copy)
|
|||
{
|
||||
if (count < 4 && !small_copy)
|
||||
count = count;
|
||||
if ((count < 4 || count > 7) && small_copy)
|
||||
{
|
||||
if ((count < 4 || count > 7) && small_copy) {
|
||||
int small_count = min(count, 3);
|
||||
*small_copy |= small_count;
|
||||
memcpy(w, r, small_count);
|
||||
|
@ -932,15 +831,12 @@ static void write5_c0(byte*& w, int count, const byte* r, byte* small_copy)
|
|||
w += small_count;
|
||||
count -= small_count;
|
||||
}
|
||||
if (count)
|
||||
{
|
||||
if (count) {
|
||||
assert(count > 3);
|
||||
if (count > 18)
|
||||
{
|
||||
if (count > 18) {
|
||||
*w++ = 0;
|
||||
write5_count(w, count - 18);
|
||||
}
|
||||
else
|
||||
} else
|
||||
*w++ = count - 3;
|
||||
memcpy(w, r, count);
|
||||
w += count;
|
||||
|
@ -953,12 +849,10 @@ static void write5_c1(byte*& w, int count, int p)
|
|||
assert(p >= 0);
|
||||
assert(p < 32768);
|
||||
count -= 2;
|
||||
if (count > 7)
|
||||
{
|
||||
if (count > 7) {
|
||||
*w++ = 0x10 | (p >> 11) & 8;
|
||||
write5_count(w, count - 7);
|
||||
}
|
||||
else
|
||||
} else
|
||||
*w++ = 0x10 | (p >> 11) & 8 | count;
|
||||
write_w((p << 2) & 0xfffc, w);
|
||||
}
|
||||
|
@ -970,12 +864,10 @@ static void write5_c2(byte*& w, int count, int p)
|
|||
assert(p <= 16384);
|
||||
count -= 2;
|
||||
p--;
|
||||
if (count > 31)
|
||||
{
|
||||
if (count > 31) {
|
||||
*w++ = 0x20;
|
||||
write5_count(w, count - 31);
|
||||
}
|
||||
else
|
||||
} else
|
||||
*w++ = 0x20 | count;
|
||||
write_w(p << 2, w);
|
||||
}
|
||||
|
@ -996,19 +888,16 @@ int get_count(const byte*& r)
|
|||
{
|
||||
int count = -255;
|
||||
int v;
|
||||
do
|
||||
{
|
||||
do {
|
||||
count += 255;
|
||||
v = *r++;
|
||||
}
|
||||
while (!v);
|
||||
} while (!v);
|
||||
return count + v;
|
||||
}
|
||||
|
||||
static void flush_c0(byte*& w, const byte* r, const byte*& copy_from, byte* small_copy, bool start)
|
||||
{
|
||||
if (copy_from)
|
||||
{
|
||||
if (copy_from) {
|
||||
int count = r - copy_from;
|
||||
/*
|
||||
if (start)
|
||||
|
@ -1067,42 +956,34 @@ int decode5s(const byte* s, byte* d, int cb_s)
|
|||
2 copy 001ccccc ppppppzz p
|
||||
3 copy cccpppzz p
|
||||
*/
|
||||
|
||||
|
||||
const byte* c;
|
||||
const byte* r = s;
|
||||
byte* w = d;
|
||||
int code;
|
||||
int count;
|
||||
code = *r;
|
||||
if (code > 17)
|
||||
{
|
||||
if (code > 17) {
|
||||
r++;
|
||||
count = code - 17;
|
||||
while (count--)
|
||||
*w++ = *r++;
|
||||
}
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
code = *r++;
|
||||
if (code & 0xf0)
|
||||
{
|
||||
if (code & 0xc0)
|
||||
{
|
||||
if (code & 0xf0) {
|
||||
if (code & 0xc0) {
|
||||
count = (code >> 5) - 1;
|
||||
c = w - (code >> 2 & 7);
|
||||
c -= *r++ << 3;
|
||||
c--;
|
||||
}
|
||||
else if (code & 0x20)
|
||||
{
|
||||
} else if (code & 0x20) {
|
||||
count = code & 0x1f;
|
||||
if (!count)
|
||||
count = get_count(r) + 31;
|
||||
c = w - (read_w(r) >> 2);
|
||||
c--;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
c = w - ((code & 8) << 11);
|
||||
count = code & 7;
|
||||
if (!count)
|
||||
|
@ -1112,27 +993,22 @@ int decode5s(const byte* s, byte* d, int cb_s)
|
|||
break;
|
||||
}
|
||||
count += 2;
|
||||
while (count--)
|
||||
{
|
||||
while (count--) {
|
||||
if (*w != *c)
|
||||
*w = *c;
|
||||
w++;
|
||||
c++;
|
||||
}
|
||||
count = *(r - 2) & 3;
|
||||
while (count--)
|
||||
{
|
||||
while (count--) {
|
||||
if (*w != *r)
|
||||
*w = *r;
|
||||
w++;
|
||||
r++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
count = code ? code + 3: get_count(r) + 18;
|
||||
while (count--)
|
||||
{
|
||||
} else {
|
||||
count = code ? code + 3 : get_count(r) + 18;
|
||||
while (count--) {
|
||||
if (*w != *r)
|
||||
*w = *r;
|
||||
w++;
|
||||
|
@ -1149,8 +1025,7 @@ int encode5(const byte* s, byte* d, int cb_s, int format)
|
|||
const byte* r = s;
|
||||
const byte* r_end = s + cb_s;
|
||||
byte* w = d;
|
||||
while (r < r_end)
|
||||
{
|
||||
while (r < r_end) {
|
||||
int cb_section = min<size_t>(r_end - r, 8192);
|
||||
t_pack_section_header& header = *reinterpret_cast<t_pack_section_header*>(w);
|
||||
w += sizeof(t_pack_section_header);
|
||||
|
@ -1165,8 +1040,7 @@ int decode5(const byte* s, byte* d, int cb_s, int format)
|
|||
const byte* r = s;
|
||||
const byte* r_end = s + cb_s;
|
||||
byte* w = d;
|
||||
while (r < r_end)
|
||||
{
|
||||
while (r < r_end) {
|
||||
const t_pack_section_header& header = *reinterpret_cast<const t_pack_section_header*>(r);
|
||||
r += sizeof(t_pack_section_header);
|
||||
if (format == 80)
|
||||
|
|
24
3rdParty/xcc/misc/shp_decode.h
vendored
24
3rdParty/xcc/misc/shp_decode.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
213
3rdParty/xcc/misc/shp_ts_file.cpp
vendored
213
3rdParty/xcc/misc/shp_ts_file.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -58,17 +58,14 @@ public:
|
|||
const int cx = m_f.get_cx(m_frame_i);
|
||||
const int cy = m_f.get_cy(m_frame_i);
|
||||
const byte* r;
|
||||
if (m_f.is_compressed(m_frame_i))
|
||||
{
|
||||
if (m_f.is_compressed(m_frame_i)) {
|
||||
decode3(m_f.get_image(m_frame_i), s.write_start(cx * cy), cx, cy);
|
||||
r = s.data();
|
||||
}
|
||||
else
|
||||
} else
|
||||
r = m_f.get_image(m_frame_i);
|
||||
memset(d, 0, cb_image());
|
||||
byte* w = d + m_f.get_x(m_frame_i) + Cshp_ts_decoder::cx() * m_f.get_y(m_frame_i);
|
||||
for (int y = 0; y < cy; y++)
|
||||
{
|
||||
for (int y = 0; y < cy; y++) {
|
||||
memcpy(w, r, cx);
|
||||
r += cx;
|
||||
w += Cshp_ts_decoder::cx();
|
||||
|
@ -109,13 +106,12 @@ bool Cshp_ts_file::is_valid() const
|
|||
{
|
||||
const t_shp_ts_header& h = header();
|
||||
int size = get_size();
|
||||
if (sizeof(t_shp_ts_header) > size ||
|
||||
if (sizeof(t_shp_ts_header) > size ||
|
||||
h.zero ||
|
||||
h.c_images < 1 || h.c_images > 10000 ||
|
||||
h.c_images < 1 || h.c_images > 10000 ||
|
||||
sizeof(t_shp_ts_header) + get_cb_index() > size)
|
||||
return false;
|
||||
for (int i = 0; i < min(cf(), 1000); i++)
|
||||
{
|
||||
for (int i = 0; i < min(cf(), 1000); i++) {
|
||||
const t_shp_ts_image_header& image_header = *get_image_header(i);
|
||||
if (!image_header.cx && !image_header.cy && !image_header.offset)
|
||||
continue;
|
||||
|
@ -124,13 +120,10 @@ bool Cshp_ts_file::is_valid() const
|
|||
image_header.zero ||
|
||||
image_header.offset < sizeof(t_shp_ts_header) + get_cb_index())
|
||||
return false;
|
||||
if (is_compressed(i))
|
||||
{
|
||||
if (is_compressed(i)) {
|
||||
if (image_header.offset > size)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (image_header.offset + image_header.cx * image_header.cy > size)
|
||||
return false;
|
||||
}
|
||||
|
@ -152,55 +145,42 @@ int Cshp_ts_file::extract_as_pcx(const Cfname& name, t_file_type ft, const t_pal
|
|||
const int global_cx = cx();
|
||||
const int global_cy = cy();
|
||||
const int c_images = cf();
|
||||
if (combine_shadows && ~c_images & 1)
|
||||
{
|
||||
if (combine_shadows && ~c_images & 1) {
|
||||
bool shadow = false;
|
||||
byte* image = new byte[global_cx * global_cy];
|
||||
byte* d = new byte[global_cx * global_cy * c_images >> 1];
|
||||
byte* w = d;
|
||||
for (int i = 0; i < c_images; i++)
|
||||
{
|
||||
for (int i = 0; i < c_images; i++) {
|
||||
const int cx = get_cx(i);
|
||||
const int cy = get_cy(i);
|
||||
const byte* r;
|
||||
if (is_compressed(i))
|
||||
{
|
||||
if (is_compressed(i)) {
|
||||
decode3(get_image(i), image, cx, cy);
|
||||
r = image;
|
||||
}
|
||||
else
|
||||
} else
|
||||
r = get_image(i);
|
||||
if (!shadow)
|
||||
{
|
||||
if (i == c_images >> 1)
|
||||
{
|
||||
if (!shadow) {
|
||||
if (i == c_images >> 1) {
|
||||
shadow = true;
|
||||
w = d;
|
||||
}
|
||||
else
|
||||
} else
|
||||
memset(w, 0, global_cx * global_cy);
|
||||
}
|
||||
byte* w_start = w;
|
||||
w += get_x(i) + global_cx * get_y(i);
|
||||
for (int y = 0; y < cy; y++)
|
||||
{
|
||||
if (shadow)
|
||||
{
|
||||
for (int x = 0; x < cx; x++)
|
||||
{
|
||||
for (int y = 0; y < cy; y++) {
|
||||
if (shadow) {
|
||||
for (int x = 0; x < cx; x++) {
|
||||
if (*r++)
|
||||
w[x] = 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
memcpy(w, r, cx);
|
||||
r += cx;
|
||||
}
|
||||
w += global_cx;
|
||||
}
|
||||
if (shadow)
|
||||
{
|
||||
if (shadow) {
|
||||
Cfname t = name;
|
||||
t.set_title(name.get_ftitle() + " " + nwzl(4, i - (c_images >> 1)));
|
||||
error = image_file_write(t, ft, w_start, palet, global_cx, global_cy);
|
||||
|
@ -211,27 +191,21 @@ int Cshp_ts_file::extract_as_pcx(const Cfname& name, t_file_type ft, const t_pal
|
|||
}
|
||||
delete[] d;
|
||||
delete[] image;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
byte* image = new byte[global_cx * global_cy];
|
||||
byte* s = new byte[global_cx * global_cy];
|
||||
for (int i = 0; i < c_images; i++)
|
||||
{
|
||||
for (int i = 0; i < c_images; i++) {
|
||||
const int cx = get_cx(i);
|
||||
const int cy = get_cy(i);
|
||||
const byte* r;
|
||||
if (is_compressed(i))
|
||||
{
|
||||
if (is_compressed(i)) {
|
||||
decode3(get_image(i), image, cx, cy);
|
||||
r = image;
|
||||
}
|
||||
else
|
||||
} else
|
||||
r = get_image(i);
|
||||
memset(s, 0, global_cx * global_cy);
|
||||
byte* w = s + get_x(i) + global_cx * get_y(i);
|
||||
for (int y = 0; y < cy; y++)
|
||||
{
|
||||
for (int y = 0; y < cy; y++) {
|
||||
memcpy(w, r, cx);
|
||||
r += cx;
|
||||
w += global_cx;
|
||||
|
@ -266,62 +240,47 @@ Cvirtual_image Cshp_ts_file::extract_as_pcx_single(const t_palet _palet, bool co
|
|||
Cvirtual_binary image;
|
||||
Cvirtual_binary s;
|
||||
memset(s.write_start(cx_s * cy_s), 0, cx_s * cy_s);
|
||||
if (combine_shadows)
|
||||
{
|
||||
if (combine_shadows) {
|
||||
c_images <<= 1;
|
||||
bool shadow = false;
|
||||
for (int i = 0; i < c_images; i++)
|
||||
{
|
||||
for (int i = 0; i < c_images; i++) {
|
||||
const int cx = get_cx(i);
|
||||
const int cy = get_cy(i);
|
||||
const byte* r;
|
||||
if (is_compressed(i))
|
||||
{
|
||||
if (is_compressed(i)) {
|
||||
decode3(get_image(i), image.write_start(global_cx * global_cy), cx, cy);
|
||||
r = image.data();
|
||||
}
|
||||
else
|
||||
} else
|
||||
r = get_image(i);
|
||||
if (!shadow && i == c_images >> 1)
|
||||
shadow = true;
|
||||
int j = i % (c_images >> 1);
|
||||
byte* w = s.data_edit() + get_ofs(j % cblocks_x * global_cx + get_x(i), j / cblocks_x * global_cy + get_y(i), cx_s, cy_s);
|
||||
for (int y = 0; y < cy; y++)
|
||||
{
|
||||
if (shadow)
|
||||
{
|
||||
for (int x = 0; x < cx; x++)
|
||||
{
|
||||
for (int y = 0; y < cy; y++) {
|
||||
if (shadow) {
|
||||
for (int x = 0; x < cx; x++) {
|
||||
if (*r++)
|
||||
w[x] = 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
memcpy(w, r, cx);
|
||||
r += cx;
|
||||
}
|
||||
w += cx_s;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < c_images; i++)
|
||||
{
|
||||
} else {
|
||||
for (int i = 0; i < c_images; i++) {
|
||||
const int cx = get_cx(i);
|
||||
const int cy = get_cy(i);
|
||||
const byte* r;
|
||||
if (is_compressed(i))
|
||||
{
|
||||
if (is_compressed(i)) {
|
||||
decode3(get_image(i), image.write_start(global_cx * global_cy), cx, cy);
|
||||
r = image.data();
|
||||
}
|
||||
else
|
||||
} else
|
||||
r = get_image(i);
|
||||
byte* w = s.data_edit() + get_ofs(i % cblocks_x * global_cx + get_x(i), i / cblocks_x * global_cy + get_y(i), cx_s, cy_s);
|
||||
for (int y = 0; y < cy; y++)
|
||||
{
|
||||
for (int y = 0; y < cy; y++) {
|
||||
memcpy(w, r, cx);
|
||||
r += cx;
|
||||
w += cx_s;
|
||||
|
@ -340,13 +299,10 @@ void shp_split_frames(Cvirtual_image& image, int cblocks_x, int cblocks_y)
|
|||
byte* d = new byte[cx_d * cy_d];
|
||||
byte* w = d;
|
||||
const byte* r_line = image.image();
|
||||
for (int yb = 0; yb < cblocks_y; yb++)
|
||||
{
|
||||
for (int xb = 0; xb < cblocks_x; xb++)
|
||||
{
|
||||
for (int yb = 0; yb < cblocks_y; yb++) {
|
||||
for (int xb = 0; xb < cblocks_x; xb++) {
|
||||
const byte* r = r_line + cx * xb;
|
||||
for (int y = 0; y < cy; y++)
|
||||
{
|
||||
for (int y = 0; y < cy; y++) {
|
||||
memcpy(w, r, cx);
|
||||
r += image.cx();
|
||||
w += cx_d;
|
||||
|
@ -364,18 +320,15 @@ void shp_split_shadows(Cvirtual_image& image)
|
|||
int cy = image.cy();
|
||||
int count = cx * cy;
|
||||
byte* d = new byte[count << 1];
|
||||
memcpy(d, image.image(), count);
|
||||
memcpy(d, image.image(), count);
|
||||
byte* r = d;
|
||||
byte* w = d + count;
|
||||
while (count--)
|
||||
{
|
||||
while (count--) {
|
||||
byte& v = *r++;
|
||||
if (v == 4)
|
||||
{
|
||||
if (v == 4) {
|
||||
v = 0;
|
||||
*w++ = 1;
|
||||
}
|
||||
else
|
||||
} else
|
||||
*w++ = 0;
|
||||
}
|
||||
image.load(d, cx, cy << 1, image.cb_pixel(), image.palet());
|
||||
|
@ -432,11 +385,9 @@ static int encode4_line(const byte* r, byte* d, int cx)
|
|||
{
|
||||
const byte* s_end = r + cx;
|
||||
byte* w = d;
|
||||
while (r < s_end)
|
||||
{
|
||||
while (r < s_end) {
|
||||
int v = *w++ = *r++;
|
||||
if (!v)
|
||||
{
|
||||
if (!v) {
|
||||
int c = min(get_run_length(r - 1, s_end), 0xff);
|
||||
r += c - 1;
|
||||
*w++ = c;
|
||||
|
@ -448,11 +399,9 @@ static int encode4_line(const byte* r, byte* d, int cx)
|
|||
static int decode4_line_size(const byte*& r, int cx)
|
||||
{
|
||||
int w = 0;
|
||||
while (cx--)
|
||||
{
|
||||
while (cx--) {
|
||||
w++;
|
||||
if (!*r++)
|
||||
{
|
||||
if (!*r++) {
|
||||
cx -= *r++ - 1;
|
||||
w++;
|
||||
}
|
||||
|
@ -463,8 +412,7 @@ static int decode4_line_size(const byte*& r, int cx)
|
|||
static int decode4_line(const byte* s, byte*& w, int cx)
|
||||
{
|
||||
const byte* r = s;
|
||||
while (cx--)
|
||||
{
|
||||
while (cx--) {
|
||||
if (!(*w++ = *r++))
|
||||
cx -= (*w++ = *r++) - 1;
|
||||
}
|
||||
|
@ -476,8 +424,7 @@ static int encode4(const byte* s, byte* d, int cx, int cy)
|
|||
const byte* s_end = s + cx * cy;
|
||||
const byte* r = s;
|
||||
byte* w = d;
|
||||
for (int y = 0; y < cy; y++)
|
||||
{
|
||||
for (int y = 0; y < cy; y++) {
|
||||
int lm = min(get_left_margin(r, cx), 0xff);
|
||||
int rm = min(get_right_margin(r + cx, cx - lm), 0xff);
|
||||
*w++ = lm;
|
||||
|
@ -491,8 +438,7 @@ static int encode4(const byte* s, byte* d, int cx, int cy)
|
|||
static int decode4_size(const byte*& r, int cx, int cy)
|
||||
{
|
||||
int w = 0;
|
||||
for (int y = 0; y < cy; y++)
|
||||
{
|
||||
for (int y = 0; y < cy; y++) {
|
||||
int lm = *r++;
|
||||
int rm = *r++;
|
||||
w += 2;
|
||||
|
@ -508,20 +454,17 @@ static int decode4_size(const byte*& r, int cx, int cy)
|
|||
static int decode4(const byte* s, byte*& w, int cx, int cy)
|
||||
{
|
||||
const byte* r = s;
|
||||
for (int y = 0; y < cy; y++)
|
||||
{
|
||||
for (int y = 0; y < cy; y++) {
|
||||
int lm = *r++;
|
||||
int rm = *r++;
|
||||
byte* w_line = w;
|
||||
w += 2;
|
||||
if (lm)
|
||||
{
|
||||
if (lm) {
|
||||
*w++ = 0;
|
||||
*w++ = lm;
|
||||
}
|
||||
r += decode4_line(r, w, cx - lm - rm);
|
||||
if (rm)
|
||||
{
|
||||
if (rm) {
|
||||
*w++ = 0;
|
||||
*w++ = rm;
|
||||
}
|
||||
|
@ -558,21 +501,17 @@ int shp_encode4(const Cshp_ts_file& f, byte* d)
|
|||
header.c_frames = c_frames;
|
||||
w += sizeof(t_shp4_header);
|
||||
|
||||
for (int i = 0; i < c_frames; i++)
|
||||
{
|
||||
for (int i = 0; i < c_frames; i++) {
|
||||
const t_shp_ts_image_header& image_header = *f.get_image_header(i);
|
||||
|
||||
const int cx = image_header.cx;
|
||||
const int cy = image_header.cy;
|
||||
|
||||
t_shp4_frame_header& frame_header = *reinterpret_cast<t_shp4_frame_header*>(w);
|
||||
if (image_header.cx && image_header.cy)
|
||||
{
|
||||
if (image_header.cx && image_header.cy) {
|
||||
frame_header.lm = image_header.x;
|
||||
frame_header.tm = image_header.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
frame_header.lm = min(global_cx, 0xff);
|
||||
frame_header.tm = min(global_cy, 0xff);
|
||||
}
|
||||
|
@ -583,13 +522,11 @@ int shp_encode4(const Cshp_ts_file& f, byte* d)
|
|||
frame_header.bm = global_cy - frame_header.tm - cy;
|
||||
w += sizeof(t_shp4_frame_header);
|
||||
|
||||
if (f.is_compressed(i))
|
||||
{
|
||||
if (f.is_compressed(i)) {
|
||||
Cvirtual_binary image;
|
||||
decode3(f.get_image(i), image.write_start(cx * cy), cx, cy);
|
||||
w += encode4(image.data(), w, cx, cy);
|
||||
}
|
||||
else
|
||||
} else
|
||||
w += encode4(f.get_image(i), w, cx, cy);
|
||||
}
|
||||
return w - d;
|
||||
|
@ -605,8 +542,7 @@ int shp_decode4_size(const byte* s)
|
|||
const int c_frames = s_header.c_frames;
|
||||
r += sizeof(t_shp4_header);
|
||||
int w = 0;
|
||||
for (int i = 0; i < c_frames; i++)
|
||||
{
|
||||
for (int i = 0; i < c_frames; i++) {
|
||||
const t_shp4_frame_header& frame_header = *reinterpret_cast<const t_shp4_frame_header*>(r);
|
||||
int x = frame_header.lm;
|
||||
int y = frame_header.tm;
|
||||
|
@ -639,8 +575,7 @@ Cvirtual_binary shp_decode4(const byte* s, int cb_d)
|
|||
header.c_images = c_frames;
|
||||
w += sizeof(t_shp_ts_header);
|
||||
byte* w1 = w + c_frames * sizeof(t_shp_ts_image_header);
|
||||
for (int i = 0; i < c_frames; i++)
|
||||
{
|
||||
for (int i = 0; i < c_frames; i++) {
|
||||
const t_shp4_frame_header& frame_header = *reinterpret_cast<const t_shp4_frame_header*>(r);
|
||||
int x = frame_header.lm;
|
||||
int y = frame_header.tm;
|
||||
|
|
34
3rdParty/xcc/misc/shp_ts_file.h
vendored
34
3rdParty/xcc/misc/shp_ts_file.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -24,7 +24,7 @@
|
|||
#include "video_file.h"
|
||||
#include "virtual_image.h"
|
||||
|
||||
class Cshp_ts_file : public Cvideo_file<t_shp_ts_header>
|
||||
class Cshp_ts_file : public Cvideo_file<t_shp_ts_header>
|
||||
{
|
||||
public:
|
||||
Cvideo_decoder* decoder(const t_palet_entry*);
|
||||
|
@ -74,10 +74,10 @@ public:
|
|||
return get_image_header(i)->cy;
|
||||
}
|
||||
|
||||
int get_cb_index() const
|
||||
{
|
||||
return sizeof(t_shp_ts_image_header) * cf();
|
||||
}
|
||||
int get_cb_index() const
|
||||
{
|
||||
return sizeof(t_shp_ts_image_header) * cf();
|
||||
}
|
||||
|
||||
bool is_compressed(int i) const
|
||||
{
|
||||
|
|
82
3rdParty/xcc/misc/string_conversion.cpp
vendored
82
3rdParty/xcc/misc/string_conversion.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -27,8 +27,7 @@ int a2ip(const string& s)
|
|||
{
|
||||
int r = 0;
|
||||
int l = 0;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int c = s.find('.', l);
|
||||
r = r << 8 | atoi(s.substr(l, c - l).c_str());
|
||||
l = c + 1;
|
||||
|
@ -117,8 +116,7 @@ string nh(int l, __int64 v)
|
|||
{
|
||||
string s;
|
||||
int w;
|
||||
while (l)
|
||||
{
|
||||
while (l) {
|
||||
w = v & 0xf;
|
||||
if (w > 9)
|
||||
w += 7;
|
||||
|
@ -133,16 +131,12 @@ string nwp(int l, unsigned int v)
|
|||
{
|
||||
string r;
|
||||
string s = n(v);
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
int l = s.size();
|
||||
if (l > 3)
|
||||
{
|
||||
if (l > 3) {
|
||||
r = '.' + s.substr(l - 3, 3) + r;
|
||||
s.erase(l - 3, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
r = s + r;
|
||||
break;
|
||||
}
|
||||
|
@ -154,13 +148,10 @@ string nwp(int l, unsigned int v)
|
|||
void split_key(const string& key, string& name, string& value)
|
||||
{
|
||||
size_t i = key.find('=');
|
||||
if (i == string::npos)
|
||||
{
|
||||
if (i == string::npos) {
|
||||
name = key;
|
||||
value.erase();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
name = key.substr(0, i);
|
||||
value = key.substr(i + 1);
|
||||
}
|
||||
|
@ -169,16 +160,13 @@ void split_key(const string& key, string& name, string& value)
|
|||
string tabs2spaces(const string& v)
|
||||
{
|
||||
string r;
|
||||
for (size_t i = 0; i < v.size(); i++)
|
||||
{
|
||||
for (size_t i = 0; i < v.size(); i++) {
|
||||
char c = v[i];
|
||||
if (c == '\t')
|
||||
{
|
||||
if (c == '\t') {
|
||||
do
|
||||
r += ' ';
|
||||
while (r.size() & 3);
|
||||
}
|
||||
else
|
||||
} else
|
||||
r += c;
|
||||
}
|
||||
return r;
|
||||
|
@ -198,10 +186,8 @@ string time2a(time_t v)
|
|||
string js_encode(const string& v)
|
||||
{
|
||||
string r;
|
||||
for (size_t i = 0; i < v.size(); i++)
|
||||
{
|
||||
switch (v[i])
|
||||
{
|
||||
for (size_t i = 0; i < v.size(); i++) {
|
||||
switch (v[i]) {
|
||||
case '<':
|
||||
r += "<";
|
||||
break;
|
||||
|
@ -220,16 +206,13 @@ string trim_field(const string& v)
|
|||
{
|
||||
string r;
|
||||
bool copy_white = false;
|
||||
for (size_t i = 0; i < v.size(); i++)
|
||||
{
|
||||
for (size_t i = 0; i < v.size(); i++) {
|
||||
if (isspace(v[i]))
|
||||
copy_white = true;
|
||||
else
|
||||
{
|
||||
if (copy_white)
|
||||
{
|
||||
else {
|
||||
if (copy_white) {
|
||||
if (!r.empty())
|
||||
r += ' ';
|
||||
r += ' ';
|
||||
copy_white = false;
|
||||
}
|
||||
r += v[i];
|
||||
|
@ -242,18 +225,15 @@ string trim_text(const string& v)
|
|||
{
|
||||
string r;
|
||||
bool copy_white = false;
|
||||
for (size_t i = 0; i < v.size(); )
|
||||
{
|
||||
for (size_t i = 0; i < v.size(); ) {
|
||||
int p = v.find('\n', i);
|
||||
if (p == string::npos)
|
||||
p = v.size();
|
||||
string line = trim_field(v.substr(i, p - i));
|
||||
if (line.empty())
|
||||
copy_white = true;
|
||||
else
|
||||
{
|
||||
if (copy_white)
|
||||
{
|
||||
else {
|
||||
if (copy_white) {
|
||||
if (!r.empty())
|
||||
r += '\n';
|
||||
copy_white = false;
|
||||
|
|
24
3rdParty/xcc/misc/string_conversion.h
vendored
24
3rdParty/xcc/misc/string_conversion.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
32
3rdParty/xcc/misc/tmp_file.h
vendored
32
3rdParty/xcc/misc/tmp_file.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -21,16 +21,16 @@
|
|||
#include <cc_file_sh.h>
|
||||
#include <cc_structures.h>
|
||||
|
||||
class Ctmp_file : public Ccc_file_sh<t_tmp_header>
|
||||
class Ctmp_file : public Ccc_file_sh<t_tmp_header>
|
||||
{
|
||||
public:
|
||||
bool is_valid() const
|
||||
{
|
||||
const t_tmp_header& h = header();
|
||||
int size = get_size();
|
||||
return !(sizeof(t_tmp_header) > size ||
|
||||
h.cx != 24 ||
|
||||
h.cy != 24 ||
|
||||
return !(sizeof(t_tmp_header) > size ||
|
||||
h.cx != 24 ||
|
||||
h.cy != 24 ||
|
||||
h.c_tiles > 128 ||
|
||||
h.zero1 ||
|
||||
h.size != size ||
|
||||
|
|
71
3rdParty/xcc/misc/tmp_ts_file.cpp
vendored
71
3rdParty/xcc/misc/tmp_ts_file.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -26,20 +26,17 @@ void Ctmp_ts_file::get_rect(int& x, int& y, int& cx, int& cy) const
|
|||
x = INT_MAX;
|
||||
y = INT_MAX;
|
||||
cx = INT_MIN;
|
||||
cy = INT_MIN;
|
||||
cy = INT_MIN;
|
||||
int bigy = INT_MIN;
|
||||
int bigyval = 0;
|
||||
for (int i = 0; i < get_c_tiles(); i++)
|
||||
{
|
||||
if (get_index()[i])
|
||||
{
|
||||
for (int i = 0; i < get_c_tiles(); i++) {
|
||||
if (get_index()[i]) {
|
||||
int height = get_height() - get_height(i);
|
||||
int x_t = get_x(i);
|
||||
int y_t = get_y(i) + (height * (get_cy() / 2));
|
||||
int x2_t = x_t + get_cx();
|
||||
int y2_t = y_t + get_cy();
|
||||
if (has_extra_graphics(i))
|
||||
{
|
||||
if (has_extra_graphics(i)) {
|
||||
int y_t_extra = get_y_extra(i) + (height * (get_cy() / 2));
|
||||
int y2_t_extra = y_t_extra + get_cy_extra(i);
|
||||
if (y_t_extra < y)
|
||||
|
@ -55,8 +52,7 @@ void Ctmp_ts_file::get_rect(int& x, int& y, int& cx, int& cy) const
|
|||
y = y_t;
|
||||
if (y2_t > cy)
|
||||
cy = y2_t;
|
||||
if (bigy < get_y(i))
|
||||
{
|
||||
if (bigy < get_y(i)) {
|
||||
bigy = get_y(i);
|
||||
bigyval = get_y(i) + get_cy() + (get_height(i) * (get_cy() / 2));
|
||||
if (has_extra_graphics(i))
|
||||
|
@ -75,43 +71,36 @@ void Ctmp_ts_file::draw(byte* d) const
|
|||
int global_x, global_y, global_cx, global_cy;
|
||||
get_rect(global_x, global_y, global_cx, global_cy);
|
||||
memset(d, 0, global_cx * global_cy);
|
||||
for (int i = 0; i < get_c_tiles(); i++)
|
||||
{
|
||||
if (get_index()[i])
|
||||
{
|
||||
for (int i = 0; i < get_c_tiles(); i++) {
|
||||
if (get_index()[i]) {
|
||||
int height = get_height() - get_height(i);
|
||||
const byte* r = get_image(i);
|
||||
byte* w_line = d + get_x(i) - global_x + global_cx * (get_y(i) - global_y + (height * (get_cy() / 2)));
|
||||
int x = get_cx() / 2;
|
||||
int cx = 0;
|
||||
int y = 0;
|
||||
for (; y < get_cy() / 2; y++)
|
||||
{
|
||||
for (; y < get_cy() / 2; y++) {
|
||||
cx += 4;
|
||||
x -= 2;
|
||||
memcpy(w_line + x, r, cx);
|
||||
r += cx;
|
||||
w_line += global_cx;
|
||||
}
|
||||
for (; y < get_cy(); y++)
|
||||
{
|
||||
for (; y < get_cy(); y++) {
|
||||
cx -= 4;
|
||||
x += 2;
|
||||
memcpy(w_line + x, r, cx);
|
||||
r += cx;
|
||||
w_line += global_cx;
|
||||
}
|
||||
if (has_extra_graphics(i))
|
||||
{
|
||||
if (has_extra_graphics(i)) {
|
||||
r += get_cx() * get_cy() / 2;
|
||||
w_line = d + get_x_extra(i) - global_x + global_cx * (get_y_extra(i) - global_y + (height * (get_cy() / 2)));
|
||||
int cx = get_cx_extra(i);
|
||||
int cy = get_cy_extra(i);
|
||||
for (y = 0; y < cy; y++)
|
||||
{
|
||||
for (y = 0; y < cy; y++) {
|
||||
byte* w = w_line;
|
||||
for (int i = 0; i < cx; i++)
|
||||
{
|
||||
for (int i = 0; i < cx; i++) {
|
||||
int v = *r++;
|
||||
if (v)
|
||||
*w = v;
|
||||
|
@ -133,16 +122,14 @@ int decode_tile(const byte* s, byte* d, int cx_d)
|
|||
int x = cx_d / 2;
|
||||
int cx = 0;
|
||||
int y = 0;
|
||||
for (; y < cy / 2; y++)
|
||||
{
|
||||
for (; y < cy / 2; y++) {
|
||||
cx += 4;
|
||||
x -= 2;
|
||||
memcpy(w + x, r, cx);
|
||||
r += cx;
|
||||
w += cx_d;
|
||||
}
|
||||
for (; y < cy; y++)
|
||||
{
|
||||
for (; y < cy; y++) {
|
||||
cx -= 4;
|
||||
x += 2;
|
||||
memcpy(w + x, r, cx);
|
||||
|
@ -160,16 +147,14 @@ int encode_tile(const byte* s, byte* d, int cx_s)
|
|||
int x = cx_s / 2;
|
||||
int cx = 0;
|
||||
int y = 0;
|
||||
for (; y < cy / 2; y++)
|
||||
{
|
||||
for (; y < cy / 2; y++) {
|
||||
cx += 4;
|
||||
x -= 2;
|
||||
memcpy(w, r + x, cx);
|
||||
r += cx_s;
|
||||
w += cx;
|
||||
}
|
||||
for (; y < cy; y++)
|
||||
{
|
||||
for (; y < cy; y++) {
|
||||
cx -= 4;
|
||||
x += 2;
|
||||
memcpy(w, r + x, cx);
|
||||
|
|
42
3rdParty/xcc/misc/tmp_ts_file.h
vendored
42
3rdParty/xcc/misc/tmp_ts_file.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -35,16 +35,14 @@ public:
|
|||
{
|
||||
const t_tmp_ts_header& h = header();
|
||||
auto const size = get_size();
|
||||
if (sizeof(t_tmp_ts_header) > size ||
|
||||
if (sizeof(t_tmp_ts_header) > size ||
|
||||
!h.cblocks_x || !h.cblocks_y ||
|
||||
h.cx != 48 && h.cx != 60 ||
|
||||
2 * h.cy != h.cx ||
|
||||
sizeof(t_tmp_ts_header) + 4 * get_c_tiles() > size)
|
||||
return false;
|
||||
for (int i = 0; i < min(get_c_tiles(), 64); i++)
|
||||
{
|
||||
if (get_index()[i])
|
||||
{
|
||||
for (int i = 0; i < min(get_c_tiles(), 64); i++) {
|
||||
if (get_index()[i]) {
|
||||
const t_tmp_image_header& image_header = *get_image_header(i);
|
||||
}
|
||||
}
|
||||
|
@ -114,14 +112,12 @@ public:
|
|||
{
|
||||
return get_image_header(i)->x_extra;
|
||||
}
|
||||
|
||||
|
||||
int get_height() const
|
||||
{
|
||||
int height = 0;
|
||||
for (int i = 0; i < get_c_tiles(); i++)
|
||||
{
|
||||
if (get_index()[i])
|
||||
{
|
||||
for (int i = 0; i < get_c_tiles(); i++) {
|
||||
if (get_index()[i]) {
|
||||
if (get_height(i) > height)
|
||||
height = get_height(i);
|
||||
}
|
||||
|
@ -188,7 +184,7 @@ public:
|
|||
assert(a == b);
|
||||
return data() + get_index()[i] + get_image_header(i)->z_ofs;
|
||||
}
|
||||
|
||||
|
||||
const byte* get_extra_data(int i) const
|
||||
{
|
||||
return data() + get_index()[i] + get_image_header(i)->extra_ofs;
|
||||
|
|
24
3rdParty/xcc/misc/vartypes.h
vendored
24
3rdParty/xcc/misc/vartypes.h
vendored
|
@ -1,20 +1,20 @@
|
|||
#pragma once
|
||||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
|
|
24
3rdParty/xcc/misc/video_decoder.cpp
vendored
24
3rdParty/xcc/misc/video_decoder.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
|
24
3rdParty/xcc/misc/virtual_audio.cpp
vendored
24
3rdParty/xcc/misc/virtual_audio.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2001 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2001 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
|
26
3rdParty/xcc/misc/virtual_audio.h
vendored
26
3rdParty/xcc/misc/virtual_audio.h
vendored
|
@ -1,26 +1,26 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2001 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2001 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "virtual_file.h"
|
||||
|
||||
class Cvirtual_audio
|
||||
class Cvirtual_audio
|
||||
{
|
||||
public:
|
||||
void load(Cvirtual_file f, int c_samples, int samplerate, int cb_sample, int c_channels);
|
||||
|
|
45
3rdParty/xcc/misc/virtual_binary.cpp
vendored
45
3rdParty/xcc/misc/virtual_binary.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2001 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2001 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -23,14 +23,11 @@
|
|||
|
||||
Cvirtual_binary_source::Cvirtual_binary_source(const void* d, size_t cb_d, const std::shared_ptr<const void>& source)
|
||||
{
|
||||
if (source)
|
||||
{
|
||||
if (source) {
|
||||
m_data = const_cast<byte*>(reinterpret_cast<const byte*>(d));
|
||||
m_size = cb_d;
|
||||
m_source = source;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
m_data = new byte[cb_d];
|
||||
m_size = cb_d;
|
||||
if (d)
|
||||
|
@ -62,7 +59,7 @@ Cvirtual_binary_source* Cvirtual_binary_source::pre_edit()
|
|||
Cvirtual_binary_source* t = new Cvirtual_binary_source(m_data, m_size, NULL);
|
||||
detach();
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
Cvirtual_binary::Cvirtual_binary()
|
||||
{
|
||||
|
@ -102,8 +99,7 @@ Cvirtual_binary::~Cvirtual_binary()
|
|||
|
||||
const Cvirtual_binary& Cvirtual_binary::operator=(const Cvirtual_binary& v)
|
||||
{
|
||||
if (this != &v)
|
||||
{
|
||||
if (this != &v) {
|
||||
m_source->detach();
|
||||
m_source = v.m_source->attach();
|
||||
}
|
||||
|
@ -119,11 +115,10 @@ int Cvirtual_binary::load(const string& fname, bool use_mm)
|
|||
{
|
||||
if (use_mm)
|
||||
*this = file32_read(fname);
|
||||
else
|
||||
{
|
||||
Cvirtual_binary d = file32_read(fname);
|
||||
*this = Cvirtual_binary(d.data(), d.size());
|
||||
}
|
||||
else {
|
||||
Cvirtual_binary d = file32_read(fname);
|
||||
*this = Cvirtual_binary(d.data(), d.size());
|
||||
}
|
||||
return !data();
|
||||
}
|
||||
|
||||
|
|
48
3rdParty/xcc/misc/virtual_binary.h
vendored
48
3rdParty/xcc/misc/virtual_binary.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2001 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2001 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -61,10 +61,10 @@ public:
|
|||
m_size = v;
|
||||
}
|
||||
|
||||
bool unique() const
|
||||
{
|
||||
return mc_references == 1;
|
||||
}
|
||||
bool unique() const
|
||||
{
|
||||
return mc_references == 1;
|
||||
}
|
||||
private:
|
||||
byte* m_data;
|
||||
size_t m_size;
|
||||
|
@ -102,15 +102,15 @@ public:
|
|||
return m_source ? m_source->data_end() : NULL;
|
||||
}
|
||||
|
||||
const byte* begin() const
|
||||
{
|
||||
return data();
|
||||
}
|
||||
const byte* begin() const
|
||||
{
|
||||
return data();
|
||||
}
|
||||
|
||||
const byte* end() const
|
||||
{
|
||||
return data_end();
|
||||
}
|
||||
const byte* end() const
|
||||
{
|
||||
return data_end();
|
||||
}
|
||||
|
||||
byte* data_edit()
|
||||
{
|
||||
|
|
29
3rdParty/xcc/misc/virtual_file.cpp
vendored
29
3rdParty/xcc/misc/virtual_file.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -55,7 +55,7 @@ int Cvirtual_file::size() const
|
|||
{
|
||||
int r = 0;
|
||||
for (auto& i : m_data)
|
||||
r += i.size();
|
||||
r += i.size();
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -63,8 +63,7 @@ int Cvirtual_file::save(const string& fname) const
|
|||
{
|
||||
Cfile32 f;
|
||||
int error = f.open_write(fname);
|
||||
if (!error)
|
||||
{
|
||||
if (!error) {
|
||||
for (auto& i : m_data)
|
||||
error = f.write(i);
|
||||
}
|
||||
|
|
26
3rdParty/xcc/misc/virtual_file.h
vendored
26
3rdParty/xcc/misc/virtual_file.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -23,7 +23,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
class Cvirtual_file
|
||||
class Cvirtual_file
|
||||
{
|
||||
public:
|
||||
int save(const string& fname) const;
|
||||
|
|
81
3rdParty/xcc/misc/virtual_image.cpp
vendored
81
3rdParty/xcc/misc/virtual_image.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -47,13 +47,11 @@ Cvirtual_image::Cvirtual_image(const void* image, int cx, int cy, int cb_pixel,
|
|||
|
||||
const Cvirtual_image& Cvirtual_image::palet(const t_palet_entry* palet, bool inflate)
|
||||
{
|
||||
if (palet)
|
||||
{
|
||||
if (palet) {
|
||||
memcpy(m_palet.write_start(sizeof(t_palet)), palet, sizeof(t_palet));
|
||||
if (inflate)
|
||||
convert_palet_18_to_24(reinterpret_cast<t_palet_entry*>(m_palet.data_edit()));
|
||||
}
|
||||
else
|
||||
} else
|
||||
m_palet.clear();
|
||||
return *this;
|
||||
}
|
||||
|
@ -99,25 +97,21 @@ int Cvirtual_image::load(const Cvirtual_binary& s)
|
|||
return png_f.decode(*this);
|
||||
else if (tga_f.load(s), tga_f.is_valid())
|
||||
return tga_f.decode(*this);
|
||||
else
|
||||
{
|
||||
else {
|
||||
IStream* is = SHCreateMemStream(s.data(), s.size());
|
||||
Gdiplus::Bitmap bmp(is);
|
||||
is->Release();
|
||||
if (bmp.GetLastStatus() != Ok)
|
||||
return 1;
|
||||
PixelFormat pf = bmp.GetPixelFormat();
|
||||
if (bmp.GetPixelFormat() & PixelFormatIndexed)
|
||||
{
|
||||
if (bmp.GetPixelFormat() & PixelFormatIndexed) {
|
||||
load(NULL, bmp.GetWidth(), bmp.GetHeight(), 1, NULL);
|
||||
BitmapData d;
|
||||
d.Stride = bmp.GetWidth();
|
||||
d.Scan0 = image_edit();
|
||||
bmp.LockBits(NULL, ImageLockModeRead | ImageLockModeUserInputBuf, PixelFormat8bppIndexed, &d);
|
||||
bmp.UnlockBits(&d);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
load(NULL, bmp.GetWidth(), bmp.GetHeight(), 3, NULL);
|
||||
BitmapData d;
|
||||
d.Stride = bmp.GetWidth() * 3;
|
||||
|
@ -163,8 +157,7 @@ void Cvirtual_image::swap_rb()
|
|||
{
|
||||
int count = m_cx * m_cy;
|
||||
t_palet_entry* r = reinterpret_cast<t_palet_entry*>(m_image.data_edit());
|
||||
while (count--)
|
||||
{
|
||||
while (count--) {
|
||||
swap(r->r, r->b);
|
||||
r++;
|
||||
}
|
||||
|
@ -175,8 +168,7 @@ static void flip_frame(const byte* s, byte* d, int cx, int cy, int cb_pixel)
|
|||
int cb_line = cx * cb_pixel;
|
||||
const byte* r = s;
|
||||
byte* w = d + cb_line * cy;
|
||||
while (cy--)
|
||||
{
|
||||
while (cy--) {
|
||||
w -= cb_line;
|
||||
memcpy(w, r, cb_line);
|
||||
r += cb_line;
|
||||
|
@ -200,8 +192,7 @@ void Cvirtual_image::cb_pixel(int cb_pixel, const t_palet_entry* palet)
|
|||
|
||||
void Cvirtual_image::decrease_color_depth(int new_cb_pixel, const t_palet_entry* palet)
|
||||
{
|
||||
if (new_cb_pixel == 3)
|
||||
{
|
||||
if (new_cb_pixel == 3) {
|
||||
remove_alpha();
|
||||
return;
|
||||
}
|
||||
|
@ -211,21 +202,16 @@ void Cvirtual_image::decrease_color_depth(int new_cb_pixel, const t_palet_entry*
|
|||
load(NULL, cx(), cy(), new_cb_pixel, palet);
|
||||
byte* w = image_edit();
|
||||
int count = m_cx * m_cy;
|
||||
if (old_cb_pixel == 3)
|
||||
{
|
||||
if (old_cb_pixel == 3) {
|
||||
const t_palet_entry* r = reinterpret_cast<const t_palet_entry*>(t.data());
|
||||
while (count--)
|
||||
{
|
||||
while (count--) {
|
||||
*w++ = find_color(r->r, r->g, r->b, palet);
|
||||
r++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
assert(old_cb_pixel == 4);
|
||||
const t_palet32entry* r = reinterpret_cast<const t_palet32entry*>(t.data());
|
||||
while (count--)
|
||||
{
|
||||
while (count--) {
|
||||
*w++ = r->a < 0x80 ? find_color(r->r, r->g, r->b, palet) : 0;
|
||||
r++;
|
||||
}
|
||||
|
@ -254,8 +240,7 @@ static t_palet32entry p32e(const t_palet palet, int i)
|
|||
|
||||
void Cvirtual_image::increase_color_depth(int new_cb_pixel)
|
||||
{
|
||||
if (cb_pixel() == 3)
|
||||
{
|
||||
if (cb_pixel() == 3) {
|
||||
if (new_cb_pixel == 4)
|
||||
add_alpha();
|
||||
return;
|
||||
|
@ -265,14 +250,11 @@ void Cvirtual_image::increase_color_depth(int new_cb_pixel)
|
|||
const byte* r = t.image();
|
||||
load(NULL, cx(), cy(), new_cb_pixel, NULL);
|
||||
int count = m_cx * m_cy;
|
||||
if (cb_pixel() == 3)
|
||||
{
|
||||
if (cb_pixel() == 3) {
|
||||
t_palet_entry* w = reinterpret_cast<t_palet_entry*>(image_edit());
|
||||
while (count--)
|
||||
*w++ = t.palet()[*r++];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
assert(cb_pixel() == 4);
|
||||
t_palet32entry* w = reinterpret_cast<t_palet32entry*>(image_edit());
|
||||
while (count--)
|
||||
|
@ -288,8 +270,7 @@ void Cvirtual_image::add_alpha()
|
|||
int count = m_cx * m_cy;
|
||||
const byte* r = t.data();
|
||||
byte* w = image_edit();
|
||||
while (count--)
|
||||
{
|
||||
while (count--) {
|
||||
*w++ = *r++;
|
||||
*w++ = *r++;
|
||||
*w++ = *r++;
|
||||
|
@ -306,8 +287,7 @@ void Cvirtual_image::remove_alpha()
|
|||
int count = m_cx * m_cy;
|
||||
const byte* r = t.data();
|
||||
byte* w = image_edit();
|
||||
while (count--)
|
||||
{
|
||||
while (count--) {
|
||||
*w++ = *r++;
|
||||
*w++ = *r++;
|
||||
*w++ = *r++;
|
||||
|
@ -321,8 +301,7 @@ void Cvirtual_image::increase_palet_depth()
|
|||
Cvirtual_binary t = m_palet;
|
||||
const t_palet_entry* s = reinterpret_cast<const t_palet_entry*>(t.data());
|
||||
t_palet_entry* d = reinterpret_cast<t_palet_entry*>(t.data_edit());
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
for (int i = 0; i < 256; i++) {
|
||||
d[i].r = (s[i].r & 63) * 255 / 63;
|
||||
d[i].g = (s[i].g & 63) * 255 / 63;
|
||||
d[i].b = (s[i].b & 63) * 255 / 63;
|
||||
|
|
26
3rdParty/xcc/misc/virtual_image.h
vendored
26
3rdParty/xcc/misc/virtual_image.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -109,7 +109,7 @@ public:
|
|||
{
|
||||
return reinterpret_cast<const t_palet_entry*>(m_image.data())[ofs8(x, y)];
|
||||
}
|
||||
|
||||
|
||||
void pixel24(int x, int y, t_palet_entry v)
|
||||
{
|
||||
reinterpret_cast<t_palet_entry*>(m_image.data_edit())[ofs8(x, y)] = v;
|
||||
|
|
42
3rdParty/xcc/misc/virtual_tfile.cpp
vendored
42
3rdParty/xcc/misc/virtual_tfile.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -30,10 +30,8 @@ string Cvirtual_tfile::read_line()
|
|||
assert(data());
|
||||
const int first_non_ws = pos;
|
||||
int last_non_ws;
|
||||
while (pos < size())
|
||||
{
|
||||
switch (data()[pos++])
|
||||
{
|
||||
while (pos < size()) {
|
||||
switch (data()[pos++]) {
|
||||
case '\r':
|
||||
last_non_ws = pos - 2;
|
||||
if (pos < size() && data()[pos] == '\n')
|
||||
|
@ -55,10 +53,8 @@ string Cvirtual_tfile::read_line(bool remove_ws)
|
|||
assert(data());
|
||||
int first_non_ws;
|
||||
int last_non_ws;
|
||||
while (pos < size())
|
||||
{
|
||||
switch (data()[pos++])
|
||||
{
|
||||
while (pos < size()) {
|
||||
switch (data()[pos++]) {
|
||||
case '\r':
|
||||
if (pos < size() && data()[pos] == '\n')
|
||||
pos++;
|
||||
|
@ -70,10 +66,8 @@ string Cvirtual_tfile::read_line(bool remove_ws)
|
|||
default:
|
||||
first_non_ws = pos - 1;
|
||||
last_non_ws = pos - 2;
|
||||
while (pos < size())
|
||||
{
|
||||
switch (data()[pos++])
|
||||
{
|
||||
while (pos < size()) {
|
||||
switch (data()[pos++]) {
|
||||
case '\r':
|
||||
if (pos < size() && data()[pos] == '\n')
|
||||
pos++;
|
||||
|
|
24
3rdParty/xcc/misc/virtual_tfile.h
vendored
24
3rdParty/xcc/misc/virtual_tfile.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
196
3rdParty/xcc/misc/vxl_file.cpp
vendored
196
3rdParty/xcc/misc/vxl_file.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -30,7 +30,7 @@
|
|||
|
||||
bool Cvxl_file::is_valid() const
|
||||
{
|
||||
int size = get_size();
|
||||
int size = get_size();
|
||||
const t_vxl_header& h = header();
|
||||
if (sizeof(t_vxl_header) > size ||
|
||||
strcmp(h.id, vxl_id) ||
|
||||
|
@ -47,7 +47,7 @@ bool Cvxl_file::is_valid() const
|
|||
if (section_header.one != 1 ||
|
||||
section_header.zero ||
|
||||
section_tailer.span_end_ofs - section_tailer.span_start_ofs != section_tailer.span_data_ofs - section_tailer.span_end_ofs)
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
|
@ -64,24 +64,18 @@ int Cvxl_file::extract_as_pcx(const Cfname& name, t_file_type ft, const t_palet
|
|||
const int cy = section_tailer.cy;
|
||||
const int cz = section_tailer.cz;
|
||||
Cvirtual_binary s;
|
||||
for (int i = 0; i < cz; i++)
|
||||
{
|
||||
for (int i = 0; i < cz; i++) {
|
||||
memset(s.write_start(cx * cy), 0, cx * cy);
|
||||
int j = 0;
|
||||
for (int y = 0; y < cy; y++)
|
||||
{
|
||||
for (int x = 0; x < cx; x++)
|
||||
{
|
||||
for (int y = 0; y < cy; y++) {
|
||||
for (int x = 0; x < cx; x++) {
|
||||
const byte* r = get_span_data(0, j);
|
||||
if (r)
|
||||
{
|
||||
if (r) {
|
||||
int z = 0;
|
||||
while (z < cz)
|
||||
{
|
||||
while (z < cz) {
|
||||
z += *r++;
|
||||
int c = *r++;
|
||||
while (c--)
|
||||
{
|
||||
while (c--) {
|
||||
if (i == z)
|
||||
s.data_edit()[x + cx * y] = *r;
|
||||
r += 2;
|
||||
|
@ -105,27 +99,21 @@ int Cvxl_file::extract_as_pcx(const Cfname& name, t_file_type ft, const t_palet
|
|||
|
||||
ostream& Cvxl_file::extract_as_text(ostream& os) const
|
||||
{
|
||||
for (int i = 0; i < get_c_section_headers(); i++)
|
||||
{
|
||||
for (int i = 0; i < get_c_section_headers(); i++) {
|
||||
const t_vxl_section_tailer& section_tailer = *get_section_tailer(i);
|
||||
const int cx = section_tailer.cx;
|
||||
const int cy = section_tailer.cy;
|
||||
const int cz = section_tailer.cz;
|
||||
int j = 0;
|
||||
for (int y = 0; y < cy; y++)
|
||||
{
|
||||
for (int x = 0; x < cx; x++)
|
||||
{
|
||||
for (int y = 0; y < cy; y++) {
|
||||
for (int x = 0; x < cx; x++) {
|
||||
const byte* r = get_span_data(i, j);
|
||||
if (r)
|
||||
{
|
||||
if (r) {
|
||||
int z = 0;
|
||||
while (z < cz)
|
||||
{
|
||||
while (z < cz) {
|
||||
z += *r++;
|
||||
int c = *r++;
|
||||
while (c--)
|
||||
{
|
||||
while (c--) {
|
||||
os << i << ',' << x << ',' << y << ',' << z << ',' << static_cast<int>(*r++) << ',' << static_cast<int>(*r++) << endl;
|
||||
z++;
|
||||
}
|
||||
|
@ -173,16 +161,14 @@ int Cvxl_file::extract_as_xif(const string& name) const
|
|||
Cxif_key& header = k.open_key_write(vi_header);
|
||||
Cxif_key& palet = header.open_key_write(vi_palet);
|
||||
int i;
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
for (i = 0; i < 256; i++) {
|
||||
Cxif_key& palet_entry = palet.open_key_write(i);
|
||||
palet_entry.set_value_int(vi_red, get_palet()[i].r);
|
||||
palet_entry.set_value_int(vi_green, get_palet()[i].g);
|
||||
palet_entry.set_value_int(vi_blue, get_palet()[i].b);
|
||||
}
|
||||
Cxif_key& body = k.open_key_write(vi_body);
|
||||
for (i = 0; i < get_c_section_headers(); i++)
|
||||
{
|
||||
for (i = 0; i < get_c_section_headers(); i++) {
|
||||
const t_vxl_section_header& section_header = *get_section_header(i);
|
||||
const t_vxl_section_tailer& section_tailer = *get_section_tailer(i);
|
||||
const int cx = section_tailer.cx;
|
||||
|
@ -191,24 +177,19 @@ int Cvxl_file::extract_as_xif(const string& name) const
|
|||
Cxif_key& section = body.open_key_write(i);
|
||||
Cxif_key& header = section.open_key_write(vi_header);
|
||||
header.set_value_string(vi_id, section_header.id);
|
||||
Cxif_key& body = section.open_key_write(vi_body);
|
||||
Cxif_key& body = section.open_key_write(vi_body);
|
||||
int j = 0;
|
||||
for (int y = 0; y < cy; y++)
|
||||
{
|
||||
for (int y = 0; y < cy; y++) {
|
||||
Cxif_key& yi = body.open_key_write(y);
|
||||
for (int x = 0; x < cx; x++)
|
||||
{
|
||||
for (int x = 0; x < cx; x++) {
|
||||
Cxif_key& xi = yi.open_key_write(x);
|
||||
const byte* r = get_span_data(i, j);
|
||||
if (r)
|
||||
{
|
||||
if (r) {
|
||||
int z = 0;
|
||||
while (z < cz)
|
||||
{
|
||||
while (z < cz) {
|
||||
z += *r++;
|
||||
int c = *r++;
|
||||
while (c--)
|
||||
{
|
||||
while (c--) {
|
||||
Cxif_key& zi = xi.open_key_write(z);
|
||||
zi.set_value_int(vi_color, *r++);
|
||||
zi.set_value_int(vi_surface_normal, *r++);
|
||||
|
@ -220,7 +201,7 @@ int Cvxl_file::extract_as_xif(const string& name) const
|
|||
j++;
|
||||
}
|
||||
}
|
||||
Cxif_key& tailer = section.open_key_write(vi_tailer);
|
||||
Cxif_key& tailer = section.open_key_write(vi_tailer);
|
||||
tailer.set_value_int(vi_x_min, section_tailer.x_min_scale * 1000000);
|
||||
tailer.set_value_int(vi_y_min, section_tailer.y_min_scale * 1000000);
|
||||
tailer.set_value_int(vi_z_min, section_tailer.z_min_scale * 1000000);
|
||||
|
@ -252,16 +233,14 @@ Cvirtual_binary vxl_file_write(const Cxif_key& s)
|
|||
header.unknown = 0x1f10;
|
||||
const Cxif_key& palet_key = header_key.open_key_read(vi_palet);
|
||||
int i;
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
for (i = 0; i < 256; i++) {
|
||||
const Cxif_key& palet_entry_key = palet_key.open_key_read(i);
|
||||
header.palet[i].r = palet_entry_key.get_value_int(vi_red);
|
||||
header.palet[i].g = palet_entry_key.get_value_int(vi_green);
|
||||
header.palet[i].b = palet_entry_key.get_value_int(vi_blue);
|
||||
}
|
||||
w += sizeof(t_vxl_header);
|
||||
for (i = 0; i < c_sections; i++)
|
||||
{
|
||||
for (i = 0; i < c_sections; i++) {
|
||||
const Cxif_key& section_key = body_key.open_key_read(i);
|
||||
const Cxif_key& section_header_key = section_key.open_key_read(vi_header);
|
||||
t_vxl_section_header& section_header = *reinterpret_cast<t_vxl_section_header*>(w);
|
||||
|
@ -272,8 +251,7 @@ Cvirtual_binary vxl_file_write(const Cxif_key& s)
|
|||
w += sizeof(t_vxl_section_header);
|
||||
}
|
||||
byte* body_start = w;
|
||||
for (i = 0; i < c_sections; i++)
|
||||
{
|
||||
for (i = 0; i < c_sections; i++) {
|
||||
const Cxif_key& section_key = body_key.open_key_read(i);
|
||||
const Cxif_key& section_body_key = section_key.open_key_read(vi_body);
|
||||
const Cxif_key& section_tailer_key = section_key.open_key_read(vi_tailer);
|
||||
|
@ -289,16 +267,13 @@ Cvirtual_binary vxl_file_write(const Cxif_key& s)
|
|||
byte* span_data_start = w;
|
||||
span_data_ofs[i] = w - body_start;
|
||||
int span_i = 0;
|
||||
for (int y = 0; y < cy; y++)
|
||||
{
|
||||
for (int y = 0; y < cy; y++) {
|
||||
const Cxif_key& yi = section_body_key.open_key_read(y);
|
||||
for (int x = 0; x < cx; x++)
|
||||
{
|
||||
for (int x = 0; x < cx; x++) {
|
||||
byte* span_start = w;
|
||||
const Cxif_key& xi = yi.open_key_read(x);
|
||||
int z = 0;
|
||||
for (auto& i : xi.m_keys)
|
||||
{
|
||||
for (auto& i : xi.m_keys) {
|
||||
int z_inc = i.first - z;
|
||||
z = i.first + 1;
|
||||
*w++ = z_inc;
|
||||
|
@ -307,15 +282,11 @@ Cvirtual_binary vxl_file_write(const Cxif_key& s)
|
|||
*w++ = i.second.get_value_int(vi_surface_normal);
|
||||
*w++ = 1;
|
||||
}
|
||||
if (span_start == w)
|
||||
{
|
||||
if (span_start == w) {
|
||||
span_start_list[span_i] = -1;
|
||||
span_end_list[span_i] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (z != cz)
|
||||
{
|
||||
} else {
|
||||
if (z != cz) {
|
||||
*w++ = cz - z;
|
||||
*w++ = 0;
|
||||
*w++ = 0;
|
||||
|
@ -328,8 +299,7 @@ Cvirtual_binary vxl_file_write(const Cxif_key& s)
|
|||
}
|
||||
}
|
||||
header.size = w - body_start;
|
||||
for (i = 0; i < c_sections; i++)
|
||||
{
|
||||
for (i = 0; i < c_sections; i++) {
|
||||
const Cxif_key& section_key = body_key.open_key_read(i);
|
||||
const Cxif_key& section_tailer_key = section_key.open_key_read(vi_tailer);
|
||||
t_vxl_section_tailer& section_tailer = *reinterpret_cast<t_vxl_section_tailer*>(w);
|
||||
|
@ -338,8 +308,7 @@ Cvirtual_binary vxl_file_write(const Cxif_key& s)
|
|||
section_tailer.span_end_ofs = span_end_list_ofs[i];
|
||||
section_tailer.span_data_ofs = span_data_ofs[i];
|
||||
section_tailer.scale = 0;
|
||||
for (int ty = 0; ty < 3; ty++)
|
||||
{
|
||||
for (int ty = 0; ty < 3; ty++) {
|
||||
for (int tx = 0; tx < 4; tx++)
|
||||
section_tailer.transform[ty][tx] = 0;
|
||||
}
|
||||
|
@ -367,8 +336,7 @@ Cvirtual_binary vxl_file_write(const byte* s, const byte* s_normals, int cx, int
|
|||
Cxif_key k;
|
||||
Cxif_key& header = k.open_key_write(vi_header);
|
||||
Cxif_key& palet = header.open_key_write(vi_palet);
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
for (int i = 0; i < 256; i++) {
|
||||
Cxif_key& palet_entry = palet.open_key_write(i);
|
||||
palet_entry.set_value_int(vi_red, i);
|
||||
palet_entry.set_value_int(vi_green, i);
|
||||
|
@ -379,28 +347,24 @@ Cvirtual_binary vxl_file_write(const byte* s, const byte* s_normals, int cx, int
|
|||
Cxif_key& section = body.open_key_write(0);
|
||||
Cxif_key& header = section.open_key_write(vi_header);
|
||||
header.set_value_string(vi_id, "NONE");
|
||||
Cxif_key& body = section.open_key_write(vi_body);
|
||||
for (int y = 0; y < cy; y++)
|
||||
{
|
||||
Cxif_key& body = section.open_key_write(vi_body);
|
||||
for (int y = 0; y < cy; y++) {
|
||||
Cxif_key& yi = body.open_key_write(y);
|
||||
for (int x = 0; x < cx; x++)
|
||||
{
|
||||
for (int x = 0; x < cx; x++) {
|
||||
Cxif_key& xi = yi.open_key_write(x);
|
||||
const byte* r = s + x + cx * y;
|
||||
for (int z = 0; z < cz; z++)
|
||||
{
|
||||
for (int z = 0; z < cz; z++) {
|
||||
int v = *r;
|
||||
if (v)
|
||||
{
|
||||
if (v) {
|
||||
Cxif_key& zi = xi.open_key_write(z);
|
||||
zi.set_value_int(vi_color, v);
|
||||
zi.set_value_int(vi_surface_normal, s_normals ? s_normals[r - s]: -1);
|
||||
zi.set_value_int(vi_surface_normal, s_normals ? s_normals[r - s] : -1);
|
||||
}
|
||||
r += cx * cy;
|
||||
}
|
||||
}
|
||||
}
|
||||
Cxif_key& tailer = section.open_key_write(vi_tailer);
|
||||
Cxif_key& tailer = section.open_key_write(vi_tailer);
|
||||
tailer.set_value_int(vi_x_min, cx * -1000000 / 2);
|
||||
tailer.set_value_int(vi_y_min, cy * -1000000 / 2);
|
||||
tailer.set_value_int(vi_z_min, cz * -1000000 / 2);
|
||||
|
@ -433,8 +397,7 @@ Cvirtual_binary vxl_file_write(Cvirtual_tfile s)
|
|||
int cx = 0;
|
||||
int cy = 0;
|
||||
int cz = 0;
|
||||
while (!s.eof())
|
||||
{
|
||||
while (!s.eof()) {
|
||||
Cmulti_line l = s.read_line();
|
||||
t_voxel e;
|
||||
int s = l.get_next_int(',');
|
||||
|
@ -454,8 +417,7 @@ Cvirtual_binary vxl_file_write(Cvirtual_tfile s)
|
|||
Cvirtual_binary normals(NULL, cx * cy * cz);
|
||||
colors.memset(0);
|
||||
normals.memset(0);
|
||||
for (auto& e : list)
|
||||
{
|
||||
for (auto& e : list) {
|
||||
int o = e.x + cx * (e.y + cy * e.z);
|
||||
colors.data_edit()[o] = e.color;
|
||||
normals.data_edit()[o] = e.normal;
|
||||
|
@ -496,8 +458,7 @@ int vxl_encode4(const Cvxl_file& f, byte* d)
|
|||
header.c_sections = c_sections;
|
||||
w += sizeof(t_vxl4_header);
|
||||
|
||||
for (int i = 0; i < c_sections; i++)
|
||||
{
|
||||
for (int i = 0; i < c_sections; i++) {
|
||||
const t_vxl_section_header& s_section_header = *f.get_section_header(i);
|
||||
const t_vxl_section_tailer& section_tailer = *f.get_section_tailer(i);
|
||||
const int cx = section_tailer.cx;
|
||||
|
@ -520,29 +481,24 @@ int vxl_encode4(const Cvxl_file& f, byte* d)
|
|||
section_header.cz = section_tailer.cz;
|
||||
section_header.unknown = section_tailer.unknown;
|
||||
w += sizeof(t_vxl4_section_header);
|
||||
for (int j = 0; j < f.get_c_spans(i); j++)
|
||||
{
|
||||
for (int j = 0; j < f.get_c_spans(i); j++) {
|
||||
const byte* r = f.get_span_data(i, j);
|
||||
if (r)
|
||||
{
|
||||
if (r) {
|
||||
int z = 0;
|
||||
while (z < cz)
|
||||
{
|
||||
while (z < cz) {
|
||||
int z_inc = *w++ = *r++;
|
||||
if (z_inc == cz)
|
||||
break;
|
||||
z += z_inc;
|
||||
int c = *w++ = *r++;
|
||||
while (c--)
|
||||
{
|
||||
while (c--) {
|
||||
*w++ = *r++;
|
||||
*w++ = *r++;
|
||||
z++;
|
||||
}
|
||||
r++;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
*w++ = cz;
|
||||
}
|
||||
}
|
||||
|
@ -556,19 +512,16 @@ int vxl_decode4_size(const byte* s)
|
|||
const int c_sections = s_header.c_sections;
|
||||
r += sizeof(t_vxl4_header);
|
||||
int w = 0;
|
||||
for (int i = 0; i < c_sections; i++)
|
||||
{
|
||||
for (int i = 0; i < c_sections; i++) {
|
||||
const t_vxl4_section_header& section_header = *reinterpret_cast<const t_vxl4_section_header*>(r);
|
||||
const int cx = section_header.cx;
|
||||
const int cy = section_header.cy;
|
||||
const int cz = section_header.cz;
|
||||
w += 8 * cx * cy;
|
||||
r += sizeof(t_vxl4_section_header);
|
||||
for (int j = 0; j < cx * cy; j++)
|
||||
{
|
||||
for (int j = 0; j < cx * cy; j++) {
|
||||
int z = 0;
|
||||
while (z < cz)
|
||||
{
|
||||
while (z < cz) {
|
||||
int z_inc = *r++;
|
||||
if (z_inc == cz)
|
||||
break;
|
||||
|
@ -604,8 +557,7 @@ Cvirtual_binary vxl_decode4(const byte* s, int cb_d)
|
|||
t_vxl_section_tailer* section_tailer = new t_vxl_section_tailer[c_sections];
|
||||
w += sizeof(t_vxl_section_header) * c_sections;
|
||||
byte* body_start = w;
|
||||
for (int i = 0; i < c_sections; i++)
|
||||
{
|
||||
for (int i = 0; i < c_sections; i++) {
|
||||
const t_vxl4_section_header& section_header = *reinterpret_cast<const t_vxl4_section_header*>(r);
|
||||
const int cx = section_header.cx;
|
||||
const int cy = section_header.cy;
|
||||
|
@ -635,33 +587,27 @@ Cvirtual_binary vxl_decode4(const byte* s, int cb_d)
|
|||
section_tailer[i].unknown = section_header.unknown;
|
||||
r += sizeof(t_vxl4_section_header);
|
||||
byte* span_data_start = w;
|
||||
for (int j = 0; j < cx * cy; j++)
|
||||
{
|
||||
for (int j = 0; j < cx * cy; j++) {
|
||||
byte* span_start = w;
|
||||
int z = 0;
|
||||
while (z < cz)
|
||||
{
|
||||
while (z < cz) {
|
||||
int z_inc = *r++;
|
||||
if (z_inc == cz)
|
||||
break;
|
||||
z += *w++ = z_inc;
|
||||
int count = *w++ = *r++;
|
||||
int c = count;
|
||||
while (c--)
|
||||
{
|
||||
while (c--) {
|
||||
*w++ = *r++;
|
||||
*w++ = *r++;
|
||||
z++;
|
||||
}
|
||||
*w++ = count;
|
||||
}
|
||||
if (span_start == w)
|
||||
{
|
||||
if (span_start == w) {
|
||||
span_start_list[j] = -1;
|
||||
span_end_list[j] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
span_start_list[j] = span_start - span_data_start;
|
||||
span_end_list[j] = w - span_data_start - 1;
|
||||
}
|
||||
|
|
26
3rdParty/xcc/misc/vxl_file.h
vendored
26
3rdParty/xcc/misc/vxl_file.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -37,7 +37,7 @@ public:
|
|||
int extract_as_xif(const string& name) const;
|
||||
#endif
|
||||
bool is_valid() const;
|
||||
|
||||
|
||||
int get_c_section_headers() const
|
||||
{
|
||||
return header().c_section_headers;
|
||||
|
|
24
3rdParty/xcc/misc/win_handle.cpp
vendored
24
3rdParty/xcc/misc/win_handle.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2002 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2002 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
|
24
3rdParty/xcc/misc/win_handle.h
vendored
24
3rdParty/xcc/misc/win_handle.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2002 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2002 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
65
3rdParty/xcc/misc/xcc_dirs.cpp
vendored
65
3rdParty/xcc/misc/xcc_dirs.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "xcc_dirs.h"
|
||||
|
@ -50,8 +50,7 @@ bool xcc_dirs::enable_log()
|
|||
|
||||
string xcc_dirs::get_dir(t_game game)
|
||||
{
|
||||
switch (game)
|
||||
{
|
||||
switch (game) {
|
||||
case game_td:
|
||||
return td_primary_dir;
|
||||
case game_ra:
|
||||
|
@ -87,8 +86,7 @@ string xcc_dirs::get_dir(t_game game)
|
|||
|
||||
string xcc_dirs::get_exe(t_game game)
|
||||
{
|
||||
switch (game)
|
||||
{
|
||||
switch (game) {
|
||||
case game_td:
|
||||
return td_primary_dir + "c&c95.exe";
|
||||
case game_ra:
|
||||
|
@ -116,8 +114,7 @@ string xcc_dirs::get_exe(t_game game)
|
|||
|
||||
string xcc_dirs::get_audio_mix(t_game game)
|
||||
{
|
||||
switch (game)
|
||||
{
|
||||
switch (game) {
|
||||
case game_ra2:
|
||||
return "audio.mix";
|
||||
case game_ra2_yr:
|
||||
|
@ -129,8 +126,7 @@ string xcc_dirs::get_audio_mix(t_game game)
|
|||
|
||||
string xcc_dirs::get_csf_fname(t_game game)
|
||||
{
|
||||
switch (game)
|
||||
{
|
||||
switch (game) {
|
||||
case game_ra2:
|
||||
return "ra2.csf";
|
||||
case game_ra2_yr:
|
||||
|
@ -173,8 +169,7 @@ string xcc_dirs::get_expand_mix(t_game game, const string& s)
|
|||
|
||||
string xcc_dirs::get_language_mix(t_game game)
|
||||
{
|
||||
switch (game)
|
||||
{
|
||||
switch (game) {
|
||||
case game_ra2:
|
||||
return ra2_dir + "language.mix";
|
||||
case game_ra2_yr:
|
||||
|
@ -190,8 +185,7 @@ string xcc_dirs::get_language_mix(t_game game)
|
|||
|
||||
string xcc_dirs::get_local_mix(t_game game)
|
||||
{
|
||||
switch (game)
|
||||
{
|
||||
switch (game) {
|
||||
case game_ts:
|
||||
case game_ra2:
|
||||
return "local.mix";
|
||||
|
@ -204,8 +198,7 @@ string xcc_dirs::get_local_mix(t_game game)
|
|||
|
||||
string xcc_dirs::get_main_mix(t_game game)
|
||||
{
|
||||
switch (game)
|
||||
{
|
||||
switch (game) {
|
||||
case game_ra:
|
||||
return ra_dir + "redalert.mix";
|
||||
case game_ts:
|
||||
|
@ -223,14 +216,13 @@ static void set_path(string s, string& path)
|
|||
{
|
||||
boost::to_lower(s);
|
||||
if (!s.empty() && s.back() != '\\')
|
||||
s += '\\';
|
||||
s += '\\';
|
||||
path = s;
|
||||
}
|
||||
|
||||
void xcc_dirs::set_dir(t_game game, const string &s)
|
||||
void xcc_dirs::set_dir(t_game game, const string& s)
|
||||
{
|
||||
switch (game)
|
||||
{
|
||||
switch (game) {
|
||||
case game_td:
|
||||
set_path(s, td_primary_dir);
|
||||
break;
|
||||
|
@ -294,10 +286,8 @@ void xcc_dirs::reset_cd_dir()
|
|||
{
|
||||
int drive_map = GetLogicalDrives();
|
||||
char drive_root[] = "a:\\";
|
||||
for (int i = 0; i < 26; i++)
|
||||
{
|
||||
if (drive_map >> i & 1 && GetDriveTypeA(drive_root) == DRIVE_CDROM)
|
||||
{
|
||||
for (int i = 0; i < 26; i++) {
|
||||
if (drive_map >> i & 1 && GetDriveTypeA(drive_root) == DRIVE_CDROM) {
|
||||
set_cd_dir(drive_root);
|
||||
break;
|
||||
}
|
||||
|
@ -314,8 +304,8 @@ static void read_dir(const string& key, const string& value, t_game game)
|
|||
{
|
||||
Creg_key h;
|
||||
string s;
|
||||
if (xcc_dirs::get_dir(game).empty()
|
||||
&& ERROR_SUCCESS == h.open(HKEY_LOCAL_MACHINE, key, KEY_QUERY_VALUE)
|
||||
if (xcc_dirs::get_dir(game).empty()
|
||||
&& ERROR_SUCCESS == h.open(HKEY_LOCAL_MACHINE, key, KEY_QUERY_VALUE)
|
||||
&& ERROR_SUCCESS == h.query_value(value, s))
|
||||
xcc_dirs::set_dir(game, Cfname(s).get_path());
|
||||
}
|
||||
|
@ -323,8 +313,7 @@ static void read_dir(const string& key, const string& value, t_game game)
|
|||
void xcc_dirs::load_from_registry()
|
||||
{
|
||||
Creg_key kh_base;
|
||||
if (!Cxcc_registry::get_base_key(kh_base))
|
||||
{
|
||||
if (!Cxcc_registry::get_base_key(kh_base)) {
|
||||
string s;
|
||||
if (ERROR_SUCCESS == kh_base.query_value("dune2_dir", s))
|
||||
set_dir(game_dune2, s);
|
||||
|
|
30
3rdParty/xcc/misc/xcc_dirs.h
vendored
30
3rdParty/xcc/misc/xcc_dirs.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -21,7 +21,7 @@
|
|||
#include "cc_structures.h"
|
||||
#include "fname.h"
|
||||
|
||||
class xcc_dirs
|
||||
class xcc_dirs
|
||||
{
|
||||
public:
|
||||
static bool enable_log();
|
||||
|
@ -41,8 +41,8 @@ public:
|
|||
static string get_local_mix(t_game game);
|
||||
static string get_main_mix(t_game game);
|
||||
static void set_td_secondary_dir(const string& s);
|
||||
static void set_cd_dir(const string &s);
|
||||
static void set_data_dir(const string &s);
|
||||
static void set_cd_dir(const string& s);
|
||||
static void set_data_dir(const string& s);
|
||||
static void set_dir(t_game game, const string& s);
|
||||
static void reset_cd_dir();
|
||||
static void reset_data_dir();
|
||||
|
|
26
3rdParty/xcc/misc/xcc_file.h
vendored
26
3rdParty/xcc/misc/xcc_file.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -35,7 +35,7 @@ public:
|
|||
{
|
||||
const t_xcc_header& h = header();
|
||||
int size = get_size();
|
||||
return !(sizeof(t_xcc_header) > size ||
|
||||
return !(sizeof(t_xcc_header) > size ||
|
||||
strcmp(h.id, xcc_id) ||
|
||||
h.size != size ||
|
||||
h.version);
|
||||
|
|
24
3rdParty/xcc/misc/xcc_file_sh.h
vendored
24
3rdParty/xcc/misc/xcc_file_sh.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
24
3rdParty/xcc/misc/xcc_lmd_file.h
vendored
24
3rdParty/xcc/misc/xcc_lmd_file.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
|
27
3rdParty/xcc/misc/xcc_lmd_file_write.cpp
vendored
27
3rdParty/xcc/misc/xcc_lmd_file_write.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
@ -44,8 +44,7 @@ Cvirtual_binary Cxcc_lmd_file_write::write(t_game game) const
|
|||
lmd_header.c_fnames = m_index.size();
|
||||
lmd_header.game = game;
|
||||
w += sizeof(t_xcc_lmd_header);
|
||||
for (auto& i : m_index)
|
||||
{
|
||||
for (auto& i : m_index) {
|
||||
strcpy(reinterpret_cast<char*>(w), i.c_str());
|
||||
w += i.length() + 1;
|
||||
}
|
||||
|
|
26
3rdParty/xcc/misc/xcc_lmd_file_write.h
vendored
26
3rdParty/xcc/misc/xcc_lmd_file_write.h
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -24,7 +24,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
class Cxcc_lmd_file_write
|
||||
class Cxcc_lmd_file_write
|
||||
{
|
||||
public:
|
||||
void add_fname(const string& fname);
|
||||
|
|
24
3rdParty/xcc/misc/xcc_registry.cpp
vendored
24
3rdParty/xcc/misc/xcc_registry.cpp
vendored
|
@ -1,19 +1,19 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
|
26
3rdParty/xcc/misc/xcc_registry.h
vendored
26
3rdParty/xcc/misc/xcc_registry.h
vendored
|
@ -1,26 +1,26 @@
|
|||
/*
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
XCC Utilities and Library
|
||||
Copyright (C) 2000 Olaf van der Spek <olafvdspek@gmail.com>
|
||||
|
||||
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 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.
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "reg_key.h"
|
||||
|
||||
class Cxcc_registry
|
||||
class Cxcc_registry
|
||||
{
|
||||
public:
|
||||
static int get_base_key(Creg_key&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue