This diff moves the code of the researched technology to a separate class and uses object orientation of course in the #5387.
The code for this already is free of defects, it couldn't be changed in any way without breaking it.
The patch improves the performance by doing less engine GetGUIObjectByName calls, by not reassigning onPress:
Unpatched:
332 201 187 193 183 283 185 178 178 175 176 181 187 181 174 189 178 170 198 185 184 177 182 184 194 198 188 176 189 174 239 184 174 175 313 176 177 174 175 175 172 172 222 214 173 158 167 161 163 165 171 159 174 167 162 163 169 182 159 162 160 171 187 180 189 175 172 171 173 174 171 179 175 171 184 169 171 189 185 173 172 177 181 182 175 172 216 174 176 178 171 173 178 188 173 174 652 473 449 484 492 479 493 1345 485 469 805 496 461 455 483 446 452 456 446 537 468 425 446 443 444 433 454 444 449 442 447 479 517 466 436 450 434 433 438 427 435 431 429 431 444 442 434 463 456 477 507 797 452 491 452 492 475 564 591 445 477 486 467 471 556 470 465 475 458 458 514 480 471 463 455 457 469 447 449 505 447 452 455 457 447 455 449 455 448 483 462 452 657 499 534 420 458 414 430 415 416 441 414 462 436 429 413 445 431 411 404 413 415 892 405 407 421 426 414 412 411 404 416 445 411 433 438 395 420 400 395 438 428 396 403 409 400 409 397 423 415 420 433 399 403 398 398 399 401 444 393 416 397 413 395 389 404 402 402 403 393 425 517 424 403 432 405 403 438 426 397 403 402 450 402 399 428 440 407 401 399 402 515 399 402 399 399 398 414 401 400 405 400 401 410 423 440 399 398 419 155 164 151 152 161 158 151 152 153 149 151 153 153 157 165 155 155 152 151 159 151 152 151 151 150 150 151 150 155 151 153 153 173 152 151 153 155 153 210 159 152 157 152 151 153 155 152 151 154 163 155 152 151 151 153 155 151 162 153 152 156 151 150 151 153 150 158 152 155 150 151 153 152 250 150 148 152 154 151 152 156 153 156
Patched:
167 75 67 70 61 151 52 52 51 52 51 49 49 49 47 47 50 49 48 53 54 49 50 50 47 54 48 53 47 47 52 49 47 48 48 47 48 50 50 58 58 68 65 49 60 50 51 49 51 52 53 48 50 50 49 51 60 51 54 50 48 49 48 47 46 53 51 46 47 52 50 50 49 47 54 51 50 465 374 379 341 342 344 347 344 354 339 507 329 405 333 349 333 353 327 314 333 357 336 315 317 319 316 308 329 319 354 342 333 336 435 346 337 322 322 324 309 325 323 340 319 325 318 315 329 373 345 337 330 372 327 322 324 346 335 347 337 342 335 343 317 322 313 320 330 342 321 326 320 333 394 319 325 319 342 420 411 317 334 312 357 314 317 312 324 318 330 330 392 342 334 328 332 316 361 312 332 315 330 323 317 314 317 338 324 339 366 346 336 329 346 354 344 326 324 322 313 316 313 327 352 318 328 323 339 314 313 331 326 772 314 333 317 315 322 321 309 314 317 333 331 320 347 332 435 324 351 414 379 336 340 338 327 322 314 341 320 311 324 334 333 316 339 314 337 335 309 314 345 320 325 321 394 315 316 334 337 323 358 326 328 326 325 325 584 346 322 320 351 324 316 1154 345 349 345 338 48 53 47 45 47 47 54 46 47 47 46 47 45 47 49 46 49 46 48 49 48 47 50 46 49 50 63 55 46 54 49 51 47 47 57 58 49 53
Also that Math.round is unnecessary.
We notice that the session counter code is called onTick, which sounds unfortunate but possibly necessary by design, otherwise unrelated to this diff.
Notice that the diff does not increase cohesion within the function, but reduces coupling of session.js.