MCPcopy Create free account
hub / github.com/crossuo/crossuo / Save

Method Save

src/Macro.cpp:200–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200void CMacro::Save(Wisp::CBinaryFileWriter &writer)
201{
202 short size = 12;
203 short count = 0;
204 for (auto obj = (CMacroObject *)m_Items; obj != nullptr; obj = (CMacroObject *)obj->m_Next)
205 {
206 size += 5;
207 count++;
208 if (obj->HaveString()) //with string
209 {
210 auto str = ((CMacroObjectString *)obj)->m_String;
211 size += (short)str.length() + 3;
212 }
213 }
214
215 writer.WriteUInt16LE(size);
216 auto key = Key;
217 if (Alt)
218 {
219 key += MODKEY_ALT;
220 }
221
222 if (Ctrl)
223 {
224 key += MODKEY_CTRL;
225 }
226
227 if (Shift)
228 {
229 key += MODKEY_SHIFT;
230 }
231
232 writer.WriteInt32LE(key);
233 writer.WriteUInt16LE(count);
234 for (auto obj = (CMacroObject *)m_Items; obj != nullptr; obj = (CMacroObject *)obj->m_Next)
235 {
236 uint8_t type = 0;
237 if (obj->HaveString())
238 {
239 type = 2;
240 }
241
242 writer.WriteUInt8(type);
243 writer.WriteUInt16LE(obj->Code);
244 writer.WriteUInt16LE(obj->SubCode);
245 if (type == 2) //with string
246 {
247 auto str = ((CMacroObjectString *)obj)->m_String;
248 int len = (int)str.length();
249 writer.WriteInt16LE(len + 1);
250 writer.WriteString(str);
251 }
252 writer.WriteBuffer();
253 }
254 writer.WriteUInt32LE(0); //EOM
255 writer.WriteBuffer();
256}
257

Callers 2

UninstallMethod · 0.45
SaveLocalConfigMethod · 0.45

Calls 9

lengthMethod · 0.80
WriteUInt16LEMethod · 0.80
WriteInt32LEMethod · 0.80
WriteUInt8Method · 0.80
WriteInt16LEMethod · 0.80
WriteBufferMethod · 0.80
WriteUInt32LEMethod · 0.80
HaveStringMethod · 0.45
WriteStringMethod · 0.45

Tested by

no test coverage detected