1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

- gcc/Linux fixes

- added --nointro parameter to skip intro videos
- minor fixes to scenario selection menu
This commit is contained in:
Ivan Savenko
2011-03-19 22:27:05 +00:00
parent 7b9e77f899
commit 7209f158a1
14 changed files with 96 additions and 52 deletions

View File

@@ -195,7 +195,8 @@ int main(int argc, char** argv)
opts.add_options()
("help,h", "display help and exit")
("version,v", "display version information and exit")
("battle,b", po::value<std::string>(), "runs game in duel mode (battle-only");
("battle,b", po::value<std::string>(), "runs game in duel mode (battle-only")
("nointro,i", "skips intro movies");
po::variables_map vm;
if(argc > 1)
@@ -261,7 +262,7 @@ int main(int argc, char** argv)
//we can properly play intro only in the main thread, so we have to move loading to the separate thread
boost::thread loading(init);
if(!vm.count("battle"))
if(!vm.count("battle") && !vm.count("nointro"))
playIntro();
SDL_FillRect(screen,NULL,0);

View File

@@ -610,7 +610,8 @@ void ComponentsToBlit::blitCompsOnSur( SDL_Surface * _or, int inter, int &curh,
{
totalw += (inter) * ((comps)[i].size() - 1);
}
int startHeight = curh;
int middleh = curh + maxh/2;//axis for image aligment
int curw = (ret->w/2)-(totalw/2);
@@ -620,14 +621,14 @@ void ComponentsToBlit::blitCompsOnSur( SDL_Surface * _or, int inter, int &curh,
//blit img
int imgX = curw + ( cur->comp->pos.w - cur->comp->getImg()->w ) / 2;
int imgY = middleh - cur->comp->getImg()->h / 2;
int imgY = startHeight;
blitAt(cur->img, imgX, imgY, ret);
cur->comp->pos.x = imgX;
cur->comp->pos.y = imgY;
//blit subtitle
int textX = imgX + cur->comp->getImg()->w/2;
int textY = middleh + cur->comp->getImg()->h /2 + COMPONENT_TO_SUBTITLE;
int textY = startHeight + cur->comp->getImg()->h + COMPONENT_TO_SUBTITLE;
CMessage::blitTextOnSur(cur->txt, cur->txtFontHeight, textY, ret, textX );
//if there is subsequent component blit "or"

View File

@@ -2838,16 +2838,21 @@ void CBonusSelection::updateBonusSelection()
//prim skill - PSKILBON.DEF
//sec skill - SSKILBON.DEF
//resource - BORES.DEF
//player - ?
//hero -?
//player - CREST58.DEF
//hero - PORTRAITSLARGE (HPL###.BMPs)
const CCampaignScenario &scenario = ourCampaign->camp->scenarios[sInfo.whichMapInCampaign];
const std::vector<CScenarioTravel::STravelBonus> & bonDescs = scenario.travelOptions.bonusesToChoose;
bonuses->buttons.clear();
for (size_t i=0; i<bonuses->buttons.size(); i++)
{
BLOCK_CAPTURING;
if (bonuses->buttons[i]->active)
bonuses->buttons[i]->deactivate();
bonuses->delChild(bonuses->buttons[i]);
}
bonuses->buttons.clear();
static const char *bonusPics[] = {"SPELLBON.DEF", "TWCRPORT.DEF", "", "ARTIFBON.DEF", "SPELLBON.DEF",
"PSKILBON.DEF", "SSKILBON.DEF", "BORES.DEF", "CREST58.DEF", "HPL000KN"};
"PSKILBON.DEF", "SSKILBON.DEF", "BORES.DEF", "CREST58.DEF", "PORTRAITSLARGE"};
for(int i = 0; i < bonDescs.size(); i++)
{
@@ -2882,8 +2887,13 @@ void CBonusSelection::updateBonusSelection()
}
assert(faction != -1);
picName = graphics->ERMUtoPicture[faction][CBuildingHandler::campToERMU(bonDescs[i].info1, faction, std::set<si32>())];
int buildID = CBuildingHandler::campToERMU(bonDescs[i].info1, faction, std::set<si32>());
picName = graphics->ERMUtoPicture[faction][buildID];
picNumber = -1;
tlog1<<CGI->buildh->buildings.size()<<"\t"<<faction<<"\t"<<CGI->buildh->buildings[faction].size()<<"\t"<<buildID<<"\n";
if (vstd::contains(CGI->buildh->buildings[faction], buildID))
desc = CGI->buildh->buildings[faction].find(buildID)->second->Description();
}
break;
case 3: //artifact
@@ -2981,33 +2991,31 @@ void CBonusSelection::updateBonusSelection()
if (bonDescs[i].info2 == 0xFFFF)
{
boost::algorithm::replace_first(desc, "%s", CGI->heroh->heroes[0]->name); //hero's name
//surfToDuplicate = graphics->portraitLarge[0];
//TODO: re-enable - need to get filename or CAnimation with heroes pics
picNumber = 0;
}
else
{
boost::algorithm::replace_first(desc, "%s", CGI->heroh->heroes[bonDescs[i].info2]->name); //hero's name
//surfToDuplicate = graphics->portraitLarge[bonDescs[i].info2];
}
picNumber = -1;
break;
}
bonuses->addButton(new CHighlightableButton(desc, desc, 0, 475 + i*68, 455, "", i));
//create separate surface with yellow border
if (picNumber != -1)
picName += ":" + boost::lexical_cast<std::string>(picNumber);
CAnimation * anim = new CAnimation();
anim->setCustom(picName, 0);
anim->setCustom("TWCRPORT:1", 1);
anim->setCustom("TWCRPORT:1", 1);//create separate surface with yellow border
bonuses->buttons.back()->setImage(anim);
//FIXME: use show base
}
}
if (active)
for (size_t i=0; i<bonuses->buttons.size(); i++)
bonuses->buttons[i]->activate();
if (bonuses->buttons.size() > 0)
{
bonuses->select(0, 0);
@@ -3101,6 +3109,7 @@ void CBonusSelection::CRegion::clickLeft( tribool down, bool previousState )
{
owner->selectMap(myNumber);
owner->highlightedRegion = this;
parent->showAll(screen);
}
}

View File

@@ -5,7 +5,7 @@
#include <SDL.h>
#include "../client/SDL_Extensions.h"
#include "../client/CPlayerInterface.h"
#include "boost\filesystem.hpp"
#include "boost/filesystem.hpp"
extern SystemOptions GDefaultOptions;
//reads events and returns true on key down
@@ -800,8 +800,7 @@ bool CVideoPlayer::nextFrame()
// Is this a packet from the video stream?
if (packet.stream_index == stream) {
// Decode video frame
avcodec_decode_video(codecContext, frame, &frameFinished,
packet.data, packet.size);
avcodec_decode_video2(codecContext, frame, &frameFinished, &packet);
// Did we get a video frame?
if (frameFinished) {

View File

@@ -722,6 +722,17 @@ const Rect & CIntObject::center(const Point &p, bool propagate /*= true*/)
return pos;
}
void CIntObject::fitToScreen(int borderWidth, bool propagate)
{
Point newPos = pos.topLeft();
amax(newPos.x, borderWidth);
amax(newPos.y, borderWidth);
amin(newPos.x, screen->w - borderWidth - pos.w);
amin(newPos.y, screen->h - borderWidth - pos.h);
if (newPos != pos.topLeft())
moveTo(newPos, propagate);
}
void CIntObject::moveBy( const Point &p, bool propagate /*= true*/ )
{
pos.x += p.x;
@@ -889,11 +900,17 @@ void CPicture::createSimpleRect(const Rect &r, bool screenFormat, ui32 color)
}
void CPicture::colorizeAndConvert(int player)
{
assert(bg);
colorize(player);
convertToScreenBPP();
}
void CPicture::colorize(int player)
{
assert(bg);
assert(bg->format->BitsPerPixel == 8);
graphics->blueToPlayersAdv(bg, player);
convertToScreenBPP();
}
ObjectConstruction::ObjectConstruction( CIntObject *obj )

View File

@@ -421,6 +421,7 @@ public:
const Rect & center(const Rect &r, bool propagate = true); //sets pos so that r will be in the center of screen, assigns sizes of r to pos, returns new position
const Rect & center(const Point &p, bool propagate = true); //moves object so that point p will be in its center
const Rect & center(bool propagate = true); //centers when pos.w and pos.h are set, returns new position
void fitToScreen(int borderWidth, bool propagate = true); //moves window to fit into screen
void moveBy(const Point &p, bool propagate = true);
void moveTo(const Point &p, bool propagate = true);
void changeUsedEvents(ui16 what, bool enable, bool adjust = true);
@@ -503,6 +504,7 @@ public:
void showAll(SDL_Surface * to);
void convertToScreenBPP();
void colorizeAndConvert(int player);
void colorize(int player);
};
/// Handles GUI logic and drawing

