Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9829) remove effect dio code
Home

[Freeciv-Dev] (PR#9829) remove effect dio code

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9829) remove effect dio code
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 26 Aug 2004 17:33:12 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9829 >

This patch handles effects via arrays in the packets rather than using 
DIO callbacks.

Vasco: IMO you should do the effects right in the building packet 
instead of in a separate "effects cache" packet (reminder: it's not a 
cache).  But if you insist I can rewrite this patch to use a new packet 
like you do.

See PR#9828.

jason

Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.397
diff -u -r1.397 packhand.c
--- client/packhand.c   26 Aug 2004 18:37:51 -0000      1.397
+++ client/packhand.c   27 Aug 2004 00:25:53 -0000
@@ -2329,7 +2329,17 @@
 
   b->effect = fc_malloc(sizeof(*b->effect) * (p->effect_count + 1));
   for (i = 0; i < p->effect_count; i++) {
-    b->effect[i] = p->effect[i];
+    b->effect[i].type = p->effect_type[i];
+    b->effect[i].range = p->effect_range[i];
+    b->effect[i].amount = p->effect_amount[i];
+    b->effect[i].survives = p->effect_survives[i];
+    b->effect[i].cond_bldg = p->effect_cond_bldg[i];
+    b->effect[i].cond_gov = p->effect_cond_gov[i];
+    b->effect[i].cond_adv = p->effect_cond_tech[i];
+    b->effect[i].cond_eff = p->effect_cond_eff[i];
+    b->effect[i].aff_unit = p->effect_aff_unit[i];
+    b->effect[i].aff_terr = p->effect_aff_terr[i];
+    b->effect[i].aff_spec = p->effect_aff_spec[i];
   }
   b->effect[p->effect_count].type = EFT_LAST;
 
Index: common/dataio.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/dataio.c,v
retrieving revision 1.11
diff -u -r1.11 dataio.c
--- common/dataio.c     2 Jun 2004 19:47:41 -0000       1.11
+++ common/dataio.c     27 Aug 2004 00:25:53 -0000
@@ -711,33 +711,3 @@
   dio_put_uint16(dout, pds->contact_turns_left);
   dio_put_uint8(dout, pds->has_reason_to_cancel);
 }
-
-void dio_get_effect(struct data_in *din, struct impr_effect *peffect)
-{
-  dio_get_uint8(din, (int *) &(peffect->type));
-  dio_get_uint8(din, (int *) &(peffect->range));
-  dio_get_sint16(din, &peffect->amount);
-  dio_get_uint8(din, &peffect->survives);
-  dio_get_uint8(din, (int *) &peffect->cond_bldg);
-  dio_get_uint8(din, &peffect->cond_gov);
-  dio_get_uint8(din, &peffect->cond_adv);
-  dio_get_uint8(din, (int *) &(peffect->cond_eff));
-  dio_get_uint8(din, (int *) &(peffect->aff_unit));
-  dio_get_uint8(din, (int *) &(peffect->aff_terr));
-  dio_get_uint16(din, (int *) &(peffect->aff_spec));
-}
-
-void dio_put_effect(struct data_out *dout, const struct impr_effect *peffect)
-{
-  dio_put_uint8(dout, peffect->type);
-  dio_put_uint8(dout, peffect->range);
-  dio_put_sint16(dout, peffect->amount);
-  dio_put_uint8(dout, peffect->survives);
-  dio_put_uint8(dout, peffect->cond_bldg);
-  dio_put_uint8(dout, peffect->cond_gov);
-  dio_put_uint8(dout, peffect->cond_adv);
-  dio_put_uint8(dout, peffect->cond_eff);
-  dio_put_uint8(dout, peffect->aff_unit);
-  dio_put_uint8(dout, peffect->aff_terr);
-  dio_put_uint16(dout, peffect->aff_spec);
-}
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.42
diff -u -r1.42 packets.def
--- common/packets.def  26 Aug 2004 18:37:52 -0000      1.42
+++ common/packets.def  27 Aug 2004 00:25:54 -0000
@@ -157,7 +157,6 @@
 type BIT_STRING                = bit_string(char)
 type WORKLIST          = worklist(struct worklist)
 type TECH_LIST         = tech_list(int)
-type EFFECT            = effect(struct impr_effect)
 
 # typedefs for enums
 type CLAUSE            = uint8(enum clause_type)
@@ -177,6 +176,8 @@
 type DIRECTION         = uint8(enum direction8)
 type ORDERS            = uint8(enum unit_orders)
 type SSET_TYPE         = uint8(enum sset_type)
+type EFFECT_TYPE       = uint8(enum effect_type)
+type EFFECT_RANGE      = uint8(enum effect_range)
 
 # typedefs for IDs
 type PLAYER            = UINT8
@@ -1159,8 +1160,19 @@
   IMPROVEMENT equiv_dupl[255:equiv_dupl_count];
   UINT8 equiv_repl_count;
   IMPROVEMENT equiv_repl[255:equiv_repl_count];
+
   UINT8 effect_count;
-  EFFECT effect[255:effect_count];  
+  EFFECT_TYPE effect_type[255:effect_count];
+  EFFECT_RANGE effect_range[255:effect_count];
+  SINT32 effect_amount[255:effect_count];
+  BOOL effect_survives[255:effect_count];
+  IMPROVEMENT effect_cond_bldg[255:effect_count];
+  GOVERNMENT effect_cond_gov[255:effect_count];
+  TECH effect_cond_tech[255:effect_count];
+  EFFECT_TYPE effect_cond_eff[255:effect_count];
+  UNIT_TYPE effect_aff_unit[255:effect_count];
+  TERRAIN effect_aff_terr[255:effect_count];
+  SPECIAL effect_aff_spec[255:effect_count];
 end
 
 PACKET_RULESET_TERRAIN=105;sc,lsend
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.190
diff -u -r1.190 ruleset.c
--- server/ruleset.c    25 Aug 2004 18:57:07 -0000      1.190
+++ server/ruleset.c    27 Aug 2004 00:25:57 -0000
@@ -2870,6 +2870,7 @@
     struct impr_type *b = &improvement_types[i];
     struct packet_ruleset_building packet;
     struct impr_effect *eff;
+    int j;
 
     packet.id = i;
     sz_strlcpy(packet.name, b->name_orig);
@@ -2904,11 +2905,22 @@
     T(equiv_repl, equiv_repl_count, B_LAST);
 #undef T
 
-    packet.effect_count = 0;
+    j = 0;
     for (eff = b->effect; eff->type != EFT_LAST; eff++) {
-      packet.effect[packet.effect_count] = *eff;
-      packet.effect_count++;
+      packet.effect_type[j] = eff->type;
+      packet.effect_range[j] = eff->range;
+      packet.effect_amount[j] = eff->amount;
+      packet.effect_survives[j] = eff->survives;
+      packet.effect_cond_bldg[j] = eff->cond_bldg;
+      packet.effect_cond_gov[j] = eff->cond_gov;
+      packet.effect_cond_tech[j] = eff->cond_adv;
+      packet.effect_cond_eff[j] = eff->cond_eff;
+      packet.effect_aff_unit[j] = eff->aff_unit;
+      packet.effect_aff_terr[j] = eff->aff_terr;
+      packet.effect_aff_spec[j] = eff->aff_spec;
+      j++;
     }
+    packet.effect_count = j;
 
     lsend_packet_ruleset_building(dest, &packet);
   } impr_type_iterate_end;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9829) remove effect dio code, Jason Short <=