Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2] 3 4 5

Author Topic: Proof of Concept: DF Text Mode (works over SSH!)  (Read 25789 times)

stolensteel

  • Bay Watcher
    • View Profile
Re: Proof of Concept: DF Text Mode (works over SSH!)
« Reply #15 on: November 26, 2009, 11:36:48 pm »

I have visions of a succession fortress run on a "whoever logs in gets the fort, turn ends when they log out" basis...

This might be the most awesome idea ever. Anybody have a box somewhere we can try it on?
Logged
-st

Ninjabob

  • Bay Watcher
    • View Profile
Re: Proof of Concept: DF Text Mode (works over SSH!)
« Reply #16 on: November 27, 2009, 03:01:38 pm »

Sounds awesome but I can't be arsed to setup this on a virtualbox or whatever. >_>
Logged

FeepingCreature

  • Bay Watcher
    • View Profile
Re: Proof of Concept: DF Text Mode (works over SSH!)
« Reply #17 on: November 27, 2009, 07:39:27 pm »

Here's a problem.

The game would have to run in a screen session.

When you're logged into screen, and somebody else logs in under the same account, s/he can trivially kick you out of your game (via screen -d).

Can you think of a way to lock a screen session from being detached? Maybe a setuid script that write-protects it ..
Also, what needs to be done to make a public account safe to use for the server owner?
Logged

CobaltKobold

  • Bay Watcher
  • ☼HOOD☼ ☼ROBE☼ ☼DAGGER☼ [TAIL]
    • View Profile
Re: Proof of Concept: DF Text Mode (works over SSH!)
« Reply #18 on: November 27, 2009, 08:04:16 pm »

FeepingCreature: And why would you be allowing telnet-people access to real commands? Make a shell to edit inits and run DF, and you should be good.

Well, I'm sure many have thought about this since DF is in that odd state of ascii-but-graphics. Nice to see someone seems to have made it.

UTF-8? is ASCII transmission no longer an option, or do you get into too many problems with the once-code characters?

'course, with DF's computational intensity, real public servers feel quite unlikely.
Logged
Neither whole, nor broken. Interpreting this post is left as an exercise for the reader.
OCEANCLIFF seeding, high z-var(40d)
Tilesets

FeepingCreature

  • Bay Watcher
    • View Profile
Re: Proof of Concept: DF Text Mode (works over SSH!)
« Reply #19 on: November 27, 2009, 11:55:49 pm »

ASCII doesn't have Greek characters :) The DF code map is not pure ASCII, so Unicode was necessary.

I set up a public Dwarf Fortress running account: ssh to demented.no-ip.org, username dwarfort, password dwarfort. This is a screen session, so press ctrl-F to fit it to your terminal, and when you're done, press ctrl-a d to detach.

Here's how I did it.

First, chmod +s $(which screen). This will make screen run as suid root and is sadly necessary to make multi-user mode work.

Second, add two new users, "dwarfort" and "dwarfort_watch". Set dwarfort_watch's login shell to /sbin/nologin. We'll come back to dwarfort's login shell later.

Third, create a file called ".screenrc" in dwarfort's home folder. Put this into it. This will unbind almost all normal screen commands (except for detach, which we need), and allow multiuser read-only access from dwarfort_watch.

Fourth, create two shellscript files in dwarfort's home folder, attach.sh (this is our "login shell", make it executable), and reown.sh. This one is a bit more complicated. I'll explain its purpose in a bit. It is important that you make it read-only (but executable) and owned by root!

Fifth, edit your /etc/sudoers file and add the following entries:

dwarfort ALL=(dwarfort_watch) NOPASSWD: ALL
dwarfort ALL=(ALL) NOPASSWD: /home/dwarfort/reown.sh

The first line allows dwarfort to execute commands as dwarfort_watch.
The second line allows dwarfort to execute reown as root. This is okay because reown.sh can't be changed and the command inside it will only change the ownership of files that already belong to dwarfort anyway. The reasoning for this is a bit complex, but it involves not being able to trivially change the ownership of your /dev/pts/[number] file from a non-interactive script (I ran into confusing permission errors trying this). If anybody has a better way, let me know.

Sixth, in /etc/passwd, set dwarfort's login shell to "/home/dwarfort/attach.sh".

Seventh, symlink or copy your Dwarf Fortress files into a "df" folder in /home/dwarfort, or change the path in the shellscript.

Anyway, this is what happens:

The first person who logs in gets a screen session started that contains a Dwarf Fortress game. The session offers no further access to screen commands aside from detach. It is usable as normal.

Subsequent people to connect are asked whether they want to observe or quit. If they want to observe, their terminal ownership is transferred to dwarfort_watch, and screen is connected in read-only mode to the running game. Since this will break automatic resize handling for the original player, he can use the ctrl-F key combo to re-fit the window.

Have fun!
« Last Edit: November 28, 2009, 12:13:33 am by FeepingCreature »
Logged

stolensteel

  • Bay Watcher
    • View Profile
Re: Proof of Concept: DF Text Mode (works over SSH!)
« Reply #20 on: November 28, 2009, 12:30:33 am »

