//============================================================================= // METHOD: SPELLipcDataChunk:: //============================================================================= int SPELLipcDataChunk::startChunks( const std::string& id, const DataList& data ) { SPELLmonitor m(m_lock); if (data.size()<=m_chunkSize) return 0; ListOfDataList* chunks = new ListOfDataList(); DataList::const_iterator it; DataList::const_iterator end = data.end(); unsigned int lineCount = 0; DataList* chunk = new DataList(); for( it = data.begin(); it != end; it++) { chunk->push_back( (*it) ); lineCount++; if (lineCount==m_chunkSize) { chunks->push_back( chunk ); chunk = new DataList(); lineCount = 0; } } // Add the last partial chunk if any if (chunk->size()>0) { chunks->push_back( chunk ); } m_chunks[id] = chunks; int totalChunks = chunks->size(); return totalChunks; }
void Auth2Certificate::AppendDataList( const DataList &theDataList ) { Auth2Certificate::DataListCIter anIter = theDataList.begin(); while( anIter != theDataList.end() ) { CertificateDataBlock *aBlock = (*anIter)->Duplicate(); mDataList.push_back( aBlock ); ++anIter; } }
//============================================================================= // METHOD: SPELLipcDataChunk:: //============================================================================= SPELLipcDataChunk::DataList SPELLipcDataChunk::getChunk( const std::string& id, unsigned int num ) { DataList chunk; DataMap::iterator it = m_chunks.find(id); if (it != m_chunks.end()) { ListOfDataList* chunks = it->second; if (num<chunks->size()) { DataList* list = (*chunks)[num]; DataList::iterator lit; for( lit = list->begin(); lit != list->end(); lit++) { chunk.push_back( (*lit) ); } } } return chunk; }
//Sort data void sortDataList(DataList& a) { sort(a.begin(),a.end(),myfunction); }
//====================================================================================================================== // // create player // bool MessageLib::sendCreatePlayer(PlayerObject* playerObject,PlayerObject* targetObject) { if(!_checkPlayer(targetObject)) return(false); sendCreateObjectByCRC(playerObject,targetObject,false); if(targetObject == playerObject) { sendBaselinesCREO_1(playerObject); sendBaselinesCREO_4(playerObject); } sendBaselinesCREO_3(playerObject,targetObject); sendBaselinesCREO_6(playerObject,targetObject); sendCreateObjectByCRC(playerObject,targetObject,true); sendContainmentMessage(playerObject->getPlayerObjId(),playerObject->getId(),4,targetObject); sendBaselinesPLAY_3(playerObject,targetObject); sendBaselinesPLAY_6(playerObject,targetObject); if(targetObject == playerObject) { sendBaselinesPLAY_8(playerObject,targetObject); sendBaselinesPLAY_9(playerObject,targetObject); } //close the yalp sendEndBaselines(playerObject->getPlayerObjId(),targetObject); sendPostureMessage(playerObject,targetObject); if(playerObject->getParentId()) { sendContainmentMessage(playerObject->getId(),playerObject->getParentId(),4,targetObject); } if(targetObject == playerObject) { // tangible objects if(TangibleObject* hair = dynamic_cast<TangibleObject*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Hair))) { //only create the hair as the helmet will be created at a different time if(hair->getTangibleType() == TanType_Hair) { sendCreateTangible(hair,targetObject); } } // create inventory and contents if(dynamic_cast<TangibleObject*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))) { sendInventory(playerObject); } // mission bag if(TangibleObject* missionBag = dynamic_cast<TangibleObject*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Mission))) { gMessageLib->sendCreateTangible(missionBag,playerObject); //Now iterate through the missions and create them clientside MissionBag* mbag = dynamic_cast<MissionBag*> (missionBag); MissionList::iterator it = mbag->getMissions()->begin(); while(it != mbag->getMissions()->end()) { MissionObject* mission = dynamic_cast<MissionObject*>(*it); sendCreateObjectByCRC(mission, targetObject, false); sendContainmentMessage(mission->getId(), mbag->getId(), 4, targetObject); sendBaselinesMISO_3(mission, targetObject); sendBaselinesMISO_6(mission, targetObject); sendBaselinesMISO_8(mission, targetObject); sendBaselinesMISO_9(mission, targetObject); sendEndBaselines(mission->getId(), targetObject); ++it; } } // datapad Datapad* datapad = playerObject->getDataPad(); if(datapad) { //would be nice to use the tangibles objectcontainer for the datapad //need to get missionobjects intangibles, Man Schematics, waypoints and stuff in though, so better do it manually gMessageLib->sendCreateTangible(datapad,playerObject); //now iterate through the schematics and create them clientside Datapad* dpad = dynamic_cast<Datapad*> (datapad); ManufacturingSchematicList* manufacturingSchematics = dpad->getManufacturingSchematics(); ManufacturingSchematicList::iterator it = manufacturingSchematics->begin(); while(it != manufacturingSchematics->end()) { gMessageLib->sendCreateManufacturingSchematic((dynamic_cast<ManufacturingSchematic*>(*it)),playerObject ,false); ++it; } //Send player's intangibles vehicles,pets,droids...etc DataList* intangibles = dpad->getData(); DataList::iterator ite = intangibles->begin(); while(ite != intangibles->end()) { if(IntangibleObject* itno = dynamic_cast<IntangibleObject*>(*ite)) { gMessageLib->sendCreateInTangible(itno, dpad->getId(), playerObject); //dont add it to the MainObjectMap //gWorldManager->addObject(itno,true); switch(itno->getItnoGroup()) { case ItnoGroup_Vehicle: { // set Owner for vehicles if(VehicleController* vehicle = dynamic_cast<VehicleController*>(itno)) { vehicle->set_owner(playerObject); } } break; default: break; } } ++ite; } //Should send accepted missions here } } //equipped items are already in the creo6 so only send them for ourselves sendEndBaselines(playerObject->getId(),targetObject); sendUpdatePvpStatus(playerObject,targetObject); if(targetObject == playerObject) { // We are actually sending this info from CharacterLoginHandler::handleDispatchMessage at the opCmdSceneReady event. // sendFriendListPlay9(playerObject); // sendIgnoreListPlay9(playerObject); //request the GRUP baselines from chatserver if grouped if(playerObject->getGroupId() != 0) { gMessageLib->sendIsmGroupBaselineRequest(playerObject); } } //Player mounts if(playerObject->checkIfMountCalled()) { if(playerObject->getMount()) { gMessageLib->sendCreateObject(playerObject->getMount(),targetObject); if(playerObject->checkIfMounted()) { gMessageLib->sendContainmentMessage(playerObject->getId(), playerObject->getMount()->getId(), 0xffffffff, targetObject); } } } return(true); }
string to_string(const DataList &list) { return Convert::to_string<'[', ']'>(list.begin(), list.end(), [](const ObjectPtr &obj) { return to_string(obj); }); }
int main() { #ifdef _DEBUG // When we have a memory leak, set this variable to // the allocation number (e.g. 122) and then we'll break // when that allocation occurs. //_crtBreakAlloc = 17366 ; _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif // _DEBUG { // create local scope to allow for local memory cleanup before we check at end // // create the test data // DataList* dataList = CreateEventTestData(); // // set up Soar // Kernel* kernel = Kernel::CreateKernelInNewThread(); Agent* agent = kernel->CreateAgent("Soar1"); RegisterForEvents(kernel, agent, dataList); // Load up TOH as a base set of rules. // Comment this out if we don't want any initial set of rules. //cout << kernel->ExecuteCommandLine("source ..\\..\\SoarLibrary\\Demos\\towers-of-hanoi\\towers-of-hanoi.soar", agent->GetAgentName()) << endl ; // // let the user do whatever they want // string command; do { cout << agent->GetAgentName() << "> "; getline(cin, command); // check for special commands if(command == "reset") { ResetEventCounts(dataList); cout << "counts reset" << endl; } else if(!command.compare(0, 6, "counts")) { string type = ""; if(command != "counts") { type = command.substr(7,command.length()-7); } PrintEventData(dataList, type); } else { cout << kernel->ExecuteCommandLine(command.c_str(), agent->GetAgentName()) << endl; } } while( (command != "quit") && (command != "exit") ); kernel->Shutdown(); delete kernel; // // Show results // PrintEventData(dataList); //string dummy; //cout << endl << endl << "Press any key and enter to continue"; //cin >> dummy; // // clean up // for(DataList::iterator i = dataList->begin(); i != dataList->end(); i++) { delete (*i); } delete dataList; } // end local scope return 0; }