Skip to content

Commit

Permalink
Fix TWString bug
Browse files Browse the repository at this point in the history
  • Loading branch information
AdventureT committed Jan 6, 2024
1 parent 4dead3e commit 5788d00
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion OpenJPOG/Source/Tasks/ARootTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void ARootTask::UnloadFrontEndController()
void ARootTask::AllocateRenderInterface()
{
g_oTheApp.GetKernel()->LoadInterface("TRenderD3DInterface");
m_pRenderInterface = (TRenderInterface*)TFindClass("TRenderD3DInterface", TNULL)->CreateObject();
m_pRenderInterface = (TRenderInterface*)TFindClass(TRenderD3DInterface, TNULL)->CreateObject();
m_pRenderInterface->Create(g_oTheApp.GetKernel());
m_pRenderInterface->DumpStats();
}
Expand Down
3 changes: 2 additions & 1 deletion Toshi/Include/TKernel/TWString.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <stdio.h>
#include "TDebug.h"
#include "TSystemTools.h"
#include <TKernel/TMemory.h>

TOSHI_NAMESPACE_BEGIN

Expand Down Expand Up @@ -140,7 +141,7 @@ class TKERNELINTERFACE_EXPORTS TWString
void FreeBuffer()
{
if (m_iStrLen != 0) {
free(m_pBuffer);
tfree(m_pBuffer);
m_pBuffer = TNULL;
}
Reset();
Expand Down
3 changes: 3 additions & 0 deletions Toshi/Include/TRenderD3D/TRenderD3DInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class TMSWindow;

class TRENDERINTERFACED3D_EXPORTS TRenderD3DInterface : public TRenderInterface
{

DECLARE_DYNAMIC(TRenderD3DInterface)

public:

TRenderD3DInterface();
Expand Down
7 changes: 3 additions & 4 deletions Toshi/Source/TKernel/TWString.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "TWString.h"
#include "TSystemTools.h"
#include <string.h>
#include <TKernel/TMemory.h>

TOSHI_NAMESPACE_USING

Expand All @@ -25,7 +24,7 @@ TBOOL TWString::AllocBuffer(TINT a_iLength, TBOOL a_bClear)
if (newExcessLen < 0 || newExcessLen > 0xFF) {
if (m_iStrLen != 0 && a_bClear) tfree(m_pBuffer);

m_pBuffer = (TPWCHAR)tmalloc((a_iLength * 2) + 1, TNULL, -1);
m_pBuffer = (TPWCHAR)tmalloc((a_iLength + 1) * 2, TNULL, -1);
m_iExcessLen = 0;
TASSERT(m_pBuffer != TNULL);
hasChanged = TTRUE;
Expand Down Expand Up @@ -97,7 +96,7 @@ void TWString::Copy(const TWString& a_rOther, TINT a_iLength)
if (*this != a_rOther) {
if (a_rOther.m_iStrLen < a_iLength || a_iLength == -1) a_iLength = a_rOther.m_iStrLen;
AllocBuffer(a_iLength);
TSystem::MemCopy(m_pBuffer, a_rOther.m_pBuffer, a_iLength);
TSystem::StringCopy(m_pBuffer, a_rOther.m_pBuffer, a_iLength);
m_pBuffer[a_iLength] = '\0';
}
}
Expand All @@ -108,7 +107,7 @@ void TWString::Copy(TPCWCHAR a_pcString, TINT a_iLength)
TINT iLength = a_pcString ? TSystem::StringLength(a_pcString) : 0;
if (iLength < a_iLength || a_iLength == -1) a_iLength = iLength;
AllocBuffer(a_iLength, TTRUE);
TSystem::MemCopy(m_pBuffer, a_pcString, a_iLength);
TSystem::StringCopy(m_pBuffer, a_pcString, a_iLength);
m_pBuffer[a_iLength] = '\0';
}
}
Expand Down
2 changes: 1 addition & 1 deletion Toshi/Source/TRender/TNullResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

TOSHI_NAMESPACE_USING

IMPLEMENT_DYNAMIC(TNullResource, TResource)
IMPLEMENT_DYNCREATE(TNullResource, TResource)
9 changes: 2 additions & 7 deletions Toshi/Source/TRender/TRenderInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ TRenderInterface::TRenderInterface()
{
m_bIsCreated = TFALSE;
m_pDefaultRenderContext = TNULL;
m_pCurrentRenderContext = TNULL;
m_pKernel = TNULL;
m_iResourceCount = 1;
TASSERT(s_Interface == TNULL);
s_Interface = this;
TSystem::MemSet(m_aSysResources, 0, sizeof(m_aSysResources));
Expand All @@ -29,13 +31,6 @@ TBOOL TRenderInterface::Create(TKernelInterface* pKernelInterface)
return TTRUE;
}

//class TVertexFactoryResource : public TVertexFactoryFormat, public TResource
//{
// DECLARE_DYNAMIC(TVertexFactoryResource)
//};

//IMPLEMENT_DYNCREATE(TVertexFactoryResource, TResource)

TBOOL TRenderInterface::CreateSystemResources()
{
{
Expand Down
1 change: 1 addition & 0 deletions Toshi/Source/TRenderD3D/TD3DVertexPoolResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ TOSHI_NAMESPACE_USING

IMPLEMENT_DYNCREATE(TVertexPoolResource, TVertexPoolResourceInterface)


TBOOL TVertexPoolResource::Validate()
{
if (IsValid()) {
Expand Down
2 changes: 2 additions & 0 deletions Toshi/Source/TRenderD3D/TRenderD3DInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

TOSHI_NAMESPACE_USING

IMPLEMENT_DYNCREATE(TRenderD3DInterface, TRenderInterface)

TRenderD3DInterface::TRenderD3DInterface()
{
m_pD3DInterface = NULL;
Expand Down

0 comments on commit 5788d00

Please sign in to comment.