[Scummvm-cvs-logs] SF.net SVN: scummvm: [21450] scummvm/trunk/engines/scumm/he
kirben at users.sourceforge.net
kirben at users.sourceforge.net
Sat Mar 25 03:02:01 CET 2006
Revision: 21450
Author: kirben
Date: 2006-03-25 03:01:00 -0800 (Sat, 25 Mar 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=21450&view=rev
Log Message:
-----------
Move convertFilePath() to ScummEngine_v60he, to allow use by earlier HE games
Modified Paths:
--------------
scummvm/trunk/engines/scumm/he/intern_he.h
scummvm/trunk/engines/scumm/he/script_v60he.cpp
scummvm/trunk/engines/scumm/he/script_v72he.cpp
scummvm/trunk/engines/scumm/he/wiz_he.cpp
Modified: scummvm/trunk/engines/scumm/he/intern_he.h
===================================================================
--- scummvm/trunk/engines/scumm/he/intern_he.h 2006-03-25 10:39:05 UTC (rev 21449)
+++ scummvm/trunk/engines/scumm/he/intern_he.h 2006-03-25 11:01:00 UTC (rev 21450)
@@ -66,8 +66,11 @@
void redimArray(int arrayId, int newX, int newY, int d);
int readFileToArray(int slot, int32 size);
void writeFileFromArray(int slot, int resID);
+
int virtScreenSave(byte *dst, int x1, int y1, int x2, int y2);
void virtScreenLoad(int resIdx, int x1, int y1, int x2, int y2);
+
+ int convertFilePath(byte *dst, bool setFilePath = false);
virtual void decodeParseString(int a, int b);
void swapObjects(int object1, int object2);
@@ -267,7 +270,6 @@
virtual void decodeParseString(int a, int b);
void decodeScriptString(byte *dst, bool scriptString = false);
void copyScriptString(byte *dst, int dstSize);
- int convertFilePath(byte *dst, bool setFilePath = false);
int findObject(int x, int y, int num, int *args);
int getSoundResourceSize(int id);
Modified: scummvm/trunk/engines/scumm/he/script_v60he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v60he.cpp 2006-03-25 10:39:05 UTC (rev 21449)
+++ scummvm/trunk/engines/scumm/he/script_v60he.cpp 2006-03-25 11:01:00 UTC (rev 21450)
@@ -399,6 +399,51 @@
return _opcodesv60he[i].desc;
}
+int ScummEngine_v60he::convertFilePath(byte *dst, bool setFilePath) {
+ debug(1, "convertFilePath: original filePath is %s", dst);
+
+ int len = resStrLen(dst) + 1;
+ if (dst[0] == ':') {
+ // Switch all : to / for portablity
+ int j = 0;
+ for (int i = 1; i < len; i++) {
+ if (dst[i] == ':')
+ dst[j++] = '/';
+ else
+ dst[j++] = dst[i];
+ }
+ } else {
+ // Switch all \ to / for portablity
+ for (int i = 0; i < len; i++) {
+ if (dst[i] == '\\')
+ dst[i] = '/';
+ }
+ }
+
+ // Strip path
+ int r = 0;
+ if (dst[0] == '.' && dst[1] == '/') {
+ r = 2;
+ } else if (dst[0] == 'c' && dst[1] == ':') {
+ for (r = len; r != 0; r--) {
+ if (dst[r - 1] == '/')
+ break;
+ }
+ }
+
+ if (setFilePath) {
+ char filePath[256];
+ sprintf(filePath, "%s", dst + r);
+ if (!Common::File::exists(filePath)) {
+ sprintf(filePath, "%s%s", _saveFileMan->getSavePath(), dst + r);
+ }
+ strcpy((char *)dst, filePath);
+ debug(1, "convertFilePath: filePath is %s", dst);
+ }
+
+ return r;
+}
+
void ScummEngine_v60he::o60_setState() {
int state = pop();
int obj = pop();
Modified: scummvm/trunk/engines/scumm/he/script_v72he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v72he.cpp 2006-03-25 10:39:05 UTC (rev 21449)
+++ scummvm/trunk/engines/scumm/he/script_v72he.cpp 2006-03-25 11:01:00 UTC (rev 21450)
@@ -526,51 +526,6 @@
}
}
-int ScummEngine_v72he::convertFilePath(byte *dst, bool setFilePath) {
- debug(1, "convertFilePath: original filePath is %s", dst);
-
- int len = resStrLen(dst) + 1;
- if (dst[0] == ':') {
- // Switch all : to / for portablity
- int j = 0;
- for (int i = 1; i < len; i++) {
- if (dst[i] == ':')
- dst[j++] = '/';
- else
- dst[j++] = dst[i];
- }
- } else {
- // Switch all \ to / for portablity
- for (int i = 0; i < len; i++) {
- if (dst[i] == '\\')
- dst[i] = '/';
- }
- }
-
- // Strip path
- int r = 0;
- if (dst[0] == '.' && dst[1] == '/') {
- r = 2;
- } else if (dst[0] == 'c' && dst[1] == ':') {
- for (r = len; r != 0; r--) {
- if (dst[r - 1] == '/')
- break;
- }
- }
-
- if (setFilePath) {
- char filePath[256];
- sprintf(filePath, "%s", dst + r);
- if (!Common::File::exists(filePath)) {
- sprintf(filePath, "%s%s", _saveFileMan->getSavePath(), dst + r);
- }
- strcpy((char *)dst, filePath);
- debug(1, "convertFilePath: filePath is %s", dst);
- }
-
- return r;
-}
-
void ScummEngine_v72he::copyScriptString(byte *dst, int dstSize) {
byte string[1024];
byte chr;
Modified: scummvm/trunk/engines/scumm/he/wiz_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/wiz_he.cpp 2006-03-25 10:39:05 UTC (rev 21449)
+++ scummvm/trunk/engines/scumm/he/wiz_he.cpp 2006-03-25 11:01:00 UTC (rev 21450)
@@ -1873,8 +1873,7 @@
}
void Wiz::processWizImage(const WizParameters *params) {
- char buf[512];
- unsigned int i;
+ byte filename[260];
debug(2, "processWizImage: processMode %d", params->processMode);
switch (params->processMode) {
@@ -1891,14 +1890,10 @@
if (params->processFlags & kWPFUseFile) {
Common::File f;
- // Convert Windows path separators to something more portable
- strncpy(buf, (const char *)params->filename, 512);
- for (i = 0; i < strlen(buf); i++) {
- if (buf[i] == '\\')
- buf[i] = '/';
- }
+ memcpy(filename, params->filename, 260);
+ _vm->convertFilePath(filename);
- if (f.open((const char *)buf, Common::File::kFileReadMode)) {
+ if (f.open((const char *)filename, Common::File::kFileReadMode)) {
uint32 id = f.readUint32BE();
if (id == MKID_BE('AWIZ') || id == MKID_BE('MULT')) {
uint32 size = f.readUint32BE();
@@ -1906,7 +1901,7 @@
byte *p = _vm->res.createResource(rtImage, params->img.resNum, size);
if (f.read(p, size) != size) {
_vm->res.nukeResource(rtImage, params->img.resNum);
- error("i/o error when reading '%s'", buf);
+ error("i/o error when reading '%s'", filename);
_vm->VAR(_vm->VAR_GAME_LOADED) = -2;
_vm->VAR(119) = -2;
} else {
@@ -1922,7 +1917,7 @@
} else {
_vm->VAR(_vm->VAR_GAME_LOADED) = -3;
_vm->VAR(119) = -3;
- debug(0, "Unable to open for read '%s'", buf);
+ debug(0, "Unable to open for read '%s'", filename);
}
}
break;
@@ -1938,15 +1933,11 @@
// TODO Write image to file
break;
case 0:
- // Convert Windows path separators to something more portable
- strncpy(buf, (const char *)params->filename, 512);
- for (i = 0; i < strlen(buf); i++) {
- if (buf[i] == '\\')
- buf[i] = '/';
- }
+ memcpy(filename, params->filename, 260);
+ _vm->convertFilePath(filename);
- if (!f.open((const char *)buf, Common::File::kFileWriteMode)) {
- debug(0, "Unable to open for write '%s'", buf);
+ if (!f.open((const char *)filename, Common::File::kFileWriteMode)) {
+ debug(0, "Unable to open for write '%s'", filename);
_vm->VAR(119) = -3;
} else {
byte *p = _vm->getResourceAddress(rtImage, params->img.resNum);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list