GLK: AGT: Get two-word commands fix to work for both AGT and AGX

This commit is contained in:
Walter Agazzi 2022-09-24 21:32:15 +02:00 committed by Paul Gilbert
parent 8c5a1d1e37
commit 5460bfdec5
4 changed files with 39 additions and 35 deletions

View File

@ -889,6 +889,7 @@ const char *get_objattr_str(int dtype, int id, long val);
const opdef *get_opdef(integer op);
char *objname(int);
void sort_cmd(void);
void cmds_syns_canon(void);
void agtwarn(const char *, int elev);
void agtnwarn(const char *, int, int elev);

View File

@ -549,40 +549,6 @@ static int translate_vnum(int vnum)
return vnum;
}
static word check_comb(int combptr, int verbcmd, int nouncmd) {
word w;
if (combptr == 0) return 0;
w = syntbl[combptr];
if (syntbl[combptr+1] != verbcmd) return 0;
if (syntbl[combptr+2] != nouncmd) return 0;
if (syntbl[combptr+3] == 0) return w;
return 0;
}
/* For metacommands that apply to built-in two-word synonyms (e.g. GET OUT),
change the command to apply to the canonical form. */
void command_syn_canon(cmd_rec* cmd) {
int i, vb;
word w;
/* VERB NOUN only */
if(cmd->verbcmd > 0 && cmd->nouncmd > 0 && cmd->prep == 0 && cmd->objcmd == 0) {
for(i = 0; i < num_auxcomb; i++) {
w = check_comb(auxcomb[i], cmd->verbcmd, cmd->nouncmd);
if (w > 0) {
vb = verb_builtin(w);
if(vb > 0) {
cmd->verbcmd = syntbl[auxsyn[vb]];
cmd->nouncmd = 0;
}
}
}
}
}
#define CREC_SIZE (FRS_CMD)
static long badtokcnt;
@ -624,7 +590,6 @@ static void read_da5(fc_type fc) {
cmd_ptr[i] = (long)buff[bp] + (((long)buff[bp + 1]) << 8);
bp += 2;
}
command_syn_canon(command+i);
}
if (DIAG)
rprintf(" Internal:%ld\n", bp);
@ -1737,6 +1702,8 @@ static void finish_read(rbool cleanup)
flagnum++;
}
}
cmds_syns_canon();
}
void free_all_agtread() {

View File

@ -1141,7 +1141,9 @@ int read_agx(fc_type fc, rbool diag) {
descr_ofs = index[11].file_offset;
mem_descr = nullptr;
}
reinit_dict();
cmds_syns_canon();
return 1;
}

View File

@ -1261,8 +1261,42 @@ void sort_cmd(void) {
}
}
static word check_comb(int combptr, int verbcmd, int nouncmd) {
word w;
if (combptr == 0) return 0;
w = syntbl[combptr];
if (syntbl[combptr+1] != verbcmd) return 0;
if (syntbl[combptr+2] != nouncmd) return 0;
if (syntbl[combptr+3] == 0) return w;
return 0;
}
/* For metacommands that apply to built-in two-word synonyms (e.g. GET OUT),
change the command to apply to the canonical form. */
void cmds_syns_canon(void) {
int i, j, vb;
word w;
for (i = 0; i < last_cmd; i++) {
/* VERB NOUN only */
if (command[i].verbcmd > 0 && command[i].nouncmd > 0 && command[i].prep == 0 &&
command[i].objcmd == 0) {
for (j = 0; j < num_auxcomb; j++) {
w = check_comb(auxcomb[j], command[i].verbcmd, command[i].nouncmd);
if (w > 0) {
vb = verb_builtin(w);
if (vb > 0) {
command[i].verbcmd = syntbl[auxsyn[vb]];
command[i].nouncmd = 0;
}
}
}
}
}
}
/* ------------------------------------------------------------------- */
/* Functions for getting opcode information */