Skip to content

Commit

Permalink
xrGame: Avoid all the remaining issues by "#ifndef LINUX"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zegeri committed Sep 16, 2018
1 parent 24697f8 commit a902b75
Show file tree
Hide file tree
Showing 40 changed files with 183 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/xrAICore/Navigation/vertex_manager_hash_fixed_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ inline bool CHashFixedVertexManager::is_opened(const Vertex& vertex) const { ret
TEMPLATE_SPECIALIZATION
inline u32 CHashFixedVertexManager::hash_index(const Index& vertex_id) const
{
#ifdef LINUX // FIXME!!
return 0;
#else
return hash_fixed_vertex_manager::to_u32(vertex_id) % HashSize;
#endif
}

TEMPLATE_SPECIALIZATION
Expand Down
4 changes: 4 additions & 0 deletions src/xrGame/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@
#include "doors.h"
#include "xrNetServer/NET_Messages.h"

#ifndef LINUX // FIXME!!!
#pragma warning(push)
#pragma warning(disable : 4995)
#include <intrin.h>
#pragma warning(pop)

#pragma intrinsic(_InterlockedCompareExchange)
#endif

extern MagicBox3 MagicMinBox(int iQuantity, const Fvector* akPoint);

Expand Down Expand Up @@ -109,8 +111,10 @@ void CGameObject::MakeMeCrow()
return;
u32 const device_frame_id = Device.dwFrame;
u32 const object_frame_id = dwFrame_AsCrow;
#ifndef LINUX // FIXME!!!
if ((u32)_InterlockedCompareExchange((long*)&dwFrame_AsCrow, device_frame_id, object_frame_id) == device_frame_id)
return;
#endif
VERIFY(dwFrame_AsCrow == device_frame_id);
Props.crow = 1;
g_pGameLevel->Objects.o_crow(this);
Expand Down
3 changes: 3 additions & 0 deletions src/xrGame/Level_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ bool CLevel::Connect2Server(const char* options)
//---------------------------------------------------------------------------
if (psNET_direct_connect)
m_bConnectResultReceived = true;

#ifndef LINUX // FIXME!!!
u32 EndTime = GetTickCount() + ConnectionTimeOut;
while (!m_bConnectResultReceived)
{
Expand Down Expand Up @@ -391,6 +393,7 @@ bool CLevel::Connect2Server(const char* options)
}
//-----------------------------------------
}
#endif
Msg("%c client : connection %s - <%s>", m_bConnectResult ? '*' : '!', m_bConnectResult ? "accepted" : "rejected",
m_sConnectResult.c_str());
if (!m_bConnectResult)
Expand Down
2 changes: 2 additions & 0 deletions src/xrGame/Level_network_Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ void CLevel::PrepareToSaveDemo()
R_ASSERT(!m_DemoPlay);
string_path demo_name = "";
string_path demo_path;
#ifndef LINUX // FIXME!!!
SYSTEMTIME Time;
GetLocalTime(&Time);
xr_sprintf(demo_name, "xray_%02d-%02d-%02d_%02d-%02d-%02d.demo", Time.wMonth, Time.wDay, Time.wYear, Time.wHour,
Time.wMinute, Time.wSecond);
#endif
Msg("Demo would be stored in - %s", demo_name);
FS.update_path(demo_path, "$logs$", demo_name);
m_writer = FS.w_open(demo_path);
Expand Down
3 changes: 2 additions & 1 deletion src/xrGame/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,9 @@ void CMainMenu::OnDownloadPatch(CUIWindow*, void*)

string4096 FilePath = "";
char* FileName = NULL;
#ifndef LINUX // FIXME!!!
GetFullPathName(fileName, 4096, FilePath, &FileName);

