Make EventCommand::Code and MoveCommand::Code enum class
MODIFY
generator/templates/rpg_header.tmpl
generator/templates/rpg_header.tmpl
@@ -34,23 +34,17 @@ namespace rpg {
{% endif %}
{%- if struct_name in enums %}
{%- for name, enum in enums[struct_name].items() %}
- {%- if name == "Code" %}
- struct {{ name }} {
- enum Index {
+ enum {% if name == "Code" -%} class {% endif -%} {{ name }} {
{%- for field in enum %}
- {{ field.0 }} = {{ field.1 }}{%- if not loop.last %},{% endif %}
- {%- endfor %}
- };
- };
+ {%- if name != "Code" %}
+ {{ name }}_{{ field.0 }}
{%- else %}
- enum {{ name }} {
- {%- for field in enum %}
- {{ name }}_{{ field.0 }} = {{ field.1 }}{%- if not loop.last %},{% endif %}
+ {{ field.0 }}
+ {%- endif %} = {{ field.1 }}{%- if not loop.last %},{% endif %}
{%- endfor %}
};
- {%- endif %}
{%- if enum is monotonic_from_0 %}
- static constexpr auto k{{ name }}Tags = lcf::makeEnumTags<{{name}}{%- if name == "Code" %}::Index{%- endif %}>(
+ static constexpr auto k{{ name }}Tags = lcf::makeEnumTags<{{name}}>(
{%- for field in enum %}
"{{ field.0 }}"{%- if not loop.last %},{% endif %}
{%- endfor %}

MODIFY
src/generated/lcf/rpg/eventcommand.h
src/generated/lcf/rpg/eventcommand.h
Binary files a/src/generated/lcf/rpg/eventcommand.h and b/src/generated/lcf/rpg/eventcommand.h differ

MODIFY
src/generated/lcf/rpg/movecommand.h
src/generated/lcf/rpg/movecommand.h
Binary files a/src/generated/lcf/rpg/movecommand.h and b/src/generated/lcf/rpg/movecommand.h differ

MODIFY
src/lmu_movecommand.cpp
src/lmu_movecommand.cpp
@@ -36,7 +36,8 @@ struct RawStruct<std::vector<rpg::MoveCommand> > {
*/
void RawStruct<rpg::MoveCommand>::ReadLcf(rpg::MoveCommand& ref, LcfReader& stream, uint32_t /* length */) {
ref.command_id = stream.ReadInt();
- switch (ref.command_id) {
+ const auto cmd = static_cast<rpg::MoveCommand::Code>(ref.command_id);
+ switch (cmd) {
case rpg::MoveCommand::Code::switch_on:
stream.Read(ref.parameter_a);
break;
@@ -58,7 +59,8 @@ void RawStruct<rpg::MoveCommand>::ReadLcf(rpg::MoveCommand& ref, LcfReader& stre
void RawStruct<rpg::MoveCommand>::WriteLcf(const rpg::MoveCommand& ref, LcfWriter& stream) {
stream.WriteInt(ref.command_id);
- switch (ref.command_id) {
+ const auto cmd = static_cast<rpg::MoveCommand::Code>(ref.command_id);
+ switch (cmd) {
case rpg::MoveCommand::Code::switch_on:
stream.Write(ref.parameter_a);
break;
@@ -83,7 +85,8 @@ void RawStruct<rpg::MoveCommand>::WriteLcf(const rpg::MoveCommand& ref, LcfWrite
int RawStruct<rpg::MoveCommand>::LcfSize(const rpg::MoveCommand& ref, LcfWriter& stream) {
int result = 0;
result += LcfReader::IntSize(ref.command_id);
- switch (ref.command_id) {
+ const auto cmd = static_cast<rpg::MoveCommand::Code>(ref.command_id);
+ switch (cmd) {
case rpg::MoveCommand::Code::switch_on:
result += LcfReader::IntSize(ref.parameter_a);
break;
@@ -109,7 +112,8 @@ int RawStruct<rpg::MoveCommand>::LcfSize(const rpg::MoveCommand& ref, LcfWriter&
void RawStruct<rpg::MoveCommand>::WriteXml(const rpg::MoveCommand& ref, XmlWriter& stream) {
stream.BeginElement("MoveCommand");
stream.WriteNode<int32_t>("command_id", ref.command_id);
- switch (ref.command_id) {
+ const auto cmd = static_cast<rpg::MoveCommand::Code>(ref.command_id);
+ switch (cmd) {
case rpg::MoveCommand::Code::switch_on:
stream.WriteNode<int32_t>("parameter_a", ref.parameter_a);
break;

Make EventCommand::Code and MoveCommand::Code enum class