From 47732f92db307bfc766fc8fd06edfb236f41ae90 Mon Sep 17 00:00:00 2001 From: Atemo Date: Mon, 8 Jun 2020 23:51:07 +0200 Subject: [PATCH] Corrected WOE Controller Reward * Fixed an issue when several characters with the same ip are in the same guild and ip check is enabled, the character offline could receive the reward instead of the character online Fixed #4833 Thanks to @mazvi ! --- npc/custom/woe_controller.txt | 41 ++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/npc/custom/woe_controller.txt b/npc/custom/woe_controller.txt index acfb75979e..fdf877e922 100644 --- a/npc/custom/woe_controller.txt +++ b/npc/custom/woe_controller.txt @@ -283,13 +283,36 @@ OnReward: .@cid[0] = .@master_cid; .@aid[0] = .@master_aid; } - - for(set .@j,0; .@j<.@size_guild; set .@j,.@j+1) { - if ((.Options&8) && !(.Options&4)) { - set .@ip$, replacestr(getcharip(.@aid[.@j]),".","a"); - if (getd(".@ip_"+.@i+"_"+.@ip$)) continue; - setd ".@ip_"+.@i+"_"+.@ip$,1; + else if (.Options&8) { + for ( .@j = 0; .@j < .@size_guild; ++.@j ) { + .@is_online[.@j] = isloggedin( .@aid[.@j], .@cid[.@j] ); + if (.@is_online[.@j]) + .@ip$ = replacestr(getcharip(.@aid[.@j]),".","a"); + else { + if (query_sql("SELECT `last_ip` FROM `login` WHERE `account_id` = '" + .@aid[.@j] + "'", .@last_ip$) < 1) + continue; + .@ip$ = replacestr(.@last_ip$, ".", "a"); + } + .@variable$ = ".@ip_" + .@i + "_" + .@ip$; + .@index = getd(.@variable$) - 1; + + if (.@index >= 0) { + if (.@is_online[.@j]) { + .@tmp_account_id[.@index] = .@aid[.@j]; + .@tmp_char_id[.@index] = .@cid[.@j]; + } + continue; + } + setd .@variable$, .@j+1; + .@tmp_account_id[.@k] = .@aid[.@j]; + .@tmp_char_id[.@k] = .@cid[.@j]; + .@k++; } + copyarray .@aid[0], .@tmp_account_id[0], .@k; + copyarray .@cid[0], .@tmp_char_id[0], .@k; + .@size_guild = .@k; + } + for(set .@j,0; .@j<.@size_guild; set .@j,.@j+1) { if (.Options&2) { .@charid = .@cid[.@j]; .@sender$ = "no-reply"; @@ -318,7 +341,6 @@ OnReward: } Zeny += .reward_zeny; dispbottom "You have been rewarded for conquering " + .@castle_name$ + "."; - detachrid; } } } @@ -326,15 +348,14 @@ OnReward: return; OnPCLoadMapEvent: - .@compare_val = compare(strcharinfo(3),"g_cas"); - if (!.@compare_val) end; + if (!compare(strcharinfo(3),"g_cas")) end; if (((.AutoKick && .Active[0]) || (.NoOwner && !getcastledata(strcharinfo(3),1))) && !(.Active[0]&(1<