diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 96d0cf906..59b94c018 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1872,7 +1872,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket) int GameTick = Unpacker.GetInt(); int DeltaTick = GameTick - Unpacker.GetInt(); int PartSize = 0; - int Crc = 0; + unsigned int Crc = 0; int CompleteSize = 0; const char *pData = 0; @@ -2160,7 +2160,7 @@ void CClient::ProcessServerPacketDummy(CNetChunk *pPacket) int GameTick = Unpacker.GetInt(); int DeltaTick = GameTick - Unpacker.GetInt(); int PartSize = 0; - int Crc = 0; + unsigned int Crc = 0; int CompleteSize = 0; const char *pData = 0; diff --git a/src/engine/client/serverbrowser.cpp b/src/engine/client/serverbrowser.cpp index c2b46044b..793d5bce7 100644 --- a/src/engine/client/serverbrowser.cpp +++ b/src/engine/client/serverbrowser.cpp @@ -290,7 +290,7 @@ void CServerBrowser::Filter() { // check for friend m_ppServerlist[i]->m_Info.m_FriendState = IFriends::FRIEND_NO; - for(p = 0; p < m_ppServerlist[i]->m_Info.m_NumClients; p++) + for(p = 0; p < minimum(m_ppServerlist[i]->m_Info.m_NumClients, (int)MAX_CLIENTS); p++) { m_ppServerlist[i]->m_Info.m_aClients[p].m_FriendState = m_pFriends->GetFriendState(m_ppServerlist[i]->m_Info.m_aClients[p].m_aName, m_ppServerlist[i]->m_Info.m_aClients[p].m_aClan); @@ -500,7 +500,8 @@ CServerBrowser::CServerEntry *CServerBrowser::Add(const NETADDR &Addr) CServerEntry **ppNewlist; m_NumServerCapacity += 100; ppNewlist = (CServerEntry **)calloc(m_NumServerCapacity, sizeof(CServerEntry *)); - mem_copy(ppNewlist, m_ppServerlist, m_NumServers * sizeof(CServerEntry *)); + if(m_NumServers > 0) + mem_copy(ppNewlist, m_ppServerlist, m_NumServers * sizeof(CServerEntry *)); free(m_ppServerlist); m_ppServerlist = ppNewlist; } diff --git a/src/engine/shared/network.cpp b/src/engine/shared/network.cpp index d74119580..5d03adbf6 100644 --- a/src/engine/shared/network.cpp +++ b/src/engine/shared/network.cpp @@ -310,7 +310,8 @@ void CNetBase::SendControlMsg(NETSOCKET Socket, NETADDR *pAddr, int Ack, int Con Construct.m_NumChunks = 0; Construct.m_DataSize = 1 + ExtraSize; Construct.m_aChunkData[0] = ControlMsg; - mem_copy(&Construct.m_aChunkData[1], pExtra, ExtraSize); + if(pExtra) + mem_copy(&Construct.m_aChunkData[1], pExtra, ExtraSize); // send the control message CNetBase::SendPacket(Socket, pAddr, &Construct, SecurityToken, Sixup, true); diff --git a/src/engine/shared/snapshot.cpp b/src/engine/shared/snapshot.cpp index cd6650f57..802ef2b80 100644 --- a/src/engine/shared/snapshot.cpp +++ b/src/engine/shared/snapshot.cpp @@ -59,9 +59,9 @@ int CSnapshot::GetItemIndex(int Key) return -1; } -int CSnapshot::Crc() +unsigned CSnapshot::Crc() { - int Crc = 0; + unsigned int Crc = 0; for(int i = 0; i < m_NumItems; i++) { @@ -230,7 +230,7 @@ int CSnapshotDelta::CreateDelta(CSnapshot *pFrom, CSnapshot *pTo, void *pDstData } GenerateHash(Hashlist, pFrom); - int aPastIndecies[1024]; + int aPastIndices[1024]; // fetch previous indices // we do this as a separate pass because it helps the cache @@ -238,7 +238,7 @@ int CSnapshotDelta::CreateDelta(CSnapshot *pFrom, CSnapshot *pTo, void *pDstData for(i = 0; i < NumItems; i++) { pCurItem = pTo->GetItem(i); // O(1) .. O(n) - aPastIndecies[i] = GetItemIndexHashed(pCurItem->Key(), Hashlist); // O(n) .. O(n^n) + aPastIndices[i] = GetItemIndexHashed(pCurItem->Key(), Hashlist); // O(n) .. O(n^n) } for(i = 0; i < NumItems; i++) @@ -246,7 +246,7 @@ int CSnapshotDelta::CreateDelta(CSnapshot *pFrom, CSnapshot *pTo, void *pDstData // do delta ItemSize = pTo->GetItemSize(i); // O(1) .. O(n) pCurItem = pTo->GetItem(i); // O(1) .. O(n) - PastIndex = aPastIndecies[i]; + PastIndex = aPastIndices[i]; if(PastIndex != -1) { diff --git a/src/engine/shared/snapshot.h b/src/engine/shared/snapshot.h index 474eeacda..85a69add7 100644 --- a/src/engine/shared/snapshot.h +++ b/src/engine/shared/snapshot.h @@ -47,7 +47,7 @@ public: int GetItemIndex(int Key); int GetItemType(int Index); - int Crc(); + unsigned Crc(); void DebugDump(); static void RemoveExtraInfo(unsigned char *pData); }; diff --git a/src/game/client/components/ghost.cpp b/src/game/client/components/ghost.cpp index c4d65f08d..a9891817d 100644 --- a/src/game/client/components/ghost.cpp +++ b/src/game/client/components/ghost.cpp @@ -597,7 +597,7 @@ void CGhost::OnMessage(int MsgType, void *pRawMsg) { char aName[MAX_NAME_LENGTH]; int Time = CRaceHelper::TimeFromFinishMessage(pMsg->m_pMessage, aName, sizeof(aName)); - if(Time > 0 && str_comp(aName, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aName) == 0) + if(Time > 0 && m_pClient->m_Snap.m_LocalClientID >= 0 && str_comp(aName, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aName) == 0) { StopRecord(Time); StopRender(); diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index 728a0b8d9..c1707e58a 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -105,8 +105,13 @@ void CMenus::RenderGame(CUIRect MainView) static int s_JoinRedButton = 0; static int s_JoinBlueButton = 0; - bool Paused = m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_Paused; - bool Spec = m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_Spec; + bool Paused = false; + bool Spec = false; + if(m_pClient->m_Snap.m_LocalClientID >= 0) + { + Paused = m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_Paused; + Spec = m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_Spec; + } if(m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pGameInfoObj && !Paused && !Spec) { diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index b4f43eb67..532a67a80 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -194,7 +194,7 @@ void CPlayers::RenderPlayer( bool PredictLocalWeapons = false; float AttackTime = (Client()->PrevGameTick(g_Config.m_ClDummy) - Player.m_AttackTick) / (float)SERVER_TICK_SPEED + Client()->GameTickTime(g_Config.m_ClDummy); float LastAttackTime = (Client()->PrevGameTick(g_Config.m_ClDummy) - Player.m_AttackTick) / (float)SERVER_TICK_SPEED + s_LastGameTickTime; - if(m_pClient->m_aClients[ClientID].m_IsPredictedLocal && m_pClient->AntiPingGunfire()) + if(ClientID >= 0 && m_pClient->m_aClients[ClientID].m_IsPredictedLocal && m_pClient->AntiPingGunfire()) { PredictLocalWeapons = true; AttackTime = (Client()->PredIntraGameTick(g_Config.m_ClDummy) + (Client()->PredGameTick(g_Config.m_ClDummy) - 1 - Player.m_AttackTick)) / (float)SERVER_TICK_SPEED; diff --git a/src/game/client/components/race_demo.cpp b/src/game/client/components/race_demo.cpp index 94b5ad188..fd8af3417 100644 --- a/src/game/client/components/race_demo.cpp +++ b/src/game/client/components/race_demo.cpp @@ -131,7 +131,7 @@ void CRaceDemo::OnMessage(int MsgType, void *pRawMsg) { char aName[MAX_NAME_LENGTH]; int Time = CRaceHelper::TimeFromFinishMessage(pMsg->m_pMessage, aName, sizeof(aName)); - if(Time > 0 && str_comp(aName, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aName) == 0) + if(Time > 0 && m_pClient->m_Snap.m_LocalClientID >= 0 && str_comp(aName, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aName) == 0) { m_RaceState = RACE_FINISHED; m_RecordStopTick = Client()->GameTick(g_Config.m_ClDummy) + Client()->GameTickSpeed(); diff --git a/src/game/client/components/skins.cpp b/src/game/client/components/skins.cpp index 44f761e8f..03ce42626 100644 --- a/src/game/client/components/skins.cpp +++ b/src/game/client/components/skins.cpp @@ -138,8 +138,12 @@ int CSkins::LoadSkin(const char *pName, const char *pPath, int DirType, int *pGe for(int x = 0; x < BodySize; x++) { int v = d[y * Pitch + x * 4]; - if(v <= OrgWeight) + if(OrgWeight == 0) + v = 0; + else if(v <= OrgWeight) v = (int)(((v / (float)OrgWeight) * NewWeight)); + else if(InvOrgWeight == 0) + v = NewWeight; else v = (int)(((v - OrgWeight) / (float)InvOrgWeight) * InvNewWeight + NewWeight); d[y * Pitch + x * 4] = v; diff --git a/src/game/gamecore.cpp b/src/game/gamecore.cpp index 3c5098478..85aa00b04 100644 --- a/src/game/gamecore.cpp +++ b/src/game/gamecore.cpp @@ -64,10 +64,7 @@ void CCharacterCore::Init(CWorldCore *pWorld, CCollision *pCollision, CTeamsCore m_pTeams = pTeams; m_Id = -1; - m_Hook = true; - m_Collision = true; - m_JumpedTotal = 0; - m_Jumps = 2; + Reset(); } void CCharacterCore::Init(CWorldCore *pWorld, CCollision *pCollision, CTeamsCore *pTeams, std::map> *pTeleOuts) @@ -78,10 +75,7 @@ void CCharacterCore::Init(CWorldCore *pWorld, CCollision *pCollision, CTeamsCore m_pTeams = pTeams; m_Id = -1; - m_Hook = true; - m_Collision = true; - m_JumpedTotal = 0; - m_Jumps = 2; + Reset(); } void CCharacterCore::Reset() @@ -274,7 +268,7 @@ void CCharacterCore::Tick(bool UseInput) for(int i = 0; i < MAX_CLIENTS; i++) { CCharacterCore *pCharCore = m_pWorld->m_apCharacters[i]; - if(!pCharCore || pCharCore == this || (!(m_Super || pCharCore->m_Super) && (!m_pTeams->CanCollide(i, m_Id) || pCharCore->m_Solo || m_Solo))) + if(!pCharCore || pCharCore == this || (!(m_Super || pCharCore->m_Super) && ((m_Id != -1 && !m_pTeams->CanCollide(i, m_Id)) || pCharCore->m_Solo || m_Solo))) continue; vec2 ClosestPoint = closest_point_on_line(m_HookPos, NewPos, pCharCore->m_Pos); @@ -328,7 +322,7 @@ void CCharacterCore::Tick(bool UseInput) if(m_HookedPlayer != -1) { CCharacterCore *pCharCore = m_pWorld->m_apCharacters[m_HookedPlayer]; - if(pCharCore && m_pTeams->CanKeepHook(m_Id, pCharCore->m_Id)) + if(pCharCore && m_Id != -1 && m_pTeams->CanKeepHook(m_Id, pCharCore->m_Id)) m_HookPos = pCharCore->m_Pos; else { @@ -581,7 +575,7 @@ bool CCharacterCore::IsSwitchActiveCb(int Number, void *pUser) { CCharacterCore *pThis = (CCharacterCore *)pUser; if(pThis->Collision()->m_pSwitchers) - if(pThis->m_pTeams->Team(pThis->m_Id) != (pThis->m_pTeams->m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER)) + if(pThis->m_Id != -1 && pThis->m_pTeams->Team(pThis->m_Id) != (pThis->m_pTeams->m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER)) return pThis->Collision()->m_pSwitchers[Number].m_Status[pThis->m_pTeams->Team(pThis->m_Id)]; return false; }