CreatureObject* TurretDataComponent::selectTarget() {
	Vector<CreatureObject*> targets = getAvailableTargets(true);

	if (targets.size() == 0)
		return NULL;

	return targets.get(System::random(targets.size() - 1));
}
Example #2
0
void PlayerCreationManager::loadLuaStartingItems(Lua* lua) {
	// Catch potential errors from loading starting items.
	try {
		// Read professions.
		Vector < String > professions;
		LuaObject professionsLuaObject = lua->getGlobalObject("professions");
		for (int professionNumber = 1;
				professionNumber <= professionsLuaObject.getTableSize();
				professionNumber++) {
			professions.add(professionsLuaObject.getStringAt(professionNumber));
		}
		professionsLuaObject.pop();

		// Read profession specific items.
		LuaObject professionSpecificItems = lua->getGlobalObject(
				"professionSpecificItems");
		for (int professionNumber = 0; professionNumber < professions.size();
				professionNumber++) {
			LuaObject professionSpecificItemList =
					professionSpecificItems.getObjectField(
							professions.get(professionNumber));
			for (int itemNumber = 1;
					itemNumber <= professionSpecificItemList.getTableSize();
					itemNumber++) {
				professionDefaultsInfo.get(professions.get(professionNumber))->getStartingItems()->add(
						professionSpecificItemList.getStringAt(itemNumber));
			}
			professionSpecificItemList.pop();
		}
		professionSpecificItems.pop();

		// Read common starting items.
		LuaObject commonStartingItemsLuaObject = lua->getGlobalObject(
				"commonStartingItems");
		for (int itemNumber = 1;
				itemNumber <= commonStartingItemsLuaObject.getTableSize();
				itemNumber++) {
			commonStartingItems.add(
					commonStartingItemsLuaObject.getStringAt(itemNumber));
		}
		commonStartingItemsLuaObject.pop();
	} catch (Exception& e) {
		error("Failed to load starting items.");
		error(e.getMessage());
	}
}
Example #3
0
double RegularVector::distanceFrom(Vector& otherVector) const {
	unsigned maxDimension = std::max(get_dimension_count(), otherVector.get_dimension_count());
	double sum = 0;
	for(unsigned i = 0; i != maxDimension; i++)
		sum += std::pow(abs(get(i) - otherVector.get(i)), minkowskiParameter);
	return std::pow(sum, ((double)1)/((double)minkowskiParameter));
	//return std::sqrt(sum);
};
Example #4
0
void printVector(Vector vector)
{
	for (int i = 0; i < 10; i++)
	{
		cout << vector.get(i) << " ";
	}
	cout << endl;
}
Example #5
0
T
tc_sum(Vector<T, Block> vec)
{
  T sumval = T();
  for (index_type i=0; i<vec.size(0); ++i)
    sumval += vec.get(i);
  return sumval;
}
bool CreatureManagerImplementation::addWearableItem(CreatureObject* creature, TangibleObject* clothing) {

	if (!clothing->isWearableObject() && !clothing->isWeaponObject())
		return false;

	ChatManager* chatMan = zoneServer->getChatManager();

	SharedTangibleObjectTemplate* tanoData = dynamic_cast<SharedTangibleObjectTemplate*>(clothing->getObjectTemplate());
	Vector<uint32>* races = tanoData->getPlayerRaces();
	String race = creature->getObjectTemplate()->getFullTemplateString();

	if(clothing->isWearableObject()) {
		if (!races->contains(race.hashCode())) {
			UnicodeString message;

			if(creature->getObjectTemplate()->getFullTemplateString().contains("ithorian"))
				message = "@player_structure:wear_not_ithorian";
			else
				message = "@player_structure:wear_no";

			chatMan->broadcastMessage(creature, message, clothing->getObjectID(), creature->getMoodID(), 0);

			return false;
		}
	}

	ManagedReference<SceneObject*> clothingParent = clothing->getParent();

	if (clothingParent == NULL)
		return false;

	for (int i = 0; i < clothing->getArrangementDescriptorSize(); ++i) {
		Vector<String> descriptors = clothing->getArrangementDescriptor(i);

		for (int j = 0; j < descriptors.size(); ++j) {
			ManagedReference<SceneObject*> slot = creature->getSlottedObject(descriptors.get(j));

			if (slot != NULL) {
				slot->destroyObjectFromWorld(true);
				slot->destroyObjectFromDatabase(true);
			}
		}
	}

	creature->transferObject(clothing, 4, false);
	creature->doAnimation("pose_proudly");
	creature->broadcastObject(clothing, true);

	UnicodeString message;
	if(clothing->isWeaponObject())
		message = "@player_structure:wear_yes_weapon";
	else
		message = "@player_structure:wear_yes";

	chatMan->broadcastMessage(creature, message, clothing->getObjectID(), creature->getMoodID(), 0);

	return true;
}
Example #7
0
void PortalLayout::connectFloorMeshGraphs() {
	for (int i = 0; i < cellProperties.size(); ++i) {
		FloorMesh* floorMesh = getFloorMesh(i);

		if (floorMesh == NULL)
			continue;

		PathGraph* pathGraph = floorMesh->getPathGraph();

		if (pathGraph == NULL)
			continue;

		Vector<PathNode*> globalNodes = pathGraph->getGlobalNodes();

		for (int j = 0; j < globalNodes.size(); ++j) {
			PathNode* node = globalNodes.get(j);

			int globalID = node->getGlobalGraphNodeID();

			for (int k = 0; k < cellProperties.size(); ++k) {
				if (i != k) {
					FloorMesh* newMesh = getFloorMesh(k);

					if (newMesh != NULL) {
						PathGraph* newPathGraph = newMesh->getPathGraph();

						if (newPathGraph != NULL) {
							Vector<PathNode*> newGlobalNodes = newPathGraph->getGlobalNodes();

							for (int l = 0; l < newGlobalNodes.size(); ++l) {
								PathNode* newNode = newGlobalNodes.get(l);

								int newGlobalID = newNode->getGlobalGraphNodeID();

								if (globalID == newGlobalID)
									node->addChild(newNode);
							}
						}
					}
				}
			}
		}
	}

}
void HelpItemManager::moveItemFromQueueToActiveList(const ClientGame *game)
{
   TNLAssert(mPacedTimer.getCurrent() == 0 && mFloodControl.getCurrent() == 0, "Expected timers to be clear!");
   S32 itemToShow = 0;

   Vector<WeightedHelpItem> *items = NULL;
   
   bool useHighPriorityQueue = true;

   while(true)
   {
      items = useHighPriorityQueue ? &mHighPriorityQueuedItems : &mLowPriorityQueuedItems;

      if(items->size() <= itemToShow)
      {
         if(useHighPriorityQueue)      // High priority queue exhausted; switch to low priority queue
         {
            itemToShow = 0;
            useHighPriorityQueue = false;
            continue;
         }
         else                          // Low priority queue exhausted; nothing to show... go home
         {
            mPacedTimer.reset();       // Set this just so we don't keep hammering this function all day
            return;
         }
      }
  
      // Handle special case -- want to suppress, but not delete, this item if there are bots in the game
      if(items->get(itemToShow).helpItem == AddBotsItem && game->getBotCount() > 0)
      {
         itemToShow += 1;
         continue;
      }

      break;      // Exit our loop... we have our item list (items) and our itemToShow
   }


   HelpItem queuedMessage = items->get(itemToShow).helpItem;
   items->erase(itemToShow);

   addInlineHelpItem(queuedMessage, true);
   mPacedTimer.reset();
}
void ResourceSpawnImplementation::createSpawnMaps(bool jtl, int minpool, int maxpool,
		const String& zonerestriction, Vector<String>& activeZones) {

	int concentration = getConcentration(jtl);
	Vector<String> zonenames = getSpawnZones(minpool, maxpool, zonerestriction, activeZones);

	for (int i = 0; i < zonenames.size(); ++i) {

		Zone* zone = server->getZoneServer()->getZone(zonenames.get(i));
		if (zone == NULL)
			continue;

		SpawnDensityMap newMap(isType("ore"), concentration, zone->getMinX(),
				zone->getMaxX(), zone->getMinY(), zone->getMaxY());

		spawnMaps.put(zonenames.get(i), newMap);
	}
}
Example #10
0
void test_vector() {
    cout << "vector_test" << endl;
    Vector v;
    cout << "push " <<endl;
    srand(time(NULL));
    for(int i=0; i<Max; ++i) {
        a[i] = rand()%(Max*100);
        v.push(a[i]);
    }
    for(int i=0; i<Max; i++)
        cout << v.get(i) << "\t";

    cout << "pop \n";
    for(int i=0; i<Max; i++)
        v.pop_back();
    cout << v.get(0) << "\t";
    cout<<endl;
}
Example #11
0
Vector operator -(const Vector& a, const Vector& b){
    assert(a.size() == b.size());
    Vector v = Vector(a.size());

    for(int i = 0; i<v.size(); ++i)
        v[i] = a.get(i) - b[i];

    return v;
}
 static int cCcCc_cCcCc(int, char*, double, char, bool) {
     cout << "function c start" << endl;
     cout << endl;
     // error("blargh!");
     Vector<int> v;
     v.get(42);  // lolol
     cout << "function c end" << endl;
     return 0;
 }
Example #13
0
paramStruct* InfoPage::movetoNextEditParam(){
	Vector<paramStruct*> v = getallEditableParams();
	currentEditedParam++;
	if (currentEditedParam>=v.size()){
		currentEditedParam = 0;
	}
//	debugf("getNextEditParam next param is %i", currentEditedParam);
	return v.get(currentEditedParam);
}
Example #14
0
T
vector_sum(Vector<T, Block> v)
{
  // std::cout << "vector_sum(" << Block_name<Block>::name() << ")\n";
  T total = T();
  for (index_type i=0; i<v.length(); ++i)
    total += v.get(i);
  return total;
}
Example #15
0
bool containsWord(Vector<string> &v,string word)
{
	for(int i = 0; i < v.size(); i++){
		if(v.get(i) == word){
			return true;
		}
	}
	return false;
}
int ZoneImplementation::getInRangeObjects(float x, float y, float range, SortedVector<ManagedReference<QuadTreeEntry*> >* objects, bool readLockZone) {
	//Locker locker(_this.getReferenceUnsafeStaticCast());

	bool readlock = readLockZone && !_this.getReferenceUnsafeStaticCast()->isLockedByCurrentThread();

	Vector<ManagedReference<QuadTreeEntry*> > buildingObjects;

//	_this.getReferenceUnsafeStaticCast()->rlock(readlock);

	try {
		_this.getReferenceUnsafeStaticCast()->rlock(readlock);
		
		quadTree->inRange(x, y, range, *objects);
		
		_this.getReferenceUnsafeStaticCast()->runlock(readlock);
	} catch (...) {
		_this.getReferenceUnsafeStaticCast()->runlock(readlock);
	}

		for (int i = 0; i < objects->size(); ++i) {
			SceneObject* sceneObject = cast<SceneObject*>(objects->get(i).get());
			BuildingObject* building = dynamic_cast<BuildingObject*>(sceneObject);

			if (building != NULL) {
				for (int j = 1; j <= building->getMapCellSize(); ++j) {
					CellObject* cell = building->getCell(j);

					if (cell != NULL) {
					try {
							ReadLocker rlocker(cell->getContainerLock());

							for (int h = 0; h < cell->getContainerObjectsSize(); ++h) {
								ManagedReference<SceneObject*> obj = cell->getContainerObject(h);
								
								if (obj != NULL)
									buildingObjects.add(obj.get());
								}
						
						} catch (...) {
					}
					}
				}
			} else if (sceneObject != NULL && (sceneObject->isVehicleObject() || sceneObject->isMount())) {
				ManagedReference<SceneObject*> rider = sceneObject->getSlottedObject("rider");

				if (rider != NULL)
					buildingObjects.add(rider.get());
			}
		}

	//_this.getReferenceUnsafeStaticCast()->runlock(readlock);

	for (int i = 0; i < buildingObjects.size(); ++i)
		objects->put(buildingObjects.get(i));

	return objects->size();
}
Reference<CallArakydTask*> BountyHunterDroid::callArakydDroid(SceneObject* droidObject, CreatureObject* player, MissionObject* mission) {
	if (mission->getMissionLevel() < 3) {
		player->sendSystemMessage("@mission/mission_generic:bounty_no_ability"); // You do not understand how to use this item.
		return NULL;
	}

	if (mission->getMissionObjective() == NULL) {
		player->sendSystemMessage("@mission/mission_generic:bounty_no_mission"); // You must accept a bounty mission before you can use a probe droid.
		return NULL;
	}

	ManagedReference<BountyMissionObjective*> objective = cast<BountyMissionObjective*>(mission->getMissionObjective());

	if (objective == NULL || objective->getObjectiveStatus() == BountyMissionObjective::INITSTATUS) {
		player->sendSystemMessage("@mission/mission_generic:bounty_no_signature");// You must go speak with your informant before you can track your target.
		return NULL;
	}

	if (objective->getArakydDroid() != NULL) {
		player->sendSystemMessage("@mission/mission_generic:probe_droid_too_many"); // You cannot launch another probe droid.
		return NULL;
	}

	Vector<ManagedReference<ActiveArea*> >* areas = player->getActiveAreas();
	for (int i = 0; i < areas->size(); i++) {
		if (areas->get(i)->isMunicipalZone()) {
			player->sendSystemMessage("@mission/mission_generic:probe_droid_bad_location"); // You must move to a different area to call down a probe droid from orbit.
			return NULL;
		}
	}

	if (player->isRidingMount()) {
		player->sendSystemMessage("@error_message:survey_on_mount"); // You cannot perform that action while mounted on a creature or driving a vehicle.
		return NULL;
	}

	Reference<CallArakydTask*> task = new CallArakydTask(player, cast<BountyMissionObjective*>(mission->getMissionObjective()));

	Core::getTaskManager()->executeTask(task);

	//Temporary set the arakyd droid to the player object. The call task will overwrite it with correct value.
	//This is needed to prevent the player from launching more than one droid at a time.
	objective->setArakydDroid(player);

	Locker locker(droidObject);

	TangibleObject* tano = cast<TangibleObject*>(droidObject);

	if(tano != NULL){
		tano->setUseCount(tano->getUseCount() - 1, true);
	} else {
		droidObject->destroyObjectFromWorld(true);
	}

	return task;
}
void ProceduralTerrainAppearance::translateBoundaries(Layer* layer, float x, float y) {
	Vector<Boundary*>* boundaries = layer->getBoundaries();

	for (int j = 0; j < boundaries->size(); ++j) {
		Boundary* boundary = boundaries->get(j);

		boundary->translateBoundary(x, y);
	}

	Vector<Layer*>* children = layer->getChildren();

	for (int i = 0; i < children->size(); ++i) {
		Layer* child = children->get(i);

		if (child->isEnabled()) {
			translateBoundaries(child, x, y);
		}
	}
}
Example #19
0
 int pop() {
     int res = a.get(start);
     start++;
     --cnt;
     if (a.reduce(start, end)) {
         start = 0;
         end = cnt - 1;
     }
     return res;
 }
