Skip to content

Commit

Permalink
Rescore upon reading the log (#292)
Browse files Browse the repository at this point in the history
* rescore upon reading the log

* prompt user to update log file on rescoring changes

* makelogline: rework using qso_t

* readcalls: avoid showstring warning
  • Loading branch information
zcsahok authored Jan 4, 2022
1 parent a6a243d commit ceef327
Show file tree
Hide file tree
Showing 28 changed files with 487 additions and 620 deletions.
41 changes: 21 additions & 20 deletions src/addcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@
#include "tlf.h"
#include "zone_nr.h"

int excl_add_veto;
/* This variable helps to handle in other modules, that station is multiplier
* or not */
/* In addcall2(), this variable helps to handle the excluded multipliers,
* which came from lan_logline the Tlf scoring logic is totally completely
* different in local and LAN source the addcall() function doesn't increment
* the band_score[] array, that maintains the score() function. Here, the
* addcall2() is need to separate the points and multipliers.
*/


/* collect all relevant data for the actual QSO into a qso_t structure */
struct qso_t *collect_qso_data(void) {
Expand All @@ -73,6 +63,9 @@ struct qso_t *collect_qso_data(void) {
qso->freq = freq;
qso->timestamp = get_time();
qso->comment = g_strdup(comment);
qso->qso_nr = qsonum;
qso->rst_s = atoi(sent_rst);
qso->rst_r = atoi(recvd_rst);
return qso;
}

Expand Down Expand Up @@ -123,8 +116,10 @@ int addcall(struct qso_t *qso) {
bool add_ok;
int pfxnumcntidx = -1;
int pxnr = 0;
bool excl_add_veto = false;

excl_add_veto = 0;
new_cty = 0;
new_zone = 0;

int station = lookup_or_add_worked(qso->call);
update_worked(station, qso);
Expand Down Expand Up @@ -164,18 +159,23 @@ int addcall(struct qso_t *qso) {

if (continentlist_only) {
if (!is_in_continentlist(dxcc_by_index(cty)->continent)) {
excl_add_veto = 1;
excl_add_veto = true;
}
}

excl_add_veto |= check_veto(cty);
if (excl_add_veto) {
add_ok = false;
new_cty = 0;
new_zone = 0;
addcallarea = 0;
}

/* If WPX -> add prefix to prefixes_worked */
new_pfx = false;
if (!excl_add_veto || !pfxmultab) {
/* add prefix, remember if new */
new_pfx = (add_pfx(wpx_prefix, qso->bandindex) == 0);
}

/* qso's per band */
if (!(CONTEST_IS(ARRLDX_USA)
&& ((countrynr == w_cty) || (countrynr == ve_cty))))
Expand Down Expand Up @@ -207,13 +207,14 @@ int addcall(struct qso_t *qso) {
}
}

addmult(current_qso); /* for wysiwyg */
addmult(qso); /* for wysiwyg */

return cty;
}

/* ----------------------for network qso's-----------------------------------*/

int excl_add_veto2;
int addcall2(void) {

int cty, zone = 0;
Expand All @@ -224,7 +225,7 @@ int addcall2(void) {
int bandinx;
int pfxnumcntidx = -1;
int pxnr = 0;
excl_add_veto = 0;
excl_add_veto2 = 0;

/* parse copy of lan_logline */
struct qso_t *qso;
Expand Down Expand Up @@ -274,12 +275,12 @@ int addcall2(void) {

if (continentlist_only) {
if (!is_in_continentlist(dxcc_by_index(cty)->continent)) {
excl_add_veto = 1;
excl_add_veto2 = 1;
}
}

excl_add_veto |= check_veto(cty);
if (excl_add_veto) {
excl_add_veto2 |= check_veto(cty);
if (excl_add_veto2) {
add_ok = false;
new_cty = 0;
addcallarea = 0;
Expand All @@ -291,7 +292,7 @@ int addcall2(void) {

worked[station].band |= inxes[bandinx]; /* worked on this band */

if (excl_add_veto == 0) {
if (excl_add_veto2 == 0) {

if (pfxnumcntidx < 0) {
if (cty != 0 && (countries[cty] & inxes[bandinx]) == 0) {
Expand Down
18 changes: 9 additions & 9 deletions src/addmult.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void addmult(struct qso_t *qso) {

idx = get_exact_mult_index(mult1_value);
if (idx >= 0) {
remember_multi(get_mult(idx), bandinx, ALL_BAND);
remember_multi(get_mult(idx), qso->bandindex, ALL_BAND);
// NOTE: return value not used, new mult is not marked in log
}
}
Expand All @@ -69,7 +69,7 @@ void addmult(struct qso_t *qso) {
idx = get_exact_mult_index(mult1_value);
if (idx >= 0) {
new_mult =
remember_multi(get_mult(idx), bandinx, PER_BAND);
remember_multi(get_mult(idx), qso->bandindex, PER_BAND);
}
}

Expand All @@ -80,7 +80,7 @@ void addmult(struct qso_t *qso) {
idx = get_exact_mult_index(mult1_value);
if (idx >= 0) {
new_mult =
remember_multi(get_mult(idx), bandinx, ALL_BAND);
remember_multi(get_mult(idx), qso->bandindex, ALL_BAND);
}
}

Expand All @@ -90,31 +90,31 @@ void addmult(struct qso_t *qso) {
idx = get_exact_mult_index(mult1_value);
if (idx >= 0) {
new_mult =
remember_multi(get_mult(idx), bandinx, PER_BAND);
remember_multi(get_mult(idx), qso->bandindex, PER_BAND);
}
}

// --------------------wysiwyg----------------
else if (wysiwyg_once) {
new_mult = remember_multi(stripped_comment, bandinx, ALL_BAND);
new_mult = remember_multi(stripped_comment, qso->bandindex, ALL_BAND);
}

else if (wysiwyg_multi) {
new_mult = remember_multi(stripped_comment, bandinx, PER_BAND);
new_mult = remember_multi(stripped_comment, qso->bandindex, PER_BAND);
}

else if (serial_grid4_mult) {
section[4] = '\0';
new_mult = remember_multi(section, bandinx, PER_BAND);
new_mult = remember_multi(section, qso->bandindex, PER_BAND);
}

/* -------------- unique call multi -------------- */
else if (unique_call_multi == UNIQUECALL_ALL) {
new_mult = remember_multi(qso->call, bandinx, ALL_BAND);
new_mult = remember_multi(qso->call, qso->bandindex, ALL_BAND);
}

else if (unique_call_multi == UNIQUECALL_BAND) {
new_mult = remember_multi(qso->call, bandinx, PER_BAND);
new_mult = remember_multi(qso->call, qso->bandindex, PER_BAND);
}

free(stripped_comment);
Expand Down
2 changes: 1 addition & 1 deletion src/background_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void *background_process(void *ptr) {

if ((qsonum <= n) && (n > 0)) {
qsonum = highqsonr + 1;
qsonr_to_str();
qsonr_to_str(qsonrstr, qsonum);
}
lan_message[0] = '\0';

Expand Down
7 changes: 3 additions & 4 deletions src/changepars.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,16 +512,15 @@ int changepars(void) {
case 41: { /* SYNC */
if (strlen(synclogfile) > 0)
synclog(synclogfile);
nr_qsos = log_read_n_score();
scroll_log();
/** \todo register return value */
log_read_n_score();
clear_display();
break;
}
case 42: { /* RESCORE */
/** \todo register return value */
log_read_n_score();
nr_qsos = log_read_n_score();
clear_display();
scroll_log();
break;
}
case 43: { /* SCVOLUME - set soundcard volume */
Expand Down
2 changes: 1 addition & 1 deletion src/clear_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void clear_display(void) {
format_time(time_buf, sizeof(time_buf), DATE_TIME_FORMAT);
update_line(time_buf);

qsonr_to_str();
qsonr_to_str(qsonrstr, qsonum);
mvaddstr(12, 23, qsonrstr);

if (no_rst) {
Expand Down
9 changes: 3 additions & 6 deletions src/editlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "checklogfile.h"
#include "clear_display.h"
#include "err_utils.h"
#include "globalvars.h"
#include "ignore_unused.h"
#include "readqtccalls.h"
#include "readcalls.h"
Expand Down Expand Up @@ -71,15 +72,11 @@ void edit(char *filename) {

void logedit(void) {

extern char logfile[];

int j;

stop_background_process();
edit(logfile);
checklogfile();

log_read_n_score();
nr_qsos = log_read_n_score();

start_background_process();

Expand All @@ -90,7 +87,7 @@ void logedit(void) {
clear_display();
attron(COLOR_PAIR(C_LOG) | A_STANDOUT);

for (j = 13; j < LINES - 1; j++) {
for (int j = 13; j < LINES - 1; j++) {
clear_line(j);
}
refreshp();
Expand Down
2 changes: 1 addition & 1 deletion src/getexchange.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ int getexchange(void) {
&& ((x != TAB) && (strlen(section) < 1))) {
if (!serial_or_section
|| (serial_or_section && country_found(hiscall))) {
mvaddstr(13, 54, "section?X");
mvaddstr(13, 54, "section?");
mvaddstr(12, 54, comment);
refreshp();
}
Expand Down
15 changes: 11 additions & 4 deletions src/getmessages.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "getctydata.h"
#include "globalvars.h"
#include "locator2longlat.h"
#include "startmsg.h"


/* get countrynumber, QTH, CQ zone and continent for myself */
Expand Down Expand Up @@ -53,10 +54,16 @@ void show_station_info(void) {

getstationinfo();

printw("\n Call = %s\n", my.call);
printw(" My Zone = %d", my.cqzone);
printw(" My Continent = %s", my.continent);
printw("\n\n");
showmsg("");
char *info;
info = g_strdup_printf(" Call = %s\n", my.call);
showmsg(info);
g_free(info);
info = g_strdup_printf(" My Zone = %02d My Continent = %s\n",
my.cqzone, my.continent);
showmsg(info);
g_free(info);
showmsg("");

refreshp();
}
3 changes: 1 addition & 2 deletions src/globalvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ extern char band[NBANDS][4];
extern freq_t bandfrequency[NBANDS];

extern struct tm *time_ptr;
extern struct tm time_ptr_cabrillo;

extern char cqzone[];
extern char ituzone[];
Expand Down Expand Up @@ -122,7 +121,7 @@ extern bool wazmult;
extern int addcallarea;
extern int new_cty;
extern int new_zone;
extern int do_cabrillo;
extern bool new_pfx;
extern bool no_rst;
extern rmode_t digi_mode;
extern int minitest; // minitest period length in seconds, 0 if not used
Expand Down
10 changes: 3 additions & 7 deletions src/log_to_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ void restart_band_timer(void) {
}
}

/* score QSO and add to total points */
void score_qso(void) {
qso_points = score(); /* update qso's per band and score */
total = total + qso_points;
}

/** \brief logs one record to disk
* Logs one record to disk which may come from different sources
* (direct from tlf or from other instance via LAN)
Expand Down Expand Up @@ -94,7 +88,9 @@ void log_to_disk(int from_lan) {
addcall(current_qso); /* add call to dupe list */

score_qso();
makelogline();
char *logline = makelogline(current_qso);
strcpy(logline4, logline);
g_free(logline);

store_qso(logline4);

Expand Down
1 change: 0 additions & 1 deletion src/log_to_disk.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#define LOG_TO_DISK_H

void restart_band_timer(void);
void score_qso(void);
void log_to_disk(int from_lan);

#endif /* LOG_TO_DISK_H */
11 changes: 5 additions & 6 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,14 @@ int countryscore[NBANDS];
int zonedisplay = 0;
int new_zone = 0; /* index of new zone */
int new_cty = 0; /* index of new country */
bool new_pfx = false; /* worked a new prefix */
int new_mult = -1;
int minute_timer = 0;

int bandinx = BANDINDEX_40; /* start with 40m */
int qsonum = 1; /* nr of next QSO */
int ymax, xmax; /* screen size */

struct tm time_ptr_cabrillo;

freq_t freq;
bool logfrequency = false;
bool rit;
Expand Down Expand Up @@ -414,7 +413,6 @@ char itustr[3];
bool nopacket = false; /* set if tlf is called with '-n' */
bool no_trx_control = false; /* set if tlf is called with '-r' */
bool convert_cabrillo = false; /* set if the arg input is a cabrillo */
int do_cabrillo = 0; /* actually converting cabrillo file to Tlf log */

int bandweight_points[NBANDS] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0};
int bandweight_multis[NBANDS] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0};
Expand Down Expand Up @@ -1024,12 +1022,13 @@ int main(int argc, char *argv[]) {
lan_init();
keyer_init();

nr_qsos = readcalls(logfile); /* read the logfile and rebuild
point and multiplier scoring */
show_station_info();

nr_qsos = readcalls(logfile, true); /* read the logfile and rebuild
point and multiplier scoring */

scroll_log(); /* show the last 5 log lines and
set the next serial number */
show_station_info();
clearmsg_wait();

packet_init();
Expand Down
Loading

0 comments on commit ceef327

Please sign in to comment.