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.

Returns the frontend identifier from command-line flags.

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

Returns:

  • (String) —

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



578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
# File 'documented/main/argv_options.rb', line 578

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.

Configures game server host and port based on command-line flags.

Routes to specialized handlers:

- Explicit -g/--game flag: uses the next ARGV element as host:port
- --shattered: connects to Shattered (GemStone IV test realm)
- --fallen: connects to Fallen (DragonRealms test realm)
- --gemstone or -g flag: connects to main GemStone IV server
- --dragonrealms or -d flag: connects to main DragonRealms server
- None of the above: sets game_host and game_port to nil and logs info

Also sets $platinum and $frontend based on detected flags (--platinum, --stormfront, --avalon, --frostbite, --saga, --wizard, --genie).

Parameters:

  • processed_options (Hash) —

    the options hash to modify

Returns:

  • (Hash) —

    the same processed_options with :game_host, :game_port set



403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'documented/main/argv_options.rb', line 403

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.

This method returns an undefined value.

Configures connection to the main DragonRealms server.

Sets game_host to dr.simutronics.net and determines game_port based on flags: 11124 for Platinum, 11024 for standard, 11624 for --test. Determines frontend preference from flags (--stormfront, --genie, --avalon, --frostbite, --saga) with --wizard as fallback. Sets $platinum flag accordingly.

Parameters:

  • processed_options (Hash) —

    the options hash to modify



536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
# File 'documented/main/argv_options.rb', line 536

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.

Configures an explicit game server from the -g/--game flag argument.

Retrieves the argument immediately following -g or --game in ARGV, splits it on ':', and stores the host and port (converted to Integer). Determines the frontend and calls Frontend.init_from_parent unless --detachable-client is set.

Parameters:

  • arg (String) —

    the matched -g or --game flag

  • processed_options (Hash) —

    the options hash to modify with :game_host, :game_port



432
433
434
435
436
437
438
439
440
# File 'documented/main/argv_options.rb', line 432

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.

This method returns an undefined value.

Configures connection to the Fallen realm (DragonRealms test).

Sets game_host to dr.simutronics.net and game_port to 11324. Determines frontend preference from flags (--stormfront, --genie, --avalon, --frostbite, --saga) with --wizard as fallback. Sets $platinum to false.

Parameters:

  • processed_options (Hash) —

    the options hash to modify



509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# File 'documented/main/argv_options.rb', line 509

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.

This method returns an undefined value.

Configures connection to the main GemStone IV server.

Sets game_host to storm.gs4.game.play.net and determines game_port based on flags: 10124 for Platinum, 10024 for standard, 10624 for --test. Determines frontend preference from flags (--stormfront, --avalon, --frostbite, --saga) with --wizard as fallback. Sets $platinum flag accordingly.

Parameters:

  • processed_options (Hash) —

    the options hash to modify



452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
# File 'documented/main/argv_options.rb', line 452

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.

This method returns an undefined value.

Configures connection to the Shattered realm (GemStone IV test).

Sets game_host to storm.gs4.game.play.net and game_port to 10324. Determines frontend preference from flags (--stormfront, --avalon, --frostbite, --saga) with --wizard as fallback. Sets $platinum to false.

Parameters:

  • processed_options (Hash) —

    the options hash to modify



487
488
489
490
491
492
493
494
495
496
497
498
# File 'documented/main/argv_options.rb', line 487

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