#endif
string_path fname;
if (FS.path_exist("$downloads$"))
{
Expand Down
44 changes: 40 additions & 4 deletions src/xrGame/RegistryFuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

bool ReadRegistryValue(LPCSTR rKeyName, DWORD rKeyType, void* value)
{
#ifdef LINUX // FIXME!!!
return true;
#else
HKEY hKey = 0;
long res = RegOpenKeyEx(REGISTRY_BASE, REGISTRY_PATH, 0, KEY_READ, &hKey);

Expand Down Expand Up @@ -51,10 +54,14 @@ bool ReadRegistryValue(LPCSTR rKeyName, DWORD rKeyType, void* value)

memcpy(value, rBuf, KeyValueSize);
return true;
#endif
};

bool WriteRegistryValue(LPCSTR rKeyName, DWORD rKeyType, const void* value)
{
#ifdef LINUX // FIXME!!!
return true;
#else
HKEY hKey;

long res = RegOpenKeyEx(REGISTRY_BASE, REGISTRY_PATH, 0, KEY_WRITE, &hKey);
Expand Down Expand Up @@ -93,14 +100,40 @@ bool WriteRegistryValue(LPCSTR rKeyName, DWORD rKeyType, const void* value)
if (hKey)
RegCloseKey(hKey);
return true;
#endif
};

bool ReadRegistry_StrValue(LPCSTR rKeyName, char* value) { return ReadRegistryValue(rKeyName, REG_SZ, value); }
void WriteRegistry_StrValue(LPCSTR rKeyName, const char* value) { WriteRegistryValue(rKeyName, REG_SZ, value); }
void ReadRegistry_DWValue(LPCSTR rKeyName, DWORD& value) { ReadRegistryValue(rKeyName, REG_DWORD, &value); }
void WriteRegistry_DWValue(LPCSTR rKeyName, const DWORD& value) { WriteRegistryValue(rKeyName, REG_DWORD, &value); }
bool ReadRegistry_StrValue(LPCSTR rKeyName, char* value)
{
#ifdef LINUX // FIXME!!!
return true;
#else
return ReadRegistryValue(rKeyName, REG_SZ, value);
#endif
}
void WriteRegistry_StrValue(LPCSTR rKeyName, const char* value)
{
#ifndef LINUX // FIXME!!!
WriteRegistryValue(rKeyName, REG_SZ, value);
#endif
}
void ReadRegistry_DWValue(LPCSTR rKeyName, DWORD& value)
{
#ifndef LINUX // FIXME!!!
ReadRegistryValue(rKeyName, REG_DWORD, &value);
#endif
}
void WriteRegistry_DWValue(LPCSTR rKeyName, const DWORD& value)
{
#ifndef LINUX // FIXME!!
WriteRegistryValue(rKeyName, REG_DWORD, &value);
#endif
}
u32 const ReadRegistry_BinaryValue(LPCSTR rKeyName, u8* buffer_dest, u32 const buffer_size)
{
#ifdef LINUX // FIXME!!!
return u32(0);
#else
HKEY hKey = 0;
long res = RegOpenKeyEx(REGISTRY_BASE, REGISTRY_PATH, 0, KEY_READ, &hKey);

Expand All @@ -127,10 +160,12 @@ u32 const ReadRegistry_BinaryValue(LPCSTR rKeyName, u8* buffer_dest, u32 const b
}

return static_cast<u32>(tmp_buffer_size);
#endif
}

void WriteRegistry_BinaryValue(LPCSTR rKeyName, u8 const* buffer_src, u32 const buffer_size)
{
#ifndef LINUX // FIXME!!!
HKEY hKey;

long res = RegOpenKeyEx(REGISTRY_BASE, REGISTRY_PATH, 0, KEY_WRITE, &hKey);
Expand All @@ -150,4 +185,5 @@ void WriteRegistry_BinaryValue(LPCSTR rKeyName, u8 const* buffer_src, u32 const
res = RegSetValueEx(hKey, rKeyName, NULL, REG_BINARY, buffer_src, buffer_size);

RegCloseKey(hKey);
#endif
}
2 changes: 2 additions & 0 deletions src/xrGame/account_manager_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ using namespace luabind;
using namespace luabind::policy;
using namespace gamespy_gp;

#ifndef LINUX // FIXME!!!
SCRIPT_EXPORT(account_manager, (), {
module(luaState)[class_<account_manager>("account_manager")
.def("suggest_unique_nicks", &account_manager::suggest_unique_nicks)
Expand Down Expand Up @@ -65,3 +66,4 @@ SCRIPT_EXPORT(found_email_cb, (), {
.def("bind", &gamespy_gp::found_email_cb::bind)
.def("clear", &gamespy_gp::found_email_cb::clear)];
});
#endif
3 changes: 3 additions & 0 deletions src/xrGame/alife_simulator_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ SCRIPT_EXPORT(CALifeSimulator, (), {
.def("set_interactive",
(void (CALifeSimulator::*)(ALife::_OBJECT_ID, bool))(&CALifeSimulator::set_interactive))
.def("kill_entity", &CALifeSimulator::kill_entity)

.def("kill_entity", &kill_entity0)
.def("kill_entity", &kill_entity1)
.def("add_in_restriction", &add_in_restriction)
Expand All @@ -347,8 +348,10 @@ SCRIPT_EXPORT(CALifeSimulator, (), {
.def("actor", &get_actor)
.def("has_info", &has_info)
.def("dont_has_info", &dont_has_info)
#ifndef LINUX // FIXME!!!
.def("switch_distance", &CALifeSimulator::switch_distance)
.def("set_switch_distance", &CALifeSimulator::set_switch_distance) //Alundaio: renamed to set_switch_distance from switch_distance
#endif
//Alundaio: extend alife simulator exports
.def("teleport_object", &teleport_object)
//Alundaio: END
Expand Down
10 changes: 10 additions & 0 deletions src/xrGame/configs_dumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,21 @@ configs_dumper::configs_dumper()

configs_dumper::~configs_dumper()
{
#ifndef LINUX // FIXME!!!
if (m_make_start_event)
{
SetEvent(m_make_start_event);
WaitForSingleObject(m_make_done_event, INFINITE); // thread stoped
CloseHandle(m_make_done_event);
CloseHandle(m_make_start_event);
}
#endif
xr_free(m_buffer_for_compress);
}

void configs_dumper::shedule_Update(u32 dt)
{
#ifndef LINUX // FIXME!!!
DWORD thread_result = WaitForSingleObject(m_make_done_event, 0);
R_ASSERT((thread_result != WAIT_ABANDONED) && (thread_result != WAIT_FAILED));
R_ASSERT(m_state == ds_active);
Expand All @@ -53,6 +56,7 @@ void configs_dumper::shedule_Update(u32 dt)
m_state = ds_not_active;
Engine.Sheduler.Unregister(this);
}
#endif
}

struct ExistDumpPredicate
Expand Down Expand Up @@ -204,6 +208,7 @@ void configs_dumper::dump_config(complete_callback_t complete_cb)
}

ULONG_PTR process_affinity_mask, tmp_dword;
#ifndef LINUX // FIXME!!!
GetProcessAffinityMask(GetCurrentProcess(), &process_affinity_mask, &tmp_dword);
bool single_core = (btwCount1(static_cast<u32>(process_affinity_mask)) == 1);
if (single_core)
Expand All @@ -227,6 +232,7 @@ void configs_dumper::dump_config(complete_callback_t complete_cb)
m_make_done_event = CreateEvent(NULL, FALSE, FALSE, NULL);
thread_spawn(&configs_dumper::dumper_thread, "configs_dumper", 0, this);
Engine.Sheduler.Register(this, TRUE);
#endif
}

void configs_dumper::compress_configs()
Expand All @@ -244,6 +250,7 @@ void configs_dumper::compress_configs()
void configs_dumper::dumper_thread(void* my_ptr)
{
configs_dumper* this_ptr = static_cast<configs_dumper*>(my_ptr);
#ifndef LINUX // FIXME!!!
DWORD wait_result = WaitForSingleObject(this_ptr->m_make_start_event, INFINITE);
while ((wait_result != WAIT_ABANDONED) || (wait_result != WAIT_FAILED))
{
Expand All @@ -262,6 +269,7 @@ void configs_dumper::dumper_thread(void* my_ptr)
wait_result = WaitForSingleObject(this_ptr->m_make_start_event, INFINITE);
}
SetEvent(this_ptr->m_make_done_event);
#endif
}

void __stdcall configs_dumper::yield_cb(long progress)
Expand All @@ -274,8 +282,10 @@ void __stdcall configs_dumper::yield_cb(long progress)

void __stdcall configs_dumper::switch_thread()
{
#ifndef LINUX // FIXME!!!
if (!SwitchToThread())
Sleep(10);
#endif
}

void configs_dumper::realloc_compress_buffer(u32 need_size)
Expand Down
3 changes: 2 additions & 1 deletion src/xrGame/game_cl_base_weapon_usage_statistic_save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void WeaponUsageStatistic::SaveData()
return;

string64 GameType;
#ifndef LINUX // FIXME!!!
SYSTEMTIME Time;
switch (GameID())
{
Expand All @@ -82,7 +83,7 @@ void WeaponUsageStatistic::SaveData()
GetLocalTime(&Time);
xr_sprintf(mFileName, "(%s)_(%s)_%02d.%02d.%02d_%02d.%02d.%02d.wus", *(Level().name()), GameType, Time.wMonth,
Time.wDay, Time.wYear, Time.wHour, Time.wMinute, Time.wSecond);

#endif
//---------------------------------------------------------
FS.update_path(mFileName, "$logs$", mFileName);
FILE* SFile = fopen(mFileName, "wb");
Expand Down
4 changes: 4 additions & 0 deletions src/xrGame/game_cl_mp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1535,11 +1535,13 @@ void game_cl_mp::SendCollectedData(u8 const* buffer, u32 buffer_size, u32 uncomp
upload_memory_writer.pointer(), upload_memory_writer.size(), sending_cb, uncompressed_size);
};

#ifndef LINUX // FIXME!!!
void game_cl_mp::generate_file_name(string_path& file_name, LPCSTR file_suffix, SYSTEMTIME const& date_time)
{
xr_sprintf(file_name, "%02d%02d%02d-%02d%02d%02d_%s", date_time.wYear % 100, date_time.wMonth, date_time.wDay,
date_time.wHour, date_time.wMinute, date_time.wSecond, file_suffix);
}
#endif

LPCSTR game_cl_mp::make_file_name(LPCSTR session_id, string_path& dest)
{
Expand Down Expand Up @@ -1582,9 +1584,11 @@ void game_cl_mp::PrepareToReceiveFile(
string_path screen_shot_fn;
LPCSTR dest_file_name = NULL;
STRCONCAT(dest_file_name, make_file_name(client_session_id.c_str(), screen_shot_fn));
#ifndef LINUX // FIXME!!!
SYSTEMTIME date_time;
GetLocalTime(&date_time);
generate_file_name(screen_shot_fn, dest_file_name, date_time);
#endif

fr_callback_binder* tmp_binder = get_receiver_cb_binder();
if (!tmp_binder)
Expand Down
2 changes: 2 additions & 0 deletions src/xrGame/game_cl_mp.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ class game_cl_mp : public game_cl_GameState

void __stdcall sending_screenshot_callback(file_transfer::sending_status_t status, u32 bytes_sent, u32 data_size);
//-------------------------------------------------------------------------------------------------
#ifndef LINUX
static void generate_file_name(string_path& file_name, LPCSTR file_suffix, SYSTEMTIME const& date_time);
#endif
static LPCSTR make_file_name(LPCSTR session_id, string_path& dest);
//-------------------------------------------------------------------------------------------------
#include "game_cl_mp_messages_menu.h"
Expand Down
4 changes: 4 additions & 0 deletions src/xrGame/game_sv_deathmatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ void game_sv_Deathmatch::Create(shared_str& options)

switch_Phase(GAME_PHASE_PENDING);

#ifdef LINUX // FIXME!!!
::Random.seed(0);
#else
::Random.seed(GetTickCount());
#endif
m_CorpseList.clear();

m_AnomaliesPermanent.clear();
Expand Down
Loading

0 comments on commit a902b75

Please sign in to comment.