Loading system/gd/packet/parser/struct_def.cc +5 −5 Original line number Diff line number Diff line Loading @@ -20,17 +20,17 @@ #include "util.h" StructDef::StructDef(std::string name, FieldList fields) : StructDef(name, fields, nullptr) {} StructDef::StructDef(std::string name, FieldList fields, StructDef* parent) : ParentDef(name, fields, parent) {} StructDef::StructDef(std::string name, FieldList fields, StructDef* parent) : ParentDef(name, fields, parent), total_size_(GetSize(true)) {} PacketField* StructDef::GetNewField(const std::string& name, ParseLocation loc) const { Size total_size = GetSize(false); if (fields_.HasBody()) { if (fields_.HasBody() || total_size_.has_dynamic()) { ERROR(new StructField(name, name_, -1, loc)) << "Variable size structs are not supported"; fprintf(stderr, "total_size of %s(%s) = %s\n", name_.c_str(), name.c_str(), total_size.ToString().c_str()); fprintf(stderr, "total_size_ of %s(%s) = %s\n", name_.c_str(), name.c_str(), total_size_.ToString().c_str()); abort(); return new StructField(name, name_, -1, loc); } else { return new StructField(name, name_, total_size.bits(), loc); return new StructField(name, name_, total_size_.bits(), loc); } } Loading system/gd/packet/parser/struct_def.h +3 −0 Original line number Diff line number Diff line Loading @@ -39,4 +39,7 @@ class StructDef : public ParentDef { void GenDefinition(std::ostream& s) const; void GenConstructor(std::ostream& s) const; private: Size total_size_; }; Loading
system/gd/packet/parser/struct_def.cc +5 −5 Original line number Diff line number Diff line Loading @@ -20,17 +20,17 @@ #include "util.h" StructDef::StructDef(std::string name, FieldList fields) : StructDef(name, fields, nullptr) {} StructDef::StructDef(std::string name, FieldList fields, StructDef* parent) : ParentDef(name, fields, parent) {} StructDef::StructDef(std::string name, FieldList fields, StructDef* parent) : ParentDef(name, fields, parent), total_size_(GetSize(true)) {} PacketField* StructDef::GetNewField(const std::string& name, ParseLocation loc) const { Size total_size = GetSize(false); if (fields_.HasBody()) { if (fields_.HasBody() || total_size_.has_dynamic()) { ERROR(new StructField(name, name_, -1, loc)) << "Variable size structs are not supported"; fprintf(stderr, "total_size of %s(%s) = %s\n", name_.c_str(), name.c_str(), total_size.ToString().c_str()); fprintf(stderr, "total_size_ of %s(%s) = %s\n", name_.c_str(), name.c_str(), total_size_.ToString().c_str()); abort(); return new StructField(name, name_, -1, loc); } else { return new StructField(name, name_, total_size.bits(), loc); return new StructField(name, name_, total_size_.bits(), loc); } } Loading
system/gd/packet/parser/struct_def.h +3 −0 Original line number Diff line number Diff line Loading @@ -39,4 +39,7 @@ class StructDef : public ParentDef { void GenDefinition(std::ostream& s) const; void GenConstructor(std::ostream& s) const; private: Size total_size_; };