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

Refactor Game_Character classes 1 of 2 #1502

Merged
merged 24 commits into from Dec 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a1eb8e3
Add Utils::Clamp
fmatthew5876 Nov 30, 2018
785bd70
Store SaveMapEventBase pointer in Game_Character
fmatthew5876 Nov 18, 2018
d52dca7
Add Game_Vehicle::data()
fmatthew5876 Nov 18, 2018
ac9919c
Add Game_Player::data()
fmatthew5876 Nov 18, 2018
67f9078
Add Game_Event::data()
fmatthew5876 Nov 18, 2018
832f097
Collapse some SaveMapEventBase fields to Game_Character
fmatthew5876 Nov 18, 2018
d9cdfab
More SaveMapEventBase -> Game_Character
fmatthew5876 Nov 18, 2018
804d666
Simplify GetTileId()
fmatthew5876 Nov 19, 2018
b4f23b9
Fix animation_type
fmatthew5876 Nov 19, 2018
8421b4f
Use SaveMapEventBase stop_count and max_stop_count
fmatthew5876 Nov 19, 2018
254a4bd
Use SaveMapEventBase::remaining_step
fmatthew5876 Nov 19, 2018
8c64d74
Use SaveMapEventBase::anim_count
fmatthew5876 Nov 19, 2018
883f5bb
Use SaveMapEventBase::jumping
fmatthew5876 Nov 19, 2018
c8e701b
Expose begin_jump_x and y
fmatthew5876 Nov 19, 2018
d5430ae
Encapsulate SaveMapEventBase::flying
fmatthew5876 Nov 19, 2018
3b7ee28
devirtualize GetBushDepth()
fmatthew5876 Nov 19, 2018
9417e21
Refactor BushDepth
fmatthew5876 Nov 19, 2018
dd5ca65
Refactor Transparency/Opacity
fmatthew5876 Nov 19, 2018
dbd53e1
Set and reset player flying flag in airship
fmatthew5876 Nov 19, 2018
b8fff9a
Remove Game_Vehicle::driving
fmatthew5876 Nov 19, 2018
0d213b4
Remove unused Game_Character::animation_id
fmatthew5876 Nov 19, 2018
52f718c
Use SaveMapEventBase::anim_frame
fmatthew5876 Nov 19, 2018
f50be8b
Use SaveMapEventBase::anim_paused
fmatthew5876 Nov 19, 2018
48d6d9d
Add compatibility hack for old Player save games
fmatthew5876 Nov 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
170 changes: 70 additions & 100 deletions src/game_character.cpp

Large diffs are not rendered by default.

510 changes: 440 additions & 70 deletions src/game_character.h

Large diffs are not rendered by default.

237 changes: 43 additions & 194 deletions src/game_event.cpp

Large diffs are not rendered by default.

49 changes: 13 additions & 36 deletions src/game_event.h
Expand Up @@ -46,45 +46,10 @@ class Game_Event : public Game_Character {
* Implementation of abstract methods
*/
/** @{ */
int GetX() const override;
void SetX(int new_x) override;
int GetY() const override;
void SetY(int new_y) override;
int GetMapId() const override;
void SetMapId(int new_map_id) override;
int GetDirection() const override;
void SetDirection(int new_direction) override;
int GetSpriteDirection() const override;
void SetSpriteDirection(int new_direction) override;
bool IsFacingLocked() const override;
void SetFacingLocked(bool locked) override;
int GetLayer() const override;
void SetLayer(int new_layer) override;
bool IsOverlapForbidden() const override;
int GetMoveSpeed() const override;
void SetMoveSpeed(int speed) override;
int GetMoveFrequency() const override;
void SetMoveFrequency(int frequency) override;
const RPG::MoveRoute& GetMoveRoute() const override;
void SetMoveRoute(const RPG::MoveRoute& move_route) override;
int GetOriginalMoveRouteIndex() const override;
void SetOriginalMoveRouteIndex(int new_index) override;
int GetMoveRouteIndex() const override;
void SetMoveRouteIndex(int new_index) override;
bool IsMoveRouteOverwritten() const override;
void SetMoveRouteOverwritten(bool force) override;
bool IsMoveRouteRepeated() const override;
void SetMoveRouteRepeated(bool force) override;
const std::string& GetSpriteName() const override;
void SetSpriteName(const std::string& sprite_name) override;
int GetSpriteIndex() const override;
void SetSpriteIndex(int index) override;
Color GetFlashColor() const override;
void SetFlashColor(const Color& flash_color) override;
double GetFlashLevel() const override;
void SetFlashLevel(double flash_level) override;
int GetFlashTimeLeft() const override;
void SetFlashTimeLeft(int time_left) override;
bool GetThrough() const override;
void SetThrough(bool through) override;
/** @} */
Expand Down Expand Up @@ -193,6 +158,10 @@ class Game_Event : public Game_Character {
const RPG::EventPage* GetActivePage() const;

const RPG::SaveMapEvent& GetSaveData();
protected:
RPG::SaveMapEvent* data();
const RPG::SaveMapEvent* data() const;

private:
void UpdateSelfMovement() override;

Expand Down Expand Up @@ -232,7 +201,7 @@ class Game_Event : public Game_Character {
// Not a reference on purpose.
// Events change during map change and old are destroyed, breaking the
// reference.
RPG::SaveMapEvent data;
std::unique_ptr<RPG::SaveMapEvent> _data_copy;

bool starting = false, running = false, halting = false;
bool started_by_decision_key = false;
Expand All @@ -247,4 +216,12 @@ class Game_Event : public Game_Character {
int frame_count_at_last_auto_start_check = -1;
};

inline RPG::SaveMapEvent* Game_Event::data() {
return static_cast<RPG::SaveMapEvent*>(Game_Character::data());
}

inline const RPG::SaveMapEvent* Game_Event::data() const {
return static_cast<const RPG::SaveMapEvent*>(Game_Character::data());
}

#endif