Skip to content

Commit

Permalink
Replace some patterns in JSON schema with enums. Fix parsing attenuat…
Browse files Browse the repository at this point in the history
…ion from string
  • Loading branch information
FreeSlave committed Oct 18, 2024
1 parent 1cf193c commit ad54d81
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dlls/soundscripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static const char* ChannelToString(int channel)

static bool ParseAttenuation(const char* str, float& attenuation)
{
constexpr std::pair<const char*, int> attenuations[] = {
constexpr std::pair<const char*, float> attenuations[] = {
{"norm", ATTN_NORM},
{"idle", ATTN_IDLE},
{"static", ATTN_STATIC},
Expand Down
6 changes: 3 additions & 3 deletions game_shared/json_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ constexpr const char definitions[] = R"(
},
"channel": {
"type": "string",
"pattern": "^auto|weapon|voice|item|body|static$"
"enum": ["Auto","auto","Weapon","weapon","Voice","voice","Item","item","Body","body","Static","static"]
},
"volume": {
"$ref": "#/range"
},
"attenuation": {
"type": ["number", "string"],
"minimum": 0,
"pattern": "^norm|idle|static|none$"
"enum": ["Norm","norm","Idle","idle","Static","static","None","none"]
},
"pitch": {
"$ref": "#/range_int"
Expand All @@ -109,7 +109,7 @@ constexpr const char definitions[] = R"(
},
"rendermode": {
"type": "string",
"pattern": ["Normal","normal","Color","color","Texture","texture","Glow","glow","Solid","solid","Additive","additive$"]
"pattern": ["Normal","normal","Color","color","Texture","texture","Glow","glow","Solid","solid","Additive","additive"]
},
"color": {
"$ref": "definitions.json#/color"
Expand Down

0 comments on commit ad54d81

Please sign in to comment.