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

Modernize more volume and weight #41721

Merged

Conversation

hexagonrecursion
Copy link
Contributor

@hexagonrecursion hexagonrecursion commented Jul 1, 2020

Summary

SUMMARY: none

Purpose of change

Contributes to #36110

Describe the solution

Convert the integral_volume and the confusingly named barrel_length to strings

Describe alternatives you've considered

none

Testing

  1. Create a new world with the following mods:
  • Disable NPC Needs
  • CRIT Expansion
  • Generic Guns
  • Magiclysm
  1. Start a new game in it
  2. Test that attaching a tactical flashlight (id: flash_acc) to Luty SMG: .40 S&W (id: smg_40) does not change the volume of the SMG
  3. Test that a sawn-off handmade magnum carbine is 0.25 L smaller than a regular one

Additional context

This PR was brought to you by

#!/usr/bin/env bash
set -eux

echo "Using JSON formatter: ${JSON_FORMATTER:=tools/format/json_formatter.cgi}"
echo

# The data/ directory is a mess:
# 1. It has a json/ subdirectory even though there is plenty of JSON
#    outside that subdirectory.
# 2. Most JSON files in data/ have a uniform structure (see example 1 below),
#    but there are exceptions - files that have a completely different structure.
# The following command collects the names of all the files that use the uniform
# structure ignoring all files that don't. It also looks in utilities/.
# Even though utilities/ does not contain any loadable data, it contains
# examples. I want to modernize the documentation too.
#
# example 1
# [
#   {"type": "foo", ...},
#   {"type": "bar", ...}
# ]
#
mapfile -t FILES < <(
	find utilities data \
		-name '*.json' \
		-not -path 'data/raw/color_templates/no_bright_background.json' \
		-not -path 'data/names/*' \
		-not -path 'data/mods/replacements.json' \
		-not -path 'data/fontdata.json' \
)

# Piping game data through jq introduces some noise because jq does not
# distinguish between 123.0 and 123. I use some git rebase magic
# to work around this issue. After running this script run:
# git rebase --onto=master modernize-volume-weight-noise modernize-volume-weight-2
git checkout -b modernize-volume-weight-noise master
for F in "${FILES[@]}"; do
	echo "noise: $F"
	jq '.' "$F" | $JSON_FORMATTER | sponge "$F"
done
git add .
git commit -m 'DO NOT MERGE'

JQ='
(
  .[]
  |
    (select(.type=="GUN") | .barrel_length),
    (select(.type=="GUNMOD") | .integral_volume)
  | numbers
) |= (./4*1000 | if .%1000 == 0 then "\(./1000) L" else "\(.) ml" end)
'
git checkout -b modernize-volume-weight-2 modernize-volume-weight-noise
for F in "${FILES[@]}"; do
	echo "$F"
	jq "$JQ" "$F" | $JSON_FORMATTER | sponge "$F"
done
git add .
git commit -m 'Modernize more volume and weight'

@hexagonrecursion hexagonrecursion marked this pull request as ready for review July 1, 2020 11:25
@mlangsdorf mlangsdorf added Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Ranged Ranged (firearms, bows, crossbows, throwing), balance, tactics labels Jul 1, 2020
@ZhilkinSerg ZhilkinSerg merged commit 623a5b1 into CleverRaven:master Jul 2, 2020
@hexagonrecursion hexagonrecursion deleted the modernize-volume-weight-2 branch July 3, 2020 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Ranged Ranged (firearms, bows, crossbows, throwing), balance, tactics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants