Partage
  • Partager sur Facebook
  • Partager sur Twitter

erreur à la compilation

Sujet résolu
    6 septembre 2022 à 18:50:43

    Salut j'ai cette erreur en compilation

    /home/laurent/gitODFAEG/Demos/ODFAEG-CLIENT/gameAction.hpp|6|error: expected template-name before ‘<’ token|
    #ifndef GAME_ACTION_HPP
    #define GAME_ACTION_HPP
    #include "hero.h"
    #include "odfaeg/Network/network.h"
    namespace sorrok {
        class GameAction : public odfaeg::core::Visitor<> {
            public :
            void operator()(Item& item, Hero* hero);
            void operator()(Skill& skill, Hero* hero);
        };
    }
    #endif



    On dirait qu'il ne reconnaît pas ma classe EntityFactory ici :

    #ifndef HERO_HPP
    #define HERO_HPP
    #include "caracter.h"
    #include "item.hpp"
    #include "quest.hpp"
    #include "skill.hpp"
    namespace sorrok {
        class Hero : public Caracter {
        public :
            Hero(odfaeg::graphic::EntityFactory& factory);
            Hero(std::string factionName, std::string name, std::string sex, std::string currentMapName, std::string hairColor,
            std::string eyesColor, std::string skinColor, std::string faceType, std::string classs, int level, odfaeg::graphic::EntityFactory& factory);
            void setIsMovingFromKeyboard(bool b);
            bool isMovingFromKeyboard();
            bool isMonster() {
                return false;
            }
            void setCurrentXp(int xp);
            void setXpReqForNextLevel(int xpReqForNextLevel);
            void up (int xp);
            int getCurrentXp ();
            int getXpReqForNextLevel ();
            std::vector<Skill> getSkills();
            template <typename Archive>
            void vtserialize(Archive& ar) {
                Caracter::vtserialize(ar);
                ar(factionName);
                ar(sex);
                ar(hairColor);
                ar(eyesColor);
                ar(skinColor);
                ar(faceType);
                ar(xp);
                ar(xpReqForNextLevel);
                ar(skills);
            }
            void addItem (Item item);
            bool containsQuest(std::string name);
            void addQuest(Quest quest);
            void removeQuest (Quest quest);
            Quest* getQuest(std::string name);
            std::vector<Quest> getDiary();
            std::map<Item::Type, std::vector<Item>>& getInventory();
            void addSkill (Skill skill);
            ~Hero();
        private :
            std::string factionName, sex, hairColor, eyesColor, skinColor, faceType;
            bool moveFromKeyboard;
            int xp, xpReqForNextLevel;
            std::map<Item::Type, std::vector<Item>> inventory;
            std::vector<Skill> skills;
            std::vector<Quest> diary;
        };
    }
    #endif // HERO_HPP
    
    // *** ADDED BY HEADER FIXUP ***
    // *** END ***
    #ifndef CARACTER
    #define CARACTER
    #include <vector>
    #include "odfaeg/Math/vec2f.h"
    #include "odfaeg/Graphics/anim.h"
    #include "odfaeg/Graphics/tile.h"
    #include "odfaeg/Graphics/GUI/progressBar.hpp"
    #include "odfaeg/Graphics/world.h"
    #include <string>
    #include <SFML/Graphics.hpp>
    #include "odfaeg/Graphics/boneAnimation.hpp"
    namespace sorrok {
        class MyAppli;
        class Caracter : public odfaeg::graphic::BoneAnimation {
        public :
            enum ANIMS {
                WALKING, ATTACKING = 8, TIPPING_OVER = 16
            };
            Caracter(odfaeg::graphic::EntityFactory& factory);
            Caracter (std::string type, std::string name, std::string currentMapName, std::string classs, int level, odfaeg::graphic::EntityFactory& factory);
            Entity* clone();
            void setXpHpBar(odfaeg::graphic::gui::ProgressBar* hpBar, odfaeg::graphic::gui::ProgressBar* xpBar, odfaeg::graphic::gui::ProgressBar* manaBar);
            bool isMovable() const {
                return true;
            }
            bool selectable() const {
                return false;
            }
            bool operator== (Entity& other);
            void addAnimation (odfaeg::graphic::Anim *anim);
            odfaeg::graphic::Tile& getCurrentTile();
            void setMoving(bool b);
            bool isMoving ();
            void setDir(odfaeg::math::Vec2f dir);
            odfaeg::math::Vec2f getDir();
            void setPath(std::vector<odfaeg::math::Vec2f> path);
            std::vector<odfaeg::math::Vec2f> getPath();
            float getSpeed();
            void setSpeed(float speed);
            odfaeg::graphic::Anim* getAnimation(unsigned int index);
            unsigned int getCurrentPathIndex ();
            void setCurrentPathIndex (unsigned int index);
            virtual bool isMonster() = 0;
            void setRange(int range);
            int getRange();
            void setLife(int life);
            void setMaxLife(int life);
            int getLife ();
            int getMaxLife();
            int getManaMax();
            int getLevel();
            std::string getClass();
            int getAttackMin();
            int getAttackMax();
            void setAttackSpeed(float attackSpeed);
            float getAttackSpeed();
            void setFightingMode(bool b);
            bool isInFightingMode();
            bool isAttacking ();
            void setAlive(bool b);
            bool isAlive();
            void setAttacking(bool b);
            void setCurrentXp(int xp);
            void setXpReqForNextLevel(int xpReqForNextLevel);
            void setLevel (int level);
            sf::Time getTimeOfLastAttack();
            sf::Time getTimeOfLastHpRegen();
            sf::Time getTimeOfLastManaRegen();
            void attackFocusedCaracter(int attack);
            void setFocusedCaracter(Caracter* caracter);
            Caracter* getFocusedCaracter();
            void up (int xp);
            int getCurrentXp ();
            int getXpReqForNextLevel ();
            float getRegenHpSpeed();
            float getRegenManaSpeed();
            void setRegenHpSpeed(float regenHpSpeed);
            int getRegenHpAmountMin();
            void setRegenHpAmountMin(int regenHpAmount);
            int getRegenHpAmountMax();
            void setRegenHpAmountMax(int regenHpAmount);
            Entity* getCurrentFrame() const;
            void onDraw(odfaeg::graphic::RenderTarget&, odfaeg::graphic::RenderStates);
            void onMove(odfaeg::math::Vec3f& t);
            virtual void setIsMovingFromKeyboard(bool b) {}
            virtual bool isMovingFromKeyboard() = 0;
            sf::Clock& getClkTransfertTime();
            sf::Time getTimeBeforeLastRespawn();
            sf::Time getTimeSinceLastRespawn();
            void restartAttackSpeed();
            void restartRespawn();
            std::vector<int>& getDamages();
            void setDamages(std::vector<int> damages);
            void setDmgTransferTime(sf::Int64 time);
            void setRgnTransferTime(sf::Int64 time);
            void setRgnManaTransferTime(sf::Int64 time);
            sf::Int64 getDmgTransferTime();
            sf::Int64 getRgnTransferTime();
            sf::Int64 getRgnManaTransferTime();
            std::string getName();
            template <typename Archive>
            void vtserialize(Archive & ar) {
                Entity::vtserialize(ar);
                ar(moving);
                ar(name);
                ar(classs);
                ar(level);
                ar(speed);
                ar(attackMin);
                ar(attackMax);
                ar(range);
                ar(attackSpeed);
                ar(regenHpSpeed);
                ar(alive);
                ar(regenHpAmountMin);
                ar(regenHpAmountMax);
                ar(life);
                ar(mana);
                ar(regenManaSpeed);
                ar(regenManaAmountMin);
                ar(regenManaAmountMax);
                sf::Int64 i = 0;
                addAttribute("isAlive"+odfaeg::core::conversionIntString(getId()), i);
                addAttribute("isMoving"+odfaeg::core::conversionIntString(getId()),i);
                addAttribute("isInFightingMode"+odfaeg::core::conversionIntString(getId()), i);
                addAttribute("isAttacking"+odfaeg::core::conversionIntString(getId()), i);
                addAttribute("life"+odfaeg::core::conversionIntString(getId()), i);
                addAttribute("mana"+odfaeg::core::conversionIntString(getId()), i);
                addAttribute("position"+odfaeg::core::conversionIntString(getId()), i);
            }
            std::pair<odfaeg::math::Vec2f, odfaeg::math::Vec2f> interpolation;
            void setRegen(std::vector<int> regen);
            void setManaRegen (std::vector<int> regen);
            std::vector<int>& getRegen();
            std::vector<int>& getManaRegen();
            void restartRegenHP();
            void restartRegenMana();
            virtual ~Caracter();
            bool isAttacked();
            odfaeg::graphic::gui::ProgressBar* getXpBar();
            int getMana();
            void setMana(int mana);
            private :
            std::string name, currentMapName, classs;
            int level, attackMin, attackMax, sterk, range;
            float attackSpeed, regenHpSpeed, regenManaSpeed, speed;
            bool moving, alive;
            odfaeg::math::Vec2f dir;
            std::vector<odfaeg::math::Vec2f> path;
            std::vector<odfaeg::graphic::Anim*> anims;
            int currentAnimIndex;
            int life, maxLife, regenHpAmountMin, regenHpAmountMax, mana, regenManaAmountMin, regenManaAmountMax, maxMana;
            bool attacking, fightingMode;
            sf::Clock clockAtkSpeed, clockRegenHp, clockTransfertTime, clockBeforeLastRespawn, clockManaRegen;
            Caracter* focusedCaracter;
            ANIMS baseAnimIndex;
            sf::Time timeBefLastRespawn;
            std::vector<int> damages, regen, manaRegen;
            sf::Int64 dmgTransferTime, rgnTransferTime, rgnManaTransferTime;
            odfaeg::graphic::gui::ProgressBar *hpBar, *xpBar, *manaBar;
            bool attacked;
        };
    }
    #endif
    
    /**
              * \file entity.h
              * \class Entity
              * \brief Represent a 2D entity.
              * \author Duroisin.L
              * \version 1.0
              * \date 1/02/2014
              * \brief Abstract class which can represent any type of entities.
              *  Entities can have 0, 1 or more children and 0 or one parent.
              *  Each entity of the framework inherits from this class.
              */
            class EntityFactory {
                public :
                    EntityFactory() {
                        nbEntities = 0;
                        nbEntitiesTypes = 0;
                    }
                    int getIntOfType(std::string sType) {
                        std::map<int, std::string>::iterator it;
                        for (it = types.begin(); it != types.end(); ++it) {
                            if (it->second == sType)
                                return it->first;
                        }
                        return -1;
                    }
                    std::pair<int, std::string> updateTypes(std::string sType) {
                        int iType = getIntOfType(sType);
                        if (iType == -1) {
                            std::pair<int, std::string> type = std::pair<int, std::string> (nbEntitiesTypes, sType);
                            types.insert(type);
                            nbEntitiesTypes++;
                            return type;
                        } else {
                            std::map<int, std::string>::iterator it = types.find(iType);
                            return *it;
                        }
                    }
                    std::string getTypeOfInt (int type) {
                        std::map<int, std::string>::iterator it = types.find(type);
                        return it != types.end() ? it->second : "";
                    }
                    int getNbEntitiesTypes () {
                        return nbEntitiesTypes;
                    }
                    int getNbEntities () {
                        return nbEntities;
                    }
                    template <typename D, typename... Args>
                    D* make_entity(Args&&... args) {
                        return new D(std::forward<Args>(args)...);
                    }
                    int getUniqueId() {
                        nbEntities++;
                        return nbEntities-1;
                    }
                private :
                    //EntityFactory(const EntityFactory& entity) = delete; /**> an entity if not copiable.*/
                    //EntityFactory& operator=(const EntityFactory& entity) = delete; /**> an entity is not affectable*/
                    unsigned int nbEntities, nbEntitiesTypes;
                    std::map<int, std::string> types;
    
            };

    Pourtant j'inclu bien le fichier entity.h

    Merci.



    -
    Edité par OmbreNoire 6 septembre 2022 à 18:51:26

    • Partager sur Facebook
    • Partager sur Twitter
      6 septembre 2022 à 19:31:36

      >On dirait qu'il ne reconnaît pas ma classe EntityFactory ici :

      Qu'est-ce qui vous fait vous dire cela ???

      Moi, je suis bébête : "expected template-name before ‘<’ token", j'en déduit que ce qui est devant le "<" devrait être un type template => "odfaeg::core::Visitor".

      Or, vous ne nous donnez pas la définition de ce template, et s'il existe vraiment, pourquoi n'y a-t-il pas explicitement l'include correspondant (ou la forward déclaration correspondante).

      • Partager sur Facebook
      • Partager sur Twitter
      Je recherche un CDI/CDD/mission freelance comme Architecte Logiciel/ Expert Technique sur technologies Microsoft.
        6 septembre 2022 à 20:08:04

        Ah oui j'avais oublié d'inclure variant.h pourtant auparavant ça compilait bref résolu!
        • Partager sur Facebook
        • Partager sur Twitter
          6 septembre 2022 à 22:29:34

          J'aurais préféré un include de "Core/visitor.hpp" que de "variant.h".
          • Partager sur Facebook
          • Partager sur Twitter
          Je recherche un CDI/CDD/mission freelance comme Architecte Logiciel/ Expert Technique sur technologies Microsoft.

          erreur à la compilation

          × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
          × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
          • Editeur
          • Markdown