Esempio n. 1
0
static bool Cmd_ConScribe_UnregisterLog_Execute(COMMAND_ARGS)
{
	UInt32 DefaultFlag = 0;
	UInt32 DeleteFlag = 0;
	char Buffer[kMaxMessageLength];
	const char* ModName = ResolveModName(scriptObj);

	if (Buffer == NULL || ModName == NULL)
		return true;
	else if (!ExtractFormatStringArgs(0, Buffer, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, kCommandInfo_UnregisterLog.numParams, &DefaultFlag, &DeleteFlag))
		return true;

	if (!_stricmp(Buffer, "*.*")) {
		if (!DefaultFlag) { 		
			_MESSAGE("Mod '%s' unregistered all of its logs", ModName);
			LogManager::GetSingleton()->GetModLogData(ModName)->RegisteredLogs.clear();
			DeleteFlag = 0;
		}
		LogManager::GetSingleton()->SetDefaultLog(ModName, (const char*)NULL);
	}
	else	
		LogManager::GetSingleton()->UnregisterLog(ModName, Buffer);

	if (DeleteFlag) {
		DeleteFile(std::string(std::string(GET_INI_STRING("RootDirectory")) + "ConScribe Logs\\Per-Mod\\" + std::string(Buffer) + ".log").c_str());
		_MESSAGE("Deleted '%s'", Buffer);
	}

	return true;
}
static bool Cmd_MessageBoxEX_Execute(COMMAND_ARGS)
{
	*result = 0;
	char buffer[kMaxMessageLength];

	if (!ExtractFormatStringArgs(0, buffer, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, kCommandInfo_MessageBoxEX.numParams))
		return true;

	//extract the buttons
	char* b[10] = {0};
	UInt32 btnIdx = 0;

	for (char* ch = buffer; *ch && btnIdx < 10; ch++)
	{
		if (*ch == GetSeparatorChar(scriptObj))
		{
			*ch = '\0';
			b[btnIdx++] = ch + 1;
		}
	}

	if (!btnIdx)				//supply default OK button
		b[0] = "Ok";

	if (thisObj && !(thisObj->flags & 0x00004000))		//if not temporary object and not quest script
		*ShowMessageBox_pScriptRefID = thisObj->refID;
	else
		*ShowMessageBox_pScriptRefID = scriptObj->refID;

	*ShowMessageBox_button = 0xFF;	//overwrite any previously pressed button
	ShowMessageBox(buffer, ShowMessageBox_Callback, 0, b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8], b[9], 0);

	return true;
}
// setting name included in format string i.e. "sSomeSetting|newSettingValue"
bool Cmd_SetStringIniSetting_Execute(COMMAND_ARGS)
{
	char fmtString[kMaxMessageLength] = { 0 };
	*result = 0;

	if (ExtractFormatStringArgs(0, fmtString, PASS_FMTSTR_ARGS, kCommandInfo_SetStringGameSettingEX.numParams))
	{
		UInt32 pipePos = std::string(fmtString).find(GetSeparatorChar(scriptObj));
		if (pipePos != -1)
		{
			fmtString[pipePos] = 0;
			char* newValue = fmtString + pipePos + 1;

			Setting* setting = NULL;
			GameSettingCollection* gmsts = GameSettingCollection::GetSingleton();
			if (gmsts && gmsts->GetGameSetting(fmtString, &setting) && setting && setting->GetType() == Setting::kSetting_String)
			{
				setting->Set(newValue);;
				*result = 1;
			}
		}
	}

	return true;
}
Esempio n. 4
0
static bool Cmd_ConScribe_RegisterLog_Execute(COMMAND_ARGS)
{
	UInt32 DefaultFlag = 0;
	char Buffer[kMaxMessageLength];
	const char* ModName = ResolveModName(scriptObj);

	if (Buffer == NULL || ModName == NULL)
		return true;
	else if (!ExtractFormatStringArgs(0, Buffer, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, kCommandInfo_RegisterLog.numParams, &DefaultFlag))
		return true;

	LogManager::GetSingleton()->RegisterMod(ModName);

	static std::string InvalidChars = "\\/*:?\"<>;|.";

	std::string StringBuffer(Buffer);
	if (StringBuffer.find_first_of(InvalidChars) != std::string::npos) {
		_MESSAGE("Invalid log name '%s' passed in script %08x", Buffer, scriptObj->refID);
		return true;
	} else	
		LogManager::GetSingleton()->RegisterLog(ModName, Buffer);

	if (DefaultFlag)			LogManager::GetSingleton()->SetDefaultLog(ModName, Buffer);
	return true;
}
bool Cmd_sv_Construct_Execute(COMMAND_ARGS)
{
	char buffer[kMaxMessageLength] = {0};

	//not checking the return value here 'cuz we need to assign to the string regardless
	ExtractFormatStringArgs(0, buffer, PASS_FMTSTR_ARGS, kCommandInfo_sv_Construct.numParams);
	AssignToStringVar(PASS_COMMAND_ARGS, buffer);

	return true;
}
Esempio n. 6
0
static bool Cmd_ConScribe_Scribe_Execute(COMMAND_ARGS)
{
	UInt32 PrintC = 0;
	const char* ModName = ResolveModName(scriptObj);
	char Buffer[kMaxMessageLength];

	if (!ExtractFormatStringArgs(0, Buffer, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, kCommandInfo_Scribe.numParams, &PrintC))
		return true;
	else if (Buffer == NULL || ModName == NULL)
		return true;

	LogManager::GetSingleton()->ScribeToLog(Buffer, ModName, scriptObj->refID, PrintC);
	return true;
}
bool Cmd_MessageEx_Execute(COMMAND_ARGS)
{
	*result = 0;

	char buffer[kMaxMessageLength];

	if(ExtractFormatStringArgs(0, buffer, paramInfo, scriptData, opcodeOffsetPtr, scriptObj, eventList, kCommandInfo_MessageEx.numParams))
	{
		*result = 1;
		QueueUIMessage(buffer, 0, NULL, NULL, 2.0f, 0);
	}

	return true;
}
bool StringVar_Find_Execute(COMMAND_ARGS, UInt32 mode, CommandInfo* commandInfo)
{
	*result = -1;
	UInt32 strID = 0;
	UInt32 startPos = 0;
	UInt32 numChars = -1;
	UInt32 bCaseSensitive = 0;
	UInt32 numToReplace = -1;			//replace all by default
	char toFind[kMaxMessageLength] = { 0 };

	UInt32 intResult = -1;

	if (!ExtractFormatStringArgs(0, toFind, PASS_FMTSTR_ARGS, commandInfo->numParams, &strID, &startPos, &numChars, &bCaseSensitive, &numToReplace))
		return true;

	StringVar* strVar = g_StringMap.Get(strID);
	if (strVar)
	{
		if (numChars == -1)
			numChars = strVar->GetLength() - startPos;

		switch (mode)
		{
		case eMode_svFind:
			intResult = strVar->Find(toFind, startPos, numChars, bCaseSensitive ? true : false);
			break;
		case eMode_svCount:
			intResult = strVar->Count(toFind, startPos, numChars, bCaseSensitive ? true : false);
			break;
		case eMode_svReplace:
			{
				std::string str(toFind);
				UInt32 splitPoint = str.find(GetSeparatorChar(scriptObj));
				if (splitPoint != -1 && splitPoint < str.length())
				{
					toFind[splitPoint] = '\0';
					char* replaceWith = (splitPoint == str.length() - 1) ? "" : toFind + splitPoint + 1;
					intResult = strVar->Replace(toFind, replaceWith, startPos, numChars, bCaseSensitive ? true : false, numToReplace);
				}
				break;
			}
		}
	}

	if (intResult != -1)
		*result = intResult;

	return true;
}
static bool Cmd_GetStringIniSetting_Execute(COMMAND_ARGS)
{
	char settingName[kMaxMessageLength] = { 0 };
	const char* settingString = "";

	if (ExtractFormatStringArgs(0, settingName, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, SIZEOF_FMT_STRING_PARAMS))
	{
		INISettingEntry* entry = GetIniSetting(settingName);
		if (entry && (entry->data->name[0] == 'S' || entry->data->name[0] == 's'))
			settingString = entry->data->s;
	}

	AssignToStringVar(PASS_COMMAND_ARGS, settingString);
	return true;
}
bool Cmd_sv_Set_Execute(COMMAND_ARGS)
{
	char buffer[kMaxMessageLength] = { 0 };
	UInt32 stringID = 0;
	if (ExtractFormatStringArgs(0, buffer, PASS_FMTSTR_ARGS, kCommandInfo_sv_Set.numParams, &stringID))
	{
		StringVar* var = g_StringMap.Get(stringID);
		if (var)
		{
			var->Set(buffer);
		}
	}

	return true;
}
bool Cmd_SetNthFactionRankNameEX_Execute(COMMAND_ARGS)
{
	TESForm* form = NULL;
	UInt32 rank = 0;
	UInt32 gender = 0;
	char newName[kMaxMessageLength] = { 0 };

	if (ExtractFormatStringArgs(0, newName, PASS_FMTSTR_ARGS, kCommandInfo_SetNthFactionRankNameEX.numParams, &form, &rank, &gender))
	{
		TESFaction* faction = DYNAMIC_CAST(form, TESForm, TESFaction);
		if (faction)
			faction->SetNthRankName(newName, rank, gender ? true : false);
	}

	return true;
}
Esempio n. 12
0
bool Cmd_NX_SetEVFlEx_Execute(COMMAND_ARGS)
{
  std::string key;
  char buffer[kMaxMessageLength];

  *result = 0;

  if (ExtractFormatStringArgs(0, buffer, paramInfo, scriptData, opcodeOffsetPtr, scriptObj, eventList, 19))
  {
  }

  _MESSAGE("START SetEVFlEx");

  _MESSAGE("END SetEVFlEx");
  return true;
}
Esempio n. 13
0
static bool Cmd_InsertInInputText_Execute(COMMAND_ARGS)
{
	*result = 0;

	TextInputHandler* textBox = TextInputHandler::GetTextBox();
	if (textBox)
	{
		char buffer[kMaxMessageLength];
		if (!ExtractFormatStringArgs(0, buffer, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, 21))
			return true;

		textBox->InsertInText(buffer);
	}

	return true;
}
bool Cmd_sv_Insert_Execute(COMMAND_ARGS)
{
	UInt32 strID = 0;
	UInt32 insertionPos = 0;
	char subString[kMaxMessageLength] = { 0 };
	*result = 0;

	if (!ExtractFormatStringArgs(0, subString, PASS_FMTSTR_ARGS, kCommandInfo_sv_Insert.numParams, &strID, &insertionPos))
		return true;

	StringVar* lhs = g_StringMap.Get(strID);
	if (lhs)
		lhs->Insert(subString, insertionPos);

	return true;
}
Esempio n. 15
0
/* Print formatted string to Oblivion console
 * syntax: PrintToConsole fmtstring num1 num2 ...
 * shortname: printc
 *
 * Prints a formatted string to the Oblivion console, similar to how printf() works.
 * -Format notation is the same as MessageBox, so you can use %#.#f %g %e %%
 * -While this function technically accepts floats, you can use %g to print integers.  Again, how this works
 *  is probably similar to how MessageBox works (ie. same range limitations).
 * -The string can be up to 511 characters long, not including the null byte.
 * -You can pass up to 9 variables, but you don't have to pass any at all.
 *
 * Updated v0014: Takes additional format specifiers as MessageEX/MessageBoxEX
 * retains previous functionality
 */
