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

Added support for more unquoted characters and inline empty blocks #22

Merged
merged 12 commits into from
Jan 18, 2021

Conversation

lasa01
Copy link
Contributor

@lasa01 lasa01 commented Sep 7, 2019

CSGO has material (.vmt) files that have unquoted keys starting with $.

For example, csgo/materials/grass/hr_grass/grass_a.vmt:

LightmappedGeneric
{
$baseTexture "grass/hr_grass/grass_a"
$bumpmap "grass/hr_grass/grass_a_normals"

}

This fixes the parsing of these files.

Copy link
Contributor

@rossengeorgiev rossengeorgiev left a comment

Choose a reason for hiding this comment

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

This PR will certainly resolve that specific case, but its probably best to add $ as part of the character class. We also need unit tests for this.

@lasa01 lasa01 changed the title Added support for unquoted keys starting with $ Added support for more unquoted characters and inline empty blocks Feb 3, 2020
@lasa01
Copy link
Contributor Author

lasa01 commented Feb 3, 2020

Moved the changes to the character set and updated the weird unquoted character test case.

Also extended support for other missing characters in unquoted keys and values:

  • % in keys (e.g. csgo\materials\detail\detailsprites_overgrown_massive9.vmt)
  • single / in values (comments still work) (e.g. csgo\materials\liquids\canalswater_cheap.vmt)
  • $ in values (e.g. csgo\materials\models\error\new light1.vmt)
  • < > in keys and values (e.g. csgo\materials\particle\fire_burning_character\fire_molotov.vmt, csgo\materials\trash\hr_t\hr_trash_a.vmt)

Also added support for inline empty blocks directly after keys, and a corresponding test case, e.g.:

		"Proxies"
		{
			"EntityOrigin" {}
		}

(csgo\materials\models\player\custom_player\econ\head\ctm_fbi\ctm_fbi_v2_head_varianta.vmt)

For example, file "csgo\materials\models\props_c17\furniturewooddresser001a.vmt" has these.
Copy link
Contributor

@rossengeorgiev rossengeorgiev left a comment

Choose a reason for hiding this comment

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

This looks really good. Happy to merge after the comments are addressed.

It would be interesting to see how much of these testcases are covered: https://github.com/SteamDatabase/ValveKeyValue/tree/master/ValveKeyValue/ValveKeyValue.Test/Test%20Data/Text

vdf/__init__.py Show resolved Hide resolved
vdf/__init__.py Outdated Show resolved Hide resolved
@ValvePython ValvePython deleted a comment from sonarcloud bot Dec 17, 2020
@rossengeorgiev rossengeorgiev merged commit 3b9435c into ValvePython:master Jan 18, 2021
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.

None yet

2 participants