View previous topic :: View next topic |
Author |
Message |
werehound
Joined: 17 Aug 2010 Posts: 41
|
Posted: Mon Apr 16, 2012 21:04 Post subject: nwnx2_fixes |
|
|
The option to prevent the stacking of items with different variables only works for one (the first) variable on an item. If the second variables differ, they will still stack.
Any way to fix this? |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Wed Apr 18, 2012 1:18 Post subject: a guess |
|
|
My guess is that it is because of the use of 'return' statements in each case statement.
It returns out of the variable iteration before processing all variables.
I think at one point, the author was going to use bFound - as the return value, but then opted for direct booleans.
Assuming I have it correct - the quick fix could potentially be changing the return FALSE etc statements, to be
bFound = false;
and then return bFound outside of the for loop.
Can anyone else with more c++ experience confirm?
Code: |
bool CompareVarLists (CNWObjectVarList *pVarList1, CNWObjectVarList *pVarList2) {
if (pVarList1->VarCount == 0 && pVarList2->VarCount == 0)
return true;
for (unsigned int i = 0; i < pVarList1->VarCount; i++) {
bool bFound = false;
CNWObjectVarListElement *pVar1 = &pVarList1->VarList[i];
// Only check variables that start with an underscore.
// This lets us control whether or not a variable should block stacking.
if (fixes.ini_compare_vars_ignore_prefix[0] &&
!strncmp(pVar1->sVarName.Text, fixes.ini_compare_vars_ignore_prefix, strlen(fixes.ini_compare_vars_ignore_prefix))) {
continue;
}
for (unsigned int j = 0; j < pVarList2->VarCount; j++) {
CNWObjectVarListElement *pVar2 = &pVarList2->VarList[j];
if (pVar1->nVarType == pVar2->nVarType &&
strcmp(pVar1->sVarName.Text, pVar2->sVarName.Text) == 0) {
bFound = true;
//Compare values
switch (pVar1->nVarType) {
case 1: //int
if ((int)(pVar1->nVarValue) != (int)(pVar2->nVarValue)) {
#ifdef NWNX_FIXES_DEBUG
fixes.Log(3, "blocking merge: int value '%s' %d != %d\n", pVar1->sVarName.Text,
(int)(pVar1->nVarValue), (int)(pVar2->nVarValue));
#endif
return false;
}
break;
case 2: //float
if ((float)(pVar1->nVarValue) != (float)(pVar2->nVarValue)) {
#ifdef NWNX_FIXES_DEBUG
fixes.Log(3, "blocking merge: float value '%s' %.04f != %.04f\n", pVar1->sVarName.Text,
(float)(pVar1->nVarValue), (float)(pVar2->nVarValue));
#endif
return false;
}
break;
case 3: //string
// both pointers are equal or both are null
if ((char **)(pVar1->nVarValue) == (char **)(pVar2->nVarValue))
break;
if ((char **)(pVar1->nVarValue) == NULL || (char **)(pVar2->nVarValue) == NULL) { //the variable is not set on one of the objects
#ifdef NWNX_FIXES_DEBUG
fixes.Log(3, "blocking merge: string value '%s' is not set on one of the objects\n", pVar1->sVarName.Text);
#endif
return false;
}
if (*(char **)(pVar1->nVarValue) == *(char **)(pVar2->nVarValue)) //equal pointers
break;
if (*(char **)(pVar1->nVarValue) == NULL || *(char **)(pVar2->nVarValue) == NULL) { //one of the variables is empty
#ifdef NWNX_FIXES_DEBUG
fixes.Log(3, "blocking merge: string value '%s' is not set on one of the objects\n", pVar1->sVarName.Text);
#endif
return false;
}
if (strcmp(*(char **)(pVar1->nVarValue), *(char **)(pVar2->nVarValue)) != 0) { //string values are not equal
#ifdef NWNX_FIXES_DEBUG
fixes.Log(3, "blocking merge: string value '%s' '%s' != '%s'\n", pVar1->sVarName.Text,
*(char **)(pVar1->nVarValue), *(char **)(pVar2->nVarValue));
#endif
return false;
}
break;
case 4: //object
if ((dword)(pVar1->nVarValue) != (dword)(pVar2->nVarValue)) {
#ifdef NWNX_FIXES_DEBUG
fixes.Log(3, "blocking merge: object value '%s' %08X != %08X\n", pVar1->sVarName.Text,
(dword)(pVar1->nVarValue), (dword)(pVar2->nVarValue));
#endif
return false;
}
break;
case 5: //location
break;
}
break;
}
}
if (!bFound) {
#ifdef NWNX_FIXES_DEBUG
fixes.Log(3, "blocking merge: local variable '%s' not found on one of the objects", pVar1->sVarName.Text);
#endif
return false;
}
return 1;
}
return true;
}
|
|
|
Back to top |
|
|
werehound
Joined: 17 Aug 2010 Posts: 41
|
Posted: Wed Apr 18, 2012 1:45 Post subject: |
|
|
Looks like that'd be it.
Can't compile without NWNXBase.h...
Where can I find this? |
|
Back to top |
|
|
Terra_777
Joined: 27 Jun 2008 Posts: 216 Location: Sweden
|
Posted: Wed Apr 18, 2012 2:01 Post subject: |
|
|
nwnxdll. I suggest downloading http://tortoisesvn.net/downloads.html and downloading the files from the svn which you can find stickied in this forum section.
Quick tutorial:
*Install tortoisesvn
*Rightclick a folder and select svn checkout
*Fill in the svn address same as the one you find in the svn topic
*Press ok/go/whatever and it'll sync the folder with the svn and you'll get all code. _________________ I dun have any signature, I'm happy anyway. |
|
Back to top |
|
|
werehound
Joined: 17 Aug 2010 Posts: 41
|
Posted: Wed Apr 18, 2012 5:20 Post subject: |
|
|
Oh, this is so much fun, and it fixes my problem! Thank you! |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|