From b0db6a8510ee0e34affcb9656becd2fe793e13df Mon Sep 17 00:00:00 2001
From: Jeffrey Phillips Freeman <the@jeffreyfreeman.me>
Date: Sun, 26 Apr 2020 04:27:03 +0200
Subject: [PATCH] Cleaned up the dsplay loading for an existing character on
 login.

---
 conf/config.yaml                    |  2 +-
 lib/aethyr/core/connection/login.rb |  6 +-----
 lib/aethyr/core/objects/player.rb   | 15 ++++++++-------
 3 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/conf/config.yaml b/conf/config.yaml
index 019b2da..7424243 100644
--- a/conf/config.yaml
+++ b/conf/config.yaml
@@ -9,7 +9,7 @@
 :restart_delay: 10
 :address: 0.0.0.0
 :intro_file: intro.txt
-:start_room: c1551b23-e2ef-628a-a7d9-e76a68d2e789
+:start_room: fc511e2c-863e-daf1-87be-6214f59c013a
 :restart_limit: 15
 :mccp: false
 :mssp: false
diff --git a/lib/aethyr/core/connection/login.rb b/lib/aethyr/core/connection/login.rb
index 8f7059a..6d9b73d 100644
--- a/lib/aethyr/core/connection/login.rb
+++ b/lib/aethyr/core/connection/login.rb
@@ -159,12 +159,8 @@ module Login
       return
     end
 
-
-    @display.color_settings = player.color_settings unless player.color_settings.nil?
-    @display.layout(layout: player.layout, in_combat: player.info.in_combat) unless player.layout.nil?
-
     @word_wrap = player.word_wrap
-    player.instance_variable_set(:@player, self)
+    player.set_connection(self)
     $manager.add_object(player)
 
     @player = player
diff --git a/lib/aethyr/core/objects/player.rb b/lib/aethyr/core/objects/player.rb
index c45f4c0..a7c433b 100644
--- a/lib/aethyr/core/objects/player.rb
+++ b/lib/aethyr/core/objects/player.rb
@@ -71,6 +71,12 @@ class Player < LivingObject
     map_skill.add_xp 750
   end
 
+  def set_connection(new_player)
+    @player = new_player
+    @player.display.color_settings = @color_settings
+    @player.display.layout(layout: @layout)
+  end
+
   #called right before saving to temporarily remove volatile data.
   def dehydrate
     volatile_data = super()
@@ -85,11 +91,12 @@ class Player < LivingObject
   end
 
   def layout
-    return nil if @player.display.nil?
+    return @layout if @player.display.nil?
     return @player.display.layout_type
   end
 
   def layout= new_layout
+    @layout = new_layout
     @player.display.layout(layout: new_layout)
     @player.display.refresh_watch_windows(self)
   end
@@ -190,12 +197,6 @@ class Player < LivingObject
     end
   end
 
-  #Just outputs a message to the player that we don't know what
-  #to do with the method call.
-  def method_missing(*args)
-    self.output("Don't know what do to with: #{args.inspect}")
-  end
-
   #Handles the input from the Player. Basically, it just takes the
   #input, feeds it to the CommandParser, then sends the event
   #(if any) to the Manager.
-- 
GitLab