diff --git a/mk/windoze/CopyWindowsRuntimeDlls.bat b/mk/windoze/CopyWindowsRuntimeDlls.bat index c54532e6..4b59dafb 100644 --- a/mk/windoze/CopyWindowsRuntimeDlls.bat +++ b/mk/windoze/CopyWindowsRuntimeDlls.bat @@ -1,6 +1,6 @@ @echo off -if not exist ..\..\data\glest_game\dsound.dll copy dsound.dll ..\..\data\glest_game\ +rem if not exist ..\..\data\glest_game\dsound.dll copy dsound.dll ..\..\data\glest_game\ if not exist ..\..\data\glest_game\xerces-c_3_0.dll copy xerces-c_3_0.dll ..\..\data\glest_game\ if not exist ..\..\data\glest_game\libpng14.dll copy libpng14.dll ..\..\data\glest_game\ if not exist ..\..\data\glest_game\zlib1.dll copy zlib1.dll ..\..\data\glest_game\ diff --git a/mk/windoze/Glest.sln b/mk/windoze/Glest.sln index 5d8a8778..73b2a3ea 100755 --- a/mk/windoze/Glest.sln +++ b/mk/windoze/Glest.sln @@ -20,6 +20,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "g3d_viewer", "g3d_viewer.vc EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glest_configurator", "glest_configurator.vcproj", "{FE5C7C7C-F109-44F5-8329-19A4E24F162D}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libstreflop", "libstreflop.vcproj", "{CDF4DDB9-945E-4D0D-9F0E-2BBEB5D22141}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -46,6 +48,10 @@ Global {FE5C7C7C-F109-44F5-8329-19A4E24F162D}.Debug|Win32.Build.0 = Debug|Win32 {FE5C7C7C-F109-44F5-8329-19A4E24F162D}.Release|Win32.ActiveCfg = Release|Win32 {FE5C7C7C-F109-44F5-8329-19A4E24F162D}.Release|Win32.Build.0 = Release|Win32 + {CDF4DDB9-945E-4D0D-9F0E-2BBEB5D22141}.Debug|Win32.ActiveCfg = Debug|Win32 + {CDF4DDB9-945E-4D0D-9F0E-2BBEB5D22141}.Debug|Win32.Build.0 = Debug|Win32 + {CDF4DDB9-945E-4D0D-9F0E-2BBEB5D22141}.Release|Win32.ActiveCfg = Release|Win32 + {CDF4DDB9-945E-4D0D-9F0E-2BBEB5D22141}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/mk/windoze/Glest.suo b/mk/windoze/Glest.suo index c6253989..68548b36 100755 Binary files a/mk/windoze/Glest.suo and b/mk/windoze/Glest.suo differ diff --git a/mk/windoze/g3d_viewer.vcproj b/mk/windoze/g3d_viewer.vcproj index 774e41f0..4f305a04 100755 --- a/mk/windoze/g3d_viewer.vcproj +++ b/mk/windoze/g3d_viewer.vcproj @@ -4,6 +4,7 @@ Version="9.00" Name="g3d_viewer" ProjectGUID="{FE5C7C7C-F109-44F5-8329-25A4E24F162C}" + RootNamespace="g3d_viewer" Keyword="Win32Proj" TargetFrameworkVersion="0" > @@ -115,7 +116,7 @@ /> + + + + diff --git a/mk/windoze/libstreflop.vcproj b/mk/windoze/libstreflop.vcproj new file mode 100644 index 00000000..1c3b941b --- /dev/null +++ b/mk/windoze/libstreflop.vcproj @@ -0,0 +1,473 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mk/windoze/shared_lib.vcproj b/mk/windoze/shared_lib.vcproj index 842d7d5d..04e483ed 100755 --- a/mk/windoze/shared_lib.vcproj +++ b/mk/windoze/shared_lib.vcproj @@ -113,11 +113,11 @@ InlineFunctionExpansion="2" EnableIntrinsicFunctions="true" FavorSizeOrSpeed="1" - AdditionalIncludeDirectories="../../../deps/include/lua;../../../deps/include;../../source/shared_lib/include;../../source/shared_lib/include/graphics;../../source/shared_lib/include/graphics/gl;../../source/shared_lib/include/platform;../../source/shared_lib/include/platform/win32;../../source/shared_lib/include/sound;../../source/shared_lib/include/sound/ds8;../../source/shared_lib/include/util;../../source/shared_lib/include/lua;../../source/shared_lib/include/xml;../../source/win32_deps/include;"../../source/win32_deps/xerces-c-3.0.1/src";"../../source/win32_deps/xerces-c-3.0.1/src/xercesc/xinclude";../../source/win32_deps/libpng141;"../../source/win32_deps/jpeg-8a";"../../source/win32_deps/SDL-1.2.14/include";../../source/shared_lib/include/platform/sdl;"../../source/win32_deps/openal-soft-1.12.854/include";../../source/shared_lib/include/sound/openal;../../source/shared_lib/include/platform/posix" - PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;USE_PCH=1" + AdditionalIncludeDirectories="../../../deps/include/lua;../../../deps/include;../../source/shared_lib/include;../../source/shared_lib/include/graphics;../../source/shared_lib/include/graphics/gl;../../source/shared_lib/include/platform;../../source/shared_lib/include/platform/win32;../../source/shared_lib/include/sound;../../source/shared_lib/include/sound/ds8;../../source/shared_lib/include/util;../../source/shared_lib/include/lua;../../source/shared_lib/include/xml;../../source/win32_deps/include;"../../source/win32_deps/xerces-c-3.0.1/src";"../../source/win32_deps/xerces-c-3.0.1/src/xercesc/xinclude";../../source/win32_deps/libpng141;"../../source/win32_deps/jpeg-8a";"../../source/win32_deps/SDL-1.2.14/include";../../source/shared_lib/include/platform/sdl;"../../source/win32_deps/openal-soft-1.12.854/include";../../source/shared_lib/include/sound/openal;../../source/shared_lib/include/platform/posix;../../source/shared_lib/include/streflop;../../source/shared_lib/include/streflop/libm_flt32_source" + PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;USE_PCH=1;USE_STREFLOP;STREFLOP_SSE;LIBM_COMPILING_FLT32" RuntimeLibrary="0" EnableFunctionLevelLinking="true" - EnableEnhancedInstructionSet="2" + EnableEnhancedInstructionSet="1" FloatingPointModel="2" RuntimeTypeInfo="false" WarningLevel="3" @@ -134,6 +134,8 @@ /> + + + + + + @@ -332,7 +346,7 @@ > + + + + + + + + + + + + + + + + + + @@ -726,7 +776,7 @@ > + +#include "randomgen.h" + +using Shared::Util::RandomGen; + +namespace Glest{ namespace Game{ + +class Program; +class MainMenu; +class MenuStateScenario; +class Game; + +// ===================================================== +// class AutoTest +// +/// Interface to write log files +// ===================================================== + +class AutoTest{ +private: + int gameStartTime; + RandomGen random; + +private: + static const time_t invalidTime; + static const time_t gameTime; + +public: + static AutoTest & getInstance(); + AutoTest(); + + void updateIntro(Program *program); + void updateRoot(Program *program, MainMenu *mainMenu); + void updateNewGame(Program *program, MainMenu *mainMenu); + void updateScenario(MenuStateScenario *menuStateScenario); + void updateGame(Game *game); + void updateBattleEnd(Program *program); +}; + +}}//end namespace + +#endif diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 2f484f14..c29f8b77 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -24,7 +24,7 @@ #include "opengl.h" #include "faction.h" #include "factory_repository.h" -#include +//#include #include "leak_dumper.h" diff --git a/source/glest_game/gui/gui.h b/source/glest_game/gui/gui.h index 1ee95a70..1d44a59a 100644 --- a/source/glest_game/gui/gui.h +++ b/source/glest_game/gui/gui.h @@ -18,10 +18,10 @@ #include "commander.h" #include "console.h" #include "selection.h" -#include "random.h" +#include "randomgen.h" #include -//using Shared::Util::Random; +using Shared::Util::RandomGen; namespace Glest{ namespace Game{ @@ -102,7 +102,7 @@ public: private: //External objects - Shared::Util::Random random; + RandomGen random; const Commander *commander; const World *world; GameCamera *gameCamera; diff --git a/source/glest_game/menu/menu_background.h b/source/glest_game/menu/menu_background.h index 2edbbcd0..a655dd63 100644 --- a/source/glest_game/menu/menu_background.h +++ b/source/glest_game/menu/menu_background.h @@ -17,7 +17,7 @@ #include "vec.h" #include "texture.h" #include "model.h" -#include "random.h" +#include "randomgen.h" using Shared::Graphics::RainParticleSystem; using Shared::Graphics::FireParticleSystem; @@ -26,7 +26,7 @@ using Shared::Graphics::Vec3f; using Shared::Graphics::Vec2f; using Shared::Graphics::Texture2D; using Shared::Graphics::Model; -//using Shared::Util::Random; +using Shared::Util::RandomGen; namespace Glest{ namespace Game{ @@ -67,7 +67,7 @@ private: float t; //misc - Shared::Util::Random random; + RandomGen random; Model *characterModels[characterCount]; float anim; float fade; diff --git a/source/glest_game/sound/sound_container.h b/source/glest_game/sound/sound_container.h index 5f5cd347..697d4bf0 100644 --- a/source/glest_game/sound/sound_container.h +++ b/source/glest_game/sound/sound_container.h @@ -15,10 +15,10 @@ #include #include "sound.h" -#include "random.h" +#include "randomgen.h" using std::vector; -//using Shared::Util::Random; +using Shared::Util::RandomGen; using Shared::Sound::StaticSound; namespace Glest{ namespace Game{ @@ -35,7 +35,7 @@ public: private: Sounds sounds; - mutable Shared::Util::Random random; + mutable RandomGen random; mutable int lastSound; public: diff --git a/source/glest_game/type_instances/object.cpp b/source/glest_game/type_instances/object.cpp index 0825a055..44085664 100644 --- a/source/glest_game/type_instances/object.cpp +++ b/source/glest_game/type_instances/object.cpp @@ -18,7 +18,7 @@ #include "object_type.h" #include "resource.h" #include "util.h" -#include "random.h" +#include "randomgen.h" #include "leak_dumper.h" using namespace Shared::Util; @@ -31,7 +31,7 @@ namespace Glest{ namespace Game{ // ===================================================== Object::Object(ObjectType *objectType, const Vec3f &pos){ - Shared::Util::Random random; + RandomGen random; random.init(static_cast(pos.x*pos.z)); diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index d14c02ff..d9951135 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -23,11 +23,11 @@ #include "skill_type.h" #include "core_data.h" #include "renderer.h" -#include "leak_dumper.h" -#include - +//#include #include "socket.h" +#include "leak_dumper.h" + using namespace Shared::Graphics; using namespace Shared::Util; @@ -115,7 +115,7 @@ Unit::Unit(int id, const Vec2i &pos, const UnitType *type, Faction *faction, Map allowRotateUnits = Config::getInstance().getBool("AllowRotateUnits","0"); modelFacing = CardinalDir::NORTH; - Random random; + RandomGen random; this->pos=pos; this->type=type; diff --git a/source/glest_game/world/tileset.h b/source/glest_game/world/tileset.h index 9229b6df..0e2a444a 100644 --- a/source/glest_game/world/tileset.h +++ b/source/glest_game/world/tileset.h @@ -18,7 +18,7 @@ #include "xml_parser.h" #include "object_type.h" #include "sound.h" -#include "random.h" +#include "randomgen.h" #include "surface_atlas.h" #include "checksum.h" @@ -31,7 +31,7 @@ using Shared::Graphics::Model; using Shared::Graphics::Vec3f; using Shared::Graphics::Texture2D; using Shared::Graphics::Texture3D; -using Shared::Util::Random; +using Shared::Util::RandomGen; using Shared::Util::Checksum; using std::map; @@ -115,7 +115,7 @@ private: SurfProbs surfProbs[surfCount]; SurfPixmaps surfPixmaps[surfCount]; - Random random; + RandomGen random; Texture3D *waterTex; bool waterEffects; bool fog; diff --git a/source/glest_game/world/unit_updater.h b/source/glest_game/world/unit_updater.h index be70cf12..14c231e9 100644 --- a/source/glest_game/world/unit_updater.h +++ b/source/glest_game/world/unit_updater.h @@ -15,10 +15,10 @@ #include "gui.h" #include "path_finder.h" #include "particle.h" -#include "random.h" +#include "randomgen.h" using Shared::Graphics::ParticleObserver; -//using Shared::Util::Random; +using Shared::Util::RandomGen; namespace Glest{ namespace Game{ @@ -55,7 +55,7 @@ private: ScriptManager *scriptManager; PathFinder pathFinder; Game *game; - Shared::Util::Random random; + RandomGen random; bool allowRotateUnits; public: diff --git a/source/glest_game/world/world.h b/source/glest_game/world/world.h index a98af70d..022ce865 100644 --- a/source/glest_game/world/world.h +++ b/source/glest_game/world/world.h @@ -28,14 +28,14 @@ #include "water_effects.h" #include "faction.h" #include "unit_updater.h" -#include "random.h" +#include "randomgen.h" #include "game_constants.h" namespace Glest{ namespace Game{ using Shared::Graphics::Quad2i; using Shared::Graphics::Rect2i; -using Shared::Util::Random; +using Shared::Util::RandomGen; class Faction; class Unit; @@ -74,7 +74,7 @@ private: Factions factions; - Random random; + RandomGen random; ScriptManager* scriptManager; diff --git a/source/glest_map_editor/map.h b/source/glest_map_editor/map.h new file mode 100644 index 00000000..3c8926b5 --- /dev/null +++ b/source/glest_map_editor/map.h @@ -0,0 +1,134 @@ +// ============================================================== +// 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 _MAPEDITOR_MAP_H_ +#define _MAPEDITOR_MAP_H_ + +#include "util.h" +#include "types.h" +#include "randomgen.h" + +using Shared::Platform::int8; +using Shared::Platform::int32; +using Shared::Platform::float32; +using Shared::Util::RandomGen; + +namespace MapEditor { + +struct MapFileHeader { + int32 version; + int32 maxFactions; + int32 width; + int32 height; + int32 altFactor; + int32 waterLevel; + int8 title[128]; + int8 author[128]; + int8 description[256]; +}; + +// =============================================== +// class Map +// =============================================== + +class Map { +public: + static const int maxHeight = 20; + static const int minHeight = 0; + +private: + struct Cell { + int surface; + int object; + int resource; + float height; + }; + + struct StartLocation { + int x; + int y; + }; + + RandomGen random; + string title; + string author; + string desc; + string recScn; + int type; + int h; + int w; + int altFactor; + int waterLevel; + Cell **cells; + int maxFactions; + StartLocation *startLocations; + int refAlt; + +public: + Map(); + ~Map(); + float getHeight(int x, int y) const; + int getSurface(int x, int y) const; + int getObject(int x, int y) const; + int getResource(int x, int y) const; + int getStartLocationX(int index) const; + int getStartLocationY(int index) const; + int getHeightFactor() const; + int getWaterLevel() const; + bool inside(int x, int y); + + void setRefAlt(int x, int y); + void setAdvanced(int altFactor, int waterLevel); + void setTitle(const string &title); + void setDesc(const string &desc); + void setAuthor(const string &author); + + int getH() const {return h;} + int getW() const {return w;} + int getMaxFactions() const {return maxFactions;} + string getTitle() const {return title;} + string getDesc() const {return desc;} + string getAuthor() const {return author;} + + void glestChangeHeight(int x, int y, int height, int radius); + void pirateChangeHeight(int x, int y, int height, int radius); + void changeSurface(int x, int y, int surface, int radius); + void changeObject(int x, int y, int object, int radius); + void changeResource(int x, int y, int resource, int radius); + void changeStartLocation(int x, int y, int player); + + void setHeight(int x, int y, float height); + void setSurface(int x, int y, int surface); + void setObject(int x, int y, int object); + void setResource(int x, int y, int resource); + + void flipX(); + void flipY(); + void reset(int w, int h, float alt, int surf); + void resize(int w, int h, float alt, int surf); + void resetFactions(int maxFactions); + void randomizeHeights(); + void randomize(); + void switchSurfaces(int surf1, int surf2); + + void loadFromFile(const string &path); + void saveToFile(const string &path); + +public: + void resetHeights(int height); + void sinRandomize(int strenght); + void decalRandomize(int strenght); + void applyNewHeight(float newHeight, int x, int y, int strenght); +}; + +}// end namespace + +#endif diff --git a/source/shared_lib/include/graphics/particle.h b/source/shared_lib/include/graphics/particle.h index f779a2c9..752ce533 100644 --- a/source/shared_lib/include/graphics/particle.h +++ b/source/shared_lib/include/graphics/particle.h @@ -18,10 +18,10 @@ #include "vec.h" #include "pixmap.h" #include "texture_manager.h" -#include "random.h" +#include "randomgen.h" using std::list; -//using Shared::Util::Random; +using Shared::Util::RandomGen; namespace Shared{ namespace Graphics{ @@ -95,7 +95,7 @@ protected: protected: Particle *particles; - Shared::Util::Random random; + RandomGen random; BlendMode blendMode; State state; diff --git a/source/shared_lib/include/util/randomgen.h b/source/shared_lib/include/util/randomgen.h new file mode 100644 index 00000000..e05de3fd --- /dev/null +++ b/source/shared_lib/include/util/randomgen.h @@ -0,0 +1,41 @@ +// ============================================================== +// 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_UTIL_RANDOM_H_ +#define _SHARED_UTIL_RANDOM_H_ + +namespace Shared { namespace Util { + +// ===================================================== +// class RandomGen +// ===================================================== + +class RandomGen { +private: + static const int m; + static const int a; + static const int b; + +private: + int lastNumber; + +public: + RandomGen(); + void init(int seed); + + int rand(); + int randRange(int min, int max); + float randRange(float min, float max); +}; + +}}//end namespace + +#endif diff --git a/source/shared_lib/sources/graphics/pixmap.cpp b/source/shared_lib/sources/graphics/pixmap.cpp index b564e6e7..6eea0427 100644 --- a/source/shared_lib/sources/graphics/pixmap.cpp +++ b/source/shared_lib/sources/graphics/pixmap.cpp @@ -18,7 +18,7 @@ #include "util.h" #include "math_util.h" -#include "random.h" +#include "randomgen.h" #include "FileReader.h" #include "ImageReaders.h" @@ -631,7 +631,7 @@ float splatDist(Vec2i a, Vec2i b){ void Pixmap2D::splat(const Pixmap2D *leftUp, const Pixmap2D *rightUp, const Pixmap2D *leftDown, const Pixmap2D *rightDown){ - Random random; + RandomGen random; assert(components==3 || components==4); diff --git a/source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp b/source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp index 7916c6bb..bbfe51b5 100644 --- a/source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp +++ b/source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp @@ -12,7 +12,7 @@ #include "sound_player_ds8.h" #include -//#include +#include //#include "streflop.h" #include "util.h" diff --git a/source/shared_lib/sources/util/randomgen.cpp b/source/shared_lib/sources/util/randomgen.cpp new file mode 100644 index 00000000..c26dc8b1 --- /dev/null +++ b/source/shared_lib/sources/util/randomgen.cpp @@ -0,0 +1,45 @@ +#include "randomgen.h" +#include + +#include "leak_dumper.h" + +namespace Shared { namespace Util { + +// ===================================================== +// class RandomGen +// ===================================================== + +const int RandomGen::m= 714025; +const int RandomGen::a= 1366; +const int RandomGen::b= 150889; + +RandomGen::RandomGen(){ + lastNumber= 0; +} + +void RandomGen::init(int seed){ + lastNumber= seed % m; +} + +int RandomGen::rand(){ + lastNumber= (a*lastNumber + b) % m; + return lastNumber; +} + +int RandomGen::randRange(int min, int max){ + assert(min<=max); + int diff= max-min; + int res= min + static_cast(static_cast(diff+1)*RandomGen::rand() / m); + assert(res>=min && res<=max); + return res; +} + +float RandomGen::randRange(float min, float max){ + assert(min<=max); + float rand01= static_cast(RandomGen::rand())/(m-1); + float res= min+(max-min)*rand01; + assert(res>=min && res<=max); + return res; +} + +}}//end namespace