-
Notifications
You must be signed in to change notification settings - Fork 149
feat(scriptcompiler): add SCB to JSON conversion tool #1977
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
feat(scriptcompiler): add SCB to JSON conversion tool #1977
Conversation
5d53a71 to
ebe3cd5
Compare
Skyaero42
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats the purpose of this conversion tool? When would somebody use it?
It feels very AI-ish, barely any comments and large methods with hundreds of lines of code.
| { | ||
| initMemoryManager(); | ||
|
|
||
| const char* gameDir = "C:\\Program Files\\EA Games\\Command and Conquer Generals Zero Hour\\Command and Conquer Generals Zero Hour"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded gamedir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Updated to use our registry lookup, also added the gamedir as an optional command line arg
| return true; | ||
| } | ||
|
|
||
| int main(int argc, char* argv[]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lacking any comments on how to use this tool and what it does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add comments. I generally get asked to remove them, overcompensated this time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a couple of comments, can add more where helpful
"This will allow us to edit and revision AI scripts in plain text." And yes, I very much used Claude on this one, particularly when going from having round trip go from "This is logically the same" to "This is byte for byte identical." Also getting the initial build to compile (needed to include/stub a lot of stuff to keep it living in the game code), and getting it to run without issue (needed to use the debugger and step line by line to find issues). There was a lot of "here's the diff output, explain the likely causes and propose 3 fixes explaining the tradeoffs of each" over and over - it's a grind for sure, but manually getting byte for byte would have taken forever. My goal was to get the tool to work first, which it does, provably so. From here, I'm happy to refactor and improve it however is best. |
223f08b to
5b4a27f
Compare
fe39a9e to
e364ebe
Compare
6a25b9b to
2fdf9ce
Compare
|
Here is the standalone version https://github.com/bobtista/GeneralsGameCode/pull/new/bobtista/data-chunk-json-converter-standalone which I know is not the direction we're going in, but it works and may be useful some day. I'm also thinking we can get 100% automatic syncing on changes (those that wouldn't break existing scbs anyway), by combining the binary and json conversions with templating. We should also be able to get the names instead of numbers when there's mapping in the code, while still keeping things synced. For the key names though, this mapping doesn't exist yet. The binary writer just outputs their values, but we could make the JSON way more readable if we add the field name. We'd make a one time change like Right now we have ~25 of them, and this would be a one time change - in the future if we for some reason add another, we'd just add another line like this with the name as a param. This just makes the json output more human readable. |
be48b3b to
5418a61
Compare
…aram types, and booleans
Add writeEnumAsInt() method to ChunkOutputStream interface that writes int values to binary but string names to JSON _items array. Enum types converted: - COMPARISON: LESS_THAN, LESS_EQUAL, EQUAL, GREATER_EQUAL, GREATER, NOT_EQUAL - RELATION: ENEMIES, NEUTRAL, ALLIES - AI_MOOD: SLEEP, PASSIVE, NORMAL, ALERT, AGGRESSIVE - RADAR_EVENT_TYPE: INVALID, CONSTRUCTION, UPGRADE, etc. - BUILDABLE: Yes, Only_AI, No, Ignore_Prerequisites - SURFACES_ALLOWED: LAND, WATER, CLIFF - SHAKE_INTENSITY: SUBTLE, NORMAL, STRONG, SEVERE, EXTREME - LEFT_OR_RIGHT: LEFT, RIGHT Roundtrip tested: SCB -> JSON -> SCB produces byte-identical output. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Ok, here's the latest - this is all 100% byte identical round trip, and inherits any changes automatically from the game. The json output is pretty readable for anyone familiar with scripting - would love feedback at this point, can share the json of skirmish or multiplayer scb files. Script: "USA Base Expansion Check"
Conditions (OrCondition groups are OR'd, multiple groups are AND'd): "condition": "PLAYER_HAS_CREDITS" "condition": "PLAYER_HAS_OBJECT_COMPARISON" "condition": "COUNTER" Actions (when conditions pass): "action": "ENABLE_SCRIPT" "action": "SET_MILLISECOND_TIMER" "action": "CALL_SUBROUTINE" An actual snippet of the json for example: |
|
made an MVP, going to use it and iterate and add QOL improvements based on feedback, but it's another large change - will close this for now and make a new one later |
Adds JSON chunk format support for converting SCB <->JSON. This implementation integrates directly into the game engine's existing DataChunk system rather than being a standalone tool.
Tested round trip for GeneralsMD on SkirmishScripts.scb and MultiplayerScripts.scb, byte for byte identical
TODO:
[ ] Replicate to Generals