Skip to content

Commit

Permalink
Various fixes and improvements:
Browse files Browse the repository at this point in the history
SDL_SCANCODE_LGUI replaced with SDL_SCANCODE_LALT
xrGame/MainMenu.cpp: fixed mistake in condition
Removed unnecessary casts
Formatting
xrRender/HW.cpp: I'm assuming that there should be check for depth stencil format
  • Loading branch information
Xottab-DUTY committed Jul 25, 2018
1 parent 10d2ff5 commit 7dec3d7
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 39 deletions.
6 changes: 3 additions & 3 deletions src/Layers/xrRender/HW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ void CHW::CreateDevice(SDL_Window* m_sdlWnd)
fDepth = selectDepthStencil(fTarget);
}

if (D3DFMT_UNKNOWN == fTarget)
if (D3DFMT_UNKNOWN == fTarget || D3DFMT_UNKNOWN == fDepth)
{
Msg("Failed to initialize graphics hardware.\n"
Log("Failed to initialize graphics hardware.\n"
"Please try to restart the game.\n"
"Can not find matching format for back buffer.");
FlushLog();
Expand Down Expand Up @@ -143,7 +143,7 @@ void CHW::CreateDevice(SDL_Window* m_sdlWnd)
}
}
else
Log("Couldn't get window information: %s", SDL_GetError());
Log("! Couldn't get window information: ", SDL_GetError());

P.Windowed = bWindowed;

Expand Down
3 changes: 2 additions & 1 deletion src/Layers/xrRenderDX10/dx10HW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ void CHW::CreateDevice(SDL_Window* m_sdlWnd)
}
else
Log("Couldn't get window information: ", SDL_GetError());

sd.Windowed = bWindowed;

// Depth/stencil (DX10 don't need this?)
Expand All @@ -138,7 +139,7 @@ void CHW::CreateDevice(SDL_Window* m_sdlWnd)

UINT createDeviceFlags = 0;
#ifdef DEBUG
// createDeviceFlags |= D3Dxx_CREATE_DEVICE_DEBUG;
// createDeviceFlags |= D3Dxx_CREATE_DEVICE_DEBUG;
#endif
HRESULT R;
#ifdef USE_DX11
Expand Down
39 changes: 25 additions & 14 deletions src/xrEngine/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ void CRenderDevice::on_idle()
}

if (psDeviceFlags.test(rsStatistic))
g_bEnableStatGather = TRUE; // XXX: why not use either rsStatistic or g_bEnableStatGather?
g_bEnableStatGather = true; // XXX: why not use either rsStatistic or g_bEnableStatGather?
else
g_bEnableStatGather = FALSE;
g_bEnableStatGather = false;

