Merge pull request #312 from eressea/master

pull latest changes from master into develop
This commit is contained in:
Enno Rehling 2015-10-11 16:47:29 +02:00
commit 936c201d0b
11 changed files with 124 additions and 24 deletions

View File

@ -29,4 +29,5 @@ function test_store_unit()
os.remove(filename)
assert_not_nil(u)
assert_equal(u:get_item("money"), u.number * 100)
os.remove(filename)
end

View File

@ -1530,7 +1530,7 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
fprintf(F, "\"%s\";charset\n", charset);
fprintf(F, "\"%s\";locale\n", locale_name(f->locale));
fprintf(F, "%d;noskillpoints\n", 1);
fprintf(F, "%ld;date\n", ctx->report_time);
fprintf(F, "%lld;date\n", (long long)ctx->report_time);
fprintf(F, "\"%s\";Spiel\n", game_name());
fprintf(F, "\"%s\";Konfiguration\n", "Standard");
fprintf(F, "\"%s\";Koordinaten\n", "Hex");

View File

@ -989,9 +989,7 @@ static void test_nmr_warnings(CuTest *tc) {
test_cleanup();
}
static void test_mail_cmd(CuTest *tc) {
unit *u;
order *ord;
static unit * setup_mail_cmd(void) {
faction *f;
struct locale *lang;
@ -999,30 +997,90 @@ static void test_mail_cmd(CuTest *tc) {
f = test_create_faction(0);
f->locale = lang = get_or_create_locale("de");
locale_setstring(lang, parameters[P_UNIT], "EINHEIT");
locale_setstring(lang, parameters[P_REGION], "REGION");
locale_setstring(lang, parameters[P_FACTION], "PARTEI");
init_parameters(lang);
u = test_create_unit(f, test_create_region(0, 0, 0));
return test_create_unit(f, test_create_region(0, 0, 0));
}
static void test_mail_unit(CuTest *tc) {
order *ord;
unit *u;
u = setup_mail_cmd();
ord = create_order(K_MAIL, u->faction->locale, "EINHEIT %s 'Hodor!'", itoa36(u->no));
mail_cmd(u, ord);
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "unitmessage"));
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "unitmessage"));
test_cleanup();
}
static void test_mail_cmd_no_msg(CuTest *tc) {
static void test_mail_faction(CuTest *tc) {
order *ord;
unit *u;
u = setup_mail_cmd();
ord = create_order(K_MAIL, u->faction->locale, "PARTEI %s 'Hodor!'", itoa36(u->faction->no));
mail_cmd(u, ord);
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "regionmessage"));
test_cleanup();
}
static void test_mail_region(CuTest *tc) {
order *ord;
unit *u;
u = setup_mail_cmd();
ord = create_order(K_MAIL, u->faction->locale, "REGION 'Hodor!'", itoa36(u->no));
mail_cmd(u, ord);
CuAssertPtrNotNull(tc, test_find_messagetype(u->region->msgs, "mail_result"));
test_cleanup();
}
static void test_mail_unit_no_msg(CuTest *tc) {
unit *u;
order *ord;
faction *f;
struct locale *lang;
test_cleanup();
f = test_create_faction(0);
f->locale = lang = get_or_create_locale("de");
locale_setstring(lang, parameters[P_UNIT], "EINHEIT");
init_parameters(lang);
u = test_create_unit(f, test_create_region(0, 0, 0));
u = setup_mail_cmd();
ord = create_order(K_MAIL, u->faction->locale, "EINHEIT %s", itoa36(u->no));
mail_cmd(u, ord);
CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "unitmessage"));
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error30"));
CuAssertPtrEquals(tc, 0, test_find_messagetype(u->faction->msgs, "unitmessage"));
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error30"));
test_cleanup();
}
static void test_mail_faction_no_msg(CuTest *tc) {
unit *u;
order *ord;
u = setup_mail_cmd();
ord = create_order(K_MAIL, u->faction->locale, "PARTEI %s", itoa36(u->faction->no));
mail_cmd(u, ord);
CuAssertPtrEquals(tc, 0, test_find_messagetype(u->faction->msgs, "regionmessage"));
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error30"));
test_cleanup();
}
static void test_mail_faction_no_target(CuTest *tc) {
unit *u;
order *ord;
u = setup_mail_cmd();
ord = create_order(K_MAIL, u->faction->locale, "PARTEI %s", itoa36(u->faction->no+1));
mail_cmd(u, ord);
CuAssertPtrEquals(tc, 0, test_find_messagetype(u->faction->msgs, "regionmessage"));
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error66"));
test_cleanup();
}
static void test_mail_region_no_msg(CuTest *tc) {
unit *u;
order *ord;
u = setup_mail_cmd();
ord = create_order(K_MAIL, u->faction->locale, "REGION");
mail_cmd(u, ord);
CuAssertPtrEquals(tc, 0, test_find_messagetype(u->region->msgs, "mail_result"));
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error30"));
test_cleanup();
}
@ -1070,8 +1128,13 @@ CuSuite *get_laws_suite(void)
SUITE_ADD_TEST(suite, test_force_leave_ships);
SUITE_ADD_TEST(suite, test_force_leave_ships_on_ocean);
SUITE_ADD_TEST(suite, test_peasant_luck_effect);
SUITE_ADD_TEST(suite, test_mail_cmd);
SUITE_ADD_TEST(suite, test_mail_cmd_no_msg);
SUITE_ADD_TEST(suite, test_mail_unit);
SUITE_ADD_TEST(suite, test_mail_faction);
SUITE_ADD_TEST(suite, test_mail_region);
SUITE_ADD_TEST(suite, test_mail_unit_no_msg);
SUITE_ADD_TEST(suite, test_mail_faction_no_msg);
SUITE_ADD_TEST(suite, test_mail_region_no_msg);
SUITE_ADD_TEST(suite, test_mail_faction_no_target);
(void)test_luck_message; /* disabled, breaks on travis */
return suite;

