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

Update latest codes. #5

Merged
merged 178 commits into from
Aug 24, 2019
Merged

Conversation

RedShakespeare
Copy link
Owner

As above.

Hymore246 and others added 30 commits August 15, 2019 16:27
I encountered an issue where I could not create a woodchip floor, in an empty shallow pit.

I removed the precondition that required it to be empty, and now I can create woodchip floors just fine.

I looked at the definition for the empty precondition and it needs the square to be flat and have no furniture, which I'm unsure a shallow pit would count as.

I think the spirit of the empty precondition was that there should be no items but it also precluded shallow pits, perhaps there should be another check?

Also it seems quite possible this bug applies in other cases in this file, I haven't investigated yet.
There's no point having else immediately followed
by and if/else block. Simply merged that if/else
block into the else above.
Add a new class character_id, which is just a simple wrapper around int
for type-safety purposes.

No semantic change intended.
The previous solution had two function templates which had to be
specialized for every enum (one for conversion in each direction).

Typically, they were implemented by having a global static map from
strings to enum values which was used for lookup in one direction.
Conversion in the other direction (enum -> string) was either not
implemented or used a slow linear search through the map.

Change this to a new approach where only enum_to_string needs to be
specialized, and string_to_enum is automatically synthesized from it.

The advantages of this approach are:
- enum_to_string should be much more efficient.
- enum_to_string can be implemented via a switch statement, which means
  the compiler will automatically let you know to update it when a new
  enum value is added to any enum.
- No need to implement string_to_enum.  Consistency between the
  conversions in each direction happens automatically.
- We get some additional error checking for free; if any two enum values
  map to the same string that will be reported (which could easily
  happen through a copy/paste error).
- If we ever want to switch to a more performant hashtable
  implementation, we only need to change the code in one place.

The disadvantages are:
- A little more code in headers.
- Every string_to_enum contains a const static, so there needs to be a
  check that it's initialized on every call.  But this should be cheap
  compared to an unordered_map lookup.

To implement this I took advantage of the enum_traits originally added
for enum_bitset.  Every enum supporting such conversion now needs a
'last' member and an enum_traits specialization for the code to know
which member this is (many of them already had such members).

So, as a happy side-effect, all these enums will now work with
enum_bitset without further changes.

I used astyle markup around the big switch statements to get one case
per line; I find this much easier to read and see at a glance that the
values match in a reasonable way.
No need to write a lambda when we already have a perfectly good
function.
Fixes #33348 and corrects being able to unload frozen liquids from
watertight containers
Moved `outdoor_blizzard` closer to other `outdoor` sounds.
Added missing check for "Outdoor blizzard" in `sfx::do_ambient`.
Added check "is channel playing" inside of `play_ambient_variant_sound`. May not be necessary, leads to double checks. Just to be sure?
Fixed playing `radio`/`chatter` as `play_ambient_variant_sound`.
Co-Authored-By: anothersimulacrum <anothersimulacrum@gmail.com>
Co-Authored-By: anothersimulacrum <anothersimulacrum@gmail.com>
Co-Authored-By: anothersimulacrum <anothersimulacrum@gmail.com>
Co-Authored-By: anothersimulacrum <anothersimulacrum@gmail.com>
Enable this clang-tidy check and fix the issues it raises.
ZhilkinSerg and others added 26 commits August 22, 2019 19:54
…s-not-consume-glass-sheet

Consume the sheet of glass when placing a glass shards trap
)

* More Philosophy is needed

So I added it.

* Fixed Periods

* Update data/json/items/book/misc.json

Co-Authored-By: anothersimulacrum <anothersimulacrum@gmail.com>
* pull origin and update

* add script used to tools/json_tools

* Update data/json/items/armor.json

Co-Authored-By: anothersimulacrum <anothersimulacrum@gmail.com>

* Update data/json/items/armor.json

Co-Authored-By: anothersimulacrum <anothersimulacrum@gmail.com>

* Update data/json/items/armor.json

Co-Authored-By: anothersimulacrum <anothersimulacrum@gmail.com>

* Update data/json/items/armor.json

Co-Authored-By: anothersimulacrum <anothersimulacrum@gmail.com>

* formatting in cddaUpdateJsonVolume.js

* change tool to not update volume 0

* do not update volume 0

* don't update volume 0

* reapply anothersimulacrums suggestions

* add other volume values to script

* run script again and update files

* update 'storage' to metric

* update tool
* stop regeneration of moves instead of resetting on dismount
The moddified mini-nuke was using a literal ton of rocket fuel before. This change lowers the cost to match the 40 tile "range" of the launcher.
* small refactor to make Creature::get_pain_description returns a label/color pair just like get_hunger_description and get_thirst_description

