Changeset 638 for trollforge/lastmeasure
- Timestamp:
- 01/20/12 00:45:53 (17 months ago)
- File:
-
- 1 edited
-
trollforge/lastmeasure/server/lmresource.h (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trollforge/lastmeasure/server/lmresource.h
r637 r638 13 13 //#include "lmutil.h" 14 14 15 #if ndef SOFT16 static size_t imagecount = 33; 15 #ifdef SOFT 16 # define IMAGES_PREFIX "/soft/" 17 17 #else 18 static size_t imagecount = 13; 18 # define IMAGES_PREFIX "/images/" 19 19 #endif 20 21 static size_t audiocount = 16;22 20 23 21 static char const *staticnames[] = 24 22 { 25 #ifndef SOFT 26 /* Static images - 33 */ 23 /* Shock pictures */ 27 24 "/images/awesome.jpg", "/images/Pain4.jpg", 28 25 "/images/balloonboy.jpg", "/images/Pain5.jpg", … … 42 39 "/images/Pain3.jpg", "/images/jar.jpg", 43 40 "/images/lunch.jpg", 44 #else 45 /* S tatic soft images - 13*/41 42 /* Soft images */ 46 43 "/soft/christmas.jpg", "/soft/pillowfight.jpg", 47 44 "/soft/eww.jpg", "/soft/pooped.jpg", … … 51 48 "/soft/loopback.jpg", "/soft/weightlifter.jpg", 52 49 "/soft/ouch.jpg", 53 #endif 54 55 /* Static sound samples - 16 */ 50 51 /* Static sound samples */ 56 52 "/audio/abez2.wav", "/audio/abez.wav", 57 53 "/audio/blackman.wav", "/audio/eska.wav", … … 154 150 155 151 " <body style=\"background-image: url(http://" << host 156 #ifndef SOFT 157 << RandomAsset("/images/") << "); background-color: #FFFFFF;\"" 158 #else 159 << RandomAsset("/soft/") << "); background-color: #FFFFFF;\"" 160 #endif 152 << RandomAsset(IMAGES_PREFIX) << "); background-color: #FFFFFF;\"" 161 153 "\r\n onload=\"bookmark(); noframes(); load_goatse(); document.getElementById('goatse').innerHTML = ''; movew0w(); "; 162 154 if (is_ie6) … … 217 209 { 218 210 data << 219 220 "<div>\r\n"221 211 // This object plays the "hey everybody, I'm looking at gay porno!" sound 222 212 "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" " … … 227 217 "<script type=\"text/javascript\">\r\n" 228 218 "<!--\r\n" 229 "var audio = new Array();\r\n" 230 "var audiocount = " << audiocount << ";\r\n"; 231 232 for(size_t i = 0; i < audiocount; i++) { 233 data << " audio[" << i << "] = 'http://" << host << "" << staticnames[i+imagecount] << "';\r\n"; 219 "var audio = new Array();\r\n"; 220 221 for (int i = FindAssetIndex("/audio/", -1), n = 0; 222 i < (int)NSTATICS; 223 i = FindAssetIndex("/audio/", i)) 224 { 225 data << " audio[" << n << "] = 'http://" 226 << host << "" << staticnames[i] << "';\r\n"; 234 227 } 235 228 236 229 data << 237 238 "for (i = 0; i < audiocount; i++) {\r\n" 230 "for (i = 0; i < audio.length; i++) {\r\n" 239 231 " setTimeout('document.getElementById(\"audio\").innerHTML += \\'<embed src=\"' + audio[i] + '\" loop=\"true\" />\\';', 6000 * (i/2));\r\n" 240 232 "}\r\n" … … 260 252 << host << "/" << rand() 261 253 << "\">something else</a>.</p>" 262 #ifndef SOFT 263 << "<img src=\"http://" << host << "" << RandomAsset("/images/") << "\" />" 264 #else 265 << "<img src=\"http://" << host << "" << RandomAsset("/soft/") << "\" />" 266 #endif 254 << "<img src=\"http://" << host << "" << RandomAsset(IMAGES_PREFIX) << "\" />" 267 255 << "</body></html>"; 268 256 return Response(data.str(), "text/html"); … … 449 437 } 450 438 439 /* Pick a random asset starting with @prefix. For instance if @prefix 440 * is "/images/" we pick one at random and if it starts with "/images/" 441 * we return it. Otherwise, pick another one. Repeat 32 times. */ 451 442 static std::string RandomAsset(char const *prefix) 452 443 { 453 444 size_t prefixlen = strlen(prefix); 454 445 455 for ( size_t i = 0; i < 32; i++) // XXX Why 32?446 for (int i = 0; i < 32; i++) 456 447 { 457 448 char const *name = staticnames[rand() % NSTATICS]; … … 463 454 } 464 455 456 /* Find the asset index after @previous that matches @prefix. This can 457 * be used as an iterator. To get the first matching asset, use -1 as 458 * an argument. */ 459 static int FindAssetIndex(char const *prefix, int previous) 460 { 461 if (previous < -1 || previous > (int)NSTATICS) 462 return NSTATICS; 463 464 size_t prefixlen = strlen(prefix); 465 466 while (++previous < (int)NSTATICS) 467 { 468 char const *name = staticnames[previous]; 469 if (!strncmp(name, prefix, prefixlen)) 470 break; 471 } 472 473 return previous; 474 } 475 465 476 static std::string MoveAround(size_t width, size_t height, char const *host) 466 477 { … … 468 479 469 480 ret << 470 471 481 "<script type=\"text/javascript\">\r\n" 472 482 "<!--\r\n" 473 " var images = new Array();\r\n" 474 " var imagecount = " << imagecount << ";\r\n"; 475 476 for(size_t i = 0; i < imagecount; i++) 477 { 478 ret << " images[" << i << "] = 'http://" << host << "" << staticnames[i] << "';\r\n"; 483 " var images = new Array();\r\n"; 484 485 for (int i = FindAssetIndex(IMAGES_PREFIX, -1), n = 0; 486 i < (int)NSTATICS; 487 i = FindAssetIndex(IMAGES_PREFIX, i)) 488 { 489 ret << " images[" << n << "] = 'http://" << host << "" << staticnames[i] << "';\r\n"; 479 490 } 480 491 … … 505 516 " }\r\n" 506 517 507 " document.body.background = images[(Math.floor(curstep) % image count) + 1];\r\n"518 " document.body.background = images[(Math.floor(curstep) % images.length) + 1];\r\n" 508 519 " setTimeout(\"movew0w()\", delay);\r\n" 509 520 "}\r\n"
Note: See TracChangeset
for help on using the changeset viewer.
