Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMatrix 4x4 lua table in ArgumentParser #3849

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

W3lac3
Copy link
Contributor

@W3lac3 W3lac3 commented Nov 9, 2024

This PR adds for ArgumentParser to accept a 4x4 lua table as a CMatrix.

Comment on lines +1115 to +1117
bool IsValidMatrixLuaTable(lua_State* luaVM, uint uiArgIndex)
{
uint uiRow = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::uint32_t instead of uint


if (lua_type(luaVM, uiArgIndex) == LUA_TTABLE)
{
for (lua_pushnil(luaVM); lua_next(luaVM, uiArgIndex) != 0; lua_pop(luaVM, 1), uiRow++)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is that weird for loop? you can initialize uiRow (btw dont use hungarian notation) in the loop directly if needed

@@ -584,6 +584,7 @@ class CScriptArgReader;
void MixedReadDxFontString(CScriptArgReader& argStream, eFontType& outFontType, eFontType defaultFontType, CClientDxFont*& poutDxFontElement);
void MixedReadGuiFontString(CScriptArgReader& argStream, SString& strFontName, const char* szDefaultFontName, CClientGuiFont*& poutGuiFontElement);
void MixedReadMaterialString(CScriptArgReader& argStream, CClientMaterial*& pMaterialElement);
bool IsValidMatrixLuaTable(lua_State* luaVM, uint uiArgIndex);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noexcept

Comment on lines +646 to +677
bool IsValidMatrixLuaTable(lua_State* luaVM, uint uiArgIndex)
{
uint uiRow = 0;
uint uiCell = 0;

if (lua_type(luaVM, uiArgIndex) == LUA_TTABLE)
{
for (lua_pushnil(luaVM); lua_next(luaVM, uiArgIndex) != 0; lua_pop(luaVM, 1), uiRow++)
{
if (lua_type(luaVM, -1) != LUA_TTABLE)
return false;

uint uiCol = 0;

for (lua_pushnil(luaVM); lua_next(luaVM, -2) != 0; lua_pop(luaVM, 1), uiCol++, uiCell++)
{
int iArgumentType = lua_type(luaVM, -1);
if (iArgumentType != LUA_TNUMBER && iArgumentType != LUA_TSTRING)
return false;
}

if (uiCol != 4)
return false;
}
}

if (uiRow != 4 || uiCell != 16)
return false;

return true;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

above

@@ -389,6 +389,7 @@ void MixedReadResourceString(CScriptArgReader& argStream, CResource*& pOutRes
bool StringToBool(const SString& strText);
void MinServerReqCheck(CScriptArgReader& argStream, const char* szVersionReq, const char* szReason);
void ReadPregFlags(CScriptArgReader& argStream, pcrecpp::RE_Options& pOptions);
bool IsValidMatrixLuaTable(lua_State* luaVM, uint uiArgIndex);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noexcept

@tracerjebanaciota
Copy link

weź tracer nie wkurwiaj ludzi i zamknij ten pysk dzięki

@TracerDS
Copy link
Contributor

weź tracer nie wkurwiaj ludzi i zamknij ten pysk dzięki

image
heh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants