Using Adoxa's C++ programs
-
Hi,
I have downloaded a number of programs from Adoxa’s tools download page, and on FriendlyFire’s suggestion, started with tini.cpp as a way to parse the ini files efficiently (tini parses all freelancer’s ini files by using the game’s own exe/common.dll functions)
I cannot get it to work. I’m hoping someone did this in the past, and can give me some pointers where I’m going wrong?
If I run tini.exe that is in the download pack, it complains about missing “exe/common.dll”. If I run it in the root folder of freelancer, it works perfectly and outputs all the parsed ini files
( i.e. freelancer/tini.exe > allinis.txt )
So the conclusion is that it has no common.dll of its own, but uses the freelancer one.In tini.cpp the compiler directive at the start asks for the dll:
#include “common.h”
This include is present in most other Adoxa’s cpp programs.However in the source of tini.cpp there is no common.h
The file common.h can only be found in the package libfl that can also be downloaded. This suggests that this libfl package should be copied into the (Visual Studio C++ 2008 ) project so that it can be used. However if I do that, still a bunch of compile errors come up, suggesting there needs to be included more. But what?
In the same libfl package there is a makefile. It has this command:
tini.exe: tini.cpp fl.lib
$(CC) $(CPPFLAGS) $** setargv.objThis suggests that the package libfl (if it is the same as fl.lib) should not be included in the VS project, but instead the compile should be run externally from VS, somehow invoking the VS compiler, or maybe even a different compiler?
So could anybody tell me how to do it so that it works?
Thanks-Qi
-
it’s been a while since i played with that, but from what i remember the code to get/set the path for loading the .dll file doesn’t work right.
once i rewrote it in .net style and it did work.here is a basic checklist what could make LoadLibrary function fail:
1.1. “AppPath” found in “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Games\Freelancer\1.0” doesn’t exist.
1.2. “EXE” directory doesn’t exist inside “AppPath”.
1.3. “common.dll” file doesn’t exist inside “EXE” directory.
2. RegOpenKeyEx function fails.
3. SetExeDirectory function fails.here is the code snippet that worked for me:
using namespace Microsoft::Win32; using namespace System::IO; Common::Common(bool loadres) { String^ cwd = Directory::GetCurrentDirectory(); Object^ reg = Registry::GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft Games\\Freelancer\\1.0", "AppPath", nullptr); if (reg != nullptr) Directory::SetCurrentDirectory(String::Concat(reg->ToString(), "\\EXE")); ... Directory::SetCurrentDirectory(cwd); }
so you could either debug and fix the original code or use .net, which i recommend anyway.
hope it helped.