Skip to content

Commit

Permalink
Commiting alpha version of D2BS for 1.13d
Browse files Browse the repository at this point in the history
  • Loading branch information
McGod authored and McGod committed Oct 28, 2011
0 parents commit da6e727
Show file tree
Hide file tree
Showing 162 changed files with 182,162 additions and 0 deletions.
66 changes: 66 additions & 0 deletions AreaLinker.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include <windows.h>

//#include "Constants.h"
#include "D2Structs.h"
#include "D2Helpers.h"
//#include "D2Ptrs.h"
//#include "Core.h"
#include "AreaLinker.h"

AreaNode* GetAreaNode(int nAreaId)
{
for(int i = 0; i < ArraySize(AreaNodes); i++)
for(int x = 0; x < AreaNodes[i].nCount; x++)
if(AreaNodes[i].nAreas[x] == nAreaId)
return &AreaNodes[i];

return NULL;
}

int GetAreas(DWORD nArray[], int nSize, int nStartAreaId, WORD wX, WORD wY)
{
int nDest = -1;
int nCount = 0;

AreaNode* pNode = GetAreaNode(nStartAreaId);

if(pNode)
{
for(int i = 0; i < pNode->nCount; i++)
{
Level* pLevel = GetLevel(pNode->nAreas[i]);

if(pLevel && pLevel->dwPosX * 5 <= wX && pLevel->dwPosY * 5 <= wY && pLevel->dwPosX * 5 + pLevel->dwSizeX * 5 >= wX && pLevel->dwPosY * 5 + pLevel->dwSizeY * 5 >= wY)
{
nDest = pLevel->dwLevelNo;
break;
}
}

nArray[nCount++] = nStartAreaId;

if(nDest == -1 || nDest == nStartAreaId)
return nCount;

if(nStartAreaId > nDest)
{
for(int i = nStartAreaId - 1; i >= nDest; i--)
nArray[nCount++] = i;

if(nCount >= nSize)
return 0;
}
else if (nStartAreaId < nDest)
{
for(int i = nStartAreaId + 1; i <= nDest; i++)
{
nArray[nCount++] = i;

if(nCount >= nSize)
return 0;
}
}
}

return nCount;
}
27 changes: 27 additions & 0 deletions AreaLinker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include "Constants.h"

#define ArraySize(x) (sizeof((x)) / sizeof((x)[0]))

struct AreaNode
{
int nCount;
int nAreas[64];
};

extern int GetAreas(DWORD nArray[], int nSize, int nStartAreaId, WORD wX, WORD wY);

static AreaNode AreaNodes[] = {
// Act 1
{4, {MAP_A1_ROGUE_ENCAMPMENT, MAP_A1_BLOOD_MOOR, MAP_A1_COLD_PLAINS, MAP_A1_STONY_FIELD}},
{6, {MAP_A1_DARK_WOOD, MAP_A1_BLACK_MARSH, MAP_A1_TAMOE_HIGHLAND, MAP_A1_MONASTERY_GATE, MAP_A1_OUTER_CLOISTER, MAP_A1_BARRACKS}},
// Act 2
{6, {MAP_A2_LUT_GHOLEIN, MAP_A2_ROCKY_WASTE, MAP_A2_DRY_HILLS, MAP_A2_FAR_OASIS, MAP_A2_LOST_CITY, MAP_A2_VALLEY_OF_SNAKES}},
// Act 3
{9, {MAP_A3_KURAST_DOCKS, MAP_A3_SPIDER_FOREST, MAP_A3_GREAT_MARSH, MAP_A3_FLAYER_JUNGLE, MAP_A3_LOWER_KURAST, MAP_A3_KURAST_BAZAAR, MAP_A3_UPPER_KURAST, MAP_A3_KURAST_CAUSEWAY, MAP_A3_TRAVINCAL}},
// Act 4
{4, {MAP_A4_THE_PANDEMONIUM_FORTRESS, MAP_A4_OUTER_STEPPES, MAP_A4_PLAINS_OF_DESPAIR, MAP_A4_CITY_OF_THE_DAMNED}},
// Act 5
{4, {MAP_A5_HARROGATH, MAP_A5_THE_BLOODY_FOOTHILLS, MAP_A5_FRIGID_HIGHLANDS, MAP_A5_ARREAT_PLATEAU}},
};
Loading

0 comments on commit da6e727

Please sign in to comment.