walls: Add ┴ and ┘ shaped walls.

You can now build walls shaped like
┌─┐ │
│ ├─┘
│ │
instead of
┼─┼ │
│ ┼─┼
│ │
like it used to be.

The blwallh_[tl].pie files will need cleaning up.
master
Cyp 2011-12-01 16:35:30 +01:00
parent ae2896fcb1
commit aa8b290324
10 changed files with 372 additions and 89 deletions

View File

@ -20,7 +20,7 @@ A0CommandCentreNP,HQ,Level One,HARD,0,2,2,Concrete,500,3,10,500,10,100,30,300,1,
A0CyborgFactory,CYBORG FACTORY,Level All,MEDIUM,1,1,2,Concrete,500,2,10,500,100,100,30,150,255,20,ZNULLECM,DefaultSensor1Mk1,1,blcfact1.pie,blbcfact.pie,1,0
A0FacMod1,FACTORY MODULE,Level All,MEDIUM,1,3,3,Concrete,250,2,10,250,100,100,25,150,255,30,ZNULLECM,DefaultSensor1Mk1,0,blfact1.pie,0,1,0
A0HardcreteMk1CWall,CORNER WALL,Level All,HARD,1,1,1,Concrete,125,2,15,250,10,25,1,0,255,0,ZNULLECM,ZNULLSENSOR,0,BLWALLC1.pie,0,0,0
A0HardcreteMk1Wall,WALL,Level All,HARD,1,1,1,Concrete,125,2,15,250,10,25,1,0,255,0,ZNULLECM,ZNULLSENSOR,0,BLWALLH.pie,0,1,0
A0HardcreteMk1Wall,WALL,Level All,HARD,1,1,1,Concrete,125,2,15,250,10,25,1,0,255,0,ZNULLECM,ZNULLSENSOR,0,blwallh.pie@blwallc1.pie@blwallh_t.pie@blwallh_l.pie,0,1,0
A0LightFactory,FACTORY,Level All,MEDIUM,1,3,3,Concrete,500,3,10,500,100,100,30,150,255,20,ZNULLECM,BaBaSensor,1,blfact0.pie@factory_module1.pie@blfact1.pie@factory_module2.pie@blfact2.pie,blbfact.pie,1,0
A0PowerGenerator,POWER GENERATOR,Level All,MEDIUM,1,2,2,Concrete,500,2,20,500,30,50,30,300,255,10,ZNULLECM,DefaultSensor1Mk1,0,blpower0.pie@power_module4.pie@blpower4.pie,blbpower.pie,1,0
A0PowMod1,POWER MODULE,Level All,MEDIUM,0,2,2,Concrete,250,2,10,500,0,0,0,150,255,0,ZNULLECM,DefaultSensor1Mk1,0,blpower4.pie,0,1,0

View File

