Announcement

Collapse
No announcement yet.

Project: Hidden Nationality

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Project: Hidden Nationality

    My long quest to create hidden nationality an option in Ctp2 (cherry picking from civ3) has met one hiccup. I identified the code where color is done and thought I found a way to implement it but for some reason in the hiddenationality code part it assigns random colors (see attached picture).

    Basically what I want is for the unit to look like a barbarian (have barb flag color andeventually have thetext say barb in the info bar) if you don't own that unit but if you do, you see your own color. If you don't then no matter what player owns the unit it looks like a barbarian. therefore 'hidden nationality' like the privateers in civ3.

    here's the code:
    Code:
    void UnitActor::DrawStackingIndicator(sint32 x, sint32 y, sint32 stack)
    {
    #ifndef _TEST
    	STOMPCHECK();
    #endif
    	TileSet		*tileSet = g_tiledMap->GetTileSet();
    	Pixel16		color; // = g_colorSet->GetPlayerColor(m_playerNum);
    	MAPICON		icon = MAPICON_HERALD;
    	//MAPICON		civicon = MAPICON_CIVFLAG_0;
    
    [b]
    //this will make all heralds the same as barbs for HiddenNationality Units
    	if ((m_unitID.IsHiddenNationlity()) && (m_playerNum != g_selected_item->GetVisiblePlayer())) {  //needed to add visible player check so you can find your own units
    		color = g_colorSet->GetPlayerColor(0);  //PLAYER_INDEX_VANDALS  gave strange colors
    	} else if (!m_unitID.IsHiddenNationlity()) { //just an else?  or switch it to !hidden&visible
    		color = g_colorSet->GetPlayerColor(m_playerNum);
    	}
    [/b]
    	if(!g_showHeralds) return;
    
    	if (stack > 1 && stack <= 9) {
    		icon = (MAPICON) ((sint32) MAPICON_HERALD2 + stack - 2);
    	} else if(stack >= 10 && stack <= 12) {
    		icon = (MAPICON) ((sint32) MAPICON_HERALD10 + stack - 10);
    	}
    
    	POINT	iconDim = tileSet->GetMapIconDimensions(MAPICON_HERALD);
    
    	if (x < 0) return;
    	if (y < 0) return;
    	if (x >= g_screenManager->GetSurfWidth() - iconDim.x) return;
    	if (y >= g_screenManager->GetSurfHeight() - iconDim.y) return;
    
    	g_tiledMap->DrawColorizedOverlayIntoMix(tileSet->GetMapIconData(icon), x, y, color);
    [i]...rest of the code...[/i]
    Attached Files
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  • #2
    The code clearly states that if you there is a unit that you don't own, but its nationality is hidden it is displayed as barbarian. If zhis condition is false you check whether your unit hasn't the hidden nationality atrribute. And that case assigns the unit the right civ color, but you forgot the case where you have a hidden nationality unit that you own. For that case you do nothing, and since you do not initialize color it is filled with some random memory and you get random colors.

    Maybe you just should simplify your "else if" by removing the "if".

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

    Comment


    • #3
      Yep that was it and the same kind of code works in infobar.cpp so finally my hidden nationality works!
      Formerly known as "E" on Apolyton

      See me at Civfanatics.com

      Comment

      Working...
      X