Mod-Modders Guide to Fall Further

Discussion in 'Fall Further' started by xienwolf, Sep 25, 2008.

  1. Afforess

    Afforess The White Wizard

    Joined:
    Jul 31, 2007
    Messages:
    12,239
    Location:
    Austin, Texas
    I didn't know that. VS is still useful for debugging, so you may need to use it eventually anyway, unless Xienwolf knows how to do that in Codeblocks too.;)
     
  2. xienwolf

    xienwolf Deity

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
    Nope, debugging is only possible through VS so far. But Codeblocks is a good platform to learn on, you can't make quite as many mistakes in compiling (forgetting to fully recompile when required primarily) as easily.
     
  3. KarstenChu

    KarstenChu Chieftain

    Joined:
    Apr 26, 2006
    Messages:
    61
    Alright, I'll keep going on Codeblocks then! I think I'm getting ideas.
     
  4. GIR

    GIR It'sNotStupidIt'sAdvanced

    Joined:
    Jul 12, 2005
    Messages:
    884
    Location:
    EU
    hi

    im just writing a new mod component and i need help with the splited barbarians (barbarians, demons and animals).

    there is a pPlayer.isBarbarian() check in bts and ff.
    is there something similar for the other 2 barbarian fractions?

    thx
     
  5. Sephi

    Sephi Deity

    Joined:
    Jan 25, 2009
    Messages:
    2,951
    IIRC isBarBarian() returns true for all Barbarian factions in FF. To get a specific one, use gc.getANIMAL_PLAYER() which returns the ID of the barbarian player.
     
  6. xienwolf

    xienwolf Deity

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
    Sephi is correct. isBarbarian() notifies for all Barbs (though I think I wrote it stupid and it notifies for all that I wrote, and others have to be added, I should have made it generic to catch everything past Max_Civ_Players)
     
  7. ExMachina

    ExMachina Warlord

    Joined:
    Jun 5, 2008
    Messages:
    203
    I'm trying to make a module for RifE (formerly known as FF+), and from what I understand it's the same modular loading code Xienwolf merged over from WoC Lite. Anyway, I've been getting some very strange bugs, mostly from buildings but occasionally from units as well (things like buildings granting thousands of commerce to specialists, units being able to cast every spell in the game, and other such things). A couple posts in this thread suggest other people are having similar issues. The bugs I've encountered are so problematic that I'm considering scrapping my module entirely. My questions are:

    1.) Is there a post that describes the known issues with modular loading so that I can know what to look out for?
    2.) What's the current progress on resolving these issues in the code? I'm not a code monkey, but I can be pretty good at catching typos; I'll take a look at the relevant lines if someone points me in the right direction. But I don't even know where the modular loading code is (it's somewhere in the DLL, right?).
     
  8. xienwolf

    xienwolf Deity

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
    Unfortunately the issues are fairly scattered. Most all made it into the bug thread, but I don't know for CERTAIN that I carried all of them to the first post. I think at some point I just admitted that I did the merge too quickly and needed to be more cautious in the rebuild and ensure I do not simply copy over my previous setup.

    Sephi has found and fixed most of the issues. As far as I know modular loading works flawlessly in Wild Mana, so except for the new tags I have added which he has not imported, Valkrionn should look to snipe any differences in his code which involve the modular loading bits and just assume that they fix bugs. I know events were horrible, and I recall issues being mentioned with either (or maybe both) buildings or units. Been a while though since I looked at the bug thread's list, I am not anywhere NEAR implementing my old code yet in the rebuild, still cleaning up Kael's and Firaxis's code to be better optimized (hopefully) now that I understand how to do so and am willing to invest the time (when I have it to invest)

    All of the code is in the DLL, and it isn't a matter of typos (the compiler catches those, except when you typo into another variable which would be legal there), but rather of either omissions, or format/concept issues. It'd be something you have to study fairly well first, THEN get lucky looking at the code (it is only fragmented into about 70 different locations, and each one looks almost the same as all of the others, leading to "road blindness" very quickly...)
     
  9. Sephi

    Sephi Deity

    Joined:
    Jan 25, 2009
    Messages:
    2,951
    actually the worst problems are kind of typos. Some 2D dynamic arrays in the building section where i and j was exchanged, leading to the million of points specialists give, etc. I fixed the bugs that stopped me from making modules, but there is lots of questionable stuff around.

    events: don't work modular at all. You get really weird errors here. Not a big deal as modules rarely use this.

    readpass3 seems odd too. I doubt they have tested it much in WoC. I wonder if copynondefault works here at all.

    On the other hand, in RoM they seems to use lots of modular modmods. So either they don't use fancy tags, only add thigs rather than changing it, or there are some SDK changes (which I doubt, but haven't looked at it)
     
  10. xienwolf

    xienwolf Deity

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
    My pass3 is rather different from the basic WoCLite pass3, mostly because I have more complicated pass3 tags in most places, but also because I didn't think that their pass3 looked like it would work properly. I had tested it when rewriting it though, so for at least one file it works (can't recall which I tested with though)
     
  11. Sephi

    Sephi Deity

    Joined:
    Jan 25, 2009
    Messages:
    2,951
    Did you test the copynondefault? I only tested one readpass3 tag so far, but it didn't work. Prereqciv (which is similar to upgradeciv in unitinfos) for Gilden in unitinfos is set to CIVILIZATION_LJOSALFAR, in the module modifiying Gilden it isn't listed. The game loads NO_CIVILIZATION for Gilden. If I add CIVILIZATION_LJOSALFAR to the module the game loads the value CIVILIZATION_LJOSALFAR for Gilden.

    I debugged readpass3 and CIVILIZATION_LJOSALFAR shows up in the array used for the pushback only if it is listed in the module.
     
  12. Sephi

    Sephi Deity

    Joined:
    Jan 25, 2009
    Messages:
    2,951
    might as well post the sourcecode, maybe you can spot the problem.

    Code:
    //XML LOAD
    	pXML->GetChildXmlValByName(szTextVal, "PrereqCiv","NO_CIVILIZATION");
        m_aszExtraXML1forPass3.push_back(szTextVal);
    //READPASS3
    	iSize = m_aszExtraXML1forPass3.size();
    	for ( int i = 0; i < iSize; i++ )
    	{
    		if ( GC.getInfoTypeForString(m_aszExtraXML1forPass3[i], true) != -1)
    		{
                m_iPrereqCiv = GC.getInfoTypeForString(m_aszExtraXML1forPass3[i]);
    			break;
    		}
    	}
    	m_aszExtraXML1forPass3.clear();
    //copynondefaults
    	for ( int i = 0; i < pClassInfo->getPrereqCivVectorSize(); i++ )
    	{
    		m_aszExtraXML1forPass3.push_back(pClassInfo->getPrereqCivVectorElement(i));
    	}
    
     
  13. xienwolf

    xienwolf Deity

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
    Ok, so while reading it picks up the text key and tacks it on at the end of the list (which is empty as I don't re-use the list, so there is now one entry)

    Next would be the CND, if the pClassInfo held any data for this tag (which it will, since NO_CIVILIZATION is loaded if tag is excluded), then whatever it holds is placed at the END of the list. So whatever was in the module (last loaded) will always be listed first.

    Final is the pass3 to translate it. This will go through the list and load the first entry it finds which is NOT NO_CIVILIZATION, thus the LAST module loaded which was non-blank (or the original file if all modules were blank).

    Potential issue: What is that True for in the IF (getInfo) check? Is that giving false non-negatives? I should do a temp variable which stores the integer for getInfoType, and then check in the IF that the temp variable is not -1.

    Other potential issue: Pretty sure that m_iPrereqCiv has a default of -1 when the info class is built, but if not, then it ought to store a -1 here in the case of all fields in the list being NO_CIVILIZATION.


    So it looks like it OUGHT to work. That true in the IF check could cause some issues, I have a vague recollection of that either ignoring a silly assert, or allowing new items to be added. The second makes little sense, but would cause issues if it is the accurate memory.

    EDIT: Correction: there is no break; in the IF check, so what you will keep is the last actual entry in the list, thus the original XML or the first module which was loaded with the field filled. That needs fixed.

    You could also tell CND not to use the pushback command on any entry which == NO_CIVILIZATION
     
  14. Sephi

    Sephi Deity

    Joined:
    Jan 25, 2009
    Messages:
    2,951
    I checked and prereqciv is initialized as -1
    Don't think it is the true.
    Code:
    int CvGlobals::getInfoTypeForString(const char* szType, bool hideAssert) const
    	{
    	FAssertMsg(szType, "null info type string");
    	InfosMap::const_iterator it = m_infosMap.find(szType);
    	if (it!=m_infosMap.end())
    	{
    		return it->second;
    	}
    
    	if(!hideAssert)
    	{
    		CvString szError;
    		szError.Format("info type %s not found, Current XML file is: %s", szType, GC.getCurrentXMLFile().GetCString());
    		FAssertMsg(strcmp(szType, "NONE")==0 || strcmp(szType, "")==0, szError.c_str());
    		gDLL->logMsg("xml.log", szError);
    	}
    
    	return -1;
    }
    
     
  15. xienwolf

    xienwolf Deity

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
    Editted previous post, re-read it after getting Xien to sleep and noticed something. Looks like my first memory was right about the purpose of the true. Ought to be false there anyway just to help XML only modders in case they make a typo.
     
  16. Valkrionn

    Valkrionn The Hamster King

    Joined:
    May 23, 2008
    Messages:
    14,450
    Location:
    Crestview FL
    Hmm. Trying to allow promotions to affect buildorders, but I can't tell if it should be done in CvPlayer::CanBuild or CvUnit::CanBuild?
     
  17. odalrick

    odalrick Emperor

    Joined:
    Nov 12, 2003
    Messages:
    1,114
    They must work somewhat. I disable the "Goblins permanently damage your territory" event and raise the cost of the prophets to 250:gold:. As far as I can tell, it works flawlessly.

    Once I added the option to clean up the damage caused by the goblins for 50:gold: and that worked too.
     
  18. xienwolf

    xienwolf Deity

    Joined:
    Oct 4, 2007
    Messages:
    10,589
    Location:
    Location! Location!
    CvUnit. In CvPlayer it is mostly just checking for Technologies and other things which are a quick way to eliminate the check for a lot of orders and make things faster. Once that has been checked, then the unit itself is checked (pretty sure you'll find that the CvPlayer one is called at the start of the CvUnit one actually)
     
  19. Sephi

    Sephi Deity

    Joined:
    Jan 25, 2009
    Messages:
    2,951
    you are correct, I should have been more accurate. When making events modular, a lot can go wrong. When I added the MoreEventsMod as a Module, I had errors all over the place. I only had to move the new events and triggers to the base files and the errors were completly gone.
     
  20. Sephi

    Sephi Deity

    Joined:
    Jan 25, 2009
    Messages:
    2,951
    I had tried it, but no luck. Will wait until you have the time to look at it in your rebuild.
     

Share This Page