[Freeciv-Dev] (PR#18325) [Patch] unit_class bools to bitvector
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#18325) [Patch] unit_class bools to bitvector |
From: |
"Marko Lindqvist" <cazfi74@xxxxxxxxx> |
Date: |
Wed, 5 Jul 2006 07:28:48 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=18325 >
This moves unit_class booleans in to bitvector. move_params structure
is removed in the process.
Applies on top of #18250
- ML
diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c 2006-07-05 16:48:02.188250000 +0300
+++ freeciv/client/packhand.c 2006-07-05 17:06:11.516375000 +0300
@@ -2134,10 +2134,9 @@
c = unit_class_get_by_id(p->id);
sz_strlcpy(c->name, p->name);
- c->move_type = p->move_type;
- c->move.terrain_affects = p->terrain_affects;
- c->move.damage_slows = p->damage_slows;
+ c->move_type = p->move_type;
c->hp_loss_pct = p->hp_loss_pct;
+ c->flags = p->flags;
}
diff -Nurd -X.diff_ignore freeciv/common/map.c freeciv/common/map.c
--- freeciv/common/map.c 2006-07-05 15:51:43.453875000 +0300
+++ freeciv/common/map.c 2006-07-05 17:00:39.407000000 +0300
@@ -636,7 +636,7 @@
return punit->moves_left;
}
- if (punit && !pclass->move.terrain_affects) {
+ if (punit && !unit_class_flag(pclass, UCF_TERRAIN_SPEED)) {
return SINGLE_MOVE;
}
diff -Nurd -X.diff_ignore freeciv/common/movement.c freeciv/common/movement.c
--- freeciv/common/movement.c 2006-07-05 16:48:02.953875000 +0300
+++ freeciv/common/movement.c 2006-07-05 17:01:29.657000000 +0300
@@ -51,7 +51,7 @@
move_rate = base_move_rate;
- if (pclass->move.damage_slows) {
+ if (unit_class_flag(pclass, UCF_DAMAGE_SLOWS)) {
/* Scale the MP based on how many HP the unit has. */
move_rate = (move_rate * punit->hp) / unit_type(punit)->hp;
}
diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def
--- freeciv/common/packets.def 2006-07-05 16:48:03.328875000 +0300
+++ freeciv/common/packets.def 2006-07-05 17:03:35.828875000 +0300
@@ -195,6 +195,7 @@
type REQ_RANGE = uint8(enum req_range)
type EFFECT_TYPE = uint8(enum effect_type)
type BV_IMPRS = bitvector(bv_imprs)
+type BV_UCLASS_FLAGS = bitvector(bv_unit_class_flags)
type BV_FLAGS = bitvector(bv_flags)
type BV_ROLES = bitvector(bv_roles)
type BV_TERRAIN_FLAGS = bitvector(bv_terrain_flags)
@@ -1256,9 +1257,8 @@
UINT8 id;
STRING name[MAX_LEN_NAME];
UINT8 move_type;
- BOOL terrain_affects;
- BOOL damage_slows;
UINT8 hp_loss_pct;
+ BV_UCLASS_FLAGS flags;
end
/*********************************************************
diff -Nurd -X.diff_ignore freeciv/common/unittype.c freeciv/common/unittype.c
--- freeciv/common/unittype.c 2006-07-05 16:48:03.485125000 +0300
+++ freeciv/common/unittype.c 2006-07-05 16:51:42.625750000 +0300
@@ -122,6 +122,15 @@
}
/**************************************************************************
+ Return whether the given unit class has the flag.
+**************************************************************************/
+bool unit_class_flag(const struct unit_class *punitclass, int flag)
+{
+ assert(flag >= 0 && flag < UCF_LAST);
+ return BV_ISSET(punitclass->flags, flag);
+}
+
+/**************************************************************************
Return whether the unit has the given flag.
**************************************************************************/
bool unit_flag(const struct unit *punit, enum unit_flag_id flag)
diff -Nurd -X.diff_ignore freeciv/common/unittype.h freeciv/common/unittype.h
--- freeciv/common/unittype.h 2006-07-05 16:48:03.672625000 +0300
+++ freeciv/common/unittype.h 2006-07-05 16:52:07.438250000 +0300
@@ -31,17 +31,14 @@
UCF_LAST
};
-struct move_params {
- bool terrain_affects; /* Move rate is subject to terrain and improvement
effects */
- bool damage_slows; /* Damaged unit is slowed down */
-};
+BV_DEFINE(bv_unit_class_flags, UCF_LAST);
struct unit_class {
Unit_Class_id id;
char name[MAX_LEN_NAME];
enum unit_move_type move_type;
- struct move_params move;
int hp_loss_pct; /* Percentage of hitpoints lost each turn not in
city or airbase */
+ bv_unit_class_flags flags;
};
/* Unit "special effects" flags:
@@ -217,6 +214,8 @@
enum unit_move_type get_unit_move_type(const struct unit_type *punittype);
struct unit_class *unit_class_get_by_id(int id);
+bool unit_class_flag(const struct unit_class *punitclass, int flag);
+
struct unit_class *get_unit_class(const struct unit_type *punittype);
const char *unit_name(const struct unit_type *punittype);
const char *unit_name_orig(const struct unit_type *punittype);
diff -Nurd -X.diff_ignore freeciv/server/ruleset.c freeciv/server/ruleset.c
--- freeciv/server/ruleset.c 2006-07-05 16:48:04.969500000 +0300
+++ freeciv/server/ruleset.c 2006-07-05 17:08:25.610125000 +0300
@@ -1058,8 +1058,7 @@
mystrlcat(tmp, ".move_type", 200);
ut->move_type = lookup_move_type(file, tmp, filename);
- ut->move.terrain_affects = FALSE;
- ut->move.damage_slows = FALSE;
+ BV_CLR_ALL(ut->flags);
slist = secfile_lookup_str_vec(file, &nval, "%s.flags", csec[i]);
for(j = 0; j < nval; j++) {
sval = slist[j];
@@ -1071,12 +1070,7 @@
freelog(LOG_ERROR, "for unit_class \"%s\": bad flag name \"%s\" (%s)",
ut->name, sval, filename);
}
- if (ival == UCF_TERRAIN_SPEED) {
- ut->move.terrain_affects = TRUE;
- }
- if (ival == UCF_DAMAGE_SLOWS) {
- ut->move.damage_slows = TRUE;
- }
+ BV_SET(ut->flags, ival);
}
free(slist);
@@ -2686,9 +2680,8 @@
packet.id = c->id;
sz_strlcpy(packet.name, c->name);
packet.move_type = c->move_type;
- packet.terrain_affects = c->move.terrain_affects;
- packet.damage_slows = c->move.damage_slows;
packet.hp_loss_pct = c->hp_loss_pct;
+ packet.flags = c->flags;
lsend_packet_ruleset_unit_class(dest, &packet);
} unit_class_iterate_end;
diff -Nurd -X.diff_ignore freeciv/version.in freeciv/version.in
--- freeciv/version.in 2006-07-05 16:48:05.110125000 +0300
+++ freeciv/version.in 2006-07-05 16:49:59.641375000 +0300
@@ -24,4 +24,4 @@
# - Avoid adding a new manditory capbility to the development branch for
# as long as possible. We want to maintain network compatibility with
# the stable branch for as long as possible.
-FREECIV_NETWORK_CAPSTRING("+Freeciv.Devel.2006.Jul.05")
+FREECIV_NETWORK_CAPSTRING("+Freeciv.Devel.2006.Jul.05-2")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#18325) [Patch] unit_class bools to bitvector,
Marko Lindqvist <=
|
|