MCPcopy Create free account
hub / github.com/crossuo/crossuo / CreateLandTextureRect

Method CreateLandTextureRect

src/GameObjects/MapBlock.cpp:106–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106void CMapBlock::CreateLandTextureRect()
107{
108 int map = g_MapManager.GetActualMap();
109 for (int x = 0; x < 8; x++)
110 {
111 for (int y = 0; y < 8; y++)
112 {
113 CLandObject *obj = GetLand((int)x, (int)y);
114 if (obj != nullptr)
115 {
116 int tileX = obj->GetX();
117 int tileY = obj->GetY();
118 char tileZ1 = obj->GetZ();
119
120 auto spr = g_Game.ExecuteTexture(obj->Graphic);
121 if (obj->IsStretched || spr == nullptr ||
122 !TestStretched(tileX, tileY, tileZ1, map, true))
123 {
124 obj->IsStretched = false;
125 obj->MinZ = tileZ1;
126 }
127 else
128 {
129 obj->IsStretched = true;
130 obj->UpdateZ(
131 GetLandZ(tileX, tileY + 1, map),
132 GetLandZ(tileX + 1, tileY + 1, map),
133 GetLandZ(tileX + 1, tileY, map));
134
135 CVector vec[3][3][4];
136 for (int i = -1; i < 2; i++)
137 {
138 int curX = tileX + (int)i;
139 int curI = (int)i + 1;
140 for (int j = -1; j < 2; j++)
141 {
142 int curY = tileY + (int)j;
143 int curJ = (int)j + 1;
144 char currentZ = GetLandZ(curX, curY, map);
145 char leftZ = GetLandZ(curX, curY + 1, map);
146 char rightZ = GetLandZ(curX + 1, curY, map);
147 char bottomZ = GetLandZ(curX + 1, curY + 1, map);
148 if (currentZ == leftZ && currentZ == rightZ && currentZ == bottomZ)
149 {
150 for (int k = 0; k < 4; k++)
151 {
152 vec[curI][curJ][k].Link(0.0, 0.0, 1.0);
153 }
154 }
155 else
156 {
157 vec[curI][curJ][0].Link(-22.0, 22.0, (currentZ - rightZ) * 4);
158 vec[curI][curJ][0].Merge(-22.0, -22.0, (leftZ - currentZ) * 4);
159 vec[curI][curJ][0].Normalize();
160
161 vec[curI][curJ][1].Link(22.0, 22.0, (rightZ - bottomZ) * 4);
162 vec[curI][curJ][1].Merge(-22.0, 22.0, (currentZ - rightZ) * 4);
163 vec[curI][curJ][1].Normalize();

Callers 1

LoadBlockMethod · 0.80

Calls 10

GetActualMapMethod · 0.80
GetYMethod · 0.80
GetZMethod · 0.80
ExecuteTextureMethod · 0.80
UpdateZMethod · 0.80
LinkMethod · 0.80
NormalizeMethod · 0.80
GetXMethod · 0.45
MergeMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected