aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorMatthew Hoops2007-09-19 22:29:14 +0000
committerMatthew Hoops2007-09-19 22:29:14 +0000
commitf5511b3102ec57385d74aee99311a642ae621fc8 (patch)
tree6748df2b6f78e6e2176ba158943f650411c4c1df /engines/agi
parentfb97e09e9390352fc7f9b36cdf0256f73258a0cf (diff)
downloadscummvm-rg350-f5511b3102ec57385d74aee99311a642ae621fc8.tar.gz
scummvm-rg350-f5511b3102ec57385d74aee99311a642ae621fc8.tar.bz2
scummvm-rg350-f5511b3102ec57385d74aee99311a642ae621fc8.zip
some cleanup using malloc and with readObj
svn-id: r28975
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/preagi_winnie.cpp29
-rw-r--r--engines/agi/preagi_winnie.h2
2 files changed, 16 insertions, 15 deletions
diff --git a/engines/agi/preagi_winnie.cpp b/engines/agi/preagi_winnie.cpp
index 85d1983e9e..49e62d79f5 100644
--- a/engines/agi/preagi_winnie.cpp
+++ b/engines/agi/preagi_winnie.cpp
@@ -69,16 +69,17 @@ void Winnie::readRoom(int iRoom, uint8 *buffer, int buflen) {
file.close();
}
-void Winnie::readObj(int iObj, uint8 *buffer, int buflen) {
+int Winnie::readObj(int iObj, uint8 *buffer, int buflen) {
char szFile[256] = {0};
sprintf(szFile, IDS_WTP_PATH_OBJ, iObj);
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;
}
void Winnie::randomize() {
@@ -413,16 +414,16 @@ void Winnie::printObjStr(int iObj, int iStr) {
bool Winnie::isRightObj(int iRoom, int iObj, int *iCode) {
WTP_ROOM_HDR roomhdr;
WTP_OBJ_HDR objhdr;
- uint8 *roomdata = new uint8[4096];
- uint8 *objdata = new uint8[2048];
+ uint8 *roomdata = (uint8 *)malloc(4096);
+ uint8 *objdata = (uint8 *)malloc(2048);
readRoom(iRoom, roomdata, 4096);
memcpy(&roomhdr, roomdata, sizeof(WTP_ROOM_HDR));
readObj(iObj, objdata, 2048);
memcpy(&objhdr, objdata, sizeof(WTP_OBJ_HDR));
- delete [] roomdata;
- delete [] objdata;
+ free(roomdata);
+ free(objdata);
*iCode = objhdr.objId;
@@ -915,7 +916,7 @@ void Winnie::getMenuSel(char *szMenu, int *iSel, int fCanSel[]) {
void Winnie::gameLoop() {
WTP_ROOM_HDR hdr;
- uint8 *roomdata = new uint8[4096];
+ uint8 *roomdata = (uint8 *)malloc(4096);
int iBlock;
phase0:
@@ -953,7 +954,7 @@ phase2:
void Winnie::drawPic(const char *szName) {
char szFile[256] = {0};
- uint8 *buffer = new uint8[4096];
+ uint8 *buffer = (uint8 *)malloc(4096);
// construct filename
sprintf(szFile, IDS_WTP_PATH, szName);
@@ -974,16 +975,16 @@ void Winnie::drawPic(const char *szName) {
void Winnie::drawObjPic(int iObj, int x0, int y0) {
WTP_OBJ_HDR objhdr;
- uint8 *buffer = new uint8[2048];
+ uint8 *buffer = (uint8 *)malloc(2048);
if (!iObj)
return;
- readObj(iObj, buffer, 2048);
+ int objSize = readObj(iObj, buffer, 2048);
memcpy(&objhdr, buffer, sizeof(WTP_OBJ_HDR));
_vm->_picture->setOffset(x0, y0);
- _vm->_picture->decodePicture(buffer + objhdr.ofsPic - IDI_WTP_OFS_OBJ, 4096, 0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
+ _vm->_picture->decodePicture(buffer + objhdr.ofsPic - IDI_WTP_OFS_OBJ, objSize, 0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
_vm->_picture->setOffset(0, 0);
_vm->_picture->showPic(10, 0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
_vm->_gfx->doUpdate();
@@ -994,7 +995,7 @@ void Winnie::drawObjPic(int iObj, int x0, int y0) {
void Winnie::drawRoomPic() {
WTP_ROOM_HDR roomhdr;
- uint8 *buffer = new uint8[4096];
+ uint8 *buffer = (uint8 *)malloc(4096);
int iObj = getObjInRoom(room);
// clear gfx screen
@@ -1050,14 +1051,14 @@ void Winnie::gameOver() {
}
void Winnie::saveGame() {
- uint8 *buffer = new uint8[sizeof(WTP_SAVE_GAME)];
+ uint8 *buffer = (uint8 *)malloc(sizeof(WTP_SAVE_GAME));
memcpy(buffer, &game, sizeof(WTP_SAVE_GAME));
writeSaveGame(buffer);
delete [] buffer;
}
void Winnie::loadGame() {
- uint8 *buffer = new uint8[sizeof(WTP_SAVE_GAME)];
+ uint8 *buffer = (uint8 *)malloc(sizeof(WTP_SAVE_GAME));
readSaveGame(buffer);
memcpy(&game, buffer, sizeof(WTP_SAVE_GAME));
delete [] buffer;
diff --git a/engines/agi/preagi_winnie.h b/engines/agi/preagi_winnie.h
index 625795d7e1..77d99611d7 100644
--- a/engines/agi/preagi_winnie.h
+++ b/engines/agi/preagi_winnie.h
@@ -328,7 +328,7 @@ private:
void printRoomStr(int, int);
void inventory();
void printObjStr(int, int);
- void readObj(int, uint8*, int);
+ int readObj(int, uint8*, int);
void takeObj(int);
void dropObj(int);
bool isRightObj(int, int, int*);