View File

@@ -618,6 +618,7 @@ void CRClickPopup::createAndPush(const std::string &txt, const CInfoWindow::TCom
CSimpleWindow * temp = new CInfoWindow(txt, player, comps);
temp->center(Point(GH.current->motion)); //center on mouse
temp->fitToScreen(10);
CRClickPopupInt *rcpi = new CRClickPopupInt(temp,true);
GH.pushInt(rcpi);
}
@@ -1727,8 +1728,8 @@ void CRecruitmentWindow::clickLeft(tribool down, bool previousState)
{
for(int i=0;i<creatures.size();i++)
{
const int sCREATURE_WIDTH = CREATURE_WIDTH; // gcc -O0 workaround
if(isItIn(&(Rect(creatures[i].pos) + pos),GH.current->motion.x,GH.current->motion.y))
Rect creaPos = pos + creatures[i].pos;
if(isItIn(&creaPos, GH.current->motion.x, GH.current->motion.y))
{
which = i;
int newAmount = std::min(amounts[i],creatures[i].amount);
@@ -5294,7 +5295,7 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation &src, const Artifact
}
else if(src.slot >= Arts::BACKPACK_START && src.slot < commonInfo->src.slotID && src.hero == commonInfo->src.AOH->curHero) //artifact taken from before currently picked one
{
int fixedSlot = src.hero->getArtPos(commonInfo->src.art);
//int fixedSlot = src.hero->getArtPos(commonInfo->src.art);
commonInfo->src.slotID--;
assert(commonInfo->src.valid());
updateParentWindow();
@@ -5313,8 +5314,8 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation &src, const Artifact
if(dst.slot < Arts::BACKPACK_START && src.slot - Arts::BACKPACK_START < backpackPos)
shift--;
if( src.hero == curHero && src.slot >= Arts::BACKPACK_START
|| dst.hero == curHero && dst.slot >= Arts::BACKPACK_START)
if( (src.hero == curHero && src.slot >= Arts::BACKPACK_START)
|| (dst.hero == curHero && dst.slot >= Arts::BACKPACK_START) )
scrollBackpack(shift); //update backpack slots
}

2
configure vendored
View File

@@ -14501,7 +14501,7 @@ if test "x$GXX" = "xyes" -a "x$enable_debug" = "xyes" ; then
CXXFLAGS="-O0 -ggdb"
fi
if test "x$GXX" = "xyes" ; then
if test "x$GXX" = "xyes" ; then
CXXFLAGS="$CXXFLAGS -Wall -Wno-switch -Wno-sign-compare -Wcast-align -Wpointer-arith -Wno-unknown-pragmas"
fi

View File

@@ -29,7 +29,7 @@ if test "x$GXX" = "xyes" -a "x$enable_debug" = "xyes" ; then
fi
if test "x$GXX" = "xyes" ; then
CXXFLAGS="$CXXFLAGS -Wall -Wno-switch -Wno-sign-compare -Wcast-align -Wpointer-arith"
CXXFLAGS="$CXXFLAGS -Wall -Wno-switch -Wno-sign-compare -Wcast-align -Wpointer-arith -Wno-unknown-pragmas"
fi
# For clang only. Need an autoconf test.

View File

@@ -17,7 +17,7 @@ ERMParser::ERMParser(std::string file)
void ERMParser::parseFile()
{
std::ifstream file(srcFile);
std::ifstream file(srcFile.c_str());
if(!file.is_open())
{
tlog1 << "File " << srcFile << " not found or unable to open\n";

View File

@@ -38,6 +38,8 @@ libvcmi_la_SOURCES = \
CSpellHandler.h \
CTownHandler.cpp \
CTownHandler.h \
ERMParser.cpp \
ERMParser.h \
HeroBonus.cpp \
HeroBonus.h \
IGameCallback.cpp \

View File

@@ -87,9 +87,10 @@ am_libvcmi_la_OBJECTS = libvcmi_la-BattleAction.lo \
libvcmi_la-CLodHandler.lo libvcmi_la-CMapInfo.lo \
libvcmi_la-CObjectHandler.lo libvcmi_la-Connection.lo \
libvcmi_la-CSpellHandler.lo libvcmi_la-CTownHandler.lo \
libvcmi_la-HeroBonus.lo libvcmi_la-IGameCallback.lo \
libvcmi_la-map.lo libvcmi_la-NetPacksLib.lo \
libvcmi_la-RegisterTypes.lo libvcmi_la-VCMI_Lib.lo
libvcmi_la-ERMParser.lo libvcmi_la-HeroBonus.lo \
libvcmi_la-IGameCallback.lo libvcmi_la-map.lo \
libvcmi_la-NetPacksLib.lo libvcmi_la-RegisterTypes.lo \
libvcmi_la-VCMI_Lib.lo
libvcmi_la_OBJECTS = $(am_libvcmi_la_OBJECTS)
AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
@@ -313,6 +314,8 @@ libvcmi_la_SOURCES = \
CSpellHandler.h \
CTownHandler.cpp \
CTownHandler.h \
ERMParser.cpp \
ERMParser.h \
HeroBonus.cpp \
HeroBonus.h \
IGameCallback.cpp \
@@ -418,6 +421,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CSpellHandler.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-CTownHandler.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-Connection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-ERMParser.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-HeroBonus.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-IGameCallback.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvcmi_la-NetPacksLib.Plo@am__quote@
@@ -585,6 +589,14 @@ libvcmi_la-CTownHandler.lo: CTownHandler.cpp
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -c -o libvcmi_la-CTownHandler.lo `test -f 'CTownHandler.cpp' || echo '$(srcdir)/'`CTownHandler.cpp
libvcmi_la-ERMParser.lo: ERMParser.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -MT libvcmi_la-ERMParser.lo -MD -MP -MF $(DEPDIR)/libvcmi_la-ERMParser.Tpo -c -o libvcmi_la-ERMParser.lo `test -f 'ERMParser.cpp' || echo '$(srcdir)/'`ERMParser.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libvcmi_la-ERMParser.Tpo $(DEPDIR)/libvcmi_la-ERMParser.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='ERMParser.cpp' object='libvcmi_la-ERMParser.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -c -o libvcmi_la-ERMParser.lo `test -f 'ERMParser.cpp' || echo '$(srcdir)/'`ERMParser.cpp
libvcmi_la-HeroBonus.lo: HeroBonus.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libvcmi_la_CXXFLAGS) $(CXXFLAGS) -MT libvcmi_la-HeroBonus.lo -MD -MP -MF $(DEPDIR)/libvcmi_la-HeroBonus.Tpo -c -o libvcmi_la-HeroBonus.lo `test -f 'HeroBonus.cpp' || echo '$(srcdir)/'`HeroBonus.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libvcmi_la-HeroBonus.Tpo $(DEPDIR)/libvcmi_la-HeroBonus.Plo

View File

@@ -58,7 +58,7 @@ DLL_EXPORT void initDLL(CConsoleHandler *Console, std::ostream *Logfile)
using namespace boost::filesystem;
//parser checking
directory_iterator enddir;
for (directory_iterator dir("Data/s"); dir!=enddir; dir++)
for (directory_iterator dir(DATA_DIR "/Data/s"); dir!=enddir; dir++)
{
if(is_regular(dir->status()))
{

View File

@@ -1212,23 +1212,23 @@ void CGameHandler::run(bool resume)
boost::this_thread::sleep(boost::posix_time::milliseconds(5)); //give time client to close socket
}
namespace CGH
{
using namespace std;
static void readItTo(ifstream & input, vector< vector<int> > & dest) //reads 7 lines, i-th one containing i integers, and puts it to dest
{
for(int j=0; j<7; ++j)
{
std::vector<int> pom;
for(int g=0; g<j+1; ++g)
{
int hlp; input>>hlp;
pom.push_back(hlp);
}
dest.push_back(pom);
}
}
}
//namespace CGH
//{
// using namespace std;
// static void readItTo(ifstream & input, vector< vector<int> > & dest) //reads 7 lines, i-th one containing i integers, and puts it to dest
// {
// for(int j=0; j<7; ++j)
// {
// std::vector<int> pom;
// for(int g=0; g<j+1; ++g)
// {
// int hlp; input>>hlp;
// pom.push_back(hlp);
// }
// dest.push_back(pom);
// }
// }
//}
void CGameHandler::setupBattle( int3 tile, const CArmedInstance *armies[2], const CGHeroInstance *heroes[2], bool creatureBank, const CGTownInstance *town )
{