@ -0,0 +1,128 @@
PIE 2
TYPE 10200
TEXTURE 0 page-12-player-buildings.png 256 256
LEVELS 1
LEVEL 1
POINTS 64
10 65 0
26 -10 64
26 -10 0
10 65 64
-12 65 64
-28 -10 0
-28 -10 64
-12 65 0
-14 65 0
-14 78 66
-14 78 0
-14 65 66
12 65 66
12 78 0
12 78 66
12 65 0
16 89 0
37 -10 0
37 -10 0
16 89 0
-17 89 0
-38 -10 0
-38 -10 0
-17 89 0
16 89 60
37 -10 67
37 -10 60
16 89 67
-17 89 67
-38 -10 60
-38 -10 67
-17 89 60
-66 65 -12
0 -10 -28
-65 -10 -28
0 65 -12
0 65 10
-65 -10 26
0 -10 26
-66 65 10
-67 65 13
0 77 13
-67 77 13
0 65 13
0 65 -14
-67 77 -14
0 77 -14
-67 65 -14
-69 89 -17
-62 -10 -38
-69 -10 -38
-62 89 -17
-62 89 16
-69 -10 36
-62 -10 36
-69 89 16
0 89 -18
0 -10 -39
0 -10 -39
0 89 -18
0 89 15
0 -10 36
0 -10 36
0 89 15
POLYGONS 57
200 3 0 1 2 91 171 129 207 91 207
200 3 0 3 1 91 171 129 171 129 207
200 3 4 5 6 129 171 91 207 129 207
200 3 4 7 5 129 171 91 171 91 207
200 3 8 9 10 1 233 56 224 1 224
200 3 8 11 9 1 233 56 233 56 224
200 3 12 13 14 56 233 1 224 56 224
200 3 12 15 13 56 233 1 233 1 224
200 3 24 25 26 115 171 123 207 123 207
200 3 24 27 25 115 171 115 171 123 207
200 3 28 29 30 102 171 94 207 94 207
200 3 28 31 29 102 171 102 171 94 207
200 3 0 5 7 105 172 92 207 92 172
200 3 0 2 5 105 172 105 207 92 207
200 3 1 4 6 105 207 92 172 92 207
200 3 1 3 4 105 207 105 172 92 172
200 3 10 13 8 54 224 55 238 45 224
200 3 13 15 8 55 238 45 238 45 224
200 3 14 9 12 55 238 54 224 45 238
200 3 9 11 12 54 224 45 224 45 238
200 3 24 29 31 115 171 94 207 102 171
200 3 24 26 29 115 171 123 207 94 207
200 3 25 28 30 123 207 102 171 94 207
200 3 25 27 28 123 207 115 171 102 171
200 3 14 13 9 56 225 1 225 56 238
200 3 13 10 9 1 225 1 238 56 238
200 3 31 28 24 102 171 102 171 115 171
200 3 28 27 24 102 171 115 171 115 171
200 3 28 27 24 102 171 115 171 115 171
200 3 32 33 34 91 171 129 207 91 207
200 3 32 35 33 91 171 129 171 129 207
200 3 36 37 38 129 171 91 207 129 207
200 3 36 39 37 129 171 91 171 91 207
200 3 40 41 42 1 233 56 224 1 224
200 3 40 43 41 1 233 56 233 56 224
200 3 44 45 46 56 233 1 224 56 224
200 3 44 47 45 56 233 1 233 1 224
200 3 48 49 50 115 171 123 207 123 207
200 3 48 51 49 115 171 115 171 123 207
200 3 52 53 54 102 171 94 207 94 207
200 3 52 55 53 102 171 102 171 94 207
200 3 32 37 39 105 172 92 207 92 172
200 3 32 34 37 105 172 105 207 92 207
200 3 33 36 38 105 207 92 172 92 207
200 3 33 35 36 105 207 105 172 92 172
200 3 42 45 40 54 224 55 238 45 224
200 3 45 47 40 55 238 45 238 45 224
200 3 46 41 44 55 238 54 224 45 238
200 3 41 43 44 54 224 45 224 45 238
200 3 48 53 55 115 171 94 207 102 171
200 3 48 50 53 115 171 123 207 94 207
200 3 49 52 54 123 207 102 171 94 207
200 3 49 51 52 123 207 115 171 102 171
200 3 46 45 41 56 225 1 225 56 238
200 3 45 42 41 1 225 1 238 56 238
200 3 55 52 48 102 171 102 171 115 171
200 3 52 51 48 102 171 115 171 115 171

View File

