Skip to content
Browse files

Removed use of namespace std; in all common/ engine/ and in the editor

  • Loading branch information...
1 parent 0781eec commit 2cf8bb7456c09bc1f97f8c6a81eb670e07bc1716 Yohann Ferreira committed
Showing with 514 additions and 553 deletions.
  1. +52 −50 src/common/global/global_actors.cpp
  2. +3 −5 src/common/global/global_effects.cpp
  3. +2 −3 src/common/global/global_skills.cpp
  4. +1 −5 src/common/global/global_utils.cpp
  5. +20 −19 src/common/gui/gui.cpp
  6. +18 −12 src/common/gui/gui.h
  7. +4 −5 src/common/gui/menu_window.cpp
  8. +2 −2 src/common/gui/menu_window.h
  9. +7 −9 src/common/gui/option.cpp
  10. +1 −1 src/common/gui/option.h
  11. +5 −5 src/common/gui/textbox.cpp
  12. +7 −11 src/editor/editor.cpp
  13. +2 −2 src/editor/editor.h
  14. +2 −7 src/editor/editor_main.cpp
  15. +2 −2 src/editor/grid.cpp
  16. +1 −5 src/editor/skill_editor.cpp
  17. +18 −21 src/editor/tileset.cpp
  18. +34 −35 src/engine/audio/audio.cpp
  19. +2 −2 src/engine/audio/audio.h
  20. +21 −23 src/engine/audio/audio_descriptor.cpp
  21. +4 −4 src/engine/audio/audio_descriptor.h
  22. +0 −2 src/engine/audio/audio_input.cpp
  23. +0 −2 src/engine/audio/audio_stream.cpp
  24. +1 −2 src/engine/effect_supervisor.cpp
  25. +12 −10 src/engine/input.cpp
  26. +15 −12 src/engine/mode_manager.cpp
  27. +4 −5 src/engine/script/script.cpp
  28. +2 −2 src/engine/script/script.h
  29. +28 −28 src/engine/script/script_modify.cpp
  30. +29 −29 src/engine/script/script_read.cpp
  31. +36 −38 src/engine/script/script_write.cpp
  32. +5 −12 src/engine/system.cpp
  33. +1 −3 src/engine/video/fade.cpp
  34. +45 −44 src/engine/video/image.cpp
  35. +4 −5 src/engine/video/image_base.cpp
  36. +12 −13 src/engine/video/interpolator.cpp
  37. +0 −1 src/engine/video/particle_system.cpp
  38. +25 −26 src/engine/video/shake.cpp
  39. +12 −13 src/engine/video/text.cpp
  40. +8 −8 src/engine/video/text.h
  41. +0 −1 src/engine/video/texture.cpp
  42. +18 −18 src/engine/video/texture_controller.cpp
  43. +6 −8 src/engine/video/video.cpp
  44. +1 −1 src/engine/video/video.h
  45. +1 −1 src/luabind/doc/docs.html
  46. +1 −1 src/luabind/doc/index.html
  47. +1 −1 src/modes/battle/battle.cpp
  48. +2 −2 src/modes/battle/battle_actors.cpp
  49. +1 −1 src/modes/battle/battle_command.cpp
  50. +2 −2 src/modes/battle/battle_dialogue.cpp
  51. +9 −9 src/modes/battle/battle_effects.cpp
  52. +3 −3 src/modes/battle/battle_finish.cpp
  53. +1 −1 src/modes/map/map_events.cpp
  54. +1 −1 src/modes/map/map_objects.cpp
  55. +2 −2 src/modes/map/map_tiles.cpp
  56. +1 −1 src/modes/menu/menu_views.cpp
  57. +10 −10 src/modes/shop/shop.cpp
  58. +4 −4 src/modes/shop/shop_confirm.cpp
  59. +2 −2 src/modes/shop/shop_leave.cpp
  60. +1 −1 src/modes/shop/shop_utils.cpp
