Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/battle_animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ BattleAnimation::BattleAnimation(const lcf::rpg::Animation& anim, bool only_soun

SetZ(Priority_BattleAnimation);

const std::string& name = animation.animation_name;
StringView name = animation.animation_name;
BitmapRef graphic;

if (name.empty()) return;
Expand Down
10 changes: 5 additions & 5 deletions src/game_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ std::string Game_Actor::GetLearningMessage(const lcf::rpg::Skill& skill) const {
);
}

return skill.name + (Player::IsRPG2k3E() ? " " : "") + lcf::Data::terms.skill_learned;
return ToString(skill.name) + (Player::IsRPG2k3E() ? " " : "") + ToString(lcf::Data::terms.skill_learned);
}

void Game_Actor::ChangeLevel(int new_level, PendingMessage* pm) {
Expand Down Expand Up @@ -823,9 +823,9 @@ Point Game_Actor::GetOriginalPosition() const {
return { actor.battle_x, actor.battle_y };
}

const std::string& Game_Actor::GetSkillName() const {
StringView Game_Actor::GetSkillName() const {
auto& a = GetActor();
return a.rename_skill ? a.skill_name : lcf::Data::terms.command_skill;
return a.rename_skill ? StringView(a.skill_name) : StringView(lcf::Data::terms.command_skill);
}

void Game_Actor::SetSprite(const std::string &file, int index, bool transparent) {
Expand Down Expand Up @@ -1041,9 +1041,9 @@ void Game_Actor::ChangeClass(int new_class_id,
}
}

std::string Game_Actor::GetClassName() const {
StringView Game_Actor::GetClassName() const {
if (!GetClass()) {
return "";
return {};
}
return GetClass()->name;
}
Expand Down
28 changes: 10 additions & 18 deletions src/game_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,11 @@
#include <string>
#include <vector>
#include <cstdint>
#include <lcf/rpg/fwd.h>
#include <lcf/rpg/saveactor.h>
#include <lcf/rpg/learning.h>
#include "game_battler.h"

namespace lcf {
namespace rpg {
class Actor;
class Skill;
class BattleCommand;
class Item;
class Class;
} // namespace rpg
} // namespace lcf
#include "string_view.h"

class PendingMessage;

Expand Down Expand Up @@ -245,14 +237,14 @@ class Game_Actor final : public Game_Battler {
*
* @return name.
*/
const std::string& GetName() const override;
StringView GetName() const override;

/**
* Gets actor character sprite filename.
*
* @return character sprite filename.
*/
const std::string& GetSpriteName() const override;
StringView GetSpriteName() const override;

/**
* Gets actor character sprite index.
Expand All @@ -271,7 +263,7 @@ class Game_Actor final : public Game_Battler {
*
* @return face graphic filename.
*/
const std::string& GetFaceName() const;
StringView GetFaceName() const;

/**
* Gets actor face graphic index.
Expand Down Expand Up @@ -681,7 +673,7 @@ class Game_Actor final : public Game_Battler {
*
* @return name of skill menu item
*/
const std::string& GetSkillName() const;
StringView GetSkillName() const;

/**
* Sets new actor name.
Expand Down Expand Up @@ -764,7 +756,7 @@ class Game_Actor final : public Game_Battler {
*
* @return Rpg2k3 hero class name
*/
std::string GetClassName() const;
StringView GetClassName() const;

/**
* Gets battle commands.
Expand Down Expand Up @@ -889,7 +881,7 @@ inline void Game_Actor::SetName(const std::string &new_name) {
}


inline const std::string& Game_Actor::GetName() const {
inline StringView Game_Actor::GetName() const {
return GetData().name;
}

Expand All @@ -901,7 +893,7 @@ inline const std::string& Game_Actor::GetTitle() const {
return GetData().title;
}

inline const std::string& Game_Actor::GetSpriteName() const {
inline StringView Game_Actor::GetSpriteName() const {
return GetData().sprite_name;
}

Expand All @@ -913,7 +905,7 @@ inline int Game_Actor::GetSpriteTransparency() const {
return GetData().transparency;
}

inline const std::string& Game_Actor::GetFaceName() const {
inline StringView Game_Actor::GetFaceName() const {
return GetData().face_name;
}

Expand Down
7 changes: 1 addition & 6 deletions src/game_battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define EP_GAME_BATTLE_H

#include <functional>
#include <lcf/rpg/fwd.h>
#include <lcf/rpg/system.h>
#include <lcf/rpg/troop.h>
#include "teleport_target.h"
Expand All @@ -31,12 +32,6 @@ class Game_Actor;
class Game_Interpreter;
class Spriteset_Battle;

namespace lcf {
namespace rpg {
class EventPage;
} // namespace rpg
} // namespace lcf

enum class BattleResult {
Victory,
Escape,
Expand Down
60 changes: 30 additions & 30 deletions src/game_battlealgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ std::string Game_BattleAlgorithm::AlgorithmBase::GetDeathMessage() const {

bool is_ally = GetTarget()->GetType() == Game_Battler::Type_Ally;
const lcf::rpg::State* state = lcf::ReaderUtil::GetElement(lcf::Data::states, 1);
const std::string& message = is_ally ? state->message_actor
StringView message = is_ally ? state->message_actor
: state->message_enemy;

if (Player::IsRPG2kE()) {
Expand All @@ -369,15 +369,15 @@ std::string Game_BattleAlgorithm::AlgorithmBase::GetDeathMessage() const {
);
}
else {
return GetTarget()->GetName() + message;
return ToString(GetTarget()->GetName()) + ToString(message);
}
}

lcf::rpg::State::Restriction Game_BattleAlgorithm::AlgorithmBase::GetSourceRestrictionWhenStarted() const {
return source_restriction;
}

std::string Game_BattleAlgorithm::AlgorithmBase::GetAttackFailureMessage(const std::string& message) const {
std::string Game_BattleAlgorithm::AlgorithmBase::GetAttackFailureMessage(StringView message) const {
if (Player::IsRPG2kE()) {
return Utils::ReplacePlaceholders(
message,
Expand All @@ -386,11 +386,11 @@ std::string Game_BattleAlgorithm::AlgorithmBase::GetAttackFailureMessage(const s
);
}
else {
return GetTarget()->GetName() + message;
return ToString(GetTarget()->GetName()) + ToString(message);
}
}

std::string Game_BattleAlgorithm::AlgorithmBase::GetHpSpRecoveredMessage(int value, const std::string& points) const {
std::string Game_BattleAlgorithm::AlgorithmBase::GetHpSpRecoveredMessage(int value, StringView points) const {
if (Player::IsRPG2kE()) {
return Utils::ReplacePlaceholders(
lcf::Data::terms.hp_recovery,
Expand Down Expand Up @@ -420,7 +420,7 @@ std::string Game_BattleAlgorithm::AlgorithmBase::GetHpSpRecoveredMessage(int val
std::string Game_BattleAlgorithm::AlgorithmBase::GetUndamagedMessage() const {
bool target_is_ally = (GetTarget()->GetType() ==
Game_Battler::Type_Ally);
const std::string& message = target_is_ally ?
StringView message = target_is_ally ?
lcf::Data::terms.actor_undamaged :
lcf::Data::terms.enemy_undamaged;

Expand All @@ -432,14 +432,14 @@ std::string Game_BattleAlgorithm::AlgorithmBase::GetUndamagedMessage() const {
);
}
else {
return GetTarget()->GetName() + message;
return ToString(GetTarget()->GetName()) + ToString(message);
}
}

std::string Game_BattleAlgorithm::AlgorithmBase::GetCriticalHitMessage() const {
bool target_is_ally = (GetTarget()->GetType() ==
Game_Battler::Type_Ally);
const std::string& message = target_is_ally ?
StringView message = target_is_ally ?
lcf::Data::terms.actor_critical :
lcf::Data::terms.enemy_critical;

Expand All @@ -451,14 +451,14 @@ std::string Game_BattleAlgorithm::AlgorithmBase::GetCriticalHitMessage() const {
);
}
else {
return message;
return ToString(message);
}
}

std::string Game_BattleAlgorithm::AlgorithmBase::GetHpSpAbsorbedMessage(int value, const std::string& points) const {
std::string Game_BattleAlgorithm::AlgorithmBase::GetHpSpAbsorbedMessage(int value, StringView points) const {
bool target_is_ally = (GetTarget()->GetType() ==
Game_Battler::Type_Ally);
const std::string& message = target_is_ally ?
StringView message = target_is_ally ?
lcf::Data::terms.actor_hp_absorbed :
lcf::Data::terms.enemy_hp_absorbed;

Expand Down Expand Up @@ -492,7 +492,7 @@ std::string Game_BattleAlgorithm::AlgorithmBase::GetHpSpAbsorbedMessage(int valu
std::string Game_BattleAlgorithm::AlgorithmBase::GetDamagedMessage() const {
bool target_is_ally = (GetTarget()->GetType() ==
Game_Battler::Type_Ally);
const std::string& message = target_is_ally ?
StringView message = target_is_ally ?
lcf::Data::terms.actor_damaged :
lcf::Data::terms.enemy_damaged;
int value = GetAffectedHp();
Expand Down Expand Up @@ -520,8 +520,8 @@ std::string Game_BattleAlgorithm::AlgorithmBase::GetDamagedMessage() const {
}
}

std::string Game_BattleAlgorithm::AlgorithmBase::GetParameterChangeMessage(bool is_positive, int value, const std::string& points) const {
const std::string& message = is_positive ?
std::string Game_BattleAlgorithm::AlgorithmBase::GetParameterChangeMessage(bool is_positive, int value, StringView points) const {
StringView message = is_positive ?
lcf::Data::terms.parameter_increase :
lcf::Data::terms.parameter_decrease;

Expand Down Expand Up @@ -552,7 +552,7 @@ std::string Game_BattleAlgorithm::AlgorithmBase::GetParameterChangeMessage(bool
}
}

std::string Game_BattleAlgorithm::AlgorithmBase::GetStateMessage(const std::string& message) const {
std::string Game_BattleAlgorithm::AlgorithmBase::GetStateMessage(StringView message) const {
if (Player::IsRPG2kE()) {
return Utils::ReplacePlaceholders(
message,
Expand All @@ -561,12 +561,12 @@ std::string Game_BattleAlgorithm::AlgorithmBase::GetStateMessage(const std::stri
);
}
else {
return GetTarget()->GetName() + message;
return ToString(GetTarget()->GetName()) + ToString(message);
}
}

std::string Game_BattleAlgorithm::AlgorithmBase::GetAttributeShiftMessage( const std::string& attribute) const {
const std::string& message = IsPositive() ?
std::string Game_BattleAlgorithm::AlgorithmBase::GetAttributeShiftMessage(StringView attribute) const {
StringView message = IsPositive() ?
lcf::Data::terms.resistance_increase :
lcf::Data::terms.resistance_decrease;
std::stringstream ss;
Expand Down Expand Up @@ -1110,7 +1110,7 @@ std::string Game_BattleAlgorithm::Normal::GetStartMessage() const {
);
}
else {
return source->GetName() + lcf::Data::terms.attacking;
return ToString(source->GetName()) + ToString(lcf::Data::terms.attacking);
}
}
else {
Expand Down Expand Up @@ -1418,11 +1418,11 @@ std::string Game_BattleAlgorithm::Skill::GetStartMessage() const {
);
}
else {
return source->GetName() + skill.using_message1;
return ToString(source->GetName()) + ToString(skill.using_message1);
}
}
else {
return skill.name;
return ToString(skill.name);
}
}

Expand All @@ -1444,7 +1444,7 @@ std::string Game_BattleAlgorithm::Skill::GetSecondStartMessage() const {
);
}
else {
return skill.using_message2;
return ToString(skill.using_message2);
}
}
else {
Expand Down Expand Up @@ -1678,10 +1678,10 @@ std::string Game_BattleAlgorithm::Item::GetStartMessage() const {
particle = "は";
else
particle = " ";
return source->GetName() + particle + item.name + lcf::Data::terms.use_item;
return ToString(source->GetName()) + particle + ToString(item.name) + ToString(lcf::Data::terms.use_item);
}
else {
return item.name;
return ToString(item.name);
}
}

Expand Down Expand Up @@ -1716,7 +1716,7 @@ std::string Game_BattleAlgorithm::Defend::GetStartMessage() const {
);
}
else if (Player::IsRPG2k()) {
return source->GetName() + lcf::Data::terms.defending;
return ToString(source->GetName()) + ToString(lcf::Data::terms.defending);
}
else {
return "";
Expand Down Expand Up @@ -1750,7 +1750,7 @@ std::string Game_BattleAlgorithm::Observe::GetStartMessage() const {
);
}
else if (Player::IsRPG2k()) {
return source->GetName() + lcf::Data::terms.observing;
return ToString(source->GetName()) + ToString(lcf::Data::terms.observing);
}
else {
return "";
Expand All @@ -1777,7 +1777,7 @@ std::string Game_BattleAlgorithm::Charge::GetStartMessage() const {
);
}
else if (Player::IsRPG2k()) {
return source->GetName() + lcf::Data::terms.focus;
return ToString(source->GetName()) + ToString(lcf::Data::terms.focus);
}
else {
return "";
Expand Down Expand Up @@ -1808,7 +1808,7 @@ std::string Game_BattleAlgorithm::SelfDestruct::GetStartMessage() const {
);
}
else if (Player::IsRPG2k()) {
return source->GetName() + lcf::Data::terms.autodestruction;
return ToString(source->GetName()) + ToString(lcf::Data::terms.autodestruction);
}
else {
return "";
Expand Down Expand Up @@ -1888,7 +1888,7 @@ std::string Game_BattleAlgorithm::Escape::GetStartMessage() const {
}
else if (Player::IsRPG2k()) {
if (source->GetType() == Game_Battler::Type_Enemy) {
return source->GetName() + lcf::Data::terms.enemy_escape;
return ToString(source->GetName()) + ToString(lcf::Data::terms.enemy_escape);
}
}

Expand Down Expand Up @@ -1940,7 +1940,7 @@ std::string Game_BattleAlgorithm::Transform::GetStartMessage() const {
);
}
else if (Player::IsRPG2k()) {
return source->GetName() + lcf::Data::terms.enemy_transform;
return ToString(source->GetName()) + ToString(lcf::Data::terms.enemy_transform);
}
else {
return "";
Expand Down
Loading