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

Implement battery item type #32141

Merged
merged 19 commits into from
Jul 15, 2019
Merged

Implement battery item type #32141

merged 19 commits into from
Jul 15, 2019

Conversation

ymber
Copy link
Member

@ymber ymber commented Jul 5, 2019

Summary

SUMMARY: Infrastructure "Implement new item type for batteries"

Purpose of change

#32067

Describe the solution

  • Allow loading units::energy from json
  • Implement BATTERY item type
  • Allow recharging BATTERY type batteries
  • Update item::info for battery islot data
  • Support saving and loading current battery charge
  • Document new JSON

@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Items: Battery / UPS Electric power management labels Jul 5, 2019
src/item.cpp Outdated Show resolved Hide resolved
src/item.cpp Outdated Show resolved Hide resolved
src/item_factory.cpp Outdated Show resolved Hide resolved
src/itype.h Outdated Show resolved Hide resolved
@ymber ymber force-pushed the battery branch 2 times, most recently from fe35cfc to 82f95a5 Compare July 6, 2019 14:52
Copy link
Contributor

@ifreund ifreund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great, will be super nice to have everything using proper energy units in the code.

src/item.cpp Show resolved Hide resolved
src/item.h Outdated Show resolved Hide resolved
src/item.h Outdated Show resolved Hide resolved
@ymber ymber force-pushed the battery branch 2 times, most recently from 2e877c9 to 967cf30 Compare July 7, 2019 20:57
@ifreund
Copy link
Contributor

ifreund commented Jul 7, 2019

Not sure if you saw this already, but travis is failing because of an actual problem compiling on gcc 5.3

src/savegame_json.cpp:1926:47: error: specialization of ‘template<class V, class U> void units::quantity<V, U>::deserialize(JsonIn&)’ in different namespace [-fpermissive]
 void units::energy::deserialize( JsonIn &jsin )
                                               ^
In file included from src/cata_utility.h:13:0,
                 from src/player.h:20,
                 from src/avatar.h:12,
                 from src/savegame_json.cpp:29:
src/units.h:134:14: error:   from definition of ‘template<class V, class U> void units::quantity<V, U>::deserialize(JsonIn&)’ [-fpermissive]
         void deserialize( JsonIn &jsin );
              ^

@ifreund ifreund added the Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style label Jul 7, 2019
@ymber
Copy link
Member Author

ymber commented Jul 8, 2019

I saw it but I didn't know how I ought to handle it because it's a compiler bug. It got fixed in GCC 7.0. How far back do we need to support old compilers?
GCC bug 56480

@kevingranade
Copy link
Member

See https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/COMPILER_SUPPORT.md
Not at all coincidentally, the minimum compiler version we test in Travis is the minimum complier version we support.

@kevingranade
Copy link
Member

Can you simply define the specialization in the namespace? I.e. wrap lines 1925-1929 in namespace units {}?

@kevingranade kevingranade merged commit 4a20bfe into CleverRaven:master Jul 15, 2019
@ymber ymber deleted the battery branch July 15, 2019 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Items: Battery / UPS Electric power management [JSON] Changes (can be) made in JSON
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants