From a13d72b63673528139bc1790169a5b1482bf7a09 Mon Sep 17 00:00:00 2001 From: beegee1 Date: Mon, 19 Aug 2013 18:20:11 +0000 Subject: [PATCH] - Fixed GCC warning - Small refactoring - Added RPM spec to SVN again (it's better to keep it there :) ) --- CMakeLists.txt | 5 +- lib/CGameState.cpp | 4 +- lib/rmg/CMapGenerator.cpp | 39 ++++++++-------- lib/rmg/CMapGenerator.h | 6 +-- lib/rmg/CZoneGraphGenerator.cpp | 2 +- lib/rmg/CZoneGraphGenerator.h | 4 +- lib/rmg/CZonePlacer.cpp | 2 +- lib/rmg/CZonePlacer.h | 4 +- rpm/vcmi.spec | 81 +++++++++++++++++++++++++++++++++ 9 files changed, 116 insertions(+), 31 deletions(-) create mode 100644 rpm/vcmi.spec diff --git a/CMakeLists.txt b/CMakeLists.txt index f187994c6..772db4919 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,7 +90,10 @@ if(NOT WIN32) endif() if(CMAKE_COMPILER_IS_GNUCXX OR NOT WIN32) #so far all *nix compilers support such parameters - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra -Wpointer-arith -Wno-switch -Wno-sign-compare -Wno-unused-parameter -Wno-overloaded-virtual -Wno-mismatched-tags") + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(CLANG_SPECIFIC_FLAGS "-Wno-mismatched-tags") + endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra -Wpointer-arith -Wno-switch -Wno-sign-compare -Wno-unused-parameter -Wno-overloaded-virtual ${CLANG_SPECIFIC_FLAGS}") endif() if(WIN32) # on Win everything goes into H3 root directory diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index db1912de4..004200bcf 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -867,8 +867,8 @@ void CGameState::init(StartInfo * si) CStopWatch sw; // Gen map - CMapGenerator mapGen(*(scenarioOps->mapGenOptions), scenarioOps->seedToBeUsed); - map = mapGen.generate().release(); + CMapGenerator mapGenerator; + map = mapGenerator.generate(scenarioOps->mapGenOptions.get(), scenarioOps->seedToBeUsed).release(); // Update starting options for(int i = 0; i < map->players.size(); ++i) diff --git a/lib/rmg/CMapGenerator.cpp b/lib/rmg/CMapGenerator.cpp index d557e76af..0821eabec 100644 --- a/lib/rmg/CMapGenerator.cpp +++ b/lib/rmg/CMapGenerator.cpp @@ -22,10 +22,9 @@ #include "../StringConstants.h" #include "CRmgTemplate.h" -CMapGenerator::CMapGenerator(const CMapGenOptions & mapGenOptions, int randomSeed /*= std::time(nullptr)*/) : - mapGenOptions(mapGenOptions), randomSeed(randomSeed) +CMapGenerator::CMapGenerator() { - gen.seed(randomSeed); + } CMapGenerator::~CMapGenerator() @@ -33,9 +32,11 @@ CMapGenerator::~CMapGenerator() } -std::unique_ptr CMapGenerator::generate() +std::unique_ptr CMapGenerator::generate(CMapGenOptions * mapGenOptions, int randomSeed /*= std::time(nullptr)*/) { - mapGenOptions.finalize(gen); + gen.seed(randomSeed); + this->mapGenOptions = mapGenOptions; + this->mapGenOptions->finalize(gen); map = make_unique(); editManager = map->getEditManager(); @@ -55,12 +56,12 @@ std::string CMapGenerator::getMapDescription() const std::stringstream ss; ss << boost::str(boost::format(std::string("Map created by the Random Map Generator.\nTemplate was %s, Random seed was %d, size %dx%d") + - ", levels %s, humans %d, computers %d, water %s, monster %s, second expansion map") % mapGenOptions.getMapTemplate()->getName() % - randomSeed % map->width % map->height % (map->twoLevel ? "2" : "1") % static_cast(mapGenOptions.getPlayerCount()) % - static_cast(mapGenOptions.getCompOnlyPlayerCount()) % waterContentStr[mapGenOptions.getWaterContent()] % - monsterStrengthStr[mapGenOptions.getMonsterStrength()]); + ", levels %s, humans %d, computers %d, water %s, monster %s, second expansion map") % mapGenOptions->getMapTemplate()->getName() % + randomSeed % map->width % map->height % (map->twoLevel ? "2" : "1") % static_cast(mapGenOptions->getPlayerCount()) % + static_cast(mapGenOptions->getCompOnlyPlayerCount()) % waterContentStr[mapGenOptions->getWaterContent()] % + monsterStrengthStr[mapGenOptions->getMonsterStrength()]); - for(const auto & pair : mapGenOptions.getPlayersSettings()) + for(const auto & pair : mapGenOptions->getPlayersSettings()) { const auto & pSettings = pair.second; if(pSettings.getPlayerType() == EPlayerType::HUMAN) @@ -84,8 +85,8 @@ void CMapGenerator::addPlayerInfo() int teamOffset = 0; for(int i = 0; i < 2; ++i) { - int playerCount = i == 0 ? mapGenOptions.getPlayerCount() : mapGenOptions.getCompOnlyPlayerCount(); - int teamCount = i == 0 ? mapGenOptions.getTeamCount() : mapGenOptions.getCompOnlyTeamCount(); + int playerCount = i == 0 ? mapGenOptions->getPlayerCount() : mapGenOptions->getCompOnlyPlayerCount(); + int teamCount = i == 0 ? mapGenOptions->getTeamCount() : mapGenOptions->getCompOnlyTeamCount(); if(playerCount == 0) { @@ -113,7 +114,7 @@ void CMapGenerator::addPlayerInfo() } // Team numbers are assigned randomly to every player - for(const auto & pair : mapGenOptions.getPlayersSettings()) + for(const auto & pair : mapGenOptions->getPlayersSettings()) { const auto & pSettings = pair.second; PlayerInfo player; @@ -129,8 +130,8 @@ void CMapGenerator::addPlayerInfo() map->players[pSettings.getColor().getNum()] = player; } - map->howManyTeams = (mapGenOptions.getTeamCount() == 0 ? mapGenOptions.getPlayerCount() : mapGenOptions.getTeamCount()) - + (mapGenOptions.getCompOnlyTeamCount() == 0 ? mapGenOptions.getCompOnlyPlayerCount() : mapGenOptions.getCompOnlyTeamCount()); + map->howManyTeams = (mapGenOptions->getTeamCount() == 0 ? mapGenOptions->getPlayerCount() : mapGenOptions->getTeamCount()) + + (mapGenOptions->getCompOnlyTeamCount() == 0 ? mapGenOptions->getCompOnlyPlayerCount() : mapGenOptions->getCompOnlyTeamCount()); } void CMapGenerator::genTerrain() @@ -155,7 +156,7 @@ void CMapGenerator::genTowns() int side = i % 2; auto town = new CGTownInstance(); town->ID = Obj::TOWN; - int townId = mapGenOptions.getPlayersSettings().find(PlayerColor(i))->second.getStartingTown(); + int townId = mapGenOptions->getPlayersSettings().find(PlayerColor(i))->second.getStartingTown(); if(townId == CMapGenOptions::CPlayerSettings::RANDOM_TOWN) townId = gen.getInteger(0, 8); // Default towns town->subID = townId; town->tempOwner = owner; @@ -176,9 +177,9 @@ void CMapGenerator::genTowns() void CMapGenerator::addHeaderInfo() { map->version = EMapFormat::SOD; - map->width = mapGenOptions.getWidth(); - map->height = mapGenOptions.getHeight(); - map->twoLevel = mapGenOptions.getHasTwoLevels(); + map->width = mapGenOptions->getWidth(); + map->height = mapGenOptions->getHeight(); + map->twoLevel = mapGenOptions->getHasTwoLevels(); map->name = VLC->generaltexth->allTexts[740]; map->description = getMapDescription(); map->difficulty = 1; diff --git a/lib/rmg/CMapGenerator.h b/lib/rmg/CMapGenerator.h index 6d80d3459..eee921b32 100644 --- a/lib/rmg/CMapGenerator.h +++ b/lib/rmg/CMapGenerator.h @@ -21,10 +21,10 @@ class CMapEditManager; class DLL_LINKAGE CMapGenerator { public: - explicit CMapGenerator(const CMapGenOptions & mapGenOptions, int randomSeed = std::time(nullptr)); + CMapGenerator(); ~CMapGenerator(); // required due to unique_ptr - std::unique_ptr generate(); + std::unique_ptr generate(CMapGenOptions * mapGenOptions, int randomSeed = std::time(nullptr)); private: /// Generation methods @@ -34,7 +34,7 @@ private: void genTerrain(); void genTowns(); - CMapGenOptions mapGenOptions; + CMapGenOptions * mapGenOptions; std::unique_ptr map; CRandomGenerator gen; int randomSeed; diff --git a/lib/rmg/CZoneGraphGenerator.cpp b/lib/rmg/CZoneGraphGenerator.cpp index 6595a504b..2d326eeff 100644 --- a/lib/rmg/CZoneGraphGenerator.cpp +++ b/lib/rmg/CZoneGraphGenerator.cpp @@ -12,7 +12,7 @@ #include "StdInc.h" #include "CZoneGraphGenerator.h" -CZoneCell::CZoneCell(CRmgTemplateZone * zone) : zone(zone) +CZoneCell::CZoneCell(const CRmgTemplateZone * zone) : zone(zone) { } diff --git a/lib/rmg/CZoneGraphGenerator.h b/lib/rmg/CZoneGraphGenerator.h index 2737382a9..6899be869 100644 --- a/lib/rmg/CZoneGraphGenerator.h +++ b/lib/rmg/CZoneGraphGenerator.h @@ -18,10 +18,10 @@ class CMapGenOptions; class CZoneCell { public: - CZoneCell(CRmgTemplateZone * zone); + explicit CZoneCell(const CRmgTemplateZone * zone); private: - CRmgTemplateZone * zone; + const CRmgTemplateZone * zone; //TODO additional data }; diff --git a/lib/rmg/CZonePlacer.cpp b/lib/rmg/CZonePlacer.cpp index e81bdb5f4..438e595bd 100644 --- a/lib/rmg/CZonePlacer.cpp +++ b/lib/rmg/CZonePlacer.cpp @@ -14,7 +14,7 @@ #include "CZoneGraphGenerator.h" -CPlacedZone::CPlacedZone(CRmgTemplateZone * zone) : zone(zone) +CPlacedZone::CPlacedZone(const CRmgTemplateZone * zone) : zone(zone) { } diff --git a/lib/rmg/CZonePlacer.h b/lib/rmg/CZonePlacer.h index 6c6df5510..83f59f9ed 100644 --- a/lib/rmg/CZonePlacer.h +++ b/lib/rmg/CZonePlacer.h @@ -19,10 +19,10 @@ class CRmgTemplateZone; class CPlacedZone { public: - CPlacedZone(CRmgTemplateZone * zone); + explicit CPlacedZone(const CRmgTemplateZone * zone); private: - CRmgTemplateZone * zone; + const CRmgTemplateZone * zone; //TODO exact outline data of zone //TODO perhaps further zone data, guards, obstacles, etc... diff --git a/rpm/vcmi.spec b/rpm/vcmi.spec new file mode 100644 index 000000000..44b96c217 --- /dev/null +++ b/rpm/vcmi.spec @@ -0,0 +1,81 @@ +Summary: VCMI is an open-source project aiming to reimplement HMM3:WoG game engine, giving it new and extended possibilities. +Name: vcmi +Version: 0.9.3 +Release: 1%{?dist} +License: GPLv2+ +Group: Amusements/Games + +# The source for this package was pulled from upstream's vcs. Use the +# following commands to generate the tarball: +# svn export -r HEAD https://vcmi.svn.sourceforge.net/svnroot/vcmi/tags/0.93 vcmi-0.9.3-1 +# tar -cJf vcmi-0.9.3-1.tar.xz vcmi-0.9.3-1 +Source: vcmi-0.9.3-1.tar.xz + +URL: http://forum.vcmi.eu/portal.php +BuildRequires: cmake +BuildRequires: gcc-c++ >= 4.7.2 +BuildRequires: SDL-devel +BuildRequires: SDL_image-devel +BuildRequires: SDL_ttf-devel +BuildRequires: SDL_mixer-devel >= 1.2.8 +BuildRequires: boost >= 1.44 +BuildRequires: boost-devel >= 1.44 +BuildRequires: boost-filesystem >= 1.44 +BuildRequires: boost-iostreams >= 1.44 +BuildRequires: boost-system >= 1.44 +BuildRequires: boost-thread >= 1.44 +BuildRequires: boost-program-options >= 1.44 +BuildRequires: zlib-devel +BuildRequires: ffmpeg-devel +BuildRequires: ffmpeg-libs + +%description +The purpose of VCMI project is to rewrite entire HOMM 3: WoG engine from scratch, giving it new and extended possibilities. We hope to support mods and new towns already made by fans but abandoned because of game code limitations. + +VCMI is fan-made open-source project in progress. We already allow support for maps of any sizes, higher resolutions and extended engine limits. However, although working, the game is not finished. There are still many features and functionalities to add, both old and brand new. + +As yet VCMI is not standalone program, it uses Wake of Gods files and graphics. You need to install WoG before running VCMI. + +%prep +%setup -q -n %{name}-%{version}-1 + +%build +cmake -DCMAKE_INSTALL_PREFIX=/usr ./ +make %{?_smp_mflags} + +%install +rm -rf %{buildroot} +make DESTDIR=%{buildroot} install + +%files +%doc README README.linux COPYING AUTHORS ChangeLog +%{_bindir}/vcmiclient +%{_bindir}/vcmiserver +%{_bindir}/vcmibuilder +%{_libdir}/%{name}/* + +%{_datadir}/%{name}/* +%{_datadir}/applications/* +%{_datadir}/icons/* + +%changelog +* Sun Jun 02 2013 VCMI - 0.9.3-1 +- New upstream release + +* Wed Mar 06 2013 VCMI - 0.9.2-1 +- New upstream release + +* Fri Feb 01 2013 VCMI - 0.9.1-2 +- New upstream release + +* Wed Jan 30 2013 VCMI - 0.9.1-1 +- Development release + +* Sun Oct 21 2012 VCMI - 0.9-2 +- Second release of 0.9, Fixed battles crash + +* Sat Oct 06 2012 VCMI - 0.9-1 +- New upstream release + +* Sun Jun 08 2012 VCMI - 0.89-1 +- Initial version