Skip to content

Commit 763c5d3

Browse files
committed
Functions "IsDevMode" and "IsUjAPI" were added. All external functions were moved in one section.
1 parent 50daa04 commit 763c5d3

File tree

5 files changed

+63
-46
lines changed

5 files changed

+63
-46
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# War3 Lua - 1.3.7 (<span style="color: #53377A">Blight</span>)
1+
# War3 Lua - 1.3.8 (<span style="color: #53377A">Blight</span>)
22

33
[![lua](https://img.shields.io/badge/lua-v5.4.4-blue)](https://www.lua.org)
44
![warcraft](https://img.shields.io/badge/warcraft-1.24e/1.26a/1.27a/1.27b/1.28f-darkgreen)

Resource.rc

0 Bytes
Binary file not shown.

Src/DllMain.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ bool StartUp();
1616
BOOL APIENTRY DllMain(HMODULE module, UINT reason, LPVOID reserved) {
1717
switch (reason) {
1818
case DLL_PROCESS_ATTACH:
19+
DisableThreadLibraryCalls(module);
20+
1921
if (!gameBase) {
2022
return FALSE;
2123
}

Src/LuaFunctions.cpp

+59-44
Original file line numberDiff line numberDiff line change
@@ -431,45 +431,6 @@ namespace LuaFunctions {
431431
return 1;
432432
}
433433

434-
int IdToString(lua_State* l) {
435-
if (lua_isinteger(l, 1)) {
436-
DWORD id = (DWORD)lua_tointeger(l, 1);
437-
std::reverse(&(((LPSTR)&id)[0]), &(((LPSTR)&id)[4]));
438-
lua_pushlstring(l, (LPSTR)&id, 4);
439-
}
440-
else {
441-
return luaL_typeerror(l, 1, "integer");
442-
}
443-
444-
445-
return 1;
446-
}
447-
448-
int StringToId(lua_State* l) {
449-
if (lua_isstring(l, 1)) {
450-
lua_pushinteger(l, Jass::ToID(lua_tostring(l, 1)));
451-
}
452-
else {
453-
return luaL_typeerror(l, 1, "string");
454-
}
455-
456-
return 1;
457-
}
458-
459-
int FourCC(lua_State* l) {
460-
if (lua_isinteger(l, 1)) {
461-
IdToString(l);
462-
}
463-
else if (lua_isstring(l, 1)) {
464-
StringToId(l);
465-
}
466-
else {
467-
return luaL_typeerror(l, 1, "string or integer");
468-
}
469-
470-
return 1;
471-
}
472-
473434
int lua_jassoplistgc(lua_State* l) {
474435
lua_getfield(l, 1, "oplist");
475436
delete (JassMachine::JASS_OPLIST*)lua_touserdata(l, -1);
@@ -527,11 +488,7 @@ namespace LuaFunctions {
527488

528489
for (auto& native : Jass::jassnatives) {
529490
lua_registerJassNative(l, native.first.data(), &native.second, lua_invokeNative);
530-
}
531-
532-
lua_register(l, "IdToString", IdToString);
533-
lua_register(l, "StringToId", StringToId);
534-
lua_register(l, "FourCC", FourCC);
491+
}
535492
}
536493

537494
int lua_getJassArrayElement(lua_State* l) {
@@ -720,6 +677,45 @@ namespace LuaFunctions {
720677

721678
//--------------------------------------------------------
722679

680+
int lua_IdToString(lua_State* l) {
681+
if (lua_isinteger(l, 1)) {
682+
DWORD id = (DWORD)lua_tointeger(l, 1);
683+
std::reverse(&(((LPSTR)&id)[0]), &(((LPSTR)&id)[4]));
684+
lua_pushlstring(l, (LPSTR)&id, 4);
685+
}
686+
else {
687+
return luaL_typeerror(l, 1, "integer");
688+
}
689+
690+
691+
return 1;
692+
}
693+
694+
int lua_StringToId(lua_State* l) {
695+
if (lua_isstring(l, 1)) {
696+
lua_pushinteger(l, Jass::ToID(lua_tostring(l, 1)));
697+
}
698+
else {
699+
return luaL_typeerror(l, 1, "string");
700+
}
701+
702+
return 1;
703+
}
704+
705+
int lua_FourCC(lua_State* l) {
706+
if (lua_isinteger(l, 1)) {
707+
lua_IdToString(l);
708+
}
709+
else if (lua_isstring(l, 1)) {
710+
lua_StringToId(l);
711+
}
712+
else {
713+
return luaL_typeerror(l, 1, "string or integer");
714+
}
715+
716+
return 1;
717+
}
718+
723719
int lua_GetMapFileName(lua_State* l) {
724720
if (lua_isboolean(l, 1)) {
725721
Storm::Archive map;
@@ -740,7 +736,26 @@ namespace LuaFunctions {
740736
return 1;
741737
}
742738

739+
int lua_IsDevMode(lua_State* l) {
740+
lua_pushboolean(l, developerMode);
741+
742+
return 1;
743+
}
744+
745+
int lua_IsUjAPI(lua_State* l) {
746+
lua_pushboolean(l, isUjAPI);
747+
748+
return 1;
749+
}
750+
743751
void lua_openExternalFunctions(lua_State* l) {
752+
lua_register(l, "IdToString", lua_IdToString);
753+
lua_register(l, "StringToId", lua_StringToId);
754+
lua_register(l, "FourCC", lua_FourCC);
755+
744756
lua_register(l, "GetMapFileName", lua_GetMapFileName);
757+
758+
lua_register(l, "IsDevMode", lua_IsDevMode);
759+
lua_register(l, "IsUjAPI", lua_IsUjAPI);
745760
}
746761
}

Src/pch.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#define WAR3_LUA_MAJOR "1"
2222
#define WAR3_LUA_MINOR "3"
23-
#define WAR3_LUA_RELEASE "7"
23+
#define WAR3_LUA_RELEASE "8"
2424
#define WAR3_LUA_VERSION_NAME WAR3_LUA_VERSION_COLOR "Blight" WAR3_LUA_VERSION_COLOR_RESET
2525

2626
#define WAR3_LUA_VERSION WAR3_LUA_MAJOR "." WAR3_LUA_MINOR "." WAR3_LUA_RELEASE

0 commit comments

Comments
 (0)