mirror of
https://github.com/isledecomp/isle.git
synced 2024-11-26 09:38:14 -05:00
GifManager: use STL members (#460)
* Truncate symbol names to 255 characters when matching * GifManager refactor * Refactor, annotations --------- Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
parent
35e5a62ff7
commit
ee7241f73d
4 changed files with 158 additions and 58 deletions
|
@ -3,73 +3,139 @@
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "decomp.h"
|
#include "decomp.h"
|
||||||
|
#include "mxstl/stlcompat.h"
|
||||||
#include "mxtypes.h"
|
#include "mxtypes.h"
|
||||||
|
|
||||||
#include <d3drmobj.h>
|
#include <d3drmobj.h>
|
||||||
#include <ddraw.h>
|
#include <ddraw.h>
|
||||||
|
|
||||||
|
#pragma warning(disable : 4237)
|
||||||
|
|
||||||
|
// SIZE 0x14
|
||||||
struct GifData {
|
struct GifData {
|
||||||
public:
|
public:
|
||||||
const char* m_name;
|
char* m_name; // 0x00
|
||||||
LPDIRECTDRAWSURFACE m_surface;
|
LPDIRECTDRAWSURFACE m_surface; // 0x04
|
||||||
LPDIRECTDRAWPALETTE m_palette;
|
LPDIRECTDRAWPALETTE m_palette; // 0x08
|
||||||
LPDIRECT3DRMTEXTURE2 m_texture;
|
LPDIRECT3DRMTEXTURE2 m_texture; // 0x0c
|
||||||
MxU8* m_data;
|
MxU8* m_data; // 0x10
|
||||||
|
|
||||||
|
~GifData();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GifMapEntry {
|
struct GifMapComparator {
|
||||||
public:
|
bool operator()(const char* const& p_key0, const char* const& p_key1) const { return strcmp(p_key0, p_key1) > 0; }
|
||||||
GifMapEntry* m_right;
|
|
||||||
GifMapEntry* m_parent;
|
|
||||||
GifMapEntry* m_left;
|
|
||||||
const char* m_key;
|
|
||||||
GifData* m_value;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GifMap {
|
// SIZE 0x10
|
||||||
public:
|
class GifMap : public map<const char*, GifData*, GifMapComparator> {
|
||||||
GifMapEntry* FindNode(const char*& p_string);
|
// SYNTHETIC: LEGO1 0x1005a400
|
||||||
|
// GifMap::~GifMap
|
||||||
inline GifData* Get(const char* p_string)
|
|
||||||
{
|
|
||||||
GifData* ret = NULL;
|
|
||||||
GifMapEntry* entry = FindNode(p_string);
|
|
||||||
if (((m_unk0x4 == entry || strcmp(p_string, entry->m_key) > 0) ? m_unk0x4 : entry) != entry)
|
|
||||||
ret = entry->m_value;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
undefined4 m_unk0x0;
|
|
||||||
GifMapEntry* m_unk0x4;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef list<GifData*> GifList;
|
||||||
|
|
||||||
// VTABLE: LEGO1 0x100d86d4
|
// VTABLE: LEGO1 0x100d86d4
|
||||||
|
// SIZE 0x18
|
||||||
class GifManagerBase {
|
class GifManagerBase {
|
||||||
public:
|
public:
|
||||||
// STUB: LEGO1 0x1005b660
|
// FUNCTION: LEGO1 0x1005b660
|
||||||
virtual ~GifManagerBase() {}
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x1005a310
|
// SYNTHETIC: LEGO1 0x1005a310
|
||||||
// GifManagerBase::`scalar deleting destructor'
|
// GifManagerBase::`scalar deleting destructor'
|
||||||
|
|
||||||
inline GifData* Get(const char* p_name) { return m_unk0x8.Get(p_name); }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
undefined4 m_unk0x0;
|
MxBool m_ownership; // 0x04
|
||||||
undefined4 m_unk0x4;
|
GifMap m_map; // 0x08
|
||||||
GifMap m_unk0x8;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// VTABLE: LEGO1 0x100d86fc
|
// VTABLE: LEGO1 0x100d86fc
|
||||||
|
// SIZE 0x24
|
||||||
class GifManager : public GifManagerBase {
|
class GifManager : public GifManagerBase {
|
||||||
public:
|
public:
|
||||||
|
GifManager() { m_ownership = TRUE; };
|
||||||
virtual ~GifManager() override;
|
virtual ~GifManager() override;
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x1005a580
|
// SYNTHETIC: LEGO1 0x1005a580
|
||||||
// GifManager::`scalar deleting destructor'
|
// GifManager::`scalar deleting destructor'
|
||||||
|
|
||||||
|
void FUN_10099cc0(GifData* p_data);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
undefined m_unk0x14[0x1c];
|
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
|
#endif // GIFMANAGER_H
|
||||||
|
|
|
@ -1,32 +1,61 @@
|
||||||
#include "gifmanager.h"
|
#include "gifmanager.h"
|
||||||
|
|
||||||
DECOMP_SIZE_ASSERT(GifData, 0x14);
|
DECOMP_SIZE_ASSERT(GifData, 0x14);
|
||||||
DECOMP_SIZE_ASSERT(GifMapEntry, 0x14);
|
DECOMP_SIZE_ASSERT(GifMap, 0x10);
|
||||||
DECOMP_SIZE_ASSERT(GifMap, 0x08);
|
DECOMP_SIZE_ASSERT(GifManagerBase, 0x18);
|
||||||
DECOMP_SIZE_ASSERT(GifManagerBase, 0x14);
|
DECOMP_SIZE_ASSERT(GifManager, 0x24);
|
||||||
DECOMP_SIZE_ASSERT(GifManager, 0x30);
|
|
||||||
|
|
||||||
// GLOBAL: LEGO1 0x100f0100
|
// FUNCTION: LEGO1 0x10065c00
|
||||||
GifMapEntry* g_unk0x100f0100;
|
GifData::~GifData()
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10001cc0
|
|
||||||
GifMapEntry* GifMap::FindNode(const char*& p_string)
|
|
||||||
{
|
{
|
||||||
GifMapEntry* ret = m_unk0x4;
|
if (m_name) {
|
||||||
GifMapEntry* current = ret->m_parent;
|
delete[] m_name;
|
||||||
while (current != g_unk0x100f0100) {
|
m_name = NULL;
|
||||||
if (strcmp(current->m_key, p_string) <= 0) {
|
}
|
||||||
ret = current;
|
|
||||||
current = current->m_right;
|
if (m_palette) {
|
||||||
}
|
m_palette->Release();
|
||||||
else
|
m_palette = NULL;
|
||||||
current = current->m_left;
|
}
|
||||||
|
|
||||||
|
if (m_surface) {
|
||||||
|
m_surface->Release();
|
||||||
|
m_surface = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_texture) {
|
||||||
|
m_texture->Release();
|
||||||
|
m_texture = NULL;
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// STUB: LEGO1 0x10099870
|
// FUNCTION: LEGO1 0x10099870
|
||||||
GifManager::~GifManager()
|
GifManager::~GifManager()
|
||||||
{
|
{
|
||||||
// TODO
|
}
|
||||||
|
|
||||||
|
// 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 +0xc on the iterator?
|
||||||
|
*it = NULL;
|
||||||
|
|
||||||
|
if (p_data->m_texture->Release() == TRUE) {
|
||||||
|
delete p_data;
|
||||||
|
m_list.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,8 +227,7 @@ void Score::VTable0x68(MxBool p_add)
|
||||||
// FUNCTION: LEGO1 0x100019d0
|
// FUNCTION: LEGO1 0x100019d0
|
||||||
void Score::Paint()
|
void Score::Paint()
|
||||||
{
|
{
|
||||||
GifManager* gm = GetGifManager();
|
GifData* gd = GetGifManager()->Get("bigcube.gif");
|
||||||
GifData* gd = gm->Get("bigcube.gif");
|
|
||||||
|
|
||||||
if (gd) {
|
if (gd) {
|
||||||
RaceState* l78 = (RaceState*) GameState()->GetState("JetskiRaceState");
|
RaceState* l78 = (RaceState*) GameState()->GetState("JetskiRaceState");
|
||||||
|
|
|
@ -170,6 +170,12 @@ def skip_compare(self, orig: int):
|
||||||
|
|
||||||
def _match_on(self, compare_type: SymbolType, addr: int, name: str) -> bool:
|
def _match_on(self, compare_type: SymbolType, addr: int, name: str) -> bool:
|
||||||
# Update the compare_type here too since the marker tells us what we should do
|
# Update the compare_type here too since the marker tells us what we should do
|
||||||
|
|
||||||
|
# Truncate the name to 255 characters. It will not be possible to match a name
|
||||||
|
# longer than that because MSVC truncates the debug symbols to this length.
|
||||||
|
# See also: warning C4786.
|
||||||
|
name = name[:255]
|
||||||
|
|
||||||
logger.debug("Looking for %s %s", compare_type.name.lower(), name)
|
logger.debug("Looking for %s %s", compare_type.name.lower(), name)
|
||||||
cur = self._db.execute(
|
cur = self._db.execute(
|
||||||
"""UPDATE `symbols`
|
"""UPDATE `symbols`
|
||||||
|
|
Loading…
Reference in a new issue