Skip to content

Commit

Permalink
Merge pull request #213 from Ghabry/rpg2k3_1.12
Browse files Browse the repository at this point in the history
Add Rpg2k3 1.12 Chunks
  • Loading branch information
carstene1ns authored Oct 6, 2017
2 parents 8f8b9c7 + 358a712 commit 69bd43d
Show file tree
Hide file tree
Showing 18 changed files with 193 additions and 25 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,18 @@ CMakeFiles/
*.cmake
!/builds/cmake/Modules/Find*.cmake
/builds/cmake/lib/
/builds/cmake/*.in

# IntelliJ / CLion
.idea/

# doxygen generated files
/doc/

# Python generated files
*.pyc
__pycache__/

# other generated files
Makefile
*~
Expand Down
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ liblcf_la_SOURCES = \
src/generated/lsd_savemapinfo.cpp \
src/generated/lsd_savepartylocation.cpp \
src/generated/lsd_savepicture.cpp \
src/generated/lsd_savepicture_flags.cpp \
src/generated/lsd_savescreen.cpp \
src/generated/lsd_savesystem.cpp \
src/generated/lsd_savetarget.cpp \
Expand Down
1 change: 1 addition & 0 deletions builds/vs2015/liblcf.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
<ClCompile Include="..\..\src\generated\lsd_savemapinfo.cpp" />
<ClCompile Include="..\..\src\generated\lsd_savepartylocation.cpp" />
<ClCompile Include="..\..\src\generated\lsd_savepicture.cpp" />
<ClCompile Include="..\..\src\generated\lsd_savepicture_flags.cpp" />
<ClCompile Include="..\..\src\generated\lsd_savescreen.cpp" />
<ClCompile Include="..\..\src\generated\lsd_savesystem.cpp" />
<ClCompile Include="..\..\src\generated\lsd_savetarget.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions builds/vs2015/liblcf.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@
<ClCompile Include="..\..\src\generated\lsd_savepicture.cpp">
<Filter>Source Files\LSD</Filter>
</ClCompile>
<ClCompile Include="..\..\src\generated\lsd_savepicture_flags.cpp">
<Filter>Source Files\LSD</Filter>
</ClCompile>
<ClCompile Include="..\..\src\generated\lsd_savescreen.cpp">
<Filter>Source Files\LSD</Filter>
</ClCompile>
Expand Down
17 changes: 17 additions & 0 deletions generator/csv/enums.csv
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ SavePartyLocation,VehicleType,none,0
SavePartyLocation,VehicleType,skiff,1
SavePartyLocation,VehicleType,ship,2
SavePartyLocation,VehicleType,airship,3
SavePicture,MapLayer,none,0
SavePicture,MapLayer,parallax,1
SavePicture,MapLayer,tilemap_below,2
SavePicture,MapLayer,events_below,3
SavePicture,MapLayer,events_same_as_player,4
SavePicture,MapLayer,tilemap_above,5
SavePicture,MapLayer,events_above,6
SavePicture,MapLayer,weather,7
SavePicture,MapLayer,animations,8
SavePicture,MapLayer,windows,9
SavePicture,MapLayer,timers,10
SavePicture,BattleLayer,none,0
SavePicture,BattleLayer,background,1
SavePicture,BattleLayer,battlers_and_animations,2
SavePicture,BattleLayer,weather,3
SavePicture,BattleLayer,windows_and_status,4
SavePicture,BattleLayer,timers,5
SaveSystem,AtbMode,atb_active,0
SaveSystem,AtbMode,atb_wait,1
State,Persistence,ends,0
Expand Down
11 changes: 10 additions & 1 deletion generator/csv/fields.csv
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ SaveSystem,menu_allowed,f,Boolean,0x7C,True,
SaveSystem,background,f,String,0x7D,,string
SaveSystem,save_count,f,Integer,0x83,0,
SaveSystem,save_slot,f,Integer,0x84,1,
SaveSystem,atb_mode,f,Enum<SaveSystem_AtbMode>,0x8C,0,ATB mode of RPG 2003 battle system.
SaveSystem,atb_mode,f,Enum<SaveSystem_AtbMode>,0x8C,0,ATB mode of RPG 2003 battle system.
SaveScreen,tint_finish_red,f,Integer,0x01,100,int
SaveScreen,tint_finish_green,f,Integer,0x02,100,int
SaveScreen,tint_finish_blue,f,Integer,0x03,100,int
Expand Down Expand Up @@ -806,6 +806,15 @@ SavePicture,current_sat,f,Double,0x0E,-1.0,double
SavePicture,effect_mode,f,Integer,0x0F,0,int
SavePicture,current_effect,f,Double,0x10,0.0,double
SavePicture,current_bot_trans,f,Double,0x12,0.0,double
SavePicture,spritesheet_cols,f,Integer,0x13,1,Spritesheet columns
SavePicture,spritesheet_rows,f,Integer,0x14,1,Spritesheet rows
SavePicture,spritesheet_frame,f,Integer,0x15,0,Current spritesheet frame
SavePicture,spritesheet_speed,f,Integer,0x16,0,Spritesheet speed (X frames per second)
SavePicture,frames,f,Integer,0x17,0,Frames since ShowPicture
SavePicture,spritesheet_play_once,f,Boolean,0x18,False,True: Play once and destroy; False: Loop spritesheet
SavePicture,map_layer,f,Enum<MapLayer>,0x19,7,Layer to show picture on at the map
SavePicture,battle_layer,f,Enum<BattleLayer>,0x1A,0,Layer to show picture on in battle
SavePicture,flags,f,SavePicture_Flags,0x1B,97,Bitflag. Persists Map/Battle change/end; Affected by Shake/Flash/Tint
SavePicture,finish_x,f,Double,0x1F,0.0,double
SavePicture,finish_y,f,Double,0x20,0.0,double
SavePicture,finish_magnify,f,Integer,0x21,100,int
Expand Down
7 changes: 7 additions & 0 deletions generator/csv/flags.csv
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ EventPageCondition,item
EventPageCondition,actor
EventPageCondition,timer
EventPageCondition,timer2
SavePicture,erase_on_map_change
SavePicture,erase_on_battle_end
SavePicture,unused_bit
SavePicture,unused_bit2
SavePicture,affected_by_tint
SavePicture,affected_by_flash
SavePicture,affected_by_shake
11 changes: 11 additions & 0 deletions generator/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ def pod_default(field):
def flag_size(flag):
return (len(flag) + 7) // 8

def flag_set(field, bit):
bit -= 1
try:
res = bool(int(field.default) & (1 << bit))
except ValueError:
# Default was not an int
res = False

return str(res).lower()

def filter_structs_without_codes(structs):
for struct in structs:
if all(f.code for f in sfields[struct.name]):
Expand Down Expand Up @@ -334,6 +344,7 @@ def main(argv):
env.filters["struct_has_code"] = filter_structs_without_codes
env.filters["field_is_used"] = filter_unused_fields
env.filters["flag_size"] = flag_size
env.filters["flag_set"] = flag_set
env.tests['needs_ctor'] = needs_ctor

globals = dict(
Expand Down
2 changes: 1 addition & 1 deletion generator/templates/rpg_header.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace RPG {
{%- if field.type.endswith("_Flags") %}
struct Flags {
{%- for flag in flags[struct_name] %}
bool {{ flag.field }};
bool {{ flag.field }} = {{ field|flag_set(loop.index) }};
{%- endfor %}
} {{ field.name }};
{%- else %}
Expand Down
18 changes: 18 additions & 0 deletions src/generated/lsd_chunks.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,24 @@ namespace LSD_Reader {
current_effect = 0x10,
/** double */
current_bot_trans = 0x12,
/** Spritesheet columns */
spritesheet_cols = 0x13,
/** Spritesheet rows */
spritesheet_rows = 0x14,
/** Current spritesheet frame */
spritesheet_frame = 0x15,
/** Spritesheet speed (X frames per second) */
spritesheet_speed = 0x16,
/** Frames since ShowPicture */
frames = 0x17,
/** True: Play once and destroy; False: Loop spritesheet */
spritesheet_play_once = 0x18,
/** Layer to show picture on at the map */
map_layer = 0x19,
/** Layer to show picture on in battle */
battle_layer = 0x1A,
/** Bitflag. Persists Map/Battle change/end; Affected by Shake/Flash/Tint */
flags = 0x1B,
/** double */
finish_x = 0x1F,
/** double */
Expand Down
9 changes: 9 additions & 0 deletions src/generated/lsd_savepicture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ LCF_STRUCT_FIELDS_BEGIN()
LCF_STRUCT_TYPED_FIELD(int, effect_mode),
LCF_STRUCT_TYPED_FIELD(double, current_effect),
LCF_STRUCT_TYPED_FIELD(double, current_bot_trans),
LCF_STRUCT_TYPED_FIELD(int, spritesheet_cols),
LCF_STRUCT_TYPED_FIELD(int, spritesheet_rows),
LCF_STRUCT_TYPED_FIELD(int, spritesheet_frame),
LCF_STRUCT_TYPED_FIELD(int, spritesheet_speed),
LCF_STRUCT_TYPED_FIELD(int, frames),
LCF_STRUCT_TYPED_FIELD(bool, spritesheet_play_once),
LCF_STRUCT_TYPED_FIELD(int, map_layer),
LCF_STRUCT_TYPED_FIELD(int, battle_layer),
LCF_STRUCT_TYPED_FIELD(RPG::SavePicture::Flags, flags),
LCF_STRUCT_TYPED_FIELD(double, finish_x),
LCF_STRUCT_TYPED_FIELD(double, finish_y),
LCF_STRUCT_TYPED_FIELD(int, finish_magnify),
Expand Down
41 changes: 41 additions & 0 deletions src/generated/lsd_savepicture_flags.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* !!!! GENERATED FILE - DO NOT EDIT !!!!
* --------------------------------------
*
* This file is part of liblcf. Copyright (c) 2017 liblcf authors.
* https://github.com/EasyRPG/liblcf - https://easyrpg.org
*
* liblcf is Free/Libre Open Source Software, released under the MIT License.
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code.
*/

