Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions code/conquer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@

#include <algorithm>
#include <array>
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstring>
Expand All @@ -141,6 +142,7 @@
#include <io.h>
#include <share.h>
#include <span>
#include <thread>


/****************************************
Expand Down Expand Up @@ -959,7 +961,7 @@ bool Map_Edit_Loop(void)
Call_Back(); // maintains Theme.AI() for music
// Color_Cycle();

Sleep(1);
std::this_thread::sleep_for(std::chrono::milliseconds(1));

return(!GameActive);
}
Expand Down Expand Up @@ -988,7 +990,7 @@ static void Resize_Tactical_View(bool flag)
Rect view(0, 0, Options.ScreenWidth, Options.ScreenHeight);
Map.Set_View_Dimensions(view);

Sleep(2);
std::this_thread::sleep_for(std::chrono::milliseconds(2));

} else {

Expand All @@ -1001,7 +1003,7 @@ static void Resize_Tactical_View(bool flag)
Rect view(0, _tab_height, Options.ScreenWidth-_sidebar_width, Options.ScreenHeight-_tab_height);
Map.Set_View_Dimensions(view);

Sleep(2);
std::this_thread::sleep_for(std::chrono::milliseconds(2));
}
}

Expand Down
4 changes: 3 additions & 1 deletion code/except.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include <tlhelp32.h>

#include <atomic>
#include <chrono>
#include <cmath>
#include <csignal>
#include <cstdarg>
Expand All @@ -68,6 +69,7 @@
#include <cstring>
#include <eh.h>
#include <exception>
#include <thread>

#define MS_VC_THREAD_NAME_EXCEPTION 0x406D1388
#define MS_CPP_EXCEPTION 0xE06D7363
Expand Down Expand Up @@ -1679,7 +1681,7 @@ static void Save_Machine_State(EXCEPTION_POINTERS * e_info, DWORD self)
// The artifacts are safe, and the dumper owns the dialog and the exit from here.
for (;;) {
SuspendThread(GetCurrentThread());
Sleep(1000);
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
}

Expand Down
12 changes: 9 additions & 3 deletions code/mainloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
#include "special.hh"

#include <algorithm>
#include <chrono>
#include <thread>

//
// Special module globals for recording and playback
Expand Down Expand Up @@ -173,7 +175,7 @@ static void Check_For_Focus_Loss(void)
Windows_Message_Handler();
break;
}
Sleep(10);
std::this_thread::sleep_for(std::chrono::milliseconds(10));
Windows_Message_Handler();
}
}
Expand Down Expand Up @@ -557,7 +559,7 @@ void Sync_Delay(void)
TacticalMap->AI();
Map.Render();
} else {
Sleep(0);
std::this_thread::yield();
}
if (!FrameTimer()) {
break;
Expand All @@ -567,7 +569,11 @@ void Sync_Delay(void)
}

// Out of focus nothing is drawn, so the wait gives the processor back.
Sleep(GameInFocus ? 0 : 1);
if (GameInFocus) {
std::this_thread::yield();
} else {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}

static CDTimerClass<MillisecondSystemTimerClass> fps_timer;
Expand Down
6 changes: 4 additions & 2 deletions code/msengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
#include "color.hh"

#include <algorithm>
#include <chrono>
#include <climits>
#include <thread>


/// <summary>
Expand Down Expand Up @@ -377,7 +379,7 @@ void MSEngine::Wait_Delay(int delay)
timer.Start();
}

Sleep(0);
std::this_thread::yield();

} while (timer.Value() > 0);

Expand Down Expand Up @@ -406,7 +408,7 @@ void MSEngine::Wait_For_Focus(void)

while (!GameInFocus) {
DebugString("MSEngine - Sleeping\n");
Sleep(500);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
Windows_Message_Handler();
}

Expand Down
3 changes: 2 additions & 1 deletion code/netdlg2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "wsproto.h"

#include <algorithm>
#include <thread>


/*
Expand Down Expand Up @@ -390,7 +391,7 @@ bool Net2Can_Start(void)
bool Net2_Service_Lobby(void)
{
Ipx.Service();
Sleep(0);
std::this_thread::yield();
Call_Back();
Ipx.Service();
Title_Screen_Restore();
Expand Down
4 changes: 3 additions & 1 deletion code/savemgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
#include "dialog.hh"

#include <algorithm>
#include <chrono>
#include <cstdio>
#include <string>
#include <thread>
#include <vector>


Expand Down Expand Up @@ -602,7 +604,7 @@ void SaveManagerClass::Process_Pending_Load_Game(void)
}
UI_Service_Game();
UIShell.Tick();
Sleep(10);
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}

box.Hide();
Expand Down
6 changes: 4 additions & 2 deletions code/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
#include "winstub.h"

#include <algorithm>
#include <chrono>
#include <thread>


#define SIZEGBAR 140
Expand Down Expand Up @@ -1053,7 +1055,7 @@ void ScoreClass::Call_Back_Delay(int time)
cd.Start();
}

Sleep(0);
std::this_thread::yield();

} while (cd > 0);

Expand Down Expand Up @@ -1114,7 +1116,7 @@ void ScoreClass::Timing(void)
}

while (!GameInFocus) {
Sleep(500);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
Windows_Message_Handler();
}

Expand Down
4 changes: 3 additions & 1 deletion code/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@
#include "xstraw.h"

#include <algorithm>
#include <chrono>
#include <ctime> // for station ID computation
#include <dos.h> // for station ID computation
#include <thread>
#include <winsock.h> // for ntohl


Expand Down Expand Up @@ -1559,7 +1561,7 @@ void SessionClass::Update_Progress(int percent)
Call_Back();

while (Ipx.Global_Num_Send() > 5 && timer > 0) {
Sleep(20);
std::this_thread::sleep_for(std::chrono::milliseconds(20));
Windows_Message_Handler();
Call_Back();
}
Expand Down
4 changes: 3 additions & 1 deletion code/startup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,11 @@
#include "zbuffer.h"

#include <cfloat>
#include <chrono>
#include <lzo/lzoconf.h>
#include <shellapi.h>
#include <string>
#include <thread>
#include <vector>

extern HINSTANCE LanguageResources;
Expand Down Expand Up @@ -411,7 +413,7 @@ static bool Claim_Single_Instance(void)
if (GetLastError () == ERROR_ALREADY_EXISTS) {
CloseHandle (AutoPlayMutex);
AutoPlayMutex = NULL;
Sleep (2500);
std::this_thread::sleep_for(std::chrono::milliseconds(2500));
} else {
DebugString("Create AutoPlayMutex.\n");
}
Expand Down
4 changes: 3 additions & 1 deletion code/taction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@
#include "draw.hh"
#include "need.hh"

#include <chrono>
#include <cstdio>
#include <limits>
#include <thread>

DynamicVectorClass<TActionClass *> Actions;

Expand Down Expand Up @@ -2058,7 +2060,7 @@ bool TActionClass::TAction_ZOOM_IN(HouseClass * , ObjectClass * , TriggerClass *
Map.Flag_To_Redraw();
Map.Render();

Sleep(1000);
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
return(true);
}

Expand Down
4 changes: 3 additions & 1 deletion code/vqa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
// lib includes here.
#include "audio/audiomovie.h"

#include <chrono>
#include <thread>
#include <unvq.h>
#include <vqaplay.h>
#include <vqaplayp.h>
Expand Down Expand Up @@ -520,7 +522,7 @@ int VQAClass::Play_VQA(int last_frame_to_play, bool nobreakout)

if (sleeping == true) {
if (!GameInFocus) {
Sleep((1000/30));
std::this_thread::sleep_for(std::chrono::milliseconds(1000 / 30));
continue;
} else {
sleeping = false;
Expand Down
Loading