So, I'm testing it out right now. It has some interesting results... I'm using putty to SSH, since it's the only client I have. Maybe it works better with a linux computer? Here is a picasa album with my results so far:

http://picasaweb.google.com/steel.stiletto/DwarfFortress?feat=directlink

~edit~
My embark site won't be good, since I can't even tell what is what. This is just a site to see how the actual game works.

Also, I can't use the numpad to change things (/*-+). I can however do it with the regular key associated with it. So, it'll just be a bit different. I'm sure that has nothing to do with your set up though, just a limitation of SSH.
« Last Edit: November 28, 2009, 12:34:36 am by stolensteel »
Logged
-st

FeepingCreature

  • Bay Watcher
    • View Profile
Re: Proof of Concept: DF Text Mode (works over SSH!)
« Reply #21 on: November 28, 2009, 12:39:38 am »

What you're seeing seems to indicate that UTF8 is off. Try to find a setting for it. When you have, press ctrl-F to adapt the game to your terminal size. I'm sorry about the numpad keys; I'll look into it. It's probably a bug in the way key codes are parsed.

[update] Google says "
Menu -> Change Settings -> Window -> Translation -> Received data assumbed to be in character set -> UTF8".
« Last Edit: November 28, 2009, 12:42:26 am by FeepingCreature »
Logged

stolensteel

  • Bay Watcher
    • View Profile
Re: Proof of Concept: DF Text Mode (works over SSH!)
« Reply #22 on: November 28, 2009, 12:45:10 am »

Aha! It was accepting the text as ISO something, I changed it to UTF-8, and now look at the results!

~edit~
F# keys aren't working as hotkeys, they are being used to enter the escape menu... There must be an option to fix that too...

Another interesting thing is that I can't move the cursor in steps of ten by using shift-direction. I'm going to wander the configuration a bit more...
« Last Edit: November 28, 2009, 12:51:40 am by stolensteel »
Logged
-st

FeepingCreature

  • Bay Watcher
    • View Profile
Re: Proof of Concept: DF Text Mode (works over SSH!)
« Reply #23 on: November 28, 2009, 12:48:53 am »

Yes, I'm seeing them :) :has a perpetual observer window open:

[update] If something causes you to enter the menu, it means the extended keycode isn't being recognized, so it falls back to the first code.

The first code of all extended keycodes is 27, AKA escape :)
Logged

stolensteel

  • Bay Watcher
    • View Profile
Re: Proof of Concept: DF Text Mode (works over SSH!)
« Reply #24 on: November 28, 2009, 12:54:09 am »

So, if I remember correctly (it's been a while (a few years) since I've ssh'ed into anything), ctrl-c or ctrl-d (can't remember which) is supposed to send the stop command. In order to break the ssh here though, am I just supposed to exit the game? Yup.
Logged
-st

FeepingCreature

  • Bay Watcher
    • View Profile
Re: Proof of Concept: DF Text Mode (works over SSH!)
« Reply #25 on: November 28, 2009, 12:57:28 am »

When you reconnect, you can see I added a protocol line at the bottom, listing six numbers => another number. That's the raw key codes as read by the game; the number is the translated code.

Please post the key codes of the keys that aren't working, as well as the key it should be. Thanks :)
Logged

stolensteel

  • Bay Watcher
    • View Profile
Re: Proof of Concept: DF Text Mode (works over SSH!)
« Reply #26 on: November 28, 2009, 01:04:42 am »

Fixed it on my end. It is reading the F# keys correctly if I leave the setting on ESC[n~. I had set it to LINUX the first time, since I thought that would be what it wants. As far as shift-direction, putty isn't sending the shift-direction as a different code than the regular direction, so that's not something you could change on your end.

~edit~
Another thing that is amazing is that as I change my putty window size, the game changes sizes too! Now I just need a square font for putty to use...

~edit2~
Closest I could find to a square font is Terminal, but it doesn't have all the pretty utf-8. Sad.
« Last Edit: November 28, 2009, 01:15:12 am by stolensteel »
Logged
-st

FeepingCreature

  • Bay Watcher
    • View Profile
Re: Proof of Concept: DF Text Mode (works over SSH!)
« Reply #27 on: November 28, 2009, 01:16:33 am »

The changing-sizes only works if no viewers are attached. That's why I keep repeating the ctrl-F thing :p (This is a screen limitation)
Logged

stolensteel

  • Bay Watcher
    • View Profile
Re: Proof of Concept: DF Text Mode (works over SSH!)
« Reply #28 on: November 28, 2009, 01:22:30 am »

ctrl-f?

Also, the best font (on a default windows computer with putty) seems to be Lucidia Console.
Logged
-st

stolensteel

  • Bay Watcher
    • View Profile
Re: Proof of Concept: DF Text Mode (works over SSH!)
« Reply #29 on: November 28, 2009, 01:26:26 am »

So, from what I could tell, it works great once it's set up! Good job making it, and here's to hoping that amazing things come of this.
Logged
-st
Pages: 1 [2] 3 4 5