Re: [Freeciv-Dev] (PR#40365) [Patch] Restore civ2/2.0.x resource conversion rules

2008-07-19 Thread Jason Dorje Short

http://bugs.freeciv.org/Ticket/Display.html?id=40365 >

Can we get a fix for 2.1 that uses an optional capability?

-jason


On 7/19/08, Daniel Markstedt <[EMAIL PROTECTED]> wrote:
>
> http://bugs.freeciv.org/Ticket/Display.html?id=40365 >
>
> On Sat, 19 Jul 2008 07:25:41 +0900, Madeline Book
> <[EMAIL PROTECTED]> wrote:
>
>>
>> http://bugs.freeciv.org/Ticket/Display.html?id=40365 >
>>
>> Actually I don't like the way the tier field is obtained
>> at the client side. It is brittle in that it assumes that
>> terrains are sent in the same order as the server reads
>> them from the ruleset. In other words, the protocol is
>> not stateless, and this could be annoying later. (Though
>> the potential for causing trouble of a bad tier field
>> value on the client side is rather minor.)
>>
>> For S2_1 then, this drawback would be acceptable in order
>> to not have to change packet formats, but for S2_2+ the
>> tier field should be sent in PACKET_RULESET_RESOURCE, to
>> remove the tier calculation from the client and keep it
>> "dumb".
>>
>> So I will re-work the S2_2/trunk version to make it more
>> robust in this manner.
>>
>> Are there any objections to having the S2_1 version committed
>> (depends on #40364) so that resource conversion behaves the
>> same as it did in 2.0/civ2? Also, no problems with splitting
>> the grassland "resources" resource into "animal resources"
>> and "plant resources"?
>>
>> Or we could just leave S2_1 as is and have these resource
>> conversion fixes/features for S2_2 only.
>>
>
> I would vote for the latter. My standpoint is to not introduce
> gameplay-altering changes between minor versions - for a number of reasons.
>
> Let's get 2.2 out the door asap instead. :)
>
>   ~Daniel
>
>
>
> ___
> Freeciv-dev mailing list
> Freeciv-dev@gna.org
> https://mail.gna.org/listinfo/freeciv-dev
>



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


Re: [Freeciv-Dev] (PR#40365) [Patch] Restore civ2/2.0.x resource conversion rules

2008-07-19 Thread Daniel Markstedt

http://bugs.freeciv.org/Ticket/Display.html?id=40365 >

On Sat, 19 Jul 2008 07:25:41 +0900, Madeline Book  
<[EMAIL PROTECTED]> wrote:

>
> http://bugs.freeciv.org/Ticket/Display.html?id=40365 >
>
> Actually I don't like the way the tier field is obtained
> at the client side. It is brittle in that it assumes that
> terrains are sent in the same order as the server reads
> them from the ruleset. In other words, the protocol is
> not stateless, and this could be annoying later. (Though
> the potential for causing trouble of a bad tier field
> value on the client side is rather minor.)
>
> For S2_1 then, this drawback would be acceptable in order
> to not have to change packet formats, but for S2_2+ the
> tier field should be sent in PACKET_RULESET_RESOURCE, to
> remove the tier calculation from the client and keep it
> "dumb".
>
> So I will re-work the S2_2/trunk version to make it more
> robust in this manner.
>
> Are there any objections to having the S2_1 version committed
> (depends on #40364) so that resource conversion behaves the
> same as it did in 2.0/civ2? Also, no problems with splitting
> the grassland "resources" resource into "animal resources"
> and "plant resources"?
>
> Or we could just leave S2_1 as is and have these resource
> conversion fixes/features for S2_2 only.
>

I would vote for the latter. My standpoint is to not introduce  
gameplay-altering changes between minor versions - for a number of reasons.

Let's get 2.2 out the door asap instead. :)

  ~Daniel



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


[Freeciv-Dev] (PR#40365) [Patch] Restore civ2/2.0.x resource conversion rules

2008-07-19 Thread Madeline Book

http://bugs.freeciv.org/Ticket/Display.html?id=40365 >

Actually I don't like the way the tier field is obtained
at the client side. It is brittle in that it assumes that
terrains are sent in the same order as the server reads
them from the ruleset. In other words, the protocol is
not stateless, and this could be annoying later. (Though
the potential for causing trouble of a bad tier field
value on the client side is rather minor.)

For S2_1 then, this drawback would be acceptable in order
to not have to change packet formats, but for S2_2+ the
tier field should be sent in PACKET_RULESET_RESOURCE, to
remove the tier calculation from the client and keep it
"dumb".

So I will re-work the S2_2/trunk version to make it more
robust in this manner.

Are there any objections to having the S2_1 version committed
(depends on #40364) so that resource conversion behaves the
same as it did in 2.0/civ2? Also, no problems with splitting
the grassland "resources" resource into "animal resources"
and "plant resources"?

Or we could just leave S2_1 as is and have these resource
conversion fixes/features for S2_2 only.


--
一体どうするかな

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


[Freeciv-Dev] (PR#40365) [Patch] Restore civ2/2.0.x resource conversion rules

2008-07-07 Thread Madeline Book

http://bugs.freeciv.org/Ticket/Display.html?id=40365 >

Attached patches implement civ2 style (i.e. 2.0.x) resource
conversion rules, with some slight caveats. Logically depends
on #40364.

A 'tier' field is added to 'struct resource'. Resources on the
same tier convert to each other, in essence emulating how
resources used to be either "special 1" or "special 2" in
the specials bit vector. The tier value is determined from
the order of the resource as listed in the terrain's
'resources' field in the terrain ruleset.

This would almost work with the ruleset files as they currently
are now, except that the grassland terrain's "Resources"
resource occurs only once. Therefore the patches add a
second "Resources" resource to the default and civ2 terrain
ruleset files.

Complicating the matter for S2_1, since resource names must
be unique to be able to be distinguished in the 'resources'
list, the two different kinds of "Resources" are renamed
"Animal Resources" and "Plant Resources" (which somewhat fits,
considering the resources in their respective tiers, though
I am open to better naming suggestions).

Similarly, "Petroleum" is added as the desert "Oil" resource
for S2_1's default terrain ruleset (oddly, this was already
present in its civ2 terrain ruleset).


High-level tile resource conversion is controlled by the
new function tile_convert_resource. This is where future
resource conversion rules can be implemented (which I will
submit in subsequent patches).

Also, a number of bugs were fixed where code would
temporarily modify a tile to see what would happen if its
terrain changed. Such code was modified to take into account
resource conversion.


--
リソースと言うのは止めて下さい
>From 90d77b34b9f67d9a7ec7aaf6de0ca5ee1911a4a5 Mon Sep 17 00:00:00 2001
From: Madeline Book <[EMAIL PROTECTED]>
Date: Mon, 7 Jul 2008 00:03:33 -0400
Subject: [PATCH] Restore civ2/freeciv terrain resource conversion.

---
 client/packhand.c|   10 +++
 common/terrain.c |   61 ++
 common/terrain.h |8 +
 common/tile.c|   57 +++
 common/tile.h|1 +
 data/civ2/terrain.ruleset|   13 +++-
 data/default/terrain.ruleset |   13 +++-
 server/generator/startpos.c  |4 +++
 server/maphand.c |2 +
 server/ruleset.c |   11 +++
 server/settlers.c|   12 
 11 files changed, 182 insertions(+), 10 deletions(-)

diff --git a/client/packhand.c b/client/packhand.c
index 8972017..6902981 100644
--- a/client/packhand.c
+++ b/client/packhand.c
@@ -2498,6 +2498,12 @@ void handle_ruleset_control(struct packet_ruleset_control *packet)
   popup_tileset_suggestion_dialog();
 }
   }
+
+  /* Resource "tier" is set in handle_ruleset_terrain.
+   * See resource_get_tier() for explanation. */
+  resource_type_iterate(presource) {
+presource->tier = -1;
+  } resource_type_iterate_end;
 }
 
 /**
@@ -2779,7 +2785,11 @@ void handle_ruleset_terrain(struct packet_ruleset_terrain *p)
   p->resources[j],
   terrain_rule_name(pterrain));
 }
+if (pterrain->resources[j] && pterrain->resources[j]->tier == -1) {
+  pterrain->resources[j]->tier = j;
+}
   }
+  pterrain->num_resources = p->num_resources;
   pterrain->resources[p->num_resources] = NULL;
 
   pterrain->road_time = p->road_time;
diff --git a/common/terrain.c b/common/terrain.c
index baa5d80..5cc2881 100644
--- a/common/terrain.c
+++ b/common/terrain.c
@@ -386,6 +386,31 @@ struct resource *resource_by_number(const Resource_type_id type)
 }
 
 /
+  Returns the "tier" for the given resource. This value corresponds to
+  the offset of the resource name in a terrain's 'resources' field as
+  listed in the terrain ruleset file. If a resource is listed in more
+  than one 'resources' list, then the tier value will correspond only
+  to the first one.
+
+  The tier value is primarily intended to be used to implement civ2
+  style resource conversion. The tier value thus corresponds to whether
+  the given resource was a "special1" or a "special2" in previous
+  terrain ruleset definitions. Generally, resources on the same
+  tier will convert to each other when terrain is changed.
+
+  Returns an integer greater than or equal to zero indicating the
+  tier, or -1 on invalid input or if not applicable (e.g. resource
+  is never listed in a terrain entry in the ruleset).
+/
+int resource_get_tier(const struct resource *presource)
+{
+  if (!presource) {
+return -1;
+  }
+  return presource->tier;
+}
+
+/***