forked from github/server
Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
commit
247aecd92c
|
@ -398,6 +398,14 @@
|
||||||
<text locale="de">"Die natürliche Widerstandskraft gegen Verzauberung ist gestärkt. ($int36($id))"</text>
|
<text locale="de">"Die natürliche Widerstandskraft gegen Verzauberung ist gestärkt. ($int36($id))"</text>
|
||||||
<text locale="en">"The magical resistance has been strengthened. ($int36($id))"</text>
|
<text locale="en">"The magical resistance has been strengthened. ($int36($id))"</text>
|
||||||
</message>
|
</message>
|
||||||
|
<message name="curseinfo::homestone" section="events">
|
||||||
|
<type>
|
||||||
|
<arg name="building" type="building"/>
|
||||||
|
<arg name="id" type="int"/>
|
||||||
|
</type>
|
||||||
|
<text locale="de">"Die natürliche Widerstandskraft gegen Verzauberung ist gestärkt. ($int36($id))"</text>
|
||||||
|
<text locale="en">"The magical resistance has been strengthened. ($int36($id))"</text>
|
||||||
|
</message>
|
||||||
<message name="curseinfo::goodmagicresistancezone" section="events">
|
<message name="curseinfo::goodmagicresistancezone" section="events">
|
||||||
<type>
|
<type>
|
||||||
<arg name="id" type="int"/>
|
<arg name="id" type="int"/>
|
||||||
|
@ -414,6 +422,7 @@
|
||||||
</message>
|
</message>
|
||||||
<message name="curseinfo::magicwalls" section="events">
|
<message name="curseinfo::magicwalls" section="events">
|
||||||
<type>
|
<type>
|
||||||
|
<arg name="building" type="building"/>
|
||||||
<arg name="id" type="int"/>
|
<arg name="id" type="int"/>
|
||||||
</type>
|
</type>
|
||||||
<text locale="de">"Diese Mauern wirken, als wären sie direkt aus der Erde gewachsen und nicht erbaut. ($int36($id))"</text>
|
<text locale="de">"Diese Mauern wirken, als wären sie direkt aus der Erde gewachsen und nicht erbaut. ($int36($id))"</text>
|
||||||
|
@ -421,6 +430,7 @@
|
||||||
</message>
|
</message>
|
||||||
<message name="curseinfo::buildingunknown" section="events">
|
<message name="curseinfo::buildingunknown" section="events">
|
||||||
<type>
|
<type>
|
||||||
|
<arg name="building" type="building"/>
|
||||||
<arg name="id" type="int"/>
|
<arg name="id" type="int"/>
|
||||||
</type>
|
</type>
|
||||||
<text locale="de">"Ein magischer Schimmer liegt auf diesen Mauern. ($int36($id))"</text>
|
<text locale="de">"Ein magischer Schimmer liegt auf diesen Mauern. ($int36($id))"</text>
|
||||||
|
@ -541,6 +551,7 @@
|
||||||
<message name="curseinfo::nocostbuilding" section="events">
|
<message name="curseinfo::nocostbuilding" section="events">
|
||||||
<type>
|
<type>
|
||||||
<arg name="id" type="int"/>
|
<arg name="id" type="int"/>
|
||||||
|
<arg name="building" type="building"/>
|
||||||
</type>
|
</type>
|
||||||
<text locale="de">"Der Zahn der Zeit kann diesen Mauern nichts anhaben. ($int36($id))"</text>
|
<text locale="de">"Der Zahn der Zeit kann diesen Mauern nichts anhaben. ($int36($id))"</text>
|
||||||
<text locale="en">"Time cannot touch these walls. ($int36($id))"</text>
|
<text locale="en">"Time cannot touch these walls. ($int36($id))"</text>
|
||||||
|
|
|
@ -17,6 +17,9 @@ function test_dont_move_after_destroy()
|
||||||
u:add_order("NACH O")
|
u:add_order("NACH O")
|
||||||
u:add_order("ZERSTOERE " .. itoa36(u.building.id))
|
u:add_order("ZERSTOERE " .. itoa36(u.building.id))
|
||||||
process_orders()
|
process_orders()
|
||||||
|
if not u.region then
|
||||||
|
print("shit happened ", u.number)
|
||||||
|
end
|
||||||
assert_equal(r1, u.region)
|
assert_equal(r1, u.region)
|
||||||
assert_equal(nil, u.building)
|
assert_equal(nil, u.building)
|
||||||
end
|
end
|
||||||
|
|
|
@ -193,6 +193,7 @@ set(TESTS_SRC
|
||||||
spells.test.c
|
spells.test.c
|
||||||
spy.test.c
|
spy.test.c
|
||||||
upkeep.test.c
|
upkeep.test.c
|
||||||
|
spells/magicresistance.test.c
|
||||||
${ATTRIBUTES_TESTS}
|
${ATTRIBUTES_TESTS}
|
||||||
${UTIL_TESTS}
|
${UTIL_TESTS}
|
||||||
${KERNEL_TESTS}
|
${KERNEL_TESTS}
|
||||||
|
|
|
@ -742,13 +742,7 @@ static const char *oldnames[MAXCURSE] = {
|
||||||
"speed",
|
"speed",
|
||||||
"orcish",
|
"orcish",
|
||||||
"magicboost",
|
"magicboost",
|
||||||
"insectfur",
|
"insectfur"
|
||||||
"strength",
|
|
||||||
"worse",
|
|
||||||
"magicresistance",
|
|
||||||
"itemcloak",
|
|
||||||
"sparkle",
|
|
||||||
"skillmod"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *oldcursename(int id)
|
const char *oldcursename(int id)
|
||||||
|
|
|
@ -98,7 +98,6 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
/* struct's vom typ curse: */
|
|
||||||
C_FOGTRAP,
|
C_FOGTRAP,
|
||||||
C_ANTIMAGICZONE,
|
C_ANTIMAGICZONE,
|
||||||
C_FARVISION,
|
C_FARVISION,
|
||||||
|
@ -128,18 +127,10 @@ extern "C" {
|
||||||
C_RIOT, /*region in Aufruhr */
|
C_RIOT, /*region in Aufruhr */
|
||||||
C_NOCOST,
|
C_NOCOST,
|
||||||
C_CURSED_BY_THE_GODS,
|
C_CURSED_BY_THE_GODS,
|
||||||
/* struct's vom untertyp curse_unit: */
|
|
||||||
C_SPEED, /* Beschleunigt */
|
C_SPEED, /* Beschleunigt */
|
||||||
C_ORC,
|
C_ORC,
|
||||||
C_MBOOST,
|
C_MBOOST,
|
||||||
C_KAELTESCHUTZ,
|
C_KAELTESCHUTZ,
|
||||||
C_STRENGTH,
|
|
||||||
C_ALLSKILLS,
|
|
||||||
C_MAGICRESISTANCE, /* 44 - verändert Magieresistenz */
|
|
||||||
C_ITEMCLOAK,
|
|
||||||
C_SPARKLE,
|
|
||||||
/* struct's vom untertyp curse_skill: */
|
|
||||||
C_SKILL,
|
|
||||||
MAXCURSE /* OBS: when removing curses, remember to update read_ccompat() */
|
MAXCURSE /* OBS: when removing curses, remember to update read_ccompat() */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,6 @@ message *msg_message(const char *name, const char *sig, ...)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error("invalid parameter %s for message type %s\n", paramname, mtype->name);
|
log_error("invalid parameter %s for message type %s\n", paramname, mtype->name);
|
||||||
assert(!"program aborted.");
|
|
||||||
}
|
}
|
||||||
while (*ic && !isalnum(*ic))
|
while (*ic && !isalnum(*ic))
|
||||||
ic++;
|
ic++;
|
||||||
|
@ -196,7 +195,6 @@ message *msg_message(const char *name, const char *sig, ...)
|
||||||
va_end(vargs);
|
va_end(vargs);
|
||||||
if (argnum != mtype->nparameters) {
|
if (argnum != mtype->nparameters) {
|
||||||
log_error("not enough parameters for message type %s\n", mtype->name);
|
log_error("not enough parameters for message type %s\n", mtype->name);
|
||||||
assert(!"program aborted.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return msg_create(mtype, args);
|
return msg_create(mtype, args);
|
||||||
|
|
|
@ -5011,12 +5011,6 @@ int sp_resist_magic_bonus(castorder * co)
|
||||||
|
|
||||||
u = pa->param[n]->data.u;
|
u = pa->param[n]->data.u;
|
||||||
|
|
||||||
/* Ist die Einheit schon verzaubert, wirkt sich dies nur auf die
|
|
||||||
* Menge der Verzauberten Personen aus.
|
|
||||||
if (is_cursed(u->attribs, C_MAGICRESISTANCE, 0))
|
|
||||||
continue;
|
|
||||||
*/
|
|
||||||
|
|
||||||
m = _min(u->number, victims);
|
m = _min(u->number, victims);
|
||||||
victims -= m;
|
victims -= m;
|
||||||
|
|
||||||
|
@ -6767,6 +6761,8 @@ static int sp_readmind(castorder * co)
|
||||||
return cast_level;
|
return cast_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void register_magicresistance(void);
|
||||||
|
|
||||||
void register_spells(void)
|
void register_spells(void)
|
||||||
{
|
{
|
||||||
register_borders();
|
register_borders();
|
||||||
|
@ -6793,4 +6789,5 @@ void register_spells(void)
|
||||||
register_regioncurse();
|
register_regioncurse();
|
||||||
register_shipcurse();
|
register_shipcurse();
|
||||||
register_buildingcurse();
|
register_buildingcurse();
|
||||||
|
register_magicresistance();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ combatspells.c
|
||||||
regioncurse.c
|
regioncurse.c
|
||||||
shipcurse.c
|
shipcurse.c
|
||||||
unitcurse.c
|
unitcurse.c
|
||||||
|
magicresistance.c
|
||||||
)
|
)
|
||||||
FOREACH(_FILE ${_FILES})
|
FOREACH(_FILE ${_FILES})
|
||||||
LIST(APPEND _SOURCES ${PROJECT_NAME}/${_FILE})
|
LIST(APPEND _SOURCES ${PROJECT_NAME}/${_FILE})
|
||||||
|
|
|
@ -33,16 +33,16 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
static message *cinfo_building(const void *obj, objtype_t typ, const curse * c,
|
message *cinfo_building(const void *obj, objtype_t typ, const curse * c,
|
||||||
int self)
|
int self)
|
||||||
{
|
{
|
||||||
|
const building *b = (const building *)obj;
|
||||||
unused_arg(typ);
|
unused_arg(typ);
|
||||||
assert(typ == TYP_BUILDING);
|
assert(typ == TYP_BUILDING);
|
||||||
|
assert(obj);
|
||||||
|
assert(c);
|
||||||
|
|
||||||
if (self != 0) { /* owner or inside */
|
return msg_message(mkname("curseinfo", self ? c->type->cname : "buildingunknown"), "id building", c->no, b);
|
||||||
return msg_message(mkname("curseinfo", c->type->cname), "id", c->no);
|
|
||||||
}
|
|
||||||
return msg_message(mkname("curseinfo", "buildingunknown"), "id", c->no);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CurseInfo mit Spezialabfragen */
|
/* CurseInfo mit Spezialabfragen */
|
||||||
|
|
|
@ -13,14 +13,17 @@
|
||||||
|
|
||||||
#ifndef _BCURSE_H
|
#ifndef _BCURSE_H
|
||||||
#define _BCURSE_H
|
#define _BCURSE_H
|
||||||
|
#include <kernel/objtypes.h>
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct locale;
|
struct locale;
|
||||||
struct curse;
|
struct curse;
|
||||||
|
struct message;
|
||||||
|
|
||||||
extern void register_buildingcurse(void);
|
extern void register_buildingcurse(void);
|
||||||
|
struct message *cinfo_building(const void *obj, objtype_t typ, const struct curse * c, int self);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
#include <platform.h>
|
||||||
|
#include <kernel/config.h>
|
||||||
|
#include <kernel/curse.h>
|
||||||
|
#include <kernel/messages.h>
|
||||||
|
#include <util/language.h>
|
||||||
|
|
||||||
|
static struct message *cinfo_magicresistance(const void *obj, objtype_t typ, const struct curse * c, int self)
|
||||||
|
{
|
||||||
|
if (typ == TYP_UNIT) {
|
||||||
|
if (self != 0) {
|
||||||
|
const struct unit *u = (const struct unit *)obj;
|
||||||
|
return msg_message(mkname("curseinfo", c->type->cname), "unit id", u,
|
||||||
|
c->no);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (typ == TYP_BUILDING) {
|
||||||
|
const struct building *b = (const struct building *)obj;
|
||||||
|
return msg_message(mkname("curseinfo", self ? "homestone" : "buildingunknown"), "id building", c->no, b);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct curse_type ct_magicresistance = {
|
||||||
|
"magicresistance", CURSETYP_UNIT, CURSE_SPREADMODULO, M_MEN, cinfo_magicresistance
|
||||||
|
};
|
||||||
|
|
||||||
|
void register_magicresistance(void)
|
||||||
|
{
|
||||||
|
ct_register(&ct_magicresistance);
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
#include <platform.h>
|
||||||
|
#include <kernel/config.h>
|
||||||
|
#include <kernel/curse.h>
|
||||||
|
#include <kernel/building.h>
|
||||||
|
#include <kernel/faction.h>
|
||||||
|
#include <kernel/order.h>
|
||||||
|
#include <kernel/region.h>
|
||||||
|
#include <kernel/spell.h>
|
||||||
|
#include <kernel/unit.h>
|
||||||
|
#include <util/message.h>
|
||||||
|
#include <util/language.h>
|
||||||
|
#include <util/attrib.h>
|
||||||
|
#include <spells/regioncurse.h>
|
||||||
|
#include "spells.h"
|
||||||
|
|
||||||
|
#include <CuTest.h>
|
||||||
|
#include <tests.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
|
static void test_magicresistance_unit(CuTest *tc) {
|
||||||
|
struct region *r;
|
||||||
|
struct faction *f1, *f2;
|
||||||
|
unit *u1, *u2;
|
||||||
|
message *msg;
|
||||||
|
curse *c;
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
test_create_world();
|
||||||
|
r=findregion(0, 0);
|
||||||
|
f1 = test_create_faction(test_create_race("human"));
|
||||||
|
u1 = test_create_unit(f1, r);
|
||||||
|
|
||||||
|
f2 = test_create_faction(test_create_race("human"));
|
||||||
|
u2 = test_create_unit(f2, r);
|
||||||
|
|
||||||
|
c = create_curse(u1, &u2->attribs, ct_find("magicresistance"), 10, 20, 30, u2->number);
|
||||||
|
CuAssertPtrNotNull(tc, u2->attribs);
|
||||||
|
CuAssertPtrEquals(tc, (void *)&at_curse, (void *)u2->attribs->type);
|
||||||
|
msg = c->type->curseinfo(u2, TYP_UNIT, c, 1);
|
||||||
|
CuAssertPtrNotNull(tc, msg);
|
||||||
|
CuAssertStrEquals(tc, "curseinfo::magicresistance", test_get_messagetype(msg));
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_magicresistance_building(CuTest *tc) {
|
||||||
|
struct region *r;
|
||||||
|
struct faction *f1;
|
||||||
|
unit *u1;
|
||||||
|
building *b1;
|
||||||
|
message *msg;
|
||||||
|
curse *c;
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
test_create_world();
|
||||||
|
r = findregion(0, 0);
|
||||||
|
f1 = test_create_faction(test_create_race("human"));
|
||||||
|
u1 = test_create_unit(f1, r);
|
||||||
|
|
||||||
|
b1 = test_create_building(r, test_create_buildingtype("castle"));
|
||||||
|
|
||||||
|
c = create_curse(u1, &b1->attribs, ct_find("magicresistance"), 10, 20, 30, 0);
|
||||||
|
CuAssertPtrNotNull(tc, b1->attribs);
|
||||||
|
CuAssertPtrEquals(tc, (void *)&at_curse, (void *)b1->attribs->type);
|
||||||
|
msg = c->type->curseinfo(b1, TYP_BUILDING, c, 1);
|
||||||
|
CuAssertPtrNotNull(tc, msg);
|
||||||
|
CuAssertStrEquals(tc, "curseinfo::homestone", test_get_messagetype(msg));
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
CuSuite *get_magicresistance_suite(void)
|
||||||
|
{
|
||||||
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
SUITE_ADD_TEST(suite, test_magicresistance_unit);
|
||||||
|
SUITE_ADD_TEST(suite, test_magicresistance_building);
|
||||||
|
return suite;
|
||||||
|
}
|
|
@ -159,6 +159,7 @@ message *cinfo_unit(const void *obj, objtype_t typ, const curse * c, int self)
|
||||||
{
|
{
|
||||||
unused_arg(typ);
|
unused_arg(typ);
|
||||||
assert(typ == TYP_UNIT);
|
assert(typ == TYP_UNIT);
|
||||||
|
assert(obj);
|
||||||
|
|
||||||
if (self != 0) {
|
if (self != 0) {
|
||||||
unit *u = (unit *)obj;
|
unit *u = (unit *)obj;
|
||||||
|
@ -301,10 +302,6 @@ static struct curse_type ct_oldrace = {
|
||||||
"oldrace", CURSETYP_NORM, CURSE_SPREADALWAYS, NO_MERGE, NULL
|
"oldrace", CURSETYP_NORM, CURSE_SPREADALWAYS, NO_MERGE, NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct curse_type ct_magicresistance = {
|
|
||||||
"magicresistance", CURSETYP_UNIT, CURSE_SPREADMODULO, M_MEN, cinfo_unit
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
/*
|
/*
|
||||||
* C_SKILL
|
* C_SKILL
|
||||||
|
@ -365,5 +362,4 @@ void register_unitcurse(void)
|
||||||
ct_register(&ct_itemcloak);
|
ct_register(&ct_itemcloak);
|
||||||
ct_register(&ct_fumble);
|
ct_register(&ct_fumble);
|
||||||
ct_register(&ct_oldrace);
|
ct_register(&ct_oldrace);
|
||||||
ct_register(&ct_magicresistance);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@ int RunAllTests(void)
|
||||||
RUN_TESTS(suite, building);
|
RUN_TESTS(suite, building);
|
||||||
RUN_TESTS(suite, spell);
|
RUN_TESTS(suite, spell);
|
||||||
RUN_TESTS(suite, spells);
|
RUN_TESTS(suite, spells);
|
||||||
|
RUN_TESTS(suite, magicresistance);
|
||||||
RUN_TESTS(suite, ally);
|
RUN_TESTS(suite, ally);
|
||||||
RUN_TESTS(suite, messages);
|
RUN_TESTS(suite, messages);
|
||||||
/* gamecode */
|
/* gamecode */
|
||||||
|
|
Loading…
Reference in New Issue