1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00
Commit Graph

2828 Commits

Author SHA1 Message Date
Dmitry Orlov
25d9ea1ddf Feature: Opposite Side Limiter 2021-09-04 14:15:38 +03:00
Dmitry Orlov
6f0864b47c Feature: Town Negative Bonuses. Fix: Negative bonus bearers should not be affected 2021-09-04 14:15:37 +03:00
Andrii Danylchenko
83f690e059 change SDL color key alpha to transparent 2021-08-21 09:32:52 +03:00
Andrii Danylchenko
27b3a88dda Replace App Veyor 2021-08-21 09:32:52 +03:00
Sergei Trofimovich
23215e039c client/CVideoHandler.cpp: fix crash on video playback
Avoid buffer overflow caused by sws_scale():
    http://trac.ffmpeg.org/ticket/9254
Currently (ffmpeg-4.4 with SSE3 enabled) sws_scale()
has a few requirements for target data buffers on rescaling:
1. buffer has to be aligned to be usable for SIMD instructions
2. buffer has to be padded to allow small overflow by SIMD instructions
Unfortunately SDL_Surface does not provide these guarantees.
This means that atempt to rescale directly into SDL surface causes
memory corruption. Usually it happens on campaign selection screen
where short video moves start spinning on mouse hover.

To fix [1.] we use av_malloc() for memory allocation.
To fix [2.] we add an `ffmpeg_pad` that provides plenty of space.
We have to use intermdiate buffer and then use memcpy() to land it
to SDL_Surface.

Without the change crash has the following backtrace:

```
(gdb) bt
    (c=0x47508940, src=0x1ffeffef50, srcStride=0x1ffeffef30, srcSliceY=0, srcSliceH=116, dst=0x1ffeffef70, dstStride=0x1ffeffef40) at src/libswscale/x86/yuv2rgb_template.c:119
    (c=<optimized out>, srcSlice=<optimized out>, srcStride=0x432afa20, srcSliceY=<optimized out>, srcSliceH=116, dst=<optimized out>, dstStride=0x1ffefff0a0) at src/libswscale/swscale.c:969
    (this=0x1abaa330, x=90, y=72, dst=0x1a85a4c0, forceRedraw=<optimized out>, update=<optimized out>)
    at ../vcmi-9999/client/CVideoHandler.cpp:332
    at ../vcmi-9999/client/gui/CIntObject.cpp:83
    at ../vcmi-9999/client/gui/CGuiHandler.cpp:462
```

valgrind points to corruption right in sws_scale():

```
Invalid write of size 8
   at 0x6C50BD3: ??? (in /usr/lib64/libswscale.so.5.7.100)
   by 0x6C4FAE6: yuv420_rgb32_ssse3 (yuv2rgb_template.c:119)
   by 0x6C28DF2: sws_scale (swscale.c:969)
   by 0x4566F6: CVideoPlayer::nextFrame() (CVideoHandler.cpp:293)
   by 0x4573A6: CVideoPlayer::update(int, int, SDL_Surface*, bool, bool) (CVideoHandler.cpp:332)
   by 0x25EC94: CIntObject::show(SDL_Surface*) [clone .part.0] (CIntObject.cpp:83)
   by 0x34E855: CMainMenu::update() (CMainMenu.cpp:319)
   by 0x25D589: CGuiHandler::renderFrame() (CGuiHandler.cpp:462)
   by 0x1F7450: mainLoop (CMT.cpp:1387)
   by 0x1F7450: main (CMT.cpp:513)
 Address 0x475088a8 is 0 bytes after a block of size 92,840 alloc'd
   at 0x483F7E5: malloc (vg_replace_malloc.c:380)
   by 0x52B4E23: SDL_malloc_REAL (SDL_malloc.c:5387)
   by 0x5266237: SDL_SIMDAlloc_REAL (SDL_cpuinfo.c:963)
   by 0x52EF042: SDL_CreateRGBSurfaceWithFormat_REAL (SDL_surface.c:123)
   by 0x2649AC: CSDL_Ext::newSurface(int, int, SDL_Surface*) (SDL_Extensions.cpp:42)
   by 0x457B20: CVideoPlayer::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, bool, bool) (CVideoHandler.cpp:182)
   by 0x457C60: CVideoPlayer::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool) (CVideoHandler.cpp:84)
   by 0x35B14E: CCampaignScreen::CCampaignButton::show(SDL_Surface*) (CCampaignScreen.cpp:126)
   by 0x25EC94: CIntObject::show(SDL_Surface*) [clone .part.0] (CIntObject.cpp:83)
   by 0x34E855: CMainMenu::update() (CMainMenu.cpp:319)
   by 0x25D589: CGuiHandler::renderFrame() (CGuiHandler.cpp:462)
   by 0x1F7450: mainLoop (CMT.cpp:1387)
   by 0x1F7450: main (CMT.cpp:513)
```

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2021-07-31 14:35:31 +03:00
Andrii Danylchenko
3fa7e0976f Nullkiller: update / fix build, core changes required for Nullkiller AI 2021-07-26 21:02:50 +03:00
Andrii Danylchenko
b4241670ba Nullkiller: rename VCAI to AIGateway 2021-07-26 21:02:50 +03:00
Sergei Trofimovich
e407d4e547 client/lobby/CBonusSelection.cpp: fix difficulty overflow in bonus UI
Before the change campaign bonus selection screen had inconsistent
overflow behaviour for difficulty selection:

