mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 11:19:10 +00:00
Convert plClientResMgr to plString
DIE std::string DIE!!!
This commit is contained in:
@ -41,6 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
*==LICENSE==*/
|
*==LICENSE==*/
|
||||||
|
|
||||||
#include "HeadSpin.h"
|
#include "HeadSpin.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "hsStream.h"
|
#include "hsStream.h"
|
||||||
#include "hsResMgr.h"
|
#include "hsResMgr.h"
|
||||||
@ -61,9 +62,7 @@ plClientResMgr& plClientResMgr::Instance(void)
|
|||||||
|
|
||||||
plClientResMgr::~plClientResMgr()
|
plClientResMgr::~plClientResMgr()
|
||||||
{
|
{
|
||||||
std::map<plString, plMipmap*>::iterator it;
|
for (auto it = ClientResources.begin(); it != ClientResources.end(); ++it) {
|
||||||
|
|
||||||
for (it = ClientResources.begin(); it != ClientResources.end(); ++it) {
|
|
||||||
if (it->second)
|
if (it->second)
|
||||||
it->second->UnRef();
|
it->second->UnRef();
|
||||||
}
|
}
|
||||||
@ -71,9 +70,8 @@ plClientResMgr::~plClientResMgr()
|
|||||||
|
|
||||||
void plClientResMgr::ILoadResources(const plFileName& resfile)
|
void plClientResMgr::ILoadResources(const plFileName& resfile)
|
||||||
{
|
{
|
||||||
if (!resfile.IsValid()) {
|
if (!resfile.IsValid())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
hsUNIXStream in;
|
hsUNIXStream in;
|
||||||
|
|
||||||
@ -87,19 +85,19 @@ void plClientResMgr::ILoadResources(const plFileName& resfile)
|
|||||||
num_resources = in.ReadLE32();
|
num_resources = in.ReadLE32();
|
||||||
|
|
||||||
for (int i = 0; i < num_resources; i++) {
|
for (int i = 0; i < num_resources; i++) {
|
||||||
plMipmap* res_data = NULL;
|
plMipmap* res_data = nullptr;
|
||||||
uint32_t res_size = 0;
|
uint32_t res_size = 0;
|
||||||
plString res_name = in.ReadSafeStringLong();
|
plString res_name = in.ReadSafeStringLong();
|
||||||
plString res_type = res_name.Substr(res_name.GetSize() - 4, 4);
|
plString extension = plFileName(res_name).GetFileExt();
|
||||||
|
|
||||||
// Version 1 doesn't encode format, so we'll try some simple
|
// Version 1 doesn't encode format, so we'll try some simple
|
||||||
// extension sniffing
|
// extension sniffing
|
||||||
if (res_type == ".png") {
|
if (extension == "png") {
|
||||||
// Read resource stream size, but the PNG has that info in the header
|
// Read resource stream size, but the PNG has that info in the header
|
||||||
// so it's not needed
|
// so it's not needed
|
||||||
res_size = in.ReadLE32();
|
res_size = in.ReadLE32();
|
||||||
res_data = plPNG::Instance().ReadFromStream(&in);
|
res_data = plPNG::Instance().ReadFromStream(&in);
|
||||||
} else if (res_type == ".jpg") {
|
} else if (extension == "jpg") {
|
||||||
// Don't read resource stream size, as plJPEG's reader will need it
|
// Don't read resource stream size, as plJPEG's reader will need it
|
||||||
res_data = plJPEG::Instance().ReadFromStream(&in);
|
res_data = plJPEG::Instance().ReadFromStream(&in);
|
||||||
} else {
|
} else {
|
||||||
@ -126,7 +124,7 @@ void plClientResMgr::ILoadResources(const plFileName& resfile)
|
|||||||
plMipmap* plClientResMgr::getResource(const plString& resname)
|
plMipmap* plClientResMgr::getResource(const plString& resname)
|
||||||
{
|
{
|
||||||
plMipmap* resmipmap = nullptr;
|
plMipmap* resmipmap = nullptr;
|
||||||
std::map<plString, plMipmap*>::iterator it = ClientResources.find(resname);
|
auto it = ClientResources.find(resname);
|
||||||
|
|
||||||
if (it != ClientResources.end()) {
|
if (it != ClientResources.end()) {
|
||||||
resmipmap = it->second;
|
resmipmap = it->second;
|
||||||
|
@ -43,7 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
#ifndef _plClientResMgr_h
|
#ifndef _plClientResMgr_h
|
||||||
#define _plClientResMgr_h
|
#define _plClientResMgr_h
|
||||||
|
|
||||||
#include <map>
|
#include <unordered_map>
|
||||||
|
|
||||||
class plMipmap;
|
class plMipmap;
|
||||||
class plString;
|
class plString;
|
||||||
@ -51,7 +51,7 @@ class plFileName;
|
|||||||
|
|
||||||
class plClientResMgr {
|
class plClientResMgr {
|
||||||
protected:
|
protected:
|
||||||
std::map<plString, plMipmap*> ClientResources;
|
std::unordered_map<plString, plMipmap*, plString::hash> ClientResources;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
plClientResMgr() { }
|
plClientResMgr() { }
|
||||||
|
Reference in New Issue
Block a user