- Site Map >
- Modding and Creation >
- Sims 4 Creation >
- Modding Tools >
- Source code decompiler (with code reformatting)
- Site Map >
- Modding and Creation >
- Sims 4 Creation >
- Modding Tools >
- Source code decompiler (with code reformatting)
Replies: 2 (Who?), Viewed: 9153 times.
#1
8th Apr 2015 at 7:13 PM
Last edited by Aren : 21st Apr 2015 at 6:25 AM.
Posts: 47
Thanks: 1429 in 46 Posts
Source code decompiler (with code reformatting)
This is yet another source code decompiler for The Sims 4. Essentially you just set up some variables in a batch file once, and every subsequent run will automatically decompile the source code to the folder you specified.This script includes TheHologramMan's modified version of unpyc3.py to do the actual decompiling. In addition, I've included a script to automatically reformat the code to make it easier to read. It uses PythonTidy to do this, but unfortunately it hasn't been updated for Python 3. I haven't found any other alternatives that do as good a job as PythonTidy, so you'll need to install Python 2.7 to run it. It doesn't reformat everything; code specific to Python 3 causes it to break, so it just reformats the parts that need it most, like the Tunable descriptions. I may look in to writing my own script to reformat strings without needing Python 2.7, but no promises.
To demonstrate the code reformatting, here's a sample of the source code before and after the reformatting is applied.
Before:
Code:
class FamilyRelationshipTuning: __qualname__ = 'FamilyRelationshipTuning' MATRIX = TunableList(TunableList(TunableReference(services.get_instance_manager(Types.RELATIONSHIP_BIT))), description="\n This matrix is mirrored in RelationshipHelper.cpp in CAS Systems code.\n Please discuss with a GPE and CAS engineer if you wish to update\n this tuning.\n \n Sim Y's ancestry depth ----> \n +-------------+-------------+-------------+\n | | | |\n | Spouse | Parent | Grandparent | Sim X's \n | | | | ancestry\n +-------------+-------------+-------------+ depth\n | | | | |\n | Child | Sibling | Uncle/Aunt | |\n | | | | |\n +-------------+-------------+-------------+ V \n | | | |\n | Grandchild | Nephew | Cousin |\n | | | |\n +-------------+-------------+-------------+\n ")
After:
Code:
class FamilyRelationshipTuning: __qualname__ = 'FamilyRelationshipTuning' MATRIX = \ TunableList(TunableList(TunableReference(services.get_instance_manager(Types.RELATIONSHIP_BIT))), description=""" This matrix is mirrored in RelationshipHelper.cpp in CAS Systems code. Please discuss with a GPE and CAS engineer if you wish to update this tuning. Sim Y's ancestry depth ----> +-------------+-------------+-------------+ | | | | | Spouse | Parent | Grandparent | Sim X's | | | | ancestry +-------------+-------------+-------------+ depth | | | | | | Child | Sibling | Uncle/Aunt | | | | | | | +-------------+-------------+-------------+ V | | | | | Grandchild | Nephew | Cousin | | | | | +-------------+-------------+-------------+ """)
How to use
You'll need to install both Python 3.3 and Python 2.7.
At the time of writing, the latest version of 2.7 can be found here: https://www.python.org/downloads/release/python-279/. The latest version of 3.3 can be found here: https://www.python.org/downloads/release/python-335/
Download the attached code and unzip it, then open decompile.bat in your favorite text editor.
Now you'll need to set a few variables.
Change the first line to set the path where you want the decompiled source code to be extracted. Make sure you put this path between the quotation marks.
Change the second line to set the path where your Sims 4 game is installed. On my computer, this is "C:\Program Files (x86)\Origin Games\The Sims 4", but it may be different for you.
If you installed Python on your C drive in the default location, you shouldn't need to modify the next two lines. But just to be safe, make sure the default paths are correct and make any needed changes.
You should now be able to double-click decompile.bat, and if all goes well the source code should be extracted. Let me know if you have any problems getting this to work.
Attached files:
decompile.zip (118.8 KB, 360 downloads) - View custom content | ||
0 04-08-2015 12:55 decompile/ 276 04-09-2015 10:19 decompile/decompile.bat 0 04-09-2015 10:19 decompile/resources/ 1698 04-09-2015 10:17 decompile/resources/decompile.py 1440 04-11-2015 13:36 decompile/resources/extract_sources.py 151887 04-09-2015 10:17 decompile/resources/PythonTidy.py 167235 04-09-2015 10:19 decompile/resources/PythonTidy.pyc 2720 04-09-2015 10:17 decompile/resources/reformat.py 759 04-09-2015 10:17 decompile/resources/start.py 64255 04-21-2015 00:14 decompile/resources/unpyc3.py 0 04-09-2015 10:18 decompile/resources/__pycache__/ 2790 04-09-2015 10:18 decompile/resources/__pycache__/decompile.cpython-33.pyc 2318 04-09-2015 10:18 decompile/resources/__pycache__/extract_sources.cpython-33.pyc 156585 04-09-2015 10:18 decompile/resources/__pycache__/unpyc3.cpython-33.pyc --------- ------- 551963 14 files |
1 users say thanks for this.
(Who?)
Thanks
Advertisement
#2
11th Apr 2015 at 8:35 PM
Posts: 47
Thanks: 1429 in 46 Posts
I fixed an issue with the zip extraction code doubling up the folder names (e.g. exporting files to /interactions/interactions instead of just /interactions), so redownload if that was affecting you.
#3
21st Apr 2015 at 6:28 AM
Posts: 47
Thanks: 1429 in 46 Posts
Updated unpyc3 with a fix so it can (hopefully) decompile any files it wasn't able to before, such as core/sims4/tuning/tunable.py. There are still parts of the code that it can't decompile, but now it'll just skip over those parts and decompile the rest, instead of completely failing. Thanks to Scumbumbo for bringing up the error with tunable.py.
Who Posted
|