Skip to content

Commit 4986aa3

Browse files
committed
Merge pull request #326 from Zegeri/development
Bushes, improve battle interpreter, fix rotation effect and other fixes
2 parents 5a4f627 + af9c77c commit 4986aa3

22 files changed

+133
-107
lines changed

src/bitmap_screen.cpp

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,14 @@ void BitmapScreen::BlitScreen(int x, int y, Rect const& src_rect) {
7373

7474
Rect rect = src_rect_effect.GetSubRect(src_rect);
7575

76-
Rect bush_rect = src_rect_effect;
77-
bush_rect.height -= bush_effect;
78-
bush_rect = bush_rect.GetSubRect(src_rect);
79-
int bush_y = (rect.y + rect.height) - (bush_rect.y + bush_rect.height);
80-
8176
bool need_scale = false;
82-
BitmapRef draw_bitmap = Refresh(rect, need_scale, bush_y);
77+
BitmapRef draw_bitmap = Refresh(rect, need_scale);
8378

8479
bitmap_changed = false;
8580
needs_refresh = false;
8681

8782
if(draw_bitmap) {
88-
BlitScreenIntern(*draw_bitmap, x, y, rect, need_scale, bush_y);
83+
BlitScreenIntern(*draw_bitmap, x, y, rect, need_scale, bush_effect);
8984
}
9085
}
9186

