diff --git a/libstage/blockgroup.cc b/libstage/blockgroup.cc index be5d99c09..05165154b 100644 --- a/libstage/blockgroup.cc +++ b/libstage/blockgroup.cc @@ -293,7 +293,7 @@ void BlockGroup::LoadBlock( Worldfile* wf, int entity ) void BlockGroup::LoadBitmap( const std::string& bitmapfile, Worldfile* wf ) { - PRINT_DEBUG1( "attempting to load bitmap \"%s\n", bitmapfile ); + PRINT_DEBUG1( "attempting to load bitmap \"%s\n", bitmapfile.c_str() ); std::string full; @@ -311,7 +311,7 @@ void BlockGroup::LoadBitmap( const std::string& bitmapfile, Worldfile* wf ) fputs( buf, stdout ); fflush( stdout ); - PRINT_DEBUG1( "attempting to load image %s", full ); + PRINT_DEBUG1( "attempting to load image %s", full.c_str() ); Color col( 1.0, 0.0, 1.0, 1.0 ); diff --git a/libstage/canvas.cc b/libstage/canvas.cc index 09a5b0deb..e9afe5731 100644 --- a/libstage/canvas.cc +++ b/libstage/canvas.cc @@ -810,10 +810,10 @@ void Canvas::renderFrame() glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); if( showOccupancy ) - ((WorldGui*)world)->DrawOccupancy(); + world->DrawOccupancy(); if( showVoxels ) - ((WorldGui*)world)->DrawVoxels(); + world->DrawVoxels(); if( ! world->rt_cells.empty() ) diff --git a/libstage/file_manager.cc b/libstage/file_manager.cc index 759e9bf50..7eef6efd1 100644 --- a/libstage/file_manager.cc +++ b/libstage/file_manager.cc @@ -58,7 +58,7 @@ namespace Stg ranOnce = true; - PRINT_DEBUG1("FileManager - INIT: %d paths in search paths\n", paths.size() ); + PRINT_DEBUG1("FileManager - INIT: %d paths in search paths\n", int(paths.size()) ); } // search the path list diff --git a/libstage/glutgraphics.cc b/libstage/glutgraphics.cc index 03e5937bb..36fa17878 100644 --- a/libstage/glutgraphics.cc +++ b/libstage/glutgraphics.cc @@ -226,7 +226,7 @@ void ExampleDriver_Register(DriverTable* table) // pre-Setup() setup. ExampleDriver::ExampleDriver(ConfigFile* cf, int section) : Driver(cf, section, false, PLAYER_MSGQUEUE_DEFAULT_MAXLEN, - PLAYER_GRAPHICS3D_CODE) + PLAYER_GRAPHICS3D_CODE), foop(0) { // Read an option from the configuration file //this->foop = cf->ReadInt(section, "foo", 0); diff --git a/libstage/model.cc b/libstage/model.cc index 52d3075ea..2fad0b5f7 100644 --- a/libstage/model.cc +++ b/libstage/model.cc @@ -517,7 +517,7 @@ bool Model::IsRelated( const Model* that ) const return true; // wind up to top-level object - Model* candidate = (Model*)this; + const Model* candidate = this; while( candidate->parent ) { // shortcut out if we found it on the way up the tree @@ -968,7 +968,9 @@ Model::RasterVis::RasterVis() height(0), cellwidth(0), cellheight(0), - pts() + pts(), + subs(0), + used(0) { } @@ -1635,7 +1637,7 @@ void Model::LoadControllerModule( const char* lib ) // the library name is the first word in the string char libname[256]; - sscanf( lib, "%s %*s", libname ); + sscanf( lib, "%255s %*s", libname ); if(( handle = lt_dlopenext( libname ) )) { diff --git a/libstage/model_actuator.cc b/libstage/model_actuator.cc index 65249cbc5..fe33eb8ec 100644 --- a/libstage/model_actuator.cc +++ b/libstage/model_actuator.cc @@ -69,6 +69,8 @@ ModelActuator::ModelActuator( World* world, min_position(0), max_position(1), start_position(0), + cosa(0.0), + sina(0.0), control_mode( CONTROL_VELOCITY ), actuator_type( TYPE_LINEAR ), axis(0,0,0) @@ -183,10 +185,7 @@ void ModelActuator::Load( void ) void ModelActuator::Update( void ) { - PRINT_DEBUG1( "[%lu] actuator update", 0 ); - - // stop by default - double velocity = 0; + PRINT_DEBUG1( "[%d] actuator update", 0 ); // update current position Pose CurrentPose = GetPose(); @@ -215,6 +214,8 @@ void ModelActuator::Update( void ) if( this->subs ) // no driving if noone is subscribed { + // stop by default + double velocity = 0; switch( control_mode ) { case CONTROL_VELOCITY : diff --git a/libstage/model_blinkenlight.cc b/libstage/model_blinkenlight.cc index cfca808b2..6d2a82c56 100644 --- a/libstage/model_blinkenlight.cc +++ b/libstage/model_blinkenlight.cc @@ -66,8 +66,8 @@ ModelBlinkenlight::ModelBlinkenlight( World* world, period( 1000 ), on( true ) { - PRINT_DEBUG2( "Constructing ModelBlinkenlight %d (%s)\n", - id, typestr ); + PRINT_DEBUG2( "Constructing ModelBlinkenlight %u (%s)\n", + id, type.c_str() ); // Set up sensible defaults diff --git a/libstage/model_blobfinder.cc b/libstage/model_blobfinder.cc index 3582a9191..0a19bd1ed 100644 --- a/libstage/model_blobfinder.cc +++ b/libstage/model_blobfinder.cc @@ -84,7 +84,7 @@ ModelBlobfinder::ModelBlobfinder( World* world, Model* parent, const std::string& type ) : Model( world, parent, type ), - vis( world ), + blob_vis( world ), blobs(), colors(), fov( DEFAULT_BLOBFINDERFOV ), @@ -93,11 +93,11 @@ ModelBlobfinder::ModelBlobfinder( World* world, scan_height( DEFAULT_BLOBFINDERSCANHEIGHT ), scan_width( DEFAULT_BLOBFINDERSCANWIDTH ) { - PRINT_DEBUG2( "Constructing ModelBlobfinder %d (%s)\n", - id, typestr ); + PRINT_DEBUG2( "Constructing ModelBlobfinder %u (%s)\n", + id, type.c_str() ); ClearBlocks(); - AddVisualizer( &this->vis, true ); + AddVisualizer( &this->blob_vis, true ); } @@ -106,7 +106,7 @@ ModelBlobfinder::~ModelBlobfinder( void ) } static bool blob_match( Model* candidate, - Model* finder, + const Model* finder, const void* dummy ) { (void)dummy; // avoid warning about unused var diff --git a/libstage/model_bumper.cc b/libstage/model_bumper.cc index 8cdc49482..0039baeaa 100644 --- a/libstage/model_bumper.cc +++ b/libstage/model_bumper.cc @@ -66,7 +66,7 @@ ModelBumper::ModelBumper( World* world, : Model( world, parent, type ), bumpervis() { - PRINT_DEBUG2( "Constructing ModelBumper %d (%s)\n", + PRINT_DEBUG2( "Constructing ModelBumper %u (%s)\n", id, type.c_str() ); // Set up sensible defaults @@ -144,14 +144,14 @@ void ModelBumper::Load( void ) // allow individual configuration of transducers for( unsigned int i = 0; i < bumper_count; i++) { - snprintf(key, sizeof(key), "bpose[%d]", i); + snprintf(key, sizeof(key), "bpose[%u]", i); wf->ReadTuple( wf_entity, key, 0, 4, "llla", &bumpers[i].pose.x, &bumpers[i].pose.y, &bumpers[i].pose.z, &bumpers[i].pose.a ); - snprintf(key, sizeof(key), "blength[%d]", i); + snprintf(key, sizeof(key), "blength[%u]", i); bumpers[i].length = wf->ReadLength( wf_entity, key, bumpers[i].length ); } @@ -160,7 +160,7 @@ void ModelBumper::Load( void ) } static bool bumper_match( Model* candidate, - Model* finder, const void* dummy ) + const Model* finder, const void* dummy ) { // Ignore myself, my children, and my ancestors. return( //candidate->vis.obstacle_return && diff --git a/libstage/model_camera.cc b/libstage/model_camera.cc index ccf915a12..d36299978 100644 --- a/libstage/model_camera.cc +++ b/libstage/model_camera.cc @@ -102,8 +102,8 @@ ModelCamera::ModelCamera( World* world, _yaw_offset( 0.0 ), _pitch_offset( 0.0 ) { - PRINT_DEBUG2( "Constructing ModelCamera %d (%s)\n", - id, typestr ); + PRINT_DEBUG2( "Constructing ModelCamera %u (%s)\n", + id, type.c_str() ); WorldGui* world_gui = dynamic_cast< WorldGui* >( world ); @@ -125,13 +125,13 @@ ModelCamera::ModelCamera( World* world, ModelCamera::~ModelCamera() { - if( _frame_data != NULL ) { - //dont forget about GetFrame() //TODO merge these together + if( _frame_data != NULL ) { delete[] _frame_data; delete[] _frame_color_data; delete[] _vertexbuf_cache; delete[] _camera_quads; delete[] _camera_colors; + _frame_data = NULL; } } @@ -168,14 +168,6 @@ bool ModelCamera::GetFrame( void ) return false; if( _frame_data == NULL ) { - if( _frame_data != NULL ) { - //don't forget about destructor - delete[] _frame_data; - delete[] _frame_color_data; - delete[] _vertexbuf_cache; - delete[] _camera_quads; - delete[] _camera_colors; - } _frame_data = new GLfloat[ _width * _height ]; //assumes a max of depth 4 _frame_color_data = new GLubyte[ 4 * _width * _height ]; //for RGBA diff --git a/libstage/model_draw.cc b/libstage/model_draw.cc index 01dd7e81b..1687a05c5 100644 --- a/libstage/model_draw.cc +++ b/libstage/model_draw.cc @@ -443,7 +443,7 @@ void Model::DrawFlagList( void ) for( std::list::reverse_iterator it( flag_list.rbegin()); it != flag_list.rend(); - it++ ) + ++it ) { double sz = (*it)->GetSize(); double d = sz/2.0; diff --git a/libstage/model_fiducial.cc b/libstage/model_fiducial.cc index bfc3d49f7..250dea5ff 100644 --- a/libstage/model_fiducial.cc +++ b/libstage/model_fiducial.cc @@ -101,7 +101,7 @@ ModelFiducial::~ModelFiducial( void ) } static bool fiducial_raytrace_match( Model* candidate, - Model* finder, + const Model* finder, const void* dummy ) { (void)dummy; // avoid warning about unused var diff --git a/libstage/model_gripper.cc b/libstage/model_gripper.cc index e4be698e4..baefb3798 100644 --- a/libstage/model_gripper.cc +++ b/libstage/model_gripper.cc @@ -349,7 +349,7 @@ void ModelGripper::Update() static bool gripper_raytrace_match( Model* hit, - Model* finder, + const Model* finder, const void* dummy ) { (void)dummy; // avoid warning about unused var diff --git a/libstage/model_position.cc b/libstage/model_position.cc index 56964dc59..3f853b82b 100644 --- a/libstage/model_position.cc +++ b/libstage/model_position.cc @@ -117,8 +117,8 @@ ModelPosition::ModelPosition( World* world, wpvis(), posevis() { - PRINT_DEBUG2( "Constructing ModelPosition %d (%s)\n", - id, typestr ); + PRINT_DEBUG2( "Constructing ModelPosition %u (%s)\n", + id, type.c_str() ); // assert that Update() is reentrant for this derived model thread_safe = false; @@ -406,17 +406,17 @@ void ModelPosition::Update( void ) { PRINT_DEBUG( "position control mode" ); - double x_error = goal.x - est_pose.x; - double y_error = goal.y - est_pose.y; - double a_error = normalize( goal.a - est_pose.a ); + const double x_error = goal.x - est_pose.x; + const double y_error = goal.y - est_pose.y; + double a_error = normalize( goal.a - est_pose.a ); PRINT_DEBUG3( "errors: %.2f %.2f %.2f\n", x_error, y_error, a_error ); // speed limits for controllers // TODO - have these configurable - double max_speed_x = 0.4; - double max_speed_y = 0.4; - double max_speed_a = 1.0; + const double max_speed_x = 0.4; + const double max_speed_y = 0.4; + const double max_speed_a = 1.0; switch( drive_mode ) { diff --git a/libstage/model_ranger.cc b/libstage/model_ranger.cc index f3142a941..4be09fa0a 100644 --- a/libstage/model_ranger.cc +++ b/libstage/model_ranger.cc @@ -92,10 +92,9 @@ ModelRanger::ModelRanger( World* world, Model* parent, const std::string& type ) : Model( world, parent, type ), - vis( world ) + ranger_vis( world ) { - PRINT_DEBUG2( "Constructing ModelRanger %d (%s)\n", - id, type ); + PRINT_DEBUG2( "Constructing ModelRanger %u (%s)\n", id, type.c_str() ); // Set up sensible defaults @@ -109,7 +108,7 @@ ModelRanger::ModelRanger( World* world, this->SetGeom( Geom( Pose(), RANGER_SIZE )); - AddVisualizer( &vis, true ); + AddVisualizer( &ranger_vis, true ); } ModelRanger::~ModelRanger() @@ -155,7 +154,7 @@ void ModelRanger::Sensor::Load( Worldfile* wf, int entity ) static bool ranger_match( Model* hit, - Model* finder, + const Model* finder, const void* dummy ) { (void)dummy; // avoid warning about unused var @@ -271,7 +270,7 @@ void ModelRanger::Sensor::Visualize( ModelRanger::Vis* vis, ModelRanger* rgr ) c // pack the ranger hit points into a vertex array for fast rendering GLfloat pts[2*(sample_count+1)]; - glVertexPointer( 2, GL_FLOAT, 0, &pts[0] ); + glVertexPointer( 2, GL_FLOAT, 0, pts ); pts[0] = 0.0; pts[1] = 0.0; diff --git a/libstage/option.cc b/libstage/option.cc index d9a4d95e0..f9a04c4a2 100644 --- a/libstage/option.cc +++ b/libstage/option.cc @@ -16,7 +16,9 @@ Option::Option( const std::string& n, wf_token( tok ), shortcut( key ), menu( NULL ), + menuIndex( 0 ), menuCb( NULL ), + menuCbWidget( NULL ), _world( world ), htname( n ) { diff --git a/libstage/options_dlg.cc b/libstage/options_dlg.cc index 7522bb37c..a45d369d1 100644 --- a/libstage/options_dlg.cc +++ b/libstage/options_dlg.cc @@ -56,10 +56,9 @@ namespace Stg { void OptionsDlg::updateChecks() { if (scroll->children()) scroll->clear(); - scroll->begin(); - Fl_Check_Button* check; + scroll->begin(); for ( unsigned int i=0; iw(), boxH, options[ i ]->name().c_str() ); + Fl_Check_Button* check = new Fl_Check_Button( 0,boxH*(i+1)+vm, scroll->w(), boxH, options[ i ]->name().c_str() ); if ( options[ i ]->val() ) check->set(); check->callback( checkChanged, this ); diff --git a/libstage/region.cc b/libstage/region.cc index 09915c800..46082abda 100644 --- a/libstage/region.cc +++ b/libstage/region.cc @@ -21,15 +21,13 @@ Stg::Region::~Region() void Stg::Region::AddBlock() { - ++count; - assert(count>0); + ++count; superregion->AddBlock(); } void Stg::Region::RemoveBlock() { - --count; - assert(count>=0); + --count; superregion->RemoveBlock(); // if there's nothing in this region, we can garbage collect the @@ -55,14 +53,12 @@ SuperRegion::~SuperRegion() void SuperRegion::AddBlock() { - ++count; - assert(count>0); + ++count; } void SuperRegion::RemoveBlock() { - --count; - assert(count>=0); + --count; } diff --git a/libstage/stage.hh b/libstage/stage.hh index d1c870f16..859793bab 100644 --- a/libstage/stage.hh +++ b/libstage/stage.hh @@ -199,12 +199,12 @@ namespace Stg public: double r,g,b,a; - Color( double r, double g, double b, double a=1.0 ); + explicit Color( double r, double g, double b, double a=1.0 ); /** Look up the color in the X11-style database. If the color is not found in the database, a cheerful red color will be used instead. */ - Color( const std::string& name ); + explicit Color( const std::string& name ); Color(); @@ -626,7 +626,7 @@ namespace Stg stops the ray, false if the block transmits the ray */ typedef bool (*ray_test_func_t)(Model* candidate, - Model* finder, + const Model* finder, const void* arg ); // STL container iterator macros - __typeof is a gcc extension, so @@ -1340,7 +1340,7 @@ namespace Stg void CallDisplayList(); public: - BlockGroup( Model& mod ); + explicit BlockGroup( Model& mod ); ~BlockGroup(); uint32_t GetCount() const { return blocks.size(); } @@ -1682,7 +1682,7 @@ namespace Stg static joules_t global_input; public: - PowerPack( Model* mod ); + explicit PowerPack( Model* mod ); ~PowerPack(); /** OpenGL visualization of the powerpack state */ @@ -2213,7 +2213,11 @@ namespace Stg /** Alternate constructor that creates dummy models with only a pose */ Model() : mapped(false), alwayson(false), blockgroup(*this), - boundary(false), data_fresh(false), disabled(true), friction(0), has_default_block(false), log_state(false), map_resolution(0), mass(0), parent(NULL), rebuild_displaylist(false), stack_children(true), stall(false), subs(0), thread_safe(false),trail_index(0), event_queue_num(0), used(false), watts(0), watts_give(0),watts_take(0),wf(NULL), wf_entity(0), world(NULL) + boundary(false), data_fresh(false), disabled(true), friction(0), has_default_block(false), + id(0), interval(0), interval_energy(0), last_update(0), log_state(false), map_resolution(0), + mass(0), parent(NULL), power_pack(NULL), rebuild_displaylist(false), stack_children(true), + stall(false), subs(0), thread_safe(false),trail_index(0), event_queue_num(0), used(false), + watts(0), watts_give(0),watts_take(0),wf(NULL), wf_entity(0), world(NULL), world_gui(NULL) {} void Say( const std::string& str ); @@ -2476,10 +2480,10 @@ namespace Stg class Vis : public Visualizer { public: - Vis( World* world ); + explicit Vis( World* world ); virtual ~Vis( void ){} virtual void Visualize( Model* mod, Camera* cam ); - } vis; + } blob_vis; private: /** Vector of blobs detected in the field of view. Use GetBlobs() @@ -2502,7 +2506,7 @@ namespace Stg unsigned int scan_width; ///< Width of the input image in pixels. // constructor - ModelBlobfinder( World* world, + explicit ModelBlobfinder( World* world, Model* parent, const std::string& type ); // destructor @@ -2542,7 +2546,7 @@ namespace Stg class ModelLightIndicator : public Model { public: - ModelLightIndicator( World* world, + explicit ModelLightIndicator( World* world, Model* parent, const std::string& type ); ~ModelLightIndicator(); @@ -2785,10 +2789,10 @@ namespace Stg static Option showBeams; static Option showTransducers; - Vis( World* world ); + explicit Vis( World* world ); virtual ~Vis( void ){} virtual void Visualize( Model* mod, Camera* cam ); - } vis; + } ranger_vis; class Sensor { diff --git a/libstage/world.cc b/libstage/world.cc index 3e29f6b8c..feea0e7cb 100644 --- a/libstage/world.cc +++ b/libstage/world.cc @@ -890,7 +890,7 @@ RaytraceResult World::Raytrace( const Ray& r ) continue; // test the predicate we were passed - if( (*r.func)( &block->group->mod, (Model*)r.mod, r.arg )) + if( (*r.func)( &block->group->mod, r.mod, r.arg )) { // a hit! result.pose = r.origin; diff --git a/libstage/worldfile.cc b/libstage/worldfile.cc index 61ff533fd..1db807bb9 100644 --- a/libstage/worldfile.cc +++ b/libstage/worldfile.cc @@ -128,7 +128,7 @@ bool Worldfile::Load(const std::string& filename ) // Open the file //FILE *file = fopen(this->filename, "r"); - FILE *file = FileOpen(this->filename.c_str(), "r"); + FILE *file = FileOpen(this->filename, "r"); if (!file) { PRINT_ERR2("unable to open world file %s : %s", @@ -243,7 +243,6 @@ bool Worldfile::WarnUnused() // Load tokens from a file. bool Worldfile::LoadTokens(FILE *file, int include) { - int ch; int line; char token[256]; @@ -251,7 +250,7 @@ bool Worldfile::LoadTokens(FILE *file, int include) while (true) { - ch = fgetc(file); + int ch = fgetc(file); if (ch == EOF) break; @@ -341,15 +340,13 @@ bool Worldfile::LoadTokens(FILE *file, int include) bool Worldfile::LoadTokenComment(FILE *file, int *line, int include) { char token[256]; - int len; - int ch; - len = 0; + int len = 0; memset(token, 0, sizeof(token)); while (true) { - ch = fgetc(file); + int ch = fgetc(file); if (ch == EOF) { @@ -374,15 +371,13 @@ bool Worldfile::LoadTokenComment(FILE *file, int *line, int include) bool Worldfile::LoadTokenWord(FILE *file, int *line, int include) { char token[256]; - int len; - int ch; - len = 0; + int len = 0; memset(token, 0, sizeof(token)); while (true) { - ch = fgetc(file); + int ch = fgetc(file); if (ch == EOF) { @@ -419,11 +414,10 @@ bool Worldfile::LoadTokenWord(FILE *file, int *line, int include) // Load an include token; this will load the include file. bool Worldfile::LoadTokenInclude(FILE *file, int *line, int include) { - int ch; const char *filename; char *fullpath; - ch = fgetc(file); + int ch = fgetc(file); if (ch == EOF) { @@ -550,15 +544,13 @@ bool Worldfile::LoadTokenInclude(FILE *file, int *line, int include) bool Worldfile::LoadTokenNum(FILE *file, int *line, int include) { char token[256]; - int len; - int ch; - len = 0; + int len = 0; memset(token, 0, sizeof(token)); while (true) { - ch = fgetc(file); + int ch = fgetc(file); if (ch == EOF) { @@ -585,14 +577,12 @@ bool Worldfile::LoadTokenNum(FILE *file, int *line, int include) // Read in a string token bool Worldfile::LoadTokenString(FILE *file, int *line, int include) { - int ch; - int len; char token[256]; - len = 0; + int len = 0; memset(token, 0, sizeof(token)); - ch = fgetc(file); + int ch = fgetc(file); while (true) { @@ -622,16 +612,14 @@ bool Worldfile::LoadTokenString(FILE *file, int *line, int include) // Read in a whitespace token bool Worldfile::LoadTokenSpace(FILE *file, int *line, int include) { - int ch; - int len; char token[256]; - len = 0; + int len = 0; memset(token, 0, sizeof(token)); while (true) { - ch = fgetc(file); + int ch = fgetc(file); if (ch == EOF) { @@ -658,12 +646,9 @@ bool Worldfile::LoadTokenSpace(FILE *file, int *line, int include) // Save tokens to a file. bool Worldfile::SaveTokens(FILE *file) { - unsigned int i; - CToken *token; - - for (i = 0; i < this->tokens.size(); i++) + for (unsigned int i = 0; i < this->tokens.size(); i++) { - token = &this->tokens[i]; + CToken *token = &this->tokens[i]; if (token->include > 0) continue; @@ -739,10 +724,8 @@ void Worldfile::DumpTokens() // Parse tokens into entities and properties. bool Worldfile::ParseTokens() { - int i; int entity; int line; - CToken *token; ClearEntities(); ClearProperties(); @@ -751,9 +734,9 @@ bool Worldfile::ParseTokens() entity = AddEntity(-1, ""); line = 1; - for (i = 0; i < (int)this->tokens.size(); i++) + for (int i = 0; i < (int)this->tokens.size(); i++) { - token = &this->tokens[0] + i; + CToken * token = &this->tokens[0] + i; switch (token->type) { @@ -794,12 +777,9 @@ bool Worldfile::ParseTokens() // Parse an include statement bool Worldfile::ParseTokenInclude(int *index, int *line) { - int i; - CToken *token; - - for (i = *index + 1; i < (int)this->tokens.size(); i++) + for (int i = *index + 1; i < (int)this->tokens.size(); i++) { - token = &this->tokens[i]; + CToken *token = &this->tokens[i]; switch (token->type) { @@ -825,20 +805,16 @@ bool Worldfile::ParseTokenInclude(int *index, int *line) // Parse a macro definition bool Worldfile::ParseTokenDefine(int *index, int *line) { - int i; - int count; const char *macroname, *entityname; int starttoken; - CToken *token; - count = 0; macroname = NULL; entityname = NULL; starttoken = -1; - for (i = *index + 1; i < (int)this->tokens.size(); i++) + for (int i = *index + 1, count = 0; i < (int)this->tokens.size(); i++) { - token = &this->tokens[i]; + CToken * token = &this->tokens[i]; switch (token->type) { @@ -902,12 +878,9 @@ bool Worldfile::ParseTokenDefine(int *index, int *line) // Parse something starting with a word; could be a entity or an property. bool Worldfile::ParseTokenWord(int entity, int *index, int *line) { - int i; - CToken *token; - - for (i = *index + 1; i < (int)this->tokens.size(); i++) + for (int i = *index + 1; i < (int)this->tokens.size(); i++) { - token = &this->tokens[i]; + CToken *token = &this->tokens[i]; switch (token->type) { @@ -938,10 +911,7 @@ bool Worldfile::ParseTokenWord(int entity, int *index, int *line) // Parse a entity from the token list. bool Worldfile::ParseTokenEntity(int entity, int *index, int *line) { - int i; - //int macro; int name; - CToken *token; name = *index; CMacro* macro = LookupMacro(GetTokenValue(name)); @@ -956,9 +926,9 @@ bool Worldfile::ParseTokenEntity(int entity, int *index, int *line) return false; entity = nentity; - for (i = *index + 1; i < (int)this->tokens.size(); i++) + for (int i = *index + 1; i < (int)this->tokens.size(); i++) { - token = &this->tokens[i]; + CToken *token = &this->tokens[i]; switch (token->type) { @@ -989,9 +959,9 @@ bool Worldfile::ParseTokenEntity(int entity, int *index, int *line) // If the entity name is not a macro... else { - for (i = *index + 1; i < (int)this->tokens.size(); i++) + for (int i = *index + 1; i < (int)this->tokens.size(); i++) { - token = &this->tokens[i]; + CToken *token = &this->tokens[i]; switch (token->type) { @@ -1029,11 +999,10 @@ bool Worldfile::ParseTokenProperty(int entity, int *index, int *line) { CProperty* property(NULL); int name( *index ); - CToken *token(NULL); for(int i = *index + 1; i < (int)this->tokens.size(); i++) { - token = &this->tokens[i]; + CToken *token = &this->tokens[i]; switch (token->type) { @@ -1068,14 +1037,9 @@ bool Worldfile::ParseTokenProperty(int entity, int *index, int *line) // Parse a tuple. bool Worldfile::ParseTokenTuple( CProperty* property, int *index, int *line) { - unsigned int i, count; - CToken *token; - - count = 0; - - for (i = *index + 1; i < this->tokens.size(); i++) + for (unsigned int i = *index + 1, count = 0; i < this->tokens.size(); i++) { - token = &this->tokens[i]; + CToken *token = &this->tokens[i]; switch (token->type) { @@ -1579,8 +1543,8 @@ void Worldfile::WriteTuple( const int entity, const char *name, if( property->values.size() < first+count ) { - PRINT_ERR4( "Worldfile: reading tuple \"%s\" index %d to %d - tuple has length %d\n", - name, first, first+count-1, (int)property->values.size() ); + PRINT_ERR4( "Worldfile: reading tuple \"%s\" index %u to %d - tuple has length %zu\n", + name, first, int(first+count)-1, property->values.size() ); exit(-1); } diff --git a/libstage/worldgui.cc b/libstage/worldgui.cc index faad0fa2c..54c31fce3 100644 --- a/libstage/worldgui.cc +++ b/libstage/worldgui.cc @@ -260,7 +260,7 @@ void WorldGui::Show() bool WorldGui::Load( const std::string& filename ) { - PRINT_DEBUG1( "%s.Load()", token ); + PRINT_DEBUG1( "%s.Load()", token.c_str() ); // needs to happen before StgWorld load, or we segfault with GL calls on some graphics cards Fl::check(); @@ -328,7 +328,7 @@ void WorldGui::UnLoad() bool WorldGui::Save( const char* filename ) { - PRINT_DEBUG1( "%s.Save()", token ); + PRINT_DEBUG1( "%s.Save()", token.c_str() ); // worldgui exclusive properties live in the top-level section const int world_section = 0; @@ -829,11 +829,9 @@ bool WorldGui::saveAsDialog() bool WorldGui::closeWindowQuery() { - int choice; - if ( wf && confirm_on_quit ) { // worldfile loaded, ask to save - choice = fl_choice("Quitting Stage", + int choice = fl_choice("Quitting Stage", "&Cancel", // ->0: defaults to ESC "&Save, then quit", // ->1 "&Quit without saving" // ->2