fix bug in load/save settings (introduced by altering pe_settings layout)

This commit is contained in:
Arvid Norberg 2013-12-03 09:10:16 +00:00
parent a05103154b
commit 9c761f6777
3 changed files with 12 additions and 6 deletions

View File

@ -45,7 +45,7 @@ namespace libtorrent
enum struct_field_type_t
{
std_string, character, integer, floating_point,
boolean, size_integer, time_integer
boolean, size_integer, time_integer, integer16
};
// this is used to map struct entries

View File

@ -463,10 +463,10 @@ namespace aux {
bencode_map_entry proxy_settings_map[] =
{
TORRENT_SETTING(std_string, hostname)
TORRENT_SETTING(integer, port)
TORRENT_SETTING(integer16, port)
TORRENT_SETTING(std_string, username)
TORRENT_SETTING(std_string, password)
TORRENT_SETTING(integer, type)
TORRENT_SETTING(character, type)
TORRENT_SETTING(boolean, proxy_hostnames)
TORRENT_SETTING(boolean, proxy_peer_connections)
};
@ -496,9 +496,9 @@ namespace aux {
#define TORRENT_SETTING(t, x) {#x, offsetof(pe_settings,x), t},
bencode_map_entry pe_settings_map[] =
{
TORRENT_SETTING(integer, out_enc_policy)
TORRENT_SETTING(integer, in_enc_policy)
TORRENT_SETTING(integer, allowed_enc_level)
TORRENT_SETTING(character, out_enc_policy)
TORRENT_SETTING(character, in_enc_policy)
TORRENT_SETTING(character, allowed_enc_level)
TORRENT_SETTING(boolean, prefer_rc4)
};
#undef TORRENT_SETTING

View File

@ -40,6 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
// TODO: 4 eliminate all use of this mechanism
void load_struct(lazy_entry const& e, void* s, bencode_map_entry const* m, int num)
{
for (int i = 0; i < num; ++i)
@ -56,6 +57,7 @@ namespace libtorrent
break;
}
case character:
case integer16:
case boolean:
case integer:
case size_integer:
@ -67,6 +69,7 @@ namespace libtorrent
switch (m[i].type)
{
case character: *((char*)dest) = char(val); break;
case integer16: *((boost::uint16_t*)dest) = boost::uint16_t(val); break;
case integer: *((int*)dest) = int(val); break;
case size_integer: *((size_type*)dest) = size_type(val); break;
case time_integer: *((time_t*)dest) = time_t(val); break;
@ -101,6 +104,9 @@ namespace libtorrent
case integer:
if (*((int*)src) == *((int*)default_value)) continue;
break;
case integer16:
if (*((boost::uint16_t*)src) == *((boost::uint16_t*)default_value)) continue;
break;
case size_integer:
if (*((size_type*)src) == *((size_type*)default_value)) continue;
break;