@@ -94,10 +89,9 @@ void BitmapScreen::BlitScreenTiled(Rect const& src_rect, Rect const& dst_rect, i
9489
return;
9590

9691
Rect rect = src_rect_effect.GetSubRect(src_rect);
97-
int bush_y = 0;
9892

9993
bool need_scale = false;
100-
BitmapRef draw_bitmap = Refresh(rect, need_scale, bush_y);
94+
BitmapRef draw_bitmap = Refresh(rect, need_scale);
10195

10296
bitmap_changed = false;
10397
needs_refresh = false;
@@ -330,14 +324,12 @@ double BitmapScreen::GetWaverEffectPhase() const {
330324
}
331325

332326
void BitmapScreen::BlitScreenIntern(Bitmap const& draw_bitmap, int x, int y,
333-
Rect const& src_rect, bool need_scale, int bush_y) {
327+
Rect const& src_rect, bool need_scale, int opacity_split) {
334328
if (! &draw_bitmap)
335329
return;
336330

337331
BitmapRef dst = DisplayUi->GetDisplaySurface();
338332

339-
int opacity_split = bush_y;
340-
341333
double zoom_x = need_scale ? zoom_x_effect : 1.0;
342334
double zoom_y = need_scale ? zoom_y_effect : 1.0;
343335

@@ -347,7 +339,7 @@ void BitmapScreen::BlitScreenIntern(Bitmap const& draw_bitmap, int x, int y,
347339
waver_effect_depth, waver_effect_phase);
348340
}
349341

350-
BitmapRef BitmapScreen::Refresh(Rect& rect, bool& need_scale, int& bush_y) {
342+
BitmapRef BitmapScreen::Refresh(Rect& rect, bool& need_scale) {
351343
need_scale = false;
352344

353345
rect.Adjust(bitmap->GetWidth(), bitmap->GetHeight());
@@ -365,6 +357,8 @@ BitmapRef BitmapScreen::Refresh(Rect& rect, bool& need_scale, int& bush_y) {
365357
flipx_effect != current_flip_x ||
366358
flipy_effect != current_flip_y;
367359
bool effects_rect_changed = rect != bitmap_effects_src_rect;
360+
bool zoom_changed = zoom_x_effect != current_zoom_x ||
361+
zoom_y_effect != current_zoom_y;
368362

369363
if (effects_changed || effects_rect_changed || bitmap_changed) {
370364
bitmap_effects_valid = false;
@@ -429,43 +423,12 @@ BitmapRef BitmapScreen::Refresh(Rect& rect, bool& need_scale, int& bush_y) {
429423
src_bitmap = bitmap_effects;
430424
}
431425

432-
if (no_zoom || angle_effect != 0.0)
433-
return src_bitmap;
434-
435-
int zoomed_width = (int)(rect.width * zoom_x_effect);
436-
int zoomed_height = (int)(rect.height * zoom_y_effect);
437-
438-
if (zoomed_width > 640 || zoomed_height > 640) {
439-
need_scale = true;
426+
if (no_zoom && !zoom_changed)
440427
return src_bitmap;
441-
}
442-
443-
bool zoom_changed =
444-
zoom_x_effect != current_zoom_x ||
445-
zoom_y_effect != current_zoom_y;
446-
447-
bool scale_rect_changed = rect != bitmap_scale_src_rect;
448-
449-
if (zoom_changed || scale_rect_changed)
450-
bitmap_scale_valid = false;
451-
452-
if (bitmap_scale && bitmap_scale_valid) {
453-
bush_y = bush_y * bitmap_scale->GetHeight() / rect.height;
454-
rect = bitmap_scale->GetRect();
455-
return bitmap_scale;
456-
}
457428

458429
current_zoom_x = zoom_x_effect;
459430
current_zoom_y = zoom_y_effect;
431+
need_scale = true;
460432

461-
bitmap_scale.reset();
462-
463-
bitmap_scale = src_bitmap->Resample(zoomed_width, zoomed_height, rect);
464-
465-
bitmap_scale_src_rect = rect;
466-
bitmap_scale_valid = true;
467-
468-
bush_y = bush_y * bitmap_scale->GetHeight() / rect.height;
469-
rect = bitmap_scale->GetRect();
470-
return bitmap_scale;
433+
return src_bitmap;
471434
}

src/bitmap_screen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ class BitmapScreen {
321321
void BlitScreenIntern(Bitmap const& draw_bitmap, int x, int y, Rect const& src_rect,
322322
bool need_scale, int bush_y);
323323

324-
BitmapRef Refresh(Rect& rect, bool& need_scale, int& bush_y);
324+
BitmapRef Refresh(Rect& rect, bool& need_scale);
325325

326326
BitmapRef bitmap_effects;
327327
BitmapRef bitmap_scale;

src/effects.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,9 @@ void Bitmap::EffectsBlit(int x, int y, Bitmap const& src, Rect const& src_rect,
8080
EffectsBlit(x, y, src, blit_rect,
8181
top_opacity, waver_depth, waver_phase);
8282

83-
blit_rect = src_rect;
84-
blit_rect.y = src_rect.height - opacity_split;
83+
blit_rect.y += blit_rect.height;
8584
blit_rect.height = opacity_split;
86-
x += src_rect.height - opacity_split;
85+
y += src_rect.height - opacity_split;
8786
EffectsBlit(x, y, src, blit_rect,
8887
bottom_opacity, waver_depth, waver_phase);
8988
}
@@ -138,10 +137,11 @@ void Bitmap::EffectsBlit(int x, int y, Bitmap const& src, Rect const& src_rect_,
138137
}
139138

140139
if (rotate) {
141-
Matrix fwd = Matrix::Setup(1.0-angle, zoom_x, zoom_y, (src_rect.width - src_rect.x) / 2, (src_rect.height - src_rect.y) /2, x, y);
140+
Matrix fwd = Matrix::Setup(-angle, zoom_x, zoom_y,
141+
(src_rect.width - src_rect.x) / 2, (src_rect.height - src_rect.y) / 2,
142+
x + src_rect.width * zoom_x / 2, y + src_rect.height * zoom_y / 2);
142143
EffectsBlit(fwd, src, src_rect, top_opacity, bottom_opacity, opacity_split);
143-
}
144-
else if (scale)
144+
} else if (scale)
145145
EffectsBlit(x, y, *draw, src_rect,
146146
top_opacity, bottom_opacity, opacity_split,
147147
zoom_x, zoom_y,

src/filefinder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ EASYRPG_SHARED_PTR<FileFinder::ProjectTree> FileFinder::CreateProjectTree(std::s
185185
tree->directories : tree->files)[i->first] = i->second;
186186
}
187187

188+
// Stop here if the tree is invalid
189+
if (p == Main_Data::project_path && !IsRPG2kProject(*tree) && !IsEasyRpgProject(*tree))
190+
return tree;
191+
188192
for(string_map::const_iterator i = tree->directories.begin(); i != tree->directories.end(); ++i) {
189193
GetDirectoryMembers(MakePath(tree->project_path, i->second), RECURSIVE)
190194
.members.swap(tree->sub_members[i->first]);

src/game_battle.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,27 @@ bool Game_Battle::AreConditionsMet(const RPG::TroopPageCondition& condition) {
166166
return false;
167167
}*/
168168

169+
if (condition.flags.fatigue) {
170+
int fatigue = Main_Data::game_party->GetFatigue();
171+
if (fatigue < condition.fatigue_min || fatigue > condition.fatigue_max)
172+
return false;
173+
}
174+
169175
if (condition.flags.enemy_hp) {
170176
Game_Battler& enemy = (*Main_Data::game_enemyparty)[condition.enemy_id];
171177
int hp = enemy.GetHp();
172-
if (hp < condition.enemy_hp_min || hp > condition.enemy_hp_max)
178+
int hpmin = enemy.GetMaxHp() * condition.enemy_hp_min / 100;
179+
int hpmax = enemy.GetMaxHp() * condition.enemy_hp_max / 100;
180+
if (hp < hpmin || hp > hpmax)
173181
return false;
174182
}
175183

176184
if (condition.flags.actor_hp) {
177185
Game_Actor* actor = Game_Actors::GetActor(condition.actor_id);
178186
int hp = actor->GetHp();
179-
if (hp < condition.actor_hp_min || hp > condition.actor_hp_max)
187+
int hpmin = actor->GetMaxHp() * condition.actor_hp_min / 100;
188+
int hpmax = actor->GetMaxHp() * condition.actor_hp_max / 100;
189+
if (hp < hpmin || hp > hpmax)
180190
return false;
181191
}
182192
/*
@@ -189,7 +199,6 @@ bool Game_Battle::AreConditionsMet(const RPG::TroopPageCondition& condition) {
189199
if (ally->last_command != condition.command_id)
190200
return false;
191201
}*/
192-
193202
return true;
194203
}
195204

src/game_character.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ bool Game_Character::IsLandable(int x, int y) const
130130
return true;
131131
}
132132

133+
bool Game_Character::IsMessageBlocking() const {
134+
return Game_Message::message_waiting && !Game_Message::GetContinueEvents();
135+
}
136+
133137
void Game_Character::MoveTo(int x, int y) {
134138
SetX(x % Game_Map::GetWidth());
135139
SetY(y % Game_Map::GetHeight());
@@ -217,7 +221,7 @@ void Game_Character::Update() {
217221
if (stop_count >= ((GetMoveFrequency() > 7) ? 0 : pow(2.0, 9 - GetMoveFrequency()))) {
218222
if (IsMoveRouteOverwritten()) {
219223
MoveTypeCustom();
220-
} else if (Game_Message::GetContinueEvents() || !Game_Message::message_waiting) {
224+
} else if (!IsMessageBlocking()) {
221225
UpdateSelfMovement();
222226
}
223227
}
@@ -1175,8 +1179,8 @@ bool Game_Character::IsSpinning() {
11751179
return animation_type == RPG::EventPage::AnimType_spin;
11761180
}
11771181

1178-
void Game_Character::UpdateBushDepth() {
1179-
// TODO
1182+
int Game_Character::GetBushDepth() {
1183+
return Game_Map::GetBushDepth(GetX(), GetY());
11801184
}
11811185

11821186
void Game_Character::SetGraphic(const std::string& name, int index) {

src/game_character.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,13 @@ class Game_Character {
349349
*/
350350
virtual bool IsLandable(int x, int y) const;
351351

352+
/**
353+
* Gets if a message is halting this character's processes.
354+
*
355+
* @return whether the character is halted by a message.
356+
*/
357+
virtual bool IsMessageBlocking() const;
358+
352359
/**
353360
* Moves the character to a new tile.
354361
*
@@ -729,7 +736,12 @@ class Game_Character {
729736
*/
730737
bool IsSpinning();
731738

732-
virtual void UpdateBushDepth();
739+
/**
740+
* Gets the bush depth of the tile where this character is standing
741+
*
742+
* @return Bush depth at this character's position
743+
*/
744+
int GetBushDepth();
733745

734746
void SetGraphic(const std::string& name, int index);
735747

src/game_event.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "game_actor.h"
2121
#include "game_actors.h"
2222
#include "game_map.h"
23+
#include "game_message.h"
2324
#include "game_party.h"
2425
#include "game_player.h"
2526
#include "game_switches.h"
@@ -224,6 +225,11 @@ void Game_Event::SetFlashTimeLeft(int time_left) {
224225
data.flash_time_left = time_left;
225226
}
226227

228+
bool Game_Event::IsMessageBlocking() const {
229+
return Game_Message::message_waiting &&
230+
!(Game_Message::GetContinueEvents() && Game_Message::owner_id != ID);
231+
}
232+
227233
bool Game_Event::GetThrough() const {
228234
return page == NULL || Game_Character::GetThrough();
229235
}

src/game_event.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class Game_Event : public Game_Character {
8383
void SetFlashLevel(int flash_level);
8484
int GetFlashTimeLeft() const;
8585
void SetFlashTimeLeft(int time_left);
86+
bool IsMessageBlocking() const;
8687
/** @} */
8788

8889
/**

0 commit comments

Comments
 (0)