Skip to content
This repository has been archived by the owner on Jun 16, 2019. It is now read-only.
/ m2sdk Public archive

Software Development Kit for the Steam version of Mafia2.

License

Notifications You must be signed in to change notification settings

mafia2online/m2sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

m2sdk

This is a repo, containing up-to-date results of game research information provided in form of C++ header-only library. By publishing this repo, we are hoping to find and attract more people that are interested in the Mafia 2 researching/modding/reversing, and possibly even contributing to make this thing even better.

This sdk support only steam version of the game.

Prjects using this library:

  • Mafia 2 Online

Installtion

$ git clone git@github.com:mafia2online/m2sdk.git
#define MAFIA_SDK_IMPLEMENTATION
#include <m2sdk/m2sdk.h>

And add lib/m2sdk.lib to your linker.

Usage

#include <stdio.h>
#include <m2sdk/m2sdk.h>

void pluginRegisterCallback() {
    printf("game pre init !\n");

    M2::AttachHandler(M2_EVENT_CAR_ENTER, [](m2sdk_event *data) {
        auto player = (M2::C_Player2 *)data->arg1;
        auto car    = (M2::C_Car *)data->arg2;
        auto seat   = (int)data->arg3;

        printf("[game-event] ped entering the car on seat: %d\n", seat);
    });
}

BOOL APIENTRY DllMain(HMODULE module, DWORD  reason, LPVOID lpReserved) {
    switch (reason) {
        case DLL_PROCESS_ATTACH: {
            M2::Initialize(pluginRegisterCallback);
        }

        break;
    }
};

Structure

Code devided into 3 different categories, by folders:

  • classes - partially reversed game classes
  • wrappers - lightweight wrappers around game classes to make things simplier to work w/
  • utils - that is obvious

Contributing

All contributions are highly welcomed! Feel free to suggest fixes, features, improvements. And, of course, pull requests, we love 'em! ;)

License

Project is licensed under Apache 2.0 license. You can check it out there.