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

Remove value constructors for ConsoleValueRef & fix callbacks #1298

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions Engine/source/T3D/gameBase/gameConnection.cpp
Expand Up @@ -999,8 +999,10 @@ bool GameConnection::readDemoStartBlock(BitStream *stream)

void GameConnection::demoPlaybackComplete()
{
static ConsoleValueRef demoPlaybackArgv[1] = { "demoPlaybackComplete" };
Sim::postCurrentEvent(Sim::getRootGroup(), new SimConsoleEvent(1, demoPlaybackArgv, false));
static const char* demoPlaybackArgv[1] = { "demoPlaybackComplete" };
static StringStackConsoleWrapper demoPlaybackCmd(1, demoPlaybackArgv);

Sim::postCurrentEvent(Sim::getRootGroup(), new SimConsoleEvent(demoPlaybackCmd.argc, demoPlaybackCmd.argv, false));
Parent::demoPlaybackComplete();
}

Expand Down
5 changes: 3 additions & 2 deletions Engine/source/cinterface/c_scripting.cpp
Expand Up @@ -76,9 +76,10 @@ extern "C" {
if (!entry)
return "";

ConsoleValueRef argv[] = {"consoleExportXML"};
static const char* exportArgv[1] = { "consoleExportXML" };
static StringStackConsoleWrapper exportCmd(1, exportArgv);

return entry->cb.mStringCallbackFunc(NULL, 1, argv);
return entry->cb.mStringCallbackFunc(NULL, exportCmd.argc, exportCmd.argv);
}

MarshalNativeEntry* script_get_namespace_entry(const char* nameSpace, const char* name)
Expand Down
41 changes: 9 additions & 32 deletions Engine/source/console/console.cpp
Expand Up @@ -1534,9 +1534,16 @@ StringTableEntry getModNameFromPath(const char *path)
void postConsoleInput( RawData data )
{
// Schedule this to happen at the next time event.
ConsoleValue values[2];
ConsoleValueRef argv[2];
argv[0] = "eval";
argv[1] = ( const char* ) data.data;

values[0].init();
values[0].setStringValue("eval");
values[1].init();
values[1].setStringValue((const char*)data.data);
argv[0].value = &values[0];
argv[1].value = &values[1];

Sim::postCurrentEvent(Sim::getRootGroup(), new SimConsoleEvent(2, argv, false));
}

Expand Down Expand Up @@ -1610,36 +1617,6 @@ ConsoleValueRef::ConsoleValueRef(const ConsoleValueRef &ref)
value = ref.value;
}

ConsoleValueRef::ConsoleValueRef(const char *newValue) : value(NULL)
{
*this = newValue;
}

ConsoleValueRef::ConsoleValueRef(const String &newValue) : value(NULL)
{
*this = (const char*)(newValue.utf8());
}

ConsoleValueRef::ConsoleValueRef(U32 newValue) : value(NULL)
{
*this = newValue;
}

ConsoleValueRef::ConsoleValueRef(S32 newValue) : value(NULL)
{
*this = newValue;
}

ConsoleValueRef::ConsoleValueRef(F32 newValue) : value(NULL)
{
*this = newValue;
}

ConsoleValueRef::ConsoleValueRef(F64 newValue) : value(NULL)
{
*this = newValue;
}

ConsoleValueRef& ConsoleValueRef::operator=(const ConsoleValueRef &newValue)
{
value = newValue.value;
Expand Down
6 changes: 0 additions & 6 deletions Engine/source/console/console.h
Expand Up @@ -214,12 +214,6 @@ class ConsoleValueRef
~ConsoleValueRef() { ; }

ConsoleValueRef(const ConsoleValueRef &ref);
ConsoleValueRef(const char *value);
ConsoleValueRef(const String &ref);
ConsoleValueRef(U32 value);
ConsoleValueRef(S32 value);
ConsoleValueRef(F32 value);
ConsoleValueRef(F64 value);

static ConsoleValueRef fromValue(ConsoleValue *value) { ConsoleValueRef ref; ref.value = value; return ref; }

Expand Down
2 changes: 1 addition & 1 deletion Engine/source/console/simEvents.cpp
Expand Up @@ -129,7 +129,7 @@ ConsoleValueRef SimConsoleThreadExecCallback::waitForResult()
return retVal;
}

return (const char*)NULL;
return ConsoleValueRef();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, this should never be called, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing no but it doesn't make sense to return retVal if for whatever reason acquire fails.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I was just trying to understand the flow.

}

//-----------------------------------------------------------------------------
Expand Down