@ -0,0 +1,139 @@
PIE 2
TYPE 10200
TEXTURE 0 page-12-player-buildings.png 256 256
LEVELS 1
LEVEL 1
POINTS 64
10 65 0
26 -10 64
26 -10 0
10 65 64
-12 65 64
-28 -10 0
-28 -10 64
-12 65 0
-14 65 0
-14 78 66
-14 78 0
-14 65 66
12 65 66
12 78 0
12 78 66
12 65 0
16 89 0
37 -10 0
37 -10 0
16 89 0
-17 89 0
-38 -10 0
-38 -10 0
-17 89 0
16 89 60
37 -10 67
37 -10 60
16 89 67
-17 89 67
-38 -10 60
-38 -10 67
-17 89 60
-66 65 -12
65 -10 -28
-65 -10 -28
64 65 -12
64 65 10
-65 -10 26
65 -10 26
-66 65 10
-67 65 13
66 77 13
-67 77 13
66 65 13
66 65 -14
-67 77 -14
66 77 -14
-67 65 -14
-69 89 -17
-62 -10 -38
-69 -10 -38
-62 89 -17
-62 89 16
-69 -10 36
-62 -10 36
-69 89 16
60 89 -18
67 -10 -39
60 -10 -39
67 89 -18
67 89 15
60 -10 36
67 -10 36
60 89 15
POLYGONS 68
200 3 0 1 2 91 171 129 207 91 207
200 3 0 3 1 91 171 129 171 129 207
200 3 4 5 6 129 171 91 207 129 207
200 3 4 7 5 129 171 91 171 91 207
200 3 8 9 10 1 233 56 224 1 224
200 3 8 11 9 1 233 56 233 56 224
200 3 12 13 14 56 233 1 224 56 224
200 3 12 15 13 56 233 1 233 1 224
200 3 24 25 26 115 171 123 207 123 207
200 3 24 27 25 115 171 115 171 123 207
200 3 28 29 30 102 171 94 207 94 207
200 3 28 31 29 102 171 102 171 94 207
200 3 0 5 7 105 172 92 207 92 172
200 3 0 2 5 105 172 105 207 92 207
200 3 1 4 6 105 207 92 172 92 207
200 3 1 3 4 105 207 105 172 92 172
200 3 10 13 8 54 224 55 238 45 224
200 3 13 15 8 55 238 45 238 45 224
200 3 14 9 12 55 238 54 224 45 238
200 3 9 11 12 54 224 45 224 45 238
200 3 24 29 31 115 171 94 207 102 171
200 3 24 26 29 115 171 123 207 94 207
200 3 25 28 30 123 207 102 171 94 207
200 3 25 27 28 123 207 115 171 102 171
200 3 14 13 9 56 225 1 225 56 238
200 3 13 10 9 1 225 1 238 56 238
200 3 31 28 24 102 171 102 171 115 171
200 3 28 27 24 102 171 115 171 115 171
200 3 28 27 24 102 171 115 171 115 171
200 3 32 33 34 91 171 129 207 91 207
200 3 32 35 33 91 171 129 171 129 207
200 3 36 37 38 129 171 91 207 129 207
200 3 36 39 37 129 171 91 171 91 207
200 3 40 41 42 1 233 56 224 1 224
200 3 40 43 41 1 233 56 233 56 224
200 3 44 45 46 56 233 1 224 56 224
200 3 44 47 45 56 233 1 233 1 224
200 3 48 49 50 115 171 123 207 123 207
200 3 48 51 49 115 171 115 171 123 207
200 3 52 53 54 102 171 94 207 94 207
200 3 52 55 53 102 171 102 171 94 207
200 3 56 57 58 115 171 123 207 123 207
200 3 56 59 57 115 171 115 171 123 207
200 3 60 61 62 102 171 94 207 94 207
200 3 60 63 61 102 171 102 171 94 207
200 3 32 37 39 105 172 92 207 92 172
200 3 32 34 37 105 172 105 207 92 207
200 3 33 36 38 105 207 92 172 92 207
200 3 33 35 36 105 207 105 172 92 172
200 3 42 45 40 54 224 55 238 45 224
200 3 45 47 40 55 238 45 238 45 224
200 3 46 41 44 55 238 54 224 45 238
200 3 41 43 44 54 224 45 224 45 238
200 3 48 53 55 115 171 94 207 102 171
200 3 48 50 53 115 171 123 207 94 207
200 3 49 52 54 123 207 102 171 94 207
200 3 49 51 52 123 207 115 171 102 171
200 3 56 61 63 115 171 94 207 102 171
200 3 56 58 61 115 171 123 207 94 207
200 3 57 60 62 123 207 102 171 94 207
200 3 57 59 60 123 207 115 171 102 171
200 3 46 45 41 56 225 1 225 56 238
200 3 45 42 41 1 225 1 238 56 238
200 3 55 52 48 102 171 102 171 115 171
200 3 52 51 48 102 171 115 171 115 171
200 3 63 60 56 102 171 102 171 115 171
200 3 60 59 56 102 171 115 171 115 171
200 3 60 59 56 102 171 115 171 115 171

View File

@ -16,6 +16,9 @@ file IMD "blfact2.pie"
file IMD "factory_module1.pie"
file IMD "factory_module2.pie"
file IMD "blwallh.pie"
file IMD "blwallc1.pie"
file IMD "blwallh_t.pie"
file IMD "blwallh_l.pie"
file IMD "blwallc2.pie"
file IMD "blwall2.pie"
file IMD "blwallc3.pie"
@ -35,7 +38,6 @@ file IMD "blbgen.pie"
file IMD "blbhq.pie"
file IMD "blbrbbnk.pie"
file IMD "blbrtowr.pie"
file IMD "blwallc1.pie"
file IMD "blbrlook.pie"
file IMD "icdozer.pie"
file IMD "blrpair3.pie"