Example #20
0
void TestVector::insert()
{
	tools->setFunctionName("insert");
	{
		Vector<int> instance;
		instance.insert(0,5);
		tools->assertEquals(instance.get(0),5);
		instance.insert(2,3);
		tools->assertEquals(instance.get(2),3);
	}
	{
		Vector<const char *> instance;
		instance.insert(0,"Clem");
		tools->assertEquals(instance.get(0),"Clem");
		instance.insert(2,"Davies");
		tools->assertEquals(instance.get(2),"Davies");
		tools->assertEquals(instance.getSize(),(unsigned)2);
	}
}
Example #21
0
/*
 * Function: createBoard()
 * --------------------------
 * Create the board by randomly arranging the cubes and randomly picking a face for each.
 * Return the grid of chosen characters and display graphically.
 */
Grid<char> createBoard(int size){
	//setRandomSeed(1); //makes run behavior identical each time through
	//the final output
	Grid<char> board(size, size);
	/*fill a vector with the appropriate cubes*/
	Vector<string> myVector;
	if (size==4){
		int length = sizeof STANDARD_CUBES/sizeof STANDARD_CUBES[0];
		for (int i = 0; i < length; i++)
			myVector.add(STANDARD_CUBES[i]);
	}
	if (size==5){
		int length = sizeof BIG_BOGGLE_CUBES/sizeof BIG_BOGGLE_CUBES[0];
		for (int i = 0; i < length; i++)
			myVector.add(BIG_BOGGLE_CUBES[i]);
	}
	 /*randomly reorder the cubes*/
	for (int i = 0; i < myVector.size(); i++){
		int r = randomInteger(i,myVector.size()-1);
		string cubeI = myVector.get(i);
		string cubeR = myVector.get(r);
		myVector.set(i,cubeR);
		myVector.set(r,cubeI);
	}
	/*randomly select which face is up for each cube*/
	for (int i = 0; i < myVector.size(); i++){
		string letters = myVector.get(i);
		int r = randomInteger(0,5);
		string choice = letters.substr(r,1);
		myVector.set(i, choice);
	}
	/*convert vector<string> to grid<char> and apply the values to the graphic cubes*/
	int index = 0;
	for (int row = 0; row < (int)sqrt((double)myVector.size()); row++){
		for( int col = 0; col < (int)sqrt((double)myVector.size()); col++){
			string letterStr = myVector.get(index);
			board[row][col] = letterStr[0];
			labelCube(row,col,letterStr[0]);
			index++;
		}
	}	
	return board;
}
Example #22
0
TEST_F(LuaMobileTest, LuaMobileTemplatesTest) {
	CreatureTemplateManager::DEBUG_MODE = 1;

	// Verify that all mobiles load
	ASSERT_EQ(CreatureTemplateManager::instance()->loadTemplates(), 0);

	// Verify loot group map loads
	LootGroupMap* lootGroupMap = LootGroupMap::instance();
	ASSERT_EQ(lootGroupMap->initialize(), 0);

	HashTableIterator<uint32, Reference<CreatureTemplate*> > iter = CreatureTemplateManager::instance()->iterator();
	while (iter.hasNext()) {
		CreatureTemplate* creature = iter.next();
		std::string templateName( creature->getTemplateName().toCharArray() );

		// Verify loot group percentages
		LootGroupCollection* groupCollection = creature->getLootGroups();
		if( groupCollection->count() > 0 ){


			for( int i = 0; i < groupCollection->count(); i++ ){

				LootGroupCollectionEntry* collectionEntry = groupCollection->get(i);
				LootGroups* groups = collectionEntry->getLootGroups();
				if( groups->count() > 0){

					int totalChance = 0;
					for( int j = 0; j < groups->count(); j++ ){

						LootGroupEntry* lootGroup = groups->get(j);
						totalChance += lootGroup->getLootChance();

						// Verify loot group is configured correctly
						LootGroupTemplate* foundGroup = lootGroupMap->getLootGroupTemplate( lootGroup->getLootGroupName() );
						std::string groupName( lootGroup->getLootGroupName().toCharArray() );
						EXPECT_TRUE( foundGroup != NULL ) << "Loot group " << groupName << " from " << templateName << " was not found in LootGroupMap";

					}

					EXPECT_EQ( 10000000, totalChance ) << "Loot groups total chance is incorrect " << templateName;
				}
			}
		}

		// Verify weapon groups exist
		Vector<String> weapons = creature->getWeapons();
		for (int i = 0; i < weapons.size(); i++) {
			String weaponGroup = weapons.get(i);
			std::string groupName( weaponGroup.toCharArray() );
			Vector<String> group = CreatureTemplateManager::instance()->getWeapons(weaponGroup);
			EXPECT_TRUE( group.size() > 0 ) << "Weapon group " << groupName << " from " << templateName << " was not found in weaponMap";
		}
	}

}
void PathFinderManager::addTriangleNodeEdges(const Vector3& source, const Vector3& goal, Vector<Triangle*>* trianglePath, Vector<WorldCoordinates>* path, CellObject* cell) {
	Vector3 startPoint = Vector3(source.getX(), source.getZ(), source.getY());
	Vector3 goalPoint = Vector3(goal.getX(), goal.getZ(), goal.getY());

	Vector<Vector3>* funnelPath = Funnel::funnel(startPoint, goalPoint, trianglePath);

	/*info("found funnel size: " + String::valueOf(funnelPath->size()));
	info("triangle number: " + String::valueOf(trianglePath->size()));

	StringBuffer objectFoorBarSource;
	objectFoorBarSource << "funnel source point x:" << source.getX() << " z:" << source.getZ() << " y:" << source.getY();
	info(objectFoorBarSource.toString(), true);*/

	for (int i = 1; i < funnelPath->size() - 1; ++i) { //without the start and the goal
		/*Vector3 worldPosition = path->get(i);

		StringBuffer objectFoorBar;
		objectFoorBar << "funnel node point x:" << worldPosition.getX() << " z:" << worldPosition.getZ() << " y:" << worldPosition.getY();
		info(objectFoorBar.toString(), true);*/

		Vector3 pathPoint = funnelPath->get(i);

		//switch y<->x
		pathPoint.set(pathPoint.getX(), pathPoint.getY(), pathPoint.getZ());

		/*StringBuffer objectFoorBar;
		objectFoorBar << "funnel node point x:" << pathPoint.getX() << " z:" << pathPoint.getZ() << " y:" << pathPoint.getY();
		info(objectFoorBar.toString(), true);*/

		path->add(WorldCoordinates(pathPoint, cell));
	}

	/*StringBuffer objectFoorBarGoal;
	objectFoorBarGoal << "funnel goal point x:" << goal.getX() << " z:" << goal.getZ() << " y:" << goal.getY();
	info(objectFoorBarGoal.toString(), true);*/

	delete funnelPath;



	/*for (int i = 0; i < trianglePath->size(); ++i) {
		TriangleNode* node = trianglePath->get(i);

		//if (!node->isEdge()) // adding only edge nodes
			//continue;

		Vector3 pathBary = node->getBarycenter();

		//switch y<->x
		pathBary.set(pathBary.getX(), pathBary.getY(), pathBary.getZ());

		path->add(WorldCoordinates(pathBary, cell));
	}*/
}
Example #24
0
	bool Vector::operator== ( const Vector& that ) const {
		// later GSL:
		// return 0 != gsl_vector_equal( &vector, &that.vector );
		// earlier GSL: (not performance optimised, but anyway used only for testing)
		// TODO: make it more efficient
		const size_t dims = countDimensions();
		if ( dims != that.countDimensions() ) return false;
		for ( size_t dim = 0; dim < dims; ++dim ) {
			if ( get( dim ) !=  that.get( dim ) ) return false;
		}
		return true;
	}
