feat(core): add functions to remove all kazari with a specific sasa/tanzaku ID
This commit is contained in:
parent
d8c43c7855
commit
4724962cd3
@ -137,3 +137,35 @@ int kazari_rem(Shoppyou *shoppyou, uint64_t sasa_id, uint64_t tanzaku_id) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kazari_rem_by_sasa(Shoppyou *shoppyou, uint64_t sasa_id) {
|
||||
if (sasa_id == HOLE_ID) {
|
||||
return 1;
|
||||
}
|
||||
for (uint64_t i = 0; i < shoppyou->size; i++) {
|
||||
if (shoppyou->database[i].sasa_id == sasa_id) {
|
||||
shoppyou->database[i].sasa_id = HOLE_ID;
|
||||
shoppyou->hole_cnt++;
|
||||
shoppyou->holes = realloc(shoppyou->holes, shoppyou->hole_cnt * sizeof(Kazari *));
|
||||
shoppyou->holes[shoppyou->hole_cnt - 1] = shoppyou->database + i;
|
||||
shoppyou->modified_ts = time(NULL);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kazari_rem_by_tanzaku(Shoppyou *shoppyou, uint64_t tanzaku_id) {
|
||||
if (tanzaku_id == HOLE_ID) {
|
||||
return 1;
|
||||
}
|
||||
for (uint64_t i = 0; i < shoppyou->size; i++) {
|
||||
if (shoppyou->database[i].tanzaku_id == tanzaku_id) {
|
||||
shoppyou->database[i].tanzaku_id = HOLE_ID;
|
||||
shoppyou->hole_cnt++;
|
||||
shoppyou->holes = realloc(shoppyou->holes, shoppyou->hole_cnt * sizeof(Kazari *));
|
||||
shoppyou->holes[shoppyou->hole_cnt - 1] = shoppyou->database + i;
|
||||
shoppyou->modified_ts = time(NULL);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -163,6 +163,12 @@ int kazari_add(Shoppyou *shoppyou, uint64_t sasa_id, uint64_t tanzaku_id);
|
||||
// Remove kazari from shoppyou
|
||||
int kazari_rem(Shoppyou *shoppyou, uint64_t sasa_id, uint64_t tanzaku_id);
|
||||
|
||||
// Remove all kazari with a specific sasa ID from shoppyou
|
||||
int kazari_rem_by_sasa(Shoppyou *shoppyou, uint64_t sasa_id);
|
||||
|
||||
// Remove all kazari with a specific tanzaku ID from shoppyou
|
||||
int kazari_rem_by_tanzaku(Shoppyou *shoppyou, uint64_t tanzaku_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user