Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scoring #390

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/globalvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ extern char fkey_header[60];

extern SCREEN *mainscreen;

extern bool mult_side;
extern bool countrylist_only;
extern bool mixedmode;
extern bool qso_once;
extern bool leading_zeros_serial;
Expand Down
2 changes: 0 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,11 @@ int my_country_points = -1;
int my_cont_points = -1;
int dx_cont_points = -1;
char countrylist[255][6];
bool countrylist_only = false;
int countrylist_points = -1;
char continent_multiplier_list[7][3]; // SA, NA, EU, AF, AS and OC
int continentlist_points = -1;
bool continentlist_only = false;
int exclude_multilist_type = EXCLUDE_NONE;
bool mult_side = false;
/* end LZ3NY mods */

bool portable_x2 = false;
Expand Down
12 changes: 0 additions & 12 deletions src/parse_logcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,9 +648,6 @@ static int cfg_countrylist(const cfg_arg_t arg) {
}
}

/* on which multiplier side of the rules we are */
getpx(my.call);
mult_side = exist_in_country_list();
setcontest(whichcontest);

return PARSE_OK;
Expand Down Expand Up @@ -741,14 +738,6 @@ static int cfg_continentlist(const cfg_arg_t arg) {
return PARSE_OK;
}

static int cfg_country_list_only(const cfg_arg_t arg) {
countrylist_only = true;
if (mult_side) {
countrylist_only = false;
}
return PARSE_OK;
}

