Aller au contenu

Messages recommandés

  • Team
Posté(e)

Voilà le problème, l'attribut serialized_pb a été placé dans une autre ligne ce qui provoque le problème.

Màj: Il y a aussi un problème d'encodage dans le fichier généré par uncompyle.

 

creator_uuid fait partie de la classe TrayMetaData, malheureusement elle est manquante dans ton fichier. 🙁

 

Merci pour l'info sur uncompyle.

 

@Thesam1798 j'ai mis à jour le correctif et ça semble fonctionner maintenant.

Posté(e) (modifié)

Petit outil en JAVA pour unzip le generated.zip décompiler les .pyc en .py, puis convertire les .py en .proto


Prérequis : 
- Java supérieur ou égal a 1.8
- .Net supérieur ou égal a 4.6.1
- Python supérieur a 3.3

 

Le logiciel détermine automatiquement si tout est installer, il comporte aussi uncompyle6 et PB2Decompiler.

 

 PyDecompileZip.exe

Git https://github.com/Thesam1798/PyDecompileDir

Taille: 9483373 octets (9261 KiB)
CRC32: 6D263442
CRC64: B41EC21E1D737122
SHA256: EDD6902D0F6B565D5DCC0761816F71FE7E0385837571B51720CAC293E97667F4
SHA1: 6FE6308B1C47F71F4D736B352D3F5F677CEA1EEF

Modifié par Thesam1798
  • Like 1
  • 2 ans après...
Posté(e)
On 12/7/2018 at 5:17 PM, deevo said:

TrayItems are just a Google ProtoBuffer stream wrapped in another stream.

Bytes 0-3 indicate the type of the file. (Must be used on the server side)
Bytes 4-7 indicate the size of the ProtoBuffer stream.
Remaining bytes are the protobuffer stream itself.

 

 

I have a question about this. You say that a trayitem is just one stream wrapped in another. Do you know on the python side what the base class of these is? For example there is Fileserialization_pb2, Sims_pb2, but from a python standpoint, none of these are callable so cannot be made objects. However, from Fileserialization you can make for instance a SimData object. However, it's not clear exactly how you pass the bytes/binary trayfile or householdbinary to a ParseFromString call.

 

Im also unclear how the hhi files factor into it. I'm mainly interested in getting households out of tray files from the python side.

 

I've spent about 12 hours on this issue so far and hit a brick wall, so I'd appreciate if you had any insights into it.

  • Team
Posté(e)

Hello @CarlsGuide,
 

The base classes your are looking for are Exchange_pb2.TrayMetadata (trayitem) and Sims_pb2.FamilyData (householdbinary).
I don't known for sure if there is a direct wrapper for the files on the python side, but you can create one with the instructions you found.

 

TrayItem only contains the essential parts, while HouseholdBinary contains all the details about the household.

 


TrayItem File:
Bytes 0-3 type of file.

Bytes 4-7 size of the protobuffer stream.
Remaining bytes are the protobuffer stream.

 

Reading:
Import Exchange_pb2 then use the class TrayMetadata to read the protobuffer stream stored in the TrayItem file.

Household data are stored in TrayMetadata.metadata.hh_metadata.

Example (I'm not a python developer so this might not work as is, but you should get the idea 😉😞

import protocolbuffers.Exchange_pb2 as Exchange_pd2
import sys

# Read TrayItem
f = open(file, "rb")
trayitem_type = int.from_bytes(f.read(4)) # read[0-3]
stream_size = int.from_bytes(f.read(4))   # read[4-7]

# Read TrayMetadata stored inside the protobuffer stream
traymetadata = Exchange_pb2.TrayMetadata()

traymetadata.ParseFromString(f.read(stream_size)) # read the remaining bytes as message
f.close()

# Read Sims
if traymetadata.HasField('metadata'):
  if traymetadata.metadata.HasField('hh_metadata'):
    for sim in traymetadata.metadata.hh_metadata.sim_data:
      print "First name: ", sim.first_name
      print "Last name: ", sim.last_name

You can find more info here: https://developers.google.com/protocol-buffers/docs/pythontutorial#reading-a-message

 

 

HouseholdBinary File

Bytes 0-3 type of file.

Bytes 4-7 size of the protobuffer stream.
Remaining bytes are the protobuffer stream.

 

Reading:
Import Sims_pb2 then use the class FamilyData to read the protobuffer stream stored in the file.

 

 

HHI Files

The .hhi files are the household thumbnails.

Format: 0x{[0-5]hash}{[6-7]portrait_size}!0x{[0-15]hh_id}.hhi or 0x00000000!0x0000000000000000.hhi

Since I don't know the code used to generate the hash, that makes them a bit harder to locate.
If you find it, please let me know 😜

 

 

SGI Files

The .sgi files are the sim thumbnails.

Format: 0x{[0-7]portrait_size}!0x{[0-15]sim_id}.hhi or 0x00000000!0x0000000000000000.sgi

 

 

I hope this will be enough to get you started! 😜

  • Bravo ! 1
Posté(e)

MORE than enough, it helped immensely and I successfully pulled a Sim from the tray into live mode. For anyone who ends up here in the future, here's a good hint to help you finish - you will absolutely need the stream_size as proposed by deevo. You can get it using the int.from_bytes method. 

 

I really appreciate the help. It was bugging me so much. I ran into issues because I had no knowledge of how python treats files so did not realize you need to seek to a certain spot in the f.read function. This was a great learning exercise from start to finish. 

 

Also if someone is using the decompile_all that floats around that is older, if you want to get at these files easily when you decompile Sims 4's python add this to decompile all if it is not there, so you can get the protobuf files:

gameplay_folder_game = os.path.join(game_folder, 'Game', 'Bin', 'Python')

 

  • Merci ! 1
  • 3 mois après...
Posté(e)

Thank you for your great work. I was wondering if you had any advice. My goal is to convert the tray information for a saved building into a text format e.g. json or xml. Ideally so that I can get the description of a sims building so that I can reconstruct it using exported assets and render it in blender. I am aware of a ninja ripper route to get the rendered mesh but ideally would like to be able to keep the structure. Eventually it would be great to be able to compile tray data directly from the json/xml so that I could create procedural buildings. Does this sound like it would be possible? I have looked through the exchange proto but it doesn't seem to have all the information about a building just the lot and description. Any advice would be great. 

  • Team
Posté(e)

Hello @JohnB,
This will require a lot more work than for sims, the information is stored in the .blueprint files and even I could only decrypt it partially because of the lack of information.
You can get a nice view of each objects with their positions on a map, but you will need to figure out how the building part is stored. 🤔

  • deevo a épinglé ce sujet

Rejoindre la conversation

Vous pouvez publier maintenant et vous inscrire plus tard. Si vous avez un compte, connectez-vous maintenant pour publier avec votre compte.

Invité
Répondre à ce sujet…

×   Collé en tant que texte enrichi.   Coller en tant que texte brut à la place

  Seulement 75 émoticônes maximum sont autorisées.

×   Votre lien a été automatiquement intégré.   Afficher plutôt comme un lien

×   Votre contenu précédent a été rétabli.   Vider l’éditeur

×   Vous ne pouvez pas directement coller des images. Envoyez-les depuis votre ordinateur ou insérez-les depuis une URL.




×
×
  • Créer...

Information importante

Nous avons placé des cookies sur votre appareil pour aider à améliorer ce site. Vous pouvez choisir d’ajuster vos paramètres de cookie, sinon nous supposerons que vous êtes d’accord pour continuer. Conditions d’utilisation Politique de confidentialité