Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial checkin

  • Loading branch information...
commit 785e381141f387d5861181ecda0624ae7acba337 0 parents
@Brucer Brucer authored brucero committed
Showing with 5,634 additions and 0 deletions.
  1. +3 −0  .gitignore
  2. +24 −0 INSTALL
  3. +25 −0 README.md
  4. +55 −0 bin/jsgamebench
  5. BIN  images/Background_01_1024_0000.png
  6. BIN  images/Pirate_128_0000.png
  7. BIN  images/Rock.png
  8. BIN  images/asteroid.png
  9. BIN  images/asteroid/Test_Asteroid_128_00000.png
  10. BIN  images/asteroid/Test_Asteroid_128_00001.png
  11. BIN  images/asteroid/Test_Asteroid_128_00002.png
  12. BIN  images/asteroid/Test_Asteroid_128_00003.png
  13. BIN  images/asteroid/Test_Asteroid_128_00004.png
  14. BIN  images/asteroid/Test_Asteroid_128_00005.png
  15. BIN  images/asteroid/Test_Asteroid_128_00006.png
  16. BIN  images/asteroid/Test_Asteroid_128_00007.png
  17. BIN  images/asteroid/Test_Asteroid_128_00008.png
  18. BIN  images/asteroid/Test_Asteroid_128_00009.png
  19. BIN  images/asteroid/Test_Asteroid_128_00010.png
  20. BIN  images/asteroid/Test_Asteroid_128_00011.png
  21. BIN  images/asteroid/Test_Asteroid_128_00012.png
  22. BIN  images/asteroid/Test_Asteroid_128_00013.png
  23. BIN  images/asteroid/Test_Asteroid_128_00014.png
  24. BIN  images/asteroid/Test_Asteroid_128_00015.png
  25. BIN  images/asteroid/Test_Asteroid_128_00016.png
  26. BIN  images/asteroid/Test_Asteroid_128_00017.png
  27. BIN  images/asteroid/Test_Asteroid_128_00018.png
  28. BIN  images/asteroid/Test_Asteroid_128_00019.png
  29. BIN  images/asteroid/Test_Asteroid_128_00020.png
  30. BIN  images/asteroid/Test_Asteroid_128_00021.png
  31. BIN  images/asteroid/Test_Asteroid_128_00022.png
  32. BIN  images/asteroid/Test_Asteroid_128_00023.png
  33. BIN  images/asteroid/Test_Asteroid_128_00024.png
  34. BIN  images/asteroid/Test_Asteroid_128_00025.png
  35. BIN  images/asteroid/Test_Asteroid_128_00026.png
  36. BIN  images/asteroid/Test_Asteroid_128_00027.png
  37. BIN  images/asteroid/Test_Asteroid_128_00028.png
  38. BIN  images/asteroid/Test_Asteroid_128_00029.png
  39. BIN  images/asteroid/Test_Asteroid_128_00030.png
  40. BIN  images/asteroid/Test_Asteroid_128_00031.png
  41. BIN  images/asteroid/Test_Asteroid_128_00032.png
  42. BIN  images/asteroid/Test_Asteroid_128_00033.png
  43. BIN  images/asteroid/Test_Asteroid_128_00034.png
  44. BIN  images/asteroid/Test_Asteroid_128_00035.png
  45. BIN  images/asteroid/Test_Asteroid_128_00036.png
  46. BIN  images/asteroid/Test_Asteroid_128_00037.png
  47. BIN  images/asteroid/Test_Asteroid_128_00038.png
  48. BIN  images/asteroid/Test_Asteroid_128_00039.png
  49. BIN  images/asteroid/Test_Asteroid_128_00040.png
  50. BIN  images/asteroid/Test_Asteroid_128_00041.png
  51. BIN  images/asteroid/Test_Asteroid_128_00042.png
  52. BIN  images/asteroid/Test_Asteroid_128_00043.png
  53. BIN  images/asteroid/Test_Asteroid_128_00044.png
  54. BIN  images/asteroid/Test_Asteroid_128_00045.png
  55. BIN  images/asteroid/Test_Asteroid_128_00046.png
  56. BIN  images/asteroid/Test_Asteroid_128_00047.png
  57. BIN  images/asteroid/Test_Asteroid_128_00048.png
  58. BIN  images/asteroid/Test_Asteroid_128_00049.png
  59. BIN  images/asteroid/Test_Asteroid_128_00050.png
  60. BIN  images/asteroid/Test_Asteroid_128_00051.png
  61. BIN  images/asteroid/Test_Asteroid_128_00052.png
  62. BIN  images/asteroid/Test_Asteroid_128_00053.png
  63. BIN  images/asteroid/Test_Asteroid_128_00054.png
  64. BIN  images/asteroid/Test_Asteroid_128_00055.png
  65. BIN  images/asteroid/Test_Asteroid_128_00056.png
  66. BIN  images/asteroid/Test_Asteroid_128_00057.png
  67. BIN  images/asteroid/Test_Asteroid_128_00058.png
  68. BIN  images/asteroid/Test_Asteroid_128_00059.png
  69. BIN  images/board_01.png
  70. BIN  images/board_02.png
  71. BIN  images/box_01.png
  72. BIN  images/box_02.png
  73. BIN  images/cannon_l.png
  74. BIN  images/cannon_r.png
  75. BIN  images/explosion.png
  76. BIN  images/explosion/Test_Explosion_000006.png
  77. BIN  images/explosion/Test_Explosion_000007.png
  78. BIN  images/explosion/Test_Explosion_000008.png
  79. BIN  images/explosion/Test_Explosion_000009.png
  80. BIN  images/explosion/Test_Explosion_000010.png
  81. BIN  images/explosion/Test_Explosion_000011.png
  82. BIN  images/explosion/Test_Explosion_000012.png
  83. BIN  images/explosion/Test_Explosion_000013.png
  84. BIN  images/explosion/Test_Explosion_000014.png
  85. BIN  images/explosion/Test_Explosion_000015.png
  86. BIN  images/explosion/Test_Explosion_000016.png
  87. BIN  images/explosion/Test_Explosion_000017.png
  88. BIN  images/explosion/Test_Explosion_000018.png
  89. BIN  images/explosion/Test_Explosion_000019.png
  90. BIN  images/explosion/Test_Explosion_000020.png
  91. BIN  images/explosion/Test_Explosion_000021.png
  92. BIN  images/explosion/Test_Explosion_000022.png
  93. BIN  images/explosion/Test_Explosion_000023.png
  94. BIN  images/explosion/Test_Explosion_000024.png
  95. BIN  images/explosion/Test_Explosion_000025.png
  96. BIN  images/explosion/Test_Explosion_000026.png
  97. BIN  images/explosion/Test_Explosion_000027.png
  98. BIN  images/explosion/Test_Explosion_000028.png
  99. BIN  images/explosion/Test_Explosion_000029.png
  100. BIN  images/explosion/Test_Explosion_000030.png
  101. BIN  images/explosion/Test_Explosion_000031.png
  102. BIN  images/explosion/Test_Explosion_000032.png
  103. BIN  images/explosion/Test_Explosion_000033.png
  104. BIN  images/explosion/Test_Explosion_000034.png
  105. BIN  images/explosion/Test_Explosion_000035.png
  106. BIN  images/explosion/Test_Explosion_000036.png
  107. BIN  images/explosion/Test_Explosion_000037.png
  108. BIN  images/explosion/Test_Explosion_000038.png
  109. BIN  images/explosion/Test_Explosion_000039.png
  110. BIN  images/explosion/Test_Explosion_000040.png
  111. BIN  images/explosion/Test_Explosion_000041.png
  112. BIN  images/explosion/Test_Explosion_000042.png
  113. BIN  images/explosion/Test_Explosion_000043.png
  114. BIN  images/explosion/Test_Explosion_000044.png
  115. BIN  images/explosion/Test_Explosion_000045.png
  116. BIN  images/explosion/Test_Explosion_000046.png
  117. BIN  images/explosion/Test_Explosion_000047.png
  118. BIN  images/explosion/Test_Explosion_000048.png
  119. BIN  images/explosion/Test_Explosion_000049.png
  120. BIN  images/explosion/Test_Explosion_000050.png
  121. BIN  images/explosion/Test_Explosion_000051.png
  122. BIN  images/explosion/Test_Explosion_000052.png
  123. BIN  images/explosion/Test_Explosion_000053.png
  124. BIN  images/explosion/Test_Explosion_000054.png
  125. BIN  images/explosion/Test_Explosion_000055.png
  126. BIN  images/explosion/Test_Explosion_000056.png
  127. BIN  images/explosion/Test_Explosion_000057.png
  128. BIN  images/explosion/Test_Explosion_000058.png
  129. BIN  images/ninja_01.png
  130. BIN  images/ninja_02.png
  131. BIN  images/powerup.png
  132. BIN  images/powerup/Test_Powerup_Star_64_000000.png
  133. BIN  images/powerup/Test_Powerup_Star_64_000001.png
  134. BIN  images/powerup/Test_Powerup_Star_64_000002.png
  135. BIN  images/powerup/Test_Powerup_Star_64_000003.png
  136. BIN  images/powerup/Test_Powerup_Star_64_000004.png
  137. BIN  images/powerup/Test_Powerup_Star_64_000005.png
  138. BIN  images/powerup/Test_Powerup_Star_64_000006.png
  139. BIN  images/powerup/Test_Powerup_Star_64_000007.png
  140. BIN  images/powerup/Test_Powerup_Star_64_000008.png
  141. BIN  images/powerup/Test_Powerup_Star_64_000009.png
  142. BIN  images/powerup/Test_Powerup_Star_64_000010.png
  143. BIN  images/powerup/Test_Powerup_Star_64_000011.png
  144. BIN  images/powerup/Test_Powerup_Star_64_000012.png
  145. BIN  images/powerup/Test_Powerup_Star_64_000013.png
  146. BIN  images/powerup/Test_Powerup_Star_64_000014.png
  147. BIN  images/powerup/Test_Powerup_Star_64_000015.png
  148. BIN  images/powerup/Test_Powerup_Star_64_000016.png
  149. BIN  images/powerup/Test_Powerup_Star_64_000017.png
  150. BIN  images/powerup/Test_Powerup_Star_64_000018.png
  151. BIN  images/powerup/Test_Powerup_Star_64_000019.png
  152. BIN  images/powerup/Test_Powerup_Star_64_000020.png
  153. BIN  images/powerup/Test_Powerup_Star_64_000021.png
  154. BIN  images/powerup/Test_Powerup_Star_64_000022.png
  155. BIN  images/powerup/Test_Powerup_Star_64_000023.png
  156. BIN  images/powerup/Test_Powerup_Star_64_000024.png
  157. BIN  images/powerup/Test_Powerup_Star_64_000025.png
  158. BIN  images/powerup/Test_Powerup_Star_64_000026.png
  159. BIN  images/powerup/Test_Powerup_Star_64_000027.png
  160. BIN  images/powerup/Test_Powerup_Star_64_000028.png
  161. BIN  images/powerup/Test_Powerup_Star_64_000029.png
  162. BIN  images/powerup/Test_Powerup_Star_64_000030.png
  163. BIN  images/powerup/Test_Powerup_Star_64_000031.png
  164. BIN  images/powerup/Test_Powerup_Star_64_000032.png
  165. BIN  images/powerup/Test_Powerup_Star_64_000033.png
  166. BIN  images/powerup/Test_Powerup_Star_64_000034.png
  167. BIN  images/powerup/Test_Powerup_Star_64_000035.png
  168. BIN  images/powerup/Test_Powerup_Star_64_000036.png
  169. BIN  images/powerup/Test_Powerup_Star_64_000037.png
  170. BIN  images/powerup/Test_Powerup_Star_64_000038.png
  171. BIN  images/powerup/Test_Powerup_Star_64_000039.png
  172. BIN  images/ship.png
  173. BIN  images/ship/Test_Ship_Idle_128_00000.png
  174. BIN  images/ship/Test_Ship_Idle_128_00001.png
  175. BIN  images/ship/Test_Ship_Idle_128_00002.png
  176. BIN  images/ship/Test_Ship_Idle_128_00003.png
  177. BIN  images/ship/Test_Ship_Idle_128_00004.png
  178. BIN  images/ship/Test_Ship_Idle_128_00005.png
  179. BIN  images/ship/Test_Ship_Idle_128_00006.png
  180. BIN  images/ship/Test_Ship_Idle_128_00007.png
  181. BIN  images/ship/Test_Ship_Idle_128_00008.png
  182. BIN  images/ship/Test_Ship_Idle_128_00009.png
  183. BIN  images/ship/Test_Ship_Idle_128_00010.png
  184. BIN  images/ship/Test_Ship_Idle_128_00011.png
  185. BIN  images/ship/Test_Ship_Idle_128_00012.png
  186. BIN  images/ship/Test_Ship_Idle_128_00013.png
  187. BIN  images/ship/Test_Ship_Idle_128_00014.png
  188. BIN  images/ship/Test_Ship_Idle_128_00015.png
  189. BIN  images/ship/Test_Ship_Idle_128_00016.png
  190. BIN  images/ship/Test_Ship_Idle_128_00017.png
  191. BIN  images/ship/Test_Ship_Idle_128_00018.png
  192. BIN  images/ship/Test_Ship_Idle_128_00019.png
  193. BIN  images/ship/Test_Ship_Idle_128_00020.png
  194. BIN  images/ship/Test_Ship_Idle_128_00021.png
  195. BIN  images/ship/Test_Ship_Idle_128_00022.png
  196. BIN  images/ship/Test_Ship_Idle_128_00023.png
  197. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00000.png
  198. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00001.png
  199. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00002.png
  200. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00003.png
  201. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00004.png
  202. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00005.png
  203. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00006.png
  204. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00007.png
  205. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00008.png
  206. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00009.png
  207. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00010.png
  208. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00011.png
  209. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00012.png
  210. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00013.png
  211. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00014.png
  212. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00015.png
  213. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00016.png
  214. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00017.png
  215. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00018.png
  216. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00019.png
  217. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00020.png
  218. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00021.png
  219. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00022.png
  220. BIN  images/ship/Test_Ship_Thrust_Frame1_128_00023.png
  221. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00000.png
  222. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00001.png
  223. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00002.png
  224. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00003.png
  225. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00004.png
  226. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00005.png
  227. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00006.png
  228. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00007.png
  229. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00008.png
  230. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00009.png
  231. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00010.png
  232. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00011.png
  233. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00012.png
  234. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00013.png
  235. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00014.png
  236. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00015.png
  237. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00016.png
  238. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00017.png
  239. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00018.png
  240. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00019.png
  241. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00020.png
  242. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00021.png
  243. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00022.png
  244. BIN  images/ship/Test_Ship_Thrust_Frame2_128_00023.png
  245. BIN  images/ship_fbmark.png
  246. BIN  images/ship_idle.png
  247. BIN  images/ship_thrust_frame1.png
  248. BIN  images/ship_thrust_frame2.png
  249. BIN  images/shot.png
  250. BIN  images/stars.jpg
  251. BIN  images/stars.png
  252. +61 −0 lib/comm.js
  253. +52 −0 lib/log.js
  254. +98 −0 lib/logproc.js
  255. +181 −0 lib/server.js
  256. +64 −0 lib/socket.js
  257. +65 −0 lib/svrcmds.js
  258. +291 −0 lib/svrgame.js
  259. +93 −0 lib/users.js
  260. +13 −0 license.txt
  261. +4 −0 logs/.nfs0000000003ac66b500000003
  262. +103 −0 public/css/style.css
  263. +48 −0 public/index.html
  264. +105 −0 public/javascript/benchmark.js
  265. +79 −0 public/javascript/canvas_render.js
  266. +293 −0 public/javascript/clientcmds.js
  267. +42 −0 public/javascript/clientutils.js
  268. +225 −0 public/javascript/dom_render.js
  269. +51 −0 public/javascript/fbmark.js
  270. +523 −0 public/javascript/game.js
  271. +240 −0 public/javascript/gameframe.js
  272. +67 −0 public/javascript/globals.js
  273. +138 −0 public/javascript/gob.js
  274. +111 −0 public/javascript/init.js
  275. +156 −0 public/javascript/input.js
  276. +29 −0 public/javascript/json2.min.js
  277. +333 −0 public/javascript/perftest.js
  278. +298 −0 public/javascript/render.js
  279. +235 −0 public/javascript/shared/grid.js
  280. +106 −0 public/javascript/shared/gridclient.js
  281. +109 −0 public/javascript/shared/gridsvr.js
  282. +142 −0 public/javascript/shared/gridtest.js
  283. +37 −0 public/javascript/shared/math.js
  284. +113 −0 public/javascript/shared/utils.js
  285. +124 −0 public/javascript/shared/vec.js
  286. +84 −0 public/javascript/sprites.js
  287. +53 −0 public/javascript/tick.js
  288. +374 −0 public/javascript/ui.js
  289. +30 −0 public/javascript/webgl_render.js
  290. +180 −0 public/javascript/world.js
  291. +59 −0 public/javascript/xhr.js
  292. +12 −0 restart
  293. +34 −0 tools/pirates.rb
  294. +37 −0 tools/ships.rb
  295. +35 −0 tools/space.rb
