[Freeciv-Dev] [patch #3325] Allow custom types for governments to be used in effect requirements.

2012-06-23 Thread Henkutsu
Follow-up Comment #12, patch #3325 (project freeciv):

READY FOR TEST - Merged and diff'd against svn 21347.

I worked out the bug, took me all week as I manually mapped out all function
calls and struct types. I had restored the function that turns the packet
government struct into the real one accidentally. All I had to do was re-add
one line (g->flags = p->flags;) GAH!!

SUMMARY OF PATCH
Adds functionality Government Flags with regards to effects and unit
requirements.
* List of flags defined in governments.ruleset in similar manner to custom
unit flags.
* New optional government variable: flags = "", ""...
* New optional unit type variable: govflag_req - "". Functions identical to
gov_req but matches against government.flags instead of government.
* New effect requirement name: "GovFlag". Functions identical to "Gov" but can
match against multiple governments.

CODE FILES CHANGED:
client/
helpdata.c
packhand.c

common/
effects.c
fc_types.h
game.c
government.c
government.h
packets.def
packets.h
requirements.c
unittype.c
unittype.h

server/
cityturn.c
ruleset.c

RULESET CHANGES
Ruleset functionality unchanged but civ1, civ2, classic and experimental now
make use of government flag features. Documentation of new features has been
added to governments.ruleset of these 4 rulesets.

I submit this patch to for your approval.

Whew! I have learned so much doing this.

(file #15863)
___

Additional Item Attachment:

File name: GovFlags Basic Patch against svn 21347.diff Size:62 KB


___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #3325] Allow custom types for governments to be used in effect requirements.

2012-06-20 Thread Henkutsu
Follow-up Comment #11, patch #3325 (project freeciv):

Ignore that last one. I changed something and it doesn't work anymore.. time
for me to learn svn I guess. I'll try again next week... :(

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #3325] Allow custom types for governments to be used in effect requirements.

2012-06-18 Thread Henkutsu
Follow-up Comment #10, patch #3325 (project freeciv):

Here is the completed patch, diff'd against the latest nightly.

(file #15848)
___

Additional Item Attachment:

File name: governmentflags.diff   Size:24 KB


___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #3325] Allow custom types for governments to be used in effect requirements.

2012-06-18 Thread Henkutsu
Follow-up Comment #9, patch #3325 (project freeciv):

I am 99% sure the bug is in collect_production_targets(...) in climisc.c

My testing and many inserted debug comments shows everything else is working
behind the scenes.. it is just the client worklist window for some reason
won't add govreq flag units (using collect_production_targets) but will when
using collect_eventually_buildable_targets(). I have not updated ruleset files
but all tags I have added are optional so it doesn't really matter (except for
documentation.) I am going to make a diff and upload.

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #3325] Allow custom types for governments to be used in effect requirements.

2012-06-18 Thread Henkutsu
Follow-up Comment #8, patch #3325 (project freeciv):

Ok, just found why ALL the effects are working and server checking on whether
or not a unit can be built based on govflag_req is going fine, but city
production dialog doesn't know it can build a unit. 

Turns out the same bug happens if a unit requires a gov (i.e, this was an
existing bug, not something I did.)

Should I diff and upload now, or try my hand at fixing the bug (needs to pass
player. Function actually has a FIX ME on it.)?

Bug is in climisc.c/h

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #3325] Allow custom types for governments to be used in effect requirements.

2012-06-18 Thread Henkutsu
Follow-up Comment #7, patch #3325 (project freeciv):

It's WORKING! I just started a game with it. Everything is getting read in
correctly and effects are getting matched against everything. There is still
some general weirdness (bonus to tiles shows up in the output but not in
display and units can't get built unless you use the 'show future options')
but I can get that figured out later. For now, I am just happy that it seems
nothing else is broke.

for reference, the .ruleset flags are:
In governments.ruleset
[governmentflags]
flags = "Foo", "Bar", "Test"
 (no _ as that makes the parser think flags is a gov)

[government_democracy]
flags = "Liberty", "Freedom", "TV"

in effects.ruleset
"type", "name", "range"
"GovFlag", "Foo", "Player"

in units.ruleset
[unit_meatsack]
govflag_req = "TV"

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #3325] Allow custom types for governments to be used in effect requirements.

2012-06-17 Thread Henkutsu
Follow-up Comment #6, patch #3325 (project freeciv):

Heck yeah, 9 functions left to write and this is ready! (for testing)
The only warnings/errors I am getting are for undefined functions. Everything
else seems to be in order an I even got the unit govflag_req thing working.

I have decided that if a gov_req exists for unit production, you don't even
check govflag_req. It is still loaded and validated in ruleset.c but when it
is time to actually check if you can build it, govflag_req gets skipped. It
seems the most logical thing to do.

Whoever wrote those mindboggling #define structures was either a genius or a
madman. Possibly both. I am too afraid to use most of them.

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #3322] Resource requirements

2012-06-17 Thread Henkutsu
Follow-up Comment #7, patch #3322 (project freeciv):

Wow! Thanks for your work.

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #3325] Allow custom types for governments to be used in effect requirements.

2012-06-17 Thread Henkutsu
Follow-up Comment #5, patch #3325 (project freeciv):

Hmm. I have another problem I need to sort through in rulesets.c.

Are requirements in [unit_type] && or ||? That is, if a unit has gov_req =
"SomeMilitaryGov" and govflag_req = "NotAMilitaryGov", does that mean that a
unit can never be built, does it mean that if either are true it can be built,
or does it cause an error? If it is the former, a valid req list would only be
where gov_req was a subset of govflag_req. In that case, should I make it an
error if both are filled, and have only the gov_req applied? 

In other words, if gov_req!=NULL : govflag_req=NULL ?

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #3325] Allow custom types for governments to be used in effect requirements.

2012-06-17 Thread Henkutsu
Follow-up Comment #4, patch #3325 (project freeciv):

Thanks for the pickup. I've fixed it all (all enums related to gov flag now
start with G_). I've taken gorbs advice and been running make clean / make
every time I save a file, so now I am compiling with no warnings/errors w/
regard to:
cityturn.c
requirements.c
effects.c
fc_types.h
packets.h
packets.def
helpdata.c
unittype.h

I've mostly got government.h done. Just need to make sure my prototyping
matches and mostly I just need to finish filling out functions in
government.c.

The only real problem I am having is that I REALLY want to add government
flags as an optional requirement for units. I have everything done in that
respect except lookup_government_flag. I know it has to work differently from
lookup_government as instead of counting through sections, I have to look for
the section government_flags.names, count through it and match to
unit_type.govflag_req. I am sure I can do it with a bit more time but it is
giving me a headache.

On the whole though, I am pretty confident I'll get it working within the next
few days, and that makes me happy.

Food for thought; with this implemented, should 'Default' and 'NoGov' be
turned into flags to match with how it is done with units? Furthermore, it
seems that 'Fanatics' could be done by the ruleset maker, meaning it can be
removed from the code...

Ah well, back to it!

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #3325] Allow custom types for governments to be used in effect requirements.

2012-06-17 Thread Henkutsu
Follow-up Comment #1, patch #3325 (project freeciv):

O.k. I've spent all day working on it and I am starting to get my head around
it. I am not messing with requirements yet, just working on getting flags read
from the ruleset, stored in the government struct and passed around correctly.
In this sense, I think I have finished with ruleset.c and have gotten fair far
in fc_types.h, governments.h/c.

Could someone look over my in progress ruleset.c and see if I have done
anything drastically stupid? As I keep saying, I am not a programmer, but I
would love to get this working.
(uploaded file to bugtracker)

(file #15833)
___

Additional Item Attachment:

File name: ruleset.c  Size:184 KB


___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #3322] Resource requirements

2012-06-16 Thread Henkutsu
Follow-up Comment #2, patch #3322 (project freeciv):

I can see two ways in which you would want to search for a resource; Just for
itself, and for it on a terrain. e.g. 
; Voting governments have a senate that may prevent war

; any fish
reqs =
{ "type", "name", "range"
"Resource", "(Fish)", "Adjacent"
} 

; only lake fish
reqs =
{ "type", "name", "range"
"Terrain", "Lake (Fish)", "Adjacent"
}

So which is more extensible? The first seems simpler but there is no way to
get the information of the tile back. Putting a terrain req below it will
match even if the terrain is in another square on any range other than
CityCentre or Local (Am I correct on this?). As such, I recommend the second
way. Even though it takes may take more reqs to define events, it seems a more
powerful method.

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #3326] Change range for city gov from -20<>20 to -inf<-19<>20

2012-06-16 Thread Henkutsu
Follow-up Comment #2, patch #3326 (project freeciv):

Hmm. Seems that the minimum surplus value is left to the client to decide, and
is a signed int. Does that mean it could be set to -128 or -256? Still better
than -20, it would take some effort to reach that low.

If an edge case is a problem and difficult to fix, move it out of the way and
throw a rug on it. :P
 - Awesome teacher I once had.

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #3326] Change range for city gov from -20<>20 to -inf<-19<>20

2012-06-16 Thread Henkutsu
URL:
  

 Summary: Change range for city gov from -20<>20 to
-inf<-19<>20
 Project: Freeciv
Submitted by: henkutsu_tama
Submitted on: Sat 16 Jun 2012 10:46:11 PM GMT
Category: general
Priority: 5 - Normal
  Status: None
 Privacy: Public
 Assigned to: None
Originator Email: 
 Open/Closed: Open
 Discussion Lock: Any
 Planned Release: 

___

Details:

By -inf, I mean that the cma just won't care how low that value goes, it has
no bottom. This would solve the problem with bug #18767, as you can simply
tell the cma to not care if the city is in deficit.  




___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #3325] Allow custom types for governments to be used in effect requirements.

2012-06-16 Thread Henkutsu
URL:
  

 Summary: Allow custom types for governments to be used in
effect requirements.
 Project: Freeciv
Submitted by: henkutsu_tama
Submitted on: Sat 16 Jun 2012 10:36:38 PM GMT
Category: general
Priority: 5 - Normal
  Status: None
 Privacy: Public
 Assigned to: None
Originator Email: 
 Open/Closed: Open
 Discussion Lock: Any
 Planned Release: 

___

Details:

I am fairly sure this would be a big project (I am not a programmer), needing
changes to;
fc_types.h
requirements.h
packets.def ?
governments.c
governments.h
effects.h
(perhaps adding govtypes.c/h as well?)

But it looks like most of the code can be copied from the infrastructure
needed for unit types, and there are good reasons for doing it:

After reading through all the rulesets I can get my hands on, (aliens,
ancients, Civ2-3, etc) and writing my own I have notice that there is a huge
amount of repetition when tying effects to governments, and that repetition
increases the chances of errors/difficulty of modifying and lowers
readability.

Some time ago it was proposed on the wiki to radically change how governments
work; ethos, scope etc. Not all of these fit together well so there would have
to be relation rules.. and it becomes a mess. HOWEVER! Setting anarchy to 1
turn and (using my ruleset as an example) having 15 different governments
across a [3 (size),3 (focus),2 (antiquity)] matrix with their own quirks works
just as well, and seems to be understandable by the ai without any changes.
(need to do more testing). The only problem is defining everything, and the
amount of req{} nreq{} gets ridiculous. 

Being able to just write
; Voting governments have a senate that may prevent war
[effect_govtype_voting_senate]
type  = "Has Senate"
value   = 1
reqs=
{ "type",   "name",  "range"
  "GovType", "Voting",  "Player"
}

; Economically geared societies gain a trade bonus
[effect_govtype_voting_senate]
type= "Output_Inc_Tile"
value   = 1
reqs=
{ "type",   "name",  "range"
  "GovType", "FocusEconomy", "Player"
  "OutputType", "Trade", "Local"
}

; Unsophisticated governance leads to lazy loafers
[effect_govtype_primitive_production]
type= "Output_Penalty_Tile"
value   = 2
reqs=
{ "type",   "name",  "range"
  "GovType", "Primitive",  "Player"
}

or
; Temple effects reduced under 'rational' governments, unless it is a cult of
personality.
[effect_temple_rational]
type= "Make_Content"
value   = -1 
reqs=
{ "type",   "name",  "range"
  "GovType", "Rational",  "Player"
}
nreqs
{ "type",   "name",  "range"
  "GovType", "CultLeader",  "Player"
}
These are simple but common instances where flags would help. In more complex
situations, such as where a wonder improves the effect of a building, but only
under/in a different way under different governments.

Again, I am not a programmer. I can't svn or diff to save my life but I will
have a go at implementing this on a daily snapshot. If I can get it to work
(not likely, but I'll try), I'll upload the modified files and let someone
smarter diff them.





___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #3323] Allow requirement range "within city workable radius" for tile-based requirements?

2012-06-16 Thread Henkutsu
Follow-up Comment #3, patch #3323 (project freeciv):

First off, thanks for looking at this. I've been reading the codebase for two
other tickets I am about to open (I am not a programmer so I understand maybe
1/3 of it. Yay comments!), so I can see how expensive this could be.

With regards to fluctuations, how about if range where a number, like city
radius? I imagine small numbers would have the same effect as CAdj then Adj.
The ruleset maker could then decide what an acceptable distance from the city
to the target could be.

I did not know about the sell off. If a building requires a min size city and
the city shrinks, is it sold? Sounds like an expensive routine to check each
turn. Perhaps allow 'persists' or something similar so authors can choose to
have no further checks on the building until it obsoletes?

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #19815] ai won't utilize transports for settling with only 1 space.

2012-06-16 Thread Henkutsu
Follow-up Comment #4, bug #19815 (project freeciv):

Actually, thinking about it, a better solution would be to simply document in
the units.rulesets that for the ai to use a craft for settling, it should have
a capacity of at least 2. That way there is no need to muck around with the
ai.

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #19815] ai won't utilize transports for settling with only 1 space.

2012-06-16 Thread Henkutsu
Follow-up Comment #3, bug #19815 (project freeciv):

The problem is that the ai doesn't build bodyguards at the beginning. Not
until it meets an enemy or reaches a certain size and stops spamming settlers.
As a result, an ai on a small island with only small ships available will spam
settlers until it starves/goes broke without spreading.

Perhaps the bodyguard reservation should only come into effect once the
settler spam period is ended? This way the ai will at least have some citys on
other islands before it stops using transports.

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #3322] Resource requirements

2012-06-16 Thread Henkutsu
Follow-up Comment #1, patch #3322 (project freeciv):

Thanks. It would really expand the possibilities of what can be done. One of
the reasons I wanted to do this was so that I could lower the output of some
specials unless an appropriate facility is built in the city (which may have a
tech requirement).

___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #19815] ai won't utilize transports for settling with only 1 space.

2012-06-15 Thread Henkutsu
URL:
  

 Summary: ai won't utilize transports for settling with only 1
space.
 Project: Freeciv
Submitted by: henkutsu_tama
Submitted on: Sat 16 Jun 2012 06:13:12 AM GMT
Category: ai
Severity: 3 - Normal
Priority: 5 - Normal
  Status: None
 Assigned to: None
Originator Email: 
 Open/Closed: Open
 Release: 2.3.2
 Discussion Lock: Any
Operating System: GNU/Linux
 Planned Release: 

___

Details:

I have been experimenting with rulesets with the intent of making an
alternate, ai friendly ruleset and included the 'boats' unit from ancient era.
When starting a game map made of small islands it became obvious that the ai
wasn't expanding, even though they had 20+ city builder units. At first I
thought it was the speed of the boats that was the issue, because when I gave
the ai some unmodified triremes they utilized them. However, increasing the
speed of the 'boats' unit did not fix the problem. It wasn't until I increased
the transport capacity to 2 that the ai began to use the boats for
transportation.


How to test:
Put an ai on a small island (room for one city) and give them many settlers
and (adjacent to the settlers), any type of transport modified to have only
one capacity. The ai will not use it. Repeat again with the same save but with
the transport able to carry 2 units. The ai will use it.

NOTE: I have only tested this with settlers. I do not know if it effects other
units. I have tested this with the default ruleset, only changing the capacity
of the trireme.




___

Reply to this item at:

  

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev