diff options
author | Matthew Hoops | 2007-09-20 21:55:37 +0000 |
---|---|---|
committer | Matthew Hoops | 2007-09-20 21:55:37 +0000 |
commit | 9ae47673e0bbaf2e16d1c2ddb69e58dcb2a5bcf3 (patch) | |
tree | 69f0f827bbefa802a826f7df639448e2c3f1df74 /engines/agi | |
parent | 341b8f1e67610d7843a75f37fe915f9354fc1188 (diff) | |
download | scummvm-rg350-9ae47673e0bbaf2e16d1c2ddb69e58dcb2a5bcf3.tar.gz scummvm-rg350-9ae47673e0bbaf2e16d1c2ddb69e58dcb2a5bcf3.tar.bz2 scummvm-rg350-9ae47673e0bbaf2e16d1c2ddb69e58dcb2a5bcf3.zip |
cleanup to readObj and readRoom
svn-id: r28993
Diffstat (limited to 'engines/agi')
-rw-r--r-- | engines/agi/preagi_winnie.cpp | 33 | ||||
-rw-r--r-- | engines/agi/preagi_winnie.h | 4 |
2 files changed, 19 insertions, 18 deletions
diff --git a/engines/agi/preagi_winnie.cpp b/engines/agi/preagi_winnie.cpp index 49e62d79f5..244f4030b3 100644 --- a/engines/agi/preagi_winnie.cpp +++ b/engines/agi/preagi_winnie.cpp @@ -57,19 +57,20 @@ void Winnie::initVars() { winnie_event = false; } -void Winnie::readRoom(int iRoom, uint8 *buffer, int buflen) { +uint32 Winnie::readRoom(int iRoom, uint8 *buffer) { char szFile[256] = {0}; sprintf(szFile, IDS_WTP_PATH_ROOM, iRoom); Common::File file; if (!file.open(szFile)) - return; + return 0; uint32 filelen = file.size(); memset(buffer, 0, sizeof(buffer)); file.read(buffer, filelen); file.close(); + return filelen; } -int Winnie::readObj(int iObj, uint8 *buffer, int buflen) { +uint32 Winnie::readObj(int iObj, uint8 *buffer) { char szFile[256] = {0}; sprintf(szFile, IDS_WTP_PATH_OBJ, iObj); Common::File file; @@ -404,7 +405,7 @@ void Winnie::printObjStr(int iObj, int iStr) { WTP_OBJ_HDR hdr; uint8 *buffer = (uint8 *)malloc(2048); - readObj(iObj, buffer, 2048); + readObj(iObj, buffer); memcpy(&hdr, buffer, sizeof(hdr)); _vm->printStrXOR((char *)(buffer + hdr.ofsStr[iStr] - IDI_WTP_OFS_OBJ)); @@ -417,9 +418,9 @@ bool Winnie::isRightObj(int iRoom, int iObj, int *iCode) { uint8 *roomdata = (uint8 *)malloc(4096); uint8 *objdata = (uint8 *)malloc(2048); - readRoom(iRoom, roomdata, 4096); + readRoom(iRoom, roomdata); memcpy(&roomhdr, roomdata, sizeof(WTP_ROOM_HDR)); - readObj(iObj, objdata, 2048); + readObj(iObj, objdata); memcpy(&objhdr, objdata, sizeof(WTP_OBJ_HDR)); free(roomdata); @@ -922,7 +923,7 @@ void Winnie::gameLoop() { phase0: if (!game.nObjMiss && (room == IDI_WTP_ROOM_PICNIC)) room = IDI_WTP_ROOM_PARTY; - readRoom(room, roomdata, 4096); + readRoom(room, roomdata); memcpy(&hdr, roomdata, sizeof(WTP_ROOM_HDR)); drawRoomPic(); phase1: @@ -949,7 +950,7 @@ phase2: } } - delete [] roomdata; + free(roomdata); } void Winnie::drawPic(const char *szName) { @@ -970,7 +971,7 @@ void Winnie::drawPic(const char *szName) { _vm->_gfx->doUpdate(); _vm->_system->updateScreen(); // TODO: this should go in the game's main loop - delete [] buffer; + free(buffer); } void Winnie::drawObjPic(int iObj, int x0, int y0) { @@ -980,7 +981,7 @@ void Winnie::drawObjPic(int iObj, int x0, int y0) { if (!iObj) return; - int objSize = readObj(iObj, buffer, 2048); + uint32 objSize = readObj(iObj, buffer); memcpy(&objhdr, buffer, sizeof(WTP_OBJ_HDR)); _vm->_picture->setOffset(x0, y0); @@ -990,7 +991,7 @@ void Winnie::drawObjPic(int iObj, int x0, int y0) { _vm->_gfx->doUpdate(); _vm->_system->updateScreen(); - delete [] buffer; + free(buffer); } void Winnie::drawRoomPic() { @@ -1004,7 +1005,7 @@ void Winnie::drawRoomPic() { _vm->_system->updateScreen(); // TODO: this should go in the game's main loop // read room picture - readRoom(room, buffer, 4096); + readRoom(room, buffer); memcpy(&roomhdr, buffer, sizeof(WTP_ROOM_HDR)); // draw room picture @@ -1016,7 +1017,7 @@ void Winnie::drawRoomPic() { // draw object picture drawObjPic(iObj, IDI_WTP_PIC_X0 + roomhdr.objX, IDI_WTP_PIC_Y0 + roomhdr.objY); - delete [] buffer; + free(buffer); } void Winnie::clrMenuSel(int *iSel, int fCanSel[]) { @@ -1030,7 +1031,7 @@ void Winnie::printRoomStr(int iRoom, int iStr) { WTP_ROOM_HDR hdr; uint8 *buffer = (uint8 *)malloc(4096); - readRoom(iRoom, buffer, 4096); + readRoom(iRoom, buffer); memcpy(&hdr, buffer, sizeof(hdr)); _vm->printStrXOR((char *)(buffer + hdr.ofsStr[iStr - 1] - IDI_WTP_OFS_ROOM)); @@ -1054,14 +1055,14 @@ void Winnie::saveGame() { uint8 *buffer = (uint8 *)malloc(sizeof(WTP_SAVE_GAME)); memcpy(buffer, &game, sizeof(WTP_SAVE_GAME)); writeSaveGame(buffer); - delete [] buffer; + free(buffer); } void Winnie::loadGame() { uint8 *buffer = (uint8 *)malloc(sizeof(WTP_SAVE_GAME)); readSaveGame(buffer); memcpy(&game, buffer, sizeof(WTP_SAVE_GAME)); - delete [] buffer; + free(buffer); } void Winnie::readSaveGame(uint8 *buffer) { diff --git a/engines/agi/preagi_winnie.h b/engines/agi/preagi_winnie.h index 77d99611d7..94294d6fba 100644 --- a/engines/agi/preagi_winnie.h +++ b/engines/agi/preagi_winnie.h @@ -314,7 +314,7 @@ private: void intro(); void drawPic(const char*); void gameLoop(); - void readRoom(int, uint8*, int); + uint32 readRoom(int, uint8*); void drawRoomPic(); int parser(int, int, uint8*); int getObjInRoom(int); @@ -328,7 +328,7 @@ private: void printRoomStr(int, int); void inventory(); void printObjStr(int, int); - int readObj(int, uint8*, int); + uint32 readObj(int, uint8*); void takeObj(int); void dropObj(int); bool isRightObj(int, int, int*); |