/*
* Headers
*/
#include "lsd_reader.h"
#include "lsd_chunks.h"
#include "reader_struct.h"


// Read SavePicture.

typedef RPG::SavePicture::Flags flags_type;

template <>
char const* const Flags<flags_type>::name("SavePicture_Flags");

template <>
const Flags<flags_type>::Flag* Flags<flags_type>::flags[] = {
new Flags<flags_type>::Flag(&flags_type::erase_on_map_change, "erase_on_map_change"),
new Flags<flags_type>::Flag(&flags_type::erase_on_battle_end, "erase_on_battle_end"),
new Flags<flags_type>::Flag(&flags_type::unused_bit, "unused_bit"),
new Flags<flags_type>::Flag(&flags_type::unused_bit2, "unused_bit2"),
new Flags<flags_type>::Flag(&flags_type::affected_by_tint, "affected_by_tint"),
new Flags<flags_type>::Flag(&flags_type::affected_by_flash, "affected_by_flash"),
new Flags<flags_type>::Flag(&flags_type::affected_by_shake, "affected_by_shake"),
NULL
};

template <>
const uint32_t Flags<flags_type>::max_size = 1;

14 changes: 7 additions & 7 deletions src/generated/rpg_eventpagecondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ namespace RPG {
};

struct Flags {
bool switch_a;
bool switch_b;
bool variable;
bool item;
bool actor;
bool timer;
bool timer2;
bool switch_a = false;
bool switch_b = false;
bool variable = false;
bool item = false;
bool actor = false;
bool timer = false;
bool timer2 = false;
} flags;
int switch_a_id = 1;
int switch_b_id = 1;
Expand Down
39 changes: 39 additions & 0 deletions src/generated/rpg_savepicture.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@
namespace RPG {
class SavePicture {
public:
enum MapLayer {
MapLayer_none = 0,
MapLayer_parallax = 1,
MapLayer_tilemap_below = 2,
MapLayer_events_below = 3,
MapLayer_events_same_as_player = 4,
MapLayer_tilemap_above = 5,
MapLayer_events_above = 6,
MapLayer_weather = 7,
MapLayer_animations = 8,
MapLayer_windows = 9,
MapLayer_timers = 10
};
enum BattleLayer {
BattleLayer_none = 0,
BattleLayer_background = 1,
BattleLayer_battlers_and_animations = 2,
BattleLayer_weather = 3,
BattleLayer_windows_and_status = 4,
BattleLayer_timers = 5
};

int ID = 0;
std::string name;
double start_x = 0.0;
Expand All @@ -38,6 +60,23 @@ namespace RPG {
int effect_mode = 0;
double current_effect = 0.0;
double current_bot_trans = 0.0;
int spritesheet_cols = 1;
int spritesheet_rows = 1;
int spritesheet_frame = 0;
int spritesheet_speed = 0;
int frames = 0;
bool spritesheet_play_once = false;
int map_layer = 7;
int battle_layer = 0;
struct Flags {
bool erase_on_map_change = true;
bool erase_on_battle_end = false;
bool unused_bit = false;
bool unused_bit2 = false;
bool affected_by_tint = false;
bool affected_by_flash = true;
bool affected_by_shake = true;
} flags;
double finish_x = 0.0;
double finish_y = 0.0;
int finish_magnify = 100;
Expand Down
8 changes: 4 additions & 4 deletions src/generated/rpg_terrain.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ namespace RPG {
int background_b_scrollh_speed = 0;
int background_b_scrollv_speed = 0;
struct Flags {
bool back_party;
bool back_enemies;
bool lateral_party;
bool lateral_enemies;
bool back_party = false;
bool back_enemies = false;
bool lateral_party = false;
bool lateral_enemies = false;
} special_flags;
int special_back_party = 15;
int special_back_enemies = 10;
Expand Down
20 changes: 10 additions & 10 deletions src/generated/rpg_trooppagecondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ namespace RPG {
class TroopPageCondition {
public:
struct Flags {
bool switch_a;
bool switch_b;
bool variable;
bool turn;
bool fatigue;
bool enemy_hp;
bool actor_hp;
bool turn_enemy;
bool turn_actor;
bool command_actor;
bool switch_a = false;
bool switch_b = false;
bool variable = false;
bool turn = false;
bool fatigue = false;
bool enemy_hp = false;
bool actor_hp = false;
bool turn_enemy = false;
bool turn_actor = false;
bool command_actor = false;
} flags;
int switch_a_id = 1;
int switch_b_id = 1;
Expand Down
2 changes: 2 additions & 0 deletions src/reader_flags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "rpg_trooppagecondition.h"
#include "rpg_eventpagecondition.h"
#include "rpg_terrain.h"
#include "rpg_savepicture.h"

// Templates

Expand Down Expand Up @@ -120,3 +121,4 @@ void Flags<S>::BeginXml(S& obj, XmlReader& stream) {
template class Flags<RPG::TroopPageCondition::Flags>;
template class Flags<RPG::EventPageCondition::Flags>;
template class Flags<RPG::Terrain::Flags>;
template class Flags<RPG::SavePicture::Flags>;
6 changes: 4 additions & 2 deletions src/reader_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "rpg_movecommand.h"
#include "rpg_treemap.h"
#include "rpg_rect.h"
#include "rpg_savepicture.h"

// Forward declarations

Expand All @@ -55,7 +56,8 @@ struct TypeCategory {

template <> struct TypeCategory<RPG::TroopPageCondition::Flags> { static const Category::Index value = Category::Flags; };
template <> struct TypeCategory<RPG::EventPageCondition::Flags> { static const Category::Index value = Category::Flags; };
template <> struct TypeCategory<RPG::Terrain::Flags> { static const Category::Index value = Category::Flags; };
template <> struct TypeCategory<RPG::Terrain::Flags> { static const Category::Index value = Category::Flags; };
template <> struct TypeCategory<RPG::SavePicture::Flags> { static const Category::Index value = Category::Flags; };

template <> struct TypeCategory<RPG::Equipment> { static const Category::Index value = Category::RawStruct; };
template <> struct TypeCategory<RPG::EventCommand> { static const Category::Index value = Category::RawStruct; };
Expand Down Expand Up @@ -216,7 +218,7 @@ struct Primitive<int> {
#endif
stream.Seek(length, LcfReader::FromCurrent);
}

}
static void WriteLcf(const int& ref, LcfWriter& stream) {
stream.WriteInt(ref);
Expand Down

0 comments on commit 69bd43d

Please sign in to comment.