View File

@ -21,7 +21,7 @@ A0CyborgFactory,CYBORG FACTORY,Level All,MEDIUM,1,1,2,Concrete,500,2,10,1000,100
A0FacMod1,FACTORY MODULE,Level All,MEDIUM,1,3,3,Concrete,250,2,10,500,100,100,25,150,255,30,ZNULLECM,DefaultSensor1Mk1,0,blfact1.pie,0,1,0
A0HardcreteMk1CWall,CORNER WALL,Level All,HARD,1,1,1,Concrete,125,2,15,700,10,25,1,0,255,0,ZNULLECM,ZNULLSENSOR,0,BLWALLC1.pie,0,0,0
A0HardcreteMk1Gate,GATE,Level All,HARD,1,1,1,Concrete,250,2,15,700,10,25,1,0,255,0,ZNULLECM,ZNULLSENSOR,0,BLGATEH.pie,0,0,0
A0HardcreteMk1Wall,WALL,Level All,HARD,1,1,1,Concrete,125,2,15,700,10,25,1,0,255,0,ZNULLECM,ZNULLSENSOR,0,BLWALLH.pie,0,1,0
A0HardcreteMk1Wall,WALL,Level All,HARD,1,1,1,Concrete,125,2,15,700,10,25,1,0,255,0,ZNULLECM,ZNULLSENSOR,0,blwallh.pie@blwallc1.pie@blwallh_t.pie@blwallh_l.pie,0,1,0
A0LasSatCommand,DOOR,Level All,MEDIUM,1,2,2,Concrete,2500,2,16,1000,10,1000,1,0,255,0,ZNULLECM,0,1,milasbas.pie,0,0,1
A0LightFactory,FACTORY,Level All,MEDIUM,1,3,3,Concrete,500,3,10,1000,100,100,30,150,255,20,ZNULLECM,BaBaSensor,1,blfact0.pie@factory_module1.pie@blfact1.pie@factory_module2.pie@blfact2.pie,blbfact.pie,1,0
A0PowerGenerator,POWER GENERATOR,Level All,MEDIUM,1,2,2,Concrete,500,2,20,1000,30,50,30,300,255,10,ZNULLECM,DefaultSensor1Mk1,0,blpower0.pie@power_module4.pie@blpower4.pie,blbpower.pie,1,0

View File

@ -16,6 +16,9 @@ file IMD "blfact2.pie"
file IMD "factory_module1.pie"
file IMD "factory_module2.pie"
file IMD "blwallh.pie"
file IMD "blwallc1.pie"
file IMD "blwallh_t.pie"
file IMD "blwallh_l.pie"
file IMD "blgateh.pie"
file IMD "blwallc2.pie"
file IMD "blwall2.pie"
@ -36,7 +39,6 @@ file IMD "blbgen.pie"
file IMD "blbhq.pie"
file IMD "blbrbbnk.pie"
file IMD "blbrtowr.pie"
file IMD "blwallc1.pie"
file IMD "blbrlook.pie"
file IMD "icdozer.pie"
file IMD "blrpair3.pie"

View File

@ -1654,24 +1654,6 @@ void displayBlueprints(void)
// Actually render everything.
for (std::vector<Blueprint>::iterator blueprint = blueprints.begin(); blueprint != blueprints.end(); ++blueprint)
{
// Rotate wall if needed.
if (blueprint->stats->type == REF_WALL || blueprint->stats->type == REF_GATE)
{
WallOrientation orientation = structChooseWallTypeBlueprint(map_coord(blueprint->pos.x), map_coord(blueprint->pos.y));
switch (orientation)
{
case WALL_HORIZ: blueprint->dir = DEG(0); break;
case WALL_VERT: blueprint->dir = DEG(90); break;
case WALL_CORNER:
if (blueprint->stats->type != REF_GATE)
{
blueprint->stats = ((WALL_FUNCTION *)blueprint->stats->asFuncList[0])->pCornerStat;
}
break;
case WALL_NEUTRAL: break;
}
}
blueprint->renderBlueprint();
}
}

