forked from github/server
- new test case (recruiting)
- logging and compilation fixes
This commit is contained in:
parent
5ea74d8bd8
commit
24182c4d06
6 changed files with 119 additions and 104 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include "eressea/server.cpp"
|
#include "eressea/server.cpp"
|
||||||
|
|
||||||
#ifndef BINDINGS_TOLUA
|
#ifdef BINDINGS_LUABIND
|
||||||
#include "eressea/lua/alliance.cpp"
|
#include "eressea/lua/alliance.cpp"
|
||||||
#include "eressea/lua/building.cpp"
|
#include "eressea/lua/building.cpp"
|
||||||
#include "eressea/lua/eressea.cpp"
|
#include "eressea/lua/eressea.cpp"
|
||||||
|
|
|
@ -837,7 +837,7 @@ demographics(void)
|
||||||
free(free_migrants);
|
free(free_migrants);
|
||||||
free_migrants = m;
|
free_migrants = m;
|
||||||
};
|
};
|
||||||
putchar('\n');
|
if (verbosity>=1) putchar('\n');
|
||||||
|
|
||||||
remove_empty_units();
|
remove_empty_units();
|
||||||
|
|
||||||
|
@ -3930,7 +3930,7 @@ update_subscriptions(void)
|
||||||
strcat(strcpy(zText, basepath()), "/subscriptions");
|
strcat(strcpy(zText, basepath()), "/subscriptions");
|
||||||
F = fopen(zText, "r");
|
F = fopen(zText, "r");
|
||||||
if (F==NULL) {
|
if (F==NULL) {
|
||||||
log_info((0, "could not open %s.\n", zText));
|
log_warning((0, "could not open %s.\n", zText));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
|
@ -357,10 +357,6 @@ extern void reorder_units(struct region * r);
|
||||||
|
|
||||||
extern const char *localenames[];
|
extern const char *localenames[];
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include <stdafx.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** compatibility: **/
|
/** compatibility: **/
|
||||||
extern race_t old_race(const struct race *);
|
extern race_t old_race(const struct race *);
|
||||||
extern const struct race * new_race[];
|
extern const struct race * new_race[];
|
||||||
|
|
|
@ -258,7 +258,6 @@ _log_info(unsigned int level, const char * format, ...)
|
||||||
va_start(marker, format);
|
va_start(marker, format);
|
||||||
vfprintf(logfile, format, marker);
|
vfprintf(logfile, format, marker);
|
||||||
va_end(marker);
|
va_end(marker);
|
||||||
}
|
|
||||||
if (logfile!=stderr) {
|
if (logfile!=stderr) {
|
||||||
if (stderr_level>=level) {
|
if (stderr_level>=level) {
|
||||||
fprintf(stderr, "INFO[%u]: ", level);
|
fprintf(stderr, "INFO[%u]: ", level);
|
||||||
|
@ -286,3 +285,4 @@ _log_info(unsigned int level, const char * format, ...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -122,11 +122,11 @@
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning (pop)
|
#pragma warning (pop)
|
||||||
#endif // _MSC_VER
|
#endif // _MSC_VER
|
||||||
#endif // BINDINGS_LUABIND
|
|
||||||
|
|
||||||
#include "lua/script.h"
|
#include "lua/script.h"
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
|
|
||||||
|
#endif // BINDINGS_LUABIND
|
||||||
|
|
||||||
#include <libxml/encoding.h>
|
#include <libxml/encoding.h>
|
||||||
|
|
||||||
/* stdc++ includes */
|
/* stdc++ includes */
|
||||||
|
|
|
@ -185,7 +185,7 @@ function test_events()
|
||||||
str = evt:get(0)
|
str = evt:get(0)
|
||||||
u2 = evt:get(1)
|
u2 = evt:get(1)
|
||||||
assert(u2~=nil)
|
assert(u2~=nil)
|
||||||
print(str=="Du Elf stinken")
|
assert(str=="Du Elf stinken")
|
||||||
message_unit(u, u2, "thanks unit, i got your message: " .. str)
|
message_unit(u, u2, "thanks unit, i got your message: " .. str)
|
||||||
message_faction(u, u2.faction, "thanks faction, i got your message: " .. str)
|
message_faction(u, u2.faction, "thanks faction, i got your message: " .. str)
|
||||||
message_region(u, "thanks region, i got your message: " .. str)
|
message_region(u, "thanks region, i got your message: " .. str)
|
||||||
|
@ -218,18 +218,37 @@ function test_events()
|
||||||
assert(fail==0)
|
assert(fail==0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function test_recruit()
|
||||||
|
free_game()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create("enno@eressea.de", "human", "de")
|
||||||
|
local u = unit.create(f, r)
|
||||||
|
u.number = 1
|
||||||
|
local n = 3
|
||||||
|
r:set_resource("peasant", 200)
|
||||||
|
u:clear_orders()
|
||||||
|
u:add_item("money", 85*n+20)
|
||||||
|
u:add_order("REKRUTIERE " .. n)
|
||||||
|
process_orders()
|
||||||
|
assert(u.number == n+1)
|
||||||
|
local p = r:get_resource("peasant")
|
||||||
|
assert(p<200 and p>=200-n)
|
||||||
|
assert(u:get_item("money")==10)
|
||||||
|
end
|
||||||
|
|
||||||
loadscript("extensions.lua")
|
loadscript("extensions.lua")
|
||||||
tests = {
|
tests = {
|
||||||
["test_pure"] = test_pure,
|
["pure"] = test_pure,
|
||||||
["test_read_write"] = test_read_write,
|
["read_write"] = test_read_write,
|
||||||
["test_faction"] = test_faction,
|
["faction"] = test_faction,
|
||||||
["test_region"] = test_region,
|
["region"] = test_region,
|
||||||
["test_building"] = test_building,
|
["building"] = test_building,
|
||||||
["test_unit"] = test_unit,
|
["unit"] = test_unit,
|
||||||
["test_message"] = test_message,
|
["message"] = test_message,
|
||||||
["test_hashtable"] = test_hashtable,
|
["hashtable"] = test_hashtable,
|
||||||
["test_gmtool"] = test_gmtool,
|
["gmtool"] = test_gmtool,
|
||||||
["test_events"] = test_events
|
["events"] = test_events,
|
||||||
|
["recruit"] = test_recruit
|
||||||
}
|
}
|
||||||
|
|
||||||
fail = 0
|
fail = 0
|
||||||
|
|
Loading…
Reference in a new issue