From: Andrew C. <ac...@us...> - 2004-02-09 03:05:51
|
Update of /cvsroot/planeshift/planeshift/src/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18003/src/server Modified Files: usermanager.cpp usermanager.h Log Message: Fixed up some buddy details and added new buddy window for client. Index: usermanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/usermanager.cpp,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** usermanager.cpp 8 Feb 2004 00:42:01 -0000 1.92 --- usermanager.cpp 9 Feb 2004 03:02:42 -0000 1.93 *************** *** 143,151 **** else if (msg.command == "/buddylist") { ! BuddyList(msg,client,me->clientnum, UserManager::ALL_PLAYERS); } else if (msg.command == "/online") { ! BuddyList(msg,client,me->clientnum, true); } else if (msg.command == "/roll") --- 143,151 ---- else if (msg.command == "/buddylist") { ! BuddyList(client,me->clientnum, UserManager::ALL_PLAYERS); } else if (msg.command == "/online") { ! BuddyList(client,me->clientnum, true); } else if (msg.command == "/roll") *************** *** 288,292 **** } ! if (!database->AddBuddy(selfid,buddyid)) { --- 288,298 ---- } ! if ( !client->GetCharacterData()->AddBuddy( buddyid, msg.player ) ) ! { ! psserver->SendSystemError(clientnum,"%s could not be added to buddy list.\n",(const char *)msg.player); ! return; ! } ! ! if (!database->AddBuddy(selfid,buddyid)) { *************** *** 295,298 **** --- 301,306 ---- } + BuddyList( client, clientnum, true ); + psserver->SendSystemInfo(clientnum,"%s has been added to your buddy list.\n",(const char *)msg.player); } *************** *** 321,324 **** --- 329,334 ---- } + client->GetCharacterData()->RemoveBuddy( buddyid ); + if (!database->RemoveBuddy(selfid,buddyid)) { *************** *** 326,336 **** return; } psserver->SendSystemInfo(clientnum,"%s has been removed from your buddy list.\n",(const char *)msg.player); } ! void UserManager::BuddyList(psUserCmdMessage& msg,Client *client,int clientnum,bool filter) { - (void) msg; psCharacter *chardata=client->GetCharacterData(); if (chardata==NULL) --- 336,346 ---- return; } + BuddyList( client, clientnum, true ); psserver->SendSystemInfo(clientnum,"%s has been removed from your buddy list.\n",(const char *)msg.player); } ! void UserManager::BuddyList(Client *client,int clientnum,bool filter) { psCharacter *chardata=client->GetCharacterData(); if (chardata==NULL) *************** *** 339,388 **** return; } ! unsigned int selfid=chardata->GetCharacterID(); ! ! Result result(db->Select("select a.name" ! " from characters a," ! " buddy_list b" ! " where b.player_id=%d" ! " and b.player_buddy=a.id",selfid)); ! ! if (!result.IsValid()) ! { ! Error2("Error getting buddy list from db: %s.\n",db->GetLastError()); ! psserver->SendSystemError(clientnum,db->GetLastError()); ! return; ! } ! ! if (!filter) ! { ! psserver->SendSystemInfo(clientnum,"Your Buddy List"); ! } ! else ! { ! psserver->SendSystemInfo(clientnum,"Currently Online"); ! } ! psserver->SendSystemInfo(clientnum,"-------------------------------------", ! (const char *)client->GetName()); ! ! int count=0; ! for (unsigned int i=0; i<result.Count(); i++) ! { ! const char *who = result[i][0]; ! ! if (filter && !clients->Find(who)) // skip if doing online filter and not online ! continue; ! ! psserver->SendSystemInfo(clientnum,"%s",who); ! count++; ! } ! if (!count) ! { ! psserver->SendSystemInfo(clientnum,"(You have no buddies on your list right now.)" ); ! } ! else { ! psserver->SendSystemInfo(clientnum,"(End of list.)" ); } } --- 349,364 ---- return; } ! ! int totalBuddies = chardata->buddyList.Length(); ! ! psBuddyListMsg mesg( clientnum, totalBuddies ); ! for ( int i = 0; i < totalBuddies; i++ ) { ! mesg.AddBuddy( i, chardata->buddyList[i].name, clients->Find(chardata->buddyList[i].name) ); } + + mesg.Build(); + msghandler->SendMessage(mesg.msg); } *************** *** 390,411 **** void UserManager::NotifyBuddies(Client * client, bool logged_in) { ! Result result(db->Select("select a.id, a.name" ! " from characters a," ! " buddy_list b" ! " where b.player_buddy=%d" ! " and b.player_id=a.id",client->GetPlayerID() )); ! if (!result.IsValid() ) ! { ! CPrintf("SQL Error in UserManager::NotifyBuddies: %s\n",database->GetLastError()); ! return; ! } ! ! for (unsigned int i=0; i<result.Count(); i++) { ! Client *buddy = clients->FindPlayer( result[i].GetInt("id") ); // name of player buddy if (buddy) // is buddy online at the moment? if so let him know buddy just logged on { ! CPrintf("UserManager::NotifyBuddies: Notify player %s that buddy %s has logged %s\n",buddy->GetName(),client->GetName(),(logged_in?"in":"out")); if (logged_in) { --- 366,377 ---- void UserManager::NotifyBuddies(Client * client, bool logged_in) { ! for (unsigned int i=0; i< client->GetCharacterData()->buddyList.Length(); i++) { ! Client *buddy = clients->Find( client->GetCharacterData()->buddyList[i].name.GetData() ); // name of player buddy if (buddy) // is buddy online at the moment? if so let him know buddy just logged on { ! psBuddyStatus status( buddy->GetClientNum(), client->GetCharacterData()->buddyList[i].name, logged_in ); ! msghandler->SendMessage(status.msg); if (logged_in) { Index: usermanager.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/usermanager.h,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** usermanager.h 23 Dec 2003 18:44:46 -0000 1.25 --- usermanager.h 9 Feb 2004 03:02:42 -0000 1.26 *************** *** 128,137 **** * Sends a list of all the players that are currently on a player's buddy list. * - * @param msg The incomming user command message. * @param client The client that request the command.. * @param clientnum The client id number of the requesting client. * @param filter True if show only buddies online. Else show all buddies. */ ! void BuddyList(psUserCmdMessage& msg,Client *client,int clientnum,bool filter); enum { --- 128,136 ---- * Sends a list of all the players that are currently on a player's buddy list. * * @param client The client that request the command.. * @param clientnum The client id number of the requesting client. * @param filter True if show only buddies online. Else show all buddies. */ ! void BuddyList(Client *client,int clientnum,bool filter); enum { |