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