From: Anders R. <ma...@us...> - 2003-03-15 20:10:11
|
Update of /cvsroot/planeshift/planeshift/src/server In directory sc8-pr-cvs1:/tmp/cvs-serv9915/src/server Modified Files: psdatabase.cpp psdatabase.h usermanager.cpp Log Message: - Give usefull error message when you add a person already on buddy list to your list. Index: psdatabase.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/psdatabase.cpp,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -d -r1.102 -r1.103 *** psdatabase.cpp 14 Mar 2003 00:43:48 -0000 1.102 --- psdatabase.cpp 15 Mar 2003 20:09:57 -0000 1.103 *************** *** 731,734 **** --- 731,755 ---- } + bool psDatabase::IsBuddy(int self,int buddy) + { + Result result(mysql->Select("SELECT player_id" + " from buddy_list" + " where player_buddy=%d " + " and player_id=%d",buddy,self)); + if (!result.IsValid()) + { + lasterror = GetLastSQLError(); + return false; + } + + if (result.Count() < 1) + { + lasterror = "No buddy found"; + return false; + } + + return true; + } + bool psDatabase::AddBuddy(int self,int buddy) { *************** *** 738,743 **** if (rows != 1) { ! lasterror.Format ("Got sql error in AddBuddy on query " ! "<%s>.\n",mysql->GetLastQuery() ); return false; } --- 759,763 ---- if (rows != 1) { ! lasterror = GetLastSQLError(); return false; } Index: psdatabase.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/psdatabase.h,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** psdatabase.h 14 Mar 2003 00:43:48 -0000 1.58 --- psdatabase.h 15 Mar 2003 20:09:58 -0000 1.59 *************** *** 216,219 **** --- 216,224 ---- /** + * Check if buddy is on your buddy list. + */ + bool IsBuddy(int self,int buddy); + + /** * Adds a buddy to this players list of buddies. Takes the * player ID of us and the player ID of the buddy. Index: usermanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/usermanager.cpp,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** usermanager.cpp 1 Mar 2003 02:26:55 -0000 1.45 --- usermanager.cpp 15 Mar 2003 20:09:58 -0000 1.46 *************** *** 196,199 **** --- 196,205 ---- int self = database->GetPlayerID(client->GetName() ); + if (database->IsBuddy(self,player)){ + psSystemMessage newmsg(clientnum,MSG_ERROR,"Player %s already on your buddy list.\n",(const char *)msg.player); + msghandler->SendMessage(newmsg.msg); + return; + } + if (!database->AddBuddy(self,player)) { |