MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / ReadFromRAM

Method ReadFromRAM

Source/Scripting/scriptparams.cpp:502–523  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

500}
501
502void ScriptParam::ReadFromRAM(const std::vector<char> &data, int &index) {
503 memread(&type_, sizeof(int), 1, data, index);
504 switch (type_) {
505 case INT:
506 memread(&i_val_, sizeof(int), 1, data, index);
507 break;
508 case FLOAT:
509 memread(&f_val_, sizeof(float), 1, data, index);
510 break;
511 case STRING:
512 case JSON:
513 int str_len;
514 memread(&str_len, sizeof(int), 1, data, index);
515 str_val_.resize(str_len);
516 memread(&str_val_[0], sizeof(char), str_len, data, index);
517 break;
518 case OTHER:
519 LOGW << "Got unhandled type OTHER" << std::endl;
520 break;
521 }
522 editor_.ReadFromRAM(data, index);
523}
524
525void ScriptParam::WriteToRAM(std::vector<char> &data) const {
526 int int_type = type_;

Callers 1

Calls 2

memreadFunction · 0.85
resizeMethod · 0.45

Tested by

no test coverage detected