Permalink
Browse files

Merge branch 'master' into HEAD

Conflicts:
	src/MapRenderer.cpp
	src/Utils.cpp
	src/Utils.h
  • Loading branch information...
2 parents 545b7e4 + e0bb78b commit 3fc09338c3028f0da4bbc3ab13323cf27ec7f5f1 @stefanbeller stefanbeller committed Apr 1, 2013
Showing with 875 additions and 1,376 deletions.
  1. +3 −0 .mailmap
  2. +3 −5 src/Animation.cpp
  3. +1 −3 src/AnimationSet.cpp
  4. +5 −4 src/Avatar.cpp
  5. +1 −1 src/BehaviorStandard.cpp
  6. +1 −1 src/CombatText.cpp
  7. +1 −1 src/Enemy.cpp
  8. +1 −1 src/EnemyGroupManager.cpp
  9. +24 −24 src/EnemyManager.cpp
  10. +0 −34 src/Entity.cpp
  11. +0 −1 src/Entity.h
  12. +12 −3 src/FileParser.cpp
  13. +12 −1 src/FileParser.h
  14. +2 −2 src/FontEngine.cpp
  15. +18 −52 src/GameStateConfig.cpp
  16. +1 −2 src/GameStateConfig.h
  17. +16 −57 src/GameStateLoad.cpp
  18. +3 −18 src/GameStateNew.cpp
  19. +3 −12 src/GameStatePlay.cpp
  20. +1 −14 src/GameStateTitle.cpp
  21. +1 −2 src/GameStateTitle.h
  22. +1 −1 src/GameSwitcher.cpp
  23. +6 −4 src/GetText.cpp
  24. +7 −24 src/ImageManager.cpp
  25. +5 −8 src/InputState.cpp
  26. +8 −23 src/ItemManager.cpp
  27. +0 −2 src/ItemManager.h
  28. +2 −2 src/LootManager.cpp
  29. +453 −461 src/MapRenderer.cpp
  30. +31 −23 src/MapRenderer.h
  31. +5 −35 src/MenuActionBar.cpp
  32. +3 −11 src/MenuActiveEffects.cpp
  33. +2 −16 src/MenuCharacter.cpp
  34. +1 −13 src/MenuConfirm.cpp
  35. +0 −1 src/MenuConfirm.h
  36. +5 −24 src/MenuEnemy.cpp
  37. +1 −13 src/MenuExit.cpp
  38. +2 −15 src/MenuInventory.cpp
  39. +3 −12 src/MenuItemStorage.cpp
  40. +2 −17 src/MenuLog.cpp
  41. +9 −17 src/MenuManager.cpp
  42. +1 −1 src/MenuMiniMap.cpp
  43. +3 −5 src/MenuNPCActions.cpp
  44. +7 −45 src/MenuPowers.cpp
  45. +2 −14 src/MenuStash.cpp
  46. +0 −3 src/MenuStash.h
  47. +5 −24 src/MenuStatBar.cpp
  48. +3 −28 src/MenuTalker.cpp
  49. +0 −2 src/MenuTalker.h
  50. +2 −14 src/MenuVendor.cpp
  51. +0 −2 src/MenuVendor.h
  52. +3 −15 src/NPC.cpp
  53. +1 −1 src/NPCManager.cpp
  54. +2 −0 src/NPCManager.h
  55. +2 −64 src/PowerManager.cpp
  56. +0 −2 src/PowerManager.h
  57. +1 −3 src/QuestLog.cpp
  58. +16 −16 src/Settings.cpp
  59. +2 −5 src/SoundManager.cpp
  60. +4 −9 src/StatBlock.cpp
  61. +7 −26 src/TileSet.cpp
  62. +98 −1 src/Utils.cpp
  63. +33 −2 src/Utils.h
  64. +4 −16 src/WidgetButton.cpp
  65. +8 −20 src/WidgetCheckBox.cpp
  66. +1 −2 src/WidgetCheckBox.h
  67. +2 −18 src/WidgetInput.cpp
  68. +3 −25 src/WidgetListBox.cpp
  69. +0 −1 src/WidgetListBox.h
  70. +1 −13 src/WidgetScrollBar.cpp
  71. +4 −12 src/WidgetSlider.cpp
  72. +0 −1 src/WidgetSlider.h
  73. +3 −14 src/WidgetTabControl.cpp
  74. +1 −3 src/WidgetTooltip.cpp
  75. +1 −9 src/main.cpp
View
@@ -1,5 +1,7 @@
# Proper Name <proper@email.xx> Commit Name <commit@email.xx>
Clint Bellanger <clintbellanger@gmail.com> clintbellanger <clintbellanger@gmail.com>
+Clint Bellanger <clintbellanger@gmail.com> unknown <cpb0001@LIB-AU16638.auburn.edu>
+Clint Bellanger <clintbellanger@gmail.com> unknown <clintbellanger@gmail.com>
Thane Brimhall <thane.brimhall@gmail.com> Thane Brimhall <thane@lenny.(none)>
Thane Brimhall <thane.brimhall@gmail.com> Thane Brimhall <tbrimhall@turtle.(none)>
Thane Brimhall <thane.brimhall@gmail.com> Thane Brimhall <thane@thane-laptop.(none)>
@@ -12,4 +14,5 @@ Chris Oelmueller <chris.oelmueller@gmail.com> Chris Oelmueller <eoc.eoc.eoc@gmai
Manuel A. Fernandez Montecelo <manuel.montezelo@gmail.com> Manuel A. Fernandez Montecelo <mafm@mafm-laptop.itsari.org>
Adrián Chaves Fernández (Gallaecio) <adriyetichaves@gmail.com> Adrian Chavez Fernandez (Gallaecio) <adriyetichaves@gmail.com>
Adrián Chaves Fernández (Gallaecio) <adriyetichaves@gmail.com> Adrian Chaves Fernandez <adriyetichaves@gmail.com>
+Henrik Andersson <hean01@users.sourceforge.net> Henrik Andersson <henrik.4e@gmail.com>
View
@@ -203,9 +203,6 @@ Renderable Animation::getCurrentFrame(int kind) {
r.offset.y = render_offset[index].y;
r.sprite = sprite;
}
- else {
- memset(&r, 0, sizeof(Renderable));
- }
return r;
}
@@ -226,9 +223,10 @@ void Animation::syncTo(const Animation *other) {
}
void Animation::setActiveFrames(const std::vector<short> &_active_frames) {
- if (_active_frames.size() == 1 && _active_frames[0] == -1)
- for (short i=0; i < number_frames; ++i)
+ if (_active_frames.size() == 1 && _active_frames[0] == -1) {
+ for (short i = 0; i < number_frames; ++i)
active_frames.push_back(i);
+ }
else
active_frames = std::vector<short>(_active_frames);
}
View
@@ -66,10 +66,8 @@ void AnimationSet::load() {
FileParser parser;
const string filename = mods->locate(name);
- if (!parser.open(filename.c_str())) {
- cout << "Error loading animation definition file: " << name << endl;
+ if (!parser.open(filename, "Error loading animation definition: " + name))
return;
- }
string _name = "";
int position = 0;
View
@@ -35,6 +35,7 @@ FLARE. If not, see http://www.gnu.org/licenses/
#include "MapRenderer.h"
#include "PowerManager.h"
#include "SharedResources.h"
+#include "Utils.h"
#include "UtilsParsing.h"
#include "UtilsMath.h"
@@ -170,7 +171,7 @@ void Avatar::loadLayerDefinitions() {
}
}
infile.close();
- } else fprintf(stderr, "Unable to open engine/hero_options.txt!\n");
+ }
// There are the positions of the items relative to layer_reference_order
// so if layer_reference_order=main,body,head,off
@@ -276,7 +277,7 @@ void Avatar::set_direction() {
target = path.back();
}
}
- stats.direction = face(target.x, target.y);
+ stats.direction = calcDirection(stats.pos, target);
} else {
if (inpt->pressing[UP] && inpt->pressing[LEFT]) stats.direction = 1;
else if (inpt->pressing[UP] && inpt->pressing[RIGHT]) stats.direction = 3;
@@ -327,7 +328,7 @@ void Avatar::handlePower(int actionbar_power) {
// is this a power that requires changing direction?
if (power.face) {
- stats.direction = face(target.x, target.y);
+ stats.direction = calcDirection(stats.pos, target);
}
switch (power.new_state) {
@@ -776,7 +777,7 @@ bool Avatar::takeHit(const Hazard &h) {
if (!stats.effects.immunity) {
if (stats.effects.forced_move) {
- float theta = powers->calcTheta(h.src_stats->pos.x, h.src_stats->pos.y, stats.pos.x, stats.pos.y);
+ float theta = calcTheta(h.src_stats->pos.x, h.src_stats->pos.y, stats.pos.x, stats.pos.y);
stats.forced_speed.x = static_cast<int>(ceil(stats.effects.forced_speed * cos(theta)));
stats.forced_speed.y = static_cast<int>(ceil(stats.effects.forced_speed * sin(theta)));
}
View
@@ -315,7 +315,7 @@ void BehaviorStandard::checkMove() {
}
}
- e->stats.direction = e->face(pursue_pos.x, pursue_pos.y);
+ e->stats.direction = calcDirection(e->stats.pos, pursue_pos);
e->stats.turn_ticks = 0;
}
}
View
@@ -54,7 +54,7 @@ CombatText::CombatText() {
}
}
infile.close();
- } else fprintf(stderr, "Unable to open engine/combat_text.txt!\n");
+ }
}
void CombatText::setCam(Point location) {
View
@@ -240,7 +240,7 @@ bool Enemy::takeHit(const Hazard &h) {
powers->effect(&stats, h.power_index);
if (stats.effects.forced_move) {
- float theta = powers->calcTheta(stats.hero_pos.x, stats.hero_pos.y, stats.pos.x, stats.pos.y);
+ float theta = calcTheta(stats.hero_pos.x, stats.hero_pos.y, stats.pos.x, stats.pos.y);
stats.forced_speed.x = static_cast<int>(ceil(stats.effects.forced_speed * cos(theta)));
stats.forced_speed.y = static_cast<int>(ceil(stats.effects.forced_speed * sin(theta)));
}
@@ -77,7 +77,7 @@ void EnemyGroupManager::parseEnemyFileAndStore(const string& filename) {
}
}
infile.close();
- } else fprintf(stderr, "Unable to open enemies/%s!\n", filename.c_str());
+ }
}
Enemy_Level EnemyGroupManager::getRandomEnemy(const std::string& category, int minlevel, int maxlevel) const {
View
@@ -201,45 +201,45 @@ void EnemyManager::logic() {
handleSpawn();
- for (unsigned int i=0; i < enemies.size(); i++) {
-
+ vector<Enemy*>::iterator it;
+ for (it = enemies.begin(); it != enemies.end(); ++it) {
// hazards are processed after Avatar and Enemy[]
// so process and clear sound effects from previous frames
// check sound effects
if (AUDIO) {
- vector<string>::iterator found = find (sfx_prefixes.begin(), sfx_prefixes.end(), enemies[i]->stats.sfx_prefix);
+ vector<string>::iterator found = find (sfx_prefixes.begin(), sfx_prefixes.end(), (*it)->stats.sfx_prefix);
unsigned pref_id = distance(sfx_prefixes.begin(), found);
if (pref_id >= sfx_prefixes.size()) {
cerr << "ERROR: enemy sfx_prefix doesn't match registered prefixes (enemy: '"
- << enemies[i]->stats.name << "', sfx_prefix: '"
- << enemies[i]->stats.sfx_prefix << "')" << endl;
+ << (*it)->stats.name << "', sfx_prefix: '"
+ << (*it)->stats.sfx_prefix << "')" << endl;
} else {
- if (enemies[i]->sfx_phys)
- snd->play(sound_phys[pref_id], GLOBAL_VIRTUAL_CHANNEL, enemies[i]->stats.pos, false);
- if (enemies[i]->sfx_ment)
- snd->play(sound_ment[pref_id], GLOBAL_VIRTUAL_CHANNEL, enemies[i]->stats.pos, false);
- if (enemies[i]->sfx_hit)
- snd->play(sound_hit[pref_id], GLOBAL_VIRTUAL_CHANNEL, enemies[i]->stats.pos, false);
- if (enemies[i]->sfx_die)
- snd->play(sound_die[pref_id], GLOBAL_VIRTUAL_CHANNEL, enemies[i]->stats.pos, false);
- if (enemies[i]->sfx_critdie)
- snd->play(sound_critdie[pref_id], GLOBAL_VIRTUAL_CHANNEL, enemies[i]->stats.pos, false);
+ if ((*it)->sfx_phys)
+ snd->play(sound_phys[pref_id], GLOBAL_VIRTUAL_CHANNEL, (*it)->stats.pos, false);
+ if ((*it)->sfx_ment)
+ snd->play(sound_ment[pref_id], GLOBAL_VIRTUAL_CHANNEL, (*it)->stats.pos, false);
+ if ((*it)->sfx_hit)
+ snd->play(sound_hit[pref_id], GLOBAL_VIRTUAL_CHANNEL, (*it)->stats.pos, false);
+ if ((*it)->sfx_die)
+ snd->play(sound_die[pref_id], GLOBAL_VIRTUAL_CHANNEL, (*it)->stats.pos, false);
+ if ((*it)->sfx_critdie)
+ snd->play(sound_critdie[pref_id], GLOBAL_VIRTUAL_CHANNEL, (*it)->stats.pos, false);
}
// clear sound flags
- enemies[i]->sfx_hit = false;
- enemies[i]->sfx_phys = false;
- enemies[i]->sfx_ment = false;
- enemies[i]->sfx_die = false;
- enemies[i]->sfx_critdie = false;
+ (*it)->sfx_hit = false;
+ (*it)->sfx_phys = false;
+ (*it)->sfx_ment = false;
+ (*it)->sfx_die = false;
+ (*it)->sfx_critdie = false;
}
// new actions this round
- enemies[i]->stats.hero_pos = hero_pos;
- enemies[i]->stats.hero_alive = hero_alive;
- enemies[i]->stats.hero_stealth = hero_stealth;
- enemies[i]->logic();
+ (*it)->stats.hero_pos = hero_pos;
+ (*it)->stats.hero_alive = hero_alive;
+ (*it)->stats.hero_stealth = hero_stealth;
+ (*it)->logic();
}
}
View
@@ -104,40 +104,6 @@ bool Entity::move() {
}
/**
- * Change direction to face the target map location
- */
-int Entity::face(int mapx, int mapy) {
- // inverting Y to convert map coordinates to standard cartesian coordinates
- int dx = mapx - stats.pos.x;
- int dy = stats.pos.y - mapy;
-
- // avoid div by zero
- if (dx == 0) {
- if (dy > 0) return 3;
- else return 7;
- }
-
- float slope = ((float)dy)/((float)dx);
- if (0.5 <= slope && slope <= 2.0) {
- if (dy > 0) return 4;
- else return 0;
- }
- if (-0.5 <= slope && slope <= 0.5) {
- if (dx > 0) return 5;
- else return 1;
- }
- if (-2.0 <= slope && slope <= -0.5) {
- if (dx > 0) return 6;
- else return 2;
- }
- if (2.0 <= slope || -2.0 >= slope) {
- if (dy > 0) return 3;
- else return 7;
- }
- return stats.direction;
-}
-
-/**
* Set the entity's current animation by name
*/
bool Entity::setAnimation(const string& animationName) {
View
@@ -44,7 +44,6 @@ class Entity {
virtual ~Entity();
bool move();
- int face(int, int);
// Each child of Entity defines its own rendering method
virtual Renderable getRender() = 0;
View
@@ -33,9 +33,13 @@ FileParser::FileParser()
, val("")
{}
-bool FileParser::open(const string& filename) {
+bool FileParser::open(const string& filename, const string &errormessage) {
+ this->filename = filename;
infile.open(filename.c_str(), ios::in);
- return infile.is_open();
+ bool ret = infile.is_open();
+ if (!ret && !errormessage.empty())
+ fprintf(stderr, "%s: %s\n", errormessage.c_str(), filename.c_str());
+ return ret;
}
void FileParser::close() {
@@ -105,7 +109,7 @@ string FileParser::nextValue() {
size_t seppos = val.find_first_of(',');
size_t alt_seppos = val.find_first_of(';');
if (alt_seppos != string::npos && alt_seppos < seppos)
- seppos = alt_seppos; // return the first ',' or ';'
+ seppos = alt_seppos; // return the first ',' or ';'
if (seppos == string::npos) {
s = val;
@@ -118,6 +122,11 @@ string FileParser::nextValue() {
return s;
}
+std::string FileParser::getFileName()
+{
+ return filename;
+}
+
FileParser::~FileParser() {
close();
}
View
@@ -31,18 +31,29 @@ FLARE. If not, see http://www.gnu.org/licenses/
class FileParser {
private:
+ std::string filename;
std::ifstream infile;
std::string line;
public:
FileParser();
~FileParser();
- bool open(const std::string& filename);
+ /**
+ * @brief open
+ * @param filename The file to be opened
+ * @param errormessage
+ * Optional parameter, will be printed to stderr together with the filename
+ * if an error occurs. If errormessage is empty, there will be no output to
+ * stderr in any case.
+ * @return true if file could be opened successfully for reading.
+ */
+ bool open(const std::string& filename, const std::string &errormessage = "Could not open text file");
void close();
bool next();
std::string nextValue(); // next value inside one line.
std::string getRawLine();
+ std::string getFileName();
bool new_section;
std::string section;
View
@@ -77,7 +77,7 @@ FontEngine::FontEngine()
}
}
infile.close();
- } else fprintf(stderr, "Unable to open engine/font_settings.txt!\n");
+ }
// set the font colors
// RGB values, the last value is 'unused'. For info,
@@ -92,7 +92,7 @@ FontEngine::FontEngine()
color_map[infile.key] = color;
}
infile.close();
- } else fprintf(stderr, "Unable to open engine/font_colors.txt!\n");
+ }
// Attempt to set the default active font
setFont("font_regular");
Oops, something went wrong.

0 comments on commit 3fc0933

Please sign in to comment.