View File

@ -4778,6 +4778,11 @@ static bool loadSaveStructure2(const char *pFileName, STRUCTURE **ppList)
psReArmPad->timeStarted = ini.value("Rearm/timeStarted").toInt();
psReArmPad->timeLastUpdated = ini.value("Rearm/timeLastUpdated").toInt();
break;
case REF_WALL:
case REF_GATE:
psStructure->pFunctionality->wall.type = ini.value("Wall/type").toInt();
psStructure->sDisplay.imd = psStructure->pStructureType->pIMD[std::min<unsigned>(psStructure->pFunctionality->wall.type, psStructure->pStructureType->pIMD.size() - 1)];
break;
default:
break;
}
@ -4974,6 +4979,10 @@ bool writeStructFile(const char *pFileName)
ini.setValue("Rearm/target/type", psReArmPad->psObj->type);
}
}
else if (psCurr->pStructureType->type == REF_WALL || psCurr->pStructureType->type == REF_GATE)
{
ini.setValue("Wall/type", psCurr->pFunctionality->wall.type);
}
}
ini.endGroup();
}

View File

@ -1047,13 +1047,47 @@ bool structSetManufacture(STRUCTURE *psStruct, DROID_TEMPLATE *psTempl, QUEUE_MO
* John.
*/
// Orientations are:
//
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
// | | | | | | | |
// * -* *- -*- * -* *- -*- * -* *- -*- * -* *- -*-
// | | | | | | | |
// IMDs are:
//
// 0 1 2 3
// | | |
// -*- -*- -*- -*
// |
// Orientations are: IMDs are:
// 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3
// ╴ ╶ ─ ╵ ┘ └ ┴ ╷ ┐ ┌ ┬ │ ┤ ├ ┼ ─ ┼ ┴ ┘
static uint16_t wallDir(WallOrientation orient)
{
const uint16_t d0 = DEG(0), d1 = DEG(90), d2 = DEG(180), d3 = DEG(270); // d1 = rotate ccw, d3 = rotate cw
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
uint16_t dirs[16] = {d0, d0, d2, d0, d3, d0, d3, d0, d1, d1, d2, d2, d3, d1, d3, d0};
return dirs[orient];
}
static uint16_t wallType(WallOrientation orient)
{
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
int types[16] = {0, 0, 0, 0, 0, 3, 3, 2, 0, 3, 3, 2, 0, 2, 2, 1};
return types[orient];
}
// look at where other walls are to decide what type of wall to build
static WallOrientation structWallScan(bool aWallPresent[5][5], int x, int y)
{
bool horiz = aWallPresent[x - 1][y] || aWallPresent[x + 1][y];
bool vert = aWallPresent[x][y - 1] || aWallPresent[x][y + 1];
const WallOrientation orientations[2][2] = {{WALL_NEUTRAL, WALL_HORIZ}, {WALL_VERT, WALL_CORNER}};
return orientations[vert][horiz];
WallOrientation left = aWallPresent[x - 1][y]? WallConnectLeft : WallConnectNone;
WallOrientation right = aWallPresent[x + 1][y]? WallConnectRight : WallConnectNone;
WallOrientation up = aWallPresent[x][y - 1]? WallConnectUp : WallConnectNone;
WallOrientation down = aWallPresent[x][y + 1]? WallConnectDown : WallConnectNone;
return WallOrientation(left | right | up | down);
}
static bool isWallCombiningStructureType(STRUCTURE_STATS const *pStructureType)
@ -1116,7 +1150,7 @@ static WallOrientation structWallScanTerrain(bool aWallPresent[5][5], int mapX,
{
WallOrientation orientation = structWallScan(aWallPresent, 2, 2);
if (orientation == WALL_NEUTRAL)
if (orientation == WallConnectNone)
{
// If neutral, try choosing horizontal or vertical based on terrain, but don't change to corner type.
aWallPresent[2][1] = wallBlockingTerrainJoin(mapX, mapY - 1);
@ -1124,9 +1158,9 @@ static WallOrientation structWallScanTerrain(bool aWallPresent[5][5], int mapX,
aWallPresent[1][2] = wallBlockingTerrainJoin(mapX - 1, mapY);
aWallPresent[3][2] = wallBlockingTerrainJoin(mapX + 1, mapY);
orientation = structWallScan(aWallPresent, 2, 2);
if (orientation == WALL_CORNER)
if ((orientation & (WallConnectLeft | WallConnectRight)) != 0 && (orientation & (WallConnectUp | WallConnectDown)) != 0)
{
orientation = WALL_NEUTRAL;
orientation = WallConnectNone;
}
}
@ -1153,7 +1187,6 @@ static WallOrientation structChooseWallType(unsigned player, int mapX, int mapY)
bool aWallPresent[5][5];
STRUCTURE *psStruct;
STRUCTURE *apsStructs[5][5];
SDWORD neighbourType, scanType;
// scan around the location looking for walls
memset(aWallPresent, 0, sizeof(aWallPresent));
@ -1171,49 +1204,21 @@ static WallOrientation structChooseWallType(unsigned player, int mapX, int mapY)
{
// figure out what type the wall currently is
psStruct = apsStructs[x][y];
if (psStruct->pStructureType->type == REF_WALL || psStruct->pStructureType->type == REF_GATE)
{
if (psStruct->rot.direction == DEG(90))
{
neighbourType = WALL_VERT;
}
else
{
neighbourType = WALL_HORIZ;
}
}
else
if (psStruct->pStructureType->type != REF_WALL && psStruct->pStructureType->type != REF_GATE)
{
// do not need to adjust anything apart from walls
continue;
}
// see what type the wall should be
scanType = structWallScan(aWallPresent, x,y);
WallOrientation scanType = structWallScan(aWallPresent, x,y);
if (neighbourType != scanType)
// Got to change the wall
if (scanType != WallConnectNone)
{
// Got to change the wall
if (scanType == WALL_CORNER)
{
// change to a corner
if (!psStruct->pStructureType->asFuncList.empty() && psStruct->pStructureType->asFuncList[0]->type == WALL_TYPE)
{
STRUCTURE_STATS *psStats = ((WALL_FUNCTION *)psStruct->pStructureType->asFuncList[0])->pCornerStat;
psStruct->pStructureType = psStats;
psStruct->sDisplay.imd = psStats->pIMD[0];
}
}
else if (scanType == WALL_HORIZ)
{
// change to a horizontal wall
psStruct->rot.direction = 0;
}
else if (scanType == WALL_VERT)
{
// change to a vertical wall
psStruct->rot.direction = DEG(90);
}
psStruct->pFunctionality->wall.type = wallType(scanType);
psStruct->rot.direction = wallDir(scanType);
psStruct->sDisplay.imd = psStruct->pStructureType->pIMD[std::min<unsigned>(psStruct->pFunctionality->wall.type, psStruct->pStructureType->pIMD.size() - 1)];
}
}
}
@ -1323,7 +1328,7 @@ STRUCTURE* buildStructureDir(STRUCTURE_STATS *pStructureType, UDWORD x, UDWORD y
if (IsStatExpansionModule(pStructureType)==false)
{
SDWORD wallType = 0, preScrollMinX = 0, preScrollMinY = 0, preScrollMaxX = 0, preScrollMaxY = 0;
SDWORD preScrollMinX = 0, preScrollMinY = 0, preScrollMaxX = 0, preScrollMaxY = 0;
UDWORD max = pStructureType - asStructureStats;
int i;
@ -1364,16 +1369,10 @@ STRUCTURE* buildStructureDir(STRUCTURE_STATS *pStructureType, UDWORD x, UDWORD y
return NULL;
}
WallOrientation wallOrientation = WallConnectNone;
if (!FromSave && isWallCombiningStructureType(pStructureType))
{
wallType = structChooseWallType(player, map_coord(x), map_coord(y)); // This makes neighbouring walls match us, even if we're a hardpoint, not a wall.
if (wallType == WALL_CORNER && pStructureType->type == REF_WALL)
{
if (pStructureType->asFuncList[0]->type == WALL_TYPE)
{
pStructureType = ((WALL_FUNCTION *)pStructureType->asFuncList[0])->pCornerStat;
}
}
wallOrientation = structChooseWallType(player, map_coord(x), map_coord(y)); // This makes neighbouring walls match us, even if we're a hardpoint, not a wall.
}
// allocate memory for and initialize a structure object
@ -1499,17 +1498,6 @@ STRUCTURE* buildStructureDir(STRUCTURE_STATS *pStructureType, UDWORD x, UDWORD y
alignStructure(psBuilding);
// rotate a wall if necessary
if (!FromSave && (pStructureType->type == REF_WALL || pStructureType->type == REF_GATE))
{
switch (wallType)
{
case WALL_HORIZ: psBuilding->rot.direction = DEG(0); break;
case WALL_VERT: psBuilding->rot.direction = DEG(90); break;
default: break;
}
}
//set up the sensor stats
objSensorCache(psBuilding, psBuilding->pStructureType->pSensor);
objEcmCache(psBuilding, psBuilding->pStructureType->pECM);
@ -1623,6 +1611,17 @@ STRUCTURE* buildStructureDir(STRUCTURE_STATS *pStructureType, UDWORD x, UDWORD y
// NOTE: resizeRadar() may be required here, since we change scroll limits?
}
// rotate a wall if necessary
if (!FromSave && (pStructureType->type == REF_WALL || pStructureType->type == REF_GATE))
{
psBuilding->pFunctionality->wall.type = wallType(wallOrientation);
if (wallOrientation != WallConnectNone)
{
psBuilding->rot.direction = wallDir(wallOrientation);
psBuilding->sDisplay.imd = psBuilding->pStructureType->pIMD[std::min<unsigned>(psBuilding->pFunctionality->wall.type, psBuilding->pStructureType->pIMD.size() - 1)];
}
}
psBuilding->body = (UWORD)structureBody(psBuilding);
psBuilding->expectedDamage = 0; // Begin life optimistically.
@ -1830,6 +1829,19 @@ STRUCTURE *buildBlueprint(STRUCTURE_STATS const *psStats, int32_t x, int32_t y,
blueprint->prevTime = 42;
blueprint->status = state;
// Rotate wall if needed.
if (blueprint->pStructureType->type == REF_WALL || blueprint->pStructureType->type == REF_GATE)
{
WallOrientation scanType = structChooseWallTypeBlueprint(map_coord(blueprint->pos.x), map_coord(blueprint->pos.y));
unsigned type = wallType(scanType);
if (scanType != WallConnectNone)
{
blueprint->rot.direction = wallDir(scanType);
blueprint->sDisplay.imd = blueprint->pStructureType->pIMD[std::min<unsigned>(type, blueprint->pStructureType->pIMD.size() - 1)];
}
}
return blueprint;
}
@ -1847,6 +1859,8 @@ static bool setFunctionality(STRUCTURE *psBuilding, STRUCTURE_TYPE functionType)
case REF_RESOURCE_EXTRACTOR:
case REF_REPAIR_FACILITY:
case REF_REARM_PAD:
case REF_WALL:
case REF_GATE:
// Allocate space for the buildings functionality
psBuilding->pFunctionality = (FUNCTIONALITY *)calloc(1, sizeof(*psBuilding->pFunctionality));
ASSERT_OR_RETURN(false, psBuilding != NULL, "Out of memory");

View File

@ -231,6 +231,11 @@ struct REARM_PAD
UDWORD timeLastUpdated; /* Time rearm was last updated */
};
struct WALL
{
unsigned type; // Type of wall, 0 = ─, 1 = ┼, 2 = ┴, 3 = ┘.
};
union FUNCTIONALITY
{
RESEARCH_FACILITY researchFacility;
@ -239,6 +244,7 @@ union FUNCTIONALITY
POWER_GEN powerGenerator;
REPAIR_FACILITY repairFacility;
REARM_PAD rearmPad;
WALL wall;
};
//this structure is used whenever an instance of a building is required in game
@ -354,10 +360,11 @@ typedef UPGRADE REARM_UPGRADE;
enum WallOrientation
{
WALL_NEUTRAL, ///< Arbitrary wall orientation
WALL_HORIZ, ///< Wall like this: -
WALL_VERT, ///< Wall like this: |
WALL_CORNER, ///< Wall like this: +
WallConnectNone = 0,
WallConnectLeft = 1,
WallConnectRight = 2,
WallConnectUp = 4,
WallConnectDown = 8,
};
#endif // __INCLUDED_STRUCTUREDEF_H__