Merge branch 'master' into decideaction

This commit is contained in:
Asdow
2023-10-10 23:21:12 +03:00
89 changed files with 1240 additions and 3432 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ set(usingMsBuild $<STREQUAL:${CMAKE_VS_PLATFORM_NAME},Win32>)
# TODO: build our own Lua 5.1.2 from source so we can use whichever
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
add_compile_definitions(CINTERFACE XML_STATIC VFS_STATIC VFS_WITH_SLF VFS_WITH_7ZIP USE_VFS _CRT_SECURE_NO_DEPRECATE)
add_compile_definitions(CINTERFACE XML_STATIC VFS_STATIC VFS_WITH_SLF VFS_WITH_7ZIP _CRT_SECURE_NO_DEPRECATE)
include_directories(${CMAKE_SOURCE_DIR} "ext/VFS/include" Utils TileEngine TacticalAI ModularizedTacticalAI Tactical Strategic "Standard Gaming Platform" Res Lua Laptop Multiplayer "Multiplayer/raknet" Editor Console)
# external libraries
+2 -41
View File
@@ -83,9 +83,7 @@ INT32 iCurrFileShown;
INT32 iLastFileClicked;
INT32 iLastClickTime;
#ifdef USE_VFS
CHAR8 gzProfileName[FILENAME_BUFLEN];//dnl ch81 021213
#endif
CHAR16 gzFilename[FILENAME_BUFLEN];//dnl ch39 190909
extern INT16 gsSelSectorX;
extern INT16 gsSelSectorY;
@@ -165,7 +163,6 @@ void LoadSaveScreenEntry()
}
iTopFileShown = iTotalFiles = 0;
#ifdef USE_VFS//dnl ch37 300909
gzProfileName[0] = 0;//dnl ch81 021213
FDLG_LIST* TempFileList = NULL;
vfs::CProfileStack* st = getVFS()->getProfileStack();
@@ -220,25 +217,6 @@ void LoadSaveScreenEntry()
}
while(FileList->pPrev)
FileList = FileList->pPrev;
#else
if(GetFileFirst("MAPS\\*.dat", &FileInfo))
{
if(strlen(FileInfo.zFileName) < FILENAME_BUFLEN)
{
FileList = AddToFDlgList(FileList, &FileInfo);
iTotalFiles++;
}
while(GetFileNext(&FileInfo))
{
if(strlen(FileInfo.zFileName) < FILENAME_BUFLEN)
{
FileList = AddToFDlgList(FileList, &FileInfo);
iTotalFiles++;
}
}
GetFileClose(&FileInfo);
}
#endif
swprintf( zOrigName, L"%s Map (*.dat)", iCurrentAction == ACTION_SAVE_MAP ? L"Save" : L"Load" );
swprintf( gzFilename, L"%S", gubFilename );
@@ -283,7 +261,8 @@ UINT32 ProcessLoadSaveScreenMessageBoxResult()
{
if( gfReadOnly )
{
FileClearAttributes( gszCurrFilename );
// Other call sites have replaced this with FileDelete(); for VFS, should we do the same here?
//FileClearAttributes( gszCurrFilename );
gfReadOnly = FALSE;
}
FileDelete( gszCurrFilename );
@@ -468,19 +447,6 @@ UINT32 LoadSaveScreenHandle(void)
}
sprintf(gszCurrFilename, "MAPS\\%S", gzFilename);
gfFileExists = FALSE;
#ifndef USE_VFS
gfReadOnly = FALSE;
if(FileExists(gszCurrFilename))
{
gfFileExists = TRUE;
if(GetFileFirst(gszCurrFilename, &FileInfo))
{
if(FileInfo.uiFileAttribs & (FILE_IS_READONLY|FILE_IS_DIRECTORY|FILE_IS_HIDDEN|FILE_IS_SYSTEM|FILE_IS_OFFLINE|FILE_IS_TEMPORARY))
gfReadOnly = TRUE;
GetFileClose(&FileInfo);
}
}
#else
gfReadOnly = TRUE;
vfs::CProfileStack* st = getVFS()->getProfileStack();
vfs::CProfileStack::Iterator it = st->begin();
@@ -502,7 +468,6 @@ UINT32 LoadSaveScreenHandle(void)
}
it.next();
}
#endif
if(gfReadOnly)
{
CreateMessageBox(L" File is read only! Choose a different name? ");
@@ -726,7 +691,6 @@ void SelectFileDialogYPos( UINT16 usRelativeYPos )
iLastClickTime = iCurrClickTime;
iLastFileClicked = x;
//dnl ch81 021213
#ifdef USE_VFS
gzProfileName[0] = 0;
while(FListNode = FListNode->pPrev)
{
@@ -737,7 +701,6 @@ void SelectFileDialogYPos( UINT16 usRelativeYPos )
break;
}
}
#endif
break;
}
FListNode = FListNode->pNext;
@@ -950,7 +913,6 @@ void HandleMainKeyEvents( InputAtom *pEvent )
SetInputFieldStringWith16BitString(0, L"");
wcscpy(gzFilename, L"");
}
#ifdef USE_VFS
gzProfileName[0] = 0;
while(curr = curr->pPrev)
{
@@ -961,7 +923,6 @@ void HandleMainKeyEvents( InputAtom *pEvent )
break;
}
}
#endif
}
}
}
-2
View File
@@ -51,9 +51,7 @@ extern CHAR16 gzErrorCatchString[ 256 ];
//dnl ch81 031213
extern CHAR16 gzFilename[FILENAME_BUFLEN];
#ifdef USE_VFS
extern CHAR8 gzProfileName[FILENAME_BUFLEN];
#endif
#endif
#endif
+2 -177
View File
@@ -1923,40 +1923,14 @@ BOOLEAN HandleSummaryInput( InputAtom *pEvent )
void CreateGlobalSummary()
{
#ifndef USE_VFS
FILE *fp;
STRING512 Dir;
STRING512 ExecDir;
#endif
OutputDebugString( "Generating GlobalSummary Information...\n" );
gfGlobalSummaryExists = FALSE;
//Set current directory to JA2\DevInfo which contains all of the summary data
#ifndef USE_VFS
GetExecutableDirectory( ExecDir );
sprintf( Dir, "%s\\DevInfo", ExecDir );
// Snap: save current directory
//GetFileManCurrentDirectory( DataDir );
//Directory doesn't exist, so create it, and continue.
if( !MakeFileManDirectory( Dir ) )
AssertMsg( 0, "Can't create new directory, JA2\\DevInfo for summary information." );
if( !SetFileManCurrentDirectory( Dir ) )
AssertMsg( 0, "Can't set to new directory, JA2\\DevInfo for summary information." );
//Generate a simple readme file.
fp = fopen( "readme.txt", "w" );
Assert( fp );
fprintf( fp, "%s\n%s\n", "This information is used in conjunction with the editor.",
"This directory or it's contents shouldn't be included with final release." );
fclose( fp );
#else
vfs::COpenWriteFile wfile(L"DevInfo\\readme.txt",true,true);
std::string str = "This information is used in conjunction with the editor.\n";
str += "This directory or it's contents shouldn't be included with final release.\n";
SGP_TRYCATCH_RETHROW( wfile->write(str.c_str(), str.length()), L"" );
#endif
// Snap: Restore the data directory once we are finished.
//SetFileManCurrentDirectory( DataDir );
@@ -2203,7 +2177,8 @@ void SummarySaveMapCallback( GUI_BUTTON *btn, INT32 reason )
{
CHAR8 filename[40];
sprintf( filename, "MAPS\\%S", gszDisplayName );
FileClearAttributes( filename );
// Other call sites have replaced this with FileDelete(); for VFS, should we do the same here?
//FileClearAttributes( filename );
}
if( ExternalSaveMap( gszDisplayName ) )
{
@@ -2281,12 +2256,6 @@ void CalculateOverrideStatus()
void LoadGlobalSummary()
{
HWFILE hfile;
#ifndef USE_VFS
STRING512 DataDir;
STRING512 ExecDir;
STRING512 DevInfoDir;
STRING512 MapsDir;
#endif
UINT32 uiNumBytesRead;
FLOAT dMajorVersion;
INT32 x,y;
@@ -2295,34 +2264,16 @@ void LoadGlobalSummary()
OutputDebugString( "Executing LoadGlobalSummary()...\n" );
// Snap: save current directory
#ifndef USE_VFS
GetFileManCurrentDirectory( DataDir );
#endif
gfMustForceUpdateAllMaps = FALSE;
gusNumberOfMapsToBeForceUpdated = 0;
gfGlobalSummaryExists = FALSE;
//Set current directory to JA2\DevInfo which contains all of the summary data
#ifndef USE_VFS
GetExecutableDirectory( ExecDir );
sprintf( DevInfoDir, "%s\\DevInfo", ExecDir );
sprintf( MapsDir, "%s\\Maps", DataDir );
//Check to make sure we have a DevInfo directory. If we don't create one!
if( !SetFileManCurrentDirectory( DevInfoDir ) )
{
OutputDebugString( "LoadGlobalSummary() aborted -- doesn't exist on this local computer.\n");
return;
}
#endif
//TEMP
#ifndef USE_VFS
FileDelete( "_global.sum" );
#else
if(FileExists("DevInfo\\_global.sum"))
{
FileDelete( "DevInfo\\_global.sum" );
}
#endif
gfGlobalSummaryExists = TRUE;
//Analyse all sectors to see if matching maps exist. For any maps found, the information
@@ -2337,19 +2288,12 @@ void LoadGlobalSummary()
sprintf( szSector, "%c%d", 'A' + y, x + 1 );
//main ground level
#ifndef USE_VFS
sprintf( szFilename, "%c%d.dat", 'A' + y, x + 1 );
SetFileManCurrentDirectory( MapsDir );
hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
SetFileManCurrentDirectory( DevInfoDir );
#else
sprintf( szFilename, "Maps\\%c%d.dat", 'A' + y, x + 1 );
hfile = NULL;
if(FileExists(szFilename))
{
hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
}
#endif
if( hfile )
{
gbSectorLevels[x][y] |= GROUND_LEVEL_MASK;
@@ -2359,27 +2303,16 @@ void LoadGlobalSummary()
}
else
{
#ifndef USE_VFS
sprintf( szFilename, "%s.sum", szSector );
#else
sprintf( szFilename, "DevInfo\\%s.sum", szSector );
#endif
FileDelete( szFilename );
}
//main B1 level
#ifndef USE_VFS
sprintf( szFilename, "%c%d_b1.dat", 'A' + y, x + 1 );
SetFileManCurrentDirectory( MapsDir );
hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
SetFileManCurrentDirectory( DevInfoDir );
#else
sprintf( szFilename, "Maps\\%c%d_b1.dat", 'A' + y, x + 1 );
hfile = NULL;
if(FileExists(szFilename))
{
hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
}
#endif
if( hfile )
{
gbSectorLevels[x][y] |= BASEMENT1_LEVEL_MASK;
@@ -2389,27 +2322,16 @@ void LoadGlobalSummary()
}
else
{
#ifndef USE_VFS
sprintf( szFilename, "%s_b1.sum", szSector );
#else
sprintf( szFilename, "DevInfo\\%s_b1.sum", szSector );
#endif
FileDelete( szFilename );
}
//main B2 level
#ifndef USE_VFS
sprintf( szFilename, "%c%d_b2.dat", 'A' + y, x + 1 );
SetFileManCurrentDirectory( MapsDir );
hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
SetFileManCurrentDirectory( DevInfoDir );
#else
sprintf( szFilename, "Maps\\%c%d_b2.dat", 'A' + y, x + 1 );
hfile = NULL;
if(FileExists(szFilename))
{
hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
}
#endif
if( hfile )
{
gbSectorLevels[x][y] |= BASEMENT2_LEVEL_MASK;
@@ -2419,27 +2341,16 @@ void LoadGlobalSummary()
}
else
{
#ifndef USE_VFS
sprintf( szFilename, "%s_b2.sum", szSector );
#else
sprintf( szFilename, "DevInfo\\%s_b2.sum", szSector );
#endif
FileDelete( szFilename );
}
//main B3 level
#ifndef USE_VFS
sprintf( szFilename, "%c%d_b3.dat", 'A' + y, x + 1 );
SetFileManCurrentDirectory( MapsDir );
hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
SetFileManCurrentDirectory( DevInfoDir );
#else
sprintf( szFilename, "Maps\\%c%d_b3.dat", 'A' + y, x + 1 );
hfile = NULL;
if(FileExists(szFilename))
{
hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
}
#endif
if( hfile )
{
gbSectorLevels[x][y] |= BASEMENT3_LEVEL_MASK;
@@ -2449,27 +2360,16 @@ void LoadGlobalSummary()
}
else
{
#ifndef USE_VFS
sprintf( szFilename, "%s_b3.sum", szSector );
#else
sprintf( szFilename, "DevInfo\\%s_b3.sum", szSector );
#endif
FileDelete( szFilename );
}
//alternate ground level
#ifndef USE_VFS
sprintf( szFilename, "%c%d_a.dat", 'A' + y, x + 1 );
SetFileManCurrentDirectory( MapsDir );
hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
SetFileManCurrentDirectory( DevInfoDir );
#else
sprintf( szFilename, "Maps\\%c%d_a.dat", 'A' + y, x + 1 );
hfile = NULL;
if(FileExists(szFilename))
{
hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
}
#endif
if( hfile )
{
gbSectorLevels[x][y] |= ALTERNATE_GROUND_MASK;
@@ -2479,27 +2379,16 @@ void LoadGlobalSummary()
}
else
{
#ifndef USE_VFS
sprintf( szFilename, "%s_a.sum", szSector );
#else
sprintf( szFilename, "DevInfo\\%s_a.sum", szSector );
#endif
FileDelete( szFilename );
}
//alternate B1 level
#ifndef USE_VFS
sprintf( szFilename, "%c%d_b1_a.dat", 'A' + y, x + 1 );
SetFileManCurrentDirectory( MapsDir );
hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
SetFileManCurrentDirectory( DevInfoDir );
#else
sprintf( szFilename, "Maps\\%c%d_b1_a.dat", 'A' + y, x + 1 );
hfile = NULL;
if(FileExists(szFilename))
{
hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
}
#endif
if( hfile )
{
gbSectorLevels[x][y] |= ALTERNATE_B1_MASK;
@@ -2509,27 +2398,16 @@ void LoadGlobalSummary()
}
else
{
#ifndef USE_VFS
sprintf( szFilename, "%s_b1_a.sum", szSector );
#else
sprintf( szFilename, "DevInfo\\%s_b1_a.sum", szSector );
#endif
FileDelete( szFilename );
}
//alternate B2 level
#ifndef USE_VFS
sprintf( szFilename, "%c%d_b2_a.dat", 'A' + y, x + 1 );
SetFileManCurrentDirectory( MapsDir );
hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
SetFileManCurrentDirectory( DevInfoDir );
#else
sprintf( szFilename, "Maps\\%c%d_b2_a.dat", 'A' + y, x + 1 );
hfile = NULL;
if(FileExists(szFilename))
{
hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
}
#endif
if( hfile )
{
gbSectorLevels[x][y] |= ALTERNATE_B2_MASK;
@@ -2539,27 +2417,16 @@ void LoadGlobalSummary()
}
else
{
#ifndef USE_VFS
sprintf( szFilename, "%s_b2_a.sum", szSector );
#else
sprintf( szFilename, "DevInfo\\%s_b2_a.sum", szSector );
#endif
FileDelete( szFilename );
}
//alternate B3 level
#ifndef USE_VFS
sprintf( szFilename, "%c%d_b3_a.dat", 'A' + y, x + 1 );
SetFileManCurrentDirectory( MapsDir );
hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
SetFileManCurrentDirectory( DevInfoDir );
#else
sprintf( szFilename, "Maps\\%c%d_b3_a.dat", 'A' + y, x + 1 );
hfile = NULL;
if(FileExists(szFilename))
{
hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE );
}
#endif
if( hfile )
{
gbSectorLevels[x][y] |= ALTERNATE_B1_MASK;;
@@ -2569,20 +2436,12 @@ void LoadGlobalSummary()
}
else
{
#ifndef USE_VFS
sprintf( szFilename, "%s_b3_a.sum", szSector );
#else
sprintf( szFilename, "DevInfo\\%s_b3_a.sum", szSector );
#endif
FileDelete( szFilename );
}
}
OutputDebugString( (LPCSTR)String("Sector Row %c complete... \n", y + 'A') );
}
#ifndef USE_VFS
// Snap: Restore the data directory once we are finished.
SetFileManCurrentDirectory( DataDir );
#endif
//sprintf( MapsDir, "%s\\Data", ExecDir );
//SetFileManCurrentDirectory( MapsDir );
@@ -2599,39 +2458,6 @@ void LoadGlobalSummary()
void GenerateSummaryList()
{
#ifndef USE_VFS
FILE *fp;
STRING512 DataDir;
STRING512 ExecDir;
STRING512 Dir;
// Snap: save current directory
GetFileManCurrentDirectory( DataDir );
//Set current directory to JA2\DevInfo which contains all of the summary data
GetExecutableDirectory( ExecDir );
sprintf( Dir, "%s\\DevInfo", ExecDir );
if( !SetFileManCurrentDirectory( Dir ) )
{
//Directory doesn't exist, so create it, and continue.
if( !MakeFileManDirectory( Dir ) )
AssertMsg( 0, "Can't create new directory, JA2\\DevInfo for summary information." );
if( !SetFileManCurrentDirectory( Dir ) )
AssertMsg( 0, "Can't set to new directory, JA2\\DevInfo for summary information." );
//Generate a simple readme file.
fp = fopen( "readme.txt", "w" );
Assert( fp );
fprintf( fp, "%s\n%s\n", "This information is used in conjunction with the editor.",
"This directory or it's contents shouldn't be included with final release." );
fclose( fp );
}
// Snap: Restore the data directory once we are finished.
SetFileManCurrentDirectory( DataDir );
//Set current directory back to data directory!
//sprintf( Dir, "%s\\Data", ExecDir );
//SetFileManCurrentDirectory( Dir );
#else
try
{
vfs::COpenWriteFile wfile(L"DevInfo/readme.txt",true,true);
@@ -2643,7 +2469,6 @@ void GenerateSummaryList()
{
SGP_RETHROW(L"Could not create readme.txt", ex);
}
#endif
}
//dnl ch28 260909
-8
View File
@@ -1514,12 +1514,6 @@ UINT32 InitializeJA2(void)
// INit intensity tables
BuildIntensityTable( );
// Init Event Manager
if ( !InitializeEventManager( ) )
{
return( ERROR_SCREEN );
}
// Initailize World
if ( !InitializeWorld( ) )
{
@@ -1698,8 +1692,6 @@ void ShutdownJA2(void)
ShutdownJA2Sound( );
ShutdownEventManager( );
ShutdownBaseDirtyRectQueue( );
// Unload any text box images!
-11
View File
@@ -1336,16 +1336,6 @@ void WriteOutCurrentImpCharacter( INT32 iProfileId )
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("WriteOutCurrentImpCharacter: Nickname.dat"));
#ifndef USE_VFS
char zFileName[13];
char temp;
for(int i=0;i < 9;i++) // Madd: I couldn't get strcpy or anything to work here... weird... if s/o wants to fix it, go ahead
{
temp = (char) gMercProfiles[iProfileId].zNickname[i];
zFileName[i] = temp;
}
#else
char zFileName[32];
if(vfs::Settings::getUseUnicode())
{
@@ -1355,7 +1345,6 @@ void WriteOutCurrentImpCharacter( INT32 iProfileId )
{
vfs::String::narrow(gMercProfiles[iProfileId].zNickname, 10, zFileName, 32);
}
#endif
// Changed by ADB, rev 1513
//strcat(zFileName,IMP_FILENAME_SUFFIX);
-1
View File
@@ -476,7 +476,6 @@ void GameInitFiles( )
{
if ( FileExists( FILES_DAT_FILE ) == TRUE )
{
FileClearAttributes( FILES_DAT_FILE );
FileDelete( FILES_DAT_FILE );
}
-1
View File
@@ -460,7 +460,6 @@ void GameInitFinances()
// unlink Finances data file
if( (FileExists( FINANCES_DATA_FILE ) ) )
{
FileClearAttributes( FINANCES_DATA_FILE );
FileDelete( FINANCES_DATA_FILE );
}
GetBalanceFromDisk( );
-1
View File
@@ -227,7 +227,6 @@ void GameInitHistory()
if( ( FileExists( HISTORY_DATA_FILE ) ) )
{
// unlink history file
FileClearAttributes( HISTORY_DATA_FILE );
FileDelete( HISTORY_DATA_FILE );
}
-4
View File
@@ -7136,28 +7136,24 @@ void ClearOutTempLaptopFiles( void )
// file file
if ( (FileExists( "files.dat" ) == TRUE ) )
{
FileClearAttributes( "files.dat" );
FileDelete( "files.dat" );
}
// finances
if ( (FileExists( "finances.dat" ) == TRUE ) )
{
FileClearAttributes( "finances.dat" );
FileDelete( "finances.dat" );
}
// email
if ( (FileExists( "email.dat" ) == TRUE ) )
{
FileClearAttributes( "email.dat" );
FileDelete( "email.dat" );
}
// history
if ( (FileExists( "history.dat" ) == TRUE ) )
{
FileClearAttributes( "history.dat" );
FileDelete( "history.dat" );
}
}
-2
View File
@@ -248,7 +248,6 @@ BOOLEAN InitMainMenu( )
{
is_networked = FALSE;
#ifdef USE_VFS
// remove Multiplayer profile if it exists
vfs::CProfileStack *PS = getVFS()->getProfileStack();
vfs::CVirtualProfile *pProf = PS->getProfile("_MULTIPLAYER");
@@ -256,7 +255,6 @@ BOOLEAN InitMainMenu( )
{
SGP_THROW_IFFALSE(PS->popProfile(), "Leaving Multiplayer mode : Could not remove \"_MULTIPLAYER\" profile");
}
#endif
// Snap: UN-Init MP save game directory
if ( !InitSaveDir() )
+4 -7
View File
@@ -815,10 +815,8 @@ void recievePATH(RPCParameters *rpcParameters)
SendGetNewSoldierPathEvent( pSoldier, SNetPath->sDestGridNo, SNetPath->ubNewState );
INT16 sCellX, sCellY;
sCellX = CenterX( SNetPath->sAtGridNo );
sCellY = CenterY( SNetPath->sAtGridNo );
ConvertGridNoToCenterCellXY(SNetPath->sAtGridNo, &sCellX, &sCellY);
if (( gAnimControl[ pSoldier->usAnimState ].uiFlags & ( ANIM_MOVING | ANIM_SPECIALMOVE ) ) && !(pSoldier->flags.fNoAPToFinishMove ) )
{
}
@@ -4251,8 +4249,7 @@ void UpdateSoldierFromNetwork (RPCParameters *rpcParameters)
pSoldier->stats.bLife=SUpdateNetworkSoldier->bLife;
INT16 sCellX, sCellY;
sCellX = CenterX( SUpdateNetworkSoldier->sAtGridNo );
sCellY = CenterY( SUpdateNetworkSoldier->sAtGridNo );
ConvertGridNoToCenterCellXY(SUpdateNetworkSoldier->sAtGridNo, &sCellX, &sCellY);
if( pSoldier->sGridNo != SUpdateNetworkSoldier->sAtGridNo)
{
@@ -5281,4 +5278,4 @@ void ChatCallback( UINT8 ubResult )
void OpenChatMsgBox( void )
{
DoChatBox((guiCurrentScreen == GAME_SCREEN? true : false),gzMPChatboxText[1],guiCurrentScreen,ChatCallback,NULL);
}
}
-28
View File
@@ -3553,33 +3553,6 @@ BOOLEAN Inventory::Save( HWFILE hFile, bool fSavingMap )
// The save directory now resides in the data directory (default or custom)
BOOLEAN InitSaveDir()
{
#ifndef USE_VFS
// Look for a custom data dir first
std::string dataDir = gCustomDataCat.GetRootDir();
if( dataDir.empty() || FileGetAttributes( (STR) dataDir.c_str() ) == 0xFFFFFFFF ) {
dataDir = gDefaultDataCat.GetRootDir();
}
// The locale-specific save dir location is of the form L"..\\SavedGames"
// This has not changed; instead, we strip the ".." at the beginning
if(is_networked)
{
sprintf( gSaveDir, "%s%S", dataDir.c_str(), pMessageStrings[ MSG_MPSAVEDIRECTORY ] + 2 );
}
else
sprintf( gSaveDir, "%s%S", dataDir.c_str(), pMessageStrings[ MSG_SAVEDIRECTORY ] + 2 );
// This was moved here from SaveGame
//Check to see if the save directory exists
if( FileGetAttributes( (STR) gSaveDir ) == 0xFFFFFFFF )
{
//ok the direcotry doesnt exist, create it
if( !MakeFileManDirectory( (CHAR8 *)gSaveDir ) )
{
return FALSE;
}
}
#else
if(is_networked)
{
sprintf( gSaveDir, "%s", vfs::String::as_utf8(pMessageStrings[ MSG_MPSAVEDIRECTORY ] + 3).c_str() );
@@ -3588,7 +3561,6 @@ BOOLEAN InitSaveDir()
{
sprintf( gSaveDir, "%s", vfs::String::as_utf8(pMessageStrings[ MSG_SAVEDIRECTORY ] + 3).c_str() );
}
#endif
return TRUE;
}
-2
View File
@@ -1350,7 +1350,6 @@ BOOLEAN InitSaveGameArray()
gbSaveGameArray[VAL_SLOT_START + cnt] = TRUE;
// anv: read last modified date property of save file
#ifdef USE_VFS
// get full path to save file
vfs::Path vfsPath;
vfs::COpenReadFile rfile(zSaveGameName);
@@ -1369,7 +1368,6 @@ BOOLEAN InitSaveGameArray()
// close
CloseHandle( hFile );
rfile->close();
#endif
}
}
else
-2
View File
@@ -252,10 +252,8 @@ namespace sgp
// compatibility with std::exception
Exception(WString const& msg, std::exception& ex SGP_CALLER_LOCATION);
#if defined(USE_VFS)
// compatibility with vfs::Exception
Exception(WString const& msg, vfs::Exception& ex SGP_CALLER_LOCATION);
#endif
virtual const char* what() const throw();
-2
View File
@@ -562,7 +562,6 @@ sgp::Exception::Exception(sgp::WString const& msg, Exception& ex SGP_CALLER_LOCA
_msg.push_back(excp);
}
#if defined(USE_VFS)
sgp::Exception::Exception(sgp::WString const& msg, vfs::Exception& ex SGP_CALLER_LOCATION_IMPL)
{
vfs::Exception::CALLSTACK::iterator it = ex.m_CallStack.begin();
@@ -584,7 +583,6 @@ sgp::Exception::Exception(sgp::WString const& msg, vfs::Exception& ex SGP_CALLER
_msg.push_back(excp);
}
#endif
sgp::Exception::Exception(WString const& msg, std::exception& ex SGP_CALLER_LOCATION_IMPL)
{
File diff suppressed because it is too large Load Diff
-7
View File
@@ -132,7 +132,6 @@ BOOLEAN GetFileManCurrentDirectory( STRING512 pcDirectory );
BOOLEAN GetExecutableDirectory( STRING512 pcDirectory );
BOOLEAN DirectoryExists( STRING512 pcDirectory );
BOOLEAN MakeFileManDirectory( STRING512 pcDirectory );
// WARNING: THESE DELETE ALL FILES IN THE DIRECTORY ( and all subdirectories if fRecursive is TRUE!! )
BOOLEAN RemoveFileManDirectory( STRING512 pcDirectory, BOOLEAN fRecursive);
@@ -157,8 +156,6 @@ BOOLEAN FileMove(STR strOldName, STR strNewName);
BOOLEAN FileSetAttributes( STR filename, UINT32 uiNewAttribs );
UINT32 FileGetAttributes( STR filename );
BOOLEAN FileClearAttributes( STR strFilename );
//returns true if at end of file, else false
BOOLEAN FileCheckEndOfFile( HWFILE hFile );
@@ -180,10 +177,6 @@ INT32 CompareSGPFileTimes( SGP_FILETIME *pFirstFileTime, SGP_FILETIME *pSecondFi
// files times may be slightly different due to SourceSafe of copying
BOOLEAN FileIsOlderThanFile(CHAR8 *pcFileName1, CHAR8 *pcFileName2, UINT32 ulNumSeconds);
// Pass in the Fileman file handle of an OPEN file and it will return..
// if its a Real File, the return will be the handle of the REAL file
// if its a LIBRARY file, the return will be the handle of the LIBRARY
HANDLE GetRealFileHandleFromFileManFileHandle( HWFILE hFile );
BOOLEAN AddSubdirectoryToPath(CHAR8 *pDirectory);
-18
View File
@@ -204,23 +204,6 @@ void ShutdownMemoryManager( void )
#ifndef EXTREME_MEMORY_DEBUGGING
#ifdef JA2BETAVERSION
{
#ifndef USE_VFS
FILE *fp;
fp = fopen( "MemLeakInfo.txt", "a" );
if( fp )
{
fprintf( fp, "\n\n" );
fprintf( fp, ">>>>> MEMORY LEAK DETECTED!!! <<<<<\n" );
fprintf( fp, " %d bytes memory total was allocated\n", guiMemAlloced );
fprintf( fp, "- %d bytes memory total was freed\n", guiMemFreed );
fprintf( fp, "_______________________________________________\n" );
fprintf( fp, "%d bytes memory total STILL allocated\n", guiMemTotal );
fprintf( fp, "%d memory blocks still allocated\n", MemDebugCounter );
fprintf( fp, "guiScreenExitedFrom = %S\n", gzJA2ScreenNames[ gMsgBox.uiExitScreen ] );
fprintf( fp, "\n\n" );
}
fclose( fp );
#else
sgp::Logger_ID log_id = sgp::Logger::instance().createLogger();
sgp::Logger::LogInstance memLeak = SGP_LOG(log_id);
memLeak << sgp::endl << sgp::endl;
@@ -232,7 +215,6 @@ void ShutdownMemoryManager( void )
memLeak << MemDebugCounter << " memory blocks still allocated" << sgp::endl;
memLeak << "guiScreenExitedFrom = " << gzJA2ScreenNames[ gMsgBox.uiExitScreen ] << sgp::endl;
memLeak << sgp::endl << sgp::endl;
#endif
}
#endif
#endif
+1 -21
View File
@@ -141,15 +141,6 @@ typedef VECTOR4 COLOR; // rgba color array
inline void convert_string(std::wstring const& str_in, std::string &str_out)
{
#if !defined(USE_VFS)
const wchar_t* src = str_in.c_str();
size_t len = wcstombs(NULL, src, str_in.length());
if(len > 0)
{
str_out.resize(len);
wcstombs(&str_out[0], src, len);
}
#else
if(vfs::Settings::getUseUnicode())
{
str_out = vfs::String::as_utf8(str_in);
@@ -158,20 +149,10 @@ inline void convert_string(std::wstring const& str_in, std::string &str_out)
{
vfs::String::narrow(str_in, str_out);
}
#endif
}
inline void convert_string(std::string const& str_in, std::wstring &str_out)
{
#if !defined(USE_VFS)
const char* src = str_in.c_str();
size_t len = mbstowcs(NULL, src, str_in.length());
if(len > 0)
{
str_out.resize(len);
mbstowcs(&str_out[0], src, len);
}
#else
if(vfs::Settings::getUseUnicode())
{
vfs::String::as_utf16(str_in, str_out);
@@ -180,8 +161,7 @@ inline void convert_string(std::string const& str_in, std::wstring &str_out)
{
vfs::String::widen(str_in, str_out);
}
#endif
}
#endif
#endif
-16
View File
@@ -189,21 +189,6 @@ Name=Tahoma
Height=-20
Weight=400
*/
#ifndef USE_VFS
char INIFile[MAX_PATH];
GetExecutableDirectory( INIFile );
strcat(INIFile, "\\");
strcat(INIFile, GAME_INI_FILE);
gWinFontAdjust = GetPrivateProfileInt("Ja2 Settings", "WIN_FONT_ADJUST", 0, INIFile);
for (UINT16 i=0; i<WIN_LASTFONT; i++)
{
GetPrivateProfileString(FontInfo[i].FontName, "Name", FontInfo[i].LogFont.lfFaceName, FontInfo[i].LogFont.lfFaceName, LF_FACESIZE, INIFile);
FontInfo[i].LogFont.lfHeight = gWinFontAdjust + GetPrivateProfileInt(FontInfo[i].FontName, "Height", FontInfo[i].LogFont.lfHeight, INIFile);
FontInfo[i].LogFont.lfWeight = GetPrivateProfileInt(FontInfo[i].FontName, "Weight", FontInfo[i].LogFont.lfWeight, INIFile);
}
#else
vfs::PropertyContainer props;
props.initFromIniFile(GAME_INI_FILE);
@@ -216,7 +201,6 @@ Weight=400
FontInfo[i].LogFont.lfHeight = gWinFontAdjust + (LONG)props.getIntProperty(FontInfo[i].FontName, "Height", FontInfo[i].LogFont.lfHeight);
FontInfo[i].LogFont.lfWeight = (LONG)props.getIntProperty(FontInfo[i].FontName, "Weight", FontInfo[i].LogFont.lfWeight);
}
#endif
}
void InitWinFonts( )
-122
View File
@@ -144,9 +144,7 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
#ifdef USE_VFS
static void PopulateSectionFromCommandLine(vfs::PropertyContainer &oProps, vfs::String const& sSection);
#endif
HINSTANCE ghInstance;
@@ -194,9 +192,7 @@ extern bool g_bUseXML_Strings;// = false;
bool g_bUseXML_Structures = false;
//bool g_bUseXML_Tilesets = false;
#ifdef USE_VFS
static vfs::Path sp_force_load_jsd_xml_file;
#endif
INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LPARAM lParam)
{
@@ -497,7 +493,6 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
return FALSE;
}
#ifdef USE_VFS
//vfs::Path exe_dir, exe_file;
//os::getExecutablePath(exe_dir, exe_file);
@@ -545,41 +540,6 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
}
}
#endif // USE_CODE_PAGE
#else
// Snap: moved the following from InitJA2SplashScreen for clarity
STRING512 CurrentDir;
STRING512 DataDir;
// Get Executable Directory
GetExecutableDirectory( CurrentDir );
// Adjust Current Dir
sprintf( DataDir, "%s\\Data", CurrentDir );
if ( !SetFileManCurrentDirectory( DataDir ) )
{
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Could not find data directory, shutting down");
return FALSE;
}
//Initialize the file database
//InitializeFileDatabase( gGameLibaries, NUMBER_OF_LIBRARIES ); // ?!?! doesn't take parameters (jonathanl)
InitializeFileDatabase();
// Snap: Initialize the Data directory catalogue
gDefaultDataCat.NewCat(DataDir);
STRING512 ja2INIfile;
strcat(ja2INIfile, "..\\");
strcat(ja2INIfile, GAME_INI_FILE);
// Snap: Get the custom Data directory location from GAME_INI_FILE (if any)
// and initialize the custom catalogue
char customDataPath[MAX_PATH];
if ( GetPrivateProfileString( "Ja2 Settings","CUSTOM_DATA_LOCATION", "", customDataPath, MAX_PATH, ja2INIfile ) )
{
gCustomDataCat.NewCat(std::string(CurrentDir) + '\\' + customDataPath);
}
#endif
if(g_bUseXML_Strings)
{
@@ -721,7 +681,6 @@ void ShutdownStandardGamingPlatform(void)
vfs::ObjectAllocator::clear();
}
#ifdef USE_VFS
#include "MPJoinScreen.h"
vfs::String getGameID()
@@ -735,7 +694,6 @@ vfs::String getGameID()
}
return _id;
}
#endif
#include "debug_util.h"
#include <vfs/Aspects/vfs_logging.h>
@@ -841,9 +799,7 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
#ifdef USE_VFS
vfs::Log::setSharedString( getGameID() );
#endif
//if(!vfs::Aspects::getMutexFactory())
//{
// vfs::Aspects::setMutexFactory( new VfsMutexFactory() );
@@ -914,15 +870,6 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
// ShowCursor(FALSE);
#ifdef USE_VFS
//vfs::Path exe_dir, exe_file;
//os::getExecutablePath(exe_dir, exe_file);
//os::setCurrectDirectory(exe_dir);
#else
STRING512 sExecutableDir;
GetExecutableDirectory( sExecutableDir );
SetCurrentDirectory(sExecutableDir);
#endif
try
{
// Inititialize the SGP
@@ -934,9 +881,7 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
}
HANDLE_FATAL_ERROR;
#ifdef USE_VFS
vfs::Log::flushReleaseAll();
#endif
#ifdef LUACONSOLE
if (1==iScreenMode)
@@ -1051,39 +996,10 @@ void GetRuntimeSettings( )
/* Detect cnc-ddraw and disable windowed mode */
BOOL bCncDdraw = GetProcAddress(GetModuleHandleW(L"ddraw.dll"), "GameHandlesClose") != NULL;
#ifndef USE_VFS
CHAR8 zMaximize[ 50 ];
CHAR8 zWindowedMode[ 50 ];
// Runtime settings - for now use INI file - later use registry
STRING512 INIFile; // Path to the ini file
CHAR8 zScreenResolution[ 50 ];
// Get Executable Directory
GetExecutableDirectory( INIFile );
strcat(INIFile, "\\");
strcat(INIFile, GAME_INI_FILE);
#else
vfs::PropertyContainer oProps;
oProps.initFromIniFile(GAME_INI_FILE);
PopulateSectionFromCommandLine(oProps, "Ja2 Settings");
#endif
#ifndef USE_VFS
if (GetPrivateProfileString( "Ja2 Settings","SCREEN_RESOLUTION", "", zScreenResolution, 50, INIFile ))
{
iResolution = atoi(zScreenResolution);
}
if (GetPrivateProfileString( "Ja2 Settings","SCREEN_MODE_WINDOWED_MAXIMIZE", "", zMaximize, 50, INIFile ))
{
iMaximize = atoi(zMaximize);
}
if (GetPrivateProfileString( "Ja2 Settings","SCREEN_MODE_WINDOWED", "", zWindowedMode, 50, INIFile ))
{
iWindowedMode = bCncDdraw ? 0 : atoi(zWindowedMode);
}
#else
vfs::String loc = oProps.getStringProperty("Ja2 Settings", L"LOCALE");
if(!loc.empty())
{
@@ -1142,9 +1058,7 @@ void GetRuntimeSettings( )
CIniReader::RegisterFileForMerging(*it);
}
}
#endif
#ifdef USE_VFS
extern bool g_bUsePngItemImages;
g_bUsePngItemImages = oProps.getBoolProperty(L"Ja2 Settings", L"USE_PNG_ITEM_IMAGES", false);
g_bUseXML_Structures = oProps.getBoolProperty(L"Ja2 Settings", L"USE_XML_STRUCTURES", false);
@@ -1164,17 +1078,9 @@ void GetRuntimeSettings( )
s_bExportStrings = oProps.getBoolProperty(L"Ja2 Settings", L"EXPORT_STRINGS", false);
sp_force_load_jsd_xml_file = oProps.getStringProperty(L"Ja2 Settings", L"FORCE_LOAD_JSD_XML_FILE", L"");
#endif
#ifdef JA2EDITOR
#ifndef USE_VFS
if (GetPrivateProfileString( "Ja2 Settings","EDITOR_SCREEN_RESOLUTION", "", zScreenResolution, 50, INIFile ))
{
iResolution = atoi(zScreenResolution);
}
#else
iResolution = (int)oProps.getIntProperty("Ja2 Settings","EDITOR_SCREEN_RESOLUTION", -1);
#endif
#endif
int iResX;
@@ -1311,30 +1217,6 @@ void GetRuntimeSettings( )
}
// Adjust again
#ifndef USE_VFS
gbPixelDepth = GetPrivateProfileInt( "SGP", "PIXEL_DEPTH", PIXEL_DEPTH, INIFile );
SCREEN_WIDTH = GetPrivateProfileInt( "SGP", "WIDTH", iResX, INIFile );
SCREEN_HEIGHT = GetPrivateProfileInt( "SGP", "HEIGHT", iResY, INIFile );
iScreenWidthOffset = (SCREEN_WIDTH - 640) / 2;
iScreenHeightOffset = (SCREEN_HEIGHT - 480) / 2;
/* Sergeant_Kolja. 2007-02-20: runtime Windowed mode instead of compile-time */
/* 1 for Windowed, 0 for Fullscreen */
if( !bScreenModeCmdLine )
iScreenMode = bCncDdraw ? 0 : (int) GetPrivateProfileInt( "Ja2 Settings","SCREEN_MODE_WINDOWED", iScreenMode, INIFile );
// WANNE: Should we play the intro?
iPlayIntro = (int) GetPrivateProfileInt( "Ja2 Settings","PLAY_INTRO", iPlayIntro, INIFile );
iUseWinFonts = (int) GetPrivateProfileInt( "Ja2 Settings","USE_WINFONTS", iUseWinFonts, INIFile,);
fTooltipScaleFactor = ((int)GetPrivateProfileInt("Ja2 Settings", "TOOLTIP_SCALE_FACTOR", 100, INIFile, )) / 100;
if (fTooltipScaleFactor < 1) fTooltipScaleFactor = 1;
// haydent: mouse scrolling
iDisableMouseScrolling = (int) GetPrivateProfileInt( "Ja2 Settings","DISABLE_MOUSE_SCROLLING", iDisableMouseScrolling, INIFile );
#else
gbPixelDepth = PIXEL_DEPTH;
SCREEN_WIDTH = iResX;
@@ -1388,8 +1270,6 @@ void GetRuntimeSettings( )
// get timer/clock initialization state
//SetHiSpeedClockMode( oProps.getBoolProperty("Ja2 Settings", "HIGHSPEED_TIMER", false) ? TRUE : FALSE );
SetHiSpeedClockMode( TRUE );
#endif
}
@@ -1464,7 +1344,6 @@ void ProcessJa2CommandLineBeforeInitialization(CHAR8 *pCommandLine)
MemFree(pCopy);
}
#ifdef USE_VFS
static void PopulateSectionFromCommandLine(vfs::PropertyContainer &oProps, vfs::String const& sSection)
{
const wchar_t* lpCommandLine = GetCommandLineW();
@@ -1496,7 +1375,6 @@ static void PopulateSectionFromCommandLine(vfs::PropertyContainer &oProps, vfs::
}
}
}
#endif
static LONG __stdcall SGPExceptionFilter(int exceptionCount, EXCEPTION_POINTERS* pExceptInfo)
{
-34
View File
@@ -16,16 +16,12 @@ static inline void flush_screen(std::wstringstream& stream)
int sgp::Logger::_next_log_id = -1;
#if defined(USE_VFS)
//std::vector<sgp::Logger::STimeLog> sgp::Logger::_logs;
std::vector<sgp::Logger::LogData> sgp::Logger::_logs;
#endif
sgp::Logger::Logger()
{
#if defined(USE_VFS)
connectFile(this->createLogger(), L"game_log.log", false, sgp::Logger::FLUSH_ON_ENDL);
#endif
}
sgp::Logger::~Logger()
@@ -47,9 +43,7 @@ bool sgp::Logger::shutdown()
{
for(::size_t i=0; i < _logs.size(); ++i)
{
#if defined(USE_VFS)
disconnectFile(i);
#endif
disconnectStream(i);
disconnectScreen(i);
}
@@ -102,7 +96,6 @@ void sgp::Logger::flushMode(sgp::Logger_ID id, sgp::Logger::FlushMode fmode)
}
#if defined(USE_VFS)
void sgp::Logger::connectFile(sgp::Logger_ID id, vfs::Path const& log_file, bool append, FlushMode fmode)
{
if(id >= 0 && id < _logs.size())
@@ -128,7 +121,6 @@ void sgp::Logger::disconnectFile(sgp::Logger_ID id)
}
}
}
#endif
void sgp::Logger::connectStream(sgp::Logger_ID id, std::ostream& stream)
{
@@ -170,29 +162,10 @@ void sgp::Logger::disconnectScreen(sgp::Logger_ID id)
}
//#if defined(USE_VFS)
//int sgp::Logger::createLogger(vfs::Path const& log_file, bool append, FlushMode fp)
//{
// vfs::Log::EFlushMode fm;
// if(fp == sgp::Logger::FLUSH_ON_DELETE) fm = vfs::Log::FLUSH_ON_DELETE;
// else if(fp == sgp::Logger::FLUSH_IMMIDIATELY) fm = vfs::Log::FLUSH_IMMEDIATELY;
// else if(fp == sgp::Logger::FLUSH_FULL_BUFFER) fm = vfs::Log::FLUSH_BUFFER;
// else if(fp == sgp::Logger::FLUSH_ON_ENDL) fm = vfs::Log::FLUSH_ON_ENDL;
// else fm = vfs::Log::FLUSH_IMMEDIATELY;
//
// _logs.push_back(STimeLog());
// _next_log_id++;
// _logs[_next_log_id]._log = vfs::Log::create(log_file,append,fm);
// _logs[_next_log_id]._timer.startTimer();
// return _next_log_id;
//}
//#endif
sgp::Logger::LogInstance sgp::Logger::logger(sgp::Logger_ID id)
{
if(id < _logs.size())
{
#if defined(USE_VFS)
std::wstringstream tmp;
tmp << L"[" << _logs[id].timer.running() << L"] : ";
std::wstring str(tmp.str());
@@ -208,7 +181,6 @@ sgp::Logger::LogInstance sgp::Logger::logger(sgp::Logger_ID id)
if(ld.screen) {
(*ld.screen) << str;
}
#endif
return sgp::Logger::LogInstance(&ld);
}
SGP_THROW(L"Unknown log id");
@@ -219,10 +191,8 @@ sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< <sgp::_flush>(sgp
{
if(_log.file)
{
#if defined(USE_VFS)
(*_log.file).flush();
(*_log.file).unlock();
#endif
}
if(_log.stream)
{
@@ -240,14 +210,12 @@ sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< <sgp::_endl>(sgp:
{
if(_log.file)
{
#if defined(USE_VFS)
(*_log.file) << vfs::Log::endl;
if(_log.file->flushMode() == vfs::Log::FLUSH_ON_ENDL)
{
(*_log.file).flush();
}
(*_log.file).unlock();
#endif
}
if(_log.stream)
{
@@ -263,8 +231,6 @@ sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< <sgp::_endl>(sgp:
template <>
sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< <sgp::_lock>(sgp::_lock const& l)
{
#if defined(USE_VFS)
_log.file->lock();
#endif
return *this;
}
+3 -31
View File
@@ -2,13 +2,9 @@
#define SGP_LOGGER_H
#include <vector>
#if defined(USE_VFS)
# include <vfs/Core/vfs_string.h>
# include <vfs/Tools/vfs_log.h>
# include <vfs/Tools/vfs_hp_timer.h>
#else
# include <iostream>
#endif
#include <vfs/Core/vfs_string.h>
#include <vfs/Tools/vfs_log.h>
#include <vfs/Tools/vfs_hp_timer.h>
namespace sgp
{
@@ -22,13 +18,9 @@ namespace sgp
{
struct LogData
{
#if defined(USE_VFS)
LogData() : file(NULL), stream(NULL), screen(NULL) {};
vfs::HPTimer timer;
vfs::Log* file;
#else
LogData() : stream(NULL), screen(NULL) {};
#endif
std::wostream* stream;
std::wstringstream* screen;
};
@@ -53,9 +45,7 @@ namespace sgp
LogInstance& operator<<(T const& t){
if(_log.stream) (*_log.stream) << t;
if(_log.screen) (*_log.screen) << t;
#if defined(USE_VFS)
if(_log.file ) (*_log.file) << t;
#endif
return *this;
}
private:
@@ -72,10 +62,8 @@ namespace sgp
Logger_ID createLogger();
#if defined(USE_VFS)
void connectFile(Logger_ID id, vfs::Path const& log_file, bool append, FlushMode fp);
void disconnectFile(Logger_ID id);
#endif
void connectStream(Logger_ID id, std::ostream& stream);
void disconnectStream(Logger_ID id);
@@ -102,44 +90,28 @@ namespace sgp
Logger::LogInstance& Logger::LogInstance::operator<< <_flush>(_flush const& f);
}
#if defined(USE_VFS)
inline sgp::Logger::LogInstance SGP_LOG(sgp::Logger_ID id, vfs::String const& str){
#else
inline sgp::Logger::LogInstance SGP_LOG(int id, const char* str){
#endif
return sgp::Logger::instance().logger(id) << (str) << sgp::endl;
}
inline sgp::Logger::LogInstance SGP_LOG(sgp::Logger_ID id){
return sgp::Logger::instance().logger(id);
}
#if defined(USE_VFS)
inline sgp::Logger::LogInstance SGP_INFO(vfs::String const& str){
#else
inline sgp::Logger::LogInstance SGP_INFO(const char* str){
#endif
return sgp::Logger::instance().logger(0) << str << sgp::endl;
}
inline sgp::Logger::LogInstance SGP_INFO(){
return sgp::Logger::instance().logger(0);
}
#if defined(USE_VFS)
inline sgp::Logger::LogInstance SGP_WARNING(vfs::String const& str){
#else
inline sgp::Logger::LogInstance SGP_WARNING(const char* str){
#endif
return sgp::Logger::instance().logger(0) << "WARNING : " << str << sgp::endl;
}
inline sgp::Logger::LogInstance SGP_WARNING(){
return sgp::Logger::instance().logger(0) << "WARNING : ";
}
#if defined(USE_VFS)
inline sgp::Logger::LogInstance SGP_ERROR(vfs::String const& str){
#else
inline sgp::Logger::LogInstance SGP_ERROR(const char* str){
#endif
return sgp::Logger::instance().logger(0) << "ERROR : " << str << sgp::endl;
}
inline sgp::Logger::LogInstance SGP_ERROR(){
-28
View File
@@ -61,7 +61,6 @@ FILE *SndDebug;
// Debug logging
void SoundLog(CHAR8 *strMessage);
void InitLogging();
// Cache system
BOOLEAN SoundInitCache(void);
@@ -213,7 +212,6 @@ BOOLEAN InitializeSoundManager(void)
{
UINT32 uiCount;
InitLogging();
if(fSoundSystemInit)
{
@@ -1869,31 +1867,5 @@ void SoundLog(CHAR8 *strMessage)
sgp::Logger::instance().connectFile(id, SndDebugFileName, true, sgp::Logger::FLUSH_ON_DELETE);
}
} s_SoundLog;
#ifndef USE_VFS
if ((SndDebug = fopen(SndDebugFileName, "a+t")) != NULL)
{
fprintf(SndDebug, "%s\n", strMessage);
fclose(SndDebug);
}
#else
SGP_LOG(s_SoundLog.id, vfs::String::widen(strMessage,strlen(strMessage)));
#endif
}
//*****************************************************************************************
// InitLogging
// Creates empty log file
//
// Returns nothing
//
// Created: 10.12.2005 Lesh
//*****************************************************************************************
void InitLogging()
{
#ifndef USE_VFS
if ((SndDebug = fopen(SndDebugFileName, "wt")) != NULL)
{
fclose(SndDebug);
}
#endif
}
-79
View File
@@ -1888,22 +1888,10 @@ void RefreshScreen(void *DummyVariable)
LPDIRECTDRAWSURFACE _pTmpBuffer;
LPDIRECTDRAWSURFACE2 pTmpBuffer;
DDSURFACEDESC SurfaceDescription;
#ifndef USE_VFS
FILE *OutputFile;
#endif
CHAR8 FileName[64];
INT32 iIndex;
UINT16 *p16BPPData;
// Snap: save current directory
#ifndef USE_VFS
STRING512 DataDir;
STRING512 ExecDir;
GetFileManCurrentDirectory( DataDir );
GetExecutableDirectory( ExecDir );
SetFileManCurrentDirectory( ExecDir );
#endif
//
// Create temporary system memory surface. This is used to correct problems with the backbuffer
// surface which can be interlaced or have a funky pitch
@@ -1953,23 +1941,13 @@ void RefreshScreen(void *DummyVariable)
{
sprintf( FileName, "SCREEN%03d.TGA", guiPrintFrameBufferIndex++);
}
#ifndef USE_VFS
while( (_access( FileName, 0 )) != -1 );
#else
while(FileExists(FileName));
#endif
#ifndef USE_VFS
if ((OutputFile = fopen( FileName, "wb")) != NULL)
{
fprintf(OutputFile, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, LOBYTE(SCREEN_WIDTH), HIBYTE(SCREEN_WIDTH), LOBYTE(SCREEN_HEIGHT), HIBYTE(SCREEN_HEIGHT), 0x10, 0);
#else
try
{
vfs::COpenWriteFile wfile(FileName,true,true);
char head[] = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, LOBYTE(SCREEN_WIDTH), HIBYTE(SCREEN_WIDTH), LOBYTE(SCREEN_HEIGHT), HIBYTE(SCREEN_HEIGHT), 0x10, 0};
SGP_TRYCATCH_RETHROW(wfile->write(head,18), L"");
#endif
//
// Lock temp surface
@@ -2006,19 +1984,11 @@ void RefreshScreen(void *DummyVariable)
ConvertRGBDistribution565To555( p16BPPData, SCREEN_WIDTH );
// Write
#ifndef USE_VFS
fwrite( p16BPPData, SCREEN_WIDTH * 2, 1, OutputFile);
#else
SGP_TRYCATCH_RETHROW(wfile->write((vfs::Byte*)p16BPPData, SCREEN_WIDTH * 2), L"");
#endif
}
else
{
#ifndef USE_VFS
fwrite((void *)(((UINT8 *)SurfaceDescription.lpSurface) + (iIndex * SCREEN_WIDTH * 2)), SCREEN_WIDTH * 2, 1, OutputFile);
#else
SGP_TRYCATCH_RETHROW(wfile->write((vfs::Byte*)(((UINT8 *)SurfaceDescription.lpSurface) + (iIndex * SCREEN_WIDTH * 2)), SCREEN_WIDTH * 2), L"");
#endif
}
}
@@ -2027,9 +1997,6 @@ void RefreshScreen(void *DummyVariable)
{
MemFree( p16BPPData );
}
#ifndef USE_VFS
fclose(OutputFile);
#endif
//
// Unlock temp surface
//
@@ -2043,12 +2010,10 @@ void RefreshScreen(void *DummyVariable)
}
}
#ifdef USE_VFS
catch(std::exception& ex)
{
SGP_RETHROW(L"", ex);
}
#endif
//
// Release temp surface
@@ -2056,12 +2021,6 @@ void RefreshScreen(void *DummyVariable)
gfPrintFrameBuffer = FALSE;
IDirectDrawSurface2_Release(pTmpBuffer);
#ifndef USE_VFS
// Snap: Restore the data directory once we are finished.
SetFileManCurrentDirectory( DataDir );
//strcat( ExecDir, "\\Data" );
//SetFileManCurrentDirectory( ExecDir );
#endif
}
//
@@ -3322,80 +3281,42 @@ void RefreshMovieCache( )
{
TARGA_HEADER Header;
INT32 iCountX, iCountY;
#ifndef USE_VFS
FILE *disk;
#endif
CHAR8 cFilename[_MAX_PATH];
static UINT32 uiPicNum=0;
UINT16 *pDest;
INT32 cnt;
#ifndef USE_VFS
STRING512 DataDir;
STRING512 ExecDir;
#endif
PauseTime( TRUE );
#ifndef USE_VFS
// Snap: save current directory
GetFileManCurrentDirectory( DataDir );
GetExecutableDirectory( ExecDir );
SetFileManCurrentDirectory( ExecDir );
#else
try
{
#endif
for ( cnt = 0; cnt < giNumFrames; cnt++ )
{
sprintf( cFilename, "JA%5.5d.TGA", uiPicNum++ );
#ifndef USE_VFS
if( ( disk = fopen(cFilename, "wb"))==NULL )
return;
#else
vfs::COpenWriteFile wfile(cFilename, true, true);
#endif
memset(&Header, 0, sizeof(TARGA_HEADER));
Header.ubTargaType=2; // Uncompressed 16/24/32 bit
Header.usImageWidth=SCREEN_WIDTH;
Header.usImageHeight=SCREEN_HEIGHT;
Header.ubBitsPerPixel=16;
#ifndef USE_VFS
fwrite(&Header, sizeof(TARGA_HEADER), 1, disk);
#else
SGP_TRYCATCH_RETHROW(wfile->write((vfs::Byte*)&Header, sizeof(TARGA_HEADER)), L"");
#endif
pDest = gpFrameData[ cnt ];
for(iCountY=SCREEN_HEIGHT-1; iCountY >=0 ; iCountY-=1)
{
for(iCountX=0; iCountX < SCREEN_WIDTH; iCountX ++ )
{
#ifndef USE_VFS
fwrite( ( pDest + ( iCountY * SCREEN_WIDTH ) + iCountX ), sizeof(UINT16), 1, disk);
#else
SGP_TRYCATCH_RETHROW(wfile->write( (vfs::Byte*)( pDest + ( iCountY * SCREEN_WIDTH ) + iCountX ), sizeof(UINT16)), L"");
#endif
}
}
#ifndef USE_VFS
fclose(disk);
#endif
}
PauseTime( FALSE );
giNumFrames = 0;
#ifndef USE_VFS
// Snap: Restore the data directory once we are finished.
SetFileManCurrentDirectory( DataDir );
//strcat( ExecDir, "\\Data" );
//SetFileManCurrentDirectory( ExecDir );
#else
}
catch(std::exception& ex)
{
SGP_ERROR(ex.what());
}
#endif
}
-1
View File
@@ -51,7 +51,6 @@
HLIST ghVideoObjects = NULL;
BOOLEAN gfVideoObjectsInit=FALSE;
#ifndef SGP_VIDEO_DEBUGGING
-1
View File
@@ -225,7 +225,6 @@ BOOLEAN GetETRLEPixelValue( UINT8 * pDest, HVOBJECT hVObject, UINT16 usETLREInde
// Globals
//
// ****************************************************************************
extern HLIST ghVideoObjects;
// ****************************************************************************
//
+19 -55
View File
@@ -98,18 +98,13 @@ void CheckValidVSurfaceIndex( UINT32 uiIndex );
INT32 giMemUsedInSurfaces;
//OBSOLETE!!!!!!!!!
HLIST ghVideoSurfaces = NULL;
//OBSOLETE!!!!!!!!!
HVSURFACE ghPrimary = NULL;
HVSURFACE ghBackBuffer = NULL;
HVSURFACE ghFrameBuffer = NULL;
HVSURFACE ghMouseBuffer = NULL;
#include <map>
#include <vector>
extern std::map<UINT32,ClipRectangle> g_SurfaceRectangle;
@@ -1161,11 +1156,7 @@ HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc )
//
// Allocate memory for Video Surface data and initialize
//
hVSurface = (HVSURFACE) MemAlloc( sizeof( SGPVSurface ) );
memset( hVSurface, 0, sizeof( SGPVSurface ) );
CHECKF( hVSurface != NULL );
hVSurface = new SGPVSurface{};
hVSurface->usHeight = usHeight;
hVSurface->usWidth = usWidth;
// BF : since we use a 16bpp framebuffer and images are converted to that format,
@@ -1178,7 +1169,6 @@ HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc )
hVSurface->pPalette = NULL;
hVSurface->p16BPPPalette = NULL;
hVSurface->TransparentColor = FROMRGB( 0, 0, 0 );
hVSurface->RegionList = CreateList( DEFAULT_NUM_REGIONS, sizeof( VSURFACE_REGION ) );
hVSurface->fFlags = 0;
hVSurface->pClipper = NULL;
@@ -1647,12 +1637,6 @@ BOOLEAN DeleteVideoSurface( HVSURFACE hVSurface )
hVSurface->pPalette = NULL;
}
//if ( hVSurface->pClipper != NULL )
//{
// Release Clipper
// DDReleaseClipper( (LPDIRECTDRAWCLIPPER)hVSurface->pClipper );
//}
// Get surface pointer
lpDDSurface = (LPDIRECTDRAWSURFACE2)hVSurface->pSurfaceData;
@@ -1670,7 +1654,7 @@ BOOLEAN DeleteVideoSurface( HVSURFACE hVSurface )
}
// Release region data
DeleteList( hVSurface->RegionList );
hVSurface->RegionList.clear();
//If there is a 16bpp palette, free it
if( hVSurface->p16BPPPalette != NULL )
@@ -1682,8 +1666,7 @@ BOOLEAN DeleteVideoSurface( HVSURFACE hVSurface )
giMemUsedInSurfaces -= ( hVSurface->usHeight * hVSurface->usWidth * ( hVSurface->ubBitDepth / 8 ) );
// Release object
MemFree( hVSurface );
delete hVSurface;
return( TRUE );
}
@@ -1768,7 +1751,7 @@ BOOLEAN GetNumRegions( HVSURFACE hVSurface , UINT32 *puiNumRegions )
{
Assert( hVSurface );
*puiNumRegions = ListSize( hVSurface->RegionList );
*puiNumRegions = hVSurface->RegionList.size();
return( TRUE );
@@ -1780,7 +1763,7 @@ BOOLEAN AddVSurfaceRegion( HVSURFACE hVSurface, VSURFACE_REGION *pNewRegion )
Assert( pNewRegion != NULL );
// Add new region to list
hVSurface->RegionList = AddtoList( hVSurface->RegionList, pNewRegion, ListSize( hVSurface->RegionList ) );
hVSurface->RegionList.push_back(*pNewRegion);
return( TRUE );
}
@@ -1801,29 +1784,10 @@ BOOLEAN AddVSurfaceRegions( HVSURFACE hVSurface, VSURFACE_REGION **ppNewRegions,
return( TRUE );
}
BOOLEAN RemoveVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex )
{
VSURFACE_REGION aRegion;
Assert( hVSurface != NULL );
return( RemfromList( hVSurface->RegionList, &aRegion, usIndex ) );
}
BOOLEAN ClearAllVSurfaceRegions( HVSURFACE hVSurface )
{
UINT32 uiListSize;
Assert( hVSurface != NULL );
uiListSize = ListSize( hVSurface->RegionList );
for ( INT32 cnt = uiListSize - 1; cnt >= 0; cnt-- )
{
RemoveVSurfaceRegion( hVSurface, (UINT16)cnt );
}
hVSurface->RegionList.clear();
return( TRUE );
}
@@ -1831,11 +1795,12 @@ BOOLEAN GetVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION
{
Assert( hVSurface != NULL );
if ( !PeekList( hVSurface->RegionList, aRegion, usIndex ) )
if (usIndex >= hVSurface->RegionList.size())
{
return( FALSE );
}
*aRegion = hVSurface->RegionList[usIndex];
return( TRUE );
}
@@ -1858,15 +1823,12 @@ BOOLEAN ReplaceVSurfaceRegion( HVSURFACE hVSurface , UINT16 usIndex, VSURFACE_RE
Assert( hVSurface != NULL );
// Validate index given
if ( !PeekList( hVSurface->RegionList, &OldRegion, usIndex ) )
if (usIndex >= hVSurface->RegionList.size())
{
return( FALSE );
}
// Replace information
hVSurface->RegionList = AddtoList( hVSurface->RegionList, aRegion, usIndex );
hVSurface->RegionList[usIndex] = *aRegion;
return( TRUE );
}
@@ -1875,11 +1837,14 @@ BOOLEAN AddVSurfaceRegionAtIndex( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_
Assert( hVSurface != NULL );
Assert( pNewRegion != NULL );
// Add new region to list
hVSurface->RegionList = AddtoList( hVSurface->RegionList, pNewRegion, usIndex );
return( TRUE );
if (usIndex >= hVSurface->RegionList.size())
{
return(FALSE);
}
auto pos = hVSurface->RegionList.begin() + usIndex;
hVSurface->RegionList.insert(pos, *pNewRegion);
return(TRUE);
}
// *******************************************************************
@@ -2161,7 +2126,7 @@ HVSURFACE CreateVideoSurfaceFromDDSurface( LPDIRECTDRAWSURFACE2 lpDDSurface )
// Allocate Video Surface struct
hVSurface = (HVSURFACE) MemAlloc( sizeof( SGPVSurface ) );
hVSurface = new SGPVSurface{};
// Set values based on DD Surface given
DDGetSurfaceDescription ( lpDDSurface, &DDSurfaceDesc );
@@ -2173,7 +2138,6 @@ HVSURFACE CreateVideoSurfaceFromDDSurface( LPDIRECTDRAWSURFACE2 lpDDSurface )
hVSurface->pSurfaceData = (PTR)lpDDSurface;
hVSurface->pSurfaceData1 = NULL;
hVSurface->pSavedSurfaceData = NULL;
hVSurface->RegionList = CreateList( DEFAULT_NUM_REGIONS, sizeof( VSURFACE_REGION ) );
hVSurface->fFlags = 0;
// Get and Set palette, if attached, allow to fail
+3 -3
View File
@@ -5,6 +5,7 @@
#include "container.h"
#include "himage.h"
#include "vobject.h"
#include <vector>
///////////////////////////////////////////////////////////////////////////////////////////////////
//
@@ -105,7 +106,7 @@ typedef struct
UINT16 *p16BPPPalette; // A 16BPP palette used for 8->16 blits
COLORVAL TransparentColor; // Defaults to 0,0,0
PTR pClipper; // A void pointer encapsolated as a clipper Surface
HLIST RegionList; // A List of regions within the video Surface
std::vector<VSURFACE_REGION> RegionList; // A List of regions within the video Surface
} SGPVSurface, *HVSURFACE;
@@ -240,7 +241,6 @@ BOOLEAN DeleteVideoSurfaceFromIndex( UINT32 uiIndex );
BOOLEAN AddVSurfaceRegion( HVSURFACE hVSurface, VSURFACE_REGION *pNewRegion );
BOOLEAN AddVSurfaceRegionAtIndex( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION *pNewRegion );
BOOLEAN AddVSurfaceRegions( HVSURFACE hVSurface, VSURFACE_REGION **ppNewRegions, UINT16 uiNumRegions );
BOOLEAN RemoveVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex );
BOOLEAN ClearAllVSurfaceRegions( HVSURFACE hVSurface );
BOOLEAN GetVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION *aRegion );
BOOLEAN GetNumRegions( HVSURFACE hVSurface , UINT32 *puiNumRegions );
@@ -286,4 +286,4 @@ BOOLEAN ShadowVideoSurfaceRectUsingLowPercentTable( UINT32 uiDestVSurface, INT32
#endif
*/
#endif
#endif
-21
View File
@@ -206,26 +206,6 @@ BOOLEAN ReadInAltSectors(STR fileName)
BOOLEAN WriteInAltSectors(STR fileName)
{
#ifndef USE_VFS
// Lets output the current Strategic map format using the XML structure I've devised.
FILE *outfile = fopen(fileName, "wt");
UINT32 x, y;
fprintf (outfile, "<ALT_SECTORS_LIST>\n");
for(y = 1;y <= 16;y++)
{
fprintf (outfile, "\t<ROW y=\"%c\">",(y+0x40));
for(x = 1;x <= 16; x++)
{
fprintf (outfile, " %d",RandomSector[ ((y - 1) * 16) + (x - 1) ] );
}
fprintf (outfile, " </ROW>\n");
}
fprintf (outfile, "</ALT_SECTORS_LIST>\n");
fclose(outfile);
#else
XMLWriter xmlw;
xmlw.openNode(L"ALT_SECTORS_LIST");
UINT32 x, y;
@@ -241,7 +221,6 @@ BOOLEAN WriteInAltSectors(STR fileName)
}
xmlw.closeNode();
xmlw.writeToFile(fileName);
#endif
return (TRUE);
}
-41
View File
@@ -5430,22 +5430,11 @@ void LogStrategicMsg( STR8 str, ... )
{
va_list argptr;
CHAR8 string[512];
#ifndef USE_VFS
FILE *fp;
fp = fopen( "Strategic Decisions.txt", "a" );
if( !fp )
return;
#endif
va_start(argptr, str );
vsprintf( string, str, argptr);
va_end(argptr);
#ifndef USE_VFS
fprintf( fp, "%s\n", string );
#else
SGP_LOG(s_stratD.id, string);
#endif
if( gfDisplayStrategicAILogs )
{
@@ -5455,33 +5444,17 @@ void LogStrategicMsg( STR8 str, ... )
{
OutputDebugString( (LPCSTR)String( "%s\n", string ) );
}
#ifndef USE_VFS
fclose( fp );
#endif
}
void LogStrategicEvent( STR8 str, ... )
{
va_list argptr;
CHAR8 string[512];
#ifndef USE_VFS
FILE *fp;
fp = fopen( "Strategic Decisions.txt", "a" );
if( !fp )
return;
#endif
va_start(argptr, str );
vsprintf( string, str, argptr);
va_end(argptr);
#ifndef USE_VFS
fprintf( fp, "\n%S:\n", WORLDTIMESTR );
fprintf( fp, "%s\n", string );
#else
SGP_LOG(s_stratD.id) << sgp::endl << WORLDTIMESTR << ":" << sgp::endl << string << sgp::endl;
#endif
if( gfDisplayStrategicAILogs )
{
ScreenMsg( FONT_LTKHAKI, MSG_DIALOG, L"%S", string );
@@ -5490,25 +5463,11 @@ void LogStrategicEvent( STR8 str, ... )
{
OutputDebugString( (LPCSTR)String( "%s\n", string ) );
}
#ifndef USE_VFS
fclose( fp );
#endif
}
void ClearStrategicLog()
{
#ifndef USE_VFS
FILE *fp;
fp = fopen( "Strategic Decisions.txt", "w" );
if( !fp )
return;
fprintf( fp, "STRATEGIC LOG\n" );
fclose( fp );
#else
SGP_LOG(s_stratD.id) << sgp::flush;
#endif
}
#endif
+12 -12
View File
@@ -1757,30 +1757,30 @@ void AddCorpsesToBloodcatLair( INT16 sSectorX, INT16 sSectorY )
Corpse.usFlags = ROTTING_CORPSE_FIND_SWEETSPOT_FROM_GRIDNO;
// 1st gridno
Corpse.sGridNo = 14319; //dnl!!!
ConvertGridNoToXY( Corpse.sGridNo, &sXPos, &sYPos );
Corpse.dXPos = (FLOAT)( CenterX( sXPos ) );
Corpse.dYPos = (FLOAT)( CenterY( sYPos ) );
Corpse.sGridNo = 14319; //dnl!!!
ConvertGridNoToCenterCellXY(Corpse.sGridNo, &sXPos, &sYPos);
Corpse.dXPos = (FLOAT)( sXPos );
Corpse.dYPos = (FLOAT)( sYPos );
//Add the rotting corpse info to the sectors unloaded rotting corpse file
AddRottingCorpseToUnloadedSectorsRottingCorpseFile( sSectorX, sSectorY, 0, &Corpse);
// 2nd gridno
Corpse.sGridNo = 9835; //dnl!!!
ConvertGridNoToXY( Corpse.sGridNo, &sXPos, &sYPos );
Corpse.dXPos = (FLOAT)( CenterX( sXPos ) );
Corpse.dYPos = (FLOAT)( CenterY( sYPos ) );
Corpse.sGridNo = 9835; //dnl!!!
ConvertGridNoToCenterCellXY(Corpse.sGridNo, &sXPos, &sYPos);
Corpse.dXPos = (FLOAT)(sXPos);
Corpse.dYPos = (FLOAT)(sYPos);
//Add the rotting corpse info to the sectors unloaded rotting corpse file
AddRottingCorpseToUnloadedSectorsRottingCorpseFile( sSectorX, sSectorY, 0, &Corpse);
// 3rd gridno
Corpse.sGridNo = 11262; //dnl!!!
ConvertGridNoToXY( Corpse.sGridNo, &sXPos, &sYPos );
Corpse.dXPos = (FLOAT)( CenterX( sXPos ) );
Corpse.dYPos = (FLOAT)( CenterY( sYPos ) );
Corpse.sGridNo = 11262; //dnl!!!
ConvertGridNoToCenterCellXY(Corpse.sGridNo, &sXPos, &sYPos);
Corpse.dXPos = (FLOAT)(sXPos);
Corpse.dYPos = (FLOAT)(sYPos);
//Add the rotting corpse info to the sectors unloaded rotting corpse file
AddRottingCorpseToUnloadedSectorsRottingCorpseFile( sSectorX, sSectorY, 0, &Corpse);
+2 -77
View File
@@ -1659,80 +1659,6 @@ void EndLoadScreen( )
'A' + gWorldSectorY - 1, gWorldSectorX, gbWorldSectorZ, uiSeconds, uiHundreths );
}
ScreenMsg( FONT_YELLOW, MSG_TESTVERSION, str );
#ifndef USE_VFS
FILE *fp;
if ( fStartNewFile )
{ //start new file
fp = fopen( "TimeResults.txt", "w" );
ScreenMsg( FONT_YELLOW, MSG_TESTVERSION, L"See JA2\\Data\\TimeResults.txt for more detailed timings." );
fStartNewFile = FALSE;
}
else
{ //append to end of file
fp = fopen( "TimeResults.txt", "a" );
if ( fp )
{
fprintf( fp, "\n\n--------------------------------------------------------------------\n\n" );
}
}
if ( fp )
{
//Record all of the timings.
fprintf( fp, "%S\n", str );
fprintf( fp, "EnterSector() supersets LoadWorld(). This includes other external sections.\n" );
//FileRead()
fprintf( fp, "\n\nVARIOUS FUNCTION TIMINGS (exclusive of actual function timings in second heading)\n" );
uiSeconds = uiTotalFileReadTime / 1000;
uiHundreths = (uiTotalFileReadTime / 10) % 100;
fprintf( fp, "FileRead: %d.%02d (called %d times)\n", uiSeconds, uiHundreths, uiTotalFileReadCalls );
fprintf( fp, "\n\nSECTIONS OF LOADWORLD (all parts should add up to 100%)\n" );
//TrashWorld()
uiSeconds = uiTrashWorldTime / 1000;
uiHundreths = (uiTrashWorldTime / 10) % 100;
fprintf( fp, "TrashWorld: %d.%02d\n", uiSeconds, uiHundreths );
//LoadMapTilesets()
uiSeconds = uiLoadMapTilesetTime / 1000;
uiHundreths = (uiLoadMapTilesetTime / 10) % 100;
fprintf( fp, "LoadMapTileset: %d.%02d\n", uiSeconds, uiHundreths );
//LoadMapLights()
uiSeconds = uiLoadMapLightsTime / 1000;
uiHundreths = (uiLoadMapLightsTime / 10) % 100;
fprintf( fp, "LoadMapLights: %d.%02d\n", uiSeconds, uiHundreths );
uiSeconds = uiBuildShadeTableTime / 1000;
uiHundreths = (uiBuildShadeTableTime / 10) % 100;
fprintf( fp, " 1) BuildShadeTables: %d.%02d\n", uiSeconds, uiHundreths );
uiPercentage = uiNumImagesReloaded * 100 / giNumberOfTileTypes;
fprintf( fp, " 2) %d%% of the tileset images were actually reloaded.\n", uiPercentage );
if ( (uiNumTablesSaved + uiNumTablesLoaded) != 0 )
{
uiPercentage = uiNumTablesSaved * 100 / (uiNumTablesSaved + uiNumTablesLoaded);
}
else
{
uiPercentage = 0;
}
fprintf( fp, " 3) Of that, %d%% of the shade tables were generated (not loaded).\n", uiPercentage );
if ( gfForceBuildShadeTables )
fprintf( fp, " NOTE: Force building of shadetables enabled on this local computer.\n" );
//Unaccounted
uiUnaccounted = uiLoadWorldTime - uiTrashWorldTime - uiLoadMapTilesetTime - uiLoadMapLightsTime;
uiSeconds = uiUnaccounted / 1000;
uiHundreths = (uiUnaccounted / 10) % 100;
fprintf( fp, "Unaccounted: %d.%02d\n", uiSeconds, uiHundreths );
//LoadWorld()
uiSeconds = uiLoadWorldTime / 1000;
uiHundreths = (uiLoadWorldTime / 10) % 100;
fprintf( fp, "\nTotal: %d.%02d\n", uiSeconds, uiHundreths );
fclose( fp );
}
#else
sgp::Logger_ID time_log_id = sgp::Logger::instance( ).createLogger( );
sgp::Logger::instance( ).connectFile( time_log_id, L"TimeResults.txt", true, sgp::Logger::FLUSH_ON_ENDL );
sgp::Logger::LogInstance timeResults = SGP_LOG( time_log_id );
@@ -1793,7 +1719,6 @@ void EndLoadScreen( )
uiSeconds = uiLoadWorldTime / 1000;
uiHundreths = (uiLoadWorldTime / 10) % 100;
timeResults << vfs::Log::endl << "Total: " << uiSeconds << "." << uiHundreths << sgp::endl;
#endif // USE_VFS
#endif
}
@@ -4773,8 +4698,8 @@ void DoneFadeOutAdjacentSector( )
curr->pSoldier->ubWaitActionToDo = 1;
// OK, here we have been given a position, a gridno has been given to use as well....
sOldGridNo = curr->pSoldier->sGridNo;
sWorldX = CenterX( sGridNo );
sWorldY = CenterY( sGridNo );
ConvertGridNoToCenterCellXY(sGridNo, &sWorldX, &sWorldY);
curr->pSoldier->EVENT_SetSoldierPosition( sWorldX, sWorldY );
if ( sGridNo != sOldGridNo )
{
+9 -13
View File
@@ -352,9 +352,8 @@ INT32 PickRandomLocationAtMinSpacesAway( INT32 sGridNo, INT16 sMinValue, INT16 s
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,"PickRandomLocationAtMinSpacesAway");
sX = CenterX( sGridNo );
sY = CenterY( sGridNo );
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
while(TileIsOutOfBounds(sNewGridNo))
{
sNewX = sX + sMinValue + (INT16)Random( sRandomVar );
@@ -596,8 +595,7 @@ void BeginBombing( )
sGridNo = PickRandomLocationAtMinSpacesAway( gsDiveTargetLocation , 300, 200 );
// Save X, y:
gsDiveX = CenterX( sGridNo );
gsDiveY = CenterY( sGridNo );
ConvertGridNoToCenterCellXY(sGridNo, &gsDiveX, &gsDiveY);
RESETTIMECOUNTER( giTimerAirRaidUpdate, RAID_DELAY );
@@ -657,8 +655,7 @@ void BeginDive( )
sGridNo = PickRandomLocationAtMinSpacesAway( gsDiveTargetLocation, 300, 200 );
// Save X, y:
gsDiveX = CenterX( sGridNo );
gsDiveY = CenterY( sGridNo );
ConvertGridNoToCenterCellXY(sGridNo, &gsDiveX, &gsDiveY);
RESETTIMECOUNTER( giTimerAirRaidUpdate, RAID_DELAY );
giNumTurnsSinceDiveStarted = 0;
@@ -760,8 +757,7 @@ void DoDive( )
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,"DoDive: move towards target");
// Move Towards target....
sTargetX = CenterX( gsDiveTargetLocation );
sTargetY = CenterY( gsDiveTargetLocation );
ConvertGridNoToCenterCellXY(gsDiveTargetLocation, &sTargetX, &sTargetY);
// Determine deltas
dDeltaX = (FLOAT)( sTargetX - gsDiveX );
@@ -886,7 +882,7 @@ void DoBombing( )
INT16 sRange;
INT32 sGridNo, sOldGridNo, sBombGridNo;
INT16 sTargetX, sTargetY;
INT16 sTargetX, sTargetY, sBombX, sBombY;
UINT16 usItem;
INT16 sStrafeX, sStrafeY;
FLOAT dDeltaX, dDeltaY, dAngle, dDeltaXPos, dDeltaYPos;
@@ -933,8 +929,7 @@ void DoBombing( )
RESETTIMECOUNTER( giTimerAirRaidUpdate, RAID_DELAY );
// Move Towards target....
sTargetX = CenterX( gsDiveTargetLocation );
sTargetY = CenterY( gsDiveTargetLocation );
ConvertGridNoToCenterCellXY(gsDiveTargetLocation, &sTargetX, &sTargetY);
// Determine deltas
dDeltaX = (FLOAT)( sTargetX - gsDiveX );
@@ -1002,7 +997,8 @@ void DoBombing( )
}
// Drop bombs...
InternalIgniteExplosion( NOBODY, CenterX( sBombGridNo ), CenterY( sBombGridNo ), 0, sBombGridNo, usItem, fLocate , (UINT8)IsRoofPresentAtGridNo( sBombGridNo ) );
ConvertGridNoToCenterCellXY(sBombGridNo, &sBombX, &sBombY);
InternalIgniteExplosion( NOBODY, sBombX, sBombY, 0, sBombGridNo, usItem, fLocate , (UINT8)IsRoofPresentAtGridNo( sBombGridNo ) );
}
+3 -3
View File
@@ -102,7 +102,7 @@ public:
return (returnHeap);
}
int moveUp(register int index, KEY newKey)
int moveUp(int index, KEY newKey)
{
while (index > 1) {
int current2 = index>>1;//divided by 2
@@ -120,7 +120,7 @@ public:
int moveDown(int index, KEY currentKey)
{
register int current2 = index+index;
int current2 = index+index;
while (current2 < heapCount) {
if (current2+1 < heapCount) {
//choose child to possibly move
@@ -314,7 +314,7 @@ insert:
int findData(const T data) const
{
register int current;
int current;
for (current = heapCount-1; current > 0; --current) {
if (BinaryHeap[current].data == data) {
break;
File diff suppressed because it is too large Load Diff
+8 -8
View File
@@ -373,7 +373,7 @@ BOOLEAN HasAdjTile( const INT32& ubX, const INT32& ubY, const INT32& ubZ )
void AddCoverObjectsToViewArea()
{
register INT32 ubX, ubY, ubZ;
INT32 ubX, ubY, ubZ;
BOOLEAN fChanged = FALSE;
BOOLEAN fNightTime = NightTime( );
@@ -406,7 +406,7 @@ void RemoveCoverObjectsFromViewArea()
return;
// Go through the whole gCoverViewArea when removing cover objects. Otherwise we don't clean up tiles that are not in the viewport which results in an annoying visual bug.
register INT32 ubX, ubY, ubZ;
INT32 ubX, ubY, ubZ;
BOOLEAN fChanged = FALSE;
for ( ubX = 0; ubX < COVER_X_CELLS; ++ubX )
@@ -669,8 +669,8 @@ static void CalculateCoverFromEnemies()
void CalculateCover()
{
register INT32 ubX, ubY;
register INT8 ubZ;
INT32 ubX, ubY;
INT8 ubZ;
SOLDIERTYPE* pSoldier;
if (gusSelectedSoldier == NOBODY)
@@ -1144,7 +1144,7 @@ void AddMinesObjectsToViewArea()
if ( gsMaxCellY < 0 )
return;
register INT32 ubX, ubY, ubZ;
INT32 ubX, ubY, ubZ;
BOOLEAN fChanged = FALSE;
BOOLEAN fNightTime = NightTime( );
@@ -1503,7 +1503,7 @@ void AddTraitObjectsToViewArea()
if ( gsMaxCellY < 0 )
return;
register INT32 ubX, ubY, ubZ;
INT32 ubX, ubY, ubZ;
BOOLEAN fChanged = FALSE;
BOOLEAN fNightTime = NightTime( );
@@ -1657,7 +1657,7 @@ void AddTrackerObjectsToViewArea( )
if ( gsMaxCellY < 0 )
return;
register INT32 ubX, ubY, ubZ;
INT32 ubX, ubY, ubZ;
BOOLEAN fChanged = FALSE;
BOOLEAN fNightTime = NightTime();
@@ -1731,7 +1731,7 @@ void CalculateFortify( )
if ( gsMaxCellY < 0 )
return;
register INT32 ubX, ubY, ubZ;
INT32 ubX, ubY, ubZ;
BOOLEAN fChanged = FALSE;
BOOLEAN fNightTime = NightTime( );
+305 -281
View File
@@ -62,7 +62,8 @@ void NewEye( FACETYPE *pFace );
void NewMouth( FACETYPE *pFace );
INT32 GetFreeFace(void);
void RecountFaces(void);
void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLEAN fUseExternBuffer, UINT32 uiBuffer, INT16 sFaceX, INT16 sFaceY, UINT16 usEyesX, UINT16 usEyesY );
UINT32 GetFaceShade(SOLDIERTYPE *pSoldier, FACETYPE *pFace, BOOLEAN fExternBlit);
void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLEAN fUseExternBuffer, UINT32 uiBuffer, INT16 sFaceX, INT16 sFaceY, UINT16 usEyesX, UINT16 usEyesY, UINT32 uiFaceShade);
extern BOOLEAN gfInItemPickupMenu;
@@ -157,6 +158,32 @@ INT32 InitFace( UINT8 usMercProfileID, UINT8 ubSoldierID, UINT32 uiInitFlags )
}
void SetPalettes(HVOBJECT *hVObject, UINT32 uiIndex)
{
SGPPaletteEntry Pal[256];
// Build a grayscale palette! ( for testing different looks )
for (UINT32 uiCount = 0; uiCount < 256; uiCount++)
{
Pal[uiCount].peRed = 255;
Pal[uiCount].peGreen = 255;
Pal[uiCount].peBlue = 255;
}
(*hVObject)->pShades[FLASH_PORTRAIT_NOSHADE] = Create16BPPPaletteShaded((*hVObject)->pPaletteEntry, 255, 255, 255, FALSE);
(*hVObject)->pShades[FLASH_PORTRAIT_STARTSHADE] = Create16BPPPaletteShaded(Pal, 255, 255, 255, FALSE);
(*hVObject)->pShades[FLASH_PORTRAIT_ENDSHADE] = Create16BPPPaletteShaded((*hVObject)->pPaletteEntry, 250, 25, 25, TRUE);
(*hVObject)->pShades[FLASH_PORTRAIT_DARKSHADE] = Create16BPPPaletteShaded((*hVObject)->pPaletteEntry, 100, 100, 100, TRUE);
(*hVObject)->pShades[FLASH_PORTRAIT_LITESHADE] = Create16BPPPaletteShaded((*hVObject)->pPaletteEntry, 100, 100, 100, FALSE);
for (UINT32 uiCount = 0; uiCount < 256; uiCount++)
{
Pal[uiCount].peRed = (UINT8)(uiCount % 128) + 128;
Pal[uiCount].peGreen = (UINT8)(uiCount % 128) + 128;
Pal[uiCount].peBlue = (UINT8)(uiCount % 128) + 128;
}
(*hVObject)->pShades[FLASH_PORTRAIT_GRAYSHADE] = Create16BPPPaletteShaded(Pal, 255, 255, 255, FALSE);
}
INT32 InternalInitFace( UINT8 usMercProfileID, UINT8 ubSoldierID, UINT32 uiInitFlags, INT32 iFaceFileID, UINT32 uiBlinkFrequency, UINT32 uiExpressionFrequency )
{
@@ -167,7 +194,6 @@ INT32 InternalInitFace( UINT8 usMercProfileID, UINT8 ubSoldierID, UINT32 uiInitF
ETRLEObject ETRLEObject;
HVOBJECT hVObject;
UINT32 uiCount;
SGPPaletteEntry Pal[256];
if( ( iFaceIndex = GetFreeFace() )==(-1) )
return(-1);
@@ -436,33 +462,11 @@ INT32 InternalInitFace( UINT8 usMercProfileID, UINT8 ubSoldierID, UINT32 uiInitF
// Set palette
if( GetVideoObject( &hVObject, uiVideoObject ) )
if (GetVideoObject(&hVObject, uiVideoObject))
{
// Build a grayscale palette! ( for testing different looks )
for(uiCount=0; uiCount < 256; uiCount++)
{
Pal[uiCount].peRed=255;
Pal[uiCount].peGreen=255;
Pal[uiCount].peBlue=255;
}
hVObject->pShades[ FLASH_PORTRAIT_NOSHADE ] = Create16BPPPaletteShaded( hVObject->pPaletteEntry, 255, 255, 255, FALSE );
hVObject->pShades[ FLASH_PORTRAIT_STARTSHADE ] = Create16BPPPaletteShaded( Pal, 255, 255, 255, FALSE );
hVObject->pShades[ FLASH_PORTRAIT_ENDSHADE ] = Create16BPPPaletteShaded( hVObject->pPaletteEntry, 250, 25, 25, TRUE );
hVObject->pShades[ FLASH_PORTRAIT_DARKSHADE ] = Create16BPPPaletteShaded( hVObject->pPaletteEntry, 100, 100, 100, TRUE );
hVObject->pShades[ FLASH_PORTRAIT_LITESHADE ] = Create16BPPPaletteShaded( hVObject->pPaletteEntry, 100, 100, 100, FALSE );
for(uiCount=0; uiCount < 256; uiCount++)
{
Pal[uiCount].peRed=(UINT8)(uiCount%128)+128;
Pal[uiCount].peGreen=(UINT8)(uiCount%128)+128;
Pal[uiCount].peBlue=(UINT8)(uiCount%128)+128;
}
hVObject->pShades[ FLASH_PORTRAIT_GRAYSHADE ] = Create16BPPPaletteShaded( Pal, 255, 255, 255, FALSE );
SetPalettes(&hVObject, uiVideoObject);
}
// Get FACE height, width
if( GetVideoObjectETRLEPropertiesFromIndex( uiVideoObject, &ETRLEObject, 0 ) == FALSE )
{
@@ -942,9 +946,13 @@ void BlinkAutoFace( INT32 iFaceIndex )
{
pFace = &gFacesData[ iFaceIndex ];
UINT32 uiFaceShade = FLASH_PORTRAIT_NOSHADE;
// CHECK IF BUDDY IS DEAD, UNCONSCIOUS, ASLEEP, OR POW!
if ( pFace->ubSoldierID != NOBODY )
{
uiFaceShade = GetFaceShade(MercPtrs[pFace->ubSoldierID], pFace, FALSE);
if ( ( MercPtrs[ pFace->ubSoldierID ]->stats.bLife < OKLIFE ) ||
( MercPtrs[ pFace->ubSoldierID ]->flags.fMercAsleep == TRUE ) ||
( MercPtrs[ pFace->ubSoldierID ]->bAssignment == ASSIGNMENT_POW ) )
@@ -1043,8 +1051,7 @@ void BlinkAutoFace( INT32 iFaceIndex )
}
HandleRenderFaceAdjustments( pFace, TRUE, FALSE, 0, pFace->usFaceX, pFace->usFaceY, pFace->usEyesX, pFace->usEyesY );
HandleRenderFaceAdjustments(pFace, TRUE, FALSE, 0, pFace->usFaceX, pFace->usFaceY, pFace->usEyesX, pFace->usEyesY, uiFaceShade);
}
}
@@ -1228,7 +1235,15 @@ void MouthAutoFace( INT32 iFaceIndex )
}
HandleRenderFaceAdjustments( pFace, TRUE, FALSE, 0, pFace->usFaceX, pFace->usFaceY, pFace->usEyesX, pFace->usEyesY );
UINT32 uiFaceShade = FLASH_PORTRAIT_NOSHADE;
// Set shade
if (pFace->ubSoldierID != NOBODY)
{
uiFaceShade = GetFaceShade(MercPtrs[pFace->ubSoldierID], pFace, FALSE);
}
HandleRenderFaceAdjustments( pFace, TRUE, FALSE, 0, pFace->usFaceX, pFace->usFaceY, pFace->usEyesX, pFace->usEyesY, uiFaceShade);
}
}
@@ -1317,32 +1332,38 @@ void HandleTalkingAutoFace( INT32 iFaceIndex )
// Local function - uses these variables because they have already been validated
void SetFaceShade( SOLDIERTYPE *pSoldier, FACETYPE *pFace, BOOLEAN fExternBlit )
void SetFaceShade(FACETYPE *pFace, UINT32 uiFaceShade)
{
// Set to default
SetObjectHandleShade( pFace->uiVideoObject, FLASH_PORTRAIT_NOSHADE );
SetObjectHandleShade(pFace->uiVideoObject, uiFaceShade);
}
if ( pFace->iVideoOverlay == -1 && !fExternBlit )
UINT32 GetFaceShade(SOLDIERTYPE *pSoldier, FACETYPE *pFace, BOOLEAN fExternBlit)
{
if (pFace->iVideoOverlay == -1 && !fExternBlit)
{
if ( ( pSoldier->bActionPoints == 0 ) && !( gTacticalStatus.uiFlags & REALTIME ) && (gTacticalStatus.uiFlags & INCOMBAT ) )
if ((pSoldier->bActionPoints == 0) && !(gTacticalStatus.uiFlags & REALTIME) && (gTacticalStatus.uiFlags & INCOMBAT))
{
SetObjectHandleShade( pFace->uiVideoObject, FLASH_PORTRAIT_LITESHADE );
return FLASH_PORTRAIT_LITESHADE;
}
}
if ( pSoldier->stats.bLife < OKLIFE )
if (pSoldier->stats.bLife < OKLIFE)
{
SetObjectHandleShade( pFace->uiVideoObject, FLASH_PORTRAIT_DARKSHADE );
return FLASH_PORTRAIT_DARKSHADE;
}
// ATE: Don't shade for damage if blitting extern face...
if ( !fExternBlit )
if (!fExternBlit)
{
if ( pSoldier->flags.fFlashPortrait == FLASH_PORTRAIT_START )
if (pSoldier->flags.fFlashPortrait == FLASH_PORTRAIT_START)
{
SetObjectHandleShade( pFace->uiVideoObject, pSoldier->bFlashPortraitFrame );
return pSoldier->bFlashPortraitFrame;
}
}
// Set to default
return FLASH_PORTRAIT_NOSHADE;
}
BOOLEAN RenderAutoFaceFromSoldier( UINT8 ubSoldierID )
@@ -1450,45 +1471,46 @@ void DoRightIcon_legion_GAS_MASK( UINT32 uiRenderBuffer, FACETYPE *pFace, INT16
}
*/
void GetXYForRightIconPlacement_FaceGera( FACETYPE *pFace, UINT16 ubIndex, INT16 sFaceX, INT16 sFaceY, INT16 *psX, INT16 *psY, INT8 bNumIcons , UINT32 uIDFaceGear, BOOLEAN isIMP)
void GetXYForRightIconPlacement_FaceGear(FACETYPE *pFace, UINT16 ubIndex, INT16 sFaceX, INT16 sFaceY, INT16 *psX, INT16 *psY, INT8 bNumIcons, UINT32 uiFaceGearIndex, UINT32 uiFaceShade)
{
INT16 sX, sY;
UINT16 usWidth, usHeight;
ETRLEObject *pTrav;
HVOBJECT hVObject;
ETRLEObject *pTrav;
HVOBJECT hVObject = nullptr;
// Get height, width of icon...
if (isIMP)
GetVideoObject( &hVObject, zNewFaceGearIMP[uIDFaceGear].uiIndex );
else
GetVideoObject( &hVObject, zNewFaceGear[uIDFaceGear].uiIndex );
pTrav = &(hVObject->pETRLEObject[ ubIndex ] );
usHeight = pTrav->usHeight;
usWidth = pTrav->usWidth;
if (GetVideoObject(&hVObject, uiFaceGearIndex))
{
SetPalettes(&hVObject, uiFaceGearIndex);
}
sX = sFaceX + ( usWidth * bNumIcons );
SetObjectShade(hVObject, uiFaceShade);
pTrav = &(hVObject->pETRLEObject[ubIndex]);
usHeight = pTrav->usHeight;
usWidth = pTrav->usWidth;
sX = sFaceX + (usWidth * bNumIcons);
sY = sFaceY + pFace->usFaceHeight - usHeight;
*psX = sX;
*psY = sY;
}
void DoRightIcon_FaceGear( UINT32 uiRenderBuffer, FACETYPE *pFace, INT16 sFaceX, INT16 sFaceY, INT8 bNumIcons, UINT8 sIconIndex , UINT32 uIDFaceGear, BOOLEAN isIMP)
void DoRightIcon_FaceGear(UINT32 uiRenderBuffer, FACETYPE *pFace, INT16 sFaceX, INT16 sFaceY, INT8 bNumIcons, UINT8 sIconIndex, UINT32 uIDFaceGear, BOOLEAN isIMP, UINT32 uiFaceShade)
{
INT16 sIconX, sIconY;
INT16 sIconX, sIconY;
// Find X, y for placement
if (isIMP)
{
GetXYForRightIconPlacement_FaceGera( pFace, sIconIndex, sFaceX, sFaceY, &sIconX, &sIconY, bNumIcons , uIDFaceGear,isIMP);
BltVideoObjectFromIndex( uiRenderBuffer, zNewFaceGearIMP[uIDFaceGear].uiIndex, sIconIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL );
GetXYForRightIconPlacement_FaceGear(pFace, sIconIndex, sFaceX, sFaceY, &sIconX, &sIconY, bNumIcons, zNewFaceGearIMP[uIDFaceGear].uiIndex, uiFaceShade);
BltVideoObjectFromIndex(uiRenderBuffer, zNewFaceGearIMP[uIDFaceGear].uiIndex, sIconIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL);
}
else
{
GetXYForRightIconPlacement_FaceGera( pFace, sIconIndex, sFaceX, sFaceY, &sIconX, &sIconY, bNumIcons , uIDFaceGear,isIMP);
BltVideoObjectFromIndex( uiRenderBuffer, zNewFaceGear[uIDFaceGear].uiIndex, sIconIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL );
GetXYForRightIconPlacement_FaceGear(pFace, sIconIndex, sFaceX, sFaceY, &sIconX, &sIconY, bNumIcons, zNewFaceGear[uIDFaceGear].uiIndex, uiFaceShade);
BltVideoObjectFromIndex(uiRenderBuffer, zNewFaceGear[uIDFaceGear].uiIndex, sIconIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL);
}
}
//----------------------------------------------------------------
@@ -1548,7 +1570,7 @@ void DoRightIcon( UINT32 uiRenderBuffer, FACETYPE *pFace, INT16 sFaceX, INT16 sF
}
void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLEAN fUseExternBuffer, UINT32 uiBuffer, INT16 sFaceX, INT16 sFaceY, UINT16 usEyesX, UINT16 usEyesY )
void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLEAN fUseExternBuffer, UINT32 uiBuffer, INT16 sFaceX, INT16 sFaceY, UINT16 usEyesX, UINT16 usEyesY, UINT32 uiFaceShade)
{
INT16 sIconX, sIconY;
INT16 sIconIndex = -1;
@@ -1612,6 +1634,190 @@ void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLE
{
pSoldier = MercPtrs[ pFace->ubSoldierID ];
UINT8 faceProfileId = gMercProfiles[pSoldier->ubProfile].ubFaceIndex;
BOOLEAN isIMP = gMercProfiles[pSoldier->ubProfile].Type == PROFILETYPE_IMP;
if (gGameSettings.fOptions[TOPTION_SHOW_TACTICAL_FACE_GEAR] && MercPtrs[pFace->ubSoldierID]->stats.bLife > 0 && !(pFace->uiFlags & FACE_BIGFACE))
{
if (MercPtrs[pFace->ubSoldierID]->inv[HELMETPOS].usItem > 0)
{
uiFaceItemOne = MercPtrs[pFace->ubSoldierID]->inv[HELMETPOS].usItem;
if (uiFaceItemOne != NONE && zNewFaceGear[uiFaceItemOne].Type == 1) //back
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceItemOne, isIMP, uiFaceShade);
}
}
// this section chooses the pictures for gas mask and NV goggles if the ini setting "SHOW_TACTICAL_FACE_GEAR" is TRUE
// and the merc actually wears something to be shown
if (MercPtrs[pFace->ubSoldierID]->inv[HEAD1POS].usItem + MercPtrs[pFace->ubSoldierID]->inv[HEAD2POS].usItem > 0)
{
// WANNE: Removed the limitation
// silversurfer: don't overwrite icons if they shall be shown!
//if ( !gGameSettings.fOptions[ SHOW_TACTICAL_FACE_ICONS ] )
{
uiFaceItemOne = MercPtrs[pFace->ubSoldierID]->inv[HEAD1POS].usItem;
uiFaceItemTwo = MercPtrs[pFace->ubSoldierID]->inv[HEAD2POS].usItem;
uiFaceOne = MercPtrs[pFace->ubSoldierID]->inv[HEAD1POS].usItem;
uiFaceTwo = MercPtrs[pFace->ubSoldierID]->inv[HEAD2POS].usItem;
// check first face slot
if (uiFaceItemOne != NONE)
{
if (zNewFaceGear[uiFaceOne].Type == 3)
{
uiFaceItemOne = 1;
}
else if (zNewFaceGear[uiFaceOne].Type == 4)
{
uiFaceItemOne = 2;
}
else uiFaceItemOne = 0;
}
// check second face slot
if (uiFaceItemTwo != NONE)
{
if (zNewFaceGear[uiFaceTwo].Type == 3)
{
uiFaceItemTwo = 21;
}
else if (zNewFaceGear[uiFaceTwo].Type == 4)
{
uiFaceItemTwo = 42;
}
else uiFaceItemTwo = 0;
}
// Now select the correct picture. This uses a matrix from uiFaceOneItem and uiFaceTwoItem (simple addition)
// the numbers on the outer border are used if that is the only item worn in that slot
//
// 21 42 63 84
// face slot 1 \ slot 2 gas mask | NV goggles | sun goggles | extended ear
// 1 gas mask -- 43 64 85
// 2 NV goggles 23 -- -- 86
// 3 sun goggles 24 -- -- 87
// 4 extended ear 25 46 67 --
//
// this matrix leaves room for expansion
// we only need a few of the matrix' values this time because we only show gas mask or NV goggles pictures
ubFaceItemsCombined = uiFaceItemOne + uiFaceItemTwo;
}
// WANNE: Removed silversurfers limitation, because it is too complex for the players :)
// silversurfer: we don't want to display icons for gas mask or NV goggles because you can actually see the merc wearing the gear
// in case of gas mask together with NV we display the picture of the item in face slot 1 and the icon of the item
// in face slot 2 (if icons are allowed)
//Type : 3 - gas mask ; 4 - NV googles
// gas mask only
if (ubFaceItemsCombined == 1 || ubFaceItemsCombined == 21)
{
if (zNewFaceGear[uiFaceOne].Type == 3)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP, uiFaceShade);
}
else if (zNewFaceGear[uiFaceTwo].Type == 3)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP, uiFaceShade);
}
}
// NV goggles only
if (ubFaceItemsCombined == 2 || ubFaceItemsCombined == 42)
{
if (zNewFaceGear[uiFaceOne].Type == 4)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP, uiFaceShade);
}
else if (zNewFaceGear[uiFaceTwo].Type == 4)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP, uiFaceShade);
}
}
// NV goggles + gas mask
if (ubFaceItemsCombined == 23)
{
if (zNewFaceGear[uiFaceOne].Type == 4 && zNewFaceGear[uiFaceTwo].Type == 3)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP, uiFaceShade);
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP, uiFaceShade);
}
}
// gas mask + NV goggles
if (ubFaceItemsCombined == 43)
{
if (zNewFaceGear[uiFaceOne].Type == 3 && zNewFaceGear[uiFaceTwo].Type == 4)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP, uiFaceShade);
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP, uiFaceShade);
}
}
// gas mask + extended ear
if (ubFaceItemsCombined == 24 || ubFaceItemsCombined == 64)
{
if (zNewFaceGear[uiFaceOne].Type == 3)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP, uiFaceShade);
}
else if (zNewFaceGear[uiFaceTwo].Type == 3)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP, uiFaceShade);
}
}
// gas mask + extended ear
if (ubFaceItemsCombined == 25 || ubFaceItemsCombined == 85)
{
if (zNewFaceGear[uiFaceOne].Type == 3)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP, uiFaceShade);
}
else if (zNewFaceGear[uiFaceTwo].Type == 3)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP, uiFaceShade);
}
}
// NV goggles + extended ear
if (ubFaceItemsCombined == 46 || ubFaceItemsCombined == 86)
{
if (zNewFaceGear[uiFaceOne].Type == 4)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP, uiFaceShade);
}
else if (zNewFaceGear[uiFaceTwo].Type == 4)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP, uiFaceShade);
}
}
}
if (MercPtrs[pFace->ubSoldierID]->inv[HELMETPOS].usItem > 0)
// dirty hack for IMPs because they don't have pictures for face gear
// && ( MercPtrs[ pFace->ubSoldierID ]->ubProfile < 51 || MercPtrs[ pFace->ubSoldierID ]->ubProfile > 56 )
{
uiFaceItemOne = MercPtrs[pFace->ubSoldierID]->inv[HELMETPOS].usItem;
if (uiFaceItemOne != NONE)
{
if (uiFaceItemOne != NONE && zNewFaceGear[uiFaceItemOne].Type == 2) //front
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceItemOne, isIMP, uiFaceShade);
}
}
}
//------------------------------------end of tactical face gear-----------------------------
}
if ( (MercPtrs[pFace->ubSoldierID]->stats.bLife < CONSCIOUSNESS || MercPtrs[pFace->ubSoldierID]->flags.fDeadPanel ) )
{
// Blit Closed eyes here!
@@ -1707,34 +1913,6 @@ void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLE
// Blit hatch!
BltVideoObjectFromIndex( uiRenderBuffer, guiHATCH, 0, sFaceX, sFaceY, VO_BLT_SRCTRANSPARENCY, NULL );
}
if ( !pFace->fDisabled && !pFace->fInvalidAnim )
{
// Render text above here if that's what was asked for
if ( pFace->fDisplayTextOver != FACE_NO_TEXT_OVER )
{
SetFont( TINYFONT1 );
SetFontBackground( FONT_MCOLOR_BLACK );
SetFontForeground( FONT_MCOLOR_WHITE );
SetFontDestBuffer( uiRenderBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE );
VarFindFontCenterCoordinates( sFaceX, sFaceY, pFace->usFaceWidth, pFace->usFaceHeight, TINYFONT1, &sFontX, &sFontY, pFace->zDisplayText );
if ( pFace->fDisplayTextOver == FACE_DRAW_TEXT_OVER )
{
gprintfinvalidate( sFontX, sFontY, pFace->zDisplayText );
mprintf( sFontX, sFontY, pFace->zDisplayText );
}
else if ( pFace->fDisplayTextOver == FACE_ERASE_TEXT_OVER )
{
gprintfRestore( sFontX, sFontY, pFace->zDisplayText );
pFace->fDisplayTextOver = FACE_NO_TEXT_OVER;
}
SetFontDestBuffer( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE );
}
}
}
// sevenfm: only show for alive soldiers, no face icons for big faces
@@ -1760,15 +1938,6 @@ void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLE
//------------------------------------Legion 2 by jazz--------------------------------
UINT8 faceProfileId = gMercProfiles[MercPtrs[pFace->ubSoldierID]->ubProfile].ubFaceIndex;
BOOLEAN isIMP = FALSE;
//IMP
if (gMercProfiles[MercPtrs[pFace->ubSoldierID]->ubProfile].Type == PROFILETYPE_IMP)
{
isIMP = TRUE;
}
// rewritten by silversurfer
// this section chooses the icons for face gear if the ini setting "SHOW_TACTICAL_FACE_ICONS" is TRUE
// and the merc actually wears something to be shown
@@ -1883,187 +2052,6 @@ void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLE
}
}
if (gGameSettings.fOptions[TOPTION_SHOW_TACTICAL_FACE_GEAR])
{
if (MercPtrs[pFace->ubSoldierID]->inv[HELMETPOS].usItem > 0)
{
uiFaceItemOne = MercPtrs[pFace->ubSoldierID]->inv[HELMETPOS].usItem;
if (uiFaceItemOne != NONE && zNewFaceGear[uiFaceItemOne].Type == 1) //back
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceItemOne, isIMP);
}
}
// this section chooses the pictures for gas mask and NV goggles if the ini setting "SHOW_TACTICAL_FACE_GEAR" is TRUE
// and the merc actually wears something to be shown
if (MercPtrs[pFace->ubSoldierID]->inv[HEAD1POS].usItem + MercPtrs[pFace->ubSoldierID]->inv[HEAD2POS].usItem > 0)
{
// WANNE: Removed the limitation
// silversurfer: don't overwrite icons if they shall be shown!
//if ( !gGameSettings.fOptions[ SHOW_TACTICAL_FACE_ICONS ] )
{
uiFaceItemOne = MercPtrs[pFace->ubSoldierID]->inv[HEAD1POS].usItem;
uiFaceItemTwo = MercPtrs[pFace->ubSoldierID]->inv[HEAD2POS].usItem;
uiFaceOne = MercPtrs[pFace->ubSoldierID]->inv[HEAD1POS].usItem;
uiFaceTwo = MercPtrs[pFace->ubSoldierID]->inv[HEAD2POS].usItem;
// check first face slot
if (uiFaceItemOne != NONE)
{
if (zNewFaceGear[uiFaceOne].Type == 3)
{
uiFaceItemOne = 1;
}
else if (zNewFaceGear[uiFaceOne].Type == 4)
{
uiFaceItemOne = 2;
}
else uiFaceItemOne = 0;
}
// check second face slot
if (uiFaceItemTwo != NONE)
{
if (zNewFaceGear[uiFaceTwo].Type == 3)
{
uiFaceItemTwo = 21;
}
else if (zNewFaceGear[uiFaceTwo].Type == 4)
{
uiFaceItemTwo = 42;
}
else uiFaceItemTwo = 0;
}
// Now select the correct picture. This uses a matrix from uiFaceOneItem and uiFaceTwoItem (simple addition)
// the numbers on the outer border are used if that is the only item worn in that slot
//
// 21 42 63 84
// face slot 1 \ slot 2 gas mask | NV goggles | sun goggles | extended ear
// 1 gas mask -- 43 64 85
// 2 NV goggles 23 -- -- 86
// 3 sun goggles 24 -- -- 87
// 4 extended ear 25 46 67 --
//
// this matrix leaves room for expansion
// we only need a few of the matrix' values this time because we only show gas mask or NV goggles pictures
ubFaceItemsCombined = uiFaceItemOne + uiFaceItemTwo;
}
// WANNE: Removed silversurfers limitation, because it is too complex for the players :)
// silversurfer: we don't want to display icons for gas mask or NV goggles because you can actually see the merc wearing the gear
// in case of gas mask together with NV we display the picture of the item in face slot 1 and the icon of the item
// in face slot 2 (if icons are allowed)
//Type : 3 - gas mask ; 4 - NV googles
// gas mask only
if (ubFaceItemsCombined == 1 || ubFaceItemsCombined == 21)
{
if (zNewFaceGear[uiFaceOne].Type == 3)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP);
}
else if (zNewFaceGear[uiFaceTwo].Type == 3)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP);
}
}
// NV goggles only
if (ubFaceItemsCombined == 2 || ubFaceItemsCombined == 42)
{
if (zNewFaceGear[uiFaceOne].Type == 4)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP);
}
else if (zNewFaceGear[uiFaceTwo].Type == 4)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP);
}
}
// NV goggles + gas mask
if (ubFaceItemsCombined == 23)
{
if (zNewFaceGear[uiFaceOne].Type == 4 && zNewFaceGear[uiFaceTwo].Type == 3)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP);
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP);
}
}
// gas mask + NV goggles
if (ubFaceItemsCombined == 43)
{
if (zNewFaceGear[uiFaceOne].Type == 3 && zNewFaceGear[uiFaceTwo].Type == 4)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP);
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP);
}
}
// gas mask + extended ear
if (ubFaceItemsCombined == 24 || ubFaceItemsCombined == 64)
{
if (zNewFaceGear[uiFaceOne].Type == 3)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP);
}
else if (zNewFaceGear[uiFaceTwo].Type == 3)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP);
}
}
// gas mask + extended ear
if (ubFaceItemsCombined == 25 || ubFaceItemsCombined == 85)
{
if (zNewFaceGear[uiFaceOne].Type == 3)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP);
}
else if (zNewFaceGear[uiFaceTwo].Type == 3)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP);
}
}
// NV goggles + extended ear
if (ubFaceItemsCombined == 46 || ubFaceItemsCombined == 86)
{
if (zNewFaceGear[uiFaceOne].Type == 4)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP);
}
else if (zNewFaceGear[uiFaceTwo].Type == 4)
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP);
}
}
}
if (MercPtrs[pFace->ubSoldierID]->inv[HELMETPOS].usItem > 0)
// dirty hack for IMPs because they don't have pictures for face gear
// && ( MercPtrs[ pFace->ubSoldierID ]->ubProfile < 51 || MercPtrs[ pFace->ubSoldierID ]->ubProfile > 56 )
{
uiFaceItemOne = MercPtrs[pFace->ubSoldierID]->inv[HELMETPOS].usItem;
if (uiFaceItemOne != NONE)
{
if (uiFaceItemOne != NONE && zNewFaceGear[uiFaceItemOne].Type == 2) //front
{
DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceItemOne, isIMP);
}
}
}
//------------------------------------end of tactical face gear-----------------------------
}
// If blind...
if (MercPtrs[pFace->ubSoldierID]->bBlindedCounter > 0)
{
@@ -2542,6 +2530,37 @@ void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLE
}
}
}
if (!(pFace->uiFlags & FACE_INACTIVE_HANDLED_ELSEWHERE) || fUseExternBuffer)
{
if (!pFace->fDisabled && !pFace->fInvalidAnim)
{
// Render text above here if that's what was asked for
if (pFace->fDisplayTextOver != FACE_NO_TEXT_OVER)
{
SetFont(TINYFONT1);
SetFontBackground(FONT_MCOLOR_BLACK);
SetFontForeground(FONT_MCOLOR_WHITE);
SetFontDestBuffer(uiRenderBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE);
VarFindFontCenterCoordinates(sFaceX, sFaceY, pFace->usFaceWidth, pFace->usFaceHeight, TINYFONT1, &sFontX, &sFontY, pFace->zDisplayText);
if (pFace->fDisplayTextOver == FACE_DRAW_TEXT_OVER)
{
gprintfinvalidate(sFontX, sFontY, pFace->zDisplayText);
mprintf(sFontX, sFontY, pFace->zDisplayText);
}
else if (pFace->fDisplayTextOver == FACE_ERASE_TEXT_OVER)
{
gprintfRestore(sFontX, sFontY, pFace->zDisplayText);
pFace->fDisplayTextOver = FACE_NO_TEXT_OVER;
}
SetFontDestBuffer(FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE);
}
}
}
}
else
{
@@ -2601,10 +2620,13 @@ BOOLEAN RenderAutoFace( INT32 iFaceIndex )
// Check for disabled guy!
CHECKF( pFace->fDisabled != TRUE );
UINT32 uiFaceShade = FLASH_PORTRAIT_NOSHADE;
// Set shade
if ( pFace->ubSoldierID != NOBODY )
{
SetFaceShade( MercPtrs[ pFace->ubSoldierID ], pFace, FALSE );
uiFaceShade = GetFaceShade(MercPtrs[pFace->ubSoldierID], pFace, FALSE);
SetFaceShade(pFace, uiFaceShade);
}
// Blit face to save buffer!
@@ -2620,7 +2642,7 @@ BOOLEAN RenderAutoFace( INT32 iFaceIndex )
}
}
HandleRenderFaceAdjustments( pFace, FALSE, FALSE, 0, pFace->usFaceX, pFace->usFaceY, pFace->usEyesX, pFace->usEyesY );
HandleRenderFaceAdjustments(pFace, FALSE, FALSE, 0, pFace->usFaceX, pFace->usFaceY, pFace->usEyesX, pFace->usEyesY, uiFaceShade);
// Restore extern rect
if ( pFace->uiAutoRestoreBuffer == guiSAVEBUFFER )
@@ -2664,9 +2686,11 @@ BOOLEAN ExternRenderFace( UINT32 uiBuffer, INT32 iFaceIndex, INT16 sX, INT16 sY
// Here, any face can be rendered, even if disabled
// Set shade
UINT32 uiFaceShade = FLASH_PORTRAIT_NOSHADE;
if ( pFace->ubSoldierID != NOBODY )
{
SetFaceShade( MercPtrs[ pFace->ubSoldierID ], pFace , TRUE );
uiFaceShade = GetFaceShade(MercPtrs[pFace->ubSoldierID], pFace, TRUE);
SetFaceShade(pFace, uiFaceShade);
}
// Blit face to save buffer!
@@ -2674,7 +2698,7 @@ BOOLEAN ExternRenderFace( UINT32 uiBuffer, INT32 iFaceIndex, INT16 sX, INT16 sY
GetFaceRelativeCoordinates( pFace, &usEyesX, &usEyesY, &usMouthX, &usMouthY );
HandleRenderFaceAdjustments( pFace, FALSE, TRUE, uiBuffer, sX, sY, ( UINT16)( sX + usEyesX ), ( UINT16)( sY + usEyesY ) );
HandleRenderFaceAdjustments(pFace, FALSE, TRUE, uiBuffer, sX, sY, (UINT16)(sX + usEyesX), ( UINT16)(sY + usEyesY), uiFaceShade);
// Restore extern rect
if ( uiBuffer == guiSAVEBUFFER )
+2 -3
View File
@@ -2187,7 +2187,7 @@ void HandleSoldierThrowItem( SOLDIERTYPE *pSoldier, INT32 sGridNo )
pSoldier->usPendingAnimation = LOB_ITEM;
}
// Draw item depending on distance from buddy
else if ( GetRangeFromGridNoDiff( sGridNo, pSoldier->sGridNo ) < MIN_LOB_RANGE )
else if (PythSpacesAway( sGridNo, pSoldier->sGridNo ) < MIN_LOB_RANGE )
{
//ddd maybe need to add check for throwing item class - grenade
if( (pSoldier->pThrowParams->ubActionCode == THROW_ARM_ITEM) &&
@@ -5919,8 +5919,7 @@ void SetOffBoobyTrap( ITEM_POOL * pItemPool )
if ( pItemPool )
{
INT16 sX, sY;
sX = CenterX( pItemPool->sGridNo );
sY = CenterY( pItemPool->sGridNo );
ConvertGridNoToCenterCellXY(pItemPool->sGridNo, &sX, &sY);
IgniteExplosion( NOBODY, sX, sY, (INT16) (gpWorldLevelData[pItemPool->sGridNo].sHeight + pItemPool->bRenderZHeightAboveLevel), pItemPool->sGridNo, MINI_GRENADE, 0 );
RemoveItemFromPool( pItemPool->sGridNo, pItemPool->iItemIndex, pItemPool->ubLevel );
}
+2 -2
View File
@@ -5619,7 +5619,7 @@ UINT32 UIHandleTOnTerrain( UI_EVENT *pUIEvent )
sTargetGridNo = MercPtrs[ ubTargID ]->sGridNo;
}
uiRange = GetRangeFromGridNoDiff( pSoldier->sGridNo, sTargetGridNo );
uiRange = PythSpacesAway( pSoldier->sGridNo, sTargetGridNo );
if ( uiRange <= NPC_TALK_RADIUS )
@@ -6610,7 +6610,7 @@ BOOLEAN HandleTalkInit( )
}
// Check distance
uiRange = GetRangeFromGridNoDiff( pSoldier->sGridNo, usMapPos );
uiRange = PythSpacesAway( pSoldier->sGridNo, usMapPos );
// Double check path
if ( GetCivType( pTSoldier ) != CIV_TYPE_NA )
+10 -4
View File
@@ -1827,7 +1827,7 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum
EXITGRID ExitGrid;
INT32 iRandom = 0;
UINT8 ubMineIndex;
INT16 sX, sY, sX2, sY2;
pSoldier2 = NULL;
//ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Handling %s, action %d at %ld", gMercProfiles[ ubTargetNPC ].zNickname, usActionCode, GetJA2Clock() );
@@ -1840,7 +1840,9 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum
if (pSoldier && pSoldier2)
{
// see if we are facing this person
ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(pSoldier2->sGridNo),CenterY(pSoldier2->sGridNo));
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
ConvertGridNoToCenterCellXY(pSoldier2->sGridNo, &sX2, &sY2);
ubDesiredMercDir = atan8(sX, sY, sX2, sY2);
// if not already facing in that direction,
if (pSoldier->ubDirection != ubDesiredMercDir)
{
@@ -2317,7 +2319,9 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum
if (!TileIsOutOfBounds(sGridNo))
{
// see if we are facing this person
ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sGridNo),CenterY(sGridNo));
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
ConvertGridNoToCenterCellXY(sGridNo, &sX2, &sY2);
ubDesiredMercDir = atan8(sX, sY, sX2, sY2);
// if not already facing in that direction,
if (pSoldier->ubDirection != ubDesiredMercDir)
{
@@ -5632,7 +5636,9 @@ void HandleRaulBlowingHimselfUp()
//blow himself up with, hmmm, lets say TNT. :)
usItem = HAND_GRENADE;
IgniteExplosion( RAUL_UB, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, usItem, pSoldier->pathing.bLevel );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
IgniteExplosion( RAUL_UB, sX, sY, 0, pSoldier->sGridNo, usItem, pSoldier->pathing.bLevel );
SetJa25GeneralFlag( JA_GF__RAUL_BLOW_HIMSELF_UP );
}
+1 -1
View File
@@ -9570,7 +9570,7 @@ BOOLEAN HandleItemPointerClick( INT32 usMapPos )
BOOLEAN ItemCursorInLobRange( INT32 usMapPos )
{
// Draw item depending on distance from buddy
if ( GetRangeFromGridNoDiff( usMapPos, gpItemPointerSoldier->sGridNo ) > MIN_LOB_RANGE )
if (PythSpacesAway( usMapPos, gpItemPointerSoldier->sGridNo ) > MIN_LOB_RANGE )
{
return( FALSE );
}
+8 -6
View File
@@ -2478,14 +2478,16 @@ BOOLEAN DrawCTHIndicator()
//////////////////////////////////
// Calculate Aperture
INT16 sX, sY;
// Calculate the center point of the shooter, in world coordinates.
FLOAT dStartX = (FLOAT) CenterX( gCTHDisplay.iShooterGridNo );
FLOAT dStartY = (FLOAT) CenterY( gCTHDisplay.iShooterGridNo );
ConvertGridNoToCenterCellXY(gCTHDisplay.iShooterGridNo, &sX, &sY);
FLOAT dStartX = (FLOAT) sX;
FLOAT dStartY = (FLOAT) sY;
// Calculate the center point of the target, in world coordinates.
FLOAT dEndX = (FLOAT) CenterX( gCTHDisplay.iTargetGridNo );
FLOAT dEndY = (FLOAT) CenterY( gCTHDisplay.iTargetGridNo );
ConvertGridNoToCenterCellXY(gCTHDisplay.iTargetGridNo, &sX, &sY);
FLOAT dEndX = (FLOAT) sX;
FLOAT dEndY = (FLOAT) sY;
// Calculate a delta: the difference between the shooter and target.
FLOAT dDeltaX = dEndX - dStartX;
@@ -6647,4 +6649,4 @@ INT16 GetBackgroundValue( UINT8 usProfile, UINT16 aNr )
}
return 0;
}
}
+10 -5
View File
@@ -9262,13 +9262,16 @@ void CheckEquipmentForDamage( SOLDIERTYPE *pSoldier, INT32 iDamage )
if (fBlowsUp)
{
// blow it up!
INT16 sX, sY;
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
if ( gTacticalStatus.ubAttackBusyCount )
{
IgniteExplosion( pSoldier->ubAttackerID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, pSoldier->inv[ bSlot ].usItem, pSoldier->pathing.bLevel, pSoldier->ubDirection, &pSoldier->inv[ bSlot ] );
IgniteExplosion( pSoldier->ubAttackerID, sX, sY, 0, pSoldier->sGridNo, pSoldier->inv[ bSlot ].usItem, pSoldier->pathing.bLevel, pSoldier->ubDirection, &pSoldier->inv[ bSlot ] );
}
else
{
IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, pSoldier->inv[ bSlot ].usItem, pSoldier->pathing.bLevel, pSoldier->ubDirection, &pSoldier->inv[ bSlot ] );
IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, pSoldier->inv[ bSlot ].usItem, pSoldier->pathing.bLevel, pSoldier->ubDirection, &pSoldier->inv[ bSlot ] );
}
//ADB when something in a stack blows up the whole stack goes, so no need to worry about number of items
@@ -9333,7 +9336,9 @@ BOOLEAN DamageItemOnGround( OBJECTTYPE * pObject, INT32 sGridNo, INT8 bLevel, IN
if ( fBlowsUp )
{
// OK, Ignite this explosion!
IgniteExplosion( ubOwner, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, pObject->usItem, bLevel, DIRECTION_IRRELEVANT, pObject );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
IgniteExplosion( ubOwner, sX, sY, 0, sGridNo, pObject->usItem, bLevel, DIRECTION_IRRELEVANT, pObject );
// SANDRO - merc records
if ( (pObject->fFlags & OBJECT_ARMED_BOMB) && ((*pObject)[0]->data.misc.ubBombOwner > 1) )
@@ -15271,7 +15276,7 @@ BOOLEAN HasItemFlag( UINT16 usItem, UINT64 aFlag )
// Flugente: get first item number that has this flag. Use with caution, as we search in all items
BOOLEAN GetFirstItemWithFlag( UINT16* pusItem, UINT64 aFlag )
{
register UINT16 i;
UINT16 i;
for ( i = 1; i < gMAXITEMS_READ; ++i )
{
if ( HasItemFlag(i, aFlag) )
@@ -15537,7 +15542,7 @@ BOOLEAN GetFirstClothesItemWithSpecificData( UINT16* pusItem, PaletteRepID aPalV
UINT32 bestclothestype = 999999;
UINT16 bestitem = 0;
register UINT16 i;
UINT16 i;
for ( i = 1; i < gMAXITEMS_READ; ++i )
{
if ( Item[i].clothestype > 0 )
+4 -3
View File
@@ -669,7 +669,9 @@ void HandleDoorTrap( SOLDIERTYPE * pSoldier, DOOR * pDoor )
{
case EXPLOSION:
// cause damage as a regular hand grenade
IgniteExplosion( NOBODY, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 25, pSoldier->sGridNo, HAND_GRENADE, 0 );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
IgniteExplosion( NOBODY, sX, sY, 25, pSoldier->sGridNo, HAND_GRENADE, 0 );
break;
case SIREN:
@@ -760,8 +762,7 @@ BOOLEAN AttemptToBlowUpLock(SOLDIERTYPE * pSoldier, DOOR * pDoor)
sGridNo = pDoor->sGridNo;
// Get sX, sy;
sX = CenterX(sGridNo);
sY = CenterY(sGridNo);
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
// Get Z position, based on orientation....
sZ = 20;
+85 -66
View File
@@ -2380,12 +2380,15 @@ INT32 SoldierToSoldierLineOfSightTest( SOLDIERTYPE * pStartSoldier, SOLDIERTYPE
UINT8 ubNumberOfTiles = pBase->pDBStructureRef->pDBStructure->ubNumberOfTiles;
INT32 sStructGridNo;
INT16 sX, sY, sX2, sY2;
ConvertGridNoToCenterCellXY(pStartSoldier->sGridNo, &sX, &sY);
// loop through all tiles
for (UINT8 ubLoop = BASE_TILE; ubLoop < ubNumberOfTiles; ubLoop++)
{
sStructGridNo = AddPosRelToBase(pBase->sGridNo, ppTile[ubLoop]);
if( LineOfSightTest( (FLOAT) CenterX( pStartSoldier->sGridNo ), (FLOAT) CenterY( pStartSoldier->sGridNo ), dStartZPos, (FLOAT) CenterX( sStructGridNo ), (FLOAT) CenterY( sStructGridNo ), dEndZPos, iTileSightLimit, bAware, fSmell, NULL, adjustForSight, cthCalc ) )
ConvertGridNoToCenterCellXY(sStructGridNo, &sX2, &sY2);
if( LineOfSightTest( (FLOAT) sX, (FLOAT) sY, dStartZPos, (FLOAT) sX2, (FLOAT) sY2, dEndZPos, iTileSightLimit, bAware, fSmell, NULL, adjustForSight, cthCalc ) )
{
return( TRUE );
}
@@ -2393,14 +2396,18 @@ INT32 SoldierToSoldierLineOfSightTest( SOLDIERTYPE * pStartSoldier, SOLDIERTYPE
return( FALSE );
}
return( LineOfSightTest( (FLOAT) CenterX( pStartSoldier->sGridNo ), (FLOAT) CenterY( pStartSoldier->sGridNo ), dStartZPos, (FLOAT) CenterX( pEndSoldier->sGridNo ), (FLOAT) CenterY( pEndSoldier->sGridNo ), dEndZPos, iTileSightLimit, bAware, fSmell, NULL, adjustForSight, cthCalc ) );
INT16 sX, sY, sX2, sY2;
ConvertGridNoToCenterCellXY(pStartSoldier->sGridNo, &sX, &sY);
ConvertGridNoToCenterCellXY(pEndSoldier->sGridNo, &sX2, &sY2);
return( LineOfSightTest( (FLOAT) sX, (FLOAT) sY, dStartZPos, (FLOAT) sX2, (FLOAT) sY2, dEndZPos, iTileSightLimit, bAware, fSmell, NULL, adjustForSight, cthCalc ) );
}
INT32 SoldierToLocationWindowTest( SOLDIERTYPE * pStartSoldier, INT32 sEndGridNo )
{
// figure out if there is a SINGLE window between the looker and target
FLOAT dStartZPos, dEndZPos;
INT16 sXPos, sYPos;
INT16 sX, sY, sX2, sY2;
INT32 sWindowGridNo = NOWHERE;
INT32 iRet;
@@ -2413,24 +2420,23 @@ INT32 SoldierToLocationWindowTest( SOLDIERTYPE * pStartSoldier, INT32 sEndGridNo
dStartZPos += CONVERT_PIXELS_TO_HEIGHTUNITS( gpWorldLevelData[pStartSoldier->sGridNo].sHeight );
dEndZPos = dStartZPos;
ConvertGridNoToXY( sEndGridNo, &sXPos, &sYPos );
sXPos = sXPos * CELL_X_SIZE + (CELL_X_SIZE / 2);
sYPos = sYPos * CELL_Y_SIZE + (CELL_Y_SIZE / 2);
ConvertGridNoToCenterCellXY(pStartSoldier->sGridNo, &sX, &sY);
ConvertGridNoToCenterCellXY(sEndGridNo, &sX2, &sY2);
//ADB changed from 255 to 511 to handle new LOS test
// We don't want to consider distance limits here so pass in tile sight limit of 255( + 256)
// and consider trees as little as possible
iRet = LineOfSightTest( (FLOAT) CenterX( pStartSoldier->sGridNo ), (FLOAT) CenterY( pStartSoldier->sGridNo ), dStartZPos, (FLOAT) sXPos, (FLOAT) sYPos, dEndZPos, 511, TRUE, FALSE, &sWindowGridNo );
iRet = LineOfSightTest( (FLOAT) sX, (FLOAT) sY, dStartZPos, (FLOAT) sX2, (FLOAT) sY2, dEndZPos, 511, TRUE, FALSE, &sWindowGridNo );
return( sWindowGridNo );
}
INT32 SoldierTo3DLocationLineOfSightTest( SOLDIERTYPE * pStartSoldier, INT32 sGridNo, INT8 bLevel, INT8 bCubeLevel, INT8 bAware, int iTileSightLimit, bool adjustForSight )
{
FLOAT dStartZPos, dEndZPos;
INT16 sXPos, sYPos;
UINT8 ubTargetID;
BOOLEAN fOk;
FLOAT dStartZPos, dEndZPos;
INT16 sX, sY, sX2, sY2;
UINT8 ubTargetID;
BOOLEAN fOk;
CHECKF( pStartSoldier );
@@ -2457,9 +2463,6 @@ INT32 SoldierTo3DLocationLineOfSightTest( SOLDIERTYPE * pStartSoldier, INT32 sGr
dEndZPos += CONVERT_PIXELS_TO_HEIGHTUNITS( gpWorldLevelData[ sGridNo ].sHeight );
}
ConvertGridNoToXY( sGridNo, &sXPos, &sYPos );
sXPos = sXPos * CELL_X_SIZE + (CELL_X_SIZE / 2);
sYPos = sYPos * CELL_Y_SIZE + (CELL_Y_SIZE / 2);
if (iTileSightLimit == CALC_FROM_ALL_DIRS || iTileSightLimit == CALC_FROM_WANTED_DIR) {
iTileSightLimit = pStartSoldier->GetMaxDistanceVisible( sGridNo, bLevel, iTileSightLimit );
@@ -2468,14 +2471,17 @@ INT32 SoldierTo3DLocationLineOfSightTest( SOLDIERTYPE * pStartSoldier, INT32 sGr
iTileSightLimit = 255 + pStartSoldier->GetMaxDistanceVisible( sGridNo, bLevel, CALC_FROM_ALL_DIRS );
}
return( LineOfSightTest( (FLOAT) CenterX( pStartSoldier->sGridNo ), (FLOAT) CenterY( pStartSoldier->sGridNo ), dStartZPos, (FLOAT) sXPos, (FLOAT) sYPos, dEndZPos, iTileSightLimit, bAware, HasThermalOptics( pStartSoldier), NULL, adjustForSight ) );
ConvertGridNoToCenterCellXY(pStartSoldier->sGridNo, &sX, &sY);
ConvertGridNoToCenterCellXY(sGridNo, &sX2, &sY2);
return( LineOfSightTest( (FLOAT) sX, (FLOAT) sY, dStartZPos, (FLOAT) sX2, (FLOAT) sY2, dEndZPos, iTileSightLimit, bAware, HasThermalOptics( pStartSoldier), NULL, adjustForSight ) );
}
INT32 SoldierToVirtualSoldierLineOfSightTest( SOLDIERTYPE * pStartSoldier, INT32 sGridNo, INT8 bLevel, INT8 bStance, INT8 bAware, int iTileSightLimit )
{
FLOAT dStartZPos, dEndZPos;
INT16 sXPos, sYPos;
BOOLEAN fOk;
FLOAT dStartZPos, dEndZPos;
INT16 endXPos, endYPos, startXPos, startYPos;
BOOLEAN fOk;
CHECKF( pStartSoldier );
@@ -2504,10 +2510,6 @@ INT32 SoldierToVirtualSoldierLineOfSightTest( SOLDIERTYPE * pStartSoldier, INT32
}
ConvertGridNoToXY( sGridNo, &sXPos, &sYPos );
sXPos = sXPos * CELL_X_SIZE + (CELL_X_SIZE / 2);
sYPos = sYPos * CELL_Y_SIZE + (CELL_Y_SIZE / 2);
if (iTileSightLimit == CALC_FROM_ALL_DIRS || iTileSightLimit == CALC_FROM_WANTED_DIR) {
iTileSightLimit = pStartSoldier->GetMaxDistanceVisible( sGridNo, bLevel, iTileSightLimit );
}
@@ -2515,13 +2517,15 @@ INT32 SoldierToVirtualSoldierLineOfSightTest( SOLDIERTYPE * pStartSoldier, INT32
iTileSightLimit = 255 + pStartSoldier->GetMaxDistanceVisible( sGridNo, bLevel, CALC_FROM_ALL_DIRS );
}
return( LineOfSightTest( (FLOAT) CenterX( pStartSoldier->sGridNo ), (FLOAT) CenterY( pStartSoldier->sGridNo ), dStartZPos, (FLOAT) sXPos, (FLOAT) sYPos, dEndZPos, iTileSightLimit, bAware, HasThermalOptics( pStartSoldier), NULL, false ) );
ConvertGridNoToCenterCellXY(pStartSoldier->sGridNo, &startXPos, &startYPos);
ConvertGridNoToCenterCellXY(sGridNo, &endXPos, &endYPos);
return(LineOfSightTest((FLOAT)startXPos, (FLOAT)startYPos, dStartZPos, (FLOAT)endXPos, (FLOAT)endYPos, dEndZPos, iTileSightLimit, bAware, HasThermalOptics(pStartSoldier), NULL, false));
}
INT32 LocationToLocationLineOfSightTest( INT32 sStartGridNo, INT8 bStartLevel, INT32 sEndGridNo, INT8 bEndLevel, INT8 bAware, int iTileSightLimit, FLOAT dStartPos, FLOAT dEndPos )
{
FLOAT dStartZPos, dEndZPos;
INT16 sStartXPos, sStartYPos, sEndXPos, sEndYPos;
FLOAT dStartZPos, dEndZPos;
INT16 sStartXPos, sStartYPos, sEndXPos, sEndYPos;
// Bob: prevent access violation
if (sStartGridNo < 0) {
@@ -2544,19 +2548,11 @@ INT32 LocationToLocationLineOfSightTest( INT32 sStartGridNo, INT8 bStartLevel, I
// add in ground height
dStartZPos += CONVERT_PIXELS_TO_HEIGHTUNITS( gpWorldLevelData[ sStartGridNo ].sHeight );
ConvertGridNoToXY( sStartGridNo, &sStartXPos, &sStartYPos );
sStartXPos = sStartXPos * CELL_X_SIZE + (CELL_X_SIZE / 2);
sStartYPos = sStartYPos * CELL_Y_SIZE + (CELL_Y_SIZE / 2);
// sevenfm: use height argument
dEndZPos = dEndPos + bEndLevel * HEIGHT_UNITS;
// add in ground height
dEndZPos += CONVERT_PIXELS_TO_HEIGHTUNITS( gpWorldLevelData[ sEndGridNo ].sHeight );
ConvertGridNoToXY( sEndGridNo, &sEndXPos, &sEndYPos );
sEndXPos = sEndXPos * CELL_X_SIZE + (CELL_X_SIZE / 2);
sEndYPos = sEndYPos * CELL_Y_SIZE + (CELL_Y_SIZE / 2);
if (iTileSightLimit == CALC_FROM_ALL_DIRS || iTileSightLimit == CALC_FROM_WANTED_DIR)
{
iTileSightLimit = MaxNormalDistanceVisible();
@@ -2565,6 +2561,10 @@ INT32 LocationToLocationLineOfSightTest( INT32 sStartGridNo, INT8 bStartLevel, I
{
iTileSightLimit = 255 + MaxNormalDistanceVisible();
}
ConvertGridNoToCenterCellXY(sStartGridNo, &sStartXPos, &sStartYPos);
ConvertGridNoToCenterCellXY(sEndGridNo, &sEndXPos, &sEndYPos);
return( LineOfSightTest( (FLOAT)sStartXPos, (FLOAT)sStartYPos, dStartZPos, (FLOAT) sEndXPos, (FLOAT) sEndYPos, dEndZPos, iTileSightLimit, bAware, FALSE, NULL ) );
}
@@ -2931,20 +2931,24 @@ BOOLEAN BulletHitMerc( BULLET * pBullet, STRUCTURE * pStructure, BOOLEAN fIntend
// Flugente: we measure the distance of the bullet's location to the location of the soldier, and to the 2 gridnos his head and leg occupy
// From this we can decide what body part was hit
FLOAT bodycenterX = (FLOAT)CenterX( pTarget->sGridNo );
FLOAT bodycenterY = (FLOAT)CenterY( pTarget->sGridNo );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(pTarget->sGridNo, &sX, &sY);
FLOAT bodycenterX = (FLOAT) sX;
FLOAT bodycenterY = (FLOAT) sY;
FLOAT difftobodycenter = sqrt( (bodycenterX - x) * (bodycenterX - x) + (bodycenterY - y) * (bodycenterY - y) );
INT32 viewdirectiongridno = NewGridNo( pTarget->sGridNo, DirectionInc( pTarget->ubDirection ) );
FLOAT nextgridnocenterX = (FLOAT)CenterX( viewdirectiongridno );
FLOAT nextgridnocenterY = (FLOAT)CenterY( viewdirectiongridno );
ConvertGridNoToCenterCellXY(viewdirectiongridno, &sX, &sY);
FLOAT nextgridnocenterX = (FLOAT) sX;
FLOAT nextgridnocenterY = (FLOAT) sY;
FLOAT difftonextgridno = sqrt( (nextgridnocenterX - x) * (nextgridnocenterX - x) + (nextgridnocenterY - y) * (nextgridnocenterY - y) );
INT32 oppositeviewdirectiongridno = NewGridNo( pTarget->sGridNo, DirectionInc( gOppositeDirection[pTarget->ubDirection] ) );
FLOAT oppositenextgridnocenterX = (FLOAT)CenterX( oppositeviewdirectiongridno );
FLOAT oppositenextgridnocenterY = (FLOAT)CenterY( oppositeviewdirectiongridno );
ConvertGridNoToCenterCellXY(oppositeviewdirectiongridno, &sX, &sY);
FLOAT oppositenextgridnocenterX = (FLOAT) sX;
FLOAT oppositenextgridnocenterY = (FLOAT) sY;
FLOAT difftooppositenextgridno = sqrt( (oppositenextgridnocenterX - x) * (oppositenextgridnocenterX - x) + (oppositenextgridnocenterY - y) * (oppositenextgridnocenterY - y) );
@@ -4319,8 +4323,9 @@ UINT8 CalcChanceToGetThrough( BULLET * pBullet )
UINT8 SoldierToSoldierChanceToGetThrough( SOLDIERTYPE * pStartSoldier, SOLDIERTYPE * pEndSoldier )
{
FLOAT dEndZPos;
BOOLEAN fOk;
INT16 sX, sY;
FLOAT dEndZPos;
BOOLEAN fOk;
if (pStartSoldier == pEndSoldier)
{
@@ -4337,15 +4342,18 @@ UINT8 SoldierToSoldierChanceToGetThrough( SOLDIERTYPE * pStartSoldier, SOLDIERTY
// set startsoldier's target ID ... need an ID stored in case this
// is the AI calculating cover to a location where he might not be any more
pStartSoldier->ubCTGTTargetID = pEndSoldier->ubID;
return( ChanceToGetThrough( pStartSoldier, (FLOAT) CenterX( pEndSoldier->sGridNo ), (FLOAT) CenterY( pEndSoldier->sGridNo ), dEndZPos ) );
ConvertGridNoToCenterCellXY(pEndSoldier->sGridNo, &sX, &sY);
return( ChanceToGetThrough( pStartSoldier, (FLOAT) sX, (FLOAT) sY, dEndZPos ) );
}
UINT8 SoldierToSoldierBodyPartChanceToGetThrough( SOLDIERTYPE * pStartSoldier, SOLDIERTYPE * pEndSoldier, UINT8 ubAimLocation )
{
// does like StS-CTGT but with a particular body part in mind
FLOAT dEndZPos;
BOOLEAN fOk;
UINT8 ubPosType;
INT16 sX, sY;
FLOAT dEndZPos;
BOOLEAN fOk;
UINT8 ubPosType;
if (pStartSoldier == pEndSoldier)
{
@@ -4378,7 +4386,8 @@ UINT8 SoldierToSoldierBodyPartChanceToGetThrough( SOLDIERTYPE * pStartSoldier, S
// set startsoldier's target ID ... need an ID stored in case this
// is the AI calculating cover to a location where he might not be any more
pStartSoldier->ubCTGTTargetID = pEndSoldier->ubID;
return( ChanceToGetThrough( pStartSoldier, (FLOAT) CenterX( pEndSoldier->sGridNo ), (FLOAT) CenterY( pEndSoldier->sGridNo ), dEndZPos ) );
ConvertGridNoToCenterCellXY(pEndSoldier->sGridNo, &sX, &sY);
return( ChanceToGetThrough( pStartSoldier, (FLOAT) sX, (FLOAT) sY, dEndZPos ) );
}
UINT8 SoldierToLocationChanceToGetThrough( SOLDIERTYPE * pStartSoldier, INT32 sGridNo, INT8 bLevel, INT8 bCubeLevel, UINT8 ubTargetID )
@@ -4423,9 +4432,7 @@ UINT8 SoldierToLocationChanceToGetThrough( SOLDIERTYPE * pStartSoldier, INT32 sG
}
dEndZPos += CONVERT_PIXELS_TO_HEIGHTUNITS( gpWorldLevelData[sGridNo].sHeight );
ConvertGridNoToXY( sGridNo, &sXPos, &sYPos );
sXPos = sXPos * CELL_X_SIZE + (CELL_X_SIZE / 2);
sYPos = sYPos * CELL_Y_SIZE + (CELL_Y_SIZE / 2);
ConvertGridNoToCenterCellXY(sGridNo, &sXPos, &sYPos);
// set startsoldier's target ID ... need an ID stored in case this
// is the AI calculating cover to a location where he might not be any more
@@ -4437,6 +4444,7 @@ UINT8 SoldierToLocationChanceToGetThrough( SOLDIERTYPE * pStartSoldier, INT32 sG
UINT8 AISoldierToSoldierChanceToGetThrough( SOLDIERTYPE * pStartSoldier, SOLDIERTYPE * pEndSoldier )
{
// Like a standard CTGT algorithm BUT fakes the start soldier at standing height
INT16 sX, sY;
FLOAT dEndZPos;
BOOLEAN fOk;
UINT8 ubChance;
@@ -4460,7 +4468,8 @@ UINT8 AISoldierToSoldierChanceToGetThrough( SOLDIERTYPE * pStartSoldier, SOLDIER
// is the AI calculating cover to a location where he might not be any more
pStartSoldier->ubCTGTTargetID = NOBODY;
ubChance = ChanceToGetThrough( pStartSoldier, (FLOAT) CenterX( pEndSoldier->sGridNo ), (FLOAT) CenterY( pEndSoldier->sGridNo ), dEndZPos );
ConvertGridNoToCenterCellXY(pEndSoldier->sGridNo, &sX, &sY);
ubChance = ChanceToGetThrough( pStartSoldier, (FLOAT) sX, (FLOAT) sY, dEndZPos );
pStartSoldier->usAnimState = usTrueState;
return( ubChance );
}
@@ -4510,9 +4519,7 @@ UINT8 AISoldierToLocationChanceToGetThrough( SOLDIERTYPE * pStartSoldier, INT32
}
dEndZPos += CONVERT_PIXELS_TO_HEIGHTUNITS( gpWorldLevelData[sGridNo].sHeight );
ConvertGridNoToXY( sGridNo, &sXPos, &sYPos );
sXPos = sXPos * CELL_X_SIZE + (CELL_X_SIZE / 2);
sYPos = sYPos * CELL_Y_SIZE + (CELL_Y_SIZE / 2);
ConvertGridNoToCenterCellXY(sGridNo, &sXPos, &sYPos);
// set startsoldier's target ID ... need an ID stored in case this
// is the AI calculating cover to a location where he might not be any more
@@ -4788,6 +4795,7 @@ INT8 FireBulletGivenTargetNCTH( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY,
UINT8 ubSpreadIndex = 0;
UINT16 usBulletFlags = 0;
int n=0;
INT16 sXPos, sYPos;
OBJECTTYPE* pObjAttHand = pFirer->GetUsedWeapon( &(pFirer->inv[pFirer->ubAttackingHand]) );
@@ -4799,8 +4807,9 @@ INT8 FireBulletGivenTargetNCTH( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY,
CalculateSoldierZPos( pFirer, FIRING_POS, &dStartZ );
dStartX = (FLOAT) CenterX( pFirer->sGridNo );
dStartY = (FLOAT) CenterY( pFirer->sGridNo );
ConvertGridNoToCenterCellXY(pFirer->sGridNo, &sXPos, &sYPos);
dStartX = (FLOAT) sXPos;
dStartY = (FLOAT) sYPos;
dDeltaX = dEndX - dStartX;
dDeltaY = dEndY - dStartY;
@@ -5279,6 +5288,7 @@ INT8 FireBulletGivenTarget( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY, FLOA
UINT8 ubSpreadIndex = 0;
UINT16 usBulletFlags = 0;
int n=0;
INT16 sXPos, sYPos;
OBJECTTYPE* pObjAttHand = pFirer->GetUsedWeapon( &(pFirer->inv[pFirer->ubAttackingHand]) );
@@ -5290,8 +5300,9 @@ INT8 FireBulletGivenTarget( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY, FLOA
CalculateSoldierZPos( pFirer, FIRING_POS, &dStartZ );
dStartX = (FLOAT) CenterX( pFirer->sGridNo );
dStartY = (FLOAT) CenterY( pFirer->sGridNo );
ConvertGridNoToCenterCellXY(pFirer->sGridNo, &sXPos, &sYPos);
dStartX = (FLOAT) sXPos;
dStartY = (FLOAT) sYPos;
dDeltaX = dEndX - dStartX;
dDeltaY = dEndY - dStartY;
@@ -5954,6 +5965,7 @@ INT8 FireBulletGivenTargetTrapOnly( SOLDIERTYPE* pThrower, OBJECTTYPE* pObj, INT
UINT8 ubSpreadIndex = 0;
UINT16 usBulletFlags = 0;
int n=0;
INT16 sXPos, sYPos;
UINT16 usItem = pObj->usItem;
UINT8 ammotype = ( *pObj )[0]->data.gun.ubGunAmmoType;
@@ -5962,8 +5974,9 @@ INT8 FireBulletGivenTargetTrapOnly( SOLDIERTYPE* pThrower, OBJECTTYPE* pObj, INT
if ( AmmoTypes[ammotype].numberOfBullets > 1 )
fBuckshot = TRUE;
dStartX = (FLOAT) CenterX( gridno );
dStartY = (FLOAT) CenterY( gridno );
ConvertGridNoToCenterCellXY(gridno, &sXPos, &sYPos);
dStartX = (FLOAT) sXPos;
dStartY = (FLOAT) sYPos;
dDeltaX = dEndX - dStartX;
dDeltaY = dEndY - dStartY;
@@ -6541,13 +6554,15 @@ INT8 FireBulletGivenTarget_NoObjectNoSoldier( UINT16 usItem, UINT8 ammotype, UIN
UINT8 ubSpreadIndex = 0;
UINT16 usBulletFlags = 0;
int n = 0;
INT16 sXPos, sYPos;
BOOLEAN fBuckshot = FALSE;
if ( AmmoTypes[ammotype].numberOfBullets > 1 )
fBuckshot = TRUE;
dStartX = (FLOAT)CenterX( gridno );
dStartY = (FLOAT)CenterY( gridno );
ConvertGridNoToCenterCellXY(gridno, &sXPos, &sYPos);
dStartX = (FLOAT)sXPos;
dStartY = (FLOAT)sYPos;
dDeltaX = dEndX - dStartX;
dDeltaY = dEndY - dStartY;
@@ -8537,8 +8552,10 @@ void AdjustTargetCenterPoint( SOLDIERTYPE *pShooter, INT32 iTargetGridNo, FLOAT
CalculateSoldierZPos( pShooter, FIRING_POS, &dStartZ );
// Locate absolute center X,Y of the shooter
dStartX = (FLOAT) CenterX( pShooter->sGridNo );
dStartY = (FLOAT) CenterY( pShooter->sGridNo );
INT16 sXPos, sYPos;
ConvertGridNoToCenterCellXY(pShooter->sGridNo, &sXPos, &sYPos);
dStartX = (FLOAT) sXPos;
dStartY = (FLOAT) sYPos;
////////////////////////////////////////////////////////////////////////////
// Calculate difference (Delta) between start and end point of bullet flight
@@ -9157,8 +9174,10 @@ void CalcTargetMovementOffset( SOLDIERTYPE *pShooter, SOLDIERTYPE *pTarget, OBJE
{
// HEADROCK HAM 4: Hopefully the right spot for this: This soldier has no "old" coordinates, so just set them
// to wherever he/she is currently standing.
pTarget->sOldXPos = CenterX( pTarget->sGridNo );
pTarget->sOldYPos = CenterY( pTarget->sGridNo );
INT16 sXPos, sYPos;
ConvertGridNoToCenterCellXY(pTarget->sGridNo, &sXPos, &sYPos);
pTarget->sOldXPos = sXPos;
pTarget->sOldYPos = sYPos;
// Since movement is now nonexistent, break the formula here without adjusting coordinates.
return;
}
+7 -7
View File
@@ -561,8 +561,7 @@ INT32 AddRottingCorpse( ROTTING_CORPSE_DEFINITION *pCorpseDef )
}
else
{
AniParams.sX = CenterX(pCorpse->def.sGridNo);
AniParams.sY = CenterY(pCorpse->def.sGridNo);
ConvertGridNoToCenterCellXY(pCorpse->def.sGridNo, &AniParams.sX, &AniParams.sY);
}
AniParams.sZ = (INT16)pCorpse->def.sHeightAdjustment;
@@ -1588,8 +1587,7 @@ void VaporizeCorpse( INT32 sGridNo, INT8 asLevel, UINT16 usStructureID )
AniParams.sDelay = (INT16)( 80 );
AniParams.sStartFrame = 0;
AniParams.uiFlags = ANITILE_CACHEDTILE | ANITILE_FORWARD;
AniParams.sX = CenterX( sBaseGridNo );
AniParams.sY = CenterY( sBaseGridNo );
ConvertGridNoToCenterCellXY(sBaseGridNo, &AniParams.sX, &AniParams.sY);
AniParams.sZ = (INT16)pCorpse->def.sHeightAdjustment;
strcpy( AniParams.zCachedFile, "TILECACHE\\GEN_BLOW.STI" );
@@ -2284,10 +2282,12 @@ BOOLEAN AddCorpseFromObject(OBJECTTYPE* pObj, INT32 sGridNo, INT8 bLevel )
Corpse.ubBodyType = REGMALE;
}
INT16 sX, sY;
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
Corpse.sGridNo = sGridNo;
Corpse.dXPos = CenterX(Corpse.sGridNo);
Corpse.dYPos = CenterY(Corpse.sGridNo);
Corpse.dXPos = sX;
Corpse.dYPos = sY;
Corpse.sHeightAdjustment = 0;
+2 -2
View File
@@ -776,7 +776,7 @@ BOOLEAN EnterShopKeeperInterface()
else
pShopkeeper = FindSoldierByProfileID( armsDealerInfo[gbSelectedArmsDealerID].ubShopKeeperID, FALSE );
if ( GetRangeFromGridNoDiff( pSoldier->sGridNo, pShopkeeper->sGridNo ) > NPC_TALK_RADIUS )
if (PythSpacesAway( pSoldier->sGridNo, pShopkeeper->sGridNo ) > NPC_TALK_RADIUS )
{
//so now we know we are too far away to trade, so instead of just quitting,
//either post a message or run to the guy like HandleTalkInit does
@@ -6668,7 +6668,7 @@ BOOLEAN CanMercInteractWithSelectedShopkeeper( SOLDIERTYPE *pSoldier )
if ( SoldierTo3DLocationLineOfSightTest( pSoldier, sDestGridNo, bDestLevel, 3, TRUE, CALC_FROM_ALL_DIRS ) )
{
// Get range to shopkeeper
uiRange = GetRangeFromGridNoDiff( pSoldier->sGridNo, sDestGridNo );
uiRange = PythSpacesAway( pSoldier->sGridNo, sDestGridNo );
// and is close enough to talk to the shopkeeper (use this define INSTEAD of PASSING_ITEM_DISTANCE_OKLIFE!)
if ( uiRange <= NPC_TALK_RADIUS )
+11 -22
View File
@@ -1367,11 +1367,9 @@ void InternalSoldierInSectorSleep( SOLDIERTYPE *pSoldier, INT32 sGridNo, BOOLEAN
usAnim = STANDING;
}
// OK, look for sutable placement....
// OK, look for suitable placement....
sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, usAnim, sGridNo, 5, &ubNewDirection, FALSE );
sWorldX = CenterX( sGoodGridNo );
sWorldY = CenterY( sGoodGridNo );
ConvertGridNoToCenterCellXY(sGoodGridNo, &sWorldX, &sWorldY);
pSoldier->EVENT_SetSoldierPosition( sWorldX, sWorldY );
@@ -1408,11 +1406,9 @@ void SoldierInSectorIncompaciated( SOLDIERTYPE *pSoldier, INT32 sGridNo )
return;
}
// OK, look for sutable placement....
// OK, look for suitable placement....
sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, STAND_FALLFORWARD_STOP, sGridNo, 5, &ubNewDirection, FALSE );
sWorldX = CenterX( sGoodGridNo );
sWorldY = CenterY( sGoodGridNo );
ConvertGridNoToCenterCellXY(sGoodGridNo, &sWorldX, &sWorldY);
pSoldier->EVENT_SetSoldierPosition( sWorldX, sWorldY );
@@ -1444,11 +1440,9 @@ void SoldierInSectorPatient( SOLDIERTYPE *pSoldier, INT32 sGridNo )
return;
}
// OK, look for sutable placement....
// OK, look for suitable placement....
sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, BEING_PATIENT, sGridNo, 5, &ubNewDirection, FALSE );
sWorldX = CenterX( sGoodGridNo );
sWorldY = CenterY( sGoodGridNo );
ConvertGridNoToCenterCellXY(sGoodGridNo, &sWorldX, &sWorldY);
pSoldier->EVENT_SetSoldierPosition( sWorldX, sWorldY );
@@ -1479,11 +1473,9 @@ void SoldierInSectorDoctor( SOLDIERTYPE *pSoldier, INT32 sGridNo )
return;
}
// OK, look for sutable placement....
// OK, look for suitable placement....
sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, BEING_DOCTOR, sGridNo, 5, &ubNewDirection, FALSE );
sWorldX = CenterX( sGoodGridNo );
sWorldY = CenterY( sGoodGridNo );
ConvertGridNoToCenterCellXY(sGoodGridNo, &sWorldX, &sWorldY);
pSoldier->EVENT_SetSoldierPosition( sWorldX, sWorldY );
@@ -1514,11 +1506,9 @@ void SoldierInSectorRepair( SOLDIERTYPE *pSoldier, INT32 sGridNo )
return;
}
// OK, look for sutable placement....
// OK, look for suitable placement....
sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, BEING_REPAIRMAN, sGridNo, 5, &ubNewDirection, FALSE );
sWorldX = CenterX( sGoodGridNo );
sWorldY = CenterY( sGoodGridNo );
ConvertGridNoToCenterCellXY(sGoodGridNo, &sWorldX, &sWorldY);
pSoldier->EVENT_SetSoldierPosition( sWorldX, sWorldY );
@@ -1550,8 +1540,7 @@ void AddSoldierToSectorGridNo( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 ubDir
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("AddSoldierToSectorGridNo"));
// Add merc to gridno
sWorldX = CenterX( sGridNo );
sWorldY = CenterY( sGridNo );
ConvertGridNoToCenterCellXY(sGridNo, &sWorldX, &sWorldY);
// Set reserved location!
pSoldier->sReservedMovementGridNo = NOWHERE;
+2 -3
View File
@@ -280,7 +280,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
INT16 sXPos, sYPos;
//sNewGridNo = NewGridNo( pSoldier->sGridNo, (UINT16)DirectionInc( pSoldier->ubDirection ) );
ConvertMapPosToWorldTileCenter( pSoldier->sTempNewGridNo, &sXPos, &sYPos );
ConvertGridNoToCenterCellXY( pSoldier->sTempNewGridNo, &sXPos, &sYPos );
pSoldier->EVENT_SetSoldierPosition( (FLOAT)sXPos, (FLOAT)sYPos );
}
@@ -717,8 +717,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
// CODE: End Hop Fence
// MOVE TO FORCASTED GRIDNO
sX = CenterX( pSoldier->sForcastGridno );
sY = CenterY( pSoldier->sForcastGridno );
ConvertGridNoToCenterCellXY(pSoldier->sForcastGridno, &sX, &sY);
pSoldier->EVENT_InternalSetSoldierPosition( (FLOAT) sX, (FLOAT) sY, FALSE, FALSE, FALSE );
pSoldier->EVENT_SetSoldierDirection( gTwoCDirection[ pSoldier->ubDirection ] );
+36 -19
View File
@@ -5041,8 +5041,10 @@ void SOLDIERTYPE::EVENT_FireSoldierWeapon( INT32 sTargetGridNo )
}
else if (!TileIsOutOfBounds(sTargetGridNo) && !GridNoOnScreen(sTargetGridNo))
{
INT16 sNewCenterWorldX = CenterX(sTargetGridNo);
INT16 sNewCenterWorldY = CenterY(sTargetGridNo);
INT16 sNewCenterWorldX;
INT16 sNewCenterWorldY;
ConvertGridNoToCenterCellXY(sTargetGridNo, &sNewCenterWorldX, &sNewCenterWorldY);
SetRenderCenter(sNewCenterWorldX, sNewCenterWorldY);
// Plot new path!
@@ -7359,7 +7361,7 @@ void SOLDIERTYPE::EVENT_InternalSetSoldierDestination( UINT16 usNewDirection, BO
// Get dest gridno, convert to center coords
sNewGridNo = NewGridNo( this->sGridNo, DirectionInc( (UINT8)usNewDirection ) );
ConvertMapPosToWorldTileCenter( sNewGridNo, &sXPos, &sYPos );
ConvertGridNoToCenterCellXY( sNewGridNo, &sXPos, &sYPos );
// Save new dest gridno, x, y
this->pathing.sDestination = sNewGridNo;
@@ -11544,7 +11546,7 @@ void SOLDIERTYPE::MoveMerc( FLOAT dMovementChange, FLOAT dAngle, BOOLEAN fCheckR
{
INT16 this_base_x = 0;
INT16 this_base_y = 0;
ConvertMapPosToWorldTileCenter( this->sGridNo, &this_base_x, &this_base_y );
ConvertGridNoToCenterCellXY( this->sGridNo, &this_base_x, &this_base_y );
dx = this->dXPos - this_base_x;
dy = this->dYPos - this_base_y;
@@ -11552,7 +11554,7 @@ void SOLDIERTYPE::MoveMerc( FLOAT dMovementChange, FLOAT dAngle, BOOLEAN fCheckR
INT16 base_x = 0;
INT16 base_y = 0;
ConvertMapPosToWorldTileCenter( gridnotouse, &base_x, &base_y );
ConvertGridNoToCenterCellXY( gridnotouse, &base_x, &base_y );
pSoldier->EVENT_InternalSetSoldierPosition( base_x + dx, base_y + dy, FALSE, FALSE, FALSE );
}
@@ -11586,27 +11588,33 @@ void SOLDIERTYPE::MoveMerc( FLOAT dMovementChange, FLOAT dAngle, BOOLEAN fCheckR
// adjust both gridno and x,y coordinates
if (sOldGridNo != this->sGridNo)
{
CorpseDef.sGridNo = sOldGridNo;
CorpseDef.dXPos = CenterX(CorpseDef.sGridNo);
CorpseDef.dYPos = CenterY(CorpseDef.sGridNo);
INT16 sX, sY;
ConvertGridNoToCenterCellXY(sOldGridNo, &sX, &sY);
CorpseDef.sGridNo = sOldGridNo;
CorpseDef.dXPos = sX;
CorpseDef.dYPos = sY;
}
else
{
// move corpse a bit
INT16 this_base_x = 0;
INT16 this_base_y = 0;
ConvertMapPosToWorldTileCenter(this->sGridNo, &this_base_x, &this_base_y);
ConvertGridNoToCenterCellXY(this->sGridNo, &this_base_x, &this_base_y);
FLOAT dx = this->dXPos - this_base_x;
FLOAT dy = this->dYPos - this_base_y;
INT16 base_x = 0;
INT16 base_y = 0;
ConvertMapPosToWorldTileCenter(pCorpse->def.sGridNo, &base_x, &base_y);
ConvertGridNoToCenterCellXY(pCorpse->def.sGridNo, &base_x, &base_y);
INT16 sX, sY;
ConvertGridNoToCenterCellXY(pCorpse->def.sGridNo, &sX, &sY);
CorpseDef.sGridNo = pCorpse->def.sGridNo;
CorpseDef.dXPos = CenterX(CorpseDef.sGridNo) + dx;
CorpseDef.dYPos = CenterY(CorpseDef.sGridNo) + dy;
CorpseDef.dXPos = sX + dx;
CorpseDef.dYPos = sY + dy;
}
CorpseDef.usFlags |= ROTTING_CORPSE_USE_XY_PROVIDED;
@@ -11768,6 +11776,17 @@ UINT8 GetDirectionFromXY( INT16 sXPos, INT16 sYPos, SOLDIERTYPE *pSoldier )
return(atan8( sXPos2, sYPos2, sXPos, sYPos ));
}
INT16 GetDirectionFromCenterCellXYGridNo(INT32 EndGridNo, INT32 StartGridNo)
{
INT16 sXPos2, sYPos2;
INT16 sXPos, sYPos;
ConvertGridNoToCenterCellXY(StartGridNo, &sXPos, &sYPos);
ConvertGridNoToCenterCellXY(EndGridNo, &sXPos2, &sYPos2);
return(atan8(sXPos2, sYPos2, sXPos, sYPos));
}
//#if 0
UINT8 atan8( INT16 sXPos, INT16 sYPos, INT16 sXPos2, INT16 sYPos2 )
@@ -12261,8 +12280,7 @@ void SOLDIERTYPE::ReviveSoldier( void )
this->BeginSoldierGetup( );
// Makesure center of tile
sX = CenterX( this->sGridNo );
sY = CenterY( this->sGridNo );
ConvertGridNoToCenterCellXY(this->sGridNo, &sX, &sY);
this->EVENT_SetSoldierPosition( (FLOAT)sX, (FLOAT)sY );
@@ -13962,8 +13980,7 @@ void SOLDIERTYPE::EVENT_StopMerc( INT32 sGridNo, INT8 bDirection )
// MOVE GUY TO GRIDNO--- SHOULD BE THE SAME UNLESS IN MULTIPLAYER
// Makesure center of tile
sX = CenterX( sGridNo );
sY = CenterY( sGridNo );
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
//Cancel pending events
if ( !this->flags.fDelayedMovement )
@@ -15862,7 +15879,7 @@ BOOLEAN SOLDIERTYPE::SeemsLegit( UINT8 ubObserverID )
}
UINT8 covertlevel = NUM_SKILL_TRAITS( this, COVERT_NT ); // our level in covert operations
INT32 distance = GetRangeFromGridNoDiff( this->sGridNo, pSoldier->sGridNo );
INT32 distance = PythSpacesAway( this->sGridNo, pSoldier->sGridNo );
// if we are closer than this, our cover will always break if we do not have the skill
// if we have the skill, our cover will blow if we dress up as a soldier, but not if we are dressed like a civilian
@@ -20865,7 +20882,7 @@ void SOLDIERTYPE::CancelDrag()
{
INT16 base_x = 0;
INT16 base_y = 0;
ConvertMapPosToWorldTileCenter(pSoldier->sGridNo, &base_x, &base_y);
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &base_x, &base_y);
pSoldier->EVENT_InternalSetSoldierPosition(base_x, base_y, FALSE, FALSE, FALSE);
}
@@ -23199,7 +23216,7 @@ BOOLEAN SOLDIERTYPE::PlayerSoldierStartTalking( UINT8 ubTargetID, BOOLEAN fValid
return(FALSE);
}
uiRange = GetRangeFromGridNoDiff( this->sGridNo, pTSoldier->sGridNo );
uiRange = PythSpacesAway( this->sGridNo, pTSoldier->sGridNo );
if ( uiRange > (NPC_TALK_RADIUS * 2) )
{
+2 -1
View File
@@ -2204,7 +2204,8 @@ BOOLEAN GetDirectionChangeAmount( INT32 sGridNo, SOLDIERTYPE *pSoldier, UINT8 ui
UINT8 GetDirectionFromGridNo( INT32 sGridNo, SOLDIERTYPE *pSoldier );
UINT8 atan8( INT16 sXPos, INT16 sYPos, INT16 sXPos2, INT16 sYPos2 );
UINT8 atan8FromAngle( DOUBLE dAngle );
INT16 GetDirectionToGridNoFromGridNo( INT32 sGridNoDest, INT32 sGridNoSrc );
INT16 GetDirectionToGridNoFromGridNo(INT32 sGridNoDest, INT32 sGridNoSrc);
INT16 GetDirectionFromCenterCellXYGridNo(INT32 EndGridNo, INT32 StartGridNo);
// This function is now obsolete. Call ReduceAttackBusyCount instead.
// void ReleaseSoldiersAttacker( SOLDIERTYPE *pSoldier );
+16 -12
View File
@@ -814,8 +814,7 @@ BOOLEAN SoldierLocationRelativeToScreen( INT32 sGridNo, UINT16 usReasonID, INT8
*puiScrollFlags = 0;
sX = CenterX( sGridNo );
sY = CenterY( sGridNo );
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
// Get screen coordinates for current position of soldier
GetWorldXYAbsoluteScreenXY( (INT16)(sX/CELL_X_SIZE), (INT16)(sY/CELL_Y_SIZE), &sWorldX, &sWorldY);
@@ -954,25 +953,28 @@ BOOLEAN FindRelativeSoldierPosition( SOLDIERTYPE *pSoldier, UINT16 *usFlags, INT
// Then, depending on whether this is the gridno we are looking at, this will be head or legs
if ( gGameExternalOptions.fAllowTargetHeadAndLegIfProne )
{
INT16 sWorldX, sWorldY;
INT16 sWorldX, sWorldY, sX, sY;
GetMouseWorldCoords( &sWorldX, &sWorldY );
// Flugente: we measure the distance of the bullet's location to the location of the soldier, and to the 2 gridnos his head and leg occupy
// From this we can decide what body part was hit
FLOAT bodycenterX = (FLOAT)CenterX( pSoldier->sGridNo );
FLOAT bodycenterY = (FLOAT)CenterY( pSoldier->sGridNo );
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
FLOAT bodycenterX = (FLOAT) sX;
FLOAT bodycenterY = (FLOAT) sY;
FLOAT difftobodycenter = sqrt( (bodycenterX - sWorldX) * (bodycenterX - sWorldX) + (bodycenterY - sWorldY) * (bodycenterY - sWorldY) );
INT32 viewdirectiongridno = NewGridNo( pSoldier->sGridNo, DirectionInc( pSoldier->ubDirection ) );
FLOAT nextgridnocenterX = (FLOAT)CenterX( viewdirectiongridno );
FLOAT nextgridnocenterY = (FLOAT)CenterY( viewdirectiongridno );
ConvertGridNoToCenterCellXY(viewdirectiongridno, &sX, &sY);
FLOAT nextgridnocenterX = (FLOAT) sX;
FLOAT nextgridnocenterY = (FLOAT) sY;
FLOAT difftonextgridno = sqrt( (nextgridnocenterX - sWorldX) * (nextgridnocenterX - sWorldX) + (nextgridnocenterY - sWorldY) * (nextgridnocenterY - sWorldY) );
INT32 oppositeviewdirectiongridno = NewGridNo( pSoldier->sGridNo, DirectionInc( gOppositeDirection[pSoldier->ubDirection] ) );
FLOAT oppositenextgridnocenterX = (FLOAT)CenterX( oppositeviewdirectiongridno );
FLOAT oppositenextgridnocenterY = (FLOAT)CenterY( oppositeviewdirectiongridno );
ConvertGridNoToCenterCellXY(oppositeviewdirectiongridno, &sX, &sY);
FLOAT oppositenextgridnocenterX = (FLOAT) sX;
FLOAT oppositenextgridnocenterY = (FLOAT) sY;
FLOAT difftooppositenextgridno = sqrt( (oppositenextgridnocenterX - sWorldX) * (oppositenextgridnocenterX - sWorldX) + (oppositenextgridnocenterY - sWorldY) * (oppositenextgridnocenterY - sWorldY) );
@@ -1030,13 +1032,15 @@ UINT8 QuickFindSoldier( INT32 sGridNo )
void GetGridNoScreenPos( INT32 sGridNo, UINT8 ubLevel, INT16 *psScreenX, INT16 *psScreenY )
{
INT16 sScreenX, sScreenY;
INT16 sScreenX, sScreenY, sX, sY;
FLOAT dOffsetX, dOffsetY;
FLOAT dTempX_S, dTempY_S;
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
// Get 'TRUE' merc position
dOffsetX = (FLOAT)( CenterX( sGridNo ) - gsRenderCenterX );
dOffsetY = (FLOAT)( CenterY( sGridNo ) - gsRenderCenterY );
dOffsetX = (FLOAT)( sX - gsRenderCenterX );
dOffsetY = (FLOAT)( sY - gsRenderCenterY );
// OK, DONT'T ASK... CONVERSION TO PROPER Y NEEDS THIS...
dOffsetX -= CELL_Y_SIZE;
+1 -2
View File
@@ -738,8 +738,7 @@ BOOLEAN TeleportSoldier( SOLDIERTYPE *pSoldier, INT32 sGridNo, BOOLEAN fForce )
if ( NewOKDestination( pSoldier, sGridNo, TRUE, 0 ) || fForce )
{
// TELEPORT TO THIS LOCATION!
sX = CenterX( sGridNo );
sY = CenterY( sGridNo );
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
pSoldier->EVENT_SetSoldierPosition( (FLOAT) sX, (FLOAT) sY );
pSoldier->pathing.sFinalDestination = sGridNo;
+11 -36
View File
@@ -1678,33 +1678,7 @@ BOOLEAN RetrieveTempFileFromSavedGame( HWFILE hFile, UINT32 uiType, INT16 sMapX,
//Deletes the Temp map Directory
BOOLEAN InitTacticalSave( BOOLEAN fCreateTempDir )
{
#ifndef USE_VFS
UINT32 uiRetVal;
//If the Map Temp directory exists, removes the temp files
uiRetVal = FileGetAttributes( MAPS_DIR );
if( uiRetVal != 0xFFFFFFFF )
{
if( uiRetVal & FILE_ATTRIBUTES_DIRECTORY )
{
//Erase the directory
if( !EraseDirectory( MAPS_DIR ) )
{
//error erasing the temporary maps directory
}
}
}
else
{
if( !MakeFileManDirectory( MAPS_DIR ) )
{
//Erro creating the temp map directory
AssertMsg( 0, "Error creating the Temp Directory.");
}
}
#else
EraseDirectory( MAPS_DIR );
#endif
if( fCreateTempDir )
{
//Create the initial temp file for the Npc Quote Info
@@ -1878,8 +1852,10 @@ BOOLEAN LoadRottingCorpsesFromTempCorpseFile( INT16 sMapX, INT16 sMapY, INT8 bMa
def.sGridNo = gMapInformation.sWestGridNo;
}
//Recalculate the dx,dy info
def.dXPos = CenterX( def.sGridNo );
def.dYPos = CenterY( def.sGridNo );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(def.sGridNo, &sX, &sY);
def.dXPos = sX;
def.dYPos = sY;
// If not from loading a save....
if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) )
{
@@ -2737,15 +2713,14 @@ BOOLEAN AddDeadSoldierToUnLoadedSector( INT16 sMapX, INT16 sMapY, UINT8 bMapZ, S
memset( &Corpse, 0, sizeof( ROTTING_CORPSE_DEFINITION ) );
// Setup some values!
Corpse.ubBodyType = pSoldier->ubBodyType;
Corpse.sGridNo = sGridNo;
ConvertGridNoToCenterCellXY(sGridNo, &sXPos, &sYPos);
ConvertGridNoToXY( sGridNo, &sXPos, &sYPos );
Corpse.dXPos = (FLOAT)( CenterX( sXPos ) );
Corpse.dYPos = (FLOAT)( CenterY( sYPos ) );
Corpse.sHeightAdjustment = pSoldier->sHeightAdjustment;
Corpse.bVisible = TRUE;
Corpse.ubBodyType = pSoldier->ubBodyType;
Corpse.sGridNo = sGridNo;
Corpse.dXPos = (FLOAT)( sXPos );
Corpse.dYPos = (FLOAT)( sYPos );
Corpse.sHeightAdjustment = pSoldier->sHeightAdjustment;
Corpse.bVisible = TRUE;
SET_PALETTEREP_ID ( Corpse.HeadPal, pSoldier->HeadPal );
SET_PALETTEREP_ID ( Corpse.VestPal, pSoldier->VestPal );
+18 -6
View File
@@ -676,8 +676,12 @@ UINT8 HandleActivatedTargetCursor( SOLDIERTYPE *pSoldier, INT32 usMapPos, BOOLEA
gCTHDisplay.iTargetGridNo = usMapPos;
// Calculate distance to target
FLOAT dDeltaX = (FLOAT)(CenterX( pSoldier->sGridNo ) - CenterX( usMapPos ));
FLOAT dDeltaY = (FLOAT)(CenterY( pSoldier->sGridNo ) - CenterY( usMapPos ));
INT16 sX, sY, sXMap, sYMap;
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
ConvertGridNoToCenterCellXY(usMapPos, &sXMap, &sYMap);
FLOAT dDeltaX = (FLOAT)( sX - sXMap );
FLOAT dDeltaY = (FLOAT)( sY - sYMap );
FLOAT d2DDistance = sqrt((dDeltaX*dDeltaX)+(dDeltaY*dDeltaY));
CalcMagFactorSimple( pSoldier, d2DDistance, pSoldier->aiData.bShownAimTime, usMapPos );
@@ -782,8 +786,12 @@ UINT8 HandleActivatedTargetCursor( SOLDIERTYPE *pSoldier, INT32 usMapPos, BOOLEA
gbCtHBurstCount = 0;
// Calculate distance to target
FLOAT dDeltaX = (FLOAT)(CenterX( pSoldier->sGridNo ) - CenterX( usMapPos ));
FLOAT dDeltaY = (FLOAT)(CenterY( pSoldier->sGridNo ) - CenterY( usMapPos ));
INT16 sX, sY, sXMap, sYMap;
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
ConvertGridNoToCenterCellXY(usMapPos, &sXMap, &sYMap);
FLOAT dDeltaX = (FLOAT)(sX - sXMap);
FLOAT dDeltaY = (FLOAT)(sY - sYMap);
FLOAT d2DDistance = sqrt((dDeltaX*dDeltaX)+(dDeltaY*dDeltaY));
CalcMagFactorSimple( pSoldier, d2DDistance, pSoldier->aiData.bShownAimTime, usMapPos );
@@ -884,8 +892,12 @@ UINT8 HandleActivatedTargetCursor( SOLDIERTYPE *pSoldier, INT32 usMapPos, BOOLEA
gCTHDisplay.iTargetGridNo = usMapPos;
// Calculate distance to target
FLOAT dDeltaX = (FLOAT)(CenterX( pSoldier->sGridNo ) - CenterX( usMapPos ));
FLOAT dDeltaY = (FLOAT)(CenterY( pSoldier->sGridNo ) - CenterY( usMapPos ));
INT16 sX, sY, sXMap, sYMap;
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
ConvertGridNoToCenterCellXY(usMapPos, &sXMap, &sYMap);
FLOAT dDeltaX = (FLOAT)(sX - sXMap);
FLOAT dDeltaY = (FLOAT)(sY - sYMap);
FLOAT d2DDistance = sqrt((dDeltaX*dDeltaX)+(dDeltaY*dDeltaY));
CalcMagFactorSimple( pSoldier, d2DDistance, pSoldier->aiData.bShownAimTime, usMapPos );
+6 -2
View File
@@ -1787,7 +1787,9 @@ BOOLEAN ExitVehicle( SOLDIERTYPE *pSoldier )
pSoldier->aiData.bOppList[ pVehicle->ubID ] = 1;
// Add to sector....
pSoldier->EVENT_SetSoldierPosition( CenterX( sGridNo ), CenterY( sGridNo ) );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
pSoldier->EVENT_SetSoldierPosition( sX, sY );
// anv: since now they can shoot it's important to set passenger to proper stance
// namely, back to standing, because we set them to crouching when entering
@@ -2064,7 +2066,9 @@ void HandleCriticalHitForVehicleInLocation( UINT8 ubID, INT16 sDmg, INT32 sGridN
pVehicleList[ ubID ].fDestroyed = TRUE;
// Explode vehicle...
IgniteExplosion( ubAttackerID, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, GREAT_BIG_EXPLOSION, 0 );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
IgniteExplosion( ubAttackerID, sX, sY, 0, sGridNo, GREAT_BIG_EXPLOSION, 0 );
if ( pSoldier != NULL )
{
+50 -27
View File
@@ -1714,7 +1714,7 @@ void GetTargetWorldPositions( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo, FLOAT
FLOAT dTargetZ;
SOLDIERTYPE* pTargetSoldier = NULL;
INT8 bStructHeight;
INT16 sXMapPos, sYMapPos;
INT16 sXMapPos, sYMapPos, sX, sY;
UINT32 uiRoll;
INT8 bTargetCubeLevel = 0;
INT8 bTargetLevel = 0;
@@ -1731,8 +1731,9 @@ void GetTargetWorldPositions( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo, FLOAT
{
// SAVE OPP ID
pSoldier->ubOppNum = pTargetSoldier->ubID;
dTargetX = (FLOAT) CenterX( pTargetSoldier->sGridNo );
dTargetY = (FLOAT) CenterY( pTargetSoldier->sGridNo );
ConvertGridNoToCenterCellXY(pTargetSoldier->sGridNo, &sX, &sY);
dTargetX = (FLOAT) sX;
dTargetY = (FLOAT) sY;
if (pSoldier->bAimShotLocation == AIM_SHOT_RANDOM)
{
uiRoll = PreRandom( 100 );
@@ -1773,9 +1774,11 @@ void GetTargetWorldPositions( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo, FLOAT
if ( gGameExternalOptions.fAllowTargetHeadAndLegIfProne && gAnimControl[pTargetSoldier->usAnimState].ubHeight == ANIM_PRONE )
{
INT32 viewdirectiongridno = NewGridNo( pTargetSoldier->sGridNo, DirectionInc( pTargetSoldier->ubDirection ) );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(viewdirectiongridno, &sX, &sY);
dTargetX = (0.3f * dTargetX + 0.7f * (FLOAT)CenterX( viewdirectiongridno )) / 1.0f;
dTargetY = (0.3f * dTargetY + 0.7f * (FLOAT)CenterY( viewdirectiongridno )) / 1.0f;
dTargetX = (0.3f * dTargetX + 0.7f * (FLOAT)sX) / 1.0f;
dTargetY = (0.3f * dTargetY + 0.7f * (FLOAT)sY) / 1.0f;
}
}
break;
@@ -1789,9 +1792,11 @@ void GetTargetWorldPositions( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo, FLOAT
if ( gGameExternalOptions.fAllowTargetHeadAndLegIfProne && gAnimControl[pTargetSoldier->usAnimState].ubHeight == ANIM_PRONE )
{
INT32 viewdirectiongridno = NewGridNo( pTargetSoldier->sGridNo, DirectionInc( gOppositeDirection[pTargetSoldier->ubDirection] ) );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(viewdirectiongridno, &sX, &sY);
dTargetX = (0.3f * dTargetX + 0.7f * (FLOAT)CenterX( viewdirectiongridno )) / 1.0f;
dTargetY = (0.3f * dTargetY + 0.7f * (FLOAT)CenterY( viewdirectiongridno )) / 1.0f;
dTargetX = (0.3f * dTargetX + 0.7f * (FLOAT)sX) / 1.0f;
dTargetY = (0.3f * dTargetY + 0.7f * (FLOAT)sY) / 1.0f;
}
}
break;
@@ -2718,11 +2723,14 @@ BOOLEAN UseGunNCTH( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo )
{
if ( WillExplosiveWeaponFail( pSoldier, pObjHand ) )
{
INT16 sX, sY;
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
if ( Item[usUBItem].singleshotrocketlauncher )
{
CreateItem( Item[usItemNum].discardedlauncheritem , (*pObjHand)[0]->data.objectStatus, pObjHand );
// Flugente: why would we keep a piece of scrap in our ahnds in the first place? just drop it to the ground
// Flugente: why would we keep a piece of scrap in our hands in the first place? just drop it to the ground
AddItemToPool( pSoldier->sGridNo, pObjHand, 1, pSoldier->pathing.bLevel, 0, -1 );
// Delete object
@@ -2730,20 +2738,21 @@ BOOLEAN UseGunNCTH( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo )
DirtyMercPanelInterface( pSoldier, DIRTYLEVEL2 );
if ( Item[usUBItem].usBuddyItem != 0 && Item[Item[usUBItem].usBuddyItem].usItemClass & IC_EXPLOSV )
{
IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, Item[usUBItem].usBuddyItem, pSoldier->pathing.bLevel );
IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, Item[usUBItem].usBuddyItem, pSoldier->pathing.bLevel );
}
else
{
IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, C1, pSoldier->pathing.bLevel );
IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, C1, pSoldier->pathing.bLevel );
}
}
else
{
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("StructureHit: RPG7 item: %d, Ammo: %d", usUBItem , (*pObjHand)[0]->data.gun.usGunAmmoItem ) );
IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, (*pObjHand)[0]->data.gun.usGunAmmoItem, pSoldier->pathing.bLevel );
IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, (*pObjHand)[0]->data.gun.usGunAmmoItem, pSoldier->pathing.bLevel );
pSoldier->inv[pSoldier->ubAttackingHand ][0]->data.gun.usGunAmmoItem = NONE;
}
// Reduce again for attack end 'cause it has been incremented for a normal attack
@@ -2893,8 +2902,8 @@ BOOLEAN UseGunNCTH( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo )
{
sTempGridNo = NewGridNo(sTempGridNo, DirectionInc(pSoldier->ubDirection));
}
INT16 sX = CenterX(sTempGridNo);
INT16 sY = CenterY(sTempGridNo);
INT16 sX, sY;
ConvertGridNoToCenterCellXY(sTempGridNo, &sX, &sY);
AniParams.sGridNo = pSoldier->sGridNo;
AniParams.ubLevelID = ANI_TOPMOST_LEVEL;
@@ -3643,6 +3652,9 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo )
{
if ( WillExplosiveWeaponFail( pSoldier, pObjUsed ) )
{
INT16 sX, sY;
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
if ( Item[usUBItem].singleshotrocketlauncher )
{
CreateItem( Item[usUBItem].discardedlauncheritem , (*pObjUsed)[0]->data.objectStatus, pObjUsed );
@@ -3655,20 +3667,21 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo )
DirtyMercPanelInterface( pSoldier, DIRTYLEVEL2 );
if ( Item[usUBItem].usBuddyItem != 0 && Item[Item[usUBItem].usBuddyItem].usItemClass & IC_EXPLOSV )
{
IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, C1, pSoldier->pathing.bLevel );
IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, C1, pSoldier->pathing.bLevel );
}
else
{
IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, C1, pSoldier->pathing.bLevel );
IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, C1, pSoldier->pathing.bLevel );
}
}
else
{
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("StructureHit: RPG7 item: %d, Ammo: %d", usUBItem , (*pObjUsed)[0]->data.gun.usGunAmmoItem ) );
IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, (*pObjUsed)[0]->data.gun.usGunAmmoItem, pSoldier->pathing.bLevel );
IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, (*pObjUsed)[0]->data.gun.usGunAmmoItem, pSoldier->pathing.bLevel );
OBJECTTYPE * pLaunchable = FindLaunchableAttachment( pObjUsed, usUBItem );
if(pLaunchable)
@@ -3708,8 +3721,8 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo )
{
sTempGridNo = NewGridNo(sTempGridNo, DirectionInc(pSoldier->ubDirection));
}
INT16 sX = CenterX(sTempGridNo);
INT16 sY = CenterY(sTempGridNo);
INT16 sX, sY;
ConvertGridNoToCenterCellXY(sTempGridNo, &sX, &sY);
AniParams.sGridNo = pSoldier->sGridNo;
AniParams.ubLevelID = ANI_TOPMOST_LEVEL;
@@ -5167,7 +5180,9 @@ BOOLEAN UseLauncher( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo )
// So we still should have ABC > 0
// Begin explosion due to failure...
IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, Launchable.usItem, pSoldier->pathing.bLevel );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, Launchable.usItem, pSoldier->pathing.bLevel );
// Reduce again for attack end 'cause it has been incremented for a normal attack
// Nope, not anymore.
@@ -5676,15 +5691,18 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT16 bWeaponStatus, UIN
// HEADROCK HAM 5: Fragments fired by such weapons should not explode.
if ( pBullet->fFragment == false)
{
INT16 sX, sY;
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
if ( Item[usWeaponIndex].singleshotrocketlauncher )
{
if ( Item[usWeaponIndex].usBuddyItem != 0 && Item[Item[usWeaponIndex].usBuddyItem].usItemClass & IC_EXPLOSV )
{
IgniteExplosion( ubAttackerID, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, Item[usWeaponIndex].usBuddyItem, bLevel, usDirection );
IgniteExplosion( ubAttackerID, sX, sY, 0, sGridNo, Item[usWeaponIndex].usBuddyItem, bLevel, usDirection );
}
else
{
IgniteExplosion( ubAttackerID, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, C1, bLevel, usDirection );
IgniteExplosion( ubAttackerID, sX, sY, 0, sGridNo, C1, bLevel, usDirection );
}
}
// changed too to use 2 flag to determine
@@ -5692,7 +5710,7 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT16 bWeaponStatus, UIN
//there shouldn't be a way to enter here with an UnderBarrel weapon, so retaining original code :JMich
{
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("StructureHit: RPG7 item: %d, Ammo: %d",pAttacker->inv[HANDPOS].usItem , pAttacker->inv[HANDPOS][0]->data.gun.usGunAmmoItem ) );
IgniteExplosion( ubAttackerID, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, pAttacker->inv[pAttacker->ubAttackingHand][0]->data.gun.usGunAmmoItem, bLevel, usDirection );
IgniteExplosion( ubAttackerID, sX, sY, 0, sGridNo, pAttacker->inv[pAttacker->ubAttackingHand][0]->data.gun.usGunAmmoItem, bLevel, usDirection );
//This is just to make multishot launchers work in semi auto. It's not really a permanent solution because it still doesn't allow autofire, but it will do for now.
OBJECTTYPE * pLaunchable = FindLaunchableAttachment( &(pAttacker->inv[pAttacker->ubAttackingHand ]), pAttacker->inv[pAttacker->ubAttackingHand ].usItem );
@@ -5708,7 +5726,7 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT16 bWeaponStatus, UIN
else if ( AmmoTypes[(*pObj)[0]->data.gun.ubGunAmmoType].explosionSize > 1)
{
// re-routed the Highexplosive value to define exposion type
IgniteExplosion( ubAttackerID, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, AmmoTypes[(*pObj)[0]->data.gun.ubGunAmmoType].highExplosive, bLevel, usDirection );
IgniteExplosion( ubAttackerID, sX, sY, 0, sGridNo, AmmoTypes[(*pObj)[0]->data.gun.ubGunAmmoType].highExplosive, bLevel, usDirection );
// pSoldier->inv[pSoldier->ubAttackingHand ][0]->data.gun.usGunAmmoItem = NONE;
}
}
@@ -5726,7 +5744,9 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT16 bWeaponStatus, UIN
//FreeUpAttacker( ubAttackerID );
// HEADROCK HAM 5 TODO: Tank shell!!
IgniteExplosion( ubAttackerID, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, TANK_SHELL, bLevel, usDirection );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
IgniteExplosion( ubAttackerID, sX, sY, 0, sGridNo, TANK_SHELL, bLevel, usDirection );
//FreeUpAttacker( (UINT8) ubAttackerID );
// Moved here to keep ABC >0 as long as possible
@@ -6250,7 +6270,7 @@ UINT32 CalcNewChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTi
// Basic defines
SOLDIERTYPE * pTarget;
INT32 iRange, iSightRange; //, minRange;
INT16 sX, sY, sX2, sY2;
UINT16 usInHand;
OBJECTTYPE * pInHand;
INT16 sDistVis, sDistVisNoScope;
@@ -6270,8 +6290,11 @@ UINT32 CalcNewChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTi
// calculate actual range (in units, 10 units = 1 tile)
iRange = GetRangeInCellCoordsFromGridNoDiff( pSoldier->sGridNo, sGridNo );
FLOAT dDeltaX = (FLOAT)(CenterX( pSoldier->sGridNo ) - CenterX( sGridNo ));
FLOAT dDeltaY = (FLOAT)(CenterY( pSoldier->sGridNo ) - CenterY( sGridNo ));
ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY);
ConvertGridNoToCenterCellXY(sGridNo, &sX2, &sY2);
FLOAT dDeltaX = (FLOAT)( sX - sX2 );
FLOAT dDeltaY = (FLOAT)( sY - sY2 );
FLOAT d2DDistance = sqrt((dDeltaX*dDeltaX)+(dDeltaY*dDeltaY));
// Find a target in the tile
+3 -7
View File
@@ -6130,10 +6130,8 @@ void ProcessNoise(UINT8 ubNoiseMaker, INT32 sGridNo, INT8 bLevel, UINT8 ubTerrTy
{
// ALL RIGHT! Passed all the tests, this listener hears this noise!!!
HearNoise(pSoldier,ubSource,sGridNo,bLevel,ubEffVolume,ubNoiseType, (UINT8 *)&bSeen);
bHeard = TRUE;
ubNoiseDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sGridNo),CenterY(sGridNo));
ubNoiseDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sGridNo);
// check the 'noise heard & reported' bit for that soldier & direction
if ( ubNoiseType != NOISE_MOVEMENT || bTeam != OUR_TEAM || (pSoldier->aiData.bInterruptDuelPts != NO_INTERRUPT) || !(pSoldier->ubMovementNoiseHeard & (1 << ubNoiseDir) ) )
@@ -6441,8 +6439,7 @@ void HearNoise(SOLDIERTYPE *pSoldier, UINT8 ubNoiseMaker, INT32 sGridNo, INT8 bL
// ignore muzzle flashes when turning head to see noise
if ( ubNoiseType == NOISE_GUNFIRE && ubNoiseMaker != NOBODY && MercPtrs[ ubNoiseMaker ]->flags.fMuzzleFlash )
{
sNoiseX = CenterX(sGridNo);
sNoiseY = CenterY(sGridNo);
ConvertGridNoToCenterCellXY(sGridNo, &sNoiseX, &sNoiseY);
bDirection = atan8(pSoldier->sX,pSoldier->sY,sNoiseX,sNoiseY);
if ( pSoldier->ubDirection != bDirection && pSoldier->ubDirection != gOneCDirection[ bDirection ] && pSoldier->ubDirection != gOneCCDirection[ bDirection ] )
{
@@ -6463,8 +6460,7 @@ void HearNoise(SOLDIERTYPE *pSoldier, UINT8 ubNoiseMaker, INT32 sGridNo, INT8 bL
if (PythSpacesAway(pSoldier->sGridNo,sGridNo) <= sDistVisible )
{
// just use the XXadjustedXX center of the gridno
sNoiseX = CenterX(sGridNo);
sNoiseY = CenterY(sGridNo);
ConvertGridNoToCenterCellXY(sGridNo, &sNoiseX, &sNoiseY);
if (pSoldier->ubDirection != atan8(pSoldier->sX,pSoldier->sY,sNoiseX,sNoiseY))
{
+6 -6
View File
@@ -144,7 +144,7 @@ BOOLEAN ConsiderProne( SOLDIERTYPE * pSoldier )
}
// We don't want to go prone if there is a nearby enemy
ClosestKnownOpponent( pSoldier, &sOpponentGridNo, &bOpponentLevel );
iRange = GetRangeFromGridNoDiff( pSoldier->sGridNo, sOpponentGridNo );
iRange = PythSpacesAway( pSoldier->sGridNo, sOpponentGridNo );
if (iRange > 10)
{
return( TRUE );
@@ -2736,7 +2736,7 @@ INT32 CalcManThreatValue( SOLDIERTYPE *pEnemy, INT32 sMyGrid, UINT8 ubReduceForC
else
{
// ADD 5% if man's already facing me
if (pEnemy->ubDirection == atan8(CenterX(pEnemy->sGridNo),CenterY(pEnemy->sGridNo),CenterX(sMyGrid),CenterY(sMyGrid)))
if (pEnemy->ubDirection == GetDirectionFromCenterCellXYGridNo(pEnemy->sGridNo, sMyGrid))
{
iThreatValue += (iThreatValue / 20);
}
@@ -3631,13 +3631,13 @@ UINT8 CountFriendsInDirection( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo )
CHECKF(pSoldier);
ubMyDir = atan8(CenterX(sTargetGridNo),CenterY(sTargetGridNo),CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo));
ubMyDir = GetDirectionFromCenterCellXYGridNo(sTargetGridNo, pSoldier->sGridNo);
// Run through each friendly.
for ( UINT8 iCounter = gTacticalStatus.Team[ pSoldier->bTeam ].bFirstID ; iCounter <= gTacticalStatus.Team[ pSoldier->bTeam ].bLastID ; iCounter ++ )
{
pFriend = MercPtrs[ iCounter ];
ubFriendDir = atan8(CenterX(sTargetGridNo),CenterY(sTargetGridNo),CenterX(pFriend->sGridNo),CenterY(pFriend->sGridNo));
ubFriendDir = GetDirectionFromCenterCellXYGridNo(sTargetGridNo, pFriend->sGridNo);
if (pFriend != pSoldier &&
pFriend->bActive &&
@@ -4823,7 +4823,7 @@ BOOLEAN AnyCoverFromSpot( INT32 sSpot, INT8 bLevel, INT32 sThreatLoc, INT8 bThre
return FALSE;
}
ubDirection = atan8(CenterX(sSpot), CenterY(sSpot), CenterX(sThreatLoc), CenterY(sThreatLoc));
ubDirection = GetDirectionFromCenterCellXYGridNo(sSpot, sThreatLoc);
sCoverSpot = NewGridNo( sSpot, DirectionInc( ubDirection ) );
if ( TileIsOutOfBounds( sCoverSpot ) )
@@ -5013,7 +5013,7 @@ UINT8 AIDirection(INT32 sSpot1, INT32 sSpot2)
return DIRECTION_IRRELEVANT;
}
return atan8(CenterX(sSpot1), CenterY(sSpot1), CenterX(sSpot2), CenterY(sSpot2));
return GetDirectionFromCenterCellXYGridNo(sSpot1, sSpot2);
}
BOOLEAN AICheckIsSniper(SOLDIERTYPE *pSoldier)
+1 -8
View File
@@ -783,7 +783,6 @@ BOOLEAN CloseEnoughForGrenadeToss( INT32 sGridNo, INT32 sGridNo2 )
{
INT32 sTempGridNo;
UINT8 ubDirection;
INT16 sXPos, sYPos, sXPos2, sYPos2;
UINT8 ubMovementCost;
if (sGridNo == sGridNo2 )
@@ -815,13 +814,7 @@ BOOLEAN CloseEnoughForGrenadeToss( INT32 sGridNo, INT32 sGridNo2 )
// so we can now do a loop safely
sTempGridNo = sGridNo;
sXPos = CenterX( sGridNo );
sYPos = CenterY( sGridNo );
sXPos2 = CenterX( sGridNo2 );
sYPos2 = CenterY( sGridNo2 );
ubDirection = atan8( sXPos, sYPos, sXPos2, sYPos2 );
ubDirection = GetDirectionFromCenterCellXYGridNo(sGridNo, sGridNo2);
// For each step of the loop, we are checking for door or obstacle movement costs. If we
// find we're blocked, then this is no good for grenade tossing!
do
+3 -3
View File
@@ -481,7 +481,7 @@ INT8 CreatureDecideActionYellow( SOLDIERTYPE * pSoldier )
if (pSoldier->aiData.bMobility != CREATURE_IMMOBILE)
{
// determine direction from this soldier in which the noise lies
ubNoiseDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sNoiseGridNo),CenterY(sNoiseGridNo));
ubNoiseDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sNoiseGridNo);
// if soldier is not already facing in that direction,
// and the noise source is close enough that it could possibly be seen
@@ -849,7 +849,7 @@ INT8 CreatureDecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
if (!TileIsOutOfBounds(sClosestOpponent))
{
// determine direction from this soldier to the closest opponent
ubOpponentDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sClosestOpponent),CenterY(sClosestOpponent));
ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestOpponent);
// if soldier is not already facing in that direction,
// and the opponent is close enough that he could possibly be seen
@@ -1410,7 +1410,7 @@ INT8 CreatureDecideActionBlack( SOLDIERTYPE * pSoldier )
}
else if (GetAPsToLook( pSoldier ) <= pSoldier->bActionPoints) // turn to face enemy
{
bDirection = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sClosestOpponent),CenterY(sClosestOpponent));
bDirection = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestOpponent);
// if we're not facing towards him
if (pSoldier->ubDirection != bDirection && ValidCreatureTurn( pSoldier, bDirection ) )
+31 -33
View File
@@ -475,8 +475,7 @@ INT8 DecideActionSchedule( SOLDIERTYPE * pSoldier )
switch( pSoldier->bAIScheduleProgress )
{
case 0:
sX = CenterX( pSoldier->sOffWorldGridNo );
sY = CenterY( pSoldier->sOffWorldGridNo );
ConvertGridNoToCenterCellXY(pSoldier->sOffWorldGridNo, &sX, &sY);
pSoldier->EVENT_SetSoldierPosition( sX, sY );
pSoldier->bInSector = TRUE;
MoveSoldierFromAwayToMercSlot( pSoldier );
@@ -567,7 +566,7 @@ INT8 DecideActionBoxerEnteringRing(SOLDIERTYPE *pSoldier)
if (!TileIsOutOfBounds(sDesiredMercLoc))
{
// see if we are facing this person
ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sDesiredMercLoc),CenterY(sDesiredMercLoc));
ubDesiredMercDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sDesiredMercLoc);
// if not already facing in that direction,
if ( pSoldier->ubDirection != ubDesiredMercDir && pSoldier->InternalIsValidStance( ubDesiredMercDir, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
@@ -628,7 +627,7 @@ INT8 DecideActionNamedNPC( SOLDIERTYPE * pSoldier )
}
// see if we are facing this person
ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sDesiredMercLoc),CenterY(sDesiredMercLoc));
ubDesiredMercDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sDesiredMercLoc);
// if not already facing in that direction,
if (pSoldier->ubDirection != ubDesiredMercDir && pSoldier->InternalIsValidStance( ubDesiredMercDir, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
@@ -784,7 +783,7 @@ INT8 DecideActionGreen(SOLDIERTYPE *pSoldier)
UINT8 ubRingDir;
// face ring!
ubRingDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(CENTER_OF_RING),CenterY(CENTER_OF_RING));
ubRingDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, CENTER_OF_RING);
if ( gfTurnBasedAI || GetAPsToLook( pSoldier ) <= pSoldier->bActionPoints )
{
if ( pSoldier->ubDirection != ubRingDir )
@@ -962,7 +961,7 @@ INT8 DecideActionGreen(SOLDIERTYPE *pSoldier)
if ( PythSpacesAway(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo) < 2 )
{
// see if we are facing this person
UINT8 ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(MercPtrs[ubPerson]->sGridNo),CenterY(MercPtrs[ubPerson]->sGridNo));
UINT8 ubDesiredMercDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo);
// if not already facing in that direction,
if ( pSoldier->ubDirection != ubDesiredMercDir )
@@ -1491,8 +1490,7 @@ INT8 DecideActionGreen(SOLDIERTYPE *pSoldier)
UINT8 ubNoiseDir;
if (TileIsOutOfBounds(sNoiseGridNo) ||
(ubNoiseDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sNoiseGridNo),CenterY(sNoiseGridNo))
) == pSoldier->ubDirection )
( ubNoiseDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sNoiseGridNo) ) == pSoldier->ubDirection )
{
pSoldier->aiData.usActionData = PreRandom(8);
@@ -1664,7 +1662,7 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier)
if ( PythSpacesAway(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo) < 2 )
{
// see if we are facing this person
UINT8 ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(MercPtrs[ubPerson]->sGridNo),CenterY(MercPtrs[ubPerson]->sGridNo));
UINT8 ubDesiredMercDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo);
// if not already facing in that direction,
if ( pSoldier->ubDirection != ubDesiredMercDir )
@@ -1717,7 +1715,7 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier)
if ( PythSpacesAway(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo) < 2 )
{
// see if we are facing this person
UINT8 ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(MercPtrs[ubPerson]->sGridNo),CenterY(MercPtrs[ubPerson]->sGridNo));
UINT8 ubDesiredMercDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo);
// if not already facing in that direction,
if ( pSoldier->ubDirection != ubDesiredMercDir )
@@ -1794,7 +1792,7 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier)
////////////////////////////////////////////////////////////////////////////
// determine direction from this soldier in which the noise lies
ubNoiseDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sNoiseGridNo),CenterY(sNoiseGridNo));
ubNoiseDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sNoiseGridNo);
// if soldier is not already facing in that direction,
// and the noise source is close enough that it could possibly be seen
@@ -3312,7 +3310,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier)
DebugAI(AI_MSG_INFO, pSoldier, String("I am close enough to free POW"));
// see if we are facing this person
UINT8 ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(MercPtrs[ubPerson]->sGridNo),CenterY(MercPtrs[ubPerson]->sGridNo));
UINT8 ubDesiredMercDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo);
// if not already facing in that direction,
if ( pSoldier->ubDirection != ubDesiredMercDir )
@@ -3376,7 +3374,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier)
DebugAI(AI_MSG_INFO, pSoldier, String("Wounded soldier is nearby"));
// see if we are facing this person
UINT8 ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(MercPtrs[ubPerson]->sGridNo),CenterY(MercPtrs[ubPerson]->sGridNo));
UINT8 ubDesiredMercDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo);
// if not already facing in that direction,
if ( pSoldier->ubDirection != ubDesiredMercDir )
@@ -4680,7 +4678,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier)
{
DebugAI(AI_MSG_TOPIC, pSoldier, String("[Look around towards enemy]"));
// determine direction from this soldier to the closest opponent
ubOpponentDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sClosestOpponent),CenterY(sClosestOpponent));
ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestOpponent);
// if soldier is not already facing in that direction,
// and the opponent is close enough that he could possibly be seen
@@ -4791,7 +4789,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier)
if (!TileIsOutOfBounds(sClosestDisturbance))
{
ubOpponentDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sClosestDisturbance ), CenterY( sClosestDisturbance ) );
ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestDisturbance);
if ( pSoldier->ubDirection == ubOpponentDir )
{
DebugAI(AI_MSG_INFO, pSoldier, String("Already facing closest disturbance, face a random direction"));
@@ -4936,12 +4934,12 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier)
AIPopMessage(tempstr);
#endif
////////////////////////////////////////////////////////////////////////////
// SANDRO - allow regular soldiers to raise scoped weapons to see farther away too
if (!gfTurnBasedAI || (GetAPsToReadyWeapon( pSoldier, READY_RIFLE_CROUCH ) + GetAPsToChangeStance( pSoldier, ANIM_CROUCH )) <= pSoldier->bActionPoints)
{
// determine direction from this soldier to the closest opponent
ubOpponentDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sClosestOpponent),CenterY(sClosestOpponent));
////////////////////////////////////////////////////////////////////////////
// SANDRO - allow regular soldiers to raise scoped weapons to see farther away too
if (!gfTurnBasedAI || (GetAPsToReadyWeapon( pSoldier, READY_RIFLE_CROUCH ) + GetAPsToChangeStance( pSoldier, ANIM_CROUCH )) <= pSoldier->bActionPoints)
{
// determine direction from this soldier to the closest opponent
ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestOpponent);
if (!WeaponReady(pSoldier) &&
pSoldier->ubDirection == ubOpponentDir &&
@@ -4978,7 +4976,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier)
if (!TileIsOutOfBounds(sClosestDisturbance))
{
ubOpponentDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sClosestDisturbance ), CenterY( sClosestDisturbance ) );
ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestDisturbance);
if ( pSoldier->ubDirection != ubOpponentDir )
{
if ( !gfTurnBasedAI || GetAPsToLook( pSoldier ) <= pSoldier->bActionPoints )
@@ -7156,7 +7154,7 @@ L_NEWAIM:
if(!TileIsOutOfBounds(pSoldier->sLastTarget))
sClosestOpponent = pSoldier->sLastTarget;
pSoldier->aiData.bNextAction = AI_ACTION_CHANGE_FACING;
pSoldier->aiData.usNextActionData = atan8(CenterX(sBestCover),CenterY(sBestCover),CenterX(sClosestOpponent),CenterY(sClosestOpponent));
pSoldier->aiData.usNextActionData = GetDirectionFromCenterCellXYGridNo(sBestCover, sClosestOpponent);
}
return(AI_ACTION_TAKE_COVER);
}
@@ -7252,7 +7250,7 @@ L_NEWAIM:
// if we have a closest seen opponent
if (!TileIsOutOfBounds(sClosestOpponent))
{
bDirection = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sClosestOpponent),CenterY(sClosestOpponent));
bDirection = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestOpponent);
// if we're not facing towards him
if (pSoldier->ubDirection != bDirection)
@@ -7314,7 +7312,7 @@ L_NEWAIM:
{
if(!TileIsOutOfBounds(pSoldier->sLastTarget))//dnl ch58 150913
sClosestOpponent = pSoldier->sLastTarget;
bDirection = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sClosestOpponent),CenterY(sClosestOpponent));
bDirection = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestOpponent);
// if we're not facing towards him
if ( pSoldier->ubDirection != bDirection && pSoldier->InternalIsValidStance( bDirection, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) )
@@ -7965,7 +7963,7 @@ INT8 ArmedVehicleDecideActionGreen( SOLDIERTYPE *pSoldier )
UINT8 ubNoiseDir;
if ( TileIsOutOfBounds( sNoiseGridNo ) ||
(ubNoiseDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sNoiseGridNo ), CenterY( sNoiseGridNo ) )
(ubNoiseDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sNoiseGridNo)
) == pSoldier->ubDirection )
{
@@ -8068,7 +8066,7 @@ INT8 ArmedVehicleDecideActionYellow( SOLDIERTYPE *pSoldier )
////////////////////////////////////////////////////////////////////////////
// determine direction from this soldier in which the noise lies
ubNoiseDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sNoiseGridNo ), CenterY( sNoiseGridNo ) );
ubNoiseDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sNoiseGridNo);
// if soldier is not already facing in that direction,
// and the noise source is close enough that it could possibly be seen
@@ -9317,7 +9315,7 @@ INT8 ArmedVehicleDecideActionRed( SOLDIERTYPE *pSoldier)
if ( bHighestWatchLoc != -1 )
{
// see if we need turn to face that location
ubOpponentDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( gsWatchedLoc[pSoldier->ubID][bHighestWatchLoc] ), CenterY( gsWatchedLoc[pSoldier->ubID][bHighestWatchLoc] ) );
ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, gsWatchedLoc[pSoldier->ubID][bHighestWatchLoc]);
// if soldier is not already facing in that direction,
// and the opponent is close enough that he could possibly be seen
@@ -9503,7 +9501,7 @@ INT8 ArmedVehicleDecideActionRed( SOLDIERTYPE *pSoldier)
if ( !TileIsOutOfBounds( sClosestOpponent ) )
{
// determine direction from this soldier to the closest opponent
ubOpponentDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sClosestOpponent ), CenterY( sClosestOpponent ) );
ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestOpponent);
// if soldier is not already facing in that direction,
// and the opponent is close enough that he could possibly be seen
@@ -9548,7 +9546,7 @@ INT8 ArmedVehicleDecideActionRed( SOLDIERTYPE *pSoldier)
if ( !TileIsOutOfBounds( sClosestDisturbance ) )
{
ubOpponentDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sClosestDisturbance ), CenterY( sClosestDisturbance ) );
ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestDisturbance);
if ( pSoldier->ubDirection == ubOpponentDir )
{
ubOpponentDir = (UINT8)PreRandom( NUM_WORLD_DIRECTIONS );
@@ -9599,7 +9597,7 @@ INT8 ArmedVehicleDecideActionRed( SOLDIERTYPE *pSoldier)
if ( !TileIsOutOfBounds( sClosestDisturbance ) )
{
ubOpponentDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sClosestDisturbance ), CenterY( sClosestDisturbance ) );
ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestDisturbance);
if ( pSoldier->ubDirection != ubOpponentDir )
{
if ( !gfTurnBasedAI || GetAPsToLook( pSoldier ) <= pSoldier->bActionPoints )
@@ -10183,7 +10181,7 @@ INT8 ArmedVehicleDecideActionBlack( SOLDIERTYPE *pSoldier )
if ( gGameExternalOptions.fEnemyTanksCanMoveInTactical )
{
// first get the direction, as we will need to pass that in to ShootingStanceChange
bDirection = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( BestAttack.sTarget ), CenterY( BestAttack.sTarget ) );
bDirection = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, BestAttack.sTarget);
// Change facing
if ( pSoldier->ubDirection != bDirection && pSoldier->InternalIsValidStance( bDirection, gAnimControl[pSoldier->usAnimState].ubEndHeight ) )
@@ -10470,7 +10468,7 @@ INT8 ArmedVehicleDecideActionBlack( SOLDIERTYPE *pSoldier )
{
if ( !TileIsOutOfBounds( pSoldier->sLastTarget ) )//dnl ch58 150913
sClosestOpponent = pSoldier->sLastTarget;
bDirection = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sClosestOpponent ), CenterY( sClosestOpponent ) );
bDirection = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestOpponent);
// if we're not facing towards him
if ( pSoldier->ubDirection != bDirection && pSoldier->InternalIsValidStance( bDirection, gAnimControl[pSoldier->usAnimState].ubEndHeight ) )
+24 -11
View File
@@ -698,8 +698,7 @@ INT8 ExplosiveDamageStructureAtGridNo( STRUCTURE * pCurrent, STRUCTURE **ppNextC
#endif
// Get xy
sX = CenterX( sGridNo );
sY = CenterY( sGridNo );
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
// ATE: Continue if we are only looking for walls
if ( fOnlyWalls && !( pCurrent->fFlags & STRUCTURE_WALLSTUFF ) )
@@ -1305,7 +1304,9 @@ INT8 ExplosiveDamageStructureAtGridNo( STRUCTURE * pCurrent, STRUCTURE **ppNextC
// Make secondary explosion if eplosive....
if ( fExplosive )
{
InternalIgniteExplosion( ubOwner, CenterX( sBaseGridNo ), CenterY( sBaseGridNo ), 0, sBaseGridNo, STRUCTURE_EXPLOSION, FALSE, bLevel );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(sBaseGridNo, &sX, &sY);
InternalIgniteExplosion( ubOwner, sX, sY, 0, sBaseGridNo, STRUCTURE_EXPLOSION, FALSE, bLevel );
}
}
@@ -1477,7 +1478,9 @@ void ExplosiveDamageGridNo( INT32 sGridNo, INT16 sWoundAmt, UINT32 uiDist, BOOLE
}
{
InternalIgniteExplosion( ubOwner, CenterX( sNewGridNo2 ), CenterY( sNewGridNo2 ), 0, sNewGridNo2, RDX, FALSE, bLevel );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(sNewGridNo2, &sX, &sY);
InternalIgniteExplosion( ubOwner, sX, sY, 0, sNewGridNo2, RDX, FALSE, bLevel );
}
fToBreak = TRUE;
@@ -4163,7 +4166,10 @@ void HandleExplosionQueue( void )
// no preplaced (owner=NOBODY) tripwire with explosive attachments allowed
if ( gGameExternalOptions.bAllowExplosiveAttachments && (*pObj)[0]->data.misc.ubBombOwner > 1 )
{
fAttFound=HandleAttachedExplosions( (UINT8) ((*pObj)[0]->data.misc.ubBombOwner - 2), CenterX( sGridNo ), CenterY( sGridNo ), 0,
INT16 sX, sY;
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
fAttFound=HandleAttachedExplosions( (UINT8) ((*pObj)[0]->data.misc.ubBombOwner - 2), sX, sY, 0,
sGridNo, (*pObj)[0]->data.misc.usBombItem, FALSE, ubLevel, (*pObj)[0]->data.ubDirection, pObj);
}
}
@@ -4236,15 +4242,18 @@ void HandleExplosionQueue( void )
CheckForBuriedBombsAndRemoveFlags( sGridNo, ubLevel);
// BOOM!
INT16 sX, sY;
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
// bomb objects only store the SIDE who placed the bomb! :-(
if ( (*pObj)[0]->data.misc.ubBombOwner > 1 )
{
IgniteExplosion( (UINT8) ((*pObj)[0]->data.misc.ubBombOwner - 2), CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, (*pObj)[0]->data.misc.usBombItem, ubLevel, (*pObj)[0]->data.ubDirection, pObj);
IgniteExplosion( (UINT8) ((*pObj)[0]->data.misc.ubBombOwner - 2), sX, sY, 0, sGridNo, (*pObj)[0]->data.misc.usBombItem, ubLevel, (*pObj)[0]->data.ubDirection, pObj);
}
else
{
// pre-placed
IgniteExplosion( NOBODY, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, (*pObj)[0]->data.misc.usBombItem, ubLevel, (*pObj)[0]->data.ubDirection );
IgniteExplosion( NOBODY, sX, sY, 0, sGridNo, (*pObj)[0]->data.misc.usBombItem, ubLevel, (*pObj)[0]->data.ubDirection );
}
}
/* if ( FindWorldItemForBuriedBombInGridNo(sGridNo, ubLevel) != -1 )
@@ -5530,8 +5539,8 @@ void FireFragmentsTrapGun( SOLDIERTYPE* pThrower, INT32 gridno, INT16 sZ, OBJECT
INT16 horizontalarc = 5;
INT16 verticalarc = 0;
INT16 sX = CenterX(gridno);
INT16 sY = CenterY(gridno);
INT16 sX, sY;
ConvertGridNoToCenterCellXY(gridno, &sX, &sY);
AssertMsg( ubFragRange > 0 , "Fragmentation data lacks range property!" );
@@ -6331,7 +6340,9 @@ void RoofDestruction( INT32 sGridNo, BOOLEAN fWithExplosion )
static UINT16 usRoofCollapseExplosionIndex = 1727;
if ( HasItemFlag( usRoofCollapseExplosionIndex, ROOF_COLLAPSE_ITEM ) || GetFirstItemWithFlag( &usRoofCollapseExplosionIndex, ROOF_COLLAPSE_ITEM ) )
{
InternalIgniteExplosion( NOBODY, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, usRoofCollapseExplosionIndex, FALSE, 0 );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
InternalIgniteExplosion( NOBODY, sX, sY, 0, sGridNo, usRoofCollapseExplosionIndex, FALSE, 0 );
}
if ( Chance( 15 ) )
@@ -6340,7 +6351,9 @@ void RoofDestruction( INT32 sGridNo, BOOLEAN fWithExplosion )
if ( debrissmokeitem )
{
InternalIgniteExplosion( NOBODY, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, debrissmokeitem, FALSE, 0 );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
InternalIgniteExplosion( NOBODY, sX, sY, 0, sGridNo, debrissmokeitem, FALSE, 0 );
}
}
}
+3 -64
View File
@@ -708,27 +708,6 @@ BOOLEAN GetMouseMapPos( INT32 *psMapPos )
}
BOOLEAN ConvertMapPosToWorldTileCenter( INT32 usMapPos, INT16 *psXPos, INT16 *psYPos )
{
INT16 sWorldX, sWorldY;
INT16 sCellX, sCellY;
// Get X, Y world GRID Coordinates
sWorldY = ( usMapPos / WORLD_COLS );
sWorldX = usMapPos - ( sWorldY * WORLD_COLS );
// Convert into cell coords
sCellY = sWorldY * CELL_Y_SIZE;
sCellX = sWorldX * CELL_X_SIZE;
// Add center tile positions
*psXPos = sCellX + ( CELL_X_SIZE / 2 );
*psYPos = sCellY + ( CELL_Y_SIZE / 2 );
return( TRUE );
}
void GetScreenXYWorldCoords( INT16 sScreenX, INT16 sScreenY, INT16 *psWorldX, INT16 *psWorldY )
{
INT16 sOffsetX, sOffsetY;
@@ -931,7 +910,7 @@ void ConvertGridNoToCellXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos )
*sXPos = ( *sXPos * CELL_X_SIZE );
}
void ConvertGridNoToCenterCellXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos )
void ConvertGridNoToCenterCellXY( const INT32 sGridNo, INT16 *sXPos, INT16 *sYPos )
{
*sYPos = ( sGridNo / WORLD_COLS );
*sXPos = ( sGridNo - ( *sYPos * WORLD_COLS ) );
@@ -940,22 +919,6 @@ void ConvertGridNoToCenterCellXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos )
*sXPos = ( *sXPos * CELL_X_SIZE ) + ( CELL_X_SIZE / 2 );
}
INT32 GetRangeFromGridNoDiff( INT32 sGridNo1, INT32 sGridNo2 )
{
INT32 uiDist;
INT16 sXPos, sYPos, sXPos2, sYPos2;
// Convert our grid-not into an XY
ConvertGridNoToXY( sGridNo1, &sXPos, &sYPos );
// Convert our grid-not into an XY
ConvertGridNoToXY( sGridNo2, &sXPos2, &sYPos2 );
uiDist = (INT32)(sqrt((double) ( sXPos2 - sXPos )*( sXPos2 - sXPos ) + ( sYPos2 - sYPos ) * ( sYPos2 - sYPos ) ));
return( uiDist );
}
INT32 GetRangeInCellCoordsFromGridNoDiff( INT32 sGridNo1, INT32 sGridNo2 )
{
INT16 sXPos, sYPos, sXPos2, sYPos2;
@@ -1002,8 +965,8 @@ INT16 PythSpacesAway(INT32 sOrigin, INT32 sDest)
{
INT16 sRows,sCols,sResult;
sRows = abs((sOrigin / MAXCOL) - (sDest / MAXCOL));
sCols = abs((sOrigin % MAXROW) - (sDest % MAXROW));
sRows = (sOrigin / MAXCOL) - (sDest / MAXCOL);
sCols = (sOrigin % MAXROW) - (sDest % MAXROW);
// apply Pythagoras's theorem for right-handed triangle:
@@ -1234,30 +1197,6 @@ INT16 ExtQuickestDirection(INT16 origin, INT16 dest)
}
// Returns the (center ) cell coordinates in X
INT16 CenterX( INT32 sGridNo )
{
INT32 sYPos, sXPos;
sYPos = sGridNo / WORLD_COLS;
sXPos = ( sGridNo - ( sYPos * WORLD_COLS ) );
return( ( sXPos * CELL_X_SIZE ) + ( CELL_X_SIZE / 2 ) );
}
// Returns the (center ) cell coordinates in Y
INT16 CenterY( INT32 sGridNo )
{
INT32 sYPos, sXPos;
sYPos = sGridNo / WORLD_COLS;
sXPos = ( sGridNo - ( sYPos * WORLD_COLS ) );
return( ( sYPos * CELL_Y_SIZE ) + ( CELL_Y_SIZE / 2 ) );
}
INT16 MapX( INT32 sGridNo )
{
INT32 sYPos, sXPos;
+2 -11
View File
@@ -45,7 +45,7 @@ extern UINT8 gPurpendicularDirection[ NUM_WORLD_DIRECTIONS ][ NUM_WORLD_DIRECTIO
void ConvertDirectionToVectorInXY(UINT8 ubDirection, INT16* sXDir, INT16* sYDir);
void ConvertGridNoToXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos );
void ConvertGridNoToCellXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos );
void ConvertGridNoToCenterCellXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos );
void ConvertGridNoToCenterCellXY( const INT32 sGridNo, INT16 *sXPos, INT16 *sYPos );
// GRID NO MANIPULATION FUNCTIONS
@@ -88,11 +88,8 @@ BOOLEAN GridNoOnVisibleWorldTile( INT32 sGridNo );
BOOLEAN GridNoOnVisibleWorldTileGivenYLimits( INT32 sGridNo );
BOOLEAN GridNoOnEdgeOfMap( INT32 sGridNo, INT8 * pbDirection );
BOOLEAN ConvertMapPosToWorldTileCenter( INT32 usMapPos, INT16 *psXPos, INT16 *psYPos );
BOOLEAN CellXYToScreenXY(INT16 sCellX, INT16 sCellY, INT16 *sScreenX, INT16 *sScreenY);
INT32 GetRangeFromGridNoDiff( INT32 sGridNo1, INT32 sGridNo2 );
INT32 GetRangeInCellCoordsFromGridNoDiff( INT32 sGridNo1, INT32 sGridNo2 );
BOOLEAN IsPointInScreenRect( INT16 sXPos, INT16 sYPos, SGPRect *pRect );
@@ -110,12 +107,6 @@ INT16 QuickestDirection(INT16 origin, INT16 dest);
INT16 ExtQuickestDirection(INT16 origin, INT16 dest);
// Returns the (center ) cell coordinates in X
INT16 CenterX( INT32 sGridNo );
// Returns the (center ) cell coordinates in Y
INT16 CenterY( INT32 sGridNo );
INT16 MapX( INT32 sGridNo );
INT16 MapY( INT32 sGridNo );
BOOLEAN FindFenceJumpDirection( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bStartingDir, INT8 *pbDirection );
@@ -157,4 +148,4 @@ BOOLEAN FindWindowJumpDirection( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bSta
// Flugente: is this gridno near a player merc?
BOOLEAN GridNoNearPlayerMercs( INT32 sGridNo, INT16 sRadius );
#endif
#endif
+4 -1
View File
@@ -84,7 +84,10 @@ void UpdateLightingSprite( LIGHTEFFECT *pLight )
LightSpritePower( pLight->iLight, TRUE );
// LightSpriteFake( pLight->iLight );
LightSpritePosition( pLight->iLight, (INT16)( CenterX( pLight->sGridNo ) / CELL_X_SIZE ), (INT16)( CenterY( pLight->sGridNo ) / CELL_Y_SIZE ) );
INT16 sX, sY;
ConvertGridNoToCenterCellXY(pLight->sGridNo, &sX, &sY);
LightSpritePosition( pLight->iLight, (INT16)( sX / CELL_X_SIZE ), (INT16)( sY / CELL_Y_SIZE ) );
}
// Flugente: create a pure light, worry about updating sight in other functions
-6
View File
@@ -557,12 +557,6 @@ BOOLEAN LoadAllMapChangesFromMapTempFileAndApplyThem( )
{
ReSetSectorFlag( gWorldSectorX, gWorldSectorY, gbWorldSectorZ, SF_MAP_MODIFICATIONS_TEMP_FILE_EXISTS );
}
#ifndef USE_VFS
FileClose( hFile );
#else
// FileClose( hFile );
// file already deleted. can't close it anymore (handle is invalid)
#endif
//Free the memory used for the temp array
MemFree( pTempArrayOfMaps );
-31
View File
@@ -24,10 +24,6 @@ BOOLEAN gfForceBuildShadeTables = FALSE;
void DetermineRGBDistributionSettings()
{
#ifndef USE_VFS
STRING512 DataDir;
STRING512 ExecDir;
#endif
STRING512 ShadeTableDir;
UINT32 uiRBitMask, uiGBitMask, uiBBitMask;
UINT32 uiPrevRBitMask, uiPrevGBitMask, uiPrevBBitMask;
@@ -37,36 +33,9 @@ void DetermineRGBDistributionSettings()
BOOLEAN fCleanShadeTable = FALSE;
BOOLEAN fLoadedPrevRGBDist = FALSE;
#ifndef USE_VFS
// Snap: save current directory
GetFileManCurrentDirectory( DataDir );
//First, determine if we have a file saved. If not, then this is the first time, and
//all shade tables will have to be built and saved to disk. This can be time consuming, adding up to
//3-4 seconds to the time of a map load.
GetExecutableDirectory( ExecDir );
sprintf( ShadeTableDir, "%s\\%s", DataDir, SHADE_TABLE_DIR );
//Check to make sure we have a ShadeTable directory. If we don't create one!
if( !SetFileManCurrentDirectory( ShadeTableDir ) )
{
if( !MakeFileManDirectory( ShadeTableDir ) )
{
AssertMsg( 0, "ShadeTable directory doesn't exist, and couldn't create one!" );
}
if( !SetFileManCurrentDirectory( ShadeTableDir ) )
{
AssertMsg( 0, "Couldn't access the newly created ShadeTable directory." );
}
fSaveRGBDist = TRUE;
}
// directory existed or was created.
SetFileManCurrentDirectory( DataDir );
#else
// changing the current directory can screw up the VFS; don't do it
// the creation of the SHADE_TABLE_DIR directory is done by the VFS
sprintf( ShadeTableDir, "%s", SHADE_TABLE_DIR );
#endif
CHAR8 sRGBDist[50];
sprintf( sRGBDist, "%s\\%s", SHADE_TABLE_DIR, "RGBDist.dat");
+5 -3
View File
@@ -534,9 +534,11 @@ void AddSmokeEffectToTile( INT32 iSmokeEffectID, INT8 bType, INT32 sGridNo, INT8
AniParams.uiFlags = ANITILE_CACHEDTILE | ANITILE_FORWARD | ANITILE_SMOKE_EFFECT | ANITILE_LOOPING | ANITILE_ALWAYS_TRANSLUCENT;
}
AniParams.sX = CenterX( sGridNo );
AniParams.sY = CenterY( sGridNo );
AniParams.sZ = (INT16)0;
INT16 sX, sY;
ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY);
AniParams.sX = sX;
AniParams.sY = sY;
AniParams.sZ = (INT16)0;
// Use the right graphic based on type..
switch( bType )
-2
View File
@@ -138,7 +138,6 @@ void InitEngineTilesets( )
#endif
}
#ifdef USE_VFS
void ExportTilesets(vfs::Path const& filename)
{
UINT32 uiNumBytesRead = 0;
@@ -217,7 +216,6 @@ void ExportTilesets(vfs::Path const& filename)
xmlw.closeNode();
xmlw.writeToFile(filename);
}
#endif
void SetTilesetOneTerrainValues( )
{
+1 -3
View File
@@ -1093,7 +1093,6 @@ void AddSnakeAmim( INT32 sGridno, UINT8 usDirection )
if ( !TileIsOutOfBounds( sGridno ) )
{
ANITILE_PARAMS AniParams;
memset( &AniParams, 0, sizeof(ANITILE_PARAMS) );
AniParams.sGridNo = sGridno;
@@ -1101,8 +1100,7 @@ void AddSnakeAmim( INT32 sGridno, UINT8 usDirection )
AniParams.sDelay = 100;
AniParams.sStartFrame = 0;
AniParams.uiFlags = ANITILE_CACHEDTILE | ANITILE_FORWARD | ANITILE_USE_DIRECTION_FOR_START_FRAME;//| ANITILE_LOOPING;
AniParams.sX = CenterX( sGridno );
AniParams.sY = CenterY( sGridno );
ConvertGridNoToCenterCellXY(sGridno, &AniParams.sX, &AniParams.sY);
AniParams.sZ = 0;
strcpy( AniParams.zCachedFile, "TILECACHE\\WATERSNAKE_MOVE.sti" );
+1 -1
View File
@@ -1995,7 +1995,7 @@ void CalculateLaunchItemBasicParams( SOLDIERTYPE *pSoldier, OBJECTTYPE *pItem, I
{
// bad news - i can't throw item at myself
// so use dir incrementer
UINT8 ubDir = atan8( CenterX(pSoldier->sGridNo), CenterY(pSoldier->sGridNo), CenterX(sGridNo), CenterY(sGridNo) );
UINT8 ubDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sGridNo);
sInterGridNo += DirIncrementer[ubDir];
}
}
+1 -1
View File
@@ -614,7 +614,7 @@ void ShowRiotShield( SOLDIERTYPE* pSoldier, UINT16 *pBuffer, UINT32 uiDestPitchB
// try to keep the shield 'moving' alongside the soldier. This won't work perfectly, but it's better than nothing
INT16 base_x = 0;
INT16 base_y = 0;
ConvertMapPosToWorldTileCenter( pSoldier->sGridNo, &base_x, &base_y );
ConvertGridNoToCenterCellXY( pSoldier->sGridNo, &base_x, &base_y );
INT16 dx = pSoldier->sX - base_x;
INT16 dy = pSoldier->sY - base_y;
-8
View File
@@ -2437,14 +2437,10 @@ BOOLEAN EvaluateWorld(STR8 pSector, UINT8 ubLevel)
if(ValidMapFileName(szFileName))
strcpy(szFilename, pSector);
sprintf(szDirFilename, "MAPS\\%s", szFilename);
#ifdef USE_VFS//dnl ch81 021213
if(guiCurrentScreen == LOADSAVE_SCREEN)
hfile = FileOpen(szDirFilename, FILE_ACCESS_READ, FALSE, gzProfileName);
else
hfile = FileOpen(szDirFilename, FILE_ACCESS_READ);
#else
hfile = FileOpen(szDirFilename, FILE_ACCESS_READ, FALSE);
#endif
if(!hfile)
return(FALSE);
uiFileSize = FileGetSize(hfile);
@@ -2851,7 +2847,6 @@ BOOLEAN LoadWorld(const STR8 puiFilename, FLOAT* pMajorMapVersion, UINT8* pMinor
else
sprintf(aFilename, "MAPS\\%s", puiFilename);
// Open file
#ifdef USE_VFS//dnl ch81 021213
#ifdef JA2EDITOR
if(guiCurrentScreen == LOADSAVE_SCREEN)
hfile = FileOpen(aFilename, FILE_ACCESS_READ, FALSE, gzProfileName);
@@ -2859,9 +2854,6 @@ BOOLEAN LoadWorld(const STR8 puiFilename, FLOAT* pMajorMapVersion, UINT8* pMinor
hfile = FileOpen(aFilename, FILE_ACCESS_READ);
#else
hfile = FileOpen(aFilename, FILE_ACCESS_READ);
#endif
#else
hfile = FileOpen(aFilename, FILE_ACCESS_READ, FALSE);
#endif
if(!hfile)
{
-1
View File
@@ -6,7 +6,6 @@ set(UtilsSrc
"${CMAKE_CURRENT_SOURCE_DIR}/Debug Control.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/dsutil.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Encrypted File.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Event Manager.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Event Pump.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ExportStrings.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Font Control.cpp"
-16
View File
@@ -171,17 +171,6 @@ BINKFLIC *BinkOpenFlic( const CHAR8 *cFilename )
ErrorMsg("BINK ERROR: Out of flic slots, cannot open another");
return(NULL);
}
#ifndef USE_VFS
// Attempt opening the filename
if(!(pBink->hFileHandle = FileOpen( const_cast<CHAR8*>(cFilename), FILE_OPEN_EXISTING | FILE_ACCESS_READ, FALSE ) ) )
{
ErrorMsg("BINK ERROR: Can't open the BINK file");
return(NULL);
}
//Get the real file handle for the file man handle for the smacker file
HANDLE hFile = GetRealFileHandleFromFileManFileHandle( pBink->hFileHandle );
#else
vfs::Path introname(cFilename);
vfs::Path dir,filename;
introname.splitLast(dir,filename);
@@ -207,11 +196,7 @@ BINKFLIC *BinkOpenFlic( const CHAR8 *cFilename )
SGP_RETHROW(_BS(L"Intro file \"") << filename << L"\" could not be extracted" << _BS::wget, ex);
}
}
#endif
#ifndef USE_VFS
if( !( pBink->BinkHandle = BinkOpen((CHAR8 *)hFile, BINKFILEHANDLE ) ) ) //| SMACKTRACKS
#else
vfs::Path tempfilename;
try
{
@@ -226,7 +211,6 @@ BINKFLIC *BinkOpenFlic( const CHAR8 *cFilename )
SGP_RETHROW(L"Temporary intro file could not be read", ex);
}
if( !( pBink->BinkHandle = BinkOpen(tempfilename.to_string().c_str(), BINKNOTHREADEDIO /*BINKFILEHANDLE*/ ) ) ) //| SMACKTRACKS
#endif
{
ErrorMsg("BINK ERROR: Bink won't open the BINK file");
return(NULL);
-18
View File
@@ -194,19 +194,6 @@ SMKFLIC *SmkOpenFlic(const CHAR8 *cFilename)
return(NULL);
}
#ifndef USE_VFS
// Attempt opening the filename
if(!(pSmack->hFileHandle=FileOpen(cFilename, FILE_OPEN_EXISTING | FILE_ACCESS_READ, FALSE)))
{
ErrorMsg("SMK ERROR: Can't open the SMK file");
return(NULL);
}
HANDLE hFile;
//Get the real file handle for the file man handle for the smacker file
hFile = GetRealFileHandleFromFileManFileHandle( pSmack->hFileHandle );
#else
vfs::Path introname(cFilename);
vfs::Path dir,filename;
introname.splitLast(dir,filename);
@@ -232,7 +219,6 @@ SMKFLIC *SmkOpenFlic(const CHAR8 *cFilename)
SGP_RETHROW(_BS(L"Intro file \"") << filename << L"\" could not be extracted" << _BS::wget, ex);
}
}
#endif
// Allocate a Smacker buffer for video decompression
if(!(pSmack->SmackBuffer=SmackBufferOpen(hDisplayWindow,SMACKAUTOBLIT,SCREEN_WIDTH,SCREEN_HEIGHT,0,0)))
@@ -240,9 +226,6 @@ SMKFLIC *SmkOpenFlic(const CHAR8 *cFilename)
ErrorMsg("SMK ERROR: Can't allocate a Smacker decompression buffer");
return(NULL);
}
#ifndef USE_VFS
if(!(pSmack->SmackHandle=SmackOpen((CHAR8 *)hFile, SMACKFILEHANDLE | SMACKTRACKS, SMACKAUTOEXTRA)))
#else
// if(!(pSmack->SmackHandle=SmackOpen(cFilename, SMACKTRACKS, SMACKAUTOEXTRA)))
vfs::Path tempfilename;
try
@@ -258,7 +241,6 @@ SMKFLIC *SmkOpenFlic(const CHAR8 *cFilename)
SGP_RETHROW(L"Temporary intro file could not be read", ex);
}
if(!(pSmack->SmackHandle=SmackOpen(tempfilename.to_string().c_str(), SMACKTRACKS, SMACKAUTOEXTRA)))
#endif
{
ErrorMsg("SMK ERROR: Smacker won't open the SMK file");
return(NULL);
-20
View File
@@ -62,30 +62,10 @@ static struct LiveLog {
void LiveMessage( CHAR8 *strMessage)
{
#ifndef USE_VFS
FILE *OutFile;
if ((OutFile = fopen("Log.txt", "a+t")) != NULL)
{
fprintf(OutFile, "%s\n", strMessage);
fclose(OutFile);
}
#else
SGP_LOG(s_LiveLog.id, strMessage);
#endif
}
void MPDebugMsg( CHAR8 *strMessage)
{
#ifndef USE_VFS
FILE *OutFile;
if ((OutFile = fopen("MPDebug.txt", "a+t")) != NULL)
{
fprintf(OutFile, "%s\n", strMessage);
fclose(OutFile);
}
#else
static vfs::Log& mpMsg = *vfs::Log::create(L"MPDebug.txt", true);
mpMsg << strMessage << vfs::Log::endl;
#endif
}
-234
View File
@@ -1,234 +0,0 @@
#include <stdio.h>
#include <time.h>
#include "sgp.h"
#include "container.h"
#include "wcheck.h"
#include "Event Manager.h"
#include "Timer Control.h"
HLIST hEventQueue = NULL;
HLIST hDelayEventQueue = NULL;
HLIST hDemandEventQueue = NULL;
#define QUEUE_RESIZE 20
// LOCAL FUNCTIONS
HLIST GetQueue( UINT8 ubQueueID );
void SetQueue( UINT8 ubQueueID, HLIST hQueue );
BOOLEAN InitializeEventManager( )
{
// Create Queue
hEventQueue = CreateList( QUEUE_RESIZE, sizeof( PTR ) );
if ( hEventQueue == NULL )
{
return( FALSE );
}
// Create Delay Queue
hDelayEventQueue = CreateList( QUEUE_RESIZE, sizeof( PTR ) );
if ( hDelayEventQueue == NULL )
{
return( FALSE );
}
// Create Demand Queue (events on this queue are only processed when specifically
// called for by code)
hDemandEventQueue = CreateList( QUEUE_RESIZE, sizeof( PTR ) );
if ( hDemandEventQueue == NULL )
{
return( FALSE );
}
return( TRUE );
}
BOOLEAN ShutdownEventManager( )
{
if ( hEventQueue != NULL )
{
DeleteList( hEventQueue );
}
if ( hDelayEventQueue != NULL )
{
DeleteList( hDelayEventQueue );
}
if ( hDemandEventQueue != NULL )
{
DeleteList( hDemandEventQueue );
}
return( TRUE );
}
BOOLEAN AddEvent( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT32 uiDataSize, UINT8 ubQueueID )
{
EVENT *pEvent;
UINT32 uiEventSize = sizeof( EVENT );
HLIST hQueue;
// Allocate new event
pEvent = (EVENT *) MemAlloc( uiEventSize + uiDataSize );
CHECKF( pEvent != NULL );
// Set values
pEvent->TimeStamp = GetJA2Clock( );
pEvent->usDelay = usDelay;
pEvent->uiEvent = uiEvent;
pEvent->uiFlags = 0;
pEvent->uiDataSize = uiDataSize;
pEvent->pData = (BYTE*)pEvent;
pEvent->pData = pEvent->pData + uiEventSize;
memcpy( pEvent->pData, pEventData, uiDataSize );
// Add event to queue
hQueue = GetQueue( ubQueueID );
hQueue = AddtoList( hQueue, &pEvent, ListSize( hQueue ) );
SetQueue( ubQueueID, hQueue );
return( TRUE );
}
BOOLEAN RemoveEvent( EVENT **ppEvent, UINT32 uiIndex, UINT8 ubQueueID )
{
UINT32 uiQueueSize;
HLIST hQueue;
// Get an event from queue, if one exists
//
hQueue = GetQueue( ubQueueID );
// Get Size
uiQueueSize = ListSize( hQueue );
if ( uiQueueSize > 0 )
{
// Get
CHECKF( RemfromList( hQueue , ppEvent, uiIndex ) != FALSE );
}
else
{
return( FALSE );
}
return( TRUE );
}
BOOLEAN PeekEvent( EVENT **ppEvent, UINT32 uiIndex , UINT8 ubQueueID )
{
UINT32 uiQueueSize;
HLIST hQueue;
// Get an event from queue, if one exists
//
hQueue = GetQueue( ubQueueID );
// Get Size
uiQueueSize = ListSize( hQueue );
if ( uiQueueSize > 0 )
{
// Get
CHECKF( PeekList( hQueue, ppEvent, uiIndex ) != FALSE );
}
else
{
return( FALSE );
}
return( TRUE );
}
BOOLEAN FreeEvent( EVENT *pEvent )
{
CHECKF( pEvent != NULL );
// Delete event
MemFree( pEvent );
return( TRUE );
}
UINT32 EventQueueSize( UINT8 ubQueueID )
{
UINT32 uiQueueSize;
HLIST hQueue;
// Get an event from queue, if one exists
//
hQueue = GetQueue( ubQueueID );
// Get Size
uiQueueSize = ListSize( hQueue );
return( uiQueueSize );
}
HLIST GetQueue( UINT8 ubQueueID )
{
switch( ubQueueID )
{
case PRIMARY_EVENT_QUEUE:
return( hEventQueue );
break;
case SECONDARY_EVENT_QUEUE:
return( hDelayEventQueue );
break;
case DEMAND_EVENT_QUEUE:
return( hDemandEventQueue );
break;
default:
Assert( FALSE );
return( 0 );
break;
}
}
void SetQueue( UINT8 ubQueueID, HQUEUE hQueue )
{
switch( ubQueueID )
{
case PRIMARY_EVENT_QUEUE:
hEventQueue = hQueue;
break;
case SECONDARY_EVENT_QUEUE:
hDelayEventQueue = hQueue;
break;
case DEMAND_EVENT_QUEUE:
hDemandEventQueue = hQueue;
break;
default:
Assert( FALSE );
break;
}
}
-33
View File
@@ -1,33 +0,0 @@
#ifndef __EVENT_MANAGER_H
#define __EVENT_MANAGER_H
typedef struct
{
TIMER TimeStamp;
UINT32 uiFlags;
UINT16 usDelay;
UINT32 uiEvent;
UINT32 uiDataSize;
BYTE *pData;
} EVENT;
#define PRIMARY_EVENT_QUEUE 0
#define SECONDARY_EVENT_QUEUE 1
#define DEMAND_EVENT_QUEUE 2
#define EVENT_EXPIRED 0x00000002
// Management fucntions
BOOLEAN InitializeEventManager( );
BOOLEAN ShutdownEventManager( );
BOOLEAN AddEvent( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT32 uiDataSize, UINT8 ubQueueID );
BOOLEAN RemoveEvent( EVENT **ppEvent, UINT32 uiIndex , UINT8 ubQueueID );
BOOLEAN PeekEvent( EVENT **ppEvent, UINT32 uiIndex , UINT8 ubQueueID );
BOOLEAN FreeEvent( EVENT *pEvent );
UINT32 EventQueueSize( UINT8 ubQueueID );
#endif
+255 -115
View File
@@ -1,21 +1,26 @@
#include <stdio.h>
#include <time.h>
#include "sgp.h"
#include "container.h"
#include "wcheck.h"
#include "Event Pump.h"
#include "Timer.h"
#include "Sound Control.h"
#include "Overhead.h"
#include "weapons.h"
#include "Animation Control.h"
#include "opplist.h"
#include "Tactical Save.h"
#include <stdio.h>
#include <time.h>
#include "sgp.h"
#include "container.h"
#include "wcheck.h"
#include "Event Pump.h"
#include "Timer.h"
#include "Sound Control.h"
#include "Overhead.h"
#include "weapons.h"
#include "Animation Control.h"
#include "opplist.h"
#include "Tactical Save.h"
#include <vector>
#include <queue>
#ifdef NETWORKED
#include "Networking.h"
#include "NetworkEvent.h"
#endif
#include "MemMan.h"
#include "Timer Control.h"
#include "DEBUG.H"
UINT8 gubEncryptionArray4[ BASE_NUMBER_OF_ROTATION_ARRAYS * 3 ][ NEW_ROTATION_ARRAY_SIZE ] =
{
@@ -590,6 +595,44 @@ UINT8 gubEncryptionArray4[ BASE_NUMBER_OF_ROTATION_ARRAYS * 3 ][ NEW_ROTATION_AR
},
};
struct EVENT
{
TIMER TimeStamp;
UINT32 uiFlags;
UINT16 usDelay;
UINT32 uiEvent;
UINT32 uiDataSize;
BYTE* pData;
EVENT(UINT16 delay, UINT32 event, UINT32 dataSize, BYTE* eventData) :
TimeStamp(GetJA2Clock()),
uiFlags(0),
usDelay(delay),
uiEvent(event),
uiDataSize(dataSize),
pData{ eventData }
{
}
EVENT() :
TimeStamp(GetJA2Clock()),
uiFlags(0),
usDelay(0),
uiEvent(0),
uiDataSize(0),
pData{ nullptr }
{}
};
#define PRIMARY_EVENT_QUEUE 0
#define SECONDARY_EVENT_QUEUE 1
#define DEMAND_EVENT_QUEUE 2
#define EVENT_EXPIRED 0x00000002
std::queue<EVENT> hEventQueue;
std::vector<EVENT> hDelayEventQueue;
std::queue<EVENT> hDemandEventQueue;
// GLobals used here, for each event structure used,
// Used as globals for stack reasons
EV_E_PLAYSOUND EPlaySound;
@@ -601,68 +644,144 @@ EV_S_GETNEWPATH SGetNewPath;
EV_S_BEGINTURN SBeginTurn;
EV_S_CHANGESTANCE SChangeStance;
EV_S_SETDIRECTION SSetDirection;
EV_S_SETDESIREDDIRECTION SSetDesiredDirection;
EV_S_BEGINFIREWEAPON SBeginFireWeapon;
EV_S_SETDESIREDDIRECTION SSetDesiredDirection;
EV_S_BEGINFIREWEAPON SBeginFireWeapon;
EV_S_FIREWEAPON SFireWeapon;
EV_S_WEAPONHIT SWeaponHit;
EV_S_STRUCTUREHIT SStructureHit;
EV_S_WINDOWHIT SWindowHit;
EV_S_MISS SMiss;
EV_S_NOISE SNoise;
EV_S_MISS SMiss;
EV_S_NOISE SNoise;
EV_S_STOP_MERC SStopMerc;
EV_S_SENDPATHTONETWORK SUpdateNetworkSoldier;
EV_S_SENDPATHTONETWORK SUpdateNetworkSoldier;
extern BOOLEAN gfAmINetworked;
BOOLEAN AddGameEventToQueue( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT8 ubQueueID );
BOOLEAN ExecuteGameEvent( EVENT *pEvent );
BOOLEAN AddGameEvent( UINT32 uiEvent, UINT16 usDelay, PTR pEventData )
BOOLEAN AddEvent(UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT32 uiDataSize, UINT8 ubQueueID)
{
if (usDelay == DEMAND_EVENT_DELAY)
BYTE* pData = (BYTE*)MemAlloc(uiDataSize);
Assert(pData);
memcpy(pData, pEventData, uiDataSize);
// Add event to queue
switch (ubQueueID)
{
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("AddGameEvent: Sending Local and network #%d", uiEvent));
#ifdef NETWORKED
if(gfAmINetworked)
SendEventToNetwork(uiEvent, usDelay, pEventData);
#endif
return( AddGameEventToQueue( uiEvent, 0, pEventData, DEMAND_EVENT_QUEUE ) );
case PRIMARY_EVENT_QUEUE:
hEventQueue.emplace(usDelay, uiEvent, uiDataSize, pData);
break;
case SECONDARY_EVENT_QUEUE:
hDelayEventQueue.emplace_back(usDelay, uiEvent, uiDataSize, pData);
break;
case DEMAND_EVENT_QUEUE:
hDemandEventQueue.emplace(usDelay, uiEvent, uiDataSize, pData);
break;
default:
Assert(FALSE);
break;
}
else if( uiEvent < EVENTS_LOCAL_AND_NETWORK)
return(TRUE);
}
static BOOLEAN RemoveEventFromSecondaryEventQueue(EVENT* ppEvent, UINT32 uiIndex)
{
if (uiIndex >= hDelayEventQueue.size())
{
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("AddGameEvent: Sending Local and network #%d", uiEvent));
#ifdef NETWORKED
if(gfAmINetworked)
SendEventToNetwork(uiEvent, usDelay, pEventData);
#endif
return( AddGameEventToQueue( uiEvent, usDelay, pEventData, PRIMARY_EVENT_QUEUE ) );
}
else if( uiEvent < EVENTS_ONLY_USED_LOCALLY)
{
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("AddGameEvent: Sending Local #%d", uiEvent));
return( AddGameEventToQueue( uiEvent, usDelay, pEventData, PRIMARY_EVENT_QUEUE ) );
}
else if( uiEvent < EVENTS_ONLY_SENT_OVER_NETWORK)
{
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("AddGameEvent: Sending network #%d", uiEvent));
#ifdef NETWORKED
if(gfAmINetworked)
SendEventToNetwork(uiEvent, usDelay, pEventData);
#endif
return(TRUE);
}
// There is an error with the event
else
return(FALSE);
}
*ppEvent = hDelayEventQueue[uiIndex];
hDelayEventQueue.erase(hDelayEventQueue.begin() + uiIndex);
return(TRUE);
}
BOOLEAN AddGameEventFromNetwork( UINT32 uiEvent, UINT16 usDelay, PTR pEventData )
static BOOLEAN PopEvent(EVENT* ppEvent, UINT8 ubQueueID)
{
return( AddGameEventToQueue( uiEvent, usDelay, pEventData, PRIMARY_EVENT_QUEUE ) );
// Get an event from queue, if one exists
//
switch (ubQueueID)
{
case PRIMARY_EVENT_QUEUE:
if (!hEventQueue.empty())
{
*ppEvent = hEventQueue.front();
hEventQueue.pop();
return(TRUE);
}
break;
case SECONDARY_EVENT_QUEUE:
if (!hDelayEventQueue.empty())
{
*ppEvent = hDelayEventQueue.front();
hDelayEventQueue.erase(hDelayEventQueue.begin());
return(TRUE);
}
break;
case DEMAND_EVENT_QUEUE:
if (!hDemandEventQueue.empty())
{
*ppEvent = hDemandEventQueue.front();
hDemandEventQueue.pop();
return(TRUE);
}
break;
default:
Assert(FALSE);
break;
}
return(FALSE);
}
BOOLEAN AddGameEventToQueue( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT8 ubQueueID )
static BOOLEAN FreeEventData(EVENT* pEvent)
{
CHECKF(pEvent != NULL);
MemFree(pEvent->pData);
//MemFree(pEvent);
return(TRUE);
}
UINT32 EventQueueSize(UINT8 ubQueueID)
{
switch (ubQueueID)
{
case PRIMARY_EVENT_QUEUE:
return(hEventQueue.size());
break;
case SECONDARY_EVENT_QUEUE:
return(hDelayEventQueue.size());
break;
case DEMAND_EVENT_QUEUE:
return(hDemandEventQueue.size());
break;
default:
Assert(FALSE);
return(-1);
break;
}
}
static BOOLEAN AddGameEventToQueue( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT8 ubQueueID )
{
UINT32 uiDataSize;
@@ -783,18 +902,65 @@ BOOLEAN AddGameEventToQueue( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UIN
return( TRUE );
}
BOOLEAN AddGameEvent(UINT32 uiEvent, UINT16 usDelay, PTR pEventData)
{
if (usDelay == DEMAND_EVENT_DELAY)
{
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("AddGameEvent: Sending Local and network #%d", uiEvent));
#ifdef NETWORKED
if (gfAmINetworked)
SendEventToNetwork(uiEvent, usDelay, pEventData);
#endif
return(AddGameEventToQueue(uiEvent, 0, pEventData, DEMAND_EVENT_QUEUE));
}
else if (uiEvent < EVENTS_LOCAL_AND_NETWORK)
{
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("AddGameEvent: Sending Local and network #%d", uiEvent));
#ifdef NETWORKED
if (gfAmINetworked)
SendEventToNetwork(uiEvent, usDelay, pEventData);
#endif
return(AddGameEventToQueue(uiEvent, usDelay, pEventData, PRIMARY_EVENT_QUEUE));
}
else if (uiEvent < EVENTS_ONLY_USED_LOCALLY)
{
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("AddGameEvent: Sending Local #%d", uiEvent));
return(AddGameEventToQueue(uiEvent, usDelay, pEventData, PRIMARY_EVENT_QUEUE));
}
else if (uiEvent < EVENTS_ONLY_SENT_OVER_NETWORK)
{
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("AddGameEvent: Sending network #%d", uiEvent));
#ifdef NETWORKED
if (gfAmINetworked)
SendEventToNetwork(uiEvent, usDelay, pEventData);
#endif
return(TRUE);
}
// There is an error with the event
else
return(FALSE);
}
BOOLEAN AddGameEventFromNetwork(UINT32 uiEvent, UINT16 usDelay, PTR pEventData)
{
return(AddGameEventToQueue(uiEvent, usDelay, pEventData, PRIMARY_EVENT_QUEUE));
}
BOOLEAN DequeAllGameEvents( BOOLEAN fExecute )
{
EVENT *pEvent;
UINT32 uiQueueSize, cnt;
BOOLEAN fCompleteLoop = FALSE;
EVENT pEvent;
UINT32 uiQueueSize, i;
BOOLEAN fCompleteLoop = FALSE;
// First dequeue all primary events
while( EventQueueSize( PRIMARY_EVENT_QUEUE ) > 0 )
{
// Get Event
if ( RemoveEvent( &pEvent, 0, PRIMARY_EVENT_QUEUE) == FALSE )
if (PopEvent( &pEvent, PRIMARY_EVENT_QUEUE) == FALSE )
{
return( FALSE );
}
@@ -802,90 +968,66 @@ BOOLEAN DequeAllGameEvents( BOOLEAN fExecute )
if ( fExecute )
{
// Check if event has a delay and add to secondary queue if so
if ( pEvent->usDelay > 0 )
if ( pEvent.usDelay > 0 )
{
AddGameEventToQueue( pEvent->uiEvent, pEvent->usDelay, pEvent->pData, SECONDARY_EVENT_QUEUE );
AddGameEventToQueue( pEvent.uiEvent, pEvent.usDelay, pEvent.pData, SECONDARY_EVENT_QUEUE );
}
else
{
ExecuteGameEvent( pEvent );
ExecuteGameEvent( &pEvent );
}
}
// Delete event
FreeEvent( pEvent );
FreeEventData( &pEvent );
};
// NOW CHECK SECONDARY QUEUE FOR ANY EXPRIED EVENTS
// Get size of queue
// NOW CHECK SECONDARY QUEUE FOR EVENTS
uiQueueSize = EventQueueSize( SECONDARY_EVENT_QUEUE );
for ( cnt = 0; cnt < uiQueueSize; cnt++ )
for ( i = 0; i < uiQueueSize; i++ )
{
if ( PeekEvent( &pEvent, cnt, SECONDARY_EVENT_QUEUE) == FALSE )
{
return( FALSE );
}
EVENT& pEventRef = hDelayEventQueue[i];
// Check time
if ( ( GetJA2Clock() - pEvent->TimeStamp ) > pEvent->usDelay )
if ( ( GetJA2Clock() - pEventRef.TimeStamp ) > pEventRef.usDelay )
{
if ( fExecute )
{
ExecuteGameEvent( pEvent );
ExecuteGameEvent( &pEventRef );
}
// FLag as expired
pEvent->uiFlags = EVENT_EXPIRED;
pEventRef.uiFlags = EVENT_EXPIRED;
}
}
do
// Remove expired events from secondary event queue
uiQueueSize = EventQueueSize(SECONDARY_EVENT_QUEUE);
for (INT32 i = uiQueueSize-1; i >= 0; i--)
{
uiQueueSize = EventQueueSize( SECONDARY_EVENT_QUEUE );
for ( cnt = 0; cnt < uiQueueSize; cnt++ )
EVENT& pEventRef = hDelayEventQueue[i];
if (pEventRef.uiFlags & EVENT_EXPIRED)
{
if ( PeekEvent( &pEvent, cnt, SECONDARY_EVENT_QUEUE) == FALSE )
{
return( FALSE );
}
// Check time
if ( pEvent->uiFlags & EVENT_EXPIRED )
{
RemoveEvent( &pEvent, cnt, SECONDARY_EVENT_QUEUE );
FreeEvent( pEvent );
// Restart loop
break;
}
RemoveEventFromSecondaryEventQueue(&pEventRef, i);
FreeEventData(&pEventRef);
}
if ( cnt == uiQueueSize )
{
fCompleteLoop = TRUE;
}
} while( fCompleteLoop == FALSE );
}
return( TRUE );
}
BOOLEAN DequeueAllDemandGameEvents( BOOLEAN fExecute )
{
EVENT *pEvent;
EVENT pEvent;
// Dequeue all events on the demand queue (only)
while( EventQueueSize( DEMAND_EVENT_QUEUE ) > 0 )
{
// Get Event
if ( RemoveEvent( &pEvent, 0, DEMAND_EVENT_QUEUE) == FALSE )
if ( PopEvent( &pEvent, DEMAND_EVENT_QUEUE) == FALSE )
{
return( FALSE );
}
@@ -893,18 +1035,18 @@ BOOLEAN DequeueAllDemandGameEvents( BOOLEAN fExecute )
if ( fExecute )
{
// Check if event has a delay and add to secondary queue if so
if ( pEvent->usDelay > 0 )
if ( pEvent.usDelay > 0 )
{
AddGameEventToQueue( pEvent->uiEvent, pEvent->usDelay, pEvent->pData, SECONDARY_EVENT_QUEUE );
AddGameEventToQueue( pEvent.uiEvent, pEvent.usDelay, pEvent.pData, SECONDARY_EVENT_QUEUE );
}
else
{
ExecuteGameEvent( pEvent );
ExecuteGameEvent( &pEvent );
}
}
// Delete event
FreeEvent( pEvent );
FreeEventData( &pEvent );
};
@@ -912,7 +1054,6 @@ BOOLEAN DequeueAllDemandGameEvents( BOOLEAN fExecute )
}
BOOLEAN ExecuteGameEvent( EVENT *pEvent )
{
SOLDIERTYPE *pSoldier;
@@ -1237,17 +1378,16 @@ BOOLEAN ExecuteGameEvent( EVENT *pEvent )
BOOLEAN ClearEventQueue( void )
{
// clear out the event queue
EVENT *pEvent;
EVENT pEvent;
while( EventQueueSize( PRIMARY_EVENT_QUEUE ) > 0 )
{
// Get Event
if ( RemoveEvent( &pEvent, 0, PRIMARY_EVENT_QUEUE) == FALSE )
if (PopEvent( &pEvent, PRIMARY_EVENT_QUEUE) == FALSE )
{
return( FALSE );
}
FreeEventData(&pEvent);
}
return( TRUE );
}
+2 -5
View File
@@ -1,7 +1,6 @@
#ifndef EVENT_PROCESSOR_H
#define EVENT_PROCESSOR_H
#include "Event Manager.h"
#include "Overhead Types.h"
@@ -271,8 +270,6 @@ BOOLEAN AddGameEventFromNetwork( UINT32 uiEvent, UINT16 usDelay, PTR pEventData
BOOLEAN DequeAllGameEvents( BOOLEAN fExecute );
BOOLEAN DequeueAllDemandGameEvents( BOOLEAN fExecute );
// clean out the evetn queue
// clean out the event queue
BOOLEAN ClearEventQueue( void );
#endif
#endif
+1 -110
View File
@@ -12,9 +12,7 @@
#include <vfs/Core/vfs.h>
#ifdef USE_VFS
std::set<vfs::Path,vfs::Path::Less> CIniReader::m_merge_files;
#endif
std::stack<std::string> iniErrorMessages;
template<typename ValueType>
@@ -32,26 +30,14 @@ void PushErrorMessage(std::string const& filename,
iniErrorMessages.push(errMessage.str());
}
#ifdef USE_VFS
void CIniReader::RegisterFileForMerging(vfs::Path const& filename)
{
m_merge_files.insert(filename);
}
#endif
CIniReader::CIniReader(const STR8 szFileName)
{
memset(m_szFileName,0,sizeof(m_szFileName));
#ifndef USE_VFS
// Snap: Look for the INI file in the custom Data directory.
// If not there, leave at default location.
if ( gCustomDataCat.FindFile(szFileName) ) {
sprintf(m_szFileName, "%s\\%s", gCustomDataCat.GetRootDir().c_str(), szFileName);
}
else {
sprintf(m_szFileName, "%s\\%s", gDefaultDataCat.GetRootDir().c_str(), szFileName);
}
#else
strncpy(m_szFileName,szFileName, std::min<int>(strlen(szFileName), sizeof(m_szFileName)-1));
if(m_merge_files.find(szFileName) == m_merge_files.end())
{
@@ -81,7 +67,6 @@ CIniReader::CIniReader(const STR8 szFileName)
if(getVFS()->fileExists(OvrFileName))
m_oProps.initFromIniFile(vfs::Path(OvrFileName));
}
#endif
}
CIniReader::CIniReader(const STR8 szFileName, BOOLEAN Force_Custom_Data_Path)
@@ -89,32 +74,6 @@ CIniReader::CIniReader(const STR8 szFileName, BOOLEAN Force_Custom_Data_Path)
memset(m_szFileName,0,sizeof(m_szFileName));
// ary-05/05/2009 : force custom data path for potential non existing file -or- force default data path
// : Also, flag file detection to allow functions to determine course of action for case of file [not found/is found].
#ifndef USE_VFS
if ( Force_Custom_Data_Path )
{
if ( gCustomDataCat.FindFile(szFileName) )
{
CIniReader_File_Found = TRUE;
}
else
{
CIniReader_File_Found = FALSE;
}
sprintf(m_szFileName, "%s\\%s", gCustomDataCat.GetRootDir().c_str(), szFileName);
}
else
{
if ( gDefaultDataCat.FindFile(szFileName) )
{
CIniReader_File_Found = TRUE;
}
else
{
CIniReader_File_Found = FALSE;
}
sprintf(m_szFileName, "%s\\%s", gDefaultDataCat.GetRootDir().c_str(), szFileName);
}
#else
strncpy(m_szFileName,szFileName, std::min<int>(strlen(szFileName), sizeof(m_szFileName)-1));
if(m_merge_files.find(szFileName) == m_merge_files.end())
{
@@ -137,38 +96,24 @@ CIniReader::CIniReader(const STR8 szFileName, BOOLEAN Force_Custom_Data_Path)
rev_order.pop();
}
}
#endif
}
void CIniReader::Clear()
{
#ifndef USE_VFS
memset(m_szFileName, 0, MAX_PATH);
#else
memset(m_szFileName, 0, MAX_PATH);
m_oProps.clearContainer();
#endif
}
int CIniReader::ReadInteger(const STR8 szSection, const STR8 szKey, int iDefaultValue)
{
#ifndef USE_VFS
return GetPrivateProfileInt(szSection, szKey, iDefaultValue, m_szFileName);
#else
return (int)(m_oProps.getIntProperty(szSection, szKey, iDefaultValue));
#endif
}
int CIniReader::ReadInteger(const STR8 szSection, const STR8 szKey, int defaultValue, int minValue, int maxValue)
{
#ifndef USE_VFS
int iniValueReadFromFile = (int)(GetPrivateProfileInt(szSection, szKey, defaultValue, m_szFileName));
#else
int iniValueReadFromFile = (int)(m_oProps.getIntProperty(szSection, szKey, defaultValue));
#endif
//AssertGE(iniValueReadFromFile, minValue);
//AssertLE(iniValueReadFromFile, maxValue);
if (iniValueReadFromFile < minValue)
@@ -200,15 +145,7 @@ int CIniReader::ReadInteger(const STR8 szSection, const STR8 szKey, int defaultV
double CIniReader::ReadDouble(const STR8 szSection, const STR8 szKey, double defaultValue, double minValue, double maxValue)
{
double iniValueReadFromFile;
#ifndef USE_VFS
char szResult[255];
char szDefault[255];
sprintf(szDefault, "%f", defaultValue);
GetPrivateProfileString(szSection, szKey, szDefault, szResult, 255, m_szFileName);
iniValueReadFromFile = (float) atof(szResult);
#else
iniValueReadFromFile = m_oProps.getFloatProperty(szSection, szKey, defaultValue);
#endif
//AssertGE(iniValueReadFromFile, minValue);
//AssertLE(iniValueReadFromFile, maxValue);
if (iniValueReadFromFile < minValue)
@@ -227,15 +164,7 @@ double CIniReader::ReadDouble(const STR8 szSection, const STR8 szKey, double def
FLOAT CIniReader::ReadFloat(const STR8 szSection, const STR8 szKey, FLOAT defaultValue, FLOAT minValue, FLOAT maxValue)
{
FLOAT iniValueReadFromFile;
#ifndef USE_VFS
char szResult[255];
char szDefault[255];
sprintf(szDefault, "%f", defaultValue);
GetPrivateProfileString(szSection, szKey, szDefault, szResult, 255, m_szFileName);
iniValueReadFromFile = (FLOAT) atof(szResult);
#else
iniValueReadFromFile = (FLOAT) m_oProps.getFloatProperty(szSection, szKey, (float)defaultValue);
#endif
//AssertGE(iniValueReadFromFile, minValue);
//AssertLE(iniValueReadFromFile, maxValue);
@@ -329,18 +258,6 @@ void CIniReader::ReadINT32Array(const STR8 szSection, const STR8 szKey, std::vec
BOOLEAN CIniReader::ReadBoolean(const STR8 szSection, const STR8 szKey, bool defaultValue, bool bolDisplayError)
{
#ifndef USE_VFS
char szResult[255];
char szDefault[255];
sprintf(szDefault, "%s", defaultValue? "TRUE" : "FALSE");
GetPrivateProfileString(szSection, szKey, szDefault, szResult, 255, m_szFileName);
for (int idx=0; (szResult[idx] != 0) && (idx < 255); ++idx)
szResult[idx] = toupper(szResult[idx]);
if (strcmp(szResult, "TRUE") == 0)
return TRUE;
else if (strcmp(szResult, "FALSE") == 0)
return FALSE;
#else
vfs::String str = m_oProps.getStringProperty(szSection, szKey, L"");
if( vfs::StrCmp::Equal(str, L"true") )
{
@@ -353,7 +270,7 @@ BOOLEAN CIniReader::ReadBoolean(const STR8 szSection, const STR8 szKey, bool def
std::string szResult = str.utf8();
char szDefault[255];
sprintf(szDefault, "%s", defaultValue? "TRUE" : "FALSE");
#endif
if(bolDisplayError){
std::stringstream errMessage;
errMessage << "The value [" << szSection << "][" << szKey << "] = \"" << szResult << "\" "
@@ -370,14 +287,10 @@ BOOLEAN CIniReader::ReadBoolean(const STR8 szSection, const STR8 szKey, bool def
void CIniReader::ReadString(const STR8 szSection, const STR8 szKey, const STR8 szDefaultValue, STR8 input_buffer, size_t buffer_size)
{
#ifndef USE_VFS
GetPrivateProfileString(szSection, szKey, szDefaultValue, input_buffer, buffer_size, m_szFileName);
#else
std::string s = m_oProps.getStringProperty(szSection, szKey, szDefaultValue).utf8();
int len = std::min<unsigned int>(s.length(),buffer_size-1);
strncpy(input_buffer, s.c_str(), len);
input_buffer[len] = 0;
#endif
}
// WANNE - MP: Old version, currently used by Multiplayer
@@ -386,12 +299,8 @@ STR8 CIniReader::ReadString(const STR8 szSection, const STR8 szKey, const STR8 s
// >>>>> Memory Leak <<<<<
STR8 szResult = new char[255];
memset(szResult, 0x00, 255);
#ifndef USE_VFS
GetPrivateProfileString(szSection, szKey, szDefaultValue, szResult, 255, m_szFileName);
#else
std::string s = m_oProps.getStringProperty(szSection, szKey, szDefaultValue).utf8();
strncpy(szResult, s.c_str(), std::min<int>(s.length(),254));
#endif
return szResult;
}
@@ -429,20 +338,7 @@ UINT32 CIniReader::ReadUINT32(const STR8 szSection, const STR8 szKey, UINT32 def
UINT32 CIniReader::ReadUINT(const STR8 szSection, const STR8 szKey, UINT32 defaultValue, UINT32 minValue, UINT32 maxValue )
{
UINT32 iniValueReadFromFile;
#ifndef USE_VFS
STR8 szResult = new char[255];
STR8 szDefault = new char[255];
memset(szResult, 0x00, 255);
memset(szDefault, 0x00, 255);
sprintf(szDefault, "%u", defaultValue);
this->ReadString (szSection , szKey , szDefault, szResult, (size_t) 255 );
iniValueReadFromFile = (UINT32) strtoul(szResult,NULL,0);
#else
iniValueReadFromFile = (UINT32) m_oProps.getUIntProperty(szSection, szKey, defaultValue);
#endif
//AssertGE(iniValueReadFromFile, minValue);
//AssertLE(iniValueReadFromFile, maxValue);
@@ -457,10 +353,5 @@ UINT32 CIniReader::ReadUINT(const STR8 szSection, const STR8 szKey, UINT32 defau
iniValueReadFromFile = maxValue;
}
#ifndef USE_VFS
delete [] szResult ;
delete [] szDefault ;
#endif
return iniValueReadFromFile;
}
+1 -5
View File
@@ -56,18 +56,14 @@ public:
BOOLEAN Is_CIniReader_File_Found(void) {return (CIniReader_File_Found);}
void Clear();
#ifdef USE_VFS
static void RegisterFileForMerging(vfs::Path const& filename);
#endif
private:
vfs::PropertyContainer m_oProps;
char m_szFileName[MAX_PATH];
BOOLEAN CIniReader_File_Found;
UINT32 ReadUINT(const STR8 szSection, const STR8 szKey, UINT32 defaultValue, UINT32 minValue, UINT32 maxValue);
#ifdef USE_VFS
static std::set<vfs::Path, vfs::Path::Less> m_merge_files;
#endif
};
#endif//INIREADER_H
#endif//INIREADER_H
-14
View File
@@ -1522,22 +1522,8 @@ static struct DebugMessageLog {
void WriteMessageToFile( const STR16 pString )
{
#ifdef JA2BETAVERSION
#ifndef USE_VFS
FILE *fp;
fp = fopen( "DebugMessage.txt", "a" );
if( fp == NULL )
{
return;
}
fprintf( fp, "%S\n", pString );
fclose( fp );
#else
SGP_LOG(s_DebugMessageLog.id, pString);
#endif
#endif
}
-2
View File
@@ -1,5 +1,3 @@
cmake_minimum_required(VERSION 2.6)
project(bfVFS)
set(BFVFS_VERSION_MAJOR 1)
-19
View File
@@ -396,44 +396,25 @@ UINT32 InitScreenHandle(void)
// Handle queued .ini file error messages
int y = 40;
#ifdef USE_VFS
sgp::Logger_ID ini_id = sgp::Logger::instance().createLogger();
sgp::Logger::instance().connectFile(ini_id, L"iniErrorReport.txt", false, sgp::Logger::FLUSH_ON_DELETE);
sgp::Logger::LogInstance logger = sgp::Logger::instance().logger(ini_id);
#endif
while (! iniErrorMessages.empty()) {
#ifndef USE_VFS
FILE *file_pointer;
#endif
static BOOL iniErrorMessage_create_out_file = TRUE;
std::string iniErrorMessage = iniErrorMessages.top();
CHAR16 str[256];
if (iniErrorMessage_create_out_file)
{
#ifndef USE_VFS
fopen_s( &file_pointer, "..\\iniErrorReport.txt", "w" );
#endif
y += 25;
swprintf( str, L"%S", "Warning: found the following ini errors. iniErrorReport.txt has been created." );
DisplayWrappedString( 10, y, 560, 2, FONT12ARIAL, FONT_ORANGE, str, FONT_BLACK, TRUE, LEFT_JUSTIFIED );
iniErrorMessage_create_out_file = FALSE;
}
else
{
#ifndef USE_VFS
fopen_s( &file_pointer, "..\\iniErrorReport.txt", "a+" );
#endif
}
y += 25;
swprintf( str, L"%S", iniErrorMessage.c_str() );
#ifndef USE_VFS
fprintf_s (file_pointer , "%S\n" , str );
fclose( file_pointer );
#else
logger << iniErrorMessage << sgp::endl;
#endif
DisplayWrappedString( 10, y, 560, 2, FONT12ARIAL, FONT_ORANGE, str, FONT_BLACK, TRUE, LEFT_JUSTIFIED );
iniErrorMessages.pop();