Skip to content

Commit

Permalink
Battle RPG2k: Fix broken Japanese messages if the encoding is CP932
Browse files Browse the repository at this point in the history
  • Loading branch information
kakurasan committed Oct 14, 2016
1 parent 0a9b449 commit 953f1fd
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 17 deletions.
16 changes: 12 additions & 4 deletions src/game_actor.cpp
Expand Up @@ -28,6 +28,11 @@
#include "rpg_skill.h"
#include "util_macro.h"

/** Interprets char literals as utf-8 */
#ifdef _MSC_VER
#pragma execution_character_set("utf-8")
#endif

static int max_hp_value() {
return Player::IsRPG2k() ? 999 : 9999;
}
Expand Down Expand Up @@ -598,12 +603,15 @@ void Game_Actor::ChangeLevel(int new_level, bool level_up_message) {
if (new_level > old_level) {
if (level_up_message) {
std::stringstream ss;
ss << GetData().name << " ";
ss << GetData().name;
if (Player::IsRPG2k3E()) {
ss << Data::terms.level_up << " ";
ss << Data::terms.level << " " << new_level;
ss << " " << Data::terms.level_up << " ";
ss << " " << Data::terms.level << " " << new_level;
} else {
ss << Data::terms.level << " " << new_level;
if (Player::IsCP932())
ss << "" << Data::terms.level << " " << new_level << " ";
else
ss << " " << Data::terms.level << " " << new_level;
ss << Data::terms.level_up;
}
Game_Message::texts.push_back(ss.str());
Expand Down
75 changes: 62 additions & 13 deletions src/game_battlealgorithm.cpp
Expand Up @@ -40,6 +40,11 @@
#include "sprite_battler.h"
#include "utils.h"

/** Interprets char literals as utf-8 */
#ifdef _MSC_VER
#pragma execution_character_set("utf-8")
#endif

Game_BattleAlgorithm::AlgorithmBase::AlgorithmBase(Game_Battler* source) :
source(source), no_target(true), first_attack(true) {
Reset();
Expand Down Expand Up @@ -199,8 +204,10 @@ void Game_BattleAlgorithm::AlgorithmBase::GetResultMessages(std::vector<std::str

if (IsPositive()) {
if (!(*current_target)->IsDead()) {
ss << " ";
ss << Data::terms.health_points << " " << GetAffectedHp();
if (Player::IsCP932())
ss << "" << Data::terms.health_points << "" << GetAffectedHp() << " ";
else
ss << " " << Data::terms.health_points << " " << GetAffectedHp();
ss << Data::terms.hp_recovery;
out.push_back(ss.str());
}
Expand All @@ -219,13 +226,20 @@ void Game_BattleAlgorithm::AlgorithmBase::GetResultMessages(std::vector<std::str
}
else {
if (absorb) {
ss << " " << Data::terms.health_points << " " << GetAffectedHp();
if (Player::IsCP932())
ss << (target_is_ally ? "" : "") << Data::terms.health_points << "" << GetAffectedHp() << " ";
else
ss << " " << Data::terms.health_points << " " << GetAffectedHp();
ss << (target_is_ally ?
Data::terms.actor_hp_absorbed :
Data::terms.enemy_hp_absorbed);
}
else {
ss << " " << GetAffectedHp() << (target_is_ally ?
if (Player::IsCP932())
ss << (target_is_ally ? "" : "") << " " << GetAffectedHp() << " ";
else
ss << " " << GetAffectedHp();
ss << (target_is_ally ?
Data::terms.actor_damaged :
Data::terms.enemy_damaged);
}
Expand All @@ -239,19 +253,27 @@ void Game_BattleAlgorithm::AlgorithmBase::GetResultMessages(std::vector<std::str
ss << (*current_target)->GetName();

if (IsPositive()) {
ss << " ";
ss << Data::terms.spirit_points << " " << GetAffectedSp();
if (Player::IsCP932())
ss << "" << Data::terms.spirit_points << "" << GetAffectedSp() << " ";
else
ss << " " << Data::terms.spirit_points << GetAffectedSp();
ss << Data::terms.hp_recovery;
}
else {
if (absorb) {
ss << " " << Data::terms.spirit_points << " " << GetAffectedSp();
if (Player::IsCP932())
ss << (target_is_ally ? "" : "") << Data::terms.spirit_points << "" << GetAffectedSp() << " ";
else
ss << " " << Data::terms.spirit_points << " " << GetAffectedSp();
ss << (target_is_ally ?
Data::terms.actor_hp_absorbed :
Data::terms.enemy_hp_absorbed);
}
else {
ss << " " << Data::terms.spirit_points << " " << GetAffectedSp();
if (Player::IsCP932())
ss << "" << Data::terms.spirit_points << "" << GetAffectedSp() << " " << Data::terms.parameter_decrease;
else
ss << " " << Data::terms.spirit_points << " " << GetAffectedSp();
}
}
out.push_back(ss.str());
Expand All @@ -260,28 +282,52 @@ void Game_BattleAlgorithm::AlgorithmBase::GetResultMessages(std::vector<std::str
if (GetAffectedAttack() != -1) {
std::stringstream ss;
ss << (*current_target)->GetName();
ss << " " << Data::terms.attack << " " << GetAffectedAttack();
if (Player::IsCP932())
{
ss << "" << Data::terms.attack << "" << GetAffectedAttack();
ss << " " << (IsPositive() ? Data::terms.parameter_increase : Data::terms.parameter_decrease);
}
else
ss << " " << Data::terms.attack << " " << GetAffectedAttack();
out.push_back(ss.str());
}

if (GetAffectedDefense() != -1) {
std::stringstream ss;
ss << (*current_target)->GetName();
ss << " " << Data::terms.defense << " " << GetAffectedDefense();
if (Player::IsCP932())
{
ss << "" << Data::terms.defense << "" << GetAffectedDefense();
ss << " " << (IsPositive() ? Data::terms.parameter_increase : Data::terms.parameter_decrease);
}
else
ss << " " << Data::terms.defense << " " << GetAffectedDefense();
out.push_back(ss.str());
}

if (GetAffectedSpirit() != -1) {
std::stringstream ss;
ss << (*current_target)->GetName();
ss << " " << Data::terms.spirit << " " << GetAffectedSpirit();
if (Player::IsCP932())
{
ss << "" << Data::terms.spirit << "" << GetAffectedSpirit();
ss << " " << (IsPositive() ? Data::terms.parameter_increase : Data::terms.parameter_decrease);
}
else
ss << " " << Data::terms.spirit << " " << GetAffectedSpirit();
out.push_back(ss.str());
}

if (GetAffectedAgility() != -1) {
std::stringstream ss;
ss << (*current_target)->GetName();
ss << " " << Data::terms.agility << " " << GetAffectedAgility();
if (Player::IsCP932())
{
ss << "" << Data::terms.agility << "" << GetAffectedAgility();
ss << " " << (IsPositive() ? Data::terms.parameter_increase : Data::terms.parameter_decrease);
}
else
ss << " " << Data::terms.agility << " " << GetAffectedAgility();
out.push_back(ss.str());
}

Expand Down Expand Up @@ -1003,7 +1049,10 @@ void Game_BattleAlgorithm::Item::Apply() {

std::string Game_BattleAlgorithm::Item::GetStartMessage() const {
if (Player::IsRPG2k()) {
return source->GetName() + " " + item.name + Data::terms.use_item;
if (Player::IsCP932())
return source->GetName() + "" + item.name + Data::terms.use_item;
else
return source->GetName() + " " + item.name + Data::terms.use_item;
}
else {
return item.name;
Expand Down

0 comments on commit 953f1fd

Please sign in to comment.