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

Rewrite trap loading to use generic_factory #20683

Merged
merged 2 commits into from Apr 2, 2017

Conversation

Projects
None yet
2 participants
@Coolthulhu
Copy link
Contributor

commented Mar 26, 2017

Should fix http://smf.cataclysmdda.com/index.php?topic=14294.0
I can't tell for sure because the bug is most likely related to vector location and thus compiler dependent, mod dependent and even runtime memory dependent.

The trap loading code was unusual and possibly fragile. It might lead to a situation where string and int ids do not match, which would explain the issue in the linked forum thread.

Using generic_factory ensures that even if it is wrong, it is consistently wrong and only needs to be fixed in one place.
Also minor cleanup:

  • Using std::function instead of function pointers
  • trapfunc becomes a namespace (was struct)
  • Changed the trap_function_from_string from an if stack to an unordered map (saves lines, improves readability)

Coolthulhu added some commits Mar 26, 2017

@kevingranade kevingranade merged commit 8fa04f3 into CleverRaven:master Apr 2, 2017

1 check passed

default
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.