Thread: vector<>

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    12

    vector<>

    Hello,

    I'm having a few problems with vector<> and was wondering if anyone can help..
    I've tried to find out what's wrong (I've programmed in many langues before just not C++ that often, and I've never used vector<> )
    To my understanding.. it's just a type of array created with vector<type>
    Now.. I'm proting a forgotten game (Borqueror), to Linux so I can continue it's development. Fixed and rewrote the MS specific code.. but this won't complie at all.

    [teval@quantum Game]$ gcc -v
    Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
    Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
    Thread model: posix
    gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

    The problem is:

    Code:
    #include "stdafx.h"
    
    #include "Planets.h"
    #include "Colony.h"
    #include "Technology.h"
    #include "Production.h"
    #include "Fleet.h"
    #include "SolarSystem.h"
    #include "Vessel.h"
    #include "itoa.h"
    
    const double Facility::GetEffisciency( void )
    {
            double ans = effisciency;
    
            return ans;
    }
    
    void Production::UpdateAllow2Build( const int maxTechLevel )
    {
            availFacilities.clear();
    
            for( vector<Technology>::iterator it = tt.begin() ; it != tt.end() ; ++it )
            {
                    if( it->techLevel && it->techLevel <= maxTechLevel )
                            if( CanBuild( it ) )
                                    availFacilities.push_back( it->name );
            }
    }
    
    
    const bool Production::Proceed( vector<TurnEvent*> &event )
    {
            for( vector<Facility>::iterator it = facilities.begin() ; it != facilities.end() ; ++it )
            {
                    vector<Technology>::iterator pos = find_if( tt.begin() , tt.end() , bind2nd( mem_fun_ref( &Technology::IsNamed ) , it->name.c_str() ) );
    
                    if( (pos->mask & 0x04) == 0x04 )
                            it->SetOutput( pos->prodQty * it->GetEffisciency() * it->nr );
    
                    if( (pos->mask & 0x10) == 0x10 )
                    {
                            if( pos->name == "Natural Resources" )
                                    it->SetOutput( pos->prodQty * planet.GetOre() );
                            else if( pos->name == "Soil Composition" )
                                    it->SetOutput( pos->prodQty * planet.GetSoil() );
                            else if( pos->name == "Planet Energy Rsc." )
                                    it->SetOutput( pos->prodQty * planet.GetEnergy() );
                            else if( pos->name == "Sunrays Factor" )
                                    it->SetOutput( pos->prodQty * planet.GetSunFactor() );
                    }
            }
    
            int     n = 0;
            bool    ans = !buildStack.empty();
    
            for( vector<BuildInProgress*>::iterator pos =  buildStack.begin() ; pos != buildStack.end() ; ++pos )
            {
                    Building( pos );
                    if( pos->IsBuilt() )
                    {
                            ans = true;
                            vector<Facility>::iterator at = find_if( facilities.begin() , facilities.end() , bind2nd( mem_fun_ref( &Facility::IsNamed ) , pos->name.c_str() ) );
                            if( at != facilities.end() )
                                    at->nr += 1;
                            else
                            {
                                    vector<Technology>::iterator ins = find_if( tt.begin() , tt.end() , bind2nd( mem_fun_ref( &Technology::IsNamed ) , pos->name.c_str() ) );
                                    if( (ins->mask & 0x08) == 0x08 )
                                    {
                                            SolarSystem     &ss = planet.ss;
                                            Fleet   *f = 0;
                                            for( multimap<string,Fleet*>::iterator it = PlayGame::fleets.lower_bound( species ) ; it != PlayGame::fleets.upper_bound( species ) ; ++it )
                                                    if( it->second->GetPosition() == ss.GetPosition() )
                                                    {
                                                            f = it->second;
                                                            break;
                                                    }
                                            if( !f )
                                            {
                                                    bool    ok = false;
                                                    int     i = 0;
                                                    string  fleetName;
                                                    while( !ok )
                                                    {
                                                            char    tmp[10];
                                                            fleetName = species + itoa( ++i , tmp , 10 );
    
                                                            for( multimap<string,Fleet *>::iterator it = PlayGame::fleets.lower_bound( species ) ; it != PlayGame::fleets.upper_bound( species ) ; ++it )
                                                                    if( it->second->name == fleetName )
                                                                            break;
                                                            ok = (it == PlayGame::fleets.upper_bound( species ));
                                                    }
                                                    f = new Fleet( species , fleetName );
                                                    f->Setup( ss.GetPosition() , &planet );
                                                    f->Setup();
                                            }
                                            f->push_back( new Vessel( ins->prodName , species ) );
                                    }
                                    else
                                    {
                                            facilities.push_back( Facility( *ins , planet.GetEffisciency( species ) ) );
                                            facilities.back().nr = 1;
                                    }
                            }
                            event.push_back( this );
                            n += 1;
                    }
            }
    
            if( n > 0 && ans )
            {
                    while( (pos = find_if( buildStack.begin() , buildStack.end() , mem_fun_ref( &BuildInProgress::IsBuilt ) )) != buildStack.end() )
                            buildStack.erase( pos );
    
                    UpdateAllow2Build();
            }
    
            return ans;
    }
    
    void Production::Building( BuildInProgress *bip )
    {
            for( vector<pair<string,int> >::iterator it = bip->buildRequisite.begin() ; it != bip->buildRequisite.end() ; ++it )
            {
                    vector<Facility>::iterator      pos = facilities.begin();
                    while( it->second )
                    {
                            if( (pos = find_if( pos , facilities.end() , bind2nd( mem_fun_ref( &Facility::DoesProduce ) , it->first.c_str() ) )) != facilities.end() )
                                    if( pos->GetOutput() >= it->second )
                                    {
                                            pos->AddOutput( -it->second );
                                            it->second = 0;
                                    }
                                    else
                                    {
                                            it->second -= pos->GetOutput();
                                            pos->SetOutput( 0 );
                                    }
                            else
                                    break;
                            ++pos;
                    }
            }
    }
    
    const bool Production::CanBuild( Technology *t )
    {
            if( !t->request.empty() )
                    if( find_if( facilities.begin() , facilities.end() , bind2nd( mem_fun_ref( &Facility::IsNamed ) , t->request.c_str() ) ) == facilities.end() )
                            return false;
            for( vector<pair<string,int> >::iterator it = t->inputList.begin() ; it != t->inputList.end() ; ++it )
                    if( find_if( facilities.begin() , facilities.end() , bind2nd( mem_fun_ref( &Facility::DoesProduce ) , it->first.c_str() ) ) == facilities.end() )
                            return false;
    
            for( it = t->buildRequisite.begin() ; it != t->buildRequisite.end() ; ++it )
                    if( find_if( facilities.begin() , facilities.end() , bind2nd( mem_fun_ref( &Facility::DoesProduce ) , it->first.c_str() ) ) == facilities.end() )
                            return false;
    
            return true;
    }


    The error message I get:

    c++ -c -fno-for-scope -fno-const-strings -I../Source -I../Source/Game -I../Source/Distribution -I../Source/Include -I../Source/Utils -I/usr/local/include ../Source/Game/Production.cpp
    ../Source/Game/Production.cpp: In member function `void
    Production::UpdateAllow2Build(int)':
    ../Source/Game/Production.cpp:26: no matching function for call to `Production
    ::CanBuild(__gnu_cxx::__normal_iterator<Technology *, std::vector<Technology,
    std::allocator<Technology> > >&)'
    ../Source/Game/Production.h:112: candidates are: const bool
    Production::CanBuild(Technology*)
    ../Source/Game/Production.cpp: In member function `const bool
    Production::Proceed(std::vector<TurnEvent*, std::allocator<TurnEvent*> >&)':
    ../Source/Game/Production.cpp:57: conversion from `
    __gnu_cxx::__normal_iterator<BuildInProgress*, std::vector<BuildInProgress,
    std::allocator<BuildInProgress> > >' to non-scalar type `
    __gnu_cxx::__normal_iterator<BuildInProgress**,
    std::vector<BuildInProgress*, std::allocator<BuildInProgress*> > >'
    requested
    ../Source/Game/Production.cpp:57: no match for `
    __gnu_cxx::__normal_iterator<BuildInProgress**,
    std::vector<BuildInProgress*, std::allocator<BuildInProgress*> > >& !=
    __gnu_cxx::__normal_iterator<BuildInProgress*, std::vector<BuildInProgress,
    std::allocator<BuildInProgress> > >' operator
    /usr/local/include/allegro/inline/fix.inl:78: candidates are: int
    operator!=(fix, fix)
    /usr/local/include/allegro/inline/fix.inl:79: int
    operator!=(fix, int)
    /usr/local/include/allegro/inline/fix.inl:80: int
    operator!=(int, fix)
    /usr/local/include/allegro/inline/fix.inl:81: int
    operator!=(fix, long int)
    /usr/local/include/allegro/inline/fix.inl:82: int
    operator!=(long int, fix)
    /usr/local/include/allegro/inline/fix.inl:83: int
    operator!=(fix, float)
    /usr/local/include/allegro/inline/fix.inl:84: int
    operator!=(float, fix)
    /usr/local/include/allegro/inline/fix.inl:85: int
    operator!=(fix, double)
    /usr/local/include/allegro/inline/fix.inl:86: int
    operator!=(double, fix)
    ../Source/Game/Production.cpp:59: no matching function for call to `Production
    ::Building(__gnu_cxx::__normal_iterator<BuildInPro gress**,
    std::vector<BuildInProgress*, std::allocator<BuildInProgress*> > >&)'
    ../Source/Game/Production.h:118: candidates are: void
    Production::Building(BuildInProgress*)
    ../Source/Game/Production.cpp:60: request for member `IsBuilt' in `
    *(&pos)->__gnu_cxx::__normal_iterator<_Iterator, _Container>erator->()
    const [with _Iterator = BuildInProgress**, _Container =
    std::vector<BuildInProgress*, std::allocator<BuildInProgress*> >]()', which
    is of non-aggregate type `BuildInProgress*'
    ../Source/Game/Production.cpp:63: request for member `name' in `
    *(&pos)->__gnu_cxx::__normal_iterator<_Iterator, _Container>erator->()
    const [with _Iterator = BuildInProgress**, _Container =
    std::vector<BuildInProgress*, std::allocator<BuildInProgress*> >]()', which
    is of non-aggregate type `BuildInProgress*'
    ../Source/Game/Production.cpp:68: request for member `name' in `
    *(&pos)->__gnu_cxx::__normal_iterator<_Iterator, _Container>erator->()
    const [with _Iterator = BuildInProgress**, _Container =
    std::vector<BuildInProgress*, std::allocator<BuildInProgress*> >]()', which
    is of non-aggregate type `BuildInProgress*'
    ../Source/Game/Production.cpp:113: no match for `
    __gnu_cxx::__normal_iterator<BuildInProgress**,
    std::vector<BuildInProgress*, std::allocator<BuildInProgress*> > >& =
    __gnu_cxx::__normal_iterator<BuildInProgress*, std::vector<BuildInProgress,
    std::allocator<BuildInProgress> > >' operator
    /usr/include/c++/3.2.2/bits/stl_iterator.h:571: candidates are:
    __gnu_cxx::__normal_iterator<BuildInProgress**,
    std::vector<BuildInProgress*, std::allocator<BuildInProgress*> > >&
    __gnu_cxx::__normal_iterator<BuildInProgress**,
    std::vector<BuildInProgress*, std::allocator<BuildInProgress*> >
    >erator=(const __gnu_cxx::__normal_iterator<BuildInProgress**,
    std::vector<BuildInProgress*, std::allocator<BuildInProgress*> > >&)
    ../Source/Game/Production.cpp:114: no matching function for call to `
    std::vector<BuildInProgress, std::allocator<BuildInProgress> >::erase(
    __gnu_cxx::__normal_iterator<BuildInProgress**,
    std::vector<BuildInProgress*, std::allocator<BuildInProgress*> > >&)'
    /usr/include/c++/3.2.2/bits/stl_vector.h:647: candidates are:
    __gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >
    std::vector<_Tp, _Alloc>::erase(__gnu_cxx::__normal_iterator<_Tp*,
    std::vector<_Tp, _Alloc> > ) [with _Tp = BuildInProgress, _Alloc =
    std::allocator<BuildInProgress>]
    /usr/include/c++/3.2.2/bits/stl_vector.h:670:
    __gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >
    std::vector<_Tp, _Alloc>::erase(__gnu_cxx::__normal_iterator<_Tp*,
    std::vector<_Tp, _Alloc> >, __gnu_cxx::__normal_iterator<_Tp*,
    std::vector<_Tp, _Alloc> > ) [with _Tp = BuildInProgress, _Alloc =
    std::allocator<BuildInProgress>]
    ../Source/Game/Production.cpp: In member function `void
    Production::Building(BuildInProgress*)':
    ../Source/Game/Production.cpp:137: warning: assignment to `int' from `double'
    ../Source/Game/Production.cpp:137: warning: argument to `int' from `double'
    make: *** [../Source/Game/Production.o] Error 1

    I have no clue what to do
    I know Technology as a type is defined in Technology.h, included.
    And if I define any of those types without vector they work fine.. baffeled.

    Thanks


    If you'd like to see any other piece of code tell me, it's also availabe online from sourceforge as Borqueror is GPLed

  2. #2
    Registered User
    Join Date
    Jun 2002
    Posts
    230
    You didnt include the vector library

    #include <vector>
    or
    #include <vector.h> depending on your compiler and how old it may be.
    C++ Rules!!!!
    ------------
    Microsoft Visual Studio .NET Enterprise

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    44
    Could somebody explain why some header files have the .h extension and some don't?
    Check out all my dimensions:
    Height, width, and for a limited time only... Depth!
    -sb

  4. #4
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    My understanding has been that header files without the .h are newer and/or up to the standard...

    If you use these header files be sure to use the standard namspace:
    Code:
    using namspace std;
    //after #includes
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    12
    Standard headers from the STL for C, the headers like iostream.h have .h
    They are not part of the C++ language though
    The headers form the STL for C++ have the same name as the C headers, just without the .h to allow interoperability.

    Yes I have vector in there, otherwise the compile error would have been drastically different and there would not have been a reference to vector.h
    Whose inclusion is because I've included <vector>

    It's included in the stdafx.h header file, included into this file.

  6. #6
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,090
    The first thing I see is that your CanBuild method takes a Technology* as an argument, but in your UpdateAllow2Build method you are passing a vector<Technology>::iterator.

    While I think the vector iterator might be implemented as a pointer in some cases, I don't think there is an implicit conversion. You should try this in your UpdateAllow2Build method:
    Code:
                    ...
                    if( it->techLevel && it->techLevel <= maxTechLevel )
                            if( CanBuild( &(*it) ) )
                                    availFacilities.push_back( it->name );
                    ...
    I don't remember off the top of my head whether you can just take the address of the dereferenced iterator like that, but I think it should work.

  7. #7
    Registered User
    Join Date
    Aug 2003
    Posts
    12
    That doesn't generate an error, but I'll make a note of it, when I finish getting it to actually compile, I'll redo everything with -Wall, and start going through those.

  8. #8
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    >>Standard headers from the STL for C, the headers like iostream.h have .h
    There is no STL for C. C doesn't support classes. The .h files are from the pre-98 standard for C++.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  9. #9
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    Originally posted by jlou I don't remember off the top of my head whether you can just take the address of the dereferenced iterator like that, but I think it should work. [/B]
    You can. Dereferencing takes you to the object, and referencing gives you a pointer to the object.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  10. #10
    Registered User
    Join Date
    Aug 2003
    Posts
    12
    Allrighty, fixed some things
    Now.. all that's left:

    ../Source/Game/Production.cpp: In member function `const bool
    Production::Proceed(std::vector<TurnEvent*, std::allocator<TurnEvent*> >&)':
    ../Source/Game/Production.cpp:47: no matching function for call to `Production
    ::Building(__gnu_cxx::__normal_iterator<BuildInPro gress*,
    std::vector<BuildInProgress, std::allocator<BuildInProgress> > >&)'
    ../Source/Game/Production.h:118: candidates are: void
    Production::Building(BuildInProgress*)
    ../Source/Game/Production.cpp: In member function `void
    Production::Building(BuildInProgress*)':
    ../Source/Game/Production.cpp:125: warning: assignment to `int' from `double'
    ../Source/Game/Production.cpp:125: warning: argument to `int' from `double'
    ../Source/Game/Production.cpp: In member function `void
    Production::UpdateAllow2Build(int)':
    ../Source/Game/Production.cpp:158: no matching function for call to `Production
    ::CanBuild(__gnu_cxx::__normal_iterator<Technology *, std::vector<Technology,
    std::allocator<Technology> > >&)'
    ../Source/Game/Production.cpp:136: candidates are: const bool
    Production::CanBuild(Technology*)

    Code:
    #include "stdafx.h"
    
    #include "Planets.h"
    #include "Colony.h"
    #include "Technology.h"
    #include "PlayGame.h"
    #include "Production.h"
    #include "Fleet.h"
    #include "SolarSystem.h"
    #include "Vessel.h"
    #include "itoa.h"
    
    const double Facility::GetEffisciency( void )
    {
            double ans = effisciency;
    
            return ans;
    }
    
    const bool Production::Proceed( vector<TurnEvent*> &event )
    {
            for( vector<Facility>::iterator it = facilities.begin() ; it != facilities.end() ; ++it )
            {
                    vector<Technology>::iterator pos = find_if( tt.begin() , tt.end() , bind2nd( mem_fun_ref( &Technology::IsNamed ) , it->name.c_str() ) );
    
                    if( (pos->mask & 0x04) == 0x04 )
                            it->SetOutput( pos->prodQty * it->GetEffisciency() * it->nr );
    
                    if( (pos->mask & 0x10) == 0x10 )
                    {
                            if( pos->name == "Natural Resources" )
                                    it->SetOutput( pos->prodQty * planet.GetOre() );
                            else if( pos->name == "Soil Composition" )
                                    it->SetOutput( pos->prodQty * planet.GetSoil() );
                            else if( pos->name == "Planet Energy Rsc." )
                                    it->SetOutput( pos->prodQty * planet.GetEnergy() );
                            else if( pos->name == "Sunrays Factor" )
                                    it->SetOutput( pos->prodQty * planet.GetSunFactor() );
                    }
            }
    
            int     n = 0;
            bool    ans = !buildStack.empty();
    
            for( vector<BuildInProgress>::iterator pos =  buildStack.begin() ; pos != buildStack.end() ; ++pos )
            {
                    Building( pos );
                    if( pos->IsBuilt() )
                    {
                            ans = true;
                            vector<Facility>::iterator at = find_if( facilities.begin() , facilities.end() , bind2nd( mem_fun_ref( &Facility::IsNamed ) , pos->name.c_str() ) );
                            if( at != facilities.end() )
                                    at->nr += 1;
                            else
                            {
                                    vector<Technology>::iterator ins = find_if( tt.begin() , tt.end() , bind2nd( mem_fun_ref( &Technology::IsNamed ) , pos->name.c_str() ) );
                                    if( (ins->mask & 0x08) == 0x08 )
                                    {
                                            SolarSystem     &ss = planet.ss;
                                            Fleet   *f = 0;
                                            for( multimap<string,Fleet*>::iterator it = PlayGame::fleets.lower_bound( species ) ; it != PlayGame::fleets.upper_bound( species ) ; ++it )
                                                    if( it->second->GetPosition() == ss.GetPosition() )
                                                    {
                                                            f = it->second;
                                                            break;
                                                    }
                                            if( !f )
                                            {
                                                    bool    ok = false;
                                                    int     i = 0;
                                                    string  fleetName;
                                                    while( !ok )
                                                    {
                                                            char    tmp[10];
                                                            fleetName = species + itoa( ++i , tmp , 10 );
    
                                                            for( multimap<string,Fleet *>::iterator it = PlayGame::fleets.lower_bound( species ) ; it != PlayGame::fleets.upper_bound( species ) ; ++it )
                                                                    if( it->second->name == fleetName )
                                                                            break;
                                                            ok = (it == PlayGame::fleets.upper_bound( species ));
                                                    }
                                                    f = new Fleet( species , fleetName );
                                                    f->Setup( ss.GetPosition() , &planet );
                                                    f->Setup();
                                            }
                                            f->push_back( new Vessel( ins->prodName , species ) );
                                    }
                                    else
                                    {
                                            facilities.push_back( Facility( *ins , planet.GetEffisciency( species ) ) );
                                            facilities.back().nr = 1;
                                    }
                            }
                            event.push_back( this );
                            n += 1;
                    }
            }
    
            if( n > 0 && ans )
            {
                    while( (pos = find_if( buildStack.begin() , buildStack.end() , mem_fun_ref( &BuildInProgress::IsBuilt ) )) != buildStack.end() )
                            buildStack.erase( pos );
    
                    UpdateAllow2Build();
            }
    
            return ans;
    }
    
    void Production::Building( BuildInProgress *bip )
    {
            for( vector<pair<string,int> >::iterator it = bip->buildRequisite.begin() ; it != bip->buildRequisite.end() ; ++it )
            {
                    vector<Facility>::iterator      pos = facilities.begin();
                    while( it->second )
                    {
                            if( (pos = find_if( pos , facilities.end() , bind2nd( mem_fun_ref( &Facility::DoesProduce ) , it->first.c_str() ) )) != facilities.end() )
                                    if( pos->GetOutput() >= it->second )
                                    {
                                            pos->AddOutput( -it->second );
                                            it->second = 0;
                                    }
                                    else
                                    {
                                            it->second -= pos->GetOutput();
                                            pos->SetOutput( 0 );
                                    }
                            else
                                    break;
                            ++pos;
                    }
            }
    }
    
    const bool Production::CanBuild( Technology *t )
    {
            if( !t->request.empty() )
                    if( find_if( facilities.begin() , facilities.end() , bind2nd( mem_fun_ref( &Facility::IsNamed ) , t->request.c_str() ) ) == facilities.end() )
                            return false;
            for( vector<pair<string,int> >::iterator it = t->inputList.begin() ; it != t->inputList.end() ; ++it )
                    if( find_if( facilities.begin() , facilities.end() , bind2nd( mem_fun_ref( &Facility::DoesProduce ) , it->first.c_str() ) ) == facilities.end() )
                            return false;
    
            for( it = t->buildRequisite.begin() ; it != t->buildRequisite.end() ; ++it )
                    if( find_if( facilities.begin() , facilities.end() , bind2nd( mem_fun_ref( &Facility::DoesProduce ) , it->first.c_str() ) ) == facilities.end() )
                            return false;
    
            return true;
    }
    
    void Production::UpdateAllow2Build( const int maxTechLevel )
    {
            availFacilities.clear();
    
            for( vector<Technology>::iterator pos = tt.begin() ; pos != tt.end() ; ++pos )
            {
                    if( pos->techLevel && pos->techLevel <= maxTechLevel )
                            if( CanBuild( pos ) )
                                    availFacilities.push_back( pos->name );
            }
    }
    Also the header file for it:



    Code:
    #if !defined( __PRODUCTION_H__ )
    #define __PRODUCTION_H__
    
    class Planets;
    #include "Technology.h"
    #include "PlayGame.h"
    
    class Facility  {
    private:
    
            int     outputQty;
    
    public:
    
            string  name , prodName;
            vector<pair<string , int> >     inputList;
            int     nr;
            double effisciency;
    
            Facility( Technology &tech , const double aEff = 0.0 )
            : name( tech.name ) , effisciency( aEff ) , inputList( tech.inputList )
            , outputQty( tech.prodQty ) , nr( tech.nr )
            , prodName( tech.prodName )
            {}
    
            ~Facility( void )       {}
    
            inline Facility &operator=( const Facility &f )
            {
                    name = f.name;
                    inputList = f.inputList;
                    effisciency = f.effisciency;
                    prodName = f.prodName;
                    outputQty = f.outputQty;
                    nr = f.nr;
                    return *this;
            }
            const bool IsNamed( const char *aName ) const   {       return name == aName; }
            const bool DoesProduce( const char *aName ) const       {       return prodName == aName;       }
            const double GetOutput( void ) const    {       return outputQty * nr * effisciency;    }
            void    SetOutput( const double aQty )  {       outputQty = (int)aQty;  }
            void    AddOutput( const double aQty )  {       outputQty += (int)aQty; }
            const double GetEffisciency( void );
    };
    
    class BuildInProgress   {
    public:
            string  name;
            double progress;
            vector<pair<string,int> >       buildRequisite;
    
            BuildInProgress( Technology &tech )
            : name( tech.name ) , progress( 0.0 ) , buildRequisite( tech.buildRequisite )
            {}
    
            ~BuildInProgress( void )        {}
    
            const bool IsNamed( const char *aName ) const   {       return name == aName; }
            inline BuildInProgress &operator=( const BuildInProgress &f )
            {
                    name = f.name;
                    buildRequisite = f.buildRequisite;
                    progress = f.progress;
                    return *this;
            }
    
            const bool IsBuilt( void )
            {
                    int     ans = 0;
                    for( vector<pair<string,int> >::iterator it = buildRequisite.begin() ; it != buildRequisite.end() ; ++it )
                            ans += it->second;
                    return ans == 0;
            }
    };
    
    class Production :  public TurnEvent    {
    protected:
    
            vector<Facility>        facilities;
            vector<string>  availFacilities;
            vector<BuildInProgress> buildStack;
            TechnologyTree  &tt;
            Planets &planet;
    
    public:
    
            const string species;
    
            Production( Planets &aPlanet , const string aSpecies )
            : species( aSpecies ) , tt( PlayGame::Get( aSpecies ) ) , planet( aPlanet )
            {
            }
    
            ~Production( void )
            {
                    facilities.clear();
                    availFacilities.clear();
            }
    
            const bool CanBuild( Technology *t );
    
            void UpdateAllow2Build( const int maxTechLevel = 1 );
    
            const bool Proceed( vector<TurnEvent*> &event );
    
            void Building( BuildInProgress *bip );
    };
    
    #endif
    Any clue how to fix the remaining errors.. i figured out what was happening but.. still haven't figured out all the errors.

    Thanks

  11. #11
    Registered User
    Join Date
    Aug 2003
    Posts
    12
    Made the modification that jlou suggested, thanks

    Fixed another set of errors.. remaing are:

    ../Source/Game/Production.cpp: In member function `const bool
    Production::Proceed(std::vector<TurnEvent*, std::allocator<TurnEvent*> >&)':
    ../Source/Game/Production.cpp:47: no matching function for call to `Production
    ::Building(__gnu_cxx::__normal_iterator<BuildInPro gress*,
    std::vector<BuildInProgress, std::allocator<BuildInProgress> > >&)'
    ../Source/Game/Production.h:118: candidates are: void
    Production::Building(BuildInProgress*)
    ../Source/Game/Production.cpp: In member function `void
    Production::Building(BuildInProgress*)':
    ../Source/Game/Production.cpp:125: warning: assignment to `int' from `double'
    ../Source/Game/Production.cpp:125: warning: argument to `int' from `double'

  12. #12
    Registered User
    Join Date
    Aug 2003
    Posts
    12
    Alrighty, fixed.. sorry about all the spam

Popular pages Recent additions subscribe to a feed