Skip to content

Commit

Permalink
Fix another issue with listitem
Browse files Browse the repository at this point in the history
  • Loading branch information
RusJJ committed Oct 10, 2024
1 parent 903b4d1 commit 266dcfa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobject appContext;
JNIEnv* env;

// Main
static ModInfo modinfoLocal("net.rusjj.aml", "AML Core", "1.2.3", "RusJJ aka [-=KILL MAN=-]");
static ModInfo modinfoLocal("net.rusjj.aml", "AML Core", "1.2.4", "RusJJ aka [-=KILL MAN=-]");
ModInfo* amlmodinfo = &modinfoLocal;
static Config cfgLocal("ModLoaderCore");
Config* cfg = &cfgLocal;
Expand Down
10 changes: 7 additions & 3 deletions mod/listitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@
list = this; \
} \
inline bool Remove(__cls_name **listPtr) { \
if(!listPtr || !*listPtr || !pLast) return false; \
__cls_name*& list = *listPtr; \
if(!pPrev && !pNext && !pLast) return false; \
if(list == this) { \
if(pNext) { \
list = pNext; \
pNext->nCount = nCount - 1; \
pNext->pPrev = NULL; \
list->nCount = nCount - 1; \
list->pPrev = NULL; \
list->pLast = pLast; \
} else { \
list = NULL; \
} \
Expand Down Expand Up @@ -90,9 +91,12 @@
nCount = 1; \
}

// Never use FAST versions if you do "Remove" or "Push" in a loop! Or maintain it by yourself!

#define LIST_FOR(__list) for(auto item = __list, itemNext = item ? item->pNext : NULL; item != NULL; item = itemNext, itemNext = item ? item->pNext : NULL)
#define LIST_FOR_FAST(__list) for(auto item = __list; item != NULL; item = item->pNext)
#define LIST_FOR2(__list, __itemname) for(auto __itemname = __list, itemNext = __itemname ? __itemname->pNext : NULL; __itemname != NULL; __itemname = itemNext, itemNext = __itemname ? __itemname->pNext : NULL)
#define LIST_FOR2_FAST(__list, __itemname) for(auto __itemname = __list; __itemname != NULL; __itemname = __itemname->pNext)
#define LIST_FOR_REVERSE(__list) for(auto item = __list ? __list->pLast : NULL, itemPrev = item ? item->pPrev : NULL; item != NULL; item = itemPrev, itemPrev = item ? item->pPrev : NULL)
#define LIST_FOR_REVERSE_FAST(__list) for(auto item = __list ? __list->pLast : NULL; item != NULL; item = item->pPrev)
#define LIST_RESET(__list, __resetFunc) LIST_FOR(__list) { __resetFunc(); item->Remove(&__list); }
10 changes: 7 additions & 3 deletions template_of_mod/mod/listitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@
list = this; \
} \
inline bool Remove(__cls_name **listPtr) { \
if(!listPtr || !*listPtr || !pLast) return false; \
__cls_name*& list = *listPtr; \
if(!pPrev && !pNext && !pLast) return false; \
if(list == this) { \
if(pNext) { \
list = pNext; \
pNext->nCount = nCount - 1; \
pNext->pPrev = NULL; \
list->nCount = nCount - 1; \
list->pPrev = NULL; \
list->pLast = pLast; \
} else { \
list = NULL; \
} \
Expand Down Expand Up @@ -90,9 +91,12 @@
nCount = 1; \
}

// Never use FAST versions if you do "Remove" or "Push" in a loop! Or maintain it by yourself!

#define LIST_FOR(__list) for(auto item = __list, itemNext = item ? item->pNext : NULL; item != NULL; item = itemNext, itemNext = item ? item->pNext : NULL)
#define LIST_FOR_FAST(__list) for(auto item = __list; item != NULL; item = item->pNext)
#define LIST_FOR2(__list, __itemname) for(auto __itemname = __list, itemNext = __itemname ? __itemname->pNext : NULL; __itemname != NULL; __itemname = itemNext, itemNext = __itemname ? __itemname->pNext : NULL)
#define LIST_FOR2_FAST(__list, __itemname) for(auto __itemname = __list; __itemname != NULL; __itemname = __itemname->pNext)
#define LIST_FOR_REVERSE(__list) for(auto item = __list ? __list->pLast : NULL, itemPrev = item ? item->pPrev : NULL; item != NULL; item = itemPrev, itemPrev = item ? item->pPrev : NULL)
#define LIST_FOR_REVERSE_FAST(__list) for(auto item = __list ? __list->pLast : NULL; item != NULL; item = item->pPrev)
#define LIST_RESET(__list, __resetFunc) LIST_FOR(__list) { __resetFunc(); item->Remove(&__list); }

0 comments on commit 266dcfa

Please sign in to comment.