|  | @@ -260,6 +260,20 @@ class Game(protocol.Protocol):
 | 
	
		
			
				|  |  |              self.sector_state = 'normal'
 | 
	
		
			
				|  |  |              self.linestate = ''
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    def portline(self, line):
 | 
	
		
			
				|  |  | +        # Map these items to which keys
 | 
	
		
			
				|  |  | +        log.msg("portline({0}): {1}".format(self.current_sector, line))
 | 
	
		
			
				|  |  | +        mapto = { 'Fuel': 'fuel', 'Organics': 'org', 'Equipment': 'equ'}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if '%' in line:
 | 
	
		
			
				|  |  | +            # Fuel Ore   Buying    2890    100%       0
 | 
	
		
			
				|  |  | +            work = line.replace('Fuel Ore', 'Fuel').replace('%', '')
 | 
	
		
			
				|  |  | +            parts = re.split(r"\s+", work)
 | 
	
		
			
				|  |  | +            data = { mapto[parts[0]] : { 'sale': parts[1][0], 'units': parts[2], 'pct': int(parts[3]) } }
 | 
	
		
			
				|  |  | +            # log.msg("Setting {0} to {1}".format(self.current_sector, data))
 | 
	
		
			
				|  |  | +            self.gamedata.set_port(self.current_sector, data)
 | 
	
		
			
				|  |  | +            # log.msg("NOW: {0}".format(self.gamedata.ports[self.current_sector]))
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      def lineReceived(self, line):
 | 
	
		
			
				|  |  |          """ line received from the game. """
 | 
	
		
			
				|  |  |          if "log_lines" in config and config["log_lines"]:
 | 
	
	
		
			
				|  | @@ -279,9 +293,18 @@ class Game(protocol.Protocol):
 | 
	
		
			
				|  |  |                  self.observer.emit("user-game", (self.factory.player.user, self.game))
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          # Process.pas parse line
 | 
	
		
			
				|  |  | +        if line.startswith("Command [TL=]"):
 | 
	
		
			
				|  |  | +            # Ok, get the current sector from this
 | 
	
		
			
				|  |  | +            _, _, sector = line.partition("]:[")
 | 
	
		
			
				|  |  | +            sector, _, _ = sector.partition("]")
 | 
	
		
			
				|  |  | +            self.current_sector = int(sector)
 | 
	
		
			
				|  |  | +            log.msg("current sector: {0}".format(self.current_sector))
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          if line.startswith("The shortest path (") or line.startswith("  TO > "):
 | 
	
		
			
				|  |  |              self.linestate = "warpline"
 | 
	
		
			
				|  |  |              self.lastwarp = 0
 | 
	
		
			
				|  |  | +        elif line.startswith(" Items     Status  Trading % of max OnBoard"):
 | 
	
		
			
				|  |  | +            self.linestate = "port"
 | 
	
		
			
				|  |  |          elif self.linestate == "warpline":
 | 
	
		
			
				|  |  |              if line == "":
 | 
	
		
			
				|  |  |                  self.linestate = ""
 | 
	
	
		
			
				|  | @@ -316,6 +339,11 @@ class Game(protocol.Protocol):
 | 
	
		
			
				|  |  |              self.current_sector = int(parts[2])
 | 
	
		
			
				|  |  |          elif self.linestate == "sector":
 | 
	
		
			
				|  |  |              self.sectorline(line)
 | 
	
		
			
				|  |  | +        elif self.linestate == 'port':
 | 
	
		
			
				|  |  | +            if line == '':
 | 
	
		
			
				|  |  | +                self.linestate = ''
 | 
	
		
			
				|  |  | +            else:
 | 
	
		
			
				|  |  | +                self.portline(line)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          self.observer.emit("game-line", line)
 | 
	
		
			
				|  |  |  
 |