From 6e0d3139c80b32f0be331c006befc815aace2bfe Mon Sep 17 00:00:00 2001
From: heinrich5991 <heinrich5991@gmail.com>
Date: Mon, 24 Dec 2018 22:58:06 +0100
Subject: [PATCH 2/2] Fix a couple of warnings
Use autogenerated copy constructors for ranges, don't use fallthrough as
control flow, initialize variables, don't cast something to a `const T`
in an expression.
---
src/base/tl/range.h | 10 ----------
src/engine/shared/console.cpp | 2 +-
src/game/client/components/mapimages.cpp | 4 ++--
src/game/client/gameclient.cpp | 13 +++++++------
src/game/client/localization.cpp | 1 +
src/game/server/gamecontext.cpp | 1 +
6 files changed, 12 insertions(+), 19 deletions(-)
diff --git a/src/base/tl/range.h b/src/base/tl/range.h
index 1d225f491..ff89b4663 100644
--- a/src/base/tl/range.h
+++ b/src/base/tl/range.h
@@ -138,11 +138,6 @@ public:
end = 0x0;
}
- plain_range(const plain_range &r)
- {
- *this = r;
- }
-
plain_range(T *b, T *e)
{
begin = b;
@@ -184,11 +179,6 @@ public:
plain_range_sorted()
{}
- plain_range_sorted(const plain_range_sorted &r)
- {
- *this = r;
- }
-
plain_range_sorted(T *b, T *e)
: parent(b, e)
{}
diff --git a/src/engine/shared/console.cpp b/src/engine/shared/console.cpp
index fb5f63500..daf966540 100644
--- a/src/engine/shared/console.cpp
+++ b/src/engine/shared/console.cpp
@@ -553,7 +553,7 @@ static void StrVariableCommand(IConsole::IResult *pResult, void *pUserData)
int Length = 0;
while(*pString)
{
- int Size = str_utf8_encode(Temp, static_cast<const unsigned char>(*pString++));
+ int Size = str_utf8_encode(Temp, static_cast<unsigned char>(*pString++));
if(Length+Size < pData->m_MaxSize)
{
mem_copy(pData->m_pStr+Length, &Temp, Size);
diff --git a/src/game/client/components/mapimages.cpp b/src/game/client/components/mapimages.cpp
index 00398f263..6639dc71d 100644
--- a/src/game/client/components/mapimages.cpp
+++ b/src/game/client/components/mapimages.cpp
@@ -37,9 +37,9 @@ void CMapImages::LoadMapImages(IMap *pMap, class CLayers *pLayers, int MapType)
for(int k = 0; k < pLayers->NumLayers(); k++)
{
const CMapItemLayer * const pLayer = pLayers->GetLayer(k);
- if(!FoundQuadLayer && pLayer->m_Type == LAYERTYPE_QUADS && ((const CMapItemLayerQuads * const)pLayer)->m_Image == i)
+ if(!FoundQuadLayer && pLayer->m_Type == LAYERTYPE_QUADS && ((const CMapItemLayerQuads *)pLayer)->m_Image == i)
FoundQuadLayer = true;
- if(!FoundTileLayer && pLayer->m_Type == LAYERTYPE_TILES && ((const CMapItemLayerTilemap * const)pLayer)->m_Image == i)
+ if(!FoundTileLayer && pLayer->m_Type == LAYERTYPE_TILES && ((const CMapItemLayerTilemap *)pLayer)->m_Image == i)
FoundTileLayer = true;
}
if(FoundTileLayer)
diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp
index 425f2d9be..246b9d7b8 100644
--- a/src/game/client/gameclient.cpp
+++ b/src/game/client/gameclient.cpp
@@ -524,12 +524,13 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
// get paras
switch(gs_GameMsgList[GameMsgID].m_ParaType)
{
- case PARA_III:
- aParaI[NumParaI++] = pUnpacker->GetInt();
- case PARA_II:
- aParaI[NumParaI++] = pUnpacker->GetInt();
- case PARA_I:
- aParaI[NumParaI++] = pUnpacker->GetInt();
+ case PARA_I: NumParaI = 1; break;
+ case PARA_II: NumParaI = 2; break;
+ case PARA_III: NumParaI = 3; break;
+ }
+ for(int i = 0; i < NumParaI; i++)
+ {
+ aParaI[i] = pUnpacker->GetInt();
}
// check for unpacking errors
diff --git a/src/game/client/localization.cpp b/src/game/client/localization.cpp
index de11f5e89..84d4ff8ee 100644
--- a/src/game/client/localization.cpp
+++ b/src/game/client/localization.cpp
@@ -126,6 +126,7 @@ const char *CLocalizationDatabase::FindString(unsigned Hash, unsigned ContextHas
{
CString String;
String.m_Hash = Hash;
+ String.m_ContextHash = 0; // this is ignored for the search anyway
sorted_array<CString>::range r = ::find_binary(m_Strings.all(), String);
if(r.empty())
return 0;
diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp
index ca0275c26..fb66e40ad 100644
--- a/src/game/server/gamecontext.cpp
+++ b/src/game/server/gamecontext.cpp
@@ -648,6 +648,7 @@ void CGameContext::OnClientEnter(int ClientID)
{
CNetMsg_De_ClientEnter Msg;
Msg.m_pName = NewClientInfoMsg.m_pName;
+ Msg.m_ClientID = ClientID;
Msg.m_Team = NewClientInfoMsg.m_Team;
Server()->SendPackMsg(&Msg, MSGFLAG_NOSEND, -1);
}
--
2.20.1