I would really like to make a small in-game display instead of using an external program that you have to download separately and have to alt-tab out to check on. I was hoping you might have a suggestion like that. I will look at those files. I am finished with all of the code I think (aside from the in-game display if I try that). I tested the code in my dice rolling test program and have integrated the rng code into the game and it all compiles without errors. I decided to put the hotbits file reading/writing function definitions in legacysystems.cpp right before they are called in the constructor and destructor and the rest (GetInt()) is in rng.cpp. The function definitions could be moved of course.
I just have to spend some hours actually playing ToEE in TrueRandom mode with and without a hotbits file. I added 3 settings to config.cpp/h and the .ini file: useTrueRandom (defaults to 0), forceRdrand (defaults to 0), and randLevel (defaults to 8 and represents the number of whitening iterations when running rdrand()). I decided not to add a useHotbits option because if useTrueRandom = 1 the program searches for a hotbits.bin file anyway before enabling that code path. I also included a code path for people with old CPUs who want to use a hotbits file (until it runs out) instead of Mersenne. For now I decided not to mix/whiten the hotbits data in that scenario. It should just use the hotbits until they are gone and then switch back to Mersenne.
Right now I am re-coding my hotbits downloader .bat file as a c++ program (well trying to) and I will do some toee playtesting soon. It is amazing how much longer and more complex the c version is compared to a simple batch file, but it is also doing more.
I have never worked on any large projects with multiple source files etc before and I have had to learn how to deal with the added complexity. In general it is still possible to set breakpoints and single-step through the code, right? I can't get that to work though. I can't get VS2017 to 'start debugging' at all. It says "Unable to start program ..\repos\TemplePlus\Debug\Infrastructure.lib" and "..\repos\TemplePlus\Debug\Infrastructure.lib is not a valid Win32 application." I have a suspicion that if I did succeed in getting it to run the game might crash at a breakpoint anyway, but I was going to at least try. Is it not possible to do that sort of debugging with this project perhaps because a lot of the game code is actually compiled Troika code? There are some things I just can't test with an external test program.
...
Well I looked at those source and header files and that code is not 'self-documenting'. I could only make wild guesses about how to make a display. Maybe if there were comments, but that is not The Way of modern programming I guess. The modern way is 'It was hard to write. It should be hard to read.' Hehe.
Perhaps if you could give me a general outline of how I might do it. I really just need to display a single variable (a global pointer to uints) that represents the progress through the hotbits file as a number and a percentage. A battery meter style display would be good too if possible.
...
I decided that the hotbitsmon program could still be useful for crash protection. If the game crashes hotbitsmon can essentially run trimhotbits() itself so that the hotbits data status is kept updated. If I implement this then the only time the hotbits file won't stay updated is with a power loss. A game crash will be no problem. I thought I had to go back to storing the bits in a shared memory object, but then realized I could just use the hotbits file itself to reread the data if there was a crash. The important thing is that the index remains in hotbitsmon if the game crashes.
Anyway it's all looking good. My c/c++ downloading program (hotbitsfetch) is much more sophisticated than the simple batch file and seems to be working. It won't allow downloads until 24 hours (in seconds) has passed since the last download and will automatically append to previous downloads or to the main hotbits.bin file depending on whether or not templeplus.exe is currently running. It can be set to run from the windows task scheduler every 24 hours and just keep growing the size of the file every day. I am working on implementing the crash protection in hotbitsmon now.
I just have to spend some hours actually playing ToEE in TrueRandom mode with and without a hotbits file. I added 3 settings to config.cpp/h and the .ini file: useTrueRandom (defaults to 0), forceRdrand (defaults to 0), and randLevel (defaults to 8 and represents the number of whitening iterations when running rdrand()). I decided not to add a useHotbits option because if useTrueRandom = 1 the program searches for a hotbits.bin file anyway before enabling that code path. I also included a code path for people with old CPUs who want to use a hotbits file (until it runs out) instead of Mersenne. For now I decided not to mix/whiten the hotbits data in that scenario. It should just use the hotbits until they are gone and then switch back to Mersenne.
Right now I am re-coding my hotbits downloader .bat file as a c++ program (well trying to) and I will do some toee playtesting soon. It is amazing how much longer and more complex the c version is compared to a simple batch file, but it is also doing more.
I have never worked on any large projects with multiple source files etc before and I have had to learn how to deal with the added complexity. In general it is still possible to set breakpoints and single-step through the code, right? I can't get that to work though. I can't get VS2017 to 'start debugging' at all. It says "Unable to start program ..\repos\TemplePlus\Debug\Infrastructure.lib" and "..\repos\TemplePlus\Debug\Infrastructure.lib is not a valid Win32 application." I have a suspicion that if I did succeed in getting it to run the game might crash at a breakpoint anyway, but I was going to at least try. Is it not possible to do that sort of debugging with this project perhaps because a lot of the game code is actually compiled Troika code? There are some things I just can't test with an external test program.
...
Well I looked at those source and header files and that code is not 'self-documenting'. I could only make wild guesses about how to make a display. Maybe if there were comments, but that is not The Way of modern programming I guess. The modern way is 'It was hard to write. It should be hard to read.' Hehe.
Perhaps if you could give me a general outline of how I might do it. I really just need to display a single variable (a global pointer to uints) that represents the progress through the hotbits file as a number and a percentage. A battery meter style display would be good too if possible.
...
I decided that the hotbitsmon program could still be useful for crash protection. If the game crashes hotbitsmon can essentially run trimhotbits() itself so that the hotbits data status is kept updated. If I implement this then the only time the hotbits file won't stay updated is with a power loss. A game crash will be no problem. I thought I had to go back to storing the bits in a shared memory object, but then realized I could just use the hotbits file itself to reread the data if there was a crash. The important thing is that the index remains in hotbitsmon if the game crashes.
Anyway it's all looking good. My c/c++ downloading program (hotbitsfetch) is much more sophisticated than the simple batch file and seems to be working. It won't allow downloads until 24 hours (in seconds) has passed since the last download and will automatically append to previous downloads or to the main hotbits.bin file depending on whether or not templeplus.exe is currently running. It can be set to run from the windows task scheduler every 24 hours and just keep growing the size of the file every day. I am working on implementing the crash protection in hotbitsmon now.
Last edited: