Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Commit

Permalink
Some tweaks + started working on 2d effect plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jte committed Nov 30, 2014
1 parent a701e3f commit f3bc230
Show file tree
Hide file tree
Showing 30 changed files with 1,366 additions and 254 deletions.
453 changes: 448 additions & 5 deletions Engine/C2dEffect.cpp

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions Engine/C2dEffect.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#pragma once

typedef int CRoadsignAttrFlags;

class C2dEffect
{
public:
static bool PluginAttach();
* Roadsign_GetNumLettersFromFlags(CRoadsignAttrFlags)
* Roadsign_GetNumLinesFromFlags(CRoadsignAttrFlags)
* Roadsign_GetPaletteIDFromFlags(CRoadsignAttrFlags)
* Shutdown()
size_t Roadsign_GetNumLettersFromFlags(CRoadsignAttrFlags flags);
size_t Roadsign_GetNumLinesFromFlags(CRoadsignAttrFlags flags);
size_t Roadsign_GetPaletteIDFromFlags(CRoadsignAttrFlags flags);
void Shutdown();
protected:
private:
};
2 changes: 1 addition & 1 deletion Engine/CBaseModelInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CBaseModelInfo
float GetLoadDistanceUnscaled() const;
RwObject* GetRwObject() const;
bool GetIsRoad() const;
private:
protected:
uint32_t m_hashKey;
uint16_t m_refCount;
uint16_t m_textureDictionary;
Expand Down
46 changes: 37 additions & 9 deletions Engine/CClumpModelInfo.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "StdInc.h"
/*

void CClumpModelInfo::Init()
{
m_AnimId = -1;
Expand All @@ -26,14 +26,14 @@ static RpAtomic *SetAtomicHAnimHierarchyCB(RpAtomic *pAtomic, void *pData)

RpClump *CClumpModelInfo::CreateInstance()
{
if(pRwObject == NULL)
if (GetRwObject() == NULL)
{
return NULL;
}
AddRef();
RpClump *pCloned = RpClumpClone(pRwObject);
RpClump *pCloned = RpClumpClone((RpClump*)GetRwObject());
RpAtomic *pFirst = GetFirstAtomic(pCloned);
if(pFirst)
if (pFirst)
{
if(RpSkinGeometryGetSkin(pFirst->geometry) != NULL)
{
Expand All @@ -47,11 +47,11 @@ RpClump *CClumpModelInfo::CreateInstance()
}
}
}
if(bIsRoad)
if (GetIsRoad())
{
RpAnimBlendClumpInit(pCloned);
CAnimBlendHierarchy *pAnim = CAnimManager::GetAnimationByID(m_uiHashKey, &CAnimManager::AnimBlocks[m_AnimId]);
if(pAnim)
CAnimBlendHierarchy *pAnim = CAnimManager::GetAnimationByID(GetHashKey(), &CAnimManager::AnimBlocks[m_AnimId]);
if (pAnim)
{
CAnimManager::BlendAnimation(pCloned, pAnim, 2, 1.0f);
}
Expand All @@ -62,7 +62,7 @@ RpClump *CClumpModelInfo::CreateInstance()

RpClump *CClumpModelInfo::CreateInstance(RwMatrixTag *pMatrix)
{
if(pRwObject == NULL)
if(GetRwObject() == NULL)
{
return NULL;
}
Expand All @@ -88,4 +88,32 @@ void CClumpModelInfo::ConvertAnimFileIndex()
delete[] m_AnimFile;
m_AnimId = animId;
}
}*/
}

