~ubuntu-branches/debian/jessie/scummvm/jessie

« back to all changes in this revision

Viewing changes to engines/tucker/resource.cpp

  • Committer: Package Import Robot
  • Author(s): Moritz Muehlenhoff
  • Date: 2011-11-05 10:29:43 UTC
  • mto: This revision was merged to the branch mainline in revision 25.
  • Revision ID: package-import@ubuntu.com-20111105102943-zfm3dhlvy5b01u7v
Tags: upstream-1.4.0
ImportĀ upstreamĀ versionĀ 1.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * along with this program; if not, write to the Free Software
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
20
 *
21
 
 * $URL$
22
 
 * $Id$
23
 
 *
24
21
 */
25
22
 
26
23
#include "common/file.h"
163
160
};
164
161
 
165
162
uint8 *TuckerEngine::loadFile(const char *fname, uint8 *p) {
166
 
        char filename[80];
167
 
        strcpy(filename, fname);
 
163
        Common::String filename;
 
164
        filename = fname;
168
165
        if (_gameLang == Common::DE_DEU) {
169
 
                if (strcmp(filename, "bgtext.c") == 0) {
170
 
                        strcpy(filename, "bgtextgr.c");
171
 
                } else if (strcmp(filename, "charname.c") == 0) {
172
 
                        strcpy(filename, "charnmgr.c");
173
 
                } else if (strcmp(filename, "data5.c") == 0) {
174
 
                        strcpy(filename, "data5gr.c");
175
 
                } else if (strcmp(filename, "infobar.txt") == 0) {
176
 
                        strcpy(filename, "infobrgr.txt");
177
 
                } else if (strcmp(filename, "charsize.dta") == 0) {
178
 
                        strcpy(filename, "charszgr.dta");
179
 
                } else if (strncmp(filename, "objtxt", 6) == 0) {
180
 
                        const char num = filename[6];
181
 
                        snprintf(filename, sizeof(filename), "objtx%cgr.c", num);
182
 
                } else if (strncmp(filename, "pt", 2) == 0) {
183
 
                        const char num = filename[2];
184
 
                        snprintf(filename, sizeof(filename), "pt%ctxtgr.c", num);
 
166
                if (filename == "bgtext.c") {
 
167
                        filename = "bgtextgr.c";
 
168
                } else if (filename == "charname.c") {
 
169
                        filename = "charnmgr.c";
 
170
                } else if (filename == "data5.c") {
 
171
                        filename = "data5gr.c";
 
172
                } else if (filename == "infobar.txt") {
 
173
                        filename = "infobrgr.txt";
 
174
                } else if (filename == "charsize.dta") {
 
175
                        filename = "charszgr.dta";
 
176
                } else if (filename.hasPrefix("objtxt")) {
 
177
                        filename = Common::String::format("objtx%cgr.c", filename[6]);
 
178
                } else if (filename.hasPrefix("pt")) {
 
179
                        filename = Common::String::format("pt%ctxtgr.c", filename[2]);
185
180
                }
186
181
        }
187
182
        _fileLoadSize = 0;
188
183
        bool decode = false;
189
184
        if (_gameFlags & kGameFlagEncodedData) {
190
 
                char *ext = strrchr(filename, '.');
191
 
                if (ext && strcmp(ext + 1, "c") == 0) {
192
 
                        strcpy(ext + 1, "enc");
 
185
                if (filename.hasSuffix(".c")) {
 
186
                        filename.deleteLastChar();
 
187
                        filename += "enc";
193
188
                        decode = true;
194
189
                }
195
190
        }
196
191
        Common::File f;
197
192
        if (!f.open(filename)) {
198
 
                warning("Unable to open '%s'", filename);
 
193
                warning("Unable to open '%s'", filename.c_str());
199
194
                return 0;
200
195
        }
201
196
        const int sz = f.size();
392
387
        int spriteOffset = 0;
393
388
        for (int i = startOffset; i < endOffset; ++i) {
394
389
                if (framesCount[frame] == i) {
395
 
                        char filename[40];
 
390
                        Common::String filename;
396
391
                        switch (_flagsTable[137]) {
397
392
                        case 0:
398
393
                                if ((_gameFlags & kGameFlagDemo) != 0) {
399
 
                                        snprintf(filename, sizeof(filename), "budl00_%d.pcx", frame + 1);
 
394
                                        filename = Common::String::format("budl00_%d.pcx", frame + 1);
400
395
                                } else {
401
 
                                        snprintf(filename, sizeof(filename), "bud_%d.pcx", frame + 1);
 
396
                                        filename = Common::String::format("bud_%d.pcx", frame + 1);
402
397
                                }
403
398
                                break;
404
399
                        case 1:
405
 
                                snprintf(filename, sizeof(filename), "peg_%d.pcx", frame + 1);
 
400
                                filename = Common::String::format("peg_%d.pcx", frame + 1);
406
401
                                break;
407
402
                        default:
408
 
                                snprintf(filename, sizeof(filename), "mac_%d.pcx", frame + 1);
 
403
                                filename = Common::String::format("mac_%d.pcx", frame + 1);
409
404
                                break;
410
405
                        }
411
 
                        loadImage(filename, _loadTempBuf, 0);
 
406
                        loadImage(filename.c_str(), _loadTempBuf, 0);
412
407
                        ++frame;
413
408
                }
414
409
                int sz = Graphics::encodeRLE(_loadTempBuf + _spriteFramesTable[i].sourceOffset, _spritesGfxBuf + spriteOffset, _spriteFramesTable[i].xSize, _spriteFramesTable[i].ySize);
482
477
}
483
478
 
484
479
void TuckerEngine::loadLoc() {
485
 
        char filename[40];
 
480
        Common::String filename;
486
481
 
487
482
        int i = _locationWidthTable[_locationNum];
488
483
        _locationHeight = (_locationNum < 73) ? 140 : 200;
489
 
        snprintf(filename, sizeof(filename), (i == 1) ? "loc%02d.pcx" : "loc%02da.pcx", _locationNum);
490
 
        copyLocBitmap(filename, 0, false);
 
484
        filename = Common::String::format((i == 1) ? "loc%02d.pcx" : "loc%02da.pcx", _locationNum);
 
485
        copyLocBitmap(filename.c_str(), 0, false);
491
486
        Graphics::copyRect(_quadBackgroundGfxBuf, 320, _locationBackgroundGfxBuf, 640, 320, _locationHeight);
492
487
        if (_locationHeight == 200) {
493
488
                return;
494
489
        }
495
 
        snprintf(filename, sizeof(filename), (i != 2) ? "path%02d.pcx" : "path%02da.pcx", _locationNum);
496
 
        copyLocBitmap(filename, 0, true);
 
490
        filename = Common::String::format((i != 2) ? "path%02d.pcx" : "path%02da.pcx", _locationNum);
 
491
        copyLocBitmap(filename.c_str(), 0, true);
497
492
        if (i > 1) {
498
 
                snprintf(filename, sizeof(filename), "loc%02db.pcx", _locationNum);
499
 
                copyLocBitmap(filename, 320, false);
 
493
                filename = Common::String::format("loc%02db.pcx", _locationNum);
 
494
                copyLocBitmap(filename.c_str(), 320, false);
500
495
                Graphics::copyRect(_quadBackgroundGfxBuf + 44800, 320, _locationBackgroundGfxBuf + 320, 640, 320, _locationHeight);
501
496
                if (i == 2) {
502
 
                        snprintf(filename, sizeof(filename), "path%02db.pcx", _locationNum);
503
 
                        copyLocBitmap(filename, 320, true);
 
497
                        filename = Common::String::format("path%02db.pcx", _locationNum);
 
498
                        copyLocBitmap(filename.c_str(), 320, true);
504
499
                }
505
500
        }
506
501
        if (i > 2) {
507
 
                snprintf(filename, sizeof(filename), "loc%02dc.pcx", _locationNum);
508
 
                copyLocBitmap(filename, 0, false);
 
502
                filename = Common::String::format("loc%02dc.pcx", _locationNum);
 
503
                copyLocBitmap(filename.c_str(), 0, false);
509
504
                Graphics::copyRect(_quadBackgroundGfxBuf + 89600, 320, _locationBackgroundGfxBuf, 640, 320, 140);
510
505
        }
511
506
        if (_locationNum == 1) {
513
508
                loadImage("rochpath.pcx", _loadLocBufPtr, 0);
514
509
        }
515
510
        if (i > 3) {
516
 
                snprintf(filename, sizeof(filename), "loc%02dd.pcx", _locationNum);
517
 
                copyLocBitmap(filename, 0, false);
 
511
                filename = Common::String::format("loc%02dd.pcx", _locationNum);
 
512
                copyLocBitmap(filename.c_str(), 0, false);
518
513
                Graphics::copyRect(_quadBackgroundGfxBuf + 134400, 320, _locationBackgroundGfxBuf + 320, 640, 320, 140);
519
514
        }
520
515
        _fullRedraw = true;
543
538
        }
544
539
        _currentPartNum = _partNum;
545
540
 
546
 
        char filename[40];
547
 
        snprintf(filename, sizeof(filename), "objtxt%d.c", _partNum);
 
541
        Common::String filename;
 
542
        filename = Common::String::format("objtxt%d.c", _partNum);
548
543
        free(_objTxtBuf);
549
 
        _objTxtBuf = loadFile(filename, 0);
550
 
        snprintf(filename, sizeof(filename), "pt%dtext.c", _partNum);
 
544
        _objTxtBuf = loadFile(filename.c_str(), 0);
 
545
        filename = Common::String::format("pt%dtext.c", _partNum);
551
546
        free(_ptTextBuf);
552
 
        _ptTextBuf = loadFile(filename, 0);
 
547
        _ptTextBuf = loadFile(filename.c_str(), 0);
553
548
        _characterSpeechDataPtr = _ptTextBuf;
554
549
        loadData();
555
550
        loadPanObj();
587
582
        _dataCount = maxCount;
588
583
        int offset = 0;
589
584
        for (int i = 0; i < count; ++i) {
590
 
                char filename[40];
591
 
                snprintf(filename, sizeof(filename), "scrobj%d%d.pcx", _partNum, i);
592
 
                loadImage(filename, _loadTempBuf, 0);
 
585
                Common::String filename = Common::String::format("scrobj%d%d.pcx", _partNum, i);
 
586
                loadImage(filename.c_str(), _loadTempBuf, 0);
593
587
                offset = loadDataHelper(offset, i);
594
588
        }
595
589
}
606
600
}
607
601
 
608
602
void TuckerEngine::loadPanObj() {
609
 
        char filename[40];
610
 
        snprintf(filename, sizeof(filename), "panobjs%d.pcx", _partNum);
611
 
        loadImage(filename, _loadTempBuf, 0);
 
603
        Common::String filename = Common::String::format("panobjs%d.pcx", _partNum);
 
604
        loadImage(filename.c_str(), _loadTempBuf, 0);
612
605
        int offset = 0;
613
606
        for (int y = 0; y < 5; ++y) {
614
607
                for (int x = 0; x < 10; ++x) {
815
808
        unloadSprA02_01();
816
809
        const int count = _sprA02LookupTable[_locationNum];
817
810
        for (int i = 1; i < count + 1; ++i) {
818
 
                char filename[40];
819
 
                snprintf(filename, sizeof(filename), "sprites/a%02d_%02d.spr", _locationNum, i);
820
 
                _sprA02Table[i] = loadFile(filename, 0);
 
811
                Common::String filename = Common::String::format("sprites/a%02d_%02d.spr", _locationNum, i);
 
812
                _sprA02Table[i] = loadFile(filename.c_str(), 0);
821
813
        }
822
814
        _sprA02Table[0] = _sprA02Table[1];
823
815
}
834
826
        unloadSprC02_01();
835
827
        const int count = _sprC02LookupTable[_locationNum];
836
828
        for (int i = 1; i < count + 1; ++i) {
837
 
                char filename[40];
838
 
                snprintf(filename, sizeof(filename), "sprites/c%02d_%02d.spr", _locationNum, i);
839
 
                _sprC02Table[i] = loadFile(filename, 0);
 
829
                Common::String filename = Common::String::format("sprites/c%02d_%02d.spr", _locationNum, i);
 
830
                _sprC02Table[i] = loadFile(filename.c_str(), 0);
840
831
        }
841
832
        _sprC02Table[0] = _sprC02Table[1];
842
833
        _spritesCount = _sprC02LookupTable2[_locationNum];
945
936
                default:
946
937
                        return;
947
938
                }
948
 
                char fileName[64];
949
 
                snprintf(fileName, sizeof(fileName), fmt, num);
 
939
                Common::String fileName = Common::String::format(fmt, num);
950
940
                Common::File *f = new Common::File;
951
941
                if (f->open(fileName)) {
952
942
                        stream = Audio::makeWAVStream(f, DisposeAfterUse::YES);