Author Topic: back end mapper dll source code  (Read 3166 times)

Fire Plague

  • Guest
back end mapper dll source code
« on: September 10, 2019, 09:40:41 PM »
I went poking around git hub on the back end mapper and i noticed that the #include "OP2Editor.h" line appears in several pieces but dose not exist in the project. Is it depreciated?  ??? Out of the box the whole thing can't compile.

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1015
Re: back end mapper dll source code
« Reply #1 on: September 11, 2019, 07:44:48 AM »
Fire Plague,

When you open op2editor in Visual Studio again, look in the filter (virtual folder) 'source code'. You will find op2editor is included in the project. That is the 'main' file. op2editor.cpp contains the main function for the library, posted below. I compiled this using VS2017 I think about a year ago, so it can be done. It relies on COM to talk with the op2mapper frontend that was written in an older version of Visual Basic.

Code: [Select]
// DLL Entry Point
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
    if (dwReason == DLL_PROCESS_ATTACH)
    {
g_hInstance = hInstance;
        DisableThreadLibraryCalls(hInstance);
    }

    return TRUE;    // ok
}

If you want to compile, post the errors you are getting and I'll see if I can help.

However, we pulled many sections of code out of op2editor and incorporated them into OP2Utility. In the process we removed COM, started using C++11 or newer language features, and removed all dependencies on windows specific libraries. OP2utility can be used on Windows or Linux and compiled against x86 or x64. So I would recommend using OP2Utility for archive access, loading maps, unpacking sprites (this is partially implemented), etc. Not sure what you are trying to accomplish though.

op2editor has remained abandoned because no one in the community is taking the time to update the front-end (requiring experience in Visual Basic) or has a real skillset in COM. Although an update to the op2mapper would be a boon to the community at some point.

Hope that helps.
-Brett

Fire Plague

  • Guest
Re: back end mapper dll source code
« Reply #2 on: September 11, 2019, 08:01:01 AM »
Actually I was trying to self learn something by looking at the code of others when I noticed the include call to a file not on the list in github. My programming skills are about that of a baby and moving forward seems like a learning curve of a cliff. I had hoped to find some raw information on what structures are used. (like here is a class and here is the ints and chars or strings that make up a map or this is the guts of a .bmp file) I didn't get that far.

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2352
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: back end mapper dll source code
« Reply #3 on: September 16, 2019, 06:49:03 PM »
The back-end code for the mapper DLL is advanced C++ programming -- it would easily overwhelm a beginning developer.

TechCor developed a C# API for OP2 development that you may find easier to understand.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Re: back end mapper dll source code
« Reply #4 on: September 18, 2019, 04:11:40 AM »
I'd also recommend OP2Utility considering what you want to learn about. Both projects contain details about things like the map file structure. As Brett said, OP2Utility took a lot of the guts from OP2Editor and reworked it into modern C++. The OP2Utility project is actively maintained, regularly compiled on multiple platforms, and should just work.


Back when OP2Editor was still being developed, we were using MSVC 6.0 (released in 1996). I don't know how well it would compile with a modern compiler. Meanwhile, the frontend of the op2mapper used Visual Basic 6.0. Microsoft never released a free version of Visual Basic 6.0. Couple that with the break in source code compatibility between VB6 and VB.net (effectively VB7) means we don't really have an easily accessible compiler to do development work on the op2mapper frontend.

With that said, I do see an OP2Editor.h in the repository. It's just kind of hidden among all the other similarly named files, such as the various project, solution, and workspace files, for multiple versions of Visual Studio, and the IDL (Interface Definition Language) file. As for how Visual Studio displays the projects, it tends to sort files into source files (.cpp), and header files (.h), so they may appear in different virtual folders within Visual Studio.

The COM/IDL/language interop stuff used to interface the OP2Editor backend DLL (written in C++) with the op2mapper frontend EXE (written in Visual Basic) does use a few intermediate topics, such as interfaces. The COM documentation on interfaces was actually a wonderful read. Though the rest of the COM documentation, on things like COM registration, factories, reference counting, and marshalling for DCOM (distributed COM) was much less pleasant (and much less relevant to the project). Anyway, hopefully the use of COM and IDL is not too hard to read, even if the details of how it all works is not too clear.


You're welcome to poke around with OP2Editor if you want. You might have an easier time with OP2Utility though.