annotate arogue7/mdport.c @ 201:6fb21004a981

Fix some preprocessor directives. Include process.h in the right place, and use the correct definition of PATH_MAX, when compiling on Windows.
author John "Elwin" Edwards
date Wed, 12 Aug 2015 16:56:19 -0400
parents 600873555ec0
children e69128d2e4c5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2 mdport.c - Machine Dependent Code for Porting Unix/Curses games
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
4 Copyright (C) 2005 Nicholas J. Kisseberth
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
5 All rights reserved.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
6
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
7 Redistribution and use in source and binary forms, with or without
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
8 modification, are permitted provided that the following conditions
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
9 are met:
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
10 1. Redistributions of source code must retain the above copyright
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
11 notice, this list of conditions and the following disclaimer.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
12 2. Redistributions in binary form must reproduce the above copyright
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
13 notice, this list of conditions and the following disclaimer in the
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
14 documentation and/or other materials provided with the distribution.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
15 3. Neither the name(s) of the author(s) nor the names of other contributors
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
16 may be used to endorse or promote products derived from this software
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
17 without specific prior written permission.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
18
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
19 THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
22 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
25 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
26 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
27 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
28 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
29 SUCH DAMAGE.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
30 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
31
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
32 #if defined(_WIN32)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
33 #include <Windows.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
34 #include <Lmcons.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
35 #include <shlobj.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
36 #include <Shlwapi.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
37 #include <sys/types.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
38 #undef MOUSE_MOVED
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
39 #elif defined(__DJGPP__)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
40 #include <process.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
41 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
42 #include <pwd.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
43 #include <sys/utsname.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
44 #include <unistd.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
45 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
46
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
47 #include <stdlib.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
48
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
49 #if defined(_WIN32) && !defined(__MINGW32__)
201
6fb21004a981 Fix some preprocessor directives.
John "Elwin" Edwards
parents: 162
diff changeset
50 #define PATH_MAX _MAX_PATH
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
51 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
52
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
53 #include <curses.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
54
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
55 #if defined(__INTERIX) || defined(__MSYS__)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
56 #include <term.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
57 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
58 #ifdef NCURSES_VERSION
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
59 #include <ncurses/term.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
60 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
61 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
62
201
6fb21004a981 Fix some preprocessor directives.
John "Elwin" Edwards
parents: 162
diff changeset
63 #if defined(_WIN32)
6fb21004a981 Fix some preprocessor directives.
John "Elwin" Edwards
parents: 162
diff changeset
64 #include <process.h>
6fb21004a981 Fix some preprocessor directives.
John "Elwin" Edwards
parents: 162
diff changeset
65 #endif
6fb21004a981 Fix some preprocessor directives.
John "Elwin" Edwards
parents: 162
diff changeset
66
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
67 #include <stdio.h>
126
b786053d2f37 arogue7: add missing header includes.
John "Elwin" Edwards
parents: 125
diff changeset
68 #include <string.h>
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
69 #include <fcntl.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
70 #include <limits.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
71 #include <sys/stat.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
72 #include <signal.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
73
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
74 #define MOD_MOVE(c) (toupper(c) )
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
75
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
76 void
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
77 md_init()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
78 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
79 #ifdef __INTERIX
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
80 char *term;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
81
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
82 term = getenv("TERM");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
83
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
84 if (term == NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
85 setenv("TERM","interix");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
86 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
87 #if defined(__DJGPP__) || defined(_WIN32)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
88 _fmode = _O_BINARY;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
89 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
90 #if defined(__CYGWIN__) || defined(__MSYS__)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
91 ESCDELAY=250;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
92 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
93 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
94
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
95 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
96 md_hasclreol()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
97 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
98 #ifndef attron
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
99 return(!CE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
100 #elif !defined(__PDCURSES__)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
101 return(clr_eol != NULL);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
102 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
103 return(TRUE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
104 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
105 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
106
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
107 #ifdef attron
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
108 # define _puts(s) tputs(s, 0, md_putchar);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
109 # define SO enter_standout_mode
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
110 # define SE exit_standout_mode
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
111 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
112
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
113 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
114 md_putchar(int c)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
115 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
116 putchar(c);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
117 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
118
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
119 static int md_standout_mode = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
120
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
121 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
122 md_raw_standout()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
123 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
124 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
125 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
126 HANDLE hStdout;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
127 int fgattr,bgattr;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
128
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
129 if (md_standout_mode == 0)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
130 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
131 hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
132 GetConsoleScreenBufferInfo(hStdout, &csbiInfo);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
133 fgattr = (csbiInfo.wAttributes & 0xF);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
134 bgattr = (csbiInfo.wAttributes & 0xF0);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
135 SetConsoleTextAttribute(hStdout,(fgattr << 4) | (bgattr >> 4));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
136 md_standout_mode = 1;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
137 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
138 #elif !defined(__PDCURSES__)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
139 _puts(SO);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
140 fflush(stdout);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
141 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
142 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
143
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
144 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
145 md_raw_standend()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
146 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
147 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
148 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
149 HANDLE hStdout;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
150 int fgattr,bgattr;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
151
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
152 if (md_standout_mode == 1)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
153 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
154 hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
155 GetConsoleScreenBufferInfo(hStdout, &csbiInfo);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
156 fgattr = (csbiInfo.wAttributes & 0xF);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
157 bgattr = (csbiInfo.wAttributes & 0xF0);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
158 SetConsoleTextAttribute(hStdout,(fgattr << 4) | (bgattr >> 4));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
159 md_standout_mode = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
160 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
161 #elif !defined(__PDCURSES__)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
162 _puts(SE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
163 fflush(stdout);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
164 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
165 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
166
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
167 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
168 md_unlink_open_file(char *file, int inf)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
169 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
170 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
171 close(inf);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
172 chmod(file, 0600);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
173 return( _unlink(file) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
174 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
175 return(unlink(file));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
176 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
177 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
178
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
179 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
180 md_unlink(char *file)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
181 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
182 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
183 chmod(file, 0600);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
184 return( _unlink(file) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
185 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
186 return(unlink(file));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
187 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
188 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
189
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
190 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
191 md_creat(char *file, int mode)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
192 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
193 int fd;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
194 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
195 mode = _S_IREAD | _S_IWRITE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
196 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
197 fd = open(file,O_CREAT | O_EXCL | O_WRONLY, mode);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
198
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
199 return(fd);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
200 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
201
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
202
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
203 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
204 md_normaluser()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
205 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
206 #ifndef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
207 setuid(getuid());
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
208 setgid(getgid());
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
209 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
210 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
211
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
212 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
213 md_getuid()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
214 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
215 #ifndef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
216 return( getuid() );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
217 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
218 return(42);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
219 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
220 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
221
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
222 char *
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
223 md_getusername()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
224 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
225 static char login[80];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
226 char *l = NULL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
227 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
228 LPSTR mybuffer;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
229 DWORD size = UNLEN + 1;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
230 TCHAR buffer[UNLEN + 1];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
231
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
232 mybuffer = buffer;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
233 GetUserName(mybuffer,&size);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
234 l = mybuffer;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
235 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
236 #if !defined(_WIN32) && !defined(DJGPP)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
237 struct passwd *pw;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
238
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
239 pw = getpwuid(getuid());
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
240
144
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
241 if (pw != NULL)
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
242 l = pw->pw_name;
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
243 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
244
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
245 if ((l == NULL) || (*l == '\0'))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
246 if ( (l = getenv("USERNAME")) == NULL )
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
247 if ( (l = getenv("LOGNAME")) == NULL )
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
248 if ( (l = getenv("USER")) == NULL )
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
249 l = "nobody";
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
250
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
251 strncpy(login,l,80);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
252 login[79] = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
253
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
254 return(login);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
255 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
256
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
257 char *
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
258 md_gethomedir()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
259 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
260 static char homedir[PATH_MAX];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
261 char *h = NULL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
262 size_t len;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
263 #if defined(_WIN32)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
264 TCHAR szPath[PATH_MAX];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
265 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
266 #if defined(_WIN32) || defined(DJGPP)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
267 char slash = '\\';
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
268 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
269 char slash = '/';
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
270 struct passwd *pw;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
271 pw = getpwuid(getuid());
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
272
144
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
273 if (pw != NULL)
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
274 {
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
275 h = pw->pw_dir;
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
276 if (strcmp(h,"/") == 0)
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
277 h = NULL;
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
278 }
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
279 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
280 homedir[0] = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
281 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
282 if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, szPath)))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
283 h = szPath;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
284 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
285
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
286 if ( (h == NULL) || (*h == '\0') )
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
287 if ( (h = getenv("HOME")) == NULL )
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
288 if ( (h = getenv("HOMEDRIVE")) == NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
289 h = "";
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
290 else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
291 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
292 strncpy(homedir,h,PATH_MAX-1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
293 homedir[PATH_MAX-1] = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
294
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
295 if ( (h = getenv("HOMEPATH")) == NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
296 h = "";
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
297 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
298
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
299
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
300 len = strlen(homedir);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
301 strncat(homedir,h,PATH_MAX-len-1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
302 len = strlen(homedir);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
303
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
304 if ((len > 0) && (homedir[len-1] != slash)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
305 homedir[len] = slash;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
306 homedir[len+1] = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
307 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
308
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
309 return(homedir);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
310 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
311
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
312 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
313 md_sleep(int s)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
314 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
315 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
316 _sleep(s);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
317 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
318 sleep(s);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
319 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
320 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
321
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
322 char *
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
323 md_getshell()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
324 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
325 static char shell[PATH_MAX];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
326 char *s = NULL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
327 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
328 char *def = "C:\\WINDOWS\\SYSTEM32\\CMD.EXE";
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
329 #elif defined(__DJGPP__)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
330 char *def = "C:\\COMMAND.COM";
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
331 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
332 char *def = "/bin/sh";
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
333 struct passwd *pw;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
334 pw = getpwuid(getuid());
144
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
335 if (pw != NULL)
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
336 s = pw->pw_shell;
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
337 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
338 if ((s == NULL) || (*s == '\0'))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
339 if ( (s = getenv("COMSPEC")) == NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
340 if ( (s = getenv("SHELL")) == NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
341 if ( (s = getenv("SystemRoot")) == NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
342 s = def;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
343
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
344 strncpy(shell,s,PATH_MAX);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
345 shell[PATH_MAX-1] = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
346
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
347 return(shell);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
348 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
349
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
350 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
351 md_shellescape()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
352 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
353 #if (!defined(_WIN32) && !defined(__DJGPP__))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
354 int ret_status;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
355 int pid;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
356 void (*myquit)(int);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
357 void (*myend)(int);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
358 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
359 char *sh;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
360
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
361 sh = md_getshell();
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
362
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
363 #if defined(_WIN32)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
364 return((int)_spawnl(_P_WAIT,sh,"shell",NULL,0));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
365 #elif defined(__DJGPP__)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
366 return ( spawnl(P_WAIT,sh,"shell",NULL,0) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
367 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
368 while((pid = fork()) < 0)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
369 sleep(1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
370
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
371 if (pid == 0) /* Shell Process */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
372 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
373 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
374 * Set back to original user, just in case
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
375 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
376 setuid(getuid());
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
377 setgid(getgid());
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
378 execl(sh == NULL ? "/bin/sh" : sh, "shell", "-i", 0);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
379 perror("No shelly");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
380 _exit(-1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
381 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
382 else /* Application */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
383 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
384 myend = signal(SIGINT, SIG_IGN);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
385 #ifdef SIGQUIT
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
386 myquit = signal(SIGQUIT, SIG_IGN);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
387 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
388 while (wait(&ret_status) != pid)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
389 continue;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
390
162
600873555ec0 Don't swap signal handlers in md_shellescape().
John "Elwin" Edwards
parents: 150
diff changeset
391 signal(SIGINT, myend);
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
392 #ifdef SIGQUIT
162
600873555ec0 Don't swap signal handlers in md_shellescape().
John "Elwin" Edwards
parents: 150
diff changeset
393 signal(SIGQUIT, myquit);
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
394 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
395 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
396
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
397 return(ret_status);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
398 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
399 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
400
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
401 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
402 directory_exists(char *dirname)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
403 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
404 struct stat sb;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
405
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
406 if (stat(dirname, &sb) == 0) /* path exists */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
407 return (sb.st_mode & S_IFDIR);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
408
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
409 return(0);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
410 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
411
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
412 char *
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
413 md_getroguedir()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
414 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
415 static char path[1024];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
416 char *end,*home;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
417
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
418 if ( (home = getenv("ROGUEHOME")) != NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
419 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
420 if (*home)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
421 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
422 strncpy(path, home, PATH_MAX - 20);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
423
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
424 end = &path[strlen(path)-1];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
425
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
426 while( (end >= path) && ((*end == '/') || (*end == '\\')))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
427 *end-- = '\0';
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
428
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
429 if (directory_exists(path))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
430 return(path);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
431 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
432 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
433
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
434 if (directory_exists("/var/games/roguelike"))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
435 return("/var/games/roguelike");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
436 if (directory_exists("/var/lib/roguelike"))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
437 return("/var/lib/roguelike");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
438 if (directory_exists("/var/roguelike"))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
439 return("/var/roguelike");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
440 if (directory_exists("/usr/games/lib"))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
441 return("/usr/games/lib");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
442 if (directory_exists("/games/roguelik"))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
443 return("/games/roguelik");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
444
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
445 return("");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
446 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
447
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
448 char *
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
449 md_getrealname(int uid)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
450 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
451 static char uidstr[20];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
452 #if !defined(_WIN32) && !defined(DJGPP)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
453 struct passwd *pp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
454
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
455 if ((pp = getpwuid(uid)) == NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
456 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
457 sprintf(uidstr,"%d", uid);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
458 return(uidstr);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
459 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
460 else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
461 return(pp->pw_name);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
462 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
463 sprintf(uidstr,"%d", uid);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
464 return(uidstr);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
465 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
466 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
467
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
468 extern char *xcrypt(char *key, char *salt);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
469
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
470 char *
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
471 md_crypt(char *key, char *salt)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
472 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
473 return( xcrypt(key,salt) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
474 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
475
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
476 char *
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
477 md_getpass(prompt)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
478 char *prompt;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
479 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
480 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
481 static char password_buffer[9];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
482 char *p = password_buffer;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
483 int c, count = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
484 int max_length = 9;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
485
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
486 fflush(stdout);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
487 /* If we can't prompt, abort */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
488 if (fputs(prompt, stderr) < 0)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
489 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
490 *p = '\0';
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
491 return NULL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
492 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
493
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
494 for(;;)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
495 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
496 /* Get a character with no echo */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
497 c = _getch();
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
498
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
499 /* Exit on interrupt (^c or ^break) */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
500 if (c == '\003' || c == 0x100)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
501 exit(1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
502
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
503 /* Terminate on end of line or file (^j, ^m, ^d, ^z) */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
504 if (c == '\r' || c == '\n' || c == '\004' || c == '\032')
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
505 break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
506
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
507 /* Back up on backspace */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
508 if (c == '\b')
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
509 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
510 if (count)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
511 count--;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
512 else if (p > password_buffer)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
513 p--;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
514 continue;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
515 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
516
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
517 /* Ignore DOS extended characters */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
518 if ((c & 0xff) != c)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
519 continue;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
520
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
521 /* Add to password if it isn't full */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
522 if (p < password_buffer + max_length - 1)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
523 *p++ = c;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
524 else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
525 count++;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
526 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
527 *p = '\0';
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
528
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
529 fputc('\n', stderr);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
530
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
531 return password_buffer;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
532 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
533 return( (char *) getpass(prompt) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
534 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
535 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
536
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
537
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
538 int md_endian = 0x01020304;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
539
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
540 unsigned long int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
541 md_ntohl(unsigned long int x)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
542 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
543 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
544 if ( *((char *)&md_endian) == 0x01 )
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
545 return(x);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
546 else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
547 return( ((x & 0x000000ffU) << 24) |
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
548 ((x & 0x0000ff00U) << 8) |
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
549 ((x & 0x00ff0000U) >> 8) |
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
550 ((x & 0xff000000U) >> 24) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
551 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
552 return( ntohl(x) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
553 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
554 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
555
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
556 unsigned long int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
557 md_htonl(unsigned long int x)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
558 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
559 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
560 if ( *((char *)&md_endian) == 0x01 )
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
561 return(x);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
562 else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
563 return( ((x & 0x000000ffU) << 24) |
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
564 ((x & 0x0000ff00U) << 8) |
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
565 ((x & 0x00ff0000U) >> 8) |
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
566 ((x & 0xff000000U) >> 24) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
567 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
568 return( htonl(x) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
569 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
570 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
571
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
572 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
573 md_rand()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
574 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
575 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
576 return(rand());
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
577 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
578 return(random());
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
579 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
580 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
581
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
582 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
583 md_srand(seed)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
584 register int seed;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
585 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
586 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
587 srand(seed);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
588 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
589 srandom(seed);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
590 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
591 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
592
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
593 long
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
594 md_memused()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
595 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
596 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
597 MEMORYSTATUS stat;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
598
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
599 GlobalMemoryStatus(&stat);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
600
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
601 return((long)stat.dwTotalPageFile);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
602 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
603 return( (long)sbrk(0) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
604 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
605 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
606
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
607 char *
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
608 md_gethostname()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
609 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
610 static char nodename[80];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
611 char *n = NULL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
612 #if !defined(_WIN32) && !defined(__DJGPP__)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
613 struct utsname ourname;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
614
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
615 if (uname(&ourname) == 0)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
616 n = ourname.nodename;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
617 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
618 if ((n == NULL) || (*n == '\0'))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
619 if ( (n = getenv("COMPUTERNAME")) == NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
620 if ( (n = getenv("HOSTNAME")) == NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
621 n = "localhost";
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
622
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
623 strncpy(nodename, n, 80);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
624 nodename[79] = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
625
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
626 return(nodename);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
627 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
628
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
629 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
630 md_erasechar()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
631 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
632 #ifdef BSD
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
633 return(_tty.sg_erase); /* process erase character */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
634 #elif defined(USG5_0)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
635 return(_tty.c_cc[VERASE]); /* process erase character */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
636 #else /* USG5_2 .... curses */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
637 return( erasechar() ); /* process erase character */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
638 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
639 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
640
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
641 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
642 md_killchar()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
643 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
644 #ifdef BSD
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
645 return(_tty.sg_kill);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
646 #elif defined(USG5_0)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
647 return(_tty.c_cc[VKILL]);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
648 #else /* USG5_2 ..... curses */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
649 return( killchar() );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
650 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
651 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
652
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
653 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
654 * unctrl:
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
655 * Print a readable version of a certain character
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
656 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
657
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
658 char *
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
659 md_unctrl(ch)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
660 char ch;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
661 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
662 #if USG5_0
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
663 extern char *_unctrl[]; /* Defined in curses library */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
664
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
665 return _unctrl[ch&0177];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
666 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
667 return( unctrl(ch) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
668 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
669 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
670
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
671 void
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
672 md_flushinp()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
673 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
674 #ifdef BSD
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
675 ioctl(0, TIOCFLUSH);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
676 #elif defined(USG5_0)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
677 ioctl(_tty_ch,TCFLSH,0)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
678 #else /* USG5_2.... curses */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
679 flushinp();
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
680 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
681 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
682
145
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
683 extern int scorefd;
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
684 extern char score_file[];
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
685
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
686 void
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
687 md_reopen_score(void)
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
688 {
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
689 if (scorefd > 0)
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
690 close(scorefd);
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
691 scorefd = open(score_file, O_RDWR | O_CREAT, 0666);
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
692 }
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
693
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
694 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
695 Cursor/Keypad Support
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
696
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
697 Sadly Cursor/Keypad support is less straightforward than it should be.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
698
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
699 The various terminal emulators/consoles choose to differentiate the
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
700 cursor and keypad keys (with modifiers) in different ways (if at all!).
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
701 Furthermore they use different code set sequences for each key only
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
702 a subset of which the various curses libraries recognize. Partly due
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
703 to incomplete termcap/terminfo entries and partly due to inherent
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
704 limitations of those terminal capability databases.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
705
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
706 I give curses first crack at decoding the sequences. If it fails to decode
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
707 it we check for common ESC-prefixed sequences.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
708
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
709 All cursor/keypad results are translated into standard rogue movement
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
710 commands.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
711
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
712 Unmodified keys are translated to walk commands: hjklyubn
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
713 Modified (shift,control,alt) are translated to run commands: HJKLYUBN
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
714
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
715 Console and supported (differentiated) keys
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
716 Interix: Cursor Keys, Keypad, Ctl-Keypad
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
717 Cygwin: Cursor Keys, Keypad, Alt-Cursor Keys
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
718 MSYS: Cursor Keys, Keypad, Ctl-Cursor Keys, Ctl-Keypad
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
719 Win32: Cursor Keys, Keypad, Ctl/Shift/Alt-Cursor Keys, Ctl/Alt-Keypad
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
720 DJGPP: Cursor Keys, Keypad, Ctl/Shift/Alt-Cursor Keys, Ctl/Alt-Keypad
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
721
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
722 Interix Console (raw, ncurses)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
723 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
724 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
725 ESC [D, ESC F^, ESC [D, ESC [D /# Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
726 ESC [C, ESC F$, ESC [C, ESC [C /# Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
727 ESC [A, ESC F-, local win, ESC [A /# Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
728 ESC [B, ESC F+, local win, ESC [B /# Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
729 ESC [H, ESC [H, ESC [H, ESC [H /# Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
730 ESC [S, local win, ESC [S, ESC [S /# Page Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
731 ESC [T, local win, ESC [T, ESC [T /# Page Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
732 ESC [U, ESC [U, ESC [U, ESC [U /# End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
733 ESC [D, ESC F^, ESC [D, O /# Keypad Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
734 ESC [C, ESC F$, ESC [C, O /# Keypad Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
735 ESC [A, ESC [A, ESC [-1, O /# Keypad Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
736 ESC [B, ESC [B, ESC [-2, O /# Keypad Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
737 ESC [H, ESC [H, ESC [-263, O /# Keypad Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
738 ESC [S, ESC [S, ESC [-19, O /# Keypad PgUp #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
739 ESC [T, ESC [T, ESC [-20, O /# Keypad PgDn #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
740 ESC [U, ESC [U, ESC [-21, O /# Keypad End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
741 nothing, nothing, nothing, O /# Kaypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
742
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
743 Interix Console (term=interix, ncurses)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
744 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
745 KEY_LEFT, ESC F^, KEY_LEFT, KEY_LEFT /# Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
746 KEY_RIGHT, ESC F$, KEY_RIGHT, KEY_RIGHT /# Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
747 KEY_UP, 0x146, local win, KEY_UP /# Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
748 KEY_DOWN, 0x145, local win, KEY_DOWN /# Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
749 ESC [H, ESC [H, ESC [H, ESC [H /# Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
750 KEY_PPAGE, local win, KEY_PPAGE, KEY_PPAGE /# Page Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
751 KEY_NPAGE, local win, KEY_NPAGE, KEY_NPAGE /# Page Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
752 KEY_LL, KEY_LL, KEY_LL, KEY_LL /# End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
753 KEY_LEFT, ESC F^, ESC [-4, O /# Keypad Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
754 KEY_RIGHT, ESC F$, ESC [-3, O /# Keypad Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
755 KEY_UP, KEY_UP, ESC [-1, O /# Keypad Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
756 KEY_DOWN, KEY_DOWN, ESC [-2, O /# Keypad Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
757 ESC [H, ESC [H, ESC [-263, O /# Keypad Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
758 KEY_PPAGE, KEY_PPAGE, ESC [-19, O /# Keypad PgUp #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
759 KEY_NPAGE, KEY_NPAGE, ESC [-20, O /# Keypad PgDn #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
760 KEY_LL, KEY_LL, ESC [-21, O /# Keypad End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
761 nothing, nothing, nothing, O /# Keypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
762
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
763 Cygwin Console (raw, ncurses)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
764 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
765 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
766 ESC [D, ESC [D, ESC [D, ESC ESC [D /# Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
767 ESC [C, ESC [C, ESC [C, ESC ESC [C /# Rght #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
768 ESC [A, ESC [A, ESC [A, ESC ESC [A /# Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
769 ESC [B, ESC [B, ESC [B, ESC ESC [B /# Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
770 ESC [1~, ESC [1~, ESC [1~, ESC ESC [1~ /# Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
771 ESC [5~, ESC [5~, ESC [5~, ESC ESC [5~ /# Page Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
772 ESC [6~, ESC [6~, ESC [6~, ESC ESC [6~ /# Page Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
773 ESC [4~, ESC [4~, ESC [4~, ESC ESC [4~ /# End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
774 ESC [D, ESC [D, ESC [D, ESC ESC [D,O /# Keypad Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
775 ESC [C, ESC [C, ESC [C, ESC ESC [C,O /# Keypad Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
776 ESC [A, ESC [A, ESC [A, ESC ESC [A,O /# Keypad Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
777 ESC [B, ESC [B, ESC [B, ESC ESC [B,O /# Keypad Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
778 ESC [1~, ESC [1~, ESC [1~, ESC ESC [1~,O /# Keypad Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
779 ESC [5~, ESC [5~, ESC [5~, ESC ESC [5~,O /# Keypad PgUp #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
780 ESC [6~, ESC [6~, ESC [6~, ESC ESC [6~,O /# Keypad PgDn #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
781 ESC [4~, ESC [4~, ESC [4~, ESC ESC [4~,O /# Keypad End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
782 ESC [-71, nothing, nothing, O /# Keypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
783
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
784 Cygwin Console (term=cygwin, ncurses)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
785 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
786 KEY_LEFT, KEY_LEFT, KEY_LEFT, ESC-260 /# Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
787 KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, ESC-261 /# Rght #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
788 KEY_UP, KEY_UP, KEY_UP, ESC-259 /# Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
789 KEY_DOWN, KEY_DOWN, KEY_DOWN, ESC-258 /# Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
790 KEY_HOME, KEY_HOME, KEY_HOME, ESC-262 /# Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
791 KEY_PPAGE, KEY_PPAGE, KEY_PPAGE, ESC-339 /# Page Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
792 KEY_NPAGE, KEY_NPAGE, KEY_NPAGE, ESC-338 /# Page Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
793 KEY_END, KEY_END, KEY_END, ESC-360 /# End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
794 KEY_LEFT, KEY_LEFT, KEY_LEFT, ESC-260,O /# Keypad Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
795 KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, ESC-261,O /# Keypad Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
796 KEY_UP, KEY_UP, KEY_UP, ESC-259,O /# Keypad Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
797 KEY_DOWN, KEY_DOWN, KEY_DOWN, ESC-258,O /# Keypad Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
798 KEY_HOME, KEY_HOME, KEY_HOME, ESC-262,O /# Keypad Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
799 KEY_PPAGE, KEY_PPAGE, KEY_PPAGE, ESC-339,O /# Keypad PgUp #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
800 KEY_NPAGE, KEY_NPAGE, KEY_NPAGE, ESC-338,O /# Keypad PgDn #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
801 KEY_END, KEY_END, KEY_END, ESC-360,O /# Keypad End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
802 ESC [G, nothing, nothing, O /# Keypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
803
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
804 MSYS Console (raw, ncurses)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
805 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
806 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
807 ESC OD, ESC [d, ESC Od nothing /# Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
808 ESC OE, ESC [e, ESC Oe, nothing /# Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
809 ESC OA, ESC [a, ESC Oa, nothing /# Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
810 ESC OB, ESC [b, ESC Ob, nothing /# Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
811 ESC [7~, ESC [7$, ESC [7^, nothing /# Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
812 ESC [5~, local window, ESC [5^, nothing /# Page Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
813 ESC [6~, local window, ESC [6^, nothing /# Page Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
814 ESC [8~, ESC [8$, ESC [8^, nothing /# End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
815 ESC OD, ESC [d, ESC Od O /# Keypad Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
816 ESC OE, ESC [c, ESC Oc, O /# Keypad Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
817 ESC OA, ESC [a, ESC Oa, O /# Keypad Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
818 ESC OB, ESC [b, ESC Ob, O /# Keypad Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
819 ESC [7~, ESC [7$, ESC [7^, O /# Keypad Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
820 ESC [5~, local window, ESC [5^, O /# Keypad PgUp #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
821 ESC [6~, local window, ESC [6^, O /# Keypad PgDn #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
822 ESC [8~, ESC [8$, ESC [8^, O /# Keypad End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
823 11, 11, 11, O /# Keypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
824
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
825 MSYS Console (term=rxvt, ncurses)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
826 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
827 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
828 KEY_LEFT, KEY_SLEFT, 514 nothing /# Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
829 KEY_RIGHT, KEY_SRIGHT, 516, nothing /# Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
830 KEY_UP, 518, 519, nothing /# Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
831 KEY_DOWN, 511, 512, nothing /# Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
832 KEY_HOME, KEY_SHOME, ESC [7^, nothing /# Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
833 KEY_PPAGE, local window, ESC [5^, nothing /# Page Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
834 KEY_NPAGE, local window, ESC [6^, nothing /# Page Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
835 KEY_END, KEY_SEND, KEY_EOL, nothing /# End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
836 KEY_LEFT, KEY_SLEFT, 514 O /# Keypad Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
837 KEY_RIGHT, KEY_SRIGHT, 516, O /# Keypad Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
838 KEY_UP, 518, 519, O /# Keypad Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
839 KEY_DOWN, 511, 512, O /# Keypad Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
840 KEY_HOME, KEY_SHOME, ESC [7^, O /# Keypad Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
841 KEY_PPAGE, local window, ESC [5^, O /# Keypad PgUp #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
842 KEY_NPAGE, local window, ESC [6^, O /# Keypad PgDn #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
843 KEY_END, KEY_SEND, KEY_EOL, O /# Keypad End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
844 11, 11, 11, O /# Keypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
845
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
846 Win32 Console (raw, pdcurses)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
847 DJGPP Console (raw, pdcurses)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
848 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
849 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
850 260, 391, 443, 493 /# Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
851 261, 400, 444, 492 /# Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
852 259, 547, 480, 490 /# Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
853 258, 548, 481, 491 /# Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
854 262, 388, 447, 524 /# Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
855 339, 396, 445, 526 /# Page Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
856 338, 394, 446, 520 /# Page Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
857 358, 384, 448, 518 /# End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
858 452, 52('4'), 511, 521 /# Keypad Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
859 454, 54('6'), 513, 523 /# Keypad Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
860 450, 56('8'), 515, 525 /# Keypad Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
861 456, 50('2'), 509, 519 /# Keypad Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
862 449, 55('7'), 514, 524 /# Keypad Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
863 451, 57('9'), 516, 526 /# Keypad PgUp #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
864 457, 51('3'), 510, 520 /# Keypad PgDn #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
865 455, 49('1'), 508, 518 /# Keypad End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
866 453, 53('5'), 512, 522 /# Keypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
867
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
868 Win32 Console (pdcurses, MSVC/MingW32)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
869 DJGPP Console (pdcurses)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
870 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
871 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
872 KEY_LEFT, KEY_SLEFT, CTL_LEFT, ALT_LEFT /# Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
873 KEY_RIGHT, KEY_SRIGHT, CTL_RIGHT, ALT_RIGHT /# Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
874 KEY_UP, KEY_SUP, CTL_UP, ALT_UP /# Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
875 KEY_DOWN, KEY_SDOWN, CTL_DOWN, ALT_DOWN /# Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
876 KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME /# Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
877 KEY_PPAGE, KEY_SPREVIOUS, CTL_PGUP, ALT_PGUP /# Page Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
878 KEY_NPAGE, KEY_SNEXTE, CTL_PGDN, ALT_PGDN /# Page Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
879 KEY_END, KEY_SEND, CTL_END, ALT_END /# End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
880 KEY_B1, 52('4'), CTL_PAD4, ALT_PAD4 /# Keypad Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
881 KEY_B3, 54('6'), CTL_PAD6, ALT_PAD6 /# Keypad Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
882 KEY_A2, 56('8'), CTL_PAD8, ALT_PAD8 /# Keypad Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
883 KEY_C2, 50('2'), CTL_PAD2, ALT_PAD2 /# Keypad Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
884 KEY_A1, 55('7'), CTL_PAD7, ALT_PAD7 /# Keypad Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
885 KEY_A3, 57('9'), CTL_PAD9, ALT_PAD9 /# Keypad PgUp #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
886 KEY_C3, 51('3'), CTL_PAD3, ALT_PAD3 /# Keypad PgDn #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
887 KEY_C1, 49('1'), CTL_PAD1, ALT_PAD1 /# Keypad End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
888 KEY_B2, 53('5'), CTL_PAD5, ALT_PAD5 /# Keypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
889
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
890 Windows Telnet (raw)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
891 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
892 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
893 ESC [D, ESC [D, ESC [D, ESC [D /# Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
894 ESC [C, ESC [C, ESC [C, ESC [C /# Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
895 ESC [A, ESC [A, ESC [A, ESC [A /# Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
896 ESC [B, ESC [B, ESC [B, ESC [B /# Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
897 ESC [1~, ESC [1~, ESC [1~, ESC [1~ /# Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
898 ESC [5~, ESC [5~, ESC [5~, ESC [5~ /# Page Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
899 ESC [6~, ESC [6~, ESC [6~, ESC [6~ /# Page Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
900 ESC [4~, ESC [4~, ESC [4~, ESC [4~ /# End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
901 ESC [D, ESC [D, ESC [D, ESC [D /# Keypad Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
902 ESC [C, ESC [C, ESC [C, ESC [C /# Keypad Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
903 ESC [A, ESC [A, ESC [A, ESC [A /# Keypad Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
904 ESC [B, ESC [B, ESC [B, ESC [B /# Keypad Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
905 ESC [1~, ESC [1~, ESC [1~, ESC [1~ /# Keypad Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
906 ESC [5~, ESC [5~, ESC [5~, ESC [5~ /# Keypad PgUp #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
907 ESC [6~, ESC [6~, ESC [6~, ESC [6~ /# Keypad PgDn #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
908 ESC [4~, ESC [4~, ESC [4~, ESC [4~ /# Keypad End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
909 nothing, nothing, nothing, nothing /# Keypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
910
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
911 Windows Telnet (term=xterm)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
912 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
913 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
914 KEY_LEFT, KEY_LEFT, KEY_LEFT, KEY_LEFT /# Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
915 KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, KEY_RIGHT /# Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
916 KEY_UP, KEY_UP, KEY_UP, KEY_UP /# Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
917 KEY_DOWN, KEY_DOWN, KEY_DOWN, KEY_DOWN /# Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
918 ESC [1~, ESC [1~, ESC [1~, ESC [1~ /# Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
919 KEY_PPAGE, KEY_PPAGE, KEY_PPAGE, KEY_PPAGE /# Page Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
920 KEY_NPAGE, KEY_NPAGE, KEY_NPAGE, KEY_NPAGE /# Page Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
921 ESC [4~, ESC [4~, ESC [4~, ESC [4~ /# End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
922 KEY_LEFT, KEY_LEFT, KEY_LEFT, O /# Keypad Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
923 KEY_RIGHT, KEY_RIGHT, KEY_RIGHT, O /# Keypad Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
924 KEY_UP, KEY_UP, KEY_UP, O /# Keypad Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
925 KEY_DOWN, KEY_DOWN, KEY_DOWN, O /# Keypad Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
926 ESC [1~, ESC [1~, ESC [1~, ESC [1~ /# Keypad Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
927 KEY_PPAGE, KEY_PPAGE, KEY_PPAGE, KEY_PPAGE /# Keypad PgUp #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
928 KEY_NPAGE, KEY_NPAGE, KEY_NPAGE, KEY_NPAGE /# Keypad PgDn #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
929 ESC [4~, ESC [4~, ESC [4~, O /# Keypad End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
930 ESC [-71, nothing, nothing, O /# Keypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
931
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
932 PuTTY
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
933 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
934 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
935 ESC [D, ESC [D, ESC OD, ESC [D /# Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
936 ESC [C, ESC [C, ESC OC, ESC [C /# Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
937 ESC [A, ESC [A, ESC OA, ESC [A /# Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
938 ESC [B, ESC [B, ESC OB, ESC [B /# Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
939 ESC [1~, ESC [1~, local win, ESC [1~ /# Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
940 ESC [5~, local win, local win, ESC [5~ /# Page Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
941 ESC [6~, local win, local win, ESC [6~ /# Page Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
942 ESC [4~, ESC [4~, local win, ESC [4~ /# End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
943 ESC [D, ESC [D, ESC [D, O /# Keypad Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
944 ESC [C, ESC [C, ESC [C, O /# Keypad Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
945 ESC [A, ESC [A, ESC [A, O /# Keypad Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
946 ESC [B, ESC [B, ESC [B, O /# Keypad Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
947 ESC [1~, ESC [1~, ESC [1~, O /# Keypad Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
948 ESC [5~, ESC [5~, ESC [5~, O /# Keypad PgUp #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
949 ESC [6~, ESC [6~, ESC [6~, O /# Keypad PgDn #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
950 ESC [4~, ESC [4~, ESC [4~, O /# Keypad End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
951 nothing, nothing, nothing, O /# Keypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
952
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
953 PuTTY
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
954 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
955 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
956 KEY_LEFT, KEY_LEFT, ESC OD, ESC KEY_LEFT /# Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
957 KEY_RIGHT KEY_RIGHT, ESC OC, ESC KEY_RIGHT /# Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
958 KEY_UP, KEY_UP, ESC OA, ESC KEY_UP /# Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
959 KEY_DOWN, KEY_DOWN, ESC OB, ESC KEY_DOWN /# Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
960 ESC [1~, ESC [1~, local win, ESC ESC [1~ /# Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
961 KEY_PPAGE local win, local win, ESC KEY_PPAGE /# Page Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
962 KEY_NPAGE local win, local win, ESC KEY_NPAGE /# Page Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
963 ESC [4~, ESC [4~, local win, ESC ESC [4~ /# End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
964 ESC Ot, ESC Ot, ESC Ot, O /# Keypad Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
965 ESC Ov, ESC Ov, ESC Ov, O /# Keypad Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
966 ESC Ox, ESC Ox, ESC Ox, O /# Keypad Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
967 ESC Or, ESC Or, ESC Or, O /# Keypad Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
968 ESC Ow, ESC Ow, ESC Ow, O /# Keypad Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
969 ESC Oy, ESC Oy, ESC Oy, O /# Keypad PgUp #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
970 ESC Os, ESC Os, ESC Os, O /# Keypad PgDn #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
971 ESC Oq, ESC Oq, ESC Oq, O /# Keypad End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
972 ESC Ou, ESC Ou, ESC Ou, O /# Keypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
973 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
974
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
975 #define M_NORMAL 0
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
976 #define M_ESC 1
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
977 #define M_KEYPAD 2
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
978 #define M_TRAIL 3
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
979
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
980 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
981 md_readchar(WINDOW *win)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
982 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
983 int ch = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
984 int lastch = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
985 int mode = M_NORMAL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
986 int mode2 = M_NORMAL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
987
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
988 while(1)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
989 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
990 ch = wgetch(win);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
991
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
992 if (ch == ERR) /* timed out waiting for valid sequence */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
993 { /* flush input so far and start over */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
994 mode = M_NORMAL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
995 nocbreak();
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
996 raw();
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
997 ch = 27;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
998 break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
999 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1000
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1001 if (mode == M_TRAIL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1002 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1003 if (ch == '^') /* msys console : 7,5,6,8: modified*/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1004 ch = MOD_MOVE( toupper(lastch) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1005
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1006 if (ch == '~') /* cygwin console: 1,5,6,4: normal */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1007 ch = tolower(lastch); /* windows telnet: 1,5,6,4: normal */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1008 /* msys console : 7,5,6,8: normal */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1009
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1010 if (mode2 == M_ESC) /* cygwin console: 1,5,6,4: modified*/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1011 ch = MOD_MOVE( toupper(ch) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1012
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1013 break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1014 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1015
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1016 if (mode == M_ESC)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1017 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1018 if (ch == 27)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1019 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1020 mode2 = M_ESC;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1021 continue;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1022 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1023
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1024 if ((ch == 'F') || (ch == 'O') || (ch == '['))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1025 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1026 mode = M_KEYPAD;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1027 continue;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1028 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1029
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1030
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1031 switch(ch)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1032 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1033 /* Cygwin Console */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1034 /* PuTTY */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1035 case KEY_LEFT : ch = MOD_MOVE('H'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1036 case KEY_RIGHT: ch = MOD_MOVE('L'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1037 case KEY_UP : ch = MOD_MOVE('K'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1038 case KEY_DOWN : ch = MOD_MOVE('J'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1039 case KEY_HOME : ch = MOD_MOVE('Y'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1040 case KEY_PPAGE: ch = MOD_MOVE('U'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1041 case KEY_NPAGE: ch = MOD_MOVE('N'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1042 case KEY_END : ch = MOD_MOVE('B'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1043
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1044 default: break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1045 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1046
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1047 break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1048 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1049
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1050 if (mode == M_KEYPAD)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1051 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1052 switch(ch)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1053 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1054 /* ESC F - Interix Console codes */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1055 case '^': ch = MOD_MOVE('H'); break; /* Shift-Left */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1056 case '$': ch = MOD_MOVE('L'); break; /* Shift-Right */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1057
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1058 /* ESC [ - Interix Console codes */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1059 case 'H': ch = 'y'; break; /* Home */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1060 case 1: ch = MOD_MOVE('K'); break; /* Ctl-Keypad Up */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1061 case 2: ch = MOD_MOVE('J'); break; /* Ctl-Keypad Down */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1062 case 3: ch = MOD_MOVE('L'); break; /* Ctl-Keypad Right */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1063 case 4: ch = MOD_MOVE('H'); break; /* Ctl-Keypad Left */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1064 case 263: ch = MOD_MOVE('Y'); break; /* Ctl-Keypad Home */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1065 case 19: ch = MOD_MOVE('U'); break; /* Ctl-Keypad PgUp */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1066 case 20: ch = MOD_MOVE('N'); break; /* Ctl-Keypad PgDn */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1067 case 21: ch = MOD_MOVE('B'); break; /* Ctl-Keypad End */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1068
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1069 /* ESC [ - Cygwin Console codes */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1070 case 'G': ch = '.'; break; /* Keypad 5 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1071 case '7': lastch = 'Y'; mode=M_TRAIL; break; /* Ctl-Home */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1072 case '5': lastch = 'U'; mode=M_TRAIL; break; /* Ctl-PgUp */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1073 case '6': lastch = 'N'; mode=M_TRAIL; break; /* Ctl-PgDn */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1074
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1075 /* ESC [ - Win32 Telnet, PuTTY */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1076 case '1': lastch = 'y'; mode=M_TRAIL; break; /* Home */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1077 case '4': lastch = 'b'; mode=M_TRAIL; break; /* End */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1078
149
9aa9b9a2e159 arogue7, xrogue: add support for keypad 5.
John "Elwin" Edwards
parents: 145
diff changeset
1079 /* ESC [ - screen/tmux */
9aa9b9a2e159 arogue7, xrogue: add support for keypad 5.
John "Elwin" Edwards
parents: 145
diff changeset
1080 case 'E': ch = '.'; break;
9aa9b9a2e159 arogue7, xrogue: add support for keypad 5.
John "Elwin" Edwards
parents: 145
diff changeset
1081
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1082 /* ESC O - PuTTY */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1083 case 'D': ch = MOD_MOVE('H'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1084 case 'C': ch = MOD_MOVE('L'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1085 case 'A': ch = MOD_MOVE('K'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1086 case 'B': ch = MOD_MOVE('J'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1087 case 't': ch = 'h'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1088 case 'v': ch = 'l'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1089 case 'x': ch = 'k'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1090 case 'r': ch = 'j'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1091 case 'w': ch = 'y'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1092 case 'y': ch = 'u'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1093 case 's': ch = 'n'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1094 case 'q': ch = 'b'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1095 case 'u': ch = '.'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1096 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1097
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1098 if (mode != M_KEYPAD)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1099 continue;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1100 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1101
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1102 if (ch == 27)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1103 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1104 halfdelay(1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1105 mode = M_ESC;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1106 continue;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1107 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1108
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1109 switch(ch)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1110 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1111 case KEY_LEFT : ch = 'h'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1112 case KEY_DOWN : ch = 'j'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1113 case KEY_UP : ch = 'k'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1114 case KEY_RIGHT : ch = 'l'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1115 case KEY_HOME : ch = 'y'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1116 case KEY_PPAGE : ch = 'u'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1117 case KEY_END : ch = 'b'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1118 #ifdef KEY_LL
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1119 case KEY_LL : ch = 'b'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1120 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1121 case KEY_NPAGE : ch = 'n'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1122
150
a307ff9cd95e arogue7: fix the backspace key in prompts.
John "Elwin" Edwards
parents: 149
diff changeset
1123 #ifdef KEY_BACKSPACE
a307ff9cd95e arogue7: fix the backspace key in prompts.
John "Elwin" Edwards
parents: 149
diff changeset
1124 case KEY_BACKSPACE: ch = md_erasechar(); break;
a307ff9cd95e arogue7: fix the backspace key in prompts.
John "Elwin" Edwards
parents: 149
diff changeset
1125 #endif
a307ff9cd95e arogue7: fix the backspace key in prompts.
John "Elwin" Edwards
parents: 149
diff changeset
1126
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1127 #ifdef KEY_B1
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1128 case KEY_B1 : ch = 'h'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1129 case KEY_C2 : ch = 'j'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1130 case KEY_A2 : ch = 'k'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1131 case KEY_B3 : ch = 'l'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1132 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1133 case KEY_A1 : ch = 'y'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1134 case KEY_A3 : ch = 'u'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1135 case KEY_C1 : ch = 'b'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1136 case KEY_C3 : ch = 'n'; break;
149
9aa9b9a2e159 arogue7, xrogue: add support for keypad 5.
John "Elwin" Edwards
parents: 145
diff changeset
1137 case KEY_B2 : ch = '.'; break;
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1138
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1139 #ifdef KEY_SLEFT
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1140 case KEY_SRIGHT : ch = MOD_MOVE('L'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1141 case KEY_SLEFT : ch = MOD_MOVE('H'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1142 #ifdef KEY_SUP
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1143 case KEY_SUP : ch = MOD_MOVE('K'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1144 case KEY_SDOWN : ch = MOD_MOVE('J'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1145 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1146 case KEY_SHOME : ch = MOD_MOVE('Y'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1147 case KEY_SPREVIOUS:ch = MOD_MOVE('U'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1148 case KEY_SEND : ch = MOD_MOVE('B'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1149 case KEY_SNEXT : ch = MOD_MOVE('N'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1150 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1151 case 0x146 : ch = MOD_MOVE('K'); break; /* Shift-Up */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1152 case 0x145 : ch = MOD_MOVE('J'); break; /* Shift-Down */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1153
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1154 #ifdef CTL_RIGHT
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1155 case CTL_RIGHT : ch = MOD_MOVE('L'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1156 case CTL_LEFT : ch = MOD_MOVE('H'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1157 case CTL_UP : ch = MOD_MOVE('K'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1158 case CTL_DOWN : ch = MOD_MOVE('J'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1159 case CTL_HOME : ch = MOD_MOVE('Y'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1160 case CTL_PGUP : ch = MOD_MOVE('U'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1161 case CTL_END : ch = MOD_MOVE('B'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1162 case CTL_PGDN : ch = MOD_MOVE('N'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1163 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1164 #ifdef KEY_EOL
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1165 case KEY_EOL : ch = MOD_MOVE('B'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1166 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1167
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1168 #ifndef CTL_PAD1
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1169 /* MSYS rxvt console */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1170 case 511 : ch = MOD_MOVE('J'); break; /* Shift Dn */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1171 case 512 : ch = MOD_MOVE('J'); break; /* Ctl Down */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1172 case 514 : ch = MOD_MOVE('H'); break; /* Ctl Left */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1173 case 516 : ch = MOD_MOVE('L'); break; /* Ctl Right*/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1174 case 518 : ch = MOD_MOVE('K'); break; /* Shift Up */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1175 case 519 : ch = MOD_MOVE('K'); break; /* Ctl Up */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1176 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1177
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1178 #ifdef CTL_PAD1
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1179 case CTL_PAD1 : ch = MOD_MOVE('B'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1180 case CTL_PAD2 : ch = MOD_MOVE('J'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1181 case CTL_PAD3 : ch = MOD_MOVE('N'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1182 case CTL_PAD4 : ch = MOD_MOVE('H'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1183 case CTL_PAD5 : ch = '.'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1184 case CTL_PAD6 : ch = MOD_MOVE('L'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1185 case CTL_PAD7 : ch = MOD_MOVE('Y'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1186 case CTL_PAD8 : ch = MOD_MOVE('K'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1187 case CTL_PAD9 : ch = MOD_MOVE('U'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1188 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1189
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1190 #ifdef ALT_RIGHT
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1191 case ALT_RIGHT : ch = MOD_MOVE('L'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1192 case ALT_LEFT : ch = MOD_MOVE('H'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1193 case ALT_DOWN : ch = MOD_MOVE('J'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1194 case ALT_HOME : ch = MOD_MOVE('Y'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1195 case ALT_PGUP : ch = MOD_MOVE('U'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1196 case ALT_END : ch = MOD_MOVE('B'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1197 case ALT_PGDN : ch = MOD_MOVE('N'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1198 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1199
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1200 #ifdef ALT_PAD1
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1201 case ALT_PAD1 : ch = MOD_MOVE('B'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1202 case ALT_PAD2 : ch = MOD_MOVE('J'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1203 case ALT_PAD3 : ch = MOD_MOVE('N'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1204 case ALT_PAD4 : ch = MOD_MOVE('H'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1205 case ALT_PAD5 : ch = '.'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1206 case ALT_PAD6 : ch = MOD_MOVE('L'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1207 case ALT_PAD7 : ch = MOD_MOVE('Y'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1208 case ALT_PAD8 : ch = MOD_MOVE('K'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1209 case ALT_PAD9 : ch = MOD_MOVE('U'); break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1210 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1211 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1212
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1213 break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1214 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1215
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1216 nocbreak(); /* disable halfdelay mode if on */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1217 raw();
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1218
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1219 return(ch & 0x7F);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1220 }