Porting begins

6 October 2010

Tags

  • City of Wonder

Day #1, and my team is largely blocked by lack of data. The Facebook game uses AMF meaning we don’t natively or immediately have support for talking to the server, rather, I’m going to use Charles to sniff the packets and save them as txt files, from the txt files I can populate the structures. And with this magic script, and some help from Chris Sharp, I can start porting the structures over:

find . -name "*.as" | while read i; do echo "#if 0" > ${i/.as/.h}; cat $i | sed "s/package/namespace/" | sed "s/public var//" | sed "s/public class/struct/" | sed "s/Number/float/" | sed "s/Boolean/bool/" | sed "s/String/string/" | sed "s/\(^[ \t]\)\*\(.\*\)[ \t]*:[ \t]\*\(.\*\);/\1 \3 \2;/" | sed "s/\\/\\/ ActionScript file//" >> ${i/.as/.h}; echo >> ${i/.as/.h}; echo "#endif" >> ${i/.as/.h}; done

For all *.as files

  • add #if 0 to the top and #endif to the bottom
  • replace the package keyword with namespace
  • and the public class keyword with struct
  • change Number to float, String to string
  • remove all public var and switch the variable name and type (this is Chris’ magic)
  • and finally rename to *.h

Also, it looks like we have 44MB of assets.