if (g_loading_events.size())
{
Expand Down Expand Up @@ -505,17 +505,19 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason)
if (bOn)
{
if (!Paused())
bShowPauseString = editor() ? FALSE :
{
bShowPauseString = editor() ? FALSE : TRUE;
#ifdef DEBUG
!xr_strcmp(reason, "li_pause_key_no_clip") ? FALSE :
#endif // DEBUG
TRUE;
if (xr_strcmp(reason, "li_pause_key_no_clip") == 0)
bShowPauseString = FALSE;
#endif
}
if (bTimer && (!g_pGamePersistent || g_pGamePersistent->CanBePaused()))
{
g_pauseMngr().Pause(TRUE);
g_pauseMngr().Pause(true);
#ifdef DEBUG
if (!xr_strcmp(reason, "li_pause_key_no_clip"))
TimerGlobal.Pause(FALSE);
if (xr_strcmp(reason, "li_pause_key_no_clip") == 0)
TimerGlobal.Pause(false);
#endif
}
if (bSound && GEnv.Sound)
Expand All @@ -526,7 +528,7 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason)
if (bTimer && g_pauseMngr().Paused())
{
fTimeDelta = EPS_S + EPS_S;
g_pauseMngr().Pause(FALSE);
g_pauseMngr().Pause(false);
}
if (bSound)
{
Expand All @@ -545,7 +547,10 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason)
BOOL CRenderDevice::Paused() { return g_pauseMngr().Paused(); }
void CRenderDevice::OnWM_Activate(WPARAM wParam, LPARAM /*lParam*/)
{
const BOOL isWndActive = (1 == wParam) ? TRUE : FALSE;
u16 fActive = LOWORD(wParam);
const BOOL fMinimized = (BOOL)HIWORD(wParam);

const BOOL isWndActive = (fActive != WA_INACTIVE && !fMinimized) ? TRUE : FALSE;

if (!editor() && !GEnv.isDedicatedServer && isWndActive)
pInput->ClipCursor(true);
Expand Down Expand Up @@ -589,10 +594,16 @@ CRenderDevice* get_device() { return &Device; }
u32 script_time_global() { return Device.dwTimeGlobal; }
u32 script_time_global_async() { return Device.TimerAsync_MMT(); }

SCRIPT_EXPORT(Device, (), {
SCRIPT_EXPORT(Device, (),
{
using namespace luabind;
module(luaState)[def("time_global", &script_time_global), def("time_global_async", &script_time_global_async),
def("device", &get_device), def("is_enough_address_space_available", &is_enough_address_space_available)];
module(luaState)
[
def("time_global", &script_time_global),
def("time_global_async", &script_time_global_async),
def("device", &get_device),
def("is_enough_address_space_available", &is_enough_address_space_available)
];
});

CLoadScreenRenderer::CLoadScreenRenderer() : b_registered(false), b_need_user_input(false) {}
Expand Down
17 changes: 8 additions & 9 deletions src/xrEngine/line_edit_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ void line_edit_control::update_key_states()
{
m_key_state.zero();

set_key_state(ks_LShift, !!pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT));
set_key_state(ks_RShift, !!pInput->iGetAsyncKeyState(SDL_SCANCODE_RSHIFT));
set_key_state(ks_LCtrl, !!pInput->iGetAsyncKeyState(SDL_SCANCODE_LCTRL));
set_key_state(ks_RCtrl, !!pInput->iGetAsyncKeyState(SDL_SCANCODE_RCTRL));
set_key_state(ks_LAlt, !!pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT));
set_key_state(ks_RAlt, !!pInput->iGetAsyncKeyState(SDL_SCANCODE_RALT));
set_key_state(ks_CapsLock, text_editor::get_caps_lock_state());
set_key_state(ks_LShift, pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT));
set_key_state(ks_RShift, pInput->iGetAsyncKeyState(SDL_SCANCODE_RSHIFT));
set_key_state(ks_LCtrl, pInput->iGetAsyncKeyState(SDL_SCANCODE_LCTRL));
set_key_state(ks_RCtrl, pInput->iGetAsyncKeyState(SDL_SCANCODE_RCTRL));
set_key_state(ks_LAlt, pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT));
set_key_state(ks_RAlt, pInput->iGetAsyncKeyState(SDL_SCANCODE_RALT));
set_key_state(ks_CapsLock, SDL_GetModState() & KMOD_CAPS);
}

