News for hackers. Stuff that matters.
Re:EA CEO John Riccitiello Steps Down by hkmurakami on Monday March 18, 2013 @04:58PM (#5397089)
So according to the articles posted in the parent post, removing line 22 here [1] will enable offline play.

I'm not literate at all about the state in which production code gets shipped to the end user, but I would have expected this level of code to have been in binary form. Could someone shed some light on this?

[1] http://pastebin.com/8NR1EdkN

Re:EA CEO John Riccitiello Steps Down by ryusage on Monday March 18, 2013 @05:55PM (#5397420)
JavaScript doesn't get compiled into binary. The human readable source code file just gets processed directly by an engine that executes each command. You're right though, the fact that this is in a form that's so easy to read is extremely surprising.

Normally what's done with script languages like JavaScript is to obfuscate the file by processing it with a tool that would rename everything to be meaningless, and change spacing, line breaks, etc in a way that is still executable, but overwhelmingly tedious/difficult for any human to read and understand.

Did they really ship the game with such open sourced code? For a company so concerned about preventing piracy, I find that pretty hard to believe. It's like they didn't even try.

Re:EA CEO John Riccitiello Steps Down by derefr on Monday March 18, 2013 @06:04PM (#5397474)
> JavaScript doesn't get compiled into binary.

Well, it can. V8 and other Javascript engines do Just-In-Time (JIT) binary compilation, meaning that they start by interpreting and executing each line of code as they read it, but when they see a function getting executed a lot, they convert just that function to native machine code as a performance optimization for the next time it gets called.

And, because this does happen, you can ship compiled Javascript--by dumping the memory-image of the Javascript interpreter after running it for a while (JITed routines and all) and then reloading it on the client end.

node-webkit (an application framework similar to the one EA/Maxis uses for SimCity's UI) has a good example of this concept in action: https://github.com/rogerwang/node-webkit/wiki/Protect-JavaSc...

Re:EA CEO John Riccitiello Steps Down by munificent on Monday March 18, 2013 @06:30PM (#5397599)
> meaning that they start by interpreting and executing each line of code as they read it, but when they see a function getting executed a lot, they convert just that function to native machine code as a performance optimization for the next time it gets called.

Technically V8 does not have an interpreter pass at all. It always JITs to machine code. It does have two compilers though: a fast JIT and a slow JIT. The fast one gets code running as quickly as possible so your app starts fast, but doesn't generate optimal code. The slow JIT kicks in for hot code and spends more timing compiling it to something that will run faster.

Re:EA CEO John Riccitiello Steps Down by zevyoura on Monday March 18, 2013 @06:26PM (#5397576)
The pastebin has been de-obfuscated and manually cleaned up significantly compared to the original that's bundled with the game.
Re:EA CEO John Riccitiello Steps Down by ryusage on Tuesday March 19, 2013 @10:25AM (#5401037)
Ah, thank you. That makes infinitely more sense.
Re:EA CEO John Riccitiello Steps Down by jfoutz on Monday March 18, 2013 @06:56PM (#5397718)
Another trick, that's clearly not as fancy as derefr's, its to parse the js, then save the interpreter and parsed ast as a big binary.

The dart guys are always talking about how long it takes to parse js. it's not a huge win, but still quicker doing the parsing up front.

Re:EA CEO John Riccitiello Steps Down by wskinner on Monday March 18, 2013 @05:10PM (#5397155)
This appears to be javascript. Lots of games use scripting languages for certain components. However, it is pretty surprising that they would implement a supposed "security" feature in such a way.
Re:EA CEO John Riccitiello Steps Down by seanalltogether on Monday March 18, 2013 @07:49PM (#5397939)
Thats the thing, its not a security feature at all, all you're doing by disabling that feature is extending the length of time you can play before checking in with the server, but if you quit the game without reconnecting you will still lose everything. Maxis must've decided that 20 minutes was the threshold before people would be really pissed that they might lose their progress.
Re:EA CEO John Riccitiello Steps Down by pixl97 on Monday March 18, 2013 @06:13PM (#5397521)
The Glassbox engine was designed to be easily moddable. The problem is the games 'online' nature leads EA to ban people from making mods to keep people from cheating. There was a huge disconnect in the grand vision somewhere.
Re:EA CEO John Riccitiello Steps Down by bashinator on Monday March 18, 2013 @07:46PM (#5397921)
I always figured they meant moddable by EA, for the purposes of developing and selling DLC.