From: Ondrej H. <tan...@us...> - 2005-05-15 17:26:29
|
Update of /cvsroot/planeshift/planeshift/src/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25685/src/server Modified Files: adminmanager.cpp adminmanager.h Log Message: - Changed /teleport_to to /teleport, cleaned it up, made arguments natural. See data/help.xml. Index: adminmanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/adminmanager.cpp,v retrieving revision 1.153 retrieving revision 1.154 diff -C2 -d -r1.153 -r1.154 *** adminmanager.cpp 12 May 2005 16:56:04 -0000 1.153 --- adminmanager.cpp 15 May 2005 17:25:48 -0000 1.154 *************** *** 343,347 **** { Client *target; ! if (this->VerifyPlayerClient(me->clientnum,msg.player,target)) MutePlayer(me,msg,client,target); } --- 343,347 ---- { Client *target; ! if (target = FindPlayerClient(msg.player, me->clientnum)) MutePlayer(me,msg,client,target); } *************** *** 349,358 **** { Client *target; ! if (this->VerifyPlayerClient(me->clientnum,msg.player,target)) UnmutePlayer(me,msg,client,target); } ! else if (msg.command == "/teleport_to") { ! TeleportTo(me,msg,client); } else if (msg.command == "/slide_me") --- 349,358 ---- { Client *target; ! if (target = FindPlayerClient(msg.player, me->clientnum)) UnmutePlayer(me,msg,client,target); } ! else if (msg.command == "/teleport") { ! Teleport(me,msg,client); } else if (msg.command == "/slide_me") *************** *** 363,367 **** { Client *target; ! if (this->VerifyPlayerClient(me->clientnum,msg.player,target)) SlideTarget(me,msg,client,target); } --- 363,367 ---- { Client *target; ! if (target = FindPlayerClient(msg.player,me->clientnum)) SlideTarget(me,msg,client,target); } *************** *** 373,377 **** { Client *target; ! if (this->VerifyPlayerClient(me->clientnum,msg.player,target)) KickPlayer(me,msg,client,target); } --- 373,377 ---- { Client *target; ! if (target = FindPlayerClient(msg.player, me->clientnum)) KickPlayer(me,msg,client,target); } *************** *** 605,638 **** } ! void AdminManager::TeleportTo(MsgEntry* me, psAdminCmdMessage& msg,Client *client) { ! if(msg.target == "map") ! TeleportToMap(client, msg); ! else if(msg.target == "here") ! { ! Client *player; ! if (this->VerifyPlayerClient(me->clientnum,msg.player,player)) ! TeleportToPlayer(client, msg.player,false,player); ! } ! else ! { ! Client *player; ! if (this->VerifyPlayerClient(me->clientnum,msg.player,player)) ! TeleportToPlayer(client, msg.player,true,player); ! } } ! void AdminManager::TeleportToMap(Client * client, psAdminCmdMessage& msg) { - if(!msg.map.GetData()) - return; - - iCameraPosition *loc; - iRegionList * regions; - iEngine * engine; - iRegion * region; - iSector * sector; - csVector3 pos; - if ( client->GetSecurityLevel() < GM_LEVEL_1 ) { --- 605,621 ---- } ! bool SamePos(gemActor * actor, iSector * sector, const csVector3 & point) { ! float yRot; ! iSector * currSector; ! csVector3 currPoint; ! ! actor->GetPosition(currPoint, yRot, currSector); ! ! return (currPoint == point) && (currSector == sector); } ! void AdminManager::Teleport(MsgEntry* me, psAdminCmdMessage& msg, Client *client) { if ( client->GetSecurityLevel() < GM_LEVEL_1 ) { *************** *** 641,764 **** } ! engine = psserver->GetEntityManager()->GetEngine(); ! regions = engine->GetRegions(); ! assert(regions); ! region = regions->FindByName(msg.map.GetData()); ! if (region == NULL) { ! psserver->SendSystemError(client->GetClientNum(), "Map not found."); return; } ! ! if(!msg.useCords) { ! loc = region->FindCameraPosition("Camera01"); ! if (loc == NULL) ! { ! psserver->SendSystemError(client->GetClientNum(), "Starting location not found in map."); ! return; ! } ! ! sector = engine->FindSector(loc->GetSector()); ! pos = loc->GetPosition(); } ! else { ! pos.x = msg.x; ! pos.y = msg.y; ! pos.z = msg.z; ! ! sector = engine->FindSector(msg.sector); ! if(!sector) ! { ! psserver->SendSystemError(client->GetClientNum(), "Cannot find sector " + msg.sector); ! return; ! } ! } ! if (sector) { ! Client* target = NULL; ! if(msg.player.Length() > 0) { ! target = clients->Find(msg.player); ! if(!target) { ! psserver->SendSystemError(client->GetClientNum(), "Cannot find player " + msg.player); ! return; } } else - target = client; - - target->GetActor()->pcmove->SetVelocity(csVector3(0.0f,0.0f,0.0f)); - target->GetActor()->SetPosition(pos, 0, sector); - target->GetActor()->UpdateProxList(true); - target->GetActor()->MulticastDRUpdate(); - - if(target == client) - psserver->SendSystemInfo(client->GetClientNum(), - "Welcome to " + msg.map + ", sector " + csString(sector->QueryObject()->GetName())); - else { ! psserver->SendSystemInfo(client->GetClientNum(),"Teleported player " + (csString)target->GetName() + " to " + msg.map); ! psserver->SendSystemInfo(target->GetClientNum(),"You were moved by a GM"); } } ! else ! psserver->SendSystemError(client->GetClientNum(), "Cannot find sector. Please contact Planeshift support."); ! } ! ! void AdminManager::TeleportToPlayer(Client * client, csString playerName,bool gm,Client *target) ! { ! // Check to see if this client has admin level ! if ( client->GetSecurityLevel() < GM_LEVEL_1 ) ! { ! psserver->SendSystemError(client->GetClientNum(), "Must be GM to use this feature."); ! return; ! } ! ! csVector3 pos; ! iSector* sector = 0; ! float yrot; ! ! Client* effected; ! ! if(gm) { ! target->GetActor()->GetPosition(pos, yrot, sector); ! effected = client; } else { ! client->GetActor()->GetPosition(pos, yrot, sector); ! effected = target; } ! if (sector) ! { ! effected->GetActor()->pcmove->SetVelocity(csVector3(0.0f,0.0f,0.0f)); ! ! effected->GetActor()->SetPosition(pos,yrot, sector); ! if(gm) ! psserver->SendSystemInfo(client->GetClientNum(),"Teleported to player."); ! else ! psserver->SendSystemInfo(client->GetClientNum(),"Teleported player to you."); ! effected->GetActor()->UpdateProxList(true); // true=force update ! effected->GetActor()->MulticastDRUpdate(); } ! else { ! psserver->SendSystemError(client->GetClientNum(), ! "Cannot teleport to petitioner. Please contact Planeshift support."); } ! psGUITargetUpdateMessage updateMessage( client->GetClientNum(), target->GetActor()->GetEntity()->GetID() ); ! updateMessage.SendMessage(); } --- 624,760 ---- } ! /*Result result(db->Select("SELECT id,name,lastname from characters where account_id=%u order by id",accountid)); ! if (!result.IsValid()) ! return false; ! ! charlist->SetValidCount( result.Count() ); ! for (unsigned int i=0;i<result.Count();i++) { ! charlist->SetEntryValid(i,true); ! charlist->SetCharacterID(i,result[i].GetInt("id")); ! charlist->SetCharacterFullName(i,result[i]["name"],result[i]["lastname"]); ! }*/ ! // ---------- determine who we are teleporting and where ! ! Client * subject; ! if (msg.player == "me") ! subject = client; ! else ! { ! subject = FindPlayerClient(msg.player, me->clientnum); ! if (subject == NULL) ! return; ! } ! ! iSector * targetSector; ! csVector3 targetPoint; ! if (!GetTargetOfTeleport(client, msg, targetSector, targetPoint)) ! return; ! ! //Error6("tele %s to %s %f %f %f",subject->GetName(), targetSector->QueryObject()->GetName(), targetPoint.x, targetPoint.y, targetPoint.z); ! ! if (SamePos(subject->GetActor(), targetSector, targetPoint)) ! { ! psserver->SendSystemError(client->GetClientNum(), "What's the point ?"); return; } ! ! // ---------- do the teleport ! subject->GetActor()->pcmove->SetVelocity(csVector3(0.0f,0.0f,0.0f)); ! subject->GetActor()->SetPosition(targetPoint, 0, targetSector); ! subject->GetActor()->UpdateProxList(true); ! subject->GetActor()->MulticastDRUpdate(); ! ! // ---------- send explanations ! ! if (msg.target == "map") { ! psserver->SendSystemInfo(subject->GetClientNum(), "Welcome to " + msg.map + ", sector " + csString(targetSector->QueryObject()->GetName())); } ! ! if (subject != client) { ! psserver->SendSystemInfo(client->GetClientNum(), "Teleported player " + (csString)subject->GetName() + " to " + msg.target); ! ! psserver->SendSystemInfo(subject->GetClientNum(), "You were moved by a GM"); } + + if (msg.player == "me" && msg.target != "map" && msg.target != "here") + { + psGUITargetUpdateMessage updateMessage( client->GetClientNum(), subject->GetActor()->GetEntity()->GetID() ); + updateMessage.SendMessage(); + } + } ! bool AdminManager::GetTargetOfTeleport(Client * client, psAdminCmdMessage& msg, iSector * & targetSector, csVector3 & targetPoint) ! { ! // when teleporting to a map ! if (msg.target == "map") { ! if (msg.useCoords) { ! targetSector = psserver->GetEntityManager()->GetEngine()->FindSector(msg.sector); ! if (!targetSector) { ! psserver->SendSystemError(client->GetClientNum(), "Cannot find sector " + msg.sector); ! return false; } + targetPoint = csVector3(msg.x, msg.y, msg.z); } else { ! if (!GetStartOfMap(client, msg.map, targetSector, targetPoint)) ! return false; } } ! // when teleporting to the place where we are standing at ! else if (msg.target == "here") { ! float yRot; ! client->GetActor()->GetPosition(targetPoint, yRot, targetSector); } + // when teleporting to a player else { ! Client * player = FindPlayerClient(msg.target, client->GetClientNum()); ! if (!player) ! return false; ! float yRot; ! player->GetActor()->GetPosition(targetPoint, yRot, targetSector); } + return true; + } ! bool AdminManager::GetStartOfMap(Client * client, const csString & map, iSector * & targetSector, csVector3 & targetPoint) ! { ! iCameraPosition *loc; ! iRegionList * regions; ! iEngine * engine; ! iRegion * region; ! ! engine = psserver->GetEntityManager()->GetEngine(); ! regions = engine->GetRegions(); ! assert(regions); ! region = regions->FindByName(map.GetData()); ! if (region == NULL) ! { ! psserver->SendSystemError(client->GetClientNum(), "Map not found."); ! return false; } ! ! loc = region->FindCameraPosition("Camera01"); ! if (loc == NULL) { ! psserver->SendSystemError(client->GetClientNum(), "Starting location not found in map."); ! return false; } ! targetSector = engine->FindSector(loc->GetSector()); ! targetPoint = loc->GetPosition(); ! return true; } *************** *** 1210,1214 **** commandList.Append("<command name='/thaw' />"); case GM_LEVEL_1: ! commandList.Append( "<command name='/teleport_to' />" ); commandList.Append( "<command name='/slide' />" ); commandList.Append( "<command name='/slide_me' />" ); --- 1206,1210 ---- commandList.Append("<command name='/thaw' />"); case GM_LEVEL_1: ! commandList.Append( "<command name='/teleport' />" ); commandList.Append( "<command name='/slide' />" ); commandList.Append( "<command name='/slide_me' />" ); Index: adminmanager.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/adminmanager.h,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** adminmanager.h 12 May 2005 16:56:05 -0000 1.52 --- adminmanager.h 15 May 2005 17:25:49 -0000 1.53 *************** *** 71,77 **** void ModifyKey(MsgEntry *me, psAdminCmdMessage& msg, Client *client); void CreateHuntLocation(MsgEntry* me,psAdminCmdMessage& msg, Client *client); ! void TeleportTo(MsgEntry* me,psAdminCmdMessage& msg, Client *client); ! void TeleportToPlayer(Client * client,csString playerName,bool gm,Client *player); ! void TeleportToMap(Client * client,psAdminCmdMessage& msg); void SlideSelf(MsgEntry* me,psAdminCmdMessage& msg, Client *client); void SlideTarget(MsgEntry* me,psAdminCmdMessage& msg, Client *client,Client *target); --- 71,83 ---- void ModifyKey(MsgEntry *me, psAdminCmdMessage& msg, Client *client); void CreateHuntLocation(MsgEntry* me,psAdminCmdMessage& msg, Client *client); ! void Teleport(MsgEntry* me,psAdminCmdMessage& msg, Client *client); ! ! /** Get sector and coordinates of target of teleportation described by 'msg'. ! Return success */ ! bool GetTargetOfTeleport(Client * client, psAdminCmdMessage& msg, iSector * & targetSector, csVector3 & targetPoint); ! ! /** Get sector and coordinates of starting point of a map. Returns success. */ ! bool GetStartOfMap(Client * client, const csString & map, iSector * & targetSector, csVector3 & targetPoint); ! void SlideSelf(MsgEntry* me,psAdminCmdMessage& msg, Client *client); void SlideTarget(MsgEntry* me,psAdminCmdMessage& msg, Client *client,Client *target); |