Пример #1
0
bool Cmd_RunBatchScript_Execute(COMMAND_ARGS)
{
	char	fileName[1024];
	UInt32	bRunOnRef = 0;
	UInt32	bSuppressOutput = 0;

	*result = 0;

	if(!ExtractArgs(paramInfo, arg1, opcodeOffsetPtr, thisObj, arg3, scriptObj, eventList, &fileName, &bRunOnRef, &bSuppressOutput)) {
		return true;
	}

	FILE	* src = NULL;
	fopen_s(&src, fileName, "r");
	if(src)
	{
		*result = 1;

		char	line[4096];
		while(fgets(line, sizeof(line), src))
		{
			UInt32	lineLen = strlen(line);
			if(lineLen > 1)	// skip empty lines
			{
				// strip the trailing newline (if we have one)
				if(line[lineLen - 1] == '\n')
					line[lineLen - 1] = 0;

				if (bRunOnRef)
				{
					if (!RunScriptLineOnREFR(line, thisObj, bSuppressOutput ? true : false))
						*result = 0;
				}
				else
				{
					if (!RunScriptLine2(line, bSuppressOutput ? true : false))
						*result = 0;
				}
			}
		}

		fclose(src);
	}

	return true;
}
Пример #2
0
static bool Cmd_RunScriptLine_Execute(COMMAND_ARGS)
{
	char scriptText[kMaxMessageLength];
	UInt32 bRunOnRef = 0;
	UInt32 bSuppressOutput = 0;
	*result = 0;

	if (!ExtractFormatStringArgs(0, scriptText, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, kCommandInfo_RunScriptLine.numParams, &bRunOnRef, &bSuppressOutput))
		return true;

	UInt32 len = strlen(scriptText);
	if (len)
	{
		if (bRunOnRef)
			*result = RunScriptLineOnREFR(scriptText, thisObj, bSuppressOutput ? true : false) ? 1 : 0;
		else
			*result = RunScriptLine2(scriptText, bSuppressOutput ? true : false) ? 1 : 0;
	}

	return true;
}
Пример #3
0
bool Script::RunScriptLine(const char * text, TESObjectREFR * object)
{
    return RunScriptLine2(text, object, false);
}