Ticket #7547: iqpoints2.diff
File iqpoints2.diff, 5.1 KB (added by , 18 years ago) |
---|
-
engines/scumm/scumm.cpp
1704 1704 } 1705 1705 } 1706 1706 1707 if (_game.id == GID_INDY3) { 1708 saveLoadIQPoints(true); 1709 } 1710 1707 1711 return 0; 1708 1712 } 1709 1713 -
engines/scumm/scumm.h
603 603 bool _saveTemporaryState; 604 604 char _saveLoadName[32]; 605 605 606 void saveLoadIQPoints(bool save); 607 606 608 bool saveState(int slot, bool compat); 607 609 bool loadState(int slot, bool compat); 608 610 virtual void saveOrLoad(Serializer *s); -
engines/scumm/saveload.cpp
69 69 70 70 #define INFOSECTION_VERSION 2 71 71 72 void ScummEngine::saveLoadIQPoints(bool save) { 73 assert(_game.id == GID_INDY3); 74 75 // Save/load the "series" IQ points for Indy3. See FR #1666521 for 76 // some explanations as to why/how this code works. 77 // We store string 7, but load string 9 (this is on purpose). 78 char iqPointsFilename[32]; 79 sprintf(iqPointsFilename, "%s.___", _targetName.c_str()); 80 81 if (save) { 82 Common::OutSaveFile *file = _saveFileMan->openForSaving(iqPointsFilename); 83 if (file != NULL) { 84 int size = getResourceSize(rtString, 7); 85 byte *ptr = getResourceAddress(rtString, 7); 86 file->write(ptr, size); 87 delete file; 88 } 89 } else { 90 Common::InSaveFile *file = _saveFileMan->openForLoading(iqPointsFilename); 91 if (file != NULL) { 92 int len = file->size(); 93 byte *ptr9 = (byte *)malloc(len); 94 len = file->read(ptr9, len); // Read the future content of string 9 95 loadPtrToResource(rtString, 9, ptr9); 96 97 byte *ptr7 = getResourceAddress(rtString, 7); 98 99 int seriesIQ = 0; 100 for (int i = 0; i <= 73; ++i) { 101 if (ptr9[i]) 102 ptr7[i] = ptr9[i]; 103 seriesIQ += ptr7[i]; 104 } 105 // TODO: Set var 245 to seriesIQ ??? 106 107 free(ptr9); 108 delete file; 109 } 110 } 111 } 112 72 113 void ScummEngine::requestSave(int slot, const char *name, bool temporary) { 73 114 _saveLoadSlot = slot; 74 115 _saveTemporaryState = temporary; … … 1108 1149 1109 1150 s->saveLoadArrayOf(_bitVars, _numBitVariables >> 3, 1, sleByte); 1110 1151 1152 if (_game.id == GID_INDY3) { 1153 saveLoadIQPoints(s->isSaving()); 1154 } 1111 1155 1112 1156 // 1113 1157 // Save/load a list of the locked objects -
engines/scumm/script_v5.cpp
871 871 void ScummEngine_v5::saveVars() { 872 872 int a, b; 873 873 874 // FIXME: This opcode is currently a stub. It is needed for at least two things: 874 // This opcode is a stub, on purpose. As far as we know it is used 875 // for precisely two things. 875 876 // * storing save game names in Indy 3 (and maybe others) 876 877 // * storing the global IQ (Indy Quotient) in Indy 3 877 878 // The former is not so important as we have our own save system, but the 878 879 // latter one of course is a desirable feature. 879 // So implementing this would be nice indeed. Not sure what the filename 880 // should be -- either base it on the target name, or base it on the gameid. 881 // Both approaches have their merits, though. 880 // However, there are at least two problems: First off, it's questionable 881 // whether using the filename passed to this opcode is a good idea. 882 // It might clash with others, and is neither target nor gameid specific, 883 // which could lead to conflicts. 884 // Secondly, the scripts calling this opcode are only run when using the 885 // built-in save/load dialog of Indy3, which we don't. 886 // 887 // Hence, instead of all this, we store the relevant strings (7 resp. 9) 888 // ourselves with custom code in ScummEngine::saveOrLoad(). 882 889 883 890 while ((_opcode = fetchScriptByte()) != 0) { 884 891 switch (_opcode & 0x1F) { … … 911 918 void ScummEngine_v5::loadVars() { 912 919 int a, b; 913 920 914 // FIXME: See ScummEngine_v5::saveVars 921 // See ScummEngine_v5::saveVars for an explanation of this opcode and 922 // why it is only a stub. 915 923 916 // Common::hexdump(_scriptPointer, 64);917 924 while ((_opcode = fetchScriptByte()) != 0) { 918 925 switch (_opcode & 0x1F) { 919 926 case 0x01: // read a range of variables … … 1985 1992 file = _saveFileMan->openForLoading(filename); 1986 1993 if (file != NULL) { 1987 1994 byte *ptr; 1988 int len = 256, cnt = 0;1995 int len = file->size(); 1989 1996 ptr = (byte *)malloc(len); 1990 while (ptr) { 1991 int r = file->read(ptr + cnt, len - cnt); 1992 cnt += r; 1993 if (cnt < len) 1994 break; 1995 len *= 2; 1996 ptr = (byte *)realloc(ptr, len); 1997 } 1998 ptr[cnt] = '\0'; 1997 len = file->read(ptr, len); 1999 1998 loadPtrToResource(rtString, a, ptr); 2000 1999 free(ptr); 2001 2000 delete file; … … 2303 2302 _opcode = fetchScriptByte(); 2304 2303 switch (_opcode & 0x1F) { 2305 2304 case 1: /* loadstring */ 2306 loadPtrToResource(rtString, getVarOrDirectByte(PARAM_1), NULL); 2305 a = getVarOrDirectByte(PARAM_1); 2306 loadPtrToResource(rtString, a, NULL); 2307 2307 break; 2308 2308 case 2: /* copystring */ 2309 2309 a = getVarOrDirectByte(PARAM_1);