Skip to content

Commit a8de8c6

Browse files
committed
Move tocolor to shared definitions
1 parent 9ee294d commit a8de8c6

File tree

5 files changed

+34
-30
lines changed

5 files changed

+34
-30
lines changed

Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.Util.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,34 +73,6 @@ int CLuaFunctionDefs::GetTok(lua_State* luaVM)
7373
return 1;
7474
}
7575

76-
int CLuaFunctionDefs::tocolor(lua_State* luaVM)
77-
{
78-
// int tocolor ( int red, int green, int blue [, int alpha = 255] )
79-
int iRed;
80-
int iGreen;
81-
int iBlue;
82-
int iAlpha;
83-
84-
CScriptArgReader argStream(luaVM);
85-
argStream.ReadNumber(iRed);
86-
argStream.ReadNumber(iGreen);
87-
argStream.ReadNumber(iBlue);
88-
argStream.ReadNumber(iAlpha, 255);
89-
90-
if (!argStream.HasErrors())
91-
{
92-
// Make it into an unsigned long
93-
unsigned long ulColor = COLOR_RGBA(iRed, iGreen, iBlue, iAlpha);
94-
lua_pushinteger(luaVM, static_cast<lua_Integer>(ulColor));
95-
return 1;
96-
}
97-
98-
// Make it black so funcs dont break
99-
unsigned long ulColor = COLOR_RGBA(0, 0, 0, 255);
100-
lua_pushnumber(luaVM, static_cast<lua_Number>(ulColor));
101-
return 1;
102-
}
103-
10476
int CLuaFunctionDefs::GetValidPedModels(lua_State* luaVM)
10577
{
10678
int iIndex = 0;

Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ class CLuaFunctionDefs
7979
// Util functions to make scripting easier for the end user
8080
// Some of these are based on standard mIRC script funcs as a lot of people will be used to them
8181
LUA_DECLARE(GetTok);
82-
LUA_DECLARE(tocolor);
8382
LUA_DECLARE(GetValidPedModels);
8483
LUA_DECLARE(SetDevelopmentMode);
8584
LUA_DECLARE(GetDevelopmentMode);

Client/mods/deathmatch/logic/lua/CLuaManager.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ void CLuaManager::LoadCFunctions(void)
253253

254254
// Util functions
255255
CLuaCFunctions::AddFunction("gettok", CLuaFunctionDefs::GetTok);
256-
CLuaCFunctions::AddFunction("tocolor", CLuaFunctionDefs::tocolor);
257256
CLuaCFunctions::AddFunction("getValidPedModels", CLuaFunctionDefs::GetValidPedModels);
258257
CLuaCFunctions::AddFunction("downloadFile", CLuaFunctionDefs::DownloadFile);
259258

Shared/mods/deathmatch/logic/luadefs/CLuaUtilDefs.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ void CLuaUtilDefs::LoadFunctions(void)
4141

4242
// Debug functions
4343
CLuaCFunctions::AddFunction("debugSleep", DebugSleep);
44+
45+
// Utility functions
46+
CLuaCFunctions::AddFunction("tocolor", tocolor);
4447
}
4548

4649
int CLuaUtilDefs::DisabledFunction(lua_State* luaVM)
@@ -613,3 +616,31 @@ int CLuaUtilDefs::DebugSleep(lua_State* luaVM)
613616
lua_pushboolean(luaVM, false);
614617
return 1;
615618
}
619+
620+
int CLuaUtilDefs::tocolor(lua_State* luaVM)
621+
{
622+
// int tocolor ( int red, int green, int blue [, int alpha = 255 ] )
623+
int iRed;
624+
int iGreen;
625+
int iBlue;
626+
int iAlpha;
627+
628+
CScriptArgReader argStream(luaVM);
629+
argStream.ReadNumber(iRed);
630+
argStream.ReadNumber(iGreen);
631+
argStream.ReadNumber(iBlue);
632+
argStream.ReadNumber(iAlpha, 255);
633+
634+
if (!argStream.HasErrors())
635+
{
636+
// Make it into an unsigned long
637+
unsigned long ulColor = COLOR_RGBA(iRed, iGreen, iBlue, iAlpha);
638+
lua_pushinteger(luaVM, static_cast<lua_Integer>(ulColor));
639+
return 1;
640+
}
641+
642+
// Make it black so funcs dont break
643+
unsigned long ulColor = COLOR_RGBA(0, 0, 0, 255);
644+
lua_pushnumber(luaVM, static_cast<lua_Number>(ulColor));
645+
return 1;
646+
}

Shared/mods/deathmatch/logic/luadefs/CLuaUtilDefs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,7 @@ class CLuaUtilDefs : public CLuaDefs
4848

4949
// Debug functions
5050
LUA_DECLARE(DebugSleep);
51+
52+
// Utility functions
53+
LUA_DECLARE(tocolor);
5154
};

0 commit comments

Comments
 (0)