forked from github/server
Merge pull request #603 from ennorehling/develop
fix bug 2253 and remove orcification
This commit is contained in:
commit
7b06c28708
17 changed files with 89 additions and 258 deletions
|
@ -16,7 +16,6 @@ matmod.c
|
|||
moved.c
|
||||
movement.c
|
||||
dict.c
|
||||
orcification.c
|
||||
otherfaction.c
|
||||
overrideroads.c
|
||||
racename.c
|
||||
|
|
|
@ -33,7 +33,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include "moved.h"
|
||||
#include "movement.h"
|
||||
#include "dict.h"
|
||||
#include "orcification.h"
|
||||
#include "otherfaction.h"
|
||||
#include "overrideroads.h"
|
||||
#include "racename.h"
|
||||
|
@ -120,6 +119,7 @@ void register_attributes(void)
|
|||
at_register(&at_germs);
|
||||
|
||||
at_deprecate("xontormiaexpress", a_readint); /* required for old datafiles */
|
||||
at_deprecate("orcification", a_readint); /* required for old datafiles */
|
||||
at_deprecate("lua", read_ext); /* required for old datafiles */
|
||||
at_deprecate("gm", a_readint);
|
||||
at_deprecate("guard", a_readint); /* used to contain guard-flags (v3.10.0-259-g8597e8b) */
|
||||
|
@ -133,7 +133,6 @@ void register_attributes(void)
|
|||
at_register(&at_keys);
|
||||
at_register(&at_follow);
|
||||
at_register(&at_targetregion);
|
||||
at_register(&at_orcification);
|
||||
at_register(&at_hate);
|
||||
at_register(&at_reduceproduction);
|
||||
at_register(&at_otherfaction);
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 1998-2015, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
**/
|
||||
|
||||
#include <platform.h>
|
||||
#include <kernel/config.h>
|
||||
#include "orcification.h"
|
||||
|
||||
#include <kernel/save.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
/*
|
||||
* simple attributes that do not yet have their own file
|
||||
*/
|
||||
|
||||
attrib_type at_orcification = {
|
||||
"orcification", NULL, NULL, NULL, a_writeint, a_readint, NULL, ATF_UNIQUE
|
||||
};
|
||||
|
||||
attrib *make_orcification(int orcification)
|
||||
{
|
||||
attrib *a = a_new(&at_orcification);
|
||||
a->data.i = orcification;
|
||||
return a;
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 1998-2015, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
**/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern struct attrib_type at_orcification;
|
||||
|
||||
extern struct attrib *make_orcification(int orcification);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -24,7 +24,6 @@ without prior permission by the authors of Eressea.
|
|||
|
||||
/* attributes include */
|
||||
#include <attributes/follow.h>
|
||||
#include <attributes/orcification.h>
|
||||
#include <attributes/otherfaction.h>
|
||||
#include <attributes/racename.h>
|
||||
#include <attributes/raceprefix.h>
|
||||
|
@ -1329,9 +1328,6 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
|||
if (fval(r->terrain, LAND_REGION)) {
|
||||
assert(r->land);
|
||||
fprintf(F, "%d;Bauern\n", rpeasants(r));
|
||||
if (fval(r, RF_ORCIFIED)) {
|
||||
fprintf(F, "1;Verorkt\n");
|
||||
}
|
||||
fprintf(F, "%d;Pferde\n", rhorses(r));
|
||||
|
||||
if (r->seen.mode >= seen_unit) {
|
||||
|
|
|
@ -69,7 +69,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
#include <attributes/reduceproduction.h>
|
||||
#include <attributes/racename.h>
|
||||
#include <attributes/orcification.h>
|
||||
|
||||
/* libs includes */
|
||||
#include <math.h>
|
||||
|
@ -498,13 +497,6 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders)
|
|||
return;
|
||||
}
|
||||
|
||||
if (fval(r, RF_ORCIFIED)) {
|
||||
if (rc != get_race(RC_ORC)) {
|
||||
cmistake(u, ord, 238, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (recruitcost) {
|
||||
pl = getplane(r);
|
||||
if (pl && fval(pl, PFL_NORECRUITS)) {
|
||||
|
|
36
src/give.c
36
src/give.c
|
@ -34,7 +34,6 @@
|
|||
|
||||
/* attributes includes */
|
||||
#include <attributes/racename.h>
|
||||
#include <attributes/orcification.h>
|
||||
|
||||
/* util includes */
|
||||
#include <util/attrib.h>
|
||||
|
@ -224,15 +223,11 @@ static bool unit_has_cursed_item(const unit * u)
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool can_give_men(const unit *u, order *ord, message **msg) {
|
||||
if (u_race(u) == get_race(RC_SNOTLING)) {
|
||||
/* snotlings may not be given to the peasants. */
|
||||
if (msg) *msg = msg_error(u, ord, 307);
|
||||
}
|
||||
else if (unit_has_cursed_item(u)) {
|
||||
static bool can_give_men(const unit *u, const unit *dst, order *ord, message **msg) {
|
||||
if (unit_has_cursed_item(u)) {
|
||||
if (msg) *msg = msg_error(u, ord, 78);
|
||||
}
|
||||
else if (has_skill(u, SK_MAGIC)) {
|
||||
else if (dst && (has_skill(u, SK_MAGIC) && dst->number > 0)) {
|
||||
/* cannot give units to and from magicians */
|
||||
if (msg) *msg = msg_error(u, ord, 158);
|
||||
}
|
||||
|
@ -263,9 +258,9 @@ message * give_men(int n, unit * u, unit * u2, struct order *ord)
|
|||
message * msg;
|
||||
int maxt = max_transfers();
|
||||
|
||||
assert(u2);
|
||||
assert(u2); // use disband_men for GIVE 0
|
||||
|
||||
if (!can_give_men(u, ord, &msg)) {
|
||||
if (!can_give_men(u, u2, ord, &msg)) {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
@ -400,20 +395,21 @@ message * give_men(int n, unit * u, unit * u2, struct order *ord)
|
|||
|
||||
message * disband_men(int n, unit * u, struct order *ord) {
|
||||
message * msg;
|
||||
static const race *rc_snotling;
|
||||
static int rccache;
|
||||
|
||||
if (!can_give_men(u, ord, &msg)) {
|
||||
if (rc_changed(&rccache)) {
|
||||
rc_snotling = get_race(RC_SNOTLING);
|
||||
}
|
||||
|
||||
if (u_race(u) == rc_snotling) {
|
||||
/* snotlings may not be given to the peasants. */
|
||||
return msg_error(u, ord, 307);
|
||||
}
|
||||
if (!can_give_men(u, NULL, ord, &msg)) {
|
||||
return msg;
|
||||
}
|
||||
transfermen(u, NULL, n);
|
||||
#ifdef ORCIFICATION
|
||||
if (u_race(u) == get_race(RC_SNOTLING) && !fval(u->region, RF_ORCIFIED)) {
|
||||
attrib *a = a_find(u->region->attribs, &at_orcification);
|
||||
if (!a) {
|
||||
a = a_add(&u->region->attribs, a_new(&at_orcification));
|
||||
}
|
||||
a->data.i += n;
|
||||
}
|
||||
#endif
|
||||
if (fval(u->region->terrain, SEA_REGION)) {
|
||||
return msg_message("give_person_ocean", "unit amount", u, n);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ static void setup_give(struct give *env) {
|
|||
|
||||
static void test_give_unit_to_peasants(CuTest * tc) {
|
||||
struct give env;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f1 = test_create_faction(0);
|
||||
env.f2 = 0;
|
||||
setup_give(&env);
|
||||
|
@ -63,7 +63,7 @@ static void test_give_unit_to_peasants(CuTest * tc) {
|
|||
|
||||
static void test_give_unit(CuTest * tc) {
|
||||
struct give env;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f1 = test_create_faction(0);
|
||||
env.f2 = test_create_faction(0);
|
||||
setup_give(&env);
|
||||
|
@ -82,7 +82,7 @@ static void test_give_unit(CuTest * tc) {
|
|||
|
||||
static void test_give_unit_in_ocean(CuTest * tc) {
|
||||
struct give env;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f1 = test_create_faction(0);
|
||||
env.f2 = 0;
|
||||
setup_give(&env);
|
||||
|
@ -94,7 +94,7 @@ static void test_give_unit_in_ocean(CuTest * tc) {
|
|||
|
||||
static void test_give_men(CuTest * tc) {
|
||||
struct give env;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f2 = env.f1 = test_create_faction(0);
|
||||
setup_give(&env);
|
||||
CuAssertPtrEquals(tc, 0, give_men(1, env.src, env.dst, NULL));
|
||||
|
@ -103,10 +103,41 @@ static void test_give_men(CuTest * tc) {
|
|||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_give_men_magicians(CuTest * tc) {
|
||||
struct give env;
|
||||
int p;
|
||||
message * msg;
|
||||
|
||||
test_setup();
|
||||
env.f2 = env.f1 = test_create_faction(0);
|
||||
setup_give(&env);
|
||||
set_level(env.src, SK_MAGIC, 1);
|
||||
CuAssertPtrNotNull(tc, msg = give_men(1, env.src, env.dst, NULL));
|
||||
CuAssertStrEquals(tc, "error158", (const char *)msg->parameters[3].v);
|
||||
CuAssertIntEquals(tc, 1, env.dst->number);
|
||||
CuAssertIntEquals(tc, 1, env.src->number);
|
||||
msg_release(msg);
|
||||
|
||||
|
||||
set_number(env.dst, 0);
|
||||
CuAssertPtrEquals(tc, NULL, give_men(1, env.src, env.dst, NULL));
|
||||
CuAssertIntEquals(tc, 1, env.dst->number);
|
||||
CuAssertIntEquals(tc, 0, env.src->number);
|
||||
|
||||
p = rpeasants(env.r);
|
||||
CuAssertPtrNotNull(tc, msg = disband_men(1, env.dst, NULL));
|
||||
CuAssertStrEquals(tc, "give_person_peasants", (const char *)msg->parameters[0].v);
|
||||
CuAssertIntEquals(tc, 0, env.dst->number);
|
||||
CuAssertIntEquals(tc, p+1, rpeasants(env.r));
|
||||
msg_release(msg);
|
||||
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_give_men_limit(CuTest * tc) {
|
||||
struct give env;
|
||||
message *msg;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f2 = test_create_faction(0);
|
||||
env.f1 = test_create_faction(0);
|
||||
setup_give(&env);
|
||||
|
@ -137,7 +168,7 @@ static void test_give_men_in_ocean(CuTest * tc) {
|
|||
struct give env;
|
||||
message * msg;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f1 = test_create_faction(0);
|
||||
env.f2 = 0;
|
||||
setup_give(&env);
|
||||
|
@ -151,7 +182,7 @@ static void test_give_men_in_ocean(CuTest * tc) {
|
|||
|
||||
static void test_give_men_too_many(CuTest * tc) {
|
||||
struct give env;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f2 = env.f1 = test_create_faction(0);
|
||||
setup_give(&env);
|
||||
CuAssertPtrEquals(tc, 0, give_men(2, env.src, env.dst, NULL));
|
||||
|
@ -164,7 +195,7 @@ static void test_give_men_none(CuTest * tc) {
|
|||
struct give env;
|
||||
message * msg;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f2 = env.f1 = test_create_faction(0);
|
||||
setup_give(&env);
|
||||
msg = give_men(0, env.src, env.dst, NULL);
|
||||
|
@ -179,7 +210,7 @@ static void test_give_men_other_faction(CuTest * tc) {
|
|||
struct give env;
|
||||
message * msg;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f1 = test_create_faction(0);
|
||||
env.f2 = test_create_faction(0);
|
||||
setup_give(&env);
|
||||
|
@ -198,7 +229,7 @@ static void test_give_men_requires_contact(CuTest * tc) {
|
|||
order *ord;
|
||||
char cmd[32];
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f1 = test_create_faction(0);
|
||||
env.f2 = test_create_faction(0);
|
||||
setup_give(&env);
|
||||
|
@ -222,7 +253,7 @@ static void test_give_men_requires_contact(CuTest * tc) {
|
|||
static void test_give_men_not_to_self(CuTest * tc) {
|
||||
struct give env;
|
||||
message * msg;
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f2 = env.f1 = test_create_faction(0);
|
||||
setup_give(&env);
|
||||
msg = give_men(1, env.src, env.src, NULL);
|
||||
|
@ -236,7 +267,7 @@ static void test_give_peasants(CuTest * tc) {
|
|||
struct give env;
|
||||
message * msg;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f1 = test_create_faction(0);
|
||||
env.f2 = 0;
|
||||
setup_give(&env);
|
||||
|
@ -252,7 +283,7 @@ static void test_give_peasants(CuTest * tc) {
|
|||
static void test_give(CuTest * tc) {
|
||||
struct give env;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f2 = env.f1 = test_create_faction(0);
|
||||
setup_give(&env);
|
||||
|
||||
|
@ -272,7 +303,7 @@ static void test_give_herbs(CuTest * tc) {
|
|||
struct order *ord;
|
||||
char cmd[32];
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
test_create_world();
|
||||
env.f2 = env.f1 = test_create_faction(0);
|
||||
setup_give(&env);
|
||||
|
@ -292,7 +323,7 @@ static void test_give_herbs(CuTest * tc) {
|
|||
static void test_give_okay(CuTest * tc) {
|
||||
struct give env;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f2 = env.f1 = test_create_faction(0);
|
||||
setup_give(&env);
|
||||
|
||||
|
@ -305,7 +336,7 @@ static void test_give_denied_by_rules(CuTest * tc) {
|
|||
struct give env;
|
||||
struct message *msg;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f1 = test_create_faction(0);
|
||||
env.f2 = test_create_faction(0);
|
||||
setup_give(&env);
|
||||
|
@ -320,7 +351,7 @@ static void test_give_dead_unit(CuTest * tc) {
|
|||
struct give env;
|
||||
struct message *msg;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f1 = test_create_faction(0);
|
||||
env.f2 = test_create_faction(0);
|
||||
setup_give(&env);
|
||||
|
@ -334,7 +365,7 @@ static void test_give_dead_unit(CuTest * tc) {
|
|||
static void test_give_new_unit(CuTest * tc) {
|
||||
struct give env;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f1 = test_create_faction(0);
|
||||
env.f2 = test_create_faction(0);
|
||||
setup_give(&env);
|
||||
|
@ -349,7 +380,7 @@ static void test_give_invalid_target(CuTest *tc) {
|
|||
struct give env;
|
||||
order *ord;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
env.f1 = test_create_faction(0);
|
||||
env.f2 = 0;
|
||||
setup_give(&env);
|
||||
|
@ -370,6 +401,7 @@ CuSuite *get_give_suite(void)
|
|||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_give);
|
||||
SUITE_ADD_TEST(suite, test_give_men);
|
||||
SUITE_ADD_TEST(suite, test_give_men_magicians);
|
||||
SUITE_ADD_TEST(suite, test_give_men_limit);
|
||||
SUITE_ADD_TEST(suite, test_give_men_in_ocean);
|
||||
SUITE_ADD_TEST(suite, test_give_men_none);
|
||||
|
|
|
@ -942,9 +942,6 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
|||
else if (fval(r->terrain, SEA_REGION)) {
|
||||
wage = 11;
|
||||
}
|
||||
else if (fval(r, RF_ORCIFIED)) {
|
||||
wage = wagetable[esize][1];
|
||||
}
|
||||
else {
|
||||
wage = wagetable[esize][2];
|
||||
}
|
||||
|
|
|
@ -92,10 +92,11 @@ struct message *msg_feedback(const struct unit *u, struct order *ord,
|
|||
if (!mtype) {
|
||||
log_warning("trying to create message of unknown type \"%s\"\n", name);
|
||||
if (!mt_find("missing_feedback")) {
|
||||
mt_register(mt_new_va("missing_feedback", "unit:unit", "region:region", "command:order", "name:string", 0));
|
||||
mt_register(mt_new_va("missing_feedback", "unit:unit",
|
||||
"region:region", "command:order", "name:string", 0));
|
||||
}
|
||||
return msg_message("missing_feedback", "unit region command name", u,
|
||||
u->region, ord, name);
|
||||
return msg_message("missing_feedback", "name unit region command",
|
||||
name, u, u->region, ord);
|
||||
}
|
||||
|
||||
var.v = (void *)u;
|
||||
|
|
|
@ -44,7 +44,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#define RF_ENCOUNTER (1<<9) /* persistent */
|
||||
#define RF_MAPPER_HIGHLIGHT (1<<10)
|
||||
#define RF_LIGHTHOUSE (1<<11) /* this region may contain a lighthouse */
|
||||
#define RF_ORCIFIED (1<<12) /* persistent */
|
||||
#define RF_MIGRATION (1<<13)
|
||||
|
||||
#define RF_UNUSED_14 (1<<14)
|
||||
|
@ -58,7 +57,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
#define RF_ALL 0xFFFFFF
|
||||
|
||||
#define RF_SAVEMASK (RF_CHAOTIC|RF_MALLORN|RF_BLOCKED|RF_ENCOUNTER|RF_ORCIFIED|RF_GUARDED|RF_LIGHTHOUSE)
|
||||
#define RF_SAVEMASK (RF_CHAOTIC|RF_MALLORN|RF_BLOCKED|RF_ENCOUNTER|RF_GUARDED|RF_LIGHTHOUSE)
|
||||
struct message;
|
||||
struct message_list;
|
||||
struct rawmaterial;
|
||||
|
|
|
@ -67,7 +67,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
#include <attributes/iceberg.h>
|
||||
extern struct attrib_type at_unitdissolve;
|
||||
extern struct attrib_type at_orcification;
|
||||
|
||||
/* In a->data.ca[1] steht der Prozentsatz mit dem sich die Einheit
|
||||
* auflöst, in a->data.ca[0] kann angegeben werden, wohin die Personen
|
||||
|
@ -807,44 +806,6 @@ void randomevents(void)
|
|||
godcurse();
|
||||
orc_growth();
|
||||
demon_skillchanges();
|
||||
|
||||
/* Orkifizierte Regionen mutieren und mutieren zurück */
|
||||
|
||||
for (r = regions; r; r = r->next) {
|
||||
if (fval(r, RF_ORCIFIED)) {
|
||||
direction_t dir;
|
||||
double probability = 0.0;
|
||||
for (dir = 0; dir < MAXDIRECTIONS; dir++) {
|
||||
region *rc = rconnect(r, dir);
|
||||
if (rc && rpeasants(rc) > 0 && !fval(rc, RF_ORCIFIED))
|
||||
probability += 0.02;
|
||||
}
|
||||
if (chance(probability)) {
|
||||
ADDMSG(&r->msgs, msg_message("deorcified", "region", r));
|
||||
freset(r, RF_ORCIFIED);
|
||||
}
|
||||
}
|
||||
else {
|
||||
attrib *a = a_find(r->attribs, &at_orcification);
|
||||
if (a != NULL) {
|
||||
double probability = 0.0;
|
||||
if (rpeasants(r) <= 0)
|
||||
continue;
|
||||
probability = a->data.i / (double)rpeasants(r);
|
||||
if (chance(probability)) {
|
||||
fset(r, RF_ORCIFIED);
|
||||
a_remove(&r->attribs, a);
|
||||
ADDMSG(&r->msgs, msg_message("orcified", "region", r));
|
||||
}
|
||||
else {
|
||||
a->data.i -= _max(10, a->data.i / 10);
|
||||
if (a->data.i <= 0)
|
||||
a_remove(&r->attribs, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
volcano_update();
|
||||
/* Monumente zerfallen, Schiffe verfaulen */
|
||||
|
||||
|
|
23
src/report.c
23
src/report.c
|
@ -1021,23 +1021,12 @@ static void describe(stream *out, const region * r, faction * f)
|
|||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
if (fval(r, RF_ORCIFIED)) {
|
||||
bytes = (int)strlcpy(bufp, " ", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
|
||||
bytes =
|
||||
(int)strlcpy(bufp, LOC(f->locale, n == 1 ? "rc_orc" : "rc_orc_p"),
|
||||
size);
|
||||
}
|
||||
else {
|
||||
bytes = (int)strlcpy(bufp, " ", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
bytes =
|
||||
(int)strlcpy(bufp, LOC(f->locale, n == 1 ? "peasant" : "peasant_p"),
|
||||
size);
|
||||
}
|
||||
bytes = (int)strlcpy(bufp, " ", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
bytes =
|
||||
(int)strlcpy(bufp, LOC(f->locale, n == 1 ? "peasant" : "peasant_p"),
|
||||
size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
if (is_mourning(r, turn + 1)) {
|
||||
|
|
|
@ -59,7 +59,6 @@ typedef struct summary {
|
|||
int landregionen;
|
||||
int regionen_mit_spielern;
|
||||
int landregionen_mit_spielern;
|
||||
int orkifizierte_regionen;
|
||||
int inactive_volcanos;
|
||||
int active_volcanos;
|
||||
int spielerpferde;
|
||||
|
@ -227,7 +226,6 @@ void report_summary(summary * s, summary * o, bool full)
|
|||
fprintf(F, "Landregionen: %d\n", s->landregionen);
|
||||
fprintf(F, "Spielerregionen: %d\n", s->regionen_mit_spielern);
|
||||
fprintf(F, "Landspielerregionen: %d\n", s->landregionen_mit_spielern);
|
||||
fprintf(F, "Orkifizierte Regionen: %d\n", s->orkifizierte_regionen);
|
||||
fprintf(F, "Inaktive Vulkane: %d\n", s->inactive_volcanos);
|
||||
fprintf(F, "Aktive Vulkane: %d\n\n", s->active_volcanos);
|
||||
}
|
||||
|
@ -422,9 +420,6 @@ summary *make_summary(void)
|
|||
if (r->units) {
|
||||
s->landregionen_mit_spielern++;
|
||||
}
|
||||
if (fval(r, RF_ORCIFIED)) {
|
||||
s->orkifizierte_regionen++;
|
||||
}
|
||||
if (r->terrain == newterrain(T_VOLCANO)) {
|
||||
s->inactive_volcanos++;
|
||||
}
|
||||
|
|
|
@ -37,23 +37,25 @@ int unicode_utf8_trim(utf8_t *buf)
|
|||
int result = 0, ts = 0;
|
||||
utf8_t *op = buf, *ip = buf, *lc = buf;
|
||||
while (*ip) {
|
||||
ucs4_t ucs = *ip;
|
||||
size_t size = 1;
|
||||
if (ucs & 0x80) {
|
||||
wint_t wc = *ip;
|
||||
if (wc & 0x80) {
|
||||
ucs4_t ucs;
|
||||
int ret = unicode_utf8_to_ucs4(&ucs, ip, &size);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
wc = (wint_t)ucs;
|
||||
}
|
||||
if (op == buf && iswspace(ucs)) {
|
||||
if (op == buf && iswspace(wc)) {
|
||||
++result;
|
||||
}
|
||||
else if (iswprint(ucs)) {
|
||||
else if (iswprint(wc)) {
|
||||
if (op != ip) {
|
||||
memcpy(op, ip, size);
|
||||
memmove(op, ip, size);
|
||||
}
|
||||
op += size;
|
||||
if (iswspace(ucs)) ++ts;
|
||||
if (iswspace(wc)) ++ts;
|
||||
else {
|
||||
lc = op;
|
||||
ts = 0;
|
||||
|
@ -67,49 +69,6 @@ int unicode_utf8_trim(utf8_t *buf)
|
|||
return result + ts;
|
||||
}
|
||||
|
||||
int unicode_utf8_mkname(utf8_t * op, size_t outlen, const utf8_t * ip)
|
||||
{
|
||||
int ret = 0;
|
||||
bool iss = true;
|
||||
while (*ip) {
|
||||
size_t size = 1;
|
||||
bool isp = false;
|
||||
do {
|
||||
ucs4_t ucs = *ip;
|
||||
if (ucs & 0x80) {
|
||||
ret = unicode_utf8_to_ucs4(&ucs, ip, &size);
|
||||
if (ret !=0) {
|
||||
return ret;
|
||||
}
|
||||
isp = iswprint(ucs);
|
||||
iss &= !!iswspace(ucs);
|
||||
} else {
|
||||
isp = isprint(ucs);
|
||||
iss &= !!isspace(ucs);
|
||||
}
|
||||
if (iss) {
|
||||
ip += size;
|
||||
}
|
||||
} while (iss);
|
||||
if (size > outlen) {
|
||||
return ENOMEM;
|
||||
}
|
||||
if (isp) {
|
||||
memcpy(op, ip, size);
|
||||
op += size;
|
||||
outlen -= size;
|
||||
} else {
|
||||
ret = 1;
|
||||
}
|
||||
ip += size;
|
||||
}
|
||||
if (outlen <= 0) {
|
||||
return ENOMEM;
|
||||
}
|
||||
*op = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int unicode_utf8_tolower(utf8_t * op, size_t outlen, const utf8_t * ip)
|
||||
{
|
||||
while (*ip) {
|
||||
|
@ -128,7 +87,7 @@ int unicode_utf8_tolower(utf8_t * op, size_t outlen, const utf8_t * ip)
|
|||
}
|
||||
low = towlower((wint_t)ucs);
|
||||
if (low == ucs) {
|
||||
memcpy(op, ip, size);
|
||||
memmove(op, ip, size);
|
||||
ip += size;
|
||||
op += size;
|
||||
outlen -= size;
|
||||
|
|
|
@ -25,7 +25,7 @@ extern "C" {
|
|||
|
||||
#include <wchar.h>
|
||||
#define USE_UNICODE
|
||||
typedef unsigned long ucs4_t;
|
||||
typedef long ucs4_t;
|
||||
typedef char utf8_t;
|
||||
|
||||
int unicode_utf8_to_cp437(unsigned char *result, const utf8_t * utf8_string,
|
||||
|
@ -42,7 +42,6 @@ extern "C" {
|
|||
int unicode_latin1_to_utf8(utf8_t * out, size_t * outlen,
|
||||
const char *in, size_t * inlen);
|
||||
int unicode_utf8_tolower(utf8_t *op, size_t outlen, const utf8_t *ip);
|
||||
int unicode_utf8_mkname(utf8_t *op, size_t outlen, const utf8_t *ip);
|
||||
int unicode_utf8_trim(utf8_t *ip);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -30,21 +30,6 @@ static void test_unicode_trim(CuTest * tc)
|
|||
CuAssertStrEquals(tc, "Hello Word", buffer);
|
||||
}
|
||||
|
||||
static void test_unicode_mkname(CuTest * tc)
|
||||
{
|
||||
char buffer[32];
|
||||
CuAssertIntEquals(tc, 0, unicode_utf8_mkname(buffer, sizeof(buffer), " HeLlO W0Rld"));
|
||||
CuAssertStrEquals(tc, "HeLlO W0Rld", buffer);
|
||||
CuAssertIntEquals(tc, 0, unicode_utf8_mkname(buffer, sizeof(buffer), "HeLlO W0Rld"));
|
||||
CuAssertStrEquals(tc, "HeLlO W0Rld", buffer);
|
||||
CuAssertIntEquals(tc, 1, unicode_utf8_mkname(buffer, sizeof(buffer), "HeLlO\nW0Rld"));
|
||||
CuAssertStrEquals(tc, "HeLlOW0Rld", buffer);
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
buffer[5] = 'X';
|
||||
CuAssertIntEquals(tc, ENOMEM, unicode_utf8_mkname(buffer, 5, "HeLl\n W0Rld"));
|
||||
CuAssertStrEquals(tc, "HeLl X", buffer);
|
||||
}
|
||||
|
||||
static void test_unicode_tolower(CuTest * tc)
|
||||
{
|
||||
char buffer[32];
|
||||
|
@ -106,7 +91,6 @@ CuSuite *get_unicode_suite(void)
|
|||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_unicode_tolower);
|
||||
SUITE_ADD_TEST(suite, test_unicode_mkname);
|
||||
SUITE_ADD_TEST(suite, test_unicode_trim);
|
||||
SUITE_ADD_TEST(suite, test_unicode_utf8_to_other);
|
||||
return suite;
|
||||
|
|
Loading…
Reference in a new issue