Code: Select all
listen $mafia_port script mafia_incoming pub
proc mafia_incoming {idx} {
global mafia_players
set dl [dcclist socket]
set myhost unknown
for {set i 0} {$i < [llength $dl]} {incr i} {
if {[lindex [lindex $dl $i] 0] == $idx} {set myhost [lindex [split [lindex [lindex $dl $i] 2] "@"] 1]}
}
set dl [dcclist script]
set clones 0
for {set i 0} {$i < [llength $dl]} {incr i} {
if {[lindex [lindex $dl $i] 0] != $idx} {
if {[string tolower [lindex [split [lindex [lindex $dl $i] 2] "@"] 1]] == [string tolower $myhost]} {set clones 1}
}
}
if {!$clones} {
control $idx mafia_line
} else {
killdcc $idx
}
}
Code: Select all
proc mafia_line {idx text} {
set me [mafia_getplayerbyidx $idx]
set mynick [mafia_geti $me 1]
(...)
if {$text == ""} {
mafia_killplayer [mafia_geti $me 1]
mafia_echo "common" "0,1*** $mynick has disconnected from Mafia."
mafia_killcon [mafia_geti $me 0]
}
(...)
}
proc mafia_killcon {idx} {
global mafia_players
set me [mafia_getplayerbyidx $idx]
if {$me != {}} {
set mafia_players [lreplace $mafia_players $me $me]
}
if {[valididx $idx]} {
killdcc $idx
}
}
.tcl mafia_line "SomePlayersNickname" ""
The player was successfully disconnected AND the remaining players received the message, $mynick has disconnected from Mafia. So the only occasion in which players can't receive the message is when mafia_line is triggered by a user's disconnection.
Now, the Eggdrop documentation emphasizes that the programmer should be careful not to send messages to the IDX of the user who has just disconnected. While I was careful not to do that, I was wondering if Eggdrop doesn't somehow block ALL calls to putidx/putdcc during disconnect calls to the message handling procedure in order to stop the user from making this mistake, thus accidentally blocking calls to putidx/putdcc with legitimate (not yet disconnected) IDXs in these circumstances.
Any ideas?
EDIT/PS: Note that putidx/putdcc do not work in the situation described, but they do not output any errors either, and they do not halt the evaluation of the procedure.