Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime flags: New bit-fields for storing various interpreter states #491

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions generator/csv/enums_easyrpg.csv
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,20 @@ SavePicture,EasyRpgType,default,0
SavePicture,EasyRpgType,window,1
Skill,HpType,cost,0
Skill,HpType,percent,1
SaveEventExecState,RuntimeFlags,conf_override_active,0x01
SaveEventExecState,RuntimeFlags,patch_destiny_on,0x10
SaveEventExecState,RuntimeFlags,patch_destiny_off,0x20
SaveEventExecState,RuntimeFlags,patch_dynrpg_on,0x40
SaveEventExecState,RuntimeFlags,patch_dynrpg_off,0x80
SaveEventExecState,RuntimeFlags,patch_maniac_on,0x100
SaveEventExecState,RuntimeFlags,patch_maniac_of,0x200
SaveEventExecState,RuntimeFlags,patch_common_this_event_on,0x400
SaveEventExecState,RuntimeFlags,patch_common_this_event_off,0x800
SaveEventExecState,RuntimeFlags,patch_unlock_pics_on,0x1000
SaveEventExecState,RuntimeFlags,patch_unlock_pics_off,0x2000
SaveEventExecState,RuntimeFlags,patch_keypatch_on,0x4000
SaveEventExecState,RuntimeFlags,patch_keypatch_off,0x8000
SaveEventExecState,RuntimeFlags,patch_rpg2k3_cmds_on,0x10000
SaveEventExecState,RuntimeFlags,patch_rpg2k3_cmds_off,0x20000
SaveEventExecState,RuntimeFlags,use_rpg2k_battle_system_on,0x40000
SaveEventExecState,RuntimeFlags,use_rpg2k_battle_system_off,0x80000
4 changes: 4 additions & 0 deletions generator/csv/fields_easyrpg.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ SaveEventExecFrame,maniac_event_id,f,Int32,0x0F,0,0,0,Event ID
SaveEventExecFrame,maniac_event_page_id,f,Int32,0x10,0,0,0,Page ID when it is a map event
SaveEventExecFrame,maniac_loop_info_size,f,Int32,0x11,0,0,0,Amount of loop info groups
SaveEventExecFrame,maniac_loop_info,f,Vector<Int32>,0x12,,0,0,"One group of (Current loop count, end loop value) for each identation"
SaveEventExecFrame,easyrpg_runtime_flags,f,UInt32,0xC8,0,0,0,
SaveEventExecState,easyrpg_runtime_flags,f,UInt32,0xC8,0,0,0,
SaveEventExecState,easyrpg_active,f,Boolean,0xC9,False,0,0,When true state of an event is preserved in easyrpg_string and easyrpg_parameters
SaveEventExecState,easyrpg_string,f,DBString,0xCA,,0,0,Preserved string data of an event
SaveEventExecState,easyrpg_parameters,f,Vector<Int32>,0xCB,,0,0,Preserved int parameter of an event
Expand All @@ -30,7 +32,9 @@ SaveEasyRpgText,font_size,f,Int32,0x05,12,0,0,Font size
SaveEasyRpgText,letter_spacing,f,Int32,0x06,0,0,0,Additional spacing between letters
SaveEasyRpgText,line_spacing,f,Int32,0x07,4,0,0,Additional spacing between lines
SaveEasyRpgText,flags,f,SaveEasyRpgText_Flags,0x08,3,0,0,Various text settings
SaveMapEventBase,easyrpg_runtime_flags,f,UInt32,0xC8,0,0,0,
SaveMapEventBase,easyrpg_move_failure_count,f,Int32,0xC9,0,0,0,Tracks how often the current move operation in a move route failed
SaveMapEventBase,easyrpg_clone_map_id,f,UInt32,0xCA,0,0,0,The original map id of a cloned event
SavePartyLocation,maniac_horizontal_pan_speed,f,Double,0x8D,0,0,0,horizontal speed in the scrolls of the screen
SavePartyLocation,maniac_vertical_pan_speed,f,Double,0x8E,0,0,0,vertical speed in the scrolls of the screen
SaveSystem,maniac_strings,f,Vector<DBString>,0x24,,0,0,rpg::Strings
Expand Down
6 changes: 5 additions & 1 deletion generator/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,14 @@ def type_is_array_of_struct(ty):
def is_monotonic_from_0(enum):
expected = 0
for (val, idx) in enum:
if int(idx) != expected:
if int(idx, 0) != expected:
return False
expected += 1
return True

