forum.webdiplomacy.net

webDip dev coordination forum / public access todo list
It is currently Mon Nov 20, 2017 12:00 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Nov 11, 2009 7:58 pm 
Offline

Joined: Wed Sep 09, 2009 2:37 pm
Posts: 156
in wD_Members, change newMessagesFrom to TEXT, then apply this patch. The rest of the newMessagesFrom code works with the TEXT value. I just had to put in a specific check for duplicates, and changed a check of 0 to a check of an empty string.

Code:
diff -r -u dipgoon/0.24-backup/lib/gamemessage.php dip/lib/gamemessage.php
--- dipgoon/0.24-backup/lib/gamemessage.php   2009-11-10 15:38:21.000000000 -0800
+++ dip/lib/gamemessage.php   2009-11-11 10:24:31.000000000 -0800
@@ -92,23 +102,31 @@
    private static function notify($toCountry, $fromCountry)
    {
       global $DB, $Game;
-      
+
+      $memToUpdate = array();
+
       if ( $toCountry == 'Global' )
       {
-         $DB->sql_put("UPDATE wD_Members
-                  SET newMessagesFrom = IF( CHAR_LENGTH(newMessagesFrom) = 0,
-                                    'Global',
-                                    CONCAT_WS(',',newMessagesFrom,'Global') )
-                  WHERE gameID = ".$Game->id." AND NOT country='".$fromCountry."'");
+         foreach ($Game->Members->ByCountry as $Member) {
+            $memToUpdate[] = $Member;
+            $fromCountry = 'Global';
+         }
       }
       else
       {
-         $DB->sql_put("UPDATE wD_Members
-                  SET newMessagesFrom = IF( CHAR_LENGTH(newMessagesFrom) = 0,
-                                    '".$fromCountry."',
-                                    CONCAT_WS(',',newMessagesFrom,'".$fromCountry."') )
-                  WHERE gameID = ".$Game->id." AND country='".$toCountry."'");
+         $memToUpdate[] = $Game->Members->ByCountry[$toCountry];
+      }
+      foreach ($memToUpdate as $Member) {
+         if (!in_array($fromCountry, $Member->newMessagesFrom)) {
+            // Moved this down here since there is no longer a mysql-based check for duplicates
+            $DB->sql_put("UPDATE wD_Members
+                     SET newMessagesFrom = IF( CHAR_LENGTH(newMessagesFrom) = 0,
+                                       '".$fromCountry."',
+                                       CONCAT_WS(',',newMessagesFrom,'".$fromCountry."') )
+                     WHERE gameID = ".$Game->id." AND country='".$Member->country."'");
+            $Member->newMessagesFrom[] = $fromCountry;
+         }
       }
    }
 }
-?>
\ No newline at end of file
+?>
diff -r -u dipgoon/0.24-backup/lib/html.php dip/lib/html.php
--- dipgoon/0.24-backup/lib/html.php   2009-11-10 15:38:21.000000000 -0800
+++ dip/lib/html.php   2009-11-11 08:13:36.000000000 -0800
@@ -169,7 +171,7 @@
          FROM wD_Members m
          INNER JOIN wD_Games g ON ( m.gameID = g.id )
          WHERE m.userID = ".$User->id." AND ( m.status='Playing' OR m.status='Left' )
-            AND ( m.finalized = 'No' OR m.movesReceived = 'No' OR NOT ( m.newMessagesFrom = 0 ) )");
+            AND ( m.finalized = 'No' OR m.movesReceived = 'No' OR NOT ( m.newMessagesFrom = '' ) )");
       
       $gameIDs = array();
       $notifyGames = array();


Please note that after this patch, you will need to remove the "wD_Members, newMessagesFrom" line from any variant enum install script.


Top
 Profile  
 
PostPosted: Tue Sep 21, 2010 3:02 am 
Offline
Site Admin

Joined: Sat Jun 28, 2008 6:24 am
Posts: 892
A neat workaround, but I think with the new variant system this is no longer needed (hopefully? sleepcap?), and also as a text field it'll be much less efficient unfortunately


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group