MCPcopy Create free account
hub / github.com/diasurgical/devilution / Cl2BlitOutlineSafe

Function Cl2BlitOutlineSafe

Source/engine.cpp:1213–1287  ·  view source on GitHub ↗

* @brief Blit a solid colder shape one pixel larger then the given sprite shape, to the given buffer * @param pDecodeTo The output buffer * @param pRLEBytes CL2 pixel stream (run-length encoded) * @param nDataSize Size of CL2 in bytes * @param nWidth Width of sprite * @param col Color index from current palette */

Source from the content-addressed store, hash-verified

1211 * @param col Color index from current palette
1212 */
1213void Cl2BlitOutlineSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col)
1214{
1215 int w;
1216 char width;
1217 BYTE *src, *dst;
1218
1219 src = pRLEBytes;
1220 dst = pDecodeTo;
1221 w = nWidth;
1222
1223 while (nDataSize) {
1224 width = *src++;
1225 nDataSize--;
1226 if (width < 0) {
1227 width = -width;
1228 if (width > 65) {
1229 width -= 65;
1230 nDataSize--;
1231 if (*src++ && dst < gpBufEnd && dst > gpBufStart) {
1232 w -= width;
1233 dst[-1] = col;
1234 dst[width] = col;
1235 while (width) {
1236 dst[-BUFFER_WIDTH] = col;
1237 dst[BUFFER_WIDTH] = col;
1238 dst++;
1239 width--;
1240 }
1241 if (!w) {
1242 w = nWidth;
1243 dst -= BUFFER_WIDTH + w;
1244 }
1245 continue;
1246 }
1247 } else {
1248 nDataSize -= width;
1249 if (dst < gpBufEnd && dst > gpBufStart) {
1250 w -= width;
1251 while (width) {
1252 if (*src++) {
1253 dst[-1] = col;
1254 dst[1] = col;
1255 dst[-BUFFER_WIDTH] = col;
1256 dst[BUFFER_WIDTH] = col;
1257 }
1258 dst++;
1259 width--;
1260 }
1261 if (!w) {
1262 w = nWidth;
1263 dst -= BUFFER_WIDTH + w;
1264 }
1265 continue;
1266 } else {
1267 src += width;
1268 }
1269 }
1270 }

Callers 1

Cl2DrawOutlineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected