MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / PerformAction

Method PerformAction

plugins/base/macro-action-random.cpp:47–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47bool MacroActionRandom::PerformAction()
48{
49 if (_macros.size() == 0) {
50 SetTempVarValue("macro", "");
51 return true;
52 }
53
54 auto macros = getNextMacros(_macros, lastRandomMacro, _allowRepeat);
55 if (macros.size() == 0) {
56 SetTempVarValue("macro", "");
57 return true;
58 }
59
60 if (macros.size() == 1) {
61 lastRandomMacro = macros[0];
62 SetTempVarValue("macro", GetMacroName(macros[0].get()));
63 return RunMacroActions(macros[0].get());
64 }
65
66 srand((unsigned int)time(0));
67 size_t idx = std::rand() % (macros.size());
68 lastRandomMacro = macros[idx];
69
70 SetTempVarValue("macro", GetMacroName(macros[idx].get()));
71
72 return RunMacroActions(macros[idx].get());
73}
74
75void MacroActionRandom::LogAction() const
76{

Callers

nothing calls this directly

Calls 6

SetTempVarValueFunction · 0.85
getNextMacrosFunction · 0.85
GetMacroNameFunction · 0.85
RunMacroActionsFunction · 0.85
sizeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected