about summary refs log tree commit diff
path: root/src/engine
diff options
context:
space:
mode:
authorxalduin <xalduin@gmail.com>2010-06-10 00:24:38 +0800
committerMagnus Auvinen <magnus.auvinen@gmail.com>2010-06-10 20:38:03 +0800
commitdc3feaf42cd8bcb22b04fdba17dc10caacc94fef (patch)
treeb19550f37ecf1b2e4ed2561e6647e659fb560bf5 /src/engine
parent7fa21400d6739de935b2a13ceeefa32dbbb95986 (diff)
downloadzcatch-dc3feaf42cd8bcb22b04fdba17dc10caacc94fef.tar.gz
zcatch-dc3feaf42cd8bcb22b04fdba17dc10caacc94fef.zip
Fixed remaining compiler warnings for gcc on Linux
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/client/client.cpp11
-rw-r--r--src/engine/server/server.cpp11
-rw-r--r--src/engine/shared/demorec.cpp2
-rw-r--r--src/engine/shared/ringbuffer.cpp2
4 files changed, 14 insertions, 12 deletions
diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp
index 613a8137..881f06d8 100644
--- a/src/engine/client/client.cpp
+++ b/src/engine/client/client.cpp
@@ -1123,6 +1123,7 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
 						int DeltaSize;
 						unsigned char aTmpBuffer2[CSnapshot::MAX_SIZE];
 						unsigned char aTmpBuffer3[CSnapshot::MAX_SIZE];
+						CSnapshot *pTmpBuffer3 = (CSnapshot*)aTmpBuffer3;	// Fix compiler warning for strict-aliasing
 						int SnapSize;
 
 						CompleteSize = (NumParts-1) * MAX_SNAPSHOT_PACKSIZE + PartSize;
@@ -1169,19 +1170,19 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
 
 						// unpack delta
 						PurgeTick = DeltaTick;
-						SnapSize = m_SnapshotDelta.UnpackDelta(pDeltaShot, (CSnapshot*)aTmpBuffer3, pDeltaData, DeltaSize);
+						SnapSize = m_SnapshotDelta.UnpackDelta(pDeltaShot, pTmpBuffer3, pDeltaData, DeltaSize);
 						if(SnapSize < 0)
 						{
 							dbg_msg("client", "delta unpack failed!");
 							return;
 						}
 
-						if(Msg != NETMSG_SNAPEMPTY && ((CSnapshot*)aTmpBuffer3)->Crc() != Crc)
+						if(Msg != NETMSG_SNAPEMPTY && pTmpBuffer3->Crc() != Crc)
 						{
 							if(g_Config.m_Debug)
 							{
 								dbg_msg("client", "snapshot crc error #%d - tick=%d wantedcrc=%d gotcrc=%d compressed_size=%d delta_tick=%d",
-									m_SnapCrcErrors, GameTick, Crc, ((CSnapshot*)aTmpBuffer3)->Crc(), CompleteSize, DeltaTick);
+									m_SnapCrcErrors, GameTick, Crc, pTmpBuffer3->Crc(), CompleteSize, DeltaTick);
 							}
 
 							m_SnapCrcErrors++;
@@ -1209,13 +1210,13 @@ void CClient::ProcessPacket(CNetChunk *pPacket)
 						m_SnapshotStorage.PurgeUntil(PurgeTick);
 
 						// add new
-						m_SnapshotStorage.Add(GameTick, time_get(), SnapSize, (CSnapshot*)aTmpBuffer3, 1);
+						m_SnapshotStorage.Add(GameTick, time_get(), SnapSize, pTmpBuffer3, 1);
 
 						// add snapshot to demo
 						if(m_DemoRecorder.IsRecording())
 						{
 							// write snapshot
-							m_DemoRecorder.RecordSnapshot(GameTick, aTmpBuffer3, SnapSize);
+							m_DemoRecorder.RecordSnapshot(GameTick, pTmpBuffer3, SnapSize);
 						}
 
 						// apply snapshot, cycle pointers
diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp
index bd5bebe1..7a26704c 100644
--- a/src/engine/server/server.cpp
+++ b/src/engine/server/server.cpp
@@ -427,6 +427,7 @@ void CServer::DoSnapshot()
 			
 		{
 			char aData[CSnapshot::MAX_SIZE];
+			CSnapshot *pData = (CSnapshot*)aData;	// Fix compiler warning for strict-aliasing
 			char aDeltaData[CSnapshot::MAX_SIZE];
 			char aCompData[CSnapshot::MAX_SIZE];
 			int SnapshotSize;
@@ -442,15 +443,15 @@ void CServer::DoSnapshot()
 			GameServer()->OnSnap(i);
 
 			// finish snapshot
-			SnapshotSize = m_SnapshotBuilder.Finish(aData);
-			Crc = ((CSnapshot*)aData)->Crc();
+			SnapshotSize = m_SnapshotBuilder.Finish(pData);
+			Crc = pData->Crc();
 
 			// remove old snapshos
 			// keep 3 seconds worth of snapshots
 			m_aClients[i].m_Snapshots.PurgeUntil(m_CurrentGameTick-SERVER_TICK_SPEED*3);
 			
 			// save it the snapshot
-			m_aClients[i].m_Snapshots.Add(m_CurrentGameTick, time_get(), SnapshotSize, aData, 0);
+			m_aClients[i].m_Snapshots.Add(m_CurrentGameTick, time_get(), SnapshotSize, pData, 0);
 			
 			// find snapshot that we can preform delta against
 			EmptySnap.Clear();
@@ -468,7 +469,7 @@ void CServer::DoSnapshot()
 			}
 			
 			// create delta
-			DeltaSize = m_SnapshotDelta.CreateDelta(pDeltashot, (CSnapshot*)aData, aDeltaData);
+			DeltaSize = m_SnapshotDelta.CreateDelta(pDeltashot, pData, aDeltaData);
 			
 			if(DeltaSize)
 			{
@@ -554,7 +555,7 @@ void CServer::SendMap(int ClientId)
 {
 	//get the name of the map without his path
 	char * pMapShortName = &g_Config.m_SvMap[0];
-	for(int i = 0; i < 127; i++)
+	for(int i = 0; i < str_length(g_Config.m_SvMap)-1; i++)
 	{
 		if(g_Config.m_SvMap[i] == '/' || g_Config.m_SvMap[i] == '\\')
 			pMapShortName = &g_Config.m_SvMap[i+1];
diff --git a/src/engine/shared/demorec.cpp b/src/engine/shared/demorec.cpp
index 48b06e9a..6c2ba07d 100644
--- a/src/engine/shared/demorec.cpp
+++ b/src/engine/shared/demorec.cpp
@@ -335,7 +335,7 @@ void CDemoPlayer::DoTick()
 	static char aDecompressed[CSnapshot::MAX_SIZE];
 	static char aData[CSnapshot::MAX_SIZE];
 	int ChunkType, ChunkTick, ChunkSize;
-	int DataSize;
+	int DataSize = 0;
 	int GotSnapshot = 0;
 
 	// update ticks
diff --git a/src/engine/shared/ringbuffer.cpp b/src/engine/shared/ringbuffer.cpp
index 45a845ee..b84db5a3 100644
--- a/src/engine/shared/ringbuffer.cpp
+++ b/src/engine/shared/ringbuffer.cpp
@@ -98,7 +98,7 @@ void *CRingBufferBase::Allocate(int Size)
 	// okey, we have our block
 	
 	// split the block if needed
-	if(pBlock->m_Size > WantedSize+sizeof(CItem))
+	if(pBlock->m_Size > WantedSize+(int)sizeof(CItem))
 	{
 		CItem *pNewItem = (CItem *)((char *)pBlock + WantedSize);
 		pNewItem->m_pPrev = pBlock;