mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
*** Merged Code from Multiplayer Branch Revision 2960 ***
- Virtual File System (VFS) by birdflu. This is needed for Multiplayer and is also used for Single Player. Very neat system :-) - Multiplayer Version 1.1 + some additional features and bugfixes * INFO: If you compile a new EXE and want to test, be sure to also use the latest SVN GameDir files in your JA2 install directory * git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2961 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -2282,7 +2282,7 @@ void SpreadEffect( INT16 sGridNo, UINT8 ubRadius, UINT16 usItem, UINT8 ubOwner,
|
||||
}
|
||||
if(is_networked)
|
||||
{
|
||||
ScreenMsg( FONT_LTBLUE, MSG_CHAT, L"explosives not coded in MP");
|
||||
ScreenMsg( FONT_LTBLUE, MSG_MPSYSTEM, L"explosives not coded in MP");
|
||||
return;
|
||||
}
|
||||
// Set values for recompile region to optimize area we need to recompile for MPs
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "Smell.h"
|
||||
#endif
|
||||
|
||||
#include "VFS/vfs.h"
|
||||
|
||||
#define NUM_REVEALED_BYTES 3200
|
||||
|
||||
extern BOOLEAN gfLoadingExitGrids;
|
||||
@@ -300,8 +302,12 @@ 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 );
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "Fileman.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include "VFS/vfs.h"
|
||||
|
||||
#define SHADE_TABLE_DIR "ShadeTables"
|
||||
|
||||
@@ -28,8 +28,10 @@ BOOLEAN gfForceBuildShadeTables = FALSE;
|
||||
|
||||
void DetermineRGBDistributionSettings()
|
||||
{
|
||||
#ifndef USE_VFS
|
||||
STRING512 DataDir;
|
||||
STRING512 ExecDir;
|
||||
#endif
|
||||
STRING512 ShadeTableDir;
|
||||
UINT32 uiRBitMask, uiGBitMask, uiBBitMask;
|
||||
UINT32 uiPrevRBitMask, uiPrevGBitMask, uiPrevBBitMask;
|
||||
@@ -39,6 +41,7 @@ void DetermineRGBDistributionSettings()
|
||||
BOOLEAN fCleanShadeTable = FALSE;
|
||||
BOOLEAN fLoadedPrevRGBDist = FALSE;
|
||||
|
||||
#ifndef USE_VFS
|
||||
// Snap: save current directory
|
||||
GetFileManCurrentDirectory( DataDir );
|
||||
|
||||
@@ -48,7 +51,6 @@ void DetermineRGBDistributionSettings()
|
||||
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 ) )
|
||||
{
|
||||
@@ -62,10 +64,22 @@ void DetermineRGBDistributionSettings()
|
||||
}
|
||||
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");
|
||||
CHAR8 sResetShadeTables[50];
|
||||
sprintf( sResetShadeTables, "%s\\%s", SHADE_TABLE_DIR, "ResetShadeTables.txt");
|
||||
|
||||
if( !fSaveRGBDist )
|
||||
{ //Load the previous RGBDist and determine if it is the same one
|
||||
if( !FileExists( "RGBDist.dat" ) || FileExists( "ResetShadeTables.txt" ) )
|
||||
if( !FileExists( sRGBDist ) || FileExists( sResetShadeTables ) )
|
||||
{ //Can't find the RGBDist.dat file. The directory exists, but the file doesn't, which
|
||||
//means the user deleted the file manually. Now, set it up to create a new one.
|
||||
fSaveRGBDist = TRUE;
|
||||
@@ -73,7 +87,7 @@ void DetermineRGBDistributionSettings()
|
||||
}
|
||||
else
|
||||
{
|
||||
hfile = FileOpen( "RGBDist.dat", FILE_ACCESS_READ, FALSE );
|
||||
hfile = FileOpen( sRGBDist, FILE_ACCESS_READ, FALSE );
|
||||
if( !hfile )
|
||||
{
|
||||
AssertMsg( 0, "Couldn't open RGBDist.dat, even though it exists!" );
|
||||
@@ -111,7 +125,7 @@ void DetermineRGBDistributionSettings()
|
||||
{ //The RGB distribution is going to be saved in a tiny file for future reference. As long as the
|
||||
//RGB distribution never changes, the shade table will grow until eventually, all tilesets are loaded,
|
||||
//shadetables generated and saved in this directory.
|
||||
hfile = FileOpen( "RGBDist.dat", FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE );
|
||||
hfile = FileOpen( sRGBDist, FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE );
|
||||
if( !hfile )
|
||||
{
|
||||
AssertMsg( 0, "Couldn't create RGBDist.dat for writing!" );
|
||||
@@ -123,7 +137,10 @@ void DetermineRGBDistributionSettings()
|
||||
}
|
||||
|
||||
// Snap: Restore the data directory once we are finished.
|
||||
SetFileManCurrentDirectory( DataDir );
|
||||
|
||||
// BF : current directory was reset above
|
||||
//SetFileManCurrentDirectory( DataDir );
|
||||
|
||||
//We're done, so restore the executable directory to JA2\Data.
|
||||
//sprintf( DataDir, "%s\\Data", ExecDir );
|
||||
//SetFileManCurrentDirectory( DataDir );
|
||||
@@ -140,7 +157,11 @@ BOOLEAN LoadShadeTable( HVOBJECT pObj, UINT32 uiTileTypeIndex )
|
||||
//We are assuming that the uiTileTypeIndex is referring to the correct file
|
||||
//stored in the TileSurfaceFilenames[]. If it isn't, then that is a huge problem
|
||||
//and should be fixed. Also assumes that the directory is set to Data\ShadeTables.
|
||||
strcpy( ShadeFileName, TileSurfaceFilenames[ uiTileTypeIndex ] );
|
||||
|
||||
//BF
|
||||
//strcpy( ShadeFileName, TileSurfaceFilenames[ uiTileTypeIndex ] );
|
||||
sprintf( ShadeFileName, "%s\\%s", SHADE_TABLE_DIR, TileSurfaceFilenames[ uiTileTypeIndex ] );
|
||||
|
||||
ptr = strstr( ShadeFileName, "." );
|
||||
if( !ptr )
|
||||
{
|
||||
@@ -149,12 +170,15 @@ BOOLEAN LoadShadeTable( HVOBJECT pObj, UINT32 uiTileTypeIndex )
|
||||
ptr++;
|
||||
sprintf( ptr, "sha" );
|
||||
|
||||
hfile = FileOpen( ShadeFileName, FILE_ACCESS_READ, FALSE );
|
||||
if( !hfile )
|
||||
{ //File doesn't exist, so generate it
|
||||
FileClose( hfile );
|
||||
//hfile = FileOpen( ShadeFileName, FILE_ACCESS_READ, FALSE );
|
||||
//if( !hfile )
|
||||
//{ //File doesn't exist, so generate it
|
||||
// FileClose( hfile );
|
||||
if(!FileExists(ShadeFileName))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
hfile = FileOpen( ShadeFileName, FILE_ACCESS_READ, FALSE );
|
||||
|
||||
//MISSING: Compare time stamps.
|
||||
|
||||
@@ -180,14 +204,18 @@ BOOLEAN SaveShadeTable( HVOBJECT pObj, UINT32 uiTileTypeIndex )
|
||||
UINT32 uiNumBytesWritten;
|
||||
CHAR8 ShadeFileName[ 100 ];
|
||||
CHAR8 *ptr;
|
||||
#ifdef JA2TESTVERSION
|
||||
uiNumTablesSaved++;
|
||||
#endif
|
||||
#ifdef JA2TESTVERSION
|
||||
uiNumTablesSaved++;
|
||||
#endif
|
||||
//ASSUMPTIONS:
|
||||
//We are assuming that the uiTileTypeIndex is referring to the correct file
|
||||
//stored in the TileSurfaceFilenames[]. If it isn't, then that is a huge problem
|
||||
//and should be fixed. Also assumes that the directory is set to Data\ShadeTables.
|
||||
strcpy( ShadeFileName, TileSurfaceFilenames[ uiTileTypeIndex ] );
|
||||
|
||||
// BF
|
||||
//strcpy( ShadeFileName, TileSurfaceFilenames[ uiTileTypeIndex ] );
|
||||
sprintf_s( ShadeFileName, "%s\\%s", SHADE_TABLE_DIR, TileSurfaceFilenames[ uiTileTypeIndex ] );
|
||||
|
||||
ptr = strstr( ShadeFileName, "." );
|
||||
if( !ptr )
|
||||
{
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#endif
|
||||
#include "connect.h"
|
||||
#include "saveloadscreen.h"
|
||||
#include "Map Edgepoints.h"
|
||||
|
||||
|
||||
typedef struct MERCPLACEMENT
|
||||
@@ -120,7 +121,8 @@ void PickUpMercPiece( INT32 iPlacement );
|
||||
void SetCursorMerc( INT8 bPlacementID );
|
||||
void SelectNextUnplacedUnit();
|
||||
|
||||
#ifdef JA2BETAVERSION
|
||||
// WANNE: Made methods available for Release build, because we need them in multiplayer
|
||||
//#ifdef JA2BETAVERSION
|
||||
|
||||
BOOLEAN gfNorthValid, gfEastValid, gfSouthValid, gfWestValid;
|
||||
BOOLEAN gfChangedEntrySide = FALSE;
|
||||
@@ -219,7 +221,7 @@ void CheckForValidMapEdge( UINT8 *pubStrategicInsertionCode )
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
|
||||
void InitTacticalPlacementGUI()
|
||||
@@ -316,6 +318,7 @@ void InitTacticalPlacementGUI()
|
||||
SpecifyButtonHilitedTextColors( iTPButtons[ GROUP_BUTTON ], FONT_WHITE, FONT_NEARBLACK );
|
||||
SpecifyButtonHilitedTextColors( iTPButtons[ DONE_BUTTON ], FONT_WHITE, FONT_NEARBLACK );
|
||||
|
||||
|
||||
//First pass: Count the number of mercs that are going to be placed by the player.
|
||||
// This determines the size of the array we will allocate.
|
||||
giPlacements = 0;
|
||||
@@ -349,6 +352,12 @@ void InitTacticalPlacementGUI()
|
||||
!MercPtrs[ i ]->bSectorZ )
|
||||
{
|
||||
|
||||
// WANNE - MP: Check if the desired insertion direction is valid on the map. If not, choose another entry direction!
|
||||
if (is_networked)
|
||||
{
|
||||
MercPtrs[ i ]->ubStrategicInsertionCode = GetValidInsertionDirectionForMP(MercPtrs[ i ]->ubStrategicInsertionCode);
|
||||
}
|
||||
|
||||
// ATE: If we are in a vehicle - remove ourselves from it!
|
||||
//if ( MercPtrs[ i ]->flags.uiStatusFlags & ( SOLDIER_DRIVER | SOLDIER_PASSENGER ) )
|
||||
//{
|
||||
@@ -363,9 +372,15 @@ void InitTacticalPlacementGUI()
|
||||
gMercPlacement[ giPlacements ].pSoldier = MercPtrs[ i ];
|
||||
gMercPlacement[ giPlacements ].ubStrategicInsertionCode = MercPtrs[ i ]->ubStrategicInsertionCode;
|
||||
gMercPlacement[ giPlacements ].fPlaced = FALSE;
|
||||
|
||||
#ifdef JA2BETAVERSION
|
||||
CheckForValidMapEdge( &MercPtrs[ i ]->ubStrategicInsertionCode );
|
||||
#else
|
||||
// WANNE: We need to have valid map edges in multiplayer!
|
||||
if (is_networked)
|
||||
CheckForValidMapEdge( &MercPtrs[ i ]->ubStrategicInsertionCode );
|
||||
#endif
|
||||
|
||||
switch( MercPtrs[ i ]->ubStrategicInsertionCode )
|
||||
{
|
||||
case INSERTION_CODE_NORTH:
|
||||
@@ -445,6 +460,107 @@ void InitTacticalPlacementGUI()
|
||||
}
|
||||
}
|
||||
|
||||
// WANNE - MP: This method checks, if the desired entry direction (N, E, S, W) on the map is valid. If not it chooses the next valid diretion
|
||||
UINT8 GetValidInsertionDirectionForMP(UINT8 currentInsertionPoint)
|
||||
{
|
||||
bool foundValidDirection = false;
|
||||
UINT8 validInsertionDirection = currentInsertionPoint;
|
||||
|
||||
// Check if current insertion direction is valid
|
||||
switch (currentInsertionPoint)
|
||||
{
|
||||
case INSERTION_CODE_NORTH:
|
||||
if (gus1stNorthEdgepointArraySize > 0 || gus2ndNorthEdgepointArraySize > 0)
|
||||
{
|
||||
foundValidDirection = true;
|
||||
validInsertionDirection = INSERTION_CODE_NORTH;
|
||||
}
|
||||
break;
|
||||
case INSERTION_CODE_SOUTH:
|
||||
if (gus1stSouthEdgepointArraySize > 0 || gus2ndSouthEdgepointArraySize > 0)
|
||||
{
|
||||
foundValidDirection = true;
|
||||
validInsertionDirection = INSERTION_CODE_SOUTH;
|
||||
}
|
||||
break;
|
||||
case INSERTION_CODE_EAST:
|
||||
if (gus1stEastEdgepointArraySize > 0 || gus2ndEastEdgepointArraySize > 0)
|
||||
{
|
||||
foundValidDirection = true;
|
||||
validInsertionDirection = INSERTION_CODE_EAST;
|
||||
}
|
||||
break;
|
||||
case INSERTION_CODE_WEST:
|
||||
if (gus1stWestEdgepointArraySize > 0 || gus2ndWestEdgepointArraySize > 0)
|
||||
{
|
||||
foundValidDirection = true;
|
||||
validInsertionDirection = INSERTION_CODE_WEST;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Find alternate insertion direction by looping through all directions (N, S, E, W)
|
||||
if (!foundValidDirection)
|
||||
{
|
||||
UINT8 direction = 0;
|
||||
|
||||
// Find NEXT valid direction
|
||||
for (int i = currentInsertionPoint; (i < currentInsertionPoint + 4); i++)
|
||||
{
|
||||
// First iteration, start with current insertion direction
|
||||
if (i == currentInsertionPoint)
|
||||
direction = i;
|
||||
else
|
||||
{
|
||||
if (i <= 3)
|
||||
direction = i;
|
||||
else
|
||||
{
|
||||
direction = 4 - i;
|
||||
}
|
||||
}
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case INSERTION_CODE_NORTH:
|
||||
if (gus1stNorthEdgepointArraySize > 0 || gus2ndNorthEdgepointArraySize > 0)
|
||||
{
|
||||
foundValidDirection = true;
|
||||
validInsertionDirection = INSERTION_CODE_NORTH;
|
||||
}
|
||||
break;
|
||||
case INSERTION_CODE_SOUTH:
|
||||
if (gus1stSouthEdgepointArraySize > 0 || gus2ndSouthEdgepointArraySize > 0)
|
||||
{
|
||||
foundValidDirection = true;
|
||||
validInsertionDirection = INSERTION_CODE_SOUTH;
|
||||
}
|
||||
break;
|
||||
case INSERTION_CODE_EAST:
|
||||
if (gus1stEastEdgepointArraySize > 0 || gus2ndEastEdgepointArraySize > 0)
|
||||
{
|
||||
foundValidDirection = true;
|
||||
validInsertionDirection = INSERTION_CODE_EAST;
|
||||
}
|
||||
break;
|
||||
case INSERTION_CODE_WEST:
|
||||
if (gus1stWestEdgepointArraySize > 0 || gus2ndWestEdgepointArraySize > 0)
|
||||
{
|
||||
foundValidDirection = true;
|
||||
validInsertionDirection = INSERTION_CODE_WEST;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Exit loop condition
|
||||
if (foundValidDirection)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return validInsertionDirection;
|
||||
}
|
||||
|
||||
void RenderTacticalPlacementGUI()
|
||||
{
|
||||
INT32 i, xp, yp, width, height;
|
||||
@@ -574,17 +690,33 @@ void RenderTacticalPlacementGUI()
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO.RW: Check for insertion
|
||||
if (is_networked)
|
||||
{
|
||||
gMercPlacement[ gbCursorMercID ].ubStrategicInsertionCode = GetValidInsertionDirectionForMP(gMercPlacement[ gbCursorMercID ].ubStrategicInsertionCode);
|
||||
}
|
||||
|
||||
gTPClipRect.iLeft = iOffsetHorizontal;
|
||||
gTPClipRect.iTop = iOffsetVertical + 3;
|
||||
//gTPClipRect.iRight = iOffsetHorizontal + 640;
|
||||
gTPClipRect.iRight = iOffsetHorizontal + 634; // 635
|
||||
gTPClipRect.iBottom = iOffsetVertical + 320;
|
||||
|
||||
|
||||
switch( gMercPlacement[ gbCursorMercID ].ubStrategicInsertionCode )
|
||||
{
|
||||
case INSERTION_CODE_NORTH: gTPClipRect.iTop = iOffsetVertical + 30 + 3; break;
|
||||
case INSERTION_CODE_EAST: gTPClipRect.iRight = iOffsetHorizontal + 610; break;
|
||||
case INSERTION_CODE_SOUTH: gTPClipRect.iBottom = iOffsetVertical + 290; break;
|
||||
case INSERTION_CODE_WEST: gTPClipRect.iLeft = iOffsetHorizontal + 30; break;
|
||||
case INSERTION_CODE_NORTH:
|
||||
gTPClipRect.iTop = iOffsetVertical + 30 + 3;
|
||||
break;
|
||||
case INSERTION_CODE_EAST:
|
||||
gTPClipRect.iRight = iOffsetHorizontal + 610;
|
||||
break;
|
||||
case INSERTION_CODE_SOUTH:
|
||||
gTPClipRect.iBottom = iOffsetVertical + 290;
|
||||
break;
|
||||
case INSERTION_CODE_WEST:
|
||||
gTPClipRect.iLeft = iOffsetHorizontal + 30;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES );
|
||||
|
||||
@@ -11,6 +11,9 @@ void RenderTacticalPlacementGUI();
|
||||
|
||||
void HandleTacticalPlacementClicksInOverheadMap( MOUSE_REGION *reg, INT32 reason );
|
||||
|
||||
// WANNE - MP: This method checks, if the desired entry direction (N, E, S, W) on the map is valid. If not it chooses the next valid diretion
|
||||
UINT8 GetValidInsertionDirectionForMP(UINT8 currentInsertionPoint);
|
||||
|
||||
extern BOOLEAN gfTacticalPlacementGUIActive;
|
||||
extern BOOLEAN gfEnterTacticalPlacementGUI;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Version="8,00"
|
||||
Name="TileEngine_2005Express"
|
||||
ProjectGUID="{FC1938E8-9253-49A8-AA99-4639BBB46C1B}"
|
||||
RootNamespace="TileEngine_2005Express"
|
||||
@@ -41,7 +41,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/D "_CRT_SECURE_NO_DEPRECATE""
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\Multiplayer"
|
||||
AdditionalIncludeDirectories="..\Multiplayer;..\ext\utf8\source;..\VFS"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
@@ -105,7 +105,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/D "_CRT_SECURE_NO_DEPRECATE""
|
||||
AdditionalIncludeDirectories="..\Multiplayer"
|
||||
AdditionalIncludeDirectories="..\Multiplayer;..\ext\utf8\source;..\VFS"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;"
|
||||
RuntimeLibrary="0"
|
||||
RuntimeTypeInfo="false"
|
||||
@@ -166,7 +166,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/D "_CRT_SECURE_NO_DEPRECATE""
|
||||
AdditionalIncludeDirectories="..\Multiplayer"
|
||||
AdditionalIncludeDirectories="..\Multiplayer;..\ext\utf8\source;..\VFS"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;"
|
||||
RuntimeLibrary="0"
|
||||
RuntimeTypeInfo="false"
|
||||
@@ -228,7 +228,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/D "_CRT_SECURE_NO_DEPRECATE""
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\Multiplayer"
|
||||
AdditionalIncludeDirectories="..\Multiplayer;..\ext\utf8\source;..\VFS"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
|
||||
+25
-4
@@ -14,6 +14,9 @@
|
||||
#include "fileMan.h"
|
||||
#endif
|
||||
|
||||
#include "VFS/vfs.h"
|
||||
#include "XMLWriter.h"
|
||||
|
||||
// THIS FILE CONTAINS DEFINITIONS FOR TILESET FILES
|
||||
|
||||
void SetTilesetThreeTerrainValues();
|
||||
@@ -34,6 +37,7 @@ void InitEngineTilesets( )
|
||||
HWFILE hfile;
|
||||
CHAR8 zName[32];
|
||||
UINT32 uiNumBytesRead;
|
||||
XMLWriter xmlw;
|
||||
|
||||
//OPEN FILE
|
||||
// hfile = fopen( "BINARYDATA\\JA2SET.DAT", "rb" );
|
||||
@@ -44,6 +48,7 @@ void InitEngineTilesets( )
|
||||
return;
|
||||
}
|
||||
|
||||
xmlw.OpenNode("JA2SET");
|
||||
|
||||
// READ # TILESETS and compare
|
||||
// fread( &gubNumSets, sizeof( gubNumSets ), 1, hfile );
|
||||
@@ -55,6 +60,7 @@ void InitEngineTilesets( )
|
||||
SET_ERROR( "Too many tilesets in the data file" );
|
||||
return;
|
||||
}
|
||||
xmlw.AddAttributeToNextValue("numTilesets",(int)gubNumSets);
|
||||
|
||||
// READ #files
|
||||
// fread( &uiNumFiles, sizeof( uiNumFiles ), 1, hfile );
|
||||
@@ -67,40 +73,55 @@ void InitEngineTilesets( )
|
||||
SET_ERROR( "Number of tilesets slots in code does not match data file" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
xmlw.AddAttributeToNextValue("numFiles",(int)uiNumFiles);
|
||||
xmlw.OpenNode("tilesets");
|
||||
// Loop through each tileset, load name then files
|
||||
for ( cnt = 0; cnt < gubNumSets; cnt++ )
|
||||
{
|
||||
xmlw.AddAttributeToNextValue("index",(int)cnt);
|
||||
xmlw.OpenNode("Tileset");
|
||||
//Read name
|
||||
// fread( &zName, sizeof( zName ), 1, hfile );
|
||||
FileRead( hfile, &zName, sizeof( zName ), &uiNumBytesRead );
|
||||
xmlw.AddValue("Name",std::string(zName));
|
||||
|
||||
// Read ambience value
|
||||
// fread( &(gTilesets[ cnt ].ubAmbientID), sizeof( UINT8), 1, hfile );
|
||||
FileRead( hfile, &(gTilesets[ cnt ].ubAmbientID), sizeof( UINT8 ), &uiNumBytesRead );
|
||||
xmlw.AddValue("AmbientID",(int)gTilesets[ cnt ].ubAmbientID);
|
||||
|
||||
// Set into tileset
|
||||
swprintf( gTilesets[ cnt ].zName, L"%S", zName );
|
||||
|
||||
xmlw.OpenNode("Files");
|
||||
// Loop for files
|
||||
for ( cnt2 = 0; cnt2 < uiNumFiles; cnt2++ )
|
||||
{
|
||||
// Read file name
|
||||
// fread( &zName, sizeof( zName ), 1, hfile );
|
||||
FileRead( hfile, &zName, sizeof( zName ), &uiNumBytesRead );
|
||||
if(!std::string(zName).empty())
|
||||
{
|
||||
xmlw.AddAttributeToNextValue("index",(int)cnt2);
|
||||
xmlw.AddValue("file",std::string(zName));
|
||||
}
|
||||
|
||||
// Set into database
|
||||
strcpy( gTilesets[ cnt ].TileSurfaceFilenames[ cnt2 ], zName );
|
||||
|
||||
}
|
||||
|
||||
xmlw.CloseNode(); // Files
|
||||
xmlw.CloseNode(); // tileset
|
||||
}
|
||||
xmlw.CloseNode();
|
||||
|
||||
// fclose( hfile );
|
||||
FileClose( hfile );
|
||||
|
||||
|
||||
xmlw.CloseNode();
|
||||
#ifdef USE_VFS
|
||||
xmlw.WriteToFile("Ja2Set.dat.xml");
|
||||
#endif
|
||||
// SET CALLBACK FUNTIONS!!!!!!!!!!!!!
|
||||
gTilesets[ TLS_CAVES_1 ].MovementCostFnc = (TILESET_CALLBACK)SetTilesetTwoTerrainValues;
|
||||
gTilesets[ TLS_AIRSTRIP ].MovementCostFnc = (TILESET_CALLBACK)SetTilesetThreeTerrainValues;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#endif
|
||||
|
||||
#include "Text.h"
|
||||
#include "connect.h"
|
||||
|
||||
//effects whether or not time of day effects the lighting. Underground
|
||||
//maps have an ambient light level that is saved in the map, and doesn't change.
|
||||
@@ -682,13 +683,20 @@ BOOLEAN LightningEndOfTurn( UINT8 ubTeam )
|
||||
|
||||
UINT8 GetTimeOfDayAmbientLightLevel()
|
||||
{
|
||||
if ( SectorTemperature( GetWorldMinutesInDay(), gWorldSectorX, gWorldSectorY, gbWorldSectorZ ) == HOT )
|
||||
if (!is_networked)
|
||||
{
|
||||
return( HOT_DAY_LIGHTLEVEL );
|
||||
if ( SectorTemperature( GetWorldMinutesInDay(), gWorldSectorX, gWorldSectorY, gbWorldSectorZ ) == HOT )
|
||||
{
|
||||
return( HOT_DAY_LIGHTLEVEL );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( gubEnvLightValue );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return( gubEnvLightValue );
|
||||
return ( gubEnvLightValue );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+65
-24
@@ -503,20 +503,20 @@ void HandleOverheadMap( )
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( GetOverheadMouseGridNoForFullSoldiersGridNo( &sMapPos ) )
|
||||
{
|
||||
if ( GetOverheadMouseGridNoForFullSoldiersGridNo( &sMapPos ) )
|
||||
{
|
||||
if ( GetClosestMercInOverheadMap( sMapPos, &pSoldier, 1 ) )
|
||||
{
|
||||
if ( pSoldier->bTeam == gbPlayerNum )
|
||||
{
|
||||
gfUIHandleSelectionAboveGuy = TRUE;
|
||||
gsSelectedGuy = pSoldier->ubID;
|
||||
}
|
||||
if ( pSoldier->bTeam == gbPlayerNum )
|
||||
{
|
||||
gfUIHandleSelectionAboveGuy = TRUE;
|
||||
gsSelectedGuy = pSoldier->ubID;
|
||||
}
|
||||
|
||||
DisplayMercNameInOverhead( pSoldier );
|
||||
}
|
||||
DisplayMercNameInOverhead( pSoldier );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ void HandleOverheadMap( )
|
||||
{
|
||||
pSoldier = MercPtrs[ gusSelectedSoldier ];
|
||||
|
||||
DisplayMercNameInOverhead( pSoldier );
|
||||
DisplayMercNameInOverhead( pSoldier );
|
||||
}
|
||||
|
||||
RenderButtons( );
|
||||
@@ -1272,22 +1272,44 @@ void RenderOverheadOverlays()
|
||||
else
|
||||
#endif
|
||||
if( !gfTacticalPlacementGUIActive )
|
||||
{ //normal
|
||||
{
|
||||
//normal
|
||||
if(is_networked)
|
||||
{
|
||||
if(pSoldier->bTeam!=0)
|
||||
{
|
||||
if(pSoldier->bSide==1)Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, 1 );
|
||||
if(pSoldier->bSide==0)Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, 3 );
|
||||
if(pSoldier->bSide==1)
|
||||
{
|
||||
// Civ (white)
|
||||
if (pSoldier->bTeam == 4)
|
||||
Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, 4 );
|
||||
// Enemy (red)
|
||||
else
|
||||
Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, 1 );
|
||||
}
|
||||
|
||||
// Other clients
|
||||
if(pSoldier->bSide==0)
|
||||
{
|
||||
int personIndex = pSoldier->bTeam + 4;
|
||||
// TODO.RW: Get the correct person index (depending on the pSoldier->bTeam)
|
||||
//Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, 3 );
|
||||
Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, personIndex );
|
||||
}
|
||||
}
|
||||
else Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, pSoldier->bTeam );
|
||||
else
|
||||
// Color depends on the bTeam
|
||||
Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, pSoldier->bTeam );
|
||||
}
|
||||
// Color depends on the bTeam
|
||||
else
|
||||
Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, pSoldier->bTeam );
|
||||
Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, pSoldier->bTeam );
|
||||
|
||||
RegisterBackgroundRect(BGND_FLAG_SINGLE, NULL, sX, sY, (INT16)(sX + 3), (INT16)(sY + 9));
|
||||
}
|
||||
else if( pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE )
|
||||
{ //vehicle
|
||||
{
|
||||
//vehicle
|
||||
Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, 9 );
|
||||
RegisterBackgroundRect(BGND_FLAG_SINGLE, NULL, (INT16)(sX-6), (INT16)(sY), (INT16)(sX + 9), (INT16)(sY + 10));
|
||||
}
|
||||
@@ -1296,30 +1318,49 @@ void RenderOverheadOverlays()
|
||||
// ubPassengers++;
|
||||
//}
|
||||
else if( gpTacticalPlacementSelectedSoldier == pSoldier )
|
||||
{ //tactical placement selected merc
|
||||
{
|
||||
//tactical placement selected merc
|
||||
Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, 7 );
|
||||
RegisterBackgroundRect(BGND_FLAG_SINGLE, NULL, (INT16)(sX-2), (INT16)(sY-2), (INT16)(sX + 5), (INT16)(sY + 11));
|
||||
}
|
||||
else if( gpTacticalPlacementHilightedSoldier == pSoldier && pSoldier->flags.uiStatusFlags )
|
||||
{ //tactical placement hilighted merc
|
||||
{
|
||||
//tactical placement hilighted merc
|
||||
Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, 8 );
|
||||
RegisterBackgroundRect(BGND_FLAG_SINGLE, NULL, (INT16)(sX-2), (INT16)(sY-2), (INT16)(sX + 5), (INT16)(sY + 11));
|
||||
}
|
||||
else
|
||||
{ //normal
|
||||
{
|
||||
//normal
|
||||
if(is_networked)
|
||||
{
|
||||
if(pSoldier->bTeam!=0)
|
||||
{
|
||||
if(pSoldier->bSide==1)continue;//dont render enemy
|
||||
if(pSoldier->bSide==0)Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, 3 );
|
||||
if(pSoldier->bSide==1)
|
||||
continue;//dont render enemy
|
||||
|
||||
// Green
|
||||
// Other clients
|
||||
if(pSoldier->bSide==0)
|
||||
{
|
||||
int personIndex = pSoldier->bTeam + 4;
|
||||
// TODO.RW: Get the correct person index (depending on the pSoldier->bTeam)
|
||||
|
||||
//Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, 3 );
|
||||
Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, personIndex );
|
||||
}
|
||||
}
|
||||
else Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, pSoldier->bTeam );
|
||||
else
|
||||
// Color depends on the bTeam
|
||||
Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, pSoldier->bTeam );
|
||||
}
|
||||
else
|
||||
Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, pSoldier->bTeam );
|
||||
// Color depends on the bTeam
|
||||
Blt8BPPDataTo16BPPBufferTransparent((UINT16*)pDestBuf, uiDestPitchBYTES, hVObject, sX, sY, pSoldier->bTeam );
|
||||
|
||||
RegisterBackgroundRect(BGND_FLAG_SINGLE, NULL, sX, sY, (INT16)(sX + 3), (INT16)(sY + 9));
|
||||
}
|
||||
|
||||
if( ubPassengers )
|
||||
{
|
||||
SetFont( SMALLCOMPFONT );
|
||||
|
||||
+41
-35
@@ -522,8 +522,9 @@ extern BOOLEAN gfLoadShadeTablesFromTextFile;
|
||||
void BuildTileShadeTables( )
|
||||
{
|
||||
HWFILE hfile;
|
||||
STRING512 DataDir;
|
||||
STRING512 ShadeTableDir;
|
||||
// BF
|
||||
//STRING512 DataDir;
|
||||
//STRING512 ShadeTableDir;
|
||||
UINT32 uiLoop;
|
||||
CHAR8 cRootFile[ 128 ];
|
||||
BOOLEAN fForceRebuildForSlot = FALSE;
|
||||
@@ -540,18 +541,22 @@ void BuildTileShadeTables( )
|
||||
uiStartTime = GetJA2Clock();
|
||||
#endif
|
||||
|
||||
|
||||
//Set the directory to the shadetable directory
|
||||
GetFileManCurrentDirectory( DataDir );
|
||||
sprintf( ShadeTableDir, "%s\\ShadeTables", DataDir );
|
||||
if( !SetFileManCurrentDirectory( ShadeTableDir ) )
|
||||
// BF : adjust filename, instead of changing current directory (doesn't make sence with a VFS)
|
||||
//////////////Set the directory to the shadetable directory
|
||||
////////////GetFileManCurrentDirectory( DataDir );
|
||||
////////////sprintf( ShadeTableDir, "%s\\ShadeTables", DataDir );
|
||||
////////////if( !SetFileManCurrentDirectory( ShadeTableDir ) )
|
||||
////////////{
|
||||
//////////// AssertMsg( 0, "Can't set the directory to Data\\ShadeTable. Kris' big problem!" );
|
||||
////////////}
|
||||
CHAR8 sIgnoreShadeTables[50];
|
||||
sprintf( sIgnoreShadeTables, "%s\\%s", "ShadeTables", "IgnoreShadeTables.txt");
|
||||
//hfile = FileOpen( sIgnoreShadeTables, FILE_ACCESS_READ, FALSE );
|
||||
//if( hfile )
|
||||
//{
|
||||
// FileClose( hfile );
|
||||
if(FileExists(sIgnoreShadeTables))
|
||||
{
|
||||
AssertMsg( 0, "Can't set the directory to Data\\ShadeTable. Kris' big problem!" );
|
||||
}
|
||||
hfile = FileOpen( "IgnoreShadeTables.txt", FILE_ACCESS_READ, FALSE );
|
||||
if( hfile )
|
||||
{
|
||||
FileClose( hfile );
|
||||
gfForceBuildShadeTables = TRUE;
|
||||
}
|
||||
else
|
||||
@@ -585,40 +590,41 @@ void BuildTileShadeTables( )
|
||||
if ( gTileSurfaceArray[ uiLoop ] != NULL )
|
||||
{
|
||||
// Don't Create shade tables if default were already used once!
|
||||
#ifdef JA2EDITOR
|
||||
if( gbNewTileSurfaceLoaded[ uiLoop ] || gfEditorForceShadeTableRebuild )
|
||||
#else
|
||||
if( gbNewTileSurfaceLoaded[ uiLoop ] )
|
||||
#endif
|
||||
{
|
||||
fForceRebuildForSlot = FALSE;
|
||||
#ifdef JA2EDITOR
|
||||
if( gbNewTileSurfaceLoaded[ uiLoop ] || gfEditorForceShadeTableRebuild )
|
||||
#else
|
||||
if( gbNewTileSurfaceLoaded[ uiLoop ] )
|
||||
#endif
|
||||
{
|
||||
fForceRebuildForSlot = FALSE;
|
||||
|
||||
GetRootName( cRootFile, TileSurfaceFilenames[ uiLoop ] );
|
||||
|
||||
if ( strcmp( cRootFile, "grass2" ) == 0 )
|
||||
{
|
||||
fForceRebuildForSlot = TRUE;
|
||||
}
|
||||
if ( strcmp( cRootFile, "grass2" ) == 0 )
|
||||
{
|
||||
fForceRebuildForSlot = TRUE;
|
||||
}
|
||||
|
||||
#ifdef JA2TESTVERSION
|
||||
uiNumImagesReloaded++;
|
||||
#endif
|
||||
RenderProgressBar( 0, uiLoop * 100 / NUMBEROFTILETYPES );
|
||||
CreateTilePaletteTables( gTileSurfaceArray[ uiLoop ]->vo, uiLoop, fForceRebuildForSlot );
|
||||
}
|
||||
#ifdef JA2TESTVERSION
|
||||
uiNumImagesReloaded++;
|
||||
#endif
|
||||
RenderProgressBar( 0, uiLoop * 100 / NUMBEROFTILETYPES );
|
||||
CreateTilePaletteTables( gTileSurfaceArray[ uiLoop ]->vo, uiLoop, fForceRebuildForSlot );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Restore the data directory once we are finished.
|
||||
SetFileManCurrentDirectory( DataDir );
|
||||
// BF : see above
|
||||
////Restore the data directory once we are finished.
|
||||
//SetFileManCurrentDirectory( DataDir );
|
||||
|
||||
ubLastRed = gpLightColors[0].peRed;
|
||||
ubLastGreen = gpLightColors[0].peGreen;
|
||||
ubLastBlue = gpLightColors[0].peBlue;
|
||||
|
||||
#ifdef JA2TESTVERSION
|
||||
uiBuildShadeTableTime = GetJA2Clock() - uiStartTime;
|
||||
#endif
|
||||
#ifdef JA2TESTVERSION
|
||||
uiBuildShadeTableTime = GetJA2Clock() - uiStartTime;
|
||||
#endif
|
||||
}
|
||||
|
||||
void DestroyTileShadeTables( )
|
||||
|
||||
Reference in New Issue
Block a user