bool Cmd_PrintToConsole_Execute(COMMAND_ARGS)
{
	*result = 0;
	char buffer[kMaxMessageLength];

	if (ExtractFormatStringArgs(0, buffer, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, kCommandInfo_PrintToConsole.numParams))
	{
		if (strlen(buffer) < 512)
		{
			*result = 1;
			Console_Print(buffer);
		}
		else
			Console_Print_Long(buffer);
	}

	return true;
}
bool Cmd_sv_Compare_Execute(COMMAND_ARGS)
{
	*result = -2;			//sentinel value if comparison fails
	UInt32 stringID = 0;
	char buffer[kMaxMessageLength] = { 0 };
	UInt32 bCaseSensitive = 0;

	if (!ExtractFormatStringArgs(0, buffer, PASS_FMTSTR_ARGS, kCommandInfo_sv_Compare.numParams, &stringID, &bCaseSensitive))
		return true;

	StringVar* lhs = g_StringMap.Get(stringID);
	if (!lhs)
		return true;

	*result = lhs->Compare(buffer, bCaseSensitive ? true : false);

	return true;
}
bool Cmd_SetIconPathEX_Execute(COMMAND_ARGS)
{
	TESForm* form = NULL;
	char newPath[kMaxMessageLength] = { 0 };

	if (ExtractFormatStringArgs(0, newPath, PASS_FMTSTR_ARGS, kCommandInfo_SetIconPathEX.numParams, &form))
	{
		if (!form)
			if (thisObj)
				form = thisObj->baseForm;

		TESIcon* icon = DYNAMIC_CAST(form, TESForm, TESIcon);
		if (icon)
			icon->SetPath(newPath);
	}

	return true;
}
Esempio n. 18
0
File: main.cpp Progetto: nh2/obse
bool Cmd_TestExtractFormatString_Execute(COMMAND_ARGS)
{
	char str[0x200] = { 0 };
	int i = 0;
	TESForm* form = NULL;
	*result = 0.0;

	if (ExtractFormatStringArgs(0, str, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, 
		SIZEOF_FMT_STRING_PARAMS + 2, &i, &form)) {
			Console_Print("TestExtractFormatString >> str: %s int: %d form: %08X", str, i, form ? form->refID : 0);
			*result = 1.0;
	}
	else {
		Console_Print("TestExtractFormatString >> couldn't extract arguments.");
	}

	return true;
}
bool Cmd_SetNthEffectItemScriptNameEX_Execute(COMMAND_ARGS)
{
	TESForm* form = NULL;
	UInt32 whichEffect = 0;
	char newName[kMaxMessageLength] = { 0 };

	if (ExtractFormatStringArgs(0, newName, PASS_FMTSTR_ARGS, kCommandInfo_SetNthEffectItemScriptNameEX.numParams, &form, &whichEffect))
	{
		EffectItemList* effectList = GetEffectList(form);
		if (effectList)
		{
			EffectItem* effectItem = effectList->ItemAt(whichEffect);
			if (effectItem && effectItem->scriptEffectInfo)
				effectItem->scriptEffectInfo->effectName.Set(newName);
		}
	}

	return true;
}
Esempio n. 20
0
static bool Cmd_ClickMenuButton_Execute(COMMAND_ARGS)
{
	UInt32 menuType;
	char name[kMaxMessageLength] = { 0 };

	if (ExtractFormatStringArgs(0, name, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, kCommandInfo_GetMenuFloatValue.numParams, &menuType))
	{
		Menu* menu = GetMenuByType(menuType);
		if (menu && name)
		{
			UInt32 buttonID = 0;
			Tile* parentTile = NULL;

			if (name[0] == '#')		// component specified by ID rather than name
			{
				buttonID = atoi(name + 1);
				parentTile = menu->tile->GetChildByIDTrait(buttonID);
			}
			else		// roundabout way of getting a button tile - look up the <id> trait then take the parent tile
			{
				UInt32 nameLen = strlen(name);
				name[nameLen] = '\\';
				name[nameLen+1] = 'i';
				name[nameLen+2] = 'd';
				name[nameLen+3] = '\0';

				Tile::Value* val = menu->tile->GetValueByName(name);
				if (val)
				{
					buttonID = val->num;
					parentTile = val->parentTile;
				}
			}

			//DEBUG_PRINT("Parent Tile: %08x, ID: %d", parentTile, buttonID);
			if (parentTile)
				menu->HandleClick(buttonID, parentTile);
		}
	}

	return true;
}
bool Cmd_SetModelPathEX_Execute(COMMAND_ARGS)
{
	TESForm* form = NULL;
	char newPath[kMaxMessageLength] = { 0 };

	if (ExtractFormatStringArgs(0, newPath, PASS_FMTSTR_ARGS, kCommandInfo_SetModelPathEX.numParams, &form))
	{
		if (form)
			form = form->TryGetREFRParent();
		if (!form)
			if (thisObj)
				form = thisObj->baseForm;

		TESModel* model = DYNAMIC_CAST(form, TESForm, TESModel);
		if (model)
			model->SetPath(newPath);
	}

	return true;
}
bool Cmd_PrintToConsole_Execute(COMMAND_ARGS)
{
	*result = 0;
	char buffer[kMaxMessageLength];

	if (ExtractFormatStringArgs(0, buffer, paramInfo, scriptData, opcodeOffsetPtr, scriptObj, eventList, 21))
	{
		if (strlen(buffer) < 512)
		{
			*result = 1;
			Console_Print("%s", buffer);
#if defined(_DEBUG)
			_MESSAGE("%s", buffer);
#endif
		}
		else
			Console_Print("PrintToConsole >> Max length exceeded (512 chars)");
	}

	return true;
}
Esempio n. 23
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;
}
Esempio n. 24
0
static bool Cmd_OpenTextInput_Execute(COMMAND_ARGS)
{
	*result = 0;
	char buffer[kMaxMessageLength];
	UInt32 maxLength = kMaxMessageLength;
	UInt32 menuType = kInputMenuType_Message;

	if (TextInputHandler::GetTextBox())
		return true;					//already in use

	if (!ExtractFormatStringArgs(0, buffer, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, 
								 kCommandInfo_OpenTextInput.numParams, &menuType, &maxLength))
		return true;

	if (maxLength > kMaxMessageLength)
		maxLength = kMaxMessageLength;

	TextInputMenu * menu = NULL;
	switch (menuType)
	{
	case kInputMenuType_Message:
		menu = new TextInputMessageBox(buffer, maxLength, scriptObj, thisObj);
		break;
	case kInputMenuType_Book:
		menu = new TextInputJournal(buffer, maxLength, false);
		break;
	case kInputMenuType_Scroll:
		menu = new TextInputJournal(buffer, maxLength, true);
		break;
	default:			//invalid type
		return true;
	}

	if (TextInputHandler::Create(menu))
		*result = 1;
	else				// wtf?
		delete menu;

	return true;
}
static bool Cmd_MessageEX_Execute(COMMAND_ARGS)
{
	*result = 0;
	char buffer[kMaxMessageLength];
	// updated 0021: kyoma's MenuQue plugin causes UI messages to take duration into account
	// so we accept a duration now
	float duration = 2.0;
	if (ExtractFormatStringArgs(0, buffer, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, kCommandInfo_MessageEX.numParams, &duration))
	{
		*result = 1;
		if (*MessageIconPath || *MessageSoundID)
		{
			QueueUIMessage_2(buffer, duration, MessageIconPath, MessageSoundID);
			*MessageIconPath = 0;
			*MessageSoundID = 0;
		}
		else
			QueueUIMessage(buffer, 0, 1, duration);
	}

	return true;
}
static bool Cmd_SetStringIniSetting_Execute(COMMAND_ARGS)
{
	char stringArg[kMaxMessageLength] = { 0 };

	if (ExtractFormatStringArgs(0, stringArg, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, SIZEOF_FMT_STRING_PARAMS))
	{
		char* strtokContext = NULL;
		char* settingName = strtok_s(stringArg, GetSeparatorChars(scriptObj), &strtokContext);
		char* settingVal = strtok_s(NULL, GetSeparatorChars(scriptObj), &strtokContext);
		if (settingName && settingVal)
		{
			INISettingEntry* entry = GetIniSetting(settingName);
			if (entry && (entry->data->name[0] == 'S' || entry->data->name[0] == 's'))
			{
				UInt32 valLen = strlen(settingVal) + 1;
				entry->data->s = new char[valLen];				// this leaks. INI string alloc'd where?
				strcpy_s(entry->data->s, valLen, settingVal);
			}
		}
	}

	return true;
}
bool BipedPathFunc_Execute(COMMAND_ARGS, UInt32 mode, bool bIcon)
{
	UInt32 whichPath = 0;
	TESForm* form = NULL;
	const char* pathStr = "";
	char newPath[kMaxMessageLength] = { 0 };

	bool bExtracted = false;
	if (mode == eMode_Set)
		bExtracted = ExtractFormatStringArgs(0, newPath, PASS_FMTSTR_ARGS, kCommandInfo_SetBipedModelPathEX.numParams, &whichPath, &form);
	else
		bExtracted = ExtractArgsEx(EXTRACT_ARGS_EX, &whichPath, &form);

	if (bExtracted)
	{
		if (!form)
			if (thisObj)
				form = thisObj->baseForm;

		TESBipedModelForm* bipedModel = DYNAMIC_CAST(form, TESForm, TESBipedModelForm);
		if (bipedModel)
		{
			bool bFemale = (whichPath % 2) ? true : false;
			whichPath = bIcon ? bipedModel->ePath_Icon : whichPath / 2;

			if (mode == eMode_Set)
				bipedModel->SetPath(newPath, whichPath, bFemale);
			else
				pathStr = bipedModel->GetPath(whichPath, bFemale);
		}
	}

	if (mode == eMode_Get)
		AssignToStringVarLong(PASS_COMMAND_ARGS, pathStr);

	return true;
}
// setting name included in format string i.e. "sSomeSetting|newSettingValue"
bool Cmd_SetStringGameSettingEX_Execute(COMMAND_ARGS)
{
	char fmtString[kMaxMessageLength] = { 0 };
	*result = 0;

	if (ExtractFormatStringArgs(0, fmtString, PASS_FMTSTR_ARGS, kCommandInfo_SetStringGameSettingEX.numParams))
	{
		UInt32 pipePos = std::string(fmtString).find(GetSeparatorChar(scriptObj));
		if (pipePos != -1)
		{
			fmtString[pipePos] = 0;
			char* newValue = fmtString + pipePos + 1;

			Setting* setting = NULL;
			if (GetIniSetting(fmtString, &setting))
			{
				setting->Set(newValue);;
				*result = 1;
			}
		}
	}

	return true;
}
Esempio n. 29
0
static bool Cmd_ConScribe_ReadFromLog_Execute(COMMAND_ARGS)
{
	*result = 0;
	const char * ModName = ResolveModName(scriptObj);
	char Buffer[kMaxMessageLength];

	if (!ExtractFormatStringArgs(0, Buffer, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, kCommandInfo_ReadFromLog.numParams))
		return true;
	else if (Buffer == NULL || ModName == NULL)
		return true;

	std::string LogPath;
	std::vector<OBSEElement> LogContents;

	if (!_stricmp(Buffer, "*.*") && LogManager::GetSingleton()->GetDefaultLog(ModName))
		LogPath = std::string(GET_INI_STRING("RootDirectory")) + "ConScribe Logs\\Per-Mod\\" + std::string(LogManager::GetSingleton()->GetDefaultLog(ModName)) + ".log";
	else if (LogManager::GetSingleton()->IsLogRegistered(ModName, Buffer))
		LogPath = std::string(GET_INI_STRING("RootDirectory")) + "ConScribe Logs\\Per-Mod\\" + std::string(Buffer) + ".log";
	else		return true;
	LogContents.push_back(LogPath.c_str());

	ConScribeLog* TempLog = new ConScribeLog(LogPath.c_str(), ConScribeLog::e_In);
	std::vector<std::string> STLVector(TempLog->ReadAllLines());

	OBSEArray* ResultArray = ArrayFromStdVector(LogContents, scriptObj);

	for (std::vector<std::string>::const_iterator Itr = STLVector.begin(); Itr != STLVector.end(); Itr++) {
		if (Itr == STLVector.end() - 1 && Itr->begin() == Itr->end())		continue;		// skip empty last lines
		g_arrayIntfc->AppendElement(ResultArray, Itr->c_str());
	}

	if (!ResultArray)													_MESSAGE("Couldn't create array. Passed in script %08x", scriptObj->refID);
	else if (!g_arrayIntfc->AssignCommandResult(ResultArray, result))	_MESSAGE("Couldn't assign result array. Passed in script %08x", scriptObj->refID);

	return true;
}
Esempio n. 30
0
static bool GetSetMenuValue_Execute(COMMAND_ARGS, UInt32 mode)
{
	const char* separatorChar = GetSeparatorChars(scriptObj);
	char stringArg[kMaxMessageLength] = { 0 };
	UInt32 menuType = 0;
	float newFloatVal = 0;
	char* newStringVal = NULL;
	
	char* componentPath = stringArg;

	bool bExtracted = false;
	switch (mode)
	{
	case kGetFloat:
	case kGetString:
	case kExists:
		bExtracted = ExtractFormatStringArgs(0, stringArg, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, kCommandInfo_GetMenuFloatValue.numParams, &menuType);
		break;
	case kSetFloat:
		bExtracted = ExtractFormatStringArgs(0, stringArg, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, kCommandInfo_SetMenuFloatValue.numParams, &menuType, &newFloatVal);
		break;
	case kSetString:
		{
			bExtracted = ExtractFormatStringArgs(0, stringArg, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, kCommandInfo_GetMenuFloatValue.numParams, &menuType);
			// extract new value from format string
			char* context = NULL;
			componentPath = strtok_s(stringArg, separatorChar, &context);
			newStringVal = strtok_s(NULL, separatorChar, &context);
			bExtracted = (bExtracted && componentPath && newStringVal);
		}
		break;
	}

	char* strToAssign = "";

	if (bExtracted)
	{
		Menu* menu = GetMenuByType(menuType);
		if (menu && menu->tile)
		{
			Tile::Value* val = menu->tile->GetValueByName(componentPath);
			if (val)
			{
#if _DEBUG && 0
				val->DumpExpressionList();
#endif
				switch (mode)
				{
				case kExists:
					*result = 1;
					break;
				case kGetFloat:
					if (val->IsNum())
						*result = val->num;
					break;
				case kSetFloat:
					val->bIsNum = 1;
					val->parentTile->UpdateFloat(val->id, newFloatVal);
					break;
				case kGetString:
					if (val->IsString())
						strToAssign = val->str.m_data;
					break;
				case kSetString:
					val->bIsNum = 0;
					val->parentTile->UpdateString(val->id, newStringVal);
					val->parentTile->SetStringValue(val->id, newStringVal);
					val->parentTile->UpdateField(val->id, 0, newStringVal);

					break;
				}
			}
		}
	}

	if (mode == kGetString)		// need to assign even if errors occur during arg extraction/value retrieval
		AssignToStringVar(PASS_COMMAND_ARGS, strToAssign);

	return true;
}