def is_scoped_enum(enum_name):
return enum_name == "Code" or enum_name == "RuntimeFlags"

def openToRender(path):
subdir = os.path.dirname(path)
if not os.path.exists(subdir):
Expand Down Expand Up @@ -508,6 +511,7 @@ def main(argv):
env.filters["flag_size"] = flag_size
env.filters["flag_set"] = flag_set
env.tests['monotonic_from_0'] = is_monotonic_from_0
env.tests['scoped_enum'] = is_scoped_enum
env.tests['is_db_string'] = type_is_db_string
env.tests['is_array'] = type_is_array
env.tests['is_array_of_struct'] = type_is_array_of_struct
Expand Down
6 changes: 3 additions & 3 deletions generator/templates/rpg_header.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ namespace rpg {
{% endif %}
{%- if struct_name in enums %}
{%- for name, enum in enums[struct_name].items() %}
enum {% if name == "Code" -%} class {% endif -%} {{ name }} {
enum {% if name is scoped_enum -%} class {% endif -%} {{ name }} {
{%- for field in enum %}
{%- if name != "Code" %}
{%- if name is not scoped_enum %}
{{ name }}_{{ field.0 }}
{%- else %}
{{ field.0 }}
Expand All @@ -55,7 +55,7 @@ namespace rpg {
{%- else %}
static constexpr auto k{{ name }}Tags = lcf::EnumTags{
{%- for field in enum %}
{%- if name != "Code" %}
{%- if name is not scoped_enum %}
{{ name }}_{{ field.0 }}, "{{ field.0 }}"{%- if not loop.last %},{% endif %}
{%- else %}
{{ name }}::{{ field.0 }}, "{{ field.0 }}"{%- if not loop.last %},{% endif %}
Expand Down
24 changes: 22 additions & 2 deletions src/generated/lcf/lsd/chunks.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,12 @@ namespace LSD_Reader {
flash_current_level = 0x54,
/** int */
flash_time_left = 0x55,
/** */
easyrpg_runtime_flags = 0xC8,
/** Tracks how often the current move operation in a move route failed */
easyrpg_move_failure_count = 0xC9,
/** The original map id of a cloned event */
easyrpg_clone_map_id = 0xCA,
/** */
boarding = 0x65,
/** */
Expand Down Expand Up @@ -528,8 +532,12 @@ namespace LSD_Reader {
flash_current_level = 0x54,
/** int */
flash_time_left = 0x55,
/** */
easyrpg_runtime_flags = 0xC8,
/** Tracks how often the current move operation in a move route failed */
easyrpg_move_failure_count = 0xC9,
/** The original map id of a cloned event */
easyrpg_clone_map_id = 0xCA,
/** Which vehicle */
vehicle = 0x65,
/** From 0 to 255 - In flying vehicles; remaining distance to ascend */
Expand Down Expand Up @@ -693,7 +701,9 @@ namespace LSD_Reader {
/** Amount of loop info groups */
maniac_loop_info_size = 0x11,
/** One group of (Current loop count, end loop value) for each identation */
maniac_loop_info = 0x12
maniac_loop_info = 0x12,
/** */
easyrpg_runtime_flags = 0xC8
};
};
struct ChunkSaveEventExecState {
Expand Down Expand Up @@ -742,6 +752,8 @@ namespace LSD_Reader {
keyinput_timed = 0x29,
/** Used for a wait command WaitForKeyInput rm2k3 feature to wait for decision key press. */
wait_key_enter = 0x2A,
/** */
easyrpg_runtime_flags = 0xC8,
/** When true state of an event is preserved in easyrpg_string and easyrpg_parameters */
easyrpg_active = 0xC9,
/** Preserved string data of an event */
Expand Down Expand Up @@ -830,8 +842,12 @@ namespace LSD_Reader {
flash_current_level = 0x54,
/** int */
flash_time_left = 0x55,
/** */
easyrpg_runtime_flags = 0xC8,
/** Tracks how often the current move operation in a move route failed */
easyrpg_move_failure_count = 0xC9
easyrpg_move_failure_count = 0xC9,
/** The original map id of a cloned event */
easyrpg_clone_map_id = 0xCA
};
};
struct ChunkSaveMapEvent {
Expand Down Expand Up @@ -914,8 +930,12 @@ namespace LSD_Reader {
flash_current_level = 0x54,
/** int */
flash_time_left = 0x55,
/** */
easyrpg_runtime_flags = 0xC8,
/** Tracks how often the current move operation in a move route failed */
easyrpg_move_failure_count = 0xC9,
/** The original map id of a cloned event */
easyrpg_clone_map_id = 0xCA,
/** If true; this event is waiting for foreground execution. */
waiting_execution = 0x65,
/** Index of custom move route */
Expand Down
4 changes: 3 additions & 1 deletion src/generated/lcf/rpg/saveeventexecframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace rpg {
int32_t maniac_event_page_id = 0;
int32_t maniac_loop_info_size = 0;
std::vector<int32_t> maniac_loop_info;
uint32_t easyrpg_runtime_flags = 0;
};

inline bool operator==(const SaveEventExecFrame& l, const SaveEventExecFrame& r) {
Expand All @@ -50,7 +51,8 @@ namespace rpg {
&& l.maniac_event_id == r.maniac_event_id
&& l.maniac_event_page_id == r.maniac_event_page_id
&& l.maniac_loop_info_size == r.maniac_loop_info_size
&& l.maniac_loop_info == r.maniac_loop_info;
&& l.maniac_loop_info == r.maniac_loop_info
&& l.easyrpg_runtime_flags == r.easyrpg_runtime_flags;
}

inline bool operator!=(const SaveEventExecFrame& l, const SaveEventExecFrame& r) {
Expand Down
49 changes: 47 additions & 2 deletions src/generated/lcf/rpg/saveeventexecstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,45 @@ namespace lcf {
namespace rpg {
class SaveEventExecState {
public:
enum class RuntimeFlags {
conf_override_active = 0x01,
patch_destiny_on = 0x10,
patch_destiny_off = 0x20,
patch_dynrpg_on = 0x40,
patch_dynrpg_off = 0x80,
patch_maniac_on = 0x100,
patch_maniac_of = 0x200,
patch_common_this_event_on = 0x400,
patch_common_this_event_off = 0x800,
patch_unlock_pics_on = 0x1000,
patch_unlock_pics_off = 0x2000,
patch_keypatch_on = 0x4000,
patch_keypatch_off = 0x8000,
patch_rpg2k3_cmds_on = 0x10000,
patch_rpg2k3_cmds_off = 0x20000,
use_rpg2k_battle_system_on = 0x40000,
use_rpg2k_battle_system_off = 0x80000
};
static constexpr auto kRuntimeFlagsTags = lcf::EnumTags{
RuntimeFlags::conf_override_active, "conf_override_active",
RuntimeFlags::patch_destiny_on, "patch_destiny_on",
RuntimeFlags::patch_destiny_off, "patch_destiny_off",
RuntimeFlags::patch_dynrpg_on, "patch_dynrpg_on",
RuntimeFlags::patch_dynrpg_off, "patch_dynrpg_off",
RuntimeFlags::patch_maniac_on, "patch_maniac_on",
RuntimeFlags::patch_maniac_of, "patch_maniac_of",
RuntimeFlags::patch_common_this_event_on, "patch_common_this_event_on",
RuntimeFlags::patch_common_this_event_off, "patch_common_this_event_off",
RuntimeFlags::patch_unlock_pics_on, "patch_unlock_pics_on",
RuntimeFlags::patch_unlock_pics_off, "patch_unlock_pics_off",
RuntimeFlags::patch_keypatch_on, "patch_keypatch_on",
RuntimeFlags::patch_keypatch_off, "patch_keypatch_off",
RuntimeFlags::patch_rpg2k3_cmds_on, "patch_rpg2k3_cmds_on",
RuntimeFlags::patch_rpg2k3_cmds_off, "patch_rpg2k3_cmds_off",
RuntimeFlags::use_rpg2k_battle_system_on, "use_rpg2k_battle_system_on",
RuntimeFlags::use_rpg2k_battle_system_off, "use_rpg2k_battle_system_off"
};

std::vector<SaveEventExecFrame> stack;
bool show_message = false;
bool abort_on_escape = false;
Expand All @@ -50,10 +89,15 @@ namespace rpg {
int32_t keyinput_2k3up = 0;
bool keyinput_timed = false;
bool wait_key_enter = false;
uint32_t easyrpg_runtime_flags = 0;
bool easyrpg_active = false;
DBString easyrpg_string;
std::vector<int32_t> easyrpg_parameters;
};
inline std::ostream& operator<<(std::ostream& os, SaveEventExecState::RuntimeFlags code) {
os << static_cast<std::underlying_type_t<decltype(code)>>(code);
return os;
}

inline bool operator==(const SaveEventExecState& l, const SaveEventExecState& r) {
return l.stack == r.stack
Expand All @@ -78,6 +122,7 @@ namespace rpg {
&& l.keyinput_2k3up == r.keyinput_2k3up
&& l.keyinput_timed == r.keyinput_timed
&& l.wait_key_enter == r.wait_key_enter
&& l.easyrpg_runtime_flags == r.easyrpg_runtime_flags
&& l.easyrpg_active == r.easyrpg_active
&& l.easyrpg_string == r.easyrpg_string
&& l.easyrpg_parameters == r.easyrpg_parameters;
Expand All @@ -95,8 +140,8 @@ namespace rpg {
const auto ctx1 = Context<SaveEventExecState, ParentCtx>{ "stack", i, &obj, parent_ctx };
ForEachString(obj.stack[i], f, &ctx1);
}
const auto ctx24 = Context<SaveEventExecState, ParentCtx>{ "easyrpg_string", -1, &obj, parent_ctx };
f(obj.easyrpg_string, ctx24);
const auto ctx25 = Context<SaveEventExecState, ParentCtx>{ "easyrpg_string", -1, &obj, parent_ctx };
f(obj.easyrpg_string, ctx25);
(void)obj;
(void)f;
(void)parent_ctx;
Expand Down
6 changes: 5 additions & 1 deletion src/generated/lcf/rpg/savemapeventbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ namespace rpg {
int32_t flash_blue = -1;
double flash_current_level = 0.0;
int32_t flash_time_left = 0;
uint32_t easyrpg_runtime_flags = 0;
int32_t easyrpg_move_failure_count = 0;
uint32_t easyrpg_clone_map_id = 0;
};

inline bool operator==(const SaveMapEventBase& l, const SaveMapEventBase& r) {
Expand Down Expand Up @@ -110,7 +112,9 @@ namespace rpg {
&& l.flash_blue == r.flash_blue
&& l.flash_current_level == r.flash_current_level
&& l.flash_time_left == r.flash_time_left
&& l.easyrpg_move_failure_count == r.easyrpg_move_failure_count;
&& l.easyrpg_runtime_flags == r.easyrpg_runtime_flags
&& l.easyrpg_move_failure_count == r.easyrpg_move_failure_count
&& l.easyrpg_clone_map_id == r.easyrpg_clone_map_id;
}

inline bool operator!=(const SaveMapEventBase& l, const SaveMapEventBase& r) {
Expand Down
8 changes: 8 additions & 0 deletions src/generated/lsd_saveeventexecframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ static TypedField<rpg::SaveEventExecFrame, std::vector<int32_t>> static_maniac_l
0,
0
);
static TypedField<rpg::SaveEventExecFrame, uint32_t> static_easyrpg_runtime_flags(
&rpg::SaveEventExecFrame::easyrpg_runtime_flags,
LSD_Reader::ChunkSaveEventExecFrame::easyrpg_runtime_flags,
"easyrpg_runtime_flags",
0,
0
);


template <>
Expand All @@ -118,6 +125,7 @@ Field<rpg::SaveEventExecFrame> const* Struct<rpg::SaveEventExecFrame>::fields[]
&static_maniac_event_page_id,
&static_maniac_loop_info_size,
&static_maniac_loop_info,
&static_easyrpg_runtime_flags,
NULL
};

Expand Down
8 changes: 8 additions & 0 deletions src/generated/lsd_saveeventexecstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ static TypedField<rpg::SaveEventExecState, bool> static_wait_key_enter(
0,
0
);
static TypedField<rpg::SaveEventExecState, uint32_t> static_easyrpg_runtime_flags(
&rpg::SaveEventExecState::easyrpg_runtime_flags,
LSD_Reader::ChunkSaveEventExecState::easyrpg_runtime_flags,
"easyrpg_runtime_flags",
0,
0
);
static TypedField<rpg::SaveEventExecState, bool> static_easyrpg_active(
&rpg::SaveEventExecState::easyrpg_active,
LSD_Reader::ChunkSaveEventExecState::easyrpg_active,
Expand Down Expand Up @@ -221,6 +228,7 @@ Field<rpg::SaveEventExecState> const* Struct<rpg::SaveEventExecState>::fields[]
&static_keyinput_2k3up,
&static_keyinput_timed,
&static_wait_key_enter,
&static_easyrpg_runtime_flags,
&static_easyrpg_active,
&static_easyrpg_string,
&static_easyrpg_parameters,
Expand Down
16 changes: 16 additions & 0 deletions src/generated/lsd_savemapevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,27 @@ static TypedField<rpg::SaveMapEvent, int32_t> static_flash_time_left(
0,
0
);
static TypedField<rpg::SaveMapEvent, uint32_t> static_easyrpg_runtime_flags(
&rpg::SaveMapEvent::easyrpg_runtime_flags,
LSD_Reader::ChunkSaveMapEvent::easyrpg_runtime_flags,
"easyrpg_runtime_flags",
0,
0
);
static TypedField<rpg::SaveMapEvent, int32_t> static_easyrpg_move_failure_count(
&rpg::SaveMapEvent::easyrpg_move_failure_count,
LSD_Reader::ChunkSaveMapEvent::easyrpg_move_failure_count,
"easyrpg_move_failure_count",
0,
0
);
static TypedField<rpg::SaveMapEvent, uint32_t> static_easyrpg_clone_map_id(
&rpg::SaveMapEvent::easyrpg_clone_map_id,
LSD_Reader::ChunkSaveMapEvent::easyrpg_clone_map_id,
"easyrpg_clone_map_id",
0,
0
);
static TypedField<rpg::SaveMapEvent, bool> static_waiting_execution(
&rpg::SaveMapEvent::waiting_execution,
LSD_Reader::ChunkSaveMapEvent::waiting_execution,
Expand Down Expand Up @@ -371,7 +385,9 @@ Field<rpg::SaveMapEvent> const* Struct<rpg::SaveMapEvent>::fields[] = {
&static_flash_blue,
&static_flash_current_level,
&static_flash_time_left,
&static_easyrpg_runtime_flags,
&static_easyrpg_move_failure_count,
&static_easyrpg_clone_map_id,
&static_waiting_execution,
&static_original_move_route_index,
&static_triggered_by_decision_key,
Expand Down
16 changes: 16 additions & 0 deletions src/generated/lsd_savemapeventbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,27 @@ static TypedField<rpg::SaveMapEventBase, int32_t> static_flash_time_left(
0,
0
);
static TypedField<rpg::SaveMapEventBase, uint32_t> static_easyrpg_runtime_flags(
&rpg::SaveMapEventBase::easyrpg_runtime_flags,
LSD_Reader::ChunkSaveMapEventBase::easyrpg_runtime_flags,
"easyrpg_runtime_flags",
0,
0
);
static TypedField<rpg::SaveMapEventBase, int32_t> static_easyrpg_move_failure_count(
&rpg::SaveMapEventBase::easyrpg_move_failure_count,
LSD_Reader::ChunkSaveMapEventBase::easyrpg_move_failure_count,
"easyrpg_move_failure_count",
0,
0
);
static TypedField<rpg::SaveMapEventBase, uint32_t> static_easyrpg_clone_map_id(
&rpg::SaveMapEventBase::easyrpg_clone_map_id,
LSD_Reader::ChunkSaveMapEventBase::easyrpg_clone_map_id,
"easyrpg_clone_map_id",
0,
0
);


template <>
Expand Down Expand Up @@ -343,7 +357,9 @@ Field<rpg::SaveMapEventBase> const* Struct<rpg::SaveMapEventBase>::fields[] = {
&static_flash_blue,
&static_flash_current_level,
&static_flash_time_left,
&static_easyrpg_runtime_flags,
&static_easyrpg_move_failure_count,
&static_easyrpg_clone_map_id,
NULL
};

Expand Down
Loading