Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call CTO2GameClientShell's destructor correctly. #80

Open
wants to merge 1 commit into
base: linux-x86_64
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion NOLF2/ClientShellDLL/TO2/GlobalsInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,18 @@ define_holder(ILTTexInterface,g_pTexInterface);

SETUP_CLIENTSHELL();

#ifndef __LINUX
define_interface(CTO2GameClientShell, IClientShell);

#else
static CAPIInstanceDefines<CTO2GameClientShell>
global_static_impl_CTO2GameClientShell_defines_IClientShell_Default_{
new CTO2GameClientShell,
"IClientShell" "." "Default",
IClientShell::_IClientShell_VERSION_};

static SStaticSearchInterface
global_static_var_search_IClientShell_CTO2GameClientShell_Default_ = {
SEARCH_MARKER_INTERFACE, SEARCH_MARKER_INT, "IClientShell",
"CTO2GameClientShell", "Default",
IClientShell::_IClientShell_VERSION_};
#endif
6 changes: 6 additions & 0 deletions runtime/client/src/clientmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,12 @@ void CClientMgr::TermClientShellDE()
{
bm_UnbindModule(m_hShellModule);
m_hShellModule = NULL;
#ifdef __LINUX
delete i_client_shell;
i_client_shell = NULL;
con_client_shell_is_gone();
#endif

}

if (m_hClientResourceModule)
Expand Down
7 changes: 7 additions & 0 deletions runtime/client/src/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ void con_WhitePrintf(const char *pMsg, ...)
va_end( marker );
}

#ifdef __LINUX
void con_client_shell_is_gone()
{
GETCONSOLE()->ClientShellIsGone();
}
#endif

void con_OnKeyPress(uint32 key)
{
if (dsi_IsConsoleEnabled ())
Expand Down
3 changes: 3 additions & 0 deletions runtime/client/src/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ void con_DrawSmall(int nLines);
void con_PrintString(CONCOLOR theColor, int filterLevel, const char *pMsg);
void con_Printf(CONCOLOR theColor, int filterLevel, const char *pMsg, ...);
void con_WhitePrintf(const char *pMsg, ...);
#ifdef __LINUX
void con_client_shell_is_gone();
#endif

#endif // __CONSOLE_H__

8 changes: 7 additions & 1 deletion runtime/client/src/sys/linux/linuxconsole_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ CConsole::CConsole()

m_bInitialized = true;
m_bInitTerminate = false;
m_bClientShellIsGone = false;

m_Tex = NULL;
m_Font = NULL;
Expand Down Expand Up @@ -1328,7 +1329,7 @@ void CConsole::PrintString(CONCOLOR theColor, int filterLevel, const char *pMsg)

// Send the info we're using for output to the client shell so the
// game code can do whatever it wants with it.
if (i_client_shell != NULL) {
if (!m_bClientShellIsGone) {
CConsolePrintData PrintData;

// turn the CONCOLOR into an LTRGB
Expand Down Expand Up @@ -1473,6 +1474,11 @@ void CConsole::OnKeyPress(uint32 key)
}
}

void CConsole::ClientShellIsGone()
{
m_bClientShellIsGone = true;
}

uint32 GetInterfaceSurfaceMemory()
{
return 0;
Expand Down
7 changes: 7 additions & 0 deletions runtime/client/src/sys/linux/linuxconsole_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ class CConsole
// haven't been loaded
bool m_bSaveVariablesMask;

//On Linux, the client shell is heap allocated and deleted in CClientMgr::TermClientShellDE.
//For some reason, PrintString does not correctly see this, and calls OnConsolePrint to a NULL pointer.
//Instead, check this.
bool m_bClientShellIsGone;

protected:

enum EConState {
Expand Down Expand Up @@ -430,6 +435,8 @@ class CConsole

void OnKeyPress( uint32 key );

void ClientShellIsGone();

};

extern bool IsKeyDown(uint16 vkKey);
Expand Down