• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Custom Natives on 1.29.2

Status
Not open for further replies.
I updated my tool for 1.29.2 which allows you to add JASS natives.

Download Patch 1.29.2

This version only works on 1.29.2, there is an older version which works on 1.28.5 and 1.26 on the forums somewhere.

Example Configuration
Code:
ExtendGameView=1
JASSOperationLimit=3000000
DisableCheats=1
DisablePause=1
Executable=D:\Games\Warcraft III - 129\Warcraft III.exe


Example Plugin (C++)

C++:
#include "stdafx.h"
#include "jAPI.h"

#include <chrono>
#include <list>

using namespace std;

jAPI::pAddNative jAddNative;

list<std::chrono::time_point<std::chrono::steady_clock>> List;

int StopWatchValue(int swid, int output)
{
    auto swStart = std::next(List.begin(), swid);

    if (swStart != List.end())
    {
        auto swNow = chrono::high_resolution_clock::now();
        chrono::duration<double> fs = swNow - *swStart;

        return chrono::duration_cast<chrono::milliseconds>(fs).count();

        if (output == 1)
            return chrono::duration_cast<chrono::milliseconds>(fs).count();
        if (output == 2)
            return chrono::duration_cast<chrono::microseconds>(fs).count();

        return chrono::duration_cast<chrono::nanoseconds>(fs).count();
    }

    return 0; // invalid stopwatch
}

int StopWatchCreate()
{
    auto start = chrono::high_resolution_clock::now();
    auto it = List.insert(List.end(), start);

    int index = std::distance(List.begin(), it);

    return index;
}

int StopWatchMark(int swid) { return StopWatchValue(swid, 1); } // milliseconds
int StopWatchTicks(int swid) { return StopWatchValue(swid, 0); } // nanoseconds

void StopWatchDestroy(int swid)
{
    auto swStart = std::next(List.begin(), swid);
    if (swStart != List.end())
        List.erase(swStart);
}

extern "C" __declspec(dllexport) void InitjAPI()
{
    HMODULE hjApi = GetModuleHandle(L"W3Framework.dll");
    jAddNative = (jAPI::pAddNative)GetProcAddress(hjApi, "jAddNative");

    jAddNative(StopWatchCreate, "StopWatchCreate", "()I");
    jAddNative(StopWatchTicks, "StopWatchTicks", "(I)I");
    jAddNative(StopWatchTicks, "StopWatchMark", "(I)I");
    jAddNative(StopWatchDestroy, "StopWatchDestroy", "(I)V");
}
The system also supports C# (.NET) plugins in the managed folder.

The download includes a demo map with Stopwatch natives for benchmarking.
 

Attachments

  • War3Loader.zip
    267.2 KB · Views: 160
  • StopWatch Demo.w3x
    28.6 KB · Views: 220
Last edited:
Status
Not open for further replies.
Top