From 6b7e1f54f48182d8d03f482c06dd59d72ca9da5d Mon Sep 17 00:00:00 2001 From: def Date: Wed, 8 Jul 2020 23:25:07 +0200 Subject: [PATCH 1/2] Send zoom status for dummy too --- src/game/client/gameclient.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 137b14bdf..7faf7532c 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -1552,21 +1552,28 @@ void CGameClient::OnNewSnapshot() static float LastZoom = .0; static float LastScreenAspect = .0; + static bool LastDummyConnected = false; float ZoomToSend = m_pCamera->m_ZoomSmoothingTarget == .0 ? m_pCamera->m_Zoom // Initial : m_pCamera->m_ZoomSmoothingTarget > m_pCamera->m_Zoom ? m_pCamera->m_ZoomSmoothingTarget // Zooming out : m_pCamera->m_ZoomSmoothingTarget < m_pCamera->m_Zoom ? LastZoom // Zooming in : m_pCamera->m_Zoom; // Not zooming - if(ZoomToSend != LastZoom || Graphics()->ScreenAspect() != LastScreenAspect) + if(ZoomToSend != LastZoom || Graphics()->ScreenAspect() != LastScreenAspect || (Client()->DummyConnected() && !LastDummyConnected)) { - LastZoom = ZoomToSend; - LastScreenAspect = Graphics()->ScreenAspect(); CNetMsg_Cl_ShowDistance Msg; float x, y; RenderTools()->CalcScreenParams(Graphics()->ScreenAspect(), ZoomToSend, &x, &y); Msg.m_X = x; Msg.m_Y = y; - Client()->SendPackMsg(&Msg, MSGFLAG_VITAL); + CMsgPacker Packer(Msg.MsgID(), false); + Msg.Pack(&Packer); + if(ZoomToSend != LastZoom) + Client()->SendMsgY(&Packer, MSGFLAG_VITAL, 0); + if(Client()->DummyConnected()) + Client()->SendMsgY(&Packer, MSGFLAG_VITAL, 1); + LastZoom = ZoomToSend; + LastScreenAspect = Graphics()->ScreenAspect(); } + LastDummyConnected = Client()->DummyConnected(); m_pGhost->OnNewSnapshot(); m_pRaceDemo->OnNewSnapshot(); From f4344dc420a72f18e59507d359d668f3705fd2e4 Mon Sep 17 00:00:00 2001 From: def Date: Wed, 8 Jul 2020 16:59:32 +0200 Subject: [PATCH 2/2] Use (u)int64 from system.h instead of (u)int64_t from cstdint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit src/game/client/prediction/gameworld.h:62:90: error: ‘int64_t’ has not been declared 62 | void CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamage, int ActivatedTeam, int64_t Mask); | ^~~~~~~ --- src/base/hash_ctxt.h | 3 ++- src/base/hash_libtomcrypt.c | 4 +-- src/base/system.c | 6 ++--- src/engine/client/sound.cpp | 4 +-- src/engine/client/video.cpp | 4 +-- src/engine/client/video.h | 4 +-- .../client/prediction/entities/projectile.cpp | 4 +-- src/game/client/prediction/gameworld.cpp | 2 +- src/game/client/prediction/gameworld.h | 2 +- src/game/server/entities/character.cpp | 2 +- src/game/server/entities/laser.cpp | 2 +- src/game/server/entities/projectile.cpp | 6 ++--- src/game/server/eventhandler.cpp | 2 +- src/game/server/eventhandler.h | 13 +++------- src/game/server/gamecontext.cpp | 14 +++++----- src/game/server/gamecontext.h | 26 +++++++++---------- src/game/server/gamecontroller.h | 4 +-- src/game/server/teams.cpp | 4 +-- src/game/server/teams.h | 4 +-- 19 files changed, 52 insertions(+), 58 deletions(-) diff --git a/src/base/hash_ctxt.h b/src/base/hash_ctxt.h index 6204db31a..256988832 100644 --- a/src/base/hash_ctxt.h +++ b/src/base/hash_ctxt.h @@ -2,6 +2,7 @@ #define BASE_HASH_CTXT_H #include "hash.h" +#include "system.h" #include #if defined(CONF_OPENSSL) @@ -20,7 +21,7 @@ extern "C" { #else typedef struct { - uint64_t length; + uint64 length; uint32_t state[8]; uint32_t curlen; unsigned char buf[64]; diff --git a/src/base/hash_libtomcrypt.c b/src/base/hash_libtomcrypt.c index 951f3ebc7..b3deafe49 100755 --- a/src/base/hash_libtomcrypt.c +++ b/src/base/hash_libtomcrypt.c @@ -30,7 +30,7 @@ static const u32 K[64] = 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL }; -static u32 min(u32 x, u32 y) +static u32 minimum(u32 x, u32 y) { return x < y ? x : y; } @@ -133,7 +133,7 @@ static void sha_process(sha256_state* md, const void* src, u32 inlen) } else { - u32 n = min(inlen, (block_size - md->curlen)); + u32 n = minimum(inlen, (block_size - md->curlen)); memcpy(md->buf + md->curlen, in, n); md->curlen += n; in += n; diff --git a/src/base/system.c b/src/base/system.c index e74292f63..572ec58b6 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -930,9 +930,9 @@ int64 time_get_impl(void) #if defined(CONF_PLATFORM_MACOSX) static int got_timebase = 0; mach_timebase_info_data_t timebase; - uint64_t time; - uint64_t q; - uint64_t r; + uint64 time; + uint64 q; + uint64 r; if(!got_timebase) { mach_timebase_info(&timebase); diff --git a/src/engine/client/sound.cpp b/src/engine/client/sound.cpp index 912311d30..fa66d2a75 100644 --- a/src/engine/client/sound.cpp +++ b/src/engine/client/sound.cpp @@ -828,11 +828,11 @@ void CSound::SetVoiceTimeOffset(CVoiceHandle Voice, float offset) { int Tick = 0; bool IsLooping = m_aVoices[VoiceID].m_Flags&ISound::FLAG_LOOP; - uint64_t TickOffset = m_aVoices[VoiceID].m_pSample->m_Rate * offset; + uint64 TickOffset = m_aVoices[VoiceID].m_pSample->m_Rate * offset; if(m_aVoices[VoiceID].m_pSample->m_NumFrames > 0 && IsLooping) Tick = TickOffset % m_aVoices[VoiceID].m_pSample->m_NumFrames; else - Tick = clamp(TickOffset, (uint64_t)0, (uint64_t)m_aVoices[VoiceID].m_pSample->m_NumFrames); + Tick = clamp(TickOffset, (uint64)0, (uint64)m_aVoices[VoiceID].m_pSample->m_NumFrames); // at least 200msec off, else depend on buffer size float Threshold = maximum(0.2f * m_aVoices[VoiceID].m_pSample->m_Rate, (float)m_MaxFrames); diff --git a/src/engine/client/video.cpp b/src/engine/client/video.cpp index 302608cf0..943e0143d 100644 --- a/src/engine/client/video.cpp +++ b/src/engine/client/video.cpp @@ -220,7 +220,7 @@ void CVideo::NextVideoFrameThread() if(m_Vseq >= 2) { m_ProcessingVideoFrame = true; - m_VideoStream.pFrame->pts = (int64_t)m_VideoStream.pEnc->frame_number; + m_VideoStream.pFrame->pts = (int64)m_VideoStream.pEnc->frame_number; dbg_msg("video_recorder", "vframe: %d", m_VideoStream.pEnc->frame_number); ReadRGBFromGL(); @@ -407,7 +407,7 @@ AVFrame* CVideo::AllocPicture(enum AVPixelFormat PixFmt, int Width, int Height) } -AVFrame* CVideo::AllocAudioFrame(enum AVSampleFormat SampleFmt, uint64_t ChannelLayout, int SampleRate, int NbSamples) +AVFrame* CVideo::AllocAudioFrame(enum AVSampleFormat SampleFmt, uint64 ChannelLayout, int SampleRate, int NbSamples) { AVFrame *Frame = av_frame_alloc(); int Ret; diff --git a/src/engine/client/video.h b/src/engine/client/video.h index 272133b08..287e64f3b 100644 --- a/src/engine/client/video.h +++ b/src/engine/client/video.h @@ -41,7 +41,7 @@ typedef struct OutputStream { AVCodecContext *pEnc; /* pts of the next frame that will be generated */ - int64_t NextPts; + int64 NextPts; int SamplesCount; AVFrame *pFrame; @@ -83,7 +83,7 @@ private: void OpenVideo(); void OpenAudio(); AVFrame *AllocPicture(enum AVPixelFormat PixFmt, int Width, int Height); - AVFrame* AllocAudioFrame(enum AVSampleFormat SampleFmt, uint64_t ChannelLayout, int SampleRate, int NbSamples); + AVFrame* AllocAudioFrame(enum AVSampleFormat SampleFmt, uint64 ChannelLayout, int SampleRate, int NbSamples); void WriteFrame(OutputStream* pStream); void FinishFrames(OutputStream* pStream); diff --git a/src/game/client/prediction/entities/projectile.cpp b/src/game/client/prediction/entities/projectile.cpp index f2300a154..888cd689e 100644 --- a/src/game/client/prediction/entities/projectile.cpp +++ b/src/game/client/prediction/entities/projectile.cpp @@ -88,7 +88,7 @@ void CProjectile::Tick() if(m_LifeSpan > -1) m_LifeSpan--; - int64_t TeamMask = -1LL; + int64 TeamMask = -1LL; bool isWeaponCollide = false; if ( @@ -140,7 +140,7 @@ void CProjectile::Tick() if(m_Owner >= 0) pOwnerChar = GameWorld()->GetCharacterByID(m_Owner); - int64_t TeamMask = -1LL; + int64 TeamMask = -1LL; GameWorld()->CreateExplosion(ColPos, m_Owner, m_Type, m_Owner == -1, (!pOwnerChar ? -1 : pOwnerChar->Team()), (m_Owner != -1)? TeamMask : -1LL); diff --git a/src/game/client/prediction/gameworld.cpp b/src/game/client/prediction/gameworld.cpp index 9b298ac21..121a61822 100644 --- a/src/game/client/prediction/gameworld.cpp +++ b/src/game/client/prediction/gameworld.cpp @@ -294,7 +294,7 @@ CEntity *CGameWorld::GetEntity(int ID, int EntType) return 0; } -void CGameWorld::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamage, int ActivatedTeam, int64_t Mask) +void CGameWorld::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamage, int ActivatedTeam, int64 Mask) { if(Owner < 0 && m_WorldConfig.m_IsSolo && !(Weapon == WEAPON_SHOTGUN && m_WorldConfig.m_IsDDRace)) return; diff --git a/src/game/client/prediction/gameworld.h b/src/game/client/prediction/gameworld.h index 0acaca47f..caa2f1639 100644 --- a/src/game/client/prediction/gameworld.h +++ b/src/game/client/prediction/gameworld.h @@ -59,7 +59,7 @@ public: class CCharacter *GetCharacterByID(int ID) { return (ID >= 0 && ID < MAX_CLIENTS) ? m_apCharacters[ID] : 0; } // from gamecontext - void CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamage, int ActivatedTeam, int64_t Mask); + void CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamage, int ActivatedTeam, int64 Mask); // for client side prediction struct diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 82c52d0a9..2c002bb14 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -1005,7 +1005,7 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon) // do damage Hit sound if(From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From]) { - int64_t Mask = CmaskOne(From); + int64 Mask = CmaskOne(From); for(int i = 0; i < MAX_CLIENTS; i++) { if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS && GameServer()->m_apPlayers[i]->m_SpectatorID == From) diff --git a/src/game/server/entities/laser.cpp b/src/game/server/entities/laser.cpp index 434722434..37384eaca 100644 --- a/src/game/server/entities/laser.cpp +++ b/src/game/server/entities/laser.cpp @@ -266,7 +266,7 @@ void CLaser::Snap(int SnappingClient) return; CCharacter *pOwnerChar = 0; - int64_t TeamMask = -1LL; + int64 TeamMask = -1LL; if(m_Owner >= 0) pOwnerChar = GameServer()->GetPlayerChar(m_Owner); diff --git a/src/game/server/entities/projectile.cpp b/src/game/server/entities/projectile.cpp index efa85635a..a74025c59 100644 --- a/src/game/server/entities/projectile.cpp +++ b/src/game/server/entities/projectile.cpp @@ -125,7 +125,7 @@ void CProjectile::Tick() if(m_LifeSpan > -1) m_LifeSpan--; - int64_t TeamMask = -1LL; + int64 TeamMask = -1LL; bool IsWeaponCollide = false; if ( @@ -254,7 +254,7 @@ void CProjectile::Tick() if(m_Owner >= 0) pOwnerChar = GameServer()->GetPlayerChar(m_Owner); - int64_t TeamMask = -1LL; + int64 TeamMask = -1LL; if (pOwnerChar && pOwnerChar->IsAlive()) { TeamMask = pOwnerChar->Teams()->TeamMask(pOwnerChar->Team(), -1, m_Owner); @@ -312,7 +312,7 @@ void CProjectile::Snap(int SnappingClient) return; CCharacter *pOwnerChar = 0; - int64_t TeamMask = -1LL; + int64 TeamMask = -1LL; if(m_Owner >= 0) pOwnerChar = GameServer()->GetPlayerChar(m_Owner); diff --git a/src/game/server/eventhandler.cpp b/src/game/server/eventhandler.cpp index 7ddede093..0cfd5e4f4 100644 --- a/src/game/server/eventhandler.cpp +++ b/src/game/server/eventhandler.cpp @@ -17,7 +17,7 @@ void CEventHandler::SetGameServer(CGameContext *pGameServer) m_pGameServer = pGameServer; } -void *CEventHandler::Create(int Type, int Size, int64_t Mask) +void *CEventHandler::Create(int Type, int Size, int64 Mask) { if(m_NumEvents == MAX_EVENTS) return 0; diff --git a/src/game/server/eventhandler.h b/src/game/server/eventhandler.h index bc397c675..ec1382df9 100644 --- a/src/game/server/eventhandler.h +++ b/src/game/server/eventhandler.h @@ -3,14 +3,7 @@ #ifndef GAME_SERVER_EVENTHANDLER_H #define GAME_SERVER_EVENTHANDLER_H -#if !defined(_MSC_VER) || _MSC_VER >= 1600 -#include -#else -typedef __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#endif +#include // class CEventHandler { @@ -20,7 +13,7 @@ class CEventHandler int m_aTypes[MAX_EVENTS]; // TODO: remove some of these arrays int m_aOffsets[MAX_EVENTS]; int m_aSizes[MAX_EVENTS]; - int64_t m_aClientMasks[MAX_EVENTS]; + int64 m_aClientMasks[MAX_EVENTS]; char m_aData[MAX_DATASIZE]; class CGameContext *m_pGameServer; @@ -32,7 +25,7 @@ public: void SetGameServer(CGameContext *pGameServer); CEventHandler(); - void *Create(int Type, int Size, int64_t Mask = -1LL); + void *Create(int Type, int Size, int64 Mask = -1LL); void Clear(); void Snap(int SnappingClient); diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index d3087740b..ac593065c 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -176,7 +176,7 @@ void CGameContext::FillAntibot(CAntibotRoundData *pData) } } -void CGameContext::CreateDamageInd(vec2 Pos, float Angle, int Amount, int64_t Mask) +void CGameContext::CreateDamageInd(vec2 Pos, float Angle, int Amount, int64 Mask) { float a = 3 * 3.14159f / 2 + Angle; //float a = get_angle(dir); @@ -195,7 +195,7 @@ void CGameContext::CreateDamageInd(vec2 Pos, float Angle, int Amount, int64_t Ma } } -void CGameContext::CreateHammerHit(vec2 Pos, int64_t Mask) +void CGameContext::CreateHammerHit(vec2 Pos, int64 Mask) { // create the event CNetEvent_HammerHit *pEvent = (CNetEvent_HammerHit *)m_Events.Create(NETEVENTTYPE_HAMMERHIT, sizeof(CNetEvent_HammerHit), Mask); @@ -206,7 +206,7 @@ void CGameContext::CreateHammerHit(vec2 Pos, int64_t Mask) } } -void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamage, int ActivatedTeam, int64_t Mask) +void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamage, int ActivatedTeam, int64 Mask) { // create the event CNetEvent_Explosion *pEvent = (CNetEvent_Explosion *)m_Events.Create(NETEVENTTYPE_EXPLOSION, sizeof(CNetEvent_Explosion), Mask); @@ -221,7 +221,7 @@ void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamag float Radius = 135.0f; float InnerRadius = 48.0f; int Num = m_World.FindEntities(Pos, Radius, (CEntity**)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); - int64_t TeamMask = -1; + int64 TeamMask = -1; for(int i = 0; i < Num; i++) { vec2 Diff = apEnts[i]->m_Pos - Pos; @@ -257,7 +257,7 @@ void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamag } } -void CGameContext::CreatePlayerSpawn(vec2 Pos, int64_t Mask) +void CGameContext::CreatePlayerSpawn(vec2 Pos, int64 Mask) { // create the event CNetEvent_Spawn *ev = (CNetEvent_Spawn *)m_Events.Create(NETEVENTTYPE_SPAWN, sizeof(CNetEvent_Spawn), Mask); @@ -268,7 +268,7 @@ void CGameContext::CreatePlayerSpawn(vec2 Pos, int64_t Mask) } } -void CGameContext::CreateDeath(vec2 Pos, int ClientID, int64_t Mask) +void CGameContext::CreateDeath(vec2 Pos, int ClientID, int64 Mask) { // create the event CNetEvent_Death *pEvent = (CNetEvent_Death *)m_Events.Create(NETEVENTTYPE_DEATH, sizeof(CNetEvent_Death), Mask); @@ -280,7 +280,7 @@ void CGameContext::CreateDeath(vec2 Pos, int ClientID, int64_t Mask) } } -void CGameContext::CreateSound(vec2 Pos, int Sound, int64_t Mask) +void CGameContext::CreateSound(vec2 Pos, int Sound, int64 Mask) { if (Sound < 0) return; diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h index bdca41b86..e3626d24e 100644 --- a/src/game/server/gamecontext.h +++ b/src/game/server/gamecontext.h @@ -22,8 +22,8 @@ #ifdef _MSC_VER typedef __int32 int32_t; typedef unsigned __int32 uint32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; +typedef __int64 int64; +typedef unsigned __int64 uint64; #else #include #endif @@ -178,12 +178,12 @@ public: CVoteOptionServer *m_pVoteOptionLast; // helper functions - void CreateDamageInd(vec2 Pos, float AngleMod, int Amount, int64_t Mask=-1); - void CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamage, int ActivatedTeam, int64_t Mask); - void CreateHammerHit(vec2 Pos, int64_t Mask=-1); - void CreatePlayerSpawn(vec2 Pos, int64_t Mask=-1); - void CreateDeath(vec2 Pos, int Who, int64_t Mask=-1); - void CreateSound(vec2 Pos, int Sound, int64_t Mask=-1); + void CreateDamageInd(vec2 Pos, float AngleMod, int Amount, int64 Mask=-1); + void CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamage, int ActivatedTeam, int64 Mask); + void CreateHammerHit(vec2 Pos, int64 Mask=-1); + void CreatePlayerSpawn(vec2 Pos, int64 Mask=-1); + void CreateDeath(vec2 Pos, int Who, int64 Mask=-1); + void CreateSound(vec2 Pos, int Sound, int64 Mask=-1); void CreateSoundGlobal(int Sound, int Target=-1); @@ -433,9 +433,9 @@ public: int m_ChatPrintCBIndex; }; -inline int64_t CmaskAll() { return -1LL; } -inline int64_t CmaskOne(int ClientID) { return 1LL< m_pSaveTeamResult[MAX_CLIENTS]; @@ -61,7 +61,7 @@ public: void ChangeTeamState(int Team, int State); void onChangeTeamState(int Team, int State, int OldState); - int64_t TeamMask(int Team, int ExceptID = -1, int Asker = -1); + int64 TeamMask(int Team, int ExceptID = -1, int Asker = -1); int Count(int Team) const;