- Joined
- Jun 23, 2007
- Messages
- 4,066
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
Example Plugin (C++)
The system also supports C# (.NET) plugins in the managed folder.
The download includes a demo map with Stopwatch natives for benchmarking.
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 download includes a demo map with Stopwatch natives for benchmarking.
Attachments
Last edited: