No.Btw does CVariableMap have a vtbl pointer?
You can compile with CRT 9.0 (VC++ 2008) or CRT 1.0 (VC++ 2010). Obviously you need Detours 3.0 and MFC 4.2.
Posted 14 April 2012 - 03:06 PM
No.Btw does CVariableMap have a vtbl pointer?
--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.
Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)
Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)
Posted 14 April 2012 - 03:13 PM
This. Old MFC was causing me so much trouble, of course, not CRT. You did send it to me, but before I have properly tested it, you added "Spell Reflection Fix"/"Spell Reflection Animation Fix" to TobEx yourself : D Btw those fixes work like a charm, I'm happy that I somewhat helped you in that investigation!Obviously you need Detours 3.0 and MFC 4.2.
Edited by Suslik, 14 April 2012 - 03:17 PM.
Howto: mage in Baldur's Gate. My lame guide.
List of issues I have encountered in BWP 10.3 tactical
Stutter-fixer for Infinity Engine
While you were reading this signature, I have probably edited the post above. Twice.
Posted 14 April 2012 - 04:42 PM
--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.
Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)
Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)
Posted 14 April 2012 - 05:29 PM
Howto: mage in Baldur's Gate. My lame guide.
List of issues I have encountered in BWP 10.3 tactical
Stutter-fixer for Infinity Engine
While you were reading this signature, I have probably edited the post above. Twice.
Posted 14 April 2012 - 07:11 PM
void CVariableMap::MarshalGlobal(arg1, arg2) .text 0064AB6E void CVariableMap::MarshalLocal(cre) .text 0064AE43And what happens if I do not override them, but I do override information stored in those 8 bytes of CVariableMap? I think bad things will hapen, but I'm not sure.
Edited by Suslik, 14 April 2012 - 07:29 PM.
Howto: mage in Baldur's Gate. My lame guide.
List of issues I have encountered in BWP 10.3 tactical
Stutter-fixer for Infinity Engine
While you were reading this signature, I have probably edited the post above. Twice.
Posted 14 April 2012 - 07:48 PM
I'm not sure if your project settings are same as mine. I don't have the issues you mention. Also compiling under CRT 9.0 is required to work on Win2000 and WinXP SP1 or less. People have complained about using the CRT 10.0. I still haven't gotten confirmation that it actually works, though.Just a quick report on current TobEx src:
Solution file is MSVS2010 but default project toolset(project->properties) is set to v90. Bug? Feature? Does not compile in VS2010 until set to v100
Error 1 error C2440: 'return' : cannot convert from 'const void *' to 'void *' \src\lib\cptrlistex.cpp 54 (a few of those)
Error above was since v20 at least, as I recall. Why u no fix it? D: I "fixed" it via commenting those functions in cptrlistex.cpp which return void *. Since they are never called, it works : D
Ok, except for that and some bugginess with a messed detours version(which also requires detoured), I have built tobex and it works. Yeah, you will call me a vagrant, but I have just replaced v23's TobEx.dll with a new one and it still works : D I cannot install the thing properly due to generalized_biffing and >1000 mods and I dunno how to do it manually, but just replacing TobEx.dll works.
Anyway, I'm going to do some code injection here, yarrr!
Yes, and yes.What string key is this var added with? Does its "name" field count as string key? If yes, it means that name length is limited to 32 characters?
I would have though you knew about Unmarshal and Marshal, although probably not in binary to binary sense. The variables need to be saved in the saved game, so global variables marshalled into BALDUR.GAM and .ARE structures, while local variables marshalled into .CRE structures.What do these do? Are they even public?
No, you can never be sure. Test.I mean in case I'm overriding the memory of CVariableMap(I use 8 bytes stored in it in my own way), it's imperative to override all methods that will use this class's memory, but can I be sure that these are all necessary methods and there are not any more I do not know about?
--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.
Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)
Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)
Posted 15 April 2012 - 05:41 AM
I do know about marshalling, but I have no idea how to marshal those variables into .gam/.are/.cre files. And why is there no unmarshal? Hell, why is hashmap responsible for such operations and not some external mechanism? But anyway, I hope the game will not crash if will test it without saving. I will test.would have though you knew about Unmarshal and Marshal, although probably not in binary to binary sense.
I am currently about 95% sure that the stuttering is caused by GetGlobals. But I do not know how exactly the hashmap is organised so I cannot tell how the size of the hashmap affects its performance. But I will experiment.Aren't you jumping the gun a little? You haven't fully diagnosed the cause of the stutters yet?
Howto: mage in Baldur's Gate. My lame guide.
List of issues I have encountered in BWP 10.3 tactical
Stutter-fixer for Infinity Engine
While you were reading this signature, I have probably edited the post above. Twice.
Posted 15 April 2012 - 06:25 AM
Edited by Suslik, 15 April 2012 - 06:28 AM.
Howto: mage in Baldur's Gate. My lame guide.
List of issues I have encountered in BWP 10.3 tactical
Stutter-fixer for Infinity Engine
While you were reading this signature, I have probably edited the post above. Twice.
Posted 15 April 2012 - 07:41 AM
Howto: mage in Baldur's Gate. My lame guide.
List of issues I have encountered in BWP 10.3 tactical
Stutter-fixer for Infinity Engine
While you were reading this signature, I have probably edited the post above. Twice.
Posted 15 April 2012 - 08:14 AM
Edited by i30817, 15 April 2012 - 08:59 AM.
Posted 15 April 2012 - 09:28 AM
Umm.. It does not look complicated, why? Anyway, implementing the algorithm itself is far easier than injecting its code to the binary. All those DETOUR things, special memory management, Tramp- stuff is a little overwhelming and gives way more trouble than implementing a standard algorithm.Cuckoo hashing is complex to implement.
Edited by Suslik, 15 April 2012 - 09:28 AM.
Howto: mage in Baldur's Gate. My lame guide.
List of issues I have encountered in BWP 10.3 tactical
Stutter-fixer for Infinity Engine
While you were reading this signature, I have probably edited the post above. Twice.
Posted 15 April 2012 - 09:40 AM
- The failure mode of cuckoo hashing is unpleasant. One thing I glossed over last time is that there's some (small) chance that cuckoo hashing gets caught in a loop; in moving things around to try to find an empty space, it can get stuck in a cycle, moving the same things back and forth repeatedly without ever being able to squeeze in a new element. In the theoretical analysis, this can swept under the rug by saying that after a certain number of steps, declare a failure and re-hash everything with new hash functions. In practical settings, like a router, this is often not a feasible option.
Edited by i30817, 15 April 2012 - 09:50 AM.
Posted 15 April 2012 - 10:00 AM
What's the problem? When the table becomes too tight, just rehash it. It will anyway be rehashed when it's fully occupied, why not make it a little earlier?In the theoretical analysis, this can swept under the rug by saying that after a certain number of steps, declare a failure and re-hash everything with new hash functions.
Howto: mage in Baldur's Gate. My lame guide.
List of issues I have encountered in BWP 10.3 tactical
Stutter-fixer for Infinity Engine
While you were reading this signature, I have probably edited the post above. Twice.
Posted 15 April 2012 - 10:05 AM
Resize is a private, implementation detail of Maps. It normally happens when you need to add a new mapping that doesn't exist yet on the map and it's rate of occupancy is beyond what the designer thought was wise. As it is private, i'd be very surprised if it was called outside the class.I'm currently tinkering with overriding their hashmap functionality. It has some hidden mechanism to determine if the hashtable needs to be resized. For example, ::Resize() is not called if Add() returns 0, but it is called under some other circumstances I do not know about. I cannot implement any hashing algorithm until I can say the engine that my map needs to be resized.
What's the problem? When the table becomes too tight, just rehash it. It will anyway be rehashed when it's fully occupied, why not make it a little earlier?In the theoretical analysis, this can swept under the rug by saying that after a certain number of steps, declare a failure and re-hash everything with new hash functions.
Edited by i30817, 15 April 2012 - 10:26 AM.
Posted 15 April 2012 - 10:23 AM
Maybe it's called by another private method of this class, but since its whole interface is unknown, it does not matter if this is class's private method or an outside function.i'd be very surprised if it was called outside the class.
That was the first thing I tried, but it seems to crash in some other method I have not yet externalized. It seems that the only way to figure this out is either ask Asc64 for a more complete list of class methods or debug the executable myself.And even if it was, i'd just NOP it and let other; implicit on Add resize of the implementation you snipped in work.
Edited by Suslik, 15 April 2012 - 10:24 AM.
Howto: mage in Baldur's Gate. My lame guide.
List of issues I have encountered in BWP 10.3 tactical
Stutter-fixer for Infinity Engine
While you were reading this signature, I have probably edited the post above. Twice.
Posted 15 April 2012 - 10:29 AM
Posted 15 April 2012 - 01:40 PM
Edited by Suslik, 15 April 2012 - 01:43 PM.
Howto: mage in Baldur's Gate. My lame guide.
List of issues I have encountered in BWP 10.3 tactical
Stutter-fixer for Infinity Engine
While you were reading this signature, I have probably edited the post above. Twice.
Posted 15 April 2012 - 06:25 PM
static randomNumbers[256][32]; static randomNumbersInitialized = 0; //alternative hashing for strings of max length 32. never used but looks promising. unsigned int StrTableHash(const char *str) { if(!randomNumbersInitialized) { for(int i = 0; i < 256; i++) { for(int j = 0; j < 32; j++) { randomNumbers[i][j] = IERand(); } } randomNumbersInitialized = 1; } unsigned int hash = 0; for(int i = 0; str[i] != 0; i++) hash ^= randomNumbers[str[i]][i]; return hash; } unsigned int StrHash(const char *str) { unsigned int hash = 5381; unsigned int c; while (c = *str++) hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ return hash; } void DETOUR_CVariableMap::DETOUR_Construct(int nSize) { //nSize = 4096; (this->*Tramp_CVariableMap_Construct)(nSize); } void DETOUR_CVariableMap::DETOUR_Deconstruct() { return (this->*Tramp_CVariableMap_Deconstruct)(); } bool IsEmpty(CVariable &var) { return var.name.GetBuf()[0] == 0; } BOOL DETOUR_CVariableMap::DETOUR_Add(CVariable& var) { int i = 0; for(int i = 0; (i < 32) && var.name.GetBuf()[i] != 0; i++) { var.name.GetBuf()[i] = toupper(var.name.GetBuf()[i]); } unsigned int start = StrHash((char *)&(var.name)); for(unsigned int i = 0; i < nArraySize / 10; i++) { int index = (i + start) % nArraySize; if(IsEmpty(pArray[index]) || strcmp(var.name.GetBuf(), pArray[index].name.GetBuf()) == 0)//.ToCString().CompareNoCase(pArray[index].name.ToCString()) == 0) //bucket is empty { pArray[index] = var; return 1; } } SetSize(nArraySize * 2); return DETOUR_Add(var); int sizeBefore = nArraySize; BOOL res = (this->*Tramp_CVariableMap_Add)(var); return res; } CVariable& DETOUR_CVariableMap::DETOUR_Find(IECString sVar) { char key[32]; int i = 0; do { key[i] = toupper(sVar[i]); }while(sVar[i++] != 0 && i < 32); key[31] = 0; unsigned int start = StrHash(key); for(unsigned int i = 0; i < nArraySize; i++) { unsigned int index = (start + i) % nArraySize; if(strcmp(key, pArray[index].name.GetBuf()) == 0) { return pArray[index]; } if(IsEmpty(pArray[index])) break; } return *((CVariable *)0); return (this->*Tramp_CVariableMap_Find)(sVar); } void DETOUR_CVariableMap::DETOUR_Empty() { return (this->*Tramp_CVariableMap_Empty)(); } void DETOUR_CVariableMap::DETOUR_SetSize(int nNewSize) { //console.writef("resizing from size %d to %d\n", nArraySize, nNewSize); (this->*Tramp_CVariableMap_SetSize)(nNewSize); /*int largestBlockSize = 1; int currBlockSize = 0; for(int i = 0; i < nArraySize; i++) { if(IsEmpty(pArray[i])) currBlockSize = 0; currBlockSize++; if(currBlockSize > largestBlockSize) largestBlockSize = currBlockSize; } console.writef("after resize largest block is %d\n", largestBlockSize);*/ }There are two major things I have changed from the original algorithm:
Edited by Suslik, 15 April 2012 - 07:36 PM.
Howto: mage in Baldur's Gate. My lame guide.
List of issues I have encountered in BWP 10.3 tactical
Stutter-fixer for Infinity Engine
While you were reading this signature, I have probably edited the post above. Twice.
Posted 15 April 2012 - 08:55 PM
Edited by i30817, 15 April 2012 - 09:42 PM.
Posted 15 April 2012 - 09:28 PM