annotate arogue7/mdport.c @ 252:3d4252fa2ed3

Use more portable random seed generation. The new function md_random_seed() has replaced time() + getpid() and similar methods. Putting everything in mdport.c slightly reduces the warnings and workarounds.
author John "Elwin" Edwards
date Sat, 28 Jan 2017 15:49:41 -0500
parents f9ef86cf22b2
children d3968e9cb98d
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>
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
68 #include <ctype.h>
126
b786053d2f37 arogue7: add missing header includes.
John "Elwin" Edwards
parents: 125
diff changeset
69 #include <string.h>
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
70 #include <fcntl.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
71 #include <limits.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
72 #include <sys/stat.h>
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
73 #include <signal.h>
252
3d4252fa2ed3 Use more portable random seed generation.
John "Elwin" Edwards
parents: 219
diff changeset
74 #include <time.h>
125
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 #define MOD_MOVE(c) (toupper(c) )
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
77
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
78 void
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
79 md_init(void)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
80 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
81 #ifdef __INTERIX
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
82 char *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 term = getenv("TERM");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
85
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
86 if (term == NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
87 setenv("TERM","interix");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
88 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
89 #if defined(__DJGPP__) || defined(_WIN32)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
90 _fmode = _O_BINARY;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
91 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
92 #if defined(__CYGWIN__) || defined(__MSYS__)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
93 ESCDELAY=250;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
94 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
95 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
96
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
97 #ifdef attron
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
98 # 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
99 # define SO enter_standout_mode
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
100 # define SE exit_standout_mode
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
101 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
102
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
103 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
104 md_putchar(int c)
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 putchar(c);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
107 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
108
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
109 static int md_standout_mode = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
110
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
111 int
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
112 md_raw_standout(void)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
113 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
114 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
115 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
116 HANDLE hStdout;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
117 int fgattr,bgattr;
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 if (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 hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
122 GetConsoleScreenBufferInfo(hStdout, &csbiInfo);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
123 fgattr = (csbiInfo.wAttributes & 0xF);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
124 bgattr = (csbiInfo.wAttributes & 0xF0);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
125 SetConsoleTextAttribute(hStdout,(fgattr << 4) | (bgattr >> 4));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
126 md_standout_mode = 1;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
127 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
128 #elif !defined(__PDCURSES__)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
129 _puts(SO);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
130 fflush(stdout);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
131 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
132 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
133
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
134 int
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
135 md_raw_standend(void)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
136 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
137 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
138 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
139 HANDLE hStdout;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
140 int fgattr,bgattr;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
141
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
142 if (md_standout_mode == 1)
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 hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
145 GetConsoleScreenBufferInfo(hStdout, &csbiInfo);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
146 fgattr = (csbiInfo.wAttributes & 0xF);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
147 bgattr = (csbiInfo.wAttributes & 0xF0);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
148 SetConsoleTextAttribute(hStdout,(fgattr << 4) | (bgattr >> 4));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
149 md_standout_mode = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
150 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
151 #elif !defined(__PDCURSES__)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
152 _puts(SE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
153 fflush(stdout);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
154 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
155 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
156
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
157 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
158 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
159 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
160 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
161 close(inf);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
162 chmod(file, 0600);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
163 return( _unlink(file) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
164 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
165 return(unlink(file));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
166 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
167 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
168
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
169 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
170 md_unlink(char *file)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
171 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
172 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
173 chmod(file, 0600);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
174 return( _unlink(file) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
175 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
176 return(unlink(file));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
177 #endif
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
203
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
180 FILE *
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
181 md_fdopen(int fd, char *mode)
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
182 {
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
183 #ifdef _WIN32
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
184 return( _fdopen(fd, mode) );
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
185 #else
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
186 return( fdopen(fd, mode) );
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
187 #endif
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
188 }
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
189
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
190 int
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
191 md_fileno(FILE *fp)
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
192 {
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
193 #ifdef _WIN32
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
194 return( _fileno(fp) );
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
195 #else
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
196 return( fileno(fp) );
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
197 #endif
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
198 }
aa8e1fc62926 Advanced Rogue 7: add and use more md_ functions.
John "Elwin" Edwards
parents: 202
diff changeset
199
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
200 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
201 md_creat(char *file, int mode)
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 fd;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
204 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
205 mode = _S_IREAD | _S_IWRITE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
206 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
207 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
208
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
209 return(fd);
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
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
213 int
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
214 md_normaluser(void)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
215 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
216 #ifndef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
217 setuid(getuid());
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
218 setgid(getgid());
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 int
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
223 md_getuid(void)
125
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 #ifndef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
226 return( getuid() );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
227 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
228 return(42);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
229 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
230 }
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 char *
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
233 md_getusername(void)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
234 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
235 static char login[80];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
236 char *l = NULL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
237 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
238 LPSTR mybuffer;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
239 DWORD size = UNLEN + 1;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
240 TCHAR buffer[UNLEN + 1];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
241
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
242 mybuffer = buffer;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
243 GetUserName(mybuffer,&size);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
244 l = mybuffer;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
245 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
246 #if !defined(_WIN32) && !defined(DJGPP)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
247 struct passwd *pw;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
248
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
249 pw = getpwuid(getuid());
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
250
144
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
251 if (pw != NULL)
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
252 l = pw->pw_name;
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
253 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
254
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
255 if ((l == NULL) || (*l == '\0'))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
256 if ( (l = getenv("USERNAME")) == NULL )
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
257 if ( (l = getenv("LOGNAME")) == NULL )
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
258 if ( (l = getenv("USER")) == NULL )
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
259 l = "nobody";
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
260
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
261 strncpy(login,l,80);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
262 login[79] = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
263
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
264 return(login);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
265 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
266
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
267 char *
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
268 md_gethomedir(void)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
269 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
270 static char homedir[PATH_MAX];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
271 char *h = NULL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
272 size_t len;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
273 #if defined(_WIN32)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
274 TCHAR szPath[PATH_MAX];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
275 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
276 #if defined(_WIN32) || defined(DJGPP)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
277 char slash = '\\';
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
278 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
279 char slash = '/';
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
280 struct passwd *pw;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
281 pw = getpwuid(getuid());
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
282
144
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
283 if (pw != NULL)
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
284 {
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
285 h = pw->pw_dir;
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
286 if (strcmp(h,"/") == 0)
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
287 h = NULL;
708bb2dea17c arogue7, xrogue: prevent potential NULL dereferencing.
John "Elwin" Edwards
parents: 126
diff changeset
288 }
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
289 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
290 homedir[0] = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
291 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
292 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
293 h = szPath;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
294 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
295
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
296 if ( (h == NULL) || (*h == '\0') )
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
297 if ( (h = getenv("HOME")) == NULL )
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
298 if ( (h = getenv("HOMEDRIVE")) == NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
299 h = "";
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
300 else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
301 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
302 strncpy(homedir,h,PATH_MAX-1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
303 homedir[PATH_MAX-1] = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
304
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
305 if ( (h = getenv("HOMEPATH")) == NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
306 h = "";
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
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
310 len = strlen(homedir);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
311 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
312 len = strlen(homedir);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
313
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
314 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
315 homedir[len] = slash;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
316 homedir[len+1] = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
317 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
318
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
319 return(homedir);
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 *
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
323 md_getshell(void)
125
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
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
351 md_shellescape(void)
125
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 *
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
413 md_getroguedir(void)
125
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 *
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
477 md_getpass(char *prompt)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
478 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
479 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
480 static char password_buffer[9];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
481 char *p = password_buffer;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
482 int c, count = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
483 int max_length = 9;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
484
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
485 fflush(stdout);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
486 /* If we can't prompt, abort */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
487 if (fputs(prompt, stderr) < 0)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
488 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
489 *p = '\0';
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
490 return NULL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
491 }
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 for(;;)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
494 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
495 /* Get a character with no echo */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
496 c = _getch();
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
497
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
498 /* Exit on interrupt (^c or ^break) */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
499 if (c == '\003' || c == 0x100)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
500 exit(1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
501
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
502 /* 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
503 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
504 break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
505
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
506 /* Back up on backspace */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
507 if (c == '\b')
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
508 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
509 if (count)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
510 count--;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
511 else if (p > password_buffer)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
512 p--;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
513 continue;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
514 }
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 /* Ignore DOS extended characters */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
517 if ((c & 0xff) != c)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
518 continue;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
519
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
520 /* 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
521 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
522 *p++ = c;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
523 else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
524 count++;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
525 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
526 *p = '\0';
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
527
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
528 fputc('\n', stderr);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
529
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
530 return password_buffer;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
531 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
532 return( (char *) getpass(prompt) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
533 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
534 }
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 int md_endian = 0x01020304;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
538
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
539 unsigned long int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
540 md_ntohl(unsigned long int x)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
541 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
542 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
543 if ( *((char *)&md_endian) == 0x01 )
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
544 return(x);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
545 else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
546 return( ((x & 0x000000ffU) << 24) |
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
547 ((x & 0x0000ff00U) << 8) |
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
548 ((x & 0x00ff0000U) >> 8) |
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
549 ((x & 0xff000000U) >> 24) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
550 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
551 return( ntohl(x) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
552 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
553 }
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 unsigned long int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
556 md_htonl(unsigned long int x)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
557 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
558 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
559 if ( *((char *)&md_endian) == 0x01 )
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
560 return(x);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
561 else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
562 return( ((x & 0x000000ffU) << 24) |
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
563 ((x & 0x0000ff00U) << 8) |
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
564 ((x & 0x00ff0000U) >> 8) |
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
565 ((x & 0xff000000U) >> 24) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
566 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
567 return( htonl(x) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
568 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
569 }
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 int
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
572 md_rand(void)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
573 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
574 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
575 return(rand());
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
576 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
577 return(random());
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
578 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
579 }
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 int
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
582 md_srand(int seed)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
583 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
584 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
585 srand(seed);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
586 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
587 srandom(seed);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
588 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
589 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
590
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
591 long
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
592 md_memused(void)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
593 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
594 #ifdef _WIN32
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
595 MEMORYSTATUS stat;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
596
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
597 GlobalMemoryStatus(&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 return((long)stat.dwTotalPageFile);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
600 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
601 return( (long)sbrk(0) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
602 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
603 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
604
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
605 char *
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
606 md_gethostname(void)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
607 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
608 static char nodename[80];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
609 char *n = NULL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
610 #if !defined(_WIN32) && !defined(__DJGPP__)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
611 struct utsname ourname;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
612
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
613 if (uname(&ourname) == 0)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
614 n = ourname.nodename;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
615 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
616 if ((n == NULL) || (*n == '\0'))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
617 if ( (n = getenv("COMPUTERNAME")) == NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
618 if ( (n = getenv("HOSTNAME")) == NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
619 n = "localhost";
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
620
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
621 strncpy(nodename, n, 80);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
622 nodename[79] = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
623
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
624 return(nodename);
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
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
627 int
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
628 md_erasechar(void)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
629 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
630 #ifdef BSD
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
631 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
632 #elif defined(USG5_0)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
633 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
634 #else /* USG5_2 .... curses */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
635 return( erasechar() ); /* process erase character */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
636 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
637 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
638
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
639 int
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
640 md_killchar(void)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
641 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
642 #ifdef BSD
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
643 return(_tty.sg_kill);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
644 #elif defined(USG5_0)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
645 return(_tty.c_cc[VKILL]);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
646 #else /* USG5_2 ..... curses */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
647 return( killchar() );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
648 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
649 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
650
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 * unctrl:
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
653 * 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
654 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
655
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
656 char *
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
657 md_unctrl(char ch)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
658 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
659 #if USG5_0
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
660 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
661
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
662 return _unctrl[ch&0177];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
663 #else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
664 return( unctrl(ch) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
665 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
666 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
667
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
668 void
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 203
diff changeset
669 md_flushinp(void)
125
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 #ifdef BSD
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
672 ioctl(0, TIOCFLUSH);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
673 #elif defined(USG5_0)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
674 ioctl(_tty_ch,TCFLSH,0)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
675 #else /* USG5_2.... curses */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
676 flushinp();
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
677 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
678 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
679
145
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
680 extern int scorefd;
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
681 extern char score_file[];
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
682
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
683 void
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
684 md_reopen_score(void)
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 if (scorefd > 0)
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
687 close(scorefd);
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
688 scorefd = open(score_file, O_RDWR | O_CREAT, 0666);
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
689 }
aac28331e71d Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents: 144
diff changeset
690
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
691 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
692 Cursor/Keypad Support
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
693
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
694 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
695
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
696 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
697 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
698 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
699 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
700 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
701 limitations of those terminal capability databases.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
702
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
703 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
704 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
705
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
706 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
707 commands.
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 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
710 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
711
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
712 Console and supported (differentiated) keys
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
713 Interix: Cursor Keys, Keypad, Ctl-Keypad
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
714 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
715 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
716 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
717 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
718
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
719 Interix Console (raw, ncurses)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
720 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
721 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
722 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
723 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
724 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
725 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
726 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
727 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
728 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
729 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
730 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
731 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
732 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
733 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
734 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
735 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
736 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
737 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
738 nothing, nothing, nothing, O /# Kaypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
739
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
740 Interix Console (term=interix, ncurses)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
741 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
742 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
743 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
744 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
745 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
746 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
747 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
748 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
749 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
750 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
751 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
752 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
753 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
754 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
755 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
756 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
757 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
758 nothing, nothing, nothing, O /# Keypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
759
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
760 Cygwin Console (raw, ncurses)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
761 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
762 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
763 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
764 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
765 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
766 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
767 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
768 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
769 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
770 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
771 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
772 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
773 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
774 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
775 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
776 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
777 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
778 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
779 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
780
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
781 Cygwin Console (term=cygwin, ncurses)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
782 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
783 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
784 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
785 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
786 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
787 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
788 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
789 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
790 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
791 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
792 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
793 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
794 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
795 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
796 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
797 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
798 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
799 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
800
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
801 MSYS Console (raw, ncurses)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
802 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
803 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
804 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
805 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
806 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
807 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
808 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
809 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
810 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
811 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
812 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
813 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
814 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
815 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
816 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
817 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
818 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
819 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
820 11, 11, 11, O /# Keypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
821
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
822 MSYS Console (term=rxvt, ncurses)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
823 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
824 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
825 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
826 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
827 KEY_UP, 518, 519, nothing /# Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
828 KEY_DOWN, 511, 512, nothing /# Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
829 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
830 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
831 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
832 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
833 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
834 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
835 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
836 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
837 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
838 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
839 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
840 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
841 11, 11, 11, O /# Keypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
842
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
843 Win32 Console (raw, pdcurses)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
844 DJGPP Console (raw, pdcurses)
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 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
847 260, 391, 443, 493 /# Left #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
848 261, 400, 444, 492 /# Right #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
849 259, 547, 480, 490 /# Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
850 258, 548, 481, 491 /# Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
851 262, 388, 447, 524 /# Home #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
852 339, 396, 445, 526 /# Page Up #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
853 338, 394, 446, 520 /# Page Down #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
854 358, 384, 448, 518 /# End #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
855 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
856 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
857 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
858 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
859 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
860 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
861 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
862 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
863 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
864
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
865 Win32 Console (pdcurses, MSVC/MingW32)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
866 DJGPP Console (pdcurses)
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 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
869 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
870 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
871 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
872 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
873 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
874 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
875 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
876 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
877 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
878 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
879 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
880 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
881 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
882 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
883 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
884 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
885 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
886
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
887 Windows Telnet (raw)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
888 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
889 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
890 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
891 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
892 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
893 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
894 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
895 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
896 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
897 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
898 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
899 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
900 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
901 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
902 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
903 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
904 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
905 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
906 nothing, nothing, nothing, nothing /# Keypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
907
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
908 Windows Telnet (term=xterm)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
909 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
910 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
911 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
912 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
913 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
914 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
915 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
916 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
917 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
918 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
919 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
920 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
921 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
922 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
923 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
924 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
925 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
926 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
927 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
928
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
929 PuTTY
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
930 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
931 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
932 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
933 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
934 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
935 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
936 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
937 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
938 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
939 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
940 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
941 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
942 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
943 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
944 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
945 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
946 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
947 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
948 nothing, nothing, nothing, O /# Keypad 5 #/
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
949
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
950 PuTTY
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
951 ==============================
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
952 normal shift ctrl alt
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
953 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
954 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
955 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
956 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
957 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
958 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
959 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
960 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
961 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
962 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
963 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
964 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
965 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
966 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
967 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
968 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
969 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
970 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
971
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
972 #define M_NORMAL 0
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
973 #define M_ESC 1
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
974 #define M_KEYPAD 2
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
975 #define M_TRAIL 3
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
976
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
977 int
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
978 md_readchar(WINDOW *win)
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 ch = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
981 int lastch = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
982 int mode = M_NORMAL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
983 int mode2 = M_NORMAL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
984
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
985 while(1)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
986 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
987 ch = wgetch(win);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
988
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
989 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
990 { /* 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
991 mode = M_NORMAL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
992 nocbreak();
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
993 raw();
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
994 ch = 27;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
995 break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
996 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
997
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
998 if (mode == M_TRAIL)
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 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
1001 ch = MOD_MOVE( toupper(lastch) );
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 == '~') /* 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
1004 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
1005 /* 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
1006
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1007 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
1008 ch = MOD_MOVE( toupper(ch) );
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 break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1011 }
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 if (mode == M_ESC)
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 if (ch == 27)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1016 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1017 mode2 = M_ESC;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1018 continue;
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
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1021 if ((ch == 'F') || (ch == 'O') || (ch == '['))
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 mode = M_KEYPAD;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1024 continue;
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
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1027
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1028 switch(ch)
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 /* Cygwin Console */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1031 /* PuTTY */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1032 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
1033 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
1034 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
1035 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
1036 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
1037 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
1038 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
1039 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
1040
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1041 default: break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1042 }
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 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 if (mode == M_KEYPAD)
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 switch(ch)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1050 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1051 /* ESC F - Interix Console codes */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1052 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
1053 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
1054
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1055 /* ESC [ - Interix Console codes */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1056 case 'H': ch = 'y'; break; /* Home */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1057 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
1058 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
1059 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
1060 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
1061 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
1062 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
1063 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
1064 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
1065
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1066 /* ESC [ - Cygwin Console codes */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1067 case 'G': ch = '.'; break; /* Keypad 5 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1068 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
1069 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
1070 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
1071
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1072 /* ESC [ - Win32 Telnet, PuTTY */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1073 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
1074 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
1075
149
9aa9b9a2e159 arogue7, xrogue: add support for keypad 5.
John "Elwin" Edwards
parents: 145
diff changeset
1076 /* ESC [ - screen/tmux */
9aa9b9a2e159 arogue7, xrogue: add support for keypad 5.
John "Elwin" Edwards
parents: 145
diff changeset
1077 case 'E': ch = '.'; break;
9aa9b9a2e159 arogue7, xrogue: add support for keypad 5.
John "Elwin" Edwards
parents: 145
diff changeset
1078
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1079 /* ESC O - PuTTY */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1080 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
1081 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
1082 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
1083 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
1084 case 't': ch = 'h'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1085 case 'v': ch = 'l'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1086 case 'x': ch = 'k'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1087 case 'r': ch = 'j'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1088 case 'w': ch = 'y'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1089 case 'y': ch = 'u'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1090 case 's': ch = 'n'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1091 case 'q': ch = 'b'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1092 case 'u': ch = '.'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1093 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1094
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1095 if (mode != M_KEYPAD)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1096 continue;
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
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1099 if (ch == 27)
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 halfdelay(1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1102 mode = M_ESC;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1103 continue;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1104 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1105
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1106 switch(ch)
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 case KEY_LEFT : ch = 'h'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1109 case KEY_DOWN : ch = 'j'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1110 case KEY_UP : ch = 'k'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1111 case KEY_RIGHT : ch = 'l'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1112 case KEY_HOME : ch = 'y'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1113 case KEY_PPAGE : ch = 'u'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1114 case KEY_END : ch = 'b'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1115 #ifdef KEY_LL
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1116 case KEY_LL : ch = 'b'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1117 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1118 case KEY_NPAGE : ch = 'n'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1119
150
a307ff9cd95e arogue7: fix the backspace key in prompts.
John "Elwin" Edwards
parents: 149
diff changeset
1120 #ifdef KEY_BACKSPACE
a307ff9cd95e arogue7: fix the backspace key in prompts.
John "Elwin" Edwards
parents: 149
diff changeset
1121 case KEY_BACKSPACE: ch = md_erasechar(); break;
a307ff9cd95e arogue7: fix the backspace key in prompts.
John "Elwin" Edwards
parents: 149
diff changeset
1122 #endif
a307ff9cd95e arogue7: fix the backspace key in prompts.
John "Elwin" Edwards
parents: 149
diff changeset
1123
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1124 #ifdef KEY_B1
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1125 case KEY_B1 : ch = 'h'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1126 case KEY_C2 : ch = 'j'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1127 case KEY_A2 : ch = 'k'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1128 case KEY_B3 : ch = 'l'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1129 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1130 case KEY_A1 : ch = 'y'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1131 case KEY_A3 : ch = 'u'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1132 case KEY_C1 : ch = 'b'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1133 case KEY_C3 : ch = 'n'; break;
149
9aa9b9a2e159 arogue7, xrogue: add support for keypad 5.
John "Elwin" Edwards
parents: 145
diff changeset
1134 case KEY_B2 : ch = '.'; break;
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1135
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1136 #ifdef KEY_SLEFT
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1137 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
1138 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
1139 #ifdef KEY_SUP
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1140 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
1141 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
1142 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1143 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
1144 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
1145 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
1146 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
1147 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1148 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
1149 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
1150
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1151 #ifdef CTL_RIGHT
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1152 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
1153 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
1154 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
1155 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
1156 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
1157 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
1158 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
1159 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
1160 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1161 #ifdef KEY_EOL
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1162 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
1163 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1164
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1165 #ifndef CTL_PAD1
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1166 /* MSYS rxvt console */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1167 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
1168 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
1169 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
1170 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
1171 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
1172 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
1173 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1174
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1175 #ifdef CTL_PAD1
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1176 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
1177 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
1178 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
1179 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
1180 case CTL_PAD5 : ch = '.'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1181 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
1182 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
1183 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
1184 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
1185 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1186
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1187 #ifdef ALT_RIGHT
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1188 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
1189 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
1190 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
1191 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
1192 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
1193 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
1194 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
1195 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1196
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1197 #ifdef ALT_PAD1
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1198 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
1199 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
1200 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
1201 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
1202 case ALT_PAD5 : ch = '.'; break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1203 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
1204 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
1205 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
1206 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
1207 #endif
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1208 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1209
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1210 break;
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 nocbreak(); /* disable halfdelay mode if on */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1214 raw();
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 return(ch & 0x7F);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1217 }
252
3d4252fa2ed3 Use more portable random seed generation.
John "Elwin" Edwards
parents: 219
diff changeset
1218
3d4252fa2ed3 Use more portable random seed generation.
John "Elwin" Edwards
parents: 219
diff changeset
1219 unsigned int
3d4252fa2ed3 Use more portable random seed generation.
John "Elwin" Edwards
parents: 219
diff changeset
1220 md_random_seed(void)
3d4252fa2ed3 Use more portable random seed generation.
John "Elwin" Edwards
parents: 219
diff changeset
1221 {
3d4252fa2ed3 Use more portable random seed generation.
John "Elwin" Edwards
parents: 219
diff changeset
1222 unsigned int seed;
3d4252fa2ed3 Use more portable random seed generation.
John "Elwin" Edwards
parents: 219
diff changeset
1223 seed = (unsigned int) time((time_t *) NULL);
3d4252fa2ed3 Use more portable random seed generation.
John "Elwin" Edwards
parents: 219
diff changeset
1224 #ifdef _WIN32
3d4252fa2ed3 Use more portable random seed generation.
John "Elwin" Edwards
parents: 219
diff changeset
1225 seed += _getpid();
3d4252fa2ed3 Use more portable random seed generation.
John "Elwin" Edwards
parents: 219
diff changeset
1226 #else
3d4252fa2ed3 Use more portable random seed generation.
John "Elwin" Edwards
parents: 219
diff changeset
1227 seed += getpid();
3d4252fa2ed3 Use more portable random seed generation.
John "Elwin" Edwards
parents: 219
diff changeset
1228 #endif
3d4252fa2ed3 Use more portable random seed generation.
John "Elwin" Edwards
parents: 219
diff changeset
1229 return seed;
3d4252fa2ed3 Use more portable random seed generation.
John "Elwin" Edwards
parents: 219
diff changeset
1230 }