Adjusting Railroad Movement With New Technology

BlueViper

Chieftain
Joined
May 11, 2004
Messages
5
I would like to adjust the Flat Rate Movement of Railroads from 10 to 20 when the person researches Industrialism.

Unfortunately, an error occurs when I try to edit the following code with an <iFlatMovementChange>:

<Type>ROUTE_RAILROAD</Type>
<Description>TXT_KEY_ROUTE_RAILROAD</Description>
<iValue>2</iValue>
<iMovement>20</iMovement>
<iFlatMovement>6</iFlatMovement>
<BonusType>BONUS_COAL</BonusType>
<Yields/>
<TechMovementChanges>
<TechFlatMovementChange>
<PrereqTech>TECH_INDUSTRIALISM</PrereqTech>
<iFlatMovementChange>-3</iFlatMovementChange>
</TechFlatMovementChange>

</TechMovementChanges>

I also tried <TechMovementChange> and then <iFlatMovementChange> with no luck, as well as <TechFlatMovementChanges> at the beginning.

Has anyone been able to adjust the flat movement rate of railroads using technology (like roads use Engineering)?

My last resort will most likely have to be increasing the road movement to a higher rate than railroads. :( (I hate this option, since I like the flat rate on railroads...it makes complete sense that infantry and tanks move that same speed WHILE ON the train)

Thanks for any help...I hope this doesn't require SDK either, since I haven't even tried going THAT deep into code...I'm not as good with code.
 
Your breaking the Schema, their is no <iFlatMovmentChange> tag, you cant just thinkup a none-existent tag and add it to the XML and expect it to magicaly do what you want it to, Civ4 XML loader dose not read minds :rolleyes:

From the Schema..

<ElementType name="TechMovementChange" content="eltOnly">
<element type="PrereqTech"/>
<element type="iMovementChange"/>
</ElementType>

So you could do a MovmentChange similar to what happens with Roads at Enginering but Flatmovment apears to be unchangable after its loaded. SDK moding would be required to change this.
 
Thanks for the info. Yeah, I found out that my errors were due to not updating the schema for the Misc XML. I fixed that problem, so now it loads the game, but doesn't apply the new XML (like you said, SDK doesn't know what to do with the new info).

So, I've decided to see if I can recode the .dll for the game and get it to work.

There are some really great tutorials on this site for XML, Python, and SDK - props to the writers!

Hopefully, all goes well and I'll be able to report back here with some results....or at least some great questions! :D
 
Ok, since last night, I've updated the XML files to have the language to change the flat rate movement of railroads from 10 to 20 with the discovery of Robotics.

I also updated the misc schema to recognize the new language, so now the XML doesn't give an error when loading.

Then, I used Kael's Adding New XML post, as well as his Installing and using the SDK post to modify some of the SDK files. Thanks Kael for the great info! :goodjob:

Here are the files I edited:
---In the ..\mods\MODNAME\assets\XML\misc\
CIV4MiscSchema.xml
CIV4RouteInfos.xml
---In the ..\Civ4_SDK_source\CvGameCoreDLL_v161\CvGameCoreDLL\
CvInfos.cpp
CvInfos.h

After compiling the EDITED CvGameCoreDLL.dll and adding it to the mod folder, it loads without errors, but doesn't give the change in the flat rate movement. All it shows is a '+movement' symbol in the tech tree (but no text with the symbol - this is due to the XML changes, not the SDK edits)

I attached me files in a ZIP for anyone to look at.



My changes in the CvInfos.cpp were:
m_piTechFlatMovementChange(NULL)

AND

SAFE_DELETE_ARRAY(m_piTechFlatMovementChange);

AND

int CvRouteInfo::getTechFlatMovementChange(int i) const
{
FAssertMsg(i < GC.getNumTechInfos(), "Index out of bounds");
FAssertMsg(i > -1, "Index out of bounds");
return m_piTechFlatMovementChange ? m_piTechFlatMovementChange : -1;
}


