Fix read not to split production report when update is slow
Adjacent telegrams are squashed together if type and sender are the same, and the timestamp is "close enough". This is done in two places: rea() and typed_wu(). They're inconsistent: typed_wu() ignores the timestamp for production reports since Empire 2, but rea() doesn't. Record typed_wu()'s decision in new telstr member tel_cont. Use it in rea().
This commit is contained in:
parent
a0b82b8d46
commit
17223e8fe2
3 changed files with 8 additions and 23 deletions
|
@ -27,7 +27,7 @@
|
||||||
* tel.h: Definitions for things having to do with telegrams
|
* tel.h: Definitions for things having to do with telegrams
|
||||||
*
|
*
|
||||||
* Known contributors to this file:
|
* Known contributors to this file:
|
||||||
* Markus Armbruster, 2009-2010
|
* Markus Armbruster, 2009-2011
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TEL_H
|
#ifndef TEL_H
|
||||||
|
@ -50,6 +50,7 @@
|
||||||
struct telstr {
|
struct telstr {
|
||||||
natid tel_from; /* sender */
|
natid tel_from; /* sender */
|
||||||
unsigned char tel_type;
|
unsigned char tel_type;
|
||||||
|
signed char tel_cont; /* squash into prev. telegram? */
|
||||||
unsigned tel_length; /* how long */
|
unsigned tel_length; /* how long */
|
||||||
time_t tel_date; /* when sent */
|
time_t tel_date; /* when sent */
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
* Doug Hay, 1998
|
* Doug Hay, 1998
|
||||||
* Steve McClure, 1998-2000
|
* Steve McClure, 1998-2000
|
||||||
* Ron Koenderink, 2005-2007
|
* Ron Koenderink, 2005-2007
|
||||||
* Markus Armbruster, 2009
|
* Markus Armbruster, 2009-2011
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -62,10 +62,6 @@ rea(void)
|
||||||
int teles;
|
int teles;
|
||||||
int size;
|
int size;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
int lasttype;
|
|
||||||
int lastcnum;
|
|
||||||
time_t lastdate;
|
|
||||||
int header;
|
|
||||||
int filelen;
|
int filelen;
|
||||||
char *kind;
|
char *kind;
|
||||||
int n, res;
|
int n, res;
|
||||||
|
@ -74,7 +70,6 @@ rea(void)
|
||||||
time_t now;
|
time_t now;
|
||||||
time_t then;
|
time_t then;
|
||||||
time_t delta;
|
time_t delta;
|
||||||
int first = 1;
|
|
||||||
int may_delete = 1; /* may messages be deleted? */
|
int may_delete = 1; /* may messages be deleted? */
|
||||||
|
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
|
@ -108,9 +103,6 @@ rea(void)
|
||||||
teles = 0;
|
teles = 0;
|
||||||
size = fsize(fileno(telfp));
|
size = fsize(fileno(telfp));
|
||||||
more:
|
more:
|
||||||
lastdate = 0;
|
|
||||||
lastcnum = -1;
|
|
||||||
lasttype = -1;
|
|
||||||
while ((res = tel_read_header(telfp, mbox, &tgm)) > 0) {
|
while ((res = tel_read_header(telfp, mbox, &tgm)) > 0) {
|
||||||
if (*kind == 'a') {
|
if (*kind == 'a') {
|
||||||
if ((!player->god && (getrejects(tgm.tel_from, np) & REJ_ANNO))
|
if ((!player->god && (getrejects(tgm.tel_from, np) & REJ_ANNO))
|
||||||
|
@ -121,26 +113,16 @@ rea(void)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (first && *kind == 'a') {
|
if (!teles && *kind == 'a')
|
||||||
pr("\nAnnouncements since %s", ctime(&then));
|
pr("\nAnnouncements since %s", ctime(&then));
|
||||||
first = 0;
|
if (!teles || !tgm.tel_cont) {
|
||||||
}
|
|
||||||
header = 0;
|
|
||||||
if (tgm.tel_type != lasttype || tgm.tel_from != lastcnum)
|
|
||||||
header++;
|
|
||||||
if (abs((int)(tgm.tel_date - (long)lastdate)) > TEL_SECONDS)
|
|
||||||
header++;
|
|
||||||
if (header) {
|
|
||||||
pr("\n> ");
|
pr("\n> ");
|
||||||
lastcnum = tgm.tel_from;
|
|
||||||
lasttype = tgm.tel_type;
|
|
||||||
pr("%s ", telnames[tgm.tel_type]);
|
pr("%s ", telnames[tgm.tel_type]);
|
||||||
if ((tgm.tel_type == TEL_NORM) ||
|
if ((tgm.tel_type == TEL_NORM) ||
|
||||||
(tgm.tel_type == TEL_ANNOUNCE) ||
|
(tgm.tel_type == TEL_ANNOUNCE) ||
|
||||||
(tgm.tel_type == TEL_BULLETIN))
|
(tgm.tel_type == TEL_BULLETIN))
|
||||||
pr("from %s, (#%d)", cname(tgm.tel_from), tgm.tel_from);
|
pr("from %s, (#%d)", cname(tgm.tel_from), tgm.tel_from);
|
||||||
pr(" dated %s", ctime(&tgm.tel_date));
|
pr(" dated %s", ctime(&tgm.tel_date));
|
||||||
lastdate = tgm.tel_date;
|
|
||||||
}
|
}
|
||||||
teles++;
|
teles++;
|
||||||
res = tel_read_body(telfp, mbox, &tgm, print_sink, NULL);
|
res = tel_read_body(telfp, mbox, &tgm, print_sink, NULL);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
*
|
*
|
||||||
* Known contributors to this file:
|
* Known contributors to this file:
|
||||||
* Steve McClure, 2000
|
* Steve McClure, 2000
|
||||||
|
* Markus Armbruster, 2005-2011
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -145,6 +146,7 @@ typed_wu(natid from, natid to, char *message, int type)
|
||||||
len = strlen(message);
|
len = strlen(message);
|
||||||
tel.tel_length = len;
|
tel.tel_length = len;
|
||||||
tel.tel_type = type;
|
tel.tel_type = type;
|
||||||
|
tel.tel_cont = !telegram_is_new(to, &tel);
|
||||||
iov[0].iov_base = &tel;
|
iov[0].iov_base = &tel;
|
||||||
iov[0].iov_len = sizeof(tel);
|
iov[0].iov_len = sizeof(tel);
|
||||||
iov[1].iov_base = message;
|
iov[1].iov_base = message;
|
||||||
|
@ -169,7 +171,7 @@ typed_wu(natid from, natid to, char *message, int type)
|
||||||
putnat(np);
|
putnat(np);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!np->nat_tgms || telegram_is_new(to, &tel)) {
|
if (!np->nat_tgms || !tel.tel_cont) {
|
||||||
np->nat_tgms++;
|
np->nat_tgms++;
|
||||||
putnat(np);
|
putnat(np);
|
||||||
if (np->nat_flags & NF_INFORM) {
|
if (np->nat_flags & NF_INFORM) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue