Skip to content

Commit 7dec3d7

Browse files
committed
Various fixes and improvements:
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
1 parent 10d2ff5 commit 7dec3d7

File tree

10 files changed

+50
-39
lines changed

10 files changed

+50
-39
lines changed

src/Layers/xrRender/HW.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ void CHW::CreateDevice(SDL_Window* m_sdlWnd)
101101
fDepth = selectDepthStencil(fTarget);
102102
}
103103

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

148148
P.Windowed = bWindowed;
149149

src/Layers/xrRenderDX10/dx10HW.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ void CHW::CreateDevice(SDL_Window* m_sdlWnd)
126126
}
127127
else
128128
Log("Couldn't get window information: ", SDL_GetError());
129+
129130
sd.Windowed = bWindowed;
130131

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

139140
UINT createDeviceFlags = 0;
140141
#ifdef DEBUG
141-
// createDeviceFlags |= D3Dxx_CREATE_DEVICE_DEBUG;
142+
// createDeviceFlags |= D3Dxx_CREATE_DEVICE_DEBUG;
142143
#endif
143144
HRESULT R;
144145
#ifdef USE_DX11

src/xrEngine/device.cpp

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ void CRenderDevice::on_idle()
230230
}
231231

232232
if (psDeviceFlags.test(rsStatistic))
233-
g_bEnableStatGather = TRUE; // XXX: why not use either rsStatistic or g_bEnableStatGather?
233+
g_bEnableStatGather = true; // XXX: why not use either rsStatistic or g_bEnableStatGather?
234234
else
235-
g_bEnableStatGather = FALSE;
235+
g_bEnableStatGather = false;
236236