```
    0 1 2 3 4 | available buttons: '-' to decrease
      ^       |                    '+' to increase
```

Before the change:

1. If we click '+' 5 times we will end up on difficulty=4 (ok, saturated).
2. If we click '-' 5 times we will end up on difficulty=1 (unexpected, wrap around).

After the change:

1. If we click '+' 5 times we will end up on difficulty=4 (saturated).
2. If we click '-' 5 times we will end up on difficulty=0 (saturated).

The inconsistency happens because `difficulty` variable has `ui8` type
and server uses `difficulty = vstd::abetween(difficulty, 0, 4)` to
implement the saturation.

For large positive values saturation works as expected:
    vstd::abetween(difficulty=5, 0, 4) -> 4
For small values it does not:
    vstd::abetween(difficulty=-1, 0, 4) -> 4

The change makes client to avoid using negative values.
2021-07-25 21:01:17 +03:00
Sergei Trofimovich
e4dd2f6dd8 client/lobby/SelectionTab.cpp: initialize generalSortingBy before use
Noticed use of uninitialized value when built vcmi with -fsanitize=undefined:

```
  Established connection with
    VCMI 0.99 b310f2e61e (server).
    UUID: bab9a90d-7416-4566-8817-e367ffcac7c1
  ../vcmi-9999/client/lobby/SelectionTab.cpp:138:16:
    runtime error: load of value 32717, which is not a valid value for type 'ESortBy'
  /usr/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include/g++-v12/tuple:190:4:
    runtime error: load of value 32717, which is not a valid value for type 'ESortBy'
  /usr/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include/g++-v12/tuple:190:4:
    runtime error: load of value 32717, which is not a valid value for type 'ESortBy'
```

Here (before the change) `SelectionTab()` used `generalSortingBy` before
first use:

```
    SelectionTab::SelectionTab(ESelectionScreen Type) {
        ...
        if(tabType != ESelectionScreen::campaignList)
        {
            ...
                ESortBy criteria = (ESortBy)i;
                if(criteria == _name)
                    criteria = generalSortingBy;

                buttonsSortBy.push_back(... std::bind(&SelectionTab::sortBy, this, criteria)));
            ...
        }
        ...
        switch(tabType)
        {
        case ESelectionScreen::newGame:
                generalSortingBy = ESortBy::_name;
        ....
```

The change moves `generalSortingBy` initialization before first use.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2021-07-25 21:00:31 +03:00
Andrii Danylchenko
9c8d776398 Merge branch 'develop' into handlersAbstraction
# Conflicts:
#	CI/linux/before_install.sh
#	CI/mac/before_install.sh
#	CI/mxe/before_install.sh
#	lib/CModHandler.cpp
#	lib/mapObjects/CObjectClassesHandler.cpp
#	lib/mapObjects/CObjectClassesHandler.h
#	lib/mapObjects/CommonConstructors.cpp
#	server/CGameHandler.cpp
#	test/CMakeLists.txt
#	test/spells/effects/TeleportTest.cpp
2021-07-16 00:32:13 +03:00
AlexVinS
483a4689ce Fixes for code review issues 2021-02-20 04:57:50 +03:00
Vladislav Yakovlev
8e57d36b8c [3167] Fix SDL_StopTextInput extra calls 2021-02-15 21:11:18 +03:00
AlexVinS
a59e12ca5f tweaks 2021-02-15 15:03:32 +03:00
AlexVinS
ecaa9f5d0b Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2021-02-14 19:05:43 +03:00
Alexander Shishkin
db1f9a15b0
Merge pull request #675 from ShubusCorporation/do/fix/mod_system_and_interface_bugs
Fixed: Mods dependency issues leading to hanging & 'Restart Scenario' button functionality
2021-02-08 07:32:09 +03:00
Andrii Danylchenko
ade84699b0 found a bug in code where AI can change client gamestate directly causing sorting crash 2021-01-30 17:29:49 +02:00
Alexander Shishkin
5dc6d782f7
Merge pull request #674 from ShubusCorporation/do/fix/game_interface/load_and_main_menu_buttons
Fix: 'Load' and 'Main Menu' in-game buttons should work properly
2021-01-20 21:52:51 +03:00
Dmitry Orlov
3add3156e2 Fix: 'Restart Scenario' button should work properly 2021-01-20 21:29:50 +03:00
Dmitry Orlov
c99b8b54e6 Fix: 'Load' and 'Main menu' in-game buttons should work properly 2021-01-17 19:18:26 +03:00
Dmitry Orlov
8cd1af6998 Fix: Siege crashes when creature on the archer's tower is not a shooter 2021-01-17 15:02:58 +03:00
Dmitry Orlov
854a2e6c39 Feature: Mods system improvement, Part III. Bunusing buildings customization. 2021-01-14 01:02:13 +03:00
Dmitry Orlov
9cf953157a Fix: client crashes while browsing saves, if some factions are removed 2021-01-06 17:19:59 +03:00
Dmitry Orlov
39de2f6435 Fix: Morale bonus should be shown correctly 2020-11-11 22:43:40 +03:00
Alexander Shishkin
9ca9c809c6
Merge pull request #660 from ShubusCorporation/shc_rmg_issue
Mod system improvement: Patch 2
2020-10-26 09:26:14 +03:00
John Bolton
bb58d349cb Fixed potential race condition 2020-10-24 23:38:39 -07:00
Dmitry Orlov
d6a4767865 Mod system improvement: Patch 2 2020-10-25 01:04:34 +03:00
Alexander Shishkin
ff7fd2077a
Merge pull request #658 from ShubusCorporation/shc_test_centered
Fix: Issue #3151 - text centralization
2020-10-16 08:33:37 +03:00
Dmitry Orlov
e7665ba5de Fix: Issue #3151 - text centralization 2020-10-16 06:08:59 +03:00
Dmitry Orlov
934c4e511d Special buildings support : Patch 1 2020-10-15 15:03:01 +03:00
Dmitry Orlov
195fb8ff41 Mod system improvement Part I : Fix content losing after deserialization 2020-10-10 00:31:23 +03:00
Dmitry Orlov
f4816b0824 Mod system improvement Part I : Special buildings should work in the modders towns 2020-10-07 12:35:11 +03:00
John Bolton
c61bae4060 Fixed RETURN_IF_BATTLE(). Undid disabled warnings. Fixed indentation. 2020-10-05 16:28:28 -07:00
John Bolton
1722d15276
Update client/windows/CCreatureWindow.h
Removed leftover debugging code.