AND

pXML->SetVariableListTagPair(&m_piTechFlatMovementChange, "TechMovementChanges", GC.getTechInfo(), sizeof(GC.getTechInfo((TechTypes)0)), GC.getNumTechInfos());



For the CvInfos.h, I added 2 lines:
DllExport int getTechFlatMovementChange(int i) const;

AND

int* m_piTechFlatMovementChange;

(I just copied what was above those lines and added Flat)

Any help on furthering my SDK editing would be very helpful. I'm in the dark on how this all relates together and what to modify and how. :(

Thanks!
 
Thats quite a lot of progress so far, i'm impressed you got this done so quickly. Your data is now obviosly being loaded into the game, its just not triggering an effect.

I havent looked at any of the code involved with routes but you will likley need to make changes at the Player level (because each player must individual recive or not recive the bonus based on their aquisition of the Tech). Trace the calls to the Routes default Flatmovment data and see ware its being utilized and how its utilized. Trace the base movment and its modifier to see how the game stores knowlage of when the modifier is applied (probably a boolean in the Player Object). Then work out a means of doing the same with your new Flatmovment data. Be warned I suspect this will be a rather complex task.
 
Impaler[WrG] said:
Thats quite a lot of progress so far, i'm impressed you got this done so quickly. Your data is now obviosly being loaded into the game, its just not triggering an effect.

I havent looked at any of the code involved with routes but you will likley need to make changes at the Player level (because each player must individual recive or not recive the bonus based on their aquisition of the Tech). Trace the calls to the Routes default Flatmovment data and see ware its being utilized and how its utilized. Trace the base movment and its modifier to see how the game stores knowlage of when the modifier is applied (probably a boolean in the Player Object). Then work out a means of doing the same with your new Flatmovment data. Be warned I suspect this will be a rather complex task.

Thanks Impaler, but unfortunately, my luck runs out here...I am having no luck tracing where the game gets the movement rate info for roads or railroads and how it applies the changes within the game for each player. I've searched all the .cpp, .h, and XML files for references to movement, flatmovement, routeinfo, and techmovementchange with no luck on finding links. This is almost certainly due to my 0.03% grasp of SDK and XML code and how it works and directs info. So, I might have stumbled upon it somewhere, but I just don't have the knowledge of piecing the info together.

If you, or anyone reading this, has a better grasp of this code, and would be willing to assist me in creating this mod, I would appreciate it!

I'll try to help as much as I can, but I'm afraid my help might be limited to seaching the files for certain lines of code and reporting back to a better coder who understands what I searched for.

Thanks!
 
I have developed some techniques for tracing from XML tag to SDK code, I assume your using the CodeBlocks editor and if not you atleast have an editor that can do a global search for any specified string.

Start by searching the tag itself stripped of < and >, this will probably find errorious hits but it should also find hits on the Infos.cpp in a read call, this is ware the data is being loaded from XML, find the data member its being placed in , its usualy proceeded by & and begins with m_.

Now global search that variable, you should find hits just on the Infos.h and Infos.cpp files, try to find the get function that has "return NAMEOFVARIABLE" as its only or almost only line of code. Now you can take the name of that function and global search for it as well. This will often result in many hits on a variety of files. GameText.cpp is one you can ignore for now as its only a passive output for the Pedia and help text. The most likly places to see a real interaction are the CvPlayer, CvCity and CvUnit classes.

At this point you should be into code which is activly using or preparing to use the data your searching for, its much less predictable from this point on so you will have to realy read and understand from top to bottom the code your looking at, their are probably other datamembers and functions interacting here across one or more classes. The quickest way to find the definition of any functions you see is to search for "::NAMEOFFUCNTION" meaning you want to preceed it with :: and leave off the () this should take you strait to the definition. To best understand the function search for all of its calls by searching without the ::

Hope this comes in handy
 
Back
Top Bottom