mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-04-26 22:33:27 -04:00
Implement TextureData::Create (#586)
* Implement TextureData::Create * Fix names * Rename * Fix name * Fix annotation * Add missing annotation * Fix annotation * More annotation fixes * Compat template type ambiguity * Fix
This commit is contained in:
parent
688dc0b6ee
commit
9d8820ee06
13 changed files with 422 additions and 259 deletions
|
@ -291,9 +291,9 @@ add_library(lego1 SHARED
|
|||
LEGO1/lego/legoomni/src/build/legovehiclebuildstate.cpp
|
||||
LEGO1/lego/legoomni/src/build/racecar.cpp
|
||||
LEGO1/lego/legoomni/src/common/animstate.cpp
|
||||
LEGO1/lego/legoomni/src/common/gifmanager.cpp
|
||||
LEGO1/lego/legoomni/src/common/legoactioncontrolpresenter.cpp
|
||||
LEGO1/lego/legoomni/src/common/legobackgroundcolor.cpp
|
||||
LEGO1/lego/legoomni/src/common/legocontainer.cpp
|
||||
LEGO1/lego/legoomni/src/common/legofullscreenmovie.cpp
|
||||
LEGO1/lego/legoomni/src/common/legogamestate.cpp
|
||||
LEGO1/lego/legoomni/src/common/legoobjectfactory.cpp
|
||||
|
|
|
@ -1,143 +0,0 @@
|
|||
#ifndef GIFMANAGER_H
|
||||
#define GIFMANAGER_H
|
||||
|
||||
#include "compat.h"
|
||||
#include "decomp.h"
|
||||
#include "mxstl/stlcompat.h"
|
||||
#include "mxtypes.h"
|
||||
|
||||
#include <d3drmobj.h>
|
||||
#include <ddraw.h>
|
||||
|
||||
#pragma warning(disable : 4237)
|
||||
|
||||
// SIZE 0x14
|
||||
struct GifData {
|
||||
public:
|
||||
char* m_name; // 0x00
|
||||
LPDIRECTDRAWSURFACE m_surface; // 0x04
|
||||
LPDIRECTDRAWPALETTE m_palette; // 0x08
|
||||
LPDIRECT3DRMTEXTURE2 m_texture; // 0x0c
|
||||
MxU8* m_data; // 0x10
|
||||
|
||||
~GifData();
|
||||
};
|
||||
|
||||
struct GifMapComparator {
|
||||
bool operator()(const char* const& p_key0, const char* const& p_key1) const { return strcmp(p_key0, p_key1) > 0; }
|
||||
};
|
||||
|
||||
// SIZE 0x10
|
||||
class GifMap : public map<const char*, GifData*, GifMapComparator> {
|
||||
// SYNTHETIC: LEGO1 0x1005a400
|
||||
// GifMap::~GifMap
|
||||
};
|
||||
|
||||
typedef list<GifData*> GifList;
|
||||
|
||||
// VTABLE: LEGO1 0x100d86d4
|
||||
// SIZE 0x18
|
||||
class GifManagerBase {
|
||||
public:
|
||||
// FUNCTION: LEGO1 0x1005b660
|
||||
virtual ~GifManagerBase()
|
||||
{
|
||||
GifMap::iterator it;
|
||||
for (it = m_map.begin(); it != m_map.end(); it++) {
|
||||
// DECOMP: Use of const_cast here matches ~ViewLODListManager from 96 source.
|
||||
const char* const& key = (*it).first;
|
||||
delete[] const_cast<char*>(key);
|
||||
|
||||
if (m_ownership) {
|
||||
delete (*it).second; // GifData*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline GifData* Get(const char* p_name)
|
||||
{
|
||||
GifMap::iterator it = m_map.find(p_name);
|
||||
if (it != m_map.end()) {
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline void SetOwnership(MxBool p_ownership) { m_ownership = p_ownership; }
|
||||
|
||||
// SYNTHETIC: LEGO1 0x1005a310
|
||||
// GifManagerBase::`scalar deleting destructor'
|
||||
|
||||
protected:
|
||||
MxBool m_ownership; // 0x04
|
||||
GifMap m_map; // 0x08
|
||||
};
|
||||
|
||||
// VTABLE: LEGO1 0x100d86fc
|
||||
// SIZE 0x24
|
||||
class GifManager : public GifManagerBase {
|
||||
public:
|
||||
GifManager() { m_ownership = TRUE; }
|
||||
~GifManager() override;
|
||||
|
||||
// SYNTHETIC: LEGO1 0x1005a580
|
||||
// GifManager::`scalar deleting destructor'
|
||||
|
||||
void FUN_10099cc0(GifData* p_data);
|
||||
|
||||
protected:
|
||||
GifList m_list; // 0x18
|
||||
};
|
||||
|
||||
// TEMPLATE: LEGO1 0x10059c50
|
||||
// allocator<GifData *>::_Charalloc
|
||||
|
||||
// clang-format off
|
||||
// TEMPLATE: LEGO1 0x10001cc0
|
||||
// _Tree<char const *,pair<char const * const,GifData *>,map<char const *,GifData *,GifMapComparator,allocator<GifData *> >::_Kfn,GifMapComparator,allocator<GifData *> >::_Lbound
|
||||
|
||||
// TEMPLATE: LEGO1 0x1004f9b0
|
||||
// _Tree<char const *,pair<char const * const,GifData *>,map<char const *,GifData *,GifMapComparator,allocator<GifData *> >::_Kfn,GifMapComparator,allocator<GifData *> >::_Insert
|
||||
|
||||
// TEMPLATE: LEGO1 0x10059c70
|
||||
// _Tree<char const *,pair<char const * const,GifData *>,map<char const *,GifData *,GifMapComparator,allocator<GifData *> >::_Kfn,GifMapComparator,allocator<GifData *> >::_Color
|
||||
|
||||
// TEMPLATE: LEGO1 0x10059c80
|
||||
// _Tree<char const *,pair<char const * const,GifData *>,map<char const *,GifData *,GifMapComparator,allocator<GifData *> >::_Kfn,GifMapComparator,allocator<GifData *> >::_Left
|
||||
|
||||
// TEMPLATE: LEGO1 0x10059c90
|
||||
// _Tree<char const *,pair<char const * const,GifData *>,map<char const *,GifData *,GifMapComparator,allocator<GifData *> >::_Kfn,GifMapComparator,allocator<GifData *> >::_Parent
|
||||
|
||||
// TEMPLATE: LEGO1 0x10059ca0
|
||||
// _Tree<char const *,pair<char const * const,GifData *>,map<char const *,GifData *,GifMapComparator,allocator<GifData *> >::_Kfn,GifMapComparator,allocator<GifData *> >::_Right
|
||||
|
||||
// TEMPLATE: LEGO1 0x10059cb0
|
||||
// _Tree<char const *,pair<char const * const,GifData *>,map<char const *,GifData *,GifMapComparator,allocator<GifData *> >::_Kfn,GifMapComparator,allocator<GifData *> >::~_Tree<char const *,pair<char const * const,GifData *>,map<char const *,GifData *,GifMapComparator,allocator<GifData *> >::_Kfn,GifMapComparator,allocator<GifData *> >
|
||||
|
||||
// TEMPLATE: LEGO1 0x10059d80
|
||||
// _Tree<char const *,pair<char const * const,GifData *>,map<char const *,GifData *,GifMapComparator,allocator<GifData *> >::_Kfn,GifMapComparator,allocator<GifData *> >::iterator::_Inc
|
||||
|
||||
// TEMPLATE: LEGO1 0x10059dc0
|
||||
// _Tree<char const *,pair<char const * const,GifData *>,map<char const *,GifData *,GifMapComparator,allocator<GifData *> >::_Kfn,GifMapComparator,allocator<GifData *> >::erase
|
||||
|
||||
// TEMPLATE: LEGO1 0x1005a210
|
||||
// _Tree<char const *,pair<char const * const,GifData *>,map<char const *,GifData *,GifMapComparator,allocator<GifData *> >::_Kfn,GifMapComparator,allocator<GifData *> >::_Erase
|
||||
|
||||
// TEMPLATE: LEGO1 0x1005a250
|
||||
// list<GifData *,allocator<GifData *> >::~list<GifData *,allocator<GifData *> >
|
||||
|
||||
// TEMPLATE: LEGO1 0x1005a2c0
|
||||
// map<char const *,GifData *,GifMapComparator,allocator<GifData *> >::~map<char const *,GifData *,GifMapComparator,allocator<GifData *> >
|
||||
|
||||
// TEMPLATE: LEGO1 0x1005a450
|
||||
// Map<char const *,GifData *,GifMapComparator>::~Map<char const *,GifData *,GifMapComparator>
|
||||
|
||||
// TEMPLATE: LEGO1 0x1005a5a0
|
||||
// List<GifData *>::~List<GifData *>
|
||||
|
||||
// GLOBAL: LEGO1 0x100f0100
|
||||
// _Tree<char const *,pair<char const * const,GifData *>,map<char const *,GifData *,GifMapComparator,allocator<GifData *> >::_Kfn,GifMapComparator,allocator<GifData *> >::_Nil
|
||||
// clang-format on
|
||||
|
||||
#endif // GIFMANAGER_H
|
161
LEGO1/lego/legoomni/include/legocontainer.h
Normal file
161
LEGO1/lego/legoomni/include/legocontainer.h
Normal file
|
@ -0,0 +1,161 @@
|
|||
#ifndef LEGOTEXTURECONTAINER_H
|
||||
#define LEGOTEXTURECONTAINER_H
|
||||
|
||||
#include "compat.h"
|
||||
#include "decomp.h"
|
||||
#include "mxstl/stlcompat.h"
|
||||
#include "mxtypes.h"
|
||||
|
||||
#include <d3drmobj.h>
|
||||
#include <ddraw.h>
|
||||
|
||||
#pragma warning(disable : 4237)
|
||||
|
||||
class LegoTexture;
|
||||
|
||||
// SIZE 0x10
|
||||
struct TextureData {
|
||||
public:
|
||||
TextureData();
|
||||
~TextureData();
|
||||
|
||||
static TextureData* Create(const char* p_name, LegoTexture* p_texture);
|
||||
|
||||
char* m_name; // 0x00
|
||||
LPDIRECTDRAWSURFACE m_surface; // 0x04
|
||||
LPDIRECTDRAWPALETTE m_palette; // 0x08
|
||||
LPDIRECT3DRMTEXTURE2 m_texture; // 0x0c
|
||||
};
|
||||
|
||||
struct LegoContainerInfoComparator {
|
||||
bool operator()(const char* const& p_key0, const char* const& p_key1) const { return strcmp(p_key0, p_key1) > 0; }
|
||||
};
|
||||
|
||||
// SIZE 0x10
|
||||
template <class T>
|
||||
class LegoContainerInfo : public map<const char*, T*, LegoContainerInfoComparator> {};
|
||||
|
||||
// SIZE 0x18
|
||||
template <class T>
|
||||
class LegoContainer {
|
||||
public:
|
||||
virtual ~LegoContainer()
|
||||
{
|
||||
#ifdef COMPAT_MODE
|
||||
typename LegoContainerInfo<T>::iterator it;
|
||||
#else
|
||||
LegoContainerInfo<T>::iterator it;
|
||||
#endif
|
||||
for (it = m_map.begin(); it != m_map.end(); it++) {
|
||||
// DECOMP: Use of const_cast here matches ~ViewLODListManager from 96 source.
|
||||
const char* const& key = (*it).first;
|
||||
delete[] const_cast<char*>(key);
|
||||
|
||||
if (m_ownership) {
|
||||
delete (*it).second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline T* Get(const char* p_name)
|
||||
{
|
||||
#ifdef COMPAT_MODE
|
||||
typename LegoContainerInfo<T>::iterator it = m_map.find(p_name);
|
||||
#else
|
||||
LegoContainerInfo<T>::iterator it = m_map.find(p_name);
|
||||
#endif
|
||||
if (it != m_map.end()) {
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline void SetOwnership(MxBool p_ownership) { m_ownership = p_ownership; }
|
||||
|
||||
protected:
|
||||
MxBool m_ownership; // 0x04
|
||||
LegoContainerInfo<T> m_map; // 0x08
|
||||
};
|
||||
|
||||
// VTABLE: LEGO1 0x100d86d4
|
||||
// class LegoContainer<TextureData>
|
||||
|
||||
typedef list<TextureData*> TextureList;
|
||||
|
||||
// VTABLE: LEGO1 0x100d86fc
|
||||
// SIZE 0x24
|
||||
class LegoTextureContainer : public LegoContainer<TextureData> {
|
||||
public:
|
||||
LegoTextureContainer() { m_ownership = TRUE; }
|
||||
~LegoTextureContainer() override;
|
||||
|
||||
void FUN_10099cc0(TextureData* p_data);
|
||||
|
||||
protected:
|
||||
TextureList m_list; // 0x18
|
||||
};
|
||||
|
||||
// TEMPLATE: LEGO1 0x10059c50
|
||||
// allocator<TextureData *>::_Charalloc
|
||||
|
||||
// clang-format off
|
||||
// TEMPLATE: LEGO1 0x10001cc0
|
||||
// _Tree<char const *,pair<char const * const,TextureData *>,map<char const *,TextureData *,LegoContainerInfoComparator,allocator<TextureData *> >::_Kfn,LegoContainerInfoComparator,allocator<TextureData *> >::_Lbound
|
||||
|
||||
// TEMPLATE: LEGO1 0x1004f9b0
|
||||
// _Tree<char const *,pair<char const * const,TextureData *>,map<char const *,TextureData *,LegoContainerInfoComparator,allocator<TextureData *> >::_Kfn,LegoContainerInfoComparator,allocator<TextureData *> >::_Insert
|
||||
|
||||
// TEMPLATE: LEGO1 0x10059c70
|
||||
// _Tree<char const *,pair<char const * const,TextureData *>,map<char const *,TextureData *,LegoContainerInfoComparator,allocator<TextureData *> >::_Kfn,LegoContainerInfoComparator,allocator<TextureData *> >::_Color
|
||||
|
||||
// TEMPLATE: LEGO1 0x10059c80
|
||||
// _Tree<char const *,pair<char const * const,TextureData *>,map<char const *,TextureData *,LegoContainerInfoComparator,allocator<TextureData *> >::_Kfn,LegoContainerInfoComparator,allocator<TextureData *> >::_Left
|
||||
|
||||
// TEMPLATE: LEGO1 0x10059c90
|
||||
// _Tree<char const *,pair<char const * const,TextureData *>,map<char const *,TextureData *,LegoContainerInfoComparator,allocator<TextureData *> >::_Kfn,LegoContainerInfoComparator,allocator<TextureData *> >::_Parent
|
||||
|
||||
// TEMPLATE: LEGO1 0x10059ca0
|
||||
// _Tree<char const *,pair<char const * const,TextureData *>,map<char const *,TextureData *,LegoContainerInfoComparator,allocator<TextureData *> >::_Kfn,LegoContainerInfoComparator,allocator<TextureData *> >::_Right
|
||||
|
||||
// TEMPLATE: LEGO1 0x10059cb0
|
||||
// _Tree<char const *,pair<char const * const,TextureData *>,map<char const *,TextureData *,LegoContainerInfoComparator,allocator<TextureData *> >::_Kfn,LegoContainerInfoComparator,allocator<TextureData *> >::~_Tree<char const *,pair<char const * const,TextureData *>,map<char const *,TextureData *,LegoContainerInfoComparator,allocator<TextureData *> >::_Kfn,LegoContainerInfoComparator,allocator<TextureData *> >
|
||||
|
||||
// TEMPLATE: LEGO1 0x10059d80
|
||||
// _Tree<char const *,pair<char const * const,TextureData *>,map<char const *,TextureData *,LegoContainerInfoComparator,allocator<TextureData *> >::_Kfn,LegoContainerInfoComparator,allocator<TextureData *> >::iterator::_Inc
|
||||
|
||||
// TEMPLATE: LEGO1 0x10059dc0
|
||||
// _Tree<char const *,pair<char const * const,TextureData *>,map<char const *,TextureData *,LegoContainerInfoComparator,allocator<TextureData *> >::_Kfn,LegoContainerInfoComparator,allocator<TextureData *> >::erase
|
||||
|
||||
// TEMPLATE: LEGO1 0x1005a210
|
||||
// _Tree<char const *,pair<char const * const,TextureData *>,map<char const *,TextureData *,LegoContainerInfoComparator,allocator<TextureData *> >::_Kfn,LegoContainerInfoComparator,allocator<TextureData *> >::_Erase
|
||||
|
||||
// TEMPLATE: LEGO1 0x1005a250
|
||||
// list<TextureData *,allocator<TextureData *> >::~list<TextureData *,allocator<TextureData *> >
|
||||
|
||||
// TEMPLATE: LEGO1 0x1005a2c0
|
||||
// map<char const *,TextureData *,LegoContainerInfoComparator,allocator<TextureData *> >::~map<char const *,TextureData *,LegoContainerInfoComparator,allocator<TextureData *> >
|
||||
|
||||
// TEMPLATE: LEGO1 0x1005a310
|
||||
// LegoContainer<TextureData>::`scalar deleting destructor'
|
||||
|
||||
// TEMPLATE: LEGO1 0x1005a400
|
||||
// LegoContainerInfo<TextureData>::~LegoContainerInfo<TextureData>
|
||||
|
||||
// TEMPLATE: LEGO1 0x1005a450
|
||||
// Map<char const *,TextureData *,LegoContainerInfoComparator>::~Map<char const *,TextureData *,LegoContainerInfoComparator>
|
||||
|
||||
// SYNTHETIC: LEGO1 0x1005a580
|
||||
// LegoTextureContainer::`scalar deleting destructor'
|
||||
|
||||
// TEMPLATE: LEGO1 0x1005a5a0
|
||||
// List<TextureData *>::~List<TextureData *>
|
||||
|
||||
// TEMPLATE: LEGO1 0x1005b660
|
||||
// LegoContainer<TextureData>::~LegoContainer<TextureData>
|
||||
|
||||
// GLOBAL: LEGO1 0x100f0100
|
||||
// _Tree<char const *,pair<char const * const,TextureData *>,map<char const *,TextureData *,LegoContainerInfoComparator,allocator<TextureData *> >::_Kfn,LegoContainerInfoComparator,allocator<TextureData *> >::_Nil
|
||||
// clang-format on
|
||||
|
||||
#endif // LEGOTEXTURECONTAINER_H
|
|
@ -5,7 +5,7 @@
|
|||
#include "mxdsaction.h"
|
||||
#include "mxomni.h"
|
||||
|
||||
class GifManager;
|
||||
class LegoTextureContainer;
|
||||
class Isle;
|
||||
class IslePathActor;
|
||||
class LegoAnimationManager;
|
||||
|
@ -211,8 +211,8 @@ public:
|
|||
|
||||
LegoVideoManager* GetVideoManager() { return (LegoVideoManager*) m_videoManager; }
|
||||
LegoSoundManager* GetSoundManager() { return (LegoSoundManager*) m_soundManager; }
|
||||
LegoInputManager* GetInputManager() { return m_inputMgr; }
|
||||
GifManager* GetGifManager() { return m_gifManager; }
|
||||
LegoInputManager* GetInputManager() { return m_inputManager; }
|
||||
LegoTextureContainer* GetTextureContainer() { return m_textureContainer; }
|
||||
LegoWorld* GetCurrentWorld() { return m_currentWorld; }
|
||||
LegoNavController* GetNavController() { return m_navController; }
|
||||
IslePathActor* GetCurrentVehicle() { return m_currentVehicle; }
|
||||
|
@ -238,8 +238,8 @@ public:
|
|||
private:
|
||||
ScriptContainer* m_scripts; // 0x68
|
||||
ViewLODListManager* m_viewLODListManager; // 0x6c
|
||||
LegoInputManager* m_inputMgr; // 0x70
|
||||
GifManager* m_gifManager; // 0x74
|
||||
LegoInputManager* m_inputManager; // 0x70
|
||||
LegoTextureContainer* m_textureContainer; // 0x74
|
||||
LegoWorldList* m_worldList; // 0x78
|
||||
LegoWorld* m_currentWorld; // 0x7c
|
||||
MxBool m_exit; // 0x80
|
||||
|
@ -275,7 +275,7 @@ ViewManager* GetViewManager();
|
|||
LegoPlantManager* PlantManager();
|
||||
LegoWorld* CurrentWorld();
|
||||
LegoUnkSaveDataWriter* UnkSaveDataWriter();
|
||||
GifManager* GetGifManager();
|
||||
LegoTextureContainer* GetTextureContainer();
|
||||
void FUN_10015820(MxBool p_disable, MxU16 p_flags);
|
||||
void SetROIUnknown0x0c(const char* p_name, undefined p_unk0x0c);
|
||||
LegoWorld* FindWorld(const MxAtomId& p_atom, MxS32 p_entityid);
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
void OverrideSkyColor(MxBool p_shouldOverride);
|
||||
void FUN_1007c520();
|
||||
|
||||
inline Tgl::Renderer* GetRenderer() { return this->m_renderer; }
|
||||
inline Lego3DManager* Get3DManager() { return this->m_3dManager; }
|
||||
inline MxDirect3D* GetDirect3D() { return this->m_direct3d; }
|
||||
inline void SetRender3D(MxBool p_render3d) { this->m_render3d = p_render3d; }
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
#include "gifmanager.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(GifData, 0x14);
|
||||
DECOMP_SIZE_ASSERT(GifMap, 0x10);
|
||||
DECOMP_SIZE_ASSERT(GifManagerBase, 0x18);
|
||||
DECOMP_SIZE_ASSERT(GifManager, 0x24);
|
||||
|
||||
// FUNCTION: LEGO1 0x10065c00
|
||||
GifData::~GifData()
|
||||
{
|
||||
if (m_name) {
|
||||
delete[] m_name;
|
||||
m_name = NULL;
|
||||
}
|
||||
|
||||
if (m_palette) {
|
||||
m_palette->Release();
|
||||
m_palette = NULL;
|
||||
}
|
||||
|
||||
if (m_surface) {
|
||||
m_surface->Release();
|
||||
m_surface = NULL;
|
||||
}
|
||||
|
||||
if (m_texture) {
|
||||
m_texture->Release();
|
||||
m_texture = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10099870
|
||||
GifManager::~GifManager()
|
||||
{
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10099cc0
|
||||
void GifManager::FUN_10099cc0(GifData* p_data)
|
||||
{
|
||||
if (p_data == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef COMPAT_MODE
|
||||
GifList::iterator it;
|
||||
for (it = m_list.begin(); it != m_list.end(); it++) {
|
||||
#else
|
||||
for (GifList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
||||
#endif
|
||||
if (*it == p_data) {
|
||||
// TODO: This is wrong, but what is at +0x0c on the iterator?
|
||||
*it = NULL;
|
||||
|
||||
if (p_data->m_texture->Release() == TRUE) {
|
||||
delete p_data;
|
||||
m_list.erase(it);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
188
LEGO1/lego/legoomni/src/common/legocontainer.cpp
Normal file
188
LEGO1/lego/legoomni/src/common/legocontainer.cpp
Normal file
|
@ -0,0 +1,188 @@
|
|||
#include "legocontainer.h"
|
||||
|
||||
#include "lego/sources/misc/legoimage.h"
|
||||
#include "lego/sources/misc/legotexture.h"
|
||||
#include "legoomni.h"
|
||||
#include "legovideomanager.h"
|
||||
#include "tgl/d3drm/impl.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(TextureData, 0x10);
|
||||
DECOMP_SIZE_ASSERT(LegoContainerInfo<LegoTexture>, 0x10);
|
||||
// DECOMP_SIZE_ASSERT(LegoContainer<LegoTexture>, 0x18);
|
||||
DECOMP_SIZE_ASSERT(LegoTextureContainer, 0x24);
|
||||
|
||||
// FUNCTION: LEGO1 0x10065bf0
|
||||
TextureData::TextureData()
|
||||
{
|
||||
m_name = NULL;
|
||||
m_surface = NULL;
|
||||
m_palette = NULL;
|
||||
m_texture = NULL;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10065c00
|
||||
TextureData::~TextureData()
|
||||
{
|
||||
if (m_name) {
|
||||
delete[] m_name;
|
||||
m_name = NULL;
|
||||
}
|
||||
|
||||
if (m_palette) {
|
||||
m_palette->Release();
|
||||
m_palette = NULL;
|
||||
}
|
||||
|
||||
if (m_surface) {
|
||||
m_surface->Release();
|
||||
m_surface = NULL;
|
||||
}
|
||||
|
||||
if (m_texture) {
|
||||
m_texture->Release();
|
||||
m_texture = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10065c60
|
||||
TextureData* TextureData::Create(const char* p_name, LegoTexture* p_texture)
|
||||
{
|
||||
TextureData* texture = new TextureData();
|
||||
|
||||
if (p_name == NULL || p_texture == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (p_name) {
|
||||
texture->m_name = new char[strlen(p_name) + 1];
|
||||
strcpy(texture->m_name, p_name);
|
||||
}
|
||||
|
||||
LPDIRECTDRAW pDirectDraw = VideoManager()->GetDirect3D()->DirectDraw();
|
||||
LegoImage* image = p_texture->GetImage();
|
||||
|
||||
DDSURFACEDESC desc;
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = sizeof(desc);
|
||||
desc.dwFlags = DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
|
||||
desc.dwWidth = image->GetWidth();
|
||||
desc.dwHeight = image->GetHeight();
|
||||
desc.ddsCaps.dwCaps = DDCAPS_OVERLAYCANTCLIP | DDCAPS_OVERLAY;
|
||||
desc.ddpfPixelFormat.dwSize = sizeof(desc.ddpfPixelFormat);
|
||||
desc.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8;
|
||||
desc.ddpfPixelFormat.dwRGBBitCount = 8;
|
||||
|
||||
MxS32 i;
|
||||
LegoU8* bits;
|
||||
MxU8* surface;
|
||||
|
||||
if (pDirectDraw->CreateSurface(&desc, &texture->m_surface, NULL) != DD_OK) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
bits = image->GetBits();
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = sizeof(desc);
|
||||
|
||||
if (texture->m_surface->Lock(NULL, &desc, DDLOCK_SURFACEMEMORYPTR, NULL) != DD_OK) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
surface = (MxU8*) desc.lpSurface;
|
||||
if (desc.dwWidth == desc.lPitch) {
|
||||
memcpy(surface, bits, desc.dwWidth * desc.dwHeight);
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < desc.dwHeight; i++) {
|
||||
*(MxU32*) surface = *(MxU32*) bits;
|
||||
surface += desc.lPitch;
|
||||
bits += desc.dwWidth;
|
||||
}
|
||||
}
|
||||
|
||||
texture->m_surface->Unlock(desc.lpSurface);
|
||||
|
||||
PALETTEENTRY entries[256];
|
||||
memset(entries, 0, sizeof(entries));
|
||||
|
||||
for (i = 0; i < _countof(entries); i++) {
|
||||
if (i < image->GetCount()) {
|
||||
entries[i].peFlags = 0;
|
||||
entries[i].peRed = image->GetPaletteEntry(i).GetRed();
|
||||
entries[i].peGreen = image->GetPaletteEntry(i).GetGreen();
|
||||
entries[i].peBlue = image->GetPaletteEntry(i).GetBlue();
|
||||
}
|
||||
else {
|
||||
entries[i].peFlags = 0x80;
|
||||
}
|
||||
}
|
||||
|
||||
if (pDirectDraw->CreatePalette(DDPCAPS_ALLOW256 | DDPCAPS_8BIT, entries, &texture->m_palette, NULL) != DD_OK) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
texture->m_surface->SetPalette(texture->m_palette);
|
||||
|
||||
if (((TglImpl::RendererImpl*) VideoManager()->GetRenderer())
|
||||
->CreateTextureFromSurface(texture->m_surface, &texture->m_texture) != D3DRM_OK) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
texture->m_texture->SetAppData((DWORD) texture);
|
||||
return texture;
|
||||
|
||||
done:
|
||||
if (texture->m_name != NULL) {
|
||||
delete[] texture->m_name;
|
||||
texture->m_name = NULL;
|
||||
}
|
||||
|
||||
if (texture->m_palette != NULL) {
|
||||
texture->m_palette->Release();
|
||||
texture->m_palette = NULL;
|
||||
}
|
||||
|
||||
if (texture->m_surface != NULL) {
|
||||
texture->m_surface->Release();
|
||||
texture->m_surface = NULL;
|
||||
}
|
||||
|
||||
if (texture != NULL) {
|
||||
delete texture;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10099870
|
||||
LegoTextureContainer::~LegoTextureContainer()
|
||||
{
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10099cc0
|
||||
void LegoTextureContainer::FUN_10099cc0(TextureData* p_data)
|
||||
{
|
||||
if (p_data == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef COMPAT_MODE
|
||||
TextureList::iterator it;
|
||||
for (it = m_list.begin(); it != m_list.end(); it++) {
|
||||
#else
|
||||
for (TextureList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
||||
#endif
|
||||
if (*it == p_data) {
|
||||
// TODO: This is wrong, but what is at +0x0c on the iterator?
|
||||
*it = NULL;
|
||||
|
||||
if (p_data->m_texture->Release() == TRUE) {
|
||||
delete p_data;
|
||||
m_list.erase(it);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
#include "score.h"
|
||||
|
||||
#include "ambulancemissionstate.h"
|
||||
#include "gifmanager.h"
|
||||
#include "jukebox.h"
|
||||
#include "legocontainer.h"
|
||||
#include "legocontrolmanager.h"
|
||||
#include "legogamestate.h"
|
||||
#include "legoinputmanager.h"
|
||||
|
@ -233,7 +233,7 @@ void Score::Enable(MxBool p_enable)
|
|||
// FUNCTION: LEGO1 0x100019d0
|
||||
void Score::Paint()
|
||||
{
|
||||
GifData* gd = GetGifManager()->Get("bigcube.gif");
|
||||
TextureData* gd = GetTextureContainer()->Get("bigcube.gif");
|
||||
|
||||
if (gd) {
|
||||
RaceState* l78 = (RaceState*) GameState()->GetState("JetskiRaceState");
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "legoomni.h"
|
||||
|
||||
#include "gifmanager.h"
|
||||
#include "legoanimationmanager.h"
|
||||
#include "legobuildingmanager.h"
|
||||
#include "legocontainer.h"
|
||||
#include "legogamestate.h"
|
||||
#include "legoinputmanager.h"
|
||||
#include "legoobjectfactory.h"
|
||||
|
@ -215,9 +215,9 @@ LegoBuildingManager* BuildingManager()
|
|||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10015800
|
||||
GifManager* GetGifManager()
|
||||
LegoTextureContainer* GetTextureContainer()
|
||||
{
|
||||
return LegoOmni::GetInstance()->GetGifManager();
|
||||
return LegoOmni::GetInstance()->GetTextureContainer();
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10015820
|
||||
|
@ -466,9 +466,9 @@ void LegoOmni::Init()
|
|||
{
|
||||
MxOmni::Init();
|
||||
m_scripts = NULL;
|
||||
m_inputMgr = NULL;
|
||||
m_inputManager = NULL;
|
||||
m_viewLODListManager = NULL;
|
||||
m_gifManager = NULL;
|
||||
m_textureContainer = NULL;
|
||||
m_worldList = NULL;
|
||||
m_currentWorld = NULL;
|
||||
m_exit = FALSE;
|
||||
|
@ -520,9 +520,9 @@ void LegoOmni::Destroy()
|
|||
m_buildingManager = NULL;
|
||||
}
|
||||
|
||||
if (m_gifManager) {
|
||||
delete m_gifManager;
|
||||
m_gifManager = NULL;
|
||||
if (m_textureContainer) {
|
||||
delete m_textureContainer;
|
||||
m_textureContainer = NULL;
|
||||
}
|
||||
|
||||
if (m_viewLODListManager) {
|
||||
|
@ -530,14 +530,14 @@ void LegoOmni::Destroy()
|
|||
m_viewLODListManager = NULL;
|
||||
}
|
||||
|
||||
if (m_inputMgr) {
|
||||
delete m_inputMgr;
|
||||
m_inputMgr = NULL;
|
||||
if (m_inputManager) {
|
||||
delete m_inputManager;
|
||||
m_inputManager = NULL;
|
||||
}
|
||||
|
||||
if (m_inputMgr) {
|
||||
delete m_inputMgr;
|
||||
m_inputMgr = NULL;
|
||||
if (m_inputManager) {
|
||||
delete m_inputManager;
|
||||
m_inputManager = NULL;
|
||||
}
|
||||
|
||||
// todo FUN_10046de0
|
||||
|
@ -598,15 +598,15 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param)
|
|||
goto done;
|
||||
}
|
||||
|
||||
if (!(m_inputMgr = new LegoInputManager()) || m_inputMgr->Create(p_param.GetWindowHandle()) != SUCCESS) {
|
||||
delete m_inputMgr;
|
||||
m_inputMgr = NULL;
|
||||
if (!(m_inputManager = new LegoInputManager()) || m_inputManager->Create(p_param.GetWindowHandle()) != SUCCESS) {
|
||||
delete m_inputManager;
|
||||
m_inputManager = NULL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
m_viewLODListManager = new ViewLODListManager();
|
||||
m_gifManager = new GifManager();
|
||||
m_gifManager->SetOwnership(FALSE);
|
||||
m_textureContainer = new LegoTextureContainer();
|
||||
m_textureContainer->SetOwnership(FALSE);
|
||||
// FUN_10046c10
|
||||
|
||||
m_saveDataWriter = new LegoUnkSaveDataWriter();
|
||||
|
@ -616,7 +616,7 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param)
|
|||
m_gameState = new LegoGameState();
|
||||
m_worldList = new LegoWorldList(TRUE);
|
||||
|
||||
if (!m_viewLODListManager || !m_gifManager || !m_worldList || !m_saveDataWriter || !m_plantManager ||
|
||||
if (!m_viewLODListManager || !m_textureContainer || !m_worldList || !m_saveDataWriter || !m_plantManager ||
|
||||
!m_animationManager || !m_buildingManager) {
|
||||
goto done;
|
||||
}
|
||||
|
@ -900,7 +900,7 @@ void LegoOmni::FUN_1005b4f0(MxBool p_disable, MxU16 p_flags)
|
|||
{
|
||||
if (p_disable) {
|
||||
if (p_flags & c_disableInput) {
|
||||
m_inputMgr->DisableInputProcessing();
|
||||
m_inputManager->DisableInputProcessing();
|
||||
}
|
||||
|
||||
if (p_flags & c_disable3d) {
|
||||
|
@ -912,7 +912,7 @@ void LegoOmni::FUN_1005b4f0(MxBool p_disable, MxU16 p_flags)
|
|||
}
|
||||
}
|
||||
else {
|
||||
m_inputMgr->EnableInputProcessing();
|
||||
m_inputManager->EnableInputProcessing();
|
||||
((LegoVideoManager*) m_videoManager)->SetRender3D(TRUE);
|
||||
((LegoVideoManager*) m_videoManager)->UpdateView(0, 0, 0, 0);
|
||||
}
|
||||
|
|
|
@ -57,33 +57,45 @@ void LegoAnimPresenter::Destroy(MxBool p_fromDestructor)
|
|||
MxResult LegoAnimPresenter::VTable0x88(MxStreamChunk* p_chunk)
|
||||
{
|
||||
MxResult result = FAILURE;
|
||||
LegoMemory stream((char*) p_chunk->GetData());
|
||||
|
||||
LegoMemory storage(p_chunk->GetData());
|
||||
MxS32 magicSig;
|
||||
MxS32 val2 = 0;
|
||||
LegoS32 parseScene = 0;
|
||||
MxS32 val3;
|
||||
|
||||
if (stream.Read(&magicSig, sizeof(MxS32)) == SUCCESS && magicSig == 0x11) {
|
||||
if (stream.Read(&m_unk0xa4, sizeof(MxU32)) == SUCCESS) {
|
||||
if (stream.Read(&m_unk0xa8[0], sizeof(float)) == SUCCESS) {
|
||||
if (stream.Read(&m_unk0xa8[1], sizeof(float)) == SUCCESS) {
|
||||
if (stream.Read(&m_unk0xa8[2], sizeof(float)) == SUCCESS) {
|
||||
if (stream.Read(&val2, sizeof(MxS32)) == SUCCESS) {
|
||||
if (stream.Read(&val3, sizeof(MxS32)) == SUCCESS) {
|
||||
m_anim = new LegoAnim();
|
||||
if (m_anim) {
|
||||
if (m_anim->Read(&stream, val2) == SUCCESS) {
|
||||
result = SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (storage.Read(&magicSig, sizeof(magicSig)) != SUCCESS || magicSig != 0x11) {
|
||||
goto done;
|
||||
}
|
||||
if (storage.Read(&m_unk0xa4, sizeof(m_unk0xa4)) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
if (storage.Read(&m_unk0xa8[0], sizeof(m_unk0xa8[0])) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
if (storage.Read(&m_unk0xa8[1], sizeof(m_unk0xa8[1])) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
if (storage.Read(&m_unk0xa8[2], sizeof(m_unk0xa8[2])) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
if (storage.Read(&parseScene, sizeof(parseScene)) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
if (storage.Read(&val3, sizeof(val3)) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
m_anim = new LegoAnim();
|
||||
if (!m_anim) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (m_anim->Read(&storage, parseScene) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
result = SUCCESS;
|
||||
|
||||
done:
|
||||
if (result != SUCCESS) {
|
||||
delete m_anim;
|
||||
Init();
|
||||
|
|
|
@ -35,6 +35,7 @@ public:
|
|||
void SetWidth(LegoU32 p_width) { m_width = p_width; }
|
||||
LegoU32 GetHeight() { return m_height; }
|
||||
void SetHeight(LegoU32 p_height) { m_height = p_height; }
|
||||
LegoU32 GetCount() { return m_count; }
|
||||
LegoPaletteEntry* GetPalette() { return m_palette; }
|
||||
LegoPaletteEntry& GetPaletteEntry(LegoU32 p_i) { return m_palette[p_i]; }
|
||||
void SetPaletteEntry(LegoU32 p_i, LegoPaletteEntry& p_paletteEntry) { m_palette[p_i] = p_paletteEntry; }
|
||||
|
|
|
@ -129,7 +129,7 @@ LPDIRECTDRAWPALETTE MxPalette::CreateNativePalette()
|
|||
}
|
||||
|
||||
if (MVideoManager() && MVideoManager()->GetDirectDraw()) {
|
||||
MVideoManager()->GetDirectDraw()->CreatePalette(4, this->m_entries, &this->m_palette, NULL);
|
||||
MVideoManager()->GetDirectDraw()->CreatePalette(DDPCAPS_8BIT, this->m_entries, &this->m_palette, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,6 +79,11 @@ public:
|
|||
// vtable+0x30
|
||||
Result SetTextureDefaultColorCount(unsigned long) override;
|
||||
|
||||
inline HRESULT CreateTextureFromSurface(LPDIRECTDRAWSURFACE pSurface, LPDIRECT3DRMTEXTURE2* pTexture2)
|
||||
{
|
||||
return m_data->CreateTextureFromSurface(pSurface, pTexture2);
|
||||
}
|
||||
|
||||
public:
|
||||
inline Result Create();
|
||||
inline void Destroy();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue