Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(UI): gunmod wield info no longer causes game to crash #5136

Merged
merged 4 commits into from
Aug 3, 2024

Conversation

chaosvolt
Copy link
Member

Checklist

Required

Optional

Purpose of change

This fixes a mistake I made in #4183 where UI changes did not play well with uninstalled gunmods.

Fixes #5132

Describe the solution

In character_functions.cpp, updated fmt_wielded_weapon so that the gun UI stuff only calls for gun_current_mode if the affected item is a valid gun and not an isolated gunmod. Gunmods also no longer try to display fire mode since it's not relevant to gunmods that can't be fired when uninstalled.

Describe alternatives you've considered

Just slapping && !weapon.is_gunmod() to the opening if statement would be a braindead easy hack to fix this but would make it so wielded gunmods no longer show you their (technically irrelevant due to not being able to fire) loaded ammo in wield info.

Testing

  1. Compiled and load-tested.
  2. Wielded an M4, M203, and an M4 with M203 installed on it.
  3. No crashes when wielding a gunmod anymore, info displayed when wielding the M203 is also fixed.
  4. Checked affected file for astyle.

M4:
image

Loose M203:
image

M4 with M203 installed:
image

M4 with M203, M203 selected:
image

Additional context

chaosvolt and others added 2 commits August 2, 2024 21:44
Co-Authored-By: KheirFerrum <102964889+KheirFerrum@users.noreply.github.com>
@github-actions github-actions bot added the src changes related to source code. label Aug 3, 2024
@chaosvolt chaosvolt changed the title fix (UI): gunmod wield info no longer causes game to crash fix(UI): gunmod wield info no longer causes game to crash Aug 3, 2024
Co-authored-by: scarf <greenscarf005@gmail.com>
@chaosvolt
Copy link
Member Author

@scarf005 so that change proposal borked it:

1>C:\Users\Vincent\Documents\GitHub\Cataclysm-BN\src\character_functions.cpp(458,72): error C2678: binary '+=': no operator found which takes a left-hand operand of type 'const std::string' (or there is no acceptable conversion)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(3084,42): message : could be 'std::basic_string<char,std::char_traits<char>,std::allocator<char>> &std::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator +=(_Elem)'
1>        with
1>        [
1>            _Elem=char
1>        ] (compiling source file ..\src\character_functions.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(3080,42): message : or       'std::basic_string<char,std::char_traits<char>,std::allocator<char>> &std::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator +=(const _Elem *const )'
1>        with
1>        [
1>            _Elem=char
1>        ] (compiling source file ..\src\character_functions.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(3069,42): message : or       'std::basic_string<char,std::char_traits<char>,std::allocator<char>> &std::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator +=(const std::basic_string<char,std::char_traits<char>,std::allocator<char>> &)' (compiling source file ..\src\character_functions.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(2935,42): message : or       'std::basic_string<char,std::char_traits<char>,std::allocator<char>> &std::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator +=(std::initializer_list<_Elem>)'
1>        with
1>        [
1>            _Elem=char
1>        ] (compiling source file ..\src\character_functions.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(3075,42): message : or       'std::basic_string<char,std::char_traits<char>,std::allocator<char>> &std::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator +=<std::basic_string<char,std::char_traits<char>,std::allocator<char>>,0>(const _StringViewIsh &)'
1>        with
1>        [
1>            _StringViewIsh=std::basic_string<char,std::char_traits<char>,std::allocator<char>>
1>        ] (compiling source file ..\src\character_functions.cpp)
1>C:\Users\Vincent\Documents\GitHub\Cataclysm-BN\src\character_functions.cpp(458,72): message : while trying to match the argument list '(const std::string, std::basic_string<char,std::char_traits<char>,std::allocator<char>>)'
1>C:\Users\Vincent\Documents\GitHub\Cataclysm-BN\src\character_functions.cpp(460,74): error C2678: binary '+=': no operator found which takes a left-hand operand of type 'const std::string' (or there is no acceptable conversion)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(3084,42): message : could be 'std::basic_string<char,std::char_traits<char>,std::allocator<char>> &std::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator +=(_Elem)'
1>        with
1>        [
1>            _Elem=char
1>        ] (compiling source file ..\src\character_functions.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(3080,42): message : or       'std::basic_string<char,std::char_traits<char>,std::allocator<char>> &std::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator +=(const _Elem *const )'
1>        with
1>        [
1>            _Elem=char
1>        ] (compiling source file ..\src\character_functions.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(3069,42): message : or       'std::basic_string<char,std::char_traits<char>,std::allocator<char>> &std::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator +=(const std::basic_string<char,std::char_traits<char>,std::allocator<char>> &)' (compiling source file ..\src\character_functions.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(2935,42): message : or       'std::basic_string<char,std::char_traits<char>,std::allocator<char>> &std::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator +=(std::initializer_list<_Elem>)'
1>        with
1>        [
1>            _Elem=char
1>        ] (compiling source file ..\src\character_functions.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(3075,42): message : or       'std::basic_string<char,std::char_traits<char>,std::allocator<char>> &std::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator +=<std::basic_string<char,std::char_traits<char>,std::allocator<char>>,0>(const _StringViewIsh &)'
1>        with
1>        [
1>            _StringViewIsh=std::basic_string<char,std::char_traits<char>,std::allocator<char>>
1>        ] (compiling source file ..\src\character_functions.cpp)
1>C:\Users\Vincent\Documents\GitHub\Cataclysm-BN\src\character_functions.cpp(460,74): message : while trying to match the argument list '(const std::string, std::basic_string<char,std::char_traits<char>,std::allocator<char>>)'
1>C:\Users\Vincent\Documents\GitHub\Cataclysm-BN\src\character_functions.cpp(462,31): error C2678: binary '+=': no operator found which takes a left-hand operand of type 'const std::string' (or there is no acceptable conversion)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(3084,42): message : could be 'std::basic_string<char,std::char_traits<char>,std::allocator<char>> &std::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator +=(_Elem)'
1>        with
1>        [
1>            _Elem=char
1>        ] (compiling source file ..\src\character_functions.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(3080,42): message : or       'std::basic_string<char,std::char_traits<char>,std::allocator<char>> &std::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator +=(const _Elem *const )'
1>        with
1>        [
1>            _Elem=char
1>        ] (compiling source file ..\src\character_functions.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(3069,42): message : or       'std::basic_string<char,std::char_traits<char>,std::allocator<char>> &std::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator +=(const std::basic_string<char,std::char_traits<char>,std::allocator<char>> &)' (compiling source file ..\src\character_functions.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xstring(2935,42): message : or       'std::basic_string<char,std::char_traits<char>,std::allocator<char>> &std::basic_string<char,std::char_traits<char>,std::allocator<char>>::operator +=(std::initializer_list<_Elem>)'
1>        with
1>        [
1>            _Elem=char
1>        ] (compiling source file ..\src\character_functions.cpp)
1>C:\Users\Vincent\Documents\GitHub\Cataclysm-BN\src\character_functions.cpp(462,31): message : while trying to match the argument list '(const std::string, const char [2])'
1>Done building project "Cataclysm-lib-vcpkg-static.vcxproj" -- FAILED.

ugh i hate mutation
@chaosvolt
Copy link
Member Author

Aight, it compiles and works same as the initial method did.

@chaosvolt chaosvolt merged commit 2b7c4bb into cataclysmbnteam:main Aug 3, 2024
12 of 13 checks passed
@chaosvolt chaosvolt deleted the gunmod-crashfix branch August 3, 2024 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when attempting to wield underbarrel shotguns
2 participants