Co-authored-by: Alexander Shishkin <alexvins@users.noreply.github.com>
2020-10-05 16:13:13 -07:00
John Bolton
a05ae78e67 Fixed lots of warnings.
Disabled the following (for MSVC only) that couldn't (or shouldn't) be fixed.

4003: not enough actual parameters for macro 'identifier'
4250: 'class1' : inherits 'class2::member' via dominance
4251: 'type' : class 'type1' needs to have dll-interface to be used by clients of class 'type2'
4275: non dll-interface class 'type1' used as base for dll-interface class 'type2'
2020-10-04 02:20:18 -07:00
John Bolton
6d8f1e4530 Fixed incorrect usage of const std::shared_ptr. Resolves 0003142.
Replaced const TBonusListPtr with TConstBonusListPtr where necessary
Replaced const std::shared_ptr<T> with std::shared_ptr<const T> where necessary.
Removed superfluous use of const.
Replaced const std::shared_ptr<T> with const std::shared_ptr<T> & in function parameters and ranged for-loops.
2020-09-30 22:56:28 -07:00
Dmitry Orlov
38fd05f655 Minor fix: apply Monday bonuses to heroes who have slept overnight 2020-09-28 01:32:33 +03:00
laikh
edc1d06f4e Random Map Generator Option: Allow having more computer only players than human/computer players
Remove unused variable humanPlayersCount and function getHumanOnlyPlayerCount()
2020-07-07 19:45:53 +08:00
laikh
90e2ab58a8 Include header SDL_Compat.h in AdventureMapClasses.cpp 2020-07-05 21:10:29 +08:00
Victor Luchits
f68b449e5e More formatting 2020-05-17 11:21:49 +03:00
Victor Luchits
604246bc7a VS 2019/Windows 10 Kit fix 2020-05-05 15:25:07 +03:00
Victor Luchits
febbeaeeed Close the global log targets on exit, flushing log files to disk 2020-05-05 15:25:07 +03:00
Arseniy Lartsev
fca9bcdd7f
Fixed possible freezes while dragging visible area on minimap (#638) 2020-05-03 01:26:30 +03:00
AlexVinS
55b54024a8 Cherry-picked essential fix from #631. This fixes https://bugs.vcmi.eu/view.php?id=3074. 2020-03-18 00:06:07 +03:00
Alexander Shishkin
00de1fd734
Merge pull request #625 from Toneyisnow/toneyisnow/Battle_Clone_Effect
Implement the Clone Effect in battle.
2020-01-27 13:42:58 +03:00
toneyisnow
1319175bdc Removed the create functions in the ColorShifter classes. 2020-01-27 00:34:59 -08:00
toneyisnow
a03e696ec0 Updated const. 2020-01-26 16:18:07 -08:00
toneyisnow
8db638c054 Fix tiny space issue and remove reference of SDL.h 2020-01-26 00:05:38 -08:00
toneyisnow
468584d469 Update the originalPalette, and use SDL_Palette methods to improve memory management. 2020-01-26 00:01:48 -08:00
toneyisnow
0f4a9e5106 Updated resolved some issues. 2020-01-25 18:49:53 -08:00
toneyisnow
0f3dabab9a Initialize the change:
1. Make color shifter for CAnimation, and use that in the clone effect.
2. Update the original position of the cloned object.
2020-01-25 01:21:26 -08:00