Skip to content

Commit

Permalink
Implement Han's VT102 bugfix (which works! wooot!).
Browse files Browse the repository at this point in the history
Removed row_plaintext method (row_text is fine, the difference was (like in Perl's Term::VT102, row_text uses null bytes, and row_plaintext replaces them with spaces.. but there's no reason to even have the null byte method, right?).

Made VT102 screen dumps a config option. If VT102 screen dumps are off, we just get the NetHack output itself. This should help bugfixing. (I've already noticed a few anomalies like the @ not always disappearing when moving)
  • Loading branch information
eidolos committed Oct 13, 2006
1 parent ff71315 commit b8fd875
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
3 changes: 3 additions & 0 deletions config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ race = "h" # Hum
gender = "m" # Mal
align = "n" # Neu

# debug stuff
vt102_debug = true # if true, screen dumps; if false, regular screen output

# telnet options
binmode = false
output_log = "output_log" # use nil for no output
Expand Down
8 changes: 5 additions & 3 deletions game_data/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ def send(msg)
# Send the text to the sockets
response = $telnet.send_and_rec(msg)

print response if !$config.opt["vt102_debug"]

# Parse the message
$vt102.process(response)

response = $vt102.row_plaintext(0)
response = $vt102.row_text(0)

# Check to see if we overflowed to the next line.
if $vt102.y == 1 && $vt102.x == $vt102.row_plaintext(1).sub(/\s*/, "").length && $vt102.row_plaintext(1) =~ / --More-- \s* $ /x
response += $vt102.row_plaintext(1)
if $vt102.y == 1 && $vt102.x == $vt102.row_text(1).sub(/\s*/, "").length && $vt102.row_text(1) =~ / --More-- \s* $ /x
response += $vt102.row_text(1)
end

# If we see a --More-- or a (# of #) message, we send spaces and grab the whole message as a large chunk to return.
Expand Down
8 changes: 2 additions & 6 deletions interface/VT102.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _set_x(value)
elsif (value >= @cols)
# TODO: Perhaps enable screen-scrolling when we increment Y off the bottom of the page.
@x = value % @cols
print_screen
print_screen if $config.opt["vt102_debug"]
print "Warning -- Autoincrimented Y\n"
_set_y(@y + (value / @cols).to_i)
else
Expand Down Expand Up @@ -212,11 +212,7 @@ def process(text)
end

def row_text(row)
@screen[row]
end

def row_plaintext(row)
row_text(row)
String.new(@screen[row])
end

def print_screen()
Expand Down
2 changes: 1 addition & 1 deletion main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

# While in the game, as long as we're not dead or ascended yet, continue playing.
while (true)
$vt102.print_screen()
$vt102.print_screen() if $config.opt["vt102_debug"]

# Send the next command to the network
resp = ai_manager.run_next_task()
Expand Down

0 comments on commit b8fd875

Please sign in to comment.