///init void CAIService::init (void) { // start any available system command. CConfigFile::CVar *sysCmds = IService::getInstance()->ConfigFile.getVarPtr("SystemCmd"); if (sysCmds != NULL) { for (uint i=0; i<sysCmds->size(); ++i) { string cmd = sysCmds->asString(i); nlinfo("Invoking system command '%s'...", cmd.c_str()); int ret = system(cmd.c_str()); nlinfo(" command returned %d", ret); } } // read sheet_id.bin and don't prune out unknown files CSheetId::init(false); // Init singleton manager CSingletonRegistry::getInstance()->init(); // init static fame manager CStaticFames::getInstance(); setVersion (RYZOM_VERSION); // Init ligo if (!LigoConfig.readPrimitiveClass ("world_editor_classes.xml", false)) { // Should be in l:\leveldesign\world_editor_files nlerror ("Can't load ligo primitive config file world_editor_classes.xml"); } // have ligo library register its own class types for its class factory NLLIGO::Register(); // setup the update systems setUpdateTimeout(100); // init sub systems CAIKeywords::init(); CMirrors::init(cbTick, NULL, cbTickRelease); CMessages::init(); AISHEETS::CSheets::getInstance()->init(); // initialise the AI_SHARE library AI_SHARE::init(&LigoConfig); // set the primitive context NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &LigoConfig; CAISActions::init(); CEGSInterface::init(); CTimeInterface::init(); CCombatInterface::init(); CVisualPropertiesInterface::init(); CAIDSInterface::init(); // register the service up and service down callbacks CMirrors::Mirror.setServiceMirrorUpCallback("*", cbServiceMirrorUp, 0); CMirrors::Mirror.setServiceDownCallback( "*", cbServiceDown, 0); // CUnifiedNetwork::getInstance()->setServiceDownCallback( "*", cbServiceDown, 0); CConfigFile::CVar *clientCreature=IService::getInstance()->ConfigFile.getVarPtr ("CreatureDebug"); if (clientCreature) { CAIS::instance().setClientCreatureDebug(clientCreature->asInt()!=0); } }
// init the service void CGlobalPositionManagerService::init() { setVersion (RYZOM_VERSION); // keep pointer on class pCGPMS = this; // set update time out setUpdateTimeout(100); CUnifiedNetwork::getInstance()->setServiceUpCallback( string("*"), cbConnection, 0); CUnifiedNetwork::getInstance()->setServiceUpCallback( "EGS", cbEGSConnection, 0); CUnifiedNetwork::getInstance()->setServiceUpCallback( "EVS", cbEVSConnection, 0); CUnifiedNetwork::getInstance()->setServiceDownCallback( string("*"), cbDisconnection, 0); CUnifiedNetwork::getInstance()->setServiceDownCallback( "EVS", cbEVSDisconnection, 0); uint32 WorldMapSizeX; uint32 WorldMapSizeY; uint32 VisionDistance; uint32 PrimitiveMaxSize; uint32 NbWorldImages; bool LoadPacsPrims; bool LoadPacsCol; // init the class transport system TRANSPORT_CLASS_REGISTER (CGPMPlayerPrivilegeInst); GET_VAR_FROM_CF(CheckPlayerSpeed, true); GET_VAR_FROM_CF(Verbose, false); GET_VAR_FROM_CF(WorldMapSizeX, 2100); GET_VAR_FROM_CF(WorldMapSizeY, 2970); GET_VAR_FROM_CF(VisionDistance, 250000); GET_VAR_FROM_CF(PrimitiveMaxSize, 8); GET_VAR_FROM_CF(NbWorldImages, 31); GET_VAR_FROM_CF(LoadPacsCol, false); GET_VAR_FROM_CF(LoadPacsPrims, true); CSheets::init(); // World Position Manager init if (!IsRingShard) { CWorldPositionManager::init(WorldMapSizeX, WorldMapSizeY, VisionDistance, PrimitiveMaxSize, (uint8)NbWorldImages, LoadPacsPrims, LoadPacsCol); } // Init ligo if (!LigoConfig.readPrimitiveClass ("world_editor_classes.xml", false)) { // Should be in l:\leveldesign\world_editor_files nlerror ("Can't load ligo primitive config file world_editor_classes.xml"); } /* // read the continent name translator map<string, string> translator; { CConfigFile::CVar *v = IService::getInstance()->ConfigFile.getVarPtr("ContinentNameTranslator"); if (v) { for (sint i=0; i<v->size()/2; ++i) { string s1, s2; s1 = v->asString(i*2); s2 = v->asString(i*2+1); translator[s1] = s2; } } } */ // todo: r2 GPMS doesn't read pacs for now - this will have to be fixed later if (!IsRingShard) { // init continents try { CUsedContinent::TUsedContinentCont continents = CUsedContinent::instance().getContinents(); // CConfigFile::CVar& cvUsedContinents = ConfigFile.getVar("UsedContinents"); // uint i; // for (i=0; (sint)i<cvUsedContinents.size(); ++i) // if (cvUsedContinents.asString(i) != "") for (uint i=0; i<continents.size(); ++i) { string name = continents[i].ContinentName; name = CUsedContinent::instance().getPhysicalContinentName(name); // if (translator.find(name) != translator.end()) // name = translator[name]; // CWorldPositionManager::loadContinent(cvUsedContinents.asString(i), cvUsedContinents.asString(i), i); CWorldPositionManager::loadContinent(name, continents[i].ContinentName, continents[i].ContinentInstance); } } catch(const EUnknownVar &) { nlwarning("<CGlobalPositionManagerService::init> UsedContinents not found, no continent used"); } } NLLIGO::Register(); CMessages::init(); CClientMessages::init(); // if (!IsRingShard) { CWorldPositionManager::initPatatManager(); } // Init the mirror system vector<string> datasetNames; datasetNames.push_back( "fe_temp" ); Mirror.init( datasetNames, cbMirrorIsReady, gpmsUpdate, cbSync ); Mirror.setServiceMirrorUpCallback( "EGS", cbEGSConnection, 0); setCrashCallback(crashCallback); if (IsRingShard) { // setup the R2 Vision object and move checker object pCGPMS->RingVisionDeltaManager=new CVisionDeltaManager; pCGPMS->RingVisionUniverse= new R2_VISION::CUniverse; pCGPMS->RingVisionUniverse->registerVisionDeltaManager(RingVisionDeltaManager); pCGPMS->MoveChecker= new CMoveChecker; } } // init //
/* * init() */ bool CPrimChecker::build(const string &primitivesPath, const string &igLandPath, const string &igVillagePath, const string &outputDirectory, bool forceRebuild) { if (Verbose) nlinfo("Checking pacs.packed_prims consistency"); NLLIGO::Register(); // Init ligo if (!LigoConfig.readPrimitiveClass ("world_editor_classes.xml", false)) { // Should be in l:\leveldesign\world_edit_files nlwarning ("Can't load ligo primitive config file world_editor_classes.xml"); return false; } uint i, j; string outputfname = CPath::standardizePath(outputDirectory)+"pacs.packed_prims"; _Grid.clear(); vector<string> files; CPath::getPathContent(primitivesPath, true, false, true, files); for (i=0; i<files.size(); ++i) { if (CFile::getExtension(files[i]) == "primitive") { readFile(files[i]); } } files.clear(); CPath::getPathContent(igLandPath, true, false, true, files); CPath::getPathContent(igVillagePath, true, false, true, files); set<string> noWaterShapes; for (i=0; i<files.size(); ++i) { try { // load ig associated to the zone string igname = files[i]; string ignamelookup = CPath::lookup(igname); //nlinfo("Reading ig '%s'", ignamelookup.c_str()); CIFile igStream(ignamelookup); CInstanceGroup ig; igStream.serial(ig); // search in group for water instance for (j=0; j<ig._InstancesInfos.size(); ++j) { string shapeName = ig._InstancesInfos[j].Name; if (CFile::getExtension (shapeName) == "") shapeName += ".shape"; if (noWaterShapes.find(shapeName) != noWaterShapes.end()) continue; string shapeNameLookup = CPath::lookup (shapeName, false, false); if (!shapeNameLookup.empty()) { CIFile f; if (f.open (shapeNameLookup)) { CShapeStream shape; shape.serial(f); CWaterShape *wshape = dynamic_cast<CWaterShape*>(shape.getShapePointer()); if (wshape == NULL) { noWaterShapes.insert(shapeName); continue; } //nlinfo("Render water shape '%s'", shapeNameLookup.c_str()); CMatrix matrix; ig.getInstanceMatrix(j, matrix); CPolygon wpoly; //wshape->getShapeInWorldSpace(wpoly); CPolygon2D wpoly2d = wshape->getShape(); uint k; for (k=0; k<wpoly2d.Vertices.size(); ++k) { wpoly.Vertices.push_back(matrix * wpoly2d.Vertices[k]); } float zwater = wpoly.Vertices[0].z - WaterThreshold; uint16 idx = (uint16)_WaterHeight.size(); _WaterHeight.push_back(zwater); render(wpoly, idx); if (Verbose) nlinfo("Rendered water shape '%s' in instance '%s'", CFile::getFilenameWithoutExtension(shapeName).c_str(), CFile::getFilenameWithoutExtension(igname).c_str()); } else if (Verbose) { noWaterShapes.insert(shapeName); nlwarning ("Can't load shape %s", shapeNameLookup.c_str()); } } else if (Verbose) { noWaterShapes.insert(shapeName); nlwarning ("Can't find shape %s", shapeName.c_str()); } } } catch (const Exception &e) { nlwarning("%s", e.what()); } } COFile f; if (f.open(outputfname)) { f.serial(_Grid); f.serialCont(_WaterHeight); } else { nlwarning("Couldn't save pacs.packed_prims file '%s'", outputfname.c_str()); } return true; }