RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.11
diff -u -r1.11 resource.cpp
|
|
|
1111 | 1111 | { |
1112 | 1112 | byte *ptr; |
1113 | 1113 | |
1114 | | CHECK_HEAP validateResource("getResourceAddress", type, idx); |
| 1114 | CHECK_HEAP if (!validateResource("getResourceAddress", type, idx)) |
| 1115 | return NULL; |
| 1116 | |
1115 | 1117 | if (!res.address[type]) { |
1116 | 1118 | debug(9, "getResourceAddress(%s,%d), res.address[type] == NULL", resTypeFromId(type), idx); |
1117 | 1119 | return NULL; |
… |
… |
|
1174 | 1176 | |
1175 | 1177 | CHECK_HEAP debug(9, "createResource(%s,%d,%d)", resTypeFromId(type), idx, size); |
1176 | 1178 | |
1177 | | validateResource("allocating", type, idx); |
| 1179 | if (!validateResource("allocating", type, idx)) |
| 1180 | return NULL; |
1178 | 1181 | nukeResource(type, idx); |
1179 | 1182 | |
1180 | 1183 | expireResources(size); |
… |
… |
|
1192 | 1195 | return ptr + sizeof(MemBlkHeader); /* skip header */ |
1193 | 1196 | } |
1194 | 1197 | |
1195 | | void Scumm::validateResource(const char *str, int type, int idx) |
| 1198 | bool Scumm::validateResource(const char *str, int type, int idx) |
1196 | 1199 | { |
1197 | 1200 | if (type < rtFirst || type > rtLast || (uint) idx >= (uint) res.num[type]) { |
1198 | 1201 | warning("%s Illegal Glob type %s (%d) num %d", str, resTypeFromId(type), type, idx); |
| 1202 | return false; |
1199 | 1203 | } |
| 1204 | return true; |
1200 | 1205 | } |
1201 | 1206 | |
1202 | 1207 | void Scumm::nukeResource(int type, int idx) |
… |
… |
|
1370 | 1375 | |
1371 | 1376 | void Scumm::lock(int type, int i) |
1372 | 1377 | { |
1373 | | validateResource("Locking", type, i); |
| 1378 | if (!validateResource("Locking", type, i)) |
| 1379 | return; |
1374 | 1380 | res.flags[type][i] |= RF_LOCK; |
1375 | 1381 | |
1376 | 1382 | // debug(1, "locking %d,%d", type, i); |
… |
… |
|
1378 | 1384 | |
1379 | 1385 | void Scumm::unlock(int type, int i) |
1380 | 1386 | { |
1381 | | validateResource("Unlocking", type, i); |
| 1387 | if (!validateResource("Unlocking", type, i)) |
| 1388 | return; |
1382 | 1389 | res.flags[type][i] &= ~RF_LOCK; |
1383 | 1390 | |
1384 | 1391 | // debug(1, "unlocking %d,%d", type, i); |
… |
… |
|
1386 | 1393 | |
1387 | 1394 | bool Scumm::isResourceInUse(int type, int i) |
1388 | 1395 | { |
1389 | | validateResource("isResourceInUse", type, i); |
| 1396 | if (!validateResource("isResourceInUse", type, i)) |
| 1397 | return false; |
1390 | 1398 | switch (type) { |
1391 | 1399 | case rtRoom: |
1392 | 1400 | return _roomResource == (byte)i; |
… |
… |
|
1503 | 1511 | |
1504 | 1512 | bool Scumm::isResourceLoaded(int type, int idx) |
1505 | 1513 | { |
1506 | | validateResource("isLoaded", type, idx); |
| 1514 | if (!validateResource("isLoaded", type, idx)) |
| 1515 | return false; |
1507 | 1516 | return res.address[type][idx] != NULL; |
1508 | 1517 | } |
1509 | 1518 | |
… |
… |
|
1674 | 1683 | |
1675 | 1684 | bool Scumm::isGlobInMemory(int type, int idx) |
1676 | 1685 | { |
1677 | | validateResource("isGlobInMemory", type, idx); |
| 1686 | if (!validateResource("isGlobInMemory", type, idx)) |
| 1687 | return false; |
1678 | 1688 | |
1679 | 1689 | return res.address[type][idx] != NULL; |
1680 | 1690 | } |
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.28
diff -u -r1.28 scumm.h
|
|
|
600 | 600 | int readSoundResource(int type, int index); |
601 | 601 | int readSoundResourceSmallHeader(int type, int index); |
602 | 602 | void setResourceCounter(int type, int index, byte flag); |
603 | | void validateResource(const char *str, int type, int index); |
| 603 | bool validateResource(const char *str, int type, int index); |
604 | 604 | void increaseResourceCounter(); |
605 | 605 | bool isResourceInUse(int type, int i); |
606 | 606 | bool isResourceLoaded(int type, int index); |