The Sim: Free Play

How to translate the files of a game
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

The Sim: Free Play

Post by hackspeedok »

Have any tools for this file ? Thanks for helping. :D
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: The Sim: Free Play

Post by hackspeedok »

Anyone can help ? :(
puggsoy
Posts: 161
Joined: Sat Dec 13, 2014 1:01 am

Re: The Sim: Free Play

Post by puggsoy »

I know how to make a script to extract the strings, I don't think it would support reimporting though. I could probably make a script that has separate parts for extraction and importing though, depending on whether you give it a .sb file or a .txt file.
puggsoy
Posts: 161
Joined: Sat Dec 13, 2014 1:01 am

Re: The Sim: Free Play

Post by puggsoy »

Hmm, some issues are arising. One of the strings is 0x9C0 bytes long, which first of all seems to be too large for the QuickBMS string variable. Secondly, that string is also multilined, which would break my reimporting script.

I can probably still do it but it will take a bit more time.
puggsoy
Posts: 161
Joined: Sat Dec 13, 2014 1:01 am

Re: The Sim: Free Play

Post by puggsoy »

Here it is, finally:

Code: Select all

# The Sims: FreePlay .sb file extraction and re-insertion
#
# Written by puggsoy
# script for QuickBMS http://quickbms.aluigi.org

get EXT extension

if EXT == "sb"
   callfunction SBEXTRACT
elif EXT == "txt"
   callfunction REIMPORT
endif

startfunction SBEXTRACT
   findloc CHDROFF string "CHDR"
   findloc CDATOFF string "CDAT"
   
   goto CDATOFF
   idstring "CDAT"
   get CDATSZ long
   get DUMMY long
   savepos STRINGSOFF
   
   goto CHDROFF
   idstring "CHDR"
   get CHDRSZ long
   get DUMMY long
   
   log MEMORY_FILE 0 0
   
   append
   for POS = 0 < CHDRSZ
      get OFFSET long
      get SIZE long
      math OFFSET += STRINGSOFF
      
      log MEMORY_FILE OFFSET SIZE
      
      goto 0 MEMORY_FILE SEEK_END
      put 0xFF byte MEMORY_FILE
      put 0x0D byte MEMORY_FILE
      put 0x0A byte MEMORY_FILE
      
      math POS += 8
   next
   append
   
   get MSIZE asize MEMORY_FILE
   log "sbextracted.txt" 0 MSIZE MEMORY_FILE
endfunction

startfunction REIMPORT
   open "." "sims3_deluxe_ios.sb" 1 EXISTS
   findloc CHDROFF string "CHDR" 1
   set SIZE CHDROFF
   math SIZE += 0x0C
   
   log MEMORY_FILE 0 SIZE 1
   goto 0 MEMORY_FILE SEEK_END
   
   log MEMORY_FILE2 0 0
   
   get FILESIZE asize
   set STRNUM 0
   set OFFSET 0
   
   append
   for POS = 0 < FILESIZE
      findloc DELOFF byte 255
      set SIZE DELOFF
      math SIZE -= POS
      
      put OFFSET long MEMORY_FILE
      put SIZE long MEMORY_FILE
      
      log MEMORY_FILE2 POS SIZE
      goto 0 MEMORY_FILE2 SEEK_END
      put 0x00 byte MEMORY_FILE2
      goto 0 MEMORY_FILE2 SEEK_END
      savepos OFFSET MEMORY_FILE2
      
      math DELOFF += 3
      goto DELOFF
      savepos POS
      
      math STRNUM += 1
   next
   append
   
   goto CHDROFF MEMORY_FILE
   idstring "CHDR" MEMORY_FILE
   set CHDRSZ STRNUM
   math CHDRSZ *= 8
   put CHDRSZ long MEMORY_FILE
   
   findloc CDATOFF string "CDAT" 1
   set SIZE 0x0C
   
   append
   log MEMORY_FILE CDATOFF SIZE 1
   goto 0 MEMORY_FILE SEEK_END
   
   get MSIZE asize MEMORY_FILE2
   log MEMORY_FILE 0 MSIZE MEMORY_FILE2
   append
   
   get MSIZE asize MEMORY_FILE
   log "newstrings.sb" 0 MSIZE MEMORY_FILE
endfunction

There are a number of things you need to keep in mind:

First of all, when you extract the file, it will create a .txt file containing all of the strings. Each string ends with the "ÿ" character, and then a newline. Do not remove this character (or the newline) when editing the text because it is essential for re-importing.
Secondly, to re-import the strings, choose the edited .txt file as the input file. It is also necessary that "sims3_deluxe_ios.sb" is in the output folder. It will not overwrite this file, but instead create a new file called "newstrings.sb" that contains your edited strings.

I am unable to test this with the game myself (since I don't own it), but if I extract and then re-import without changing anything, the resulting .sb file is identical to the original. So I assume that you should be able to edit strings and re-import them to mod or translate the game.
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: The Sim: Free Play

Post by hackspeedok »

puggsoy wrote:Here it is, finally:

Code: Select all

# The Sims: FreePlay .sb file extraction and re-insertion
#
# Written by puggsoy
# script for QuickBMS http://quickbms.aluigi.org

get EXT extension

if EXT == "sb"
   callfunction SBEXTRACT
elif EXT == "txt"
   callfunction REIMPORT
endif

startfunction SBEXTRACT
   findloc CHDROFF string "CHDR"
   findloc CDATOFF string "CDAT"
   
   goto CDATOFF
   idstring "CDAT"
   get CDATSZ long
   get DUMMY long
   savepos STRINGSOFF
   
   goto CHDROFF
   idstring "CHDR"
   get CHDRSZ long
   get DUMMY long
   
   log MEMORY_FILE 0 0
   
   append
   for POS = 0 < CHDRSZ
      get OFFSET long
      get SIZE long
      math OFFSET += STRINGSOFF
      
      log MEMORY_FILE OFFSET SIZE
      
      goto 0 MEMORY_FILE SEEK_END
      put 0xFF byte MEMORY_FILE
      put 0x0D byte MEMORY_FILE
      put 0x0A byte MEMORY_FILE
      
      math POS += 8
   next
   append
   
   get MSIZE asize MEMORY_FILE
   log "sbextracted.txt" 0 MSIZE MEMORY_FILE
endfunction

startfunction REIMPORT
   open "." "sims3_deluxe_ios.sb" 1 EXISTS
   findloc CHDROFF string "CHDR" 1
   set SIZE CHDROFF
   math SIZE += 0x0C
   
   log MEMORY_FILE 0 SIZE 1
   goto 0 MEMORY_FILE SEEK_END
   
   log MEMORY_FILE2 0 0
   
   get FILESIZE asize
   set STRNUM 0
   set OFFSET 0
   
   append
   for POS = 0 < FILESIZE
      findloc DELOFF byte 255
      set SIZE DELOFF
      math SIZE -= POS
      
      put OFFSET long MEMORY_FILE
      put SIZE long MEMORY_FILE
      
      log MEMORY_FILE2 POS SIZE
      goto 0 MEMORY_FILE2 SEEK_END
      put 0x00 byte MEMORY_FILE2
      goto 0 MEMORY_FILE2 SEEK_END
      savepos OFFSET MEMORY_FILE2
      
      math DELOFF += 3
      goto DELOFF
      savepos POS
      
      math STRNUM += 1
   next
   append
   
   goto CHDROFF MEMORY_FILE
   idstring "CHDR" MEMORY_FILE
   set CHDRSZ STRNUM
   math CHDRSZ *= 8
   put CHDRSZ long MEMORY_FILE
   
   findloc CDATOFF string "CDAT" 1
   set SIZE 0x0C
   
   append
   log MEMORY_FILE CDATOFF SIZE 1
   goto 0 MEMORY_FILE SEEK_END
   
   get MSIZE asize MEMORY_FILE2
   log MEMORY_FILE 0 MSIZE MEMORY_FILE2
   append
   
   get MSIZE asize MEMORY_FILE
   log "newstrings.sb" 0 MSIZE MEMORY_FILE
endfunction

There are a number of things you need to keep in mind:

First of all, when you extract the file, it will create a .txt file containing all of the strings. Each string ends with the "ÿ" character, and then a newline. Do not remove this character (or the newline) when editing the text because it is essential for re-importing.
Secondly, to re-import the strings, choose the edited .txt file as the input file. It is also necessary that "sims3_deluxe_ios.sb" is in the output folder. It will not overwrite this file, but instead create a new file called "newstrings.sb" that contains your edited strings.

I am unable to test this with the game myself (since I don't own it), but if I extract and then re-import without changing anything, the resulting .sb file is identical to the original. So I assume that you should be able to edit strings and re-import them to mod or translate the game.

Thanks so much :D It's very very ok
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: The Sim: Free Play

Post by hackspeedok »

Puggsoy, something wrong ? When i edited some strings that didn't have "ÿ" at the end of string, the game crashed. Can you help me ?
http://i.imgur.com/kFMFrTO.png

P/S: And can you help me for editing with longer strings than orginal ? Example: Old string: "New Game", i want to replace with "Chơi mới" (more characters). Reimport will error if i do that.
puggsoy
Posts: 161
Joined: Sat Dec 13, 2014 1:01 am

Re: The Sim: Free Play

Post by puggsoy »

I can see that you're using Notepad++ in UTF-8 mode. You need to use it in ANSI mode (go to Encoding -> Encode in ANSI). That might help.
Also, I don't think unicode characters will work. For example "Chơi mới" cannot be saved as ANSI.

That said, there is a lot of the file format I am still unfamiliar with and that probably is used by the game, so even if you use ANSI strings it might not work. Try it though, just changing one or two simple words without unicode characters.
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: The Sim: Free Play

Post by hackspeedok »

puggsoy wrote:I can see that you're using Notepad++ in UTF-8 mode. You need to use it in ANSI mode (go to Encoding -> Encode in ANSI). That might help.
Also, I don't think unicode characters will work. For example "Chơi mới" cannot be saved as ANSI.

That said, there is a lot of the file format I am still unfamiliar with and that probably is used by the game, so even if you use ANSI strings it might not work. Try it though, just changing one or two simple words without unicode characters.

It still work with Unicode characters in encoding UTF 8 :) But it will crash if i edit the strings that don't have "ÿ" at the end of string. And crash when i replace the original string by longer new string, too. Do you have any idea ?
puggsoy
Posts: 161
Joined: Sat Dec 13, 2014 1:01 am

Re: The Sim: Free Play

Post by puggsoy »

That's very strange indeed. I have no idea why that would be happening, I tested that and the resulting .sb file is what I would expect, so I don't think it's importing them incorrectly. What about if the string is shorter than original?
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: The Sim: Free Play

Post by hackspeedok »

Shorter is ok but crash if longer than original :(
puggsoy
Posts: 161
Joined: Sat Dec 13, 2014 1:01 am

Re: The Sim: Free Play

Post by puggsoy »

That's very strange... I'm not sure what it could be then. Maybe just some sort of restriction in the game engine.

I apologise but I don't think I can help you further :?
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: The Sim: Free Play

Post by hackspeedok »

puggsoy wrote:That's very strange... I'm not sure what it could be then. Maybe just some sort of restriction in the game engine.

I apologise but I don't think I can help you further :?


Anyway, thanks you so much
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: The Sim: Free Play

Post by hackspeedok »

Can you update script for the new version ? Thanks
puggsoy
Posts: 161
Joined: Sat Dec 13, 2014 1:01 am

Re: The Sim: Free Play

Post by puggsoy »

It appears to work fine with the existing script. Are you experiencing issues?
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: The Sim: Free Play

Post by hackspeedok »

puggsoy wrote:It appears to work fine with the existing script. Are you experiencing issues?

Sorry, my failed :D It is still working
hackspeedok
Posts: 404
Joined: Mon Oct 06, 2014 6:41 pm

Re: The Sim: Free Play

Post by hackspeedok »

Hi, this game has new update and the old script does not work. When i modding, the game didn't work