void CClumpModelInfo::DeleteRwObject()
{
RpClump *pClump = (RpClump*)m_rwObject;
if (pClump)
{
v3 = Get2DEffectAtomic(m_rwObject);
if ( v3 )
{
v4 = *(_DWORD *)(g2dEffectPluginOffset + *(_DWORD *)(v3 + 24));
if ( v4 )
v5 = *(_DWORD *)v4;
else
LOBYTE(v5) = 0;
pThis->uc2DFxCount -= v5;
}
RpClumpDestroy(pClump);
m_rwObject = 0;
RemoveTexDictionaryRef();
size_t animIndex = GetAnimFileIndex();
if (animIndex != -1)
{
CAnimManager::RemoveAnimBlockRef(animIndex);
}
if ( HIBYTE(pThis->flags) & 8 )
LOBYTE(v1) = CBaseModelInfo__DeleteCollisionModel(pThis);
}
}
4 changes: 2 additions & 2 deletions Engine/CClumpModelInfo.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once

class CClumpModelInfo : public CBaseModelInfo
class CClumpModelInfo : protected CBaseModelInfo
{
public:
void ConvertAnimFileIndex();
RpClump *CreateInstance();
RpClump *CreateInstance(RwMatrixTag *pMatrix);
//* DeleteRwObject()
void DeleteRwObject();
//* FillFrameArray(RpClump*, RwFrame**)
//* FillFrameArrayCB(RwFrame*, void*)
//* FindFrameFromIdCB(RwFrame*, void*)
Expand Down
7 changes: 6 additions & 1 deletion Engine/CDraw.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "CRGBA.h"

class CDraw
{
public:
Expand All @@ -9,13 +11,16 @@ class CDraw
//
static float GetFOV();
static float GetAspectRatio();
static float GetFarClip();
static float GetLODDistance();
static float GetNearClip();
protected:
private:
static bool Drawn;
//* FadeBlue
//* FadeGreen
//* FadeRed
//* FadeValue
static CRGBA FadeValue;
static bool NotDrawn;
static float ms_fAspectRatio;
static float ms_fFOV;
Expand Down
87 changes: 86 additions & 1 deletion Engine/CFileLoader.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "StdInc.h"

/*
RpAtomic *CFileLoader::FindRelatedModelInfoCB(RpAtomic *atomic, void *data)
{
RpClump *clump = (RpClump*)data;
Expand Down Expand Up @@ -42,4 +42,89 @@ void CFileLoader::LoadAtomicFile(char const *filename)
}
}
RwStreamClose(stream, NULL);
}*/

const char* CFileLoader::LoadLine(int fp)
{
if(!CFileMgr::ReadLine((FILE*)fp, ms_line, sizeof(ms_line)))
{
return NULL;
}
char* p = ms_line;
while(p)
{
if(*p < ' ' || *p == ',')
{
*p = ' ';
}
}
p = ms_line;
while(p && *p == ' ') p++;
return p;
}

bool CFileLoader::LoadClumpFile(RwStream *stream, size_t model_id)
{
char v2; // bl@1
int v3; // ebp@1
CVehicleModelInfo *v4; // esi@1
RpClump *v5; // ebx@2
RwFrame *v6; // ebp@2
RpClump *v7; // eax@3
RpClump *v8; // esi@3
RwFrame *v9; // eax@4
RpClump *v11; // edi@10
CVehicleModelInfo *v12; // [sp+10h] [bp+10h]@1

v3 = model_id;
CVehicleModelInfo* v12 = static_cast<CVehicleModelInfo*>(CModelInfo::GetModelInfo(model_id));
v4 = v12;
v2 = (unsigned __int8)v12->__parent.__parent.__vmt->getType(v12) == 6;
if ( HIBYTE(v12->__parent.__parent.flags) & 2 )
{
v5 = (RpClump *)RpClumpCreate();
v6 = RwFrameCreate();
v5->object.parent = v6;
if ( !v7ed2d0(stream, 16, 0, 0) )
{
LABEL_6:
((void (__thiscall *)(CVehicleModelInfo *, RpClump *))v4->__parent.__parent.__vmt[1]._m04)(v4, v5);
return 1;
}
while ( 1 )
{
v7 = RpClumpStreamRead(stream);
v8 = v7;
if ( !v7 )
return 0;
v9 = _rwFrameCloneAndLinkClones(v7->object.parent);
v7f0b00(v6, v9);
RpClumpForAllAtomics(v8, (int (__cdecl *)(_DWORD, _DWORD))dummy_537290, v5);
RpClumpDestroy(v8);
if ( !v7ed2d0(stream, 16, 0, 0) )
{
v4 = v12;
goto LABEL_6;
}
}
}
if ( !v7ed2d0(stream, 16, 0, 0) )
return 0;
if ( v2 )
{
CCollisionPlugin__SetModelInfo(&v12->__parent.__parent);
CVehicleModelInfo__UseCommonVehicleTexDicationary();
}
v11 = RpClumpStreamRead(stream);
if ( v2 )
{
CCollisionPlugin__SetModelInfo(0);
restoreTextureFindCallback();
}
if ( !v11 )
return 0;
((void (__thiscall *)(CVehicleModelInfo *, RpClump *))v12->__parent.__parent.__vmt[1]._m04)(v12, v11);
if ( v3 == 508 )
v12->ucDoorCount = 2;
return 1;
}
4 changes: 2 additions & 2 deletions Engine/CFileLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CFileLoader
//* LoadEntryExit(char const*)
//* LoadGarage(char const*)
//* LoadLevel(char const*)
//* LoadLine(int)
static const char* LoadLine(int fp);
//* LoadLine(unsigned char**, int&)
//* LoadObject(char const*)
//* LoadObjectInstance(CFileObjectInstance*, char const*)
Expand All @@ -57,5 +57,5 @@ class CFileLoader
//* StartLoadClumpFile(RwStream*, unsigned int)
protected:
private:
static char *ms_line;
static char ms_line[512];
};
24 changes: 12 additions & 12 deletions Engine/CFileMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ class CFileMgr
{
public:
//* ChangeDir(char const*)
bool CloseFile(FILE *pFile);
static bool CloseFile(FILE *pFile);
//* GetCdError()
//* GetCdErrorString(int)
//* GetCdFile(char const*, unsigned int&, unsigned int&)
//* GetErrorReadWrite(int)
size_t GetTotalSize(FILE *pFile);
static size_t GetTotalSize(FILE *pFile);
//* InitCd()
//* InitCdSystem()
//* Initialise()
int LoadFile(char const *szFilename, unsigned char *pBuffer, int iBufferSize, char const *szMode);
FILE *OpenFile(char const *szName, char const *szMode);
FILE *OpenFileForAppending(char const *szName);
FILE *OpenFileForWriting(char const *szName);
size_t Read(FILE *pFile, char *pBuffer, int iBufferSize);
static int LoadFile(char const *szFilename, unsigned char *pBuffer, int iBufferSize, char const *szMode);
static FILE *OpenFile(char const *szName, char const *szMode);
static FILE *OpenFileForAppending(char const *szName);
static FILE *OpenFileForWriting(char const *szName);
static size_t Read(FILE *pFile, char *pBuffer, int iBufferSize);
//* ReadCd(unsigned int, char*, unsigned int)
bool ReadLine(FILE *pFile, char *pBuffer, int iBufferSize);
bool Seek(FILE *pFile, int iPos, int iFrom);
void SetDir(char const *szDirectory);
static bool ReadLine(FILE *pFile, char *pBuffer, int iBufferSize);
static bool Seek(FILE *pFile, int iPos, int iFrom);
static void SetDir(char const *szDirectory);
//* SetDirMyDocuments()
// * SyncCd()
size_t Tell(FILE *pFile);
size_t Write(FILE *pFile, char *pBuffer, int iBufferSize);
static size_t Tell(FILE *pFile);
static size_t Write(FILE *pFile, char *pBuffer, int iBufferSize);
private:
static char fileDataArea[MAX_PATH];
static char ms_dirName[MAX_PATH];
Expand Down
Loading

0 comments on commit f3bc230

Please sign in to comment.