Level editor and resource loader fixups and refactors

This commit is contained in:
elasota
2020-01-23 01:19:12 -05:00
parent 27a1f89c15
commit 5a3cedaa95
43 changed files with 310 additions and 367 deletions

View File

@@ -15,6 +15,7 @@
#include "HostMutex.h"
#include "HostSystemServices.h"
#include "MemoryManager.h"
#include "ResourceManager.h"
#define kBaseBufferMusicID 2000
@@ -212,7 +213,7 @@ PLError_t LoadMusicSounds (void)
for (i = 0; i < kMaxMusic; i++)
{
theSound = ParseAndConvertSound(GetResource('snd ', i + kBaseBufferMusicID));
theSound = ParseAndConvertSound(PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('snd ', i + kBaseBufferMusicID));
if (theSound == nil)
return PLErrors::kOutOfMemory;
@@ -364,24 +365,18 @@ void KillMusic (void)
long MusicBytesNeeded (void)
{
Handle theSound;
long totalBytes;
size_t totalBytes;
short i;
totalBytes = 0L;
SetResLoad(false);
for (i = 0; i < kMaxMusic; i++)
{
theSound = GetResource('snd ', i + kBaseBufferMusicID);
if (theSound == nil)
{
SetResLoad(true);
size_t resSize = 0;
if (!PortabilityLayer::ResourceManager::GetInstance()->GetAppResourceArchive()->GetResourceSize('snd ', i + kBaseBufferMusicID, resSize))
return -1;
}
totalBytes += GetMaxResourceSize(theSound);
// ReleaseResource(theSound);
totalBytes += static_cast<long>(resSize);
}
SetResLoad(true);
return totalBytes;
}