1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

- Fixed GCC warning

- Small refactoring
- Added RPM spec to SVN again (it's better to keep it there :) )
This commit is contained in:
beegee1 2013-08-19 18:20:11 +00:00
parent 5654fef901
commit a13d72b636
9 changed files with 116 additions and 31 deletions

View File

@ -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

View File

@ -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)

View File

@ -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<CMap> CMapGenerator::generate()
std::unique_ptr<CMap> 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<CMap>();
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<int>(mapGenOptions.getPlayerCount()) %
static_cast<int>(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<int>(mapGenOptions->getPlayerCount()) %
static_cast<int>(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;

View File

@ -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<CMap> generate();
std::unique_ptr<CMap> 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<CMap> map;
CRandomGenerator gen;
int randomSeed;

View File

@ -12,7 +12,7 @@
#include "StdInc.h"
#include "CZoneGraphGenerator.h"
CZoneCell::CZoneCell(CRmgTemplateZone * zone) : zone(zone)
CZoneCell::CZoneCell(const CRmgTemplateZone * zone) : zone(zone)
{
}

View File

@ -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
};

View File

@ -14,7 +14,7 @@
#include "CZoneGraphGenerator.h"
CPlacedZone::CPlacedZone(CRmgTemplateZone * zone) : zone(zone)
CPlacedZone::CPlacedZone(const CRmgTemplateZone * zone) : zone(zone)
{
}

View File

@ -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...

81
rpm/vcmi.spec Normal file
View File

@ -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