From 492790cbf05fae74ba1ccf42cfe2c37fa68f1d20 Mon Sep 17 00:00:00 2001 From: Flugente Date: Sat, 2 Jun 2018 00:56:15 +0000 Subject: [PATCH] Fix: lua function CheckMiscFlags1 checks the wrong flags git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8564 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Strategic/LuaInitNPCs.cpp | 63 +++++---------------------------------- 1 file changed, 8 insertions(+), 55 deletions(-) diff --git a/Strategic/LuaInitNPCs.cpp b/Strategic/LuaInitNPCs.cpp index 165166027..0a954c360 100644 --- a/Strategic/LuaInitNPCs.cpp +++ b/Strategic/LuaInitNPCs.cpp @@ -11175,67 +11175,20 @@ static int l_ubMiscFlags2Check (lua_State *L) //check character MiscFlags1 static int l_ubMiscFlags1Check (lua_State *L) { - UINT32 set = 0; - UINT8 Profile = 0; UINT8 n = lua_gettop(L); - UINT8 Flag = 0; - int i = 0; + if ( n >= 2 ) + { + UINT8 Profile = lua_tointeger( L, 1 ); + UINT8 set = lua_tointeger( L, 2 ); - for (i= 1; i<=n; i++ ) - { - if (i == 1 ) Profile = lua_tointeger(L,i); - if (i == 2 ) set = lua_tointeger(L,i); + if ( gMercProfiles[Profile].ubMiscFlags & set ) + lua_pushinteger( L, 1 ); + else + lua_pushinteger( L, 0 ); } - - if (set == 1) - { - if (gMercProfiles[Profile].ubMiscFlags2 & PROFILE_MISC_FLAG_RECRUITED) - Flag = 1; - } - else if (set == 2) - { - if (gMercProfiles[Profile].ubMiscFlags2 & PROFILE_MISC_FLAG_HAVESEENCREATURE) - Flag = 1; - } - else if (set == 4) - { - if (gMercProfiles[Profile].ubMiscFlags2 & PROFILE_MISC_FLAG_FORCENPCQUOTE) - Flag = 1; - } - else if (set == 8) - { - if (gMercProfiles[Profile].ubMiscFlags2 & PROFILE_MISC_FLAG_WOUNDEDBYPLAYER) - Flag = 1; - } - else if (set == 16) - { - if (gMercProfiles[Profile].ubMiscFlags2 & PROFILE_MISC_FLAG_TEMP_NPC_QUOTE_DATA_EXISTS) - Flag = 1; - } - else if (set == 32) - { - if (gMercProfiles[Profile].ubMiscFlags2 & PROFILE_MISC_FLAG_SAID_HOSTILE_QUOTE) - Flag = 1; - } - else if (set == 64 ) - { - if (gMercProfiles[Profile].ubMiscFlags2 & PROFILE_MISC_FLAG_EPCACTIVE) - Flag = 1; - } - else if (set == 128 ) - { - if (gMercProfiles[Profile].ubMiscFlags2 & PROFILE_MISC_FLAG_ALREADY_USED_ITEMS) - Flag = 1; - } - - //Flag = (gMercProfiles[Profile].ubMiscFlags & set); - - - lua_pushinteger(L, Flag); return 1; - } //set chracter MiscFlags1