void MissionObjectiveImplementation::awardReward() {
	Vector<ManagedReference<CreatureObject*> > players;
	PlayMusicMessage* pmm = new PlayMusicMessage("sound/music_mission_complete.snd");

	Vector3 missionEndPoint = getEndPosition();

	ManagedReference<CreatureObject*> owner = getPlayerOwner();

	ManagedReference<GroupObject*> group = owner->getGroup();

	if (group != NULL) {
		Locker lockerGroup(group, _this.get());

		for(int i = 0; i < group->getGroupSize(); i++) {
			Reference<CreatureObject*> groupMember = group->getGroupMember(i)->isPlayerCreature() ? (group->getGroupMember(i)).castTo<CreatureObject*>() : NULL;

			if (groupMember != NULL) {
				//Play mission complete sound.
				groupMember->sendMessage(pmm->clone());

				if (groupMember->getWorldPosition().distanceTo(missionEndPoint) < 128) {
					players.add(groupMember);
				}
			}
		}

		delete pmm;
	} else {
		//Play mission complete sound.
		owner->sendMessage(pmm);
		players.add(owner);
	}

	if (players.size() == 0) {
		players.add(owner);
	}

	ManagedReference<MissionObject* > mission = this->mission.get();

	int dividedReward = mission->getRewardCredits() / players.size();

	for (int i = 0; i < players.size(); i++) {
		ManagedReference<CreatureObject*> player = players.get(i);
		StringIdChatParameter stringId("mission/mission_generic", "success_w_amount");
		stringId.setDI(dividedReward);
		player->sendSystemMessage(stringId);

		Locker lockerPl(player, _this.get());
		player->addBankCredits(dividedReward, true);
	}

	StatisticsManager::instance()->completeMission(mission->getTypeCRC() ,mission->getRewardCredits());
}
string generatePermutations(Vector<string> keyPresses, Vector<char> output, int index) {
	string result;
	if (index == keyPresses.size()) {
		string str;
		for (int i = 0; i < output.size(); i++) {
			str += output[i];
		}
		return str;
	}

	for (int i = 0; i < keyPresses.get(index)[i]; i++) {
		output[index] = keyPresses.get(index)[i];
		result += generatePermutations(keyPresses, output, index + 1) + " ";
		if (keyPresses.get(index) == "0") {
			return "0";
		} else if (keyPresses.get(index) == "1") {
			return "1";
		}
	}
	return result;

}
Example #27
0
int LuaPlayerObject::getHologrindProfessions(lua_State* L) {
	Vector<byte>* professions = realObject->getHologrindProfessions();

	lua_newtable(L);
	for (int i = 0; i < professions->size(); i++) {
		lua_pushnumber(L, professions->get(i));
	}
	for (int i = professions->size(); i > 0; i--) {
		lua_rawseti(L, -i - 1, i);
	}

	return 1;
}
Example #28
0
int close(int fildes)
{
    Vector<FileDescriptor> *fds = getFiles();
    FileDescriptor *fd = ZERO;

    if ((fd = (FileDescriptor *) fds->get(fildes)) == ZERO || !fd->open)
    {
        errno = ENOENT;
        return -1;
    }
    fd->open = false;
    return 0;
}
Example #29
0
void dumpIntVector(Vector<UINT> & v)
{
    if (g_tfile == NULL) return;
    fprintf(g_tfile, "\n");
    for (INT i = 0; i <= v.get_last_idx(); i++) {
        UINT x = v.get(i);
        if (x == 0) {
            fprintf(g_tfile, "0,");
        } else {
            fprintf(g_tfile, "0x%x,", x);
        }
    }
    fflush(g_tfile);
}
Example #30
0
void SkillManager::removeAbilities(PlayerObject* ghost, Vector<String>& abilityNames, bool notifyClient) {
	Vector<Ability*> abilities;

	for (int i = 0; i < abilityNames.size(); ++i) {
		String abilityName = abilityNames.get(i);

		Ability* ability = abilityMap.get(abilityName);

		if (ability != NULL && ghost->hasAbility(abilityName))
			abilities.add(ability);
	}

	ghost->removeAbilities(abilities, notifyClient);
}