2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 02:27:40 -04:00

Make Python.Cheat little bit safer

This commit is contained in:
Bartek Bok
2012-07-24 23:40:43 +02:00
parent 8fc79f280c
commit 2531dba66c
3 changed files with 104 additions and 9 deletions

View File

@ -6974,16 +6974,17 @@ PF_CONSOLE_CMD( Python,
"string functions, ...", // Params
"Run a cheat command" )
{
const char* extraParms = "";
if (numParams > 1)
extraParms = params[1];
// now evaluate this mess they made
PyObject* mymod = PythonInterface::FindModule("__main__");
plString args;
if (numParams > 1)
{
const char* tmp = params[1];
args = plString::Format("(%s,)", tmp);
}
else
args = _TEMP_CONVERT_FROM_LITERAL("()");
PythonInterface::RunFunctionSafe("xCheat", params[0], args.c_str());
// create the line to execute the file
char runline[256];
sprintf(runline,"import xCheat;xCheat.%s('%s')", (const char*)params[0],extraParms);
PythonInterface::RunString(runline,mymod);
std::string output;
// get the messages
PythonInterface::getOutputAndReset(&output);