Seite 55 von 110 ErsteErste ... 54551525354555657585965105 ... LetzteLetzte
Ergebnis 811 bis 825 von 1650

Thema: Bugsammlung

  1. #811
    Civ4 BASE Coder Avatar von rucivfan
    Registriert seit
    10.07.11
    Ort
    Antarktika
    Beiträge
    19.016
    Bei Endlosturn hilft nur eins, debug.dll und den Code anhalten lassen. Dann muss man schauen, wo man ist. Man tastet sich langsam mit breakpoints ran. Das ist ein zeitaufwendiger Fehler. Man muss den Grund auf die Spur kommen, warum es eine Schleife gibt.

    Bei sowas gibt es in der Regel auch keinen verwertbaren Log-Eintrag, weil eben erst beim Ausführen mit Ende Logs geschrieben werden.

  2. #812
    Civ4 BASE Coder Avatar von rucivfan
    Registriert seit
    10.07.11
    Ort
    Antarktika
    Beiträge
    19.016
    Es wäre generell sinnvoll, dass der Mod mal eine Versionierung erhält. Das macht es viel einfacher, wenn man Code und weitere Sachen einer Version Griff bereit hat.

  3. #813
    Registrierter Benutzer Avatar von Builder
    Registriert seit
    05.12.08
    Beiträge
    3.480
    Ich habe jetzt mal Fernglas mit einem Wissi gebulbt. (Werk der Naturwissenschaften) -> Spiel hängt. Jetzt werde ich mal die Forschung umstellen. Getan und neue Runde (Kryptografie erforscht) läuft an.

    Also sind es definitiv die Piras.
    "Vegetarisch" ist indianisch und heißt "zu blöd zum Jagen"

    Bekennender Steam Hasser;)

  4. #814
    Moderator Avatar von Kathy
    Registriert seit
    11.10.07
    Beiträge
    17.019
    Das ist seltsam, denn bei Dead-Eye scheinen sie ja zumindest in der ersten Runde funktioniert zu haben. Aber auszuschließen ist es nicht, denn sie sind ja auch bei ihm die Civ, bei der es nicht weitergeht. Ich muss noch einmal in Ruhe nachdenken, was das Problem bei den Piraten sein könnte, wenn es nicht die Ballistenstellungen sind. Wenn mir nichts einfällt, muss ich wohl ab morgen einmal die debug.dll darüberlaufen lassen.

  5. #815
    Moderator Avatar von Kathy
    Registriert seit
    11.10.07
    Beiträge
    17.019
    Ich habe keine Ahnung, ob das wichtig ist, aber ich frage trotzdem mal: Hattet ihr vor dem Entstehen der Piraten schon einen Schwierigkeitsgradaufstieg? Und speziell Builder: Wenn du mit der fehlerhaften Datei spielst, hängt das Spiel dann eine Runde später trotzdem, oder funktioniert es dann länger stabil?

  6. #816
    Registrierter Benutzer Avatar von Builder
    Registriert seit
    05.12.08
    Beiträge
    3.480
    Ich hab jetzt 3 Runden mit umgestellter Forschung laufen lassen. Solange ich die finger vom Fernglas lasse läuft es stabiel.
    "Vegetarisch" ist indianisch und heißt "zu blöd zum Jagen"

    Bekennender Steam Hasser;)

  7. #817
    Moderator Avatar von Kathy
    Registriert seit
    11.10.07
    Beiträge
    17.019
    Ich meinte eigenltlich: Was passiert, wenn du mit der fehlerhaften Python-Datei "Fernglas" erforschst - wie lange läuft es dann?

    Ich hatte heute Morgen noch einen Einfall, vielleicht komme ich doch noch um die Debug-Dll herum. Emoticon: beten

    Edit: Das war auch nicht das Problem. Bleibt also nur die Debug-Dll
    Geändert von Kathy (13. Dezember 2014 um 12:01 Uhr)

  8. #818
    Registrierter Benutzer Avatar von Builder
    Registriert seit
    05.12.08
    Beiträge
    3.480
    Mit dem Fehler hatte ich nur noch 2 Runden laufen lassen. Falls mehr benötigt wird kann ich die alte Datei teaktiviren. Auffällig ist das es sich auch aufhängt wenn ich die Technik direkt also in der laufenden Runde erhalte. Das deutet für mich darauf hin das der Fehler in den Pratenrutinen ist. Werden die nicht ausgeführt läuft es.

    Zum Test kann der Spielstand dienen den ich hochgelegen habe. Einfach mit dem Wissenschaftler Fernglas holen.
    "Vegetarisch" ist indianisch und heißt "zu blöd zum Jagen"

    Bekennender Steam Hasser;)

  9. #819
    Moderator Avatar von Kathy
    Registriert seit
    11.10.07
    Beiträge
    17.019
    Ich habe nun einen Assert, von dem ich nicht weiß, ob er relevant ist:

    Stack:
    Code:
    >	CvGameCoreDLL.dll!CvCity::updateCommerce(CommerceTypes eIndex=COMMERCE_GOLD)  Zeile 8871 + 0x42 Bytes	C++
     	CvGameCoreDLL.dll!CvCity::updateCommerce()  Zeile 8893	C++
     	CvGameCoreDLL.dll!CvPlayer::updateCommerce()  Zeile 3981	C++
     	CvGameCoreDLL.dll!CvPlayer::setCommercePercent(CommerceTypes eIndex=COMMERCE_RESEARCH, int iNewValue=100)  Zeile 12273	C++
     	CvGameCoreDLL.dll!CvPlayerAI::AI_doCommerce()  Zeile 13446	C++
     	CvGameCoreDLL.dll!CvPlayerAI::AI_doTurnPre()  Zeile 415 + 0x10 Bytes	C++
     	CvGameCoreDLL.dll!CvPlayer::doTurn()  Zeile 3621 + 0xd Bytes	C++
     	CvGameCoreDLL.dll!CvPlayer::setTurnActive(bool bNewValue=false, bool bDoTurn=true)  Zeile 11510	C++
     	CvGameCoreDLL.dll!CvPlayer::setAutoMoves(bool bNewValue=false)  Zeile 11593	C++
     	CvGameCoreDLL.dll!CvGame::updateMoves()  Zeile 6702	C++
     	CvGameCoreDLL.dll!CvGame::update()  Zeile 2093	C++
     	Civ4BeyondSword.exe!00415321() 	
     	[Unten angegebene Rahmen sind möglicherweise nicht korrekt und/oder fehlen, keine Symbole geladen für Civ4BeyondSword.exe]	
     	KernelBase.dll!7605af2b() 	
     	Civ4BeyondSword.exe!004d6f46() 	
     	Civ4BeyondSword.exe!008f497f() 	
     	kernel32.dll!76b5338a() 	
     	ntdll.dll!77229f72() 	
     	ntdll.dll!77229f45() 	
     	Civ4BeyondSword.exe!00790074() 	
     	Civ4BeyondSword.exe!00790074() 	
     	Civ4BeyondSword.exe!0078006f() 	
     	Civ4BeyondSword.exe!0078006f() 	
     	Civ4BeyondSword.exe!0078006f() 	
     	Civ4BeyondSword.exe!0078006f() 	
     	Civ4BeyondSword.exe!0064006e() 	
     	Civ4BeyondSword.exe!0064006e() 	
     	Civ4BeyondSword.exe!0069006c() 	
     	Civ4BeyondSword.exe!0064006e() 	
     	Civ4BeyondSword.exe!0064005f() 	
     	Civ4BeyondSword.exe!0064005f() 	
     	Civ4BeyondSword.exe!0075006c() 	
     	Civ4BeyondSword.exe!0075006c() 	
     	Civ4BeyondSword.exe!0075006c() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0073005f() 	
     	Civ4BeyondSword.exe!0073005f() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064006e() 	
     	Civ4BeyondSword.exe!0064006e() 	
     	Civ4BeyondSword.exe!0064006e() 	
     	Civ4BeyondSword.exe!0064006e()
    Code:
    void CvCity::updateCommerce(CommerceTypes eIndex)
    {
    	int iOldCommerce;
    	int iNewCommerce;
    
    	FAssertMsg(eIndex >= 0, "eIndex expected to be >= 0");
    	FAssertMsg(eIndex < NUM_COMMERCE_TYPES, "eIndex expected to be < NUM_COMMERCE_TYPES");
    
    	iOldCommerce = m_aiCommerceRate[eIndex];
    
    	if (isDisorder())
    	{
    		iNewCommerce = 0;
    	}
    	else
    	{
    		iNewCommerce = (getBaseCommerceRateTimes100(eIndex) * getTotalCommerceRateModifier(eIndex)) / 100;
    		iNewCommerce += getYieldRate(YIELD_PRODUCTION) * getProductionToCommerceModifier(eIndex);
    	}
    
    	if (iOldCommerce != iNewCommerce)
    	{
    		m_aiCommerceRate[eIndex] = iNewCommerce;
    		FAssert(m_aiCommerceRate[eIndex] >= 0);
    
    		GET_PLAYER(getOwnerINLINE()).invalidateCommerceRankCache(eIndex);
    
    		GET_PLAYER(getOwnerINLINE()).changeCommerceRate(eIndex, (iNewCommerce - iOldCommerce));
    
    		if (isCitySelected())
    		{
    			gDLL->getInterfaceIFace()->setDirty(InfoPane_DIRTY_BIT, true );
    			gDLL->getInterfaceIFace()->setDirty(CityScreen_DIRTY_BIT, true);
    		}
    	}
    }
    iNewCommerce = -420
    eIndex = COMMERCE_GOLD
    iOldCommerce = 1092

    Zeile 2:
    Code:
    void CvCity::updateCommerce()
    {
    	GET_PLAYER(getOwnerINLINE()).invalidateYieldRankCache();
    
    	for (int iI = 0; iI < NUM_COMMERCE_TYPES; iI++)
    	{
    		updateCommerce((CommerceTypes)iI);
    	}
    }
    Zeile 3:
    [/CODE]void CvPlayer::updateCommerce()
    {
    CvCity* pLoopCity;
    int iLoop;

    for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
    {
    pLoopCity->updateCommerce();
    }
    }[/CODE]
    iLoop =22

    Zeile 4:
    Code:
    void CvPlayer::setCommercePercent(CommerceTypes eIndex, int iNewValue)
    {
    	int iTotalCommercePercent;
    	int iOldValue;
    	int iI;
    
    	FAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)");
    	FAssertMsg(eIndex < NUM_COMMERCE_TYPES, "eIndex is expected to be within maximum bounds (invalid Index)");
    
    	iOldValue = getCommercePercent(eIndex);
    
    	m_aiCommercePercent[eIndex] = range(iNewValue, 0, 100);
    
    	if (iOldValue != getCommercePercent(eIndex))
    	{
    		iTotalCommercePercent = 0;
    
    		for (iI = 0; iI < NUM_COMMERCE_TYPES; iI++)
    		{
    			iTotalCommercePercent += getCommercePercent((CommerceTypes)iI);
    		}
    
    		for (iI = 0; iI < NUM_COMMERCE_TYPES; iI++)
    		{
    			if (iI != eIndex)
    			{
    				if (100 != iTotalCommercePercent)
    				{
    					int iAdjustment = std::min(m_aiCommercePercent[iI], iTotalCommercePercent - 100);
    					m_aiCommercePercent[iI] -= iAdjustment;
    					iTotalCommercePercent -= iAdjustment;
    				}
    				else
    				{
    					break;
    				}
    			}
    		}
    
    		FAssert(100 == iTotalCommercePercent);
    
    		updateCommerce();
    
    		AI_makeAssignWorkDirty();
    
    		if (getTeam() == GC.getGameINLINE().getActiveTeam())
    		{
    			gDLL->getInterfaceIFace()->setDirty(GameData_DIRTY_BIT, true);
    			gDLL->getInterfaceIFace()->setDirty(Score_DIRTY_BIT, true);
    			gDLL->getInterfaceIFace()->setDirty(CityScreen_DIRTY_BIT, true);
    			gDLL->getInterfaceIFace()->setDirty(Financial_Screen_DIRTY_BIT, true);
    		}
    	}
    }
    iTotalCommercePercent =100
    iOldValue = 70
    iI =2

    Zeile 5:
    Code:
    void CvPlayerAI::AI_doCommerce()
    {
    	CvCity* pLoopCity;
    	int iIdealPercent;
    	int iGoldTarget;
    	int iLoop;
    
    	FAssertMsg(!isHuman(), "isHuman did not return false as expected");
    
    /************************************************************************************************/
    /* BETTER_BTS_AI_MOD                      07/20/09                                jdog5000      */
    /*                                                                                              */
    /* Barbarian AI, efficiency                                                                     */
    /************************************************************************************************/
    	if( isBarbarian() )
    	{
    		return;
    	}
    /************************************************************************************************/
    /* BETTER_BTS_AI_MOD                       END                                                  */
    /************************************************************************************************/
    
    	iGoldTarget = AI_goldTarget();
    	int iTargetTurns = 4 * GC.getGameSpeedInfo(GC.getGameINLINE().getGameSpeedType()).getResearchPercent();
    	iTargetTurns /= 100;
    	iTargetTurns = std::max(3, iTargetTurns);
    
        if (isCommerceFlexible(COMMERCE_RESEARCH) && !AI_avoidScience())
    	{
            // set research rate to 100%
    		setCommercePercent(COMMERCE_RESEARCH, 100);
    		
    		// if the gold rate is under 0 at 90% research
    		int iGoldRate = calculateGoldRate();
    		if (iGoldRate < 0)
    		{
    			TechTypes eCurrentResearch = getCurrentResearch();
    			if (eCurrentResearch != NO_TECH)
    			{
    				int iResearchTurnsLeft = getResearchTurnsLeft(eCurrentResearch, true);
    				
    				// if we can finish the current research without running out of gold, let us spend 2/3rds of our gold 
    				if (getGold() >= iResearchTurnsLeft * iGoldRate)
    				{
    					iGoldTarget /= 3;
    				}
    			}
    		}
    	}
    iTargetTurns =16
    iGoldTarget =3414

    Zeile 6:
    Code:
    void CvPlayerAI::AI_doTurnPre()
    {
    	PROFILE_FUNC();
    
    	FAssertMsg(getPersonalityType() != NO_LEADER, "getPersonalityType() is not expected to be equal with NO_LEADER");
    	FAssertMsg(getLeaderType() != NO_LEADER, "getLeaderType() is not expected to be equal with NO_LEADER");
    	FAssertMsg(getCivilizationType() != NO_CIVILIZATION, "getCivilizationType() is not expected to be equal with NO_CIVILIZATION");
    
    	AI_invalidateCloseBordersAttitudeCache();
    
    	AI_doCounter();
    
    /************************************************************************************************/
    /* BETTER_BTS_AI_MOD                      09/03/09                       poyuzhe & jdog5000     */
    /*                                                                                              */
    /* Efficiency                                                                                   */
    /************************************************************************************************/
    	// From Sanguo Mod Performance, ie the CAR Mod
    	// Attitude cache
    	AI_invalidateAttitudeCache();
    /************************************************************************************************/
    /* BETTER_BTS_AI_MOD                       END                                                  */
    /************************************************************************************************/
    
    	AI_updateBonusValue();
    	
    	AI_doEnemyUnitData();
    	
    	if (isHuman())
    	{
    		return;
    	}
    
    	AI_doResearch();
    
    	AI_doCommerce();
    
    	AI_doMilitary();
    
    	AI_doCivics();
    
    	AI_doReligion();
    
    	AI_doCheckFinancialTrouble();
    
    	if (isBarbarian())
    	{
    		return;
    	}
    
    	if (isMinorCiv())
    	{
    		return;
    	}
    }
    Wenn ich das richtig verstehe, versucht hier eine KI, unter 0% Kommerzrate (Gold) zu gehen. Ist das so? Und: Ist der relevant?

  10. #820
    Moderator Avatar von Kathy
    Registriert seit
    11.10.07
    Beiträge
    17.019
    Es ist jedenfalls nicht der Endlospunkt, denn nachdem ich weitergehe, geht das Spiel auch zum nächsten Player über.

  11. #821
    Civ4 BASE Coder Avatar von rucivfan
    Registriert seit
    10.07.11
    Ort
    Antarktika
    Beiträge
    19.016
    Der Assert wurde so gesetzt, weil man in der Spielentwicklung davon ausging, dass immer Positive Erträge aus einer Stadt kommen.

  12. #822
    Moderator Avatar von Kathy
    Registriert seit
    11.10.07
    Beiträge
    17.019
    Alles klar. Irgendwie kam mir diese Problematik auch bekannt vor. Danach ging es auch weiter.

    Das komische ist: Ich lande jetzt mit meinen Haltepunkten in einer Schleife, bei der tatsächlich immer wieder die von mir für unschuldig erklärten Ballistenstellungen ( oder eine andere Einheit mit UNITAI_RANGED_ATTACK ) ihren Code durchlaufen.

  13. #823
    Civ4 BASE Coder Avatar von rucivfan
    Registriert seit
    10.07.11
    Ort
    Antarktika
    Beiträge
    19.016
    Es wird wohl Standardproblem Nummer 1 sein. Wenn der KI-Code eine Aufgabe festlegt und diese nicht ausgeführt wird, warum auch immer, kommt es zur Schleife, weil der KI-Code jede Einheit ohne tun neu setzen will.

    Es müsste geklärt werden, warum ein Ziel ausgewählt wird, aber der Angriffscode nciht ausgeführt wird.

  14. #824
    Moderator Avatar von Kathy
    Registriert seit
    11.10.07
    Beiträge
    17.019
    Das ist die Situation, schon seit einigen Klicks:
    Stack:
    Code:
    >	CvGameCoreDLL.dll!CvUnitAI::AI_doAttackRangedMove()  Zeile 21214	C++
     	CvGameCoreDLL.dll!CvUnitAI::AI_attackRangedMove()  Zeile 8535 + 0x8 Bytes	C++
     	CvGameCoreDLL.dll!CvUnitAI::AI_update()  Zeile 408	C++
     	CvGameCoreDLL.dll!CvSelectionGroupAI::AI_update()  Zeile 275 + 0x13 Bytes	C++
     	CvGameCoreDLL.dll!CvPlayerAI::AI_unitUpdate()  Zeile 1478 + 0xd Bytes	C++
     	CvGameCoreDLL.dll!CvGame::updateMoves()  Zeile 6677 + 0x13 Bytes	C++
     	CvGameCoreDLL.dll!CvGame::update()  Zeile 2093	C++
     	Civ4BeyondSword.exe!00415321() 	
     	[Unten angegebene Rahmen sind möglicherweise nicht korrekt und/oder fehlen, keine Symbole geladen für Civ4BeyondSword.exe]	
     	KernelBase.dll!7605af2b() 	
     	Civ4BeyondSword.exe!004d6f46() 	
     	Civ4BeyondSword.exe!008f497f() 	
     	kernel32.dll!76b5338a() 	
     	ntdll.dll!77229f72() 	
     	ntdll.dll!77229f45() 	
     	Civ4BeyondSword.exe!00790074() 	
     	Civ4BeyondSword.exe!00790074() 	
     	Civ4BeyondSword.exe!0078006f() 	
     	Civ4BeyondSword.exe!0078006f() 	
     	Civ4BeyondSword.exe!0078006f() 	
     	Civ4BeyondSword.exe!0078006f() 	
     	Civ4BeyondSword.exe!0064006e() 	
     	Civ4BeyondSword.exe!0064006e() 	
     	Civ4BeyondSword.exe!0069006c() 	
     	Civ4BeyondSword.exe!0064006e() 	
     	Civ4BeyondSword.exe!0064005f() 	
     	Civ4BeyondSword.exe!0064005f() 	
     	Civ4BeyondSword.exe!0075006c() 	
     	Civ4BeyondSword.exe!0075006c() 	
     	Civ4BeyondSword.exe!0075006c() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0073005f() 	
     	Civ4BeyondSword.exe!0073005f() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064002e() 	
     	Civ4BeyondSword.exe!0064006e() 	
     	Civ4BeyondSword.exe!0064006e() 	
     	Civ4BeyondSword.exe!0064006e() 	
     	Civ4BeyondSword.exe!0064006e()
    Code:
    bool CvUnitAI::AI_doAttackRangedMove()
    {
    	PROFILE_FUNC();
    
    	CvUnit* pDefender;
    	CvPlot* pLoopPlot;
    	CvPlot* pBestPlot;
    	int iDamage;
    	int iValue;
    	int iBestValue;
    	int iDX, iDY;
    
    	// Only search around base
    	int iSearchRange = m_pUnitInfo->getAirRange();
    
    	iBestValue = (isSuicide() && m_pUnitInfo->getProductionCost() > 0) ? (15 * m_pUnitInfo->getProductionCost()) : 0;
    	pBestPlot = NULL;
    
    	for (iDX = -(iSearchRange); iDX <= iSearchRange; iDX++)
    	{
    		for (iDY = -(iSearchRange); iDY <= iSearchRange; iDY++)
    		{
    			pLoopPlot = plotXY(getX_INLINE(), getY_INLINE(), iDX, iDY);
    
    			if ( canRangeStrikeAt( plot() ,iDX,iDY) )//Wird mehrfach pro Unit geprüft, genau genommen: 9 x 
    			{
    				if (pLoopPlot != NULL)
    				{
    					iValue = 0;
    						
    					pDefender = pLoopPlot->getBestDefender(NO_PLAYER, getOwnerINLINE(), this, true);
    						
    					if(pDefender != NULL)
    					{
    						FAssert(pDefender->canDefend());
    
    						iDamage = airCombatDamage(pDefender);//Wird nie aufgerufen, vermutlich, da keine Ziele in Reichweise sind
    
    						iValue = std::max(0, (std::min((pDefender->getDamage() + iDamage), airCombatLimit()) - pDefender->getDamage()));
    
    						iValue += ((iDamage * collateralDamage()) * std::min((pLoopPlot->getNumVisibleEnemyDefenders(this) - 1), collateralDamageMaxUnits())) / (2*100);
    
    					// Weight towards stronger units
    						iValue *= (pDefender->currCombatStr(NULL,NULL,NULL) + 2000);
    						iValue /= 2000;
    						if( plot()->area() == pLoopPlot->area() )
    						{
    							iValue *= 5;
    							iValue /= 3;
    						}
    
    					// Weight towards adjacent stacks
    						if( plotDistance(plot()->getX_INLINE(), plot()->getY_INLINE(), pLoopPlot->getX_INLINE(), pLoopPlot->getY_INLINE()) == 1 )
    						{
    							iValue *= 5;
    							iValue /= 4;
    						}
    
    						if (iValue > iBestValue)
    						{
    							iBestValue = iValue;
    							pBestPlot = pLoopPlot;
    							FAssert(!atPlot(pBestPlot));
    						}
    					}
    				}
    			}
    		}
    	}
    
    	if (pBestPlot != NULL)
    	{
    		FAssert(!atPlot(pBestPlot));
    		getGroup()->pushMission(MISSION_RANGE_ATTACK, pBestPlot->getX_INLINE(), pBestPlot->getY_INLINE());//Wird auch nicht aufgerufen
    		return true;
    	}
    
    	return false;//Kommt wie erwartet regelmäßig, da die Einheit keine Ziele erhält.
    }
    Code:
    void CvUnitAI::AI_attackRangedMove()
    {
    	PROFILE_FUNC();
    
    /********************************************************************************/
    /* 	BETTER_BTS_AI_MOD						10/21/08	Solver & jdog5000	*/
    /* 																			*/
    /* 	Air AI																	*/
    /********************************************************************************/
    
    	// Check for direct threat to current base
    //	if (plot()->isCity(true))
    	if( getDamage() < 40 )
    	{
    		// Attack the invaders!
    		if (AI_doAttackRangedMove())
    		{
    			return;
    		}
    	
    	}
    	getGroup()->pushMission(MISSION_SKIP);//Wird natürlich auch jedes mal aufgerufen
    	return;
    }
    Code:
    bool CvUnitAI::AI_update()
    {
    	PROFILE_FUNC();
    
    	CvUnit* pTransportUnit;
    
    	FAssertMsg(canMove(), "canMove is expected to be true");
    	FAssertMsg(isGroupHead(), "isGroupHead is expected to be true"); // XXX is this a good idea???
    
    	// allow python to handle it
    	CyUnit* pyUnit = new CyUnit(this);
    	CyArgsList argsList;
    	argsList.add(gDLL->getPythonIFace()->makePythonObject(pyUnit));	// pass in unit class
    	long lResult=0;
    	gDLL->getPythonIFace()->callFunction(PYGameModule, "AI_unitUpdate", argsList.makeFunctionArgs(), &lResult);
    	delete pyUnit;	// python fxn must not hold on to this pointer
    	if (lResult == 1)
    	{
    		return false;
    	}
    
    	if (getDomainType() == DOMAIN_LAND)
    	{
    		if (plot()->isWater() && !canMoveAllTerrain())
    		{
    			getGroup()->pushMission(MISSION_SKIP);
    			return false;
    		}
    		else
    		{
    			pTransportUnit = getTransportUnit();
    
    			if (pTransportUnit != NULL)
    			{
    				if (pTransportUnit->getGroup()->hasMoved() || (pTransportUnit->getGroup()->headMissionQueueNode() != NULL))
    				{
    					getGroup()->pushMission(MISSION_SKIP);
    					return false;
    				}
    			}
    		}
    	}
    
    	if (AI_afterAttack())
    	{
    		return false;
    	}
    
    	if (getGroup()->isAutomated())
    	{
    		switch (getGroup()->getAutomateType())
    		{
    		case AUTOMATE_BUILD:
    			if (AI_getUnitAIType() == UNITAI_WORKER)
    			{
    				AI_workerMove();
    			}
    			else if (AI_getUnitAIType() == UNITAI_WORKER_SEA)
    			{
    				AI_workerSeaMove();
    			}
    			else
    			{
    				FAssert(false);
    			}
    			break;
    
    		case AUTOMATE_NETWORK:
    			AI_networkAutomated();
    			// XXX else wake up???
    			break;
    
    		case AUTOMATE_CITY:
    			AI_cityAutomated();
    			// XXX else wake up???
    			break;
    
    		case AUTOMATE_EXPLORE:
    			switch (getDomainType())
    			{
    			case DOMAIN_SEA:
    				AI_exploreSeaMove();
    				break;
    
    			case DOMAIN_AIR:
    				// if we are cargo (on a carrier), hold if the carrier is not done moving yet
    				pTransportUnit = getTransportUnit();
    				if (pTransportUnit != NULL)
    				{
    					if (pTransportUnit->isAutomated() && pTransportUnit->canMove() && pTransportUnit->getGroup()->getActivityType() != ACTIVITY_HOLD)
    					{
    						getGroup()->pushMission(MISSION_SKIP);
    						break;
    					}
    				}
    /************************************************************************************************/
    /* BETTER_BTS_AI_MOD                      01/12/09                                jdog5000      */
    /*                                                                                              */
    /* Player Interface                                                                             */
    /************************************************************************************************/
    				// Have air units explore like AI units do
    				AI_exploreAirMove();
    /************************************************************************************************/
    /* BETTER_BTS_AI_MOD                       END                                                  */
    /************************************************************************************************/		
    				break;
    
    			case DOMAIN_LAND:
    				AI_exploreMove();
    				break;
    
    			default:
    				FAssert(false);
    				break;
    			}
    			
    			// if we have air cargo (we are a carrier), and we done moving, explore with the aircraft as well
    			if (hasCargo() && domainCargo() == DOMAIN_AIR && (!canMove() || getGroup()->getActivityType() == ACTIVITY_HOLD))
    			{
    				std::vector<CvUnit*> aCargoUnits;
    				getCargoUnits(aCargoUnits);
    				for (uint i = 0; i < aCargoUnits.size() && isAutomated(); ++i)
    				{
    					CvUnit* pCargoUnit = aCargoUnits[i];
    					if (pCargoUnit->getDomainType() == DOMAIN_AIR)
    					{
    						if (pCargoUnit->canMove())
    						{
    							pCargoUnit->getGroup()->setAutomateType(AUTOMATE_EXPLORE);
    							pCargoUnit->getGroup()->setActivityType(ACTIVITY_AWAKE);
    						}
    					}
    				}
    			}
    			break;
    
    		case AUTOMATE_RELIGION:
    			if (AI_getUnitAIType() == UNITAI_MISSIONARY)
    			{
    				AI_missionaryMove();
    			}
    			break;
    /************************************************************************************************/
    /* Afforess/RevDCM           Start		 09/16/10                                               */
    /*                                                                                              */
    /* Advanced Automations                                                                         */
    /************************************************************************************************/
    		case AUTOMATE_ESPIONAGE:
    			AI_autoEspionage();
    			break;
    /************************************************************************************************/
    /* Afforess/RevDCM               END                                                            */
    /************************************************************************************************/
    		default:
    			FAssert(false);
    			break;
    		}
    	
    		// if no longer automated, then we want to bail
    		return !getGroup()->isAutomated();
    	}
    	else
    	{
    		switch (AI_getUnitAIType())
    		{
    		case UNITAI_UNKNOWN:
    			getGroup()->pushMission(MISSION_SKIP);
    			break;
    
    		case UNITAI_ANIMAL:
    			AI_animalMove();
    			break;
    
    		case UNITAI_SETTLE:
    			AI_settleMove();
    			break;
    
    		case UNITAI_WORKER:
    			AI_workerMove();
    			break;
    
    		case UNITAI_ATTACK:
    			if (isBarbarian())
    			{
    				AI_barbAttackMove();
    			}
    			else
    			{
    				AI_attackMove();
    			}
    			break;
    
    		case UNITAI_ATTACK_CITY:
    			AI_attackCityMove();
    			break;
    
    		case UNITAI_COLLATERAL:
    			AI_collateralMove();
    			break;
    
    		case UNITAI_PILLAGE:
    			AI_pillageMove();
    			break;
    
    		case UNITAI_RESERVE:
    			AI_reserveMove();
    			break;
    
    		case UNITAI_COUNTER:
    			AI_counterMove();
    			break;
    
    		case UNITAI_PARADROP:
    			AI_paratrooperMove();
    			break;
    
    		case UNITAI_CITY_DEFENSE:
    			AI_cityDefenseMove();
    			break;
    
    		case UNITAI_CITY_COUNTER:
    		case UNITAI_CITY_SPECIAL:
    			AI_cityDefenseExtraMove();
    			break;
    
    		case UNITAI_EXPLORE:
    			AI_exploreMove();
    			break;
    
    		case UNITAI_MISSIONARY:
    			AI_missionaryMove();
    			break;
    
    		case UNITAI_PROPHET:
    			AI_prophetMove();
    			break;
    
    		case UNITAI_ARTIST:
    			AI_artistMove();
    			break;
    
    		case UNITAI_SCIENTIST:
    			AI_scientistMove();
    			break;
    
    		case UNITAI_GENERAL:
    			AI_generalMove();
    			break;
    
    		case UNITAI_MERCHANT:
    			AI_merchantMove();
    			break;
    
    		case UNITAI_ENGINEER:
    			AI_engineerMove();
    			break;
    
    		case UNITAI_SPY:
    			AI_spyMove();
    			break;
    
    		case UNITAI_ICBM:
    			AI_ICBMMove();
    			break;
    
    		case UNITAI_WORKER_SEA:
    			AI_workerSeaMove();
    			break;
    
    		case UNITAI_ATTACK_SEA:
    			if (isBarbarian())
    			{
    				AI_barbAttackSeaMove();
    			}
    			else
    			{
    				AI_attackSeaMove();
    			}
    			break;
    
    		case UNITAI_RESERVE_SEA:
    			AI_reserveSeaMove();
    			break;
    
    		case UNITAI_ESCORT_SEA:
    			AI_escortSeaMove();
    			break;
    
    		case UNITAI_EXPLORE_SEA:
    			AI_exploreSeaMove();
    			break;
    
    		case UNITAI_ASSAULT_SEA:
    			AI_assaultSeaMove();
    			break;
    
    		case UNITAI_SETTLER_SEA:
    			AI_settlerSeaMove();
    			break;
    
    		case UNITAI_MISSIONARY_SEA:
    			AI_missionarySeaMove();
    			break;
    
    		case UNITAI_SPY_SEA:
    			AI_spySeaMove();
    			break;
    
    		case UNITAI_CARRIER_SEA:
    			AI_carrierSeaMove();
    			break;
    
    		case UNITAI_MISSILE_CARRIER_SEA:
    			AI_missileCarrierSeaMove();
    			break;
    
    		case UNITAI_PIRATE_SEA:
    			AI_pirateSeaMove();
    			break;
    
    		case UNITAI_ATTACK_AIR:
    			AI_attackAirMove();
    			break;
    
    		case UNITAI_RANGED_ATTACK:
    			AI_attackRangedMove();//Damit wird das ganze da oben ausgelöst
    			break;
    
    		case UNITAI_DEFENSE_AIR:
    			AI_defenseAirMove();
    			break;
    
    		case UNITAI_CARRIER_AIR:
    			AI_carrierAirMove();
    			break;
    
    		case UNITAI_MISSILE_AIR:
    			AI_missileAirMove();
    			break;
    
    		case UNITAI_ATTACK_CITY_LEMMING:
    			AI_attackCityLemmingMove();
    			break;
    
    		default:
    			FAssert(false);
    			break;
    		}
    	}
    
    	return false;
    }
    Zeile 4:
    Code:
    bool CvSelectionGroupAI::AI_update()
    {
    	CLLNode<IDInfo>* pEntityNode;
    	CvUnit* pLoopUnit;
    	bool bDead;
    	bool bFollow;
    
    	PROFILE("CvSelectionGroupAI::AI_update");
    
    	FAssert(getOwnerINLINE() != NO_PLAYER);
    
    	if (!AI_isControlled())
    	{
    		return false;
    	}
    
    	if (getNumUnits() == 0)
    	{
    		return false;
    	}
    
    /************************************************************************************************/
    /* BETTER_BTS_AI_MOD                      04/28/10                                jdog5000      */
    /*                                                                                              */
    /* Unit AI                                                                                      */
    /************************************************************************************************/
    	if( !(isHuman()) && !(getHeadUnit()->isCargo()) && getActivityType() == ACTIVITY_SLEEP )
    	{
    		setForceUpdate(true);
    	}
    /************************************************************************************************/
    /* BETTER_BTS_AI_MOD                       END                                                  */
    /************************************************************************************************/
    
    	if (isForceUpdate())
    	{
    		clearMissionQueue(); // XXX ???
    		setActivityType(ACTIVITY_AWAKE);
    		setForceUpdate(false);
    
    		// if we are in the middle of attacking with a stack, cancel it
    		AI_cancelGroupAttack();
    	}
    
    	FAssert(!(GET_PLAYER(getOwnerINLINE()).isAutoMoves()));
    
    	int iTempHack = 0; // XXX
    
    	bDead = false;
    	
    	bool bFailedAlreadyFighting = false;
    	while ((m_bGroupAttack && !bFailedAlreadyFighting) || readyToMove())
    	{
    		iTempHack++;
    		if (iTempHack > 100)
    		{
    			FAssert(false);
    			CvUnit* pHeadUnit = getHeadUnit();
    			if (NULL != pHeadUnit)
    			{
    				if (GC.getLogging())
    				{
    					TCHAR szOut[1024];
    					CvWString szTempString;
    					getUnitAIString(szTempString, pHeadUnit->AI_getUnitAIType());
    					sprintf(szOut, "Unit stuck in loop: %S(%S)[%d, %d] (%S)\n", pHeadUnit->getName().GetCString(), GET_PLAYER(pHeadUnit->getOwnerINLINE()).getName(),
    						pHeadUnit->getX_INLINE(), pHeadUnit->getY_INLINE(), szTempString.GetCString());
    					gDLL->messageControlLog(szOut);
    				}
    				
    				pHeadUnit->finishMoves();
    			}
    			break;
    		}
    
    		// if we want to force the group to attack, force another attack
    		if (m_bGroupAttack)
    		{			
    			m_bGroupAttack = false;
    
    			groupAttack(m_iGroupAttackX, m_iGroupAttackY, MOVE_DIRECT_ATTACK, bFailedAlreadyFighting);
    		}
    		// else pick AI action
    		else
    		{
    			CvUnit* pHeadUnit = getHeadUnit();
    
    			if (pHeadUnit == NULL || pHeadUnit->isDelayedDeath())
    			{
    				break;
    			}
    
    			resetPath();
    
    			if (pHeadUnit->AI_update())// Darüber scheinen wir nicht hinaus zu kommen
    			{
    				// AI_update returns true when we should abort the loop and wait until next slice
    				break;
    			}
    		}
    
    		if (doDelayedDeath())
    		{
    			bDead = true;
    			break;
    		}
    
    		// if no longer group attacking, and force separate is true, then bail, decide what to do after group is split up
    		// (UnitAI of head unit may have changed)
    		if (!m_bGroupAttack && AI_isForceSeparate())
    		{
    			AI_separate();	// pointers could become invalid...
    			return true;
    		}
    	}
    Code:
    void CvPlayerAI::AI_unitUpdate()
    {
    	PROFILE_FUNC();
    
    	CLLNode<int>* pCurrUnitNode;
    	CvSelectionGroup* pLoopSelectionGroup;
    	CLinkList<int> tempGroupCycle;
    	CLinkList<int> finalGroupCycle;
    	int iValue;
    
    	if (!hasBusyUnit())
    	{
    		pCurrUnitNode = headGroupCycleNode();
    
    		while (pCurrUnitNode != NULL)
    		{
    			pLoopSelectionGroup = getSelectionGroup(pCurrUnitNode->m_data);
    			pCurrUnitNode = nextGroupCycleNode(pCurrUnitNode);
    
    			if (pLoopSelectionGroup->AI_isForceSeparate())
    			{
    				// do not split groups that are in the midst of attacking
    				if (pLoopSelectionGroup->isForceUpdate() || !pLoopSelectionGroup->AI_isGroupAttack())
    				{
    					pLoopSelectionGroup->AI_separate();	// pointers could become invalid...
    				}
    			}
    		}
    
    		if (isHuman())
    		{
    			pCurrUnitNode = headGroupCycleNode();
    
    			while (pCurrUnitNode != NULL)
    			{
    				pLoopSelectionGroup = getSelectionGroup(pCurrUnitNode->m_data);
    				pCurrUnitNode = nextGroupCycleNode(pCurrUnitNode);
    
    				if (pLoopSelectionGroup->AI_update())
    				{
    					break; // pointers could become invalid...
    				}
    			}
    		}
    		else
    		{
    			tempGroupCycle.clear();
    			finalGroupCycle.clear();
    
    			pCurrUnitNode = headGroupCycleNode();
    
    			while (pCurrUnitNode != NULL)
    			{
    				tempGroupCycle.insertAtEnd(pCurrUnitNode->m_data);
    				pCurrUnitNode = nextGroupCycleNode(pCurrUnitNode);
    			}
    
    			iValue = 0;
    
    			while (tempGroupCycle.getLength() > 0)
    			{
    				pCurrUnitNode = tempGroupCycle.head();
    
    				while (pCurrUnitNode != NULL)
    				{
    					pLoopSelectionGroup = getSelectionGroup(pCurrUnitNode->m_data);
    					FAssertMsg(pLoopSelectionGroup != NULL, "selection group node with NULL selection group");
    
    					if (AI_movementPriority(pLoopSelectionGroup) <= iValue)
    					{
    						finalGroupCycle.insertAtEnd(pCurrUnitNode->m_data);
    						pCurrUnitNode = tempGroupCycle.deleteNode(pCurrUnitNode);
    					}
    					else
    					{
    						pCurrUnitNode = tempGroupCycle.next(pCurrUnitNode);
    					}
    				}
    
    				iValue++;
    			}
    
    			pCurrUnitNode = finalGroupCycle.head();
    
    			while (pCurrUnitNode != NULL)
    			{
    				pLoopSelectionGroup = getSelectionGroup(pCurrUnitNode->m_data);
    
    				if (NULL != pLoopSelectionGroup)  // group might have been killed by a previous group update
    				{
    					if (pLoopSelectionGroup->AI_update())
    					{
    						break; // pointers could become invalid... // neuste Erkenntnis: Dieser Punkt wird nie erreicht! Ist das gut oder schlecht?
    					}
    				}
    
    				pCurrUnitNode = finalGroupCycle.next(pCurrUnitNode);
    			}
    		}
    	}
    }

  15. #825
    Civ4 BASE Coder Avatar von rucivfan
    Registriert seit
    10.07.11
    Ort
    Antarktika
    Beiträge
    19.016
    AI_update() und höher brauchst du nicht posten. Das ist der allgemeine Einheitendurchlauf.

Seite 55 von 110 ErsteErste ... 54551525354555657585965105 ... LetzteLetzte

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •