mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +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
185 lines
6.6 KiB
C++
185 lines
6.6 KiB
C++
//**************************************************************************
|
|
//
|
|
// Filename : debug.h
|
|
//
|
|
// Purpose : prototypes for the debug manager
|
|
//
|
|
// Modification history :
|
|
//
|
|
// xxxxx96:LH - Creation
|
|
// xxnov96:HJH - made it work
|
|
//
|
|
//**************************************************************************
|
|
|
|
#ifndef __DEBUG_MANAGER_
|
|
#define __DEBUG_MANAGER_
|
|
|
|
#include <crtdbg.h>
|
|
|
|
#include "types.h"
|
|
#include "TopicOps.h"
|
|
#include "TopicIDs.h"
|
|
|
|
/*
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
*/
|
|
|
|
#define INVALID_TOPIC 0xffff
|
|
#define MAX_TOPICS_ALLOTED 1024
|
|
|
|
|
|
extern BOOLEAN gfRecordToFile;
|
|
extern BOOLEAN gfRecordToDebugger;
|
|
extern UINT32 guiProfileStart, guiExecutions, guiProfileTime;
|
|
extern INT32 giProfileCount;
|
|
|
|
#define PROFILE(x) guiProfileStart=GetTickCount(); \
|
|
guiExecutions=x; \
|
|
for(giProfileCount=0; giProfileCount < x; giProfileCount++)
|
|
|
|
#define PROFILE_REPORT() guiProfileTime=(GetTickCount()-guiProfileStart); \
|
|
_RPT3(_CRT_WARN, "*** PROFILE REPORT: %d executions took %dms, average of %.2fms per iteration.\n", guiExecutions, guiProfileTime, (FLOAT)guiProfileTime/guiExecutions);
|
|
|
|
extern void _Null(void);
|
|
extern STR8 String(const STR8 String, ...);
|
|
|
|
|
|
|
|
#if defined ( _DEBUG ) || defined ( FORCE_ASSERTS_ON )
|
|
|
|
// If DEBUG_ is defined, we need to initialize all the debug macros. Otherwise all the
|
|
// debug macros will be substituted by blank lines at compile time
|
|
//*******************************************************************************************
|
|
// Debug Mode
|
|
//*******************************************************************************************
|
|
|
|
//Modified the Assertion code. As of the writing of this code, there are no other functions that
|
|
//make use of _FailMessage. With that assumption made, we can then make two functions, the first Assert, taking
|
|
//one argument, and passing a NULL string. The second one, AssertMsg(), accepts a string as the second parameter.
|
|
//This string that has vanished for Assert is now built inside of fail message. This is the case for both Asserts, but the second one
|
|
//also is added. Ex:
|
|
//Assert( pointer );
|
|
//Assert( pointer, "This pointer is null and you tried to access it in function A ");
|
|
//It'll make debugging a little simpler. In anal cases, you could build the string first, then assert
|
|
//with it.
|
|
extern void _FailMessage(STR8 pString, UINT32 uiLineNum, STR8 pSourceFile );
|
|
|
|
#define Assert(a) (a) ? _Null() : _FailMessage( NULL, __LINE__, __FILE__ )
|
|
#define AssertMsg(a,b) (a) ? _Null() : _FailMessage( b, __LINE__, __FILE__ )
|
|
|
|
extern CHAR8 gubAssertString[128];
|
|
|
|
|
|
#else
|
|
|
|
#define Assert(a) ((void *)0)
|
|
#define AssertMsg(a,b) ((void *)0)
|
|
|
|
//*******************************************************************************************
|
|
#endif
|
|
|
|
|
|
// Kaiden: Added this for Map Editor
|
|
#ifdef JA2BETAVERSION
|
|
extern CHAR8 gubAssertString[128];
|
|
#endif
|
|
|
|
// Moved these out of the defines - debug mgr always initialized
|
|
#define InitializeDebugManager() DbgInitialize()
|
|
#define ShutdownDebugManager() DbgShutdown()
|
|
|
|
extern BOOLEAN DbgInitialize(void);
|
|
extern void DbgShutdown(void);
|
|
|
|
|
|
#ifdef SGP_DEBUG
|
|
// If DEBUG_ is defined, we need to initialize all the debug macros. Otherwise all the
|
|
// debug macros will be substituted by blank lines at compile time
|
|
//*******************************************************************************************
|
|
// Debug Mode
|
|
//*******************************************************************************************
|
|
|
|
extern BOOLEAN gfDebugTopics[MAX_TOPICS_ALLOTED];
|
|
// These are the debug macros (the ones the use will use). The user should never call
|
|
// the actual debug functions directly
|
|
|
|
// Force a breakpoint in the debugger
|
|
#define DebugBreakpoint() __asm { int 3 }
|
|
|
|
|
|
#define DbgMessage(a, b, c) DbgMessageReal( (UINT16)(a), (UINT8)(TOPIC_MESSAGE), (UINT8)(b), (CHAR8 *)(c) )
|
|
#define FastDebugMsg(a) _DebugMessage( (UINT8 *)(a), (UINT32)(__LINE__), (UINT8 *)(__FILE__) )
|
|
|
|
#define UnRegisterDebugTopic(a, b) DbgTopicRegistration( (UINT8)TOPIC_UNREGISTER, (UINT16 *)(&(a)), (CHAR8 *)(b) )
|
|
#define ClearAllDebugTopics( ) DbgClearAllTopics( )
|
|
|
|
#define ErrorMsg(a) _DebugMessage( (UINT8 *)(a), (UINT32)(__LINE__), (UINT8 *)(__FILE__))
|
|
|
|
// Enable the debug topic we want
|
|
#if defined( JA2 ) || defined( UTIL )
|
|
#define RegisterJA2DebugTopic(a, b) DbgTopicRegistration( TOPIC_REGISTER, &(a), (b) )
|
|
#define RegisterDebugTopic(a, b) ((void *)0)
|
|
#define DebugMsg(a, b, c) DbgMessageReal( (a), TOPIC_MESSAGE, (b), (c) )
|
|
#else
|
|
#define RegisterJA2DebugTopic(a, b) ((void *)0)
|
|
#define RegisterDebugTopic(a, b) DbgTopicRegistration( (UINT8)TOPIC_REGISTER, (UINT16 *)(&(a)), (CHAR8 *)(b) )
|
|
#define DebugMsg(a) _DebugMessage((UINT8 *)(a), (UINT32)(__LINE__), (UINT8 *)(__FILE__))
|
|
#endif
|
|
|
|
// public interface to debug methods:
|
|
extern void DbgMessageReal(UINT16 uiTopicId, UINT8 uiCommand, UINT8 uiDebugLevel, STR8 strMessage);
|
|
|
|
extern BOOLEAN DbgSetDebugLevel(UINT16 TopicId, UINT8 uiDebugLevel);
|
|
extern void DbgFailedAssertion( BOOLEAN fExpression, STR8 szFile, int nLine );
|
|
#if _MSC_VER <= 1200
|
|
extern void _FailMessage(UINT8 *pString, UINT32 uiLineNum, UINT8 *pSourceFile );
|
|
#endif
|
|
extern void DbgTopicRegistration( UINT8 ubCmd, UINT16 *usTopicID, CHAR8 *zMessage );
|
|
extern void DbgClearAllTopics( void );
|
|
extern void _DebugMessage(UINT8 *pSourceFile, UINT32 uiLineNum, UINT8 *pString);
|
|
|
|
//*******************************************************************************************
|
|
|
|
#else
|
|
|
|
//*******************************************************************************************
|
|
// Release Mode
|
|
//*******************************************************************************************
|
|
#define DebugBreakpoint() ((void *)0)
|
|
|
|
#define RegisterDebugTopic(a, b) ((void *)0)
|
|
#define UnRegisterDebugTopic(a, b) ((void *)0)
|
|
#define ClearAllDebugTopics( ) ((void *)0)
|
|
|
|
#define FastDebugMsg(a) ((void *)0)
|
|
#define ErrorMsg(a) ((void *)0)
|
|
|
|
#define DbgTopicRegistration(a, b, c); ((void *)0)
|
|
#define DbgMessage(a, b, c) ((void *)0)
|
|
|
|
#if defined( JA2 ) || defined( UTIL )
|
|
#define RegisterJA2DebugTopic(a, b) ((void *)0)
|
|
#define DebugMsg(a, b, c) ((void *)0)
|
|
#else
|
|
#define DebugMsg(a) ((void *)0)
|
|
#endif
|
|
|
|
//*******************************************************************************************
|
|
#endif
|
|
|
|
|
|
#ifdef DEBUG_ATTACKBUSY
|
|
#define DebugAttackBusy(x) OutputDebugString( x)
|
|
#else
|
|
#define DebugAttackBusy(x)
|
|
#endif
|
|
|
|
/*
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
*/
|
|
|
|
#endif |