diff --git a/source/glest_game/ai/ai.h b/source/glest_game/ai/ai.h index 6038171f..5ec61f15 100644 --- a/source/glest_game/ai/ai.h +++ b/source/glest_game/ai/ai.h @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2001-2008 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -19,6 +19,7 @@ #include "commander.h" #include "command.h" #include "randomgen.h" +#include "leak_dumper.h" using std::deque; using std::vector; diff --git a/source/glest_game/ai/ai_interface.h b/source/glest_game/ai/ai_interface.h index cd206180..40921845 100644 --- a/source/glest_game/ai/ai_interface.h +++ b/source/glest_game/ai/ai_interface.h @@ -18,6 +18,7 @@ #include "conversion.h" #include "ai.h" #include "game_settings.h" +#include "leak_dumper.h" using Shared::Util::intToStr; diff --git a/source/glest_game/ai/ai_rule.h b/source/glest_game/ai/ai_rule.h new file mode 100644 index 00000000..8806b463 --- /dev/null +++ b/source/glest_game/ai/ai_rule.h @@ -0,0 +1,315 @@ +// ============================================================== +// This file is part of Glest (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _GLEST_GAME_AIRULE_H_ +#define _GLEST_GAME_AIRULE_H_ + +#include + +#include "vec.h" +#include "skill_type.h" +#include "leak_dumper.h" + +using std::string; + +using Shared::Graphics::Vec2i; + +namespace Glest{ namespace Game{ + +class Ai; +class Unit; +class UnitType; +class ProduceTask; +class BuildTask; +class UpgradeTask; +class ResourceType; + +// ===================================================== +// class AiRule +// +/// An action that the AI will perform periodically +/// if the test succeeds +// ===================================================== + +class AiRule{ +protected: + Ai *ai; + +public: + AiRule(Ai *ai); + virtual ~AiRule() {} + + virtual int getTestInterval() const= 0; //in milliseconds + virtual string getName() const= 0; + + virtual bool test()= 0; + virtual void execute()= 0; +}; + +// ===================================================== +// class AiRuleWorkerHarvest +// ===================================================== + +class AiRuleWorkerHarvest: public AiRule{ +private: + int stoppedWorkerIndex; + +public: + AiRuleWorkerHarvest(Ai *ai); + + virtual int getTestInterval() const {return 2000;} + virtual string getName() const {return "Worker stopped => Order worker to harvest";} + + virtual bool test(); + virtual void execute(); +}; + +// ===================================================== +// class AiRuleRefreshHarvester +// ===================================================== + +class AiRuleRefreshHarvester: public AiRule{ +private: + int workerIndex; + +public: + AiRuleRefreshHarvester(Ai *ai); + + virtual int getTestInterval() const {return 20000;} + virtual string getName() const {return "Worker reasigned to needed resource";} + + virtual bool test(); + virtual void execute(); +}; + +// ===================================================== +// class AiRuleScoutPatrol +// ===================================================== + +class AiRuleScoutPatrol: public AiRule{ +public: + AiRuleScoutPatrol(Ai *ai); + + virtual int getTestInterval() const {return 10000;} + virtual string getName() const {return "Base is stable => Send scout patrol";} + + virtual bool test(); + virtual void execute(); +}; + +// ===================================================== +// class AiRuleRepair +// ===================================================== + +class AiRuleRepair: public AiRule{ +private: + int damagedUnitIndex; + +public: + AiRuleRepair(Ai *ai); + + virtual int getTestInterval() const {return 10000;} + virtual string getName() const {return "Building Damaged => Repair";} + + virtual bool test(); + virtual void execute(); +}; + +// ===================================================== +// class AiRuleReturnBase +// ===================================================== + +class AiRuleReturnBase: public AiRule{ +private: + int stoppedUnitIndex; +public: + AiRuleReturnBase(Ai *ai); + + virtual int getTestInterval() const {return 5000;} + virtual string getName() const {return "Stopped unit => Order return base";} + + virtual bool test(); + virtual void execute(); +}; + +// ===================================================== +// class AiRuleMassiveAttack +// ===================================================== + +class AiRuleMassiveAttack: public AiRule{ +private: + static const int baseRadius= 25; + +private: + Vec2i attackPos; + Field field; + bool ultraAttack; + +public: + AiRuleMassiveAttack(Ai *ai); + + virtual int getTestInterval() const {return 1000;} + virtual string getName() const {return "Unit under attack => Order massive attack";} + + virtual bool test(); + virtual void execute(); +}; + +// ===================================================== +// class AiRuleAddTasks +// ===================================================== + +class AiRuleAddTasks: public AiRule{ +public: + AiRuleAddTasks(Ai *ai); + + virtual int getTestInterval() const {return 5000;} + virtual string getName() const {return "Tasks empty => Add tasks";} + + virtual bool test(); + virtual void execute(); +}; + +// ===================================================== +// class AiRuleBuildOneFarm +// ===================================================== + +class AiRuleBuildOneFarm: public AiRule{ +private: + const UnitType *farm; + +public: + AiRuleBuildOneFarm(Ai *ai); + + virtual int getTestInterval() const {return 10000;} + virtual string getName() const {return "No farms => Build one";} + + virtual bool test(); + virtual void execute(); +}; + +// ===================================================== +// class AiRuleProduceResourceProducer +// ===================================================== + +class AiRuleProduceResourceProducer: public AiRule{ +private: + static const int minStaticResources= 20; + static const int longInterval= 60000; + static const int shortInterval= 5000; + const ResourceType *rt; + int interval; + +public: + AiRuleProduceResourceProducer(Ai *ai); + + virtual int getTestInterval() const {return interval;} + virtual string getName() const {return "No resources => Build Resource Producer";} + + virtual bool test(); + virtual void execute(); +}; + +// ===================================================== +// class AiRuleProduce +// ===================================================== + +class AiRuleProduce: public AiRule{ +private: + const ProduceTask *produceTask; + +public: + AiRuleProduce(Ai *ai); + + virtual int getTestInterval() const {return 2000;} + virtual string getName() const {return "Performing produce task";} + + virtual bool test(); + virtual void execute(); + +private: + void produceGeneric(const ProduceTask *pt); + void produceSpecific(const ProduceTask *pt); +}; +// ===================================================== +// class AiRuleBuild +// ===================================================== + +class AiRuleBuild: public AiRule{ +private: + const BuildTask *buildTask; + +public: + AiRuleBuild(Ai *ai); + + virtual int getTestInterval() const {return 2000;} + virtual string getName() const {return "Performing build task";} + + virtual bool test(); + virtual void execute(); + +private: + void buildGeneric(const BuildTask *bt); + void buildSpecific(const BuildTask *bt); + void buildBestBuilding(const vector &buildings); + + bool isDefensive(const UnitType *building); + bool isResourceProducer(const UnitType *building); + bool isWarriorProducer(const UnitType *building); +}; + +// ===================================================== +// class AiRuleUpgrade +// ===================================================== + +class AiRuleUpgrade: public AiRule{ +private: + const UpgradeTask *upgradeTask; + +public: + AiRuleUpgrade(Ai *ai); + + virtual int getTestInterval() const {return 2000;} + virtual string getName() const {return "Performing upgrade task";} + + virtual bool test(); + virtual void execute(); + +private: + void upgradeSpecific(const UpgradeTask *upgt); + void upgradeGeneric(const UpgradeTask *upgt); +}; + +// ===================================================== +// class AiRuleExpand +// ===================================================== + +class AiRuleExpand: public AiRule{ +private: + static const int expandDistance= 30; + +private: + Vec2i expandPos; + const UnitType *storeType; + +public: + AiRuleExpand(Ai *ai); + + virtual int getTestInterval() const {return 30000;} + virtual string getName() const {return "Expanding";} + + virtual bool test(); + virtual void execute(); +}; + +}}//end namespace + +#endif diff --git a/source/glest_game/ai/path_finder.h b/source/glest_game/ai/path_finder.h index 1a82b1bd..501844f2 100644 --- a/source/glest_game/ai/path_finder.h +++ b/source/glest_game/ai/path_finder.h @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2001-2008 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -16,6 +16,7 @@ #include #include "game_constants.h" +#include "leak_dumper.h" using std::vector; using Shared::Graphics::Vec2i; diff --git a/source/glest_game/facilities/auto_test.h b/source/glest_game/facilities/auto_test.h index 07f503e6..85e7e38c 100644 --- a/source/glest_game/facilities/auto_test.h +++ b/source/glest_game/facilities/auto_test.h @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2009 Martiño Figueroa +// Copyright (C) 2001-2009 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -15,6 +15,7 @@ #include #include "randomgen.h" +#include "leak_dumper.h" using Shared::Util::RandomGen; diff --git a/source/glest_game/facilities/components.h b/source/glest_game/facilities/components.h index f51c8848..296edbca 100644 --- a/source/glest_game/facilities/components.h +++ b/source/glest_game/facilities/components.h @@ -16,6 +16,7 @@ #include #include "font.h" +#include "leak_dumper.h" using std::string; using std::vector; diff --git a/source/glest_game/facilities/game_util.h b/source/glest_game/facilities/game_util.h index d81c6bf7..fd2eab64 100644 --- a/source/glest_game/facilities/game_util.h +++ b/source/glest_game/facilities/game_util.h @@ -16,6 +16,7 @@ #include #include "util.h" +#include "leak_dumper.h" using std::string; using Shared::Util::sharedLibVersionString; diff --git a/source/glest_game/facilities/logger.h b/source/glest_game/facilities/logger.h index bcadbf16..0ef87484 100644 --- a/source/glest_game/facilities/logger.h +++ b/source/glest_game/facilities/logger.h @@ -16,6 +16,7 @@ #include #include "texture.h" +#include "leak_dumper.h" using std::string; using std::deque; diff --git a/source/glest_game/game/chat_manager.h b/source/glest_game/game/chat_manager.h index 13f5a86b..e3a0851e 100644 --- a/source/glest_game/game/chat_manager.h +++ b/source/glest_game/game/chat_manager.h @@ -13,6 +13,7 @@ #define _GLEST_GAME_CHATMANAGER_H_ #include +#include "leak_dumper.h" using std::string; diff --git a/source/glest_game/game/commander.h b/source/glest_game/game/commander.h index f2cfb7b6..471a7bdc 100644 --- a/source/glest_game/game/commander.h +++ b/source/glest_game/game/commander.h @@ -18,6 +18,7 @@ #include "selection.h" #include "command_type.h" #include "platform_util.h" +#include "leak_dumper.h" using std::vector; diff --git a/source/glest_game/game/console.h b/source/glest_game/game/console.h index 4e4d36a8..e7aa15b0 100644 --- a/source/glest_game/game/console.h +++ b/source/glest_game/game/console.h @@ -16,6 +16,7 @@ #include #include #include +#include "leak_dumper.h" using std::string; using std::vector; diff --git a/source/glest_game/game/game.h b/source/glest_game/game/game.h index e93a5bd8..b0646321 100644 --- a/source/glest_game/game/game.h +++ b/source/glest_game/game/game.h @@ -22,8 +22,8 @@ #include "chat_manager.h" #include "script_manager.h" #include "game_settings.h" -//#include "simple_threads.h" #include "network_interface.h" +#include "leak_dumper.h" using std::vector; using namespace Shared::PlatformCommon; diff --git a/source/glest_game/game/game_settings.h b/source/glest_game/game/game_settings.h index 5e96f443..b1f4fef7 100644 --- a/source/glest_game/game/game_settings.h +++ b/source/glest_game/game/game_settings.h @@ -14,6 +14,7 @@ #include "game_constants.h" #include "conversion.h" +#include "leak_dumper.h" using namespace Shared::Util; diff --git a/source/glest_game/game/script_manager.h b/source/glest_game/game/script_manager.h index 9a3183aa..141bacfd 100644 --- a/source/glest_game/game/script_manager.h +++ b/source/glest_game/game/script_manager.h @@ -16,10 +16,10 @@ #include #include "lua_script.h" - #include "components.h" #include "game_constants.h" #include +#include "leak_dumper.h" using std::string; using std::queue; diff --git a/source/glest_game/game/stats.h b/source/glest_game/game/stats.h index 68fbb7bd..0fc549ae 100644 --- a/source/glest_game/game/stats.h +++ b/source/glest_game/game/stats.h @@ -18,6 +18,7 @@ #include "faction.h" #include "faction_type.h" #include "vec.h" +#include "leak_dumper.h" using std::string; using namespace Shared::Graphics; diff --git a/source/glest_game/global/config.h b/source/glest_game/global/config.h index bfac6ccd..82953029 100644 --- a/source/glest_game/global/config.h +++ b/source/glest_game/global/config.h @@ -14,8 +14,8 @@ #include "properties.h" #include -//#include #include "game_constants.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/global/core_data.h b/source/glest_game/global/core_data.h index 99b51168..dcea3412 100644 --- a/source/glest_game/global/core_data.h +++ b/source/glest_game/global/core_data.h @@ -18,6 +18,7 @@ #include "font.h" #include "texture.h" #include "sound_container.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/global/lang.h b/source/glest_game/global/lang.h new file mode 100644 index 00000000..820b3262 --- /dev/null +++ b/source/glest_game/global/lang.h @@ -0,0 +1,47 @@ +// ============================================================== +// This file is part of Glest (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _GLEST_GAME_LANG_H_ +#define _GLEST_GAME_LANG_H_ + +#include "properties.h" +#include "leak_dumper.h" + +namespace Glest{ namespace Game{ + +using Shared::Util::Properties; + +// ===================================================== +// class Lang +// +// String table +// ===================================================== + +class Lang{ +private: + string language; + Properties strings; + Properties scenarioStrings; + +private: + Lang(){}; + +public: + static Lang &getInstance(); + void loadStrings(const string &language); + void loadScenarioStrings(const string &scenarioDir, const string &scenarioName); + string get(const string &s); + string getScenarioString(const string &s); +}; + +}}//end namespace + +#endif diff --git a/source/glest_game/global/metrics.h b/source/glest_game/global/metrics.h new file mode 100644 index 00000000..4c1b57a2 --- /dev/null +++ b/source/glest_game/global/metrics.h @@ -0,0 +1,68 @@ +// ============================================================== +// This file is part of Glest (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _GLEST_GAME_METRICS_H_ +#define _GLEST_GAME_METRICS_H_ + +#include "config.h" +#include "leak_dumper.h" + +namespace Glest{ namespace Game{ + +// ===================================================== +// class Metrics +// ===================================================== + +class Metrics{ +private: + int virtualW; + int virtualH; + int screenW; + int screenH; + int minimapX; + int minimapY; + int minimapW; + int minimapH; + int displayX; + int displayY; + int displayH; + int displayW; + +private: + Metrics(); + +public: + static const Metrics &getInstance(); + + int getVirtualW() const {return virtualW;} + int getVirtualH() const {return virtualH;} + int getScreenW() const {return screenW;} + int getScreenH() const {return screenH;} + int getMinimapX() const {return minimapX;} + int getMinimapY() const {return minimapY;} + int getMinimapW() const {return minimapW;} + int getMinimapH() const {return minimapH;} + int getDisplayX() const {return displayX;} + int getDisplayY() const {return displayY;} + int getDisplayH() const {return displayH;} + int getDisplayW() const {return displayW;} + float getAspectRatio() const; + + int toVirtualX(int w) const; + int toVirtualY(int h) const; + + bool isInDisplay(int x, int y) const; + bool isInMinimap(int x, int y) const; +}; + +}}//end namespace + +#endif diff --git a/source/glest_game/graphics/particle_type.h b/source/glest_game/graphics/particle_type.h index e45357ec..2a2b8e2e 100644 --- a/source/glest_game/graphics/particle_type.h +++ b/source/glest_game/graphics/particle_type.h @@ -20,6 +20,7 @@ #include "vec.h" #include "xml_parser.h" #include "graphics_interface.h" +#include "leak_dumper.h" using std::string; using namespace Shared::Graphics; diff --git a/source/glest_game/graphics/renderer.h b/source/glest_game/graphics/renderer.h index 7000cacd..8874a982 100644 --- a/source/glest_game/graphics/renderer.h +++ b/source/glest_game/graphics/renderer.h @@ -38,6 +38,8 @@ # define IF_DEBUG_EDITION(x) #endif +#include "leak_dumper.h" + namespace Glest{ namespace Game{ using namespace Shared::Graphics; diff --git a/source/glest_game/graphics/unit_particle_type.h b/source/glest_game/graphics/unit_particle_type.h index b8cc24b7..c136e273 100644 --- a/source/glest_game/graphics/unit_particle_type.h +++ b/source/glest_game/graphics/unit_particle_type.h @@ -20,6 +20,7 @@ #include "vec.h" #include "xml_parser.h" #include "graphics_interface.h" +#include "leak_dumper.h" using std::string; using namespace Shared::Graphics; diff --git a/source/glest_game/gui/display.h b/source/glest_game/gui/display.h index cc3599e6..be34fa53 100644 --- a/source/glest_game/gui/display.h +++ b/source/glest_game/gui/display.h @@ -18,6 +18,7 @@ #include "util.h" #include "command_type.h" #include "game_util.h" +#include "leak_dumper.h" using std::string; diff --git a/source/glest_game/gui/gui.h b/source/glest_game/gui/gui.h index 45073a99..d9981c7d 100644 --- a/source/glest_game/gui/gui.h +++ b/source/glest_game/gui/gui.h @@ -20,6 +20,7 @@ #include "selection.h" #include "randomgen.h" #include +#include "leak_dumper.h" using Shared::Util::RandomGen; diff --git a/source/glest_game/gui/selection.h b/source/glest_game/gui/selection.h new file mode 100644 index 00000000..2fffed4e --- /dev/null +++ b/source/glest_game/gui/selection.h @@ -0,0 +1,77 @@ +// ============================================================== +// This file is part of Glest (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _GLEST_GAME_SELECTION_ +#define _GLEST_GAME_SELECTION_ + +#include "unit.h" +#include +#include "leak_dumper.h" + +using std::vector; + +namespace Glest{ namespace Game{ + +class Gui; + +// ===================================================== +// class Selection +// +/// List of selected units and groups +// ===================================================== + +class Selection: public UnitObserver{ +public: + typedef vector UnitContainer; + typedef UnitContainer::const_iterator UnitIterator; + +public: + static const int maxGroups= 10; + static const int maxUnits= 16; + +private: + int factionIndex; + UnitContainer selectedUnits; + UnitContainer groups[maxGroups]; + Gui *gui; + +public: + void init(Gui *gui, int factionIndex); + virtual ~Selection(); + + void select(Unit *unit); + void select(const UnitContainer &units); + void unSelect(int unitIndex); + void unSelect(const UnitContainer &units); + void clear(); + + bool isEmpty() const {return selectedUnits.empty();} + bool isUniform() const; + bool isEnemy() const; + bool isComandable() const; + bool isCancelable() const; + bool isMeetable() const; + int getCount() const {return selectedUnits.size();} + const Unit *getUnit(int i) const {return selectedUnits[i];} + const Unit *getFrontUnit() const {return selectedUnits.front();} + Vec3f getRefPos() const; + bool hasUnit(const Unit* unit) const; + + void assignGroup(int groupIndex); + void recallGroup(int groupIndex); + + + virtual void unitEvent(UnitObserver::Event event, const Unit *unit); +}; + +}}//end namespace + +#endif diff --git a/source/glest_game/main/battle_end.h b/source/glest_game/main/battle_end.h index af008a41..e08db503 100644 --- a/source/glest_game/main/battle_end.h +++ b/source/glest_game/main/battle_end.h @@ -14,6 +14,7 @@ #include "program.h" #include "stats.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/main/intro.h b/source/glest_game/main/intro.h new file mode 100644 index 00000000..8559ea7b --- /dev/null +++ b/source/glest_game/main/intro.h @@ -0,0 +1,85 @@ +// ============================================================== +// This file is part of Glest (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _GLEST_GAME_INTRO_H_ +#define _GLEST_GAME_INTRO_H_ + +#include + +#include "program.h" +#include "font.h" +#include "vec.h" +#include "texture.h" +#include "leak_dumper.h" + +using std::vector; + +using Shared::Graphics::Vec2i; +using Shared::Graphics::Vec2f; +using Shared::Graphics::Vec3f; +using Shared::Graphics::Font2D; +using Shared::Graphics::Texture2D; + +namespace Glest{ namespace Game{ + +// ===================================================== +// class Text +// ===================================================== + +class Text{ +private: + string text; + Vec2i pos; + Vec2i size; + int time; + const Font2D *font; + const Texture2D *texture; + +public: + Text(const string &text, const Vec2i &pos, int time, const Font2D *font); + Text(const Texture2D *texture, const Vec2i &pos, const Vec2i &size, int time); + + const string &getText() const {return text;} + const Font2D *getFont() const {return font;} + const Vec2i &getPos() const {return pos;} + const Vec2i &getSize() const {return size;} + int getTime() const {return time;} + const Texture2D *getTexture() const {return texture;} +}; + +// ===================================================== +// class Intro +// +/// ProgramState representing the intro +// ===================================================== + +class Intro: public ProgramState{ +private: + static const int introTime; + static const int appearTime; + static const int showTime; + static const int disapearTime; + +private: + vector texts; + int timer; + +public: + Intro(Program *program); + virtual void update(); + virtual void render(); + virtual void keyDown(char key); + virtual void mouseUpLeft(int x, int y); +}; + +}}//end namespace + +#endif diff --git a/source/glest_game/main/main.h b/source/glest_game/main/main.h index d132865c..2a473897 100644 --- a/source/glest_game/main/main.h +++ b/source/glest_game/main/main.h @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2001-2008 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -16,6 +16,7 @@ #include "program.h" #include "window_gl.h" +#include "leak_dumper.h" using Shared::Platform::MouseButton; using Shared::Platform::MouseState; diff --git a/source/glest_game/main/program.h b/source/glest_game/main/program.h index 7328d680..a143918f 100644 --- a/source/glest_game/main/program.h +++ b/source/glest_game/main/program.h @@ -20,6 +20,7 @@ #include "window.h" #include "simple_threads.h" #include "stats.h" +#include "leak_dumper.h" using Shared::Platform::MouseButton; using Shared::Graphics::Context; diff --git a/source/glest_game/menu/main_menu.h b/source/glest_game/menu/main_menu.h index a4d91ace..bb7b0603 100644 --- a/source/glest_game/menu/main_menu.h +++ b/source/glest_game/menu/main_menu.h @@ -20,6 +20,7 @@ #include "components.h" #include "menu_background.h" #include "game_settings.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/menu/menu_background.h b/source/glest_game/menu/menu_background.h index a655dd63..555f3efe 100644 --- a/source/glest_game/menu/menu_background.h +++ b/source/glest_game/menu/menu_background.h @@ -18,6 +18,7 @@ #include "texture.h" #include "model.h" #include "randomgen.h" +#include "leak_dumper.h" using Shared::Graphics::RainParticleSystem; using Shared::Graphics::FireParticleSystem; diff --git a/source/glest_game/menu/menu_state_about.h b/source/glest_game/menu/menu_state_about.h new file mode 100644 index 00000000..fd14386e --- /dev/null +++ b/source/glest_game/menu/menu_state_about.h @@ -0,0 +1,47 @@ +// ============================================================== +// This file is part of Glest (www.glest.org) +// +// Copyright (C) 2001-2005 Marti�o Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _GLEST_GAME_MENUSTATEABOUT_H_ +#define _GLEST_GAME_MENUSTATEABOUT_H_ + +#include "main_menu.h" +#include "leak_dumper.h" + +namespace Glest{ namespace Game{ + +// =============================== +// class MenuStateAbout +// =============================== + +class MenuStateAbout: public MenuState{ +public: + static const int aboutStringCount1= 3; + static const int aboutStringCount2= 3; + static const int teammateCount= 9; + +private: + GraphicButton buttonReturn; + GraphicLabel labelAbout1[aboutStringCount1]; + GraphicLabel labelAbout2[aboutStringCount2]; + GraphicLabel labelTeammateName[teammateCount]; + GraphicLabel labelTeammateRole[teammateCount]; + +public: + MenuStateAbout(Program *program, MainMenu *mainMenu); + + void mouseClick(int x, int y, MouseButton mouseButton); + void mouseMove(int x, int y, const MouseState *mouseState); + void render(); +}; + +}}//end namespace + +#endif diff --git a/source/glest_game/menu/menu_state_connected_game.h b/source/glest_game/menu/menu_state_connected_game.h index 05ad5edd..ac2072c4 100644 --- a/source/glest_game/menu/menu_state_connected_game.h +++ b/source/glest_game/menu/menu_state_connected_game.h @@ -14,6 +14,7 @@ #include "main_menu.h" #include "chat_manager.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/menu/menu_state_custom_game.h b/source/glest_game/menu/menu_state_custom_game.h index f6128ffb..d0e2d6c9 100644 --- a/source/glest_game/menu/menu_state_custom_game.h +++ b/source/glest_game/menu/menu_state_custom_game.h @@ -15,6 +15,7 @@ #include "main_menu.h" #include "chat_manager.h" #include "simple_threads.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ // =============================== diff --git a/source/glest_game/menu/menu_state_graphic_info.h b/source/glest_game/menu/menu_state_graphic_info.h new file mode 100644 index 00000000..867ddd6a --- /dev/null +++ b/source/glest_game/menu/menu_state_graphic_info.h @@ -0,0 +1,42 @@ +// ============================================================== +// This file is part of Glest (www.glest.org) +// +// Copyright (C) 2001-2005 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _GLEST_GAME_MENUSTATEGRAPHICINFO_H_ +#define _GLEST_GAME_MENUSTATEGRAPHICINFO_H_ + +#include "main_menu.h" +#include "leak_dumper.h" + +namespace Glest{ namespace Game{ + +// =============================== +// class MenuStateGraphicInfo +// =============================== + +class MenuStateGraphicInfo: public MenuState{ +private: + GraphicButton buttonReturn; + GraphicLabel labelInfo; + GraphicLabel labelMoreInfo; + + string glInfo; + string glMoreInfo; +public: + MenuStateGraphicInfo(Program *program, MainMenu *mainMenu); + + void mouseClick(int x, int y, MouseButton mouseButton); + void mouseMove(int x, int y, const MouseState *mouseState); + void render(); +}; + +}}//end namespace + +#endif diff --git a/source/glest_game/menu/menu_state_join_game.h b/source/glest_game/menu/menu_state_join_game.h index 186ae450..82bb2388 100644 --- a/source/glest_game/menu/menu_state_join_game.h +++ b/source/glest_game/menu/menu_state_join_game.h @@ -17,6 +17,7 @@ #include "chat_manager.h" #include #include +#include "leak_dumper.h" using Shared::Util::Properties; diff --git a/source/glest_game/menu/menu_state_masterserver.h b/source/glest_game/menu/menu_state_masterserver.h index f305cd32..6ea3ab76 100644 --- a/source/glest_game/menu/menu_state_masterserver.h +++ b/source/glest_game/menu/menu_state_masterserver.h @@ -16,6 +16,7 @@ #include "masterserver_info.h" #include "simple_threads.h" #include "network_interface.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/menu/menu_state_new_game.h b/source/glest_game/menu/menu_state_new_game.h new file mode 100644 index 00000000..0b4ed612 --- /dev/null +++ b/source/glest_game/menu/menu_state_new_game.h @@ -0,0 +1,43 @@ +// ============================================================== +// This file is part of Glest (www.glest.org) +// +// Copyright (C) 2001-2005 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _GLEST_GAME_MENUSTATENEWGAME_H_ +#define _GLEST_GAME_MENUSTATENEWGAME_H_ + +#include "main_menu.h" +#include "leak_dumper.h" + +namespace Glest{ namespace Game{ + +// =============================== +// class MenuStateNewGame +// =============================== + +class MenuStateNewGame: public MenuState{ +private: + GraphicButton buttonCustomGame; + GraphicButton buttonScenario; + GraphicButton buttonTutorial; + GraphicButton buttonReturn; + +public: + MenuStateNewGame(Program *program, MainMenu *mainMenu); + + void mouseClick(int x, int y, MouseButton mouseButton); + void mouseMove(int x, int y, const MouseState *mouseState); + void update(); + void render(); +}; + + +}}//end namespace + +#endif diff --git a/source/glest_game/menu/menu_state_options.h b/source/glest_game/menu/menu_state_options.h index 10afd6f3..acb44d4a 100644 --- a/source/glest_game/menu/menu_state_options.h +++ b/source/glest_game/menu/menu_state_options.h @@ -13,6 +13,7 @@ #define _GLEST_GAME_MENUSTATEOPTIONS_H_ #include "main_menu.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/menu/menu_state_root.h b/source/glest_game/menu/menu_state_root.h index b8396aa7..e322d0bb 100644 --- a/source/glest_game/menu/menu_state_root.h +++ b/source/glest_game/menu/menu_state_root.h @@ -13,6 +13,7 @@ #define _GLEST_GAME_MENUSTATEROOT_H_ #include "main_menu.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/menu/menu_state_scenario.h b/source/glest_game/menu/menu_state_scenario.h index c95cce2d..7f8370ee 100644 --- a/source/glest_game/menu/menu_state_scenario.h +++ b/source/glest_game/menu/menu_state_scenario.h @@ -13,6 +13,7 @@ #define _GLEST_GAME_MENUSTATESCENARIO_H_ #include "main_menu.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/network/client_interface.h b/source/glest_game/network/client_interface.h index 3e82af34..21f7f9aa 100644 --- a/source/glest_game/network/client_interface.h +++ b/source/glest_game/network/client_interface.h @@ -15,9 +15,8 @@ #include #include "network_interface.h" -//#include "game_settings.h" - #include "socket.h" +#include "leak_dumper.h" using Shared::Platform::Ip; using Shared::Platform::ClientSocket; diff --git a/source/glest_game/network/connection_slot.h b/source/glest_game/network/connection_slot.h index 2df56371..8b340eb3 100644 --- a/source/glest_game/network/connection_slot.h +++ b/source/glest_game/network/connection_slot.h @@ -17,6 +17,7 @@ #include "network_interface.h" #include #include "base_thread.h" +#include "leak_dumper.h" using Shared::Platform::ServerSocket; using Shared::Platform::Socket; diff --git a/source/glest_game/network/masterserver_info.h b/source/glest_game/network/masterserver_info.h index 12ab088d..2d9c570b 100644 --- a/source/glest_game/network/masterserver_info.h +++ b/source/glest_game/network/masterserver_info.h @@ -13,6 +13,8 @@ #define _GLEST_GAME_MASTERSERVERINFO_H_ #include +#include "leak_dumper.h" + using std::string; namespace Glest{ namespace Game{ diff --git a/source/glest_game/network/network_interface.h b/source/glest_game/network/network_interface.h index 9ef08430..c3019847 100644 --- a/source/glest_game/network/network_interface.h +++ b/source/glest_game/network/network_interface.h @@ -24,6 +24,7 @@ #include "thread.h" #include "types.h" #include +#include "leak_dumper.h" using std::string; using std::vector; diff --git a/source/glest_game/network/network_manager.h b/source/glest_game/network/network_manager.h index f6077808..2c5c1d16 100644 --- a/source/glest_game/network/network_manager.h +++ b/source/glest_game/network/network_manager.h @@ -18,6 +18,7 @@ #include "checksum.h" #include "server_interface.h" #include "client_interface.h" +#include "leak_dumper.h" using Shared::Util::Checksum; diff --git a/source/glest_game/network/network_message.h b/source/glest_game/network/network_message.h index eda28174..f3357f35 100644 --- a/source/glest_game/network/network_message.h +++ b/source/glest_game/network/network_message.h @@ -15,6 +15,7 @@ #include "socket.h" #include "game_constants.h" #include "network_types.h" +#include "leak_dumper.h" using Shared::Platform::Socket; using Shared::Platform::int8; diff --git a/source/glest_game/network/network_types.h b/source/glest_game/network/network_types.h index 59bb9b59..e66c4beb 100644 --- a/source/glest_game/network/network_types.h +++ b/source/glest_game/network/network_types.h @@ -17,6 +17,7 @@ #include "types.h" #include "vec.h" #include "command.h" +#include "leak_dumper.h" using std::string; using std::min; diff --git a/source/glest_game/network/server_interface.h b/source/glest_game/network/server_interface.h index ed8f981b..f47669e3 100644 --- a/source/glest_game/network/server_interface.h +++ b/source/glest_game/network/server_interface.h @@ -18,6 +18,7 @@ #include "network_interface.h" #include "connection_slot.h" #include "socket.h" +#include "leak_dumper.h" using std::vector; using Shared::Platform::ServerSocket; diff --git a/source/glest_game/sound/sound_container.h b/source/glest_game/sound/sound_container.h index 697d4bf0..16524f66 100644 --- a/source/glest_game/sound/sound_container.h +++ b/source/glest_game/sound/sound_container.h @@ -13,9 +13,9 @@ #define _GLEST_GAME_SOUNDCONTAINER_H_ #include - #include "sound.h" #include "randomgen.h" +#include "leak_dumper.h" using std::vector; using Shared::Util::RandomGen; diff --git a/source/glest_game/sound/sound_renderer.h b/source/glest_game/sound/sound_renderer.h index 233508e1..8fa567f6 100644 --- a/source/glest_game/sound/sound_renderer.h +++ b/source/glest_game/sound/sound_renderer.h @@ -18,6 +18,7 @@ #include "vec.h" #include "simple_threads.h" #include "platform_common.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/type_instances/command.h b/source/glest_game/type_instances/command.h index 4746245c..909dbcd1 100644 --- a/source/glest_game/type_instances/command.h +++ b/source/glest_game/type_instances/command.h @@ -17,6 +17,7 @@ #include "unit.h" #include "vec.h" #include "game_constants.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/type_instances/faction.h b/source/glest_game/type_instances/faction.h index f3790e73..a5f1ab85 100644 --- a/source/glest_game/type_instances/faction.h +++ b/source/glest_game/type_instances/faction.h @@ -19,6 +19,7 @@ #include "texture.h" #include "resource.h" #include "game_constants.h" +#include "leak_dumper.h" using std::map; using std::vector; diff --git a/source/glest_game/type_instances/object.h b/source/glest_game/type_instances/object.h index 7e4e7138..e9b48d7d 100644 --- a/source/glest_game/type_instances/object.h +++ b/source/glest_game/type_instances/object.h @@ -13,6 +13,7 @@ #include "model.h" #include "vec.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/type_instances/resource.h b/source/glest_game/type_instances/resource.h new file mode 100644 index 00000000..0b74a3ca --- /dev/null +++ b/source/glest_game/type_instances/resource.h @@ -0,0 +1,57 @@ +// ============================================================== +// This file is part of Glest (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== +#ifndef _GLEST_GAME_RESOURCE_H_ +#define _GLEST_GAME_RESOURCE_H_ + +#include +#include "vec.h" +#include "leak_dumper.h" + +using std::string; + +namespace Glest{ namespace Game{ + +using Shared::Graphics::Vec2i; + +class ResourceType; + +// ===================================================== +// class Resource +// +/// Amount of a given ResourceType +// ===================================================== + +class Resource{ +private: + int amount; + const ResourceType *type; + Vec2i pos; + int balance; + +public: + void init(const ResourceType *rt, int amount); + void init(const ResourceType *rt, const Vec2i &pos); + + int getAmount() const {return amount;} + const ResourceType * getType() const {return type;} + Vec2i getPos() const {return pos;} + int getBalance() const {return balance;} + string getDescription() const; + + void setAmount(int amount) {this->amount= amount;} + void setBalance(int balance) {this->balance= balance;} + + bool decAmount(int i); +}; + +}}// end namespace + +#endif diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index a6f0c26d..d1b56047 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -259,7 +259,10 @@ Unit::~Unit(){ // If the unit is not visible we better make sure we cleanup associated particles if(this->getVisible() == false) { Renderer::getInstance().cleanupUnitParticleSystems(unitParticleSystems,rsGame); + Renderer::getInstance().cleanupParticleSystems(fireParticleSystems,rsGame); + // Must set this to null of it will be used below in stopDamageParticles() + fire = NULL; } // fade(and by this remove) all unit particle systems @@ -923,7 +926,7 @@ const CommandType *Unit::computeCommandType(const Vec2i &pos, const Unit *target return commandType; } -bool Unit::update(){ +bool Unit::update() { assert(progress<=1.f); //highlight @@ -1491,7 +1494,7 @@ CommandResult Unit::undoCommand(Command *command){ return crSuccess; } -void Unit::stopDamageParticles(){ +void Unit::stopDamageParticles() { // stop fire if(fire != NULL) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -1521,7 +1524,7 @@ void Unit::startDamageParticles(){ } } // start fire - if(type->getProperty(UnitType::pBurnable) && fire==NULL){ + if(type->getProperty(UnitType::pBurnable) && fire == NULL) { FireParticleSystem *fps; fps= new FireParticleSystem(200); const Game *game = Renderer::getInstance().getGame(); diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index 2c394748..454eb2a8 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -18,6 +18,7 @@ #include "skill_type.h" #include "game_constants.h" #include +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/type_instances/upgrade.h b/source/glest_game/type_instances/upgrade.h index c40755ad..64c861a5 100644 --- a/source/glest_game/type_instances/upgrade.h +++ b/source/glest_game/type_instances/upgrade.h @@ -14,6 +14,7 @@ #include #include +#include "leak_dumper.h" using std::vector; diff --git a/source/glest_game/types/command_type.h b/source/glest_game/types/command_type.h index 1d3c7041..b521212f 100644 --- a/source/glest_game/types/command_type.h +++ b/source/glest_game/types/command_type.h @@ -19,6 +19,7 @@ #include "factory.h" #include "xml_parser.h" #include "sound_container.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/types/damage_multiplier.h b/source/glest_game/types/damage_multiplier.h new file mode 100644 index 00000000..3e1e60e6 --- /dev/null +++ b/source/glest_game/types/damage_multiplier.h @@ -0,0 +1,80 @@ +// ============================================================== +// This file is part of Glest (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _GLEST_GAME_DAMAGEMULTIPLIER_H_ +#define _GLEST_GAME_DAMAGEMULTIPLIER_H_ + +#include +#include "leak_dumper.h" + +using std::string; + +namespace Glest{ namespace Game{ + +// =============================== +// class AttackType +// =============================== + +class AttackType{ +private: + string name; + int id; + +public: + int getId() const {return id;} + const string &getName() const {return name;} + + void setName(const string &name) {this->name= name;} + void setId(int id) {this->id= id;} +}; + +// =============================== +// class ArmorType +// =============================== + +class ArmorType{ +private: + string name; + int id; + +public: + int getId() const {return id;} + const string &getName() const {return name;} + + void setName(const string &name) {this->name= name;} + void setId(int id) {this->id= id;} +}; + +// ===================================================== +// class DamageMultiplierTable +// +/// Some attack types have bonuses against some +/// armor types and vice-versa +// ===================================================== + +class DamageMultiplierTable{ +private: + float *values; + int attackTypeCount; + int armorTypeCount; + +public: + DamageMultiplierTable(); + ~DamageMultiplierTable(); + + void init(int attackTypeCount, int armorTypeCount); + float getDamageMultiplier(const AttackType *att, const ArmorType *art) const; + void setDamageMultiplier(const AttackType *att, const ArmorType *art, float value); +}; + +}}//end namespace + +#endif diff --git a/source/glest_game/types/element_type.h b/source/glest_game/types/element_type.h index 5011d4c7..9170e5d9 100644 --- a/source/glest_game/types/element_type.h +++ b/source/glest_game/types/element_type.h @@ -17,6 +17,7 @@ #include "texture.h" #include "resource.h" +#include "leak_dumper.h" using std::vector; using std::string; diff --git a/source/glest_game/types/faction_type.h b/source/glest_game/types/faction_type.h index ec03cd0f..4dae8795 100644 --- a/source/glest_game/types/faction_type.h +++ b/source/glest_game/types/faction_type.h @@ -15,6 +15,7 @@ #include "unit_type.h" #include "upgrade_type.h" #include "sound.h" +#include "leak_dumper.h" using Shared::Sound::StrSound; diff --git a/source/glest_game/types/object_type.h b/source/glest_game/types/object_type.h new file mode 100644 index 00000000..20a94ce5 --- /dev/null +++ b/source/glest_game/types/object_type.h @@ -0,0 +1,63 @@ +// ============================================================== +// This file is part of Glest (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== +#ifndef _GLEST_GAME_OBJECTTYPE_H_ +#define _GLEST_GAME_OBJECTTYPE_H_ + +#include + +#include "model.h" +#include "vec.h" +#include "leak_dumper.h" + +using std::vector; + +namespace Glest{ namespace Game{ + +using Shared::Graphics::Model; +using Shared::Graphics::Vec3f; + +// ===================================================== +// class ObjectType +// +/// Each of the possible objects of the map: trees, stones ... +// ===================================================== + +class ObjectType{ +private: + typedef vector Models; + +private: + static const int tree1= 0; + static const int tree2= 1; + static const int choppedTree= 2; + +private: + Models models; + Vec3f color; + int objectClass; + bool walkable; + +public: + void init(int modelCount, int objectClass, bool walkable); + + void loadModel(const string &path); + + Model *getModel(int i) {return models[i];} + int getModelCount() const {return models.size();} + const Vec3f &getColor() const {return color;} + int getClass() const {return objectClass;} + bool getWalkable() const {return walkable;} + bool isATree() const {return objectClass==tree1 || objectClass==tree2;} +}; + +}}//end namespace + +#endif diff --git a/source/glest_game/types/resource_type.h b/source/glest_game/types/resource_type.h new file mode 100644 index 00000000..26687f95 --- /dev/null +++ b/source/glest_game/types/resource_type.h @@ -0,0 +1,66 @@ +// ============================================================== +// This file is part of Glest (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _GLEST_GAME_RESOURCETYPE_H_ +#define _GLEST_GAME_RESOURCETYPE_H_ + +#include "element_type.h" +#include "model.h" +#include "checksum.h" +#include "leak_dumper.h" + +namespace Glest{ namespace Game{ + +using Shared::Graphics::Model; +using Shared::Util::Checksum; + +enum ResourceClass{ + rcTech, + rcTileset, + rcStatic, + rcConsumable +}; + +// ===================================================== +// class ResourceType +// +/// A type of resource that can be harvested or not +// ===================================================== + +class ResourceType: public DisplayableType{ +private: + ResourceClass resourceClass; + int tilesetObject; //used only if class==rcTileset + int resourceNumber; //used only if class==rcTech, resource number in the map + int interval; //used only if class==rcConsumable + int defResPerPatch; //used only if class==rcTileset || class==rcTech + bool recoup_cost; + + Model *model; + +public: + void load(const string &dir, Checksum* checksum); + + //get + int getClass() const {return resourceClass;} + int getTilesetObject() const {return tilesetObject;} + int getResourceNumber() const {return resourceNumber;} + int getInterval() const {return interval;} + int getDefResPerPatch() const {return defResPerPatch;} + const Model *getModel() const {return model;} + bool getRecoup_cost() const { return recoup_cost;} + + static ResourceClass strToRc(const string &s); +}; + +}} //end namespace + +#endif diff --git a/source/glest_game/types/skill_type.h b/source/glest_game/types/skill_type.h new file mode 100755 index 00000000..fdf14b14 --- /dev/null +++ b/source/glest_game/types/skill_type.h @@ -0,0 +1,293 @@ +// ============================================================== +// This file is part of Glest (www.glest.org) +// +// Copyright (C) 2001-2008 Marti�o Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _GLEST_GAME_SKILLTYPE_H_ +#define _GLEST_GAME_SKILLTYPE_H_ + +#include "sound.h" +#include "vec.h" +#include "model.h" +#include "xml_parser.h" +#include "util.h" +#include "damage_multiplier.h" +#include "element_type.h" +#include "factory.h" +#include "sound_container.h" +#include "particle.h" +#include "leak_dumper.h" + +using Shared::Sound::StaticSound; +using Shared::Xml::XmlNode; +using Shared::Graphics::Vec3f; +using Shared::Graphics::Model; + +namespace Glest{ namespace Game{ + +using Shared::Util::MultiFactory; + +class ParticleSystemTypeProjectile; +class ParticleSystemTypeSplash; +class UnitParticleSystemType; +class FactionType; +class TechTree; +class Lang; +class TotalUpgrade; + + +enum Field{ + fLand, + fAir, + + fieldCount +}; + +enum SkillClass{ + scStop, + scMove, + scAttack, + scBuild, + scHarvest, + scRepair, + scBeBuilt, + scProduce, + scUpgrade, + scMorph, + scDie, + + scCount +}; + +typedef list UnitParticleSystemTypes; +// ===================================================== +// class SkillType +// +/// A basic action that an unit can perform +// ===================================================== + +class SkillType{ + + +protected: + SkillClass skillClass; + string name; + int mpCost; + int speed; + int animSpeed; + Model *animation; + SoundContainer sounds; + float soundStartTime; +public: + UnitParticleSystemTypes unitParticleSystemTypes; + +public: + //varios + virtual ~SkillType(); + virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt, const FactionType *ft); + + //get + const string &getName() const {return name;} + SkillClass getClass() const {return skillClass;} + int getEpCost() const {return mpCost;} + int getSpeed() const {return speed;} + int getAnimSpeed() const {return animSpeed;} + const Model *getAnimation() const {return animation;} + StaticSound *getSound() const {return sounds.getRandSound();} + float getSoundStartTime() const {return soundStartTime;} + + //other + virtual string toString() const= 0; + virtual int getTotalSpeed(const TotalUpgrade *) const {return speed;} + static string skillClassToStr(SkillClass skillClass); + static string fieldToStr(Field field); +}; + +// =============================== +// class StopSkillType +// =============================== + +class StopSkillType: public SkillType{ +public: + StopSkillType(); + virtual string toString() const; +}; + +// =============================== +// class MoveSkillType +// =============================== + +class MoveSkillType: public SkillType{ +public: + MoveSkillType(); + virtual string toString() const; + + virtual int getTotalSpeed(const TotalUpgrade *totalUpgrade) const; +}; + +// =============================== +// class AttackSkillType +// =============================== + +class AttackSkillType: public SkillType{ +private: + int attackStrength; + int attackVar; + int attackRange; + const AttackType *attackType; + bool attackFields[fieldCount]; + float attackStartTime; + + bool projectile; + ParticleSystemTypeProjectile* projectileParticleSystemType; + SoundContainer projSounds; + + bool splash; + int splashRadius; + bool splashDamageAll; + ParticleSystemTypeSplash* splashParticleSystemType; + +public: + AttackSkillType(); + ~AttackSkillType(); + virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt, const FactionType *ft); + virtual string toString() const; + + //get + int getAttackStrength() const {return attackStrength;} + int getAttackVar() const {return attackVar;} + int getAttackRange() const {return attackRange;} + const AttackType *getAttackType() const {return attackType;} + bool getAttackField(Field field) const {return attackFields[field];} + float getAttackStartTime() const {return attackStartTime;} + + //get proj + bool getProjectile() const {return projectile;} + ParticleSystemTypeProjectile * getProjParticleType() const {return projectileParticleSystemType;} + StaticSound *getProjSound() const {return projSounds.getRandSound();} + + //get splash + bool getSplash() const {return splash;} + int getSplashRadius() const {return splashRadius;} + bool getSplashDamageAll() const {return splashDamageAll;} + ParticleSystemTypeSplash * getSplashParticleType() const {return splashParticleSystemType;} + + //misc + int getTotalAttackStrength(const TotalUpgrade *totalUpgrade) const; + int getTotalAttackRange(const TotalUpgrade *totalUpgrade) const; +}; + + +// =============================== +// class BuildSkillType +// =============================== + +class BuildSkillType: public SkillType{ +public: + BuildSkillType(); + virtual string toString() const; +}; + +// =============================== +// class HarvestSkillType +// =============================== + +class HarvestSkillType: public SkillType{ +public: + HarvestSkillType(); + virtual string toString() const; +}; + +// =============================== +// class RepairSkillType +// =============================== + +class RepairSkillType: public SkillType{ +public: + RepairSkillType(); + virtual string toString() const; +}; + +// =============================== +// class ProduceSkillType +// =============================== + +class ProduceSkillType: public SkillType{ +public: + ProduceSkillType(); + virtual string toString() const; + + virtual int getTotalSpeed(const TotalUpgrade *totalUpgrade) const; +}; + +// =============================== +// class UpgradeSkillType +// =============================== + +class UpgradeSkillType: public SkillType{ +public: + UpgradeSkillType(); + virtual string toString() const; + + virtual int getTotalSpeed(const TotalUpgrade *totalUpgrade) const; +}; + + +// =============================== +// class BeBuiltSkillType +// =============================== + +class BeBuiltSkillType: public SkillType{ +public: + BeBuiltSkillType(); + virtual string toString() const; +}; + +// =============================== +// class MorphSkillType +// =============================== + +class MorphSkillType: public SkillType{ +public: + MorphSkillType(); + virtual string toString() const; + + virtual int getTotalSpeed(const TotalUpgrade *totalUpgrade) const; +}; + +// =============================== +// class DieSkillType +// =============================== + +class DieSkillType: public SkillType{ +private: + bool fade; + +public: + DieSkillType(); + bool getFade() const {return fade;} + + virtual void load(const XmlNode *sn, const string &dir, const TechTree *tt, const FactionType *ft); + virtual string toString() const; +}; + +// =============================== +// class SkillFactory +// =============================== + +class SkillTypeFactory: public MultiFactory{ +private: + SkillTypeFactory(); +public: + static SkillTypeFactory &getInstance(); +}; + +}}//end namespace + +#endif diff --git a/source/glest_game/types/tech_tree.h b/source/glest_game/types/tech_tree.h index 54a88548..0d9bace3 100644 --- a/source/glest_game/types/tech_tree.h +++ b/source/glest_game/types/tech_tree.h @@ -18,6 +18,7 @@ #include "resource_type.h" #include "faction_type.h" #include "damage_multiplier.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index 12a9090d..7167ca84 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -23,8 +23,8 @@ #include "resource.h" #include "renderer.h" #include "game_util.h" -#include "leak_dumper.h" #include "unit_particle_type.h" +#include "leak_dumper.h" using namespace Shared::Xml; using namespace Shared::Graphics; diff --git a/source/glest_game/types/unit_type.h b/source/glest_game/types/unit_type.h index 7aba13b7..b13cf150 100644 --- a/source/glest_game/types/unit_type.h +++ b/source/glest_game/types/unit_type.h @@ -18,6 +18,7 @@ #include "sound_container.h" #include "checksum.h" #include "game_constants.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/types/upgrade_type.h b/source/glest_game/types/upgrade_type.h index 60ff05fd..d29838ef 100644 --- a/source/glest_game/types/upgrade_type.h +++ b/source/glest_game/types/upgrade_type.h @@ -15,6 +15,7 @@ #include "element_type.h" #include "checksum.h" #include "conversion.h" +#include "leak_dumper.h" using Shared::Util::Checksum; using namespace Shared::Util; diff --git a/source/glest_game/world/map.h b/source/glest_game/world/map.h index 2124aba7..d34e3e4e 100755 --- a/source/glest_game/world/map.h +++ b/source/glest_game/world/map.h @@ -19,8 +19,8 @@ #include "object.h" #include "game_constants.h" #include "selection.h" - #include +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/world/minimap.h b/source/glest_game/world/minimap.h index d3a1d6f9..fdde8722 100644 --- a/source/glest_game/world/minimap.h +++ b/source/glest_game/world/minimap.h @@ -14,6 +14,7 @@ #include "pixmap.h" #include "texture.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/world/scenario.h b/source/glest_game/world/scenario.h index 5f548a8d..409d9c6c 100644 --- a/source/glest_game/world/scenario.h +++ b/source/glest_game/world/scenario.h @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2005 Martiño Figueroa +// Copyright (C) 2001-2005 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -14,8 +14,8 @@ #include #include - #include "xml_parser.h" +#include "leak_dumper.h" using std::string; using std::vector; diff --git a/source/glest_game/world/surface_atlas.h b/source/glest_game/world/surface_atlas.h new file mode 100644 index 00000000..322588f1 --- /dev/null +++ b/source/glest_game/world/surface_atlas.h @@ -0,0 +1,87 @@ +// ============================================================== +// This file is part of Glest (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _GLEST_GAME_SURFACEATLAS_H_ +#define _GLEST_GAME_SURFACEATLAS_H_ + +#include +#include +#include "texture.h" +#include "vec.h" +#include "leak_dumper.h" + +using std::vector; +using std::set; +using Shared::Graphics::Pixmap2D; +using Shared::Graphics::Texture2D; +using Shared::Graphics::Vec2i; +using Shared::Graphics::Vec2f; + +namespace Glest{ namespace Game{ + +// ===================================================== +// class SurfaceInfo +// ===================================================== + +class SurfaceInfo{ +private: + const Pixmap2D *center; + const Pixmap2D *leftUp; + const Pixmap2D *rightUp; + const Pixmap2D *leftDown; + const Pixmap2D *rightDown; + Vec2f coord; + const Texture2D *texture; + +public: + SurfaceInfo(const Pixmap2D *center); + SurfaceInfo(const Pixmap2D *lu, const Pixmap2D *ru, const Pixmap2D *ld, const Pixmap2D *rd); + bool operator==(const SurfaceInfo &si) const; + + const Pixmap2D *getCenter() const {return center;} + const Pixmap2D *getLeftUp() const {return leftUp;} + const Pixmap2D *getRightUp() const {return rightUp;} + const Pixmap2D *getLeftDown() const {return leftDown;} + const Pixmap2D *getRightDown() const {return rightDown;} + const Vec2f &getCoord() const {return coord;} + const Texture2D *getTexture() const {return texture;} + + void setCoord(const Vec2f &coord) {this->coord= coord;} + void setTexture(const Texture2D *texture) {this->texture= texture;} +}; + +// ===================================================== +// class SurfaceAtlas +// +/// Holds all surface textures for a given Tileset +// ===================================================== + +class SurfaceAtlas{ +private: + typedef vector SurfaceInfos; + +private: + SurfaceInfos surfaceInfos; + int surfaceSize; + +public: + SurfaceAtlas(); + + void addSurface(SurfaceInfo *si); + float getCoordStep() const; + +private: + void checkDimensions(const Pixmap2D *p); +}; + +}}//end namespace + +#endif diff --git a/source/glest_game/world/tileset.h b/source/glest_game/world/tileset.h index 0e2a444a..412e98d0 100644 --- a/source/glest_game/world/tileset.h +++ b/source/glest_game/world/tileset.h @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2001-2008 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -13,7 +13,6 @@ #define _GLEST_GAME_TILESET_H_ #include - #include "graphics_interface.h" #include "xml_parser.h" #include "object_type.h" @@ -21,6 +20,7 @@ #include "randomgen.h" #include "surface_atlas.h" #include "checksum.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/world/time_flow.h b/source/glest_game/world/time_flow.h index 2e49a5f7..c47a1a62 100644 --- a/source/glest_game/world/time_flow.h +++ b/source/glest_game/world/time_flow.h @@ -14,6 +14,7 @@ #include "tileset.h" #include "sound.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/glest_game/world/unit_updater.h b/source/glest_game/world/unit_updater.h index 363bf6e6..923fac9a 100644 --- a/source/glest_game/world/unit_updater.h +++ b/source/glest_game/world/unit_updater.h @@ -16,6 +16,7 @@ #include "particle.h" #include "randomgen.h" #include "command.h" +#include "leak_dumper.h" using Shared::Graphics::ParticleObserver; using Shared::Util::RandomGen; diff --git a/source/glest_game/world/water_effects.h b/source/glest_game/world/water_effects.h index 5cfc2f62..f1e3fdf4 100644 --- a/source/glest_game/world/water_effects.h +++ b/source/glest_game/world/water_effects.h @@ -13,8 +13,8 @@ #define _GLEST_GAME_WATER_EFFECTS_H_ #include - #include "vec.h" +#include "leak_dumper.h" using std::vector; diff --git a/source/glest_game/world/world.h b/source/glest_game/world/world.h index deb258f6..30e6b783 100644 --- a/source/glest_game/world/world.h +++ b/source/glest_game/world/world.h @@ -30,6 +30,7 @@ #include "unit_updater.h" #include "randomgen.h" #include "game_constants.h" +#include "leak_dumper.h" namespace Glest{ namespace Game{ diff --git a/source/shared_lib/include/graphics/BMPReader.h b/source/shared_lib/include/graphics/BMPReader.h index 89e59838..c02135f2 100644 --- a/source/shared_lib/include/graphics/BMPReader.h +++ b/source/shared_lib/include/graphics/BMPReader.h @@ -18,6 +18,7 @@ #include "FileReader.h" #include "pixmap.h" +#include "leak_dumper.h" namespace Shared{ namespace Graphics{ diff --git a/source/shared_lib/include/graphics/FileReader.h b/source/shared_lib/include/graphics/FileReader.h index e20faaef..dcbb9dfa 100644 --- a/source/shared_lib/include/graphics/FileReader.h +++ b/source/shared_lib/include/graphics/FileReader.h @@ -13,7 +13,6 @@ #define FILE_READER_H #include "platform_util.h" - #include #include #include @@ -21,6 +20,7 @@ #include #include #include +#include "leak_dumper.h" using std::map; using std::string; diff --git a/source/shared_lib/include/graphics/ImageReaders.h b/source/shared_lib/include/graphics/ImageReaders.h index e6773671..d9311fd8 100644 --- a/source/shared_lib/include/graphics/ImageReaders.h +++ b/source/shared_lib/include/graphics/ImageReaders.h @@ -17,6 +17,7 @@ #include "JPGReader.h" #include "PNGReader.h" #include "TGAReader.h" +#include "leak_dumper.h" //Initialize some objects namespace Shared{ namespace Graphics{ diff --git a/source/shared_lib/include/graphics/JPGReader.h b/source/shared_lib/include/graphics/JPGReader.h index 2d62bdfa..1e74cbde 100644 --- a/source/shared_lib/include/graphics/JPGReader.h +++ b/source/shared_lib/include/graphics/JPGReader.h @@ -18,6 +18,7 @@ #include "FileReader.h" #include "pixmap.h" +#include "leak_dumper.h" namespace Shared{ namespace Graphics{ diff --git a/source/shared_lib/include/graphics/PNGReader.h b/source/shared_lib/include/graphics/PNGReader.h index 76577191..cfc6a968 100644 --- a/source/shared_lib/include/graphics/PNGReader.h +++ b/source/shared_lib/include/graphics/PNGReader.h @@ -18,6 +18,7 @@ #include "FileReader.h" #include "pixmap.h" +#include "leak_dumper.h" namespace Shared{ namespace Graphics{ diff --git a/source/shared_lib/include/graphics/TGAReader.h b/source/shared_lib/include/graphics/TGAReader.h index b19992d7..51bdb047 100644 --- a/source/shared_lib/include/graphics/TGAReader.h +++ b/source/shared_lib/include/graphics/TGAReader.h @@ -18,6 +18,7 @@ #include "FileReader.h" #include "pixmap.h" +#include "leak_dumper.h" namespace Shared{ namespace Graphics{ diff --git a/source/shared_lib/include/graphics/buffer.h b/source/shared_lib/include/graphics/buffer.h new file mode 100644 index 00000000..eb0257cf --- /dev/null +++ b/source/shared_lib/include/graphics/buffer.h @@ -0,0 +1,62 @@ +#ifndef _SHARED_GRAPHICS_BUFFER_H_ +#define _SHARED_GRAPHICS_BUFFER_H_ + +#include +#include "leak_dumper.h" + +using std::string; + +namespace Shared{ namespace Graphics{ + +// ===================================================== +// class VertexBuffer +// ===================================================== + +class VertexBuffer{ +private: + static const int texCoordCount = 8; + static const int attribCount = 8; + +private: + void *positionPointer; + void *normalPointer; + + void *texCoordPointers[texCoordCount]; + int texCoordCoordCounts[texCoordCount]; + + void *attribPointers[attribCount]; + int attribCoordCounts[attribCount]; + string attribNames[attribCount]; + +public: + VertexBuffer(); + virtual ~VertexBuffer(){}; + + virtual void init(int size)= 0; + + void setPositionPointer(void *pointer); + void setNormalPointer(void *pointer); + void setTexCoordPointer(void *pointer, int texCoordIndex, int coordCount); + void setAttribPointer(void *pointer, int attribIndex, int coordCount, const string &name); +}; + +// ===================================================== +// class IndexBuffer +// ===================================================== + +class IndexBuffer{ +private: + void *indexPointer; + +public: + IndexBuffer(); + virtual ~IndexBuffer(){} + + virtual void init(int size)= 0; + + void setIndexPointer(void *pointer); +}; + +}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/camera.h b/source/shared_lib/include/graphics/camera.h index bd6c41f4..cf355474 100644 --- a/source/shared_lib/include/graphics/camera.h +++ b/source/shared_lib/include/graphics/camera.h @@ -14,6 +14,7 @@ #include "vec.h" #include "quaternion.h" +#include "leak_dumper.h" namespace Shared{ namespace Graphics{ diff --git a/source/shared_lib/include/graphics/context.h b/source/shared_lib/include/graphics/context.h index eab0f7eb..4f28e00c 100644 --- a/source/shared_lib/include/graphics/context.h +++ b/source/shared_lib/include/graphics/context.h @@ -13,6 +13,7 @@ #define _SHARED_GRAPHICS_CONTEXT_H_ #include "types.h" +#include "leak_dumper.h" namespace Shared{ namespace Graphics{ diff --git a/source/shared_lib/include/graphics/font.h b/source/shared_lib/include/graphics/font.h index cea90459..8265bddd 100644 --- a/source/shared_lib/include/graphics/font.h +++ b/source/shared_lib/include/graphics/font.h @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest Shared Library (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2001-2008 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -13,6 +13,7 @@ #define _SHARED_GRAPHICS_FONT_H_ #include +#include "leak_dumper.h" using std::string; diff --git a/source/shared_lib/include/graphics/font_manager.h b/source/shared_lib/include/graphics/font_manager.h index 41069ad0..030ed589 100644 --- a/source/shared_lib/include/graphics/font_manager.h +++ b/source/shared_lib/include/graphics/font_manager.h @@ -13,8 +13,8 @@ #define _SHARED_GRAPHICS_FONTMANAGER_H_ #include "font.h" - #include +#include "leak_dumper.h" using namespace std; diff --git a/source/shared_lib/include/graphics/gl/context_gl.h b/source/shared_lib/include/graphics/gl/context_gl.h new file mode 100644 index 00000000..f96b2740 --- /dev/null +++ b/source/shared_lib/include/graphics/gl/context_gl.h @@ -0,0 +1,44 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICS_GL_CONTEXTGL_H_ +#define _SHARED_GRAPHICS_GL_CONTEXTGL_H_ + +#include "context.h" +#include "gl_wrap.h" +#include "leak_dumper.h" + +namespace Shared{ namespace Graphics{ namespace Gl{ + +using Platform::PlatformContextGl; + +// ===================================================== +// class ContextGl +// ===================================================== + +class ContextGl: public Context{ +protected: + PlatformContextGl pcgl; + +public: + virtual void init(); + virtual void end(); + virtual void reset(){}; + + virtual void makeCurrent(); + virtual void swapBuffers(); + + const PlatformContextGl *getPlatformContextGl() const {return &pcgl;} +}; + +}}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/gl/font_gl.h b/source/shared_lib/include/graphics/gl/font_gl.h new file mode 100644 index 00000000..85aa47ac --- /dev/null +++ b/source/shared_lib/include/graphics/gl/font_gl.h @@ -0,0 +1,59 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICS_GL_FONTGL_H_ +#define _SHARED_GRAPHICS_GL_FONTGL_H_ + +#include "font.h" +#include "opengl.h" +#include "leak_dumper.h" + +namespace Shared{ namespace Graphics{ namespace Gl{ + +// ===================================================== +// class FontGl +// ===================================================== + +class FontGl{ +protected: + GLuint handle; + +public: + GLuint getHandle() const {return handle;} +}; + +// ===================================================== +// class Font2DGl +// +/// OpenGL bitmap font +// ===================================================== + +class Font2DGl: public Font2D, public FontGl{ +public: + virtual void init(); + virtual void end(); +}; + +// ===================================================== +// class Font3DGl +// +/// OpenGL outline font +// ===================================================== + +class Font3DGl: public Font3D, public FontGl{ +public: + virtual void init(); + virtual void end(); +}; + +}}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/gl/graphics_factory_basic_gl.h b/source/shared_lib/include/graphics/gl/graphics_factory_basic_gl.h new file mode 100644 index 00000000..19234eb4 --- /dev/null +++ b/source/shared_lib/include/graphics/gl/graphics_factory_basic_gl.h @@ -0,0 +1,44 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2005 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICS_GL_GRAPHICSFACTORYBASICGL_H_ +#define _SHARED_GRAPHICS_GL_GRAPHICSFACTORYBASICGL_H_ + +#include "graphics_factory.h" +#include "text_renderer_gl.h" +#include "model_renderer_gl.h" +#include "context_gl.h" +#include "model_gl.h" +#include "texture_gl.h" +#include "font_gl.h" +#include "leak_dumper.h" + +namespace Shared{ namespace Graphics{ namespace Gl{ + +// ===================================================== +// class GraphicsFactoryBasicGl +// ===================================================== + +class GraphicsFactoryBasicGl: public GraphicsFactory{ +public: + virtual TextRenderer2D *newTextRenderer2D() {return new TextRenderer2DGl();} + virtual TextRenderer3D *newTextRenderer3D() {return new TextRenderer3DGl();} + virtual ModelRenderer *newModelRenderer() {return new ModelRendererGl();} + virtual Context *newContext() {return new ContextGl();} + virtual Model *newModel() {return new ModelGl();} + virtual Texture2D *newTexture2D() {return new Texture2DGl();} + virtual Font2D *newFont2D() {return new Font2DGl();} + virtual Font3D *newFont3D() {return new Font3DGl();} +}; + +}}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/gl/graphics_factory_gl.h b/source/shared_lib/include/graphics/gl/graphics_factory_gl.h new file mode 100644 index 00000000..6826305e --- /dev/null +++ b/source/shared_lib/include/graphics/gl/graphics_factory_gl.h @@ -0,0 +1,66 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICS_GL_GRAPHICSFACTORYGL_H_ +#define _SHARED_GRAPHICS_GL_GRAPHICSFACTORYGL_H_ + +#include "texture_manager.h" +#include "model_manager.h" +#include "particle.h" +#include "font_manager.h" +#include "graphics_factory.h" +#include "text_renderer_gl.h" +#include "model_renderer_gl.h" +#include "particle_renderer_gl.h" +#include "context_gl.h" +#include "model_gl.h" +#include "texture_gl.h" +#include "font_gl.h" +#include "leak_dumper.h" + +namespace Shared{ namespace Graphics{ namespace Gl{ + +// ===================================================== +// class GraphicsFactoryGl +// ===================================================== + +class GraphicsFactoryGl: public GraphicsFactory{ +public: + //context + virtual Context *newContext() {return new ContextGl();} + + //textures + virtual TextureManager *newTextureManager() {return new TextureManager();} + virtual Texture1D *newTexture1D() {return new Texture1DGl();} + virtual Texture2D *newTexture2D() {return new Texture2DGl();} + virtual Texture3D *newTexture3D() {return new Texture3DGl();} + virtual TextureCube *newTextureCube() {return new TextureCubeGl();} + + //models + virtual ModelManager *newModelManager() {return new ModelManager();} + virtual ModelRenderer *newModelRenderer() {return new ModelRendererGl();} + virtual Model *newModel() {return new ModelGl();} + + //text + virtual FontManager *newFontManager() {return new FontManager();} + virtual TextRenderer2D *newTextRenderer2D() {return new TextRenderer2DGl();} + virtual TextRenderer3D *newTextRenderer3D() {return new TextRenderer3DGl();} + virtual Font2D *newFont2D() {return new Font2DGl();} + virtual Font3D *newFont3D() {return new Font3DGl();} + + //particles + virtual ParticleManager *newParticleManager() {return new ParticleManager();} + virtual ParticleRenderer *newParticleRenderer() {return new ParticleRendererGl();} +}; + +}}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/gl/graphics_factory_gl2.h b/source/shared_lib/include/graphics/gl/graphics_factory_gl2.h new file mode 100644 index 00000000..51021682 --- /dev/null +++ b/source/shared_lib/include/graphics/gl/graphics_factory_gl2.h @@ -0,0 +1,63 @@ +#ifndef _SHARED_GRAPHICS_GL_GRAPHICSFACTORYGL2_H_ +#define _SHARED_GRAPHICS_GL_GRAPHICSFACTORYGL2_H_ + +#include "texture_manager.h" +#include "model_manager.h" +#include "font_manager.h" +#include "particle.h" +#include "graphics_factory.h" +#include "text_renderer_gl.h" +#include "model_renderer_gl.h" +#include "particle_renderer_gl.h" +#include "context_gl.h" +#include "model_gl.h" +#include "texture_gl.h" +#include "font_gl.h" +#include "shader_gl.h" +#include "shader_manager.h" +#include "leak_dumper.h" + +namespace Shared{ namespace Graphics{ namespace Gl{ + +// ===================================================== +// class GraphicsFactoryGl +// ===================================================== + +class GraphicsFactoryGl2: public GraphicsFactory{ +public: + //context + virtual Context *newContext() {return new ContextGl();} + + //textures + virtual TextureManager *newTextureManager() {return new TextureManager();} + virtual Texture1D *newTexture1D() {return new Texture1DGl();} + virtual Texture2D *newTexture2D() {return new Texture2DGl();} + virtual Texture3D *newTexture3D() {return new Texture3DGl();} + virtual TextureCube *newTextureCube() {return new TextureCubeGl();} + + //models + virtual ModelManager *newModelManager() {return new ModelManager();} + virtual ModelRenderer *newModelRenderer() {return new ModelRendererGl();} + virtual Model *newModel() {return new ModelGl();} + + //text + virtual FontManager *newFontManager() {return new FontManager();} + virtual TextRenderer2D *newTextRenderer2D() {return new TextRenderer2DGl();} + virtual TextRenderer3D *newTextRenderer3D() {return new TextRenderer3DGl();} + virtual Font2D *newFont2D() {return new Font2DGl();} + virtual Font3D *newFont3D() {return new Font3DGl();} + + //particles + virtual ParticleManager *newParticleManager() {return new ParticleManager();} + virtual ParticleRenderer *newParticleRenderer() {return new ParticleRendererGl();} + + //shaders + virtual ShaderManager *newShaderManager() {return new ShaderManager();} + virtual ShaderProgram *newShaderProgram() {return new ShaderProgramGl();} + virtual VertexShader *newVertexShader() {return new VertexShaderGl();} + virtual FragmentShader *newFragmentShader() {return new FragmentShaderGl();} +}; + +}}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/gl/model_gl.h b/source/shared_lib/include/graphics/gl/model_gl.h new file mode 100644 index 00000000..d7f28adc --- /dev/null +++ b/source/shared_lib/include/graphics/gl/model_gl.h @@ -0,0 +1,32 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICS_GL_MODELGL_H_ +#define _SHARED_GRAPHICS_GL_MODELGL_H_ + +#include "model.h" +#include "leak_dumper.h" + +namespace Shared{ namespace Graphics{ namespace Gl{ + +// ===================================================== +// class ModelGl +// ===================================================== + +class ModelGl: public Model{ +public: + virtual void init(){} + virtual void end(){} +}; + +}}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/gl/model_renderer_gl.h b/source/shared_lib/include/graphics/gl/model_renderer_gl.h new file mode 100644 index 00000000..bdb75de6 --- /dev/null +++ b/source/shared_lib/include/graphics/gl/model_renderer_gl.h @@ -0,0 +1,51 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICS_GL_MODELRENDERERGL_H_ +#define _SHARED_GRAPHICS_GL_MODELRENDERERGL_H_ + +#include "model_renderer.h" +#include "model.h" +#include "opengl.h" +#include "leak_dumper.h" + +namespace Shared{ namespace Graphics{ namespace Gl{ + +// ===================================================== +// class ModelRendererGl +// ===================================================== + +class ModelRendererGl: public ModelRenderer{ +private: + bool rendering; + bool duplicateTexCoords; + int secondaryTexCoordUnit; + GLuint lastTexture; + +public: + ModelRendererGl(); + virtual void begin(bool renderNormals, bool renderTextures, bool renderColors, MeshCallback *meshCallback); + virtual void end(); + virtual void render(const Model *model); + virtual void renderNormalsOnly(const Model *model); + + void setDuplicateTexCoords(bool duplicateTexCoords) {this->duplicateTexCoords= duplicateTexCoords;} + void setSecondaryTexCoordUnit(int secondaryTexCoordUnit) {this->secondaryTexCoordUnit= secondaryTexCoordUnit;} + +private: + + void renderMesh(const Mesh *mesh); + void renderMeshNormals(const Mesh *mesh); +}; + +}}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/gl/opengl.h b/source/shared_lib/include/graphics/gl/opengl.h new file mode 100644 index 00000000..35657f5d --- /dev/null +++ b/source/shared_lib/include/graphics/gl/opengl.h @@ -0,0 +1,69 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICS_GL_OPENGL_H_ +#define _SHARED_GRAPHICS_GL_OPENGL_H_ + +#include +#include +#include +#include "conversion.h" +#include "gl_wrap.h" +#include "leak_dumper.h" + +using std::runtime_error; +using std::string; + +namespace Shared{ namespace Graphics{ namespace Gl{ + +using Util::intToStr; + +// ===================================================== +// Globals +// ===================================================== + +bool isGlExtensionSupported(const char *extensionName); +bool isGlVersionSupported(int major, int minor, int release); +const char *getGlVersion(); +const char *getGlRenderer(); +const char *getGlVendor(); +const char *getGlExtensions(); +const char *getGlPlatformExtensions(); +int getGlMaxLights(); +int getGlMaxTextureSize(); +int getGlMaxTextureUnits(); +int getGlModelviewMatrixStackDepth(); +int getGlProjectionMatrixStackDepth(); +void checkGlExtension(const char *extensionName); + +void inline _assertGl(const char *file, int line){ + + GLenum error= glGetError(); + + if(error != GL_NO_ERROR){ + const char *errorString= reinterpret_cast(gluErrorString(error)); + throw runtime_error("OpenGL error: "+string(errorString)+" at file: "+string(file)+", line "+intToStr(line)); + } + +} + +#ifdef NDEBUG +#define assertGl() ((void) 0); + +#else + +#define assertGl() _assertGl(__FILE__, __LINE__); + +#endif + +}}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/gl/particle_renderer_gl.h b/source/shared_lib/include/graphics/gl/particle_renderer_gl.h new file mode 100644 index 00000000..511092f2 --- /dev/null +++ b/source/shared_lib/include/graphics/gl/particle_renderer_gl.h @@ -0,0 +1,51 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICS_GL_PARTICLERENDERERGL_H_ +#define _SHARED_GRAPHICS_GL_PARTICLERENDERERGL_H_ + +#include "particle_renderer.h" +#include "leak_dumper.h" + +namespace Shared{ namespace Graphics{ namespace Gl{ + +// ===================================================== +// class ParticleRendererGl +// ===================================================== + +class ParticleRendererGl: public ParticleRenderer{ +public: + static const int bufferSize = 1024; + +private: + bool rendering; + Vec3f vertexBuffer[bufferSize]; + Vec2f texCoordBuffer[bufferSize]; + Vec4f colorBuffer[bufferSize]; + +public: + //particles + ParticleRendererGl(); + virtual void renderManager(ParticleManager *pm, ModelRenderer *mr); + virtual void renderSystem(ParticleSystem *ps); + virtual void renderSystemLine(ParticleSystem *ps); + virtual void renderSystemLineAlpha(ParticleSystem *ps); + virtual void renderSingleModel(AttackParticleSystem *ps, ModelRenderer *mr); + +protected: + void renderBufferQuads(int quadCount); + void renderBufferLines(int lineCount); + void setBlendMode(ParticleSystem::BlendMode blendMode); +}; + +}}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/gl/shader_gl.h b/source/shared_lib/include/graphics/gl/shader_gl.h new file mode 100644 index 00000000..2d730f9e --- /dev/null +++ b/source/shared_lib/include/graphics/gl/shader_gl.h @@ -0,0 +1,111 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICS_GL_SHADERGL_H_ +#define _SHARED_GRAPHICS_GL_SHADERGL_H_ + +#include +#include +#include "shader.h" +#include "opengl.h" +#include "leak_dumper.h" + +using std::vector; +using std::string; +using std::pair; + +namespace Shared{ namespace Graphics{ namespace Gl{ + +// ===================================================== +// class ShaderProgramGl +// ===================================================== + +class ShaderProgramGl: public ShaderProgram{ +private: + typedef pair AttributePair; + typedef vector Attributes; + +private: + Attributes attributes; + GLhandleARB handle; + VertexShader *vertexShader; + FragmentShader *fragmentShader; + bool inited; + +public: + ShaderProgramGl(); + + GLhandleARB getHandle() const {return handle;} + + virtual void init(); + virtual void end(); + + virtual void attach(VertexShader *vertexShader, FragmentShader *fragmentShader); + virtual bool link(string &messages); + virtual void activate(); + virtual void deactivate(); + + virtual void setUniform(const string &name, int value); + virtual void setUniform(const string &name, float value); + virtual void setUniform(const string &name, const Vec2f &value); + virtual void setUniform(const string &name, const Vec3f &value); + virtual void setUniform(const string &name, const Vec4f &value); + virtual void setUniform(const string &name, const Matrix3f &value); + virtual void setUniform(const string &name, const Matrix4f &value); + + void bindAttribute(const string &name, int index); + +private: + GLint getLocation(const string &name); +}; + +// ===================================================== +// class ShaderGl +// ===================================================== + +class ShaderGl: virtual public Shader{ +protected: + GLhandleARB handle; + ShaderSource source; + bool inited; + +public: + ShaderGl(); + + const ShaderSource *getSource() const {return &source;} + GLhandleARB getHandle() const {return handle;} + + virtual void load(const string &path); + virtual bool compile(string &messages); + virtual void end(); +}; + +// ===================================================== +// class VertexShaderGl +// ===================================================== + +class VertexShaderGl: public VertexShader, public ShaderGl{ +public: + virtual void init(); +}; + +// ===================================================== +// class FragmentShaderGl +// ===================================================== + +class FragmentShaderGl: public FragmentShader, public ShaderGl{ +public: + virtual void init(); +}; + +}}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/gl/text_renderer_gl.h b/source/shared_lib/include/graphics/gl/text_renderer_gl.h index 55c07220..7a83201b 100644 --- a/source/shared_lib/include/graphics/gl/text_renderer_gl.h +++ b/source/shared_lib/include/graphics/gl/text_renderer_gl.h @@ -13,6 +13,7 @@ #define _SHARED_GRAPHICS_GL_TEXTRENDERERGL_H_ #include "text_renderer.h" +#include "leak_dumper.h" namespace Shared{ namespace Graphics{ namespace Gl{ diff --git a/source/shared_lib/include/graphics/gl/texture_gl.h b/source/shared_lib/include/graphics/gl/texture_gl.h new file mode 100644 index 00000000..dbd9e960 --- /dev/null +++ b/source/shared_lib/include/graphics/gl/texture_gl.h @@ -0,0 +1,75 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICS_GL_TEXTUREGL_H_ +#define _SHARED_GRAPHICS_GL_TEXTUREGL_H_ + +#include "texture.h" +#include "opengl.h" +#include "leak_dumper.h" + +namespace Shared{ namespace Graphics{ namespace Gl{ + +// ===================================================== +// class TextureGl +// ===================================================== + +class TextureGl{ +protected: + GLuint handle; + +public: + GLuint getHandle() const {return handle;} +}; + +// ===================================================== +// class Texture1DGl +// ===================================================== + +class Texture1DGl: public Texture1D, public TextureGl{ +public: + virtual void init(Filter filter, int maxAnisotropy= 1); + virtual void end(); +}; + +// ===================================================== +// class Texture2DGl +// ===================================================== + +class Texture2DGl: public Texture2D, public TextureGl{ +public: + virtual void init(Filter filter, int maxAnisotropy= 1); + virtual void end(); +}; + +// ===================================================== +// class Texture3DGl +// ===================================================== + +class Texture3DGl: public Texture3D, public TextureGl{ +public: + virtual void init(Filter filter, int maxAnisotropy= 1); + virtual void end(); +}; + +// ===================================================== +// class TextureCubeGl +// ===================================================== + +class TextureCubeGl: public TextureCube, public TextureGl{ +public: + virtual void init(Filter filter, int maxAnisotropy= 1); + virtual void end(); +}; + +}}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/graphics_factory.h b/source/shared_lib/include/graphics/graphics_factory.h new file mode 100644 index 00000000..6d224b1a --- /dev/null +++ b/source/shared_lib/include/graphics/graphics_factory.h @@ -0,0 +1,89 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICS_GRAPHICSFACTORY_H_ +#define _SHARED_GRAPHICS_GRAPHICSFACTORY_H_ + +#include +#include "leak_dumper.h" + +namespace Shared{ namespace Graphics{ + +class Context; + +class TextureManager; +class Texture1D; +class Texture2D; +class Texture3D; +class TextureCube; + +class ModelManager; +class ModelRenderer; +class Model; + +class FontManager; +class TextRenderer2D; +class TextRenderer3D; +class Font2D; +class Font3D; + +class ParticleManager; +class ParticleRenderer; + +class ShaderManager; +class ShaderProgram; +class VertexShader; +class FragmentShader; + +// ===================================================== +// class GraphicsFactory +// ===================================================== + +class GraphicsFactory{ +public: + virtual ~GraphicsFactory(){} + + //context + virtual Context *newContext() {return NULL;} + + //textures + virtual TextureManager *newTextureManager() {return NULL;} + virtual Texture1D *newTexture1D() {return NULL;} + virtual Texture2D *newTexture2D() {return NULL;} + virtual Texture3D *newTexture3D() {return NULL;} + virtual TextureCube *newTextureCube() {return NULL;} + + //models + virtual ModelManager *newModelManager() {return NULL;} + virtual ModelRenderer *newModelRenderer() {return NULL;} + virtual Model *newModel() {return NULL;} + + //text + virtual FontManager *newFontManager() {return NULL;} + virtual TextRenderer2D *newTextRenderer2D() {return NULL;} + virtual TextRenderer3D *newTextRenderer3D() {return NULL;} + virtual Font2D *newFont2D() {return NULL;} + virtual Font3D *newFont3D() {return NULL;} + + //particles + virtual ParticleManager *newParticleManager() {return NULL;} + virtual ParticleRenderer *newParticleRenderer() {return NULL;} + + //shaders + virtual ShaderManager *newShaderManager() {return NULL;} + virtual ShaderProgram *newShaderProgram() {return NULL;} + virtual VertexShader *newVertexShader() {return NULL;} + virtual FragmentShader *newFragmentShader() {return NULL;} +}; + +}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/graphics_interface.h b/source/shared_lib/include/graphics/graphics_interface.h index 86258a30..d880a1cd 100644 --- a/source/shared_lib/include/graphics/graphics_interface.h +++ b/source/shared_lib/include/graphics/graphics_interface.h @@ -12,6 +12,8 @@ #ifndef _SHARED_GRAPHICS_GRAPHICSINTERFACE_H_ #define _SHARED_GRAPHICS_GRAPHICSINTERFACE_H_ +#include "leak_dumper.h" + namespace Shared{ namespace Graphics{ class GraphicsFactory; diff --git a/source/shared_lib/include/graphics/interpolation.h b/source/shared_lib/include/graphics/interpolation.h index 5e3958fb..5f53ef9c 100644 --- a/source/shared_lib/include/graphics/interpolation.h +++ b/source/shared_lib/include/graphics/interpolation.h @@ -15,6 +15,7 @@ #include "vec.h" #include "model.h" #include +#include "leak_dumper.h" namespace Shared{ namespace Graphics{ diff --git a/source/shared_lib/include/graphics/math_util.h b/source/shared_lib/include/graphics/math_util.h index fa7fedb5..047ce2f7 100644 --- a/source/shared_lib/include/graphics/math_util.h +++ b/source/shared_lib/include/graphics/math_util.h @@ -13,6 +13,7 @@ #define _SHARED_GRAPHICS_MATHUTIL_H_ #include "vec.h" +#include "leak_dumper.h" namespace Shared{ namespace Graphics{ diff --git a/source/shared_lib/include/graphics/matrix.h b/source/shared_lib/include/graphics/matrix.h index 2f934571..5295278b 100644 --- a/source/shared_lib/include/graphics/matrix.h +++ b/source/shared_lib/include/graphics/matrix.h @@ -13,6 +13,7 @@ #define _SHARED_GRAPHICS_MATRIX_H_ #include "vec.h" +#include "leak_dumper.h" namespace Shared{ namespace Graphics{ diff --git a/source/shared_lib/include/graphics/model.h b/source/shared_lib/include/graphics/model.h index be4ebea0..18abab70 100644 --- a/source/shared_lib/include/graphics/model.h +++ b/source/shared_lib/include/graphics/model.h @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest Shared Library (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2001-2008 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -14,12 +14,12 @@ #include #include - #include "types.h" #include "pixmap.h" #include "texture_manager.h" #include "texture.h" #include "model_header.h" +#include "leak_dumper.h" using std::string; using std::map; diff --git a/source/shared_lib/include/graphics/model_header.h b/source/shared_lib/include/graphics/model_header.h new file mode 100644 index 00000000..b91268c9 --- /dev/null +++ b/source/shared_lib/include/graphics/model_header.h @@ -0,0 +1,119 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICTYPES_MODELHEADER_H_ +#define _SHARED_GRAPHICTYPES_MODELHEADER_H_ + +#include "types.h" +#include "leak_dumper.h" + +using Shared::Platform::uint8; +using Shared::Platform::uint16; +using Shared::Platform::uint32; +using Shared::Platform::float32; + +namespace Shared{ namespace Graphics{ + +#pragma pack(push, 1) + +struct FileHeader{ + uint8 id[3]; + uint8 version; +}; + +//version 4 + +struct ModelHeader{ + uint16 meshCount; + uint8 type; +}; + +enum ModelType{ + mtMorphMesh +}; + +enum MeshPropertyFlag{ + mpfCustomColor= 1, + mpfTwoSided= 2 +}; + +enum MeshTexture{ + mtDiffuse, + mtSpecular, + mtNormal, + mtReflection, + mtColorMask, + + meshTextureCount +}; + +const int meshTextureChannelCount[]= {-1, 1, 3, 1, 1}; + +const uint32 meshNameSize= 64; +const uint32 mapPathSize= 64; + +struct MeshHeader{ + uint8 name[meshNameSize]; + uint32 frameCount; + uint32 vertexCount; + uint32 indexCount; + float32 diffuseColor[3]; + float32 specularColor[3]; + float32 specularPower; + float32 opacity; + uint32 properties; + uint32 textures; +}; + +#pragma pack(pop) + +//version 3 + +//front faces are clockwise faces +struct ModelHeaderV3{ + uint32 meshCount; +}; + +enum MeshPropertyV3{ + mp3NoTexture= 1, + mp3TwoSided= 2, + mp3CustomColor= 4 +}; + +struct MeshHeaderV3{ + uint32 vertexFrameCount; + uint32 normalFrameCount; + uint32 texCoordFrameCount; + uint32 colorFrameCount; + uint32 pointCount; + uint32 indexCount; + uint32 properties; + uint8 texName[64]; +}; + +//version 2 + +struct MeshHeaderV2{ + uint32 vertexFrameCount; + uint32 normalFrameCount; + uint32 texCoordFrameCount; + uint32 colorFrameCount; + uint32 pointCount; + uint32 indexCount; + uint8 hasTexture; + uint8 primitive; + uint8 cullFace; + uint8 texName[64]; +}; + +}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/model_manager.h b/source/shared_lib/include/graphics/model_manager.h index 7676e6f4..5246c6de 100644 --- a/source/shared_lib/include/graphics/model_manager.h +++ b/source/shared_lib/include/graphics/model_manager.h @@ -13,8 +13,8 @@ #define _SHARED_GRAPHICS_MODELMANAGER_H_ #include "model.h" - #include +#include "leak_dumper.h" using namespace std; diff --git a/source/shared_lib/include/graphics/model_renderer.h b/source/shared_lib/include/graphics/model_renderer.h index a9c3d456..2d24f797 100644 --- a/source/shared_lib/include/graphics/model_renderer.h +++ b/source/shared_lib/include/graphics/model_renderer.h @@ -14,6 +14,7 @@ #define _SHARED_GRAPHICS_MODELRENDERER_H_ #include "model.h" +#include "leak_dumper.h" namespace Shared{ namespace Graphics{ diff --git a/source/shared_lib/include/graphics/particle.h b/source/shared_lib/include/graphics/particle.h index 968724b0..a7f8de66 100644 --- a/source/shared_lib/include/graphics/particle.h +++ b/source/shared_lib/include/graphics/particle.h @@ -14,11 +14,11 @@ #include #include - #include "vec.h" #include "pixmap.h" #include "texture_manager.h" #include "randomgen.h" +#include "leak_dumper.h" using std::list; using Shared::Util::RandomGen; diff --git a/source/shared_lib/include/graphics/particle_renderer.h b/source/shared_lib/include/graphics/particle_renderer.h new file mode 100644 index 00000000..77ec274f --- /dev/null +++ b/source/shared_lib/include/graphics/particle_renderer.h @@ -0,0 +1,39 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICS_PARTICLERENDERER_H_ +#define _SHARED_GRAPHICS_PARTICLERENDERER_H_ + +#include "particle.h" +#include "leak_dumper.h" + +namespace Shared{ namespace Graphics{ + +class ModelRenderer; + +// ===================================================== +// class ParticleRenderer +// ===================================================== + +class ParticleRenderer{ +public: + //particles + virtual ~ParticleRenderer(){}; + virtual void renderManager(ParticleManager *pm, ModelRenderer *mr)=0; + virtual void renderSystem(ParticleSystem *ps)=0; + virtual void renderSystemLine(ParticleSystem *ps)=0; + virtual void renderSystemLineAlpha(ParticleSystem *ps)=0; + virtual void renderSingleModel(AttackParticleSystem *ps, ModelRenderer *mr)=0; +}; + +}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/pixmap.h b/source/shared_lib/include/graphics/pixmap.h index 1daa8c49..1ec6df83 100644 --- a/source/shared_lib/include/graphics/pixmap.h +++ b/source/shared_lib/include/graphics/pixmap.h @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest Shared Library (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2001-2008 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -13,9 +13,9 @@ #define _SHARED_GRAPHICS_PIXMAP_H_ #include - #include "vec.h" #include "types.h" +#include "leak_dumper.h" using std::string; using Shared::Platform::int8; diff --git a/source/shared_lib/include/graphics/quaternion.h b/source/shared_lib/include/graphics/quaternion.h new file mode 100644 index 00000000..bbf830de --- /dev/null +++ b/source/shared_lib/include/graphics/quaternion.h @@ -0,0 +1,98 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICS_QUATERNION_H_ +#define _SHARED_GRAPHICS_QUATERNION_H_ + +#include + +#include "vec.h" +#include "matrix.h" +#include "leak_dumper.h" + +using namespace std; + +namespace Shared{ namespace Graphics{ + +// ===================================================== +// class AxisAngle +// ===================================================== + +class AxisAngle{ +public: + Vec3f axis; + float angle; + + AxisAngle(){}; + AxisAngle(const Vec3f &axis, float angle); +}; + +// ===================================================== +// class EulerAngles +// ===================================================== + +class EulerAngles{ +public: + float x, y, z; + + EulerAngles(){}; + EulerAngles(float x, float y, float z); +}; + +// ===================================================== +// class Quaternion +// ===================================================== + +class Quaternion{ +private: + float w; + Vec3f v; + +public: + Quaternion(); + Quaternion(float w, const Vec3f &v); + Quaternion(const EulerAngles &eulerAngles); + Quaternion(const AxisAngle &axisAngle); + + //initializers + void setMultIdentity(); + void setAddIdentity(); + void setAxisAngle(const AxisAngle &axisAngle); + void setEuler(const EulerAngles &eulerAngles); + + //unary operators + float length(); + Quaternion conjugate(); + void normalize(); + + //binary operators + Quaternion operator + (const Quaternion &q) const; + Quaternion operator * (const Quaternion &q) const; + void operator += (const Quaternion &q); + void operator *= (const Quaternion &q); + + //ternary operators + Quaternion lerp(float t, const Quaternion &q) const; + + //conversions + Matrix3f toMatrix3() const; + Matrix4f toMatrix4() const; + AxisAngle toAxisAngle() const; + + //local axis + Vec3f getLocalXAxis() const; + Vec3f getLocalYAxis() const; + Vec3f getLocalZAxis() const; +}; + +}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/shader.h b/source/shared_lib/include/graphics/shader.h new file mode 100644 index 00000000..e74a4f16 --- /dev/null +++ b/source/shared_lib/include/graphics/shader.h @@ -0,0 +1,87 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICS_SHADER_H_ +#define _SHARED_GRAPHICS_SHADER_H_ + +#include "vec.h" +#include "matrix.h" +#include "texture.h" +#include "leak_dumper.h" + +namespace Shared{ namespace Graphics{ + +// ===================================================== +// class ShaderProgram +// ===================================================== + +class VertexShader; +class FragmentShader; + +class ShaderProgram{ +public: + virtual ~ShaderProgram(){} + virtual void init()= 0; + virtual void end()= 0; + + virtual void attach(VertexShader *vs, FragmentShader *fs)= 0; + virtual bool link(string &messages)= 0; + virtual void activate()= 0; + virtual void deactivate()= 0; + + virtual void setUniform(const string &name, int value)= 0; + virtual void setUniform(const string &name, float value)= 0; + virtual void setUniform(const string &name, const Vec2f &value)= 0; + virtual void setUniform(const string &name, const Vec3f &value)= 0; + virtual void setUniform(const string &name, const Vec4f &value)= 0; + virtual void setUniform(const string &name, const Matrix3f &value)= 0; + virtual void setUniform(const string &name, const Matrix4f &value)= 0; +}; + +// ===================================================== +// class Shader +// ===================================================== + +class Shader{ +public: + virtual ~Shader(){} + virtual void init()= 0; + virtual void end()= 0; + + virtual void load(const string &path)= 0; + virtual bool compile(string &messages)= 0; +}; + +class VertexShader: virtual public Shader{ +}; + +class FragmentShader: virtual public Shader{ +}; + +// ===================================================== +// class ShaderSource +// ===================================================== + +class ShaderSource{ +private: + string pathInfo; + string code; + +public: + const string &getPathInfo() const {return pathInfo;} + const string &getCode() const {return code;} + + void load(const string &path); +}; + +}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/shader_manager.h b/source/shared_lib/include/graphics/shader_manager.h new file mode 100644 index 00000000..5015b7fa --- /dev/null +++ b/source/shared_lib/include/graphics/shader_manager.h @@ -0,0 +1,53 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICS_SHADERMANAGER_H_ +#define _SHARED_GRAPHICS_SHADERMANAGER_H_ + +#include "shader.h" +#include +#include "leak_dumper.h" + +using namespace std; + +namespace Shared{ namespace Graphics{ + +// ===================================================== +// class ShaderManager +// ===================================================== + +class ShaderManager{ +protected: + typedef vector ShaderProgramContainer; + typedef vector ShaderContainer; + +protected: + ShaderProgramContainer shaderPrograms; + ShaderContainer shaders; + string logString; + +public: + ShaderManager(){} + virtual ~ShaderManager(); + + ShaderProgram *newShaderProgram(); + VertexShader *newVertexShader(); + FragmentShader *newFragmentShader(); + + void init(); + void end(); + + const string &getLogString() const {return logString;} +}; + +}}//end namespace + +#endif diff --git a/source/shared_lib/include/graphics/text_renderer.h b/source/shared_lib/include/graphics/text_renderer.h index ef7870a2..d135c24d 100644 --- a/source/shared_lib/include/graphics/text_renderer.h +++ b/source/shared_lib/include/graphics/text_renderer.h @@ -13,9 +13,9 @@ #define _SHARED_GRAPHICS_TEXTRENDERER_H_ #include - #include "vec.h" #include "font.h" +#include "leak_dumper.h" using std::string; diff --git a/source/shared_lib/include/graphics/texture.h b/source/shared_lib/include/graphics/texture.h index 300a34f6..e13e8ac3 100644 --- a/source/shared_lib/include/graphics/texture.h +++ b/source/shared_lib/include/graphics/texture.h @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest Shared Library (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2001-2008 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -14,8 +14,8 @@ #include "types.h" #include "pixmap.h" - #include +#include "leak_dumper.h" using std::string; using Shared::Platform::uint8; diff --git a/source/shared_lib/include/graphics/texture_manager.h b/source/shared_lib/include/graphics/texture_manager.h index ffe00f91..dde152f8 100644 --- a/source/shared_lib/include/graphics/texture_manager.h +++ b/source/shared_lib/include/graphics/texture_manager.h @@ -13,8 +13,8 @@ #define _SHARED_GRAPHICS_TEXTUREMANAGER_H_ #include - #include "texture.h" +#include "leak_dumper.h" using std::vector; diff --git a/source/shared_lib/include/graphics/vec.h b/source/shared_lib/include/graphics/vec.h index 76047610..463cb07a 100644 --- a/source/shared_lib/include/graphics/vec.h +++ b/source/shared_lib/include/graphics/vec.h @@ -16,6 +16,7 @@ #include "math_wrapper.h" #include #include +#include "leak_dumper.h" namespace Shared{ namespace Graphics{ diff --git a/source/shared_lib/include/lua/lua_script.h b/source/shared_lib/include/lua/lua_script.h index a8ab4c4c..ec1b1a36 100644 --- a/source/shared_lib/include/lua/lua_script.h +++ b/source/shared_lib/include/lua/lua_script.h @@ -13,10 +13,9 @@ #define _SHARED_LUA_LUASCRIPT_H_ #include - #include - #include +#include "leak_dumper.h" using std::string; diff --git a/source/shared_lib/include/platform/common/base_thread.h b/source/shared_lib/include/platform/common/base_thread.h index 3f9e40e9..50aec40a 100644 --- a/source/shared_lib/include/platform/common/base_thread.h +++ b/source/shared_lib/include/platform/common/base_thread.h @@ -12,6 +12,7 @@ #ifndef _SHARED_PLATFORMCOMMON_BASETHREAD_H_ #define _SHARED_PLATFORMCOMMON_BASETHREAD_H_ +#include "leak_dumper.h" #include "thread.h" #include diff --git a/source/shared_lib/include/platform/common/cache_manager.h b/source/shared_lib/include/platform/common/cache_manager.h index e5dce03e..8ccb77fe 100644 --- a/source/shared_lib/include/platform/common/cache_manager.h +++ b/source/shared_lib/include/platform/common/cache_manager.h @@ -17,6 +17,7 @@ #include #include #include +#include "leak_dumper.h" using namespace std; using namespace Shared::Platform; diff --git a/source/shared_lib/include/platform/common/math_wrapper.h b/source/shared_lib/include/platform/common/math_wrapper.h index 34e506be..15a59d34 100644 --- a/source/shared_lib/include/platform/common/math_wrapper.h +++ b/source/shared_lib/include/platform/common/math_wrapper.h @@ -22,4 +22,6 @@ #endif +#include "leak_dumper.h" + #endif diff --git a/source/shared_lib/include/platform/common/platform_common.h b/source/shared_lib/include/platform/common/platform_common.h index 2d32d8e5..6864b695 100644 --- a/source/shared_lib/include/platform/common/platform_common.h +++ b/source/shared_lib/include/platform/common/platform_common.h @@ -26,6 +26,7 @@ #include "checksum.h" #include #include +#include "leak_dumper.h" using std::string; using std::vector; diff --git a/source/shared_lib/include/platform/common/simple_threads.h b/source/shared_lib/include/platform/common/simple_threads.h index b681afe9..7d69b988 100644 --- a/source/shared_lib/include/platform/common/simple_threads.h +++ b/source/shared_lib/include/platform/common/simple_threads.h @@ -14,6 +14,7 @@ #include "base_thread.h" #include #include +#include "leak_dumper.h" using namespace std; diff --git a/source/shared_lib/include/platform/posix/socket.h b/source/shared_lib/include/platform/posix/socket.h index 4b6970ef..5daa1a91 100644 --- a/source/shared_lib/include/platform/posix/socket.h +++ b/source/shared_lib/include/platform/posix/socket.h @@ -38,9 +38,11 @@ using std::string; #endif +#include "leak_dumper.h" + using namespace Shared::PlatformCommon; -namespace Shared{ namespace Platform{ +namespace Shared{ namespace Platform { // // This interface describes the methods a callback object must implement diff --git a/source/shared_lib/include/platform/sdl/factory_repository.h b/source/shared_lib/include/platform/sdl/factory_repository.h index fe84c79b..6e57596d 100644 --- a/source/shared_lib/include/platform/sdl/factory_repository.h +++ b/source/shared_lib/include/platform/sdl/factory_repository.h @@ -28,6 +28,7 @@ #include "sound_factory_openal.h" #include "sound_factory_none.h" +#include "leak_dumper.h" using std::string; diff --git a/source/shared_lib/include/platform/sdl/gl_wrap.h b/source/shared_lib/include/platform/sdl/gl_wrap.h index 20044c1d..fe1b9338 100644 --- a/source/shared_lib/include/platform/sdl/gl_wrap.h +++ b/source/shared_lib/include/platform/sdl/gl_wrap.h @@ -30,9 +30,9 @@ #endif #include - #include "font.h" #include "types.h" +#include "leak_dumper.h" using std::string; diff --git a/source/shared_lib/include/platform/sdl/noimpl.h b/source/shared_lib/include/platform/sdl/noimpl.h index b0febb86..d7de3538 100644 --- a/source/shared_lib/include/platform/sdl/noimpl.h +++ b/source/shared_lib/include/platform/sdl/noimpl.h @@ -11,5 +11,7 @@ #endif +#include "leak_dumper.h" + #endif diff --git a/source/shared_lib/include/platform/sdl/platform_main.h b/source/shared_lib/include/platform/sdl/platform_main.h index 4f349695..92937028 100644 --- a/source/shared_lib/include/platform/sdl/platform_main.h +++ b/source/shared_lib/include/platform/sdl/platform_main.h @@ -13,6 +13,7 @@ #include #include +#include "leak_dumper.h" #define MAIN_FUNCTION(X) int main(int argc, char **argv) \ { \ diff --git a/source/shared_lib/include/platform/sdl/platform_util.h b/source/shared_lib/include/platform/sdl/platform_util.h index ef0258d8..4b7b03af 100644 --- a/source/shared_lib/include/platform/sdl/platform_util.h +++ b/source/shared_lib/include/platform/sdl/platform_util.h @@ -14,6 +14,7 @@ #include #include #include "platform_common.h" +#include "leak_dumper.h" using namespace Shared::PlatformCommon; using std::string; diff --git a/source/shared_lib/include/platform/sdl/sdl_private.h b/source/shared_lib/include/platform/sdl/sdl_private.h index a7a3a3a6..e5c50925 100644 --- a/source/shared_lib/include/platform/sdl/sdl_private.h +++ b/source/shared_lib/include/platform/sdl/sdl_private.h @@ -14,6 +14,8 @@ // This header contains things that should not be used outside the platform/sdl // directory +#include "leak_dumper.h" + namespace Shared{ namespace PlatformCommon { namespace Private { extern bool shouldBeFullscreen; diff --git a/source/shared_lib/include/platform/sdl/thread.h b/source/shared_lib/include/platform/sdl/thread.h index fe34a8b6..892cbb55 100644 --- a/source/shared_lib/include/platform/sdl/thread.h +++ b/source/shared_lib/include/platform/sdl/thread.h @@ -14,6 +14,7 @@ #include #include +#include "leak_dumper.h" // ===================================================== // class Thread diff --git a/source/shared_lib/include/platform/sdl/types.h b/source/shared_lib/include/platform/sdl/types.h new file mode 100644 index 00000000..84646f04 --- /dev/null +++ b/source/shared_lib/include/platform/sdl/types.h @@ -0,0 +1,38 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2005 Matthias Braun +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== +#ifndef _SHARED_PLATFORM_TYPES_H_ +#define _SHARED_PLATFORM_TYPES_H_ + +#include +#include "leak_dumper.h" + +namespace Shared{ namespace Platform{ + +// These don't have a real meaning in the SDL port +typedef void* WindowHandle; +typedef void* DeviceContextHandle; +typedef void* GlContextHandle; + +typedef float float32; +typedef double float64; +// don't use Sint8 here because that is defined as signed char +// and some parts of the code do std::string str = (int8*) var; +typedef char int8; +typedef Uint8 uint8; +typedef Sint16 int16; +typedef Uint16 uint16; +typedef Sint32 int32; +typedef Uint32 uint32; +typedef Sint64 int64; + +}}//end namespace + +#endif diff --git a/source/shared_lib/include/platform/sdl/window.h b/source/shared_lib/include/platform/sdl/window.h index d111785e..ec58c402 100644 --- a/source/shared_lib/include/platform/sdl/window.h +++ b/source/shared_lib/include/platform/sdl/window.h @@ -17,9 +17,9 @@ #include #include #include - #include "types.h" #include "vec.h" +#include "leak_dumper.h" using std::map; using std::string; diff --git a/source/shared_lib/include/platform/sdl/window_gl.h b/source/shared_lib/include/platform/sdl/window_gl.h index 5065c9dd..b9dc2a80 100644 --- a/source/shared_lib/include/platform/sdl/window_gl.h +++ b/source/shared_lib/include/platform/sdl/window_gl.h @@ -14,6 +14,7 @@ #include "context_gl.h" #include "window.h" +#include "leak_dumper.h" using Shared::Graphics::Gl::ContextGl; diff --git a/source/shared_lib/include/platform/win32/glob.h b/source/shared_lib/include/platform/win32/glob.h index 8d6c56d6..efd0695f 100644 --- a/source/shared_lib/include/platform/win32/glob.h +++ b/source/shared_lib/include/platform/win32/glob.h @@ -47,6 +47,8 @@ #ifndef SYNSOFT_UNIXEM_INCL_H_GLOB #define SYNSOFT_UNIXEM_INCL_H_GLOB +#include "leak_dumper.h" + /* ////////////////////////////////////////////////////////////////////// */ /** \weakgroup unixem Synesis Software UNIX Emulation for Win32 diff --git a/source/shared_lib/include/platform/win32/platform_definitions.h b/source/shared_lib/include/platform/win32/platform_definitions.h new file mode 100644 index 00000000..79a88807 --- /dev/null +++ b/source/shared_lib/include/platform/win32/platform_definitions.h @@ -0,0 +1,23 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2005 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_PLATFORM_DEFINITIONS_H_ +#define _SHARED_PLATFORM_DEFINITIONS_H_ + +#include "leak_dumper.h" + +namespace Shared{ namespace Platform{ + + + +}}//end namespace + +#endif diff --git a/source/shared_lib/include/platform/win32/platform_util.h b/source/shared_lib/include/platform/win32/platform_util.h index 0986fecd..4ae5f6a7 100755 --- a/source/shared_lib/include/platform/win32/platform_util.h +++ b/source/shared_lib/include/platform/win32/platform_util.h @@ -16,6 +16,7 @@ #include #include #include "platform_common.h" +#include "leak_dumper.h" using namespace Shared::PlatformCommon; using std::string; diff --git a/source/shared_lib/include/platform/win32/types.h b/source/shared_lib/include/platform/win32/types.h index 23b27937..c796f17d 100644 --- a/source/shared_lib/include/platform/win32/types.h +++ b/source/shared_lib/include/platform/win32/types.h @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest Shared Library (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2001-2008 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -14,6 +14,7 @@ #define NOMINMAX #include +#include "leak_dumper.h" namespace Shared{ namespace Platform{ diff --git a/source/shared_lib/include/sound/openal/sound_factory_openal.h b/source/shared_lib/include/sound/openal/sound_factory_openal.h new file mode 100644 index 00000000..9756aecb --- /dev/null +++ b/source/shared_lib/include/sound/openal/sound_factory_openal.h @@ -0,0 +1,29 @@ +//This file is part of Glest Shared Library (www.glest.org) +//Copyright (C) 2005 Matthias Braun + +//You can redistribute this code and/or modify it under +//the terms of the GNU General Public License as published by the Free Software +//Foundation; either version 2 of the License, or (at your option) any later +//version. + +#ifndef _SHARED_SOUND_SOUNDFACTORYSDL_H_ +#define _SHARED_SOUND_SOUNDFACTORYSDL_H_ + +#include "sound_factory.h" +#include "sound_player_openal.h" +#include "leak_dumper.h" + +namespace Shared{ namespace Sound{ namespace OpenAL{ + +// =============================== +// class SoundFactoryOpenAL +// =============================== + +class SoundFactoryOpenAL : public SoundFactory{ +public: + virtual SoundPlayer* newSoundPlayer() {return new SoundPlayerOpenAL();} +}; + +}}}//end namespace + +#endif diff --git a/source/shared_lib/include/sound/openal/sound_player_openal.h b/source/shared_lib/include/sound/openal/sound_player_openal.h index 32b6b9bb..e460550d 100644 --- a/source/shared_lib/include/sound/openal/sound_player_openal.h +++ b/source/shared_lib/include/sound/openal/sound_player_openal.h @@ -11,12 +11,11 @@ #include "sound_player.h" #include "platform_util.h" #include "platform_common.h" - #include #include #include - #include +#include "leak_dumper.h" using std::vector; using namespace Shared::PlatformCommon; diff --git a/source/shared_lib/include/sound/sound.h b/source/shared_lib/include/sound/sound.h index 85551a85..9d26f533 100644 --- a/source/shared_lib/include/sound/sound.h +++ b/source/shared_lib/include/sound/sound.h @@ -14,6 +14,7 @@ #include #include "sound_file_loader.h" +#include "leak_dumper.h" using namespace std; using namespace Shared::Platform; diff --git a/source/shared_lib/include/sound/sound_factory.h b/source/shared_lib/include/sound/sound_factory.h new file mode 100644 index 00000000..aa063953 --- /dev/null +++ b/source/shared_lib/include/sound/sound_factory.h @@ -0,0 +1,32 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_SOUND_SOUNDFACTORY_H_ +#define _SHARED_SOUND_SOUNDFACTORY_H_ + +#include "sound_player.h" +#include "leak_dumper.h" + +namespace Shared{ namespace Sound{ + +// ===================================================== +// class SoundFactory +// ===================================================== + +class SoundFactory{ +public: + virtual ~SoundFactory(){} + virtual SoundPlayer *newSoundPlayer() {return NULL;} +}; + +}}//end namespace + +#endif diff --git a/source/shared_lib/include/sound/sound_factory_none.h b/source/shared_lib/include/sound/sound_factory_none.h index d82cb0dd..d13b4fb0 100644 --- a/source/shared_lib/include/sound/sound_factory_none.h +++ b/source/shared_lib/include/sound/sound_factory_none.h @@ -10,7 +10,7 @@ #define _SHARED_SOUND_SOUNDFACTORY_NONEL_H_ #include "sound_factory.h" -//#include "sound_player_openal.h" +#include "leak_dumper.h" namespace Shared{ namespace Sound{ diff --git a/source/shared_lib/include/sound/sound_file_loader.h b/source/shared_lib/include/sound/sound_file_loader.h index 8a7eb07c..8440c651 100644 --- a/source/shared_lib/include/sound/sound_file_loader.h +++ b/source/shared_lib/include/sound/sound_file_loader.h @@ -14,9 +14,9 @@ #include #include - #include "types.h" #include "factory.h" +#include "leak_dumper.h" struct OggVorbis_File; diff --git a/source/shared_lib/include/sound/sound_interface.h b/source/shared_lib/include/sound/sound_interface.h index 565db203..dcd96659 100644 --- a/source/shared_lib/include/sound/sound_interface.h +++ b/source/shared_lib/include/sound/sound_interface.h @@ -13,6 +13,7 @@ #define _SHARED_SOUND_SOUNDINTERFACE_H_ #include "sound_factory.h" +#include "leak_dumper.h" namespace Shared{ namespace Sound{ diff --git a/source/shared_lib/include/sound/sound_player.h b/source/shared_lib/include/sound/sound_player.h index 5467c058..06ad86c7 100644 --- a/source/shared_lib/include/sound/sound_player.h +++ b/source/shared_lib/include/sound/sound_player.h @@ -14,6 +14,7 @@ #include "sound.h" #include "types.h" +#include "leak_dumper.h" using Shared::Platform::uint32; diff --git a/source/shared_lib/include/util/checksum.h b/source/shared_lib/include/util/checksum.h index 647476f5..60508895 100644 --- a/source/shared_lib/include/util/checksum.h +++ b/source/shared_lib/include/util/checksum.h @@ -14,8 +14,8 @@ #include #include - #include "types.h" +#include "leak_dumper.h" using std::string; using Shared::Platform::int32; diff --git a/source/shared_lib/include/util/conversion.h b/source/shared_lib/include/util/conversion.h index abce16bc..fc4ca71f 100644 --- a/source/shared_lib/include/util/conversion.h +++ b/source/shared_lib/include/util/conversion.h @@ -13,6 +13,7 @@ #define _SHARED_UTIL_CONVERSION_H_ #include +#include "leak_dumper.h" using std::string; diff --git a/source/shared_lib/include/util/factory.h b/source/shared_lib/include/util/factory.h new file mode 100644 index 00000000..e88950e2 --- /dev/null +++ b/source/shared_lib/include/util/factory.h @@ -0,0 +1,87 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_UTIL_FACTORY_ +#define _SHARED_UTIL_FACTORY_ + +#include +#include +#include +#include "leak_dumper.h" + +using std::map; +using std::string; +using std::pair; +using std::runtime_error; + +namespace Shared{ namespace Util{ + +// ===================================================== +// class SingleFactoryBase +// ===================================================== + +class SingleFactoryBase{ +public: + virtual ~SingleFactoryBase(){} + virtual void *newInstance()= 0; +}; + +// ===================================================== +// class SingleFactory +// ===================================================== + +template +class SingleFactory: public SingleFactoryBase{ +public: + virtual void *newInstance() {return new T();} +}; + +// ===================================================== +// class MultiFactory +// ===================================================== + +template +class MultiFactory{ +private: + typedef map Factories; + typedef pair FactoryPair; + +private: + Factories factories; + +public: + virtual ~MultiFactory(){ + for(Factories::iterator it= factories.begin(); it!=factories.end(); ++it){ + delete it->second; + } + } + + template + void registerClass(string classId){ + factories.insert(FactoryPair(classId, new SingleFactory())); + } + + T *newInstance(string classId){ + Factories::iterator it= factories.find(classId); + if(it == factories.end()){ + throw runtime_error("Unknown class identifier: " + classId); + } + return static_cast(it->second->newInstance()); + } + + bool isClassId(string classId){ + return factories.find(classId)!=factories.end(); + } +}; + +}}//end namespace + +#endif diff --git a/source/shared_lib/include/util/leak_dumper.h b/source/shared_lib/include/util/leak_dumper.h index a3b0bcab..0b5864ae 100644 --- a/source/shared_lib/include/util/leak_dumper.h +++ b/source/shared_lib/include/util/leak_dumper.h @@ -17,8 +17,13 @@ #ifdef SL_LEAK_DUMP +#include +//#include #include #include +//#include + +using namespace std; //including this header in any file of a project will cause all //leaks to be dumped into leak_dump.txt, but only allocations that @@ -68,48 +73,48 @@ public: //if an allocation ocurrs in a file where "leaks_dumper.h" is not included //this operator new is called and file and line will be unknown -inline void * operator new (size_t bytes){ +void * operator new (size_t bytes) { void *ptr= malloc(bytes); AllocRegistry::getInstance().allocate(AllocInfo(ptr, "unknown", 0, bytes, false)); return ptr; } -inline void operator delete(void *ptr){ +void operator delete(void *ptr){ AllocRegistry::getInstance().deallocate(ptr, false); free(ptr); } -inline void * operator new[](size_t bytes){ +void * operator new[](size_t bytes){ void *ptr= malloc(bytes); AllocRegistry::getInstance().allocate(AllocInfo(ptr, "unknown", 0, bytes, true)); return ptr; } -inline void operator delete [](void *ptr){ +void operator delete [](void *ptr){ AllocRegistry::getInstance().deallocate(ptr, true); free(ptr); } //if an allocation ocurrs in a file where "leaks_dumper.h" is included //this operator new is called and file and line will be known -inline void * operator new (size_t bytes, char* file, int line){ +void * operator new (size_t bytes, char* file, int line){ void *ptr= malloc(bytes); AllocRegistry::getInstance().allocate(AllocInfo(ptr, file, line, bytes, false)); return ptr; } -inline void operator delete(void *ptr, char* file, int line){ +void operator delete(void *ptr, char* file, int line){ AllocRegistry::getInstance().deallocate(ptr, false); free(ptr); } -inline void * operator new[](size_t bytes, char* file, int line){ +void * operator new[](size_t bytes, char* file, int line){ void *ptr= malloc(bytes); AllocRegistry::getInstance().allocate(AllocInfo(ptr, file, line, bytes, true)); return ptr; } -inline void operator delete [](void *ptr, char* file, int line){ +void operator delete [](void *ptr, char* file, int line){ AllocRegistry::getInstance().deallocate(ptr, true); free(ptr); } @@ -118,4 +123,5 @@ inline void operator delete [](void *ptr, char* file, int line){ #endif + #endif diff --git a/source/shared_lib/include/util/profiler.h b/source/shared_lib/include/util/profiler.h index 33d2d5d4..e9cc1ba7 100644 --- a/source/shared_lib/include/util/profiler.h +++ b/source/shared_lib/include/util/profiler.h @@ -19,6 +19,7 @@ #include "platform_common.h" #include #include +#include "leak_dumper.h" using std::list; using std::string; diff --git a/source/shared_lib/include/util/properties.h b/source/shared_lib/include/util/properties.h index 98d0a89d..d718e3c4 100644 --- a/source/shared_lib/include/util/properties.h +++ b/source/shared_lib/include/util/properties.h @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest Shared Library (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2001-2008 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -15,6 +15,7 @@ #include #include #include +#include "leak_dumper.h" using std::map; using std::vector; diff --git a/source/shared_lib/include/util/randomgen.h b/source/shared_lib/include/util/randomgen.h index 90541bab..3d2c2487 100644 --- a/source/shared_lib/include/util/randomgen.h +++ b/source/shared_lib/include/util/randomgen.h @@ -12,7 +12,7 @@ #ifndef _SHARED_UTIL_RANDOM_H_ #define _SHARED_UTIL_RANDOM_H_ -//#include "math_wrapper.h" +#include "leak_dumper.h" namespace Shared { namespace Util { diff --git a/source/shared_lib/include/util/util.h b/source/shared_lib/include/util/util.h index d31f7188..1ba57106 100644 --- a/source/shared_lib/include/util/util.h +++ b/source/shared_lib/include/util/util.h @@ -18,6 +18,7 @@ #include "thread.h" #include #include +#include "leak_dumper.h" using std::string; using namespace Shared::Platform; diff --git a/source/shared_lib/include/xml/xml_parser.h b/source/shared_lib/include/xml/xml_parser.h new file mode 100644 index 00000000..de347387 --- /dev/null +++ b/source/shared_lib/include/xml/xml_parser.h @@ -0,0 +1,158 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Marti�o Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_XML_XMLPARSER_H_ +#define _SHARED_XML_XMLPARSER_H_ + +#include +#include +#include +#include "leak_dumper.h" + +using std::string; +using std::vector; + +namespace XERCES_CPP_NAMESPACE{ + class DOMImplementation; + class DOMDocument; + class DOMNode; + class DOMElement; +} + +namespace Shared{ namespace Xml{ + +const int strSize= 256; + +class XmlIo; +class XmlTree; +class XmlNode; +class XmlAttribute; + +// ===================================================== +// class XmlIo +// +/// Wrapper for Xerces C++ +// ===================================================== + +class XmlIo{ +private: + static bool initialized; + XERCES_CPP_NAMESPACE::DOMImplementation *implementation; + +private: + XmlIo(); + +public: + static XmlIo &getInstance(); + ~XmlIo(); + XmlNode *load(const string &path); + void save(const string &path, const XmlNode *node); +}; + +// ===================================================== +// class XmlTree +// ===================================================== + +class XmlTree{ +private: + XmlNode *rootNode; + +private: + XmlTree(XmlTree&); + void operator =(XmlTree&); + +public: + XmlTree(); + ~XmlTree(); + + void init(const string &name); + void load(const string &path); + void save(const string &path); + + XmlNode *getRootNode() const {return rootNode;} +}; + +// ===================================================== +// class XmlNode +// ===================================================== + +class XmlNode{ +private: + string name; + string text; + vector children; + vector attributes; + +private: + XmlNode(XmlNode&); + void operator =(XmlNode&); + +public: + XmlNode(XERCES_CPP_NAMESPACE::DOMNode *node); + XmlNode(const string &name); + ~XmlNode(); + + const string &getName() const {return name;} + int getChildCount() const {return children.size();} + int getAttributeCount() const {return attributes.size();} + const string &getText() const {return text;} + + XmlAttribute *getAttribute(int i) const; + XmlAttribute *getAttribute(const string &name) const; + XmlNode *getChild(int i) const; + XmlNode *getChild(const string &childName, int childIndex=0) const; + bool hasChildAtIndex(const string &childName, int childIndex=0) const; + bool hasChild(const string &childName) const; + XmlNode *getParent() const; + + + XmlNode *addChild(const string &name); + XmlAttribute *addAttribute(const string &name, const string &value); + + XERCES_CPP_NAMESPACE::DOMElement *buildElement(XERCES_CPP_NAMESPACE::DOMDocument *document) const; + +private: + string getTreeString() const; +}; + +// ===================================================== +// class XmlAttribute +// ===================================================== + +class XmlAttribute{ +private: + string value; + string name; + +private: + XmlAttribute(XmlAttribute&); + void operator =(XmlAttribute&); + +public: + XmlAttribute(XERCES_CPP_NAMESPACE::DOMNode *attribute); + XmlAttribute(const string &name, const string &value); + +public: + const string &getName() const {return name;} + const string &getValue() const {return value;} + + bool getBoolValue() const; + int getIntValue() const; + int getIntValue(int min, int max) const; + float getFloatValue() const; + float getFloatValue(float min, float max) const; + const string &getRestrictedValue() const; +}; + + +}}//end namespace + +#endif diff --git a/source/shared_lib/sources/util/leak_dumper.cpp b/source/shared_lib/sources/util/leak_dumper.cpp index 0345a777..a689eaa2 100644 --- a/source/shared_lib/sources/util/leak_dumper.cpp +++ b/source/shared_lib/sources/util/leak_dumper.cpp @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest Shared Library (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2001-2008 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published