* show needs in the 4 comestible inventory windows using the inventory_selector's hint line
* Add u_buy_monster talk effect

* Update u_buy_monster name to be translatable
Fix bug where player could not create woodchip floors
…capacity does not (always) work #33473"

The volume does not matter if the character can wield the item (has empty hands).
Change suggested by @ampersand55

Co-Authored-By: ampersand55 <9817636+ampersand55@users.noreply.github.com>
Routine i18n updates on 23 Aug 2019
* Adds damage numbers when it is your ridden mech that is attacking with melee
* fix missing plural

* need unconscious cyborg clarification

* Update snippets.json
Update `contains` in JSON to use volume string syntax
* Add pr validator workflow
Fixed "Activating items near character with empty hands and 0 volume capacity does not (always) work #33473"
@RedShakespeare RedShakespeare merged commit 33e8dc5 into RedShakespeare:master Aug 24, 2019
RedShakespeare pushed a commit that referenced this pull request May 10, 2020
The function `are_requirements_nearby` accesses `player::backlog::front()`, which causes UB when the `backlog` list is empty.

This is usually checked by the caller, but there is at least one way to reach this function without that check:

```
#2  0x000000000083dfaa in string_id<activity_type>::operator== (rhs=..., this=0xdf1b460) at src/player_activity.h:93
#3  are_requirements_nearby (loot_spots=std::vector of length 21, capacity 32 = {...}, needed_things=..., p=..., activity_to_restore=..., in_loot_zones=true, src_loc=...)
    at src/activity_item_handling.cpp:1113
#4  0x0000000000843a46 in generic_multi_activity_check_requirement (p=..., act_id=..., act_info=..., src=..., src_loc=...,
    src_set=std::unordered_set with 1 element = {...}, check_only=false) at src/activity_item_handling.cpp:2676
#5  0x0000000000852813 in generic_multi_activity_handler (act=..., p=..., check_only=check_only@entry=false) at src/activity_item_handling.cpp:2885
#6  0x0000000000800896 in activity_handlers::multiple_butcher_do_turn (act=<optimized out>, p=<optimized out>) at src/activity_handlers.cpp:3822
#7  0x000000000082b248 in std::_Function_handler<void (player_activity*, player*), void (*)(player_activity*, player*)>::_M_invoke(std::_Any_data const&, player_activity*&&, player*&&) (__functor=..., __args#0=<optimized out>, __args#1=<optimized out>) at /usr/include/c++/8/bits/std_function.h:88
#8  0x00000000008630e3 in std::function<void (player_activity*, player*)>::operator()(player_activity*, player*) const (this=<optimized out>, __args#0=<optimized out>,
    __args#0@entry=0xdf1b330, __args#1=<optimized out>, __args#1@entry=0xdf1ae50) at /usr/include/c++/8/bits/std_function.h:260
#9  0x0000000000860306 in activity_type::call_do_turn (this=0x2c3c930, act=act@entry=0xdf1b330, p=p@entry=0xdf1ae50) at src/activity_type.cpp:118
#10 0x00000000014a968b in player_activity::do_turn (this=this@entry=0xdf1b330, p=...) at src/player_activity.cpp:237
#11 0x00000000013092a4 in npc::do_player_activity (this=this@entry=0xdf1ae50) at src/npcmove.cpp:3299
#12 0x0000000001322a07 in npc::execute_action (this=this@entry=0xdf1ae50, action=<optimized out>, action@entry=npc_player_activity) at src/npcmove.cpp:1237
#13 0x000000000132690a in npc::move (this=this@entry=0xdf1ae50) at src/npcmove.cpp:907
```

This adds a simple check within the function.
RedShakespeare pushed a commit that referenced this pull request May 19, 2020
BrettDong pushed a commit that referenced this pull request Jan 1, 2021
As they appear in the diff:

1. I couldn't track down where the error was occurring here, so I just
   told the tileset load to ignore it. (It was loading correctly)

2. This makes it more clear why the 'additional_tiles' member is not
   visited.

3. Color loaders are loaded separately from their type member being
   loaded (but it is required elsewhere), so just visit it.

4. In initializing the JsonObjectInputArchive, a JsonObject was created
   and destroyed without visiting members. Make that explicit, and tell
   it  to ignore omitted members.

5. Support for reactor and tank _plut was removed recently, but old
   saves may still have them. Just visit them, it'll be resolved with a
   new save.

6. grab_type was only read if grab_point is valid, but it was
   unconditionally written. So read it, but don't always use it.

7. See #5

8. This member was written, but not read.

9. This member was written, but not read.

10. external options have an info string explaining what they do. Visit
    this string, even though it doesn't contain anything the game uses.
    I chose to visit it instead of commenting it out to avoid massive
    amounts of lines changed (in mods and in data/core).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.