| 5502 | } |
| 5503 | |
| 5504 | void physfsReloadSprites(bool reloadAll) //TODO: NX PORT: Any changes needed here? |
| 5505 | { |
| 5506 | if ( !PHYSFS_getRealDir("images/sprites.txt") ) |
| 5507 | { |
| 5508 | printlog("error: could not find file: %s", "images/sprites.txt"); |
| 5509 | return; |
| 5510 | } |
| 5511 | std::string spritesDirectory = PHYSFS_getRealDir("images/sprites.txt"); |
| 5512 | spritesDirectory.append(PHYSFS_getDirSeparator()).append("images/sprites.txt"); |
| 5513 | printlog("[PhysFS]: Loading sprites from directory %s...\n", spritesDirectory.c_str()); |
| 5514 | File* fp = openDataFile(spritesDirectory.c_str(), "rb"); |
| 5515 | char name[PATH_MAX]; |
| 5516 | |
| 5517 | /*int numsprites = 0; |
| 5518 | for ( numsprites = 0; !fp->eof(); numsprites++ ) |
| 5519 | { |
| 5520 | while ( fp->getc() != '\n' ) if ( fp->eof() ) |
| 5521 | { |
| 5522 | break; |
| 5523 | } |
| 5524 | }*/ |
| 5525 | |
| 5526 | for ( int c = 0; !fp->eof(); ++c ) |
| 5527 | { |
| 5528 | fp->gets2(name, PATH_MAX); |
| 5529 | if ( PHYSFS_getRealDir(name) != nullptr ) |
| 5530 | { |
| 5531 | std::string spritesRealDir = PHYSFS_getRealDir(name); |
| 5532 | if ( reloadAll || spritesRealDir.compare("./") != 0 ) |
| 5533 | { |
| 5534 | std::string spriteFile = spritesRealDir; |
| 5535 | spriteFile.append(PHYSFS_getDirSeparator()).append(name); |
| 5536 | if ( sprites[c] ) |
| 5537 | { |
| 5538 | SDL_FreeSurface(sprites[c]); |
| 5539 | } |
| 5540 | char fullname[PATH_MAX]; |
| 5541 | strncpy(fullname, spriteFile.c_str(), PATH_MAX - 1); |
| 5542 | sprites[c] = loadImage(fullname); |
| 5543 | if ( nullptr != sprites[c] ) |
| 5544 | { |
| 5545 | //Whee |
| 5546 | } |
| 5547 | else |
| 5548 | { |
| 5549 | printlog("warning: failed to load '%s' listed at line %d in %s\n", name, c + 1, spritesDirectory.c_str()); |
| 5550 | if ( 0 == c ) |
| 5551 | { |
| 5552 | printlog("sprite 0 cannot be NULL!\n"); |
| 5553 | FileIO::close(fp); |
| 5554 | return; |
| 5555 | } |
| 5556 | } |
| 5557 | } |
| 5558 | } |
| 5559 | if (Mods::isLoading) { |
| 5560 | doLoadingScreen(); |
| 5561 | } |
no test coverage detected