From: Thomas T. <to...@us...> - 2003-12-29 20:32:36
|
Update of /cvsroot/planeshift/planeshift/src/server In directory sc8-pr-cvs1:/tmp/cvs-serv4372 Modified Files: usermanager.cpp Log Message: Moved some of the trade use logic out of usermanager and into the workmanager module. Index: usermanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/usermanager.cpp,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** usermanager.cpp 23 Dec 2003 18:44:46 -0000 1.87 --- usermanager.cpp 29 Dec 2003 20:32:25 -0000 1.88 *************** *** 1014,1082 **** void UserManager::HandleUse(Client *client, bool on) { ! //Check if we are turning on ! gemObject *target = client->GetTargetObject(); if( on ) { ! // Check if anything is targeted ! if (!target) ! { ! psSystemMessage msg(client->GetClientNum(),MSG_INFO, ! "No item targeted for use!"); ! msghandler->SendMessage(msg.msg); ! return; ! } ! ! // Make sure it's not character ! if (target->IsActor()) ! { ! psSystemMessage msg(client->GetClientNum(),MSG_INFO, ! "Only items can be targeted for use!"); ! msghandler->SendMessage(msg.msg); ! return; ! } ! ! // Check use range ! if (client->GetActor()->RangeTo(target) > RANGE_TO_USE) ! { ! psSystemMessage msg(client->GetClientNum(),MSG_INFO, ! "You are not in range to use %s.",target->GetItem()->GetName()); ! msghandler->SendMessage(msg.msg); ! return; ! } ! ! // Check if you can do work on item. ! char info[128] = ""; ! gemActor * user = client->GetActor(); ! psItem* item = target->GetItem(); ! psWorkManager* wm = psserver->GetWorkManager(); ! if (wm->ValidateWork(user, item, info)) ! { ! // send info about the trade work. ! psSystemMessage msg(client->GetClientNum(),MSG_INFO, info); ! msghandler->SendMessage(msg.msg); ! } ! else ! { ! // otherwise send no use message to client. ! psSystemMessage msg(client->GetClientNum(),MSG_INFO, ! "You find no use for %s.",target->GetItem()->GetName()); ! msghandler->SendMessage(msg.msg); ! } } else { ! // Stop work on item. ! char resp[128] = ""; ! gemActor* user = client->GetActor(); ! psItem* item = target->GetItem(); ! psWorkManager* wm = psserver->GetWorkManager(); ! wm->StopWork(user, item, resp); ! ! // send message about the trade work if any ! if( strcmp( resp,"" ) != 0 ) ! { ! psSystemMessage msg(client->GetClientNum(),MSG_INFO, resp); ! msghandler->SendMessage(msg.msg); ! } } } --- 1014,1027 ---- void UserManager::HandleUse(Client *client, bool on) { ! //Check if we are starting or stopping use if( on ) { ! // Check to see if we can use it ! psserver->GetWorkManager()->ValidateUseWork(client); } else { ! // Stop work on item ! psserver->GetWorkManager()->StopUseWork(client); } } |