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:
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user