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 compilation errors in condition.cpp #58082

Merged
merged 1 commit into from
Jun 2, 2022

Conversation

c8060da
Copy link
Contributor

@c8060da c8060da commented Jun 2, 2022

Summary

Bugfixes "Fix compilation errors in condition.cpp"

Purpose of change

Fixes #57762
When trying to build the project in macOS 12.4 (clang 13.1.6), got the following errors:

src/condition.cpp -o obj/tiles/condition.o
src/condition.cpp:776:5: error: use of class template 'int_or_var' requires template arguments
    int_or_var iov = get_int_or_var( jo, "npc_allies_global" );
    ^
src/condition.h:131:8: note: template is declared here
struct int_or_var {
       ^
src/condition.cpp:776:22: error: no matching function for call to 'get_int_or_var'
    int_or_var iov = get_int_or_var( jo, "npc_allies_global" );
                     ^~~~~~~~~~~~~~
src/condition.cpp:105:15: note: candidate template ignored: couldn't infer template argument 'T'
int_or_var<T> get_int_or_var( const JsonObject &jo, std::string member, bool required,
              ^
2 errors generated.

And further:

src/condition.cpp -o obj/tiles/condition.o
src/condition.cpp:785:61: error: reference to type 'const dialogue' could not bind to an rvalue of type 'talker *'
         return count >= static_cast<size_t>( iov.evaluate( d.actor( iov.is_npc() ) ) );
                                                            ^~~~~~~~~~~~~~~~~~~~~~~
src/condition.cpp:2797:17: note: in instantiation of member function 'conditional_t<dialogue>::set_npc_allies_global' requested here
template struct conditional_t<dialogue>;
                ^
src/condition.h:138:28: note: passing argument to parameter 'd' here
    int evaluate( const T &d ) const {
                           ^
src/condition.cpp:785:61: error: reference to type 'const mission_goal_condition_context' could not bind to an rvalue of type 'talker *'
         return count >= static_cast<size_t>( iov.evaluate( d.actor( iov.is_npc() ) ) );
                                                            ^~~~~~~~~~~~~~~~~~~~~~~
src/condition.cpp:2576:9: note: in instantiation of member function 'conditional_t<mission_goal_condition_context>::set_npc_allies_global' requested here
        set_npc_allies_global( jo );
        ^
src/condition.cpp:304:26: note: in instantiation of member function 'conditional_t<mission_goal_condition_context>::conditional_t' requested here
        conditional_t<T> sub_condition( con_obj );
                         ^
src/condition.h:138:28: note: passing argument to parameter 'd' here
    int evaluate( const T &d ) const {
                           ^
2 errors generated.

Describe the solution

Fix the errors above. Additionally changed NPC death check.

Describe alternatives you've considered

Invent something with d.actor, but this is not required, because in dialogue in avatar_death() , the avatar is always alpha.

Testing

The project can build and execute successfully. Checked in game the function of continuing the game after the avatar death - everything works as intended, including outside the bubble of reality. Additional tests are welcome. Especially from the creator of the original PR @perryprog.

Additional context

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Jun 2, 2022
@perryprog
Copy link
Contributor

Ha—looks like this got through due to #57983 being merged after I wrote that PR. This should probably be merged quickly, so I'll see if there's any edge-cases that come up again due to the implementation changes later. Thanks for fixing this!

@Maleclypse Maleclypse added the (P2 - High) High priority (for ex. important bugfixes) label Jun 2, 2022
@dseguin dseguin merged commit f841d7b into CleverRaven:master Jun 2, 2022
@c8060da c8060da deleted the fix-set_npc_allies_global branch June 2, 2022 16:51
@perryprog
Copy link
Contributor

@c8060da, I am able to recreate one interesting issue that I originally had—this is what I added the Note: it seems that the is_npc check [...] comment about, though I'm not sure that solution ever really worked.

My best set of steps to reproduce is like this, though it's possibly able to done simpler:

  1. Have at least two NPC followers.
    • I recommend duplicating a save where you have a few followers for quicker testing purposes.
    • It's okay if the character you're in was previously an NPC that you now control.
    • Make a note of this character's name.
  2. Move out of the reality bubble of the two NPC followers and die.
  3. Choose one of the other followers.
    • Make a note of the name that you did not choose.
  4. Move out of the reality bubble and die.
    • It seems you can also stay with the (truly) alive NPC for this step.
  5. You should get an option between the noted names in step 1 and 4. Choose the name from step 1.
  6. You immediately die.

However, if you go to where the NPC from step 1 died before step 4, you'll actually see that character die ("John Doe dies!"). At this point, you can die and you won't get the option to choose the now really-really dead John Doe.

bombasticSlacks pushed a commit to bombasticSlacks/Cataclysm-DDA that referenced this pull request Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions (P2 - High) High priority (for ex. important bugfixes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants