if( *i == sss ){
i = update_list.erase(i);
} else {
- i++;
+ ++i;
}
}
}
StreamSoundSources::iterator s = update_list.begin();
while( s != update_list.end() ){
(*s)->update();
- s++;
+ ++s;
}
}
willo_radius(200),
willo_speed(1.8f),
willo_color(0),
- glow_sprite(),
+ glow_sprite(SpriteManager::current()->create("images/creatures/ghosttree/ghosttree-glow.sprite")),
colorchange_timer(),
suck_timer(),
root_timer(),
suck_lantern(0),
willowisps()
{
- glow_sprite = SpriteManager::current()->create("images/creatures/ghosttree/ghosttree-glow.sprite");
set_colgroup_active(COLGROUP_TOUCHABLE);
SoundManager::current()->preload("sounds/tree_howling.ogg");
SoundManager::current()->preload("sounds/tree_suck.ogg");
Root::Root(const Vector& pos) :
BadGuy(pos, "images/creatures/ghosttree/root.sprite", LAYER_TILES-1),
mystate(STATE_APPEARING),
- base_sprite(),
+ base_sprite(SpriteManager::current()->create("images/creatures/ghosttree/root-base.sprite")),
offset_y(0),
hatch_timer()
{
- base_sprite = SpriteManager::current()->create("images/creatures/ghosttree/root-base.sprite");
base_sprite->set_action("appearing", 1);
base_sprite->set_animation_loops(1); // TODO: necessary because set_action ignores loops for default action
physic.enable_gravity(false);
Sector* s = Sector::current();
if (s) {
// jump a bit if we find a suitable totem
- for (std::vector<MovingObject*>::iterator i = s->moving_objects.begin(); i != s->moving_objects.end(); i++) {
+ for (std::vector<MovingObject*>::iterator i = s->moving_objects.begin(); i != s->moving_objects.end(); ++i) {
Totem* t = dynamic_cast<Totem*>(*i);
if (!t) continue;
#include "util/reader.hpp"
AmbientSound::AmbientSound(const Reader& lisp) :
- name(),
+ name(""),
position(),
dimension(),
- sample(),
+ sample(""),
sound_source(),
latency(),
distance_factor(),
currentvolume(),
volume_ptr()
{
- name="";
position.x = 0;
position.y = 0;
distance_factor = 0;
distance_bias = 0;
maximumvolume = 1;
- sample = "";
currentvolume = 0;
if (!(lisp.get("x", position.x)&&lisp.get("y", position.y))) {
name(),
position(),
dimension(),
- sample(),
+ sample(file),
sound_source(),
latency(),
distance_factor(),
distance_factor=factor*factor;
distance_bias=bias*bias;
maximumvolume=vol;
- sample=file;
// set default silence_distance
CloudParticleSystem::CloudParticleSystem() :
ParticleSystem(128),
- cloudimage()
+ cloudimage(Surface::create("images/objects/particles/cloud.png"))
{
- cloudimage = Surface::create("images/objects/particles/cloud.png");
-
virtual_width = 2000.0;
// create some random clouds
static const float DROP_TIME = .1f; // time duration between "drops" of coin rain
CoinRain::CoinRain(const Vector& pos, bool emerge) :
- sprite(),
+ sprite(SpriteManager::current()->create("images/objects/coin/coin.sprite")),
position(pos),
emerge_distance(0),
timer(),
counter(0),
drop(0)
{
- sprite = SpriteManager::current()->create("images/objects/coin/coin.sprite");
-
if(emerge) {
emerge_distance = sprite->get_height();
}
FallingCoin::FallingCoin(const Vector& start_position, const int vel_x) :
physic(),
- pos(),
- sprite()
+ pos(start_position),
+ sprite(SpriteManager::current()->create("images/objects/coin/coin.sprite"))
{
- pos = start_position;
- sprite = SpriteManager::current()->create("images/objects/coin/coin.sprite");
physic.set_velocity_y(-800);
physic.set_velocity_x(vel_x);
}
InfoBlock::~InfoBlock()
{
- for(std::vector<InfoBoxLine*>::iterator i = lines.begin(); i != lines.end(); i++) {
+ for(std::vector<InfoBoxLine*>::iterator i = lines.begin(); i != lines.end(); ++i) {
delete *i;
}
}
// first hide all other InfoBlocks' messages in same sector
Sector* parent = Sector::current();
if (!parent) return;
- for (Sector::GameObjects::iterator i = parent->gameobjects.begin(); i != parent->gameobjects.end(); i++) {
+ for (Sector::GameObjects::iterator i = parent->gameobjects.begin(); i != parent->gameobjects.end(); ++i) {
InfoBlock* block = dynamic_cast<InfoBlock*>(i->get());
if (!block) continue;
if (block != this) block->hide_message();
std::list<TileMap*> solid_tilemaps = Sector::current()->solid_tilemaps;
for (float test_x = lsx; test_x <= lex; test_x += 16) {
for (float test_y = lsy; test_y <= ley; test_y += 16) {
- for(std::list<TileMap*>::const_iterator i = solid_tilemaps.begin(); i != solid_tilemaps.end(); i++) {
+ for(std::list<TileMap*>::const_iterator i = solid_tilemaps.begin(); i != solid_tilemaps.end(); ++i) {
TileMap* solids = *i;
const Tile* tile = solids->get_tile_at(Vector(test_x, test_y));
if(!tile) continue;
Lantern::Lantern(const Vector& pos) :
Rock(pos, "images/objects/lantern/lantern.sprite"),
lightcolor(0.0f, 0.0f, 0.0f),
- lightsprite()
+ lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light.sprite"))
{
- lightsprite = SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light.sprite");
lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
updateColor();
SoundManager::current()->preload("sounds/willocatch.wav");
MovingSprite::MovingSprite(const MovingSprite& other) :
MovingObject(other),
sprite_name(),
- sprite(),
+ sprite(other.sprite->clone()),
layer(other.layer)
{
- sprite = other.sprite->clone();
}
/*
MovingSprite&
{
// free particles
for(std::vector<Particle*>::iterator i = particles.begin();
- i < particles.end(); i++)
+ i < particles.end(); ++i)
delete (*i);
}
{
// draw particles
for(std::vector<Particle*>::iterator i = particles.begin();
- i != particles.end(); i++) {
+ i != particles.end(); ++i) {
context.draw_filled_rect((*i)->pos, Vector(size,size), color,drawing_layer);
}
}
dest.move(movement);
Constraints constraints;
- for(std::list<TileMap*>::const_iterator i = Sector::current()->solid_tilemaps.begin(); i != Sector::current()->solid_tilemaps.end(); i++) {
+ for(std::list<TileMap*>::const_iterator i = Sector::current()->solid_tilemaps.begin(); i != Sector::current()->solid_tilemaps.end(); ++i) {
TileMap* solids = *i;
// FIXME Handle a nonzero tilemap offset
for(int x = starttilex; x*32 < max_x; ++x) {
int nearest_node_id = -1;
float nearest_node_dist = 0;
int id = 0;
- for (std::vector<Node>::const_iterator i = nodes.begin(); i != nodes.end(); i++, id++) {
+ for (std::vector<Node>::const_iterator i = nodes.begin(); i != nodes.end(); ++i, ++id) {
float dist = (i->position - reference_point).norm();
if ((nearest_node_id == -1) || (dist < nearest_node_dist)) {
nearest_node_id = id;
int farthest_node_id = -1;
float farthest_node_dist = 0;
int id = 0;
- for (std::vector<Node>::const_iterator i = nodes.begin(); i != nodes.end(); i++, id++) {
+ for (std::vector<Node>::const_iterator i = nodes.begin(); i != nodes.end(); ++i, ++id) {
float dist = (i->position - reference_point).norm();
if ((farthest_node_id == -1) || (dist > farthest_node_dist)) {
farthest_node_id = id;
RainSplash::RainSplash(Vector pos, bool vertical) :
sprite(),
- position(),
- frame()
+ position(pos),
+ frame(0)
{
- frame = 0;
- position = pos;
if (vertical) sprite = SpriteManager::current()->create("images/objects/particles/rainsplash-vertical.sprite");
else sprite = SpriteManager::current()->create("images/objects/particles/rainsplash.sprite");
}
}
const SpriteData::Action*
-SpriteData::get_action(const std::string act)
+SpriteData::get_action(const std::string& act)
{
Actions::iterator i = actions.find(act);
if(i == actions.end()) {
void parse_action(const Reader& lispreader, const std::string& basedir);
/** Get an action */
- const Action* get_action(const std::string act);
+ const Action* get_action(const std::string& act);
Actions actions;
std::string name;
Console::show_history(int offset_)
{
while ((offset_ > 0) && (m_history_position != m_history.end())) {
- m_history_position++;
+ ++m_history_position;
offset_--;
}
while ((offset_ < 0) && (m_history_position != m_history.begin())) {
- m_history_position--;
+ --m_history_position;
offset_++;
}
if (m_history_position == m_history.end()) {
}
int skipLines = -m_offset;
- for (std::list<std::string>::iterator i = m_buffer.m_lines.begin(); i != m_buffer.m_lines.end(); i++)
+ for (std::list<std::string>::iterator i = m_buffer.m_lines.begin(); i != m_buffer.m_lines.end(); ++i)
{
if (skipLines-- > 0) continue;
lineNo++;
void
FlipLevelTransformer::transform_path(float height, float obj_height, Path& path)
{
- for (std::vector<Path::Node>::iterator i = path.nodes.begin(); i != path.nodes.end(); i++) {
+ for (std::vector<Path::Node>::iterator i = path.nodes.begin(); i != path.nodes.end(); ++i) {
Vector& pos = i->position;
pos.y = height - pos.y - obj_height;
}
InfoBox::InfoBox(const std::string& text) :
firstline(0),
- lines(),
+ // Split text string lines into a vector
+ lines(InfoBoxLine::split(text, 400)),
images(),
arrow_scrollup(),
arrow_scrolldown()
{
- // Split text string lines into a vector
- lines = InfoBoxLine::split(text, 400);
-
try
{
// get the arrow sprites
InfoBox::~InfoBox()
{
for(std::vector<InfoBoxLine*>::iterator i = lines.begin();
- i != lines.end(); i++)
+ i != lines.end(); ++i)
delete *i;
}
InfoBoxLine::InfoBoxLine(char format_char, const std::string& text_) :
lineType(NORMAL),
- font(Resources::normal_font),
+ font(get_font_by_format_char(format_char)),
color(),
text(text_),
image()
{
- font = get_font_by_format_char(format_char);
lineType = get_linetype_by_format_char(format_char);
color = get_color_by_format_char(format_char);
if (lineType == IMAGE)
LevelIntro::LevelIntro(const Level* level_, const Statistics* best_level_statistics_) :
level(level_),
best_level_statistics(best_level_statistics_),
- player_sprite(),
+ player_sprite(SpriteManager::current()->create("images/creatures/tux/tux.sprite")),
player_sprite_py(0),
player_sprite_vy(0),
player_sprite_jump_timer()
{
- player_sprite = SpriteManager::current()->create("images/creatures/tux/tux.sprite");
player_sprite->set_action("small-walk-right");
player_sprite_jump_timer.start(graphicsRandom.randf(5,10));
}
int mnid = MNID_LANGUAGE_NEXT;
std::set<tinygettext::Language> languages = g_dictionary_manager->get_languages();
- for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); i++)
+ for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); ++i)
{
add_entry(mnid++, i->get_name());
}
int mnid = MNID_LANGUAGE_NEXT;
std::set<tinygettext::Language> languages = g_dictionary_manager->get_languages();
- for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); i++)
+ for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); ++i)
{
if (item->id == mnid++)
{
TextScroller::~TextScroller()
{
- for(std::vector<InfoBoxLine*>::iterator i = lines.begin(); i != lines.end(); i++) delete *i;
+ for(std::vector<InfoBoxLine*>::iterator i = lines.begin(); i != lines.end(); ++i) delete *i;
}
void
* in quotation marks because because the slope's gradient is taken.
* Also, this uses the movement relative to the tilemaps own movement
* (if any). --octo */
-bool Tile::check_movement_unisolid (const Vector movement) const
+bool Tile::check_movement_unisolid (const Vector& movement) const
{
int slope_info;
double mv_x;
/** Returns zero if a unisolid tile is non-solid due to the movement
* direction, non-zero if the tile is solid due to direction. */
- bool check_movement_unisolid (const Vector movement) const;
+ bool check_movement_unisolid (const Vector& movement) const;
/** Returns zero if a unisolid tile is non-solid due to the position of the
* tile and the object, non-zero if the tile is solid. */
TriggerBase::~TriggerBase()
{
// unregister remove_listener hooks, so nobody will try to call us after we've been destroyed
- for (std::list<Player*>::iterator i = losetouch_listeners.begin(); i != losetouch_listeners.end(); i++) {
+ for (std::list<Player*>::iterator i = losetouch_listeners.begin(); i != losetouch_listeners.end(); ++i) {
Player* p = *i;
p->del_remove_listener(this);
}
TriggerBase::update(float )
{
if (lasthit && !hit) {
- for (std::list<Player*>::iterator i = losetouch_listeners.begin(); i != losetouch_listeners.end(); i++) {
+ for (std::list<Player*>::iterator i = losetouch_listeners.begin(); i != losetouch_listeners.end(); ++i) {
Player* p = *i;
event(*p, EVENT_LOSETOUCH);
p->del_remove_listener(this);
void
TriggerBase::object_removed(GameObject* object)
{
- for (std::list<Player*>::iterator i = losetouch_listeners.begin(); i != losetouch_listeners.end(); i++) {
+ for (std::list<Player*>::iterator i = losetouch_listeners.begin(); i != losetouch_listeners.end(); ++i) {
Player* p = *i;
if (p == object) {
losetouch_listeners.erase(i);
// if we are in a stay_group, also clear all stay actions in this group
if (stay_group != "") {
- for (std::list<SpriteChange*>::iterator i = all_sprite_changes.begin(); i != all_sprite_changes.end(); i++) {
+ for (std::list<SpriteChange*>::iterator i = all_sprite_changes.begin(); i != all_sprite_changes.end(); ++i) {
SpriteChange* sc = *i;
if (sc->stay_group != stay_group) continue;
sc->in_stay_action = false;
}
current_tileset = NULL;
- if(solid_tilemaps.size() == 0)
+ if(solid_tilemaps.empty())
throw std::runtime_error("No solid tilemap specified");
move_to_spawnpoint("main");
{
int dirs = 0;
- for(std::list<TileMap*>::const_iterator i = solid_tilemaps.begin(); i != solid_tilemaps.end(); i++) {
+ for(std::list<TileMap*>::const_iterator i = solid_tilemaps.begin(); i != solid_tilemaps.end(); ++i) {
TileMap* tilemap = *i;
const Tile* tile = tilemap->get_tile((int)p.x, (int)p.y);
int dirdata = tile->getData();
WorldMap::get_width() const
{
float width = 0;
- for(std::list<TileMap*>::const_iterator i = solid_tilemaps.begin(); i != solid_tilemaps.end(); i++) {
+ for(std::list<TileMap*>::const_iterator i = solid_tilemaps.begin(); i != solid_tilemaps.end(); ++i) {
TileMap* solids = *i;
if (solids->get_width() > width) width = solids->get_width();
}
WorldMap::get_height() const
{
float height = 0;
- for(std::list<TileMap*>::const_iterator i = solid_tilemaps.begin(); i != solid_tilemaps.end(); i++) {
+ for(std::list<TileMap*>::const_iterator i = solid_tilemaps.begin(); i != solid_tilemaps.end(); ++i) {
TileMap* solids = *i;
if (solids->get_height() > height) height = solids->get_height();
}