1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
typedef uchar hack_t;
#define HACK_T_MAX UCHAR_MAX
typedef struct _HACK
{
uchar use : 1;
// Is Radio List
uchar irl : 1;
// ID (codelist file usage only)
ulong id;
// Current Index
hack_t _ci;
// Parent Index
hack_t _pi;
// 1st Child Index
hack_t _fi;
// Next Sibling Index
hack_t _ni;
} HACK;
typedef struct _HACKS
{
hack_t i;
hack_t c;
hack_t _c;
size_t s;
HACK a[1];
} HACKS;
void guiHacks_OnRemUpdate ( hack_t i, hack_t c, hack_t r )
{
HACK *hack = &tmpHacks.hacks->a[i];
hack->_ci = i;
if ( hack->_fi )
{
guiHacks_OnRemUpdate ( hack->_fi > r ? hack->_fi -= c : hack->_fi, c, r );
}
if ( hack->_ni )
{
guiHacks_OnRemUpdate ( hack->_ni > r ? hack->_ni -= c : hack->_ni, c, r );
}
}
void guiHacks_OnRem ( void )
{
if ( !tmpIndex || tmpHacks.hacks->i < 1 || tmpHacks.hacks->c <= 1 )
{
return;
}
hack_t i = tmpHacks.hacks->i, c = tmpHacks.hacks->c;
HACK *hack = &tmpHacks.hacks->a[i];
char *name = tmpHacks.names[i].a;
HACK *ownr = &tmpHacks.hacks->a[hack->_pi];
HACK *prev = &tmpHacks.hacks->a[i - 1];
hack_t n = hack->_ni ? hack->_ni : ownr->_ni;
HACK *next = n ? &tmpHacks.hacks->a[n] : NULL;
if ( !hack->_ni )
{
if ( prev == ownr )
{
ownr->_fi = 0;
}
else
{
prev->_ni = 0;
}
}
if ( next )
{
c -= n;
memmove ( &tmpIndex[i], &tmpIndex[n], c * sizeof ( hack_t ) );
memmove ( name, tmpHacks.names[n].a, c * NAME_MAX );
memmove ( hack, next, c * sizeof ( HACK ) );
n -= i;
c = tmpHacks.hacks->c - n;
}
else
{
n = 1;
c = i;
}
guiHacks_OnRemUpdate ( 0, n, i );
hacksReSize ( &tmpHacks, &tmpIndex, c );
guiHacks_OnShow ( guiHacks.main.fset );
}
|