// Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . #include "stdpch.h" // Nel Misc #include "nel/misc/command.h" #include "nel/misc/file.h" #include "nel/misc/i_xml.h" #include "nel/misc/path.h" #include "gpm_service.h" #include "world_position_manager.h" using namespace NLMISC; using namespace NLNET; using namespace std; /* * Commands for GPMS initialisation */ // Enable/disable player speed checking NLMISC_COMMAND(setPlayerSpeedCheck, "set player speed check (0=disable)", "entityId <0/1>") { if (args.size() < 2) return false; CEntityId id; id.fromString(args[0].c_str()); bool enable; NLMISC::fromString(args[1], enable); CWorldEntity *entity = CWorldPositionManager::getEntityPtr( CWorldPositionManager::getEntityIndex(id) ); if (entity == NULL || entity->PlayerInfos == NULL) { log.displayNL("CGPMPlayerPrivilegeInst::callback(): entity '%d' is not a player", id.toString().c_str()); return false; } // enable/disable speed checking entity->PlayerInfos->CheckSpeed = enable; return true; } // Command to load a continent NLMISC_COMMAND(loadContinent, "load a continent in the gpms","index name filename") { if (args.size() < 3) return false; uint8 continent; NLMISC::fromString(args[0], continent); string name = args[1]; string file = args[2]; CWorldPositionManager::loadContinent(name, file, continent); return true; } // Command to remove a continent NLMISC_COMMAND(removeContinent, "remove a continent from the gpms","index") { if (args.size() < 1) return false; uint8 continent; NLMISC::fromString(args[0], continent); CWorldPositionManager::removeContinent(continent); return true; } // Command to init trigger manager NLMISC_COMMAND(initPatatManager, "init/reset patat&pacs trigger manager", "") { CWorldPositionManager::initPatatManager(); return true; } // Command to load patat NLMISC_COMMAND(loadPatatFile, "load a patat file in patat manager (.prim file)", "filename") { if (args.size() != 1) return false; CWorldPositionManager::loadPatatsInFile(args[0]); return true; } // Command to load patat NLMISC_COMMAND(loadPatatPath, "load a patat path in patat manager (all .prim files in path)", "pathname") { if (args.size() != 1) return false; CWorldPositionManager::loadPatatsInPath(args[0]); return true; } // Command to load patat NLMISC_COMMAND(loadPatatManagerFile, "load a patat manager file", "filename") { if (args.size() != 1) return false; CWorldPositionManager::loadPatatManagerFile(args[0]); return true; } // Command to load patat NLMISC_COMMAND(savePatatManagerFile, "save a patat manager file", "filename") { if (args.size() != 1) return false; CWorldPositionManager::savePatatManagerFile(args[0]); return true; } // Add CPrimZone class filter NLMISC_COMMAND(addPrimZoneFilter, "add one or more positive filters on CPrimZone for PatatSubscribeManager", " ...") { if (args.size() < 1) return false; uint i; for (i=0; i ...") { if (args.size() < 1) return false; uint i; for (i=0; i= 1) { uint16 serviceId; NLMISC::fromString(args[0], serviceId); // get the values NLNET::TServiceId ServiceId(serviceId); //CWorldPositionManager::removeAiVisionEntitiesForService( ServiceId ); } else { CWorldPositionManager::removeAllEntities(); } return true; } /* * Commands for position management */ // Command to move an entity in the GPMS NLMISC_COMMAND(moveEntity,"move an entity in the GPMS","entity Id, newPos X (meters), newPos Y, newPos Z") { /* // check args, if there s not the right number of parameter, return bad if(args.size() != 4) return false; // get the values uint32 Id; NLMISC::fromString(args[0], Id); uint32 PosX; NLMISC::fromString(args[1], PosX); uint32 PosY; NLMISC::fromString(args[2], PosY); sint32 PosZ; NLMISC::fromString(args[3], PosZ); // Init Entity CEntityId id; id.fromString(args[0].c_str()); // display the result on the displayer log.displayNL("move entity Id %d from GPMS", Id); CWorldPositionManager::setEntityPosition(id,1000*PosX, 1000*PosY, 1000*PosZ, 0.0f, CTickEventHandler::getGameCycle() ); */ return true; } // Command to move an entity in the GPMS NLMISC_COMMAND(teleportEntity,"teleport an entity", "entity Id, newPos X (meters), newPos Y, newPos Z, cell") { // check args, if there s not the right number of parameter, return bad if(args.size() != 5) return false; // Init Entity CEntityId id; id.fromString(args[0].c_str()); // get the values uint32 PosX; NLMISC::fromString(args[1], PosX); uint32 PosY; NLMISC::fromString(args[2], PosY); sint32 PosZ; NLMISC::fromString(args[3], PosZ); sint32 Cell; NLMISC::fromString(args[4], Cell); // display the result on the displayer log.displayNL("teleport entity %s", id.toString().c_str()); TDataSetRow index = CWorldPositionManager::getEntityIndex(id); CWorldPositionManager::teleport(index, 1000*PosX, 1000*PosY, 1000*PosZ, 0.0f, INVALID_CONTINENT_INDEX, Cell, CTickEventHandler::getGameCycle()); return true; } // Command to move an entity in the GPMS NLMISC_COMMAND(setEntityContent,"set an entity content", "CEntityId entityId, [CEntityId containeeId, CSheetId(int) containeeSheet]+") { // check args, if there s not the right number of parameter, return bad if (args.size() < 1) return false; if ((args.size() & 1) == 0) return false; // Init Entity CEntityId id; id.fromString(args[0].c_str()); // get the values vector content; uint arg = 1; while (arg < args.size()) { CEntityId id; id.fromString(args[arg].c_str()); uint32 sheetId; NLMISC::fromString(args[arg+1], sheetId); CSheetId sheet(sheetId); content.push_back(CEntitySheetId(id, sheet)); } CWorldPositionManager::setContent(CWorldPositionManager::getEntityIndex(id), content); return true; } // Command to display all vision or the vision for the specified entity NLMISC_COMMAND(mirrorAroundEntity,"Ask a local mirror arround an entity","service Id, entity Id") { // check args, if there s not the right number of parameter, return bad if(args.size() != 2) { return false; } // get the values uint16 serviceId; NLMISC::fromString(args[0], serviceId); NLNET::TServiceId ServiceId(serviceId); uint32 Id; NLMISC::fromString(args[1], Id); list< string > properties; properties.push_back( "X" ); properties.push_back( "Y" ); properties.push_back( "Z" ); properties.push_back( "Theta" ); properties.push_back( "Sheet" ); // Init Entity CEntityId id; id.fromString(args[0].c_str()); CWorldPositionManager::requestForEntityAround( ServiceId, id, properties ); return true; } // Command to display a single entity or more, with full debug info NLMISC_COMMAND(displayEntity,"display single or more entities in the gpms","[CEntityId]*") { if (args.size() == 0) { CWorldPositionManager::displayAllEntitiesFullDebug(&log); } else { uint i; for (i=0; iTracked.push_back(eid); pCGPMS->EntityTrack1 = pCGPMS->EntityTrack0; pCGPMS->EntityTrack0 = eid; return true; } NLMISC_COMMAND(removeTracks, "remove all entities tracks", "") { pCGPMS->Tracked.clear(); return true; } NLMISC_COMMAND(autoCheck, "perform autocheck", "") { CWorldPositionManager::autoCheck(&log); return true; } NLMISC_COMMAND(displayVisionCells, "display VisionCells info", "") { CWorldPositionManager::displayVisionCells(&log); return true; } // NLMISC_COMMAND(test_vision, "", "") { CVector centerPos(4700, -3500, 0); sint i, j, k=0; for (i=-7; i<=+7; ++i) { for (j=-7; j<=+7; ++j) { CEntityId id; id.setType( RYZOMID::npc ); sint32 x = (sint32)((centerPos.x+i*16)*1000); sint32 y = (sint32)((centerPos.y+j*16)*1000); id.setShortId( k+9000 ); ++k; TheMirror.addEntity( false, id ); TDataSetRow index = TheDataset.getDataSetRow(id); CWorldPositionManager::onAddEntity( index ); // because a local change is not notified //CWorldPositionManager::onAddEntity(id, 1000 * PosX, 1000*PosY, 1000*PosZ, 0.0f, INVALID_CONTINENT_INDEX, 0, CTickEventHandler::getGameCycle() - 1/*CTickEventHandler::getGameCycles()*/,/*sheet*/CSheetId(0),FeId); CWorldPositionManager::teleport( index, x, y, 0, 0.0f, INVALID_CONTINENT_INDEX, 0, CTickEventHandler::getGameCycle() ); } } CEntityId id; id.setType( RYZOMID::player ); sint32 x = (sint32)((centerPos.x)*1000); sint32 y = (sint32)((centerPos.y)*1000); id.setShortId( k+9000 ); ++k; TheMirror.addEntity( false, id ); TDataSetRow index = TheDataset.getDataSetRow(id); CWorldPositionManager::onAddEntity( index ); // because a local change is not notified //CWorldPositionManager::onAddEntity(id, 1000 * PosX, 1000*PosY, 1000*PosZ, 0.0f, INVALID_CONTINENT_INDEX, 0, CTickEventHandler::getGameCycle() - 1/*CTickEventHandler::getGameCycles()*/,/*sheet*/CSheetId(0),FeId); CWorldPositionManager::teleport( index, x, y, 0, 0.0f, INVALID_CONTINENT_INDEX, 0, CTickEventHandler::getGameCycle() ); return true; } NLMISC_COMMAND(dumpRingVisionUniverse, "dump state information from the ring vision universe", "") { if (!args.empty()) return false; pCGPMS->RingVisionUniverse->dump(log); return true; } NLMISC_COMMAND(resetRingVision, "resets a character's vision in ring mode", "") { if (args.size()!=1) return false; uint32 idx=NLMISC::CSString(args[0]).atoui(); TDataSetRow row(*(TDataSetRow*)&idx); pCGPMS->RingVisionUniverse->forceResetVision(row); return true; }