I have tried several times to work with the freeciv source code, but every time I am unable to due to the complexity of it. Consequently, I think that some c coding tutorials for freeciv would lower the required skill level to contribute to freeciv.
A few things I would like to see tutorials for are adding an action, adding a variable to an object (unit type, building, etc.), and adding a function to be called by Lua.
C coding tutorials
C coding tutorials
Civ 3 tileset: viewtopic.php?t=92953
3d Irrlicht desktop client development: viewtopic.php?t=92289&start=20
3d Irrlicht desktop client development: viewtopic.php?t=92289&start=20
Re: C coding tutorials
If it is any tutorial to easy support a work on freeciv i go
Re: C coding tutorials
Meanwhile, if you know an already implemented patch that does similar thing to what you want to do, check through that patch to see where and how it implements the changes.
Re: C coding tutorials
Github search by commits generally helps you. Also, data structures and some algorithms are mostly documented somewhere in the code, read it.
Re: C coding tutorials
That's a great idea! I have previously tried to find patches for what I wanted to do on OSDN, but many older patches are not on there (or at least I couldn't find them). However, the patch's age means that many of them are very out of date and no longer applicable. For example, trying to make a nation req, the most recent requirement patch for units is the improvement req patch, from 2003.
https://github.com/freeciv/freeciv/comm ... ff=unified
As you can see, some of the affected files don't exist and the rest are very different, which makes it a lot harder for someone with no c coding experience to figure out. However, it is certainly better than nothing!
https://github.com/freeciv/freeciv/comm ... ff=unified
As you can see, some of the affected files don't exist and the rest are very different, which makes it a lot harder for someone with no c coding experience to figure out. However, it is certainly better than nothing!
Civ 3 tileset: viewtopic.php?t=92953
3d Irrlicht desktop client development: viewtopic.php?t=92289&start=20
3d Irrlicht desktop client development: viewtopic.php?t=92289&start=20
Re: C coding tutorials
It's certainly more work, and maybe still not feasible, but it would make sense to evaluate what are the remaining obstacles preventing using full requirements vectors for units, resolving those issues, and then taking requirement vectors to use, instead of adding another single(!) requirement support as a special case.
Re: C coding tutorials
It makes sense, but I have very little c coding experience, and it would be a lot easier to add a nation req (all that would be needed is a nation_req field for units, and to prevent them from being built if it is not satisfied. The AI wouldn't need to be notified because there is nothing anyone could do to build a uu unless they are of the right nation)
Civ 3 tileset: viewtopic.php?t=92953
3d Irrlicht desktop client development: viewtopic.php?t=92289&start=20
3d Irrlicht desktop client development: viewtopic.php?t=92289&start=20
Re: C coding tutorials
Ok, I guess there's already bunch to learn about freeciv code even for the "simple" addition of nation requirement. The full implementation will require something like: (but you can test parts of it with less)
1) Add the nation requirement to the unit_type structure
2) Check that requirement in relevant function(s) ("can_...build...")
3) Read the nation requirement from the ruleset, in the server side (server/ruleset.c)
At this point the server side should already enforce the rule. The client side UI is not aware of the restrictions (so likely it allows you to try illegal things, which server then rejects)
4) Add that requirement to network protocol (common/networking/packets.def, ruleset_unit or some such packet)
5) Bump network protocol capstring (fc_version in the source root directory)
6) Fill that network packet with the new field, in the server side (server/ruleset.c, send_...() )
7) Set the value to unit_type structure from the packet, in the client side (client/packhand.c)
Now also client side should work sensibly.
8) Add documentation comments to supplied rulesets & data/ruledit/comments.txt
9) Add saving the new nation requirement informatino to the rulesets (from ruledit or ruleup) to tools/ruleutil/rulesave.c
1) Add the nation requirement to the unit_type structure
2) Check that requirement in relevant function(s) ("can_...build...")
3) Read the nation requirement from the ruleset, in the server side (server/ruleset.c)
At this point the server side should already enforce the rule. The client side UI is not aware of the restrictions (so likely it allows you to try illegal things, which server then rejects)
4) Add that requirement to network protocol (common/networking/packets.def, ruleset_unit or some such packet)
5) Bump network protocol capstring (fc_version in the source root directory)
6) Fill that network packet with the new field, in the server side (server/ruleset.c, send_...() )
7) Set the value to unit_type structure from the packet, in the client side (client/packhand.c)
Now also client side should work sensibly.
8) Add documentation comments to supplied rulesets & data/ruledit/comments.txt
9) Add saving the new nation requirement informatino to the rulesets (from ruledit or ruleup) to tools/ruleutil/rulesave.c