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

Function GetItemSpace

Source/items.cpp:999–1051  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

997}
998
999BOOL GetItemSpace(int x, int y, char inum)
1000{
1001 int i, j, rs;
1002 int xx, yy;
1003 BOOL savail;
1004
1005 yy = 0;
1006 for (j = y - 1; j <= y + 1; j++) {
1007 xx = 0;
1008 for (i = x - 1; i <= x + 1; i++) {
1009 itemhold[xx][yy] = ItemSpaceOk(i, j);
1010 xx++;
1011 }
1012 yy++;
1013 }
1014
1015 savail = FALSE;
1016 for (j = 0; j < 3; j++) {
1017 for (i = 0; i < 3; i++) {
1018 if (itemhold[i][j])
1019 savail = TRUE;
1020 }
1021 }
1022
1023 rs = random_(13, 15) + 1;
1024
1025 if (!savail)
1026 return FALSE;
1027
1028 xx = 0;
1029 yy = 0;
1030 while (rs > 0) {
1031 if (itemhold[xx][yy])
1032 rs--;
1033 if (rs > 0) {
1034 xx++;
1035 if (xx == 3) {
1036 xx = 0;
1037 yy++;
1038 if (yy == 3)
1039 yy = 0;
1040 }
1041 }
1042 }
1043
1044 xx += x - 1;
1045 yy += y - 1;
1046 item[inum]._ix = xx;
1047 item[inum]._iy = yy;
1048 dItem[xx][yy] = inum + 1;
1049
1050 return TRUE;
1051}
1052
1053void GetSuperItemSpace(int x, int y, char inum)
1054{

Callers 1

GetSuperItemSpaceFunction · 0.85

Calls 2

ItemSpaceOkFunction · 0.85
random_Function · 0.85

Tested by

no test coverage detected