Переглянути джерело

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 !
Atemo 5 роки тому
батько
коміт
47732f92db
1 змінених файлів з 31 додано та 10 видалено
  1. 31 10
      npc/custom/woe_controller.txt

+ 31 - 10
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<<getd("."+strcharinfo(3))))) {
 		if (getcharid(2) && getcastledata(strcharinfo(3),1) == getcharid(2)) end;
 		.@castle_name$ = getcastlename(strcharinfo(3));
 		sleep2 1000;
 		message strcharinfo(0), .@castle_name$ + " is currently inactive.";
 		sleep2 5000;
-		if (.@compare_val) warp "SavePoint",0,0;
+		if (compare(strcharinfo(3),"g_cas")) warp "SavePoint",0,0;
 	}
 	end;