237237
if (g_loading_events.size())
238238
{
@@ -505,17 +505,19 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason)
505505
if (bOn)
506506
{
507507
if (!Paused())
508-
bShowPauseString = editor() ? FALSE :
508+
{
509+
bShowPauseString = editor() ? FALSE : TRUE;
509510
#ifdef DEBUG
510-
!xr_strcmp(reason, "li_pause_key_no_clip") ? FALSE :
511-
#endif // DEBUG
512-
TRUE;
511+
if (xr_strcmp(reason, "li_pause_key_no_clip") == 0)
512+
bShowPauseString = FALSE;
513+
#endif
514+
}
513515
if (bTimer && (!g_pGamePersistent || g_pGamePersistent->CanBePaused()))
514516
{
515-
g_pauseMngr().Pause(TRUE);
517+
g_pauseMngr().Pause(true);
516518
#ifdef DEBUG
517-
if (!xr_strcmp(reason, "li_pause_key_no_clip"))
518-
TimerGlobal.Pause(FALSE);
519+
if (xr_strcmp(reason, "li_pause_key_no_clip") == 0)
520+
TimerGlobal.Pause(false);
519521
#endif
520522
}
521523
if (bSound && GEnv.Sound)
@@ -526,7 +528,7 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason)
526528
if (bTimer && g_pauseMngr().Paused())
527529
{
528530
fTimeDelta = EPS_S + EPS_S;
529-
g_pauseMngr().Pause(FALSE);
531+
g_pauseMngr().Pause(false);
530532
}
531533
if (bSound)
532534
{
@@ -545,7 +547,10 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason)
545547
BOOL CRenderDevice::Paused() { return g_pauseMngr().Paused(); }
546548
void CRenderDevice::OnWM_Activate(WPARAM wParam, LPARAM /*lParam*/)
547549
{
548-
const BOOL isWndActive = (1 == wParam) ? TRUE : FALSE;
550+
u16 fActive = LOWORD(wParam);
551+
const BOOL fMinimized = (BOOL)HIWORD(wParam);
552+
553+
const BOOL isWndActive = (fActive != WA_INACTIVE && !fMinimized) ? TRUE : FALSE;
549554

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

592-
SCRIPT_EXPORT(Device, (), {
597+
SCRIPT_EXPORT(Device, (),
598+
{
593599
using namespace luabind;
594-
module(luaState)[def("time_global", &script_time_global), def("time_global_async", &script_time_global_async),
595-
def("device", &get_device), def("is_enough_address_space_available", &is_enough_address_space_available)];
600+
module(luaState)
601+
[
602+
def("time_global", &script_time_global),
603+
def("time_global_async", &script_time_global_async),
604+
def("device", &get_device),
605+
def("is_enough_address_space_available", &is_enough_address_space_available)
606+
];
596607
});
597608

598609
CLoadScreenRenderer::CLoadScreenRenderer() : b_registered(false), b_need_user_input(false) {}

src/xrEngine/line_edit_control.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ void line_edit_control::update_key_states()
125125
{
126126
m_key_state.zero();
127127

128-
set_key_state(ks_LShift, !!pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT));
129-
set_key_state(ks_RShift, !!pInput->iGetAsyncKeyState(SDL_SCANCODE_RSHIFT));
130-
set_key_state(ks_LCtrl, !!pInput->iGetAsyncKeyState(SDL_SCANCODE_LCTRL));
131-
set_key_state(ks_RCtrl, !!pInput->iGetAsyncKeyState(SDL_SCANCODE_RCTRL));
132-
set_key_state(ks_LAlt, !!pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT));
133-
set_key_state(ks_RAlt, !!pInput->iGetAsyncKeyState(SDL_SCANCODE_RALT));
134-
set_key_state(ks_CapsLock, text_editor::get_caps_lock_state());
128+
set_key_state(ks_LShift, pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT));
129+
set_key_state(ks_RShift, pInput->iGetAsyncKeyState(SDL_SCANCODE_RSHIFT));
130+
set_key_state(ks_LCtrl, pInput->iGetAsyncKeyState(SDL_SCANCODE_LCTRL));
131+
set_key_state(ks_RCtrl, pInput->iGetAsyncKeyState(SDL_SCANCODE_RCTRL));
132+
set_key_state(ks_LAlt, pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT));
133+
set_key_state(ks_RAlt, pInput->iGetAsyncKeyState(SDL_SCANCODE_RALT));
134+
set_key_state(ks_CapsLock, SDL_GetModState() & KMOD_CAPS);
135135
}
136136

137137
void line_edit_control::clear_states()
@@ -489,7 +489,7 @@ void line_edit_control::on_frame()
489489
{
490490
update_key_states();
491491

492-
u32 fr_time = Device.dwTimeContinual;
492+
const auto fr_time = Device.dwTimeContinual;
493493
float dt = (fr_time - m_last_frame_time) * 0.001f;
494494
if (dt > 0.06666f)
495495
{
@@ -774,7 +774,6 @@ void remove_spaces(pstr str)
774774
--i;
775775

776776
if (i < str_size)
777-
778777
strncpy_s(str, str_size, new_str, i);
779778
}
780779

src/xrEngine/line_editor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace text_editor
1313
line_editor::line_editor(u32 str_buffer_size) : m_control(str_buffer_size) {}
1414
line_editor::~line_editor() {}
1515
void line_editor::on_frame() { m_control.on_frame(); }
16-
void line_editor::IR_OnKeyboardPress(int dik) {m_control.on_key_press(dik); }
17-
void line_editor::IR_OnKeyboardHold(int dik) {m_control.on_key_hold(dik); }
18-
void line_editor::IR_OnKeyboardRelease(int dik) {m_control.on_key_release(dik); }
16+
void line_editor::IR_OnKeyboardPress(int dik) { m_control.on_key_press(dik); }
17+
void line_editor::IR_OnKeyboardHold(int dik) { m_control.on_key_hold(dik); }
18+
void line_editor::IR_OnKeyboardRelease(int dik) { m_control.on_key_release(dik); }
1919
} // namespace text_editor

