Added window around windowed JA2

Replaced Windows console with freeware console implementation.  Activate in windowed mode with \
Added error and quit if JA2 started in window mode in >16bpp color depth
Fix to enemy sector investigation:  Was deducting from redshirts when elites investigated
Fix AWOL militia (need additional fix to prevent them from being redistributed during after reinforcements)
Fix to tanks to add them in their original spot when a new one cannot be found.  Should modify to remove old wreckage in this case.
AI no longer tries to fire mortar when no room for it
Tanks no longer try to throw knives


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1030 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Overhaul
2007-07-08 07:02:56 +00:00
parent 45b0868ace
commit d8145755c3
60 changed files with 9433 additions and 349 deletions
+46 -17
View File
@@ -67,8 +67,8 @@ UINT32 guiRightButtonRepeatTimer;
BOOLEAN gfTrackMousePos; // TRUE = queue mouse movement events, FALSE = don't
BOOLEAN gfLeftButtonState; // TRUE = Pressed, FALSE = Not Pressed
BOOLEAN gfRightButtonState; // TRUE = Pressed, FALSE = Not Pressed
UINT16 gusMouseXPos; // X position of the mouse on screen
UINT16 gusMouseYPos; // y position of the mouse on screen
INT16 gusMouseXPos; // X position of the mouse on screen
INT16 gusMouseYPos; // y position of the mouse on screen
// The queue structures are used to track input events using queued events
@@ -120,7 +120,7 @@ LRESULT CALLBACK KeyboardHandler(int Code, WPARAM wParam, LPARAM lParam)
else
{ // Key was up
KeyDown(wParam, lParam);
gfSGPInputReceived = TRUE;
gfSGPInputReceived = TRUE;
}
return TRUE;
@@ -131,6 +131,7 @@ LRESULT CALLBACK KeyboardHandler(int Code, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK MouseHandler(int Code, WPARAM wParam, LPARAM lParam)
{
UINT32 uiParam;
POINT mpos;
#ifndef JA2
if((Code < 0) || (!gfApplicationActive))
@@ -145,8 +146,10 @@ LRESULT CALLBACK MouseHandler(int Code, WPARAM wParam, LPARAM lParam)
{
case WM_LBUTTONDOWN
: // Update the current mouse position
gusMouseXPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).x;
gusMouseYPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).y;
mpos = ((MOUSEHOOKSTRUCT *)lParam)->pt;
ScreenToClient( ghWindow, &mpos);
gusMouseXPos = (INT16)mpos.x;
gusMouseYPos = (INT16)mpos.y;
uiParam = gusMouseYPos;
uiParam = uiParam << 16;
uiParam = uiParam | gusMouseXPos;
@@ -159,8 +162,10 @@ LRESULT CALLBACK MouseHandler(int Code, WPARAM wParam, LPARAM lParam)
break;
case WM_LBUTTONUP
: // Update the current mouse position
gusMouseXPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).x;
gusMouseYPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).y;
mpos = ((MOUSEHOOKSTRUCT *)lParam)->pt;
ScreenToClient( ghWindow, &mpos);
gusMouseXPos = (INT16)mpos.x;
gusMouseYPos = (INT16)mpos.y;
uiParam = gusMouseYPos;
uiParam = uiParam << 16;
uiParam = uiParam | gusMouseXPos;
@@ -173,8 +178,10 @@ LRESULT CALLBACK MouseHandler(int Code, WPARAM wParam, LPARAM lParam)
break;
case WM_RBUTTONDOWN
: // Update the current mouse position
gusMouseXPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).x;
gusMouseYPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).y;
mpos = ((MOUSEHOOKSTRUCT *)lParam)->pt;
ScreenToClient( ghWindow, &mpos);
gusMouseXPos = (INT16)mpos.x;
gusMouseYPos = (INT16)mpos.y;
uiParam = gusMouseYPos;
uiParam = uiParam << 16;
uiParam = uiParam | gusMouseXPos;
@@ -187,8 +194,10 @@ LRESULT CALLBACK MouseHandler(int Code, WPARAM wParam, LPARAM lParam)
break;
case WM_RBUTTONUP
: // Update the current mouse position
gusMouseXPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).x;
gusMouseYPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).y;
mpos = ((MOUSEHOOKSTRUCT *)lParam)->pt;
ScreenToClient( ghWindow, &mpos);
gusMouseXPos = (INT16)mpos.x;
gusMouseYPos = (INT16)mpos.y;
uiParam = gusMouseYPos;
uiParam = uiParam << 16;
uiParam = uiParam | gusMouseXPos;
@@ -201,8 +210,10 @@ LRESULT CALLBACK MouseHandler(int Code, WPARAM wParam, LPARAM lParam)
break;
case WM_MOUSEMOVE
: // Update the current mouse position
gusMouseXPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).x;
gusMouseYPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).y;
mpos = ((MOUSEHOOKSTRUCT *)lParam)->pt;
ScreenToClient( ghWindow, &mpos);
gusMouseXPos = (INT16)mpos.x;
gusMouseYPos = (INT16)mpos.y;
uiParam = gusMouseYPos;
uiParam = uiParam << 16;
uiParam = uiParam | gusMouseXPos;
@@ -214,7 +225,16 @@ LRESULT CALLBACK MouseHandler(int Code, WPARAM wParam, LPARAM lParam)
//Set that we have input
gfSGPInputReceived = TRUE;
break;
default:
return CallNextHookEx(ghMouseHook, Code, wParam, lParam);
}
// if (gusMouseXPos < 0 || gusMouseXPos >= SCREEN_WIDTH ||
// gusMouseYPos < 0 || gusMouseYPos >= SCREEN_HEIGHT)
{
return CallNextHookEx(ghMouseHook, Code, wParam, lParam);
}
return TRUE;
}
@@ -346,8 +366,8 @@ BOOLEAN InitializeInputManager(void)
gfCurrentStringInputState = FALSE;
gpCurrentStringDescriptor = NULL;
// Activate the hook functions for both keyboard and Mouse
ghKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) KeyboardHandler, (HINSTANCE) 0, GetCurrentThreadId());
DbgMessage(TOPIC_INPUT, DBG_LEVEL_2, String("Set keyboard hook returned %d", ghKeyboardHook));
// ghKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) KeyboardHandler, (HINSTANCE) 0, GetCurrentThreadId());
// DbgMessage(TOPIC_INPUT, DBG_LEVEL_2, String("Set keyboard hook returned %d", ghKeyboardHook));
ghMouseHook = SetWindowsHookEx(WH_MOUSE, (HOOKPROC) MouseHandler, (HINSTANCE) 0, GetCurrentThreadId());
DbgMessage(TOPIC_INPUT, DBG_LEVEL_2, String("Set mouse hook returned %d", ghMouseHook));
@@ -358,7 +378,7 @@ void ShutdownInputManager(void)
{ // There's very little to do when shutting down the input manager. In the future, this is where the keyboard and
// mouse hooks will be destroyed
UnRegisterDebugTopic(TOPIC_INPUT, "Input Manager");
UnhookWindowsHookEx(ghKeyboardHook);
// UnhookWindowsHookEx(ghKeyboardHook);
UnhookWindowsHookEx(ghMouseHook);
}
@@ -913,6 +933,8 @@ void KeyChange(UINT32 usParam, UINT32 uiParam, UINT8 ufKeyState)
}
GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
uiTmpLParam = ((MousePos.y << 16) & 0xffff0000) | (MousePos.x & 0x0000ffff);
if (ufKeyState == TRUE)
@@ -1064,6 +1086,7 @@ void GetMousePos(SGPPoint *Point)
POINT MousePos;
GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
Point->iX = (UINT32) MousePos.x;
Point->iY = (UINT32) MousePos.y;
@@ -1517,7 +1540,9 @@ void RestrictMouseCursor(SGPRect *pRectangle)
{
// Make a copy of our rect....
memcpy( &gCursorClipRect, pRectangle, sizeof( gCursorClipRect ) );
ClipCursor((RECT *)pRectangle);
ClientToScreen( ghWindow, (LPPOINT)&gCursorClipRect);
ClientToScreen( ghWindow, ((LPPOINT)&gCursorClipRect)+1);
ClipCursor(&gCursorClipRect);
fCursorWasClipped = TRUE;
}
@@ -1538,6 +1563,8 @@ void RestoreCursorClipRect( void )
void GetRestrictedClipCursor( SGPRect *pRectangle )
{
GetClipCursor((RECT *) pRectangle );
ScreenToClient( ghWindow, (LPPOINT)pRectangle);
ScreenToClient( ghWindow, ((LPPOINT)pRectangle)+1);
}
BOOLEAN IsCursorRestricted( void )
@@ -1613,6 +1640,7 @@ void HandleSingleClicksAndButtonRepeats( void )
POINT MousePos;
GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
uiTmpLParam = ((MousePos.y << 16) & 0xffff0000) | (MousePos.x & 0x0000ffff);
QueueEvent(LEFT_BUTTON_REPEAT, 0, uiTmpLParam);
guiLeftButtonRepeatTimer = uiTimer + BUTTON_REPEAT_TIME;
@@ -1633,6 +1661,7 @@ void HandleSingleClicksAndButtonRepeats( void )
POINT MousePos;
GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
uiTmpLParam = ((MousePos.y << 16) & 0xffff0000) | (MousePos.x & 0x0000ffff);
QueueEvent(RIGHT_BUTTON_REPEAT, 0, uiTmpLParam);
guiRightButtonRepeatTimer = uiTimer + BUTTON_REPEAT_TIME;