void line_edit_control::clear_states()
Expand Down Expand Up @@ -489,7 +489,7 @@ void line_edit_control::on_frame()
{
update_key_states();

u32 fr_time = Device.dwTimeContinual;
const auto fr_time = Device.dwTimeContinual;
float dt = (fr_time - m_last_frame_time) * 0.001f;
if (dt > 0.06666f)
{
Expand Down Expand Up @@ -774,7 +774,6 @@ void remove_spaces(pstr str)
--i;

if (i < str_size)

strncpy_s(str, str_size, new_str, i);
}

Expand Down
6 changes: 3 additions & 3 deletions src/xrEngine/line_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace text_editor
line_editor::line_editor(u32 str_buffer_size) : m_control(str_buffer_size) {}
line_editor::~line_editor() {}
void line_editor::on_frame() { m_control.on_frame(); }
void line_editor::IR_OnKeyboardPress(int dik) {m_control.on_key_press(dik); }
void line_editor::IR_OnKeyboardHold(int dik) {m_control.on_key_hold(dik); }
void line_editor::IR_OnKeyboardRelease(int dik) {m_control.on_key_release(dik); }
void line_editor::IR_OnKeyboardPress(int dik) { m_control.on_key_press(dik); }
void line_editor::IR_OnKeyboardHold(int dik) { m_control.on_key_hold(dik); }
void line_editor::IR_OnKeyboardRelease(int dik) { m_control.on_key_release(dik); }
} // namespace text_editor
1 change: 1 addition & 0 deletions src/xrEngine/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "Text_Console.h"
#elif defined(LINUX)
#define CTextConsole CConsole
#pragma todo("Implement text console or it's alternative")
#endif
#include "xrSASH.h"
#include "xr_ioc_cmd.h"
Expand Down
6 changes: 3 additions & 3 deletions src/xrGame/ActorInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ void CActor::OnNextWeaponSlot()
IR_OnKeyboardPress(kARTEFACT);
}
else
IR_OnKeyboardPress((EGameActions) (kWPN_1 + i));
IR_OnKeyboardPress(kWPN_1 + i);
return;
}
}
Expand Down Expand Up @@ -570,7 +570,7 @@ void CActor::OnPrevWeaponSlot()
IR_OnKeyboardPress(kARTEFACT);
}
else
IR_OnKeyboardPress((EGameActions) (kWPN_1 + i));
IR_OnKeyboardPress(kWPN_1 + i);
return;
}
}
Expand Down Expand Up @@ -661,7 +661,7 @@ void CActor::NoClipFly(int cmd)
float scale = 1.0f;
if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT))
scale = 0.25f;
else if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LGUI))
else if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT))
scale = 4.0f;

switch (cmd)
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ void CMainMenu::IR_OnKeyboardPress(int dik)
return;
}

if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT) || pInput->iGetAsyncKeyState(SDL_SCANCODE_RALT)
&& pInput->iGetAsyncKeyState(SDL_SCANCODE_LGUI) || pInput->iGetAsyncKeyState(SDL_SCANCODE_RGUI))
if ((pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT) || pInput->iGetAsyncKeyState(SDL_SCANCODE_RALT))
&& (pInput->iGetAsyncKeyState(SDL_SCANCODE_LGUI) || pInput->iGetAsyncKeyState(SDL_SCANCODE_RGUI)))
{
IWantMyMouseBackScreamed = true;
pInput->ClipCursor(false);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/attachable_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void attach_adjust_mode_keyb(int dik)
return;

bool b_move = !!(pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT));
bool b_rot = !!(pInput->iGetAsyncKeyState(SDL_SCANCODE_LGUI));
bool b_rot = !!(pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT));

int axis = -1;
if (pInput->iGetAsyncKeyState(SDL_SCANCODE_Z))
Expand Down
5 changes: 2 additions & 3 deletions src/xrGame/ui/UIXmlInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ bool CUIXmlInit::InitText(CUIXml& xml_doc, LPCSTR path, int index, CUILines* pLi
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////
extern int keyname_to_dik(LPCSTR);

bool CUIXmlInit::Init3tButton(CUIXml& xml_doc, LPCSTR path, int index, CUI3tButton* pWnd)
{
Expand Down Expand Up @@ -397,13 +396,13 @@ bool CUIXmlInit::Init3tButton(CUIXml& xml_doc, LPCSTR path, int index, CUI3tButt
LPCSTR accel = xml_doc.ReadAttrib(path, index, "accel", NULL);
if (accel)
{
int acc = (int) keyname_to_dik(accel);
int acc = keyname_to_dik(accel);
pWnd->SetAccelerator(acc, 0);
}
accel = xml_doc.ReadAttrib(path, index, "accel_ext", NULL);
if (accel)
{
int acc = (int) keyname_to_dik(accel);
int acc = keyname_to_dik(accel);
pWnd->SetAccelerator(acc, 1);
}

Expand Down

0 comments on commit 7dec3d7

Please sign in to comment.