4 ms·
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 pr
by hkmurakami 14y ago
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 http://pastebin.com/8NR1EdkN
- wskinner 14y agoThis 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.
- seanalltogether 14y agoThats 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.
- ryusage 14y agoJavaScript 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.
- derefr 14y ago> 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-JavaScript-source-code-with-v8-snapshot https://github.com/rogerwang/node-webkit/wiki/Protect-JavaSc...
- munificent 14y ago> 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.
- zevyoura 14y agoThe pastebin has been de-obfuscated and manually cleaned up significantly compared to the original that's bundled with the game.
- ryusage 14y agoAh, thank you. That makes infinitely more sense.
- jfoutz 14y agoAnother 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.
- pixl97 14y agoThe 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.
- bashinator 14y agoI always figured they meant moddable by EA, for the purposes of developing and selling DLC.