"xdump updates" believes there are always 15 (UPDATE_TIME_LEN - 1)
scheduled updates. When fewer than 15 updates are scheduled, it shows
whatever crap update time happens to be in the unused part of
update_time[]: the initial zero or a previously scheduled update.
Root cause is that table EF_UPDATES has always UPDATE_TIME_LEN - 1
entries, which is incorrect when fewer updates are scheduled. Only
xdump is affected, as the other users ignore the length and stop at
the sentinel.
Fix update_get_schedule() to resize table EF_UPDATES.
* Update schedule table. Use read_schedule() to fill.
*/
{EF_UPDATES, "updates", NULL, update_ca,
* Update schedule table. Use read_schedule() to fill.
*/
{EF_UPDATES, "updates", NULL, update_ca,
- ARRAY_TABLE(update_time, EFF_CFG)},
+ ARRAY_CACHE(update_time, EFF_CFG)},
/*
* Special tables. EF_META gets bogus size, cids and fids here.
* Fixed up by empfile_init(). EF_VERSION's cadef is set by
/*
* Special tables. EF_META gets bogus size, cids and fids here.
* Fixed up by empfile_init(). EF_VERSION's cadef is set by
#endif
#include <time.h>
#include "empthread.h"
#endif
#include <time.h>
#include "empthread.h"
#include "game.h"
#include "misc.h"
#include "optlist.h"
#include "game.h"
#include "misc.h"
#include "optlist.h"
update_get_schedule(void)
{
time_t now = time(NULL);
update_get_schedule(void)
{
time_t now = time(NULL);
+ int n = sizeof(update_time) / sizeof(*update_time);
+ int i;
- if (read_schedule(schedulefil, update_time,
- sizeof(update_time) / sizeof(*update_time),
+ ef_truncate(EF_UPDATES, 0);
+ ef_extend(EF_UPDATES, n - 1);
+ if (read_schedule(schedulefil, update_time, n,
now + 30, update_schedule_anchor) < 0) {
logerror("No update schedule!");
now + 30, update_schedule_anchor) < 0) {
logerror("No update schedule!");
+ ef_truncate(EF_UPDATES, 0);
return -1;
}
logerror("Update schedule read");
return -1;
}
logerror("Update schedule read");
+ for (i = 0; update_time[i]; i++) ;
+ ef_truncate(EF_UPDATES, i);