View Full Version : Compiling prbs woth original files - what's wrong?


Duke176
Nov 28, 2006, 07:50 PM
hello,
I have a question about compliling sdk files.

I made a minor mod to base files:
- added an "iCostant" to xml unit infos
- modified cvinfo.cpp/.h; cvunit.cpp/h;cyinterface1.cpp; cyunit.cpp/h and cyinterface1.cpp

the change (part of a dev project) just verify if a function that lower player gold of the "iCostant" ammount when a unit moves works.

I never touched cvgroupselection.cpp but while I'm compliling to see if it works the compiler find a bug in that file - I never touched it.
Here is a shoot to give oyu an idea.


I cannot really get the wrong change I made - all other modded files are complied without any prb.

Thx.

Duke176
Nov 29, 2006, 06:58 AM
little add on to help my helpers:

in CyInfoInterface1.cpp
.def("getMinAreaSize", &CvUnitInfo::getMinAreaSize, "int ()")
.def("getMoves", &CvUnitInfo::getMoves, "int ()")
//------------------------------ MIO OIL COST -------------------------------
.def("getOilCostPerMove", &CvUnitInfo::getOilCostPerMove, "int ()")
//---------------------------------------- end -------------------------------------
.def("getAirRange", &CvUnitInfo::getAirRange, "int ()")
.def("getNukeRange", &CvUnitInfo::getNukeRange, "int ()")

in CyUnitInterface1.cpp
.def("maxMoves", &CyUnit::maxMoves, "int ()")
.def("canMove", &CyUnit::canMove, "bool ()")
.def("hasMoved", &CyUnit::hasMoved, "bool ()")
//------------------------------------- MIO OIL COST --------------------------------------------------
.def("oilCostPerMove", &CyUnit::oilCostPerMove, "int ()")
//--------------------------------------------- end ----------------------------------------------------------
.def("airRange", &CyUnit::airRange, "int ()")
.def("nukeRange", &CyUnit::nukeRange, "int ()")

in CyUnit.h
bool canMove();
bool hasMoved();
//------------------------------ MIO OIL COST -----------------------
int oilCostPerMove();
//------------------------------------- end -------------------------------
int airRange();
int nukeRange();

in CyUnit.cpp
bool CyUnit::hasMoved()
{
return m_pUnit ? m_pUnit->hasMoved() : false;
}

//---------------------------------- MIO OIL COST ---------------------------------
int CyUnit::oilCostPerMove()
{
return m_pUnit ? m_pUnit->oilCostPerMove() : -1;
}
//------------------------------------- end ----------------------------------------------

int CyUnit::airRange()
{
return m_pUnit ? m_pUnit->airRange() : -1;
}


in CvInfos.h
DllExport int getMinAreaSize() const; // Exposed to Python
DllExport int getMoves() const; // Exposed to Python
//---------------- MIO OIL COST -------------------------
DllExport int getOilCostPerMove() const; // Exposed to Python
//--------------------- end -------------------------------------
DllExport int getAirRange() const; // Exposed to Python
DllExport int getNukeRange() const; // Exposed to Python

int m_iMinAreaSize;
int m_iMoves;
//--------------- MIO OIL COST --------------------
int m_iOilCostPerMove;
//-------------------- end ------------------------------
int m_iAirRange;

in CvInfos.cpp
m_iMoves(0),
//----------------------- MIO OIL COST ------------------
m_iOilCostPerMove(0),
//-------------------------- end -------------------------------
m_iAirRange(0),

int CvUnitInfo::getMoves() const
{
return m_iMoves;
}

//------------------------- MIO OIL COST ------------------------
int CvUnitInfo::getOilCostPerMove() const
{
return m_iOilCostPerMove;
}
//--------------------------- end --------------------------------------

int CvUnitInfo::getAirRange() const
{
return m_iAirRange;
}

stream->Read(&m_iMoves);
//--------------- MIO OIL COST -------------------------
stream->Read(&m_iOilCostPerMove);
//--------------------- end ---------------------------------
stream->Read(&m_iAirRange);

stream->Write(m_iMoves);
//--------------------- MIO OIL COST -------------------------
stream->Write(m_iOilCostPerMove);
//------------------------------ end -------------------------------
stream->Write(m_iAirRange);

pXML->GetChildXmlValByName(&m_iMinAreaSize, "iMinAreaSize");
pXML->GetChildXmlValByName(&m_iMoves, "iMoves");
//------------------------- MIO OIL COST -----------------------------------
pXML->GetChildXmlValByName(&m_iOilCostPerMove, "iOilCostPerMove");
//------------------------------------- end ---------------------------------------
pXML->GetChildXmlValByName(&m_iAirRange, "iAirRange");
pXML->GetChildXmlValByName(&m_iNukeRange, "iNukeRange");

CvUnit.h
DllExport bool canMove() const; // Exposed to Python
DllExport bool hasMoved() const; // Exposed to Python
//----------------------------------- MIO OIL COST -----------------------------------

DllExport int oilCostPerMove() const; // Exposed to Python //--------------------------------------end-------------------------------------------------

DllExport int airRange() const; // Exposed to Python
DllExport int nukeRange() const; // Exposed to Python

in CvUnit.cpp
void CvUnit::attack(CvPlot* pPlot, bool bQuick)
{
FAssert(canMoveInto(pPlot, true));
FAssert(getCombatTimer() == 0);

setAttackPlot(pPlot);

updateCombat(bQuick);
}


//---------------------------------- MIO OIL COST ------------------------------------I get this here to decleare the function that recalls the row after
int CvUnit::oilCostPerMove() const
{
return GC.getUnitInfo(getUnitType()).getOilCostPerMove();
}
//------------------------------------------- end -----------------------------

void CvUnit::move(CvPlot* pPlot, bool bShow)
{
FeatureTypes eFeature;
EffectTypes eEffect;

FAssert(canMoveOrAttackInto(pPlot) || isMadeAttack());

changeMoves(pPlot->movementCost(this, plot()));

setXY(pPlot->getX_INLINE(), pPlot->getY_INLINE(), true, true, (bShow && pPlot->isVisibleToWatchingHuman()));

if (getOwnerINLINE() == GC.getGameINLINE().getActivePlayer())
{
if (!(pPlot->isOwned()))
{
//spawn birds if trees present - JW
eFeature = pPlot->getFeatureType();

if (eFeature != NO_FEATURE)
{
if (GC.getASyncRand().get(100) < GC.getFeatureInfo(eFeature).getEffectProbability() )
{
eEffect = (EffectTypes)GC.getInfoTypeForString(GC.getFeature Info(eFeature).getEffectType());
gDLL->getEngineIFace()->TriggerEffect(eEffect, pPlot->getPoint(), (float)(GC.getASyncRand().get(360)));
gDLL->getInterfaceIFace()->playGeneralSound("AS3D_UN_BIRDS_SCATTER", pPlot->getPoint());
}
}
}
}

gDLL->getEventReporterIFace()->unitMove(pPlot, this);
//------------------------------- MIO OIL COST ------------------------------
GET_PLAYER(getOwnerINLINE()).changeGold(-(oilCostPerMove()));
//------------------------------------- end ----------------------------------------
}


int CvUnit::movesLeft() const
{
return max(0, (maxMoves() - getMoves()));
}

bool CvUnit::canMove() const
{
//----------------------------- MIO OIL COST --------------------------------- look if the cost of movement in oil ammount is higher than total ammount of OIL
if (GET_PLAYER(getOwnerINLINE()).getGold() < oilCostPerMove())
{
return false;
}
//------------------------------------------------- end ------------------------------
return (getMoves() < maxMoves());
}

bool CvUnit::hasMoved() const
{
return (getMoves() > 0);
}



THAT'S ALL.
Anyone can help me??? :cry:

iOilCostPerMove - is also in CvUnit.xml, CvUnitSchema.xml as

in CvUnit.xml - under UNITCLASS_MECHANIZED_INFANTRY
<iMinAreaSize>-1</iMinAreaSize>
<iMoves>2</iMoves>
<!-- MIO OIL COST -->
<iOilCostPerMove>1</iOilCostPerMove>
<!-- end -->
<iAirRange>0</iAirRange>

in CvUnitSchema.xml
<ElementType name="iMinAreaSize" content="textOnly" dt:type="int"/>
<ElementType name="iMoves" content="textOnly" dt:type="int"/>
<!-- COSTO PER MOVE MOD -->
<ElementType name="iOilCostPerMove" content="textOnly" dt:type="int"/>
<!-- end -->
<ElementType name="iAirRange" content="textOnly" dt:type="int"/>
<ElementType name="iNukeRange" content="textOnly" dt:type="int"/>

<element type="iMinAreaSize"/>
<element type="iMoves"/>
<!-- MIO OIL COST -->
<element type="iOilCostPerMove" minOccurs="0"/>
<!-- end -->
<element type="iAirRange"/>
<element type="iNukeRange"/>

Duke176
Nov 30, 2006, 02:18 AM
bump...
sorry but I really need someone to check what's wrong or I cannot go on with work.

Gyathaar
Nov 30, 2006, 02:22 AM
My guess is you somehow got some SDK code from v2.00 and v2.08 mixed up..

The extra 5th agument (the last false) was added in 2.08 .. you would get that compile bug if you still have the v2.00 version of cvUnit.cpp

Duke176
Nov 30, 2006, 02:28 AM
I'll check and I'll try. Thx for answer anyway it's a sort of light at the end of a dark tunnel :)

Gyathaar
Nov 30, 2006, 02:38 AM
it could be v2.00 version of cvUnit.h too I guess

Gyathaar
Nov 30, 2006, 02:58 AM
btw.. unless you plan to add functions to change the oilconsumption for individual units i runtime, then storing the value in the savefile is not that useful

talking about
stream->Read(&m_iOilCostPerMove);

and
stream->Write(m_iOilCostPerMove);

Duke176
Nov 30, 2006, 04:00 AM
well to be complitely honest I was thinking to work a bit over OilConsumption for different kind of terrains - for ex. moving over hills or throw forest would consume doubble of oil... - but I wanted to understand how much hard it could be before.

Anyway, the next big step (for me - new to SDK) will be to create a counter for Oil similar to the "gold" one and show it under the culture ticker top left of the screen.

here is the full explanation of my project development:
http://forums.civfanatics.com/showthread.php?t=194293

Thx again for help :D :D :D :D :D

Duke176
Nov 30, 2006, 06:39 AM
IT WORKED GREATLY THX!!!!!!!!!!!!!! :D:D:D:D:D
now it compiles without no problems.