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
-126
View File
@@ -1,126 +0,0 @@
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <iostream>
#include <fstream>
#include <conio.h>
#include "Console.h"
#include "Lua Interpreter.h"
#ifndef _USE_OLD_IOSTREAMS
using namespace std;
#endif
extern HWND ghWindow;
// maximum mumber of lines the output console should have
static const WORD MAX_CONSOLE_LINES = 500;
BOOL WINAPI ControlHandlerRoutine(
DWORD dwCtrlType
)
{
switch (dwCtrlType)
{
case CTRL_CLOSE_EVENT:
// Tell the main window that the console wants out
PostMessage( ghWindow, WM_USER, 0, 0 );
case CTRL_C_EVENT:
case CTRL_BREAK_EVENT:
case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT:
// Ignore all of these signals. The game itself will handle the important stuff anyway.
return TRUE;
}
return FALSE;
}
void CreateConsole()
{
int hConHandle;
long lStdHandle;
CONSOLE_SCREEN_BUFFER_INFO coninfo;
FILE *fp;
// HWND hConWindow;
// allocate a console for this app
AllocConsole();
// Eliminate the game-killing control signals
SetConsoleCtrlHandler( ControlHandlerRoutine, TRUE );
// set the screen buffer to be big enough to let us scroll text
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),
&coninfo);
coninfo.dwSize.Y = MAX_CONSOLE_LINES;
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE),
coninfo.dwSize);
// redirect unbuffered STDOUT to the console
lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
fp = _fdopen( hConHandle, "w" );
*stdout = *fp;
setvbuf( stdout, NULL, _IONBF, 0 );
// redirect unbuffered STDIN to the console
lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
fp = _fdopen( hConHandle, "r" );
*stdin = *fp;
setvbuf( stdin, NULL, _IONBF, 0 );
// redirect unbuffered STDERR to the console
lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
fp = _fdopen( hConHandle, "w" );
*stderr = *fp;
setvbuf( stderr, NULL, _IONBF, 0 );
// make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog
// point to console as well
ios::sync_with_stdio();
// Print the warning message
printf( "Do not close this window!\n");
printf( "> " );
}
void PollConsole ()
{
static int buf_idx = 0;
static char buf[16384];
if (_kbhit() )
{
buf[ buf_idx++ ] = _getche();
if (buf[ buf_idx-1] == 8) {
_putch( ' ');
buf_idx--;
if (buf_idx > 0)
{
_putch( 8 );
buf_idx--;
}
}
}
if (buf[ buf_idx-1] == '\r')
{
buf[ buf_idx-1] = 0;
printf( "\n");
EvalLua( buf);
printf( "\n> ");
buf_idx = 0;
}
}
//End of File
-9
View File
@@ -1,9 +0,0 @@
#ifndef __CONSOLE_H__
#define __CONSOLE_H__
void CreateConsole();
void PollConsole();
#endif
/* End of File */
+1 -9
View File
@@ -20,7 +20,7 @@
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="4"
InheritedPropertySheets="..\ja2_2005Express.vsprops"
InheritedPropertySheets="..\ja2_2005Express.vsprops;..\ja2_2005ExpressDebug.vsprops"
>
<Tool
Name="VCPreBuildEventTool"
@@ -145,10 +145,6 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\Console.h"
>
</File>
<File
RelativePath=".\lauxlib.h"
>
@@ -183,10 +179,6 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\Console.cpp"
>
</File>
<File
RelativePath=".\lua.cpp"
>