Skip to content

Commit

Permalink
Port performance improvements to bodytemp calculations
Browse files Browse the repository at this point in the history
Merge pull request CleverRaven#50739 from anothersimulacrum/materials_windresist

JSONize material wind resistance
  • Loading branch information
kevingranade authored and Coolthulhu committed Sep 14, 2021
1 parent 55cbaec commit 4ab5bd6
Show file tree
Hide file tree
Showing 14 changed files with 374 additions and 127 deletions.
6 changes: 6 additions & 0 deletions data/json/materials.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"fire_resist": 1,
"elec_resist": 2,
"chip_resist": 8,
"wind_resist": 90,
"repaired_with": "bone",
"salvaged_into": "skewer_bone",
"dmg_adj": [ "scratched", "cut", "cracked", "shattered" ],
Expand Down Expand Up @@ -241,6 +242,7 @@
"fire_resist": 2,
"elec_resist": 2,
"chip_resist": 10,
"wind_resist": 90,
"repaired_with": "chitin_piece",
"salvaged_into": "chitin_piece",
"dmg_adj": [ "scratched", "cut", "cracked", "shattered" ],
Expand Down Expand Up @@ -812,6 +814,7 @@
"fire_resist": 2,
"elec_resist": 2,
"chip_resist": 10,
"wind_resist": 90,
"repaired_with": "leather",
"salvaged_into": "leather",
"dmg_adj": [ "scratched", "cut", "shredded", "tattered" ],
Expand Down Expand Up @@ -919,6 +922,7 @@
"fire_resist": 20,
"elec_resist": 4,
"chip_resist": 8,
"wind_resist": 90,
"repaired_with": "nomex",
"salvaged_into": "nomex",
"dmg_adj": [ "ripped", "torn", "shredded", "tattered" ],
Expand Down Expand Up @@ -1025,6 +1029,7 @@
"fire_resist": 1,
"elec_resist": 2,
"chip_resist": 6,
"wind_resist": 90,
"repaired_with": "plastic_chunk",
"salvaged_into": "plastic_chunk",
"dmg_adj": [ "scratched", "cut", "cracked", "shattered" ],
Expand Down Expand Up @@ -1544,6 +1549,7 @@
"elec_resist": 2,
"chip_resist": 6,
"warmth_when_wet": 0.5,
"wind_resist": 60,
"repaired_with": "felt_patch",
"salvaged_into": "felt_patch",
"dmg_adj": [ "ripped", "torn", "shredded", "tattered" ],
Expand Down
1 change: 1 addition & 0 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ When you sort your inventory by category, these are the categories that are disp
| `dmg_adj` | Adjectives used to describe damage states of a material.
| `density` | Density of a material.
| `vitamins` | Vitamins in a material. Usually overridden by item specific values.
| `wind_resist` | Percentage 0-100. How effective this material is at stopping wind from getting through. Higher values are better. If none of the materials an item is made of specify a value, a default of 99 is assumed.
| `warmth_when_wet` | Percentage of warmth retained when fully drenched. Default is 0.2.
| `specific_heat_liquid` | Specific heat of a material when not frozen (J/(g K)). Default 4.186.
| `specific_heat_solid` | Specific heat of a material when frozen (J/(g K)). Default 2.108.
Expand Down
13 changes: 13 additions & 0 deletions src/bodypart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@
#include "pldata.h"
#include "type_id.h"

const bodypart_str_id body_part_head( "head" );
const bodypart_str_id body_part_eyes( "eyes" );
const bodypart_str_id body_part_mouth( "mouth" );
const bodypart_str_id body_part_torso( "torso" );
const bodypart_str_id body_part_arm_l( "arm_l" );
const bodypart_str_id body_part_arm_r( "arm_r" );
const bodypart_str_id body_part_hand_l( "hand_l" );
const bodypart_str_id body_part_hand_r( "hand_r" );
const bodypart_str_id body_part_leg_l( "leg_l" );
const bodypart_str_id body_part_foot_l( "foot_l" );
const bodypart_str_id body_part_leg_r( "leg_r" );
const bodypart_str_id body_part_foot_r( "foot_r" );

side opposite_side( side s )
{
switch( s ) {
Expand Down
22 changes: 17 additions & 5 deletions src/bodypart.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,26 @@
class JsonObject;
class JsonIn;
class JsonOut;
struct body_part_type;

template <typename E> struct enum_traits;

using bodypart_str_id = string_id<body_part_type>;
using bodypart_id = int_id<body_part_type>;

extern const bodypart_str_id body_part_head;
extern const bodypart_str_id body_part_eyes;
extern const bodypart_str_id body_part_mouth;
extern const bodypart_str_id body_part_torso;
extern const bodypart_str_id body_part_arm_l;
extern const bodypart_str_id body_part_arm_r;
extern const bodypart_str_id body_part_hand_l;
extern const bodypart_str_id body_part_hand_r;
extern const bodypart_str_id body_part_leg_l;
extern const bodypart_str_id body_part_foot_l;
extern const bodypart_str_id body_part_leg_r;
extern const bodypart_str_id body_part_foot_r;

// The order is important ; pldata.h has to be in the same order
enum body_part : int {
bp_torso = 0,
Expand Down Expand Up @@ -69,11 +86,6 @@ constexpr std::array<body_part, 12> all_body_parts = {{
}
};

struct body_part_type;

using bodypart_str_id = string_id<body_part_type>;
using bodypart_id = int_id<body_part_type>;

struct body_part_type {
public:
bodypart_str_id id;
Expand Down
Loading

0 comments on commit 4ab5bd6

Please sign in to comment.