Merge pull request #2072 from Dune-jr/code-fixes

Small code fixes
This commit is contained in:
oy 2019-03-22 18:13:52 +01:00 committed by GitHub
commit 995ba19f20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 8 additions and 13 deletions

View file

@ -1,4 +1,3 @@
import os
import sys
from datatypes import *
import content

View file

@ -1,4 +1,3 @@
import copy
from datatypes import *
class Sound(Struct):

View file

@ -1154,7 +1154,7 @@ int net_udp_recv(NETSOCKET sock, NETADDR *addr, void *data, int maxsize)
socklen_t fromlen;// = sizeof(sockaddrbuf);
int bytes = 0;
if(bytes == 0 && sock.ipv4sock >= 0)
if(sock.ipv4sock >= 0)
{
fromlen = sizeof(struct sockaddr_in);
bytes = recvfrom(sock.ipv4sock, (char*)data, maxsize, 0, (struct sockaddr *)&sockaddrbuf, &fromlen);

View file

@ -682,7 +682,7 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
*pDesktopHeight = DisplayMode.h;
// use desktop resolution as default resolution
if (*pWidth == 0 || *pWidth == 0)
if (*pWidth == 0 || *pHeight == 0)
{
*pWidth = *pDesktopWidth;
*pHeight = *pDesktopHeight;

View file

@ -95,7 +95,7 @@ bool CDataFileReader::Open(class IStorage *pStorage, const char *pFilename, int
while(1)
{
unsigned Bytes = io_read(File, aBuffer, BUFFER_SIZE);
if(Bytes <= 0)
if(Bytes == 0)
break;
sha256_update(&Sha256Ctx, aBuffer, Bytes);
Crc = crc32(Crc, aBuffer, Bytes); // ignore_convention

View file

@ -21,9 +21,8 @@ void CHeap::NewChunk()
pChunk->m_pMemory = (char*)(pChunk+1);
pChunk->m_pCurrent = pChunk->m_pMemory;
pChunk->m_pEnd = pChunk->m_pMemory + CHUNK_SIZE;
pChunk->m_pNext = (CChunk *)0x0;
pChunk->m_pNext = m_pCurrent;
m_pCurrent = pChunk;
}

View file

@ -167,7 +167,6 @@ int CSnapshotDelta::CreateDelta(CSnapshot *pFrom, CSnapshot *pTo, void *pDstData
CSnapshotItem *pFromItem;
CSnapshotItem *pCurItem;
CSnapshotItem *pPastItem;
int Count = 0;
int SizeCount = 0;
pDelta->m_NumDeletedItems = 0;
@ -240,7 +239,6 @@ int CSnapshotDelta::CreateDelta(CSnapshot *pFrom, CSnapshot *pTo, void *pDstData
SizeCount += ItemSize;
pData += ItemSize/4;
pDelta->m_NumUpdateItems++;
Count++;
}
}

View file

@ -172,7 +172,6 @@ void CCharacterCore::Tick(bool UseInput)
{
m_HookState = HOOK_RETRACTED;
//m_TriggeredEvents |= COREEVENTFLAG_HOOK_RETRACT;
m_HookState = HOOK_RETRACTED;
}
else if(m_HookState == HOOK_FLYING)
{
@ -350,12 +349,13 @@ void CCharacterCore::Move()
if(!m_pWorld)
return;
float PhysSize = 28.0f;
float RampValue = VelocityRamp(length(m_Vel)*50, m_pWorld->m_Tuning.m_VelrampStart, m_pWorld->m_Tuning.m_VelrampRange, m_pWorld->m_Tuning.m_VelrampCurvature);
m_Vel.x = m_Vel.x*RampValue;
vec2 NewPos = m_Pos;
m_pCollision->MoveBox(&NewPos, &m_Vel, vec2(28.0f, 28.0f), 0);
m_pCollision->MoveBox(&NewPos, &m_Vel, vec2(PhysSize, PhysSize), 0);
m_Vel.x = m_Vel.x*(1.0f/RampValue);
@ -375,7 +375,7 @@ void CCharacterCore::Move()
if(!pCharCore || pCharCore == this)
continue;
float D = distance(Pos, pCharCore->m_Pos);
if(D < 28.0f && D > 0.0f)
if(D < PhysSize && D > 0.0f)
{
if(a > 0.0f)
m_Pos = LastPos;

View file

@ -1213,7 +1213,7 @@ void CGameContext::ConAddVote(IConsole::IResult *pResult, void *pUserData)
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
return;
}
while(*pDescription && *pDescription == ' ')
while(*pDescription == ' ')
pDescription++;
if(str_length(pDescription) >= VOTE_DESC_LENGTH || *pDescription == 0)
{