View File

@ -870,9 +870,9 @@ int eff_spelllevel(unit * u, const spell * sp, int cast_level, int range)
/* Ein Spruch mit Fixkosten wird immer mit der Stufe des Spruchs und
* nicht auf der Stufe des Magiers gezaubert */
if (costtyp == SPC_FIX) {
spellbook * spells = unit_get_spellbook(u);
if (spells) {
spellbook_entry * sbe = spellbook_get(spells, sp);
spellbook * sb = unit_get_spellbook(u);
if (sb) {
spellbook_entry * sbe = spellbook_get(sb, sp);
if (sbe) {
return _min(cast_level, sbe->level);
}

View File

@ -34,6 +34,16 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# undef MOUSE_MOVED
# define STDIO_CP 1252 /* log.c, convert to console character set */
# pragma warning (disable: 4201 4214 4514 4115 4711)
#if _MSC_VER >= 1900
# pragma warning(disable: 4710)
/* warning C4710: function not inlined */
# pragma warning(disable: 4456)
/* warning C4456 : declaration of <name> hides previous local declaration */
# pragma warning(disable: 4457)
/* warning C4457: declaration of <name> hides function parameter */
# pragma warning(disable: 4459)
/* warning C4459: declaration of <name> hides global declaration */
#endif
# pragma warning(disable: 4056)
/* warning C4056: overflow in floating point constant arithmetic */
# pragma warning(disable: 4201)

View File

@ -97,6 +97,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <limits.h>
#include <stdlib.h>
#if defined(_MSC_VER) && _MSC_VER >= 1900
# pragma warning(disable: 4774) // TODO: remove this
#endif
extern int *storms;
extern int weeks_per_month;
extern int months_per_year;

View File

@ -75,6 +75,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "move.h"
#if defined(_MSC_VER) && _MSC_VER >= 1900
# pragma warning(disable: 4774) // TODO: remove this
#endif
#define SCALEWEIGHT 100 /* Faktor, um den die Anzeige von Gewichten skaliert wird */
bool nocr = false;

View File

@ -101,6 +101,10 @@
#include <attributes/hate.h>
/* ----------------------------------------------------------------------- */
#if defined(_MSC_VER) && _MSC_VER >= 1900
# pragma warning(disable: 4774) // TODO: remove this
#endif
static double zero_effect = 0.0;
attrib_type at_wdwpyramid = {

View File

@ -270,7 +270,7 @@ const char * test_get_messagetype(const message *msg) {
struct message * test_find_messagetype(struct message_list *msgs, const char *name) {
struct mlist *ml;
assert(msgs);
if (!msgs) return 0;
for (ml = msgs->begin; ml; ml = ml->next) {
if (strcmp(name, test_get_messagetype(ml->msg)) == 0) {
return ml->msg;

View File

@ -1,5 +1,8 @@
@ECHO OFF
SET BUILD=..\build-vs12\eressea\Debug\
IF EXIST ..\build-vs10 SET BUILD=..\build-vs10\eressea\Debug
IF EXIST ..\build-vs11 SET BUILD=..\build-vs11\eressea\Debug
IF EXIST ..\build-vs12 SET BUILD=..\build-vs12\eressea\Debug
IF EXIST ..\build-vs14 SET BUILD=..\build-vs14\eressea\Debug
SET SERVER=%BUILD%\eressea.exe
%BUILD%\test_eressea.exe
%SERVER% ..\scripts\run-tests.lua

11
vs2015-build.bat Normal file
View File

@ -0,0 +1,11 @@
@ECHO OFF
SET VSVERSION=14
SET SRCDIR=%CD%
CD ..
SET ERESSEA=%CD%
CD %SRCDIR%
mkdir build-vs%VSVERSION%
cd build-vs%VSVERSION%
"%ProgramFiles(x86)%\CMake\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%SRCDIR%/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE ..
PAUSE