3  .gitignore
@@ -0,0 +1,3 @@
+*.log
+a.out
+
24 INSTALL
@@ -0,0 +1,24 @@
+here's how we do it:
+
+install nodejs
+---------
+get the stable build of nodejs from http://nodejs.org/#download
+./configure --prefix=~/local
+make;make install
+add ~/local/bin to your PATH
+
+install npm (node package manager https://github.com/isaacs/npm)
+--------
+curl http://npmjs.org/install.sh | sh
+
+install node socket.io package
+npm install socket.io
+
+run it:
+node bin/jsgamebench
+(runs on port 8081 by default)
+
+
+OPTIONAL install node-inspector for server debugging: (https://github.com/dannycoates/node-inspector)
+npm install node-inspector
+
25 README.md
@@ -0,0 +1,25 @@
+= jsgamebench =
+
+Gamelike sprite performance testing for browsers.
+
+= License =
+
+jsgamebench is licensed under the Apache 2.0 license
+
+Copyright 2011 Facebook, Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may
+not use this file except in compliance with the License. You may obtain
+a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+License for the specific language governing permissions and limitations
+under the License.
+
+= How to use =
+
+= More info than you wanted =
55 bin/jsgamebench
@@ -0,0 +1,55 @@
+#! /usr/bin/env node
+
+// Copyright 2004-present Facebook. All Rights Reserved.
+
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+
+// http://www.apache.org/licenses/LICENSE-2.0
+
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+sys = require('sys');
+fs = require('fs');
+path = require('path');
+events = require('events');
+http = require('http');
+crypto = require('crypto');
+url = require('url');
+querystring = require('querystring');
+net = require('net');
+io = require('socket.io');
+
+Log = require('../lib/log');
+LogProc = require('../lib/logproc');
+
+Utils = require('../public/javascript/shared/utils');
+Users = require('../lib/users');
+Server = require('../lib/server');
+Comm = require('../lib/comm');
+Grid = require('../public/javascript/shared/grid');
+GridSvr = require('../public/javascript/shared/gridsvr');
+Vec = require('../public/javascript/shared/vec');
+Mathx = require('../public/javascript/shared/math');
+Socket = require('../lib/socket');
+SvrGame = require('../lib/svrgame');
+SvrCmds = require('../lib/svrcmds');
+
+sys.puts("starting server");
+var production_mode = false;
+SvrGame.init();
+for(var i=0;i<process.argv.length;i++) {
+ if (process.argv[i] == '-80') {
+ production_mode = true;
+ }
+}
+
+sys.puts("reading log file");
+LogProc.start('logs/stats.log',null);
+
+Server.init(Server.serverCallback,production_mode ? 80 : 8081);
BIN  images/Background_01_1024_0000.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/Pirate_128_0000.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/Rock.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00000.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00001.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00002.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00003.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00004.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00005.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00006.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00007.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00008.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00009.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00010.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00011.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00012.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00013.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00014.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00015.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00016.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00017.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00018.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00019.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00020.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  images/asteroid/Test_Asteroid_128_00021.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00022.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00023.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00024.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00025.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00026.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00027.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00028.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00029.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00030.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00031.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00032.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00033.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00034.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00035.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00036.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00037.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00038.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00039.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00040.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00041.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00042.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00043.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00044.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00045.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00046.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00047.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00048.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00049.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00050.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00051.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00052.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00053.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00054.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00055.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00056.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00057.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00058.png
Diff not rendered
BIN  images/asteroid/Test_Asteroid_128_00059.png
Diff not rendered
BIN  images/board_01.png
Diff not rendered
BIN  images/board_02.png
Diff not rendered
BIN  images/box_01.png
Diff not rendered
BIN  images/box_02.png
Diff not rendered
BIN  images/cannon_l.png
Diff not rendered
BIN  images/cannon_r.png
Diff not rendered
BIN  images/explosion.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000006.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000007.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000008.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000009.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000010.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000011.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000012.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000013.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000014.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000015.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000016.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000017.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000018.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000019.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000020.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000021.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000022.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000023.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000024.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000025.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000026.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000027.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000028.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000029.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000030.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000031.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000032.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000033.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000034.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000035.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000036.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000037.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000038.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000039.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000040.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000041.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000042.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000043.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000044.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000045.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000046.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000047.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000048.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000049.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000050.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000051.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000052.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000053.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000054.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000055.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000056.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000057.png
Diff not rendered
BIN  images/explosion/Test_Explosion_000058.png
Diff not rendered
BIN  images/ninja_01.png
Diff not rendered
BIN  images/ninja_02.png
Diff not rendered
BIN  images/powerup.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000000.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000001.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000002.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000003.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000004.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000005.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000006.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000007.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000008.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000009.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000010.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000011.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000012.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000013.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000014.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000015.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000016.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000017.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000018.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000019.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000020.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000021.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000022.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000023.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000024.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000025.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000026.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000027.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000028.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000029.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000030.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000031.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000032.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000033.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000034.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000035.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000036.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000037.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000038.png
Diff not rendered
BIN  images/powerup/Test_Powerup_Star_64_000039.png
Diff not rendered
BIN  images/ship.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00000.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00001.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00002.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00003.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00004.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00005.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00006.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00007.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00008.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00009.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00010.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00011.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00012.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00013.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00014.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00015.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00016.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00017.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00018.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00019.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00020.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00021.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00022.png
Diff not rendered
BIN  images/ship/Test_Ship_Idle_128_00023.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00000.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00001.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00002.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00003.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00004.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00005.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00006.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00007.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00008.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00009.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00010.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00011.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00012.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00013.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00014.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00015.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00016.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00017.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00018.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00019.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00020.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00021.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00022.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame1_128_00023.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00000.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00001.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00002.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00003.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00004.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00005.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00006.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00007.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00008.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00009.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00010.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00011.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00012.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00013.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00014.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00015.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00016.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00017.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00018.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00019.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00020.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00021.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00022.png
Diff not rendered
BIN  images/ship/Test_Ship_Thrust_Frame2_128_00023.png
Diff not rendered
BIN  images/ship_fbmark.png
Diff not rendered
BIN  images/ship_idle.png
Diff not rendered
BIN  images/ship_thrust_frame1.png
Diff not rendered
BIN  images/ship_thrust_frame2.png
Diff not rendered
BIN  images/shot.png
Diff not rendered
BIN  images/stars.jpg
Diff not rendered
BIN  images/stars.png
Diff not rendered
61 lib/comm.js
@@ -0,0 +1,61 @@
+// Copyright 2004-present Facebook. All Rights Reserved.
+
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+
+// http://www.apache.org/licenses/LICENSE-2.0
+
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+function sendFileNotFound(res, filename, err) {
+ console.log('fnf: ' + filename);
+ Log.http('404 - ' + filename);
+ res.writeHead(404, {'Content-Type': 'text/plain'});
+ res.write('404 Not Found: ' + filename + ' (' + err + ')\n');
+ res.end();
+}
+
+function sendFile(res, filename, cached, cb) {
+ fullname = process.cwd() + (filename[0] == '/' ? '' : '/') + filename;
+ fs.readFile(fullname, 'binary', function(err, file) {
+ if (err) {
+ if (cb)
+ cb(res, filename);
+ else
+ sendFileNotFound(res, filename, err);
+ } else {
+ var extension = path.extname(filename);
+ Log.http(filename + ' has extension ' + extension);
+ var header = {};
+ switch (extension) {
+ case '.js':
+ header['Content-Type'] = 'text/javascript';
+ break;
+ case '.css':
+ header['Content-Type'] = 'text/css';
+ break;
+ }
+ Log.http('200 - ' + filename);
+ if (cached) {
+ header['Expires'] = 'Sun, 17 Jan 2038 19:14:07 GMT';
+ header['Cache-Control'] = 'max-age=3600';
+ }
+ res.writeHead(200, header);
+ res.write(file, 'binary');
+ res.end();
+ }
+ });
+}
+
+function toClient(user, cmd) {
+ user.commands.push(cmd);
+}
+
+exports.sendFileNotFound = sendFileNotFound;
+exports.sendFile = sendFile;
+exports.toClient = toClient;
52 lib/log.js
@@ -0,0 +1,52 @@
+// Copyright 2004-present Facebook. All Rights Reserved.
+
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+
+// http://www.apache.org/licenses/LICENSE-2.0
+
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+var open_files = {};
+
+function log(logname, user, msg, type) {
+ if (user)
+ var name = user.name;
+ else
+ name = 'walletin';
+ var str = '[' + new Date().toUTCString() + '] ' + name + ' ' + type + ': ' + msg + '\n';
+
+ if (open_files[logname] == undefined) {
+ var fd = fs.openSync('logs/' + logname + '.log', 'a+', 0666);
+ open_files[logname] = fd || 0;
+ }
+ var fd = open_files[logname];
+ if (fd) {
+ fs.write(fd, str, null, undefined, function(err, written) {
+ if (err)
+ console.log('log write err: ' + err);
+ });
+ }
+}
+
+function error(logname, user, msg) {
+ return log(logname, user, msg, 'error');
+}
+
+function info(logname, user, msg) {
+ return log(logname, user, msg, 'info');
+}
+
+function http(str) {
+ sys.puts(str);
+}
+
+
+exports.error = error;
+exports.info = info;
+exports.http = http;
98 lib/logproc.js
@@ -0,0 +1,98 @@
+// Copyright 2004-present Facebook. All Rights Reserved.
+
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+
+// http://www.apache.org/licenses/LICENSE-2.0
+
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+var perf = [];
+
+function addNewEntry(entry) {
+ for (var p = 0, len = perf.length; p < len; p++) {
+ if (perf[p].browser == entry.browser) {
+ if (perf[p].peak < entry.score) {
+ perf[p].peak = parseInt(entry.score);
+ }
+ var subscores = entry.details;
+ for (var rm in subscores) {
+ if (perf[p].details[rm] === undefined) {
+ perf[p].details[rm] = {};
+ }
+ for (var sp in subscores[rm]) {
+ if (perf[p].details[rm][sp] === undefined) {
+ perf[p].details[rm][sp] = {};
+ }
+ for (var d=0, dlen=subscores[rm][sp].length;d<dlen; d++) {
+ if (perf[p].details[rm][sp][subscores[rm][sp][d].path] === undefined) {
+ perf[p].details[rm][sp][subscores[rm][sp][d].path] = {count:1, total:subscores[rm][sp][d].score};
+ } else {
+ perf[p].details[rm][sp][subscores[rm][sp][d].path].count++;
+ perf[p].details[rm][sp][subscores[rm][sp][d].path].total += subscores[rm][sp][d].score;
+ }
+ }
+ }
+ }
+
+ perf[p].total += parseInt(entry.score);
+ perf[p].count++;
+ perf.sort(function(a,b) {return b.peak - a.peak;});
+ return;
+ }
+ }
+ var nentry = {browser: entry.browser, peak: parseInt(entry.score), total: parseInt(entry.score), count: 1, details:{}};
+ var subscores = entry.details;
+ for (var rm in subscores) {
+ nentry.details[rm] = {};
+ for (var sp in subscores[rm]) {
+ nentry.details[rm][sp] = {};
+ for (var d=0, dlen=subscores[rm][sp].length;d<dlen; d++) {
+ nentry.details[rm][sp][subscores[rm][sp][d].path] = {count:1, total:subscores[rm][sp][d].score};
+ }
+ }
+ }
+
+ perf.push(nentry);
+ perf.sort(function(a,b) {return b.peak - a.peak;});
+}
+
+function proc(line) {
+ var tmp = line.match(/.*(guest_\d+) info: (.*)\t([\d\.]+)\t(.*)/);
+ if (tmp) {
+ var user = tmp[1];
+ var browser = tmp[2];
+ var score = tmp[3];
+ var result = tmp[4];
+ addNewEntry({browser: browser, score: score, details: JSON.parse(result)});
+ }
+}
+
+function start(file, cb) {
+ fs.readFile(file, 'utf8', function(error, content) {
+ if (error) {
+ if (cb)
+ cb(null);
+ } else {
+ content.split('\n').forEach(function(line, index) {
+ proc(line);
+ });
+ if (cb)
+ cb(perf);
+ }
+ });
+}
+
+function retPerf(cb) {
+ console.log(JSON.stringify(perf));
+ cb(perf);
+}
+
+exports.start = start;
+exports.addNewEntry = addNewEntry;
+exports.retPerf = retPerf;
181 lib/server.js
@@ -0,0 +1,181 @@
+// Copyright 2004-present Facebook. All Rights Reserved.
+
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+
+// http://www.apache.org/licenses/LICENSE-2.0
+
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+var tick_count = 0;
+var tick_fps = 50;
+var grid_send_rate = 5; // needs to be integer multiple of tick_fps
+
+function tick() {
+ tick_count++;
+ var send_grid = (tick_count % (tick_fps / grid_send_rate)) == 0;
+ var curr_msecs = (new Date).getTime();
+
+ SvrGame.tick();
+ for (var i in Users.sessions) {
+ var user = Users.sessions[i];
+ GridSvr.sendUpdates(user);
+
+ if (send_grid) {
+ if (user.commands.length) {
+ user.commands.push({cmd: 'clock', args: [curr_msecs, 1000 / grid_send_rate]});
+ Socket.sendMessage(user.client, user.message_id, user.commands);
+ user.commands = [];
+ user.response = 0;
+ }
+ }
+ }
+}
+
+var credentials;
+
+exports.init = function(cb, port) {
+ var svr = http.createServer(cb);
+ svr.listen(port);
+ Socket.init(svr);
+ setInterval(function() { tick(); }, 1000 / tick_fps);
+};
+
+exports.processUserCmds = function(user, message_id, command) {
+ SvrCmds.exec(user, command);
+};
+
+function fbOAuth(app_id, app_secret, hostname, code_string, cb) {
+ var connection = http.createClient(443, 'graph.facebook.com', true);
+ connection.addListener('error', function(err) { console.log('err:' + err); });
+
+ if (hostname[hostname.length - 1] != '/') {
+ hostname += '/';
+ }
+ var path = '/oauth/access_token?client_id='
+ + app_id + '&redirect_uri=http://' + hostname + 'oauth_redirect&client_secret='
+ + app_secret + '&code=' + code_string;
+ var request = connection.request('GET', path, {'host' : 'graph.facebook.com'});
+ request.end();
+
+ request.on('response', function(response) {
+ if (response.statusCode != 200) {
+ return cb();
+ }
+ response.setEncoding('utf8');
+ response.on('data', function(chunk) {
+ var access_token = chunk.match(/access_token=(.*)/)[1];
+ var request = connection.request('GET', '/me/?access_token=' + access_token, {'host' : 'graph.facebook.com'});
+ request.end();
+ request.on('response', function(response) {
+ if (response.statusCode != 200) {
+ return cb();
+ }
+ response.on('data', function(chunk) {
+ var userdata = JSON.parse(chunk);
+ return cb(userdata);
+ });
+ });
+ });
+ });
+}
+
+function makeCookie(c_name,value,expiredays,path)
+{
+ var expire_str = '';
+ if (expiredays)
+ {
+ var exdate = new Date();
+ exdate.setDate(exdate.getDate() + expiredays);
+ expire_str = ';expires=' + exdate.toUTCString();
+ }
+ return c_name + '=' + escape(value) + expire_str + ';path=' + path;
+}
+
+var fb_users = {};
+
+function userId(user,id) {
+ var fb = fb_users[id];
+ if (!fb) {
+ console.log('cant find fb userdata for id: ' + id);
+ return;
+ }
+ user.name = fb.first_name;
+ console.log('logged in user: ' + user.name);
+}
+exports.userId = userId;
+
+function handleOAuth(req,res) {
+ var parse = url.parse(req.url, true);
+ var app_id = 0;
+ var app_secret = '';
+ var site_url = req.headers.host + '/game/';
+ fbOAuth(app_id, app_secret, site_url, parse.query.code, function(userdata) {
+ if (userdata) {
+ console.log('userdata: ' + JSON.stringify(userdata));
+ var id = userdata.id;
+ userdata.fb_oauth = parse.query.code;
+ fb_users[id] = userdata;
+ var redir = 'http://' + site_url;
+ var id = makeCookie('id', id, 20, '/');
+ res.writeHead(302, { 'Location': redir, 'Set-Cookie': [id], 'Content-Type': 'text/plain' });
+ }
+ else {
+ console.log('no userdata');
+ var redir = 'http://' + site_url;
+ res.writeHead(302, {'Content-Type': 'text/plain', 'Location': redir});
+ }
+ res.write('Redirecting to ' + redir);
+ res.end();
+ });
+}
+
+exports.serverCallback = function(req, res) {
+ if (req.method == 'POST') {
+ console.log(req.method + ': ' + req.url);
+ console.log('headers: ' + JSON.stringify(req.headers));
+ console.log('body: ' + JSON.stringify(req.body));
+ }
+ var parse = url.parse(req.url);
+ var pathname = parse.pathname;
+ var split = pathname.split('/');
+ if (req.method === 'GET' || req.method === 'POST') {
+ switch (split[1]) {
+ case 'public':
+ Comm.sendFile(res, pathname);
+ break;
+ case 'images':
+ Comm.sendFile(res, pathname, 1);
+ break;
+ case 'game':
+ if (split[2] == 'oauth_redirect') {
+ handleOAuth(req, res);
+ } else {
+ Comm.sendFile(res, '/public/index.html');
+ }
+ break;
+ default:
+ var useragent = req.headers['user-agent'];
+ if (/iPhone/.test(useragent)) {
+ Comm.sendFile(res, '/public/index.html');
+ }
+ else if (/iPad/.test(useragent)) {
+ Comm.sendFile(res, '/public/index.html');
+ }
+ else if (/iPod/.test(useragent)) {
+ Comm.sendFile(res, '/public/index.html');
+ }
+ else if (/Android/.test(useragent)) {
+ Comm.sendFile(res, '/public/index.html');
+ } else {
+ Comm.sendFile(res, '/public/index.html');
+ }
+ break;
+ }
+ }
+};
64 lib/socket.js
@@ -0,0 +1,64 @@
+// Copyright 2004-present Facebook. All Rights Reserved.
+
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+
+// http://www.apache.org/licenses/LICENSE-2.0
+
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+var socket;
+
+function sendMessage(client, id, cmds) {
+ client.send(JSON.stringify({id: id, cmds: cmds}));
+}
+
+function handleDataReq(client, message) {
+ var user = Users.findSession(message.user_id);
+
+ // browser was left running past server restart,
+ // or disconnected for some reason, give him new session key
+
+ if (!user) {
+ if (message.user_id <= 0) {
+ user = Users.addSession();
+ user.client = client;
+ client.user_id = user.id;
+ console.log('req_id: ' + message.req_id + ' user_id: ' + user.id);
+ sendMessage(client, message.req_id, [{cmd: 'startsession', args: [user.id]}]);
+ } else {
+ sendMessage(client, message.req_id, [{cmd: 'resetsession', args: []}]);
+ }
+ return;
+ }
+ user.last_recv_time = (new Date).getTime();
+ Server.processUserCmds(user, message.req_id, message.cmd);
+}
+
+function init(server) {
+ socket = io.listen(server);
+ socket.on('connection', function(client) {
+ client.on('message', function(message) {
+ try {
+ var message = JSON.parse(message.replace('<', '&lt;').replace('>', '&gt;'));
+ } catch (SyntaxError) {
+ log('Invalid JSON:');
+ log(message);
+ return false;
+ }
+ handleDataReq(client, message);
+ });
+
+ client.on('disconnect', function() {
+ Users.removeSession(client.user_id);
+ });
+ });
+}
+
+exports.init = init;
+exports.sendMessage = sendMessage;
65 lib/svrcmds.js
@@ -0,0 +1,65 @@
+// Copyright 2004-present Facebook. All Rights Reserved.
+
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+
+// http://www.apache.org/licenses/LICENSE-2.0
+
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+function svrtest(user, a, b) {
+ console.log('test: a,b = ' + [a, b]);
+ Comm.toClient(user, {cmd: 'clienttest', args: ['a', 'b']});
+ Comm.toClient(user, {cmd: 'clienttest', args: [1, 2]});
+}
+
+var server_cmds = {};
+
+function install(name, func) {
+ server_cmds[name] = {func: func};
+ exports[name] = function() {
+ var command = {cmd: name, args: Array.prototype.slice.call(arguments)};
+ var ret = Utils.cmd_exec(server_cmds, user, command);
+ if (ret)
+ return ret;
+ }
+}
+
+function logPerf(name, browser, result) {
+ LogProc.addNewEntry({browser: browser, score: result.score, details: result});
+ Log.info('stats', name, browser + '\t' + result.score + '\t' + JSON.stringify(result));
+}
+
+function perfQuery(user, query) {
+ LogProc.retPerf(function(response) {
+ Comm.toClient(user, {cmd: 'perfresp', args: [response]});
+ });
+}
+
+install('linktouser', Users.linkToUser);
+install('setview', Users.setView);
+install('svrtest', svrtest);
+install('add', GridSvr.add);
+install('remove', GridSvr.remove);
+install('transform', GridSvr.transform);
+install('logout', Users.logout);
+install('logperf', logPerf);
+install('perfquery', perfQuery);
+install('userid', Server.userId);
+install('tagtile', SvrGame.tagTile);
+install('shoot', SvrGame.shoot);
+install('explode', SvrGame.explode);
+
+exports.exec = function(user, command) {
+ //console.log('cmd: ' + JSON.stringify(command));
+ var ret = Utils.cmd_exec(server_cmds, user, command);
+ if (ret)
+ return ret;
+};
+
+exports.install = install;
291 lib/svrgame.js
@@ -0,0 +1,291 @@
+// Copyright 2004-present Facebook, Inc.
+
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+
+// http://www.apache.org/licenses/LICENSE-2.0
+
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+
+var tiles = [];
+var world_grid = {version: 1, idx: 0};
+var ent_grid = {version: 1, idx: 1};
+var g_grids = [world_grid, ent_grid];
+var live_ents = [];
+
+var gem_names = ['GemGreen', 'GemBlue', 'GemOrange'];
+var tile_names = ['DirtBlock', 'PlainBlock', 'StoneBlock'];
+var shots = ['shot'];
+var playfield_radius = 1600;
+
+function addAsteroid() {
+ var r = playfield_radius * 0.9;
+ var x = Math.sin(Math.random()*2*Math.PI) * r * Math.random();
+ var y = Math.cos(Math.random()*2*Math.PI) * r * Math.random();
+ var obj = {};
+ obj.uuid = Utils.uuidv4();
+ obj.extent = [[x, y], [100, 120]];
+ obj.name = 'asteroid';
+ obj.spin = Math.random()*1.4+0.7;
+ if (Math.random() < 0.5) {
+ obj.spin = -obj.spin;
+ }
+ Grid.add(ent_grid, obj);
+}
+
+function init() {
+ var grid = world_grid;
+
+ var total = 100;
+ for(var i=0;i<total;i++) {
+ var x = Math.sin(i*2*Math.PI / total) * playfield_radius;
+ var y = Math.cos(i*2*Math.PI / total) * playfield_radius;
+ var obj = {};
+ obj.uuid = Utils.uuidv4();
+ obj.extent = [[x, y], [100, 120]];
+ obj.name = 'Rock';
+ Grid.add(world_grid, obj);
+ }
+ for(var i=0;i<50;i++) {
+ addAsteroid();
+ }
+}
+
+/*
+ for (var y = 0; y < 20; y++) {
+ tiles[y] = [];
+ for (var x = 0; x < 20; x++) {
+ var obj = {};
+ obj.uuid = Utils.uuidv4();
+ obj.extent = [[x * 100, y * 120], [100, 120]];
+ obj.name = 'DirtBlock';
+ if ((x == 3 && y == 3) || (x == 14 && y == 3))
+ obj.name = 'Rock';
+ Grid.add(grid, obj);
+ tiles[y][x] = obj;
+ }
+ }
+*/
+
+
+function tagTile(user,uuid,tile_pos) {
+ user.color = gem_names[(user.idx % gem_names.length)];
+ var x = parseInt(tile_pos[0]);
+ var y = parseInt(tile_pos[1]);
+ if (tiles[y])
+ var obj = tiles[y][x];
+ if (obj && obj.name != user.color) {
+ Grid.transform(world_grid, uuid, {name: user.color});
+ fillConnected(x, y, user.color);
+ }
+}
+
+function getVal(t,x,y) {
+ var line = t[y];
+ if (line) {
+ var obj = line[x];
+ if (obj) {
+ return obj.name;
+ }
+ }
+}
+
+function checkPerimeter(start_x,start_y,end_x,end_y,match)
+{
+ var x, y;
+
+ for (x = start_x; x <= end_x; x++) {
+ if (getVal(tiles, x, start_y) == match || getVal(tiles, x, end_y) == match) {
+ return 1;
+ }
+ }
+ for (y = start_y; y <= end_y; y++) {
+ if (getVal(tiles, start_x, y) == match || getVal(tiles, end_x, y) == match) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+function getBounds(x,y,match) {
+ var start_x = x;
+ var end_x = x;
+ var start_y = y;
+ var end_y = y;
+ for (;;) {
+ start_x = Math.max(start_x - 1, -1);
+ start_y = Math.max(start_y - 1, -1);
+ end_x = Math.min(end_x + 1, tiles[0].length);
+ end_y = Math.min(end_y + 1, tiles.length);
+ if (!checkPerimeter(start_x, start_y, end_x, end_y, match))
+ break;
+ // console.log('curr: ' + [start_x,start_y]+' '+[end_x,end_y]);
+ }
+ //console.log('bounds: '+[end_x-start_x,end_y-start_y]+' '+
+ //[start_x,start_y] + ' to ' + [end_x,end_y]);
+ return [[start_x, start_y], [end_x, end_y]];
+}
+
+function printRect(rect) {
+ var txt = '';
+ for (var y = 0; y < rect.length; y++) {
+ for (var x = 0; x < rect[y].length; x++) {
+ txt += ' ' + rect[y][x];
+ }
+ txt += '\n';
+ }
+ //console.log(txt);
+}
+
+function fillConnected(x,y,match) {
+ var bounds = getBounds(x, y, match);
+ var min = bounds[0];
+ var max = bounds[1];
+ var rect = [];
+ for (var y = min[1]; y <= max[1]; y++) {
+ var line = [];
+ for (var x = min[0]; x <= max[0]; x++) {
+ var val = getVal(tiles, x, y);
+ line.push(val ? val : 0);
+ }
+ rect.push(line);
+ }
+ // console.log('rect size: ' + [rect.length,rect[0].length]);
+ printRect(rect);
+ var count = floodFill(rect, 0, 0, match);
+ //console.log('result');
+ printRect(rect);
+ if (giveBonus(rect, min, max, match)) {
+ clearPerimeter(rect, min, max, match);
+ }
+}
+
+
+function giveBonus(rect,min,max,match) {
+ var bonus = 0;
+ for (var y = 0; y < rect.length; y++) {
+ for (var x = 0; x < rect[y].length; x++) {
+ var tx = x + min[0];
+ var ty = y + min[1];
+ var obj = tiles[ty] && tiles[ty][tx];
+ if (rect[y][x] != match) {
+ Grid.transform(world_grid, obj.uuid, {name: 'star'});
+ bonus++;
+ }
+ }
+ }
+ return bonus;
+}
+
+function clearPerimeter(rect,min,max,match) {
+ for (var y = 0; y < rect.length; y++) {
+ for (var x = 0; x < rect[y].length; x++) {
+ var tx = x + min[0];
+ var ty = y + min[1];
+ var obj = tiles[ty] && tiles[ty][tx];
+ if (obj && obj.name == match) {
+ Grid.transform(world_grid, obj.uuid, {name: 'star'});
+ }
+ }
+ }
+}
+
+var Stack = [];
+
+function floodFill(rect, x, y, match) {
+ fillPixel(rect, x, y, match);
+
+ while (Stack.length > 0) {
+ toFill = Stack.pop();
+ fillPixel(rect, toFill[0], toFill[1], match);
+ }
+}
+
+function fillPixel(rect, x, y, match) {
+ if (!alreadyFilled(rect, x, y, match)) fill(rect, x, y, match);
+
+ if (!alreadyFilled(rect, x, y - 1, match)) Stack.push([x, y - 1]);
+ if (!alreadyFilled(rect, x + 1, y, match)) Stack.push([x + 1, y]);
+ if (!alreadyFilled(rect, x, y + 1, match)) Stack.push([x, y + 1]);
+ if (!alreadyFilled(rect, x - 1, y, match)) Stack.push([x - 1, y]);
+}
+
+function fill(rect, x, y, match) {
+ rect[y][x] = match;
+}
+
+function alreadyFilled(rect, x, y, match) {
+ var line = rect[y];
+ if (!line) {
+ return true;
+ }
+ if (line[x] == undefined) {
+ return true;
+ }
+ return line[x] == match;
+}
+
+
+function shoot(user,pos,vel) {
+ var obj = {};
+ obj.uuid = Utils.uuidv4();
+ obj.extent = [pos, [32, 32]];
+ obj.name = shots[user.idx % shots.length];
+ obj.vel = Vec.scale(vel,40);
+ obj.ttl = 50;
+ obj.shot = 1;
+ obj.owner = user.owned_uuid;
+ obj = Grid.add(ent_grid, obj);
+ live_ents.push(obj);
+ console.log('shoot: '+pos+' ' + vel);
+}
+
+function explode(user, uuid) {
+ var hit = Grid.findById(ent_grid, uuid);
+ if (!hit || hit.name != 'asteroid') {
+ return;
+ }
+ Grid.transform(ent_grid, uuid, {name: 'boom', frame: 0, spin: 1});
+ hit.ttl = 59;
+ live_ents.push(hit);
+ var pos = Utils.clone(hit.extent[0]);
+ var uuid = Utils.uuidv4();
+ var obj = { uuid:uuid, name:'powerup', ttl:400, extent:[pos, [100, 100]] };
+ obj = Grid.add(ent_grid, obj);
+ live_ents.push(obj);
+ addAsteroid();
+ var owner = Grid.findById(ent_grid,user.owned_uuid);
+ if (owner) {
+ var points = (owner.points || 0) + 1;
+ Grid.transform(ent_grid, user.owned_uuid, {points:points});
+ }
+}
+
+function tick() {
+ for(var i=live_ents.length-1;i>=0;i--) {
+ var ent = live_ents[i];
+ if (ent.vel) {
+ var extent = Utils.clone(ent.extent);
+ extent[0] = Vec.add(ent.extent[0], ent.vel);
+ Grid.transform(ent_grid, ent.uuid, {extent: extent});
+ }
+ if (--ent.ttl <= 0) {
+ Grid.remove(ent_grid,ent.uuid);
+ live_ents.splice(i,1);
+ }
+ }
+}
+
+exports.tick = tick;
+exports.shoot = shoot;
+exports.explode = explode;
+exports.init = init;
+exports.tagTile = tagTile;
+exports.grids = g_grids;
+
93 lib/users.js
@@ -0,0 +1,93 @@
+// Copyright 2004-present Facebook. All Rights Reserved.
+
+// Licensed under the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License. You may obtain
+// a copy of the License at
+
+// http://www.apache.org/licenses/LICENSE-2.0
+
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations
+// under the License.
+
+var sessions = {};
+var user_count = 0;
+
+function findSession(id) {
+ if (sessions[id])
+ return sessions[id];
+ return 0;
+}
+
+function addSession() {
+ var user;
+ var curdate = new Date();
+ var msec = Date.parse(curdate.toGMTString());
+ var t = parseInt(Math.random() * 100000000, 10) + (msec % 10000);
+ user = sessions[t] = {
+ 'response': null,
+ 'req_id': null,
+ 'commands': [],
+ 'id': t,
+ grid_caches: [],
+ view_pos: [0, 0],
+ view_size: [1024, 1024],
+ idx: user_count,
+ grids: SvrGame.grids
+ };
+ user.time = user.last_recv_time = user.last_send_time = curdate.getTime();
+ user.name = 'guest_' + ++user_count;
+ user.grids = SvrGame.grids;
+
+ for (var i = 0; i < user.grids.length; i++) {
+ user.grid_caches[i] = { cell_versions: [], obj_trackers: {} };
+ }
+
+ return user;
+}
+
+function setView(user,pos,size)
+{
+ user.view_pos = pos;
+ user.view_size = size;
+ GridSvr.sendUpdates(user);
+}
+
+function linkToUser(user,uuid) {
+ var grid = user.grids[1];
+ Grid.transform(grid, uuid, {user_name: user.name, owner_id: user.id});
+ var obj = Grid.findById(grid, uuid);
+ if (obj) {
+ console.log('set user avatar name to: ' + obj.user_name);
+ }
+ console.log('linked ' + uuid + ' to ' + user.id);
+ user.owned_uuid = uuid;
+}
+
+function removeSession(id) {
+ var user = sessions[id];
+ if (user) {
+ if (user.owned_uuid)
+ GridSvr.remove(user, 1, user.owned_uuid);
+ delete sessions[id];
+ console.log('deleted session: ' + id);
+ for (var i in sessions)
+ Comm.toClient(sessions[i], 'disconnected', id);
+ }
+}
+
+function logout(user) {
+ console.log('logout: ' + user.id);
+ removeSession(user.id);
+}
+
+
+exports.linkToUser = linkToUser;
+exports.sessions = sessions;
+exports.setView = setView;
+exports.findSession = findSession;
+exports.addSession = addSession;
+exports.removeSession = removeSession;
+exports.logout = logout;
13 license.txt
@@ -0,0 +1,13 @@
+Copyright 2011 Facebook, Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may
+not use this file except in compliance with the License. You may obtain
+a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+License for the specific language governing permissions and limitations
+under the License.
4 logs/.nfs0000000003ac66b500000003
@@ -0,0 +1,4 @@
+[Mon, 17 Jan 2011 23:37:42 GMT] guest_1 info: Chrome 10 212.83796653792763 {"canvas":{"aa":[{"score":755,"path":"canvas_background:true "},{"score":747,"path":"canvas_background:false canvas_bake_background:true "},{"score":734,"path":"canvas_background:false canvas_bake_background:false "}],"rot":[{"score":43,"path":"canvas_background:true "},{"score":39,"path":"canvas_background:false canvas_bake_background:false "},{"score":37,"path":"canvas_background:false canvas_bake_background:true "}]},"html":{"aa":[{"score":602,"path":"update_existing:true use_div_background:true rotate_only:true css_transitions:true "},{"score":592,"path":"update_existing:true use_div_background:true rotate_only:false css_transitions:true "},{"score":565,"path":"update_existing:true use_div_background:false rotate_only:true css_transitions:true "},{"score":554,"path":"update_existing:true use_div_background:false rotate_only:false css_transitions:true "},{"score":379,"path":"update_existing:true use_div_background:false rotate_only:false css_transitions:false "},{"score":377,"path":"update_existing:true use_div_background:false rotate_only:true css_transitions:false "},{"score":372,"path":"update_existing:true use_div_background:true rotate_only:false css_transitions:false "},{"score":353,"path":"update_existing:true use_div_background:true rotate_only:true css_transitions:false "},{"score":321,"path":"update_existing:false use_div_background:true rotate_only:true css_transitions:false "},{"score":307,"path":"update_existing:false use_div_background:true rotate_only:false css_transitions:false "},{"score":266,"path":"update_existing:false use_div_background:false rotate_only:true css_transitions:false "},{"score":261,"path":"update_existing:false use_div_background:false rotate_only:false css_transitions:false "}],"rot":[{"score":60,"path":"update_existing:true use_div_background:true rotate_only:true css_transitions:true "},{"score":60,"path":"update_existing:true use_div_background:true rotate_only:false css_transitions:false "},{"score":59,"path":"update_existing:true use_div_background:false rotate_only:true css_transitions:false "},{"score":58,"path":"update_existing:false use_div_background:true rotate_only:true css_transitions:false "},{"score":57,"path":"update_existing:true use_div_background:true rotate_only:false css_transitions:true "},{"score":56,"path":"update_existing:false use_div_background:false rotate_only:false css_transitions:false "},{"score":54,"path":"update_existing:true use_div_background:false rotate_only:false css_transitions:false "},{"score":54,"path":"update_existing:true use_div_background:false rotate_only:false css_transitions:true "},{"score":54,"path":"update_existing:false use_div_background:true rotate_only:false css_transitions:false "},{"score":53,"path":"update_existing:true use_div_background:true rotate_only:true css_transitions:false "},{"score":51,"path":"update_existing:true use_div_background:false rotate_only:true css_transitions:true "},{"score":50,"path":"update_existing:false use_div_background:false rotate_only:true css_transitions:false "}]},"score":212.83796653792763}
+[Tue, 18 Jan 2011 00:14:48 GMT] guest_26 info: Chrome 10 213.89249636207438 {"canvas":{"aa":[{"score":750,"path":"canvas_background:true "},{"score":749,"path":"canvas_background:false canvas_bake_background:true "},{"score":747,"path":"canvas_background:false canvas_bake_background:false "}],"rot":[{"score":45,"path":"canvas_background:false canvas_bake_background:false "},{"score":41,"path":"canvas_background:true "},{"score":39,"path":"canvas_background:false canvas_bake_background:true "}]},"html":{"aa":[{"score":634,"path":"update_existing:true use_div_background:true rotate_only:false css_transitions:true "},{"score":592,"path":"update_existing:true use_div_background:true rotate_only:true css_transitions:true "},{"score":559,"path":"update_existing:true use_div_background:false rotate_only:true css_transitions:true "},{"score":558,"path":"update_existing:true use_div_background:false rotate_only:false css_transitions:true "},{"score":364,"path":"update_existing:true use_div_background:false rotate_only:false css_transitions:false "},{"score":357,"path":"update_existing:true use_div_background:false rotate_only:true css_transitions:false "},{"score":352,"path":"update_existing:true use_div_background:true rotate_only:false css_transitions:false "},{"score":340,"path":"update_existing:true use_div_background:true rotate_only:true css_transitions:false "},{"score":302,"path":"update_existing:false use_div_background:true rotate_only:true css_transitions:false "},{"score":300,"path":"update_existing:false use_div_background:true rotate_only:false css_transitions:false "},{"score":244,"path":"update_existing:false use_div_background:false rotate_only:true css_transitions:false "},{"score":236,"path":"update_existing:false use_div_background:false rotate_only:false css_transitions:false "}],"rot":[{"score":61,"path":"update_existing:true use_div_background:true rotate_only:true css_transitions:false "},{"score":59,"path":"update_existing:true use_div_background:true rotate_only:false css_transitions:true "},{"score":52,"path":"update_existing:true use_div_background:true rotate_only:true css_transitions:true "},{"score":51,"path":"update_existing:false use_div_background:true rotate_only:false css_transitions:false "},{"score":49,"path":"update_existing:true use_div_background:true rotate_only:false css_transitions:false "},{"score":44,"path":"update_existing:true use_div_background:false rotate_only:true css_transitions:true "},{"score":44,"path":"update_existing:true use_div_background:false rotate_only:true css_transitions:false "},{"score":43,"path":"update_existing:true use_div_background:false rotate_only:false css_transitions:true "},{"score":43,"path":"update_existing:true use_div_background:false rotate_only:false css_transitions:false "},{"score":41,"path":"update_existing:false use_div_background:true rotate_only:true css_transitions:false "},{"score":37,"path":"update_existing:false use_div_background:false rotate_only:true css_transitions:false "},{"score":32,"path":"update_existing:false use_div_background:false rotate_only:false css_transitions:false "}]},"score":213.89249636207438}
+[Tue, 18 Jan 2011 00:24:23 GMT] guest_39 info: Safari 533 499.2274030940209 {"canvas":{"aa":[{"score":90,"path":"canvas_background:true "},{"score":84,"path":"canvas_background:false canvas_bake_background:false "},{"score":83,"path":"canvas_background:false canvas_bake_background:true "}],"rot":[{"score":53,"path":"canvas_background:false canvas_bake_background:true "},{"score":44,"path":"canvas_background:true "},{"score":43,"path":"canvas_background:false canvas_bake_background:false "}]},"html":{"aa":[{"score":387,"path":"update_existing:true use_div_background:true rotate_only:true css_transitions:true "},{"score":365,"path":"update_existing:true use_div_background:false rotate_only:false css_transitions:true "},{"score":364,"path":"update_existing:true use_div_background:true rotate_only:false css_transitions:true "},{"score":330,"path":"update_existing:true use_div_background:false rotate_only:true css_transitions:true "},{"score":313,"path":"update_existing:true use_div_background:false rotate_only:true css_transitions:false "},{"score":307,"path":"update_existing:true use_div_background:false rotate_only:false css_transitions:false "},{"score":278,"path":"update_existing:false use_div_background:true rotate_only:true css_transitions:false "},{"score":277,"path":"update_existing:false use_div_background:true rotate_only:false css_transitions:false "},{"score":267,"path":"update_existing:true use_div_background:true rotate_only:false css_transitions:false "},{"score":266,"path":"update_existing:true use_div_background:true rotate_only:true css_transitions:false "},{"score":219,"path":"update_existing:false use_div_background:false rotate_only:true css_transitions:false "},{"score":219,"path":"update_existing:false use_div_background:false rotate_only:false css_transitions:false "}],"rot":[{"score":644,"path":"update_existing:true use_div_background:false rotate_only:false css_transitions:true "},{"score":148,"path":"update_existing:true use_div_background:true rotate_only:false css_transitions:true "},{"score":47,"path":"update_existing:true use_div_background:false rotate_only:true css_transitions:true "},{"score":40,"path":"update_existing:true use_div_background:true rotate_only:false css_transitions:false "},{"score":37,"path":"update_existing:true use_div_background:true rotate_only:true css_transitions:false "},{"score":36,"path":"update_existing:true use_div_background:false rotate_only:true css_transitions:false "},{"score":34,"path":"update_existing:false use_div_background:false rotate_only:false css_transitions:false "},{"score":33,"path":"update_existing:false use_div_background:true rotate_only:true css_transitions:false "},{"score":33,"path":"update_existing:false use_div_background:false rotate_only:true css_transitions:false "},{"score":33,"path":"update_existing:true use_div_background:false rotate_only:false css_transitions:false "},{"score":30,"path":"update_existing:true use_div_background:true rotate_only:true css_transitions:true "},{"score":30,"path":"update_existing:false use_div_background:true rotate_only:false css_transitions:false "}]},"score":499.2274030940209}
+[Tue, 18 Jan 2011 02:50:09 GMT] guest_19 info: Firefox 3 10.392304845413264 {"canvas":{"aa":[{"score":1,"path":"canvas_background:true "},{"score":1,"path":"canvas_background:false canvas_bake_background:true "},{"score":1,"path":"canvas_background:false canvas_bake_background:false "}],"rot":[{"score":1,"path":"canvas_background:true "},{"score":1,"path":"canvas_background:false canvas_bake_background:true "},{"score":1,"path":"canvas_background:false canvas_bake_background:false "}]},"html":{"aa":[{"score":9,"path":"update_existing:false use_div_background:true rotate_only:false css_transitions:false "},{"score":7,"path":"update_existing:true use_div_background:true rotate_only:true css_transitions:false "},{"score":6,"path":"update_existing:false use_div_background:true rotate_only:true css_transitions:false "},{"score":5,"path":"update_existing:true use_div_background:false rotate_only:true css_transitions:false "},{"score":5,"path":"update_existing:true use_div_background:true rotate_only:false css_transitions:false "},{"score":5,"path":"update_existing:true use_div_background:false rotate_only:false css_transitions:false "},{"score":4,"path":"update_existing:false use_div_background:false rotate_only:true css_transitions:false "},{"score":4,"path":"update_existing:false use_div_background:false rotate_only:false css_transitions:false "}],"rot":[{"score":12,"path":"update_existing:true use_div_background:false rotate_only:false css_transitions:false "},{"score":9,"path":"update_existing:true use_div_background:false rotate_only:true css_transitions:false "},{"score":9,"path":"update_existing:false use_div_background:false rotate_only:true css_transitions:false "},{"score":7,"path":"update_existing:false use_div_background:false rotate_only:false css_transitions:false "},{"score":5,"path":"update_existing:true use_div_background:true rotate_only:true css_transitions:false "},{"score":5,"path":"update_existing:false use_div_background:true rotate_only:true css_transitions:false "},{"score":5,"path":"update_existing:false use_div_background:true rotate_only:false css_transitions:false "},{"score":4,"path":"update_existing:true use_div_background:true rotate_only:false css_transitions:false "}]},"score":10.392304845413264}
103 public/css/style.css
@@ -0,0 +1,103 @@
+/*
+ Copryright 2004-present Facebook, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
+ not use this file except in compliance with the License. You may obtain
+ a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ License for the specific language governing permissions and limitations
+ under the License.
+*/
+
+* {
+ -webkit-touch-callout: none;
+ -moz-user-select: none;
+ -khtml-user-select: none;
+ -webkit-user-select: none;
+ -khtml-user-drag: none;
+ -webkit-user-drag: none;
+ user-select: none;
+ draggable: false;
+}
+
+img {
+ border: 0;
+}
+
+body {
+ font-family:'Lucida Grande',Tahoma,Verdana,Arial,sans-serif;
+ background:#FFFFFF;
+ font-size: 11px;
+}
+
+#gamebody {
+ overflow:auto;
+}
+
+div {
+ -webkit-transform: rotate(0deg);
+ -moz-transform: rotate(0deg);
+}
+
+.ui_html {
+ background: #3B5998;
+ border: 1px solid #BDC7D8;
+ color: #000000;
+ white-space: nowrap;
+}
+
+.ui_button {
+ color: #ffffff;
+ background: #5B74A8;
+ border-style: solid;
+ border-width: 1px;
+ border-color: #29447E #29447E #1A356E;
+ white-space: nowrap;
+}
+
+.spriteholder {
+ position:absolute;
+}
+
+.sprite {
+ position:absolute;
+}
+
+.gameviewport {
+ border-top:1px solid #cccccc;
+}
+
+.testtype {
+ margin: 2px;
+}
+
+.perfblock {
+ background: #3B5998;
+ border: 1px solid #BDC7D8;
+}
+
+.perfscore {
+ font-size:45px;
+}
+
+.perfavescore {
+ font-size:24px;
+}
+
+.browsername {
+ font-size:24px;
+}
+
+.renderdetails {
+ font-size:15px;
+ line-height:15px
+}
+
+.center {
+ text-align: center;
+}
48 public/index.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+
+<html>
+
+<head>
+ <meta name="viewport" content="user-scalable=no, width=device-width, height=device-height, initial-scale=0.5, maximum-scale=0.5"/>
+ <meta name="apple-mobile-web-app-capable" content="yes" />
+ <meta name="apple-touch-fullscreen" content="yes" />
+ <meta name="apple-mobile-web-app-status-bar-style" content="black" />
+ <link rel="stylesheet" type="text/css" href="/public/css/style.css" />
+ <script type="text/javascript" src="/socket.io/socket.io.js"></script>
+ <script type="text/javascript" src="/public/javascript/json2.min.js"></script>
+ <script type="text/javascript" src="/public/javascript/globals.js"> </script>
+ <script type="text/javascript" src="/public/javascript/tick.js"> </script>
+ <script type="text/javascript" src="/public/javascript/clientutils.js"> </script>
+ <script type="text/javascript" src="/public/javascript/shared/utils.js"> </script>
+ <script type="text/javascript" src="/public/javascript/shared/math.js"> </script>
+ <script type="text/javascript" src="/public/javascript/shared/vec.js"> </script>
+ <script type="text/javascript" src="/public/javascript/shared/grid.js"> </script>
+ <script type="text/javascript" src="/public/javascript/shared/gridclient.js"> </script>
+ <script type="text/javascript" src="/public/javascript/gameframe.js"> </script>
+ <script type="text/javascript" src="/public/javascript/ui.js"> </script>
+ <script type="text/javascript" src="/public/javascript/gob.js"> </script>
+ <script type="text/javascript" src="/public/javascript/world.js"> </script>
+ <script type="text/javascript" src="/public/javascript/sprites.js"> </script>
+ <script type="text/javascript" src="/public/javascript/render.js"> </script>
+ <script type="text/javascript" src="/public/javascript/dom_render.js"> </script>
+ <script type="text/javascript" src="/public/javascript/canvas_render.js"> </script>