mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Added missing #includes Added LUA scripting and console Changed the way tracers are visualized, so they work more like real tracers instead of a light fountain Fixed signedness of many grid variables used in GetMouseMapPos calls Fixed enemy weapon choosing: Sometimes a mortar is chosen but later rejected, but the grenade class was not reset. Caused assertion failure Added checks so enemies don't try to chuck RPG grenades with their hands Now possible to shoot a someone in the head if he's in water Fixed InitSightArrays to also clear soldier interrupt duel points. This was causing an assertion failure elsewhere in the code because the interrupt list still had soldiers on it sometimes when this function was called. Soldiers are much less willing to forfeit their turn over an attempt to use more APs than they have Removed early setting of muzzle flash. This would allow enemies to get an interrupt before you even fired. Fixed item dropping by AI. If AI tried to drop something while standing it would cause deadlock Change to greatly speed up closing the sector inventory window in an unloaded sector Added conditional compile flag to always give robot weapon ready advantage, even for 360 degree sighting Check builddefines.h for the conditional flags. Of greatest interest might be LUA_CONSOLE. This will cause the game to bring up a command console when run. However this console is severely lacking in many areas. If anybody knows of an open-source terminal/console that could be used instead, it would be appreciated. The existing console does bad things when you try to close it, and since it counts as a separate app, it pauses the game while it has focus. LUA scripting is very limited, basically just proof of concept. There is one global variable, the Soldiers array. An array index gives you the soldier in that slot in the currently loaded sector. The soldier has a few things that can be accessed: name (short name); fullname (long name); grid (current grid #, can be changed); walkto(grid) (function to walk to another grid); runto(grid) (function to run to another grid) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@924 3b4a5df2-a311-0410-b5c6-a8a6f20db521
127 lines
2.7 KiB
C++
127 lines
2.7 KiB
C++
#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
|
|
|
|
|
|
|