forked from github/server
Bugfix eternath-gates
This commit is contained in:
parent
41d8f1ebfa
commit
f56265c589
|
@ -1091,6 +1091,7 @@ report_computer(FILE * F, faction * f, const faction_list * addresses,
|
|||
building *b;
|
||||
ship *sh;
|
||||
unit *u;
|
||||
int score = 0, avgscore = 0;
|
||||
const char * mailto = locale_string(f->locale, "mailto");
|
||||
region * first = NULL, * last = NULL;
|
||||
const attrib * a;
|
||||
|
@ -1124,9 +1125,11 @@ report_computer(FILE * F, faction * f, const faction_list * addresses,
|
|||
fprintf(F, "\"%s\";locale\n", locale_name(f->locale));
|
||||
fprintf(F, "%d;Optionen\n", f->options);
|
||||
if (f->options & want(O_SCORE) && f->age>DISPLAYSCORE) {
|
||||
fprintf(F, "%d;Punkte\n", f->score);
|
||||
fprintf(F, "%d;Punktedurchschnitt\n", average_score_of_age(f->age, f->age / 24 + 1));
|
||||
}
|
||||
score = f->score;
|
||||
avgscore = average_score_of_age(f->age, f->age / 24 + 1);
|
||||
}
|
||||
fprintf(F, "%d;Punkte\n", score);
|
||||
fprintf(F, "%d;Punktedurchschnitt\n", avgscore);
|
||||
{
|
||||
const char * zRace = rc_name(f->race, 1);
|
||||
fprintf(F, "\"%s\";Typ\n", add_translation(zRace, LOC(f->locale, zRace)));
|
||||
|
|
|
@ -44,7 +44,7 @@ use_speedsail(struct unit * u, const struct item_type * itype, int amount, struc
|
|||
} else {
|
||||
if (u->ship) {
|
||||
attrib * a = a_find(u->ship->attribs, &at_speedup);
|
||||
if (a!=NULL) {
|
||||
if (a==NULL) {
|
||||
a = a_add(&u->ship->attribs, a_new(&at_speedup));
|
||||
a->data.sa[0] = 50; /* speed */
|
||||
a->data.sa[1] = 50; /* decay */
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
extern boolean incomplete_data;
|
||||
|
||||
unsigned int nextborder = 0;
|
||||
|
||||
border * borders[BMAXHASH];
|
||||
|
@ -508,12 +510,12 @@ read_borders(FILE * f)
|
|||
assert(type || !"border type not registered");
|
||||
from = findregion(fx, fy);
|
||||
if (from==NULL) {
|
||||
log_error(("border for unknown region %d,%d\n", fx, fy));
|
||||
if (!incomplete_data) log_error(("border for unknown region %d,%d\n", fx, fy));
|
||||
from = new_region(fx, fy);
|
||||
}
|
||||
to = findregion(tx, ty);
|
||||
if (to==NULL) {
|
||||
log_error(("border for unknown region %d,%d\n", tx, ty));
|
||||
if (!incomplete_data) log_error(("border for unknown region %d,%d\n", tx, ty));
|
||||
to = new_region(tx, ty);
|
||||
}
|
||||
if (to==from) {
|
||||
|
|
|
@ -677,6 +677,7 @@ int maxregions = -1;
|
|||
int loadplane = 0;
|
||||
|
||||
boolean dirtyload = false;
|
||||
boolean incomplete_data = false;
|
||||
|
||||
enum {
|
||||
U_MAN,
|
||||
|
@ -1828,7 +1829,9 @@ readgame(const char * filename, int backup)
|
|||
n = ri(F);
|
||||
if (rmax<0) rmax = n;
|
||||
printf(" - Einzulesende Regionen: %d/%d\r", rmax, n);
|
||||
|
||||
if (loadplane || dirtyload || firstx || firsty || maxregions>=0) {
|
||||
incomplete_data = true;
|
||||
}
|
||||
while (--n >= 0) {
|
||||
unit **up;
|
||||
boolean skip = false;
|
||||
|
|
|
@ -84,6 +84,7 @@
|
|||
#undef XMAS2002
|
||||
|
||||
extern void reorder_owners(struct region * r);
|
||||
extern int incomplete_data;
|
||||
|
||||
static int
|
||||
curse_emptiness(void)
|
||||
|
@ -933,15 +934,17 @@ extern border *borders[];
|
|||
static void
|
||||
fix_road_borders(void)
|
||||
{
|
||||
border *deleted[10000];
|
||||
#define MAXDEL 10000
|
||||
border *deleted[MAXDEL];
|
||||
int hash;
|
||||
int i = 0;
|
||||
|
||||
for(hash=0; hash<BMAXHASH; hash++) {
|
||||
if (incomplete_data) return;
|
||||
for(hash=0; hash<BMAXHASH && i!=MAXDEL; hash++) {
|
||||
border * bhash;
|
||||
for (bhash=borders[hash];bhash;bhash=bhash->nexthash) {
|
||||
for (bhash=borders[hash];bhash && i!=MAXDEL;bhash=bhash->nexthash) {
|
||||
border * b;
|
||||
for (b=bhash;b;b=b->next) {
|
||||
for (b=bhash;b && i!=MAXDEL;b=b->next) {
|
||||
if (b->type == &bt_road) {
|
||||
int x1, x2, y1, y2;
|
||||
region *r1, *r2;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
// util includes
|
||||
#include <util/base36.h>
|
||||
#include <util/log.h>
|
||||
|
||||
using namespace luabind;
|
||||
|
||||
|
@ -40,8 +41,26 @@ lc_age(struct attrib * a)
|
|||
assert(b!=NULL);
|
||||
if (fname==NULL) return -1;
|
||||
|
||||
luabind::object globals = luabind::get_globals(L);
|
||||
if (globals.at(fname).type()!=LUA_TFUNCTION) return -1;
|
||||
try {
|
||||
luabind::object globals = luabind::get_globals(L);
|
||||
luabind::object fun = globals.at(fname);
|
||||
if (!fun.is_valid()) {
|
||||
log_error(("Could not index function %s\n", fname));
|
||||
return -1;
|
||||
}
|
||||
if (fun.type()!=LUA_TFUNCTION) {
|
||||
log_error(("Lua global object %s is not a function\n", fname));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
catch (luabind::error& e) {
|
||||
lua_State* L = e.state();
|
||||
const char* error = lua_tostring(L, -1);
|
||||
|
||||
log_error((error));
|
||||
lua_pop(L, 1);
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
return luabind::call_function<int>(L, fname, *b);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
function eternath_travellers(b, maxsize)
|
||||
if gate_exchange==nil then
|
||||
dofile("gates.lua")
|
||||
end
|
||||
|
||||
local function eternath_travellers(b, maxsize)
|
||||
local size = maxsize
|
||||
local units = {}
|
||||
local u
|
||||
|
@ -17,28 +21,18 @@ function eternath_travellers(b, maxsize)
|
|||
return units
|
||||
end
|
||||
|
||||
function eternath_exchange(b1, b2)
|
||||
-- identify everyone who is travelling, first:
|
||||
local units1 = eternath_travellers(b1, 10)
|
||||
local units2 = eternath_travellers(b2, 10)
|
||||
local function eternath_exchange(b1, b2, size)
|
||||
local units1 = eternath_travellers(b1, size)
|
||||
local units2 = eternath_travellers(b2, size)
|
||||
|
||||
-- we've found which units we want to exchange, now swap them:
|
||||
local u
|
||||
for u in units1 do
|
||||
u.region = b2.region
|
||||
u.building = b2
|
||||
end
|
||||
for u in units2 do
|
||||
u.region = b1.region
|
||||
u.building = b1
|
||||
end
|
||||
gate_exchange(b1, units1, b2, units2)
|
||||
end
|
||||
|
||||
function eternathgate_action(b)
|
||||
if eternathgate == nil then
|
||||
eternathgate = b
|
||||
else
|
||||
eternath_exchange(eternathgate, b)
|
||||
eternath_exchange(eternathgate, b, 10)
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
function gate_exchange(b1, units1, b2, units2)
|
||||
-- we've found which units we want to exchange, now swap them:
|
||||
local u
|
||||
for u in units1 do
|
||||
u.region = b2.region
|
||||
u.building = b2
|
||||
end
|
||||
for u in units2 do
|
||||
u.region = b1.region
|
||||
u.building = b1
|
||||
end
|
||||
end
|
|
@ -2,10 +2,14 @@
|
|||
-- used on the jadee/wildente wedding island. the two _action functions
|
||||
-- are used as age() functions for a building_action with b:addaction("name")
|
||||
|
||||
if gate_exchange==nil then
|
||||
dofile("gates.lua")
|
||||
end
|
||||
|
||||
hellgate = nil
|
||||
peacegate = nil
|
||||
|
||||
function wedding_travellers(b)
|
||||
local function wedding_travellers(b)
|
||||
local units = {}
|
||||
|
||||
for u in b.units do
|
||||
|
@ -16,20 +20,11 @@ function wedding_travellers(b)
|
|||
return units
|
||||
end
|
||||
|
||||
function wedding_exchange(b1, b2)
|
||||
local function wedding_exchange(b1, b2)
|
||||
local units1 = wedding_travellers(b1)
|
||||
local units2 = wedding_travellers(b2)
|
||||
|
||||
-- we've found which units we want to exchange, now swap them:
|
||||
local u
|
||||
for u in units1 do
|
||||
u.region = b2.region
|
||||
u.building = b2
|
||||
end
|
||||
for u in units2 do
|
||||
u.region = b1.region
|
||||
u.building = b1
|
||||
end
|
||||
gate_exchange(b1, units1, b2, units2)
|
||||
end
|
||||
|
||||
function hellgate_action(b)
|
||||
|
@ -45,7 +40,7 @@ function peacegate_action(b)
|
|||
if peacegate == nil then
|
||||
peacegate = b
|
||||
else
|
||||
gate_exchange(peacegate, b)
|
||||
wedding_exchange(peacegate, b)
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue