Page 9 of 10 FirstFirst ... 6 7 8 9 10 LastLast
Results 241 to 270 of 278

Thread: E's Source Code attempts

  1. #241
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    10:07
    Originally posted by Martin Gühmann
    Than I can assume this, too. However I looked into the source code and it seemed that there they are filled in prperly. It might be a general problem with location and unit arraies in the message boxes. But that is a little bit hard to figure out. However you could figure out whether putting an army into the slic context works.
    will do. But i'm beginning to wonder if maybe some thing was missed when the patch was reimplemented. Maybe thats why the arrays aren't working with SLIC?

    Yes, we still need translators. By the way did you try the robot translation on my German text bit? Have some fun with robot translation.
    not yet I was messing with cleaning up my civ3 stuff

    Not really a custom ResourceDB, however there is some kind of resource map that contains good prbabilities or prices or whatever. That might be recomputed.
    I think my best bet starts with WrlEnv.cpp. But is it a MAX_GOOD issue? I thought about doing a g_ResourceDB->Num() in my enablesgood code but it caused crashes, and I'm not sure that would have been the solution. If you get a chance look at the code below and let me know if anything sticks out. I best bet was on the SetRandomGood code as i think it set the goods on the map but not sure where or how to change it. Maybe load all the enablesgoodIndex stuff from the tileimps and buildings too?


    EDIT: I think this might be it, it gets all the resources from the terrainDB and not the resourceDB right? Should add all the tileImp enablesgood too or am I off? I left the other code below.
    Code:
    sint32 Cell::GetGoodsIndex(sint32 &val) const
    {
        val = (m_env & k_MASK_ENV_GOOD);
        if (val == 0) {
            return FALSE;
    	} else {
    		val >>= k_SHIFT_ENV_GOOD;
    		val--;
    		while(val >= 0 && 
    			  (g_theTerrainDB->Get(m_terrain_type)->GetNumResources() <= val)) {
    			val--;
    		}
    		if(val < 0)
    			return FALSE;
    		return TRUE;
        }
    }
    Code:
    WrlEnv.cpp
    
    //------------------------------------------------------------------------
    
    ----
    //
    // Name       : World::GetGood
    //
    // Description: Checks whether the given location has a good.
    //
    // Parameters : const MapPoint &pos: Map position which 
    
    should be checked, 
    //                                   whether it has a good.
    //              sint32 &good:        Filled with the good database index 
    //                                   of the good at the map position.
    //
    // Globals    : g_theTerrainDB: The terrain database.
    //
    // Returns    : Whether the given location has a good.
    //
    // Remark(s)  : -
    //
    //------------------------------------------------------------------------
    
    ----
    BOOL World::GetGood(const MapPoint &pos, sint32 &good) 
    
    const
    {
    
    	sint32 i;
    	Cell *c = GetCell(pos);
    
    	if (c->GetGoodsIndex(i)) {
    		good= 
    
    g_theTerrainDB->Get(c->m_terrain_type)->GetResourcesIndex(
    
    i);
    		return TRUE;
    	} else {
    		return FALSE;
    	}
    }
    
    //------------------------------------------------------------------------
    
    ----
    //
    // Name       : World::GetGood
    //
    // Description: Checks whether the given location has a good.
    //
    // Parameters : Cell *cell:   Pointer on the cell for which should 
    
    be checked,
    //                            whether it has a good.
    //              sint32 &good: Filled with the good database index of 
    
    the good
    //                            in the cell.
    //
    // Globals    : g_theTerrainDB: The terrain database.
    //
    // Returns    : Whether the given location has a good.
    //
    // Remark(s)  : -
    //
    //------------------------------------------------------------------------
    
    ----
    BOOL World::GetGood(const Cell *c, sint32 &good) const
    {
    
    	sint32 i;
    
    	if (c->GetGoodsIndex(i)) {
    		good= 
    
    g_theTerrainDB->Get(c->m_terrain_type)->GetResourcesIndex(
    
    i);
    		return TRUE;
    	} else {
    		return FALSE;
    	}
    }
    
    void World::ClearGoods(const sint32 x, const sint32 y)
    {
    	m_map[x][y]->m_env &= ~k_MASK_ENV_GOOD ;
    }
    
    
    void World::SetGood(const sint32 x, const sint32 y, const sint32 
    
    g)
    
    { 
    	Assert(0<= x); 
    	Assert(xAccess(m_map[x][y]->m_terrain_type)->Get
    
    NumResources() <= g -1)
    		return; 
    	
    	switch(g) { 
    	case 0:   m_map[x][y]->m_env &= 
    
    ~k_MASK_ENV_GOOD; break;
    	case 1:   m_map[x][y]->m_env = 
    
    (m_map[x][y]->m_env & ~k_MASK_ENV_GOOD) | 
    
    k_BIT_ENV_GOOD1; break; 
    	case 2:   m_map[x][y]->m_env = 
    
    (m_map[x][y]->m_env & ~k_MASK_ENV_GOOD) | 
    
    k_BIT_ENV_GOOD2; break; 
    	case 3:   m_map[x][y]->m_env = 
    
    (m_map[x][y]->m_env & ~k_MASK_ENV_GOOD) | 
    
    k_BIT_ENV_GOOD3; break; 
    	case 4:   m_map[x][y]->m_env = 
    
    (m_map[x][y]->m_env & ~k_MASK_ENV_GOOD) | 
    
    k_BIT_ENV_GOOD4; break; 
    	default:
    		Assert(0); 
    	}
    #ifdef _DEBUG
    	
    	
    #endif
    }
    
    void World::SetRandomGood(const sint32 x, const sint32 y)
    {
    	double totalProb = 0;
    	double 
    
    prob[k_MAX_GOODS_TYPES_PER_TERRAIN];
    
    	Cell *cell = m_map[x][y];
    
    	sint32 i;
    	for(i = 0; i < 
    
    k_MAX_GOODS_TYPES_PER_TERRAIN; i++) {
    		
    
    if(g_theTerrainDB->Get(cell->m_terrain_type)->GetNumResour
    
    ces() > i) {
    			prob[i] = 
    
    g_theTerrainDB->Get(cell->m_terrain_type)->GetResources(i)-
    
    >GetProbability();
    			totalProb += prob[i];
    		} else {
    			prob[i] = 0;
    		}
    	}
    
    	Assert(totalProb <= 1.0);
    	totalProb = 0;
    	sint32 val = g_rand->Next(1000);
    	for(i = 0; i < 
    
    k_MAX_GOODS_TYPES_PER_TERRAIN; i++) {
    		if(val < (totalProb + prob[i]) * 1000) {
    			SetGood(x,y,i+1);
    			return;
    		}
    		totalProb += prob[i];
    	}
    }
    Last edited by Ekmek; March 25, 2006 at 22:47.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  2. #242
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    10:07
    Martin,

    I got the AllTerrainAsImprovement stuff wokrking as MoveBonus (finally). but I cant figure this out, I posted it also in ShowOnMap

    -----------------------------

    I need help

    Ok I got it working so that it doesn't look for advances etc

    How do I get it to place just once?

    Currently it puts it all around the city until you run out of PW, but in the case of wonders PW cost is zero. How do I get the iterator to stop after the first time it builds?

    Martin, J, Fromafar, anyone?


    Code:
    	CityInfluenceIterator it(cityPos, 1); //m_sizeIndex
    	for(it.Start(); !it.End(); it.Next()) {
    		Cell *cell = g_theWorld->GetCell(it.Pos());
    		if(cityPos == it.Pos())
    				continue;
    		sint32 s;
    		for(s = 0; s < wrec->GetNumShowOnMap(); s++) {
    		const TerrainImprovementRecord *rec = g_theTerrainImprovementDB->Get(s);
    			if(terrainutil_CanPlayerSpecialBuildAt(rec, m_owner, it.Pos())) {
    				g_player[m_owner]->CreateSpecialImprovement(wrec->GetShowOnMapIndex(s), it.Pos(), 0);
    
    			}
    		}
    	}
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  3. #243
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 24, 2013
    Local Time
    20:07

    Post

    Originally posted by E
    I got the AllTerrainAsImprovement stuff wokrking as MoveBonus (finally).
    Maybe you could tell me what this MoveBonus should do, I found it in the unit.cdb. And in the code it just seems to do some strange stuff:

    Code:
    sint32 UnitData::DeductMoveCost(const Unit &me, const double cost, BOOL &out_of_fuel) 
    {
    
    	const UnitRecord *rec = g_theUnitDB->Get(m_type);
    
    	if(!Flag(k_UDF_PACMAN)) {
    
    			m_movement_points -= cost;
    			m_movement_points = std::max(m_movement_points, 0.0);
    			ClearFlag(k_UDF_FIRST_MOVE);
    	}
    
    
    
    	out_of_fuel = FALSE; 
    	if (!rec->GetNoFuelThenCrash()){ 
    		return FALSE; 
    	} else {
    		m_fuel -= g_theConstDB->NonSpaceFuelCost();
    
    		if (m_fuel <= 0) {
    			CheckForRefuel();//refuel the unit if it's in a city, airbase, or being transported
    
    			if(m_fuel <= 0) { //refuelling failed, it's NoFuelThenCrash
    				out_of_fuel = TRUE;
    			
    				if(g_player[m_owner]->GetPlayerType() != PLAYER_TYPE_ROBOT ||
    				  (g_network.IsClient() && g_network.IsLocalPlayer(m_owner))) {
    					m_army.AddDeath(Unit(m_id), CAUSE_REMOVE_ARMY_OUTOFFUEL, -1);
    				}
    
    				m_movement_points = 0;
    				return TRUE; 
    			}
    		}
    	}
    
    	sint32 bonus;
    	if(rec->GetMoveBonus(bonus)) {  //EMOD
    		m_movement_points -= bonus;
    	} else {
    		m_movement_points -= cost;
    	}
    	
    	return FALSE;
    }
    By the way I already fixed it a little bit but still it does not do much sense. The old version just deducted one move point now it deducts always the same amount of movepoints regardless of the terrain. Is that what you really want?

    Second problem:

    Code:
    bool CityData::HasTileImpInRadius(sint32 tileimp, MapPoint &cityPos) const
    {
    	//MapPoint cityPos(m_home_city.RetPos());
    	CityInfluenceIterator it(cityPos, m_sizeIndex);
    
    	for(it.Start(); !it.End(); it.Next()) {
    		Cell *cell = g_theWorld->GetCell(it.Pos());
    	
    		if(cell->GetDBImprovement(tileimp) > 0);
    			return true;
    	}
    	return false;
    }
    What is this you add an semicolon after an if statement and put nothing before it. So what does do this little piece of code?

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  4. #244
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    10:07
    Originally posted by Martin Gühmann
    By the way I already fixed it a little bit but still it does not do much sense. The old version just deducted one move point now it deducts always the same amount of movepoints regardless of the terrain. Is that what you really want?
    Yes. the move bonus code is supposed to be like AllTerrainAsRoad in Civ2 and Civ3. If you recall, that flagwould only cost 1/3 no matter what terrain the unit moved on, like there is a road there. this movebonus is like that except instead of forcing it to only be roads, I figured having a value as a movebonus a modder could specify roads (by giving it 33 just like roads have) or 20 for rail roads or different values to differentiate.

    So yes thats what I want. Thanks for fixing it.




    Second problem:

    Code:
    bool CityData::HasTileImpInRadius(sint32 tileimp, MapPoint &cityPos) const
    {
    	//MapPoint cityPos(m_home_city.RetPos());
    	CityInfluenceIterator it(cityPos, m_sizeIndex);
    
    	for(it.Start(); !it.End(); it.Next()) {
    		Cell *cell = g_theWorld->GetCell(it.Pos());
    	
    		if(cell->GetDBImprovement(tileimp) > 0);
    			return true;
    	}
    	return false;
    }
    What is this you add an semicolon after an if statement and put nothing before it. So what does do this little piece of code?

    -Martin
    I might have slipped on the semi colon. This coed was an attempt to do a check of a city radius for any tileimp in there, kind of like looking for a good in a radius.

    This was going to be a check for showOnMap and I was thinking that it could later be used for stuff like nuclear weapons, where you have to have a weapons lab tileimp in order to build hem and the AI 9or you) may try to pillage or bomb it to prevent nukes.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  5. #245
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 24, 2013
    Local Time
    20:07

    Post

    Actually I asked you what the code does with the semicolon in, not what it was supposed to do.

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  6. #246
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    10:07
    it just returns true if the tileimp is in that cell (thereby its greater than zero). But I figure I can just leave it as a bool.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  7. #247
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 24, 2013
    Local Time
    20:07

    Post

    Originally posted by E
    it just returns true if the tileimp is in that cell (thereby its greater than zero). But I figure I can just leave it as a bool.
    No, that is what it is supposed to do, and would do without the semicolon, so what does the code with the semicolon at that place?

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  8. #248
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    10:07
    i guess does nothing
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  9. #249
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 24, 2013
    Local Time
    20:07

    Post

    Originally posted by E
    i guess does nothing
    No, it does something else. And I think you have to understand this. So what does it?

    Oh and I found anther piece of code:

    Code:
    			sint32 pop;
    			for (pop = 0; pop < u.GetDBRec()->GetPopCostsToBuild(); ++pop) {
    				if(u.GetDBRec()->GetPopCostsToBuild(pop) > 0) {
    					cd->SubtractAccumulatedFood(static_cast(g_theConstDB->CityGrowthCoefficient()));
    					cd->ChangePopulation(-pop);
    				}
    			}
    I took the freedom to turn it into something like this:

    Code:
    			sint32 pop;
    			if(u.GetDBRec()->GetPopCostsToBuild(pop)) {
    				cd->SubtractAccumulatedFood(static_cast(g_theConstDB->CityGrowthCoefficient()));
    				cd->ChangePopulation(-pop);
    			}
    So what is the difference between those two pieces of code? By the way did you check whether building such a unit that costs 2 pops does not make the parent city disband?

    -Martin

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  10. #250
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    10:07
    with > I think it changes it from a simple false true bool to a 0 or 1 bool?


    as foor popcost. I had that check in there, well I tried. but I got stuck on trying to get the pop-up message to trigger right. but with your code changes I'll try again because I think that was the reason why I wasnt able to trigger the pop-up

    PS I'm glad to see you had some time to devote to CtP2
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  11. #251
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 24, 2013
    Local Time
    20:07

    Post

    Originally posted by E
    with > I think it changes it from a simple false true bool to a 0 or 1 bool?
    Nope, the result is something else. Remember what I told you about ifs (well also about fors and whiles): An if only works on the following statement, you can combine statements by putting them into brackets. But you didn't do this here. And the second thing about statements is that they are closed by a semicolon.

    So you have an if that works on the next statement and right there is a semicolon. So what happens.

    Originally posted by E
    as foor popcost. I had that check in there, well I tried. but I got stuck on trying to get the pop-up message to trigger right. but with your code changes I'll try again because I think that was the reason why I wasnt able to trigger the pop-up
    I doubt that my code changes do the trick in fact I asked you about the differences of the two pieces of code. For instance we have the functionality of the code and we have the complexity of the code which I would like o messure in this case by the number of lines. As a hint there is only a difference in one of these two aspects.

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  12. #252
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 24, 2013
    Local Time
    20:07

    Post

    By the way E what does GetDBImprovement do?

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  13. #253
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    10:07
    based on this

    Code:
    sint32 Cell::GetDBImprovement(sint32 index) const
    {
    	if(!m_objects)
    		return -1;
    
    	sint32 i, c = 0;
    	for(i = m_objects->Num() -1; i >= 0; i--) {
    		if((m_objects->Access(i).m_id & k_ID_TYPE_MASK) == k_BIT_GAME_OBJ_TYPE_IMPROVEMENT_DB) {
    			if(c == index) {
    				return m_objects->Access(i).m_id & k_ID_KEY_MASK;
    			}
    			c++;
    		}
    	}
    	return -1;
    }
    I thought it returns the tileimprovemnt in the cell

    So you have an if that works on the next statement and right there is a semicolon. So what happens.
    ok, not sure. I don't think it crashes so my next guess would be that it either ignores the following statement or it just goes on to the next statement whether its true or false.

    I asked you about the differences of the two pieces of code
    it was abpout populating the value of the sint32 and the for only adds value of one where as your second piece of code populates it with the db text file's value
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  14. #254
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 24, 2013
    Local Time
    20:07

    Post

    Originally posted by E
    I thought it returns the tileimprovemnt in the cell
    Well I thought this as well but if I look on the code I am not so sure. However this is not the problem here. The real problem is what is the input. What does mean the input.

    Originally posted by E
    ok, not sure. I don't think it crashes so my next guess would be that it either ignores the following statement or it just goes on to the next statement whether its true or false.
    So you have to decide, what happens if the following statement that is under the control of the if is empty. That is what basicly stands there. And imediately following semicolon that marks the end of an statement, that contains in this case nothing.

    Originally posted by E
    it was abpout populating the value of the sint32 and the for only adds value of one where as your second piece of code populates it with the db text file's value
    Not quite. What does return GetPopCostsToBuild()? Maybe this brings you a little bit closer.

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  15. #255
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    10:07
    Outcommented AI gold cheat. This should be an option for modmakers and nothing else. The AI has to hande the gold stuff properly and if it can't then it must be modified so that it can.
    modified ctp2_code/gs/gameobj/CityData.cpp
    Any recommendations on how to make this optional? The difficulty db doesnt look the same as the other and I'm hesitant to make it a flag there or in Const.cdb since it might further complicate backwards compatibility. I guess I could make it a "AIDeficitSpending' flag for a building...


    Removed double call of CityData::AddWonder, this method is already called in Player::AddWonder:
    modified ctp2_code/gs/gameobj/CityEvent.cpp
    Are you sure about this? Looking at player it does assign the wonder to the city but not the same way addimprovement does for a biulding in citydata.

    My add borders code doesn't activate without citydata::addwonder called in the cityevent. Thats how I got it to work with my buildings and not it doesn't work. So i think I wasn'tthat off unless you think it should go into player (I doubt it because it doesn't address generate borders) and putting it in cityevent.cpp also I had problems with.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  16. #256
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 24, 2013
    Local Time
    20:07

    Post

    Originally posted by E
    Any recommendations on how to make this optional? The difficulty db doesnt look the same as the other and I'm hesitant to make it a flag there or in Const.cdb since it might further complicate backwards compatibility. I guess I could make it a "AIDeficitSpending' flag for a building...
    It goes into the difficulty database, but not into the current CTP1 one. However I already have replaced it with the new one in my working copy, but first I would like to do some playtesting.

    Originally posted by E
    Are you sure about this? Looking at player it does assign the wonder to the city but not the same way addimprovement does for a biulding in citydata.

    My add borders code doesn't activate without [C]ity[D]ata::[A]dd[W]onder called in the cityevent. Thats how I got it to work with my buildings and not it doesn't work. So i think I wasn'tthat off unless you think it should go into player (I doubt it because it doesn't address generate borders) and putting it in cityevent.cpp also I had problems with.
    As far as I was able to see it CityData::AddWonder is called in Player::AddWonder, therefore it shouldn't be a problem. Of course I should have a look at it again.

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  17. #257
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    10:07
    Originally posted by Martin Gühmann
    It goes into the difficulty database, but not into the current CTP1 one. However I already have replaced it with the new one in my working copy, but first I would like to do some playtesting.
    Great! I'll wait until you get it going. I think I need to add one with shields too. I have that in readiness and it maybe causing BureauBerts latest Governor/readiness crash

    Originally posted by Martin Gühmann

    As far as I was able to see it CityData::AddWonder is called in Player::AddWonder, therefore it shouldn't be a problem. Of course I should have a look at it again.

    I don't see it there...should we add it there or back into cityevent?

    Code:
    void Player::AddWonder(sint32 wonder, Unit &city)
    {
    	DPRINTF(k_DBG_GAMESTATE, ("Player %d built wonder %d\n", m_owner, wonder));
    	m_builtWonders |= ((uint64)1 << wonder);
    	
    
    	if(wonderutil_Get(wonder)->GetPollutersToParks()) {
    
    		
    		
    		
    		if(!g_network.IsClient() || g_network.IsLocalPlayer(m_owner)) {
    			
    			sint32 polluters;
    			wonderutil_Get(wonder)->GetPollutersToParks(polluters);
    			Unit *ua = new Unit[polluters];
    			for(sint32 i = 0; i < polluters; i++) {
    				ua[i].m_id = (0);
    			}
    			
    			sint32 pl, c, po, mv;
    			
    			for(pl = 0; pl < k_MAX_PLAYERS; pl++) {
    				if(!g_player[pl]) continue;
    				int numCities=g_player[pl]->m_all_cities->Num() ;
    				for(c = 0; c m_all_cities->Access(c));
    
    					
    					if(city.AccessData()->GetCityData()->GetBuiltWonders() & (uint64(1) << wonder))
    						continue;
    
    					
    					if(city.GetPollution() < 1)
    						continue;
    
    					for(po = 0; po < polluters; po++) {
    						if(ua[po].m_id == (0)) {
    							ua[po] = city;
    							break;
    						} else if(city.GetPollution() > ua[po].GetPollution()) {
    							for(mv = polluters - 1; mv > po; mv--) {
    								ua[mv] = ua[mv -1];
    							}
    							ua[po] = city;
    							break;
    						}
    					}
    				}
    			}
    
    			for(po = 0; po < polluters; po++) {
    				if(ua[po].m_id != (0)) {
    					ua[po].CityToPark(m_owner);
    				}
    			}
    			delete [] ua;
    		}
    	}
    
    	if(wonderutil_GetFreeSlaves((uint64)1 << wonder)) {
    		sint32 i, n = m_all_cities->Num();
    		for(i = 0; i < n; i++) {
    			m_all_cities->Access(i).FreeSlaves();
    		}
    
    		for(i = m_all_units->Num() - 1; i >= 0; i--) {
    			const UnitRecord *rec = m_all_units->Access(i).GetDBRec();
    			if(rec->GetSlaveRaids() || rec->GetSettlerSlaveRaids() ||
    			   rec->GetSlaveUprising()) {
    				m_all_units->Access(i).Kill(CAUSE_REMOVE_ARMY_EMANCIPATION, -1);
    			}
    		}
    			
    		for(i = 0; i < k_MAX_PLAYERS; i++) {
    			if(g_player[i] && i != m_owner) {
    				g_player[i]->Emancipate();
    			}
    		}
    	}
    
    	sint32 hpBonus = wonderutil_GetIncreaseHP((uint64)1 << wonder);
    	if(hpBonus > 0) {
    		sint32 i, n = m_all_units->Num();
    		for(i = 0; i < n; i++) {
    			m_all_units->Access(i).AddWonderHPBonus(hpBonus);
    		}
    	}
    
    	sint32 fullHappinessTurns = wonderutil_GetTemporaryFullHappiness(
    		((uint64)1 << wonder));
    	if(fullHappinessTurns > 0) {
    		sint32 i, n = m_all_cities->Num();
    		for(i = 0; i < n; i++) {
    			m_all_cities->Access(i).SetFullHappinessTurns(fullHappinessTurns);
    		}
    	}
    
    	
    	
    	
    	
    	sint32 readinessReduction = wonderutil_GetReadinessCostReduction((uint64)1 << wonder);
    	if(readinessReduction > 0) {
    		m_readiness->RecalcCost();
    	}
    		
    	if(wonderutil_GetNukesEliminated((uint64) 1 << wonder)) {
    		sint32 i, p;
    		SlicObject *so = new SlicObject("251NaniteDefuseEliminatesNukes");
    		so->AddWonder(wonder);
    		so->AddCivilisation(m_owner);
    		for(p = 0; p < k_MAX_PLAYERS; p++) {
    			if(g_player[p]) {
    				so->AddRecipient(p);
    				
    				for(i = 0; i < g_player[p]->m_all_cities->Num(); i++) {
    					g_player[p]->m_all_cities->Access(i).AccessData()->GetCityData()->EliminateNukes();
    				}
    				
    				for(i = g_player[p]->m_all_units->Num() - 1; i >= 0; i--) {
    					if(g_player[p]->m_all_units->Access(i).GetDBRec()->GetNuclearAttack()) {
    						g_player[p]->m_all_units->Access(i).Kill(CAUSE_REMOVE_ARMY_NUKES_ELIMINATED, m_owner);
    					}
    				}
    			}
    		}
    		g_slicEngine->Execute(so);
    	}
    
    	if(wonderutil_GetCloseEmbassies((uint64)1 << wonder)) {
    		sint32 p;
    		for(p = 0; p < k_MAX_PLAYERS; p++) {
    			if(g_player[p]) {
    				g_player[p]->CloseEmbassy(m_owner);
    				g_player[p]->SetDiplomaticState(m_owner, DIPLOMATIC_STATE_NEUTRAL);
    				SetDiplomaticState(p, DIPLOMATIC_STATE_NEUTRAL);
    			}
    		}
    	}
    
    	if(wonderutil_GetEmbassiesEverywhereEvenAtWar((uint64)1 << wonder)) {
    		sint32 p;
    		for(p = 0; p < k_MAX_PLAYERS; p++) {
    			if(g_player[p]) {
    				g_player[p]->SetDiplomaticState(m_owner, DIPLOMATIC_STATE_NEUTRAL);
    				SetDiplomaticState(p, DIPLOMATIC_STATE_NEUTRAL);
    			}
    		}
    	}
    
    	if(wonderutil_Get(wonder)->GetPreventConversion()) {
    		sint32 i;
    		for(i = 0; i < m_all_cities->Num(); i++) {
    			m_all_cities->Access(i).GetData()->GetCityData()->Unconvert(FALSE);
    		}
    	}
    
    	
    	if(wonderutil_Get(wonder)->GetGlobalRadar()) {
    		m_hasGlobalRadar = TRUE;
    		g_theWonderTracker->SetGlobeSatFlags(g_theWonderTracker->GlobeSatFlags() | (1 << m_owner));
    
    		
    		sint32 p;
    		for(p = 0; p < k_MAX_PLAYERS; p++) {
    			sint32 u;
    			if(!g_player[p] || m_owner == p)
    				continue;
    
    			
    			
    			ContactMade(p);
    
    			for(u = 0; u < g_player[p]->m_all_units->Num(); u++) {
    				if(g_player[p]->m_all_units->Access(u).GetDBRec()->GetVisionClassStandard()) {
    					g_player[p]->m_all_units->Access(u).SetVisible(m_owner);
    				}
    			}
    
    			sint32 c;
    			for(c = 0; c < g_player[p]->m_all_cities->Num(); c++) {
    				g_player[p]->m_all_cities->Access(c).SetVisible(m_owner);
    			}
    		}
    
    		
    		
    		m_vision->SetTheWholeWorldExplored();
    		m_vision->ClearUnseen();
    
    		if(m_owner == g_selected_item->GetVisiblePlayer()) {
    			
    			
    			
    			g_director->AddCopyVision();
    		}
    	}
    
    	sint32 i;
    	for(i = 0; i < m_all_cities->Num(); i++) {
    		m_all_cities->Access(i).GetData()->GetCityData()->GetBuildQueue()->RemoveIllegalItems();
    	}
    
    	
    	
    	sint32 pl, c;
    	for(pl = 0; pl < k_MAX_PLAYERS; pl++) {
    		if(pl == m_owner || 
    		   !g_player[pl]) {
    			continue;
    		}
    		int numCities=g_player[pl]->m_all_cities->Num() ;
    		for(c = 0; c m_all_cities->Access(c).GetData()->GetCityData()->GetBuildQueue()->
    				RemoveIllegalItems(TRUE);
    		}
    	}
    
    	const WonderRecord *wrec = g_theWonderDB->Get(wonder);
    	sint32 buildingIndex;
    	if(wrec->GetBuildingEverywhereIndex(buildingIndex)) {
    		m_wonderBuildings |= ((uint64)1 << buildingIndex);
    	}
    		
    }

    I don't see it there...should we add it there or back into cityevent?
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  18. #258
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 24, 2013
    Local Time
    20:07

    Post

    Originally posted by E
    Great! I'll wait until you get it going. I think I need to add one with shields too. I have that in readiness and it maybe causing BureauBerts latest Governor/readiness crash
    What do you mean by this, and what does it has to do with your Governor related crash?

    Originally posted by E
    I don't see it there...should we add it there or back into cityevent?
    Well maybe I look closer at the call again. I just outcommented it.

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  19. #259
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    10:07
    Originally posted by Martin Gühmann


    What do you mean by this, and what does it has to do with your Governor related crash?
    I also have a 'If Player is Robot' in readiness where if the AI has more units than shields can support it does not disband the extra units like it does for the human player. It allows the AI a lot of extra units. So, like the Gold cheat I added I'm sure you'd prefer that to be an option in the difficulty db instead of just being there.

    it may relate to the crash because m_cost is featured in the shield cost calculation and may affect how the governor is calculating that cost.


    re: AddWonder
    Well maybe I look closer at the call again. I just outcommented it.
    ok
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  20. #260
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    10:07
    Martin (and others),
    I had two problems when compiling and they stem from accessing player.h from ArmyData

    it was this code (outcommented) in ArmyData::BeginTurn()

    g_player[m_owner]->m_materialPool->AddMaterials(shields);

    AND

    in Armydata:isband

    g_player[m_owner]->CreateSpecialImprovement(rec->GetSettleImprovementIndex(imp), m_pos, 0)

    in the first it was saying the declaration of MaterialPool was wrong and the second it was that Terrain Improvement was wrong. Even odder if i don't out comment the material pool part the terrainimp one doesn't shown as an error, but it pops up if materialpool is outcommented. not sure why it does that, they aren't linked.

    I was thinking it has something to do with public and private declarations in player.h but didn't see anything like that. Is there something I'm missing?

    thanks



    g_player[m_owner]->m_materialPool->AddMaterials(
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  21. #261
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 24, 2013
    Local Time
    20:07

    Post

    Originally posted by E
    I was thinking it has something to do with public and private declarations in player.h but didn't see anything like that.
    No E, all the stuff you use is declared public. Maybe it would be more helpful if you post the error messages here.

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  22. #262
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    10:07
    Martin,

    I was able to get this stuff working, it appears that Materials.h wasn't included

    but I still can't get around this code I'm trying in player.cpp:

    Code:
    			sint32 good;
    			if ((rec->GetCanExportGood()) && (g_theWorld->GetGood(inst.RetPos(), good))){
    				for (sint32 c=0; c < n; c++) {
    					CityData *cd = m_all_cities->Access(i).CD();
    					//CityData *cd = m_all_cities->Access(c).GetData()->GetCityData();
    					if(!cd->IsLocalResource (good)) {
    						//cd->GetCollectingResources()->AddResource(good);
    						cd->m_collectingResources.AddResource(good); //GetCollectingResources()->AddResource(good);
    						//cd->AddGoodToCity(good);
    						//break;  may have to add a break like sneakattack because only one city should receive it
    					}
    				}
    			}
    My out commented stuff was other attempts I had at trying to access this. But, now it looks like its a private problem...

    Code:
    ...trunk\ctp2_code\gs\gameobj\Player.cpp(2138) : error C2248: 'm_collectingResources' : cannot access private member declared in class 'CityData'
     ... \trunk\ctp2_code\gs\gameobj\citydata.h(253) : see declaration of 'm_collectingResources'
    what do I have to do to access it? My code intent is to search all cities to see if they are collecting the good that this imp has. if its not it will add to that city and only that city.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  23. #263
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,248
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    May 24, 2013
    Local Time
    20:07

    Post

    m_collectingResources is private and should be private: The best is if you encapsulate the stuff you want to do from the if including the if in a method of CityData.

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

  24. #264
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    10:07
    I tried this
    Code:
    void CityData::AddGoodToCity(sint32 good) const
    {
    	 m_collectingResources.AddResource(good);
    }
    but got this

    Code:
    trunk\ctp2_code\gs\gameobj\CityData.cpp(5299) : error C2662: 'AddResource' : cannot convert 'this' pointer from 'const class Resources' to 'class Resources &'
            Conversion loses qualifiers
    why cant it load this sint32 good when it does it usually?
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  25. #265
    J Bytheway
    Emperor J Bytheway's Avatar
    Join Date
    02 Jul 2001
    Location
    England
    Posts
    3,826
    Country
    This is J Bytheway's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    19:07
    Originally posted by E
    I tried this
    Code:
    void CityData::AddGoodToCity(sint32 good) const
    You declared the method const, so it cannot modify the object *this, but you are trying to make it do so. You may be able to simply remove the const, but OTOH that may lead to other problems. I would say it looks like it should not be const.

  26. #266
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    10:07
    Thanks J!

    That was exactly the problem. It works now!
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  27. #267
    Fromafar
    Prince
    Join Date
    25 May 2003
    Posts
    622
    Country
    This is Fromafar's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    20:07
    Originally posted by E
    I thought restoring this line
    Code:
    Assert(foreignerId < m_diplomacy.size() );
    to
    Code:
    sint32 Diplomat::GetNewProposalPriority(const PLAYER_INDEX foreignerId, const PROPOSAL_TYPE proposalType ) const
    would fix the new CTD
    Adding or removing Assert statements will do nothing to prevent CTDs in the final version. Those are active only in the debug version and report expected unexpected situations. In this case, the Assert is quite useless - even in the debug version. The foreigner Id is used as index in the line before the Assert, so when using a wrong index, it could have crashed before reaching the Assert.

    Because the reported crash is attributed to the GetProposal() call, you have already passed the Assert statements. Are you running the debug version? Set a breakpoint (or run until you get the automatic breakpoint when the crash occurs) at the line
    Code:
    const DiplomacyProposalRecord * rec = elem->GetProposal();
    and examine the value of elem. It could be NULL, which would definitely cause a CTD.

  28. #268
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    10:07
    BUt the code was there before, but now it doesn't work the same.

    I tried removing that part
    Code:
    sint32 Diplomat::GetNewProposalPriority(const PLAYER_INDEX foreignerId, 
    							  const PROPOSAL_TYPE proposalType ) const
    {
    	Assert(s_proposalTypeToElemIndex[proposalType] < m_diplomacy[foreignerId].GetNumProposalElement());
    	
    	const DiplomacyRecord::ProposalElement * elem =
    		m_diplomacy[foreignerId].GetProposalElement(s_proposalTypeToElemIndex[proposalType]);
    
    	
    //	const DiplomacyProposalRecord * rec = elem->GetProposal();
    //	if (InvalidNewProposal(foreignerId, rec))
    //		return -1;
    
    	sint32 priority = -1;
    	(void) elem->GetSendPriority(priority);
    	return priority;
    }
    and still got the crash.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  29. #269
    Fromafar
    Prince
    Join Date
    25 May 2003
    Posts
    622
    Country
    This is Fromafar's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    20:07
    That does not invalidate the hypothesis.
    Code:
    (void) elem->GetSendPriority(priority);
    will cause the same kind of crash when elem is NULL.

  30. #270
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    May 24, 2013
    Local Time
    10:07
    Code:
    sint32 Diplomat::GetNewProposalPriority(const PLAYER_INDEX foreignerId, 
    							  const PROPOSAL_TYPE proposalType ) const
    {
    	Assert(s_proposalTypeToElemIndex[proposalType] < m_diplomacy[foreignerId].GetNumProposalElement());
    	
    	const DiplomacyRecord::ProposalElement * elem =
    		m_diplomacy[foreignerId].GetProposalElement(s_proposalTypeToElemIndex[proposalType]);
    
    	
    	const DiplomacyProposalRecord * rec = elem->GetProposal();
    	if (InvalidNewProposal(foreignerId, rec))
    		return -1;
    
    	if (rec == NULL)
    		return -1;
    
    	sint32 priority = -1;
    	(void) elem->GetSendPriority(priority);
    	return priority;
    }
    I tried this for the null but still got a crash. What I dont get is why did the original code not crash before but now it does?
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

Page 9 of 10 FirstFirst ... 6 7 8 9 10 LastLast

Similar Threads

  1. CTP Source Code
    By DCMike in forum Call to Power 2
    Replies: 2
    Last Post: August 12, 2009, 14:28
  2. Civ ii source code
    By McMonkey in forum Civilization I and Civilization II
    Replies: 25
    Last Post: March 8, 2009, 19:05
  3. Who has the source code?
    By The_Reckoning in forum Alpha Centauri
    Replies: 3
    Last Post: March 1, 2009, 12:47
  4. Civ 2 source code
    By McMonkey in forum Civilization I and Civilization II
    Replies: 2
    Last Post: January 11, 2009, 11:15
  5. Javadoc Documentation for current source / + current source code
    By Mark_Everson in forum Clash of Civilizations
    Replies: 0
    Last Post: September 17, 2000, 14:15

Visitors found this page by searching for:

gameobj.cpp no such id

error C2297: * : illegal right operand has type double [21]

powered by myBB algorithms for programmers ideas and source code download

powered by myBB definition of source code

gameobj.cpp no such id 0cod.c(97) : error c2297: ^ : illegal right operand has type const void *const code attemptsus games inc d0000014error C2297: * : illegal right operand has type double [32]

Bookmarks

Posting Permissions