Skip to content

Commit 9dae709

Browse files
committed
Common: Replace GetTickCount() on SDL analogue (fix Actor death)
1 parent f32fbe2 commit 9dae709

File tree

10 files changed

+23
-48
lines changed

10 files changed

+23
-48
lines changed

src/Common/Common.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,3 @@
66
#include "Common/FSMacros.hpp"
77
#include "Include/xrAPI/xrAPI.h"
88

9-
#if defined(WINDOWS)
10-
#if __has_include("SDL.h")
11-
#include "SDL.h"
12-
#endif
13-
14-
#if __has_include("SDL_syswm.h")
15-
#include "SDL_syswm.h"
16-
#endif
17-
#endif

src/utils/mp_gpprof_server/libraries/gamespy/GP/gptest/gptestDlg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ void TransferCallback(GPConnection * connection, void * arg_, void * param)
10261026
switch(arg->type)
10271027
{
10281028
case GP_TRANSFER_SEND_REQUEST:
1029-
transferStart = GetTickCount();
1029+
transferStart = SDL_GetTicks();
10301030
CHECK(gpAcceptTransfer(connection, arg->transfer, "I'd like your file"));
10311031
break;
10321032

src/utils/mp_gpprof_server/libraries/gamespy/common/gsPlatformUtil.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ time_t time(time_t *timer)
552552
gsi_time current_time() //returns current time in milliseconds
553553
{
554554
#if defined(_WIN32)
555-
return (GetTickCount());
555+
return (SDL_GetTicks());
556556

557557
#elif defined(_PS2)
558558
unsigned int ticks;
@@ -1800,7 +1800,7 @@ static void GenerateID(char *keyval)
18001800
seed = (l1.LowPart ^ l1.HighPart);
18011801
else
18021802
seed = 0;
1803-
Util_RandSeed(seed ^ GetTickCount() ^ (unsigned long)time(NULL) ^ clock());
1803+
Util_RandSeed(seed ^ SDL_GetTicks() ^ (unsigned long)time(NULL) ^ clock());
18041804
#else
18051805
Util_RandSeed(time(NULL) ^ clock());
18061806
#endif

src/xrCore/Threading/Event.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#pragma once
22
#include "xrCore/_types.h"
33

4+
#include "SDL.h"
5+
46
class XRCORE_API Event
57
{
68
void* handle;

src/xrGame/Level_network.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,16 +363,15 @@ bool CLevel::Connect2Server(const char* options)
363363
if (psNET_direct_connect)
364364
m_bConnectResultReceived = true;
365365

366-
#ifndef LINUX // FIXME!!!
367-
u32 EndTime = GetTickCount() + ConnectionTimeOut;
366+
u32 EndTime = SDL_GetTicks() + ConnectionTimeOut;
368367
while (!m_bConnectResultReceived)
369368
{
370369
ClientReceive();
371370
Sleep(5);
372371
if (Server)
373372
Server->Update();
374373
//-----------------------------------------
375-
u32 CurTime = GetTickCount();
374+
u32 CurTime = SDL_GetTicks();
376375
if (CurTime > EndTime)
377376
{
378377
NET_Packet P;
@@ -393,7 +392,6 @@ bool CLevel::Connect2Server(const char* options)
393392
}
394393
//-----------------------------------------
395394
}
396-
#endif
397395
Msg("%c client : connection %s - <%s>", m_bConnectResult ? '*' : '!', m_bConnectResult ? "accepted" : "rejected",
398396
m_sConnectResult.c_str());
399397
if (!m_bConnectResult)

src/xrGame/game_sv_deathmatch.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,7 @@ void game_sv_Deathmatch::Create(shared_str& options)
104104

105105
switch_Phase(GAME_PHASE_PENDING);
106106

107-
#ifdef LINUX // FIXME!!!
108-
::Random.seed(0);
109-
#else
110-
::Random.seed(GetTickCount());
111-
#endif
107+
::Random.seed(SDL_GetTicks());
112108
m_CorpseList.clear();
113109

114110
m_AnomaliesPermanent.clear();

src/xrGame/game_sv_event_queue.cpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
GameEventQueue::GameEventQueue() :
66
#ifdef CONFIG_PROFILE_LOCKS
7-
pcs(new Lock(MUTEX_PROFILE_ID(GameEventQueue)))
7+
pcs(new Lock(MUTEX_PROFILE_ID(GameEventQueue)))
88
#else
9-
pcs(new Lock)
9+
pcs(new Lock)
1010
#endif // CONFIG_PROFILE_LOCKS
1111
{
1212
unused.reserve(128);
@@ -38,9 +38,7 @@ GameEvent* GameEventQueue::Create()
3838
#ifdef _DEBUG
3939
// Msg ("* GameEventQueue::Create - ready %d, unused %d", ready.size(), unused.size());
4040
#endif
41-
#ifndef LINUX // FIXME!!!
42-
LastTimeCreate = GetTickCount();
43-
#endif
41+
LastTimeCreate = SDL_GetTicks();
4442
//---------------------------------------------
4543
}
4644
else
@@ -74,16 +72,14 @@ GameEvent* GameEventQueue::Create(NET_Packet& P, u16 type, u32 time, ClientID cl
7472
pcs->Enter();
7573
if (unused.empty())
7674
{
77-
#ifndef LINUX // FIXME!!!
7875
ready.push_back(new GameEvent());
7976
ge = ready.back();
8077
//---------------------------------------------
8178
#ifdef _DEBUG
8279
// Msg ("* GameEventQueue::Create - ready %d, unused %d", ready.size(), unused.size());
8380
#endif
84-
LastTimeCreate = GetTickCount();
81+
LastTimeCreate = SDL_GetTicks();
8582
//---------------------------------------------
86-
#endif
8783
}
8884
else
8985
{
@@ -108,8 +104,7 @@ GameEvent* GameEventQueue::Retreive()
108104
//---------------------------------------------
109105
else
110106
{
111-
#ifndef LINUX // FIXME!!
112-
u32 tmp_time = GetTickCount() - 60000;
107+
u32 tmp_time = SDL_GetTicks() - 60000;
113108
u32 size = unused.size();
114109
if ((LastTimeCreate < tmp_time) && (size > 32))
115110
{
@@ -119,7 +114,6 @@ GameEvent* GameEventQueue::Retreive()
119114
// Msg ("GameEventQueue::Retreive - ready %d, unused %d", ready.size(), unused.size());
120115
#endif
121116
}
122-
#endif
123117
}
124118
//---------------------------------------------
125119
pcs->Leave();
@@ -131,8 +125,7 @@ void GameEventQueue::Release()
131125
pcs->Enter();
132126
R_ASSERT(!ready.empty());
133127
//---------------------------------------------
134-
#ifndef LINUX // FIXME!!!
135-
u32 tmp_time = GetTickCount() - 60000;
128+
u32 tmp_time = SDL_GetTicks() - 60000;
136129
u32 size = unused.size();
137130
if ((LastTimeCreate < tmp_time) && (size > 32))
138131
{
@@ -143,7 +136,6 @@ void GameEventQueue::Release()
143136
}
144137
else
145138
unused.push_back(ready.front());
146-
#endif
147139
//---------------------------------------------
148140
ready.pop_front();
149141
pcs->Leave();
@@ -183,8 +175,7 @@ u32 GameEventQueue::EraseEvents(event_predicate to_del)
183175
while (need_to_erase != ready.end())
184176
{
185177
//-----
186-
#ifndef LINUX // FIXME!!!
187-
u32 tmp_time = GetTickCount() - 60000;
178+
u32 tmp_time = SDL_GetTicks() - 60000;
188179
u32 size = unused.size();
189180
if ((LastTimeCreate < tmp_time) && (size > 32))
190181
{
@@ -197,7 +188,6 @@ u32 GameEventQueue::EraseEvents(event_predicate to_del)
197188
{
198189
unused.push_back(*need_to_erase);
199190
}
200-
#endif
201191
//-----
202192
#ifdef DEBUG
203193
Msg("! GameEventQueue::EraseEvents - destroying event type[%d], sender[0x%08x]", (*need_to_erase)->type,

src/xrGameSpy/stdafx.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
#include "Common/Common.hpp"
44
#include "xrCore/xrCore.h"
55

6-
#ifdef LINUX
76
#include "SDL.h"
8-
#endif
97

108
#include <GameSpy/common/gsCommon.h>
119
#include <GameSpy/common/gsAvailable.h>

src/xrNetServer/NET_Client.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ NET_Packet* INetQueue::Create()
132132
ready.push_back(new NET_Packet());
133133
P = ready.back();
134134
//---------------------------------------------
135-
LastTimeCreate = GetTickCount();
135+
LastTimeCreate = SDL_GetTicks();
136136
//---------------------------------------------
137137
}
138138
else
@@ -157,7 +157,7 @@ NET_Packet* INetQueue::Create(const NET_Packet& _other)
157157
ready.push_back(new NET_Packet());
158158
P = ready.back();
159159
//---------------------------------------------
160-
LastTimeCreate = GetTickCount();
160+
LastTimeCreate = SDL_GetTicks();
161161
//---------------------------------------------
162162
}
163163
else
@@ -183,7 +183,7 @@ NET_Packet* INetQueue::Retreive()
183183
//---------------------------------------------
184184
else
185185
{
186-
u32 tmp_time = GetTickCount() - 60000;
186+
u32 tmp_time = SDL_GetTicks() - 60000;
187187
u32 size = unused.size();
188188
if ((LastTimeCreate < tmp_time) && (size > 32))
189189
{
@@ -204,7 +204,7 @@ void INetQueue::Release()
204204
//#endif
205205
VERIFY(!ready.empty());
206206
//---------------------------------------------
207-
u32 tmp_time = GetTickCount() - 60000;
207+
u32 tmp_time = SDL_GetTicks() - 60000;
208208
u32 size = unused.size();
209209
ready.front()->B.count = 0;
210210
if ((LastTimeCreate < tmp_time) && (size > 32))

src/xrNetServer/empty/NET_Client.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ NET_Packet* INetQueue::Create()
4747
ready.push_back(new NET_Packet());
4848
P = ready.back();
4949
//---------------------------------------------
50-
// LastTimeCreate = GetTickCount();
50+
// LastTimeCreate = SDL_GetTicks();
5151
//---------------------------------------------
5252
} else {
5353
ready.push_back(unused.back());
@@ -66,7 +66,7 @@ NET_Packet* INetQueue::Create(const NET_Packet& _other)
6666
ready.push_back(new NET_Packet());
6767
P = ready.back();
6868
//---------------------------------------------
69-
// LastTimeCreate = GetTickCount();
69+
// LastTimeCreate = SDL_GetTicks();
7070
//---------------------------------------------
7171
} else {
7272
ready.push_back(unused.back());
@@ -87,7 +87,7 @@ NET_Packet* INetQueue::Retreive()
8787
//---------------------------------------------
8888
else {
8989
/*
90-
u32 tmp_time = GetTickCount() - 60000;
90+
u32 tmp_time = SDL_GetTicks() - 60000;
9191
u32 size = unused.size();
9292
if ((LastTimeCreate < tmp_time) && (size > 32))
9393
{
@@ -104,7 +104,7 @@ void INetQueue::Release()
104104
{
105105
VERIFY(!ready.empty());
106106
//---------------------------------------------
107-
// u32 tmp_time = GetTickCount() - 60000;
107+
// u32 tmp_time = SDL_GetTicks() - 60000;
108108
u32 size = unused.size();
109109
ready.front()->B.count = 0;
110110
/*

0 commit comments

Comments
 (0)