StringIterLoop::StringIterLoop(const ForEachContext* context) { StringVar* srcVar = g_StringMap.Get(context->sourceID); StringVar* iterVar = g_StringMap.Get(context->iteratorID); if (srcVar && iterVar) { m_src = srcVar->String(); m_curIndex = 0; m_iterID = context->iteratorID; if (m_src.length()) iterVar->Set(m_src.substr(0, 1).c_str()); } }
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 StringIterLoop::Update(COMMAND_ARGS) { StringVar* iterVar = g_StringMap.Get(m_iterID); if (iterVar) { m_curIndex++; if (m_curIndex < m_src.length()) { iterVar->Set(m_src.substr(m_curIndex, 1).c_str()); return true; } } return false; }
bool AssignToStringVarLong(COMMAND_ARGS, const char* newValue) { double strID = 0; UInt8 modIndex = 0; bool bTemp = ExpressionEvaluator::Active(); StringVar* strVar = NULL; UInt32 len = (newValue) ? strlen(newValue) : 0; if (!newValue || len >= kMaxMessageLength) //if null pointer or too long, assign an empty string newValue = ""; if (ExtractSetStatementVar(scriptObj, eventList, scriptData, &strID, &modIndex)) { strVar = g_StringMap.Get(strID); bTemp = false; } else if (!bTemp) { _WARNING("Function must be used within a Set statement or NVSE expression"); return false; } if (!modIndex) modIndex = scriptObj->GetModIndex(); if (strVar) { strVar->Set(newValue); g_StringMap.MarkTemporary(strID, false); } else strID = g_StringMap.Add(modIndex, newValue, bTemp); *result = strID; #if _DEBUG // console feedback disabled in release by request (annoying when called from batch scripts) if (IsConsoleMode() && !bTemp) { if (len < 480) Console_Print("Assigned string >> \"%s\"", newValue); else Console_Print("Assigned string (too long to print)"); } #endif return true; }
void SetString(UInt32 stringID, const char* newVal) { StringVar* var = g_StringMap.Get(stringID); if (var) var->Set(newVal); }