src/xrEngine/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "Text_Console.h"
2323
#elif defined(LINUX)
2424
#define CTextConsole CConsole
25+
#pragma todo("Implement text console or it's alternative")
2526
#endif
2627
#include "xrSASH.h"
2728
#include "xr_ioc_cmd.h"

src/xrGame/ActorInput.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ void CActor::OnNextWeaponSlot()
534534
IR_OnKeyboardPress(kARTEFACT);
535535
}
536536
else
537-
IR_OnKeyboardPress((EGameActions) (kWPN_1 + i));
537+
IR_OnKeyboardPress(kWPN_1 + i);
538538
return;
539539
}
540540
}
@@ -570,7 +570,7 @@ void CActor::OnPrevWeaponSlot()
570570
IR_OnKeyboardPress(kARTEFACT);
571571
}
572572
else
573-
IR_OnKeyboardPress((EGameActions) (kWPN_1 + i));
573+
IR_OnKeyboardPress(kWPN_1 + i);
574574
return;
575575
}
576576
}
@@ -661,7 +661,7 @@ void CActor::NoClipFly(int cmd)
661661
float scale = 1.0f;
662662
if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT))
663663
scale = 0.25f;
664-
else if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LGUI))
664+
else if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT))
665665
scale = 4.0f;
666666

667667
switch (cmd)

src/xrGame/MainMenu.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ void CMainMenu::IR_OnKeyboardPress(int dik)
348348
return;
349349
}
350350

351-
if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT) || pInput->iGetAsyncKeyState(SDL_SCANCODE_RALT)
352-
&& pInput->iGetAsyncKeyState(SDL_SCANCODE_LGUI) || pInput->iGetAsyncKeyState(SDL_SCANCODE_RGUI))
351+
if ((pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT) || pInput->iGetAsyncKeyState(SDL_SCANCODE_RALT))
352+
&& (pInput->iGetAsyncKeyState(SDL_SCANCODE_LGUI) || pInput->iGetAsyncKeyState(SDL_SCANCODE_RGUI)))
353353
{
354354
IWantMyMouseBackScreamed = true;
355355
pInput->ClipCursor(false);

src/xrGame/attachable_item.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void attach_adjust_mode_keyb(int dik)
137137
return;
138138

139139
bool b_move = !!(pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT));
140-
bool b_rot = !!(pInput->iGetAsyncKeyState(SDL_SCANCODE_LGUI));
140+
bool b_rot = !!(pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT));
141141

142142
int axis = -1;
143143
if (pInput->iGetAsyncKeyState(SDL_SCANCODE_Z))

src/xrGame/ui/UIXmlInit.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ bool CUIXmlInit::InitText(CUIXml& xml_doc, LPCSTR path, int index, CUILines* pLi
345345
return true;
346346
}
347347
////////////////////////////////////////////////////////////////////////////////////////////
348-
extern int keyname_to_dik(LPCSTR);
349348

350349
bool CUIXmlInit::Init3tButton(CUIXml& xml_doc, LPCSTR path, int index, CUI3tButton* pWnd)
351350
{
@@ -397,13 +396,13 @@ bool CUIXmlInit::Init3tButton(CUIXml& xml_doc, LPCSTR path, int index, CUI3tButt
397396
LPCSTR accel = xml_doc.ReadAttrib(path, index, "accel", NULL);
398397
if (accel)
399398
{
400-
int acc = (int) keyname_to_dik(accel);
399+
int acc = keyname_to_dik(accel);
401400
pWnd->SetAccelerator(acc, 0);
402401
}
403402
accel = xml_doc.ReadAttrib(path, index, "accel_ext", NULL);
404403
if (accel)
405404
{
406-
int acc = (int) keyname_to_dik(accel);
405+
int acc = keyname_to_dik(accel);
407406
pWnd->SetAccelerator(acc, 1);
408407
}
409408

0 commit comments

Comments
 (0)