static int cfg_bandweight_points(const cfg_arg_t arg) {
static char bwp_params_list[50] = "";
int bandindex = -1;
Expand Down Expand Up @@ -1280,7 +1269,6 @@ static config_t logcfg_configs[] = {
{"DX_&_SECTIONS", NO_PARAM, cfg_dx_n_sections},
{"COUNTRYLIST", NEED_PARAM, cfg_countrylist},
{"CONTINENTLIST", NEED_PARAM, cfg_continentlist},
{"USE_COUNTRYLIST_ONLY", NO_PARAM, cfg_country_list_only},
{"SIDETONE_VOLUME", NEED_PARAM, cfg_sc_volume},
{"MFJ1278_KEYER", NEED_PARAM, cfg_mfj1278_keyer},
{"CHANGE_RST", OPTIONAL_PARAM, cfg_change_rst},
Expand Down
59 changes: 21 additions & 38 deletions src/score.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* Tlf - contest logging program for amateur radio operators
* Copyright (C) 2001-2002-2003 Rein Couperus <[email protected]>
* 2013 Ervin Hegedus <[email protected]>
* 2013-2015, 2020
* Thomas Beierlein <[email protected]>
* 2013-2023 Thomas Beierlein <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -98,7 +97,7 @@ bool exist_in_country_list() {
}


/* HA2OS - check if continent is in CONTINENT_LIST from logcfg.dat */
/* check if continent is in CONTINENT_LIST */
bool is_in_continentlist(char *continent) {
int i = 0;

Expand All @@ -112,8 +111,7 @@ bool is_in_continentlist(char *continent) {
}


/* apply bandweight scoring *
* at the moment only LOWBAND_DOUBLES (<30m) can be active */
/* apply bandweight scoring */
int apply_bandweight(int points, int bandindex) {

if (lowband_point_mult && (bandindex < BANDINDEX_30))
Expand Down Expand Up @@ -148,53 +146,38 @@ int scoreByMode(struct qso_t *qso) {
}
}

/* Overwrite points with x if set */
#define USE_IF_SET(x) do { \

/* return x points if set */
#define RETURN_IF_SET(x) do { \
if (x >= 0) \
points = x; \
return x; \
} while(0);

int scoreByContinentOrCountry(struct qso_t *qso) {

int points = 0;
prefix_data *ctyinfo = getctyinfo(qso->call);
bool inCountryList = is_in_countrylist(ctyinfo->dxcc_ctynr);

if (countrylist_only) {
points = 0;
if (inCountryList)
USE_IF_SET(countrylist_points);
if (ctyinfo->dxcc_ctynr == my.countrynr) {
RETURN_IF_SET(my_country_points);
}

return points;
if (inCountryList) {
RETURN_IF_SET(countrylist_points);
}

/* HA2OS mods */
if (continentlist_only) {
points = 0;
// only continent list allowed
if (is_in_continentlist(ctyinfo->continent)) {
USE_IF_SET(continentlist_points);
// overwrite if own continent and my_cont_points set
if (strcmp(ctyinfo->continent, my.continent) == 0) {
USE_IF_SET(my_cont_points);
}
}
return points;
if (strcmp(ctyinfo->continent, my.continent) == 0) {
RETURN_IF_SET(my_cont_points);
}

// default
if (ctyinfo->dxcc_ctynr == my.countrynr) {
points = 0;
USE_IF_SET(my_cont_points);
USE_IF_SET(my_country_points);
} else if (inCountryList) {
USE_IF_SET(countrylist_points);
} else if (strcmp(ctyinfo->continent, my.continent) == 0) {
USE_IF_SET(my_cont_points);
} else
USE_IF_SET(dx_cont_points);
if (is_in_continentlist(ctyinfo->continent)) {
RETURN_IF_SET(continentlist_points);
}

return points;
if (strcmp(ctyinfo->continent, my.continent) != 0) {
RETURN_IF_SET(dx_cont_points);
}
return 0;
}


Expand Down
2 changes: 0 additions & 2 deletions test/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,11 @@ int my_country_points = -1;
int my_cont_points = -1;
int dx_cont_points = -1;
char countrylist[255][6];
bool countrylist_only = false;
int countrylist_points = -1;
char continent_multiplier_list[7][3]; // SA, NA, EU, AF, AS and OC
int continentlist_points = -1;
bool continentlist_only = false;
int exclude_multilist_type = EXCLUDE_NONE;
bool mult_side = false;
/* end LZ3NY mods */

bool portable_x2 = false;
Expand Down
2 changes: 0 additions & 2 deletions test/test_addcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ int setup_default(void **state) {
strcpy(countrylist[1], "CE");
strcpy(countrylist[2], "");

countrylist_only = false;

strcpy(continent_multiplier_list[0], "EU");
strcpy(continent_multiplier_list[1], "NA");
strcpy(continent_multiplier_list[2], "");
Expand Down
18 changes: 0 additions & 18 deletions test/test_parse_logcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ int setup_default(void **state) {
nodes = 0;
xplanet = MARKER_NONE;
dx_arrlsections = false;
mult_side = false;
countrylist_points = -1;
my_country_points = -1;
my_cont_points = -1;
Expand Down Expand Up @@ -1091,7 +1090,6 @@ void test_countrylist(void **state) {
assert_string_equal(countrylist[1], "GM");
assert_string_equal(countrylist[2], "F");
assert_string_equal(countrylist[3], "");
assert_true(mult_side);
assert_int_equal(CONTEST_IS(UNKNOWN), 1);
}

Expand All @@ -1109,7 +1107,6 @@ void test_countrylist_long(void **state) {
assert_string_equal(countrylist[128], "VU");
assert_string_equal(countrylist[160], "ZS8");
assert_string_equal(countrylist[161], "");
assert_false(mult_side);
assert_int_equal(CONTEST_IS(UNKNOWN), 1);
}

Expand All @@ -1121,7 +1118,6 @@ void test_countrylist_from_file(void **state) {
assert_string_equal(countrylist[0], "EA");
assert_string_equal(countrylist[1], "CT");
assert_string_equal(countrylist[2], "");
assert_true(mult_side);
assert_int_equal(CONTEST_IS(UNKNOWN), 1);
}

Expand All @@ -1141,7 +1137,6 @@ void test_countrylist_from_file_long(void **state) {
assert_string_equal(countrylist[128], "VU");
assert_string_equal(countrylist[160], "ZS8");
assert_string_equal(countrylist[161], "");
assert_true(mult_side);
assert_int_equal(CONTEST_IS(UNKNOWN), 1);
}

Expand All @@ -1151,19 +1146,6 @@ void test_countrylist_points(void **state) {
assert_int_equal(countrylist_points, 4);
}

void test_countrylist_only(void **state) {
int rc = call_parse_logcfg("USE_COUNTRYLIST_ONLY\n");
assert_int_equal(rc, PARSE_OK);
assert_true(countrylist_only);
}

void test_countrylist_only_mult_side(void **state) {
mult_side = true;
int rc = call_parse_logcfg("USE_COUNTRYLIST_ONLY\n");
assert_int_equal(rc, PARSE_OK);
assert_false(countrylist_only);
}

void test_my_country_points(void **state) {
int rc = call_parse_logcfg("MY_COUNTRY_POINTS=4\n");
assert_int_equal(rc, PARSE_OK);
Expand Down
Loading