Commit 10dd818 1 parent 13a1598 commit 10dd818 Copy full SHA for 10dd818
File tree 1 file changed +14
-4
lines changed
1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,8 @@ class OTS_Player extends OTS_Row_DAO
108
108
POT ::SKILL_SHIELD => array ('value ' => 0 , 'tries ' => 0 ),
109
109
POT ::SKILL_FISH => array ('value ' => 0 , 'tries ' => 0 )
110
110
);
111
+
112
+ private static array $ playersOnline ;
111
113
/**
112
114
* Magic PHP5 method.
113
115
*
@@ -765,10 +767,18 @@ public function setDeleted($deleted)
765
767
766
768
public function isOnline ()
767
769
{
768
- if ($ this ->db ->hasTable ('players_online ' )) // tfs 1.0
769
- {
770
- $ query = $ this ->db ->query ('SELECT `player_id` FROM `players_online` WHERE `player_id` = ' . $ this ->data ['id ' ]);
771
- return $ query ->rowCount () > 0 ;
770
+ if ($ this ->db ->hasTable ('players_online ' )) {// tfs 1.0
771
+ if (!isset (self ::$ playersOnline )) {
772
+ self ::$ playersOnline = [];
773
+
774
+ $ query = $ this ->db ->query ('SELECT `player_id` FROM `players_online` ' );
775
+
776
+ foreach ($ query ->fetchAll (PDO ::FETCH_ASSOC ) as $ item ) {
777
+ self ::$ playersOnline [$ item ['player_id ' ]] = true ;
778
+ }
779
+ }
780
+
781
+ return isset (self ::$ playersOnline [$ this ->data ['id ' ]]);
772
782
}
773
783
774
784
if ( !isset ($ this ->data ['online ' ]) )
You can’t perform that action at this time.
0 commit comments