forked from github/server
NMR-Zaehlung auch fuer LUA
This commit is contained in:
parent
7590fa50ef
commit
c3e4e828a8
|
@ -2646,18 +2646,15 @@ report_summary(summary * s, summary * o, boolean full)
|
|||
FILE * F = NULL;
|
||||
int i, newplayers = 0;
|
||||
faction * f;
|
||||
int * nmrs = malloc(sizeof(int)*(NMRTimeout()+1));
|
||||
char zText[MAX_PATH];
|
||||
|
||||
{
|
||||
char zText[MAX_PATH];
|
||||
if (full) {
|
||||
sprintf(zText, "%s/parteien.full", basepath());
|
||||
} else {
|
||||
sprintf(zText, "%s/parteien", basepath());
|
||||
}
|
||||
F = cfopen(zText, "w");
|
||||
if (!F) return;
|
||||
if (full) {
|
||||
sprintf(zText, "%s/parteien.full", basepath());
|
||||
} else {
|
||||
sprintf(zText, "%s/parteien", basepath());
|
||||
}
|
||||
F = cfopen(zText, "w");
|
||||
if (!F) return;
|
||||
printf("Schreibe Zusammenfassung (parteien)...\n");
|
||||
fprintf(F, "%s\n%s\n\n", global.gamename, gamedate2(default_locale));
|
||||
fprintf(F, "Auswertung Nr: %d\n\n", turn);
|
||||
|
@ -2751,24 +2748,8 @@ report_summary(summary * s, summary * o, boolean full)
|
|||
|
||||
fprintf(F, "\n\n");
|
||||
|
||||
for (i = 0; i <= NMRTimeout(); ++i) {
|
||||
nmrs[i] = 0;
|
||||
}
|
||||
|
||||
for (f = factions; f; f = f->next) {
|
||||
if (fval(f, FFL_ISNEW)) {
|
||||
++newplayers;
|
||||
} else if (f->no != MONSTER_FACTION) {
|
||||
int nmr = turn-f->lastorders;
|
||||
if (nmr<0 || nmr>NMRTimeout()) {
|
||||
log_error(("faction %s has %d NMRS\n", factionid(f), nmr));
|
||||
nmr = max(0, nmr);
|
||||
nmr = min(nmr, NMRTimeout());
|
||||
}
|
||||
nmrs[nmr]++;
|
||||
}
|
||||
}
|
||||
|
||||
newplayers = update_nmrs();
|
||||
|
||||
for (i = 0; i <= NMRTimeout(); ++i) {
|
||||
if (i == NMRTimeout()) {
|
||||
fprintf(F, "+ NMRs:\t\t %d\n", nmrs[i]);
|
||||
|
@ -2827,6 +2808,7 @@ report_summary(summary * s, summary * o, boolean full)
|
|||
writemonument();
|
||||
}
|
||||
free(nmrs);
|
||||
nmrs = NULL;
|
||||
}
|
||||
/******* end summary ******/
|
||||
|
||||
|
|
|
@ -164,6 +164,35 @@ report_item(const unit * owner, const item * i, const faction * viewer, const ch
|
|||
}
|
||||
|
||||
|
||||
int * nmrs = NULL;
|
||||
|
||||
int
|
||||
update_nmrs(void)
|
||||
{
|
||||
int i, newplayers =0;
|
||||
faction *f;
|
||||
|
||||
if (nmrs==NULL) nmrs = malloc(sizeof(int)*(NMRTimeout()+1));
|
||||
for (i = 0; i <= NMRTimeout(); ++i) {
|
||||
nmrs[i] = 0;
|
||||
}
|
||||
|
||||
for (f = factions; f; f = f->next) {
|
||||
if (fval(f, FFL_ISNEW)) {
|
||||
++newplayers;
|
||||
} else if (f->no != MONSTER_FACTION) {
|
||||
int nmr = turn-f->lastorders;
|
||||
if (nmr<0 || nmr>NMRTimeout()) {
|
||||
log_error(("faction %s has %d NMRS\n", factionid(f), nmr));
|
||||
nmr = max(0, nmr);
|
||||
nmr = min(nmr, NMRTimeout());
|
||||
}
|
||||
++nmrs[nmr];
|
||||
}
|
||||
}
|
||||
return newplayers;
|
||||
}
|
||||
|
||||
#define ORDERS_IN_NR 1
|
||||
static size_t
|
||||
buforder(char * bufp, size_t size, const order * ord, int mode)
|
||||
|
|
|
@ -103,7 +103,10 @@ extern int bufunit(const struct faction * f, const struct unit * u, int indent,
|
|||
extern const char * reportpath(void);
|
||||
extern const char * trailinto(const struct region * r, const struct locale * lang);
|
||||
|
||||
extern void reports_init(void);
|
||||
extern void reports_init(void);
|
||||
|
||||
extern int update_nmrs(void);
|
||||
extern int * nmrs;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -559,14 +559,14 @@ factionorders(void)
|
|||
/* Die Partei hat sich zumindest gemeldet, so daß sie noch
|
||||
* nicht als untätig gilt */
|
||||
|
||||
/* TODO: +1 ist ein Workaround, weil turn erst in process_orders
|
||||
* incrementiert wird. */
|
||||
f->lastorders = global.data_turn+1;
|
||||
|
||||
} else
|
||||
log_warning(("Befehle für die ungültige Partei %s\n", fid));
|
||||
|
||||
return f;
|
||||
/* TODO: +1 ist ein Workaround, weil turn erst in process_orders
|
||||
* incrementiert wird. */
|
||||
f->lastorders = global.data_turn+1;
|
||||
|
||||
} else {
|
||||
log_warning(("Befehle für die ungültige Partei %s\n", fid));
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
double
|
||||
|
|
|
@ -51,6 +51,16 @@ get_turn(void)
|
|||
return turn;
|
||||
}
|
||||
|
||||
static int
|
||||
get_nmrs(int n)
|
||||
{
|
||||
if (n<=NMRTimeout()) {
|
||||
if (nmrs==NULL) update_nmrs();
|
||||
return nmrs[n];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
find_plane_id(const char * name)
|
||||
{
|
||||
|
@ -229,6 +239,7 @@ bind_eressea(lua_State * L)
|
|||
def("dice_roll", &dice_rand),
|
||||
def("equipment_setitem", &lua_addequipment),
|
||||
def("get_turn", &get_turn),
|
||||
def("get_nmrs", &get_nmrs),
|
||||
def("remove_empty_units", &remove_empty_units),
|
||||
|
||||
def("update_subscriptions", &update_subscriptions),
|
||||
|
|
|
@ -62,6 +62,12 @@ function process(orders)
|
|||
print("could not read " .. orders)
|
||||
return -1
|
||||
end
|
||||
nmrs = get_nmrs(1)
|
||||
if nmrs >= 60 then
|
||||
print("Shit. More than 60 factions with 1 NMR (" .. nmrs .. ")")
|
||||
return -1
|
||||
fi
|
||||
print (nmrs .. " Factions with 1 NMR")
|
||||
run_scripts()
|
||||
|
||||
-- create new monsters:
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
local function kill_multis()
|
||||
local multis = { ["ms04"]="Wird wegen Parteiuebernahme geloescht" }
|
||||
local multis = {
|
||||
-- ["Luna"]="Wird wegen Missbrauch von Sonnensegeln geloescht",
|
||||
-- ["amam"]="Wird wegen Missbrauch von Sonnensegeln geloescht",
|
||||
-- ["jr81"]="Wird wegen Missbrauch von Sonnensegeln geloescht"
|
||||
}
|
||||
for k, v in multis do
|
||||
local f = get_faction(atoi36(k))
|
||||
if f~=nil then
|
||||
|
|
Loading…
Reference in New Issue