• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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: 156
  • StopWatch Demo.w3x
    28.6 KB · Views: 207
Last edited:
Status
Not open for further replies.
Top