Module: Lich::Main::ArgvOptions::GameConnection

Defined in:
documented/main/argv_options.rb

Overview

Handle game connection configuration

Class Method Summary collapse

Class Method Details

.determine_frontend ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Inspects ARGV to select the active UI frontend (-s, -w, --avalon, etc.).

Searches ARGV for frontend flags in order: -s/--stormfront, -w/--wizard, --avalon, --frostbite, --saga. Returns the first match found, or 'unknown' if none are present.

Returns:

  • (String) —

    one of 'stormfront', 'wizard', 'avalon', 'frostbite', 'saga', or 'unknown'



523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
# File 'documented/main/argv_options.rb', line 523

def self.determine_frontend
  if ARGV.any? { |a| a == '-s' || a == '--stormfront' }
    'stormfront'
  elsif ARGV.any? { |a| a == '-w' || a == '--wizard' }
    'wizard'
  elsif ARGV.any? { |a| a == '--avalon' }
    'avalon'
  elsif ARGV.any? { |a| a == '--frostbite' }
    'frostbite'
  elsif ARGV.any? { |a| a == '--saga' }
    'saga'
  else
    'unknown'
  end
end

.execute(processed_options) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

Called after side effects; modifies global game connection state

Routes ARGV flags to the appropriate game server connection handler and sets game_host, game_port, and $frontend accordingly.

Detects force-mode flags (-g/--game, --shattered, --fallen, or authentication provider flags) and calls the corresponding handler. If no game mode is detected, sets game_host and game_port to nil. Also initializes Common::Frontend from the parent process for normal connections (not detachable-client mode).

Parameters:

Returns:

  • (Hash) —

    the same processed_options hash, updated with :game_host and :game_port keys; side effect is setting global $frontend and $platinum



338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'documented/main/argv_options.rb', line 338

def self.execute(processed_options)
  if (arg = ARGV.find { |a| a == '-g' || a == '--game' })
    handle_explicit_game_connection(arg, processed_options)
  elsif ARGV.include?('--shattered')
    handle_shattered_connection(processed_options)
  elsif ARGV.include?('--fallen')
    handle_fallen_connection(processed_options)
  elsif Lich::Common::Authentication::LoginHelpers.gemstone_flag?(ARGV)
    handle_gemstone_connection(processed_options)
  elsif Lich::Common::Authentication::LoginHelpers.dragonrealms_flag?(ARGV)
    handle_dragonrealms_connection(processed_options)
  else
    processed_options[:game_host] = nil
    processed_options[:game_port] = nil
    Lich.log 'info: no force-mode info given'
  end
  processed_options
end

.handle_dragonrealms_connection(processed_options) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

Sets global $platinum and $frontend

This method returns an undefined value.

Sets game server and frontend for DragonRealms (premium or free play).

Selects the appropriate server port based on --platinum flag and --test flag. Determines frontend from -s/--stormfront, --genie, --avalon, --frostbite, --saga, or defaults to wizard. Stormfront is preferred if specified; Genie is checked next; then the remaining flags in order.

Parameters:

  • processed_options (Hash) —

    the options hash to update with :game_host and :game_port



480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# File 'documented/main/argv_options.rb', line 480

def self.handle_dragonrealms_connection(processed_options)
  if ARGV.include?('--platinum')
    $platinum = true
    if ARGV.any? { |a| a =~ /^-s$/i || a =~ /^--stormfront$/i }
      processed_options[:game_host] = 'dr.simutronics.net'
      processed_options[:game_port] = 11124
      $frontend = 'stormfront'
    elsif ARGV.grep(/--genie/i).any?
      processed_options[:game_host] = 'dr.simutronics.net'
      processed_options[:game_port] = 11124
      $frontend = 'genie'
    else
      processed_options[:game_host] = 'dr.simutronics.net'
      processed_options[:game_port] = 11124
      $frontend = ARGV.any? { |a| a =~ /^--avalon$/i } ? 'avalon' : ARGV.any? { |a| a =~ /^--frostbite$/i } ? 'frostbite' : ARGV.any? { |a| a =~ /^--saga$/i } ? 'saga' : 'wizard'
    end
  else
    $platinum = false
    if ARGV.any? { |a| a =~ /^-s$/i || a =~ /^--stormfront$/i }
      processed_options[:game_host] = 'dr.simutronics.net'
      processed_options[:game_port] = ARGV.include?('--test') ? 11624 : 11024
      $frontend = 'stormfront'
    elsif ARGV.grep(/--genie/i).any?
      processed_options[:game_host] = 'dr.simutronics.net'
      processed_options[:game_port] = ARGV.include?('--test') ? 11624 : 11024
      $frontend = 'genie'
    else
      processed_options[:game_host] = 'dr.simutronics.net'
      processed_options[:game_port] = ARGV.include?('--test') ? 11624 : 11024
      $frontend = ARGV.any? { |a| a =~ /^--avalon$/i } ? 'avalon' : ARGV.any? { |a| a =~ /^--frostbite$/i } ? 'frostbite' : ARGV.any? { |a| a =~ /^--saga$/i } ? 'saga' : 'wizard'
    end
  end
end

.handle_explicit_game_connection(arg, processed_options) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Handles explicit -g/--game mode: parses host:port and sets frontend from ARGV.

Extracts the game server address from ARGV immediately following -g or --game, splits on ':', converts port to Integer, and calls determine_frontend to select the UI. Initializes Common::Frontend from the parent process unless --detachable-client is present.

Parameters:

  • arg (String) —

    the literal '-g' or '--game' flag from ARGV

  • processed_options (Hash) —

    the options hash to update with :game_host and :game_port



369
370
371
372
373
374
375
376
377
# File 'documented/main/argv_options.rb', line 369

def self.handle_explicit_game_connection(arg, processed_options)
  processed_options[:game_host], processed_options[:game_port] = ARGV[ARGV.index(arg) + 1].split(':')
  processed_options[:game_port] = processed_options[:game_port].to_i
  $frontend = determine_frontend
  # Initialize frontend from parent process unless using detachable client
  unless ARGV.any? { |a| a =~ /^--detachable-client/i }
    Lich::Common::Frontend.init_from_parent(Process.ppid)
  end
end

.handle_fallen_connection(processed_options) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

Sets global $frontend and $platinum to false

This method returns an undefined value.

Sets game server and frontend for DragonRealms: Fallen (event realm).

Connects to dr.simutronics.net port 11324. Determines frontend from -s/--stormfront, --genie, --avalon, --frostbite, --saga, or defaults to wizard. Genie is preferred if specified; Stormfront is checked next.

Parameters:

  • processed_options (Hash) —

    the options hash to update with :game_host and :game_port



451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'documented/main/argv_options.rb', line 451

def self.handle_fallen_connection(processed_options)
  $platinum = false
  if ARGV.any? { |a| a =~ /^-s$/i || a =~ /^--stormfront$/i }
    processed_options[:game_host] = 'dr.simutronics.net'
    processed_options[:game_port] = 11324
    $frontend = 'stormfront'
  elsif ARGV.grep(/--genie/i).any?
    processed_options[:game_host] = 'dr.simutronics.net'
    processed_options[:game_port] = 11324
    $frontend = 'genie'
  else
    processed_options[:game_host] = 'dr.simutronics.net'
    processed_options[:game_port] = 11324
    $frontend = ARGV.any? { |a| a =~ /^--avalon$/i } ? 'avalon' : ARGV.any? { |a| a =~ /^--frostbite$/i } ? 'frostbite' : ARGV.any? { |a| a =~ /^--saga$/i } ? 'saga' : 'wizard'
  end
end

.handle_gemstone_connection(processed_options) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

Sets global $platinum and $frontend

This method returns an undefined value.

Sets game server and frontend for GemStone IV (premium or free play).

Selects the appropriate server port based on --platinum flag and --test flag. Determines frontend from -s/--stormfront, --avalon, --frostbite, --saga, or defaults to wizard. Stormfront is preferred if specified; otherwise frontend flags are checked in the order listed.

Parameters:

  • processed_options (Hash) —

    the options hash to update with :game_host and :game_port



391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# File 'documented/main/argv_options.rb', line 391

def self.handle_gemstone_connection(processed_options)
  if ARGV.include?('--platinum')
    $platinum = true
    if ARGV.any? { |a| a =~ /^-s$/i || a =~ /^--stormfront$/i }
      processed_options[:game_host] = 'storm.gs4.game.play.net'
      processed_options[:game_port] = 10124
      $frontend = 'stormfront'
    else
      processed_options[:game_host] = 'storm.gs4.game.play.net'
      processed_options[:game_port] = 10124
      $frontend = ARGV.any? { |a| a =~ /^--avalon$/i } ? 'avalon' : ARGV.any? { |a| a =~ /^--frostbite$/i } ? 'frostbite' : ARGV.any? { |a| a =~ /^--saga$/i } ? 'saga' : 'wizard'
    end
  else
    $platinum = false
    if ARGV.any? { |a| a =~ /^-s$/i || a =~ /^--stormfront$/i }
      processed_options[:game_host] = 'storm.gs4.game.play.net'
      processed_options[:game_port] = ARGV.include?('--test') ? 10624 : 10024
      $frontend = 'stormfront'
    else
      processed_options[:game_host] = 'storm.gs4.game.play.net'
      processed_options[:game_port] = ARGV.include?('--test') ? 10624 : 10024
      $frontend = ARGV.any? { |a| a =~ /^--avalon$/i } ? 'avalon' : ARGV.any? { |a| a =~ /^--frostbite$/i } ? 'frostbite' : ARGV.any? { |a| a =~ /^--saga$/i } ? 'saga' : 'wizard'
    end
  end
end

.handle_shattered_connection(processed_options) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

Sets global $frontend and $platinum to false

This method returns an undefined value.

Sets game server and frontend for GemStone IV: Shattered (event realm).

Connects to storm.gs4.game.play.net port 10324. Determines frontend from -s/--stormfront, --avalon, --frostbite, --saga, or defaults to wizard.

Parameters:

  • processed_options (Hash) —

    the options hash to update with :game_host and :game_port



427
428
429
430
431
432
433
434
435
436
437
438
# File 'documented/main/argv_options.rb', line 427

def self.handle_shattered_connection(processed_options)
  $platinum = false
  if ARGV.any? { |a| a =~ /^-s$/i || a =~ /^--stormfront$/i }
    processed_options[:game_host] = 'storm.gs4.game.play.net'
    processed_options[:game_port] = 10324
    $frontend = 'stormfront'
  else
    processed_options[:game_host] = 'storm.gs4.game.play.net'
    processed_options[:game_port] = 10324
    $frontend = ARGV.any? { |a| a =~ /^--avalon$/i } ? 'avalon' : ARGV.any? { |a| a =~ /^--frostbite$/i } ? 'frostbite' : ARGV.any? { |a| a =~ /^--saga$/i } ? 'saga' : 'wizard'
  end
end