mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
- New Feature/exploit enhancement: enter hostile sector with helicopter and land mercs anywhere (see http://www.bears-pit.com/board/ubbthreads.php/topics/327879.html#Post327879)
- MP entry points are now much more and scale with mapsize git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6576 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -74,49 +74,109 @@ BOOLEAN EdgepointsClose( SOLDIERTYPE *pSoldier, INT32 sEdgepoint1, INT32 sEdgepo
|
||||
|
||||
extern UINT8 gubTacticalDirection;
|
||||
|
||||
|
||||
BOOLEAN GridNoValidForCenterEntryPoint(INT32 sGridNo)
|
||||
{
|
||||
if ( GridNoOnVisibleWorldTile( sGridNo ) && gpWorldLevelData[gMapInformation.sCenterGridNo].sHeight == gpWorldLevelData[sGridNo].sHeight && !FindStructure( sGridNo, (STRUCTURE_SLANTED_ROOF|STRUCTURE_TALL_ROOF) ) )
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define CENTER_ENTRY_POINTS_ROW 100
|
||||
#define NUM_CENTER_ENTRY_POINTS (CENTER_ENTRY_POINTS_ROW * CENTER_ENTRY_POINTS_ROW)
|
||||
|
||||
static INT32* statCentGrid = NULL;
|
||||
static INT32 numcentergridnos = 0;
|
||||
void FillCentreGridnos(BOOLEAN fCenterOnly)
|
||||
{
|
||||
static INT16 sectorX = -1;
|
||||
static INT16 sectorY = -1;
|
||||
|
||||
// generate points only if current points are for a different map
|
||||
if ( gWorldSectorX == sectorX && gWorldSectorY == sectorY )
|
||||
return;
|
||||
|
||||
sectorX = gWorldSectorX;
|
||||
sectorY = gWorldSectorY;
|
||||
|
||||
statCentGrid = (INT32*)MemAlloc( NUM_CENTER_ENTRY_POINTS * sizeof( INT32 ) );
|
||||
|
||||
FLOAT lenx = 0.0f;
|
||||
if ( fCenterOnly )
|
||||
lenx = std::sqrt((float)(CENTERENTRYPTS_TOP_Y*CENTERENTRYPTS_TOP_Y + CENTERENTRYPTS_LEFT_X*CENTERENTRYPTS_LEFT_X));
|
||||
|
||||
FLOAT lent = std::sqrt((float)((320-3)*(320-3) + 634*634));
|
||||
FLOAT xratio = lenx/lent;
|
||||
|
||||
// top row of gridnos isn't accessible, we thus have to shorten the accessible lenghts
|
||||
INT32 world_cols_adjusted = WORLD_COLS - 3;
|
||||
INT32 world_rows_adjusted = WORLD_ROWS - 3;
|
||||
|
||||
INT32 x_base = world_cols_adjusted * xratio;
|
||||
INT32 y_base = world_rows_adjusted/2;
|
||||
|
||||
INT32 totallen = std::sqrt((float)(world_rows_adjusted * world_rows_adjusted + world_cols_adjusted * world_cols_adjusted));
|
||||
INT32 droplen = totallen * (1.0f - 2 * xratio);
|
||||
INT32 steplen = droplen / CENTER_ENTRY_POINTS_ROW;
|
||||
|
||||
UINT16 cnt = 0;
|
||||
for(UINT16 i = 0; i < CENTER_ENTRY_POINTS_ROW; ++i)
|
||||
{
|
||||
INT32 x_start = x_base + i * steplen;
|
||||
INT32 y_start = y_base + i * steplen;
|
||||
|
||||
for(UINT16 j = 0; j < CENTER_ENTRY_POINTS_ROW; ++j)
|
||||
{
|
||||
INT32 x = x_start + j * steplen;
|
||||
INT32 y = y_start - j * steplen;
|
||||
|
||||
INT32 gridno = y * WORLD_COLS + x;
|
||||
|
||||
// use gridno only if valid and if it does not have an inaccessible roof
|
||||
if ( GridNoValidForCenterEntryPoint( gridno ) )
|
||||
{
|
||||
statCentGrid[ cnt ] = gridno;
|
||||
++cnt;
|
||||
}
|
||||
else
|
||||
{
|
||||
// test wether neighbour gridnos are ok
|
||||
for(UINT8 dir = NORTH; dir < NUM_WORLD_DIRECTIONS; ++dir)
|
||||
{
|
||||
INT32 newgridno = NewGridNo(gridno, dir);
|
||||
if ( GridNoValidForCenterEntryPoint( newgridno ) )
|
||||
{
|
||||
statCentGrid[ cnt ] = newgridno;
|
||||
++cnt;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
numcentergridnos = cnt;
|
||||
}
|
||||
|
||||
// WANNE - MP: Center
|
||||
void InitCenterEdgepoint()
|
||||
void InitCenterEdgepoint(BOOLEAN fCenterOnly)
|
||||
{
|
||||
if (gps1stCenterEdgepointArray )
|
||||
MemFree( gps1stCenterEdgepointArray );
|
||||
|
||||
gps1stCenterEdgepointArray = NULL;
|
||||
|
||||
FillCentreGridnos(fCenterOnly);
|
||||
|
||||
// Set some center points
|
||||
gus1stCenterEdgepointArraySize = 30;
|
||||
gus1stCenterEdgepointArraySize = numcentergridnos;
|
||||
|
||||
gps1stCenterEdgepointArray = (INT32*)MemAlloc( gus1stCenterEdgepointArraySize * sizeof( INT32 ) );
|
||||
|
||||
gps1stCenterEdgepointArray[ 0 ] = 13024;
|
||||
gps1stCenterEdgepointArray[ 1 ] = 13507;
|
||||
gps1stCenterEdgepointArray[ 2 ] = 13990;
|
||||
gps1stCenterEdgepointArray[ 3 ] = 14473;
|
||||
gps1stCenterEdgepointArray[ 4 ] = 15117;
|
||||
gps1stCenterEdgepointArray[ 5 ] = 12547;
|
||||
gps1stCenterEdgepointArray[ 6 ] = 13030;
|
||||
gps1stCenterEdgepointArray[ 7 ] = 13513;
|
||||
gps1stCenterEdgepointArray[ 8 ] = 13996;
|
||||
gps1stCenterEdgepointArray[ 9 ] = 14479;
|
||||
gps1stCenterEdgepointArray[ 10 ] = 12070;
|
||||
gps1stCenterEdgepointArray[ 11 ] = 12553;
|
||||
gps1stCenterEdgepointArray[ 12 ] = 13036;
|
||||
gps1stCenterEdgepointArray[ 13 ] = 13519;
|
||||
gps1stCenterEdgepointArray[ 14 ] = 14002;
|
||||
gps1stCenterEdgepointArray[ 15 ] = 11593;
|
||||
gps1stCenterEdgepointArray[ 16 ] = 12076;
|
||||
gps1stCenterEdgepointArray[ 17 ] = 12559;
|
||||
gps1stCenterEdgepointArray[ 18 ] = 13042;
|
||||
gps1stCenterEdgepointArray[ 19 ] = 13525;
|
||||
gps1stCenterEdgepointArray[ 20 ] = 11117;
|
||||
gps1stCenterEdgepointArray[ 21 ] = 11600;
|
||||
gps1stCenterEdgepointArray[ 22 ] = 12083;
|
||||
gps1stCenterEdgepointArray[ 23 ] = 12566;
|
||||
gps1stCenterEdgepointArray[ 24 ] = 13049;
|
||||
gps1stCenterEdgepointArray[ 25 ] = 10640;
|
||||
gps1stCenterEdgepointArray[ 26 ] = 11123;
|
||||
gps1stCenterEdgepointArray[ 27 ] = 11606;
|
||||
gps1stCenterEdgepointArray[ 28 ] = 12089;
|
||||
gps1stCenterEdgepointArray[ 29 ] = 12572;
|
||||
for(UINT16 i = 0; i < numcentergridnos; ++i)
|
||||
gps1stCenterEdgepointArray[i] = statCentGrid[i];
|
||||
}
|
||||
|
||||
void TrashMapEdgepoints()
|
||||
@@ -149,8 +209,7 @@ void TrashMapEdgepoints()
|
||||
gus1stEastEdgepointMiddleIndex = 0;
|
||||
gus1stSouthEdgepointMiddleIndex = 0;
|
||||
gus1stWestEdgepointMiddleIndex = 0;
|
||||
|
||||
|
||||
|
||||
//Secondary edgepoints
|
||||
if( gps2ndNorthEdgepointArray )
|
||||
MemFree( gps2ndNorthEdgepointArray );
|
||||
@@ -1052,9 +1111,9 @@ INT32 ChooseMapEdgepoint( UINT8 *ubStrategicInsertionCode, UINT8 lastValidICode
|
||||
if( *ubStrategicInsertionCode == INSERTION_CODE_GRIDNO)
|
||||
*ubStrategicInsertionCode = lastValidICode;
|
||||
|
||||
if (is_networked && *ubStrategicInsertionCode == INSERTION_CODE_CENTER)
|
||||
if ( (is_networked && *ubStrategicInsertionCode == INSERTION_CODE_CENTER) || *ubStrategicInsertionCode == INSERTION_CODE_CHOPPER )
|
||||
{
|
||||
InitCenterEdgepoint();
|
||||
InitCenterEdgepoint( *ubStrategicInsertionCode == INSERTION_CODE_CENTER );
|
||||
|
||||
psArray = gps1stCenterEdgepointArray;
|
||||
usArraySize = gus1stCenterEdgepointArraySize;
|
||||
@@ -1339,9 +1398,9 @@ INT32 SearchForClosestPrimaryMapEdgepoint(INT32 sGridNo, UINT8 ubInsertionCode,
|
||||
break;
|
||||
}
|
||||
// WANNE - MP: Center
|
||||
if(is_networked && ubInsertionCode == INSERTION_CODE_CENTER)
|
||||
if( (is_networked && ubInsertionCode == INSERTION_CODE_CENTER) || ubInsertionCode == INSERTION_CODE_CHOPPER )
|
||||
{
|
||||
InitCenterEdgepoint();
|
||||
InitCenterEdgepoint( ubInsertionCode == INSERTION_CODE_CENTER );
|
||||
psArray = gps1stCenterEdgepointArray;
|
||||
usArraySize = gus1stCenterEdgepointArraySize;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user