Ticket #7904: resource_type_patch

File resource_type_patch, 4.8 KB (added by SF/japj, 19 years ago)

resource type patch

Line 
1Index: resource.cpp
2===================================================================
3RCS file: /cvsroot/scummvm/scummvm/resource.cpp,v
4retrieving revision 1.14
5diff -u -r1.14 resource.cpp
6--- resource.cpp 2001/11/08 20:00:33 1.14
7+++ resource.cpp 2001/11/09 17:41:14
8@@ -175,7 +175,7 @@
9
10 switch(blocktype) {
11 case MKID('DCHR'):
12- readResTypeList(6,MKID('CHAR'),"charset");
13+ readResTypeList(rtCharset,MKID('CHAR'),"charset");
14 break;
15
16 case MKID('DOBJ'):
17@@ -200,15 +200,15 @@
18 break;
19
20 case MKID('DROO'):
21- readResTypeList(1,MKID('ROOM'),"room");
22+ readResTypeList(rtRoom,MKID('ROOM'),"room");
23 break;
24
25 case MKID('DSCR'):
26- readResTypeList(2,MKID('SCRP'),"script");
27+ readResTypeList(rtScript,MKID('SCRP'),"script");
28 break;
29
30 case MKID('DCOS'):
31- readResTypeList(3,MKID('COST'),"costume");
32+ readResTypeList(rtCostume,MKID('COST'),"costume");
33 break;
34
35 case MKID('MAXS'):
36@@ -224,7 +224,7 @@
37 break;
38
39 case MKID('DSOU'):
40- readResTypeList(4,MKID('SOUN'),"sound");
41+ readResTypeList(rtSound,MKID('SOUN'),"sound");
42 break;
43
44 default:
45@@ -265,7 +265,7 @@
46
47 switch(blocktype) {
48 case MKID('DCHR'):
49- readResTypeList(6,MKID('CHAR'),"charset");
50+ readResTypeList(rtCharset,MKID('CHAR'),"charset");
51 break;
52
53 case MKID('DOBJ'):
54@@ -284,15 +284,15 @@
55 break;
56
57 case MKID('DROO'):
58- readResTypeList(1,MKID('ROOM'),"room");
59+ readResTypeList(rtRoom,MKID('ROOM'),"room");
60 break;
61
62 case MKID('DSCR'):
63- readResTypeList(2,MKID('SCRP'),"script");
64+ readResTypeList(rtScript,MKID('SCRP'),"script");
65 break;
66
67 case MKID('DCOS'):
68- readResTypeList(3,MKID('COST'),"costume");
69+ readResTypeList(rtCostume,MKID('COST'),"costume");
70 break;
71
72 case MKID('MAXS'):
73@@ -300,7 +300,7 @@
74 break;
75
76 case MKID('DSOU'):
77- readResTypeList(4,MKID('SOUN'),"sound");
78+ readResTypeList(rtSound,MKID('SOUN'),"sound");
79 break;
80
81 case MKID('AARY'):
82@@ -412,7 +412,7 @@
83
84 debug(9, "ensureResourceLoaded(%d,%d)", type, i);
85
86- if (type==1 && i>127) {
87+ if (type==rtRoom && i>127) {
88 i = _resourceMapper[i&127];
89 }
90
91@@ -425,7 +425,7 @@
92
93 loadResource(type, i);
94
95- if (type==1 && i==_roomResource)
96+ if (type==rtRoom && i==_roomResource)
97 _vars[VAR_ROOM_FLAG] = 1;
98 }
99
100@@ -442,7 +442,7 @@
101 res.name[type],index);
102 }
103
104- if (type==1) {
105+ if (type==rtRoom) {
106 fileOffs = 0;
107 } else {
108 fileOffs = res.roomoffs[type][index];
109@@ -455,7 +455,7 @@
110 openRoom(roomNr);
111
112 fileSeek(_fileHandle, fileOffs + _fileOffset, SEEK_SET);
113- if (type==4) {
114+ if (type==rtSound) {
115 fileReadDwordLE();
116 fileReadDwordLE();
117 return readSoundResource(type, index);
118@@ -475,7 +475,7 @@
119
120 /* dump the resource */
121 #ifdef DUMP_SCRIPTS
122- if(type==2) {
123+ if(type==rtScript) {
124 dumpResource("script-", index, getResourceAddress(rtScript, index));
125 }
126 #endif
127@@ -527,7 +527,7 @@
128 }
129
130 int Scumm::getResourceRoomNr(int type, int index) {
131- if (type==1)
132+ if (type==rtRoom)
133 return index;
134 return res.roomno[type][index];
135 }
136@@ -603,7 +603,7 @@
137 }
138
139 void Scumm::validateResource(const char *str, int type, int index) {
140- if (type<1 || type>16 || index<0 || index >= res.num[type]) {
141+ if (type<rtRoom || type>=rtLastResourceType || index<0 || index >= res.num[type]) {
142 error("%d Illegal Glob type %d num %d", str, type, index);
143 }
144 }
145Index: saveload.cpp
146===================================================================
147RCS file: /cvsroot/scummvm/scummvm/saveload.cpp,v
148retrieving revision 1.10
149diff -u -r1.10 saveload.cpp
150--- saveload.cpp 2001/11/07 18:10:51 1.10
151+++ saveload.cpp 2001/11/09 17:41:15
152@@ -439,7 +439,7 @@
153 byte flag;
154
155 /* don't save/load these resource types */
156- if (type==13 || type==12 || type==10 || res.mode[type])
157+ if (type==rtFlObject || type==rtTemp || type==rtBuffer || res.mode[type])
158 return;
159
160 if (ser->isSaving()) {
161@@ -454,7 +454,7 @@
162 ser->saveUint32(size);
163 ser->saveLoadBytes(ptr+sizeof(ResHeader),size);
164
165- if (type==5) {
166+ if (type==rtInventory) {
167 ser->saveWord(_inventory[index]);
168 }
169 } else {
170@@ -462,7 +462,7 @@
171 if (size) {
172 createResource(type, index, size);
173 ser->saveLoadBytes(getResourceAddress(type, index), size);
174- if (type==5) {
175+ if (type==rtInventory) {
176 _inventory[index] = ser->loadWord();
177 }
178 }
179Index: scumm.h
180===================================================================
181RCS file: /cvsroot/scummvm/scummvm/scumm.h,v
182retrieving revision 1.21
183diff -u -r1.21 scumm.h
184--- scumm.h 2001/11/07 21:44:09 1.21
185+++ scumm.h 2001/11/09 17:41:17
186@@ -305,6 +305,7 @@
187 rtMatrix = 14,
188 rtBox = 15,
189 rtObjectName = 16,
190+ rtLastResourceType=17,
191
192 };
193