View
102 src/common/global/global_actors.cpp
@@ -20,8 +20,6 @@
#include "global_effects.h"
#include "global_skills.h"
-using namespace std;
-
using namespace hoa_utils;
using namespace hoa_video;
using namespace hoa_script;
@@ -66,7 +64,7 @@ bool GlobalAttackPoint::LoadData(ReadScriptDescriptor& script) {
script.ReadTableKeys(table_keys);
for (uint32 i = 0; i < table_keys.size(); i++) {
float probability = script.ReadFloat(table_keys[i]);
- _status_effects.push_back(make_pair(static_cast<GLOBAL_STATUS>(table_keys[i]), probability));
+ _status_effects.push_back(std::make_pair(static_cast<GLOBAL_STATUS>(table_keys[i]), probability));
}
script.CloseTable();
@@ -75,8 +73,9 @@ bool GlobalAttackPoint::LoadData(ReadScriptDescriptor& script) {
if (script.IsErrorDetected()) {
if (GLOBAL_DEBUG) {
- PRINT_WARNING << "one or more errors occurred while reading the save game file - they are listed below" << std::endl;
- cerr << script.GetErrorMessages() << std::endl;
+ PRINT_WARNING << "one or more errors occurred while reading the save game file - they are listed below"
+ << std::endl
+ << script.GetErrorMessages() << std::endl;
}
return false;
}
@@ -167,7 +166,7 @@ GlobalActor::~GlobalActor() {
_armor_equipped.clear();
// Delete all skills
- for (map<uint32, GlobalSkill*>::iterator i = _skills.begin(); i != _skills.end(); i++) {
+ for (std::map<uint32, GlobalSkill*>::iterator i = _skills.begin(); i != _skills.end(); i++) {
delete i->second;
}
_skills.clear();
@@ -216,8 +215,8 @@ GlobalActor::GlobalActor(const GlobalActor& copy) {
}
// Copy all skills
- for (map<uint32, GlobalSkill*>::const_iterator i = copy._skills.begin(); i != copy._skills.end(); i++) {
- _skills.insert(make_pair(i->first, new GlobalSkill(*(i->second))));
+ for (std::map<uint32, GlobalSkill*>::const_iterator i = copy._skills.begin(); i != copy._skills.end(); i++) {
+ _skills.insert(std::make_pair(i->first, new GlobalSkill(*(i->second))));
}
}
@@ -268,8 +267,8 @@ GlobalActor& GlobalActor::operator=(const GlobalActor& copy) {
}
// Copy all skills
- for (map<uint32, GlobalSkill*>::const_iterator i = copy._skills.begin(); i != copy._skills.end(); i++) {
- _skills.insert(make_pair(i->first, new GlobalSkill(*(i->second))));
+ for (std::map<uint32, GlobalSkill*>::const_iterator i = copy._skills.begin(); i != copy._skills.end(); i++) {
+ _skills.insert(std::make_pair(i->first, new GlobalSkill(*(i->second))));
}
return *this;
}
@@ -362,7 +361,7 @@ GlobalAttackPoint* GlobalActor::GetAttackPoint(uint32 index) const {
GlobalSkill* GlobalActor::GetSkill(uint32 skill_id) const {
- map<uint32, GlobalSkill*>::const_iterator skill_location = _skills.find(skill_id);
+ std::map<uint32, GlobalSkill*>::const_iterator skill_location = _skills.find(skill_id);
if (skill_location == _skills.end()) {
IF_PRINT_WARNING(GLOBAL_DEBUG) << "actor did not have a skill with the requested skill_id: " << skill_id << std::endl;
return NULL;
@@ -761,7 +760,7 @@ void GlobalCharacterGrowth::AcknowledgeGrowth() {
_experience_level_gained = false;
_DetermineNextLevelExperience();
- string filename = "dat/actors/characters.lua";
+ std::string filename = "dat/actors/characters.lua";
ReadScriptDescriptor character_script;
if (character_script.OpenFile(filename) == false) {
IF_PRINT_WARNING(GLOBAL_DEBUG) << "failed to open character data file: " << filename << std::endl;
@@ -792,7 +791,7 @@ void GlobalCharacterGrowth::AcknowledgeGrowth() {
}
// Insert the pointer to the new skill inside of the global skills map and the skill type vector
- _character_owner->_skills.insert(make_pair(skill->GetID(), skill));
+ _character_owner->_skills.insert(std::make_pair(skill->GetID(), skill));
switch (skill->GetType()) {
case GLOBAL_SKILL_ATTACK:
_character_owner->_attack_skills.push_back(skill);
@@ -827,7 +826,7 @@ void GlobalCharacterGrowth::_AddSkill(uint32 skill_id) {
return;
}
// Make sure we don't add a skill to learn more than once
- for (vector<GlobalSkill*>::iterator i = _skills_learned.begin(); i != _skills_learned.end(); i++) {
+ for (std::vector<GlobalSkill*>::iterator i = _skills_learned.begin(); i != _skills_learned.end(); i++) {
if (skill_id == (*i)->GetID()) {
IF_PRINT_WARNING(GLOBAL_DEBUG) << "the skill to add was already present in the list of skills to learn: " << skill_id << std::endl;
return;
@@ -1041,14 +1040,14 @@ void GlobalCharacterGrowth::_ConstructPeriodicGrowth() {
// TODO: Implement a gradual growth algorithm
// TEMP: all growth is done when the experience level is gained
- _hit_points_periodic_growth.push_back(make_pair(_experience_for_next_level, _hit_points_growth));
- _skill_points_periodic_growth.push_back(make_pair(_experience_for_next_level, _skill_points_growth));
- _strength_periodic_growth.push_back(make_pair(_experience_for_next_level, _strength_growth));
- _vigor_periodic_growth.push_back(make_pair(_experience_for_next_level, _vigor_growth));
- _fortitude_periodic_growth.push_back(make_pair(_experience_for_next_level, _fortitude_growth));
- _protection_periodic_growth.push_back(make_pair(_experience_for_next_level, _protection_growth));
- _agility_periodic_growth.push_back(make_pair(_experience_for_next_level, _agility_growth));
- _evade_periodic_growth.push_back(make_pair(_experience_for_next_level, _evade_growth));
+ _hit_points_periodic_growth.push_back(std::make_pair(_experience_for_next_level, _hit_points_growth));
+ _skill_points_periodic_growth.push_back(std::make_pair(_experience_for_next_level, _skill_points_growth));
+ _strength_periodic_growth.push_back(std::make_pair(_experience_for_next_level, _strength_growth));
+ _vigor_periodic_growth.push_back(std::make_pair(_experience_for_next_level, _vigor_growth));
+ _fortitude_periodic_growth.push_back(std::make_pair(_experience_for_next_level, _fortitude_growth));
+ _protection_periodic_growth.push_back(std::make_pair(_experience_for_next_level, _protection_growth));
+ _agility_periodic_growth.push_back(std::make_pair(_experience_for_next_level, _agility_growth));
+ _evade_periodic_growth.push_back(std::make_pair(_experience_for_next_level, _evade_growth));
_hit_points_growth = 0;
_skill_points_growth = 0;
@@ -1216,8 +1215,9 @@ GlobalCharacter::GlobalCharacter(uint32 id, bool initial) :
char_script.CloseTable();
if (char_script.IsErrorDetected()) {
if (GLOBAL_DEBUG) {
- PRINT_WARNING << "one or more errors occurred while reading initial data - they are listed below" << std::endl;
- cerr << char_script.GetErrorMessages() << std::endl;
+ PRINT_WARNING << "one or more errors occurred while reading initial data - they are listed below"
+ << std::endl
+ << char_script.GetErrorMessages() << std::endl;
}
}
} // if (initial == true)
@@ -1232,7 +1232,8 @@ GlobalCharacter::GlobalCharacter(uint32 id, bool initial) :
_attack_points.push_back(new GlobalAttackPoint(this));
char_script.OpenTable(i);
if (_attack_points[i]->LoadData(char_script) == false) {
- IF_PRINT_WARNING(GLOBAL_DEBUG) << "failed to succesfully load data for attack point: " << i << std::endl;
+ IF_PRINT_WARNING(GLOBAL_DEBUG) << "failed to succesfully load data for attack point: "
+ << i << std::endl;
}
char_script.CloseTable();
}
@@ -1240,21 +1241,21 @@ GlobalCharacter::GlobalCharacter(uint32 id, bool initial) :
if (char_script.IsErrorDetected()) {
if (GLOBAL_DEBUG) {
- PRINT_WARNING << "one or more errors occurred while reading attack point data - they are listed below" << std::endl;
- cerr << char_script.GetErrorMessages() << std::endl;
+ PRINT_WARNING << "one or more errors occurred while reading attack point data - they are listed below"
+ << std::endl << char_script.GetErrorMessages() << std::endl;
}
}
// Construct the character's initial skill set if necessary
if (initial) {
// The skills table contains key/value pairs. The key indicate the level required to learn the skill and the value is the skill's id
- vector<uint32> skill_levels;
+ std::vector<uint32> skill_levels;
char_script.OpenTable("skills");
char_script.ReadTableKeys(skill_levels);
// We want to add the skills beginning with the first learned to the last. ReadTableKeys does not guarantee returing the keys in a sorted order,
// so sort the skills by level before checking each one.
- sort(skill_levels.begin(), skill_levels.end());
+ std::sort(skill_levels.begin(), skill_levels.end());
// Only add the skills for which the experience level requirements are met
for (uint32 i = 0; i < skill_levels.size(); i++) {
@@ -1270,8 +1271,8 @@ GlobalCharacter::GlobalCharacter(uint32 id, bool initial) :
char_script.CloseTable();
if (char_script.IsErrorDetected()) {
if (GLOBAL_DEBUG) {
- PRINT_WARNING << "one or more errors occurred while reading skill data - they are listed below" << std::endl;
- cerr << char_script.GetErrorMessages() << std::endl;
+ PRINT_WARNING << "one or more errors occurred while reading skill data - they are listed below"
+ << std::endl << char_script.GetErrorMessages() << std::endl;
}
}
} // if (initial)
@@ -1300,8 +1301,8 @@ GlobalCharacter::GlobalCharacter(uint32 id, bool initial) :
// Close the script file and calculate all rating totals
if (char_script.IsErrorDetected()) {
if (GLOBAL_DEBUG) {
- PRINT_WARNING << "one or more errors occurred while reading final data - they are listed below" << std::endl;
- cerr << char_script.GetErrorMessages() << std::endl;
+ PRINT_WARNING << "one or more errors occurred while reading final data - they are listed below"
+ << std::endl << char_script.GetErrorMessages() << std::endl;
}
}
char_script.CloseFile();
@@ -1336,7 +1337,7 @@ void GlobalCharacter::AddSkill(uint32 skill_id) {
}
// Insert the pointer to the new skill inside of the global skills map and the skill type vector
- _skills.insert(make_pair(skill_id, skill));
+ _skills.insert(std::make_pair(skill_id, skill));
switch (skill->GetType()) {
case GLOBAL_SKILL_ATTACK:
_attack_skills.push_back(skill);
@@ -1374,8 +1375,8 @@ GlobalEnemy::GlobalEnemy(uint32 id) :
_id = id;
// Use the id member to determine the name of the data file that the enemy is defined in
- string file_ext;
- string filename;
+ std::string file_ext;
+ std::string filename;
if (_id == 0)
PRINT_ERROR << "invalid id for loading enemy data: " << _id << std::endl;
@@ -1397,7 +1398,7 @@ GlobalEnemy::GlobalEnemy(uint32 id) :
// Attempt to load the MultiImage for the sprite's frames, which should contain one row and four columns of images
_battle_sprite_frames.assign(4, StillImage());
- string sprite_filename = enemy_data.ReadString("battle_sprites");
+ std::string sprite_filename = enemy_data.ReadString("battle_sprites");
if (!ImageDescriptor::LoadMultiImageFromElementGrid(_battle_sprite_frames, sprite_filename, 1, 4))
IF_PRINT_WARNING(GLOBAL_DEBUG) << "failed to load sprite frames for enemy: " << sprite_filename << std::endl;
@@ -1466,8 +1467,8 @@ GlobalEnemy::GlobalEnemy(uint32 id) :
if (enemy_data.IsErrorDetected()) {
if (GLOBAL_DEBUG) {
- PRINT_WARNING << "one or more errors occurred while reading the enemy data - they are listed below" << std::endl;
- cerr << enemy_data.GetErrorMessages() << std::endl;
+ PRINT_WARNING << "one or more errors occurred while reading the enemy data - they are listed below"
+ << std::endl << enemy_data.GetErrorMessages() << std::endl;
}
}
@@ -1498,7 +1499,7 @@ void GlobalEnemy::AddSkill(uint32 skill_id) {
}
// Insert the pointer to the new skill inside of the global skills map and the skill type vector
- _skills.insert(make_pair(skill_id, skill));
+ _skills.insert(std::make_pair(skill_id, skill));
}
@@ -1544,7 +1545,7 @@ void GlobalEnemy::Initialize() {
-void GlobalEnemy::DetermineDroppedObjects(vector<GlobalObject*>& objects) {
+void GlobalEnemy::DetermineDroppedObjects(std::vector<GlobalObject*>& objects) {
objects.clear();
for (uint32 i = 0; i < _dropped_objects.size(); i++) {
@@ -1588,7 +1589,7 @@ void GlobalParty::AddActor(GlobalActor* actor, int32 index) {
return;
}
else {
- vector<GlobalActor*>::iterator position = _actors.begin();
+ std::vector<GlobalActor*>::iterator position = _actors.begin();
for (int32 i = 0; i < index; i++, position++);
_actors.insert(position, actor);
}
@@ -1598,12 +1599,13 @@ void GlobalParty::AddActor(GlobalActor* actor, int32 index) {
GlobalActor* GlobalParty::RemoveActorAtIndex(uint32 index) {
if (index >= _actors.size()) {
- IF_PRINT_WARNING(GLOBAL_DEBUG) << "index argument exceeded current party size: " << index << std::endl;
+ IF_PRINT_WARNING(GLOBAL_DEBUG) << "index argument exceeded current party size: "
+ << index << std::endl;
return NULL;
}
GlobalActor* removed_actor = _actors[index];
- vector<GlobalActor*>::iterator position = _actors.begin();
+ std::vector<GlobalActor*>::iterator position = _actors.begin();
for (uint32 i = 0; i < index; i++, position++);
_actors.erase(position);
@@ -1619,7 +1621,7 @@ GlobalActor* GlobalParty::RemoveActorByID(uint32 id) {
}
GlobalActor* removed_actor = NULL;
- for (vector<GlobalActor*>::iterator position = _actors.begin(); position != _actors.end(); position++) {
+ for (std::vector<GlobalActor*>::iterator position = _actors.begin(); position != _actors.end(); position++) {
if (id == (*position)->GetID()) {
removed_actor = *position;
_actors.erase(position);
@@ -1696,8 +1698,8 @@ void GlobalParty::SwapActorsByID(uint32 first_id, uint32 second_id) {
return;
}
- vector<GlobalActor*>::iterator first_position;
- vector<GlobalActor*>::iterator second_position;
+ std::vector<GlobalActor*>::iterator first_position;
+ std::vector<GlobalActor*>::iterator second_position;
for (first_position = _actors.begin(); first_position != _actors.end(); first_position++) {
if ((*first_position)->GetID() == first_id)
break;
@@ -1751,7 +1753,7 @@ GlobalActor* GlobalParty::ReplaceActorByID(uint32 id, GlobalActor* new_actor) {
}
GlobalActor* removed_actor = NULL;
- for (vector<GlobalActor*>::iterator position = _actors.begin(); position != _actors.end(); position++) {
+ for (std::vector<GlobalActor*>::iterator position = _actors.begin(); position != _actors.end(); position++) {
if ((*position)->GetID() == id) {
removed_actor = *position;
*position = new_actor;
@@ -1777,13 +1779,13 @@ float GlobalParty::AverageExperienceLevel() const {
}
void GlobalParty::AddHitPoints(uint32 hp) {
- for (vector<GlobalActor*>::iterator i = _actors.begin(); i != _actors.end(); i++) {
+ for (std::vector<GlobalActor*>::iterator i = _actors.begin(); i != _actors.end(); i++) {
(*i)->AddHitPoints(hp);
}
}
void GlobalParty::AddSkillPoints(uint32 sp) {
- for (vector<GlobalActor*>::iterator i = _actors.begin(); i != _actors.end(); i++) {
+ for (std::vector<GlobalActor*>::iterator i = _actors.begin(); i != _actors.end(); i++) {
(*i)->AddSkillPoints(sp);
}
}
View
8 src/common/global/global_effects.cpp
@@ -18,8 +18,6 @@
#include "engine/system.h"
-using namespace std;
-
using namespace hoa_utils;
using namespace hoa_script;
@@ -27,7 +25,7 @@ using namespace hoa_system;
namespace hoa_global {
-string GetElementName(GLOBAL_ELEMENTAL type) {
+std::string GetElementName(GLOBAL_ELEMENTAL type) {
switch (type) {
case GLOBAL_ELEMENTAL_FIRE:
return Translate("Fire");
@@ -52,8 +50,8 @@ string GetElementName(GLOBAL_ELEMENTAL type) {
-string GetStatusName(GLOBAL_STATUS type) {
- string result;
+std::string GetStatusName(GLOBAL_STATUS type) {
+ std::string result;
int32 table_id = static_cast<int32>(type);
ReadScriptDescriptor& script_file = GlobalManager->GetStatusEffectsScript();
View
5 src/common/global/global_skills.cpp
@@ -19,7 +19,6 @@
#include "global_skills.h"
#include "global.h"
-using namespace std;
using namespace hoa_utils;
using namespace hoa_video;
using namespace hoa_script;
@@ -153,11 +152,11 @@ bool GlobalSkill::ExecuteBattleFunction(private_battle::BattleActor *user, priva
try {
ScriptCallFunction<void>(_battle_execute_function, user, target);
}
- catch (luabind::error err) {
+ catch (const luabind::error& err) {
ScriptManager->HandleLuaError(err);
return false;
}
- catch (luabind::cast_failed e) {
+ catch (const luabind::cast_failed& e) {
ScriptManager->HandleCastError(e);
return false;
}
View
6 src/common/global/global_utils.cpp
@@ -18,17 +18,13 @@
#include "engine/system.h"
-using namespace std;
-
using namespace hoa_utils;
-
using namespace hoa_system;
-
using namespace hoa_global::private_global;
namespace hoa_global {
-string GetTargetText(GLOBAL_TARGET target) {
+std::string GetTargetText(GLOBAL_TARGET target) {
switch (target) {
case GLOBAL_TARGET_SELF_POINT:
return Translate("Self — Point");
View
39 src/common/gui/gui.cpp
@@ -7,12 +7,11 @@
// See http://www.gnu.org/copyleft/gpl.html for details.
///////////////////////////////////////////////////////////////////////////////
-#include "engine/video/video.h"
#include "gui.h"
+#include "engine/video/video.h"
#include "common/gui/menu_window.h"
-using namespace std;
using namespace hoa_utils;
using namespace hoa_video;
@@ -219,7 +218,7 @@ bool GUISystem::SingletonInitialize() {
-bool GUISystem::LoadMenuSkin(std::string skin_name, std::string border_image, std::string background_image, bool make_default)
+bool GUISystem::LoadMenuSkin(const std::string& skin_name, const std::string& border_image, const std::string& background_image, bool make_default)
{
return LoadMenuSkin(skin_name, border_image, background_image,
Color::clear, Color::clear, Color::clear, Color::clear, make_default);
@@ -227,7 +226,7 @@ bool GUISystem::LoadMenuSkin(std::string skin_name, std::string border_image, st
-bool GUISystem::LoadMenuSkin(std::string skin_name, std::string border_image, Color background_color, bool make_default)
+bool GUISystem::LoadMenuSkin(const std::string& skin_name, const std::string& border_image, const Color& background_color, bool make_default)
{
return LoadMenuSkin(skin_name, border_image, "", background_color, background_color,
background_color, background_color, make_default);
@@ -235,8 +234,9 @@ bool GUISystem::LoadMenuSkin(std::string skin_name, std::string border_image, Co
-bool GUISystem::LoadMenuSkin(std::string skin_name, std::string border_image, Color top_left, Color top_right,
- Color bottom_left, Color bottom_right, bool make_default)
+bool GUISystem::LoadMenuSkin(const std::string& skin_name, const std::string& border_image,
+ const Color& top_left, const Color& top_right,
+ const Color& bottom_left, const Color& bottom_right, bool make_default)
{
return LoadMenuSkin(skin_name, border_image, "", top_left, top_right,
bottom_left, bottom_right, make_default);
@@ -244,8 +244,9 @@ bool GUISystem::LoadMenuSkin(std::string skin_name, std::string border_image, Co
-bool GUISystem::LoadMenuSkin(std::string skin_name, std::string border_image, std::string background_image,
- Color background_color, bool make_default)
+bool GUISystem::LoadMenuSkin(const std::string& skin_name, const std::string& border_image,
+ const std::string& background_image,
+ const Color& background_color, bool make_default)
{
return LoadMenuSkin(skin_name, border_image, background_image, background_color,
background_color, background_color, background_color, make_default);
@@ -253,8 +254,8 @@ bool GUISystem::LoadMenuSkin(std::string skin_name, std::string border_image, st
-bool GUISystem::LoadMenuSkin(string skin_name, string border_image, string background_image,
- Color top_left, Color top_right, Color bottom_left, Color bottom_right, bool make_default)
+bool GUISystem::LoadMenuSkin(const std::string& skin_name, const std::string& border_image, const std::string& background_image,
+ const Color& top_left, const Color& top_right, const Color& bottom_left, const Color& bottom_right, bool make_default)
{
// ----- (1) Check that the skin_name is not already used by another skin
if (_menu_skins.find(skin_name) != _menu_skins.end()) {
@@ -262,7 +263,7 @@ bool GUISystem::LoadMenuSkin(string skin_name, string border_image, string backg
return false;
}
- _menu_skins.insert(make_pair(skin_name, MenuSkin()));
+ _menu_skins.insert(std::make_pair(skin_name, MenuSkin()));
MenuSkin& new_skin = _menu_skins[skin_name];
// ----- (2) Load the MultiImage containing the borders of the skin.
@@ -313,7 +314,7 @@ bool GUISystem::LoadMenuSkin(string skin_name, string border_image, string backg
-void GUISystem::SetDefaultMenuSkin(std::string& skin_name) {
+void GUISystem::SetDefaultMenuSkin(const std::string& skin_name) {
if (_menu_skins.find(skin_name) == _menu_skins.end()) {
IF_PRINT_WARNING(VIDEO_DEBUG) << "the skin name " << skin_name << " was not registered" << std::endl;
return;
@@ -324,7 +325,7 @@ void GUISystem::SetDefaultMenuSkin(std::string& skin_name) {
-void GUISystem::DeleteMenuSkin(std::string& skin_name) {
+void GUISystem::DeleteMenuSkin(const std::string& skin_name) {
if (_menu_skins.find(skin_name) == _menu_skins.end()) {
IF_PRINT_WARNING(VIDEO_DEBUG) << "the skin name " << skin_name << " was not registered" << std::endl;
return;
@@ -332,7 +333,7 @@ void GUISystem::DeleteMenuSkin(std::string& skin_name) {
MenuSkin* dead_skin = &_menu_skins[skin_name];
- map<uint32, MenuWindow*>::iterator i = _menu_windows.begin();
+ std::map<uint32, MenuWindow*>::iterator i = _menu_windows.begin();
while (i != _menu_windows.end()) {
if (dead_skin == i->second->_skin) {
IF_PRINT_WARNING(VIDEO_DEBUG) << "the MenuSkin \"" << skin_name << "\" was not deleted because a MenuWindow object was found to be using it" << std::endl;
@@ -344,7 +345,7 @@ void GUISystem::DeleteMenuSkin(std::string& skin_name) {
_menu_skins.erase(skin_name);
}
-bool GUISystem::IsMenuSkinAvailable(std::string& skin_name) const {
+bool GUISystem::IsMenuSkinAvailable(const std::string& skin_name) const {
if (_menu_skins.find(skin_name) == _menu_skins.end()) {
return false;
}
@@ -353,7 +354,7 @@ bool GUISystem::IsMenuSkinAvailable(std::string& skin_name) const {
}
}
-private_gui::MenuSkin* GUISystem::_GetMenuSkin(std::string& skin_name) {
+private_gui::MenuSkin* GUISystem::_GetMenuSkin(const std::string& skin_name) {
if (_menu_skins.find(skin_name) == _menu_skins.end())
return NULL;
else
@@ -373,10 +374,10 @@ void GUISystem::_AddMenuWindow(MenuWindow* new_window) {
void GUISystem::_RemoveMenuWindow(MenuWindow* old_window) {
- map<uint32, MenuWindow*>::iterator i = _menu_windows.find(old_window->_id);
+ std::map<uint32, MenuWindow*>::iterator it = _menu_windows.find(old_window->_id);
- if (i != _menu_windows.end()) {
- _menu_windows.erase(i);
+ if (it != _menu_windows.end()) {
+ _menu_windows.erase(it);
}
else {
IF_PRINT_WARNING(VIDEO_DEBUG) << "did not find a corresponding entry in the menu windows map" << std::endl;
View
30 src/common/gui/gui.h
@@ -263,22 +263,28 @@ class GUISystem : public hoa_utils::Singleton<GUISystem> {
**/
//@{
//! \brief Loads a background image with no background colors
- bool LoadMenuSkin(std::string skin_name, std::string border_image, std::string background_image, bool make_default = false);
+ bool LoadMenuSkin(const std::string& skin_name, const std::string& border_image,
+ const std::string& background_image, bool make_default = false);
//! \brief Loads a single background color with no background image
- bool LoadMenuSkin(std::string skin_name, std::string border_image, hoa_video::Color background_color, bool make_default = false);
+ bool LoadMenuSkin(const std::string& skin_name, const std::string& border_image,
+ const hoa_video::Color& background_color, bool make_default = false);
//! \brief Loads multiple multiple background colors with no background image
- bool LoadMenuSkin(std::string skin_name, std::string border_image, hoa_video::Color top_left, hoa_video::Color top_right,
- hoa_video::Color bottom_left, hoa_video::Color bottom_right, bool make_default = false);
+ bool LoadMenuSkin(const std::string& skin_name, const std::string& border_image,
+ const hoa_video::Color& top_left, const hoa_video::Color& top_right,
+ const hoa_video::Color& bottom_left, const hoa_video::Color& bottom_right, bool make_default = false);
//! \brief Loads a background image with a single background color
- bool LoadMenuSkin(std::string skin_name, std::string border_image, std::string background_image,
- hoa_video::Color background_color, bool make_default = false);
+ bool LoadMenuSkin(const std::string& skin_name, const std::string& border_image,
+ const std::string& background_image,
+ const hoa_video::Color& background_color, bool make_default = false);
//! \brief Loads a background image with multiple background colors
- bool LoadMenuSkin(std::string skin_name, std::string border_image, std::string background_image,
- hoa_video::Color top_left, hoa_video::Color top_right, hoa_video::Color bottom_left, hoa_video::Color bottom_right, bool make_default = false);
+ bool LoadMenuSkin(const std::string& skin_name, const std::string& border_image,
+ const std::string& background_image,
+ const hoa_video::Color& top_left, const hoa_video::Color& top_right,
+ const hoa_video::Color& bottom_left, const hoa_video::Color& bottom_right, bool make_default = false);
//@}
/** \brief Deletes a menu skin that has been loaded
@@ -290,10 +296,10 @@ class GUISystem : public hoa_utils::Singleton<GUISystem> {
*** and not delete the skin. Therefore, <b>before you call this function, you must delete any and all
*** MenuWindow objects which make use of this skin, or change the skin used by those objects</b>.
**/
- void DeleteMenuSkin(std::string& skin_name);
+ void DeleteMenuSkin(const std::string& skin_name);
//! \brief Returns true if there is a menu skin avialable corresponding to the argument name
- bool IsMenuSkinAvailable(std::string& skin_name) const;
+ bool IsMenuSkinAvailable(const std::string& skin_name) const;
/** \brief Sets the default menu skin to use from the set of pre-loaded skins
*** \param skin_name The name of the already loaded menu skin that should be made the default skin
@@ -302,7 +308,7 @@ class GUISystem : public hoa_utils::Singleton<GUISystem> {
*** will occur.
*** \note This method will <b>not</b> change the skins of any active menu windows.
**/
- void SetDefaultMenuSkin(std::string& skin_name);
+ void SetDefaultMenuSkin(const std::string& skin_name);
//! \brief Returns true if GUI elements should have outlines drawn over their boundaries
bool DEBUG_DrawOutlines() const
@@ -361,7 +367,7 @@ class GUISystem : public hoa_utils::Singleton<GUISystem> {
*** \param skin_name The name of the menu skin to grab
*** \return A pointer to the MenuSkin, or NULL if the skin name was not found
**/
- private_gui::MenuSkin* _GetMenuSkin(std::string& skin_name);
+ private_gui::MenuSkin* _GetMenuSkin(const std::string& skin_name);
//! \brief Returns a pointer to the default menu skin
private_gui::MenuSkin* _GetDefaultMenuSkin() const
View
9 src/common/gui/menu_window.cpp
@@ -12,7 +12,6 @@
#include "engine/video/video.h"
#include "menu_window.h"
-using namespace std;
using namespace hoa_utils;
using namespace hoa_video;
using namespace hoa_video::private_video;
@@ -33,7 +32,7 @@ MenuWindow::MenuWindow() :
-bool MenuWindow::Create(string skin_name, float w, float h, int32 visible_flags, int32 shared_flags) {
+bool MenuWindow::Create(const std::string& skin_name, float w, float h, int32 visible_flags, int32 shared_flags) {
_skin = GUIManager->_GetMenuSkin(skin_name);
if (_skin == NULL) {
IF_PRINT_WARNING(VIDEO_DEBUG) << "the requested menu skin was not found: " << skin_name << std::endl;
@@ -242,9 +241,9 @@ void MenuWindow::Hide() {
-bool MenuWindow::IsInitialized(string& errors) {
+bool MenuWindow::IsInitialized(std::string& errors) {
errors.clear();
- ostringstream stream;
+ std::ostringstream stream;
// Check width
if (_width <= 0.0f || _width > 1024.0f)
@@ -301,7 +300,7 @@ void MenuWindow::SetDimensions(float w, float h) {
-void MenuWindow::SetMenuSkin(string& skin_name) {
+void MenuWindow::SetMenuSkin(const std::string& skin_name) {
MenuSkin* new_skin = GUIManager->_GetMenuSkin(skin_name);
if (new_skin == NULL) {
IF_PRINT_WARNING(VIDEO_DEBUG) << "the skin_name \"" << skin_name << "\" was invalid" << std::endl;
View
4 src/common/gui/menu_window.h
@@ -175,7 +175,7 @@ class MenuWindow : public private_gui::GUIElement {
*** \return False and print an error message on failure. Otherwise return true upon success.
*** \note This function <b>must</b> be called before you attempt to draw the window.
**/
- bool Create(std::string skin_name, float w, float h, int32 visible_flags = VIDEO_MENU_EDGE_ALL, int32 shared_flags = 0);
+ bool Create(const std::string& skin_name, float w, float h, int32 visible_flags = VIDEO_MENU_EDGE_ALL, int32 shared_flags = 0);
//! \note This version of the create function does not take a skin_name argument. It uses the default menu skin.
bool Create(float w, float h, int32 visible_flags = VIDEO_MENU_EDGE_ALL, int32 shared_flags = 0);
@@ -262,7 +262,7 @@ class MenuWindow : public private_gui::GUIElement {
{ _edge_shared_flags = flags; _RecreateImage(); }
//! \note This call is somewhat expensive since it has to recreate the menu window image.
- void SetMenuSkin(std::string& skin_name);
+ void SetMenuSkin(const std::string& skin_name);
void SetDisplayMode(VIDEO_MENU_DISPLAY_MODE mode);
//@}
View
16 src/common/gui/option.cpp
@@ -12,8 +12,6 @@
#include "option.h"
#include "engine/video/video.h"
-using namespace std;
-
using namespace hoa_utils;
using namespace hoa_video;
using namespace hoa_video::private_video;
@@ -159,7 +157,7 @@ void OptionBox::Update(uint32 frame_time) {
void OptionBox::Draw() {
// Do nothing if the option box is not properly initialized
if (!IsInitialized(_initialization_errors)) {
- cout << "ERROR: Could not draw OptionBox" << std::endl;
+ PRINT_ERROR << "ERROR: Could not draw OptionBox" << std::endl;
return;
}
@@ -322,9 +320,9 @@ void OptionBox::SetDimensions(float width, float height, uint8 num_cols, uint8 n
-void OptionBox::SetOptions(const vector<ustring>& option_text) {
+void OptionBox::SetOptions(const std::vector<ustring>& option_text) {
ClearOptions();
- for (vector<ustring>::const_iterator i = option_text.begin(); i != option_text.end(); i++) {
+ for (std::vector<ustring>::const_iterator i = option_text.begin(); i != option_text.end(); i++) {
const ustring& str = *i;
Option option;
@@ -386,7 +384,7 @@ void OptionBox::AddOptionElementText(uint32 option_index, const ustring& text) {
-void OptionBox::AddOptionElementImage(uint32 option_index, string& image_filename) {
+void OptionBox::AddOptionElementImage(uint32 option_index, const std::string& image_filename) {
if (option_index >= GetNumberOptions()) {
IF_PRINT_WARNING(VIDEO_DEBUG) << "out-of-range option_index argument: " << option_index << std::endl;
return;
@@ -538,8 +536,8 @@ StillImage* OptionBox::GetEmbeddedImage(uint32 index) const {
-bool OptionBox::IsInitialized(string& error_messages) {
- ostringstream s;
+bool OptionBox::IsInitialized(std::string& error_messages) {
+ std::ostringstream s;
error_messages.clear();
if (_width <= 0.0f)
@@ -821,7 +819,7 @@ bool OptionBox::_ConstructOption(const ustring& format_string, Option& op) {
}
else { // The tag contains more than 1-character
// Extract the tag string
- string tag_text = MakeStandardString(tmp.substr(1, end_position - 1));
+ std::string tag_text = MakeStandardString(tmp.substr(1, end_position - 1));
if (IsStringNumeric(tag_text)) { // Then this must be a positioning tag
new_element.type = VIDEO_OPTION_ELEMENT_POSITION;
View
2 src/common/gui/option.h
@@ -303,7 +303,7 @@ class OptionBox : public private_gui::GUIControl {
*** \param option_index The index of the option to append the image element to
*** \param filename The name of the image file to load for use in this option
**/
- void AddOptionElementImage(uint32 option_index, std::string& image_filename);
+ void AddOptionElementImage(uint32 option_index, const std::string& image_filename);
/** \brief Appends an image element to an existing option
*** \param option_index The index of the option to append the image element to
View
10 src/common/gui/textbox.cpp
@@ -12,7 +12,6 @@
#include "common/gui/menu_window.h"
#include "engine/video/video.h"
-using namespace std;
using namespace hoa_utils;
using namespace hoa_video;
using namespace hoa_video::private_video;
@@ -228,7 +227,8 @@ void TextBox::SetDisplayMode(const TEXT_DISPLAY_MODE &mode) {
void TextBox::SetDisplaySpeed(float display_speed) {
if (display_speed <= 0.0f) {
if (VIDEO_DEBUG)
- cerr << "VIDEO WARNING: TextBox::SetDisplaySpeed() failed due to an invalid display speed: " << display_speed << std::endl;
+ PRINT_ERROR << "VIDEO WARNING: TextBox::SetDisplaySpeed() failed due to an invalid display speed: "
+ << display_speed << std::endl;
return;
}
@@ -237,7 +237,7 @@ void TextBox::SetDisplaySpeed(float display_speed) {
-void TextBox::SetDisplayText(const string &text) {
+void TextBox::SetDisplayText(const std::string &text) {
SetDisplayText(MakeUnicodeString(text));
}
@@ -327,9 +327,9 @@ void TextBox::_ReformatText() {
-bool TextBox::IsInitialized(string& errors) {
+bool TextBox::IsInitialized(std::string& errors) {
errors.clear();
- ostringstream stream;
+ std::ostringstream stream;
// Check font
View
18 src/editor/editor.cpp
@@ -19,14 +19,10 @@
#include <QTableWidgetItem>
#include <QScrollBar>
-using namespace std;
-
using namespace hoa_utils;
using namespace hoa_script;
using namespace hoa_video;
-
-
namespace hoa_editor {
@@ -1658,7 +1654,7 @@ void EditorScrollArea::Resize(int width, int height) {
-vector<vector<int32> >& EditorScrollArea::GetCurrentLayer() {
+std::vector<std::vector<int32> >& EditorScrollArea::GetCurrentLayer() {
return _map->GetLayers(_map->GetContext())[_layer_id].tiles;
}
@@ -1874,7 +1870,7 @@ bool EditorScrollArea::contentsMouseMoveEvent(QMouseEvent *evt) {
bool EditorScrollArea::contentsMouseReleaseEvent(QMouseEvent *evt) {
- vector<int32>::iterator it; // used to iterate over an entire layer
+ std::vector<int32>::iterator it; // used to iterate over an entire layer
// get reference to Editor so we can access the undo stack
Editor* editor = static_cast<Editor*> (topLevelWidget());
@@ -2151,7 +2147,7 @@ void EditorScrollArea::_DeleteTile(int32 index_x, int32 index_y) {
void EditorScrollArea::_AutotileRandomize(int32& tileset_num, int32& tile_index) {
- map<int, string>::iterator it = _map->tilesets[tileset_num]->
+ std::map<int, std::string>::iterator it = _map->tilesets[tileset_num]->
autotileability.find(tile_index);
if (it != _map->tilesets[tileset_num]->autotileability.end())
@@ -2165,7 +2161,7 @@ void EditorScrollArea::_AutotileRandomize(int32& tileset_num, int32& tile_index)
read_data.OpenTable(it->second);
int32 random_index = RandomBoundedInteger(1, static_cast<int32>(read_data.GetTableSize()));
read_data.OpenTable(random_index);
- string tileset_name = read_data.ReadString(1);
+ std::string tileset_name = read_data.ReadString(1);
tile_index = read_data.ReadInt(2);
read_data.CloseTable();
tileset_num = _map->tileset_names.indexOf(
@@ -2180,7 +2176,7 @@ void EditorScrollArea::_AutotileRandomize(int32& tileset_num, int32& tile_index)
-void EditorScrollArea::_AutotileTransitions(int32& tileset_num, int32& tile_index, const string tile_group) {
+void EditorScrollArea::_AutotileTransitions(int32& tileset_num, int32& tile_index, const std::string& tile_group) {
/*
// These 2 vectors have a one-to-one correspondence. They should always
// contain 8 entries.
@@ -2379,8 +2375,8 @@ void EditorScrollArea::_AutotileTransitions(int32& tileset_num, int32& tile_inde
-TRANSITION_PATTERN_TYPE EditorScrollArea::_CheckForTransitionPattern(const string current_group,
- const vector<string>& surrounding_groups, string& border_group)
+TRANSITION_PATTERN_TYPE EditorScrollArea::_CheckForTransitionPattern(const std::string& current_group,
+ const std::vector<std::string>& surrounding_groups, std::string& border_group)
{
// Assumes that surrounding_groups always has 8 entries. Well, it's an error if it doesn't,
// and technically should never happen.
View
4 src/editor/editor.h
@@ -391,8 +391,8 @@ private slots:
//! \param tile_group The autotileable group that the current tile belongs to.
//{@
void _AutotileRandomize(int32& tileset_num, int32& tile_index);
- void _AutotileTransitions(int32& tileset_num, int32& tile_index, const std::string tile_group);
- TRANSITION_PATTERN_TYPE _CheckForTransitionPattern(const std::string current_group,
+ void _AutotileTransitions(int32& tileset_num, int32& tile_index, const std::string& tile_group);
+ TRANSITION_PATTERN_TYPE _CheckForTransitionPattern(const std::string& current_group,
const std::vector<std::string>& surrounding_groups, std::string& border_group);
//@}
View
9 src/editor/editor_main.cpp
@@ -25,20 +25,15 @@
#undef main
#endif
-using namespace std;
-
using namespace hoa_script;
-
using namespace hoa_editor;
-
-
int main(int argc, char **argv) {
#ifndef _WIN32
#ifndef __MACH__
// Look for data files in DATADIR only if they are not available in the
// current directory.
- if (ifstream("./dat/config/settings.lua") == NULL) {
+ if (std::ifstream("./dat/config/settings.lua") == NULL) {
if (chdir(PKG_DATADIR) != 0) {
PRINT_ERROR << "failed to change directory to data location" << std::endl;
}
@@ -47,7 +42,7 @@ int main(int argc, char **argv) {
#endif
#ifdef __MACH__
- string path;
+ std::string path;
path = argv[0];
// remove the binary name
path.erase(path.find_last_of('/'));
View
4 src/editor/grid.cpp
@@ -132,7 +132,7 @@ Grid::Grid(QWidget* parent, const QString& name, uint32 width, uint32 height) :
Grid::~Grid()
{
- for (vector<Tileset*>::iterator it = tilesets.begin();
+ for (std::vector<Tileset*>::iterator it = tilesets.begin();
it != tilesets.end(); it++)
delete *it;
VideoManager->SingletonDestroy();
@@ -407,7 +407,7 @@ bool Grid::LoadMap()
return false;
}
- for (vector<int32>::iterator it = vect.begin(); it != vect.end(); ++it)
+ for (std::vector<int32>::iterator it = vect.begin(); it != vect.end(); ++it)
_tile_contexts[0].layers[layer_id].tiles[y].push_back(*it);
vect.clear();
} // iterate through the rows of the layer
View
6 src/editor/skill_editor.cpp
@@ -17,16 +17,12 @@
#include "engine/script/script_read.h"
-using namespace std;
-
using namespace hoa_utils;
-
using namespace hoa_script;
using namespace hoa_global;
using namespace hoa_editor;
-
-SkillEditor::SkillEditor(QWidget *parent, const QString &name)
+SkillEditor::SkillEditor(QWidget *parent, const QString& name)
: QWidget(parent, static_cast<const char *>(name))
{
setCaption("Skill Editor");
View
39 src/editor/tileset.cpp
@@ -21,15 +21,12 @@
#include <QHeaderView>
-using namespace std;
using namespace hoa_video;
using namespace hoa_script;
-
namespace hoa_editor
{
-
////////////////////////////////////////////////////////////////////////////////
// Tileset class -- all functions
////////////////////////////////////////////////////////////////////////////////
@@ -85,7 +82,7 @@ bool Tileset::New(const QString& img_filename, bool one_image)
tiles.clear();
tiles.resize(1);
tiles[0].SetDimensions(16.0f, 16.0f);
- if (tiles[0].Load(string(img_filename.toAscii()), 16, 16) == false)
+ if (tiles[0].Load(std::string(img_filename.toAscii()), 16, 16) == false)
{
qDebug("Failed to load tileset image: %s",
img_filename.toStdString().c_str());
@@ -99,7 +96,7 @@ bool Tileset::New(const QString& img_filename, bool one_image)
for (uint32 i = 0; i < 256; i++)
tiles[i].SetDimensions(1.0f, 1.0f);
if (ImageDescriptor::LoadMultiImageFromElementGrid(tiles,
- string(img_filename.toAscii()), 16, 16) == false)
+ std::string(img_filename.toAscii()), 16, 16) == false)
{
qDebug("Failed to load tileset image: %s",
img_filename.toStdString().c_str());
@@ -108,10 +105,10 @@ bool Tileset::New(const QString& img_filename, bool one_image)
}
// Initialize the rest of the tileset data
- vector<int32> blank_entry(4, 0);
+ std::vector<int32> blank_entry(4, 0);
for (uint32 i = 0; i < 16; i++)
for (uint32 j = 0; j < 16; j++)
- walkability.insert(make_pair(i * 16 + j, blank_entry));
+ walkability.insert(std::make_pair(i * 16 + j, blank_entry));
autotileability.clear();
_animated_tiles.clear();
@@ -141,7 +138,7 @@ bool Tileset::Load(const QString& set_name, bool one_image)
tiles.clear();
tiles.resize(1);
tiles[0].SetDimensions(16.0f, 16.0f);
- if (tiles[0].Load(string(img_filename.toAscii()), 16, 16) == false)
+ if (tiles[0].Load(std::string(img_filename.toAscii()), 16, 16) == false)
return false;
}
else
@@ -151,25 +148,25 @@ bool Tileset::Load(const QString& set_name, bool one_image)
for (uint32 i = 0; i < 256; i++)
tiles[i].SetDimensions(1.0f, 1.0f);
if (ImageDescriptor::LoadMultiImageFromElementGrid(tiles,
- string(img_filename.toAscii()), 16, 16) == false)
+ std::string(img_filename.toAscii()), 16, 16) == false)
return false;
}
// Set up for reading the tileset definition file.
ReadScriptDescriptor read_data;
- if (read_data.OpenFile(string(dat_filename.toAscii()), true) == false)
+ if (read_data.OpenFile(std::string(dat_filename.toAscii()), true) == false)
{
_initialized = false;
return false;
}
- read_data.OpenTable(string(tileset_name.toAscii()));
+ read_data.OpenTable(std::string(tileset_name.toAscii()));
// Read in autotiling information.
if (read_data.DoesTableExist("autotiling") == true)
{
// Contains the keys (indeces, if you will) of this table's entries
- vector<int32> keys;
+ std::vector<int32> keys;
uint32 table_size = read_data.GetTableSize("autotiling");
read_data.OpenTable("autotiling");
@@ -182,7 +179,7 @@ bool Tileset::Load(const QString& set_name, bool one_image)
// Read in walkability information.
if (read_data.DoesTableExist("walkability") == true)
{
- vector<int32> vect; // used to read in vectors from the data file
+ std::vector<int32> vect; // used to read in vectors from the data file
read_data.OpenTable("walkability");
for (int32 i = 0; i < 16; i++)
@@ -218,8 +215,8 @@ bool Tileset::Load(const QString& set_name, bool one_image)
for (uint32 i = 1; i <= table_size; i++)
{
- _animated_tiles.push_back(vector<AnimatedTileData>());
- vector<AnimatedTileData>& tiles = _animated_tiles.back();
+ _animated_tiles.push_back(std::vector<AnimatedTileData>());
+ std::vector<AnimatedTileData>& tiles = _animated_tiles.back();
// Calculate loop end: an animated tile is comprised of a tile id
// and a time, so the loop end is really half the table size.
uint32 tile_count = read_data.GetTableSize(i) / 2;
@@ -246,8 +243,8 @@ bool Tileset::Load(const QString& set_name, bool one_image)
bool Tileset::Save()
{
- string dat_filename = string(CreateDataFilename(tileset_name).toAscii());
- string img_filename = string(CreateImageFilename(tileset_name).toAscii());
+ std::string dat_filename = std::string(CreateDataFilename(tileset_name).toAscii());
+ std::string img_filename = std::string(CreateImageFilename(tileset_name).toAscii());
WriteScriptDescriptor write_data;
if (write_data.OpenFile(dat_filename) == false)
@@ -268,7 +265,7 @@ bool Tileset::Save()
if (autotileability.empty() == false)
{
write_data.BeginTable("autotiling");
- for (map<int, string>::iterator it = autotileability.begin();
+ for (std::map<int, std::string>::iterator it = autotileability.begin();
it != autotileability.end(); it++)
write_data.WriteString((*it).first, (*it).second);
write_data.EndTable();
@@ -293,7 +290,7 @@ bool Tileset::Save()
{
write_data.WriteComment("The animated tiles table has one row per animated tile, with each entry in a row indicating which tile in the tileset is the next part of the animation, followed by the time in ms that the tile will be displayed for.");
write_data.BeginTable("animated_tiles");
- vector<uint32> vect;
+ std::vector<uint32> vect;
for (uint32 anim_tile = 0; anim_tile < _animated_tiles.size(); anim_tile++)
{
for (uint32 i = 0; i < _animated_tiles[anim_tile].size(); i++)
@@ -309,8 +306,8 @@ bool Tileset::Save()
if (write_data.IsErrorDetected() == true)
{
- cerr << "Errors were detected when saving tileset file. The errors include: " << std::endl;
- cerr << write_data.GetErrorMessages() << std::endl;
+ PRINT_ERROR << "Errors were detected when saving tileset file. The errors include: "
+ << std::endl << write_data.GetErrorMessages() << std::endl;
write_data.CloseFile();
return false;
} // errors were found
View
69 src/engine/audio/audio.cpp
@@ -24,7 +24,6 @@
#include "engine/system.h"
#include "engine/mode_manager.h"
-using namespace std;
using namespace hoa_utils;
using namespace hoa_system;
using namespace hoa_audio::private_audio;
@@ -150,13 +149,13 @@ AudioEngine::~AudioEngine() {
return;
// Delete all entries in the sound cache
- for (map<std::string, private_audio::AudioCacheElement>::iterator i = _audio_cache.begin(); i != _audio_cache.end(); i++) {
+ for (std::map<std::string, private_audio::AudioCacheElement>::iterator i = _audio_cache.begin(); i != _audio_cache.end(); i++) {
delete i->second.audio;
}
_audio_cache.clear();
// Delete all audio sources
- for (vector<AudioSource*>::iterator i = _audio_sources.begin(); i != _audio_sources.end(); i++) {
+ for (std::vector<AudioSource*>::iterator i = _audio_sources.begin(); i != _audio_sources.end(); i++) {
delete (*i);
}
_audio_sources.clear();
@@ -180,7 +179,7 @@ void AudioEngine::Update() {
if (!AUDIO_ENABLE)
return;
- for (vector<AudioSource*>::iterator i = _audio_sources.begin(); i != _audio_sources.end(); i++) {
+ for (std::vector<AudioSource*>::iterator i = _audio_sources.begin(); i != _audio_sources.end(); i++) {
if ((*i)->owner) {
(*i)->owner->_Update();
}
@@ -200,7 +199,7 @@ void AudioEngine::SetSoundVolume(float volume) {
_sound_volume = volume;
}
- for (list<SoundDescriptor*>::iterator i = _registered_sounds.begin(); i != _registered_sounds.end(); i++) {
+ for (std::vector<SoundDescriptor*>::iterator i = _registered_sounds.begin(); i != _registered_sounds.end(); i++) {
if ((*i)->_source != NULL) {
alSourcef((*i)->_source->source, AL_GAIN, _sound_volume * (*i)->GetVolume());
}
@@ -220,7 +219,7 @@ void AudioEngine::SetMusicVolume(float volume) {
_music_volume = volume;
}
- for (list<MusicDescriptor*>::iterator i = _registered_music.begin(); i != _registered_music.end(); i++) {
+ for (std::vector<MusicDescriptor*>::iterator i = _registered_music.begin(); i != _registered_music.end(); i++) {
if ((*i)->_source != NULL) {
alSourcef((*i)->_source->source, AL_GAIN, _music_volume * (*i)->GetVolume());
}
@@ -228,63 +227,63 @@ void AudioEngine::SetMusicVolume(float volume) {
}
void AudioEngine::PauseAllSounds() {
- for (list<SoundDescriptor*>::iterator i = _registered_sounds.begin();
+ for (std::vector<SoundDescriptor*>::iterator i = _registered_sounds.begin();
i != _registered_sounds.end(); i++) {
(*i)->Pause();
}
}
void AudioEngine::ResumeAllSounds() {
- for (list<SoundDescriptor*>::iterator i = _registered_sounds.begin();
+ for (std::vector<SoundDescriptor*>::iterator i = _registered_sounds.begin();
i != _registered_sounds.end(); i++) {
(*i)->Resume();
}
}
void AudioEngine::StopAllSounds() {
- for (list<SoundDescriptor*>::iterator i =_registered_sounds.begin();
+ for (std::vector<SoundDescriptor*>::iterator i =_registered_sounds.begin();
i != _registered_sounds.end(); i++) {
(*i)->Stop();
}
}
void AudioEngine::RewindAllSounds() {
- for (list<SoundDescriptor*>::iterator i = _registered_sounds.begin();
+ for (std::vector<SoundDescriptor*>::iterator i = _registered_sounds.begin();
i != _registered_sounds.end(); i++) {
(*i)->Rewind();
}
}
void AudioEngine::PauseAllMusic() {
- for (list<MusicDescriptor*>::iterator i = _registered_music.begin();
+ for (std::vector<MusicDescriptor*>::iterator i = _registered_music.begin();
i != _registered_music.end(); i++) {
(*i)->Pause();
}
}
void AudioEngine::ResumeAllMusic() {
- for (list<MusicDescriptor*>::iterator i = _registered_music.begin();
+ for (std::vector<MusicDescriptor*>::iterator i = _registered_music.begin();
i != _registered_music.end(); i++) {
(*i)->Resume();
}
}
void AudioEngine::StopAllMusic() {
- for (list<MusicDescriptor*>::iterator i = _registered_music.begin();
+ for (std::vector<MusicDescriptor*>::iterator i = _registered_music.begin();
i != _registered_music.end(); i++) {
(*i)->Stop();
}
}
void AudioEngine::RewindAllMusic() {
- for (list<MusicDescriptor*>::iterator i = _registered_music.begin();
+ for (std::vector<MusicDescriptor*>::iterator i = _registered_music.begin();
i != _registered_music.end(); i++) {
(*i)->Rewind();
}
}
void AudioEngine::FadeOutAllMusic(float time) {
- for (std::list<MusicDescriptor*>::iterator it = _registered_music.begin();
+ for (std::vector<MusicDescriptor*>::iterator it = _registered_music.begin();
it != _registered_music.end(); ++it) {
if (*it)
(*it)->FadeOut(time);
@@ -292,7 +291,7 @@ void AudioEngine::FadeOutAllMusic(float time) {
}
void AudioEngine::FadeInAllMusic(float time) {
- for (std::list<MusicDescriptor*>::iterator it = _registered_music.begin();
+ for (std::vector<MusicDescriptor*>::iterator it = _registered_music.begin();
it != _registered_music.end(); ++it) {
if (*it)
(*it)->FadeIn(time);
@@ -300,7 +299,7 @@ void AudioEngine::FadeInAllMusic(float time) {
}
void AudioEngine::FadeOutAllSounds(float time) {
- for (std::list<SoundDescriptor*>::iterator it =_registered_sounds.begin();
+ for (std::vector<SoundDescriptor*>::iterator it =_registered_sounds.begin();
it != _registered_sounds.end(); ++it) {
if (*it)
(*it)->FadeOut(time);
@@ -544,48 +543,48 @@ const std::string AudioEngine::CreateALCErrorString() {
void AudioEngine::DEBUG_PrintInfo() {
const ALCchar* c;
- cout << "*** Audio Information ***" << std::endl;
+ PRINT_WARNING << "*** Audio Information ***" << std::endl;
- cout << "Maximum number of sources: " << _max_sources << std::endl;
- cout << "Maximum audio cache size: " << _max_cache_size << std::endl;
- cout << "Default audio device: " << alcGetString(_device, ALC_DEFAULT_DEVICE_SPECIFIER) << std::endl;
- cout << "OpenAL Version: " << alGetString(AL_VERSION) << std::endl;
- cout << "OpenAL Renderer: " << alGetString(AL_RENDERER) << std::endl;
- cout << "OpenAL Vendor: " << alGetString(AL_VENDOR) << std::endl;
+ PRINT_WARNING << "Maximum number of sources: " << _max_sources << std::endl;
+ PRINT_WARNING << "Maximum audio cache size: " << _max_cache_size << std::endl;
+ PRINT_WARNING << "Default audio device: " << alcGetString(_device, ALC_DEFAULT_DEVICE_SPECIFIER) << std::endl;
+ PRINT_WARNING << "OpenAL Version: " << alGetString(AL_VERSION) << std::endl;
+ PRINT_WARNING << "OpenAL Renderer: " << alGetString(AL_RENDERER) << std::endl;
+ PRINT_WARNING << "OpenAL Vendor: " << alGetString(AL_VENDOR) << std::endl;
CheckALError();
- cout << "Available OpenAL Extensions:" << std::endl;
+ PRINT_WARNING << "Available OpenAL Extensions:" << std::endl;
c = alGetString(AL_EXTENSIONS);
bool new_extension = true;
while (c[0]) {
if (new_extension) {
- cout << " - ";
+ PRINT_WARNING << " - ";
new_extension = false;
continue;
}
else if (c[0] == ' ') {
- cout << std::endl;
+ PRINT_WARNING << std::endl;
new_extension = true;
c++;
continue;
}
- cout << c[0];
+ PRINT_WARNING << c[0];
c++;
}
}
private_audio::AudioSource* AudioEngine::_AcquireAudioSource() {
// (1) Find and return the first source that does not have an owner
- for (vector<AudioSource*>::iterator i = _audio_sources.begin(); i != _audio_sources.end(); i++) {
+ for (std::vector<AudioSource*>::iterator i = _audio_sources.begin(); i != _audio_sources.end(); i++) {
if ((*i)->owner == NULL) {
return *i;
}
}
// (2) If all sources are owned, find one that is in the initial or stopped state and change its ownership
- for (vector<AudioSource*>::iterator i = _audio_sources.begin(); i != _audio_sources.end(); i++) {
+ for (std::vector<AudioSource*>::iterator i = _audio_sources.begin(); i != _audio_sources.end(); i++) {
ALint state;
alGetSourcei((*i)->source, AL_SOURCE_STATE, &state);
if (state == AL_INITIAL || state == AL_STOPPED) {
@@ -618,13 +617,13 @@ bool AudioEngine::_LoadAudio(AudioDescriptor* audio, const std::string& filename
return false;
}
- _audio_cache.insert(make_pair(filename, AudioCacheElement(SDL_GetTicks(), audio)));
+ _audio_cache.insert(std::make_pair(filename, AudioCacheElement(SDL_GetTicks(), audio)));
return true;
}
// (2) The cache is full, so find an element to remove. First make sure that at least one piece of audio is stopped
- map<std::string, AudioCacheElement>::iterator lru_element = _audio_cache.end();
- for (map<std::string, AudioCacheElement>::iterator i = _audio_cache.begin(); i != _audio_cache.end(); i++) {
+ std::map<std::string, AudioCacheElement>::iterator lru_element = _audio_cache.end();
+ for (std::map<std::string, AudioCacheElement>::iterator i = _audio_cache.begin(); i != _audio_cache.end(); i++) {
if (i->second.audio->GetState() == AUDIO_STATE_STOPPED) {
lru_element = i;
break;
@@ -636,7 +635,7 @@ bool AudioEngine::_LoadAudio(AudioDescriptor* audio, const std::string& filename
return false;
}
- for (map<std::string, AudioCacheElement>::iterator i = _audio_cache.begin(); i != _audio_cache.end(); i++) {
+ for (std::map<std::string, AudioCacheElement>::iterator i = _audio_cache.begin(); i != _audio_cache.end(); i++) {
if (i->second.audio->GetState() == AUDIO_STATE_STOPPED && i->second.last_update_time < lru_element->second.last_update_time) {
lru_element = i;
}
@@ -650,7 +649,7 @@ bool AudioEngine::_LoadAudio(AudioDescriptor* audio, const std::string& filename
return false;
}
- _audio_cache.insert(make_pair(filename, AudioCacheElement(SDL_GetTicks(), audio)));
+ _audio_cache.insert(std::make_pair(filename, AudioCacheElement(SDL_GetTicks(), audio)));
return true;
} // bool AudioEngine::_LoadAudio(AudioDescriptor* audio, const std::string& filename)
View
4 src/engine/audio/audio.h
@@ -356,8 +356,8 @@ class AudioEngine : public hoa_utils::Singleton<AudioEngine> {
*** sound and music objects will also have their volumes updated.
**/
//@{
- std::list<SoundDescriptor*> _registered_sounds;
- std::list<MusicDescriptor*> _registered_music;
+ std::vector<SoundDescriptor*> _registered_sounds;
+ std::vector<MusicDescriptor*> _registered_music;
//@}
/** \brief A LRU cache of audio which is managed internally by the audio engine
View
44 src/engine/audio/audio_descriptor.cpp
@@ -23,7 +23,6 @@
#include "audio.h"
#include "audio_descriptor.h"
-using namespace std;
using namespace hoa_audio::private_audio;
namespace hoa_audio {
@@ -146,7 +145,7 @@ AudioDescriptor::AudioDescriptor(const AudioDescriptor& copy) :
}
}
-bool AudioDescriptor::LoadAudio(const string& filename, AUDIO_LOAD load_type, uint32 stream_buffer_size) {
+bool AudioDescriptor::LoadAudio(const std::string& filename, AUDIO_LOAD load_type, uint32 stream_buffer_size) {
if (!AUDIO_ENABLE)
return true;
@@ -159,9 +158,8 @@ bool AudioDescriptor::LoadAudio(const string& filename, AUDIO_LOAD load_type, ui
return false;
}
// Convert the file extension to uppercase and use it to create the proper input type
- string file_extension = filename.substr(filename.size() - 3, 3);
- for (string::iterator i = file_extension.begin(); i != file_extension.end(); i++)
- *i = toupper(*i);
+ std::string file_extension = filename.substr(filename.size() - 3, 3);
+ file_extension = hoa_utils::Upcase(file_extension);
// Based on the extension of the file, load properly one
if (file_extension.compare("WAV") == 0) {
@@ -547,7 +545,7 @@ void AudioDescriptor::AddOwner(hoa_mode_manager::GameMode *gm) {
return;
// Check for duplicate entries
- std::list<hoa_mode_manager::GameMode*>::const_iterator it = _owners.begin();
+ std::vector<hoa_mode_manager::GameMode*>::const_iterator it = _owners.begin();
for (; it != _owners.end(); ++it) {
if (*it == gm)
return;
@@ -556,8 +554,8 @@ void AudioDescriptor::AddOwner(hoa_mode_manager::GameMode *gm) {
_owners.push_back(gm);
}
-void AudioDescriptor::AddOwners(std::list<hoa_mode_manager::GameMode*>& owners) {
- std::list<hoa_mode_manager::GameMode*>::const_iterator it = owners.begin();
+void AudioDescriptor::AddOwners(std::vector<hoa_mode_manager::GameMode*>& owners) {
+ std::vector<hoa_mode_manager::GameMode*>::const_iterator it = owners.begin();
for(; it != owners.end(); ++it) {
AddOwner(*it);
@@ -573,7 +571,7 @@ bool AudioDescriptor::RemoveOwner(hoa_mode_manager::GameMode *gm) {
return false;
// Check for duplicate entries
- std::list<hoa_mode_manager::GameMode*>::iterator it = _owners.begin();
+ std::vector<hoa_mode_manager::GameMode*>::iterator it = _owners.begin();
for (; it != _owners.end();) {
if (*it != gm) {
++it;
@@ -601,7 +599,7 @@ void AudioDescriptor::FadeOut(float time) {
void AudioDescriptor::RemoveEffects() {
// Delete any active audio effects for the given audio descriptor
- for (std::list<AudioEffect*>::iterator it = _audio_effects.begin();
+ for (std::vector<AudioEffect*>::iterator it = _audio_effects.begin();
it != _audio_effects.end(); ++it) {
if (*it)
delete (*it);
@@ -610,7 +608,7 @@ void AudioDescriptor::RemoveEffects() {
}
void AudioDescriptor::DEBUG_PrintInfo() {
- cout << "*** Audio Descriptor Information ***" << std::endl;
+ PRINT_WARNING << "*** Audio Descriptor Information ***" << std::endl;
if (_input == NULL) {
PRINT_WARNING << "no audio data loaded" << std::endl;
@@ -641,19 +639,19 @@ void AudioDescriptor::DEBUG_PrintInfo() {
break;
}
- cout << "Filename: " << _input->GetFilename() << std::endl;
- cout << "Channels: " << num_channels << std::endl;
- cout << "Bits Per Sample: " << bits_per_sample << std::endl;
- cout << "Frequency: " << _input->GetSamplesPerSecond() << std::endl;
- cout << "Samples: " << _input->GetTotalNumberSamples() << std::endl;
- cout << "Time: " << _input->GetPlayTime() << std::endl;
+ PRINT_WARNING << "Filename: " << _input->GetFilename() << std::endl;
+ PRINT_WARNING << "Channels: " << num_channels << std::endl;
+ PRINT_WARNING << "Bits Per Sample: " << bits_per_sample << std::endl;
+ PRINT_WARNING << "Frequency: " << _input->GetSamplesPerSecond() << std::endl;
+ PRINT_WARNING << "Samples: " << _input->GetTotalNumberSamples() << std::endl;
+ PRINT_WARNING << "Time: " << _input->GetPlayTime() << std::endl;
if (_stream != NULL) {
- cout << "Audio load type: streamed" << std::endl;
- cout << "Stream buffer size (samples): " << _stream_buffer_size << std::endl;
+ PRINT_WARNING << "Audio load type: streamed" << std::endl;
+ PRINT_WARNING << "Stream buffer size (samples): " << _stream_buffer_size << std::endl;
}
else {
- cout << "Audio load type: static" << std::endl;
+ PRINT_WARNING << "Audio load type: static" << std::endl;
}
} // void AudioDescriptor::DEBUG_PrintInfo()
@@ -698,7 +696,7 @@ void AudioDescriptor::_Update() {
}
// Update all registered audio effects
- for (std::list<AudioEffect*>::iterator it = _audio_effects.begin(); it != _audio_effects.end();) {
+ for (std::vector<AudioEffect*>::iterator it = _audio_effects.begin(); it != _audio_effects.end();) {
(*it)->Update();
// If the effect is finished, delete it
@@ -886,7 +884,7 @@ SoundDescriptor::SoundDescriptor() :
SoundDescriptor::~SoundDescriptor() {
- for (list<SoundDescriptor*>::iterator i = AudioManager->_registered_sounds.begin();
+ for (std::vector<SoundDescriptor*>::iterator i = AudioManager->_registered_sounds.begin();
i != AudioManager->_registered_sounds.end(); i++) {
if (*i == this) {
AudioManager->_registered_sounds.erase(i);
@@ -931,7 +929,7 @@ MusicDescriptor::~MusicDescriptor() {
AudioManager->_active_music = NULL;
}
- for (list<MusicDescriptor*>::iterator i = AudioManager->_registered_music.begin();
+ for (std::vector<MusicDescriptor*>::iterator i = AudioManager->_registered_music.begin();
i != AudioManager->_registered_music.end(); i++) {
if (*i == this) {
AudioManager->_registered_music.erase(i);
View
8 src/engine/audio/audio_descriptor.h
@@ -301,7 +301,7 @@ class AudioDescriptor {
*** Adds multiple owners at once.
*** @see AddOwner()
**/
- void AddOwners(std::list<hoa_mode_manager::GameMode*>& owners);
+ void AddOwners(std::vector<hoa_mode_manager::GameMode*>& owners);
/**
*** Remove a game mode reference from the audio descriptor owners,
@@ -313,7 +313,7 @@ class AudioDescriptor {
/**
*** Get the list of game mode claiming ownership over the audio descriptor.
**/
- std::list<hoa_mode_manager::GameMode*>* GetOwners()
+ std::vector<hoa_mode_manager::GameMode*>* GetOwners()
{ return &_owners; }
/** \brief Fades a music or sound in as it plays
@@ -388,10 +388,10 @@ class AudioDescriptor {
*** Musics and sounds that are never owned will have to be freed manually.
*** @see AddOwner(), RemoveOwner()
**/
- std::list<hoa_mode_manager::GameMode*> _owners;
+ std::vector<hoa_mode_manager::GameMode*> _owners;
//! \brief Holds all active audio effects for this descriptor
- std::list<private_audio::AudioEffect*> _audio_effects;
+ std::vector<private_audio::AudioEffect*> _audio_effects;
/** \brief Sets the local volume control for this particular audio piece
*** \param volume The volume level to set, ranging from [0.0f, 1.0f]
View
2 src/engine/audio/audio_input.cpp
@@ -23,8 +23,6 @@
#include "audio_input.h"
#include <SDL/SDL_endian.h>
-using namespace std;
-
namespace hoa_audio {
namespace private_audio {
View
2 src/engine/audio/audio_stream.cpp
@@ -23,8 +23,6 @@
#include <cstdlib>
-using namespace std;
-
namespace hoa_audio {
namespace private_audio {
View
3 src/engine/effect_supervisor.cpp
@@ -20,7 +20,6 @@
#include "engine/audio/audio.h"
#include "engine/video/video.h"
-using namespace std;
using namespace hoa_video;
namespace hoa_mode_manager {
@@ -52,7 +51,7 @@ EffectSupervisor::EffectSupervisor()
}
-void EffectSupervisor::EnableAmbientOverlay(const string &filename,
+void EffectSupervisor::EnableAmbientOverlay(const std::string& filename,
float x_speed, float y_speed,
bool parallax) {
// Note: The StillImage class handles clearing an image
View
22 src/engine/input.cpp
@@ -22,8 +22,6 @@
#include "mode_manager.h"
#include "system.h"
-using namespace std;
-
using namespace hoa_utils;
using namespace hoa_video;
using namespace hoa_script;
@@ -40,7 +38,7 @@ bool INPUT_DEBUG = false;
// Initializes class members
InputEngine::InputEngine() {
- if (INPUT_DEBUG) cout << "INPUT: InputEngine constructor invoked" << std::endl;
+ IF_PRINT_WARNING(INPUT_DEBUG) << "INPUT: InputEngine constructor invoked" << std::endl;
_any_key_press = false;
_any_key_release = false;
_last_axis_moved = -1;
@@ -90,7 +88,8 @@ InputEngine::InputEngine() {
InputEngine::~InputEngine() {
- if (INPUT_DEBUG) cout << "INPUT: InputEngine destructor invoked" << std::endl;
+ IF_PRINT_WARNING(INPUT_DEBUG) << "INPUT: InputEngine destructor invoked"
+ << std::endl;
// If a joystick is open, close it before exiting
if (_joystick.js != NULL) {
@@ -103,7 +102,8 @@ InputEngine::~InputEngine() {
bool InputEngine::SingletonInitialize() {
// Initialize the SDL joystick subsystem
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != 0) {
- cerr << "INPUT ERROR: failed to initailize the SDL joystick subsystem" << std::endl;
+ PRINT_ERROR << "INPUT ERROR: failed to initailize the SDL joystick subsystem"
+ << std::endl;
return false;
}
@@ -131,10 +131,11 @@ void InputEngine::InitializeJoysticks()
// Loads the default key settings from the lua file and sets them back
bool InputEngine::RestoreDefaultKeys() {
// Load the settings file
- string in_filename = GetSettingsFilename();
+ std::string in_filename = GetSettingsFilename();
ReadScriptDescriptor settings_file;
if (!settings_file.OpenFile(in_filename)) {
- cerr << "INPUT ERROR: failed to open data file for reading: " << in_filename << std::endl;
+ PRINT_ERROR << "INPUT ERROR: failed to open data file for reading: "
+ << in_filename << std::endl;
return false;
}
@@ -165,10 +166,11 @@ bool InputEngine::RestoreDefaultKeys() {
bool InputEngine::RestoreDefaultJoyButtons()
{
// Load the settings file
- string in_filename = GetSettingsFilename();
+ std::string in_filename = GetSettingsFilename();
ReadScriptDescriptor settings_file;
if (settings_file.OpenFile(in_filename) == false) {
- cerr << "INPUT ERROR: failed to open data file for reading: " << in_filename << std::endl;
+ PRINT_ERROR << "INPUT ERROR: failed to open data file for reading: "
+ << in_filename << std::endl;
return false;
}
@@ -310,7 +312,7 @@ void InputEngine::_KeyEventHandler(SDL_KeyboardEvent& key_event) {
else if (key_event.keysym.sym == SDLK_s) {
// Take a screenshot of the current game
static uint32 i = 1;
- string path = "";
+ std::string path = "";
while (true)
{
path = hoa_utils::GetUserDataPath(true) + "screenshot_" + NumberToString<uint32>(i) + ".jpg";
View
27 src/engine/mode_manager.cpp
@@ -21,8 +21,6 @@
#include "modes/mode_help_window.h"
-using namespace std;
-
using namespace hoa_utils;
using namespace hoa_system;
using namespace hoa_boot;
@@ -43,7 +41,8 @@ const uint32 FADE_IN_OUT_TIME = 800;
// ****************************************************************************
GameMode::GameMode() {
- if (MODE_MANAGER_DEBUG) cout << "MODE MANAGER: GameMode constructor invoked" << std::endl;
+ IF_PRINT_WARNING(MODE_MANAGER_DEBUG)
+ << "MODE MANAGER: GameMode constructor invoked" << std::endl;
// The value of this member should later be replaced by the child class
mode_type = MODE_MANAGER_DUMMY_MODE;
@@ -51,13 +50,15 @@ GameMode::GameMode() {
GameMode::GameMode(uint8 mt) {
- if (MODE_MANAGER_DEBUG) cout << "MODE MANAGER: GameMode constructor invoked" << std::endl;
+ IF_PRINT_WARNING(MODE_MANAGER_DEBUG)
+ << "MODE MANAGER: GameMode constructor invoked" << std::endl;
mode_type = mt;
}
GameMode::~GameMode() {
- if (MODE_MANAGER_DEBUG) cout << "MODE MANAGER: GameMode destructor invoked" << std::endl;
+ IF_PRINT_WARNING(MODE_MANAGER_DEBUG)
+ << "MODE MANAGER: GameMode destructor invoked" << std::endl;
// Tells the audio manager that the mode is ending to permit freeing self-managed audio files.
AudioManager->RemoveOwner(this);
@@ -85,7 +86,8 @@ void GameMode::DrawEffects() {
// This constructor must be defined for the singleton macro
ModeEngine::ModeEngine() {
- if (MODE_MANAGER_DEBUG) cout << "MODE MANAGER: ModeEngine constructor invoked" << std::endl;
+ IF_PRINT_WARNING(MODE_MANAGER_DEBUG)
+ << "MODE MANAGER: ModeEngine constructor invoked" << std::endl;
_pop_count = 0;
_state_change = false;
_fade_out = false;
@@ -98,7 +100,8 @@ ModeEngine::ModeEngine() {
// The destructor frees all the modes still on the stack
ModeEngine::~ModeEngine() {
- if (MODE_MANAGER_DEBUG) cout << "MODE MANAGER: ModeEngine destructor invoked" << std::endl;
+ IF_PRINT_WARNING(MODE_MANAGER_DEBUG)
+ << "MODE MANAGER: ModeEngine destructor invoked" << std::endl;
// Delete any game modes on the stack
while (_game_stack.size() != 0) {
delete _game_stack.back();
@@ -309,16 +312,16 @@ void ModeEngine::DrawPostEffects() {
// Used for debugging purposes ONLY. Prints the contents of the game mode stack.
void ModeEngine::DEBUG_PrintStack() {
- cout << "MODE MANAGER DEBUG: Printing Game Stack" << std::endl;
+ PRINT_WARNING << "MODE MANAGER DEBUG: Printing Game Stack" << std::endl;
if (_game_stack.size() == 0) {
- cout << "***Game stack is empty!" << std::endl;
+ PRINT_WARNING << "***Game stack is empty!" << std::endl;
return;
}
- cout << "***top of stack***" << std::endl;
+ PRINT_WARNING << "***top of stack***" << std::endl;
for (int32 i = static_cast<int32>(_game_stack.size()) - 1; i >= 0; i--)
- cout << " index: " << i << " type: " << _game_stack[i]->mode_type << std::endl;
- cout << "***bottom of stack***" << std::endl;
+ PRINT_WARNING << " index: " << i << " type: " << _game_stack[i]->mode_type << std::endl;
+ PRINT_WARNING << "***bottom of stack***" << std::endl;
}
} // namespace hoa_mode_manager
View
9 src/engine/script/script.cpp
@@ -21,7 +21,6 @@
#include "script.h"
#include "script_read.h"
-using namespace std;
using namespace luabind;
using namespace hoa_utils;
@@ -76,17 +75,17 @@ bool ScriptEngine::IsFileOpen(const std::string& filename) {
-void ScriptEngine::HandleLuaError(luabind::error& err) {
+void ScriptEngine::HandleLuaError(const luabind::error& err) {
lua_State *state = err.state();
PRINT_ERROR << "a runtime Lua error has occured with the following error message:\n " << std::endl;
std::string k = lua_tostring(state, lua_gettop(state)) ;
- cerr << k << std::endl;
+ PRINT_ERROR << k << std::endl;
lua_pop(state, 1);
}
-void ScriptEngine::HandleCastError(luabind::cast_failed& err) {
+void ScriptEngine::HandleCastError(const luabind::cast_failed& err) {
PRINT_ERROR << "the return value of a Lua function call could not be successfully converted "
<<