[Freeciv-Dev] (PR#14761) Remove negated requirements; Tentative roadmap
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#14761) Remove negated requirements; Tentative roadmap |
From: |
"Vasco Alexandre da Silva Costa" <vasco.costa@xxxxxxxxx> |
Date: |
Sat, 3 Dec 2005 12:35:54 -0800 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=14761 >
Hello,
I think I made a mistake to add negated requirements:
a) nothing in the present rulesets uses them.
b) they are redundant with effect nreqs.
c) they are feature creep.
d) they are bugged.
This patch removes them.
Suggestions of things to do in the future regarding generalization:
* Split reqs and nreqs checking, loading, etc, from effects.c, ruleset.c
into requirement.c. Like this:
struct deps {
struct requirement_list *reqs;
struct requirement_list *nreqs;
};
struct effect {
enum effect_type type;
int value;
struct deps deps;
};
* Reuse that code for improvement and units build deps. Somehow.
* Make unit (obsolete_by) and improvement (obsolete_by, replaced_by)
work the same way. The way improvements can be obsoleted seems to be
a superset of how units can be obsoleted, so it probably makes sense
to make everything like improvements. This code may even be shared.
* Should we make improvements and units even more alike?
Warcraft III did it.
Index: server/ruleset.c
===================================================================
--- server/ruleset.c (revision 11298)
+++ server/ruleset.c (working copy)
@@ -237,7 +237,7 @@
sec, sub, j));
j++) {
char *range;
- bool survives, negated;
+ bool survives;
struct requirement req;
name = secfile_lookup_str(file, "%s.%s%d.name", sec, sub, j);
@@ -245,10 +245,8 @@
survives = secfile_lookup_bool_default(file, FALSE,
"%s.%s%d.survives", sec, sub, j);
- negated = secfile_lookup_bool_default(file, FALSE,
- "%s.%s%d.negated", sec, sub, j);
- req = req_from_str(type, range, survives, negated, name);
+ req = req_from_str(type, range, survives, name);
if (req.source.type == REQ_LAST) {
/* Error. Log it, clear the req and continue. */
freelog(LOG_ERROR,
Index: common/dataio.c
===================================================================
--- common/dataio.c (revision 11298)
+++ common/dataio.c (working copy)
@@ -720,15 +720,14 @@
void dio_get_requirement(struct data_in *din, struct requirement *preq)
{
int type, range, value;
- bool survives, negated;
+ bool survives;
dio_get_uint8(din, &type);
dio_get_sint32(din, &value);
dio_get_uint8(din, &range);
dio_get_bool8(din, &survives);
- dio_get_bool8(din, &negated);
- *preq = req_from_values(type, range, survives, negated, value);
+ *preq = req_from_values(type, range, survives, value);
}
/**************************************************************************
@@ -737,14 +736,13 @@
void dio_put_requirement(struct data_out *dout, const struct requirement *preq)
{
int type, range, value;
- bool survives, negated;
+ bool survives;
- req_get_values(preq, &type, &range, &survives, &negated, &value);
+ req_get_values(preq, &type, &range, &survives, &value);
dio_put_uint8(dout, type);
dio_put_sint32(dout, value);
dio_put_uint8(dout, range);
dio_put_bool8(dout, survives);
- dio_put_bool8(dout, negated);
}
Index: common/packets.def
===================================================================
--- common/packets.def (revision 11298)
+++ common/packets.def (working copy)
@@ -1347,6 +1347,5 @@
REQ_RANGE range;
BOOL survives;
- BOOL negated;
end
Index: common/effects.c
===================================================================
--- common/effects.c (revision 11298)
+++ common/effects.c (working copy)
@@ -410,7 +410,7 @@
struct requirement req, *preq;
req = req_from_values(packet->source_type, packet->range, packet->survives,
- packet->negated, packet->source_value);
+ packet->source_value);
preq = fc_malloc(sizeof(*preq));
*preq = req;
@@ -437,16 +437,15 @@
requirement_list_iterate(peffect->reqs, preq) {
struct packet_ruleset_effect_req packet;
int type, range, value;
- bool survives, negated;
+ bool survives;
- req_get_values(preq, &type, &range, &survives, &negated, &value);
+ req_get_values(preq, &type, &range, &survives, &value);
packet.effect_id = id;
packet.neg = FALSE;
packet.source_type = type;
packet.source_value = value;
packet.range = range;
packet.survives = survives;
- packet.negated = FALSE;
lsend_packet_ruleset_effect_req(dest, &packet);
} requirement_list_iterate_end;
@@ -454,16 +453,15 @@
requirement_list_iterate(peffect->nreqs, preq) {
struct packet_ruleset_effect_req packet;
int type, range, value;
- bool survives, negated;
+ bool survives;
- req_get_values(preq, &type, &range, &survives, &negated, &value);
+ req_get_values(preq, &type, &range, &survives, &value);
packet.effect_id = id;
packet.neg = TRUE;
packet.source_type = type;
packet.source_value = value;
packet.range = range;
packet.survives = survives;
- packet.negated = FALSE;
lsend_packet_ruleset_effect_req(dest, &packet);
} requirement_list_iterate_end;
Index: common/requirements.c
===================================================================
--- common/requirements.c (revision 11298)
+++ common/requirements.c (working copy)
@@ -307,8 +307,7 @@
Pass this some values like "Building", "Factory".
****************************************************************************/
struct requirement req_from_str(const char *type, const char *range,
- bool survives, bool negated,
- const char *value)
+ bool survives, const char *value)
{
struct requirement req;
bool invalid = TRUE;
@@ -345,7 +344,6 @@
}
req.survives = survives;
- req.negated = negated;
/* These checks match what combinations are supported inside
* is_req_active(). */
@@ -388,10 +386,9 @@
break;
}
if (invalid) {
- freelog(LOG_ERROR, "Invalid requirement %s | %s | %s | %s | %s",
+ freelog(LOG_ERROR, "Invalid requirement %s | %s | %s | %s",
type, range,
- survives ? "survives" : "",
- negated ? "negated" : "", value);
+ survives ? "survives" : "", value);
req.source.type = REQ_LAST;
}
@@ -403,15 +400,13 @@
of req_get_values.
****************************************************************************/
struct requirement req_from_values(int type, int range,
- bool survives, bool negated,
- int value)
+ bool survives, int value)
{
struct requirement req;
req.source = req_source_from_values(type, value);
req.range = range;
req.survives = survives;
- req.negated = negated;
return req;
}
@@ -421,13 +416,11 @@
****************************************************************************/
void req_get_values(const struct requirement *req,
int *type, int *range,
- bool *survives, bool *negated,
- int *value)
+ bool *survives, int *value)
{
req_source_get_values(&req->source, type, value);
*range = req->range;
*survives = req->survives;
- *negated = req->negated;
}
/****************************************************************************
@@ -438,8 +431,7 @@
{
return (are_req_sources_equal(&req1->source, &req2->source)
&& req1->range == req2->range
- && req1->survives == req2->survives
- && req1->negated == req2->negated);
+ && req1->survives == req2->survives);
}
/****************************************************************************
@@ -865,11 +857,7 @@
return FALSE;
}
- if (req->negated) {
- return !eval;
- } else {
- return eval;
- }
+ return eval;
}
/****************************************************************************
Index: common/requirements.h
===================================================================
--- common/requirements.h (revision 11298)
+++ common/requirements.h (working copy)
@@ -78,8 +78,7 @@
struct requirement {
struct req_source source; /* requirement source */
enum req_range range; /* requirement range */
- bool survives; /* set if destroyed sources satisfy the req*/
- bool negated; /* set if the requirement is to be negated */
+ bool survives; /* set if destroyed sources satisfy the req */
};
#define SPECLIST_TAG requirement
@@ -103,14 +102,12 @@
enum req_range req_range_from_str(const char *str);
struct requirement req_from_str(const char *type, const char *range,
- bool survives, bool negated,
- const char *value);
+ bool survives, const char *value);
void req_get_values(const struct requirement *req, int *type,
- int *range, bool *survives, bool *negated,
- int *value);
+ int *range, bool *survives, int *value);
struct requirement req_from_values(int type, int range,
- bool survives, bool negated, int value);
+ bool survives, int value);
bool are_requirements_equal(const struct requirement *req1,
const struct requirement *req2);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#14761) Remove negated requirements; Tentative roadmap,
Vasco Alexandre da Silva Costa <=
|
|