[Scummvm-git-logs] scummvm master -> fe96c942efb81c6d4c83161718c6e06518b4bf0a

bluegr bluegr at gmail.com
Sun Jan 6 21:16:05 CET 2019


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
1d8a069e24 GLK: ALAN2: Initialize game file name
fe96c942ef GLK: ALAN2: Resolve some TODOs. Some cleanup


Commit: 1d8a069e24eeb0c770275411a4be2e3eeb6ab30c
    https://github.com/scummvm/scummvm/commit/1d8a069e24eeb0c770275411a4be2e3eeb6ab30c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2019-01-06T22:14:42+02:00

Commit Message:
GLK: ALAN2: Initialize game file name

Changed paths:
    engines/glk/alan2/alan2.cpp


diff --git a/engines/glk/alan2/alan2.cpp b/engines/glk/alan2/alan2.cpp
index 60889f7..da9dbf1 100644
--- a/engines/glk/alan2/alan2.cpp
+++ b/engines/glk/alan2/alan2.cpp
@@ -46,9 +46,10 @@ Alan2::Alan2(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, g
 }
 
 void Alan2::runGame() {
+	Common::String gameFileName = _gameFile.getName();
+
 	// TODO: Initialize these properly
 	int tmp = 0;
-	Common::String gameFileName;
 	_decode = new Decode(nullptr, nullptr);
 	_execute = new Execute();
 	_saveLoad = new SaveLoad(gameFileName, nullptr, nullptr, nullptr, nullptr, &tmp);


Commit: fe96c942efb81c6d4c83161718c6e06518b4bf0a
    https://github.com/scummvm/scummvm/commit/fe96c942efb81c6d4c83161718c6e06518b4bf0a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2019-01-06T22:15:37+02:00

Commit Message:
GLK: ALAN2: Resolve some TODOs. Some cleanup

Changed paths:
    engines/glk/alan2/parse.cpp
    engines/glk/alan2/parse.h


diff --git a/engines/glk/alan2/parse.cpp b/engines/glk/alan2/parse.cpp
index 7cb34c1..e8b4f1f 100644
--- a/engines/glk/alan2/parse.cpp
+++ b/engines/glk/alan2/parse.cpp
@@ -62,12 +62,10 @@ void Parser::unknown(char *inputStr) {
 }
 
 int Parser::lookup(char *wrd) {
-#if 0
 	for (int i = 0; !endOfTable(&dict[i]); i++) {
 		if (strcmp(wrd, (char *)addrTo(dict[i].wrd)) == 0)
 			return i;
 	}
-#endif
 
 	unknown(wrd);
 	return EOF;
@@ -236,30 +234,41 @@ void Parser::nonverb() {
 		_vm->printError(M_WHAT);
 }
 
+Aword Parser::where(Aword id) {
+	if (isObj(id))
+		return objloc(id);
+	else if (isAct(id))
+		return acts[id - ACTMIN].loc;
+	else
+		error("Can't WHERE item (%ld).", (unsigned long)id);
+}
+
+Aword Parser::objloc(Aword obj) {
+	if (isCnt(objs[obj - OBJMIN].loc)) // In something ?
+		if (isObj(objs[obj - OBJMIN].loc) || isAct(objs[obj - OBJMIN].loc))
+			return where(objs[obj - OBJMIN].loc);
+		else // Containers not anywhere is where the hero is!
+			return where(HERO);
+	else
+		return(objs[obj - OBJMIN].loc);
+}
+
 Abool Parser::objhere(Aword obj) {
 	if (isCnt(objs[obj - OBJMIN].loc)) {	// In something?
 		if (isObj(objs[obj - OBJMIN].loc) || isAct(objs[obj - OBJMIN].loc))
-			return(isHere(objs[obj - OBJMIN].loc));
-// TODO
-#if 0
+			return isHere(objs[obj - OBJMIN].loc);
 		else // If the container wasn't anywhere, assume where HERO is!
-			return(where(HERO) == _vm->cur.loc);
-#endif
-
+			return where(HERO) == _vm->cur.loc;
 	} else
 		return(objs[obj - OBJMIN].loc == _vm->cur.loc);
 }
 
 
-Aword Parser::acthere(Aword act) {
-	return(acts[act - ACTMIN].loc == _vm->cur.loc);
-}
-
 Abool Parser::isHere(Aword id) {
 	if (isObj(id))
 		return objhere(id);
 	else if (isAct(id))
-		return acthere(id);
+		return acts[id - ACTMIN].loc == _vm->cur.loc;
 	else
 		error("Can't HERE item (%ld).", (unsigned long)id);
 }
@@ -571,20 +580,20 @@ void Parser::complex(ParamElem olst[]) {
 bool Parser::claCheck(ClaElem *cla) {
 	bool ok = false;
 
-	if ((cla->classes&(Aword)CLA_OBJ) != 0)
-		ok = ok || isObj(params[cla->code-1].code);
-	if ((cla->classes&(Aword)CLA_CNT) != 0)
-		ok = ok || isCnt(params[cla->code-1].code);
-	if ((cla->classes&(Aword)CLA_ACT) != 0)
-		ok = ok || isAct(params[cla->code-1].code);
-	if ((cla->classes&(Aword)CLA_NUM) != 0)
-		ok = ok || isNum(params[cla->code-1].code);
-	if ((cla->classes&(Aword)CLA_STR) != 0)
-		ok = ok || isStr(params[cla->code-1].code);
-	if ((cla->classes&(Aword)CLA_COBJ) != 0)
-		ok = ok || (isCnt(params[cla->code-1].code) && isObj(params[cla->code-1].code));
-	if ((cla->classes&(Aword)CLA_CACT) != 0)
-		ok = ok || (isCnt(params[cla->code-1].code) && isAct(params[cla->code-1].code));
+	if ((cla->classes & (Aword)CLA_OBJ) != 0)
+		ok = ok || isObj(params[cla->code - 1].code);
+	if ((cla->classes & (Aword)CLA_CNT) != 0)
+		ok = ok || isCnt(params[cla->code - 1].code);
+	if ((cla->classes & (Aword)CLA_ACT) != 0)
+		ok = ok || isAct(params[cla->code - 1].code);
+	if ((cla->classes & (Aword)CLA_NUM) != 0)
+		ok = ok || isNum(params[cla->code - 1].code);
+	if ((cla->classes & (Aword)CLA_STR) != 0)
+		ok = ok || isStr(params[cla->code - 1].code);
+	if ((cla->classes & (Aword)CLA_COBJ) != 0)
+		ok = ok || (isCnt(params[cla->code - 1].code) && isObj(params[cla->code - 1].code));
+	if ((cla->classes & (Aword)CLA_CACT) != 0)
+		ok = ok || (isCnt(params[cla->code - 1].code) && isAct(params[cla->code - 1].code));
 
 	return ok;
 }
@@ -595,12 +604,13 @@ void Parser::resolve(ParamElem plst[]) {
 
 	// Resolve ambiguities by presence
 	for (int i = 0; plst[i].code != EOF; i++)  {
-		if (plst[i].code < LITMIN)	// Literals are always 'here'
+		if (plst[i].code < LITMIN) { // Literals are always 'here'
 			if (!isHere(plst[i].code)) {
 				params[0] = plst[i];	// Copy error param as first one for message
 				params[1].code = EOF;	// But be sure to terminate
 				_vm->printError(M_NO_SUCH);
 			}
+		}
 	}
 }
 
@@ -634,6 +644,11 @@ bool Parser::endOfTable(ChkElem *addr) {
 	return *x == EOF;
 }
 
+bool Parser::endOfTable(WrdElem *addr) {
+	Aword *x = (Aword *)addr;
+	return *x == EOF;
+}
+
 AltElem *Parser::findalt(Aword vrbsadr, Aword param) {
 	VrbElem *vrb;
 	AltElem *alt;
diff --git a/engines/glk/alan2/parse.h b/engines/glk/alan2/parse.h
index 1f3a3fb..f88fd74 100644
--- a/engines/glk/alan2/parse.h
+++ b/engines/glk/alan2/parse.h
@@ -50,9 +50,10 @@ private:
 	void nonverb();
 	
 	Abool objhere(Aword obj);
-	Aword acthere(Aword act);
+	Aword objloc(Aword obj);
 	Abool isHere(Aword id);
-	
+	Aword where(Aword id);
+
 	/**
 	 * Build a list of objects matching 'all'
 	 */
@@ -113,6 +114,7 @@ private:
 	bool endOfTable(VrbElem *addr);
 	bool endOfTable(AltElem *addr);
 	bool endOfTable(ChkElem *addr);
+	bool endOfTable(WrdElem *addr);
 	
 	/**
 	 * Find the verb alternative wanted in a verb list and return





More information about the Scummvm-git-logs mailing list