Remove some disused stuff.
This commit is contained in:
parent
39a25f8ec7
commit
d9d089bdcc
4 changed files with 35 additions and 76 deletions
36
advent.h
36
advent.h
|
@ -24,11 +24,6 @@
|
||||||
typedef long token_t; // word token - someday this will be char[TOKLEN+1]
|
typedef long token_t; // word token - someday this will be char[TOKLEN+1]
|
||||||
typedef long vocab_t; // index into a vocabulary array */
|
typedef long vocab_t; // index into a vocabulary array */
|
||||||
|
|
||||||
extern const char advent_to_ascii[128];
|
|
||||||
extern const char ascii_to_advent[128];
|
|
||||||
extern const char new_advent_to_ascii[64];
|
|
||||||
extern const char new_ascii_to_advent[128];
|
|
||||||
|
|
||||||
enum bugtype {
|
enum bugtype {
|
||||||
SPECIAL_TRAVEL_500_GT_L_GT_300_EXCEEDS_GOTO_LIST = 20, // 20
|
SPECIAL_TRAVEL_500_GT_L_GT_300_EXCEEDS_GOTO_LIST = 20, // 20
|
||||||
VOCABULARY_TYPE_N_OVER_1000_NOT_BETWEEN_0_AND_3 = 22, // 22
|
VOCABULARY_TYPE_N_OVER_1000_NOT_BETWEEN_0_AND_3 = 22, // 22
|
||||||
|
@ -101,10 +96,6 @@ struct game_t {
|
||||||
|
|
||||||
extern struct game_t game;
|
extern struct game_t game;
|
||||||
|
|
||||||
extern long LNLENG, LNPOSN;
|
|
||||||
extern char rawbuf[LINESIZE], INLINE[LINESIZE + 1];
|
|
||||||
extern const char ascii_to_advent[];
|
|
||||||
extern const char advent_to_ascii[];
|
|
||||||
extern FILE *logfp;
|
extern FILE *logfp;
|
||||||
extern bool oldstyle, editline, prompt;
|
extern bool oldstyle, editline, prompt;
|
||||||
|
|
||||||
|
@ -234,31 +225,4 @@ int action(struct command_t *command);
|
||||||
/* hack to ignore GCC Unused Result */
|
/* hack to ignore GCC Unused Result */
|
||||||
#define IGNORE(r) do{if (r){}}while(0)
|
#define IGNORE(r) do{if (r){}}while(0)
|
||||||
|
|
||||||
/*
|
|
||||||
* FIXME: These constants should be replaced by strings, at their usage sites.
|
|
||||||
* They are sixbit-packed representations of vocabulary words. This, and code
|
|
||||||
* left in misc.c, is the only place left in the runtime that knows about
|
|
||||||
* word packing.
|
|
||||||
*/
|
|
||||||
#define WORD_CATCH 301200308
|
|
||||||
#define WORD_GO 715
|
|
||||||
#define WORD_POUR 16152118
|
|
||||||
#define WORD_BACK 2010311
|
|
||||||
#define WORD_CAVE 3012205
|
|
||||||
#define WORD_DPRSSN 405161805
|
|
||||||
#define WORD_ENTER 514200518
|
|
||||||
#define WORD_ENTRNC 514201801
|
|
||||||
#define WORD_LOOK 12151511
|
|
||||||
#define WORD_NUL 14211212
|
|
||||||
#define WORD_STREAM 1920180501
|
|
||||||
#define WORD_FIND 6091404
|
|
||||||
#define WORD_INVENT 914220514
|
|
||||||
#define WORD_LOCK 12150311
|
|
||||||
#define WORD_SAY 190125
|
|
||||||
#define WORD_THROW 2008181523
|
|
||||||
#define WORD_WEST 23051920
|
|
||||||
#define WORD_YES 250519
|
|
||||||
#define WORD_YINIT 25
|
|
||||||
|
|
||||||
/* end */
|
/* end */
|
||||||
|
|
||||||
|
|
3
cheat.c
3
cheat.c
|
@ -10,9 +10,6 @@
|
||||||
|
|
||||||
struct game_t game;
|
struct game_t game;
|
||||||
|
|
||||||
long LNLENG, LNPOSN;
|
|
||||||
char rawbuf[LINESIZE], INLINE[LINESIZE + 1];
|
|
||||||
|
|
||||||
FILE *logfp = NULL, *rfp = NULL;
|
FILE *logfp = NULL, *rfp = NULL;
|
||||||
bool oldstyle = false;
|
bool oldstyle = false;
|
||||||
bool editline = true;
|
bool editline = true;
|
||||||
|
|
3
main.c
3
main.c
|
@ -29,9 +29,6 @@
|
||||||
|
|
||||||
struct game_t game;
|
struct game_t game;
|
||||||
|
|
||||||
long LNLENG, LNPOSN;
|
|
||||||
char rawbuf[LINESIZE], INLINE[LINESIZE + 1];
|
|
||||||
|
|
||||||
FILE *logfp = NULL, *rfp = NULL;
|
FILE *logfp = NULL, *rfp = NULL;
|
||||||
bool oldstyle = false;
|
bool oldstyle = false;
|
||||||
bool editline = true;
|
bool editline = true;
|
||||||
|
|
69
misc.c
69
misc.c
|
@ -10,38 +10,6 @@
|
||||||
#include "linenoise/linenoise.h"
|
#include "linenoise/linenoise.h"
|
||||||
#include "dungeon.h"
|
#include "dungeon.h"
|
||||||
|
|
||||||
const char new_advent_to_ascii[] = {
|
|
||||||
' ', '!', '"', '#', '$', '%', '&', '\'',
|
|
||||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
|
||||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
|
||||||
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
|
||||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
|
||||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
|
||||||
'X', 'Y', 'Z', '\0', '\0', '\0', '\0', '\0',
|
|
||||||
};
|
|
||||||
|
|
||||||
const char new_ascii_to_advent[] = {
|
|
||||||
63, 63, 63, 63, 63, 63, 63, 63,
|
|
||||||
63, 63, 63, 63, 63, 63, 63, 63,
|
|
||||||
63, 63, 63, 63, 63, 63, 63, 63,
|
|
||||||
63, 63, 63, 63, 63, 63, 63, 63,
|
|
||||||
|
|
||||||
0, 1, 2, 3, 4, 5, 6, 7,
|
|
||||||
8, 9, 10, 11, 12, 13, 14, 15,
|
|
||||||
16, 17, 18, 19, 20, 21, 22, 23,
|
|
||||||
24, 25, 26, 27, 28, 29, 30, 31,
|
|
||||||
32, 33, 34, 35, 36, 37, 38, 39,
|
|
||||||
40, 41, 42, 43, 44, 45, 46, 47,
|
|
||||||
48, 49, 50, 51, 52, 53, 54, 55,
|
|
||||||
56, 57, 58, 59, 60, 61, 62, 63,
|
|
||||||
|
|
||||||
63, 63, 63, 63, 63, 63, 63, 63,
|
|
||||||
63, 63, 63, 63, 63, 63, 63, 63,
|
|
||||||
63, 63, 63, 63, 63, 63, 63, 63,
|
|
||||||
63, 63, 63, 63, 63, 63, 63, 63,
|
|
||||||
};
|
|
||||||
|
|
||||||
char* xstrdup(const char* s)
|
char* xstrdup(const char* s)
|
||||||
{
|
{
|
||||||
char* ptr = strdup(s);
|
char* ptr = strdup(s);
|
||||||
|
@ -69,10 +37,22 @@ void* xmalloc(size_t size)
|
||||||
|
|
||||||
void packed_to_token(long packed, char token[6])
|
void packed_to_token(long packed, char token[6])
|
||||||
{
|
{
|
||||||
|
// The advent->ascii mapping.
|
||||||
|
const char advent_to_ascii[] = {
|
||||||
|
' ', '!', '"', '#', '$', '%', '&', '\'',
|
||||||
|
'(', ')', '*', '+', ',', '-', '.', '/',
|
||||||
|
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||||
|
'8', '9', ':', ';', '<', '=', '>', '?',
|
||||||
|
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||||
|
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||||
|
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||||
|
'X', 'Y', 'Z', '\0', '\0', '\0', '\0', '\0',
|
||||||
|
};
|
||||||
|
|
||||||
// Unpack and map back to ASCII.
|
// Unpack and map back to ASCII.
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 5; ++i) {
|
||||||
char advent = (packed >> i * 6) & 63;
|
char advent = (packed >> i * 6) & 63;
|
||||||
token[i] = new_advent_to_ascii[(int) advent];
|
token[i] = advent_to_ascii[(int) advent];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the last character is \0.
|
// Ensure the last character is \0.
|
||||||
|
@ -89,10 +69,31 @@ void packed_to_token(long packed, char token[6])
|
||||||
|
|
||||||
long token_to_packed(const char token[6])
|
long token_to_packed(const char token[6])
|
||||||
{
|
{
|
||||||
|
const char ascii_to_advent[] = {
|
||||||
|
63, 63, 63, 63, 63, 63, 63, 63,
|
||||||
|
63, 63, 63, 63, 63, 63, 63, 63,
|
||||||
|
63, 63, 63, 63, 63, 63, 63, 63,
|
||||||
|
63, 63, 63, 63, 63, 63, 63, 63,
|
||||||
|
|
||||||
|
0, 1, 2, 3, 4, 5, 6, 7,
|
||||||
|
8, 9, 10, 11, 12, 13, 14, 15,
|
||||||
|
16, 17, 18, 19, 20, 21, 22, 23,
|
||||||
|
24, 25, 26, 27, 28, 29, 30, 31,
|
||||||
|
32, 33, 34, 35, 36, 37, 38, 39,
|
||||||
|
40, 41, 42, 43, 44, 45, 46, 47,
|
||||||
|
48, 49, 50, 51, 52, 53, 54, 55,
|
||||||
|
56, 57, 58, 59, 60, 61, 62, 63,
|
||||||
|
|
||||||
|
63, 63, 63, 63, 63, 63, 63, 63,
|
||||||
|
63, 63, 63, 63, 63, 63, 63, 63,
|
||||||
|
63, 63, 63, 63, 63, 63, 63, 63,
|
||||||
|
63, 63, 63, 63, 63, 63, 63, 63,
|
||||||
|
};
|
||||||
|
|
||||||
size_t t_len = strlen(token);
|
size_t t_len = strlen(token);
|
||||||
long packed = 0;
|
long packed = 0;
|
||||||
for (size_t i = 0; i < t_len; ++i) {
|
for (size_t i = 0; i < t_len; ++i) {
|
||||||
char mapped = new_ascii_to_advent[(int) token[i]];
|
char mapped = ascii_to_advent[(int) token[i]];
|
||||||
packed |= (mapped << (6 * i));
|
packed |= (mapped << (6 * i));
|
||||||
}
|
}
|
||||||
return (packed);
|
return (packed);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue