Added set of functions that perform integer division with different
rounding modes:
- divideAndCeil - rounds up to next integer
- divideAndRound - rounds to nearest integer
- divideAndFloor - rounds to previous integer (equivalent to default
division)
Intended for use in library, where usage of floating point might lead to
desync in multiplayer games.
Replaced some cases that I knew of, including recent handicap PR
Attempt to get a bit more debug info from crashes. VCMI will now:
- use c++ terminate handler on any platform in release builds
- attempt to write call stack to log file using boost::callstack
Since I use std::set_terminate this will only affect c++ exceptions, e.g.
std::runtime_error and will not affect OS signals, e.g. SIGSEGV. Handling
signals is OS-specific and has a lot of limitations that I don't want to
investigate. Besides - most of our crashes are now caused by c++
exceptions.
Haven't tested on other platforms, but should at the very least write
exception information (`e.what()`) for all exceptions and function names
for methods exported from dll's (libvcmi.so & AI's). Possibly more, if
debug information is present.
Fixes the following warning, occurring during the linux-clang-test CI builds:
[824/832] Building CXX object test/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
In file included from /home/runner/work/vcmi/vcmi/test/googletest/googletest/src/gtest-all.cc:38:
In file included from /home/runner/work/vcmi/vcmi/test/googletest/googletest/include/gtest/gtest.h:65:
In file included from /home/runner/work/vcmi/vcmi/test/googletest/googletest/include/gtest/gtest-death-test.h:43:
In file included from /home/runner/work/vcmi/vcmi/test/googletest/googletest/include/gtest/internal/gtest-death-test-internal.h:47:
In file included from /home/runner/work/vcmi/vcmi/test/googletest/googletest/include/gtest/gtest-matchers.h:48:
/home/runner/work/vcmi/vcmi/test/googletest/googletest/include/gtest/gtest-printers.h:532:9: warning: implicit conversion from 'int32_t' (aka 'int') to 'float' may lose precision [-Wimplicit-int-float-conversion]
532 | if (static_cast<int32_t>(val * mulfor6 + 0.5) / mulfor6 == val) return 6;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~
/home/runner/work/vcmi/vcmi/test/googletest/googletest/include/gtest/gtest-printers.h:551:17: note: in instantiation of function template specialization 'testing::internal::AppropriateResolution<float>' requested here
551 | os->precision(AppropriateResolution(f));
| ^
/home/runner/work/vcmi/vcmi/test/googletest/googletest/include/gtest/gtest-printers.h:544:9: warning: implicit conversion from 'int32_t' (aka 'int') to 'float' may lose precision [-Wimplicit-int-float-conversion]
544 | if (static_cast<int32_t>(val / divfor6 + 0.5) * divfor6 == val) return 6;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~
2 warnings generated.
- change return of `getBuildingVariantsFromModel` to `QVariantList`
- change while to do-while where it makes sense
- moved constants outside of methods
- made building and resources name non editable