summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-05-16 20:58:43 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-05-16 20:58:43 +0300
commit5f1bdde29d83e2e20d262f3ed0b19f37f3ac7e5e (patch)
treefe77776b03bd10c6470f0716aabb157a33be555a
parent5e6a88f7497947aec3f8d66bc023725c75e814eb (diff)
fixes #2872 (Weather: incorrect icons mapping)
-rw-r--r--protocols/Weather/src/stdafx.h2
-rw-r--r--protocols/Weather/src/version.h2
-rw-r--r--protocols/Weather/src/weather_conv.cpp8
-rw-r--r--protocols/Weather/src/weather_ini.cpp16
-rw-r--r--protocols/Weather/src/weather_svcs.cpp4
-rw-r--r--protocols/Weather/weather.vcxproj1
-rw-r--r--protocols/Weather/weather.vcxproj.filters3
7 files changed, 15 insertions, 21 deletions
diff --git a/protocols/Weather/src/stdafx.h b/protocols/Weather/src/stdafx.h
index 9c540783ae..5b105d19ca 100644
--- a/protocols/Weather/src/stdafx.h
+++ b/protocols/Weather/src/stdafx.h
@@ -321,7 +321,7 @@ typedef struct {
WIDATAITEMLIST *UpdateDataTail;
WIIDSEARCH IDSearch;
WINAMESEARCH NameSearch;
- WICONDLIST CondList[10];
+ WICONDLIST CondList[8];
} WIDATA;
//============ DATA LIST (LINKED LIST) ============
diff --git a/protocols/Weather/src/version.h b/protocols/Weather/src/version.h
index c08ac96a1d..c081f771da 100644
--- a/protocols/Weather/src/version.h
+++ b/protocols/Weather/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 4
#define __RELEASE_NUM 0
-#define __BUILD_NUM 5
+#define __BUILD_NUM 6
#include <stdver.h>
diff --git a/protocols/Weather/src/weather_conv.cpp b/protocols/Weather/src/weather_conv.cpp
index debbaeab89..0b5749c12f 100644
--- a/protocols/Weather/src/weather_conv.cpp
+++ b/protocols/Weather/src/weather_conv.cpp
@@ -316,13 +316,13 @@ void GetElev(wchar_t *tempchar, wchar_t *unit, wchar_t *str)
// cond = the string for weather condition
// return value = status for the icon (ONLINE, OFFLINE, etc)
-static const wchar_t *statusStr[10] = { L"Lightning", L"Fog", L"Snow", L"Rain", L"Partly Cloudy", L"Cloudy", L"Sunny", L"N/A" };
-static const WORD statusValue[10] = { LIGHT, FOG, SNOW, RAIN, PCLOUDY, CLOUDY, SUNNY, NA };
+static const wchar_t *statusStr[] = { L"Lightning", L"Fog", L"Snow", L"Rain", L"Partly Cloudy", L"Cloudy", L"Sunny", L"N/A" };
+static const WORD statusValue[] = { LIGHT, FOG, SNOW, RAIN, PCLOUDY, CLOUDY, SUNNY, NA };
WORD GetIcon(const wchar_t *cond, WIDATA *Data)
{
// set the icon using ini
- for (int i = 0; i < 10; i++)
+ for (int i = 0; i < _countof(statusValue); i++)
if (IsContainedInCondList(cond, &Data->CondList[i]))
return statusValue[i];
@@ -349,7 +349,7 @@ WORD GetIcon(const wchar_t *cond, WIDATA *Data)
return RAIN;
// set the icon using langpack
- for (int i = 0; i < 9; i++) {
+ for (int i = 0; i < _countof(statusStr)-1; i++) {
wchar_t LangPackStr[64], LangPackStr1[128];
int j = 0;
do {
diff --git a/protocols/Weather/src/weather_ini.cpp b/protocols/Weather/src/weather_ini.cpp
index 101f5e5d09..cc2ebae6a8 100644
--- a/protocols/Weather/src/weather_ini.cpp
+++ b/protocols/Weather/src/weather_ini.cpp
@@ -113,7 +113,7 @@ void WICondListAdd(char *str, WICONDLIST *List)
{
WICONDITEM *newItem = (WICONDITEM*)mir_alloc(sizeof(WICONDITEM));
wSetData(&newItem->Item, str);
- CharLowerBuff(newItem->Item, (DWORD)mir_wstrlen(newItem->Item));
+ CharLowerW(newItem->Item);
newItem->Next = nullptr;
if (List->Tail == nullptr) List->Head = newItem;
else List->Tail->Next = newItem;
@@ -224,13 +224,11 @@ static INT_PTR CALLBACK DlgProcSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
// pszShortFile = the file name of the ini file, but not including the path
// Data = the struct to load the ini content to, and return to previous function
-static const char *statusStr[10] =
+static const char *statusStr[] =
{
"LIGHTNING",
"FOG",
- "SNOW SHOWER",
"SNOW",
- "RAIN SHOWER",
"RAIN",
"PARTLY CLOUDY",
"CLOUDY",
@@ -328,8 +326,8 @@ static void LoadStationData(const wchar_t *pszFile, wchar_t *pszShortFile, WIDAT
Data->UpdateDataTail = nullptr;
// initialize the icon assignment list
- for (int i = 0; i < 10; i++)
- WICondListInit(&Data->CondList[i]);
+ for (auto &it : Data->CondList)
+ WICondListInit(&it);
while (!feof(pfile)) {
// determine current tag
@@ -432,7 +430,7 @@ static void LoadStationData(const wchar_t *pszFile, wchar_t *pszShortFile, WIDAT
else if (!_stricmp(ValName, "MULT ID END")) wSetData(&Data->NameSearch.Multiple.ID.End, Value);
}
else if (!_stricmp(Group, "ICONS")) {
- for (int i = 0; i < 10; i++) {
+ for (int i = 0; i < _countof(statusStr); i++) {
if (!_stricmp(ValName, statusStr[i])) {
WICondListAdd(Value, &Data->CondList[i]);
break;
@@ -567,8 +565,8 @@ static void FreeWIData(WIDATA *Data)
FreeDataItem(&Data->NameSearch.Multiple.ID);
wfree(&Data->ShortFileName);
wfree(&Data->FileName);
- for (int i = 0; i < 10; i++)
- DestroyCondList(&Data->CondList[i]);
+ for (auto &it : Data->CondList)
+ DestroyCondList(&it);
}
// remove all service data from memory
diff --git a/protocols/Weather/src/weather_svcs.cpp b/protocols/Weather/src/weather_svcs.cpp
index e71a5fa0e0..e6987a40c7 100644
--- a/protocols/Weather/src/weather_svcs.cpp
+++ b/protocols/Weather/src/weather_svcs.cpp
@@ -132,11 +132,11 @@ INT_PTR WeatherGetAvatarInfo(WPARAM, LPARAM lParam)
else szSearchPath[0] = 0;
int iStatus = g_plugin.getWord(pai->hContact, "StatusIcon");
- for (i = 0; i < 10; i++)
+ for (i = 0; i < _countof(statusValue); i++)
if (statusValue[i] == iStatus)
break;
- if (i >= 10)
+ if (i >= _countof(statusValue))
return GAIR_NOAVATAR;
pai->format = PA_FORMAT_PNG;
diff --git a/protocols/Weather/weather.vcxproj b/protocols/Weather/weather.vcxproj
index ed6396e0dc..35e9cf3032 100644
--- a/protocols/Weather/weather.vcxproj
+++ b/protocols/Weather/weather.vcxproj
@@ -35,7 +35,6 @@
<ClCompile Include="src\weather_conv.cpp" />
<ClCompile Include="src\weather_data.cpp" />
<ClCompile Include="src\weather_http.cpp" />
- <ClCompile Include="src\weather_icons.cpp" />
<ClCompile Include="src\weather_info.cpp" />
<ClCompile Include="src\weather_ini.cpp" />
<ClCompile Include="src\weather_mwin.cpp" />
diff --git a/protocols/Weather/weather.vcxproj.filters b/protocols/Weather/weather.vcxproj.filters
index 19d0900afa..a8fbc7147e 100644
--- a/protocols/Weather/weather.vcxproj.filters
+++ b/protocols/Weather/weather.vcxproj.filters
@@ -23,9 +23,6 @@
<ClCompile Include="src\weather_http.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\weather_icons.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\weather_info.cpp">
<Filter>Source Files</Filter>
</ClCompile>