URL:
  <http://gna.org/bugs/?19681>

                 Summary: cache is never valid
                 Project: Battle for Wesnoth
            Submitted by: kernigh
            Submitted on: Tue 01 May 2012 03:16:34 AM GMT
                Category: Bug
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: WML
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 1.10.2+svn (54047)
        Operating System: OpenBSD 5.0

    _______________________________________________________

Details:

Wesnoth 1.10.x always rejects the cache in ~/.cache/wesnoth and generates the
cache again. To reproduce this bug:

0 Start Wesnoth, then choose Multiplayer, Local Game. When you reach the map
list, you now have a current cache (at least for multiplayer games).
0 Quit Wesnoth.
0 Start Wesnoth again, then choose Multiplayer, Local Game. Notice that
Wesnoth generates the cache again.

This bug is more obvious if you install more multiplayer add-ons, including
SXCollection. Then cache generation is slower.

Wesnoth 1.8.6 does not have this bug. I first noticed this bug with Wesnoth
1.9.x, but I did not report the bug until now, because I often used _svn up_
or edited WML files.

Today, I hacked config_cache.cpp and learned much about this bug. Wesnoth has
trouble when reading each *.checksum.gz file. Each file looks like


$ zcat *b4ed1f*.checksum.gz
modified=1335817180
nfiles=4425
size=212649201


These are the correct values. If _file_tree_checksum dir_checksum_ would have
these values, then the checksum would pass, and Wesnoth would use my cache.
However, Wesnoth fails to load the correct values.

Around config_cache.cpp:197, I added these lines,


ERR_CACHE << "looks like " << checksum_cfg["nfiles"] << " " <<
checksum_cfg["size"] << " " << checksum_cfg["modified"] << "\n";
config_writer writer(std::cerr, false);
writer.write(checksum_cfg);


Their output is


20120430 22:01:46 error cache: looks like 4425 2.12649e+08 1.33582e+09
modified=1335817180
nfiles=4425
size=212649201


Then around config_cache.cpp:215, I added these lines,


file_tree_checksum tru_checksum = data_tree_checksum();
if(dir_checksum != tru_checksum) {
        ERR_CACHE << "wrong checksum: " << fname << extension << "\n"
                << "  have: " << dir_checksum.nfiles << " " << 
dir_checksum.sum_size << " "
<< dir_checksum.modified << "\n"
                << "  need: " << tru_checksum.nfiles << " " << 
tru_checksum.sum_size << " "
<< tru_checksum.modified << "\n";
}


Their output is


20120430 22:01:46 error cache: wrong checksum:
/home/kernigh/.cache/wesnoth/cache-v1.10.2+svn
(54047M)-b4ed1f8db3a4af53f5455db4def5f31f899667cd.gz
  have: 4425 2 1
  need: 4425 212649201 1335817180


Because 2 != 212649201, or 1 != 1335817180, so the checksum fails, and Wesnoth
rejects the cache.

Wesnoth seems to convert 212649201 to "2.12649e+08" to 2, and likewise
1335817180 to "1.33582e+09" to 1. This bug might relate to bug #19201, which
claims that Wesnoth has trouble when reading numbers from WML.

I am not sure how to fix this bug. The actual conversion happens at
filesystem.cpp:866, where


file_tree_checksum::file_tree_checksum(const config& cfg) :
        nfiles  (lexical_cast_default<size_t>(cfg["nfiles"])),
        sum_size(lexical_cast_default<size_t>(cfg["size"])),
        modified(lexical_cast_default<time_t>(cfg["modified"]))
{
}


This converts cfg[...] from _config::attribute_value_ to _size_t_ or _time_t_,
but I know not how Wesnoth does this conversion.

I compiled Wesnoth 1.10.2+svn (54047) for OpenBSD 5.0, with this compiler


$ g++ -v 
Reading specs from /usr/lib/gcc-lib/amd64-unknown-openbsd5.0/4.2.1/specs
Target: amd64-unknown-openbsd5.0
Configured with: OpenBSD/amd64 system compiler
Thread model: posix
gcc version 4.2.1 20070719 


and these packages


$ pkg_info -I boost pango sdl                               
boost-1.42.0p7      free peer-reviewed portable C++ source libraries
pango-1.28.4p2      library for layout and rendering of text
sdl-1.2.13p15       cross-platform multimedia library






    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?19681>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Wesnoth-bugs mailing list
Wesnoth-bugs@gna.org
https://mail.gna.org/listinfo/wesnoth-bugs

Reply via email to